orbital-ds 0.36.0 → 0.39.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "package": "orbital-ds",
3
- "version": "0.36.0",
3
+ "version": "0.39.0",
4
4
  "engine": "@base-ui/react",
5
5
  "docs": [
6
6
  "README.md",
@@ -392,8 +392,13 @@
392
392
  "Badge",
393
393
  "badgeVariants"
394
394
  ],
395
- "slots": [],
396
- "optionalPeers": []
395
+ "slots": [
396
+ "badge-dot"
397
+ ],
398
+ "optionalPeers": [],
399
+ "notes": [
400
+ "`dot` pone el punto de estado delante de la etiqueta y `size=\"sm\"` la compacta (listas densas, celdas de tabla). Para un estado con pulso o nivel semántico, mejor StatusBadge."
401
+ ]
397
402
  },
398
403
  "banner": {
399
404
  "import": "orbital-ds/ui/banner",
@@ -819,6 +824,22 @@
819
824
  "El título nombra la acción y el objeto; el botón repite el verbo, no «Aceptar»."
820
825
  ]
821
826
  },
827
+ "confirm-dialog": {
828
+ "import": "orbital-ds/ui/confirm-dialog",
829
+ "exports": [
830
+ "ConfirmDialogProvider",
831
+ "type ConfirmOptions",
832
+ "useConfirm"
833
+ ],
834
+ "slots": [
835
+ "confirm-action"
836
+ ],
837
+ "optionalPeers": [],
838
+ "notes": [
839
+ "Para «borrar» o «descartar» llamado desde un manejador (`if (await confirm(...))`): sin `useState` de apertura en cada pantalla. Si el diálogo vive junto a un botón concreto, usa ConfirmAction.",
840
+ "Un solo provider en la raíz; el título nombra la acción y el objeto y el botón repite el verbo. Cancelar, Escape o clic fuera resuelven `false`."
841
+ ]
842
+ },
822
843
  "connected-accounts": {
823
844
  "import": "orbital-ds/ui/connected-accounts",
824
845
  "exports": [
@@ -1342,6 +1363,20 @@
1342
1363
  "Siempre con una salida: `actions` con un botón principal (inicio, reintentar, volver). Para la ruta desconocida de un router, monta ErrorPage en su componente de «no encontrado»."
1343
1364
  ]
1344
1365
  },
