orbital-ds 0.36.0 → 0.40.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 +1 -1
- package/components.manifest.json +147 -15
- package/dist/hooks/use-ds-messages.d.ts +25 -0
- package/dist/hooks/use-in-view.d.ts +9 -0
- package/dist/hooks/use-in-view.js +33 -0
- package/dist/lib/i18n.d.ts +25 -0
- package/dist/lib/i18n.js +75 -0
- package/dist/lib/image-upload.d.ts +41 -0
- package/dist/lib/image-upload.js +66 -0
- package/dist/styles.css +16 -0
- package/dist/themes/lagoon.css +4 -1
- package/dist/themes/lagoon.scoped.css +4 -1
- package/dist/ui/badge.d.ts +5 -1
- package/dist/ui/badge.js +23 -3
- package/dist/ui/card.d.ts +16 -1
- package/dist/ui/card.js +35 -3
- package/dist/ui/checkbox.js +1 -1
- package/dist/ui/choice-card.js +1 -1
- package/dist/ui/combobox.js +1 -1
- package/dist/ui/confirm-dialog.d.ts +21 -0
- package/dist/ui/confirm-dialog.js +54 -0
- package/dist/ui/content-card.d.ts +20 -3
- package/dist/ui/content-card.js +66 -38
- package/dist/ui/error-state.d.ts +16 -0
- package/dist/ui/error-state.js +42 -0
- package/dist/ui/input-group.js +1 -1
- package/dist/ui/input-otp.js +1 -1
- package/dist/ui/input.js +1 -1
- package/dist/ui/instruction-editor.d.ts +15 -2
- package/dist/ui/instruction-editor.js +139 -16
- package/dist/ui/load-more.d.ts +19 -0
- package/dist/ui/load-more.js +72 -0
- package/dist/ui/loading-state.d.ts +5 -1
- package/dist/ui/loading-state.js +16 -12
- package/dist/ui/mosaic.d.ts +4 -2
- package/dist/ui/mosaic.js +13 -2
- package/dist/ui/native-select.js +1 -1
- package/dist/ui/questionnaire.js +4 -4
- package/dist/ui/radio-group.js +1 -1
- package/dist/ui/reveal.d.ts +11 -0
- package/dist/ui/reveal.js +39 -0
- package/dist/ui/scroll-area.js +1 -1
- package/dist/ui/search-box.d.ts +32 -0
- package/dist/ui/search-box.js +238 -0
- package/dist/ui/select.js +1 -1
- package/dist/ui/show-more.d.ts +12 -0
- package/dist/ui/show-more.js +66 -0
- package/dist/ui/skeleton.d.ts +7 -2
- package/dist/ui/skeleton.js +19 -3
- package/dist/ui/slider.d.ts +19 -2
- package/dist/ui/textarea.js +1 -1
- package/docs/designer/criterio.md +87 -0
- package/docs/designer/revision.md +11 -0
- package/package.json +18 -8
- package/scripts/cli.mjs +1 -0
- package/skill/SKILL.md +7 -3
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { RotateCwIcon } from "lucide-react";
|
|
4
|
+
import { useDsMessages } from "../hooks/use-ds-messages.js";
|
|
5
|
+
import { Button } from "./button.js";
|
|
6
|
+
import { EmptyState } from "./empty-state.js";
|
|
7
|
+
function ErrorState({
|
|
8
|
+
onRetry,
|
|
9
|
+
retrying = false,
|
|
10
|
+
retryLabel,
|
|
11
|
+
action,
|
|
12
|
+
...props
|
|
13
|
+
}) {
|
|
14
|
+
const t = useDsMessages();
|
|
15
|
+
return /* @__PURE__ */ jsx(
|
|
16
|
+
EmptyState,
|
|
17
|
+
{
|
|
18
|
+
preset: "error",
|
|
19
|
+
action: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
20
|
+
onRetry ? /* @__PURE__ */ jsxs(
|
|
21
|
+
Button,
|
|
22
|
+
{
|
|
23
|
+
"data-slot": "error-state-retry",
|
|
24
|
+
variant: "outline",
|
|
25
|
+
disabled: retrying,
|
|
26
|
+
"aria-busy": retrying || void 0,
|
|
27
|
+
onClick: () => void onRetry(),
|
|
28
|
+
children: [
|
|
29
|
+
/* @__PURE__ */ jsx(RotateCwIcon, { "data-icon": "inline-start" }),
|
|
30
|
+
retryLabel ?? t.entityRetry
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
) : null,
|
|
34
|
+
action
|
|
35
|
+
] }),
|
|
36
|
+
...props
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
ErrorState
|
|
42
|
+
};
|
package/dist/ui/input-group.js
CHANGED
|
@@ -12,7 +12,7 @@ function InputGroup({ className, ...props }) {
|
|
|
12
12
|
"data-slot": "input-group",
|
|
13
13
|
role: "group",
|
|
14
14
|
className: cn(
|
|
15
|
-
"group/input-group relative flex h-(--ds-control-h-md) w-full min-w-0 items-center rounded-control shadow-control border border-
|
|
15
|
+
"group/input-group relative flex h-(--ds-control-h-md) w-full min-w-0 items-center rounded-control shadow-control border border-(--ds-field-border) bg-(--ds-field-bg) transition-colors duration-(--ds-motion-snap) outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-data-[align=block-end]:rounded-field-multiline has-data-[align=block-start]:rounded-field-multiline has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-(length:--ds-ring-width) has-[[data-slot=input-group-control]:focus-visible]:ring-(--ds-ring-color) has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-(length:--ds-ring-width) has-[[data-slot][aria-invalid=true]]:ring-(--ds-invalid-ring) has-[textarea]:rounded-field-multiline has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pe-1.5 has-[>[data-align=inline-start]]:[&>input]:ps-1.5",
|
|
16
16
|
className
|
|
17
17
|
),
|
|
18
18
|
...props
|
package/dist/ui/input-otp.js
CHANGED
|
@@ -49,7 +49,7 @@ function InputOTPSlot({
|
|
|
49
49
|
"data-active": isActive,
|
|
50
50
|
"data-filled": char ? true : void 0,
|
|
51
51
|
className: cn(
|
|
52
|
-
"relative flex size-(--ds-control-h-md) items-center justify-center border-y border-e border-
|
|
52
|
+
"relative flex size-(--ds-control-h-md) items-center justify-center border-y border-e border-(--ds-field-border) bg-(--ds-field-bg) text-sm transition-all duration-(--ds-motion-snap) outline-none first:rounded-s-control first:border-s last:rounded-e-control aria-invalid:border-(--ds-invalid-border) data-[active=true]:z-(--ds-z-raised) data-[active=true]:border-ring data-[active=true]:ring-(length:--ds-ring-width) data-[active=true]:ring-(--ds-ring-color) data-[active=true]:aria-invalid:border-(--ds-invalid-border) data-[active=true]:aria-invalid:ring-(--ds-invalid-ring)",
|
|
53
53
|
className
|
|
54
54
|
),
|
|
55
55
|
...props,
|
package/dist/ui/input.js
CHANGED
|
@@ -7,7 +7,7 @@ function Input({ className, type, ...props }) {
|
|
|
7
7
|
type,
|
|
8
8
|
"data-slot": "input",
|
|
9
9
|
className: cn(
|
|
10
|
-
"h-(--ds-control-h-md) w-full min-w-0 rounded-control shadow-control border border-
|
|
10
|
+
"h-(--ds-control-h-md) w-full min-w-0 rounded-control shadow-control border border-(--ds-field-border) bg-(--ds-field-bg) px-(--ds-field-px) py-1 text-base transition-colors duration-(--ds-motion-snap) outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-(--ds-medium-weight) file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-(length:--ds-ring-width) focus-visible:ring-(--ds-ring-color) disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-(--ds-disabled-opacity) aria-invalid:border-(--ds-invalid-border) aria-invalid:ring-(length:--ds-ring-width) aria-invalid:ring-(--ds-invalid-ring) md:text-sm",
|
|
11
11
|
className
|
|
12
12
|
),
|
|
13
13
|
...props
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { ImageUploader } from '../lib/image-upload.js';
|
|
2
3
|
|
|
3
4
|
type InstructionEditorPreset = "prompt" | "document" | "compact";
|
|
4
5
|
/** Lo que devuelve `renderPreview`: el texto final y, si la app los calcula, datos de tamaño (p. ej. tokens TOON frente a JSON). */
|
|
@@ -10,7 +11,8 @@ interface InstructionPreview {
|
|
|
10
11
|
}[];
|
|
11
12
|
}
|
|
12
13
|
type InstructionEditorMode = "visual" | "markdown" | "html" | "preview";
|
|
13
|
-
type Tool = "history" | "heading" | "marks" | "lists" | "blocks";
|
|
14
|
+
type Tool = "history" | "heading" | "marks" | "lists" | "blocks" | "table";
|
|
15
|
+
type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
14
16
|
interface InstructionEditorProps extends Omit<React.ComponentProps<"div">, "onChange" | "defaultValue"> {
|
|
15
17
|
/** Intención: `prompt`, `document` o `compact`. Solo fija valores por defecto. */
|
|
16
18
|
preset?: InstructionEditorPreset;
|
|
@@ -41,11 +43,22 @@ interface InstructionEditorProps extends Omit<React.ComponentProps<"div">, "onCh
|
|
|
41
43
|
readOnly?: boolean;
|
|
42
44
|
/** Herramientas de la barra (por defecto, las del preset). */
|
|
43
45
|
tools?: Tool[];
|
|
46
|
+
/** Niveles de título que ofrece la barra (por defecto, H1 a H3). */
|
|
47
|
+
headingLevels?: HeadingLevel[];
|
|
48
|
+
/**
|
|
49
|
+
* Sube una imagen y devuelve su URL (S3, R2, un Worker…: ver `createPresignedUploader` y `createEndpointUploader`
|
|
50
|
+
* en `orbital-ds/lib/image-upload`). Si se da, aparece el botón de imagen y se admiten pegar y arrastrar imágenes.
|
|
51
|
+
*/
|
|
52
|
+
onUploadImage?: ImageUploader;
|
|
53
|
+
/** Tipos de imagen admitidos (por defecto, `image/*`). */
|
|
54
|
+
imageAccept?: string;
|
|
55
|
+
/** Tamaño máximo en bytes; mayor se rechaza antes de subir. */
|
|
56
|
+
imageMaxBytes?: number;
|
|
44
57
|
/** Muestra el contador de caracteres (por defecto, el del preset). */
|
|
45
58
|
showCount?: boolean;
|
|
46
59
|
/** Nombre accesible del editor. */
|
|
47
60
|
"aria-label"?: string;
|
|
48
61
|
}
|
|
49
|
-
declare function InstructionEditor({ preset, value, defaultValue, onChange, modes, mode: modeProp, defaultMode, onModeChange, variables, syntax, renderPreview, placeholder, readOnly, tools, showCount, className, "aria-label": ariaLabel, ...props }: InstructionEditorProps): React.JSX.Element;
|
|
62
|
+
declare function InstructionEditor({ preset, value, defaultValue, onChange, modes, mode: modeProp, defaultMode, onModeChange, variables, syntax, renderPreview, placeholder, readOnly, tools, onUploadImage, imageAccept, imageMaxBytes, headingLevels, showCount, className, "aria-label": ariaLabel, ...props }: InstructionEditorProps): React.JSX.Element;
|
|
50
63
|
|
|
51
64
|
export { InstructionEditor, type InstructionEditorMode, type InstructionEditorPreset, type InstructionEditorProps, type InstructionPreview };
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { EditorContent, useEditor } from "@tiptap/react";
|
|
5
5
|
import StarterKit from "@tiptap/starter-kit";
|
|
6
6
|
import { Markdown } from "@tiptap/markdown";
|
|
7
|
+
import Image from "@tiptap/extension-image";
|
|
7
8
|
import Placeholder from "@tiptap/extension-placeholder";
|
|
9
|
+
import { Table, TableCell, TableHeader, TableRow } from "@tiptap/extension-table";
|
|
8
10
|
import {
|
|
9
11
|
BoldIcon,
|
|
10
12
|
CodeIcon,
|
|
13
|
+
Heading1Icon,
|
|
11
14
|
Heading2Icon,
|
|
15
|
+
Heading3Icon,
|
|
16
|
+
ImageIcon,
|
|
12
17
|
ItalicIcon,
|
|
13
18
|
ListIcon,
|
|
14
19
|
ListOrderedIcon,
|
|
@@ -16,10 +21,12 @@ import {
|
|
|
16
21
|
Redo2Icon,
|
|
17
22
|
SquareCodeIcon,
|
|
18
23
|
StrikethroughIcon,
|
|
24
|
+
TableIcon,
|
|
19
25
|
Undo2Icon
|
|
20
26
|
} from "lucide-react";
|
|
21
27
|
import { useDsMessages } from "../hooks/use-ds-messages.js";
|
|
22
28
|
import { dsFormat } from "../lib/i18n.js";
|
|
29
|
+
import { checkImageFile, ImageUploadError } from "../lib/image-upload.js";
|
|
23
30
|
import { dsWarn } from "../lib/presets.js";
|
|
24
31
|
import { analyzeTemplate, TEMPLATE_SNIPPETS } from "../lib/template-syntax.js";
|
|
25
32
|
import { cn } from "../lib/utils.js";
|
|
@@ -29,13 +36,14 @@ import { Tabs, TabsList, TabsTrigger } from "./tabs.js";
|
|
|
29
36
|
import { Textarea } from "./textarea.js";
|
|
30
37
|
import { Toggle } from "./toggle.js";
|
|
31
38
|
const PRESET_DEFAULTS = {
|
|
32
|
-
prompt: { modes: ["visual", "markdown", "preview"], tools: ["history", "heading", "marks", "lists", "blocks"], showCount: true, density: "default" },
|
|
33
|
-
document: { modes: ["visual", "markdown", "html", "preview"], tools: ["history", "heading", "marks", "lists", "blocks"], showCount: true, density: "default" },
|
|
39
|
+
prompt: { modes: ["visual", "markdown", "preview"], tools: ["history", "heading", "marks", "lists", "blocks", "table"], showCount: true, density: "default" },
|
|
40
|
+
document: { modes: ["visual", "markdown", "html", "preview"], tools: ["history", "heading", "marks", "lists", "blocks", "table"], showCount: true, density: "default" },
|
|
34
41
|
compact: { modes: ["visual"], tools: ["marks", "lists"], showCount: false, density: "compact" }
|
|
35
42
|
};
|
|
36
43
|
const PROSE = cn(
|
|
37
44
|
"min-h-(--ds-editor-min-h) max-h-(--ds-editor-max-h) overflow-y-auto p-(--ds-editor-p) text-sm outline-none",
|
|
38
45
|
"[&_p]:my-2 [&_h1]:my-3 [&_h1]:text-xl [&_h1]:font-(--ds-heading-weight) [&_h2]:my-3 [&_h2]:text-lg [&_h2]:font-(--ds-title-weight) [&_h3]:my-2 [&_h3]:font-(--ds-title-weight)",
|
|
46
|
+
"[&_img]:my-2 [&_img]:h-auto [&_img]:max-w-full [&_img]:rounded-card [&_table]:my-2 [&_table]:w-full [&_table]:border-collapse [&_th]:border [&_th]:border-border [&_th]:bg-muted [&_th]:p-2 [&_th]:text-start [&_td]:border [&_td]:border-border [&_td]:p-2 [&_td]:align-top",
|
|
39
47
|
"[&_ul]:my-2 [&_ul]:list-disc [&_ul]:ps-6 [&_ol]:my-2 [&_ol]:list-decimal [&_ol]:ps-6",
|
|
40
48
|
"[&_blockquote]:my-2 [&_blockquote]:border-s-2 [&_blockquote]:border-border [&_blockquote]:ps-3 [&_blockquote]:text-muted-foreground",
|
|
41
49
|
"[&_code]:rounded-sm [&_code]:bg-muted [&_code]:px-1 [&_code]:font-mono [&_pre]:my-2 [&_pre]:overflow-x-auto [&_pre]:rounded-md [&_pre]:bg-inset [&_pre]:p-3 [&_pre_code]:bg-transparent [&_pre_code]:p-0",
|
|
@@ -50,7 +58,16 @@ function ToolButton({
|
|
|
50
58
|
}) {
|
|
51
59
|
return /* @__PURE__ */ jsx(Toggle, { size: "sm", "aria-label": label, title: label, pressed: !!pressed, onPressedChange: onPress, disabled, children });
|
|
52
60
|
}
|
|
53
|
-
|
|
61
|
+
const HEADING_ICONS = { 1: /* @__PURE__ */ jsx(Heading1Icon, {}), 2: /* @__PURE__ */ jsx(Heading2Icon, {}), 3: /* @__PURE__ */ jsx(Heading3Icon, {}) };
|
|
62
|
+
const DEFAULT_HEADING_LEVELS = [1, 2, 3];
|
|
63
|
+
const TABLE_TEMPLATE = "\n| Column 1 | Column 2 | Column 3 |\n| --- | --- | --- |\n| | | |\n| | | |\n";
|
|
64
|
+
function headingIcon(level) {
|
|
65
|
+
return HEADING_ICONS[level] ?? /* @__PURE__ */ jsxs("span", { "aria-hidden": true, className: "text-xs font-(--ds-title-weight)", children: [
|
|
66
|
+
"H",
|
|
67
|
+
level
|
|
68
|
+
] });
|
|
69
|
+
}
|
|
70
|
+
function Toolbar({ editor, tools, headingLevels, disabled, onPickImage }) {
|
|
54
71
|
const t = useDsMessages();
|
|
55
72
|
const run = () => editor.chain().focus();
|
|
56
73
|
const groups = [];
|
|
@@ -63,7 +80,17 @@ function Toolbar({ editor, tools, disabled }) {
|
|
|
63
80
|
);
|
|
64
81
|
if (tools.includes("heading"))
|
|
65
82
|
groups.push(
|
|
66
|
-
/* @__PURE__ */ jsx(
|
|
83
|
+
/* @__PURE__ */ jsx(React.Fragment, { children: headingLevels.map((level) => /* @__PURE__ */ jsx(
|
|
84
|
+
ToolButton,
|
|
85
|
+
{
|
|
86
|
+
label: dsFormat(t.editorHeadingLevel, { level }),
|
|
87
|
+
disabled,
|
|
88
|
+
pressed: editor.isActive("heading", { level }),
|
|
89
|
+
onPress: () => run().toggleHeading({ level }).run(),
|
|
90
|
+
children: headingIcon(level)
|
|
91
|
+
},
|
|
92
|
+
level
|
|
93
|
+
)) }, "heading")
|
|
67
94
|
);
|
|
68
95
|
if (tools.includes("marks"))
|
|
69
96
|
groups.push(
|
|
@@ -88,12 +115,31 @@ function Toolbar({ editor, tools, disabled }) {
|
|
|
88
115
|
/* @__PURE__ */ jsx(ToolButton, { label: t.editorCodeBlock, disabled, pressed: editor.isActive("codeBlock"), onPress: () => run().toggleCodeBlock().run(), children: /* @__PURE__ */ jsx(SquareCodeIcon, {}) })
|
|
89
116
|
] }, "blocks")
|
|
90
117
|
);
|
|
118
|
+
if (tools.includes("table")) {
|
|
119
|
+
const inTable = editor.isActive("table");
|
|
120
|
+
groups.push(
|
|
121
|
+
/* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
122
|
+
/* @__PURE__ */ jsx(ToolButton, { label: t.editorTable, disabled: disabled || inTable, onPress: () => run().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run(), children: /* @__PURE__ */ jsx(TableIcon, {}) }),
|
|
123
|
+
inTable ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
124
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "xs", disabled, onClick: () => run().addRowAfter().run(), children: t.editorTableAddRow }),
|
|
125
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "xs", disabled, onClick: () => run().addColumnAfter().run(), children: t.editorTableAddColumn }),
|
|
126
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "xs", disabled, onClick: () => run().deleteRow().run(), children: t.editorTableDeleteRow }),
|
|
127
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "xs", disabled, onClick: () => run().deleteColumn().run(), children: t.editorTableDeleteColumn }),
|
|
128
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "xs", disabled, onClick: () => run().deleteTable().run(), children: t.editorTableDelete })
|
|
129
|
+
] }) : null
|
|
130
|
+
] }, "table")
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
if (onPickImage)
|
|
134
|
+
groups.push(
|
|
135
|
+
/* @__PURE__ */ jsx(ToolButton, { label: t.editorImage, disabled, onPress: onPickImage, children: /* @__PURE__ */ jsx(ImageIcon, {}) }, "image")
|
|
136
|
+
);
|
|
91
137
|
return /* @__PURE__ */ jsx("div", { role: "toolbar", "aria-label": t.editorToolbar, "data-slot": "instruction-editor-toolbar", className: "flex flex-wrap items-center gap-1", children: groups.map((g, i) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
92
138
|
i > 0 ? /* @__PURE__ */ jsx(Separator, { orientation: "vertical", className: "mx-1 h-4" }) : null,
|
|
93
139
|
g
|
|
94
140
|
] }, i)) });
|
|
95
141
|
}
|
|
96
|
-
function applySourceOp(op, text, a, b) {
|
|
142
|
+
function applySourceOp(op, text, a, b, level = 2) {
|
|
97
143
|
const wrap = (m) => {
|
|
98
144
|
const sel = text.slice(a, b);
|
|
99
145
|
if (sel.length >= 2 * m.length && sel.startsWith(m) && sel.endsWith(m)) {
|
|
@@ -120,8 +166,16 @@ function applySourceOp(op, text, a, b) {
|
|
|
120
166
|
return wrap("~~");
|
|
121
167
|
case "code":
|
|
122
168
|
return wrap("`");
|
|
123
|
-
case "heading":
|
|
124
|
-
|
|
169
|
+
case "heading": {
|
|
170
|
+
const mark = "#".repeat(level) + " ";
|
|
171
|
+
const from = text.lastIndexOf("\n", a - 1) + 1;
|
|
172
|
+
const nl = text.indexOf("\n", b);
|
|
173
|
+
const rows = text.slice(from, nl === -1 ? text.length : nl).split("\n");
|
|
174
|
+
const same = rows.every((r) => r.startsWith(mark));
|
|
175
|
+
return lines(() => same ? "" : mark, same ? new RegExp(`^${mark}`) : /^#{1,6} /);
|
|
176
|
+
}
|
|
177
|
+
case "table":
|
|
178
|
+
return { text: text.slice(0, a) + TABLE_TEMPLATE + text.slice(b), start: a + TABLE_TEMPLATE.length, end: a + TABLE_TEMPLATE.length };
|
|
125
179
|
case "bullet":
|
|
126
180
|
return lines(() => "- ", /^[-*] /);
|
|
127
181
|
case "ordered":
|
|
@@ -134,15 +188,17 @@ function applySourceOp(op, text, a, b) {
|
|
|
134
188
|
}
|
|
135
189
|
}
|
|
136
190
|
}
|
|
137
|
-
function SourceToolbar({ tools, onApply }) {
|
|
191
|
+
function SourceToolbar({ tools, headingLevels, onApply, onPickImage }) {
|
|
138
192
|
const t = useDsMessages();
|
|
139
|
-
const btn = (op, label, icon) => /* @__PURE__ */ jsx(ToolButton, { label, onPress: () => onApply(op), children: icon }, op);
|
|
193
|
+
const btn = (op, label, icon, level) => /* @__PURE__ */ jsx(ToolButton, { label, onPress: () => onApply(op, level), children: icon }, level ? `${op}${level}` : op);
|
|
140
194
|
const groups = [];
|
|
141
|
-
if (tools.includes("heading")) groups.push(
|
|
195
|
+
if (tools.includes("heading")) groups.push(headingLevels.map((level) => btn("heading", dsFormat(t.editorHeadingLevel, { level }), headingIcon(level), level)));
|
|
142
196
|
if (tools.includes("marks"))
|
|
143
197
|
groups.push([btn("bold", t.editorBold, /* @__PURE__ */ jsx(BoldIcon, {})), btn("italic", t.editorItalic, /* @__PURE__ */ jsx(ItalicIcon, {})), btn("strike", t.editorStrike, /* @__PURE__ */ jsx(StrikethroughIcon, {})), btn("code", t.editorCode, /* @__PURE__ */ jsx(CodeIcon, {}))]);
|
|
144
198
|
if (tools.includes("lists")) groups.push([btn("bullet", t.editorBulletList, /* @__PURE__ */ jsx(ListIcon, {})), btn("ordered", t.editorOrderedList, /* @__PURE__ */ jsx(ListOrderedIcon, {}))]);
|
|
145
199
|
if (tools.includes("blocks")) groups.push([btn("quote", t.editorQuote, /* @__PURE__ */ jsx(QuoteIcon, {})), btn("codeBlock", t.editorCodeBlock, /* @__PURE__ */ jsx(SquareCodeIcon, {}))]);
|
|
200
|
+
if (tools.includes("table")) groups.push([btn("table", t.editorTable, /* @__PURE__ */ jsx(TableIcon, {}))]);
|
|
201
|
+
if (onPickImage) groups.push([/* @__PURE__ */ jsx(ToolButton, { label: t.editorImage, onPress: onPickImage, children: /* @__PURE__ */ jsx(ImageIcon, {}) }, "image")]);
|
|
146
202
|
return /* @__PURE__ */ jsx("div", { role: "toolbar", "aria-label": t.editorToolbar, "data-slot": "instruction-editor-toolbar", className: "flex flex-wrap items-center gap-1", children: groups.map((g, i) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
147
203
|
i > 0 ? /* @__PURE__ */ jsx(Separator, { orientation: "vertical", className: "mx-1 h-4" }) : null,
|
|
148
204
|
g
|
|
@@ -163,6 +219,10 @@ function InstructionEditor({
|
|
|
163
219
|
placeholder,
|
|
164
220
|
readOnly = false,
|
|
165
221
|
tools,
|
|
222
|
+
onUploadImage,
|
|
223
|
+
imageAccept = "image/*",
|
|
224
|
+
imageMaxBytes,
|
|
225
|
+
headingLevels = DEFAULT_HEADING_LEVELS,
|
|
166
226
|
showCount,
|
|
167
227
|
className,
|
|
168
228
|
"aria-label": ariaLabel,
|
|
@@ -184,15 +244,35 @@ function InstructionEditor({
|
|
|
184
244
|
const current = value ?? markdown;
|
|
185
245
|
const onChangeRef = React.useRef(onChange);
|
|
186
246
|
onChangeRef.current = onChange;
|
|
247
|
+
const uploadRef = React.useRef({ onUploadImage, imageAccept, imageMaxBytes });
|
|
248
|
+
uploadRef.current = { onUploadImage, imageAccept, imageMaxBytes };
|
|
249
|
+
const [imageStatus, setImageStatus] = React.useState("idle");
|
|
250
|
+
const insertImageRef = React.useRef(() => {
|
|
251
|
+
});
|
|
252
|
+
const imageFiles = (list) => Array.from(list ?? []).filter((f) => f.type.startsWith("image/"));
|
|
187
253
|
const editor = useEditor({
|
|
188
|
-
extensions: [StarterKit, Markdown, Placeholder.configure({ placeholder: placeholder ?? t.editorPlaceholder })],
|
|
254
|
+
extensions: [StarterKit, Markdown, ...onUploadImage ? [Image] : [], Table, TableRow, TableHeader, TableCell, Placeholder.configure({ placeholder: placeholder ?? t.editorPlaceholder })],
|
|
189
255
|
content: current,
|
|
190
256
|
contentType: "markdown",
|
|
191
257
|
editable: !readOnly,
|
|
192
258
|
immediatelyRender: false,
|
|
193
259
|
shouldRerenderOnTransaction: true,
|
|
194
260
|
editorProps: {
|
|
195
|
-
attributes: { class: PROSE, role: "textbox", "aria-multiline": "true", ...ariaLabel ? { "aria-label": ariaLabel } : {} }
|
|
261
|
+
attributes: { class: PROSE, role: "textbox", "aria-multiline": "true", ...ariaLabel ? { "aria-label": ariaLabel } : {} },
|
|
262
|
+
handlePaste: (_view, event) => {
|
|
263
|
+
const files = imageFiles(event.clipboardData?.files);
|
|
264
|
+
if (!uploadRef.current.onUploadImage || !files.length) return false;
|
|
265
|
+
event.preventDefault();
|
|
266
|
+
files.forEach((f) => insertImageRef.current(f));
|
|
267
|
+
return true;
|
|
268
|
+
},
|
|
269
|
+
handleDrop: (_view, event) => {
|
|
270
|
+
const files = imageFiles(event.dataTransfer?.files);
|
|
271
|
+
if (!uploadRef.current.onUploadImage || !files.length) return false;
|
|
272
|
+
event.preventDefault();
|
|
273
|
+
files.forEach((f) => insertImageRef.current(f));
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
196
276
|
},
|
|
197
277
|
onUpdate: ({ editor: ed }) => {
|
|
198
278
|
const md = ed.getMarkdown();
|
|
@@ -221,15 +301,33 @@ function InstructionEditor({
|
|
|
221
301
|
fromSource(current.slice(0, a) + text + current.slice(b));
|
|
222
302
|
} else editor?.chain().focus().insertContent(text).run();
|
|
223
303
|
};
|
|
224
|
-
const applyOp = (op) => {
|
|
304
|
+
const applyOp = (op, level) => {
|
|
225
305
|
const el = textareaRef.current;
|
|
226
|
-
const r = applySourceOp(op, current, el?.selectionStart ?? current.length, el?.selectionEnd ?? current.length);
|
|
306
|
+
const r = applySourceOp(op, current, el?.selectionStart ?? current.length, el?.selectionEnd ?? current.length, level);
|
|
227
307
|
fromSource(r.text);
|
|
228
308
|
requestAnimationFrame(() => {
|
|
229
309
|
el?.focus();
|
|
230
310
|
el?.setSelectionRange(r.start, r.end);
|
|
231
311
|
});
|
|
232
312
|
};
|
|
313
|
+
insertImageRef.current = async (file) => {
|
|
314
|
+
const { onUploadImage: up, imageAccept: accept, imageMaxBytes: maxBytes } = uploadRef.current;
|
|
315
|
+
if (!up) return;
|
|
316
|
+
try {
|
|
317
|
+
checkImageFile(file, { accept, maxBytes });
|
|
318
|
+
setImageStatus("uploading");
|
|
319
|
+
const out = await up(file);
|
|
320
|
+
const url = typeof out === "string" ? out : out.url;
|
|
321
|
+
const alt = (typeof out === "string" ? void 0 : out.alt) ?? file.name.replace(/\.[^.]+$/, "");
|
|
322
|
+
if (mode === "markdown") insertText(``);
|
|
323
|
+
else editor?.chain().focus().setImage({ src: url, alt }).run();
|
|
324
|
+
setImageStatus("idle");
|
|
325
|
+
} catch (e) {
|
|
326
|
+
setImageStatus(e instanceof ImageUploadError && (e.code === "type" || e.code === "size") ? e.code : "error");
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
const fileInputRef = React.useRef(null);
|
|
330
|
+
const pickImage = onUploadImage && !readOnly ? () => fileInputRef.current?.click() : void 0;
|
|
233
331
|
const insertVariable = (name) => insertText(`{{${name}}}`);
|
|
234
332
|
const isTemplate = syntax === "template";
|
|
235
333
|
const issues = React.useMemo(() => isTemplate ? analyzeTemplate(current, variables) : [], [isTemplate, current, variables]);
|
|
@@ -263,9 +361,34 @@ function InstructionEditor({
|
|
|
263
361
|
...props,
|
|
264
362
|
children: [
|
|
265
363
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2 border-b border-border p-2", children: [
|
|
266
|
-
mode === "visual" && editor && !readOnly ? /* @__PURE__ */ jsx(Toolbar, { editor, tools: toolList, disabled:
|
|
364
|
+
mode === "visual" && editor && !readOnly ? /* @__PURE__ */ jsx(Toolbar, { editor, tools: toolList, headingLevels, disabled: imageStatus === "uploading", onPickImage: pickImage }) : mode === "markdown" && !readOnly ? /* @__PURE__ */ jsx(SourceToolbar, { tools: toolList.filter((x) => x !== "history"), headingLevels, onApply: applyOp, onPickImage: pickImage }) : /* @__PURE__ */ jsx("span", {}),
|
|
267
365
|
availableModes.length > 1 ? /* @__PURE__ */ jsx(Tabs, { value: mode, onValueChange: (v) => setMode(v), children: /* @__PURE__ */ jsx(TabsList, { "aria-label": t.editorModes, children: availableModes.map((m) => /* @__PURE__ */ jsx(TabsTrigger, { value: m, children: { visual: t.editorModeVisual, markdown: t.editorModeMarkdown, html: t.editorModeHtml, preview: t.editorModePreview }[m] }, m)) }) }) : null
|
|
268
366
|
] }),
|
|
367
|
+
onUploadImage ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
368
|
+
/* @__PURE__ */ jsx(
|
|
369
|
+
"input",
|
|
370
|
+
{
|
|
371
|
+
ref: fileInputRef,
|
|
372
|
+
type: "file",
|
|
373
|
+
hidden: true,
|
|
374
|
+
accept: imageAccept,
|
|
375
|
+
onChange: (e) => {
|
|
376
|
+
imageFiles(e.target.files).forEach((f) => insertImageRef.current(f));
|
|
377
|
+
e.target.value = "";
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
),
|
|
381
|
+
imageStatus !== "idle" ? /* @__PURE__ */ jsx(
|
|
382
|
+
"p",
|
|
383
|
+
{
|
|
384
|
+
"data-slot": "instruction-editor-image-status",
|
|
385
|
+
"data-status": imageStatus,
|
|
386
|
+
role: imageStatus === "uploading" ? "status" : "alert",
|
|
387
|
+
className: "px-2 text-xs text-muted-foreground data-[status=error]:text-destructive data-[status=size]:text-destructive data-[status=type]:text-destructive",
|
|
388
|
+
children: { uploading: t.editorImageUploading, error: t.editorImageError, type: t.editorImageType, size: t.editorImageSize }[imageStatus]
|
|
389
|
+
}
|
|
390
|
+
) : null
|
|
391
|
+
] }) : null,
|
|
269
392
|
variables?.length && editingSource ? /* @__PURE__ */ jsxs("div", { "data-slot": "instruction-editor-variables", className: "flex flex-wrap items-center gap-1 px-2", children: [
|
|
270
393
|
/* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t.editorVariables }),
|
|
271
394
|
variables.map((v) => /* @__PURE__ */ jsx(Button, { variant: "outline", size: "xs", onClick: () => insertVariable(v), children: /* @__PURE__ */ jsx("code", { children: `{{${v}}}` }) }, v))
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
declare function LoadMore({ hasMore, loading, error, onLoadMore, remaining, loadedCount, auto, autoLimit, rootMargin, label, endLabel, className, ...props }: Omit<React.ComponentProps<"div">, "children"> & {
|
|
4
|
+
hasMore: boolean;
|
|
5
|
+
loading?: boolean;
|
|
6
|
+
error?: boolean;
|
|
7
|
+
onLoadMore: () => void | Promise<void>;
|
|
8
|
+
/** Elementos que faltan: se pinta «Cargar más (24)». */
|
|
9
|
+
remaining?: number;
|
|
10
|
+
/** Cuántos acaba de traer la última carga: se anuncia a los lectores. */
|
|
11
|
+
loadedCount?: number;
|
|
12
|
+
auto?: boolean;
|
|
13
|
+
autoLimit?: number;
|
|
14
|
+
rootMargin?: string;
|
|
15
|
+
label?: React.ReactNode;
|
|
16
|
+
endLabel?: React.ReactNode;
|
|
17
|
+
}): React.JSX.Element;
|
|
18
|
+
|
|
19
|
+
export { LoadMore };
|
|
@@ -0,0 +1,72 @@
|
|
|
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 { cn } from "../lib/utils.js";
|
|
7
|
+
import { Button } from "./button.js";
|
|
8
|
+
import { Spinner } from "./spinner.js";
|
|
9
|
+
function LoadMore({
|
|
10
|
+
hasMore,
|
|
11
|
+
loading = false,
|
|
12
|
+
error = false,
|
|
13
|
+
onLoadMore,
|
|
14
|
+
remaining,
|
|
15
|
+
loadedCount,
|
|
16
|
+
auto = false,
|
|
17
|
+
autoLimit = 3,
|
|
18
|
+
rootMargin = "0px 0px 240px 0px",
|
|
19
|
+
label,
|
|
20
|
+
endLabel,
|
|
21
|
+
className,
|
|
22
|
+
...props
|
|
23
|
+
}) {
|
|
24
|
+
const t = useDsMessages();
|
|
25
|
+
const sentinel = React.useRef(null);
|
|
26
|
+
const autoCount = React.useRef(0);
|
|
27
|
+
const busy = React.useRef(false);
|
|
28
|
+
busy.current = loading;
|
|
29
|
+
const cb = React.useRef(onLoadMore);
|
|
30
|
+
cb.current = onLoadMore;
|
|
31
|
+
React.useEffect(() => {
|
|
32
|
+
const el = sentinel.current;
|
|
33
|
+
if (!auto || !hasMore || error || !el || typeof IntersectionObserver === "undefined") return;
|
|
34
|
+
const io = new IntersectionObserver(
|
|
35
|
+
([entry]) => {
|
|
36
|
+
if (!entry?.isIntersecting || busy.current || autoCount.current >= autoLimit) return;
|
|
37
|
+
autoCount.current += 1;
|
|
38
|
+
void cb.current();
|
|
39
|
+
},
|
|
40
|
+
{ rootMargin }
|
|
41
|
+
);
|
|
42
|
+
io.observe(el);
|
|
43
|
+
return () => io.disconnect();
|
|
44
|
+
}, [auto, hasMore, error, autoLimit, rootMargin]);
|
|
45
|
+
const state = error ? "error" : loading ? "loading" : hasMore ? "idle" : "end";
|
|
46
|
+
const status = state === "loading" ? t.loading : state === "end" ? endLabel ?? t.loadMoreEnd : loadedCount ? dsFormat(t.loadMoreDone, { count: loadedCount }) : "";
|
|
47
|
+
return /* @__PURE__ */ jsxs("div", { "data-slot": "load-more", "data-state": state, className: cn("flex flex-col items-center gap-2 py-2", className), ...props, children: [
|
|
48
|
+
hasMore || error ? /* @__PURE__ */ jsxs(
|
|
49
|
+
Button,
|
|
50
|
+
{
|
|
51
|
+
"data-slot": "load-more-button",
|
|
52
|
+
variant: "outline",
|
|
53
|
+
disabled: loading,
|
|
54
|
+
"aria-busy": loading || void 0,
|
|
55
|
+
onClick: () => {
|
|
56
|
+
autoCount.current = 0;
|
|
57
|
+
void onLoadMore();
|
|
58
|
+
},
|
|
59
|
+
children: [
|
|
60
|
+
loading ? /* @__PURE__ */ jsx(Spinner, {}) : null,
|
|
61
|
+
error ? t.entityRetry : label ?? t.loadMore,
|
|
62
|
+
!error && remaining ? ` (${remaining})` : ""
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
) : null,
|
|
66
|
+
/* @__PURE__ */ jsx("div", { ref: sentinel, "aria-hidden": "true", className: "h-px w-full" }),
|
|
67
|
+
/* @__PURE__ */ jsx("p", { "data-slot": "load-more-status", role: "status", "aria-live": "polite", className: cn("text-sm text-muted-foreground", !status && "sr-only"), children: status })
|
|
68
|
+
] });
|
|
69
|
+
}
|
|
70
|
+
export {
|
|
71
|
+
LoadMore
|
|
72
|
+
};
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
3
|
type LoadingStatePreset = "list" | "card" | "table" | "detail";
|
|
4
|
-
declare function LoadingState({ preset, rows, className, }: {
|
|
4
|
+
declare function LoadingState({ preset, rows, label, shimmer, className, }: {
|
|
5
5
|
preset?: LoadingStatePreset;
|
|
6
6
|
rows?: number;
|
|
7
|
+
/** Texto visible bajo la forma («Cargando vista de proceso…»); también es el nombre accesible si es texto. */
|
|
8
|
+
label?: React.ReactNode;
|
|
9
|
+
/** Brillo en vez de latido en los bloques. */
|
|
10
|
+
shimmer?: boolean;
|
|
7
11
|
className?: string;
|
|
8
12
|
}): React.JSX.Element;
|
|
9
13
|
|
package/dist/ui/loading-state.js
CHANGED
|
@@ -5,9 +5,12 @@ import { Skeleton } from "./skeleton.js";
|
|
|
5
5
|
function LoadingState({
|
|
6
6
|
preset = "list",
|
|
7
7
|
rows = 4,
|
|
8
|
+
label,
|
|
9
|
+
shimmer = false,
|
|
8
10
|
className
|
|
9
11
|
}) {
|
|
10
12
|
const t = useDsMessages();
|
|
13
|
+
const variant = shimmer ? "shimmer" : "default";
|
|
11
14
|
const n = Array.from({ length: rows }, (_, i) => i);
|
|
12
15
|
return /* @__PURE__ */ jsxs(
|
|
13
16
|
"div",
|
|
@@ -16,29 +19,30 @@ function LoadingState({
|
|
|
16
19
|
"data-preset": preset,
|
|
17
20
|
role: "status",
|
|
18
21
|
"aria-busy": "true",
|
|
19
|
-
"aria-label": t.loading,
|
|
22
|
+
"aria-label": typeof label === "string" ? label : t.loading,
|
|
20
23
|
className: cn("flex w-full flex-col gap-(--ds-list-gap)", className),
|
|
21
24
|
children: [
|
|
22
25
|
preset === "list" && n.map((i) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
23
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "size-10 shrink-0" }),
|
|
26
|
+
/* @__PURE__ */ jsx(Skeleton, { variant, className: "size-10 shrink-0" }),
|
|
24
27
|
/* @__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" })
|
|
28
|
+
/* @__PURE__ */ jsx(Skeleton, { variant, className: "h-4 w-1/3" }),
|
|
29
|
+
/* @__PURE__ */ jsx(Skeleton, { variant, className: "h-3 w-2/3" })
|
|
27
30
|
] })
|
|
28
31
|
] }, i)),
|
|
29
32
|
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))
|
|
33
|
+
/* @__PURE__ */ jsx(Skeleton, { variant, className: "h-5 w-1/2" }),
|
|
34
|
+
n.map((i) => /* @__PURE__ */ jsx(Skeleton, { variant, className: "h-3 w-full" }, i))
|
|
32
35
|
] }),
|
|
33
36
|
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))
|
|
37
|
+
/* @__PURE__ */ jsx(Skeleton, { variant, className: "h-8 w-full" }),
|
|
38
|
+
n.map((i) => /* @__PURE__ */ jsx(Skeleton, { variant, className: "h-6 w-full" }, i))
|
|
36
39
|
] }),
|
|
37
40
|
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
|
-
] })
|
|
41
|
+
/* @__PURE__ */ jsx(Skeleton, { variant, className: "h-8 w-1/2" }),
|
|
42
|
+
/* @__PURE__ */ jsx(Skeleton, { variant, className: "h-4 w-1/3" }),
|
|
43
|
+
n.map((i) => /* @__PURE__ */ jsx(Skeleton, { variant, className: "h-20 w-full" }, i))
|
|
44
|
+
] }),
|
|
45
|
+
label ? /* @__PURE__ */ jsx("p", { "data-slot": "loading-state-label", className: "text-sm text-muted-foreground", children: label }) : null
|
|
42
46
|
]
|
|
43
47
|
}
|
|
44
48
|
);
|
package/dist/ui/mosaic.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
type MosaicPreset = "even" | "bento" | "trio";
|
|
3
|
+
type MosaicPreset = "even" | "bento" | "trio" | "hero" | "showcase";
|
|
4
4
|
declare function Mosaic({ preset, className, ...props }: React.ComponentProps<"div"> & {
|
|
5
5
|
preset?: MosaicPreset;
|
|
6
6
|
}): React.JSX.Element;
|
|
7
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"> & {
|
|
8
|
+
declare function MosaicItem({ span, rows, tone, className, ...props }: React.ComponentProps<"div"> & {
|
|
9
9
|
span?: 1 | 2 | 3 | 4;
|
|
10
10
|
rows?: 1 | 2 | 3;
|
|
11
|
+
/** Tono de la celda para alternar ritmo: `default` · `muted` (hundida) · `brand` (color de marca). */
|
|
12
|
+
tone?: "default" | "muted" | "brand";
|
|
11
13
|
}): React.JSX.Element;
|
|
12
14
|
|
|
13
15
|
export { Mosaic, MosaicItem, type MosaicPreset };
|
package/dist/ui/mosaic.js
CHANGED
|
@@ -3,7 +3,9 @@ import { cn } from "../lib/utils.js";
|
|
|
3
3
|
const LAYOUT = {
|
|
4
4
|
even: "grid-cols-1 @[32rem]:grid-cols-2 @[56rem]:grid-cols-3",
|
|
5
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"
|
|
6
|
+
trio: "grid-cols-1 @[48rem]:grid-cols-3",
|
|
7
|
+
hero: "grid-cols-1 @[40rem]:grid-cols-3 @[40rem]:[&>*:first-child]:col-span-2 @[40rem]:[&>*:first-child]:row-span-2",
|
|
8
|
+
showcase: "grid-cols-1 @[32rem]:grid-cols-2 @[56rem]:grid-cols-6 @[56rem]:[&>*:nth-child(1)]:col-span-4 @[56rem]:[&>*:nth-child(1)]:row-span-2 @[56rem]:[&>*:nth-child(2)]:col-span-2 @[56rem]:[&>*:nth-child(3)]:col-span-2 @[56rem]:[&>*:nth-child(n+4)]:col-span-2"
|
|
7
9
|
};
|
|
8
10
|
function Mosaic({
|
|
9
11
|
preset = "even",
|
|
@@ -34,6 +36,7 @@ const ROW = { 1: "", 2: "@[32rem]:row-span-2", 3: "@[32rem]:row-span-3" };
|
|
|
34
36
|
function MosaicItem({
|
|
35
37
|
span = 1,
|
|
36
38
|
rows = 1,
|
|
39
|
+
tone = "default",
|
|
37
40
|
className,
|
|
38
41
|
...props
|
|
39
42
|
}) {
|
|
@@ -41,7 +44,15 @@ function MosaicItem({
|
|
|
41
44
|
"div",
|
|
42
45
|
{
|
|
43
46
|
"data-slot": "mosaic-item",
|
|
44
|
-
|
|
47
|
+
"data-tone": tone === "default" ? void 0 : tone,
|
|
48
|
+
className: cn(
|
|
49
|
+
"flex flex-col *:flex-1",
|
|
50
|
+
tone === "muted" && "*:border-transparent *:bg-muted *:shadow-none",
|
|
51
|
+
tone === "brand" && "*:border-transparent *:bg-primary *:text-primary-foreground *:shadow-none *:[&_[data-slot=card-description]]:text-primary-foreground",
|
|
52
|
+
COL[span],
|
|
53
|
+
ROW[rows],
|
|
54
|
+
className
|
|
55
|
+
),
|
|
45
56
|
...props
|
|
46
57
|
}
|
|
47
58
|
);
|
package/dist/ui/native-select.js
CHANGED
|
@@ -21,7 +21,7 @@ function NativeSelect({
|
|
|
21
21
|
{
|
|
22
22
|
"data-slot": "native-select",
|
|
23
23
|
"data-size": size,
|
|
24
|
-
className: "h-(--ds-control-h-md) w-full min-w-0 cursor-pointer appearance-none rounded-control shadow-control border border-
|
|
24
|
+
className: "h-(--ds-control-h-md) w-full min-w-0 cursor-pointer appearance-none rounded-control shadow-control border border-(--ds-field-border) bg-(--ds-field-bg) py-1 pe-8 ps-(--ds-field-px) text-sm transition-colors duration-(--ds-motion-snap) outline-none select-none selection:bg-primary selection:text-primary-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-(length:--ds-ring-width) focus-visible:ring-(--ds-ring-color) disabled:pointer-events-none disabled:cursor-not-allowed aria-invalid:border-(--ds-invalid-border) aria-invalid:ring-(length:--ds-ring-width) aria-invalid:ring-(--ds-invalid-ring) data-[size=sm]:h-(--ds-control-h-sm) hover:bg-(--ds-field-bg-hover)",
|
|
25
25
|
...props
|
|
26
26
|
}
|
|
27
27
|
),
|