orbital-ds 0.18.2 → 0.21.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/AGENTS.md +34 -0
- package/components.manifest.json +113 -2
- package/dist/hooks/use-ds-messages.d.ts +36 -0
- package/dist/lib/i18n.d.ts +36 -0
- package/dist/lib/i18n.js +108 -0
- package/dist/lib/presets.d.ts +8 -0
- package/dist/lib/presets.js +8 -0
- package/dist/motion.css +11 -4
- package/dist/styles.css +1182 -1148
- package/dist/ui/confirm-action.d.ts +18 -0
- package/dist/ui/confirm-action.js +79 -0
- package/dist/ui/empty-state.d.ts +17 -0
- package/dist/ui/empty-state.js +58 -0
- package/dist/ui/form-layout.d.ts +19 -0
- package/dist/ui/form-layout.js +90 -0
- package/dist/ui/notice-review.d.ts +31 -0
- package/dist/ui/notice-review.js +138 -0
- package/dist/ui/notifications.d.ts +3 -1
- package/dist/ui/notifications.js +12 -2
- package/dist/ui/stat-group.d.ts +8 -0
- package/dist/ui/stat-group.js +17 -0
- package/dist/ui/step-flow.d.ts +48 -0
- package/dist/ui/step-flow.js +338 -0
- package/docs/CONTRACT.md +34 -0
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type ConfirmActionPreset = "simple" | "typed";
|
|
4
|
+
declare function ConfirmAction({ open, onOpenChange, preset, tone, title, description, confirmLabel, cancelLabel, expected, onConfirm, }: {
|
|
5
|
+
open?: boolean;
|
|
6
|
+
onOpenChange?: (open: boolean) => void;
|
|
7
|
+
preset?: ConfirmActionPreset;
|
|
8
|
+
tone?: "destructive" | "default";
|
|
9
|
+
title: React.ReactNode;
|
|
10
|
+
description?: React.ReactNode;
|
|
11
|
+
confirmLabel?: React.ReactNode;
|
|
12
|
+
cancelLabel?: React.ReactNode;
|
|
13
|
+
/** Texto que hay que escribir (preset `typed`). */
|
|
14
|
+
expected?: string;
|
|
15
|
+
onConfirm: () => void | Promise<void>;
|
|
16
|
+
}): React.JSX.Element;
|
|
17
|
+
|
|
18
|
+
export { ConfirmAction, type ConfirmActionPreset };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useDsMessages } from "../hooks/use-ds-messages.js";
|
|
5
|
+
import { dsFormat } from "../lib/i18n.js";
|
|
6
|
+
import { dsWarn } from "../lib/presets.js";
|
|
7
|
+
import {
|
|
8
|
+
AlertDialog,
|
|
9
|
+
AlertDialogAction,
|
|
10
|
+
AlertDialogCancel,
|
|
11
|
+
AlertDialogContent,
|
|
12
|
+
AlertDialogDescription,
|
|
13
|
+
AlertDialogFooter,
|
|
14
|
+
AlertDialogHeader,
|
|
15
|
+
AlertDialogTitle
|
|
16
|
+
} from "./alert-dialog.js";
|
|
17
|
+
import { Input } from "./input.js";
|
|
18
|
+
function ConfirmAction({
|
|
19
|
+
open,
|
|
20
|
+
onOpenChange,
|
|
21
|
+
preset = "simple",
|
|
22
|
+
tone = "destructive",
|
|
23
|
+
title,
|
|
24
|
+
description,
|
|
25
|
+
confirmLabel,
|
|
26
|
+
cancelLabel,
|
|
27
|
+
expected,
|
|
28
|
+
onConfirm
|
|
29
|
+
}) {
|
|
30
|
+
const t = useDsMessages();
|
|
31
|
+
const [typed, setTyped] = React.useState("");
|
|
32
|
+
const [pending, setPending] = React.useState(false);
|
|
33
|
+
const needsTyping = preset === "typed";
|
|
34
|
+
const ready = !needsTyping || expected != null && typed === expected;
|
|
35
|
+
React.useEffect(() => {
|
|
36
|
+
if (needsTyping && !expected)
|
|
37
|
+
dsWarn("ConfirmAction", 'preset="typed" needs the `expected` prop.');
|
|
38
|
+
}, [needsTyping, expected]);
|
|
39
|
+
React.useEffect(() => {
|
|
40
|
+
if (!open) setTyped("");
|
|
41
|
+
}, [open]);
|
|
42
|
+
const run = async (event) => {
|
|
43
|
+
if (pending) return;
|
|
44
|
+
event.preventDefault();
|
|
45
|
+
setPending(true);
|
|
46
|
+
try {
|
|
47
|
+
await onConfirm();
|
|
48
|
+
onOpenChange?.(false);
|
|
49
|
+
} finally {
|
|
50
|
+
setPending(false);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return /* @__PURE__ */ jsx(AlertDialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(AlertDialogContent, { "data-slot": "confirm-action", "data-preset": preset, children: [
|
|
54
|
+
/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
|
|
55
|
+
/* @__PURE__ */ jsx(AlertDialogTitle, { children: title }),
|
|
56
|
+
description ? /* @__PURE__ */ jsx(AlertDialogDescription, { children: description }) : null
|
|
57
|
+
] }),
|
|
58
|
+
needsTyping && expected ? /* @__PURE__ */ jsxs("label", { className: "flex flex-col gap-2 text-sm", children: [
|
|
59
|
+
/* @__PURE__ */ jsx("span", { children: dsFormat(t.confirmActionTyped, { value: expected }) }),
|
|
60
|
+
/* @__PURE__ */ jsx(Input, { value: typed, onChange: (e) => setTyped(e.target.value), autoComplete: "off" })
|
|
61
|
+
] }) : null,
|
|
62
|
+
/* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
|
|
63
|
+
/* @__PURE__ */ jsx(AlertDialogCancel, { disabled: pending, children: cancelLabel ?? t.confirmActionCancel }),
|
|
64
|
+
/* @__PURE__ */ jsx(
|
|
65
|
+
AlertDialogAction,
|
|
66
|
+
{
|
|
67
|
+
variant: tone === "destructive" ? "destructive" : "default",
|
|
68
|
+
disabled: !ready || pending,
|
|
69
|
+
"aria-busy": pending || void 0,
|
|
70
|
+
onClick: run,
|
|
71
|
+
children: confirmLabel ?? t.confirmActionConfirm
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
] })
|
|
75
|
+
] }) });
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
ConfirmAction
|
|
79
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Empty } from './empty.js';
|
|
3
|
+
import 'class-variance-authority/types';
|
|
4
|
+
import 'class-variance-authority';
|
|
5
|
+
|
|
6
|
+
type EmptyStatePreset = "first-use" | "no-results" | "error" | "forbidden";
|
|
7
|
+
declare function EmptyState({ preset, title, description, icon, action, className, ...props }: Omit<React.ComponentProps<typeof Empty>, "title"> & {
|
|
8
|
+
preset?: EmptyStatePreset;
|
|
9
|
+
title?: React.ReactNode;
|
|
10
|
+
description?: React.ReactNode;
|
|
11
|
+
/** Sustituye el icono del preset. */
|
|
12
|
+
icon?: React.ReactNode;
|
|
13
|
+
/** Acción principal (botón o enlace); la pone la app. */
|
|
14
|
+
action?: React.ReactNode;
|
|
15
|
+
}): React.JSX.Element;
|
|
16
|
+
|
|
17
|
+
export { EmptyState, type EmptyStatePreset };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { InboxIcon, LockIcon, SearchXIcon, TriangleAlertIcon } from "lucide-react";
|
|
4
|
+
import { useDsMessages } from "../hooks/use-ds-messages.js";
|
|
5
|
+
import { cn } from "../lib/utils.js";
|
|
6
|
+
import {
|
|
7
|
+
Empty,
|
|
8
|
+
EmptyContent,
|
|
9
|
+
EmptyDescription,
|
|
10
|
+
EmptyHeader,
|
|
11
|
+
EmptyMedia,
|
|
12
|
+
EmptyTitle
|
|
13
|
+
} from "./empty.js";
|
|
14
|
+
const ICONS = {
|
|
15
|
+
"first-use": InboxIcon,
|
|
16
|
+
"no-results": SearchXIcon,
|
|
17
|
+
error: TriangleAlertIcon,
|
|
18
|
+
forbidden: LockIcon
|
|
19
|
+
};
|
|
20
|
+
function EmptyState({
|
|
21
|
+
preset = "first-use",
|
|
22
|
+
title,
|
|
23
|
+
description,
|
|
24
|
+
icon,
|
|
25
|
+
action,
|
|
26
|
+
className,
|
|
27
|
+
...props
|
|
28
|
+
}) {
|
|
29
|
+
const t = useDsMessages();
|
|
30
|
+
const Icon = ICONS[preset];
|
|
31
|
+
const texts = {
|
|
32
|
+
"first-use": [t.emptyFirstUseTitle, t.emptyFirstUseBody],
|
|
33
|
+
"no-results": [t.emptyNoResultsTitle, t.emptyNoResultsBody],
|
|
34
|
+
error: [t.emptyErrorTitle, t.emptyErrorBody],
|
|
35
|
+
forbidden: [t.emptyForbiddenTitle, t.emptyForbiddenBody]
|
|
36
|
+
}[preset];
|
|
37
|
+
return /* @__PURE__ */ jsxs(
|
|
38
|
+
Empty,
|
|
39
|
+
{
|
|
40
|
+
"data-slot": "empty-state",
|
|
41
|
+
"data-preset": preset,
|
|
42
|
+
role: preset === "error" ? "alert" : void 0,
|
|
43
|
+
className: cn("border border-border", className),
|
|
44
|
+
...props,
|
|
45
|
+
children: [
|
|
46
|
+
/* @__PURE__ */ jsxs(EmptyHeader, { children: [
|
|
47
|
+
/* @__PURE__ */ jsx(EmptyMedia, { variant: "icon", className: cn(preset === "error" && "text-danger"), children: icon ?? /* @__PURE__ */ jsx(Icon, {}) }),
|
|
48
|
+
/* @__PURE__ */ jsx(EmptyTitle, { children: title ?? texts[0] }),
|
|
49
|
+
/* @__PURE__ */ jsx(EmptyDescription, { children: description ?? texts[1] })
|
|
50
|
+
] }),
|
|
51
|
+
action ? /* @__PURE__ */ jsx(EmptyContent, { children: action }) : null
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
EmptyState
|
|
58
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type FormLayoutPreset = "inline" | "sectioned" | "settings";
|
|
4
|
+
declare function FormLayout({ preset, dirty, saving, onSave, onDiscard, saveLabel, discardLabel, className, children, ...props }: Omit<React.ComponentProps<"form">, "onSubmit"> & {
|
|
5
|
+
preset?: FormLayoutPreset;
|
|
6
|
+
/** Hay cambios sin guardar (obligatorio para que `settings` muestre su barra). */
|
|
7
|
+
dirty?: boolean;
|
|
8
|
+
saving?: boolean;
|
|
9
|
+
onSave?: () => void | Promise<void>;
|
|
10
|
+
onDiscard?: () => void;
|
|
11
|
+
saveLabel?: React.ReactNode;
|
|
12
|
+
discardLabel?: React.ReactNode;
|
|
13
|
+
}): React.JSX.Element;
|
|
14
|
+
declare function FormSection({ title, description, className, children, ...props }: Omit<React.ComponentProps<"section">, "title"> & {
|
|
15
|
+
title: React.ReactNode;
|
|
16
|
+
description?: React.ReactNode;
|
|
17
|
+
}): React.JSX.Element;
|
|
18
|
+
|
|
19
|
+
export { FormLayout, type FormLayoutPreset, FormSection };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useDsMessages } from "../hooks/use-ds-messages.js";
|
|
4
|
+
import { cn } from "../lib/utils.js";
|
|
5
|
+
import { Button } from "./button.js";
|
|
6
|
+
function FormLayout({
|
|
7
|
+
preset = "inline",
|
|
8
|
+
dirty = false,
|
|
9
|
+
saving = false,
|
|
10
|
+
onSave,
|
|
11
|
+
onDiscard,
|
|
12
|
+
saveLabel,
|
|
13
|
+
discardLabel,
|
|
14
|
+
className,
|
|
15
|
+
children,
|
|
16
|
+
...props
|
|
17
|
+
}) {
|
|
18
|
+
const t = useDsMessages();
|
|
19
|
+
const bar = preset === "settings";
|
|
20
|
+
const showActions = bar ? dirty : true;
|
|
21
|
+
return /* @__PURE__ */ jsxs(
|
|
22
|
+
"form",
|
|
23
|
+
{
|
|
24
|
+
"data-slot": "form-layout",
|
|
25
|
+
"data-preset": preset,
|
|
26
|
+
"data-dirty": dirty || void 0,
|
|
27
|
+
onSubmit: (e) => {
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
void onSave?.();
|
|
30
|
+
},
|
|
31
|
+
className: cn(
|
|
32
|
+
"group/form @container flex min-w-0 flex-col gap-(--ds-section-gap)",
|
|
33
|
+
className
|
|
34
|
+
),
|
|
35
|
+
...props,
|
|
36
|
+
children: [
|
|
37
|
+
children,
|
|
38
|
+
showActions && /* @__PURE__ */ jsxs(
|
|
39
|
+
"div",
|
|
40
|
+
{
|
|
41
|
+
"data-slot": "form-actions",
|
|
42
|
+
role: bar ? "region" : void 0,
|
|
43
|
+
"aria-label": bar ? t.formUnsaved : void 0,
|
|
44
|
+
className: cn(
|
|
45
|
+
"flex flex-col-reverse gap-2 @[520px]:flex-row @[520px]:items-center @[520px]:justify-end",
|
|
46
|
+
bar && "sticky bottom-0 z-(--ds-z-raised) rounded-card border border-border bg-popover p-3 shadow-card"
|
|
47
|
+
),
|
|
48
|
+
children: [
|
|
49
|
+
bar && /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground @[520px]:me-auto", children: t.formUnsaved }),
|
|
50
|
+
onDiscard && /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", disabled: saving, onClick: onDiscard, children: discardLabel ?? t.formDiscard }),
|
|
51
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", disabled: saving, "aria-busy": saving || void 0, children: saving ? t.stepFlowSaving : saveLabel ?? t.formSave })
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
function FormSection({
|
|
60
|
+
title,
|
|
61
|
+
description,
|
|
62
|
+
className,
|
|
63
|
+
children,
|
|
64
|
+
...props
|
|
65
|
+
}) {
|
|
66
|
+
return /* @__PURE__ */ jsxs(
|
|
67
|
+
"section",
|
|
68
|
+
{
|
|
69
|
+
"data-slot": "form-section",
|
|
70
|
+
className: cn(
|
|
71
|
+
"grid min-w-0 gap-(--ds-section-gap)",
|
|
72
|
+
"group-data-[preset=sectioned]/form:@[700px]:grid-cols-[minmax(10rem,16rem)_minmax(0,1fr)]",
|
|
73
|
+
"group-data-[preset=settings]/form:@[700px]:grid-cols-[minmax(10rem,16rem)_minmax(0,1fr)]",
|
|
74
|
+
className
|
|
75
|
+
),
|
|
76
|
+
...props,
|
|
77
|
+
children: [
|
|
78
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col gap-1", children: [
|
|
79
|
+
/* @__PURE__ */ jsx("h3", { className: "font-display text-base leading-snug font-(--ds-heading-weight)", children: title }),
|
|
80
|
+
description ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: description }) : null
|
|
81
|
+
] }),
|
|
82
|
+
/* @__PURE__ */ jsx("div", { className: "flex min-w-0 flex-col gap-(--ds-section-gap)", children })
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
FormLayout,
|
|
89
|
+
FormSection
|
|
90
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DsPresentation } from '../lib/presets.js';
|
|
3
|
+
import { NotificationTone, NotificationState } from './notifications.js';
|
|
4
|
+
import './tabs.js';
|
|
5
|
+
import 'class-variance-authority/types';
|
|
6
|
+
import '@base-ui/react/tabs';
|
|
7
|
+
import 'class-variance-authority';
|
|
8
|
+
|
|
9
|
+
type NoticeReviewPreset = "read" | "acknowledge" | "resolve" | "respond";
|
|
10
|
+
declare function NoticeReview({ open, onOpenChange, preset, presentation, tone, icon, title, description, time, state, children, onAcknowledge, onResolve, onRespond, onSnooze, className, }: {
|
|
11
|
+
open?: boolean;
|
|
12
|
+
onOpenChange?: (open: boolean) => void;
|
|
13
|
+
preset?: NoticeReviewPreset;
|
|
14
|
+
/** `dialog` o `sheet`; `page` e `inline` no aplican. */
|
|
15
|
+
presentation?: Extract<DsPresentation, "dialog" | "sheet">;
|
|
16
|
+
tone?: NotificationTone;
|
|
17
|
+
icon?: React.ReactNode;
|
|
18
|
+
title: React.ReactNode;
|
|
19
|
+
description?: React.ReactNode;
|
|
20
|
+
time?: Date | number | string;
|
|
21
|
+
state?: NotificationState;
|
|
22
|
+
/** Contexto completo del aviso. */
|
|
23
|
+
children?: React.ReactNode;
|
|
24
|
+
onAcknowledge?: () => void | Promise<void>;
|
|
25
|
+
onResolve?: (note: string) => void | Promise<void>;
|
|
26
|
+
onRespond?: (answer: "accept" | "decline") => void | Promise<void>;
|
|
27
|
+
onSnooze?: () => void | Promise<void>;
|
|
28
|
+
className?: string;
|
|
29
|
+
}): React.JSX.Element;
|
|
30
|
+
|
|
31
|
+
export { NoticeReview, type NoticeReviewPreset };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useDsLocale, useDsMessages } from "../hooks/use-ds-messages.js";
|
|
5
|
+
import { dsWarn } from "../lib/presets.js";
|
|
6
|
+
import { cn } from "../lib/utils.js";
|
|
7
|
+
import { Button } from "./button.js";
|
|
8
|
+
import {
|
|
9
|
+
Dialog,
|
|
10
|
+
DialogContent,
|
|
11
|
+
DialogDescription,
|
|
12
|
+
DialogHeader,
|
|
13
|
+
DialogTitle
|
|
14
|
+
} from "./dialog.js";
|
|
15
|
+
import { IconTile } from "./icon-tile.js";
|
|
16
|
+
import {
|
|
17
|
+
Sheet,
|
|
18
|
+
SheetContent,
|
|
19
|
+
SheetDescription,
|
|
20
|
+
SheetHeader,
|
|
21
|
+
SheetTitle
|
|
22
|
+
} from "./sheet.js";
|
|
23
|
+
import { Textarea } from "./textarea.js";
|
|
24
|
+
function NoticeReview({
|
|
25
|
+
open,
|
|
26
|
+
onOpenChange,
|
|
27
|
+
preset = "read",
|
|
28
|
+
presentation = "dialog",
|
|
29
|
+
tone = "neutral",
|
|
30
|
+
icon,
|
|
31
|
+
title,
|
|
32
|
+
description,
|
|
33
|
+
time,
|
|
34
|
+
state,
|
|
35
|
+
children,
|
|
36
|
+
onAcknowledge,
|
|
37
|
+
onResolve,
|
|
38
|
+
onRespond,
|
|
39
|
+
onSnooze,
|
|
40
|
+
className
|
|
41
|
+
}) {
|
|
42
|
+
const t = useDsMessages();
|
|
43
|
+
const locale = useDsLocale();
|
|
44
|
+
const [note, setNote] = React.useState("");
|
|
45
|
+
const [pending, setPending] = React.useState(false);
|
|
46
|
+
React.useEffect(() => {
|
|
47
|
+
const missing = preset === "acknowledge" && !onAcknowledge && "onAcknowledge" || preset === "resolve" && !onResolve && "onResolve" || preset === "respond" && !onRespond && "onRespond";
|
|
48
|
+
if (missing) dsWarn("NoticeReview", `preset="${preset}" needs the \`${missing}\` prop.`);
|
|
49
|
+
}, [preset, onAcknowledge, onResolve, onRespond]);
|
|
50
|
+
React.useEffect(() => {
|
|
51
|
+
if (!open) setNote("");
|
|
52
|
+
}, [open]);
|
|
53
|
+
const run = async (action) => {
|
|
54
|
+
if (!action || pending) return;
|
|
55
|
+
setPending(true);
|
|
56
|
+
try {
|
|
57
|
+
await action();
|
|
58
|
+
onOpenChange?.(false);
|
|
59
|
+
} finally {
|
|
60
|
+
setPending(false);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const date = time != null ? new Date(time) : null;
|
|
64
|
+
const stateLabel = state === "new" ? t.noticeStateNew : state === "acknowledged" ? t.noticeStateAcknowledged : state === "resolved" ? t.noticeStateResolved : state;
|
|
65
|
+
const header = /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
|
|
66
|
+
icon ? /* @__PURE__ */ jsx(IconTile, { tone, size: "sm", children: icon }) : null,
|
|
67
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
68
|
+
presentation === "sheet" ? /* @__PURE__ */ jsx(SheetTitle, { children: title }) : /* @__PURE__ */ jsx(DialogTitle, { children: title }),
|
|
69
|
+
description ? presentation === "sheet" ? /* @__PURE__ */ jsx(SheetDescription, { children: description }) : /* @__PURE__ */ jsx(DialogDescription, { children: description }) : null,
|
|
70
|
+
date && !Number.isNaN(date.getTime()) || stateLabel ? /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2 text-xs text-muted-foreground", children: [
|
|
71
|
+
date && !Number.isNaN(date.getTime()) ? /* @__PURE__ */ jsx("time", { dateTime: date.toISOString(), children: new Intl.DateTimeFormat(locale, {
|
|
72
|
+
dateStyle: "medium",
|
|
73
|
+
timeStyle: "short"
|
|
74
|
+
}).format(date) }) : null,
|
|
75
|
+
stateLabel ? /* @__PURE__ */ jsx("span", { "data-slot": "notice-review-state", children: stateLabel }) : null
|
|
76
|
+
] }) : null
|
|
77
|
+
] })
|
|
78
|
+
] });
|
|
79
|
+
const body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
80
|
+
children ? /* @__PURE__ */ jsx("div", { "data-slot": "notice-review-body", className: "flex min-w-0 flex-col gap-3 text-sm", children }) : null,
|
|
81
|
+
preset === "resolve" ? /* @__PURE__ */ jsx(
|
|
82
|
+
Textarea,
|
|
83
|
+
{
|
|
84
|
+
value: note,
|
|
85
|
+
onChange: (e) => setNote(e.target.value),
|
|
86
|
+
placeholder: t.noticeNote,
|
|
87
|
+
"aria-label": t.noticeNote,
|
|
88
|
+
disabled: pending
|
|
89
|
+
}
|
|
90
|
+
) : null
|
|
91
|
+
] });
|
|
92
|
+
const footer = /* @__PURE__ */ jsxs(
|
|
93
|
+
"div",
|
|
94
|
+
{
|
|
95
|
+
"data-slot": "notice-review-actions",
|
|
96
|
+
className: "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
|
|
97
|
+
children: [
|
|
98
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", disabled: pending, onClick: () => onOpenChange?.(false), children: t.close }),
|
|
99
|
+
preset === "respond" && onSnooze ? /* @__PURE__ */ jsx(Button, { variant: "outline", disabled: pending, onClick: () => void run(onSnooze), children: t.noticeSnooze }) : null,
|
|
100
|
+
preset === "respond" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
101
|
+
/* @__PURE__ */ jsx(
|
|
102
|
+
Button,
|
|
103
|
+
{
|
|
104
|
+
variant: "outline",
|
|
105
|
+
disabled: pending,
|
|
106
|
+
onClick: () => void run(() => onRespond?.("decline")),
|
|
107
|
+
children: t.noticeDecline
|
|
108
|
+
}
|
|
109
|
+
),
|
|
110
|
+
/* @__PURE__ */ jsx(Button, { disabled: pending, onClick: () => void run(() => onRespond?.("accept")), children: t.noticeAccept })
|
|
111
|
+
] }) : null,
|
|
112
|
+
preset === "acknowledge" ? /* @__PURE__ */ jsx(Button, { disabled: pending || state === "acknowledged" || state === "resolved", onClick: () => void run(onAcknowledge), children: t.noticeAcknowledge }) : null,
|
|
113
|
+
preset === "resolve" ? /* @__PURE__ */ jsx(Button, { disabled: pending || state === "resolved", onClick: () => void run(() => onResolve?.(note)), children: t.noticeResolve }) : null
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
const hooks = {
|
|
118
|
+
"data-slot": "notice-review",
|
|
119
|
+
"data-preset": preset,
|
|
120
|
+
"data-state": state,
|
|
121
|
+
"data-tone": tone
|
|
122
|
+
};
|
|
123
|
+
if (presentation === "sheet") {
|
|
124
|
+
return /* @__PURE__ */ jsx(Sheet, { open, onOpenChange, children: /* @__PURE__ */ jsxs(SheetContent, { ...hooks, className: cn("gap-(--ds-overlay-gap) overflow-y-auto p-(--ds-overlay-p) sm:max-w-md", className), children: [
|
|
125
|
+
/* @__PURE__ */ jsx(SheetHeader, { className: "p-0", children: header }),
|
|
126
|
+
body,
|
|
127
|
+
footer
|
|
128
|
+
] }) });
|
|
129
|
+
}
|
|
130
|
+
return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent, { ...hooks, className: cn("max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-lg", className), children: [
|
|
131
|
+
/* @__PURE__ */ jsx(DialogHeader, { children: header }),
|
|
132
|
+
body,
|
|
133
|
+
footer
|
|
134
|
+
] }) });
|
|
135
|
+
}
|
|
136
|
+
export {
|
|
137
|
+
NoticeReview
|
|
138
|
+
};
|
|
@@ -42,7 +42,9 @@ declare function NotificationList({ className, children, empty, ...props }: Reac
|
|
|
42
42
|
}): React.JSX.Element;
|
|
43
43
|
/** Tiempo relativo («hace 5 minutos», «ayer») en el idioma activo. */
|
|
44
44
|
declare function formatRelativeTime(date: Date, locale: string, now?: number): string;
|
|
45
|
-
declare function NotificationItem({ className, unread, tone, icon, title, description, time, now, state, meta, actions, children, ...props }: Omit<React.ComponentProps<"li">, "title"> & {
|
|
45
|
+
declare function NotificationItem({ className, unread, tone, icon, title, description, time, now, state, meta, actions, onSelect, children, ...props }: Omit<React.ComponentProps<"li">, "title" | "onSelect"> & {
|
|
46
|
+
/** Si existe, el aviso se puede abrir (p. ej. en NoticeReview): el título pasa a ser un botón que cubre la fila. */
|
|
47
|
+
onSelect?: () => void;
|
|
46
48
|
/** Sin leer: punto de marca y fondo resaltado. */
|
|
47
49
|
unread?: boolean;
|
|
48
50
|
/** Tono de estado: colorea la baldosa del icono. */
|
package/dist/ui/notifications.js
CHANGED
|
@@ -218,6 +218,7 @@ function NotificationItem({
|
|
|
218
218
|
state,
|
|
219
219
|
meta,
|
|
220
220
|
actions,
|
|
221
|
+
onSelect,
|
|
221
222
|
children,
|
|
222
223
|
...props
|
|
223
224
|
}) {
|
|
@@ -246,7 +247,16 @@ function NotificationItem({
|
|
|
246
247
|
{
|
|
247
248
|
"data-slot": "notification-item-title",
|
|
248
249
|
className: "min-w-0 flex-1 text-sm font-(--ds-label-weight) text-foreground group-data-[state=resolved]/notification:text-muted-foreground",
|
|
249
|
-
children:
|
|
250
|
+
children: onSelect ? /* @__PURE__ */ jsx(
|
|
251
|
+
"button",
|
|
252
|
+
{
|
|
253
|
+
type: "button",
|
|
254
|
+
"data-slot": "notification-select",
|
|
255
|
+
onClick: onSelect,
|
|
256
|
+
className: "cursor-pointer text-start outline-none after:absolute after:inset-0 focus-visible:after:ring-(length:--ds-ring-width) focus-visible:after:ring-ring",
|
|
257
|
+
children: title
|
|
258
|
+
}
|
|
259
|
+
) : title
|
|
250
260
|
}
|
|
251
261
|
),
|
|
252
262
|
unread ? /* @__PURE__ */ jsx(
|
|
@@ -292,7 +302,7 @@ function NotificationItem({
|
|
|
292
302
|
"div",
|
|
293
303
|
{
|
|
294
304
|
"data-slot": "notification-actions",
|
|
295
|
-
className: "mt-1 flex flex-wrap items-center gap-2",
|
|
305
|
+
className: "relative z-(--ds-z-raised) mt-1 flex flex-wrap items-center gap-2",
|
|
296
306
|
children: actions
|
|
297
307
|
}
|
|
298
308
|
) : null
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type StatGroupPreset = "overview" | "compact" | "comparison";
|
|
4
|
+
declare function StatGroup({ preset, className, ...props }: React.ComponentProps<"div"> & {
|
|
5
|
+
preset?: StatGroupPreset;
|
|
6
|
+
}): React.JSX.Element;
|
|
7
|
+
|
|
8
|
+
export { StatGroup, type StatGroupPreset };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../lib/utils.js";
|
|
3
|
+
const LAYOUT = {
|
|
4
|
+
overview: "gap-(--ds-section-gap) grid-cols-1 @[480px]:grid-cols-2 @[900px]:grid-cols-4",
|
|
5
|
+
compact: "gap-3 grid-cols-2 @[640px]:grid-cols-4",
|
|
6
|
+
comparison: "gap-(--ds-section-gap) grid-cols-1 @[520px]:grid-cols-2"
|
|
7
|
+
};
|
|
8
|
+
function StatGroup({
|
|
9
|
+
preset = "overview",
|
|
10
|
+
className,
|
|
11
|
+
...props
|
|
12
|
+
}) {
|
|
13
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "stat-group", "data-preset": preset, className: "@container min-w-0", children: /* @__PURE__ */ jsx("div", { className: cn("grid min-w-0", LAYOUT[preset], className), ...props }) });
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
StatGroup
|
|
17
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type StepFlowPreset = "quick" | "activation" | "long";
|
|
4
|
+
type StepFlowPresentation = "dialog" | "page";
|
|
5
|
+
type StepFlowProgress = "compact" | "horizontal" | "vertical";
|
|
6
|
+
type StepFlowStep = {
|
|
7
|
+
id: string;
|
|
8
|
+
title: React.ReactNode;
|
|
9
|
+
description?: React.ReactNode;
|
|
10
|
+
/** Se puede omitir: aparece «Omitir» y la etiqueta «Opcional». */
|
|
11
|
+
optional?: boolean;
|
|
12
|
+
/** Bloquea «Siguiente» mientras el paso no esté listo. */
|
|
13
|
+
invalid?: boolean;
|
|
14
|
+
/** Marca el paso con error (tras un intento fallido). */
|
|
15
|
+
error?: boolean;
|
|
16
|
+
content: React.ReactNode;
|
|
17
|
+
};
|
|
18
|
+
type StepFlowProps = {
|
|
19
|
+
steps: StepFlowStep[];
|
|
20
|
+
preset?: StepFlowPreset;
|
|
21
|
+
presentation?: StepFlowPresentation;
|
|
22
|
+
progress?: StepFlowProgress;
|
|
23
|
+
title: React.ReactNode;
|
|
24
|
+
description?: React.ReactNode;
|
|
25
|
+
/** Vista previa o ayuda: columna al final en contenedor ancho; se oculta en estrecho. */
|
|
26
|
+
aside?: React.ReactNode;
|
|
27
|
+
/** Resumen final: añade un último paso con este contenido. */
|
|
28
|
+
review?: React.ReactNode;
|
|
29
|
+
/** Si existe, sustituye al asistente (paso hecho): éxito, error o siguiente acción. */
|
|
30
|
+
result?: React.ReactNode;
|
|
31
|
+
/** Paso actual (id) controlado. */
|
|
32
|
+
value?: string;
|
|
33
|
+
defaultValue?: string;
|
|
34
|
+
onValueChange?: (id: string) => void;
|
|
35
|
+
/** Se llama al terminar el último paso; si devuelve una promesa, bloquea los botones hasta resolverla. */
|
|
36
|
+
onComplete?: () => void | Promise<void>;
|
|
37
|
+
/** Se llama al cancelar o cerrar (tras confirmar si `dirty`). */
|
|
38
|
+
onCancel?: () => void;
|
|
39
|
+
/** Hay cambios sin guardar: pide confirmación antes de cerrar. */
|
|
40
|
+
dirty?: boolean;
|
|
41
|
+
/** Solo `dialog`. */
|
|
42
|
+
open?: boolean;
|
|
43
|
+
onOpenChange?: (open: boolean) => void;
|
|
44
|
+
className?: string;
|
|
45
|
+
};
|
|
46
|
+
declare function StepFlow({ steps, preset, presentation, progress, title, description, aside, review, result, value, defaultValue, onValueChange, onComplete, onCancel, dirty, open, onOpenChange, className, }: StepFlowProps): React.JSX.Element;
|
|
47
|
+
|
|
48
|
+
export { StepFlow, type StepFlowPresentation, type StepFlowPreset, type StepFlowProgress, type StepFlowProps, type StepFlowStep };
|