slim-select 3.6.1 → 4.0.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.
@@ -14,8 +14,10 @@
14
14
  // Heights
15
15
  --ss-main-height: 40px;
16
16
  --ss-content-height: 300px;
17
- --ss-search-height: 40px;
18
- --ss-option-height: auto;
17
+ --ss-modal-height: 85vh;
18
+ --ss-modal-width: min(90vw, 400px);
19
+ --ss-search-height: var(--ss-main-height);
20
+ --ss-option-height: var(--ss-main-height);
19
21
 
20
22
  // Spacing
21
23
  --ss-spacing-l: 9px;
@@ -25,6 +27,7 @@
25
27
  // Misc
26
28
  --ss-animation-timing: 0.2s;
27
29
  --ss-border-radius: 4px;
30
+ --ss-modal-z-index: 1000001;
28
31
  }
29
32
 
30
33
  // Animation keyframes
@@ -58,19 +61,27 @@
58
61
  .ss-main {
59
62
  display: flex;
60
63
  flex-direction: row;
64
+ align-items: center;
61
65
  position: relative;
62
66
  user-select: none;
63
67
  color: var(--ss-font-color);
64
68
  min-height: var(--ss-main-height);
65
69
  width: 100%;
66
- padding: var(--ss-spacing-s);
70
+ padding: 0 var(--ss-spacing-s);
67
71
  cursor: pointer;
68
72
  border: 1px solid var(--ss-border-color);
69
73
  border-radius: var(--ss-border-radius);
70
74
  background-color: var(--ss-bg-color);
71
75
  outline: 0;
72
76
  box-sizing: border-box;
73
- transition: background-color var(--ss-animation-timing);
77
+ transition:
78
+ background-color var(--ss-animation-timing),
79
+ border-radius var(--ss-animation-timing);
80
+
81
+ @media (prefers-reduced-motion: reduce) {
82
+ transition: background-color var(--ss-animation-timing);
83
+ }
84
+
74
85
  overflow: hidden;
75
86
 
76
87
  &:focus {
@@ -104,33 +115,52 @@
104
115
  }
105
116
 
106
117
  .ss-values {
107
- display: inline-flex;
118
+ display: flex;
108
119
  flex-wrap: wrap;
120
+ align-items: center;
121
+ align-content: center;
122
+ align-self: stretch;
109
123
  gap: var(--ss-spacing-m);
110
- flex: 1 1 100%;
111
- min-width: 0; // Allow container to shrink
112
- max-width: 100%; // Ensure container doesn't exceed parent
113
- overflow: hidden; // Prevent overflow
124
+ flex: 1 1 0%;
125
+ min-width: 0; // Allow container to shrink below content width
126
+ max-width: 100%;
127
+ padding: var(--ss-spacing-s) 0;
128
+ box-sizing: border-box;
129
+ overflow: hidden;
114
130
 
115
131
  // When multiString is enabled, values container holds a single text line
116
132
  &:has(.ss-multi-string) {
117
133
  flex-wrap: nowrap;
118
134
  gap: 0;
119
- align-items: center;
120
135
  }
121
136
 
122
- .ss-placeholder {
123
- display: block; // Use block for proper ellipsis
137
+ // Single-line value text fills space before the arrow/deselect siblings
138
+ &:has(.ss-single),
139
+ &:has(.ss-placeholder) {
140
+ flex-wrap: nowrap;
141
+ }
142
+
143
+ // Shared layout for single value, placeholder, and multiString text
144
+ .ss-single,
145
+ .ss-placeholder,
146
+ .ss-multi-string {
147
+ display: block;
148
+ flex: 1 1 0%;
149
+ min-width: 0;
124
150
  width: 100%;
125
- min-width: 0; // Allow placeholder to shrink
126
- padding: var(--ss-spacing-s) var(--ss-spacing-m) var(--ss-spacing-s)
127
- var(--ss-spacing-m);
128
- margin: auto 0px auto 0px;
129
- line-height: 1em;
130
- color: var(--ss-placeholder-color);
151
+ max-width: 100%;
152
+ margin: 0;
153
+ padding: 0 var(--ss-spacing-m) 0
154
+ calc(var(--ss-spacing-l) - var(--ss-spacing-s));
155
+ line-height: 1.2;
131
156
  overflow: hidden;
132
157
  text-overflow: ellipsis;
133
158
  white-space: nowrap;
159
+ box-sizing: border-box;
160
+ }
161
+
162
+ .ss-placeholder {
163
+ color: var(--ss-placeholder-color);
134
164
  }
135
165
 
136
166
  // Max is used to display max number of values
@@ -147,35 +177,6 @@
147
177
  border-radius: var(--ss-border-radius);
148
178
  }
149
179
 
150
- // Used for single select selected value
151
- .ss-single {
152
- display: block; // Use block for proper ellipsis
153
- margin: auto 0px auto var(--ss-spacing-s);
154
- min-width: 0; // Allow flex item to shrink below content size
155
- overflow: hidden;
156
- text-overflow: ellipsis;
157
- white-space: nowrap; // Prevent text wrapping
158
- flex: 1 1 auto; // Allow it to grow but also shrink
159
- max-width: calc(100% - 20px); // Leave space for arrow and padding
160
- }
161
-
162
- // Used for multiple select when multiString is enabled
163
- // Shows selected values as comma separated text truncated with an ellipsis
164
- .ss-multi-string {
165
- display: block; // Use block for proper ellipsis
166
- width: 100%;
167
- min-width: 0; // Allow flex item to shrink below content size
168
- padding: var(--ss-spacing-s) var(--ss-spacing-m) var(--ss-spacing-s)
169
- var(--ss-spacing-m);
170
- margin: auto 0px auto 0px;
171
- line-height: 1em;
172
- overflow: hidden;
173
- text-overflow: ellipsis;
174
- white-space: nowrap; // Prevent text wrapping
175
- flex: 1 1 auto; // Allow it to grow but also shrink
176
- max-width: calc(100% - 20px); // Leave space for arrow and padding
177
- }
178
-
179
180
  // Used for the selected values
180
181
  .ss-value {
181
182
  display: flex;
@@ -190,6 +191,10 @@
190
191
  animation-timing-function: ease-out;
191
192
  animation-fill-mode: both;
192
193
 
194
+ @media (prefers-reduced-motion: reduce) {
195
+ animation: none;
196
+ }
197
+
193
198
  &.ss-value-out {
194
199
  animation-name: ss-valueOut;
195
200
  animation-duration: var(--ss-animation-timing);
@@ -302,6 +307,7 @@
302
307
  box-sizing: border-box;
303
308
  border: solid 1px var(--ss-border-color);
304
309
  background-color: var(--ss-bg-color);
310
+ min-height: 0;
305
311
  transition:
306
312
  transform var(--ss-animation-timing),
307
313
  opacity var(--ss-animation-timing);
@@ -310,6 +316,10 @@
310
316
  overflow: hidden;
311
317
  z-index: 10000;
312
318
 
319
+ @media (prefers-reduced-motion: reduce) {
320
+ transition: none;
321
+ }
322
+
313
323
  &.ss-relative {
314
324
  position: relative;
315
325
  height: 100%;
@@ -341,6 +351,11 @@
341
351
  flex: 0 1 auto;
342
352
  display: flex;
343
353
  flex-direction: row;
354
+ align-items: center;
355
+ gap: var(--ss-spacing-s);
356
+ min-height: var(--ss-search-height);
357
+ padding: 0 var(--ss-spacing-s);
358
+ box-sizing: border-box;
344
359
  border-bottom: 1px solid var(--ss-border-color);
345
360
 
346
361
  input {
@@ -349,9 +364,10 @@
349
364
  line-height: inherit;
350
365
  flex: 1 1 auto;
351
366
  width: 100%;
352
- min-width: 0px;
353
- height: var(--ss-search-height);
354
- padding: var(--ss-spacing-m) var(--ss-spacing-l);
367
+ min-width: 0;
368
+ min-height: 0;
369
+ height: 100%;
370
+ padding: 0 var(--ss-spacing-m);
355
371
  margin: 0;
356
372
  border: none;
357
373
  background-color: var(--ss-bg-color);
@@ -375,23 +391,27 @@
375
391
  align-items: center;
376
392
  cursor: pointer;
377
393
  flex: 0 0 auto;
378
- height: auto;
379
- margin: 0 0 0 var(--ss-spacing-m);
380
- border: 1px solid var(--ss-border-color);
394
+ box-sizing: border-box;
395
+ width: 22px;
396
+ height: 22px;
397
+ margin: auto 0;
398
+ padding: 0;
399
+ border: none;
381
400
  border-radius: var(--ss-border-radius);
401
+ background-color: var(--ss-primary-color);
382
402
 
383
403
  svg {
384
404
  display: flex;
385
405
  align-items: center;
386
- justify-content: flex-end;
387
- flex: 0 1 auto;
388
- width: 12px;
389
- height: 12px;
390
- margin: auto var(--ss-spacing-m) auto var(--ss-spacing-m);
406
+ justify-content: center;
407
+ flex: 0 0 auto;
408
+ width: 10px;
409
+ height: 10px;
410
+ margin: 0;
391
411
 
392
412
  path {
393
413
  fill: none;
394
- stroke: var(--ss-font-color);
414
+ stroke: var(--ss-bg-color);
395
415
  stroke-width: 18;
396
416
  stroke-linecap: round;
397
417
  stroke-linejoin: round;
@@ -408,8 +428,10 @@
408
428
  .ss-list {
409
429
  flex: 1 1 auto;
410
430
  height: auto;
431
+ min-height: 0;
411
432
  overflow-x: hidden;
412
433
  overflow-y: auto;
434
+ scrollbar-color: var(--ss-primary-color) var(--ss-bg-color);
413
435
 
414
436
  .ss-error {
415
437
  color: var(--ss-error-color);
@@ -423,8 +445,10 @@
423
445
 
424
446
  .ss-optgroup {
425
447
  .ss-option {
448
+ min-height: 0;
426
449
  transition:
427
450
  max-height var(--ss-animation-timing) ease,
451
+ min-height var(--ss-animation-timing) ease,
428
452
  opacity var(--ss-animation-timing) ease,
429
453
  padding-top var(--ss-animation-timing) ease,
430
454
  padding-bottom var(--ss-animation-timing) ease,
@@ -432,8 +456,13 @@
432
456
  margin-bottom var(--ss-animation-timing) ease;
433
457
  }
434
458
 
459
+ &:not(.ss-close):not(.ss-open) .ss-option {
460
+ min-height: var(--ss-option-height);
461
+ }
462
+
435
463
  &.ss-open {
436
464
  .ss-option {
465
+ min-height: var(--ss-option-height);
437
466
  max-height: 100px;
438
467
  opacity: 1;
439
468
  overflow: visible;
@@ -443,6 +472,7 @@
443
472
  // If optgroup has close, hide all options
444
473
  &.ss-close {
445
474
  .ss-option {
475
+ min-height: 0 !important;
446
476
  padding-top: 0 !important;
447
477
  padding-bottom: 0 !important;
448
478
  margin-top: 0 !important;
@@ -458,8 +488,8 @@
458
488
  flex-direction: row;
459
489
  align-items: center;
460
490
  justify-content: space-between;
461
- padding: var(--ss-spacing-m) var(--ss-spacing-l) var(--ss-spacing-m)
462
- var(--ss-spacing-l);
491
+ min-height: var(--ss-option-height);
492
+ padding: 0 var(--ss-spacing-l);
463
493
 
464
494
  .ss-optgroup-label-text {
465
495
  flex: 1 1 auto;
@@ -555,8 +585,7 @@
555
585
  }
556
586
 
557
587
  .ss-option {
558
- padding: var(--ss-spacing-s) var(--ss-spacing-s) var(--ss-spacing-s)
559
- calc(var(--ss-spacing-l) * 3);
588
+ padding: 0 var(--ss-spacing-l) 0 calc(var(--ss-spacing-l) * 3);
560
589
  }
561
590
  }
562
591
 
@@ -564,12 +593,13 @@
564
593
  display: flex;
565
594
  align-items: center;
566
595
  min-height: var(--ss-option-height);
567
- padding: var(--ss-spacing-m) var(--ss-spacing-l) var(--ss-spacing-m)
568
- var(--ss-spacing-l);
596
+ padding: 0 var(--ss-spacing-l);
569
597
  white-space: normal;
570
598
  color: var(--ss-font-color);
571
599
  cursor: pointer;
572
600
  user-select: none;
601
+ content-visibility: auto;
602
+ contain-intrinsic-size: auto var(--ss-option-height);
573
603
 
574
604
  &:hover:not(.ss-disabled) {
575
605
  color: var(--ss-bg-color);
@@ -604,8 +634,134 @@
604
634
  display: flex;
605
635
  flex-direction: row;
606
636
  align-items: center;
607
- padding: var(--ss-spacing-m) var(--ss-spacing-l) var(--ss-spacing-m)
608
- var(--ss-spacing-l);
637
+ min-height: var(--ss-search-height);
638
+ padding: 0 var(--ss-spacing-l);
639
+ }
640
+ }
641
+ }
642
+
643
+ // Modal overlay
644
+ .ss-modal-overlay {
645
+ position: fixed;
646
+ inset: 0;
647
+ z-index: var(--ss-modal-z-index);
648
+ display: flex;
649
+ align-items: center;
650
+ justify-content: center;
651
+ padding: var(--ss-spacing-l);
652
+ box-sizing: border-box;
653
+ background-color: rgba(0, 0, 0, 0.8);
654
+ opacity: 0;
655
+ transition: opacity var(--ss-animation-timing);
656
+
657
+ @media (prefers-reduced-motion: reduce) {
658
+ transition: none;
659
+ }
660
+
661
+ &.ss-open {
662
+ opacity: 1;
663
+ }
664
+
665
+ .ss-modal-dialog {
666
+ position: relative;
667
+ display: flex;
668
+ flex-direction: column;
669
+ width: 100%;
670
+ max-width: var(--ss-modal-width);
671
+ max-height: var(--ss-modal-height);
672
+ overflow: visible;
673
+
674
+ .ss-modal-title {
675
+ flex: 0 0 auto;
676
+ width: 100%;
677
+ padding: 0 0 var(--ss-spacing-l);
678
+ box-sizing: border-box;
679
+ font-weight: bold;
680
+ font-size: 1.35em;
681
+ line-height: 1.3;
682
+ color: #ffffff;
683
+ text-align: left;
684
+ background: none;
685
+ border: none;
686
+ }
687
+
688
+ .ss-content {
689
+ &.ss-modal-content {
690
+ position: relative !important;
691
+ top: auto !important;
692
+ left: auto !important;
693
+ width: 100% !important;
694
+ max-width: 100%;
695
+ max-height: var(--ss-modal-height);
696
+ min-height: 0;
697
+ margin: 0 !important;
698
+ transform-origin: center center;
699
+ z-index: 1;
700
+ border-radius: var(--ss-border-radius);
701
+ overflow: visible;
702
+
703
+ .ss-modal-close {
704
+ position: absolute;
705
+ top: 0;
706
+ right: 0;
707
+ z-index: 2;
708
+ display: flex;
709
+ align-items: center;
710
+ justify-content: center;
711
+ width: 28px;
712
+ height: 28px;
713
+ padding: 0;
714
+ margin: 0;
715
+ border: none;
716
+ border-radius: var(--ss-border-radius);
717
+ background-color: var(--ss-bg-color);
718
+ color: var(--ss-font-color);
719
+ cursor: pointer;
720
+ outline: 0;
721
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
722
+ transform: translate(50%, -50%);
723
+
724
+ &:hover {
725
+ background-color: var(--ss-bg-color);
726
+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
727
+ }
728
+
729
+ &:focus {
730
+ box-shadow: 0 0 5px var(--ss-focus-color);
731
+ }
732
+
733
+ svg {
734
+ width: 10px;
735
+ height: 10px;
736
+
737
+ path {
738
+ fill: none;
739
+ stroke: currentColor;
740
+ stroke-width: 20;
741
+ stroke-linecap: round;
742
+ stroke-linejoin: round;
743
+ }
744
+ }
745
+ }
746
+
747
+ .ss-list {
748
+ min-height: 0;
749
+ overflow-x: hidden;
750
+ overflow-y: auto;
751
+ border-radius: 0 0 var(--ss-border-radius) var(--ss-border-radius);
752
+ scrollbar-color: var(--ss-primary-color) var(--ss-bg-color);
753
+ }
754
+
755
+ .ss-search.ss-hide ~ .ss-list {
756
+ border-radius: var(--ss-border-radius);
757
+ }
758
+
759
+ &.ss-dir-above,
760
+ &.ss-dir-below {
761
+ flex-direction: column;
762
+ transform-origin: center center;
763
+ }
764
+ }
609
765
  }
610
766
  }
611
767
  }