@smilodon/core 1.11.1 → 1.13.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,6 +12,37 @@
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)
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:
18
+
19
+ ```html
20
+ <enhanced-select>
21
+ <span slot="loading-icon" aria-hidden="true">⏳</span>
22
+ <div slot="loading-content">
23
+ <strong>Loading more products…</strong>
24
+ <span>Please wait.</span>
25
+ </div>
26
+ </enhanced-select>
27
+ ```
28
+
29
+ ```ts
30
+ select.updateConfig({
31
+ busyBucket: {
32
+ enabled: true,
33
+ showSpinner: false,
34
+ showMessage: true,
35
+ message: 'Loading…',
36
+ minDisplayTime: 200,
37
+ contentMode: 'append', // or 'replace'
38
+ },
39
+ })
40
+ ```
41
+
42
+ `append` keeps the built-in spinner/message with custom slot content. `replace` shows only accessible custom content and hides the icon and message regions; if no accessible replacement is supplied, Core keeps a “Loading…” fallback. `showSpinner` affects only the built-in spinner, so a supplied `loading-icon` remains visible in append mode when the fallback spinner is disabled. The existing `Searching...` state remains separate from the busy bucket.
43
+
44
+ The bucket exposes `::part(loading)`, `::part(loading-icon)`, `::part(loading-spinner)`, `::part(loading-message)`, and `::part(loading-content)`. Layout can be adjusted with `--select-busy-gap`, `--select-busy-padding`, `--select-busy-color`, `--select-busy-bg`, and the existing `--select-spinner-size` token. `minDisplayTime` is a visual minimum after request completion; it does not delay acceptance, pagination, or `aria-busy` updates.
45
+
15
46
  ## Acknowledged data loading (Phase 2F-D development candidate)
16
47
 
17
48
  The local Phase 2F-D candidate adds a public, per-instance data-loading configuration and completion surface to `EnhancedSelect`. This API is not included in the published `1.10.0` package. The legacy protocol remains the default; remote and hybrid search or cursor pagination require explicit acknowledged-protocol opt-in. There is no global acknowledged-loading default. Cross-browser certification and independent review remain pending, so these examples are illustrative and have not been certified for release.
