@smilodon/core 1.13.0 → 1.18.0
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/README.md +47 -4
- package/dist/index.cjs +209 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +209 -30
- 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 +209 -30
- 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/dist/types/src/components/enhanced-select.d.ts +14 -1
- package/dist/types/src/config/global-config.d.ts +4 -0
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/types.d.ts +10 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,9 +12,11 @@
|
|
|
12
12
|
|
|
13
13
|
> **Verification status:** `EnhancedSelect`'s public `virtualize` setting chunks large-list rendering but does not bound the final option DOM. Viewport-windowed rendering remains behind a private test seam and is not production-activated. ARIA and keyboard behaviors have automated coverage in progress; WCAG conformance and manual assistive-technology review have not been certified. See [known limitations](../../docs/KNOWN-LIMITATIONS.md#viewport-virtualization-status) and the [Phase 4 certification record](../../docs/architecture/PHASE-4-CERTIFICATION.md).
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
> **Issue #100:** `multiSelectDisplay.scrollToLatestChip` is available in `@smilodon/core@1.17.0`. See [Multi-Select Display Modes](#multi-select-display-modes) and the [release verification](../../docs/releases/WEB-1.17.0-REGISTRY-VERIFICATION.json).
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
## Custom busy bucket (Core 1.13.0)
|
|
18
|
+
|
|
19
|
+
Introduced in `@smilodon/core@1.13.0` (Issue #90), the busy bucket keeps request state in Core and lets the host customize its presentation. Use the native slots with the Web Component or Vanilla API:
|
|
18
20
|
|
|
19
21
|
```html
|
|
20
22
|
<enhanced-select>
|
|
@@ -100,6 +102,20 @@ select.startDataLoading()
|
|
|
100
102
|
|
|
101
103
|
For a paginated response, use `status: 'succeeded'` with `hasMore: true` and the next cursor when cursor pagination is configured. Use `status: 'exhausted'` with `hasMore: false` when the server reports end-of-data. On cancellation, abort the host request and do not complete it as a success. A stale completion result is not a signal to retry the old request.
|
|
102
104
|
|
|
105
|
+
When an exhausted response contains no items, Core renders the terminal no-results message automatically after the accepted snapshot finishes projection. `completeDataRequest()` returning `accepted` only means the response passed coordinator validation; it does not mean the DOM has settled. Observe `dataProjection` and wait for `status: 'complete'` before reading projected DOM. A remote search uses its current query in the no-results message; an exhausted empty query displays “No options available.”
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
select.completeDataRequest({
|
|
109
|
+
requestId: request.requestId,
|
|
110
|
+
queryGeneration: request.queryGeneration,
|
|
111
|
+
status: 'exhausted',
|
|
112
|
+
items: [],
|
|
113
|
+
hasMore: false,
|
|
114
|
+
})
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
An empty page with `status: 'empty'`, `hasMore: true`, and `advance: 'next'` is nonterminal and does not mean the search has no matches. It advances pagination; only an exhausted response establishes terminal absence of results.
|
|
118
|
+
|
|
103
119
|
## 📖 Documentation
|
|
104
120
|
|
|
105
121
|
**Live documentation & interactive examples:** [navidrezadoost.github.io/Smilodon](https://navidrezadoost.github.io/Smilodon/)
|
|
@@ -199,7 +215,30 @@ The default chevron remains in place unless a light-DOM child is assigned to the
|
|
|
199
215
|
</enhanced-select>
|
|
200
216
|
```
|
|
201
217
|
|
|
202
|
-
The custom node is decorative and Core keeps ownership of the arrow click behavior. The built-in arrow rotates with the popup; a custom node does not rotate unless the consumer styles it using the host's `data-open="true"` state.
|
|
218
|
+
The custom node is decorative and Core keeps ownership of the arrow click behavior. The built-in arrow rotates with the popup; a custom node does not rotate unless the consumer styles it using the host's `data-open="true"` state. Set the public `--select-arrow-hover-bg` token on the host to control the arrow container's hover background for either the built-in or a custom slotted arrow. For custom arrows, the background remains transparent when the token is unset:
|
|
219
|
+
|
|
220
|
+
```css
|
|
221
|
+
enhanced-select {
|
|
222
|
+
--select-arrow-hover-bg: #eef2ff;
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
This token changes the container background; it does not change the assigned icon's color or geometry. This correction is included in Core 1.18.0 (Issue #104).
|
|
227
|
+
|
|
228
|
+
### Custom empty-state content (unreleased)
|
|
229
|
+
|
|
230
|
+
Core keeps the built-in no-options/no-results message as the slot fallback. Assign a light-DOM child to `empty-state` to render custom text, markup, or an icon while the result set is terminally empty:
|
|
231
|
+
|
|
232
|
+
```html
|
|
233
|
+
<enhanced-select id="products" searchable>
|
|
234
|
+
<div slot="empty-state" role="status">
|
|
235
|
+
<svg aria-hidden="true" viewBox="0 0 24 24"><!-- decorative icon --></svg>
|
|
236
|
+
<span>No matching products. Try a different search.</span>
|
|
237
|
+
</div>
|
|
238
|
+
</enhanced-select>
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
`emptyStateChange` fires when the effective context changes. Its detail is `{ context: { query, reason } }`, or `{ context: null }` when the terminal empty state clears. `reason` is `no-options` for an empty option collection and `no-results` when a non-empty collection has no matches for the current query. `getEmptyStateContext()` returns the current detached, readonly snapshot or `null`. The slot is presentation-only: Core continues to own result state, selection, and accessibility synchronization. Provide suitable semantics for custom content (for example, `role="status"` for a concise announcement) and avoid duplicating announcements already made by the host application.
|
|
203
242
|
|
|
204
243
|
### Framework Usage
|
|
205
244
|
|
|
@@ -628,11 +667,15 @@ Control badge scrolling behavior in multi-select mode with `multiSelectDisplay`
|
|
|
628
667
|
maxHeight: '160px', // used by vertical / horizontal modes
|
|
629
668
|
overflowX: 'hidden',
|
|
630
669
|
overflowY: 'hidden',
|
|
631
|
-
dragScroll: true
|
|
670
|
+
dragScroll: true, // Enable drag-to-scroll (horizontal mode)
|
|
671
|
+
scrollToLatestChip: false, // Opt in to revealing newly selected chips
|
|
672
|
+
scrollToLatestChipBehavior: 'smooth' // 'auto' | 'smooth'
|
|
632
673
|
}
|
|
633
674
|
}
|
|
634
675
|
```
|
|
635
676
|
|
|
677
|
+
**Auto-scroll newly selected chips:** In `horizontal` mode, enable `scrollToLatestChip: true` to reveal a newly selected chip without scrolling the option list. The default is `false`. The viewport is not repositioned when an item is removed, the data is reloaded, or the component rerenders with unchanged selections. The default behavior is smooth (respects reduced motion); set `scrollToLatestChipBehavior: 'auto'` for instant movement. The setting is available through the shared Core `multiSelectDisplay` configuration in web adapters.
|
|
678
|
+
|
|
636
679
|
**Display Modes:**
|
|
637
680
|
- **`wrap`** (default) - Badges wrap naturally and the input shell grows with them; no internal chip scrollbar by default
|
|
638
681
|
- **`horizontal`** - Single row, stable trigger height, horizontal scroll, drag-to-scroll enabled, and action-area spacing reserved automatically
|
package/dist/index.cjs
CHANGED
|
@@ -2107,6 +2107,8 @@ const defaultConfig = {
|
|
|
2107
2107
|
overflowX: 'hidden',
|
|
2108
2108
|
overflowY: 'auto',
|
|
2109
2109
|
dragScroll: true,
|
|
2110
|
+
scrollToLatestChip: false,
|
|
2111
|
+
scrollToLatestChipBehavior: 'smooth',
|
|
2110
2112
|
},
|
|
2111
2113
|
scrollToSelected: {
|
|
2112
2114
|
enabled: true,
|
|
@@ -2972,23 +2974,23 @@ class SelectOption extends HTMLElement {
|
|
|
2972
2974
|
}
|
|
2973
2975
|
}
|
|
2974
2976
|
_attachEventListeners() {
|
|
2975
|
-
//
|
|
2977
|
+
// One delegated handler survives all SelectOption re-renders. In
|
|
2978
|
+
// particular, SVG descendants of the remove icon must remove the option,
|
|
2979
|
+
// not accidentally activate the surrounding option.
|
|
2976
2980
|
this._container.addEventListener('click', (e) => {
|
|
2977
|
-
|
|
2978
|
-
if (
|
|
2981
|
+
const target = e.target;
|
|
2982
|
+
if (this._removeButton
|
|
2983
|
+
&& target instanceof Node
|
|
2984
|
+
&& this._removeButton.contains(target)) {
|
|
2985
|
+
e.preventDefault();
|
|
2986
|
+
e.stopPropagation();
|
|
2987
|
+
this._handleRemove();
|
|
2979
2988
|
return;
|
|
2980
2989
|
}
|
|
2981
2990
|
if (!this._isDisabledSelectionBlocked()) {
|
|
2982
2991
|
this._handleSelect();
|
|
2983
2992
|
}
|
|
2984
2993
|
});
|
|
2985
|
-
// Remove button handler
|
|
2986
|
-
if (this._removeButton) {
|
|
2987
|
-
this._removeButton.addEventListener('click', (e) => {
|
|
2988
|
-
e.stopPropagation();
|
|
2989
|
-
this._handleRemove();
|
|
2990
|
-
});
|
|
2991
|
-
}
|
|
2992
2994
|
// Keyboard handler
|
|
2993
2995
|
this.addEventListener('keydown', (e) => {
|
|
2994
2996
|
if (this._isDisabledSelectionBlocked())
|
|
@@ -3051,7 +3053,6 @@ class SelectOption extends HTMLElement {
|
|
|
3051
3053
|
updateConfig(updates) {
|
|
3052
3054
|
this._config = { ...this._config, ...updates };
|
|
3053
3055
|
this._render();
|
|
3054
|
-
this._attachEventListeners();
|
|
3055
3056
|
}
|
|
3056
3057
|
/**
|
|
3057
3058
|
* Get current configuration
|
|
@@ -4066,6 +4067,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4066
4067
|
intendedRenderKeys: [],
|
|
4067
4068
|
filteredIndexByKey: new Map(),
|
|
4068
4069
|
};
|
|
4070
|
+
this._emptyStateContext = null;
|
|
4069
4071
|
// Null keeps the public/default renderer on its legacy full path. This
|
|
4070
4072
|
// private state is only used by guarded virtualization integration.
|
|
4071
4073
|
this._guardedVirtualWindow = null;
|
|
@@ -4122,6 +4124,10 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4122
4124
|
this._pendingFirstRenderMark = false;
|
|
4123
4125
|
this._pendingSearchRenderMark = false;
|
|
4124
4126
|
this._rangeAnchorIndex = null;
|
|
4127
|
+
/** Chip identity is tracked independently of dropdown option positions. */
|
|
4128
|
+
this._lastRenderedChipKeys = null;
|
|
4129
|
+
this._latestChipScrollGeneration = 0;
|
|
4130
|
+
this._latestChipScrollFrame = null;
|
|
4125
4131
|
this._customOptionBoundElements = new WeakSet();
|
|
4126
4132
|
this._customOptionManagedActiveClasses = new WeakMap();
|
|
4127
4133
|
this._customOptionNormalizedIds = new WeakMap();
|
|
@@ -4312,6 +4318,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4312
4318
|
this._syncListboxAccessibility();
|
|
4313
4319
|
}
|
|
4314
4320
|
disconnectedCallback() {
|
|
4321
|
+
this._cancelLatestChipScroll();
|
|
4315
4322
|
this._cancelBusyPresentation();
|
|
4316
4323
|
if (this._dataRequestCoordinator) {
|
|
4317
4324
|
const actions = this._dataRequestCoordinator.disconnect();
|
|
@@ -5529,7 +5536,9 @@ class EnhancedSelect extends HTMLElement {
|
|
|
5529
5536
|
`;
|
|
5530
5537
|
const slot = container.querySelector('slot[name="arrow"]');
|
|
5531
5538
|
slot?.addEventListener('slotchange', () => {
|
|
5532
|
-
|
|
5539
|
+
// Do not flatten: flattening can expose the built-in SVG fallback
|
|
5540
|
+
// as an assigned element after the last custom arrow is removed.
|
|
5541
|
+
if (slot.assignedElements().length > 0) {
|
|
5533
5542
|
this.setAttribute('data-custom-arrow', 'true');
|
|
5534
5543
|
}
|
|
5535
5544
|
else {
|
|
@@ -6258,7 +6267,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
6258
6267
|
}
|
|
6259
6268
|
|
|
6260
6269
|
:host([data-custom-arrow="true"]) .dropdown-arrow-container:hover {
|
|
6261
|
-
background-color: transparent;
|
|
6270
|
+
background-color: var(--select-arrow-hover-bg, transparent);
|
|
6262
6271
|
}
|
|
6263
6272
|
|
|
6264
6273
|
.dropdown-arrow {
|
|
@@ -7904,6 +7913,12 @@ class EnhancedSelect extends HTMLElement {
|
|
|
7904
7913
|
: delta >= 0
|
|
7905
7914
|
? -1
|
|
7906
7915
|
: selectableIndices.length;
|
|
7916
|
+
// The final selectable option is the keyboard pagination boundary.
|
|
7917
|
+
// Keep the active option stable while the coordinator requests more data.
|
|
7918
|
+
if (delta === 1
|
|
7919
|
+
&& currentPosition === selectableIndices.length - 1
|
|
7920
|
+
&& this._requestKeyboardLoadMore())
|
|
7921
|
+
return;
|
|
7907
7922
|
const nextPosition = Math.max(0, Math.min(selectableIndices.length - 1, basePosition + delta));
|
|
7908
7923
|
const next = selectableIndices[nextPosition];
|
|
7909
7924
|
this._setActive(next);
|
|
@@ -7916,6 +7931,33 @@ class EnhancedSelect extends HTMLElement {
|
|
|
7916
7931
|
this._selectRange(anchorIndex, next, { clear: !opts?.toggleKey });
|
|
7917
7932
|
}
|
|
7918
7933
|
}
|
|
7934
|
+
/** Return true only when boundary navigation is held for an in-flight/new page. */
|
|
7935
|
+
_requestKeyboardLoadMore() {
|
|
7936
|
+
if (!this._state.isOpen
|
|
7937
|
+
|| !this._config.infiniteScroll.enabled
|
|
7938
|
+
|| this._dataLoadingConfig.protocol !== 'acknowledged'
|
|
7939
|
+
|| !this._dataRequestCoordinator
|
|
7940
|
+
|| !this._acknowledgedReady)
|
|
7941
|
+
return false;
|
|
7942
|
+
if (this._acknowledgedProjectionPending || this._acknowledgedProjectionSettling)
|
|
7943
|
+
return true;
|
|
7944
|
+
const snapshot = this._dataRequestCoordinator.getSnapshot();
|
|
7945
|
+
if (!snapshot.connected)
|
|
7946
|
+
return false;
|
|
7947
|
+
if (snapshot.busy)
|
|
7948
|
+
return true;
|
|
7949
|
+
if (!snapshot.hasMore
|
|
7950
|
+
|| snapshot.error !== null
|
|
7951
|
+
|| snapshot.resourceLimit !== null
|
|
7952
|
+
|| (snapshot.status !== 'succeeded' && snapshot.status !== 'empty'))
|
|
7953
|
+
return false;
|
|
7954
|
+
// Delegate identity, pagination, and in-flight protection to the coordinator.
|
|
7955
|
+
const actions = this._dataRequestCoordinator.requestLoadMore('manual');
|
|
7956
|
+
if (actions.length === 0)
|
|
7957
|
+
return false;
|
|
7958
|
+
this._dispatchAcknowledgedActions(actions);
|
|
7959
|
+
return true;
|
|
7960
|
+
}
|
|
7919
7961
|
_setActive(index, reason = 'keyboard') {
|
|
7920
7962
|
this._ensureRegistryCurrent();
|
|
7921
7963
|
const record = this._getRecordByIndex(index);
|
|
@@ -8235,6 +8277,19 @@ class EnhancedSelect extends HTMLElement {
|
|
|
8235
8277
|
_updateInputDisplay() {
|
|
8236
8278
|
const selectedEntries = this._getSelectedEntries();
|
|
8237
8279
|
const selectedItems = selectedEntries.map(({ item }) => item);
|
|
8280
|
+
const nextKeys = new Set(selectedEntries.map(({ key }) => key));
|
|
8281
|
+
const previousKeys = this._lastRenderedChipKeys;
|
|
8282
|
+
let newlyAddedKey;
|
|
8283
|
+
if (previousKeys) {
|
|
8284
|
+
for (const key of nextKeys) {
|
|
8285
|
+
if (!previousKeys.has(key))
|
|
8286
|
+
newlyAddedKey = key;
|
|
8287
|
+
}
|
|
8288
|
+
}
|
|
8289
|
+
this._lastRenderedChipKeys = nextKeys;
|
|
8290
|
+
const previousChipScrollLeft = this._inputContent.scrollLeft;
|
|
8291
|
+
// Only a newly added selected key can initiate auto-scroll.
|
|
8292
|
+
this._cancelLatestChipScroll();
|
|
8238
8293
|
const getLabel = this._config.serverSide.getLabelFromItem || ((item) => item?.label ?? String(item));
|
|
8239
8294
|
if (selectedItems.length === 0) {
|
|
8240
8295
|
this._input.value = '';
|
|
@@ -8310,8 +8365,87 @@ class EnhancedSelect extends HTMLElement {
|
|
|
8310
8365
|
if (this._acknowledgedPendingSearchQuery !== null) {
|
|
8311
8366
|
this._input.value = this._acknowledgedPendingSearchQuery;
|
|
8312
8367
|
}
|
|
8368
|
+
// Recreating the chip DOM must not reset manual scrolling. In particular,
|
|
8369
|
+
// remove/clear, config rerenders, and item refreshes are not scroll intents.
|
|
8370
|
+
if (this._config.selection.mode === 'multi') {
|
|
8371
|
+
this._inputContent.scrollLeft = previousChipScrollLeft;
|
|
8372
|
+
if (newlyAddedKey !== undefined)
|
|
8373
|
+
this._scheduleLatestChipScroll(newlyAddedKey);
|
|
8374
|
+
}
|
|
8313
8375
|
this._syncClearControlState();
|
|
8314
8376
|
}
|
|
8377
|
+
_cancelLatestChipScroll() {
|
|
8378
|
+
this._latestChipScrollGeneration += 1;
|
|
8379
|
+
if (this._latestChipScrollFrame !== null) {
|
|
8380
|
+
cancelAnimationFrame(this._latestChipScrollFrame);
|
|
8381
|
+
this._latestChipScrollFrame = null;
|
|
8382
|
+
}
|
|
8383
|
+
}
|
|
8384
|
+
_scheduleLatestChipScroll(key) {
|
|
8385
|
+
if (!this.isConnected
|
|
8386
|
+
|| this._config.selection.mode !== 'multi'
|
|
8387
|
+
|| this._config.multiSelectDisplay.mode !== 'horizontal'
|
|
8388
|
+
|| this._config.multiSelectDisplay.scrollToLatestChip !== true
|
|
8389
|
+
|| this._config.multiSelectDisplay.overflowX === 'hidden')
|
|
8390
|
+
return;
|
|
8391
|
+
const generation = this._latestChipScrollGeneration;
|
|
8392
|
+
this._latestChipScrollFrame = requestAnimationFrame(() => {
|
|
8393
|
+
this._latestChipScrollFrame = null;
|
|
8394
|
+
if (generation !== this._latestChipScrollGeneration
|
|
8395
|
+
|| !this.isConnected
|
|
8396
|
+
|| this._multiScrollDrag.active
|
|
8397
|
+
|| this._config.selection.mode !== 'multi'
|
|
8398
|
+
|| this._config.multiSelectDisplay.mode !== 'horizontal'
|
|
8399
|
+
|| this._config.multiSelectDisplay.scrollToLatestChip !== true)
|
|
8400
|
+
return;
|
|
8401
|
+
// Match the canonical selected-key sequence, not option indices:
|
|
8402
|
+
// selected items may be reordered or detached from the loaded page.
|
|
8403
|
+
const entries = this._getSelectedEntries();
|
|
8404
|
+
const index = entries.findIndex((entry) => entry.key === key);
|
|
8405
|
+
if (index < 0)
|
|
8406
|
+
return;
|
|
8407
|
+
const chip = this._inputContent.querySelectorAll('.selection-badge')[index];
|
|
8408
|
+
if (!chip)
|
|
8409
|
+
return;
|
|
8410
|
+
const hostBounds = this._inputContent.getBoundingClientRect();
|
|
8411
|
+
const chipBounds = chip.getBoundingClientRect();
|
|
8412
|
+
const leftEdge = hostBounds.left + this._inputContent.clientLeft;
|
|
8413
|
+
const rightEdge = leftEdge + this._inputContent.clientWidth;
|
|
8414
|
+
let delta;
|
|
8415
|
+
if (chip.parentElement === this._inputContent && chip.offsetWidth > 0) {
|
|
8416
|
+
// getBoundingClientRect() includes the chip's entry animation transform.
|
|
8417
|
+
// Use layout dimensions so the scroll target remains correct while the
|
|
8418
|
+
// chip scales into its final size. In RTL layouts, offsetLeft and
|
|
8419
|
+
// scrollLeft are both negative relative to the inline-start origin, so
|
|
8420
|
+
// the same subtraction maps the chip into the viewport's coordinates.
|
|
8421
|
+
const chipLeft = chip.offsetLeft - this._inputContent.scrollLeft;
|
|
8422
|
+
const chipRight = chipLeft + chip.offsetWidth;
|
|
8423
|
+
delta = chipRight > this._inputContent.clientWidth
|
|
8424
|
+
? chipRight - this._inputContent.clientWidth
|
|
8425
|
+
: chipLeft < 0
|
|
8426
|
+
? chipLeft
|
|
8427
|
+
: 0;
|
|
8428
|
+
}
|
|
8429
|
+
else {
|
|
8430
|
+
// DOM test environments without layout use the measurable rectangle.
|
|
8431
|
+
delta = chipBounds.right > rightEdge
|
|
8432
|
+
? chipBounds.right - rightEdge
|
|
8433
|
+
: chipBounds.left < leftEdge
|
|
8434
|
+
? chipBounds.left - leftEdge
|
|
8435
|
+
: 0;
|
|
8436
|
+
}
|
|
8437
|
+
if (Math.abs(delta) < 0.5)
|
|
8438
|
+
return;
|
|
8439
|
+
const reducedMotion = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false;
|
|
8440
|
+
const behavior = reducedMotion ? 'auto' : (this._config.multiSelectDisplay.scrollToLatestChipBehavior ?? 'smooth');
|
|
8441
|
+
if (typeof this._inputContent.scrollBy === 'function') {
|
|
8442
|
+
this._inputContent.scrollBy({ left: delta, behavior });
|
|
8443
|
+
}
|
|
8444
|
+
else {
|
|
8445
|
+
this._inputContent.scrollLeft += delta;
|
|
8446
|
+
}
|
|
8447
|
+
});
|
|
8448
|
+
}
|
|
8315
8449
|
_isActivelyEditingSearchInput() {
|
|
8316
8450
|
return this._config.searchable === true
|
|
8317
8451
|
&& this._state.isOpen
|
|
@@ -8577,12 +8711,13 @@ class EnhancedSelect extends HTMLElement {
|
|
|
8577
8711
|
classMap: true,
|
|
8578
8712
|
optionRenderer: true,
|
|
8579
8713
|
groupHeaderRenderer: true,
|
|
8714
|
+
emptyStateSlot: true,
|
|
8580
8715
|
cssCustomProperties: true,
|
|
8581
8716
|
shadowParts: true,
|
|
8582
8717
|
globalStyleMirroring: true,
|
|
8583
8718
|
},
|
|
8584
8719
|
events: {
|
|
8585
|
-
emitted: ['select', 'open', 'close', 'search', 'change', 'loadMore', 'remove', 'clear', 'error', 'diagnostic'],
|
|
8720
|
+
emitted: ['select', 'open', 'close', 'search', 'change', 'loadMore', 'remove', 'clear', 'emptyStateChange', 'error', 'diagnostic'],
|
|
8586
8721
|
diagnosticEvent: true,
|
|
8587
8722
|
},
|
|
8588
8723
|
functionality: {
|
|
@@ -8598,6 +8733,36 @@ class EnhancedSelect extends HTMLElement {
|
|
|
8598
8733
|
limitations: this.getKnownLimitations(),
|
|
8599
8734
|
};
|
|
8600
8735
|
}
|
|
8736
|
+
/** Return a detached immutable snapshot of the currently rendered empty state. */
|
|
8737
|
+
getEmptyStateContext() {
|
|
8738
|
+
const context = this._emptyStateContext;
|
|
8739
|
+
return context ? Object.freeze({ query: context.query, reason: context.reason }) : null;
|
|
8740
|
+
}
|
|
8741
|
+
_syncEmptyStateContext(context) {
|
|
8742
|
+
const current = this._emptyStateContext;
|
|
8743
|
+
if (current?.query === context?.query
|
|
8744
|
+
&& current?.reason === context?.reason
|
|
8745
|
+
&& Boolean(current) === Boolean(context))
|
|
8746
|
+
return;
|
|
8747
|
+
this._emptyStateContext = context
|
|
8748
|
+
? Object.freeze({ query: context.query, reason: context.reason })
|
|
8749
|
+
: null;
|
|
8750
|
+
const detail = Object.freeze({ context: this.getEmptyStateContext() });
|
|
8751
|
+
this._emit('emptyStateChange', detail);
|
|
8752
|
+
}
|
|
8753
|
+
_appendEmptyState(context) {
|
|
8754
|
+
const empty = document.createElement('div');
|
|
8755
|
+
empty.setAttribute('part', 'no-results');
|
|
8756
|
+
empty.className = 'empty-state';
|
|
8757
|
+
const slot = document.createElement('slot');
|
|
8758
|
+
slot.name = 'empty-state';
|
|
8759
|
+
slot.appendChild(document.createTextNode(context.reason === 'no-results'
|
|
8760
|
+
? `No results found for "${context.query}"`
|
|
8761
|
+
: 'No options available'));
|
|
8762
|
+
empty.appendChild(slot);
|
|
8763
|
+
this._optionsContainer.appendChild(empty);
|
|
8764
|
+
this._syncEmptyStateContext(context);
|
|
8765
|
+
}
|
|
8601
8766
|
_emitChange() {
|
|
8602
8767
|
const selectedEntries = this._getSelectedEntries();
|
|
8603
8768
|
const selectedItems = selectedEntries.map(({ item }) => item);
|
|
@@ -9763,11 +9928,27 @@ class EnhancedSelect extends HTMLElement {
|
|
|
9763
9928
|
this._state.isBusy = snapshot.busy;
|
|
9764
9929
|
if (!snapshot.busy) {
|
|
9765
9930
|
this._syncBusyPresentation();
|
|
9766
|
-
|
|
9767
|
-
this.
|
|
9931
|
+
const shouldReconcileEmptyState = snapshot.status === 'exhausted'
|
|
9932
|
+
&& this._renderPlan.filteredKeys.length === 0;
|
|
9933
|
+
if (shouldReconcileEmptyState) {
|
|
9934
|
+
// The first projection rendered while logically busy, so the empty
|
|
9935
|
+
// state was intentionally suppressed. Reconcile only this terminal
|
|
9936
|
+
// empty case after settlement; keep any minimum-duration busy
|
|
9937
|
+
// presentation and its timer intact.
|
|
9938
|
+
this._renderOptions();
|
|
9939
|
+
const emptyStateRenderCycleId = this._renderCycleId;
|
|
9940
|
+
const emptyStateRenderCompleted = await this._waitForRenderCycle(emptyStateRenderCycleId);
|
|
9941
|
+
if (!emptyStateRenderCompleted) {
|
|
9942
|
+
throw new Error('Acknowledged empty-state render was superseded before completion');
|
|
9943
|
+
}
|
|
9944
|
+
}
|
|
9945
|
+
else {
|
|
9946
|
+
if (!this._busyPresentationVisible) {
|
|
9947
|
+
this._optionsContainer.querySelector('.busy-bucket')?.remove();
|
|
9948
|
+
}
|
|
9949
|
+
if (this._shouldRenderLoadMoreTrigger())
|
|
9950
|
+
this._addLoadMoreTrigger();
|
|
9768
9951
|
}
|
|
9769
|
-
if (this._shouldRenderLoadMoreTrigger())
|
|
9770
|
-
this._addLoadMoreTrigger();
|
|
9771
9952
|
}
|
|
9772
9953
|
this._optionsContainer.scrollTop = this._acknowledgedProjectionScrollTop;
|
|
9773
9954
|
this._syncListboxAccessibility();
|
|
@@ -10094,7 +10275,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
10094
10275
|
this._busyPresentationGeneration += 1;
|
|
10095
10276
|
this._clearBusyPresentationHideTimer();
|
|
10096
10277
|
this._busyPresentationVisible = this._config.busyBucket.enabled;
|
|
10097
|
-
this._busyPresentationStartedAt =
|
|
10278
|
+
this._busyPresentationStartedAt = Date.now();
|
|
10098
10279
|
}
|
|
10099
10280
|
_syncBusyPresentation() {
|
|
10100
10281
|
if (!this._config.busyBucket.enabled) {
|
|
@@ -10262,6 +10443,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
10262
10443
|
this._optionsContainer.innerHTML = '';
|
|
10263
10444
|
let filteredIndicesForScope = [];
|
|
10264
10445
|
let guardedScrollTopToRestore = null;
|
|
10446
|
+
let renderedEmptyStateContext = null;
|
|
10265
10447
|
// Ensure dropdown only contains options container (cleanup legacy direct children)
|
|
10266
10448
|
// We need to preserve optionsContainer, so we can't just clear dropdown.innerHTML
|
|
10267
10449
|
// But we can check if there are other children and remove them
|
|
@@ -10285,6 +10467,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
10285
10467
|
searching.setAttribute('part', 'loading');
|
|
10286
10468
|
searching.textContent = 'Searching...';
|
|
10287
10469
|
this._optionsContainer.appendChild(searching);
|
|
10470
|
+
this._syncEmptyStateContext(null);
|
|
10288
10471
|
this._resolveRenderCycle(renderCycleId, true);
|
|
10289
10472
|
return;
|
|
10290
10473
|
}
|
|
@@ -10388,17 +10571,11 @@ class EnhancedSelect extends HTMLElement {
|
|
|
10388
10571
|
const filteredIndices = this._renderPlan.filteredIndices;
|
|
10389
10572
|
this._refreshVirtualizationScope(filteredIndicesForScope);
|
|
10390
10573
|
this._appendGuardedTopSpacer();
|
|
10391
|
-
if (
|
|
10392
|
-
|
|
10393
|
-
|
|
10394
|
-
|
|
10395
|
-
|
|
10396
|
-
empty.textContent = `No results found for "${this._state.searchQuery}"`;
|
|
10397
|
-
}
|
|
10398
|
-
else {
|
|
10399
|
-
empty.textContent = 'No options available';
|
|
10400
|
-
}
|
|
10401
|
-
this._optionsContainer.appendChild(empty);
|
|
10574
|
+
if (this._renderPlan.filteredKeys.length === 0 && !this._state.isBusy) {
|
|
10575
|
+
renderedEmptyStateContext = this._state.searchQuery
|
|
10576
|
+
? { query: this._state.searchQuery, reason: 'no-results' }
|
|
10577
|
+
: { query: '', reason: 'no-options' };
|
|
10578
|
+
this._appendEmptyState(renderedEmptyStateContext);
|
|
10402
10579
|
}
|
|
10403
10580
|
else {
|
|
10404
10581
|
const shouldIncrementalRender = !this._guardedVirtualizer
|
|
@@ -10460,6 +10637,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
10460
10637
|
}
|
|
10461
10638
|
};
|
|
10462
10639
|
renderChunk();
|
|
10640
|
+
this._syncEmptyStateContext(null);
|
|
10463
10641
|
return;
|
|
10464
10642
|
}
|
|
10465
10643
|
filteredIndices.forEach((itemIndex) => {
|
|
@@ -10484,6 +10662,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
10484
10662
|
if (guardedScrollTopToRestore !== null) {
|
|
10485
10663
|
this._optionsContainer.scrollTop = guardedScrollTopToRestore;
|
|
10486
10664
|
}
|
|
10665
|
+
this._syncEmptyStateContext(renderedEmptyStateContext);
|
|
10487
10666
|
this._syncRenderedOptionAccessibility();
|
|
10488
10667
|
this._syncLegacyActiveAria();
|
|
10489
10668
|
this._syncGuardedOptionResizeTargets();
|