22
33A native-like select field, but better.
44
5- Mostly behaves like native ` <select> ` but accepts custom
6- markup for the options and the opener button.
5+ Mostly behaves like native ` <select> ` but accepts custom markup for the options
6+ and the opener button.
77
8- The options can be navigated from the keyboard, the opener text can be easily
9- customized, no annoying "options as arrays" props .
8+ The options are navigatable from the keyboard. The opener text is easily
9+ customizable .
1010
1111This package currently works with Vue 2 versions only.
1212
13+ ## The Problem
14+ When you think about a custom selector, you usually come to provide the
15+ options as an array. For sure, it resolves some reactivity issues by default
16+ but also has some pitfalls.
17+
18+ One such pitfall that in most cases, you need to map your data list to an
19+ array of something like ` { label, value } ` thus spending extra resources.
20+ Additionally, you write dummy code to display an options selector.
21+
22+ The second pitfall is that default ` <select> ` provides a more natural way
23+ to render lists - just by giving the elements by themselves, not the arrays.
24+
25+ The third pitfall is the poor customization capabilities of the options.
26+ Which mostly looks similar to the problem of default ` <select> `
27+ but a bit milder.
28+
29+ ` VuePicker ` resolves all of these issues.
30+
31+ ## TypeScript support
32+ Currently, ` VuePicker ` comes with no TS declarations because of the poor TS
33+ support within Vue infrastructure. Please contact me or craft an issue if you
34+ think the times have changed or you have any other arguments of introducing
35+ TypeScript to the package. Also, you're welcome to contribute.
36+
37+ ## Issues
38+ In case of a bug or a suggestion, please report on the [ Issues page] ( https://github.com/invisiburu/vue-picker/issues )
39+ or contact me by email.
40+
41+ ## Changelog
42+ Check the changes in [ CHANGELOG.md] ( CHANGELOG.md )
43+
1344## Demo
1445See the demo: https://invisiburu.github.io/vue-picker/
15- See the demo sources in [ docs /] ( docs /)
46+ See the demo sources in [ demo /] ( demo /)
1647
1748## Installation
18- In browser :
49+ ### Using unpkg :
1950``` html
2051<script src =" https://unpkg.com/vue" ></script >
2152<script src =" https://unpkg.com/@invisiburu/vue-picker" ></script >
2253<!-- optional css -->
2354<link rel =" stylesheet" href =" https://unpkg.com/@invisiburu/vue-picker/dist/vue-picker.min.css" >
55+
56+ <body >
57+ <div id =" #app" ></div >
58+ <!-- ... -->
59+
60+ <script >
61+ const app = Vue .createApp (App)
62+ app .use (window .VuePicker )
63+ app .mount (' #app' )
64+ </script >
65+ </body >
2466```
2567
26- Using npm:
68+ ### Using npm:
2769``` bash
2870npm i --save @invisiburu/vue-picker
2971```
@@ -34,41 +76,41 @@ import { VuePicker, VuePickerOption } from '@invisiburu/vue-picker'
3476// optional css
3577import ' @invisiburu/vue-picker/dist/vue-picker.min.css'
3678
37-
38- Vue .component (' VuePicker' , VuePicker)
39- Vue .component (' VuePickerOption' , VuePickerOption)
79+ const app = createApp ( /* ... */ )
80+ app .component (' VuePicker' , VuePicker)
81+ app .component (' VuePickerOption' , VuePickerOption)
4082```
4183
4284## Usage
4385### Basic:
4486``` html
45- <vue-picker v-model =" color" autofocus >
46- <vue-picker-option value =" " >Empty</vue-picker-option >
47- <vue-picker-option value =" red" >Red</vue-picker-option >
48- <vue-picker-option value =" green" >Green</vue-picker-option >
49- <vue-picker-option value =" blue" >Blue</vue-picker-option >
50- <vue-picker-option value =" yellow" disabled >Yellow</vue-picker-option >
51- <vue-picker-option value =" teal" text =" Teal" >
87+ <VuePicker v-model =" color" :isAutofocus = " true " >
88+ <VuePickerOption value =" " >Empty</VuePickerOption >
89+ <VuePickerOption value =" red" >Red</VuePickerOption >
90+ <VuePickerOption value =" green" >Green</VuePickerOption >
91+ <VuePickerOption value =" blue" >Blue</VuePickerOption >
92+ <VuePickerOption value =" yellow" :isDisabled = " true " >Yellow</VuePickerOption >
93+ <VuePickerOption value =" teal" text =" Teal" >
5294 How about teal (Teal will be shown instead)
53- </vue-picker-option >
54- </vue-picker >
95+ </VuePickerOption >
96+ </VuePicker >
5597```
5698
5799### Custom options:
58100``` html
59101<template >
60- <vue-picker v-model =" variant" >
61- <vue-picker-option value =" italic-bold" >
102+ <VuePicker v-model =" variant" >
103+ <VuePickerOption value =" italic-bold" >
62104 Some <i >italics</i > or <b >bold</b >?
63- </vue-picker-option >
105+ </VuePickerOption >
64106
65- <vue-picker-option value =" special" text =" Special! Yes!" >
107+ <VuePickerOption value =" special" text =" Special! Yes!" >
66108 <div class =" grid" >
67109 <span class =" title" >Or something more special?</span >
68110 <span class =" subtitle" >I am a subheading!</span >
69111 </div >
70- </vue-picker-option >
71- </vue-picker >
112+ </VuePickerOption >
113+ </VuePicker >
72114</template >
73115
74116<style scoped >
@@ -93,25 +135,25 @@ Vue.component('VuePickerOption', VuePickerOption)
93135### Custom opener:
94136``` html
95137<template >
96- <vue-picker v-model =" custom" >
138+ <VuePicker v-model =" custom" >
97139 <template #opener =" { opener }" >
98140 <span >
99141 <i >{{ opener.value }}</i >
100142 <b >{{ opener.text }}</b >
101143 </span >
102144 </template >
103145
104- <vue-picker-option value =" value-1" >Value 1</vue-picker-option >
105- <vue-picker-option value =" value-2" >Value 2</vue-picker-option >
106- </vue-picker >
146+ <VuePickerOption value =" value-1" >Value 1</VuePickerOption >
147+ <VuePickerOption value =" value-2" >Value 2</VuePickerOption >
148+ </VuePicker >
107149</template >
108150```
109151
110152## Api
111153### ` VuePicker `
112154#### Props:
113- - ` autofocus ` - focus the opener on mount.
114- - ` disabled ` - disable the component.
155+ - ` isAutofocus ` - focus the opener on mount.
156+ - ` isDisabled ` - disable the component.
115157- ` value ` - the value, should be a string. The behaviour is not defined for
116158 values that do not exist within provided options.
117159- ` placeholder ` - a text to show when ` value ` is null, undefined or an
@@ -134,7 +176,7 @@ Vue.component('VuePickerOption', VuePickerOption)
134176
135177### ` VuePickerOption `
136178#### Props:
137- - ` disabled ` - disable the option. Disabled options cannot be picked or
179+ - ` isDisabled ` - disable the option. Disabled options cannot be picked or
138180 navigated.
139181- ` value ` - value to set on when the option selected.
140182- ` text ` - text to be displayed instead of the content of the ` default ` slot.
0 commit comments