@smilodon/core 1.5.3 → 1.5.4

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.umd.js CHANGED
@@ -1604,7 +1604,7 @@
1604
1604
  transform: var(--select-option-selected-hover-transform, var(--select-option-selected-transform, var(--select-option-transform, none)));
1605
1605
  }
1606
1606
 
1607
- .option-container.active {
1607
+ .option-container.active:not(.disabled) {
1608
1608
  background: var(--select-option-active-bg, var(--select-option-hover-bg, #f0f0f0));
1609
1609
  color: var(--select-option-active-color, var(--select-option-hover-color, var(--select-option-color, var(--select-text-color, #1f2937))));
1610
1610
  border: var(--select-option-active-border, var(--select-option-hover-border, var(--select-option-border, none)));
@@ -1732,7 +1732,7 @@
1732
1732
  toggleClasses(this._container, [...selectedClasses, 'smilodon-option--selected'], false);
1733
1733
  toggleClasses(this, [...selectedClasses, 'smilodon-option--selected'], false);
1734
1734
  }
1735
- if (active) {
1735
+ if (active && !disabled) {
1736
1736
  toggleClasses(this._container, [...activeClasses, 'smilodon-option--active'], true);
1737
1737
  toggleClasses(this, [...activeClasses, 'smilodon-option--active'], true); // Make focus ring visible on host
1738
1738
  }
@@ -1800,8 +1800,12 @@
1800
1800
  // Set ARIA attributes and State attributes on Host
1801
1801
  this.setAttribute('role', 'option');
1802
1802
  this.setAttribute('aria-selected', String(selected));
1803
- if (disabled)
1803
+ if (disabled) {
1804
1804
  this.setAttribute('aria-disabled', 'true');
1805
+ }
1806
+ else {
1807
+ this.removeAttribute('aria-disabled');
1808
+ }
1805
1809
  this.id = this._config.id || `select-option-${index}`;
1806
1810
  // Add checkmark (part="checkmark") - standard for object mode
1807
1811
  // Only show if NOT showing remove button (avoid clutter)
@@ -1820,7 +1824,7 @@
1820
1824
  const state = [];
1821
1825
  if (selected)
1822
1826
  state.push('selected');
1823
- if (active)
1827
+ if (active && !disabled)
1824
1828
  state.push('active');
1825
1829
  if (state.length) {
1826
1830
  this.dataset.smState = state.join(' ');
@@ -1944,7 +1948,7 @@
1944
1948
  * Set active state
1945
1949
  */
1946
1950
  setActive(active) {
1947
- this._config.active = active;
1951
+ this._config.active = active && !this._config.disabled;
1948
1952
  this._render();
1949
1953
  }
1950
1954
  /**
@@ -2457,11 +2461,11 @@
2457
2461
  this._inputContainer.removeAttribute('data-multi-scroll-mode');
2458
2462
  this._inputContainer.removeAttribute('data-drag-scroll');
2459
2463
  this._inputContainer.classList.remove('is-dragging-scroll');
2460
- this._inputContainer.style.removeProperty('--select-multi-input-max-height');
2461
- this._inputContainer.style.removeProperty('--select-multi-input-overflow-x');
2462
- this._inputContainer.style.removeProperty('--select-multi-input-overflow-y');
2463
- this._inputContainer.style.removeProperty('--select-multi-input-flex-wrap');
2464
- this._inputContainer.style.removeProperty('--select-multi-input-align-content');
2464
+ this._inputContainer.style.removeProperty('--select-multi-input-max-height-config');
2465
+ this._inputContainer.style.removeProperty('--select-multi-input-overflow-x-config');
2466
+ this._inputContainer.style.removeProperty('--select-multi-input-overflow-y-config');
2467
+ this._inputContainer.style.removeProperty('--select-multi-input-flex-wrap-config');
2468
+ this._inputContainer.style.removeProperty('--select-multi-input-align-content-config');
2465
2469
  return;
2466
2470
  }
2467
2471
  const maxHeight = this._config.multiSelectDisplay?.maxHeight ?? '160px';
@@ -2471,11 +2475,11 @@
2471
2475
  const alignContent = mode === 'horizontal' ? 'center' : 'flex-start';
2472
2476
  this._inputContainer.setAttribute('data-multi-scroll-mode', mode);
2473
2477
  this._inputContainer.setAttribute('data-drag-scroll', String(dragEnabled && mode === 'horizontal'));
2474
- this._inputContainer.style.setProperty('--select-multi-input-max-height', maxHeight);
2475
- this._inputContainer.style.setProperty('--select-multi-input-overflow-x', overflowX);
2476
- this._inputContainer.style.setProperty('--select-multi-input-overflow-y', overflowY);
2477
- this._inputContainer.style.setProperty('--select-multi-input-flex-wrap', flexWrap);
2478
- this._inputContainer.style.setProperty('--select-multi-input-align-content', alignContent);
2478
+ this._inputContainer.style.setProperty('--select-multi-input-max-height-config', maxHeight);
2479
+ this._inputContainer.style.setProperty('--select-multi-input-overflow-x-config', overflowX);
2480
+ this._inputContainer.style.setProperty('--select-multi-input-overflow-y-config', overflowY);
2481
+ this._inputContainer.style.setProperty('--select-multi-input-flex-wrap-config', flexWrap);
2482
+ this._inputContainer.style.setProperty('--select-multi-input-align-content-config', alignContent);
2479
2483
  }
2480
2484
  _canUseHorizontalMultiScroll(target) {
2481
2485
  if (this._config.selection.mode !== 'multi')
@@ -3103,14 +3107,14 @@
3103
3107
  }
3104
3108
 
3105
3109
  .input-container.input-container--multi {
3106
- max-height: var(--select-multi-input-max-height, var(--select-input-max-height, 160px));
3110
+ max-height: var(--select-multi-input-max-height, var(--select-multi-input-max-height-config, var(--select-input-max-height, 160px)));
3107
3111
  }
3108
3112
 
3109
3113
  .input-container.input-container--multi .input-content {
3110
- flex-wrap: var(--select-multi-input-flex-wrap, wrap);
3111
- align-content: var(--select-multi-input-align-content, flex-start);
3112
- overflow-x: var(--select-multi-input-overflow-x, hidden);
3113
- overflow-y: var(--select-multi-input-overflow-y, auto);
3114
+ flex-wrap: var(--select-multi-input-flex-wrap, var(--select-multi-input-flex-wrap-config, wrap));
3115
+ align-content: var(--select-multi-input-align-content, var(--select-multi-input-align-content-config, flex-start));
3116
+ overflow-x: var(--select-multi-input-overflow-x, var(--select-multi-input-overflow-x-config, hidden));
3117
+ overflow-y: var(--select-multi-input-overflow-y, var(--select-multi-input-overflow-y-config, auto));
3114
3118
  }
3115
3119
 
3116
3120
  .input-container.input-container--multi::after {
@@ -3127,6 +3131,11 @@
3127
3131
  cursor: var(--select-multi-input-horizontal-cursor, grab);
3128
3132
  overflow-y: hidden;
3129
3133
  overscroll-behavior-x: contain;
3134
+ padding-right: calc(var(--select-arrow-width, 42px) + var(--select-multi-horizontal-end-gap, 12px));
3135
+ }
3136
+
3137
+ .input-container.input-container--multi[data-multi-scroll-mode="horizontal"].has-clear-control .input-content {
3138
+ 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));
3130
3139
  }
3131
3140
 
3132
3141
  .input-container.input-container--multi[data-multi-scroll-mode="horizontal"]::after {
@@ -3168,6 +3177,15 @@
3168
3177
  left: var(--select-arrow-right-with-clear, 34px);
3169
3178
  }
3170
3179
 
3180
+ :host([dir="rtl"]) .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .input-content {
3181
+ padding-right: 0;
3182
+ padding-left: calc(var(--select-arrow-width, 42px) + var(--select-multi-horizontal-end-gap, 12px));
3183
+ }
3184
+
3185
+ :host([dir="rtl"]) .input-container.input-container--multi[data-multi-scroll-mode="horizontal"].has-clear-control .input-content {
3186
+ padding-left: calc(var(--select-arrow-width, 42px) + var(--select-clear-button-size, 26px) + var(--select-clear-button-right, 8px) + var(--select-multi-horizontal-end-gap, 12px));
3187
+ }
3188
+
3171
3189
  .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] .clear-control-button {
3172
3190
  background: var(--select-multi-action-surface-bg, var(--select-input-bg, var(--select-surface)));
3173
3191
  z-index: 4;
@@ -3521,8 +3539,10 @@
3521
3539
  }
3522
3540
 
3523
3541
  .group-header:not(:first-child) {
3524
- margin-top: var(--select-group-header-separator-margin-top);
3525
- padding-top: var(--select-group-header-separator-padding-top);
3542
+ margin-top: calc(
3543
+ var(--select-group-header-separator-margin-top, 0px) +
3544
+ var(--select-group-header-separator-padding-top, 0px)
3545
+ );
3526
3546
  border-top: var(--select-group-header-separator-border-top);
3527
3547
  }
3528
3548
 
@@ -3604,7 +3624,7 @@
3604
3624
  color: var(--select-option-selected-hover-color, var(--select-option-selected-color, var(--select-accent)));
3605
3625
  }
3606
3626
 
3607
- .option.active:not(.selected) {
3627
+ .option.active:not(.selected):not(.disabled) {
3608
3628
  background: var(--select-option-active-bg, var(--select-surface-elevated));
3609
3629
  color: var(--select-option-active-color, var(--select-option-hover-color, var(--select-option-color, var(--select-text))));
3610
3630
  border: var(--select-option-active-border, var(--select-option-hover-border, var(--select-option-border, none)));
@@ -3614,7 +3634,7 @@
3614
3634
  transform: var(--select-option-active-transform, none);
3615
3635
  }
3616
3636
 
3617
- .option.selected.active {
3637
+ .option.selected.active:not(.disabled) {
3618
3638
  outline: var(--select-option-selected-active-outline, 2px solid rgba(15, 52, 96, 0.4));
3619
3639
  outline-offset: var(--select-option-selected-active-outline-offset);
3620
3640
  }
@@ -3832,6 +3852,9 @@
3832
3852
 
3833
3853
  --select-badge-bg: var(--select-dark-badge-bg, rgba(99, 102, 241, 0.2));
3834
3854
  --select-badge-color: var(--select-dark-badge-color, #e0e7ff);
3855
+ --select-badge-border: var(--select-dark-badge-border, var(--select-badge-border, none));
3856
+ --select-badge-hover-border: var(--select-dark-badge-hover-border, var(--select-badge-hover-border, var(--select-badge-border, none)));
3857
+ --select-badge-active-border: var(--select-dark-badge-active-border, var(--select-badge-active-border, var(--select-badge-hover-border, var(--select-badge-border, none))));
3835
3858
 
3836
3859
  --select-group-header-bg: var(--select-group-header-dark-bg, #1a1a2e);
3837
3860
  --select-group-header-color: var(--select-group-header-dark-color, #9ca3af);
@@ -3867,6 +3890,36 @@
3867
3890
  border-color: var(--select-border);
3868
3891
  }
3869
3892
 
3893
+ :host(.dark-mode) .input-container:hover,
3894
+ :host([dark-mode]) .input-container:hover,
3895
+ :host([darkmode]) .input-container:hover,
3896
+ :host([data-theme="dark"]) .input-container:hover,
3897
+ :host([theme="dark"]) .input-container:hover,
3898
+ :host-context(.dark-mode) .input-container:hover,
3899
+ :host-context(.dark) .input-container:hover,
3900
+ :host-context([dark-mode]) .input-container:hover,
3901
+ :host-context([darkmode]) .input-container:hover,
3902
+ :host-context([data-theme="dark"]) .input-container:hover,
3903
+ :host-context([theme="dark"]) .input-container:hover {
3904
+ border-color: var(--select-dark-input-hover-border, var(--select-input-hover-border, var(--select-dark-border-focus, var(--select-border-focus, #6366f1))));
3905
+ box-shadow: var(--select-dark-input-hover-shadow, var(--select-input-hover-shadow, var(--select-shadow-sm), 0 0 0 1px rgba(99, 102, 241, 0.12)));
3906
+ }
3907
+
3908
+ :host(.dark-mode) .input-container:focus-within,
3909
+ :host([dark-mode]) .input-container:focus-within,
3910
+ :host([darkmode]) .input-container:focus-within,
3911
+ :host([data-theme="dark"]) .input-container:focus-within,
3912
+ :host([theme="dark"]) .input-container:focus-within,
3913
+ :host-context(.dark-mode) .input-container:focus-within,
3914
+ :host-context(.dark) .input-container:focus-within,
3915
+ :host-context([dark-mode]) .input-container:focus-within,
3916
+ :host-context([darkmode]) .input-container:focus-within,
3917
+ :host-context([data-theme="dark"]) .input-container:focus-within,
3918
+ :host-context([theme="dark"]) .input-container:focus-within {
3919
+ border-color: var(--select-dark-border-focus, var(--select-border-focus, #6366f1));
3920
+ box-shadow: var(--select-dark-shadow-focus, var(--select-shadow-focus, 0 0 0 3px rgba(99, 102, 241, 0.25))), var(--select-shadow-sm);
3921
+ }
3922
+
3870
3923
  :host(.dark-mode) .input-container::after,
3871
3924
  :host([dark-mode]) .input-container::after,
3872
3925
  :host([darkmode]) .input-container::after,
@@ -3922,7 +3975,8 @@
3922
3975
  :host-context([darkmode]) .selection-badge,
3923
3976
  :host-context([data-theme="dark"]) .selection-badge,
3924
3977
  :host-context([theme="dark"]) .selection-badge {
3925
- background: var(--select-badge-dark-bg);
3978
+ background: var(--select-dark-badge-bg, var(--select-badge-bg, var(--select-badge-dark-bg)));
3979
+ color: var(--select-dark-badge-color, var(--select-badge-color, #e0e7ff));
3926
3980
  }
3927
3981
 
3928
3982
  :host(.dark-mode) .group-header:not(:first-child),
@@ -4103,6 +4157,10 @@
4103
4157
  this._inputContent.addEventListener('wheel', (e) => {
4104
4158
  if (this._config.selection.mode === 'multi'
4105
4159
  && (this._config.multiSelectDisplay?.mode ?? 'wrap') === 'horizontal') {
4160
+ const primaryDelta = Math.abs(e.deltaX) > Math.abs(e.deltaY) ? e.deltaX : e.deltaY;
4161
+ if (primaryDelta !== 0) {
4162
+ this._inputContent.scrollLeft += primaryDelta;
4163
+ }
4106
4164
  e.preventDefault();
4107
4165
  }
4108
4166
  }, { passive: false });
@@ -4497,6 +4555,8 @@
4497
4555
  }
4498
4556
  }
4499
4557
  _handleKeydown(e) {
4558
+ if (!this._config.enabled)
4559
+ return;
4500
4560
  switch (e.key) {
4501
4561
  case 'ArrowDown':
4502
4562
  e.preventDefault();
@@ -4519,17 +4579,23 @@
4519
4579
  case 'Home':
4520
4580
  e.preventDefault();
4521
4581
  if (this._state.isOpen) {
4522
- this._setActive(0);
4582
+ const selectableIndices = this._getSelectableOptionIndices();
4583
+ const firstIndex = selectableIndices[0];
4584
+ if (firstIndex === undefined)
4585
+ break;
4586
+ this._setActive(firstIndex);
4523
4587
  if (this._config.selection.mode === 'multi' && e.shiftKey) {
4524
- this._selectRange(this._rangeAnchorIndex ?? 0, 0, { clear: !(e.ctrlKey || e.metaKey) });
4588
+ this._selectRange(this._rangeAnchorIndex ?? firstIndex, firstIndex, { clear: !(e.ctrlKey || e.metaKey) });
4525
4589
  }
4526
4590
  }
4527
4591
  break;
4528
4592
  case 'End':
4529
4593
  e.preventDefault();
4530
4594
  if (this._state.isOpen) {
4531
- const options = this._getSelectableOptions();
4532
- const lastIndex = Math.max(0, options.length - 1);
4595
+ const selectableIndices = this._getSelectableOptionIndices();
4596
+ const lastIndex = selectableIndices[selectableIndices.length - 1];
4597
+ if (lastIndex === undefined)
4598
+ break;
4533
4599
  this._setActive(lastIndex);
4534
4600
  if (this._config.selection.mode === 'multi' && e.shiftKey) {
4535
4601
  this._selectRange(this._rangeAnchorIndex ?? lastIndex, lastIndex, { clear: !(e.ctrlKey || e.metaKey) });
@@ -4583,8 +4649,17 @@
4583
4649
  }
4584
4650
  }
4585
4651
  _moveActive(delta, opts) {
4586
- const options = this._getSelectableOptions();
4587
- const next = Math.max(0, Math.min(options.length - 1, this._state.activeIndex + delta));
4652
+ const selectableIndices = this._getSelectableOptionIndices();
4653
+ if (selectableIndices.length === 0)
4654
+ return;
4655
+ const currentPosition = selectableIndices.indexOf(this._state.activeIndex);
4656
+ const basePosition = currentPosition >= 0
4657
+ ? currentPosition
4658
+ : delta >= 0
4659
+ ? -1
4660
+ : selectableIndices.length;
4661
+ const nextPosition = Math.max(0, Math.min(selectableIndices.length - 1, basePosition + delta));
4662
+ const next = selectableIndices[nextPosition];
4588
4663
  this._setActive(next);
4589
4664
  if (this._config.selection.mode === 'multi' && opts?.shiftKey) {
4590
4665
  const anchor = this._rangeAnchorIndex ?? this._state.activeIndex;
@@ -4596,6 +4671,10 @@
4596
4671
  }
4597
4672
  }
4598
4673
  _setActive(index) {
4674
+ const option = this._getOptionElementByIndex(index);
4675
+ if (!option || option.getAttribute('aria-disabled') === 'true') {
4676
+ return;
4677
+ }
4599
4678
  // Clear previous active state
4600
4679
  if (this._state.activeIndex >= 0) {
4601
4680
  const prevOption = this._getOptionElementByIndex(this._state.activeIndex);
@@ -4612,7 +4691,6 @@
4612
4691
  }
4613
4692
  this._state.activeIndex = index;
4614
4693
  // Set new active state
4615
- const option = this._getOptionElementByIndex(index);
4616
4694
  if (option) {
4617
4695
  // Check if it's a custom SelectOption or a lightweight DOM element
4618
4696
  if ('setActive' in option && typeof option.setActive === 'function') {
@@ -4641,9 +4719,15 @@
4641
4719
  // Filter out group headers and other non-selectable elements
4642
4720
  // Only return elements with data-index or data-sm-selectable attributes
4643
4721
  return Array.from(this._optionsContainer.children).filter((child) => {
4644
- return child.hasAttribute('data-index') || child.hasAttribute('data-sm-selectable');
4722
+ return (child.hasAttribute('data-index') || child.hasAttribute('data-sm-selectable'))
4723
+ && child.getAttribute('aria-disabled') !== 'true';
4645
4724
  });
4646
4725
  }
4726
+ _getSelectableOptionIndices() {
4727
+ return this._getSelectableOptions()
4728
+ .map((option) => Number(option.getAttribute('data-sm-index') ?? option.getAttribute('data-index')))
4729
+ .filter((index) => Number.isFinite(index));
4730
+ }
4647
4731
  _buildRendererHelpers() {
4648
4732
  return {
4649
4733
  onSelect: (_item, index) => this._selectOption(index),
@@ -4680,24 +4764,27 @@
4680
4764
  return;
4681
4765
  const options = this._getSelectableOptions();
4682
4766
  const maxSelections = this._config.selection.maxSelections || 0;
4683
- options.forEach((option, index) => {
4767
+ options.forEach((option) => {
4768
+ const optionIndex = Number(option.getAttribute('data-sm-index') ?? option.getAttribute('data-index'));
4769
+ if (!Number.isFinite(optionIndex))
4770
+ return;
4684
4771
  if (maxSelections > 0 && this._state.selectedIndices.size >= maxSelections) {
4685
4772
  return;
4686
4773
  }
4687
- if (!this._state.selectedIndices.has(index)) {
4774
+ if (!this._state.selectedIndices.has(optionIndex)) {
4688
4775
  // Check if it's a custom SelectOption or a lightweight DOM element
4689
4776
  if ('getConfig' in option && typeof option.getConfig === 'function') {
4690
4777
  const config = option.getConfig();
4691
- this._state.selectedIndices.add(index);
4692
- this._state.selectedItems.set(index, config.item);
4778
+ this._state.selectedIndices.add(optionIndex);
4779
+ this._state.selectedItems.set(optionIndex, config.item);
4693
4780
  option.setSelected(true);
4694
4781
  }
4695
4782
  else {
4696
4783
  // Lightweight option - get item from data attribute or state
4697
- const item = this._state.loadedItems[index];
4784
+ const item = this._state.loadedItems[optionIndex];
4698
4785
  if (item) {
4699
- this._state.selectedIndices.add(index);
4700
- this._state.selectedItems.set(index, item);
4786
+ this._state.selectedIndices.add(optionIndex);
4787
+ this._state.selectedItems.set(optionIndex, item);
4701
4788
  option.classList.add('smilodon-option--selected');
4702
4789
  option.setAttribute('aria-selected', 'true');
4703
4790
  }
@@ -4721,6 +4808,9 @@
4721
4808
  if (maxSelections > 0 && this._state.selectedIndices.size >= maxSelections)
4722
4809
  break;
4723
4810
  const item = this._state.loadedItems[i];
4811
+ const optionEl = this._getOptionElementByIndex(i);
4812
+ if (optionEl?.getAttribute('aria-disabled') === 'true')
4813
+ continue;
4724
4814
  if (!item)
4725
4815
  continue;
4726
4816
  this._state.selectedIndices.add(i);
@@ -4732,8 +4822,8 @@
4732
4822
  this._announce(`${this._state.selectedIndices.size} items selected`);
4733
4823
  }
4734
4824
  _setInitialActiveOption() {
4735
- const options = this._getSelectableOptions();
4736
- if (options.length === 0)
4825
+ const selectableIndices = this._getSelectableOptionIndices();
4826
+ if (selectableIndices.length === 0)
4737
4827
  return;
4738
4828
  const selected = Array.from(this._state.selectedIndices).sort((a, b) => a - b);
4739
4829
  if (this._config.selection.mode === 'multi' && selected.length === 0) {
@@ -4741,8 +4831,8 @@
4741
4831
  this._input.removeAttribute('aria-activedescendant');
4742
4832
  return;
4743
4833
  }
4744
- const target = selected.length > 0 ? selected[0] : 0;
4745
- this._setActive(Math.min(target, options.length - 1));
4834
+ const target = selected.find((index) => selectableIndices.includes(index)) ?? selectableIndices[0];
4835
+ this._setActive(target);
4746
4836
  }
4747
4837
  _announce(message) {
4748
4838
  if (this._liveRegion) {