@danielgindi/selectbox 2.0.56 → 2.0.58

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.
@@ -0,0 +1,4 @@
1
+ import type { SelectBoxVueComponent } from './component-types.js';
2
+
3
+ declare const SelectBox: SelectBoxVueComponent;
4
+ export default SelectBox;
@@ -0,0 +1,210 @@
1
+ // Hand-authored component type declarations for the Vue wrapper components.
2
+ // These aren't derived from the .vue source by a compiler (there's no vue-tsc
3
+ // in this toolchain) - they're a manually maintained mirror of each component's
4
+ // props/emits/exposed-instance-surface. Keep in sync with DropList.vue / SelectBox.vue
5
+ // when either one's public surface (PropTypes, emits, or public methods/computed) changes.
6
+
7
+ import type { ComponentOptionsMixin, DefineComponent } from 'vue';
8
+ import type DropList from '../dist/types/DropList.js';
9
+ import type SelectBox from '../dist/types/SelectBox.js';
10
+ import type { DropListOptions, ItemBase, PositionOptions, SelectBoxOptions } from '../dist/types/types.js';
11
+
12
+ export interface DropListVueProps {
13
+ baseClassName?: string;
14
+ additionalClasses?: string | string[] | Record<string, boolean>;
15
+ direction?: 'ltr' | 'rtl' | 'auto';
16
+ autoFocus?: boolean;
17
+ autoItemBlur?: boolean;
18
+ autoItemBlurDelay?: number;
19
+ capturesFocus?: boolean;
20
+ multi?: boolean;
21
+ isHeaderVisible?: boolean;
22
+ isFooterVisible?: boolean;
23
+ searchable?: boolean;
24
+ searchPlaceholder?: string;
25
+ noResultsText?: string;
26
+ filterThrottleWindow?: number;
27
+ filterOnEmptyTerm?: boolean;
28
+ filterGroups?: boolean;
29
+ filterEmptyGroups?: boolean;
30
+ filterFn?: DropListOptions['filterFn'];
31
+ filterDependencies?: any;
32
+ keyDownHandler?: DropListOptions['keyDownHandler'];
33
+ autoCheckGroupChildren?: boolean;
34
+ useExactTargetWidth?: boolean;
35
+ constrainToWindow?: boolean;
36
+ autoFlipDirection?: boolean;
37
+ estimatedItemHeight?: number;
38
+ estimateWidth?: boolean;
39
+ virtualMinItems?: number;
40
+ labelProp?: string;
41
+ valueProp?: string;
42
+ items?: ItemBase[];
43
+ /** Vue 3 (`v-model`). Under Vue 2 compat this is `value` (+ `input` event) instead - untyped here. */
44
+ modelValue?: any;
45
+ renderItem?: DropListOptions['renderItem'];
46
+ unrenderItem?: DropListOptions['unrenderItem'];
47
+ positionOptions?: PositionOptions;
48
+ autoRelayoutOnItemsChange?: boolean;
49
+ }
50
+
51
+ export type DropListVueEmits = {
52
+ 'update:modelValue': [value: any];
53
+ itemfocus: [data: any];
54
+ itemblur: [data: any];
55
+ select: [data: any];
56
+ 'show:before': [data: any];
57
+ show: [data: any];
58
+ 'hide:before': [data: any];
59
+ hide: [data: any];
60
+ check: [data: any];
61
+ groupcheck: [data: any];
62
+ blur: [];
63
+ show_subitems: [data: any];
64
+ hide_subitems: [data: any];
65
+ 'subitems:select': [data: any];
66
+ 'subitems:blur': [data: any];
67
+ keypress: [event: KeyboardEvent];
68
+ keydown: [event: KeyboardEvent];
69
+ };
70
+
71
+ // Plain object type literals (not interfaces) here - DefineComponent's C/M generic
72
+ // slots require an index signature (ComputedOptions/MethodOptions), and TS only infers
73
+ // one implicitly for object type literals, not for named interfaces.
74
+ export type DropListVueComputed = {
75
+ /** The underlying `DropList` instance, once mounted. */
76
+ listRef: () => DropList | undefined;
77
+ };
78
+
79
+ export type DropListVueMethods = {
80
+ relayout(): void;
81
+ getHeaderElement(): HTMLElement | undefined;
82
+ getFooterElement(): HTMLElement | undefined;
83
+ elContains(other: any, considerSublists?: boolean): boolean;
84
+ };
85
+
86
+ export type DropListVueComponent = DefineComponent<
87
+ DropListVueProps,
88
+ {},
89
+ {},
90
+ DropListVueComputed,
91
+ DropListVueMethods,
92
+ ComponentOptionsMixin,
93
+ ComponentOptionsMixin,
94
+ DropListVueEmits
95
+ >;
96
+
97
+ export interface SelectBoxVueProps {
98
+ disabled?: boolean;
99
+ readOnly?: boolean;
100
+ clearable?: boolean;
101
+ hasOpenIndicator?: boolean;
102
+ placeholder?: string;
103
+ sortSelectedItems?: boolean;
104
+ sortListItems?: boolean;
105
+ sortListCheckedFirst?: boolean;
106
+ stickyValues?: any[];
107
+ sortItemComparator?: SelectBoxOptions['sortItemComparator'];
108
+ splitListCheckedGroups?: boolean;
109
+ showSelection?: boolean;
110
+ showPlaceholderInTooltip?: boolean;
111
+ multiPlaceholderFormatter?: SelectBoxOptions['multiPlaceholderFormatter'];
112
+ blurOnSingleSelection?: boolean | 'touch';
113
+ multi?: boolean;
114
+ searchable?: boolean;
115
+ allowTypeToSelect?: boolean;
116
+ noResultsText?: string;
117
+ filterThrottleWindow?: number;
118
+ filterOnEmptyTerm?: boolean;
119
+ filterFn?: SelectBoxOptions['filterFn'];
120
+ filterDependencies?: any;
121
+ labelProp?: string;
122
+ valueProp?: string;
123
+ multiItemLabelProp?: string;
124
+ multiItemRemovePosition?: 'before' | 'after' | 'none';
125
+ items?: ItemBase[];
126
+ /** Vue 3 (`v-model`). Under Vue 2 compat this is `value` (+ `input` event) instead - untyped here. */
127
+ modelValue?: any;
128
+ maxMultiItems?: number;
129
+ multiItemsRestLabelProvider?: SelectBoxOptions['multiItemsRestLabelProvider'];
130
+ renderSingleItem?: SelectBoxOptions['renderSingleItem'];
131
+ unrenderSingleItem?: SelectBoxOptions['unrenderSingleItem'];
132
+ renderMultiItem?: SelectBoxOptions['renderMultiItem'];
133
+ unrenderMultiItem?: SelectBoxOptions['unrenderMultiItem'];
134
+ renderRestMultiItem?: SelectBoxOptions['renderRestMultiItem'];
135
+ unrenderRestMultiItem?: SelectBoxOptions['unrenderRestMultiItem'];
136
+ renderNoResultsItem?: (item: ItemBase, itemEl: Element) => (any | false);
137
+ unrenderNoResultsItem?: (item: ItemBase, itemEl: Element) => void;
138
+ /** Rendered items in the drop list (as opposed to `renderSingleItem`/`renderMultiItem`, which render the *selected* item representation). */
139
+ renderListItem?: (item: ItemBase, itemEl: Element) => (any | false);
140
+ unrenderListItem?: (item: ItemBase, itemEl: Element) => void;
141
+ virtualMinItems?: number;
142
+ baseClass?: string;
143
+ droplistBaseClass?: string;
144
+ additionalClasses?: string | string[] | Record<string, boolean>;
145
+ additionalDroplistClasses?: string | string[] | Record<string, boolean>;
146
+ direction?: string;
147
+ fixedDroplistWidth?: boolean;
148
+ acceptNullAsValue?: boolean;
149
+ emitNullForEmptyValue?: boolean;
150
+ isLoadingMode?: boolean;
151
+ closeListWhenLoading?: boolean;
152
+ clearInputWhen?: string[];
153
+ treatGroupSelectionAsItems?: boolean;
154
+ autoCheckGroupChildren?: boolean;
155
+ constrainListToWindow?: boolean;
156
+ autoFlipListDirection?: boolean;
157
+ }
158
+
159
+ export type SelectBoxVueEmits = {
160
+ 'update:modelValue': [value: any];
161
+ 'clear:before': [cancellable: { cancel: boolean }];
162
+ clear: [];
163
+ open: [data: { list: any }];
164
+ 'open:before': [data: { list: any }];
165
+ close: [];
166
+ 'search:focus': [];
167
+ 'search:blur': [];
168
+ 'search:term': [term: string];
169
+ 'addsel:before': [cancellable: { value: any; item: any; cancel: boolean }];
170
+ addsel: [data: { value: any; item: any }];
171
+ 'removesel:before': [cancellable: { value: any; item: any; cancel: boolean }];
172
+ removesel: [data: { value: any; item: any }];
173
+ 'select:before': [cancellable: { value: any; item: any; cancel: boolean }];
174
+ select: [data: { value: any; item: any }];
175
+ 'input:resize': [];
176
+ itemschanged: [data: { term: string | null; mutated: boolean; count: number }];
177
+ search: [value: string];
178
+ };
179
+
180
+ export type SelectBoxVueMethods = {
181
+ toggleLoading(on?: boolean): void;
182
+ toggleList(open?: boolean): void;
183
+ openList(): void;
184
+ closeList(): void;
185
+ isListOpen(): boolean;
186
+ updateItemByValue(value: any, newItem: ItemBase): void;
187
+ getSelectedItems(): ItemBase[];
188
+ setSearchTerm(term: string, performSearch?: boolean): void;
189
+ getSearchTerm(): string;
190
+ getFilteredItemCount(): number;
191
+ isFilterPending(): boolean;
192
+ focus(): void;
193
+ blur(): void;
194
+ droplistElContains(other: any, considerSublists?: boolean): boolean | undefined;
195
+ };
196
+
197
+ export type SelectBoxVueComponent = DefineComponent<
198
+ SelectBoxVueProps,
199
+ {},
200
+ {},
201
+ {},
202
+ SelectBoxVueMethods,
203
+ ComponentOptionsMixin,
204
+ ComponentOptionsMixin,
205
+ SelectBoxVueEmits
206
+ >;
207
+
208
+ // Referenced only for documentation/traceability above (which lib class each
209
+ // wrapper controls) - not part of the emitted type surface itself.
210
+ export type { DropList as _DropListInstance, SelectBox as _SelectBoxInstance };
package/vue/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import DropList from './DropList.vue';
2
+ import SelectBox from './SelectBox.vue';
3
+
4
+ export { DropList, SelectBox };
package/vue/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import DropList from './DropList.vue';
2
- import SelectBox from './SelectBox.vue';
3
-
4
- export { DropList, SelectBox };
1
+ import DropList from './DropList.vue';
2
+ import SelectBox from './SelectBox.vue';
3
+ export { DropList, SelectBox };
@@ -1,96 +1,89 @@
1
- import * as VueModule from 'vue';
2
-
3
- const isVue3 = VueModule.version > '3.';
4
- const render3 = VueModule.render;
5
- const createVNode3 = VueModule.createVNode;
6
-
7
- const createInstanceFromVnode = vnode => {
8
- return new VueModule({
9
- render() {
10
- return vnode;
11
- },
12
- });
13
- };
14
-
15
- const createInstanceFromVnodes = vnodes => {
16
- return new VueModule({
17
- render(h) {
18
- return h('div', vnodes);
19
- },
20
- });
21
- };
22
-
23
- const VueInstanceSymbol = Symbol('vue_instance');
24
-
25
- /**
26
- *
27
- * @param {import('vue').Component} vue
28
- * @param {string} slotName
29
- * @returns {(function(item: *, parent: Element): void)|undefined}
30
- */
31
- const createSlotBasedRenderFunc = (vue, slotName) => {
32
- if (vue.$slots[slotName]) {
33
- return (item, parent) => {
34
- if (isVue3) {
35
- let slotVnode = vue.$slots[slotName](item);
36
- let vnode = createVNode3({
37
- render() {
38
- return slotVnode;
39
- },
40
- });
41
- render3(vnode, parent);
42
- parent[VueInstanceSymbol] = true;
43
- } else {
44
- let slotVnode = vue.$slots[slotName];
45
- let vm = createInstanceFromVnode(slotVnode);
46
- vm.$mount();
47
- parent[VueInstanceSymbol] = vm;
48
- parent.appendChild(vm.$el);
49
- }
50
- };
51
- }
52
-
53
- if (!isVue3 && vue.$scopedSlots && vue.$scopedSlots[slotName]) { // Removed in Vue 3
54
- return (item, parent) => {
55
- let vnode = vue.$scopedSlots[slotName](item);
56
- let vm;
57
-
58
- if (Array.isArray(vnode)) {
59
- vm = createInstanceFromVnodes(vnode);
60
- vm.$mount();
61
- let nodes = vm.$el.childNodes;
62
- parent[VueInstanceSymbol] = vm;
63
- for (let node of nodes)
64
- parent.appendChild(node);
65
- } else {
66
- vm = createInstanceFromVnode(vnode);
67
- vm.$mount();
68
- parent[VueInstanceSymbol] = vm;
69
- parent.appendChild(vm.$el);
70
- }
71
- };
72
- }
73
- };
74
-
75
- /**
76
- *
77
- * @param {import('vue').Component} vue
78
- * @param {string} slotName
79
- * @returns {(function(parent: Element): void)|undefined}
80
- */
81
- const createSlotBasedUnrenderFunc = (vue, slotName) => {
82
- if (vue.$slots[slotName] || (!isVue3 && vue.$scopedSlots && vue.$scopedSlots[slotName])) {
83
- return (parent) => {
84
- const vmOrApp = parent[VueInstanceSymbol];
85
- if (!vmOrApp) return;
86
- if (isVue3) render3(null, parent);
87
- else vmOrApp.$destroy();
88
- delete parent[VueInstanceSymbol];
89
- };
90
- }
91
- };
92
-
93
- export {
94
- createSlotBasedRenderFunc,
95
- createSlotBasedUnrenderFunc,
96
- };
1
+ import * as VueModule from 'vue';
2
+ const isVue3 = VueModule.version > '3.';
3
+ const render3 = VueModule.render;
4
+ const createVNode3 = VueModule.createVNode;
5
+ const createInstanceFromVnode = (vnode) => {
6
+ return new VueModule({
7
+ render() {
8
+ return vnode;
9
+ },
10
+ });
11
+ };
12
+ const createInstanceFromVnodes = (vnodes) => {
13
+ return new VueModule({
14
+ render(h) {
15
+ return h('div', vnodes);
16
+ },
17
+ });
18
+ };
19
+ const VueInstanceSymbol = Symbol('vue_instance');
20
+ /**
21
+ *
22
+ * @param {import('vue').Component} vue
23
+ * @param {string} slotName
24
+ * @returns {(function(item: *, parent: Element): void)|undefined}
25
+ */
26
+ const createSlotBasedRenderFunc = (vue, slotName) => {
27
+ if (vue.$slots[slotName]) {
28
+ return (item, parent) => {
29
+ if (isVue3) {
30
+ let slotVnode = vue.$slots[slotName](item);
31
+ let vnode = createVNode3({
32
+ render() {
33
+ return slotVnode;
34
+ },
35
+ });
36
+ render3(vnode, parent);
37
+ parent[VueInstanceSymbol] = true;
38
+ }
39
+ else {
40
+ let slotVnode = vue.$slots[slotName];
41
+ let vm = createInstanceFromVnode(slotVnode);
42
+ vm.$mount();
43
+ parent[VueInstanceSymbol] = vm;
44
+ parent.appendChild(vm.$el);
45
+ }
46
+ };
47
+ }
48
+ if (!isVue3 && vue.$scopedSlots && vue.$scopedSlots[slotName]) { // Removed in Vue 3
49
+ return (item, parent) => {
50
+ let vnode = vue.$scopedSlots[slotName](item);
51
+ let vm;
52
+ if (Array.isArray(vnode)) {
53
+ vm = createInstanceFromVnodes(vnode);
54
+ vm.$mount();
55
+ let nodes = vm.$el.childNodes;
56
+ parent[VueInstanceSymbol] = vm;
57
+ for (let node of nodes)
58
+ parent.appendChild(node);
59
+ }
60
+ else {
61
+ vm = createInstanceFromVnode(vnode);
62
+ vm.$mount();
63
+ parent[VueInstanceSymbol] = vm;
64
+ parent.appendChild(vm.$el);
65
+ }
66
+ };
67
+ }
68
+ };
69
+ /**
70
+ *
71
+ * @param {import('vue').Component} vue
72
+ * @param {string} slotName
73
+ * @returns {(function(parent: Element): void)|undefined}
74
+ */
75
+ const createSlotBasedUnrenderFunc = (vue, slotName) => {
76
+ if (vue.$slots[slotName] || (!isVue3 && vue.$scopedSlots && vue.$scopedSlots[slotName])) {
77
+ return (parent) => {
78
+ const vmOrApp = parent[VueInstanceSymbol];
79
+ if (!vmOrApp)
80
+ return;
81
+ if (isVue3)
82
+ render3(null, parent);
83
+ else
84
+ vmOrApp.$destroy();
85
+ delete parent[VueInstanceSymbol];
86
+ };
87
+ }
88
+ };
89
+ export { createSlotBasedRenderFunc, createSlotBasedUnrenderFunc, };
@@ -1 +0,0 @@
1
- export default value => value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
@@ -1,48 +0,0 @@
1
- const throttle = (func, wait, options) => {
2
- let timeout, context, args, result;
3
- let previous = 0;
4
- if (!options) options = {};
5
-
6
- const later = () => {
7
- previous = options.leading === false ? 0 : Date.now();
8
- timeout = null;
9
- result = func.apply(context, args);
10
- if (!timeout) context = args = null;
11
- };
12
-
13
- const throttled = function () {
14
- const now = Date.now();
15
- if (!previous && options.leading === false)
16
- previous = now;
17
-
18
- const remaining = wait - (now - previous);
19
- context = this;
20
- args = arguments;
21
- if (remaining <= 0 || remaining > wait) {
22
- if (timeout) {
23
- clearTimeout(timeout);
24
- timeout = null;
25
- }
26
- previous = now;
27
- result = func.apply(context, args);
28
- if (!timeout) context = args = null;
29
- } else if (!timeout && options.trailing !== false) {
30
- timeout = setTimeout(later, remaining);
31
- }
32
- return result;
33
- };
34
-
35
- throttled.cancel = () => {
36
- clearTimeout(timeout);
37
- previous = 0;
38
- timeout = context = args = null;
39
- };
40
-
41
- throttled.isScheduled = () => {
42
- return !!timeout;
43
- };
44
-
45
- return throttled;
46
- };
47
-
48
- export default throttle;