@r2digisolutions/components 0.21.16 → 0.21.18

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,14 +219,11 @@
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);
208
- const maxWidth = Math.min(320, viewW - margin * 2);
209
- let measured = rect.width;
210
- if (listboxEl?.matches(':popover-open')) {
211
- const raw = listboxEl.getBoundingClientRect().width;
212
- // UA [popover] { inset: 0 } can report nearly the viewport until CSS/layout settles.
213
- if (raw > 0 && raw < viewW * 0.5) measured = raw;
214
- }
215
- const width = Math.min(maxWidth, Math.max(rect.width, measured));
222
+ const ceiling = Math.min(maxHeight, available);
223
+ listHeightCeiling = ceiling;
224
+
225
+ // Match the trigger: never narrower, never capped at an arbitrary px (was 320).
226
+ const width = Math.min(Math.max(rect.width, 0), viewW - margin * 2);
216
227
 
217
228
  let left = rect.left;
218
229
  if (left + width > viewLeft + viewW - margin) {
@@ -225,11 +236,13 @@
225
236
  `bottom:${openUp ? `${viewTop + viewH - rect.top + gap}px` : 'auto'}`,
226
237
  `left:${left}px`,
227
238
  'right:auto',
228
- `min-width:${rect.width}px`,
229
- 'width:max-content',
230
- `max-width:${maxWidth}px`,
231
- `max-height:${Math.min(maxHeight, available)}px`
239
+ `width:${width}px`,
240
+ `min-width:${width}px`,
241
+ `max-width:${width}px`,
242
+ `max-height:${ceiling}px`
232
243
  ].join('; ');
244
+
245
+ syncListOverflow(ceiling);
233
246
  }
234
247
 
235
248
  function openListbox() {
@@ -263,6 +276,7 @@
263
276
  ignoreHover = true;
264
277
  requestAnimationFrame(() => {
265
278
  positionListbox();
279
+ syncListOverflow(listHeightCeiling);
266
280
  if (searchable) searchInputEl?.focus();
267
281
  else listboxEl?.focus();
268
282
  scrollHighlightedIntoView();
@@ -566,7 +580,7 @@
566
580
  aria-activedescendant={isOpen ? activeOptionId : undefined}
567
581
  style={listboxStyle}
568
582
  class={[
569
- 'select-listbox m-0 p-0 inset-auto overflow-hidden',
583
+ 'select-listbox m-0 p-0 inset-auto overflow-x-hidden overflow-y-hidden',
570
584
  'bg-surface-elevated border-border rounded-xl shadow-xl border',
571
585
  'flex flex-col outline-none'
572
586
  ]}
@@ -610,7 +624,13 @@
610
624
  <div class="border-border mx-1.5 mb-0.5 h-px border-b" role="separator"></div>
611
625
  {/if}
612
626
 
613
- <div bind:this={optionsContainerEl} class="p-1.5 min-h-0 overflow-y-auto">
627
+ <div
628
+ bind:this={optionsContainerEl}
629
+ class={[
630
+ 'p-1.5 min-h-0 overflow-x-hidden overscroll-contain',
631
+ listOverflow ? 'overflow-y-auto' : 'overflow-y-hidden'
632
+ ]}
633
+ >
614
634
  {#if visibleOptions.length === 0}
615
635
  <div class="px-3 py-2.5 text-xs text-muted text-center">No options found</div>
616
636
  {:else}
@@ -642,9 +662,9 @@
642
662
  'transition-[background-color,color,box-shadow] duration-75',
643
663
  option.disabled ? 'cursor-not-allowed opacity-40' : 'cursor-pointer',
644
664
  isHighlighted && !option.disabled
645
- ? 'bg-neutral-800 text-white shadow-sm dark:bg-neutral-200 dark:text-neutral-900'
665
+ ? 'bg-brand-500 text-white shadow-sm'
646
666
  : isSelected && !option.disabled
647
- ? 'bg-neutral-100 font-medium text-primary dark:bg-neutral-800/70'
667
+ ? 'bg-brand-500/10 font-medium text-primary'
648
668
  : 'text-primary hover:bg-surface-overlay'
649
669
  ]}
650
670
  >
@@ -652,12 +672,12 @@
652
672
  <span
653
673
  class={[
654
674
  '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'
675
+ isSelected && !option.disabled
676
+ ? isHighlighted
677
+ ? 'border-white bg-white'
678
+ : 'border-brand-500 bg-brand-500'
679
+ : isHighlighted && !option.disabled
680
+ ? 'border-white/80 bg-transparent'
661
681
  : 'border-border-strong bg-transparent'
662
682
  ]}
663
683
  aria-hidden="true"
@@ -666,9 +686,7 @@
666
686
  <svg
667
687
  class={[
668
688
  'h-2.5 w-2.5',
669
- isHighlighted
670
- ? 'text-neutral-800 dark:text-neutral-100'
671
- : 'text-white dark:text-neutral-900'
689
+ isHighlighted && !option.disabled ? 'text-brand-500' : 'text-white'
672
690
  ]}
673
691
  viewBox="0 0 24 24"
674
692
  fill="none"
@@ -682,14 +700,12 @@
682
700
  {/if}
683
701
 
684
702
  <span class="min-w-0 flex-1">
685
- <span class="block whitespace-nowrap">{option.label}</span>
703
+ <span class="block break-words">{option.label}</span>
686
704
  {#if secondary}
687
705
  <span
688
706
  class={[
689
- 'mt-0.5 block text-[11px] whitespace-nowrap',
690
- isHighlighted && !option.disabled
691
- ? 'text-white/75'
692
- : 'text-secondary'
707
+ 'mt-0.5 block text-[11px] break-words',
708
+ isHighlighted && !option.disabled ? 'text-white/80' : 'text-secondary'
693
709
  ]}
694
710
  >
695
711
  {secondary}
@@ -701,9 +717,7 @@
701
717
  <svg
702
718
  class={[
703
719
  'h-4 w-4 shrink-0',
704
- isHighlighted && !option.disabled
705
- ? 'text-white/80'
706
- : 'text-secondary'
720
+ isHighlighted && !option.disabled ? 'text-white/80' : 'text-secondary'
707
721
  ]}
708
722
  viewBox="0 0 24 24"
709
723
  fill="none"
@@ -740,7 +754,8 @@
740
754
 
741
755
  .select-listbox:popover-open {
742
756
  display: flex;
743
- overflow: hidden;
757
+ overflow-x: hidden;
758
+ overflow-y: hidden;
744
759
  }
745
760
 
746
761
  .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.18",
4
4
  "private": false,
5
5
  "description": "R2DigiSolutions Svelte 5 component library — Atomic Design, Tailwind 4, Light/Dark mode",
6
6
  "license": "MIT",