@glasshome/ui 1.21.0 → 1.21.2

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 (154) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +1 -1
  3. package/dist/lib/use-is-mobile.d.ts +3 -1
  4. package/dist/solid/alert-dialog.d.ts +7 -1
  5. package/dist/solid/bottom-sheet/bottom-sheet.d.ts +7 -1
  6. package/dist/solid/dialog-parts.d.ts +3 -2
  7. package/dist/solid/dialog.d.ts +7 -1
  8. package/dist/solid/docked-panel.d.ts +7 -1
  9. package/dist/solid/index.d.ts +9 -9
  10. package/dist/solid/index.js +5456 -5447
  11. package/dist/solid/media-store.d.ts +4 -1
  12. package/dist/solid/option-card.d.ts +4 -1
  13. package/dist/solid/responsive-dialog.d.ts +7 -1
  14. package/dist/solid/sheet.d.ts +7 -1
  15. package/dist/{utils-CMk7R3zM.js → utils-D5blHO4O.js} +624 -622
  16. package/package.json +128 -126
  17. package/scripts/check-gallery.ts +142 -142
  18. package/scripts/check-pack.ts +13 -13
  19. package/scripts/check-structural-classes.ts +20 -20
  20. package/scripts/check-tokens.ts +27 -27
  21. package/scripts/check-ui-drift.mjs +103 -103
  22. package/src/index.ts +75 -80
  23. package/src/lib/alert-tones.ts +41 -41
  24. package/src/lib/anchor-placement.ts +21 -21
  25. package/src/lib/button-variants.ts +28 -28
  26. package/src/lib/card-classes.ts +9 -9
  27. package/src/lib/carousel-classes.ts +14 -14
  28. package/src/lib/glass-tone.ts +11 -11
  29. package/src/lib/input-classes.ts +6 -6
  30. package/src/lib/layers.ts +4 -4
  31. package/src/lib/logo-lockup.ts +8 -8
  32. package/src/lib/menu-classes.ts +2 -2
  33. package/src/lib/motion-classes.ts +8 -8
  34. package/src/lib/motion-window.ts +24 -24
  35. package/src/lib/overlay-classes.ts +6 -6
  36. package/src/lib/pill-classes.ts +3 -3
  37. package/src/lib/position-bar-classes.ts +1 -1
  38. package/src/lib/spotlight-geometry.ts +67 -67
  39. package/src/lib/thumb-classes.ts +2 -2
  40. package/src/lib/tier-badge.ts +16 -16
  41. package/src/lib/use-is-mobile.ts +17 -14
  42. package/src/lib/utils.ts +1 -1
  43. package/src/solid/accordion.tsx +41 -41
  44. package/src/solid/alert-dialog.tsx +95 -95
  45. package/src/solid/alert.tsx +88 -88
  46. package/src/solid/area-picker.tsx +204 -204
  47. package/src/solid/aspect-ratio.tsx +13 -13
  48. package/src/solid/avatar.tsx +27 -27
  49. package/src/solid/badge.tsx +49 -49
  50. package/src/solid/bottom-sheet/arbitration.ts +22 -22
  51. package/src/solid/bottom-sheet/bottom-sheet.tsx +394 -394
  52. package/src/solid/bottom-sheet/drag-controller.ts +201 -201
  53. package/src/solid/bottom-sheet/focus-trap.ts +51 -47
  54. package/src/solid/bottom-sheet/index.ts +12 -12
  55. package/src/solid/bottom-sheet/keyboard.ts +25 -25
  56. package/src/solid/bottom-sheet/scroll-lock.ts +46 -46
  57. package/src/solid/bottom-sheet/state-machine.ts +28 -28
  58. package/src/solid/bottom-sheet/velocity.ts +29 -29
  59. package/src/solid/breadcrumb.tsx +76 -76
  60. package/src/solid/button-group.tsx +46 -46
  61. package/src/solid/button.tsx +19 -19
  62. package/src/solid/card.tsx +67 -67
  63. package/src/solid/carousel.tsx +246 -246
  64. package/src/solid/charts.tsx +253 -253
  65. package/src/solid/checkbox.tsx +51 -51
  66. package/src/solid/collapsible.tsx +22 -22
  67. package/src/solid/color-disc.tsx +213 -213
  68. package/src/solid/color-slider.tsx +81 -81
  69. package/src/solid/color-wheel.tsx +61 -61
  70. package/src/solid/context-menu.tsx +63 -63
  71. package/src/solid/copy-button.tsx +31 -31
  72. package/src/solid/count-pill.tsx +11 -11
  73. package/src/solid/dashboard-preview.tsx +104 -104
  74. package/src/solid/data-table.tsx +228 -228
  75. package/src/solid/dialog-parts.tsx +129 -129
  76. package/src/solid/dialog.tsx +113 -113
  77. package/src/solid/dock-paging.ts +9 -9
  78. package/src/solid/dock.tsx +339 -338
  79. package/src/solid/docked-panel.tsx +35 -35
  80. package/src/solid/dropdown-menu.tsx +77 -77
  81. package/src/solid/empty.tsx +70 -70
  82. package/src/solid/entity-data.ts +38 -38
  83. package/src/solid/entity-selector.tsx +634 -634
  84. package/src/solid/field.tsx +205 -205
  85. package/src/solid/form.tsx +159 -159
  86. package/src/solid/hero-action.tsx +85 -85
  87. package/src/solid/hover-card.tsx +11 -11
  88. package/src/solid/icon-picker.tsx +401 -401
  89. package/src/solid/icon.tsx +101 -78
  90. package/src/solid/image-picker.tsx +416 -414
  91. package/src/solid/index.ts +265 -304
  92. package/src/solid/input-group.tsx +123 -123
  93. package/src/solid/input-otp.tsx +143 -143
  94. package/src/solid/input.tsx +4 -4
  95. package/src/solid/item.tsx +130 -130
  96. package/src/solid/kbd.tsx +20 -20
  97. package/src/solid/label.tsx +12 -12
  98. package/src/solid/list-reorder.ts +122 -122
  99. package/src/solid/logo.tsx +60 -60
  100. package/src/solid/media-copy.ts +21 -21
  101. package/src/solid/media-store.ts +60 -57
  102. package/src/solid/media-tile.tsx +85 -85
  103. package/src/solid/menu-parts.tsx +164 -164
  104. package/src/solid/number-field.tsx +56 -56
  105. package/src/solid/option-card.tsx +168 -165
  106. package/src/solid/ornament.tsx +43 -43
  107. package/src/solid/overlay.tsx +4 -4
  108. package/src/solid/page-header.tsx +75 -75
  109. package/src/solid/pagination.tsx +80 -80
  110. package/src/solid/password-input.tsx +51 -51
  111. package/src/solid/picker-row.tsx +83 -83
  112. package/src/solid/picker-search.tsx +65 -63
  113. package/src/solid/picker-trigger.tsx +59 -57
  114. package/src/solid/popover.tsx +54 -54
  115. package/src/solid/preview-tile.tsx +67 -67
  116. package/src/solid/progress.tsx +21 -21
  117. package/src/solid/radio-group.tsx +51 -51
  118. package/src/solid/resizable.tsx +128 -128
  119. package/src/solid/responsive-dialog.tsx +134 -134
  120. package/src/solid/schema-form.tsx +746 -739
  121. package/src/solid/scope-indicator.tsx +5 -5
  122. package/src/solid/scroll-area.tsx +16 -16
  123. package/src/solid/section-card.tsx +281 -281
  124. package/src/solid/select.tsx +101 -101
  125. package/src/solid/separator.tsx +25 -25
  126. package/src/solid/settings-row.tsx +122 -122
  127. package/src/solid/sheet.tsx +96 -96
  128. package/src/solid/skeleton.tsx +8 -8
  129. package/src/solid/slider.tsx +132 -132
  130. package/src/solid/sliding-indicator.tsx +280 -265
  131. package/src/solid/sonner.tsx +164 -164
  132. package/src/solid/spinner.tsx +12 -12
  133. package/src/solid/spotlight.tsx +140 -140
  134. package/src/solid/step-indicator.tsx +18 -18
  135. package/src/solid/swatch-picker.tsx +38 -38
  136. package/src/solid/switch.tsx +52 -52
  137. package/src/solid/table.tsx +63 -63
  138. package/src/solid/tabs.tsx +93 -93
  139. package/src/solid/textarea.tsx +8 -8
  140. package/src/solid/toggle-group.tsx +83 -83
  141. package/src/solid/toggle.tsx +33 -33
  142. package/src/solid/tooltip.tsx +16 -16
  143. package/src/solid/widget-card.tsx +90 -90
  144. package/src/solid/widget-identity.tsx +99 -99
  145. package/src/solid/widget-trust-badge.tsx +20 -20
  146. package/src/styles/globals.css +316 -319
  147. package/src/styles/theme.css +448 -448
  148. package/src/tokens/hex.ts +29 -29
  149. package/src/tokens/material.ts +75 -75
  150. package/src/tokens/presets.ts +303 -303
  151. package/src/tokens/readability.ts +32 -32
  152. package/src/tokens/theme-colors.ts +95 -95
  153. package/src/tokens/theme-css.ts +22 -22
  154. package/src/tokens/theme-recipe.ts +106 -106
