@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.umd.js
CHANGED
|
@@ -1352,8 +1352,14 @@
|
|
|
1352
1352
|
selection: {
|
|
1353
1353
|
mode: 'single',
|
|
1354
1354
|
allowDeselect: false,
|
|
1355
|
+
disabledOptionBehavior: {
|
|
1356
|
+
selectable: false,
|
|
1357
|
+
hoverable: false,
|
|
1358
|
+
focusable: false,
|
|
1359
|
+
},
|
|
1355
1360
|
maxSelections: 0,
|
|
1356
1361
|
showRemoveButton: true,
|
|
1362
|
+
showSelectedIndicator: true,
|
|
1357
1363
|
removeButtonIcon: '×',
|
|
1358
1364
|
closeOnSelect: true,
|
|
1359
1365
|
toggleOnTriggerClick: true,
|
|
@@ -1530,53 +1536,18 @@
|
|
|
1530
1536
|
display: block;
|
|
1531
1537
|
position: relative;
|
|
1532
1538
|
font: inherit;
|
|
1533
|
-
color: inherit;
|
|
1534
|
-
}
|
|
1535
|
-
|
|
1536
|
-
/* Allow authors to style selected state from outside the shadow root
|
|
1537
|
-
by setting attributes/classes on the host element. This mirrors the
|
|
1538
|
-
internal .option-container.selected rules but reads the same CSS
|
|
1539
|
-
custom properties so themes can fully control selected appearance. */
|
|
1540
|
-
:host([aria-selected="true"]) .option-container,
|
|
1541
|
-
:host(.smilodon-option--selected) .option-container {
|
|
1542
|
-
background: var(--select-option-selected-bg, #e3f2fd);
|
|
1543
|
-
color: var(--select-option-selected-color, #1976d2);
|
|
1544
|
-
border: var(--select-option-selected-border, var(--select-option-border, none));
|
|
1545
|
-
border-bottom: var(--select-option-selected-border-bottom, var(--select-option-border-bottom, none));
|
|
1546
|
-
border-radius: var(--select-option-selected-border-radius, var(--select-option-border-radius, 0));
|
|
1547
|
-
box-shadow: var(--select-option-selected-shadow, var(--select-option-shadow, none));
|
|
1548
|
-
transform: var(--select-option-selected-transform, var(--select-option-transform, none));
|
|
1549
|
-
}
|
|
1550
|
-
|
|
1551
|
-
:host([aria-selected="true"]) .option-container:hover,
|
|
1552
|
-
:host(.smilodon-option--selected) .option-container:hover {
|
|
1553
|
-
background: var(--select-option-selected-hover-bg, var(--select-option-selected-bg, #e3f2fd));
|
|
1554
|
-
color: var(--select-option-selected-hover-color, var(--select-option-selected-color, #1976d2));
|
|
1555
|
-
border: var(--select-option-selected-hover-border, var(--select-option-selected-border, var(--select-option-border, none)));
|
|
1556
|
-
border-bottom: var(--select-option-selected-hover-border-bottom, var(--select-option-selected-border-bottom, var(--select-option-border-bottom, none)));
|
|
1557
|
-
box-shadow: var(--select-option-selected-hover-shadow, var(--select-option-selected-shadow, var(--select-option-shadow, none)));
|
|
1558
|
-
transform: var(--select-option-selected-hover-transform, var(--select-option-selected-transform, var(--select-option-transform, none)));
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
|
-
.option-container {
|
|
1562
|
-
display: flex;
|
|
1563
|
-
align-items: center;
|
|
1564
|
-
justify-content: space-between;
|
|
1565
|
-
padding: var(--select-option-padding, 10px 14px);
|
|
1566
|
-
cursor: pointer;
|
|
1567
|
-
user-select: none;
|
|
1568
1539
|
color: var(--select-option-color, var(--select-text-color, #1f2937));
|
|
1569
1540
|
background: var(--select-option-bg, var(--select-dropdown-bg, var(--select-bg, white)));
|
|
1570
|
-
transition: var(--select-option-transition, background-color 0.2s ease);
|
|
1571
1541
|
border: var(--select-option-border, none);
|
|
1572
1542
|
border-bottom: var(--select-option-border-bottom, none);
|
|
1573
1543
|
border-radius: var(--select-option-border-radius, var(--select-radius-sm, 6px));
|
|
1574
1544
|
box-shadow: var(--select-option-shadow, none);
|
|
1575
1545
|
transform: var(--select-option-transform, none);
|
|
1576
|
-
|
|
1546
|
+
transition: var(--select-option-transition, background-color 0.2s ease);
|
|
1577
1547
|
}
|
|
1578
|
-
|
|
1579
|
-
.option-
|
|
1548
|
+
|
|
1549
|
+
:host(:hover):not(.smilodon-option--disabled):not([aria-disabled="true"]),
|
|
1550
|
+
:host(.smilodon-option--disabled-hoverable:hover) {
|
|
1580
1551
|
background: var(--select-option-hover-bg, #f0f0f0);
|
|
1581
1552
|
color: var(--select-option-hover-color, var(--select-option-color, var(--select-text-color, #1f2937)));
|
|
1582
1553
|
border: var(--select-option-hover-border, var(--select-option-border, none));
|
|
@@ -1584,8 +1555,12 @@
|
|
|
1584
1555
|
box-shadow: var(--select-option-hover-shadow, var(--select-option-shadow, none));
|
|
1585
1556
|
transform: var(--select-option-hover-transform, var(--select-option-transform, none));
|
|
1586
1557
|
}
|
|
1587
|
-
|
|
1588
|
-
|
|
1558
|
+
|
|
1559
|
+
/* Keep the visual surface on the host so external utility classes applied
|
|
1560
|
+
through classMap can override selected/active/disabled styles in both
|
|
1561
|
+
light and dark themes. */
|
|
1562
|
+
:host([aria-selected="true"]),
|
|
1563
|
+
:host(.smilodon-option--selected) {
|
|
1589
1564
|
background: var(--select-option-selected-bg, #e3f2fd);
|
|
1590
1565
|
color: var(--select-option-selected-color, #1976d2);
|
|
1591
1566
|
border: var(--select-option-selected-border, var(--select-option-border, none));
|
|
@@ -1595,7 +1570,8 @@
|
|
|
1595
1570
|
transform: var(--select-option-selected-transform, var(--select-option-transform, none));
|
|
1596
1571
|
}
|
|
1597
1572
|
|
|
1598
|
-
|
|
1573
|
+
:host([aria-selected="true"]:hover),
|
|
1574
|
+
:host(.smilodon-option--selected:hover) {
|
|
1599
1575
|
background: var(--select-option-selected-hover-bg, var(--select-option-selected-bg, #e3f2fd));
|
|
1600
1576
|
color: var(--select-option-selected-hover-color, var(--select-option-selected-color, #1976d2));
|
|
1601
1577
|
border: var(--select-option-selected-hover-border, var(--select-option-selected-border, var(--select-option-border, none)));
|
|
@@ -1603,18 +1579,20 @@
|
|
|
1603
1579
|
box-shadow: var(--select-option-selected-hover-shadow, var(--select-option-selected-shadow, var(--select-option-shadow, none)));
|
|
1604
1580
|
transform: var(--select-option-selected-hover-transform, var(--select-option-selected-transform, var(--select-option-transform, none)));
|
|
1605
1581
|
}
|
|
1606
|
-
|
|
1607
|
-
.option
|
|
1582
|
+
|
|
1583
|
+
:host(.smilodon-option--active):not(.smilodon-option--disabled):not([aria-disabled="true"]),
|
|
1584
|
+
:host(.smilodon-option--active.smilodon-option--disabled-focusable) {
|
|
1608
1585
|
background: var(--select-option-active-bg, var(--select-option-hover-bg, #f0f0f0));
|
|
1609
1586
|
color: var(--select-option-active-color, var(--select-option-hover-color, var(--select-option-color, var(--select-text-color, #1f2937))));
|
|
1610
1587
|
border: var(--select-option-active-border, var(--select-option-hover-border, var(--select-option-border, none)));
|
|
1611
1588
|
box-shadow: var(--select-option-active-shadow, var(--select-option-shadow, none));
|
|
1612
1589
|
transform: var(--select-option-active-transform, var(--select-option-transform, none));
|
|
1613
|
-
outline: var(--select-option-active-outline,
|
|
1590
|
+
outline: var(--select-option-active-outline, none);
|
|
1614
1591
|
outline-offset: var(--select-option-active-outline-offset, -2px);
|
|
1615
1592
|
}
|
|
1616
|
-
|
|
1617
|
-
.option
|
|
1593
|
+
|
|
1594
|
+
:host(.smilodon-option--disabled),
|
|
1595
|
+
:host([aria-disabled="true"]) {
|
|
1618
1596
|
background: var(--select-option-disabled-bg, var(--select-option-bg, var(--select-dropdown-bg, var(--select-bg, white))));
|
|
1619
1597
|
color: var(--select-option-disabled-color, var(--select-option-color, var(--select-text-color, #1f2937)));
|
|
1620
1598
|
border: var(--select-option-disabled-border, var(--select-option-border, none));
|
|
@@ -1623,6 +1601,76 @@
|
|
|
1623
1601
|
cursor: var(--select-option-disabled-cursor, not-allowed);
|
|
1624
1602
|
pointer-events: none;
|
|
1625
1603
|
}
|
|
1604
|
+
|
|
1605
|
+
:host(.smilodon-option--disabled-interactive) {
|
|
1606
|
+
pointer-events: auto;
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
.option-container {
|
|
1610
|
+
display: flex;
|
|
1611
|
+
align-items: center;
|
|
1612
|
+
justify-content: space-between;
|
|
1613
|
+
padding: var(--select-option-padding, 10px 14px);
|
|
1614
|
+
cursor: pointer;
|
|
1615
|
+
user-select: none;
|
|
1616
|
+
color: inherit;
|
|
1617
|
+
background: inherit;
|
|
1618
|
+
transition: inherit;
|
|
1619
|
+
border: inherit;
|
|
1620
|
+
border-bottom: inherit;
|
|
1621
|
+
border-radius: inherit;
|
|
1622
|
+
box-shadow: inherit;
|
|
1623
|
+
transform: inherit;
|
|
1624
|
+
font: inherit;
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
.option-container:hover {
|
|
1628
|
+
background: inherit;
|
|
1629
|
+
color: inherit;
|
|
1630
|
+
border: inherit;
|
|
1631
|
+
border-bottom: inherit;
|
|
1632
|
+
box-shadow: inherit;
|
|
1633
|
+
transform: inherit;
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
.option-container.selected {
|
|
1637
|
+
background: inherit;
|
|
1638
|
+
color: inherit;
|
|
1639
|
+
border: inherit;
|
|
1640
|
+
border-bottom: inherit;
|
|
1641
|
+
border-radius: inherit;
|
|
1642
|
+
box-shadow: inherit;
|
|
1643
|
+
transform: inherit;
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
.option-container.selected:hover {
|
|
1647
|
+
background: inherit;
|
|
1648
|
+
color: inherit;
|
|
1649
|
+
border: inherit;
|
|
1650
|
+
border-bottom: inherit;
|
|
1651
|
+
box-shadow: inherit;
|
|
1652
|
+
transform: inherit;
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
.option-container.active:not(.disabled) {
|
|
1656
|
+
background: inherit;
|
|
1657
|
+
color: inherit;
|
|
1658
|
+
border: inherit;
|
|
1659
|
+
box-shadow: inherit;
|
|
1660
|
+
transform: inherit;
|
|
1661
|
+
outline: none;
|
|
1662
|
+
outline-offset: 0;
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
.option-container.disabled {
|
|
1666
|
+
background: inherit;
|
|
1667
|
+
color: inherit;
|
|
1668
|
+
border: inherit;
|
|
1669
|
+
border-bottom: inherit;
|
|
1670
|
+
opacity: inherit;
|
|
1671
|
+
cursor: inherit;
|
|
1672
|
+
pointer-events: none;
|
|
1673
|
+
}
|
|
1626
1674
|
|
|
1627
1675
|
.option-content {
|
|
1628
1676
|
flex: 1;
|
|
@@ -1681,6 +1729,11 @@
|
|
|
1681
1729
|
justify-content: center;
|
|
1682
1730
|
width: var(--select-badge-remove-icon-size, 10px);
|
|
1683
1731
|
height: var(--select-badge-remove-icon-size, 10px);
|
|
1732
|
+
color: var(--select-badge-remove-icon-color, currentColor);
|
|
1733
|
+
font-size: var(--select-badge-remove-icon-font-size, inherit);
|
|
1734
|
+
line-height: var(--select-badge-remove-icon-line-height, 1);
|
|
1735
|
+
transform: var(--select-badge-remove-icon-transform, none);
|
|
1736
|
+
opacity: var(--select-badge-remove-icon-opacity, 1);
|
|
1684
1737
|
pointer-events: none;
|
|
1685
1738
|
}
|
|
1686
1739
|
|
|
@@ -1702,8 +1755,20 @@
|
|
|
1702
1755
|
`;
|
|
1703
1756
|
this._shadow.appendChild(style);
|
|
1704
1757
|
}
|
|
1758
|
+
_getDisabledBehavior() {
|
|
1759
|
+
const behavior = this._config.disabledBehavior ?? {};
|
|
1760
|
+
return {
|
|
1761
|
+
selectable: behavior.selectable === true,
|
|
1762
|
+
hoverable: behavior.hoverable === true,
|
|
1763
|
+
focusable: behavior.focusable === true,
|
|
1764
|
+
};
|
|
1765
|
+
}
|
|
1766
|
+
_isDisabledSelectionBlocked() {
|
|
1767
|
+
return Boolean(this._config.disabled) && !this._getDisabledBehavior().selectable;
|
|
1768
|
+
}
|
|
1705
1769
|
_render() {
|
|
1706
1770
|
const { item, index, selected, disabled, active, render, showRemoveButton, classMap } = this._config;
|
|
1771
|
+
const disabledBehavior = this._getDisabledBehavior();
|
|
1707
1772
|
// Clear container
|
|
1708
1773
|
this._container.innerHTML = '';
|
|
1709
1774
|
// Add part attribute
|
|
@@ -1732,7 +1797,7 @@
|
|
|
1732
1797
|
toggleClasses(this._container, [...selectedClasses, 'smilodon-option--selected'], false);
|
|
1733
1798
|
toggleClasses(this, [...selectedClasses, 'smilodon-option--selected'], false);
|
|
1734
1799
|
}
|
|
1735
|
-
if (active && !disabled) {
|
|
1800
|
+
if (active && (!disabled || disabledBehavior.focusable)) {
|
|
1736
1801
|
toggleClasses(this._container, [...activeClasses, 'smilodon-option--active'], true);
|
|
1737
1802
|
toggleClasses(this, [...activeClasses, 'smilodon-option--active'], true); // Make focus ring visible on host
|
|
1738
1803
|
}
|
|
@@ -1748,6 +1813,15 @@
|
|
|
1748
1813
|
toggleClasses(this._container, [...disabledClasses, 'smilodon-option--disabled'], false);
|
|
1749
1814
|
toggleClasses(this, [...disabledClasses, 'smilodon-option--disabled'], false);
|
|
1750
1815
|
}
|
|
1816
|
+
const interactiveDisabled = Boolean(disabled && (disabledBehavior.hoverable || disabledBehavior.selectable));
|
|
1817
|
+
const toggleBehaviorClass = (className, add) => {
|
|
1818
|
+
toggleClasses(this._container, [className], add);
|
|
1819
|
+
toggleClasses(this, [className], add);
|
|
1820
|
+
};
|
|
1821
|
+
toggleBehaviorClass('smilodon-option--disabled-interactive', interactiveDisabled);
|
|
1822
|
+
toggleBehaviorClass('smilodon-option--disabled-hoverable', Boolean(disabled && disabledBehavior.hoverable));
|
|
1823
|
+
toggleBehaviorClass('smilodon-option--disabled-focusable', Boolean(disabled && disabledBehavior.focusable));
|
|
1824
|
+
toggleBehaviorClass('smilodon-option--disabled-selectable', Boolean(disabled && disabledBehavior.selectable));
|
|
1751
1825
|
// Custom class name
|
|
1752
1826
|
if (this._config.className) {
|
|
1753
1827
|
const classes = this._config.className.split(' ').filter(Boolean);
|
|
@@ -1800,7 +1874,7 @@
|
|
|
1800
1874
|
// Set ARIA attributes and State attributes on Host
|
|
1801
1875
|
this.setAttribute('role', 'option');
|
|
1802
1876
|
this.setAttribute('aria-selected', String(selected));
|
|
1803
|
-
if (disabled) {
|
|
1877
|
+
if (disabled && !disabledBehavior.selectable) {
|
|
1804
1878
|
this.setAttribute('aria-disabled', 'true');
|
|
1805
1879
|
}
|
|
1806
1880
|
else {
|
|
@@ -1824,7 +1898,7 @@
|
|
|
1824
1898
|
const state = [];
|
|
1825
1899
|
if (selected)
|
|
1826
1900
|
state.push('selected');
|
|
1827
|
-
if (active && !disabled)
|
|
1901
|
+
if (active && (!disabled || disabledBehavior.focusable))
|
|
1828
1902
|
state.push('active');
|
|
1829
1903
|
if (state.length) {
|
|
1830
1904
|
this.dataset.smState = state.join(' ');
|
|
@@ -1844,7 +1918,7 @@
|
|
|
1844
1918
|
if (e.target === this._removeButton) {
|
|
1845
1919
|
return;
|
|
1846
1920
|
}
|
|
1847
|
-
if (!this.
|
|
1921
|
+
if (!this._isDisabledSelectionBlocked()) {
|
|
1848
1922
|
this._handleSelect();
|
|
1849
1923
|
}
|
|
1850
1924
|
});
|
|
@@ -1857,7 +1931,7 @@
|
|
|
1857
1931
|
}
|
|
1858
1932
|
// Keyboard handler
|
|
1859
1933
|
this.addEventListener('keydown', (e) => {
|
|
1860
|
-
if (this.
|
|
1934
|
+
if (this._isDisabledSelectionBlocked())
|
|
1861
1935
|
return;
|
|
1862
1936
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
1863
1937
|
e.preventDefault();
|
|
@@ -1948,7 +2022,7 @@
|
|
|
1948
2022
|
* Set active state
|
|
1949
2023
|
*/
|
|
1950
2024
|
setActive(active) {
|
|
1951
|
-
this._config.active = active && !this._config.disabled;
|
|
2025
|
+
this._config.active = active && (!this._config.disabled || this._getDisabledBehavior().focusable);
|
|
1952
2026
|
this._render();
|
|
1953
2027
|
}
|
|
1954
2028
|
/**
|
|
@@ -2016,6 +2090,8 @@
|
|
|
2016
2090
|
this._mirrorGlobalStylesForCustomOptions = false;
|
|
2017
2091
|
this._globalStylesObserver = null;
|
|
2018
2092
|
this._globalStylesContainer = null;
|
|
2093
|
+
this._themeContextObserver = null;
|
|
2094
|
+
this._globalStylesSyncToken = 0;
|
|
2019
2095
|
this._tracking = { events: [], styles: [], limitations: [] };
|
|
2020
2096
|
this._suppressBlurClose = false;
|
|
2021
2097
|
this._renderCycleId = 0;
|
|
@@ -2131,6 +2207,7 @@
|
|
|
2131
2207
|
return;
|
|
2132
2208
|
if (!this._mirrorGlobalStylesForCustomOptions)
|
|
2133
2209
|
return;
|
|
2210
|
+
this._setupThemeContextMirroring();
|
|
2134
2211
|
this._mirrorDocumentStylesIntoShadow();
|
|
2135
2212
|
if (this._globalStylesObserver)
|
|
2136
2213
|
return;
|
|
@@ -2149,6 +2226,10 @@
|
|
|
2149
2226
|
this._globalStylesObserver.disconnect();
|
|
2150
2227
|
this._globalStylesObserver = null;
|
|
2151
2228
|
}
|
|
2229
|
+
if (this._themeContextObserver) {
|
|
2230
|
+
this._themeContextObserver.disconnect();
|
|
2231
|
+
this._themeContextObserver = null;
|
|
2232
|
+
}
|
|
2152
2233
|
if (this._globalStylesContainer) {
|
|
2153
2234
|
this._globalStylesContainer.remove();
|
|
2154
2235
|
this._globalStylesContainer = null;
|
|
@@ -2165,34 +2246,232 @@
|
|
|
2165
2246
|
this._shadow.appendChild(this._globalStylesContainer);
|
|
2166
2247
|
}
|
|
2167
2248
|
const container = this._globalStylesContainer;
|
|
2168
|
-
|
|
2249
|
+
const syncToken = ++this._globalStylesSyncToken;
|
|
2169
2250
|
const styleNodes = Array.from(document.querySelectorAll('style,link[rel="stylesheet"]'));
|
|
2170
|
-
styleNodes.
|
|
2171
|
-
if (
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2251
|
+
void Promise.all(styleNodes.map((node, index) => this._createScopedGlobalStyleNode(node, index))).then((mirroredNodes) => {
|
|
2252
|
+
if (!this._globalStylesContainer || syncToken !== this._globalStylesSyncToken)
|
|
2253
|
+
return;
|
|
2254
|
+
container.replaceChildren(...mirroredNodes.filter((node) => Boolean(node)));
|
|
2255
|
+
this._syncMirroredThemeContext();
|
|
2256
|
+
});
|
|
2257
|
+
}
|
|
2258
|
+
_setupThemeContextMirroring() {
|
|
2259
|
+
if (typeof document === 'undefined')
|
|
2260
|
+
return;
|
|
2261
|
+
this._syncMirroredThemeContext();
|
|
2262
|
+
if (this._themeContextObserver)
|
|
2263
|
+
return;
|
|
2264
|
+
this._themeContextObserver = new MutationObserver(() => {
|
|
2265
|
+
this._syncMirroredThemeContext();
|
|
2266
|
+
});
|
|
2267
|
+
const targets = new Set([this, document.documentElement]);
|
|
2268
|
+
if (document.body) {
|
|
2269
|
+
targets.add(document.body);
|
|
2270
|
+
}
|
|
2271
|
+
let ancestor = this.parentElement;
|
|
2272
|
+
while (ancestor) {
|
|
2273
|
+
targets.add(ancestor);
|
|
2274
|
+
ancestor = ancestor.parentElement;
|
|
2275
|
+
}
|
|
2276
|
+
targets.forEach((target) => {
|
|
2277
|
+
this._themeContextObserver?.observe(target, {
|
|
2278
|
+
attributes: true,
|
|
2279
|
+
attributeFilter: ['class', 'dark-mode', 'darkmode', 'data-theme', 'theme'],
|
|
2280
|
+
});
|
|
2281
|
+
});
|
|
2282
|
+
}
|
|
2283
|
+
_syncMirroredThemeContext() {
|
|
2284
|
+
const scopeTarget = this._optionsContainer;
|
|
2285
|
+
if (!scopeTarget)
|
|
2286
|
+
return;
|
|
2287
|
+
const darkSelectors = [
|
|
2288
|
+
'.dark-mode',
|
|
2289
|
+
'.dark',
|
|
2290
|
+
'[dark-mode]',
|
|
2291
|
+
'[darkmode]',
|
|
2292
|
+
'[data-theme="dark"]',
|
|
2293
|
+
'[theme="dark"]',
|
|
2294
|
+
];
|
|
2295
|
+
const isDark = darkSelectors.some((selector) => this.matches(selector) || Boolean(this.closest(selector)))
|
|
2296
|
+
|| document.documentElement.matches('.dark-mode, .dark, [dark-mode], [darkmode], [data-theme="dark"], [theme="dark"]')
|
|
2297
|
+
|| Boolean(document.body?.matches('.dark-mode, .dark, [dark-mode], [darkmode], [data-theme="dark"], [theme="dark"]'));
|
|
2298
|
+
scopeTarget.classList.toggle('dark', isDark);
|
|
2299
|
+
scopeTarget.classList.toggle('dark-mode', isDark);
|
|
2300
|
+
if (isDark) {
|
|
2301
|
+
scopeTarget.setAttribute('dark-mode', '');
|
|
2302
|
+
scopeTarget.setAttribute('data-theme', 'dark');
|
|
2303
|
+
scopeTarget.setAttribute('theme', 'dark');
|
|
2304
|
+
}
|
|
2305
|
+
else {
|
|
2306
|
+
scopeTarget.removeAttribute('dark-mode');
|
|
2307
|
+
scopeTarget.removeAttribute('data-theme');
|
|
2308
|
+
scopeTarget.removeAttribute('theme');
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
async _createScopedGlobalStyleNode(node, index) {
|
|
2312
|
+
if (node instanceof HTMLStyleElement) {
|
|
2313
|
+
return this._buildScopedStyleElement(node.textContent || '', String(index));
|
|
2314
|
+
}
|
|
2315
|
+
if (node instanceof HTMLLinkElement && node.href) {
|
|
2316
|
+
try {
|
|
2317
|
+
const response = await fetch(node.href, {
|
|
2318
|
+
credentials: node.crossOrigin === 'use-credentials' ? 'include' : 'same-origin',
|
|
2319
|
+
mode: 'cors',
|
|
2320
|
+
});
|
|
2321
|
+
if (!response.ok) {
|
|
2322
|
+
return null;
|
|
2323
|
+
}
|
|
2324
|
+
const cssText = await response.text();
|
|
2325
|
+
return this._buildScopedStyleElement(cssText, String(index));
|
|
2326
|
+
}
|
|
2327
|
+
catch (_error) {
|
|
2328
|
+
return null;
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
return null;
|
|
2332
|
+
}
|
|
2333
|
+
_buildScopedStyleElement(cssText, id) {
|
|
2334
|
+
const scopedCss = this._scopeMirroredCssText(cssText);
|
|
2335
|
+
if (!scopedCss.trim())
|
|
2336
|
+
return null;
|
|
2337
|
+
const style = document.createElement('style');
|
|
2338
|
+
style.setAttribute('data-smilodon-global-style', id);
|
|
2339
|
+
style.textContent = scopedCss;
|
|
2340
|
+
return style;
|
|
2341
|
+
}
|
|
2342
|
+
_scopeMirroredCssText(cssText) {
|
|
2343
|
+
if (!cssText.trim())
|
|
2344
|
+
return '';
|
|
2345
|
+
try {
|
|
2346
|
+
if (typeof CSSStyleSheet !== 'undefined') {
|
|
2347
|
+
const sheet = new CSSStyleSheet();
|
|
2348
|
+
sheet.replaceSync(cssText);
|
|
2349
|
+
return this._serializeScopedCssRules(Array.from(sheet.cssRules));
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2352
|
+
catch (_error) {
|
|
2353
|
+
return '';
|
|
2354
|
+
}
|
|
2355
|
+
return '';
|
|
2356
|
+
}
|
|
2357
|
+
_serializeScopedCssRules(rules) {
|
|
2358
|
+
return rules.map((rule) => this._serializeScopedCssRule(rule)).filter(Boolean).join('\n');
|
|
2359
|
+
}
|
|
2360
|
+
_serializeScopedCssRule(rule) {
|
|
2361
|
+
if (rule instanceof CSSStyleRule) {
|
|
2362
|
+
const selectors = this._splitSelectorList(rule.selectorText)
|
|
2363
|
+
.map((selector) => this._scopeMirroredSelector(selector))
|
|
2364
|
+
.filter(Boolean);
|
|
2365
|
+
if (selectors.length === 0)
|
|
2366
|
+
return '';
|
|
2367
|
+
return `${selectors.join(', ')} { ${rule.style.cssText} }`;
|
|
2368
|
+
}
|
|
2369
|
+
if (rule instanceof CSSMediaRule) {
|
|
2370
|
+
const nested = this._serializeScopedCssRules(Array.from(rule.cssRules));
|
|
2371
|
+
return nested ? `@media ${rule.conditionText} { ${nested} }` : '';
|
|
2372
|
+
}
|
|
2373
|
+
if (typeof CSSSupportsRule !== 'undefined' && rule instanceof CSSSupportsRule) {
|
|
2374
|
+
const nested = this._serializeScopedCssRules(Array.from(rule.cssRules));
|
|
2375
|
+
return nested ? `@supports ${rule.conditionText} { ${nested} }` : '';
|
|
2376
|
+
}
|
|
2377
|
+
if (rule instanceof CSSFontFaceRule || rule instanceof CSSKeyframesRule) {
|
|
2378
|
+
return rule.cssText;
|
|
2379
|
+
}
|
|
2380
|
+
const nestedRule = rule;
|
|
2381
|
+
if (nestedRule.cssRules) {
|
|
2382
|
+
const nested = this._serializeScopedCssRules(Array.from(nestedRule.cssRules));
|
|
2383
|
+
if (!nested)
|
|
2384
|
+
return '';
|
|
2385
|
+
const ctorName = nestedRule.constructor?.name ?? '';
|
|
2386
|
+
if (ctorName.includes('Layer')) {
|
|
2387
|
+
return `@layer ${nestedRule.name ?? ''} { ${nested} }`;
|
|
2388
|
+
}
|
|
2389
|
+
if (ctorName.includes('Container')) {
|
|
2390
|
+
return `@container ${nestedRule.conditionText ?? ''} { ${nested} }`;
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
return '';
|
|
2394
|
+
}
|
|
2395
|
+
_splitSelectorList(selectorText) {
|
|
2396
|
+
const selectors = [];
|
|
2397
|
+
let current = '';
|
|
2398
|
+
let depthRound = 0;
|
|
2399
|
+
let depthSquare = 0;
|
|
2400
|
+
for (const char of selectorText) {
|
|
2401
|
+
if (char === '(')
|
|
2402
|
+
depthRound += 1;
|
|
2403
|
+
if (char === ')')
|
|
2404
|
+
depthRound = Math.max(0, depthRound - 1);
|
|
2405
|
+
if (char === '[')
|
|
2406
|
+
depthSquare += 1;
|
|
2407
|
+
if (char === ']')
|
|
2408
|
+
depthSquare = Math.max(0, depthSquare - 1);
|
|
2409
|
+
if (char === ',' && depthRound === 0 && depthSquare === 0) {
|
|
2410
|
+
if (current.trim())
|
|
2411
|
+
selectors.push(current.trim());
|
|
2412
|
+
current = '';
|
|
2413
|
+
continue;
|
|
2414
|
+
}
|
|
2415
|
+
current += char;
|
|
2416
|
+
}
|
|
2417
|
+
if (current.trim())
|
|
2418
|
+
selectors.push(current.trim());
|
|
2419
|
+
return selectors;
|
|
2420
|
+
}
|
|
2421
|
+
_scopeMirroredSelector(selector) {
|
|
2422
|
+
const scopeClass = `.${EnhancedSelect._MIRRORED_STYLES_SCOPE_CLASS}`;
|
|
2423
|
+
let scopedSelector = selector
|
|
2424
|
+
.replace(/(^|\s|>|\+|~)(:root|html|body)(?=\b|\s|[.#[:>+~]|$)/g, `$1${scopeClass}`);
|
|
2425
|
+
const themePatterns = [
|
|
2426
|
+
/\.dark-mode(?![\w-]|\\:)/g,
|
|
2427
|
+
/\.dark(?![\w-]|\\:)/g,
|
|
2428
|
+
/\[dark-mode\]/g,
|
|
2429
|
+
/\[darkmode\]/g,
|
|
2430
|
+
/\[data-theme=(?:"dark"|'dark'|dark)\]/g,
|
|
2431
|
+
/\[theme=(?:"dark"|'dark'|dark)\]/g,
|
|
2432
|
+
];
|
|
2433
|
+
let injectedThemeScope = false;
|
|
2434
|
+
themePatterns.forEach((pattern) => {
|
|
2435
|
+
scopedSelector = scopedSelector.replace(pattern, (match) => {
|
|
2436
|
+
injectedThemeScope = true;
|
|
2437
|
+
return `${match}${scopeClass}`;
|
|
2438
|
+
});
|
|
2439
|
+
});
|
|
2440
|
+
if (!scopedSelector.includes(EnhancedSelect._MIRRORED_STYLES_SCOPE_CLASS) && !injectedThemeScope) {
|
|
2441
|
+
scopedSelector = `${scopeClass} ${scopedSelector}`;
|
|
2442
|
+
}
|
|
2443
|
+
return scopedSelector;
|
|
2444
|
+
}
|
|
2445
|
+
_normalizeCustomOptionAccessibility(optionEl, meta) {
|
|
2446
|
+
if (!optionEl.hasAttribute('aria-label') && !optionEl.hasAttribute('aria-labelledby')) {
|
|
2447
|
+
optionEl.setAttribute('aria-label', meta.label);
|
|
2448
|
+
}
|
|
2449
|
+
const nestedFocusableSelectors = [
|
|
2450
|
+
'a[href]',
|
|
2451
|
+
'button',
|
|
2452
|
+
'input',
|
|
2453
|
+
'select',
|
|
2454
|
+
'textarea',
|
|
2455
|
+
'summary',
|
|
2456
|
+
'[tabindex]',
|
|
2457
|
+
'[contenteditable=""]',
|
|
2458
|
+
'[contenteditable="true"]',
|
|
2459
|
+
'[role="button"]',
|
|
2460
|
+
'[role="link"]',
|
|
2461
|
+
'[role="checkbox"]',
|
|
2462
|
+
'[role="switch"]',
|
|
2463
|
+
'[role="radio"]',
|
|
2464
|
+
'[role="textbox"]',
|
|
2465
|
+
].join(', ');
|
|
2466
|
+
optionEl.querySelectorAll(nestedFocusableSelectors).forEach((child) => {
|
|
2467
|
+
if (child === optionEl)
|
|
2176
2468
|
return;
|
|
2469
|
+
child.tabIndex = -1;
|
|
2470
|
+
if (!child.hasAttribute('data-smilodon-keep-role')) {
|
|
2471
|
+
child.setAttribute('role', 'presentation');
|
|
2177
2472
|
}
|
|
2178
|
-
if (
|
|
2179
|
-
|
|
2180
|
-
clonedLink.rel = 'stylesheet';
|
|
2181
|
-
clonedLink.href = node.href;
|
|
2182
|
-
if (node.media)
|
|
2183
|
-
clonedLink.media = node.media;
|
|
2184
|
-
if (node.crossOrigin)
|
|
2185
|
-
clonedLink.crossOrigin = node.crossOrigin;
|
|
2186
|
-
if (node.referrerPolicy)
|
|
2187
|
-
clonedLink.referrerPolicy = node.referrerPolicy;
|
|
2188
|
-
if (node.integrity)
|
|
2189
|
-
clonedLink.integrity = node.integrity;
|
|
2190
|
-
if (node.type)
|
|
2191
|
-
clonedLink.type = node.type;
|
|
2192
|
-
if (node.nonce)
|
|
2193
|
-
clonedLink.nonce = node.nonce;
|
|
2194
|
-
clonedLink.setAttribute('data-smilodon-global-link', String(index));
|
|
2195
|
-
container.appendChild(clonedLink);
|
|
2473
|
+
if ((meta.disabled || child.matches('button, input, select, textarea, summary, a[href]')) && !child.hasAttribute('data-smilodon-keep-aria')) {
|
|
2474
|
+
child.setAttribute('aria-hidden', 'true');
|
|
2196
2475
|
}
|
|
2197
2476
|
});
|
|
2198
2477
|
}
|
|
@@ -2253,6 +2532,20 @@
|
|
|
2253
2532
|
this._setCssVariable(variableName, styleConfig?.[styleKey]);
|
|
2254
2533
|
});
|
|
2255
2534
|
}
|
|
2535
|
+
_getDisabledOptionBehavior() {
|
|
2536
|
+
const behavior = this._config.selection.disabledOptionBehavior ?? {};
|
|
2537
|
+
return {
|
|
2538
|
+
selectable: behavior.selectable === true,
|
|
2539
|
+
hoverable: behavior.hoverable === true,
|
|
2540
|
+
focusable: behavior.focusable === true,
|
|
2541
|
+
};
|
|
2542
|
+
}
|
|
2543
|
+
_isDisabledOptionSelectable(item) {
|
|
2544
|
+
return Boolean(item?.disabled) && this._getDisabledOptionBehavior().selectable;
|
|
2545
|
+
}
|
|
2546
|
+
_isOptionSelectionBlocked(item) {
|
|
2547
|
+
return Boolean(item?.disabled) && !this._isDisabledOptionSelectable(item);
|
|
2548
|
+
}
|
|
2256
2549
|
_syncStyleConfigVariables() {
|
|
2257
2550
|
const styles = this._config.styles;
|
|
2258
2551
|
this._applyStyleVariableMap(styles.option, {
|
|
@@ -2310,6 +2603,21 @@
|
|
|
2310
2603
|
opacity: '--select-option-disabled-opacity',
|
|
2311
2604
|
cursor: '--select-option-disabled-cursor',
|
|
2312
2605
|
});
|
|
2606
|
+
this._applyStyleVariableMap(styles.selectedIndicator, {
|
|
2607
|
+
width: '--select-option-selected-indicator-width',
|
|
2608
|
+
height: '--select-option-selected-indicator-height',
|
|
2609
|
+
background: '--select-option-selected-indicator-bg',
|
|
2610
|
+
backgroundColor: '--select-option-selected-indicator-bg',
|
|
2611
|
+
borderRadius: '--select-option-selected-indicator-radius',
|
|
2612
|
+
left: '--select-option-selected-indicator-left',
|
|
2613
|
+
right: '--select-option-selected-indicator-right',
|
|
2614
|
+
top: '--select-option-selected-indicator-top',
|
|
2615
|
+
transform: '--select-option-selected-indicator-transform',
|
|
2616
|
+
animation: '--select-option-selected-indicator-animation',
|
|
2617
|
+
});
|
|
2618
|
+
this._setCssVariable('--select-option-selected-indicator-display', this._config.selection.showSelectedIndicator === false
|
|
2619
|
+
? 'none'
|
|
2620
|
+
: styles.selectedIndicator?.display);
|
|
2313
2621
|
this._applyStyleVariableMap(styles.badge, {
|
|
2314
2622
|
width: '--select-badge-width',
|
|
2315
2623
|
minWidth: '--select-badge-min-width',
|
|
@@ -2368,6 +2676,15 @@
|
|
|
2368
2676
|
fontSize: '--select-badge-remove-font-size',
|
|
2369
2677
|
fontWeight: '--select-badge-remove-font-weight',
|
|
2370
2678
|
});
|
|
2679
|
+
this._applyStyleVariableMap(styles.badgeRemoveIcon, {
|
|
2680
|
+
width: '--select-badge-remove-icon-size',
|
|
2681
|
+
height: '--select-badge-remove-icon-size',
|
|
2682
|
+
color: '--select-badge-remove-icon-color',
|
|
2683
|
+
fontSize: '--select-badge-remove-icon-font-size',
|
|
2684
|
+
lineHeight: '--select-badge-remove-icon-line-height',
|
|
2685
|
+
transform: '--select-badge-remove-icon-transform',
|
|
2686
|
+
opacity: '--select-badge-remove-icon-opacity',
|
|
2687
|
+
});
|
|
2371
2688
|
this._applyStyleVariableMap(styles.badgeRemoveHover, {
|
|
2372
2689
|
background: '--select-badge-remove-hover-bg',
|
|
2373
2690
|
backgroundColor: '--select-badge-remove-hover-bg',
|
|
@@ -2468,11 +2785,24 @@
|
|
|
2468
2785
|
this._inputContainer.style.removeProperty('--select-multi-input-align-content-config');
|
|
2469
2786
|
return;
|
|
2470
2787
|
}
|
|
2471
|
-
const
|
|
2472
|
-
const
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2788
|
+
const configuredMaxHeight = this._config.multiSelectDisplay?.maxHeight;
|
|
2789
|
+
const defaultMaxHeight = '160px';
|
|
2790
|
+
let maxHeight = configuredMaxHeight ?? 'none';
|
|
2791
|
+
let overflowX = this._config.multiSelectDisplay?.overflowX ?? 'hidden';
|
|
2792
|
+
let overflowY = this._config.multiSelectDisplay?.overflowY ?? 'hidden';
|
|
2793
|
+
let flexWrap = 'wrap';
|
|
2794
|
+
let alignContent = 'flex-start';
|
|
2795
|
+
if (mode === 'vertical') {
|
|
2796
|
+
maxHeight = configuredMaxHeight ?? defaultMaxHeight;
|
|
2797
|
+
overflowY = this._config.multiSelectDisplay?.overflowY ?? 'auto';
|
|
2798
|
+
}
|
|
2799
|
+
else if (mode === 'horizontal') {
|
|
2800
|
+
maxHeight = configuredMaxHeight ?? defaultMaxHeight;
|
|
2801
|
+
overflowX = this._config.multiSelectDisplay?.overflowX ?? 'auto';
|
|
2802
|
+
overflowY = this._config.multiSelectDisplay?.overflowY ?? 'hidden';
|
|
2803
|
+
flexWrap = 'nowrap';
|
|
2804
|
+
alignContent = 'center';
|
|
2805
|
+
}
|
|
2476
2806
|
this._inputContainer.setAttribute('data-multi-scroll-mode', mode);
|
|
2477
2807
|
this._inputContainer.setAttribute('data-drag-scroll', String(dragEnabled && mode === 'horizontal'));
|
|
2478
2808
|
this._inputContainer.style.setProperty('--select-multi-input-max-height-config', maxHeight);
|
|
@@ -2656,7 +2986,7 @@
|
|
|
2656
2986
|
}
|
|
2657
2987
|
_createOptionsContainer() {
|
|
2658
2988
|
const container = document.createElement('div');
|
|
2659
|
-
container.className =
|
|
2989
|
+
container.className = `options-container ${EnhancedSelect._MIRRORED_STYLES_SCOPE_CLASS}`;
|
|
2660
2990
|
return container;
|
|
2661
2991
|
}
|
|
2662
2992
|
_createLiveRegion() {
|
|
@@ -2755,6 +3085,11 @@
|
|
|
2755
3085
|
--select-badge-letter-spacing: 0.01em;
|
|
2756
3086
|
--select-badge-hover-shadow: var(--select-shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.15);
|
|
2757
3087
|
--select-badge-remove-icon-size: 10px;
|
|
3088
|
+
--select-badge-remove-icon-color: currentColor;
|
|
3089
|
+
--select-badge-remove-icon-font-size: inherit;
|
|
3090
|
+
--select-badge-remove-icon-line-height: 1;
|
|
3091
|
+
--select-badge-remove-icon-transform: none;
|
|
3092
|
+
--select-badge-remove-icon-opacity: 1;
|
|
2758
3093
|
--select-badge-remove-focus-outline: 2px solid rgba(255, 255, 255, 0.5);
|
|
2759
3094
|
--select-badge-remove-focus-offset: 1px;
|
|
2760
3095
|
--select-badge-remove-hover-transform: scale(1.15) rotate(90deg);
|
|
@@ -2773,9 +3108,11 @@
|
|
|
2773
3108
|
--select-multi-input-overflow-y: auto;
|
|
2774
3109
|
--select-multi-input-flex-wrap: wrap;
|
|
2775
3110
|
--select-multi-input-align-content: flex-start;
|
|
3111
|
+
--select-multi-input-horizontal-height: var(--select-input-min-height, 48px);
|
|
2776
3112
|
--select-multi-input-horizontal-input-flex: 0 0 var(--select-multi-input-min-width, 96px);
|
|
2777
3113
|
--select-multi-input-horizontal-cursor: grab;
|
|
2778
3114
|
--select-multi-input-horizontal-active-cursor: grabbing;
|
|
3115
|
+
--select-multi-input-end-gap: 12px;
|
|
2779
3116
|
--select-multi-separator-inset-block: 10px;
|
|
2780
3117
|
--select-multi-separator-height: auto;
|
|
2781
3118
|
--select-multi-action-surface-bg: var(--select-input-bg, var(--select-surface));
|
|
@@ -2826,8 +3163,16 @@
|
|
|
2826
3163
|
--select-multi-container-padding: 6px;
|
|
2827
3164
|
--select-option-disabled-opacity: 0.5;
|
|
2828
3165
|
--select-option-disabled-cursor: not-allowed;
|
|
3166
|
+
--select-option-active-outline: none;
|
|
2829
3167
|
--select-option-active-outline-offset: -2px;
|
|
3168
|
+
--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%)));
|
|
3169
|
+
--select-option-selected-active-color: var(--select-option-selected-hover-color, var(--select-option-selected-color, var(--select-accent)));
|
|
3170
|
+
--select-option-selected-active-border: var(--select-option-selected-hover-border, var(--select-option-selected-border, var(--select-option-border, none)));
|
|
3171
|
+
--select-option-selected-active-shadow: var(--select-option-active-shadow, none);
|
|
3172
|
+
--select-option-selected-active-transform: var(--select-option-active-transform, none);
|
|
3173
|
+
--select-option-selected-active-outline: none;
|
|
2830
3174
|
--select-option-selected-active-outline-offset: -2px;
|
|
3175
|
+
--select-option-selected-indicator-display: block;
|
|
2831
3176
|
--select-option-selected-indicator-width: 3px;
|
|
2832
3177
|
--select-option-selected-indicator-height: 60%;
|
|
2833
3178
|
--select-option-selected-indicator-bg: var(--select-accent);
|
|
@@ -2840,8 +3185,8 @@
|
|
|
2840
3185
|
--select-option-selected-indicator-to-height: 60%;
|
|
2841
3186
|
--select-option-selected-indicator-from-opacity: 0;
|
|
2842
3187
|
--select-option-selected-indicator-to-opacity: 1;
|
|
2843
|
-
--select-option-pressed-transform:
|
|
2844
|
-
--select-option-selected-pressed-transform:
|
|
3188
|
+
--select-option-pressed-transform: none;
|
|
3189
|
+
--select-option-selected-pressed-transform: none;
|
|
2845
3190
|
--select-button-hover-transform: translateY(-1px);
|
|
2846
3191
|
--select-button-active-transform: translateY(0) scale(0.98);
|
|
2847
3192
|
--select-button-font-weight: 550;
|
|
@@ -3003,6 +3348,11 @@
|
|
|
3003
3348
|
justify-content: center;
|
|
3004
3349
|
width: var(--select-badge-remove-icon-size, 10px);
|
|
3005
3350
|
height: var(--select-badge-remove-icon-size, 10px);
|
|
3351
|
+
color: var(--select-badge-remove-icon-color, currentColor);
|
|
3352
|
+
font-size: var(--select-badge-remove-icon-font-size, inherit);
|
|
3353
|
+
line-height: var(--select-badge-remove-icon-line-height, 1);
|
|
3354
|
+
transform: var(--select-badge-remove-icon-transform, none);
|
|
3355
|
+
opacity: var(--select-badge-remove-icon-opacity, 1);
|
|
3006
3356
|
pointer-events: none;
|
|
3007
3357
|
}
|
|
3008
3358
|
|
|
@@ -3108,13 +3458,26 @@
|
|
|
3108
3458
|
|
|
3109
3459
|
.input-container.input-container--multi {
|
|
3110
3460
|
max-height: var(--select-multi-input-max-height, var(--select-multi-input-max-height-config, var(--select-input-max-height, 160px)));
|
|
3461
|
+
--select-multi-action-area-width: var(--select-arrow-width, 42px);
|
|
3111
3462
|
}
|
|
3112
3463
|
|
|
3113
3464
|
.input-container.input-container--multi .input-content {
|
|
3465
|
+
flex: 1 1 calc(100% - var(--select-multi-action-area-width, var(--select-arrow-width, 42px)));
|
|
3466
|
+
width: calc(100% - var(--select-multi-action-area-width, var(--select-arrow-width, 42px)));
|
|
3467
|
+
max-width: calc(100% - var(--select-multi-action-area-width, var(--select-arrow-width, 42px)));
|
|
3114
3468
|
flex-wrap: var(--select-multi-input-flex-wrap, var(--select-multi-input-flex-wrap-config, wrap));
|
|
3115
3469
|
align-content: var(--select-multi-input-align-content, var(--select-multi-input-align-content-config, flex-start));
|
|
3116
3470
|
overflow-x: var(--select-multi-input-overflow-x, var(--select-multi-input-overflow-x-config, hidden));
|
|
3117
3471
|
overflow-y: var(--select-multi-input-overflow-y, var(--select-multi-input-overflow-y-config, auto));
|
|
3472
|
+
padding-inline-end: var(--select-multi-input-end-gap, 12px);
|
|
3473
|
+
}
|
|
3474
|
+
|
|
3475
|
+
.input-container.input-container--multi .input-content .selection-badge {
|
|
3476
|
+
flex: 0 0 auto;
|
|
3477
|
+
}
|
|
3478
|
+
|
|
3479
|
+
.input-container.input-container--multi.has-clear-control .input-content {
|
|
3480
|
+
--select-multi-action-area-width: calc(var(--select-arrow-right-with-clear, 34px) + var(--select-arrow-width, 42px));
|
|
3118
3481
|
}
|
|
3119
3482
|
|
|
3120
3483
|
.input-container.input-container--multi::after {
|
|
@@ -3125,17 +3488,31 @@
|
|
|
3125
3488
|
|
|
3126
3489
|
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"] {
|
|
3127
3490
|
align-items: stretch;
|
|
3491
|
+
height: var(--select-multi-input-horizontal-height, var(--select-input-min-height, 48px));
|
|
3492
|
+
min-height: var(--select-multi-input-horizontal-height, var(--select-input-min-height, 48px));
|
|
3493
|
+
max-height: var(--select-multi-input-horizontal-height, var(--select-input-min-height, 48px));
|
|
3494
|
+
overflow: hidden;
|
|
3128
3495
|
}
|
|
3129
3496
|
|
|
3130
3497
|
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .input-content {
|
|
3498
|
+
flex: 1 1 100%;
|
|
3499
|
+
width: 100%;
|
|
3500
|
+
max-width: 100%;
|
|
3501
|
+
min-height: 0;
|
|
3502
|
+
height: 100%;
|
|
3131
3503
|
cursor: var(--select-multi-input-horizontal-cursor, grab);
|
|
3504
|
+
align-items: center;
|
|
3505
|
+
align-content: center;
|
|
3506
|
+
flex-wrap: nowrap;
|
|
3132
3507
|
overflow-y: hidden;
|
|
3133
3508
|
overscroll-behavior-x: contain;
|
|
3134
|
-
|
|
3509
|
+
overscroll-behavior-y: none;
|
|
3510
|
+
padding-inline-end: 0;
|
|
3511
|
+
scroll-padding-inline-end: var(--select-multi-action-area-width, var(--select-arrow-width, 42px));
|
|
3135
3512
|
}
|
|
3136
3513
|
|
|
3137
3514
|
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"].has-clear-control .input-content {
|
|
3138
|
-
|
|
3515
|
+
--select-multi-action-area-width: calc(var(--select-arrow-right-with-clear, 34px) + var(--select-arrow-width, 42px));
|
|
3139
3516
|
}
|
|
3140
3517
|
|
|
3141
3518
|
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"]::after {
|
|
@@ -3147,8 +3524,10 @@
|
|
|
3147
3524
|
user-select: none;
|
|
3148
3525
|
}
|
|
3149
3526
|
|
|
3150
|
-
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .
|
|
3527
|
+
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .selection-badge {
|
|
3151
3528
|
flex: 0 0 auto;
|
|
3529
|
+
margin-top: 0;
|
|
3530
|
+
margin-bottom: 0;
|
|
3152
3531
|
}
|
|
3153
3532
|
|
|
3154
3533
|
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .input-content > .select-input,
|
|
@@ -3177,15 +3556,6 @@
|
|
|
3177
3556
|
left: var(--select-arrow-right-with-clear, 34px);
|
|
3178
3557
|
}
|
|
3179
3558
|
|
|
3180
|
-
:host([dir="rtl"]) .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .input-content {
|
|
3181
|
-
padding-right: 0;
|
|
3182
|
-
padding-left: calc(var(--select-arrow-width, 42px) + var(--select-multi-horizontal-end-gap, 12px));
|
|
3183
|
-
}
|
|
3184
|
-
|
|
3185
|
-
:host([dir="rtl"]) .input-container.input-container--multi[data-multi-scroll-mode="horizontal"].has-clear-control .input-content {
|
|
3186
|
-
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));
|
|
3187
|
-
}
|
|
3188
|
-
|
|
3189
3559
|
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .clear-control-button {
|
|
3190
3560
|
background: var(--select-multi-action-surface-bg, var(--select-input-bg, var(--select-surface)));
|
|
3191
3561
|
z-index: 4;
|
|
@@ -3574,7 +3944,8 @@
|
|
|
3574
3944
|
margin: var(--select-option-margin);
|
|
3575
3945
|
}
|
|
3576
3946
|
|
|
3577
|
-
.option:hover
|
|
3947
|
+
.option:hover:not(.disabled):not(.smilodon-option--disabled),
|
|
3948
|
+
.option.smilodon-option--disabled-hoverable:hover {
|
|
3578
3949
|
background: var(--select-option-hover-bg, var(--select-surface-elevated));
|
|
3579
3950
|
border: var(--select-option-hover-border, var(--select-option-border, none));
|
|
3580
3951
|
color: var(--select-option-hover-color, var(--select-text));
|
|
@@ -3589,7 +3960,8 @@
|
|
|
3589
3960
|
}
|
|
3590
3961
|
|
|
3591
3962
|
.option.selected::before {
|
|
3592
|
-
content: '';
|
|
3963
|
+
content: var(--select-option-selected-indicator-content, '');
|
|
3964
|
+
display: var(--select-option-selected-indicator-display, block);
|
|
3593
3965
|
position: absolute;
|
|
3594
3966
|
left: var(--select-option-selected-indicator-left);
|
|
3595
3967
|
top: var(--select-option-selected-indicator-top);
|
|
@@ -3624,35 +3996,50 @@
|
|
|
3624
3996
|
color: var(--select-option-selected-hover-color, var(--select-option-selected-color, var(--select-accent)));
|
|
3625
3997
|
}
|
|
3626
3998
|
|
|
3627
|
-
.option.active:not(.selected):not(.disabled)
|
|
3999
|
+
.option.active:not(.selected):not(.disabled):not(.smilodon-option--disabled),
|
|
4000
|
+
.option.active.smilodon-option--disabled-focusable:not(.selected) {
|
|
3628
4001
|
background: var(--select-option-active-bg, var(--select-surface-elevated));
|
|
3629
4002
|
color: var(--select-option-active-color, var(--select-option-hover-color, var(--select-option-color, var(--select-text))));
|
|
3630
4003
|
border: var(--select-option-active-border, var(--select-option-hover-border, var(--select-option-border, none)));
|
|
3631
|
-
outline: var(--select-option-active-outline,
|
|
4004
|
+
outline: var(--select-option-active-outline, none);
|
|
3632
4005
|
outline-offset: var(--select-option-active-outline-offset);
|
|
3633
4006
|
box-shadow: var(--select-option-active-shadow, none);
|
|
3634
4007
|
transform: var(--select-option-active-transform, none);
|
|
3635
4008
|
}
|
|
3636
4009
|
|
|
3637
|
-
.option.selected.active:not(.disabled)
|
|
3638
|
-
|
|
4010
|
+
.option.selected.active:not(.disabled):not(.smilodon-option--disabled),
|
|
4011
|
+
.option.selected.active.smilodon-option--disabled-focusable {
|
|
4012
|
+
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%))));
|
|
4013
|
+
color: var(--select-option-selected-active-color, var(--select-option-selected-hover-color, var(--select-option-selected-color, var(--select-accent))));
|
|
4014
|
+
border: var(--select-option-selected-active-border, var(--select-option-selected-hover-border, var(--select-option-selected-border, var(--select-option-border, none))));
|
|
4015
|
+
outline: var(--select-option-selected-active-outline, var(--select-option-active-outline, none));
|
|
3639
4016
|
outline-offset: var(--select-option-selected-active-outline-offset);
|
|
4017
|
+
box-shadow: var(--select-option-selected-active-shadow, var(--select-option-active-shadow, none));
|
|
4018
|
+
transform: var(--select-option-selected-active-transform, var(--select-option-active-transform, none));
|
|
3640
4019
|
}
|
|
3641
4020
|
|
|
3642
|
-
.option.disabled
|
|
4021
|
+
.option.disabled,
|
|
4022
|
+
.option.smilodon-option--disabled {
|
|
3643
4023
|
background: var(--select-option-disabled-bg, var(--select-option-bg, transparent));
|
|
3644
4024
|
color: var(--select-option-disabled-color, var(--select-text-muted));
|
|
3645
4025
|
border: var(--select-option-disabled-border, var(--select-option-border, none));
|
|
3646
4026
|
opacity: var(--select-option-disabled-opacity, 0.5);
|
|
3647
4027
|
cursor: var(--select-option-disabled-cursor, not-allowed);
|
|
4028
|
+
pointer-events: var(--select-option-disabled-pointer-events, none);
|
|
4029
|
+
}
|
|
4030
|
+
|
|
4031
|
+
.option.smilodon-option--disabled-interactive {
|
|
4032
|
+
pointer-events: auto;
|
|
3648
4033
|
}
|
|
3649
4034
|
|
|
3650
|
-
.option:active:not(.selected)
|
|
4035
|
+
.option:active:not(.selected):not(.disabled):not(.smilodon-option--disabled),
|
|
4036
|
+
.option.smilodon-option--disabled-selectable:active:not(.selected) {
|
|
3651
4037
|
background: var(--select-option-pressed-bg, rgba(15, 52, 96, 0.08));
|
|
3652
4038
|
transform: var(--select-option-pressed-transform);
|
|
3653
4039
|
}
|
|
3654
4040
|
|
|
3655
|
-
.option.selected:active
|
|
4041
|
+
.option.selected:active:not(.disabled):not(.smilodon-option--disabled),
|
|
4042
|
+
.option.selected.smilodon-option--disabled-selectable:active {
|
|
3656
4043
|
transform: var(--select-option-selected-pressed-transform);
|
|
3657
4044
|
}
|
|
3658
4045
|
|
|
@@ -4228,7 +4615,7 @@
|
|
|
4228
4615
|
continue;
|
|
4229
4616
|
}
|
|
4230
4617
|
}
|
|
4231
|
-
if (option && !option.hasAttribute('aria-disabled')) {
|
|
4618
|
+
if (option && (!option.hasAttribute('aria-disabled') || option.classList.contains('smilodon-option--disabled-selectable'))) {
|
|
4232
4619
|
const indexStr = option.getAttribute('data-sm-index') ?? option.getAttribute('data-index');
|
|
4233
4620
|
const index = Number(indexStr);
|
|
4234
4621
|
if (!Number.isNaN(index)) {
|
|
@@ -4672,7 +5059,7 @@
|
|
|
4672
5059
|
}
|
|
4673
5060
|
_setActive(index) {
|
|
4674
5061
|
const option = this._getOptionElementByIndex(index);
|
|
4675
|
-
if (!option || option.getAttribute('aria-disabled') === 'true') {
|
|
5062
|
+
if (!option || (option.getAttribute('aria-disabled') === 'true' && !option.classList.contains('smilodon-option--disabled-focusable'))) {
|
|
4676
5063
|
return;
|
|
4677
5064
|
}
|
|
4678
5065
|
// Clear previous active state
|
|
@@ -4720,7 +5107,7 @@
|
|
|
4720
5107
|
// Only return elements with data-index or data-sm-selectable attributes
|
|
4721
5108
|
return Array.from(this._optionsContainer.children).filter((child) => {
|
|
4722
5109
|
return (child.hasAttribute('data-index') || child.hasAttribute('data-sm-selectable'))
|
|
4723
|
-
&& child.getAttribute('aria-disabled') !== 'true';
|
|
5110
|
+
&& (child.getAttribute('aria-disabled') !== 'true' || child.classList.contains('smilodon-option--disabled-focusable'));
|
|
4724
5111
|
});
|
|
4725
5112
|
}
|
|
4726
5113
|
_getSelectableOptionIndices() {
|
|
@@ -4775,6 +5162,8 @@
|
|
|
4775
5162
|
// Check if it's a custom SelectOption or a lightweight DOM element
|
|
4776
5163
|
if ('getConfig' in option && typeof option.getConfig === 'function') {
|
|
4777
5164
|
const config = option.getConfig();
|
|
5165
|
+
if (this._isOptionSelectionBlocked(config.item))
|
|
5166
|
+
return;
|
|
4778
5167
|
this._state.selectedIndices.add(optionIndex);
|
|
4779
5168
|
this._state.selectedItems.set(optionIndex, config.item);
|
|
4780
5169
|
option.setSelected(true);
|
|
@@ -4782,7 +5171,7 @@
|
|
|
4782
5171
|
else {
|
|
4783
5172
|
// Lightweight option - get item from data attribute or state
|
|
4784
5173
|
const item = this._state.loadedItems[optionIndex];
|
|
4785
|
-
if (item) {
|
|
5174
|
+
if (item && !this._isOptionSelectionBlocked(item)) {
|
|
4786
5175
|
this._state.selectedIndices.add(optionIndex);
|
|
4787
5176
|
this._state.selectedItems.set(optionIndex, item);
|
|
4788
5177
|
option.classList.add('smilodon-option--selected');
|
|
@@ -4809,10 +5198,12 @@
|
|
|
4809
5198
|
break;
|
|
4810
5199
|
const item = this._state.loadedItems[i];
|
|
4811
5200
|
const optionEl = this._getOptionElementByIndex(i);
|
|
4812
|
-
if (optionEl?.getAttribute('aria-disabled') === 'true')
|
|
5201
|
+
if (optionEl?.getAttribute('aria-disabled') === 'true' && !optionEl.classList.contains('smilodon-option--disabled-selectable'))
|
|
4813
5202
|
continue;
|
|
4814
5203
|
if (!item)
|
|
4815
5204
|
continue;
|
|
5205
|
+
if (this._isOptionSelectionBlocked(item))
|
|
5206
|
+
continue;
|
|
4816
5207
|
this._state.selectedIndices.add(i);
|
|
4817
5208
|
this._state.selectedItems.set(i, item);
|
|
4818
5209
|
}
|
|
@@ -4850,6 +5241,9 @@
|
|
|
4850
5241
|
if (!item) {
|
|
4851
5242
|
return;
|
|
4852
5243
|
}
|
|
5244
|
+
if (this._isOptionSelectionBlocked(item)) {
|
|
5245
|
+
return;
|
|
5246
|
+
}
|
|
4853
5247
|
const isCurrentlySelected = this._state.selectedIndices.has(index);
|
|
4854
5248
|
// Keep active/focus styling aligned with the most recently interacted option.
|
|
4855
5249
|
// Without this, a previously selected item may retain active classes/styles
|
|
@@ -5003,6 +5397,9 @@
|
|
|
5003
5397
|
removeBtn.setAttribute('aria-label', `Remove ${getLabel(item)}`);
|
|
5004
5398
|
const removeIcon = document.createElement('span');
|
|
5005
5399
|
removeIcon.className = 'badge-remove-icon';
|
|
5400
|
+
if (this._config.styles.classNames?.badgeRemoveIcon) {
|
|
5401
|
+
removeIcon.classList.add(...this._config.styles.classNames.badgeRemoveIcon.split(' ').filter(Boolean));
|
|
5402
|
+
}
|
|
5006
5403
|
removeIcon.setAttribute('part', 'chip-remove-icon');
|
|
5007
5404
|
this._setIconContent(removeIcon, this._config.selection.removeButtonIcon, '×');
|
|
5008
5405
|
removeBtn.appendChild(removeIcon);
|
|
@@ -5379,7 +5776,7 @@
|
|
|
5379
5776
|
this._state.selectedIndices.clear();
|
|
5380
5777
|
this._state.selectedItems.clear();
|
|
5381
5778
|
this._state.loadedItems.forEach((item, index) => {
|
|
5382
|
-
if (values.includes(getValue(item))) {
|
|
5779
|
+
if (values.includes(getValue(item)) && !this._isOptionSelectionBlocked(item)) {
|
|
5383
5780
|
this._state.selectedIndices.add(index);
|
|
5384
5781
|
this._state.selectedItems.set(index, item);
|
|
5385
5782
|
}
|
|
@@ -5401,6 +5798,8 @@
|
|
|
5401
5798
|
this._state.selectedIndices.clear();
|
|
5402
5799
|
this._state.selectedItems.clear();
|
|
5403
5800
|
items.forEach((item, index) => {
|
|
5801
|
+
if (this._isOptionSelectionBlocked(item))
|
|
5802
|
+
return;
|
|
5404
5803
|
this._state.selectedIndices.add(index);
|
|
5405
5804
|
this._state.selectedItems.set(index, item);
|
|
5406
5805
|
});
|
|
@@ -5665,6 +6064,9 @@
|
|
|
5665
6064
|
if (this._config.styles.classNames?.groupHeader) {
|
|
5666
6065
|
header.classList.add(...this._config.styles.classNames.groupHeader.split(' ').filter(Boolean));
|
|
5667
6066
|
}
|
|
6067
|
+
if (!header.hasAttribute('role')) {
|
|
6068
|
+
header.setAttribute('role', 'presentation');
|
|
6069
|
+
}
|
|
5668
6070
|
header.setAttribute('part', 'group-header');
|
|
5669
6071
|
this._optionsContainer.appendChild(header);
|
|
5670
6072
|
group.options.forEach(item => {
|
|
@@ -5779,6 +6181,7 @@
|
|
|
5779
6181
|
_renderSingleOption(item, index, getValue, getLabel, targetContainer = this._optionsContainer) {
|
|
5780
6182
|
const isSelected = this._state.selectedIndices.has(index);
|
|
5781
6183
|
const isDisabled = Boolean(item?.disabled);
|
|
6184
|
+
const disabledBehavior = this._getDisabledOptionBehavior();
|
|
5782
6185
|
const optionId = `${this._uniqueId}-option-${index}`;
|
|
5783
6186
|
if (this._optionRenderer) {
|
|
5784
6187
|
const rendered = this._optionRenderer(item, index, this._rendererHelpers);
|
|
@@ -5790,6 +6193,7 @@
|
|
|
5790
6193
|
selected: isSelected,
|
|
5791
6194
|
active: this._state.activeIndex === index,
|
|
5792
6195
|
disabled: isDisabled,
|
|
6196
|
+
disabledBehavior,
|
|
5793
6197
|
id: optionId,
|
|
5794
6198
|
});
|
|
5795
6199
|
optionElement.setAttribute('dir', this._config.direction ?? 'ltr');
|
|
@@ -5802,6 +6206,7 @@
|
|
|
5802
6206
|
id: optionId,
|
|
5803
6207
|
selected: isSelected,
|
|
5804
6208
|
disabled: isDisabled,
|
|
6209
|
+
disabledBehavior,
|
|
5805
6210
|
active: this._state.activeIndex === index,
|
|
5806
6211
|
getValue,
|
|
5807
6212
|
getLabel,
|
|
@@ -5863,6 +6268,10 @@
|
|
|
5863
6268
|
const isSelected = meta.selected;
|
|
5864
6269
|
const isActive = meta.active;
|
|
5865
6270
|
const isDisabled = meta.disabled;
|
|
6271
|
+
const isDisabledSelectable = isDisabled && meta.disabledBehavior.selectable;
|
|
6272
|
+
const isDisabledHoverable = isDisabled && meta.disabledBehavior.hoverable;
|
|
6273
|
+
const isDisabledFocusable = isDisabled && meta.disabledBehavior.focusable;
|
|
6274
|
+
const isDisabledInteractive = isDisabled && (isDisabledSelectable || isDisabledHoverable);
|
|
5866
6275
|
// Resolve classes from classMap or defaults
|
|
5867
6276
|
const selectedClasses = (this.classMap?.selected ?? 'selected sm-selected').split(' ').filter(Boolean);
|
|
5868
6277
|
const activeClasses = (this.classMap?.active ?? 'active sm-active').split(' ').filter(Boolean);
|
|
@@ -5909,6 +6318,10 @@
|
|
|
5909
6318
|
optionEl.classList.remove(...this._config.styles.classNames.disabledOption.split(' ').filter(Boolean));
|
|
5910
6319
|
}
|
|
5911
6320
|
}
|
|
6321
|
+
optionEl.classList.toggle('smilodon-option--disabled-interactive', isDisabledInteractive);
|
|
6322
|
+
optionEl.classList.toggle('smilodon-option--disabled-hoverable', isDisabledHoverable);
|
|
6323
|
+
optionEl.classList.toggle('smilodon-option--disabled-focusable', isDisabledFocusable);
|
|
6324
|
+
optionEl.classList.toggle('smilodon-option--disabled-selectable', isDisabledSelectable);
|
|
5912
6325
|
// Data Attributes Contract
|
|
5913
6326
|
const state = [];
|
|
5914
6327
|
if (isSelected)
|
|
@@ -5940,11 +6353,8 @@
|
|
|
5940
6353
|
if (!optionEl.getAttribute('role')) {
|
|
5941
6354
|
optionEl.setAttribute('role', 'option');
|
|
5942
6355
|
}
|
|
5943
|
-
if (!optionEl.getAttribute('aria-label')) {
|
|
5944
|
-
optionEl.setAttribute('aria-label', meta.label);
|
|
5945
|
-
}
|
|
5946
6356
|
optionEl.setAttribute('aria-selected', String(meta.selected));
|
|
5947
|
-
if (meta.disabled) {
|
|
6357
|
+
if (meta.disabled && !meta.disabledBehavior.selectable) {
|
|
5948
6358
|
optionEl.setAttribute('aria-disabled', 'true');
|
|
5949
6359
|
}
|
|
5950
6360
|
else {
|
|
@@ -5959,6 +6369,10 @@
|
|
|
5959
6369
|
// Re-attaching here causes the double-click toggle bug if a child component fails to stopPropagation.
|
|
5960
6370
|
this._customOptionBoundElements.add(optionEl);
|
|
5961
6371
|
}
|
|
6372
|
+
this._normalizeCustomOptionAccessibility(optionEl, {
|
|
6373
|
+
label: meta.label,
|
|
6374
|
+
disabled: meta.disabled,
|
|
6375
|
+
});
|
|
5962
6376
|
return optionEl;
|
|
5963
6377
|
}
|
|
5964
6378
|
_addLoadMoreTrigger() {
|
|
@@ -5993,6 +6407,7 @@
|
|
|
5993
6407
|
}
|
|
5994
6408
|
/** live set of all connected instances; used to auto-close siblings */
|
|
5995
6409
|
EnhancedSelect._instances = new Set();
|
|
6410
|
+
EnhancedSelect._MIRRORED_STYLES_SCOPE_CLASS = 'smilodon-mirrored-styles-scope';
|
|
5996
6411
|
// Register custom element
|
|
5997
6412
|
if (!customElements.get('enhanced-select')) {
|
|
5998
6413
|
customElements.define('enhanced-select', EnhancedSelect);
|