@smilodon/core 1.5.5 → 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 +138 -8
- package/dist/index.cjs +293 -88
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +293 -88
- 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 +293 -88
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/src/components/enhanced-select.d.ts +3 -0
- package/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.js
CHANGED
|
@@ -1346,8 +1346,14 @@ const defaultConfig = {
|
|
|
1346
1346
|
selection: {
|
|
1347
1347
|
mode: 'single',
|
|
1348
1348
|
allowDeselect: false,
|
|
1349
|
+
disabledOptionBehavior: {
|
|
1350
|
+
selectable: false,
|
|
1351
|
+
hoverable: false,
|
|
1352
|
+
focusable: false,
|
|
1353
|
+
},
|
|
1349
1354
|
maxSelections: 0,
|
|
1350
1355
|
showRemoveButton: true,
|
|
1356
|
+
showSelectedIndicator: true,
|
|
1351
1357
|
removeButtonIcon: '×',
|
|
1352
1358
|
closeOnSelect: true,
|
|
1353
1359
|
toggleOnTriggerClick: true,
|
|
@@ -1524,53 +1530,18 @@ class SelectOption extends HTMLElement {
|
|
|
1524
1530
|
display: block;
|
|
1525
1531
|
position: relative;
|
|
1526
1532
|
font: inherit;
|
|
1527
|
-
color: inherit;
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1530
|
-
/* Allow authors to style selected state from outside the shadow root
|
|
1531
|
-
by setting attributes/classes on the host element. This mirrors the
|
|
1532
|
-
internal .option-container.selected rules but reads the same CSS
|
|
1533
|
-
custom properties so themes can fully control selected appearance. */
|
|
1534
|
-
:host([aria-selected="true"]) .option-container,
|
|
1535
|
-
:host(.smilodon-option--selected) .option-container {
|
|
1536
|
-
background: var(--select-option-selected-bg, #e3f2fd);
|
|
1537
|
-
color: var(--select-option-selected-color, #1976d2);
|
|
1538
|
-
border: var(--select-option-selected-border, var(--select-option-border, none));
|
|
1539
|
-
border-bottom: var(--select-option-selected-border-bottom, var(--select-option-border-bottom, none));
|
|
1540
|
-
border-radius: var(--select-option-selected-border-radius, var(--select-option-border-radius, 0));
|
|
1541
|
-
box-shadow: var(--select-option-selected-shadow, var(--select-option-shadow, none));
|
|
1542
|
-
transform: var(--select-option-selected-transform, var(--select-option-transform, none));
|
|
1543
|
-
}
|
|
1544
|
-
|
|
1545
|
-
:host([aria-selected="true"]) .option-container:hover,
|
|
1546
|
-
:host(.smilodon-option--selected) .option-container:hover {
|
|
1547
|
-
background: var(--select-option-selected-hover-bg, var(--select-option-selected-bg, #e3f2fd));
|
|
1548
|
-
color: var(--select-option-selected-hover-color, var(--select-option-selected-color, #1976d2));
|
|
1549
|
-
border: var(--select-option-selected-hover-border, var(--select-option-selected-border, var(--select-option-border, none)));
|
|
1550
|
-
border-bottom: var(--select-option-selected-hover-border-bottom, var(--select-option-selected-border-bottom, var(--select-option-border-bottom, none)));
|
|
1551
|
-
box-shadow: var(--select-option-selected-hover-shadow, var(--select-option-selected-shadow, var(--select-option-shadow, none)));
|
|
1552
|
-
transform: var(--select-option-selected-hover-transform, var(--select-option-selected-transform, var(--select-option-transform, none)));
|
|
1553
|
-
}
|
|
1554
|
-
|
|
1555
|
-
.option-container {
|
|
1556
|
-
display: flex;
|
|
1557
|
-
align-items: center;
|
|
1558
|
-
justify-content: space-between;
|
|
1559
|
-
padding: var(--select-option-padding, 10px 14px);
|
|
1560
|
-
cursor: pointer;
|
|
1561
|
-
user-select: none;
|
|
1562
1533
|
color: var(--select-option-color, var(--select-text-color, #1f2937));
|
|
1563
1534
|
background: var(--select-option-bg, var(--select-dropdown-bg, var(--select-bg, white)));
|
|
1564
|
-
transition: var(--select-option-transition, background-color 0.2s ease);
|
|
1565
1535
|
border: var(--select-option-border, none);
|
|
1566
1536
|
border-bottom: var(--select-option-border-bottom, none);
|
|
1567
1537
|
border-radius: var(--select-option-border-radius, var(--select-radius-sm, 6px));
|
|
1568
1538
|
box-shadow: var(--select-option-shadow, none);
|
|
1569
1539
|
transform: var(--select-option-transform, none);
|
|
1570
|
-
|
|
1540
|
+
transition: var(--select-option-transition, background-color 0.2s ease);
|
|
1571
1541
|
}
|
|
1572
|
-
|
|
1573
|
-
.option-
|
|
1542
|
+
|
|
1543
|
+
:host(:hover):not(.smilodon-option--disabled):not([aria-disabled="true"]),
|
|
1544
|
+
:host(.smilodon-option--disabled-hoverable:hover) {
|
|
1574
1545
|
background: var(--select-option-hover-bg, #f0f0f0);
|
|
1575
1546
|
color: var(--select-option-hover-color, var(--select-option-color, var(--select-text-color, #1f2937)));
|
|
1576
1547
|
border: var(--select-option-hover-border, var(--select-option-border, none));
|
|
@@ -1578,8 +1549,12 @@ class SelectOption extends HTMLElement {
|
|
|
1578
1549
|
box-shadow: var(--select-option-hover-shadow, var(--select-option-shadow, none));
|
|
1579
1550
|
transform: var(--select-option-hover-transform, var(--select-option-transform, none));
|
|
1580
1551
|
}
|
|
1581
|
-
|
|
1582
|
-
|
|
1552
|
+
|
|
1553
|
+
/* Keep the visual surface on the host so external utility classes applied
|
|
1554
|
+
through classMap can override selected/active/disabled styles in both
|
|
1555
|
+
light and dark themes. */
|
|
1556
|
+
:host([aria-selected="true"]),
|
|
1557
|
+
:host(.smilodon-option--selected) {
|
|
1583
1558
|
background: var(--select-option-selected-bg, #e3f2fd);
|
|
1584
1559
|
color: var(--select-option-selected-color, #1976d2);
|
|
1585
1560
|
border: var(--select-option-selected-border, var(--select-option-border, none));
|
|
@@ -1589,7 +1564,8 @@ class SelectOption extends HTMLElement {
|
|
|
1589
1564
|
transform: var(--select-option-selected-transform, var(--select-option-transform, none));
|
|
1590
1565
|
}
|
|
1591
1566
|
|
|
1592
|
-
|
|
1567
|
+
:host([aria-selected="true"]:hover),
|
|
1568
|
+
:host(.smilodon-option--selected:hover) {
|
|
1593
1569
|
background: var(--select-option-selected-hover-bg, var(--select-option-selected-bg, #e3f2fd));
|
|
1594
1570
|
color: var(--select-option-selected-hover-color, var(--select-option-selected-color, #1976d2));
|
|
1595
1571
|
border: var(--select-option-selected-hover-border, var(--select-option-selected-border, var(--select-option-border, none)));
|
|
@@ -1597,18 +1573,20 @@ class SelectOption extends HTMLElement {
|
|
|
1597
1573
|
box-shadow: var(--select-option-selected-hover-shadow, var(--select-option-selected-shadow, var(--select-option-shadow, none)));
|
|
1598
1574
|
transform: var(--select-option-selected-hover-transform, var(--select-option-selected-transform, var(--select-option-transform, none)));
|
|
1599
1575
|
}
|
|
1600
|
-
|
|
1601
|
-
.option
|
|
1576
|
+
|
|
1577
|
+
:host(.smilodon-option--active):not(.smilodon-option--disabled):not([aria-disabled="true"]),
|
|
1578
|
+
:host(.smilodon-option--active.smilodon-option--disabled-focusable) {
|
|
1602
1579
|
background: var(--select-option-active-bg, var(--select-option-hover-bg, #f0f0f0));
|
|
1603
1580
|
color: var(--select-option-active-color, var(--select-option-hover-color, var(--select-option-color, var(--select-text-color, #1f2937))));
|
|
1604
1581
|
border: var(--select-option-active-border, var(--select-option-hover-border, var(--select-option-border, none)));
|
|
1605
1582
|
box-shadow: var(--select-option-active-shadow, var(--select-option-shadow, none));
|
|
1606
1583
|
transform: var(--select-option-active-transform, var(--select-option-transform, none));
|
|
1607
|
-
outline: var(--select-option-active-outline,
|
|
1584
|
+
outline: var(--select-option-active-outline, none);
|
|
1608
1585
|
outline-offset: var(--select-option-active-outline-offset, -2px);
|
|
1609
1586
|
}
|
|
1610
|
-
|
|
1611
|
-
.option
|
|
1587
|
+
|
|
1588
|
+
:host(.smilodon-option--disabled),
|
|
1589
|
+
:host([aria-disabled="true"]) {
|
|
1612
1590
|
background: var(--select-option-disabled-bg, var(--select-option-bg, var(--select-dropdown-bg, var(--select-bg, white))));
|
|
1613
1591
|
color: var(--select-option-disabled-color, var(--select-option-color, var(--select-text-color, #1f2937)));
|
|
1614
1592
|
border: var(--select-option-disabled-border, var(--select-option-border, none));
|
|
@@ -1617,6 +1595,76 @@ class SelectOption extends HTMLElement {
|
|
|
1617
1595
|
cursor: var(--select-option-disabled-cursor, not-allowed);
|
|
1618
1596
|
pointer-events: none;
|
|
1619
1597
|
}
|
|
1598
|
+
|
|
1599
|
+
:host(.smilodon-option--disabled-interactive) {
|
|
1600
|
+
pointer-events: auto;
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
.option-container {
|
|
1604
|
+
display: flex;
|
|
1605
|
+
align-items: center;
|
|
1606
|
+
justify-content: space-between;
|
|
1607
|
+
padding: var(--select-option-padding, 10px 14px);
|
|
1608
|
+
cursor: pointer;
|
|
1609
|
+
user-select: none;
|
|
1610
|
+
color: inherit;
|
|
1611
|
+
background: inherit;
|
|
1612
|
+
transition: inherit;
|
|
1613
|
+
border: inherit;
|
|
1614
|
+
border-bottom: inherit;
|
|
1615
|
+
border-radius: inherit;
|
|
1616
|
+
box-shadow: inherit;
|
|
1617
|
+
transform: inherit;
|
|
1618
|
+
font: inherit;
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
.option-container:hover {
|
|
1622
|
+
background: inherit;
|
|
1623
|
+
color: inherit;
|
|
1624
|
+
border: inherit;
|
|
1625
|
+
border-bottom: inherit;
|
|
1626
|
+
box-shadow: inherit;
|
|
1627
|
+
transform: inherit;
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
.option-container.selected {
|
|
1631
|
+
background: inherit;
|
|
1632
|
+
color: inherit;
|
|
1633
|
+
border: inherit;
|
|
1634
|
+
border-bottom: inherit;
|
|
1635
|
+
border-radius: inherit;
|
|
1636
|
+
box-shadow: inherit;
|
|
1637
|
+
transform: inherit;
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
.option-container.selected:hover {
|
|
1641
|
+
background: inherit;
|
|
1642
|
+
color: inherit;
|
|
1643
|
+
border: inherit;
|
|
1644
|
+
border-bottom: inherit;
|
|
1645
|
+
box-shadow: inherit;
|
|
1646
|
+
transform: inherit;
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
.option-container.active:not(.disabled) {
|
|
1650
|
+
background: inherit;
|
|
1651
|
+
color: inherit;
|
|
1652
|
+
border: inherit;
|
|
1653
|
+
box-shadow: inherit;
|
|
1654
|
+
transform: inherit;
|
|
1655
|
+
outline: none;
|
|
1656
|
+
outline-offset: 0;
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
.option-container.disabled {
|
|
1660
|
+
background: inherit;
|
|
1661
|
+
color: inherit;
|
|
1662
|
+
border: inherit;
|
|
1663
|
+
border-bottom: inherit;
|
|
1664
|
+
opacity: inherit;
|
|
1665
|
+
cursor: inherit;
|
|
1666
|
+
pointer-events: none;
|
|
1667
|
+
}
|
|
1620
1668
|
|
|
1621
1669
|
.option-content {
|
|
1622
1670
|
flex: 1;
|
|
@@ -1675,6 +1723,11 @@ class SelectOption extends HTMLElement {
|
|
|
1675
1723
|
justify-content: center;
|
|
1676
1724
|
width: var(--select-badge-remove-icon-size, 10px);
|
|
1677
1725
|
height: var(--select-badge-remove-icon-size, 10px);
|
|
1726
|
+
color: var(--select-badge-remove-icon-color, currentColor);
|
|
1727
|
+
font-size: var(--select-badge-remove-icon-font-size, inherit);
|
|
1728
|
+
line-height: var(--select-badge-remove-icon-line-height, 1);
|
|
1729
|
+
transform: var(--select-badge-remove-icon-transform, none);
|
|
1730
|
+
opacity: var(--select-badge-remove-icon-opacity, 1);
|
|
1678
1731
|
pointer-events: none;
|
|
1679
1732
|
}
|
|
1680
1733
|
|
|
@@ -1696,8 +1749,20 @@ class SelectOption extends HTMLElement {
|
|
|
1696
1749
|
`;
|
|
1697
1750
|
this._shadow.appendChild(style);
|
|
1698
1751
|
}
|
|
1752
|
+
_getDisabledBehavior() {
|
|
1753
|
+
const behavior = this._config.disabledBehavior ?? {};
|
|
1754
|
+
return {
|
|
1755
|
+
selectable: behavior.selectable === true,
|
|
1756
|
+
hoverable: behavior.hoverable === true,
|
|
1757
|
+
focusable: behavior.focusable === true,
|
|
1758
|
+
};
|
|
1759
|
+
}
|
|
1760
|
+
_isDisabledSelectionBlocked() {
|
|
1761
|
+
return Boolean(this._config.disabled) && !this._getDisabledBehavior().selectable;
|
|
1762
|
+
}
|
|
1699
1763
|
_render() {
|
|
1700
1764
|
const { item, index, selected, disabled, active, render, showRemoveButton, classMap } = this._config;
|
|
1765
|
+
const disabledBehavior = this._getDisabledBehavior();
|
|
1701
1766
|
// Clear container
|
|
1702
1767
|
this._container.innerHTML = '';
|
|
1703
1768
|
// Add part attribute
|
|
@@ -1726,7 +1791,7 @@ class SelectOption extends HTMLElement {
|
|
|
1726
1791
|
toggleClasses(this._container, [...selectedClasses, 'smilodon-option--selected'], false);
|
|
1727
1792
|
toggleClasses(this, [...selectedClasses, 'smilodon-option--selected'], false);
|
|
1728
1793
|
}
|
|
1729
|
-
if (active && !disabled) {
|
|
1794
|
+
if (active && (!disabled || disabledBehavior.focusable)) {
|
|
1730
1795
|
toggleClasses(this._container, [...activeClasses, 'smilodon-option--active'], true);
|
|
1731
1796
|
toggleClasses(this, [...activeClasses, 'smilodon-option--active'], true); // Make focus ring visible on host
|
|
1732
1797
|
}
|
|
@@ -1742,6 +1807,15 @@ class SelectOption extends HTMLElement {
|
|
|
1742
1807
|
toggleClasses(this._container, [...disabledClasses, 'smilodon-option--disabled'], false);
|
|
1743
1808
|
toggleClasses(this, [...disabledClasses, 'smilodon-option--disabled'], false);
|
|
1744
1809
|
}
|
|
1810
|
+
const interactiveDisabled = Boolean(disabled && (disabledBehavior.hoverable || disabledBehavior.selectable));
|
|
1811
|
+
const toggleBehaviorClass = (className, add) => {
|
|
1812
|
+
toggleClasses(this._container, [className], add);
|
|
1813
|
+
toggleClasses(this, [className], add);
|
|
1814
|
+
};
|
|
1815
|
+
toggleBehaviorClass('smilodon-option--disabled-interactive', interactiveDisabled);
|
|
1816
|
+
toggleBehaviorClass('smilodon-option--disabled-hoverable', Boolean(disabled && disabledBehavior.hoverable));
|
|
1817
|
+
toggleBehaviorClass('smilodon-option--disabled-focusable', Boolean(disabled && disabledBehavior.focusable));
|
|
1818
|
+
toggleBehaviorClass('smilodon-option--disabled-selectable', Boolean(disabled && disabledBehavior.selectable));
|
|
1745
1819
|
// Custom class name
|
|
1746
1820
|
if (this._config.className) {
|
|
1747
1821
|
const classes = this._config.className.split(' ').filter(Boolean);
|
|
@@ -1794,7 +1868,7 @@ class SelectOption extends HTMLElement {
|
|
|
1794
1868
|
// Set ARIA attributes and State attributes on Host
|
|
1795
1869
|
this.setAttribute('role', 'option');
|
|
1796
1870
|
this.setAttribute('aria-selected', String(selected));
|
|
1797
|
-
if (disabled) {
|
|
1871
|
+
if (disabled && !disabledBehavior.selectable) {
|
|
1798
1872
|
this.setAttribute('aria-disabled', 'true');
|
|
1799
1873
|
}
|
|
1800
1874
|
else {
|
|
@@ -1818,7 +1892,7 @@ class SelectOption extends HTMLElement {
|
|
|
1818
1892
|
const state = [];
|
|
1819
1893
|
if (selected)
|
|
1820
1894
|
state.push('selected');
|
|
1821
|
-
if (active && !disabled)
|
|
1895
|
+
if (active && (!disabled || disabledBehavior.focusable))
|
|
1822
1896
|
state.push('active');
|
|
1823
1897
|
if (state.length) {
|
|
1824
1898
|
this.dataset.smState = state.join(' ');
|
|
@@ -1838,7 +1912,7 @@ class SelectOption extends HTMLElement {
|
|
|
1838
1912
|
if (e.target === this._removeButton) {
|
|
1839
1913
|
return;
|
|
1840
1914
|
}
|
|
1841
|
-
if (!this.
|
|
1915
|
+
if (!this._isDisabledSelectionBlocked()) {
|
|
1842
1916
|
this._handleSelect();
|
|
1843
1917
|
}
|
|
1844
1918
|
});
|
|
@@ -1851,7 +1925,7 @@ class SelectOption extends HTMLElement {
|
|
|
1851
1925
|
}
|
|
1852
1926
|
// Keyboard handler
|
|
1853
1927
|
this.addEventListener('keydown', (e) => {
|
|
1854
|
-
if (this.
|
|
1928
|
+
if (this._isDisabledSelectionBlocked())
|
|
1855
1929
|
return;
|
|
1856
1930
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
1857
1931
|
e.preventDefault();
|
|
@@ -1942,7 +2016,7 @@ class SelectOption extends HTMLElement {
|
|
|
1942
2016
|
* Set active state
|
|
1943
2017
|
*/
|
|
1944
2018
|
setActive(active) {
|
|
1945
|
-
this._config.active = active && !this._config.disabled;
|
|
2019
|
+
this._config.active = active && (!this._config.disabled || this._getDisabledBehavior().focusable);
|
|
1946
2020
|
this._render();
|
|
1947
2021
|
}
|
|
1948
2022
|
/**
|
|
@@ -2452,6 +2526,20 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2452
2526
|
this._setCssVariable(variableName, styleConfig?.[styleKey]);
|
|
2453
2527
|
});
|
|
2454
2528
|
}
|
|
2529
|
+
_getDisabledOptionBehavior() {
|
|
2530
|
+
const behavior = this._config.selection.disabledOptionBehavior ?? {};
|
|
2531
|
+
return {
|
|
2532
|
+
selectable: behavior.selectable === true,
|
|
2533
|
+
hoverable: behavior.hoverable === true,
|
|
2534
|
+
focusable: behavior.focusable === true,
|
|
2535
|
+
};
|
|
2536
|
+
}
|
|
2537
|
+
_isDisabledOptionSelectable(item) {
|
|
2538
|
+
return Boolean(item?.disabled) && this._getDisabledOptionBehavior().selectable;
|
|
2539
|
+
}
|
|
2540
|
+
_isOptionSelectionBlocked(item) {
|
|
2541
|
+
return Boolean(item?.disabled) && !this._isDisabledOptionSelectable(item);
|
|
2542
|
+
}
|
|
2455
2543
|
_syncStyleConfigVariables() {
|
|
2456
2544
|
const styles = this._config.styles;
|
|
2457
2545
|
this._applyStyleVariableMap(styles.option, {
|
|
@@ -2509,6 +2597,21 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2509
2597
|
opacity: '--select-option-disabled-opacity',
|
|
2510
2598
|
cursor: '--select-option-disabled-cursor',
|
|
2511
2599
|
});
|
|
2600
|
+
this._applyStyleVariableMap(styles.selectedIndicator, {
|
|
2601
|
+
width: '--select-option-selected-indicator-width',
|
|
2602
|
+
height: '--select-option-selected-indicator-height',
|
|
2603
|
+
background: '--select-option-selected-indicator-bg',
|
|
2604
|
+
backgroundColor: '--select-option-selected-indicator-bg',
|
|
2605
|
+
borderRadius: '--select-option-selected-indicator-radius',
|
|
2606
|
+
left: '--select-option-selected-indicator-left',
|
|
2607
|
+
right: '--select-option-selected-indicator-right',
|
|
2608
|
+
top: '--select-option-selected-indicator-top',
|
|
2609
|
+
transform: '--select-option-selected-indicator-transform',
|
|
2610
|
+
animation: '--select-option-selected-indicator-animation',
|
|
2611
|
+
});
|
|
2612
|
+
this._setCssVariable('--select-option-selected-indicator-display', this._config.selection.showSelectedIndicator === false
|
|
2613
|
+
? 'none'
|
|
2614
|
+
: styles.selectedIndicator?.display);
|
|
2512
2615
|
this._applyStyleVariableMap(styles.badge, {
|
|
2513
2616
|
width: '--select-badge-width',
|
|
2514
2617
|
minWidth: '--select-badge-min-width',
|
|
@@ -2567,6 +2670,15 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2567
2670
|
fontSize: '--select-badge-remove-font-size',
|
|
2568
2671
|
fontWeight: '--select-badge-remove-font-weight',
|
|
2569
2672
|
});
|
|
2673
|
+
this._applyStyleVariableMap(styles.badgeRemoveIcon, {
|
|
2674
|
+
width: '--select-badge-remove-icon-size',
|
|
2675
|
+
height: '--select-badge-remove-icon-size',
|
|
2676
|
+
color: '--select-badge-remove-icon-color',
|
|
2677
|
+
fontSize: '--select-badge-remove-icon-font-size',
|
|
2678
|
+
lineHeight: '--select-badge-remove-icon-line-height',
|
|
2679
|
+
transform: '--select-badge-remove-icon-transform',
|
|
2680
|
+
opacity: '--select-badge-remove-icon-opacity',
|
|
2681
|
+
});
|
|
2570
2682
|
this._applyStyleVariableMap(styles.badgeRemoveHover, {
|
|
2571
2683
|
background: '--select-badge-remove-hover-bg',
|
|
2572
2684
|
backgroundColor: '--select-badge-remove-hover-bg',
|
|
@@ -2667,11 +2779,24 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2667
2779
|
this._inputContainer.style.removeProperty('--select-multi-input-align-content-config');
|
|
2668
2780
|
return;
|
|
2669
2781
|
}
|
|
2670
|
-
const
|
|
2671
|
-
const
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2782
|
+
const configuredMaxHeight = this._config.multiSelectDisplay?.maxHeight;
|
|
2783
|
+
const defaultMaxHeight = '160px';
|
|
2784
|
+
let maxHeight = configuredMaxHeight ?? 'none';
|
|
2785
|
+
let overflowX = this._config.multiSelectDisplay?.overflowX ?? 'hidden';
|
|
2786
|
+
let overflowY = this._config.multiSelectDisplay?.overflowY ?? 'hidden';
|
|
2787
|
+
let flexWrap = 'wrap';
|
|
2788
|
+
let alignContent = 'flex-start';
|
|
2789
|
+
if (mode === 'vertical') {
|
|
2790
|
+
maxHeight = configuredMaxHeight ?? defaultMaxHeight;
|
|
2791
|
+
overflowY = this._config.multiSelectDisplay?.overflowY ?? 'auto';
|
|
2792
|
+
}
|
|
2793
|
+
else if (mode === 'horizontal') {
|
|
2794
|
+
maxHeight = configuredMaxHeight ?? defaultMaxHeight;
|
|
2795
|
+
overflowX = this._config.multiSelectDisplay?.overflowX ?? 'auto';
|
|
2796
|
+
overflowY = this._config.multiSelectDisplay?.overflowY ?? 'hidden';
|
|
2797
|
+
flexWrap = 'nowrap';
|
|
2798
|
+
alignContent = 'center';
|
|
2799
|
+
}
|
|
2675
2800
|
this._inputContainer.setAttribute('data-multi-scroll-mode', mode);
|
|
2676
2801
|
this._inputContainer.setAttribute('data-drag-scroll', String(dragEnabled && mode === 'horizontal'));
|
|
2677
2802
|
this._inputContainer.style.setProperty('--select-multi-input-max-height-config', maxHeight);
|
|
@@ -2954,6 +3079,11 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2954
3079
|
--select-badge-letter-spacing: 0.01em;
|
|
2955
3080
|
--select-badge-hover-shadow: var(--select-shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.15);
|
|
2956
3081
|
--select-badge-remove-icon-size: 10px;
|
|
3082
|
+
--select-badge-remove-icon-color: currentColor;
|
|
3083
|
+
--select-badge-remove-icon-font-size: inherit;
|
|
3084
|
+
--select-badge-remove-icon-line-height: 1;
|
|
3085
|
+
--select-badge-remove-icon-transform: none;
|
|
3086
|
+
--select-badge-remove-icon-opacity: 1;
|
|
2957
3087
|
--select-badge-remove-focus-outline: 2px solid rgba(255, 255, 255, 0.5);
|
|
2958
3088
|
--select-badge-remove-focus-offset: 1px;
|
|
2959
3089
|
--select-badge-remove-hover-transform: scale(1.15) rotate(90deg);
|
|
@@ -2972,9 +3102,11 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2972
3102
|
--select-multi-input-overflow-y: auto;
|
|
2973
3103
|
--select-multi-input-flex-wrap: wrap;
|
|
2974
3104
|
--select-multi-input-align-content: flex-start;
|
|
3105
|
+
--select-multi-input-horizontal-height: var(--select-input-min-height, 48px);
|
|
2975
3106
|
--select-multi-input-horizontal-input-flex: 0 0 var(--select-multi-input-min-width, 96px);
|
|
2976
3107
|
--select-multi-input-horizontal-cursor: grab;
|
|
2977
3108
|
--select-multi-input-horizontal-active-cursor: grabbing;
|
|
3109
|
+
--select-multi-input-end-gap: 12px;
|
|
2978
3110
|
--select-multi-separator-inset-block: 10px;
|
|
2979
3111
|
--select-multi-separator-height: auto;
|
|
2980
3112
|
--select-multi-action-surface-bg: var(--select-input-bg, var(--select-surface));
|
|
@@ -3025,8 +3157,16 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3025
3157
|
--select-multi-container-padding: 6px;
|
|
3026
3158
|
--select-option-disabled-opacity: 0.5;
|
|
3027
3159
|
--select-option-disabled-cursor: not-allowed;
|
|
3160
|
+
--select-option-active-outline: none;
|
|
3028
3161
|
--select-option-active-outline-offset: -2px;
|
|
3162
|
+
--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%)));
|
|
3163
|
+
--select-option-selected-active-color: var(--select-option-selected-hover-color, var(--select-option-selected-color, var(--select-accent)));
|
|
3164
|
+
--select-option-selected-active-border: var(--select-option-selected-hover-border, var(--select-option-selected-border, var(--select-option-border, none)));
|
|
3165
|
+
--select-option-selected-active-shadow: var(--select-option-active-shadow, none);
|
|
3166
|
+
--select-option-selected-active-transform: var(--select-option-active-transform, none);
|
|
3167
|
+
--select-option-selected-active-outline: none;
|
|
3029
3168
|
--select-option-selected-active-outline-offset: -2px;
|
|
3169
|
+
--select-option-selected-indicator-display: block;
|
|
3030
3170
|
--select-option-selected-indicator-width: 3px;
|
|
3031
3171
|
--select-option-selected-indicator-height: 60%;
|
|
3032
3172
|
--select-option-selected-indicator-bg: var(--select-accent);
|
|
@@ -3039,8 +3179,8 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3039
3179
|
--select-option-selected-indicator-to-height: 60%;
|
|
3040
3180
|
--select-option-selected-indicator-from-opacity: 0;
|
|
3041
3181
|
--select-option-selected-indicator-to-opacity: 1;
|
|
3042
|
-
--select-option-pressed-transform:
|
|
3043
|
-
--select-option-selected-pressed-transform:
|
|
3182
|
+
--select-option-pressed-transform: none;
|
|
3183
|
+
--select-option-selected-pressed-transform: none;
|
|
3044
3184
|
--select-button-hover-transform: translateY(-1px);
|
|
3045
3185
|
--select-button-active-transform: translateY(0) scale(0.98);
|
|
3046
3186
|
--select-button-font-weight: 550;
|
|
@@ -3202,6 +3342,11 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3202
3342
|
justify-content: center;
|
|
3203
3343
|
width: var(--select-badge-remove-icon-size, 10px);
|
|
3204
3344
|
height: var(--select-badge-remove-icon-size, 10px);
|
|
3345
|
+
color: var(--select-badge-remove-icon-color, currentColor);
|
|
3346
|
+
font-size: var(--select-badge-remove-icon-font-size, inherit);
|
|
3347
|
+
line-height: var(--select-badge-remove-icon-line-height, 1);
|
|
3348
|
+
transform: var(--select-badge-remove-icon-transform, none);
|
|
3349
|
+
opacity: var(--select-badge-remove-icon-opacity, 1);
|
|
3205
3350
|
pointer-events: none;
|
|
3206
3351
|
}
|
|
3207
3352
|
|
|
@@ -3307,13 +3452,26 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3307
3452
|
|
|
3308
3453
|
.input-container.input-container--multi {
|
|
3309
3454
|
max-height: var(--select-multi-input-max-height, var(--select-multi-input-max-height-config, var(--select-input-max-height, 160px)));
|
|
3455
|
+
--select-multi-action-area-width: var(--select-arrow-width, 42px);
|
|
3310
3456
|
}
|
|
3311
3457
|
|
|
3312
3458
|
.input-container.input-container--multi .input-content {
|
|
3459
|
+
flex: 1 1 calc(100% - var(--select-multi-action-area-width, var(--select-arrow-width, 42px)));
|
|
3460
|
+
width: calc(100% - var(--select-multi-action-area-width, var(--select-arrow-width, 42px)));
|
|
3461
|
+
max-width: calc(100% - var(--select-multi-action-area-width, var(--select-arrow-width, 42px)));
|
|
3313
3462
|
flex-wrap: var(--select-multi-input-flex-wrap, var(--select-multi-input-flex-wrap-config, wrap));
|
|
3314
3463
|
align-content: var(--select-multi-input-align-content, var(--select-multi-input-align-content-config, flex-start));
|
|
3315
3464
|
overflow-x: var(--select-multi-input-overflow-x, var(--select-multi-input-overflow-x-config, hidden));
|
|
3316
3465
|
overflow-y: var(--select-multi-input-overflow-y, var(--select-multi-input-overflow-y-config, auto));
|
|
3466
|
+
padding-inline-end: var(--select-multi-input-end-gap, 12px);
|
|
3467
|
+
}
|
|
3468
|
+
|
|
3469
|
+
.input-container.input-container--multi .input-content .selection-badge {
|
|
3470
|
+
flex: 0 0 auto;
|
|
3471
|
+
}
|
|
3472
|
+
|
|
3473
|
+
.input-container.input-container--multi.has-clear-control .input-content {
|
|
3474
|
+
--select-multi-action-area-width: calc(var(--select-arrow-right-with-clear, 34px) + var(--select-arrow-width, 42px));
|
|
3317
3475
|
}
|
|
3318
3476
|
|
|
3319
3477
|
.input-container.input-container--multi::after {
|
|
@@ -3324,17 +3482,31 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3324
3482
|
|
|
3325
3483
|
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"] {
|
|
3326
3484
|
align-items: stretch;
|
|
3485
|
+
height: var(--select-multi-input-horizontal-height, var(--select-input-min-height, 48px));
|
|
3486
|
+
min-height: var(--select-multi-input-horizontal-height, var(--select-input-min-height, 48px));
|
|
3487
|
+
max-height: var(--select-multi-input-horizontal-height, var(--select-input-min-height, 48px));
|
|
3488
|
+
overflow: hidden;
|
|
3327
3489
|
}
|
|
3328
3490
|
|
|
3329
3491
|
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .input-content {
|
|
3492
|
+
flex: 1 1 100%;
|
|
3493
|
+
width: 100%;
|
|
3494
|
+
max-width: 100%;
|
|
3495
|
+
min-height: 0;
|
|
3496
|
+
height: 100%;
|
|
3330
3497
|
cursor: var(--select-multi-input-horizontal-cursor, grab);
|
|
3498
|
+
align-items: center;
|
|
3499
|
+
align-content: center;
|
|
3500
|
+
flex-wrap: nowrap;
|
|
3331
3501
|
overflow-y: hidden;
|
|
3332
3502
|
overscroll-behavior-x: contain;
|
|
3333
|
-
|
|
3503
|
+
overscroll-behavior-y: none;
|
|
3504
|
+
padding-inline-end: 0;
|
|
3505
|
+
scroll-padding-inline-end: var(--select-multi-action-area-width, var(--select-arrow-width, 42px));
|
|
3334
3506
|
}
|
|
3335
3507
|
|
|
3336
3508
|
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"].has-clear-control .input-content {
|
|
3337
|
-
|
|
3509
|
+
--select-multi-action-area-width: calc(var(--select-arrow-right-with-clear, 34px) + var(--select-arrow-width, 42px));
|
|
3338
3510
|
}
|
|
3339
3511
|
|
|
3340
3512
|
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"]::after {
|
|
@@ -3346,8 +3518,10 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3346
3518
|
user-select: none;
|
|
3347
3519
|
}
|
|
3348
3520
|
|
|
3349
|
-
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .
|
|
3521
|
+
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .selection-badge {
|
|
3350
3522
|
flex: 0 0 auto;
|
|
3523
|
+
margin-top: 0;
|
|
3524
|
+
margin-bottom: 0;
|
|
3351
3525
|
}
|
|
3352
3526
|
|
|
3353
3527
|
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .input-content > .select-input,
|
|
@@ -3376,15 +3550,6 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3376
3550
|
left: var(--select-arrow-right-with-clear, 34px);
|
|
3377
3551
|
}
|
|
3378
3552
|
|
|
3379
|
-
:host([dir="rtl"]) .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .input-content {
|
|
3380
|
-
padding-right: 0;
|
|
3381
|
-
padding-left: calc(var(--select-arrow-width, 42px) + var(--select-multi-horizontal-end-gap, 12px));
|
|
3382
|
-
}
|
|
3383
|
-
|
|
3384
|
-
:host([dir="rtl"]) .input-container.input-container--multi[data-multi-scroll-mode="horizontal"].has-clear-control .input-content {
|
|
3385
|
-
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));
|
|
3386
|
-
}
|
|
3387
|
-
|
|
3388
3553
|
.input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .clear-control-button {
|
|
3389
3554
|
background: var(--select-multi-action-surface-bg, var(--select-input-bg, var(--select-surface)));
|
|
3390
3555
|
z-index: 4;
|
|
@@ -3773,7 +3938,8 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3773
3938
|
margin: var(--select-option-margin);
|
|
3774
3939
|
}
|
|
3775
3940
|
|
|
3776
|
-
.option:hover
|
|
3941
|
+
.option:hover:not(.disabled):not(.smilodon-option--disabled),
|
|
3942
|
+
.option.smilodon-option--disabled-hoverable:hover {
|
|
3777
3943
|
background: var(--select-option-hover-bg, var(--select-surface-elevated));
|
|
3778
3944
|
border: var(--select-option-hover-border, var(--select-option-border, none));
|
|
3779
3945
|
color: var(--select-option-hover-color, var(--select-text));
|
|
@@ -3788,7 +3954,8 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3788
3954
|
}
|
|
3789
3955
|
|
|
3790
3956
|
.option.selected::before {
|
|
3791
|
-
content: '';
|
|
3957
|
+
content: var(--select-option-selected-indicator-content, '');
|
|
3958
|
+
display: var(--select-option-selected-indicator-display, block);
|
|
3792
3959
|
position: absolute;
|
|
3793
3960
|
left: var(--select-option-selected-indicator-left);
|
|
3794
3961
|
top: var(--select-option-selected-indicator-top);
|
|
@@ -3823,35 +3990,50 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3823
3990
|
color: var(--select-option-selected-hover-color, var(--select-option-selected-color, var(--select-accent)));
|
|
3824
3991
|
}
|
|
3825
3992
|
|
|
3826
|
-
.option.active:not(.selected):not(.disabled)
|
|
3993
|
+
.option.active:not(.selected):not(.disabled):not(.smilodon-option--disabled),
|
|
3994
|
+
.option.active.smilodon-option--disabled-focusable:not(.selected) {
|
|
3827
3995
|
background: var(--select-option-active-bg, var(--select-surface-elevated));
|
|
3828
3996
|
color: var(--select-option-active-color, var(--select-option-hover-color, var(--select-option-color, var(--select-text))));
|
|
3829
3997
|
border: var(--select-option-active-border, var(--select-option-hover-border, var(--select-option-border, none)));
|
|
3830
|
-
outline: var(--select-option-active-outline,
|
|
3998
|
+
outline: var(--select-option-active-outline, none);
|
|
3831
3999
|
outline-offset: var(--select-option-active-outline-offset);
|
|
3832
4000
|
box-shadow: var(--select-option-active-shadow, none);
|
|
3833
4001
|
transform: var(--select-option-active-transform, none);
|
|
3834
4002
|
}
|
|
3835
4003
|
|
|
3836
|
-
.option.selected.active:not(.disabled)
|
|
3837
|
-
|
|
4004
|
+
.option.selected.active:not(.disabled):not(.smilodon-option--disabled),
|
|
4005
|
+
.option.selected.active.smilodon-option--disabled-focusable {
|
|
4006
|
+
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%))));
|
|
4007
|
+
color: var(--select-option-selected-active-color, var(--select-option-selected-hover-color, var(--select-option-selected-color, var(--select-accent))));
|
|
4008
|
+
border: var(--select-option-selected-active-border, var(--select-option-selected-hover-border, var(--select-option-selected-border, var(--select-option-border, none))));
|
|
4009
|
+
outline: var(--select-option-selected-active-outline, var(--select-option-active-outline, none));
|
|
3838
4010
|
outline-offset: var(--select-option-selected-active-outline-offset);
|
|
4011
|
+
box-shadow: var(--select-option-selected-active-shadow, var(--select-option-active-shadow, none));
|
|
4012
|
+
transform: var(--select-option-selected-active-transform, var(--select-option-active-transform, none));
|
|
3839
4013
|
}
|
|
3840
4014
|
|
|
3841
|
-
.option.disabled
|
|
4015
|
+
.option.disabled,
|
|
4016
|
+
.option.smilodon-option--disabled {
|
|
3842
4017
|
background: var(--select-option-disabled-bg, var(--select-option-bg, transparent));
|
|
3843
4018
|
color: var(--select-option-disabled-color, var(--select-text-muted));
|
|
3844
4019
|
border: var(--select-option-disabled-border, var(--select-option-border, none));
|
|
3845
4020
|
opacity: var(--select-option-disabled-opacity, 0.5);
|
|
3846
4021
|
cursor: var(--select-option-disabled-cursor, not-allowed);
|
|
4022
|
+
pointer-events: var(--select-option-disabled-pointer-events, none);
|
|
4023
|
+
}
|
|
4024
|
+
|
|
4025
|
+
.option.smilodon-option--disabled-interactive {
|
|
4026
|
+
pointer-events: auto;
|
|
3847
4027
|
}
|
|
3848
4028
|
|
|
3849
|
-
.option:active:not(.selected)
|
|
4029
|
+
.option:active:not(.selected):not(.disabled):not(.smilodon-option--disabled),
|
|
4030
|
+
.option.smilodon-option--disabled-selectable:active:not(.selected) {
|
|
3850
4031
|
background: var(--select-option-pressed-bg, rgba(15, 52, 96, 0.08));
|
|
3851
4032
|
transform: var(--select-option-pressed-transform);
|
|
3852
4033
|
}
|
|
3853
4034
|
|
|
3854
|
-
.option.selected:active
|
|
4035
|
+
.option.selected:active:not(.disabled):not(.smilodon-option--disabled),
|
|
4036
|
+
.option.selected.smilodon-option--disabled-selectable:active {
|
|
3855
4037
|
transform: var(--select-option-selected-pressed-transform);
|
|
3856
4038
|
}
|
|
3857
4039
|
|
|
@@ -4427,7 +4609,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4427
4609
|
continue;
|
|
4428
4610
|
}
|
|
4429
4611
|
}
|
|
4430
|
-
if (option && !option.hasAttribute('aria-disabled')) {
|
|
4612
|
+
if (option && (!option.hasAttribute('aria-disabled') || option.classList.contains('smilodon-option--disabled-selectable'))) {
|
|
4431
4613
|
const indexStr = option.getAttribute('data-sm-index') ?? option.getAttribute('data-index');
|
|
4432
4614
|
const index = Number(indexStr);
|
|
4433
4615
|
if (!Number.isNaN(index)) {
|
|
@@ -4871,7 +5053,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4871
5053
|
}
|
|
4872
5054
|
_setActive(index) {
|
|
4873
5055
|
const option = this._getOptionElementByIndex(index);
|
|
4874
|
-
if (!option || option.getAttribute('aria-disabled') === 'true') {
|
|
5056
|
+
if (!option || (option.getAttribute('aria-disabled') === 'true' && !option.classList.contains('smilodon-option--disabled-focusable'))) {
|
|
4875
5057
|
return;
|
|
4876
5058
|
}
|
|
4877
5059
|
// Clear previous active state
|
|
@@ -4919,7 +5101,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4919
5101
|
// Only return elements with data-index or data-sm-selectable attributes
|
|
4920
5102
|
return Array.from(this._optionsContainer.children).filter((child) => {
|
|
4921
5103
|
return (child.hasAttribute('data-index') || child.hasAttribute('data-sm-selectable'))
|
|
4922
|
-
&& child.getAttribute('aria-disabled') !== 'true';
|
|
5104
|
+
&& (child.getAttribute('aria-disabled') !== 'true' || child.classList.contains('smilodon-option--disabled-focusable'));
|
|
4923
5105
|
});
|
|
4924
5106
|
}
|
|
4925
5107
|
_getSelectableOptionIndices() {
|
|
@@ -4974,6 +5156,8 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4974
5156
|
// Check if it's a custom SelectOption or a lightweight DOM element
|
|
4975
5157
|
if ('getConfig' in option && typeof option.getConfig === 'function') {
|
|
4976
5158
|
const config = option.getConfig();
|
|
5159
|
+
if (this._isOptionSelectionBlocked(config.item))
|
|
5160
|
+
return;
|
|
4977
5161
|
this._state.selectedIndices.add(optionIndex);
|
|
4978
5162
|
this._state.selectedItems.set(optionIndex, config.item);
|
|
4979
5163
|
option.setSelected(true);
|
|
@@ -4981,7 +5165,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
4981
5165
|
else {
|
|
4982
5166
|
// Lightweight option - get item from data attribute or state
|
|
4983
5167
|
const item = this._state.loadedItems[optionIndex];
|
|
4984
|
-
if (item) {
|
|
5168
|
+
if (item && !this._isOptionSelectionBlocked(item)) {
|
|
4985
5169
|
this._state.selectedIndices.add(optionIndex);
|
|
4986
5170
|
this._state.selectedItems.set(optionIndex, item);
|
|
4987
5171
|
option.classList.add('smilodon-option--selected');
|
|
@@ -5008,10 +5192,12 @@ class EnhancedSelect extends HTMLElement {
|
|
|
5008
5192
|
break;
|
|
5009
5193
|
const item = this._state.loadedItems[i];
|
|
5010
5194
|
const optionEl = this._getOptionElementByIndex(i);
|
|
5011
|
-
if (optionEl?.getAttribute('aria-disabled') === 'true')
|
|
5195
|
+
if (optionEl?.getAttribute('aria-disabled') === 'true' && !optionEl.classList.contains('smilodon-option--disabled-selectable'))
|
|
5012
5196
|
continue;
|
|
5013
5197
|
if (!item)
|
|
5014
5198
|
continue;
|
|
5199
|
+
if (this._isOptionSelectionBlocked(item))
|
|
5200
|
+
continue;
|
|
5015
5201
|
this._state.selectedIndices.add(i);
|
|
5016
5202
|
this._state.selectedItems.set(i, item);
|
|
5017
5203
|
}
|
|
@@ -5049,6 +5235,9 @@ class EnhancedSelect extends HTMLElement {
|
|
|
5049
5235
|
if (!item) {
|
|
5050
5236
|
return;
|
|
5051
5237
|
}
|
|
5238
|
+
if (this._isOptionSelectionBlocked(item)) {
|
|
5239
|
+
return;
|
|
5240
|
+
}
|
|
5052
5241
|
const isCurrentlySelected = this._state.selectedIndices.has(index);
|
|
5053
5242
|
// Keep active/focus styling aligned with the most recently interacted option.
|
|
5054
5243
|
// Without this, a previously selected item may retain active classes/styles
|
|
@@ -5202,6 +5391,9 @@ class EnhancedSelect extends HTMLElement {
|
|
|
5202
5391
|
removeBtn.setAttribute('aria-label', `Remove ${getLabel(item)}`);
|
|
5203
5392
|
const removeIcon = document.createElement('span');
|
|
5204
5393
|
removeIcon.className = 'badge-remove-icon';
|
|
5394
|
+
if (this._config.styles.classNames?.badgeRemoveIcon) {
|
|
5395
|
+
removeIcon.classList.add(...this._config.styles.classNames.badgeRemoveIcon.split(' ').filter(Boolean));
|
|
5396
|
+
}
|
|
5205
5397
|
removeIcon.setAttribute('part', 'chip-remove-icon');
|
|
5206
5398
|
this._setIconContent(removeIcon, this._config.selection.removeButtonIcon, '×');
|
|
5207
5399
|
removeBtn.appendChild(removeIcon);
|
|
@@ -5578,7 +5770,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
5578
5770
|
this._state.selectedIndices.clear();
|
|
5579
5771
|
this._state.selectedItems.clear();
|
|
5580
5772
|
this._state.loadedItems.forEach((item, index) => {
|
|
5581
|
-
if (values.includes(getValue(item))) {
|
|
5773
|
+
if (values.includes(getValue(item)) && !this._isOptionSelectionBlocked(item)) {
|
|
5582
5774
|
this._state.selectedIndices.add(index);
|
|
5583
5775
|
this._state.selectedItems.set(index, item);
|
|
5584
5776
|
}
|
|
@@ -5600,6 +5792,8 @@ class EnhancedSelect extends HTMLElement {
|
|
|
5600
5792
|
this._state.selectedIndices.clear();
|
|
5601
5793
|
this._state.selectedItems.clear();
|
|
5602
5794
|
items.forEach((item, index) => {
|
|
5795
|
+
if (this._isOptionSelectionBlocked(item))
|
|
5796
|
+
return;
|
|
5603
5797
|
this._state.selectedIndices.add(index);
|
|
5604
5798
|
this._state.selectedItems.set(index, item);
|
|
5605
5799
|
});
|
|
@@ -5981,6 +6175,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
5981
6175
|
_renderSingleOption(item, index, getValue, getLabel, targetContainer = this._optionsContainer) {
|
|
5982
6176
|
const isSelected = this._state.selectedIndices.has(index);
|
|
5983
6177
|
const isDisabled = Boolean(item?.disabled);
|
|
6178
|
+
const disabledBehavior = this._getDisabledOptionBehavior();
|
|
5984
6179
|
const optionId = `${this._uniqueId}-option-${index}`;
|
|
5985
6180
|
if (this._optionRenderer) {
|
|
5986
6181
|
const rendered = this._optionRenderer(item, index, this._rendererHelpers);
|
|
@@ -5992,6 +6187,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
5992
6187
|
selected: isSelected,
|
|
5993
6188
|
active: this._state.activeIndex === index,
|
|
5994
6189
|
disabled: isDisabled,
|
|
6190
|
+
disabledBehavior,
|
|
5995
6191
|
id: optionId,
|
|
5996
6192
|
});
|
|
5997
6193
|
optionElement.setAttribute('dir', this._config.direction ?? 'ltr');
|
|
@@ -6004,6 +6200,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
6004
6200
|
id: optionId,
|
|
6005
6201
|
selected: isSelected,
|
|
6006
6202
|
disabled: isDisabled,
|
|
6203
|
+
disabledBehavior,
|
|
6007
6204
|
active: this._state.activeIndex === index,
|
|
6008
6205
|
getValue,
|
|
6009
6206
|
getLabel,
|
|
@@ -6065,6 +6262,10 @@ class EnhancedSelect extends HTMLElement {
|
|
|
6065
6262
|
const isSelected = meta.selected;
|
|
6066
6263
|
const isActive = meta.active;
|
|
6067
6264
|
const isDisabled = meta.disabled;
|
|
6265
|
+
const isDisabledSelectable = isDisabled && meta.disabledBehavior.selectable;
|
|
6266
|
+
const isDisabledHoverable = isDisabled && meta.disabledBehavior.hoverable;
|
|
6267
|
+
const isDisabledFocusable = isDisabled && meta.disabledBehavior.focusable;
|
|
6268
|
+
const isDisabledInteractive = isDisabled && (isDisabledSelectable || isDisabledHoverable);
|
|
6068
6269
|
// Resolve classes from classMap or defaults
|
|
6069
6270
|
const selectedClasses = (this.classMap?.selected ?? 'selected sm-selected').split(' ').filter(Boolean);
|
|
6070
6271
|
const activeClasses = (this.classMap?.active ?? 'active sm-active').split(' ').filter(Boolean);
|
|
@@ -6111,6 +6312,10 @@ class EnhancedSelect extends HTMLElement {
|
|
|
6111
6312
|
optionEl.classList.remove(...this._config.styles.classNames.disabledOption.split(' ').filter(Boolean));
|
|
6112
6313
|
}
|
|
6113
6314
|
}
|
|
6315
|
+
optionEl.classList.toggle('smilodon-option--disabled-interactive', isDisabledInteractive);
|
|
6316
|
+
optionEl.classList.toggle('smilodon-option--disabled-hoverable', isDisabledHoverable);
|
|
6317
|
+
optionEl.classList.toggle('smilodon-option--disabled-focusable', isDisabledFocusable);
|
|
6318
|
+
optionEl.classList.toggle('smilodon-option--disabled-selectable', isDisabledSelectable);
|
|
6114
6319
|
// Data Attributes Contract
|
|
6115
6320
|
const state = [];
|
|
6116
6321
|
if (isSelected)
|
|
@@ -6143,7 +6348,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
6143
6348
|
optionEl.setAttribute('role', 'option');
|
|
6144
6349
|
}
|
|
6145
6350
|
optionEl.setAttribute('aria-selected', String(meta.selected));
|
|
6146
|
-
if (meta.disabled) {
|
|
6351
|
+
if (meta.disabled && !meta.disabledBehavior.selectable) {
|
|
6147
6352
|
optionEl.setAttribute('aria-disabled', 'true');
|
|
6148
6353
|
}
|
|
6149
6354
|
else {
|