@frontile/collections 0.17.0-beta.6 → 0.17.0-beta.8
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/components/dropdown.js +1 -1
- package/dist/components/listbox.js +1 -2
- package/dist/components/listbox.js.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/listManager-D4_vozfz.js +438 -0
- package/dist/listManager-D4_vozfz.js.map +1 -0
- package/dist/{components/listbox/item.js → listbox-DPCqpk4Q.js} +104 -5
- package/dist/listbox-DPCqpk4Q.js.map +1 -0
- package/dist/utils/listManager.js +4 -373
- package/dist/utils/listManager.js.map +1 -1
- package/package.json +6 -8
- package/dist/_app_/components/listbox/item.js +0 -1
- package/dist/_app_/components/listbox/listbox.js +0 -1
- package/dist/components/listbox/item.js.map +0 -1
- package/dist/components/listbox/listbox.js +0 -109
- package/dist/components/listbox/listbox.js.map +0 -1
- package/dist/runtime-BPCpkOf1-B5Lbloj7.js +0 -67
- package/dist/runtime-BPCpkOf1-B5Lbloj7.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { Button } from '@frontile/buttons';
|
|
3
|
-
import { Listbox } from '
|
|
3
|
+
import { L as Listbox } from '../listbox-DPCqpk4Q.js';
|
|
4
4
|
import { Popover } from '@frontile/overlays';
|
|
5
5
|
import { assert } from '@ember/debug';
|
|
6
6
|
import { hash } from '@ember/helper';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listbox.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"listbox.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { Listbox } from './
|
|
1
|
+
export { L as Listbox, a as ListboxItem } from './listbox-DPCqpk4Q.js';
|
|
2
2
|
export { Dropdown } from './components/dropdown.js';
|
|
3
|
-
export { ListboxItem } from './components/listbox/item.js';
|
|
4
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
import { tracked } from '@glimmer/tracking';
|
|
2
|
+
import { later, debounce } from '@ember/runloop';
|
|
3
|
+
import { modifier } from 'ember-modifier';
|
|
4
|
+
|
|
5
|
+
const deferred = /* @__PURE__ */new WeakMap();
|
|
6
|
+
function deferDecorator(proto, prop, desc) {
|
|
7
|
+
let map = deferred.get(proto);
|
|
8
|
+
if (!map) {
|
|
9
|
+
map = /* @__PURE__ */new Map();
|
|
10
|
+
deferred.set(proto, map);
|
|
11
|
+
}
|
|
12
|
+
map.set(prop, desc);
|
|
13
|
+
}
|
|
14
|
+
function findDeferredDecorator(target, prop) {
|
|
15
|
+
var _a;
|
|
16
|
+
let cursor = target.prototype;
|
|
17
|
+
while (cursor) {
|
|
18
|
+
let desc = (_a = deferred.get(cursor)) == null ? void 0 : _a.get(prop);
|
|
19
|
+
if (desc) {
|
|
20
|
+
return desc;
|
|
21
|
+
}
|
|
22
|
+
cursor = cursor.prototype;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function decorateFieldV2(prototype, prop, decorators, initializer) {
|
|
26
|
+
let desc = {
|
|
27
|
+
configurable: true,
|
|
28
|
+
enumerable: true,
|
|
29
|
+
writable: true,
|
|
30
|
+
initializer: null
|
|
31
|
+
};
|
|
32
|
+
if (initializer) {
|
|
33
|
+
desc.initializer = initializer;
|
|
34
|
+
}
|
|
35
|
+
for (let decorator of decorators) {
|
|
36
|
+
desc = decorator(prototype, prop, desc) || desc;
|
|
37
|
+
}
|
|
38
|
+
if (desc.initializer === void 0) {
|
|
39
|
+
Object.defineProperty(prototype, prop, desc);
|
|
40
|
+
} else {
|
|
41
|
+
deferDecorator(prototype, prop, desc);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function decorateMethodV2(prototype, prop, decorators) {
|
|
45
|
+
const origDesc = Object.getOwnPropertyDescriptor(prototype, prop);
|
|
46
|
+
let desc = {
|
|
47
|
+
...origDesc
|
|
48
|
+
};
|
|
49
|
+
for (let decorator of decorators) {
|
|
50
|
+
desc = decorator(prototype, prop, desc) || desc;
|
|
51
|
+
}
|
|
52
|
+
if (desc.initializer !== void 0) {
|
|
53
|
+
desc.value = desc.initializer ? desc.initializer.call(prototype) : void 0;
|
|
54
|
+
desc.initializer = void 0;
|
|
55
|
+
}
|
|
56
|
+
Object.defineProperty(prototype, prop, desc);
|
|
57
|
+
}
|
|
58
|
+
function initializeDeferredDecorator(target, prop) {
|
|
59
|
+
let desc = findDeferredDecorator(target.constructor, prop);
|
|
60
|
+
if (desc) {
|
|
61
|
+
Object.defineProperty(target, prop, {
|
|
62
|
+
enumerable: desc.enumerable,
|
|
63
|
+
configurable: desc.configurable,
|
|
64
|
+
writable: desc.writable,
|
|
65
|
+
value: desc.initializer ? desc.initializer.call(target) : void 0
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* eslint-disable ember/no-runloop */
|
|
71
|
+
class ListItem {
|
|
72
|
+
el;
|
|
73
|
+
key;
|
|
74
|
+
textValue;
|
|
75
|
+
static {
|
|
76
|
+
decorateFieldV2(this.prototype, "isSelected", [tracked]);
|
|
77
|
+
}
|
|
78
|
+
#isSelected = (initializeDeferredDecorator(this, "isSelected"), void 0);
|
|
79
|
+
static {
|
|
80
|
+
decorateFieldV2(this.prototype, "isDisabled", [tracked]);
|
|
81
|
+
}
|
|
82
|
+
#isDisabled = (initializeDeferredDecorator(this, "isDisabled"), void 0);
|
|
83
|
+
static {
|
|
84
|
+
decorateFieldV2(this.prototype, "isActive", [tracked]);
|
|
85
|
+
}
|
|
86
|
+
#isActive = (initializeDeferredDecorator(this, "isActive"), void 0);
|
|
87
|
+
constructor(el, args) {
|
|
88
|
+
this.el = el;
|
|
89
|
+
this.key = args.key;
|
|
90
|
+
this.textValue = args.textValue;
|
|
91
|
+
this.isSelected = args.isSelected;
|
|
92
|
+
this.isDisabled = args.isDisabled;
|
|
93
|
+
this.isActive = args.isActive;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
class ListManager {
|
|
97
|
+
#items = [];
|
|
98
|
+
searchKeys = '';
|
|
99
|
+
args = {
|
|
100
|
+
selectionMode: 'none',
|
|
101
|
+
selectedKeys: [],
|
|
102
|
+
disabledKeys: [],
|
|
103
|
+
allowEmpty: false,
|
|
104
|
+
autoActivateMode: 'none'
|
|
105
|
+
};
|
|
106
|
+
constructor(args = {}) {
|
|
107
|
+
this.updateArgs(args);
|
|
108
|
+
}
|
|
109
|
+
register(el, args) {
|
|
110
|
+
if (this.args.autoActivateMode == 'first' && this.#items.length === 0 && !args.isDisabled) {
|
|
111
|
+
args.isActive = true;
|
|
112
|
+
this.args.onActiveItemChange?.(args.key);
|
|
113
|
+
}
|
|
114
|
+
const newItem = new ListItem(el, args);
|
|
115
|
+
this.#items.push(newItem);
|
|
116
|
+
this.#syncItemsOrderWithDOM();
|
|
117
|
+
if (typeof this.args.onListItemsChange === 'function') {
|
|
118
|
+
this.args.onListItemsChange(this.#items, 'add');
|
|
119
|
+
}
|
|
120
|
+
if (this.args.autoActivateMode != 'none' && this.#items.length > 1) {
|
|
121
|
+
later(() => {
|
|
122
|
+
if (this.args.autoActivateMode == 'first') {
|
|
123
|
+
this.setFirstOptionActive();
|
|
124
|
+
} else {
|
|
125
|
+
this.setSelectedOptionActive();
|
|
126
|
+
}
|
|
127
|
+
}, 1);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
unregister(el) {
|
|
131
|
+
this.#items = this.#items.filter(item => item.el !== el);
|
|
132
|
+
if (this.args.autoActivateMode == 'first' && this.#items.length >= 1) {
|
|
133
|
+
this.activateItem(this.#items[0]);
|
|
134
|
+
}
|
|
135
|
+
if (typeof this.args.onListItemsChange === 'function') {
|
|
136
|
+
this.args.onListItemsChange(this.#items, 'remove');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
at(el) {
|
|
140
|
+
return this.#items.find(item => item.el === el);
|
|
141
|
+
}
|
|
142
|
+
atKey(key) {
|
|
143
|
+
return this.#items.find(item => item.key === key);
|
|
144
|
+
}
|
|
145
|
+
updateArgs(args) {
|
|
146
|
+
this.args.selectedKeys = args.selectedKeys || [];
|
|
147
|
+
this.args.disabledKeys = args.disabledKeys || [];
|
|
148
|
+
this.args.allowEmpty = args.allowEmpty || false;
|
|
149
|
+
this.args.autoActivateMode = args.autoActivateMode || 'none';
|
|
150
|
+
for (let i = 0; i < this.#items.length; i++) {
|
|
151
|
+
const item = this.#items[i];
|
|
152
|
+
item.isSelected = this.isKeySelected(item.key);
|
|
153
|
+
item.isDisabled = this.isKeyDisabled(item.key);
|
|
154
|
+
}
|
|
155
|
+
if (args.selectionMode) {
|
|
156
|
+
this.args.selectionMode = args.selectionMode;
|
|
157
|
+
}
|
|
158
|
+
if (args.onAction) {
|
|
159
|
+
this.args.onAction = args.onAction;
|
|
160
|
+
}
|
|
161
|
+
if (args.onSelectionChange) {
|
|
162
|
+
this.args.onSelectionChange = args.onSelectionChange;
|
|
163
|
+
}
|
|
164
|
+
if (args.onListItemsChange) {
|
|
165
|
+
this.args.onListItemsChange = args.onListItemsChange;
|
|
166
|
+
}
|
|
167
|
+
if (args.onActiveItemChange) {
|
|
168
|
+
this.args.onActiveItemChange = args.onActiveItemChange;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
selectActiveItem() {
|
|
172
|
+
const item = this.#activeItem;
|
|
173
|
+
if (item) {
|
|
174
|
+
item.el.click();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
selectItem(item) {
|
|
178
|
+
if (item) {
|
|
179
|
+
if (this.args.selectionMode !== 'none') {
|
|
180
|
+
this.activateItem(item);
|
|
181
|
+
}
|
|
182
|
+
if (typeof this.args.onAction === 'function') {
|
|
183
|
+
this.args.onAction(item.key);
|
|
184
|
+
}
|
|
185
|
+
if (typeof this.args.onSelectionChange === 'function' && this.args.selectionMode !== 'none') {
|
|
186
|
+
this.args.onSelectionChange(this.#toggleSelectedItem(item));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
activateItem(item) {
|
|
191
|
+
if (item && !item.isActive) {
|
|
192
|
+
this.#clearActive();
|
|
193
|
+
item.isActive = true;
|
|
194
|
+
this.args.onActiveItemChange?.(item.key);
|
|
195
|
+
|
|
196
|
+
// Ensure the item is scrolled into view
|
|
197
|
+
requestAnimationFrame(() => {
|
|
198
|
+
item.el.scrollIntoView({
|
|
199
|
+
block: 'nearest',
|
|
200
|
+
inline: 'nearest'
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
setNextOptionActive() {
|
|
206
|
+
for (let i = this.#indexofActiveItem + 1; i < this.#items.length; i++) {
|
|
207
|
+
const item = this.#items[i];
|
|
208
|
+
if (item && !item.isDisabled && !item.isActive) {
|
|
209
|
+
this.activateItem(item);
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
setPreviousOptionActive() {
|
|
215
|
+
for (let i = this.#indexofActiveItem - 1; i >= 0; i--) {
|
|
216
|
+
const item = this.#items[i];
|
|
217
|
+
if (item && !item.isDisabled && !item.isActive) {
|
|
218
|
+
this.activateItem(item);
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
setFirstOptionActive() {
|
|
224
|
+
for (let i = 0; i < this.#items.length; i++) {
|
|
225
|
+
const item = this.#items[i];
|
|
226
|
+
if (item && !item.isDisabled) {
|
|
227
|
+
this.activateItem(item);
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
setSelectedOptionActive() {
|
|
233
|
+
let activated = false;
|
|
234
|
+
for (let i = 0; i < this.#items.length; i++) {
|
|
235
|
+
const item = this.#items[i];
|
|
236
|
+
if (item && !item.isDisabled && item.isSelected) {
|
|
237
|
+
this.activateItem(item);
|
|
238
|
+
activated = true;
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (!activated) {
|
|
243
|
+
this.setFirstOptionActive();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
setLastOptionActive() {
|
|
247
|
+
for (let i = this.#items.length - 1; i >= 0; i--) {
|
|
248
|
+
const item = this.#items[i];
|
|
249
|
+
if (item && !item.isDisabled) {
|
|
250
|
+
this.activateItem(item);
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
search(key) {
|
|
256
|
+
debounce(this, this.#clearSeaerch, 500);
|
|
257
|
+
this.searchKeys += key.toLowerCase();
|
|
258
|
+
for (let i = 0; i < this.#items.length; i++) {
|
|
259
|
+
const item = this.#items[i];
|
|
260
|
+
if (!item.isDisabled && this.searchKeys && item.textValue.trim().toLowerCase().startsWith(this.searchKeys)) {
|
|
261
|
+
this.activateItem(item);
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
isKeyDisabled(key) {
|
|
267
|
+
return this.args.disabledKeys?.includes(key) || false;
|
|
268
|
+
}
|
|
269
|
+
isKeySelected(key) {
|
|
270
|
+
return this.args.selectedKeys?.includes(key) || false;
|
|
271
|
+
}
|
|
272
|
+
get #indexofActiveItem() {
|
|
273
|
+
let item = this.#activeItem;
|
|
274
|
+
if (!item) {
|
|
275
|
+
for (let i = 0; i < this.#items.length; i++) {
|
|
276
|
+
const n = this.#items[i];
|
|
277
|
+
if (n.isSelected) {
|
|
278
|
+
item = n;
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
if (!item) {
|
|
284
|
+
return -1;
|
|
285
|
+
}
|
|
286
|
+
return this.#items.indexOf(item);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// Ensure #items is always in sync with DOM order
|
|
290
|
+
#syncItemsOrderWithDOM() {
|
|
291
|
+
if (!this.#items.length) return;
|
|
292
|
+
|
|
293
|
+
// Sort items based on their position in the DOM
|
|
294
|
+
this.#items.sort((a, b) => {
|
|
295
|
+
const position = a.el.compareDocumentPosition(b.el);
|
|
296
|
+
if (position & Node.DOCUMENT_POSITION_FOLLOWING) return -1;
|
|
297
|
+
if (position & Node.DOCUMENT_POSITION_PRECEDING) return 1;
|
|
298
|
+
return 0;
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
#toggleSelectedItem(item) {
|
|
302
|
+
let selectedKeys = [];
|
|
303
|
+
for (let i = 0; i < this.#items.length; i++) {
|
|
304
|
+
const _item = this.#items[i];
|
|
305
|
+
if (_item.isSelected) {
|
|
306
|
+
selectedKeys.push(_item.key);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
if (selectedKeys.includes(item.key) && (this.args.allowEmpty && selectedKeys.length == 1 || selectedKeys.length > 1)) {
|
|
310
|
+
const indexToRemove = selectedKeys.indexOf(item.key);
|
|
311
|
+
selectedKeys.splice(indexToRemove, 1);
|
|
312
|
+
} else {
|
|
313
|
+
if (this.args.selectionMode === 'single') {
|
|
314
|
+
selectedKeys = [item.key];
|
|
315
|
+
} else if (!selectedKeys.includes(item.key)) {
|
|
316
|
+
selectedKeys.push(item.key);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return selectedKeys;
|
|
320
|
+
}
|
|
321
|
+
get #activeItem() {
|
|
322
|
+
for (let i = 0; i < this.#items.length; i++) {
|
|
323
|
+
const item = this.#items[i];
|
|
324
|
+
if (item.isActive) {
|
|
325
|
+
return item;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
#clearSeaerch() {
|
|
330
|
+
this.searchKeys = '';
|
|
331
|
+
}
|
|
332
|
+
#clearActive() {
|
|
333
|
+
for (let i = 0; i < this.#items.length; i++) {
|
|
334
|
+
const item = this.#items[i];
|
|
335
|
+
if (item.isActive) {
|
|
336
|
+
item.isActive = false;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
setup = modifier((_el, _, args) => {
|
|
341
|
+
this.updateArgs({
|
|
342
|
+
selectionMode: args.selectionMode,
|
|
343
|
+
disabledKeys: args.disabledKeys,
|
|
344
|
+
selectedKeys: args.selectedKeys,
|
|
345
|
+
allowEmpty: args.allowEmpty,
|
|
346
|
+
autoActivateMode: args.autoActivateMode
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
setupItem = modifier((el, _, args) => {
|
|
350
|
+
let textValue = args.textValue;
|
|
351
|
+
if (typeof textValue === 'undefined' || textValue === '' || textValue === null) {
|
|
352
|
+
const labelId = el.getAttribute('aria-labelledby');
|
|
353
|
+
if (labelId) {
|
|
354
|
+
const labelElement = el.querySelector(`#${labelId}`);
|
|
355
|
+
if (labelElement) {
|
|
356
|
+
textValue = labelElement.textContent?.trim() || '';
|
|
357
|
+
}
|
|
358
|
+
} else {
|
|
359
|
+
textValue = el.textContent?.trim() || '';
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
this.register(el, {
|
|
363
|
+
key: args.key,
|
|
364
|
+
textValue: textValue || '',
|
|
365
|
+
isActive: false,
|
|
366
|
+
isDisabled: this.isKeyDisabled(args.key),
|
|
367
|
+
isSelected: this.isKeySelected(args.key)
|
|
368
|
+
});
|
|
369
|
+
const item = this.at(el);
|
|
370
|
+
if (item && typeof args.onRegister === 'function') {
|
|
371
|
+
args.onRegister(item);
|
|
372
|
+
}
|
|
373
|
+
const mouseEnter = () => {
|
|
374
|
+
this.activateItem(item);
|
|
375
|
+
};
|
|
376
|
+
const mouseLeave = () => {
|
|
377
|
+
if (item) {
|
|
378
|
+
item.isActive = false;
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
if (!args.disableEvents) {
|
|
382
|
+
el.addEventListener('mouseenter', mouseEnter);
|
|
383
|
+
el.addEventListener('mouseleave', mouseLeave);
|
|
384
|
+
el.addEventListener('focusin', mouseEnter);
|
|
385
|
+
el.addEventListener('focusout', mouseLeave);
|
|
386
|
+
}
|
|
387
|
+
return () => {
|
|
388
|
+
this.unregister(el);
|
|
389
|
+
if (!args.disableEvents) {
|
|
390
|
+
el.removeEventListener('mouseenter', mouseEnter);
|
|
391
|
+
el.removeEventListener('mouseleave', mouseLeave);
|
|
392
|
+
el.removeEventListener('focusin', mouseEnter);
|
|
393
|
+
el.removeEventListener('focusout', mouseLeave);
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
function keyAndLabelForItem(item) {
|
|
399
|
+
// Handle primitive types directly
|
|
400
|
+
if (typeof item === 'string' || typeof item === 'number') {
|
|
401
|
+
const value = item.toString();
|
|
402
|
+
return {
|
|
403
|
+
key: value,
|
|
404
|
+
label: value
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// If the item is an object, try to extract key and label using common property names
|
|
409
|
+
if (typeof item === 'object' && item !== null) {
|
|
410
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
411
|
+
const typedItem = item;
|
|
412
|
+
|
|
413
|
+
// Try to use the 'key' property first; if not available, use 'id'
|
|
414
|
+
let keyProp = typedItem.key || typedItem.id;
|
|
415
|
+
if (keyProp === undefined) {
|
|
416
|
+
keyProp = item.toString();
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// Determine the label by checking multiple possible properties
|
|
420
|
+
let labelProp = typedItem.label || typedItem.value || typedItem.name || typedItem.title;
|
|
421
|
+
if (labelProp === undefined) {
|
|
422
|
+
labelProp = item.toString();
|
|
423
|
+
}
|
|
424
|
+
return {
|
|
425
|
+
key: keyProp.toString(),
|
|
426
|
+
label: labelProp.toString()
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// Fallback if item does not match expected types
|
|
431
|
+
return {
|
|
432
|
+
key: '',
|
|
433
|
+
label: ''
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
export { ListManager as L, decorateMethodV2 as a, decorateFieldV2 as d, initializeDeferredDecorator as i, keyAndLabelForItem as k };
|
|
438
|
+
//# sourceMappingURL=listManager-D4_vozfz.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listManager-D4_vozfz.js","sources":["../../../node_modules/.pnpm/decorator-transforms@2.3.0_@babel+core@7.26.7/node_modules/decorator-transforms/dist/runtime-BPCpkOf1.js","../src/utils/listManager.ts"],"sourcesContent":["const deferred = /* @__PURE__ */ new WeakMap();\nfunction deferDecorator(proto, prop, desc) {\n let map = deferred.get(proto);\n if (!map) {\n map = /* @__PURE__ */ new Map();\n deferred.set(proto, map);\n }\n map.set(prop, desc);\n}\nfunction findDeferredDecorator(target, prop) {\n var _a;\n let cursor = target.prototype;\n while (cursor) {\n let desc = (_a = deferred.get(cursor)) == null ? void 0 : _a.get(prop);\n if (desc) {\n return desc;\n }\n cursor = cursor.prototype;\n }\n}\nfunction decorateFieldV1(target, prop, decorators, initializer) {\n return decorateFieldV2(target.prototype, prop, decorators, initializer);\n}\nfunction decorateFieldV2(prototype, prop, decorators, initializer) {\n let desc = {\n configurable: true,\n enumerable: true,\n writable: true,\n initializer: null\n };\n if (initializer) {\n desc.initializer = initializer;\n }\n for (let decorator of decorators) {\n desc = decorator(prototype, prop, desc) || desc;\n }\n if (desc.initializer === void 0) {\n Object.defineProperty(prototype, prop, desc);\n } else {\n deferDecorator(prototype, prop, desc);\n }\n}\nfunction decorateMethodV1({ prototype }, prop, decorators) {\n return decorateMethodV2(prototype, prop, decorators);\n}\nfunction decorateMethodV2(prototype, prop, decorators) {\n const origDesc = Object.getOwnPropertyDescriptor(prototype, prop);\n let desc = { ...origDesc };\n for (let decorator of decorators) {\n desc = decorator(prototype, prop, desc) || desc;\n }\n if (desc.initializer !== void 0) {\n desc.value = desc.initializer ? desc.initializer.call(prototype) : void 0;\n desc.initializer = void 0;\n }\n Object.defineProperty(prototype, prop, desc);\n}\nfunction initializeDeferredDecorator(target, prop) {\n let desc = findDeferredDecorator(target.constructor, prop);\n if (desc) {\n Object.defineProperty(target, prop, {\n enumerable: desc.enumerable,\n configurable: desc.configurable,\n writable: desc.writable,\n value: desc.initializer ? desc.initializer.call(target) : void 0\n });\n }\n}\nfunction decorateClass(target, decorators) {\n return decorators.reduce(\n (accum, decorator) => decorator(accum) || accum,\n target\n );\n}\nfunction decoratePOJO(pojo, decorated) {\n for (let [type, prop, decorators] of decorated) {\n if (type === \"field\") {\n decoratePojoField(pojo, prop, decorators);\n } else {\n decorateMethodV2(pojo, prop, decorators);\n }\n }\n return pojo;\n}\nfunction decoratePojoField(pojo, prop, decorators) {\n let desc = {\n configurable: true,\n enumerable: true,\n writable: true,\n initializer: () => {\n var _a;\n return (_a = Object.getOwnPropertyDescriptor(pojo, prop)) == null ? void 0 : _a.value;\n }\n };\n for (let decorator of decorators) {\n desc = decorator(pojo, prop, desc) || desc;\n }\n if (desc.initializer) {\n desc.value = desc.initializer.call(pojo);\n delete desc.initializer;\n }\n Object.defineProperty(pojo, prop, desc);\n}\nconst runtime = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({\n __proto__: null,\n c: decorateClass,\n f: decorateFieldV1,\n g: decorateFieldV2,\n i: initializeDeferredDecorator,\n m: decorateMethodV1,\n n: decorateMethodV2,\n p: decoratePOJO\n}, Symbol.toStringTag, { value: \"Module\" }));\nexport {\n decorateFieldV2 as a,\n decorateMethodV1 as b,\n decorateMethodV2 as c,\n decorateFieldV1 as d,\n decorateClass as e,\n decoratePOJO as f,\n initializeDeferredDecorator as i,\n runtime as r\n};\n//# sourceMappingURL=runtime-BPCpkOf1.js.map\n","/* eslint-disable ember/no-runloop */\nimport { tracked } from '@glimmer/tracking';\nimport { debounce } from '@ember/runloop';\nimport { modifier } from 'ember-modifier';\nimport { later } from '@ember/runloop';\n\ntype SelectionMode = 'none' | 'single' | 'multiple';\ntype AutoActivateMode = 'none' | 'first' | 'selected';\n\ninterface ListItemArgs {\n key: string;\n textValue?: string;\n isSelected?: boolean;\n isDisabled?: boolean;\n isActive?: boolean;\n}\n\nclass ListItem {\n el: HTMLLIElement | HTMLOptionElement;\n key: string;\n textValue: string;\n\n @tracked isSelected: boolean;\n @tracked isDisabled: boolean;\n @tracked isActive: boolean;\n\n constructor(\n el: HTMLLIElement | HTMLOptionElement,\n args: Required<ListItemArgs>\n ) {\n this.el = el;\n this.key = args.key;\n this.textValue = args.textValue;\n this.isSelected = args.isSelected;\n this.isDisabled = args.isDisabled;\n this.isActive = args.isActive;\n }\n}\n\ninterface ListManagerArgs {\n selectionMode?: SelectionMode;\n selectedKeys?: string[];\n disabledKeys?: string[];\n allowEmpty?: boolean;\n autoActivateMode?: AutoActivateMode;\n onAction?: (key: string) => void;\n onSelectionChange?: (key: string[]) => void;\n onListItemsChange?: (items: ListItem[], action: 'add' | 'remove') => void;\n onActiveItemChange?: (key?: string) => void;\n}\n\nclass ListManager {\n #items: ListItem[] = [];\n\n searchKeys: string = '';\n args: ListManagerArgs = {\n selectionMode: 'none',\n selectedKeys: [],\n disabledKeys: [],\n allowEmpty: false,\n autoActivateMode: 'none'\n };\n\n constructor(args: ListManagerArgs = {}) {\n this.updateArgs(args);\n }\n\n register(\n el: HTMLLIElement | HTMLOptionElement,\n args: Required<ListItemArgs>\n ): void {\n if (\n this.args.autoActivateMode == 'first' &&\n this.#items.length === 0 &&\n !args.isDisabled\n ) {\n args.isActive = true;\n this.args.onActiveItemChange?.(args.key);\n }\n const newItem = new ListItem(el, args);\n this.#items.push(newItem);\n this.#syncItemsOrderWithDOM();\n\n if (typeof this.args.onListItemsChange === 'function') {\n this.args.onListItemsChange(this.#items, 'add');\n }\n\n if (this.args.autoActivateMode != 'none' && this.#items.length > 1) {\n later(() => {\n if (this.args.autoActivateMode == 'first') {\n this.setFirstOptionActive();\n } else {\n this.setSelectedOptionActive();\n }\n }, 1);\n }\n }\n\n unregister(el: HTMLLIElement | HTMLOptionElement): void {\n this.#items = this.#items.filter((item) => item.el !== el);\n\n if (this.args.autoActivateMode == 'first' && this.#items.length >= 1) {\n this.activateItem(this.#items[0]);\n }\n\n if (typeof this.args.onListItemsChange === 'function') {\n this.args.onListItemsChange(this.#items, 'remove');\n }\n }\n\n at(el?: HTMLLIElement | HTMLOptionElement): ListItem | undefined {\n return this.#items.find((item) => item.el === el);\n }\n\n atKey(key: string): ListItem | undefined {\n return this.#items.find((item) => item.key === key);\n }\n\n updateArgs(args: ListManagerArgs): void {\n this.args.selectedKeys = args.selectedKeys || [];\n this.args.disabledKeys = args.disabledKeys || [];\n this.args.allowEmpty = args.allowEmpty || false;\n this.args.autoActivateMode = args.autoActivateMode || 'none';\n\n for (let i = 0; i < this.#items.length; i++) {\n const item = this.#items[i] as ListItem;\n item.isSelected = this.isKeySelected(item.key);\n item.isDisabled = this.isKeyDisabled(item.key);\n }\n\n if (args.selectionMode) {\n this.args.selectionMode = args.selectionMode;\n }\n\n if (args.onAction) {\n this.args.onAction = args.onAction;\n }\n\n if (args.onSelectionChange) {\n this.args.onSelectionChange = args.onSelectionChange;\n }\n\n if (args.onListItemsChange) {\n this.args.onListItemsChange = args.onListItemsChange;\n }\n\n if (args.onActiveItemChange) {\n this.args.onActiveItemChange = args.onActiveItemChange;\n }\n }\n\n selectActiveItem(): void {\n const item = this.#activeItem;\n if (item) {\n item.el.click();\n }\n }\n\n selectItem(item?: ListItem): void {\n if (item) {\n if (this.args.selectionMode !== 'none') {\n this.activateItem(item);\n }\n if (typeof this.args.onAction === 'function') {\n this.args.onAction(item.key);\n }\n\n if (\n typeof this.args.onSelectionChange === 'function' &&\n this.args.selectionMode !== 'none'\n ) {\n this.args.onSelectionChange(this.#toggleSelectedItem(item));\n }\n }\n }\n\n activateItem(item?: ListItem): void {\n if (item && !item.isActive) {\n this.#clearActive();\n item.isActive = true;\n this.args.onActiveItemChange?.(item.key);\n\n // Ensure the item is scrolled into view\n requestAnimationFrame(() => {\n item.el.scrollIntoView({ block: 'nearest', inline: 'nearest' });\n });\n }\n }\n\n setNextOptionActive(): void {\n for (let i = this.#indexofActiveItem + 1; i < this.#items.length; i++) {\n const item = this.#items[i];\n if (item && !item.isDisabled && !item.isActive) {\n this.activateItem(item);\n break;\n }\n }\n }\n\n setPreviousOptionActive(): void {\n for (let i = this.#indexofActiveItem - 1; i >= 0; i--) {\n const item = this.#items[i];\n if (item && !item.isDisabled && !item.isActive) {\n this.activateItem(item);\n break;\n }\n }\n }\n\n setFirstOptionActive(): void {\n for (let i = 0; i < this.#items.length; i++) {\n const item = this.#items[i];\n if (item && !item.isDisabled) {\n this.activateItem(item);\n break;\n }\n }\n }\n\n setSelectedOptionActive(): void {\n let activated = false;\n\n for (let i = 0; i < this.#items.length; i++) {\n const item = this.#items[i];\n if (item && !item.isDisabled && item.isSelected) {\n this.activateItem(item);\n activated = true;\n break;\n }\n }\n\n if (!activated) {\n this.setFirstOptionActive();\n }\n }\n\n setLastOptionActive(): void {\n for (let i = this.#items.length - 1; i >= 0; i--) {\n const item = this.#items[i];\n if (item && !item.isDisabled) {\n this.activateItem(item);\n break;\n }\n }\n }\n\n search(key: string): void {\n debounce(this, this.#clearSeaerch, 500);\n this.searchKeys += key.toLowerCase();\n\n for (let i = 0; i < this.#items.length; i++) {\n const item = this.#items[i] as ListItem;\n\n if (\n !item.isDisabled &&\n this.searchKeys &&\n item.textValue.trim().toLowerCase().startsWith(this.searchKeys)\n ) {\n this.activateItem(item);\n break;\n }\n }\n }\n\n isKeyDisabled(key: string): boolean {\n return this.args.disabledKeys?.includes(key) || false;\n }\n\n isKeySelected(key: string): boolean {\n return this.args.selectedKeys?.includes(key) || false;\n }\n\n get #indexofActiveItem(): number {\n let item = this.#activeItem;\n\n if (!item) {\n for (let i = 0; i < this.#items.length; i++) {\n const n = this.#items[i] as ListItem;\n if (n.isSelected) {\n item = n;\n break;\n }\n }\n }\n if (!item) {\n return -1;\n }\n return this.#items.indexOf(item);\n }\n\n // Ensure #items is always in sync with DOM order\n #syncItemsOrderWithDOM(): void {\n if (!this.#items.length) return;\n\n // Sort items based on their position in the DOM\n this.#items.sort((a, b) => {\n const position = a.el.compareDocumentPosition(b.el);\n if (position & Node.DOCUMENT_POSITION_FOLLOWING) return -1;\n if (position & Node.DOCUMENT_POSITION_PRECEDING) return 1;\n return 0;\n });\n }\n\n #toggleSelectedItem(item: ListItem): string[] {\n let selectedKeys: string[] = [];\n\n for (let i = 0; i < this.#items.length; i++) {\n const _item = this.#items[i] as ListItem;\n if (_item.isSelected) {\n selectedKeys.push(_item.key);\n }\n }\n\n if (\n selectedKeys.includes(item.key) &&\n ((this.args.allowEmpty && selectedKeys.length == 1) ||\n selectedKeys.length > 1)\n ) {\n const indexToRemove = selectedKeys.indexOf(item.key);\n selectedKeys.splice(indexToRemove, 1);\n } else {\n if (this.args.selectionMode === 'single') {\n selectedKeys = [item.key];\n } else if (!selectedKeys.includes(item.key)) {\n selectedKeys.push(item.key);\n }\n }\n\n return selectedKeys;\n }\n\n get #activeItem(): ListItem | undefined {\n for (let i = 0; i < this.#items.length; i++) {\n const item = this.#items[i] as ListItem;\n if (item.isActive) {\n return item;\n }\n }\n }\n\n #clearSeaerch(): void {\n this.searchKeys = '';\n }\n\n #clearActive(): void {\n for (let i = 0; i < this.#items.length; i++) {\n const item = this.#items[i] as ListItem;\n if (item.isActive) {\n item.isActive = false;\n }\n }\n }\n\n setup = modifier(\n (\n _el: HTMLUListElement | HTMLSelectElement,\n _: unknown[],\n args: ListManagerArgs\n ) => {\n this.updateArgs({\n selectionMode: args.selectionMode,\n disabledKeys: args.disabledKeys,\n selectedKeys: args.selectedKeys,\n allowEmpty: args.allowEmpty,\n autoActivateMode: args.autoActivateMode\n });\n }\n );\n\n setupItem = modifier(\n (\n el: HTMLLIElement | HTMLOptionElement,\n _: unknown[],\n args: Pick<ListItemArgs, 'key' | 'textValue'> & {\n onRegister?: (item: ListItem) => void;\n disableEvents?: boolean;\n }\n ) => {\n let textValue = args.textValue;\n if (\n typeof textValue === 'undefined' ||\n textValue === '' ||\n textValue === null\n ) {\n const labelId = el.getAttribute('aria-labelledby');\n if (labelId) {\n const labelElement = el.querySelector(`#${labelId}`);\n if (labelElement) {\n textValue = labelElement.textContent?.trim() || '';\n }\n } else {\n textValue = el.textContent?.trim() || '';\n }\n }\n\n this.register(el as HTMLLIElement, {\n key: args.key,\n textValue: textValue || '',\n isActive: false,\n isDisabled: this.isKeyDisabled(args.key),\n isSelected: this.isKeySelected(args.key)\n });\n const item = this.at(el);\n if (item && typeof args.onRegister === 'function') {\n args.onRegister(item);\n }\n\n const mouseEnter = (): void => {\n this.activateItem(item);\n };\n\n const mouseLeave = (): void => {\n if (item) {\n item.isActive = false;\n }\n };\n\n if (!args.disableEvents) {\n el.addEventListener('mouseenter', mouseEnter);\n el.addEventListener('mouseleave', mouseLeave);\n\n el.addEventListener('focusin', mouseEnter);\n el.addEventListener('focusout', mouseLeave);\n }\n\n return (): void => {\n this.unregister(el);\n\n if (!args.disableEvents) {\n el.removeEventListener('mouseenter', mouseEnter);\n el.removeEventListener('mouseleave', mouseLeave);\n\n el.removeEventListener('focusin', mouseEnter);\n el.removeEventListener('focusout', mouseLeave);\n }\n };\n }\n );\n}\n\nfunction keyAndLabelForItem(item: unknown): { key: string; label: string } {\n // Handle primitive types directly\n if (typeof item === 'string' || typeof item === 'number') {\n const value = item.toString();\n return { key: value, label: value };\n }\n\n // If the item is an object, try to extract key and label using common property names\n if (typeof item === 'object' && item !== null) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const typedItem = item as any;\n\n // Try to use the 'key' property first; if not available, use 'id'\n let keyProp = typedItem.key || typedItem.id;\n if (keyProp === undefined) {\n keyProp = item.toString();\n }\n\n // Determine the label by checking multiple possible properties\n let labelProp =\n typedItem.label || typedItem.value || typedItem.name || typedItem.title;\n if (labelProp === undefined) {\n labelProp = item.toString();\n }\n\n return { key: keyProp.toString(), label: labelProp.toString() };\n }\n\n // Fallback if item does not match expected types\n return { key: '', label: '' };\n}\n\nexport type { ListItem, ListItemArgs, SelectionMode, AutoActivateMode };\nexport { ListManager, keyAndLabelForItem };\n"],"names":["deferred","WeakMap","deferDecorator","proto","prop","desc","map","get","Map","set","findDeferredDecorator","target","_a","cursor","prototype","decorateFieldV2","decorators","initializer","configurable","enumerable","writable","decorator","Object","defineProperty","decorateMethodV2","origDesc","getOwnPropertyDescriptor","value","call","initializeDeferredDecorator","constructor","ListItem","el","key","textValue","g","tracked","i","void 0","args","isSelected","isDisabled","isActive","ListManager","searchKeys","selectionMode","selectedKeys","disabledKeys","allowEmpty","autoActivateMode","updateArgs","register","length","onActiveItemChange","newItem","push","onListItemsChange","later","setFirstOptionActive","setSelectedOptionActive","unregister","filter","item","activateItem","at","find","atKey","isKeySelected","isKeyDisabled","onAction","onSelectionChange","selectActiveItem","click","selectItem","requestAnimationFrame","scrollIntoView","block","inline","setNextOptionActive","setPreviousOptionActive","activated","setLastOptionActive","search","debounce","toLowerCase","trim","startsWith","includes","#indexofActiveItem","n","indexOf","#syncItemsOrderWithDOM","sort","a","b","position","compareDocumentPosition","Node","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","#toggleSelectedItem","_item","indexToRemove","splice","#activeItem","#clearSeaerch","#clearActive","setup","modifier","_el","_","setupItem","labelId","getAttribute","labelElement","querySelector","textContent","onRegister","mouseEnter","mouseLeave","disableEvents","addEventListener","removeEventListener","keyAndLabelForItem","toString","label","typedItem","keyProp","id","undefined","labelProp","name","title"],"mappings":";;;;AAuBA,MAAMA,QAAA,sBAGEC,OAAA,EAAA;AAER,SAASC,eACPC,KAAA,EACAC,IAAA,EACAC,IAAA,EACM;AAC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AA,GAAG,EAAE8F,OAAO,CAACH,QAAQ,EAAE;AAAEC,MAAAA,KAAK,EAAEK,SAAS,CAACN,QAAQ;KAAI;AACjE;;AAEA;EACA,OAAO;AAAE3F,IAAAA,GAAG,EAAE,EAAE;AAAE4F,IAAAA,KAAK,EAAE;GAAI;AAC/B;;;;","x_google_ignoreList":[0]}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
|
+
import { hash } from '@ember/helper';
|
|
3
|
+
import { on } from '@ember/modifier';
|
|
4
|
+
import { useStyles } from '@frontile/theme';
|
|
5
|
+
import { d as decorateFieldV2, i as initializeDeferredDecorator, a as decorateMethodV2, L as ListManager, k as keyAndLabelForItem } from './listManager-D4_vozfz.js';
|
|
2
6
|
import { tracked } from '@glimmer/tracking';
|
|
3
7
|
import { action } from '@ember/object';
|
|
4
8
|
import { assert } from '@ember/debug';
|
|
5
|
-
import { on } from '@ember/modifier';
|
|
6
|
-
import { useStyles } from '@frontile/theme';
|
|
7
9
|
import { Divider } from '@frontile/utilities';
|
|
8
10
|
import { guidFor } from '@ember/object/internals';
|
|
9
11
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
10
12
|
import { setComponentTemplate } from '@ember/component';
|
|
11
13
|
import templateOnly from '@ember/component/template-only';
|
|
12
|
-
import {
|
|
14
|
+
import { modifier } from 'ember-modifier';
|
|
13
15
|
|
|
14
16
|
class ListboxItem extends Component {
|
|
15
17
|
labelId = guidFor(this);
|
|
@@ -100,5 +102,102 @@ const CheckIcon = setComponentTemplate(precompileTemplate("\n <svg xmlns=\"http
|
|
|
100
102
|
strictMode: true
|
|
101
103
|
}), templateOnly());
|
|
102
104
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
const isInputElement = target => {
|
|
106
|
+
return target instanceof HTMLInputElement;
|
|
107
|
+
};
|
|
108
|
+
const isUndefined = a => typeof a === 'undefined';
|
|
109
|
+
class Listbox extends Component {
|
|
110
|
+
listManager = new ListManager({
|
|
111
|
+
selectionMode: this.args.selectionMode,
|
|
112
|
+
selectedKeys: this.args.selectedKeys,
|
|
113
|
+
disabledKeys: this.args.disabledKeys,
|
|
114
|
+
allowEmpty: this.args.allowEmpty,
|
|
115
|
+
onSelectionChange: this.args.onSelectionChange,
|
|
116
|
+
onAction: this.args.onAction,
|
|
117
|
+
onActiveItemChange: this.args.onActiveItemChange,
|
|
118
|
+
autoActivateMode: isUndefined(this.args.autoActivateMode) ? 'first' : this.args.autoActivateMode
|
|
119
|
+
});
|
|
120
|
+
handleKeyPress = event => {
|
|
121
|
+
if (isInputElement(event.target)) {
|
|
122
|
+
if (event.key === 'Enter') {
|
|
123
|
+
this.listManager.selectActiveItem();
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
if (['Enter', ' ', 'Space'].includes(event.key) && this.listManager.searchKeys == '') {
|
|
128
|
+
this.listManager.selectActiveItem();
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
event.stopPropagation();
|
|
131
|
+
return;
|
|
132
|
+
} else if (event.key.length === 1) {
|
|
133
|
+
this.listManager.search(event.key);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
handleKeyDown = event => {
|
|
139
|
+
if (['ArrowUp', 'ArrowDown', 'PageUp', 'PageDown', 'Home', 'End'].includes(event.key)) {
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
if (event.key === 'ArrowDown') {
|
|
142
|
+
this.listManager.setNextOptionActive();
|
|
143
|
+
} else if (event.key === 'ArrowUp') {
|
|
144
|
+
this.listManager.setPreviousOptionActive();
|
|
145
|
+
} else if (event.key === 'Home' || event.key === 'PageUp') {
|
|
146
|
+
this.listManager.setFirstOptionActive();
|
|
147
|
+
} else if (event.key === 'End' || event.key === 'PageDown') {
|
|
148
|
+
this.listManager.setLastOptionActive();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
onKeyPress = event => {
|
|
153
|
+
if (this.args.isKeyboardEventsEnabled) {
|
|
154
|
+
this.handleKeyPress(event);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
onKeyDown = event => {
|
|
158
|
+
if (this.args.isKeyboardEventsEnabled) {
|
|
159
|
+
this.handleKeyDown(event);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
setupEvents = modifier((_el, _, args) => {
|
|
163
|
+
if (args.elementToAddKeyboardEvents) {
|
|
164
|
+
args.elementToAddKeyboardEvents.addEventListener('keydown', this.handleKeyDown);
|
|
165
|
+
args.elementToAddKeyboardEvents.addEventListener('keypress', this.handleKeyPress);
|
|
166
|
+
}
|
|
167
|
+
return () => {
|
|
168
|
+
if (args.elementToAddKeyboardEvents) {
|
|
169
|
+
args.elementToAddKeyboardEvents.removeEventListener('keydown', this.handleKeyDown);
|
|
170
|
+
args.elementToAddKeyboardEvents.removeEventListener('keypress', this.handleKeyPress);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
get classNames() {
|
|
175
|
+
const {
|
|
176
|
+
listbox
|
|
177
|
+
} = useStyles();
|
|
178
|
+
return listbox({
|
|
179
|
+
class: this.args.class
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
get role() {
|
|
183
|
+
if (this.args.type === 'menu') {
|
|
184
|
+
return this.args.type;
|
|
185
|
+
}
|
|
186
|
+
return 'listbox';
|
|
187
|
+
}
|
|
188
|
+
static {
|
|
189
|
+
setComponentTemplate(precompileTemplate("\n <ul tabindex=\"0\" role={{this.role}} {{this.listManager.setup selectedKeys=@selectedKeys disabledKeys=@disabledKeys selectionMode=@selectionMode allowEmpty=@allowEmpty autoActivateMode=(if (isUndefined @autoActivateMode) \"first\" @autoActivateMode)}} {{on \"keypress\" this.onKeyPress}} {{on \"keydown\" this.onKeyDown}} {{this.setupEvents elementToAddKeyboardEvents=@elementToAddKeyboardEvents}} data-test-id=\"listbox\" data-component=\"listbox\" class={{this.classNames}} ...attributes>\n {{#each @items as |item|}}\n {{#let (keyAndLabelForItem item) as |keyLabel|}}\n {{#if (has-block \"item\")}}\n {{yield (hash item=item key=keyLabel.key label=keyLabel.label Item=(component ListboxItem manager=this.listManager appearance=@appearance intent=@intent type=this.role key=keyLabel.key)) to=\"item\"}}\n {{else}}\n <ListboxItem @manager={{this.listManager}} @key={{keyLabel.key}} @appearance={{@appearance}} @intent={{@intent}} @type={{this.role}}>\n {{keyLabel.label}}\n </ListboxItem>\n {{/if}}\n {{/let}}\n {{/each}}\n\n {{yield (hash Item=(component ListboxItem manager=this.listManager appearance=@appearance intent=@intent type=this.role)) to=\"default\"}}\n </ul>\n ", {
|
|
190
|
+
strictMode: true,
|
|
191
|
+
scope: () => ({
|
|
192
|
+
isUndefined,
|
|
193
|
+
on,
|
|
194
|
+
keyAndLabelForItem,
|
|
195
|
+
hash,
|
|
196
|
+
ListboxItem
|
|
197
|
+
})
|
|
198
|
+
}), this);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export { Listbox as L, ListboxItem as a };
|
|
203
|
+
//# sourceMappingURL=listbox-DPCqpk4Q.js.map
|