1366
+ "error-state": {
1367
+ "import": "orbital-ds/ui/error-state",
1368
+ "exports": [
1369
+ "ErrorState"
1370
+ ],
1371
+ "slots": [
1372
+ "empty-state",
1373
+ "error-state-retry"
1374
+ ],
1375
+ "optionalPeers": [],
1376
+ "notes": [
1377
+ "Para el fallo de carga de una lista, tarjeta o sección: título y descripción por defecto y botón de reintento. `description` admite el mensaje del error si es seguro mostrarlo. Página completa → ErrorPage; sin datos y sin fallo → EmptyState."
1378
+ ]
1379
+ },
1345
1380
  "eyebrow": {
1346
1381
  "import": "orbital-ds/ui/eyebrow",
1347
1382
  "exports": [
@@ -1620,6 +1655,7 @@
1620
1655
  "instruction-editor",
1621
1656
  "instruction-editor-body",
1622
1657
  "instruction-editor-count",
1658
+ "instruction-editor-image-status",
1623
1659
  "instruction-editor-issues",
1624
1660
  "instruction-editor-preview",
1625
1661
  "instruction-editor-snippets",
@@ -1628,7 +1664,9 @@
1628
1664
  "instruction-editor-variables"
1629
1665
  ],
1630
1666
  "optionalPeers": [
1667
+ "@tiptap/extension-image",
1631
1668
  "@tiptap/extension-placeholder",
1669
+ "@tiptap/extension-table",
1632
1670
  "@tiptap/markdown",
1633
1671
  "@tiptap/react",
1634
1672
  "@tiptap/starter-kit"
@@ -1648,8 +1686,11 @@
1648
1686
  },
1649
1687
  "notes": [
1650
1688
  "Preset `prompt` para instrucciones o prompts de sistema (el modelo recibe el Markdown); `document` para texto largo con vista HTML; `compact` para notas y comentarios.",
1651
- "Tiptap es dependencia opcional: instala `@tiptap/react @tiptap/pm @tiptap/starter-kit @tiptap/markdown @tiptap/extension-placeholder`. Carga el componente con `React.lazy` si quieres que no pese en el resto de la app.",
1689
+ "Tiptap es dependencia opcional: instala `@tiptap/react @tiptap/pm @tiptap/starter-kit @tiptap/markdown @tiptap/extension-placeholder @tiptap/extension-table`. Carga el componente con `React.lazy` si quieres que no pese en el resto de la app.",
1652
1690
  "En la vista Markdown la barra inserta la sintaxis en el texto (##, **, listas, citas, bloque de código) sobre la selección y la quita si ya está; sin deshacer/rehacer propios (usa el del navegador).",
1691
+ "Seguridad: la extensión de imagen solo se registra con `onUploadImage`; sin él, un `![](https://…)` del Markdown no se pinta (no se cargan recursos externos de un texto que no es de confianza). Con él, las imágenes del documento se cargan desde su URL: sirve las tuyas desde un dominio propio y, si el texto viene de terceros, valida las URL en la app.",
1692
+ "Imágenes: con `onUploadImage` (file → URL) aparece el botón de imagen y se admiten pegar y arrastrar. orbital-ds no conoce el almacenamiento: `createPresignedUploader` (S3 y R2 por URL prefirmada) y `createEndpointUploader` (un Worker con R2, una API) de `orbital-ds/lib/image-upload` lo conectan; las claves viven en el servidor. En Markdown queda `![alt](url)`.",
1693
+ "Títulos H1–H3 por defecto (`headingLevels` los cambia). Tablas: la herramienta `table` inserta una de 3×3 con cabecera y, dentro de ella, añade/quita filas y columnas; sale como tabla Markdown (GFM). Sin celdas combinadas ni listas dentro de la celda: Markdown no las admite.",
1653
1694
  "La vista HTML es solo de lectura (no se edita HTML ni se inyecta con innerHTML): la fuente de verdad es el Markdown.",
1654
1695
  "Las variables se insertan como texto `{{nombre}}`; sustituirlas al enviar el prompt es cosa de la app.",
1655
1696
  "`syntax=\"template\"` reconoce `{{v | \"x\"}}`, `{{v ? \"a\" : \"b\"}}`, `[[IF]]/[[ELSE]]/[[UNLESS]]`: añade fragmentos a la barra y avisa de condiciones que el motor trataría como falsas, bloques sin cerrar y variables fuera de `variables`. El editor no renderiza plantillas.",
@@ -1752,7 +1793,8 @@
1752
1793
  "type LoadingStatePreset"
1753
1794
  ],
1754
1795
  "slots": [
1755
- "loading-state"
1796
+ "loading-state",
1797
+ "loading-state-label"
1756
1798
  ],
1757
1799
  "optionalPeers": [],
1758
1800
  "presets": {
@@ -1771,7 +1813,8 @@
1771
1813
  }
1772
1814
  },
1773
1815
  "notes": [
1774
- "Mientras carga, pinta la forma de lo que vendrá: `list` para filas, `card` para una tarjeta, `table` para una tabla, `detail` para una ficha."
1816
+ "Mientras carga, pinta la forma de lo que vendrá: `list` para filas, `card` para una tarjeta, `table` para una tabla, `detail` para una ficha.",
1817
+ "`label` añade un texto visible bajo la forma (p. ej. el nombre de lo que se carga); `shimmer` cambia el latido por un brillo."
1775
1818
  ]
1776
1819
  },
