@smilodon/core 1.22.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 {
@@ -2971,6 +2974,7 @@ class SelectOption extends HTMLElement {
2971
2974
  selectable: behavior.selectable === true,
2972
2975
  hoverable: behavior.hoverable === true,
2973
2976
  focusable: behavior.focusable === true,
2977
+ closeOnClick: behavior.closeOnClick === true,
2974
2978
  };
2975
2979
  }
2976
2980
  _isDisabledSelectionBlocked() {
@@ -4348,6 +4352,12 @@ class DataRequestCoordinator {
4348
4352
  *
4349
4353
  * Redesigned with formal elegance, refined microinteractions, and polished UX
4350
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
+ ];
4351
4361
  const LEGACY_DATA_LOADING_CONFIG = {
4352
4362
  protocol: 'legacy',
4353
4363
  searchMode: 'local',
@@ -4466,6 +4476,8 @@ class EnhancedSelect extends HTMLElement {
4466
4476
  this._selectedLabelTooltipResizeObserver = null;
4467
4477
  this._selectedLabelTooltipMeasureFrame = null;
4468
4478
  this._selectedLabelKeys = new WeakMap();
4479
+ this._dropdownConfigInlineStyles = new Map();
4480
+ this._managedLoaderClasses = new Set();
4469
4481
  this._busyPresentationVisible = false;
4470
4482
  this._busyPresentationStartedAt = null;
4471
4483
  this._busyPresentationGeneration = 0;
@@ -4700,6 +4712,7 @@ class EnhancedSelect extends HTMLElement {
4700
4712
  this._arrowContainer = this._createArrowContainer();
4701
4713
  this._clearControl = this._createClearControl();
4702
4714
  this._dropdown = this._createDropdown();
4715
+ this._syncDropdownConfigInlineStyles();
4703
4716
  this._optionsContainer = this._createOptionsContainer();
4704
4717
  this._liveRegion = this._createLiveRegion();
4705
4718
  this._errorDescription = this._createErrorDescription();
@@ -5311,6 +5324,7 @@ class EnhancedSelect extends HTMLElement {
5311
5324
  selectable: behavior.selectable === true,
5312
5325
  hoverable: behavior.hoverable === true,
5313
5326
  focusable: behavior.focusable === true,
5327
+ closeOnClick: behavior.closeOnClick === true,
5314
5328
  };
5315
5329
  }
5316
5330
  _isDisabledOptionSelectable(item) {
@@ -5554,6 +5568,7 @@ class EnhancedSelect extends HTMLElement {
5554
5568
  const styles = this._config.styles;
5555
5569
  if (!styles)
5556
5570
  return;
5571
+ this._syncLoaderClassNames();
5557
5572
  this._applyStyleVariableMap(styles.option, {
5558
5573
  background: '--select-option-bg',
5559
5574
  backgroundColor: '--select-option-bg',
@@ -5569,6 +5584,7 @@ class EnhancedSelect extends HTMLElement {
5569
5584
  fontWeight: '--select-option-font-weight',
5570
5585
  lineHeight: '--select-option-line-height',
5571
5586
  textAlign: '--select-option-text-align',
5587
+ zIndex: '--select-option-z-index',
5572
5588
  });
5573
5589
  this._applyStyleVariableMap(styles.selectedOption, {
5574
5590
  background: '--select-option-selected-bg',
@@ -5722,8 +5738,35 @@ class EnhancedSelect extends HTMLElement {
5722
5738
  fontWeight: '--select-group-header-weight',
5723
5739
  textTransform: '--select-group-header-text-transform',
5724
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',
5725
5755
  });
5726
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
+ }
5727
5770
  _resolveDropdownPlacement() {
5728
5771
  const placementMode = this._config.dropdownPlacement?.mode ?? 'bottom';
5729
5772
  if (placementMode === 'bottom' || placementMode === 'top') {
@@ -6021,11 +6064,139 @@ class EnhancedSelect extends HTMLElement {
6021
6064
  if (this._config.styles.classNames?.dropdown) {
6022
6065
  dropdown.className += ' ' + this._config.styles.classNames.dropdown;
6023
6066
  }
6024
- if (this._config.styles.dropdown) {
6025
- Object.assign(dropdown.style, this._config.styles.dropdown);
6026
- }
6027
6067
  return dropdown;
6028
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
+ }
6029
6200
  _createOptionsContainer() {
6030
6201
  const container = document.createElement('div');
6031
6202
  container.className = `options-container ${EnhancedSelect._MIRRORED_STYLES_SCOPE_CLASS}`;
@@ -6293,7 +6464,6 @@ class EnhancedSelect extends HTMLElement {
6293
6464
  --select-group-header-separator-border-top: none;
6294
6465
  --select-reduced-motion-duration: 0.01ms;
6295
6466
  --select-reduced-motion-iteration-count: 1;
6296
- --select-high-contrast-border-width: 2px;
6297
6467
  --select-high-contrast-indicator-width: 4px;
6298
6468
  --select-high-contrast-focus-outline-width: 3px;
6299
6469
  --select-high-contrast-focus-outline-color: Highlight;
@@ -6963,7 +7133,10 @@ class EnhancedSelect extends HTMLElement {
6963
7133
  overflow: hidden;
6964
7134
  box-sizing: border-box;
6965
7135
  background: var(--select-dropdown-bg, var(--select-surface));
6966
- 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));
6967
7140
  border-radius: var(--select-dropdown-border-radius, var(--select-radius-lg));
6968
7141
  box-shadow: var(--select-dropdown-shadow, var(--select-shadow-lg));
6969
7142
  z-index: var(--select-dropdown-z-index, 1000);
@@ -7054,11 +7227,11 @@ class EnhancedSelect extends HTMLElement {
7054
7227
  font-size: var(--select-group-header-font-size, 0.7333em);
7055
7228
  text-transform: var(--select-group-header-text-transform, uppercase);
7056
7229
  letter-spacing: var(--select-group-header-letter-spacing, 0.08em);
7057
- position: sticky;
7058
- 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));
7059
7232
  left: 0;
7060
7233
  right: 0;
7061
- z-index: 100;
7234
+ z-index: var(--select-group-header-z-index, 100);
7062
7235
  border: var(--select-group-header-border, none);
7063
7236
  border-bottom: var(--select-group-header-border-bottom, 1px solid rgba(0, 0, 0, 0.08));
7064
7237
  border-radius: var(--select-group-header-border-radius, 0);
@@ -7081,6 +7254,7 @@ class EnhancedSelect extends HTMLElement {
7081
7254
 
7082
7255
  .option {
7083
7256
  position: relative;
7257
+ z-index: var(--select-option-z-index, auto);
7084
7258
  padding: var(--select-option-padding, 10px 14px);
7085
7259
  cursor: pointer;
7086
7260
  color: var(--select-option-color, var(--select-text));
@@ -7185,7 +7359,7 @@ class EnhancedSelect extends HTMLElement {
7185
7359
  border: var(--select-option-disabled-border, var(--select-option-border, none));
7186
7360
  opacity: var(--select-option-disabled-opacity, 0.5);
7187
7361
  cursor: var(--select-option-disabled-cursor, not-allowed);
7188
- pointer-events: var(--select-option-disabled-pointer-events, none);
7362
+ pointer-events: var(--select-option-disabled-pointer-events, auto);
7189
7363
  }
7190
7364
 
7191
7365
  .option.smilodon-option--disabled-interactive {
@@ -7249,14 +7423,14 @@ class EnhancedSelect extends HTMLElement {
7249
7423
  .busy-bucket {
7250
7424
  display: flex;
7251
7425
  flex-direction: column;
7252
- align-items: center;
7253
- justify-content: center;
7254
- gap: var(--select-busy-gap, 8px);
7255
- padding: var(--select-busy-padding, 20px);
7256
- text-align: center;
7257
- color: var(--select-busy-color, var(--select-text-muted));
7258
- background: var(--select-busy-bg, transparent);
7259
- 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);
7260
7434
  }
7261
7435
 
7262
7436
  .busy-icon {
@@ -7310,26 +7484,27 @@ class EnhancedSelect extends HTMLElement {
7310
7484
  }
7311
7485
 
7312
7486
  .searching-state {
7313
- padding: var(--select-searching-padding, 32px 24px);
7314
- text-align: center;
7315
- color: var(--select-searching-color, var(--select-accent));
7316
- font-size: var(--select-searching-font-size, 0.9333em);
7317
- 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));
7318
7492
  display: flex;
7319
7493
  flex-direction: column;
7320
- align-items: center;
7321
- justify-content: center;
7322
- 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));
7323
7497
  }
7324
7498
 
7325
- .searching-state::before {
7326
- content: '';
7499
+ .searching-spinner {
7500
+ display: inline-block;
7327
7501
  width: var(--select-searching-spinner-size);
7328
7502
  height: var(--select-searching-spinner-size);
7329
7503
  border: var(--select-searching-spinner-border);
7330
7504
  border-top-color: var(--select-searching-spinner-active-color);
7331
7505
  border-radius: 50%;
7332
7506
  animation: var(--select-searching-spinner-animation);
7507
+ flex: 0 0 auto;
7333
7508
  }
7334
7509
 
7335
7510
  /* ─────────────────────────────────────────────────────────────────────────
@@ -7363,14 +7538,10 @@ class EnhancedSelect extends HTMLElement {
7363
7538
  }
7364
7539
  }
7365
7540
 
7366
- @media (prefers-contrast: high) {
7367
- .select-input:focus {
7368
- outline-width: var(--select-high-contrast-focus-outline-width);
7369
- outline-color: var(--select-high-contrast-focus-outline-color);
7370
- }
7371
-
7372
- .input-container {
7373
- 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;
7374
7545
  }
7375
7546
 
7376
7547
  .option.selected::before {
@@ -7462,7 +7633,6 @@ class EnhancedSelect extends HTMLElement {
7462
7633
  :host-context([data-theme="dark"]) .input-container,
7463
7634
  :host-context([theme="dark"]) .input-container {
7464
7635
  background: var(--select-surface);
7465
- border-color: var(--select-border);
7466
7636
  }
7467
7637
 
7468
7638
  :host(.dark-mode) .input-container:hover,
@@ -7491,7 +7661,7 @@ class EnhancedSelect extends HTMLElement {
7491
7661
  :host-context([darkmode]) .input-container:focus-within,
7492
7662
  :host-context([data-theme="dark"]) .input-container:focus-within,
7493
7663
  :host-context([theme="dark"]) .input-container:focus-within {
7494
- 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)));
7495
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);
7496
7666
  }
7497
7667
 
@@ -7521,7 +7691,6 @@ class EnhancedSelect extends HTMLElement {
7521
7691
  :host-context([data-theme="dark"]) .select-dropdown,
7522
7692
  :host-context([theme="dark"]) .select-dropdown {
7523
7693
  background: var(--select-dropdown-bg, var(--select-surface));
7524
- border-color: var(--select-border);
7525
7694
  }
7526
7695
 
7527
7696
  :host(.dark-mode) .options-container,
@@ -7656,7 +7825,7 @@ class EnhancedSelect extends HTMLElement {
7656
7825
  this._handleClose();
7657
7826
  }
7658
7827
  else if (!this._state.isOpen) {
7659
- this._handleOpen();
7828
+ this._handleOpen('pointer');
7660
7829
  }
7661
7830
  };
7662
7831
  this._arrowContainer.addEventListener('click', this._boundArrowClick);
@@ -7713,7 +7882,7 @@ class EnhancedSelect extends HTMLElement {
7713
7882
  }
7714
7883
  const wasClosed = !this._state.isOpen;
7715
7884
  if (wasClosed) {
7716
- this._handleOpen();
7885
+ this._handleOpen('pointer');
7717
7886
  }
7718
7887
  // Focus the input (do not prevent default behavior for input itself)
7719
7888
  this._applyFocusIntent('input', 'input-container-trigger');
@@ -7750,7 +7919,7 @@ class EnhancedSelect extends HTMLElement {
7750
7919
  this._suppressNextOpenClick = false;
7751
7920
  this._multiScrollDrag.moved = false;
7752
7921
  if (!this._state.isOpen) {
7753
- this._handleOpen();
7922
+ this._handleOpen('pointer');
7754
7923
  }
7755
7924
  this._applyFocusIntent('input', 'input-container-activation');
7756
7925
  });
@@ -7817,43 +7986,60 @@ class EnhancedSelect extends HTMLElement {
7817
7986
  }
7818
7987
  this._handleSearch(query);
7819
7988
  });
7820
- // If the user presses down inside the options container we should
7821
- // temporarily suppress blur-based closing until after the click has
7822
- // been handled. Setting a flag that gets cleared in the next tick is
7823
- // sufficient.
7824
- 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) => {
7825
8013
  this._suppressBlurClose = true;
7826
8014
  this._setLifecycleTimeout(() => {
7827
8015
  this._suppressBlurClose = false;
7828
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();
7829
8026
  });
7830
8027
  // Delegated click listener for improved event handling (robust across shadow DOM)
7831
8028
  const handleOptionEvent = (e) => {
7832
- const path = (e.composedPath && e.composedPath()) || [e.target];
7833
- let option = null;
7834
- for (const node of path) {
7835
- if (!(node instanceof Element))
7836
- continue;
7837
- try {
7838
- if (node.matches('[data-sm-selectable], [data-selectable], [data-sm-state]')) {
7839
- option = node;
7840
- break;
7841
- }
7842
- }
7843
- catch (err) {
7844
- continue;
7845
- }
7846
- }
7847
- if (option && (!option.hasAttribute('aria-disabled') || option.classList.contains('smilodon-option--disabled-selectable'))) {
7848
- const indexStr = option.getAttribute('data-sm-index') ?? option.getAttribute('data-index');
7849
- const index = Number(indexStr);
7850
- if (!Number.isNaN(index)) {
7851
- this._selectOption(index, {
7852
- shiftKey: e.shiftKey,
7853
- toggleKey: e.ctrlKey || e.metaKey,
7854
- });
7855
- }
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;
7856
8038
  }
8039
+ this._selectOption(resolved.record.index, {
8040
+ shiftKey: e.shiftKey,
8041
+ toggleKey: e.ctrlKey || e.metaKey,
8042
+ });
7857
8043
  };
7858
8044
  this._optionsContainer.addEventListener('click', handleOptionEvent);
7859
8045
  // Keyboard navigation
@@ -8367,7 +8553,7 @@ class EnhancedSelect extends HTMLElement {
8367
8553
  },
8368
8554
  }, { applyFocus: true });
8369
8555
  }
8370
- _handleOpen() {
8556
+ _handleOpen(intent = 'default') {
8371
8557
  if (!this._config.enabled) {
8372
8558
  this._runEngineEffects(this._engine.dispatch({ type: 'DISABLED_CHANGED', disabled: true }));
8373
8559
  return;
@@ -8401,10 +8587,17 @@ class EnhancedSelect extends HTMLElement {
8401
8587
  this._liftStackingAncestors();
8402
8588
  this._dropdown.style.display = 'block';
8403
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
+ }
8404
8596
  // Render options when opening
8405
8597
  this._renderOptions();
8406
8598
  this._syncDropdownPlacement();
8407
- this._setInitialActiveOption();
8599
+ if (intent !== 'pointer')
8600
+ this._setInitialActiveOption();
8408
8601
  this._emit('open', {});
8409
8602
  this._config.callbacks.onOpen?.();
8410
8603
  this._announce('Options expanded');
@@ -9489,7 +9682,7 @@ class EnhancedSelect extends HTMLElement {
9489
9682
  const selectableIndices = this._getSelectableOptionIndices();
9490
9683
  const selected = Array.from(this._state.selectedIndices).sort((a, b) => a - b);
9491
9684
  // Opening an empty select must not implicitly assign an active descendant.
9492
- // Keyboard navigation and pointer interaction establish active identity.
9685
+ // Keyboard navigation and option interaction establish active identity.
9493
9686
  if (selectableIndices.length === 0 || selected.length === 0) {
9494
9687
  this._dispatchActiveKey(null, 'open', 'initial active option');
9495
9688
  return;
@@ -9700,6 +9893,7 @@ class EnhancedSelect extends HTMLElement {
9700
9893
  this._chipElements.delete(key);
9701
9894
  expected.remove();
9702
9895
  if (this.isConnected) {
9896
+ this._syncMultiSelectPlaceholderVisibility();
9703
9897
  this._observeSelectedLabelTooltipTargets();
9704
9898
  this._refreshSelectedLabelTooltipMeasurements();
9705
9899
  }
@@ -9869,6 +10063,21 @@ class EnhancedSelect extends HTMLElement {
9869
10063
  nextSibling = badge;
9870
10064
  }
9871
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
+ }
9872
10081
  }
9873
10082
  _updateInputDisplay() {
9874
10083
  const selectedEntries = this._getSelectedEntries();
@@ -9897,14 +10106,8 @@ class EnhancedSelect extends HTMLElement {
9897
10106
  this._cancelLatestChipScroll();
9898
10107
  const getLabel = this._config.serverSide.getLabelFromItem || ((item) => item?.label ?? String(item));
9899
10108
  if (this._config.selection.mode === 'multi') {
9900
- if (selectedItems.length === 0) {
9901
- this._input.value = '';
9902
- this._input.placeholder = this._config.placeholder || 'Select an option...';
9903
- }
9904
- else {
9905
- this._input.value = '';
9906
- this._input.placeholder = '';
9907
- }
10109
+ this._input.value = '';
10110
+ this._input.placeholder = '';
9908
10111
  this._renderSelectedChips(selectedEntries);
9909
10112
  }
9910
10113
  else {
@@ -9926,7 +10129,10 @@ class EnhancedSelect extends HTMLElement {
9926
10129
  }
9927
10130
  // Preserve manual scrolling. Only a newly selected key can request auto-scroll.
9928
10131
  if (this._config.selection.mode === 'multi') {
9929
- 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;
9930
10136
  if (newlyAddedKey !== undefined)
9931
10137
  this._scheduleLatestChipScroll(newlyAddedKey);
9932
10138
  }
@@ -10714,7 +10920,10 @@ class EnhancedSelect extends HTMLElement {
10714
10920
  if (this._input) {
10715
10921
  this._input.readOnly = !this._config.searchable;
10716
10922
  this._syncComboboxAccessibility();
10717
- 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) {
10718
10927
  this._input.placeholder = this._config.placeholder || 'Select an option...';
10719
10928
  }
10720
10929
  }
@@ -10731,6 +10940,7 @@ class EnhancedSelect extends HTMLElement {
10731
10940
  }
10732
10941
  }
10733
10942
  this._syncStyleConfigVariables();
10943
+ this._syncDropdownConfigInlineStyles();
10734
10944
  this._syncListboxAccessibility();
10735
10945
  if (this.isConnected) {
10736
10946
  this._syncDirectionConfig();
@@ -12096,8 +12306,12 @@ class EnhancedSelect extends HTMLElement {
12096
12306
  _createBusyBucket() {
12097
12307
  const bucket = document.createElement('div');
12098
12308
  bucket.setAttribute('part', 'loading');
12309
+ bucket.setAttribute('role', 'status');
12310
+ bucket.setAttribute('aria-live', 'polite');
12311
+ bucket.setAttribute('aria-atomic', 'true');
12099
12312
  bucket.className = 'busy-bucket';
12100
12313
  this._busyBucket = bucket;
12314
+ this._syncLoaderClassNames();
12101
12315
  const icon = document.createElement('div');
12102
12316
  icon.className = 'busy-icon';
12103
12317
  icon.setAttribute('part', 'loading-icon');
@@ -12145,6 +12359,25 @@ class EnhancedSelect extends HTMLElement {
12145
12359
  this._syncBusyBucketContent(bucket);
12146
12360
  return bucket;
12147
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
+ }
12148
12381
  _renderOptions() {
12149
12382
  this._syncBusyPresentation();
12150
12383
  this._clearBusyBucketContentObserver();
@@ -12187,10 +12420,7 @@ class EnhancedSelect extends HTMLElement {
12187
12420
  this._renderPlan = this._createLegacyRenderPlan([]);
12188
12421
  this._refreshVirtualizationScope(filteredIndicesForScope);
12189
12422
  this._syncLegacyActiveAria();
12190
- const searching = document.createElement('div');
12191
- searching.className = 'searching-state';
12192
- searching.setAttribute('part', 'loading');
12193
- searching.textContent = 'Searching...';
12423
+ const searching = this._createSearchingState();
12194
12424
  this._optionsContainer.appendChild(searching);
12195
12425
  this._syncEmptyStateContext(null);
12196
12426
  this._resolveRenderCycle(renderCycleId, true);
@@ -12670,6 +12900,7 @@ class EnhancedSelect extends HTMLElement {
12670
12900
  _addLoadMoreTrigger() {
12671
12901
  const container = document.createElement('div');
12672
12902
  container.className = 'load-more-container';
12903
+ container.setAttribute('part', 'load-more-container');
12673
12904
  if (this._dataRequestCoordinator) {
12674
12905
  const shouldObserve = this._config.infiniteScroll.enabled
12675
12906
  && Boolean(this._intersectionObserver)
@@ -12681,6 +12912,7 @@ class EnhancedSelect extends HTMLElement {
12681
12912
  sentinel.style.height = '10px';
12682
12913
  sentinel.style.width = '100%';
12683
12914
  sentinel.style.opacity = '0';
12915
+ sentinel.setAttribute('aria-hidden', 'true');
12684
12916
  this._acknowledgedSentinel = sentinel;
12685
12917
  this._loadMoreTrigger = sentinel;
12686
12918
  container.appendChild(sentinel);
@@ -12690,7 +12922,8 @@ class EnhancedSelect extends HTMLElement {
12690
12922
  if (this._config.loadMore.enabled || this._config.infiniteScroll.enabled) {
12691
12923
  const button = document.createElement('button');
12692
12924
  button.className = 'load-more-button';
12693
- 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`;
12694
12927
  button.addEventListener('click', () => this._loadMoreItems('manual'));
12695
12928
  container.appendChild(button);
12696
12929
  if (!sentinel)
@@ -12718,6 +12951,7 @@ class EnhancedSelect extends HTMLElement {
12718
12951
  sentinel.style.height = '10px';
12719
12952
  sentinel.style.width = '100%';
12720
12953
  sentinel.style.opacity = '0'; // Invisible
12954
+ sentinel.setAttribute('aria-hidden', 'true');
12721
12955
  this._loadMoreTrigger = sentinel;
12722
12956
  container.appendChild(sentinel);
12723
12957
  }
@@ -12725,7 +12959,8 @@ class EnhancedSelect extends HTMLElement {
12725
12959
  // Manual Load More: Render a button
12726
12960
  const button = document.createElement('button');
12727
12961
  button.className = 'load-more-button';
12728
- 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`;
12729
12964
  button.addEventListener('click', () => this._loadMoreItems());
12730
12965
  this._loadMoreTrigger = button;
12731
12966
  container.appendChild(button);