@eifi1/ui-kit 0.15.4 → 0.16.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 +20 -15
- package/dist/chart.d.ts +3 -4
- package/dist/components/alert-banner.js +1 -1
- package/dist/components/alert-banner.js.map +1 -1
- package/dist/components/amount-input.d.ts +13 -4
- package/dist/components/amount-input.js +166 -157
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/authed-image.d.ts +14 -3
- package/dist/components/authed-image.js +32 -23
- package/dist/components/authed-image.js.map +1 -1
- package/dist/components/button-group.d.ts +3 -4
- package/dist/components/calculator.d.ts +3 -4
- package/dist/components/checkbox.js +1 -1
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/choice-card.js +1 -1
- package/dist/components/choice-card.js.map +1 -1
- package/dist/components/copy-button.d.ts +3 -4
- package/dist/components/error-boundary.js +1 -1
- package/dist/components/error-boundary.js.map +1 -1
- package/dist/components/facing-pair.d.ts +3 -4
- package/dist/components/file-button.d.ts +3 -4
- package/dist/components/file-button.js +64 -31
- package/dist/components/file-button.js.map +1 -1
- package/dist/components/file-dropzone.d.ts +3 -4
- package/dist/components/file-dropzone.js +1 -1
- package/dist/components/file-dropzone.js.map +1 -1
- package/dist/components/form-actions.d.ts +4 -5
- package/dist/components/form-actions.js +18 -6
- package/dist/components/form-actions.js.map +1 -1
- package/dist/components/line-items.d.ts +53 -2
- package/dist/components/line-items.js +73 -7
- package/dist/components/line-items.js.map +1 -1
- package/dist/components/list.d.ts +99 -5
- package/dist/components/list.js +103 -38
- package/dist/components/list.js.map +1 -1
- package/dist/components/loading-state.d.ts +19 -3
- package/dist/components/loading-state.js +14 -3
- package/dist/components/loading-state.js.map +1 -1
- package/dist/components/money-field.d.ts +3 -4
- package/dist/components/number-field.d.ts +3 -4
- package/dist/components/number-input.d.ts +3 -4
- package/dist/components/number-input.js +4 -2
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/numpad-sheet.d.ts +3 -4
- package/dist/components/passkeys-setting.d.ts +30 -10
- package/dist/components/passkeys-setting.js +19 -11
- package/dist/components/passkeys-setting.js.map +1 -1
- package/dist/components/progress-bar.d.ts +12 -3
- package/dist/components/progress-bar.js +21 -11
- package/dist/components/progress-bar.js.map +1 -1
- package/dist/components/series-chart.d.ts +3 -4
- package/dist/components/settings-fields.d.ts +3 -4
- package/dist/components/signed-amount.d.ts +28 -4
- package/dist/components/signed-amount.js +17 -8
- package/dist/components/signed-amount.js.map +1 -1
- package/dist/components/stat-tile.d.ts +31 -2
- package/dist/components/stat-tile.js +37 -6
- package/dist/components/stat-tile.js.map +1 -1
- package/dist/components/status-dot.d.ts +4 -1
- package/dist/components/status-dot.js +20 -1
- package/dist/components/status-dot.js.map +1 -1
- package/dist/components/swatch-picker.d.ts +3 -1
- package/dist/components/swatch-picker.js.map +1 -1
- package/dist/components/table.d.ts +18 -13
- package/dist/components/table.js +20 -5
- package/dist/components/table.js.map +1 -1
- package/dist/components/text-link.d.ts +3 -4
- package/dist/components/time-input.d.ts +3 -4
- package/dist/components/toggle-legend.d.ts +12 -1
- package/dist/components/toggle-legend.js +6 -2
- package/dist/components/toggle-legend.js.map +1 -1
- package/dist/components/ui.d.ts +3 -4
- package/dist/components/ui.js +156 -52
- package/dist/components/ui.js.map +1 -1
- package/dist/feedback/feedback-attachment.d.ts +2 -82
- package/dist/feedback/feedback-attachment.js +285 -55
- package/dist/feedback/feedback-attachment.js.map +1 -1
- package/dist/feedback/feedback-dialog.d.ts +2 -105
- package/dist/feedback/feedback-dialog.js +57 -25
- package/dist/feedback/feedback-dialog.js.map +1 -1
- package/dist/feedback/feedback-inbox.d.ts +1 -1
- package/dist/feedback/feedback-thread.d.ts +2 -2
- package/dist/feedback-attachment-WFiXJ8We.d.ts +302 -0
- package/dist/feedback.d.ts +1 -2
- package/dist/hooks/use-file-drop.d.ts +3 -4
- package/dist/i18n/defaults.d.ts +3 -4
- package/dist/i18n/kit-labels.d.ts +2 -3
- package/dist/i18n/locales/de-CH-informal.d.ts +3 -4
- package/dist/i18n/locales/de-CH.d.ts +3 -4
- package/dist/i18n/locales/de-informal.d.ts +3 -4
- package/dist/i18n/locales/de.d.ts +3 -4
- package/dist/i18n/locales/de.js +5 -1
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +3 -4
- package/dist/i18n/locales/es.js +5 -1
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +3 -4
- package/dist/i18n/locales/fr.js +5 -1
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +3 -4
- package/dist/i18n/locales/hu.js +5 -1
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +3 -4
- package/dist/i18n/locales/it.js +5 -1
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +3 -4
- package/dist/i18n/locales/zh.js +5 -1
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/index.d.ts +10 -11
- package/dist/{kit-labels-CnnBd-2N.d.ts → kit-labels-DE--LmCk.d.ts} +154 -14
- package/dist/lib/format.d.ts +18 -3
- package/dist/lib/format.js +2 -1
- package/dist/lib/format.js.map +1 -1
- package/dist/rhf/fields.d.ts +3 -4
- package/dist/rhf/form.d.ts +3 -4
- package/dist/rhf/line-items.js.map +1 -1
- package/dist/rhf.d.ts +3 -4
- package/dist/shell/app-shell.d.ts +3 -4
- package/dist/shell/top-bar-brand.d.ts +3 -4
- package/dist/shell.d.ts +3 -4
- package/dist/theme/palette-derive.d.ts +3 -0
- package/dist/theme/palette-derive.js +7 -0
- package/dist/theme/palette-derive.js.map +1 -1
- package/dist/wizard/stepper-nav.d.ts +3 -4
- package/dist/wizard.d.ts +3 -4
- package/package.json +4 -2
- package/src/components/alert-banner.tsx +1 -1
- package/src/components/amount-input.tsx +47 -16
- package/src/components/authed-image.tsx +20 -2
- package/src/components/checkbox.tsx +1 -1
- package/src/components/choice-card.tsx +1 -1
- package/src/components/error-boundary.tsx +1 -1
- package/src/components/file-button.tsx +77 -27
- package/src/components/file-dropzone.tsx +1 -1
- package/src/components/form-actions.tsx +86 -8
- package/src/components/line-items.tsx +131 -14
- package/src/components/list.tsx +240 -50
- package/src/components/loading-state.tsx +35 -4
- package/src/components/number-input.tsx +18 -2
- package/src/components/passkeys-setting.tsx +45 -18
- package/src/components/progress-bar.tsx +46 -21
- package/src/components/signed-amount.tsx +47 -8
- package/src/components/stat-tile.tsx +76 -6
- package/src/components/status-dot.tsx +31 -0
- package/src/components/swatch-picker.tsx +3 -1
- package/src/components/table.tsx +42 -15
- package/src/components/toggle-legend.tsx +21 -4
- package/src/components/ui.tsx +280 -70
- package/src/feedback/feedback-attachment.tsx +472 -96
- package/src/feedback/feedback-dialog.tsx +162 -50
- package/src/i18n/locales/de.ts +4 -0
- package/src/i18n/locales/es.ts +4 -0
- package/src/i18n/locales/fr.ts +4 -0
- package/src/i18n/locales/hu.ts +4 -0
- package/src/i18n/locales/it.ts +4 -0
- package/src/i18n/locales/zh.ts +4 -0
- package/src/lib/format.ts +24 -3
- package/src/rhf/line-items.tsx +6 -0
- package/src/theme/palette-derive.ts +10 -0
- package/tokens.css +9 -1
|
@@ -31,8 +31,18 @@ interface AuthedImageProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, "sr
|
|
|
31
31
|
link?: boolean;
|
|
32
32
|
/** Replaces the default skeleton while loading. */
|
|
33
33
|
loadingFallback?: ReactNode;
|
|
34
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Replaces the default "couldn't load" tile. `null` renders nothing in its place —
|
|
36
|
+
* an optional photo slot that simply stays empty; only `undefined` (left out) means
|
|
37
|
+
* the default tile.
|
|
38
|
+
*/
|
|
35
39
|
errorFallback?: ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* Keep a click on the image (and the Enter that follows its `link`) from reaching an
|
|
42
|
+
* ancestor — a thumbnail in a DataTable row or a clickable card opens itself instead
|
|
43
|
+
* of also running the row's action. As TextLink's and IconButton's `stopPropagation`.
|
|
44
|
+
*/
|
|
45
|
+
stopPropagation?: boolean;
|
|
36
46
|
labels?: Partial<AuthedImageLabels>;
|
|
37
47
|
}
|
|
38
48
|
/**
|
|
@@ -45,13 +55,13 @@ interface AuthedImageProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, "sr
|
|
|
45
55
|
* browser failing to decode what arrived (`onError` on the `<img>`, e.g. a PDF served
|
|
46
56
|
* where an image was expected).
|
|
47
57
|
*/
|
|
48
|
-
declare function AuthedImage({ src, alt, fetcher, wrapperClassName, className, link, loadingFallback, errorFallback, labels: labelsProp, onLoad, onError, ...rest }: AuthedImageProps): react.JSX.Element;
|
|
58
|
+
declare function AuthedImage({ src, alt, fetcher, wrapperClassName, className, link, loadingFallback, errorFallback, stopPropagation, labels: labelsProp, onLoad, onError, ...rest }: AuthedImageProps): react.JSX.Element;
|
|
49
59
|
/**
|
|
50
60
|
* The rendering half of {@link AuthedImage}, for a caller that already holds a
|
|
51
61
|
* {@link useAuthedSrc} result (the lightbox needs the object URL for its download link
|
|
52
62
|
* as well). Internal to the package.
|
|
53
63
|
*/
|
|
54
|
-
declare function ImageStates({ fetched, alt, labels, className, wrapperClassName, link, loadingFallback, errorFallback, imgProps, onLoad, onError, }: {
|
|
64
|
+
declare function ImageStates({ fetched, alt, labels, className, wrapperClassName, link, loadingFallback, errorFallback, stopPropagation, imgProps, onLoad, onError, }: {
|
|
55
65
|
fetched: UseAuthedSrcResult;
|
|
56
66
|
alt: string;
|
|
57
67
|
labels: AuthedImageLabels;
|
|
@@ -60,6 +70,7 @@ declare function ImageStates({ fetched, alt, labels, className, wrapperClassName
|
|
|
60
70
|
link?: boolean;
|
|
61
71
|
loadingFallback?: ReactNode;
|
|
62
72
|
errorFallback?: ReactNode;
|
|
73
|
+
stopPropagation?: boolean;
|
|
63
74
|
imgProps?: Omit<ImgHTMLAttributes<HTMLImageElement>, "src" | "alt" | "children" | "onLoad" | "onError">;
|
|
64
75
|
onLoad?: ImgHTMLAttributes<HTMLImageElement>["onLoad"];
|
|
65
76
|
onError?: ImgHTMLAttributes<HTMLImageElement>["onError"];
|
|
@@ -20,6 +20,7 @@ function AuthedImage({
|
|
|
20
20
|
link,
|
|
21
21
|
loadingFallback,
|
|
22
22
|
errorFallback,
|
|
23
|
+
stopPropagation,
|
|
23
24
|
labels: labelsProp,
|
|
24
25
|
onLoad,
|
|
25
26
|
onError,
|
|
@@ -38,6 +39,7 @@ function AuthedImage({
|
|
|
38
39
|
link,
|
|
39
40
|
loadingFallback,
|
|
40
41
|
errorFallback,
|
|
42
|
+
stopPropagation,
|
|
41
43
|
imgProps: rest,
|
|
42
44
|
onLoad,
|
|
43
45
|
onError
|
|
@@ -53,6 +55,7 @@ function ImageStates({
|
|
|
53
55
|
link,
|
|
54
56
|
loadingFallback,
|
|
55
57
|
errorFallback,
|
|
58
|
+
stopPropagation,
|
|
56
59
|
imgProps,
|
|
57
60
|
onLoad,
|
|
58
61
|
onError
|
|
@@ -84,29 +87,35 @@ function ImageStates({
|
|
|
84
87
|
)
|
|
85
88
|
}
|
|
86
89
|
);
|
|
87
|
-
return
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
"
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
{
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
90
|
+
return (
|
|
91
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions -- not an interaction: only fences the image's own clicks off from an ancestor's handler
|
|
92
|
+
/* @__PURE__ */ jsxs(
|
|
93
|
+
"span",
|
|
94
|
+
{
|
|
95
|
+
onClick: stopPropagation ? (e) => e.stopPropagation() : void 0,
|
|
96
|
+
onKeyDown: stopPropagation ? (e) => e.key === "Enter" && e.stopPropagation() : void 0,
|
|
97
|
+
"data-image-state": failed ? "error" : waiting ? "loading" : fetched.status === "idle" ? "idle" : "ready",
|
|
98
|
+
className: cn("relative block overflow-hidden", wrapperClassName),
|
|
99
|
+
"aria-busy": waiting || void 0,
|
|
100
|
+
children: [
|
|
101
|
+
link && img && fetched.src ? /* @__PURE__ */ jsx("a", { href: fetched.src, target: "_blank", rel: "noreferrer noopener", className: "block h-full w-full", children: img }) : img,
|
|
102
|
+
waiting && (loadingFallback ?? /* @__PURE__ */ jsx("span", { className: cn(SKELETON_CLASS, "absolute inset-0 block rounded-none"), children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: labels.loading }) })),
|
|
103
|
+
failed && // `=== undefined`, not `??`: `null` is the caller asking for nothing at all.
|
|
104
|
+
(errorFallback !== void 0 ? errorFallback : /* @__PURE__ */ jsxs(
|
|
105
|
+
"span",
|
|
106
|
+
{
|
|
107
|
+
role: "img",
|
|
108
|
+
"aria-label": alt ? labels.failedImage(alt) : labels.loadError,
|
|
109
|
+
className: "flex h-full min-h-16 w-full flex-col items-center justify-center gap-1 bg-[var(--bg-hover)] p-2 text-center text-xs text-[var(--text-muted)]",
|
|
110
|
+
children: [
|
|
111
|
+
/* @__PURE__ */ jsx(ImageOff, { "aria-hidden": true, className: "size-5 shrink-0" }),
|
|
112
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "line-clamp-2", children: labels.loadError })
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
))
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
)
|
|
110
119
|
);
|
|
111
120
|
}
|
|
112
121
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/authed-image.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ImgHTMLAttributes, ReactNode } from \"react\";\nimport { ImageOff } from \"lucide-react\";\n\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { SKELETON_CLASS } from \"./skeleton\";\nimport { useAuthedSrc } from \"../hooks/use-authed-src\";\nimport type { AuthedFetcher, UseAuthedSrcResult } from \"../hooks/use-authed-src\";\n\n/** The two states an image can be in besides \"there\". */\nexport interface AuthedImageLabels {\n /** Read out while the bytes are on their way (the skeleton itself is silent). */\n loading: string;\n /** Shown, small, in place of an image that could not be fetched or decoded. */\n loadError: string;\n /** The failed tile's accessible name, given the image's alt. */\n failedImage: (alt: string) => string;\n}\n\nexport const DEFAULT_AUTHED_IMAGE_LABELS: AuthedImageLabels = {\n loading: \"Loading image…\",\n loadError: \"Image couldn’t be loaded\",\n failedImage: (alt) => `${alt}: image couldn’t be loaded`,\n};\n\nexport interface AuthedImageProps\n extends Omit<ImgHTMLAttributes<HTMLImageElement>, \"src\" | \"alt\" | \"children\"> {\n /** The image's URL — an API path when a {@link fetcher} is given. */\n src: string | null | undefined;\n /** Required: an image without a text alternative is a gap a reader falls into.\n * `\"\"` for a purely decorative one. */\n alt: string;\n /** The app's authenticated GET (see {@link useAuthedSrc}). Left out, `src` is loaded\n * by the browser as usual and this is an `<img>` with loading and error states. */\n fetcher?: AuthedFetcher | null;\n /** Classes for the box around the image (the placeholders fill it). */\n wrapperClassName?: string;\n /**\n * Wrap the image in a link to itself, opening in a new tab — kastlan's\n * `AuthedImage` did, because an object URL is the only address of a protected image\n * a browser tab can open. The link's href is the `blob:` URL, never the API path.\n */\n link?: boolean;\n /** Replaces the default skeleton while loading. */\n loadingFallback?: ReactNode;\n /** Replaces the default \"couldn't load\" tile. */\n errorFallback?: ReactNode;\n labels?: Partial<AuthedImageLabels>;\n}\n\n/**\n * An image with a loading state, an error state and — given a `fetcher` — the app's\n * authentication. Replaces kastlan's `shared/components/authed-image.tsx`, which\n * rendered NOTHING until the blob arrived and nothing at all if it never did: a card\n * with a photo slot either had the photo or was silently shorter.\n *\n * Two failures are one state here: the fetch failing (401, 404, offline) and the\n * browser failing to decode what arrived (`onError` on the `<img>`, e.g. a PDF served\n * where an image was expected).\n */\nexport function AuthedImage({\n src,\n alt,\n fetcher,\n wrapperClassName,\n className,\n link,\n loadingFallback,\n errorFallback,\n labels: labelsProp,\n onLoad,\n onError,\n ...rest\n}: AuthedImageProps) {\n const labels = useKitLabels(\"authedImage\", DEFAULT_AUTHED_IMAGE_LABELS, labelsProp);\n const fetched = useAuthedSrc(src, { fetcher });\n return (\n <ImageStates\n fetched={fetched}\n alt={alt}\n labels={labels}\n className={className}\n wrapperClassName={wrapperClassName}\n link={link}\n loadingFallback={loadingFallback}\n errorFallback={errorFallback}\n imgProps={rest}\n onLoad={onLoad}\n onError={onError}\n />\n );\n}\n\n/**\n * The rendering half of {@link AuthedImage}, for a caller that already holds a\n * {@link useAuthedSrc} result (the lightbox needs the object URL for its download link\n * as well). Internal to the package.\n */\nexport function ImageStates({\n fetched,\n alt,\n labels,\n className,\n wrapperClassName,\n link,\n loadingFallback,\n errorFallback,\n imgProps,\n onLoad,\n onError,\n}: {\n fetched: UseAuthedSrcResult;\n alt: string;\n labels: AuthedImageLabels;\n className?: string;\n wrapperClassName?: string;\n link?: boolean;\n loadingFallback?: ReactNode;\n errorFallback?: ReactNode;\n imgProps?: Omit<ImgHTMLAttributes<HTMLImageElement>, \"src\" | \"alt\" | \"children\" | \"onLoad\" | \"onError\">;\n onLoad?: ImgHTMLAttributes<HTMLImageElement>[\"onLoad\"];\n onError?: ImgHTMLAttributes<HTMLImageElement>[\"onError\"];\n}) {\n // Decode state, per src: keyed so a new picture starts over rather than inheriting\n // the previous one's \"loaded\" or \"broken\".\n const [decode, setDecode] = useState<{ src: string | null; state: \"loaded\" | \"error\" } | null>(null);\n const decoded = decode && decode.src === fetched.src ? decode.state : \"pending\";\n const failed = fetched.status === \"error\" || decoded === \"error\";\n const waiting = !failed && (fetched.status === \"loading\" || (fetched.src !== null && decoded === \"pending\"));\n\n const img = fetched.src !== null && !failed && (\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- load/error are resource events, not interactions\n <img\n {...imgProps}\n src={fetched.src}\n alt={alt}\n onLoad={(e) => {\n setDecode({ src: fetched.src, state: \"loaded\" });\n onLoad?.(e);\n }}\n onError={(e) => {\n setDecode({ src: fetched.src, state: \"error\" });\n onError?.(e);\n }}\n className={cn(\n // Kept in the tree while it decodes (the browser needs it there to load at\n // all), but invisible, so the skeleton is what shows.\n decoded === \"pending\" && \"opacity-0\",\n className,\n )}\n />\n );\n\n return (\n <span\n data-image-state={failed ? \"error\" : waiting ? \"loading\" : fetched.status === \"idle\" ? \"idle\" : \"ready\"}\n className={cn(\"relative block overflow-hidden\", wrapperClassName)}\n aria-busy={waiting || undefined}\n >\n {link && img && fetched.src ? (\n <a href={fetched.src} target=\"_blank\" rel=\"noreferrer noopener\" className=\"block h-full w-full\">\n {img}\n </a>\n ) : (\n img\n )}\n {waiting &&\n (loadingFallback ?? (\n <span className={cn(SKELETON_CLASS, \"absolute inset-0 block rounded-none\")}>\n <span className=\"sr-only\">{labels.loading}</span>\n </span>\n ))}\n {failed &&\n (errorFallback ?? (\n <span\n // `role=\"img\"` with the alt as its name: the picture that failed still\n // occupies its place in the reading order, and \"couldn't be loaded\" is\n // the one fact a reader needs about it.\n role=\"img\"\n aria-label={alt ? labels.failedImage(alt) : labels.loadError}\n className=\"flex h-full min-h-16 w-full flex-col items-center justify-center gap-1 bg-[var(--bg-hover)] p-2 text-center text-xs text-[var(--text-muted)]\"\n >\n <ImageOff aria-hidden className=\"size-5 shrink-0\" />\n <span aria-hidden className=\"line-clamp-2\">{labels.loadError}</span>\n </span>\n ))}\n </span>\n );\n}\n"],"mappings":";AA8EI,cAiGM,YAjGN;AA9EJ,SAAS,gBAAgB;AAEzB,SAAS,gBAAgB;AAEzB,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAatB,MAAM,8BAAiD;AAAA,EAC5D,SAAS;AAAA,EACT,WAAW;AAAA,EACX,aAAa,CA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AAA,MACA,WAAW;AAAA;AAAA;AAAA,QAGT,YAAY,aAAa;AAAA,QACzB;AAAA,MACF;AAAA;AAAA,EACF;AAGF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,oBAAkB,SAAS,UAAU,UAAU,YAAY,QAAQ,WAAW,SAAS,SAAS;AAAA,MAChG,WAAW,GAAG,kCAAkC,gBAAgB;AAAA,MAChE,aAAW,WAAW;AAAA,MAErB;AAAA,gBAAQ,OAAO,QAAQ,MACtB,oBAAC,OAAE,MAAM,QAAQ,KAAK,QAAO,UAAS,KAAI,uBAAsB,WAAU,uBACvE,eACH,IAEA;AAAA,QAED,YACE,mBACC,oBAAC,UAAK,WAAW,GAAG,gBAAgB,qCAAqC,GACvE,8BAAC,UAAK,WAAU,WAAW,iBAAO,SAAQ,GAC5C;AAAA,QAEH,WACE,iBACC;AAAA,UAAC;AAAA;AAAA,YAIC,MAAK;AAAA,YACL,cAAY,MAAM,OAAO,YAAY,GAAG,IAAI,OAAO;AAAA,YACnD,WAAU;AAAA,YAEV;AAAA,kCAAC,YAAS,eAAW,MAAC,WAAU,mBAAkB;AAAA,cAClD,oBAAC,UAAK,eAAW,MAAC,WAAU,gBAAgB,iBAAO,WAAU;AAAA;AAAA;AAAA,QAC/D;AAAA;AAAA;AAAA,EAEN;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/authed-image.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ImgHTMLAttributes, ReactNode } from \"react\";\nimport { ImageOff } from \"lucide-react\";\n\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { SKELETON_CLASS } from \"./skeleton\";\nimport { useAuthedSrc } from \"../hooks/use-authed-src\";\nimport type { AuthedFetcher, UseAuthedSrcResult } from \"../hooks/use-authed-src\";\n\n/** The two states an image can be in besides \"there\". */\nexport interface AuthedImageLabels {\n /** Read out while the bytes are on their way (the skeleton itself is silent). */\n loading: string;\n /** Shown, small, in place of an image that could not be fetched or decoded. */\n loadError: string;\n /** The failed tile's accessible name, given the image's alt. */\n failedImage: (alt: string) => string;\n}\n\nexport const DEFAULT_AUTHED_IMAGE_LABELS: AuthedImageLabels = {\n loading: \"Loading image…\",\n loadError: \"Image couldn’t be loaded\",\n failedImage: (alt) => `${alt}: image couldn’t be loaded`,\n};\n\nexport interface AuthedImageProps\n extends Omit<ImgHTMLAttributes<HTMLImageElement>, \"src\" | \"alt\" | \"children\"> {\n /** The image's URL — an API path when a {@link fetcher} is given. */\n src: string | null | undefined;\n /** Required: an image without a text alternative is a gap a reader falls into.\n * `\"\"` for a purely decorative one. */\n alt: string;\n /** The app's authenticated GET (see {@link useAuthedSrc}). Left out, `src` is loaded\n * by the browser as usual and this is an `<img>` with loading and error states. */\n fetcher?: AuthedFetcher | null;\n /** Classes for the box around the image (the placeholders fill it). */\n wrapperClassName?: string;\n /**\n * Wrap the image in a link to itself, opening in a new tab — kastlan's\n * `AuthedImage` did, because an object URL is the only address of a protected image\n * a browser tab can open. The link's href is the `blob:` URL, never the API path.\n */\n link?: boolean;\n /** Replaces the default skeleton while loading. */\n loadingFallback?: ReactNode;\n /**\n * Replaces the default \"couldn't load\" tile. `null` renders nothing in its place —\n * an optional photo slot that simply stays empty; only `undefined` (left out) means\n * the default tile.\n */\n errorFallback?: ReactNode;\n /**\n * Keep a click on the image (and the Enter that follows its `link`) from reaching an\n * ancestor — a thumbnail in a DataTable row or a clickable card opens itself instead\n * of also running the row's action. As TextLink's and IconButton's `stopPropagation`.\n */\n stopPropagation?: boolean;\n labels?: Partial<AuthedImageLabels>;\n}\n\n/**\n * An image with a loading state, an error state and — given a `fetcher` — the app's\n * authentication. Replaces kastlan's `shared/components/authed-image.tsx`, which\n * rendered NOTHING until the blob arrived and nothing at all if it never did: a card\n * with a photo slot either had the photo or was silently shorter.\n *\n * Two failures are one state here: the fetch failing (401, 404, offline) and the\n * browser failing to decode what arrived (`onError` on the `<img>`, e.g. a PDF served\n * where an image was expected).\n */\nexport function AuthedImage({\n src,\n alt,\n fetcher,\n wrapperClassName,\n className,\n link,\n loadingFallback,\n errorFallback,\n stopPropagation,\n labels: labelsProp,\n onLoad,\n onError,\n ...rest\n}: AuthedImageProps) {\n const labels = useKitLabels(\"authedImage\", DEFAULT_AUTHED_IMAGE_LABELS, labelsProp);\n const fetched = useAuthedSrc(src, { fetcher });\n return (\n <ImageStates\n fetched={fetched}\n alt={alt}\n labels={labels}\n className={className}\n wrapperClassName={wrapperClassName}\n link={link}\n loadingFallback={loadingFallback}\n errorFallback={errorFallback}\n stopPropagation={stopPropagation}\n imgProps={rest}\n onLoad={onLoad}\n onError={onError}\n />\n );\n}\n\n/**\n * The rendering half of {@link AuthedImage}, for a caller that already holds a\n * {@link useAuthedSrc} result (the lightbox needs the object URL for its download link\n * as well). Internal to the package.\n */\nexport function ImageStates({\n fetched,\n alt,\n labels,\n className,\n wrapperClassName,\n link,\n loadingFallback,\n errorFallback,\n stopPropagation,\n imgProps,\n onLoad,\n onError,\n}: {\n fetched: UseAuthedSrcResult;\n alt: string;\n labels: AuthedImageLabels;\n className?: string;\n wrapperClassName?: string;\n link?: boolean;\n loadingFallback?: ReactNode;\n errorFallback?: ReactNode;\n stopPropagation?: boolean;\n imgProps?: Omit<ImgHTMLAttributes<HTMLImageElement>, \"src\" | \"alt\" | \"children\" | \"onLoad\" | \"onError\">;\n onLoad?: ImgHTMLAttributes<HTMLImageElement>[\"onLoad\"];\n onError?: ImgHTMLAttributes<HTMLImageElement>[\"onError\"];\n}) {\n // Decode state, per src: keyed so a new picture starts over rather than inheriting\n // the previous one's \"loaded\" or \"broken\".\n const [decode, setDecode] = useState<{ src: string | null; state: \"loaded\" | \"error\" } | null>(null);\n const decoded = decode && decode.src === fetched.src ? decode.state : \"pending\";\n const failed = fetched.status === \"error\" || decoded === \"error\";\n const waiting = !failed && (fetched.status === \"loading\" || (fetched.src !== null && decoded === \"pending\"));\n\n const img = fetched.src !== null && !failed && (\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- load/error are resource events, not interactions\n <img\n {...imgProps}\n src={fetched.src}\n alt={alt}\n onLoad={(e) => {\n setDecode({ src: fetched.src, state: \"loaded\" });\n onLoad?.(e);\n }}\n onError={(e) => {\n setDecode({ src: fetched.src, state: \"error\" });\n onError?.(e);\n }}\n className={cn(\n // Kept in the tree while it decodes (the browser needs it there to load at\n // all), but invisible, so the skeleton is what shows.\n decoded === \"pending\" && \"opacity-0\",\n className,\n )}\n />\n );\n\n return (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- not an interaction: only fences the image's own clicks off from an ancestor's handler\n <span\n onClick={stopPropagation ? (e) => e.stopPropagation() : undefined}\n onKeyDown={stopPropagation ? (e) => e.key === \"Enter\" && e.stopPropagation() : undefined}\n data-image-state={failed ? \"error\" : waiting ? \"loading\" : fetched.status === \"idle\" ? \"idle\" : \"ready\"}\n className={cn(\"relative block overflow-hidden\", wrapperClassName)}\n aria-busy={waiting || undefined}\n >\n {link && img && fetched.src ? (\n <a href={fetched.src} target=\"_blank\" rel=\"noreferrer noopener\" className=\"block h-full w-full\">\n {img}\n </a>\n ) : (\n img\n )}\n {waiting &&\n (loadingFallback ?? (\n <span className={cn(SKELETON_CLASS, \"absolute inset-0 block rounded-none\")}>\n <span className=\"sr-only\">{labels.loading}</span>\n </span>\n ))}\n {failed &&\n // `=== undefined`, not `??`: `null` is the caller asking for nothing at all.\n (errorFallback !== undefined ? errorFallback : (\n <span\n // `role=\"img\"` with the alt as its name: the picture that failed still\n // occupies its place in the reading order, and \"couldn't be loaded\" is\n // the one fact a reader needs about it.\n role=\"img\"\n aria-label={alt ? labels.failedImage(alt) : labels.loadError}\n className=\"flex h-full min-h-16 w-full flex-col items-center justify-center gap-1 bg-[var(--bg-hover)] p-2 text-center text-xs text-[var(--text-muted)]\"\n >\n <ImageOff aria-hidden className=\"size-5 shrink-0\" />\n <span aria-hidden className=\"line-clamp-2\">{labels.loadError}</span>\n </span>\n ))}\n </span>\n );\n}\n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;AAAA,IAEN;AAAA;AAEJ;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ComponentPropsWithoutRef, ReactNode, Ref, MouseEvent, ReactElement } from 'react';
|
|
3
|
-
import { f as ButtonVariant, d as ButtonSize } from '../kit-labels-
|
|
3
|
+
import { f as ButtonVariant, d as ButtonSize } from '../kit-labels-DE--LmCk.js';
|
|
4
4
|
import './data-table-labels.js';
|
|
5
5
|
import './mini-calendar.js';
|
|
6
6
|
import './calendar-heatmap.js';
|
|
@@ -32,8 +32,7 @@ import './dialog-frame.js';
|
|
|
32
32
|
import './modal.js';
|
|
33
33
|
import '../hooks/use-search-param-state.js';
|
|
34
34
|
import './measured-grid.js';
|
|
35
|
-
import '../feedback
|
|
36
|
-
import '../feedback/feedback-dialog.js';
|
|
35
|
+
import '../feedback-attachment-WFiXJ8We.js';
|
|
37
36
|
import '../feedback/feedback-thread.js';
|
|
38
37
|
import '../feedback/feedback-inbox.js';
|
|
39
38
|
import './account-settings-labels.js';
|
|
@@ -41,12 +40,12 @@ import './confirm-dialog.js';
|
|
|
41
40
|
import './floating-panel.js';
|
|
42
41
|
import './bulk-action-bar.js';
|
|
43
42
|
import './list.js';
|
|
43
|
+
import './signed-amount.js';
|
|
44
44
|
import './breadcrumbs.js';
|
|
45
45
|
import './toast.js';
|
|
46
46
|
import './description-list.js';
|
|
47
47
|
import './line-items.js';
|
|
48
48
|
import './progress-bar.js';
|
|
49
|
-
import './signed-amount.js';
|
|
50
49
|
import './error-boundary.js';
|
|
51
50
|
import './authed-image.js';
|
|
52
51
|
import '../hooks/use-authed-src.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { C as CalculatorLabels } from '../kit-labels-
|
|
2
|
+
import { C as CalculatorLabels } from '../kit-labels-DE--LmCk.js';
|
|
3
3
|
import './data-table-labels.js';
|
|
4
4
|
import './mini-calendar.js';
|
|
5
5
|
import './calendar-heatmap.js';
|
|
@@ -31,8 +31,7 @@ import './dialog-frame.js';
|
|
|
31
31
|
import './modal.js';
|
|
32
32
|
import '../hooks/use-search-param-state.js';
|
|
33
33
|
import './measured-grid.js';
|
|
34
|
-
import '../feedback
|
|
35
|
-
import '../feedback/feedback-dialog.js';
|
|
34
|
+
import '../feedback-attachment-WFiXJ8We.js';
|
|
36
35
|
import '../feedback/feedback-thread.js';
|
|
37
36
|
import '../feedback/feedback-inbox.js';
|
|
38
37
|
import './account-settings-labels.js';
|
|
@@ -40,12 +39,12 @@ import './confirm-dialog.js';
|
|
|
40
39
|
import './floating-panel.js';
|
|
41
40
|
import './bulk-action-bar.js';
|
|
42
41
|
import './list.js';
|
|
42
|
+
import './signed-amount.js';
|
|
43
43
|
import './breadcrumbs.js';
|
|
44
44
|
import './toast.js';
|
|
45
45
|
import './description-list.js';
|
|
46
46
|
import './line-items.js';
|
|
47
47
|
import './progress-bar.js';
|
|
48
|
-
import './signed-amount.js';
|
|
49
48
|
import './error-boundary.js';
|
|
50
49
|
import './authed-image.js';
|
|
51
50
|
import '../hooks/use-authed-src.js';
|
|
@@ -6,7 +6,7 @@ import { cn } from "../lib/cn.js";
|
|
|
6
6
|
import { assignRef, hasMessage, mergeDescribedBy } from "./choice-parts.js";
|
|
7
7
|
const BOX = "peer size-4 shrink-0 cursor-pointer appearance-none rounded-[4px] border border-[var(--border-strong)] bg-[var(--bg-surface)] shadow-sm transition-colors checked:border-[var(--brand)] checked:bg-[var(--brand)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-1 focus-visible:ring-offset-[var(--bg-surface)] disabled:cursor-not-allowed";
|
|
8
8
|
const BOX_MIXED = "border-[var(--brand)] bg-[var(--brand)]";
|
|
9
|
-
const BOX_INVALID = "border-[var(--danger-border)] ring-1 ring-[var(--danger-border)] checked:border-[var(--danger-border)] focus-visible:ring-[var(--danger)]";
|
|
9
|
+
const BOX_INVALID = "border-[var(--danger-border-strong)] ring-1 ring-[var(--danger-border-strong)] checked:border-[var(--danger-border-strong)] focus-visible:ring-[var(--danger)]";
|
|
10
10
|
const ERROR_CLASS = "mt-1 text-[11px] leading-tight text-[var(--danger)]";
|
|
11
11
|
const Checkbox = forwardRef(function Checkbox2({
|
|
12
12
|
label,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/checkbox.tsx"],"sourcesContent":["import { forwardRef, useCallback, useEffect, useId, useRef } from \"react\";\nimport { Check, Minus } from \"lucide-react\";\nimport type { ChangeEvent, InputHTMLAttributes, ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { assignRef, hasMessage, mergeDescribedBy } from \"./choice-parts\";\n\n/**\n * A checkbox that is still `<input type=\"checkbox\">`.\n *\n * The three consuming apps had three answers: ~30 raw inputs in Keksdose leaning on\n * `tokens.css`'s `accent-color`, a label-plus-box `CheckboxField` in Lenkbank, and a\n * Radix `<button role=\"checkbox\">` in Kastlan. The native element is the one that\n * needs no ARIA to be a checkbox — it submits with its form, answers to `required`,\n * resets with the form and takes a `<label for>` click — so it stays underneath, and\n * only its paint is replaced (`appearance-none`, a token-coloured box, and a glyph\n * laid over it that ignores the pointer so the click still lands on the input).\n *\n * `accent-color` alone was not enough: it tints the native box but cannot change its\n * border, so an INVALID checkbox had no way to say so, and the unchecked box kept the\n * browser's own grey outline in both themes.\n */\n\n// The box. 16px, like every raw checkbox it replaces, so a migration moves nothing.\n//\n// `focus-visible`, with an offset in the surface colour: a --brand ring touching a\n// --brand-filled (checked) box would be a ring painted in the colour it sits on —\n// present in the DOM and invisible on screen. The offset is what separates the two.\nconst BOX =\n \"peer size-4 shrink-0 cursor-pointer appearance-none rounded-[4px] border border-[var(--border-strong)] bg-[var(--bg-surface)] shadow-sm transition-colors \" +\n \"checked:border-[var(--brand)] checked:bg-[var(--brand)] \" +\n \"focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-1 focus-visible:ring-offset-[var(--bg-surface)] \" +\n \"disabled:cursor-not-allowed\";\n\n// A mixed box wears the checked fill whether or not the underlying input is checked:\n// `indeterminate` is a property the browser keeps separately from `checked`, and the\n// dash means \"some\", which is neither answer.\nconst BOX_MIXED = \"border-[var(--brand)] bg-[var(--brand)]\";\n\n// The same geometry as FIELD_INVALID — a border plus a 1px ring, so the highlight\n// survives fractional display scaling on every edge (see the note in ui.tsx). The\n// focus ring turns danger too, so focusing a wrong box does not repaint it as fine.\nconst BOX_INVALID =\n \"border-[var(--danger-border)] ring-1 ring-[var(--danger-border)] checked:border-[var(--danger-border)] focus-visible:ring-[var(--danger)]\";\n\nconst ERROR_CLASS = \"mt-1 text-[11px] leading-tight text-[var(--danger)]\";\n\nexport interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, \"type\"> {\n /**\n * The words beside the box. Rendered as a `<label for>` rather than a label that\n * wraps the input, so `description` and `error` can sit under it without becoming\n * part of the accessible NAME — a wrapping label would have the screen reader read\n * the whole paragraph as the checkbox's name.\n */\n label?: ReactNode;\n /** Secondary text under the label (\"Used when no account is chosen\"). Pointed at by\n * `aria-describedby`, merged with any the caller passed. Kastlan's\n * `CheckboxField` `description` variant. */\n description?: ReactNode;\n /**\n * \"Some but not all\" — the header box of a list whose rows are partly selected.\n * A DOM property with no HTML attribute, so it is set on the element after every\n * render; it does not touch `checked`, and a click clears it (the browser's rule,\n * and the caller's `onChange` decides what the click means).\n */\n indeterminate?: boolean;\n /** See {@link Input}'s `invalid`: paints the box and sets `aria-invalid` together,\n * so the two cannot be spelled separately. */\n invalid?: boolean;\n /** What is wrong, in the caller's words (\"Accept the terms to continue\"). Rendered\n * under the label, attached with `aria-describedby`, and implies `invalid`. */\n error?: ReactNode;\n /** The checked state as a boolean — the `(next) => …` shape Lenkbank's\n * `CheckboxField` and Radix's `onCheckedChange` both used, so a migration does not\n * have to unwrap `event.target.checked` at every call site. Fires alongside\n * `onChange`, never instead of it. */\n onCheckedChange?: (checked: boolean) => void;\n /** Classes for the `<input>` itself. `className` styles the OUTERMOST element —\n * the row when there is a label, the box's own wrapper when there is not — which\n * is where layout (`self-end pb-2` to sit on a field's baseline) belongs. */\n inputClassName?: string;\n /**\n * Must be ticked to submit — a consent, an acceptance before paying. Reaches the\n * `<input>` as the native `required` (so a `<form>` refuses to submit without it and a\n * screen reader announces \"required\"), and draws the kit's required mark after the\n * label, the same `aria-hidden` star as {@link Label}'s: the word is announced from\n * the control, so a star inside the name would only be read out as noise. Write the\n * label WITHOUT a literal \"*\". No mark without a label.\n */\n required?: boolean;\n}\n\n/**\n * A native checkbox in the kit's tokens, with an optional label, description and\n * error.\n *\n * Without `label`, `description` or `error` it renders the box and nothing else, so\n * it drops into a table cell or a caller's own `<label>` exactly as the raw input\n * did — give it an `aria-label` there. Every other prop reaches the `<input>`\n * (`checked`, `defaultChecked`, `name`, `required`, `data-*`, `aria-*`), so it works\n * controlled, uncontrolled, and inside a plain `<form>`.\n */\nexport const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(function Checkbox(\n {\n label,\n description,\n indeterminate = false,\n invalid,\n error,\n onCheckedChange,\n onChange,\n className,\n inputClassName,\n id,\n disabled,\n required,\n ...rest\n },\n ref,\n) {\n const generated = useId();\n const inputId = id ?? generated;\n const descriptionId = `${inputId}-description`;\n const errorId = `${inputId}-error`;\n const showError = hasMessage(error);\n const showDescription = hasMessage(description);\n const isInvalid = Boolean(invalid) || showError;\n // Nothing to lay out beside the box: render the box alone, as the raw input was.\n const bare = label === undefined && !showDescription && !showError;\n\n const local = useRef<HTMLInputElement | null>(null);\n const setRef = useCallback(\n (node: HTMLInputElement | null) => {\n local.current = node;\n assignRef(ref, node);\n },\n [ref],\n );\n // After EVERY render, not only when the prop changes: a click clears the property\n // in the DOM, and a controlled caller that keeps `indeterminate` true expects the\n // dash back on the next render even though the prop never changed.\n useEffect(() => {\n if (local.current) local.current.indeterminate = indeterminate;\n });\n\n const box = (\n <span className={cn(\"relative inline-flex shrink-0\", bare && className)}>\n <input\n ref={setRef}\n id={bare ? id : inputId}\n disabled={disabled}\n required={required}\n {...rest}\n // After the spread, like Switch: a props object spread at a checkbox must not\n // be able to turn it into something else.\n type=\"checkbox\"\n // OR-ed with the spread so a caller's own `aria-invalid` survives — Input's rule.\n aria-invalid={isInvalid || rest[\"aria-invalid\"] || undefined}\n aria-describedby={mergeDescribedBy(\n rest[\"aria-describedby\"],\n showDescription && descriptionId,\n showError && errorId,\n )}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n onChange?.(e);\n onCheckedChange?.(e.target.checked);\n }}\n className={cn(BOX, indeterminate && BOX_MIXED, isInvalid && BOX_INVALID, inputClassName)}\n />\n {/* The glyph is drawn over the box, not inside it (an input has no children),\n and ignores the pointer so a click on the tick still toggles the input. The\n tick is shown by `peer-checked`, so an UNCONTROLLED box shows it too; the\n dash replaces it outright while `indeterminate` holds. */}\n {indeterminate ? (\n <Minus\n aria-hidden\n strokeWidth={3}\n className=\"pointer-events-none absolute inset-0 m-auto size-3 text-[var(--brand-contrast)]\"\n />\n ) : (\n <Check\n aria-hidden\n strokeWidth={3}\n className=\"pointer-events-none invisible absolute inset-0 m-auto size-3 text-[var(--brand-contrast)] peer-checked:visible\"\n />\n )}\n </span>\n );\n\n if (bare) return box;\n\n return (\n <div\n className={cn(\n // `items-start` + a 20px cell for the box: the box centres on the label's FIRST\n // line (text-sm is 20px tall), so a label that wraps keeps the box at the top\n // rather than floating to the middle of a paragraph.\n \"flex items-start gap-2\",\n // The whole row fades, the way ToggleGroup and the fields do, so the label does\n // not stay at full strength beside a box you cannot change.\n disabled && \"opacity-60\",\n className,\n )}\n >\n <span className=\"flex h-5 shrink-0 items-center\">{box}</span>\n <span className=\"min-w-0\">\n {label !== undefined && (\n <label\n htmlFor={inputId}\n className={cn(\n \"block text-sm leading-5 text-[var(--text-primary)]\",\n // `select-none`: a double-click to toggle twice would otherwise select the\n // words, and a drag that starts on them starts a native text drag.\n disabled ? \"cursor-not-allowed\" : \"cursor-pointer select-none\",\n )}\n >\n {label}\n {required && (\n <span aria-hidden className=\"ms-0.5 text-[var(--danger)]\">\n *\n </span>\n )}\n </label>\n )}\n {showDescription && (\n <span id={descriptionId} className=\"mt-0.5 block text-xs text-[var(--text-muted)]\">\n {description}\n </span>\n )}\n {showError && (\n <span id={errorId} className={cn(\"block\", ERROR_CLASS)}>\n {error}\n </span>\n )}\n </span>\n </div>\n );\n});\nCheckbox.displayName = \"Checkbox\";\n"],"mappings":";AAiJI,SACE,KADF;AAjJJ,SAAS,YAAY,aAAa,WAAW,OAAO,cAAc;AAClE,SAAS,OAAO,aAAa;AAE7B,SAAS,UAAU;AACnB,SAAS,WAAW,YAAY,wBAAwB;AAuBxD,MAAM,MACJ;AAQF,MAAM,YAAY;AAKlB,MAAM,cACJ;AAEF,MAAM,cAAc;AAyDb,MAAM,WAAW,WAA4C,SAASA,UAC3E;AAAA,EACE;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GACA,KACA;AACA,QAAM,YAAY,MAAM;AACxB,QAAM,UAAU,MAAM;AACtB,QAAM,gBAAgB,GAAG,OAAO;AAChC,QAAM,UAAU,GAAG,OAAO;AAC1B,QAAM,YAAY,WAAW,KAAK;AAClC,QAAM,kBAAkB,WAAW,WAAW;AAC9C,QAAM,YAAY,QAAQ,OAAO,KAAK;AAEtC,QAAM,OAAO,UAAU,UAAa,CAAC,mBAAmB,CAAC;AAEzD,QAAM,QAAQ,OAAgC,IAAI;AAClD,QAAM,SAAS;AAAA,IACb,CAAC,SAAkC;AACjC,YAAM,UAAU;AAChB,gBAAU,KAAK,IAAI;AAAA,IACrB;AAAA,IACA,CAAC,GAAG;AAAA,EACN;AAIA,YAAU,MAAM;AACd,QAAI,MAAM,QAAS,OAAM,QAAQ,gBAAgB;AAAA,EACnD,CAAC;AAED,QAA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,eAAe,WAAU,iDAChC,uBACH;AAAA,UAED,aACC,oBAAC,UAAK,IAAI,SAAS,WAAW,GAAG,SAAS,WAAW,GAClD,iBACH;AAAA,WAEJ;AAAA;AAAA;AAAA,EACF;AAEJ,CAAC;AACD,SAAS,cAAc;","names":["Checkbox"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/checkbox.tsx"],"sourcesContent":["import { forwardRef, useCallback, useEffect, useId, useRef } from \"react\";\nimport { Check, Minus } from \"lucide-react\";\nimport type { ChangeEvent, InputHTMLAttributes, ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { assignRef, hasMessage, mergeDescribedBy } from \"./choice-parts\";\n\n/**\n * A checkbox that is still `<input type=\"checkbox\">`.\n *\n * The three consuming apps had three answers: ~30 raw inputs in Keksdose leaning on\n * `tokens.css`'s `accent-color`, a label-plus-box `CheckboxField` in Lenkbank, and a\n * Radix `<button role=\"checkbox\">` in Kastlan. The native element is the one that\n * needs no ARIA to be a checkbox — it submits with its form, answers to `required`,\n * resets with the form and takes a `<label for>` click — so it stays underneath, and\n * only its paint is replaced (`appearance-none`, a token-coloured box, and a glyph\n * laid over it that ignores the pointer so the click still lands on the input).\n *\n * `accent-color` alone was not enough: it tints the native box but cannot change its\n * border, so an INVALID checkbox had no way to say so, and the unchecked box kept the\n * browser's own grey outline in both themes.\n */\n\n// The box. 16px, like every raw checkbox it replaces, so a migration moves nothing.\n//\n// `focus-visible`, with an offset in the surface colour: a --brand ring touching a\n// --brand-filled (checked) box would be a ring painted in the colour it sits on —\n// present in the DOM and invisible on screen. The offset is what separates the two.\nconst BOX =\n \"peer size-4 shrink-0 cursor-pointer appearance-none rounded-[4px] border border-[var(--border-strong)] bg-[var(--bg-surface)] shadow-sm transition-colors \" +\n \"checked:border-[var(--brand)] checked:bg-[var(--brand)] \" +\n \"focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-1 focus-visible:ring-offset-[var(--bg-surface)] \" +\n \"disabled:cursor-not-allowed\";\n\n// A mixed box wears the checked fill whether or not the underlying input is checked:\n// `indeterminate` is a property the browser keeps separately from `checked`, and the\n// dash means \"some\", which is neither answer.\nconst BOX_MIXED = \"border-[var(--brand)] bg-[var(--brand)]\";\n\n// The same geometry as FIELD_INVALID — a border plus a 1px ring, so the highlight\n// survives fractional display scaling on every edge (see the note in ui.tsx). The\n// focus ring turns danger too, so focusing a wrong box does not repaint it as fine.\nconst BOX_INVALID =\n \"border-[var(--danger-border-strong)] ring-1 ring-[var(--danger-border-strong)] checked:border-[var(--danger-border-strong)] focus-visible:ring-[var(--danger)]\";\n\nconst ERROR_CLASS = \"mt-1 text-[11px] leading-tight text-[var(--danger)]\";\n\nexport interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, \"type\"> {\n /**\n * The words beside the box. Rendered as a `<label for>` rather than a label that\n * wraps the input, so `description` and `error` can sit under it without becoming\n * part of the accessible NAME — a wrapping label would have the screen reader read\n * the whole paragraph as the checkbox's name.\n */\n label?: ReactNode;\n /** Secondary text under the label (\"Used when no account is chosen\"). Pointed at by\n * `aria-describedby`, merged with any the caller passed. Kastlan's\n * `CheckboxField` `description` variant. */\n description?: ReactNode;\n /**\n * \"Some but not all\" — the header box of a list whose rows are partly selected.\n * A DOM property with no HTML attribute, so it is set on the element after every\n * render; it does not touch `checked`, and a click clears it (the browser's rule,\n * and the caller's `onChange` decides what the click means).\n */\n indeterminate?: boolean;\n /** See {@link Input}'s `invalid`: paints the box and sets `aria-invalid` together,\n * so the two cannot be spelled separately. */\n invalid?: boolean;\n /** What is wrong, in the caller's words (\"Accept the terms to continue\"). Rendered\n * under the label, attached with `aria-describedby`, and implies `invalid`. */\n error?: ReactNode;\n /** The checked state as a boolean — the `(next) => …` shape Lenkbank's\n * `CheckboxField` and Radix's `onCheckedChange` both used, so a migration does not\n * have to unwrap `event.target.checked` at every call site. Fires alongside\n * `onChange`, never instead of it. */\n onCheckedChange?: (checked: boolean) => void;\n /** Classes for the `<input>` itself. `className` styles the OUTERMOST element —\n * the row when there is a label, the box's own wrapper when there is not — which\n * is where layout (`self-end pb-2` to sit on a field's baseline) belongs. */\n inputClassName?: string;\n /**\n * Must be ticked to submit — a consent, an acceptance before paying. Reaches the\n * `<input>` as the native `required` (so a `<form>` refuses to submit without it and a\n * screen reader announces \"required\"), and draws the kit's required mark after the\n * label, the same `aria-hidden` star as {@link Label}'s: the word is announced from\n * the control, so a star inside the name would only be read out as noise. Write the\n * label WITHOUT a literal \"*\". No mark without a label.\n */\n required?: boolean;\n}\n\n/**\n * A native checkbox in the kit's tokens, with an optional label, description and\n * error.\n *\n * Without `label`, `description` or `error` it renders the box and nothing else, so\n * it drops into a table cell or a caller's own `<label>` exactly as the raw input\n * did — give it an `aria-label` there. Every other prop reaches the `<input>`\n * (`checked`, `defaultChecked`, `name`, `required`, `data-*`, `aria-*`), so it works\n * controlled, uncontrolled, and inside a plain `<form>`.\n */\nexport const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(function Checkbox(\n {\n label,\n description,\n indeterminate = false,\n invalid,\n error,\n onCheckedChange,\n onChange,\n className,\n inputClassName,\n id,\n disabled,\n required,\n ...rest\n },\n ref,\n) {\n const generated = useId();\n const inputId = id ?? generated;\n const descriptionId = `${inputId}-description`;\n const errorId = `${inputId}-error`;\n const showError = hasMessage(error);\n const showDescription = hasMessage(description);\n const isInvalid = Boolean(invalid) || showError;\n // Nothing to lay out beside the box: render the box alone, as the raw input was.\n const bare = label === undefined && !showDescription && !showError;\n\n const local = useRef<HTMLInputElement | null>(null);\n const setRef = useCallback(\n (node: HTMLInputElement | null) => {\n local.current = node;\n assignRef(ref, node);\n },\n [ref],\n );\n // After EVERY render, not only when the prop changes: a click clears the property\n // in the DOM, and a controlled caller that keeps `indeterminate` true expects the\n // dash back on the next render even though the prop never changed.\n useEffect(() => {\n if (local.current) local.current.indeterminate = indeterminate;\n });\n\n const box = (\n <span className={cn(\"relative inline-flex shrink-0\", bare && className)}>\n <input\n ref={setRef}\n id={bare ? id : inputId}\n disabled={disabled}\n required={required}\n {...rest}\n // After the spread, like Switch: a props object spread at a checkbox must not\n // be able to turn it into something else.\n type=\"checkbox\"\n // OR-ed with the spread so a caller's own `aria-invalid` survives — Input's rule.\n aria-invalid={isInvalid || rest[\"aria-invalid\"] || undefined}\n aria-describedby={mergeDescribedBy(\n rest[\"aria-describedby\"],\n showDescription && descriptionId,\n showError && errorId,\n )}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n onChange?.(e);\n onCheckedChange?.(e.target.checked);\n }}\n className={cn(BOX, indeterminate && BOX_MIXED, isInvalid && BOX_INVALID, inputClassName)}\n />\n {/* The glyph is drawn over the box, not inside it (an input has no children),\n and ignores the pointer so a click on the tick still toggles the input. The\n tick is shown by `peer-checked`, so an UNCONTROLLED box shows it too; the\n dash replaces it outright while `indeterminate` holds. */}\n {indeterminate ? (\n <Minus\n aria-hidden\n strokeWidth={3}\n className=\"pointer-events-none absolute inset-0 m-auto size-3 text-[var(--brand-contrast)]\"\n />\n ) : (\n <Check\n aria-hidden\n strokeWidth={3}\n className=\"pointer-events-none invisible absolute inset-0 m-auto size-3 text-[var(--brand-contrast)] peer-checked:visible\"\n />\n )}\n </span>\n );\n\n if (bare) return box;\n\n return (\n <div\n className={cn(\n // `items-start` + a 20px cell for the box: the box centres on the label's FIRST\n // line (text-sm is 20px tall), so a label that wraps keeps the box at the top\n // rather than floating to the middle of a paragraph.\n \"flex items-start gap-2\",\n // The whole row fades, the way ToggleGroup and the fields do, so the label does\n // not stay at full strength beside a box you cannot change.\n disabled && \"opacity-60\",\n className,\n )}\n >\n <span className=\"flex h-5 shrink-0 items-center\">{box}</span>\n <span className=\"min-w-0\">\n {label !== undefined && (\n <label\n htmlFor={inputId}\n className={cn(\n \"block text-sm leading-5 text-[var(--text-primary)]\",\n // `select-none`: a double-click to toggle twice would otherwise select the\n // words, and a drag that starts on them starts a native text drag.\n disabled ? \"cursor-not-allowed\" : \"cursor-pointer select-none\",\n )}\n >\n {label}\n {required && (\n <span aria-hidden className=\"ms-0.5 text-[var(--danger)]\">\n *\n </span>\n )}\n </label>\n )}\n {showDescription && (\n <span id={descriptionId} className=\"mt-0.5 block text-xs text-[var(--text-muted)]\">\n {description}\n </span>\n )}\n {showError && (\n <span id={errorId} className={cn(\"block\", ERROR_CLASS)}>\n {error}\n </span>\n )}\n </span>\n </div>\n );\n});\nCheckbox.displayName = \"Checkbox\";\n"],"mappings":";AAiJI,SACE,KADF;AAjJJ,SAAS,YAAY,aAAa,WAAW,OAAO,cAAc;AAClE,SAAS,OAAO,aAAa;AAE7B,SAAS,UAAU;AACnB,SAAS,WAAW,YAAY,wBAAwB;AAuBxD,MAAM,MACJ;AAQF,MAAM,YAAY;AAKlB,MAAM,cACJ;AAEF,MAAM,cAAc;AAyDb,MAAM,WAAW,WAA4C,SAASA,UAC3E;AAAA,EACE;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GACA,KACA;AACA,QAAM,YAAY,MAAM;AACxB,QAAM,UAAU,MAAM;AACtB,QAAM,gBAAgB,GAAG,OAAO;AAChC,QAAM,UAAU,GAAG,OAAO;AAC1B,QAAM,YAAY,WAAW,KAAK;AAClC,QAAM,kBAAkB,WAAW,WAAW;AAC9C,QAAM,YAAY,QAAQ,OAAO,KAAK;AAEtC,QAAM,OAAO,UAAU,UAAa,CAAC,mBAAmB,CAAC;AAEzD,QAAM,QAAQ,OAAgC,IAAI;AAClD,QAAM,SAAS;AAAA,IACb,CAAC,SAAkC;AACjC,YAAM,UAAU;AAChB,gBAAU,KAAK,IAAI;AAAA,IACrB;AAAA,IACA,CAAC,GAAG;AAAA,EACN;AAIA,YAAU,MAAM;AACd,QAAI,MAAM,QAAS,OAAM,QAAQ,gBAAgB;AAAA,EACnD,CAAC;AAED,QAAM,MACJ,qB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U,iDAChC,uBACH;AAAA,UAED,aACC,oBAAC,UAAK,IAAI,SAAS,WAAW,GAAG,SAAS,WAAW,GAClD,iBACH;AAAA,WAEJ;AAAA;AAAA;AAAA,EACF;AAEJ,CAAC;AACD,SAAS,cAAc;","names":["Checkbox"]}
|
|
@@ -12,7 +12,7 @@ function RequiredMark() {
|
|
|
12
12
|
}
|
|
13
13
|
const CARD = "flex cursor-pointer items-start gap-3 rounded-lg border border-[var(--border)] bg-[var(--bg-surface)] p-3 shadow-sm transition-colors hover:border-[var(--border-strong)] hover:bg-[var(--bg-hover)] has-[:checked]:border-[var(--brand)] has-[:checked]:bg-[var(--brand-bg)] has-[:checked]:ring-1 has-[:checked]:ring-[var(--brand)] has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-[var(--brand)] has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-60";
|
|
14
14
|
const CARD_DISABLED = "hover:border-[var(--border)] hover:bg-[var(--bg-surface)]";
|
|
15
|
-
const CARD_INVALID = "border-[var(--danger-border)] ring-1 ring-[var(--danger-border)] has-[:checked]:border-[var(--danger-border)] has-[:checked]:ring-[var(--danger-border)]";
|
|
15
|
+
const CARD_INVALID = "border-[var(--danger-border-strong)] ring-1 ring-[var(--danger-border-strong)] has-[:checked]:border-[var(--danger-border-strong)] has-[:checked]:ring-[var(--danger-border-strong)]";
|
|
16
16
|
const BOX = "peer size-4 shrink-0 appearance-none border border-[var(--border-strong)] bg-[var(--bg-surface)] transition-colors checked:border-[var(--brand)] focus:outline-none disabled:cursor-not-allowed";
|
|
17
17
|
const CHECKBOX = "rounded-[4px] checked:bg-[var(--brand)]";
|
|
18
18
|
const RADIO = "rounded-full checked:border-[5px]";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/choice-card.tsx"],"sourcesContent":["import { createContext, forwardRef, useCallback, useContext, useEffect, useId, useRef } from \"react\";\nimport type {\n ButtonHTMLAttributes,\n ChangeEvent,\n ComponentType,\n InputHTMLAttributes,\n MouseEvent,\n ReactElement,\n ReactNode,\n Ref,\n} from \"react\";\nimport { Check, Minus } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { assignRef, hasMessage, mergeDescribedBy } from \"./choice-parts\";\nimport { useKitLink } from \"../i18n/kit-labels\";\nimport { pickLinkRenderer } from \"./text-link\";\n\n/**\n * A checkbox or a radio, presented as a bordered card: a title, a line of description,\n * an optional icon — and the whole card is the hit area.\n *\n * Kastlan built this twice by hand: the \"manage roles\" dialog wraps a `Checkbox` in a\n * bordered `<label>` per role, and the lease wizard's \"set up recurring rent\" option is\n * a `Checkbox` with `className=\"rounded-md border p-3\"`. Neither had a focus ring on\n * the card or a checked look beyond the 16px box, and the role picker's border stayed\n * grey whether the role was on or off.\n *\n * Still a native `<input>` underneath, for the reasons {@link Checkbox} gives: it\n * submits with its form, answers to `required`, and a radio set sharing a `name` gets\n * the browser's own arrow-key behaviour — which already flips in a right-to-left page.\n * The card is a `<label>` wrapped round it, so a click anywhere on the card lands on\n * the input; the input is NAMED by the title alone and DESCRIBED by the description,\n * so a screen reader does not read the whole card as its name.\n *\n * Checked is said three ways, none of them colour alone: the box's tick (or the\n * radio's dot), a heavier border, and the brand-tinted surface.\n */\n\nexport type ChoiceCardType = \"checkbox\" | \"radio\";\n\nexport interface ChoiceCardProps extends Omit<InputHTMLAttributes<HTMLInputElement>, \"type\" | \"title\"> {\n /** \"checkbox\" (default) for an on/off option or one of several; \"radio\" for one of\n * a set — give every card of the set the same `name`, or use {@link ChoiceCardGroup}. */\n type?: ChoiceCardType;\n /** The option's name — the input's accessible name. */\n title: ReactNode;\n /** A line or two under the title. Attached with `aria-describedby`. */\n description?: ReactNode;\n /** A Lucide icon (or any component taking a `className`), shown at the card's start. */\n icon?: ComponentType<{ className?: string; \"aria-hidden\"?: boolean }>;\n /** Checkbox only: \"some but not all\". See {@link CheckboxProps.indeterminate}. */\n indeterminate?: boolean;\n /** Paints the card and sets `aria-invalid` together. */\n invalid?: boolean;\n /** What is wrong, in the caller's words. Rendered in the card and attached with\n * `aria-describedby`; implies `invalid`. */\n error?: ReactNode;\n /** The checked state as a boolean. Fires alongside `onChange`, never instead of it. */\n onCheckedChange?: (checked: boolean) => void;\n /** Classes for the `<input>`. `className` styles the card. */\n inputClassName?: string;\n /**\n * Must be ticked to submit. Reaches the `<input>` as the native `required` (a\n * `<form>` refuses to submit without it, a screen reader announces \"required\"),\n * and draws the kit's `aria-hidden` star after the title — {@link Checkbox}'s\n * contract, down to writing the title WITHOUT a literal \"*\". Inside a\n * {@link ChoiceCardGroup} the star goes on the legend instead, once.\n */\n required?: boolean;\n}\n\n/** Set by {@link ChoiceCardGroup}: its legend carries the one required mark, so the\n * cards inside it draw none of their own. Private — not a prop a caller could set\n * by accident on a lone card. */\nconst InGroupContext = createContext(false);\n\n/** The kit's required mark — {@link Label}'s: `aria-hidden`, because the word is\n * announced from the control and a star read out in the name is only noise. */\nfunction RequiredMark() {\n return (\n <span aria-hidden className=\"ms-0.5 text-[var(--danger)]\">\n *\n </span>\n );\n}\n\n// The card. `has-[:checked]` and `has-[:focus-visible]` read the INPUT's state, so an\n// uncontrolled card (`defaultChecked`, a plain form) looks right with no React state.\nconst CARD =\n \"flex cursor-pointer items-start gap-3 rounded-lg border border-[var(--border)] bg-[var(--bg-surface)] p-3 shadow-sm transition-colors \" +\n \"hover:border-[var(--border-strong)] hover:bg-[var(--bg-hover)] \" +\n \"has-[:checked]:border-[var(--brand)] has-[:checked]:bg-[var(--brand-bg)] has-[:checked]:ring-1 has-[:checked]:ring-[var(--brand)] \" +\n // The focus mark is the CARD's, not the 16px box's: the card is what was clicked and\n // what the eye is on. An OUTLINE rather than a ring, because the checked state already\n // spends the ring — two `ring-*` widths on one element are decided by stylesheet\n // order, and the loser would be the focus mark. Offset, so the two never merge.\n \"has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-[var(--brand)] \" +\n // Read from the input too, so a card disabled by its `<fieldset>` fades as well.\n \"has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-60\";\n\n// No hover offer on a card that cannot be changed.\nconst CARD_DISABLED = \"hover:border-[var(--border)] hover:bg-[var(--bg-surface)]\";\n\nconst CARD_INVALID =\n \"border-[var(--danger-border)] ring-1 ring-[var(--danger-border)] has-[:checked]:border-[var(--danger-border)] has-[:checked]:ring-[var(--danger-border)]\";\n\nconst BOX =\n \"peer size-4 shrink-0 appearance-none border border-[var(--border-strong)] bg-[var(--bg-surface)] transition-colors \" +\n \"checked:border-[var(--brand)] focus:outline-none disabled:cursor-not-allowed\";\nconst CHECKBOX = \"rounded-[4px] checked:bg-[var(--brand)]\";\n// A radio's dot is its BORDER: a 5px brand border round a surface-coloured 4px\n// centre. No glyph to lay over it, and it scales with the box.\nconst RADIO = \"rounded-full checked:border-[5px]\";\n\nexport const ChoiceCard = forwardRef<HTMLInputElement, ChoiceCardProps>(function ChoiceCard(\n {\n type = \"checkbox\",\n title,\n description,\n icon: Icon,\n indeterminate = false,\n invalid,\n error,\n onCheckedChange,\n onChange,\n className,\n inputClassName,\n id,\n disabled,\n required,\n ...rest\n },\n ref,\n) {\n const inGroup = useContext(InGroupContext);\n const generated = useId();\n const inputId = id ?? generated;\n const titleId = `${inputId}-title`;\n const descriptionId = `${inputId}-description`;\n const errorId = `${inputId}-error`;\n const showDescription = hasMessage(description);\n const showError = hasMessage(error);\n const isInvalid = Boolean(invalid) || showError;\n const mixed = type === \"checkbox\" && indeterminate;\n\n const local = useRef<HTMLInputElement | null>(null);\n const setRef = useCallback(\n (node: HTMLInputElement | null) => {\n local.current = node;\n assignRef(ref, node);\n },\n [ref],\n );\n // After every render, as Checkbox does: a click clears the DOM property.\n useEffect(() => {\n if (local.current) local.current.indeterminate = mixed;\n });\n\n return (\n <label\n htmlFor={inputId}\n className={cn(CARD, disabled && CARD_DISABLED, isInvalid && CARD_INVALID, className)}\n >\n {/* A 20px cell, so the box centres on the title's first line (text-sm). */}\n <span className=\"relative flex h-5 shrink-0 items-center\">\n <input\n ref={setRef}\n id={inputId}\n disabled={disabled}\n required={required}\n {...rest}\n type={type}\n aria-labelledby={rest[\"aria-labelledby\"] ?? titleId}\n aria-invalid={isInvalid || rest[\"aria-invalid\"] || undefined}\n aria-describedby={mergeDescribedBy(\n rest[\"aria-describedby\"],\n showDescription && descriptionId,\n showError && errorId,\n )}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n onChange?.(e);\n onCheckedChange?.(e.target.checked);\n }}\n className={cn(\n BOX,\n type === \"radio\" ? RADIO : CHECKBOX,\n mixed && \"border-[var(--brand)] bg-[var(--brand)]\",\n inputClassName,\n )}\n />\n {type === \"checkbox\" &&\n (mixed ? (\n <Minus\n aria-hidden\n strokeWidth={3}\n className=\"pointer-events-none absolute inset-0 m-auto size-3 text-[var(--brand-contrast)]\"\n />\n ) : (\n <Check\n aria-hidden\n strokeWidth={3}\n className=\"pointer-events-none invisible absolute inset-0 m-auto size-3 text-[var(--brand-contrast)] peer-checked:visible\"\n />\n ))}\n </span>\n {Icon && <Icon aria-hidden className=\"mt-0.5 size-4 shrink-0 text-[var(--text-secondary)]\" />}\n <span className=\"min-w-0 flex-1\">\n <span\n id={titleId}\n // `select-none`: a double-click to toggle twice would otherwise select the words.\n className=\"block select-none text-sm font-medium leading-5 text-[var(--text-primary)]\"\n >\n {title}\n {required && !inGroup && <RequiredMark />}\n </span>\n {showDescription && (\n <span id={descriptionId} className=\"mt-0.5 block text-xs text-[var(--text-muted)]\">\n {description}\n </span>\n )}\n {showError && (\n <span id={errorId} className=\"mt-1 block text-[11px] leading-tight text-[var(--danger)]\">\n {error}\n </span>\n )}\n </span>\n </label>\n );\n});\nChoiceCard.displayName = \"ChoiceCard\";\n\n/* ── ActionCard ──────────────────────────────────────────────────────────── */\n\n/** The colour of {@link ActionCardProps.meta}. */\nexport type ActionCardMetaTone = \"muted\" | \"warning\" | \"danger\" | \"info\" | \"success\";\n\nconst META_TONE: Record<ActionCardMetaTone, string> = {\n muted: \"text-[var(--text-muted)]\",\n warning: \"text-[var(--warning)]\",\n danger: \"text-[var(--danger)]\",\n info: \"text-[var(--info)]\",\n success: \"text-[var(--success)]\",\n};\n\n/** The colour of {@link ActionCardProps.icon}. `default` is the secondary text colour\n * the icon has always had; `brand` tints it (keksdose's privacy enrolment). */\nexport type ActionCardIconTone = \"default\" | \"muted\" | \"brand\" | \"warning\" | \"danger\" | \"info\" | \"success\";\n\nconst ICON_TONE: Record<ActionCardIconTone, string> = {\n default: \"text-[var(--text-secondary)]\",\n ...META_TONE,\n brand: \"text-[var(--brand)]\",\n};\n\n/** What {@link ActionCardProps.renderLink} (and the provider's `linkComponent`) is\n * handed. Spread it onto your router's link — `({ href, ...p }) => <Link to={href} {...p} />`. */\nexport interface ActionCardLinkProps {\n href: string;\n /** The card's whole look — keep it. */\n className: string;\n children: ReactNode;\n ref?: Ref<HTMLAnchorElement>;\n onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;\n id?: string;\n [key: `aria-${string}`]: string | boolean | number | undefined;\n [key: `data-${string}`]: unknown;\n}\n\nexport interface ActionCardProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"title\"> {\n /** What the card does — the button's accessible name. */\n title: ReactNode;\n /** A line or two on what it means. Attached with `aria-describedby`. */\n description?: ReactNode;\n /**\n * What it costs, or what else to know — a third line, said as prose and not as fine\n * print (keksdose's custody choice: both options are legitimate and neither is free,\n * so a card listing only benefits would be selling rather than explaining). Attached\n * with `aria-describedby` after the description.\n */\n meta?: ReactNode;\n /** The meta line's colour. Default `muted`; keksdose's cost line is `warning`. */\n metaTone?: ActionCardMetaTone;\n /** A Lucide icon (or any component taking a `className`), shown at the card's start. */\n icon?: ChoiceCardProps[\"icon\"];\n /** The icon's colour. Default `default` (the secondary text colour). */\n iconTone?: ActionCardIconTone;\n /** Classes on the icon, after {@link iconTone} — a size, a tinted tile behind it. */\n iconClassName?: string;\n /**\n * Makes the card a LINK to another page rather than a button that acts: kastlan's\n * section tiles on the group overview (group-overview-page), each an icon, a name and\n * a line on what is there. A real `<a href>`, so a middle click opens it in a new\n * tab. A `disabled` card renders the inert button instead — a link cannot be\n * disabled. The ref then reaches the `<a>`.\n */\n href?: string;\n /** Your router's link for an in-app `href`. Default: the `<UiKitProvider\n * linkComponent>`, then a plain `<a>`. Ignored without `href`. */\n renderLink?: (props: ActionCardLinkProps) => ReactElement;\n}\n\n/**\n * A {@link ChoiceCard} that ACTS rather than holds a state: a `<button>` with the\n * card's icon, title and description, plus a `meta` line, that runs `onClick` the\n * moment it is pressed. keksdose's privacy enrolment (privacy-enroll-dialog:345,\n * `CustodyOption`) offers two custody modes this way — picking one IS the next step,\n * so there is no checked state to show and no \"Continue\" to press after it. With\n * `href` it is the same card as a link (kastlan's overview section tiles).\n *\n * A separate component rather than `ChoiceCard as=\"button\"`: a ChoiceCard is an\n * `<input>` (its ref, its `checked`, its form value), and a button shares none of it.\n * Named by the title alone and described by the rest, so a screen reader hears\n * \"Keep the key yourself, button\" and then the explanation, not one long name.\n */\nexport const ActionCard = forwardRef<HTMLButtonElement, ActionCardProps>(function ActionCard(\n {\n title,\n description,\n meta,\n metaTone = \"muted\",\n icon: Icon,\n iconTone = \"default\",\n iconClassName,\n href,\n renderLink,\n className,\n id,\n type = \"button\",\n ...rest\n },\n ref,\n) {\n const kitLink = useKitLink();\n const generated = useId();\n const baseId = id ?? generated;\n const titleId = `${baseId}-title`;\n const descriptionId = `${baseId}-description`;\n const metaId = `${baseId}-meta`;\n const showDescription = hasMessage(description);\n const showMeta = hasMessage(meta);\n const look = cn(\n \"flex w-full items-start gap-3 rounded-lg border border-[var(--border)] bg-[var(--bg-surface)] p-3 text-start shadow-sm transition-colors\",\n \"hover:border-[var(--brand)] hover:bg-[var(--bg-hover)]\",\n // The outline, as on ChoiceCard: the card is what the eye is on.\n \"focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--brand)]\",\n \"disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:border-[var(--border)] disabled:hover:bg-[var(--bg-surface)]\",\n className,\n );\n const labelledBy = rest[\"aria-labelledby\"] ?? titleId;\n const describedBy = mergeDescribedBy(\n rest[\"aria-describedby\"],\n showDescription && descriptionId,\n showMeta && metaId,\n );\n const body = (\n <>\n {Icon && <Icon aria-hidden className={cn(\"mt-0.5 size-5 shrink-0\", ICON_TONE[iconTone], iconClassName)} />}\n <span className=\"min-w-0 flex-1 space-y-1\">\n <span id={titleId} className=\"block text-sm font-medium leading-5 text-[var(--text-primary)]\">\n {title}\n </span>\n {showDescription && (\n <span id={descriptionId} className=\"block text-sm text-[var(--text-secondary)]\">\n {description}\n </span>\n )}\n {showMeta && (\n <span id={metaId} className={cn(\"block text-sm\", META_TONE[metaTone])}>\n {meta}\n </span>\n )}\n </span>\n </>\n );\n\n if (href !== undefined && !rest.disabled) {\n // The button-only attributes stay behind; `aria-*`, `data-*` and handlers ride along.\n const {\n disabled: _disabled,\n form: _form,\n formAction: _formAction,\n name: _name,\n value: _value,\n onClick,\n ...anchorRest\n } = rest;\n const linkProps: ActionCardLinkProps = {\n ...(anchorRest as Partial<ActionCardLinkProps>),\n ref: ref as unknown as Ref<HTMLAnchorElement>,\n id,\n href,\n \"aria-labelledby\": labelledBy,\n \"aria-describedby\": describedBy,\n onClick: onClick as unknown as ActionCardLinkProps[\"onClick\"],\n className: look,\n children: body,\n };\n const render = pickLinkRenderer(renderLink, kitLink, href);\n if (render) return <RenderedActionLink render={render} {...linkProps} />;\n const { children: content, ...anchor } = linkProps;\n return <a {...anchor}>{content}</a>;\n }\n\n return (\n <button\n ref={ref}\n id={id}\n type={type}\n {...rest}\n aria-labelledby={labelledBy}\n aria-describedby={describedBy}\n className={look}\n >\n {body}\n </button>\n );\n});\nActionCard.displayName = \"ActionCard\";\n\n/** Calls the link renderer as a component, so a router link's hooks are its own. */\nfunction RenderedActionLink({\n render,\n ...props\n}: ActionCardLinkProps & { render: (props: ActionCardLinkProps) => ReactElement }) {\n return render(props);\n}\n\n/* ── ChoiceCardGroup ─────────────────────────────────────────────────────── */\n\nexport interface ChoiceCardOption<T extends string> {\n value: T;\n title: ReactNode;\n description?: ReactNode;\n icon?: ChoiceCardProps[\"icon\"];\n disabled?: boolean;\n}\n\ninterface ChoiceCardGroupBaseProps<T extends string> {\n options: ChoiceCardOption<T>[];\n /** The question the cards answer. Rendered as the fieldset's `<legend>`, which is\n * what names the group. Without one, pass `aria-label`. */\n legend?: ReactNode;\n \"aria-label\"?: string;\n /** Shared by every input — what a plain form submits under. Generated if omitted. */\n name?: string;\n /** Classes for the card grid. Default: one column, two from `sm` up. */\n className?: string;\n /** Classes for every card. */\n cardClassName?: string;\n disabled?: boolean;\n /** What is wrong with the answer as a whole. Rendered under the cards and attached\n * to the fieldset. */\n error?: ReactNode;\n /**\n * An answer is needed. Draws the required star after the `legend` (none without\n * one — the name then comes from `aria-label`, which has nowhere to draw it), and\n * reaches the inputs as the native `required`:\n * - radios: every radio of the set, which is how HTML marks a radio group — the\n * group is satisfied by any one of them, and each announces \"required\";\n * - checkboxes: every box while NONE is ticked, dropped from all of them once one\n * is — \"at least one\", which checkboxes cannot say natively. A form then refuses\n * to submit an empty set, and nothing is left demanding a second box.\n */\n required?: boolean;\n}\n\n/** One of the set: radios. `value` is `null` while nothing is chosen. */\nexport interface ChoiceCardSingleProps<T extends string> extends ChoiceCardGroupBaseProps<T> {\n multiple?: false;\n value: T | null;\n onChange: (value: T) => void;\n}\n\n/** Any of the set: checkboxes. */\nexport interface ChoiceCardMultipleProps<T extends string> extends ChoiceCardGroupBaseProps<T> {\n multiple: true;\n value: T[];\n onChange: (value: T[]) => void;\n}\n\nexport type ChoiceCardGroupProps<T extends string> =\n | ChoiceCardSingleProps<T>\n | ChoiceCardMultipleProps<T>;\n\n/**\n * A set of {@link ChoiceCard}s answering one question, in a `<fieldset>`.\n *\n * `multiple` picks the input: radios (one of the set, the browser's arrow keys\n * between them) or checkboxes (any of the set, Tab between them). The value is kept\n * in the order of `options`, not the order the boxes were ticked, so a list saved\n * from it does not depend on the order someone clicked in.\n */\nexport function ChoiceCardGroup<T extends string>(props: ChoiceCardGroupProps<T>) {\n const { options, legend, name, className, cardClassName, disabled, error, required } = props;\n const generated = useId();\n const groupName = name ?? generated;\n const errorId = `${generated}-error`;\n const showError = hasMessage(error);\n\n const isChecked = (v: T) => (props.multiple ? props.value.includes(v) : props.value === v);\n const toggle = (v: T, on: boolean) => {\n if (props.multiple) {\n const next = new Set(props.value);\n if (on) next.add(v);\n else next.delete(v);\n props.onChange(options.map((o) => o.value).filter((x) => next.has(x)));\n } else if (on) {\n props.onChange(v);\n }\n };\n\n return (\n <InGroupContext.Provider value={true}>\n <fieldset\n aria-label={props[\"aria-label\"]}\n aria-describedby={showError ? errorId : undefined}\n disabled={disabled}\n className=\"min-w-0\"\n >\n {legend !== undefined && (\n <legend className=\"mb-2 text-sm font-medium text-[var(--text-primary)]\">\n {legend}\n {required && <RequiredMark />}\n </legend>\n )}\n <div className={cn(\"grid gap-2 sm:grid-cols-2\", className)}>\n {options.map((o) => (\n <ChoiceCard\n key={o.value}\n type={props.multiple ? \"checkbox\" : \"radio\"}\n name={groupName}\n value={o.value}\n title={o.title}\n description={o.description}\n icon={o.icon}\n disabled={o.disabled}\n invalid={showError}\n required={required && (!props.multiple || props.value.length === 0) ? true : undefined}\n checked={isChecked(o.value)}\n onCheckedChange={(on) => toggle(o.value, on)}\n className={cardClassName}\n />\n ))}\n </div>\n {showError && (\n <p id={errorId} className=\"mt-1 text-[11px] leading-tight text-[var(--danger)]\">\n {error}\n </p>\n )}\n </fieldset>\n </InGroupContext.Provider>\n );\n}\n"],"mappings":";AAgFI,SAmRA,UAnRA,KAoFE,YApFF;AAhFJ,SAAS,eAAe,YAAY,aAAa,YAAY,WAAW,OAAO,cAAc;AAW7F,SAAS,OAAO,aAAa;AAC7B,SAAS,UAAU;AACnB,SAAS,WAAW,YAAY,wBAAwB;AACxD,SAAS,kBAAkB;AAC3B,SAAS,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,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC;AAAA,IACvE,WAAW,IAAI;AACb,YAAM,SAAS,CAAC;AAAA,IAClB;AAAA,EACF;AAEA,SACE,oBAAC,eAAe,UAAf,EAAwB,OAAO,MAC9B;AAAA,IAAC;AAAA;AAAA,MACC,cAAY,MAAM,YAAY;AAAA,MAC9B,oBAAkB,YAAY,UAAU;AAAA,MACxC;AAAA,MACA,WAAU;AAAA,MAET;AAAA,mBAAW,UACV,qBAAC,YAAO,WAAU,uDACf;AAAA;AAAA,UACA,YAAY,oBAAC,gBAAa;AAAA,WAC7B;AAAA,QAEF,oBAAC,SAAI,WAAW,GAAG,6BAA6B,SAAS,GACtD,kBAAQ,IAAI,CAAC,MACZ;AAAA,UAAC;AAAA;AAAA,YAEC,MAAM,MAAM,WAAW,aAAa;AAAA,YACpC,MAAM;AAAA,YACN,OAAO,EAAE;AAAA,YACT,OAAO,EAAE;AAAA,YACT,aAAa,EAAE;AAAA,YACf,MAAM,EAAE;AAAA,YACR,UAAU,EAAE;AAAA,YACZ,SAAS;AAAA,YACT,UAAU,aAAa,CAAC,MAAM,YAAY,MAAM,MAAM,WAAW,KAAK,OAAO;AAAA,YAC7E,SAAS,UAAU,EAAE,KAAK;AAAA,YAC1B,iBAAiB,CAAC,OAAO,OAAO,EAAE,OAAO,EAAE;AAAA,YAC3C,WAAW;AAAA;AAAA,UAZN,EAAE;AAAA,QAaT,CACD,GACH;AAAA,QACC,aACC,oBAAC,OAAE,IAAI,SAAS,WAAU,uDACvB,iBACH;AAAA;AAAA;AAAA,EAEJ,GACF;AAEJ;","names":["ChoiceCard","ActionCard"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/choice-card.tsx"],"sourcesContent":["import { createContext, forwardRef, useCallback, useContext, useEffect, useId, useRef } from \"react\";\nimport type {\n ButtonHTMLAttributes,\n ChangeEvent,\n ComponentType,\n InputHTMLAttributes,\n MouseEvent,\n ReactElement,\n ReactNode,\n Ref,\n} from \"react\";\nimport { Check, Minus } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { assignRef, hasMessage, mergeDescribedBy } from \"./choice-parts\";\nimport { useKitLink } from \"../i18n/kit-labels\";\nimport { pickLinkRenderer } from \"./text-link\";\n\n/**\n * A checkbox or a radio, presented as a bordered card: a title, a line of description,\n * an optional icon — and the whole card is the hit area.\n *\n * Kastlan built this twice by hand: the \"manage roles\" dialog wraps a `Checkbox` in a\n * bordered `<label>` per role, and the lease wizard's \"set up recurring rent\" option is\n * a `Checkbox` with `className=\"rounded-md border p-3\"`. Neither had a focus ring on\n * the card or a checked look beyond the 16px box, and the role picker's border stayed\n * grey whether the role was on or off.\n *\n * Still a native `<input>` underneath, for the reasons {@link Checkbox} gives: it\n * submits with its form, answers to `required`, and a radio set sharing a `name` gets\n * the browser's own arrow-key behaviour — which already flips in a right-to-left page.\n * The card is a `<label>` wrapped round it, so a click anywhere on the card lands on\n * the input; the input is NAMED by the title alone and DESCRIBED by the description,\n * so a screen reader does not read the whole card as its name.\n *\n * Checked is said three ways, none of them colour alone: the box's tick (or the\n * radio's dot), a heavier border, and the brand-tinted surface.\n */\n\nexport type ChoiceCardType = \"checkbox\" | \"radio\";\n\nexport interface ChoiceCardProps extends Omit<InputHTMLAttributes<HTMLInputElement>, \"type\" | \"title\"> {\n /** \"checkbox\" (default) for an on/off option or one of several; \"radio\" for one of\n * a set — give every card of the set the same `name`, or use {@link ChoiceCardGroup}. */\n type?: ChoiceCardType;\n /** The option's name — the input's accessible name. */\n title: ReactNode;\n /** A line or two under the title. Attached with `aria-describedby`. */\n description?: ReactNode;\n /** A Lucide icon (or any component taking a `className`), shown at the card's start. */\n icon?: ComponentType<{ className?: string; \"aria-hidden\"?: boolean }>;\n /** Checkbox only: \"some but not all\". See {@link CheckboxProps.indeterminate}. */\n indeterminate?: boolean;\n /** Paints the card and sets `aria-invalid` together. */\n invalid?: boolean;\n /** What is wrong, in the caller's words. Rendered in the card and attached with\n * `aria-describedby`; implies `invalid`. */\n error?: ReactNode;\n /** The checked state as a boolean. Fires alongside `onChange`, never instead of it. */\n onCheckedChange?: (checked: boolean) => void;\n /** Classes for the `<input>`. `className` styles the card. */\n inputClassName?: string;\n /**\n * Must be ticked to submit. Reaches the `<input>` as the native `required` (a\n * `<form>` refuses to submit without it, a screen reader announces \"required\"),\n * and draws the kit's `aria-hidden` star after the title — {@link Checkbox}'s\n * contract, down to writing the title WITHOUT a literal \"*\". Inside a\n * {@link ChoiceCardGroup} the star goes on the legend instead, once.\n */\n required?: boolean;\n}\n\n/** Set by {@link ChoiceCardGroup}: its legend carries the one required mark, so the\n * cards inside it draw none of their own. Private — not a prop a caller could set\n * by accident on a lone card. */\nconst InGroupContext = createContext(false);\n\n/** The kit's required mark — {@link Label}'s: `aria-hidden`, because the word is\n * announced from the control and a star read out in the name is only noise. */\nfunction RequiredMark() {\n return (\n <span aria-hidden className=\"ms-0.5 text-[var(--danger)]\">\n *\n </span>\n );\n}\n\n// The card. `has-[:checked]` and `has-[:focus-visible]` read the INPUT's state, so an\n// uncontrolled card (`defaultChecked`, a plain form) looks right with no React state.\nconst CARD =\n \"flex cursor-pointer items-start gap-3 rounded-lg border border-[var(--border)] bg-[var(--bg-surface)] p-3 shadow-sm transition-colors \" +\n \"hover:border-[var(--border-strong)] hover:bg-[var(--bg-hover)] \" +\n \"has-[:checked]:border-[var(--brand)] has-[:checked]:bg-[var(--brand-bg)] has-[:checked]:ring-1 has-[:checked]:ring-[var(--brand)] \" +\n // The focus mark is the CARD's, not the 16px box's: the card is what was clicked and\n // what the eye is on. An OUTLINE rather than a ring, because the checked state already\n // spends the ring — two `ring-*` widths on one element are decided by stylesheet\n // order, and the loser would be the focus mark. Offset, so the two never merge.\n \"has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-[var(--brand)] \" +\n // Read from the input too, so a card disabled by its `<fieldset>` fades as well.\n \"has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-60\";\n\n// No hover offer on a card that cannot be changed.\nconst CARD_DISABLED = \"hover:border-[var(--border)] hover:bg-[var(--bg-surface)]\";\n\nconst CARD_INVALID =\n \"border-[var(--danger-border-strong)] ring-1 ring-[var(--danger-border-strong)] has-[:checked]:border-[var(--danger-border-strong)] has-[:checked]:ring-[var(--danger-border-strong)]\";\n\nconst BOX =\n \"peer size-4 shrink-0 appearance-none border border-[var(--border-strong)] bg-[var(--bg-surface)] transition-colors \" +\n \"checked:border-[var(--brand)] focus:outline-none disabled:cursor-not-allowed\";\nconst CHECKBOX = \"rounded-[4px] checked:bg-[var(--brand)]\";\n// A radio's dot is its BORDER: a 5px brand border round a surface-coloured 4px\n// centre. No glyph to lay over it, and it scales with the box.\nconst RADIO = \"rounded-full checked:border-[5px]\";\n\nexport const ChoiceCard = forwardRef<HTMLInputElement, ChoiceCardProps>(function ChoiceCard(\n {\n type = \"checkbox\",\n title,\n description,\n icon: Icon,\n indeterminate = false,\n invalid,\n error,\n onCheckedChange,\n onChange,\n className,\n inputClassName,\n id,\n disabled,\n required,\n ...rest\n },\n ref,\n) {\n const inGroup = useContext(InGroupContext);\n const generated = useId();\n const inputId = id ?? generated;\n const titleId = `${inputId}-title`;\n const descriptionId = `${inputId}-description`;\n const errorId = `${inputId}-error`;\n const showDescription = hasMessage(description);\n const showError = hasMessage(error);\n const isInvalid = Boolean(invalid) || showError;\n const mixed = type === \"checkbox\" && indeterminate;\n\n const local = useRef<HTMLInputElement | null>(null);\n const setRef = useCallback(\n (node: HTMLInputElement | null) => {\n local.current = node;\n assignRef(ref, node);\n },\n [ref],\n );\n // After every render, as Checkbox does: a click clears the DOM property.\n useEffect(() => {\n if (local.current) local.current.indeterminate = mixed;\n });\n\n return (\n <label\n htmlFor={inputId}\n className={cn(CARD, disabled && CARD_DISABLED, isInvalid && CARD_INVALID, className)}\n >\n {/* A 20px cell, so the box centres on the title's first line (text-sm). */}\n <span className=\"relative flex h-5 shrink-0 items-center\">\n <input\n ref={setRef}\n id={inputId}\n disabled={disabled}\n required={required}\n {...rest}\n type={type}\n aria-labelledby={rest[\"aria-labelledby\"] ?? titleId}\n aria-invalid={isInvalid || rest[\"aria-invalid\"] || undefined}\n aria-describedby={mergeDescribedBy(\n rest[\"aria-describedby\"],\n showDescription && descriptionId,\n showError && errorId,\n )}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n onChange?.(e);\n onCheckedChange?.(e.target.checked);\n }}\n className={cn(\n BOX,\n type === \"radio\" ? RADIO : CHECKBOX,\n mixed && \"border-[var(--brand)] bg-[var(--brand)]\",\n inputClassName,\n )}\n />\n {type === \"checkbox\" &&\n (mixed ? (\n <Minus\n aria-hidden\n strokeWidth={3}\n className=\"pointer-events-none absolute inset-0 m-auto size-3 text-[var(--brand-contrast)]\"\n />\n ) : (\n <Check\n aria-hidden\n strokeWidth={3}\n className=\"pointer-events-none invisible absolute inset-0 m-auto size-3 text-[var(--brand-contrast)] peer-checked:visible\"\n />\n ))}\n </span>\n {Icon && <Icon aria-hidden className=\"mt-0.5 size-4 shrink-0 text-[var(--text-secondary)]\" />}\n <span className=\"min-w-0 flex-1\">\n <span\n id={titleId}\n // `select-none`: a double-click to toggle twice would otherwise select the words.\n className=\"block select-none text-sm font-medium leading-5 text-[var(--text-primary)]\"\n >\n {title}\n {required && !inGroup && <RequiredMark />}\n </span>\n {showDescription && (\n <span id={descriptionId} className=\"mt-0.5 block text-xs text-[var(--text-muted)]\">\n {description}\n </span>\n )}\n {showError && (\n <span id={errorId} className=\"mt-1 block text-[11px] leading-tight text-[var(--danger)]\">\n {error}\n </span>\n )}\n </span>\n </label>\n );\n});\nChoiceCard.displayName = \"ChoiceCard\";\n\n/* ── ActionCard ──────────────────────────────────────────────────────────── */\n\n/** The colour of {@link ActionCardProps.meta}. */\nexport type ActionCardMetaTone = \"muted\" | \"warning\" | \"danger\" | \"info\" | \"success\";\n\nconst META_TONE: Record<ActionCardMetaTone, string> = {\n muted: \"text-[var(--text-muted)]\",\n warning: \"text-[var(--warning)]\",\n danger: \"text-[var(--danger)]\",\n info: \"text-[var(--info)]\",\n success: \"text-[var(--success)]\",\n};\n\n/** The colour of {@link ActionCardProps.icon}. `default` is the secondary text colour\n * the icon has always had; `brand` tints it (keksdose's privacy enrolment). */\nexport type ActionCardIconTone = \"default\" | \"muted\" | \"brand\" | \"warning\" | \"danger\" | \"info\" | \"success\";\n\nconst ICON_TONE: Record<ActionCardIconTone, string> = {\n default: \"text-[var(--text-secondary)]\",\n ...META_TONE,\n brand: \"text-[var(--brand)]\",\n};\n\n/** What {@link ActionCardProps.renderLink} (and the provider's `linkComponent`) is\n * handed. Spread it onto your router's link — `({ href, ...p }) => <Link to={href} {...p} />`. */\nexport interface ActionCardLinkProps {\n href: string;\n /** The card's whole look — keep it. */\n className: string;\n children: ReactNode;\n ref?: Ref<HTMLAnchorElement>;\n onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;\n id?: string;\n [key: `aria-${string}`]: string | boolean | number | undefined;\n [key: `data-${string}`]: unknown;\n}\n\nexport interface ActionCardProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"title\"> {\n /** What the card does — the button's accessible name. */\n title: ReactNode;\n /** A line or two on what it means. Attached with `aria-describedby`. */\n description?: ReactNode;\n /**\n * What it costs, or what else to know — a third line, said as prose and not as fine\n * print (keksdose's custody choice: both options are legitimate and neither is free,\n * so a card listing only benefits would be selling rather than explaining). Attached\n * with `aria-describedby` after the description.\n */\n meta?: ReactNode;\n /** The meta line's colour. Default `muted`; keksdose's cost line is `warning`. */\n metaTone?: ActionCardMetaTone;\n /** A Lucide icon (or any component taking a `className`), shown at the card's start. */\n icon?: ChoiceCardProps[\"icon\"];\n /** The icon's colour. Default `default` (the secondary text colour). */\n iconTone?: ActionCardIconTone;\n /** Classes on the icon, after {@link iconTone} — a size, a tinted tile behind it. */\n iconClassName?: string;\n /**\n * Makes the card a LINK to another page rather than a button that acts: kastlan's\n * section tiles on the group overview (group-overview-page), each an icon, a name and\n * a line on what is there. A real `<a href>`, so a middle click opens it in a new\n * tab. A `disabled` card renders the inert button instead — a link cannot be\n * disabled. The ref then reaches the `<a>`.\n */\n href?: string;\n /** Your router's link for an in-app `href`. Default: the `<UiKitProvider\n * linkComponent>`, then a plain `<a>`. Ignored without `href`. */\n renderLink?: (props: ActionCardLinkProps) => ReactElement;\n}\n\n/**\n * A {@link ChoiceCard} that ACTS rather than holds a state: a `<button>` with the\n * card's icon, title and description, plus a `meta` line, that runs `onClick` the\n * moment it is pressed. keksdose's privacy enrolment (privacy-enroll-dialog:345,\n * `CustodyOption`) offers two custody modes this way — picking one IS the next step,\n * so there is no checked state to show and no \"Continue\" to press after it. With\n * `href` it is the same card as a link (kastlan's overview section tiles).\n *\n * A separate component rather than `ChoiceCard as=\"button\"`: a ChoiceCard is an\n * `<input>` (its ref, its `checked`, its form value), and a button shares none of it.\n * Named by the title alone and described by the rest, so a screen reader hears\n * \"Keep the key yourself, button\" and then the explanation, not one long name.\n */\nexport const ActionCard = forwardRef<HTMLButtonElement, ActionCardProps>(function ActionCard(\n {\n title,\n description,\n meta,\n metaTone = \"muted\",\n icon: Icon,\n iconTone = \"default\",\n iconClassName,\n href,\n renderLink,\n className,\n id,\n type = \"button\",\n ...rest\n },\n ref,\n) {\n const kitLink = useKitLink();\n const generated = useId();\n const baseId = id ?? generated;\n const titleId = `${baseId}-title`;\n const descriptionId = `${baseId}-description`;\n const metaId = `${baseId}-meta`;\n const showDescription = hasMessage(description);\n const showMeta = hasMessage(meta);\n const look = cn(\n \"flex w-full items-start gap-3 rounded-lg border border-[var(--border)] bg-[var(--bg-surface)] p-3 text-start shadow-sm transition-colors\",\n \"hover:border-[var(--brand)] hover:bg-[var(--bg-hover)]\",\n // The outline, as on ChoiceCard: the card is what the eye is on.\n \"focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--brand)]\",\n \"disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:border-[var(--border)] disabled:hover:bg-[var(--bg-surface)]\",\n className,\n );\n const labelledBy = rest[\"aria-labelledby\"] ?? titleId;\n const describedBy = mergeDescribedBy(\n rest[\"aria-describedby\"],\n showDescription && descriptionId,\n showMeta && metaId,\n );\n const body = (\n <>\n {Icon && <Icon aria-hidden className={cn(\"mt-0.5 size-5 shrink-0\", ICON_TONE[iconTone], iconClassName)} />}\n <span className=\"min-w-0 flex-1 space-y-1\">\n <span id={titleId} className=\"block text-sm font-medium leading-5 text-[var(--text-primary)]\">\n {title}\n </span>\n {showDescription && (\n <span id={descriptionId} className=\"block text-sm text-[var(--text-secondary)]\">\n {description}\n </span>\n )}\n {showMeta && (\n <span id={metaId} className={cn(\"block text-sm\", META_TONE[metaTone])}>\n {meta}\n </span>\n )}\n </span>\n </>\n );\n\n if (href !== undefined && !rest.disabled) {\n // The button-only attributes stay behind; `aria-*`, `data-*` and handlers ride along.\n const {\n disabled: _disabled,\n form: _form,\n formAction: _formAction,\n name: _name,\n value: _value,\n onClick,\n ...anchorRest\n } = rest;\n const linkProps: ActionCardLinkProps = {\n ...(anchorRest as Partial<ActionCardLinkProps>),\n ref: ref as unknown as Ref<HTMLAnchorElement>,\n id,\n href,\n \"aria-labelledby\": labelledBy,\n \"aria-describedby\": describedBy,\n onClick: onClick as unknown as ActionCardLinkProps[\"onClick\"],\n className: look,\n children: body,\n };\n const render = pickLinkRenderer(renderLink, kitLink, href);\n if (render) return <RenderedActionLink render={render} {...linkProps} />;\n const { children: content, ...anchor } = linkProps;\n return <a {...anchor}>{content}</a>;\n }\n\n return (\n <button\n ref={ref}\n id={id}\n type={type}\n {...rest}\n aria-labelledby={labelledBy}\n aria-describedby={describedBy}\n className={look}\n >\n {body}\n </button>\n );\n});\nActionCard.displayName = \"ActionCard\";\n\n/** Calls the link renderer as a component, so a router link's hooks are its own. */\nfunction RenderedActionLink({\n render,\n ...props\n}: ActionCardLinkProps & { render: (props: ActionCardLinkProps) => ReactElement }) {\n return render(props);\n}\n\n/* ── ChoiceCardGroup ─────────────────────────────────────────────────────── */\n\nexport interface ChoiceCardOption<T extends string> {\n value: T;\n title: ReactNode;\n description?: ReactNode;\n icon?: ChoiceCardProps[\"icon\"];\n disabled?: boolean;\n}\n\ninterface ChoiceCardGroupBaseProps<T extends string> {\n options: ChoiceCardOption<T>[];\n /** The question the cards answer. Rendered as the fieldset's `<legend>`, which is\n * what names the group. Without one, pass `aria-label`. */\n legend?: ReactNode;\n \"aria-label\"?: string;\n /** Shared by every input — what a plain form submits under. Generated if omitted. */\n name?: string;\n /** Classes for the card grid. Default: one column, two from `sm` up. */\n className?: string;\n /** Classes for every card. */\n cardClassName?: string;\n disabled?: boolean;\n /** What is wrong with the answer as a whole. Rendered under the cards and attached\n * to the fieldset. */\n error?: ReactNode;\n /**\n * An answer is needed. Draws the required star after the `legend` (none without\n * one — the name then comes from `aria-label`, which has nowhere to draw it), and\n * reaches the inputs as the native `required`:\n * - radios: every radio of the set, which is how HTML marks a radio group — the\n * group is satisfied by any one of them, and each announces \"required\";\n * - checkboxes: every box while NONE is ticked, dropped from all of them once one\n * is — \"at least one\", which checkboxes cannot say natively. A form then refuses\n * to submit an empty set, and nothing is left demanding a second box.\n */\n required?: boolean;\n}\n\n/** One of the set: radios. `value` is `null` while nothing is chosen. */\nexport interface ChoiceCardSingleProps<T extends string> extends ChoiceCardGroupBaseProps<T> {\n multiple?: false;\n value: T | null;\n onChange: (value: T) => void;\n}\n\n/** Any of the set: checkboxes. */\nexport interface ChoiceCardMultipleProps<T extends string> extends ChoiceCardGroupBaseProps<T> {\n multiple: true;\n value: T[];\n onChange: (value: T[]) => void;\n}\n\nexport type ChoiceCardGroupProps<T extends string> =\n | ChoiceCardSingleProps<T>\n | ChoiceCardMultipleProps<T>;\n\n/**\n * A set of {@link ChoiceCard}s answering one question, in a `<fieldset>`.\n *\n * `multiple` picks the input: radios (one of the set, the browser's arrow keys\n * between them) or checkboxes (any of the set, Tab between them). The value is kept\n * in the order of `options`, not the order the boxes were ticked, so a list saved\n * from it does not depend on the order someone clicked in.\n */\nexport function ChoiceCardGroup<T extends string>(props: ChoiceCardGroupProps<T>) {\n const { options, legend, name, className, cardClassName, disabled, error, required } = props;\n const generated = useId();\n const groupName = name ?? generated;\n const errorId = `${generated}-error`;\n const showError = hasMessage(error);\n\n const isChecked = (v: T) => (props.multiple ? props.value.includes(v) : props.value === v);\n const toggle = (v: T, on: boolean) => {\n if (props.multiple) {\n const next = new Set(props.value);\n if (on) next.add(v);\n else next.delete(v);\n props.onChange(options.map((o) => o.value).filter((x) => next.has(x)));\n } else if (on) {\n props.onChange(v);\n }\n };\n\n return (\n <InGroupContext.Provider value={true}>\n <fieldset\n aria-label={props[\"aria-label\"]}\n aria-describedby={showError ? errorId : undefined}\n disabled={disabled}\n className=\"min-w-0\"\n >\n {legend !== undefined && (\n <legend className=\"mb-2 text-sm font-medium text-[var(--text-primary)]\">\n {legend}\n {required && <RequiredMark />}\n </legend>\n )}\n <div className={cn(\"grid gap-2 sm:grid-cols-2\", className)}>\n {options.map((o) => (\n <ChoiceCard\n key={o.value}\n type={props.multiple ? \"checkbox\" : \"radio\"}\n name={groupName}\n value={o.value}\n title={o.title}\n description={o.description}\n icon={o.icon}\n disabled={o.disabled}\n invalid={showError}\n required={required && (!props.multiple || props.value.length === 0) ? true : undefined}\n checked={isChecked(o.value)}\n onCheckedChange={(on) => toggle(o.value, on)}\n className={cardClassName}\n />\n ))}\n </div>\n {showError && (\n <p id={errorId} className=\"mt-1 text-[11px] leading-tight text-[var(--danger)]\">\n {error}\n </p>\n )}\n </fieldset>\n </InGroupContext.Provider>\n );\n}\n"],"mappings":";AAgFI,SAmRA,UAnRA,KAoFE,YApFF;AAhFJ,SAAS,eAAe,YAAY,aAAa,YAAY,WAAW,OAAO,cAAc;AAW7F,SAAS,OAAO,aAAa;AAC7B,SAAS,UAAU;AACnB,SAAS,WAAW,YAAY,wBAAwB;AACxD,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB;AA2DjC,M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,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC;AAAA,IACvE,WAAW,IAAI;AACb,YAAM,SAAS,CAAC;AAAA,IAClB;AAAA,EACF;AAEA,SACE,oBAAC,eAAe,UAAf,EAAwB,OAAO,MAC9B;AAAA,IAAC;AAAA;AAAA,MACC,cAAY,MAAM,YAAY;AAAA,MAC9B,oBAAkB,YAAY,UAAU;AAAA,MACxC;AAAA,MACA,WAAU;AAAA,MAET;AAAA,mBAAW,UACV,qBAAC,YAAO,WAAU,uDACf;AAAA;AAAA,UACA,YAAY,oBAAC,gBAAa;AAAA,WAC7B;AAAA,QAEF,oBAAC,SAAI,WAAW,GAAG,6BAA6B,SAAS,GACtD,kBAAQ,IAAI,CAAC,MACZ;AAAA,UAAC;AAAA;AAAA,YAEC,MAAM,MAAM,WAAW,aAAa;AAAA,YACpC,MAAM;AAAA,YACN,OAAO,EAAE;AAAA,YACT,OAAO,EAAE;AAAA,YACT,aAAa,EAAE;AAAA,YACf,MAAM,EAAE;AAAA,YACR,UAAU,EAAE;AAAA,YACZ,SAAS;AAAA,YACT,UAAU,aAAa,CAAC,MAAM,YAAY,MAAM,MAAM,WAAW,KAAK,OAAO;AAAA,YAC7E,SAAS,UAAU,EAAE,KAAK;AAAA,YAC1B,iBAAiB,CAAC,OAAO,OAAO,EAAE,OAAO,EAAE;AAAA,YAC3C,WAAW;AAAA;AAAA,UAZN,EAAE;AAAA,QAaT,CACD,GACH;AAAA,QACC,aACC,oBAAC,OAAE,IAAI,SAAS,WAAU,uDACvB,iBACH;AAAA;AAAA;AAAA,EAEJ,GACF;AAEJ;","names":["ChoiceCard","ActionCard"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'react';
|
|
2
|
-
export {
|
|
2
|
+
export { z as CopyButton, D as CopyButtonLabels, E as CopyButtonProps, K as DEFAULT_COPY_BUTTON_LABELS } from '../kit-labels-DE--LmCk.js';
|
|
3
3
|
import './tooltip.js';
|
|
4
4
|
import './data-table-labels.js';
|
|
5
5
|
import './mini-calendar.js';
|
|
@@ -29,8 +29,7 @@ import './dialog-frame.js';
|
|
|
29
29
|
import './modal.js';
|
|
30
30
|
import '../hooks/use-search-param-state.js';
|
|
31
31
|
import './measured-grid.js';
|
|
32
|
-
import '../feedback
|
|
33
|
-
import '../feedback/feedback-dialog.js';
|
|
32
|
+
import '../feedback-attachment-WFiXJ8We.js';
|
|
34
33
|
import '../feedback/feedback-thread.js';
|
|
35
34
|
import '../feedback/feedback-inbox.js';
|
|
36
35
|
import './account-settings-labels.js';
|
|
@@ -40,12 +39,12 @@ import '../hooks/use-anchored-rect.js';
|
|
|
40
39
|
import '../lib/clipping.js';
|
|
41
40
|
import './bulk-action-bar.js';
|
|
42
41
|
import './list.js';
|
|
42
|
+
import './signed-amount.js';
|
|
43
43
|
import './breadcrumbs.js';
|
|
44
44
|
import './toast.js';
|
|
45
45
|
import './description-list.js';
|
|
46
46
|
import './line-items.js';
|
|
47
47
|
import './progress-bar.js';
|
|
48
|
-
import './signed-amount.js';
|
|
49
48
|
import './error-boundary.js';
|
|
50
49
|
import './authed-image.js';
|
|
51
50
|
import '../hooks/use-authed-src.js';
|
|
@@ -295,7 +295,7 @@ function ErrorFallback({
|
|
|
295
295
|
"p",
|
|
296
296
|
{
|
|
297
297
|
"data-error-message": "",
|
|
298
|
-
className: "-mt-1 mb-1 basis-full whitespace-pre-wrap break-words rounded-md border border-[var(--danger-border)] bg-[var(--danger-bg)] px-3 py-2 text-start font-mono text-xs text-[var(--text-primary)]",
|
|
298
|
+
className: "-mt-1 mb-1 basis-full whitespace-pre-wrap break-words rounded-md border border-[var(--danger-border-strong)] bg-[var(--danger-bg)] px-3 py-2 text-start font-mono text-xs text-[var(--text-primary)]",
|
|
299
299
|
children: errorLine
|
|
300
300
|
}
|
|
301
301
|
),
|