npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

single-select-react-jc

v2.0.4

Published

React single select component

Downloads

66

Readme

single-select-react-jc

Tiny (19kB) react single-select drop down component.

Install

$ npm install --save single-select-react-jc

Usage

Basic

import SelectMenu from 'single-select-react-jc'

<SelectMenu data={data} />

If no data provided, component will be visible but disabled

Data Format

Can be either a list of arrays or list of objects.

export const carsArray = [
  ['BMW','./images/bmw.jpeg'],
  ['Honda','./images/honda.png'],
  ['Toyota','./images/toyota.jpeg'],
  ['Nissan','./images/nissan.jpeg'],
  ['Chevrolet','./images/chevy.png'],
  ['Ford','./images/ford.png'],
  ['Ferrari','./images/ferrari.jpeg'],
  ['Lamborghini','./images/lambo.jpeg']
];

export const animeObject = [
  {'value': 'Jujutsu Kaisen', 'logo': './images/jjk.jpeg'},
  {'value': 'One Piece', 'logo': './images/onepiece.jpeg'},
  {'value': 'Naruto', 'logo': './images/naruto.jpeg'},
  {'value': 'Attack on Titan', 'logo': './images/AoT.jpeg'},
  {'value': 'Food Wars', 'logo': './images/fw.jpeg'},
  {'value': 'Pokemon', 'logo': './images/pikachu.jpeg'},
  {'value': 'My Hero Acadamia', 'logo': './images/mha.jpeg'}
];

Nested objects supported.

export const countriesObj = [
  {
    'value': 'USA',
    'logo': "https://www.countries-ofthe-world.com/flags-normal/flag-of-United-States-of-America.png",
    'subOptions': [
      {
        'value': 'San Jose',
        'logo': 'https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Flag_of_San_Jos%C3%A9%2C_California.svg/255px-Flag_of_San_Jos%C3%A9%2C_California.svg.png',
        'subOptions': [],
      },
      {
        'value': 'San Francisco',
        'logo': 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/af/Flag_of_San_Francisco.svg/255px-Flag_of_San_Francisco.svg.png',
        'subOptions': [],
      },
      {
        'value': 'Los Angeles',
        'logo': 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/85/Flag_of_Los_Angeles%2C_California.svg/1200px-Flag_of_Los_Angeles%2C_California.svg.png',
        'subOptions': [],
      },
      {
        'value': 'San Diego',
        'logo': 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/19/Flag_of_San_Diego%2C_California.svg/1200px-Flag_of_San_Diego%2C_California.svg.png',
        'subOptions': [],
      },
      {
        'value': 'Tehachapi',
        'logo': 'https://media-cdn.tripadvisor.com/media/photo-s/02/66/e1/91/filename-railroad-watertower.jpg',
        'subOptions': [],
      },
    ]
  },
  {
    'value': 'Japan',
    'logo': 'https://i.pinimg.com/originals/7a/3d/90/7a3d9097761a637b3be29cd0dc6f7971.jpg',
    'subOptions': [
      {
        'value': 'Tokyo',
        'logo': 'https://www.crwflags.com/fotw/images/j/jp-13.gif',
        'subOptions': [],
      },
      {
        'value': 'Kyoto',
        'logo': 'https://www.crwflags.com/fotw/images/j/jp-26.gif',
        'subOptions': [],
      },
      {
        'value': 'Osaka',
        'logo': 'https://www.crwflags.com/fotw/images/j/jp-27.gif',
        'subOptions': [],
      },
    ]
  },
  {
    'value': 'Germany',
    'logo': 'https://www.countries-ofthe-world.com/flags-normal/flag-of-Germany.png',
    'subOptions': [
      {
        'value': 'Munich',
        'logo': 'https://www.crwflags.com/fotw/images/d/de-ba-m1.gif',
        'subOptions': [],
      },
      {
        'value': 'Berlin',
        'logo': 'https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Flag_of_Berlin.svg/1200px-Flag_of_Berlin.svg.png',
        'subOptions': [],
      },
      {
        'value': 'Frankfurt',
        'logo': 'https://upload.wikimedia.org/wikipedia/commons/2/2e/Flag_of_the_Free_City_of_Frankfurt.svg',
        'subOptions': [],
      },
    ]
  },
  {
    'value': 'Wakanda',
    'logo': 'https://i.redd.it/yvzgtslorrg01.png',
    'subOptions': [],
  },
];

