@smilodon/core 1.12.0 → 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.
@@ -389,7 +420,7 @@ const selectedItems = select.getSelectedItems();
389
420
 
390
421
  ## Advanced Usage
391
422
 
392
- ### Dropdown enter and exit animations (Core 1.12.0 release candidate)
423
+ ### Dropdown enter and exit animations (Core 1.12.0)
393
424
 
394
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`.
395
426
 
@@ -408,9 +439,9 @@ enhanced-select.instant {
408
439
 
409
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.
410
441
 
411
- **Qualification:** merged and locally qualified 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. This README is packaged with Core; check the npm registry for the availability of the version you intend to install. See [implementation and qualification notes](../../docs/architecture/DROPDOWN-EXIT-ANIMATION.md).
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).
412
443
 
413
- For the related fixes, stable option-hover geometry shipped earlier in Core `1.11.0` ([Issue #77](https://github.com/navidrezadoost/Smilodon/issues/77)); custom active-class reconciliation is documented [above](#active-state-on-custom-option-roots) and is included in the `1.12.0` candidate. See the [release checklist](../../docs/releases/CORE-1.12.0-RELEASE.md) for exact package scope and publication status.
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).
414
445
 
415
446
  ### Custom Styling
416
447
 
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: [],
@@ -4306,6 +4312,7 @@ class EnhancedSelect extends HTMLElement {
4306
4312
  this._syncListboxAccessibility();
4307
4313
  }
4308
4314
  disconnectedCallback() {
4315
+ this._cancelBusyPresentation();
4309
4316
  if (this._dataRequestCoordinator) {
4310
4317
  const actions = this._dataRequestCoordinator.disconnect();
4311
4318
  this._acknowledgedReady = false;
@@ -6648,12 +6655,40 @@ class EnhancedSelect extends HTMLElement {
6648
6655
  }
6649
6656
 
6650
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);
6651
6663
  padding: var(--select-busy-padding, 20px);
6652
6664
  text-align: center;
6653
6665
  color: var(--select-busy-color, var(--select-text-muted));
6654
6666
  background: var(--select-busy-bg, transparent);
6655
6667
  font-size: var(--select-busy-font-size, 0.8667em);
6656
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
+ }
6657
6692
 
6658
6693
  .spinner {
6659
6694
  display: inline-block;
@@ -8392,6 +8427,8 @@ class EnhancedSelect extends HTMLElement {
8392
8427
  }
8393
8428
  }
8394
8429
  _setBusy(busy) {
8430
+ if (busy)
8431
+ this._beginBusyPresentation();
8395
8432
  this._state.isBusy = busy;
8396
8433
  this._syncListboxAccessibility();
8397
8434
  // Trigger re-render to show/hide busy indicator
@@ -9572,6 +9609,7 @@ class EnhancedSelect extends HTMLElement {
9572
9609
  _dispatchAcknowledgedActions(actions) {
9573
9610
  for (const action of actions) {
9574
9611
  if (action.type === 'cancel') {
9612
+ this._cancelBusyPresentation();
9575
9613
  this._dispatchAcknowledgedEvent('dataRequestCancel', action.notification);
9576
9614
  try {
9577
9615
  this._dataRequestCancelCallback?.(action.notification);
@@ -9596,6 +9634,7 @@ class EnhancedSelect extends HTMLElement {
9596
9634
  this._state.preserveScrollPosition = false;
9597
9635
  this._state.isSearching = true;
9598
9636
  }
9637
+ this._beginBusyPresentation();
9599
9638
  this._state.isBusy = true;
9600
9639
  this._acknowledgedLastRequest = request;
9601
9640
  this._syncListboxAccessibility();
@@ -9723,7 +9762,10 @@ class EnhancedSelect extends HTMLElement {
9723
9762
  throw new Error('Acknowledged snapshot render was superseded before completion');
9724
9763
  this._state.isBusy = snapshot.busy;
9725
9764
  if (!snapshot.busy) {
9726
- this._optionsContainer.querySelector('.busy-bucket')?.remove();
9765
+ this._syncBusyPresentation();
9766
+ if (!this._busyPresentationVisible) {
9767
+ this._optionsContainer.querySelector('.busy-bucket')?.remove();
9768
+ }
9727
9769
  if (this._shouldRenderLoadMoreTrigger())
9728
9770
  this._addLoadMoreTrigger();
9729
9771
  }
@@ -10041,7 +10083,166 @@ class EnhancedSelect extends HTMLElement {
10041
10083
  _refreshVirtualizationScope(filteredIndices) {
10042
10084
  this._virtualizationScope = this._deriveVirtualizationScope(filteredIndices);
10043
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
+ }
10044
10242
  _renderOptions() {
10243
+ this._syncBusyPresentation();
10244
+ this._clearBusyBucketContentObserver();
10245
+ this._busyBucket = undefined;
10045
10246
  this._ensureRegistryCurrent();
10046
10247
  const scrollTopBeforeRender = this._optionsContainer.scrollTop;
10047
10248
  this._renderCycleId += 1;
@@ -10230,11 +10431,20 @@ class EnhancedSelect extends HTMLElement {
10230
10431
  this._renderSingleOption(item, itemIndex, getValue, getLabel, fragment);
10231
10432
  }
10232
10433
  const renderedTargets = Array.from(fragment.children);
10233
- 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);
10234
10439
  this._appendMountedVirtualizationTargets(renderedTargets);
10235
10440
  this._syncRenderedOptionAccessibility();
10236
10441
  this._syncLegacyActiveAria();
10237
10442
  if (cursor < filteredIndices.length) {
10443
+ if (this._busyPresentationVisible
10444
+ && this._config.busyBucket.enabled
10445
+ && !this._optionsContainer.querySelector('.busy-bucket')) {
10446
+ this._appendBusyBucket();
10447
+ }
10238
10448
  this._requestLifecycleFrame(renderChunk);
10239
10449
  }
10240
10450
  else {
@@ -10260,25 +10470,12 @@ class EnhancedSelect extends HTMLElement {
10260
10470
  this._appendGuardedBottomSpacer();
10261
10471
  }
10262
10472
  this._refreshMountedVirtualizationScope();
10263
- // Append Busy Indicator if busy
10264
- if (this._state.isBusy && this._config.busyBucket.enabled) {
10265
- const busyBucket = document.createElement('div');
10266
- busyBucket.setAttribute('part', 'loading');
10267
- busyBucket.className = 'busy-bucket';
10268
- if (this._config.busyBucket.showSpinner) {
10269
- const spinner = document.createElement('div');
10270
- spinner.className = 'spinner';
10271
- busyBucket.appendChild(spinner);
10272
- }
10273
- if (this._config.busyBucket.message) {
10274
- const message = document.createElement('div');
10275
- message.textContent = this._config.busyBucket.message;
10276
- busyBucket.appendChild(message);
10277
- }
10278
- this._optionsContainer.appendChild(busyBucket);
10279
- }
10280
- // Append Load More Trigger (Button or Sentinel) if enabled and not busy
10281
- 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()) {
10282
10479
  this._addLoadMoreTrigger();
10283
10480
  }
10284
10481
  // Rebuilding the list temporarily removes its spacer geometry. Browsers