@smilodon/core 1.13.0 → 1.17.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 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
- ## Custom busy bucket (Issue #90 candidate for Core 1.13.0; not yet published)
15
+ > **Issue #100 availability:** `multiSelectDisplay.scrollToLatestChip` is documented in [Multi-Select Display Modes](#multi-select-display-modes) and is included in the Core `1.17.0` release candidate. npm currently provides Core `1.13.0`; do not expect this option from the published package until the [release checklist](../../docs/releases/WEB-1.17.0-RELEASE.md) records successful publication and registry verification.
16
16
 
17
- The upcoming Core busy bucket keeps request state in Core and lets the host customize only its presentation. It is currently unreleased. Use the native slots with the Web Component or Vanilla API:
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/)
@@ -201,6 +217,21 @@ The default chevron remains in place unless a light-DOM child is assigned to the
201
217
 
202
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. Core does not impose its arrow color or hover background on assigned custom content.
203
219
 
220
+ ### Custom empty-state content (unreleased)
221
+
222
+ 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:
223
+
224
+ ```html
225
+ <enhanced-select id="products" searchable>
226
+ <div slot="empty-state" role="status">
227
+ <svg aria-hidden="true" viewBox="0 0 24 24"><!-- decorative icon --></svg>
228
+ <span>No matching products. Try a different search.</span>
229
+ </div>
230
+ </enhanced-select>
231
+ ```
232
+
233
+ `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.
234
+
204
235
  ### Framework Usage
205
236
 
206
237
  **In browser DOM frameworks, `@smilodon/core` can be used directly** as a Web Component; framework adapters are available for framework-specific APIs.
@@ -628,11 +659,15 @@ Control badge scrolling behavior in multi-select mode with `multiSelectDisplay`
628
659
  maxHeight: '160px', // used by vertical / horizontal modes
629
660
  overflowX: 'hidden',
630
661
  overflowY: 'hidden',
631
- dragScroll: true // Enable drag-to-scroll (horizontal mode)
662
+ dragScroll: true, // Enable drag-to-scroll (horizontal mode)
663
+ scrollToLatestChip: false, // Opt in to revealing newly selected chips
664
+ scrollToLatestChipBehavior: 'smooth' // 'auto' | 'smooth'
632
665
  }
633
666
  }
634
667
  ```
635
668
 
669
+ **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.
670
+
636
671
  **Display Modes:**
637
672
  - **`wrap`** (default) - Badges wrap naturally and the input shell grows with them; no internal chip scrollbar by default