1777
1820
  "locale-switcher": {
@@ -2728,20 +2771,23 @@
2728
2771
  "skeleton": {
2729
2772
  "import": "orbital-ds/ui/skeleton",
2730
2773
  "exports": [
2731
- "Skeleton"
2774
+ "Skeleton",
2775
+ "skeletonVariants"
2732
2776
  ],
2733
2777
  "slots": [
2734
2778
  "skeleton"
2735
2779
  ],
2736
2780
  "optionalPeers": [],
2737
2781
  "notes": [
2738
- "Cargando: Skeleton con la forma del contenido, no un spinner a pantalla completa."
2782
+ "Cargando: Skeleton con la forma del contenido, no un spinner a pantalla completa.",
2783
+ "`variant=\"shimmer\"` pasa un brillo por el bloque (ritmo `--ds-motion-shimmer`, quieto con movimiento reducido); el `default` late. Úsalo en tarjetas y bloques grandes."
2739
2784
  ]
2740
2785
  },
2741
2786
  "slider": {
2742
2787
  "import": "orbital-ds/ui/slider",
2743
2788
  "exports": [
2744
- "Slider"
2789
+ "Slider",
2790
+ "type SliderProps"
2745
2791
  ],
2746
2792
  "slots": [
2747
2793
  "slider",
@@ -2750,7 +2796,10 @@
2750
2796
  "slider-thumb",
2751
2797
  "slider-track"
2752
2798
  ],
2753
- "optionalPeers": []
2799
+ "optionalPeers": [],
2800
+ "notes": [
2801
+ "Con un número en `value`/`defaultValue` hay UN tirador y `onValueChange` recibe un número; con una lista, un rango y recibe una lista. Sin normalizar a mano en cada uso."
2802
+ ]
2754
2803
  },
2755
2804
  "sonner": {
2756
2805
  "import": "orbital-ds/ui/sonner",
@@ -154,6 +154,18 @@ declare const DsMessagesContext: React.Context<{
154
154
  editorStrike: string;
155
155
  editorCode: string;
156
156
  editorHeading: string;
157
+ editorHeadingLevel: string;
158
+ editorTable: string;
159
+ editorTableAddRow: string;
160
+ editorTableAddColumn: string;
161
+ editorTableDeleteRow: string;
162
+ editorTableDeleteColumn: string;
163
+ editorTableDelete: string;
164
+ editorImage: string;
165
+ editorImageUploading: string;
166
+ editorImageError: string;
167
+ editorImageType: string;
168
+ editorImageSize: string;
157
169
  editorBulletList: string;
158
170
  editorOrderedList: string;
159
171
  editorQuote: string;
@@ -153,6 +153,18 @@ declare const en: {
153
153
  editorStrike: string;
154
154
  editorCode: string;
155
155
  editorHeading: string;
156
+ editorHeadingLevel: string;
157
+ editorTable: string;
158
+ editorTableAddRow: string;
159
+ editorTableAddColumn: string;
160
+ editorTableDeleteRow: string;
161
+ editorTableDeleteColumn: string;
162
+ editorTableDelete: string;
163
+ editorImage: string;
164
+ editorImageUploading: string;
165
+ editorImageError: string;
166
+ editorImageType: string;
167
+ editorImageSize: string;
156
168
  editorBulletList: string;
157
169
  editorOrderedList: string;
158
170
  editorQuote: string;
package/dist/lib/i18n.js CHANGED
@@ -152,6 +152,18 @@ const en = {
152
152
  editorStrike: "Strikethrough",
153
153
  editorCode: "Inline code",
154
154
  editorHeading: "Heading",
155
+ editorHeadingLevel: "Heading {level}",
156
+ editorTable: "Insert table",
157
+ editorTableAddRow: "Add row",
158
+ editorTableAddColumn: "Add column",
159
+ editorTableDeleteRow: "Delete row",
160
+ editorTableDeleteColumn: "Delete column",
161
+ editorTableDelete: "Delete table",
162
+ editorImage: "Insert image",
163
+ editorImageUploading: "Uploading image\u2026",
164
+ editorImageError: "The image could not be uploaded.",
165
+ editorImageType: "That file is not a supported image.",
166
+ editorImageSize: "The image is too large.",
155
167
  editorBulletList: "Bulleted list",
156
168
  editorOrderedList: "Numbered list",
157
169
  editorQuote: "Quote",
@@ -572,6 +584,18 @@ const es = {
572
584
  editorStrike: "Tachado",
573
585
  editorCode: "C\xF3digo en l\xEDnea",
574
586
  editorHeading: "T\xEDtulo",
587
+ editorHeadingLevel: "T\xEDtulo {level}",
588
+ editorTable: "Insertar tabla",
589
+ editorTableAddRow: "A\xF1adir fila",
590
+ editorTableAddColumn: "A\xF1adir columna",
591
+ editorTableDeleteRow: "Eliminar fila",
592
+ editorTableDeleteColumn: "Eliminar columna",
593
+ editorTableDelete: "Eliminar tabla",
594
+ editorImage: "Insertar imagen",
595
+ editorImageUploading: "Subiendo imagen\u2026",
596
+ editorImageError: "No se pudo subir la imagen.",
597
+ editorImageType: "Ese archivo no es una imagen admitida.",
598
+ editorImageSize: "La imagen es demasiado grande.",
575
599
  editorBulletList: "Lista con vi\xF1etas",
576
600
  editorOrderedList: "Lista numerada",
577
601
  editorQuote: "Cita",
@@ -992,6 +1016,18 @@ const ptBR = {
992
1016
  editorStrike: "Tachado",
993
1017
  editorCode: "C\xF3digo em linha",
994
1018
  editorHeading: "T\xEDtulo",
1019
+ editorHeadingLevel: "T\xEDtulo {level}",
1020
+ editorTable: "Inserir tabela",
1021
+ editorTableAddRow: "Adicionar linha",
1022
+ editorTableAddColumn: "Adicionar coluna",
1023
+ editorTableDeleteRow: "Excluir linha",
1024
+ editorTableDeleteColumn: "Excluir coluna",
1025
+ editorTableDelete: "Excluir tabela",
1026
+ editorImage: "Inserir imagem",
1027
+ editorImageUploading: "Enviando imagem\u2026",
1028
+ editorImageError: "N\xE3o foi poss\xEDvel enviar a imagem.",
1029
+ editorImageType: "Esse arquivo n\xE3o \xE9 uma imagem compat\xEDvel.",
1030
+ editorImageSize: "A imagem \xE9 grande demais.",
995
1031
  editorBulletList: "Lista com marcadores",
996
1032
  editorOrderedList: "Lista numerada",
997
1033
  editorQuote: "Cita\xE7\xE3o",
@@ -0,0 +1,41 @@
1
+ type ImageUploadResult = string | {
2
+ url: string;
3
+ alt?: string;
4
+ };
5
+ /** Sube una imagen y devuelve su URL pública (o `{ url, alt }`). Debe rechazar si falla. */
6
+ type ImageUploader = (file: File, options?: {
7
+ signal?: AbortSignal;
8
+ }) => Promise<ImageUploadResult>;
9
+ interface PresignedUpload {
10
+ /** URL a la que se hace el PUT del fichero. */
11
+ uploadUrl: string;
12
+ /** URL con la que se verá después la imagen (la que se guarda en el Markdown). */
13
+ publicUrl: string;
14
+ /** Cabeceras que la firma exige en el PUT (Content-Type se añade solo si falta). */
15
+ headers?: Record<string, string>;
16
+ }
17
+ declare class ImageUploadError extends Error {
18
+ readonly code: "type" | "size" | "network" | "response";
19
+ constructor(code: "type" | "size" | "network" | "response", message?: string);
20
+ }
21
+ /** Valida tipo y tamaño antes de subir. `accept` admite `image/*` o una lista de tipos MIME. */
22
+ declare function checkImageFile(file: File, { accept, maxBytes }?: {
23
+ accept?: string;
24
+ maxBytes?: number;
25
+ }): void;
26
+ /** S3 / R2 por URL prefirmada: pide la URL al servidor y hace el PUT. */
27
+ declare function createPresignedUploader({ getUploadUrl, fetcher, }: {
28
+ getUploadUrl: (file: File) => Promise<PresignedUpload>;
29
+ fetcher?: typeof fetch;
30
+ }): ImageUploader;
31
+ /** Endpoint propio (Worker con R2, API…): multipart POST con el fichero y respuesta JSON con `url`. */
32
+ declare function createEndpointUploader({ endpoint, fieldName, headers, parse, fetcher, }: {
33
+ endpoint: string;
34
+ fieldName?: string;
35
+ headers?: Record<string, string>;
36
+ /** Adapta la respuesta del servidor si no es `{ url }`. */
37
+ parse?: (json: unknown) => ImageUploadResult;
38
+ fetcher?: typeof fetch;
39
+ }): ImageUploader;
40
+
41
+ export { ImageUploadError, type ImageUploadResult, type ImageUploader, type PresignedUpload, checkImageFile, createEndpointUploader, createPresignedUploader };
@@ -0,0 +1,66 @@
1
+ class ImageUploadError extends Error {
2
+ constructor(code, message) {
3
+ super(message ?? code);
4
+ this.code = code;
5
+ this.name = "ImageUploadError";
6
+ }
7
+ code;
8
+ }
9
+ function checkImageFile(file, { accept = "image/*", maxBytes } = {}) {
10
+ const ok = accept.split(",").map((s) => s.trim()).filter(Boolean).some((a) => a.endsWith("/*") ? file.type.startsWith(a.slice(0, -1)) : file.type === a);
11
+ if (!ok) throw new ImageUploadError("type");
12
+ if (maxBytes !== void 0 && file.size > maxBytes) throw new ImageUploadError("size");
13
+ }
14
+ function createPresignedUploader({
15
+ getUploadUrl,
16
+ fetcher = fetch
17
+ }) {
18
+ return async (file, options) => {
19
+ const { uploadUrl, publicUrl, headers } = await getUploadUrl(file);
20
+ let res;
21
+ try {
22
+ res = await fetcher(uploadUrl, {
23
+ method: "PUT",
24
+ body: file,
25
+ headers: { "Content-Type": file.type, ...headers },
26
+ signal: options?.signal
27
+ });
28
+ } catch {
29
+ throw new ImageUploadError("network");
30
+ }
31
+ if (!res.ok) throw new ImageUploadError("network", `HTTP ${res.status}`);
32
+ return publicUrl;
33
+ };
34
+ }
35
+ function createEndpointUploader({
36
+ endpoint,
37
+ fieldName = "file",
38
+ headers,
39
+ parse = (json) => json,
40
+ fetcher = fetch
41
+ }) {
42
+ return async (file, options) => {
43
+ const body = new FormData();
44
+ body.append(fieldName, file);
45
+ let res;
46
+ try {
47
+ res = await fetcher(endpoint, { method: "POST", body, headers, signal: options?.signal });
48
+ } catch {
49
+ throw new ImageUploadError("network");
50
+ }
51
+ if (!res.ok) throw new ImageUploadError("network", `HTTP ${res.status}`);
52
+ try {
53
+ const out = parse(await res.json());
54
+ if (typeof out === "string" ? !out : !out?.url) throw new Error();
55
+ return out;
56
+ } catch {
57
+ throw new ImageUploadError("response");
58
+ }
59
+ };
60
+ }
61
+ export {
62
+ ImageUploadError,
63
+ checkImageFile,
64
+ createEndpointUploader,
65
+ createPresignedUploader
66
+ };
package/dist/styles.css CHANGED
@@ -476,6 +476,8 @@
476
476
  --ds-badge-ai-fg: var(--info);
477
477
  --ds-badge-ai-border: color-mix(in oklch, var(--info) 35%, transparent);
478
478
  --ds-badge-py: 0.25rem;
479
+ --ds-badge-px-sm: 0.375rem;
480
+ --ds-badge-py-sm: 0.125rem;
479
481
  --ds-bubble-px: 0.875rem;
480
482
  --ds-bubble-py: 0.625rem;
481
483
  --ds-bubble-max-w: 80%;
@@ -509,6 +511,8 @@
509
511
  */
510
512
  --ds-card-spacing: 1.5rem;
511
513
  --ds-card-spacing-sm: 1rem;
514
+ --ds-card-hover-lift: 0.125rem; /* hoverable: cuánto sube */
515
+ --ds-card-hover-border: color-mix(in oklch, var(--primary) 40%, var(--border)); /* hoverable: borde al señalar */
512
516
  --ds-field-px: 0.75rem;
513
517
  --ds-density: 1; /* escala global de relleno y separación de listas y tablas (0.8 = más denso, 1.2 = más aireado) */
514
518
  --ds-cell-p: calc(0.75rem * var(--ds-density));
@@ -4,8 +4,12 @@ import { useRender } from '@base-ui/react/use-render';
4
4
  import { VariantProps } from 'class-variance-authority';
5
5
 
6
6
  declare const badgeVariants: (props?: ({
7
+ size?: "default" | "sm" | null | undefined;
7
8
  variant?: "link" | "default" | "outline" | "secondary" | "ghost" | "destructive" | "info" | "success" | "warning" | "danger" | "neutral" | null | undefined;
8
9
  } & class_variance_authority_types.ClassProp) | undefined) => string;
9
- declare function Badge({ className, variant, render, ...props }: useRender.ComponentProps<"span"> & VariantProps<typeof badgeVariants>): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
10
+ declare function Badge({ className, variant, size, dot, render, children, ...props }: useRender.ComponentProps<"span"> & VariantProps<typeof badgeVariants> & {
11
+ /** Punto de estado a la izquierda, con el color del texto de la variante. */
12
+ dot?: boolean;
13
+ }): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
10
14
 
11
15
  export { Badge, badgeVariants };
package/dist/ui/badge.js CHANGED
@@ -1,11 +1,16 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
1
2
  import { mergeProps } from "@base-ui/react/merge-props";
2
3
  import { useRender } from "@base-ui/react/use-render";
3
4
  import { cva } from "class-variance-authority";
4
5
  import { cn } from "../lib/utils.js";
5
6
  const badgeVariants = cva(
6
- "group/badge inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-badge border border-transparent px-(--ds-badge-px) py-(--ds-badge-py) text-xs font-(--ds-badge-weight) whitespace-nowrap transition-all duration-(--ds-motion-snap) focus-visible:border-ring focus-visible:ring-(length:--ds-ring-width) focus-visible:ring-(--ds-ring-color) has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 aria-invalid:border-(--ds-invalid-border) aria-invalid:ring-(--ds-invalid-ring) [&>svg]:pointer-events-none [&>svg]:size-3!",
7
+ "group/badge inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-badge border border-transparent text-xs font-(--ds-badge-weight) whitespace-nowrap transition-all duration-(--ds-motion-snap) focus-visible:border-ring focus-visible:ring-(length:--ds-ring-width) focus-visible:ring-(--ds-ring-color) has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 aria-invalid:border-(--ds-invalid-border) aria-invalid:ring-(--ds-invalid-ring) [&>svg]:pointer-events-none [&>svg]:size-3!",
7
8
  {
8
9
  variants: {
10
+ size: {
11
+ default: "px-(--ds-badge-px) py-(--ds-badge-py)",
12
+ sm: "px-(--ds-badge-px-sm) py-(--ds-badge-py-sm)"
13
+ },
9
14
  variant: {
10
15
  default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
11
16
  secondary: "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
@@ -22,6 +27,7 @@ const badgeVariants = cva(
22
27
  }
23
28
  },
24
29
  defaultVariants: {
30
+ size: "default",
25
31
  variant: "default"
26
32
  }
27
33
  }
@@ -29,19 +35,33 @@ const badgeVariants = cva(
29
35
  function Badge({
30
36
  className,
31
37
  variant = "default",
38
+ size = "default",
39
+ dot = false,
32
40
  render,
41
+ children,
33
42
  ...props
34
43
  }) {
35
44
  return useRender({
36
45
  defaultTagName: "span",
37
46
  props: mergeProps(
38
47
  {
39
- className: cn(badgeVariants({ variant }), className)
48
+ className: cn(badgeVariants({ variant, size }), className),
49
+ children: dot ? /* @__PURE__ */ jsxs(Fragment, { children: [
50
+ /* @__PURE__ */ jsx(
51
+ "span",
52
+ {
53
+ "data-slot": "badge-dot",
54
+ "aria-hidden": "true",
55
+ className: "size-(--ds-status-dot) shrink-0 rounded-full bg-current"
56
+ }
57
+ ),
58
+ children
59
+ ] }) : children
40
60
  },
41
61
  props
42
62
  ),
43
63
  render,
44
- state: { slot: "badge", variant }
64
+ state: { slot: "badge", variant, size }
45
65
  });
46
66
  }
47
67
  export {
package/dist/ui/card.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import * as React from 'react';
2
2
 
3
- declare function Card({ className, size, ...props }: React.ComponentProps<"div"> & {
3
+ declare function Card({ className, size, hoverable, ...props }: React.ComponentProps<"div"> & {
4
4
  size?: "default" | "sm";
5
+ /** Al pasar el ratón la tarjeta se eleva y marca el borde (--ds-card-hover-lift / -border). */
6
+ hoverable?: boolean;
5
7
  }): React.JSX.Element;
6
8
  declare function CardHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
7
9
  declare function CardTitle({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
package/dist/ui/card.js CHANGED
@@ -3,6 +3,7 @@ import { cn } from "../lib/utils.js";
3
3
  function Card({
4
4
  className,
5
5
  size = "default",
6
+ hoverable = false,
6
7
  ...props
7
8
  }) {
8
9
  return /* @__PURE__ */ jsx(
@@ -10,8 +11,10 @@ function Card({
10
11
  {
11
12
  "data-slot": "card",
12
13
  "data-size": size,
14
+ "data-hoverable": hoverable || void 0,
13
15
  className: cn(
14
16
  "group/card flex flex-col gap-(--ds-card-spacing) overflow-hidden rounded-card border bg-card py-(--ds-card-spacing) text-sm text-card-foreground shadow-card transition-shadow duration-(--ds-motion-snap) hover:shadow-card-hover has-[>img:first-child]:pt-0 data-[size=sm]:[--ds-card-spacing:var(--ds-card-spacing-sm)] *:[img:first-child]:rounded-t-card *:[img:last-child]:rounded-b-card",
17
+ hoverable && "transition-[box-shadow,transform,border-color] duration-(--ds-motion-snap) hover:-translate-y-(--ds-card-hover-lift) hover:border-(--ds-card-hover-border) motion-reduce:transition-none motion-reduce:hover:translate-y-0",
15
18
  className
16
19
  ),
17
20
  ...props
@@ -0,0 +1,21 @@
1
+ import * as React from 'react';
2
+ import { ConfirmActionPreset } from './confirm-action.js';
3
+
4
+ interface ConfirmOptions {
5
+ title: React.ReactNode;
6
+ description?: React.ReactNode;
7
+ confirmLabel?: React.ReactNode;
8
+ cancelLabel?: React.ReactNode;
9
+ tone?: "destructive" | "default";
10
+ preset?: ConfirmActionPreset;
11
+ /** Texto que hay que escribir (preset `typed`). */
12
+ expected?: string;
13
+ }
14
+ type ConfirmFn = (options: ConfirmOptions) => Promise<boolean>;
15
+ declare function ConfirmDialogProvider({ children }: {
16
+ children?: React.ReactNode;
17
+ }): React.JSX.Element;
18
+ /** Devuelve `confirm(options)`: promesa de `true` (confirmó) o `false` (canceló). */
19
+ declare function useConfirm(): ConfirmFn;
20
+
21
+ export { ConfirmDialogProvider, type ConfirmOptions, useConfirm };
@@ -0,0 +1,54 @@
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 { ConfirmAction } from "./confirm-action.js";
6
+ const ConfirmContext = React.createContext(null);
7
+ function ConfirmDialogProvider({ children }) {
8
+ const [options, setOptions] = React.useState(null);
9
+ const [open, setOpen] = React.useState(false);
10
+ const resolver = React.useRef(null);
11
+ const settle = React.useCallback((ok) => {
12
+ resolver.current?.(ok);
13
+ resolver.current = null;
14
+ }, []);
15
+ const confirm = React.useCallback(
16
+ (next) => {
17
+ settle(false);
18
+ setOptions(next);
19
+ setOpen(true);
20
+ return new Promise((resolve) => {
21
+ resolver.current = resolve;
22
+ });
23
+ },
24
+ [settle]
25
+ );
26
+ React.useEffect(() => () => settle(false), [settle]);
27
+ return /* @__PURE__ */ jsxs(ConfirmContext.Provider, { value: confirm, children: [
28
+ children,
29
+ options ? /* @__PURE__ */ jsx(
30
+ ConfirmAction,
31
+ {
32
+ ...options,
33
+ open,
34
+ onOpenChange: (o) => {
35
+ setOpen(o);
36
+ if (!o) settle(false);
37
+ },
38
+ onConfirm: () => settle(true)
39
+ }
40
+ ) : null
41
+ ] });
42
+ }
43
+ function useConfirm() {
44
+ const confirm = React.useContext(ConfirmContext);
45
+ if (confirm) return confirm;
46
+ return async () => {
47
+ dsWarn("useConfirm", "Wrap your app in <ConfirmDialogProvider>; resolving false.");
48
+ return false;
49
+ };
50
+ }
51
+ export {
52
+ ConfirmDialogProvider,
53
+ useConfirm
54
+ };
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+ import { EmptyState } from './empty-state.js';
3
+ import './auth-backdrop.js';
4
+ import './empty.js';
5
+ import 'class-variance-authority/types';
6
+ import 'class-variance-authority';
7
+
8
+ declare function ErrorState({ onRetry, retrying, retryLabel, action, ...props }: Omit<React.ComponentProps<typeof EmptyState>, "preset"> & {
9
+ /** Reintenta la carga. Sin ella no se pinta el botón. */
10
+ onRetry?: () => void | Promise<void>;
11
+ /** Está reintentando: bloquea el botón. */
12
+ retrying?: boolean;
13
+ retryLabel?: React.ReactNode;
14
+ }): React.JSX.Element;
15
+
16
+ export { ErrorState };
@@ -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
+ };
@@ -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
- function Toolbar({ editor, tools, disabled }) {
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(ToolButton, { label: t.editorHeading, disabled, pressed: editor.isActive("heading", { level: 2 }), onPress: () => run().toggleHeading({ level: 2 }).run(), children: /* @__PURE__ */ jsx(Heading2Icon, {}) }, "heading")
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
- return lines(() => "## ", /^#{1,6} /);
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([btn("heading", t.editorHeading, /* @__PURE__ */ jsx(Heading2Icon, {}))]);
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(`![${alt}](${url})`);
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: false }) : mode === "markdown" && !readOnly ? /* @__PURE__ */ jsx(SourceToolbar, { tools: toolList.filter((x) => x !== "history"), onApply: applyOp }) : /* @__PURE__ */ jsx("span", {}),
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))
@@ -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
 
@@ -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
  );
@@ -1,5 +1,10 @@
1
1
  import * as React$1 from 'react';
2
+ import * as class_variance_authority_types from 'class-variance-authority/types';
3
+ import { VariantProps } from 'class-variance-authority';
2
4
 
3
- declare function Skeleton({ className, ...props }: React.ComponentProps<"div">): React$1.JSX.Element;
5
+ declare const skeletonVariants: (props?: ({
6
+ variant?: "default" | "shimmer" | null | undefined;
7
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
8
+ declare function Skeleton({ className, variant, ...props }: React.ComponentProps<"div"> & VariantProps<typeof skeletonVariants>): React$1.JSX.Element;
4
9
 
5
- export { Skeleton };
10
+ export { Skeleton, skeletonVariants };
@@ -1,15 +1,31 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
+ import { cva } from "class-variance-authority";
2
3
  import { cn } from "../lib/utils.js";
3
- function Skeleton({ className, ...props }) {
4
+ const skeletonVariants = cva("rounded-skeleton bg-muted", {
5
+ variants: {
6
+ variant: {
7
+ default: "animate-pulse",
8
+ shimmer: "shimmer motion-reduce:animate-none"
9
+ }
10
+ },
11
+ defaultVariants: { variant: "default" }
12
+ });
13
+ function Skeleton({
14
+ className,
15
+ variant = "default",
16
+ ...props
17
+ }) {
4
18
  return /* @__PURE__ */ jsx(
5
19
  "div",
6
20
  {
7
21
  "data-slot": "skeleton",
8
- className: cn("animate-pulse rounded-skeleton bg-muted", className),
22
+ "data-variant": variant,
23
+ className: cn(skeletonVariants({ variant }), className),
9
24
  ...props
10
25
  }
11
26
  );
12
27
  }
13
28
  export {
14
- Skeleton
29
+ Skeleton,
30
+ skeletonVariants
15
31
  };
@@ -1,6 +1,23 @@
1
1
  import * as React from 'react';
2
2
  import { Slider as Slider$1 } from '@base-ui/react/slider';
3
3
 
4
- declare function Slider({ className, defaultValue, value, min, max, ...props }: Slider$1.Root.Props): React.JSX.Element;
4
+ type SliderBase = Omit<Slider$1.Root.Props, "value" | "defaultValue" | "onValueChange" | "onValueCommitted">;
5
+ type SliderEventDetails = Slider$1.Root.ChangeEventDetails;
6
+ /** Un tirador: `value` es un número y `onValueChange` recibe un número. */
7
+ type SliderSingleProps = SliderBase & {
8
+ value?: number;
9
+ defaultValue?: number;
10
+ onValueChange?: (value: number, details: SliderEventDetails) => void;
11
+ onValueCommitted?: (value: number, details: Slider$1.Root.CommitEventDetails) => void;
12
+ };
13
+ /** Rango o varios tiradores: `value` es una lista y `onValueChange` recibe una lista. */
14
+ type SliderRangeProps = SliderBase & {
15
+ value?: readonly number[];
16
+ defaultValue?: readonly number[];
17
+ onValueChange?: (value: number[], details: SliderEventDetails) => void;
18
+ onValueCommitted?: (value: number[], details: Slider$1.Root.CommitEventDetails) => void;
19
+ };
20
+ type SliderProps = SliderSingleProps | SliderRangeProps;
21
+ declare function Slider({ className, defaultValue, value, min, max, ...props }: SliderProps): React.JSX.Element;
5
22
 
6
- export { Slider };
23
+ export { Slider, type SliderProps };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orbital-ds",
3
- "version": "0.36.0",
3
+ "version": "0.39.0",
4
4
  "description": "Sistema de diseño genérico: estructura común + temas con personalidad (qratia, zyro) + ~60 componentes sobre Base UI y Tailwind v4, con contrato verificable y legible por agentes.",
5
5
  "keywords": [
6
6
  "design-system",
@@ -84,6 +84,14 @@
84
84
  "@base-ui/react": ">=1.9",
85
85
  "@shadcn/react": ">=0.3",
86
86
  "@tanstack/react-table": ">=9",
87
+ "@tiptap/core": ">=3",
88
+ "@tiptap/extension-image": ">=3",
89
+ "@tiptap/extension-placeholder": ">=3",
90
+ "@tiptap/extension-table": ">=3",
91
+ "@tiptap/markdown": ">=3",
92
+ "@tiptap/pm": ">=3",
93
+ "@tiptap/react": ">=3",
94
+ "@tiptap/starter-kit": ">=3",
87
95
  "class-variance-authority": ">=0.7",
88
96
  "clsx": ">=2",
89
97
  "cmdk": ">=1.1",
@@ -102,13 +110,7 @@
102
110
  "sonner": ">=2",
103
111
  "tailwind-merge": ">=3",
104
112
  "tailwindcss": ">=4.1",
105
- "tw-animate-css": ">=1.3",
106
- "@tiptap/react": ">=3",
107
- "@tiptap/pm": ">=3",
108
- "@tiptap/core": ">=3",
109
- "@tiptap/starter-kit": ">=3",
110
- "@tiptap/markdown": ">=3",
111
- "@tiptap/extension-placeholder": ">=3"
113
+ "tw-animate-css": ">=1.3"
112
114
  },
113
115
  "peerDependenciesMeta": {
114
116
  "next-themes": {
@@ -167,6 +169,12 @@
167
169
  },
168
170
  "@tiptap/extension-placeholder": {
169
171
  "optional": true
172
+ },
173
+ "@tiptap/extension-table": {
174
+ "optional": true
175
+ },
176
+ "@tiptap/extension-image": {
177
+ "optional": true
170
178
  }
171
179
  },
172
180
  "devDependencies": {
@@ -175,7 +183,9 @@
175
183
  "@tailwindcss/vite": "^4.3.3",
176
184
  "@tanstack/react-table": "^9.2.8",
177
185
  "@tiptap/core": "^3.33.1",
186
+ "@tiptap/extension-image": "^3.33.1",
178
187
  "@tiptap/extension-placeholder": "^3.33.1",
188
+ "@tiptap/extension-table": "^3.33.1",
179
189
  "@tiptap/markdown": "^3.33.1",
180
190
  "@tiptap/pm": "^3.33.1",
181
191
  "@tiptap/react": "^3.33.1",