@smilodon/core 1.10.1 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -154,6 +154,22 @@ select.addEventListener('change', (event) => {
154
154
  });
155
155
  ```
156
156
 
157
+ ### Hover stability
158
+
159
+ Option hover styling no longer moves the option hit target or introduces a layout-changing border. Hover border tokens render as outlines; hover-specific border-bottom and transform styling is not applied to the selectable option. The former `styles.hoverOption.transform` setting no longer moves the selectable element on hover; animate inner content instead if motion is needed. Option selection and keyboard-active styling remain separate from hover.
160
+
161
+ ### Custom arrow slot
162
+
163
+ The default chevron remains in place unless a light-DOM child is assigned to the `arrow` slot:
164
+
165
+ ```html
166
+ <enhanced-select id="my-select">
167
+ <span slot="arrow" aria-hidden="true">▼</span>
168
+ </enhanced-select>
169
+ ```
170
+
171
+ The custom node is decorative and Core keeps ownership of the arrow click behavior. The built-in arrow rotates with the popup; a custom node does not rotate unless the consumer styles it using the host's `data-open="true"` state. Core does not impose its arrow color or hover background on assigned custom content.
172
+
157
173
  ### Framework Usage
158
174
 
159
175
  **In browser DOM frameworks, `@smilodon/core` can be used directly** as a Web Component; framework adapters are available for framework-specific APIs.
@@ -528,6 +544,8 @@ The component implements keyboard interaction paths including:
528
544
  | `Ctrl+A` (multi-select) | Select all options |
529
545
  | Type characters | Type-ahead search |
530
546
 
547
+ When an empty single-select opens, it has no active option and does not expose `aria-activedescendant` until keyboard navigation begins. Press `ArrowDown` to activate the first selectable option. If a value is already selected, opening the list activates that selected option.
548
+
531
549
  **Multi-Select Range Selection:**
532
550
  - `Shift + ↑/↓` - Range selection
533
551
  - `Ctrl/Cmd + Click` - Toggle individual items
package/dist/index.cjs CHANGED
@@ -2606,14 +2606,13 @@ class SelectOption extends HTMLElement {
2606
2606
  transition: var(--select-option-transition, background-color 0.2s ease);
2607
2607
  }
2608
2608
 
2609
- :host(:hover):not(.smilodon-option--disabled):not([aria-disabled="true"]),
2609
+ :host(:hover:not(.smilodon-option--disabled):not([aria-disabled="true"])),
2610
2610
  :host(.smilodon-option--disabled-hoverable:hover) {
2611
2611
  background: var(--select-option-hover-bg, #f0f0f0);
2612
2612
  color: var(--select-option-hover-color, var(--select-option-color, var(--select-text-color, #1f2937)));
2613
- border: var(--select-option-hover-border, var(--select-option-border, none));
2614
- border-bottom: var(--select-option-hover-border-bottom, var(--select-option-border-bottom, none));
2613
+ outline: var(--select-option-hover-border, none);
2614
+ outline-offset: -1px;
2615
2615
  box-shadow: var(--select-option-hover-shadow, var(--select-option-shadow, none));
2616
- transform: var(--select-option-hover-transform, var(--select-option-transform, none));
2617
2616
  }
2618
2617
 
2619
2618
  /* Keep the visual surface on the host so external utility classes applied
@@ -2634,10 +2633,9 @@ class SelectOption extends HTMLElement {
2634
2633
  :host(.smilodon-option--selected:hover) {
2635
2634
  background: var(--select-option-selected-hover-bg, var(--select-option-selected-bg, #e3f2fd));
2636
2635
  color: var(--select-option-selected-hover-color, var(--select-option-selected-color, #1976d2));
2637
- border: var(--select-option-selected-hover-border, var(--select-option-selected-border, var(--select-option-border, none)));
2638
- border-bottom: var(--select-option-selected-hover-border-bottom, var(--select-option-selected-border-bottom, var(--select-option-border-bottom, none)));
2636
+ outline: var(--select-option-selected-hover-border, var(--select-option-hover-border, none));
2637
+ outline-offset: -1px;
2639
2638
  box-shadow: var(--select-option-selected-hover-shadow, var(--select-option-selected-shadow, var(--select-option-shadow, none)));
2640
- transform: var(--select-option-selected-hover-transform, var(--select-option-selected-transform, var(--select-option-transform, none)));
2641
2639
  }
2642
2640
 
2643
2641
  :host(.smilodon-option--active):not(.smilodon-option--disabled):not([aria-disabled="true"]),
@@ -5494,10 +5492,21 @@ class EnhancedSelect extends HTMLElement {
5494
5492
  const container = document.createElement('div');
5495
5493
  container.className = 'dropdown-arrow-container';
5496
5494
  container.innerHTML = `
