@smilodon/core 1.5.0 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -128,6 +128,8 @@ See the [main documentation](https://github.com/navidrezadoost/smilodon#readme)
128
128
  - **Zero Dependencies**: 6.6 KB gzipped runtime
129
129
  - **Framework Agnostic**: Works with React, Vue, Svelte, or vanilla JS
130
130
  - **Accessibility**: WCAG 2.2 AA compliant with ARIA 1.2
131
+ - **Full keyboard navigation**: Enter/Space, Arrows, Home/End, PageUp/Down, Escape
132
+ - **Multi-select modes**: wrap, horizontal, vertical, both (with drag-scroll)
131
133
 
132
134
  ### 🔒 Enterprise Grade
133
135
  - **SOC2 Compliant**: Audit-ready security controls
@@ -701,6 +703,120 @@ enhanced-select.dark-mode {
701
703
  --select-dark-option-selected-bg /* Dark selected bg (#3730a3) */
702
704
  --select-dark-group-header-color /* Dark header text */
703
705
  --select-dark-group-header-bg /* Dark header background */
706
+ --select-dark-badge-bg /* Dark badge background */
707
+ --select-dark-badge-color /* Dark badge text */
708
+ --select-dark-arrow-color /* Dark arrow icon color */
709
+ --select-dark-arrow-bg /* Dark arrow background */
710
+ --select-dark-arrow-hover-bg /* Dark arrow hover background */
711
+ --select-dark-separator-bg /* Dark separator color */
712
+ --select-dark-separator-width /* Dark separator width */
713
+ --select-dark-empty-color /* Dark empty state text */
714
+ ```
715
+
716
+ ---
717
+
718
+ ### Keyboard Navigation & Accessibility
719
+
720
+ Smilodon provides full keyboard accessibility (WCAG 2.2 AA compliant):
721
+
722
+ | Key | Action |
723
+ |-----|--------|
724
+ | `Enter` / `Space` | Open dropdown or select focused option |
725
+ | `↑` / `↓` | Navigate through options |
726
+ | `Home` / `End` | Jump to first/last option |
727
+ | `PageUp` / `PageDown` | Jump 10 options up/down |
728
+ | `Escape` | Close dropdown |
729
+ | `Tab` | Close dropdown and move focus |
730
+ | `Ctrl+A` (multi-select) | Select all options |
731
+ | Type characters | Type-ahead search |
732
+
733
+ **Multi-Select Range Selection:**
734
+ - `Shift + ↑/↓` - Range selection
735
+ - `Ctrl/Cmd + Click` - Toggle individual items
736
+ - `Shift + Home/End` - Select from current to first/last
737
+
738
+ ---
739
+
740
+ ### Multi-Select Display Modes
741
+
742
+ Control badge scrolling behavior in multi-select mode with `multiSelectDisplay` config:
743
+
744
+ ```javascript
745
+ {
746
+ multiSelectDisplay: {
747
+ mode: 'wrap', // 'wrap' | 'horizontal' | 'vertical' | 'both'
748
+ maxHeight: '160px',
749
+ overflowX: 'auto',
750
+ overflowY: 'auto',
751
+ dragScroll: true // Enable drag-to-scroll (horizontal mode)
752
+ }
753
+ }
754
+ ```
755
+
756
+ **Display Modes:**
757
+ - **`wrap`** (default) - Badges wrap to new lines, vertical scroll when needed
758
+ - **`horizontal`** - Single row, horizontal scroll, drag-to-scroll enabled
759
+ - **`vertical`** - Single column, vertical scroll only
760
+ - **`both`** - Both horizontal and vertical scroll, dense packing
761
+
762
+ ---
763
+
764
+ ### Advanced Styling Controls
765
+
766
+ #### Disabling Hover Animation
767
+
768
+ To remove hover effects on options:
769
+
770
+ ```css
771
+ enhanced-select {
772
+ --select-option-hover-bg: transparent;
773
+ --select-option-hover-color: inherit;
774
+ --select-option-hover-transform: none;
775
+ }
776
+ ```
777
+
778
+ #### Multi-Select Container & Badge Padding
779
+
780
+ Control container padding separately from badge padding:
781
+
782
+ ```css
783
+ enhanced-select {
784
+ --select-multi-container-padding: 8px; /* Container internal padding */
785
+ --select-badge-padding: 4px 8px; /* Individual badge padding */
786
+ --select-input-gap: 6px; /* Gap between badges */
787
+ }
788
+ ```
789
+
790
+ #### Separator Dimension Controls
791
+
792
+ Full control over the vertical separator line (works in all modes):
793
+
794
+ ```css
795
+ enhanced-select {
796
+ --select-separator-width: 2px; /* Line thickness */
797
+ --select-separator-height: 60%; /* Line height for single-select (% of container) */
798
+ --select-multi-separator-height: 40px; /* Fixed height for multi-select (default: auto) */
799
+ --select-separator-display: none; /* Hide separator completely */
800
+ --select-separator-bg: #e5e7eb; /* Custom color/gradient */
801
+ --select-separator-opacity: 0.8; /* Line opacity */
802
+ }
803
+ ```
804
+
805
+ **Note:** Multi-select uses `--select-multi-separator-height` (default: `auto` to stretch with container). Set a fixed pixel value like `40px` to maintain consistent separator height regardless of how many items are selected.
806
+
807
+ #### Input & Badge Typography
808
+
809
+ ```css
810
+ enhanced-select {
811
+ /* Input field text */
812
+ --select-input-font-size: 14px;
813
+ --select-input-font-weight: 400;
814
+
815
+ /* Badge text */
816
+ --select-badge-font-size: 13px;
817
+ --select-badge-font-weight: 500;
818
+ --select-badge-line-height: 1.2;
819
+ }
704
820
  ```
705
821
 
706
822
  **Complete CSS Variables Reference**
package/dist/index.cjs CHANGED
@@ -2721,7 +2721,7 @@ class EnhancedSelect extends HTMLElement {
2721
2721
  --select-accent: #0f3460;
2722
2722
  --select-accent-hover: #e94560;
2723
2723
  --select-surface: #ffffff;
2724
- --select-surface-elevated: #fafbfc;
2724
+ --select-surface-elevated: rgba(0, 0, 0, 0.04);
2725
2725
  --select-border: #e1e5eb;
2726
2726
  --select-border-focus: #0f3460;
2727
2727
  --select-text: #1a1a2e;
@@ -2769,8 +2769,13 @@ class EnhancedSelect extends HTMLElement {
2769
2769
  --select-multi-input-horizontal-cursor: grab;
2770
2770
  --select-multi-input-horizontal-active-cursor: grabbing;
2771
2771
  --select-multi-separator-inset-block: 10px;
2772
+ --select-multi-separator-height: auto;
2772
2773
  --select-multi-action-surface-bg: var(--select-input-bg, var(--select-surface));
2773
2774
  --select-multi-action-divider: 1px solid var(--select-border);
2775
+ --select-separator-width: 1px;
2776
+ --select-separator-inset-block: 10px;
2777
+ --select-separator-height: auto;
2778
+ --select-separator-display: block;
2774
2779
  --select-separator-opacity: 0.6;
2775
2780
  --select-separator-active-opacity: 1;
2776
2781
  --select-separator-position: var(--select-arrow-width, 42px);
@@ -2801,9 +2806,16 @@ class EnhancedSelect extends HTMLElement {
2801
2806
  --select-dropdown-transform-origin: top center;
2802
2807
  --select-scrollbar-width: 6px;
2803
2808
  --select-scrollbar-thumb-radius: 3px;
2809
+ --select-option-hover-enabled: 1;
2804
2810
  --select-option-hover-transform: translateX(2px);
2805
2811
  --select-option-font-weight: 450;
2806
2812
  --select-option-margin: 2px 0;
2813
+ --select-input-font-size: inherit;
2814
+ --select-input-font-weight: 400;
2815
+ --select-multi-container-padding: 6px;
2816
+ --select-input-font-size: inherit;
2817
+ --select-input-font-weight: 400;
2818
+ --select-multi-container-padding: 6px;
2807
2819
  --select-option-disabled-opacity: 0.5;
2808
2820
  --select-option-disabled-cursor: not-allowed;
2809
2821
  --select-option-active-outline-offset: -2px;
@@ -2836,9 +2848,9 @@ class EnhancedSelect extends HTMLElement {
2836
2848
  --select-searching-spinner-size: 24px;
2837
2849
  --select-searching-spinner-border: 2px solid var(--select-border);
2838
2850
  --select-searching-spinner-animation: var(--select-spinner-animation);
2839
- --select-group-header-separator-margin-top: 8px;
2840
- --select-group-header-separator-padding-top: 14px;
2841
- --select-group-header-separator-border-top: 1px solid var(--select-border);
2851
+ --select-group-header-separator-margin-top: 0;
2852
+ --select-group-header-separator-padding-top: 0;
2853
+ --select-group-header-separator-border-top: none;
2842
2854
  --select-reduced-motion-duration: 0.01ms;
2843
2855
  --select-reduced-motion-iteration-count: 1;
2844
2856
  --select-high-contrast-border-width: 2px;
@@ -3040,9 +3052,13 @@ class EnhancedSelect extends HTMLElement {
3040
3052
  min-height: var(--select-input-min-height, 48px);
3041
3053
  max-height: var(--select-input-max-height, 160px);
3042
3054
  overflow: hidden;
3055
+ padding: var(--select-multi-container-padding, 6px);
3043
3056
  align-content: var(--select-input-align-content, center);
3044
3057
  text-align: var(--select-input-text-align, start);
3045
3058
  background: var(--select-input-bg, var(--select-surface));
3059
+ font-size: var(--select-input-font-size, inherit);
3060
+ font-weight: var(--select-input-font-weight, 400);
3061
+ font-weight: var(--select-input-font-weight, 400);
3046
3062
  border: var(--select-input-border, 1.5px solid var(--select-border));
3047
3063
  border-radius: var(--select-input-border-radius, var(--select-radius-md));
3048
3064
  box-shadow: var(--select-shadow-sm);
@@ -3094,10 +3110,9 @@ class EnhancedSelect extends HTMLElement {
3094
3110
  }
3095
3111
 
3096
3112
  .input-container.input-container--multi::after {
3097
- top: var(--select-multi-separator-inset-block, 10px);
3098
- bottom: var(--select-multi-separator-inset-block, 10px);
3099
- height: auto;
3100
- transform: none;
3113
+ top: var(--select-multi-separator-inset-block, var(--select-separator-inset-block, 10px));
3114
+ bottom: var(--select-multi-separator-inset-block, var(--select-separator-inset-block, 10px));
3115
+ height: var(--select-multi-separator-height, auto);
3101
3116
  }
3102
3117
 
3103
3118
  .input-container.input-container--multi[data-multi-scroll-mode="horizontal"] {
@@ -3162,12 +3177,13 @@ class EnhancedSelect extends HTMLElement {
3162
3177
  /* Elegant separator line before arrow */
3163
3178
  .input-container::after {
3164
3179
  content: '';
3180
+ display: var(--select-separator-display, block);
3165
3181
  position: absolute;
3166
- top: 50%;
3182
+ top: var(--select-separator-inset-block, 10px);
3183
+ bottom: var(--select-separator-inset-block, 10px);
3167
3184
  right: var(--select-separator-position, var(--select-arrow-width, 42px));
3168
- transform: translateY(-50%);
3169
3185
  width: var(--select-separator-width, 1px);
3170
- height: var(--select-separator-height, 50%);
3186
+ height: var(--select-separator-height, auto);
3171
3187
  background: var(--select-separator-bg, linear-gradient(
3172
3188
  to bottom,
3173
3189
  transparent 0%,
@@ -3478,22 +3494,26 @@ class EnhancedSelect extends HTMLElement {
3478
3494
  ───────────────────────────────────────────────────────────────────────── */
3479
3495
 
3480
3496
  .group-header {
3481
- padding: var(--select-group-header-padding, 10px 12px 6px);
3482
- margin: var(--select-group-header-margin, 0);
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));
3483
3499
  font-weight: var(--select-group-header-weight, 600);
3484
3500
  color: var(--select-group-header-color, var(--select-text-muted));
3485
- background-color: var(--select-group-header-bg, var(--select-surface));
3501
+ background: var(--select-group-header-bg, #ffffff);
3486
3502
  text-align: var(--select-group-header-text-align, left);
3487
3503
  font-size: var(--select-group-header-font-size, 0.7333em);
3488
3504
  text-transform: var(--select-group-header-text-transform, uppercase);
3489
3505
  letter-spacing: var(--select-group-header-letter-spacing, 0.08em);
3490
3506
  position: sticky;
3491
- top: 0;
3492
- z-index: 1;
3507
+ top: calc(var(--select-options-padding, 6px) * -1);
3508
+ left: 0;
3509
+ right: 0;
3510
+ z-index: 100;
3493
3511
  border: var(--select-group-header-border, none);
3494
- border-bottom: var(--select-group-header-border-bottom, none);
3512
+ border-bottom: var(--select-group-header-border-bottom, 1px solid rgba(0, 0, 0, 0.08));
3495
3513
  border-radius: var(--select-group-header-border-radius, 0);
3496
- box-shadow: var(--select-group-header-shadow, none);
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;
3497
3517
  }
3498
3518
 
3499
3519
  .group-header:not(:first-child) {
@@ -3513,13 +3533,15 @@ class EnhancedSelect extends HTMLElement {
3513
3533
  color: var(--select-option-color, var(--select-text));
3514
3534
  background: var(--select-option-bg, transparent);
3515
3535
  border: var(--select-option-border, none);
3536
+ box-sizing: border-box;
3516
3537
  text-align: var(--select-option-text-align, start);
3517
- transition:
3538
+ transition: var(--select-option-transition,
3518
3539
  background var(--select-transition-fast),
3519
3540
  color var(--select-transition-fast),
3520
- border-color var(--select-transition-fast),
3541
+ border var(--select-transition-fast),
3521
3542
  transform var(--select-transition-fast),
3522
- box-shadow var(--select-transition-fast);
3543
+ box-shadow var(--select-transition-fast)
3544
+ );
3523
3545
  user-select: none;
3524
3546
  font-size: var(--select-option-font-size, inherit);
3525
3547
  font-weight: var(--select-option-font-weight);
@@ -3532,7 +3554,7 @@ class EnhancedSelect extends HTMLElement {
3532
3554
  background: var(--select-option-hover-bg, var(--select-surface-elevated));
3533
3555
  border: var(--select-option-hover-border, var(--select-option-border, none));
3534
3556
  color: var(--select-option-hover-color, var(--select-text));
3535
- transform: var(--select-option-hover-transform);
3557
+ transform: var(--select-option-hover-transform, none);
3536
3558
  }
3537
3559
 
3538
3560
  .option.selected {
@@ -3796,14 +3818,34 @@ class EnhancedSelect extends HTMLElement {
3796
3818
 
3797
3819
  --select-dropdown-bg: var(--select-dark-dropdown-bg, var(--select-surface));
3798
3820
 
3821
+ --select-arrow-color: var(--select-dark-arrow-color, #9ca3af);
3822
+ --select-arrow-hover-color: var(--select-dark-arrow-hover-color, #f5f5f5);
3823
+ --select-arrow-bg: var(--select-dark-arrow-bg, transparent);
3824
+ --select-arrow-hover-bg: var(--select-dark-arrow-hover-bg, rgba(156, 163, 175, 0.15));
3825
+
3826
+ --select-separator-bg: var(--select-dark-separator-bg, var(--select-separator-dark-bg));
3827
+ --select-separator-width: var(--select-dark-separator-width, 1px);
3828
+
3829
+ --select-badge-bg: var(--select-dark-badge-bg, rgba(99, 102, 241, 0.2));
3830
+ --select-badge-color: var(--select-dark-badge-color, #e0e7ff);
3831
+
3832
+ --select-group-header-bg: var(--select-group-header-dark-bg, #1a1a2e);
3833
+ --select-group-header-color: var(--select-group-header-dark-color, #9ca3af);
3834
+
3835
+ --select-empty-color: var(--select-dark-empty-color, #9ca3af);
3836
+
3799
3837
  --select-option-bg: var(--select-dark-option-bg, transparent);
3800
3838
  --select-option-color: var(--select-dark-option-color, var(--select-text));
3839
+ --select-option-border: var(--select-dark-option-border, none);
3801
3840
  --select-option-hover-bg: var(--select-dark-option-hover-bg, var(--select-surface-elevated));
3802
3841
  --select-option-hover-color: var(--select-dark-option-hover-color, var(--select-text));
3842
+ --select-option-hover-border: var(--select-dark-option-hover-border, var(--select-option-border, none));
3803
3843
  --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%));
3804
3844
  --select-option-selected-color: var(--select-dark-option-selected-color, #a5b4fc);
3845
+ --select-option-selected-border: var(--select-dark-option-selected-border, var(--select-option-border, none));
3805
3846
  --select-option-selected-hover-bg: var(--select-dark-option-selected-hover-bg, var(--select-option-selected-bg));
3806
3847
  --select-option-selected-hover-color: var(--select-dark-option-selected-hover-color, var(--select-option-selected-color));
3848
+ --select-option-selected-hover-border: var(--select-dark-option-selected-hover-border, var(--select-option-selected-border, var(--select-option-hover-border, var(--select-option-border, none))));
3807
3849
  }
3808
3850
 
3809
3851
  :host(.dark-mode) .input-container,
@@ -3893,6 +3935,22 @@ class EnhancedSelect extends HTMLElement {
3893
3935
  border-top-color: var(--select-border);
3894
3936
  }
3895
3937
 
3938
+ :host(.dark-mode) .group-header,
3939
+ :host([dark-mode]) .group-header,
3940
+ :host([darkmode]) .group-header,
3941
+ :host([data-theme="dark"]) .group-header,
3942
+ :host([theme="dark"]) .group-header,
3943
+ :host-context(.dark-mode) .group-header,
3944
+ :host-context(.dark) .group-header,
3945
+ :host-context([dark-mode]) .group-header,
3946
+ :host-context([darkmode]) .group-header,
3947
+ :host-context([data-theme="dark"]) .group-header,
3948
+ :host-context([theme="dark"]) .group-header {
3949
+ background: var(--select-group-header-bg, #1a1a2e);
3950
+ border-bottom: var(--select-group-header-border-bottom, 1px solid rgba(255, 255, 255, 0.08));
3951
+ box-shadow: var(--select-group-header-shadow, 0 1px 2px rgba(0, 0, 0, 0.3));
3952
+ }
3953
+
3896
3954
  :host(.dark-mode) .option.selected::before,
3897
3955
  :host([dark-mode]) .option.selected::before,
3898
3956
  :host([darkmode]) .option.selected::before,
@@ -4466,7 +4524,7 @@ class EnhancedSelect extends HTMLElement {
4466
4524
  case 'End':
4467
4525
  e.preventDefault();
4468
4526
  if (this._state.isOpen) {
4469
- const options = Array.from(this._optionsContainer.children);
4527
+ const options = this._getSelectableOptions();
4470
4528
  const lastIndex = Math.max(0, options.length - 1);
4471
4529
  this._setActive(lastIndex);
4472
4530
  if (this._config.selection.mode === 'multi' && e.shiftKey) {
@@ -4487,8 +4545,12 @@ class EnhancedSelect extends HTMLElement {
4487
4545
  }
4488
4546
  break;
4489
4547
  case 'Enter':
4548
+ case ' ':
4490
4549
  e.preventDefault();
4491
- if (this._state.activeIndex >= 0) {
4550
+ if (!this._state.isOpen) {
4551
+ this._handleOpen();
4552
+ }
4553
+ else if (this._state.activeIndex >= 0) {
4492
4554
  this._selectOption(this._state.activeIndex, { shiftKey: e.shiftKey, toggleKey: e.ctrlKey || e.metaKey });
4493
4555
  }
4494
4556
  break;
@@ -4517,7 +4579,7 @@ class EnhancedSelect extends HTMLElement {
4517
4579
  }
4518
4580
  }
4519
4581
  _moveActive(delta, opts) {
4520
- const options = Array.from(this._optionsContainer.children);
4582
+ const options = this._getSelectableOptions();
4521
4583
  const next = Math.max(0, Math.min(options.length - 1, this._state.activeIndex + delta));
4522
4584
  this._setActive(next);
4523
4585
  if (this._config.selection.mode === 'multi' && opts?.shiftKey) {
@@ -4571,6 +4633,13 @@ class EnhancedSelect extends HTMLElement {
4571
4633
  _getOptionElementByIndex(index) {
4572
4634
  return this._optionsContainer.querySelector(`[data-index="${index}"]`);
4573
4635
  }
4636
+ _getSelectableOptions() {
4637
+ // Filter out group headers and other non-selectable elements
4638
+ // Only return elements with data-index or data-sm-selectable attributes
4639
+ return Array.from(this._optionsContainer.children).filter((child) => {
4640
+ return child.hasAttribute('data-index') || child.hasAttribute('data-sm-selectable');
4641
+ });
4642
+ }
4574
4643
  _buildRendererHelpers() {
4575
4644
  return {
4576
4645
  onSelect: (_item, index) => this._selectOption(index),
@@ -4605,7 +4674,7 @@ class EnhancedSelect extends HTMLElement {
4605
4674
  _selectAll() {
4606
4675
  if (this._config.selection.mode !== 'multi')
4607
4676
  return;
4608
- const options = Array.from(this._optionsContainer.children);
4677
+ const options = this._getSelectableOptions();
4609
4678
  const maxSelections = this._config.selection.maxSelections || 0;
4610
4679
  options.forEach((option, index) => {
4611
4680
  if (maxSelections > 0 && this._state.selectedIndices.size >= maxSelections) {
@@ -4659,7 +4728,7 @@ class EnhancedSelect extends HTMLElement {
4659
4728
  this._announce(`${this._state.selectedIndices.size} items selected`);
4660
4729
  }
4661
4730
  _setInitialActiveOption() {
4662
- const options = Array.from(this._optionsContainer.children);
4731
+ const options = this._getSelectableOptions();
4663
4732
  if (options.length === 0)
4664
4733
  return;
4665
4734
  const selected = Array.from(this._state.selectedIndices).sort((a, b) => a - b);