All Projects → spacejack → mithril-select

spacejack / mithril-select

Licence: MIT License
Custom Select Component for Mithril.js

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects
HTML
75241 projects

Projects that are alternatives of or similar to mithril-select

vue-tags-component
Vue.js 2+ tags component
Stars: ✭ 27 (+92.86%)
Mutual labels:  select, dropdown
insect
🛠 Highly customisable, minimalistic input x select field for React.
Stars: ✭ 33 (+135.71%)
Mutual labels:  select, dropdown
tagselector
Dependency-free JS library that turns select fields in customizable tag clouds
Stars: ✭ 19 (+35.71%)
Mutual labels:  select, dropdown
React Dropdown Select
Customisable dropdown select for react
Stars: ✭ 227 (+1521.43%)
Mutual labels:  select, dropdown
vue-single-select
single select dropdown with autocomplete
Stars: ✭ 43 (+207.14%)
Mutual labels:  select, dropdown
React Native Dropdown Picker
A single / multiple, categorizable & searchable item picker (dropdown) component for react native which supports both Android & iOS.
Stars: ✭ 230 (+1542.86%)
Mutual labels:  select, dropdown
choc-autocomplete
🏇 Autocomplete Component Package for Chakra UI
Stars: ✭ 286 (+1942.86%)
Mutual labels:  select, dropdown
React Select Me
Fast 🐆. Lightweight 🐜. Configurable 🐙. Easy to use 🦄. Give it a shot 👉🏼
Stars: ✭ 119 (+750%)
Mutual labels:  select, dropdown
react-native-select-pro
React Native dropdown (select) component developed by Mobile Reality
Stars: ✭ 79 (+464.29%)
Mutual labels:  select, dropdown
react-native-select-dropdown
react-native-select-dropdown is a highly customized dropdown | select | picker | menu for react native that works for andriod and iOS platforms.
Stars: ✭ 156 (+1014.29%)
Mutual labels:  select, dropdown
Angular2 Multiselect Dropdown
Angular 2 Dropdown Multiselect
Stars: ✭ 225 (+1507.14%)
Mutual labels:  select, dropdown
hierarchy-select
Hierarchy Select jQuery Plugin for Twitter Bootstrap
Stars: ✭ 40 (+185.71%)
Mutual labels:  select, dropdown
Vue Treeselect
A multi-select component with nested options support for Vue.js
Stars: ✭ 2,347 (+16664.29%)
Mutual labels:  select, dropdown
Ng Select
⭐ Native angular select component
Stars: ✭ 2,781 (+19764.29%)
Mutual labels:  select, dropdown
Flutter smart select
SmartSelect allows you to easily convert your usual form select or dropdown into dynamic page, popup dialog, or sliding bottom sheet with various choices input such as radio, checkbox, switch, chips, or even custom input. Supports single and multiple choice.
Stars: ✭ 179 (+1178.57%)
Mutual labels:  select, dropdown
react-native-autocomplete-dropdown
Dropdown Item picker with search and autocomplete (typeahead) functionality for react native
Stars: ✭ 87 (+521.43%)
Mutual labels:  select, dropdown
Bootstrap Select
🚀 The jQuery plugin that brings select elements into the 21st century with intuitive multiselection, searching, and much more.
Stars: ✭ 9,442 (+67342.86%)
Mutual labels:  select, dropdown
Downshift
🏎 A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components.
Stars: ✭ 10,183 (+72635.71%)
Mutual labels:  select, dropdown
react-multi-select-component
Lightweight (~5KB gzipped) multiple selection dropdown component
Stars: ✭ 279 (+1892.86%)
Mutual labels:  select, dropdown
react-functional-select
Micro-sized & micro-optimized select component for React.js
Stars: ✭ 165 (+1078.57%)
Mutual labels:  select, dropdown

Mithril Custom Select Component

A custom select widget component for Mithril.js. Built to mimic native browser select behaviour (if not looks) as closely as possible, including acessibility and keyboard features. The minimal CSS included can be easily overridden and customized by your own styles.

Try a live demo here.

Install:

npm install mithril-select

(TypeScript types are included.)

You will need to include the css file for some basic working styles.

Using PostCSS with postcss-import allows you to import the stylesheet from node_modules:

@import "mithril-select";

If you're using a sass compiler, you can add:

@import "node_modules/mithril-select/index";

to one of your sass files.

Otherwise you can copy the node_modules/mithril-select/index.css file to your project and add it to your html page.

See the example in the git repository for examples of style customization.

Example use:

import mithrilSelect from "mithril-select"
// var mithrilSelect = require("mithril-select").default

// Data to be used in select
const colours = [
  {id: 'red', text: 'Red'},
  {id: 'blue', text: 'Blue'},
  {id: 'green', text: 'Green'},
  {id: 'yellow', text: 'Yellow'},
  {id: 'orange', text: 'Orange'},
  {id: 'pink', text: 'Pink'}
]

let colour = ""

const component = {
  view() {
    return m(mithrilSelect, {
      options: [
        {value: null, view: 'Select a colour...'}
      ].concat(
        colours.map(c => ({value: c.id, view: c.text}))
      ),
      // A CSS class to add to the root element of the select
      class: 'my-select',
      // Respond to selection changes
      onchange: (val) => {
        colour = val != null
          ? colours.find(c => c.id === val).text
          : ""
      }
    })
  }
}

All options and component Attrs:

(See src/index.ts)

/** Represents a single option in a select */
interface Option {
  /**
   * Unique value that identifies this option.
   * Can be any type except `undefined`.
   */
  value: any
  /**
   * Either a string to display for the option or a callback
   * that renders vnodes.
   */
  view?: string | (() => m.Children)
}

/** Attrs object for Select component */
interface Attrs {
  /**
   * Array of `Option` objects
   */
  options: Option[]
  /**
   * Optional prompt to display until the user selects an option.
   * Supply either a string to display or a callback that renders vnodes.
   */
  promptView?: string | (() => m.Children)
  /**
   * Optional value to use for element id attribute.
   */
  id?: string
  /**
   * Optional name of hidden input for form. If none supplied, no hidden
   * input will be rendered. Hidden input value will be coerced to string.
   */
  name?: string
  /**
   * Current selected option value. Omitting or setting to `undefined`
   * is the same as supplying no value. (`null` can be a value.)
   */
  value?: any
	/**
   * Optional aria-labelledby attribute
   */
	ariaLabelledby?: string
  /**
   * Value of option that will be selected on creation. Overridden
   * by `value` if supplied, otherwise will be first option.
   */
  initialValue?: any
  /**
   * Additional class string to use on containing element.
   */
  class?: string
  /**
   * Callback that will be passed the value of the selected option
   * when selection changes.
   */
  onchange?(value: any): void
}

Development Install:

First git clone this repo. Then:

npm install

Build module

npm run build

Serve, compile & watch example app:

npm start

Then go to http://localhost:3000/ in your browser.

Build a plain ES2015 version of the library:

npm run build-es2015

Will output src/index.js


Thanks to barneycarroll for providing an initial POC demo using global focus/blur listeners.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].