5497
- <svg class="dropdown-arrow" part="arrow" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
5498
- <path d="M4 6L8 10L12 6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
5499
- </svg>
5495
+ <slot name="arrow">
5496
+ <svg class="dropdown-arrow" part="arrow" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
5497
+ <path d="M4 6L8 10L12 6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
5498
+ </svg>
5499
+ </slot>
5500
5500
  `;
5501
+ const slot = container.querySelector('slot[name="arrow"]');
5502
+ slot?.addEventListener('slotchange', () => {
5503
+ if (slot.assignedElements({ flatten: true }).length > 0) {
5504
+ this.setAttribute('data-custom-arrow', 'true');
5505
+ }
5506
+ else {
5507
+ this.removeAttribute('data-custom-arrow');
5508
+ }
5509
+ });
5501
5510
  return container;
5502
5511
  }
5503
5512
  _createClearControl() {
@@ -5653,7 +5662,7 @@ class EnhancedSelect extends HTMLElement {
5653
5662
  --select-scrollbar-width: 6px;
5654
5663
  --select-scrollbar-thumb-radius: 3px;
5655
5664
  --select-option-hover-enabled: 1;
5656
- --select-option-hover-transform: translateX(2px);
5665
+ --select-option-hover-transform: none;
5657
5666
  --select-option-font-weight: 450;
5658
5667
  --select-option-margin: 2px 0;
5659
5668
  --select-input-font-size: inherit;
@@ -6212,6 +6221,10 @@ class EnhancedSelect extends HTMLElement {
6212
6221
  .dropdown-arrow-container:hover {
6213
6222
  background-color: var(--select-arrow-hover-bg, rgba(15, 52, 96, 0.05));
6214
6223
  }
6224
+
6225
+ :host([data-custom-arrow="true"]) .dropdown-arrow-container:hover {
6226
+ background-color: transparent;
6227
+ }
6215
6228
 
6216
6229
  .dropdown-arrow {
6217
6230
  width: var(--select-arrow-width, var(--select-arrow-size, 16px));
@@ -6433,8 +6446,7 @@ class EnhancedSelect extends HTMLElement {
6433
6446
  transition: var(--select-option-transition,
6434
6447
  background var(--select-transition-fast),
6435
6448
  color var(--select-transition-fast),
6436
- border var(--select-transition-fast),
6437
- transform var(--select-transition-fast),
6449
+ outline-color var(--select-transition-fast),
6438
6450
  box-shadow var(--select-transition-fast)
6439
6451
  );
6440
6452
  user-select: none;
@@ -6448,9 +6460,10 @@ class EnhancedSelect extends HTMLElement {
6448
6460
  .option:hover:not(.disabled):not(.smilodon-option--disabled),
6449
6461
  .option.smilodon-option--disabled-hoverable:hover {
6450
6462
  background: var(--select-option-hover-bg, var(--select-surface-elevated));
6451
- border: var(--select-option-hover-border, var(--select-option-border, none));
6463
+ /* Hover decoration must not resize or translate the pointer hit target. */
6464
+ outline: var(--select-option-hover-border, none);
6465
+ outline-offset: -1px;
6452
6466
  color: var(--select-option-hover-color, var(--select-text));
6453
- transform: var(--select-option-hover-transform, none);
6454
6467
  }
6455
6468
 
6456
6469
  .option.selected {
@@ -6493,7 +6506,8 @@ class EnhancedSelect extends HTMLElement {
6493
6506
 
6494
6507
  .option.selected:hover {
6495
6508
  background: var(--select-option-selected-hover-bg, var(--select-option-selected-bg, linear-gradient(135deg, rgba(15, 52, 96, 0.12) 0%, rgba(15, 52, 96, 0.06) 100%)));
6496
- border: var(--select-option-selected-hover-border, var(--select-option-selected-border, var(--select-option-hover-border, var(--select-option-border, none))));
6509
+ outline: var(--select-option-selected-hover-border, var(--select-option-hover-border, none));
6510
+ outline-offset: -1px;
6497
6511
  color: var(--select-option-selected-hover-color, var(--select-option-selected-color, var(--select-accent)));
6498
6512
  }
6499
6513
 
@@ -7923,7 +7937,9 @@ class EnhancedSelect extends HTMLElement {
7923
7937
  _setInitialActiveOption() {
7924
7938
  const selectableIndices = this._getSelectableOptionIndices();
7925
7939
  const selected = Array.from(this._state.selectedIndices).sort((a, b) => a - b);
7926
- if (selectableIndices.length === 0 || (this._config.selection.mode === 'multi' && selected.length === 0)) {
7940
+ // Opening an empty select must not implicitly assign an active descendant.
7941
+ // Keyboard navigation and pointer interaction establish active identity.
7942
+ if (selectableIndices.length === 0 || selected.length === 0) {
7927
7943
  this._dispatchActiveKey(null, 'open', 'initial active option');
7928
7944
  return;
7929
7945
  }
@@ -8149,6 +8165,11 @@ class EnhancedSelect extends HTMLElement {
8149
8165
  }
8150
8166
  this._syncClearControlState();
8151
8167
  }
8168
+ _isActivelyEditingSearchInput() {
8169
+ return this._config.searchable === true
8170
+ && this._state.isOpen
8171
+ && this._shadow.activeElement === this._input;
8172
+ }
8152
8173
  _renderOptionsWithAnimation() {
8153
8174
  // Add fade-out animation
8154
8175
  this._optionsContainer.style.opacity = '0';
@@ -8458,7 +8479,7 @@ class EnhancedSelect extends HTMLElement {
8458
8479
  const previousLength = this._state.loadedItems.length;
8459
8480
  this._rebuildItemRegistry(items);
8460
8481
  this._state.groupedItems = this._groupItemsByProperty(items);
8461
- if (!this._state.searchQuery)
8482
+ if (!this._state.searchQuery && !this._isActivelyEditingSearchInput())
8462
8483
  this._updateInputDisplay();
8463
8484
  const newLength = this._state.loadedItems.length;
8464
8485
  if (this._dataRequestCoordinator) {
@@ -8539,7 +8560,7 @@ class EnhancedSelect extends HTMLElement {
8539
8560
  this._rebuildItemRegistry(groupedItems.flatMap(group => group.options));
8540
8561
  this._state.groupedItems = groupedItems;
8541
8562
  this._renderOptions();
8542
- if (!this._state.searchQuery)
8563
+ if (!this._state.searchQuery && !this._isActivelyEditingSearchInput())
8543
8564
  this._updateInputDisplay();
8544
8565
  }
8545
8566
  /**
@@ -8755,14 +8776,16 @@ class EnhancedSelect extends HTMLElement {
8755
8776
  // Re-initialize observers in case infinite scroll was enabled/disabled
8756
8777
  this._initializeObservers();
8757
8778
  this._syncClearControlState();
8758
- this._updateInputDisplay();
8779
+ if (!this._isActivelyEditingSearchInput())
8780
+ this._updateInputDisplay();
8759
8781
  this._renderOptions();
8760
8782
  }
8761
8783
  else {
8762
8784
  this._syncInputContainerMode();
8763
8785
  this._syncMultiSelectDisplayConfig();
8764
8786
  this._syncClearControlState();
8765
- this._updateInputDisplay();
8787
+ if (!this._isActivelyEditingSearchInput())
8788
+ this._updateInputDisplay();
8766
8789
  }
8767
8790
  this._acknowledgedSearchMode = this._dataLoadingConfig.searchMode;
8768
8791
  if (this._dataLoadingConfig.protocol === 'legacy')
@@ -9575,7 +9598,9 @@ class EnhancedSelect extends HTMLElement {
9575
9598
  this._acknowledgedProjectionFailureStageForTest = null;
9576
9599
  throw new Error('Injected acknowledged projection failure after publication');
9577
9600
  }
9578
- if (!this._state.searchQuery && this._acknowledgedPendingSearchQuery === null) {
9601
+ if (!this._state.searchQuery
9602
+ && this._acknowledgedPendingSearchQuery === null
9603
+ && !this._isActivelyEditingSearchInput()) {
9579
9604
  this._updateInputDisplay();
9580
9605
  }
9581
9606
  this._syncListboxAccessibility();