@smilodon/core 1.5.1 → 1.5.4

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
@@ -1598,7 +1598,7 @@ class SelectOption extends HTMLElement {
1598
1598
  transform: var(--select-option-selected-hover-transform, var(--select-option-selected-transform, var(--select-option-transform, none)));
1599
1599
  }
1600
1600
 
1601
- .option-container.active {
1601
+ .option-container.active:not(.disabled) {
1602
1602
  background: var(--select-option-active-bg, var(--select-option-hover-bg, #f0f0f0));
1603
1603
  color: var(--select-option-active-color, var(--select-option-hover-color, var(--select-option-color, var(--select-text-color, #1f2937))));
1604
1604
  border: var(--select-option-active-border, var(--select-option-hover-border, var(--select-option-border, none)));
@@ -1726,7 +1726,7 @@ class SelectOption extends HTMLElement {
1726
1726
  toggleClasses(this._container, [...selectedClasses, 'smilodon-option--selected'], false);
1727
1727
  toggleClasses(this, [...selectedClasses, 'smilodon-option--selected'], false);
1728
1728
  }
1729
- if (active) {
1729
+ if (active && !disabled) {
1730
1730
  toggleClasses(this._container, [...activeClasses, 'smilodon-option--active'], true);
1731
1731
  toggleClasses(this, [...activeClasses, 'smilodon-option--active'], true); // Make focus ring visible on host
1732
1732
  }
@@ -1794,8 +1794,12 @@ class SelectOption extends HTMLElement {
1794
1794
  // Set ARIA attributes and State attributes on Host
1795
1795
  this.setAttribute('role', 'option');
1796
1796
  this.setAttribute('aria-selected', String(selected));
1797
- if (disabled)
1797
+ if (disabled) {
1798
1798
  this.setAttribute('aria-disabled', 'true');
1799
+ }
1800
+ else {
1801
+ this.removeAttribute('aria-disabled');
1802
+ }
1799
1803
  this.id = this._config.id || `select-option-${index}`;
1800
1804
  // Add checkmark (part="checkmark") - standard for object mode
1801
1805
  // Only show if NOT showing remove button (avoid clutter)
@@ -1814,7 +1818,7 @@ class SelectOption extends HTMLElement {
1814
1818
  const state = [];
1815
1819
  if (selected)
1816
1820
  state.push('selected');
1817
- if (active)
1821
+ if (active && !disabled)
1818
1822
  state.push('active');
1819
1823
  if (state.length) {
1820
1824
  this.dataset.smState = state.join(' ');
@@ -1938,7 +1942,7 @@ class SelectOption extends HTMLElement {
1938
1942
  * Set active state
1939
1943
  */
1940
1944
  setActive(active) {
1941
- this._config.active = active;
1945
+ this._config.active = active && !this._config.disabled;
1942
1946
  this._render();
1943
1947
  }
1944
1948
  /**
@@ -2451,11 +2455,11 @@ class EnhancedSelect extends HTMLElement {
2451
2455
  this._inputContainer.removeAttribute('data-multi-scroll-mode');
2452
2456
  this._inputContainer.removeAttribute('data-drag-scroll');
2453
2457
  this._inputContainer.classList.remove('is-dragging-scroll');
2454
- this._inputContainer.style.removeProperty('--select-multi-input-max-height');
2455
- this._inputContainer.style.removeProperty('--select-multi-input-overflow-x');
2456
- this._inputContainer.style.removeProperty('--select-multi-input-overflow-y');
2457
- this._inputContainer.style.removeProperty('--select-multi-input-flex-wrap');
2458
- this._inputContainer.style.removeProperty('--select-multi-input-align-content');
2458
+ this._inputContainer.style.removeProperty('--select-multi-input-max-height-config');
2459
+ this._inputContainer.style.removeProperty('--select-multi-input-overflow-x-config');
2460
+ this._inputContainer.style.removeProperty('--select-multi-input-overflow-y-config');
2461
+ this._inputContainer.style.removeProperty('--select-multi-input-flex-wrap-config');
2462
+ this._inputContainer.style.removeProperty('--select-multi-input-align-content-config');
2459
2463
  return;
2460
2464
  }
2461
2465
  const maxHeight = this._config.multiSelectDisplay?.maxHeight ?? '160px';
@@ -2465,11 +2469,11 @@ class EnhancedSelect extends HTMLElement {
2465
2469
  const alignContent = mode === 'horizontal' ? 'center' : 'flex-start';
2466
2470
  this._inputContainer.setAttribute('data-multi-scroll-mode', mode);
2467
2471
  this._inputContainer.setAttribute('data-drag-scroll', String(dragEnabled && mode === 'horizontal'));
2468
- this._inputContainer.style.setProperty('--select-multi-input-max-height', maxHeight);
2469
- this._inputContainer.style.setProperty('--select-multi-input-overflow-x', overflowX);
2470
- this._inputContainer.style.setProperty('--select-multi-input-overflow-y', overflowY);
2471
- this._inputContainer.style.setProperty('--select-multi-input-flex-wrap', flexWrap);
2472
- this._inputContainer.style.setProperty('--select-multi-input-align-content', alignContent);
2472
+ this._inputContainer.style.setProperty('--select-multi-input-max-height-config', maxHeight);
2473
+ this._inputContainer.style.setProperty('--select-multi-input-overflow-x-config', overflowX);
2474
+ this._inputContainer.style.setProperty('--select-multi-input-overflow-y-config', overflowY);
2475
+ this._inputContainer.style.setProperty('--select-multi-input-flex-wrap-config', flexWrap);
2476
+ this._inputContainer.style.setProperty('--select-multi-input-align-content-config', alignContent);
2473
2477
  }
2474
2478
  _canUseHorizontalMultiScroll(target) {
2475
2479
  if (this._config.selection.mode !== 'multi')
@@ -2719,7 +2723,7 @@ class EnhancedSelect extends HTMLElement {
2719
2723
  --select-accent: #0f3460;
2720
2724
  --select-accent-hover: #e94560;
2721
2725
  --select-surface: #ffffff;
2722
- --select-surface-elevated: #fafbfc;
2726
+ --select-surface-elevated: rgba(0, 0, 0, 0.04);
2723
2727
  --select-border: #e1e5eb;
2724
2728
  --select-border-focus: #0f3460;
2725
2729
  --select-text: #1a1a2e;
@@ -2767,16 +2771,15 @@ class EnhancedSelect extends HTMLElement {
2767
2771
  --select-multi-input-horizontal-cursor: grab;
2768
2772
  --select-multi-input-horizontal-active-cursor: grabbing;
2769
2773
  --select-multi-separator-inset-block: 10px;
2774
+ --select-multi-separator-height: auto;
2770
2775
  --select-multi-action-surface-bg: var(--select-input-bg, var(--select-surface));
2771
2776
  --select-multi-action-divider: 1px solid var(--select-border);
2772
2777
  --select-separator-width: 1px;
2773
- --select-separator-height: 50%;
2778
+ --select-separator-inset-block: 10px;
2779
+ --select-separator-height: auto;
2774
2780
  --select-separator-display: block;
2775
2781
  --select-separator-opacity: 0.6;
2776
2782
  --select-separator-active-opacity: 1;
2777
- --select-separator-width: 1px;
2778
- --select-separator-height: 50%;
2779
- --select-separator-display: block;
2780
2783
  --select-separator-position: var(--select-arrow-width, 42px);
2781
2784
  --select-separator-position-with-clear: calc(var(--select-arrow-right-with-clear, 34px) + var(--select-arrow-width, 42px));
2782
2785
  --select-separator-dark-bg: linear-gradient(
@@ -2847,9 +2850,9 @@ class EnhancedSelect extends HTMLElement {
2847
2850
  --select-searching-spinner-size: 24px;
2848
2851
  --select-searching-spinner-border: 2px solid var(--select-border);
2849
2852
  --select-searching-spinner-animation: var(--select-spinner-animation);
2850
- --select-group-header-separator-margin-top: 8px;
2851
- --select-group-header-separator-padding-top: 14px;
2852
- --select-group-header-separator-border-top: 1px solid var(--select-border);
2853
+ --select-group-header-separator-margin-top: 0;
2854
+ --select-group-header-separator-padding-top: 0;
2855
+ --select-group-header-separator-border-top: none;
2853
2856
  --select-reduced-motion-duration: 0.01ms;
2854
2857
  --select-reduced-motion-iteration-count: 1;
2855
2858
  --select-high-contrast-border-width: 2px;
@@ -3098,21 +3101,20 @@ class EnhancedSelect extends HTMLElement {
3098
3101
  }
3099
3102
 
3100
3103
  .input-container.input-container--multi {
3101
- max-height: var(--select-multi-input-max-height, var(--select-input-max-height, 160px));
3104
+ max-height: var(--select-multi-input-max-height, var(--select-multi-input-max-height-config, var(--select-input-max-height, 160px)));
3102
3105
  }
3103
3106
 
3104
3107
  .input-container.input-container--multi .input-content {
3105
- flex-wrap: var(--select-multi-input-flex-wrap, wrap);
3106
- align-content: var(--select-multi-input-align-content, flex-start);
3107
- overflow-x: var(--select-multi-input-overflow-x, hidden);
3108
- overflow-y: var(--select-multi-input-overflow-y, auto);
3108
+ flex-wrap: var(--select-multi-input-flex-wrap, var(--select-multi-input-flex-wrap-config, wrap));
3109
+ align-content: var(--select-multi-input-align-content, var(--select-multi-input-align-content-config, flex-start));
3110
+ overflow-x: var(--select-multi-input-overflow-x, var(--select-multi-input-overflow-x-config, hidden));
3111
+ overflow-y: var(--select-multi-input-overflow-y, var(--select-multi-input-overflow-y-config, auto));
3109
3112
  }
3110
3113
 
3111
3114
  .input-container.input-container--multi::after {
3112
- top: var(--select-multi-separator-inset-block, 10px);
3113
- bottom: var(--select-multi-separator-inset-block, 10px);
3114
- height: auto;
3115
- transform: none;
3115
+ top: var(--select-multi-separator-inset-block, var(--select-separator-inset-block, 10px));
3116
+ bottom: var(--select-multi-separator-inset-block, var(--select-separator-inset-block, 10px));
3117
+ height: var(--select-multi-separator-height, auto);
3116
3118
  }
3117
3119
 
3118
3120
  .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] {
@@ -3123,6 +3125,11 @@ class EnhancedSelect extends HTMLElement {
3123
3125
  cursor: var(--select-multi-input-horizontal-cursor, grab);
3124
3126
  overflow-y: hidden;
3125
3127
  overscroll-behavior-x: contain;
3128
+ padding-right: calc(var(--select-arrow-width, 42px) + var(--select-multi-horizontal-end-gap, 12px));
3129
+ }
3130
+
3131
+ .input-container.input-container--multi[data-multi-scroll-mode="horizontal"].has-clear-control .input-content {
3132
+ padding-right: calc(var(--select-arrow-width, 42px) + var(--select-clear-button-size, 26px) + var(--select-clear-button-right, 8px) + var(--select-multi-horizontal-end-gap, 12px));
3126
3133
  }
3127
3134
 
3128
3135
  .input-container.input-container--multi[data-multi-scroll-mode="horizontal"]::after {
@@ -3164,6 +3171,15 @@ class EnhancedSelect extends HTMLElement {
3164
3171
  left: var(--select-arrow-right-with-clear, 34px);
3165
3172
  }
3166
3173
 
3174
+ :host([dir="rtl"]) .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .input-content {
3175
+ padding-right: 0;
3176
+ padding-left: calc(var(--select-arrow-width, 42px) + var(--select-multi-horizontal-end-gap, 12px));
3177
+ }
3178
+
3179
+ :host([dir="rtl"]) .input-container.input-container--multi[data-multi-scroll-mode="horizontal"].has-clear-control .input-content {
3180
+ padding-left: calc(var(--select-arrow-width, 42px) + var(--select-clear-button-size, 26px) + var(--select-clear-button-right, 8px) + var(--select-multi-horizontal-end-gap, 12px));
3181
+ }
3182
+
3167
3183
  .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .clear-control-button {
3168
3184
  background: var(--select-multi-action-surface-bg, var(--select-input-bg, var(--select-surface)));
3169
3185
  z-index: 4;
@@ -3179,11 +3195,11 @@ class EnhancedSelect extends HTMLElement {
3179
3195
  content: '';
3180
3196
  display: var(--select-separator-display, block);
3181
3197
  position: absolute;
3182
- top: 50%;
3198
+ top: var(--select-separator-inset-block, 10px);
3199
+ bottom: var(--select-separator-inset-block, 10px);
3183
3200
  right: var(--select-separator-position, var(--select-arrow-width, 42px));
3184
- transform: translateY(-50%);
3185
3201
  width: var(--select-separator-width, 1px);
3186
- height: var(--select-separator-height, 50%);
3202
+ height: var(--select-separator-height, auto);
3187
3203
  background: var(--select-separator-bg, linear-gradient(
3188
3204
  to bottom,
3189
3205
  transparent 0%,
@@ -3517,8 +3533,10 @@ class EnhancedSelect extends HTMLElement {
3517
3533
  }
3518
3534
 
3519
3535
  .group-header:not(:first-child) {
3520
- margin-top: var(--select-group-header-separator-margin-top);
3521
- padding-top: var(--select-group-header-separator-padding-top);
3536
+ margin-top: calc(
3537
+ var(--select-group-header-separator-margin-top, 0px) +
3538
+ var(--select-group-header-separator-padding-top, 0px)
3539
+ );
3522
3540
  border-top: var(--select-group-header-separator-border-top);
3523
3541
  }
3524
3542
 
@@ -3533,13 +3551,15 @@ class EnhancedSelect extends HTMLElement {
3533
3551
  color: var(--select-option-color, var(--select-text));
3534
3552
  background: var(--select-option-bg, transparent);
3535
3553
  border: var(--select-option-border, none);
3554
+ box-sizing: border-box;
3536
3555
  text-align: var(--select-option-text-align, start);
3537
- transition:
3556
+ transition: var(--select-option-transition,
3538
3557
  background var(--select-transition-fast),
3539
3558
  color var(--select-transition-fast),
3540
- border-color var(--select-transition-fast),
3559
+ border var(--select-transition-fast),
3541
3560
  transform var(--select-transition-fast),
3542
- box-shadow var(--select-transition-fast);
3561
+ box-shadow var(--select-transition-fast)
3562
+ );
3543
3563
  user-select: none;
3544
3564
  font-size: var(--select-option-font-size, inherit);
3545
3565
  font-weight: var(--select-option-font-weight);
@@ -3549,10 +3569,10 @@ class EnhancedSelect extends HTMLElement {
3549
3569
  }
3550
3570
 
3551
3571
  .option:hover {
3552
- background: calc(var(--select-option-hover-enabled, 1) * 1) > 0 ? var(--select-option-hover-bg, var(--select-surface-elevated)) : var(--select-option-bg, transparent);
3553
- border: calc(var(--select-option-hover-enabled, 1) * 1) > 0 ? var(--select-option-hover-border, var(--select-option-border, none)) : var(--select-option-border, none);
3554
- color: calc(var(--select-option-hover-enabled, 1) * 1) > 0 ? var(--select-option-hover-color, var(--select-text)) : var(--select-option-color, var(--select-text));
3555
- transform: calc(var(--select-option-hover-enabled, 1) * 1) > 0 ? var(--select-option-hover-transform) : none;
3572
+ background: var(--select-option-hover-bg, var(--select-surface-elevated));
3573
+ border: var(--select-option-hover-border, var(--select-option-border, none));
3574
+ color: var(--select-option-hover-color, var(--select-text));
3575
+ transform: var(--select-option-hover-transform, none);
3556
3576
  }
3557
3577
 
3558
3578
  .option.selected {
@@ -3598,7 +3618,7 @@ class EnhancedSelect extends HTMLElement {
3598
3618
  color: var(--select-option-selected-hover-color, var(--select-option-selected-color, var(--select-accent)));
3599
3619
  }
3600
3620
 
3601
- .option.active:not(.selected) {
3621
+ .option.active:not(.selected):not(.disabled) {
3602
3622
  background: var(--select-option-active-bg, var(--select-surface-elevated));
3603
3623
  color: var(--select-option-active-color, var(--select-option-hover-color, var(--select-option-color, var(--select-text))));
3604
3624
  border: var(--select-option-active-border, var(--select-option-hover-border, var(--select-option-border, none)));
@@ -3608,7 +3628,7 @@ class EnhancedSelect extends HTMLElement {
3608
3628
  transform: var(--select-option-active-transform, none);
3609
3629
  }
3610
3630
 
3611
- .option.selected.active {
3631
+ .option.selected.active:not(.disabled) {
3612
3632
  outline: var(--select-option-selected-active-outline, 2px solid rgba(15, 52, 96, 0.4));
3613
3633
  outline-offset: var(--select-option-selected-active-outline-offset);
3614
3634
  }
@@ -3826,6 +3846,9 @@ class EnhancedSelect extends HTMLElement {
3826
3846
 
3827
3847
  --select-badge-bg: var(--select-dark-badge-bg, rgba(99, 102, 241, 0.2));
3828
3848
  --select-badge-color: var(--select-dark-badge-color, #e0e7ff);
3849
+ --select-badge-border: var(--select-dark-badge-border, var(--select-badge-border, none));
3850
+ --select-badge-hover-border: var(--select-dark-badge-hover-border, var(--select-badge-hover-border, var(--select-badge-border, none)));
3851
+ --select-badge-active-border: var(--select-dark-badge-active-border, var(--select-badge-active-border, var(--select-badge-hover-border, var(--select-badge-border, none))));
3829
3852
 
3830
3853
  --select-group-header-bg: var(--select-group-header-dark-bg, #1a1a2e);
3831
3854
  --select-group-header-color: var(--select-group-header-dark-color, #9ca3af);
@@ -3834,12 +3857,16 @@ class EnhancedSelect extends HTMLElement {
3834
3857
 
3835
3858
  --select-option-bg: var(--select-dark-option-bg, transparent);
3836
3859
  --select-option-color: var(--select-dark-option-color, var(--select-text));
3860
+ --select-option-border: var(--select-dark-option-border, none);
3837
3861
  --select-option-hover-bg: var(--select-dark-option-hover-bg, var(--select-surface-elevated));
3838
3862
  --select-option-hover-color: var(--select-dark-option-hover-color, var(--select-text));
3863
+ --select-option-hover-border: var(--select-dark-option-hover-border, var(--select-option-border, none));
3839
3864
  --select-option-selected-bg: var(--select-dark-option-selected-bg, linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(99, 102, 241, 0.08) 100%));
3840
3865
  --select-option-selected-color: var(--select-dark-option-selected-color, #a5b4fc);
3866
+ --select-option-selected-border: var(--select-dark-option-selected-border, var(--select-option-border, none));
3841
3867
  --select-option-selected-hover-bg: var(--select-dark-option-selected-hover-bg, var(--select-option-selected-bg));
3842
3868
  --select-option-selected-hover-color: var(--select-dark-option-selected-hover-color, var(--select-option-selected-color));
3869
+ --select-option-selected-hover-border: var(--select-dark-option-selected-hover-border, var(--select-option-selected-border, var(--select-option-hover-border, var(--select-option-border, none))));
3843
3870
  }
3844
3871
 
3845
3872
  :host(.dark-mode) .input-container,
@@ -3857,6 +3884,36 @@ class EnhancedSelect extends HTMLElement {
3857
3884
  border-color: var(--select-border);
3858
3885
  }
3859
3886
 
3887
+ :host(.dark-mode) .input-container:hover,
3888
+ :host([dark-mode]) .input-container:hover,
3889
+ :host([darkmode]) .input-container:hover,
3890
+ :host([data-theme="dark"]) .input-container:hover,
3891
+ :host([theme="dark"]) .input-container:hover,
3892
+ :host-context(.dark-mode) .input-container:hover,
3893
+ :host-context(.dark) .input-container:hover,
3894
+ :host-context([dark-mode]) .input-container:hover,
3895
+ :host-context([darkmode]) .input-container:hover,
3896
+ :host-context([data-theme="dark"]) .input-container:hover,
3897
+ :host-context([theme="dark"]) .input-container:hover {
3898
+ border-color: var(--select-dark-input-hover-border, var(--select-input-hover-border, var(--select-dark-border-focus, var(--select-border-focus, #6366f1))));
3899
+ box-shadow: var(--select-dark-input-hover-shadow, var(--select-input-hover-shadow, var(--select-shadow-sm), 0 0 0 1px rgba(99, 102, 241, 0.12)));
3900
+ }
3901
+
3902
+ :host(.dark-mode) .input-container:focus-within,
3903
+ :host([dark-mode]) .input-container:focus-within,
3904
+ :host([darkmode]) .input-container:focus-within,
3905
+ :host([data-theme="dark"]) .input-container:focus-within,
3906
+ :host([theme="dark"]) .input-container:focus-within,
3907
+ :host-context(.dark-mode) .input-container:focus-within,
3908
+ :host-context(.dark) .input-container:focus-within,
3909
+ :host-context([dark-mode]) .input-container:focus-within,
3910
+ :host-context([darkmode]) .input-container:focus-within,
3911
+ :host-context([data-theme="dark"]) .input-container:focus-within,
3912
+ :host-context([theme="dark"]) .input-container:focus-within {
3913
+ border-color: var(--select-dark-border-focus, var(--select-border-focus, #6366f1));
3914
+ 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);
3915
+ }
3916
+
3860
3917
  :host(.dark-mode) .input-container::after,
3861
3918
  :host([dark-mode]) .input-container::after,
3862
3919
  :host([darkmode]) .input-container::after,
@@ -3912,7 +3969,8 @@ class EnhancedSelect extends HTMLElement {
3912
3969
  :host-context([darkmode]) .selection-badge,
3913
3970
  :host-context([data-theme="dark"]) .selection-badge,
3914
3971
  :host-context([theme="dark"]) .selection-badge {
3915
- background: var(--select-badge-dark-bg);
3972
+ background: var(--select-dark-badge-bg, var(--select-badge-bg, var(--select-badge-dark-bg)));
3973
+ color: var(--select-dark-badge-color, var(--select-badge-color, #e0e7ff));
3916
3974
  }
3917
3975
 
3918
3976
  :host(.dark-mode) .group-header:not(:first-child),
@@ -4093,6 +4151,10 @@ class EnhancedSelect extends HTMLElement {
4093
4151
  this._inputContent.addEventListener('wheel', (e) => {
4094
4152
  if (this._config.selection.mode === 'multi'
4095
4153
  && (this._config.multiSelectDisplay?.mode ?? 'wrap') === 'horizontal') {
4154
+ const primaryDelta = Math.abs(e.deltaX) > Math.abs(e.deltaY) ? e.deltaX : e.deltaY;
4155
+ if (primaryDelta !== 0) {
4156
+ this._inputContent.scrollLeft += primaryDelta;
4157
+ }
4096
4158
  e.preventDefault();
4097
4159
  }
4098
4160
  }, { passive: false });
@@ -4487,6 +4549,8 @@ class EnhancedSelect extends HTMLElement {
4487
4549
  }
4488
4550
  }
4489
4551
  _handleKeydown(e) {
4552
+ if (!this._config.enabled)
4553
+ return;
4490
4554
  switch (e.key) {
4491
4555
  case 'ArrowDown':
4492
4556
  e.preventDefault();
@@ -4509,17 +4573,23 @@ class EnhancedSelect extends HTMLElement {
4509
4573
  case 'Home':
4510
4574
  e.preventDefault();
4511
4575
  if (this._state.isOpen) {
4512
- this._setActive(0);
4576
+ const selectableIndices = this._getSelectableOptionIndices();
4577
+ const firstIndex = selectableIndices[0];
4578
+ if (firstIndex === undefined)
4579
+ break;
4580
+ this._setActive(firstIndex);
4513
4581
  if (this._config.selection.mode === 'multi' && e.shiftKey) {
4514
- this._selectRange(this._rangeAnchorIndex ?? 0, 0, { clear: !(e.ctrlKey || e.metaKey) });
4582
+ this._selectRange(this._rangeAnchorIndex ?? firstIndex, firstIndex, { clear: !(e.ctrlKey || e.metaKey) });
4515
4583
  }
4516
4584
  }
4517
4585
  break;
4518
4586
  case 'End':
4519
4587
  e.preventDefault();
4520
4588
  if (this._state.isOpen) {
4521
- const options = Array.from(this._optionsContainer.children);
4522
- const lastIndex = Math.max(0, options.length - 1);
4589
+ const selectableIndices = this._getSelectableOptionIndices();
4590
+ const lastIndex = selectableIndices[selectableIndices.length - 1];
4591
+ if (lastIndex === undefined)
4592
+ break;
4523
4593
  this._setActive(lastIndex);
4524
4594
  if (this._config.selection.mode === 'multi' && e.shiftKey) {
4525
4595
  this._selectRange(this._rangeAnchorIndex ?? lastIndex, lastIndex, { clear: !(e.ctrlKey || e.metaKey) });
@@ -4573,8 +4643,17 @@ class EnhancedSelect extends HTMLElement {
4573
4643
  }
4574
4644
  }
4575
4645
  _moveActive(delta, opts) {
4576
- const options = Array.from(this._optionsContainer.children);
4577
- const next = Math.max(0, Math.min(options.length - 1, this._state.activeIndex + delta));
4646
+ const selectableIndices = this._getSelectableOptionIndices();
4647
+ if (selectableIndices.length === 0)
4648
+ return;
4649
+ const currentPosition = selectableIndices.indexOf(this._state.activeIndex);
4650
+ const basePosition = currentPosition >= 0
4651
+ ? currentPosition
4652
+ : delta >= 0
4653
+ ? -1
4654
+ : selectableIndices.length;
4655
+ const nextPosition = Math.max(0, Math.min(selectableIndices.length - 1, basePosition + delta));
4656
+ const next = selectableIndices[nextPosition];
4578
4657
  this._setActive(next);
4579
4658
  if (this._config.selection.mode === 'multi' && opts?.shiftKey) {
4580
4659
  const anchor = this._rangeAnchorIndex ?? this._state.activeIndex;
@@ -4586,6 +4665,10 @@ class EnhancedSelect extends HTMLElement {
4586
4665
  }
4587
4666
  }
4588
4667
  _setActive(index) {
4668
+ const option = this._getOptionElementByIndex(index);
4669
+ if (!option || option.getAttribute('aria-disabled') === 'true') {
4670
+ return;
4671
+ }
4589
4672
  // Clear previous active state
4590
4673
  if (this._state.activeIndex >= 0) {
4591
4674
  const prevOption = this._getOptionElementByIndex(this._state.activeIndex);
@@ -4602,7 +4685,6 @@ class EnhancedSelect extends HTMLElement {
4602
4685
  }
4603
4686
  this._state.activeIndex = index;
4604
4687
  // Set new active state
4605
- const option = this._getOptionElementByIndex(index);
4606
4688
  if (option) {
4607
4689
  // Check if it's a custom SelectOption or a lightweight DOM element
4608
4690
  if ('setActive' in option && typeof option.setActive === 'function') {
@@ -4627,6 +4709,19 @@ class EnhancedSelect extends HTMLElement {
4627
4709
  _getOptionElementByIndex(index) {
4628
4710
  return this._optionsContainer.querySelector(`[data-index="${index}"]`);
4629
4711
  }
4712
+ _getSelectableOptions() {
4713
+ // Filter out group headers and other non-selectable elements
4714
+ // Only return elements with data-index or data-sm-selectable attributes
4715
+ return Array.from(this._optionsContainer.children).filter((child) => {
4716
+ return (child.hasAttribute('data-index') || child.hasAttribute('data-sm-selectable'))
4717
+ && child.getAttribute('aria-disabled') !== 'true';
4718
+ });
4719
+ }
4720
+ _getSelectableOptionIndices() {
4721
+ return this._getSelectableOptions()
4722
+ .map((option) => Number(option.getAttribute('data-sm-index') ?? option.getAttribute('data-index')))
4723
+ .filter((index) => Number.isFinite(index));
4724
+ }
4630
4725
  _buildRendererHelpers() {
4631
4726
  return {
4632
4727
  onSelect: (_item, index) => this._selectOption(index),
@@ -4661,26 +4756,29 @@ class EnhancedSelect extends HTMLElement {
4661
4756
  _selectAll() {
4662
4757
  if (this._config.selection.mode !== 'multi')
4663
4758
  return;
4664
- const options = Array.from(this._optionsContainer.children);
4759
+ const options = this._getSelectableOptions();
4665
4760
  const maxSelections = this._config.selection.maxSelections || 0;
4666
- options.forEach((option, index) => {
4761
+ options.forEach((option) => {
4762
+ const optionIndex = Number(option.getAttribute('data-sm-index') ?? option.getAttribute('data-index'));
4763
+ if (!Number.isFinite(optionIndex))
4764
+ return;
4667
4765
  if (maxSelections > 0 && this._state.selectedIndices.size >= maxSelections) {
4668
4766
  return;
4669
4767
  }
4670
- if (!this._state.selectedIndices.has(index)) {
4768
+ if (!this._state.selectedIndices.has(optionIndex)) {
4671
4769
  // Check if it's a custom SelectOption or a lightweight DOM element
4672
4770
  if ('getConfig' in option && typeof option.getConfig === 'function') {
4673
4771
  const config = option.getConfig();
4674
- this._state.selectedIndices.add(index);
4675
- this._state.selectedItems.set(index, config.item);
4772
+ this._state.selectedIndices.add(optionIndex);
4773
+ this._state.selectedItems.set(optionIndex, config.item);
4676
4774
  option.setSelected(true);
4677
4775
  }
4678
4776
  else {
4679
4777
  // Lightweight option - get item from data attribute or state
4680
- const item = this._state.loadedItems[index];
4778
+ const item = this._state.loadedItems[optionIndex];
4681
4779
  if (item) {
4682
- this._state.selectedIndices.add(index);
4683
- this._state.selectedItems.set(index, item);
4780
+ this._state.selectedIndices.add(optionIndex);
4781
+ this._state.selectedItems.set(optionIndex, item);
4684
4782
  option.classList.add('smilodon-option--selected');
4685
4783
  option.setAttribute('aria-selected', 'true');
4686
4784
  }
@@ -4704,6 +4802,9 @@ class EnhancedSelect extends HTMLElement {
4704
4802
  if (maxSelections > 0 && this._state.selectedIndices.size >= maxSelections)
4705
4803
  break;
4706
4804
  const item = this._state.loadedItems[i];
4805
+ const optionEl = this._getOptionElementByIndex(i);
4806
+ if (optionEl?.getAttribute('aria-disabled') === 'true')
4807
+ continue;
4707
4808
  if (!item)
4708
4809
  continue;
4709
4810
  this._state.selectedIndices.add(i);
@@ -4715,8 +4816,8 @@ class EnhancedSelect extends HTMLElement {
4715
4816
  this._announce(`${this._state.selectedIndices.size} items selected`);
4716
4817
  }
4717
4818
  _setInitialActiveOption() {
4718
- const options = Array.from(this._optionsContainer.children);
4719
- if (options.length === 0)
4819
+ const selectableIndices = this._getSelectableOptionIndices();
4820
+ if (selectableIndices.length === 0)
4720
4821
  return;
4721
4822
  const selected = Array.from(this._state.selectedIndices).sort((a, b) => a - b);
4722
4823
  if (this._config.selection.mode === 'multi' && selected.length === 0) {
@@ -4724,8 +4825,8 @@ class EnhancedSelect extends HTMLElement {
4724
4825
  this._input.removeAttribute('aria-activedescendant');
4725
4826
  return;
4726
4827
  }
4727
- const target = selected.length > 0 ? selected[0] : 0;
4728
- this._setActive(Math.min(target, options.length - 1));
4828
+ const target = selected.find((index) => selectableIndices.includes(index)) ?? selectableIndices[0];
4829
+ this._setActive(target);
4729
4830
  }
4730
4831
  _announce(message) {
4731
4832
  if (this._liveRegion) {