@leitware/composables 2.0.0 → 3.0.0

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.
Files changed (88) hide show
  1. package/README.md +16 -0
  2. package/dist/presets/brutalist.css +16 -17
  3. package/dist/presets/default.css +11 -13
  4. package/dist/presets/editorial-grid.css +12 -13
  5. package/dist/presets/kumo.css +14 -20
  6. package/dist/presets/signal-pop.css +14 -26
  7. package/dist/styles.css +1 -1
  8. package/dist/tailwind.css +20 -0
  9. package/package.json +7 -7
  10. package/rules/composables.md +10 -9
  11. package/skills/use-composables/references/public-api.md +1 -1
  12. package/skills/use-composables/references/semantic-utilities.md +5 -0
  13. package/src/_internal/accordion.tsx +10 -10
  14. package/src/_internal/alert-dialog.tsx +3 -3
  15. package/src/_internal/alert.tsx +9 -7
  16. package/src/_internal/avatar.tsx +25 -14
  17. package/src/_internal/badge.tsx +2 -1
  18. package/src/_internal/bubble.tsx +2 -2
  19. package/src/_internal/button.tsx +16 -8
  20. package/src/_internal/calendar.tsx +3 -3
  21. package/src/_internal/card.tsx +53 -17
  22. package/src/_internal/checkbox.tsx +2 -2
  23. package/src/_internal/combobox.tsx +2 -2
  24. package/src/_internal/dialog.tsx +29 -9
  25. package/src/_internal/divider.tsx +14 -16
  26. package/src/_internal/dropdown-menu.tsx +4 -4
  27. package/src/_internal/empty.tsx +6 -3
  28. package/src/_internal/field.tsx +11 -7
  29. package/src/_internal/hover-card.tsx +1 -1
  30. package/src/_internal/input-group.tsx +17 -12
  31. package/src/_internal/input.tsx +33 -4
  32. package/src/_internal/item.tsx +2 -2
  33. package/src/_internal/label.tsx +1 -1
  34. package/src/_internal/message.tsx +1 -1
  35. package/src/_internal/native-select.tsx +1 -1
  36. package/src/_internal/popover.tsx +9 -3
  37. package/src/_internal/progress.tsx +37 -7
  38. package/src/_internal/radio-group.tsx +39 -4
  39. package/src/_internal/select.tsx +2 -2
  40. package/src/_internal/separator.tsx +1 -1
  41. package/src/_internal/sheet.tsx +9 -3
  42. package/src/_internal/sidebar.tsx +0 -35
  43. package/src/_internal/skeleton.tsx +26 -3
  44. package/src/_internal/slider.tsx +9 -7
  45. package/src/_internal/sonner.tsx +4 -4
  46. package/src/_internal/spinner.tsx +43 -3
  47. package/src/_internal/switch.tsx +2 -2
  48. package/src/_internal/table.tsx +20 -5
  49. package/src/_internal/tabs.tsx +4 -1
  50. package/src/_internal/textarea.tsx +1 -1
  51. package/src/_internal/toggle.tsx +1 -1
  52. package/src/_internal/tooltip.tsx +53 -8
  53. package/src/_internal/typography.tsx +4 -2
  54. package/src/index.ts +2 -1
  55. package/src/lib/utils.ts +2 -2
  56. package/src/opinionated/alert.tsx +8 -10
  57. package/src/opinionated/avatar.tsx +2 -2
  58. package/src/opinionated/button.tsx +13 -3
  59. package/src/opinionated/dialog.tsx +10 -1
  60. package/src/opinionated/form-calendar-popover.tsx +5 -10
  61. package/src/opinionated/form-checkbox.tsx +2 -2
  62. package/src/opinionated/form-date-of-birth.tsx +12 -8
  63. package/src/opinionated/form-input-group.tsx +1 -1
  64. package/src/opinionated/form-radiogroup.tsx +24 -7
  65. package/src/opinionated/form-switch.tsx +7 -6
  66. package/src/opinionated/progress.tsx +7 -2
  67. package/src/opinionated/select.tsx +4 -1
  68. package/src/opinionated/sidebar.tsx +0 -1
  69. package/src/opinionated/skeleton.tsx +3 -13
  70. package/src/opinionated/spinner.tsx +2 -0
  71. package/src/opinionated/token-config-panel/spacing-editor.tsx +21 -3
  72. package/src/opinionated/tooltip.tsx +20 -2
  73. package/src/styles/presets/brutalist.css +16 -17
  74. package/src/styles/presets/default.css +11 -13
  75. package/src/styles/presets/editorial-grid.css +12 -13
  76. package/src/styles/presets/kumo.css +14 -20
  77. package/src/styles/presets/signal-pop.css +14 -26
  78. package/src/styles/presets-data/brutalist.ts +16 -19
  79. package/src/styles/presets-data/default.ts +11 -15
  80. package/src/styles/presets-data/editorial-grid.ts +12 -6
  81. package/src/styles/presets-data/kumo.ts +12 -6
  82. package/src/styles/presets-data/signal-pop.ts +14 -30
  83. package/src/styles/tokens/components.css +64 -20
  84. package/src/styles/tokens/registry.ts +33 -0
  85. package/src/styles/tokens/semantic-utilities.css +20 -0
  86. package/src/styles/tokens/semantic.css +10 -0
  87. package/src/styles/tokens/tailwind-color-adapter.css +3 -0
  88. package/src/styles/tokens/tailwind-public-utilities.css +20 -0
