@smilodon/core 1.21.0 → 1.23.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/dist/index.js CHANGED
@@ -2204,6 +2204,7 @@ const defaultConfig = {
2204
2204
  selectable: false,
2205
2205
  hoverable: false,
2206
2206
  focusable: false,
2207
+ closeOnClick: false,
2207
2208
  },
2208
2209
  maxSelections: 0,
2209
2210
  showRemoveButton: true,
@@ -2250,6 +2251,7 @@ const defaultConfig = {
2250
2251
  minDisplayTime: 200,
2251
2252
  contentMode: 'append',
2252
2253
  },
2254
+ searchingMessage: 'Searching...',
2253
2255
  styles: {
2254
2256
  classNames: {},
2255
2257
  },
@@ -2738,6 +2740,7 @@ class SelectOption extends HTMLElement {
2738
2740
  :host {
2739
2741
  display: block;
2740
2742
  position: relative;
2743
+ z-index: var(--select-option-z-index, auto);
2741
2744
  font: inherit;
2742
2745
  color: var(--select-option-color, var(--select-text-color, #1f2937));
2743
2746
  background: var(--select-option-bg, var(--select-dropdown-bg, var(--select-bg, white)));
@@ -2800,7 +2803,7 @@ class SelectOption extends HTMLElement {
2800
2803
  border-bottom: var(--select-option-disabled-border-bottom, var(--select-option-border-bottom, none));
2801
2804
  opacity: var(--select-option-disabled-opacity, 0.5);
2802
2805
  cursor: var(--select-option-disabled-cursor, not-allowed);
2803
- pointer-events: none;
2806
+ pointer-events: auto;
2804
2807
  }
2805
2808
 
2806
2809
  :host(.smilodon-option--disabled-interactive) {
@@ -2870,7 +2873,7 @@ class SelectOption extends HTMLElement {
2870
2873
  border-bottom: inherit;
2871
2874
  opacity: inherit;
2872
2875
  cursor: inherit;
2873
- pointer-events: none;
2876
+ pointer-events: auto;
2874
2877
  }
2875
2878
 
2876
2879
  .option-content {
@@ -2938,6 +2941,15 @@ class SelectOption extends HTMLElement {
2938
2941
  pointer-events: none;
2939
2942
  }
2940
2943
 
2944
+ .remove-button-icon > [data-smilodon-fallback-icon],
2945
+ .remove-button-icon > [data-smilodon-react-icon-root] {
2946
+ display: contents;
2947
+ }
2948
+
2949
+ .remove-button-icon[data-smilodon-icon-owner="react"] > [data-smilodon-fallback-icon] {
2950
+ display: none;
2951
+ }
2952
+
2941
2953
  .remove-button-icon svg {
2942
2954
  width: 100%;
2943
2955
  height: 100%;
@@ -2962,6 +2974,7 @@ class SelectOption extends HTMLElement {
2962
2974
  selectable: behavior.selectable === true,
2963
2975
  hoverable: behavior.hoverable === true,
2964
2976
  focusable: behavior.focusable === true,
2977
+ closeOnClick: behavior.closeOnClick === true,
2965
2978
  };
2966
2979
  }
2967
2980
  _isDisabledSelectionBlocked() {
@@ -3060,15 +3073,20 @@ class SelectOption extends HTMLElement {
3060
3073
  const removeIcon = document.createElement('span');
3061
3074
  removeIcon.className = 'remove-button-icon';
3062
3075
  removeIcon.setAttribute('part', 'chip-remove-icon');
3076
+ const fallbackIcon = document.createElement('span');
3077
+ fallbackIcon.setAttribute('data-smilodon-fallback-icon', '');
3078
+ const portalRoot = document.createElement('span');
3079
+ portalRoot.setAttribute('data-smilodon-react-icon-root', '');
3063
3080
  const iconMarkup = this._config.removeButtonIcon && this._config.removeButtonIcon.trim()
3064
3081
  ? this._config.removeButtonIcon
3065
3082
  : '×';
3066
3083
  if (iconMarkup.trim().startsWith('<')) {
3067
- removeIcon.innerHTML = iconMarkup;
3084
+ fallbackIcon.innerHTML = iconMarkup;
3068
3085
  }
3069
3086
  else {
3070
- removeIcon.textContent = iconMarkup;
3087
+ fallbackIcon.textContent = iconMarkup;
3071
3088
  }
3089
+ removeIcon.append(fallbackIcon, portalRoot);
3072
3090
  this._removeButton.appendChild(removeIcon);
3073
3091
  this._container.appendChild(this._removeButton);
3074
3092
  }
@@ -4334,6 +4352,12 @@ class DataRequestCoordinator {
4334
4352
  *
4335
4353
  * Redesigned with formal elegance, refined microinteractions, and polished UX
4336
4354
  */
4355
+ const DROPDOWN_BORDER_LONGHANDS = [
4356
+ 'border-top-width', 'border-right-width', 'border-bottom-width', 'border-left-width',
4357
+ 'border-top-style', 'border-right-style', 'border-bottom-style', 'border-left-style',
4358
+ 'border-top-color', 'border-right-color', 'border-bottom-color', 'border-left-color',
4359
+ 'border-image-source', 'border-image-slice', 'border-image-width', 'border-image-outset', 'border-image-repeat',
4360
+ ];
4337
4361
  const LEGACY_DATA_LOADING_CONFIG = {
4338
4362
  protocol: 'legacy',
4339
4363
  searchMode: 'local',
@@ -4452,6 +4476,8 @@ class EnhancedSelect extends HTMLElement {
4452
4476
  this._selectedLabelTooltipResizeObserver = null;
4453
4477
  this._selectedLabelTooltipMeasureFrame = null;
4454
4478
  this._selectedLabelKeys = new WeakMap();
4479
+ this._dropdownConfigInlineStyles = new Map();
4480
+ this._managedLoaderClasses = new Set();
4455
4481
  this._busyPresentationVisible = false;
4456
4482
  this._busyPresentationStartedAt = null;
4457
4483
  this._busyPresentationGeneration = 0;
@@ -4682,9 +4708,11 @@ class EnhancedSelect extends HTMLElement {
4682
4708
  this._inputContent = this._createInputContent();
4683
4709
  this._input = this._createInput();
4684
4710
  this._selectedLabelTooltip = this._createSelectedLabelTooltip();
4711
+ this._selectedLabelTooltipTextMeasure = this._createSelectedLabelTooltipTextMeasure();
4685
4712
  this._arrowContainer = this._createArrowContainer();
4686
4713
  this._clearControl = this._createClearControl();
4687
4714
  this._dropdown = this._createDropdown();
4715
+ this._syncDropdownConfigInlineStyles();
4688
4716
  this._optionsContainer = this._createOptionsContainer();
4689
4717
  this._liveRegion = this._createLiveRegion();
4690
4718
  this._errorDescription = this._createErrorDescription();
@@ -4701,6 +4729,9 @@ class EnhancedSelect extends HTMLElement {
4701
4729
  }
4702
4730
  connectedCallback() {
4703
4731
  this._hasEverConnected = true;
4732
+ // Adapter capability marker without adding a field to the public class
4733
+ // declaration. React-node remove icons require the isolated root contract.
4734
+ this.setAttribute('data-smilodon-react-icon-portals', 'isolated-v1');
4704
4735
  // register instance
4705
4736
  EnhancedSelect._instances.add(this);
4706
4737
  this._runEngineEffects(this._engine.dispatch({ type: 'CONNECT' }));
@@ -4708,6 +4739,7 @@ class EnhancedSelect extends HTMLElement {
4708
4739
  this._connectionController?.abort();
4709
4740
  this._connectionController = new AbortController();
4710
4741
  this._observeSelectedLabelTooltipTargets();
4742
+ this._inputContent.addEventListener('scroll', this._scheduleSelectedLabelTooltipMeasure, { passive: true });
4711
4743
  document.addEventListener('pointerdown', this._onDocumentPointerDown, {
4712
4744
  signal: this._connectionController.signal,
4713
4745
  });
@@ -4791,6 +4823,7 @@ class EnhancedSelect extends HTMLElement {
4791
4823
  this._handleClose('disconnect');
4792
4824
  }
4793
4825
  this._runEngineEffects(this._engine.dispatch({ type: 'DISCONNECT' }));
4826
+ this._inputContent.removeEventListener('scroll', this._scheduleSelectedLabelTooltipMeasure);
4794
4827
  this._connectionController?.abort();
4795
4828
  this._connectionController = undefined;
4796
4829
  this._hideSelectedLabelTooltip(true);
@@ -5291,6 +5324,7 @@ class EnhancedSelect extends HTMLElement {
5291
5324
  selectable: behavior.selectable === true,
5292
5325
  hoverable: behavior.hoverable === true,
5293
5326
  focusable: behavior.focusable === true,
5327
+ closeOnClick: behavior.closeOnClick === true,
5294
5328
  };
5295
5329
  }
5296
5330
  _isDisabledOptionSelectable(item) {
@@ -5534,6 +5568,7 @@ class EnhancedSelect extends HTMLElement {
5534
5568
  const styles = this._config.styles;
5535
5569
  if (!styles)
5536
5570
  return;
5571
+ this._syncLoaderClassNames();
5537
5572
  this._applyStyleVariableMap(styles.option, {
5538
5573
  background: '--select-option-bg',
5539
5574
  backgroundColor: '--select-option-bg',
@@ -5549,6 +5584,7 @@ class EnhancedSelect extends HTMLElement {
5549
5584
  fontWeight: '--select-option-font-weight',
5550
5585
  lineHeight: '--select-option-line-height',
5551
5586
  textAlign: '--select-option-text-align',
5587
+ zIndex: '--select-option-z-index',
5552
5588
  });
5553
5589
  this._applyStyleVariableMap(styles.selectedOption, {
5554
5590
  background: '--select-option-selected-bg',
@@ -5702,8 +5738,35 @@ class EnhancedSelect extends HTMLElement {
5702
5738
  fontWeight: '--select-group-header-weight',
5703
5739
  textTransform: '--select-group-header-text-transform',
5704
5740
  letterSpacing: '--select-group-header-letter-spacing',
5741
+ position: '--select-group-header-position',
5742
+ top: '--select-group-header-top',
5743
+ zIndex: '--select-group-header-z-index',
5744
+ });
5745
+ this._applyStyleVariableMap(styles.loader, {
5746
+ gap: '--select-loader-gap',
5747
+ padding: '--select-loader-padding',
5748
+ color: '--select-loader-color',
5749
+ background: '--select-loader-bg',
5750
+ backgroundColor: '--select-loader-bg',
5751
+ fontSize: '--select-loader-font-size',
5752
+ textAlign: '--select-loader-text-align',
5753
+ alignItems: '--select-loader-align-items',
5754
+ justifyContent: '--select-loader-justify-content',
5705
5755
  });
5706
5756
  }
5757
+ _syncLoaderClassNames(additionalTarget) {
5758
+ const classNames = new Set((this._config.styles.classNames?.loader ?? '').split(/\s+/).filter(Boolean));
5759
+ const targets = [
5760
+ this._busyBucket,
5761
+ this._optionsContainer?.querySelector('.searching-state'),
5762
+ additionalTarget,
5763
+ ].filter((element) => Boolean(element));
5764
+ for (const target of targets) {
5765
+ target.classList.remove(...this._managedLoaderClasses);
5766
+ target.classList.add(...classNames);
5767
+ }
5768
+ this._managedLoaderClasses = classNames;
5769
+ }
5707
5770
  _resolveDropdownPlacement() {
5708
5771
  const placementMode = this._config.dropdownPlacement?.mode ?? 'bottom';
5709
5772
  if (placementMode === 'bottom' || placementMode === 'top') {
@@ -5731,12 +5794,25 @@ class EnhancedSelect extends HTMLElement {
5731
5794
  }
5732
5795
  _setIconContent(target, markup, fallback) {
5733
5796
  const content = markup && markup.trim() ? markup : fallback;
5734
- target.innerHTML = '';
5797
+ let fallbackTarget = target.querySelector(':scope > [data-smilodon-fallback-icon]');
5798
+ if (!fallbackTarget) {
5799
+ fallbackTarget = document.createElement('span');
5800
+ fallbackTarget.setAttribute('data-smilodon-fallback-icon', '');
5801
+ target.prepend(fallbackTarget);
5802
+ }
5803
+ if (!target.querySelector(':scope > [data-smilodon-react-icon-root]')) {
5804
+ const portalRoot = document.createElement('span');
5805
+ portalRoot.setAttribute('data-smilodon-react-icon-root', '');
5806
+ target.append(portalRoot);
5807
+ }
5808
+ // Only Core's fallback subtree is replaceable. React may reconcile a
5809
+ // separate portal root beneath this stable icon target.
5810
+ fallbackTarget.replaceChildren();
5735
5811
  if (content.trim().startsWith('<')) {
5736
- target.innerHTML = content;
5812
+ fallbackTarget.innerHTML = content;
5737
5813
  return;
5738
5814
  }
5739
- target.textContent = content;
5815
+ fallbackTarget.textContent = content;
5740
5816
  }
5741
5817
  _syncInputContainerMode() {
5742
5818
  if (!this._inputContainer || !this._input)
@@ -5959,6 +6035,27 @@ class EnhancedSelect extends HTMLElement {
5959
6035
  tooltip.hidden = true;
5960
6036
  return tooltip;
5961
6037
  }
6038
+ _createSelectedLabelTooltipTextMeasure() {
6039
+ const measure = document.createElement('span');
6040
+ measure.setAttribute('aria-hidden', 'true');
6041
+ measure.dataset.selectInternal = 'tooltip-measure';
6042
+ measure.style.cssText = [
6043
+ 'all: initial',
6044
+ 'position: fixed',
6045
+ 'left: -100000px',
6046
+ 'top: 0',
6047
+ 'display: inline-block',
6048
+ 'width: max-content',
6049
+ 'height: auto',
6050
+ 'padding: 0',
6051
+ 'margin: 0',
6052
+ 'border: 0',
6053
+ 'white-space: pre',
6054
+ 'visibility: hidden',
6055
+ 'pointer-events: none',
6056
+ ].join(';');
6057
+ return measure;
6058
+ }
5962
6059
  _createDropdown() {
5963
6060
  const dropdown = document.createElement('div');
5964
6061
  dropdown.className = 'select-dropdown';
@@ -5967,11 +6064,139 @@ class EnhancedSelect extends HTMLElement {
5967
6064
  if (this._config.styles.classNames?.dropdown) {
5968
6065
  dropdown.className += ' ' + this._config.styles.classNames.dropdown;
5969
6066
  }
5970
- if (this._config.styles.dropdown) {
5971
- Object.assign(dropdown.style, this._config.styles.dropdown);
5972
- }
5973
6067
  return dropdown;
5974
6068
  }
6069
+ _syncDropdownConfigInlineStyles() {
6070
+ if (!this._dropdown)
6071
+ return;
6072
+ const toCssProperty = (property) => {
6073
+ if (property.startsWith('--'))
6074
+ return property;
6075
+ if (property === 'cssFloat')
6076
+ return 'float';
6077
+ return property.replace(/[A-Z]/g, (character) => `-${character.toLowerCase()}`);
6078
+ };
6079
+ const configured = new Map();
6080
+ for (const [property, value] of Object.entries(this._config.styles.dropdown ?? {})) {
6081
+ if (value === undefined || value === null || String(value).trim() === '')
6082
+ continue;
6083
+ configured.set(toCssProperty(property), String(value));
6084
+ }
6085
+ const style = this._dropdown.style;
6086
+ const readValue = (property) => style.getPropertyValue(property).trim();
6087
+ const readSnapshot = (property) => ({
6088
+ value: readValue(property),
6089
+ priority: style.getPropertyPriority(property),
6090
+ });
6091
+ const sameSnapshot = (left, right) => left.value === right.value && left.priority === right.priority;
6092
+ const readBorderParts = () => new Map(DROPDOWN_BORDER_LONGHANDS.map((part) => [part, readSnapshot(part)]));
6093
+ const restoreValue = (property, value, priority) => {
6094
+ if (value)
6095
+ style.setProperty(property, value, priority);
6096
+ else
6097
+ style.removeProperty(property);
6098
+ };
6099
+ for (const [property, previousOwnership] of this._dropdownConfigInlineStyles) {
6100
+ const currentValue = readValue(property);
6101
+ const currentPriority = style.getPropertyPriority(property);
6102
+ const isStillCoreOwned = currentValue === previousOwnership.appliedValue
6103
+ && currentPriority === previousOwnership.appliedPriority;
6104
+ const previousValue = isStillCoreOwned ? previousOwnership.previousValue : currentValue;
6105
+ const previousPriority = isStillCoreOwned ? previousOwnership.previousPriority : currentPriority;
6106
+ const nextValue = configured.get(property);
6107
+ const relatedBorderParts = previousOwnership.relatedBorderParts;
6108
+ if (nextValue === undefined) {
6109
+ const borderPartRestorations = relatedBorderParts
6110
+ ? [...relatedBorderParts].map(([part, ownership]) => {
6111
+ const current = readSnapshot(part);
6112
+ return [part, sameSnapshot(current, ownership.applied) ? ownership.previous : current];
6113
+ })
6114
+ : [];
6115
+ if (isStillCoreOwned)
6116
+ restoreValue(property, previousValue, previousPriority);
6117
+ for (const [part, restore] of borderPartRestorations) {
6118
+ restoreValue(part, restore.value, restore.priority);
6119
+ }
6120
+ // A shorthand and a longhand can both own the same border components.
6121
+ // When one layer is released, rebase any still-active layer whose saved
6122
+ // baseline came from the released layer's applied value. Otherwise the
6123
+ // final release can resurrect an intermediate Core value instead of
6124
+ // the consumer-authored declaration.
6125
+ if (relatedBorderParts) {
6126
+ for (const [otherProperty, otherOwnership] of this._dropdownConfigInlineStyles) {
6127
+ if (otherProperty === property || !otherOwnership.relatedBorderParts)
6128
+ continue;
6129
+ for (const [part, released] of relatedBorderParts) {
6130
+ const other = otherOwnership.relatedBorderParts.get(part);
6131
+ if (!other)
6132
+ continue;
6133
+ const current = readSnapshot(part);
6134
+ if (sameSnapshot(current, other.applied) && sameSnapshot(other.previous, released.applied)) {
6135
+ otherOwnership.relatedBorderParts.set(part, {
6136
+ ...other,
6137
+ previous: released.previous,
6138
+ });
6139
+ }
6140
+ }
6141
+ }
6142
+ }
6143
+ this._dropdownConfigInlineStyles.delete(property);
6144
+ continue;
6145
+ }
6146
+ const tracksBorderParts = property === 'border' || property === 'border-width';
6147
+ const beforeBorderParts = tracksBorderParts ? readBorderParts() : undefined;
6148
+ style.setProperty(property, nextValue);
6149
+ const afterBorderParts = tracksBorderParts ? readBorderParts() : undefined;
6150
+ let nextRelatedBorderParts;
6151
+ if (beforeBorderParts && afterBorderParts) {
6152
+ nextRelatedBorderParts = new Map();
6153
+ for (const part of DROPDOWN_BORDER_LONGHANDS) {
6154
+ const before = beforeBorderParts.get(part);
6155
+ const after = afterBorderParts.get(part);
6156
+ const previous = relatedBorderParts?.get(part);
6157
+ if (previous || !sameSnapshot(before, after)) {
6158
+ nextRelatedBorderParts.set(part, {
6159
+ previous: previous && sameSnapshot(before, previous.applied) ? previous.previous : before,
6160
+ applied: after,
6161
+ });
6162
+ }
6163
+ }
6164
+ }
6165
+ this._dropdownConfigInlineStyles.set(property, {
6166
+ appliedValue: readValue(property),
6167
+ appliedPriority: style.getPropertyPriority(property),
6168
+ previousValue,
6169
+ previousPriority,
6170
+ ...(nextRelatedBorderParts ? { relatedBorderParts: nextRelatedBorderParts } : {}),
6171
+ });
6172
+ configured.delete(property);
6173
+ }
6174
+ for (const [property, value] of configured) {
6175
+ const previousValue = readValue(property);
6176
+ const previousPriority = style.getPropertyPriority(property);
6177
+ const tracksBorderParts = property === 'border' || property === 'border-width';
6178
+ const beforeBorderParts = tracksBorderParts ? readBorderParts() : undefined;
6179
+ style.setProperty(property, value);
6180
+ const afterBorderParts = tracksBorderParts ? readBorderParts() : undefined;
6181
+ let relatedBorderParts;
6182
+ if (beforeBorderParts && afterBorderParts) {
6183
+ relatedBorderParts = new Map();
6184
+ for (const part of DROPDOWN_BORDER_LONGHANDS) {
6185
+ const before = beforeBorderParts.get(part);
6186
+ const after = afterBorderParts.get(part);
6187
+ if (!sameSnapshot(before, after))
6188
+ relatedBorderParts.set(part, { previous: before, applied: after });
6189
+ }
6190
+ }
6191
+ this._dropdownConfigInlineStyles.set(property, {
6192
+ appliedValue: readValue(property),
6193
+ appliedPriority: style.getPropertyPriority(property),
6194
+ previousValue,
6195
+ previousPriority,
6196
+ ...(relatedBorderParts ? { relatedBorderParts } : {}),
6197
+ });
6198
+ }
6199
+ }
5975
6200
  _createOptionsContainer() {
5976
6201
  const container = document.createElement('div');
5977
6202
  container.className = `options-container ${EnhancedSelect._MIRRORED_STYLES_SCOPE_CLASS}`;
@@ -6054,6 +6279,7 @@ class EnhancedSelect extends HTMLElement {
6054
6279
  this._shadow.appendChild(this._errorDescription);
6055
6280
  }
6056
6281
  this._shadow.appendChild(this._selectedLabelTooltip);
6282
+ this._shadow.appendChild(this._selectedLabelTooltipTextMeasure);
6057
6283
  // Set ARIA relationships
6058
6284
  const listboxId = `${this._uniqueId}-listbox`;
6059
6285
  this._dropdown.id = listboxId;
@@ -6238,7 +6464,6 @@ class EnhancedSelect extends HTMLElement {
6238
6464
  --select-group-header-separator-border-top: none;
6239
6465
  --select-reduced-motion-duration: 0.01ms;
6240
6466
  --select-reduced-motion-iteration-count: 1;
6241
- --select-high-contrast-border-width: 2px;
6242
6467
  --select-high-contrast-indicator-width: 4px;
6243
6468
  --select-high-contrast-focus-outline-width: 3px;
6244
6469
  --select-high-contrast-focus-outline-color: Highlight;
@@ -6405,6 +6630,15 @@ class EnhancedSelect extends HTMLElement {
6405
6630
  pointer-events: none;
6406
6631
  }
6407
6632
 
6633
+ .badge-remove-icon > [data-smilodon-fallback-icon],
6634
+ .badge-remove-icon > [data-smilodon-react-icon-root] {
6635
+ display: contents;
6636
+ }
6637
+
6638
+ .badge-remove-icon[data-smilodon-icon-owner="react"] > [data-smilodon-fallback-icon] {
6639
+ display: none;
6640
+ }
6641
+
6408
6642
  .badge-remove-icon svg {
6409
6643
  width: 100%;
6410
6644
  height: 100%;
@@ -6899,7 +7133,10 @@ class EnhancedSelect extends HTMLElement {
6899
7133
  overflow: hidden;
6900
7134
  box-sizing: border-box;
6901
7135
  background: var(--select-dropdown-bg, var(--select-surface));
6902
- border: 1px solid var(--select-dropdown-border, var(--select-border));
7136
+ border:
7137
+ var(--select-dropdown-border-width, 1px)
7138
+ var(--select-dropdown-border-style, solid)
7139
+ var(--select-dropdown-border, var(--select-border));
6903
7140
  border-radius: var(--select-dropdown-border-radius, var(--select-radius-lg));
6904
7141
  box-shadow: var(--select-dropdown-shadow, var(--select-shadow-lg));
6905
7142
  z-index: var(--select-dropdown-z-index, 1000);
@@ -6990,11 +7227,11 @@ class EnhancedSelect extends HTMLElement {
6990
7227
  font-size: var(--select-group-header-font-size, 0.7333em);
6991
7228
  text-transform: var(--select-group-header-text-transform, uppercase);
6992
7229
  letter-spacing: var(--select-group-header-letter-spacing, 0.08em);
6993
- position: sticky;
6994
- top: calc(var(--select-options-padding, 6px) * -1);
7230
+ position: var(--select-group-header-position, sticky);
7231
+ top: var(--select-group-header-top, calc(var(--select-options-padding, 6px) * -1));
6995
7232
  left: 0;
6996
7233
  right: 0;
6997
- z-index: 100;
7234
+ z-index: var(--select-group-header-z-index, 100);
6998
7235
  border: var(--select-group-header-border, none);
6999
7236
  border-bottom: var(--select-group-header-border-bottom, 1px solid rgba(0, 0, 0, 0.08));
7000
7237
  border-radius: var(--select-group-header-border-radius, 0);
@@ -7017,6 +7254,7 @@ class EnhancedSelect extends HTMLElement {
7017
7254
 
7018
7255
  .option {
7019
7256
  position: relative;
7257
+ z-index: var(--select-option-z-index, auto);
7020
7258
  padding: var(--select-option-padding, 10px 14px);
7021
7259
  cursor: pointer;
7022
7260
  color: var(--select-option-color, var(--select-text));
@@ -7121,7 +7359,7 @@ class EnhancedSelect extends HTMLElement {
7121
7359
  border: var(--select-option-disabled-border, var(--select-option-border, none));
7122
7360
  opacity: var(--select-option-disabled-opacity, 0.5);
7123
7361
  cursor: var(--select-option-disabled-cursor, not-allowed);
7124
- pointer-events: var(--select-option-disabled-pointer-events, none);
7362
+ pointer-events: var(--select-option-disabled-pointer-events, auto);
7125
7363
  }
7126
7364
 
7127
7365
  .option.smilodon-option--disabled-interactive {
@@ -7185,14 +7423,14 @@ class EnhancedSelect extends HTMLElement {
7185
7423
  .busy-bucket {
7186
7424
  display: flex;
7187
7425
  flex-direction: column;
7188
- align-items: center;
7189
- justify-content: center;
7190
- gap: var(--select-busy-gap, 8px);
7191
- padding: var(--select-busy-padding, 20px);
7192
- text-align: center;
7193
- color: var(--select-busy-color, var(--select-text-muted));
7194
- background: var(--select-busy-bg, transparent);
7195
- font-size: var(--select-busy-font-size, 0.8667em);
7426
+ gap: var(--select-loader-gap, var(--select-busy-gap, 8px));
7427
+ padding: var(--select-loader-padding, var(--select-busy-padding, 20px));
7428
+ text-align: var(--select-loader-text-align, center);
7429
+ color: var(--select-loader-color, var(--select-busy-color, var(--select-text-muted)));
7430
+ background: var(--select-loader-bg, var(--select-busy-bg, transparent));
7431
+ font-size: var(--select-loader-font-size, var(--select-busy-font-size, 0.8667em));
7432
+ align-items: var(--select-loader-align-items, center);
7433
+ justify-content: var(--select-loader-justify-content, center);
7196
7434
  }
7197
7435
 
7198
7436
  .busy-icon {
@@ -7246,26 +7484,27 @@ class EnhancedSelect extends HTMLElement {
7246
7484
  }
7247
7485
 
7248
7486
  .searching-state {
7249
- padding: var(--select-searching-padding, 32px 24px);
7250
- text-align: center;
7251
- color: var(--select-searching-color, var(--select-accent));
7252
- font-size: var(--select-searching-font-size, 0.9333em);
7253
- background: var(--select-searching-bg, transparent);
7487
+ padding: var(--select-loader-padding, var(--select-searching-padding, 32px 24px));
7488
+ text-align: var(--select-loader-text-align, center);
7489
+ color: var(--select-loader-color, var(--select-searching-color, var(--select-accent)));
7490
+ font-size: var(--select-loader-font-size, var(--select-searching-font-size, 0.9333em));
7491
+ background: var(--select-loader-bg, var(--select-searching-bg, transparent));
7254
7492
  display: flex;
7255
7493
  flex-direction: column;
7256
- align-items: center;
7257
- justify-content: center;
7258
- gap: var(--select-searching-gap);
7494
+ align-items: var(--select-loader-align-items, center);
7495
+ justify-content: var(--select-loader-justify-content, center);
7496
+ gap: var(--select-loader-gap, var(--select-searching-gap, 8px));
7259
7497
  }
7260
7498
 
7261
- .searching-state::before {
7262
- content: '';
7499
+ .searching-spinner {
7500
+ display: inline-block;
7263
7501
  width: var(--select-searching-spinner-size);
7264
7502
  height: var(--select-searching-spinner-size);
7265
7503
  border: var(--select-searching-spinner-border);
7266
7504
  border-top-color: var(--select-searching-spinner-active-color);
7267
7505
  border-radius: 50%;
7268
7506
  animation: var(--select-searching-spinner-animation);
7507
+ flex: 0 0 auto;
7269
7508
  }
7270
7509
 
7271
7510
  /* ─────────────────────────────────────────────────────────────────────────
@@ -7299,14 +7538,10 @@ class EnhancedSelect extends HTMLElement {
7299
7538
  }
7300
7539
  }
7301
7540
 
7302
- @media (prefers-contrast: high) {
7303
- .select-input:focus {
7304
- outline-width: var(--select-high-contrast-focus-outline-width);
7305
- outline-color: var(--select-high-contrast-focus-outline-color);
7306
- }
7307
-
7308
- .input-container {
7309
- border-width: var(--select-high-contrast-border-width);
7541
+ @media (prefers-contrast: more) {
7542
+ .input-container:focus-within {
7543
+ outline: var(--select-high-contrast-focus-outline-width) solid var(--select-high-contrast-focus-outline-color);
7544
+ outline-offset: 2px;
7310
7545
  }
7311
7546
 
7312
7547
  .option.selected::before {
@@ -7398,7 +7633,6 @@ class EnhancedSelect extends HTMLElement {
7398
7633
  :host-context([data-theme="dark"]) .input-container,
7399
7634
  :host-context([theme="dark"]) .input-container {
7400
7635
  background: var(--select-surface);
7401
- border-color: var(--select-border);
7402
7636
  }
7403
7637
 
7404
7638
  :host(.dark-mode) .input-container:hover,
@@ -7427,7 +7661,7 @@ class EnhancedSelect extends HTMLElement {
7427
7661
  :host-context([darkmode]) .input-container:focus-within,
7428
7662
  :host-context([data-theme="dark"]) .input-container:focus-within,
7429
7663
  :host-context([theme="dark"]) .input-container:focus-within {
7430
- border-color: var(--select-dark-border-focus, var(--select-border-focus, #6366f1));
7664
+ border-color: var(--select-dark-border-focus, var(--select-input-focus-border, var(--select-border-focus, #6366f1)));
7431
7665
  box-shadow: var(--select-dark-shadow-focus, var(--select-shadow-focus, 0 0 0 3px rgba(99, 102, 241, 0.25))), var(--select-shadow-sm);
7432
7666
  }
7433
7667
 
@@ -7457,7 +7691,6 @@ class EnhancedSelect extends HTMLElement {
7457
7691
  :host-context([data-theme="dark"]) .select-dropdown,
7458
7692
  :host-context([theme="dark"]) .select-dropdown {
7459
7693
  background: var(--select-dropdown-bg, var(--select-surface));
7460
- border-color: var(--select-border);
7461
7694
  }
7462
7695
 
7463
7696
  :host(.dark-mode) .options-container,
@@ -7580,7 +7813,6 @@ class EnhancedSelect extends HTMLElement {
7580
7813
  keyboardEvent.stopPropagation();
7581
7814
  this._dismissSelectedLabelTooltip();
7582
7815
  });
7583
- this._inputContent.addEventListener('scroll', this._scheduleSelectedLabelTooltipMeasure, { passive: true });
7584
7816
  // Arrow click handler
7585
7817
  if (this._arrowContainer) {
7586
7818
  this._boundArrowClick = (e) => {
@@ -7593,7 +7825,7 @@ class EnhancedSelect extends HTMLElement {
7593
7825
  this._handleClose();
7594
7826
  }
7595
7827
  else if (!this._state.isOpen) {
7596
- this._handleOpen();
7828
+ this._handleOpen('pointer');
7597
7829
  }
7598
7830
  };
7599
7831
  this._arrowContainer.addEventListener('click', this._boundArrowClick);
@@ -7650,7 +7882,7 @@ class EnhancedSelect extends HTMLElement {
7650
7882
  }
7651
7883
  const wasClosed = !this._state.isOpen;
7652
7884
  if (wasClosed) {
7653
- this._handleOpen();
7885
+ this._handleOpen('pointer');
7654
7886
  }
7655
7887
  // Focus the input (do not prevent default behavior for input itself)
7656
7888
  this._applyFocusIntent('input', 'input-container-trigger');
@@ -7687,7 +7919,7 @@ class EnhancedSelect extends HTMLElement {
7687
7919
  this._suppressNextOpenClick = false;
7688
7920
  this._multiScrollDrag.moved = false;
7689
7921
  if (!this._state.isOpen) {
7690
- this._handleOpen();
7922
+ this._handleOpen('pointer');
7691
7923
  }
7692
7924
  this._applyFocusIntent('input', 'input-container-activation');
7693
7925
  });
@@ -7749,49 +7981,65 @@ class EnhancedSelect extends HTMLElement {
7749
7981
  if (!this._config.searchable)
7750
7982
  return;
7751
7983
  const query = e.target.value;
7752
- if (this._selectedLabelTooltipTrigger === this._input
7753
- && this._getSelectedLabelForTrigger(this._input) === null) {
7754
- this._hideSelectedLabelTooltip();
7984
+ if (this._selectedLabelTooltipDismissedTrigger === this._input) {
7985
+ this._selectedLabelTooltipDismissedTrigger = null;
7755
7986
  }
7756
7987
  this._handleSearch(query);
7757
7988
  });
7758
- // If the user presses down inside the options container we should
7759
- // temporarily suppress blur-based closing until after the click has
7760
- // been handled. Setting a flag that gets cleared in the next tick is
7761
- // sufficient.
7762
- this._optionsContainer.addEventListener('pointerdown', () => {
7989
+ const findOptionElement = (event) => {
7990
+ const path = typeof event.composedPath === 'function' ? event.composedPath() : [event.target];
7991
+ for (const node of path) {
7992
+ if (!(node instanceof Element))
7993
+ continue;
7994
+ if (node.matches('select-option[data-sm-index], [data-sm-selectable][data-sm-index], [data-selectable][data-index]')) {
7995
+ return node;
7996
+ }
7997
+ }
7998
+ return null;
7999
+ };
8000
+ const resolveOptionRecord = (event, option = findOptionElement(event)) => {
8001
+ if (!option)
8002
+ return null;
8003
+ const index = Number(option.getAttribute('data-sm-index') ?? option.getAttribute('data-index'));
8004
+ if (!Number.isSafeInteger(index) || index < 0)
8005
+ return null;
8006
+ this._ensureRegistryCurrent();
8007
+ const record = this._getRecordByIndex(index);
8008
+ return record ? { option, record } : null;
8009
+ };
8010
+ // Keep the input focused when a blocked disabled option is pressed. This
8011
+ // prevents the delayed blur-close path from racing the delegated click.
8012
+ this._optionsContainer.addEventListener('pointerdown', (event) => {
7763
8013
  this._suppressBlurClose = true;
7764
8014
  this._setLifecycleTimeout(() => {
7765
8015
  this._suppressBlurClose = false;
7766
8016
  }, 150); // Increased timeout to ensure click finishes before blur checks
8017
+ const option = findOptionElement(event);
8018
+ if (!option?.matches('[aria-disabled="true"], .smilodon-option--disabled, .disabled'))
8019
+ return;
8020
+ const resolved = resolveOptionRecord(event, option);
8021
+ if (!resolved || !resolved.record.disabled)
8022
+ return;
8023
+ if (this._getDisabledOptionBehavior().selectable)
8024
+ return;
8025
+ event.preventDefault();
7767
8026
  });
7768
8027
  // Delegated click listener for improved event handling (robust across shadow DOM)
7769
8028
  const handleOptionEvent = (e) => {
7770
- const path = (e.composedPath && e.composedPath()) || [e.target];
7771
- let option = null;
7772
- for (const node of path) {
7773
- if (!(node instanceof Element))
7774
- continue;
7775
- try {
7776
- if (node.matches('[data-sm-selectable], [data-selectable], [data-sm-state]')) {
7777
- option = node;
7778
- break;
7779
- }
7780
- }
7781
- catch (err) {
7782
- continue;
7783
- }
7784
- }
7785
- if (option && (!option.hasAttribute('aria-disabled') || option.classList.contains('smilodon-option--disabled-selectable'))) {
7786
- const indexStr = option.getAttribute('data-sm-index') ?? option.getAttribute('data-index');
7787
- const index = Number(indexStr);
7788
- if (!Number.isNaN(index)) {
7789
- this._selectOption(index, {
7790
- shiftKey: e.shiftKey,
7791
- toggleKey: e.ctrlKey || e.metaKey,
7792
- });
7793
- }
8029
+ const resolved = resolveOptionRecord(e);
8030
+ if (!resolved)
8031
+ return;
8032
+ const behavior = this._getDisabledOptionBehavior();
8033
+ if (resolved.record.disabled && !behavior.selectable) {
8034
+ e.preventDefault();
8035
+ if (behavior.closeOnClick)
8036
+ this._handleClose('disabled-option-click');
8037
+ return;
7794
8038
  }
8039
+ this._selectOption(resolved.record.index, {
8040
+ shiftKey: e.shiftKey,
8041
+ toggleKey: e.ctrlKey || e.metaKey,
8042
+ });
7795
8043
  };
7796
8044
  this._optionsContainer.addEventListener('click', handleOptionEvent);
7797
8045
  // Keyboard navigation
@@ -7928,7 +8176,7 @@ class EnhancedSelect extends HTMLElement {
7928
8176
  _getSelectedLabelForTrigger(trigger) {
7929
8177
  const entries = this._getSelectedEntries();
7930
8178
  if (trigger === this._input) {
7931
- if (this._config.selection.mode !== 'single' || this._state.searchQuery.length > 0)
8179
+ if (this._config.selection.mode !== 'single')
7932
8180
  return null;
7933
8181
  const item = entries[0]?.item;
7934
8182
  if (item === undefined)
@@ -7952,6 +8200,57 @@ class EnhancedSelect extends HTMLElement {
7952
8200
  return false;
7953
8201
  return trigger.clientWidth > 0 && trigger.scrollWidth > trigger.clientWidth + 1;
7954
8202
  }
8203
+ _getSelectedLabelTooltipContent(trigger) {
8204
+ if (trigger === this._input && this._config.searchable) {
8205
+ const visibleText = this._input.value;
8206
+ const pendingQuery = this._acknowledgedPendingSearchQuery;
8207
+ const committedQuery = this._state.searchQuery;
8208
+ const isPendingQuery = pendingQuery !== null && pendingQuery.length > 0 && visibleText === pendingQuery;
8209
+ const isCommittedQuery = committedQuery.length > 0 && visibleText === committedQuery;
8210
+ if (visibleText.length > 0 && (isPendingQuery || isCommittedQuery)) {
8211
+ return { kind: 'search-query', text: visibleText };
8212
+ }
8213
+ }
8214
+ const selectedLabel = this._getSelectedLabelForTrigger(trigger);
8215
+ return selectedLabel === null ? null : { kind: 'selected-label', text: selectedLabel };
8216
+ }
8217
+ _isSelectedLabelTooltipContentTruncated(trigger, content) {
8218
+ if (trigger !== this._input)
8219
+ return this._isSelectedLabelTruncated(trigger);
8220
+ if (!trigger.isConnected || !content.text)
8221
+ return false;
8222
+ const style = getComputedStyle(this._input);
8223
+ const measure = this._selectedLabelTooltipTextMeasure;
8224
+ measure.textContent = content.text;
8225
+ const mirroredProperties = [
8226
+ 'font',
8227
+ 'font-family',
8228
+ 'font-size',
8229
+ 'font-style',
8230
+ 'font-weight',
8231
+ 'font-stretch',
8232
+ 'font-variant',
8233
+ 'font-kerning',
8234
+ 'font-feature-settings',
8235
+ 'font-variation-settings',
8236
+ 'letter-spacing',
8237
+ 'word-spacing',
8238
+ 'text-transform',
8239
+ 'direction',
8240
+ 'unicode-bidi',
8241
+ ];
8242
+ for (const property of mirroredProperties) {
8243
+ const value = style.getPropertyValue(property);
8244
+ if (value)
8245
+ measure.style.setProperty(property, value);
8246
+ }
8247
+ const contentWidth = measure.getBoundingClientRect().width;
8248
+ const inputStyle = style;
8249
+ const horizontalPadding = Number.parseFloat(inputStyle.paddingLeft) + Number.parseFloat(inputStyle.paddingRight);
8250
+ const textIndent = Number.parseFloat(inputStyle.textIndent) || 0;
8251
+ const availableWidth = this._input.clientWidth - (Number.isFinite(horizontalPadding) ? horizontalPadding : 0) - textIndent;
8252
+ return availableWidth > 0 && contentWidth > availableWidth + 1;
8253
+ }
7955
8254
  _handleSelectedLabelPointerOver(event) {
7956
8255
  const target = event.target;
7957
8256
  if (target?.closest('.selected-label-tooltip') === this._selectedLabelTooltip) {
@@ -8017,8 +8316,8 @@ class EnhancedSelect extends HTMLElement {
8017
8316
  this._hideSelectedLabelTooltip();
8018
8317
  return;
8019
8318
  }
8020
- const label = this._getSelectedLabelForTrigger(trigger);
8021
- if (label === null || !this._isSelectedLabelTruncated(trigger)) {
8319
+ const content = this._getSelectedLabelTooltipContent(trigger);
8320
+ if (content === null || !this._isSelectedLabelTooltipContentTruncated(trigger, content)) {
8022
8321
  if (trigger.classList.contains('selection-badge-label'))
8023
8322
  trigger.tabIndex = -1;
8024
8323
  if (this._selectedLabelTooltipTrigger === trigger)
@@ -8031,7 +8330,7 @@ class EnhancedSelect extends HTMLElement {
8031
8330
  this._removeSelectedLabelTooltipDescription(this._selectedLabelTooltipTrigger);
8032
8331
  this._selectedLabelTooltipTrigger = trigger;
8033
8332
  }
8034
- this._selectedLabelTooltip.textContent = label;
8333
+ this._selectedLabelTooltip.textContent = content.text;
8035
8334
  this._selectedLabelTooltip.hidden = false;
8036
8335
  this._positionSelectedLabelTooltip(trigger);
8037
8336
  this._syncSelectedLabelTooltipDescription();
@@ -8085,6 +8384,7 @@ class EnhancedSelect extends HTMLElement {
8085
8384
  this._removeSelectedLabelTooltipDescription(this._selectedLabelTooltipTrigger);
8086
8385
  this._selectedLabelTooltipTrigger = null;
8087
8386
  this._selectedLabelTooltip.hidden = true;
8387
+ this._selectedLabelTooltipTextMeasure.textContent = '';
8088
8388
  if (clearInteractionState) {
8089
8389
  this._selectedLabelTooltipPointerTrigger = null;
8090
8390
  this._selectedLabelTooltipFocusTrigger = null;
@@ -8142,10 +8442,12 @@ class EnhancedSelect extends HTMLElement {
8142
8442
  return;
8143
8443
  const hasSingleSelection = this._config.selection.mode === 'single'
8144
8444
  && this._getSelectedEntries().length > 0;
8445
+ const inputContent = this._getSelectedLabelTooltipContent(this._input);
8446
+ const shouldObserveInput = hasSingleSelection || inputContent?.kind === 'search-query';
8145
8447
  const chipLabels = this._getActiveChipBadges()
8146
8448
  .map((badge) => badge.querySelector('.selection-badge-label'))
8147
8449
  .filter((label) => label !== null);
8148
- if (!hasSingleSelection && chipLabels.length === 0) {
8450
+ if (!shouldObserveInput && chipLabels.length === 0) {
8149
8451
  this._selectedLabelTooltipResizeObserver?.disconnect();
8150
8452
  this._selectedLabelTooltipResizeObserver = null;
8151
8453
  return;
@@ -8154,7 +8456,7 @@ class EnhancedSelect extends HTMLElement {
8154
8456
  this._selectedLabelTooltipResizeObserver = new ResizeObserver(() => this._scheduleSelectedLabelTooltipMeasure());
8155
8457
  }
8156
8458
  this._selectedLabelTooltipResizeObserver.disconnect();
8157
- if (hasSingleSelection)
8459
+ if (shouldObserveInput)
8158
8460
  this._selectedLabelTooltipResizeObserver.observe(this._input);
8159
8461
  chipLabels.forEach((label) => {
8160
8462
  this._selectedLabelTooltipResizeObserver?.observe(label);
@@ -8188,8 +8490,8 @@ class EnhancedSelect extends HTMLElement {
8188
8490
  this._hideSelectedLabelTooltip();
8189
8491
  return;
8190
8492
  }
8191
- const label = this._getSelectedLabelForTrigger(trigger);
8192
- if (label === null || !this._isSelectedLabelTruncated(trigger)) {
8493
+ const content = this._getSelectedLabelTooltipContent(trigger);
8494
+ if (content === null || !this._isSelectedLabelTooltipContentTruncated(trigger, content)) {
8193
8495
  if (this._selectedLabelTooltipTrigger === trigger)
8194
8496
  this._hideSelectedLabelTooltip();
8195
8497
  return;
@@ -8251,7 +8553,7 @@ class EnhancedSelect extends HTMLElement {
8251
8553
  },
8252
8554
  }, { applyFocus: true });
8253
8555
  }
8254
- _handleOpen() {
8556
+ _handleOpen(intent = 'default') {
8255
8557
  if (!this._config.enabled) {
8256
8558
  this._runEngineEffects(this._engine.dispatch({ type: 'DISABLED_CHANGED', disabled: true }));
8257
8559
  return;
@@ -8285,10 +8587,17 @@ class EnhancedSelect extends HTMLElement {
8285
8587
  this._liftStackingAncestors();
8286
8588
  this._dropdown.style.display = 'block';
8287
8589
  this._updateArrowRotation();
8590
+ // Pointer opening must not turn the previous selection or stale active key
8591
+ // into a synthetic hover-like highlight. Clear engine identity before the
8592
+ // options are rendered so built-in and custom renderers share the same state.
8593
+ if (intent === 'pointer') {
8594
+ this._dispatchActiveKey(null, 'open', 'pointer dropdown open');
8595
+ }
8288
8596
  // Render options when opening
8289
8597
  this._renderOptions();
8290
8598
  this._syncDropdownPlacement();
8291
- this._setInitialActiveOption();
8599
+ if (intent !== 'pointer')
8600
+ this._setInitialActiveOption();
8292
8601
  this._emit('open', {});
8293
8602
  this._config.callbacks.onOpen?.();
8294
8603
  this._announce('Options expanded');
@@ -8791,10 +9100,8 @@ class EnhancedSelect extends HTMLElement {
8791
9100
  return results;
8792
9101
  }
8793
9102
  _handleSearch(query) {
8794
- if (this._selectedLabelTooltipTrigger === this._input
8795
- && (query.length > 0 || this._getSelectedLabelForTrigger(this._input) === null)) {
8796
- this._hideSelectedLabelTooltip();
8797
- }
9103
+ const previousQuery = this._acknowledgedPendingSearchQuery ?? this._state.searchQuery;
9104
+ const queryPresenceChanged = Boolean(previousQuery) !== Boolean(query);
8798
9105
  if (this._dataRequestCoordinator
8799
9106
  && (this._acknowledgedProjectionPending || this._acknowledgedProjectionSettling)) {
8800
9107
  // Keep the committed query/generation stable until the accepted snapshot
@@ -8803,6 +9110,9 @@ class EnhancedSelect extends HTMLElement {
8803
9110
  this._acknowledgedPendingSearchQuery = query;
8804
9111
  this._input.value = query;
8805
9112
  this._syncClearControlState();
9113
+ if (queryPresenceChanged)
9114
+ this._observeSelectedLabelTooltipTargets();
9115
+ this._refreshSelectedLabelTooltipMeasurements();
8806
9116
  return;
8807
9117
  }
8808
9118
  if (this._dataLoadingConfig.protocol === 'acknowledged'
@@ -8814,6 +9124,9 @@ class EnhancedSelect extends HTMLElement {
8814
9124
  this._cancelBusyPresentation();
8815
9125
  this._state.searchQuery = query;
8816
9126
  this._syncClearControlState();
9127
+ if (queryPresenceChanged)
9128
+ this._observeSelectedLabelTooltipTargets();
9129
+ this._refreshSelectedLabelTooltipMeasurements();
8817
9130
  this._state.lastNotifiedQuery = query;
8818
9131
  this._state.lastNotifiedResultCount = 0;
8819
9132
  if (this._dataRequestCoordinator) {
@@ -8852,6 +9165,9 @@ class EnhancedSelect extends HTMLElement {
8852
9165
  }
8853
9166
  this._state.searchQuery = query;
8854
9167
  this._syncClearControlState();
9168
+ if (queryPresenceChanged)
9169
+ this._observeSelectedLabelTooltipTargets();
9170
+ this._refreshSelectedLabelTooltipMeasurements();
8855
9171
  if (this._dataLoadingConfig.protocol === 'acknowledged' && this._dataRequestCoordinator) {
8856
9172
  // Local acknowledged search has no remote request, but pagination still
8857
9173
  // belongs to the coordinator's current query generation.
@@ -9366,7 +9682,7 @@ class EnhancedSelect extends HTMLElement {
9366
9682
  const selectableIndices = this._getSelectableOptionIndices();
9367
9683
  const selected = Array.from(this._state.selectedIndices).sort((a, b) => a - b);
9368
9684
  // Opening an empty select must not implicitly assign an active descendant.
9369
- // Keyboard navigation and pointer interaction establish active identity.
9685
+ // Keyboard navigation and option interaction establish active identity.
9370
9686
  if (selectableIndices.length === 0 || selected.length === 0) {
9371
9687
  this._dispatchActiveKey(null, 'open', 'initial active option');
9372
9688
  return;
@@ -9577,6 +9893,7 @@ class EnhancedSelect extends HTMLElement {
9577
9893
  this._chipElements.delete(key);
9578
9894
  expected.remove();
9579
9895
  if (this.isConnected) {
9896
+ this._syncMultiSelectPlaceholderVisibility();
9580
9897
  this._observeSelectedLabelTooltipTargets();
9581
9898
  this._refreshSelectedLabelTooltipMeasurements();
9582
9899
  }
@@ -9746,6 +10063,21 @@ class EnhancedSelect extends HTMLElement {
9746
10063
  nextSibling = badge;
9747
10064
  }
9748
10065
  }
10066
+ this._syncMultiSelectPlaceholderVisibility();
10067
+ }
10068
+ _syncMultiSelectPlaceholderVisibility() {
10069
+ if (this._config.selection.mode !== 'multi')
10070
+ return;
10071
+ const hasLogicalSelection = this._getSelectedEntries().length > 0;
10072
+ const hasMountedChipPresentation = this._inputContent.querySelector('.selection-badge') !== null;
10073
+ const isEmpty = !hasLogicalSelection && !hasMountedChipPresentation;
10074
+ this._input.placeholder = isEmpty
10075
+ ? (this._config.placeholder || 'Select an option...')
10076
+ : '';
10077
+ if (isEmpty
10078
+ && (this._config.multiSelectDisplay?.mode ?? 'wrap') === 'horizontal') {
10079
+ this._inputContent.scrollLeft = 0;
10080
+ }
9749
10081
  }
9750
10082
  _updateInputDisplay() {
9751
10083
  const selectedEntries = this._getSelectedEntries();
@@ -9774,14 +10106,8 @@ class EnhancedSelect extends HTMLElement {
9774
10106
  this._cancelLatestChipScroll();
9775
10107
  const getLabel = this._config.serverSide.getLabelFromItem || ((item) => item?.label ?? String(item));
9776
10108
  if (this._config.selection.mode === 'multi') {
9777
- if (selectedItems.length === 0) {
9778
- this._input.value = '';
9779
- this._input.placeholder = this._config.placeholder || 'Select an option...';
9780
- }
9781
- else {
9782
- this._input.value = '';
9783
- this._input.placeholder = '';
9784
- }
10109
+ this._input.value = '';
10110
+ this._input.placeholder = '';
9785
10111
  this._renderSelectedChips(selectedEntries);
9786
10112
  }
9787
10113
  else {
@@ -9803,7 +10129,10 @@ class EnhancedSelect extends HTMLElement {
9803
10129
  }
9804
10130
  // Preserve manual scrolling. Only a newly selected key can request auto-scroll.
9805
10131
  if (this._config.selection.mode === 'multi') {
9806
- this._inputContent.scrollLeft = previousChipScrollLeft;
10132
+ const hasMountedChipPresentation = this._inputContent.querySelector('.selection-badge') !== null;
10133
+ this._inputContent.scrollLeft = selectedEntries.length === 0 && !hasMountedChipPresentation
10134
+ ? 0
10135
+ : previousChipScrollLeft;
9807
10136
  if (newlyAddedKey !== undefined)
9808
10137
  this._scheduleLatestChipScroll(newlyAddedKey);
9809
10138
  }
@@ -10474,6 +10803,8 @@ class EnhancedSelect extends HTMLElement {
10474
10803
  }
10475
10804
  this._renderOptions();
10476
10805
  this._syncClearControlState();
10806
+ this._observeSelectedLabelTooltipTargets();
10807
+ this._refreshSelectedLabelTooltipMeasurements();
10477
10808
  }
10478
10809
  /**
10479
10810
  * Open dropdown
@@ -10589,7 +10920,10 @@ class EnhancedSelect extends HTMLElement {
10589
10920
  if (this._input) {
10590
10921
  this._input.readOnly = !this._config.searchable;
10591
10922
  this._syncComboboxAccessibility();
10592
- if (this._state.selectedIndices.size === 0) {
10923
+ if (this._config.selection.mode === 'multi') {
10924
+ this._syncMultiSelectPlaceholderVisibility();
10925
+ }
10926
+ else if (this._state.selectedIndices.size === 0) {
10593
10927
  this._input.placeholder = this._config.placeholder || 'Select an option...';
10594
10928
  }
10595
10929
  }
@@ -10606,6 +10940,7 @@ class EnhancedSelect extends HTMLElement {
10606
10940
  }
10607
10941
  }
10608
10942
  this._syncStyleConfigVariables();
10943
+ this._syncDropdownConfigInlineStyles();
10609
10944
  this._syncListboxAccessibility();
10610
10945
  if (this.isConnected) {
10611
10946
  this._syncDirectionConfig();
@@ -10682,6 +11017,8 @@ class EnhancedSelect extends HTMLElement {
10682
11017
  }
10683
11018
  }
10684
11019
  }
11020
+ this._observeSelectedLabelTooltipTargets();
11021
+ this._refreshSelectedLabelTooltipMeasurements();
10685
11022
  if (configErrorDetail) {
10686
11023
  this._emit('dataLoadingConfigError', configErrorDetail);
10687
11024
  try {
@@ -11969,8 +12306,12 @@ class EnhancedSelect extends HTMLElement {
11969
12306
  _createBusyBucket() {
11970
12307
  const bucket = document.createElement('div');
11971
12308
  bucket.setAttribute('part', 'loading');
12309
+ bucket.setAttribute('role', 'status');
12310
+ bucket.setAttribute('aria-live', 'polite');
12311
+ bucket.setAttribute('aria-atomic', 'true');
11972
12312
  bucket.className = 'busy-bucket';
11973
12313
  this._busyBucket = bucket;
12314
+ this._syncLoaderClassNames();
11974
12315
  const icon = document.createElement('div');
11975
12316
  icon.className = 'busy-icon';
11976
12317
  icon.setAttribute('part', 'loading-icon');
@@ -12018,6 +12359,25 @@ class EnhancedSelect extends HTMLElement {
12018
12359
  this._syncBusyBucketContent(bucket);
12019
12360
  return bucket;
12020
12361
  }
12362
+ _createSearchingState() {
12363
+ const searching = document.createElement('div');
12364
+ searching.className = 'searching-state';
12365
+ searching.setAttribute('part', 'loading searching');
12366
+ searching.setAttribute('role', 'status');
12367
+ searching.setAttribute('aria-live', 'polite');
12368
+ searching.setAttribute('aria-atomic', 'true');
12369
+ const spinner = document.createElement('span');
12370
+ spinner.className = 'searching-spinner';
12371
+ spinner.setAttribute('part', 'searching-spinner');
12372
+ spinner.setAttribute('aria-hidden', 'true');
12373
+ const message = document.createElement('span');
12374
+ message.className = 'searching-message';
12375
+ message.setAttribute('part', 'searching-message');
12376
+ message.textContent = this._config.searchingMessage ?? 'Searching...';
12377
+ searching.append(spinner, message);
12378
+ this._syncLoaderClassNames(searching);
12379
+ return searching;
12380
+ }
12021
12381
  _renderOptions() {
12022
12382
  this._syncBusyPresentation();
12023
12383
  this._clearBusyBucketContentObserver();
@@ -12060,10 +12420,7 @@ class EnhancedSelect extends HTMLElement {
12060
12420
  this._renderPlan = this._createLegacyRenderPlan([]);
12061
12421
  this._refreshVirtualizationScope(filteredIndicesForScope);
12062
12422
  this._syncLegacyActiveAria();
12063
- const searching = document.createElement('div');
12064
- searching.className = 'searching-state';
12065
- searching.setAttribute('part', 'loading');
12066
- searching.textContent = 'Searching...';
12423
+ const searching = this._createSearchingState();
12067
12424
  this._optionsContainer.appendChild(searching);
12068
12425
  this._syncEmptyStateContext(null);
12069
12426
  this._resolveRenderCycle(renderCycleId, true);
@@ -12543,6 +12900,7 @@ class EnhancedSelect extends HTMLElement {
12543
12900
  _addLoadMoreTrigger() {
12544
12901
  const container = document.createElement('div');
12545
12902
  container.className = 'load-more-container';
12903
+ container.setAttribute('part', 'load-more-container');
12546
12904
  if (this._dataRequestCoordinator) {
12547
12905
  const shouldObserve = this._config.infiniteScroll.enabled
12548
12906
  && Boolean(this._intersectionObserver)
@@ -12554,6 +12912,7 @@ class EnhancedSelect extends HTMLElement {
12554
12912
  sentinel.style.height = '10px';
12555
12913
  sentinel.style.width = '100%';
12556
12914
  sentinel.style.opacity = '0';
12915
+ sentinel.setAttribute('aria-hidden', 'true');
12557
12916
  this._acknowledgedSentinel = sentinel;
12558
12917
  this._loadMoreTrigger = sentinel;
12559
12918
  container.appendChild(sentinel);
@@ -12563,7 +12922,8 @@ class EnhancedSelect extends HTMLElement {
12563
12922
  if (this._config.loadMore.enabled || this._config.infiniteScroll.enabled) {
12564
12923
  const button = document.createElement('button');
12565
12924
  button.className = 'load-more-button';
12566
- button.textContent = `Load ${this._config.loadMore.itemsPerLoad} more`;
12925
+ button.setAttribute('part', 'load-more-button');
12926
+ button.textContent = this._config.loadMore.label ?? `Load ${this._config.loadMore.itemsPerLoad} more`;
12567
12927
  button.addEventListener('click', () => this._loadMoreItems('manual'));
12568
12928
  container.appendChild(button);
12569
12929
  if (!sentinel)
@@ -12591,6 +12951,7 @@ class EnhancedSelect extends HTMLElement {
12591
12951
  sentinel.style.height = '10px';
12592
12952
  sentinel.style.width = '100%';
12593
12953
  sentinel.style.opacity = '0'; // Invisible
12954
+ sentinel.setAttribute('aria-hidden', 'true');
12594
12955
  this._loadMoreTrigger = sentinel;
12595
12956
  container.appendChild(sentinel);
12596
12957
  }
@@ -12598,7 +12959,8 @@ class EnhancedSelect extends HTMLElement {
12598
12959
  // Manual Load More: Render a button
12599
12960
  const button = document.createElement('button');
12600
12961
  button.className = 'load-more-button';
12601
- button.textContent = `Load ${this._config.loadMore.itemsPerLoad} more`;
12962
+ button.setAttribute('part', 'load-more-button');
12963
+ button.textContent = this._config.loadMore.label ?? `Load ${this._config.loadMore.itemsPerLoad} more`;
12602
12964
  button.addEventListener('click', () => this._loadMoreItems());
12603
12965
  this._loadMoreTrigger = button;
12604
12966
  container.appendChild(button);