SubOption name can be specified by user

export const countriesArr = [
  [
    'USA',
    'https://www.countries-ofthe-world.com/flags-normal/flag-of-United-States-of-America.png',
    [
      [
        'San Jose',
        'https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Flag_of_San_Jos%C3%A9%2C_California.svg/255px-Flag_of_San_Jos%C3%A9%2C_California.svg.png',
        []
      ],
      [
        'San Francisco',
        'https://upload.wikimedia.org/wikipedia/commons/thumb/a/af/Flag_of_San_Francisco.svg/255px-Flag_of_San_Francisco.svg.png',
        []
      ],
      [
        'Los Angeles',
        'https://upload.wikimedia.org/wikipedia/commons/thumb/8/85/Flag_of_Los_Angeles%2C_California.svg/1200px-Flag_of_Los_Angeles%2C_California.svg.png',
        []
      ],
      [
        'San Diego',
        'https://upload.wikimedia.org/wikipedia/commons/thumb/1/19/Flag_of_San_Diego%2C_California.svg/1200px-Flag_of_San_Diego%2C_California.svg.png',
        []
      ],
      [
        'Tehachapi',
        'https://media-cdn.tripadvisor.com/media/photo-s/02/66/e1/91/filename-railroad-watertower.jpg',
        []
      ]
    ]
  ],
  [
    'Japan',
    'https://i.pinimg.com/originals/7a/3d/90/7a3d9097761a637b3be29cd0dc6f7971.jpg',
    [
      [
        'Tokyo',
        'https://www.crwflags.com/fotw/images/j/jp-13.gif',
        []
      ],
      [
        'Kyoto',
        'https://www.crwflags.com/fotw/images/j/jp-26.gif',
        []
      ],
      [
        'Osaka',
        'https://www.crwflags.com/fotw/images/j/jp-27.gif',
        []
      ]
    ]
  ],
  [
    'Germany',
    'https://www.countries-ofthe-world.com/flags-normal/flag-of-Germany.png',
    [
      [
        'Munich',
        'https://www.crwflags.com/fotw/images/d/de-ba-m1.gif',
        []
      ],
      [
        'Berlin',
        'https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Flag_of_Berlin.svg/1200px-Flag_of_Berlin.svg.png',
        []
      ],
      [
        'Frankfurt',
        'https://upload.wikimedia.org/wikipedia/commons/2/2e/Flag_of_the_Free_City_of_Frankfurt.svg',
        []
      ],
    ]
  ],
  [
    'Wakanda',
    'https://i.redd.it/yvzgtslorrg01.png',
    []
  ]
];

Demo

Edit single-select-react-jc

API

Props

Name | Default | Type | Description -----|---------|------|------------ centered | false | {bool} | Center component in parent container disabled | false | {bool} | Show component as disabled floated | | {enum} | Position component in parent containerEnums:left right hidden | | {bool} | Component visibility hidden name | | {string} | Name of input element onChange | | {func} | Set parent variable on change onClick | | {func} | Set parent variable on click placeholder | | {string} | Placeholder text size | | {enum} | Component width within parent containerEnums:mini small medium full striped | | {enum} | Alternate striping of menu optionsEnums:lightgrey lightcyan lightgreen lightpink sub | | {string} | User-specified keyword for subcategory

Accessibility

  • Tab focuses to component
  • Keyboard Up / Down arrow navigation
  • Enter selects first matching option
  • Esc closes menu

Development

npm install
npm run react-dev
npm start (http://localhost:3003)

License

single-select-react-jc is released under the ISC license.