@seekalfred/primitives 0.5.0 → 0.6.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/README.md +664 -9
- package/dist/accordion/accordion.d.ts +5 -5
- package/dist/accordion/accordion.js +22 -11
- package/dist/accordion/accordion.js.map +1 -1
- package/dist/action-button/action-button.d.ts +50 -0
- package/dist/action-button/action-button.js +159 -0
- package/dist/action-button/action-button.js.map +1 -0
- package/dist/action-button/index.d.ts +2 -0
- package/dist/action-button/index.js +2 -0
- package/dist/alert/alert.d.ts +16 -2
- package/dist/alert/alert.js +118 -20
- package/dist/alert/alert.js.map +1 -1
- package/dist/alert-dialog/alert-dialog.d.ts +1 -1
- package/dist/alert-dialog/alert-dialog.js +4 -2
- package/dist/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/avatar/avatar.d.ts +7 -1
- package/dist/avatar/avatar.js +51 -18
- package/dist/avatar/avatar.js.map +1 -1
- package/dist/badge/badge.d.ts +10 -3
- package/dist/badge/badge.js +37 -5
- package/dist/badge/badge.js.map +1 -1
- package/dist/breadcrumb/breadcrumb.d.ts +3 -30
- package/dist/breadcrumb/breadcrumb.js +25 -8
- package/dist/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/button/button.d.ts +36 -23
- package/dist/button/button.js +178 -33
- package/dist/button/button.js.map +1 -1
- package/dist/button-group/button-group.d.ts +76 -0
- package/dist/button-group/button-group.js +403 -0
- package/dist/button-group/button-group.js.map +1 -0
- package/dist/button-group/index.d.ts +2 -0
- package/dist/button-group/index.js +2 -0
- package/dist/calendar/calendar.d.ts +3 -3
- package/dist/calendar/calendar.js +263 -34
- package/dist/calendar/calendar.js.map +1 -1
- package/dist/card/card.d.ts +14 -7
- package/dist/card/card.js +32 -14
- package/dist/card/card.js.map +1 -1
- package/dist/checkbox/checkbox.d.ts +2 -9
- package/dist/checkbox/checkbox.js +28 -29
- package/dist/checkbox/checkbox.js.map +1 -1
- package/dist/confirm-morph/confirm-morph.d.ts +85 -0
- package/dist/confirm-morph/confirm-morph.js +652 -0
- package/dist/confirm-morph/confirm-morph.js.map +1 -0
- package/dist/confirm-morph/index.d.ts +2 -0
- package/dist/confirm-morph/index.js +2 -0
- package/dist/copy-button/copy-button.d.ts +32 -0
- package/dist/copy-button/copy-button.js +134 -0
- package/dist/copy-button/copy-button.js.map +1 -0
- package/dist/copy-button/index.d.ts +2 -0
- package/dist/copy-button/index.js +2 -0
- package/dist/date-picker/date-picker.d.ts +51 -0
- package/dist/date-picker/date-picker.js +241 -0
- package/dist/date-picker/date-picker.js.map +1 -0
- package/dist/date-picker/date-range-picker.d.ts +78 -0
- package/dist/date-picker/date-range-picker.js +1015 -0
- package/dist/date-picker/date-range-picker.js.map +1 -0
- package/dist/date-picker/index.d.ts +4 -0
- package/dist/date-picker/index.js +4 -0
- package/dist/date-picker/picker-parts.d.ts +46 -0
- package/dist/date-picker/picker-parts.js +135 -0
- package/dist/date-picker/picker-parts.js.map +1 -0
- package/dist/dialog/dialog.d.ts +12 -16
- package/dist/dialog/dialog.js +45 -14
- package/dist/dialog/dialog.js.map +1 -1
- package/dist/empty-state/empty-state.d.ts +44 -0
- package/dist/empty-state/empty-state.js +83 -0
- package/dist/empty-state/empty-state.js.map +1 -0
- package/dist/empty-state/index.d.ts +2 -0
- package/dist/empty-state/index.js +2 -0
- package/dist/expanding-button-group/expanding-button-group.d.ts +54 -0
- package/dist/expanding-button-group/expanding-button-group.js +350 -0
- package/dist/expanding-button-group/expanding-button-group.js.map +1 -0
- package/dist/expanding-button-group/index.d.ts +2 -0
- package/dist/expanding-button-group/index.js +2 -0
- package/dist/file-drop-zone/file-drop-zone.d.ts +71 -0
- package/dist/file-drop-zone/file-drop-zone.js +116 -0
- package/dist/file-drop-zone/file-drop-zone.js.map +1 -0
- package/dist/file-drop-zone/index.d.ts +2 -0
- package/dist/file-drop-zone/index.js +2 -0
- package/dist/filter-bar/filter-bar.d.ts +121 -0
- package/dist/filter-bar/filter-bar.js +300 -0
- package/dist/filter-bar/filter-bar.js.map +1 -0
- package/dist/filter-bar/index.d.ts +2 -0
- package/dist/filter-bar/index.js +2 -0
- package/dist/floating-button-group/floating-button-group.d.ts +61 -0
- package/dist/floating-button-group/floating-button-group.js +340 -0
- package/dist/floating-button-group/floating-button-group.js.map +1 -0
- package/dist/floating-button-group/index.d.ts +2 -0
- package/dist/floating-button-group/index.js +2 -0
- package/dist/icon-morph/icon-morph.d.ts +55 -0
- package/dist/icon-morph/icon-morph.js +331 -0
- package/dist/icon-morph/icon-morph.js.map +1 -0
- package/dist/icon-morph/index.d.ts +2 -0
- package/dist/icon-morph/index.js +2 -0
- package/dist/index.d.ts +24 -2
- package/dist/index.js +29 -7
- package/dist/input/input.d.ts +23 -1
- package/dist/input/input.js +37 -13
- package/dist/input/input.js.map +1 -1
- package/dist/label/label.d.ts +1 -1
- package/dist/label/label.js +4 -2
- package/dist/label/label.js.map +1 -1
- package/dist/lib/count-to.js +113 -0
- package/dist/lib/count-to.js.map +1 -0
- package/dist/lib/eye-morph.js +62 -0
- package/dist/lib/eye-morph.js.map +1 -0
- package/dist/lib/field-message.js +336 -0
- package/dist/lib/field-message.js.map +1 -0
- package/dist/lib/field-shell.js +81 -0
- package/dist/lib/field-shell.js.map +1 -0
- package/dist/lib/field-surface.js +4 -2
- package/dist/lib/field-surface.js.map +1 -1
- package/dist/lib/flip.js +80 -0
- package/dist/lib/flip.js.map +1 -0
- package/dist/lib/height-follow.js +59 -0
- package/dist/lib/height-follow.js.map +1 -0
- package/dist/lib/icon-swap.js +47 -0
- package/dist/lib/icon-swap.js.map +1 -0
- package/dist/lib/leaving-list.js +57 -0
- package/dist/lib/leaving-list.js.map +1 -0
- package/dist/lib/merge-refs.js +22 -0
- package/dist/lib/merge-refs.js.map +1 -0
- package/dist/lib/morph-text.js +128 -0
- package/dist/lib/morph-text.js.map +1 -0
- package/dist/lib/motion.js +162 -0
- package/dist/lib/motion.js.map +1 -0
- package/dist/lib/pausable-timeout.js +67 -0
- package/dist/lib/pausable-timeout.js.map +1 -0
- package/dist/lib/rolling-value.js +31 -0
- package/dist/lib/rolling-value.js.map +1 -0
- package/dist/lib/spring-progress.js +114 -0
- package/dist/lib/spring-progress.js.map +1 -0
- package/dist/lib/svg-id.js +10 -0
- package/dist/lib/svg-id.js.map +1 -0
- package/dist/lib/swap-text.js +77 -0
- package/dist/lib/swap-text.js.map +1 -0
- package/dist/lib/use-copy-feedback.js +36 -0
- package/dist/lib/use-copy-feedback.js.map +1 -0
- package/dist/menu/menu.d.ts +5 -5
- package/dist/menu/menu.js +10 -6
- package/dist/menu/menu.js.map +1 -1
- package/dist/page-header/index.d.ts +2 -0
- package/dist/page-header/index.js +2 -0
- package/dist/page-header/page-header.d.ts +75 -0
- package/dist/page-header/page-header.js +83 -0
- package/dist/page-header/page-header.js.map +1 -0
- package/dist/password-field/index.d.ts +2 -0
- package/dist/password-field/index.js +2 -0
- package/dist/password-field/password-field.d.ts +37 -0
- package/dist/password-field/password-field.js +101 -0
- package/dist/password-field/password-field.js.map +1 -0
- package/dist/password-strength/index.d.ts +2 -0
- package/dist/password-strength/index.js +2 -0
- package/dist/password-strength/password-strength.d.ts +127 -0
- package/dist/password-strength/password-strength.js +455 -0
- package/dist/password-strength/password-strength.js.map +1 -0
- package/dist/popover/popover.d.ts +10 -2
- package/dist/popover/popover.js +6 -4
- package/dist/popover/popover.js.map +1 -1
- package/dist/progress/progress.d.ts +2 -2
- package/dist/progress/progress.js +50 -7
- package/dist/progress/progress.js.map +1 -1
- package/dist/radio-group/radio-group.d.ts +3 -3
- package/dist/radio-group/radio-group.js +14 -10
- package/dist/radio-group/radio-group.js.map +1 -1
- package/dist/scroll-area/scroll-area.d.ts +17 -6
- package/dist/scroll-area/scroll-area.js +30 -6
- package/dist/scroll-area/scroll-area.js.map +1 -1
- package/dist/search-field/index.d.ts +2 -0
- package/dist/search-field/index.js +2 -0
- package/dist/search-field/search-field.d.ts +26 -0
- package/dist/search-field/search-field.js +155 -0
- package/dist/search-field/search-field.js.map +1 -0
- package/dist/select/select.d.ts +3 -3
- package/dist/select/select.js +85 -24
- package/dist/select/select.js.map +1 -1
- package/dist/separator/separator.d.ts +1 -1
- package/dist/separator/separator.js +4 -2
- package/dist/separator/separator.js.map +1 -1
- package/dist/sheet/sheet.d.ts +1 -1
- package/dist/sheet/sheet.js +6 -3
- package/dist/sheet/sheet.js.map +1 -1
- package/dist/side-nav/index.d.ts +2 -0
- package/dist/side-nav/index.js +2 -0
- package/dist/side-nav/side-nav.d.ts +72 -0
- package/dist/side-nav/side-nav.js +142 -0
- package/dist/side-nav/side-nav.js.map +1 -0
- package/dist/skeleton/skeleton.d.ts +8 -2
- package/dist/skeleton/skeleton.js +9 -3
- package/dist/skeleton/skeleton.js.map +1 -1
- package/dist/slider/slider.d.ts +2 -2
- package/dist/slider/slider.js +64 -8
- package/dist/slider/slider.js.map +1 -1
- package/dist/spinner/spinner.d.ts +1 -1
- package/dist/spinner/spinner.js +4 -2
- package/dist/spinner/spinner.js.map +1 -1
- package/dist/split-button/index.d.ts +2 -0
- package/dist/split-button/index.js +2 -0
- package/dist/split-button/split-button.d.ts +46 -0
- package/dist/split-button/split-button.js +122 -0
- package/dist/split-button/split-button.js.map +1 -0
- package/dist/stat-card/index.d.ts +2 -0
- package/dist/stat-card/index.js +2 -0
- package/dist/stat-card/stat-card.d.ts +81 -0
- package/dist/stat-card/stat-card.js +152 -0
- package/dist/stat-card/stat-card.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/switch/switch.d.ts +2 -2
- package/dist/switch/switch.js +11 -8
- package/dist/switch/switch.js.map +1 -1
- package/dist/table/index.d.ts +2 -2
- package/dist/table/index.js +2 -2
- package/dist/table/table.d.ts +38 -7
- package/dist/table/table.js +114 -12
- package/dist/table/table.js.map +1 -1
- package/dist/tabs/tabs.d.ts +4 -4
- package/dist/tabs/tabs.js +153 -12
- package/dist/tabs/tabs.js.map +1 -1
- package/dist/textarea/textarea.d.ts +24 -1
- package/dist/textarea/textarea.js +27 -3
- package/dist/textarea/textarea.js.map +1 -1
- package/dist/theme-switch/index.d.ts +2 -0
- package/dist/theme-switch/index.js +2 -0
- package/dist/theme-switch/theme-switch.d.ts +37 -0
- package/dist/theme-switch/theme-switch.js +123 -0
- package/dist/theme-switch/theme-switch.js.map +1 -0
- package/dist/time-picker/index.d.ts +2 -0
- package/dist/time-picker/index.js +2 -0
- package/dist/time-picker/time-picker.d.ts +54 -0
- package/dist/time-picker/time-picker.js +201 -0
- package/dist/time-picker/time-picker.js.map +1 -0
- package/dist/toast/toast.d.ts +2 -2
- package/dist/toast/toast.js +61 -39
- package/dist/toast/toast.js.map +1 -1
- package/dist/tooltip/tooltip.d.ts +3 -3
- package/dist/tooltip/tooltip.js +66 -15
- package/dist/tooltip/tooltip.js.map +1 -1
- package/package.json +83 -3
package/dist/card/card.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { cn } from "../lib/cn.js";
|
|
2
|
+
import { cn, cnAll } from "../lib/cn.js";
|
|
3
3
|
import { cva } from "class-variance-authority";
|
|
4
|
+
import { forwardRef, useState } from "react";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
//#region src/card/card.tsx
|
|
6
7
|
/**
|
|
@@ -49,21 +50,34 @@ const cardTitleVariants = cva(["text-base leading-(--leading-none) font-semibold
|
|
|
49
50
|
const cardDescriptionVariants = cva(["text-sm leading-(--leading-normal) text-muted-foreground"]);
|
|
50
51
|
const cardContentVariants = cva("px-6");
|
|
51
52
|
const cardFooterVariants = cva("flex items-center px-6");
|
|
52
|
-
function Card({ className, ...props }) {
|
|
53
|
+
const Card = forwardRef(function Card({ className, interactive = false, onPointerEnter, onPointerLeave, ...props }, ref) {
|
|
54
|
+
const [pointed, setPointed] = useState(false);
|
|
53
55
|
return /* @__PURE__ */ jsx("div", {
|
|
56
|
+
ref,
|
|
54
57
|
...props,
|
|
55
58
|
"data-slot": "card",
|
|
56
|
-
|
|
59
|
+
"data-interactive": interactive || void 0,
|
|
60
|
+
"data-pointed": interactive && pointed || void 0,
|
|
61
|
+
onPointerEnter: (event) => {
|
|
62
|
+
onPointerEnter?.(event);
|
|
63
|
+
if (interactive && event.pointerType !== "touch") setPointed(true);
|
|
64
|
+
},
|
|
65
|
+
onPointerLeave: (event) => {
|
|
66
|
+
onPointerLeave?.(event);
|
|
67
|
+
setPointed(false);
|
|
68
|
+
},
|
|
69
|
+
className: cnAll(cardVariants(), interactive && "card-lift", className)
|
|
57
70
|
});
|
|
58
|
-
}
|
|
59
|
-
function CardHeader({ className, ...props }) {
|
|
71
|
+
});
|
|
72
|
+
const CardHeader = forwardRef(function CardHeader({ className, ...props }, ref) {
|
|
60
73
|
return /* @__PURE__ */ jsx("div", {
|
|
74
|
+
ref,
|
|
61
75
|
...props,
|
|
62
76
|
"data-slot": "card-header",
|
|
63
77
|
className: cn(cardHeaderVariants(), className)
|
|
64
78
|
});
|
|
65
|
-
}
|
|
66
|
-
function CardTitle({ className, level = 3, ...props }) {
|
|
79
|
+
});
|
|
80
|
+
const CardTitle = forwardRef(function CardTitle({ className, level = 3, ...props }, ref) {
|
|
67
81
|
const Heading = {
|
|
68
82
|
1: "h1",
|
|
69
83
|
2: "h2",
|
|
@@ -73,32 +87,36 @@ function CardTitle({ className, level = 3, ...props }) {
|
|
|
73
87
|
6: "h6"
|
|
74
88
|
}[level];
|
|
75
89
|
return /* @__PURE__ */ jsx(Heading, {
|
|
90
|
+
ref,
|
|
76
91
|
...props,
|
|
77
92
|
"data-slot": "card-title",
|
|
78
93
|
className: cn(cardTitleVariants(), className)
|
|
79
94
|
});
|
|
80
|
-
}
|
|
81
|
-
function CardDescription({ className, ...props }) {
|
|
95
|
+
});
|
|
96
|
+
const CardDescription = forwardRef(function CardDescription({ className, ...props }, ref) {
|
|
82
97
|
return /* @__PURE__ */ jsx("div", {
|
|
98
|
+
ref,
|
|
83
99
|
...props,
|
|
84
100
|
"data-slot": "card-description",
|
|
85
101
|
className: cn(cardDescriptionVariants(), className)
|
|
86
102
|
});
|
|
87
|
-
}
|
|
88
|
-
function CardContent({ className, ...props }) {
|
|
103
|
+
});
|
|
104
|
+
const CardContent = forwardRef(function CardContent({ className, ...props }, ref) {
|
|
89
105
|
return /* @__PURE__ */ jsx("div", {
|
|
106
|
+
ref,
|
|
90
107
|
...props,
|
|
91
108
|
"data-slot": "card-content",
|
|
92
109
|
className: cn(cardContentVariants(), className)
|
|
93
110
|
});
|
|
94
|
-
}
|
|
95
|
-
function CardFooter({ className, ...props }) {
|
|
111
|
+
});
|
|
112
|
+
const CardFooter = forwardRef(function CardFooter({ className, ...props }, ref) {
|
|
96
113
|
return /* @__PURE__ */ jsx("div", {
|
|
114
|
+
ref,
|
|
97
115
|
...props,
|
|
98
116
|
"data-slot": "card-footer",
|
|
99
117
|
className: cn(cardFooterVariants(), className)
|
|
100
118
|
});
|
|
101
|
-
}
|
|
119
|
+
});
|
|
102
120
|
//#endregion
|
|
103
121
|
export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, cardContentVariants, cardDescriptionVariants, cardFooterVariants, cardHeaderVariants, cardTitleVariants, cardVariants };
|
|
104
122
|
|
package/dist/card/card.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.js","names":[],"sources":["../../src/card/card.tsx"],"sourcesContent":["\"use client\";\n\nimport { cva } from \"class-variance-authority\";\nimport type
|
|
1
|
+
{"version":3,"file":"card.js","names":[],"sources":["../../src/card/card.tsx"],"sourcesContent":["\"use client\";\n\nimport { cva } from \"class-variance-authority\";\nimport { forwardRef, useState, type ComponentPropsWithoutRef } from \"react\";\n\nimport { cn, cnAll } from \"../lib/cn.js\";\n\n/**\n * Card, ported from the legacy shadcn component.\n *\n * Presentational, so there is no React Aria base -- React Aria ships no card,\n * and a container that is not focusable, selectable or interactive needs no\n * behaviour to inherit.\n *\n * Five parts, from six. The census (24 consumer files, the most-used\n * container in the app) reads: Card 55, CardContent 40, CardHeader 21,\n * CardTitle 19, CardDescription 8, CardFooter 2, **CardAction 0**.\n *\n * Dropping `CardAction` takes three things with it, which is most of the\n * legacy header's complexity: the `grid`, the `grid-rows-[auto_auto]`, and\n * the `has-data-[slot=card-action]:grid-cols-[1fr_auto]` rule that existed\n * only to reserve a column for it. With no action to place, a header is a\n * stack.\n *\n * Two more legacy rules are gone. `[.border-b]:pb-6` and `[.border-t]:pt-6`\n * added padding when the CONSUMER happened to add a border class -- clever,\n * but action at a distance through a class name we do not own, and the census\n * found zero application call sites relying on it (one call site passes\n * `border-b-0`, which removes a border it never had). `@container/card-header`\n * named a container nothing queried.\n *\n * Every string in the cva blocks below is a STATIC literal. Tailwind scans\n * source text, so a class assembled at runtime is invisible to it and would\n * simply never be emitted.\n */\nexport const cardVariants = cva([\n \"flex flex-col gap-6\",\n \"rounded-xl border-(length:--border-width) border-border py-6\",\n \"bg-card text-card-foreground shadow-surface\",\n\n // box-border and font-sans are not boilerplate. The reset in\n // @seekalfred/styles is OPT-IN, so a consumer may load none: content-box\n // would add the padding to any width they set (the Alert shipped\n // overflowing its container by 46px), and an unstyled document renders\n // text in a serif (the Accordion shipped its panel that way). Declaring\n // the family HERE rather than on each part means one declaration covers\n // the whole subtree by inheritance.\n \"box-border font-sans\",\n]);\n\n/**\n * Padding is inline-only on the sections and block-only on the shell.\n *\n * That split is load-bearing rather than stylistic: it is what lets a\n * consumer run a divider or a full-bleed image edge to edge, which a single\n * `p-6` on the shell would make impossible.\n */\nexport const cardHeaderVariants = cva(\"flex flex-col gap-1.5 px-6\");\n\nexport const cardTitleVariants = cva([\n // leading-* AFTER text-*: tailwind-merge treats a later text-* as owning\n // line-height and silently strips a leading-* that precedes it.\n \"text-base leading-(--leading-none) font-semibold\",\n // The user-agent <h3> ships a 1em block margin and font-size 1.17em. The\n // legacy component was a <div> and never met either.\n \"m-0\",\n]);\n\nexport const cardDescriptionVariants = cva([\n \"text-sm leading-(--leading-normal) text-muted-foreground\",\n]);\n\nexport const cardContentVariants = cva(\"px-6\");\n\nexport const cardFooterVariants = cva(\"flex items-center px-6\");\n\n/**\n * A content container.\n *\n * @example\n * <Card>\n * <CardHeader>\n * <CardTitle>Learning Progress</CardTitle>\n * <CardDescription>Across all active courses.</CardDescription>\n * </CardHeader>\n * <CardContent>Twelve of eighteen modules complete.</CardContent>\n * </Card>\n */\nexport interface CardProps extends ComponentPropsWithoutRef<\"div\"> {\n /**\n * Make the card respond to a pointer: it floats 2px on a spring while it is pointed\n * at, its border darkens and its shadow deepens. Mouse and pen only; touch never lifts.\n * Leave it off for a card that is not a target: a static card should not move.\n */\n interactive?: boolean;\n}\n\nexport const Card = forwardRef<HTMLDivElement, CardProps>(function Card(\n { className, interactive = false, onPointerEnter, onPointerLeave, ...props },\n ref,\n) {\n // Pointed at by a mouse or pen. Touch never lifts, so it is read from the pointer, not :hover (which a tap leaves stuck).\n const [pointed, setPointed] = useState(false);\n return (\n <div\n ref={ref}\n {...props}\n data-slot=\"card\"\n data-interactive={interactive || undefined}\n data-pointed={(interactive && pointed) || undefined}\n onPointerEnter={(event) => {\n onPointerEnter?.(event);\n if (interactive && event.pointerType !== \"touch\") setPointed(true);\n }}\n onPointerLeave={(event) => {\n onPointerLeave?.(event);\n setPointed(false);\n }}\n className={cnAll(cardVariants(), interactive && \"card-lift\", className)}\n />\n );\n});\n\n/** Title and description, stacked. */\nexport type CardHeaderProps = ComponentPropsWithoutRef<\"div\">;\n\nexport const CardHeader = forwardRef<HTMLDivElement, CardHeaderProps>(function CardHeader(\n { className, ...props },\n ref,\n) {\n return (\n <div\n ref={ref}\n {...props}\n data-slot=\"card-header\"\n className={cn(cardHeaderVariants(), className)}\n />\n );\n});\n\n/**\n * The card's heading.\n *\n * A REAL heading, unlike the legacy `<div class=\"font-semibold\">`. None of\n * the 19 legacy call sites wrapped one, so 19 card titles were invisible to\n * screen-reader heading navigation -- the same shape of finding as the Avatar\n * port's missing `alt`, and the migration is when it gets answered.\n */\nexport interface CardTitleProps extends ComponentPropsWithoutRef<\"h3\"> {\n /**\n * Heading level.\n *\n * `3` by default, because a card almost always sits under a section\n * heading. It is a prop rather than a constant because the correct level\n * is a fact about the PAGE, and a fixed one would be wrong somewhere; the\n * level changes semantics only, never the rendered size.\n *\n * @default 3\n */\n level?: 1 | 2 | 3 | 4 | 5 | 6;\n}\n\nexport const CardTitle = forwardRef<HTMLHeadingElement, CardTitleProps>(function CardTitle(\n { className, level = 3, ...props },\n ref,\n) {\n // Static union, not a template literal: `h${level}` is a string React\n // accepts but TypeScript cannot narrow to an intrinsic element, and the\n // cast that silences it would also accept `h7`.\n const Heading = ({ 1: \"h1\", 2: \"h2\", 3: \"h3\", 4: \"h4\", 5: \"h5\", 6: \"h6\" } as const)[level];\n\n return (\n <Heading\n ref={ref}\n {...props}\n data-slot=\"card-title\"\n className={cn(cardTitleVariants(), className)}\n />\n );\n});\n\n/** Secondary text under the title. */\nexport type CardDescriptionProps = ComponentPropsWithoutRef<\"div\">;\n\nexport const CardDescription = forwardRef<HTMLDivElement, CardDescriptionProps>(\n function CardDescription({ className, ...props }, ref) {\n return (\n <div\n ref={ref}\n {...props}\n data-slot=\"card-description\"\n className={cn(cardDescriptionVariants(), className)}\n />\n );\n },\n);\n\n/** The card's body. */\nexport type CardContentProps = ComponentPropsWithoutRef<\"div\">;\n\nexport const CardContent = forwardRef<HTMLDivElement, CardContentProps>(function CardContent(\n { className, ...props },\n ref,\n) {\n return (\n <div\n ref={ref}\n {...props}\n data-slot=\"card-content\"\n className={cn(cardContentVariants(), className)}\n />\n );\n});\n\n/** Actions or metadata at the foot of the card. */\nexport type CardFooterProps = ComponentPropsWithoutRef<\"div\">;\n\nexport const CardFooter = forwardRef<HTMLDivElement, CardFooterProps>(function CardFooter(\n { className, ...props },\n ref,\n) {\n return (\n <div\n ref={ref}\n {...props}\n data-slot=\"card-footer\"\n className={cn(cardFooterVariants(), className)}\n />\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,eAAe,IAAI;CAC9B;CACA;CACA;CASA;AACF,CAAC;;;;;;;;AASD,MAAa,qBAAqB,IAAI,4BAA4B;AAElE,MAAa,oBAAoB,IAAI,CAGnC,oDAGA,KACF,CAAC;AAED,MAAa,0BAA0B,IAAI,CACzC,0DACF,CAAC;AAED,MAAa,sBAAsB,IAAI,MAAM;AAE7C,MAAa,qBAAqB,IAAI,wBAAwB;AAuB9D,MAAa,OAAO,WAAsC,SAAS,KACjE,EAAE,WAAW,cAAc,OAAO,gBAAgB,gBAAgB,GAAG,SACrE,KACA;CAEA,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,OACE,oBAAC,OAAD;EACO;EACL,GAAI;EACJ,aAAU;EACV,oBAAkB,eAAe,KAAA;EACjC,gBAAe,eAAe,WAAY,KAAA;EAC1C,iBAAiB,UAAU;GACzB,iBAAiB,KAAK;GACtB,IAAI,eAAe,MAAM,gBAAgB,SAAS,WAAW,IAAI;EACnE;EACA,iBAAiB,UAAU;GACzB,iBAAiB,KAAK;GACtB,WAAW,KAAK;EAClB;EACA,WAAW,MAAM,aAAa,GAAG,eAAe,aAAa,SAAS;CACvE,CAAA;AAEL,CAAC;AAKD,MAAa,aAAa,WAA4C,SAAS,WAC7E,EAAE,WAAW,GAAG,SAChB,KACA;CACA,OACE,oBAAC,OAAD;EACO;EACL,GAAI;EACJ,aAAU;EACV,WAAW,GAAG,mBAAmB,GAAG,SAAS;CAC9C,CAAA;AAEL,CAAC;AAwBD,MAAa,YAAY,WAA+C,SAAS,UAC/E,EAAE,WAAW,QAAQ,GAAG,GAAG,SAC3B,KACA;CAIA,MAAM,UAAW;EAAE,GAAG;EAAM,GAAG;EAAM,GAAG;EAAM,GAAG;EAAM,GAAG;EAAM,GAAG;CAAK,EAAY;CAEpF,OACE,oBAAC,SAAD;EACO;EACL,GAAI;EACJ,aAAU;EACV,WAAW,GAAG,kBAAkB,GAAG,SAAS;CAC7C,CAAA;AAEL,CAAC;AAKD,MAAa,kBAAkB,WAC7B,SAAS,gBAAgB,EAAE,WAAW,GAAG,SAAS,KAAK;CACrD,OACE,oBAAC,OAAD;EACO;EACL,GAAI;EACJ,aAAU;EACV,WAAW,GAAG,wBAAwB,GAAG,SAAS;CACnD,CAAA;AAEL,CACF;AAKA,MAAa,cAAc,WAA6C,SAAS,YAC/E,EAAE,WAAW,GAAG,SAChB,KACA;CACA,OACE,oBAAC,OAAD;EACO;EACL,GAAI;EACJ,aAAU;EACV,WAAW,GAAG,oBAAoB,GAAG,SAAS;CAC/C,CAAA;AAEL,CAAC;AAKD,MAAa,aAAa,WAA4C,SAAS,WAC7E,EAAE,WAAW,GAAG,SAChB,KACA;CACA,OACE,oBAAC,OAAD;EACO;EACL,GAAI;EACJ,aAAU;EACV,WAAW,GAAG,mBAAmB,GAAG,SAAS;CAC9C,CAAA;AAEL,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CheckboxProps } from "react-aria-components";
|
|
2
1
|
import { ReactNode } from "react";
|
|
2
|
+
import { CheckboxProps } from "react-aria-components";
|
|
3
3
|
//#region src/checkbox/checkbox.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Checkbox, rebuilt on React Aria.
|
|
@@ -38,13 +38,6 @@ import { ReactNode } from "react";
|
|
|
38
38
|
*/
|
|
39
39
|
export declare const checkboxVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
40
40
|
export declare const checkboxBoxVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
41
|
-
/**
|
|
42
|
-
* A checkbox.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* <Checkbox defaultSelected>Email me about new courses</Checkbox>
|
|
46
|
-
* <Checkbox aria-label="Select row" />
|
|
47
|
-
*/
|
|
48
41
|
interface CheckboxProps$1 extends Omit<CheckboxProps, "className" | "style" | "children"> {
|
|
49
42
|
/**
|
|
50
43
|
* The label, and the control's accessible name.
|
|
@@ -57,7 +50,7 @@ interface CheckboxProps$1 extends Omit<CheckboxProps, "className" | "style" | "c
|
|
|
57
50
|
/** Extra classes for the label. Merged last, so they win conflicts. */
|
|
58
51
|
className?: string;
|
|
59
52
|
}
|
|
60
|
-
declare
|
|
53
|
+
declare const Checkbox$1: import("react").ForwardRefExoticComponent<CheckboxProps$1 & import("react").RefAttributes<HTMLInputElement>>;
|
|
61
54
|
//#endregion
|
|
62
55
|
export { Checkbox$1 as Checkbox, CheckboxProps$1 as CheckboxProps };
|
|
63
56
|
//# sourceMappingURL=checkbox.d.ts.map
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
import { cn } from "../lib/cn.js";
|
|
3
3
|
import { selectionLabelVariants, selectionRingVariants } from "../lib/selection-control.js";
|
|
4
4
|
import { cva } from "class-variance-authority";
|
|
5
|
+
import { forwardRef } from "react";
|
|
5
6
|
import { Checkbox } from "react-aria-components";
|
|
6
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
//#region src/checkbox/checkbox.tsx
|
|
8
9
|
/**
|
|
9
10
|
* Checkbox, rebuilt on React Aria.
|
|
@@ -45,49 +46,47 @@ const checkboxBoxVariants = cva([
|
|
|
45
46
|
"inline-flex size-4 shrink-0 items-center justify-center",
|
|
46
47
|
"rounded-2xs border-(length:--border-width)",
|
|
47
48
|
"box-border",
|
|
48
|
-
"bg-background border-border",
|
|
49
|
-
"
|
|
50
|
-
"group-data-[selected]:
|
|
51
|
-
"group-data-[
|
|
52
|
-
"group-data-[
|
|
53
|
-
"group-data-[indeterminate]:text-primary-foreground",
|
|
49
|
+
"bg-background border-border text-primary-foreground",
|
|
50
|
+
"checkbox-box",
|
|
51
|
+
"group-data-[selected]:border-primary-strong",
|
|
52
|
+
"group-data-[indeterminate]:border-primary-strong",
|
|
53
|
+
"group-data-[hovered]:not-group-data-[selected]:not-group-data-[indeterminate]:border-muted-foreground",
|
|
54
54
|
selectionRingVariants()
|
|
55
55
|
]);
|
|
56
|
-
|
|
56
|
+
const Checkbox$1 = forwardRef(function Checkbox$2({ className, children, ...props }, ref) {
|
|
57
57
|
return /* @__PURE__ */ jsx(Checkbox, {
|
|
58
58
|
...props,
|
|
59
|
+
inputRef: ref,
|
|
59
60
|
"data-slot": "checkbox",
|
|
60
61
|
className: cn(checkboxVariants(), className),
|
|
61
|
-
children: ({ isSelected, isIndeterminate }) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */
|
|
62
|
+
children: ({ isSelected, isIndeterminate }) => /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("span", {
|
|
62
63
|
"aria-hidden": "true",
|
|
63
64
|
"data-slot": "checkbox-box",
|
|
64
65
|
className: checkboxBoxVariants(),
|
|
65
|
-
children:
|
|
66
|
-
"data-slot": "checkbox-
|
|
67
|
-
|
|
66
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
67
|
+
"data-slot": "checkbox-fill",
|
|
68
|
+
className: "checkbox-fill"
|
|
69
|
+
}), /* @__PURE__ */ jsx("svg", {
|
|
70
|
+
"data-slot": "checkbox-mark",
|
|
71
|
+
"data-mark": isIndeterminate ? "indeterminate" : isSelected ? "check" : void 0,
|
|
72
|
+
viewBox: "0 0 18 18",
|
|
68
73
|
fill: "none",
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
strokeWidth: "2.5",
|
|
80
|
-
strokeLinecap: "round",
|
|
81
|
-
strokeLinejoin: "round",
|
|
82
|
-
className: "size-3",
|
|
83
|
-
children: /* @__PURE__ */ jsx("path", { d: "m3.5 8.5 3 3 6-6" })
|
|
84
|
-
}) : null
|
|
74
|
+
className: "absolute -inset-px size-4 overflow-visible",
|
|
75
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
76
|
+
className: "checkbox-mark",
|
|
77
|
+
pathLength: "1",
|
|
78
|
+
stroke: "currentColor",
|
|
79
|
+
strokeWidth: "2",
|
|
80
|
+
strokeLinecap: "round",
|
|
81
|
+
strokeLinejoin: "round"
|
|
82
|
+
})
|
|
83
|
+
})]
|
|
85
84
|
}), children == null ? null : /* @__PURE__ */ jsx("span", {
|
|
86
85
|
"data-slot": "checkbox-label",
|
|
87
86
|
children
|
|
88
87
|
})] })
|
|
89
88
|
});
|
|
90
|
-
}
|
|
89
|
+
});
|
|
91
90
|
//#endregion
|
|
92
91
|
export { Checkbox$1 as Checkbox, checkboxBoxVariants, checkboxVariants };
|
|
93
92
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.js","names":["Checkbox","AriaCheckbox"],"sources":["../../src/checkbox/checkbox.tsx"],"sourcesContent":["\"use client\";\n\nimport { cva } from \"class-variance-authority\";\nimport type
|
|
1
|
+
{"version":3,"file":"checkbox.js","names":["Checkbox","AriaCheckbox"],"sources":["../../src/checkbox/checkbox.tsx"],"sourcesContent":["\"use client\";\n\nimport { cva } from \"class-variance-authority\";\nimport { forwardRef, type ReactNode } from \"react\";\nimport {\n Checkbox as AriaCheckbox,\n type CheckboxProps as AriaCheckboxProps,\n} from \"react-aria-components\";\n\nimport { cn } from \"../lib/cn.js\";\nimport { selectionLabelVariants, selectionRingVariants } from \"../lib/selection-control.js\";\n\n/**\n * Checkbox, rebuilt on React Aria.\n *\n * THE CENSUS FOUND ZERO CALL SITES. It is ported anyway because forms and\n * table row selection are unbuildable without it, but that fact changes what\n * this is: with no usage to be faithful to and no call site to break, it is a\n * rewrite rather than a restyling. Four things the legacy component got\n * wrong are therefore simply fixed rather than carried:\n *\n * - **No accessible name.** It rendered a bare `<input type=\"checkbox\">` with\n * no label, no `aria-label` and no `id`, so every use was an axe `label`\n * violation. Here the label is `children`, and React Aria wraps the input\n * in it.\n * - **The fill never showed.** `checked:bg-primary` on a native input with no\n * `appearance-none` is painted over by the user-agent checkbox.\n * - **`border-primary` cannot be a boundary.** Brand orange is 2.44:1 on\n * white, under even the 3:1 non-text floor (WCAG 1.4.11).\n * - **`focus-visible:ring-2` is a box-shadow**, which forced-colors discards,\n * taking the only focus indication with it.\n *\n * React Aria renders a `<label>` around a visually-hidden real `<input>` and\n * NOTHING else -- there is no visual box in the box. Drawing one, and keeping\n * it in step with `data-selected` / `data-indeterminate`, is what this\n * component owns.\n *\n * Every string in the cva blocks below is a STATIC literal. Tailwind scans\n * source text, so a class assembled at runtime is invisible to it and would\n * simply never be emitted.\n */\n/**\n * The label geometry now lives in lib/selection-control.ts, shared with\n * Radio and Switch. Three controls with the same 24px target and the same\n * typography is the Rule of Three, and this migration has twice found a\n * legacy pair that styled one surface twice and silently drifted.\n */\nexport const checkboxVariants = cva([selectionLabelVariants()]);\n\nexport const checkboxBoxVariants = cva([\n \"inline-flex size-4 shrink-0 items-center justify-center\",\n \"rounded-2xs border-(length:--border-width)\",\n\n // box-border: the size is the whole square, border included.\n \"box-border\",\n\n \"bg-background border-border text-primary-foreground\",\n\n // Border colour eases, the square presses to .95 and springs back (see checkbox-box).\n \"checkbox-box\",\n\n // The border takes the strong tone once chosen; the colour itself is the fill below.\n \"group-data-[selected]:border-primary-strong\",\n \"group-data-[indeterminate]:border-primary-strong\",\n // Hover darkens an unchosen box's border.\n \"group-data-[hovered]:not-group-data-[selected]:not-group-data-[indeterminate]:border-muted-foreground\",\n\n selectionRingVariants(),\n]);\n\nexport interface CheckboxProps\n extends Omit<AriaCheckboxProps, \"className\" | \"style\" | \"children\"> {\n /**\n * The label, and the control's accessible name.\n *\n * Omit it only for a genuinely label-less checkbox -- a table row selector\n * -- and pass `aria-label` instead. A checkbox with neither has no\n * accessible name, which is what every legacy call site would have been.\n */\n children?: ReactNode;\n /** Extra classes for the label. Merged last, so they win conflicts. */\n className?: string;\n}\n\nexport const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(function Checkbox(\n { className, children, ...props },\n ref,\n) {\n return (\n <AriaCheckbox\n {...props}\n // inputRef, not ref: AriaCheckbox's own ref targets the label it\n // renders around a visually-hidden native input, and a label cannot\n // be focused -- ref.current.focus() would silently no-op. inputRef is\n // React Aria's own escape hatch to the real control.\n inputRef={ref}\n data-slot=\"checkbox\"\n // `group` is load-bearing: React Aria puts data-selected,\n // data-indeterminate and data-focus-visible on the LABEL, and CSS\n // cannot look upward from the box to them.\n className={cn(checkboxVariants(), className)}\n >\n {({ isSelected, isIndeterminate }) => (\n <>\n {/*\n aria-hidden: the real <input> already carries the state. A\n decorative box announced as well would say everything twice.\n */}\n <span aria-hidden=\"true\" data-slot=\"checkbox-box\" className={checkboxBoxVariants()}>\n <span data-slot=\"checkbox-fill\" className=\"checkbox-fill\" />\n {/*\n One mark, always rendered: the state decides what it shows. Both\n states can be true at once (a \"select all\" box that has been\n partially cleared) and indeterminate wins, which the path's\n `d` carries in CSS -- the same precedence the old two-glyph\n branch pinned in JS.\n */}\n <svg\n data-slot=\"checkbox-mark\"\n data-mark={isIndeterminate ? \"indeterminate\" : isSelected ? \"check\" : undefined}\n viewBox=\"0 0 18 18\"\n fill=\"none\"\n className=\"absolute -inset-px size-4 overflow-visible\"\n >\n <path\n className=\"checkbox-mark\"\n pathLength=\"1\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n </span>\n {children == null ? null : <span data-slot=\"checkbox-label\">{children}</span>}\n </>\n )}\n </AriaCheckbox>\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAa,mBAAmB,IAAI,CAAC,uBAAuB,CAAC,CAAC;AAE9D,MAAa,sBAAsB,IAAI;CACrC;CACA;CAGA;CAEA;CAGA;CAGA;CACA;CAEA;CAEA,sBAAsB;AACxB,CAAC;AAgBD,MAAaA,aAAW,WAA4C,SAASA,WAC3E,EAAE,WAAW,UAAU,GAAG,SAC1B,KACA;CACA,OACE,oBAACC,UAAD;EACE,GAAI;EAKJ,UAAU;EACV,aAAU;EAIV,WAAW,GAAG,iBAAiB,GAAG,SAAS;EAEzC,WAAA,EAAE,YAAY,sBACd,qBAAA,YAAA,EAAA,UAAA,CAKE,qBAAC,QAAD;GAAM,eAAY;GAAO,aAAU;GAAe,WAAW,oBAAoB;GAAjF,UAAA,CACE,oBAAC,QAAD;IAAM,aAAU;IAAgB,WAAU;GAAiB,CAAA,GAQ3D,oBAAC,OAAD;IACE,aAAU;IACV,aAAW,kBAAkB,kBAAkB,aAAa,UAAU,KAAA;IACtE,SAAQ;IACR,MAAK;IACL,WAAU;IAEV,UAAA,oBAAC,QAAD;KACE,WAAU;KACV,YAAW;KACX,QAAO;KACP,aAAY;KACZ,eAAc;KACd,gBAAe;IAChB,CAAA;GACE,CAAA,CACD;EACL,CAAA,GAAA,YAAY,OAAO,OAAO,oBAAC,QAAD;GAAM,aAAU;GAAkB;EAAe,CAAA,CAC5E,EAAA,CAAA;CAEQ,CAAA;AAElB,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
//#region src/confirm-morph/confirm-morph.d.ts
|
|
3
|
+
/** Where the control is in its life: resting, asking, working, finished, or failed. */
|
|
4
|
+
export type ConfirmMorphState = "idle" | "confirming" | "pending" | "done" | "error";
|
|
5
|
+
/** How the question is answered: a press, a press held until the fill completes, or a press followed by a short countdown. */
|
|
6
|
+
export type ConfirmMorphMode = "press" | "hold" | "countdown";
|
|
7
|
+
/**
|
|
8
|
+
* A button for destructive or important actions that asks in place. Pressing it
|
|
9
|
+
* morphs the same pill into an inline question with Cancel and Confirm, then into
|
|
10
|
+
* a spinner, then into a result with Undo. The width springs to each face while
|
|
11
|
+
* the faces crossfade at their natural width, so text never squashes and nothing
|
|
12
|
+
* around the control jumps. Escape, an outside press, or the timeout all return
|
|
13
|
+
* it to rest.
|
|
14
|
+
*
|
|
15
|
+
* Use it where a modal dialog would be heavy: deleting a project, revoking
|
|
16
|
+
* access, discarding a draft.
|
|
17
|
+
*/
|
|
18
|
+
export interface ConfirmMorphProps {
|
|
19
|
+
/** The resting label, such as "Delete project". */
|
|
20
|
+
label: ReactNode;
|
|
21
|
+
/** A plain icon before the resting label. Mark it `aria-hidden`. */
|
|
22
|
+
icon?: ReactNode;
|
|
23
|
+
/** The question shown while confirming, such as "Delete 3 files?". Defaults to the label with a question mark. */
|
|
24
|
+
prompt?: ReactNode;
|
|
25
|
+
confirmLabel?: string;
|
|
26
|
+
cancelLabel?: string;
|
|
27
|
+
/** Shown beside the spinner while `onConfirm` resolves. */
|
|
28
|
+
pendingLabel?: string;
|
|
29
|
+
doneLabel?: string;
|
|
30
|
+
errorLabel?: string;
|
|
31
|
+
retryLabel?: string;
|
|
32
|
+
undoLabel?: string;
|
|
33
|
+
/** Shown beside the spinner while `onUndo` resolves. */
|
|
34
|
+
undoingLabel?: string;
|
|
35
|
+
/**
|
|
36
|
+
* `danger` (default) gives the confirm button the destructive colour, for
|
|
37
|
+
* actions that destroy something. `neutral` gives it the primary colour, for
|
|
38
|
+
* important actions that can be reversed. The resting button is neutral either way.
|
|
39
|
+
*/
|
|
40
|
+
tone?: "danger" | "neutral";
|
|
41
|
+
/** `press` confirms on a press. `hold` asks for a press held for `holdDuration`. `countdown` confirms, then counts down `countdown` seconds that Cancel or Escape can still stop. */
|
|
42
|
+
confirmMode?: ConfirmMorphMode;
|
|
43
|
+
/** Milliseconds the confirm button must be held in `hold` mode. */
|
|
44
|
+
holdDuration?: number;
|
|
45
|
+
/** Seconds counted down before the action runs in `countdown` mode. */
|
|
46
|
+
countdown?: number;
|
|
47
|
+
/** Text before the seconds in `countdown` mode, such as "Deleting in". Defaults to the pending label followed by "in". */
|
|
48
|
+
countdownLabel?: string;
|
|
49
|
+
/** Runs on confirm. Return a promise to show the pending face; a rejection shows the error face with Retry. */
|
|
50
|
+
onConfirm?: () => void | Promise<unknown>;
|
|
51
|
+
/** Offering it adds Undo to the result. Return a promise to show a pending face while it runs. */
|
|
52
|
+
onUndo?: () => void | Promise<unknown>;
|
|
53
|
+
onCancel?: () => void;
|
|
54
|
+
/** Controlled state. Pair it with `onStateChange`. */
|
|
55
|
+
state?: ConfirmMorphState;
|
|
56
|
+
/** Starting state when uncontrolled. */
|
|
57
|
+
defaultState?: ConfirmMorphState;
|
|
58
|
+
onStateChange?: (state: ConfirmMorphState) => void;
|
|
59
|
+
/** Milliseconds before an unanswered question returns to rest. Resting the pointer on the control pauses it. 0 turns it off. */
|
|
60
|
+
confirmTimeout?: number;
|
|
61
|
+
/** Milliseconds a result stays before returning to rest. Resting the pointer on the control pauses it. 0 turns it off. */
|
|
62
|
+
resultTimeout?: number;
|
|
63
|
+
/** A press outside the control cancels an open question. Defaults to true. */
|
|
64
|
+
cancelOnOutsidePress?: boolean;
|
|
65
|
+
isDisabled?: boolean;
|
|
66
|
+
/** Extra classes for the root. Merged last, so they win conflicts with ours. */
|
|
67
|
+
className?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* A button for an action that deserves a second thought, without a dialog. It
|
|
71
|
+
* asks in place: the pill morphs into a question with Cancel and Confirm, then
|
|
72
|
+
* a spinner, then a result with Undo, its width springing to each face while the
|
|
73
|
+
* faces crossfade at their natural width.
|
|
74
|
+
*
|
|
75
|
+
* Escape, a press outside, or the timeout answer the question with no. Focus
|
|
76
|
+
* follows the control between faces, but only when it was already inside, so a
|
|
77
|
+
* timeout never steals it. A live region announces each step.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* <ConfirmMorph label="Delete project" onConfirm={() => deleteProject()} onUndo={() => restore()} />
|
|
81
|
+
* <ConfirmMorph label="Delete project" confirmMode="hold" onConfirm={deleteProject} />
|
|
82
|
+
*/
|
|
83
|
+
export declare const ConfirmMorph: import("react").ForwardRefExoticComponent<ConfirmMorphProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
84
|
+
//#endregion
|
|
85
|
+
//# sourceMappingURL=confirm-morph.d.ts.map
|