@@ -1,43 +1,43 @@
1
1
  export interface Box {
2
- x: number;
3
- y: number;
4
- width: number;
5
- height: number;
2
+ x: number;
3
+ y: number;
4
+ width: number;
5
+ height: number;
6
6
  }
7
7
 
8
8
  export interface Viewport {
9
- width: number;
10
- height: number;
9
+ width: number;
10
+ height: number;
11
11
  }
12
12
 
13
13
  /* Outer rect plus a rounded rect, filled even-odd. With no target the hole
14
14
  * collapses to a point at the centre, same commands, so clip-path interpolates. */
15
15
  export function holePath(
16
- viewport: Viewport,
17
- target: Box | null,
18
- pad: number,
19
- radius: number,
16
+ viewport: Viewport,
17
+ target: Box | null,
18
+ pad: number,
19
+ radius: number,
20
20
  ): string {
21
- const box = target
22
- ? {
23
- x: target.x - pad,
24
- y: target.y - pad,
25
- width: target.width + pad * 2,
26
- height: target.height + pad * 2,
27
- }
28
- : { x: viewport.width / 2, y: viewport.height / 2, width: 0, height: 0 };
29
- const r = Math.max(0, Math.min(radius, box.width / 2, box.height / 2));
30
- const left = box.x;
31
- const top = box.y;
32
- const right = box.x + box.width;
33
- const bottom = box.y + box.height;
34
- const outer = `M0 0H${viewport.width}V${viewport.height}H0Z`;
35
- const hole =
36
- `M${left + r} ${top}H${right - r}A${r} ${r} 0 0 1 ${right} ${top + r}` +
37
- `V${bottom - r}A${r} ${r} 0 0 1 ${right - r} ${bottom}` +
38
- `H${left + r}A${r} ${r} 0 0 1 ${left} ${bottom - r}` +
39
- `V${top + r}A${r} ${r} 0 0 1 ${left + r} ${top}Z`;
40
- return outer + hole;
21
+ const box = target
22
+ ? {
23
+ x: target.x - pad,
24
+ y: target.y - pad,
25
+ width: target.width + pad * 2,
26
+ height: target.height + pad * 2,
27
+ }
28
+ : { x: viewport.width / 2, y: viewport.height / 2, width: 0, height: 0 };
29
+ const r = Math.max(0, Math.min(radius, box.width / 2, box.height / 2));
30
+ const left = box.x;
31
+ const top = box.y;
32
+ const right = box.x + box.width;
33
+ const bottom = box.y + box.height;
34
+ const outer = `M0 0H${viewport.width}V${viewport.height}H0Z`;
35
+ const hole =
36
+ `M${left + r} ${top}H${right - r}A${r} ${r} 0 0 1 ${right} ${top + r}` +
37
+ `V${bottom - r}A${r} ${r} 0 0 1 ${right - r} ${bottom}` +
38
+ `H${left + r}A${r} ${r} 0 0 1 ${left} ${bottom - r}` +
39
+ `V${top + r}A${r} ${r} 0 0 1 ${left + r} ${top}Z`;
40
+ return outer + hole;
41
41
  }
