slim-select 1.27.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/.nvmrc +1 -0
  2. package/.prettierrc +6 -0
  3. package/.vscode/extensions.json +3 -0
  4. package/.vscode/settings.json +15 -5
  5. package/README.md +2 -1
  6. package/dist/helper.d.ts +1 -4
  7. package/dist/index.d.ts +38 -58
  8. package/dist/render.d.ts +109 -0
  9. package/dist/select.d.ts +31 -20
  10. package/dist/settings.d.ts +33 -0
  11. package/dist/slimselect.cjs.js +2 -0
  12. package/dist/slimselect.cjs.js.map +1 -0
  13. package/dist/slimselect.css +1 -2
  14. package/dist/slimselect.css.map +1 -0
  15. package/dist/slimselect.es.js +2 -0
  16. package/dist/slimselect.es.js.map +1 -0
  17. package/dist/slimselect.global.js +2 -0
  18. package/dist/slimselect.global.js.map +1 -0
  19. package/dist/slimselect.js +2 -1956
  20. package/dist/slimselect.js.map +1 -0
  21. package/dist/slimselect.umd.js +2 -0
  22. package/dist/slimselect.umd.js.map +1 -0
  23. package/dist/store.d.ts +71 -0
  24. package/docs/assets/check-mark.svg +6 -0
  25. package/docs/assets/data.js +59 -0
  26. package/docs/assets/home.css +1 -0
  27. package/docs/assets/home.js +1 -0
  28. package/docs/assets/index.css +1 -0
  29. package/docs/assets/index.js +16 -0
  30. package/docs/assets/index2.js +274 -0
  31. package/docs/assets/index3.js +126 -0
  32. package/docs/assets/index4.js +60 -0
  33. package/docs/assets/install.js +34 -0
  34. package/docs/assets/selects.js +55 -0
  35. package/docs/index.html +18 -5
  36. package/docs.go +3 -1
  37. package/index.html +16 -0
  38. package/jest.config.js +7 -0
  39. package/package.json +39 -39
  40. package/src/docs/app.vue +185 -76
  41. package/src/docs/assets/scss/_variables.scss +26 -10
  42. package/src/docs/assets/scss/alert.scss +12 -0
  43. package/src/docs/assets/scss/animations.scss +5 -3
  44. package/src/docs/assets/scss/button.scss +21 -0
  45. package/src/docs/assets/scss/index.scss +8 -6
  46. package/src/docs/assets/scss/input.scss +2 -2
  47. package/src/docs/assets/scss/layout.scss +195 -65
  48. package/src/docs/assets/scss/misc.scss +144 -34
  49. package/src/docs/assets/scss/prism.scss +155 -153
  50. package/src/docs/env.d.ts +12 -0
  51. package/src/docs/images/check-mark.svg +6 -0
  52. package/src/docs/images/chrome.svg +22 -0
  53. package/src/docs/images/firefox.svg +58 -0
  54. package/src/docs/images/github.png +0 -0
  55. package/src/docs/images/ie.svg +11 -0
  56. package/src/docs/images/npm.png +0 -0
  57. package/src/docs/images/opera.svg +15 -0
  58. package/src/docs/images/safari.svg +22 -0
  59. package/src/docs/main.ts +27 -0
  60. package/src/docs/pages/data.vue +130 -0
  61. package/src/docs/pages/events/addable.vue +79 -0
  62. package/src/docs/pages/events/before_after_change.vue +140 -0
  63. package/src/docs/pages/events/before_after_open_close.vue +122 -0
  64. package/src/docs/pages/events/error.vue +59 -0
  65. package/src/docs/pages/events/index.vue +33 -0
  66. package/src/docs/pages/events/search.vue +154 -0
  67. package/src/docs/pages/events/search_filter.vue +45 -0
  68. package/src/docs/pages/home.vue +96 -116
  69. package/src/docs/pages/install.vue +47 -74
  70. package/src/docs/pages/methods/destroy.vue +66 -0
  71. package/src/docs/pages/methods/enable_disable.vue +70 -0
  72. package/src/docs/pages/methods/get_data.vue +81 -0
  73. package/src/docs/pages/methods/get_selected.vue +78 -0
  74. package/src/docs/pages/methods/index.vue +36 -0
  75. package/src/docs/pages/methods/open_close.vue +63 -0
  76. package/src/docs/pages/methods/search.vue +62 -0
  77. package/src/docs/pages/methods/set_data.vue +106 -0
  78. package/src/docs/pages/methods/set_selected.vue +70 -0
  79. package/src/docs/pages/selects.vue +108 -114
  80. package/src/docs/pages/settings/always_open.vue +88 -0
  81. package/src/docs/pages/settings/close_on_select.vue +69 -0
  82. package/src/docs/pages/settings/content_location.vue +64 -0
  83. package/src/docs/pages/settings/content_position.vue +86 -0
  84. package/src/docs/pages/settings/css.vue +73 -0
  85. package/src/docs/pages/settings/data_attributes.vue +39 -0
  86. package/src/docs/pages/settings/deselect.vue +69 -0
  87. package/src/docs/pages/settings/display.vue +88 -0
  88. package/src/docs/pages/settings/hide_selected.vue +73 -0
  89. package/src/docs/pages/settings/html.vue +86 -0
  90. package/src/docs/pages/settings/index.vue +73 -0
  91. package/src/docs/pages/settings/mandatory.vue +91 -0
  92. package/src/docs/pages/settings/min_max.vue +61 -0
  93. package/src/docs/pages/settings/open_position.vue +60 -0
  94. package/src/docs/pages/settings/placeholder.vue +72 -0
  95. package/src/docs/pages/settings/search.vue +140 -0
  96. package/src/docs/pages/settings/select.vue +32 -0
  97. package/src/docs/pages/settings/select_by_group.vue +46 -0
  98. package/src/docs/pages/settings/show_tooltip.vue +44 -0
  99. package/src/docs/pages/settings/styles.vue +51 -0
  100. package/src/docs/router.ts +41 -13
  101. package/src/slim-select/helper.ts +25 -86
  102. package/src/slim-select/index.ts +318 -413
  103. package/src/slim-select/render.test.ts +39 -0
  104. package/src/slim-select/render.ts +1129 -0
  105. package/src/slim-select/rollup.config.mjs +39 -0
  106. package/src/slim-select/select.test.ts +155 -0
  107. package/src/slim-select/select.ts +280 -107
  108. package/src/slim-select/settings.ts +68 -0
  109. package/src/slim-select/slimselect.scss +263 -278
  110. package/src/slim-select/store.test.ts +220 -0
  111. package/src/slim-select/store.ts +320 -0
  112. package/src/slim-select/tsconfig.json +11 -5
  113. package/src/vue/slimselect.vue +61 -0
  114. package/tsconfig.json +10 -29
  115. package/vite.config.ts +18 -0
  116. package/.browserslistrc +0 -4
  117. package/.postcssrc.js +0 -5
  118. package/.travis.yml +0 -22
  119. package/babel.config.js +0 -5
  120. package/dist/config.d.ts +0 -83
  121. package/dist/data.d.ts +0 -50
  122. package/dist/slim.d.ts +0 -50
  123. package/dist/slimselect.min.css +0 -1
  124. package/dist/slimselect.min.js +0 -1
  125. package/dist/slimselect.min.mjs +0 -1
  126. package/docs/css/app.d5840d21.css +0 -1
  127. package/docs/css/chunk-vendors.4db6930d.css +0 -1
  128. package/docs/css/home.57020178.css +0 -1
  129. package/docs/css/install.baa5d3fb.css +0 -1
  130. package/docs/css/methods.728c742a.css +0 -1
  131. package/docs/css/options.b28a32ef.css +0 -1
  132. package/docs/css/selects.1a7e1e6a.css +0 -1
  133. package/docs/js/app.db13c724.js +0 -2
  134. package/docs/js/app.db13c724.js.map +0 -1
  135. package/docs/js/chunk-vendors.cc40aa28.js +0 -28
  136. package/docs/js/chunk-vendors.cc40aa28.js.map +0 -1
  137. package/docs/js/home.8bcb44fd.js +0 -2
  138. package/docs/js/home.8bcb44fd.js.map +0 -1
  139. package/docs/js/install.02f31028.js +0 -2
  140. package/docs/js/install.02f31028.js.map +0 -1
  141. package/docs/js/methods.1b31e988.js +0 -11
  142. package/docs/js/methods.1b31e988.js.map +0 -1
  143. package/docs/js/options.39fe1005.js +0 -2
  144. package/docs/js/options.39fe1005.js.map +0 -1
  145. package/docs/js/selects.f4d0b859.js +0 -2
  146. package/docs/js/selects.f4d0b859.js.map +0 -1
  147. package/src/docs/pages/methods.vue +0 -427
  148. package/src/docs/pages/options.vue +0 -1480
  149. package/src/main.ts +0 -29
  150. package/src/shims-vue.d.ts +0 -8
  151. package/src/slim-select/config.ts +0 -118
  152. package/src/slim-select/data.ts +0 -377
  153. package/src/slim-select/slim.ts +0 -770
  154. package/tslint.json +0 -26
  155. package/vue.config.js +0 -23
