orbital-ds 0.18.3 → 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.
@@ -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. */
@@ -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: title
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 };