@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 CHANGED
@@ -12,6 +12,8 @@
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
+ > **Next Core candidate (unpublished):** Core `1.22.0` adds the truncated search-query tooltip and isolated icon-root support for React-node remove icons. See the [release candidate record](../../docs/releases/WEB-1.22.0-RELEASE.md) for package pairing and qualification status.
16
+
15
17
  > **Issue #100:** `multiSelectDisplay.scrollToLatestChip` is available in `@smilodon/core@1.17.0`. See [Multi-Select Display Modes](#multi-select-display-modes) and the [release verification](../../docs/releases/WEB-1.17.0-REGISTRY-VERIFICATION.json).
16
18
 
17
19
  > **Core 1.20.0:** Adds selected-first option presentation and selected-option open positioning through `selectedOptions` and `scrollToSelected`. It also includes Core 1.19.0's styling fixes and search threshold. See [selected-option configuration](#selected-option-presentation-and-opening-scroll), [arrow container positioning](#custom-arrow-slot), and the [release record](../../docs/releases/WEB-1.20.0-RELEASE.md).
@@ -33,6 +35,10 @@ select.updateConfig({
33
35
 
34
36
  Core displays the full selected display label in a shared tooltip when the closed single-select value or a multi-select chip is visually truncated. The tooltip appears on pointer hover or keyboard focus; a label that fits does not open one. It uses the same configured item-label resolver as the visible selection, so custom `serverSide.getLabelFromItem` labels are reflected. Search queries are not treated as selected values. Multi-select chip labels become tab stops only while truncated, and Escape dismisses the tooltip without moving focus. This behavior covers selected values and chips, not custom option content in the dropdown.
35
37
 
38
+ ### Truncated search queries (Issue #129)
39
+
40
+ When a searchable input's current query is wider than the visible input area, Core uses the same tooltip to expose the full query on hover or keyboard focus. Search content remains a query, never a selected label; pending acknowledged input is considered while its update is in flight. The tooltip follows edits, query clearing, resize, and direction changes without changing the input value, caret, selection, or scroll position. Escape dismisses the tooltip, and a later edit can show it again. This behavior is included in Core `1.22.0`.
41
+
36
42
  ## Custom busy bucket (Core 1.13.0)
37
43
 
38
44
  Introduced in `@smilodon/core@1.13.0` (Issue #90), the busy bucket keeps request state in Core and lets the host customize its presentation. Use the native slots with the Web Component or Vanilla API:
package/dist/index.cjs CHANGED
@@ -2940,6 +2940,15 @@ class SelectOption extends HTMLElement {
2940
2940
  pointer-events: none;
2941
2941
  }
2942
2942
 
2943
+ .remove-button-icon > [data-smilodon-fallback-icon],
2944
+ .remove-button-icon > [data-smilodon-react-icon-root] {
2945
+ display: contents;
2946
+ }
2947
+
2948
+ .remove-button-icon[data-smilodon-icon-owner="react"] > [data-smilodon-fallback-icon] {
2949
+ display: none;
2950
+ }
2951
+
2943
2952
  .remove-button-icon svg {
2944
2953
  width: 100%;
2945
2954
  height: 100%;
@@ -3062,15 +3071,20 @@ class SelectOption extends HTMLElement {
3062
3071
  const removeIcon = document.createElement('span');
3063
3072
  removeIcon.className = 'remove-button-icon';
3064
3073
  removeIcon.setAttribute('part', 'chip-remove-icon');
3074
+ const fallbackIcon = document.createElement('span');
3075
+ fallbackIcon.setAttribute('data-smilodon-fallback-icon', '');
3076
+ const portalRoot = document.createElement('span');
3077
+ portalRoot.setAttribute('data-smilodon-react-icon-root', '');
3065
3078
  const iconMarkup = this._config.removeButtonIcon && this._config.removeButtonIcon.trim()
3066
3079
  ? this._config.removeButtonIcon
3067
3080
  : '×';
3068
3081
  if (iconMarkup.trim().startsWith('<')) {
3069
- removeIcon.innerHTML = iconMarkup;
3082
+ fallbackIcon.innerHTML = iconMarkup;
3070
3083
  }
3071
3084
  else {
3072
- removeIcon.textContent = iconMarkup;
3085
+ fallbackIcon.textContent = iconMarkup;
3073
3086
  }
3087
+ removeIcon.append(fallbackIcon, portalRoot);
3074
3088
  this._removeButton.appendChild(removeIcon);
3075
3089
  this._container.appendChild(this._removeButton);
3076
3090
  }
@@ -4684,6 +4698,7 @@ class EnhancedSelect extends HTMLElement {
4684
4698
  this._inputContent = this._createInputContent();
4685
4699
  this._input = this._createInput();
4686
4700
  this._selectedLabelTooltip = this._createSelectedLabelTooltip();
4701
+ this._selectedLabelTooltipTextMeasure = this._createSelectedLabelTooltipTextMeasure();
4687
4702
  this._arrowContainer = this._createArrowContainer();
4688
4703
  this._clearControl = this._createClearControl();
4689
4704
  this._dropdown = this._createDropdown();
@@ -4703,6 +4718,9 @@ class EnhancedSelect extends HTMLElement {
4703
4718
  }
4704
4719
  connectedCallback() {
4705
4720
  this._hasEverConnected = true;
4721
+ // Adapter capability marker without adding a field to the public class
4722
+ // declaration. React-node remove icons require the isolated root contract.
4723
+ this.setAttribute('data-smilodon-react-icon-portals', 'isolated-v1');
4706
4724
  // register instance
4707
4725
  EnhancedSelect._instances.add(this);
4708
4726
  this._runEngineEffects(this._engine.dispatch({ type: 'CONNECT' }));
@@ -4710,6 +4728,7 @@ class EnhancedSelect extends HTMLElement {
4710
4728
  this._connectionController?.abort();
4711
4729
  this._connectionController = new AbortController();
4712
4730
  this._observeSelectedLabelTooltipTargets();
4731
+ this._inputContent.addEventListener('scroll', this._scheduleSelectedLabelTooltipMeasure, { passive: true });
4713
4732
  document.addEventListener('pointerdown', this._onDocumentPointerDown, {
4714
4733
  signal: this._connectionController.signal,
4715
4734
  });
@@ -4793,6 +4812,7 @@ class EnhancedSelect extends HTMLElement {
4793
4812
  this._handleClose('disconnect');
4794
4813
  }
4795
4814
  this._runEngineEffects(this._engine.dispatch({ type: 'DISCONNECT' }));
4815
+ this._inputContent.removeEventListener('scroll', this._scheduleSelectedLabelTooltipMeasure);
4796
4816
  this._connectionController?.abort();
4797
4817
  this._connectionController = undefined;
4798
4818
  this._hideSelectedLabelTooltip(true);
@@ -5733,12 +5753,25 @@ class EnhancedSelect extends HTMLElement {
5733
5753
  }
5734
5754
  _setIconContent(target, markup, fallback) {
5735
5755
  const content = markup && markup.trim() ? markup : fallback;
5736
- target.innerHTML = '';
5756
+ let fallbackTarget = target.querySelector(':scope > [data-smilodon-fallback-icon]');
5757
+ if (!fallbackTarget) {
5758
+ fallbackTarget = document.createElement('span');
5759
+ fallbackTarget.setAttribute('data-smilodon-fallback-icon', '');
5760
+ target.prepend(fallbackTarget);
5761
+ }
5762
+ if (!target.querySelector(':scope > [data-smilodon-react-icon-root]')) {
5763
+ const portalRoot = document.createElement('span');
5764
+ portalRoot.setAttribute('data-smilodon-react-icon-root', '');
5765
+ target.append(portalRoot);
5766
+ }
5767
+ // Only Core's fallback subtree is replaceable. React may reconcile a
5768
+ // separate portal root beneath this stable icon target.
5769
+ fallbackTarget.replaceChildren();
5737
5770
  if (content.trim().startsWith('<')) {
5738
- target.innerHTML = content;
5771
+ fallbackTarget.innerHTML = content;
5739
5772
  return;
5740
5773
  }
5741
- target.textContent = content;
5774
+ fallbackTarget.textContent = content;
5742
5775
  }
5743
5776
  _syncInputContainerMode() {
5744
5777
  if (!this._inputContainer || !this._input)
@@ -5961,6 +5994,27 @@ class EnhancedSelect extends HTMLElement {
5961
5994
  tooltip.hidden = true;
5962
5995
  return tooltip;
5963
5996
  }
5997
+ _createSelectedLabelTooltipTextMeasure() {
5998
+ const measure = document.createElement('span');
5999
+ measure.setAttribute('aria-hidden', 'true');
6000
+ measure.dataset.selectInternal = 'tooltip-measure';
6001
+ measure.style.cssText = [
6002
+ 'all: initial',
6003
+ 'position: fixed',
6004
+ 'left: -100000px',
6005
+ 'top: 0',
6006
+ 'display: inline-block',
6007
+ 'width: max-content',
6008
+ 'height: auto',
6009
+ 'padding: 0',
6010
+ 'margin: 0',
6011
+ 'border: 0',
6012
+ 'white-space: pre',
6013
+ 'visibility: hidden',
6014
+ 'pointer-events: none',
6015
+ ].join(';');
6016
+ return measure;
6017
+ }
5964
6018
  _createDropdown() {
5965
6019
  const dropdown = document.createElement('div');
5966
6020
  dropdown.className = 'select-dropdown';
@@ -6056,6 +6110,7 @@ class EnhancedSelect extends HTMLElement {
6056
6110
  this._shadow.appendChild(this._errorDescription);
6057
6111
  }
6058
6112
  this._shadow.appendChild(this._selectedLabelTooltip);
6113
+ this._shadow.appendChild(this._selectedLabelTooltipTextMeasure);
6059
6114
  // Set ARIA relationships
6060
6115
  const listboxId = `${this._uniqueId}-listbox`;
6061
6116
  this._dropdown.id = listboxId;
@@ -6407,6 +6462,15 @@ class EnhancedSelect extends HTMLElement {
6407
6462
  pointer-events: none;
6408
6463
  }
6409
6464
 
6465
+ .badge-remove-icon > [data-smilodon-fallback-icon],
6466
+ .badge-remove-icon > [data-smilodon-react-icon-root] {
6467
+ display: contents;
6468
+ }
6469
+
6470
+ .badge-remove-icon[data-smilodon-icon-owner="react"] > [data-smilodon-fallback-icon] {
6471
+ display: none;
6472
+ }
6473
+
6410
6474
  .badge-remove-icon svg {
6411
6475
  width: 100%;
6412
6476
  height: 100%;
@@ -7582,7 +7646,6 @@ class EnhancedSelect extends HTMLElement {
7582
7646
  keyboardEvent.stopPropagation();
7583
7647
  this._dismissSelectedLabelTooltip();
7584
7648
  });
7585
- this._inputContent.addEventListener('scroll', this._scheduleSelectedLabelTooltipMeasure, { passive: true });
7586
7649
  // Arrow click handler
7587
7650
  if (this._arrowContainer) {
7588
7651
  this._boundArrowClick = (e) => {
@@ -7751,9 +7814,8 @@ class EnhancedSelect extends HTMLElement {
7751
7814
  if (!this._config.searchable)
7752
7815
  return;
7753
7816
  const query = e.target.value;
7754
- if (this._selectedLabelTooltipTrigger === this._input
7755
- && this._getSelectedLabelForTrigger(this._input) === null) {
7756
- this._hideSelectedLabelTooltip();
7817
+ if (this._selectedLabelTooltipDismissedTrigger === this._input) {
7818
+ this._selectedLabelTooltipDismissedTrigger = null;
7757
7819
  }
7758
7820
  this._handleSearch(query);
7759
7821
  });
@@ -7930,7 +7992,7 @@ class EnhancedSelect extends HTMLElement {
7930
7992
  _getSelectedLabelForTrigger(trigger) {
7931
7993
  const entries = this._getSelectedEntries();
7932
7994
  if (trigger === this._input) {
7933
- if (this._config.selection.mode !== 'single' || this._state.searchQuery.length > 0)
7995
+ if (this._config.selection.mode !== 'single')
7934
7996
  return null;
7935
7997
  const item = entries[0]?.item;
7936
7998
  if (item === undefined)
@@ -7954,6 +8016,57 @@ class EnhancedSelect extends HTMLElement {
7954
8016
  return false;
7955
8017
  return trigger.clientWidth > 0 && trigger.scrollWidth > trigger.clientWidth + 1;
7956
8018
  }
8019
+ _getSelectedLabelTooltipContent(trigger) {
8020
+ if (trigger === this._input && this._config.searchable) {
8021
+ const visibleText = this._input.value;
8022
+ const pendingQuery = this._acknowledgedPendingSearchQuery;
8023
+ const committedQuery = this._state.searchQuery;
8024
+ const isPendingQuery = pendingQuery !== null && pendingQuery.length > 0 && visibleText === pendingQuery;
8025
+ const isCommittedQuery = committedQuery.length > 0 && visibleText === committedQuery;
8026
+ if (visibleText.length > 0 && (isPendingQuery || isCommittedQuery)) {
8027
+ return { kind: 'search-query', text: visibleText };
8028
+ }
8029
+ }
8030
+ const selectedLabel = this._getSelectedLabelForTrigger(trigger);
8031
+ return selectedLabel === null ? null : { kind: 'selected-label', text: selectedLabel };
8032
+ }
8033
+ _isSelectedLabelTooltipContentTruncated(trigger, content) {
8034
+ if (trigger !== this._input)
8035
+ return this._isSelectedLabelTruncated(trigger);
8036
+ if (!trigger.isConnected || !content.text)
8037
+ return false;
8038
+ const style = getComputedStyle(this._input);
8039
+ const measure = this._selectedLabelTooltipTextMeasure;
8040
+ measure.textContent = content.text;
8041
+ const mirroredProperties = [
8042
+ 'font',
8043
+ 'font-family',
8044
+ 'font-size',
8045
+ 'font-style',
8046
+ 'font-weight',
8047
+ 'font-stretch',
8048
+ 'font-variant',
8049
+ 'font-kerning',
8050
+ 'font-feature-settings',
8051
+ 'font-variation-settings',
8052
+ 'letter-spacing',
8053
+ 'word-spacing',
8054
+ 'text-transform',
8055
+ 'direction',
8056
+ 'unicode-bidi',
8057
+ ];
8058
+ for (const property of mirroredProperties) {
8059
+ const value = style.getPropertyValue(property);
8060
+ if (value)
8061
+ measure.style.setProperty(property, value);
8062
+ }
8063
+ const contentWidth = measure.getBoundingClientRect().width;
8064
+ const inputStyle = style;
8065
+ const horizontalPadding = Number.parseFloat(inputStyle.paddingLeft) + Number.parseFloat(inputStyle.paddingRight);
8066
+ const textIndent = Number.parseFloat(inputStyle.textIndent) || 0;
8067
+ const availableWidth = this._input.clientWidth - (Number.isFinite(horizontalPadding) ? horizontalPadding : 0) - textIndent;
8068
+ return availableWidth > 0 && contentWidth > availableWidth + 1;
8069
+ }
7957
8070
  _handleSelectedLabelPointerOver(event) {
7958
8071
  const target = event.target;
7959
8072
  if (target?.closest('.selected-label-tooltip') === this._selectedLabelTooltip) {
@@ -8019,8 +8132,8 @@ class EnhancedSelect extends HTMLElement {
8019
8132
  this._hideSelectedLabelTooltip();
8020
8133
  return;
8021
8134
  }
8022
- const label = this._getSelectedLabelForTrigger(trigger);
8023
- if (label === null || !this._isSelectedLabelTruncated(trigger)) {
8135
+ const content = this._getSelectedLabelTooltipContent(trigger);
8136
+ if (content === null || !this._isSelectedLabelTooltipContentTruncated(trigger, content)) {
8024
8137
  if (trigger.classList.contains('selection-badge-label'))
8025
8138
  trigger.tabIndex = -1;
8026
8139
  if (this._selectedLabelTooltipTrigger === trigger)
@@ -8033,7 +8146,7 @@ class EnhancedSelect extends HTMLElement {
8033
8146
  this._removeSelectedLabelTooltipDescription(this._selectedLabelTooltipTrigger);
8034
8147
  this._selectedLabelTooltipTrigger = trigger;
8035
8148
  }
8036
- this._selectedLabelTooltip.textContent = label;
8149
+ this._selectedLabelTooltip.textContent = content.text;
8037
8150
  this._selectedLabelTooltip.hidden = false;
8038
8151
  this._positionSelectedLabelTooltip(trigger);
8039
8152
  this._syncSelectedLabelTooltipDescription();
@@ -8087,6 +8200,7 @@ class EnhancedSelect extends HTMLElement {
8087
8200
  this._removeSelectedLabelTooltipDescription(this._selectedLabelTooltipTrigger);
8088
8201
  this._selectedLabelTooltipTrigger = null;
8089
8202
  this._selectedLabelTooltip.hidden = true;
8203
+ this._selectedLabelTooltipTextMeasure.textContent = '';
8090
8204
  if (clearInteractionState) {
8091
8205
  this._selectedLabelTooltipPointerTrigger = null;
8092
8206
  this._selectedLabelTooltipFocusTrigger = null;
@@ -8144,10 +8258,12 @@ class EnhancedSelect extends HTMLElement {
8144
8258
  return;
8145
8259
  const hasSingleSelection = this._config.selection.mode === 'single'
8146
8260
  && this._getSelectedEntries().length > 0;
8261
+ const inputContent = this._getSelectedLabelTooltipContent(this._input);
8262
+ const shouldObserveInput = hasSingleSelection || inputContent?.kind === 'search-query';
8147
8263
  const chipLabels = this._getActiveChipBadges()
8148
8264
  .map((badge) => badge.querySelector('.selection-badge-label'))
8149
8265
  .filter((label) => label !== null);
8150
- if (!hasSingleSelection && chipLabels.length === 0) {
8266
+ if (!shouldObserveInput && chipLabels.length === 0) {
8151
8267
  this._selectedLabelTooltipResizeObserver?.disconnect();
8152
8268
  this._selectedLabelTooltipResizeObserver = null;
8153
8269
  return;
@@ -8156,7 +8272,7 @@ class EnhancedSelect extends HTMLElement {
8156
8272
  this._selectedLabelTooltipResizeObserver = new ResizeObserver(() => this._scheduleSelectedLabelTooltipMeasure());
8157
8273
  }
8158
8274
  this._selectedLabelTooltipResizeObserver.disconnect();
8159
- if (hasSingleSelection)
8275
+ if (shouldObserveInput)
8160
8276
  this._selectedLabelTooltipResizeObserver.observe(this._input);
8161
8277
  chipLabels.forEach((label) => {
8162
8278
  this._selectedLabelTooltipResizeObserver?.observe(label);
@@ -8190,8 +8306,8 @@ class EnhancedSelect extends HTMLElement {
8190
8306
  this._hideSelectedLabelTooltip();
8191
8307
  return;
8192
8308
  }
8193
- const label = this._getSelectedLabelForTrigger(trigger);
8194
- if (label === null || !this._isSelectedLabelTruncated(trigger)) {
8309
+ const content = this._getSelectedLabelTooltipContent(trigger);
8310
+ if (content === null || !this._isSelectedLabelTooltipContentTruncated(trigger, content)) {
8195
8311
  if (this._selectedLabelTooltipTrigger === trigger)
8196
8312
  this._hideSelectedLabelTooltip();
8197
8313
  return;
@@ -8793,10 +8909,8 @@ class EnhancedSelect extends HTMLElement {
8793
8909
  return results;
8794
8910
  }
8795
8911
  _handleSearch(query) {
8796
- if (this._selectedLabelTooltipTrigger === this._input
8797
- && (query.length > 0 || this._getSelectedLabelForTrigger(this._input) === null)) {
8798
- this._hideSelectedLabelTooltip();
8799
- }
8912
+ const previousQuery = this._acknowledgedPendingSearchQuery ?? this._state.searchQuery;
8913
+ const queryPresenceChanged = Boolean(previousQuery) !== Boolean(query);
8800
8914
  if (this._dataRequestCoordinator
8801
8915
  && (this._acknowledgedProjectionPending || this._acknowledgedProjectionSettling)) {
8802
8916
  // Keep the committed query/generation stable until the accepted snapshot
@@ -8805,6 +8919,9 @@ class EnhancedSelect extends HTMLElement {
8805
8919
  this._acknowledgedPendingSearchQuery = query;
8806
8920
  this._input.value = query;
8807
8921
  this._syncClearControlState();
8922
+ if (queryPresenceChanged)
8923
+ this._observeSelectedLabelTooltipTargets();
8924
+ this._refreshSelectedLabelTooltipMeasurements();
8808
8925
  return;
8809
8926
  }
8810
8927
  if (this._dataLoadingConfig.protocol === 'acknowledged'
@@ -8816,6 +8933,9 @@ class EnhancedSelect extends HTMLElement {
8816
8933
  this._cancelBusyPresentation();
8817
8934
  this._state.searchQuery = query;
8818
8935
  this._syncClearControlState();
8936
+ if (queryPresenceChanged)
8937
+ this._observeSelectedLabelTooltipTargets();
8938
+ this._refreshSelectedLabelTooltipMeasurements();
8819
8939
  this._state.lastNotifiedQuery = query;
8820
8940
  this._state.lastNotifiedResultCount = 0;
8821
8941
  if (this._dataRequestCoordinator) {
@@ -8854,6 +8974,9 @@ class EnhancedSelect extends HTMLElement {
8854
8974
  }
8855
8975
  this._state.searchQuery = query;
8856
8976
  this._syncClearControlState();
8977
+ if (queryPresenceChanged)
8978
+ this._observeSelectedLabelTooltipTargets();
8979
+ this._refreshSelectedLabelTooltipMeasurements();
8857
8980
  if (this._dataLoadingConfig.protocol === 'acknowledged' && this._dataRequestCoordinator) {
8858
8981
  // Local acknowledged search has no remote request, but pagination still
8859
8982
  // belongs to the coordinator's current query generation.
@@ -10476,6 +10599,8 @@ class EnhancedSelect extends HTMLElement {
10476
10599
  }
10477
10600
  this._renderOptions();
10478
10601
  this._syncClearControlState();
10602
+ this._observeSelectedLabelTooltipTargets();
10603
+ this._refreshSelectedLabelTooltipMeasurements();
10479
10604
  }
10480
10605
  /**
10481
10606
  * Open dropdown
@@ -10684,6 +10809,8 @@ class EnhancedSelect extends HTMLElement {
10684
10809
  }
10685
10810
  }
10686
10811
  }
10812
+ this._observeSelectedLabelTooltipTargets();
10813
+ this._refreshSelectedLabelTooltipMeasurements();
10687
10814
  if (configErrorDetail) {
10688
10815
  this._emit('dataLoadingConfigError', configErrorDetail);
10689
10816
  try {