@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.umd.js
CHANGED
|
@@ -2610,14 +2610,13 @@
|
|
|
2610
2610
|
transition: var(--select-option-transition, background-color 0.2s ease);
|
|
2611
2611
|
}
|
|
2612
2612
|
|
|
2613
|
-
:host(:hover
|
|
2613
|
+
:host(:hover:not(.smilodon-option--disabled):not([aria-disabled="true"])),
|
|
2614
2614
|
:host(.smilodon-option--disabled-hoverable:hover) {
|
|
2615
2615
|
background: var(--select-option-hover-bg, #f0f0f0);
|
|
2616
2616
|
color: var(--select-option-hover-color, var(--select-option-color, var(--select-text-color, #1f2937)));
|
|
2617
|
-
|
|
2618
|
-
|
|
2617
|
+
outline: var(--select-option-hover-border, none);
|
|
2618
|
+
outline-offset: -1px;
|
|
2619
2619
|
box-shadow: var(--select-option-hover-shadow, var(--select-option-shadow, none));
|
|
2620
|
-
transform: var(--select-option-hover-transform, var(--select-option-transform, none));
|
|
2621
2620
|
}
|
|
2622
2621
|
|
|
2623
2622
|
/* Keep the visual surface on the host so external utility classes applied
|
|
@@ -2638,10 +2637,9 @@
|
|
|
2638
2637
|
:host(.smilodon-option--selected:hover) {
|
|
2639
2638
|
background: var(--select-option-selected-hover-bg, var(--select-option-selected-bg, #e3f2fd));
|
|
2640
2639
|
color: var(--select-option-selected-hover-color, var(--select-option-selected-color, #1976d2));
|
|
2641
|
-
|
|
2642
|
-
|
|
2640
|
+
outline: var(--select-option-selected-hover-border, var(--select-option-hover-border, none));
|
|
2641
|
+
outline-offset: -1px;
|
|
2643
2642
|
box-shadow: var(--select-option-selected-hover-shadow, var(--select-option-selected-shadow, var(--select-option-shadow, none)));
|
|
2644
|
-
transform: var(--select-option-selected-hover-transform, var(--select-option-selected-transform, var(--select-option-transform, none)));
|
|
2645
2643
|
}
|
|
2646
2644
|
|
|
2647
2645
|
:host(.smilodon-option--active):not(.smilodon-option--disabled):not([aria-disabled="true"]),
|
|
@@ -4123,6 +4121,7 @@
|
|
|
4123
4121
|
this._pendingSearchRenderMark = false;
|
|
4124
4122
|
this._rangeAnchorIndex = null;
|
|
4125
4123
|
this._customOptionBoundElements = new WeakSet();
|
|
4124
|
+
this._customOptionManagedActiveClasses = new WeakMap();
|
|
4126
4125
|
this._customOptionNormalizedIds = new WeakMap();
|
|
4127
4126
|
this._customOptionNormalizedLabels = new WeakMap();
|
|
4128
4127
|
this._mirrorGlobalStylesForCustomOptions = false;
|
|
@@ -5498,10 +5497,21 @@
|
|
|
5498
5497
|
const container = document.createElement('div');
|
|
5499
5498
|
container.className = 'dropdown-arrow-container';
|
|
5500
5499
|
container.innerHTML = `
|
|
5501
|
-
<
|
|
5502
|
-
<
|
|
5503
|
-
|
|
5500
|
+
<slot name="arrow">
|
|
5501
|
+
<svg class="dropdown-arrow" part="arrow" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
5502
|
+
<path d="M4 6L8 10L12 6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
5503
|
+
</svg>
|
|
5504
|
+
</slot>
|
|
5504
5505
|
`;
|
|
5506
|
+
const slot = container.querySelector('slot[name="arrow"]');
|
|
5507
|
+
slot?.addEventListener('slotchange', () => {
|
|
5508
|
+
if (slot.assignedElements({ flatten: true }).length > 0) {
|
|
5509
|
+
this.setAttribute('data-custom-arrow', 'true');
|
|
5510
|
+
}
|
|
5511
|
+
else {
|
|
5512
|
+
this.removeAttribute('data-custom-arrow');
|
|
5513
|
+
}
|
|
5514
|
+
});
|
|
5505
5515
|
return container;
|
|
5506
5516
|
}
|
|
5507
5517
|
_createClearControl() {
|
|
@@ -5657,7 +5667,7 @@
|
|
|
5657
5667
|
--select-scrollbar-width: 6px;
|
|
5658
5668
|
--select-scrollbar-thumb-radius: 3px;
|
|
5659
5669
|
--select-option-hover-enabled: 1;
|
|
5660
|
-
--select-option-hover-transform:
|
|
5670
|
+
--select-option-hover-transform: none;
|
|
5661
5671
|
--select-option-font-weight: 450;
|
|
5662
5672
|
--select-option-margin: 2px 0;
|
|
5663
5673
|
--select-input-font-size: inherit;
|
|
@@ -6216,6 +6226,10 @@
|
|
|
6216
6226
|
.dropdown-arrow-container:hover {
|
|
6217
6227
|
background-color: var(--select-arrow-hover-bg, rgba(15, 52, 96, 0.05));
|
|
6218
6228
|
}
|
|
6229
|
+
|
|
6230
|
+
:host([data-custom-arrow="true"]) .dropdown-arrow-container:hover {
|
|
6231
|
+
background-color: transparent;
|
|
6232
|
+
}
|
|
6219
6233
|
|
|
6220
6234
|
.dropdown-arrow {
|
|
6221
6235
|
width: var(--select-arrow-width, var(--select-arrow-size, 16px));
|
|
@@ -6437,8 +6451,7 @@
|
|
|
6437
6451
|
transition: var(--select-option-transition,
|
|
6438
6452
|
background var(--select-transition-fast),
|
|
6439
6453
|
color var(--select-transition-fast),
|
|
6440
|
-
|
|
6441
|
-
transform var(--select-transition-fast),
|
|
6454
|
+
outline-color var(--select-transition-fast),
|
|
6442
6455
|
box-shadow var(--select-transition-fast)
|
|
6443
6456
|
);
|
|
6444
6457
|
user-select: none;
|
|
@@ -6452,9 +6465,10 @@
|
|
|
6452
6465
|
.option:hover:not(.disabled):not(.smilodon-option--disabled),
|
|
6453
6466
|
.option.smilodon-option--disabled-hoverable:hover {
|
|
6454
6467
|
background: var(--select-option-hover-bg, var(--select-surface-elevated));
|
|
6455
|
-
|
|
6468
|
+
/* Hover decoration must not resize or translate the pointer hit target. */
|
|
6469
|
+
outline: var(--select-option-hover-border, none);
|
|
6470
|
+
outline-offset: -1px;
|
|
6456
6471
|
color: var(--select-option-hover-color, var(--select-text));
|
|
6457
|
-
transform: var(--select-option-hover-transform, none);
|
|
6458
6472
|
}
|
|
6459
6473
|
|
|
6460
6474
|
.option.selected {
|
|
@@ -6497,7 +6511,8 @@
|
|
|
6497
6511
|
|
|
6498
6512
|
.option.selected:hover {
|
|
6499
6513
|
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%)));
|
|
6500
|
-
|
|
6514
|
+
outline: var(--select-option-selected-hover-border, var(--select-option-hover-border, none));
|
|
6515
|
+
outline-offset: -1px;
|
|
6501
6516
|
color: var(--select-option-selected-hover-color, var(--select-option-selected-color, var(--select-accent)));
|
|
6502
6517
|
}
|
|
6503
6518
|
|
|
@@ -7783,8 +7798,7 @@
|
|
|
7783
7798
|
prevOption.setActive(false);
|
|
7784
7799
|
}
|
|
7785
7800
|
else {
|
|
7786
|
-
|
|
7787
|
-
prevOption.classList.remove('active', 'smilodon-option--active');
|
|
7801
|
+
this._syncCustomOptionActiveClasses(prevOption, false);
|
|
7788
7802
|
}
|
|
7789
7803
|
}
|
|
7790
7804
|
}
|
|
@@ -7795,8 +7809,7 @@
|
|
|
7795
7809
|
option.setActive(true);
|
|
7796
7810
|
}
|
|
7797
7811
|
else {
|
|
7798
|
-
|
|
7799
|
-
option.classList.add('active', 'smilodon-option--active');
|
|
7812
|
+
this._syncCustomOptionActiveClasses(option, true);
|
|
7800
7813
|
}
|
|
7801
7814
|
if (typeof option.scrollIntoView === 'function') {
|
|
7802
7815
|
// Don't scroll wildly when just opening with pre-selections
|
|
@@ -7927,7 +7940,9 @@
|
|
|
7927
7940
|
_setInitialActiveOption() {
|
|
7928
7941
|
const selectableIndices = this._getSelectableOptionIndices();
|
|
7929
7942
|
const selected = Array.from(this._state.selectedIndices).sort((a, b) => a - b);
|
|
7930
|
-
|
|
7943
|
+
// Opening an empty select must not implicitly assign an active descendant.
|
|
7944
|
+
// Keyboard navigation and pointer interaction establish active identity.
|
|
7945
|
+
if (selectableIndices.length === 0 || selected.length === 0) {
|
|
7931
7946
|
this._dispatchActiveKey(null, 'open', 'initial active option');
|
|
7932
7947
|
return;
|
|
7933
7948
|
}
|
|
@@ -10289,6 +10304,26 @@
|
|
|
10289
10304
|
option.ensureRendered();
|
|
10290
10305
|
}
|
|
10291
10306
|
}
|
|
10307
|
+
/** Keep custom option active classes aligned with the engine, including previous class maps. */
|
|
10308
|
+
_syncCustomOptionActiveClasses(option, active) {
|
|
10309
|
+
const mapped = (this.classMap?.active ?? 'active sm-active').split(/\s+/).filter(Boolean);
|
|
10310
|
+
const styled = (this._config.styles.classNames?.activeOption ?? '').split(/\s+/).filter(Boolean);
|
|
10311
|
+
const current = [...new Set([...mapped, ...styled, 'smilodon-option--active'])];
|
|
10312
|
+
const previous = this._customOptionManagedActiveClasses.get(option) ?? [];
|
|
10313
|
+
option.classList.remove(...new Set([...previous, ...current, 'active', 'sm-active', 'smilodon-option--active']));
|
|
10314
|
+
if (active)
|
|
10315
|
+
option.classList.add(...current);
|
|
10316
|
+
this._customOptionManagedActiveClasses.set(option, current);
|
|
10317
|
+
const states = new Set((option.dataset.smState ?? '').split(/\s+/).filter(Boolean));
|
|
10318
|
+
if (active)
|
|
10319
|
+
states.add('active');
|
|
10320
|
+
else
|
|
10321
|
+
states.delete('active');
|
|
10322
|
+
if (states.size)
|
|
10323
|
+
option.dataset.smState = [...states].join(' ');
|
|
10324
|
+
else
|
|
10325
|
+
delete option.dataset.smState;
|
|
10326
|
+
}
|
|
10292
10327
|
_normalizeCustomOptionElement(element, meta) {
|
|
10293
10328
|
const optionEl = element instanceof HTMLElement ? element : document.createElement('div');
|
|
10294
10329
|
// Add part attribute for styling
|
|
@@ -10310,7 +10345,6 @@
|
|
|
10310
10345
|
const isDisabledInteractive = isDisabled && (isDisabledSelectable || isDisabledHoverable);
|
|
10311
10346
|
// Resolve classes from classMap or defaults
|
|
10312
10347
|
const selectedClasses = (this.classMap?.selected ?? 'selected sm-selected').split(' ').filter(Boolean);
|
|
10313
|
-
const activeClasses = (this.classMap?.active ?? 'active sm-active').split(' ').filter(Boolean);
|
|
10314
10348
|
const disabledClasses = (this.classMap?.disabled ?? 'disabled sm-disabled').split(' ').filter(Boolean);
|
|
10315
10349
|
if (isSelected) {
|
|
10316
10350
|
optionEl.classList.add(...selectedClasses);
|
|
@@ -10326,20 +10360,7 @@
|
|
|
10326
10360
|
optionEl.classList.remove(...this._config.styles.classNames.selectedOption.split(' ').filter(Boolean));
|
|
10327
10361
|
}
|
|
10328
10362
|
}
|
|
10329
|
-
|
|
10330
|
-
optionEl.classList.add(...activeClasses);
|
|
10331
|
-
optionEl.classList.add('smilodon-option--active');
|
|
10332
|
-
if (this._config.styles.classNames?.activeOption) {
|
|
10333
|
-
optionEl.classList.add(...this._config.styles.classNames.activeOption.split(' ').filter(Boolean));
|
|
10334
|
-
}
|
|
10335
|
-
}
|
|
10336
|
-
else {
|
|
10337
|
-
optionEl.classList.remove(...activeClasses);
|
|
10338
|
-
optionEl.classList.remove('smilodon-option--active');
|
|
10339
|
-
if (this._config.styles.classNames?.activeOption) {
|
|
10340
|
-
optionEl.classList.remove(...this._config.styles.classNames.activeOption.split(' ').filter(Boolean));
|
|
10341
|
-
}
|
|
10342
|
-
}
|
|
10363
|
+
this._syncCustomOptionActiveClasses(optionEl, isActive);
|
|
10343
10364
|
if (isDisabled) {
|
|
10344
10365
|
optionEl.classList.add(...disabledClasses);
|
|
10345
10366
|
optionEl.classList.add('smilodon-option--disabled');
|