638
673
  - **`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
- // Click handler for selection
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
- // Don't trigger selection if clicking remove button
2978
- if (e.target === this._removeButton) {
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();
@@ -7904,6 +7911,12 @@ class EnhancedSelect extends HTMLElement {
7904
7911
  : delta >= 0
7905
7912
  ? -1
7906
7913
  : selectableIndices.length;
7914
+ // The final selectable option is the keyboard pagination boundary.
7915
+ // Keep the active option stable while the coordinator requests more data.
7916
+ if (delta === 1
7917
+ && currentPosition === selectableIndices.length - 1
7918
+ && this._requestKeyboardLoadMore())
7919
+ return;
7907
7920
  const nextPosition = Math.max(0, Math.min(selectableIndices.length - 1, basePosition + delta));
7908
7921
  const next = selectableIndices[nextPosition];
7909
7922
  this._setActive(next);
@@ -7916,6 +7929,33 @@ class EnhancedSelect extends HTMLElement {
7916
7929
  this._selectRange(anchorIndex, next, { clear: !opts?.toggleKey });
7917
7930
  }
7918
7931
  }
7932
+ /** Return true only when boundary navigation is held for an in-flight/new page. */
7933
+ _requestKeyboardLoadMore() {
7934
+ if (!this._state.isOpen
7935
+ || !this._config.infiniteScroll.enabled
7936
+ || this._dataLoadingConfig.protocol !== 'acknowledged'
7937
+ || !this._dataRequestCoordinator
7938
+ || !this._acknowledgedReady)
7939
+ return false;
7940
+ if (this._acknowledgedProjectionPending || this._acknowledgedProjectionSettling)
7941
+ return true;
7942
+ const snapshot = this._dataRequestCoordinator.getSnapshot();
7943
+ if (!snapshot.connected)
7944
+ return false;
7945
+ if (snapshot.busy)
7946
+ return true;
7947
+ if (!snapshot.hasMore
7948
+ || snapshot.error !== null
7949
+ || snapshot.resourceLimit !== null
7950
+ || (snapshot.status !== 'succeeded' && snapshot.status !== 'empty'))
7951
+ return false;
7952
+ // Delegate identity, pagination, and in-flight protection to the coordinator.
7953
+ const actions = this._dataRequestCoordinator.requestLoadMore('manual');
7954
+ if (actions.length === 0)
7955
+ return false;
7956
+ this._dispatchAcknowledgedActions(actions);
7957
+ return true;
7958
+ }
7919
7959
  _setActive(index, reason = 'keyboard') {
7920
7960
  this._ensureRegistryCurrent();
7921
7961
  const record = this._getRecordByIndex(index);
@@ -8235,6 +8275,19 @@ class EnhancedSelect extends HTMLElement {
8235
8275
  _updateInputDisplay() {
8236
8276
  const selectedEntries = this._getSelectedEntries();
8237
8277
  const selectedItems = selectedEntries.map(({ item }) => item);
8278
+ const nextKeys = new Set(selectedEntries.map(({ key }) => key));
8279
+ const previousKeys = this._lastRenderedChipKeys;
8280
+ let newlyAddedKey;
8281
+ if (previousKeys) {
8282
+ for (const key of nextKeys) {
8283
+ if (!previousKeys.has(key))
8284
+ newlyAddedKey = key;
8285
+ }
8286
+ }
8287
+ this._lastRenderedChipKeys = nextKeys;
8288
+ const previousChipScrollLeft = this._inputContent.scrollLeft;
8289
+ // Only a newly added selected key can initiate auto-scroll.
8290
+ this._cancelLatestChipScroll();
8238
8291
  const getLabel = this._config.serverSide.getLabelFromItem || ((item) => item?.label ?? String(item));
8239
8292
  if (selectedItems.length === 0) {
8240
8293
  this._input.value = '';
@@ -8310,8 +8363,87 @@ class EnhancedSelect extends HTMLElement {
8310
8363
  if (this._acknowledgedPendingSearchQuery !== null) {
8311
8364
  this._input.value = this._acknowledgedPendingSearchQuery;
8312
8365
  }
8366
+ // Recreating the chip DOM must not reset manual scrolling. In particular,
8367
+ // remove/clear, config rerenders, and item refreshes are not scroll intents.
8368
+ if (this._config.selection.mode === 'multi') {
8369
+ this._inputContent.scrollLeft = previousChipScrollLeft;
8370
+ if (newlyAddedKey !== undefined)
8371
+ this._scheduleLatestChipScroll(newlyAddedKey);
8372
+ }
8313
8373
  this._syncClearControlState();
8314
8374
  }
8375
+ _cancelLatestChipScroll() {
8376
+ this._latestChipScrollGeneration += 1;
8377
+ if (this._latestChipScrollFrame !== null) {
8378
+ cancelAnimationFrame(this._latestChipScrollFrame);
8379
+ this._latestChipScrollFrame = null;
8380
+ }
8381
+ }
8382
+ _scheduleLatestChipScroll(key) {
8383
+ if (!this.isConnected
8384
+ || this._config.selection.mode !== 'multi'
8385
+ || this._config.multiSelectDisplay.mode !== 'horizontal'
8386
+ || this._config.multiSelectDisplay.scrollToLatestChip !== true
8387
+ || this._config.multiSelectDisplay.overflowX === 'hidden')
8388
+ return;
8389
+ const generation = this._latestChipScrollGeneration;
8390
+ this._latestChipScrollFrame = requestAnimationFrame(() => {
8391
+ this._latestChipScrollFrame = null;
8392
+ if (generation !== this._latestChipScrollGeneration
8393
+ || !this.isConnected
8394
+ || this._multiScrollDrag.active
8395
+ || this._config.selection.mode !== 'multi'
8396
+ || this._config.multiSelectDisplay.mode !== 'horizontal'
8397
+ || this._config.multiSelectDisplay.scrollToLatestChip !== true)
8398
+ return;
8399
+ // Match the canonical selected-key sequence, not option indices:
8400
+ // selected items may be reordered or detached from the loaded page.
8401
+ const entries = this._getSelectedEntries();
8402
+ const index = entries.findIndex((entry) => entry.key === key);
8403
+ if (index < 0)
8404
+ return;
8405
+ const chip = this._inputContent.querySelectorAll('.selection-badge')[index];
8406
+ if (!chip)
8407
+ return;
8408
+ const hostBounds = this._inputContent.getBoundingClientRect();
8409
+ const chipBounds = chip.getBoundingClientRect();
8410
+ const leftEdge = hostBounds.left + this._inputContent.clientLeft;
8411
+ const rightEdge = leftEdge + this._inputContent.clientWidth;
8412
+ let delta;
8413
+ if (chip.parentElement === this._inputContent && chip.offsetWidth > 0) {
8414
+ // getBoundingClientRect() includes the chip's entry animation transform.
8415
+ // Use layout dimensions so the scroll target remains correct while the
8416
+ // chip scales into its final size. In RTL layouts, offsetLeft and
8417
+ // scrollLeft are both negative relative to the inline-start origin, so
8418
+ // the same subtraction maps the chip into the viewport's coordinates.
8419
+ const chipLeft = chip.offsetLeft - this._inputContent.scrollLeft;
8420
+ const chipRight = chipLeft + chip.offsetWidth;
8421
+ delta = chipRight > this._inputContent.clientWidth
8422
+ ? chipRight - this._inputContent.clientWidth
8423
+ : chipLeft < 0
8424
+ ? chipLeft
8425
+ : 0;
8426
+ }
8427
+ else {
8428
+ // DOM test environments without layout use the measurable rectangle.
8429
+ delta = chipBounds.right > rightEdge
8430
+ ? chipBounds.right - rightEdge
8431
+ : chipBounds.left < leftEdge
8432
+ ? chipBounds.left - leftEdge
8433
+ : 0;
8434
+ }
8435
+ if (Math.abs(delta) < 0.5)
8436
+ return;
8437
+ const reducedMotion = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false;
8438
+ const behavior = reducedMotion ? 'auto' : (this._config.multiSelectDisplay.scrollToLatestChipBehavior ?? 'smooth');
8439
+ if (typeof this._inputContent.scrollBy === 'function') {
8440
+ this._inputContent.scrollBy({ left: delta, behavior });
8441
+ }
8442
+ else {
8443
+ this._inputContent.scrollLeft += delta;
8444
+ }
8445
+ });
8446
+ }
8315
8447
  _isActivelyEditingSearchInput() {
8316
8448
  return this._config.searchable === true
8317
8449
  && this._state.isOpen
@@ -8577,12 +8709,13 @@ class EnhancedSelect extends HTMLElement {
8577
8709
  classMap: true,
8578
8710
  optionRenderer: true,
8579
8711
  groupHeaderRenderer: true,
8712
+ emptyStateSlot: true,
8580
8713
  cssCustomProperties: true,
8581
8714
  shadowParts: true,
8582
8715
  globalStyleMirroring: true,
8583
8716
  },
8584
8717
  events: {
8585
- emitted: ['select', 'open', 'close', 'search', 'change', 'loadMore', 'remove', 'clear', 'error', 'diagnostic'],
8718
+ emitted: ['select', 'open', 'close', 'search', 'change', 'loadMore', 'remove', 'clear', 'emptyStateChange', 'error', 'diagnostic'],
8586
8719
  diagnosticEvent: true,
8587
8720
  },
8588
8721
  functionality: {
@@ -8598,6 +8731,36 @@ class EnhancedSelect extends HTMLElement {
8598
8731
  limitations: this.getKnownLimitations(),
8599
8732
  };
8600
8733
  }
8734
+ /** Return a detached immutable snapshot of the currently rendered empty state. */
8735
+ getEmptyStateContext() {
8736
+ const context = this._emptyStateContext;
8737
+ return context ? Object.freeze({ query: context.query, reason: context.reason }) : null;
8738
+ }
8739
+ _syncEmptyStateContext(context) {
8740
+ const current = this._emptyStateContext;
8741
+ if (current?.query === context?.query
8742
+ && current?.reason === context?.reason
8743
+ && Boolean(current) === Boolean(context))
8744
+ return;
8745
+ this._emptyStateContext = context
8746
+ ? Object.freeze({ query: context.query, reason: context.reason })
8747
+ : null;
8748
+ const detail = Object.freeze({ context: this.getEmptyStateContext() });
8749
+ this._emit('emptyStateChange', detail);
8750
+ }
8751
+ _appendEmptyState(context) {
8752
+ const empty = document.createElement('div');
8753
+ empty.setAttribute('part', 'no-results');
8754
+ empty.className = 'empty-state';
8755
+ const slot = document.createElement('slot');
8756
+ slot.name = 'empty-state';
8757
+ slot.appendChild(document.createTextNode(context.reason === 'no-results'
8758
+ ? `No results found for "${context.query}"`
8759
+ : 'No options available'));
8760
+ empty.appendChild(slot);
8761
+ this._optionsContainer.appendChild(empty);
8762
+ this._syncEmptyStateContext(context);
8763
+ }
8601
8764
  _emitChange() {
8602
8765
  const selectedEntries = this._getSelectedEntries();
8603
8766
  const selectedItems = selectedEntries.map(({ item }) => item);
@@ -9763,11 +9926,27 @@ class EnhancedSelect extends HTMLElement {
9763
9926
  this._state.isBusy = snapshot.busy;
9764
9927
  if (!snapshot.busy) {
9765
9928
  this._syncBusyPresentation();
9766
- if (!this._busyPresentationVisible) {
9767
- this._optionsContainer.querySelector('.busy-bucket')?.remove();
9929
+ const shouldReconcileEmptyState = snapshot.status === 'exhausted'
9930
+ && this._renderPlan.filteredKeys.length === 0;
9931
+ if (shouldReconcileEmptyState) {
9932
+ // The first projection rendered while logically busy, so the empty
9933
+ // state was intentionally suppressed. Reconcile only this terminal
9934
+ // empty case after settlement; keep any minimum-duration busy
9935
+ // presentation and its timer intact.
9936
+ this._renderOptions();
9937
+ const emptyStateRenderCycleId = this._renderCycleId;
9938
+ const emptyStateRenderCompleted = await this._waitForRenderCycle(emptyStateRenderCycleId);
9939
+ if (!emptyStateRenderCompleted) {
9940
+ throw new Error('Acknowledged empty-state render was superseded before completion');
9941
+ }
9942
+ }
9943
+ else {
9944
+ if (!this._busyPresentationVisible) {
9945
+ this._optionsContainer.querySelector('.busy-bucket')?.remove();
9946
+ }
9947
+ if (this._shouldRenderLoadMoreTrigger())
9948
+ this._addLoadMoreTrigger();
9768
9949
  }
9769
- if (this._shouldRenderLoadMoreTrigger())
9770
- this._addLoadMoreTrigger();
9771
9950
  }
9772
9951
  this._optionsContainer.scrollTop = this._acknowledgedProjectionScrollTop;
9773
9952
  this._syncListboxAccessibility();
@@ -10094,7 +10273,7 @@ class EnhancedSelect extends HTMLElement {
10094
10273
  this._busyPresentationGeneration += 1;
10095
10274
  this._clearBusyPresentationHideTimer();
10096
10275
  this._busyPresentationVisible = this._config.busyBucket.enabled;
10097
- this._busyPresentationStartedAt = this._busyBucket?.isConnected ? Date.now() : null;
10276
+ this._busyPresentationStartedAt = Date.now();
10098
10277
  }
10099
10278
  _syncBusyPresentation() {
10100
10279
  if (!this._config.busyBucket.enabled) {
@@ -10262,6 +10441,7 @@ class EnhancedSelect extends HTMLElement {
10262
10441
  this._optionsContainer.innerHTML = '';
10263
10442
  let filteredIndicesForScope = [];
10264
10443
  let guardedScrollTopToRestore = null;
10444
+ let renderedEmptyStateContext = null;
10265
10445
  // Ensure dropdown only contains options container (cleanup legacy direct children)
10266
10446
  // We need to preserve optionsContainer, so we can't just clear dropdown.innerHTML
10267
10447
  // But we can check if there are other children and remove them
@@ -10285,6 +10465,7 @@ class EnhancedSelect extends HTMLElement {
10285
10465
  searching.setAttribute('part', 'loading');
10286
10466
  searching.textContent = 'Searching...';
10287
10467
  this._optionsContainer.appendChild(searching);
10468
+ this._syncEmptyStateContext(null);
10288
10469
  this._resolveRenderCycle(renderCycleId, true);
10289
10470
  return;
10290
10471
  }
@@ -10388,17 +10569,11 @@ class EnhancedSelect extends HTMLElement {
10388
10569
  const filteredIndices = this._renderPlan.filteredIndices;
10389
10570
  this._refreshVirtualizationScope(filteredIndicesForScope);
10390
10571
  this._appendGuardedTopSpacer();
10391
- if (filteredIndices.length === 0 && !this._state.isBusy) {
10392
- const empty = document.createElement('div');
10393
- empty.setAttribute('part', 'no-results');
10394
- empty.className = 'empty-state';
10395
- if (query) {
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);
10572
+ if (this._renderPlan.filteredKeys.length === 0 && !this._state.isBusy) {
10573
+ renderedEmptyStateContext = this._state.searchQuery
10574
+ ? { query: this._state.searchQuery, reason: 'no-results' }
10575
+ : { query: '', reason: 'no-options' };
10576
+ this._appendEmptyState(renderedEmptyStateContext);
10402
10577
  }
10403
10578
  else {
10404
10579
  const shouldIncrementalRender = !this._guardedVirtualizer
@@ -10460,6 +10635,7 @@ class EnhancedSelect extends HTMLElement {
10460
10635
  }
10461
10636
  };
10462
10637
  renderChunk();
10638
+ this._syncEmptyStateContext(null);
10463
10639
  return;
10464
10640
  }
10465
10641
  filteredIndices.forEach((itemIndex) => {
@@ -10484,6 +10660,7 @@ class EnhancedSelect extends HTMLElement {
10484
10660
  if (guardedScrollTopToRestore !== null) {
10485
10661
  this._optionsContainer.scrollTop = guardedScrollTopToRestore;
10486
10662
  }
10663
+ this._syncEmptyStateContext(renderedEmptyStateContext);
10487
10664
  this._syncRenderedOptionAccessibility();
10488
10665
  this._syncLegacyActiveAria();
10489
10666
  this._syncGuardedOptionResizeTargets();