@smilodon/core 1.5.4 → 1.6.0-debug.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 +146 -8
- package/dist/index.cjs +532 -117
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +532 -117
- 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 +532 -117
- 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 +16 -0
- package/dist/types/src/components/select-option.d.ts +5 -0
- package/dist/types/src/config/global-config.d.ts +17 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1348,8 +1348,14 @@ const defaultConfig = {
|
|
|
1348
1348
|
selection: {
|
|
1349
1349
|
mode: 'single',
|
|
1350
1350
|
allowDeselect: false,
|
|
1351
|
+
disabledOptionBehavior: {
|
|
1352
|
+
selectable: false,
|
|
1353
|
+
hoverable: false,
|
|
1354
|
+
focusable: false,
|
|
1355
|
+
},
|
|
1351
1356
|
maxSelections: 0,
|
|
1352
1357
|
showRemoveButton: true,
|
|
1358
|
+
showSelectedIndicator: true,
|
|
1353
1359
|
removeButtonIcon: '×',
|
|
1354
1360
|
closeOnSelect: true,
|
|
1355
1361
|
toggleOnTriggerClick: true,
|
|
@@ -1526,53 +1532,18 @@ class SelectOption extends HTMLElement {
|
|
|
1526
1532
|
display: block;
|
|
1527
1533
|
position: relative;
|
|
1528
1534
|
font: inherit;
|
|
1529
|
-
color: inherit;
|
|
1530
|
-
}
|
|
1531
|
-
|
|
1532
|
-
/* Allow authors to style selected state from outside the shadow root
|
|
1533
|
-
by setting attributes/classes on the host element. This mirrors the
|
|
1534
|
-
internal .option-container.selected rules but reads the same CSS
|
|
1535
|
-
custom properties so themes can fully control selected appearance. */
|
|
1536
|
-
:host([aria-selected="true"]) .option-container,
|
|
1537
|
-
:host(.smilodon-option--selected) .option-container {
|
|
1538
|
-
background: var(--select-option-selected-bg, #e3f2fd);
|
|
1539
|
-
color: var(--select-option-selected-color, #1976d2);
|
|
1540
|
-
border: var(--select-option-selected-border, var(--select-option-border, none));
|
|
1541
|
-
border-bottom: var(--select-option-selected-border-bottom, var(--select-option-border-bottom, none));
|
|
1542
|
-
border-radius: var(--select-option-selected-border-radius, var(--select-option-border-radius, 0));
|
|
1543
|
-
box-shadow: var(--select-option-selected-shadow, var(--select-option-shadow, none));
|
|
1544
|
-
transform: var(--select-option-selected-transform, var(--select-option-transform, none));
|
|
1545
|
-
}
|
|
1546
|
-
|
|
1547
|
-
:host([aria-selected="true"]) .option-container:hover,
|
|
1548
|
-
:host(.smilodon-option--selected) .option-container:hover {
|
|
1549
|
-
background: var(--select-option-selected-hover-bg, var(--select-option-selected-bg, #e3f2fd));
|
|
1550
|
-
color: var(--select-option-selected-hover-color, var(--select-option-selected-color, #1976d2));
|
|
1551
|
-
border: var(--select-option-selected-hover-border, var(--select-option-selected-border, var(--select-option-border, none)));
|
|
1552
|
-
border-bottom: var(--select-option-selected-hover-border-bottom, var(--select-option-selected-border-bottom, var(--select-option-border-bottom, none)));
|
|
1553
|
-
box-shadow: var(--select-option-selected-hover-shadow, var(--select-option-selected-shadow, var(--select-option-shadow, none)));
|
|
1554
|
-
transform: var(--select-option-selected-hover-transform, var(--select-option-selected-transform, var(--select-option-transform, none)));
|
|
1555
|
-
}
|
|
1556
|
-
|
|
1557
|
-
.option-container {
|
|
1558
|
-
display: flex;
|
|
1559
|
-
align-items: center;
|
|
1560
|
-
justify-content: space-between;
|
|
1561
|
-
padding: var(--select-option-padding, 10px 14px);
|
|
1562
|
-
cursor: pointer;
|
|
1563
|
-
user-select: none;
|
|
1564
1535
|
color: var(--select-option-color, var(--select-text-color, #1f2937));
|
|
1565
1536
|
background: var(--select-option-bg, var(--select-dropdown-bg, var(--select-bg, white)));
|
|
1566
|
-
transition: var(--select-option-transition, background-color 0.2s ease);
|
|
1567
1537
|
border: var(--select-option-border, none);
|
|
1568
1538
|
border-bottom: var(--select-option-border-bottom, none);
|
|
1569
1539
|
border-radius: var(--select-option-border-radius, var(--select-radius-sm, 6px));
|
|
1570
1540
|
box-shadow: var(--select-option-shadow, none);
|
|
1571
1541
|
transform: var(--select-option-transform, none);
|
|
1572
|
-
|
|
1542
|
+
transition: var(--select-option-transition, background-color 0.2s ease);
|
|
1573
1543
|
}
|
|
1574
|
-
|
|
1575
|
-
.option-
|
|
1544
|
+
|
|
1545
|
+
:host(:hover):not(.smilodon-option--disabled):not([aria-disabled="true"]),
|
|
1546
|
+
:host(.smilodon-option--disabled-hoverable:hover) {
|
|
1576
1547
|
background: var(--select-option-hover-bg, #f0f0f0);
|
|
1577
1548
|
color: var(--select-option-hover-color, var(--select-option-color, var(--select-text-color, #1f2937)));
|
|
1578
1549
|
border: var(--select-option-hover-border, var(--select-option-border, none));
|
|
@@ -1580,8 +1551,12 @@ class SelectOption extends HTMLElement {
|
|
|
1580
1551
|
box-shadow: var(--select-option-hover-shadow, var(--select-option-shadow, none));
|
|
1581
1552
|
transform: var(--select-option-hover-transform, var(--select-option-transform, none));
|
|
1582
1553
|
}
|
|
1583
|
-
|
|
1584
|
-
|
|
1554
|
+
|
|
1555
|
+
/* Keep the visual surface on the host so external utility classes applied
|
|
1556
|
+
through classMap can override selected/active/disabled styles in both
|
|
1557
|
+
light and dark themes. */
|
|
1558
|
+
:host([aria-selected="true"]),
|
|
1559
|
+
:host(.smilodon-option--selected) {
|
|
1585
1560
|
background: var(--select-option-selected-bg, #e3f2fd);
|
|
1586
1561
|
color: var(--select-option-selected-color, #1976d2);
|
|
1587
1562
|
border: var(--select-option-selected-border, var(--select-option-border, none));
|
|
@@ -1591,7 +1566,8 @@ class SelectOption extends HTMLElement {
|
|
|
1591
1566
|
transform: var(--select-option-selected-transform, var(--select-option-transform, none));
|
|
1592
1567
|
}
|
|
1593
1568
|
|
|
1594
|
-
|
|
1569
|
+
:host([aria-selected="true"]:hover),
|
|
1570
|
+
:host(.smilodon-option--selected:hover) {
|
|
1595
1571
|
background: var(--select-option-selected-hover-bg, var(--select-option-selected-bg, #e3f2fd));
|
|
1596
1572
|
color: var(--select-option-selected-hover-color, var(--select-option-selected-color, #1976d2));
|
|
1597
1573
|
border: var(--select-option-selected-hover-border, var(--select-option-selected-border, var(--select-option-border, none)));
|
|
@@ -1599,18 +1575,20 @@ class SelectOption extends HTMLElement {
|
|
|
1599
1575
|
box-shadow: var(--select-option-selected-hover-shadow, var(--select-option-selected-shadow, var(--select-option-shadow, none)));
|
|
1600
1576
|
transform: var(--select-option-selected-hover-transform, var(--select-option-selected-transform, var(--select-option-transform, none)));
|
|
1601
1577
|
}
|
|
1602
|
-
|
|
1603
|
-
.option
|
|
1578
|
+
|
|
1579
|
+
:host(.smilodon-option--active):not(.smilodon-option--disabled):not([aria-disabled="true"]),
|
|
1580
|
+
:host(.smilodon-option--active.smilodon-option--disabled-focusable) {
|
|
1604
1581
|
background: var(--select-option-active-bg, var(--select-option-hover-bg, #f0f0f0));
|
|
1605
1582
|
color: var(--select-option-active-color, var(--select-option-hover-color, var(--select-option-color, var(--select-text-color, #1f2937))));
|
|
1606
1583
|
border: var(--select-option-active-border, var(--select-option-hover-border, var(--select-option-border, none)));
|
|
1607
1584
|
box-shadow: var(--select-option-active-shadow, var(--select-option-shadow, none));
|
|
1608
1585
|
transform: var(--select-option-active-transform, var(--select-option-transform, none));
|
|
1609
|
-
outline: var(--select-option-active-outline,
|
|
1586
|
+
outline: var(--select-option-active-outline, none);
|
|
1610
1587
|
outline-offset: var(--select-option-active-outline-offset, -2px);
|
|
1611
1588
|
}
|
|
1612
|
-
|
|
1613
|
-
.option
|
|
1589
|
+
|
|
1590
|
+
:host(.smilodon-option--disabled),
|
|
1591
|
+
:host([aria-disabled="true"]) {
|
|
1614
1592
|
background: var(--select-option-disabled-bg, var(--select-option-bg, var(--select-dropdown-bg, var(--select-bg, white))));
|
|
1615
1593
|
color: var(--select-option-disabled-color, var(--select-option-color, var(--select-text-color, #1f2937)));
|
|
1616
1594
|
border: var(--select-option-disabled-border, var(--select-option-border, none));
|
|
@@ -1619,6 +1597,76 @@ class SelectOption extends HTMLElement {
|
|
|
1619
1597
|
cursor: var(--select-option-disabled-cursor, not-allowed);
|
|
1620
1598
|
pointer-events: none;
|
|
1621
1599
|
}
|
|
1600
|
+
|
|
1601
|
+
:host(.smilodon-option--disabled-interactive) {
|
|
1602
|
+
pointer-events: auto;
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
.option-container {
|
|
1606
|
+
display: flex;
|
|
1607
|
+
align-items: center;
|
|
1608
|
+
justify-content: space-between;
|
|
1609
|
+
padding: var(--select-option-padding, 10px 14px);
|
|
1610
|
+
cursor: pointer;
|
|
1611
|
+
user-select: none;
|
|
1612
|
+
color: inherit;
|
|
1613
|
+
background: inherit;
|
|
1614
|
+
transition: inherit;
|
|
1615
|
+
border: inherit;
|
|
1616
|
+
border-bottom: inherit;
|
|
1617
|
+
border-radius: inherit;
|
|
1618
|
+
box-shadow: inherit;
|
|
1619
|
+
transform: inherit;
|
|
1620
|
+
font: inherit;
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
.option-container:hover {
|
|
1624
|
+
background: inherit;
|
|
1625
|
+
color: inherit;
|
|
1626
|
+
border: inherit;
|
|
1627
|
+
border-bottom: inherit;
|
|
1628
|
+
box-shadow: inherit;
|
|
1629
|
+
transform: inherit;
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1632
|
+
.option-container.selected {
|
|
1633
|
+
background: inherit;
|
|
1634
|
+
color: inherit;
|
|
1635
|
+
border: inherit;
|
|
1636
|
+
border-bottom: inherit;
|
|
1637
|
+
border-radius: inherit;
|
|
1638
|
+
box-shadow: inherit;
|
|
1639
|
+
transform: inherit;
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
.option-container.selected:hover {
|
|
1643
|
+
background: inherit;
|
|
1644
|
+
color: inherit;
|
|
1645
|
+
border: inherit;
|
|
1646
|
+
border-bottom: inherit;
|
|
1647
|
+
box-shadow: inherit;
|
|
1648
|
+
transform: inherit;
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
.option-container.active:not(.disabled) {
|
|
1652
|
+
background: inherit;
|
|
1653
|
+
color: inherit;
|
|
1654
|
+
border: inherit;
|
|
1655
|
+
box-shadow: inherit;
|
|
1656
|
+
transform: inherit;
|
|
1657
|
+
outline: none;
|
|
1658
|
+
outline-offset: 0;
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
.option-container.disabled {
|
|
1662
|
+
background: inherit;
|
|
1663
|
+
color: inherit;
|
|
1664
|
+
border: inherit;
|
|
1665
|
+
border-bottom: inherit;
|
|
1666
|
+
opacity: inherit;
|
|
1667
|
+
cursor: inherit;
|
|
1668
|
+
pointer-events: none;
|
|
1669
|
+
}
|
|
1622
1670
|
|
|
1623
1671
|
.option-content {
|
|
1624
1672
|
flex: 1;
|
|
@@ -1677,6 +1725,11 @@ class SelectOption extends HTMLElement {
|
|
|
1677
1725
|
justify-content: center;
|
|
1678
1726
|
width: var(--select-badge-remove-icon-size, 10px);
|
|
1679
1727
|
height: var(--select-badge-remove-icon-size, 10px);
|
|
1728
|
+
color: var(--select-badge-remove-icon-color, currentColor);
|
|
1729
|
+
font-size: var(--select-badge-remove-icon-font-size, inherit);
|
|
1730
|
+
line-height: var(--select-badge-remove-icon-line-height, 1);
|
|
1731
|
+
transform: var(--select-badge-remove-icon-transform, none);
|
|
1732
|
+
opacity: var(--select-badge-remove-icon-opacity, 1);
|
|
1680
1733
|
pointer-events: none;
|
|
1681
1734
|
}
|
|
1682
1735
|
|
|
@@ -1698,8 +1751,20 @@ class SelectOption extends HTMLElement {
|
|
|
1698
1751
|
`;
|
|
1699
1752
|
this._shadow.appendChild(style);
|
|
1700
1753
|
}
|
|
1754
|
+
_getDisabledBehavior() {
|
|
1755
|
+
const behavior = this._config.disabledBehavior ?? {};
|
|
1756
|
+
return {
|
|
1757
|
+
selectable: behavior.selectable === true,
|
|
1758
|
+
hoverable: behavior.hoverable === true,
|
|
1759
|
+
focusable: behavior.focusable === true,
|
|
1760
|
+
};
|
|
1761
|
+
}
|
|
1762
|
+
_isDisabledSelectionBlocked() {
|
|
1763
|
+
return Boolean(this._config.disabled) && !this._getDisabledBehavior().selectable;
|
|
1764
|
+
}
|
|
1701
1765
|
_render() {
|
|
1702
1766
|
const { item, index, selected, disabled, active, render, showRemoveButton, classMap } = this._config;
|
|
1767
|
+
const disabledBehavior = this._getDisabledBehavior();
|
|
1703
1768
|
// Clear container
|
|
1704
1769
|
this._container.innerHTML = '';
|
|
1705
1770
|
// Add part attribute
|
|
@@ -1728,7 +1793,7 @@ class SelectOption extends HTMLElement {
|
|
|
1728
1793
|
toggleClasses(this._container, [...selectedClasses, 'smilodon-option--selected'], false);
|
|
1729
1794
|
toggleClasses(this, [...selectedClasses, 'smilodon-option--selected'], false);
|
|
1730
1795
|
}
|
|
1731
|
-
if (active && !disabled) {
|
|
1796
|
+
if (active && (!disabled || disabledBehavior.focusable)) {
|
|
1732
1797
|
toggleClasses(this._container, [...activeClasses, 'smilodon-option--active'], true);
|
|
1733
1798
|
toggleClasses(this, [...activeClasses, 'smilodon-option--active'], true); // Make focus ring visible on host
|
|
1734
1799
|
}
|
|
@@ -1744,6 +1809,15 @@ class SelectOption extends HTMLElement {
|
|
|
1744
1809
|
toggleClasses(this._container, [...disabledClasses, 'smilodon-option--disabled'], false);
|
|
1745
1810
|
toggleClasses(this, [...disabledClasses, 'smilodon-option--disabled'], false);
|
|
1746
1811
|
}
|
|
1812
|
+
const interactiveDisabled = Boolean(disabled && (disabledBehavior.hoverable || disabledBehavior.selectable));
|
|
1813
|
+
const toggleBehaviorClass = (className, add) => {
|
|
1814
|
+
toggleClasses(this._container, [className], add);
|
|
1815
|
+
toggleClasses(this, [className], add);
|
|
1816
|
+
};
|
|
1817
|
+
toggleBehaviorClass('smilodon-option--disabled-interactive', interactiveDisabled);
|
|
1818
|
+
toggleBehaviorClass('smilodon-option--disabled-hoverable', Boolean(disabled && disabledBehavior.hoverable));
|
|
1819
|
+
toggleBehaviorClass('smilodon-option--disabled-focusable', Boolean(disabled && disabledBehavior.focusable));
|
|
1820
|
+
toggleBehaviorClass('smilodon-option--disabled-selectable', Boolean(disabled && disabledBehavior.selectable));
|
|
1747
1821
|
// Custom class name
|
|
1748
1822
|
if (this._config.className) {
|
|
1749
1823
|
const classes = this._config.className.split(' ').filter(Boolean);
|
|
@@ -1796,7 +1870,7 @@ class SelectOption extends HTMLElement {
|
|
|
1796
1870
|
// Set ARIA attributes and State attributes on Host
|
|
1797
1871
|
this.setAttribute('role', 'option');
|
|
1798
1872
|
this.setAttribute('aria-selected', String(selected));
|
|
1799
|
-
if (disabled) {
|
|
1873
|
+
if (disabled && !disabledBehavior.selectable) {
|
|
1800
1874
|
this.setAttribute('aria-disabled', 'true');
|
|
1801
1875
|
}
|
|
1802
1876
|
else {
|
|
@@ -1820,7 +1894,7 @@ class SelectOption extends HTMLElement {
|
|
|
1820
1894
|
const state = [];
|
|
1821
1895
|
if (selected)
|
|
1822
1896
|
state.push('selected');
|
|
1823
|
-
if (active && !disabled)
|
|
1897
|
+
if (active && (!disabled || disabledBehavior.focusable))
|
|
1824
1898
|
state.push('active');
|
|
1825
1899
|
if (state.length) {
|
|
1826
1900
|
this.dataset.smState = state.join(' ');
|
|
@@ -1840,7 +1914,7 @@ class SelectOption extends HTMLElement {
|
|
|
1840
1914
|
if (e.target === this._removeButton) {
|
|
1841
1915
|
return;
|
|
1842
1916
|
}
|
|
1843
|
-
if (!this.
|
|
1917
|
+
if (!this._isDisabledSelectionBlocked()) {
|
|
1844
1918
|
this._handleSelect();
|
|
1845
1919
|
}
|
|
1846
1920
|
});
|
|
@@ -1853,7 +1927,7 @@ class SelectOption extends HTMLElement {
|
|
|
1853
1927
|
}
|
|
1854
1928
|
// Keyboard handler
|
|
1855
1929
|
this.addEventListener('keydown', (e) => {
|
|
1856
|
-
if (this.
|
|
1930
|
+
if (this._isDisabledSelectionBlocked())
|
|
1857
1931
|
return;
|
|
1858
1932
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
1859
1933
|
e.preventDefault();
|
|
@@ -1944,7 +2018,7 @@ class SelectOption extends HTMLElement {
|
|
|
1944
2018
|
* Set active state
|
|
1945
2019
|
*/
|
|
1946
2020
|
setActive(active) {
|
|
1947
|
-
this._config.active = active && !this._config.disabled;
|
|
2021
|
+
this._config.active = active && (!this._config.disabled || this._getDisabledBehavior().focusable);
|
|
1948
2022
|
this._render();
|
|
1949
2023
|
}
|
|
1950
2024
|
/**
|
|
@@ -2012,6 +2086,8 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2012
2086
|
this._mirrorGlobalStylesForCustomOptions = false;
|
|
2013
2087
|
this._globalStylesObserver = null;
|
|
2014
2088
|
this._globalStylesContainer = null;
|
|
2089
|
+
this._themeContextObserver = null;
|
|
2090
|
+
this._globalStylesSyncToken = 0;
|
|
2015
2091
|
this._tracking = { events: [], styles: [], limitations: [] };
|
|
2016
2092
|
this._suppressBlurClose = false;
|
|
2017
2093
|
this._renderCycleId = 0;
|
|
@@ -2127,6 +2203,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2127
2203
|
return;
|
|
2128
2204
|
if (!this._mirrorGlobalStylesForCustomOptions)
|
|
2129
2205
|
return;
|
|
2206
|
+
this._setupThemeContextMirroring();
|
|
2130
2207
|
this._mirrorDocumentStylesIntoShadow();
|
|
2131
2208
|
if (this._globalStylesObserver)
|
|
2132
2209
|
return;
|
|
@@ -2145,6 +2222,10 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2145
2222
|
this._globalStylesObserver.disconnect();
|
|
2146
2223
|
this._globalStylesObserver = null;
|
|
2147
2224
|
}
|
|
2225
|
+
if (this._themeContextObserver) {
|
|
2226
|
+
this._themeContextObserver.disconnect();
|
|
2227
|
+
this._themeContextObserver = null;
|
|
2228
|
+
}
|
|
2148
2229
|
if (this._globalStylesContainer) {
|
|
2149
2230
|
this._globalStylesContainer.remove();
|
|
2150
2231
|
this._globalStylesContainer = null;
|
|
@@ -2161,34 +2242,232 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2161
2242
|
this._shadow.appendChild(this._globalStylesContainer);
|
|
2162
2243
|
}
|
|
2163
2244
|
const container = this._globalStylesContainer;
|
|
2164
|
-
|
|
2245
|
+
const syncToken = ++this._globalStylesSyncToken;
|
|
2165
2246
|
const styleNodes = Array.from(document.querySelectorAll('style,link[rel="stylesheet"]'));
|
|
2166
|
-
styleNodes.
|
|
2167
|
-
if (
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2247
|
+
void Promise.all(styleNodes.map((node, index) => this._createScopedGlobalStyleNode(node, index))).then((mirroredNodes) => {
|
|
2248
|
+
if (!this._globalStylesContainer || syncToken !== this._globalStylesSyncToken)
|
|
2249
|
+
return;
|
|
2250
|
+
container.replaceChildren(...mirroredNodes.filter((node) => Boolean(node)));
|
|
2251
|
+
this._syncMirroredThemeContext();
|
|
2252
|
+
});
|
|
2253
|
+
}
|
|
2254
|
+
_setupThemeContextMirroring() {
|
|
2255
|
+
if (typeof document === 'undefined')
|
|
2256
|
+
return;
|
|
2257
|
+
this._syncMirroredThemeContext();
|
|
2258
|
+
if (this._themeContextObserver)
|
|
2259
|
+
return;
|
|
2260
|
+
this._themeContextObserver = new MutationObserver(() => {
|
|
2261
|
+
this._syncMirroredThemeContext();
|
|
2262
|
+
});
|
|
2263
|
+
const targets = new Set([this, document.documentElement]);
|
|
2264
|
+
if (document.body) {
|
|
2265
|
+
targets.add(document.body);
|
|
2266
|
+
}
|
|
2267
|
+
let ancestor = this.parentElement;
|
|
2268
|
+
while (ancestor) {
|
|
2269
|
+
targets.add(ancestor);
|
|
2270
|
+
ancestor = ancestor.parentElement;
|
|
2271
|
+
}
|
|
2272
|
+
targets.forEach((target) => {
|
|
2273
|
+
this._themeContextObserver?.observe(target, {
|
|
2274
|
+
attributes: true,
|
|
2275
|
+
attributeFilter: ['class', 'dark-mode', 'darkmode', 'data-theme', 'theme'],
|
|
2276
|
+
});
|
|
2277
|
+
});
|
|
2278
|
+
}
|
|
2279
|
+
_syncMirroredThemeContext() {
|
|
2280
|
+
const scopeTarget = this._optionsContainer;
|
|
2281
|
+
if (!scopeTarget)
|
|
2282
|
+
return;
|
|
2283
|
+
const darkSelectors = [
|
|
2284
|
+
'.dark-mode',
|
|
2285
|
+
'.dark',
|
|
2286
|
+
'[dark-mode]',
|
|
2287
|
+
'[darkmode]',
|
|
2288
|
+
'[data-theme="dark"]',
|
|
2289
|
+
'[theme="dark"]',
|
|
2290
|
+
];
|
|
2291
|
+
const isDark = darkSelectors.some((selector) => this.matches(selector) || Boolean(this.closest(selector)))
|
|
2292
|
+
|| document.documentElement.matches('.dark-mode, .dark, [dark-mode], [darkmode], [data-theme="dark"], [theme="dark"]')
|
|
2293
|
+
|| Boolean(document.body?.matches('.dark-mode, .dark, [dark-mode], [darkmode], [data-theme="dark"], [theme="dark"]'));
|
|
2294
|
+
scopeTarget.classList.toggle('dark', isDark);
|
|
2295
|
+
scopeTarget.classList.toggle('dark-mode', isDark);
|
|
2296
|
+
if (isDark) {
|
|
2297
|
+
scopeTarget.setAttribute('dark-mode', '');
|
|
2298
|
+
scopeTarget.setAttribute('data-theme', 'dark');
|
|
2299
|
+
scopeTarget.setAttribute('theme', 'dark');
|
|
2300
|
+
}
|
|
2301
|
+
else {
|
|
2302
|
+
scopeTarget.removeAttribute('dark-mode');
|
|
2303
|
+
scopeTarget.removeAttribute('data-theme');
|
|
2304
|
+
scopeTarget.removeAttribute('theme');
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
async _createScopedGlobalStyleNode(node, index) {
|
|
2308
|
+
if (node instanceof HTMLStyleElement) {
|
|
2309
|
+
return this._buildScopedStyleElement(node.textContent || '', String(index));
|
|
2310
|
+
}
|
|
2311
|
+
if (node instanceof HTMLLinkElement && node.href) {
|
|
2312
|
+
try {
|
|
2313
|
+
const response = await fetch(node.href, {
|
|
2314
|
+
credentials: node.crossOrigin === 'use-credentials' ? 'include' : 'same-origin',
|
|
2315
|
+
mode: 'cors',
|
|
2316
|
+
});
|
|
2317
|
+
if (!response.ok) {
|
|
2318
|
+
return null;
|
|
2319
|
+
}
|
|
2320
|
+
const cssText = await response.text();
|
|
2321
|
+
return this._buildScopedStyleElement(cssText, String(index));
|
|
2322
|
+
}
|
|
2323
|
+
catch (_error) {
|
|
2324
|
+
return null;
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
return null;
|
|
2328
|
+
}
|
|
2329
|
+
_buildScopedStyleElement(cssText, id) {
|
|
2330
|
+
const scopedCss = this._scopeMirroredCssText(cssText);
|
|
2331
|
+
if (!scopedCss.trim())
|
|
2332
|
+
return null;
|
|
2333
|
+
const style = document.createElement('style');
|
|
2334
|
+
style.setAttribute('data-smilodon-global-style', id);
|
|
2335
|
+
style.textContent = scopedCss;
|
|
2336
|
+
return style;
|
|
2337
|
+
}
|
|
2338
|
+
_scopeMirroredCssText(cssText) {
|
|
2339
|
+
if (!cssText.trim())
|
|
2340
|
+
return '';
|
|
2341
|
+
try {
|
|
2342
|
+
if (typeof CSSStyleSheet !== 'undefined') {
|
|
2343
|
+
const sheet = new CSSStyleSheet();
|
|
2344
|
+
sheet.replaceSync(cssText);
|
|
2345
|
+
return this._serializeScopedCssRules(Array.from(sheet.cssRules));
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
catch (_error) {
|
|
2349
|
+
return '';
|
|
2350
|
+
}
|
|
2351
|
+
return '';
|
|
2352
|
+
}
|
|
2353
|
+
_serializeScopedCssRules(rules) {
|
|
2354
|
+
return rules.map((rule) => this._serializeScopedCssRule(rule)).filter(Boolean).join('\n');
|
|
2355
|
+
}
|
|
2356
|
+
_serializeScopedCssRule(rule) {
|
|
2357
|
+
if (rule instanceof CSSStyleRule) {
|
|
2358
|
+
const selectors = this._splitSelectorList(rule.selectorText)
|
|
2359
|
+
.map((selector) => this._scopeMirroredSelector(selector))
|
|
2360
|
+
.filter(Boolean);
|
|
2361
|
+
if (selectors.length === 0)
|
|
2362
|
+
return '';
|
|
2363
|
+
return `${selectors.join(', ')} { ${rule.style.cssText} }`;
|
|
2364
|
+
}
|
|
2365
|
+
if (rule instanceof CSSMediaRule) {
|
|
2366
|
+
const nested = this._serializeScopedCssRules(Array.from(rule.cssRules));
|
|
2367
|
+
return nested ? `@media ${rule.conditionText} { ${nested} }` : '';
|
|
2368
|
+
}
|
|
2369
|
+
if (typeof CSSSupportsRule !== 'undefined' && rule instanceof CSSSupportsRule) {
|
|
2370
|
+
const nested = this._serializeScopedCssRules(Array.from(rule.cssRules));
|
|
2371
|
+
return nested ? `@supports ${rule.conditionText} { ${nested} }` : '';
|
|
2372
|
+
}
|
|
2373
|
+
if (rule instanceof CSSFontFaceRule || rule instanceof CSSKeyframesRule) {
|
|
2374
|
+
return rule.cssText;
|
|
2375
|
+
}
|
|
2376
|
+
const nestedRule = rule;
|
|
2377
|
+
if (nestedRule.cssRules) {
|
|
2378
|
+
const nested = this._serializeScopedCssRules(Array.from(nestedRule.cssRules));
|
|
2379
|
+
if (!nested)
|
|
2380
|
+
return '';
|
|
2381
|
+
const ctorName = nestedRule.constructor?.name ?? '';
|
|
2382
|
+
if (ctorName.includes('Layer')) {
|
|
2383
|
+
return `@layer ${nestedRule.name ?? ''} { ${nested} }`;
|
|
2384
|
+
}
|
|
2385
|
+
if (ctorName.includes('Container')) {
|
|
2386
|
+
return `@container ${nestedRule.conditionText ?? ''} { ${nested} }`;
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
return '';
|
|
2390
|
+
}
|
|
2391
|
+
_splitSelectorList(selectorText) {
|
|
2392
|
+
const selectors = [];
|
|
2393
|
+
let current = '';
|
|
2394
|
+
let depthRound = 0;
|
|
2395
|
+
let depthSquare = 0;
|
|
2396
|
+
for (const char of selectorText) {
|
|
2397
|
+
if (char === '(')
|
|
2398
|
+
depthRound += 1;
|
|
2399
|
+
if (char === ')')
|
|
2400
|
+
depthRound = Math.max(0, depthRound - 1);
|
|
2401
|
+
if (char === '[')
|
|
2402
|
+
depthSquare += 1;
|
|
2403
|
+
if (char === ']')
|
|
2404
|
+
depthSquare = Math.max(0, depthSquare - 1);
|
|
2405
|
+
if (char === ',' && depthRound === 0 && depthSquare === 0) {
|
|
2406
|
+
if (current.trim())
|
|
2407
|
+
selectors.push(current.trim());
|
|
2408
|
+
current = '';
|
|
2409
|
+
continue;
|
|
2410
|
+
}
|
|
2411
|
+
current += char;
|
|
2412
|
+
}
|
|
2413
|
+
if (current.trim())
|
|
2414
|
+
selectors.push(current.trim());
|
|
2415
|
+
return selectors;
|
|
2416
|
+
}
|
|
2417
|
+
_scopeMirroredSelector(selector) {
|
|
2418
|
+
const scopeClass = `.${EnhancedSelect._MIRRORED_STYLES_SCOPE_CLASS}`;
|
|
2419
|
+
let scopedSelector = selector
|
|
2420
|
+
.replace(/(^|\s|>|\+|~)(:root|html|body)(?=\b|\s|[.#[:>+~]|$)/g, `$1${scopeClass}`);
|
|
2421
|
+
const themePatterns = [
|
|
2422
|
+
/\.dark-mode(?![\w-]|\\:)/g,
|
|
2423
|
+
/\.dark(?![\w-]|\\:)/g,
|
|
2424
|
+
/\[dark-mode\]/g,
|
|
2425
|
+
/\[darkmode\]/g,
|
|
2426
|
+
/\[data-theme=(?:"dark"|'dark'|dark)\]/g,
|
|
2427
|
+
/\[theme=(?:"dark"|'dark'|dark)\]/g,
|
|
2428
|
+
];
|
|
2429
|
+
let injectedThemeScope = false;
|
|
2430
|
+
themePatterns.forEach((pattern) => {
|
|
2431
|
+
scopedSelector = scopedSelector.replace(pattern, (match) => {
|
|
2432
|
+
injectedThemeScope = true;
|
|
2433
|
+
return `${match}${scopeClass}`;
|
|
2434
|
+
});
|
|
2435
|
+
});
|
|
2436
|
+
if (!scopedSelector.includes(EnhancedSelect._MIRRORED_STYLES_SCOPE_CLASS) && !injectedThemeScope) {
|
|
2437
|
+
scopedSelector = `${scopeClass} ${scopedSelector}`;
|
|
2438
|
+
}
|
|
2439
|
+
return scopedSelector;
|
|
2440
|
+
}
|
|
2441
|
+
_normalizeCustomOptionAccessibility(optionEl, meta) {
|
|
2442
|
+
if (!optionEl.hasAttribute('aria-label') && !optionEl.hasAttribute('aria-labelledby')) {
|
|
2443
|
+
optionEl.setAttribute('aria-label', meta.label);
|
|
2444
|
+
}
|
|
2445
|
+
const nestedFocusableSelectors = [
|
|
2446
|
+
'a[href]',
|
|
2447
|
+
'button',
|
|
2448
|
+
'input',
|
|
2449
|
+
'select',
|
|
2450
|
+
'textarea',
|
|
2451
|
+
'summary',
|
|
2452
|
+
'[tabindex]',
|
|
2453
|
+
'[contenteditable=""]',
|
|
2454
|
+
'[contenteditable="true"]',
|
|
2455
|
+
'[role="button"]',
|
|
2456
|
+
'[role="link"]',
|
|
2457
|
+
'[role="checkbox"]',
|
|
2458
|
+
'[role="switch"]',
|
|
2459
|
+
'[role="radio"]',
|
|
2460
|
+
'[role="textbox"]',
|
|
2461
|
+
].join(', ');
|
|
2462
|
+
optionEl.querySelectorAll(nestedFocusableSelectors).forEach((child) => {
|
|
2463
|
+
if (child === optionEl)
|
|
2172
2464
|
return;
|
|
2465
|
+
child.tabIndex = -1;
|
|
2466
|
+
if (!child.hasAttribute('data-smilodon-keep-role')) {
|
|
2467
|
+
child.setAttribute('role', 'presentation');
|
|
2173
2468
|
}
|
|
2174
|
-
if (
|
|
2175
|
-
|
|
2176
|
-
clonedLink.rel = 'stylesheet';
|
|
2177
|
-
clonedLink.href = node.href;
|
|
2178
|
-
if (node.media)
|
|
2179
|
-
clonedLink.media = node.media;
|
|
2180
|
-
if (node.crossOrigin)
|
|
2181
|
-
clonedLink.crossOrigin = node.crossOrigin;
|
|
2182
|
-
if (node.referrerPolicy)
|
|
2183
|
-
clonedLink.referrerPolicy = node.referrerPolicy;
|
|
2184
|
-
if (node.integrity)
|
|
2185
|
-
clonedLink.integrity = node.integrity;
|
|
2186
|
-
if (node.type)
|
|
2187
|
-
clonedLink.type = node.type;
|
|
2188
|
-
if (node.nonce)
|
|
2189
|
-
clonedLink.nonce = node.nonce;
|
|
2190
|
-
clonedLink.setAttribute('data-smilodon-global-link', String(index));
|
|
2191
|
-
container.appendChild(clonedLink);
|
|
2469
|
+
if ((meta.disabled || child.matches('button, input, select, textarea, summary, a[href]')) && !child.hasAttribute('data-smilodon-keep-aria')) {
|
|
2470
|
+
child.setAttribute('aria-hidden', 'true');
|
|
2192
2471
|
}
|
|
2193
2472
|
});
|
|
2194
2473
|
}
|
|
@@ -2249,6 +2528,20 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2249
2528
|
this._setCssVariable(variableName, styleConfig?.[styleKey]);
|
|
2250
2529
|
});
|
|
2251
2530
|
}
|
|
2531
|
+
_getDisabledOptionBehavior() {
|
|
2532
|
+
const behavior = this._config.selection.disabledOptionBehavior ?? {};
|
|
2533
|
+
return {
|
|
2534
|
+
selectable: behavior.selectable === true,
|
|
2535
|
+
hoverable: behavior.hoverable === true,
|
|
2536
|
+
focusable: behavior.focusable === true,
|
|
2537
|
+
};
|
|
2538
|
+
}
|
|
2539
|
+
_isDisabledOptionSelectable(item) {
|
|
2540
|
+
return Boolean(item?.disabled) && this._getDisabledOptionBehavior().selectable;
|
|
2541
|
+
}
|
|
2542
|
+
_isOptionSelectionBlocked(item) {
|
|
2543
|
+
return Boolean(item?.disabled) && !this._isDisabledOptionSelectable(item);
|
|
2544
|
+
}
|
|
2252
2545
|
_syncStyleConfigVariables() {
|
|
2253
2546
|
const styles = this._config.styles;
|
|
2254
2547
|
this._applyStyleVariableMap(styles.option, {
|
|
@@ -2306,6 +2599,21 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2306
2599
|
opacity: '--select-option-disabled-opacity',
|
|
2307
2600
|
cursor: '--select-option-disabled-cursor',
|
|
2308
2601
|
});
|
|
2602
|
+
this._applyStyleVariableMap(styles.selectedIndicator, {
|
|
2603
|
+
width: '--select-option-selected-indicator-width',
|
|
2604
|
+
height: '--select-option-selected-indicator-height',
|
|
2605
|
+
background: '--select-option-selected-indicator-bg',
|
|
2606
|
+
backgroundColor: '--select-option-selected-indicator-bg',
|
|
2607
|
+
borderRadius: '--select-option-selected-indicator-radius',
|
|
2608
|
+
left: '--select-option-selected-indicator-left',
|
|
2609
|
+
right: '--select-option-selected-indicator-right',
|
|
2610
|
+
top: '--select-option-selected-indicator-top',
|
|
2611
|
+
transform: '--select-option-selected-indicator-transform',
|
|
2612
|
+
animation: '--select-option-selected-indicator-animation',
|
|
2613
|
+
});
|
|
2614
|
+
this._setCssVariable('--select-option-selected-indicator-display', this._config.selection.showSelectedIndicator === false
|
|
2615
|
+
? 'none'
|
|
2616
|
+
: styles.selectedIndicator?.display);
|
|
2309
2617
|
this._applyStyleVariableMap(styles.badge, {
|
|
2310
2618
|
width: '--select-badge-width',
|
|
2311
2619
|
minWidth: '--select-badge-min-width',
|
|
@@ -2364,6 +2672,15 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2364
2672
|
fontSize: '--select-badge-remove-font-size',
|
|
2365
2673
|
fontWeight: '--select-badge-remove-font-weight',
|
|
2366
2674
|
});
|
|
2675
|
+
this._applyStyleVariableMap(styles.badgeRemoveIcon, {
|
|
2676
|
+
width: '--select-badge-remove-icon-size',
|
|
2677
|
+
height: '--select-badge-remove-icon-size',
|
|
2678
|
+
color: '--select-badge-remove-icon-color',
|
|
2679
|
+
fontSize: '--select-badge-remove-icon-font-size',
|
|
2680
|
+
lineHeight: '--select-badge-remove-icon-line-height',
|
|
2681
|
+
transform: '--select-badge-remove-icon-transform',
|
|
2682
|
+
opacity: '--select-badge-remove-icon-opacity',
|
|
2683
|
+
});
|
|
2367
2684
|
this._applyStyleVariableMap(styles.badgeRemoveHover, {
|
|
2368
2685
|
background: '--select-badge-remove-hover-bg',
|
|
2369
2686
|
backgroundColor: '--select-badge-remove-hover-bg',
|
|
@@ -2464,11 +2781,24 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2464
2781
|
this._inputContainer.style.removeProperty('--select-multi-input-align-content-config');
|
|
2465
2782
|
return;
|
|
2466
2783
|
}
|
|
2467
|
-
const
|
|
2468
|
-
const
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2784
|
+
const configuredMaxHeight = this._config.multiSelectDisplay?.maxHeight;
|
|
2785
|
+
const defaultMaxHeight = '160px';
|
|
2786
|
+
let maxHeight = configuredMaxHeight ?? 'none';
|
|
2787
|
+
let overflowX = this._config.multiSelectDisplay?.overflowX ?? 'hidden';
|
|
2788
|
+
let overflowY = this._config.multiSelectDisplay?.overflowY ?? 'hidden';
|
|
2789
|
+
let flexWrap = 'wrap';
|
|
2790
|
+
let alignContent = 'flex-start';
|
|
2791
|
+
if (mode === 'vertical') {
|
|
2792
|
+
maxHeight = configuredMaxHeight ?? defaultMaxHeight;
|
|
2793
|
+
overflowY = this._config.multiSelectDisplay?.overflowY ?? 'auto';
|
|
2794
|
+
}
|
|
2795
|
+
else if (mode === 'horizontal') {
|
|
2796
|
+
maxHeight = configuredMaxHeight ?? defaultMaxHeight;
|
|
2797
|
+
overflowX = this._config.multiSelectDisplay?.overflowX ?? 'auto';
|
|
2798
|
+
overflowY = this._config.multiSelectDisplay?.overflowY ?? 'hidden';
|
|
2799
|
+
flexWrap = 'nowrap';
|
|
2800
|
+
alignContent = 'center';
|
|
2801
|
+
}
|
|
2472
2802
|
this._inputContainer.setAttribute('data-multi-scroll-mode', mode);
|
|
2473
2803
|
this._inputContainer.setAttribute('data-drag-scroll', String(dragEnabled && mode === 'horizontal'));
|
|
2474
2804
|
this._inputContainer.style.setProperty('--select-multi-input-max-height-config', maxHeight);
|
|
@@ -2652,7 +2982,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2652
2982
|
}
|
|
2653
2983
|
_createOptionsContainer() {
|
|
2654
2984
|
const container = document.createElement('div');
|
|
2655
|
-
container.className =
|
|
2985
|
+
container.className = `options-container ${EnhancedSelect._MIRRORED_STYLES_SCOPE_CLASS}`;
|
|
2656
2986
|
return container;
|
|
2657
2987
|
}
|
|
2658
2988
|
_createLiveRegion() {
|
|
@@ -2751,6 +3081,11 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2751
3081
|
--select-badge-letter-spacing: 0.01em;
|
|
2752
3082
|
--select-badge-hover-shadow: var(--select-shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.15);
|
|
2753
3083
|
--select-badge-remove-icon-size: 10px;
|
|
3084
|
+
--select-badge-remove-icon-color: currentColor;
|
|
3085
|
+
--select-badge-remove-icon-font-size: inherit;
|
|
3086
|
+
--select-badge-remove-icon-line-height: 1;
|
|
3087
|
+
--select-badge-remove-icon-transform: none;
|
|
3088
|
+
--select-badge-remove-icon-opacity: 1;
|
|
2754
3089
|
--select-badge-remove-focus-outline: 2px solid rgba(255, 255, 255, 0.5);
|
|
2755
3090
|
--select-badge-remove-focus-offset: 1px;
|
|
2756
3091
|
--select-badge-remove-hover-transform: scale(1.15) rotate(90deg);
|
|
@@ -2769,9 +3104,11 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2769
3104
|
--select-multi-input-overflow-y: auto;
|
|
2770
3105
|
--select-multi-input-flex-wrap: wrap;
|
|
2771
3106
|
--select-multi-input-align-content: flex-start;
|
|
3107
|
+
--select-multi-input-horizontal-height: var(--select-input-min-height, 48px);
|
|
2772
3108
|
--select-multi-input-horizontal-input-flex: 0 0 var(--select-multi-input-min-width, 96px);
|
|
2773
3109
|
--select-multi-input-horizontal-cursor: grab;
|
|
2774
3110
|
--select-multi-input-horizontal-active-cursor: grabbing;
|
|
3111
|
+
--select-multi-input-end-gap: 12px;
|
|
2775
3112
|
--select-multi-separator-inset-block: 10px;
|
|
2776
3113
|
--select-multi-separator-height: auto;
|
|
2777
3114
|
--select-multi-action-surface-bg: var(--select-input-bg, var(--select-surface));
|
|
@@ -2822,8 +3159,16 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2822
3159
|
--select-multi-container-padding: 6px;
|
|
2823
3160
|
--select-option-disabled-opacity: 0.5;
|
|
2824
3161
|
--select-option-disabled-cursor: not-allowed;
|
|
3162
|
+
--select-option-active-outline: none;
|
|
2825
3163
|
--select-option-active-outline-offset: -2px;
|
|
3164
|
+
--select-option-selected-active-bg: 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%)));
|
|
3165
|
+
--select-option-selected-active-color: var(--select-option-selected-hover-color, var(--select-option-selected-color, var(--select-accent)));
|
|
3166
|
+
--select-option-selected-active-border: var(--select-option-selected-hover-border, var(--select-option-selected-border, var(--select-option-border, none)));
|
|
3167
|
+
--select-option-selected-active-shadow: var(--select-option-active-shadow, none);
|
|
3168
|
+
--select-option-selected-active-transform: var(--select-option-active-transform, none);
|
|
3169
|
+
--select-option-selected-active-outline: none;
|
|
2826
3170
|
--select-option-selected-active-outline-offset: -2px;
|
|
3171
|
+
--select-option-selected-indicator-display: block;
|
|
2827
3172
|
--select-option-selected-indicator-width: 3px;
|
|
2828
3173
|
--select-option-selected-indicator-height: 60%;
|
|
2829
3174
|
--select-option-selected-indicator-bg: var(--select-accent);
|
|
@@ -2836,8 +3181,8 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2836
3181
|
--select-option-selected-indicator-to-height: 60%;
|
|
2837
3182
|
--select-option-selected-indicator-from-opacity: 0;
|
|
2838
3183
|
--select-option-selected-indicator-to-opacity: 1;
|
|
2839
|
-
--select-option-pressed-transform:
|
|
2840
|
-
--select-option-selected-pressed-transform:
|
|
3184
|
+
--select-option-pressed-transform: none;
|
|
3185
|
+
--select-option-selected-pressed-transform: none;
|
|
2841
3186
|
--select-button-hover-transform: translateY(-1px);
|
|
2842
3187
|
--select-button-active-transform: translateY(0) scale(0.98);
|
|
2843
3188
|
--select-button-font-weight: 550;
|
|
@@ -2999,6 +3344,11 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2999
3344
|
justify-content: center;
|
|
3000
3345
|
width: var(--select-badge-remove-icon-size, 10px);
|
|
3001
3346
|
height: var(--select-badge-remove-icon-size, 10px);
|
|
3347
|
+
color: var(--select-badge-remove-icon-color, currentColor);
|
|
3348
|
+
font-size: var(--select-badge-remove-icon-font-size, inherit);
|
|
3349
|
+
line-height: var(--select-badge-remove-icon-line-height, 1);
|
|
3350
|
+
transform: var(--select-badge-remove-icon-transform, none);
|
|
3351
|
+
opacity: var(--select-badge-remove-icon-opacity, 1);
|
|
3002
3352
|
pointer-events: none;
|
|
3003
3353
|
}
|
|
3004
3354
|
|
|
@@ -3104,13 +3454,26 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3104
3454
|
|
|
3105
3455
|
.input-container.input-container--multi {
|
|
3106
3456
|
max-height: var(--select-multi-input-max-height, var(--select-multi-input-max-height-config, var(--select-input-max-height, 160px)));
|
|
3457
|
+
--select-multi-action-area-width: var(--select-arrow-width, 42px);
|
|
3107
3458
|
}
|
|
3108
3459
|
|
|
3109
3460
|
.input-container.input-container--multi .input-content {
|
|
3461
|
+
flex: 1 1 calc(100% - var(--select-multi-action-area-width, var(--select-arrow-width, 42px)));
|
|
3462
|
+
width: calc(100% - var(--select-multi-action-area-width, var(--select-arrow-width, 42px)));
|
|
3463
|
+
max-width: calc(100% - var(--select-multi-action-area-width, var(--select-arrow-width, 42px)));
|
|
3110
3464
|
flex-wrap: var(--select-multi-input-flex-wrap, var(--select-multi-input-flex-wrap-config, wrap));
|
|
3111
3465
|
align-content: var(--select-multi-input-align-content, var(--select-multi-input-align-content-config, flex-start));
|
|
3112
3466
|
overflow-x: var(--select-multi-input-overflow-x, var(--select-multi-input-overflow-x-config, hidden));
|
|
3113
3467
|
overflow-y: var(--select-multi-input-overflow-y, var(--select-multi-input-overflow-y-config, auto));
|
|
3468
|
+
padding-inline-end: var(--select-multi-input-end-gap, 12px);
|
|
3469
|
+
}
|
|
3470
|
+
|
|
3471
|
+
.input-container.input-container--multi .input-content .selection-badge {
|
|
3472
|
+
flex: 0 0 auto;
|
|
3473
|
+
}
|
|
3474
|
+
|
|
3475
|
+
.input-container.input-container--multi.has-clear-control .input-content {
|
|
3476
|
+
--select-multi-action-area-width: calc(var(--select-arrow-right-with-clear, 34px) + var(--select-arrow-width, 42px));
|
|
3114
3477
|
}
|
|
3115
3478
|
|
|
3116
3479
|
.input-container.input-container--multi::after {
|
|
@@ -3121,17 +3484,31 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3121
3484
|
|
|
3122
3485
|
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"] {
|
|
3123
3486
|
align-items: stretch;
|
|
3487
|
+
height: var(--select-multi-input-horizontal-height, var(--select-input-min-height, 48px));
|
|
3488
|
+
min-height: var(--select-multi-input-horizontal-height, var(--select-input-min-height, 48px));
|
|
3489
|
+
max-height: var(--select-multi-input-horizontal-height, var(--select-input-min-height, 48px));
|
|
3490
|
+
overflow: hidden;
|
|
3124
3491
|
}
|
|
3125
3492
|
|
|
3126
3493
|
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .input-content {
|
|
3494
|
+
flex: 1 1 100%;
|
|
3495
|
+
width: 100%;
|
|
3496
|
+
max-width: 100%;
|
|
3497
|
+
min-height: 0;
|
|
3498
|
+
height: 100%;
|
|
3127
3499
|
cursor: var(--select-multi-input-horizontal-cursor, grab);
|
|
3500
|
+
align-items: center;
|
|
3501
|
+
align-content: center;
|
|
3502
|
+
flex-wrap: nowrap;
|
|
3128
3503
|
overflow-y: hidden;
|
|
3129
3504
|
overscroll-behavior-x: contain;
|
|
3130
|
-
|
|
3505
|
+
overscroll-behavior-y: none;
|
|
3506
|
+
padding-inline-end: 0;
|
|
3507
|
+
scroll-padding-inline-end: var(--select-multi-action-area-width, var(--select-arrow-width, 42px));
|
|
3131
3508
|
}
|
|
3132
3509
|
|
|
3133
3510
|
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"].has-clear-control .input-content {
|
|
3134
|
-
|
|
3511
|
+
--select-multi-action-area-width: calc(var(--select-arrow-right-with-clear, 34px) + var(--select-arrow-width, 42px));
|
|
3135
3512
|
}
|
|
3136
3513
|
|
|
3137
3514
|
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"]::after {
|
|
@@ -3143,8 +3520,10 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3143
3520
|
user-select: none;
|
|
3144
3521
|
}
|
|
3145
3522
|
|
|
3146
|
-
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .
|
|
3523
|
+
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .selection-badge {
|
|
3147
3524
|
flex: 0 0 auto;
|
|
3525
|
+
margin-top: 0;
|
|
3526
|
+
margin-bottom: 0;
|
|
3148
3527
|
}
|
|
3149
3528
|
|
|
3150
3529
|
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .input-content > .select-input,
|
|
@@ -3173,15 +3552,6 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3173
3552
|
left: var(--select-arrow-right-with-clear, 34px);
|
|
3174
3553
|
}
|
|
3175
3554
|
|
|
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
|
-
|
|
3185
3555
|
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .clear-control-button {
|
|
3186
3556
|
background: var(--select-multi-action-surface-bg, var(--select-input-bg, var(--select-surface)));
|
|
3187
3557
|
z-index: 4;
|
|
@@ -3570,7 +3940,8 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3570
3940
|
margin: var(--select-option-margin);
|
|
3571
3941
|
}
|
|
3572
3942
|
|
|
3573
|
-
.option:hover
|
|
3943
|
+
.option:hover:not(.disabled):not(.smilodon-option--disabled),
|
|
3944
|
+
.option.smilodon-option--disabled-hoverable:hover {
|
|
3574
3945
|
background: var(--select-option-hover-bg, var(--select-surface-elevated));
|
|
3575
3946
|
border: var(--select-option-hover-border, var(--select-option-border, none));
|
|
3576
3947
|
color: var(--select-option-hover-color, var(--select-text));
|
|
@@ -3585,7 +3956,8 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3585
3956
|
}
|
|
3586
3957
|
|
|
3587
3958
|
.option.selected::before {
|
|
3588
|
-
content: '';
|
|
3959
|
+
content: var(--select-option-selected-indicator-content, '');
|
|
3960
|
+
display: var(--select-option-selected-indicator-display, block);
|
|
3589
3961
|
position: absolute;
|
|
3590
3962
|
left: var(--select-option-selected-indicator-left);
|
|
3591
3963
|
top: var(--select-option-selected-indicator-top);
|
|
@@ -3620,35 +3992,50 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3620
3992
|
color: var(--select-option-selected-hover-color, var(--select-option-selected-color, var(--select-accent)));
|
|
3621
3993
|
}
|
|
3622
3994
|
|
|
3623
|
-
.option.active:not(.selected):not(.disabled)
|
|
3995
|
+
.option.active:not(.selected):not(.disabled):not(.smilodon-option--disabled),
|
|
3996
|
+
.option.active.smilodon-option--disabled-focusable:not(.selected) {
|
|
3624
3997
|
background: var(--select-option-active-bg, var(--select-surface-elevated));
|
|
3625
3998
|
color: var(--select-option-active-color, var(--select-option-hover-color, var(--select-option-color, var(--select-text))));
|
|
3626
3999
|
border: var(--select-option-active-border, var(--select-option-hover-border, var(--select-option-border, none)));
|
|
3627
|
-
outline: var(--select-option-active-outline,
|
|
4000
|
+
outline: var(--select-option-active-outline, none);
|
|
3628
4001
|
outline-offset: var(--select-option-active-outline-offset);
|
|
3629
4002
|
box-shadow: var(--select-option-active-shadow, none);
|
|
3630
4003
|
transform: var(--select-option-active-transform, none);
|
|
3631
4004
|
}
|
|
3632
4005
|
|
|
3633
|
-
.option.selected.active:not(.disabled)
|
|
3634
|
-
|
|
4006
|
+
.option.selected.active:not(.disabled):not(.smilodon-option--disabled),
|
|
4007
|
+
.option.selected.active.smilodon-option--disabled-focusable {
|
|
4008
|
+
background: var(--select-option-selected-active-bg, 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%))));
|
|
4009
|
+
color: var(--select-option-selected-active-color, var(--select-option-selected-hover-color, var(--select-option-selected-color, var(--select-accent))));
|
|
4010
|
+
border: var(--select-option-selected-active-border, var(--select-option-selected-hover-border, var(--select-option-selected-border, var(--select-option-border, none))));
|
|
4011
|
+
outline: var(--select-option-selected-active-outline, var(--select-option-active-outline, none));
|
|
3635
4012
|
outline-offset: var(--select-option-selected-active-outline-offset);
|
|
4013
|
+
box-shadow: var(--select-option-selected-active-shadow, var(--select-option-active-shadow, none));
|
|
4014
|
+
transform: var(--select-option-selected-active-transform, var(--select-option-active-transform, none));
|
|
3636
4015
|
}
|
|
3637
4016
|
|
|
3638
|
-
.option.disabled
|
|
4017
|
+
.option.disabled,
|
|
4018
|
+
.option.smilodon-option--disabled {
|
|
3639
4019
|
background: var(--select-option-disabled-bg, var(--select-option-bg, transparent));
|
|
3640
4020
|
color: var(--select-option-disabled-color, var(--select-text-muted));
|
|
3641
4021
|
border: var(--select-option-disabled-border, var(--select-option-border, none));
|
|
3642
4022
|
opacity: var(--select-option-disabled-opacity, 0.5);
|
|
3643
4023
|
cursor: var(--select-option-disabled-cursor, not-allowed);
|
|
4024
|
+
pointer-events: var(--select-option-disabled-pointer-events, none);
|
|
4025
|
+
}
|
|
4026
|
+
|
|
4027
|
+
.option.smilodon-option--disabled-interactive {
|
|
4028
|
+
pointer-events: auto;
|
|
3644
4029
|
}
|
|
3645
4030
|
|
|
3646
|
-
.option:active:not(.selected)
|
|
4031
|
+
.option:active:not(.selected):not(.disabled):not(.smilodon-option--disabled),
|
|
4032
|
+
.option.smilodon-option--disabled-selectable:active:not(.selected) {
|
|
3647
4033
|
background: var(--select-option-pressed-bg, rgba(15, 52, 96, 0.08));
|
|
3648
4034
|
transform: var(--select-option-pressed-transform);
|
|
3649
4035
|
}
|
|
3650
4036
|
|
|
3651
|
-
.option.selected:active
|
|
4037
|
+
.option.selected:active:not(.disabled):not(.smilodon-option--disabled),
|
|
4038
|
+
.option.selected.smilodon-option--disabled-selectable:active {
|
|
3652
4039
|
transform: var(--select-option-selected-pressed-transform);
|
|
3653
4040
|
}
|
|
3654
4041
|
|
|
@@ -4224,7 +4611,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4224
4611
|
continue;
|
|
4225
4612
|
}
|
|
4226
4613
|
}
|
|
4227
|
-
if (option && !option.hasAttribute('aria-disabled')) {
|
|
4614
|
+
if (option && (!option.hasAttribute('aria-disabled') || option.classList.contains('smilodon-option--disabled-selectable'))) {
|
|
4228
4615
|
const indexStr = option.getAttribute('data-sm-index') ?? option.getAttribute('data-index');
|
|
4229
4616
|
const index = Number(indexStr);
|
|
4230
4617
|
if (!Number.isNaN(index)) {
|
|
@@ -4668,7 +5055,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4668
5055
|
}
|
|
4669
5056
|
_setActive(index) {
|
|
4670
5057
|
const option = this._getOptionElementByIndex(index);
|
|
4671
|
-
if (!option || option.getAttribute('aria-disabled') === 'true') {
|
|
5058
|
+
if (!option || (option.getAttribute('aria-disabled') === 'true' && !option.classList.contains('smilodon-option--disabled-focusable'))) {
|
|
4672
5059
|
return;
|
|
4673
5060
|
}
|
|
4674
5061
|
// Clear previous active state
|
|
@@ -4716,7 +5103,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4716
5103
|
// Only return elements with data-index or data-sm-selectable attributes
|
|
4717
5104
|
return Array.from(this._optionsContainer.children).filter((child) => {
|
|
4718
5105
|
return (child.hasAttribute('data-index') || child.hasAttribute('data-sm-selectable'))
|
|
4719
|
-
&& child.getAttribute('aria-disabled') !== 'true';
|
|
5106
|
+
&& (child.getAttribute('aria-disabled') !== 'true' || child.classList.contains('smilodon-option--disabled-focusable'));
|
|
4720
5107
|
});
|
|
4721
5108
|
}
|
|
4722
5109
|
_getSelectableOptionIndices() {
|
|
@@ -4771,6 +5158,8 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4771
5158
|
// Check if it's a custom SelectOption or a lightweight DOM element
|
|
4772
5159
|
if ('getConfig' in option && typeof option.getConfig === 'function') {
|
|
4773
5160
|
const config = option.getConfig();
|
|
5161
|
+
if (this._isOptionSelectionBlocked(config.item))
|
|
5162
|
+
return;
|
|
4774
5163
|
this._state.selectedIndices.add(optionIndex);
|
|
4775
5164
|
this._state.selectedItems.set(optionIndex, config.item);
|
|
4776
5165
|
option.setSelected(true);
|
|
@@ -4778,7 +5167,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4778
5167
|
else {
|
|
4779
5168
|
// Lightweight option - get item from data attribute or state
|
|
4780
5169
|
const item = this._state.loadedItems[optionIndex];
|
|
4781
|
-
if (item) {
|
|
5170
|
+
if (item && !this._isOptionSelectionBlocked(item)) {
|
|
4782
5171
|
this._state.selectedIndices.add(optionIndex);
|
|
4783
5172
|
this._state.selectedItems.set(optionIndex, item);
|
|
4784
5173
|
option.classList.add('smilodon-option--selected');
|
|
@@ -4805,10 +5194,12 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4805
5194
|
break;
|
|
4806
5195
|
const item = this._state.loadedItems[i];
|
|
4807
5196
|
const optionEl = this._getOptionElementByIndex(i);
|
|
4808
|
-
if (optionEl?.getAttribute('aria-disabled') === 'true')
|
|
5197
|
+
if (optionEl?.getAttribute('aria-disabled') === 'true' && !optionEl.classList.contains('smilodon-option--disabled-selectable'))
|
|
4809
5198
|
continue;
|
|
4810
5199
|
if (!item)
|
|
4811
5200
|
continue;
|
|
5201
|
+
if (this._isOptionSelectionBlocked(item))
|
|
5202
|
+
continue;
|
|
4812
5203
|
this._state.selectedIndices.add(i);
|
|
4813
5204
|
this._state.selectedItems.set(i, item);
|
|
4814
5205
|
}
|
|
@@ -4846,6 +5237,9 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4846
5237
|
if (!item) {
|
|
4847
5238
|
return;
|
|
4848
5239
|
}
|
|
5240
|
+
if (this._isOptionSelectionBlocked(item)) {
|
|
5241
|
+
return;
|
|
5242
|
+
}
|
|
4849
5243
|
const isCurrentlySelected = this._state.selectedIndices.has(index);
|
|
4850
5244
|
// Keep active/focus styling aligned with the most recently interacted option.
|
|
4851
5245
|
// Without this, a previously selected item may retain active classes/styles
|
|
@@ -4999,6 +5393,9 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4999
5393
|
removeBtn.setAttribute('aria-label', `Remove ${getLabel(item)}`);
|
|
5000
5394
|
const removeIcon = document.createElement('span');
|
|
5001
5395
|
removeIcon.className = 'badge-remove-icon';
|
|
5396
|
+
if (this._config.styles.classNames?.badgeRemoveIcon) {
|
|
5397
|
+
removeIcon.classList.add(...this._config.styles.classNames.badgeRemoveIcon.split(' ').filter(Boolean));
|
|
5398
|
+
}
|
|
5002
5399
|
removeIcon.setAttribute('part', 'chip-remove-icon');
|
|
5003
5400
|
this._setIconContent(removeIcon, this._config.selection.removeButtonIcon, '×');
|
|
5004
5401
|
removeBtn.appendChild(removeIcon);
|
|
@@ -5375,7 +5772,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
5375
5772
|
this._state.selectedIndices.clear();
|
|
5376
5773
|
this._state.selectedItems.clear();
|
|
5377
5774
|
this._state.loadedItems.forEach((item, index) => {
|
|
5378
|
-
if (values.includes(getValue(item))) {
|
|
5775
|
+
if (values.includes(getValue(item)) && !this._isOptionSelectionBlocked(item)) {
|
|
5379
5776
|
this._state.selectedIndices.add(index);
|
|
5380
5777
|
this._state.selectedItems.set(index, item);
|
|
5381
5778
|
}
|
|
@@ -5397,6 +5794,8 @@ class EnhancedSelect extends HTMLElement {
|
|
|
5397
5794
|
this._state.selectedIndices.clear();
|
|
5398
5795
|
this._state.selectedItems.clear();
|
|
5399
5796
|
items.forEach((item, index) => {
|
|
5797
|
+
if (this._isOptionSelectionBlocked(item))
|
|
5798
|
+
return;
|
|
5400
5799
|
this._state.selectedIndices.add(index);
|
|
5401
5800
|
this._state.selectedItems.set(index, item);
|
|
5402
5801
|
});
|
|
@@ -5661,6 +6060,9 @@ class EnhancedSelect extends HTMLElement {
|
|
|
5661
6060
|
if (this._config.styles.classNames?.groupHeader) {
|
|
5662
6061
|
header.classList.add(...this._config.styles.classNames.groupHeader.split(' ').filter(Boolean));
|
|
5663
6062
|
}
|
|
6063
|
+
if (!header.hasAttribute('role')) {
|
|
6064
|
+
header.setAttribute('role', 'presentation');
|
|
6065
|
+
}
|
|
5664
6066
|
header.setAttribute('part', 'group-header');
|
|
5665
6067
|
this._optionsContainer.appendChild(header);
|
|
5666
6068
|
group.options.forEach(item => {
|
|
@@ -5775,6 +6177,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
5775
6177
|
_renderSingleOption(item, index, getValue, getLabel, targetContainer = this._optionsContainer) {
|
|
5776
6178
|
const isSelected = this._state.selectedIndices.has(index);
|
|
5777
6179
|
const isDisabled = Boolean(item?.disabled);
|
|
6180
|
+
const disabledBehavior = this._getDisabledOptionBehavior();
|
|
5778
6181
|
const optionId = `${this._uniqueId}-option-${index}`;
|
|
5779
6182
|
if (this._optionRenderer) {
|
|
5780
6183
|
const rendered = this._optionRenderer(item, index, this._rendererHelpers);
|
|
@@ -5786,6 +6189,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
5786
6189
|
selected: isSelected,
|
|
5787
6190
|
active: this._state.activeIndex === index,
|
|
5788
6191
|
disabled: isDisabled,
|
|
6192
|
+
disabledBehavior,
|
|
5789
6193
|
id: optionId,
|
|
5790
6194
|
});
|
|
5791
6195
|
optionElement.setAttribute('dir', this._config.direction ?? 'ltr');
|
|
@@ -5798,6 +6202,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
5798
6202
|
id: optionId,
|
|
5799
6203
|
selected: isSelected,
|
|
5800
6204
|
disabled: isDisabled,
|
|
6205
|
+
disabledBehavior,
|
|
5801
6206
|
active: this._state.activeIndex === index,
|
|
5802
6207
|
getValue,
|
|
5803
6208
|
getLabel,
|
|
@@ -5859,6 +6264,10 @@ class EnhancedSelect extends HTMLElement {
|
|
|
5859
6264
|
const isSelected = meta.selected;
|
|
5860
6265
|
const isActive = meta.active;
|
|
5861
6266
|
const isDisabled = meta.disabled;
|
|
6267
|
+
const isDisabledSelectable = isDisabled && meta.disabledBehavior.selectable;
|
|
6268
|
+
const isDisabledHoverable = isDisabled && meta.disabledBehavior.hoverable;
|
|
6269
|
+
const isDisabledFocusable = isDisabled && meta.disabledBehavior.focusable;
|
|
6270
|
+
const isDisabledInteractive = isDisabled && (isDisabledSelectable || isDisabledHoverable);
|
|
5862
6271
|
// Resolve classes from classMap or defaults
|
|
5863
6272
|
const selectedClasses = (this.classMap?.selected ?? 'selected sm-selected').split(' ').filter(Boolean);
|
|
5864
6273
|
const activeClasses = (this.classMap?.active ?? 'active sm-active').split(' ').filter(Boolean);
|
|
@@ -5905,6 +6314,10 @@ class EnhancedSelect extends HTMLElement {
|
|
|
5905
6314
|
optionEl.classList.remove(...this._config.styles.classNames.disabledOption.split(' ').filter(Boolean));
|
|
5906
6315
|
}
|
|
5907
6316
|
}
|
|
6317
|
+
optionEl.classList.toggle('smilodon-option--disabled-interactive', isDisabledInteractive);
|
|
6318
|
+
optionEl.classList.toggle('smilodon-option--disabled-hoverable', isDisabledHoverable);
|
|
6319
|
+
optionEl.classList.toggle('smilodon-option--disabled-focusable', isDisabledFocusable);
|
|
6320
|
+
optionEl.classList.toggle('smilodon-option--disabled-selectable', isDisabledSelectable);
|
|
5908
6321
|
// Data Attributes Contract
|
|
5909
6322
|
const state = [];
|
|
5910
6323
|
if (isSelected)
|
|
@@ -5936,11 +6349,8 @@ class EnhancedSelect extends HTMLElement {
|
|
|
5936
6349
|
if (!optionEl.getAttribute('role')) {
|
|
5937
6350
|
optionEl.setAttribute('role', 'option');
|
|
5938
6351
|
}
|
|
5939
|
-
if (!optionEl.getAttribute('aria-label')) {
|
|
5940
|
-
optionEl.setAttribute('aria-label', meta.label);
|
|
5941
|
-
}
|
|
5942
6352
|
optionEl.setAttribute('aria-selected', String(meta.selected));
|
|
5943
|
-
if (meta.disabled) {
|
|
6353
|
+
if (meta.disabled && !meta.disabledBehavior.selectable) {
|
|
5944
6354
|
optionEl.setAttribute('aria-disabled', 'true');
|
|
5945
6355
|
}
|
|
5946
6356
|
else {
|
|
@@ -5955,6 +6365,10 @@ class EnhancedSelect extends HTMLElement {
|
|
|
5955
6365
|
// Re-attaching here causes the double-click toggle bug if a child component fails to stopPropagation.
|
|
5956
6366
|
this._customOptionBoundElements.add(optionEl);
|
|
5957
6367
|
}
|
|
6368
|
+
this._normalizeCustomOptionAccessibility(optionEl, {
|
|
6369
|
+
label: meta.label,
|
|
6370
|
+
disabled: meta.disabled,
|
|
6371
|
+
});
|
|
5958
6372
|
return optionEl;
|
|
5959
6373
|
}
|
|
5960
6374
|
_addLoadMoreTrigger() {
|
|
@@ -5989,6 +6403,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
5989
6403
|
}
|
|
5990
6404
|
/** live set of all connected instances; used to auto-close siblings */
|
|
5991
6405
|
EnhancedSelect._instances = new Set();
|
|
6406
|
+
EnhancedSelect._MIRRORED_STYLES_SCOPE_CLASS = 'smilodon-mirrored-styles-scope';
|
|
5992
6407
|
// Register custom element
|
|
5993
6408
|
if (!customElements.get('enhanced-select')) {
|
|
5994
6409
|
customElements.define('enhanced-select', EnhancedSelect);
|