42
42
 
43
43
  const clamp = (value: number, min: number, max: number) => Math.min(Math.max(value, min), max);
@@ -48,43 +48,43 @@ const PANEL_RADIUS = 20.4;
48
48
  const TAIL_MARGIN = PANEL_RADIUS + 8;
49
49
 
50
50
  export function placeBubble(
51
- viewport: Viewport,
52
- target: Box | null,
53
- bubble: { width: number; height: number },
54
- gap: number,
55
- margin: number,
51
+ viewport: Viewport,
52
+ target: Box | null,
53
+ bubble: { width: number; height: number },
54
+ gap: number,
55
+ margin: number,
56
56
  ): {
57
- x: number;
58
- y: number;
59
- side: "above" | "below" | "center" | "inside";
60
- tail: { x: number } | null;
57
+ x: number;
58
+ y: number;
59
+ side: "above" | "below" | "center" | "inside";
60
+ tail: { x: number } | null;
61
61
  } {
62
- if (!target) {
63
- return {
64
- x: (viewport.width - bubble.width) / 2,
65
- y: (viewport.height - bubble.height) / 2,
66
- side: "center",
67
- tail: null,
68
- };
69
- }
70
- const rawX = target.x + target.width / 2 - bubble.width / 2;
71
- if (target.height > viewport.height / 2) {
72
- return {
73
- x: clamp(rawX, margin, viewport.width - bubble.width - margin),
74
- y: clamp(target.y + gap, margin, viewport.height - bubble.height - margin),
75
- side: "inside",
76
- tail: null,
77
- };
78
- }
79
- const centreY = target.y + target.height / 2;
80
- const side = centreY > viewport.height / 2 ? "above" : "below";
81
- const rawY = side === "above" ? target.y - gap - bubble.height : target.y + target.height + gap;
82
- const x = clamp(rawX, margin, viewport.width - bubble.width - margin);
83
- const anchorCentre = target.x + target.width / 2;
84
- return {
85
- x,
86
- y: clamp(rawY, margin, viewport.height - bubble.height - margin),
87
- side,
88
- tail: { x: clamp(anchorCentre - x, TAIL_MARGIN, bubble.width - TAIL_MARGIN) },
89
- };
62
+ if (!target) {
63
+ return {
64
+ x: (viewport.width - bubble.width) / 2,
65
+ y: (viewport.height - bubble.height) / 2,
66
+ side: "center",
67
+ tail: null,
68
+ };
69
+ }
70
+ const rawX = target.x + target.width / 2 - bubble.width / 2;
71
+ if (target.height > viewport.height / 2) {
72
+ return {
73
+ x: clamp(rawX, margin, viewport.width - bubble.width - margin),
74
+ y: clamp(target.y + gap, margin, viewport.height - bubble.height - margin),
75
+ side: "inside",
76
+ tail: null,
77
+ };
78
+ }
79
+ const centreY = target.y + target.height / 2;
80
+ const side = centreY > viewport.height / 2 ? "above" : "below";
81
+ const rawY = side === "above" ? target.y - gap - bubble.height : target.y + target.height + gap;
82
+ const x = clamp(rawX, margin, viewport.width - bubble.width - margin);
83
+ const anchorCentre = target.x + target.width / 2;
84
+ return {
85
+ x,
86
+ y: clamp(rawY, margin, viewport.height - bubble.height - margin),
87
+ side,
88
+ tail: { x: clamp(anchorCentre - x, TAIL_MARGIN, bubble.width - TAIL_MARGIN) },
89
+ };
90
90
  }