@@ -336,7 +367,7 @@ select.optionRenderer = (item, index) => {
336
367
 
337
368
  ### Active state on custom option roots
338
369
 
339
- For custom-rendered options, `classMap.active` names the class or classes applied to the active option root. Core removes its built-in active aliases and previously configured active classes when another option becomes active, when the option is rendered again, or when `classMap` changes. The active `data-sm-state` token is reconciled with those classes, so an inactive option does not retain stale active styling.
370
+ For custom-rendered options, `classMap.active` names the class or classes applied to the active option root. This fixes [Issue #82](https://github.com/navidrezadoost/Smilodon/issues/82) in the Core source (merged prior to this release). Core removes its built-in active aliases and previously configured active classes when another option becomes active, when the option is rendered again, or when `classMap` changes. The active `data-sm-state` token is reconciled with those classes, so an inactive option does not retain stale active styling.
340
371
 
341
372
  ```typescript
342
373
  select.classMap = { active: 'is-active keyboard-focus' };
@@ -389,6 +420,29 @@ const selectedItems = select.getSelectedItems();
389
420
 
390
421
  ## Advanced Usage
391
422
 
423
+ ### Dropdown enter and exit animations (Core 1.12.0)
424
+
425
+ The default entry animation uses `--select-dropdown-animation`. The new exit animation mirrors that control through `--select-dropdown-exit-animation`, defaulting to `dropdownExit 160ms cubic-bezier(0.4, 0, 1, 1) forwards`.
426
+
427
+ ```css
428
+ enhanced-select {
429
+ --select-dropdown-animation: dropdownEnter 250ms ease-out forwards;
430
+ --select-dropdown-exit-animation: dropdownExit 180ms ease-in forwards;
431
+ --select-dropdown-exit-to-transform: translateY(-10px) scale(0.98);
432
+ --select-dropdown-top-exit-to-transform: translateY(10px) scale(0.98);
433
+ }
434
+ enhanced-select.instant {
435
+ --select-dropdown-animation: none;
436
+ --select-dropdown-exit-animation: none;
437
+ }
438
+ ```
439
+
440
+ Opacity and starting transform can be adjusted using `--select-dropdown-exit-from-opacity`, `--select-dropdown-exit-to-opacity`, and `--select-dropdown-exit-from-transform`. Closing updates engine and ARIA immediately; the panel is inert and hidden from assistive technology while exiting. Reopening cancels the exit. Reduced-motion preferences are respected.
441
+
442
+ **Release:** available as `@smilodon/core@1.12.0` from npm. Qualification was recorded on Chrome 156 (8/8 focused Core tests, 4/4 browser scenarios, 723 passed/7 skipped in the full suite, as reported for PR #86). The repository's pinned Playwright Chromium 147 run remains unverified. See [implementation and qualification notes](../../docs/architecture/DROPDOWN-EXIT-ANIMATION.md) and the [release record](../../docs/releases/CORE-1.12.0-RELEASE.md).
443
+
444
+ For the related fixes, stable option-hover geometry shipped in Core `1.11.0` ([Issue #77](https://github.com/navidrezadoost/Smilodon/issues/77)) and custom active-class reconciliation shipped in `1.11.1` ([Issue #82](https://github.com/navidrezadoost/Smilodon/issues/82)). Both remain in `1.12.0`; the exit animation is the new feature in that version. See the [release record](../../docs/releases/CORE-1.12.0-RELEASE.md).
445
+
392
446
  ### Custom Styling
393
447
 
394
448
  Smilodon uses CSS custom properties (CSS variables) for easy theming and customization. The default theme is **light mode** with a clean white background.
package/dist/index.cjs CHANGED
@@ -2123,8 +2123,10 @@ const defaultConfig = {
2123
2123
  busyBucket: {
2124
2124
  enabled: true,
2125
2125
  showSpinner: true,
2126
+ showMessage: true,
2126
2127
  message: 'Loading...',
2127
2128
  minDisplayTime: 200,
2129
+ contentMode: 'append',
2128
2130
  },
2129
2131
  styles: {
2130
2132
  classNames: {},
@@ -4043,6 +4045,10 @@ class EnhancedSelect extends HTMLElement {
4043
4045
  super();
4044
4046
  this._dataLoadingConfig = { ...LEGACY_DATA_LOADING_CONFIG };
4045
4047
  this._hasLastInvalidDataLoadingCandidate = false;
4048
+ this._busyPresentationVisible = false;
4049
+ this._busyPresentationStartedAt = null;
4050
+ this._busyPresentationGeneration = 0;
4051
+ this._busyPresentationHideTimer = null;
4046
4052
  this._engine = new SelectEngineBridge();
4047
4053
  this._virtualizationScope = {
4048
4054
  dataKeys: [],
@@ -4137,6 +4143,22 @@ class EnhancedSelect extends HTMLElement {
4137
4143
  this._renderCycleWaiterTimeouts = new Map();
4138
4144
  this._suppressNextOpenClick = false;
4139
4145
  this._resolvedDropdownPlacement = 'bottom';
4146
+ // Presentation only: the popup engine is already closed while the exit runs.
4147
+ this._dropdownExitTimer = null;
4148
+ this._onDropdownExitAnimationEnd = (event) => {
4149
+ if (event.target !== this._dropdown || this._state.isOpen)
4150
+ return;
4151
+ if (this._dropdown.getAttribute('data-motion') !== 'closing')
4152
+ return;
4153
+ // A composite consumer animation must finish all timelines, not just the first.
4154
+ const names = getComputedStyle(this._dropdown).animationName
4155
+ .split(',').map((name) => name.trim()).filter((name) => name && name !== 'none');
4156
+ if (names.length > 1)
4157
+ return; // bounded timeout waits for the longest timeline
4158
+ if (event.animationName && names[0] && event.animationName !== names[0])
4159
+ return;
4160
+ this._finishDropdownExit();
4161
+ };
4140
4162
  this._multiScrollDrag = {
4141
4163
  active: false,
4142
4164
  moved: false,
@@ -4290,6 +4312,7 @@ class EnhancedSelect extends HTMLElement {
4290
4312
  this._syncListboxAccessibility();
4291
4313
  }
4292
4314
  disconnectedCallback() {
4315
+ this._cancelBusyPresentation();
4293
4316
  if (this._dataRequestCoordinator) {
4294
4317
  const actions = this._dataRequestCoordinator.disconnect();
4295
4318
  this._acknowledgedReady = false;
@@ -4298,6 +4321,11 @@ class EnhancedSelect extends HTMLElement {
4298
4321
  this._state.isSearching = false;
4299
4322
  this._state.preserveScrollPosition = false;
4300
4323
  }
4324
+ // A disconnected popup must not retain a visual exit or a live timer.
4325
+ this._cancelDropdownExit();
4326
+ this._dropdown.style.display = 'none';
4327
+ this._dropdown.setAttribute('inert', '');
4328
+ this._dropdown.setAttribute('aria-hidden', 'true');
4301
4329
  // unregister instance
4302
4330
  EnhancedSelect._instances.delete(this);
4303
4331
  if (this._state.isOpen) {
@@ -5651,6 +5679,12 @@ class EnhancedSelect extends HTMLElement {
5651
5679
  --select-dropdown-top: calc(100% + 6px);
5652
5680
  --select-dropdown-bottom: calc(100% + 6px);
5653
5681
  --select-dropdown-animation: dropdownEnter 200ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
5682
+ --select-dropdown-exit-animation: dropdownExit 160ms cubic-bezier(0.4, 0, 1, 1) forwards;
5683
+ --select-dropdown-exit-from-opacity: 1;
5684
+ --select-dropdown-exit-from-transform: translateY(0) scale(1);
5685
+ --select-dropdown-exit-to-opacity: 0;
5686
+ --select-dropdown-exit-to-transform: translateY(-8px) scale(0.98);
5687
+ --select-dropdown-top-exit-to-transform: translateY(8px) scale(0.98);
5654
5688
  --select-dropdown-enter-from-opacity: 0;
5655
5689
  --select-dropdown-enter-from-transform: translateY(-8px) scale(0.98);
5656
5690
  --select-dropdown-enter-to-opacity: 1;
@@ -6353,8 +6387,26 @@ class EnhancedSelect extends HTMLElement {
6353
6387
 
6354
6388
  .select-dropdown[data-placement="top"] {
6355
6389
  --select-dropdown-enter-from-transform: var(--select-dropdown-top-enter-from-transform, translateY(8px) scale(0.98));
6390
+ --select-dropdown-exit-to-transform: var(--select-dropdown-top-exit-to-transform, translateY(8px) scale(0.98));
6356
6391
  }
6357
-
6392
+
6393
+ /* A closed popup stays visually mounted for exit, but cannot be interacted with. */
6394
+ .select-dropdown[data-motion="closing"] {
6395
+ animation: var(--select-dropdown-exit-animation);
6396
+ pointer-events: none;
6397
+ }
6398
+
6399
+ @keyframes dropdownExit {
6400
+ from {
6401
+ opacity: var(--select-dropdown-exit-from-opacity);
6402
+ transform: var(--select-dropdown-exit-from-transform);
6403
+ }
6404
+ to {
6405
+ opacity: var(--select-dropdown-exit-to-opacity);
6406
+ transform: var(--select-dropdown-exit-to-transform);
6407
+ }
6408
+ }
6409
+
6358
6410
  @keyframes dropdownEnter {
6359
6411
  0% {
6360
6412
  opacity: var(--select-dropdown-enter-from-opacity);
@@ -6603,12 +6655,40 @@ class EnhancedSelect extends HTMLElement {
6603
6655
  }
6604
6656
 
6605
6657
  .busy-bucket {
6658
+ display: flex;
6659
+ flex-direction: column;
6660
+ align-items: center;
6661
+ justify-content: center;
6662
+ gap: var(--select-busy-gap, 8px);
6606
6663
  padding: var(--select-busy-padding, 20px);
6607
6664
  text-align: center;
6608
6665
  color: var(--select-busy-color, var(--select-text-muted));
6609
6666
  background: var(--select-busy-bg, transparent);
6610
6667
  font-size: var(--select-busy-font-size, 0.8667em);
6611
6668
  }
6669
+
6670
+ .busy-icon {
6671
+ display: flex;
6672
+ align-items: center;
6673
+ justify-content: center;
6674
+ }
6675
+
6676
+ .busy-icon[hidden] {
6677
+ display: none;
6678
+ }
6679
+
6680
+ .busy-message {
6681
+ text-align: center;
6682
+ }
6683
+
6684
+ .busy-content[hidden] {
6685
+ display: none;
6686
+ }
6687
+
6688
+ .busy-bucket--replace .busy-icon,
6689
+ .busy-bucket--replace .busy-message {
6690
+ display: none;
6691
+ }
6612
6692
 
6613
6693
  .spinner {
6614
6694
  display: inline-block;
@@ -7360,6 +7440,10 @@ class EnhancedSelect extends HTMLElement {
7360
7440
  if (!effects.some((effect) => effect.type === 'POPUP_OPENED'))
7361
7441
  return;
7362
7442
  this._runEngineEffects(effects);
7443
+ // Reopening during exit cancels the old finish callback and restores interactivity.
7444
+ this._cancelDropdownExit();
7445
+ this._dropdown.removeAttribute('inert');
7446
+ this._dropdown.removeAttribute('aria-hidden');
7363
7447
  this._markOpenStart();
7364
7448
  this.setAttribute('data-open', 'true');
7365
7449
  this._liftStackingAncestors();
@@ -7396,14 +7480,78 @@ class EnhancedSelect extends HTMLElement {
7396
7480
  return;
7397
7481
  this.removeAttribute('data-open');
7398
7482
  this._restoreLiftedAncestors();
7399
- this._dropdown.style.display = 'none';
7400
7483
  this._dropdown.setAttribute('data-placement', this._resolvedDropdownPlacement);
7401
7484
  this._updateArrowRotation();
7485
+ // Engine + ARIA close immediately. Only the visual panel waits for exit.
7402
7486
  this._runEngineEffects(effects);
7487
+ this._beginDropdownExit(reason === 'disconnect' || !this.isConnected);
7403
7488
  this._emit('close', {});
7404
7489
  this._config.callbacks.onClose?.();
7405
7490
  this._announce('Options collapsed');
7406
7491
  }
7492
+ /** Stop an outstanding exit before reopening, disconnecting or starting another one. */
7493
+ _cancelDropdownExit() {
7494
+ if (this._dropdownExitTimer !== null) {
7495
+ window.clearTimeout(this._dropdownExitTimer);
7496
+ this._dropdownExitTimer = null;
7497
+ }
7498
+ this._dropdown.removeEventListener('animationend', this._onDropdownExitAnimationEnd);
7499
+ this._dropdown.removeAttribute('data-motion');
7500
+ }
7501
+ _finishDropdownExit() {
7502
+ if (this._state.isOpen || this._dropdown.getAttribute('data-motion') !== 'closing')
7503
+ return;
7504
+ this._cancelDropdownExit();
7505
+ this._dropdown.style.display = 'none';
7506
+ }
7507
+ _beginDropdownExit(immediate) {
7508
+ this._cancelDropdownExit();
7509
+ // Inert + aria-hidden apply at logical close, not at animation completion.
7510
+ this._dropdown.setAttribute('inert', '');
7511
+ this._dropdown.setAttribute('aria-hidden', 'true');
7512
+ if (immediate || this._dropdown.style.display === 'none') {
7513
+ this._dropdown.style.display = 'none';
7514
+ return;
7515
+ }
7516
+ this._dropdown.setAttribute('data-motion', 'closing');
7517
+ const duration = this._getDropdownExitDurationMs();
7518
+ if (duration <= 0) {
7519
+ this._finishDropdownExit();
7520
+ return;
7521
+ }
7522
+ // animationend optimizes normal completion; timeout handles missing/cancelled events.
7523
+ this._dropdown.addEventListener('animationend', this._onDropdownExitAnimationEnd);
7524
+ this._dropdownExitTimer = window.setTimeout(() => this._finishDropdownExit(), duration + 34);
7525
+ }
7526
+ /** CSS animations may be disabled or customized by consumers; never wait forever. */
7527
+ _getDropdownExitDurationMs() {
7528
+ if (window.matchMedia?.('(prefers-reduced-motion: reduce)').matches)
7529
+ return 0;
7530
+ const style = getComputedStyle(this._dropdown);
7531
+ const names = style.animationName.split(',').map((value) => value.trim());
7532
+ if (!names.length || names.every((name) => !name || name === 'none'))
7533
+ return 0;
7534
+ const toMs = (value) => {
7535
+ const trimmed = value.trim();
7536
+ const parsed = Number.parseFloat(trimmed);
7537
+ if (!Number.isFinite(parsed))
7538
+ return 0;
7539
+ return trimmed.endsWith('ms') ? parsed : trimmed.endsWith('s') ? parsed * 1000 : 0;
7540
+ };
7541
+ const durations = style.animationDuration.split(',');
7542
+ const delays = style.animationDelay.split(',');
7543
+ const counts = style.animationIterationCount.split(',');
7544
+ const maximum = names.reduce((max, name, index) => {
7545
+ if (!name || name === 'none')
7546
+ return max;
7547
+ const duration = toMs(durations[index % durations.length] ?? '0s');
7548
+ const delay = toMs(delays[index % delays.length] ?? '0s');
7549
+ const count = Number.parseFloat(counts[index % counts.length] ?? '1');
7550
+ const iterations = Number.isFinite(count) ? Math.max(0, count) : 1;
7551
+ return Math.max(max, Math.max(0, duration * iterations + delay));
7552
+ }, 0);
7553
+ return Math.min(maximum, 10000);
7554
+ }
7407
7555
  _updateDropdownVisibility() {
7408
7556
  if (this._state.isOpen) {
7409
7557
  this.setAttribute('data-open', 'true');
@@ -8279,6 +8427,8 @@ class EnhancedSelect extends HTMLElement {
8279
8427
  }
8280
8428
  }
8281
8429
  _setBusy(busy) {
8430
+ if (busy)
8431
+ this._beginBusyPresentation();
8282
8432
  this._state.isBusy = busy;
8283
8433
  this._syncListboxAccessibility();
8284
8434
  // Trigger re-render to show/hide busy indicator
@@ -9459,6 +9609,7 @@ class EnhancedSelect extends HTMLElement {
9459
9609
  _dispatchAcknowledgedActions(actions) {
9460
9610
  for (const action of actions) {
9461
9611
  if (action.type === 'cancel') {
9612
+ this._cancelBusyPresentation();
9462
9613
  this._dispatchAcknowledgedEvent('dataRequestCancel', action.notification);
9463
9614
  try {
9464
9615
  this._dataRequestCancelCallback?.(action.notification);
@@ -9483,6 +9634,7 @@ class EnhancedSelect extends HTMLElement {
9483
9634
  this._state.preserveScrollPosition = false;
9484
9635
  this._state.isSearching = true;
9485
9636
  }
9637
+ this._beginBusyPresentation();
9486
9638
  this._state.isBusy = true;
9487
9639
  this._acknowledgedLastRequest = request;
9488
9640
  this._syncListboxAccessibility();
@@ -9610,7 +9762,10 @@ class EnhancedSelect extends HTMLElement {
9610
9762
  throw new Error('Acknowledged snapshot render was superseded before completion');
9611
9763
  this._state.isBusy = snapshot.busy;
9612
9764
  if (!snapshot.busy) {
9613
- this._optionsContainer.querySelector('.busy-bucket')?.remove();
9765
+ this._syncBusyPresentation();
9766
+ if (!this._busyPresentationVisible) {
9767
+ this._optionsContainer.querySelector('.busy-bucket')?.remove();
9768
+ }
9614
9769
  if (this._shouldRenderLoadMoreTrigger())
9615
9770
  this._addLoadMoreTrigger();
9616
9771
  }
@@ -9928,7 +10083,166 @@ class EnhancedSelect extends HTMLElement {
9928
10083
  _refreshVirtualizationScope(filteredIndices) {
9929
10084
  this._virtualizationScope = this._deriveVirtualizationScope(filteredIndices);
9930
10085
  }
10086
+ _clearBusyPresentationHideTimer() {
10087
+ if (this._busyPresentationHideTimer === null)
10088
+ return;
10089
+ window.clearTimeout(this._busyPresentationHideTimer);
10090
+ this._lifecycleTimers.delete(this._busyPresentationHideTimer);
10091
+ this._busyPresentationHideTimer = null;
10092
+ }
10093
+ _beginBusyPresentation() {
10094
+ this._busyPresentationGeneration += 1;
10095
+ this._clearBusyPresentationHideTimer();
10096
+ this._busyPresentationVisible = this._config.busyBucket.enabled;
10097
+ this._busyPresentationStartedAt = this._busyBucket?.isConnected ? Date.now() : null;
10098
+ }
10099
+ _syncBusyPresentation() {
10100
+ if (!this._config.busyBucket.enabled) {
10101
+ this._cancelBusyPresentation();
10102
+ return;
10103
+ }
10104
+ if (this._state.isBusy) {
10105
+ if (!this._busyPresentationVisible || this._busyPresentationHideTimer !== null) {
10106
+ this._beginBusyPresentation();
10107
+ }
10108
+ return;
10109
+ }
10110
+ if (!this._busyPresentationVisible || this._busyPresentationHideTimer !== null)
10111
+ return;
10112
+ const configuredMinimum = Number(this._config.busyBucket.minDisplayTime ?? 0);
10113
+ const minimum = Number.isFinite(configuredMinimum) ? Math.max(0, configuredMinimum) : 0;
10114
+ if (this._busyPresentationStartedAt === null)
10115
+ this._busyPresentationStartedAt = Date.now();
10116
+ const shownAt = this._busyPresentationStartedAt;
10117
+ const remaining = minimum - Math.max(0, Date.now() - shownAt);
10118
+ if (remaining <= 0) {
10119
+ this._busyPresentationGeneration += 1;
10120
+ this._busyPresentationVisible = false;
10121
+ this._busyPresentationStartedAt = null;
10122
+ return;
10123
+ }
10124
+ const generation = this._busyPresentationGeneration;
10125
+ this._busyPresentationHideTimer = this._setLifecycleTimeout(() => {
10126
+ if (generation !== this._busyPresentationGeneration || this._state.isBusy)
10127
+ return;
10128
+ this._busyPresentationHideTimer = null;
10129
+ this._busyPresentationVisible = false;
10130
+ this._busyPresentationStartedAt = null;
10131
+ this._busyBucket = undefined;
10132
+ this._clearBusyBucketContentObserver();
10133
+ this._renderOptions();
10134
+ }, remaining);
10135
+ }
10136
+ _clearBusyBucketContentObserver() {
10137
+ this._busyBucketContentObserver?.disconnect();
10138
+ this._busyBucketContentObserver = undefined;
10139
+ }
10140
+ _cancelBusyPresentation() {
10141
+ this._busyPresentationGeneration += 1;
10142
+ this._clearBusyPresentationHideTimer();
10143
+ this._busyPresentationVisible = false;
10144
+ this._busyPresentationStartedAt = null;
10145
+ this._clearBusyBucketContentObserver();
10146
+ this._busyBucket = undefined;
10147
+ this._optionsContainer?.querySelector('.busy-bucket')?.remove();
10148
+ }
10149
+ _hasAccessibleBusyContent(nodes) {
10150
+ return nodes.some((node) => {
10151
+ if (node.nodeType === Node.TEXT_NODE)
10152
+ return Boolean(node.textContent?.trim());
10153
+ if (!(node instanceof Element))
10154
+ return false;
10155
+ if (node.hasAttribute('hidden')
10156
+ || node.hasAttribute('inert')
10157
+ || node.getAttribute('aria-hidden')?.toLowerCase() === 'true')
10158
+ return false;
10159
+ if (['aria-label', 'aria-labelledby', 'alt', 'title'].some((name) => Boolean(node.getAttribute(name)?.trim()))) {
10160
+ return true;
10161
+ }
10162
+ return this._hasAccessibleBusyContent(Array.from(node.childNodes));
10163
+ });
10164
+ }
10165
+ _syncBusyBucketContent(bucket) {
10166
+ if (bucket !== this._busyBucket)
10167
+ return;
10168
+ const contentSlot = bucket.querySelector('slot[name="loading-content"]');
10169
+ const iconSlot = bucket.querySelector('slot[name="loading-icon"]');
10170
+ if (!contentSlot || !iconSlot)
10171
+ return;
10172
+ const contentNodes = contentSlot.assignedNodes({ flatten: true });
10173
+ const iconNodes = iconSlot.assignedNodes({ flatten: true });
10174
+ const hasContent = contentNodes.length > 0;
10175
+ const hasAccessibleContent = this._hasAccessibleBusyContent(contentNodes);
10176
+ const icon = bucket.querySelector('.busy-icon');
10177
+ icon?.toggleAttribute('hidden', this._config.busyBucket.showSpinner === false && iconNodes.length === 0);
10178
+ const content = bucket.querySelector('.busy-content');
10179
+ content?.toggleAttribute('hidden', !hasContent);
10180
+ bucket.classList.toggle('busy-bucket--replace', this._config.busyBucket.contentMode === 'replace' && hasAccessibleContent);
10181
+ const message = bucket.querySelector('.busy-message');
10182
+ if (message) {
10183
+ const needsAccessibleFallback = this._config.busyBucket.contentMode === 'replace' && !hasAccessibleContent;
10184
+ message.toggleAttribute('hidden', this._config.busyBucket.showMessage === false && !needsAccessibleFallback);
10185
+ if (needsAccessibleFallback && !message.textContent?.trim()) {
10186
+ message.textContent = this._config.busyBucket.message || 'Loading...';
10187
+ }
10188
+ }
10189
+ }
10190
+ _createBusyBucket() {
10191
+ const bucket = document.createElement('div');
10192
+ bucket.setAttribute('part', 'loading');
10193
+ bucket.className = 'busy-bucket';
10194
+ this._busyBucket = bucket;
10195
+ const icon = document.createElement('div');
10196
+ icon.className = 'busy-icon';
10197
+ icon.setAttribute('part', 'loading-icon');
10198
+ icon.setAttribute('aria-hidden', 'true');
10199
+ const iconSlot = document.createElement('slot');
10200
+ iconSlot.name = 'loading-icon';
10201
+ if (this._config.busyBucket.showSpinner !== false) {
10202
+ const spinner = document.createElement('div');
10203
+ spinner.className = 'spinner';
10204
+ spinner.setAttribute('part', 'loading-spinner');
10205
+ spinner.setAttribute('aria-hidden', 'true');
10206
+ iconSlot.appendChild(spinner);
10207
+ }
10208
+ icon.appendChild(iconSlot);
10209
+ bucket.appendChild(icon);
10210
+ const message = document.createElement('div');
10211
+ message.className = 'busy-message';
10212
+ message.setAttribute('part', 'loading-message');
10213
+ message.textContent = this._config.busyBucket.message ?? 'Loading...';
10214
+ message.toggleAttribute('hidden', this._config.busyBucket.showMessage === false);
10215
+ bucket.appendChild(message);
10216
+ const content = document.createElement('div');
10217
+ content.className = 'busy-content';
10218
+ content.setAttribute('part', 'loading-content');
10219
+ const contentSlot = document.createElement('slot');
10220
+ contentSlot.name = 'loading-content';
10221
+ content.appendChild(contentSlot);
10222
+ bucket.appendChild(content);
10223
+ const syncContent = () => this._syncBusyBucketContent(bucket);
10224
+ contentSlot.addEventListener('slotchange', syncContent);
10225
+ iconSlot.addEventListener('slotchange', syncContent);
10226
+ syncContent();
10227
+ if (typeof MutationObserver !== 'undefined') {
10228
+ this._clearBusyBucketContentObserver();
10229
+ this._busyBucketContentObserver = new MutationObserver(syncContent);
10230
+ this._busyBucketContentObserver.observe(this, { childList: true, subtree: true, characterData: true });
10231
+ }
10232
+ return bucket;
10233
+ }
10234
+ _appendBusyBucket() {
10235
+ const bucket = this._createBusyBucket();
10236
+ this._optionsContainer.appendChild(bucket);
10237
+ if (this._busyPresentationStartedAt === null)
10238
+ this._busyPresentationStartedAt = Date.now();
10239
+ this._syncBusyBucketContent(bucket);
10240
+ return bucket;
10241
+ }
9931
10242
  _renderOptions() {
10243
+ this._syncBusyPresentation();
10244
+ this._clearBusyBucketContentObserver();
10245
+ this._busyBucket = undefined;
9932
10246
  this._ensureRegistryCurrent();
9933
10247
  const scrollTopBeforeRender = this._optionsContainer.scrollTop;
9934
10248
  this._renderCycleId += 1;
@@ -10117,11 +10431,20 @@ class EnhancedSelect extends HTMLElement {
10117
10431
  this._renderSingleOption(item, itemIndex, getValue, getLabel, fragment);
10118
10432
  }
10119
10433
  const renderedTargets = Array.from(fragment.children);
10120
- this._optionsContainer.appendChild(fragment);
10434
+ const existingBusyBucket = this._optionsContainer.querySelector('.busy-bucket');
10435
+ if (existingBusyBucket)
10436
+ this._optionsContainer.insertBefore(fragment, existingBusyBucket);
10437
+ else
10438
+ this._optionsContainer.appendChild(fragment);
10121
10439
  this._appendMountedVirtualizationTargets(renderedTargets);
10122
10440
  this._syncRenderedOptionAccessibility();
10123
10441
  this._syncLegacyActiveAria();
10124
10442
  if (cursor < filteredIndices.length) {
10443
+ if (this._busyPresentationVisible
10444
+ && this._config.busyBucket.enabled
10445
+ && !this._optionsContainer.querySelector('.busy-bucket')) {
10446
+ this._appendBusyBucket();
10447
+ }
10125
10448
  this._requestLifecycleFrame(renderChunk);
10126
10449
  }
10127
10450
  else {
@@ -10147,25 +10470,12 @@ class EnhancedSelect extends HTMLElement {
10147
10470
  this._appendGuardedBottomSpacer();
10148
10471
  }
10149
10472
  this._refreshMountedVirtualizationScope();
10150
- // Append Busy Indicator if busy
10151
- if (this._state.isBusy && this._config.busyBucket.enabled) {
10152
- const busyBucket = document.createElement('div');
10153
- busyBucket.setAttribute('part', 'loading');
10154
- busyBucket.className = 'busy-bucket';
10155
- if (this._config.busyBucket.showSpinner) {
10156
- const spinner = document.createElement('div');
10157
- spinner.className = 'spinner';
10158
- busyBucket.appendChild(spinner);
10159
- }
10160
- if (this._config.busyBucket.message) {
10161
- const message = document.createElement('div');
10162
- message.textContent = this._config.busyBucket.message;
10163
- busyBucket.appendChild(message);
10164
- }
10165
- this._optionsContainer.appendChild(busyBucket);
10166
- }
10167
- // Append Load More Trigger (Button or Sentinel) if enabled and not busy
10168
- else if ((!this._dataRequestCoordinator || !this._state.isBusy) && this._shouldRenderLoadMoreTrigger()) {
10473
+ if (this._busyPresentationVisible && this._config.busyBucket.enabled) {
10474
+ this._appendBusyBucket();
10475
+ }
10476
+ // The load-more trigger follows logical busy state, not any optional
10477
+ // visual minimum-display hold after a request has already completed.
10478
+ if ((!this._dataRequestCoordinator || !this._state.isBusy) && this._shouldRenderLoadMoreTrigger()) {
10169
10479
  this._addLoadMoreTrigger();
10170
10480
  }
10171
10481
  // Rebuilding the list temporarily removes its spacer geometry. Browsers