@glasshome/ui 1.21.1 → 1.22.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.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/use-is-mobile.d.ts +3 -1
- package/dist/solid/index.d.ts +9 -9
- package/dist/solid/index.js +5431 -5424
- package/dist/solid/sonner.d.ts +1 -0
- package/dist/{utils-CMk7R3zM.js → utils-D5blHO4O.js} +624 -622
- package/package.json +128 -126
- package/scripts/check-gallery.ts +142 -142
- package/scripts/check-pack.ts +13 -13
- package/scripts/check-structural-classes.ts +20 -20
- package/scripts/check-tokens.ts +27 -27
- package/scripts/check-ui-drift.mjs +103 -103
- package/src/index.ts +75 -80
- package/src/lib/alert-tones.ts +41 -41
- package/src/lib/anchor-placement.ts +21 -21
- package/src/lib/button-variants.ts +28 -28
- package/src/lib/card-classes.ts +9 -9
- package/src/lib/carousel-classes.ts +14 -14
- package/src/lib/glass-tone.ts +11 -11
- package/src/lib/input-classes.ts +6 -6
- package/src/lib/layers.ts +4 -4
- package/src/lib/logo-lockup.ts +8 -8
- package/src/lib/menu-classes.ts +2 -2
- package/src/lib/motion-classes.ts +8 -8
- package/src/lib/motion-window.ts +24 -24
- package/src/lib/overlay-classes.ts +6 -6
- package/src/lib/pill-classes.ts +3 -3
- package/src/lib/position-bar-classes.ts +1 -1
- package/src/lib/spotlight-geometry.ts +67 -67
- package/src/lib/thumb-classes.ts +2 -2
- package/src/lib/tier-badge.ts +16 -16
- package/src/lib/use-is-mobile.ts +17 -14
- package/src/lib/utils.ts +1 -1
- package/src/solid/accordion.tsx +41 -41
- package/src/solid/alert-dialog.tsx +95 -95
- package/src/solid/alert.tsx +88 -88
- package/src/solid/area-picker.tsx +204 -204
- package/src/solid/aspect-ratio.tsx +13 -13
- package/src/solid/avatar.tsx +27 -27
- package/src/solid/badge.tsx +49 -49
- package/src/solid/bottom-sheet/arbitration.ts +22 -22
- package/src/solid/bottom-sheet/bottom-sheet.tsx +394 -394
- package/src/solid/bottom-sheet/drag-controller.ts +201 -201
- package/src/solid/bottom-sheet/focus-trap.ts +51 -47
- package/src/solid/bottom-sheet/index.ts +12 -12
- package/src/solid/bottom-sheet/keyboard.ts +25 -25
- package/src/solid/bottom-sheet/scroll-lock.ts +46 -46
- package/src/solid/bottom-sheet/state-machine.ts +28 -28
- package/src/solid/bottom-sheet/velocity.ts +29 -29
- package/src/solid/breadcrumb.tsx +76 -76
- package/src/solid/button-group.tsx +46 -46
- package/src/solid/button.tsx +19 -19
- package/src/solid/card.tsx +67 -67
- package/src/solid/carousel.tsx +246 -246
- package/src/solid/charts.tsx +253 -253
- package/src/solid/checkbox.tsx +51 -51
- package/src/solid/collapsible.tsx +22 -22
- package/src/solid/color-disc.tsx +213 -213
- package/src/solid/color-slider.tsx +81 -81
- package/src/solid/color-wheel.tsx +61 -61
- package/src/solid/context-menu.tsx +63 -63
- package/src/solid/copy-button.tsx +31 -31
- package/src/solid/count-pill.tsx +11 -11
- package/src/solid/dashboard-preview.tsx +104 -104
- package/src/solid/data-table.tsx +228 -228
- package/src/solid/dialog-parts.tsx +127 -127
- package/src/solid/dialog.tsx +113 -113
- package/src/solid/dock-paging.ts +9 -9
- package/src/solid/dock.tsx +339 -339
- package/src/solid/docked-panel.tsx +35 -35
- package/src/solid/dropdown-menu.tsx +77 -77
- package/src/solid/empty.tsx +70 -70
- package/src/solid/entity-data.ts +38 -38
- package/src/solid/entity-selector.tsx +634 -634
- package/src/solid/field.tsx +205 -205
- package/src/solid/form.tsx +159 -159
- package/src/solid/hero-action.tsx +85 -85
- package/src/solid/hover-card.tsx +11 -11
- package/src/solid/icon-picker.tsx +401 -401
- package/src/solid/icon.tsx +101 -78
- package/src/solid/image-picker.tsx +416 -414
- package/src/solid/index.ts +265 -304
- package/src/solid/input-group.tsx +123 -123
- package/src/solid/input-otp.tsx +143 -143
- package/src/solid/input.tsx +4 -4
- package/src/solid/item.tsx +130 -130
- package/src/solid/kbd.tsx +20 -20
- package/src/solid/label.tsx +12 -12
- package/src/solid/list-reorder.ts +122 -122
- package/src/solid/logo.tsx +60 -60
- package/src/solid/media-copy.ts +21 -21
- package/src/solid/media-store.ts +56 -56
- package/src/solid/media-tile.tsx +85 -85
- package/src/solid/menu-parts.tsx +164 -164
- package/src/solid/number-field.tsx +56 -56
- package/src/solid/option-card.tsx +164 -164
- package/src/solid/ornament.tsx +43 -43
- package/src/solid/overlay.tsx +4 -4
- package/src/solid/page-header.tsx +75 -75
- package/src/solid/pagination.tsx +80 -80
- package/src/solid/password-input.tsx +51 -51
- package/src/solid/picker-row.tsx +83 -83
- package/src/solid/picker-search.tsx +65 -63
- package/src/solid/picker-trigger.tsx +59 -57
- package/src/solid/popover.tsx +54 -54
- package/src/solid/preview-tile.tsx +67 -67
- package/src/solid/progress.tsx +21 -21
- package/src/solid/radio-group.tsx +51 -51
- package/src/solid/resizable.tsx +128 -128
- package/src/solid/responsive-dialog.tsx +134 -134
- package/src/solid/schema-form.tsx +743 -743
- package/src/solid/scope-indicator.tsx +5 -5
- package/src/solid/scroll-area.tsx +16 -16
- package/src/solid/section-card.tsx +281 -281
- package/src/solid/select.tsx +101 -101
- package/src/solid/separator.tsx +25 -25
- package/src/solid/settings-row.tsx +122 -122
- package/src/solid/sheet.tsx +96 -96
- package/src/solid/skeleton.tsx +8 -8
- package/src/solid/slider.tsx +132 -132
- package/src/solid/sliding-indicator.tsx +280 -265
- package/src/solid/sonner.tsx +165 -164
- package/src/solid/spinner.tsx +12 -12
- package/src/solid/spotlight.tsx +140 -140
- package/src/solid/step-indicator.tsx +18 -18
- package/src/solid/swatch-picker.tsx +38 -38
- package/src/solid/switch.tsx +52 -52
- package/src/solid/table.tsx +63 -63
- package/src/solid/tabs.tsx +93 -93
- package/src/solid/textarea.tsx +8 -8
- package/src/solid/toggle-group.tsx +83 -83
- package/src/solid/toggle.tsx +33 -33
- package/src/solid/tooltip.tsx +16 -16
- package/src/solid/widget-card.tsx +90 -90
- package/src/solid/widget-identity.tsx +99 -99
- package/src/solid/widget-trust-badge.tsx +20 -20
- package/src/styles/globals.css +316 -319
- package/src/styles/theme.css +448 -448
- package/src/tokens/hex.ts +29 -29
- package/src/tokens/material.ts +75 -75
- package/src/tokens/presets.ts +303 -303
- package/src/tokens/readability.ts +32 -32
- package/src/tokens/theme-colors.ts +95 -95
- package/src/tokens/theme-css.ts +22 -22
- package/src/tokens/theme-recipe.ts +106 -106
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
export interface Box {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export interface Viewport {
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
viewport: Viewport,
|
|
17
|
+
target: Box | null,
|
|
18
|
+
pad: number,
|
|
19
|
+
radius: number,
|
|
20
20
|
): string {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
viewport: Viewport,
|
|
52
|
+
target: Box | null,
|
|
53
|
+
bubble: { width: number; height: number },
|
|
54
|
+
gap: number,
|
|
55
|
+
margin: number,
|
|
56
56
|
): {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
x: number;
|
|
58
|
+
y: number;
|
|
59
|
+
side: "above" | "below" | "center" | "inside";
|
|
60
|
+
tail: { x: number } | null;
|
|
61
61
|
} {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
}
|
package/src/lib/thumb-classes.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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. */
|
package/src/lib/tier-badge.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
hi: string,
|
|
20
|
+
lo: string,
|
|
21
|
+
text: string,
|
|
22
|
+
sweep: TierSweep = {},
|
|
23
23
|
): Record<string, string> {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
}
|
package/src/lib/use-is-mobile.ts
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
package/src/solid/accordion.tsx
CHANGED
|
@@ -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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
20
|
+
props,
|
|
21
21
|
) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
46
|
+
props,
|
|
47
47
|
) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
22
|
+
<AlertDialogPrimitive {...props} preventScroll={false} />
|
|
23
23
|
);
|
|
24
24
|
|
|
25
25
|
const AlertDialogTrigger: Component<ComponentProps<typeof AlertDialogPrimitive.Trigger>> = (
|
|
26
|
-
|
|
26
|
+
props,
|
|
27
27
|
) => <AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />;
|
|
28
28
|
|
|
29
29
|
const AlertDialogOverlay: Component<ComponentProps<typeof AlertDialogPrimitive.Overlay>> = (
|
|
30
|
-
|
|
30
|
+
props,
|
|
31
31
|
) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
91
|
+
props,
|
|
92
92
|
) => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
138
|
+
AlertDialog,
|
|
139
|
+
AlertDialogAction,
|
|
140
|
+
AlertDialogBody,
|
|
141
|
+
AlertDialogCancel,
|
|
142
|
+
AlertDialogContent,
|
|
143
|
+
AlertDialogDescription,
|
|
144
|
+
AlertDialogFooter,
|
|
145
|
+
AlertDialogHeader,
|
|
146
|
+
AlertDialogTitle,
|
|
147
|
+
AlertDialogTrigger,
|
|
148
148
|
};
|