@sincpro/web-ui 2.4.0 → 2.6.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.
Files changed (69) hide show
  1. package/README.md +75 -8
  2. package/dist/components/activity/Activity.d.ts +28 -2
  3. package/dist/components/activity/Activity.js +53 -11
  4. package/dist/components/activity/Messages.d.ts +4 -0
  5. package/dist/components/activity/index.d.ts +1 -1
  6. package/dist/components/attachments/Attachments.d.ts +1 -28
  7. package/dist/components/attachments/Attachments.js +5 -24
  8. package/dist/components/attachments/FileList.d.ts +28 -0
  9. package/dist/components/attachments/FileList.js +91 -0
  10. package/dist/components/attachments/FileThumb.d.ts +13 -0
  11. package/dist/components/attachments/FileThumb.js +34 -0
  12. package/dist/components/attachments/download.d.ts +9 -0
  13. package/dist/components/attachments/download.js +36 -0
  14. package/dist/components/attachments/files.d.ts +28 -0
  15. package/dist/components/attachments/index.d.ts +4 -2
  16. package/dist/components/attachments/index.js +4 -1
  17. package/dist/components/board/Board.d.ts +74 -2
  18. package/dist/components/board/Board.js +65 -2
  19. package/dist/components/board/index.d.ts +1 -1
  20. package/dist/components/board/index.js +1 -1
  21. package/dist/components/calendar/RecordCalendar.d.ts +2 -1
  22. package/dist/components/calendar/RecordCalendar.js +4 -1
  23. package/dist/components/calendar/calendar.css +37 -0
  24. package/dist/components/canvas/canvas.css +6 -1
  25. package/dist/components/chat/ChatThread.d.ts +8 -1
  26. package/dist/components/chat/ChatThread.js +9 -4
  27. package/dist/components/chat/model.d.ts +4 -0
  28. package/dist/components/form/Form.js +11 -0
  29. package/dist/components/form/FormIndex.d.ts +11 -0
  30. package/dist/components/form/FormIndex.js +96 -0
  31. package/dist/components/form/Sheet.js +5 -0
  32. package/dist/components/gantt/RecordGantt.d.ts +9 -1
  33. package/dist/components/gantt/RecordGantt.js +16 -3
  34. package/dist/components/gantt/gantt.css +52 -0
  35. package/dist/components/listing/ChartExplorer.js +10 -5
  36. package/dist/components/record/DirtyActions.d.ts +10 -1
  37. package/dist/components/record/DirtyActions.js +77 -6
  38. package/dist/components/record/RecordHeader.js +17 -11
  39. package/dist/foundations/calendar.d.ts +12 -0
  40. package/dist/foundations/calendar.js +50 -0
  41. package/dist/foundations/chart.d.ts +10 -1
  42. package/dist/foundations/chart.js +17 -1
  43. package/dist/foundations/copy.d.ts +26 -0
  44. package/dist/foundations/copy.es.js +12 -0
  45. package/dist/foundations/copy.js +12 -0
  46. package/dist/foundations/form.d.ts +6 -0
  47. package/dist/foundations/form.js +7 -0
  48. package/dist/foundations/index.d.ts +2 -2
  49. package/dist/foundations/index.js +2 -2
  50. package/dist/foundations/pivot.d.ts +6 -0
  51. package/dist/foundations/pivot.js +1 -0
  52. package/dist/primitives/button/Button.d.ts +5 -1
  53. package/dist/primitives/button/Button.js +9 -2
  54. package/dist/primitives/chart/BarList.d.ts +30 -0
  55. package/dist/primitives/chart/BarList.js +27 -0
  56. package/dist/primitives/chart/Chart.d.ts +13 -0
  57. package/dist/primitives/chart/Chart.js +71 -19
  58. package/dist/primitives/chart/Sparkline.d.ts +30 -0
  59. package/dist/primitives/chart/Sparkline.js +53 -0
  60. package/dist/primitives/chart/index.d.ts +2 -0
  61. package/dist/primitives/chart/index.js +2 -0
  62. package/dist/primitives/field/Field.d.ts +6 -2
  63. package/dist/primitives/field/Field.js +35 -6
  64. package/dist/primitives/value/Markdown.d.ts +1 -0
  65. package/dist/primitives/value/Markdown.js +1 -0
  66. package/dist/primitives/value/Metric.d.ts +7 -0
  67. package/dist/primitives/value/Metric.js +5 -2
  68. package/dist/tokens.css +59 -87
  69. package/package.json +1 -1
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { fileExtension, } from "./files.js";
3
+ import { File, FileImage, FileSpreadsheet, FileText, FileType, } from "lucide-react";
4
+ /* ==================================================================== *
5
+ * FILE THUMB — what a file is, at the size of a row: shared by the record's list
6
+ * (`Attachments`) and the files inside a message or a section (`FileList`), so a PDF looks
7
+ * the same wherever it appears.
8
+ * ==================================================================== */
9
+ const KIND_ICON = {
10
+ image: FileImage,
11
+ pdf: FileText,
12
+ sheet: FileSpreadsheet,
13
+ doc: FileType,
14
+ other: File,
15
+ };
16
+ /** The type, at the size of a row: the image itself when there is one, otherwise the icon
17
+ * of its kind over its extension. The extension is written because three of the five
18
+ * icons are a page with lines on it — «PDF» and «DOCX» are what tell them apart, and a
19
+ * word is never a colour that only some people see.
20
+ *
21
+ * `sm` is the icon alone, for a line of text (a list of a release's assets): the name next
22
+ * to it already ends in its extension. */
23
+ export function FileThumb({ file, kind, size = "md", }) {
24
+ const Icon = KIND_ICON[kind];
25
+ if (size === "sm") {
26
+ return (_jsx(Icon, { "aria-hidden": true, className: "size-(--size-icon-md) shrink-0 text-muted", strokeWidth: 1.75 }));
27
+ }
28
+ const picture = kind === "image" && file.status !== "failed" ? (file.thumbnail ?? file.url) : undefined;
29
+ const extension = fileExtension(file.name).slice(0, 4);
30
+ return (
31
+ /* Decorative: the name next to it says which file it is, and the image's `alt` would
32
+ say it twice. */
33
+ _jsx("span", { "aria-hidden": true, className: "flex size-(--size-control-lg) shrink-0 flex-col items-center justify-center gap-0.5 overflow-clip rounded-control border border-line bg-ink/4 text-muted", children: picture === undefined ? (_jsxs(_Fragment, { children: [_jsx(Icon, { className: "size-(--size-icon-md)", strokeWidth: 1.75 }), extension === "" ? null : (_jsx("span", { className: "text-micro leading-none font-medium uppercase", children: extension }))] })) : (_jsx("img", { src: picture, alt: "", loading: "lazy", className: "size-full object-cover" })) }));
34
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Saves `source` — a `Blob` already in memory, or a URL the browser can reach — as `name`.
3
+ *
4
+ * A `Blob` gets an object URL for the length of the click and is released after it, so a
5
+ * 40 MB PDF does not stay pinned in the tab. A URL on another origin ignores `download` (the
6
+ * browser's rule, not ours): it opens instead of saving, and the server should send
7
+ * `Content-Disposition: attachment` — or the application fetches it and passes the `Blob`.
8
+ */
9
+ export declare function downloadFile(source: Blob | string, name: string): void;
@@ -0,0 +1,36 @@
1
+ "use client";
2
+ /* ==================================================================== *
3
+ * DOWNLOAD — save a file the application fetched by code, with its name.
4
+ *
5
+ * Context: a link with `download` is the best download there is — the browser streams it to
6
+ * disk, middle-click and «save as» work — and `FileList` uses one whenever the file has a
7
+ * `url`. But some files are not behind a plain URL: the request needs a token in a header,
8
+ * the server signs a URL on demand, an Odoo attachment comes through an RPC. Then the
9
+ * application fetches the bytes and has a `Blob` in its hand, and saving it with the right
10
+ * name is the same ten lines in every application. They are here once.
11
+ *
12
+ * onDownload={async (file) => downloadFile(await api.attachment(file.id), file.name)}
13
+ * ==================================================================== */
14
+ /**
15
+ * Saves `source` — a `Blob` already in memory, or a URL the browser can reach — as `name`.
16
+ *
17
+ * A `Blob` gets an object URL for the length of the click and is released after it, so a
18
+ * 40 MB PDF does not stay pinned in the tab. A URL on another origin ignores `download` (the
19
+ * browser's rule, not ours): it opens instead of saving, and the server should send
20
+ * `Content-Disposition: attachment` — or the application fetches it and passes the `Blob`.
21
+ */
22
+ export function downloadFile(source, name) {
23
+ const href = typeof source === "string" ? source : URL.createObjectURL(source);
24
+ const link = document.createElement("a");
25
+ link.href = href;
26
+ link.download = name;
27
+ link.rel = "noopener";
28
+ /* Firefox only follows a click on a link that is in the document. */
29
+ link.style.display = "none";
30
+ document.body.append(link);
31
+ link.click();
32
+ link.remove();
33
+ /* Released on the next task, not now: Safari reads the object URL after `click` returns. */
34
+ if (typeof source !== "string")
35
+ setTimeout(() => URL.revokeObjectURL(href), 0);
36
+ }
@@ -1,3 +1,31 @@
1
+ export type AttachmentStatus = "ready" | "uploading" | "failed";
2
+ export type AttachmentFile = {
3
+ /** The attachment's identity: the server's id, or a local key while it uploads. */
4
+ id: string;
5
+ /** The file name as it was saved: «Factura proveedor 0418.pdf». */
6
+ name: string;
7
+ /** In bytes. Written in the copy's locale: «1,2 MB». */
8
+ size?: number;
9
+ /** The MIME type, when the server knows it. With the name, it picks the icon. */
10
+ type?: string;
11
+ /** Where it downloads from. Absent = no download (still uploading, or not allowed). */
12
+ url?: string;
13
+ /** A small image for the thumbnail. Defaults to `url` for an image — pass a smaller one
14
+ * when the server has it, so a list of 4 MB photos does not load 4 MB photos. */
15
+ thumbnail?: string;
16
+ /** Who added it. */
17
+ by?: string;
18
+ /** Their face, for the chip. */
19
+ byAvatar?: string;
20
+ /** When it was added. */
21
+ at?: Date | string | number;
22
+ /** `ready` by default. The application owns it: it is what the upload is really doing. */
23
+ status?: AttachmentStatus;
24
+ /** 0 to 100 while `uploading`. Absent = under way without a figure yet. */
25
+ progress?: number;
26
+ /** Why it `failed`, in the server's words. */
27
+ error?: string;
28
+ };
1
29
  /** The five kinds a list of attachments tells apart. Five and not twenty: the icon is there
2
30
  * to say «this one is the spreadsheet» at a glance, and twenty icons are read, not seen. */
3
31
  export type AttachmentKind = "image" | "pdf" | "sheet" | "doc" | "other";
@@ -1,2 +1,4 @@
1
- export { type AttachmentFile, Attachments, type AttachmentsProps, type AttachmentStatus, } from "./Attachments.js";
2
- export { type AttachmentKind, attachmentKind, fileExtension, formatFileSize, } from "./files.js";
1
+ export { Attachments, type AttachmentsProps, } from "./Attachments.js";
2
+ export { downloadFile } from "./download.js";
3
+ export { FileList, type FileListLayout, type FileListProps, } from "./FileList.js";
4
+ export { type AttachmentFile, type AttachmentKind, attachmentKind, type AttachmentStatus, fileExtension, formatFileSize, } from "./files.js";
@@ -1,3 +1,6 @@
1
- /* ATTACHMENTS — the files of a record: what they are, who brought them, and what to do with them. */
1
+ /* ATTACHMENTS — the files of a record (`Attachments`: add, remove, undo), files shown inside a
2
+ message, a card or a section (`FileList`), and how to save one fetched by code. */
2
3
  export { Attachments, } from "./Attachments.js";
4
+ export { downloadFile } from "./download.js";
5
+ export { FileList, } from "./FileList.js";
3
6
  export { attachmentKind, fileExtension, formatFileSize, } from "./files.js";
@@ -1,4 +1,7 @@
1
- import type { ReactNode } from "react";
1
+ import type { Tone } from "../../foundations/types.js";
2
+ import { type MetricProps } from "../../primitives/value/Metric.js";
3
+ import type { LucideIcon } from "lucide-react";
4
+ import { type ReactNode } from "react";
2
5
  /**
3
6
  * A BOARD: the tiles of a dashboard — Odoo's «Tableros», a BI page — over one slice of data.
4
7
  *
@@ -28,6 +31,18 @@ import type { ReactNode } from "react";
28
31
  * chart it will hold (`--size-tile-body`), so a neighbour landing never moves the grid. The
29
32
  * board's own `state` is the same for what the board reads as a whole: its headline numbers.
30
33
  * The application (or web-framework's boards) decides each state; web-ui only draws it.
34
+ *
35
+ * ── A tile is a panel of the page, and looks like one ──────────────────
36
+ *
37
+ * A tile used to be a box with a hard border (`line-strong`) and 16 px of air, the radius of
38
+ * a card inside a form: on the near-white ground the border did all the separating, and a
39
+ * page of them read as a wireframe. A tile is a PANEL — the panel's radius, the soft
40
+ * hairline every card has, more air — and its look is its own tokens (`--ui-tile-*`),
41
+ * falling back to the card's.
42
+ *
43
+ * The headline numbers are `BoardStat`s in a `BoardStats` row: tiles too, the same width as
44
+ * the columns under them, the figure in its own type step (`figure`, `hero`) and the trend
45
+ * beside it. `Metric` stays what it is — the chip that filters a list.
31
46
  */
32
47
  /** What a tile — or the board's own headline reading — is doing. */
33
48
  export type BoardState = {
@@ -63,19 +78,76 @@ declare const SPAN: {
63
78
  readonly 2: "@3xl:col-span-2";
64
79
  readonly full: "col-span-full";
65
80
  };
81
+ declare const ROWS: {
82
+ readonly 1: "";
83
+ readonly 2: "@3xl:row-span-2";
84
+ };
66
85
  export type BoardTileProps = {
67
86
  title: string;
87
+ /** What the tile is about, beside its title: a mailbox, a shield. */
88
+ icon?: LucideIcon;
89
+ /** What it counts and how, behind an ⓘ: the sentence that does not fit under the title. */
90
+ hint?: ReactNode;
68
91
  /** One line under the title: what it counts, or what a press on it does. */
69
92
  description?: ReactNode;
70
93
  /** The tile's own buttons, at its top right: open the list behind it, download. */
71
94
  actions?: ReactNode;
72
95
  /** How many columns it takes: a time series reads better wide. */
73
96
  span?: keyof typeof SPAN;
97
+ /** How many rows: a tall tile beside two short ones stacked. From two columns up. */
98
+ rows?: keyof typeof ROWS;
74
99
  /** Reading, ready or failed. Not ready, the body is the state, the height of a chart; the
75
100
  * title, its description and its actions stay. */
76
101
  state?: BoardState;
77
102
  children: ReactNode;
78
103
  };
79
104
  /** One tile of a `Board`: a titled surface around a chart, a list or a number. */
80
- export declare function BoardTile({ title, description, actions, span, state, children, }: BoardTileProps): import("react").JSX.Element;
105
+ export declare function BoardTile({ title, icon, hint, description, actions, span, rows, state, children, }: BoardTileProps): import("react").JSX.Element;
106
+ export type BoardStatProps = {
107
+ /** What the figure counts: «Mensajes recibidos». Sentence case, no colon. */
108
+ label: string;
109
+ /** The figure, already written or a number (written in the copy's locale). Absent — and not
110
+ * reading — it says «Sin datos»: nothing to compute it from, which is not zero. */
111
+ value?: number | string;
112
+ icon?: LucideIcon;
113
+ /** What it counts and how, behind an ⓘ beside the label. */
114
+ hint?: ReactNode;
115
+ /** A second reading under the figure, already formatted: «de 1.240 recibidos». */
116
+ detail?: string;
117
+ /** How it moved against a NAMED period — the same mark as `Metric.change`. */
118
+ change?: MetricProps["change"];
119
+ /** The last periods, oldest first: drawn as a sparkline beside the figure. */
120
+ trend?: readonly (number | null)[];
121
+ /** The ONE figure the board leads with: the hero step (≥ 48 px). At most one per board. */
122
+ hero?: boolean;
123
+ /**
124
+ * The STATE of the reading, never decoration: a share of clean mail under its floor is
125
+ * `bad`. It tints the tile and its icon; the label, the detail or the hint has to say why
126
+ * in words, because a colour alone is not read by everyone.
127
+ */
128
+ tone?: Tone;
129
+ /** Reading or failed: the figure's place keeps its size, the label stays. */
130
+ state?: BoardState;
131
+ /** Columns in the row of stats. */
132
+ span?: 1 | 2;
133
+ };
134
+ /**
135
+ * A board's headline figure as a tile: the label (with its icon and ⓘ), the figure big, and
136
+ * under it how it moved and the shape of the last periods.
137
+ *
138
+ * Context: it is NOT a `Metric`. A metric is a chip over a list that narrows it when pressed —
139
+ * small, the size of what it filters. A stat tile is read before anything else on a board
140
+ * and pressed for nothing; it has the width of the columns under it, so the page is one grid,
141
+ * and the figure is in the figure step, in proportional digits (tabular digits space a lone
142
+ * «121» like «000»; they are for columns).
143
+ */
144
+ export declare function BoardStat({ label, value, icon, hint, detail, change, trend, hero, tone, state, span, }: BoardStatProps): import("react").JSX.Element;
145
+ /**
146
+ * The row of a board's stat tiles: as wide as the grid under it, every tile the same width —
147
+ * two per row when the board is narrow, all in one row from a wide board up. A row of
148
+ * figures of different widths reads as figures of different kinds.
149
+ */
150
+ export declare function BoardStats({ children }: {
151
+ children: ReactNode;
152
+ }): import("react").JSX.Element;
81
153
  export {};
@@ -2,7 +2,11 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { fillCopy, useUiCopy } from "../../foundations/copy.js";
4
4
  import { Button } from "../../primitives/button/Button.js";
5
+ import { Sparkline } from "../../primitives/chart/Sparkline.js";
6
+ import { Hint } from "../../primitives/hint/Hint.js";
5
7
  import { Failed } from "../../primitives/notice/Notice.js";
8
+ import { MetricChange } from "../../primitives/value/Metric.js";
9
+ import { useMemo } from "react";
6
10
  const READY = { status: "ready" };
7
11
  function Failure({ heading, state, }) {
8
12
  const copy = useUiCopy();
@@ -28,11 +32,70 @@ const SPAN = {
28
32
  2: "@3xl:col-span-2",
29
33
  full: "col-span-full",
30
34
  };
35
+ const ROWS = { 1: "", 2: "@3xl:row-span-2" };
36
+ /** The skin every tile shares, a stat tile included: a panel on the ground. */
37
+ const TILE = "rounded-ui-tile border border-ui-tile-border bg-ui-tile";
38
+ /** The mark of what a tile is about: its icon in a quiet square, never in a colour of its
39
+ * own — the colour of a tile is its state, not its subject. */
40
+ function TileIcon({ icon: Icon, tone }) {
41
+ return (_jsx("span", { "aria-hidden": true, className: `flex size-8 shrink-0 items-center justify-center rounded-control ${tone === undefined || tone === "neutral" ? "bg-ink/5 text-muted" : TONE[tone].icon}`, children: _jsx(Icon, { className: "size-(--size-icon-md)", strokeWidth: 2 }) }));
42
+ }
43
+ /** A tile's heading: the icon, the title and its ⓘ — what it counts, said on demand. */
44
+ function TileHeading({ title, icon, hint, tone, size = "title", }) {
45
+ return (_jsxs("div", { className: "flex min-w-0 items-center gap-2.5", children: [icon === undefined ? null : _jsx(TileIcon, { icon: icon, tone: tone }), _jsx("h2", { className: `min-w-0 truncate font-semibold text-ink ${size === "title" ? "text-lead" : "text-meta"}`, children: title }), hint === undefined ? null : _jsx(Hint, { children: hint })] }));
46
+ }
31
47
  /** One tile of a `Board`: a titled surface around a chart, a list or a number. */
32
- export function BoardTile({ title, description, actions, span = 1, state = READY, children, }) {
48
+ export function BoardTile({ title, icon, hint, description, actions, span = 1, rows = 1, state = READY, children, }) {
33
49
  const copy = useUiCopy();
34
- return (_jsxs("section", { "aria-label": title, ...(state.status === "loading" ? { "aria-busy": true } : {}), "data-ui": "board.tile", className: `flex min-w-0 flex-col gap-4 rounded-ui-card border border-line-strong bg-ui-card p-4 ${SPAN[span]}`, children: [_jsxs("header", { className: "flex min-w-0 items-start justify-between gap-3", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("h2", { className: "text-lead font-semibold text-ink", children: title }), description === undefined ? null : (_jsx("p", { className: "mt-0.5 text-meta text-muted", children: description }))] }), actions === undefined ? null : (_jsx("div", { className: "flex shrink-0 items-center gap-1", children: actions }))] }), state.status === "loading" ? (
50
+ return (_jsxs("section", { "aria-label": title, ...(state.status === "loading" ? { "aria-busy": true } : {}), "data-ui": "board.tile", className: `flex min-w-0 flex-col gap-4 p-5 ${TILE} ${SPAN[span]} ${ROWS[rows]}`, children: [_jsxs("header", { className: "flex min-w-0 items-start justify-between gap-3", children: [_jsxs("div", { className: "min-w-0", children: [_jsx(TileHeading, { title: title, icon: icon, hint: hint }), description === undefined ? null : (_jsx("p", { className: "mt-0.5 text-meta text-muted", children: description }))] }), actions === undefined ? null : (_jsx("div", { className: "flex shrink-0 items-center gap-1", children: actions }))] }), state.status === "loading" ? (
35
51
  /* A quiet block where the chart goes. It appears late, like every skeleton: a fast
36
52
  read never shows it. */
37
53
  _jsx("div", { className: "min-h-(--size-tile-body) animate-reveal-late rounded-control bg-ink/4", children: _jsx("span", { className: "sr-only", children: copy.failed.loading }) })) : state.status === "failed" ? (_jsx("div", { className: "flex min-h-(--size-tile-body) flex-col justify-center", children: _jsx(Failure, { heading: fillCopy(copy.board.tileFailed, { title }), state: state }) })) : (children)] }));
38
54
  }
55
+ /* ==================================================================== *
56
+ * THE STAT TILE — the headline numbers of a board.
57
+ * ==================================================================== */
58
+ const TONE = {
59
+ neutral: { tile: "", icon: "bg-ink/5 text-muted" },
60
+ info: { tile: "bg-info/6 border-info/25", icon: "bg-info/12 text-info" },
61
+ good: { tile: "bg-good/6 border-good/25", icon: "bg-good/12 text-good" },
62
+ warn: { tile: "bg-warn/8 border-warn/30", icon: "bg-warn/14 text-warn" },
63
+ bad: { tile: "bg-bad/6 border-bad/25", icon: "bg-bad/12 text-bad" },
64
+ /* The gold never draws the border of a state (PRINCIPLES §3): only the wash. */
65
+ accent: { tile: "bg-accent/12", icon: "bg-accent/20 text-ink" },
66
+ };
67
+ /**
68
+ * A board's headline figure as a tile: the label (with its icon and ⓘ), the figure big, and
69
+ * under it how it moved and the shape of the last periods.
70
+ *
71
+ * Context: it is NOT a `Metric`. A metric is a chip over a list that narrows it when pressed —
72
+ * small, the size of what it filters. A stat tile is read before anything else on a board
73
+ * and pressed for nothing; it has the width of the columns under it, so the page is one grid,
74
+ * and the figure is in the figure step, in proportional digits (tabular digits space a lone
75
+ * «121» like «000»; they are for columns).
76
+ */
77
+ export function BoardStat({ label, value, icon, hint, detail, change, trend, hero = false, tone, state = READY, span = 1, }) {
78
+ const copy = useUiCopy();
79
+ const percent = useMemo(() => new Intl.NumberFormat(copy.locale, {
80
+ style: "percent",
81
+ maximumFractionDigits: 1,
82
+ signDisplay: "exceptZero",
83
+ }), [copy.locale]);
84
+ const loading = state.status === "loading";
85
+ const missing = value === undefined;
86
+ const figure = missing
87
+ ? copy.board.noData
88
+ : typeof value === "number"
89
+ ? value.toLocaleString(copy.locale)
90
+ : value;
91
+ const shade = tone === undefined ? "" : TONE[tone].tile;
92
+ return (_jsxs("section", { "aria-label": label, ...(loading ? { "aria-busy": true } : {}), "data-ui": "board.stat", ...(tone === undefined ? {} : { "data-tone": tone }), className: `flex min-w-0 flex-col gap-3 p-5 ${TILE} ${shade} ${span === 2 ? "@xl:col-span-2" : ""}`, children: [_jsx(TileHeading, { title: label, icon: icon, hint: hint, tone: tone, size: "label" }), state.status === "failed" ? (_jsx(Failure, { heading: fillCopy(copy.board.tileFailed, { title: label }), state: state })) : (_jsxs("div", { className: "flex min-w-0 items-end justify-between gap-4", children: [_jsxs("div", { className: "flex min-w-0 flex-col gap-1", children: [loading ? (_jsx("span", { "aria-hidden": true, className: `inline-block w-24 animate-reveal-late rounded-control bg-ink/8 ${hero ? "h-(--text-hero)" : "h-(--text-figure)"}` })) : (_jsx("span", { "data-ui": "board.stat.value", className: `min-w-0 truncate font-semibold text-ink ${hero ? "text-hero" : "text-figure"} ${missing ? "text-muted" : ""}`, children: figure })), loading ? _jsx("span", { className: "sr-only", children: copy.failed.loading }) : null, loading || (detail === undefined && change === undefined) ? null : (_jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5", children: [change === undefined ? null : (_jsx(MetricChange, { change: change, format: percent.format })), detail === undefined ? null : (_jsx("span", { className: "min-w-0 truncate text-micro text-muted", children: detail }))] }))] }), loading || trend === undefined ? null : (_jsx("div", { className: "w-2/5 max-w-40 shrink-0 pb-1", children: _jsx(Sparkline, { values: trend, label: label }) }))] }))] }));
93
+ }
94
+ /**
95
+ * The row of a board's stat tiles: as wide as the grid under it, every tile the same width —
96
+ * two per row when the board is narrow, all in one row from a wide board up. A row of
97
+ * figures of different widths reads as figures of different kinds.
98
+ */
99
+ export function BoardStats({ children }) {
100
+ return (_jsx("div", { className: "grid min-w-0 grid-cols-1 gap-4 @xl:grid-cols-2 @5xl:grid-flow-col @5xl:grid-cols-none @5xl:auto-cols-fr", children: children }));
101
+ }
@@ -1 +1 @@
1
- export { Board, type BoardProps, type BoardState, BoardTile, type BoardTileProps, } from "./Board.js";
1
+ export { Board, type BoardProps, BoardStat, type BoardState, type BoardStatProps, BoardStats, BoardTile, type BoardTileProps, } from "./Board.js";
@@ -1,3 +1,3 @@
1
1
  /* A dashboard: one filter row, the headline numbers, and tiles over the same slice — each
2
2
  tile reading on its own, with its loading and failed states. */
3
- export { Board, BoardTile, } from "./Board.js";
3
+ export { Board, BoardStat, BoardStats, BoardTile, } from "./Board.js";
@@ -1,3 +1,4 @@
1
+ import "@sincpro/web-ui/components/calendar/calendar.css";
1
2
  import type { Tone } from "../../foundations/types.js";
2
3
  import type { ReactNode } from "react";
3
4
  export type CalendarView = "month" | "week" | "day" | "agenda";
@@ -39,7 +40,7 @@ export type RecordCalendarProps<T> = {
39
40
  * Records on a calendar — Odoo's calendar view: meetings, deliveries, due dates.
40
41
  *
41
42
  * Context: drawn by FullCalendar v7 (MIT standard views: month, week, day, agenda), dressed by
42
- * `tokens.css` (its `forma` palette points at web-ui's tokens, so it follows the theme). It is a
43
+ * `calendar.css` (its `forma` palette points at web-ui's tokens, so it follows the theme). It is a
43
44
  * CONTROLLED view of the records: dragging or stretching an event reports `onMove` and the
44
45
  * library's own change is undone at once — the app persists and passes the new `items`, so the
45
46
  * screen never shows a date the backend refused. Resource rows (per person, per room) are
@@ -1,5 +1,8 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ /* FullCalendar's stylesheet and its palette in web-ui's tokens: imported here, not in
4
+ `tokens.css`, so it travels in the calendar's chunk. */
5
+ import "@sincpro/web-ui/components/calendar/calendar.css";
3
6
  import FullCalendar from "@fullcalendar/react";
4
7
  import dayGridPlugin from "@fullcalendar/react/daygrid";
5
8
  import interactionPlugin from "@fullcalendar/react/interaction";
@@ -29,7 +32,7 @@ const TONE_COLOR = {
29
32
  * Records on a calendar — Odoo's calendar view: meetings, deliveries, due dates.
30
33
  *
31
34
  * Context: drawn by FullCalendar v7 (MIT standard views: month, week, day, agenda), dressed by
32
- * `tokens.css` (its `forma` palette points at web-ui's tokens, so it follows the theme). It is a
35
+ * `calendar.css` (its `forma` palette points at web-ui's tokens, so it follows the theme). It is a
33
36
  * CONTROLLED view of the records: dragging or stretching an event reports `onMove` and the
34
37
  * library's own change is undone at once — the app persists and passes the new `items`, so the
35
38
  * screen never shows a date the backend refused. Resource rows (per person, per room) are
@@ -0,0 +1,37 @@
1
+ /* ====================================================================
2
+ * THE RECORD CALENDAR (FullCalendar v7, `forma` theme) in these tokens.
3
+ *
4
+ * Context: FullCalendar's structure and its `forma` theme, then the palette that theme reads.
5
+ * It comes with `RecordCalendar` — imported by the component, not by `tokens.css` — so it
6
+ * travels in the calendar's chunk: a screen that never opens a calendar never downloads it.
7
+ *
8
+ * The theme reads a palette of `--fc-forma-*` variables. Pointed at web-ui's tokens it takes
9
+ * the theme — light, dark, a brand — with no dark block of its own: the tokens already flip.
10
+ * Aliases, so no contrast of their own to measure; the translucent washes are mixed from the
11
+ * ink so they read on either theme.
12
+ * ==================================================================== */
13
+ @import "@fullcalendar/react/skeleton.css";
14
+ @import "@fullcalendar/react/themes/forma/theme.css";
15
+
16
+ :root {
17
+ --fc-forma-primary: var(--color-primary);
18
+ --fc-forma-primary-over: var(--color-primary-hover);
19
+ --fc-forma-primary-down: var(--color-primary-hover);
20
+ --fc-forma-primary-foreground: var(--color-surface);
21
+ --fc-forma-event: var(--color-primary);
22
+ --fc-forma-event-contrast: var(--color-surface);
23
+ --fc-forma-background-event: var(--color-primary);
24
+ --fc-forma-highlight: color-mix(in srgb, var(--color-primary) 18%, transparent);
25
+ --fc-forma-background: var(--color-surface);
26
+ --fc-forma-faint: color-mix(in srgb, var(--color-ink) 3%, transparent);
27
+ --fc-forma-muted: color-mix(in srgb, var(--color-ink) 7%, transparent);
28
+ --fc-forma-strong: color-mix(in srgb, var(--color-ink) 12%, transparent);
29
+ --fc-forma-stronger: color-mix(in srgb, var(--color-ink) 16%, transparent);
30
+ --fc-forma-strongest: color-mix(in srgb, var(--color-ink) 20%, transparent);
31
+ --fc-forma-foreground: var(--color-ink);
32
+ --fc-forma-faint-foreground: var(--color-muted);
33
+ --fc-forma-muted-foreground: var(--color-muted);
34
+ --fc-forma-border: var(--color-line);
35
+ --fc-forma-muted-border: var(--color-line);
36
+ --fc-forma-strong-border: var(--color-line-strong);
37
+ }
@@ -14,6 +14,11 @@
14
14
  --xy-controls-button-border-color-default: var(--color-line);
15
15
  --xy-controls-button-color-default: var(--color-ink);
16
16
  --xy-minimap-background-color-default: var(--color-surface);
17
- --xy-minimap-mask-background-color-default: var(--color-scrim);
17
+ /* The mask covers what is off screen; opaque, it would hide those nodes instead of dimming. */
18
+ --xy-minimap-mask-background-color-default: color-mix(
19
+ in srgb,
20
+ var(--color-scrim) 40%,
21
+ transparent
22
+ );
18
23
  --xy-handle-background-color-default: var(--color-primary);
19
24
  }
@@ -1,3 +1,4 @@
1
+ import type { AttachmentFile } from "../attachments/files.js";
1
2
  import { type ChatMessage } from "./model.js";
2
3
  export type ChatThreadProps = {
3
4
  messages: readonly ChatMessage[];
@@ -9,5 +10,11 @@ export type ChatThreadProps = {
9
10
  label?: string;
10
11
  /** The «now» the day names are relative to. */
11
12
  now?: Date;
13
+ /** Open a file a message carries. Present = its name is a button; WHERE it opens — a
14
+ * peek, a `FilePreview` — is the application's. */
15
+ onOpenFile?: (file: AttachmentFile, message: ChatMessage) => void;
16
+ /** Download a file a message carries by code (a token, a signed URL). Without it, a file
17
+ * with a `url` downloads by link. Busy while the promise runs; a rejection is said. */
18
+ onDownloadFile?: (file: AttachmentFile, message: ChatMessage) => void | Promise<unknown>;
12
19
  };
13
- export declare function ChatThread({ messages, onLoadOlder, loadingOlder, label, now, }: ChatThreadProps): import("react").JSX.Element;
20
+ export declare function ChatThread({ messages, onLoadOlder, loadingOlder, label, now, onOpenFile, onDownloadFile, }: ChatThreadProps): import("react").JSX.Element;
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { FileList } from "../attachments/FileList.js";
3
4
  import { dayLabel, groupByDay, startsRun, } from "./model.js";
4
5
  import { useUiCopy } from "../../foundations/copy.js";
5
6
  import { Button } from "../../primitives/button/Button.js";
@@ -33,7 +34,7 @@ import { useLayoutEffect, useRef, useState } from "react";
33
34
  * ==================================================================== */
34
35
  /** How close to the bottom still counts as «at the bottom», in pixels. */
35
36
  const AT_BOTTOM = 48;
36
- export function ChatThread({ messages, onLoadOlder, loadingOlder = false, label, now, }) {
37
+ export function ChatThread({ messages, onLoadOlder, loadingOlder = false, label, now, onOpenFile, onDownloadFile, }) {
37
38
  const copy = useUiCopy();
38
39
  const scroller = useRef(null);
39
40
  /* A ref, not state: the scroll handler writes it on every frame and nothing
@@ -67,10 +68,14 @@ export function ChatThread({ messages, onLoadOlder, loadingOlder = false, label,
67
68
  const words = { today: copy.chat.today, yesterday: copy.chat.yesterday };
68
69
  return (_jsxs("div", { className: "relative flex min-h-0 flex-1 flex-col", children: [_jsxs("div", { ref: scroller, role: "log",
69
70
  /* A scrollable region is reachable by keyboard (axe): the arrows scroll it. */
70
- tabIndex: 0, "aria-label": label ?? copy.chat.thread, "aria-live": "polite", onScroll: onScroll, className: "flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto px-5 py-4", children: [onLoadOlder === undefined ? null : (_jsx("div", { className: "flex justify-center pb-3", children: _jsx(Button, { role: "ghost", size: "sm", disabled: loadingOlder, onClick: onLoadOlder, children: loadingOlder ? copy.chat.loadingOlder : copy.chat.loadOlder }) })), messages.length === 0 ? _jsx(Empty, { sentence: copy.chat.empty }) : null, groups.map((group) => (_jsxs("section", { className: "flex flex-col gap-1", children: [_jsx("div", { className: "my-3 flex justify-center", children: _jsx("span", { className: "rounded-control border border-line bg-surface px-3 py-0.5 text-micro font-medium text-muted", children: dayLabel(group.day, clock, words, copy.locale) }) }), group.messages.map((message, index) => (_jsx(Bubble, { message: message, first: startsRun(group.messages, index), locale: copy.locale }, message.id)))] }, group.key)))] }), showJump ? (_jsx("div", { className: "pointer-events-none absolute inset-x-0 bottom-3 flex justify-center", children: _jsx("div", { className: "pointer-events-auto", children: _jsx(Button, { role: "secondary", size: "sm", onClick: toLatest, children: copy.chat.jumpLatest }) }) })) : null] }));
71
+ tabIndex: 0, "aria-label": label ?? copy.chat.thread, "aria-live": "polite", onScroll: onScroll, className: "flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto px-5 py-4", children: [onLoadOlder === undefined ? null : (_jsx("div", { className: "flex justify-center pb-3", children: _jsx(Button, { role: "ghost", size: "sm", disabled: loadingOlder, onClick: onLoadOlder, children: loadingOlder ? copy.chat.loadingOlder : copy.chat.loadOlder }) })), messages.length === 0 ? _jsx(Empty, { sentence: copy.chat.empty }) : null, groups.map((group) => (_jsxs("section", { className: "flex flex-col gap-1", children: [_jsx("div", { className: "my-3 flex justify-center", children: _jsx("span", { className: "rounded-control border border-line bg-surface px-3 py-0.5 text-micro font-medium text-muted", children: dayLabel(group.day, clock, words, copy.locale) }) }), group.messages.map((message, index) => (_jsx(Bubble, { message: message, first: startsRun(group.messages, index), locale: copy.locale, onOpenFile: onOpenFile, onDownloadFile: onDownloadFile }, message.id)))] }, group.key)))] }), showJump ? (_jsx("div", { className: "pointer-events-none absolute inset-x-0 bottom-3 flex justify-center", children: _jsx("div", { className: "pointer-events-auto", children: _jsx(Button, { role: "secondary", size: "sm", onClick: toLatest, children: copy.chat.jumpLatest }) }) })) : null] }));
71
72
  }
72
- function Bubble({ message, first, locale, }) {
73
+ function Bubble({ message, first, locale, onOpenFile, onDownloadFile, }) {
73
74
  const copy = useUiCopy();
74
75
  const time = new Intl.DateTimeFormat(locale, { hour: "2-digit", minute: "2-digit" }).format(message.at);
75
- return (_jsx("div", { className: `flex ${message.mine ? "justify-end" : "justify-start"} ${first ? "mt-2" : ""}`, children: _jsxs("div", { className: `max-w-prose rounded-control border px-3 py-2 ${message.mine ? "border-primary/30 bg-primary/10" : "border-line bg-surface"} ${message.pending === true ? "opacity-70" : ""}`, children: [first && !message.mine ? (_jsx("p", { className: "text-meta font-medium text-muted", children: message.author })) : null, _jsx("p", { className: "text-body break-words whitespace-pre-wrap text-ink", children: message.body }), _jsxs("p", { className: "mt-1 text-micro text-muted", children: [_jsx("time", { dateTime: message.at.toISOString(), children: time }), message.pending === true ? ` · ${copy.chat.sending}` : null] })] }) }));
76
+ return (_jsx("div", { className: `flex ${message.mine ? "justify-end" : "justify-start"} ${first ? "mt-2" : ""}`, children: _jsxs("div", { className: `max-w-prose rounded-control border px-3 py-2 ${message.mine ? "border-primary/30 bg-primary/10" : "border-line bg-surface"} ${message.pending === true ? "border-dashed" : ""}`, children: [first && !message.mine ? (_jsx("p", { className: "text-meta font-medium text-muted", children: message.author })) : null, message.body === "" ? null : (_jsx("p", { className: "text-body break-words whitespace-pre-wrap text-ink", children: message.body })), message.files === undefined ? null : (_jsx("div", { className: "mt-1.5", children: _jsx(FileList, { files: message.files, ...(onOpenFile === undefined
77
+ ? {}
78
+ : { onOpen: (file) => onOpenFile(file, message) }), ...(onDownloadFile === undefined
79
+ ? {}
80
+ : { onDownload: (file) => onDownloadFile(file, message) }) }) })), _jsxs("p", { className: "mt-1 text-micro text-muted", children: [_jsx("time", { dateTime: message.at.toISOString(), children: time }), message.pending === true ? ` · ${copy.chat.sending}` : null] })] }) }));
76
81
  }
@@ -1,3 +1,4 @@
1
+ import type { AttachmentFile } from "../attachments/files.js";
1
2
  export type ChatMessage = {
2
3
  id: string;
3
4
  /** Who wrote it, as the screen names them: «Ana Ruiz». */
@@ -9,6 +10,9 @@ export type ChatMessage = {
9
10
  mine?: boolean;
10
11
  /** Sent but not yet confirmed by the server. Said, never a silent success. */
11
12
  pending?: boolean;
13
+ /** The files it carries, drawn under the text as cards (`FileList`). A message may be
14
+ * only its files: then `body` is empty. One still uploading says so with its progress. */
15
+ files?: readonly AttachmentFile[];
12
16
  };
13
17
  export type DayGroup = {
14
18
  /** `YYYY-MM-DD` in local time: a stable key, and the day's identity. */
@@ -1,6 +1,8 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useFormIndexEntry } from "./FormIndex.js";
3
4
  import { byDensity, useDensity } from "../../foundations/density.js";
5
+ import { useFormStyle } from "../../foundations/form.js";
4
6
  import { Hint } from "../../primitives/hint/Hint.js";
5
7
  import { Tag } from "../../primitives/tag/Tag.js";
6
8
  /* ==================================================================== *
@@ -20,12 +22,21 @@ import { Tag } from "../../primitives/tag/Tag.js";
20
22
  * go into every aspect to discover it was empty. */
21
23
  export function FormSection({ title, hint, status, actions, columns = 1, children, }) {
22
24
  const d = useDensity();
25
+ const settings = useFormStyle() === "settings";
26
+ const indexed = useFormIndexEntry(settings ? title : undefined);
23
27
  const asGrid = columns > 1 && d === "comfortable";
24
28
  const grid = columns === 3 ? "grid-cols-3" : "grid-cols-2";
25
29
  const withHeader = title !== undefined ||
26
30
  status !== undefined ||
27
31
  hint !== undefined ||
28
32
  actions !== undefined;
33
+ if (settings) {
34
+ /* «settings»: the section is a card of rows, one under the other, a hairline between
35
+ them — `columns` does not apply, a row already has its two. Its help is written under
36
+ the title, like a field's under its label. `@container`: each row measures the card
37
+ to decide whether its label still fits beside the control (`grid-setting`). */
38
+ return (_jsxs("section", { ...(indexed === undefined ? {} : { id: indexed }), "data-ui": "form.section", className: "@container flex min-w-0 scroll-mt-3 flex-col gap-1 rounded-ui-card border border-ui-card-border bg-ui-card px-5 py-4", children: [withHeader ? (_jsxs("header", { className: "flex min-w-0 flex-wrap items-start gap-x-2.5 gap-y-1 pb-2", children: [title === undefined && hint === undefined ? null : (_jsxs("div", { className: "flex min-w-0 flex-col gap-0.5", children: [title === undefined ? null : (_jsx("h2", { className: "min-w-0 text-title font-semibold text-ink", children: title })), hint === undefined ? null : (_jsx("p", { className: "max-w-prose text-micro text-muted", children: hint }))] })), status === undefined ? null : _jsx(Tag, { tone: status.tone, children: status.label }), actions === undefined ? null : (_jsx("span", { className: "ml-auto flex shrink-0 items-center gap-1.5", children: actions }))] })) : null, _jsx("div", { className: "flex min-w-0 flex-col divide-y divide-line *:py-3.5 *:first:pt-0 *:last:pb-0", children: children })] }));
39
+ }
29
40
  return (_jsxs("section", { className: `flex min-w-0 flex-col ${byDensity(d, "gap-3", "gap-2")}`, children: [withHeader ? (_jsxs("header", { className: "flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-1", children: [title === undefined && hint === undefined ? null : (_jsxs("h3", { className: "flex min-w-0 items-center gap-1 text-meta font-medium text-ink", children: [title === undefined ? null : _jsx("span", { className: "min-w-0 truncate", children: title }), hint === undefined ? null : _jsx(Hint, { children: hint })] })), status === undefined ? null : _jsx(Tag, { tone: status.tone, children: status.label }), actions === undefined ? null : (_jsx("span", { className: "ml-auto flex shrink-0 items-center gap-1.5", children: actions }))] })) : null, _jsx("div", { className: `min-w-0 ${asGrid
30
41
  ? `grid ${grid} gap-x-8 ${byDensity(d, "gap-y-3.5", "gap-y-2.5")}`
31
42
  : `flex flex-col ${byDensity(d, "gap-3.5", "gap-2.5")}`}`, children: children })] }));
@@ -0,0 +1,11 @@
1
+ import { type ReactNode } from "react";
2
+ /** Where a form's sections register: the sheet of a «settings» form. */
3
+ export declare function FormIndexScope({ children }: {
4
+ children: ReactNode;
5
+ }): import("react").JSX.Element;
6
+ /** A section's place in the index: the id to give its element, or `undefined` when it is not
7
+ * listed — no title, or no index around it. */
8
+ export declare function useFormIndexEntry(title: string | undefined): string | undefined;
9
+ /** The index itself: the sections' titles, the current one marked, each bringing its
10
+ * section into view. Drawn by `Sheet` in the «settings» style. */
11
+ export declare function FormIndex(): import("react").JSX.Element | null;