slim-select 2.13.1 → 3.0.1
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.
- package/README.md +185 -44
- package/dist/index.d.ts +304 -52
- package/dist/react/index.d.ts +304 -0
- package/dist/react/index.js +1549 -0
- package/dist/react/index.umd.js +22 -0
- package/dist/slimselect.cjs.js +2 -2030
- package/dist/slimselect.cjs.js.map +1 -0
- package/dist/slimselect.css +1 -1
- package/dist/slimselect.css.map +1 -1
- package/dist/slimselect.es.js +1225 -2012
- package/dist/slimselect.es.js.map +1 -0
- package/dist/slimselect.iife.js +2 -0
- package/dist/slimselect.iife.js.map +1 -0
- package/dist/slimselect.js +2 -2036
- package/dist/slimselect.js.map +1 -0
- package/dist/vue/index.d.ts +304 -0
- package/dist/vue/index.js +1341 -0
- package/dist/vue/index.umd.js +1 -0
- package/index.html +1 -0
- package/package.json +63 -40
- package/release.js +0 -7
- package/src/slim-select/accessibility.test.ts +782 -0
- package/src/slim-select/classes.test.ts +7 -6
- package/src/slim-select/classes.ts +8 -6
- package/src/slim-select/helpers.test.ts +10 -8
- package/src/slim-select/index.test.ts +509 -14
- package/src/slim-select/index.ts +58 -31
- package/src/slim-select/react/index.tsx +9 -0
- package/src/slim-select/react/react.tsx +112 -0
- package/src/slim-select/render.test.ts +479 -119
- package/src/slim-select/render.ts +213 -91
- package/src/slim-select/select.test.ts +28 -10
- package/src/slim-select/select.ts +35 -12
- package/src/slim-select/settings.test.ts +19 -8
- package/src/slim-select/settings.ts +2 -4
- package/src/slim-select/slimselect.scss +30 -15
- package/src/slim-select/store.test.ts +13 -16
- package/src/slim-select/store.ts +97 -86
- package/src/slim-select/vue/index.ts +9 -0
- package/src/slim-select/vue/vue.test.ts +832 -0
- package/src/slim-select/{vue.vue → vue/vue.vue} +45 -23
- package/tsconfig.json +6 -4
- package/{vite.config.mts → vite.config.docs.mts} +10 -0
- package/vite.config.lib.mts +48 -0
- package/vite.config.react.mts +40 -0
- package/vite.config.vue.mts +39 -0
- package/vitest.config.ts +29 -0
- package/dist/classes.d.ts +0 -43
- package/dist/helpers.d.ts +0 -5
- package/dist/render.d.ts +0 -81
- package/dist/select.d.ts +0 -30
- package/dist/settings.d.ts +0 -35
- package/dist/slimselect.global.js +0 -2033
- package/dist/slimselect.min.js +0 -1
- package/dist/slimselect.umd.js +0 -2036
- package/dist/slimselect.umd.min.js +0 -1
- package/dist/store.d.ts +0 -84
- package/jest.config.js +0 -14
- package/src/slim-select/rollup.config.mjs +0 -127
- package/src/slim-select/tsconfig.json +0 -14
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# Slim Select
|
|
1
|
+
# Slim Select
|
|
2
2
|
|
|
3
3
|
## [slimselectjs.com](https://slimselectjs.com)
|
|
4
4
|
|
|
5
5
|
Advanced select dropdown
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/slim-select)
|
|
8
|
-
 [](https://snyk.io/advisor/npm-package/slim-select)
|
|
9
9
|
|
|
10
10
|
## Support
|
|
11
11
|
|
|
@@ -39,10 +39,12 @@ See [website](https://slimselectjs.com) for the full list of [settings](https://
|
|
|
39
39
|
- Clean Animations
|
|
40
40
|
- Performant
|
|
41
41
|
- Typescript
|
|
42
|
+
- ARIA Accessibility (WCAG 2.1 Level AA compliant)
|
|
42
43
|
|
|
43
44
|
## Frameworks
|
|
44
45
|
|
|
45
|
-
- Vue
|
|
46
|
+
- [Vue](#vue)
|
|
47
|
+
- [React](#react)
|
|
46
48
|
|
|
47
49
|
## Installation
|
|
48
50
|
|
|
@@ -53,7 +55,7 @@ npm install slim-select
|
|
|
53
55
|
### or
|
|
54
56
|
|
|
55
57
|
```html
|
|
56
|
-
<script src="https://unpkg.com/slim-select@latest/dist/slimselect.
|
|
58
|
+
<script src="https://unpkg.com/slim-select@latest/dist/slimselect.js"></script>
|
|
57
59
|
<link rel="stylesheet" href="https://unpkg.com/slim-select@latest/dist/slimselect.css" />
|
|
58
60
|
```
|
|
59
61
|
|
|
@@ -65,7 +67,7 @@ import 'slim-select/styles' // optional css import method
|
|
|
65
67
|
import 'slim-select/scss' // optional scss import method
|
|
66
68
|
|
|
67
69
|
new SlimSelect({
|
|
68
|
-
select: '#selectElement'
|
|
70
|
+
select: '#selectElement'
|
|
69
71
|
})
|
|
70
72
|
```
|
|
71
73
|
|
|
@@ -91,7 +93,7 @@ new SlimSelect({
|
|
|
91
93
|
// or
|
|
92
94
|
|
|
93
95
|
// Array of Optgroups and/or Options
|
|
94
|
-
data: [{ label: 'Optgroup Label', options: { text: 'Value 1', value: 'value1' } }]
|
|
96
|
+
data: [{ label: 'Optgroup Label', options: { text: 'Value 1', value: 'value1' } }]
|
|
95
97
|
})
|
|
96
98
|
```
|
|
97
99
|
|
|
@@ -103,7 +105,7 @@ var optgroup = {
|
|
|
103
105
|
label: 'label', // Required
|
|
104
106
|
selectAll: false, // Optional - default false
|
|
105
107
|
closable: 'off', // Optional - default 'off' - 'off', 'open', 'close'
|
|
106
|
-
options: []
|
|
108
|
+
options: [] // Required - value is an array of options
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
// <option>
|
|
@@ -118,44 +120,46 @@ var option = {
|
|
|
118
120
|
placeholder: false, // Optional - default is false
|
|
119
121
|
class: '', // Optional - default is not set
|
|
120
122
|
style: '', // Optional - default is not set
|
|
121
|
-
data: {}
|
|
123
|
+
data: {} // Optional - If you have data attributes
|
|
122
124
|
}
|
|
123
125
|
```
|
|
124
126
|
|
|
125
127
|
## Settings
|
|
126
128
|
|
|
127
|
-
Settings are
|
|
129
|
+
Settings are optional fields that customize how SlimSelect operates. All values shown are defaults.
|
|
130
|
+
|
|
131
|
+
[Full Settings Documentation](https://slimselectjs.com/settings)
|
|
128
132
|
|
|
129
133
|
```javascript
|
|
130
134
|
new SlimSelect({
|
|
131
135
|
select: '#selectElement',
|
|
132
136
|
|
|
133
137
|
settings: {
|
|
134
|
-
|
|
135
|
-
//
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
showOptionTooltips: false,
|
|
152
|
-
minSelected: 0,
|
|
153
|
-
maxSelected: 1000,
|
|
154
|
-
timeoutDelay: 200,
|
|
155
|
-
maxValuesShown: 20,
|
|
156
|
-
maxValuesMessage: '{number} selected',
|
|
157
|
-
addableText: 'Press "Enter" to add {value}'
|
|
158
|
-
}
|
|
138
|
+
disabled: false, // Disable the select
|
|
139
|
+
alwaysOpen: false, // Keep dropdown always open
|
|
140
|
+
showSearch: true, // Show search input
|
|
141
|
+
focusSearch: true, // Auto focus search on open
|
|
142
|
+
ariaLabel: 'Combobox', // ARIA label for accessibility
|
|
143
|
+
searchPlaceholder: 'Search', // Search input placeholder
|
|
144
|
+
searchText: 'No Results', // Text when no results found
|
|
145
|
+
searchingText: 'Searching...', // Text while searching
|
|
146
|
+
searchHighlight: false, // Highlight search terms
|
|
147
|
+
closeOnSelect: true, // Close dropdown after selection
|
|
148
|
+
contentLocation: document.body, // Where to append dropdown
|
|
149
|
+
contentPosition: 'absolute', // CSS position: absolute, relative, fixed
|
|
150
|
+
openPosition: 'auto', // Open direction: auto, up, down
|
|
151
|
+
placeholderText: 'Select Value', // Placeholder text
|
|
152
|
+
allowDeselect: false, // Allow deselecting in single select
|
|
153
|
+
hideSelected: false, // Hide selected options in dropdown
|
|
154
|
+
keepOrder: false, // Keep user click order (not DOM order) for getSelected
|
|
155
|
+
showOptionTooltips: false, // Show tooltips on options
|
|
156
|
+
minSelected: 0, // Minimum selections (multi-select)
|
|
157
|
+
maxSelected: 1000, // Maximum selections (multi-select)
|
|
158
|
+
timeoutDelay: 200, // Delay for callbacks (ms)
|
|
159
|
+
maxValuesShown: 20, // Max values shown before message
|
|
160
|
+
maxValuesMessage: '{number} selected', // Message when max values exceeded
|
|
161
|
+
addableText: 'Press "Enter" to add {value}' // Text for addable option
|
|
162
|
+
}
|
|
159
163
|
})
|
|
160
164
|
```
|
|
161
165
|
|
|
@@ -163,21 +167,158 @@ new SlimSelect({
|
|
|
163
167
|
|
|
164
168
|
Events are function callbacks for when certain actions happen
|
|
165
169
|
|
|
170
|
+
[Full Events Documentation](https://slimselectjs.com/events)
|
|
171
|
+
|
|
166
172
|
```javascript
|
|
167
173
|
new SlimSelect({
|
|
168
174
|
select: '#selectElement',
|
|
169
175
|
|
|
170
176
|
events: {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
177
|
+
// Custom search function - return Promise or data array
|
|
178
|
+
search: (searchValue: string, currentData: (Option | Optgroup)[]) => Promise<(Partial<Option> | Partial<Optgroup>)[]> | (Partial<Option> | Partial<Optgroup>)[],
|
|
179
|
+
|
|
180
|
+
// Filter function for search - return true to show option
|
|
181
|
+
searchFilter: (option: Option, search: string) => boolean,
|
|
182
|
+
|
|
183
|
+
// Allow user to add options - return new option or error
|
|
184
|
+
addable: (value: string) => Promise<Partial<Option> | string> | Partial<Option> | string | Error,
|
|
185
|
+
|
|
186
|
+
// Before selection changes - return false to prevent change
|
|
187
|
+
beforeChange: (newVal: Option[], oldVal: Option[]) => boolean | void,
|
|
188
|
+
|
|
189
|
+
// After selection changes
|
|
190
|
+
afterChange: (newVal: Option[]) => void,
|
|
191
|
+
|
|
192
|
+
// Before dropdown opens
|
|
193
|
+
beforeOpen: () => void,
|
|
194
|
+
|
|
195
|
+
// After dropdown opens
|
|
196
|
+
afterOpen: () => void,
|
|
197
|
+
|
|
198
|
+
// Before dropdown closes
|
|
199
|
+
beforeClose: () => void,
|
|
200
|
+
|
|
201
|
+
// After dropdown closes
|
|
202
|
+
afterClose: () => void,
|
|
203
|
+
|
|
204
|
+
// Error handler
|
|
180
205
|
error: (err: Error) => void
|
|
181
|
-
}
|
|
206
|
+
}
|
|
182
207
|
})
|
|
183
208
|
```
|
|
209
|
+
|
|
210
|
+
## Methods
|
|
211
|
+
|
|
212
|
+
SlimSelect provides methods to programmatically control the select
|
|
213
|
+
|
|
214
|
+
[Full Methods Documentation](https://slimselectjs.com/methods)
|
|
215
|
+
|
|
216
|
+
```javascript
|
|
217
|
+
const slim = new SlimSelect({ select: '#selectElement' })
|
|
218
|
+
|
|
219
|
+
slim.enable() // Enable the select
|
|
220
|
+
slim.disable() // Disable the select
|
|
221
|
+
slim.getData() // Get current data array
|
|
222
|
+
slim.setData(data) // Set new data array
|
|
223
|
+
slim.getSelected() // Get selected values as string[]
|
|
224
|
+
slim.setSelected(['value1', 'value2']) // Set selected by values
|
|
225
|
+
slim.addOption(option) // Add a single option
|
|
226
|
+
slim.open() // Open the dropdown
|
|
227
|
+
slim.close() // Close the dropdown
|
|
228
|
+
slim.search('searchValue') // Programmatically search
|
|
229
|
+
slim.destroy() // Destroy the instance
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Vue
|
|
233
|
+
|
|
234
|
+
SlimSelect has official Vue 3 component support with full reactivity.
|
|
235
|
+
|
|
236
|
+
For more Vue examples and advanced usage, see the [Vue documentation](https://slimselectjs.com/vue).
|
|
237
|
+
|
|
238
|
+
### Installation
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
npm install slim-select
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Usage
|
|
245
|
+
|
|
246
|
+
```vue
|
|
247
|
+
<script lang="ts">
|
|
248
|
+
import SlimSelect from 'slim-select/vue'
|
|
249
|
+
import 'slim-select/styles'
|
|
250
|
+
|
|
251
|
+
export default {
|
|
252
|
+
components: { SlimSelect },
|
|
253
|
+
data() {
|
|
254
|
+
return {
|
|
255
|
+
selected: 'value2',
|
|
256
|
+
options: [
|
|
257
|
+
{ text: 'Value 1', value: 'value1' },
|
|
258
|
+
{ text: 'Value 2', value: 'value2' },
|
|
259
|
+
{ text: 'Value 3', value: 'value3' }
|
|
260
|
+
]
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
</script>
|
|
265
|
+
|
|
266
|
+
<template>
|
|
267
|
+
<SlimSelect v-model="selected" :data="options" />
|
|
268
|
+
</template>
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
## React
|
|
272
|
+
|
|
273
|
+
SlimSelect has official React component support with hooks.
|
|
274
|
+
|
|
275
|
+
For more React examples and advanced usage, see the [documentation](https://slimselectjs.com).
|
|
276
|
+
|
|
277
|
+
### Installation
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
npm install slim-select
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Usage
|
|
284
|
+
|
|
285
|
+
```tsx
|
|
286
|
+
import { useState } from 'react'
|
|
287
|
+
import SlimSelect from 'slim-select/react'
|
|
288
|
+
import 'slim-select/styles'
|
|
289
|
+
|
|
290
|
+
function MyComponent() {
|
|
291
|
+
const [selected, setSelected] = useState('value2')
|
|
292
|
+
const options = [
|
|
293
|
+
{ text: 'Value 1', value: 'value1' },
|
|
294
|
+
{ text: 'Value 2', value: 'value2' },
|
|
295
|
+
{ text: 'Value 3', value: 'value3' }
|
|
296
|
+
]
|
|
297
|
+
|
|
298
|
+
return <SlimSelect data={options} value={selected} onChange={setSelected} />
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### Advanced Usage with Ref
|
|
303
|
+
|
|
304
|
+
```tsx
|
|
305
|
+
import { useRef } from 'react'
|
|
306
|
+
import SlimSelect, { SlimSelectRef } from 'slim-select/react'
|
|
307
|
+
import 'slim-select/styles'
|
|
308
|
+
|
|
309
|
+
function MyComponent() {
|
|
310
|
+
const slimRef = useRef<SlimSelectRef>(null)
|
|
311
|
+
|
|
312
|
+
const handleClick = () => {
|
|
313
|
+
// Access SlimSelect methods via ref
|
|
314
|
+
slimRef.current?.slimSelect?.open()
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return (
|
|
318
|
+
<>
|
|
319
|
+
<SlimSelect ref={slimRef} data={options} />
|
|
320
|
+
<button onClick={handleClick}>Open Dropdown</button>
|
|
321
|
+
</>
|
|
322
|
+
)
|
|
323
|
+
}
|
|
324
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,52 +1,304 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
1
|
+
declare interface Callbacks {
|
|
2
|
+
open: () => void;
|
|
3
|
+
close: () => void;
|
|
4
|
+
addable?: (value: string) => Promise<Partial<Option_2> | string> | Partial<Option_2> | string | false | undefined | null | Error;
|
|
5
|
+
setSelected: (value: string | string[], runAfterChange: boolean) => void;
|
|
6
|
+
addOption: (option: Option_2) => void;
|
|
7
|
+
search: (search: string) => void;
|
|
8
|
+
beforeChange?: (newVal: Option_2[], oldVal: Option_2[]) => boolean | void;
|
|
9
|
+
afterChange?: (newVal: Option_2[]) => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export declare interface Config {
|
|
13
|
+
select: string | Element;
|
|
14
|
+
data?: (Partial<Option_2> | Partial<Optgroup>)[];
|
|
15
|
+
settings?: Partial<Settings>;
|
|
16
|
+
cssClasses?: Partial<CssClasses>;
|
|
17
|
+
events?: Events;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare interface Content {
|
|
21
|
+
main: HTMLDivElement;
|
|
22
|
+
search: Search;
|
|
23
|
+
list: HTMLDivElement;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare class CssClasses {
|
|
27
|
+
main: string;
|
|
28
|
+
placeholder: string;
|
|
29
|
+
values: string;
|
|
30
|
+
single: string;
|
|
31
|
+
max: string;
|
|
32
|
+
value: string;
|
|
33
|
+
valueText: string;
|
|
34
|
+
valueDelete: string;
|
|
35
|
+
valueOut: string;
|
|
36
|
+
deselect: string;
|
|
37
|
+
deselectPath: string;
|
|
38
|
+
arrow: string;
|
|
39
|
+
arrowClose: string;
|
|
40
|
+
arrowOpen: string;
|
|
41
|
+
content: string;
|
|
42
|
+
contentOpen: string;
|
|
43
|
+
dirAbove: string;
|
|
44
|
+
dirBelow: string;
|
|
45
|
+
search: string;
|
|
46
|
+
searchHighlighter: string;
|
|
47
|
+
searching: string;
|
|
48
|
+
addable: string;
|
|
49
|
+
addablePath: string;
|
|
50
|
+
list: string;
|
|
51
|
+
optgroup: string;
|
|
52
|
+
optgroupLabel: string;
|
|
53
|
+
optgroupLabelText: string;
|
|
54
|
+
optgroupActions: string;
|
|
55
|
+
optgroupSelectAll: string;
|
|
56
|
+
optgroupSelectAllBox: string;
|
|
57
|
+
optgroupSelectAllCheck: string;
|
|
58
|
+
optgroupClosable: string;
|
|
59
|
+
option: string;
|
|
60
|
+
optionDelete: string;
|
|
61
|
+
highlighted: string;
|
|
62
|
+
mainOpen: string;
|
|
63
|
+
close: string;
|
|
64
|
+
selected: string;
|
|
65
|
+
error: string;
|
|
66
|
+
disabled: string;
|
|
67
|
+
hide: string;
|
|
68
|
+
constructor(classes?: Partial<CssClasses>);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export declare interface Events {
|
|
72
|
+
search?: (searchValue: string, currentData: (Option_2 | Optgroup)[]) => Promise<(Partial<Option_2> | Partial<Optgroup>)[]> | (Partial<Option_2> | Partial<Optgroup>)[];
|
|
73
|
+
searchFilter?: (option: Option_2, search: string) => boolean;
|
|
74
|
+
addable?: (value: string) => Promise<Partial<Option_2> | string> | Partial<Option_2> | string | false | null | undefined | Error;
|
|
75
|
+
beforeChange?: (newVal: Option_2[], oldVal: Option_2[]) => boolean | void;
|
|
76
|
+
afterChange?: (newVal: Option_2[]) => void;
|
|
77
|
+
beforeOpen?: () => void;
|
|
78
|
+
afterOpen?: () => void;
|
|
79
|
+
beforeClose?: () => void;
|
|
80
|
+
afterClose?: () => void;
|
|
81
|
+
error?: (err: Error) => void;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
declare interface Main {
|
|
85
|
+
main: HTMLDivElement;
|
|
86
|
+
values: HTMLDivElement;
|
|
87
|
+
deselect: {
|
|
88
|
+
main: HTMLDivElement;
|
|
89
|
+
svg: SVGSVGElement;
|
|
90
|
+
path: SVGPathElement;
|
|
91
|
+
};
|
|
92
|
+
arrow: {
|
|
93
|
+
main: SVGSVGElement;
|
|
94
|
+
path: SVGPathElement;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export declare class Optgroup {
|
|
99
|
+
id: string;
|
|
100
|
+
label: string;
|
|
101
|
+
selectAll: boolean;
|
|
102
|
+
selectAllText: string;
|
|
103
|
+
closable: 'off' | 'open' | 'close';
|
|
104
|
+
options: Partial<Option_2>[];
|
|
105
|
+
constructor(optgroup: Partial<Optgroup>);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
declare class Option_2 {
|
|
109
|
+
id: string;
|
|
110
|
+
value: string;
|
|
111
|
+
text: string;
|
|
112
|
+
html: string;
|
|
113
|
+
defaultSelected: boolean;
|
|
114
|
+
selected: boolean;
|
|
115
|
+
display: boolean;
|
|
116
|
+
disabled: boolean;
|
|
117
|
+
placeholder: boolean;
|
|
118
|
+
class: string;
|
|
119
|
+
style: string;
|
|
120
|
+
data: {
|
|
121
|
+
[key: string]: string;
|
|
122
|
+
};
|
|
123
|
+
mandatory: boolean;
|
|
124
|
+
constructor(option: Partial<Option_2>);
|
|
125
|
+
}
|
|
126
|
+
export { Option_2 as Option }
|
|
127
|
+
|
|
128
|
+
export declare class Render {
|
|
129
|
+
settings: Settings;
|
|
130
|
+
store: Store;
|
|
131
|
+
callbacks: Callbacks;
|
|
132
|
+
private lastSelectedOption;
|
|
133
|
+
main: Main;
|
|
134
|
+
content: Content;
|
|
135
|
+
classes: CssClasses;
|
|
136
|
+
constructor(settings: Required<Settings>, classes: Required<CssClasses>, store: Store, callbacks: Callbacks);
|
|
137
|
+
enable(): void;
|
|
138
|
+
disable(): void;
|
|
139
|
+
open(): void;
|
|
140
|
+
close(): void;
|
|
141
|
+
updateClassStyles(): void;
|
|
142
|
+
updateAriaAttributes(): void;
|
|
143
|
+
mainDiv(): Main;
|
|
144
|
+
mainFocus(eventType: string | null): void;
|
|
145
|
+
placeholder(): HTMLDivElement;
|
|
146
|
+
renderValues(): void;
|
|
147
|
+
private renderSingleValue;
|
|
148
|
+
private renderMultipleValues;
|
|
149
|
+
multipleValue(option: Option_2): HTMLDivElement;
|
|
150
|
+
contentDiv(): Content;
|
|
151
|
+
moveContent(): void;
|
|
152
|
+
searchDiv(): Search;
|
|
153
|
+
searchFocus(): void;
|
|
154
|
+
clearSearch(): void;
|
|
155
|
+
getOptions(notPlaceholder?: boolean, notDisabled?: boolean, notHidden?: boolean): HTMLDivElement[];
|
|
156
|
+
highlight(dir: 'up' | 'down'): void;
|
|
157
|
+
listDiv(): HTMLDivElement;
|
|
158
|
+
renderError(error: string): void;
|
|
159
|
+
renderSearching(): void;
|
|
160
|
+
renderOptions(data: (Option_2 | Optgroup)[]): void;
|
|
161
|
+
option(option: Option_2): HTMLDivElement;
|
|
162
|
+
destroy(): void;
|
|
163
|
+
private highlightText;
|
|
164
|
+
moveContentAbove(): void;
|
|
165
|
+
moveContentBelow(): void;
|
|
166
|
+
ensureElementInView(container: HTMLElement, element: HTMLElement): void;
|
|
167
|
+
putContent(): 'up' | 'down';
|
|
168
|
+
updateDeselectAll(): void;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
declare interface Search {
|
|
172
|
+
main: HTMLDivElement;
|
|
173
|
+
input: HTMLInputElement;
|
|
174
|
+
addable?: {
|
|
175
|
+
main: HTMLDivElement;
|
|
176
|
+
svg: SVGSVGElement;
|
|
177
|
+
path: SVGPathElement;
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export declare class Select {
|
|
182
|
+
select: HTMLSelectElement;
|
|
183
|
+
onValueChange?: (value: Option_2[]) => void;
|
|
184
|
+
onClassChange?: (classes: string[]) => void;
|
|
185
|
+
onDisabledChange?: (disabled: boolean) => void;
|
|
186
|
+
onOptionsChange?: (data: (Option_2 | Optgroup)[]) => void;
|
|
187
|
+
listen: boolean;
|
|
188
|
+
private observer;
|
|
189
|
+
constructor(select: HTMLSelectElement);
|
|
190
|
+
enable(): void;
|
|
191
|
+
disable(): void;
|
|
192
|
+
hideUI(): void;
|
|
193
|
+
showUI(): void;
|
|
194
|
+
changeListen(listen: boolean): void;
|
|
195
|
+
valueChange(ev: Event): boolean;
|
|
196
|
+
private observeCall;
|
|
197
|
+
getData(): (Option_2 | Optgroup)[];
|
|
198
|
+
getDataFromOptgroup(optgroup: HTMLOptGroupElement): Optgroup;
|
|
199
|
+
getDataFromOption(option: HTMLOptionElement): Option_2;
|
|
200
|
+
getSelectedOptions(): Option_2[];
|
|
201
|
+
getSelectedValues(): string[];
|
|
202
|
+
setSelected(ids: string[]): void;
|
|
203
|
+
setSelectedByValue(values: string[]): void;
|
|
204
|
+
updateSelect(id?: string, style?: string, classes?: string[]): void;
|
|
205
|
+
updateOptions(data: (Option_2 | Optgroup)[]): void;
|
|
206
|
+
createOptgroup(optgroup: Optgroup): HTMLOptGroupElement;
|
|
207
|
+
createOption(info: Option_2): HTMLOptionElement;
|
|
208
|
+
destroy(): void;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
declare type selectType = 'single' | 'multiple';
|
|
212
|
+
|
|
213
|
+
export declare class Settings {
|
|
214
|
+
id: string;
|
|
215
|
+
style: string;
|
|
216
|
+
class: string[];
|
|
217
|
+
isMultiple: boolean;
|
|
218
|
+
isOpen: boolean;
|
|
219
|
+
isFullOpen: boolean;
|
|
220
|
+
intervalMove: ReturnType<typeof setInterval> | null;
|
|
221
|
+
disabled: boolean;
|
|
222
|
+
alwaysOpen: boolean;
|
|
223
|
+
showSearch: boolean;
|
|
224
|
+
focusSearch: boolean;
|
|
225
|
+
ariaLabel: string;
|
|
226
|
+
searchPlaceholder: string;
|
|
227
|
+
searchText: string;
|
|
228
|
+
searchingText: string;
|
|
229
|
+
searchHighlight: boolean;
|
|
230
|
+
closeOnSelect: boolean;
|
|
231
|
+
contentLocation: HTMLElement | null;
|
|
232
|
+
contentPosition: 'relative' | 'absolute' | 'fixed';
|
|
233
|
+
openPosition: 'auto' | 'up' | 'down';
|
|
234
|
+
placeholderText: string;
|
|
235
|
+
allowDeselect: boolean;
|
|
236
|
+
hideSelected: boolean;
|
|
237
|
+
keepOrder: boolean;
|
|
238
|
+
showOptionTooltips: boolean;
|
|
239
|
+
minSelected: number;
|
|
240
|
+
maxSelected: number;
|
|
241
|
+
timeoutDelay: number;
|
|
242
|
+
maxValuesShown: number;
|
|
243
|
+
maxValuesMessage: string;
|
|
244
|
+
addableText: string;
|
|
245
|
+
constructor(settings?: Partial<Settings>);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
declare class SlimSelect {
|
|
249
|
+
selectEl: HTMLSelectElement;
|
|
250
|
+
settings: Settings;
|
|
251
|
+
cssClasses: CssClasses;
|
|
252
|
+
select: Select;
|
|
253
|
+
store: Store;
|
|
254
|
+
render: Render;
|
|
255
|
+
private openTimeout;
|
|
256
|
+
private closeTimeout;
|
|
257
|
+
events: Events;
|
|
258
|
+
constructor(config: Config);
|
|
259
|
+
enable(): void;
|
|
260
|
+
disable(): void;
|
|
261
|
+
getData(): Option_2[] | Optgroup[];
|
|
262
|
+
setData(data: (Partial<Option_2> | Partial<Optgroup>)[]): void;
|
|
263
|
+
getSelected(): string[];
|
|
264
|
+
setSelected(values: string | string[], runAfterChange?: boolean): void;
|
|
265
|
+
addOption(option: Partial<Option_2>): void;
|
|
266
|
+
open(): void;
|
|
267
|
+
close(eventType?: string | null): void;
|
|
268
|
+
search(value: string): void;
|
|
269
|
+
destroy(): void;
|
|
270
|
+
private windowResize;
|
|
271
|
+
private windowScroll;
|
|
272
|
+
private documentClick;
|
|
273
|
+
private windowVisibilityChange;
|
|
274
|
+
}
|
|
275
|
+
export default SlimSelect;
|
|
276
|
+
|
|
277
|
+
export declare class Store {
|
|
278
|
+
private selectType;
|
|
279
|
+
private data;
|
|
280
|
+
private selectedOrder;
|
|
281
|
+
constructor(type: selectType, data: (Partial<Option_2> | Partial<Optgroup>)[]);
|
|
282
|
+
validateDataArray(data: (Partial<Option_2> | Partial<Optgroup>)[]): Error | null;
|
|
283
|
+
validateOption(option: Partial<Option_2>): Error | null;
|
|
284
|
+
partialToFullData(data: (Partial<Option_2> | Partial<Optgroup>)[]): (Option_2 | Optgroup)[];
|
|
285
|
+
setData(data: (Partial<Option_2> | Partial<Optgroup>)[], preserveSelected?: boolean): void;
|
|
286
|
+
getData(): Option_2[] | Optgroup[];
|
|
287
|
+
getDataOptions(): Option_2[];
|
|
288
|
+
addOption(option: Partial<Option_2>, addToStart?: boolean): void;
|
|
289
|
+
setSelectedBy(selectedType: 'id' | 'value', selectedValues: string[]): void;
|
|
290
|
+
getSelected(): string[];
|
|
291
|
+
getSelectedValues(): string[];
|
|
292
|
+
getSelectedOptions(): Option_2[];
|
|
293
|
+
getOptgroupByID(id: string): Optgroup | null;
|
|
294
|
+
getOptionByID(id: string): Option_2 | null;
|
|
295
|
+
getSelectType(): string;
|
|
296
|
+
getFirstOption(): Option_2 | null;
|
|
297
|
+
search(search: string, searchFilter: (opt: Option_2, search: string) => boolean): (Option_2 | Optgroup)[];
|
|
298
|
+
filter(filter: {
|
|
299
|
+
(opt: Option_2): boolean;
|
|
300
|
+
} | null, includeOptgroup: boolean): (Option_2 | Optgroup)[];
|
|
301
|
+
selectedOrderOptions(options: Option_2[]): Option_2[];
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export { }
|