@smilodon/core 1.12.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 +70 -4
- package/dist/index.cjs +420 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +420 -46
- 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 +420 -46
- 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 +28 -1
- package/dist/types/src/config/global-config.d.ts +9 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/types.d.ts +10 -0
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -2111,6 +2111,8 @@
|
|
|
2111
2111
|
overflowX: 'hidden',
|
|
2112
2112
|
overflowY: 'auto',
|
|
2113
2113
|
dragScroll: true,
|
|
2114
|
+
scrollToLatestChip: false,
|
|
2115
|
+
scrollToLatestChipBehavior: 'smooth',
|
|
2114
2116
|
},
|
|
2115
2117
|
scrollToSelected: {
|
|
2116
2118
|
enabled: true,
|
|
@@ -2127,8 +2129,10 @@
|
|
|
2127
2129
|
busyBucket: {
|
|
2128
2130
|
enabled: true,
|
|
2129
2131
|
showSpinner: true,
|
|
2132
|
+
showMessage: true,
|
|
2130
2133
|
message: 'Loading...',
|
|
2131
2134
|
minDisplayTime: 200,
|
|
2135
|
+
contentMode: 'append',
|
|
2132
2136
|
},
|
|
2133
2137
|
styles: {
|
|
2134
2138
|
classNames: {},
|
|
@@ -2974,23 +2978,23 @@
|
|
|
2974
2978
|
}
|
|
2975
2979
|
}
|
|
2976
2980
|
_attachEventListeners() {
|
|
2977
|
-
//
|
|
2981
|
+
// One delegated handler survives all SelectOption re-renders. In
|
|
2982
|
+
// particular, SVG descendants of the remove icon must remove the option,
|
|
2983
|
+
// not accidentally activate the surrounding option.
|
|
2978
2984
|
this._container.addEventListener('click', (e) => {
|
|
2979
|
-
|
|
2980
|
-
if (
|
|
2985
|
+
const target = e.target;
|
|
2986
|
+
if (this._removeButton
|
|
2987
|
+
&& target instanceof Node
|
|
2988
|
+
&& this._removeButton.contains(target)) {
|
|
2989
|
+
e.preventDefault();
|
|
2990
|
+
e.stopPropagation();
|
|
2991
|
+
this._handleRemove();
|
|
2981
2992
|
return;
|
|
2982
2993
|
}
|
|
2983
2994
|
if (!this._isDisabledSelectionBlocked()) {
|
|
2984
2995
|
this._handleSelect();
|
|
2985
2996
|
}
|
|
2986
2997
|
});
|
|
2987
|
-
// Remove button handler
|
|
2988
|
-
if (this._removeButton) {
|
|
2989
|
-
this._removeButton.addEventListener('click', (e) => {
|
|
2990
|
-
e.stopPropagation();
|
|
2991
|
-
this._handleRemove();
|
|
2992
|
-
});
|
|
2993
|
-
}
|
|
2994
2998
|
// Keyboard handler
|
|
2995
2999
|
this.addEventListener('keydown', (e) => {
|
|
2996
3000
|
if (this._isDisabledSelectionBlocked())
|
|
@@ -3053,7 +3057,6 @@
|
|
|
3053
3057
|
updateConfig(updates) {
|
|
3054
3058
|
this._config = { ...this._config, ...updates };
|
|
3055
3059
|
this._render();
|
|
3056
|
-
this._attachEventListeners();
|
|
3057
3060
|
}
|
|
3058
3061
|
/**
|
|
3059
3062
|
* Get current configuration
|
|
@@ -4047,6 +4050,10 @@
|
|
|
4047
4050
|
super();
|
|
4048
4051
|
this._dataLoadingConfig = { ...LEGACY_DATA_LOADING_CONFIG };
|
|
4049
4052
|
this._hasLastInvalidDataLoadingCandidate = false;
|
|
4053
|
+
this._busyPresentationVisible = false;
|
|
4054
|
+
this._busyPresentationStartedAt = null;
|
|
4055
|
+
this._busyPresentationGeneration = 0;
|
|
4056
|
+
this._busyPresentationHideTimer = null;
|
|
4050
4057
|
this._engine = new SelectEngineBridge();
|
|
4051
4058
|
this._virtualizationScope = {
|
|
4052
4059
|
dataKeys: [],
|
|
@@ -4064,6 +4071,7 @@
|
|
|
4064
4071
|
intendedRenderKeys: [],
|
|
4065
4072
|
filteredIndexByKey: new Map(),
|
|
4066
4073
|
};
|
|
4074
|
+
this._emptyStateContext = null;
|
|
4067
4075
|
// Null keeps the public/default renderer on its legacy full path. This
|
|
4068
4076
|
// private state is only used by guarded virtualization integration.
|
|
4069
4077
|
this._guardedVirtualWindow = null;
|
|
@@ -4120,6 +4128,10 @@
|
|
|
4120
4128
|
this._pendingFirstRenderMark = false;
|
|
4121
4129
|
this._pendingSearchRenderMark = false;
|
|
4122
4130
|
this._rangeAnchorIndex = null;
|
|
4131
|
+
/** Chip identity is tracked independently of dropdown option positions. */
|
|
4132
|
+
this._lastRenderedChipKeys = null;
|
|
4133
|
+
this._latestChipScrollGeneration = 0;
|
|
4134
|
+
this._latestChipScrollFrame = null;
|
|
4123
4135
|
this._customOptionBoundElements = new WeakSet();
|
|
4124
4136
|
this._customOptionManagedActiveClasses = new WeakMap();
|
|
4125
4137
|
this._customOptionNormalizedIds = new WeakMap();
|
|
@@ -4310,6 +4322,8 @@
|
|
|
4310
4322
|
this._syncListboxAccessibility();
|
|
4311
4323
|
}
|
|
4312
4324
|
disconnectedCallback() {
|
|
4325
|
+
this._cancelLatestChipScroll();
|
|
4326
|
+
this._cancelBusyPresentation();
|
|
4313
4327
|
if (this._dataRequestCoordinator) {
|
|
4314
4328
|
const actions = this._dataRequestCoordinator.disconnect();
|
|
4315
4329
|
this._acknowledgedReady = false;
|
|
@@ -6652,12 +6666,40 @@
|
|
|
6652
6666
|
}
|
|
6653
6667
|
|
|
6654
6668
|
.busy-bucket {
|
|
6669
|
+
display: flex;
|
|
6670
|
+
flex-direction: column;
|
|
6671
|
+
align-items: center;
|
|
6672
|
+
justify-content: center;
|
|
6673
|
+
gap: var(--select-busy-gap, 8px);
|
|
6655
6674
|
padding: var(--select-busy-padding, 20px);
|
|
6656
6675
|
text-align: center;
|
|
6657
6676
|
color: var(--select-busy-color, var(--select-text-muted));
|
|
6658
6677
|
background: var(--select-busy-bg, transparent);
|
|
6659
6678
|
font-size: var(--select-busy-font-size, 0.8667em);
|
|
6660
6679
|
}
|
|
6680
|
+
|
|
6681
|
+
.busy-icon {
|
|
6682
|
+
display: flex;
|
|
6683
|
+
align-items: center;
|
|
6684
|
+
justify-content: center;
|
|
6685
|
+
}
|
|
6686
|
+
|
|
6687
|
+
.busy-icon[hidden] {
|
|
6688
|
+
display: none;
|
|
6689
|
+
}
|
|
6690
|
+
|
|
6691
|
+
.busy-message {
|
|
6692
|
+
text-align: center;
|
|
6693
|
+
}
|
|
6694
|
+
|
|
6695
|
+
.busy-content[hidden] {
|
|
6696
|
+
display: none;
|
|
6697
|
+
}
|
|
6698
|
+
|
|
6699
|
+
.busy-bucket--replace .busy-icon,
|
|
6700
|
+
.busy-bucket--replace .busy-message {
|
|
6701
|
+
display: none;
|
|
6702
|
+
}
|
|
6661
6703
|
|
|
6662
6704
|
.spinner {
|
|
6663
6705
|
display: inline-block;
|
|
@@ -7873,6 +7915,12 @@
|
|
|
7873
7915
|
: delta >= 0
|
|
7874
7916
|
? -1
|
|
7875
7917
|
: selectableIndices.length;
|
|
7918
|
+
// The final selectable option is the keyboard pagination boundary.
|
|
7919
|
+
// Keep the active option stable while the coordinator requests more data.
|
|
7920
|
+
if (delta === 1
|
|
7921
|
+
&& currentPosition === selectableIndices.length - 1
|
|
7922
|
+
&& this._requestKeyboardLoadMore())
|
|
7923
|
+
return;
|
|
7876
7924
|
const nextPosition = Math.max(0, Math.min(selectableIndices.length - 1, basePosition + delta));
|
|
7877
7925
|
const next = selectableIndices[nextPosition];
|
|
7878
7926
|
this._setActive(next);
|
|
@@ -7885,6 +7933,33 @@
|
|
|
7885
7933
|
this._selectRange(anchorIndex, next, { clear: !opts?.toggleKey });
|
|
7886
7934
|
}
|
|
7887
7935
|
}
|
|
7936
|
+
/** Return true only when boundary navigation is held for an in-flight/new page. */
|
|
7937
|
+
_requestKeyboardLoadMore() {
|
|
7938
|
+
if (!this._state.isOpen
|
|
7939
|
+
|| !this._config.infiniteScroll.enabled
|
|
7940
|
+
|| this._dataLoadingConfig.protocol !== 'acknowledged'
|
|
7941
|
+
|| !this._dataRequestCoordinator
|
|
7942
|
+
|| !this._acknowledgedReady)
|
|
7943
|
+
return false;
|
|
7944
|
+
if (this._acknowledgedProjectionPending || this._acknowledgedProjectionSettling)
|
|
7945
|
+
return true;
|
|
7946
|
+
const snapshot = this._dataRequestCoordinator.getSnapshot();
|
|
7947
|
+
if (!snapshot.connected)
|
|
7948
|
+
return false;
|
|
7949
|
+
if (snapshot.busy)
|
|
7950
|
+
return true;
|
|
7951
|
+
if (!snapshot.hasMore
|
|
7952
|
+
|| snapshot.error !== null
|
|
7953
|
+
|| snapshot.resourceLimit !== null
|
|
7954
|
+
|| (snapshot.status !== 'succeeded' && snapshot.status !== 'empty'))
|
|
7955
|
+
return false;
|
|
7956
|
+
// Delegate identity, pagination, and in-flight protection to the coordinator.
|
|
7957
|
+
const actions = this._dataRequestCoordinator.requestLoadMore('manual');
|
|
7958
|
+
if (actions.length === 0)
|
|
7959
|
+
return false;
|
|
7960
|
+
this._dispatchAcknowledgedActions(actions);
|
|
7961
|
+
return true;
|
|
7962
|
+
}
|
|
7888
7963
|
_setActive(index, reason = 'keyboard') {
|
|
7889
7964
|
this._ensureRegistryCurrent();
|
|
7890
7965
|
const record = this._getRecordByIndex(index);
|
|
@@ -8204,6 +8279,19 @@
|
|
|
8204
8279
|
_updateInputDisplay() {
|
|
8205
8280
|
const selectedEntries = this._getSelectedEntries();
|
|
8206
8281
|
const selectedItems = selectedEntries.map(({ item }) => item);
|
|
8282
|
+
const nextKeys = new Set(selectedEntries.map(({ key }) => key));
|
|
8283
|
+
const previousKeys = this._lastRenderedChipKeys;
|
|
8284
|
+
let newlyAddedKey;
|
|
8285
|
+
if (previousKeys) {
|
|
8286
|
+
for (const key of nextKeys) {
|
|
8287
|
+
if (!previousKeys.has(key))
|
|
8288
|
+
newlyAddedKey = key;
|
|
8289
|
+
}
|
|
8290
|
+
}
|
|
8291
|
+
this._lastRenderedChipKeys = nextKeys;
|
|
8292
|
+
const previousChipScrollLeft = this._inputContent.scrollLeft;
|
|
8293
|
+
// Only a newly added selected key can initiate auto-scroll.
|
|
8294
|
+
this._cancelLatestChipScroll();
|
|
8207
8295
|
const getLabel = this._config.serverSide.getLabelFromItem || ((item) => item?.label ?? String(item));
|
|
8208
8296
|
if (selectedItems.length === 0) {
|
|
8209
8297
|
this._input.value = '';
|
|
@@ -8279,8 +8367,87 @@
|
|
|
8279
8367
|
if (this._acknowledgedPendingSearchQuery !== null) {
|
|
8280
8368
|
this._input.value = this._acknowledgedPendingSearchQuery;
|
|
8281
8369
|
}
|
|
8370
|
+
// Recreating the chip DOM must not reset manual scrolling. In particular,
|
|
8371
|
+
// remove/clear, config rerenders, and item refreshes are not scroll intents.
|
|
8372
|
+
if (this._config.selection.mode === 'multi') {
|
|
8373
|
+
this._inputContent.scrollLeft = previousChipScrollLeft;
|
|
8374
|
+
if (newlyAddedKey !== undefined)
|
|
8375
|
+
this._scheduleLatestChipScroll(newlyAddedKey);
|
|
8376
|
+
}
|
|
8282
8377
|
this._syncClearControlState();
|
|
8283
8378
|
}
|
|
8379
|
+
_cancelLatestChipScroll() {
|
|
8380
|
+
this._latestChipScrollGeneration += 1;
|
|
8381
|
+
if (this._latestChipScrollFrame !== null) {
|
|
8382
|
+
cancelAnimationFrame(this._latestChipScrollFrame);
|
|
8383
|
+
this._latestChipScrollFrame = null;
|
|
8384
|
+
}
|
|
8385
|
+
}
|
|
8386
|
+
_scheduleLatestChipScroll(key) {
|
|
8387
|
+
if (!this.isConnected
|
|
8388
|
+
|| this._config.selection.mode !== 'multi'
|
|
8389
|
+
|| this._config.multiSelectDisplay.mode !== 'horizontal'
|
|
8390
|
+
|| this._config.multiSelectDisplay.scrollToLatestChip !== true
|
|
8391
|
+
|| this._config.multiSelectDisplay.overflowX === 'hidden')
|
|
8392
|
+
return;
|
|
8393
|
+
const generation = this._latestChipScrollGeneration;
|
|
8394
|
+
this._latestChipScrollFrame = requestAnimationFrame(() => {
|
|
8395
|
+
this._latestChipScrollFrame = null;
|
|
8396
|
+
if (generation !== this._latestChipScrollGeneration
|
|
8397
|
+
|| !this.isConnected
|
|
8398
|
+
|| this._multiScrollDrag.active
|
|
8399
|
+
|| this._config.selection.mode !== 'multi'
|
|
8400
|
+
|| this._config.multiSelectDisplay.mode !== 'horizontal'
|
|
8401
|
+
|| this._config.multiSelectDisplay.scrollToLatestChip !== true)
|
|
8402
|
+
return;
|
|
8403
|
+
// Match the canonical selected-key sequence, not option indices:
|
|
8404
|
+
// selected items may be reordered or detached from the loaded page.
|
|
8405
|
+
const entries = this._getSelectedEntries();
|
|
8406
|
+
const index = entries.findIndex((entry) => entry.key === key);
|
|
8407
|
+
if (index < 0)
|
|
8408
|
+
return;
|
|
8409
|
+
const chip = this._inputContent.querySelectorAll('.selection-badge')[index];
|
|
8410
|
+
if (!chip)
|
|
8411
|
+
return;
|
|
8412
|
+
const hostBounds = this._inputContent.getBoundingClientRect();
|
|
8413
|
+
const chipBounds = chip.getBoundingClientRect();
|
|
8414
|
+
const leftEdge = hostBounds.left + this._inputContent.clientLeft;
|
|
8415
|
+
const rightEdge = leftEdge + this._inputContent.clientWidth;
|
|
8416
|
+
let delta;
|
|
8417
|
+
if (chip.parentElement === this._inputContent && chip.offsetWidth > 0) {
|
|
8418
|
+
// getBoundingClientRect() includes the chip's entry animation transform.
|
|
8419
|
+
// Use layout dimensions so the scroll target remains correct while the
|
|
8420
|
+
// chip scales into its final size. In RTL layouts, offsetLeft and
|
|
8421
|
+
// scrollLeft are both negative relative to the inline-start origin, so
|
|
8422
|
+
// the same subtraction maps the chip into the viewport's coordinates.
|
|
8423
|
+
const chipLeft = chip.offsetLeft - this._inputContent.scrollLeft;
|
|
8424
|
+
const chipRight = chipLeft + chip.offsetWidth;
|
|
8425
|
+
delta = chipRight > this._inputContent.clientWidth
|
|
8426
|
+
? chipRight - this._inputContent.clientWidth
|
|
8427
|
+
: chipLeft < 0
|
|
8428
|
+
? chipLeft
|
|
8429
|
+
: 0;
|
|
8430
|
+
}
|
|
8431
|
+
else {
|
|
8432
|
+
// DOM test environments without layout use the measurable rectangle.
|
|
8433
|
+
delta = chipBounds.right > rightEdge
|
|
8434
|
+
? chipBounds.right - rightEdge
|
|
8435
|
+
: chipBounds.left < leftEdge
|
|
8436
|
+
? chipBounds.left - leftEdge
|
|
8437
|
+
: 0;
|
|
8438
|
+
}
|
|
8439
|
+
if (Math.abs(delta) < 0.5)
|
|
8440
|
+
return;
|
|
8441
|
+
const reducedMotion = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false;
|
|
8442
|
+
const behavior = reducedMotion ? 'auto' : (this._config.multiSelectDisplay.scrollToLatestChipBehavior ?? 'smooth');
|
|
8443
|
+
if (typeof this._inputContent.scrollBy === 'function') {
|
|
8444
|
+
this._inputContent.scrollBy({ left: delta, behavior });
|
|
8445
|
+
}
|
|
8446
|
+
else {
|
|
8447
|
+
this._inputContent.scrollLeft += delta;
|
|
8448
|
+
}
|
|
8449
|
+
});
|
|
8450
|
+
}
|
|
8284
8451
|
_isActivelyEditingSearchInput() {
|
|
8285
8452
|
return this._config.searchable === true
|
|
8286
8453
|
&& this._state.isOpen
|
|
@@ -8396,6 +8563,8 @@
|
|
|
8396
8563
|
}
|
|
8397
8564
|
}
|
|
8398
8565
|
_setBusy(busy) {
|
|
8566
|
+
if (busy)
|
|
8567
|
+
this._beginBusyPresentation();
|
|
8399
8568
|
this._state.isBusy = busy;
|
|
8400
8569
|
this._syncListboxAccessibility();
|
|
8401
8570
|
// Trigger re-render to show/hide busy indicator
|
|
@@ -8544,12 +8713,13 @@
|
|
|
8544
8713
|
classMap: true,
|
|
8545
8714
|
optionRenderer: true,
|
|
8546
8715
|
groupHeaderRenderer: true,
|
|
8716
|
+
emptyStateSlot: true,
|
|
8547
8717
|
cssCustomProperties: true,
|
|
8548
8718
|
shadowParts: true,
|
|
8549
8719
|
globalStyleMirroring: true,
|
|
8550
8720
|
},
|
|
8551
8721
|
events: {
|
|
8552
|
-
emitted: ['select', 'open', 'close', 'search', 'change', 'loadMore', 'remove', 'clear', 'error', 'diagnostic'],
|
|
8722
|
+
emitted: ['select', 'open', 'close', 'search', 'change', 'loadMore', 'remove', 'clear', 'emptyStateChange', 'error', 'diagnostic'],
|
|
8553
8723
|
diagnosticEvent: true,
|
|
8554
8724
|
},
|
|
8555
8725
|
functionality: {
|
|
@@ -8565,6 +8735,36 @@
|
|
|
8565
8735
|
limitations: this.getKnownLimitations(),
|
|
8566
8736
|
};
|
|
8567
8737
|
}
|
|
8738
|
+
/** Return a detached immutable snapshot of the currently rendered empty state. */
|
|
8739
|
+
getEmptyStateContext() {
|
|
8740
|
+
const context = this._emptyStateContext;
|
|
8741
|
+
return context ? Object.freeze({ query: context.query, reason: context.reason }) : null;
|
|
8742
|
+
}
|
|
8743
|
+
_syncEmptyStateContext(context) {
|
|
8744
|
+
const current = this._emptyStateContext;
|
|
8745
|
+
if (current?.query === context?.query
|
|
8746
|
+
&& current?.reason === context?.reason
|
|
8747
|
+
&& Boolean(current) === Boolean(context))
|
|
8748
|
+
return;
|
|
8749
|
+
this._emptyStateContext = context
|
|
8750
|
+
? Object.freeze({ query: context.query, reason: context.reason })
|
|
8751
|
+
: null;
|
|
8752
|
+
const detail = Object.freeze({ context: this.getEmptyStateContext() });
|
|
8753
|
+
this._emit('emptyStateChange', detail);
|
|
8754
|
+
}
|
|
8755
|
+
_appendEmptyState(context) {
|
|
8756
|
+
const empty = document.createElement('div');
|
|
8757
|
+
empty.setAttribute('part', 'no-results');
|
|
8758
|
+
empty.className = 'empty-state';
|
|
8759
|
+
const slot = document.createElement('slot');
|
|
8760
|
+
slot.name = 'empty-state';
|
|
8761
|
+
slot.appendChild(document.createTextNode(context.reason === 'no-results'
|
|
8762
|
+
? `No results found for "${context.query}"`
|
|
8763
|
+
: 'No options available'));
|
|
8764
|
+
empty.appendChild(slot);
|
|
8765
|
+
this._optionsContainer.appendChild(empty);
|
|
8766
|
+
this._syncEmptyStateContext(context);
|
|
8767
|
+
}
|
|
8568
8768
|
_emitChange() {
|
|
8569
8769
|
const selectedEntries = this._getSelectedEntries();
|
|
8570
8770
|
const selectedItems = selectedEntries.map(({ item }) => item);
|
|
@@ -9576,6 +9776,7 @@
|
|
|
9576
9776
|
_dispatchAcknowledgedActions(actions) {
|
|
9577
9777
|
for (const action of actions) {
|
|
9578
9778
|
if (action.type === 'cancel') {
|
|
9779
|
+
this._cancelBusyPresentation();
|
|
9579
9780
|
this._dispatchAcknowledgedEvent('dataRequestCancel', action.notification);
|
|
9580
9781
|
try {
|
|
9581
9782
|
this._dataRequestCancelCallback?.(action.notification);
|
|
@@ -9600,6 +9801,7 @@
|
|
|
9600
9801
|
this._state.preserveScrollPosition = false;
|
|
9601
9802
|
this._state.isSearching = true;
|
|
9602
9803
|
}
|
|
9804
|
+
this._beginBusyPresentation();
|
|
9603
9805
|
this._state.isBusy = true;
|
|
9604
9806
|
this._acknowledgedLastRequest = request;
|
|
9605
9807
|
this._syncListboxAccessibility();
|
|
@@ -9727,9 +9929,28 @@
|
|
|
9727
9929
|
throw new Error('Acknowledged snapshot render was superseded before completion');
|
|
9728
9930
|
this._state.isBusy = snapshot.busy;
|
|
9729
9931
|
if (!snapshot.busy) {
|
|
9730
|
-
this.
|
|
9731
|
-
|
|
9732
|
-
this.
|
|
9932
|
+
this._syncBusyPresentation();
|
|
9933
|
+
const shouldReconcileEmptyState = snapshot.status === 'exhausted'
|
|
9934
|
+
&& this._renderPlan.filteredKeys.length === 0;
|
|
9935
|
+
if (shouldReconcileEmptyState) {
|
|
9936
|
+
// The first projection rendered while logically busy, so the empty
|
|
9937
|
+
// state was intentionally suppressed. Reconcile only this terminal
|
|
9938
|
+
// empty case after settlement; keep any minimum-duration busy
|
|
9939
|
+
// presentation and its timer intact.
|
|
9940
|
+
this._renderOptions();
|
|
9941
|
+
const emptyStateRenderCycleId = this._renderCycleId;
|
|
9942
|
+
const emptyStateRenderCompleted = await this._waitForRenderCycle(emptyStateRenderCycleId);
|
|
9943
|
+
if (!emptyStateRenderCompleted) {
|
|
9944
|
+
throw new Error('Acknowledged empty-state render was superseded before completion');
|
|
9945
|
+
}
|
|
9946
|
+
}
|
|
9947
|
+
else {
|
|
9948
|
+
if (!this._busyPresentationVisible) {
|
|
9949
|
+
this._optionsContainer.querySelector('.busy-bucket')?.remove();
|
|
9950
|
+
}
|
|
9951
|
+
if (this._shouldRenderLoadMoreTrigger())
|
|
9952
|
+
this._addLoadMoreTrigger();
|
|
9953
|
+
}
|
|
9733
9954
|
}
|
|
9734
9955
|
this._optionsContainer.scrollTop = this._acknowledgedProjectionScrollTop;
|
|
9735
9956
|
this._syncListboxAccessibility();
|
|
@@ -10045,7 +10266,166 @@
|
|
|
10045
10266
|
_refreshVirtualizationScope(filteredIndices) {
|
|
10046
10267
|
this._virtualizationScope = this._deriveVirtualizationScope(filteredIndices);
|
|
10047
10268
|
}
|
|
10269
|
+
_clearBusyPresentationHideTimer() {
|
|
10270
|
+
if (this._busyPresentationHideTimer === null)
|
|
10271
|
+
return;
|
|
10272
|
+
window.clearTimeout(this._busyPresentationHideTimer);
|
|
10273
|
+
this._lifecycleTimers.delete(this._busyPresentationHideTimer);
|
|
10274
|
+
this._busyPresentationHideTimer = null;
|
|
10275
|
+
}
|
|
10276
|
+
_beginBusyPresentation() {
|
|
10277
|
+
this._busyPresentationGeneration += 1;
|
|
10278
|
+
this._clearBusyPresentationHideTimer();
|
|
10279
|
+
this._busyPresentationVisible = this._config.busyBucket.enabled;
|
|
10280
|
+
this._busyPresentationStartedAt = Date.now();
|
|
10281
|
+
}
|
|
10282
|
+
_syncBusyPresentation() {
|
|
10283
|
+
if (!this._config.busyBucket.enabled) {
|
|
10284
|
+
this._cancelBusyPresentation();
|
|
10285
|
+
return;
|
|
10286
|
+
}
|
|
10287
|
+
if (this._state.isBusy) {
|
|
10288
|
+
if (!this._busyPresentationVisible || this._busyPresentationHideTimer !== null) {
|
|
10289
|
+
this._beginBusyPresentation();
|
|
10290
|
+
}
|
|
10291
|
+
return;
|
|
10292
|
+
}
|
|
10293
|
+
if (!this._busyPresentationVisible || this._busyPresentationHideTimer !== null)
|
|
10294
|
+
return;
|
|
10295
|
+
const configuredMinimum = Number(this._config.busyBucket.minDisplayTime ?? 0);
|
|
10296
|
+
const minimum = Number.isFinite(configuredMinimum) ? Math.max(0, configuredMinimum) : 0;
|
|
10297
|
+
if (this._busyPresentationStartedAt === null)
|
|
10298
|
+
this._busyPresentationStartedAt = Date.now();
|
|
10299
|
+
const shownAt = this._busyPresentationStartedAt;
|
|
10300
|
+
const remaining = minimum - Math.max(0, Date.now() - shownAt);
|
|
10301
|
+
if (remaining <= 0) {
|
|
10302
|
+
this._busyPresentationGeneration += 1;
|
|
10303
|
+
this._busyPresentationVisible = false;
|
|
10304
|
+
this._busyPresentationStartedAt = null;
|
|
10305
|
+
return;
|
|
10306
|
+
}
|
|
10307
|
+
const generation = this._busyPresentationGeneration;
|
|
10308
|
+
this._busyPresentationHideTimer = this._setLifecycleTimeout(() => {
|
|
10309
|
+
if (generation !== this._busyPresentationGeneration || this._state.isBusy)
|
|
10310
|
+
return;
|
|
10311
|
+
this._busyPresentationHideTimer = null;
|
|
10312
|
+
this._busyPresentationVisible = false;
|
|
10313
|
+
this._busyPresentationStartedAt = null;
|
|
10314
|
+
this._busyBucket = undefined;
|
|
10315
|
+
this._clearBusyBucketContentObserver();
|
|
10316
|
+
this._renderOptions();
|
|
10317
|
+
}, remaining);
|
|
10318
|
+
}
|
|
10319
|
+
_clearBusyBucketContentObserver() {
|
|
10320
|
+
this._busyBucketContentObserver?.disconnect();
|
|
10321
|
+
this._busyBucketContentObserver = undefined;
|
|
10322
|
+
}
|
|
10323
|
+
_cancelBusyPresentation() {
|
|
10324
|
+
this._busyPresentationGeneration += 1;
|
|
10325
|
+
this._clearBusyPresentationHideTimer();
|
|
10326
|
+
this._busyPresentationVisible = false;
|
|
10327
|
+
this._busyPresentationStartedAt = null;
|
|
10328
|
+
this._clearBusyBucketContentObserver();
|
|
10329
|
+
this._busyBucket = undefined;
|
|
10330
|
+
this._optionsContainer?.querySelector('.busy-bucket')?.remove();
|
|
10331
|
+
}
|
|
10332
|
+
_hasAccessibleBusyContent(nodes) {
|
|
10333
|
+
return nodes.some((node) => {
|
|
10334
|
+
if (node.nodeType === Node.TEXT_NODE)
|
|
10335
|
+
return Boolean(node.textContent?.trim());
|
|
10336
|
+
if (!(node instanceof Element))
|
|
10337
|
+
return false;
|
|
10338
|
+
if (node.hasAttribute('hidden')
|
|
10339
|
+
|| node.hasAttribute('inert')
|
|
10340
|
+
|| node.getAttribute('aria-hidden')?.toLowerCase() === 'true')
|
|
10341
|
+
return false;
|
|
10342
|
+
if (['aria-label', 'aria-labelledby', 'alt', 'title'].some((name) => Boolean(node.getAttribute(name)?.trim()))) {
|
|
10343
|
+
return true;
|
|
10344
|
+
}
|
|
10345
|
+
return this._hasAccessibleBusyContent(Array.from(node.childNodes));
|
|
10346
|
+
});
|
|
10347
|
+
}
|
|
10348
|
+
_syncBusyBucketContent(bucket) {
|
|
10349
|
+
if (bucket !== this._busyBucket)
|
|
10350
|
+
return;
|
|
10351
|
+
const contentSlot = bucket.querySelector('slot[name="loading-content"]');
|
|
10352
|
+
const iconSlot = bucket.querySelector('slot[name="loading-icon"]');
|
|
10353
|
+
if (!contentSlot || !iconSlot)
|
|
10354
|
+
return;
|
|
10355
|
+
const contentNodes = contentSlot.assignedNodes({ flatten: true });
|
|
10356
|
+
const iconNodes = iconSlot.assignedNodes({ flatten: true });
|
|
10357
|
+
const hasContent = contentNodes.length > 0;
|
|
10358
|
+
const hasAccessibleContent = this._hasAccessibleBusyContent(contentNodes);
|
|
10359
|
+
const icon = bucket.querySelector('.busy-icon');
|
|
10360
|
+
icon?.toggleAttribute('hidden', this._config.busyBucket.showSpinner === false && iconNodes.length === 0);
|
|
10361
|
+
const content = bucket.querySelector('.busy-content');
|
|
10362
|
+
content?.toggleAttribute('hidden', !hasContent);
|
|
10363
|
+
bucket.classList.toggle('busy-bucket--replace', this._config.busyBucket.contentMode === 'replace' && hasAccessibleContent);
|
|
10364
|
+
const message = bucket.querySelector('.busy-message');
|
|
10365
|
+
if (message) {
|
|
10366
|
+
const needsAccessibleFallback = this._config.busyBucket.contentMode === 'replace' && !hasAccessibleContent;
|
|
10367
|
+
message.toggleAttribute('hidden', this._config.busyBucket.showMessage === false && !needsAccessibleFallback);
|
|
10368
|
+
if (needsAccessibleFallback && !message.textContent?.trim()) {
|
|
10369
|
+
message.textContent = this._config.busyBucket.message || 'Loading...';
|
|
10370
|
+
}
|
|
10371
|
+
}
|
|
10372
|
+
}
|
|
10373
|
+
_createBusyBucket() {
|
|
10374
|
+
const bucket = document.createElement('div');
|
|
10375
|
+
bucket.setAttribute('part', 'loading');
|
|
10376
|
+
bucket.className = 'busy-bucket';
|
|
10377
|
+
this._busyBucket = bucket;
|
|
10378
|
+
const icon = document.createElement('div');
|
|
10379
|
+
icon.className = 'busy-icon';
|
|
10380
|
+
icon.setAttribute('part', 'loading-icon');
|
|
10381
|
+
icon.setAttribute('aria-hidden', 'true');
|
|
10382
|
+
const iconSlot = document.createElement('slot');
|
|
10383
|
+
iconSlot.name = 'loading-icon';
|
|
10384
|
+
if (this._config.busyBucket.showSpinner !== false) {
|
|
10385
|
+
const spinner = document.createElement('div');
|
|
10386
|
+
spinner.className = 'spinner';
|
|
10387
|
+
spinner.setAttribute('part', 'loading-spinner');
|
|
10388
|
+
spinner.setAttribute('aria-hidden', 'true');
|
|
10389
|
+
iconSlot.appendChild(spinner);
|
|
10390
|
+
}
|
|
10391
|
+
icon.appendChild(iconSlot);
|
|
10392
|
+
bucket.appendChild(icon);
|
|
10393
|
+
const message = document.createElement('div');
|
|
10394
|
+
message.className = 'busy-message';
|
|
10395
|
+
message.setAttribute('part', 'loading-message');
|
|
10396
|
+
message.textContent = this._config.busyBucket.message ?? 'Loading...';
|
|
10397
|
+
message.toggleAttribute('hidden', this._config.busyBucket.showMessage === false);
|
|
10398
|
+
bucket.appendChild(message);
|
|
10399
|
+
const content = document.createElement('div');
|
|
10400
|
+
content.className = 'busy-content';
|
|
10401
|
+
content.setAttribute('part', 'loading-content');
|
|
10402
|
+
const contentSlot = document.createElement('slot');
|
|
10403
|
+
contentSlot.name = 'loading-content';
|
|
10404
|
+
content.appendChild(contentSlot);
|
|
10405
|
+
bucket.appendChild(content);
|
|
10406
|
+
const syncContent = () => this._syncBusyBucketContent(bucket);
|
|
10407
|
+
contentSlot.addEventListener('slotchange', syncContent);
|
|
10408
|
+
iconSlot.addEventListener('slotchange', syncContent);
|
|
10409
|
+
syncContent();
|
|
10410
|
+
if (typeof MutationObserver !== 'undefined') {
|
|
10411
|
+
this._clearBusyBucketContentObserver();
|
|
10412
|
+
this._busyBucketContentObserver = new MutationObserver(syncContent);
|
|
10413
|
+
this._busyBucketContentObserver.observe(this, { childList: true, subtree: true, characterData: true });
|
|
10414
|
+
}
|
|
10415
|
+
return bucket;
|
|
10416
|
+
}
|
|
10417
|
+
_appendBusyBucket() {
|
|
10418
|
+
const bucket = this._createBusyBucket();
|
|
10419
|
+
this._optionsContainer.appendChild(bucket);
|
|
10420
|
+
if (this._busyPresentationStartedAt === null)
|
|
10421
|
+
this._busyPresentationStartedAt = Date.now();
|
|
10422
|
+
this._syncBusyBucketContent(bucket);
|
|
10423
|
+
return bucket;
|
|
10424
|
+
}
|
|
10048
10425
|
_renderOptions() {
|
|
10426
|
+
this._syncBusyPresentation();
|
|
10427
|
+
this._clearBusyBucketContentObserver();
|
|
10428
|
+
this._busyBucket = undefined;
|
|
10049
10429
|
this._ensureRegistryCurrent();
|
|
10050
10430
|
const scrollTopBeforeRender = this._optionsContainer.scrollTop;
|
|
10051
10431
|
this._renderCycleId += 1;
|
|
@@ -10065,6 +10445,7 @@
|
|
|
10065
10445
|
this._optionsContainer.innerHTML = '';
|
|
10066
10446
|
let filteredIndicesForScope = [];
|
|
10067
10447
|
let guardedScrollTopToRestore = null;
|
|
10448
|
+
let renderedEmptyStateContext = null;
|
|
10068
10449
|
// Ensure dropdown only contains options container (cleanup legacy direct children)
|
|
10069
10450
|
// We need to preserve optionsContainer, so we can't just clear dropdown.innerHTML
|
|
10070
10451
|
// But we can check if there are other children and remove them
|
|
@@ -10088,6 +10469,7 @@
|
|
|
10088
10469
|
searching.setAttribute('part', 'loading');
|
|
10089
10470
|
searching.textContent = 'Searching...';
|
|
10090
10471
|
this._optionsContainer.appendChild(searching);
|
|
10472
|
+
this._syncEmptyStateContext(null);
|
|
10091
10473
|
this._resolveRenderCycle(renderCycleId, true);
|
|
10092
10474
|
return;
|
|
10093
10475
|
}
|
|
@@ -10191,17 +10573,11 @@
|
|
|
10191
10573
|
const filteredIndices = this._renderPlan.filteredIndices;
|
|
10192
10574
|
this._refreshVirtualizationScope(filteredIndicesForScope);
|
|
10193
10575
|
this._appendGuardedTopSpacer();
|
|
10194
|
-
if (
|
|
10195
|
-
|
|
10196
|
-
|
|
10197
|
-
|
|
10198
|
-
|
|
10199
|
-
empty.textContent = `No results found for "${this._state.searchQuery}"`;
|
|
10200
|
-
}
|
|
10201
|
-
else {
|
|
10202
|
-
empty.textContent = 'No options available';
|
|
10203
|
-
}
|
|
10204
|
-
this._optionsContainer.appendChild(empty);
|
|
10576
|
+
if (this._renderPlan.filteredKeys.length === 0 && !this._state.isBusy) {
|
|
10577
|
+
renderedEmptyStateContext = this._state.searchQuery
|
|
10578
|
+
? { query: this._state.searchQuery, reason: 'no-results' }
|
|
10579
|
+
: { query: '', reason: 'no-options' };
|
|
10580
|
+
this._appendEmptyState(renderedEmptyStateContext);
|
|
10205
10581
|
}
|
|
10206
10582
|
else {
|
|
10207
10583
|
const shouldIncrementalRender = !this._guardedVirtualizer
|
|
@@ -10234,11 +10610,20 @@
|
|
|
10234
10610
|
this._renderSingleOption(item, itemIndex, getValue, getLabel, fragment);
|
|
10235
10611
|
}
|
|
10236
10612
|
const renderedTargets = Array.from(fragment.children);
|
|
10237
|
-
this._optionsContainer.
|
|
10613
|
+
const existingBusyBucket = this._optionsContainer.querySelector('.busy-bucket');
|
|
10614
|
+
if (existingBusyBucket)
|
|
10615
|
+
this._optionsContainer.insertBefore(fragment, existingBusyBucket);
|
|
10616
|
+
else
|
|
10617
|
+
this._optionsContainer.appendChild(fragment);
|
|
10238
10618
|
this._appendMountedVirtualizationTargets(renderedTargets);
|
|
10239
10619
|
this._syncRenderedOptionAccessibility();
|
|
10240
10620
|
this._syncLegacyActiveAria();
|
|
10241
10621
|
if (cursor < filteredIndices.length) {
|
|
10622
|
+
if (this._busyPresentationVisible
|
|
10623
|
+
&& this._config.busyBucket.enabled
|
|
10624
|
+
&& !this._optionsContainer.querySelector('.busy-bucket')) {
|
|
10625
|
+
this._appendBusyBucket();
|
|
10626
|
+
}
|
|
10242
10627
|
this._requestLifecycleFrame(renderChunk);
|
|
10243
10628
|
}
|
|
10244
10629
|
else {
|
|
@@ -10254,6 +10639,7 @@
|
|
|
10254
10639
|
}
|
|
10255
10640
|
};
|
|
10256
10641
|
renderChunk();
|
|
10642
|
+
this._syncEmptyStateContext(null);
|
|
10257
10643
|
return;
|
|
10258
10644
|
}
|
|
10259
10645
|
filteredIndices.forEach((itemIndex) => {
|
|
@@ -10264,25 +10650,12 @@
|
|
|
10264
10650
|
this._appendGuardedBottomSpacer();
|
|
10265
10651
|
}
|
|
10266
10652
|
this._refreshMountedVirtualizationScope();
|
|
10267
|
-
|
|
10268
|
-
|
|
10269
|
-
|
|
10270
|
-
|
|
10271
|
-
|
|
10272
|
-
|
|
10273
|
-
const spinner = document.createElement('div');
|
|
10274
|
-
spinner.className = 'spinner';
|
|
10275
|
-
busyBucket.appendChild(spinner);
|
|
10276
|
-
}
|
|
10277
|
-
if (this._config.busyBucket.message) {
|
|
10278
|
-
const message = document.createElement('div');
|
|
10279
|
-
message.textContent = this._config.busyBucket.message;
|
|
10280
|
-
busyBucket.appendChild(message);
|
|
10281
|
-
}
|
|
10282
|
-
this._optionsContainer.appendChild(busyBucket);
|
|
10283
|
-
}
|
|
10284
|
-
// Append Load More Trigger (Button or Sentinel) if enabled and not busy
|
|
10285
|
-
else if ((!this._dataRequestCoordinator || !this._state.isBusy) && this._shouldRenderLoadMoreTrigger()) {
|
|
10653
|
+
if (this._busyPresentationVisible && this._config.busyBucket.enabled) {
|
|
10654
|
+
this._appendBusyBucket();
|
|
10655
|
+
}
|
|
10656
|
+
// The load-more trigger follows logical busy state, not any optional
|
|
10657
|
+
// visual minimum-display hold after a request has already completed.
|
|
10658
|
+
if ((!this._dataRequestCoordinator || !this._state.isBusy) && this._shouldRenderLoadMoreTrigger()) {
|
|
10286
10659
|
this._addLoadMoreTrigger();
|
|
10287
10660
|
}
|
|
10288
10661
|
// Rebuilding the list temporarily removes its spacer geometry. Browsers
|
|
@@ -10291,6 +10664,7 @@
|
|
|
10291
10664
|
if (guardedScrollTopToRestore !== null) {
|
|
10292
10665
|
this._optionsContainer.scrollTop = guardedScrollTopToRestore;
|
|
10293
10666
|
}
|
|
10667
|
+
this._syncEmptyStateContext(renderedEmptyStateContext);
|
|
10294
10668
|
this._syncRenderedOptionAccessibility();
|
|
10295
10669
|
this._syncLegacyActiveAria();
|
|
10296
10670
|
this._syncGuardedOptionResizeTargets();
|