@@ -9,14 +9,14 @@ export const THUMB_SIZE = 31;
9
9
  * focus ring is not part of it: on a slider the thumb takes focus, on a switch
10
10
  * the track does. */
11
11
  export const THUMB_CLASS =
12
- "block size-7 shrink-0 rounded-xl shadow-[0_2px_5px_oklch(0_0_0/0.35),inset_0_1px_0_oklch(1_0_0/0.35),inset_0_-2px_3px_oklch(0_0_0/0.2)]";
12
+ "block size-7 shrink-0 rounded-xl shadow-[0_2px_5px_oklch(0_0_0/0.35),inset_0_1px_0_oklch(1_0_0/0.35),inset_0_-2px_3px_oklch(0_0_0/0.2)]";
13
13
 
14
14
  /* The lit knob wears the theme's hue at the depth theme.css sets per mode. The
15
15
  * knob re-declares --thumb-face-on on itself with this value: a var() resolves
16
16
  * where it is declared, so the :root one answers for the page only and a
17
17
  * container that re-scopes --primary (a theme preview) would keep the page's. */
18
18
  export const THUMB_FACE_ON =
19
- "oklch(from var(--primary) var(--thumb-on-l) min(c, var(--thumb-on-c)) h)";
19
+ "oklch(from var(--primary) var(--thumb-on-l) min(c, var(--thumb-on-c)) h)";
20
20
 
21
21
  /* A rail pads by half a thumb so the knob stays inside the track at both ends;
22
22
  * the fill cancels the same inset to reach the rounded edges. */
@@ -1,31 +1,31 @@
1
1
  /* Metallic tier chip: 135deg brushed sweep, bright ends, dip in the middle. */
2
2
 
3
3
  export const TIER_BADGE_CLASS =
4
- "inline-flex cursor-default select-none items-center rounded-lg px-2 py-0.5 font-black text-[10px] tracking-wide";
4
+ "inline-flex cursor-default select-none items-center rounded-lg px-2 py-0.5 font-black text-[10px] tracking-wide";
5
5
 
