@smilodon/core 1.21.0 → 1.22.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 +6 -0
- package/dist/index.cjs +148 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +148 -21
- 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 +148 -21
- 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 +4 -0
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -2944,6 +2944,15 @@
|
|
|
2944
2944
|
pointer-events: none;
|
|
2945
2945
|
}
|
|
2946
2946
|
|
|
2947
|
+
.remove-button-icon > [data-smilodon-fallback-icon],
|
|
2948
|
+
.remove-button-icon > [data-smilodon-react-icon-root] {
|
|
2949
|
+
display: contents;
|
|
2950
|
+
}
|
|
2951
|
+
|
|
2952
|
+
.remove-button-icon[data-smilodon-icon-owner="react"] > [data-smilodon-fallback-icon] {
|
|
2953
|
+
display: none;
|
|
2954
|
+
}
|
|
2955
|
+
|
|
2947
2956
|
.remove-button-icon svg {
|
|
2948
2957
|
width: 100%;
|
|
2949
2958
|
height: 100%;
|
|
@@ -3066,15 +3075,20 @@
|
|
|
3066
3075
|
const removeIcon = document.createElement('span');
|
|
3067
3076
|
removeIcon.className = 'remove-button-icon';
|
|
3068
3077
|
removeIcon.setAttribute('part', 'chip-remove-icon');
|
|
3078
|
+
const fallbackIcon = document.createElement('span');
|
|
3079
|
+
fallbackIcon.setAttribute('data-smilodon-fallback-icon', '');
|
|
3080
|
+
const portalRoot = document.createElement('span');
|
|
3081
|
+
portalRoot.setAttribute('data-smilodon-react-icon-root', '');
|
|
3069
3082
|
const iconMarkup = this._config.removeButtonIcon && this._config.removeButtonIcon.trim()
|
|
3070
3083
|
? this._config.removeButtonIcon
|
|
3071
3084
|
: '×';
|
|
3072
3085
|
if (iconMarkup.trim().startsWith('<')) {
|
|
3073
|
-
|
|
3086
|
+
fallbackIcon.innerHTML = iconMarkup;
|
|
3074
3087
|
}
|
|
3075
3088
|
else {
|
|
3076
|
-
|
|
3089
|
+
fallbackIcon.textContent = iconMarkup;
|
|
3077
3090
|
}
|
|
3091
|
+
removeIcon.append(fallbackIcon, portalRoot);
|
|
3078
3092
|
this._removeButton.appendChild(removeIcon);
|
|
3079
3093
|
this._container.appendChild(this._removeButton);
|
|
3080
3094
|
}
|
|
@@ -4688,6 +4702,7 @@
|
|
|
4688
4702
|
this._inputContent = this._createInputContent();
|
|
4689
4703
|
this._input = this._createInput();
|
|
4690
4704
|
this._selectedLabelTooltip = this._createSelectedLabelTooltip();
|
|
4705
|
+
this._selectedLabelTooltipTextMeasure = this._createSelectedLabelTooltipTextMeasure();
|
|
4691
4706
|
this._arrowContainer = this._createArrowContainer();
|
|
4692
4707
|
this._clearControl = this._createClearControl();
|
|
4693
4708
|
this._dropdown = this._createDropdown();
|
|
@@ -4707,6 +4722,9 @@
|
|
|
4707
4722
|
}
|
|
4708
4723
|
connectedCallback() {
|
|
4709
4724
|
this._hasEverConnected = true;
|
|
4725
|
+
// Adapter capability marker without adding a field to the public class
|
|
4726
|
+
// declaration. React-node remove icons require the isolated root contract.
|
|
4727
|
+
this.setAttribute('data-smilodon-react-icon-portals', 'isolated-v1');
|
|
4710
4728
|
// register instance
|
|
4711
4729
|
EnhancedSelect._instances.add(this);
|
|
4712
4730
|
this._runEngineEffects(this._engine.dispatch({ type: 'CONNECT' }));
|
|
@@ -4714,6 +4732,7 @@
|
|
|
4714
4732
|
this._connectionController?.abort();
|
|
4715
4733
|
this._connectionController = new AbortController();
|
|
4716
4734
|
this._observeSelectedLabelTooltipTargets();
|
|
4735
|
+
this._inputContent.addEventListener('scroll', this._scheduleSelectedLabelTooltipMeasure, { passive: true });
|
|
4717
4736
|
document.addEventListener('pointerdown', this._onDocumentPointerDown, {
|
|
4718
4737
|
signal: this._connectionController.signal,
|
|
4719
4738
|
});
|
|
@@ -4797,6 +4816,7 @@
|
|
|
4797
4816
|
this._handleClose('disconnect');
|
|
4798
4817
|
}
|
|
4799
4818
|
this._runEngineEffects(this._engine.dispatch({ type: 'DISCONNECT' }));
|
|
4819
|
+
this._inputContent.removeEventListener('scroll', this._scheduleSelectedLabelTooltipMeasure);
|
|
4800
4820
|
this._connectionController?.abort();
|
|
4801
4821
|
this._connectionController = undefined;
|
|
4802
4822
|
this._hideSelectedLabelTooltip(true);
|
|
@@ -5737,12 +5757,25 @@
|
|
|
5737
5757
|
}
|
|
5738
5758
|
_setIconContent(target, markup, fallback) {
|
|
5739
5759
|
const content = markup && markup.trim() ? markup : fallback;
|
|
5740
|
-
target.
|
|
5760
|
+
let fallbackTarget = target.querySelector(':scope > [data-smilodon-fallback-icon]');
|
|
5761
|
+
if (!fallbackTarget) {
|
|
5762
|
+
fallbackTarget = document.createElement('span');
|
|
5763
|
+
fallbackTarget.setAttribute('data-smilodon-fallback-icon', '');
|
|
5764
|
+
target.prepend(fallbackTarget);
|
|
5765
|
+
}
|
|
5766
|
+
if (!target.querySelector(':scope > [data-smilodon-react-icon-root]')) {
|
|
5767
|
+
const portalRoot = document.createElement('span');
|
|
5768
|
+
portalRoot.setAttribute('data-smilodon-react-icon-root', '');
|
|
5769
|
+
target.append(portalRoot);
|
|
5770
|
+
}
|
|
5771
|
+
// Only Core's fallback subtree is replaceable. React may reconcile a
|
|
5772
|
+
// separate portal root beneath this stable icon target.
|
|
5773
|
+
fallbackTarget.replaceChildren();
|
|
5741
5774
|
if (content.trim().startsWith('<')) {
|
|
5742
|
-
|
|
5775
|
+
fallbackTarget.innerHTML = content;
|
|
5743
5776
|
return;
|
|
5744
5777
|
}
|
|
5745
|
-
|
|
5778
|
+
fallbackTarget.textContent = content;
|
|
5746
5779
|
}
|
|
5747
5780
|
_syncInputContainerMode() {
|
|
5748
5781
|
if (!this._inputContainer || !this._input)
|
|
@@ -5965,6 +5998,27 @@
|
|
|
5965
5998
|
tooltip.hidden = true;
|
|
5966
5999
|
return tooltip;
|
|
5967
6000
|
}
|
|
6001
|
+
_createSelectedLabelTooltipTextMeasure() {
|
|
6002
|
+
const measure = document.createElement('span');
|
|
6003
|
+
measure.setAttribute('aria-hidden', 'true');
|
|
6004
|
+
measure.dataset.selectInternal = 'tooltip-measure';
|
|
6005
|
+
measure.style.cssText = [
|
|
6006
|
+
'all: initial',
|
|
6007
|
+
'position: fixed',
|
|
6008
|
+
'left: -100000px',
|
|
6009
|
+
'top: 0',
|
|
6010
|
+
'display: inline-block',
|
|
6011
|
+
'width: max-content',
|
|
6012
|
+
'height: auto',
|
|
6013
|
+
'padding: 0',
|
|
6014
|
+
'margin: 0',
|
|
6015
|
+
'border: 0',
|
|
6016
|
+
'white-space: pre',
|
|
6017
|
+
'visibility: hidden',
|
|
6018
|
+
'pointer-events: none',
|
|
6019
|
+
].join(';');
|
|
6020
|
+
return measure;
|
|
6021
|
+
}
|
|
5968
6022
|
_createDropdown() {
|
|
5969
6023
|
const dropdown = document.createElement('div');
|
|
5970
6024
|
dropdown.className = 'select-dropdown';
|
|
@@ -6060,6 +6114,7 @@
|
|
|
6060
6114
|
this._shadow.appendChild(this._errorDescription);
|
|
6061
6115
|
}
|
|
6062
6116
|
this._shadow.appendChild(this._selectedLabelTooltip);
|
|
6117
|
+
this._shadow.appendChild(this._selectedLabelTooltipTextMeasure);
|
|
6063
6118
|
// Set ARIA relationships
|
|
6064
6119
|
const listboxId = `${this._uniqueId}-listbox`;
|
|
6065
6120
|
this._dropdown.id = listboxId;
|
|
@@ -6411,6 +6466,15 @@
|
|
|
6411
6466
|
pointer-events: none;
|
|
6412
6467
|
}
|
|
6413
6468
|
|
|
6469
|
+
.badge-remove-icon > [data-smilodon-fallback-icon],
|
|
6470
|
+
.badge-remove-icon > [data-smilodon-react-icon-root] {
|
|
6471
|
+
display: contents;
|
|
6472
|
+
}
|
|
6473
|
+
|
|
6474
|
+
.badge-remove-icon[data-smilodon-icon-owner="react"] > [data-smilodon-fallback-icon] {
|
|
6475
|
+
display: none;
|
|
6476
|
+
}
|
|
6477
|
+
|
|
6414
6478
|
.badge-remove-icon svg {
|
|
6415
6479
|
width: 100%;
|
|
6416
6480
|
height: 100%;
|
|
@@ -7586,7 +7650,6 @@
|
|
|
7586
7650
|
keyboardEvent.stopPropagation();
|
|
7587
7651
|
this._dismissSelectedLabelTooltip();
|
|
7588
7652
|
});
|
|
7589
|
-
this._inputContent.addEventListener('scroll', this._scheduleSelectedLabelTooltipMeasure, { passive: true });
|
|
7590
7653
|
// Arrow click handler
|
|
7591
7654
|
if (this._arrowContainer) {
|
|
7592
7655
|
this._boundArrowClick = (e) => {
|
|
@@ -7755,9 +7818,8 @@
|
|
|
7755
7818
|
if (!this._config.searchable)
|
|
7756
7819
|
return;
|
|
7757
7820
|
const query = e.target.value;
|
|
7758
|
-
if (this.
|
|
7759
|
-
|
|
7760
|
-
this._hideSelectedLabelTooltip();
|
|
7821
|
+
if (this._selectedLabelTooltipDismissedTrigger === this._input) {
|
|
7822
|
+
this._selectedLabelTooltipDismissedTrigger = null;
|
|
7761
7823
|
}
|
|
7762
7824
|
this._handleSearch(query);
|
|
7763
7825
|
});
|
|
@@ -7934,7 +7996,7 @@
|
|
|
7934
7996
|
_getSelectedLabelForTrigger(trigger) {
|
|
7935
7997
|
const entries = this._getSelectedEntries();
|
|
7936
7998
|
if (trigger === this._input) {
|
|
7937
|
-
if (this._config.selection.mode !== 'single'
|
|
7999
|
+
if (this._config.selection.mode !== 'single')
|
|
7938
8000
|
return null;
|
|
7939
8001
|
const item = entries[0]?.item;
|
|
7940
8002
|
if (item === undefined)
|
|
@@ -7958,6 +8020,57 @@
|
|
|
7958
8020
|
return false;
|
|
7959
8021
|
return trigger.clientWidth > 0 && trigger.scrollWidth > trigger.clientWidth + 1;
|
|
7960
8022
|
}
|
|
8023
|
+
_getSelectedLabelTooltipContent(trigger) {
|
|
8024
|
+
if (trigger === this._input && this._config.searchable) {
|
|
8025
|
+
const visibleText = this._input.value;
|
|
8026
|
+
const pendingQuery = this._acknowledgedPendingSearchQuery;
|
|
8027
|
+
const committedQuery = this._state.searchQuery;
|
|
8028
|
+
const isPendingQuery = pendingQuery !== null && pendingQuery.length > 0 && visibleText === pendingQuery;
|
|
8029
|
+
const isCommittedQuery = committedQuery.length > 0 && visibleText === committedQuery;
|
|
8030
|
+
if (visibleText.length > 0 && (isPendingQuery || isCommittedQuery)) {
|
|
8031
|
+
return { kind: 'search-query', text: visibleText };
|
|
8032
|
+
}
|
|
8033
|
+
}
|
|
8034
|
+
const selectedLabel = this._getSelectedLabelForTrigger(trigger);
|
|
8035
|
+
return selectedLabel === null ? null : { kind: 'selected-label', text: selectedLabel };
|
|
8036
|
+
}
|
|
8037
|
+
_isSelectedLabelTooltipContentTruncated(trigger, content) {
|
|
8038
|
+
if (trigger !== this._input)
|
|
8039
|
+
return this._isSelectedLabelTruncated(trigger);
|
|
8040
|
+
if (!trigger.isConnected || !content.text)
|
|
8041
|
+
return false;
|
|
8042
|
+
const style = getComputedStyle(this._input);
|
|
8043
|
+
const measure = this._selectedLabelTooltipTextMeasure;
|
|
8044
|
+
measure.textContent = content.text;
|
|
8045
|
+
const mirroredProperties = [
|
|
8046
|
+
'font',
|
|
8047
|
+
'font-family',
|
|
8048
|
+
'font-size',
|
|
8049
|
+
'font-style',
|
|
8050
|
+
'font-weight',
|
|
8051
|
+
'font-stretch',
|
|
8052
|
+
'font-variant',
|
|
8053
|
+
'font-kerning',
|
|
8054
|
+
'font-feature-settings',
|
|
8055
|
+
'font-variation-settings',
|
|
8056
|
+
'letter-spacing',
|
|
8057
|
+
'word-spacing',
|
|
8058
|
+
'text-transform',
|
|
8059
|
+
'direction',
|
|
8060
|
+
'unicode-bidi',
|
|
8061
|
+
];
|
|
8062
|
+
for (const property of mirroredProperties) {
|
|
8063
|
+
const value = style.getPropertyValue(property);
|
|
8064
|
+
if (value)
|
|
8065
|
+
measure.style.setProperty(property, value);
|
|
8066
|
+
}
|
|
8067
|
+
const contentWidth = measure.getBoundingClientRect().width;
|
|
8068
|
+
const inputStyle = style;
|
|
8069
|
+
const horizontalPadding = Number.parseFloat(inputStyle.paddingLeft) + Number.parseFloat(inputStyle.paddingRight);
|
|
8070
|
+
const textIndent = Number.parseFloat(inputStyle.textIndent) || 0;
|
|
8071
|
+
const availableWidth = this._input.clientWidth - (Number.isFinite(horizontalPadding) ? horizontalPadding : 0) - textIndent;
|
|
8072
|
+
return availableWidth > 0 && contentWidth > availableWidth + 1;
|
|
8073
|
+
}
|
|
7961
8074
|
_handleSelectedLabelPointerOver(event) {
|
|
7962
8075
|
const target = event.target;
|
|
7963
8076
|
if (target?.closest('.selected-label-tooltip') === this._selectedLabelTooltip) {
|
|
@@ -8023,8 +8136,8 @@
|
|
|
8023
8136
|
this._hideSelectedLabelTooltip();
|
|
8024
8137
|
return;
|
|
8025
8138
|
}
|
|
8026
|
-
const
|
|
8027
|
-
if (
|
|
8139
|
+
const content = this._getSelectedLabelTooltipContent(trigger);
|
|
8140
|
+
if (content === null || !this._isSelectedLabelTooltipContentTruncated(trigger, content)) {
|
|
8028
8141
|
if (trigger.classList.contains('selection-badge-label'))
|
|
8029
8142
|
trigger.tabIndex = -1;
|
|
8030
8143
|
if (this._selectedLabelTooltipTrigger === trigger)
|
|
@@ -8037,7 +8150,7 @@
|
|
|
8037
8150
|
this._removeSelectedLabelTooltipDescription(this._selectedLabelTooltipTrigger);
|
|
8038
8151
|
this._selectedLabelTooltipTrigger = trigger;
|
|
8039
8152
|
}
|
|
8040
|
-
this._selectedLabelTooltip.textContent =
|
|
8153
|
+
this._selectedLabelTooltip.textContent = content.text;
|
|
8041
8154
|
this._selectedLabelTooltip.hidden = false;
|
|
8042
8155
|
this._positionSelectedLabelTooltip(trigger);
|
|
8043
8156
|
this._syncSelectedLabelTooltipDescription();
|
|
@@ -8091,6 +8204,7 @@
|
|
|
8091
8204
|
this._removeSelectedLabelTooltipDescription(this._selectedLabelTooltipTrigger);
|
|
8092
8205
|
this._selectedLabelTooltipTrigger = null;
|
|
8093
8206
|
this._selectedLabelTooltip.hidden = true;
|
|
8207
|
+
this._selectedLabelTooltipTextMeasure.textContent = '';
|
|
8094
8208
|
if (clearInteractionState) {
|
|
8095
8209
|
this._selectedLabelTooltipPointerTrigger = null;
|
|
8096
8210
|
this._selectedLabelTooltipFocusTrigger = null;
|
|
@@ -8148,10 +8262,12 @@
|
|
|
8148
8262
|
return;
|
|
8149
8263
|
const hasSingleSelection = this._config.selection.mode === 'single'
|
|
8150
8264
|
&& this._getSelectedEntries().length > 0;
|
|
8265
|
+
const inputContent = this._getSelectedLabelTooltipContent(this._input);
|
|
8266
|
+
const shouldObserveInput = hasSingleSelection || inputContent?.kind === 'search-query';
|
|
8151
8267
|
const chipLabels = this._getActiveChipBadges()
|
|
8152
8268
|
.map((badge) => badge.querySelector('.selection-badge-label'))
|
|
8153
8269
|
.filter((label) => label !== null);
|
|
8154
|
-
if (!
|
|
8270
|
+
if (!shouldObserveInput && chipLabels.length === 0) {
|
|
8155
8271
|
this._selectedLabelTooltipResizeObserver?.disconnect();
|
|
8156
8272
|
this._selectedLabelTooltipResizeObserver = null;
|
|
8157
8273
|
return;
|
|
@@ -8160,7 +8276,7 @@
|
|
|
8160
8276
|
this._selectedLabelTooltipResizeObserver = new ResizeObserver(() => this._scheduleSelectedLabelTooltipMeasure());
|
|
8161
8277
|
}
|
|
8162
8278
|
this._selectedLabelTooltipResizeObserver.disconnect();
|
|
8163
|
-
if (
|
|
8279
|
+
if (shouldObserveInput)
|
|
8164
8280
|
this._selectedLabelTooltipResizeObserver.observe(this._input);
|
|
8165
8281
|
chipLabels.forEach((label) => {
|
|
8166
8282
|
this._selectedLabelTooltipResizeObserver?.observe(label);
|
|
@@ -8194,8 +8310,8 @@
|
|
|
8194
8310
|
this._hideSelectedLabelTooltip();
|
|
8195
8311
|
return;
|
|
8196
8312
|
}
|
|
8197
|
-
const
|
|
8198
|
-
if (
|
|
8313
|
+
const content = this._getSelectedLabelTooltipContent(trigger);
|
|
8314
|
+
if (content === null || !this._isSelectedLabelTooltipContentTruncated(trigger, content)) {
|
|
8199
8315
|
if (this._selectedLabelTooltipTrigger === trigger)
|
|
8200
8316
|
this._hideSelectedLabelTooltip();
|
|
8201
8317
|
return;
|
|
@@ -8797,10 +8913,8 @@
|
|
|
8797
8913
|
return results;
|
|
8798
8914
|
}
|
|
8799
8915
|
_handleSearch(query) {
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
this._hideSelectedLabelTooltip();
|
|
8803
|
-
}
|
|
8916
|
+
const previousQuery = this._acknowledgedPendingSearchQuery ?? this._state.searchQuery;
|
|
8917
|
+
const queryPresenceChanged = Boolean(previousQuery) !== Boolean(query);
|
|
8804
8918
|
if (this._dataRequestCoordinator
|
|
8805
8919
|
&& (this._acknowledgedProjectionPending || this._acknowledgedProjectionSettling)) {
|
|
8806
8920
|
// Keep the committed query/generation stable until the accepted snapshot
|
|
@@ -8809,6 +8923,9 @@
|
|
|
8809
8923
|
this._acknowledgedPendingSearchQuery = query;
|
|
8810
8924
|
this._input.value = query;
|
|
8811
8925
|
this._syncClearControlState();
|
|
8926
|
+
if (queryPresenceChanged)
|
|
8927
|
+
this._observeSelectedLabelTooltipTargets();
|
|
8928
|
+
this._refreshSelectedLabelTooltipMeasurements();
|
|
8812
8929
|
return;
|
|
8813
8930
|
}
|
|
8814
8931
|
if (this._dataLoadingConfig.protocol === 'acknowledged'
|
|
@@ -8820,6 +8937,9 @@
|
|
|
8820
8937
|
this._cancelBusyPresentation();
|
|
8821
8938
|
this._state.searchQuery = query;
|
|
8822
8939
|
this._syncClearControlState();
|
|
8940
|
+
if (queryPresenceChanged)
|
|
8941
|
+
this._observeSelectedLabelTooltipTargets();
|
|
8942
|
+
this._refreshSelectedLabelTooltipMeasurements();
|
|
8823
8943
|
this._state.lastNotifiedQuery = query;
|
|
8824
8944
|
this._state.lastNotifiedResultCount = 0;
|
|
8825
8945
|
if (this._dataRequestCoordinator) {
|
|
@@ -8858,6 +8978,9 @@
|
|
|
8858
8978
|
}
|
|
8859
8979
|
this._state.searchQuery = query;
|
|
8860
8980
|
this._syncClearControlState();
|
|
8981
|
+
if (queryPresenceChanged)
|
|
8982
|
+
this._observeSelectedLabelTooltipTargets();
|
|
8983
|
+
this._refreshSelectedLabelTooltipMeasurements();
|
|
8861
8984
|
if (this._dataLoadingConfig.protocol === 'acknowledged' && this._dataRequestCoordinator) {
|
|
8862
8985
|
// Local acknowledged search has no remote request, but pagination still
|
|
8863
8986
|
// belongs to the coordinator's current query generation.
|
|
@@ -10480,6 +10603,8 @@
|
|
|
10480
10603
|
}
|
|
10481
10604
|
this._renderOptions();
|
|
10482
10605
|
this._syncClearControlState();
|
|
10606
|
+
this._observeSelectedLabelTooltipTargets();
|
|
10607
|
+
this._refreshSelectedLabelTooltipMeasurements();
|
|
10483
10608
|
}
|
|
10484
10609
|
/**
|
|
10485
10610
|
* Open dropdown
|
|
@@ -10688,6 +10813,8 @@
|
|
|
10688
10813
|
}
|
|
10689
10814
|
}
|
|
10690
10815
|
}
|
|
10816
|
+
this._observeSelectedLabelTooltipTargets();
|
|
10817
|
+
this._refreshSelectedLabelTooltipMeasurements();
|
|
10691
10818
|
if (configErrorDetail) {
|
|
10692
10819
|
this._emit('dataLoadingConfigError', configErrorDetail);
|
|
10693
10820
|
try {
|