@r2digisolutions/components 0.21.16 → 0.21.17

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.
@@ -72,14 +72,14 @@
72
72
  success:
73
73
  'checked:bg-green-500 checked:border-green-500 indeterminate:bg-green-500 indeterminate:border-green-500 hover:border-green-400 focus-visible:ring-green-500',
74
74
  neutral:
75
- 'checked:bg-neutral-800 checked:border-neutral-800 indeterminate:bg-neutral-800 indeterminate:border-neutral-800 hover:border-neutral-500 focus-visible:ring-neutral-500 dark:checked:bg-neutral-200 dark:checked:border-neutral-200 dark:indeterminate:bg-neutral-200 dark:indeterminate:border-neutral-200 dark:hover:border-neutral-400 dark:focus-visible:ring-neutral-400'
75
+ 'checked:bg-neutral-800 checked:border-neutral-800 indeterminate:bg-neutral-800 indeterminate:border-neutral-800 hover:border-neutral-500 focus-visible:ring-neutral-500 dark:checked:bg-neutral-600 dark:checked:border-neutral-500 dark:indeterminate:bg-neutral-600 dark:indeterminate:border-neutral-500 dark:hover:border-neutral-400 dark:focus-visible:ring-neutral-400'
76
76
  };
77
77
 
78
78
  const toneIconColors: Record<SelectionBoxTone, string> = {
79
79
  brand: 'text-white',
80
80
  success: 'text-white',
81
81
  primary: 'text-white dark:text-neutral-900',
82
- neutral: 'text-white dark:text-neutral-900'
82
+ neutral: 'text-white'
83
83
  };
84
84
 
