@smilodon/core 1.0.9 → 1.0.10
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/index.cjs +26 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -22
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.umd.js +26 -22
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2264,24 +2264,33 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2264
2264
|
});
|
|
2265
2265
|
this._optionsContainer.appendChild(header);
|
|
2266
2266
|
group.options.forEach(item => {
|
|
2267
|
-
|
|
2267
|
+
// Find original index for correct ID generation and selection
|
|
2268
|
+
const index = this._state.loadedItems.indexOf(item);
|
|
2269
|
+
if (index !== -1) {
|
|
2270
|
+
this._renderSingleOption(item, index, getValue, getLabel);
|
|
2271
|
+
}
|
|
2268
2272
|
});
|
|
2269
2273
|
});
|
|
2270
2274
|
}
|
|
2271
2275
|
else {
|
|
2272
2276
|
// Normal rendering (flat list or filtered)
|
|
2273
|
-
|
|
2274
|
-
|
|
2277
|
+
let hasRenderedItems = false;
|
|
2278
|
+
this._state.loadedItems.forEach((item, index) => {
|
|
2279
|
+
// Apply filter if query exists
|
|
2280
|
+
if (query) {
|
|
2275
2281
|
try {
|
|
2276
2282
|
const label = String(getLabel(item)).toLowerCase();
|
|
2277
|
-
|
|
2283
|
+
if (!label.includes(query))
|
|
2284
|
+
return;
|
|
2278
2285
|
}
|
|
2279
2286
|
catch (e) {
|
|
2280
|
-
return
|
|
2287
|
+
return;
|
|
2281
2288
|
}
|
|
2282
|
-
}
|
|
2283
|
-
|
|
2284
|
-
|
|
2289
|
+
}
|
|
2290
|
+
hasRenderedItems = true;
|
|
2291
|
+
this._renderSingleOption(item, index, getValue, getLabel);
|
|
2292
|
+
});
|
|
2293
|
+
if (!hasRenderedItems && !this._state.isBusy) {
|
|
2285
2294
|
const empty = document.createElement('div');
|
|
2286
2295
|
empty.className = 'empty-state';
|
|
2287
2296
|
if (query) {
|
|
@@ -2292,11 +2301,6 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2292
2301
|
}
|
|
2293
2302
|
this._optionsContainer.appendChild(empty);
|
|
2294
2303
|
}
|
|
2295
|
-
else {
|
|
2296
|
-
itemsToRender.forEach((item) => {
|
|
2297
|
-
this._renderSingleOption(item, getValue, getLabel);
|
|
2298
|
-
});
|
|
2299
|
-
}
|
|
2300
2304
|
}
|
|
2301
2305
|
// Append Busy Indicator if busy
|
|
2302
2306
|
if (this._state.isBusy && this._config.busyBucket.enabled) {
|
|
@@ -2319,26 +2323,26 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2319
2323
|
this._addLoadMoreTrigger();
|
|
2320
2324
|
}
|
|
2321
2325
|
}
|
|
2322
|
-
_renderSingleOption(item, getValue, getLabel) {
|
|
2326
|
+
_renderSingleOption(item, index, getValue, getLabel) {
|
|
2323
2327
|
const option = document.createElement('div');
|
|
2324
2328
|
option.className = 'option';
|
|
2329
|
+
option.id = `${this._uniqueId}-option-${index}`;
|
|
2325
2330
|
const value = getValue(item);
|
|
2326
2331
|
const label = getLabel(item);
|
|
2327
2332
|
option.textContent = label;
|
|
2328
2333
|
option.dataset.value = String(value);
|
|
2334
|
+
option.dataset.index = String(index); // Also useful for debugging/selectors
|
|
2329
2335
|
// Check if selected using selectedItems map
|
|
2330
|
-
const isSelected =
|
|
2331
|
-
const selectedValue = getValue(selectedItem);
|
|
2332
|
-
return selectedValue === value;
|
|
2333
|
-
});
|
|
2336
|
+
const isSelected = this._state.selectedIndices.has(index);
|
|
2334
2337
|
if (isSelected) {
|
|
2335
2338
|
option.classList.add('selected');
|
|
2339
|
+
option.setAttribute('aria-selected', 'true');
|
|
2340
|
+
}
|
|
2341
|
+
else {
|
|
2342
|
+
option.setAttribute('aria-selected', 'false');
|
|
2336
2343
|
}
|
|
2337
2344
|
option.addEventListener('click', () => {
|
|
2338
|
-
|
|
2339
|
-
if (index !== -1) {
|
|
2340
|
-
this._selectOption(index);
|
|
2341
|
-
}
|
|
2345
|
+
this._selectOption(index);
|
|
2342
2346
|
});
|
|
2343
2347
|
this._optionsContainer.appendChild(option);
|
|
2344
2348
|
}
|