@smilodon/core 1.4.13 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1348,9 +1348,21 @@ const defaultConfig = {
1348
1348
  allowDeselect: false,
1349
1349
  maxSelections: 0,
1350
1350
  showRemoveButton: true,
1351
+ removeButtonIcon: '×',
1351
1352
  closeOnSelect: true,
1352
1353
  toggleOnTriggerClick: true,
1353
1354
  },
1355
+ direction: 'ltr',
1356
+ dropdownPlacement: {
1357
+ mode: 'bottom',
1358
+ },
1359
+ multiSelectDisplay: {
1360
+ mode: 'wrap',
1361
+ maxHeight: '160px',
1362
+ overflowX: 'hidden',
1363
+ overflowY: 'auto',
1364
+ dragScroll: true,
1365
+ },
1354
1366
  scrollToSelected: {
1355
1367
  enabled: true,
1356
1368
  multiSelectTarget: 'first',
@@ -1511,6 +1523,8 @@ class SelectOption extends HTMLElement {
1511
1523
  :host {
1512
1524
  display: block;
1513
1525
  position: relative;
1526
+ font: inherit;
1527
+ color: inherit;
1514
1528
  }
1515
1529
 
1516
1530
  /* Allow authors to style selected state from outside the shadow root
@@ -1542,7 +1556,7 @@ class SelectOption extends HTMLElement {
1542
1556
  display: flex;
1543
1557
  align-items: center;
1544
1558
  justify-content: space-between;
1545
- padding: var(--select-option-padding, 8px 12px);
1559
+ padding: var(--select-option-padding, 10px 14px);
1546
1560
  cursor: pointer;
1547
1561
  user-select: none;
1548
1562
  color: var(--select-option-color, var(--select-text-color, #1f2937));
@@ -1550,13 +1564,19 @@ class SelectOption extends HTMLElement {
1550
1564
  transition: var(--select-option-transition, background-color 0.2s ease);
1551
1565
  border: var(--select-option-border, none);
1552
1566
  border-bottom: var(--select-option-border-bottom, none);
1553
- border-radius: var(--select-option-border-radius, 0);
1567
+ border-radius: var(--select-option-border-radius, var(--select-radius-sm, 6px));
1554
1568
  box-shadow: var(--select-option-shadow, none);
1555
1569
  transform: var(--select-option-transform, none);
1570
+ font: inherit;
1556
1571
  }
1557
1572
 
1558
1573
  .option-container:hover {
1559
1574
  background: var(--select-option-hover-bg, #f0f0f0);
1575
+ color: var(--select-option-hover-color, var(--select-option-color, var(--select-text-color, #1f2937)));
1576
+ border: var(--select-option-hover-border, var(--select-option-border, none));
1577
+ border-bottom: var(--select-option-hover-border-bottom, var(--select-option-border-bottom, none));
1578
+ box-shadow: var(--select-option-hover-shadow, var(--select-option-shadow, none));
1579
+ transform: var(--select-option-hover-transform, var(--select-option-transform, none));
1560
1580
  }
1561
1581
 
1562
1582
  .option-container.selected {
@@ -1579,13 +1599,22 @@ class SelectOption extends HTMLElement {
1579
1599
  }
1580
1600
 
1581
1601
  .option-container.active {
1582
- outline: 2px solid var(--select-option-active-outline, #1976d2);
1583
- outline-offset: -2px;
1602
+ background: var(--select-option-active-bg, var(--select-option-hover-bg, #f0f0f0));
1603
+ color: var(--select-option-active-color, var(--select-option-hover-color, var(--select-option-color, var(--select-text-color, #1f2937))));
1604
+ border: var(--select-option-active-border, var(--select-option-hover-border, var(--select-option-border, none)));
1605
+ box-shadow: var(--select-option-active-shadow, var(--select-option-shadow, none));
1606
+ transform: var(--select-option-active-transform, var(--select-option-transform, none));
1607
+ outline: var(--select-option-active-outline, 2px solid #1976d2);
1608
+ outline-offset: var(--select-option-active-outline-offset, -2px);
1584
1609
  }
1585
1610
 
1586
1611
  .option-container.disabled {
1587
- opacity: 0.5;
1588
- cursor: not-allowed;
1612
+ background: var(--select-option-disabled-bg, var(--select-option-bg, var(--select-dropdown-bg, var(--select-bg, white))));
1613
+ color: var(--select-option-disabled-color, var(--select-option-color, var(--select-text-color, #1f2937)));
1614
+ border: var(--select-option-disabled-border, var(--select-option-border, none));
1615
+ border-bottom: var(--select-option-disabled-border-bottom, var(--select-option-border-bottom, none));
1616
+ opacity: var(--select-option-disabled-opacity, 0.5);
1617
+ cursor: var(--select-option-disabled-cursor, not-allowed);
1589
1618
  pointer-events: none;
1590
1619
  }
1591
1620
 
@@ -1602,6 +1631,12 @@ class SelectOption extends HTMLElement {
1602
1631
  color: var(--select-checkmark-color, currentColor);
1603
1632
  }
1604
1633
 
1634
+ :host([dir="rtl"]) .checkmark-icon,
1635
+ :host-context([dir="rtl"]) .checkmark-icon {
1636
+ margin-left: 0;
1637
+ margin-right: var(--select-checkmark-margin-left, 8px);
1638
+ }
1639
+
1605
1640
  :host([aria-selected="true"]) .checkmark-icon,
1606
1641
  .option-container.selected .checkmark-icon {
1607
1642
  display: inline-flex;
@@ -1609,20 +1644,49 @@ class SelectOption extends HTMLElement {
1609
1644
 
1610
1645
  .remove-button {
1611
1646
  margin-left: 8px;
1612
- padding: 2px 6px;
1647
+ width: var(--select-badge-remove-size, 18px);
1648
+ height: var(--select-badge-remove-size, 18px);
1649
+ min-width: var(--select-badge-remove-min-width, var(--select-badge-remove-size, 18px));
1650
+ min-height: var(--select-badge-remove-min-height, var(--select-badge-remove-size, 18px));
1651
+ padding: 0;
1613
1652
  border: none;
1614
- background-color: var(--select-remove-btn-bg, transparent);
1615
- color: var(--select-remove-btn-color, #666);
1653
+ background-color: var(--select-badge-remove-bg, rgba(255, 255, 255, 0.2));
1654
+ color: var(--select-badge-remove-color, currentColor);
1616
1655
  cursor: pointer;
1617
- border-radius: 3px;
1618
- font-size: 16px;
1656
+ border-radius: var(--select-badge-remove-radius, 50%);
1657
+ font-size: var(--select-badge-remove-font-size, 0.7333em);
1658
+ font-weight: var(--select-badge-remove-font-weight, 600);
1619
1659
  line-height: 1;
1660
+ display: inline-flex;
1661
+ align-items: center;
1662
+ justify-content: center;
1620
1663
  transition: all 0.2s ease;
1621
1664
  }
1665
+
1666
+ :host([dir="rtl"]) .remove-button,
1667
+ :host-context([dir="rtl"]) .remove-button {
1668
+ margin-left: 0;
1669
+ margin-right: 8px;
1670
+ }
1671
+
1672
+ .remove-button-icon {
1673
+ display: inline-flex;
1674
+ align-items: center;
1675
+ justify-content: center;
1676
+ width: var(--select-badge-remove-icon-size, 10px);
1677
+ height: var(--select-badge-remove-icon-size, 10px);
1678
+ pointer-events: none;
1679
+ }
1680
+
1681
+ .remove-button-icon svg {
1682
+ width: 100%;
1683
+ height: 100%;
1684
+ display: block;
1685
+ }
1622
1686
 
1623
1687
  .remove-button:hover {
1624
- background-color: var(--select-remove-btn-hover-bg, #ffebee);
1625
- color: var(--select-remove-btn-hover-color, #c62828);
1688
+ background-color: var(--select-badge-remove-hover-bg, #ffebee);
1689
+ color: var(--select-badge-remove-hover-color, #c62828);
1626
1690
  }
1627
1691
 
1628
1692
  .remove-button:focus {
@@ -1709,10 +1773,22 @@ class SelectOption extends HTMLElement {
1709
1773
  if (showRemoveButton && selected) {
1710
1774
  this._removeButton = document.createElement('button');
1711
1775
  this._removeButton.className = 'remove-button';
1712
- this._removeButton.innerHTML = '×';
1713
1776
  this._removeButton.setAttribute('part', 'chip-remove');
1714
1777
  this._removeButton.setAttribute('aria-label', 'Remove option');
1715
1778
  this._removeButton.setAttribute('type', 'button');
1779
+ const removeIcon = document.createElement('span');
1780
+ removeIcon.className = 'remove-button-icon';
1781
+ removeIcon.setAttribute('part', 'chip-remove-icon');
1782
+ const iconMarkup = this._config.removeButtonIcon && this._config.removeButtonIcon.trim()
1783
+ ? this._config.removeButtonIcon
1784
+ : '×';
1785
+ if (iconMarkup.trim().startsWith('<')) {
1786
+ removeIcon.innerHTML = iconMarkup;
1787
+ }
1788
+ else {
1789
+ removeIcon.textContent = iconMarkup;
1790
+ }
1791
+ this._removeButton.appendChild(removeIcon);
1716
1792
  this._container.appendChild(this._removeButton);
1717
1793
  }
1718
1794
  // Set ARIA attributes and State attributes on Host
@@ -1933,6 +2009,16 @@ class EnhancedSelect extends HTMLElement {
1933
2009
  this._tracking = { events: [], styles: [], limitations: [] };
1934
2010
  this._suppressBlurClose = false;
1935
2011
  this._renderCycleId = 0;
2012
+ this._suppressNextOpenClick = false;
2013
+ this._resolvedDropdownPlacement = 'bottom';
2014
+ this._multiScrollDrag = {
2015
+ active: false,
2016
+ moved: false,
2017
+ pointerId: -1,
2018
+ startX: 0,
2019
+ startScrollLeft: 0,
2020
+ };
2021
+ this._liftedAncestors = [];
1936
2022
  this._shadow = this.attachShadow({ mode: 'open' });
1937
2023
  this._uniqueId = `enhanced-select-${Math.random().toString(36).substr(2, 9)}`;
1938
2024
  this._rendererHelpers = this._buildRendererHelpers();
@@ -1960,6 +2046,7 @@ class EnhancedSelect extends HTMLElement {
1960
2046
  // Create DOM structure
1961
2047
  this._container = this._createContainer();
1962
2048
  this._inputContainer = this._createInputContainer();
2049
+ this._inputContent = this._createInputContent();
1963
2050
  this._input = this._createInput();
1964
2051
  this._arrowContainer = this._createArrowContainer();
1965
2052
  this._clearControl = this._createClearControl();
@@ -1968,6 +2055,8 @@ class EnhancedSelect extends HTMLElement {
1968
2055
  this._liveRegion = this._createLiveRegion();
1969
2056
  // Initialize styles BEFORE assembling DOM (order matters in shadow DOM)
1970
2057
  this._initializeStyles();
2058
+ this._syncStyleConfigVariables();
2059
+ this._syncDirectionConfig();
1971
2060
  this._assembleDOM();
1972
2061
  this._attachEventListeners();
1973
2062
  this._initializeObservers();
@@ -2003,6 +2092,7 @@ class EnhancedSelect extends HTMLElement {
2003
2092
  clearTimeout(this._typeTimeout);
2004
2093
  if (this._searchTimeout)
2005
2094
  clearTimeout(this._searchTimeout);
2095
+ this._endMultiScrollDrag();
2006
2096
  // Cleanup arrow click listener
2007
2097
  if (this._boundArrowClick && this._arrowContainer) {
2008
2098
  this._arrowContainer.removeEventListener('click', this._boundArrowClick);
@@ -2136,6 +2226,203 @@ class EnhancedSelect extends HTMLElement {
2136
2226
  }
2137
2227
  return container;
2138
2228
  }
2229
+ _createInputContent() {
2230
+ const content = document.createElement('div');
2231
+ content.className = 'input-content';
2232
+ return content;
2233
+ }
2234
+ _setCssVariable(name, value) {
2235
+ if (value == null || value === '') {
2236
+ this.style.removeProperty(name);
2237
+ return;
2238
+ }
2239
+ this.style.setProperty(name, String(value));
2240
+ }
2241
+ _applyStyleVariableMap(styleConfig, variableMap) {
2242
+ Object.entries(variableMap).forEach(([styleKey, variableName]) => {
2243
+ this._setCssVariable(variableName, styleConfig?.[styleKey]);
2244
+ });
2245
+ }
2246
+ _syncStyleConfigVariables() {
2247
+ const styles = this._config.styles;
2248
+ this._applyStyleVariableMap(styles.option, {
2249
+ background: '--select-option-bg',
2250
+ backgroundColor: '--select-option-bg',
2251
+ color: '--select-option-color',
2252
+ border: '--select-option-border',
2253
+ borderBottom: '--select-option-border-bottom',
2254
+ borderRadius: '--select-option-border-radius',
2255
+ boxShadow: '--select-option-shadow',
2256
+ transform: '--select-option-transform',
2257
+ padding: '--select-option-padding',
2258
+ margin: '--select-option-margin',
2259
+ fontSize: '--select-option-font-size',
2260
+ fontWeight: '--select-option-font-weight',
2261
+ lineHeight: '--select-option-line-height',
2262
+ textAlign: '--select-option-text-align',
2263
+ });
2264
+ this._applyStyleVariableMap(styles.selectedOption, {
2265
+ background: '--select-option-selected-bg',
2266
+ backgroundColor: '--select-option-selected-bg',
2267
+ color: '--select-option-selected-color',
2268
+ border: '--select-option-selected-border',
2269
+ borderBottom: '--select-option-selected-border-bottom',
2270
+ borderRadius: '--select-option-selected-border-radius',
2271
+ boxShadow: '--select-option-selected-shadow',
2272
+ transform: '--select-option-selected-transform',
2273
+ fontWeight: '--select-option-selected-weight',
2274
+ });
2275
+ this._applyStyleVariableMap(styles.hoverOption, {
2276
+ background: '--select-option-hover-bg',
2277
+ backgroundColor: '--select-option-hover-bg',
2278
+ color: '--select-option-hover-color',
2279
+ border: '--select-option-hover-border',
2280
+ borderBottom: '--select-option-hover-border-bottom',
2281
+ boxShadow: '--select-option-hover-shadow',
2282
+ transform: '--select-option-hover-transform',
2283
+ });
2284
+ this._applyStyleVariableMap(styles.activeOption, {
2285
+ background: '--select-option-active-bg',
2286
+ backgroundColor: '--select-option-active-bg',
2287
+ color: '--select-option-active-color',
2288
+ border: '--select-option-active-border',
2289
+ outline: '--select-option-active-outline',
2290
+ outlineOffset: '--select-option-active-outline-offset',
2291
+ boxShadow: '--select-option-active-shadow',
2292
+ transform: '--select-option-active-transform',
2293
+ });
2294
+ this._applyStyleVariableMap(styles.disabledOption, {
2295
+ background: '--select-option-disabled-bg',
2296
+ backgroundColor: '--select-option-disabled-bg',
2297
+ color: '--select-option-disabled-color',
2298
+ border: '--select-option-disabled-border',
2299
+ borderBottom: '--select-option-disabled-border-bottom',
2300
+ opacity: '--select-option-disabled-opacity',
2301
+ cursor: '--select-option-disabled-cursor',
2302
+ });
2303
+ this._applyStyleVariableMap(styles.badge, {
2304
+ width: '--select-badge-width',
2305
+ minWidth: '--select-badge-min-width',
2306
+ maxWidth: '--select-badge-max-width',
2307
+ height: '--select-badge-height',
2308
+ minHeight: '--select-badge-min-height',
2309
+ padding: '--select-badge-padding',
2310
+ margin: '--select-badge-margin',
2311
+ gap: '--select-badge-gap',
2312
+ background: '--select-badge-bg',
2313
+ backgroundColor: '--select-badge-bg',
2314
+ color: '--select-badge-color',
2315
+ border: '--select-badge-border',
2316
+ borderRadius: '--select-badge-border-radius',
2317
+ boxShadow: '--select-badge-shadow',
2318
+ fontSize: '--select-badge-font-size',
2319
+ fontWeight: '--select-badge-font-weight',
2320
+ lineHeight: '--select-badge-line-height',
2321
+ letterSpacing: '--select-badge-letter-spacing',
2322
+ });
2323
+ this._applyStyleVariableMap(styles.badgeHover, {
2324
+ background: '--select-badge-hover-bg',
2325
+ backgroundColor: '--select-badge-hover-bg',
2326
+ color: '--select-badge-hover-color',
2327
+ border: '--select-badge-hover-border',
2328
+ boxShadow: '--select-badge-hover-shadow',
2329
+ transform: '--select-badge-hover-transform',
2330
+ });
2331
+ this._applyStyleVariableMap(styles.badgeActive, {
2332
+ background: '--select-badge-active-bg',
2333
+ backgroundColor: '--select-badge-active-bg',
2334
+ color: '--select-badge-active-color',
2335
+ border: '--select-badge-active-border',
2336
+ boxShadow: '--select-badge-active-shadow',
2337
+ transform: '--select-badge-active-transform',
2338
+ });
2339
+ this._applyStyleVariableMap(styles.badgeLabel, {
2340
+ color: '--select-badge-label-color',
2341
+ fontSize: '--select-badge-label-font-size',
2342
+ fontWeight: '--select-badge-label-font-weight',
2343
+ lineHeight: '--select-badge-label-line-height',
2344
+ letterSpacing: '--select-badge-label-letter-spacing',
2345
+ textAlign: '--select-badge-label-text-align',
2346
+ });
2347
+ this._applyStyleVariableMap(styles.badgeRemove, {
2348
+ width: '--select-badge-remove-size',
2349
+ height: '--select-badge-remove-size',
2350
+ minWidth: '--select-badge-remove-min-width',
2351
+ minHeight: '--select-badge-remove-min-height',
2352
+ marginLeft: '--select-badge-remove-margin-left',
2353
+ background: '--select-badge-remove-bg',
2354
+ backgroundColor: '--select-badge-remove-bg',
2355
+ border: '--select-badge-remove-border',
2356
+ borderRadius: '--select-badge-remove-radius',
2357
+ color: '--select-badge-remove-color',
2358
+ fontSize: '--select-badge-remove-font-size',
2359
+ fontWeight: '--select-badge-remove-font-weight',
2360
+ });
2361
+ this._applyStyleVariableMap(styles.badgeRemoveHover, {
2362
+ background: '--select-badge-remove-hover-bg',
2363
+ backgroundColor: '--select-badge-remove-hover-bg',
2364
+ color: '--select-badge-remove-hover-color',
2365
+ border: '--select-badge-remove-hover-border',
2366
+ boxShadow: '--select-badge-remove-hover-shadow',
2367
+ transform: '--select-badge-remove-hover-transform',
2368
+ });
2369
+ this._applyStyleVariableMap(styles.badgeRemoveActive, {
2370
+ background: '--select-badge-remove-active-bg',
2371
+ backgroundColor: '--select-badge-remove-active-bg',
2372
+ color: '--select-badge-remove-active-color',
2373
+ border: '--select-badge-remove-active-border',
2374
+ boxShadow: '--select-badge-remove-active-shadow',
2375
+ transform: '--select-badge-remove-active-transform',
2376
+ });
2377
+ this._applyStyleVariableMap(styles.groupHeader, {
2378
+ padding: '--select-group-header-padding',
2379
+ margin: '--select-group-header-margin',
2380
+ color: '--select-group-header-color',
2381
+ background: '--select-group-header-bg',
2382
+ backgroundColor: '--select-group-header-bg',
2383
+ border: '--select-group-header-border',
2384
+ borderBottom: '--select-group-header-border-bottom',
2385
+ borderRadius: '--select-group-header-border-radius',
2386
+ boxShadow: '--select-group-header-shadow',
2387
+ textAlign: '--select-group-header-text-align',
2388
+ fontSize: '--select-group-header-font-size',
2389
+ fontWeight: '--select-group-header-weight',
2390
+ textTransform: '--select-group-header-text-transform',
2391
+ letterSpacing: '--select-group-header-letter-spacing',
2392
+ });
2393
+ }
2394
+ _resolveDropdownPlacement() {
2395
+ const placementMode = this._config.dropdownPlacement?.mode ?? 'bottom';
2396
+ if (placementMode === 'bottom' || placementMode === 'top') {
2397
+ return placementMode;
2398
+ }
2399
+ const hostRect = this._container.getBoundingClientRect();
2400
+ const availableBelow = window.innerHeight - hostRect.bottom;
2401
+ const computedDropdown = window.getComputedStyle(this._dropdown);
2402
+ const maxHeight = Number.parseFloat(computedDropdown.maxHeight || '0');
2403
+ const desiredHeight = Number.isFinite(maxHeight) && maxHeight > 0
2404
+ ? Math.min(this._dropdown.scrollHeight, maxHeight)
2405
+ : this._dropdown.scrollHeight;
2406
+ return availableBelow >= desiredHeight ? 'bottom' : 'top';
2407
+ }
2408
+ _syncDropdownPlacement() {
2409
+ if (!this._dropdown)
2410
+ return;
2411
+ this._resolvedDropdownPlacement = this._resolveDropdownPlacement();
2412
+ this._dropdown.setAttribute('data-placement', this._resolvedDropdownPlacement);
2413
+ }
2414
+ _syncDirectionConfig() {
2415
+ this.setAttribute('dir', this._config.direction ?? 'ltr');
2416
+ }
2417
+ _setIconContent(target, markup, fallback) {
2418
+ const content = markup && markup.trim() ? markup : fallback;
2419
+ target.innerHTML = '';
2420
+ if (content.trim().startsWith('<')) {
2421
+ target.innerHTML = content;
2422
+ return;
2423
+ }
2424
+ target.textContent = content;
2425
+ }
2139
2426
  _syncInputContainerMode() {
2140
2427
  if (!this._inputContainer || !this._input)
2141
2428
  return;
@@ -2152,6 +2439,121 @@ class EnhancedSelect extends HTMLElement {
2152
2439
  this._input.style.width = '100%';
2153
2440
  this._input.style.minWidth = '0';
2154
2441
  }
2442
+ this._syncMultiSelectDisplayConfig();
2443
+ }
2444
+ _syncMultiSelectDisplayConfig() {
2445
+ if (!this._inputContainer || !this._input)
2446
+ return;
2447
+ const isMulti = this._config.selection.mode === 'multi';
2448
+ const mode = this._config.multiSelectDisplay?.mode ?? 'wrap';
2449
+ const dragEnabled = this._config.multiSelectDisplay?.dragScroll !== false;
2450
+ if (!isMulti) {
2451
+ this._inputContainer.removeAttribute('data-multi-scroll-mode');
2452
+ this._inputContainer.removeAttribute('data-drag-scroll');
2453
+ this._inputContainer.classList.remove('is-dragging-scroll');
2454
+ this._inputContainer.style.removeProperty('--select-multi-input-max-height');
2455
+ this._inputContainer.style.removeProperty('--select-multi-input-overflow-x');
2456
+ this._inputContainer.style.removeProperty('--select-multi-input-overflow-y');
2457
+ this._inputContainer.style.removeProperty('--select-multi-input-flex-wrap');
2458
+ this._inputContainer.style.removeProperty('--select-multi-input-align-content');
2459
+ return;
2460
+ }
2461
+ const maxHeight = this._config.multiSelectDisplay?.maxHeight ?? '160px';
2462
+ const overflowX = this._config.multiSelectDisplay?.overflowX ?? (mode === 'horizontal' ? 'auto' : 'hidden');
2463
+ const overflowY = this._config.multiSelectDisplay?.overflowY ?? (mode === 'horizontal' ? 'hidden' : 'auto');
2464
+ const flexWrap = mode === 'horizontal' ? 'nowrap' : 'wrap';
2465
+ const alignContent = mode === 'horizontal' ? 'center' : 'flex-start';
2466
+ this._inputContainer.setAttribute('data-multi-scroll-mode', mode);
2467
+ this._inputContainer.setAttribute('data-drag-scroll', String(dragEnabled && mode === 'horizontal'));
2468
+ this._inputContainer.style.setProperty('--select-multi-input-max-height', maxHeight);
2469
+ this._inputContainer.style.setProperty('--select-multi-input-overflow-x', overflowX);
2470
+ this._inputContainer.style.setProperty('--select-multi-input-overflow-y', overflowY);
2471
+ this._inputContainer.style.setProperty('--select-multi-input-flex-wrap', flexWrap);
2472
+ this._inputContainer.style.setProperty('--select-multi-input-align-content', alignContent);
2473
+ }
2474
+ _canUseHorizontalMultiScroll(target) {
2475
+ if (this._config.selection.mode !== 'multi')
2476
+ return false;
2477
+ if ((this._config.multiSelectDisplay?.mode ?? 'wrap') !== 'horizontal')
2478
+ return false;
2479
+ if (this._config.multiSelectDisplay?.dragScroll === false)
2480
+ return false;
2481
+ if (!target)
2482
+ return true;
2483
+ if (target.closest('.dropdown-arrow-container, .clear-control-button, .badge-remove'))
2484
+ return false;
2485
+ if (target.matches('.select-input'))
2486
+ return false;
2487
+ return true;
2488
+ }
2489
+ _isScrollableMultiSelectMode() {
2490
+ if (this._config.selection.mode !== 'multi')
2491
+ return false;
2492
+ const mode = this._config.multiSelectDisplay?.mode ?? 'wrap';
2493
+ return mode === 'vertical' || mode === 'horizontal';
2494
+ }
2495
+ _isPointerOnInputScrollbar(event) {
2496
+ if (!this._isScrollableMultiSelectMode())
2497
+ return false;
2498
+ const rect = this._inputContent.getBoundingClientRect();
2499
+ const verticalScrollbarWidth = this._inputContent.offsetWidth - this._inputContent.clientWidth;
2500
+ const horizontalScrollbarHeight = this._inputContent.offsetHeight - this._inputContent.clientHeight;
2501
+ if (verticalScrollbarWidth > 0
2502
+ && event.clientX >= rect.right - verticalScrollbarWidth
2503
+ && event.clientX <= rect.right
2504
+ && event.clientY >= rect.top
2505
+ && event.clientY <= rect.bottom) {
2506
+ return true;
2507
+ }
2508
+ if (horizontalScrollbarHeight > 0
2509
+ && event.clientY >= rect.bottom - horizontalScrollbarHeight
2510
+ && event.clientY <= rect.bottom
2511
+ && event.clientX >= rect.left
2512
+ && event.clientX <= rect.right) {
2513
+ return true;
2514
+ }
2515
+ return false;
2516
+ }
2517
+ _beginMultiScrollDrag(e) {
2518
+ const scrollHost = this._inputContent;
2519
+ this._multiScrollDrag.active = true;
2520
+ this._multiScrollDrag.moved = false;
2521
+ this._multiScrollDrag.pointerId = e.pointerId;
2522
+ this._multiScrollDrag.startX = e.clientX;
2523
+ this._multiScrollDrag.startScrollLeft = scrollHost.scrollLeft;
2524
+ this._inputContainer.classList.add('is-dragging-scroll');
2525
+ try {
2526
+ scrollHost.setPointerCapture(e.pointerId);
2527
+ }
2528
+ catch (_error) {
2529
+ // ignore pointer capture issues
2530
+ }
2531
+ }
2532
+ _updateMultiScrollDrag(e) {
2533
+ if (!this._multiScrollDrag.active || this._multiScrollDrag.pointerId !== e.pointerId)
2534
+ return;
2535
+ const deltaX = e.clientX - this._multiScrollDrag.startX;
2536
+ if (Math.abs(deltaX) > 3) {
2537
+ this._multiScrollDrag.moved = true;
2538
+ }
2539
+ this._inputContent.scrollLeft = this._multiScrollDrag.startScrollLeft - deltaX;
2540
+ }
2541
+ _endMultiScrollDrag(pointerId) {
2542
+ if (!this._multiScrollDrag.active)
2543
+ return;
2544
+ if (pointerId != null && this._multiScrollDrag.pointerId !== pointerId)
2545
+ return;
2546
+ try {
2547
+ if (this._multiScrollDrag.pointerId >= 0) {
2548
+ this._inputContent.releasePointerCapture(this._multiScrollDrag.pointerId);
2549
+ }
2550
+ }
2551
+ catch (_error) {
2552
+ // ignore pointer capture issues
2553
+ }
2554
+ this._multiScrollDrag.active = false;
2555
+ this._multiScrollDrag.pointerId = -1;
2556
+ this._inputContainer.classList.remove('is-dragging-scroll');
2155
2557
  }
2156
2558
  _createInput() {
2157
2559
  const input = document.createElement('input');
@@ -2280,7 +2682,8 @@ class EnhancedSelect extends HTMLElement {
2280
2682
  return button;
2281
2683
  }
2282
2684
  _assembleDOM() {
2283
- this._inputContainer.appendChild(this._input);
2685
+ this._inputContent.appendChild(this._input);
2686
+ this._inputContainer.appendChild(this._inputContent);
2284
2687
  if (this._clearControl) {
2285
2688
  this._inputContainer.appendChild(this._clearControl);
2286
2689
  }
@@ -2337,9 +2740,11 @@ class EnhancedSelect extends HTMLElement {
2337
2740
  --select-badge-enter-from-transform: scale(0.8) translateY(-4px);
2338
2741
  --select-badge-enter-to-opacity: 1;
2339
2742
  --select-badge-enter-to-transform: scale(1) translateY(0);
2743
+ --select-badge-active-transform: scale(0.98);
2340
2744
  --select-badge-hover-transform: scale(1.02);
2341
2745
  --select-badge-letter-spacing: 0.01em;
2342
2746
  --select-badge-hover-shadow: var(--select-shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.15);
2747
+ --select-badge-remove-icon-size: 10px;
2343
2748
  --select-badge-remove-focus-outline: 2px solid rgba(255, 255, 255, 0.5);
2344
2749
  --select-badge-remove-focus-offset: 1px;
2345
2750
  --select-badge-remove-hover-transform: scale(1.15) rotate(90deg);
@@ -2349,8 +2754,31 @@ class EnhancedSelect extends HTMLElement {
2349
2754
  --select-input-font-weight: 450;
2350
2755
  --select-input-letter-spacing: 0.01em;
2351
2756
  --select-input-disabled-opacity: 0.6;
2757
+ --select-input-overflow-x: hidden;
2758
+ --select-input-align-items: center;
2759
+ --select-input-align-content: center;
2760
+ --select-input-align-self: center;
2761
+ --select-multi-input-max-height: 160px;
2762
+ --select-multi-input-overflow-x: hidden;
2763
+ --select-multi-input-overflow-y: auto;
2764
+ --select-multi-input-flex-wrap: wrap;
2765
+ --select-multi-input-align-content: flex-start;
2766
+ --select-multi-input-horizontal-input-flex: 0 0 var(--select-multi-input-min-width, 96px);
2767
+ --select-multi-input-horizontal-cursor: grab;
2768
+ --select-multi-input-horizontal-active-cursor: grabbing;
2769
+ --select-multi-separator-inset-block: 10px;
2770
+ --select-multi-action-surface-bg: var(--select-input-bg, var(--select-surface));
2771
+ --select-multi-action-divider: 1px solid var(--select-border);
2772
+ --select-separator-width: 1px;
2773
+ --select-separator-height: 50%;
2774
+ --select-separator-display: block;
2352
2775
  --select-separator-opacity: 0.6;
2353
2776
  --select-separator-active-opacity: 1;
2777
+ --select-separator-width: 1px;
2778
+ --select-separator-height: 50%;
2779
+ --select-separator-display: block;
2780
+ --select-separator-position: var(--select-arrow-width, 42px);
2781
+ --select-separator-position-with-clear: calc(var(--select-arrow-right-with-clear, 34px) + var(--select-arrow-width, 42px));
2354
2782
  --select-separator-dark-bg: linear-gradient(
2355
2783
  to bottom,
2356
2784
  transparent 0%,
@@ -2364,18 +2792,31 @@ class EnhancedSelect extends HTMLElement {
2364
2792
  --select-clear-button-focus-offset: 2px;
2365
2793
  --select-clear-icon-size: 14px;
2366
2794
  --select-dropdown-top: calc(100% + 6px);
2795
+ --select-dropdown-bottom: calc(100% + 6px);
2367
2796
  --select-dropdown-animation: dropdownEnter 200ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
2368
2797
  --select-dropdown-enter-from-opacity: 0;
2369
2798
  --select-dropdown-enter-from-transform: translateY(-8px) scale(0.98);
2370
2799
  --select-dropdown-enter-to-opacity: 1;
2371
2800
  --select-dropdown-enter-to-transform: translateY(0) scale(1);
2801
+ --select-dropdown-top-transform-origin: bottom center;
2802
+ --select-dropdown-top-enter-from-transform: translateY(8px) scale(0.98);
2803
+ --select-dropdown-padding: 6px;
2372
2804
  --select-dropdown-scroll-behavior: smooth;
2373
2805
  --select-dropdown-transform-origin: top center;
2374
2806
  --select-scrollbar-width: 6px;
2375
2807
  --select-scrollbar-thumb-radius: 3px;
2808
+ --select-option-hover-enabled: 1;
2376
2809
  --select-option-hover-transform: translateX(2px);
2377
2810
  --select-option-font-weight: 450;
2378
2811
  --select-option-margin: 2px 0;
2812
+ --select-input-font-size: inherit;
2813
+ --select-input-font-weight: 400;
2814
+ --select-multi-container-padding: 6px;
2815
+ --select-input-font-size: inherit;
2816
+ --select-input-font-weight: 400;
2817
+ --select-multi-container-padding: 6px;
2818
+ --select-option-disabled-opacity: 0.5;
2819
+ --select-option-disabled-cursor: not-allowed;
2379
2820
  --select-option-active-outline-offset: -2px;
2380
2821
  --select-option-selected-active-outline-offset: -2px;
2381
2822
  --select-option-selected-indicator-width: 3px;
@@ -2417,12 +2858,31 @@ class EnhancedSelect extends HTMLElement {
2417
2858
  --select-high-contrast-focus-outline-color: Highlight;
2418
2859
  --select-touch-target-min-height: 44px;
2419
2860
  --select-badge-dark-bg: linear-gradient(135deg, var(--select-accent) 0%, #4f46e5 100%);
2861
+ --select-host-z-index: auto;
2862
+ --select-host-open-z-index: var(--select-dropdown-z-index, 1000);
2863
+ --select-ancestor-open-z-index: var(--select-host-open-z-index, var(--select-dropdown-z-index, 1000));
2420
2864
 
2421
2865
  display: block;
2422
2866
  position: relative;
2867
+ z-index: var(--select-host-z-index, auto);
2423
2868
  width: var(--select-width, 100%);
2424
2869
  height: var(--select-height, auto);
2425
- font-family: var(--select-font-family, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
2870
+ font-family: var(--select-font-family, inherit);
2871
+ font-size: var(--select-font-size, inherit);
2872
+ line-height: var(--select-line-height, inherit);
2873
+ color: var(--select-color, inherit);
2874
+ }
2875
+
2876
+ :host([data-open="true"]) {
2877
+ z-index: var(--select-host-open-z-index, var(--select-dropdown-z-index, 1000));
2878
+ }
2879
+
2880
+ :host([dir="ltr"]) {
2881
+ direction: ltr;
2882
+ }
2883
+
2884
+ :host([dir="rtl"]) {
2885
+ direction: rtl;
2426
2886
  }
2427
2887
 
2428
2888
  /* ─────────────────────────────────────────────────────────────────────────
@@ -2434,6 +2894,9 @@ class EnhancedSelect extends HTMLElement {
2434
2894
  align-items: center;
2435
2895
  gap: var(--select-badge-gap, 6px);
2436
2896
  flex: 0 1 auto;
2897
+ width: var(--select-badge-width, auto);
2898
+ min-width: var(--select-badge-min-width, 0);
2899
+ height: var(--select-badge-height, auto);
2437
2900
  min-height: var(--select-badge-min-height, 26px);
2438
2901
  padding: var(--select-badge-padding, 4px 10px 4px 12px);
2439
2902
  margin: var(--select-badge-margin, 3px);
@@ -2443,7 +2906,7 @@ class EnhancedSelect extends HTMLElement {
2443
2906
  border-radius: var(--select-badge-border-radius, 999px);
2444
2907
  box-shadow: var(--select-badge-shadow, var(--select-shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.1));
2445
2908
  box-sizing: border-box;
2446
- font-size: var(--select-badge-font-size, 13px);
2909
+ font-size: var(--select-badge-font-size, 0.8667em);
2447
2910
  font-weight: var(--select-badge-font-weight, 500);
2448
2911
  line-height: var(--select-badge-line-height, 1.2);
2449
2912
  letter-spacing: var(--select-badge-letter-spacing);
@@ -2469,17 +2932,33 @@ class EnhancedSelect extends HTMLElement {
2469
2932
  }
2470
2933
 
2471
2934
  .selection-badge:hover {
2935
+ background: var(--select-badge-hover-bg, var(--select-badge-bg, linear-gradient(135deg, var(--select-accent) 0%, var(--select-primary-light) 100%)));
2936
+ color: var(--select-badge-hover-color, var(--select-badge-color, #ffffff));
2937
+ border: var(--select-badge-hover-border, var(--select-badge-border, none));
2472
2938
  box-shadow: var(--select-badge-hover-shadow);
2473
2939
  transform: var(--select-badge-hover-transform);
2474
2940
  }
2475
2941
 
2942
+ .selection-badge:active {
2943
+ background: var(--select-badge-active-bg, var(--select-badge-hover-bg, var(--select-badge-bg, linear-gradient(135deg, var(--select-accent) 0%, var(--select-primary-light) 100%))));
2944
+ color: var(--select-badge-active-color, var(--select-badge-hover-color, var(--select-badge-color, #ffffff)));
2945
+ border: var(--select-badge-active-border, var(--select-badge-hover-border, var(--select-badge-border, none)));
2946
+ box-shadow: var(--select-badge-active-shadow, var(--select-badge-hover-shadow));
2947
+ transform: var(--select-badge-active-transform);
2948
+ }
2949
+
2476
2950
  .selection-badge-label {
2477
2951
  display: block;
2478
2952
  min-width: 0;
2479
2953
  overflow: hidden;
2480
2954
  text-overflow: ellipsis;
2481
2955
  white-space: nowrap;
2482
- line-height: var(--select-badge-line-height, 1.2);
2956
+ color: var(--select-badge-label-color, inherit);
2957
+ font-size: var(--select-badge-label-font-size, inherit);
2958
+ font-weight: var(--select-badge-label-font-weight, inherit);
2959
+ line-height: var(--select-badge-label-line-height, var(--select-badge-line-height, 1.2));
2960
+ letter-spacing: var(--select-badge-label-letter-spacing, inherit);
2961
+ text-align: var(--select-badge-label-text-align, start);
2483
2962
  }
2484
2963
 
2485
2964
  .badge-remove {
@@ -2488,24 +2967,47 @@ class EnhancedSelect extends HTMLElement {
2488
2967
  justify-content: center;
2489
2968
  width: var(--select-badge-remove-size, 18px);
2490
2969
  height: var(--select-badge-remove-size, 18px);
2970
+ min-width: var(--select-badge-remove-min-width, var(--select-badge-remove-size, 18px));
2971
+ min-height: var(--select-badge-remove-min-height, var(--select-badge-remove-size, 18px));
2491
2972
  padding: 0;
2492
2973
  margin-left: var(--select-badge-remove-margin-left);
2493
2974
  background: var(--select-badge-remove-bg, rgba(255, 255, 255, 0.2));
2494
2975
  border: var(--select-badge-remove-border, none);
2495
2976
  border-radius: var(--select-badge-remove-radius);
2496
2977
  color: var(--select-badge-remove-color, #ffffff);
2497
- font-size: var(--select-badge-remove-font-size, 11px);
2978
+ font-size: var(--select-badge-remove-font-size, 0.7333em);
2498
2979
  font-weight: var(--select-badge-remove-font-weight);
2499
2980
  line-height: 1;
2500
2981
  cursor: pointer;
2501
2982
  flex: 0 0 auto;
2502
2983
  transition:
2503
2984
  background var(--select-transition-fast),
2985
+ color var(--select-transition-fast),
2986
+ border-color var(--select-transition-fast),
2987
+ box-shadow var(--select-transition-fast),
2504
2988
  transform var(--select-transition-bounce);
2505
2989
  }
2990
+
2991
+ .badge-remove-icon {
2992
+ display: inline-flex;
2993
+ align-items: center;
2994
+ justify-content: center;
2995
+ width: var(--select-badge-remove-icon-size, 10px);
2996
+ height: var(--select-badge-remove-icon-size, 10px);
2997
+ pointer-events: none;
2998
+ }
2999
+
3000
+ .badge-remove-icon svg {
3001
+ width: 100%;
3002
+ height: 100%;
3003
+ display: block;
3004
+ }
2506
3005
 
2507
3006
  .badge-remove:hover {
2508
3007
  background: var(--select-badge-remove-hover-bg, rgba(233, 69, 96, 0.9));
3008
+ color: var(--select-badge-remove-hover-color, var(--select-badge-remove-color, #ffffff));
3009
+ border: var(--select-badge-remove-hover-border, var(--select-badge-remove-border, none));
3010
+ box-shadow: var(--select-badge-remove-hover-shadow, none);
2509
3011
  transform: var(--select-badge-remove-hover-transform);
2510
3012
  }
2511
3013
 
@@ -2515,8 +3017,17 @@ class EnhancedSelect extends HTMLElement {
2515
3017
  }
2516
3018
 
2517
3019
  .badge-remove:active {
3020
+ background: var(--select-badge-remove-active-bg, var(--select-badge-remove-hover-bg, rgba(233, 69, 96, 0.9)));
3021
+ color: var(--select-badge-remove-active-color, var(--select-badge-remove-hover-color, var(--select-badge-remove-color, #ffffff)));
3022
+ border: var(--select-badge-remove-active-border, var(--select-badge-remove-hover-border, var(--select-badge-remove-border, none)));
3023
+ box-shadow: var(--select-badge-remove-active-shadow, var(--select-badge-remove-hover-shadow, none));
2518
3024
  transform: var(--select-badge-remove-active-transform);
2519
3025
  }
3026
+
3027
+ :host([dir="rtl"]) .badge-remove {
3028
+ margin-left: 0;
3029
+ margin-right: var(--select-badge-remove-margin-left);
3030
+ }
2520
3031
 
2521
3032
  /* ─────────────────────────────────────────────────────────────────────────
2522
3033
  Input Container — Sophisticated control shell
@@ -2531,16 +3042,22 @@ class EnhancedSelect extends HTMLElement {
2531
3042
  position: relative;
2532
3043
  width: 100%;
2533
3044
  display: flex;
2534
- align-items: center;
3045
+ align-items: var(--select-input-align-items, center);
2535
3046
  flex-wrap: nowrap;
3047
+ justify-content: var(--select-input-justify-content, flex-start);
2536
3048
  gap: var(--select-input-gap, 6px);
2537
3049
  padding: var(--select-input-padding, 10px 52px 10px 14px);
2538
3050
  height: var(--select-input-height, auto);
2539
3051
  min-height: var(--select-input-min-height, 48px);
2540
3052
  max-height: var(--select-input-max-height, 160px);
2541
- overflow-y: var(--select-input-overflow-y, auto);
2542
- align-content: center;
3053
+ overflow: hidden;
3054
+ padding: var(--select-multi-container-padding, 6px);
3055
+ align-content: var(--select-input-align-content, center);
3056
+ text-align: var(--select-input-text-align, start);
2543
3057
  background: var(--select-input-bg, var(--select-surface));
3058
+ font-size: var(--select-input-font-size, inherit);
3059
+ font-weight: var(--select-input-font-weight, 400);
3060
+ font-weight: var(--select-input-font-weight, 400);
2544
3061
  border: var(--select-input-border, 1.5px solid var(--select-border));
2545
3062
  border-radius: var(--select-input-border-radius, var(--select-radius-md));
2546
3063
  box-shadow: var(--select-shadow-sm);
@@ -2550,6 +3067,25 @@ class EnhancedSelect extends HTMLElement {
2550
3067
  box-shadow var(--select-transition-smooth),
2551
3068
  transform var(--select-transition-fast);
2552
3069
  }
3070
+
3071
+ .input-content {
3072
+ position: relative;
3073
+ display: flex;
3074
+ flex: 1 1 auto;
3075
+ width: 100%;
3076
+ min-width: 0;
3077
+ min-height: 0;
3078
+ align-self: stretch;
3079
+ align-items: var(--select-input-align-items, center);
3080
+ align-content: var(--select-input-align-content, center);
3081
+ justify-content: var(--select-input-justify-content, flex-start);
3082
+ flex-wrap: nowrap;
3083
+ gap: var(--select-input-gap, 6px);
3084
+ overflow-x: var(--select-input-overflow-x, hidden);
3085
+ overflow-y: var(--select-input-overflow-y, hidden);
3086
+ scrollbar-width: thin;
3087
+ box-sizing: border-box;
3088
+ }
2553
3089
 
2554
3090
  .input-container:hover {
2555
3091
  border-color: var(--select-input-hover-border);
@@ -2562,8 +3098,75 @@ class EnhancedSelect extends HTMLElement {
2562
3098
  }
2563
3099
 
2564
3100
  .input-container.input-container--multi {
2565
- flex-wrap: wrap;
2566
- align-content: flex-start;
3101
+ max-height: var(--select-multi-input-max-height, var(--select-input-max-height, 160px));
3102
+ }
3103
+
3104
+ .input-container.input-container--multi .input-content {
3105
+ flex-wrap: var(--select-multi-input-flex-wrap, wrap);
3106
+ align-content: var(--select-multi-input-align-content, flex-start);
3107
+ overflow-x: var(--select-multi-input-overflow-x, hidden);
3108
+ overflow-y: var(--select-multi-input-overflow-y, auto);
3109
+ }
3110
+
3111
+ .input-container.input-container--multi::after {
3112
+ top: var(--select-multi-separator-inset-block, 10px);
3113
+ bottom: var(--select-multi-separator-inset-block, 10px);
3114
+ height: auto;
3115
+ transform: none;
3116
+ }
3117
+
3118
+ .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] {
3119
+ align-items: stretch;
3120
+ }
3121
+
3122
+ .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .input-content {
3123
+ cursor: var(--select-multi-input-horizontal-cursor, grab);
3124
+ overflow-y: hidden;
3125
+ overscroll-behavior-x: contain;
3126
+ }
3127
+
3128
+ .input-container.input-container--multi[data-multi-scroll-mode="horizontal"]::after {
3129
+ display: none;
3130
+ }
3131
+
3132
+ .input-container.input-container--multi[data-multi-scroll-mode="horizontal"].is-dragging-scroll .input-content {
3133
+ cursor: var(--select-multi-input-horizontal-active-cursor, grabbing);
3134
+ user-select: none;
3135
+ }
3136
+
3137
+ .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .input-content .selection-badge {
3138
+ flex: 0 0 auto;
3139
+ }
3140
+
3141
+ .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .input-content > .select-input,
3142
+ .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .input-content > input.select-input,
3143
+ .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .input-content > .select-input[type="text"] {
3144
+ flex: var(--select-multi-input-horizontal-input-flex, 0 0 var(--select-multi-input-min-width, 96px));
3145
+ }
3146
+
3147
+ .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .dropdown-arrow-container {
3148
+ background: var(--select-multi-action-surface-bg, var(--select-input-bg, var(--select-surface)));
3149
+ border-left: var(--select-multi-action-divider, 1px solid var(--select-border));
3150
+ z-index: 4;
3151
+ }
3152
+
3153
+ .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .dropdown-arrow-container.with-clear-control {
3154
+ right: var(--select-arrow-right-with-clear, 34px);
3155
+ }
3156
+
3157
+ :host([dir="rtl"]) .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .dropdown-arrow-container {
3158
+ border-left: none;
3159
+ border-right: var(--select-multi-action-divider, 1px solid var(--select-border));
3160
+ }
3161
+
3162
+ :host([dir="rtl"]) .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .dropdown-arrow-container.with-clear-control {
3163
+ right: auto;
3164
+ left: var(--select-arrow-right-with-clear, 34px);
3165
+ }
3166
+
3167
+ .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .clear-control-button {
3168
+ background: var(--select-multi-action-surface-bg, var(--select-input-bg, var(--select-surface)));
3169
+ z-index: 4;
2567
3170
  }
2568
3171
 
2569
3172
  .input-container:focus-within {
@@ -2574,9 +3177,10 @@ class EnhancedSelect extends HTMLElement {
2574
3177
  /* Elegant separator line before arrow */
2575
3178
  .input-container::after {
2576
3179
  content: '';
3180
+ display: var(--select-separator-display, block);
2577
3181
  position: absolute;
2578
3182
  top: 50%;
2579
- right: var(--select-separator-position, 42px);
3183
+ right: var(--select-separator-position, var(--select-arrow-width, 42px));
2580
3184
  transform: translateY(-50%);
2581
3185
  width: var(--select-separator-width, 1px);
2582
3186
  height: var(--select-separator-height, 50%);
@@ -2597,6 +3201,11 @@ class EnhancedSelect extends HTMLElement {
2597
3201
  .input-container:focus-within::after {
2598
3202
  opacity: var(--select-separator-active-opacity);
2599
3203
  }
3204
+
3205
+ :host([dir="rtl"]) .input-container::after {
3206
+ right: auto;
3207
+ left: var(--select-separator-position, var(--select-arrow-width, 42px));
3208
+ }
2600
3209
 
2601
3210
  /* ─────────────────────────────────────────────────────────────────────────
2602
3211
  Dropdown Arrow — Smooth rotation with refined styling
@@ -2623,13 +3232,29 @@ class EnhancedSelect extends HTMLElement {
2623
3232
  }
2624
3233
 
2625
3234
  .input-container.has-clear-control::after {
2626
- right: var(--select-separator-position-with-clear, 74px);
3235
+ right: var(--select-separator-position-with-clear, calc(var(--select-arrow-right-with-clear, 34px) + var(--select-arrow-width, 42px)));
2627
3236
  }
2628
3237
 
2629
3238
  .dropdown-arrow-container.with-clear-control {
2630
3239
  right: var(--select-arrow-right-with-clear, 34px);
2631
3240
  }
2632
3241
 
3242
+ :host([dir="rtl"]) .dropdown-arrow-container {
3243
+ right: auto;
3244
+ left: 0;
3245
+ border-radius: var(--select-arrow-border-radius-rtl, var(--select-radius-md) 0 0 var(--select-radius-md));
3246
+ }
3247
+
3248
+ :host([dir="rtl"]) .input-container.has-clear-control::after {
3249
+ right: auto;
3250
+ left: var(--select-separator-position-with-clear, calc(var(--select-arrow-right-with-clear, 34px) + var(--select-arrow-width, 42px)));
3251
+ }
3252
+
3253
+ :host([dir="rtl"]) .dropdown-arrow-container.with-clear-control {
3254
+ right: auto;
3255
+ left: var(--select-arrow-right-with-clear, 34px);
3256
+ }
3257
+
2633
3258
  /* ─────────────────────────────────────────────────────────────────────────
2634
3259
  Clear Control — Minimal and elegant dismiss button
2635
3260
  ───────────────────────────────────────────────────────────────────────── */
@@ -2675,6 +3300,11 @@ class EnhancedSelect extends HTMLElement {
2675
3300
  display: none;
2676
3301
  }
2677
3302
 
3303
+ :host([dir="rtl"]) .clear-control-button {
3304
+ right: auto;
3305
+ left: var(--select-clear-button-right, 8px);
3306
+ }
3307
+
2678
3308
  .clear-control-icon {
2679
3309
  width: var(--select-clear-icon-size);
2680
3310
  height: var(--select-clear-icon-size);
@@ -2729,7 +3359,7 @@ class EnhancedSelect extends HTMLElement {
2729
3359
  padding: var(--select-input-field-padding, 0) !important;
2730
3360
  margin: 0 !important;
2731
3361
  border: 0 !important;
2732
- font-size: var(--select-input-font-size, 15px);
3362
+ font-size: var(--select-input-font-size, inherit);
2733
3363
  line-height: var(--select-input-line-height, 1.5);
2734
3364
  color: var(--select-input-color, var(--select-text));
2735
3365
  background: transparent !important;
@@ -2737,13 +3367,16 @@ class EnhancedSelect extends HTMLElement {
2737
3367
  outline: none !important;
2738
3368
  font-weight: var(--select-input-font-weight);
2739
3369
  letter-spacing: var(--select-input-letter-spacing);
2740
- align-self: center;
3370
+ font-family: var(--select-input-font-family, inherit);
3371
+ font-style: var(--select-input-font-style, normal);
3372
+ align-self: var(--select-input-align-self, center);
2741
3373
  appearance: none !important;
2742
3374
  -webkit-appearance: none !important;
2743
3375
  box-shadow: none !important;
2744
3376
  border-radius: 0 !important;
2745
3377
  overflow: hidden;
2746
3378
  text-overflow: ellipsis;
3379
+ text-align: var(--select-input-text-align, inherit);
2747
3380
  white-space: nowrap;
2748
3381
  }
2749
3382
 
@@ -2752,6 +3385,14 @@ class EnhancedSelect extends HTMLElement {
2752
3385
  font-weight: 400;
2753
3386
  }
2754
3387
 
3388
+ :host([dir="rtl"]) .input-container {
3389
+ padding: var(--select-input-padding-rtl, 10px 14px 10px 52px);
3390
+ }
3391
+
3392
+ :host([dir="rtl"]) .input-container.has-clear-control {
3393
+ padding: var(--select-input-padding-with-clear-rtl, 10px 14px 10px 84px);
3394
+ }
3395
+
2755
3396
  .input-container.input-container--multi > .select-input,
2756
3397
  .input-container.input-container--multi > input.select-input,
2757
3398
  .input-container.input-container--multi > .select-input[type="text"] {
@@ -2782,10 +3423,12 @@ class EnhancedSelect extends HTMLElement {
2782
3423
  position: absolute;
2783
3424
  scroll-behavior: var(--select-dropdown-scroll-behavior);
2784
3425
  top: var(--select-dropdown-top);
3426
+ bottom: auto;
2785
3427
  left: 0;
2786
3428
  right: 0;
2787
3429
  max-height: var(--select-dropdown-max-height, 320px);
2788
3430
  overflow: hidden;
3431
+ box-sizing: border-box;
2789
3432
  background: var(--select-dropdown-bg, var(--select-surface));
2790
3433
  border: 1px solid var(--select-dropdown-border, var(--select-border));
2791
3434
  border-radius: var(--select-dropdown-border-radius, var(--select-radius-lg));
@@ -2794,6 +3437,16 @@ class EnhancedSelect extends HTMLElement {
2794
3437
  transform-origin: var(--select-dropdown-transform-origin);
2795
3438
  animation: var(--select-dropdown-animation);
2796
3439
  }
3440
+
3441
+ .select-dropdown[data-placement="top"] {
3442
+ top: auto;
3443
+ bottom: var(--select-dropdown-bottom, calc(100% + 6px));
3444
+ transform-origin: var(--select-dropdown-top-transform-origin, bottom center);
3445
+ }
3446
+
3447
+ .select-dropdown[data-placement="top"] {
3448
+ --select-dropdown-enter-from-transform: var(--select-dropdown-top-enter-from-transform, translateY(8px) scale(0.98));
3449
+ }
2797
3450
 
2798
3451
  @keyframes dropdownEnter {
2799
3452
  0% {
@@ -2810,8 +3463,9 @@ class EnhancedSelect extends HTMLElement {
2810
3463
  position: relative;
2811
3464
  max-height: var(--select-options-max-height, 320px);
2812
3465
  overflow: auto;
2813
- padding: var(--select-options-padding, 6px);
2814
- background: var(--select-options-bg, var(--select-surface));
3466
+ box-sizing: border-box;
3467
+ padding: var(--select-options-padding, var(--select-dropdown-padding, 6px));
3468
+ background: var(--select-options-bg, var(--select-dropdown-bg, var(--select-surface)));
2815
3469
 
2816
3470
  /* Custom scrollbar styling */
2817
3471
  scrollbar-width: thin;
@@ -2840,18 +3494,26 @@ class EnhancedSelect extends HTMLElement {
2840
3494
  ───────────────────────────────────────────────────────────────────────── */
2841
3495
 
2842
3496
  .group-header {
2843
- padding: var(--select-group-header-padding, 10px 12px 6px);
3497
+ padding: var(--select-group-header-padding, 10px 12px 8px 12px);
3498
+ margin: var(--select-group-header-margin, 0 calc(var(--select-options-padding, 6px) * -1));
2844
3499
  font-weight: var(--select-group-header-weight, 600);
2845
3500
  color: var(--select-group-header-color, var(--select-text-muted));
2846
- background-color: var(--select-group-header-bg, var(--select-surface));
3501
+ background: var(--select-group-header-bg, #ffffff);
2847
3502
  text-align: var(--select-group-header-text-align, left);
2848
- font-size: var(--select-group-header-font-size, 11px);
3503
+ font-size: var(--select-group-header-font-size, 0.7333em);
2849
3504
  text-transform: var(--select-group-header-text-transform, uppercase);
2850
3505
  letter-spacing: var(--select-group-header-letter-spacing, 0.08em);
2851
3506
  position: sticky;
2852
- top: 0;
2853
- z-index: 1;
2854
- border-bottom: var(--select-group-header-border-bottom, none);
3507
+ top: calc(var(--select-options-padding, 6px) * -1);
3508
+ left: 0;
3509
+ right: 0;
3510
+ z-index: 100;
3511
+ border: var(--select-group-header-border, none);
3512
+ border-bottom: var(--select-group-header-border-bottom, 1px solid rgba(0, 0, 0, 0.08));
3513
+ border-radius: var(--select-group-header-border-radius, 0);
3514
+ box-shadow: var(--select-group-header-shadow, 0 1px 2px rgba(0, 0, 0, 0.04));
3515
+ /* Force solid background to prevent option bleed-through */
3516
+ isolation: isolate;
2855
3517
  }
2856
3518
 
2857
3519
  .group-header:not(:first-child) {
@@ -2870,13 +3532,16 @@ class EnhancedSelect extends HTMLElement {
2870
3532
  cursor: pointer;
2871
3533
  color: var(--select-option-color, var(--select-text));
2872
3534
  background: var(--select-option-bg, transparent);
3535
+ border: var(--select-option-border, none);
3536
+ text-align: var(--select-option-text-align, start);
2873
3537
  transition:
2874
3538
  background var(--select-transition-fast),
2875
3539
  color var(--select-transition-fast),
3540
+ border-color var(--select-transition-fast),
2876
3541
  transform var(--select-transition-fast),
2877
3542
  box-shadow var(--select-transition-fast);
2878
3543
  user-select: none;
2879
- font-size: var(--select-option-font-size, 14px);
3544
+ font-size: var(--select-option-font-size, inherit);
2880
3545
  font-weight: var(--select-option-font-weight);
2881
3546
  line-height: var(--select-option-line-height, 1.5);
2882
3547
  border-radius: var(--select-option-border-radius, var(--select-radius-sm));
@@ -2884,13 +3549,15 @@ class EnhancedSelect extends HTMLElement {
2884
3549
  }
2885
3550
 
2886
3551
  .option:hover {
2887
- background: var(--select-option-hover-bg, var(--select-surface-elevated));
2888
- color: var(--select-option-hover-color, var(--select-text));
2889
- transform: var(--select-option-hover-transform);
3552
+ background: calc(var(--select-option-hover-enabled, 1) * 1) > 0 ? var(--select-option-hover-bg, var(--select-surface-elevated)) : var(--select-option-bg, transparent);
3553
+ border: calc(var(--select-option-hover-enabled, 1) * 1) > 0 ? var(--select-option-hover-border, var(--select-option-border, none)) : var(--select-option-border, none);
3554
+ color: calc(var(--select-option-hover-enabled, 1) * 1) > 0 ? var(--select-option-hover-color, var(--select-text)) : var(--select-option-color, var(--select-text));
3555
+ transform: calc(var(--select-option-hover-enabled, 1) * 1) > 0 ? var(--select-option-hover-transform) : none;
2890
3556
  }
2891
3557
 
2892
3558
  .option.selected {
2893
3559
  background: var(--select-option-selected-bg, linear-gradient(135deg, rgba(15, 52, 96, 0.08) 0%, rgba(15, 52, 96, 0.04) 100%));
3560
+ border: var(--select-option-selected-border, var(--select-option-border, none));
2894
3561
  color: var(--select-option-selected-color, var(--select-accent));
2895
3562
  font-weight: var(--select-option-selected-weight, 550);
2896
3563
  }
@@ -2907,6 +3574,12 @@ class EnhancedSelect extends HTMLElement {
2907
3574
  border-radius: var(--select-option-selected-indicator-radius);
2908
3575
  animation: var(--select-option-selected-indicator-animation);
2909
3576
  }
3577
+
3578
+ :host([dir="rtl"]) .option.selected::before {
3579
+ left: auto;
3580
+ right: var(--select-option-selected-indicator-right, var(--select-option-selected-indicator-left));
3581
+ border-radius: var(--select-option-selected-indicator-radius-rtl, 2px 0 0 2px);
3582
+ }
2910
3583
 
2911
3584
  @keyframes selectedIndicator {
2912
3585
  0% {
@@ -2920,13 +3593,19 @@ class EnhancedSelect extends HTMLElement {
2920
3593
  }
2921
3594
 
2922
3595
  .option.selected:hover {
2923
- background: var(--select-option-selected-hover-bg, linear-gradient(135deg, rgba(15, 52, 96, 0.12) 0%, rgba(15, 52, 96, 0.06) 100%));
3596
+ background: var(--select-option-selected-hover-bg, var(--select-option-selected-bg, linear-gradient(135deg, rgba(15, 52, 96, 0.12) 0%, rgba(15, 52, 96, 0.06) 100%)));
3597
+ border: var(--select-option-selected-hover-border, var(--select-option-selected-border, var(--select-option-hover-border, var(--select-option-border, none))));
3598
+ color: var(--select-option-selected-hover-color, var(--select-option-selected-color, var(--select-accent)));
2924
3599
  }
2925
3600
 
2926
3601
  .option.active:not(.selected) {
2927
3602
  background: var(--select-option-active-bg, var(--select-surface-elevated));
3603
+ color: var(--select-option-active-color, var(--select-option-hover-color, var(--select-option-color, var(--select-text))));
3604
+ border: var(--select-option-active-border, var(--select-option-hover-border, var(--select-option-border, none)));
2928
3605
  outline: var(--select-option-active-outline, 2px solid rgba(15, 52, 96, 0.3));
2929
3606
  outline-offset: var(--select-option-active-outline-offset);
3607
+ box-shadow: var(--select-option-active-shadow, none);
3608
+ transform: var(--select-option-active-transform, none);
2930
3609
  }
2931
3610
 
2932
3611
  .option.selected.active {
@@ -2934,6 +3613,14 @@ class EnhancedSelect extends HTMLElement {
2934
3613
  outline-offset: var(--select-option-selected-active-outline-offset);
2935
3614
  }
2936
3615
 
3616
+ .option.disabled {
3617
+ background: var(--select-option-disabled-bg, var(--select-option-bg, transparent));
3618
+ color: var(--select-option-disabled-color, var(--select-text-muted));
3619
+ border: var(--select-option-disabled-border, var(--select-option-border, none));
3620
+ opacity: var(--select-option-disabled-opacity, 0.5);
3621
+ cursor: var(--select-option-disabled-cursor, not-allowed);
3622
+ }
3623
+
2937
3624
  .option:active:not(.selected) {
2938
3625
  background: var(--select-option-pressed-bg, rgba(15, 52, 96, 0.08));
2939
3626
  transform: var(--select-option-pressed-transform);
@@ -2959,7 +3646,7 @@ class EnhancedSelect extends HTMLElement {
2959
3646
  color: var(--select-button-color, var(--select-accent));
2960
3647
  border-radius: var(--select-button-border-radius, var(--select-radius-md));
2961
3648
  cursor: pointer;
2962
- font-size: var(--select-button-font-size, 13px);
3649
+ font-size: var(--select-button-font-size, 0.8667em);
2963
3650
  font-weight: var(--select-button-font-weight);
2964
3651
  letter-spacing: var(--select-button-letter-spacing);
2965
3652
  transition:
@@ -2991,7 +3678,7 @@ class EnhancedSelect extends HTMLElement {
2991
3678
  text-align: center;
2992
3679
  color: var(--select-busy-color, var(--select-text-muted));
2993
3680
  background: var(--select-busy-bg, transparent);
2994
- font-size: var(--select-busy-font-size, 13px);
3681
+ font-size: var(--select-busy-font-size, 0.8667em);
2995
3682
  }
2996
3683
 
2997
3684
  .spinner {
@@ -3012,7 +3699,7 @@ class EnhancedSelect extends HTMLElement {
3012
3699
  padding: var(--select-empty-padding, 32px 24px);
3013
3700
  text-align: center;
3014
3701
  color: var(--select-empty-color, var(--select-text-muted));
3015
- font-size: var(--select-empty-font-size, 14px);
3702
+ font-size: var(--select-empty-font-size, 0.9333em);
3016
3703
  background: var(--select-empty-bg, transparent);
3017
3704
  display: flex;
3018
3705
  flex-direction: column;
@@ -3025,7 +3712,7 @@ class EnhancedSelect extends HTMLElement {
3025
3712
  padding: var(--select-searching-padding, 32px 24px);
3026
3713
  text-align: center;
3027
3714
  color: var(--select-searching-color, var(--select-accent));
3028
- font-size: var(--select-searching-font-size, 14px);
3715
+ font-size: var(--select-searching-font-size, 0.9333em);
3029
3716
  background: var(--select-searching-bg, transparent);
3030
3717
  display: flex;
3031
3718
  flex-direction: column;
@@ -3115,24 +3802,44 @@ class EnhancedSelect extends HTMLElement {
3115
3802
  --select-primary-light: #2a2a3e;
3116
3803
  --select-accent: #6366f1;
3117
3804
  --select-accent-hover: #f43f5e;
3118
- --select-surface: #1a1a2e;
3805
+ --select-surface: var(--select-dark-bg, #1a1a2e);
3119
3806
  --select-surface-elevated: #252540;
3120
- --select-border: #3f3f5a;
3807
+ --select-border: var(--select-dark-border, #3f3f5a);
3121
3808
  --select-border-focus: #6366f1;
3122
- --select-text: #f5f5f5;
3809
+ --select-text: var(--select-dark-text, #f5f5f5);
3123
3810
  --select-text-muted: #9ca3af;
3124
3811
  --select-text-placeholder: #6b7280;
3125
3812
  --select-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
3126
3813
  --select-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
3127
3814
  --select-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
3128
3815
  --select-shadow-focus: 0 0 0 3px rgba(99, 102, 241, 0.25);
3816
+
3817
+ --select-dropdown-bg: var(--select-dark-dropdown-bg, var(--select-surface));
3818
+
3819
+ --select-arrow-color: var(--select-dark-arrow-color, #9ca3af);
3820
+ --select-arrow-hover-color: var(--select-dark-arrow-hover-color, #f5f5f5);
3821
+ --select-arrow-bg: var(--select-dark-arrow-bg, transparent);
3822
+ --select-arrow-hover-bg: var(--select-dark-arrow-hover-bg, rgba(156, 163, 175, 0.15));
3823
+
3824
+ --select-separator-bg: var(--select-dark-separator-bg, var(--select-separator-dark-bg));
3825
+ --select-separator-width: var(--select-dark-separator-width, 1px);
3129
3826
 
3130
- --select-option-bg: transparent;
3131
- --select-option-color: var(--select-text);
3132
- --select-option-hover-bg: var(--select-surface-elevated);
3133
- --select-option-hover-color: var(--select-text);
3134
- --select-option-selected-bg: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(99, 102, 241, 0.08) 100%);
3135
- --select-option-selected-color: #a5b4fc;
3827
+ --select-badge-bg: var(--select-dark-badge-bg, rgba(99, 102, 241, 0.2));
3828
+ --select-badge-color: var(--select-dark-badge-color, #e0e7ff);
3829
+
3830
+ --select-group-header-bg: var(--select-group-header-dark-bg, #1a1a2e);
3831
+ --select-group-header-color: var(--select-group-header-dark-color, #9ca3af);
3832
+
3833
+ --select-empty-color: var(--select-dark-empty-color, #9ca3af);
3834
+
3835
+ --select-option-bg: var(--select-dark-option-bg, transparent);
3836
+ --select-option-color: var(--select-dark-option-color, var(--select-text));
3837
+ --select-option-hover-bg: var(--select-dark-option-hover-bg, var(--select-surface-elevated));
3838
+ --select-option-hover-color: var(--select-dark-option-hover-color, var(--select-text));
3839
+ --select-option-selected-bg: var(--select-dark-option-selected-bg, linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(99, 102, 241, 0.08) 100%));
3840
+ --select-option-selected-color: var(--select-dark-option-selected-color, #a5b4fc);
3841
+ --select-option-selected-hover-bg: var(--select-dark-option-selected-hover-bg, var(--select-option-selected-bg));
3842
+ --select-option-selected-hover-color: var(--select-dark-option-selected-hover-color, var(--select-option-selected-color));
3136
3843
  }
3137
3844
 
3138
3845
  :host(.dark-mode) .input-container,
@@ -3175,7 +3882,7 @@ class EnhancedSelect extends HTMLElement {
3175
3882
  :host-context([darkmode]) .select-dropdown,
3176
3883
  :host-context([data-theme="dark"]) .select-dropdown,
3177
3884
  :host-context([theme="dark"]) .select-dropdown {
3178
- background: var(--select-surface);
3885
+ background: var(--select-dropdown-bg, var(--select-surface));
3179
3886
  border-color: var(--select-border);
3180
3887
  }
3181
3888
 
@@ -3190,7 +3897,7 @@ class EnhancedSelect extends HTMLElement {
3190
3897
  :host-context([darkmode]) .options-container,
3191
3898
  :host-context([data-theme="dark"]) .options-container,
3192
3899
  :host-context([theme="dark"]) .options-container {
3193
- background: var(--select-surface);
3900
+ background: var(--select-dropdown-bg, var(--select-surface));
3194
3901
  scrollbar-color: var(--select-border) transparent;
3195
3902
  }
3196
3903
 
@@ -3222,6 +3929,22 @@ class EnhancedSelect extends HTMLElement {
3222
3929
  border-top-color: var(--select-border);
3223
3930
  }
3224
3931
 
3932
+ :host(.dark-mode) .group-header,
3933
+ :host([dark-mode]) .group-header,
3934
+ :host([darkmode]) .group-header,
3935
+ :host([data-theme="dark"]) .group-header,
3936
+ :host([theme="dark"]) .group-header,
3937
+ :host-context(.dark-mode) .group-header,
3938
+ :host-context(.dark) .group-header,
3939
+ :host-context([dark-mode]) .group-header,
3940
+ :host-context([darkmode]) .group-header,
3941
+ :host-context([data-theme="dark"]) .group-header,
3942
+ :host-context([theme="dark"]) .group-header {
3943
+ background: var(--select-group-header-bg, #1a1a2e);
3944
+ border-bottom: var(--select-group-header-border-bottom, 1px solid rgba(255, 255, 255, 0.08));
3945
+ box-shadow: var(--select-group-header-shadow, 0 1px 2px rgba(0, 0, 0, 0.3));
3946
+ }
3947
+
3225
3948
  :host(.dark-mode) .option.selected::before,
3226
3949
  :host([dark-mode]) .option.selected::before,
3227
3950
  :host([darkmode]) .option.selected::before,
@@ -3287,6 +4010,19 @@ class EnhancedSelect extends HTMLElement {
3287
4010
  return;
3288
4011
  if (target && target.closest('.clear-control-button'))
3289
4012
  return;
4013
+ if (this._isPointerOnInputScrollbar(e)) {
4014
+ this._suppressNextOpenClick = true;
4015
+ return;
4016
+ }
4017
+ const isHorizontalMultiMode = this._config.selection.mode === 'multi'
4018
+ && (this._config.multiSelectDisplay?.mode ?? 'wrap') === 'horizontal';
4019
+ const enableHorizontalDrag = this._canUseHorizontalMultiScroll(target);
4020
+ if (enableHorizontalDrag && e.button === 0) {
4021
+ this._beginMultiScrollDrag(e);
4022
+ this._suppressNextOpenClick = false;
4023
+ e.preventDefault();
4024
+ return;
4025
+ }
3290
4026
  // If we clicked the container, but not the input itself, we must prevent default
3291
4027
  // otherwise the browser moves focus from our input to the body, immediately triggering blur.
3292
4028
  if (target && !target.matches('.select-input')) {
@@ -3295,6 +4031,8 @@ class EnhancedSelect extends HTMLElement {
3295
4031
  const clickedInput = Boolean(target && target.matches('.select-input'));
3296
4032
  if (this._state.isOpen &&
3297
4033
  this._config.selection.toggleOnTriggerClick !== false &&
4034
+ !isHorizontalMultiMode &&
4035
+ !enableHorizontalDrag &&
3298
4036
  !(clickedInput && this._config.searchable)) {
3299
4037
  this._handleClose();
3300
4038
  return;
@@ -3317,6 +4055,47 @@ class EnhancedSelect extends HTMLElement {
3317
4055
  }
3318
4056
  }
3319
4057
  });
4058
+ this._inputContainer.addEventListener('click', (e) => {
4059
+ const target = e.target;
4060
+ const isHorizontalMultiMode = this._config.selection.mode === 'multi'
4061
+ && (this._config.multiSelectDisplay?.mode ?? 'wrap') === 'horizontal';
4062
+ if (!this._config.enabled || !isHorizontalMultiMode) {
4063
+ this._suppressNextOpenClick = false;
4064
+ this._multiScrollDrag.moved = false;
4065
+ return;
4066
+ }
4067
+ if (target && target.closest('.dropdown-arrow-container, .clear-control-button')) {
4068
+ this._suppressNextOpenClick = false;
4069
+ this._multiScrollDrag.moved = false;
4070
+ return;
4071
+ }
4072
+ if (this._suppressNextOpenClick || this._multiScrollDrag.moved || this._isPointerOnInputScrollbar(e)) {
4073
+ this._suppressNextOpenClick = false;
4074
+ this._multiScrollDrag.moved = false;
4075
+ return;
4076
+ }
4077
+ this._suppressNextOpenClick = false;
4078
+ this._multiScrollDrag.moved = false;
4079
+ if (!this._state.isOpen) {
4080
+ this._handleOpen();
4081
+ }
4082
+ this._input.focus();
4083
+ });
4084
+ this._inputContent.addEventListener('pointermove', (e) => {
4085
+ this._updateMultiScrollDrag(e);
4086
+ });
4087
+ this._inputContent.addEventListener('pointerup', (e) => {
4088
+ this._endMultiScrollDrag(e.pointerId);
4089
+ });
4090
+ this._inputContent.addEventListener('pointercancel', (e) => {
4091
+ this._endMultiScrollDrag(e.pointerId);
4092
+ });
4093
+ this._inputContent.addEventListener('wheel', (e) => {
4094
+ if (this._config.selection.mode === 'multi'
4095
+ && (this._config.multiSelectDisplay?.mode ?? 'wrap') === 'horizontal') {
4096
+ e.preventDefault();
4097
+ }
4098
+ }, { passive: false });
3320
4099
  // Input container click - prevent event from reaching document listener
3321
4100
  this._container.addEventListener('click', (e) => {
3322
4101
  e.stopPropagation();
@@ -3487,11 +4266,14 @@ class EnhancedSelect extends HTMLElement {
3487
4266
  this._input.focus();
3488
4267
  this._markOpenStart();
3489
4268
  this._state.isOpen = true;
4269
+ this.setAttribute('data-open', 'true');
4270
+ this._liftStackingAncestors();
3490
4271
  this._dropdown.style.display = 'block';
3491
4272
  this._input.setAttribute('aria-expanded', 'true');
3492
4273
  this._updateArrowRotation();
3493
4274
  // Render options when opening
3494
4275
  this._renderOptions();
4276
+ this._syncDropdownPlacement();
3495
4277
  this._setInitialActiveOption();
3496
4278
  this._emit('open', {});
3497
4279
  this._config.callbacks.onOpen?.();
@@ -3511,7 +4293,10 @@ class EnhancedSelect extends HTMLElement {
3511
4293
  if (!this._state.isOpen)
3512
4294
  return;
3513
4295
  this._state.isOpen = false;
4296
+ this.removeAttribute('data-open');
4297
+ this._restoreLiftedAncestors();
3514
4298
  this._dropdown.style.display = 'none';
4299
+ this._dropdown.setAttribute('data-placement', this._resolvedDropdownPlacement);
3515
4300
  this._input.setAttribute('aria-expanded', 'false');
3516
4301
  this._input.removeAttribute('aria-activedescendant');
3517
4302
  this._updateArrowRotation();
@@ -3521,14 +4306,76 @@ class EnhancedSelect extends HTMLElement {
3521
4306
  }
3522
4307
  _updateDropdownVisibility() {
3523
4308
  if (this._state.isOpen) {
4309
+ this.setAttribute('data-open', 'true');
4310
+ this._liftStackingAncestors();
3524
4311
  this._dropdown.style.display = 'block';
4312
+ this._syncDropdownPlacement();
3525
4313
  this._input.setAttribute('aria-expanded', 'true');
3526
4314
  }
3527
4315
  else {
4316
+ this.removeAttribute('data-open');
4317
+ this._restoreLiftedAncestors();
3528
4318
  this._dropdown.style.display = 'none';
3529
4319
  this._input.setAttribute('aria-expanded', 'false');
3530
4320
  }
3531
4321
  }
4322
+ _liftStackingAncestors() {
4323
+ this._restoreLiftedAncestors();
4324
+ let ancestor = this.parentElement;
4325
+ while (ancestor && ancestor !== document.body) {
4326
+ if (this._createsStackingContext(ancestor)) {
4327
+ const hadMarker = ancestor.hasAttribute('data-smilodon-open-ancestor');
4328
+ this._liftedAncestors.push({
4329
+ element: ancestor,
4330
+ position: ancestor.style.position,
4331
+ zIndex: ancestor.style.zIndex,
4332
+ hadMarker,
4333
+ });
4334
+ if (getComputedStyle(ancestor).position === 'static') {
4335
+ ancestor.style.position = 'relative';
4336
+ }
4337
+ ancestor.style.zIndex = 'var(--select-ancestor-open-z-index, var(--select-host-open-z-index, var(--select-dropdown-z-index, 1000)))';
4338
+ ancestor.setAttribute('data-smilodon-open-ancestor', 'true');
4339
+ }
4340
+ ancestor = ancestor.parentElement;
4341
+ }
4342
+ }
4343
+ _restoreLiftedAncestors() {
4344
+ for (const lifted of this._liftedAncestors) {
4345
+ lifted.element.style.position = lifted.position;
4346
+ lifted.element.style.zIndex = lifted.zIndex;
4347
+ if (!lifted.hadMarker) {
4348
+ lifted.element.removeAttribute('data-smilodon-open-ancestor');
4349
+ }
4350
+ }
4351
+ this._liftedAncestors = [];
4352
+ }
4353
+ _createsStackingContext(element) {
4354
+ const style = getComputedStyle(element);
4355
+ if (style.position === 'fixed' || style.position === 'sticky')
4356
+ return true;
4357
+ if (style.zIndex !== 'auto' && style.position !== 'static')
4358
+ return true;
4359
+ if (style.opacity !== '1')
4360
+ return true;
4361
+ if (style.transform !== 'none')
4362
+ return true;
4363
+ if (style.filter !== 'none')
4364
+ return true;
4365
+ if (style.backdropFilter && style.backdropFilter !== 'none')
4366
+ return true;
4367
+ if (style.perspective !== 'none')
4368
+ return true;
4369
+ if (style.mixBlendMode !== 'normal')
4370
+ return true;
4371
+ if (style.isolation === 'isolate')
4372
+ return true;
4373
+ if (style.contain.includes('paint') || style.contain.includes('layout'))
4374
+ return true;
4375
+ if (style.willChange.includes('transform') || style.willChange.includes('opacity') || style.willChange.includes('filter'))
4376
+ return true;
4377
+ return false;
4378
+ }
3532
4379
  _updateArrowRotation() {
3533
4380
  if (this._arrowContainer) {
3534
4381
  const arrow = this._arrowContainer.querySelector('.dropdown-arrow');
@@ -3692,8 +4539,12 @@ class EnhancedSelect extends HTMLElement {
3692
4539
  }
3693
4540
  break;
3694
4541
  case 'Enter':
4542
+ case ' ':
3695
4543
  e.preventDefault();
3696
- if (this._state.activeIndex >= 0) {
4544
+ if (!this._state.isOpen) {
4545
+ this._handleOpen();
4546
+ }
4547
+ else if (this._state.activeIndex >= 0) {
3697
4548
  this._selectOption(this._state.activeIndex, { shiftKey: e.shiftKey, toggleKey: e.ctrlKey || e.metaKey });
3698
4549
  }
3699
4550
  break;
@@ -4000,7 +4851,7 @@ class EnhancedSelect extends HTMLElement {
4000
4851
  this._input.value = '';
4001
4852
  this._input.placeholder = this._config.placeholder || 'Select an option...';
4002
4853
  // Clear any badges
4003
- const existingBadges = this._inputContainer.querySelectorAll('.selection-badge');
4854
+ const existingBadges = this._inputContent.querySelectorAll('.selection-badge');
4004
4855
  existingBadges.forEach(badge => badge.remove());
4005
4856
  }
4006
4857
  else if (this._config.selection.mode === 'single') {
@@ -4011,16 +4862,23 @@ class EnhancedSelect extends HTMLElement {
4011
4862
  this._input.value = '';
4012
4863
  this._input.placeholder = '';
4013
4864
  // Clear existing badges
4014
- const existingBadges = this._inputContainer.querySelectorAll('.selection-badge');
4865
+ const existingBadges = this._inputContent.querySelectorAll('.selection-badge');
4015
4866
  existingBadges.forEach(badge => badge.remove());
4016
4867
  // Create badges for each selected item
4017
4868
  const selectedEntries = Array.from(this._state.selectedItems.entries());
4018
4869
  selectedEntries.forEach(([index, item]) => {
4019
4870
  const badge = document.createElement('span');
4020
4871
  badge.className = 'selection-badge';
4872
+ if (this._config.styles.classNames?.badge) {
4873
+ badge.classList.add(...this._config.styles.classNames.badge.split(' ').filter(Boolean));
4874
+ }
4021
4875
  badge.setAttribute('part', 'chip');
4022
4876
  const badgeLabel = document.createElement('span');
4023
4877
  badgeLabel.className = 'selection-badge-label';
4878
+ if (this._config.styles.classNames?.badgeLabel) {
4879
+ badgeLabel.classList.add(...this._config.styles.classNames.badgeLabel.split(' ').filter(Boolean));
4880
+ }
4881
+ badgeLabel.setAttribute('part', 'chip-label');
4024
4882
  badgeLabel.textContent = getLabel(item);
4025
4883
  badge.appendChild(badgeLabel);
4026
4884
  // Add remove button to badge
@@ -4028,9 +4886,19 @@ class EnhancedSelect extends HTMLElement {
4028
4886
  const removeBtn = document.createElement('button');
4029
4887
  removeBtn.type = 'button';
4030
4888
  removeBtn.className = 'badge-remove';
4889
+ if (this._config.styles.classNames?.removeButton) {
4890
+ removeBtn.classList.add(...this._config.styles.classNames.removeButton.split(' ').filter(Boolean));
4891
+ }
4892
+ if (this._config.styles.classNames?.badgeRemove) {
4893
+ removeBtn.classList.add(...this._config.styles.classNames.badgeRemove.split(' ').filter(Boolean));
4894
+ }
4031
4895
  removeBtn.setAttribute('part', 'chip-remove');
4032
- removeBtn.innerHTML = '×';
4033
4896
  removeBtn.setAttribute('aria-label', `Remove ${getLabel(item)}`);
4897
+ const removeIcon = document.createElement('span');
4898
+ removeIcon.className = 'badge-remove-icon';
4899
+ removeIcon.setAttribute('part', 'chip-remove-icon');
4900
+ this._setIconContent(removeIcon, this._config.selection.removeButtonIcon, '×');
4901
+ removeBtn.appendChild(removeIcon);
4034
4902
  removeBtn.addEventListener('pointerdown', (e) => {
4035
4903
  e.stopPropagation();
4036
4904
  e.preventDefault();
@@ -4042,7 +4910,7 @@ class EnhancedSelect extends HTMLElement {
4042
4910
  });
4043
4911
  badge.appendChild(removeBtn);
4044
4912
  }
4045
- this._inputContainer.insertBefore(badge, this._input);
4913
+ this._inputContent.insertBefore(badge, this._input);
4046
4914
  });
4047
4915
  }
4048
4916
  this._syncClearControlState();
@@ -4515,6 +5383,7 @@ class EnhancedSelect extends HTMLElement {
4515
5383
  if (this._clearControlIcon) {
4516
5384
  this._clearControlIcon.innerHTML = `<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12 4L4 12M4 4L12 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
4517
5385
  }
5386
+ this._syncStyleConfigVariables();
4518
5387
  if (this._dropdown) {
4519
5388
  if (this._config.selection.mode === 'multi') {
4520
5389
  this._dropdown.setAttribute('aria-multiselectable', 'true');
@@ -4523,10 +5392,14 @@ class EnhancedSelect extends HTMLElement {
4523
5392
  this._dropdown.removeAttribute('aria-multiselectable');
4524
5393
  }
4525
5394
  }
5395
+ this._syncDirectionConfig();
4526
5396
  this._syncInputContainerMode();
5397
+ this._syncMultiSelectDisplayConfig();
5398
+ this._syncDropdownPlacement();
4527
5399
  // Re-initialize observers in case infinite scroll was enabled/disabled
4528
5400
  this._initializeObservers();
4529
5401
  this._syncClearControlState();
5402
+ this._updateInputDisplay();
4530
5403
  this._renderOptions();
4531
5404
  }
4532
5405
  _mergeConfig(target, source) {
@@ -4682,6 +5555,9 @@ class EnhancedSelect extends HTMLElement {
4682
5555
  header.textContent = group.label;
4683
5556
  }
4684
5557
  header.classList.add('group-header');
5558
+ if (this._config.styles.classNames?.groupHeader) {
5559
+ header.classList.add(...this._config.styles.classNames.groupHeader.split(' ').filter(Boolean));
5560
+ }
4685
5561
  header.setAttribute('part', 'group-header');
4686
5562
  this._optionsContainer.appendChild(header);
4687
5563
  group.options.forEach(item => {
@@ -4809,6 +5685,7 @@ class EnhancedSelect extends HTMLElement {
4809
5685
  disabled: isDisabled,
4810
5686
  id: optionId,
4811
5687
  });
5688
+ optionElement.setAttribute('dir', this._config.direction ?? 'ltr');
4812
5689
  targetContainer.appendChild(optionElement);
4813
5690
  return;
4814
5691
  }
@@ -4822,8 +5699,23 @@ class EnhancedSelect extends HTMLElement {
4822
5699
  getValue,
4823
5700
  getLabel,
4824
5701
  showRemoveButton: this._config.selection.mode === 'multi' && this._config.selection.showRemoveButton,
5702
+ removeButtonIcon: this._config.selection.removeButtonIcon,
4825
5703
  classMap: this.classMap,
5704
+ className: this._config.styles.classNames?.option,
4826
5705
  });
5706
+ if (this._config.styles.classNames?.option) {
5707
+ option.classList.add(...this._config.styles.classNames.option.split(' ').filter(Boolean));
5708
+ }
5709
+ option.setAttribute('dir', this._config.direction ?? 'ltr');
5710
+ if (isSelected && this._config.styles.classNames?.selectedOption) {
5711
+ option.classList.add(...this._config.styles.classNames.selectedOption.split(' ').filter(Boolean));
5712
+ }
5713
+ if (this._state.activeIndex === index && this._config.styles.classNames?.activeOption) {
5714
+ option.classList.add(...this._config.styles.classNames.activeOption.split(' ').filter(Boolean));
5715
+ }
5716
+ if (isDisabled && this._config.styles.classNames?.disabledOption) {
5717
+ option.classList.add(...this._config.styles.classNames.disabledOption.split(' ').filter(Boolean));
5718
+ }
4827
5719
  // Valid part attribute on the web component host itself
4828
5720
  option.setAttribute('part', 'option');
4829
5721
  option.dataset.index = String(index);
@@ -4857,6 +5749,9 @@ class EnhancedSelect extends HTMLElement {
4857
5749
  }
4858
5750
  // Add both semantic namespaced classes and the legacy internal classes that CSS uses
4859
5751
  optionEl.classList.add('smilodon-option', 'option');
5752
+ if (this._config.styles.classNames?.option) {
5753
+ optionEl.classList.add(...this._config.styles.classNames.option.split(' ').filter(Boolean));
5754
+ }
4860
5755
  // Toggle state classes using classMap if available
4861
5756
  const isSelected = meta.selected;
4862
5757
  const isActive = meta.active;
@@ -4868,26 +5763,44 @@ class EnhancedSelect extends HTMLElement {
4868
5763
  if (isSelected) {
4869
5764
  optionEl.classList.add(...selectedClasses);
4870
5765
  optionEl.classList.add('smilodon-option--selected');
5766
+ if (this._config.styles.classNames?.selectedOption) {
5767
+ optionEl.classList.add(...this._config.styles.classNames.selectedOption.split(' ').filter(Boolean));
5768
+ }
4871
5769
  }
4872
5770
  else {
4873
5771
  optionEl.classList.remove(...selectedClasses);
4874
5772
  optionEl.classList.remove('smilodon-option--selected');
5773
+ if (this._config.styles.classNames?.selectedOption) {
5774
+ optionEl.classList.remove(...this._config.styles.classNames.selectedOption.split(' ').filter(Boolean));
5775
+ }
4875
5776
  }
4876
5777
  if (isActive) {
4877
5778
  optionEl.classList.add(...activeClasses);
4878
5779
  optionEl.classList.add('smilodon-option--active');
5780
+ if (this._config.styles.classNames?.activeOption) {
5781
+ optionEl.classList.add(...this._config.styles.classNames.activeOption.split(' ').filter(Boolean));
5782
+ }
4879
5783
  }
4880
5784
  else {
4881
5785
  optionEl.classList.remove(...activeClasses);
4882
5786
  optionEl.classList.remove('smilodon-option--active');
5787
+ if (this._config.styles.classNames?.activeOption) {
5788
+ optionEl.classList.remove(...this._config.styles.classNames.activeOption.split(' ').filter(Boolean));
5789
+ }
4883
5790
  }
4884
5791
  if (isDisabled) {
4885
5792
  optionEl.classList.add(...disabledClasses);
4886
5793
  optionEl.classList.add('smilodon-option--disabled');
5794
+ if (this._config.styles.classNames?.disabledOption) {
5795
+ optionEl.classList.add(...this._config.styles.classNames.disabledOption.split(' ').filter(Boolean));
5796
+ }
4887
5797
  }
4888
5798
  else {
4889
5799
  optionEl.classList.remove(...disabledClasses);
4890
5800
  optionEl.classList.remove('smilodon-option--disabled');
5801
+ if (this._config.styles.classNames?.disabledOption) {
5802
+ optionEl.classList.remove(...this._config.styles.classNames.disabledOption.split(' ').filter(Boolean));
5803
+ }
4891
5804
  }
4892
5805
  // Data Attributes Contract
4893
5806
  const state = [];