@smilodon/core 1.5.3 → 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/README.md +3 -0
- package/dist/index.cjs +134 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +134 -44
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.umd.js +134 -44
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/src/components/enhanced-select.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -674,6 +674,9 @@ enhanced-select.dark-mode {
|
|
|
674
674
|
|
|
675
675
|
/* Group headers (when using groupedItems or flat items with `group` property) */
|
|
676
676
|
--select-group-header-padding /* Padding inside header (8px 12px) */
|
|
677
|
+
--select-group-header-separator-margin-top /* Extra gap before later groups */
|
|
678
|
+
--select-group-header-separator-padding-top /* Adds separator spacing without changing header title padding */
|
|
679
|
+
--select-group-header-separator-border-top /* Divider above later groups */
|
|
677
680
|
--select-group-header-color /* Text color (#6b7280) */
|
|
678
681
|
--select-group-header-bg /* Background (#f3f4f6) */
|
|
679
682
|
--select-group-header-font-size
|
package/dist/index.cjs
CHANGED
|
@@ -1600,7 +1600,7 @@ class SelectOption extends HTMLElement {
|
|
|
1600
1600
|
transform: var(--select-option-selected-hover-transform, var(--select-option-selected-transform, var(--select-option-transform, none)));
|
|
1601
1601
|
}
|
|
1602
1602
|
|
|
1603
|
-
.option-container.active {
|
|
1603
|
+
.option-container.active:not(.disabled) {
|
|
1604
1604
|
background: var(--select-option-active-bg, var(--select-option-hover-bg, #f0f0f0));
|
|
1605
1605
|
color: var(--select-option-active-color, var(--select-option-hover-color, var(--select-option-color, var(--select-text-color, #1f2937))));
|
|
1606
1606
|
border: var(--select-option-active-border, var(--select-option-hover-border, var(--select-option-border, none)));
|
|
@@ -1728,7 +1728,7 @@ class SelectOption extends HTMLElement {
|
|
|
1728
1728
|
toggleClasses(this._container, [...selectedClasses, 'smilodon-option--selected'], false);
|
|
1729
1729
|
toggleClasses(this, [...selectedClasses, 'smilodon-option--selected'], false);
|
|
1730
1730
|
}
|
|
1731
|
-
if (active) {
|
|
1731
|
+
if (active && !disabled) {
|
|
1732
1732
|
toggleClasses(this._container, [...activeClasses, 'smilodon-option--active'], true);
|
|
1733
1733
|
toggleClasses(this, [...activeClasses, 'smilodon-option--active'], true); // Make focus ring visible on host
|
|
1734
1734
|
}
|
|
@@ -1796,8 +1796,12 @@ class SelectOption extends HTMLElement {
|
|
|
1796
1796
|
// Set ARIA attributes and State attributes on Host
|
|
1797
1797
|
this.setAttribute('role', 'option');
|
|
1798
1798
|
this.setAttribute('aria-selected', String(selected));
|
|
1799
|
-
if (disabled)
|
|
1799
|
+
if (disabled) {
|
|
1800
1800
|
this.setAttribute('aria-disabled', 'true');
|
|
1801
|
+
}
|
|
1802
|
+
else {
|
|
1803
|
+
this.removeAttribute('aria-disabled');
|
|
1804
|
+
}
|
|
1801
1805
|
this.id = this._config.id || `select-option-${index}`;
|
|
1802
1806
|
// Add checkmark (part="checkmark") - standard for object mode
|
|
1803
1807
|
// Only show if NOT showing remove button (avoid clutter)
|
|
@@ -1816,7 +1820,7 @@ class SelectOption extends HTMLElement {
|
|
|
1816
1820
|
const state = [];
|
|
1817
1821
|
if (selected)
|
|
1818
1822
|
state.push('selected');
|
|
1819
|
-
if (active)
|
|
1823
|
+
if (active && !disabled)
|
|
1820
1824
|
state.push('active');
|
|
1821
1825
|
if (state.length) {
|
|
1822
1826
|
this.dataset.smState = state.join(' ');
|
|
@@ -1940,7 +1944,7 @@ class SelectOption extends HTMLElement {
|
|
|
1940
1944
|
* Set active state
|
|
1941
1945
|
*/
|
|
1942
1946
|
setActive(active) {
|
|
1943
|
-
this._config.active = active;
|
|
1947
|
+
this._config.active = active && !this._config.disabled;
|
|
1944
1948
|
this._render();
|
|
1945
1949
|
}
|
|
1946
1950
|
/**
|
|
@@ -2453,11 +2457,11 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2453
2457
|
this._inputContainer.removeAttribute('data-multi-scroll-mode');
|
|
2454
2458
|
this._inputContainer.removeAttribute('data-drag-scroll');
|
|
2455
2459
|
this._inputContainer.classList.remove('is-dragging-scroll');
|
|
2456
|
-
this._inputContainer.style.removeProperty('--select-multi-input-max-height');
|
|
2457
|
-
this._inputContainer.style.removeProperty('--select-multi-input-overflow-x');
|
|
2458
|
-
this._inputContainer.style.removeProperty('--select-multi-input-overflow-y');
|
|
2459
|
-
this._inputContainer.style.removeProperty('--select-multi-input-flex-wrap');
|
|
2460
|
-
this._inputContainer.style.removeProperty('--select-multi-input-align-content');
|
|
2460
|
+
this._inputContainer.style.removeProperty('--select-multi-input-max-height-config');
|
|
2461
|
+
this._inputContainer.style.removeProperty('--select-multi-input-overflow-x-config');
|
|
2462
|
+
this._inputContainer.style.removeProperty('--select-multi-input-overflow-y-config');
|
|
2463
|
+
this._inputContainer.style.removeProperty('--select-multi-input-flex-wrap-config');
|
|
2464
|
+
this._inputContainer.style.removeProperty('--select-multi-input-align-content-config');
|
|
2461
2465
|
return;
|
|
2462
2466
|
}
|
|
2463
2467
|
const maxHeight = this._config.multiSelectDisplay?.maxHeight ?? '160px';
|
|
@@ -2467,11 +2471,11 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2467
2471
|
const alignContent = mode === 'horizontal' ? 'center' : 'flex-start';
|
|
2468
2472
|
this._inputContainer.setAttribute('data-multi-scroll-mode', mode);
|
|
2469
2473
|
this._inputContainer.setAttribute('data-drag-scroll', String(dragEnabled && mode === 'horizontal'));
|
|
2470
|
-
this._inputContainer.style.setProperty('--select-multi-input-max-height', maxHeight);
|
|
2471
|
-
this._inputContainer.style.setProperty('--select-multi-input-overflow-x', overflowX);
|
|
2472
|
-
this._inputContainer.style.setProperty('--select-multi-input-overflow-y', overflowY);
|
|
2473
|
-
this._inputContainer.style.setProperty('--select-multi-input-flex-wrap', flexWrap);
|
|
2474
|
-
this._inputContainer.style.setProperty('--select-multi-input-align-content', alignContent);
|
|
2474
|
+
this._inputContainer.style.setProperty('--select-multi-input-max-height-config', maxHeight);
|
|
2475
|
+
this._inputContainer.style.setProperty('--select-multi-input-overflow-x-config', overflowX);
|
|
2476
|
+
this._inputContainer.style.setProperty('--select-multi-input-overflow-y-config', overflowY);
|
|
2477
|
+
this._inputContainer.style.setProperty('--select-multi-input-flex-wrap-config', flexWrap);
|
|
2478
|
+
this._inputContainer.style.setProperty('--select-multi-input-align-content-config', alignContent);
|
|
2475
2479
|
}
|
|
2476
2480
|
_canUseHorizontalMultiScroll(target) {
|
|
2477
2481
|
if (this._config.selection.mode !== 'multi')
|
|
@@ -3099,14 +3103,14 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3099
3103
|
}
|
|
3100
3104
|
|
|
3101
3105
|
.input-container.input-container--multi {
|
|
3102
|
-
max-height: var(--select-multi-input-max-height, var(--select-input-max-height, 160px));
|
|
3106
|
+
max-height: var(--select-multi-input-max-height, var(--select-multi-input-max-height-config, var(--select-input-max-height, 160px)));
|
|
3103
3107
|
}
|
|
3104
3108
|
|
|
3105
3109
|
.input-container.input-container--multi .input-content {
|
|
3106
|
-
flex-wrap: var(--select-multi-input-flex-wrap, wrap);
|
|
3107
|
-
align-content: var(--select-multi-input-align-content, flex-start);
|
|
3108
|
-
overflow-x: var(--select-multi-input-overflow-x, hidden);
|
|
3109
|
-
overflow-y: var(--select-multi-input-overflow-y, auto);
|
|
3110
|
+
flex-wrap: var(--select-multi-input-flex-wrap, var(--select-multi-input-flex-wrap-config, wrap));
|
|
3111
|
+
align-content: var(--select-multi-input-align-content, var(--select-multi-input-align-content-config, flex-start));
|
|
3112
|
+
overflow-x: var(--select-multi-input-overflow-x, var(--select-multi-input-overflow-x-config, hidden));
|
|
3113
|
+
overflow-y: var(--select-multi-input-overflow-y, var(--select-multi-input-overflow-y-config, auto));
|
|
3110
3114
|
}
|
|
3111
3115
|
|
|
3112
3116
|
.input-container.input-container--multi::after {
|
|
@@ -3123,6 +3127,11 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3123
3127
|
cursor: var(--select-multi-input-horizontal-cursor, grab);
|
|
3124
3128
|
overflow-y: hidden;
|
|
3125
3129
|
overscroll-behavior-x: contain;
|
|
3130
|
+
padding-right: calc(var(--select-arrow-width, 42px) + var(--select-multi-horizontal-end-gap, 12px));
|
|
3131
|
+
}
|
|
3132
|
+
|
|
3133
|
+
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"].has-clear-control .input-content {
|
|
3134
|
+
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
3135
|
}
|
|
3127
3136
|
|
|
3128
3137
|
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"]::after {
|
|
@@ -3164,6 +3173,15 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3164
3173
|
left: var(--select-arrow-right-with-clear, 34px);
|
|
3165
3174
|
}
|
|
3166
3175
|
|
|
3176
|
+
:host([dir="rtl"]) .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .input-content {
|
|
3177
|
+
padding-right: 0;
|
|
3178
|
+
padding-left: calc(var(--select-arrow-width, 42px) + var(--select-multi-horizontal-end-gap, 12px));
|
|
3179
|
+
}
|
|
3180
|
+
|
|
3181
|
+
:host([dir="rtl"]) .input-container.input-container--multi[data-multi-scroll-mode="horizontal"].has-clear-control .input-content {
|
|
3182
|
+
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));
|
|
3183
|
+
}
|
|
3184
|
+
|
|
3167
3185
|
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .clear-control-button {
|
|
3168
3186
|
background: var(--select-multi-action-surface-bg, var(--select-input-bg, var(--select-surface)));
|
|
3169
3187
|
z-index: 4;
|
|
@@ -3517,8 +3535,10 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3517
3535
|
}
|
|
3518
3536
|
|
|
3519
3537
|
.group-header:not(:first-child) {
|
|
3520
|
-
margin-top:
|
|
3521
|
-
|
|
3538
|
+
margin-top: calc(
|
|
3539
|
+
var(--select-group-header-separator-margin-top, 0px) +
|
|
3540
|
+
var(--select-group-header-separator-padding-top, 0px)
|
|
3541
|
+
);
|
|
3522
3542
|
border-top: var(--select-group-header-separator-border-top);
|
|
3523
3543
|
}
|
|
3524
3544
|
|
|
@@ -3600,7 +3620,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3600
3620
|
color: var(--select-option-selected-hover-color, var(--select-option-selected-color, var(--select-accent)));
|
|
3601
3621
|
}
|
|
3602
3622
|
|
|
3603
|
-
.option.active:not(.selected) {
|
|
3623
|
+
.option.active:not(.selected):not(.disabled) {
|
|
3604
3624
|
background: var(--select-option-active-bg, var(--select-surface-elevated));
|
|
3605
3625
|
color: var(--select-option-active-color, var(--select-option-hover-color, var(--select-option-color, var(--select-text))));
|
|
3606
3626
|
border: var(--select-option-active-border, var(--select-option-hover-border, var(--select-option-border, none)));
|
|
@@ -3610,7 +3630,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3610
3630
|
transform: var(--select-option-active-transform, none);
|
|
3611
3631
|
}
|
|
3612
3632
|
|
|
3613
|
-
.option.selected.active {
|
|
3633
|
+
.option.selected.active:not(.disabled) {
|
|
3614
3634
|
outline: var(--select-option-selected-active-outline, 2px solid rgba(15, 52, 96, 0.4));
|
|
3615
3635
|
outline-offset: var(--select-option-selected-active-outline-offset);
|
|
3616
3636
|
}
|
|
@@ -3828,6 +3848,9 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3828
3848
|
|
|
3829
3849
|
--select-badge-bg: var(--select-dark-badge-bg, rgba(99, 102, 241, 0.2));
|
|
3830
3850
|
--select-badge-color: var(--select-dark-badge-color, #e0e7ff);
|
|
3851
|
+
--select-badge-border: var(--select-dark-badge-border, var(--select-badge-border, none));
|
|
3852
|
+
--select-badge-hover-border: var(--select-dark-badge-hover-border, var(--select-badge-hover-border, var(--select-badge-border, none)));
|
|
3853
|
+
--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))));
|
|
3831
3854
|
|
|
3832
3855
|
--select-group-header-bg: var(--select-group-header-dark-bg, #1a1a2e);
|
|
3833
3856
|
--select-group-header-color: var(--select-group-header-dark-color, #9ca3af);
|
|
@@ -3863,6 +3886,36 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3863
3886
|
border-color: var(--select-border);
|
|
3864
3887
|
}
|
|
3865
3888
|
|
|
3889
|
+
:host(.dark-mode) .input-container:hover,
|
|
3890
|
+
:host([dark-mode]) .input-container:hover,
|
|
3891
|
+
:host([darkmode]) .input-container:hover,
|
|
3892
|
+
:host([data-theme="dark"]) .input-container:hover,
|
|
3893
|
+
:host([theme="dark"]) .input-container:hover,
|
|
3894
|
+
:host-context(.dark-mode) .input-container:hover,
|
|
3895
|
+
:host-context(.dark) .input-container:hover,
|
|
3896
|
+
:host-context([dark-mode]) .input-container:hover,
|
|
3897
|
+
:host-context([darkmode]) .input-container:hover,
|
|
3898
|
+
:host-context([data-theme="dark"]) .input-container:hover,
|
|
3899
|
+
:host-context([theme="dark"]) .input-container:hover {
|
|
3900
|
+
border-color: var(--select-dark-input-hover-border, var(--select-input-hover-border, var(--select-dark-border-focus, var(--select-border-focus, #6366f1))));
|
|
3901
|
+
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)));
|
|
3902
|
+
}
|
|
3903
|
+
|
|
3904
|
+
:host(.dark-mode) .input-container:focus-within,
|
|
3905
|
+
:host([dark-mode]) .input-container:focus-within,
|
|
3906
|
+
:host([darkmode]) .input-container:focus-within,
|
|
3907
|
+
:host([data-theme="dark"]) .input-container:focus-within,
|
|
3908
|
+
:host([theme="dark"]) .input-container:focus-within,
|
|
3909
|
+
:host-context(.dark-mode) .input-container:focus-within,
|
|
3910
|
+
:host-context(.dark) .input-container:focus-within,
|
|
3911
|
+
:host-context([dark-mode]) .input-container:focus-within,
|
|
3912
|
+
:host-context([darkmode]) .input-container:focus-within,
|
|
3913
|
+
:host-context([data-theme="dark"]) .input-container:focus-within,
|
|
3914
|
+
:host-context([theme="dark"]) .input-container:focus-within {
|
|
3915
|
+
border-color: var(--select-dark-border-focus, var(--select-border-focus, #6366f1));
|
|
3916
|
+
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);
|
|
3917
|
+
}
|
|
3918
|
+
|
|
3866
3919
|
:host(.dark-mode) .input-container::after,
|
|
3867
3920
|
:host([dark-mode]) .input-container::after,
|
|
3868
3921
|
:host([darkmode]) .input-container::after,
|
|
@@ -3918,7 +3971,8 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3918
3971
|
:host-context([darkmode]) .selection-badge,
|
|
3919
3972
|
:host-context([data-theme="dark"]) .selection-badge,
|
|
3920
3973
|
:host-context([theme="dark"]) .selection-badge {
|
|
3921
|
-
background: var(--select-badge-dark-bg);
|
|
3974
|
+
background: var(--select-dark-badge-bg, var(--select-badge-bg, var(--select-badge-dark-bg)));
|
|
3975
|
+
color: var(--select-dark-badge-color, var(--select-badge-color, #e0e7ff));
|
|
3922
3976
|
}
|
|
3923
3977
|
|
|
3924
3978
|
:host(.dark-mode) .group-header:not(:first-child),
|
|
@@ -4099,6 +4153,10 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4099
4153
|
this._inputContent.addEventListener('wheel', (e) => {
|
|
4100
4154
|
if (this._config.selection.mode === 'multi'
|
|
4101
4155
|
&& (this._config.multiSelectDisplay?.mode ?? 'wrap') === 'horizontal') {
|
|
4156
|
+
const primaryDelta = Math.abs(e.deltaX) > Math.abs(e.deltaY) ? e.deltaX : e.deltaY;
|
|
4157
|
+
if (primaryDelta !== 0) {
|
|
4158
|
+
this._inputContent.scrollLeft += primaryDelta;
|
|
4159
|
+
}
|
|
4102
4160
|
e.preventDefault();
|
|
4103
4161
|
}
|
|
4104
4162
|
}, { passive: false });
|
|
@@ -4493,6 +4551,8 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4493
4551
|
}
|
|
4494
4552
|
}
|
|
4495
4553
|
_handleKeydown(e) {
|
|
4554
|
+
if (!this._config.enabled)
|
|
4555
|
+
return;
|
|
4496
4556
|
switch (e.key) {
|
|
4497
4557
|
case 'ArrowDown':
|
|
4498
4558
|
e.preventDefault();
|
|
@@ -4515,17 +4575,23 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4515
4575
|
case 'Home':
|
|
4516
4576
|
e.preventDefault();
|
|
4517
4577
|
if (this._state.isOpen) {
|
|
4518
|
-
this.
|
|
4578
|
+
const selectableIndices = this._getSelectableOptionIndices();
|
|
4579
|
+
const firstIndex = selectableIndices[0];
|
|
4580
|
+
if (firstIndex === undefined)
|
|
4581
|
+
break;
|
|
4582
|
+
this._setActive(firstIndex);
|
|
4519
4583
|
if (this._config.selection.mode === 'multi' && e.shiftKey) {
|
|
4520
|
-
this._selectRange(this._rangeAnchorIndex ??
|
|
4584
|
+
this._selectRange(this._rangeAnchorIndex ?? firstIndex, firstIndex, { clear: !(e.ctrlKey || e.metaKey) });
|
|
4521
4585
|
}
|
|
4522
4586
|
}
|
|
4523
4587
|
break;
|
|
4524
4588
|
case 'End':
|
|
4525
4589
|
e.preventDefault();
|
|
4526
4590
|
if (this._state.isOpen) {
|
|
4527
|
-
const
|
|
4528
|
-
const lastIndex =
|
|
4591
|
+
const selectableIndices = this._getSelectableOptionIndices();
|
|
4592
|
+
const lastIndex = selectableIndices[selectableIndices.length - 1];
|
|
4593
|
+
if (lastIndex === undefined)
|
|
4594
|
+
break;
|
|
4529
4595
|
this._setActive(lastIndex);
|
|
4530
4596
|
if (this._config.selection.mode === 'multi' && e.shiftKey) {
|
|
4531
4597
|
this._selectRange(this._rangeAnchorIndex ?? lastIndex, lastIndex, { clear: !(e.ctrlKey || e.metaKey) });
|
|
@@ -4579,8 +4645,17 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4579
4645
|
}
|
|
4580
4646
|
}
|
|
4581
4647
|
_moveActive(delta, opts) {
|
|
4582
|
-
const
|
|
4583
|
-
|
|
4648
|
+
const selectableIndices = this._getSelectableOptionIndices();
|
|
4649
|
+
if (selectableIndices.length === 0)
|
|
4650
|
+
return;
|
|
4651
|
+
const currentPosition = selectableIndices.indexOf(this._state.activeIndex);
|
|
4652
|
+
const basePosition = currentPosition >= 0
|
|
4653
|
+
? currentPosition
|
|
4654
|
+
: delta >= 0
|
|
4655
|
+
? -1
|
|
4656
|
+
: selectableIndices.length;
|
|
4657
|
+
const nextPosition = Math.max(0, Math.min(selectableIndices.length - 1, basePosition + delta));
|
|
4658
|
+
const next = selectableIndices[nextPosition];
|
|
4584
4659
|
this._setActive(next);
|
|
4585
4660
|
if (this._config.selection.mode === 'multi' && opts?.shiftKey) {
|
|
4586
4661
|
const anchor = this._rangeAnchorIndex ?? this._state.activeIndex;
|
|
@@ -4592,6 +4667,10 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4592
4667
|
}
|
|
4593
4668
|
}
|
|
4594
4669
|
_setActive(index) {
|
|
4670
|
+
const option = this._getOptionElementByIndex(index);
|
|
4671
|
+
if (!option || option.getAttribute('aria-disabled') === 'true') {
|
|
4672
|
+
return;
|
|
4673
|
+
}
|
|
4595
4674
|
// Clear previous active state
|
|
4596
4675
|
if (this._state.activeIndex >= 0) {
|
|
4597
4676
|
const prevOption = this._getOptionElementByIndex(this._state.activeIndex);
|
|
@@ -4608,7 +4687,6 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4608
4687
|
}
|
|
4609
4688
|
this._state.activeIndex = index;
|
|
4610
4689
|
// Set new active state
|
|
4611
|
-
const option = this._getOptionElementByIndex(index);
|
|
4612
4690
|
if (option) {
|
|
4613
4691
|
// Check if it's a custom SelectOption or a lightweight DOM element
|
|
4614
4692
|
if ('setActive' in option && typeof option.setActive === 'function') {
|
|
@@ -4637,9 +4715,15 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4637
4715
|
// Filter out group headers and other non-selectable elements
|
|
4638
4716
|
// Only return elements with data-index or data-sm-selectable attributes
|
|
4639
4717
|
return Array.from(this._optionsContainer.children).filter((child) => {
|
|
4640
|
-
return child.hasAttribute('data-index') || child.hasAttribute('data-sm-selectable')
|
|
4718
|
+
return (child.hasAttribute('data-index') || child.hasAttribute('data-sm-selectable'))
|
|
4719
|
+
&& child.getAttribute('aria-disabled') !== 'true';
|
|
4641
4720
|
});
|
|
4642
4721
|
}
|
|
4722
|
+
_getSelectableOptionIndices() {
|
|
4723
|
+
return this._getSelectableOptions()
|
|
4724
|
+
.map((option) => Number(option.getAttribute('data-sm-index') ?? option.getAttribute('data-index')))
|
|
4725
|
+
.filter((index) => Number.isFinite(index));
|
|
4726
|
+
}
|
|
4643
4727
|
_buildRendererHelpers() {
|
|
4644
4728
|
return {
|
|
4645
4729
|
onSelect: (_item, index) => this._selectOption(index),
|
|
@@ -4676,24 +4760,27 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4676
4760
|
return;
|
|
4677
4761
|
const options = this._getSelectableOptions();
|
|
4678
4762
|
const maxSelections = this._config.selection.maxSelections || 0;
|
|
4679
|
-
options.forEach((option
|
|
4763
|
+
options.forEach((option) => {
|
|
4764
|
+
const optionIndex = Number(option.getAttribute('data-sm-index') ?? option.getAttribute('data-index'));
|
|
4765
|
+
if (!Number.isFinite(optionIndex))
|
|
4766
|
+
return;
|
|
4680
4767
|
if (maxSelections > 0 && this._state.selectedIndices.size >= maxSelections) {
|
|
4681
4768
|
return;
|
|
4682
4769
|
}
|
|
4683
|
-
if (!this._state.selectedIndices.has(
|
|
4770
|
+
if (!this._state.selectedIndices.has(optionIndex)) {
|
|
4684
4771
|
// Check if it's a custom SelectOption or a lightweight DOM element
|
|
4685
4772
|
if ('getConfig' in option && typeof option.getConfig === 'function') {
|
|
4686
4773
|
const config = option.getConfig();
|
|
4687
|
-
this._state.selectedIndices.add(
|
|
4688
|
-
this._state.selectedItems.set(
|
|
4774
|
+
this._state.selectedIndices.add(optionIndex);
|
|
4775
|
+
this._state.selectedItems.set(optionIndex, config.item);
|
|
4689
4776
|
option.setSelected(true);
|
|
4690
4777
|
}
|
|
4691
4778
|
else {
|
|
4692
4779
|
// Lightweight option - get item from data attribute or state
|
|
4693
|
-
const item = this._state.loadedItems[
|
|
4780
|
+
const item = this._state.loadedItems[optionIndex];
|
|
4694
4781
|
if (item) {
|
|
4695
|
-
this._state.selectedIndices.add(
|
|
4696
|
-
this._state.selectedItems.set(
|
|
4782
|
+
this._state.selectedIndices.add(optionIndex);
|
|
4783
|
+
this._state.selectedItems.set(optionIndex, item);
|
|
4697
4784
|
option.classList.add('smilodon-option--selected');
|
|
4698
4785
|
option.setAttribute('aria-selected', 'true');
|
|
4699
4786
|
}
|
|
@@ -4717,6 +4804,9 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4717
4804
|
if (maxSelections > 0 && this._state.selectedIndices.size >= maxSelections)
|
|
4718
4805
|
break;
|
|
4719
4806
|
const item = this._state.loadedItems[i];
|
|
4807
|
+
const optionEl = this._getOptionElementByIndex(i);
|
|
4808
|
+
if (optionEl?.getAttribute('aria-disabled') === 'true')
|
|
4809
|
+
continue;
|
|
4720
4810
|
if (!item)
|
|
4721
4811
|
continue;
|
|
4722
4812
|
this._state.selectedIndices.add(i);
|
|
@@ -4728,8 +4818,8 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4728
4818
|
this._announce(`${this._state.selectedIndices.size} items selected`);
|
|
4729
4819
|
}
|
|
4730
4820
|
_setInitialActiveOption() {
|
|
4731
|
-
const
|
|
4732
|
-
if (
|
|
4821
|
+
const selectableIndices = this._getSelectableOptionIndices();
|
|
4822
|
+
if (selectableIndices.length === 0)
|
|
4733
4823
|
return;
|
|
4734
4824
|
const selected = Array.from(this._state.selectedIndices).sort((a, b) => a - b);
|
|
4735
4825
|
if (this._config.selection.mode === 'multi' && selected.length === 0) {
|
|
@@ -4737,8 +4827,8 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4737
4827
|
this._input.removeAttribute('aria-activedescendant');
|
|
4738
4828
|
return;
|
|
4739
4829
|
}
|
|
4740
|
-
const target = selected.
|
|
4741
|
-
this._setActive(
|
|
4830
|
+
const target = selected.find((index) => selectableIndices.includes(index)) ?? selectableIndices[0];
|
|
4831
|
+
this._setActive(target);
|
|
4742
4832
|
}
|
|
4743
4833
|
_announce(message) {
|
|
4744
4834
|
if (this._liveRegion) {
|