@@ -22,7 +22,7 @@ function Message({
22
22
  data-slot="message"
23
23
  data-align={align}
24
24
  className={cn(
25
- 'group/message relative flex w-full min-w-0 gap-2 text-xs/relaxed data-[align=end]:flex-row-reverse',
25
+ 'group/message relative flex w-full min-w-0 gap-2 text-(length:--body-font-size) leading-relaxed data-[align=end]:flex-row-reverse',
26
26
  className,
27
27
  )}
28
28
  {...props}
@@ -27,7 +27,7 @@ function NativeSelect({
27
27
  className={cn(
28
28
  FOCUS_RING,
29
29
  HOVER_RING,
30
- 'border-field bg-page h-(--input-height) w-full appearance-none rounded-(--input-radius) border px-3 py-2 pr-9 text-xs/relaxed shadow-xs outline-none motion-colors disabled:pointer-events-none disabled:cursor-not-allowed data-[size=sm]:h-8 data-[size=sm]:py-1',
30
+ 'border-field bg-surface-input h-(--control-size-md) w-full min-w-(--control-min-width) appearance-none rounded-(--input-radius) border px-3 py-0 pr-9 text-(length:--control-font-size) leading-relaxed shadow-xs outline-none motion-colors disabled:pointer-events-none disabled:cursor-not-allowed data-[size=sm]:h-(--control-size-sm)',
31
31
  className,
32
32
  )}
33
33
  {...props}
@@ -40,7 +40,7 @@ function PopoverContent({
40
40
  <PopoverPrimitive.Popup
41
41
  data-slot="popover-content"
42
42
  className={cn(
43
- 'bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 flex flex-col gap-4 rounded-lg p-2.5 text-xs shadow-md ring-[length:var(--border-width)] duration-fast z-popover w-72 origin-(--transform-origin) outline-hidden',
43
+ 'bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 flex flex-col gap-4 rounded-lg p-2.5 text-(length:--body-font-size) leading-(--body-line-height) shadow-md ring-[length:var(--border-width)] duration-fast z-popover w-72 origin-(--transform-origin) outline-hidden',
44
44
  className,
45
45
  )}
46
46
  {...props}
@@ -54,7 +54,10 @@ function PopoverHeader({ className, ...props }: React.ComponentProps<'div'>) {
54
54
  return (
55
55
  <div
56
56
  data-slot="popover-header"
57
- className={cn('flex flex-col gap-1 text-xs', className)}
57
+ className={cn(
58
+ 'flex flex-col gap-1 text-(length:--body-font-size) leading-(--body-line-height)',
59
+ className,
60
+ )}
58
61
  {...props}
59
62
  />
60
63
  )
@@ -64,7 +67,10 @@ function PopoverTitle({ className, ...props }: PopoverPrimitive.Title.Props) {
64
67
  return (
65
68
  <PopoverPrimitive.Title
66
69
  data-slot="popover-title"
67
- className={cn('text-sm font-medium', className)}
70
+ className={cn(
71
+ 'text-(length:--title-font-size) leading-(--title-line-height) font-medium',
72
+ className,
73
+ )}
68
74
  {...props}
69
75
  />
70
76
  )
@@ -1,7 +1,25 @@
1
1
  import { Progress as ProgressPrimitive } from '@base-ui/react/progress'
2
+ import { cva, type VariantProps } from 'class-variance-authority'
2
3
 
3
4
  import { cn } from '../lib/utils'
4
5
 
6
+ const progressIndicatorVariants = cva(
7
+ 'h-full rounded-full transition-[width] duration-normal ease-out',
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: 'bg-primary',
12
+ success: 'bg-fill-success',
13
+ warning: 'bg-fill-warning',
14
+ destructive: 'bg-fill-critical',
15
+ },
16
+ },
17
+ defaultVariants: {
18
+ variant: 'default',
19
+ },
20
+ },
21
+ )
22
+
5
23
  function Progress({ className, value, ...props }: ProgressPrimitive.Root.Props) {
6
24
  return (
7
25
  <ProgressPrimitive.Root
@@ -17,20 +35,25 @@ function ProgressTrack({ className, ...props }: ProgressPrimitive.Track.Props) {
17
35
  return (
18
36
  <ProgressPrimitive.Track
19
37
  data-slot="progress-track"
20
- className={cn('relative h-2 w-full overflow-hidden rounded-full bg-muted', className)}
38
+ className={cn(
39
+ 'relative h-2 w-full overflow-hidden rounded-full bg-muted has-data-[variant=success]:bg-surface-success has-data-[variant=warning]:bg-surface-warning has-data-[variant=destructive]:bg-surface-critical',
40
+ className,
41
+ )}
21
42
  {...props}
22
43
  />
23
44
  )
24
45
  }
25
46
 
26
- function ProgressIndicator({ className, ...props }: ProgressPrimitive.Indicator.Props) {
47
+ function ProgressIndicator({
48
+ className,
49
+ variant,
50
+ ...props
51
+ }: ProgressPrimitive.Indicator.Props & VariantProps<typeof progressIndicatorVariants>) {
27
52
  return (
28
53
  <ProgressPrimitive.Indicator
29
54
  data-slot="progress-indicator"
30
- className={cn(
31
- 'h-full rounded-full bg-primary transition-[width] duration-normal ease-out',
32
- className,
33
- )}
55
+ data-variant={variant ?? 'default'}
56
+ className={cn(progressIndicatorVariants({ variant, className }))}
34
57
  {...props}
35
58
  />
36
59
  )
@@ -56,4 +79,11 @@ function ProgressValue({ className, ...props }: ProgressPrimitive.Value.Props) {
56
79
  )
57
80
  }
58
81
 
59
- export { Progress, ProgressTrack, ProgressIndicator, ProgressLabel, ProgressValue }
82
+ export {
83
+ Progress,
84
+ ProgressTrack,
85
+ ProgressIndicator,
86
+ progressIndicatorVariants,
87
+ ProgressLabel,
88
+ ProgressValue,
89
+ }
@@ -1,5 +1,9 @@
1
1
  import { Radio as RadioPrimitive } from '@base-ui/react/radio'
2
2
  import { RadioGroup as RadioGroupPrimitive } from '@base-ui/react/radio-group'
3
+ import { cva, type VariantProps } from 'class-variance-authority'
4
+ import type * as React from 'react'
5
+
6
+ import { Label } from './label'
3
7
  import { cn, FOCUS_RING, HOVER_RING } from '../lib/utils'
4
8
 
5
9
  function RadioGroup({ className, ...props }: RadioGroupPrimitive.Props) {
@@ -19,19 +23,50 @@ function RadioGroupItem({ className, ...props }: RadioPrimitive.Root.Props) {
19
23
  className={cn(
20
24
  FOCUS_RING,
21
25
  HOVER_RING,
22
- 'border-field dark:bg-surface-field/30 data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary data-checked:border-primary flex size-4 rounded-[var(--radius)] transition-shadow group/radio-group-item peer relative aspect-square shrink-0 border outline-none after:absolute after:-inset-x-3 after:-inset-y-2 disabled:cursor-not-allowed disabled:opacity-disabled',
26
+ 'border-(color:--choice-border-color) not-data-checked:hover:bg-(--bg-surface-hover) dark:bg-surface-field/30 data-checked:bg-selected data-checked:text-selected-foreground dark:data-checked:bg-selected data-checked:border-selected flex size-(--choice-size) rounded-full transition-shadow group/radio-group-item peer relative aspect-square shrink-0 border outline-none after:absolute after:-inset-x-3 after:-inset-y-2 disabled:cursor-not-allowed disabled:opacity-disabled',
23
27
  className,
24
28
  )}
25
29
  {...props}
26
30
  >
27
31
  <RadioPrimitive.Indicator
28
32
  data-slot="radio-group-indicator"
29
- className="flex size-4 items-center justify-center"
33
+ className="flex size-full items-center justify-center"
30
34
  >
31
- <div className="absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rounded-[var(--radius)] bg-current group-aria-invalid/radio-group-item:bg-fill-critical" />
35
+ <div className="absolute top-1/2 left-1/2 size-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-current group-aria-invalid/radio-group-item:bg-fill-critical" />
32
36
  </RadioPrimitive.Indicator>
33
37
  </RadioPrimitive.Root>
34
38
  )
35
39
  }
36
40
 
37
- export { RadioGroup, RadioGroupItem }
41
+ const radioGroupOptionVariants = cva(
42
+ 'flex cursor-pointer items-center gap-2 text-(length:--body-font-size) text-foreground normal-case font-normal leading-snug',
43
+ {
44
+ variants: {
45
+ variant: {
46
+ default: '',
47
+ // Selectable tile: the whole card is the hit area and the checked
48
+ // tile takes the selected colour as its border.
49
+ card: 'bg-accent hover:bg-secondary rounded-(--input-radius) border border-transparent p-3 has-data-checked:border-selected has-disabled:cursor-not-allowed has-disabled:opacity-disabled motion-colors',
50
+ },
51
+ },
52
+ defaultVariants: { variant: 'default' },
53
+ },
54
+ )
55
+
56
+ /** A clickable row (or card) wrapping one RadioGroupItem and its label. */
57
+ function RadioGroupOption({
58
+ className,
59
+ variant = 'default',
60
+ ...props
61
+ }: React.ComponentProps<typeof Label> & VariantProps<typeof radioGroupOptionVariants>) {
62
+ return (
63
+ <Label
64
+ data-slot="radio-group-option"
65
+ data-variant={variant}
66
+ className={cn(radioGroupOptionVariants({ variant }), className)}
67
+ {...props}
68
+ />
69
+ )
70
+ }
71
+
72
+ export { RadioGroup, RadioGroupItem, RadioGroupOption, radioGroupOptionVariants }
@@ -40,7 +40,7 @@ function SelectTrigger({
40
40
  className={cn(
41
41
  FOCUS_RING,
42
42
  HOVER_RING,
43
- "border-field data-[placeholder]:text-muted-foreground bg-surface-field/20 dark:bg-surface-field/30 dark:hover:bg-surface-field/50 gap-1.5 rounded-(--input-radius) border px-2 py-1.5 text-xs/relaxed data-[size=default]:h-(--input-height) data-[size=sm]:h-6 *:data-[slot=select-value]:flex *:data-[slot=select-value]:gap-1.5 [&_svg:not([class*='size-'])]:size-3.5 flex w-fit items-center justify-between whitespace-nowrap outline-none disabled:cursor-not-allowed disabled:opacity-disabled *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center [&_svg]:pointer-events-none [&_svg]:shrink-0",
43
+ "border-field data-[placeholder]:text-muted-foreground bg-surface-input gap-1.5 rounded-(--input-radius) border px-2 py-1.5 text-(length:--control-font-size) leading-relaxed data-[size=default]:h-(--control-size-md) data-[size=sm]:h-(--control-size-sm) *:data-[slot=select-value]:flex *:data-[slot=select-value]:gap-1.5 [&_svg:not([class*='size-'])]:size-3.5 flex w-fit min-w-(--control-min-width) items-center justify-between whitespace-nowrap outline-none disabled:cursor-not-allowed disabled:opacity-disabled *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center [&_svg]:pointer-events-none [&_svg]:shrink-0",
44
44
  className,
45
45
  )}
46
46
  {...props}
@@ -109,7 +109,7 @@ function SelectItem({ className, children, ...props }: SelectPrimitive.Item.Prop
109
109
  <SelectPrimitive.Item
110
110
  data-slot="select-item"
111
111
  className={cn(
112
- "focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground min-h-7 gap-2 rounded-md px-2 py-1 text-xs/relaxed [&_svg:not([class*='size-'])]:size-3.5 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2 relative flex w-full cursor-default items-center outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-disabled [&_svg]:pointer-events-none [&_svg]:shrink-0",
112
+ "focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground min-h-7 gap-2 rounded-md px-2 py-1 text-(length:--control-font-size) leading-relaxed [&_svg:not([class*='size-'])]:size-3.5 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2 relative flex w-full cursor-default items-center outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-disabled [&_svg]:pointer-events-none [&_svg]:shrink-0",
113
113
  className,
114
114
  )}
115
115
  {...props}
@@ -8,7 +8,7 @@ function Separator({ className, orientation = 'horizontal', ...props }: Separato
8
8
  data-slot="separator"
9
9
  orientation={orientation}
10
10
  className={cn(
11
- 'bg-stroke shrink-0 data-[orientation=horizontal]:h-[var(--border-width-base,1px)] data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-[var(--border-width-base,1px)] data-[orientation=vertical]:self-stretch',
11
+ 'bg-stroke shrink-0 data-[orientation=horizontal]:h-(--rule-width) data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-(--rule-width) data-[orientation=vertical]:self-stretch',
12
12
  className,
13
13
  )}
14
14
  {...props}
@@ -50,7 +50,7 @@ function SheetContent({
50
50
  data-slot="sheet-content"
51
51
  data-side={side}
52
52
  className={cn(
53
- 'bg-page data-open:animate-in data-closed:animate-out data-[side=right]:data-closed:slide-out-to-right-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=top]:data-closed:slide-out-to-top-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:fade-out-0 data-open:fade-in-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=bottom]:data-open:slide-in-from-bottom-10 fixed z-modal flex flex-col bg-clip-padding text-xs/relaxed shadow-lg transition-[opacity,transform,box-shadow] duration-normal ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm',
53
+ 'bg-page data-open:animate-in data-closed:animate-out data-[side=right]:data-closed:slide-out-to-right-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=top]:data-closed:slide-out-to-top-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:fade-out-0 data-open:fade-in-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=bottom]:data-open:slide-in-from-bottom-10 fixed z-modal flex flex-col bg-clip-padding text-(length:--body-font-size) leading-relaxed shadow-lg transition-[opacity,transform,box-shadow] duration-normal ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm',
54
54
  className,
55
55
  )}
56
56
  {...props}
@@ -94,7 +94,10 @@ function SheetTitle({ className, ...props }: SheetPrimitive.Title.Props) {
94
94
  return (
95
95
  <SheetPrimitive.Title
96
96
  data-slot="sheet-title"
97
- className={cn('text-foreground text-sm font-medium', className)}
97
+ className={cn(
98
+ 'text-foreground text-(length:--heading-font-size) leading-(--heading-line-height) font-medium',
99
+ className,
100
+ )}
98
101
  {...props}
99
102
  />
100
103
  )
@@ -104,7 +107,10 @@ function SheetDescription({ className, ...props }: SheetPrimitive.Description.Pr
104
107
  return (
105
108
  <SheetPrimitive.Description
106
109
  data-slot="sheet-description"
107
- className={cn('text-muted-foreground text-xs/relaxed', className)}
110
+ className={cn(
111
+ 'text-muted-foreground text-(length:--body-font-size) leading-relaxed',
112
+ className,
113
+ )}
108
114
  {...props}
109
115
  />
110
116
  )
@@ -9,7 +9,6 @@ import { Button } from './button'
9
9
  import { Input } from './input'
10
10
  import { Separator } from './separator'
11
11
  import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from './sheet'
12
- import { Skeleton } from './skeleton'
13
12
  import { Tooltip, TooltipContent, TooltipTrigger } from './tooltip'
14
13
  import { useIsMobile } from '../hooks/use-mobile'
15
14
  import { cn, FOCUS_RING } from '../lib/utils'
@@ -569,39 +568,6 @@ function SidebarMenuBadge({ className, ...props }: React.ComponentProps<'div'>)
569
568
  )
570
569
  }
571
570
 
572
- function SidebarMenuSkeleton({
573
- className,
574
- showIcon = false,
575
- ...props
576
- }: React.ComponentProps<'div'> & {
577
- showIcon?: boolean
578
- }) {
579
- // Random width between 50 to 90%.
580
- const [width] = React.useState(() => {
581
- return `${Math.floor(Math.random() * 40) + 50}%`
582
- })
583
-
584
- return (
585
- <div
586
- data-slot="sidebar-menu-skeleton"
587
- data-sidebar="menu-skeleton"
588
- className={cn('h-8 gap-2 rounded-md px-2 flex items-center', className)}
589
- {...props}
590
- >
591
- {showIcon && <Skeleton className="size-4 rounded-md" data-sidebar="menu-skeleton-icon" />}
592
- <Skeleton
593
- className="h-4 max-w-(--skeleton-width) flex-1"
594
- data-sidebar="menu-skeleton-text"
595
- style={
596
- {
597
- '--skeleton-width': width,
598
- } as React.CSSProperties
599
- }
600
- />
601
- </div>
602
- )
603
- }
604
-
605
571
  function SidebarMenuSub({ className, ...props }: React.ComponentProps<'ul'>) {
606
572
  return (
607
573
  <ul
@@ -675,7 +641,6 @@ export {
675
641
  SidebarMenuBadge,
676
642
  SidebarMenuButton,
677
643
  SidebarMenuItem,
678
- SidebarMenuSkeleton,
679
644
  SidebarMenuSub,
680
645
  SidebarMenuSubButton,
681
646
  SidebarMenuSubItem,
@@ -1,13 +1,36 @@
1
+ import { cva, type VariantProps } from 'class-variance-authority'
2
+
1
3
  import { cn } from '../lib/utils'
2
4
 
3
- function Skeleton({ className, ...props }: React.ComponentProps<'div'>) {
5
+ const skeletonVariants = cva('bg-muted animate-pulse', {
6
+ variants: {
7
+ variant: {
8
+ rectangle: 'rounded-md',
9
+ circle: 'rounded-full',
10
+ text: 'rounded',
11
+ },
12
+ size: {
13
+ sm: 'h-4',
14
+ md: 'h-6',
15
+ lg: 'h-8',
16
+ },
17
+ },
18
+ defaultVariants: { variant: 'rectangle' },
19
+ })
20
+
21
+ function Skeleton({
22
+ className,
23
+ variant,
24
+ size,
25
+ ...props
26
+ }: React.ComponentProps<'div'> & VariantProps<typeof skeletonVariants>) {
4
27
  return (
5
28
  <div
6
29
  data-slot="skeleton"
7
- className={cn('bg-muted rounded-md animate-pulse', className)}
30
+ className={cn(skeletonVariants({ variant, size }), className)}
8
31
  {...props}
9
32
  />
10
33
  )
11
34
  }
12
35
 
13
- export { Skeleton }
36
+ export { Skeleton, skeletonVariants }
@@ -11,14 +11,16 @@ function Slider({
11
11
  max = 100,
12
12
  ...props
13
13
  }: SliderPrimitive.Root.Props) {
14
- const _values = React.useMemo(
15
- () => (Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max]),
16
- [value, defaultValue, min, max],
17
- )
14
+ // One thumb per value; a single number (or no value) is a single thumb.
15
+ const _values = React.useMemo(() => {
16
+ const current = value ?? defaultValue
17
+ if (Array.isArray(current)) return current
18
+ return typeof current === 'number' ? [current] : [min, max]
19
+ }, [value, defaultValue, min, max])
18
20
 
19
21
  return (
20
22
  <SliderPrimitive.Root
21
- className="data-horizontal:w-full data-vertical:h-full"
23
+ className="data-horizontal:w-full data-horizontal:min-w-(--control-min-width) data-vertical:h-full"
22
24
  data-slot="slider"
23
25
  defaultValue={defaultValue}
24
26
  value={value}
@@ -35,7 +37,7 @@ function Slider({
35
37
  >
36
38
  <SliderPrimitive.Track
37
39
  data-slot="slider-track"
38
- className="bg-muted rounded-full data-horizontal:h-5 data-horizontal:w-full data-vertical:h-full data-vertical:w-5 relative overflow-hidden select-none"
40
+ className="bg-muted rounded-full data-horizontal:h-(--slider-size) data-horizontal:w-full data-vertical:h-full data-vertical:w-(--slider-size) relative overflow-hidden select-none"
39
41
  >
40
42
  <SliderPrimitive.Indicator
41
43
  data-slot="slider-range"
@@ -47,7 +49,7 @@ function Slider({
47
49
  data-slot="slider-thumb"
48
50
  key={index}
49
51
  className={cn(
50
- 'border-primary size-5 rounded-full border bg-page hover:ring-4 hover:ring-focus/30 active:ring-4 active:ring-focus/50 block shrink-0 select-none disabled:pointer-events-none disabled:opacity-disabled',
52
+ 'border-(color:--slider-thumb-border) bg-(--slider-thumb-color) size-(--slider-size) rounded-full border hover:ring-4 hover:ring-focus/30 active:ring-4 active:ring-focus/50 block shrink-0 select-none disabled:pointer-events-none disabled:opacity-disabled',
51
53
  'has-[:focus-visible]:border-[var(--focus-ring-color)] has-[:focus-visible]:ring-[color:var(--focus-ring-color)]/30 has-[:focus-visible]:ring-[length:var(--focus-ring-width)]',
52
54
  )}
53
55
  />
@@ -25,15 +25,15 @@ const Toaster = ({ ...props }: ToasterProps) => {
25
25
  unstyled: true,
26
26
  classNames: {
27
27
  toast:
28
- 'flex items-center gap-2 rounded-lg border bg-popover p-3 text-xs font-medium text-popover-foreground shadow-md w-[var(--width)]',
29
- title: 'text-xs font-medium leading-relaxed',
28
+ 'flex items-center gap-2 rounded-lg border bg-popover p-3 text-(length:--body-font-size) leading-(--body-line-height) font-medium text-popover-foreground shadow-md w-[var(--width)]',
29
+ title: 'text-(length:--body-font-size) font-medium leading-relaxed',
30
30
  description: 'text-2xs font-normal leading-relaxed text-muted-foreground',
31
31
  content: 'flex flex-col gap-0.5',
32
32
  icon: 'flex size-4 shrink-0 items-center justify-center',
33
33
  actionButton:
34
- 'ml-auto h-6 shrink-0 cursor-pointer rounded-md bg-primary px-2.5 text-xs font-medium text-primary-foreground',
34
+ 'ml-auto h-6 shrink-0 cursor-pointer rounded-md bg-primary px-2.5 text-(length:--body-font-size) leading-(--body-line-height) font-medium text-primary-foreground',
35
35
  cancelButton:
36
- 'ml-auto h-6 shrink-0 cursor-pointer rounded-md bg-muted px-2.5 text-xs font-medium text-muted-foreground',
36
+ 'ml-auto h-6 shrink-0 cursor-pointer rounded-md bg-muted px-2.5 text-(length:--body-font-size) leading-(--body-line-height) font-medium text-muted-foreground',
37
37
  success:
38
38
  'bg-surface-success border-stroke-success text-success [&_[data-icon]>svg]:text-icon-success [&_[data-title]]:text-success [&_[data-description]]:text-success/90',
39
39
  error:
@@ -1,16 +1,56 @@
1
+ import { cva, type VariantProps } from 'class-variance-authority'
1
2
  import { Loader2Icon } from 'lucide-react'
2
3
 
3
4
  import { cn } from '../lib/utils'
4
5
 
5
- function Spinner({ className, ...props }: React.ComponentProps<'svg'>) {
6
+ const spinnerVariants = cva('shrink-0', {
7
+ variants: {
8
+ variant: {
9
+ default: 'size-4 animate-spin',
10
+ // Three bouncing dots in currentColor.
11
+ dots: 'h-4 w-auto text-primary',
12
+ },
13
+ },
14
+ defaultVariants: { variant: 'default' },
15
+ })
16
+
17
+ function Spinner({
18
+ className,
19
+ variant = 'default',
20
+ ...props
21
+ }: React.ComponentProps<'svg'> & VariantProps<typeof spinnerVariants>) {
22
+ if (variant === 'dots') {
23
+ return (
24
+ <svg
25
+ role="status"
26
+ aria-label="Loading"
27
+ viewBox="0 0 60 32"
28
+ fill="currentColor"
29
+ className={cn(spinnerVariants({ variant }), className)}
30
+ {...props}
31
+ >
32
+ {[8, 30, 52].map((cx, index) => (
33
+ <circle
34
+ key={cx}
35
+ cx={cx}
36
+ cy={20}
37
+ r={7}
38
+ className="motion-safe:animate-bounce [transform-box:fill-box]"
39
+ style={{ animationDelay: `${index * 150}ms` }}
40
+ />
41
+ ))}
42
+ </svg>
43
+ )
44
+ }
45
+
6
46
  return (
7
47
  <Loader2Icon
8
48
  role="status"
9
49
  aria-label="Loading"
10
- className={cn('size-4 animate-spin', className)}
50
+ className={cn(spinnerVariants({ variant }), className)}
11
51
  {...props}
12
52
  />
13
53
  )
14
54
  }
15
55
 
16
- export { Spinner }
56
+ export { Spinner, spinnerVariants }
@@ -16,14 +16,14 @@ function Switch({
16
16
  className={cn(
17
17
  FOCUS_RING,
18
18
  HOVER_RING,
19
- 'data-checked:bg-primary data-unchecked:bg-surface-field dark:data-unchecked:bg-surface-field/80 shrink-0 rounded-[var(--radius)] p-0.5 data-[size=default]:h-4 data-[size=default]:w-7 data-[size=sm]:h-3.5 data-[size=sm]:w-6 peer group/switch relative inline-flex items-center transition-[opacity,box-shadow] outline-none after:absolute after:-inset-x-3 after:-inset-y-2 data-disabled:cursor-not-allowed data-disabled:opacity-disabled',
19
+ 'data-checked:bg-(--switch-on-color) data-unchecked:bg-surface-field dark:data-unchecked:bg-surface-field/80 shrink-0 rounded-[var(--radius)] p-0.5 data-[size=default]:h-(--switch-height) data-[size=default]:w-[calc(var(--switch-height)*2_-_var(--spacing))] data-[size=sm]:h-3.5 data-[size=sm]:w-6 peer group/switch relative inline-flex items-center transition-[opacity,box-shadow] outline-none after:absolute after:-inset-x-3 after:-inset-y-2 data-disabled:cursor-not-allowed data-disabled:opacity-disabled',
20
20
  className,
21
21
  )}
22
22
  {...props}
23
23
  >
24
24
  <SwitchPrimitive.Thumb
25
25
  data-slot="switch-thumb"
26
- className="bg-page dark:data-unchecked:bg-foreground dark:data-checked:bg-primary-foreground rounded-[var(--radius)] group-data-[size=default]/switch:size-3 group-data-[size=sm]/switch:size-2.5 group-data-[size=default]/switch:data-checked:translate-x-3 group-data-[size=sm]/switch:data-checked:translate-x-2.5 data-unchecked:translate-x-0 pointer-events-none block ring-0 transition-transform"
26
+ className="bg-page dark:data-unchecked:bg-foreground dark:data-checked:bg-primary-foreground rounded-[var(--radius)] group-data-[size=default]/switch:size-[calc(var(--switch-height)_-_var(--spacing))] group-data-[size=sm]/switch:size-2.5 group-data-[size=default]/switch:data-checked:translate-x-[calc(var(--switch-height)_-_var(--spacing))] group-data-[size=sm]/switch:data-checked:translate-x-2.5 data-unchecked:translate-x-0 pointer-events-none block ring-0 transition-transform"
27
27
  />
28
28
  </SwitchPrimitive.Root>
29
29
  )
@@ -7,7 +7,10 @@ function Table({ className, ...props }: React.ComponentProps<'table'>) {
7
7
  <div data-slot="table-container" className="relative w-full overflow-x-auto">
8
8
  <table
9
9
  data-slot="table"
10
- className={cn('w-full caption-bottom text-xs', className)}
10
+ className={cn(
11
+ 'w-full caption-bottom text-(length:--body-font-size) leading-(--body-line-height)',
12
+ className,
13
+ )}
11
14
  {...props}
12
15
  />
13
16
  </div>
@@ -15,7 +18,13 @@ function Table({ className, ...props }: React.ComponentProps<'table'>) {
15
18
  }
16
19
 
17
20
  function TableHeader({ className, ...props }: React.ComponentProps<'thead'>) {
18
- return <thead data-slot="table-header" className={cn('[&_tr]:border-b', className)} {...props} />
21
+ return (
22
+ <thead
23
+ data-slot="table-header"
24
+ className={cn('[&_tr]:border-b-(length:--rule-width)', className)}
25
+ {...props}
26
+ />
27
+ )
19
28
  }
20
29
 
21
30
  function TableBody({ className, ...props }: React.ComponentProps<'tbody'>) {
@@ -32,7 +41,10 @@ function TableFooter({ className, ...props }: React.ComponentProps<'tfoot'>) {
32
41
  return (
33
42
  <tfoot
34
43
  data-slot="table-footer"
35
- className={cn('bg-muted/50 border-t font-medium [&>tr]:last:border-b-0', className)}
44
+ className={cn(
45
+ 'bg-muted/50 border-t-(length:--rule-width) font-medium [&>tr]:last:border-b-0',
46
+ className,
47
+ )}
36
48
  {...props}
37
49
  />
38
50
  )
@@ -42,7 +54,10 @@ function TableRow({ className, ...props }: React.ComponentProps<'tr'>) {
42
54
  return (
43
55
  <tr
44
56
  data-slot="table-row"
45
- className={cn('hover:bg-muted/50 data-[state=selected]:bg-muted border-b', className)}
57
+ className={cn(
58
+ 'hover:bg-muted/50 data-[state=selected]:bg-muted border-b-(length:--rule-width)',
59
+ className,
60
+ )}
46
61
  {...props}
47
62
  />
48
63
  )
@@ -53,7 +68,7 @@ function TableHead({ className, ...props }: React.ComponentProps<'th'>) {
53
68
  <th
54
69
  data-slot="table-head"
55
70
  className={cn(
56
- 'text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0',
71
+ 'text-(color:--label-color) text-(length:--label-font-size) leading-(--text-xs--line-height) [text-transform:var(--label-text-transform)] h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0',
57
72
  className,
58
73
  )}
59
74
  {...props}
@@ -85,7 +85,10 @@ function TabsContent({ className, ...props }: TabsPrimitive.Panel.Props) {
85
85
  return (
86
86
  <TabsPrimitive.Panel
87
87
  data-slot="tabs-content"
88
- className={cn('flex-1 text-xs/relaxed outline-none', className)}
88
+ className={cn(
89
+ 'text-(length:--body-font-size) leading-relaxed flex-1 outline-none',
90
+ className,
91
+ )}
89
92
  {...props}
90
93
  />
91
94
  )
@@ -9,7 +9,7 @@ function Textarea({ className, ...props }: React.ComponentProps<'textarea'>) {
9
9
  className={cn(
10
10
  FOCUS_RING,
11
11
  HOVER_RING,
12
- 'border-field bg-surface-field/20 dark:bg-surface-field/30 resize-none rounded-(--input-radius) border px-2 py-2 text-sm md:text-xs/relaxed placeholder:text-muted-foreground flex field-sizing-content min-h-16 w-full outline-none disabled:cursor-not-allowed disabled:opacity-disabled',
12
+ 'border-field bg-surface-input resize-none rounded-(--input-radius) border px-2 py-2 text-(length:--control-font-size) max-md:text-[length:max(var(--control-font-size),var(--text-sm))] leading-relaxed placeholder:text-muted-foreground flex field-sizing-content min-h-16 w-full min-w-(--control-min-width) outline-none disabled:cursor-not-allowed disabled:opacity-disabled',
13
13
  className,
14
14
  )}
15
15
  {...props}
@@ -4,7 +4,7 @@ import { cva, type VariantProps } from 'class-variance-authority'
4
4
  import { cn, FOCUS_RING, HOVER_RING } from '../lib/utils'
5
5
 
6
6
  const toggleVariants = cva(
7
- `${FOCUS_RING} ${HOVER_RING} hover:text-foreground aria-pressed:bg-muted data-[state=on]:bg-muted gap-1 rounded-md text-xs font-medium transition-[opacity,box-shadow] [&_svg:not([class*='size-'])]:size-3.5 group/toggle inline-flex items-center justify-center whitespace-nowrap outline-none disabled:pointer-events-none disabled:opacity-disabled [&_svg]:pointer-events-none [&_svg]:shrink-0`,
7
+ `${FOCUS_RING} ${HOVER_RING} hover:text-foreground aria-pressed:bg-muted data-[state=on]:bg-muted gap-1 rounded-md text-(length:--control-font-size) leading-(--text-xs--line-height) font-medium transition-[opacity,box-shadow] [&_svg:not([class*='size-'])]:size-3.5 group/toggle inline-flex items-center justify-center whitespace-nowrap outline-none disabled:pointer-events-none disabled:opacity-disabled [&_svg]:pointer-events-none [&_svg]:shrink-0`,
8
8
  {
9
9
  variants: {
10
10
  variant: {