@danielgindi/selectbox 2.0.51 → 2.0.53
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/benchmarks/selectbox-value-lookup.mjs +311 -0
- package/css/droplist.css +1 -1
- package/css/droplist.css.map +1 -1
- package/dist/lib.cjs.js +118 -15
- 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 +151 -48
- 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 +118 -15
- 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/eslint.config.mjs +1 -1
- package/lib/DropList.js +90 -41
- package/lib/SelectBox.js +61 -7
- package/package.json +2 -1
- package/scss/droplist.scss +11 -8
- package/vue/DropList.vue +51 -31
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
|
|
3
|
+
import { performance } from 'node:perf_hooks';
|
|
4
|
+
|
|
5
|
+
const topLevelCount = 10000;
|
|
6
|
+
const groupsCount = 100;
|
|
7
|
+
const subitemsPerGroup = 50;
|
|
8
|
+
const lookupIterations = 100000;
|
|
9
|
+
const stateIterations = 10000;
|
|
10
|
+
const resetIterations = 100;
|
|
11
|
+
|
|
12
|
+
function createItems() {
|
|
13
|
+
const items = [];
|
|
14
|
+
|
|
15
|
+
for (let i = 0; i < topLevelCount; i++) {
|
|
16
|
+
items.push({ label: `Top ${i}`, value: `top-${i}` });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
for (let groupIndex = 0; groupIndex < groupsCount; groupIndex++) {
|
|
20
|
+
const subitems = [];
|
|
21
|
+
|
|
22
|
+
for (let subitemIndex = 0; subitemIndex < subitemsPerGroup; subitemIndex++) {
|
|
23
|
+
subitems.push({
|
|
24
|
+
label: `Sub ${groupIndex}.${subitemIndex}`,
|
|
25
|
+
value: `sub-${groupIndex}-${subitemIndex}`,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
items.push({
|
|
30
|
+
label: `Group ${groupIndex}`,
|
|
31
|
+
value: `group-${groupIndex}`,
|
|
32
|
+
_subitems: subitems,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return items;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function createSelectBoxState(items, multi = false) {
|
|
40
|
+
const state = {
|
|
41
|
+
_p: {
|
|
42
|
+
items: [],
|
|
43
|
+
itemByValueMap: new Map(),
|
|
44
|
+
subitemByValueMap: null,
|
|
45
|
+
valueProp: 'value',
|
|
46
|
+
multi,
|
|
47
|
+
selectedItems: [],
|
|
48
|
+
selectedValues: [],
|
|
49
|
+
itemsChanged: true,
|
|
50
|
+
selectionChanged: true,
|
|
51
|
+
resortBySelectionNeeded: false,
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
setItems(nextItems, resetValues = true) {
|
|
55
|
+
const p = this._p;
|
|
56
|
+
|
|
57
|
+
p.items = (nextItems ?? []).slice(0);
|
|
58
|
+
p.itemsChanged = true;
|
|
59
|
+
this._updateItemByValueMap();
|
|
60
|
+
|
|
61
|
+
if (resetValues)
|
|
62
|
+
this.setSelectedValues(this.getSelectedValues());
|
|
63
|
+
|
|
64
|
+
return this;
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
setValue(value) {
|
|
68
|
+
const p = this._p;
|
|
69
|
+
if (p.multi)
|
|
70
|
+
return this.setSelectedValues(Array.isArray(value) ? value : value !== undefined ? [value] : []);
|
|
71
|
+
|
|
72
|
+
return this.setSelectedValues(value !== undefined ? [value] : []);
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
setSelectedValues(values) {
|
|
76
|
+
const p = this._p;
|
|
77
|
+
const valueProp = p.valueProp;
|
|
78
|
+
|
|
79
|
+
if (!p.multi)
|
|
80
|
+
values = values.slice(0, 1);
|
|
81
|
+
|
|
82
|
+
const set = new Set();
|
|
83
|
+
const selectedValues = [];
|
|
84
|
+
const selectedItems = [];
|
|
85
|
+
|
|
86
|
+
for (let value of values) {
|
|
87
|
+
if (set.has(value))
|
|
88
|
+
continue;
|
|
89
|
+
set.add(value);
|
|
90
|
+
|
|
91
|
+
selectedValues.push(value);
|
|
92
|
+
|
|
93
|
+
const item = this._getItemByValue(value);
|
|
94
|
+
if (item !== undefined) {
|
|
95
|
+
selectedItems.push(item);
|
|
96
|
+
} else {
|
|
97
|
+
selectedItems.push({ [valueProp]: value });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
p.selectedValues = selectedValues;
|
|
102
|
+
p.selectedItems = selectedItems;
|
|
103
|
+
p.selectionChanged = true;
|
|
104
|
+
p.resortBySelectionNeeded = true;
|
|
105
|
+
|
|
106
|
+
return this;
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
getSelectedValues() {
|
|
110
|
+
return this._p.selectedValues.slice(0);
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
updateItemByValue(value, newItem) {
|
|
114
|
+
const p = this._p;
|
|
115
|
+
const existingItem = this._getItemByValue(value);
|
|
116
|
+
|
|
117
|
+
if (existingItem) {
|
|
118
|
+
const currentValue = existingItem[p.valueProp];
|
|
119
|
+
if (p.itemByValueMap?.has(currentValue))
|
|
120
|
+
p.itemByValueMap.delete(currentValue);
|
|
121
|
+
|
|
122
|
+
Object.assign(existingItem, newItem);
|
|
123
|
+
p.itemByValueMap.set(existingItem[p.valueProp], existingItem);
|
|
124
|
+
p.subitemByValueMap = null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return this;
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
_updateItemByValueMap() {
|
|
131
|
+
const p = this._p;
|
|
132
|
+
const itemByValueMap = p.itemByValueMap = new Map();
|
|
133
|
+
const valueProp = p.valueProp;
|
|
134
|
+
|
|
135
|
+
for (let item of p.items) {
|
|
136
|
+
itemByValueMap.set(item[valueProp], item);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
p.subitemByValueMap = null;
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
_getItemByValue(value) {
|
|
143
|
+
const p = this._p;
|
|
144
|
+
let item = p.itemByValueMap.get(value);
|
|
145
|
+
if (item !== undefined)
|
|
146
|
+
return item;
|
|
147
|
+
|
|
148
|
+
if (!p.subitemByValueMap)
|
|
149
|
+
this._refreshSubitemByValueMap();
|
|
150
|
+
|
|
151
|
+
return p.subitemByValueMap.get(value);
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
_refreshSubitemByValueMap() {
|
|
155
|
+
const p = this._p;
|
|
156
|
+
const subitemByValueMap = p.subitemByValueMap = new Map();
|
|
157
|
+
this._addSubitemsToValueMap(p.items, subitemByValueMap, p.valueProp);
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
_addSubitemsToValueMap(itemsToMap, itemByValueMap, valueProp) {
|
|
161
|
+
for (let item of itemsToMap) {
|
|
162
|
+
if (!item._subitems?.length)
|
|
163
|
+
continue;
|
|
164
|
+
|
|
165
|
+
for (let subitem of item._subitems) {
|
|
166
|
+
if (!itemByValueMap.has(subitem[valueProp]))
|
|
167
|
+
itemByValueMap.set(subitem[valueProp], subitem);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
this._addSubitemsToValueMap(item._subitems, itemByValueMap, valueProp);
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
return state.setItems(items, false);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function assert(condition, message) {
|
|
179
|
+
if (!condition)
|
|
180
|
+
throw new Error(message);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function measure(name, fn) {
|
|
184
|
+
const startedAt = performance.now();
|
|
185
|
+
fn();
|
|
186
|
+
const elapsed = performance.now() - startedAt;
|
|
187
|
+
|
|
188
|
+
console.log(`${name.padEnd(48)} ${elapsed.toFixed(3)}ms`);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function heading(name) {
|
|
192
|
+
console.log(`\n${name}`);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const items = createItems();
|
|
196
|
+
const topLevelValue = `top-${topLevelCount - 1}`;
|
|
197
|
+
const otherTopLevelValue = `top-${topLevelCount - 2}`;
|
|
198
|
+
const subitemValue = `sub-${groupsCount - 1}-${subitemsPerGroup - 1}`;
|
|
199
|
+
const otherSubitemValue = `sub-${groupsCount - 1}-${subitemsPerGroup - 2}`;
|
|
200
|
+
|
|
201
|
+
heading('Value map');
|
|
202
|
+
|
|
203
|
+
measure('build top-level value map', () => {
|
|
204
|
+
createSelectBoxState(items);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
const lookup = createSelectBoxState(items);
|
|
208
|
+
measure(`${lookupIterations} top-level lookups`, () => {
|
|
209
|
+
for (let i = 0; i < lookupIterations; i++) {
|
|
210
|
+
lookup._getItemByValue(topLevelValue);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
assert(lookup._p.subitemByValueMap === null, 'Top-level lookups should not build the subitem map');
|
|
215
|
+
|
|
216
|
+
measure('first subitem lookup, includes cache build', () => {
|
|
217
|
+
const item = lookup._getItemByValue(subitemValue);
|
|
218
|
+
assert(item?.value === subitemValue, 'Expected subitem to resolve');
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
measure(`${lookupIterations} warmed subitem lookups`, () => {
|
|
222
|
+
for (let i = 0; i < lookupIterations; i++) {
|
|
223
|
+
lookup._getItemByValue(subitemValue);
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
heading('Single selection');
|
|
228
|
+
|
|
229
|
+
measure(`${stateIterations} setValue(top-level)`, () => {
|
|
230
|
+
const state = createSelectBoxState(items);
|
|
231
|
+
for (let i = 0; i < stateIterations; i++) {
|
|
232
|
+
state.setValue(i % 2 === 0 ? topLevelValue : otherTopLevelValue);
|
|
233
|
+
}
|
|
234
|
+
assert(state._p.subitemByValueMap === null, 'Top-level setValue should not build the subitem map');
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
measure(`${stateIterations} setValue(subitem, cold first)`, () => {
|
|
238
|
+
const state = createSelectBoxState(items);
|
|
239
|
+
for (let i = 0; i < stateIterations; i++) {
|
|
240
|
+
state.setValue(i % 2 === 0 ? subitemValue : otherSubitemValue);
|
|
241
|
+
}
|
|
242
|
+
assert(state._p.selectedItems[0]?.value === otherSubitemValue, 'Expected warmed subitem selection to resolve');
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
measure(`${stateIterations} setValue(unknown)`, () => {
|
|
246
|
+
const state = createSelectBoxState(items);
|
|
247
|
+
for (let i = 0; i < stateIterations; i++) {
|
|
248
|
+
state.setValue(`missing-${i}`);
|
|
249
|
+
}
|
|
250
|
+
assert(state._p.selectedItems[0]?.value === `missing-${stateIterations - 1}`, 'Expected unknown value fallback item');
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
heading('Multi selection');
|
|
254
|
+
|
|
255
|
+
measure(`${stateIterations} setSelectedValues(5 top-level)`, () => {
|
|
256
|
+
const state = createSelectBoxState(items, true);
|
|
257
|
+
for (let i = 0; i < stateIterations; i++) {
|
|
258
|
+
state.setSelectedValues(['top-1', 'top-2', 'top-3', 'top-4', 'top-5']);
|
|
259
|
+
}
|
|
260
|
+
assert(state._p.selectedItems.length === 5, 'Expected five selected top-level items');
|
|
261
|
+
assert(state._p.subitemByValueMap === null, 'Top-level multi selection should not build the subitem map');
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
measure(`${stateIterations} setSelectedValues(mixed)`, () => {
|
|
265
|
+
const state = createSelectBoxState(items, true);
|
|
266
|
+
for (let i = 0; i < stateIterations; i++) {
|
|
267
|
+
state.setSelectedValues(['top-1', subitemValue, 'missing-value', otherSubitemValue, 'top-1']);
|
|
268
|
+
}
|
|
269
|
+
assert(state._p.selectedItems.length === 4, 'Expected duplicate selected value to be ignored');
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
heading('Items and updates');
|
|
273
|
+
|
|
274
|
+
measure(`${resetIterations} setItems(reset top-level value)`, () => {
|
|
275
|
+
const state = createSelectBoxState(items);
|
|
276
|
+
state.setValue(topLevelValue);
|
|
277
|
+
|
|
278
|
+
for (let i = 0; i < resetIterations; i++) {
|
|
279
|
+
state.setItems(createItems());
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
assert(state._p.selectedItems[0]?.value === topLevelValue, 'Expected top-level selection after item reset');
|
|
283
|
+
assert(state._p.subitemByValueMap === null, 'Top-level item reset should not build the subitem map');
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
measure(`${resetIterations} setItems(reset subitem value)`, () => {
|
|
287
|
+
const state = createSelectBoxState(items);
|
|
288
|
+
state.setValue(subitemValue);
|
|
289
|
+
|
|
290
|
+
for (let i = 0; i < resetIterations; i++) {
|
|
291
|
+
state.setItems(createItems());
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
assert(state._p.selectedItems[0]?.value === subitemValue, 'Expected subitem selection after item reset');
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
measure(`${stateIterations} updateItemByValue(top-level)`, () => {
|
|
298
|
+
const state = createSelectBoxState(items);
|
|
299
|
+
for (let i = 0; i < stateIterations; i++) {
|
|
300
|
+
state.updateItemByValue('top-0', { label: `Top updated ${i}`, value: 'top-0' });
|
|
301
|
+
}
|
|
302
|
+
assert(state._getItemByValue('top-0')?.label === `Top updated ${stateIterations - 1}`, 'Expected top-level update');
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
measure(`${stateIterations} updateItemByValue(subitem)`, () => {
|
|
306
|
+
const state = createSelectBoxState(items);
|
|
307
|
+
for (let i = 0; i < stateIterations; i++) {
|
|
308
|
+
state.updateItemByValue('sub-0-0', { label: `Sub updated ${i}`, value: 'sub-0-0' });
|
|
309
|
+
}
|
|
310
|
+
assert(state._getItemByValue('sub-0-0')?.label === `Sub updated ${stateIterations - 1}`, 'Expected subitem update');
|
|
311
|
+
});
|
package/css/droplist.css
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
.droplist_wrapper{--droplist-border-radius: 5px;--droplist-border-above-below-radius: 0px;--droplist-above-margin: 1px;--droplist-below-margin: -1px;--droplist-item-height: 1.77em;--droplist-item-top-padding: 0.23em;--droplist-item-bottom-padding: 0.23em;--droplist-item-start-padding: 0.85em;--droplist-item-end-padding: 0.85em;--droplist-item-child-start-padding: 1.85em;--droplist-item-multi-top-padding: 0.077em;--droplist-item-multi-bottom-padding: 0.154em;--droplist-item-multi-start-padding: 0.154em;--droplist-item-multi-end-padding: 0.462em;--droplist-item-multi-label-top-padding: 0.077em;--droplist-item-multi-label-start-padding: 1.85em;--droplist-item-multi-child-start-padding: 1.15em;--droplist-item-remove-spacing: 2px;--droplist-checkbox-start: 6px;box-sizing:border-box;z-index:10000;float:left;margin:0;padding:0;border:1px solid #b1b1b1;outline:0;border-radius:var(--droplist-border-radius);background:#fff;max-height:300px;max-width:100%;line-height:1.3}.droplist_wrapper .droplist_header{position:relative;padding:.5em;box-sizing:inherit}.droplist_wrapper .droplist_header input[type=search]{box-sizing:inherit;width:100%}.droplist_wrapper.droplist__is_above{margin-top:var(--droplist-above-margin)}.droplist_wrapper.droplist__is_above,.droplist_wrapper.droplist__is_above ul{border-bottom-left-radius:var(--droplist-border-above-below-radius);border-bottom-right-radius:var(--droplist-border-above-below-radius)}.droplist_wrapper.droplist__is_below{margin-top:var(--droplist-below-margin)}.droplist_wrapper.droplist__is_below,.droplist_wrapper.droplist__is_below ul{border-top-left-radius:var(--droplist-border-above-below-radius);border-top-right-radius:var(--droplist-border-above-below-radius)}.droplist_wrapper ul{border-radius:var(--droplist-border-radius);position:relative;list-style:none;margin:0;padding:0;border:0;overflow-y:auto;overflow-x:hidden;max-height:100%;max-width:100%;background:none}.droplist_wrapper ul li{box-sizing:border-box;position:relative;margin:0;padding-top:var(--droplist-item-top-padding);padding-bottom:var(--droplist-item-bottom-padding);padding-left:var(--droplist-item-start-padding);padding-right:var(--droplist-item-end-padding);height:var(--droplist-item-height);color:#3e3f48;white-space:nowrap;cursor:pointer;width:100%;overflow:hidden}.droplist_wrapper ul li.droplist__item_focus{background-color:#3e3f48;color:#fff}.droplist_wrapper ul li .checkbox{position:absolute;top:50%;transform:translateY(-50%);left:var(--droplist-checkbox-start);display:block;width:16px;height:16px;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 448'%3E%3Crect x='14' y='14' width='420' height='420' rx='84' style='stroke-width: 28px; stroke: %236ca1c6; fill: %23dae7f1;'%3E%3C/rect%3E%3C/svg%3E");background-size:100% 100%}.droplist_wrapper ul li:not(:active):hover .checkbox{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 448'%3E%3Crect x='14' y='14' width='420' height='420' rx='84' style='stroke-width: 28px; stroke: %236ca1c6; fill: %23fff;'%3E%3C/rect%3E%3C/svg%3E")}.droplist_wrapper ul li:active .checkbox{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 448'%3E%3Crect x='14' y='14' width='420' height='420' rx='84' style='stroke-width: 28px; stroke: %23396d93; fill: %23b5cfe3;'%3E%3C/rect%3E%3C/svg%3E")}.droplist_wrapper ul li.droplist__item_multi.droplist__item_checked .checkbox{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 448'%3E%3Crect x='14' y='14' width='420' height='420' rx='84' style='stroke-width: 28px; stroke: %236ca1c6; fill: %23dae7f1;'%3E%3C/rect%3E%3Cpath fill='%236ca1c6' d='m364.136 158.276-172.589 171.204c-4.705 4.667-12.303 4.637-16.97-.068l-90.781-91.516c-4.667-4.705-4.637-12.303.069-16.971l22.719-22.536c4.705-4.667 12.303-4.637 16.97.069l59.792 60.277 141.352-140.216c4.705-4.667 12.303-4.637 16.97.068l22.536 22.718c4.667 4.706 4.637 12.304-.068 16.971z'/%3E%3C/svg%3E%0A")}.droplist_wrapper ul li.droplist__item_multi.droplist__item_checked:not(:active):hover .checkbox{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 448'%3E%3Crect x='14' y='14' width='420' height='420' rx='84' style='stroke-width: 28px; stroke: %236ca1c6; fill: %23fff;'%3E%3C/rect%3E%3Cpath fill='%236ca1c6' d='m364.136 158.276-172.589 171.204c-4.705 4.667-12.303 4.637-16.97-.068l-90.781-91.516c-4.667-4.705-4.637-12.303.069-16.971l22.719-22.536c4.705-4.667 12.303-4.637 16.97.069l59.792 60.277 141.352-140.216c4.705-4.667 12.303-4.637 16.97.068l22.536 22.718c4.667 4.706 4.637 12.304-.068 16.971z'/%3E%3C/svg%3E%0A")}.droplist_wrapper ul li.droplist__item_multi.droplist__item_checked:active .checkbox{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 448'%3E%3Crect x='14' y='14' width='420' height='420' rx='84' style='stroke-width: 28px; stroke: %23396d93; fill: %23b5cfe3;'%3E%3C/rect%3E%3Cpath fill='%23396d93' d='m364.136 158.276-172.589 171.204c-4.705 4.667-12.303 4.637-16.97-.068l-90.781-91.516c-4.667-4.705-4.637-12.303.069-16.971l22.719-22.536c4.705-4.667 12.303-4.637 16.97.069l59.792 60.277 141.352-140.216c4.705-4.667 12.303-4.637 16.97.068l22.536 22.718c4.667 4.706 4.637 12.304-.068 16.971z'/%3E%3C/svg%3E%0A")}.droplist_wrapper ul li.droplist__item_single.droplist__item_checked{opacity:.5}.droplist_wrapper ul li.droplist__item_multi:not(.droplist__item_multi_nocheck){padding-top:var(--droplist-item-multi-top-padding);padding-bottom:var(--droplist-item-multi-bottom-padding);padding-left:var(--droplist-item-multi-start-padding);padding-right:var(--droplist-item-multi-end-padding)}.droplist_wrapper ul li.droplist__item_multi:not(.droplist__item_multi_nocheck) .droplist__item_label{display:block;margin-top:var(--droplist-item-multi-label-top-padding);margin-left:var(--droplist-item-multi-label-start-padding)}.droplist_wrapper ul li.droplist__item_group{font-weight:bold}.droplist_wrapper ul li.droplist__item_child.droplist__item_multi:not(.droplist__item_multi_nocheck){padding-left:var(--droplist-item-multi-child-start-padding)}.droplist_wrapper ul li.droplist__item_child.droplist__item_single,.droplist_wrapper ul li.droplist__item_child.droplist__item_multi_nocheck{padding-left:var(--droplist-item-child-start-padding)}.droplist_wrapper ul li.droplist__item_nointeraction{cursor:default}.droplist_wrapper ul .droplist__no_results_content{text-align:center}.droplist_wrapper ul li .remove{display:none;position:absolute;top:0;right:var(--droplist-item-remove-spacing);width:34px;height:20px;padding:0;border:0;background:none;line-height:20px;vertical-align:middle;text-align:center;direction:ltr;font-size:15px;cursor:pointer}.droplist_wrapper ul li .remove:before{display:inline-block;content:"x";color:#fff}.droplist_wrapper ul .droplist__item_focus .remove{display:block}.droplist_wrapper.droplist__rtl,[dir=rtl] .droplist_wrapper:not(.droplist__ltr){direction:rtl}.droplist_wrapper.droplist__rtl ul li .checkbox,[dir=rtl] .droplist_wrapper:not(.droplist__ltr) ul li .checkbox{left:auto;right:var(--droplist-checkbox-start)}.droplist_wrapper.droplist__rtl ul li.droplist__item_multi:not(.droplist__item_multi_nocheck),[dir=rtl] .droplist_wrapper:not(.droplist__ltr) ul li.droplist__item_multi:not(.droplist__item_multi_nocheck){padding-left:var(--droplist-item-multi-end-padding);padding-right:var(--droplist-item-multi-start-padding)}.droplist_wrapper.droplist__rtl ul li.droplist__item_multi:not(.droplist__item_multi_nocheck) .droplist__item_label,[dir=rtl] .droplist_wrapper:not(.droplist__ltr) ul li.droplist__item_multi:not(.droplist__item_multi_nocheck) .droplist__item_label{margin-left:0;margin-right:var(--droplist-item-multi-label-start-padding)}.droplist_wrapper.droplist__rtl ul li.droplist__item_child.droplist__item_multi:not(.droplist__item_multi_nocheck),[dir=rtl] .droplist_wrapper:not(.droplist__ltr) ul li.droplist__item_child.droplist__item_multi:not(.droplist__item_multi_nocheck){padding-left:var(--droplist-item-multi-end-padding);padding-right:var(--droplist-item-multi-child-start-padding)}.droplist_wrapper.droplist__rtl ul li.droplist__item_child.droplist__item_single,.droplist_wrapper.droplist__rtl ul li.droplist__item_child.droplist__item_multi_nocheck,[dir=rtl] .droplist_wrapper:not(.droplist__ltr) ul li.droplist__item_child.droplist__item_single,[dir=rtl] .droplist_wrapper:not(.droplist__ltr) ul li.droplist__item_child.droplist__item_multi_nocheck{padding-left:var(--droplist-item-end-padding);padding-right:var(--droplist-item-child-start-padding)}.droplist_wrapper.droplist__rtl ul li .remove,[dir=rtl] .droplist_wrapper:not(.droplist__ltr) ul li .remove{right:auto;left:var(--droplist-item-remove-spacing)}.droplist_wrapper.droplist_disabled_no_interaction ul li.droplist__item_nointeraction{opacity:.5}
|
|
1
|
+
.droplist_wrapper{--droplist-border-radius: 5px;--droplist-border-above-below-radius: 0px;--droplist-above-margin: 1px;--droplist-below-margin: -1px;--droplist-item-height: 1.77em;--droplist-item-top-padding: 0.23em;--droplist-item-bottom-padding: 0.23em;--droplist-item-start-padding: 0.85em;--droplist-item-end-padding: 0.85em;--droplist-item-child-start-padding: 1.85em;--droplist-item-multi-top-padding: 0.077em;--droplist-item-multi-bottom-padding: 0.154em;--droplist-item-multi-start-padding: 0.154em;--droplist-item-multi-end-padding: 0.462em;--droplist-item-multi-label-top-padding: 0.077em;--droplist-item-multi-label-start-padding: 1.85em;--droplist-item-multi-child-start-padding: 1.15em;--droplist-item-remove-spacing: 2px;--droplist-checkbox-start: 6px;box-sizing:border-box;z-index:10000;float:left;margin:0;padding:0;border:1px solid #b1b1b1;outline:0;border-radius:var(--droplist-border-radius);background:#fff;max-height:300px;max-width:100%;line-height:1.3}.droplist_wrapper .droplist_header,.droplist_wrapper .droplist_footer{position:relative;padding:.5em;box-sizing:inherit}.droplist_wrapper .droplist_header input[type=search]{box-sizing:inherit;width:100%}.droplist_wrapper.droplist__is_above{margin-top:var(--droplist-above-margin)}.droplist_wrapper.droplist__is_above,.droplist_wrapper.droplist__is_above ul{border-bottom-left-radius:var(--droplist-border-above-below-radius);border-bottom-right-radius:var(--droplist-border-above-below-radius)}.droplist_wrapper.droplist__is_below{margin-top:var(--droplist-below-margin)}.droplist_wrapper.droplist__is_below,.droplist_wrapper.droplist__is_below ul{border-top-left-radius:var(--droplist-border-above-below-radius);border-top-right-radius:var(--droplist-border-above-below-radius)}.droplist_wrapper ul{border-radius:var(--droplist-border-radius);position:relative;list-style:none;margin:0;padding:0;border:0;overflow-y:auto;overflow-x:hidden;max-height:100%;max-width:100%;background:none}.droplist_wrapper ul li{box-sizing:border-box;position:relative;margin:0;padding-top:var(--droplist-item-top-padding);padding-bottom:var(--droplist-item-bottom-padding);padding-left:var(--droplist-item-start-padding);padding-right:var(--droplist-item-end-padding);height:var(--droplist-item-height);color:#3e3f48;white-space:nowrap;cursor:pointer;width:100%;overflow:hidden}.droplist_wrapper ul li.droplist__item_focus{background-color:#3e3f48;color:#fff}.droplist_wrapper ul li .checkbox{position:absolute;top:50%;transform:translateY(-50%);left:var(--droplist-checkbox-start);display:block;width:16px;height:16px;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 448'%3E%3Crect x='14' y='14' width='420' height='420' rx='84' style='stroke-width: 28px; stroke: %236ca1c6; fill: %23dae7f1;'%3E%3C/rect%3E%3C/svg%3E");background-size:100% 100%}.droplist_wrapper ul li:not(:active):hover .checkbox{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 448'%3E%3Crect x='14' y='14' width='420' height='420' rx='84' style='stroke-width: 28px; stroke: %236ca1c6; fill: %23fff;'%3E%3C/rect%3E%3C/svg%3E")}.droplist_wrapper ul li:active .checkbox{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 448'%3E%3Crect x='14' y='14' width='420' height='420' rx='84' style='stroke-width: 28px; stroke: %23396d93; fill: %23b5cfe3;'%3E%3C/rect%3E%3C/svg%3E")}.droplist_wrapper ul li.droplist__item_multi.droplist__item_checked .checkbox{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 448'%3E%3Crect x='14' y='14' width='420' height='420' rx='84' style='stroke-width: 28px; stroke: %236ca1c6; fill: %23dae7f1;'%3E%3C/rect%3E%3Cpath fill='%236ca1c6' d='m364.136 158.276-172.589 171.204c-4.705 4.667-12.303 4.637-16.97-.068l-90.781-91.516c-4.667-4.705-4.637-12.303.069-16.971l22.719-22.536c4.705-4.667 12.303-4.637 16.97.069l59.792 60.277 141.352-140.216c4.705-4.667 12.303-4.637 16.97.068l22.536 22.718c4.667 4.706 4.637 12.304-.068 16.971z'/%3E%3C/svg%3E%0A")}.droplist_wrapper ul li.droplist__item_multi.droplist__item_checked:not(:active):hover .checkbox{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 448'%3E%3Crect x='14' y='14' width='420' height='420' rx='84' style='stroke-width: 28px; stroke: %236ca1c6; fill: %23fff;'%3E%3C/rect%3E%3Cpath fill='%236ca1c6' d='m364.136 158.276-172.589 171.204c-4.705 4.667-12.303 4.637-16.97-.068l-90.781-91.516c-4.667-4.705-4.637-12.303.069-16.971l22.719-22.536c4.705-4.667 12.303-4.637 16.97.069l59.792 60.277 141.352-140.216c4.705-4.667 12.303-4.637 16.97.068l22.536 22.718c4.667 4.706 4.637 12.304-.068 16.971z'/%3E%3C/svg%3E%0A")}.droplist_wrapper ul li.droplist__item_multi.droplist__item_checked:active .checkbox{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 448'%3E%3Crect x='14' y='14' width='420' height='420' rx='84' style='stroke-width: 28px; stroke: %23396d93; fill: %23b5cfe3;'%3E%3C/rect%3E%3Cpath fill='%23396d93' d='m364.136 158.276-172.589 171.204c-4.705 4.667-12.303 4.637-16.97-.068l-90.781-91.516c-4.667-4.705-4.637-12.303.069-16.971l22.719-22.536c4.705-4.667 12.303-4.637 16.97.069l59.792 60.277 141.352-140.216c4.705-4.667 12.303-4.637 16.97.068l22.536 22.718c4.667 4.706 4.637 12.304-.068 16.971z'/%3E%3C/svg%3E%0A")}.droplist_wrapper ul li.droplist__item_single.droplist__item_checked{opacity:.5}.droplist_wrapper ul li.droplist__item_multi:not(.droplist__item_multi_nocheck){padding-top:var(--droplist-item-multi-top-padding);padding-bottom:var(--droplist-item-multi-bottom-padding);padding-left:var(--droplist-item-multi-start-padding);padding-right:var(--droplist-item-multi-end-padding)}.droplist_wrapper ul li.droplist__item_multi:not(.droplist__item_multi_nocheck) .droplist__item_label{display:block;margin-top:var(--droplist-item-multi-label-top-padding);margin-left:var(--droplist-item-multi-label-start-padding)}.droplist_wrapper ul li.droplist__item_group{font-weight:bold}.droplist_wrapper ul li.droplist__item_child.droplist__item_multi:not(.droplist__item_multi_nocheck){padding-left:var(--droplist-item-multi-child-start-padding)}.droplist_wrapper ul li.droplist__item_child.droplist__item_single,.droplist_wrapper ul li.droplist__item_child.droplist__item_multi_nocheck{padding-left:var(--droplist-item-child-start-padding)}.droplist_wrapper ul li.droplist__item_nointeraction{cursor:default}.droplist_wrapper ul .droplist__no_results_content{text-align:center}.droplist_wrapper ul li .remove{display:none;position:absolute;top:0;right:var(--droplist-item-remove-spacing);width:34px;height:20px;padding:0;border:0;background:none;line-height:20px;vertical-align:middle;text-align:center;direction:ltr;font-size:15px;cursor:pointer}.droplist_wrapper ul li .remove:before{display:inline-block;content:"x";color:#fff}.droplist_wrapper ul .droplist__item_focus .remove{display:block}.droplist_wrapper.droplist__rtl,[dir=rtl] .droplist_wrapper:not(.droplist__ltr){direction:rtl}.droplist_wrapper.droplist__rtl ul li .checkbox,[dir=rtl] .droplist_wrapper:not(.droplist__ltr) ul li .checkbox{left:auto;right:var(--droplist-checkbox-start)}.droplist_wrapper.droplist__rtl ul li.droplist__item_multi:not(.droplist__item_multi_nocheck),[dir=rtl] .droplist_wrapper:not(.droplist__ltr) ul li.droplist__item_multi:not(.droplist__item_multi_nocheck){padding-left:var(--droplist-item-multi-end-padding);padding-right:var(--droplist-item-multi-start-padding)}.droplist_wrapper.droplist__rtl ul li.droplist__item_multi:not(.droplist__item_multi_nocheck) .droplist__item_label,[dir=rtl] .droplist_wrapper:not(.droplist__ltr) ul li.droplist__item_multi:not(.droplist__item_multi_nocheck) .droplist__item_label{margin-left:0;margin-right:var(--droplist-item-multi-label-start-padding)}.droplist_wrapper.droplist__rtl ul li.droplist__item_child.droplist__item_multi:not(.droplist__item_multi_nocheck),[dir=rtl] .droplist_wrapper:not(.droplist__ltr) ul li.droplist__item_child.droplist__item_multi:not(.droplist__item_multi_nocheck){padding-left:var(--droplist-item-multi-end-padding);padding-right:var(--droplist-item-multi-child-start-padding)}.droplist_wrapper.droplist__rtl ul li.droplist__item_child.droplist__item_single,.droplist_wrapper.droplist__rtl ul li.droplist__item_child.droplist__item_multi_nocheck,[dir=rtl] .droplist_wrapper:not(.droplist__ltr) ul li.droplist__item_child.droplist__item_single,[dir=rtl] .droplist_wrapper:not(.droplist__ltr) ul li.droplist__item_child.droplist__item_multi_nocheck{padding-left:var(--droplist-item-end-padding);padding-right:var(--droplist-item-child-start-padding)}.droplist_wrapper.droplist__rtl ul li .remove,[dir=rtl] .droplist_wrapper:not(.droplist__ltr) ul li .remove{right:auto;left:var(--droplist-item-remove-spacing)}.droplist_wrapper.droplist_disabled_no_interaction ul li.droplist__item_nointeraction{opacity:.5}
|
|
2
2
|
|
|
3
3
|
/*# sourceMappingURL=droplist.css.map */
|
package/css/droplist.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sourceRoot":"","sources":["../scss/droplist.scss"],"names":[],"mappings":"AAAA,kBACC,8BACA,0CACA,6BACA,8BACA,+BACA,oCACA,uCACA,sCACA,oCACA,4CACA,2CACA,8CACA,6CACA,2CACA,iDACA,kDACA,kDACA,oCACA,+BAEA,sBACA,cACA,WACA,SACA,UACA,yBACA,UACA,4CACA,gBACA,iBACA,eACA,gBAEA,
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["../scss/droplist.scss"],"names":[],"mappings":"AAAA,kBACC,8BACA,0CACA,6BACA,8BACA,+BACA,oCACA,uCACA,sCACA,oCACA,4CACA,2CACA,8CACA,6CACA,2CACA,iDACA,kDACA,kDACA,oCACA,+BAEA,sBACA,cACA,WACA,SACA,UACA,yBACA,UACA,4CACA,gBACA,iBACA,eACA,gBAEA,sEAEC,kBACA,aACA,mBAIA,sDACC,mBACA,WAIF,qCACC,wCAEA,6EACC,oEACA,qEAIF,qCACC,wCAEA,6EACC,iEACA,kEAIF,qBACC,4CACA,kBACA,gBACA,SACA,UACA,SACA,gBACA,kBACA,gBACA,eACA,gBAEA,wBACC,sBACA,kBACA,SACA,6CACA,mDACA,gDACA,+CACA,mCACA,cACA,mBACA,eAIA,WACA,gBAEA,6CAEC,yBACA,WAKD,kCACC,kBACA,QACA,2BACA,oCACA,cACA,WACA,YAGA,4PACA,0BAGD,qDAEC,yPAGD,yCAEC,4PAKD,8EAEC,+jBAGD,iGAEC,4jBAGD,qFAEC,+jBAIF,qEACC,WAGD,gFACC,mDACA,yDACA,sDACA,qDAEA,sGACC,cACA,wDACA,2DAIF,6CACC,iBAGD,qGACC,4DAGD,6IAEC,sDAGD,qDACC,eAGD,mDACC,kBAGD,gCACC,aACA,kBACA,MACA,0CACA,WACA,YACA,UACA,SACA,gBACA,iBACA,sBACA,kBACA,cACA,eACA,eAEA,uCACC,qBACA,YACA,WAIF,mDACC,cAIF,gFAEC,cAMC,gHACC,UACA,qCAIF,4MACC,oDACA,uDAEA,wPACC,cACA,4DAIF,sPACC,oDACA,6DAGD,kXAEC,8CACA,uDAGD,4GACC,WACA,yCAKH,sFACC"}
|
package/dist/lib.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @danielgindi/selectbox 2.0.
|
|
2
|
+
* @danielgindi/selectbox 2.0.53
|
|
3
3
|
* git://github.com/danielgindi/selectbox.git
|
|
4
4
|
*/
|
|
5
5
|
'use strict';
|
|
@@ -6322,7 +6322,8 @@ const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
|
6322
6322
|
* @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [renderNoResultsItem]
|
|
6323
6323
|
* @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderNoResultsItem]
|
|
6324
6324
|
* @property {function(name: string, data: *)} [on]
|
|
6325
|
-
* @property {boolean} [isHeaderVisible=false] show header element
|
|
6325
|
+
* @property {boolean} [isHeaderVisible=false] show header element
|
|
6326
|
+
* @property {boolean} [isFooterVisible=false] show footer element
|
|
6326
6327
|
* @property {boolean} [searchable=false] include inline search box
|
|
6327
6328
|
* @property {string} [noResultsText='No matching results'] text for no results (empty for none)
|
|
6328
6329
|
* @property {number} [filterThrottleWindow=300] throttle time (milliseconds) for filtering
|
|
@@ -6396,6 +6397,7 @@ const DefaultOptions$1 = {
|
|
|
6396
6397
|
on: null,
|
|
6397
6398
|
|
|
6398
6399
|
isHeaderVisible: false,
|
|
6400
|
+
isFooterVisible: false,
|
|
6399
6401
|
searchable: false,
|
|
6400
6402
|
noResultsText: 'No matching results',
|
|
6401
6403
|
filterThrottleWindow: 300,
|
|
@@ -6469,6 +6471,7 @@ class DropList {
|
|
|
6469
6471
|
|
|
6470
6472
|
searchable: o.searchable,
|
|
6471
6473
|
isHeaderVisible: o.isHeaderVisible,
|
|
6474
|
+
isFooterVisible: o.isFooterVisible,
|
|
6472
6475
|
|
|
6473
6476
|
silenceEvents: true,
|
|
6474
6477
|
mitt: mitt(),
|
|
@@ -6526,6 +6529,10 @@ class DropList {
|
|
|
6526
6529
|
class: p.baseClassName + '_header'
|
|
6527
6530
|
});
|
|
6528
6531
|
|
|
6532
|
+
p.footerEl = Dom.createElement('div', {
|
|
6533
|
+
class: p.baseClassName + '_footer'
|
|
6534
|
+
});
|
|
6535
|
+
|
|
6529
6536
|
if (o.searchable) {
|
|
6530
6537
|
this.setSearchable(true);
|
|
6531
6538
|
}
|
|
@@ -6535,6 +6542,9 @@ class DropList {
|
|
|
6535
6542
|
|
|
6536
6543
|
wrapperEl.appendChild(menuEl);
|
|
6537
6544
|
|
|
6545
|
+
if (o.isFooterVisible)
|
|
6546
|
+
this.setFooterVisible(o.isFooterVisible);
|
|
6547
|
+
|
|
6538
6548
|
p.items = [];
|
|
6539
6549
|
p.groupCount = 0; // This will keep state of how many `group` items we have
|
|
6540
6550
|
p.mouseHandled = false;
|
|
@@ -7791,12 +7801,18 @@ class DropList {
|
|
|
7791
7801
|
headerHeight = Css.getElementHeight(p.headerEl, true, true);
|
|
7792
7802
|
}
|
|
7793
7803
|
|
|
7804
|
+
let footerHeight = 0;
|
|
7805
|
+
if (p.footerEl) {
|
|
7806
|
+
footerHeight = Css.getElementHeight(p.footerEl, true, true);
|
|
7807
|
+
}
|
|
7808
|
+
|
|
7794
7809
|
if (p.virtualListHelper.isVirtual()) {
|
|
7795
7810
|
maxViewHeight =
|
|
7796
7811
|
p.virtualListHelper.estimateFullHeight() +
|
|
7797
7812
|
verticalPadding +
|
|
7798
7813
|
verticalBorderWidth +
|
|
7799
|
-
headerHeight
|
|
7814
|
+
headerHeight +
|
|
7815
|
+
footerHeight;
|
|
7800
7816
|
} else {
|
|
7801
7817
|
// Another method to calculate height is measuring the whole thing at once.
|
|
7802
7818
|
// This causes relayout of course.
|
|
@@ -7940,7 +7956,7 @@ class DropList {
|
|
|
7940
7956
|
Css.setElementHeight(el, viewSize.height, true, true);
|
|
7941
7957
|
|
|
7942
7958
|
if (menuEl !== el) {
|
|
7943
|
-
let menuHeight = viewSize.height - headerHeight - verticalBorderWidth - verticalPadding;
|
|
7959
|
+
let menuHeight = viewSize.height - headerHeight - footerHeight - verticalBorderWidth - verticalPadding;
|
|
7944
7960
|
Css.setElementHeight(menuEl, menuHeight, true, true);
|
|
7945
7961
|
}
|
|
7946
7962
|
|
|
@@ -8276,9 +8292,42 @@ class DropList {
|
|
|
8276
8292
|
return this._p.headerEl;
|
|
8277
8293
|
}
|
|
8278
8294
|
|
|
8279
|
-
/**
|
|
8280
|
-
*
|
|
8281
|
-
* You should probably call `relayout()` after this.
|
|
8295
|
+
/**
|
|
8296
|
+
* Change visibility of the footer element
|
|
8297
|
+
* You should probably call `relayout()` after this.
|
|
8298
|
+
* @param {boolean} visible
|
|
8299
|
+
*/
|
|
8300
|
+
setFooterVisible(visible) {
|
|
8301
|
+
let isVisible = this.isFooterVisible();
|
|
8302
|
+
if (isVisible === !!visible)
|
|
8303
|
+
return;
|
|
8304
|
+
|
|
8305
|
+
if (visible) {
|
|
8306
|
+
this._p.el.appendChild(this._p.footerEl);
|
|
8307
|
+
} else {
|
|
8308
|
+
this._p.footerEl.remove();
|
|
8309
|
+
}
|
|
8310
|
+
}
|
|
8311
|
+
|
|
8312
|
+
/**
|
|
8313
|
+
* Is the footer element visible?
|
|
8314
|
+
* @returns {boolean}
|
|
8315
|
+
*/
|
|
8316
|
+
isFooterVisible() {
|
|
8317
|
+
return !!this._p.footerEl.parentNode;
|
|
8318
|
+
}
|
|
8319
|
+
|
|
8320
|
+
/**
|
|
8321
|
+
* Get a reference to the footer element in order to add custom content.
|
|
8322
|
+
* @returns {Element}
|
|
8323
|
+
*/
|
|
8324
|
+
getFooterElement() {
|
|
8325
|
+
return this._p.footerEl;
|
|
8326
|
+
}
|
|
8327
|
+
|
|
8328
|
+
/**
|
|
8329
|
+
* Set inline search visibility
|
|
8330
|
+
* You should probably call `relayout()` after this.
|
|
8282
8331
|
* @param {boolean} searchable
|
|
8283
8332
|
*/
|
|
8284
8333
|
setSearchable(searchable) {
|
|
@@ -10434,7 +10483,7 @@ class SelectBox {
|
|
|
10434
10483
|
p.items = items.slice(0);
|
|
10435
10484
|
p.itemsChanged = true;
|
|
10436
10485
|
|
|
10437
|
-
this.
|
|
10486
|
+
this._refreshItemByValueMap();
|
|
10438
10487
|
|
|
10439
10488
|
if (resetValues) {
|
|
10440
10489
|
this.setSelectedValues(this.getSelectedValues());
|
|
@@ -10465,9 +10514,16 @@ class SelectBox {
|
|
|
10465
10514
|
updateItemByValue(value, newItem) {
|
|
10466
10515
|
const p = this._p;
|
|
10467
10516
|
|
|
10468
|
-
let existingItem =
|
|
10469
|
-
if (existingItem)
|
|
10470
|
-
|
|
10517
|
+
let existingItem = this._getItemByValue(value);
|
|
10518
|
+
if (existingItem) {var _p$itemByValueMap;
|
|
10519
|
+
const valueProp = existingItem[p.valueProp];
|
|
10520
|
+
if ((_p$itemByValueMap = p.itemByValueMap) !== null && _p$itemByValueMap !== void 0 && _p$itemByValueMap.has(valueProp))
|
|
10521
|
+
p.itemByValueMap.delete(valueProp);
|
|
10522
|
+
|
|
10523
|
+
Object.assign(existingItem, newItem);
|
|
10524
|
+
|
|
10525
|
+
p.itemByValueMap.set(existingItem[p.valueProp], existingItem);
|
|
10526
|
+
}
|
|
10471
10527
|
|
|
10472
10528
|
if (p.dropList) {
|
|
10473
10529
|
p.dropList.updateItemByValue(value, newItem);
|
|
@@ -11038,7 +11094,7 @@ class SelectBox {
|
|
|
11038
11094
|
if (p.dropList)
|
|
11039
11095
|
p.dropList.setValueProp(prop);
|
|
11040
11096
|
|
|
11041
|
-
this.
|
|
11097
|
+
this._refreshItemByValueMap();
|
|
11042
11098
|
|
|
11043
11099
|
return this;
|
|
11044
11100
|
}
|
|
@@ -11224,7 +11280,7 @@ class SelectBox {
|
|
|
11224
11280
|
|
|
11225
11281
|
selectedValues.push(value);
|
|
11226
11282
|
|
|
11227
|
-
let item =
|
|
11283
|
+
let item = this._getItemByValue(value);
|
|
11228
11284
|
if (item !== undefined) {
|
|
11229
11285
|
selectedItems.push(item);
|
|
11230
11286
|
} else {
|
|
@@ -11519,7 +11575,7 @@ class SelectBox {
|
|
|
11519
11575
|
* This reduces search time greatly (i.e when checking items), especially when Vue proxies are in place.
|
|
11520
11576
|
* @private
|
|
11521
11577
|
*/
|
|
11522
|
-
|
|
11578
|
+
_refreshItemByValueMap() {
|
|
11523
11579
|
const p = this._p;
|
|
11524
11580
|
|
|
11525
11581
|
const itemByValueMap = p.itemByValueMap = new Map();
|
|
@@ -11527,6 +11583,52 @@ class SelectBox {
|
|
|
11527
11583
|
for (let item of p.items) {
|
|
11528
11584
|
itemByValueMap.set(item[valueProp], item);
|
|
11529
11585
|
}
|
|
11586
|
+
|
|
11587
|
+
p.subitemByValueMap = null;
|
|
11588
|
+
}
|
|
11589
|
+
|
|
11590
|
+
/**
|
|
11591
|
+
* @param {*} value
|
|
11592
|
+
* @returns {DropList.ItemBase|undefined}
|
|
11593
|
+
* @private
|
|
11594
|
+
*/
|
|
11595
|
+
_getItemByValue(value) {
|
|
11596
|
+
const p = this._p;
|
|
11597
|
+
let item = p.itemByValueMap.get(value);
|
|
11598
|
+
if (item !== undefined)
|
|
11599
|
+
return item;
|
|
11600
|
+
|
|
11601
|
+
if (!p.subitemByValueMap)
|
|
11602
|
+
this._refreshSubitemByValueMap();
|
|
11603
|
+
|
|
11604
|
+
return p.subitemByValueMap.get(value);
|
|
11605
|
+
}
|
|
11606
|
+
|
|
11607
|
+
/** @private */
|
|
11608
|
+
_refreshSubitemByValueMap() {
|
|
11609
|
+
const p = this._p;
|
|
11610
|
+
const subitemByValueMap = p.subitemByValueMap = new Map();
|
|
11611
|
+
this._addSubitemsToValueMap(p.items, subitemByValueMap, p.valueProp);
|
|
11612
|
+
}
|
|
11613
|
+
|
|
11614
|
+
/**
|
|
11615
|
+
* @param {DropList.ItemBase[]} items
|
|
11616
|
+
* @param {Map<*, DropList.ItemBase>} itemByValueMap
|
|
11617
|
+
* @param {string} valueProp
|
|
11618
|
+
* @private
|
|
11619
|
+
*/
|
|
11620
|
+
_addSubitemsToValueMap(items, itemByValueMap, valueProp) {
|
|
11621
|
+
for (let item of items) {var _item$_subitems;
|
|
11622
|
+
if (!((_item$_subitems = item._subitems) !== null && _item$_subitems !== void 0 && _item$_subitems.length))
|
|
11623
|
+
continue;
|
|
11624
|
+
|
|
11625
|
+
for (let subitem of item._subitems) {
|
|
11626
|
+
if (!itemByValueMap.has(subitem[valueProp]))
|
|
11627
|
+
itemByValueMap.set(subitem[valueProp], subitem);
|
|
11628
|
+
}
|
|
11629
|
+
|
|
11630
|
+
this._addSubitemsToValueMap(item._subitems, itemByValueMap, valueProp);
|
|
11631
|
+
}
|
|
11530
11632
|
}
|
|
11531
11633
|
|
|
11532
11634
|
/** @private */
|
|
@@ -11911,7 +12013,8 @@ class SelectBox {
|
|
|
11911
12013
|
}
|
|
11912
12014
|
break;
|
|
11913
12015
|
|
|
11914
|
-
case 'select':
|
|
12016
|
+
case 'select':
|
|
12017
|
+
case 'subitems:select':{
|
|
11915
12018
|
if (p.multi) return;
|
|
11916
12019
|
|
|
11917
12020
|
const item = event.item;
|