@krizaka/ui 2.0.0-beta.1 → 2.0.0-beta.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.
- package/README.md +14 -3
- package/dist/button-G5qY4qSY.d.ts +68 -0
- package/dist/card.js +1 -1
- package/dist/checkbox.d.ts +52 -0
- package/dist/checkbox.js +42 -0
- package/dist/checkbox.js.map +1 -0
- package/dist/chip.d.ts +97 -0
- package/dist/chip.js +93 -0
- package/dist/chip.js.map +1 -0
- package/dist/{chunk-RLOXWF2G.js → chunk-5AXLA4LK.js} +1 -1
- package/dist/chunk-5AXLA4LK.js.map +1 -0
- package/dist/chunk-5FRYKFTO.js +121 -0
- package/dist/chunk-5FRYKFTO.js.map +1 -0
- package/dist/{chunk-CPMZS4XA.js → chunk-FJDSLNXK.js} +1 -1
- package/dist/chunk-FJDSLNXK.js.map +1 -0
- package/dist/cn.d.ts +3 -0
- package/dist/cn.js +1 -1
- package/dist/command.d.ts +156 -0
- package/dist/command.js +111 -0
- package/dist/command.js.map +1 -0
- package/dist/confirm-button.d.ts +23 -0
- package/dist/confirm-button.js +85 -0
- package/dist/confirm-button.js.map +1 -0
- package/dist/dialog-DGBY2grk.d.ts +147 -0
- package/dist/dialog.d.ts +4 -131
- package/dist/dialog.js +26 -90
- package/dist/dialog.js.map +1 -1
- package/dist/dropdown-menu.js +1 -1
- package/dist/field.js +1 -1
- package/dist/motion.css +7 -1
- package/dist/popover.js +1 -1
- package/dist/progress.d.ts +87 -0
- package/dist/progress.js +85 -0
- package/dist/progress.js.map +1 -0
- package/dist/radio-group.d.ts +77 -0
- package/dist/radio-group.js +48 -0
- package/dist/radio-group.js.map +1 -0
- package/dist/slider.d.ts +88 -0
- package/dist/slider.js +82 -0
- package/dist/slider.js.map +1 -0
- package/dist/switch.d.ts +72 -0
- package/dist/switch.js +38 -0
- package/dist/switch.js.map +1 -0
- package/dist/tabs.d.ts +83 -0
- package/dist/tabs.js +60 -0
- package/dist/tabs.js.map +1 -0
- package/dist/theme.d.ts +2 -59
- package/dist/toast.js +1 -1
- package/dist/tooltip.js +1 -1
- package/package.json +134 -5
- package/dist/chunk-CPMZS4XA.js.map +0 -1
- package/dist/chunk-RLOXWF2G.js.map +0 -1
package/dist/dialog.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
export { a as Dialog, b as DialogBody, c as DialogContent, D as DialogContentProps, d as DialogDescription, e as DialogFooter, f as DialogHeader, g as DialogTitle, h as DialogVariants, S as Sheet, i as SheetProps, j as dialog } from './dialog-DGBY2grk.js';
|
|
3
|
+
import 'tailwind-variants';
|
|
4
|
+
import 'radix-ui';
|
|
5
5
|
|
|
6
6
|
type AlertDialogProps = {
|
|
7
7
|
open?: boolean;
|
|
@@ -25,131 +25,4 @@ type AlertDialogProps = {
|
|
|
25
25
|
};
|
|
26
26
|
declare function AlertDialog({ open: openProp, defaultOpen, onOpenChange, trigger, title, description, children, confirmLabel, cancelLabel, tone, onConfirm, container, className, }: AlertDialogProps): React.JSX.Element;
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
placement: {
|
|
30
|
-
center: {
|
|
31
|
-
content: string;
|
|
32
|
-
};
|
|
33
|
-
bottom: {
|
|
34
|
-
content: string;
|
|
35
|
-
};
|
|
36
|
-
right: {
|
|
37
|
-
content: string;
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
size: {
|
|
41
|
-
sm: {
|
|
42
|
-
content: string;
|
|
43
|
-
};
|
|
44
|
-
md: {
|
|
45
|
-
content: string;
|
|
46
|
-
};
|
|
47
|
-
lg: {
|
|
48
|
-
content: string;
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
}, {
|
|
52
|
-
overlay: string;
|
|
53
|
-
content: string;
|
|
54
|
-
close: string;
|
|
55
|
-
header: string;
|
|
56
|
-
title: string;
|
|
57
|
-
description: string;
|
|
58
|
-
body: string;
|
|
59
|
-
footer: string;
|
|
60
|
-
}, undefined, {
|
|
61
|
-
placement: {
|
|
62
|
-
center: {
|
|
63
|
-
content: string;
|
|
64
|
-
};
|
|
65
|
-
bottom: {
|
|
66
|
-
content: string;
|
|
67
|
-
};
|
|
68
|
-
right: {
|
|
69
|
-
content: string;
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
size: {
|
|
73
|
-
sm: {
|
|
74
|
-
content: string;
|
|
75
|
-
};
|
|
76
|
-
md: {
|
|
77
|
-
content: string;
|
|
78
|
-
};
|
|
79
|
-
lg: {
|
|
80
|
-
content: string;
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
}, {
|
|
84
|
-
overlay: string;
|
|
85
|
-
content: string;
|
|
86
|
-
close: string;
|
|
87
|
-
header: string;
|
|
88
|
-
title: string;
|
|
89
|
-
description: string;
|
|
90
|
-
body: string;
|
|
91
|
-
footer: string;
|
|
92
|
-
}, tailwind_variants.TVReturnTypeLike<{
|
|
93
|
-
placement: {
|
|
94
|
-
center: {
|
|
95
|
-
content: string;
|
|
96
|
-
};
|
|
97
|
-
bottom: {
|
|
98
|
-
content: string;
|
|
99
|
-
};
|
|
100
|
-
right: {
|
|
101
|
-
content: string;
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
size: {
|
|
105
|
-
sm: {
|
|
106
|
-
content: string;
|
|
107
|
-
};
|
|
108
|
-
md: {
|
|
109
|
-
content: string;
|
|
110
|
-
};
|
|
111
|
-
lg: {
|
|
112
|
-
content: string;
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
}, {
|
|
116
|
-
overlay: string;
|
|
117
|
-
content: string;
|
|
118
|
-
close: string;
|
|
119
|
-
header: string;
|
|
120
|
-
title: string;
|
|
121
|
-
description: string;
|
|
122
|
-
body: string;
|
|
123
|
-
footer: string;
|
|
124
|
-
}>>;
|
|
125
|
-
type DialogVariants = VariantProps<typeof dialog>;
|
|
126
|
-
type DialogContentProps = React.ComponentProps<typeof Dialog$1.Content> & DialogVariants & {
|
|
127
|
-
/** The accessible name of the close button — passed translated. */
|
|
128
|
-
closeLabel: string;
|
|
129
|
-
/** The element the portal renders into (default: document.body). */
|
|
130
|
-
container?: HTMLElement | null;
|
|
131
|
-
};
|
|
132
|
-
/** The dialog itself, portalled over a dimmed overlay, with a close button. Give it a `Dialog.Title`. */
|
|
133
|
-
declare function DialogContent({ placement, size, closeLabel, container, className, children, ...props }: DialogContentProps): React.JSX.Element;
|
|
134
|
-
declare function DialogHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
135
|
-
declare function DialogTitle({ className, ...props }: React.ComponentProps<typeof Dialog$1.Title>): React.JSX.Element;
|
|
136
|
-
declare function DialogDescription({ className, ...props }: React.ComponentProps<typeof Dialog$1.Description>): React.JSX.Element;
|
|
137
|
-
declare function DialogBody({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
138
|
-
declare function DialogFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
139
|
-
/** `Dialog.Root/Trigger/Content/Header/Title/Description/Body/Footer/Close`. `open`/`defaultOpen` + `onOpenChange`. */
|
|
140
|
-
declare const Dialog: {
|
|
141
|
-
Root: React.FC<Dialog$1.DialogProps>;
|
|
142
|
-
Trigger: React.ForwardRefExoticComponent<Dialog$1.DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
143
|
-
Close: React.ForwardRefExoticComponent<Dialog$1.DialogCloseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
144
|
-
Content: typeof DialogContent;
|
|
145
|
-
Header: typeof DialogHeader;
|
|
146
|
-
Title: typeof DialogTitle;
|
|
147
|
-
Description: typeof DialogDescription;
|
|
148
|
-
Body: typeof DialogBody;
|
|
149
|
-
Footer: typeof DialogFooter;
|
|
150
|
-
};
|
|
151
|
-
type SheetProps = Omit<DialogContentProps, "placement">;
|
|
152
|
-
/** A sheet is a dialog anchored at the bottom (centred from `sm` up): `Dialog.Content placement="bottom"`. */
|
|
153
|
-
declare function Sheet(props: SheetProps): React.JSX.Element;
|
|
154
|
-
|
|
155
|
-
export { AlertDialog, type AlertDialogProps, Dialog, DialogBody, DialogContent, type DialogContentProps, DialogDescription, DialogFooter, DialogHeader, DialogTitle, type DialogVariants, Sheet, type SheetProps, dialog };
|
|
28
|
+
export { AlertDialog, type AlertDialogProps };
|
package/dist/dialog.js
CHANGED
|
@@ -1,88 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Dialog,
|
|
4
|
+
DialogBody,
|
|
5
|
+
DialogContent,
|
|
6
|
+
DialogDescription,
|
|
7
|
+
DialogFooter,
|
|
8
|
+
DialogHeader,
|
|
9
|
+
DialogTitle,
|
|
10
|
+
Sheet,
|
|
11
|
+
dialog
|
|
12
|
+
} from "./chunk-5FRYKFTO.js";
|
|
13
|
+
import {
|
|
14
|
+
Button
|
|
5
15
|
} from "./chunk-QRG5RYEI.js";
|
|
6
16
|
|
|
7
17
|
// src/dialog/alert-dialog.tsx
|
|
8
18
|
import { AlertDialog as AlertDialogPrimitive } from "radix-ui";
|
|
9
19
|
import * as React from "react";
|
|
10
|
-
|
|
11
|
-
// src/dialog/dialog.tsx
|
|
12
|
-
import { Dialog as DialogPrimitive } from "radix-ui";
|
|
13
|
-
import { tv } from "tailwind-variants";
|
|
14
20
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
-
var
|
|
16
|
-
slots: {
|
|
17
|
-
overlay: "kz-overlay fixed inset-0 z-50 bg-overlay backdrop-blur-xs",
|
|
18
|
-
content: "kz-dialog fixed z-50 flex flex-col overflow-hidden border border-border-default bg-surface-1 text-fg shadow-lg focus:outline-hidden",
|
|
19
|
-
close: "absolute right-3 top-3 h-9 w-9",
|
|
20
|
-
header: "flex flex-col gap-1 px-5 pb-2 pr-14 pt-5",
|
|
21
|
-
title: "text-base font-bold text-fg",
|
|
22
|
-
description: "text-sm text-fg-secondary",
|
|
23
|
-
body: "min-h-0 flex-1 overflow-y-auto px-5 pb-5",
|
|
24
|
-
footer: "flex flex-wrap items-center justify-end gap-2 border-t border-border-subtle px-5 py-4 pb-[max(1rem,env(safe-area-inset-bottom))]"
|
|
25
|
-
},
|
|
26
|
-
variants: {
|
|
27
|
-
placement: {
|
|
28
|
-
center: { content: "left-1/2 top-1/2 max-h-[85dvh] w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl" },
|
|
29
|
-
/* A sheet: anchored at the bottom on a phone, centred from `sm` up. */
|
|
30
|
-
bottom: {
|
|
31
|
-
content: "inset-x-0 bottom-0 max-h-[92dvh] rounded-t-[1.75rem] sm:bottom-auto sm:left-1/2 sm:top-1/2 sm:w-full sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-[1.75rem]"
|
|
32
|
-
},
|
|
33
|
-
right: { content: "inset-y-0 right-0 h-full w-full max-w-md rounded-none border-y-0 border-r-0" }
|
|
34
|
-
},
|
|
35
|
-
size: { sm: { content: "sm:max-w-sm" }, md: { content: "sm:max-w-md" }, lg: { content: "sm:max-w-2xl" } }
|
|
36
|
-
},
|
|
37
|
-
defaultVariants: { placement: "center", size: "md" }
|
|
38
|
-
});
|
|
39
|
-
var s = dialog();
|
|
40
|
-
function CloseIcon() {
|
|
41
|
-
return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", className: "h-4 w-4", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M18 6 6 18M6 6l12 12" }) });
|
|
42
|
-
}
|
|
43
|
-
function DialogContent({ placement, size, closeLabel, container, className, children, ...props }) {
|
|
44
|
-
const v = dialog({ placement, size });
|
|
45
|
-
return /* @__PURE__ */ jsxs(DialogPrimitive.Portal, { container, children: [
|
|
46
|
-
/* @__PURE__ */ jsx(DialogPrimitive.Overlay, { className: v.overlay() }),
|
|
47
|
-
/* @__PURE__ */ jsxs(DialogPrimitive.Content, { "data-placement": placement ?? "center", className: v.content({ className }), ...props, children: [
|
|
48
|
-
children,
|
|
49
|
-
/* @__PURE__ */ jsx(DialogPrimitive.Close, { asChild: true, children: /* @__PURE__ */ jsx(IconButton, { label: closeLabel, variant: "ghost", shape: "pill", className: v.close(), children: /* @__PURE__ */ jsx(CloseIcon, {}) }) })
|
|
50
|
-
] })
|
|
51
|
-
] });
|
|
52
|
-
}
|
|
53
|
-
function DialogHeader({ className, ...props }) {
|
|
54
|
-
return /* @__PURE__ */ jsx("div", { className: s.header({ className }), ...props });
|
|
55
|
-
}
|
|
56
|
-
function DialogTitle({ className, ...props }) {
|
|
57
|
-
return /* @__PURE__ */ jsx(DialogPrimitive.Title, { className: s.title({ className }), ...props });
|
|
58
|
-
}
|
|
59
|
-
function DialogDescription({ className, ...props }) {
|
|
60
|
-
return /* @__PURE__ */ jsx(DialogPrimitive.Description, { className: s.description({ className }), ...props });
|
|
61
|
-
}
|
|
62
|
-
function DialogBody({ className, ...props }) {
|
|
63
|
-
return /* @__PURE__ */ jsx("div", { className: s.body({ className }), ...props });
|
|
64
|
-
}
|
|
65
|
-
function DialogFooter({ className, ...props }) {
|
|
66
|
-
return /* @__PURE__ */ jsx("div", { className: s.footer({ className }), ...props });
|
|
67
|
-
}
|
|
68
|
-
var Dialog = {
|
|
69
|
-
Root: DialogPrimitive.Root,
|
|
70
|
-
Trigger: DialogPrimitive.Trigger,
|
|
71
|
-
Close: DialogPrimitive.Close,
|
|
72
|
-
Content: DialogContent,
|
|
73
|
-
Header: DialogHeader,
|
|
74
|
-
Title: DialogTitle,
|
|
75
|
-
Description: DialogDescription,
|
|
76
|
-
Body: DialogBody,
|
|
77
|
-
Footer: DialogFooter
|
|
78
|
-
};
|
|
79
|
-
function Sheet(props) {
|
|
80
|
-
return /* @__PURE__ */ jsx(DialogContent, { placement: "bottom", ...props });
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// src/dialog/alert-dialog.tsx
|
|
84
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
85
|
-
var s2 = dialog({ placement: "center", size: "sm" });
|
|
21
|
+
var s = dialog({ placement: "center", size: "sm" });
|
|
86
22
|
function AlertDialog({
|
|
87
23
|
open: openProp,
|
|
88
24
|
defaultOpen = false,
|
|
@@ -115,26 +51,26 @@ function AlertDialog({
|
|
|
115
51
|
setPending(false);
|
|
116
52
|
}
|
|
117
53
|
};
|
|
118
|
-
return /* @__PURE__ */
|
|
119
|
-
trigger && /* @__PURE__ */
|
|
120
|
-
/* @__PURE__ */
|
|
121
|
-
/* @__PURE__ */
|
|
122
|
-
/* @__PURE__ */
|
|
54
|
+
return /* @__PURE__ */ jsxs(AlertDialogPrimitive.Root, { open, onOpenChange: (next) => pending ? void 0 : setOpen(next), children: [
|
|
55
|
+
trigger && /* @__PURE__ */ jsx(AlertDialogPrimitive.Trigger, { asChild: true, children: trigger }),
|
|
56
|
+
/* @__PURE__ */ jsxs(AlertDialogPrimitive.Portal, { container, children: [
|
|
57
|
+
/* @__PURE__ */ jsx(AlertDialogPrimitive.Overlay, { className: s.overlay() }),
|
|
58
|
+
/* @__PURE__ */ jsxs(
|
|
123
59
|
AlertDialogPrimitive.Content,
|
|
124
60
|
{
|
|
125
61
|
"data-tone": tone,
|
|
126
62
|
"aria-busy": pending || void 0,
|
|
127
|
-
className:
|
|
63
|
+
className: s.content({ className }),
|
|
128
64
|
onEscapeKeyDown: (event) => pending && event.preventDefault(),
|
|
129
65
|
children: [
|
|
130
|
-
/* @__PURE__ */
|
|
131
|
-
/* @__PURE__ */
|
|
132
|
-
description && /* @__PURE__ */
|
|
66
|
+
/* @__PURE__ */ jsxs("div", { className: s.header({ className: "pr-5" }), children: [
|
|
67
|
+
/* @__PURE__ */ jsx(AlertDialogPrimitive.Title, { className: s.title(), children: title }),
|
|
68
|
+
description && /* @__PURE__ */ jsx(AlertDialogPrimitive.Description, { className: s.description(), children: description })
|
|
133
69
|
] }),
|
|
134
|
-
children && /* @__PURE__ */
|
|
135
|
-
/* @__PURE__ */
|
|
136
|
-
/* @__PURE__ */
|
|
137
|
-
/* @__PURE__ */
|
|
70
|
+
children && /* @__PURE__ */ jsx("div", { className: s.body(), children }),
|
|
71
|
+
/* @__PURE__ */ jsxs("div", { className: s.footer(), children: [
|
|
72
|
+
/* @__PURE__ */ jsx(AlertDialogPrimitive.Cancel, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "ghost", disabled: pending, children: cancelLabel }) }),
|
|
73
|
+
/* @__PURE__ */ jsx(Button, { variant: tone === "danger" ? "danger" : "primary", loading: pending, onClick: confirm, children: confirmLabel })
|
|
138
74
|
] })
|
|
139
75
|
]
|
|
140
76
|
}
|
package/dist/dialog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dialog/alert-dialog.tsx","../src/dialog/dialog.tsx"],"sourcesContent":["// Client. A confirmation that interrupts: Radix AlertDialog (role=\"alertdialog\", no outside click, focus on Cancel).\n// `onConfirm` may be async: the dialog stays open with the confirm button loading until it settles, closes when it\n// resolves, and stays open when it rejects (the product shows the error).\nimport { AlertDialog as AlertDialogPrimitive } from \"radix-ui\";\nimport * as React from \"react\";\n\nimport { Button } from \"../button/button\";\nimport { dialog } from \"./dialog\";\n\nconst s = dialog({ placement: \"center\", size: \"sm\" });\n\nexport type AlertDialogProps = {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** The element that opens the dialog (rendered as is, `asChild`): a Button, an IconButton. */\n trigger?: React.ReactNode;\n title: React.ReactNode;\n description?: React.ReactNode;\n /** More content between the description and the actions. */\n children?: React.ReactNode;\n confirmLabel: string;\n cancelLabel: string;\n /** `danger` for a destructive action (delete, leave, cancel a payment). */\n tone?: \"danger\" | \"primary\";\n /** Runs on confirm. A promise keeps the dialog open and the button loading until it settles. */\n onConfirm: () => void | Promise<unknown>;\n /** The element the portal renders into (default: document.body). */\n container?: HTMLElement | null;\n className?: string;\n};\n\nexport function AlertDialog({\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n trigger,\n title,\n description,\n children,\n confirmLabel,\n cancelLabel,\n tone = \"primary\",\n onConfirm,\n container,\n className,\n}: AlertDialogProps) {\n const [openState, setOpenState] = React.useState(defaultOpen);\n const [pending, setPending] = React.useState(false);\n const open = openProp ?? openState;\n\n const setOpen = (next: boolean) => {\n if (openProp === undefined) setOpenState(next);\n onOpenChange?.(next);\n };\n\n const confirm = async () => {\n setPending(true);\n try {\n await onConfirm();\n setOpen(false);\n } catch {\n // Stays open: the product reports the failure (a toast, an inline error) and the person may retry.\n } finally {\n setPending(false);\n }\n };\n\n return (\n <AlertDialogPrimitive.Root open={open} onOpenChange={(next) => (pending ? undefined : setOpen(next))}>\n {trigger && <AlertDialogPrimitive.Trigger asChild>{trigger}</AlertDialogPrimitive.Trigger>}\n <AlertDialogPrimitive.Portal container={container}>\n <AlertDialogPrimitive.Overlay className={s.overlay()} />\n <AlertDialogPrimitive.Content\n data-tone={tone}\n aria-busy={pending || undefined}\n className={s.content({ className })}\n onEscapeKeyDown={(event) => pending && event.preventDefault()}\n >\n <div className={s.header({ className: \"pr-5\" })}>\n <AlertDialogPrimitive.Title className={s.title()}>{title}</AlertDialogPrimitive.Title>\n {description && <AlertDialogPrimitive.Description className={s.description()}>{description}</AlertDialogPrimitive.Description>}\n </div>\n {children && <div className={s.body()}>{children}</div>}\n <div className={s.footer()}>\n <AlertDialogPrimitive.Cancel asChild>\n <Button variant=\"ghost\" disabled={pending}>\n {cancelLabel}\n </Button>\n </AlertDialogPrimitive.Cancel>\n <Button variant={tone === \"danger\" ? \"danger\" : \"primary\"} loading={pending} onClick={confirm}>\n {confirmLabel}\n </Button>\n </div>\n </AlertDialogPrimitive.Content>\n </AlertDialogPrimitive.Portal>\n </AlertDialogPrimitive.Root>\n );\n}\n","// Client (a portal). Radix does the focus trap, the scroll lock, Escape, the outside click, aria-modal, the\n// aria-labelledby / aria-describedby wiring and the focus return: this file only holds the shape.\nimport { Dialog as DialogPrimitive } from \"radix-ui\";\nimport type * as React from \"react\";\nimport { tv, type VariantProps } from \"tailwind-variants\";\n\nimport { IconButton } from \"../button/button\";\n\nexport const dialog = tv({\n slots: {\n overlay: \"kz-overlay fixed inset-0 z-50 bg-overlay backdrop-blur-xs\",\n content:\n \"kz-dialog fixed z-50 flex flex-col overflow-hidden border border-border-default bg-surface-1 text-fg shadow-lg focus:outline-hidden\",\n close: \"absolute right-3 top-3 h-9 w-9\",\n header: \"flex flex-col gap-1 px-5 pb-2 pr-14 pt-5\",\n title: \"text-base font-bold text-fg\",\n description: \"text-sm text-fg-secondary\",\n body: \"min-h-0 flex-1 overflow-y-auto px-5 pb-5\",\n footer:\n \"flex flex-wrap items-center justify-end gap-2 border-t border-border-subtle px-5 py-4 pb-[max(1rem,env(safe-area-inset-bottom))]\",\n },\n variants: {\n placement: {\n center: { content: \"left-1/2 top-1/2 max-h-[85dvh] w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl\" },\n /* A sheet: anchored at the bottom on a phone, centred from `sm` up. */\n bottom: {\n content:\n \"inset-x-0 bottom-0 max-h-[92dvh] rounded-t-[1.75rem] sm:bottom-auto sm:left-1/2 sm:top-1/2 sm:w-full \" +\n \"sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-[1.75rem]\",\n },\n right: { content: \"inset-y-0 right-0 h-full w-full max-w-md rounded-none border-y-0 border-r-0\" },\n },\n size: { sm: { content: \"sm:max-w-sm\" }, md: { content: \"sm:max-w-md\" }, lg: { content: \"sm:max-w-2xl\" } },\n },\n defaultVariants: { placement: \"center\", size: \"md\" },\n});\nconst s = dialog();\n\nexport type DialogVariants = VariantProps<typeof dialog>;\n\nfunction CloseIcon() {\n return (\n <svg viewBox=\"0 0 24 24\" className=\"h-4 w-4\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" aria-hidden>\n <path d=\"M18 6 6 18M6 6l12 12\" />\n </svg>\n );\n}\n\nexport type DialogContentProps = React.ComponentProps<typeof DialogPrimitive.Content> &\n DialogVariants & {\n /** The accessible name of the close button — passed translated. */\n closeLabel: string;\n /** The element the portal renders into (default: document.body). */\n container?: HTMLElement | null;\n };\n\n/** The dialog itself, portalled over a dimmed overlay, with a close button. Give it a `Dialog.Title`. */\nexport function DialogContent({ placement, size, closeLabel, container, className, children, ...props }: DialogContentProps) {\n const v = dialog({ placement, size });\n return (\n <DialogPrimitive.Portal container={container}>\n <DialogPrimitive.Overlay className={v.overlay()} />\n <DialogPrimitive.Content data-placement={placement ?? \"center\"} className={v.content({ className })} {...props}>\n {children}\n <DialogPrimitive.Close asChild>\n <IconButton label={closeLabel} variant=\"ghost\" shape=\"pill\" className={v.close()}>\n <CloseIcon />\n </IconButton>\n </DialogPrimitive.Close>\n </DialogPrimitive.Content>\n </DialogPrimitive.Portal>\n );\n}\n\nexport function DialogHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n return <div className={s.header({ className })} {...props} />;\n}\n\nexport function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>) {\n return <DialogPrimitive.Title className={s.title({ className })} {...props} />;\n}\n\nexport function DialogDescription({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Description>) {\n return <DialogPrimitive.Description className={s.description({ className })} {...props} />;\n}\n\nexport function DialogBody({ className, ...props }: React.ComponentProps<\"div\">) {\n return <div className={s.body({ className })} {...props} />;\n}\n\nexport function DialogFooter({ className, ...props }: React.ComponentProps<\"div\">) {\n return <div className={s.footer({ className })} {...props} />;\n}\n\n/** `Dialog.Root/Trigger/Content/Header/Title/Description/Body/Footer/Close`. `open`/`defaultOpen` + `onOpenChange`. */\nexport const Dialog = {\n Root: DialogPrimitive.Root,\n Trigger: DialogPrimitive.Trigger,\n Close: DialogPrimitive.Close,\n Content: DialogContent,\n Header: DialogHeader,\n Title: DialogTitle,\n Description: DialogDescription,\n Body: DialogBody,\n Footer: DialogFooter,\n};\n\nexport type SheetProps = Omit<DialogContentProps, \"placement\">;\n\n/** A sheet is a dialog anchored at the bottom (centred from `sm` up): `Dialog.Content placement=\"bottom\"`. */\nexport function Sheet(props: SheetProps) {\n return <DialogContent placement=\"bottom\" {...props} />;\n}\n"],"mappings":";;;;;;;AAGA,SAAS,eAAe,4BAA4B;AACpD,YAAY,WAAW;;;ACFvB,SAAS,UAAU,uBAAuB;AAE1C,SAAS,UAA6B;AAuChC,cAmBA,YAnBA;AAnCC,IAAM,SAAS,GAAG;AAAA,EACvB,OAAO;AAAA,IACL,SAAS;AAAA,IACT,SACE;AAAA,IACF,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM;AAAA,IACN,QACE;AAAA,EACJ;AAAA,EACA,UAAU;AAAA,IACR,WAAW;AAAA,MACT,QAAQ,EAAE,SAAS,kGAAkG;AAAA;AAAA,MAErH,QAAQ;AAAA,QACN,SACE;AAAA,MAEJ;AAAA,MACA,OAAO,EAAE,SAAS,8EAA8E;AAAA,IAClG;AAAA,IACA,MAAM,EAAE,IAAI,EAAE,SAAS,cAAc,GAAG,IAAI,EAAE,SAAS,cAAc,GAAG,IAAI,EAAE,SAAS,eAAe,EAAE;AAAA,EAC1G;AAAA,EACA,iBAAiB,EAAE,WAAW,UAAU,MAAM,KAAK;AACrD,CAAC;AACD,IAAM,IAAI,OAAO;AAIjB,SAAS,YAAY;AACnB,SACE,oBAAC,SAAI,SAAQ,aAAY,WAAU,WAAU,MAAK,QAAO,QAAO,gBAAe,aAAY,KAAI,eAAc,SAAQ,eAAW,MAC9H,8BAAC,UAAK,GAAE,wBAAuB,GACjC;AAEJ;AAWO,SAAS,cAAc,EAAE,WAAW,MAAM,YAAY,WAAW,WAAW,UAAU,GAAG,MAAM,GAAuB;AAC3H,QAAM,IAAI,OAAO,EAAE,WAAW,KAAK,CAAC;AACpC,SACE,qBAAC,gBAAgB,QAAhB,EAAuB,WACtB;AAAA,wBAAC,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,EAAE,UAAU,CAAC;AAAA,UAClC,iBAAiB,CAAC,UAAU,WAAW,MAAM,eAAe;AAAA,UAE5D;AAAA,4BAAAD,MAAC,SAAI,WAAWC,GAAE,OAAO,EAAE,WAAW,OAAO,CAAC,GAC5C;AAAA,8BAAAF,KAAC,qBAAqB,OAArB,EAA2B,WAAWE,GAAE,MAAM,GAAI,iBAAM;AAAA,cACxD,eAAe,gBAAAF,KAAC,qBAAqB,aAArB,EAAiC,WAAWE,GAAE,YAAY,GAAI,uBAAY;AAAA,eAC7F;AAAA,YACC,YAAY,gBAAAF,KAAC,SAAI,WAAWE,GAAE,KAAK,GAAI,UAAS;AAAA,YACjD,gBAAAD,MAAC,SAAI,WAAWC,GAAE,OAAO,GACvB;AAAA,8BAAAF,KAAC,qBAAqB,QAArB,EAA4B,SAAO,MAClC,0BAAAA,KAAC,UAAO,SAAQ,SAAQ,UAAU,SAC/B,uBACH,GACF;AAAA,cACA,gBAAAA,KAAC,UAAO,SAAS,SAAS,WAAW,WAAW,WAAW,SAAS,SAAS,SAAS,SACnF,wBACH;AAAA,eACF;AAAA;AAAA;AAAA,MACF;AAAA,OACF;AAAA,KACF;AAEJ;","names":["jsx","jsxs","s"]}
|
|
1
|
+
{"version":3,"sources":["../src/dialog/alert-dialog.tsx"],"sourcesContent":["// Client. A confirmation that interrupts: Radix AlertDialog (role=\"alertdialog\", no outside click, focus on Cancel).\n// `onConfirm` may be async: the dialog stays open with the confirm button loading until it settles, closes when it\n// resolves, and stays open when it rejects (the product shows the error).\nimport { AlertDialog as AlertDialogPrimitive } from \"radix-ui\";\nimport * as React from \"react\";\n\nimport { Button } from \"../button/button\";\nimport { dialog } from \"./dialog\";\n\nconst s = dialog({ placement: \"center\", size: \"sm\" });\n\nexport type AlertDialogProps = {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** The element that opens the dialog (rendered as is, `asChild`): a Button, an IconButton. */\n trigger?: React.ReactNode;\n title: React.ReactNode;\n description?: React.ReactNode;\n /** More content between the description and the actions. */\n children?: React.ReactNode;\n confirmLabel: string;\n cancelLabel: string;\n /** `danger` for a destructive action (delete, leave, cancel a payment). */\n tone?: \"danger\" | \"primary\";\n /** Runs on confirm. A promise keeps the dialog open and the button loading until it settles. */\n onConfirm: () => void | Promise<unknown>;\n /** The element the portal renders into (default: document.body). */\n container?: HTMLElement | null;\n className?: string;\n};\n\nexport function AlertDialog({\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n trigger,\n title,\n description,\n children,\n confirmLabel,\n cancelLabel,\n tone = \"primary\",\n onConfirm,\n container,\n className,\n}: AlertDialogProps) {\n const [openState, setOpenState] = React.useState(defaultOpen);\n const [pending, setPending] = React.useState(false);\n const open = openProp ?? openState;\n\n const setOpen = (next: boolean) => {\n if (openProp === undefined) setOpenState(next);\n onOpenChange?.(next);\n };\n\n const confirm = async () => {\n setPending(true);\n try {\n await onConfirm();\n setOpen(false);\n } catch {\n // Stays open: the product reports the failure (a toast, an inline error) and the person may retry.\n } finally {\n setPending(false);\n }\n };\n\n return (\n <AlertDialogPrimitive.Root open={open} onOpenChange={(next) => (pending ? undefined : setOpen(next))}>\n {trigger && <AlertDialogPrimitive.Trigger asChild>{trigger}</AlertDialogPrimitive.Trigger>}\n <AlertDialogPrimitive.Portal container={container}>\n <AlertDialogPrimitive.Overlay className={s.overlay()} />\n <AlertDialogPrimitive.Content\n data-tone={tone}\n aria-busy={pending || undefined}\n className={s.content({ className })}\n onEscapeKeyDown={(event) => pending && event.preventDefault()}\n >\n <div className={s.header({ className: \"pr-5\" })}>\n <AlertDialogPrimitive.Title className={s.title()}>{title}</AlertDialogPrimitive.Title>\n {description && <AlertDialogPrimitive.Description className={s.description()}>{description}</AlertDialogPrimitive.Description>}\n </div>\n {children && <div className={s.body()}>{children}</div>}\n <div className={s.footer()}>\n <AlertDialogPrimitive.Cancel asChild>\n <Button variant=\"ghost\" disabled={pending}>\n {cancelLabel}\n </Button>\n </AlertDialogPrimitive.Cancel>\n <Button variant={tone === \"danger\" ? \"danger\" : \"primary\"} loading={pending} onClick={confirm}>\n {confirmLabel}\n </Button>\n </div>\n </AlertDialogPrimitive.Content>\n </AlertDialogPrimitive.Portal>\n </AlertDialogPrimitive.Root>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAGA,SAAS,eAAe,4BAA4B;AACpD,YAAY,WAAW;AAkEL,cASR,YATQ;AA7DlB,IAAM,IAAI,OAAO,EAAE,WAAW,UAAU,MAAM,KAAK,CAAC;AAuB7C,SAAS,YAAY;AAAA,EAC1B,MAAM;AAAA,EACN,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AACF,GAAqB;AACnB,QAAM,CAAC,WAAW,YAAY,IAAU,eAAS,WAAW;AAC5D,QAAM,CAAC,SAAS,UAAU,IAAU,eAAS,KAAK;AAClD,QAAM,OAAO,YAAY;AAEzB,QAAM,UAAU,CAAC,SAAkB;AACjC,QAAI,aAAa,OAAW,cAAa,IAAI;AAC7C,mBAAe,IAAI;AAAA,EACrB;AAEA,QAAM,UAAU,YAAY;AAC1B,eAAW,IAAI;AACf,QAAI;AACF,YAAM,UAAU;AAChB,cAAQ,KAAK;AAAA,IACf,QAAQ;AAAA,IAER,UAAE;AACA,iBAAW,KAAK;AAAA,IAClB;AAAA,EACF;AAEA,SACE,qBAAC,qBAAqB,MAArB,EAA0B,MAAY,cAAc,CAAC,SAAU,UAAU,SAAY,QAAQ,IAAI,GAC/F;AAAA,eAAW,oBAAC,qBAAqB,SAArB,EAA6B,SAAO,MAAE,mBAAQ;AAAA,IAC3D,qBAAC,qBAAqB,QAArB,EAA4B,WAC3B;AAAA,0BAAC,qBAAqB,SAArB,EAA6B,WAAW,EAAE,QAAQ,GAAG;AAAA,MACtD;AAAA,QAAC,qBAAqB;AAAA,QAArB;AAAA,UACC,aAAW;AAAA,UACX,aAAW,WAAW;AAAA,UACtB,WAAW,EAAE,QAAQ,EAAE,UAAU,CAAC;AAAA,UAClC,iBAAiB,CAAC,UAAU,WAAW,MAAM,eAAe;AAAA,UAE5D;AAAA,iCAAC,SAAI,WAAW,EAAE,OAAO,EAAE,WAAW,OAAO,CAAC,GAC5C;AAAA,kCAAC,qBAAqB,OAArB,EAA2B,WAAW,EAAE,MAAM,GAAI,iBAAM;AAAA,cACxD,eAAe,oBAAC,qBAAqB,aAArB,EAAiC,WAAW,EAAE,YAAY,GAAI,uBAAY;AAAA,eAC7F;AAAA,YACC,YAAY,oBAAC,SAAI,WAAW,EAAE,KAAK,GAAI,UAAS;AAAA,YACjD,qBAAC,SAAI,WAAW,EAAE,OAAO,GACvB;AAAA,kCAAC,qBAAqB,QAArB,EAA4B,SAAO,MAClC,8BAAC,UAAO,SAAQ,SAAQ,UAAU,SAC/B,uBACH,GACF;AAAA,cACA,oBAAC,UAAO,SAAS,SAAS,WAAW,WAAW,WAAW,SAAS,SAAS,SAAS,SACnF,wBACH;AAAA,eACF;AAAA;AAAA;AAAA,MACF;AAAA,OACF;AAAA,KACF;AAEJ;","names":[]}
|
package/dist/dropdown-menu.js
CHANGED
package/dist/field.js
CHANGED
package/dist/motion.css
CHANGED
|
@@ -145,12 +145,18 @@
|
|
|
145
145
|
from { opacity: 0; transform: translateY(12px) scale(0.97); }
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
+
/* An indeterminate progress bar: a segment that crosses the track (Progress, variant bar). */
|
|
149
|
+
.kz-progress[data-state="indeterminate"] { animation: kz-progress-slide 1.4s var(--kz-ease) infinite; }
|
|
150
|
+
@keyframes kz-progress-slide {
|
|
151
|
+
from { transform: translateX(-100%); }
|
|
152
|
+
to { transform: translateX(250%); }
|
|
153
|
+
}
|
|
148
154
|
@keyframes kz-pop-in {
|
|
149
155
|
from { opacity: 0; transform: translateY(-6px) scale(0.96); }
|
|
150
156
|
}
|
|
151
157
|
|
|
152
158
|
@media (prefers-reduced-motion: reduce) {
|
|
153
|
-
.kz-page, .kz-word, .kz-gradient-text, .kz-marquee, .kz-overlay, .kz-dialog, .kz-pop, .kz-fade { animation: none !important; }
|
|
159
|
+
.kz-page, .kz-word, .kz-gradient-text, .kz-marquee, .kz-overlay, .kz-dialog, .kz-pop, .kz-fade, .kz-progress { animation: none !important; }
|
|
154
160
|
[data-reveal] { opacity: 1; transform: none; filter: none; transition: none; }
|
|
155
161
|
.kz-sheen::after { display: none; }
|
|
156
162
|
.kz-lift, .kz-lift:hover { transform: none; transition: none; }
|
package/dist/popover.js
CHANGED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import * as tailwind_variants from 'tailwind-variants';
|
|
2
|
+
import { VariantProps } from 'tailwind-variants';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
declare const progress: tailwind_variants.TVReturnType<{
|
|
6
|
+
variant: {
|
|
7
|
+
bar: {
|
|
8
|
+
root: string;
|
|
9
|
+
indicator: string;
|
|
10
|
+
};
|
|
11
|
+
ring: {
|
|
12
|
+
root: string;
|
|
13
|
+
track: string;
|
|
14
|
+
indicator: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
size: {
|
|
18
|
+
sm: {};
|
|
19
|
+
md: {};
|
|
20
|
+
lg: {};
|
|
21
|
+
};
|
|
22
|
+
}, {
|
|
23
|
+
root: string;
|
|
24
|
+
track: string;
|
|
25
|
+
indicator: string;
|
|
26
|
+
center: string;
|
|
27
|
+
}, undefined, {
|
|
28
|
+
variant: {
|
|
29
|
+
bar: {
|
|
30
|
+
root: string;
|
|
31
|
+
indicator: string;
|
|
32
|
+
};
|
|
33
|
+
ring: {
|
|
34
|
+
root: string;
|
|
35
|
+
track: string;
|
|
36
|
+
indicator: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
size: {
|
|
40
|
+
sm: {};
|
|
41
|
+
md: {};
|
|
42
|
+
lg: {};
|
|
43
|
+
};
|
|
44
|
+
}, {
|
|
45
|
+
root: string;
|
|
46
|
+
track: string;
|
|
47
|
+
indicator: string;
|
|
48
|
+
center: string;
|
|
49
|
+
}, tailwind_variants.TVReturnTypeLike<{
|
|
50
|
+
variant: {
|
|
51
|
+
bar: {
|
|
52
|
+
root: string;
|
|
53
|
+
indicator: string;
|
|
54
|
+
};
|
|
55
|
+
ring: {
|
|
56
|
+
root: string;
|
|
57
|
+
track: string;
|
|
58
|
+
indicator: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
size: {
|
|
62
|
+
sm: {};
|
|
63
|
+
md: {};
|
|
64
|
+
lg: {};
|
|
65
|
+
};
|
|
66
|
+
}, {
|
|
67
|
+
root: string;
|
|
68
|
+
track: string;
|
|
69
|
+
indicator: string;
|
|
70
|
+
center: string;
|
|
71
|
+
}>>;
|
|
72
|
+
type ProgressVariants = VariantProps<typeof progress>;
|
|
73
|
+
type ProgressProps = Omit<React.ComponentProps<"div">, "children"> & ProgressVariants & {
|
|
74
|
+
/** How far, between 0 and `max`. `null` or absent: indeterminate (a wait of unknown length). */
|
|
75
|
+
value?: number | null;
|
|
76
|
+
max?: number;
|
|
77
|
+
/** The accessible name — passed translated ("Upload", "Raised towards the goal"). */
|
|
78
|
+
label: string;
|
|
79
|
+
/** The value in words for assistive technology ("$420 of $1,000") — default: the percentage. */
|
|
80
|
+
valueText?: string;
|
|
81
|
+
/** A ring's centre: an amount, a percentage, an icon. */
|
|
82
|
+
children?: React.ReactNode;
|
|
83
|
+
};
|
|
84
|
+
/** A progress bar or ring: `value` / `max`, indeterminate without a value. State: `data-state` (loading · complete · indeterminate). */
|
|
85
|
+
declare function Progress({ variant, size, value, max, label, valueText, className, children, ...props }: ProgressProps): React.JSX.Element;
|
|
86
|
+
|
|
87
|
+
export { Progress, type ProgressProps, type ProgressVariants, progress };
|
package/dist/progress.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// src/progress/progress.tsx
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
var progress = tv({
|
|
5
|
+
slots: {
|
|
6
|
+
root: "relative",
|
|
7
|
+
track: "",
|
|
8
|
+
indicator: "",
|
|
9
|
+
center: "absolute inset-0 flex flex-col items-center justify-center text-center"
|
|
10
|
+
},
|
|
11
|
+
variants: {
|
|
12
|
+
variant: {
|
|
13
|
+
bar: {
|
|
14
|
+
root: "w-full overflow-hidden rounded-full bg-surface-3",
|
|
15
|
+
indicator: "kz-progress h-full rounded-full bg-linear-to-r from-accent to-accent-2 transition-[width] duration-500 motion-reduce:transition-none data-[state=indeterminate]:w-2/5"
|
|
16
|
+
},
|
|
17
|
+
ring: {
|
|
18
|
+
root: "inline-flex shrink-0 items-center justify-center",
|
|
19
|
+
track: "stroke-border-default",
|
|
20
|
+
indicator: "stroke-accent transition-[stroke-dashoffset] duration-1000 motion-reduce:transition-none data-[state=indeterminate]:origin-center data-[state=indeterminate]:animate-spin motion-reduce:data-[state=indeterminate]:animate-none"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
size: { sm: {}, md: {}, lg: {} }
|
|
24
|
+
},
|
|
25
|
+
compoundVariants: [
|
|
26
|
+
{ variant: "bar", size: "sm", class: { root: "h-1" } },
|
|
27
|
+
{ variant: "bar", size: "md", class: { root: "h-2" } },
|
|
28
|
+
{ variant: "bar", size: "lg", class: { root: "h-3" } },
|
|
29
|
+
{ variant: "ring", size: "sm", class: { root: "h-10 w-10" } },
|
|
30
|
+
{ variant: "ring", size: "md", class: { root: "h-20 w-20" } },
|
|
31
|
+
{ variant: "ring", size: "lg", class: { root: "h-36 w-36" } }
|
|
32
|
+
],
|
|
33
|
+
defaultVariants: { variant: "bar", size: "md" }
|
|
34
|
+
});
|
|
35
|
+
var STROKE = { sm: 12, md: 9, lg: 7 };
|
|
36
|
+
function Progress({ variant = "bar", size = "md", value, max = 100, label, valueText, className, children, ...props }) {
|
|
37
|
+
const s = progress({ variant, size });
|
|
38
|
+
const known = typeof value === "number" && Number.isFinite(value);
|
|
39
|
+
const ratio = known ? Math.min(1, Math.max(0, value / (max || 1))) : 0;
|
|
40
|
+
const percent = Math.round(ratio * 100);
|
|
41
|
+
const state = !known ? "indeterminate" : ratio >= 1 ? "complete" : "loading";
|
|
42
|
+
const aria = {
|
|
43
|
+
role: "progressbar",
|
|
44
|
+
"aria-label": label,
|
|
45
|
+
"aria-valuemin": known ? 0 : void 0,
|
|
46
|
+
"aria-valuemax": known ? max : void 0,
|
|
47
|
+
"aria-valuenow": known ? Math.min(max, Math.max(0, value)) : void 0,
|
|
48
|
+
"aria-valuetext": known ? valueText ?? `${percent}%` : valueText,
|
|
49
|
+
"data-state": state,
|
|
50
|
+
"data-value": known ? value : void 0,
|
|
51
|
+
"data-variant": variant
|
|
52
|
+
};
|
|
53
|
+
if (variant === "ring") {
|
|
54
|
+
const stroke = STROKE[size];
|
|
55
|
+
const r = 50 - stroke / 2;
|
|
56
|
+
return /* @__PURE__ */ jsxs("div", { ...aria, className: s.root({ className }), ...props, children: [
|
|
57
|
+
/* @__PURE__ */ jsxs("svg", { viewBox: "0 0 100 100", className: "h-full w-full -rotate-90", "aria-hidden": true, children: [
|
|
58
|
+
/* @__PURE__ */ jsx("circle", { cx: "50", cy: "50", r, fill: "none", strokeWidth: stroke, className: s.track() }),
|
|
59
|
+
/* @__PURE__ */ jsx(
|
|
60
|
+
"circle",
|
|
61
|
+
{
|
|
62
|
+
cx: "50",
|
|
63
|
+
cy: "50",
|
|
64
|
+
r,
|
|
65
|
+
fill: "none",
|
|
66
|
+
strokeWidth: stroke,
|
|
67
|
+
strokeLinecap: "round",
|
|
68
|
+
pathLength: 100,
|
|
69
|
+
strokeDasharray: 100,
|
|
70
|
+
strokeDashoffset: known ? 100 - percent : 75,
|
|
71
|
+
"data-state": state,
|
|
72
|
+
className: s.indicator()
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
] }),
|
|
76
|
+
children !== void 0 && /* @__PURE__ */ jsx("div", { className: s.center(), children })
|
|
77
|
+
] });
|
|
78
|
+
}
|
|
79
|
+
return /* @__PURE__ */ jsx("div", { ...aria, className: s.root({ className }), ...props, children: /* @__PURE__ */ jsx("div", { "data-state": state, className: s.indicator(), style: known ? { width: `${ratio * 100}%` } : void 0 }) });
|
|
80
|
+
}
|
|
81
|
+
export {
|
|
82
|
+
Progress,
|
|
83
|
+
progress
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/progress/progress.tsx"],"sourcesContent":["// Server-safe: no hook, no context. role=\"progressbar\" with aria-valuenow / aria-valuemax (none when indeterminate),\n// named by `label`. A bar or a ring; the ring can hold content in its centre (an amount, a percentage).\nimport type * as React from \"react\";\nimport { tv, type VariantProps } from \"tailwind-variants\";\n\nexport const progress = tv({\n slots: {\n root: \"relative\",\n track: \"\",\n indicator: \"\",\n center: \"absolute inset-0 flex flex-col items-center justify-center text-center\",\n },\n variants: {\n variant: {\n bar: {\n root: \"w-full overflow-hidden rounded-full bg-surface-3\",\n indicator:\n \"kz-progress h-full rounded-full bg-linear-to-r from-accent to-accent-2 transition-[width] duration-500 motion-reduce:transition-none \" +\n \"data-[state=indeterminate]:w-2/5\",\n },\n ring: {\n root: \"inline-flex shrink-0 items-center justify-center\",\n track: \"stroke-border-default\",\n indicator:\n \"stroke-accent transition-[stroke-dashoffset] duration-1000 motion-reduce:transition-none \" +\n \"data-[state=indeterminate]:origin-center data-[state=indeterminate]:animate-spin motion-reduce:data-[state=indeterminate]:animate-none\",\n },\n },\n size: { sm: {}, md: {}, lg: {} },\n },\n compoundVariants: [\n { variant: \"bar\", size: \"sm\", class: { root: \"h-1\" } },\n { variant: \"bar\", size: \"md\", class: { root: \"h-2\" } },\n { variant: \"bar\", size: \"lg\", class: { root: \"h-3\" } },\n { variant: \"ring\", size: \"sm\", class: { root: \"h-10 w-10\" } },\n { variant: \"ring\", size: \"md\", class: { root: \"h-20 w-20\" } },\n { variant: \"ring\", size: \"lg\", class: { root: \"h-36 w-36\" } },\n ],\n defaultVariants: { variant: \"bar\", size: \"md\" },\n});\n\nexport type ProgressVariants = VariantProps<typeof progress>;\n\nexport type ProgressProps = Omit<React.ComponentProps<\"div\">, \"children\"> &\n ProgressVariants & {\n /** How far, between 0 and `max`. `null` or absent: indeterminate (a wait of unknown length). */\n value?: number | null;\n max?: number;\n /** The accessible name — passed translated (\"Upload\", \"Raised towards the goal\"). */\n label: string;\n /** The value in words for assistive technology (\"$420 of $1,000\") — default: the percentage. */\n valueText?: string;\n /** A ring's centre: an amount, a percentage, an icon. */\n children?: React.ReactNode;\n };\n\nconst STROKE = { sm: 12, md: 9, lg: 7 } as const;\n\n/** A progress bar or ring: `value` / `max`, indeterminate without a value. State: `data-state` (loading · complete · indeterminate). */\nexport function Progress({ variant = \"bar\", size = \"md\", value, max = 100, label, valueText, className, children, ...props }: ProgressProps) {\n const s = progress({ variant, size });\n const known = typeof value === \"number\" && Number.isFinite(value);\n const ratio = known ? Math.min(1, Math.max(0, value / (max || 1))) : 0;\n const percent = Math.round(ratio * 100);\n const state = !known ? \"indeterminate\" : ratio >= 1 ? \"complete\" : \"loading\";\n const aria = {\n role: \"progressbar\" as const,\n \"aria-label\": label,\n \"aria-valuemin\": known ? 0 : undefined,\n \"aria-valuemax\": known ? max : undefined,\n \"aria-valuenow\": known ? Math.min(max, Math.max(0, value)) : undefined,\n \"aria-valuetext\": known ? (valueText ?? `${percent}%`) : valueText,\n \"data-state\": state,\n \"data-value\": known ? value : undefined,\n \"data-variant\": variant,\n };\n if (variant === \"ring\") {\n const stroke = STROKE[size];\n const r = 50 - stroke / 2;\n return (\n <div {...aria} className={s.root({ className })} {...props}>\n <svg viewBox=\"0 0 100 100\" className=\"h-full w-full -rotate-90\" aria-hidden>\n <circle cx=\"50\" cy=\"50\" r={r} fill=\"none\" strokeWidth={stroke} className={s.track()} />\n <circle\n cx=\"50\"\n cy=\"50\"\n r={r}\n fill=\"none\"\n strokeWidth={stroke}\n strokeLinecap=\"round\"\n pathLength={100}\n strokeDasharray={100}\n strokeDashoffset={known ? 100 - percent : 75}\n data-state={state}\n className={s.indicator()}\n />\n </svg>\n {children !== undefined && <div className={s.center()}>{children}</div>}\n </div>\n );\n }\n return (\n <div {...aria} className={s.root({ className })} {...props}>\n <div data-state={state} className={s.indicator()} style={known ? { width: `${ratio * 100}%` } : undefined} />\n </div>\n );\n}\n"],"mappings":";AAGA,SAAS,UAA6B;AA8E9B,SACE,KADF;AA5ED,IAAM,WAAW,GAAG;AAAA,EACzB,OAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,WAAW;AAAA,IACX,QAAQ;AAAA,EACV;AAAA,EACA,UAAU;AAAA,IACR,SAAS;AAAA,MACP,KAAK;AAAA,QACH,MAAM;AAAA,QACN,WACE;AAAA,MAEJ;AAAA,MACA,MAAM;AAAA,QACJ,MAAM;AAAA,QACN,OAAO;AAAA,QACP,WACE;AAAA,MAEJ;AAAA,IACF;AAAA,IACA,MAAM,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE;AAAA,EACjC;AAAA,EACA,kBAAkB;AAAA,IAChB,EAAE,SAAS,OAAO,MAAM,MAAM,OAAO,EAAE,MAAM,MAAM,EAAE;AAAA,IACrD,EAAE,SAAS,OAAO,MAAM,MAAM,OAAO,EAAE,MAAM,MAAM,EAAE;AAAA,IACrD,EAAE,SAAS,OAAO,MAAM,MAAM,OAAO,EAAE,MAAM,MAAM,EAAE;AAAA,IACrD,EAAE,SAAS,QAAQ,MAAM,MAAM,OAAO,EAAE,MAAM,YAAY,EAAE;AAAA,IAC5D,EAAE,SAAS,QAAQ,MAAM,MAAM,OAAO,EAAE,MAAM,YAAY,EAAE;AAAA,IAC5D,EAAE,SAAS,QAAQ,MAAM,MAAM,OAAO,EAAE,MAAM,YAAY,EAAE;AAAA,EAC9D;AAAA,EACA,iBAAiB,EAAE,S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H,IAAG;AAAA,YACH;AAAA,YACA,MAAK;AAAA,YACL,aAAa;AAAA,YACb,eAAc;AAAA,YACd,YAAY;AAAA,YACZ,iBAAiB;AAAA,YACjB,kBAAkB,QAAQ,MAAM,UAAU;AAAA,YAC1C,cAAY;AAAA,YACZ,WAAW,EAAE,UAAU;AAAA;AAAA,QACzB;AAAA,SACF;AAAA,MACC,aAAa,UAAa,oBAAC,SAAI,WAAW,EAAE,OAAO,GAAI,UAAS;AAAA,OACnE;AAAA,EAEJ;AACA,SACE,oBAAC,SAAK,GAAG,MAAM,WAAW,EAAE,KAAK,EAAE,UAAU,CAAC,GAAI,GAAG,OACnD,8BAAC,SAAI,cAAY,OAAO,WAAW,EAAE,UAAU,GAAG,OAAO,QAAQ,EAAE,OAAO,GAAG,QAAQ,GAAG,IAAI,IAAI,QAAW,GAC7G;AAEJ;","names":[]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as tailwind_variants from 'tailwind-variants';
|
|
2
|
+
import { RadioGroup as RadioGroup$1 } from 'radix-ui';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
declare const radioGroup: tailwind_variants.TVReturnType<{
|
|
6
|
+
[key: string]: {
|
|
7
|
+
[key: string]: tailwind_variants.ClassValue | {
|
|
8
|
+
root?: tailwind_variants.ClassValue;
|
|
9
|
+
dot?: tailwind_variants.ClassValue;
|
|
10
|
+
label?: tailwind_variants.ClassValue;
|
|
11
|
+
item?: tailwind_variants.ClassValue;
|
|
12
|
+
card?: tailwind_variants.ClassValue;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
} | {
|
|
16
|
+
[x: string]: {
|
|
17
|
+
[x: string]: tailwind_variants.ClassValue | {
|
|
18
|
+
root?: tailwind_variants.ClassValue;
|
|
19
|
+
dot?: tailwind_variants.ClassValue;
|
|
20
|
+
label?: tailwind_variants.ClassValue;
|
|
21
|
+
item?: tailwind_variants.ClassValue;
|
|
22
|
+
card?: tailwind_variants.ClassValue;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
} | {}, {
|
|
26
|
+
root: string;
|
|
27
|
+
item: string;
|
|
28
|
+
dot: string;
|
|
29
|
+
label: string;
|
|
30
|
+
card: string;
|
|
31
|
+
}, undefined, {
|
|
32
|
+
[key: string]: {
|
|
33
|
+
[key: string]: tailwind_variants.ClassValue | {
|
|
34
|
+
root?: tailwind_variants.ClassValue;
|
|
35
|
+
dot?: tailwind_variants.ClassValue;
|
|
36
|
+
label?: tailwind_variants.ClassValue;
|
|
37
|
+
item?: tailwind_variants.ClassValue;
|
|
38
|
+
card?: tailwind_variants.ClassValue;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
} | {}, {
|
|
42
|
+
root: string;
|
|
43
|
+
item: string;
|
|
44
|
+
dot: string;
|
|
45
|
+
label: string;
|
|
46
|
+
card: string;
|
|
47
|
+
}, tailwind_variants.TVReturnTypeLike<unknown, {
|
|
48
|
+
root: string;
|
|
49
|
+
item: string;
|
|
50
|
+
dot: string;
|
|
51
|
+
label: string;
|
|
52
|
+
card: string;
|
|
53
|
+
}>>;
|
|
54
|
+
type RadioGroupRootProps = React.ComponentProps<typeof RadioGroup$1.Root> & {
|
|
55
|
+
/** The group's accessible name — passed translated (or `aria-labelledby` a visible heading). */
|
|
56
|
+
label?: string;
|
|
57
|
+
/** Marks every radio invalid: aria-invalid (pair it with a `Field.Error`). */
|
|
58
|
+
invalid?: boolean;
|
|
59
|
+
};
|
|
60
|
+
/** `value`/`defaultValue` + `onValueChange`, `orientation`, `required`, `name` for a form. */
|
|
61
|
+
declare function RadioGroupRoot({ label, invalid, className, ...props }: RadioGroupRootProps): React.JSX.Element;
|
|
62
|
+
type RadioGroupItemProps = Omit<React.ComponentProps<typeof RadioGroup$1.Item>, "children"> & {
|
|
63
|
+
/** The words next to the dot, clickable. Otherwise name it with `Field.Label htmlFor` or `aria-label`. */
|
|
64
|
+
children?: React.ReactNode;
|
|
65
|
+
};
|
|
66
|
+
/** A radio: a dot, and its words when given. */
|
|
67
|
+
declare function RadioGroupItem({ className, children, ...props }: RadioGroupItemProps): React.JSX.Element;
|
|
68
|
+
/** A whole card as the radio: its content is the radio's name. `data-state="checked"` styles the chosen one. */
|
|
69
|
+
declare function RadioGroupCard({ className, ...props }: React.ComponentProps<typeof RadioGroup$1.Item>): React.JSX.Element;
|
|
70
|
+
/** `RadioGroup.Root/Item/Card`. */
|
|
71
|
+
declare const RadioGroup: {
|
|
72
|
+
Root: typeof RadioGroupRoot;
|
|
73
|
+
Item: typeof RadioGroupItem;
|
|
74
|
+
Card: typeof RadioGroupCard;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export { RadioGroup, RadioGroupCard, RadioGroupItem, type RadioGroupItemProps, RadioGroupRoot, type RadioGroupRootProps, radioGroup };
|