6
6
  /** Optional sweep shaping. Default is the symmetric brushed look (both ends
7
7
  * `hi`, dipping to `lo` at the midpoint). The collectible/license golds are a
8
8
  * lit bevel instead: they dip early and land on a darker `end`. */
9
9
  export interface TierSweep {
10
- /** Far end of the sweep. Default: `hi` (symmetric). */
11
- end?: string;
12
- /** Where `lo` sits, in percent. Default: 50. */
13
- stop?: number;
10
+ /** Far end of the sweep. Default: `hi` (symmetric). */
11
+ end?: string;
12
+ /** Where `lo` sits, in percent. Default: 50. */
13
+ stop?: number;
14
14
  }
15
15
 
16
16
  /** Inline style for the metallic pill body. Keys are CSS property names (works
17
17
  * as a Solid `style` object and, joined, as an Astro `style` string). */
18
18
  export function tierBadgeStyle(
19
- hi: string,
20
- lo: string,
21
- text: string,
22
- sweep: TierSweep = {},
19
+ hi: string,
20
+ lo: string,
21
+ text: string,
22
+ sweep: TierSweep = {},
23
23
  ): Record<string, string> {
24
- const end = sweep.end ?? hi;
25
- const stop = sweep.stop ?? 50;
26
- return {
27
- background: `linear-gradient(135deg, ${hi}, ${lo} ${stop}%, ${end})`,
28
- color: text,
29
- "box-shadow": "inset 0 1px 0 oklch(1 0 0 / 0.45), 0 1px 2px oklch(0 0 0 / 0.25)",
30
- };
24
+ const end = sweep.end ?? hi;
25
+ const stop = sweep.stop ?? 50;
26
+ return {
27
+ background: `linear-gradient(135deg, ${hi}, ${lo} ${stop}%, ${end})`,
28
+ color: text,
29
+ "box-shadow": "inset 0 1px 0 oklch(1 0 0 / 0.45), 0 1px 2px oklch(0 0 0 / 0.25)",
30
+ };
31
31
  }
@@ -1,21 +1,24 @@
1
- import { createSignal, onCleanup, onMount } from "solid-js";
1
+ import { type Accessor, createSignal } from "solid-js";
2
2
 
3
3
  /* Tailwind's `sm` edge, so the JS branch (dialog → bottom sheet, picker →
4
4
  * sheet, toast position) flips where the `sm:` utilities flip. */
5
5
  export const MOBILE_BREAKPOINT = 640;
6
6
 
