@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.umd.js CHANGED
@@ -2210,6 +2210,7 @@
2210
2210
  selectable: false,
2211
2211
  hoverable: false,
2212
2212
  focusable: false,
2213
+ closeOnClick: false,
2213
2214
  },
2214
2215
  maxSelections: 0,
2215
2216
  showRemoveButton: true,
@@ -2256,6 +2257,7 @@
2256
2257
  minDisplayTime: 200,
2257
2258
  contentMode: 'append',
2258
2259
  },
2260
+ searchingMessage: 'Searching...',
2259
2261
  styles: {
2260
2262
  classNames: {},
2261
2263
  },
@@ -2744,6 +2746,7 @@
2744
2746
  :host {
2745
2747
  display: block;
2746
2748
  position: relative;
2749
+ z-index: var(--select-option-z-index, auto);
2747
2750
  font: inherit;
2748
2751
  color: var(--select-option-color, var(--select-text-color, #1f2937));
2749
2752
  background: var(--select-option-bg, var(--select-dropdown-bg, var(--select-bg, white)));
@@ -2806,7 +2809,7 @@
2806
2809
  border-bottom: var(--select-option-disabled-border-bottom, var(--select-option-border-bottom, none));
2807
2810
  opacity: var(--select-option-disabled-opacity, 0.5);
2808
2811
  cursor: var(--select-option-disabled-cursor, not-allowed);
2809
- pointer-events: none;
2812
+ pointer-events: auto;
2810
2813
  }
2811
2814
 
2812
2815
  :host(.smilodon-option--disabled-interactive) {
@@ -2876,7 +2879,7 @@
2876
2879
  border-bottom: inherit;
2877
2880
  opacity: inherit;
2878
2881
  cursor: inherit;
2879
- pointer-events: none;
2882
+ pointer-events: auto;
2880
2883
  }
2881
2884
 
2882
2885
  .option-content {
@@ -2977,6 +2980,7 @@
2977
2980
  selectable: behavior.selectable === true,
2978
2981
  hoverable: behavior.hoverable === true,
2979
2982
  focusable: behavior.focusable === true,
2983
+ closeOnClick: behavior.closeOnClick === true,
2980
2984
  };
2981
2985
  }
2982
2986
  _isDisabledSelectionBlocked() {
@@ -4354,6 +4358,12 @@
4354
4358
  *
4355
4359
  * Redesigned with formal elegance, refined microinteractions, and polished UX
4356
4360
  */
4361
+ const DROPDOWN_BORDER_LONGHANDS = [
4362
+ 'border-top-width', 'border-right-width', 'border-bottom-width', 'border-left-width',
4363
+ 'border-top-style', 'border-right-style', 'border-bottom-style', 'border-left-style',
4364
+ 'border-top-color', 'border-right-color', 'border-bottom-color', 'border-left-color',
4365
+ 'border-image-source', 'border-image-slice', 'border-image-width', 'border-image-outset', 'border-image-repeat',
4366
+ ];
4357
4367
  const LEGACY_DATA_LOADING_CONFIG = {
4358
4368
  protocol: 'legacy',
4359
4369
  searchMode: 'local',
@@ -4472,6 +4482,8 @@
4472
4482
  this._selectedLabelTooltipResizeObserver = null;
4473
4483
  this._selectedLabelTooltipMeasureFrame = null;
4474
4484
  this._selectedLabelKeys = new WeakMap();
4485
+ this._dropdownConfigInlineStyles = new Map();
4486
+ this._managedLoaderClasses = new Set();
4475
4487
  this._busyPresentationVisible = false;
4476
4488
  this._busyPresentationStartedAt = null;
4477
4489
  this._busyPresentationGeneration = 0;
@@ -4706,6 +4718,7 @@
4706
4718
  this._arrowContainer = this._createArrowContainer();
4707
4719
  this._clearControl = this._createClearControl();
4708
4720
  this._dropdown = this._createDropdown();
4721
+ this._syncDropdownConfigInlineStyles();
4709
4722
  this._optionsContainer = this._createOptionsContainer();
4710
4723
  this._liveRegion = this._createLiveRegion();
4711
4724
  this._errorDescription = this._createErrorDescription();
@@ -5317,6 +5330,7 @@
5317
5330
  selectable: behavior.selectable === true,
5318
5331
  hoverable: behavior.hoverable === true,
5319
5332
  focusable: behavior.focusable === true,
5333
+ closeOnClick: behavior.closeOnClick === true,
5320
5334
  };
5321
5335
  }
5322
5336
  _isDisabledOptionSelectable(item) {
@@ -5560,6 +5574,7 @@
5560
5574
  const styles = this._config.styles;
5561
5575
  if (!styles)
5562
5576
  return;
5577
+ this._syncLoaderClassNames();
5563
5578
  this._applyStyleVariableMap(styles.option, {
5564
5579
  background: '--select-option-bg',
5565
5580
  backgroundColor: '--select-option-bg',
@@ -5575,6 +5590,7 @@
5575
5590
  fontWeight: '--select-option-font-weight',
5576
5591
  lineHeight: '--select-option-line-height',
5577
5592
  textAlign: '--select-option-text-align',
5593
+ zIndex: '--select-option-z-index',
5578
5594
  });
5579
5595
  this._applyStyleVariableMap(styles.selectedOption, {
5580
5596
  background: '--select-option-selected-bg',
@@ -5728,8 +5744,35 @@
5728
5744
  fontWeight: '--select-group-header-weight',
5729
5745
  textTransform: '--select-group-header-text-transform',
5730
5746
  letterSpacing: '--select-group-header-letter-spacing',
5747
+ position: '--select-group-header-position',
5748
+ top: '--select-group-header-top',
5749
+ zIndex: '--select-group-header-z-index',
5750
+ });
5751
+ this._applyStyleVariableMap(styles.loader, {
5752
+ gap: '--select-loader-gap',
5753
+ padding: '--select-loader-padding',
5754
+ color: '--select-loader-color',
5755
+ background: '--select-loader-bg',
5756
+ backgroundColor: '--select-loader-bg',
5757
+ fontSize: '--select-loader-font-size',
5758
+ textAlign: '--select-loader-text-align',
5759
+ alignItems: '--select-loader-align-items',
5760
+ justifyContent: '--select-loader-justify-content',
5731
5761
  });
5732
5762
  }
5763
+ _syncLoaderClassNames(additionalTarget) {
5764
+ const classNames = new Set((this._config.styles.classNames?.loader ?? '').split(/\s+/).filter(Boolean));
5765
+ const targets = [
5766
+ this._busyBucket,
5767
+ this._optionsContainer?.querySelector('.searching-state'),
5768
+ additionalTarget,
5769
+ ].filter((element) => Boolean(element));
5770
+ for (const target of targets) {
5771
+ target.classList.remove(...this._managedLoaderClasses);
5772
+ target.classList.add(...classNames);
5773
+ }
5774
+ this._managedLoaderClasses = classNames;
5775
+ }
5733
5776
  _resolveDropdownPlacement() {
5734
5777
  const placementMode = this._config.dropdownPlacement?.mode ?? 'bottom';
5735
5778
  if (placementMode === 'bottom' || placementMode === 'top') {
@@ -6027,11 +6070,139 @@
6027
6070
  if (this._config.styles.classNames?.dropdown) {
6028
6071
  dropdown.className += ' ' + this._config.styles.classNames.dropdown;
6029
6072
  }
6030
- if (this._config.styles.dropdown) {
6031
- Object.assign(dropdown.style, this._config.styles.dropdown);
6032
- }
6033
6073
  return dropdown;
6034
6074
  }
6075
+ _syncDropdownConfigInlineStyles() {
6076
+ if (!this._dropdown)
6077
+ return;
6078
+ const toCssProperty = (property) => {
6079
+ if (property.startsWith('--'))
6080
+ return property;
6081
+ if (property === 'cssFloat')
6082
+ return 'float';
6083
+ return property.replace(/[A-Z]/g, (character) => `-${character.toLowerCase()}`);
6084
+ };
6085
+ const configured = new Map();
6086
+ for (const [property, value] of Object.entries(this._config.styles.dropdown ?? {})) {
6087
+ if (value === undefined || value === null || String(value).trim() === '')
6088
+ continue;
6089
+ configured.set(toCssProperty(property), String(value));
6090
+ }
6091
+ const style = this._dropdown.style;
6092
+ const readValue = (property) => style.getPropertyValue(property).trim();
6093
+ const readSnapshot = (property) => ({
6094
+ value: readValue(property),
6095
+ priority: style.getPropertyPriority(property),
6096
+ });
6097
+ const sameSnapshot = (left, right) => left.value === right.value && left.priority === right.priority;
6098
+ const readBorderParts = () => new Map(DROPDOWN_BORDER_LONGHANDS.map((part) => [part, readSnapshot(part)]));
6099
+ const restoreValue = (property, value, priority) => {
6100
+ if (value)
6101
+ style.setProperty(property, value, priority);
6102
+ else
6103
+ style.removeProperty(property);
6104
+ };
6105
+ for (const [property, previousOwnership] of this._dropdownConfigInlineStyles) {
6106
+ const currentValue = readValue(property);
6107
+ const currentPriority = style.getPropertyPriority(property);
6108
+ const isStillCoreOwned = currentValue === previousOwnership.appliedValue
6109
+ && currentPriority === previousOwnership.appliedPriority;
6110
+ const previousValue = isStillCoreOwned ? previousOwnership.previousValue : currentValue;
6111
+ const previousPriority = isStillCoreOwned ? previousOwnership.previousPriority : currentPriority;
6112
+ const nextValue = configured.get(property);
6113
+ const relatedBorderParts = previousOwnership.relatedBorderParts;
6114
+ if (nextValue === undefined) {
6115
+ const borderPartRestorations = relatedBorderParts
6116
+ ? [...relatedBorderParts].map(([part, ownership]) => {
6117
+ const current = readSnapshot(part);
6118
+ return [part, sameSnapshot(current, ownership.applied) ? ownership.previous : current];
6119
+ })
6120
+ : [];
6121
+ if (isStillCoreOwned)
6122
+ restoreValue(property, previousValue, previousPriority);
6123
+ for (const [part, restore] of borderPartRestorations) {
6124
+ restoreValue(part, restore.value, restore.priority);
6125
+ }
6126
+ // A shorthand and a longhand can both own the same border components.
6127
+ // When one layer is released, rebase any still-active layer whose saved
6128
+ // baseline came from the released layer's applied value. Otherwise the
6129
+ // final release can resurrect an intermediate Core value instead of
6130
+ // the consumer-authored declaration.
6131
+ if (relatedBorderParts) {
6132
+ for (const [otherProperty, otherOwnership] of this._dropdownConfigInlineStyles) {
6133
+ if (otherProperty === property || !otherOwnership.relatedBorderParts)
6134
+ continue;
6135
+ for (const [part, released] of relatedBorderParts) {
6136
+ const other = otherOwnership.relatedBorderParts.get(part);
6137
+ if (!other)
6138
+ continue;
6139
+ const current = readSnapshot(part);
6140
+ if (sameSnapshot(current, other.applied) && sameSnapshot(other.previous, released.applied)) {
6141
+ otherOwnership.relatedBorderParts.set(part, {
6142
+ ...other,
6143
+ previous: released.previous,
6144
+ });
6145
+ }
6146
+ }
6147
+ }
6148
+ }
6149
+ this._dropdownConfigInlineStyles.delete(property);
6150
+ continue;
6151
+ }
6152
+ const tracksBorderParts = property === 'border' || property === 'border-width';
6153
+ const beforeBorderParts = tracksBorderParts ? readBorderParts() : undefined;
6154
+ style.setProperty(property, nextValue);
6155
+ const afterBorderParts = tracksBorderParts ? readBorderParts() : undefined;
6156
+ let nextRelatedBorderParts;
6157
+ if (beforeBorderParts && afterBorderParts) {
6158
+ nextRelatedBorderParts = new Map();
6159
+ for (const part of DROPDOWN_BORDER_LONGHANDS) {
6160
+ const before = beforeBorderParts.get(part);
6161
+ const after = afterBorderParts.get(part);
6162
+ const previous = relatedBorderParts?.get(part);
6163
+ if (previous || !sameSnapshot(before, after)) {
6164
+ nextRelatedBorderParts.set(part, {
6165
+ previous: previous && sameSnapshot(before, previous.applied) ? previous.previous : before,
6166
+ applied: after,
6167
+ });
6168
+ }
6169
+ }
6170
+ }
6171
+ this._dropdownConfigInlineStyles.set(property, {
6172
+ appliedValue: readValue(property),
6173
+ appliedPriority: style.getPropertyPriority(property),
6174
+ previousValue,
6175
+ previousPriority,
6176
+ ...(nextRelatedBorderParts ? { relatedBorderParts: nextRelatedBorderParts } : {}),
6177
+ });
6178
+ configured.delete(property);
6179
+ }
6180
+ for (const [property, value] of configured) {
6181
+ const previousValue = readValue(property);
6182
+ const previousPriority = style.getPropertyPriority(property);
6183
+ const tracksBorderParts = property === 'border' || property === 'border-width';
6184
+ const beforeBorderParts = tracksBorderParts ? readBorderParts() : undefined;
6185
+ style.setProperty(property, value);
6186
+ const afterBorderParts = tracksBorderParts ? readBorderParts() : undefined;
6187
+ let relatedBorderParts;
6188
+ if (beforeBorderParts && afterBorderParts) {
6189
+ relatedBorderParts = new Map();
6190
+ for (const part of DROPDOWN_BORDER_LONGHANDS) {
6191
+ const before = beforeBorderParts.get(part);
6192
+ const after = afterBorderParts.get(part);
6193
+ if (!sameSnapshot(before, after))
6194
+ relatedBorderParts.set(part, { previous: before, applied: after });
6195
+ }
6196
+ }
6197
+ this._dropdownConfigInlineStyles.set(property, {
6198
+ appliedValue: readValue(property),
6199
+ appliedPriority: style.getPropertyPriority(property),
6200
+ previousValue,
6201
+ previousPriority,
6202
+ ...(relatedBorderParts ? { relatedBorderParts } : {}),
6203
+ });
6204
+ }
6205
+ }
6035
6206
  _createOptionsContainer() {
6036
6207
  const container = document.createElement('div');
6037
6208
  container.className = `options-container ${EnhancedSelect._MIRRORED_STYLES_SCOPE_CLASS}`;
@@ -6299,7 +6470,6 @@
6299
6470
  --select-group-header-separator-border-top: none;
6300
6471
  --select-reduced-motion-duration: 0.01ms;
6301
6472
  --select-reduced-motion-iteration-count: 1;
6302
- --select-high-contrast-border-width: 2px;
6303
6473
  --select-high-contrast-indicator-width: 4px;
6304
6474
  --select-high-contrast-focus-outline-width: 3px;
6305
6475
  --select-high-contrast-focus-outline-color: Highlight;
@@ -6969,7 +7139,10 @@
6969
7139
  overflow: hidden;
6970
7140
  box-sizing: border-box;
6971
7141
  background: var(--select-dropdown-bg, var(--select-surface));
6972
- border: 1px solid var(--select-dropdown-border, var(--select-border));
7142
+ border:
7143
+ var(--select-dropdown-border-width, 1px)
7144
+ var(--select-dropdown-border-style, solid)
7145
+ var(--select-dropdown-border, var(--select-border));
6973
7146
  border-radius: var(--select-dropdown-border-radius, var(--select-radius-lg));
6974
7147
  box-shadow: var(--select-dropdown-shadow, var(--select-shadow-lg));
6975
7148
  z-index: var(--select-dropdown-z-index, 1000);
@@ -7060,11 +7233,11 @@
7060
7233
  font-size: var(--select-group-header-font-size, 0.7333em);
7061
7234
  text-transform: var(--select-group-header-text-transform, uppercase);
7062
7235
  letter-spacing: var(--select-group-header-letter-spacing, 0.08em);
7063
- position: sticky;
7064
- top: calc(var(--select-options-padding, 6px) * -1);
7236
+ position: var(--select-group-header-position, sticky);
7237
+ top: var(--select-group-header-top, calc(var(--select-options-padding, 6px) * -1));
7065
7238
  left: 0;
7066
7239
  right: 0;
7067
- z-index: 100;
7240
+ z-index: var(--select-group-header-z-index, 100);
7068
7241
  border: var(--select-group-header-border, none);
7069
7242
  border-bottom: var(--select-group-header-border-bottom, 1px solid rgba(0, 0, 0, 0.08));
7070
7243
  border-radius: var(--select-group-header-border-radius, 0);
@@ -7087,6 +7260,7 @@
7087
7260
 
7088
7261
  .option {
7089
7262
  position: relative;
7263
+ z-index: var(--select-option-z-index, auto);
7090
7264
  padding: var(--select-option-padding, 10px 14px);
7091
7265
  cursor: pointer;
7092
7266
  color: var(--select-option-color, var(--select-text));
@@ -7191,7 +7365,7 @@
7191
7365
  border: var(--select-option-disabled-border, var(--select-option-border, none));
7192
7366
  opacity: var(--select-option-disabled-opacity, 0.5);
7193
7367
  cursor: var(--select-option-disabled-cursor, not-allowed);
7194
- pointer-events: var(--select-option-disabled-pointer-events, none);
7368
+ pointer-events: var(--select-option-disabled-pointer-events, auto);
7195
7369
  }
7196
7370
 
7197
7371
  .option.smilodon-option--disabled-interactive {
@@ -7255,14 +7429,14 @@
7255
7429
  .busy-bucket {
7256
7430
  display: flex;
7257
7431
  flex-direction: column;
7258
- align-items: center;
7259
- justify-content: center;
7260
- gap: var(--select-busy-gap, 8px);
7261
- padding: var(--select-busy-padding, 20px);
7262
- text-align: center;
7263
- color: var(--select-busy-color, var(--select-text-muted));
7264
- background: var(--select-busy-bg, transparent);
7265
- font-size: var(--select-busy-font-size, 0.8667em);
7432
+ gap: var(--select-loader-gap, var(--select-busy-gap, 8px));
7433
+ padding: var(--select-loader-padding, var(--select-busy-padding, 20px));
7434
+ text-align: var(--select-loader-text-align, center);
7435
+ color: var(--select-loader-color, var(--select-busy-color, var(--select-text-muted)));
7436
+ background: var(--select-loader-bg, var(--select-busy-bg, transparent));
7437
+ font-size: var(--select-loader-font-size, var(--select-busy-font-size, 0.8667em));
7438
+ align-items: var(--select-loader-align-items, center);
7439
+ justify-content: var(--select-loader-justify-content, center);
7266
7440
  }
7267
7441
 
7268
7442
  .busy-icon {
@@ -7316,26 +7490,27 @@
7316
7490
  }
7317
7491
 
7318
7492
  .searching-state {
7319
- padding: var(--select-searching-padding, 32px 24px);
7320
- text-align: center;
7321
- color: var(--select-searching-color, var(--select-accent));
7322
- font-size: var(--select-searching-font-size, 0.9333em);
7323
- background: var(--select-searching-bg, transparent);
7493
+ padding: var(--select-loader-padding, var(--select-searching-padding, 32px 24px));
7494
+ text-align: var(--select-loader-text-align, center);
7495
+ color: var(--select-loader-color, var(--select-searching-color, var(--select-accent)));
7496
+ font-size: var(--select-loader-font-size, var(--select-searching-font-size, 0.9333em));
7497
+ background: var(--select-loader-bg, var(--select-searching-bg, transparent));
7324
7498
  display: flex;
7325
7499
  flex-direction: column;
7326
- align-items: center;
7327
- justify-content: center;
7328
- gap: var(--select-searching-gap);
7500
+ align-items: var(--select-loader-align-items, center);
7501
+ justify-content: var(--select-loader-justify-content, center);
7502
+ gap: var(--select-loader-gap, var(--select-searching-gap, 8px));
7329
7503
  }
7330
7504
 
7331
- .searching-state::before {
7332
- content: '';
7505
+ .searching-spinner {
7506
+ display: inline-block;
7333
7507
  width: var(--select-searching-spinner-size);
7334
7508
  height: var(--select-searching-spinner-size);
7335
7509
  border: var(--select-searching-spinner-border);
7336
7510
  border-top-color: var(--select-searching-spinner-active-color);
7337
7511
  border-radius: 50%;
7338
7512
  animation: var(--select-searching-spinner-animation);
7513
+ flex: 0 0 auto;
7339
7514
  }
7340
7515
 
7341
7516
  /* ─────────────────────────────────────────────────────────────────────────
@@ -7369,14 +7544,10 @@
7369
7544
  }
7370
7545
  }
7371
7546
 
7372
- @media (prefers-contrast: high) {
7373
- .select-input:focus {
7374
- outline-width: var(--select-high-contrast-focus-outline-width);
7375
- outline-color: var(--select-high-contrast-focus-outline-color);
7376
- }
7377
-
7378
- .input-container {
7379
- border-width: var(--select-high-contrast-border-width);
7547
+ @media (prefers-contrast: more) {
7548
+ .input-container:focus-within {
7549
+ outline: var(--select-high-contrast-focus-outline-width) solid var(--select-high-contrast-focus-outline-color);
7550
+ outline-offset: 2px;
7380
7551
  }
7381
7552
 
7382
7553
  .option.selected::before {
@@ -7468,7 +7639,6 @@
7468
7639
  :host-context([data-theme="dark"]) .input-container,
7469
7640
  :host-context([theme="dark"]) .input-container {
7470
7641
  background: var(--select-surface);
7471
- border-color: var(--select-border);
7472
7642
  }
7473
7643
 
7474
7644
  :host(.dark-mode) .input-container:hover,
@@ -7497,7 +7667,7 @@
7497
7667
  :host-context([darkmode]) .input-container:focus-within,
7498
7668
  :host-context([data-theme="dark"]) .input-container:focus-within,
7499
7669
  :host-context([theme="dark"]) .input-container:focus-within {
7500
- border-color: var(--select-dark-border-focus, var(--select-border-focus, #6366f1));
7670
+ border-color: var(--select-dark-border-focus, var(--select-input-focus-border, var(--select-border-focus, #6366f1)));
7501
7671
  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);
7502
7672
  }
7503
7673
 
@@ -7527,7 +7697,6 @@
7527
7697
  :host-context([data-theme="dark"]) .select-dropdown,
7528
7698
  :host-context([theme="dark"]) .select-dropdown {
7529
7699
  background: var(--select-dropdown-bg, var(--select-surface));
7530
- border-color: var(--select-border);
7531
7700
  }
7532
7701
 
7533
7702
  :host(.dark-mode) .options-container,
@@ -7662,7 +7831,7 @@
7662
7831
  this._handleClose();
7663
7832
  }
7664
7833
  else if (!this._state.isOpen) {
7665
- this._handleOpen();
7834
+ this._handleOpen('pointer');
7666
7835
  }
7667
7836
  };
7668
7837
  this._arrowContainer.addEventListener('click', this._boundArrowClick);
@@ -7719,7 +7888,7 @@
7719
7888
  }
7720
7889
  const wasClosed = !this._state.isOpen;
7721
7890
  if (wasClosed) {
7722
- this._handleOpen();
7891
+ this._handleOpen('pointer');
7723
7892
  }
7724
7893
  // Focus the input (do not prevent default behavior for input itself)
7725
7894
  this._applyFocusIntent('input', 'input-container-trigger');
@@ -7756,7 +7925,7 @@
7756
7925
  this._suppressNextOpenClick = false;
7757
7926
  this._multiScrollDrag.moved = false;
7758
7927
  if (!this._state.isOpen) {
7759
- this._handleOpen();
7928
+ this._handleOpen('pointer');
7760
7929
  }
7761
7930
  this._applyFocusIntent('input', 'input-container-activation');
7762
7931
  });
@@ -7823,43 +7992,60 @@
7823
7992
  }
7824
7993
  this._handleSearch(query);
7825
7994
  });
7826
- // If the user presses down inside the options container we should
7827
- // temporarily suppress blur-based closing until after the click has
7828
- // been handled. Setting a flag that gets cleared in the next tick is
7829
- // sufficient.
7830
- this._optionsContainer.addEventListener('pointerdown', () => {
7995
+ const findOptionElement = (event) => {
7996
+ const path = typeof event.composedPath === 'function' ? event.composedPath() : [event.target];
7997
+ for (const node of path) {
7998
+ if (!(node instanceof Element))
7999
+ continue;
8000
+ if (node.matches('select-option[data-sm-index], [data-sm-selectable][data-sm-index], [data-selectable][data-index]')) {
8001
+ return node;
8002
+ }
8003
+ }
8004
+ return null;
8005
+ };
8006
+ const resolveOptionRecord = (event, option = findOptionElement(event)) => {
8007
+ if (!option)
8008
+ return null;
8009
+ const index = Number(option.getAttribute('data-sm-index') ?? option.getAttribute('data-index'));
8010
+ if (!Number.isSafeInteger(index) || index < 0)
8011
+ return null;
8012
+ this._ensureRegistryCurrent();
8013
+ const record = this._getRecordByIndex(index);
8014
+ return record ? { option, record } : null;
8015
+ };
8016
+ // Keep the input focused when a blocked disabled option is pressed. This
8017
+ // prevents the delayed blur-close path from racing the delegated click.
8018
+ this._optionsContainer.addEventListener('pointerdown', (event) => {
7831
8019
  this._suppressBlurClose = true;
7832
8020
  this._setLifecycleTimeout(() => {
7833
8021
  this._suppressBlurClose = false;
7834
8022
  }, 150); // Increased timeout to ensure click finishes before blur checks
8023
+ const option = findOptionElement(event);
8024
+ if (!option?.matches('[aria-disabled="true"], .smilodon-option--disabled, .disabled'))
8025
+ return;
8026
+ const resolved = resolveOptionRecord(event, option);
8027
+ if (!resolved || !resolved.record.disabled)
8028
+ return;
8029
+ if (this._getDisabledOptionBehavior().selectable)
8030
+ return;
8031
+ event.preventDefault();
7835
8032
  });
7836
8033
  // Delegated click listener for improved event handling (robust across shadow DOM)
7837
8034
  const handleOptionEvent = (e) => {
7838
- const path = (e.composedPath && e.composedPath()) || [e.target];
7839
- let option = null;
7840
- for (const node of path) {
7841
- if (!(node instanceof Element))
7842
- continue;
7843
- try {
7844
- if (node.matches('[data-sm-selectable], [data-selectable], [data-sm-state]')) {
7845
- option = node;
7846
- break;
7847
- }
7848
- }
7849
- catch (err) {
7850
- continue;
7851
- }
7852
- }
7853
- if (option && (!option.hasAttribute('aria-disabled') || option.classList.contains('smilodon-option--disabled-selectable'))) {
7854
- const indexStr = option.getAttribute('data-sm-index') ?? option.getAttribute('data-index');
7855
- const index = Number(indexStr);
7856
- if (!Number.isNaN(index)) {
7857
- this._selectOption(index, {
7858
- shiftKey: e.shiftKey,
7859
- toggleKey: e.ctrlKey || e.metaKey,
7860
- });
7861
- }
8035
+ const resolved = resolveOptionRecord(e);
8036
+ if (!resolved)
8037
+ return;
8038
+ const behavior = this._getDisabledOptionBehavior();
8039
+ if (resolved.record.disabled && !behavior.selectable) {
8040
+ e.preventDefault();
8041
+ if (behavior.closeOnClick)
8042
+ this._handleClose('disabled-option-click');
8043
+ return;
7862
8044
  }
8045
+ this._selectOption(resolved.record.index, {
8046
+ shiftKey: e.shiftKey,
8047
+ toggleKey: e.ctrlKey || e.metaKey,
8048
+ });
7863
8049
  };
7864
8050
  this._optionsContainer.addEventListener('click', handleOptionEvent);
7865
8051
  // Keyboard navigation
@@ -8373,7 +8559,7 @@
8373
8559
  },
8374
8560
  }, { applyFocus: true });
8375
8561
  }
8376
- _handleOpen() {
8562
+ _handleOpen(intent = 'default') {
8377
8563
  if (!this._config.enabled) {
8378
8564
  this._runEngineEffects(this._engine.dispatch({ type: 'DISABLED_CHANGED', disabled: true }));
8379
8565
  return;
@@ -8407,10 +8593,17 @@
8407
8593
  this._liftStackingAncestors();
8408
8594
  this._dropdown.style.display = 'block';
8409
8595
  this._updateArrowRotation();
8596
+ // Pointer opening must not turn the previous selection or stale active key
8597
+ // into a synthetic hover-like highlight. Clear engine identity before the
8598
+ // options are rendered so built-in and custom renderers share the same state.
8599
+ if (intent === 'pointer') {
8600
+ this._dispatchActiveKey(null, 'open', 'pointer dropdown open');
8601
+ }
8410
8602
  // Render options when opening
8411
8603
  this._renderOptions();
8412
8604
  this._syncDropdownPlacement();
8413
- this._setInitialActiveOption();
8605
+ if (intent !== 'pointer')
8606
+ this._setInitialActiveOption();
8414
8607
  this._emit('open', {});
8415
8608
  this._config.callbacks.onOpen?.();
8416
8609
  this._announce('Options expanded');
@@ -9495,7 +9688,7 @@
9495
9688
  const selectableIndices = this._getSelectableOptionIndices();
9496
9689
  const selected = Array.from(this._state.selectedIndices).sort((a, b) => a - b);
9497
9690
  // Opening an empty select must not implicitly assign an active descendant.
9498
- // Keyboard navigation and pointer interaction establish active identity.
9691
+ // Keyboard navigation and option interaction establish active identity.
9499
9692
  if (selectableIndices.length === 0 || selected.length === 0) {
9500
9693
  this._dispatchActiveKey(null, 'open', 'initial active option');
9501
9694
  return;
@@ -9706,6 +9899,7 @@
9706
9899
  this._chipElements.delete(key);
9707
9900
  expected.remove();
9708
9901
  if (this.isConnected) {
9902
+ this._syncMultiSelectPlaceholderVisibility();
9709
9903
  this._observeSelectedLabelTooltipTargets();
9710
9904
  this._refreshSelectedLabelTooltipMeasurements();
9711
9905
  }
@@ -9875,6 +10069,21 @@
9875
10069
  nextSibling = badge;
9876
10070
  }
9877
10071
  }
10072
+ this._syncMultiSelectPlaceholderVisibility();
10073
+ }
10074
+ _syncMultiSelectPlaceholderVisibility() {
10075
+ if (this._config.selection.mode !== 'multi')
10076
+ return;
10077
+ const hasLogicalSelection = this._getSelectedEntries().length > 0;
10078
+ const hasMountedChipPresentation = this._inputContent.querySelector('.selection-badge') !== null;
10079
+ const isEmpty = !hasLogicalSelection && !hasMountedChipPresentation;
10080
+ this._input.placeholder = isEmpty
10081
+ ? (this._config.placeholder || 'Select an option...')
10082
+ : '';
10083
+ if (isEmpty
10084
+ && (this._config.multiSelectDisplay?.mode ?? 'wrap') === 'horizontal') {
10085
+ this._inputContent.scrollLeft = 0;
10086
+ }
9878
10087
  }
9879
10088
  _updateInputDisplay() {
9880
10089
  const selectedEntries = this._getSelectedEntries();
@@ -9903,14 +10112,8 @@
9903
10112
  this._cancelLatestChipScroll();
9904
10113
  const getLabel = this._config.serverSide.getLabelFromItem || ((item) => item?.label ?? String(item));
9905
10114
  if (this._config.selection.mode === 'multi') {
9906
- if (selectedItems.length === 0) {
9907
- this._input.value = '';
9908
- this._input.placeholder = this._config.placeholder || 'Select an option...';
9909
- }
9910
- else {
9911
- this._input.value = '';
9912
- this._input.placeholder = '';
9913
- }
10115
+ this._input.value = '';
10116
+ this._input.placeholder = '';
9914
10117
  this._renderSelectedChips(selectedEntries);
9915
10118
  }
9916
10119
  else {
@@ -9932,7 +10135,10 @@
9932
10135
  }
9933
10136
  // Preserve manual scrolling. Only a newly selected key can request auto-scroll.
9934
10137
  if (this._config.selection.mode === 'multi') {
9935
- this._inputContent.scrollLeft = previousChipScrollLeft;
10138
+ const hasMountedChipPresentation = this._inputContent.querySelector('.selection-badge') !== null;
10139
+ this._inputContent.scrollLeft = selectedEntries.length === 0 && !hasMountedChipPresentation
10140
+ ? 0
10141
+ : previousChipScrollLeft;
9936
10142
  if (newlyAddedKey !== undefined)
9937
10143
  this._scheduleLatestChipScroll(newlyAddedKey);
9938
10144
  }
@@ -10720,7 +10926,10 @@
10720
10926
  if (this._input) {
10721
10927
  this._input.readOnly = !this._config.searchable;
10722
10928
  this._syncComboboxAccessibility();
10723
- if (this._state.selectedIndices.size === 0) {
10929
+ if (this._config.selection.mode === 'multi') {
10930
+ this._syncMultiSelectPlaceholderVisibility();
10931
+ }
10932
+ else if (this._state.selectedIndices.size === 0) {
10724
10933
  this._input.placeholder = this._config.placeholder || 'Select an option...';
10725
10934
  }
10726
10935
  }
@@ -10737,6 +10946,7 @@
10737
10946
  }
10738
10947
  }
10739
10948
  this._syncStyleConfigVariables();
10949
+ this._syncDropdownConfigInlineStyles();
10740
10950
  this._syncListboxAccessibility();
10741
10951
  if (this.isConnected) {
10742
10952
  this._syncDirectionConfig();
@@ -12102,8 +12312,12 @@
12102
12312
  _createBusyBucket() {
12103
12313
  const bucket = document.createElement('div');
12104
12314
  bucket.setAttribute('part', 'loading');
12315
+ bucket.setAttribute('role', 'status');
12316
+ bucket.setAttribute('aria-live', 'polite');
12317
+ bucket.setAttribute('aria-atomic', 'true');
12105
12318
  bucket.className = 'busy-bucket';
12106
12319
  this._busyBucket = bucket;
12320
+ this._syncLoaderClassNames();
12107
12321
  const icon = document.createElement('div');
12108
12322
  icon.className = 'busy-icon';
12109
12323
  icon.setAttribute('part', 'loading-icon');
@@ -12151,6 +12365,25 @@
12151
12365
  this._syncBusyBucketContent(bucket);
12152
12366
  return bucket;
12153
12367
  }
12368
+ _createSearchingState() {
12369
+ const searching = document.createElement('div');
12370
+ searching.className = 'searching-state';
12371
+ searching.setAttribute('part', 'loading searching');
12372
+ searching.setAttribute('role', 'status');
12373
+ searching.setAttribute('aria-live', 'polite');
12374
+ searching.setAttribute('aria-atomic', 'true');
12375
+ const spinner = document.createElement('span');
12376
+ spinner.className = 'searching-spinner';
12377
+ spinner.setAttribute('part', 'searching-spinner');
12378
+ spinner.setAttribute('aria-hidden', 'true');
12379
+ const message = document.createElement('span');
12380
+ message.className = 'searching-message';
12381
+ message.setAttribute('part', 'searching-message');
12382
+ message.textContent = this._config.searchingMessage ?? 'Searching...';
12383
+ searching.append(spinner, message);
12384
+ this._syncLoaderClassNames(searching);
12385
+ return searching;
12386
+ }
12154
12387
  _renderOptions() {
12155
12388
  this._syncBusyPresentation();
12156
12389
  this._clearBusyBucketContentObserver();
@@ -12193,10 +12426,7 @@
12193
12426
  this._renderPlan = this._createLegacyRenderPlan([]);
12194
12427
  this._refreshVirtualizationScope(filteredIndicesForScope);
12195
12428
  this._syncLegacyActiveAria();
12196
- const searching = document.createElement('div');
12197
- searching.className = 'searching-state';
12198
- searching.setAttribute('part', 'loading');
12199
- searching.textContent = 'Searching...';
12429
+ const searching = this._createSearchingState();
12200
12430
  this._optionsContainer.appendChild(searching);
12201
12431
  this._syncEmptyStateContext(null);
12202
12432
  this._resolveRenderCycle(renderCycleId, true);
@@ -12676,6 +12906,7 @@
12676
12906
  _addLoadMoreTrigger() {
12677
12907
  const container = document.createElement('div');
12678
12908
  container.className = 'load-more-container';
12909
+ container.setAttribute('part', 'load-more-container');
12679
12910
  if (this._dataRequestCoordinator) {
12680
12911
  const shouldObserve = this._config.infiniteScroll.enabled
12681
12912
  && Boolean(this._intersectionObserver)
@@ -12687,6 +12918,7 @@
12687
12918
  sentinel.style.height = '10px';
12688
12919
  sentinel.style.width = '100%';
12689
12920
  sentinel.style.opacity = '0';
12921
+ sentinel.setAttribute('aria-hidden', 'true');
12690
12922
  this._acknowledgedSentinel = sentinel;
12691
12923
  this._loadMoreTrigger = sentinel;
12692
12924
  container.appendChild(sentinel);
@@ -12696,7 +12928,8 @@
12696
12928
  if (this._config.loadMore.enabled || this._config.infiniteScroll.enabled) {
12697
12929
  const button = document.createElement('button');
12698
12930
  button.className = 'load-more-button';
12699
- button.textContent = `Load ${this._config.loadMore.itemsPerLoad} more`;
12931
+ button.setAttribute('part', 'load-more-button');
12932
+ button.textContent = this._config.loadMore.label ?? `Load ${this._config.loadMore.itemsPerLoad} more`;
12700
12933
  button.addEventListener('click', () => this._loadMoreItems('manual'));
12701
12934
  container.appendChild(button);
12702
12935
  if (!sentinel)
@@ -12724,6 +12957,7 @@
12724
12957
  sentinel.style.height = '10px';
12725
12958
  sentinel.style.width = '100%';
12726
12959
  sentinel.style.opacity = '0'; // Invisible
12960
+ sentinel.setAttribute('aria-hidden', 'true');
12727
12961
  this._loadMoreTrigger = sentinel;
12728
12962
  container.appendChild(sentinel);
12729
12963
  }
@@ -12731,7 +12965,8 @@
12731
12965
  // Manual Load More: Render a button
12732
12966
  const button = document.createElement('button');
12733
12967
  button.className = 'load-more-button';
12734
- button.textContent = `Load ${this._config.loadMore.itemsPerLoad} more`;
12968
+ button.setAttribute('part', 'load-more-button');
12969
+ button.textContent = this._config.loadMore.label ?? `Load ${this._config.loadMore.itemsPerLoad} more`;
12735
12970
  button.addEventListener('click', () => this._loadMoreItems());
12736
12971
  this._loadMoreTrigger = button;
12737
12972
  container.appendChild(button);