@sincpro/web-ui 1.9.0 → 1.10.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/dist/components/canvas/Canvas.d.ts +14 -0
- package/dist/components/canvas/Canvas.js +9 -0
- package/dist/components/canvas/canvas.css +19 -0
- package/dist/components/canvas/index.d.ts +1 -0
- package/dist/components/canvas/index.js +2 -0
- package/dist/components/chat/ChatComposer.d.ts +10 -0
- package/dist/components/chat/ChatComposer.js +29 -0
- package/dist/components/chat/ChatThread.d.ts +13 -0
- package/dist/components/chat/ChatThread.js +76 -0
- package/dist/components/chat/ConversationList.d.ts +22 -0
- package/dist/components/chat/ConversationList.js +22 -0
- package/dist/components/chat/index.d.ts +4 -0
- package/dist/components/chat/index.js +5 -0
- package/dist/components/chat/model.d.ts +30 -0
- package/dist/components/chat/model.js +53 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +3 -0
- package/dist/components/listing/ColumnsMenu.d.ts +7 -1
- package/dist/components/listing/ColumnsMenu.js +16 -5
- package/dist/components/listing/GroupingLevels.d.ts +5 -1
- package/dist/components/listing/GroupingLevels.js +7 -4
- package/dist/components/listing/ListingBar.js +2 -2
- package/dist/components/preview/FilePreview.d.ts +19 -0
- package/dist/components/preview/FilePreview.js +112 -0
- package/dist/components/preview/PdfPreview.d.ts +7 -0
- package/dist/components/preview/PdfPreview.js +47 -0
- package/dist/components/preview/index.d.ts +1 -0
- package/dist/components/preview/index.js +2 -0
- package/dist/components/record/SmartButtons.js +1 -1
- package/dist/components/search/FieldPath.d.ts +54 -0
- package/dist/components/search/FieldPath.js +159 -0
- package/dist/components/search/FilterBuilder.d.ts +38 -5
- package/dist/components/search/FilterBuilder.js +129 -25
- package/dist/components/search/SearchBar.js +7 -2
- package/dist/components/search/criteria.d.ts +23 -1
- package/dist/components/search/index.d.ts +4 -2
- package/dist/components/search/index.js +4 -0
- package/dist/components/search/paths.d.ts +49 -0
- package/dist/components/search/paths.js +75 -0
- package/dist/components/shell/TopBar.js +1 -1
- package/dist/foundations/copy.d.ts +86 -0
- package/dist/foundations/copy.es.js +63 -0
- package/dist/foundations/copy.js +57 -0
- package/dist/primitives/field/Field.js +2 -1
- package/dist/primitives/notice/Callout.d.ts +4 -1
- package/dist/primitives/notice/Callout.js +12 -2
- package/dist/primitives/notice/Notice.d.ts +26 -2
- package/dist/primitives/notice/Notice.js +64 -4
- package/dist/primitives/notice/Toast.js +10 -1
- package/dist/primitives/value/Markdown.d.ts +9 -0
- package/dist/primitives/value/Markdown.js +18 -0
- package/dist/primitives/value/index.d.ts +1 -0
- package/dist/primitives/value/index.js +1 -0
- package/dist/tokens.css +28 -0
- package/package.json +4 -1
|
@@ -267,6 +267,7 @@ export const SPANISH_COPY = {
|
|
|
267
267
|
failed: "No se pudo copiar",
|
|
268
268
|
field: "Copiar «{label}»",
|
|
269
269
|
empty: "No hay nada que copiar",
|
|
270
|
+
report: "Copiar el error",
|
|
270
271
|
},
|
|
271
272
|
richText: {
|
|
272
273
|
toolbar: "Formato del texto",
|
|
@@ -544,6 +545,68 @@ export const SPANISH_COPY = {
|
|
|
544
545
|
failed: "No se pudo subir el archivo.",
|
|
545
546
|
retry: "Reintentar",
|
|
546
547
|
},
|
|
548
|
+
fieldPath: {
|
|
549
|
+
choose: "Elegir un campo",
|
|
550
|
+
search: "Buscar un campo",
|
|
551
|
+
back: "Volver",
|
|
552
|
+
loading: "Cargando los campos…",
|
|
553
|
+
failed: "No se pudieron cargar los campos.",
|
|
554
|
+
failedHint: "Probá de nuevo en un momento, o copiá el error para quien mantiene el modelo.",
|
|
555
|
+
empty: "Ningún campo coincide.",
|
|
556
|
+
self: "«{label}» (el registro)",
|
|
557
|
+
opens: "muestra sus campos",
|
|
558
|
+
addColumn: "Agregar columna",
|
|
559
|
+
addLevel: "Agrupar por otro campo",
|
|
560
|
+
match: { label: "Cuántos de «{relation}»", any: "alguno", none: "ninguno", all: "todos" },
|
|
561
|
+
say: {
|
|
562
|
+
any: "alguno de {relation} con {inner}",
|
|
563
|
+
none: "ninguno de {relation} con {inner}",
|
|
564
|
+
all: "todos los de {relation} con {inner}",
|
|
565
|
+
one: "{relation} > {inner}",
|
|
566
|
+
},
|
|
567
|
+
},
|
|
568
|
+
preview: {
|
|
569
|
+
label: "Vista previa",
|
|
570
|
+
download: "Descargar",
|
|
571
|
+
unsupported: "No hay vista previa para este tipo de archivo. Igual lo podés descargar.",
|
|
572
|
+
loading: "Cargando la vista previa…",
|
|
573
|
+
failed: "No se pudo mostrar el archivo.",
|
|
574
|
+
page: "Página {page} de {total}",
|
|
575
|
+
previousPage: "Página anterior",
|
|
576
|
+
nextPage: "Página siguiente",
|
|
577
|
+
fit: "Ajustar",
|
|
578
|
+
actualSize: "Tamaño real",
|
|
579
|
+
kind: {
|
|
580
|
+
image: "Imagen",
|
|
581
|
+
pdf: "PDF",
|
|
582
|
+
text: "Texto",
|
|
583
|
+
markdown: "Documento",
|
|
584
|
+
other: "Archivo",
|
|
585
|
+
},
|
|
586
|
+
},
|
|
587
|
+
chat: {
|
|
588
|
+
thread: "Conversación",
|
|
589
|
+
empty: "Todavía no hay mensajes. Escribí el primero.",
|
|
590
|
+
loadOlder: "Cargar mensajes anteriores",
|
|
591
|
+
loadingOlder: "Cargando mensajes anteriores…",
|
|
592
|
+
jumpLatest: "Ir al último mensaje",
|
|
593
|
+
today: "Hoy",
|
|
594
|
+
yesterday: "Ayer",
|
|
595
|
+
composer: "Mensaje",
|
|
596
|
+
placeholder: "Escribí un mensaje… Enter lo envía, Shift+Enter hace otro renglón",
|
|
597
|
+
send: "Enviar",
|
|
598
|
+
unread: "{count} sin leer",
|
|
599
|
+
conversations: "Conversaciones",
|
|
600
|
+
newMessages: "Mensajes nuevos",
|
|
601
|
+
sending: "Enviando…",
|
|
602
|
+
},
|
|
603
|
+
canvas: {
|
|
604
|
+
label: "Lienzo",
|
|
605
|
+
zoomIn: "Acercar",
|
|
606
|
+
zoomOut: "Alejar",
|
|
607
|
+
fit: "Ajustar a la pantalla",
|
|
608
|
+
readOnly: "Solo lectura",
|
|
609
|
+
},
|
|
547
610
|
theme: {
|
|
548
611
|
label: "Tema",
|
|
549
612
|
system: "Sistema",
|
package/dist/foundations/copy.js
CHANGED
|
@@ -215,6 +215,7 @@ export const ENGLISH_COPY = {
|
|
|
215
215
|
failed: "Could not copy",
|
|
216
216
|
field: "Copy «{label}»",
|
|
217
217
|
empty: "Nothing to copy",
|
|
218
|
+
report: "Copy the error",
|
|
218
219
|
},
|
|
219
220
|
richText: {
|
|
220
221
|
toolbar: "Text formatting",
|
|
@@ -539,6 +540,62 @@ export const ENGLISH_COPY = {
|
|
|
539
540
|
failed: "The file could not be uploaded.",
|
|
540
541
|
retry: "Try again",
|
|
541
542
|
},
|
|
543
|
+
fieldPath: {
|
|
544
|
+
choose: "Choose a field",
|
|
545
|
+
search: "Search a field",
|
|
546
|
+
back: "Back",
|
|
547
|
+
loading: "Loading the fields…",
|
|
548
|
+
failed: "The fields could not be loaded.",
|
|
549
|
+
failedHint: "Try again in a moment, or copy the error for whoever maintains the model.",
|
|
550
|
+
empty: "No field matches.",
|
|
551
|
+
self: "«{label}» itself",
|
|
552
|
+
opens: "shows its fields",
|
|
553
|
+
addColumn: "Add a column",
|
|
554
|
+
addLevel: "Group by another field",
|
|
555
|
+
match: { label: "How many of «{relation}»", any: "some", none: "none", all: "all" },
|
|
556
|
+
say: {
|
|
557
|
+
any: "some of {relation} with {inner}",
|
|
558
|
+
none: "none of {relation} with {inner}",
|
|
559
|
+
all: "all of {relation} with {inner}",
|
|
560
|
+
one: "{relation} > {inner}",
|
|
561
|
+
},
|
|
562
|
+
},
|
|
563
|
+
preview: {
|
|
564
|
+
label: "Preview",
|
|
565
|
+
download: "Download",
|
|
566
|
+
unsupported: "There is no preview for this kind of file. You can still download it.",
|
|
567
|
+
loading: "Loading the preview…",
|
|
568
|
+
failed: "The file could not be shown.",
|
|
569
|
+
page: "Page {page} of {total}",
|
|
570
|
+
previousPage: "Previous page",
|
|
571
|
+
nextPage: "Next page",
|
|
572
|
+
fit: "Fit",
|
|
573
|
+
actualSize: "Actual size",
|
|
574
|
+
kind: { image: "Image", pdf: "PDF", text: "Text", markdown: "Document", other: "File" },
|
|
575
|
+
},
|
|
576
|
+
chat: {
|
|
577
|
+
thread: "Conversation",
|
|
578
|
+
empty: "No messages yet. Write the first one.",
|
|
579
|
+
loadOlder: "Load earlier messages",
|
|
580
|
+
loadingOlder: "Loading earlier messages…",
|
|
581
|
+
jumpLatest: "Jump to the latest",
|
|
582
|
+
today: "Today",
|
|
583
|
+
yesterday: "Yesterday",
|
|
584
|
+
composer: "Message",
|
|
585
|
+
placeholder: "Write a message… Enter sends, Shift+Enter starts a new line",
|
|
586
|
+
send: "Send",
|
|
587
|
+
unread: "{count} unread",
|
|
588
|
+
conversations: "Conversations",
|
|
589
|
+
newMessages: "New messages",
|
|
590
|
+
sending: "Sending…",
|
|
591
|
+
},
|
|
592
|
+
canvas: {
|
|
593
|
+
label: "Canvas",
|
|
594
|
+
zoomIn: "Zoom in",
|
|
595
|
+
zoomOut: "Zoom out",
|
|
596
|
+
fit: "Fit to screen",
|
|
597
|
+
readOnly: "Read only",
|
|
598
|
+
},
|
|
542
599
|
theme: {
|
|
543
600
|
label: "Theme",
|
|
544
601
|
system: "System",
|
|
@@ -12,6 +12,7 @@ import { useSheetLayout } from "./layout.js";
|
|
|
12
12
|
import { describedByOf, NoteCard, NoteFlag, } from "./note.js";
|
|
13
13
|
import { Hint } from "../hint/Hint.js";
|
|
14
14
|
import { Popover } from "../overlay/Popover.js";
|
|
15
|
+
import { CopyButton } from "../value/Copyable.js";
|
|
15
16
|
import { roundTo } from "../value/rounding.js";
|
|
16
17
|
import { AlertCircle, Check, ChevronDown, ChevronUp } from "lucide-react";
|
|
17
18
|
import { useId, useRef } from "react";
|
|
@@ -76,7 +77,7 @@ export function Field({ label, hint, error, required = false, children, htmlFor,
|
|
|
76
77
|
/* The render prop gets the same context as a control written directly: a system control
|
|
77
78
|
inside it then also finds the label that names it, not only the id it is handed. */
|
|
78
79
|
const content = (_jsx(FieldIdsContext.Provider, { value: ids, children: _jsx("div", { ref: shown, className: "contents", children: typeof children === "function" ? children(ids) : children }) }));
|
|
79
|
-
const body = (_jsxs(_Fragment, { children: [mode === undefined ? (content) : (_jsx(FormModeProvider, { value: mode, children: content })), error === undefined ? null : (_jsxs("p", { id: errorId, role: "alert", className: "flex items-start gap-1.5 text-micro text-danger", children: [_jsx(AlertCircle, { className: "mt-px size-(--size-icon-sm) shrink-0", strokeWidth: 2, "aria-hidden": true }), _jsx("span", { className: "max-w-prose", children: error })] }))] }));
|
|
80
|
+
const body = (_jsxs(_Fragment, { children: [mode === undefined ? (content) : (_jsx(FormModeProvider, { value: mode, children: content })), error === undefined ? null : (_jsxs("p", { id: errorId, role: "alert", className: "flex items-start gap-1.5 text-micro text-danger", children: [_jsx(AlertCircle, { className: "mt-px size-(--size-icon-sm) shrink-0", strokeWidth: 2, "aria-hidden": true }), _jsx("span", { className: "max-w-prose", children: error }), _jsx(CopyButton, { label: copy.copyable.report, value: () => `${label}: ${error}` })] }))] }));
|
|
80
81
|
if (inline) {
|
|
81
82
|
return (_jsxs("div", { className: "grid-label grid min-w-0 items-start gap-x-4 gap-y-1 group/field", children: [labelNode, _jsx("div", { className: "flex min-w-0 flex-col gap-1", children: body }), action === undefined ? null : (_jsx("div", { "data-under-control": true, className: "flex items-center gap-2", children: action })), noteCard] }));
|
|
82
83
|
}
|
|
@@ -45,5 +45,8 @@ export type CalloutProps = {
|
|
|
45
45
|
dismissLabel?: string;
|
|
46
46
|
/** Un ícono propio, cuando el del tono no dice lo suficiente. */
|
|
47
47
|
icon?: LucideIcon;
|
|
48
|
+
/** Lo que se copia con «Copiar el error» cuando el tono es `bad`. Sin esto, la
|
|
49
|
+
* oración (si es texto) con el título. Para un aviso con detalle técnico, pasarlo acá. */
|
|
50
|
+
report?: string;
|
|
48
51
|
};
|
|
49
|
-
export declare function Callout({ children, tone, title, action, onDismiss, dismissLabel, icon, }: CalloutProps): import("react").JSX.Element;
|
|
52
|
+
export declare function Callout({ children, tone, title, action, onDismiss, dismissLabel, icon, report, }: CalloutProps): import("react").JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { byDensity, useDensity } from "../../foundations/density.js";
|
|
4
|
+
import { currentPage, ErrorCopy, errorReport, } from "./Notice.js";
|
|
4
5
|
import { AlertTriangle, CheckCircle2, Info, OctagonAlert, X } from "lucide-react";
|
|
5
6
|
const ICON = {
|
|
6
7
|
info: Info,
|
|
@@ -17,12 +18,21 @@ const SKIN = {
|
|
|
17
18
|
bad: "border-bad/25 bg-bad/8 text-bad",
|
|
18
19
|
good: "border-good/25 bg-good/8 text-good",
|
|
19
20
|
};
|
|
20
|
-
export function Callout({ children, tone = "info", title, action, onDismiss, dismissLabel, icon, }) {
|
|
21
|
+
export function Callout({ children, tone = "info", title, action, onDismiss, dismissLabel, icon, report, }) {
|
|
21
22
|
const d = useDensity();
|
|
22
23
|
const Icon = icon ?? ICON[tone];
|
|
24
|
+
/* The text a person would paste: the sentence, or what the caller names. A title that
|
|
25
|
+
is text becomes the report's heading; without one the sentence is the heading. */
|
|
26
|
+
const sentence = report ?? (typeof children === "string" ? children : "");
|
|
27
|
+
const copyable = tone === "bad" && sentence !== "";
|
|
23
28
|
return (_jsxs("div", {
|
|
24
29
|
/* `status` y no `alert`: `alert` interrumpe al lector de pantalla y se
|
|
25
30
|
reserva para lo que pasó JUSTO AHORA. Un aviso que ya estaba cuando la
|
|
26
31
|
pantalla abrió no interrumpe nada. */
|
|
27
|
-
role: "status", className: `flex min-w-0 items-start gap-2.5 rounded-box border ${SKIN[tone]} ${byDensity(d, "px-3 py-2.5", "px-2.5 py-2")}`, children: [_jsx(Icon, { className: "mt-0.5 size-(--size-icon-sm) shrink-0", strokeWidth: 2, "aria-hidden": true }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-wrap items-start gap-x-3 gap-y-2", children: [_jsxs("div", { className: "flex min-w-0 flex-1 basis-(--container-name) flex-col gap-1", children: [title === undefined ? null : (_jsx("p", { className: "text-meta font-medium text-ink", children: title })), _jsx("div", { className: "min-w-0 text-meta text-ink", children: children })] }), action === undefined ? null : _jsx("span", { className: "shrink-0", children: action })
|
|
32
|
+
role: "status", className: `flex min-w-0 items-start gap-2.5 rounded-box border ${SKIN[tone]} ${byDensity(d, "px-3 py-2.5", "px-2.5 py-2")}`, children: [_jsx(Icon, { className: "mt-0.5 size-(--size-icon-sm) shrink-0", strokeWidth: 2, "aria-hidden": true }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-wrap items-start gap-x-3 gap-y-2", children: [_jsxs("div", { className: "flex min-w-0 flex-1 basis-(--container-name) flex-col gap-1", children: [title === undefined ? null : (_jsx("p", { className: "text-meta font-medium text-ink", children: title })), _jsx("div", { className: "min-w-0 text-meta text-ink", children: children })] }), action === undefined ? null : _jsx("span", { className: "shrink-0", children: action }), copyable ? (_jsx("span", { className: "shrink-0", children: _jsx(ErrorCopy, { report: () => errorReport({
|
|
33
|
+
heading: typeof title === "string" ? title : "",
|
|
34
|
+
sentence: typeof title === "string" ? sentence : undefined,
|
|
35
|
+
at: new Date(),
|
|
36
|
+
page: currentPage(),
|
|
37
|
+
}) }) })) : null] }), onDismiss === undefined ? null : (_jsx("button", { type: "button", onClick: onDismiss, "aria-label": dismissLabel ?? "cerrar", title: dismissLabel ?? "cerrar", className: "-mr-1 shrink-0 rounded-control p-0.5 text-muted transition-colors duration-(--duration-instant) hover:bg-ink/6 hover:text-ink", children: _jsx(X, { className: "size-(--size-icon-sm)", strokeWidth: 2 }) }))] }));
|
|
28
38
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type LucideIcon } from "lucide-react";
|
|
2
|
-
import type
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
3
|
export declare function Skeleton({ rows, label, }: {
|
|
4
4
|
/** How many row-silhouettes. Six is a screen of a list, not a guess at
|
|
5
5
|
* the real count. */
|
|
@@ -25,10 +25,34 @@ align, }: {
|
|
|
25
25
|
* replacing it with one of our own is what forces you to go to the console to
|
|
26
26
|
* find out what happened.
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* The text a person pastes into a ticket or a chat when something broke: what
|
|
30
|
+
* the screen said, the technical detail if there is one, when it happened and
|
|
31
|
+
* where. Pure, so the same report reads the same in every error.
|
|
32
|
+
*/
|
|
33
|
+
export declare function errorReport(report: {
|
|
34
|
+
heading: string;
|
|
35
|
+
sentence?: string;
|
|
36
|
+
detail?: string;
|
|
37
|
+
at: Date;
|
|
38
|
+
page?: string;
|
|
39
|
+
}): string;
|
|
40
|
+
export declare function currentPage(): string | undefined;
|
|
41
|
+
export declare function useErrorCopy(report: () => string): {
|
|
42
|
+
said: string;
|
|
43
|
+
state: "idle" | "done" | "failed";
|
|
44
|
+
run: () => Promise<void>;
|
|
45
|
+
};
|
|
46
|
+
export declare function ErrorCopy({ report }: {
|
|
47
|
+
report: () => string;
|
|
48
|
+
}): import("react").JSX.Element;
|
|
49
|
+
export declare function Failed({ heading, sentence, action, detail, }: {
|
|
29
50
|
heading: string;
|
|
30
51
|
sentence: string;
|
|
31
52
|
action?: ReactNode;
|
|
53
|
+
/** The technical text (an HTTP status, a server message, an id). Drawn in mono
|
|
54
|
+
* so it reads as data, and included in what «Copiar el error» copies. */
|
|
55
|
+
detail?: string;
|
|
32
56
|
}): import("react").JSX.Element;
|
|
33
57
|
/**
|
|
34
58
|
* Nobody knows how to draw this. It carries the full identifier because that is
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useUiCopy } from "../../foundations/copy.js";
|
|
3
4
|
import { byDensity, useDensity } from "../../foundations/density.js";
|
|
4
|
-
import {
|
|
5
|
+
import { Button } from "../button/Button.js";
|
|
6
|
+
import { AlertTriangle, Check, Copy, PackageX } from "lucide-react";
|
|
7
|
+
import { useEffect, useRef, useState } from "react";
|
|
5
8
|
/**
|
|
6
9
|
* Context: the ways a view says there is no content yet, and they are
|
|
7
10
|
* different because each one is fixed by a different person.
|
|
@@ -48,15 +51,72 @@ align = "center", }) {
|
|
|
48
51
|
* replacing it with one of our own is what forces you to go to the console to
|
|
49
52
|
* find out what happened.
|
|
50
53
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
/**
|
|
55
|
+
* The text a person pastes into a ticket or a chat when something broke: what
|
|
56
|
+
* the screen said, the technical detail if there is one, when it happened and
|
|
57
|
+
* where. Pure, so the same report reads the same in every error.
|
|
58
|
+
*/
|
|
59
|
+
export function errorReport(report) {
|
|
60
|
+
/* An empty heading (a callout without a title) is left out, not written as a blank line. */
|
|
61
|
+
const lines = report.heading === "" ? [] : [report.heading];
|
|
62
|
+
if (report.sentence)
|
|
63
|
+
lines.push(report.sentence);
|
|
64
|
+
if (report.detail)
|
|
65
|
+
lines.push(report.detail);
|
|
66
|
+
lines.push(report.at.toISOString());
|
|
67
|
+
if (report.page)
|
|
68
|
+
lines.push(report.page);
|
|
69
|
+
return lines.join("\n");
|
|
70
|
+
}
|
|
71
|
+
/* The page is read when the button is pressed, not when the error is drawn: a
|
|
72
|
+
report copied later still says where the person was. */
|
|
73
|
+
export function currentPage() {
|
|
74
|
+
return typeof window === "undefined" ? undefined : window.location.href;
|
|
75
|
+
}
|
|
76
|
+
/* A visible, labelled button, not the icon-only `CopyButton`: on an error the
|
|
77
|
+
person has to SEE that there is something to copy, and «Copiar el error» says
|
|
78
|
+
what it copies. Its feedback is said in words too, and a failed copy is said
|
|
79
|
+
as a failure — never a check mark over a clipboard that did not get the text. */
|
|
80
|
+
export function useErrorCopy(report) {
|
|
81
|
+
const copy = useUiCopy();
|
|
82
|
+
const [state, setState] = useState("idle");
|
|
83
|
+
const timer = useRef(null);
|
|
84
|
+
useEffect(() => () => {
|
|
85
|
+
if (timer.current !== null)
|
|
86
|
+
clearTimeout(timer.current);
|
|
87
|
+
}, []);
|
|
88
|
+
async function run() {
|
|
89
|
+
if (timer.current !== null)
|
|
90
|
+
clearTimeout(timer.current);
|
|
91
|
+
try {
|
|
92
|
+
await navigator.clipboard.writeText(report());
|
|
93
|
+
setState("done");
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
setState("failed");
|
|
97
|
+
}
|
|
98
|
+
timer.current = setTimeout(() => setState("idle"), 2000);
|
|
99
|
+
}
|
|
100
|
+
const said = state === "done"
|
|
101
|
+
? copy.copyable.done
|
|
102
|
+
: state === "failed"
|
|
103
|
+
? copy.copyable.failed
|
|
104
|
+
: copy.copyable.report;
|
|
105
|
+
return { said, state, run };
|
|
106
|
+
}
|
|
107
|
+
export function ErrorCopy({ report }) {
|
|
108
|
+
const { said, state, run } = useErrorCopy(report);
|
|
109
|
+
return (_jsx(Button, { role: state === "failed" ? "danger" : "secondary", size: "sm", icon: state === "done" ? Check : Copy, onClick: () => void run(), children: said }));
|
|
110
|
+
}
|
|
111
|
+
export function Failed({ heading, sentence, action, detail, }) {
|
|
112
|
+
return (_jsxs("div", { className: "rounded-control border border-bad/40 bg-bad/5 px-4 py-3", children: [_jsx("p", { className: "text-body font-medium text-bad", children: heading }), _jsx("p", { className: "mt-1.5 max-w-prose text-lead leading-relaxed text-ink", children: sentence }), detail === undefined ? null : (_jsx("p", { className: "mt-2 max-w-prose font-mono text-micro break-words text-muted select-text", children: detail })), _jsxs("div", { className: "mt-3 flex flex-wrap items-center gap-x-4 gap-y-2", children: [action === undefined ? null : _jsx("div", { children: action }), _jsx(ErrorCopy, { report: () => errorReport({ heading, sentence, detail, at: new Date(), page: currentPage() }) })] })] }));
|
|
53
113
|
}
|
|
54
114
|
/**
|
|
55
115
|
* Nobody knows how to draw this. It carries the full identifier because that is
|
|
56
116
|
* the only thing that makes it fixable.
|
|
57
117
|
*/
|
|
58
118
|
export function Missing({ heading, detail, icon: Icon = PackageX, tone = "warn", }) {
|
|
59
|
-
return (_jsxs("div", { className: "flex h-full min-h-24 flex-col items-center justify-center gap-2 p-6 text-center", children: [_jsx(Icon, { className: `size-(--size-icon-lg) ${tone === "bad" ? "text-bad" : "text-warn"}`, strokeWidth: 1.75 }), _jsx("p", { className: "text-meta font-medium text-ink", children: heading }), detail === undefined ? null : (_jsx("p", { className: "max-w-short font-mono text-micro break-
|
|
119
|
+
return (_jsxs("div", { className: "flex h-full min-h-24 flex-col items-center justify-center gap-2 p-6 text-center", children: [_jsx(Icon, { className: `size-(--size-icon-lg) ${tone === "bad" ? "text-bad" : "text-warn"}`, strokeWidth: 1.75 }), _jsx("p", { className: "text-meta font-medium text-ink", children: heading }), detail === undefined ? null : (_jsx("p", { className: "max-w-short font-mono text-micro break-words text-muted select-text", children: detail })), _jsx(ErrorCopy, { report: () => errorReport({ heading, detail, at: new Date(), page: currentPage() }) })] }));
|
|
60
120
|
}
|
|
61
121
|
/** The icon `Missing` uses for what broke while being drawn, so that whoever
|
|
62
122
|
* composes does not have to choose it. */
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useUiCopy } from "../../foundations/copy.js";
|
|
4
4
|
import { cn, focusRing } from "../../foundations/variants.js";
|
|
5
|
+
import { currentPage, errorReport, useErrorCopy, } from "./Notice.js";
|
|
5
6
|
import { CheckCircle2, Info, TriangleAlert, X, XCircle } from "lucide-react";
|
|
6
7
|
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
|
|
7
8
|
import { Button as AriaButton, Link as AriaLink, Text, UNSTABLE_Toast as AriaToast, UNSTABLE_ToastContent as ToastContent, UNSTABLE_ToastQueue as ToastQueue, UNSTABLE_ToastRegion as ToastRegion, } from "react-aria-components";
|
|
@@ -135,7 +136,15 @@ function ToastCard({ toast, queued, queue, }) {
|
|
|
135
136
|
const Icon = ICON[tone];
|
|
136
137
|
const close = () => queue.close(queued.key);
|
|
137
138
|
const action = toast.action;
|
|
138
|
-
|
|
139
|
+
/* Only an error is worth copying whole: what it said, the server's reason, when, where.
|
|
140
|
+
The hook runs for every toast so the rules of hooks hold; only a bad one draws it. */
|
|
141
|
+
const errorCopy = useErrorCopy(() => errorReport({
|
|
142
|
+
heading: toast.message,
|
|
143
|
+
detail: toast.detail,
|
|
144
|
+
at: new Date(),
|
|
145
|
+
page: currentPage(),
|
|
146
|
+
}));
|
|
147
|
+
return (_jsxs(AriaToast, { toast: queued, className: ({ isFocusVisible }) => cn("flex min-w-0 items-start gap-2.5 rounded-panel border border-line bg-surface px-3.5 py-3 shadow-float outline-offset-2", focusRing({ isFocusVisible })), children: [_jsx(Icon, { className: `mt-px size-(--size-icon-md) shrink-0 ${TONE[tone]}`, strokeWidth: 2, "aria-hidden": true }), _jsxs(ToastContent, { className: "flex min-w-0 flex-1 flex-col gap-1", children: [_jsx(Text, { slot: "title", className: "text-meta text-ink", children: toast.message }), toast.detail === undefined ? null : (_jsx(Text, { slot: "description", className: "text-micro text-muted", children: toast.detail }))] }), tone !== "bad" ? null : (_jsx(AriaButton, { onPress: () => void errorCopy.run(), className: ({ isFocusVisible }) => cn(LINK, "mt-px", focusRing({ isFocusVisible })), children: errorCopy.said })), action === undefined ? null : action.href !== undefined ? (_jsx(AriaLink, { href: action.href, onPress: close, className: ({ isFocusVisible }) => cn(LINK, "mt-px", focusRing({ isFocusVisible })), children: action.label })) : (_jsx(AriaButton, { onPress: () => {
|
|
139
148
|
action.onSelect?.();
|
|
140
149
|
close();
|
|
141
150
|
}, className: ({ isFocusVisible }) => cn(LINK, "mt-px", focusRing({ isFocusVisible })), children: action.label })), _jsx(AriaButton, { slot: "close", "aria-label": copy.shell.closeNotice, className: ({ isFocusVisible }) => cn("-mt-0.5 -mr-1 inline-flex size-6 shrink-0 cursor-default items-center justify-center rounded-pill text-muted transition-colors duration-(--duration-instant) hover:bg-ink/6 hover:text-ink pressed:bg-ink/10", focusRing({ isFocusVisible })), children: _jsx(X, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true }) })] }));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type MarkdownProps = {
|
|
2
|
+
/** The markdown source. Plain text is valid markdown too. */
|
|
3
|
+
children: string;
|
|
4
|
+
/** The text is still arriving: hold back what cannot be read yet. */
|
|
5
|
+
streaming?: boolean;
|
|
6
|
+
/** The accessible name when the document is the point of the screen. */
|
|
7
|
+
label?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function Markdown({ children, streaming, label }: MarkdownProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Streamdown } from "streamdown";
|
|
4
|
+
/* The document's own rhythm, in tokens. The arbitrary variants only select the
|
|
5
|
+
descendants; every value is a token. A heading is the same size as the rest
|
|
6
|
+
of the product's headings, not a browser default. */
|
|
7
|
+
const BODY = "max-w-prose text-body leading-relaxed text-ink " +
|
|
8
|
+
"[&_p]:mt-2 [&_p:first-child]:mt-0 " +
|
|
9
|
+
"[&_h1]:mt-4 [&_h1]:text-display [&_h1]:font-semibold " +
|
|
10
|
+
"[&_h2]:mt-4 [&_h2]:text-lead [&_h2]:font-semibold " +
|
|
11
|
+
"[&_h3]:mt-3 [&_h3]:text-body [&_h3]:font-semibold " +
|
|
12
|
+
"[&_ul]:mt-2 [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:mt-2 [&_ol]:list-decimal [&_ol]:pl-5 " +
|
|
13
|
+
"[&_a]:text-primary [&_a]:underline [&_a]:underline-offset-4 " +
|
|
14
|
+
"[&_code]:rounded-control [&_code]:bg-ink/6 [&_code]:px-1 [&_code]:font-mono [&_code]:text-micro " +
|
|
15
|
+
"[&_blockquote]:mt-2 [&_blockquote]:border-l-2 [&_blockquote]:border-line-strong [&_blockquote]:pl-3 [&_blockquote]:text-muted";
|
|
16
|
+
export function Markdown({ children, streaming = false, label }) {
|
|
17
|
+
return (_jsx("div", { role: label === undefined ? undefined : "document", "aria-label": label, className: BODY, children: _jsx(Streamdown, { mode: streaming ? "streaming" : "static", controls: false, children: children }) }));
|
|
18
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { Copyable, type CopyableProps, CopyButton, } from "./Copyable.js";
|
|
2
2
|
export { DateValue, formatDateTime, formatRelative, } from "./DateValue.js";
|
|
3
|
+
export { Markdown, type MarkdownProps } from "./Markdown.js";
|
|
3
4
|
export { Meter, type MeterLevel, meterLevel, type MeterProps, type MeterThresholds, } from "./Meter.js";
|
|
4
5
|
export { Metric, type MetricProps, Metrics } from "./Metric.js";
|
|
5
6
|
export { Avatar, type AvatarSize, type PersonContact, UserChip, type UserChipProps, UserStack, } from "./Person.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* Show a number or a datum so that it reads as such and not as text. */
|
|
2
2
|
export { Copyable, CopyButton, } from "./Copyable.js";
|
|
3
3
|
export { DateValue, formatDateTime, formatRelative, } from "./DateValue.js";
|
|
4
|
+
export { Markdown } from "./Markdown.js";
|
|
4
5
|
export { Meter, meterLevel, } from "./Meter.js";
|
|
5
6
|
export { Metric, Metrics } from "./Metric.js";
|
|
6
7
|
export { Avatar, UserChip, UserStack, } from "./Person.js";
|
package/dist/tokens.css
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
@import "@fontsource/ibm-plex-mono/latin-ext-400.css";
|
|
12
12
|
@import "@fontsource/ibm-plex-mono/latin-500.css";
|
|
13
13
|
@import "@fontsource/ibm-plex-mono/latin-ext-500.css";
|
|
14
|
+
/* streamdown's animations for text that is still arriving (see Markdown). */
|
|
15
|
+
@import "streamdown/styles.css";
|
|
14
16
|
/* The record calendar (`RecordCalendar`, FullCalendar v7): its structure and the `forma`
|
|
15
17
|
theme. The palette that theme reads is defined below, from web-ui's tokens. */
|
|
16
18
|
@import "@fullcalendar/react/skeleton.css";
|
|
@@ -31,6 +33,13 @@
|
|
|
31
33
|
* inside node_modules — which Tailwind skips unless told. Importing this file is the whole
|
|
32
34
|
* setup a consumer needs. */
|
|
33
35
|
@source ".";
|
|
36
|
+
/* streamdown (the markdown renderer) ships its Tailwind classes too. Two paths, because the
|
|
37
|
+
* package sits in two places: the repo's node_modules (src/ and dist/ are one level below
|
|
38
|
+
* it), and the hoisted node_modules of an application (dist/ sits in
|
|
39
|
+
* node_modules/@sincpro/web-ui). A path that does not exist matches nothing, so the other
|
|
40
|
+
* one is simply skipped. */
|
|
41
|
+
@source "../node_modules/streamdown/dist";
|
|
42
|
+
@source "../../../streamdown/dist";
|
|
34
43
|
|
|
35
44
|
/* ==================================================================== *
|
|
36
45
|
* LIGHT THEME
|
|
@@ -1178,6 +1187,25 @@
|
|
|
1178
1187
|
* 100% is a dialog without a scrim**, and then it is not understood that what
|
|
1179
1188
|
* is behind can still be used.
|
|
1180
1189
|
* ------------------------------------------------------------------ */
|
|
1190
|
+
/* ------------------------------------------------------------------ *
|
|
1191
|
+
* A strip that scrolls without drawing a scrollbar.
|
|
1192
|
+
*
|
|
1193
|
+
* The menus of the app bar on a phone: they used to be clipped (`overflow:
|
|
1194
|
+
* hidden`), which left half a word against the icons — «Cl» — and the rest
|
|
1195
|
+
* of the menus out of reach. Scrolling keeps every menu reachable with the
|
|
1196
|
+
* finger, the wheel or Tab (the focused one scrolls into view); the word cut
|
|
1197
|
+
* at the edge is the sign that there is more. No bar: on the dark app bar a
|
|
1198
|
+
* scrollbar is a grey stripe across the brand.
|
|
1199
|
+
* ------------------------------------------------------------------ */
|
|
1200
|
+
@utility scroll-quiet {
|
|
1201
|
+
overflow-x: auto;
|
|
1202
|
+
overscroll-behavior-x: contain;
|
|
1203
|
+
scrollbar-width: none;
|
|
1204
|
+
&::-webkit-scrollbar {
|
|
1205
|
+
display: none;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1181
1209
|
@utility peek-width {
|
|
1182
1210
|
width: min(var(--container-peek), calc(100% - 2rem));
|
|
1183
1211
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sincpro/web-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "An enterprise web design system for business software — ERPs, back offices, management tools — in React and Tailwind: tokens, primitives, components and the two views every management screen is made of.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -64,10 +64,13 @@
|
|
|
64
64
|
"@tiptap/starter-kit": "^3.32.2",
|
|
65
65
|
"@tiptap/suggestion": "^3.32.2",
|
|
66
66
|
"@uiw/react-codemirror": "^4.25.11",
|
|
67
|
+
"@xyflow/react": "^12.12.1",
|
|
67
68
|
"dompurify": "^3.4.17",
|
|
68
69
|
"lucide-react": "^1.45.0",
|
|
69
70
|
"react-aria": "^3.53.1",
|
|
70
71
|
"react-aria-components": "^1.22.1",
|
|
72
|
+
"react-pdf": "^11.0.0",
|
|
73
|
+
"streamdown": "^2.7.1",
|
|
71
74
|
"tailwind-variants": "^4.0.0",
|
|
72
75
|
"tailwindcss-react-aria-components": "^2.2.0",
|
|
73
76
|
"temporal-polyfill": "^1.0.6"
|