@danielgindi/selectbox 2.0.57 → 2.0.59
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/dist/lib.cjs.js +227 -681
- package/dist/lib.cjs.js.map +1 -1
- package/dist/lib.cjs.min.js +2 -2
- package/dist/lib.cjs.min.js.map +1 -1
- package/dist/lib.es6.js +230 -681
- package/dist/lib.es6.js.map +1 -1
- package/dist/lib.es6.min.js +2 -2
- package/dist/lib.es6.min.js.map +1 -1
- package/dist/lib.umd.js +227 -681
- package/dist/lib.umd.js.map +1 -1
- package/dist/lib.umd.min.js +2 -2
- package/dist/lib.umd.min.js.map +1 -1
- package/dist/types/DropList.d.ts +205 -0
- package/dist/types/DropList.d.ts.map +1 -0
- package/dist/types/SelectBox.d.ts +209 -0
- package/dist/types/SelectBox.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types.d.ts +222 -0
- package/dist/types/types.d.ts.map +1 -0
- package/eslint.config.mjs +8 -0
- package/lib/DropList.js +1 -3430
- package/lib/SelectBox.js +1 -3689
- package/lib/index.js +1 -4
- package/package.json +17 -12
- package/tsconfig.json +35 -0
- package/vue/DropList.vue +508 -565
- package/vue/DropList.vue.d.ts +4 -0
- package/vue/SelectBox.vue +780 -981
- package/vue/SelectBox.vue.d.ts +4 -0
- package/vue/component-types.d.ts +210 -0
- package/vue/index.d.ts +4 -0
- package/vue/index.js +3 -4
- package/vue/utils/slots.js +71 -96
- package/lib/utils/escapeRegex.js +0 -1
- package/lib/utils/throttle.js +0 -48
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import type { DropListOptions, ItemBase, PositionOptions } from './types.js';
|
|
2
|
+
declare const ItemSymbol: unique symbol;
|
|
3
|
+
export declare const DefaultOptions: DropListOptions;
|
|
4
|
+
declare class DropList {
|
|
5
|
+
constructor(options: DropListOptions);
|
|
6
|
+
destroy(): void;
|
|
7
|
+
get el(): HTMLElement | null;
|
|
8
|
+
/**
|
|
9
|
+
* Returns true if other is an inclusive descendant of node, and false otherwise.
|
|
10
|
+
* Accepts `EventTarget` (not just `Node`) since callers pass `event.target`/`event.relatedTarget` directly.
|
|
11
|
+
*/
|
|
12
|
+
elContains(other: EventTarget | Node | null, considerSubmenus?: boolean): boolean;
|
|
13
|
+
setAdditionalClasses(classes: string | string[]): this;
|
|
14
|
+
/**
|
|
15
|
+
* Sets the appropriate direction for the droplist
|
|
16
|
+
*/
|
|
17
|
+
setDirection(direction: 'ltr' | 'rtl' | 'auto'): this;
|
|
18
|
+
/**
|
|
19
|
+
* Gets the supplied direction for the droplist
|
|
20
|
+
*/
|
|
21
|
+
getDirection(): 'ltr' | 'rtl' | 'auto';
|
|
22
|
+
setLabelProp(prop: string): this;
|
|
23
|
+
setRenderItem(fn: DropListOptions['renderItem']): this;
|
|
24
|
+
setUnrenderItem(fn: DropListOptions['unrenderItem']): this;
|
|
25
|
+
setRenderNoResultsItem(render: DropListOptions['renderNoResultsItem'], unrender: DropListOptions['unrenderNoResultsItem']): this;
|
|
26
|
+
setValueProp(prop: string): this;
|
|
27
|
+
blurFocusedItem(): void;
|
|
28
|
+
nextPage(event: Event): void;
|
|
29
|
+
previousPage(event: Event): void;
|
|
30
|
+
goToFirst(event: Event): void;
|
|
31
|
+
goToLast(event: Event): void;
|
|
32
|
+
toggleFocusedItem(event?: Event): this;
|
|
33
|
+
triggerItemSelection(item: any, event: Event): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* @param item The item to add. It is copied.
|
|
36
|
+
* @param atIndex The index to insert at (or -1)
|
|
37
|
+
*/
|
|
38
|
+
addItem(item: ItemBase, atIndex?: number): this;
|
|
39
|
+
/**
|
|
40
|
+
* Adds items to the menu and renders
|
|
41
|
+
* @param itemsToAdd The items to add. These are copied.
|
|
42
|
+
* @param atIndex The index to insert at (or -1)
|
|
43
|
+
*/
|
|
44
|
+
addItems(itemsToAdd: ItemBase[], atIndex?: number): this;
|
|
45
|
+
/**
|
|
46
|
+
* Replaces all current items with the supplied items
|
|
47
|
+
* @param items The items to set. These are copied.
|
|
48
|
+
*/
|
|
49
|
+
setItems(items: ItemBase[]): this;
|
|
50
|
+
updateItemByValue(value: any, newItem: ItemBase): this;
|
|
51
|
+
removeItem(value: any, label?: string): this;
|
|
52
|
+
removeAllItems(): this;
|
|
53
|
+
/**
|
|
54
|
+
* Should only be used if the items array has been manually manipulated.
|
|
55
|
+
* @return {DropList}
|
|
56
|
+
*/
|
|
57
|
+
invalidate(): this;
|
|
58
|
+
itemDataByValue(value: any): any;
|
|
59
|
+
itemIndexByValue(value: any): number;
|
|
60
|
+
filteredItemIndexByValue(value: any): number;
|
|
61
|
+
itemIndexByValueOrLabel(value: any, label?: string): number;
|
|
62
|
+
filteredItemIndexByValueOrLabel(value: any, label?: string): number;
|
|
63
|
+
itemIndexByItem(item: ItemBase): number;
|
|
64
|
+
filteredItemIndexByItem(item: ItemBase): number;
|
|
65
|
+
items(): ItemBase[];
|
|
66
|
+
itemsReference(): InternalItem[];
|
|
67
|
+
itemCount(): number;
|
|
68
|
+
itemAtIndex(index: number): any;
|
|
69
|
+
filteredItemAtIndex(index: number): any;
|
|
70
|
+
/**
|
|
71
|
+
* Return the item element at the given original index, if it exists.
|
|
72
|
+
* The item may not be currently rendered, and null will be returned
|
|
73
|
+
*/
|
|
74
|
+
itemElementAtIndex(index: number): HTMLElement | null;
|
|
75
|
+
/**
|
|
76
|
+
* Return the item element at the given index, if it exists.
|
|
77
|
+
* The item may not be currently rendered, and null will be returned
|
|
78
|
+
*/
|
|
79
|
+
filteredElementItemAtIndex(index: number): HTMLElement | null;
|
|
80
|
+
setPositionOptionsProvider(fn: DropListOptions['positionOptionsProvider']): this;
|
|
81
|
+
getPositionOptionsProvider(): (dropList?: DropList) => PositionOptions;
|
|
82
|
+
/**
|
|
83
|
+
* Sets a handler to intercept internal errors/warnings (e.g. from a throwing `renderItem`/`unrenderItem`)
|
|
84
|
+
* instead of the default `console.error`/`console.warn`.
|
|
85
|
+
*/
|
|
86
|
+
setOnError(fn?: DropListOptions['onError'] | null): this;
|
|
87
|
+
/**
|
|
88
|
+
* Gets the current `onError` handler, if any.
|
|
89
|
+
*/
|
|
90
|
+
getOnError(): import("./types.js").LibraryErrorHandler;
|
|
91
|
+
/**
|
|
92
|
+
* @param term the search term to set
|
|
93
|
+
* @param performSearch should actually perform the search, or just set the input's text?
|
|
94
|
+
*/
|
|
95
|
+
setSearchTerm(term: string, performSearch?: boolean): this;
|
|
96
|
+
isFilterPending(): boolean;
|
|
97
|
+
invokeRefilter(): this;
|
|
98
|
+
rushRefilter(): this;
|
|
99
|
+
getFilteredItemCount(): number;
|
|
100
|
+
setNoResultsText(noResultsText: string): this;
|
|
101
|
+
getNoResultsText(): string;
|
|
102
|
+
setFilterThrottleWindow(window: number): this;
|
|
103
|
+
getFilterThrottleWindow(): number;
|
|
104
|
+
setFilterOnEmptyTerm(value: boolean): this;
|
|
105
|
+
getFilterOnEmptyTerm(): boolean;
|
|
106
|
+
setFilterGroups(value: boolean): this;
|
|
107
|
+
getFilterGroups(): boolean;
|
|
108
|
+
setFilterEmptyGroups(value?: boolean): this;
|
|
109
|
+
getFilterEmptyGroups(): boolean;
|
|
110
|
+
setFilterFn(fn: DropListOptions['filterFn'] | null): this;
|
|
111
|
+
getFilterFn(): DropListOptions['filterFn'] | null;
|
|
112
|
+
relayout(positionOptions?: PositionOptions | null): this;
|
|
113
|
+
/**
|
|
114
|
+
* Set the checked mode of a specific value.
|
|
115
|
+
*/
|
|
116
|
+
setItemChecked(value: any, checked: boolean): this;
|
|
117
|
+
/**
|
|
118
|
+
* Set the checked values. All the other values will be unchecked,
|
|
119
|
+
*/
|
|
120
|
+
setCheckedValues(values: any[]): this;
|
|
121
|
+
/**
|
|
122
|
+
* Get all checked values. Returns array of item values.
|
|
123
|
+
* @param excludeGroups Exclude group items
|
|
124
|
+
*/
|
|
125
|
+
getCheckedValues(excludeGroups?: boolean): any[];
|
|
126
|
+
/**
|
|
127
|
+
* Get all checked items. Returns array of actual item data object.
|
|
128
|
+
* @param excludeGroups Exclude group items
|
|
129
|
+
*/
|
|
130
|
+
getCheckedItems(excludeGroups?: boolean): ItemBase[];
|
|
131
|
+
show(positionOptions?: PositionOptions | null): this;
|
|
132
|
+
hide(event?: Event): this;
|
|
133
|
+
isVisible(): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Change visibility of the header element
|
|
136
|
+
* You should probably call `relayout()` after this.
|
|
137
|
+
*/
|
|
138
|
+
setHeaderVisible(visible: boolean): void;
|
|
139
|
+
/**
|
|
140
|
+
* Is the header element visible?
|
|
141
|
+
*/
|
|
142
|
+
isHeaderVisible(): boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Get a reference to the header element in order to add custom content.
|
|
145
|
+
*/
|
|
146
|
+
getHeaderElement(): HTMLElement;
|
|
147
|
+
/**
|
|
148
|
+
* Change visibility of the footer element
|
|
149
|
+
* You should probably call `relayout()` after this.
|
|
150
|
+
*/
|
|
151
|
+
setFooterVisible(visible: boolean): void;
|
|
152
|
+
/**
|
|
153
|
+
* Is the footer element visible?
|
|
154
|
+
*/
|
|
155
|
+
isFooterVisible(): boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Get a reference to the footer element in order to add custom content.
|
|
158
|
+
*/
|
|
159
|
+
getFooterElement(): HTMLElement;
|
|
160
|
+
/**
|
|
161
|
+
* Set inline search visibility
|
|
162
|
+
* You should probably call `relayout()` after this.
|
|
163
|
+
*/
|
|
164
|
+
setSearchable(searchable: boolean): void;
|
|
165
|
+
/**
|
|
166
|
+
* Set the placeholder text of the inline search box
|
|
167
|
+
*/
|
|
168
|
+
setSearchPlaceholder(placeholder: string): void;
|
|
169
|
+
hasFocusedItem(): boolean;
|
|
170
|
+
getFocusedItemIndex(): number;
|
|
171
|
+
setFocusedItemAtIndex(itemIndex: number): this;
|
|
172
|
+
/**
|
|
173
|
+
* Updates the current open sublist with new subitems if changed
|
|
174
|
+
*/
|
|
175
|
+
updateSublist(): void;
|
|
176
|
+
setFocusedItem(item: any): this;
|
|
177
|
+
setFocusedItemByValue(value: any): this;
|
|
178
|
+
setSingleSelectedItemAtIndex(itemIndex: number, value?: any): this;
|
|
179
|
+
setSingleSelectedItem(item: any): this;
|
|
180
|
+
setSingleSelectedItemByValue(value: any): this;
|
|
181
|
+
next(event: Event): void;
|
|
182
|
+
previous(event: Event): void;
|
|
183
|
+
isFirstItem(): boolean;
|
|
184
|
+
isLastItem(): boolean;
|
|
185
|
+
scrollItemIndexIntoView(itemIndex: number): this;
|
|
186
|
+
/**
|
|
187
|
+
* Register an event handler
|
|
188
|
+
*/
|
|
189
|
+
on(event: string | '*', handler: (value: any) => void): this;
|
|
190
|
+
/**
|
|
191
|
+
* Register a one time event handler
|
|
192
|
+
*/
|
|
193
|
+
once(event: string | '*', handler: (value: any) => void): this;
|
|
194
|
+
/**
|
|
195
|
+
* Remove an `handler` for `event`, all events for `event`, or all events completely.
|
|
196
|
+
*/
|
|
197
|
+
off(event?: string | '*', handler?: (value: any) => void): this;
|
|
198
|
+
/**
|
|
199
|
+
* Emit an event
|
|
200
|
+
*/
|
|
201
|
+
emit(event: string, value?: any): this;
|
|
202
|
+
}
|
|
203
|
+
export default DropList;
|
|
204
|
+
export { ItemSymbol };
|
|
205
|
+
//# sourceMappingURL=DropList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropList.d.ts","sourceRoot":"","sources":["../../src/lib/DropList.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAI7E,QAAA,MAAM,UAAU,eAAiB,CAAC;AAiJlC,eAAO,MAAM,cAAc,EAAE,eAgC5B,CAAC;AAwBF,cAAM,QAAQ;IAUV,YAAY,OAAO,EAAE,eAAe,EAkPnC;IAED,OAAO,SAgDN;IAED,IAAI,EAAE,IAAI,WAAW,GAAG,IAAI,CAE3B;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AAK,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI,CAO7D;IAED;;OAEG;IACH,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,GAAG,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI,CAO9D;IAED;;OAEG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,IAAI,CAGrC;CAy5BJ;eAEc,QAAQ;AACvB,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import DropList from './DropList';
|
|
2
|
+
import type { SelectBoxOptions, ItemBase, DropListOptions } from './types.js';
|
|
3
|
+
export declare const DefaultOptions: SelectBoxOptions;
|
|
4
|
+
declare class SelectBox {
|
|
5
|
+
constructor(options: SelectBoxOptions);
|
|
6
|
+
destroy(): void;
|
|
7
|
+
get el(): HTMLElement | null;
|
|
8
|
+
get droplistInstance(): DropList | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Returns true if other is an inclusive descendant of droplist node, false otherwise, and undefined if the droplist is not initiated.
|
|
11
|
+
*/
|
|
12
|
+
droplistElContains(other: any, considerSubmenus?: boolean): boolean | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Enables the control
|
|
15
|
+
*/
|
|
16
|
+
enable(enabled?: boolean): this;
|
|
17
|
+
/**
|
|
18
|
+
* Is the control enabled?
|
|
19
|
+
*/
|
|
20
|
+
isEnabled(): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Disables the control
|
|
23
|
+
*/
|
|
24
|
+
disable(disabled?: boolean): this;
|
|
25
|
+
/**
|
|
26
|
+
* Is the control disabled?
|
|
27
|
+
*/
|
|
28
|
+
isDisabled(): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Sets read only mode
|
|
31
|
+
*/
|
|
32
|
+
setReadOnly(readOnly?: boolean): this;
|
|
33
|
+
/**
|
|
34
|
+
* Is the control read only?
|
|
35
|
+
*/
|
|
36
|
+
isReadOnly(): boolean;
|
|
37
|
+
setAdditionalClasses(classes: string | string[]): this;
|
|
38
|
+
/**
|
|
39
|
+
* @param items the items to set (not values)
|
|
40
|
+
* @param resetValues should reset values to current values (essentially refresh the data based on items & values). If set to false, use setValue to set a fresh value
|
|
41
|
+
*/
|
|
42
|
+
setItems(items?: ItemBase[], resetValues?: boolean): this;
|
|
43
|
+
getFilteredItemCount(): number;
|
|
44
|
+
isFilterPending(): boolean;
|
|
45
|
+
updateItemByValue(value: any, newItem: ItemBase): void;
|
|
46
|
+
getItems(): ItemBase[];
|
|
47
|
+
setClearable(clearable: boolean): this;
|
|
48
|
+
getClearable(): boolean;
|
|
49
|
+
setHasOpenIndicator(enabled: boolean): this;
|
|
50
|
+
getHasOpenIndicator(): boolean;
|
|
51
|
+
setPlaceholder(placeholder: string): this;
|
|
52
|
+
getPlaceHolder(): string;
|
|
53
|
+
/**
|
|
54
|
+
* @param term the search term to set
|
|
55
|
+
* @param performSearch should actually perform the search, or just set the input's text?
|
|
56
|
+
*/
|
|
57
|
+
setSearchTerm(term: string, performSearch?: boolean): this;
|
|
58
|
+
getSearchTerm(): string;
|
|
59
|
+
invokeRefilter(): this;
|
|
60
|
+
setSortSelectedItems(sortSelectedItems: boolean): this;
|
|
61
|
+
isSortSelectedItemsEnabled(): boolean;
|
|
62
|
+
setSortListItems(sortListItems: boolean): this;
|
|
63
|
+
isSortListItemsEnabled(): boolean;
|
|
64
|
+
setSortListCheckedFirst(sortListCheckedFirst: boolean): this;
|
|
65
|
+
isSortListCheckedFirstEnabled(): boolean;
|
|
66
|
+
setStickyValues(values: any[]): this;
|
|
67
|
+
getStickyValues(): any[];
|
|
68
|
+
setSortItemComparator(comparator: SelectBoxOptions['sortItemComparator']): this;
|
|
69
|
+
getSortItemComparator(): (a: ItemBase, b: ItemBase) => number;
|
|
70
|
+
setTreatGroupSelectionAsItems(treatGroupSelectionAsItems: boolean): this;
|
|
71
|
+
isTreatGroupSelectionAsItemsEnabled(): boolean;
|
|
72
|
+
setSplitListCheckedGroups(splitListCheckedGroups: boolean): this;
|
|
73
|
+
isSplitListCheckedGroupsEnabled(): boolean;
|
|
74
|
+
setShowSelection(showSelection: boolean): this;
|
|
75
|
+
isShowSelectionEnabled(): boolean;
|
|
76
|
+
setShowPlaceholderInTooltip(showPlaceholderInTooltip: boolean): this;
|
|
77
|
+
isShowPlaceholderInTooltipEnabled(): boolean;
|
|
78
|
+
setMultiPlaceholderFormatter(formatter: SelectBoxOptions['multiPlaceholderFormatter']): this;
|
|
79
|
+
setBlurOnSingleSelection(value: boolean | 'touch'): this;
|
|
80
|
+
getBlurOnSingleSelection(): "touch" | boolean;
|
|
81
|
+
setMulti(multi: boolean): this;
|
|
82
|
+
isMultiEnabled(): boolean;
|
|
83
|
+
setSearchable(searchable: boolean): this;
|
|
84
|
+
setAllowTypeToSelect(allowTypeToSelect: boolean): this;
|
|
85
|
+
isSearchableEnabled(): boolean;
|
|
86
|
+
setNoResultsText(noResultsText: string): this;
|
|
87
|
+
getNoResultsText(): string;
|
|
88
|
+
setAutoSelectTextOnCheck(autoSelectTextOnCheck: boolean): this;
|
|
89
|
+
getAutoSelectTextOnCheck(): boolean;
|
|
90
|
+
setFilterThrottleWindow(window: number): this;
|
|
91
|
+
getFilterThrottleWindow(): number;
|
|
92
|
+
setFilterOnEmptyTerm(value: boolean): this;
|
|
93
|
+
getFilterOnEmptyTerm(): boolean;
|
|
94
|
+
setListOptions(listOptions: DropListOptions): this;
|
|
95
|
+
setRenderSingleItem(render: SelectBoxOptions['renderSingleItem'], unrender: SelectBoxOptions['unrenderSingleItem']): this;
|
|
96
|
+
setRenderMultiItem(render: SelectBoxOptions['renderMultiItem'], unrender: SelectBoxOptions['unrenderMultiItem']): this;
|
|
97
|
+
setRenderRestMultiItem(render: SelectBoxOptions['renderRestMultiItem'], unrender: SelectBoxOptions['unrenderRestMultiItem']): this;
|
|
98
|
+
setLabelProp(prop: string): this;
|
|
99
|
+
setValueProp(prop: string): this;
|
|
100
|
+
setMultiItemLabelProp(prop: string): this;
|
|
101
|
+
setMultiItemRemovePosition(position: 'after' | 'before' | 'none'): this;
|
|
102
|
+
setMaxMultiItems(value: number | null | undefined): this;
|
|
103
|
+
setMultiItemsRestLabelProvider(value: SelectBoxOptions['multiItemsRestLabelProvider']): this;
|
|
104
|
+
setFilterFn(fn: SelectBoxOptions['filterFn'] | null): this;
|
|
105
|
+
getFilterFn(): SelectBoxOptions['filterFn'] | null;
|
|
106
|
+
/**
|
|
107
|
+
* Sets a handler to intercept internal errors/warnings (e.g. from a throwing `renderMultiItem`/`unrenderSingleItem`)
|
|
108
|
+
* instead of the default `console.error`/`console.warn`. Also used as the default `onError` for the internal
|
|
109
|
+
* `DropList`, unless `listOptions.onError` is set explicitly.
|
|
110
|
+
*/
|
|
111
|
+
setOnError(fn?: SelectBoxOptions['onError'] | null): this;
|
|
112
|
+
/**
|
|
113
|
+
* Gets the current `onError` handler, if any.
|
|
114
|
+
*/
|
|
115
|
+
getOnError(): import("./types.js").LibraryErrorHandler;
|
|
116
|
+
/**
|
|
117
|
+
* Focus on input element
|
|
118
|
+
*/
|
|
119
|
+
focusInput(): this;
|
|
120
|
+
/**
|
|
121
|
+
* Remvoe focus from the input element
|
|
122
|
+
*/
|
|
123
|
+
blurInput(): this;
|
|
124
|
+
/**
|
|
125
|
+
* Removes all selected items
|
|
126
|
+
*/
|
|
127
|
+
clear(): this;
|
|
128
|
+
/**
|
|
129
|
+
* Returns a single value or an array of selected values - depending on `multi` prop
|
|
130
|
+
*/
|
|
131
|
+
getValue(): any;
|
|
132
|
+
/**
|
|
133
|
+
* Selects the specified value or multiple values - depending on `multi` prop
|
|
134
|
+
* @param value - if `multi`, then an array of values to select, otherwise - a single value to select
|
|
135
|
+
*/
|
|
136
|
+
setValue(value: any | any[]): this;
|
|
137
|
+
/**
|
|
138
|
+
* Returns an array of selected values
|
|
139
|
+
*/
|
|
140
|
+
getSelectedValues(): any[];
|
|
141
|
+
/**
|
|
142
|
+
* Selects the specified values
|
|
143
|
+
*/
|
|
144
|
+
setSelectedValues(values: any[]): this;
|
|
145
|
+
/**
|
|
146
|
+
* Returns the count of selected values
|
|
147
|
+
*/
|
|
148
|
+
getSelectedValueCount(): number;
|
|
149
|
+
/**
|
|
150
|
+
* Returns an array of selected items
|
|
151
|
+
*/
|
|
152
|
+
getSelectedItems(): ItemBase[];
|
|
153
|
+
/**
|
|
154
|
+
* Sets the specified items to "checked" mode.
|
|
155
|
+
* An array of items is passed, not values, because we need to keep track if items,
|
|
156
|
+
* and if we already have the array of items then this spares the process of searching for the items by values.
|
|
157
|
+
*/
|
|
158
|
+
setSelectedItems(items: ItemBase[]): this;
|
|
159
|
+
openList(): this;
|
|
160
|
+
closeList(): this;
|
|
161
|
+
toggleList(open?: boolean): this;
|
|
162
|
+
isListOpen(): boolean;
|
|
163
|
+
toggleLoading(on?: boolean): this;
|
|
164
|
+
setIsLoadingMode(isLoadingMode?: boolean): this;
|
|
165
|
+
getIsLoadingMode(): boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Sets whether to close the list when loading mode is enabled
|
|
168
|
+
*/
|
|
169
|
+
setCloseListWhenLoading(closeListWhenLoading: boolean): this;
|
|
170
|
+
getCloseListWhenLoading(): boolean;
|
|
171
|
+
/**
|
|
172
|
+
* Sets when to clear the input field
|
|
173
|
+
*/
|
|
174
|
+
setClearInputWhen(clearInputWhen: string[]): this;
|
|
175
|
+
/**
|
|
176
|
+
* Retrieves the settings for when to clear the input field
|
|
177
|
+
*/
|
|
178
|
+
getClearInputWhen(): string[];
|
|
179
|
+
/**
|
|
180
|
+
* Sets the appropriate direction for the selectbox
|
|
181
|
+
*/
|
|
182
|
+
setDirection(direction: 'ltr' | 'rtl' | 'auto'): this;
|
|
183
|
+
/**
|
|
184
|
+
* Gets the supplied direction for the selectbox
|
|
185
|
+
*/
|
|
186
|
+
getDirection(): "auto" | "ltr" | "rtl";
|
|
187
|
+
/**
|
|
188
|
+
* Can be called in case that the selectbox was attached to the dom late and has a weird size.
|
|
189
|
+
*/
|
|
190
|
+
refreshSize(): this;
|
|
191
|
+
/**
|
|
192
|
+
* Register an event handler
|
|
193
|
+
*/
|
|
194
|
+
on(event: string | '*', handler: (value: any) => void): this;
|
|
195
|
+
/**
|
|
196
|
+
* Register a one time event handler
|
|
197
|
+
*/
|
|
198
|
+
once(event: string | '*', handler: (value: any) => void): this;
|
|
199
|
+
/**
|
|
200
|
+
* Remove an `handler` for `event`, all events for `event`, or all events completely.
|
|
201
|
+
*/
|
|
202
|
+
off(event?: string | '*', handler?: (value: any) => void): this;
|
|
203
|
+
/**
|
|
204
|
+
* Emit an event
|
|
205
|
+
*/
|
|
206
|
+
emit(event: string, value?: any): this;
|
|
207
|
+
}
|
|
208
|
+
export default SelectBox;
|
|
209
|
+
//# sourceMappingURL=SelectBox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectBox.d.ts","sourceRoot":"","sources":["../../src/lib/SelectBox.ts"],"names":[],"mappings":"AAwBA,OAAO,QAAwB,MAAM,YAAY,CAAC;AAalD,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,eAAe,EAAmB,MAAM,YAAY,CAAC;AA2J/F,eAAO,MAAM,cAAc,EAAE,gBAqC5B,CAAC;AA4EF,cAAM,SAAS;IAQX,YAAY,OAAO,EAAE,gBAAgB,EAqNpC;IAED,OAAO,SAgDN;IAED,IAAI,EAAE,IAAI,WAAW,GAAG,IAAI,CAE3B;IAED,IAAI,gBAAgB,IAAI,QAAQ,GAAG,SAAS,CAE3C;IAED;;OAEG;IACH,kBAAkB,CAAC,KAAK,EAAE,GAAG,EAAE,gBAAgB,UAAO,GAAG,OAAO,GAAG,SAAS,CAE3E;IAED;;OAEG;IACH,MAAM,CAAC,OAAO,GAAE,OAAc,GAAG,IAAI,CAkBpC;IAED;;OAEG;IACH,SAAS,YAER;IAED;;OAEG;IACH,OAAO,CAAC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AS"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import DropList, { DefaultOptions as DropListDefaultOptions, ItemSymbol } from './DropList.js';
|
|
2
|
+
import SelectBox, { DefaultOptions as SelectBoxDefaultOptions } from './SelectBox.js';
|
|
3
|
+
export { DropList, SelectBox, DropListDefaultOptions, SelectBoxDefaultOptions, ItemSymbol };
|
|
4
|
+
export type { DropListOptions, SelectBoxOptions, ItemBase, Item, PositionAnchor, PositionOptions } from './types.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,EAAE,EAAE,cAAc,IAAI,sBAAsB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,SAAS,EAAE,EAAE,cAAc,IAAI,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEtF,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,UAAU,EAAE,CAAC;AAC5F,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,QAAQ,EAAE,IAAI,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import type DropList from './DropList.js';
|
|
2
|
+
/**
|
|
3
|
+
* Context describing where a library-internal error/warning originated.
|
|
4
|
+
* `source` identifies the callback or code path (e.g. `'unrenderItem'`),
|
|
5
|
+
* `level` distinguishes a genuine thrown error from a soft internal warning.
|
|
6
|
+
* Additional free-form fields may be attached for debugging (e.g. `index`, `item`).
|
|
7
|
+
*/
|
|
8
|
+
export interface LibraryErrorContext {
|
|
9
|
+
source: string;
|
|
10
|
+
level?: 'warn' | 'error';
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Optional hook so consumers can intercept/redirect errors and warnings
|
|
15
|
+
* that would otherwise go straight to `console.error`/`console.warn`
|
|
16
|
+
* (e.g. exceptions thrown from a user-supplied `renderItem`/`unrenderItem`).
|
|
17
|
+
*/
|
|
18
|
+
export type LibraryErrorHandler = (error: any, context: LibraryErrorContext) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Horizontal/vertical anchor specification used for positioning the DropList relative to a target.
|
|
21
|
+
*/
|
|
22
|
+
export interface PositionAnchor {
|
|
23
|
+
/** horizontal anchor specification (could be either `'left'|'center'|'right'|'start'|'end'` or a percentage `'50%'` or a fixed decimal `Number`) */
|
|
24
|
+
x: 'left' | 'center' | 'right' | 'start' | 'end' | string | number;
|
|
25
|
+
/** vertical anchor specification (could be either `'top'|'center'|'bottom'` or a percentage `'50%'` or a fixed decimal `Number`) */
|
|
26
|
+
y: 'top' | 'center' | 'bottom' | string | number;
|
|
27
|
+
}
|
|
28
|
+
export interface PositionOptions {
|
|
29
|
+
/** Target element to act as anchor */
|
|
30
|
+
target?: Element | null;
|
|
31
|
+
/** Override the offset of target. Automatically calculated if unspecified. */
|
|
32
|
+
targetOffset?: {
|
|
33
|
+
left: number;
|
|
34
|
+
top: number;
|
|
35
|
+
} | null;
|
|
36
|
+
/** Override height of the target */
|
|
37
|
+
targetHeight?: number | null;
|
|
38
|
+
/** Override width of the target */
|
|
39
|
+
targetWidth?: number | null;
|
|
40
|
+
position?: PositionAnchor | null;
|
|
41
|
+
anchor?: PositionAnchor | null;
|
|
42
|
+
/** `true` to set width of the menu according to `target`'s width, or specify an arbitrary number. */
|
|
43
|
+
updateWidth?: boolean | number;
|
|
44
|
+
/** Override for rtl mode of the target */
|
|
45
|
+
targetRtl?: boolean | null;
|
|
46
|
+
/** Extra rtl-aware offset to the target */
|
|
47
|
+
offset?: {
|
|
48
|
+
x: number;
|
|
49
|
+
y: number;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export interface ItemBase {
|
|
53
|
+
value?: any;
|
|
54
|
+
label?: string;
|
|
55
|
+
_group?: boolean;
|
|
56
|
+
_child?: boolean;
|
|
57
|
+
_nocheck?: boolean;
|
|
58
|
+
_nointeraction?: boolean;
|
|
59
|
+
_subitems?: ItemBase[];
|
|
60
|
+
/** allows any other free-form fields on the source item data */
|
|
61
|
+
[key: string]: any;
|
|
62
|
+
}
|
|
63
|
+
export interface Item extends ItemBase {
|
|
64
|
+
_checked?: boolean;
|
|
65
|
+
}
|
|
66
|
+
export interface DropListOptions {
|
|
67
|
+
/** An element to attach to, instead of creating a new one */
|
|
68
|
+
el?: HTMLElement;
|
|
69
|
+
/** class name for the menu root element (default: 'droplist') */
|
|
70
|
+
baseClassName?: string;
|
|
71
|
+
additionalClasses?: string | string[];
|
|
72
|
+
/** default: 'auto' */
|
|
73
|
+
direction?: 'ltr' | 'rtl' | 'auto';
|
|
74
|
+
/** Should we automatically blur the focused item when the droplist loses focus? (default: true) */
|
|
75
|
+
autoItemBlur?: boolean;
|
|
76
|
+
/** How long to wait before deciding to blur the focused item (when the droplist loses focus)? (default: 300) */
|
|
77
|
+
autoItemBlurDelay?: number;
|
|
78
|
+
/** Should this DropList be added to the TAB-key stack? (default: true) */
|
|
79
|
+
capturesFocus?: boolean;
|
|
80
|
+
/** Does this DropList show checkboxes for multiple item selection? (default: false) */
|
|
81
|
+
multi?: boolean;
|
|
82
|
+
/** Current selected value when using single selection. */
|
|
83
|
+
singleSelectedValue?: any;
|
|
84
|
+
/** An alternative "keydown" event handler. Return true to prevent default behaviour. (default: null) */
|
|
85
|
+
keyDownHandler?: ((event: KeyboardEvent) => (boolean | void)) | null;
|
|
86
|
+
/** When a group is checked/unchecked - all items beneath it will update accordingly (default: true) */
|
|
87
|
+
autoCheckGroupChildren?: boolean;
|
|
88
|
+
/** Use the exact target's width, do not allow growing (default: false) */
|
|
89
|
+
useExactTargetWidth?: boolean;
|
|
90
|
+
/** Should the position be constrained to the window, attaching to window's borders if needed? (default: true) */
|
|
91
|
+
constrainToWindow?: boolean;
|
|
92
|
+
/** Should the position/anchor be flipped automatically when there's no space in the required direction? (default: true) */
|
|
93
|
+
autoFlipDirection?: boolean;
|
|
94
|
+
/** An estimated row height, for approximating scroll height. (default: 20) */
|
|
95
|
+
estimatedItemHeight?: number;
|
|
96
|
+
/** Use an estimation for the width instead of measuring. May be faster - needs testing and may depend on the CSS. (default: false) */
|
|
97
|
+
estimateWidth?: boolean;
|
|
98
|
+
/** Turns into a virtual list - with items being created and showing up on viewport only. The value specified the minimum item count where a virtual list will be created. (default: 100) */
|
|
99
|
+
virtualMinItems?: number;
|
|
100
|
+
/** default: 'label' */
|
|
101
|
+
labelProp?: string;
|
|
102
|
+
/** default: 'value' */
|
|
103
|
+
valueProp?: string;
|
|
104
|
+
/** Function to call when rendering an item element */
|
|
105
|
+
renderItem?: (item: ItemBase, itemEl: Element) => (any | false);
|
|
106
|
+
/** Function to call when rendering an item element */
|
|
107
|
+
unrenderItem?: (item: ItemBase, itemEl: Element) => void;
|
|
108
|
+
renderNoResultsItem?: (item: ItemBase, itemEl: Element) => (any | false);
|
|
109
|
+
unrenderNoResultsItem?: (item: ItemBase, itemEl: Element) => void;
|
|
110
|
+
on?: (name: string, data?: any) => void;
|
|
111
|
+
/** show header element (default: false) */
|
|
112
|
+
isHeaderVisible?: boolean;
|
|
113
|
+
/** show footer element (default: false) */
|
|
114
|
+
isFooterVisible?: boolean;
|
|
115
|
+
/** include inline search box (default: false) */
|
|
116
|
+
searchable?: boolean;
|
|
117
|
+
/** placeholder text for the inline search box (default: '') */
|
|
118
|
+
searchPlaceholder?: string;
|
|
119
|
+
/** text for no results (empty for none) (default: 'No matching results') */
|
|
120
|
+
noResultsText?: string;
|
|
121
|
+
/** throttle time (milliseconds) for filtering (default: 300) */
|
|
122
|
+
filterThrottleWindow?: number;
|
|
123
|
+
/** call the filter function on empty search term too (default: false) */
|
|
124
|
+
filterOnEmptyTerm?: boolean;
|
|
125
|
+
/** should groups be filtered? (default: false) */
|
|
126
|
+
filterGroups?: boolean;
|
|
127
|
+
/** should empty groups be filtered out? (default: false) */
|
|
128
|
+
filterEmptyGroups?: boolean;
|
|
129
|
+
filterFn?: (items: ItemBase[], term: string) => (ItemBase[] | null);
|
|
130
|
+
positionOptionsProvider?: (dropList?: DropList) => PositionOptions;
|
|
131
|
+
/** Intercept internal errors/warnings (e.g. from a throwing `renderItem`/`unrenderItem`) instead of the default `console.error`/`console.warn`. */
|
|
132
|
+
onError?: LibraryErrorHandler;
|
|
133
|
+
}
|
|
134
|
+
export interface SelectBoxOptions {
|
|
135
|
+
/** options to pass to the `DropList` */
|
|
136
|
+
listOptions?: DropListOptions;
|
|
137
|
+
/** An element to attach to, instead of creating a new one */
|
|
138
|
+
el?: HTMLElement;
|
|
139
|
+
/** class name for the menu root element (default: 'selectbox') */
|
|
140
|
+
baseClassName?: string;
|
|
141
|
+
additionalClasses?: string | string[];
|
|
142
|
+
/** default: 'auto' */
|
|
143
|
+
direction?: 'ltr' | 'rtl' | 'auto';
|
|
144
|
+
/** Should start as disabled? (default: false) */
|
|
145
|
+
disabled?: boolean;
|
|
146
|
+
/** Should start as readOnly? (default: false) */
|
|
147
|
+
readOnly?: boolean;
|
|
148
|
+
/** Has clear button? (default: true) */
|
|
149
|
+
clearable?: boolean;
|
|
150
|
+
/** has open/close indicator? (default: true) */
|
|
151
|
+
hasOpenIndicator?: boolean;
|
|
152
|
+
/** Placeholder text (default: '') */
|
|
153
|
+
placeholder?: string;
|
|
154
|
+
/** Should the selected items be sorted? (default: true) */
|
|
155
|
+
sortSelectedItems?: boolean;
|
|
156
|
+
/** Sort list items (default: false) */
|
|
157
|
+
sortListItems?: boolean;
|
|
158
|
+
/** When sorting - put checked items first (applicable to `multi` mode only) (default: true) */
|
|
159
|
+
sortListCheckedFirst?: boolean;
|
|
160
|
+
/** Treat group items as normal items (default: false) */
|
|
161
|
+
treatGroupSelectionAsItems?: boolean;
|
|
162
|
+
stickyValues?: any[];
|
|
163
|
+
sortItemComparator?: (a: ItemBase, b: ItemBase) => number;
|
|
164
|
+
/** Split groups to "checked" and "unchecked", works with `sortListCheckedFirst` only (default: true) */
|
|
165
|
+
splitListCheckedGroups?: boolean;
|
|
166
|
+
/** default: 'touch' */
|
|
167
|
+
blurOnSingleSelection?: boolean | 'touch';
|
|
168
|
+
/** can multiple values be selected? (default: false) */
|
|
169
|
+
multi?: boolean;
|
|
170
|
+
/** show selection? if false, the placeholder will take effect (default: true) */
|
|
171
|
+
showSelection?: boolean;
|
|
172
|
+
/** show placeholder in title attribute (default: false) */
|
|
173
|
+
showPlaceholderInTooltip?: boolean;
|
|
174
|
+
/** formatter for placeholder for multi items mode */
|
|
175
|
+
multiPlaceholderFormatter?: (items: ItemBase[]) => string;
|
|
176
|
+
/** default: 'label' */
|
|
177
|
+
labelProp?: string;
|
|
178
|
+
/** default: 'value' */
|
|
179
|
+
valueProp?: string;
|
|
180
|
+
/** default: 'short_label' */
|
|
181
|
+
multiItemLabelProp?: string;
|
|
182
|
+
/** default: 'after' */
|
|
183
|
+
multiItemRemovePosition?: 'after' | 'before' | 'none';
|
|
184
|
+
/** maximum number of multi items. The rest will get a single item to represent. */
|
|
185
|
+
maxMultiItems?: number;
|
|
186
|
+
/** label for the item representing the rest of the items. */
|
|
187
|
+
multiItemsRestLabelProvider?: (count: number, items: ItemBase[]) => string;
|
|
188
|
+
/** initial items */
|
|
189
|
+
items?: ItemBase[] | null;
|
|
190
|
+
/** initial selected values */
|
|
191
|
+
selectedValues?: any[] | null;
|
|
192
|
+
/** initial selected value */
|
|
193
|
+
value?: any;
|
|
194
|
+
renderSingleItem?: (item: ItemBase, itemEl: Element) => (any | false);
|
|
195
|
+
unrenderSingleItem?: (item: ItemBase, itemEl: Element) => void;
|
|
196
|
+
renderMultiItem?: (item: ItemBase, itemEl: Element) => (any | false);
|
|
197
|
+
unrenderMultiItem?: (item: ItemBase, itemEl: Element) => void;
|
|
198
|
+
renderRestMultiItem?: (item: ItemBase, itemEl: Element) => (any | false);
|
|
199
|
+
unrenderRestMultiItem?: (item: ItemBase, itemEl: Element) => void;
|
|
200
|
+
/** is it searchable? (default: false) */
|
|
201
|
+
searchable?: boolean;
|
|
202
|
+
/** default behavior of type to select (focus first item starting with the search term) when searchable is true (default: true) */
|
|
203
|
+
allowTypeToSelect?: boolean;
|
|
204
|
+
/** text for no results (empty for none) (default: 'No matching results') */
|
|
205
|
+
noResultsText?: string;
|
|
206
|
+
/** automatically select text in input when an item is checked (multi mode). Used to allow the user to quickly type multiple items. (default: true) */
|
|
207
|
+
autoSelectTextOnCheck?: boolean;
|
|
208
|
+
/** throttle time (milliseconds) for filtering (default: 300) */
|
|
209
|
+
filterThrottleWindow?: number;
|
|
210
|
+
/** call the filter function on empty search term too (default: false) */
|
|
211
|
+
filterOnEmptyTerm?: boolean;
|
|
212
|
+
filterFn?: (items: ItemBase[], term: string) => (ItemBase[] | null);
|
|
213
|
+
on?: (name: string, ...args: any[]) => void;
|
|
214
|
+
isLoadingMode?: boolean;
|
|
215
|
+
/** whether we should close the list automatically when loading */
|
|
216
|
+
closeListWhenLoading?: boolean;
|
|
217
|
+
/** clear input box when closing the droplist or selecting `['single_close', 'multi_close', 'multi_select_single']` (default: ['single_close','multi_select_single']) */
|
|
218
|
+
clearInputWhen?: string[];
|
|
219
|
+
/** Intercept internal errors/warnings (e.g. from a throwing `renderMultiItem`/`unrenderSingleItem`) instead of the default `console.error`/`console.warn`. Also used as the default `onError` for the internal `DropList`, unless `listOptions.onError` is set explicitly. */
|
|
220
|
+
onError?: LibraryErrorHandler;
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=types.d.ts.map
|