@smilodon/core 1.10.2 → 1.11.1
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 +28 -0
- package/dist/index.cjs +57 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +57 -36
- 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 +57 -36
- 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 +3 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2604,14 +2604,13 @@ class SelectOption extends HTMLElement {
|
|
|
2604
2604
|
transition: var(--select-option-transition, background-color 0.2s ease);
|
|
2605
2605
|
}
|
|
2606
2606
|
|
|
2607
|
-
:host(:hover
|
|
2607
|
+
:host(:hover:not(.smilodon-option--disabled):not([aria-disabled="true"])),
|
|
2608
2608
|
:host(.smilodon-option--disabled-hoverable:hover) {
|
|
2609
2609
|
background: var(--select-option-hover-bg, #f0f0f0);
|
|
2610
2610
|
color: var(--select-option-hover-color, var(--select-option-color, var(--select-text-color, #1f2937)));
|
|
2611
|
-
|
|
2612
|
-
|
|
2611
|
+
outline: var(--select-option-hover-border, none);
|
|
2612
|
+
outline-offset: -1px;
|
|
2613
2613
|
box-shadow: var(--select-option-hover-shadow, var(--select-option-shadow, none));
|
|
2614
|
-
transform: var(--select-option-hover-transform, var(--select-option-transform, none));
|
|
2615
2614
|
}
|
|
2616
2615
|
|
|
2617
2616
|
/* Keep the visual surface on the host so external utility classes applied
|
|
@@ -2632,10 +2631,9 @@ class SelectOption extends HTMLElement {
|
|
|
2632
2631
|
:host(.smilodon-option--selected:hover) {
|
|
2633
2632
|
background: var(--select-option-selected-hover-bg, var(--select-option-selected-bg, #e3f2fd));
|
|
2634
2633
|
color: var(--select-option-selected-hover-color, var(--select-option-selected-color, #1976d2));
|
|
2635
|
-
|
|
2636
|
-
|
|
2634
|
+
outline: var(--select-option-selected-hover-border, var(--select-option-hover-border, none));
|
|
2635
|
+
outline-offset: -1px;
|
|
2637
2636
|
box-shadow: var(--select-option-selected-hover-shadow, var(--select-option-selected-shadow, var(--select-option-shadow, none)));
|
|
2638
|
-
transform: var(--select-option-selected-hover-transform, var(--select-option-selected-transform, var(--select-option-transform, none)));
|
|
2639
2637
|
}
|
|
2640
2638
|
|
|
2641
2639
|
:host(.smilodon-option--active):not(.smilodon-option--disabled):not([aria-disabled="true"]),
|
|
@@ -4117,6 +4115,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4117
4115
|
this._pendingSearchRenderMark = false;
|
|
4118
4116
|
this._rangeAnchorIndex = null;
|
|
4119
4117
|
this._customOptionBoundElements = new WeakSet();
|
|
4118
|
+
this._customOptionManagedActiveClasses = new WeakMap();
|
|
4120
4119
|
this._customOptionNormalizedIds = new WeakMap();
|
|
4121
4120
|
this._customOptionNormalizedLabels = new WeakMap();
|
|
4122
4121
|
this._mirrorGlobalStylesForCustomOptions = false;
|
|
@@ -5492,10 +5491,21 @@ class EnhancedSelect extends HTMLElement {
|
|
|
5492
5491
|
const container = document.createElement('div');
|
|
5493
5492
|
container.className = 'dropdown-arrow-container';
|
|
5494
5493
|
container.innerHTML = `
|
|
5495
|
-
<
|
|
5496
|
-
<
|
|
5497
|
-
|
|
5494
|
+
<slot name="arrow">
|
|
5495
|
+
<svg class="dropdown-arrow" part="arrow" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
5496
|
+
<path d="M4 6L8 10L12 6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
5497
|
+
</svg>
|
|
5498
|
+
</slot>
|
|
5498
5499
|
`;
|
|
5500
|
+
const slot = container.querySelector('slot[name="arrow"]');
|
|
5501
|
+
slot?.addEventListener('slotchange', () => {
|
|
5502
|
+
if (slot.assignedElements({ flatten: true }).length > 0) {
|
|
5503
|
+
this.setAttribute('data-custom-arrow', 'true');
|
|
5504
|
+
}
|
|
5505
|
+
else {
|
|
5506
|
+
this.removeAttribute('data-custom-arrow');
|
|
5507
|
+
}
|
|
5508
|
+
});
|
|
5499
5509
|
return container;
|
|
5500
5510
|
}
|
|
5501
5511
|
_createClearControl() {
|
|
@@ -5651,7 +5661,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
5651
5661
|
--select-scrollbar-width: 6px;
|
|
5652
5662
|
--select-scrollbar-thumb-radius: 3px;
|
|
5653
5663
|
--select-option-hover-enabled: 1;
|
|
5654
|
-
--select-option-hover-transform:
|
|
5664
|
+
--select-option-hover-transform: none;
|
|
5655
5665
|
--select-option-font-weight: 450;
|
|
5656
5666
|
--select-option-margin: 2px 0;
|
|
5657
5667
|
--select-input-font-size: inherit;
|
|
@@ -6210,6 +6220,10 @@ class EnhancedSelect extends HTMLElement {
|
|
|
6210
6220
|
.dropdown-arrow-container:hover {
|
|
6211
6221
|
background-color: var(--select-arrow-hover-bg, rgba(15, 52, 96, 0.05));
|
|
6212
6222
|
}
|
|
6223
|
+
|
|
6224
|
+
:host([data-custom-arrow="true"]) .dropdown-arrow-container:hover {
|
|
6225
|
+
background-color: transparent;
|
|
6226
|
+
}
|
|
6213
6227
|
|
|
6214
6228
|
.dropdown-arrow {
|
|
6215
6229
|
width: var(--select-arrow-width, var(--select-arrow-size, 16px));
|
|
@@ -6431,8 +6445,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
6431
6445
|
transition: var(--select-option-transition,
|
|
6432
6446
|
background var(--select-transition-fast),
|
|
6433
6447
|
color var(--select-transition-fast),
|
|
6434
|
-
|
|
6435
|
-
transform var(--select-transition-fast),
|
|
6448
|
+
outline-color var(--select-transition-fast),
|
|
6436
6449
|
box-shadow var(--select-transition-fast)
|
|
6437
6450
|
);
|
|
6438
6451
|
user-select: none;
|
|
@@ -6446,9 +6459,10 @@ class EnhancedSelect extends HTMLElement {
|
|
|
6446
6459
|
.option:hover:not(.disabled):not(.smilodon-option--disabled),
|
|
6447
6460
|
.option.smilodon-option--disabled-hoverable:hover {
|
|
6448
6461
|
background: var(--select-option-hover-bg, var(--select-surface-elevated));
|
|
6449
|
-
|
|
6462
|
+
/* Hover decoration must not resize or translate the pointer hit target. */
|
|
6463
|
+
outline: var(--select-option-hover-border, none);
|
|
6464
|
+
outline-offset: -1px;
|
|
6450
6465
|
color: var(--select-option-hover-color, var(--select-text));
|
|
6451
|
-
transform: var(--select-option-hover-transform, none);
|
|
6452
6466
|
}
|
|
6453
6467
|
|
|
6454
6468
|
.option.selected {
|
|
@@ -6491,7 +6505,8 @@ class EnhancedSelect extends HTMLElement {
|
|
|
6491
6505
|
|
|
6492
6506
|
.option.selected:hover {
|
|
6493
6507
|
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%)));
|
|
6494
|
-
|
|
6508
|
+
outline: var(--select-option-selected-hover-border, var(--select-option-hover-border, none));
|
|
6509
|
+
outline-offset: -1px;
|
|
6495
6510
|
color: var(--select-option-selected-hover-color, var(--select-option-selected-color, var(--select-accent)));
|
|
6496
6511
|
}
|
|
6497
6512
|
|
|
@@ -7777,8 +7792,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
7777
7792
|
prevOption.setActive(false);
|
|
7778
7793
|
}
|
|
7779
7794
|
else {
|
|
7780
|
-
|
|
7781
|
-
prevOption.classList.remove('active', 'smilodon-option--active');
|
|
7795
|
+
this._syncCustomOptionActiveClasses(prevOption, false);
|
|
7782
7796
|
}
|
|
7783
7797
|
}
|
|
7784
7798
|
}
|
|
@@ -7789,8 +7803,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
7789
7803
|
option.setActive(true);
|
|
7790
7804
|
}
|
|
7791
7805
|
else {
|
|
7792
|
-
|
|
7793
|
-
option.classList.add('active', 'smilodon-option--active');
|
|
7806
|
+
this._syncCustomOptionActiveClasses(option, true);
|
|
7794
7807
|
}
|
|
7795
7808
|
if (typeof option.scrollIntoView === 'function') {
|
|
7796
7809
|
// Don't scroll wildly when just opening with pre-selections
|
|
@@ -7921,7 +7934,9 @@ class EnhancedSelect extends HTMLElement {
|
|
|
7921
7934
|
_setInitialActiveOption() {
|
|
7922
7935
|
const selectableIndices = this._getSelectableOptionIndices();
|
|
7923
7936
|
const selected = Array.from(this._state.selectedIndices).sort((a, b) => a - b);
|
|
7924
|
-
|
|
7937
|
+
// Opening an empty select must not implicitly assign an active descendant.
|
|
7938
|
+
// Keyboard navigation and pointer interaction establish active identity.
|
|
7939
|
+
if (selectableIndices.length === 0 || selected.length === 0) {
|
|
7925
7940
|
this._dispatchActiveKey(null, 'open', 'initial active option');
|
|
7926
7941
|
return;
|
|
7927
7942
|
}
|
|
@@ -10283,6 +10298,26 @@ class EnhancedSelect extends HTMLElement {
|
|
|
10283
10298
|
option.ensureRendered();
|
|
10284
10299
|
}
|
|
10285
10300
|
}
|
|
10301
|
+
/** Keep custom option active classes aligned with the engine, including previous class maps. */
|
|
10302
|
+
_syncCustomOptionActiveClasses(option, active) {
|
|
10303
|
+
const mapped = (this.classMap?.active ?? 'active sm-active').split(/\s+/).filter(Boolean);
|
|
10304
|
+
const styled = (this._config.styles.classNames?.activeOption ?? '').split(/\s+/).filter(Boolean);
|
|
10305
|
+
const current = [...new Set([...mapped, ...styled, 'smilodon-option--active'])];
|
|
10306
|
+
const previous = this._customOptionManagedActiveClasses.get(option) ?? [];
|
|
10307
|
+
option.classList.remove(...new Set([...previous, ...current, 'active', 'sm-active', 'smilodon-option--active']));
|
|
10308
|
+
if (active)
|
|
10309
|
+
option.classList.add(...current);
|
|
10310
|
+
this._customOptionManagedActiveClasses.set(option, current);
|
|
10311
|
+
const states = new Set((option.dataset.smState ?? '').split(/\s+/).filter(Boolean));
|
|
10312
|
+
if (active)
|
|
10313
|
+
states.add('active');
|
|
10314
|
+
else
|
|
10315
|
+
states.delete('active');
|
|
10316
|
+
if (states.size)
|
|
10317
|
+
option.dataset.smState = [...states].join(' ');
|
|
10318
|
+
else
|
|
10319
|
+
delete option.dataset.smState;
|
|
10320
|
+
}
|
|
10286
10321
|
_normalizeCustomOptionElement(element, meta) {
|
|
10287
10322
|
const optionEl = element instanceof HTMLElement ? element : document.createElement('div');
|
|
10288
10323
|
// Add part attribute for styling
|
|
@@ -10304,7 +10339,6 @@ class EnhancedSelect extends HTMLElement {
|
|
|
10304
10339
|
const isDisabledInteractive = isDisabled && (isDisabledSelectable || isDisabledHoverable);
|
|
10305
10340
|
// Resolve classes from classMap or defaults
|
|
10306
10341
|
const selectedClasses = (this.classMap?.selected ?? 'selected sm-selected').split(' ').filter(Boolean);
|
|
10307
|
-
const activeClasses = (this.classMap?.active ?? 'active sm-active').split(' ').filter(Boolean);
|
|
10308
10342
|
const disabledClasses = (this.classMap?.disabled ?? 'disabled sm-disabled').split(' ').filter(Boolean);
|
|
10309
10343
|
if (isSelected) {
|
|
10310
10344
|
optionEl.classList.add(...selectedClasses);
|
|
@@ -10320,20 +10354,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
10320
10354
|
optionEl.classList.remove(...this._config.styles.classNames.selectedOption.split(' ').filter(Boolean));
|
|
10321
10355
|
}
|
|
10322
10356
|
}
|
|
10323
|
-
|
|
10324
|
-
optionEl.classList.add(...activeClasses);
|
|
10325
|
-
optionEl.classList.add('smilodon-option--active');
|
|
10326
|
-
if (this._config.styles.classNames?.activeOption) {
|
|
10327
|
-
optionEl.classList.add(...this._config.styles.classNames.activeOption.split(' ').filter(Boolean));
|
|
10328
|
-
}
|
|
10329
|
-
}
|
|
10330
|
-
else {
|
|
10331
|
-
optionEl.classList.remove(...activeClasses);
|
|
10332
|
-
optionEl.classList.remove('smilodon-option--active');
|
|
10333
|
-
if (this._config.styles.classNames?.activeOption) {
|
|
10334
|
-
optionEl.classList.remove(...this._config.styles.classNames.activeOption.split(' ').filter(Boolean));
|
|
10335
|
-
}
|
|
10336
|
-
}
|
|
10357
|
+
this._syncCustomOptionActiveClasses(optionEl, isActive);
|
|
10337
10358
|
if (isDisabled) {
|
|
10338
10359
|
optionEl.classList.add(...disabledClasses);
|
|
10339
10360
|
optionEl.classList.add('smilodon-option--disabled');
|