@@ -1,1480 +0,0 @@
1
- <script lang="ts">
2
- import Vue from 'vue'
3
- import SlimSelect from '@/slim-select'
4
-
5
- export default Vue.extend({
6
- data() {
7
- return {
8
- addToBodySingle: null as any,
9
- addToBodyMultiple: null as any,
10
- beforeOnChangeSingle: null,
11
- beforeOnChangeMultiple: null,
12
- onChangeSingle: null,
13
- onChangeMultiple: null
14
- }
15
- },
16
- mounted() {
17
- new SlimSelect({
18
- select: '#dataSingle',
19
- data: [
20
- {text: 'data placeholder', placeholder: true},
21
- {text: 'Value 2'},
22
- {text: 'Value 3', value: ''}
23
- ]
24
- })
25
-
26
- new SlimSelect({
27
- select: '#dataMultiple',
28
- data: [
29
- {placeholder: true, text: 'data placeholder'},
30
- {text: 'Human'},
31
- {
32
- label: 'Animals',
33
- options: [
34
- {text: 'Cat'},
35
- {text: 'Dog'},
36
- {text: 'Bird', value: ''}
37
- ]
38
- }
39
- ]
40
- })
41
-
42
- new SlimSelect({ select: '#optionsSingle' })
43
- new SlimSelect({ select: '#optionsMultiple' })
44
-
45
- const ajaxSingle = new SlimSelect({
46
- select: '#ajaxSingle',
47
- placeholder: 'Search "Graham"',
48
- searchingText: 'Searching Users...',
49
- ajax(search: any, callback: any) {
50
- if (search.length < 3) {
51
- callback('Need 3 characters')
52
- return
53
- }
54
-
55
- fetch('https://jsonplaceholder.typicode.com/users')
56
- .then((response) => {
57
- return response.json()
58
- })
59
- .then((json) => {
60
- const data = [] as any
61
- for (const j of json) {
62
- data.push({ text: j.name })
63
- }
64
-
65
- callback(data)
66
- })
67
- .catch((error) => {
68
- callback(false)
69
- })
70
- }
71
- })
72
-
73
- const ajaxMulti = new SlimSelect({
74
- select: '#ajaxMultiple',
75
- placeholder: 'Search "Dennis"',
76
- ajax(search: any, callback: any) {
77
- fetch('https://jsonplaceholder.typicode.com/users')
78
- .then((response) => {
79
- return response.json()
80
- })
81
- .then((json) => {
82
- const data = [] as any
83
- for (const j of json) {
84
- data.push({ text: j.name })
85
- }
86
-
87
- setTimeout(() => {
88
- ajaxMulti.setSearchText('Sorry No Results.')
89
- callback(data)
90
- }, 1000)
91
- })
92
- .catch((error) => {
93
- callback(false)
94
- })
95
- }
96
- })
97
-
98
- const displaySelect = new SlimSelect({
99
- select: '#selectdisplay'
100
- })
101
-
102
- const displayData = [
103
- { value: 'A', text: 'A', display: false },
104
- { value: 'B', text: 'B' },
105
- { value: 'C', text: 'C' }
106
- ]
107
-
108
- displaySelect.setData(displayData)
109
- displaySelect.set(['A', 'C'])
110
-
111
- new SlimSelect({
112
- select: '#selectdisplay2'
113
- })
114
-
115
-
116
- new SlimSelect({
117
- select: '#placeholderSingle',
118
- placeholder: 'Placeholder Text Here'
119
- })
120
-
121
- new SlimSelect({
122
- select: '#placeholderMultiple',
123
- placeholder: 'Placeholder Text Here'
124
- })
125
-
126
- new SlimSelect({
127
- select: '#allowDeselect',
128
- allowDeselect: true
129
- })
130
-
131
- new SlimSelect({
132
- select: '#allowDeselectOption',
133
- allowDeselectOption: true
134
- })
135
-
136
- new SlimSelect({
137
- select: '#allowDeselectOptionMultiple',
138
- allowDeselectOption: true
139
- })
140
-
141
-
142
- new SlimSelect({
143
- select: '#deselectLabel',
144
- allowDeselect: true,
145
- deselectLabel: '<span class="red">✖</span>'
146
- })
147
-
148
- new SlimSelect({
149
- select: '#addableSingle',
150
- addable: (value: string) => {
151
- return value
152
- }
153
- })
154
-
155
- new SlimSelect({
156
- select: '#addableMultiple',
157
- addable: (value: string) => {
158
- return {
159
- text: value,
160
- value: value.toLowerCase()
161
- }
162
- }
163
- })
164
-
165
- const mandatorySelect = new SlimSelect({
166
- select: '#selectMultiMandatory'
167
- })
168
-
169
- const mandatoryData = [
170
- { value: 'A', text: 'A', mandatory: true },
171
- { value: 'B', text: 'B' },
172
- { value: 'C', text: 'C' }
173
- ]
174
-
175
- mandatorySelect.setData(mandatoryData)
176
- mandatorySelect.set(['A', 'C'])
177
-
178
- new SlimSelect({
179
- select: '#selectMultiMandatory2'
180
- })
181
-
182
- new SlimSelect({
183
- select: '#selectMultiLimit',
184
- limit: 2
185
- })
186
-
187
- new SlimSelect({ select: '#select-class' })
188
- new SlimSelect({ select: '#option-class' })
189
-
190
- new SlimSelect({ select: '#select-style' })
191
- new SlimSelect({ select: '#option-style' })
192
-
193
- new SlimSelect({
194
- select: '#selectInnerHTMLSingle',
195
- searchHighlight: true,
196
- data: [
197
- {
198
- innerHTML: '<b>Bold Text</b>',
199
- text: 'Bold Text',
200
- value: 'bold text'
201
- },
202
- {
203
- innerHTML: '<i>Slim Select you are awesome</i>',
204
- text: 'Slim Select awesome'
205
- },
206
- {
207
- innerHTML: '<div style="border: solid 1px #666666;">Border</div>',
208
- text: 'Border',
209
- value: 'border'
210
- }
211
- ]
212
- })
213
-
214
- new SlimSelect({
215
- select: '#selectInnerHTMLMulti',
216
- data: [
217
- {
218
- innerHTML: '<b>Bold Text</b>',
219
- text: 'Bold Text',
220
- value: 'bold text'
221
- },
222
- {
223
- innerHTML: '<i>Slim Select you are awesome</i>',
224
- text: 'Slim Select awesome'
225
- },
226
- {
227
- innerHTML: '<div style="border: solid 1px #666666;">Border</div>',
228
- text: 'Border',
229
- value: 'border'
230
- }
231
- ]
232
- })
233
-
234
- new SlimSelect({
235
- select: '#selectInnerHTMLSingleText',
236
- valuesUseText: true,
237
- data: [
238
- {
239
- innerHTML: '<b>Bold Text</b>',
240
- text: 'Bold Text',
241
- value: 'bold text'
242
- },
243
- {
244
- innerHTML: '<i>Slim Select you are awesome</i>',
245
- text: 'Slim Select awesome'
246
- },
247
- {
248
- innerHTML: '<div style="border: solid 1px #666666;">Border</div>',
249
- text: 'Border',
250
- value: 'border'
251
- }
252
- ]
253
- })
254
-
255
- new SlimSelect({
256
- select: '#selectInnerHTMLMultiText',
257
- valuesUseText: true,
258
- data: [
259
- {
260
- innerHTML: '<b>Bold Text</b>',
261
- text: 'Bold Text',
262
- value: 'bold text'
263
- },
264
- {
265
- innerHTML: '<i>Slim Select you are awesome</i>',
266
- text: 'Slim Select awesome'
267
- },
268
- {
269
- innerHTML: '<div style="border: solid 1px #666666;">Border</div>',
270
- text: 'Border',
271
- value: 'border'
272
- }
273
- ]
274
- })
275
-
276
- new SlimSelect({ select: '#showSearchSingle', showSearch: false })
277
- new SlimSelect({
278
- select: '#searchTextSingle', searchText: 'Sorry nothing to see here',
279
- beforeOpen: () => {console.log('beforeOpen')}, beforeClose: () => {console.log('beforeClose')},
280
- afterOpen: () => {console.log('afterOpen')}, afterClose: () => {console.log('afterClose')}
281
- })
282
- new SlimSelect({ select: '#searchPlaceholderSingle', searchPlaceholder: 'Search for the good stuff!' })
283
- new SlimSelect({ select: '#searchFocusSingle', searchFocus: false })
284
- new SlimSelect({ select: '#searchHighlightSingle', searchHighlight: true })
285
- new SlimSelect({ select: '#showSearchMulti', showSearch: false })
286
- new SlimSelect({ select: '#searchTextMulti', searchText: 'Sorry nothing to see here'})
287
- new SlimSelect({ select: '#searchPlaceholderMulti', searchPlaceholder: 'Search for the good stuff!' })
288
- new SlimSelect({ select: '#searchFocusMulti', searchFocus: false })
289
- new SlimSelect({ select: '#searchHighlightMulti', searchHighlight: true })
290
-
291
- new SlimSelect({
292
- select: '#closeOnSelectSingle',
293
- closeOnSelect: false
294
- })
295
-
296
- new SlimSelect({
297
- select: '#closeOnSelectMultiple',
298
- closeOnSelect: false,
299
- selectByGroup: true
300
- })
301
-
302
- new SlimSelect({
303
- select: '#showContentUp',
304
- showContent: 'up'
305
- })
306
-
307
- this.addToBodySingle = new SlimSelect({
308
- select: '#addToBodySingle',
309
- addToBody: true
310
- })
311
-
312
- this.addToBodyMultiple = new SlimSelect({
313
- select: '#addToBodyMultiple',
314
- addToBody: true,
315
- selectByGroup: true
316
- })
317
-
318
- new SlimSelect({
319
- select: '#showContentDown',
320
- showContent: 'down'
321
- })
322
-
323
- new SlimSelect({
324
- select: '#beforeOnChangeSingle',
325
- beforeOnChange: (value: any) => {
326
- this.beforeOnChangeSingle = value
327
- }
328
- })
329
-
330
- new SlimSelect({
331
- select: '#beforeOnChangeMultiple',
332
- beforeOnChange: (values: any) => {
333
- this.beforeOnChangeMultiple = values
334
- }
335
- })
336
-
337
- new SlimSelect({
338
- select: '#onChangeSingle',
339
- onChange: (value: any) => {
340
- this.onChangeSingle = value
341
- }
342
- })
343
-
344
- new SlimSelect({
345
- select: '#onChangeMultiple',
346
- onChange: (value: any) => {
347
- this.onChangeMultiple = value
348
- }
349
- })
350
-
351
- new SlimSelect({
352
- select: '#showOptionTooltips',
353
- showOptionTooltips: true
354
- })
355
-
356
- new SlimSelect({
357
- select: '#selectByGroup',
358
- selectByGroup: true
359
- })
360
-
361
- new SlimSelect({
362
- select: '#searchFilter',
363
- searchFilter: (option: any, search: any) => option.text.substr(0, search.length) === search
364
- })
365
-
366
- new SlimSelect({
367
- select: '#hideSelectedOption',
368
- hideSelectedOption: true
369
- })
370
-
371
- new SlimSelect({
372
- select: '#hideSelectedOptionMultiple',
373
- hideSelectedOption: true
374
- })
375
- },
376
- beforeDestroy() {
377
- this.addToBodySingle.destroy()
378
- this.addToBodyMultiple.destroy()
379
- }
380
- })
381
- </script>
382
-
383
- <style lang="scss">
384
- #options-content {
385
- .set-content {
386
- display: flex;
387
-
388
- > * {
389
- flex: 0 1 50%;
390
- width: 48%;
391
- margin: 0 5px 0 0;
392
-
393
- &:last-child {
394
- margin: 0 0 0 0;
395
- }
396
- }
397
- }
398
-
399
- .deselectLabel {
400
- .red { color: red; }
401
- }
402
-
403
- .select-class {
404
- .ss-single-selected {
405
- background-color: #5897fb;
406
- color: white;
407
- border: none;
408
-
409
- .ss-arrow * {
410
- border-color: white;
411
- }
412
- }
413
- }
414
-
415
- .ss-option {
416
- &.red { color: white; background-color: red; }
417
- &.green { color: white; background-color: green; }
418
- &.blue { color: white; background-color: blue; }
419
- }
420
- }
421
- </style>
422
-
423
- <template>
424
- <div id="options-content">
425
- <div class="content">
426
- <h2 class="header">select</h2>
427
- <p>
428
- The select option is used to identify the select element that will be used to
429
- create slim select. You can any value you normally would in a querySelector
430
- or pass the element directly.
431
- </p>
432
-
433
- <pre>
434
- <code class="language-javascript">
435
- new SlimSelect({
436
- select: '.element .you #want',
437
- // or
438
- select: document.querySelector('.element .you #want')
439
- })
440
-
441
- // If you already have a created slim select you can select your div
442
- // and continue to use slim select off of the element using the .slim data value
443
- let el = document.querySelector('.element .you #want')
444
- el.slim.open() // Or any other options/methods
445
- </code>
446
- </pre>
447
- </div>
448
-
449
- <div class="content">
450
- <h2 class="header">data</h2>
451
- <p>Data is a value that can be set to initialize options in the select dropdown</p>
452
-
453
- <div class="set-content">
454
- <select id="dataSingle"></select>
455
- <select id="dataMultiple" multiple></select>
456
- </div>
457
-
458
- <pre>
459
- <code class="language-javascript">
460
- new SlimSelect({
461
- select: '.element .you #want',
462
- data: [
463
- {text: 'Value 1'},
464
- {text: 'Value 2'},
465
- {text: 'Value 3'}
466
- ],
467
- // groups
468
- data: [
469
- {
470
- label: 'Animals',
471
- options: [
472
- {text: 'Cat'},
473
- {text: 'Dog'},
474
- {text: 'Bird'}
475
- ]
476
- }
477
- ]
478
- // Mix - option and group options
479
- data: [
480
- {text: 'Human'}, // regular option
481
- {
482
- label: 'Animals',
483
- options: [
484
- {text: 'Cat'},
485
- {text: 'Dog'},
486
- {text: 'Bird'}
487
- ]
488
- }
489
- ]
490
- })
491
-
492
- // If you want to set a placeholder set the first object placeholder to true
493
- {'placeholder': true, 'text': 'placeholder text'}
494
- </code>
495
- </pre>
496
-
497
- <h4>Data Types</h4>
498
- <pre>
499
- <code class="language-javascript">
500
- var optgroup = {
501
- label: 'label', // Required
502
- options: [] // Required - value is an array of options
503
- }
504
-
505
- var option = {
506
- text: 'text', // Required
507
- value: 'value', // Optional - value will be set by text if not set
508
- innerHTML: '&lt;b&gt;Html&lt;/b&gt;', // Optional - will be used for display purposes if set
509
- selected: false, // Optional - default is false
510
- disabled: false, // Optional - default is false
511
- placeholder: false, // Optional - default is false
512
- class: '', // Optional - default is not set
513
- css: '', // Optional - default is not set
514
- data: {} // Optional - If you have data attributes
515
- }
516
- </code>
517
- </pre>
518
- </div>
519
-
520
- <div class="content">
521
- <h2 class="header">options</h2>
522
- <p>
523
- Slim select will take on attributes of the original as best as possible.
524
- Below are example usages of attributes added to the underlining select options that slim select picked up and used
525
- </p>
526
-
527
- <div class="set-content">
528
- <select id="optionsSingle">
529
- <option data-placeholder="true"></option>
530
- <option value="value1" data-info="Here is info">Data Attributes</option>
531
- <option value="value2" disabled>Disabled Option</option>
532
- <option value="value3" class="green">Class Green</option>
533
- <option value="value3" style="color: purple;">Inline Style</option>
534
- </select>
535
- <select id="optionsMultiple" multiple>
536
- <option value="value1" data-info="Here is info">Data Attributes</option>
537
- <option value="value2" disabled>Disabled Option</option>
538
- <option value="value3" class="green">Class Green</option>
539
- <option value="value3" style="color: purple;">Inline Style</option>
540
- </select>
541
- </div>
542
- </div>
543
-
544
- <div class="content">
545
- <h2 class="header">ajax</h2>
546
- <p>
547
- Slim select allows you to syncronize result values from your ajax requests.<br />
548
- Call callback() method with slimselect data, false or string with specific string.<br />
549
- <br />
550
- When doing fetch request for each ajax call be sure to debounce your request so you are not getting fetch race conditions.
551
- </p>
552
-
553
- <div class="set-content">
554
- <select id="ajaxSingle">
555
- <option data-placeholder="true"></option>
556
- </select>
557
- <select id="ajaxMultiple" multiple></select>
558
- </div>
559
-
560
- <pre>
561
- <code class="language-javascript">
562
- new SlimSelect({
563
- select: '#ajax',
564
- searchingText: 'Searching...', // Optional - Will show during ajax request
565
- ajax: function (search, callback) {
566
- // Check search value. If you dont like it callback(false) or callback('Message String')
567
- if (search.length &lt; 3) {
568
- callback('Need 3 characters')
569
- return
570
- }
571
-
572
- // Perform your own ajax request here
573
- fetch('https://jsonplaceholder.typicode.com/users')
574
- .then(function (response) {
575
- return response.json()
576
- })
577
- .then(function (json) {
578
- let data = []
579
- for (let i = 0; i &lt; json.length; i++) {
580
- data.push({text: json[i].name})
581
- }
582
-
583
- // Upon successful fetch send data to callback function.
584
- // Be sure to send data back in the proper format.
585
- // Refer to the method setData for examples of proper format.
586
- callback(data)
587
- })
588
- .catch(function(error) {
589
- // If any erros happened send false back through the callback
590
- callback(false)
591
- })
592
- }
593
- })
594
- </code>
595
- </pre>
596
- </div>
597
-
598
- <div class="content">
599
- <h2 class="header">placeholder</h2>
600
- <p>
601
- Placeholders consists of setting the placeholder option value.
602
- The only difference is single selects require an empty option with data-placeholder set to true.
603
- Default value is "Select Value".
604
- </p>
605
-
606
- <div class="set-content">
607
- <select id="placeholderSingle">
608
- <option data-placeholder="true"></option>
609
- <option value="value1">Value 1</option>
610
- <option value="value2">Value 2</option>
611
- <option value="value3">Value 3</option>
612
- </select>
613
- <select id="placeholderMultiple" multiple>
614
- <option value="value1">Value 1</option>
615
- <option value="value2">Value 2</option>
616
- <option value="value3">Value 3</option>
617
- </select>
618
- </div>
619
-
620
- <pre>
621
- <code class="language-javascript">
622
- new SlimSelect({
623
- select: '#placeholder',
624
- placeholder: 'Placeholder Text Here'
625
- })
626
- </code>
627
- </pre>
628
-
629
- <pre>
630
- <code class="language-html">
631
- &lt;!-- Set empty option with data-placeholder if you to have placeholder --&gt;
632
- &lt;!-- text for single select, otherwise first option will be selected --&gt;
633
- &lt;select id="placeholderSingle"&gt;
634
- &lt;option data-placeholder="true"&gt;&lt;/option&gt;
635
- &lt;option value="value1"&gt;Value 1&lt;/option&gt;
636
- &lt;option value="value2"&gt;Value 2&lt;/option&gt;
637
- &lt;option value="value3"&gt;Value 3&lt;/option&gt;
638
- &lt;/select&gt;
639
- </code>
640
- </pre>
641
- </div>
642
-
643
- <div class="content">
644
- <h2 class="header">allowDeselect</h2>
645
- <p>
646
- This will allow you to deselect a value on a single select dropdown.<br />
647
- Be sure to have an empty option data placeholder so slim select has an empty string value to select.
648
- </p>
649
-
650
- <div class="set-content">
651
- <select id="allowDeselect">
652
- <option data-placeholder="true"></option>
653
- <option value="value1">Value 1</option>
654
- <option value="value2">Value 2</option>
655
- <option value="value3">Value 3</option>
656
- </select>
657
- </div>
658
-
659
- <pre>
660
- <code class="language-javascript">
661
- new SlimSelect({
662
- select: '.element .you #want',
663
- allowDeselect: true
664
- })
665
- </code>
666
- </pre>
667
- <pre>
668
- <code class="language-html">
669
- &lt;!-- Requires emtpy data-placeholder option --&gt;
670
- &lt;select id="allowDeselect"&gt;
671
- &lt;option data-placeholder="true"&gt;&lt;/option&gt;
672
- &lt;option value="value1"&gt;Value 1&lt;/option&gt;
673
- &lt;option value="value2"&gt;Value 2&lt;/option&gt;
674
- &lt;option value="value3"&gt;Value 3&lt;/option&gt;
675
- &lt;/select&gt;
676
- </code>
677
- </pre>
678
- </div>
679
-
680
- <div class="content">
681
- <h2 class="header">display</h2>
682
- <p>Allows to hide elements of select options.</p>
683
-
684
- <div class="set-content">
685
- <select id="selectdisplay" multiple></select>
686
- </div>
687
-
688
- <pre>
689
- <code class="language-javascript">
690
- const displaySelect = new SlimSelect({
691
- select: '#selectdisplay'
692
- })
693
-
694
- const displayData = [
695
- { value: 'A', text: 'A', display: false },
696
- { value: 'B', text: 'B' },
697
- { value: 'C', text: 'C' }
698
- ]
699
-
700
- displaySelect.setData(displayData)
701
- displaySelect.set(['A', 'C'])
702
- </code>
703
- </pre>
704
-
705
- <pre>
706
- <code class="language-html">
707
- &lt;select id="selectMultiMandatory" multiple&gt;
708
- &lt;/select&gt;
709
- </code>
710
- </pre>
711
-
712
- <p>Or</p>
713
- <div class="set-content">
714
- <select id="selectdisplay2" multiple>
715
- <option value="A" style="display: none;" selected>A</option>
716
- <option value="B" selected>B</option>
717
- <option value="C">C</option>
718
- </select>
719
- </div>
720
-
721
- <pre>
722
- <code class="language-javascript">
723
- const slim = new SlimSelect({
724
- select: '#selectdisplay2'
725
- });
726
- </code>
727
- </pre>
728
-
729
- <pre>
730
- <code class="language-html">
731
- &lt;select id="selectdisplay2" multiple&gt;
732
- &lt;option value="A" style="display: none;" selected&gt;A&lt;/option&gt;
733
- &lt;option value="B" selected&gt;B&lt;/option&gt;
734
- &lt;option value="C"&gt;C&lt;/option&gt;
735
- &lt;/select&gt;
736
- </code>
737
- </pre>
738
- </div>
739
-
740
- <div class="content">
741
- <h2 class="header">allowDeselectOption</h2>
742
- <p>
743
- This will allow you to deselect a value in the dropdown. By simple clicking the option again.<br />
744
- Be sure to have an empty option data placeholder so slim select has an empty string value to select.
745
- </p>
746
-
747
- <div class="set-content">
748
- <select id="allowDeselectOption">
749
- <option data-placeholder="true"></option>
750
- <option value="value1">Value 1</option>
751
- <option value="value2">Value 2</option>
752
- <option value="value3">Value 3</option>
753
- </select>
754
- <select id="allowDeselectOptionMultiple" multiple>
755
- <option value="value1">Value 1</option>
756
- <option value="value2">Value 2</option>
757
- <option value="value3">Value 3</option>
758
- </select>
759
- </div>
760
-
761
- <pre>
762
- <code class="language-javascript">
763
- new SlimSelect({
764
- select: '.element .you #want',
765
- allowDeselectOption: true
766
- })
767
- </code>
768
- </pre>
769
- <pre>
770
- <code class="language-html">
771
- &lt;!-- Requires emtpy data-placeholder option --&gt;
772
- &lt;select id="allowDeselectOption"&gt;
773
- &lt;option data-placeholder="true"&gt;&lt;/option&gt;
774
- &lt;option value="value1"&gt;Value 1&lt;/option&gt;
775
- &lt;option value="value2"&gt;Value 2&lt;/option&gt;
776
- &lt;option value="value3"&gt;Value 3&lt;/option&gt;
777
- &lt;/select&gt;
778
- </code>
779
- </pre>
780
- </div>
781
-
782
- <div class="content">
783
- <h2 class="header">deselectLabel</h2>
784
- <p>
785
- This will allow you to change the deselect label (default 'x') on single select lists,
786
- and the delete label on multiple-select lists.
787
- </p>
788
- <p>Note: Be aware of the lmited space available for it</p>
789
-
790
- <div class="set-content">
791
- <select id="deselectLabel" class="deselectLabel">
792
- <option data-placeholder="true"></option>
793
- <option selected value="value1">Value 1</option>
794
- <option value="value2">Value 2</option>
795
- <option value="value3">Value 3</option>
796
- </select>
797
- </div>
798
-
799
- <pre>
800
- <code class="language-javascript">
801
- new SlimSelect({
802
- select: '.element .you #want',
803
- allowDeselect: true,
804
- deselectLabel: '&lt;span class="red"&gt;✖&lt;/span&gt;'
805
- })
806
- </code>
807
- </pre>
808
- <pre>
809
- <code class="language-html">
810
- &lt;!-- Requires emtpy data-placeholder option --&gt;
811
- &lt;select id="deselectLabel"&gt;
812
- &lt;option data-placeholder="true"&gt;&lt;/option&gt;
813
- &lt;option value="value1"&gt;Value 1&lt;/option&gt;
814
- &lt;option value="value2"&gt;Value 2&lt;/option&gt;
815
- &lt;option value="value3"&gt;Value 3&lt;/option&gt;
816
- &lt;/select&gt;
817
- </code>
818
- </pre>
819
- </div>
820
-
821
- <div class="content">
822
- <h2 class="header">addable</h2>
823
- <p>
824
- Slim select has the ability to dynamically add options via the search input field
825
- </p>
826
- <p>
827
- addable is a callback which takes a function parameter.
828
- The return value is the string of the value you want added.
829
- </p>
830
-
831
- <div class="set-content">
832
- <select id="addableSingle">
833
- <option value="value1">Value 1</option>
834
- <option value="value2">Value 2</option>
835
- <option value="value3">Value 3</option>
836
- </select>
837
- <select id="addableMultiple" multiple>
838
- <option value="value1">Value 1</option>
839
- <option value="value2">Value 2</option>
840
- <option value="value3">Value 3</option>
841
- </select>
842
- </div>
843
-
844
- <pre>
845
- <code class="language-javascript">
846
- new SlimSelect({
847
- select: '.element .you #want',
848
- // Optional - In the event you want to alter/validate it as a return value
849
- addable: function (value) {
850
- // return false or null if you do not want to allow value to be submitted
851
- if (value === 'bad') {return false}
852
-
853
- // Return the value string
854
- return value // Optional - value alteration // ex: value.toLowerCase()
855
-
856
- // Optional - Return a valid data object. See methods/setData for list of valid options
857
- return {
858
- text: value,
859
- value: value.toLowerCase()
860
- }
861
- }
862
- })
863
- </code>
864
- </pre>
865
- </div>
866
-
867
- <div class="content">
868
- <h2 class="header">limit</h2>
869
- <p>When using multi select you can set a limit on the amount of selections you can have.</p>
870
-
871
- <div class="set-content">
872
- <select id="selectMultiLimit" multiple>
873
- <option value="value1">Value 1</option>
874
- <option value="value2">Value 2</option>
875
- <option value="value3">Value 3</option>
876
- </select>
877
- </div>
878
-
879
- <pre>
880
- <code class="language-javascript">
881
- let slim = new SlimSelect({
882
- select: '#selectMultiLimit',
883
- limit: 2
884
- })
885
- </code>
886
- </pre>
887
-
888
- <pre>
889
- <code class="language-html">
890
- &lt;select id="selectMultiLimit" multiple&gt;
891
- &lt;option value="value1"&gt;Value 1&lt;/option&gt;
892
- &lt;option value="value2"&gt;Value 2&lt;/option&gt;
893
- &lt;option value="value3"&gt;Value 3&lt;/option&gt;
894
- &lt;/select&gt;
895
- </code>
896
- </pre>
897
- </div>
898
-
899
- <div class="content">
900
- <h2 class="header">mandatory</h2>
901
- <p>When using multi select you can set a mandatory on the option to prevent capability to deselect particular option. Note options with mandatory flag is not selected by default, you need select them yourselfs.</p>
902
-
903
- <div class="set-content">
904
- <select id="selectMultiMandatory" multiple></select>
905
- </div>
906
-
907
- <pre>
908
- <code class="language-javascript">
909
- const slim = new SlimSelect({
910
- select: '#selectMultiMandatory'
911
- });
912
-
913
- const data = [
914
- { value: 'A', text: 'A', mandatory: true },
915
- { value: 'B', text: 'B' },
916
- { value: 'C', text: 'C' }
917
- ]
918
-
919
- slim.setData(data)
920
- slim.set(["A", "C"])
921
- </code>
922
- </pre>
923
-
924
- <pre>
925
- <code class="language-html">
926
- &lt;select id="selectMultiMandatory" multiple&gt;
927
- &lt;/select&gt;
928
- </code>
929
- </pre>
930
-
931
- <p>Or</p>
932
- <div class="set-content">
933
- <select id="selectMultiMandatory2" multiple>
934
- <option value="A" data-mandatory="true" selected>A</option>
935
- <option value="B" selected>B</option>
936
- <option value="C">C</option>
937
- </select>
938
- </div>
939
-
940
- <pre>
941
- <code class="language-javascript">
942
- const slim = new SlimSelect({
943
- select: '#selectMultiMandatory2'
944
- });
945
- </code>
946
- </pre>
947
-
948
- <pre>
949
- <code class="language-html">
950
- &lt;select id="selectMultiMandatory" multiple&gt;
951
- &lt;option value="A" data-mandatory="true" selected&gt;A&lt;/option&gt;
952
- &lt;option value="B" selected&gt;B&lt;/option&gt;
953
- &lt;option value="C"&gt;C&lt;/option&gt;
954
- &lt;/select&gt;
955
- </code>
956
- </pre>
957
- </div>
958
-
959
- <div class="content">
960
- <h2 class="header">css class</h2>
961
- <p>
962
- Slim select will inherit any classes that were added to the original select element.
963
- This includes options as well.
964
- </p>
965
-
966
- <div class="set-content">
967
- <select id="select-class" class="select-class">
968
- <option value="value1">Value 1</option>
969
- <option value="value2">Value 2</option>
970
- <option value="value3">Value 3</option>
971
- </select>
972
- <select id="option-class" class="option-class">
973
- <option class="red" value="value1">Red</option>
974
- <option class="green" value="value2">Green</option>
975
- <option class="blue" value="value3">Blue</option>
976
- </select>
977
- </div>
978
-
979
- <pre>
980
- <code class="language-html">
981
- &lt;select id="select-class" class="classItems"&gt;
982
- &lt;option class="red" value="value1"&gt;Value 1&lt;/option&gt;
983
- &lt;option class="green" value="value2"&gt;Value 2&lt;/option&gt;
984
- &lt;option class="blue" value="value3"&gt;Value 3&lt;/option&gt;
985
- &lt;/select&gt;
986
- </code>
987
- </pre>
988
- </div>
989
-
990
- <div class="content">
991
- <h2 class="header">inline styles</h2>
992
- <p>
993
- Slim select will inherit any styles that were added to the original select element.
994
- This includes options as well.
995
- </p>
996
-
997
- <div class="set-content">
998
- <select id="select-style" style="color: red;">
999
- <option value="value1">Value 1</option>
1000
- <option value="value2">Value 2</option>
1001
- <option value="value3">Value 3</option>
1002
- </select>
1003
- <select id="option-style">
1004
- <option style="color: red;" value="value1">Red</option>
1005
- <option style="color: green;">Green</option>
1006
- <option style="color: blue;">Blue</option>
1007
- </select>
1008
- </div>
1009
-
1010
- <pre>
1011
- <code class="language-html">
1012
- &lt;select id="select-style" style="color: red;"&gt;
1013
- &lt;option value="value1"&gt;Value 1&lt;/option&gt;
1014
- &lt;option value="value2"&gt;Value 2&lt;/option&gt;
1015
- &lt;option value="value3"&gt;Value 3&lt;/option&gt;
1016
- &lt;/select&gt;
1017
-
1018
- &lt;select id="option-style"&gt;
1019
- &lt;option style="color: red;" value="value1"&gt;Red&lt;/option&gt;
1020
- &lt;option style="color: green;"&gt;Green&lt;/option&gt;
1021
- &lt;option style="color: blue;"&gt;Blue&lt;/option&gt;
1022
- &lt;/select&gt;
1023
- </code>
1024
- </pre>
1025
- </div>
1026
-
1027
- <div class="content">
1028
- <h2 class="header">innerHTML</h2>
1029
- <p>
1030
- Slim select has the ability to set custom html in content in the select option.
1031
- </p>
1032
- <p>
1033
- Due to html spec we cant do this directly on the select dropdown, but we can pass them as data values to slim select
1034
- </p>
1035
-
1036
- <div class="set-content">
1037
- <select id="selectInnerHTMLSingle"></select>
1038
- <select id="selectInnerHTMLMulti" multiple></select>
1039
- </div>
1040
- <div class="set-content" style="padding: 16px 0 0 0;">
1041
- <h4>Use text for selected values</h4>
1042
- </div>
1043
- <div class="set-content">
1044
- <select id="selectInnerHTMLSingleText"></select>
1045
- <select id="selectInnerHTMLMultiText" multiple></select>
1046
- </div>
1047
-
1048
- <pre>
1049
- <code class="language-javascript">
1050
- &lt;select id="select-innerHTML"&gt;&lt;/select&gt;
1051
-
1052
- var select = new SlimSelect({
1053
- select: '#select-innerHTML',
1054
- valuesUseText: false, // Use text instead of innerHTML for selected values - default false
1055
- data: [
1056
- {innerHTML: '&lt;img height="30" width="30" src="http://lorempixel.com/30/30" /&gt;&nbsp;Image', text: 'Image', value: 'image'},
1057
- {innerHTML: '&lt;b&gt;Bold Text&lt;/b&gt;', text: 'Bold Text', value: 'bold text'},
1058
- {innerHTML: '&lt;div style="border: solid 1px #666666;"&gt;Border&lt;/div&gt;', text: 'Border', value: 'border'},
1059
- {innerHTML: '&lt;i&gt;Slim Select you are awesome&lt;/i&gt;', text: 'Slim Select awesome'}
1060
- ]
1061
- })
1062
- </code>
1063
- </pre>
1064
- </div>
1065
-
1066
- <div class="content">
1067
- <h2 class="header">showSearch / searchText / searchingText / searchFocus / searchHighlight</h2>
1068
- <p>
1069
- showSearch is a boolean value that will decide whether or not to show the search.
1070
- Default is true.
1071
- </p>
1072
- <p>
1073
- searchText is a string value that will show in the event there are no results.
1074
- Default is 'No Results'.
1075
- </p>
1076
- <p>
1077
- searchingText is a string value that will show during an ajax request.
1078
- Default is 'Searching...'.
1079
- </p>
1080
- <p>
1081
- searchPlaceholder is a string value that will set the value of the input search placeholder text.
1082
- Default is 'Search'.
1083
- </p>
1084
- <p>
1085
- searchFocus is a boolean value that will focus search input on opening.
1086
- Default is true.
1087
- </p>
1088
- <p>
1089
- searchHighlight is a boolean value that will highlight search results.
1090
- Default is false.
1091
- </p>
1092
-
1093
- <div class="set-content">
1094
- <select id="showSearchSingle">
1095
- <option value="dog">Dog</option>
1096
- <option value="cat">Cat</option>
1097
- <option value="bird">Bird</option>
1098
- </select>
1099
- <select id="searchTextSingle">
1100
- <option value="dog">Dog</option>
1101
- <option value="cat">Cat</option>
1102
- <option value="bird">Bird</option>
1103
- </select>
1104
- <select id="searchPlaceholderSingle">
1105
- <option value="dog">Dog</option>
1106
- <option value="cat">Cat</option>
1107
- <option value="bird">Bird</option>
1108
- </select>
1109
- <select id="searchFocusSingle">
1110
- <option value="dog">Dog</option>
1111
- <option value="cat">Cat</option>
1112
- <option value="bird">Bird</option>
1113
- </select>
1114
- <select id="searchHighlightSingle">
1115
- <option value="dog">Dog</option>
1116
- <option value="cat">Cat</option>
1117
- <option value="bird">Bird</option>
1118
- </select>
1119
- </div>
1120
-
1121
- <div class="set-content">
1122
- <select id="showSearchMulti" multiple>
1123
- <option value="dog">Dog</option>
1124
- <option value="cat">Cat</option>
1125
- <option value="bird">Bird</option>
1126
- </select>
1127
- <select id="searchTextMulti" multiple>
1128
- <option value="dog">Dog</option>
1129
- <option value="cat">Cat</option>
1130
- <option value="bird">Bird</option>
1131
- </select>
1132
- <select id="searchPlaceholderMulti" multiple>
1133
- <option value="dog">Dog</option>
1134
- <option value="cat">Cat</option>
1135
- <option value="bird">Bird</option>
1136
- </select>
1137
- <select id="searchFocusMulti" multiple>
1138
- <option value="dog">Dog</option>
1139
- <option value="cat">Cat</option>
1140
- <option value="bird">Bird</option>
1141
- </select>
1142
- <select id="searchHighlightMulti" multiple>
1143
- <option value="dog">Dog</option>
1144
- <option value="cat">Cat</option>
1145
- <option value="bird">Bird</option>
1146
- </select>
1147
- </div>
1148
-
1149
- <pre>
1150
- <code class="language-javascript">
1151
- let slim = new SlimSelect({
1152
- select: '#search',
1153
- showSearch: false,
1154
- searchText: 'Sorry nothing to see here',
1155
- searchPlaceholder: 'Search for the good stuff!',
1156
- searchFocus: false, // Whether or not to focus on the search input field
1157
- searchHighlight: true
1158
- })
1159
-
1160
- // You can also set search text via method
1161
- slim.setSearchText('Searching...')
1162
- </code>
1163
- </pre>
1164
- </div>
1165
-
1166
- <div class="content">
1167
- <h2 class="header">closeOnSelect</h2>
1168
- <p>
1169
- closeOnSelect is a boolean value in which determines whether or not to
1170
- close the content area upon selecting a value.
1171
- </p>
1172
-
1173
- <div class="set-content">
1174
- <select id="closeOnSelectSingle">
1175
- <option value="value1">Value 1</option>
1176
- <option value="value2">Value 2</option>
1177
- <option value="value3">Value 3</option>
1178
- <optgroup label="Super Values">
1179
- <option value="value11">Value 1</option>
1180
- <option value="value22">Value 2</option>
1181
- <option value="value33">Value 3</option>
1182
- </optgroup>
1183
- </select>
1184
- <select id="closeOnSelectMultiple" multiple>
1185
- <option value="value1">Value 1</option>
1186
- <option value="value2">Value 2</option>
1187
- <option value="value3">Value 3</option>
1188
- <optgroup label="Super Values">
1189
- <option value="value11">Value 1</option>
1190
- <option value="value22">Value 2</option>
1191
- <option value="value33">Value 3</option>
1192
- </optgroup>
1193
- </select>
1194
- </div>
1195
-
1196
- <pre>
1197
- <code class="language-javascript">
1198
- new SlimSelect({
1199
- select: '#search',
1200
- closeOnSelect: false
1201
- })
1202
- </code>
1203
- </pre>
1204
- </div>
1205
-
1206
- <div class="content">
1207
- <h2 class="header">showContent</h2>
1208
- <p>
1209
- showContent is a string value that will decide where to show your content when it comes out.
1210
- By default slim select will try to put the content where it can without going off screen.
1211
- But you may want to always show it in one direction.
1212
- </p>
1213
- <p>
1214
- Possible Options: <b>'auto', 'up' or 'down'</b>. Default is <b>'auto'</b>
1215
- </p>
1216
-
1217
- <div class="set-content">
1218
- <select id="showContentUp">
1219
- <option value="up1">Up 1</option>
1220
- <option value="up2">Up 2</option>
1221
- <option value="up3">Up 3</option>
1222
- </select>
1223
- <select id="showContentDown">
1224
- <option value="down1">Down 1</option>
1225
- <option value="down2">Down 2</option>
1226
- <option value="down3">Down 3</option>
1227
- </select>
1228
- </div>
1229
-
1230
- <pre>
1231
- <code class="language-javascript">
1232
- new SlimSelect({
1233
- select: '#showContent',
1234
- showContent: 'auto' // 'auto', 'up' or 'down'
1235
- })
1236
- </code>
1237
- </pre>
1238
- </div>
1239
-
1240
- <div class="content">
1241
- <h2 class="header">addToBody</h2>
1242
- <p>
1243
- addToBody is a boolean value that configures the select dropdown to be added directly to the document body, rather than the parent container.
1244
- This allows using slim-select in scenarios where you have no control of the overflow state of the parent containers.
1245
-
1246
- Keep in mind that the widget has to be disposed explicitly by calling <b>destroy</b>.
1247
- </p>
1248
- <p>
1249
- Possible Options: <b>true</b> or <b>false</b>. Default is <b>false</b>
1250
- </p>
1251
-
1252
- <div class="set-content">
1253
- <select id="addToBodySingle">
1254
- <option value="value1">Value 1</option>
1255
- <option value="value2">Value 2</option>
1256
- <option value="value3">Value 3</option>
1257
- <optgroup label="Super Values">
1258
- <option value="value11">Value 1</option>
1259
- <option value="value22">Value 2</option>
1260
- <option value="value33">Value 3</option>
1261
- </optgroup>
1262
- </select>
1263
- <select id="addToBodyMultiple" multiple>
1264
- <option value="value1">Value 1</option>
1265
- <option value="value2">Value 2</option>
1266
- <option value="value3">Value 3</option>
1267
- <optgroup label="Super Values">
1268
- <option value="value11">Value 1</option>
1269
- <option value="value22">Value 2</option>
1270
- <option value="value33">Value 3</option>
1271
- </optgroup>
1272
- </select>
1273
- </div>
1274
-
1275
- <pre>
1276
- <code class="language-javascript">
1277
- new SlimSelect({
1278
- select: '#showContent',
1279
- addToBody: true
1280
- })
1281
- </code>
1282
- </pre>
1283
- </div>
1284
-
1285
- <div class="content">
1286
- <h2 class="header">beforeOnChange</h2>
1287
- <p>
1288
- beforeOnChange will trigger a callback on an option click and will allow
1289
- you the ability to halt if the value it produces isnt to your liking.
1290
- In order to stop propagation just return false on the callback.
1291
- Returning nothing or true will allow it to continue as normal.
1292
- </p>
1293
-
1294
- <div v-if="beforeOnChangeSingle"><strong>Before on change: {{beforeOnChangeSingle}}</strong></div>
1295
-
1296
- <select id="beforeOnChangeSingle">
1297
- <option value="value1">Value 1</option>
1298
- <option value="value2">Value 2</option>
1299
- <option value="value3">Value 3</option>
1300
- </select>
1301
- <br /><br />
1302
-
1303
- <div v-if="beforeOnChangeMultiple"><strong>Before on change: {{beforeOnChangeMultiple}}</strong></div>
1304
-
1305
- <select id="beforeOnChangeMultiple" multiple>
1306
- <option value="value1" selected>Value 1</option>
1307
- <option value="value2">Value 2</option>
1308
- <option value="value3">Value 3</option>
1309
- </select>
1310
-
1311
- <pre>
1312
- <code class="language-javascript">
1313
- new SlimSelect({
1314
- select: '#beforeOnChange',
1315
- beforeOnChange: (info) => {
1316
- console.log(info)
1317
- return false // this will stop propagation
1318
- }
1319
- })
1320
- </code>
1321
- </pre>
1322
- </div>
1323
-
1324
- <div class="content">
1325
- <h2 class="header">onChange</h2>
1326
- <p>
1327
- onChange will trigger a callback after the value of the select dropdown has changed.
1328
- </p>
1329
-
1330
- <div v-if="onChangeSingle"><strong>On change: {{onChangeSingle}}</strong></div>
1331
-
1332
- <select id="onChangeSingle">
1333
- <option value="value1">Value 1</option>
1334
- <option value="value2">Value 2</option>
1335
- <option value="value3">Value 3</option>
1336
- </select>
1337
- <br /><br />
1338
-
1339
- <div v-if="onChangeMultiple"><strong>On change: {{onChangeMultiple}}</strong></div>
1340
-
1341
- <select id="onChangeMultiple" multiple>
1342
- <option value="value1" selected>Value 1</option>
1343
- <option value="value2">Value 2</option>
1344
- <option value="value3">Value 3</option>
1345
- </select>
1346
-
1347
- <pre>
1348
- <code class="language-javascript">
1349
- new SlimSelect({
1350
- select: '#onChange',
1351
- onChange: (info) => {
1352
- console.log(info)
1353
- }
1354
- })
1355
- </code>
1356
- </pre>
1357
- </div>
1358
-
1359
- <div class="content">
1360
- <h2 class="header">showOptionTooltips</h2>
1361
- <p>
1362
- showOptionTooltips option is used to active displaying the on-hover tooltips for select options.
1363
- The tooltip text is equal to the option text content.
1364
- </p>
1365
-
1366
- <select id="showOptionTooltips">
1367
- <option value="value1">Value 1</option>
1368
- <option value="value2">Value 2</option>
1369
- <option value="value3">Value 3</option>
1370
- </select>
1371
-
1372
- <pre>
1373
- <code class="language-javascript">
1374
- new SlimSelect({
1375
- select: '#showOptionTooltips',
1376
- showOptionTooltips: true
1377
- })
1378
- </code>
1379
- </pre>
1380
- </div>
1381
-
1382
- <div class="content">
1383
- <h2 class="header">selectByGroup</h2>
1384
- <p>
1385
- selectByGroup option is used to enable the selection of all options under a specific group by clicking that option group's label.
1386
- </p>
1387
-
1388
- <select id="selectByGroup" multiple>
1389
- <optgroup label="Label 1">
1390
- <option value="value1">Value 1</option>
1391
- <option value="value2">Value 2</option>
1392
- <option value="value3">Value 3</option>
1393
- </optgroup>
1394
- </select>
1395
-
1396
- <pre>
1397
- <code class="language-javascript">
1398
- new SlimSelect({
1399
- select: '#selectByGroup',
1400
- selectByGroup: true
1401
- })
1402
- </code>
1403
- </pre>
1404
- </div>
1405
-
1406
- <div class="content">
1407
- <h2 class="header">searchFilter</h2>
1408
- <p>
1409
- searchFilter option is used to replace the default matching algorithm.
1410
- </p>
1411
- <p>
1412
- See methods/setData for the proper object interface of <em>option</em>.
1413
- </p>
1414
-
1415
- <select id="searchFilter">
1416
- <option value="apple">Apple</option>
1417
- <option value="orange">Orange</option>
1418
- <option value="pineapple">Pineapple</option>
1419
- </select>
1420
-
1421
- <pre>
1422
- <code class="language-javascript">
1423
- new SlimSelect({
1424
- select: '#searchFilter',
1425
- // Exact case sensitive start of string match
1426
- searchFilter: (option, search) => {
1427
- return option.text.substr(0, search.length) === search
1428
- }
1429
- })
1430
- </code>
1431
- </pre>
1432
- </div>
1433
-
1434
- <div class="content">
1435
- <h2 class="header">hideSelectedOption</h2>
1436
- <p>
1437
- hideSelectedOption option is used to hide the current selected option in the dropdown.
1438
- </p>
1439
-
1440
- <div class="set-content">
1441
- <select id="hideSelectedOption">
1442
- <option data-placeholder="true"></option>
1443
- <option value="value1">Value 1</option>
1444
- <option value="value2">Value 2</option>
1445
- <option value="value3">Value 3</option>
1446
- </select>
1447
- <select id="hideSelectedOptionMultiple" multiple>
1448
- <option value="value1">Value 1</option>
1449
- <option value="value2">Value 2</option>
1450
- <option value="value3">Value 3</option>
1451
- </select>
1452
- </div>
1453
-
1454
- <pre>
1455
- <code class="language-javascript">
1456
- new SlimSelect({
1457
- select: '.element .you #want',
1458
- hideSelectedOption: true
1459
- })
1460
- </code>
1461
- </pre>
1462
- <pre>
1463
- <code class="language-html">
1464
- &lt;select id="hideSelectedOption"&gt;
1465
- &lt;option data-placeholder="true"&gt;&lt;/option&gt;
1466
- &lt;option value="value1"&gt;Value 1&lt;/option&gt;
1467
- &lt;option value="value2"&gt;Value 2&lt;/option&gt;
1468
- &lt;option value="value3"&gt;Value 3&lt;/option&gt;
1469
- &lt;/select&gt;
1470
-
1471
- &lt;select id="hideSelectedOptionMultiple"&gt;
1472
- &lt;option value="value1"&gt;Value 1&lt;/option&gt;
1473
- &lt;option value="value2"&gt;Value 2&lt;/option&gt;
1474
- &lt;option value="value3"&gt;Value 3&lt;/option&gt;
1475
- &lt;/select&gt;
1476
- </code>
1477
- </pre>
1478
- </div>
1479
- </div>
1480
- </template>