orbital-ds 0.21.0 → 0.25.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 +15 -4
- package/components.manifest.json +113 -1
- package/dist/hooks/use-ds-messages.d.ts +1 -0
- package/dist/lib/echarts-presets.d.ts +75 -1
- package/dist/lib/echarts-presets.js +138 -1
- package/dist/lib/echarts-setup.js +24 -0
- package/dist/lib/i18n.d.ts +1 -0
- package/dist/lib/i18n.js +3 -0
- package/dist/styles.css +7 -2
- package/dist/ui/chart-card.d.ts +28 -0
- package/dist/ui/chart-card.js +79 -0
- package/dist/ui/content-card.d.ts +31 -0
- package/dist/ui/content-card.js +89 -0
- package/dist/ui/data-table.d.ts +5 -2
- package/dist/ui/data-table.js +11 -4
- package/dist/ui/detail-panel.d.ts +16 -0
- package/dist/ui/detail-panel.js +52 -0
- package/dist/ui/entity-list.d.ts +25 -0
- package/dist/ui/entity-list.js +67 -0
- package/dist/ui/form-layout.js +4 -4
- package/dist/ui/loading-state.d.ts +10 -0
- package/dist/ui/loading-state.js +48 -0
- package/dist/ui/mosaic.d.ts +13 -0
- package/dist/ui/mosaic.js +52 -0
- package/dist/ui/page-shell.d.ts +8 -0
- package/dist/ui/page-shell.js +29 -0
- package/dist/ui/stat-group.js +3 -3
- package/dist/ui/step-flow.js +8 -8
- package/docs/CONTRACT.md +9 -2
- package/package.json +3 -2
- package/scripts/doctor.mjs +27 -0
|
@@ -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 { cn } from "../lib/utils.js";
|
|
6
|
+
import { Button } from "./button.js";
|
|
7
|
+
import { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "./card.js";
|
|
8
|
+
import { EChart } from "./echart.js";
|
|
9
|
+
import { EmptyState } from "./empty-state.js";
|
|
10
|
+
import { Skeleton } from "./skeleton.js";
|
|
11
|
+
const PRESETS = {
|
|
12
|
+
glance: { height: "9rem", exportable: false, renderer: "svg" },
|
|
13
|
+
standard: { height: "20rem", exportable: false, renderer: "svg" },
|
|
14
|
+
focus: { height: "27.5rem", exportable: true, renderer: "svg" },
|
|
15
|
+
dense: { height: "22.5rem", exportable: false, renderer: "canvas" }
|
|
16
|
+
};
|
|
17
|
+
const ChartCard = React.forwardRef(function ChartCard2({
|
|
18
|
+
option,
|
|
19
|
+
preset = "standard",
|
|
20
|
+
title,
|
|
21
|
+
description,
|
|
22
|
+
action,
|
|
23
|
+
footer,
|
|
24
|
+
loading = false,
|
|
25
|
+
error,
|
|
26
|
+
onRetry,
|
|
27
|
+
empty = false,
|
|
28
|
+
height,
|
|
29
|
+
renderer,
|
|
30
|
+
exportable,
|
|
31
|
+
fileName,
|
|
32
|
+
onEvents,
|
|
33
|
+
className
|
|
34
|
+
}, ref) {
|
|
35
|
+
const t = useDsMessages();
|
|
36
|
+
const base = PRESETS[preset];
|
|
37
|
+
const h = height ?? base.height;
|
|
38
|
+
const state = error ? "error" : loading ? "loading" : empty ? "empty" : "ready";
|
|
39
|
+
return /* @__PURE__ */ jsxs(
|
|
40
|
+
Card,
|
|
41
|
+
{
|
|
42
|
+
"data-slot": "chart-card",
|
|
43
|
+
"data-preset": preset,
|
|
44
|
+
"data-state": state,
|
|
45
|
+
className: cn("@container/chart-card min-w-0", className),
|
|
46
|
+
children: [
|
|
47
|
+
title || description || action ? /* @__PURE__ */ jsxs(CardHeader, { children: [
|
|
48
|
+
title ? /* @__PURE__ */ jsx(CardTitle, { children: title }) : null,
|
|
49
|
+
description ? /* @__PURE__ */ jsx(CardDescription, { children: description }) : null,
|
|
50
|
+
action ? /* @__PURE__ */ jsx(CardAction, { children: action }) : null
|
|
51
|
+
] }) : null,
|
|
52
|
+
/* @__PURE__ */ jsx(CardContent, { children: state === "error" ? /* @__PURE__ */ jsx(
|
|
53
|
+
EmptyState,
|
|
54
|
+
{
|
|
55
|
+
preset: "error",
|
|
56
|
+
style: { minHeight: h },
|
|
57
|
+
action: onRetry ? /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: onRetry, children: t.entityRetry }) : void 0
|
|
58
|
+
}
|
|
59
|
+
) : state === "loading" ? /* @__PURE__ */ jsx(Skeleton, { role: "status", "aria-busy": "true", "aria-label": t.loading, className: "w-full", style: { height: h } }) : /* @__PURE__ */ jsx(
|
|
60
|
+
EChart,
|
|
61
|
+
{
|
|
62
|
+
ref,
|
|
63
|
+
option,
|
|
64
|
+
height: h,
|
|
65
|
+
renderer: renderer ?? base.renderer,
|
|
66
|
+
exportable: exportable ?? base.exportable,
|
|
67
|
+
fileName,
|
|
68
|
+
empty,
|
|
69
|
+
onEvents
|
|
70
|
+
}
|
|
71
|
+
) }),
|
|
72
|
+
footer ? /* @__PURE__ */ jsx(CardFooter, { className: "text-xs text-muted-foreground", children: footer }) : null
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
export {
|
|
78
|
+
ChartCard
|
|
79
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DsDensity } from '../lib/presets.js';
|
|
3
|
+
import { IconTile } from './icon-tile.js';
|
|
4
|
+
import 'class-variance-authority/types';
|
|
5
|
+
import 'class-variance-authority';
|
|
6
|
+
|
|
7
|
+
type ContentCardPreset = "basic" | "feature" | "media" | "horizontal";
|
|
8
|
+
type ContentCardEmphasis = "elevated" | "outlined" | "filled" | "ghost";
|
|
9
|
+
declare function ContentCard({ preset, emphasis, tone, density, icon, media, title, description, action, footer, href, onSelect, children, className, }: {
|
|
10
|
+
preset?: ContentCardPreset;
|
|
11
|
+
emphasis?: ContentCardEmphasis;
|
|
12
|
+
tone?: React.ComponentProps<typeof IconTile>["tone"];
|
|
13
|
+
density?: DsDensity;
|
|
14
|
+
/** Icono (preset feature o cualquiera con `icon`). */
|
|
15
|
+
icon?: React.ReactNode;
|
|
16
|
+
/** Portada (preset media y horizontal): imagen, vídeo o cualquier nodo. */
|
|
17
|
+
media?: React.ReactNode;
|
|
18
|
+
title: React.ReactNode;
|
|
19
|
+
description?: React.ReactNode;
|
|
20
|
+
/** Acción de la cabecera (menú, botón de icono); sigue pulsable en una tarjeta interactiva. */
|
|
21
|
+
action?: React.ReactNode;
|
|
22
|
+
footer?: React.ReactNode;
|
|
23
|
+
/** Toda la tarjeta navega a esta ruta. */
|
|
24
|
+
href?: string;
|
|
25
|
+
/** Toda la tarjeta es un botón. */
|
|
26
|
+
onSelect?: () => void;
|
|
27
|
+
children?: React.ReactNode;
|
|
28
|
+
className?: string;
|
|
29
|
+
}): React.JSX.Element;
|
|
30
|
+
|
|
31
|
+
export { ContentCard, type ContentCardEmphasis, type ContentCardPreset };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { dsWarn } from "../lib/presets.js";
|
|
5
|
+
import { cn } from "../lib/utils.js";
|
|
6
|
+
import { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "./card.js";
|
|
7
|
+
import { IconTile } from "./icon-tile.js";
|
|
8
|
+
const EMPHASIS = {
|
|
9
|
+
elevated: "",
|
|
10
|
+
outlined: "shadow-none hover:shadow-none",
|
|
11
|
+
filled: "border-transparent bg-muted shadow-none hover:shadow-none",
|
|
12
|
+
ghost: "border-transparent bg-transparent shadow-none hover:shadow-none"
|
|
13
|
+
};
|
|
14
|
+
const DENSITY = {
|
|
15
|
+
compact: "[--ds-card-spacing:var(--ds-card-spacing-sm)] gap-2",
|
|
16
|
+
default: "",
|
|
17
|
+
comfortable: "[--ds-card-spacing:calc(var(--ds-card-spacing)*1.25)]"
|
|
18
|
+
};
|
|
19
|
+
function ContentCard({
|
|
20
|
+
preset = "basic",
|
|
21
|
+
emphasis = "elevated",
|
|
22
|
+
tone = "neutral",
|
|
23
|
+
density = "default",
|
|
24
|
+
icon,
|
|
25
|
+
media,
|
|
26
|
+
title,
|
|
27
|
+
description,
|
|
28
|
+
action,
|
|
29
|
+
footer,
|
|
30
|
+
href,
|
|
31
|
+
onSelect,
|
|
32
|
+
children,
|
|
33
|
+
className
|
|
34
|
+
}) {
|
|
35
|
+
React.useEffect(() => {
|
|
36
|
+
if (href && onSelect) dsWarn("ContentCard", "use either `href` or `onSelect`, not both.");
|
|
37
|
+
if ((preset === "media" || preset === "horizontal") && !media)
|
|
38
|
+
dsWarn("ContentCard", `preset="${preset}" needs the \`media\` prop.`);
|
|
39
|
+
}, [href, onSelect, preset, media]);
|
|
40
|
+
const interactive = Boolean(href || onSelect);
|
|
41
|
+
const stretch = "after:absolute after:inset-0 after:content-[''] outline-none after:rounded-card focus-visible:after:ring-(length:--ds-ring-width) focus-visible:after:ring-(--ds-ring-color)";
|
|
42
|
+
const titleNode = href ? /* @__PURE__ */ jsx("a", { href, className: stretch, children: title }) : onSelect ? /* @__PURE__ */ jsx("button", { type: "button", onClick: onSelect, className: cn("text-start", stretch), children: title }) : title;
|
|
43
|
+
const horizontal = preset === "horizontal";
|
|
44
|
+
const showIcon = icon && preset !== "media" && preset !== "horizontal";
|
|
45
|
+
return /* @__PURE__ */ jsxs(
|
|
46
|
+
Card,
|
|
47
|
+
{
|
|
48
|
+
"data-slot": "content-card",
|
|
49
|
+
"data-preset": preset,
|
|
50
|
+
"data-emphasis": emphasis,
|
|
51
|
+
"data-tone": tone,
|
|
52
|
+
"data-density": density,
|
|
53
|
+
className: cn(
|
|
54
|
+
"@container/content-card relative",
|
|
55
|
+
EMPHASIS[emphasis],
|
|
56
|
+
DENSITY[density],
|
|
57
|
+
interactive && "cursor-pointer hover:bg-muted/40",
|
|
58
|
+
horizontal && "@md/content-card:flex-row @md/content-card:py-0",
|
|
59
|
+
className
|
|
60
|
+
),
|
|
61
|
+
children: [
|
|
62
|
+
media && (preset === "media" || horizontal) ? /* @__PURE__ */ jsx(
|
|
63
|
+
"div",
|
|
64
|
+
{
|
|
65
|
+
"data-slot": "content-card-media",
|
|
66
|
+
className: cn(
|
|
67
|
+
"aspect-(--ds-media-aspect) w-full shrink-0 overflow-hidden bg-(--ds-track-bg) [&>img]:size-full [&>img]:object-cover",
|
|
68
|
+
horizontal && "@md/content-card:aspect-auto @md/content-card:w-1/3"
|
|
69
|
+
),
|
|
70
|
+
children: media
|
|
71
|
+
}
|
|
72
|
+
) : null,
|
|
73
|
+
/* @__PURE__ */ jsxs("div", { className: cn("flex min-w-0 flex-1 flex-col gap-(--ds-card-spacing)", horizontal && "@md/content-card:py-(--ds-card-spacing)"), children: [
|
|
74
|
+
/* @__PURE__ */ jsxs(CardHeader, { children: [
|
|
75
|
+
showIcon ? /* @__PURE__ */ jsx(IconTile, { tone, size: "md", className: "mb-1", children: icon }) : null,
|
|
76
|
+
/* @__PURE__ */ jsx(CardTitle, { children: titleNode }),
|
|
77
|
+
description ? /* @__PURE__ */ jsx(CardDescription, { children: description }) : null,
|
|
78
|
+
action ? /* @__PURE__ */ jsx(CardAction, { className: "relative z-(--ds-z-raised)", children: action }) : null
|
|
79
|
+
] }),
|
|
80
|
+
children ? /* @__PURE__ */ jsx(CardContent, { children }) : null,
|
|
81
|
+
footer ? /* @__PURE__ */ jsx(CardFooter, { className: "relative z-(--ds-z-raised) gap-2", children: footer }) : null
|
|
82
|
+
] })
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
ContentCard
|
|
89
|
+
};
|
package/dist/ui/data-table.d.ts
CHANGED
|
@@ -146,7 +146,10 @@ declare function DataTableBarCell({ value, max, format, tone, className, }: {
|
|
|
146
146
|
tone?: DsDataTone;
|
|
147
147
|
className?: string;
|
|
148
148
|
}): React.JSX.Element;
|
|
149
|
+
type DataTablePreset = "browse" | "manage" | "compact";
|
|
149
150
|
interface DataTableProps<TData extends object> {
|
|
151
|
+
/** Intención: `browse` (consultar), `manage` (seleccionar y actuar) o `compact` (denso). Solo fija valores por defecto. */
|
|
152
|
+
preset?: DataTablePreset;
|
|
150
153
|
columns: DataTableColumn<TData>[];
|
|
151
154
|
data: TData[];
|
|
152
155
|
/** Id estable de cada fila (selección que sobrevive a ordenar y filtrar). Por defecto, el índice. */
|
|
@@ -180,6 +183,6 @@ interface DataTableProps<TData extends object> {
|
|
|
180
183
|
"aria-label"?: string;
|
|
181
184
|
className?: string;
|
|
182
185
|
}
|
|
183
|
-
declare function DataTable<TData extends object>({ columns, data, getRowId, state: controlled, onStateChange, defaultState, searchable, selectable, columnToggle, pageSizes, loading, empty, onRowClick, toolbar, rowActions, density, "aria-label": ariaLabel, className, }: DataTableProps<TData>): React.JSX.Element;
|
|
186
|
+
declare function DataTable<TData extends object>({ columns, data, getRowId, state: controlled, onStateChange, defaultState, preset, searchable, selectable, columnToggle, pageSizes, loading, empty, onRowClick, toolbar, rowActions, density, "aria-label": ariaLabel, className, }: DataTableProps<TData>): React.JSX.Element;
|
|
184
187
|
|
|
185
|
-
export { DATA_TABLE_PAGE_SIZES, DataTable, DataTableBarCell, type DataTableColumn, type DataTableColumnMeta, type DataTableFeatures, type DataTableFilterOption, DataTableNumber, type DataTableProps, type DataTableSearch, type DataTableState, createDataTableColumnHelper, dataTableFeatures, dataTableStateFromSearch, dataTableStateToSearch, validateDataTableSearch };
|
|
188
|
+
export { DATA_TABLE_PAGE_SIZES, DataTable, DataTableBarCell, type DataTableColumn, type DataTableColumnMeta, type DataTableFeatures, type DataTableFilterOption, DataTableNumber, type DataTablePreset, type DataTableProps, type DataTableSearch, type DataTableState, createDataTableColumnHelper, dataTableFeatures, dataTableStateFromSearch, dataTableStateToSearch, validateDataTableSearch };
|
package/dist/ui/data-table.js
CHANGED
|
@@ -274,6 +274,11 @@ function prepareColumns(columns) {
|
|
|
274
274
|
return col;
|
|
275
275
|
});
|
|
276
276
|
}
|
|
277
|
+
const PRESET_DEFAULTS = {
|
|
278
|
+
browse: { searchable: true, selectable: false, columnToggle: true, density: "comfortable" },
|
|
279
|
+
manage: { searchable: true, selectable: true, columnToggle: true, density: "comfortable" },
|
|
280
|
+
compact: { searchable: true, selectable: false, columnToggle: false, density: "compact" }
|
|
281
|
+
};
|
|
277
282
|
function DataTable({
|
|
278
283
|
columns,
|
|
279
284
|
data,
|
|
@@ -281,16 +286,17 @@ function DataTable({
|
|
|
281
286
|
state: controlled,
|
|
282
287
|
onStateChange,
|
|
283
288
|
defaultState,
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
289
|
+
preset = "browse",
|
|
290
|
+
searchable = PRESET_DEFAULTS[preset].searchable,
|
|
291
|
+
selectable = PRESET_DEFAULTS[preset].selectable,
|
|
292
|
+
columnToggle = PRESET_DEFAULTS[preset].columnToggle,
|
|
287
293
|
pageSizes = DATA_TABLE_PAGE_SIZES,
|
|
288
294
|
loading = false,
|
|
289
295
|
empty,
|
|
290
296
|
onRowClick,
|
|
291
297
|
toolbar,
|
|
292
298
|
rowActions,
|
|
293
|
-
density =
|
|
299
|
+
density = PRESET_DEFAULTS[preset].density,
|
|
294
300
|
"aria-label": ariaLabel,
|
|
295
301
|
className
|
|
296
302
|
}) {
|
|
@@ -389,6 +395,7 @@ function DataTable({
|
|
|
389
395
|
"div",
|
|
390
396
|
{
|
|
391
397
|
"data-slot": "data-table",
|
|
398
|
+
"data-preset": preset,
|
|
392
399
|
"data-density": density,
|
|
393
400
|
"aria-busy": loading || void 0,
|
|
394
401
|
className: cn(
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type DetailPanelPreset = "side" | "bottom" | "full";
|
|
4
|
+
declare function DetailPanel({ open, onOpenChange, preset, side, title, description, footer, children, className, }: {
|
|
5
|
+
open?: boolean;
|
|
6
|
+
onOpenChange?: (open: boolean) => void;
|
|
7
|
+
preset?: DetailPanelPreset;
|
|
8
|
+
side?: "top" | "right" | "bottom" | "left";
|
|
9
|
+
title: React.ReactNode;
|
|
10
|
+
description?: React.ReactNode;
|
|
11
|
+
footer?: React.ReactNode;
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
className?: string;
|
|
14
|
+
}): React.JSX.Element;
|
|
15
|
+
|
|
16
|
+
export { DetailPanel, type DetailPanelPreset };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../lib/utils.js";
|
|
4
|
+
import {
|
|
5
|
+
Sheet,
|
|
6
|
+
SheetContent,
|
|
7
|
+
SheetDescription,
|
|
8
|
+
SheetHeader,
|
|
9
|
+
SheetTitle
|
|
10
|
+
} from "./sheet.js";
|
|
11
|
+
const SIDE = {
|
|
12
|
+
side: "right",
|
|
13
|
+
bottom: "bottom",
|
|
14
|
+
full: "right"
|
|
15
|
+
};
|
|
16
|
+
const SIZE = {
|
|
17
|
+
side: "",
|
|
18
|
+
bottom: "max-h-[85dvh]",
|
|
19
|
+
full: "w-full sm:max-w-none"
|
|
20
|
+
};
|
|
21
|
+
function DetailPanel({
|
|
22
|
+
open,
|
|
23
|
+
onOpenChange,
|
|
24
|
+
preset = "side",
|
|
25
|
+
side,
|
|
26
|
+
title,
|
|
27
|
+
description,
|
|
28
|
+
footer,
|
|
29
|
+
children,
|
|
30
|
+
className
|
|
31
|
+
}) {
|
|
32
|
+
return /* @__PURE__ */ jsx(Sheet, { open, onOpenChange, children: /* @__PURE__ */ jsxs(
|
|
33
|
+
SheetContent,
|
|
34
|
+
{
|
|
35
|
+
"data-slot": "detail-panel",
|
|
36
|
+
"data-preset": preset,
|
|
37
|
+
side: side ?? SIDE[preset],
|
|
38
|
+
className: cn("gap-(--ds-overlay-gap) overflow-y-auto", SIZE[preset], className),
|
|
39
|
+
children: [
|
|
40
|
+
/* @__PURE__ */ jsxs(SheetHeader, { children: [
|
|
41
|
+
/* @__PURE__ */ jsx(SheetTitle, { children: title }),
|
|
42
|
+
description ? /* @__PURE__ */ jsx(SheetDescription, { children: description }) : null
|
|
43
|
+
] }),
|
|
44
|
+
/* @__PURE__ */ jsx("div", { "data-slot": "detail-panel-body", className: "flex min-w-0 flex-1 flex-col gap-3 px-(--ds-overlay-p) text-sm", children }),
|
|
45
|
+
footer ? /* @__PURE__ */ jsx("div", { "data-slot": "detail-panel-footer", className: "flex flex-col-reverse gap-2 p-(--ds-overlay-p) sm:flex-row sm:justify-end", children: footer }) : null
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
) });
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
DetailPanel
|
|
52
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type EntityListPreset = "list" | "grid" | "compact";
|
|
4
|
+
declare function EntityList<T>({ items, getKey, renderItem, preset, toolbar, bulk, loading, error, onRetry, filtered, emptyAction, skeletonCount, className, }: {
|
|
5
|
+
items: readonly T[];
|
|
6
|
+
getKey: (item: T) => string | number;
|
|
7
|
+
renderItem: (item: T) => React.ReactNode;
|
|
8
|
+
preset?: EntityListPreset;
|
|
9
|
+
/** Barra superior (FilterBar, buscador…). */
|
|
10
|
+
toolbar?: React.ReactNode;
|
|
11
|
+
/** Barra de acciones en lote (aparece cuando la app tiene filas seleccionadas); la app decide cuándo pasarla. */
|
|
12
|
+
bulk?: React.ReactNode;
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
/** Si hay error, se muestra en lugar de la lista. */
|
|
15
|
+
error?: unknown;
|
|
16
|
+
onRetry?: () => void;
|
|
17
|
+
/** Hay filtros o búsqueda activos (distingue «sin resultados» de «primer uso»). */
|
|
18
|
+
filtered?: boolean;
|
|
19
|
+
/** Acción del estado vacío (crear la primera, quitar filtros…). */
|
|
20
|
+
emptyAction?: React.ReactNode;
|
|
21
|
+
skeletonCount?: number;
|
|
22
|
+
className?: string;
|
|
23
|
+
}): React.JSX.Element;
|
|
24
|
+
|
|
25
|
+
export { EntityList, type EntityListPreset };
|
|
@@ -0,0 +1,67 @@
|
|
|
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 { cn } from "../lib/utils.js";
|
|
6
|
+
import { Button } from "./button.js";
|
|
7
|
+
import { EmptyState } from "./empty-state.js";
|
|
8
|
+
import { Skeleton } from "./skeleton.js";
|
|
9
|
+
const LAYOUT = {
|
|
10
|
+
list: "grid-cols-1 gap-(--ds-list-gap)",
|
|
11
|
+
grid: "grid-cols-1 gap-(--ds-list-gap) @[36rem]:grid-cols-2 @[56rem]:grid-cols-3",
|
|
12
|
+
compact: "grid-cols-1 gap-(--ds-list-gap-compact)"
|
|
13
|
+
};
|
|
14
|
+
function EntityList({
|
|
15
|
+
items,
|
|
16
|
+
getKey,
|
|
17
|
+
renderItem,
|
|
18
|
+
preset = "list",
|
|
19
|
+
toolbar,
|
|
20
|
+
bulk,
|
|
21
|
+
loading = false,
|
|
22
|
+
error,
|
|
23
|
+
onRetry,
|
|
24
|
+
filtered = false,
|
|
25
|
+
emptyAction,
|
|
26
|
+
skeletonCount = 4,
|
|
27
|
+
className
|
|
28
|
+
}) {
|
|
29
|
+
const t = useDsMessages();
|
|
30
|
+
const state = error ? "error" : loading ? "loading" : items.length === 0 ? "empty" : "ready";
|
|
31
|
+
return /* @__PURE__ */ jsxs(
|
|
32
|
+
"div",
|
|
33
|
+
{
|
|
34
|
+
"data-slot": "entity-list",
|
|
35
|
+
"data-preset": preset,
|
|
36
|
+
"data-state": state,
|
|
37
|
+
className: cn("@container flex flex-col gap-(--ds-list-gap)", className),
|
|
38
|
+
children: [
|
|
39
|
+
toolbar,
|
|
40
|
+
bulk ? /* @__PURE__ */ jsx("div", { "data-slot": "entity-list-bulk", role: "toolbar", className: "flex flex-wrap items-center gap-2 rounded-card border border-border bg-muted/50 p-2", children: bulk }) : null,
|
|
41
|
+
state === "error" ? /* @__PURE__ */ jsx(
|
|
42
|
+
EmptyState,
|
|
43
|
+
{
|
|
44
|
+
preset: "error",
|
|
45
|
+
action: onRetry ? /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: onRetry, children: t.entityRetry }) : void 0
|
|
46
|
+
}
|
|
47
|
+
) : state === "loading" ? /* @__PURE__ */ jsx(
|
|
48
|
+
"div",
|
|
49
|
+
{
|
|
50
|
+
"aria-busy": "true",
|
|
51
|
+
className: cn("grid", LAYOUT[preset]),
|
|
52
|
+
children: Array.from({ length: skeletonCount }, (_, i) => /* @__PURE__ */ jsx(
|
|
53
|
+
Skeleton,
|
|
54
|
+
{
|
|
55
|
+
className: cn(preset === "compact" ? "h-12" : "h-24", "w-full")
|
|
56
|
+
},
|
|
57
|
+
i
|
|
58
|
+
))
|
|
59
|
+
}
|
|
60
|
+
) : state === "empty" ? /* @__PURE__ */ jsx(EmptyState, { preset: filtered ? "no-results" : "first-use", action: emptyAction }) : /* @__PURE__ */ jsx("div", { className: cn("grid", LAYOUT[preset]), children: items.map((item) => /* @__PURE__ */ jsx(React.Fragment, { children: renderItem(item) }, getKey(item))) })
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
EntityList
|
|
67
|
+
};
|
package/dist/ui/form-layout.js
CHANGED
|
@@ -42,11 +42,11 @@ function FormLayout({
|
|
|
42
42
|
role: bar ? "region" : void 0,
|
|
43
43
|
"aria-label": bar ? t.formUnsaved : void 0,
|
|
44
44
|
className: cn(
|
|
45
|
-
"flex flex-col-reverse gap-2 @[
|
|
45
|
+
"flex flex-col-reverse gap-2 @[32.5rem]:flex-row @[32.5rem]:items-center @[32.5rem]:justify-end",
|
|
46
46
|
bar && "sticky bottom-0 z-(--ds-z-raised) rounded-card border border-border bg-popover p-3 shadow-card"
|
|
47
47
|
),
|
|
48
48
|
children: [
|
|
49
|
-
bar && /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground @[
|
|
49
|
+
bar && /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground @[32.5rem]:me-auto", children: t.formUnsaved }),
|
|
50
50
|
onDiscard && /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", disabled: saving, onClick: onDiscard, children: discardLabel ?? t.formDiscard }),
|
|
51
51
|
/* @__PURE__ */ jsx(Button, { type: "submit", disabled: saving, "aria-busy": saving || void 0, children: saving ? t.stepFlowSaving : saveLabel ?? t.formSave })
|
|
52
52
|
]
|
|
@@ -69,8 +69,8 @@ function FormSection({
|
|
|
69
69
|
"data-slot": "form-section",
|
|
70
70
|
className: cn(
|
|
71
71
|
"grid min-w-0 gap-(--ds-section-gap)",
|
|
72
|
-
"group-data-[preset=sectioned]/form:@[
|
|
73
|
-
"group-data-[preset=settings]/form:@[
|
|
72
|
+
"group-data-[preset=sectioned]/form:@[43.75rem]:grid-cols-[minmax(10rem,16rem)_minmax(0,1fr)]",
|
|
73
|
+
"group-data-[preset=settings]/form:@[43.75rem]:grid-cols-[minmax(10rem,16rem)_minmax(0,1fr)]",
|
|
74
74
|
className
|
|
75
75
|
),
|
|
76
76
|
...props,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type LoadingStatePreset = "list" | "card" | "table" | "detail";
|
|
4
|
+
declare function LoadingState({ preset, rows, className, }: {
|
|
5
|
+
preset?: LoadingStatePreset;
|
|
6
|
+
rows?: number;
|
|
7
|
+
className?: string;
|
|
8
|
+
}): React.JSX.Element;
|
|
9
|
+
|
|
10
|
+
export { LoadingState, type LoadingStatePreset };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useDsMessages } from "../hooks/use-ds-messages.js";
|
|
3
|
+
import { cn } from "../lib/utils.js";
|
|
4
|
+
import { Skeleton } from "./skeleton.js";
|
|
5
|
+
function LoadingState({
|
|
6
|
+
preset = "list",
|
|
7
|
+
rows = 4,
|
|
8
|
+
className
|
|
9
|
+
}) {
|
|
10
|
+
const t = useDsMessages();
|
|
11
|
+
const n = Array.from({ length: rows }, (_, i) => i);
|
|
12
|
+
return /* @__PURE__ */ jsxs(
|
|
13
|
+
"div",
|
|
14
|
+
{
|
|
15
|
+
"data-slot": "loading-state",
|
|
16
|
+
"data-preset": preset,
|
|
17
|
+
role: "status",
|
|
18
|
+
"aria-busy": "true",
|
|
19
|
+
"aria-label": t.loading,
|
|
20
|
+
className: cn("flex w-full flex-col gap-(--ds-list-gap)", className),
|
|
21
|
+
children: [
|
|
22
|
+
preset === "list" && n.map((i) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
23
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "size-10 shrink-0" }),
|
|
24
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col gap-2", children: [
|
|
25
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-1/3" }),
|
|
26
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-3 w-2/3" })
|
|
27
|
+
] })
|
|
28
|
+
] }, i)),
|
|
29
|
+
preset === "card" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
30
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-1/2" }),
|
|
31
|
+
n.map((i) => /* @__PURE__ */ jsx(Skeleton, { className: "h-3 w-full" }, i))
|
|
32
|
+
] }),
|
|
33
|
+
preset === "table" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
34
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-full" }),
|
|
35
|
+
n.map((i) => /* @__PURE__ */ jsx(Skeleton, { className: "h-6 w-full" }, i))
|
|
36
|
+
] }),
|
|
37
|
+
preset === "detail" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
38
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-1/2" }),
|
|
39
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-1/3" }),
|
|
40
|
+
n.map((i) => /* @__PURE__ */ jsx(Skeleton, { className: "h-20 w-full" }, i))
|
|
41
|
+
] })
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
LoadingState
|
|
48
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type MosaicPreset = "even" | "bento" | "trio";
|
|
4
|
+
declare function Mosaic({ preset, className, ...props }: React.ComponentProps<"div"> & {
|
|
5
|
+
preset?: MosaicPreset;
|
|
6
|
+
}): React.JSX.Element;
|
|
7
|
+
/** Envuelve un hijo para darle span; solo se aplica cuando el contenedor es lo bastante ancho. */
|
|
8
|
+
declare function MosaicItem({ span, rows, className, ...props }: React.ComponentProps<"div"> & {
|
|
9
|
+
span?: 1 | 2 | 3 | 4;
|
|
10
|
+
rows?: 1 | 2 | 3;
|
|
11
|
+
}): React.JSX.Element;
|
|
12
|
+
|
|
13
|
+
export { Mosaic, MosaicItem, type MosaicPreset };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../lib/utils.js";
|
|
3
|
+
const LAYOUT = {
|
|
4
|
+
even: "grid-cols-1 @[32rem]:grid-cols-2 @[56rem]:grid-cols-3",
|
|
5
|
+
bento: "grid-cols-1 @[32rem]:grid-cols-2 @[56rem]:grid-cols-4 @[56rem]:[&>*:first-child]:col-span-2 @[56rem]:[&>*:first-child]:row-span-2",
|
|
6
|
+
trio: "grid-cols-1 @[48rem]:grid-cols-3"
|
|
7
|
+
};
|
|
8
|
+
function Mosaic({
|
|
9
|
+
preset = "even",
|
|
10
|
+
className,
|
|
11
|
+
...props
|
|
12
|
+
}) {
|
|
13
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "mosaic-root", className: "@container w-full", children: /* @__PURE__ */ jsx(
|
|
14
|
+
"div",
|
|
15
|
+
{
|
|
16
|
+
"data-slot": "mosaic",
|
|
17
|
+
"data-preset": preset,
|
|
18
|
+
className: cn(
|
|
19
|
+
"grid auto-rows-[minmax(var(--ds-mosaic-row),auto)] gap-(--ds-list-gap) [&>*]:min-w-0",
|
|
20
|
+
LAYOUT[preset],
|
|
21
|
+
className
|
|
22
|
+
),
|
|
23
|
+
...props
|
|
24
|
+
}
|
|
25
|
+
) });
|
|
26
|
+
}
|
|
27
|
+
const COL = {
|
|
28
|
+
1: "",
|
|
29
|
+
2: "@[32rem]:col-span-2",
|
|
30
|
+
3: "@[56rem]:col-span-3",
|
|
31
|
+
4: "@[56rem]:col-span-4"
|
|
32
|
+
};
|
|
33
|
+
const ROW = { 1: "", 2: "@[32rem]:row-span-2", 3: "@[32rem]:row-span-3" };
|
|
34
|
+
function MosaicItem({
|
|
35
|
+
span = 1,
|
|
36
|
+
rows = 1,
|
|
37
|
+
className,
|
|
38
|
+
...props
|
|
39
|
+
}) {
|
|
40
|
+
return /* @__PURE__ */ jsx(
|
|
41
|
+
"div",
|
|
42
|
+
{
|
|
43
|
+
"data-slot": "mosaic-item",
|
|
44
|
+
className: cn("flex flex-col *:flex-1", COL[span], ROW[rows], className),
|
|
45
|
+
...props
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
Mosaic,
|
|
51
|
+
MosaicItem
|
|
52
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type PageShellPreset = "content" | "detail" | "canvas";
|
|
4
|
+
declare function PageShell({ preset, className, ...props }: React.ComponentProps<"main"> & {
|
|
5
|
+
preset?: PageShellPreset;
|
|
6
|
+
}): React.JSX.Element;
|
|
7
|
+
|
|
8
|
+
export { PageShell, type PageShellPreset };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../lib/utils.js";
|
|
3
|
+
const WIDTH = {
|
|
4
|
+
content: "max-w-(--ds-page-max-w)",
|
|
5
|
+
detail: "max-w-(--ds-page-narrow-w)",
|
|
6
|
+
canvas: "max-w-none"
|
|
7
|
+
};
|
|
8
|
+
function PageShell({
|
|
9
|
+
preset = "content",
|
|
10
|
+
className,
|
|
11
|
+
...props
|
|
12
|
+
}) {
|
|
13
|
+
return /* @__PURE__ */ jsx(
|
|
14
|
+
"main",
|
|
15
|
+
{
|
|
16
|
+
"data-slot": "page-shell",
|
|
17
|
+
"data-preset": preset,
|
|
18
|
+
className: cn(
|
|
19
|
+
"@container mx-auto flex w-full flex-col gap-(--ds-section-gap)",
|
|
20
|
+
WIDTH[preset],
|
|
21
|
+
className
|
|
22
|
+
),
|
|
23
|
+
...props
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
PageShell
|
|
29
|
+
};
|
package/dist/ui/stat-group.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../lib/utils.js";
|
|
3
3
|
const LAYOUT = {
|
|
4
|
-
overview: "gap-(--ds-section-gap) grid-cols-1 @[
|
|
5
|
-
compact: "gap-3 grid-cols-2 @[
|
|
6
|
-
comparison: "gap-(--ds-section-gap) grid-cols-1 @[
|
|
4
|
+
overview: "gap-(--ds-section-gap) grid-cols-1 @[30rem]:grid-cols-2 @[56.25rem]:grid-cols-4",
|
|
5
|
+
compact: "gap-3 grid-cols-2 @[40rem]:grid-cols-4",
|
|
6
|
+
comparison: "gap-(--ds-section-gap) grid-cols-1 @[32.5rem]:grid-cols-2"
|
|
7
7
|
};
|
|
8
8
|
function StatGroup({
|
|
9
9
|
preset = "overview",
|