85
85
  function handleChange(e: Event) {
@@ -113,7 +113,7 @@
113
113
  {@attach setIndeterminate}
114
114
  class={[
115
115
  'absolute inset-0 cursor-pointer border-2 border-border bg-surface-elevated appearance-none transition-all duration-150',
116
- 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2',
116
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-surface',
117
117
  'disabled:cursor-not-allowed disabled:opacity-50',
118
118
  radiusClasses[radius],
119
119
  toneChecked[tone]
@@ -345,7 +345,7 @@
345
345
  />
346
346
  </div>
347
347
  {/if}
348
- <div class="min-h-0 flex-1 overflow-y-auto p-1.5">
348
+ <div class="min-h-0 overflow-y-auto overscroll-contain p-1.5">
349
349
  {#if filtered.length === 0}
350
350
  <div class="px-3 py-2.5 text-center text-xs text-muted">{emptyText}</div>
351
351
  {:else}
@@ -367,25 +367,23 @@
367
367
  (option.disabled || blocked) && 'cursor-not-allowed opacity-40',
368
368
  !option.disabled &&
369
369
  !blocked &&
370
- (highlighted === index || isSelected
371
- ? 'bg-neutral-800 text-white dark:bg-neutral-200 dark:text-neutral-900'
372
- : 'text-primary hover:bg-surface-overlay')
370
+ (highlighted === index
371
+ ? 'bg-surface-overlay text-primary'
372
+ : isSelected
373
+ ? 'bg-brand-500/10 font-medium text-primary'
374
+ : 'text-primary hover:bg-surface-overlay')
373
375
  ]}
374
376
  >
375
377
  <span
376
378
  class={[
377
379
  'flex h-4 w-4 shrink-0 items-center justify-center rounded border transition-colors',
378
- isSelected
379
- ? 'border-white bg-white dark:border-neutral-900 dark:bg-neutral-900'
380
- : highlighted === index
381
- ? 'border-white/60 dark:border-neutral-900/50'
382
- : 'border-border-strong'
380
+ isSelected ? 'border-brand-500 bg-brand-500' : 'border-border-strong'
383
381
  ]}
384
382
  aria-hidden="true"
385
383
  >
386
384
  {#if isSelected}
387
385
  <svg
388
- class="h-2.5 w-2.5 text-neutral-800 dark:text-neutral-100"
386
+ class="h-2.5 w-2.5 text-white"
389
387
  viewBox="0 0 24 24"
390
388
  fill="none"
391
389
  stroke="currentColor"
@@ -61,6 +61,8 @@
61
61
  let searchInputEl = $state<HTMLInputElement | null>(null);
62
62
  let optionsContainerEl = $state<HTMLDivElement | null>(null);
63
63
  let listboxStyle = $state('');
64
+ let listOverflow = $state(false);
65
+ let listHeightCeiling = $state(240);
64
66
  /** After keyboard nav, ignore hover until the mouse actually moves */
65
67
  let ignoreHover = $state(false);
66
68
 
@@ -188,6 +190,18 @@
188
190
  }
189
191
  }
190
192
 
193
+ function syncListOverflow(ceiling: number) {
194
+ if (!listboxEl) {
195
+ listOverflow = false;
196
+ return;
197
+ }
198
+ const fits = listboxEl.scrollHeight <= ceiling;
199
+ listOverflow = !fits;
200
+ if (fits) {
201
+ listboxStyle = listboxStyle.replace(/max-height:[^;]+/, 'max-height:none');
202
+ }
203
+ }
204
+
191
205
  function positionListbox() {
192
206
  if (!triggerEl) return;
193
207
 
@@ -205,6 +219,8 @@
205
219
  const spaceAbove = rect.top - viewTop - gap - margin;
206
220
  const openUp = spaceBelow < Math.min(maxHeight, 160) && spaceAbove > spaceBelow;
207
221
  const available = Math.max(120, openUp ? spaceAbove : spaceBelow);
222
+ const ceiling = Math.min(maxHeight, available);
223
+ listHeightCeiling = ceiling;
208
224
  const maxWidth = Math.min(320, viewW - margin * 2);
209
225
  let measured = rect.width;
210
226
  if (listboxEl?.matches(':popover-open')) {
@@ -225,11 +241,13 @@
225
241
  `bottom:${openUp ? `${viewTop + viewH - rect.top + gap}px` : 'auto'}`,
226
242
  `left:${left}px`,
227
243
  'right:auto',
228
- `min-width:${rect.width}px`,
229
- 'width:max-content',
244
+ `width:${width}px`,
245
+ `min-width:${Math.min(rect.width, maxWidth)}px`,
230
246
  `max-width:${maxWidth}px`,
231
- `max-height:${Math.min(maxHeight, available)}px`
247
+ `max-height:${ceiling}px`
232
248
  ].join('; ');
249
+
250
+ syncListOverflow(ceiling);
233
251
  }
234
252
 
235
253
  function openListbox() {
@@ -263,6 +281,7 @@
263
281
  ignoreHover = true;
264
282
  requestAnimationFrame(() => {
265
283
  positionListbox();
284
+ syncListOverflow(listHeightCeiling);
266
285
  if (searchable) searchInputEl?.focus();
267
286
  else listboxEl?.focus();
268
287
  scrollHighlightedIntoView();
@@ -566,7 +585,7 @@
566
585
  aria-activedescendant={isOpen ? activeOptionId : undefined}
567
586
  style={listboxStyle}
568
587
  class={[
569
- 'select-listbox m-0 p-0 inset-auto overflow-hidden',
588
+ 'select-listbox m-0 p-0 inset-auto overflow-x-hidden overflow-y-hidden',
570
589
  'bg-surface-elevated border-border rounded-xl shadow-xl border',
571
590
  'flex flex-col outline-none'
572
591
  ]}
@@ -610,7 +629,13 @@
610
629
  <div class="border-border mx-1.5 mb-0.5 h-px border-b" role="separator"></div>
611
630
  {/if}
612
631
 
613
- <div bind:this={optionsContainerEl} class="p-1.5 min-h-0 overflow-y-auto">
632
+ <div
633
+ bind:this={optionsContainerEl}
634
+ class={[
635
+ 'p-1.5 min-h-0 overflow-x-hidden overscroll-contain',
636
+ listOverflow ? 'overflow-y-auto' : 'overflow-y-hidden'
637
+ ]}
638
+ >
614
639
  {#if visibleOptions.length === 0}
615
640
  <div class="px-3 py-2.5 text-xs text-muted text-center">No options found</div>
616
641
  {:else}
@@ -642,9 +667,9 @@
642
667
  'transition-[background-color,color,box-shadow] duration-75',
643
668
  option.disabled ? 'cursor-not-allowed opacity-40' : 'cursor-pointer',
644
669
  isHighlighted && !option.disabled
645
- ? 'bg-neutral-800 text-white shadow-sm dark:bg-neutral-200 dark:text-neutral-900'
670
+ ? 'bg-surface-overlay text-primary shadow-sm'
646
671
  : isSelected && !option.disabled
647
- ? 'bg-neutral-100 font-medium text-primary dark:bg-neutral-800/70'
672
+ ? 'bg-brand-500/10 font-medium text-primary'
648
673
  : 'text-primary hover:bg-surface-overlay'
649
674
  ]}
650
675
  >
@@ -652,24 +677,15 @@
652
677
  <span
653
678
  class={[
654
679
  'h-4 w-4 flex shrink-0 items-center justify-center rounded-full border transition-colors duration-75',
655
- isHighlighted && !option.disabled
656
- ? isSelected
657
- ? 'border-white bg-white dark:border-neutral-900 dark:bg-neutral-900'
658
- : 'border-white/60 bg-transparent dark:border-neutral-900/50'
659
- : isSelected && !option.disabled
660
- ? 'border-neutral-800 bg-neutral-800 dark:border-neutral-200 dark:bg-neutral-200'
661
- : 'border-border-strong bg-transparent'
680
+ isSelected && !option.disabled
681
+ ? 'border-brand-500 bg-brand-500'
682
+ : 'border-border-strong bg-transparent'
662
683
  ]}
663
684
  aria-hidden="true"
664
685
  >
665
686
  {#if isSelected}
666
687
  <svg
667
- class={[
668
- 'h-2.5 w-2.5',
669
- isHighlighted
670
- ? 'text-neutral-800 dark:text-neutral-100'
671
- : 'text-white dark:text-neutral-900'
672
- ]}
688
+ class="h-2.5 w-2.5 text-white"
673
689
  viewBox="0 0 24 24"
674
690
  fill="none"
675
691
  stroke="currentColor"
@@ -682,16 +698,9 @@
682
698
  {/if}
683
699
 
684
700
  <span class="min-w-0 flex-1">
685
- <span class="block whitespace-nowrap">{option.label}</span>
701
+ <span class="block break-words">{option.label}</span>
686
702
  {#if secondary}
687
- <span
688
- class={[
689
- 'mt-0.5 block text-[11px] whitespace-nowrap',
690
- isHighlighted && !option.disabled
691
- ? 'text-white/75'
692
- : 'text-secondary'
693
- ]}
694
- >
703
+ <span class="mt-0.5 block text-[11px] break-words text-secondary">
695
704
  {secondary}
696
705
  </span>
697
706
  {/if}
@@ -699,12 +708,7 @@
699
708
 
700
709
  {#if hasChildren}
701
710
  <svg
702
- class={[
703
- 'h-4 w-4 shrink-0',
704
- isHighlighted && !option.disabled
705
- ? 'text-white/80'
706
- : 'text-secondary'
707
- ]}
711
+ class="h-4 w-4 shrink-0 text-secondary"
708
712
  viewBox="0 0 24 24"
709
713
  fill="none"
710
714
  stroke="currentColor"
@@ -740,7 +744,8 @@
740
744
 
741
745
  .select-listbox:popover-open {
742
746
  display: flex;
743
- overflow: hidden;
747
+ overflow-x: hidden;
748
+ overflow-y: hidden;
744
749
  }
745
750
 
746
751
  .select-listbox:not(:popover-open) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r2digisolutions/components",
3
- "version": "0.21.16",
3
+ "version": "0.21.17",
4
4
  "private": false,
5
5
  "description": "R2DigiSolutions Svelte 5 component library — Atomic Design, Tailwind 4, Light/Dark mode",
6
6
  "license": "MIT",