7
- export function createIsMobile(breakpoint: number = MOBILE_BREAKPOINT) {
8
- const [isMobile, setIsMobile] = createSignal<boolean | undefined>(
9
- typeof window !== "undefined" ? window.innerWidth < breakpoint : undefined,
10
- );
7
+ const shared = new Map<number, Accessor<boolean>>();
11
8
 
12
- onMount(() => {
13
- const mql = window.matchMedia(`(max-width: ${breakpoint - 1}px)`);
14
- const onChange = () => setIsMobile(window.innerWidth < breakpoint);
15
- mql.addEventListener("change", onChange);
16
- setIsMobile(window.innerWidth < breakpoint);
17
- onCleanup(() => mql.removeEventListener("change", onChange));
18
- });
19
-
20
- return isMobile;
9
+ /** One reading and one listener per breakpoint for the page: a width read can force layout, so thirty dialogs mounting read it once. */
10
+ export function createIsMobile(
11
+ breakpoint: number = MOBILE_BREAKPOINT,
12
+ ): Accessor<boolean | undefined> {
13
+ if (typeof window === "undefined") return () => undefined;
14
+ let isMobile = shared.get(breakpoint);
15
+ if (!isMobile) {
16
+ const [value, setValue] = createSignal(window.innerWidth < breakpoint);
17
+ window
18
+ .matchMedia?.(`(max-width: ${breakpoint - 1}px)`)
19
+ .addEventListener("change", () => setValue(window.innerWidth < breakpoint));
20
+ isMobile = value;
21
+ shared.set(breakpoint, isMobile);
22
+ }
23
+ return isMobile;
21
24
  }
package/src/lib/utils.ts CHANGED
@@ -2,5 +2,5 @@ import { type ClassValue, clsx } from "clsx";
2
2
  import { twMerge } from "tailwind-merge";
3
3
 
4
4
  export function cn(...inputs: ClassValue[]) {
5
- return twMerge(clsx(inputs));
5
+ return twMerge(clsx(inputs));
6
6
  }
@@ -6,55 +6,55 @@ import { Icon } from "./icon.js";
6
6
  const Accordion = AccordionPrimitive;
7
7
 
8
8
  const AccordionItem: Component<ComponentProps<typeof AccordionPrimitive.Item>> = (props) => {
9
- const [local, rest] = splitProps(props, ["class"]);
10
- return (
11
- <AccordionPrimitive.Item
12
- data-slot="accordion-item"
13
- class={cn("border-b last:border-b-0", local.class)}
14
- {...rest}
15
- />
16
- );
9
+ const [local, rest] = splitProps(props, ["class"]);
10
+ return (
11
+ <AccordionPrimitive.Item
12
+ data-slot="accordion-item"
13
+ class={cn("border-b last:border-b-0", local.class)}
14
+ {...rest}
15
+ />
16
+ );
17
17
  };
18
18
 
19
19
  const AccordionTrigger: ParentComponent<ComponentProps<typeof AccordionPrimitive.Trigger>> = (
20
- props,
20
+ props,
21
21
  ) => {
22
- const [local, rest] = splitProps(props, ["class", "children"]);
23
- return (
24
- <AccordionPrimitive.Header class="flex">
25
- <AccordionPrimitive.Trigger
26
- data-slot="accordion-trigger"
27
- class={cn(
28
- "flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left font-medium text-sm outline-none transition-all hover:underline focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 [&[data-expanded]>[data-slot=icon]]:rotate-180",
29
- local.class,
30
- )}
31
- {...rest}
32
- >
33
- {local.children}
34
- <Icon
35
- icon="lucide:chevron-down"
36
- width={16}
37
- height={16}
38
- class="pointer-events-none size-4 shrink-0 translate-y-0.5 text-muted-foreground transition-transform duration-200"
39
- />
40
- </AccordionPrimitive.Trigger>
41
- </AccordionPrimitive.Header>
42
- );
22
+ const [local, rest] = splitProps(props, ["class", "children"]);
23
+ return (
24
+ <AccordionPrimitive.Header class="flex">
25
+ <AccordionPrimitive.Trigger
26
+ data-slot="accordion-trigger"
27
+ class={cn(
28
+ "focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-expanded]>[data-slot=icon]]:rotate-180",
29
+ local.class,
30
+ )}
31
+ {...rest}
32
+ >
33
+ {local.children}
34
+ <Icon
35
+ icon="lucide:chevron-down"
36
+ width={16}
37
+ height={16}
38
+ class="text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200"
39
+ />
40
+ </AccordionPrimitive.Trigger>
41
+ </AccordionPrimitive.Header>
42
+ );
43
43
  };
44
44
 
45
45
  const AccordionContent: ParentComponent<ComponentProps<typeof AccordionPrimitive.Content>> = (
46
- props,
46
+ props,
47
47
  ) => {
48
- const [local, rest] = splitProps(props, ["class", "children"]);
49
- return (
50
- <AccordionPrimitive.Content
51
- data-slot="accordion-content"
52
- class="overflow-hidden text-sm data-[closed]:animate-accordion-up data-[expanded]:animate-accordion-down"
53
- {...rest}
54
- >
55
- <div class={cn("pt-0 pb-4", local.class)}>{local.children}</div>
56
- </AccordionPrimitive.Content>
57
- );
48
+ const [local, rest] = splitProps(props, ["class", "children"]);
49
+ return (
50
+ <AccordionPrimitive.Content
51
+ data-slot="accordion-content"
52
+ class="data-[closed]:animate-accordion-up data-[expanded]:animate-accordion-down overflow-hidden text-sm"
53
+ {...rest}
54
+ >
55
+ <div class={cn("pt-0 pb-4", local.class)}>{local.children}</div>
56
+ </AccordionPrimitive.Content>
57
+ );
58
58
  };
59
59
 
60
60
  export { Accordion, AccordionContent, AccordionItem, AccordionTrigger };
@@ -5,103 +5,103 @@ import { type Component, type ComponentProps, type ParentComponent, splitProps }
5
5
  import { buttonVariants } from "../lib/button-variants.js";
6
6
  import { cn } from "../lib/utils.js";
7
7
  import {
8
- createModalDismiss,
9
- createModalParts,
10
- MODAL_ANCHOR,
11
- MODAL_DESCRIPTION,
12
- MODAL_PANEL,
13
- MODAL_SCRIM,
14
- MODAL_TITLE,
15
- MODAL_WIDTH,
16
- type ModalDismissProps,
17
- ModalScrollLock,
18
- type ModalSize,
8
+ createModalDismiss,
9
+ createModalParts,
10
+ MODAL_ANCHOR,
11
+ MODAL_DESCRIPTION,
12
+ MODAL_PANEL,
13
+ MODAL_SCRIM,
14
+ MODAL_TITLE,
15
+ MODAL_WIDTH,
16
+ type ModalDismissProps,
17
+ ModalScrollLock,
18
+ type ModalSize,
19
19
  } from "./dialog-parts.js";
20
20
 
21
21
  const AlertDialog: ParentComponent<ComponentProps<typeof AlertDialogPrimitive>> = (props) => (
22
- <AlertDialogPrimitive {...props} preventScroll={false} />
22
+ <AlertDialogPrimitive {...props} preventScroll={false} />
23
23
  );
24
24
 
25
25
  const AlertDialogTrigger: Component<ComponentProps<typeof AlertDialogPrimitive.Trigger>> = (
26
- props,
26
+ props,
27
27
  ) => <AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />;
28
28
 
29
29
  const AlertDialogOverlay: Component<ComponentProps<typeof AlertDialogPrimitive.Overlay>> = (
30
- props,
30
+ props,
31
31
  ) => {
32
- const [local, rest] = splitProps(props, ["class"]);
33
- return (
34
- <AlertDialogPrimitive.Overlay
35
- data-slot="alert-dialog-overlay"
36
- class={cn(MODAL_SCRIM, local.class)}
37
- {...rest}
38
- />
39
- );
32
+ const [local, rest] = splitProps(props, ["class"]);
33
+ return (
34
+ <AlertDialogPrimitive.Overlay
35
+ data-slot="alert-dialog-overlay"
36
+ class={cn(MODAL_SCRIM, local.class)}
37
+ {...rest}
38
+ />
39
+ );
40
40
  };
41
41
 
42
42
  type AlertDialogContentProps = ComponentProps<typeof AlertDialogPrimitive.Content> & {
43
- size?: ModalSize;
44
- /** Names a panel that has no `AlertDialogTitle`. A registered Title wins. */
45
- ariaLabel?: string;
43
+ size?: ModalSize;
44
+ /** Names a panel that has no `AlertDialogTitle`. A registered Title wins. */
45
+ ariaLabel?: string;
46
46
  };
47
47
 
48
48
  const AlertDialogContent: ParentComponent<AlertDialogContentProps> = (props) => {
49
- const [local, rest] = splitProps(props, ["class", "children", "size", "ariaLabel"]);
50
- const context = useDialogContext();
51
- return (
52
- <AlertDialogPrimitive.Portal>
53
- <ModalScrollLock />
54
- <AlertDialogOverlay />
55
- <AlertDialogPrimitive.Content
56
- data-slot="alert-dialog-content"
57
- role="alertdialog"
58
- aria-label={context.titleId() ? undefined : local.ariaLabel}
59
- class={cn(
60
- MODAL_PANEL,
61
- MODAL_WIDTH[local.size ?? "md"],
62
- MODAL_ANCHOR[local.size ?? "md"],
63
- local.class,
64
- )}
65
- {...rest}
66
- >
67
- {local.children}
68
- </AlertDialogPrimitive.Content>
69
- </AlertDialogPrimitive.Portal>
70
- );
49
+ const [local, rest] = splitProps(props, ["class", "children", "size", "ariaLabel"]);
50
+ const context = useDialogContext();
51
+ return (
52
+ <AlertDialogPrimitive.Portal>
53
+ <ModalScrollLock />
54
+ <AlertDialogOverlay />
55
+ <AlertDialogPrimitive.Content
56
+ data-slot="alert-dialog-content"
57
+ role="alertdialog"
58
+ aria-label={context.titleId() ? undefined : local.ariaLabel}
59
+ class={cn(
60
+ MODAL_PANEL,
61
+ MODAL_WIDTH[local.size ?? "md"],
62
+ MODAL_ANCHOR[local.size ?? "md"],
63
+ local.class,
64
+ )}
65
+ {...rest}
66
+ >
67
+ {local.children}
68
+ </AlertDialogPrimitive.Content>
69
+ </AlertDialogPrimitive.Portal>
70
+ );
71
71
  };
72
72
 
73
73
  const {
74
- Header: AlertDialogHeader,
75
- Body: AlertDialogBody,
76
- Footer: AlertDialogFooter,
74
+ Header: AlertDialogHeader,
75
+ Body: AlertDialogBody,
76
+ Footer: AlertDialogFooter,
77
77
  } = createModalParts("alert-dialog");
78
78
 
79
79
  const AlertDialogTitle: Component<ComponentProps<typeof AlertDialogPrimitive.Title>> = (props) => {
80
- const [local, rest] = splitProps(props, ["class"]);
81
- return (
82
- <AlertDialogPrimitive.Title
83
- data-slot="alert-dialog-title"
84
- class={cn(MODAL_TITLE, local.class)}
85
- {...rest}
86
- />
87
- );
80
+ const [local, rest] = splitProps(props, ["class"]);
81
+ return (
82
+ <AlertDialogPrimitive.Title
83
+ data-slot="alert-dialog-title"
84
+ class={cn(MODAL_TITLE, local.class)}
85
+ {...rest}
86
+ />
87
+ );
88
88
  };
89
89
 
90
90
  const AlertDialogDescription: Component<ComponentProps<typeof AlertDialogPrimitive.Description>> = (
91
- props,
91
+ props,
92
92
  ) => {
93
- const [local, rest] = splitProps(props, ["class"]);
94
- return (
95
- <AlertDialogPrimitive.Description
96
- data-slot="alert-dialog-description"
97
- class={cn(MODAL_DESCRIPTION, local.class)}
98
- {...rest}
99
- />
100
- );
93
+ const [local, rest] = splitProps(props, ["class"]);
94
+ return (
95
+ <AlertDialogPrimitive.Description
96
+ data-slot="alert-dialog-description"
97
+ class={cn(MODAL_DESCRIPTION, local.class)}
98
+ {...rest}
99
+ />
100
+ );
101
101
  };
102
102
 
103
103
  type AlertDialogButtonProps = ModalDismissProps &
104
- Partial<Pick<VariantProps<typeof buttonVariants>, "variant" | "size">>;
104
+ Partial<Pick<VariantProps<typeof buttonVariants>, "variant" | "size">>;
105
105
 
106
106
  const ActionDismiss = createModalDismiss("alert-dialog-action");
107
107
  const CancelDismiss = createModalDismiss("alert-dialog-cancel");
@@ -111,38 +111,38 @@ const CancelDismiss = createModalDismiss("alert-dialog-cancel");
111
111
  * carry tone as arbitrary custom properties that tailwind-merge keeps side by
112
112
  * side, leaving the later stylesheet rule to win. */
113
113
  const AlertDialogAction: ParentComponent<AlertDialogButtonProps> = (props) => {
114
- const [local, rest] = splitProps(props, ["class", "variant", "size"] as const);
115
- return (
116
- <ActionDismiss
117
- class={cn(buttonVariants({ variant: local.variant, size: local.size }), local.class)}
118
- {...rest}
119
- />
120
- );
114
+ const [local, rest] = splitProps(props, ["class", "variant", "size"] as const);
115
+ return (
116
+ <ActionDismiss
117
+ class={cn(buttonVariants({ variant: local.variant, size: local.size }), local.class)}
118
+ {...rest}
119
+ />
120
+ );
121
121
  };
122
122
 
123
123
  /** This family's Close: the outline button that dismisses without acting. */
124
124
  const AlertDialogCancel: ParentComponent<AlertDialogButtonProps> = (props) => {
125
- const [local, rest] = splitProps(props, ["class", "variant", "size"] as const);
126
- return (
127
- <CancelDismiss
128
- class={cn(
129
- buttonVariants({ variant: local.variant ?? "outline", size: local.size }),
130
- local.class,
131
- )}
132
- {...rest}
133
- />
134
- );
125
+ const [local, rest] = splitProps(props, ["class", "variant", "size"] as const);
126
+ return (
127
+ <CancelDismiss
128
+ class={cn(
129
+ buttonVariants({ variant: local.variant ?? "outline", size: local.size }),
130
+ local.class,
131
+ )}
132
+ {...rest}
133
+ />
134
+ );
135
135
  };
136
136
 
137
137
  export {
138
- AlertDialog,
139
- AlertDialogAction,
140
- AlertDialogBody,
141
- AlertDialogCancel,
142
- AlertDialogContent,
143
- AlertDialogDescription,
144
- AlertDialogFooter,
145
- AlertDialogHeader,
146
- AlertDialogTitle,
147
- AlertDialogTrigger,
138
+ AlertDialog,
139
+ AlertDialogAction,
140
+ AlertDialogBody,
141
+ AlertDialogCancel,
142
+ AlertDialogContent,
143
+ AlertDialogDescription,
144
+ AlertDialogFooter,
145
+ AlertDialogHeader,
146
+ AlertDialogTitle,
147
+ AlertDialogTrigger,
148
148
  };