@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/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
- font: inherit;
1540
+ transition: var(--select-option-transition, background-color 0.2s ease);
1571
1541
  }
1572
-
1573
- .option-container:hover {
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
- .option-container.selected {
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
- .option-container.selected:hover {
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-container.active:not(.disabled) {
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, 2px solid #1976d2);
1584
+ outline: var(--select-option-active-outline, none);
1608
1585
  outline-offset: var(--select-option-active-outline-offset, -2px);
1609
1586
  }
1610
-
1611
- .option-container.disabled {
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._config.disabled) {
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._config.disabled)
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
  /**
@@ -2010,6 +2084,8 @@ class EnhancedSelect extends HTMLElement {
2010
2084
  this._mirrorGlobalStylesForCustomOptions = false;
2011
2085
  this._globalStylesObserver = null;
2012
2086
  this._globalStylesContainer = null;
2087
+ this._themeContextObserver = null;
2088
+ this._globalStylesSyncToken = 0;
2013
2089
  this._tracking = { events: [], styles: [], limitations: [] };
2014
2090
  this._suppressBlurClose = false;
2015
2091
  this._renderCycleId = 0;
@@ -2125,6 +2201,7 @@ class EnhancedSelect extends HTMLElement {
2125
2201
  return;
2126
2202
  if (!this._mirrorGlobalStylesForCustomOptions)
2127
2203
  return;
2204
+ this._setupThemeContextMirroring();
2128
2205
  this._mirrorDocumentStylesIntoShadow();
2129
2206
  if (this._globalStylesObserver)
2130
2207
  return;
@@ -2143,6 +2220,10 @@ class EnhancedSelect extends HTMLElement {
2143
2220
  this._globalStylesObserver.disconnect();
2144
2221
  this._globalStylesObserver = null;
2145
2222
  }
2223
+ if (this._themeContextObserver) {
2224
+ this._themeContextObserver.disconnect();
2225
+ this._themeContextObserver = null;
2226
+ }
2146
2227
  if (this._globalStylesContainer) {
2147
2228
  this._globalStylesContainer.remove();
2148
2229
  this._globalStylesContainer = null;
@@ -2159,34 +2240,232 @@ class EnhancedSelect extends HTMLElement {
2159
2240
  this._shadow.appendChild(this._globalStylesContainer);
2160
2241
  }
2161
2242
  const container = this._globalStylesContainer;
2162
- container.innerHTML = '';
2243
+ const syncToken = ++this._globalStylesSyncToken;
2163
2244
  const styleNodes = Array.from(document.querySelectorAll('style,link[rel="stylesheet"]'));
2164
- styleNodes.forEach((node, index) => {
2165
- if (node instanceof HTMLStyleElement) {
2166
- const clonedStyle = document.createElement('style');
2167
- clonedStyle.setAttribute('data-smilodon-global-style', String(index));
2168
- clonedStyle.textContent = node.textContent || '';
2169
- container.appendChild(clonedStyle);
2245
+ void Promise.all(styleNodes.map((node, index) => this._createScopedGlobalStyleNode(node, index))).then((mirroredNodes) => {
2246
+ if (!this._globalStylesContainer || syncToken !== this._globalStylesSyncToken)
2247
+ return;
2248
+ container.replaceChildren(...mirroredNodes.filter((node) => Boolean(node)));
2249
+ this._syncMirroredThemeContext();
2250
+ });
2251
+ }
2252
+ _setupThemeContextMirroring() {
2253
+ if (typeof document === 'undefined')
2254
+ return;
2255
+ this._syncMirroredThemeContext();
2256
+ if (this._themeContextObserver)
2257
+ return;
2258
+ this._themeContextObserver = new MutationObserver(() => {
2259
+ this._syncMirroredThemeContext();
2260
+ });
2261
+ const targets = new Set([this, document.documentElement]);
2262
+ if (document.body) {
2263
+ targets.add(document.body);
2264
+ }
2265
+ let ancestor = this.parentElement;
2266
+ while (ancestor) {
2267
+ targets.add(ancestor);
2268
+ ancestor = ancestor.parentElement;
2269
+ }
2270
+ targets.forEach((target) => {
2271
+ this._themeContextObserver?.observe(target, {
2272
+ attributes: true,
2273
+ attributeFilter: ['class', 'dark-mode', 'darkmode', 'data-theme', 'theme'],
2274
+ });
2275
+ });
2276
+ }
2277
+ _syncMirroredThemeContext() {
2278
+ const scopeTarget = this._optionsContainer;
2279
+ if (!scopeTarget)
2280
+ return;
2281
+ const darkSelectors = [
2282
+ '.dark-mode',
2283
+ '.dark',
2284
+ '[dark-mode]',
2285
+ '[darkmode]',
2286
+ '[data-theme="dark"]',
2287
+ '[theme="dark"]',
2288
+ ];
2289
+ const isDark = darkSelectors.some((selector) => this.matches(selector) || Boolean(this.closest(selector)))
2290
+ || document.documentElement.matches('.dark-mode, .dark, [dark-mode], [darkmode], [data-theme="dark"], [theme="dark"]')
2291
+ || Boolean(document.body?.matches('.dark-mode, .dark, [dark-mode], [darkmode], [data-theme="dark"], [theme="dark"]'));
2292
+ scopeTarget.classList.toggle('dark', isDark);
2293
+ scopeTarget.classList.toggle('dark-mode', isDark);
2294
+ if (isDark) {
2295
+ scopeTarget.setAttribute('dark-mode', '');
2296
+ scopeTarget.setAttribute('data-theme', 'dark');
2297
+ scopeTarget.setAttribute('theme', 'dark');
2298
+ }
2299
+ else {
2300
+ scopeTarget.removeAttribute('dark-mode');
2301
+ scopeTarget.removeAttribute('data-theme');
2302
+ scopeTarget.removeAttribute('theme');
2303
+ }
2304
+ }
2305
+ async _createScopedGlobalStyleNode(node, index) {
2306
+ if (node instanceof HTMLStyleElement) {
2307
+ return this._buildScopedStyleElement(node.textContent || '', String(index));
2308
+ }
2309
+ if (node instanceof HTMLLinkElement && node.href) {
2310
+ try {
2311
+ const response = await fetch(node.href, {
2312
+ credentials: node.crossOrigin === 'use-credentials' ? 'include' : 'same-origin',
2313
+ mode: 'cors',
2314
+ });
2315
+ if (!response.ok) {
2316
+ return null;
2317
+ }
2318
+ const cssText = await response.text();
2319
+ return this._buildScopedStyleElement(cssText, String(index));
2320
+ }
2321
+ catch (_error) {
2322
+ return null;
2323
+ }
2324
+ }
2325
+ return null;
2326
+ }
2327
+ _buildScopedStyleElement(cssText, id) {
2328
+ const scopedCss = this._scopeMirroredCssText(cssText);
2329
+ if (!scopedCss.trim())
2330
+ return null;
2331
+ const style = document.createElement('style');
2332
+ style.setAttribute('data-smilodon-global-style', id);
2333
+ style.textContent = scopedCss;
2334
+ return style;
2335
+ }
2336
+ _scopeMirroredCssText(cssText) {
2337
+ if (!cssText.trim())
2338
+ return '';
2339
+ try {
2340
+ if (typeof CSSStyleSheet !== 'undefined') {
2341
+ const sheet = new CSSStyleSheet();
2342
+ sheet.replaceSync(cssText);
2343
+ return this._serializeScopedCssRules(Array.from(sheet.cssRules));
2344
+ }
2345
+ }
2346
+ catch (_error) {
2347
+ return '';
2348
+ }
2349
+ return '';
2350
+ }
2351
+ _serializeScopedCssRules(rules) {
2352
+ return rules.map((rule) => this._serializeScopedCssRule(rule)).filter(Boolean).join('\n');
2353
+ }
2354
+ _serializeScopedCssRule(rule) {
2355
+ if (rule instanceof CSSStyleRule) {
2356
+ const selectors = this._splitSelectorList(rule.selectorText)
2357
+ .map((selector) => this._scopeMirroredSelector(selector))
2358
+ .filter(Boolean);
2359
+ if (selectors.length === 0)
2360
+ return '';
2361
+ return `${selectors.join(', ')} { ${rule.style.cssText} }`;
2362
+ }
2363
+ if (rule instanceof CSSMediaRule) {
2364
+ const nested = this._serializeScopedCssRules(Array.from(rule.cssRules));
2365
+ return nested ? `@media ${rule.conditionText} { ${nested} }` : '';
2366
+ }
2367
+ if (typeof CSSSupportsRule !== 'undefined' && rule instanceof CSSSupportsRule) {
2368
+ const nested = this._serializeScopedCssRules(Array.from(rule.cssRules));
2369
+ return nested ? `@supports ${rule.conditionText} { ${nested} }` : '';
2370
+ }
2371
+ if (rule instanceof CSSFontFaceRule || rule instanceof CSSKeyframesRule) {
2372
+ return rule.cssText;
2373
+ }
2374
+ const nestedRule = rule;
2375
+ if (nestedRule.cssRules) {
2376
+ const nested = this._serializeScopedCssRules(Array.from(nestedRule.cssRules));
2377
+ if (!nested)
2378
+ return '';
2379
+ const ctorName = nestedRule.constructor?.name ?? '';
2380
+ if (ctorName.includes('Layer')) {
2381
+ return `@layer ${nestedRule.name ?? ''} { ${nested} }`;
2382
+ }
2383
+ if (ctorName.includes('Container')) {
2384
+ return `@container ${nestedRule.conditionText ?? ''} { ${nested} }`;
2385
+ }
2386
+ }
2387
+ return '';
2388
+ }
2389
+ _splitSelectorList(selectorText) {
2390
+ const selectors = [];
2391
+ let current = '';
2392
+ let depthRound = 0;
2393
+ let depthSquare = 0;
2394
+ for (const char of selectorText) {
2395
+ if (char === '(')
2396
+ depthRound += 1;
2397
+ if (char === ')')
2398
+ depthRound = Math.max(0, depthRound - 1);
2399
+ if (char === '[')
2400
+ depthSquare += 1;
2401
+ if (char === ']')
2402
+ depthSquare = Math.max(0, depthSquare - 1);
2403
+ if (char === ',' && depthRound === 0 && depthSquare === 0) {
2404
+ if (current.trim())
2405
+ selectors.push(current.trim());
2406
+ current = '';
2407
+ continue;
2408
+ }
2409
+ current += char;
2410
+ }
2411
+ if (current.trim())
2412
+ selectors.push(current.trim());
2413
+ return selectors;
2414
+ }
2415
+ _scopeMirroredSelector(selector) {
2416
+ const scopeClass = `.${EnhancedSelect._MIRRORED_STYLES_SCOPE_CLASS}`;
2417
+ let scopedSelector = selector
2418
+ .replace(/(^|\s|>|\+|~)(:root|html|body)(?=\b|\s|[.#[:>+~]|$)/g, `$1${scopeClass}`);
2419
+ const themePatterns = [
2420
+ /\.dark-mode(?![\w-]|\\:)/g,
2421
+ /\.dark(?![\w-]|\\:)/g,
2422
+ /\[dark-mode\]/g,
2423
+ /\[darkmode\]/g,
2424
+ /\[data-theme=(?:"dark"|'dark'|dark)\]/g,
2425
+ /\[theme=(?:"dark"|'dark'|dark)\]/g,
2426
+ ];
2427
+ let injectedThemeScope = false;
2428
+ themePatterns.forEach((pattern) => {
2429
+ scopedSelector = scopedSelector.replace(pattern, (match) => {
2430
+ injectedThemeScope = true;
2431
+ return `${match}${scopeClass}`;
2432
+ });
2433
+ });
2434
+ if (!scopedSelector.includes(EnhancedSelect._MIRRORED_STYLES_SCOPE_CLASS) && !injectedThemeScope) {
2435
+ scopedSelector = `${scopeClass} ${scopedSelector}`;
2436
+ }
2437
+ return scopedSelector;
2438
+ }
2439
+ _normalizeCustomOptionAccessibility(optionEl, meta) {
2440
+ if (!optionEl.hasAttribute('aria-label') && !optionEl.hasAttribute('aria-labelledby')) {
2441
+ optionEl.setAttribute('aria-label', meta.label);
2442
+ }
2443
+ const nestedFocusableSelectors = [
2444
+ 'a[href]',
2445
+ 'button',
2446
+ 'input',
2447
+ 'select',
2448
+ 'textarea',
2449
+ 'summary',
2450
+ '[tabindex]',
2451
+ '[contenteditable=""]',
2452
+ '[contenteditable="true"]',
2453
+ '[role="button"]',
2454
+ '[role="link"]',
2455
+ '[role="checkbox"]',
2456
+ '[role="switch"]',
2457
+ '[role="radio"]',
2458
+ '[role="textbox"]',
2459
+ ].join(', ');
2460
+ optionEl.querySelectorAll(nestedFocusableSelectors).forEach((child) => {
2461
+ if (child === optionEl)
2170
2462
  return;
2463
+ child.tabIndex = -1;
2464
+ if (!child.hasAttribute('data-smilodon-keep-role')) {
2465
+ child.setAttribute('role', 'presentation');
2171
2466
  }
2172
- if (node instanceof HTMLLinkElement && node.href) {
2173
- const clonedLink = document.createElement('link');
2174
- clonedLink.rel = 'stylesheet';
2175
- clonedLink.href = node.href;
2176
- if (node.media)
2177
- clonedLink.media = node.media;
2178
- if (node.crossOrigin)
2179
- clonedLink.crossOrigin = node.crossOrigin;
2180
- if (node.referrerPolicy)
2181
- clonedLink.referrerPolicy = node.referrerPolicy;
2182
- if (node.integrity)
2183
- clonedLink.integrity = node.integrity;
2184
- if (node.type)
2185
- clonedLink.type = node.type;
2186
- if (node.nonce)
2187
- clonedLink.nonce = node.nonce;
2188
- clonedLink.setAttribute('data-smilodon-global-link', String(index));
2189
- container.appendChild(clonedLink);
2467
+ if ((meta.disabled || child.matches('button, input, select, textarea, summary, a[href]')) && !child.hasAttribute('data-smilodon-keep-aria')) {
2468
+ child.setAttribute('aria-hidden', 'true');
2190
2469
  }
2191
2470
  });
2192
2471
  }
@@ -2247,6 +2526,20 @@ class EnhancedSelect extends HTMLElement {
2247
2526
  this._setCssVariable(variableName, styleConfig?.[styleKey]);
2248
2527
  });
2249
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
+ }
2250
2543
  _syncStyleConfigVariables() {
2251
2544
  const styles = this._config.styles;
2252
2545
  this._applyStyleVariableMap(styles.option, {
@@ -2304,6 +2597,21 @@ class EnhancedSelect extends HTMLElement {
2304
2597
  opacity: '--select-option-disabled-opacity',
2305
2598
  cursor: '--select-option-disabled-cursor',
2306
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);
2307
2615
  this._applyStyleVariableMap(styles.badge, {
2308
2616
  width: '--select-badge-width',
2309
2617
  minWidth: '--select-badge-min-width',
@@ -2362,6 +2670,15 @@ class EnhancedSelect extends HTMLElement {
2362
2670
  fontSize: '--select-badge-remove-font-size',
2363
2671
  fontWeight: '--select-badge-remove-font-weight',
2364
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
+ });
2365
2682
  this._applyStyleVariableMap(styles.badgeRemoveHover, {
2366
2683
  background: '--select-badge-remove-hover-bg',
2367
2684
  backgroundColor: '--select-badge-remove-hover-bg',
@@ -2462,11 +2779,24 @@ class EnhancedSelect extends HTMLElement {
2462
2779
  this._inputContainer.style.removeProperty('--select-multi-input-align-content-config');
2463
2780
  return;
2464
2781
  }
2465
- const maxHeight = this._config.multiSelectDisplay?.maxHeight ?? '160px';
2466
- const overflowX = this._config.multiSelectDisplay?.overflowX ?? (mode === 'horizontal' ? 'auto' : 'hidden');
2467
- const overflowY = this._config.multiSelectDisplay?.overflowY ?? (mode === 'horizontal' ? 'hidden' : 'auto');
2468
- const flexWrap = mode === 'horizontal' ? 'nowrap' : 'wrap';
2469
- const alignContent = mode === 'horizontal' ? 'center' : 'flex-start';
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
+ }
2470
2800
  this._inputContainer.setAttribute('data-multi-scroll-mode', mode);
2471
2801
  this._inputContainer.setAttribute('data-drag-scroll', String(dragEnabled && mode === 'horizontal'));
2472
2802
  this._inputContainer.style.setProperty('--select-multi-input-max-height-config', maxHeight);
@@ -2650,7 +2980,7 @@ class EnhancedSelect extends HTMLElement {
2650
2980
  }
2651
2981
  _createOptionsContainer() {
2652
2982
  const container = document.createElement('div');
2653
- container.className = 'options-container';
2983
+ container.className = `options-container ${EnhancedSelect._MIRRORED_STYLES_SCOPE_CLASS}`;
2654
2984
  return container;
2655
2985
  }
2656
2986
  _createLiveRegion() {
@@ -2749,6 +3079,11 @@ class EnhancedSelect extends HTMLElement {
2749
3079
  --select-badge-letter-spacing: 0.01em;
2750
3080
  --select-badge-hover-shadow: var(--select-shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.15);
2751
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;
2752
3087
  --select-badge-remove-focus-outline: 2px solid rgba(255, 255, 255, 0.5);
2753
3088
  --select-badge-remove-focus-offset: 1px;
2754
3089
  --select-badge-remove-hover-transform: scale(1.15) rotate(90deg);
@@ -2767,9 +3102,11 @@ class EnhancedSelect extends HTMLElement {
2767
3102
  --select-multi-input-overflow-y: auto;
2768
3103
  --select-multi-input-flex-wrap: wrap;
2769
3104
  --select-multi-input-align-content: flex-start;
3105
+ --select-multi-input-horizontal-height: var(--select-input-min-height, 48px);
2770
3106
  --select-multi-input-horizontal-input-flex: 0 0 var(--select-multi-input-min-width, 96px);
2771
3107
  --select-multi-input-horizontal-cursor: grab;
2772
3108
  --select-multi-input-horizontal-active-cursor: grabbing;
3109
+ --select-multi-input-end-gap: 12px;
2773
3110
  --select-multi-separator-inset-block: 10px;
2774
3111
  --select-multi-separator-height: auto;
2775
3112
  --select-multi-action-surface-bg: var(--select-input-bg, var(--select-surface));
@@ -2820,8 +3157,16 @@ class EnhancedSelect extends HTMLElement {
2820
3157
  --select-multi-container-padding: 6px;
2821
3158
  --select-option-disabled-opacity: 0.5;
2822
3159
  --select-option-disabled-cursor: not-allowed;
3160
+ --select-option-active-outline: none;
2823
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;
2824
3168
  --select-option-selected-active-outline-offset: -2px;
3169
+ --select-option-selected-indicator-display: block;
2825
3170
  --select-option-selected-indicator-width: 3px;
2826
3171
  --select-option-selected-indicator-height: 60%;
2827
3172
  --select-option-selected-indicator-bg: var(--select-accent);
@@ -2834,8 +3179,8 @@ class EnhancedSelect extends HTMLElement {
2834
3179
  --select-option-selected-indicator-to-height: 60%;
2835
3180
  --select-option-selected-indicator-from-opacity: 0;
2836
3181
  --select-option-selected-indicator-to-opacity: 1;
2837
- --select-option-pressed-transform: translateX(2px) scale(0.99);
2838
- --select-option-selected-pressed-transform: scale(0.99);
3182
+ --select-option-pressed-transform: none;
3183
+ --select-option-selected-pressed-transform: none;
2839
3184
  --select-button-hover-transform: translateY(-1px);
2840
3185
  --select-button-active-transform: translateY(0) scale(0.98);
2841
3186
  --select-button-font-weight: 550;
@@ -2997,6 +3342,11 @@ class EnhancedSelect extends HTMLElement {
2997
3342
  justify-content: center;
2998
3343
  width: var(--select-badge-remove-icon-size, 10px);
2999
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);
3000
3350
  pointer-events: none;
3001
3351
  }
3002
3352
 
@@ -3102,13 +3452,26 @@ class EnhancedSelect extends HTMLElement {
3102
3452
 
3103
3453
  .input-container.input-container--multi {
3104
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);
3105
3456
  }
3106
3457
 
3107
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)));
3108
3462
  flex-wrap: var(--select-multi-input-flex-wrap, var(--select-multi-input-flex-wrap-config, wrap));
3109
3463
  align-content: var(--select-multi-input-align-content, var(--select-multi-input-align-content-config, flex-start));
3110
3464
  overflow-x: var(--select-multi-input-overflow-x, var(--select-multi-input-overflow-x-config, hidden));
3111
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));
3112
3475
  }
3113
3476
 
3114
3477
  .input-container.input-container--multi::after {
@@ -3119,17 +3482,31 @@ class EnhancedSelect extends HTMLElement {
3119
3482
 
3120
3483
  .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] {
3121
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;
3122
3489
  }
3123
3490
 
3124
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%;
3125
3497
  cursor: var(--select-multi-input-horizontal-cursor, grab);
3498
+ align-items: center;
3499
+ align-content: center;
3500
+ flex-wrap: nowrap;
3126
3501
  overflow-y: hidden;
3127
3502
  overscroll-behavior-x: contain;
3128
- padding-right: calc(var(--select-arrow-width, 42px) + var(--select-multi-horizontal-end-gap, 12px));
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));
3129
3506
  }
3130
3507
 
3131
3508
  .input-container.input-container--multi[data-multi-scroll-mode="horizontal"].has-clear-control .input-content {
3132
- padding-right: 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));
3509
+ --select-multi-action-area-width: calc(var(--select-arrow-right-with-clear, 34px) + var(--select-arrow-width, 42px));
3133
3510
  }
3134
3511
 
3135
3512
  .input-container.input-container--multi[data-multi-scroll-mode="horizontal"]::after {
@@ -3141,8 +3518,10 @@ class EnhancedSelect extends HTMLElement {
3141
3518
  user-select: none;
3142
3519
  }
3143
3520
 
3144
- .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .input-content .selection-badge {
3521
+ .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .selection-badge {
3145
3522
  flex: 0 0 auto;
3523
+ margin-top: 0;
3524
+ margin-bottom: 0;
3146
3525
  }
3147
3526
 
3148
3527
  .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .input-content > .select-input,
@@ -3171,15 +3550,6 @@ class EnhancedSelect extends HTMLElement {
3171
3550
  left: var(--select-arrow-right-with-clear, 34px);
3172
3551
  }
3173
3552
 
3174
- :host([dir="rtl"]) .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .input-content {
3175
- padding-right: 0;
3176
- padding-left: calc(var(--select-arrow-width, 42px) + var(--select-multi-horizontal-end-gap, 12px));
3177
- }
3178
-
3179
- :host([dir="rtl"]) .input-container.input-container--multi[data-multi-scroll-mode="horizontal"].has-clear-control .input-content {
3180
- 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));
3181
- }
3182
-
3183
3553
  .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .clear-control-button {
3184
3554
  background: var(--select-multi-action-surface-bg, var(--select-input-bg, var(--select-surface)));
3185
3555
  z-index: 4;
@@ -3568,7 +3938,8 @@ class EnhancedSelect extends HTMLElement {
3568
3938
  margin: var(--select-option-margin);
3569
3939
  }
3570
3940
 
3571
- .option:hover {
3941
+ .option:hover:not(.disabled):not(.smilodon-option--disabled),
3942
+ .option.smilodon-option--disabled-hoverable:hover {
3572
3943
  background: var(--select-option-hover-bg, var(--select-surface-elevated));
3573
3944
  border: var(--select-option-hover-border, var(--select-option-border, none));
3574
3945
  color: var(--select-option-hover-color, var(--select-text));
@@ -3583,7 +3954,8 @@ class EnhancedSelect extends HTMLElement {
3583
3954
  }
3584
3955
 
3585
3956
  .option.selected::before {
3586
- content: '';
3957
+ content: var(--select-option-selected-indicator-content, '');
3958
+ display: var(--select-option-selected-indicator-display, block);
3587
3959
  position: absolute;
3588
3960
  left: var(--select-option-selected-indicator-left);
3589
3961
  top: var(--select-option-selected-indicator-top);
@@ -3618,35 +3990,50 @@ class EnhancedSelect extends HTMLElement {
3618
3990
  color: var(--select-option-selected-hover-color, var(--select-option-selected-color, var(--select-accent)));
3619
3991
  }
3620
3992
 
3621
- .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) {
3622
3995
  background: var(--select-option-active-bg, var(--select-surface-elevated));
3623
3996
  color: var(--select-option-active-color, var(--select-option-hover-color, var(--select-option-color, var(--select-text))));
3624
3997
  border: var(--select-option-active-border, var(--select-option-hover-border, var(--select-option-border, none)));
3625
- outline: var(--select-option-active-outline, 2px solid rgba(15, 52, 96, 0.3));
3998
+ outline: var(--select-option-active-outline, none);
3626
3999
  outline-offset: var(--select-option-active-outline-offset);
3627
4000
  box-shadow: var(--select-option-active-shadow, none);
3628
4001
  transform: var(--select-option-active-transform, none);
3629
4002
  }
3630
4003
 
3631
- .option.selected.active:not(.disabled) {
3632
- outline: var(--select-option-selected-active-outline, 2px solid rgba(15, 52, 96, 0.4));
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));
3633
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));
3634
4013
  }
3635
4014
 
3636
- .option.disabled {
4015
+ .option.disabled,
4016
+ .option.smilodon-option--disabled {
3637
4017
  background: var(--select-option-disabled-bg, var(--select-option-bg, transparent));
3638
4018
  color: var(--select-option-disabled-color, var(--select-text-muted));
3639
4019
  border: var(--select-option-disabled-border, var(--select-option-border, none));
3640
4020
  opacity: var(--select-option-disabled-opacity, 0.5);
3641
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;
3642
4027
  }
3643
4028
 
3644
- .option:active:not(.selected) {
4029
+ .option:active:not(.selected):not(.disabled):not(.smilodon-option--disabled),
4030
+ .option.smilodon-option--disabled-selectable:active:not(.selected) {
3645
4031
  background: var(--select-option-pressed-bg, rgba(15, 52, 96, 0.08));
3646
4032
  transform: var(--select-option-pressed-transform);
3647
4033
  }
3648
4034
 
3649
- .option.selected:active {
4035
+ .option.selected:active:not(.disabled):not(.smilodon-option--disabled),
4036
+ .option.selected.smilodon-option--disabled-selectable:active {
3650
4037
  transform: var(--select-option-selected-pressed-transform);
3651
4038
  }
3652
4039
 
@@ -4222,7 +4609,7 @@ class EnhancedSelect extends HTMLElement {
4222
4609
  continue;
4223
4610
  }
4224
4611
  }
4225
- if (option && !option.hasAttribute('aria-disabled')) {
4612
+ if (option && (!option.hasAttribute('aria-disabled') || option.classList.contains('smilodon-option--disabled-selectable'))) {
4226
4613
  const indexStr = option.getAttribute('data-sm-index') ?? option.getAttribute('data-index');
4227
4614
  const index = Number(indexStr);
4228
4615
  if (!Number.isNaN(index)) {
@@ -4666,7 +5053,7 @@ class EnhancedSelect extends HTMLElement {
4666
5053
  }
4667
5054
  _setActive(index) {
4668
5055
  const option = this._getOptionElementByIndex(index);
4669
- if (!option || option.getAttribute('aria-disabled') === 'true') {
5056
+ if (!option || (option.getAttribute('aria-disabled') === 'true' && !option.classList.contains('smilodon-option--disabled-focusable'))) {
4670
5057
  return;
4671
5058
  }
4672
5059
  // Clear previous active state
@@ -4714,7 +5101,7 @@ class EnhancedSelect extends HTMLElement {
4714
5101
  // Only return elements with data-index or data-sm-selectable attributes
4715
5102
  return Array.from(this._optionsContainer.children).filter((child) => {
4716
5103
  return (child.hasAttribute('data-index') || child.hasAttribute('data-sm-selectable'))
4717
- && child.getAttribute('aria-disabled') !== 'true';
5104
+ && (child.getAttribute('aria-disabled') !== 'true' || child.classList.contains('smilodon-option--disabled-focusable'));
4718
5105
  });
4719
5106
  }
4720
5107
  _getSelectableOptionIndices() {
@@ -4769,6 +5156,8 @@ class EnhancedSelect extends HTMLElement {
4769
5156
  // Check if it's a custom SelectOption or a lightweight DOM element
4770
5157
  if ('getConfig' in option && typeof option.getConfig === 'function') {
4771
5158
  const config = option.getConfig();
5159
+ if (this._isOptionSelectionBlocked(config.item))
5160
+ return;
4772
5161
  this._state.selectedIndices.add(optionIndex);
4773
5162
  this._state.selectedItems.set(optionIndex, config.item);
4774
5163
  option.setSelected(true);
@@ -4776,7 +5165,7 @@ class EnhancedSelect extends HTMLElement {
4776
5165
  else {
4777
5166
  // Lightweight option - get item from data attribute or state
4778
5167
  const item = this._state.loadedItems[optionIndex];
4779
- if (item) {
5168
+ if (item && !this._isOptionSelectionBlocked(item)) {
4780
5169
  this._state.selectedIndices.add(optionIndex);
4781
5170
  this._state.selectedItems.set(optionIndex, item);
4782
5171
  option.classList.add('smilodon-option--selected');
@@ -4803,10 +5192,12 @@ class EnhancedSelect extends HTMLElement {
4803
5192
  break;
4804
5193
  const item = this._state.loadedItems[i];
4805
5194
  const optionEl = this._getOptionElementByIndex(i);
4806
- if (optionEl?.getAttribute('aria-disabled') === 'true')
5195
+ if (optionEl?.getAttribute('aria-disabled') === 'true' && !optionEl.classList.contains('smilodon-option--disabled-selectable'))
4807
5196
  continue;
4808
5197
  if (!item)
4809
5198
  continue;
5199
+ if (this._isOptionSelectionBlocked(item))
5200
+ continue;
4810
5201
  this._state.selectedIndices.add(i);
4811
5202
  this._state.selectedItems.set(i, item);
4812
5203
  }
@@ -4844,6 +5235,9 @@ class EnhancedSelect extends HTMLElement {
4844
5235
  if (!item) {
4845
5236
  return;
4846
5237
  }
5238
+ if (this._isOptionSelectionBlocked(item)) {
5239
+ return;
5240
+ }
4847
5241
  const isCurrentlySelected = this._state.selectedIndices.has(index);
4848
5242
  // Keep active/focus styling aligned with the most recently interacted option.
4849
5243
  // Without this, a previously selected item may retain active classes/styles
@@ -4997,6 +5391,9 @@ class EnhancedSelect extends HTMLElement {
4997
5391
  removeBtn.setAttribute('aria-label', `Remove ${getLabel(item)}`);
4998
5392
  const removeIcon = document.createElement('span');
4999
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
+ }
5000
5397
  removeIcon.setAttribute('part', 'chip-remove-icon');
5001
5398
  this._setIconContent(removeIcon, this._config.selection.removeButtonIcon, '×');
5002
5399
  removeBtn.appendChild(removeIcon);
@@ -5373,7 +5770,7 @@ class EnhancedSelect extends HTMLElement {
5373
5770
  this._state.selectedIndices.clear();
5374
5771
  this._state.selectedItems.clear();
5375
5772
  this._state.loadedItems.forEach((item, index) => {
5376
- if (values.includes(getValue(item))) {
5773
+ if (values.includes(getValue(item)) && !this._isOptionSelectionBlocked(item)) {
5377
5774
  this._state.selectedIndices.add(index);
5378
5775
  this._state.selectedItems.set(index, item);
5379
5776
  }
@@ -5395,6 +5792,8 @@ class EnhancedSelect extends HTMLElement {
5395
5792
  this._state.selectedIndices.clear();
5396
5793
  this._state.selectedItems.clear();
5397
5794
  items.forEach((item, index) => {
5795
+ if (this._isOptionSelectionBlocked(item))
5796
+ return;
5398
5797
  this._state.selectedIndices.add(index);
5399
5798
  this._state.selectedItems.set(index, item);
5400
5799
  });
@@ -5659,6 +6058,9 @@ class EnhancedSelect extends HTMLElement {
5659
6058
  if (this._config.styles.classNames?.groupHeader) {
5660
6059
  header.classList.add(...this._config.styles.classNames.groupHeader.split(' ').filter(Boolean));
5661
6060
  }
6061
+ if (!header.hasAttribute('role')) {
6062
+ header.setAttribute('role', 'presentation');
6063
+ }
5662
6064
  header.setAttribute('part', 'group-header');
5663
6065
  this._optionsContainer.appendChild(header);
5664
6066
  group.options.forEach(item => {
@@ -5773,6 +6175,7 @@ class EnhancedSelect extends HTMLElement {
5773
6175
  _renderSingleOption(item, index, getValue, getLabel, targetContainer = this._optionsContainer) {
5774
6176
  const isSelected = this._state.selectedIndices.has(index);
5775
6177
  const isDisabled = Boolean(item?.disabled);
6178
+ const disabledBehavior = this._getDisabledOptionBehavior();
5776
6179
  const optionId = `${this._uniqueId}-option-${index}`;
5777
6180
  if (this._optionRenderer) {
5778
6181
  const rendered = this._optionRenderer(item, index, this._rendererHelpers);
@@ -5784,6 +6187,7 @@ class EnhancedSelect extends HTMLElement {
5784
6187
  selected: isSelected,
5785
6188
  active: this._state.activeIndex === index,
5786
6189
  disabled: isDisabled,
6190
+ disabledBehavior,
5787
6191
  id: optionId,
5788
6192
  });
5789
6193
  optionElement.setAttribute('dir', this._config.direction ?? 'ltr');
@@ -5796,6 +6200,7 @@ class EnhancedSelect extends HTMLElement {
5796
6200
  id: optionId,
5797
6201
  selected: isSelected,
5798
6202
  disabled: isDisabled,
6203
+ disabledBehavior,
5799
6204
  active: this._state.activeIndex === index,
5800
6205
  getValue,
5801
6206
  getLabel,
@@ -5857,6 +6262,10 @@ class EnhancedSelect extends HTMLElement {
5857
6262
  const isSelected = meta.selected;
5858
6263
  const isActive = meta.active;
5859
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);
5860
6269
  // Resolve classes from classMap or defaults
5861
6270
  const selectedClasses = (this.classMap?.selected ?? 'selected sm-selected').split(' ').filter(Boolean);
5862
6271
  const activeClasses = (this.classMap?.active ?? 'active sm-active').split(' ').filter(Boolean);
@@ -5903,6 +6312,10 @@ class EnhancedSelect extends HTMLElement {
5903
6312
  optionEl.classList.remove(...this._config.styles.classNames.disabledOption.split(' ').filter(Boolean));
5904
6313
  }
5905
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);
5906
6319
  // Data Attributes Contract
5907
6320
  const state = [];
5908
6321
  if (isSelected)
@@ -5934,11 +6347,8 @@ class EnhancedSelect extends HTMLElement {
5934
6347
  if (!optionEl.getAttribute('role')) {
5935
6348
  optionEl.setAttribute('role', 'option');
5936
6349
  }
5937
- if (!optionEl.getAttribute('aria-label')) {
5938
- optionEl.setAttribute('aria-label', meta.label);
5939
- }
5940
6350
  optionEl.setAttribute('aria-selected', String(meta.selected));
5941
- if (meta.disabled) {
6351
+ if (meta.disabled && !meta.disabledBehavior.selectable) {
5942
6352
  optionEl.setAttribute('aria-disabled', 'true');
5943
6353
  }
5944
6354
  else {
@@ -5953,6 +6363,10 @@ class EnhancedSelect extends HTMLElement {
5953
6363
  // Re-attaching here causes the double-click toggle bug if a child component fails to stopPropagation.
5954
6364
  this._customOptionBoundElements.add(optionEl);
5955
6365
  }
6366
+ this._normalizeCustomOptionAccessibility(optionEl, {
6367
+ label: meta.label,
6368
+ disabled: meta.disabled,
6369
+ });
5956
6370
  return optionEl;
5957
6371
  }
5958
6372
  _addLoadMoreTrigger() {
@@ -5987,6 +6401,7 @@ class EnhancedSelect extends HTMLElement {
5987
6401
  }
5988
6402
  /** live set of all connected instances; used to auto-close siblings */
5989
6403
  EnhancedSelect._instances = new Set();
6404
+ EnhancedSelect._MIRRORED_STYLES_SCOPE_CLASS = 'smilodon-mirrored-styles-scope';
5990
6405
  // Register custom element
5991
6406
  if (!customElements.get('enhanced-select')) {
5992
6407
  customElements.define('enhanced-select', EnhancedSelect);