@sincpro/web-ui 2.0.0 → 2.2.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 (143) hide show
  1. package/README.md +45 -0
  2. package/dist/components/activity/Activity.d.ts +13 -14
  3. package/dist/components/activity/Activity.js +1 -1
  4. package/dist/components/activity/Messages.d.ts +5 -5
  5. package/dist/components/activity/Messages.js +8 -8
  6. package/dist/components/attachments/Attachments.d.ts +7 -1
  7. package/dist/components/attachments/Attachments.js +8 -2
  8. package/dist/components/board/Board.d.ts +32 -2
  9. package/dist/components/board/Board.js +27 -4
  10. package/dist/components/board/index.d.ts +1 -1
  11. package/dist/components/board/index.js +2 -1
  12. package/dist/components/form/Form.js +6 -6
  13. package/dist/components/form/index.js +2 -2
  14. package/dist/components/frame/FrameView.d.ts +5 -5
  15. package/dist/components/frame/FrameView.js +4 -4
  16. package/dist/components/listing/GroupingLevels.d.ts +22 -22
  17. package/dist/components/listing/GroupingLevels.js +9 -9
  18. package/dist/components/listing/Listing.d.ts +11 -11
  19. package/dist/components/listing/Listing.js +11 -11
  20. package/dist/components/listing/ListingBar.js +11 -11
  21. package/dist/components/listing/Row.d.ts +19 -19
  22. package/dist/components/listing/Row.js +27 -27
  23. package/dist/components/listing/SortMenu.d.ts +36 -36
  24. package/dist/components/listing/SortMenu.js +6 -6
  25. package/dist/components/listing/grouping.d.ts +16 -16
  26. package/dist/components/listing/grouping.js +6 -6
  27. package/dist/components/listing/index.js +1 -1
  28. package/dist/components/listing/modelColumns.d.ts +25 -25
  29. package/dist/components/listing/modelColumns.js +24 -24
  30. package/dist/components/listing/pages.js +4 -4
  31. package/dist/components/listing/set.d.ts +18 -18
  32. package/dist/components/navigation/NavigationTree.js +2 -2
  33. package/dist/components/navigation/index.js +2 -2
  34. package/dist/components/record/RecordSkeleton.js +7 -7
  35. package/dist/components/search/CriteriaBuilder.d.ts +22 -22
  36. package/dist/components/search/CriteriaBuilder.js +31 -31
  37. package/dist/components/search/CriteriaChips.d.ts +9 -9
  38. package/dist/components/search/CriteriaChips.js +12 -12
  39. package/dist/components/search/FilterBuilder.d.ts +67 -67
  40. package/dist/components/search/FilterBuilder.js +104 -104
  41. package/dist/components/search/JoinWord.d.ts +1 -1
  42. package/dist/components/search/JoinWord.js +14 -14
  43. package/dist/components/search/JsonEditor.d.ts +8 -8
  44. package/dist/components/search/JsonEditor.js +16 -16
  45. package/dist/components/search/SearchBar.d.ts +34 -34
  46. package/dist/components/search/SearchBar.js +140 -117
  47. package/dist/components/search/criteria.d.ts +61 -61
  48. package/dist/components/search/criteria.js +39 -39
  49. package/dist/components/search/datePeriods.d.ts +47 -48
  50. package/dist/components/search/datePeriods.js +29 -29
  51. package/dist/components/search/dateRanges.d.ts +27 -27
  52. package/dist/components/search/dateRanges.js +16 -16
  53. package/dist/components/search/index.js +13 -13
  54. package/dist/components/search/model.d.ts +28 -28
  55. package/dist/components/search/model.js +21 -21
  56. package/dist/components/search/query.d.ts +71 -71
  57. package/dist/components/search/query.js +119 -119
  58. package/dist/components/shell/AppFrame.d.ts +9 -2
  59. package/dist/components/shell/AppFrame.js +102 -14
  60. package/dist/components/shell/Sidebar.d.ts +34 -0
  61. package/dist/components/shell/Sidebar.js +32 -0
  62. package/dist/components/shell/TopBar.d.ts +2 -0
  63. package/dist/components/shell/TopBar.js +13 -9
  64. package/dist/components/shell/index.d.ts +2 -0
  65. package/dist/components/shell/index.js +5 -1
  66. package/dist/components/shell/sidebarDrawer.d.ts +26 -0
  67. package/dist/components/shell/sidebarDrawer.js +22 -0
  68. package/dist/foundations/calendar.d.ts +27 -27
  69. package/dist/foundations/calendar.js +72 -72
  70. package/dist/foundations/chart.d.ts +57 -57
  71. package/dist/foundations/chart.js +27 -27
  72. package/dist/foundations/copy.d.ts +109 -94
  73. package/dist/foundations/copy.es.js +10 -2
  74. package/dist/foundations/copy.js +10 -2
  75. package/dist/foundations/grouping.d.ts +175 -175
  76. package/dist/foundations/grouping.js +0 -0
  77. package/dist/foundations/index.d.ts +1 -1
  78. package/dist/foundations/index.js +21 -21
  79. package/dist/foundations/pivot.d.ts +133 -131
  80. package/dist/foundations/pivot.js +54 -54
  81. package/dist/foundations/pivotSheet.d.ts +36 -36
  82. package/dist/foundations/pivotSheet.js +0 -0
  83. package/dist/foundations/slots.d.ts +38 -38
  84. package/dist/foundations/slots.js +18 -18
  85. package/dist/foundations/sticky.d.ts +28 -28
  86. package/dist/foundations/sticky.js +59 -59
  87. package/dist/foundations/xlsx.d.ts +47 -47
  88. package/dist/foundations/xlsx.js +0 -0
  89. package/dist/primitives/block/Line.d.ts +4 -4
  90. package/dist/primitives/block/Line.js +28 -28
  91. package/dist/primitives/block/index.js +2 -2
  92. package/dist/primitives/cell/index.js +2 -2
  93. package/dist/primitives/choice/index.js +3 -3
  94. package/dist/primitives/date/Calendar.d.ts +7 -1
  95. package/dist/primitives/date/Calendar.js +13 -3
  96. package/dist/primitives/date/DatePicker.d.ts +4 -1
  97. package/dist/primitives/date/DatePicker.js +2 -2
  98. package/dist/primitives/date/index.js +3 -3
  99. package/dist/primitives/disclosure/index.js +1 -1
  100. package/dist/primitives/field/DropZone.d.ts +22 -3
  101. package/dist/primitives/field/DropZone.js +33 -12
  102. package/dist/primitives/menu/Menu.d.ts +10 -6
  103. package/dist/primitives/menu/Menu.js +4 -3
  104. package/dist/primitives/notice/Callout.d.ts +30 -30
  105. package/dist/primitives/notice/Callout.js +6 -6
  106. package/dist/primitives/overlay/index.js +3 -3
  107. package/dist/primitives/picker/Picker.d.ts +6 -0
  108. package/dist/primitives/picker/Picker.js +27 -4
  109. package/dist/primitives/picker/index.js +2 -2
  110. package/dist/primitives/table/DataTable.d.ts +32 -32
  111. package/dist/primitives/table/DataTable.js +24 -24
  112. package/dist/primitives/table/EditableTable.d.ts +10 -10
  113. package/dist/primitives/table/EditableTable.js +9 -9
  114. package/dist/primitives/table/ReportTable.js +7 -7
  115. package/dist/primitives/table/SheetTable.d.ts +13 -13
  116. package/dist/primitives/table/SheetTable.js +14 -14
  117. package/dist/primitives/table/Table.js +8 -8
  118. package/dist/primitives/tabs/Tabs.d.ts +46 -46
  119. package/dist/primitives/tabs/Tabs.js +4 -30
  120. package/dist/primitives/tag/Count.d.ts +23 -0
  121. package/dist/primitives/tag/Count.js +59 -0
  122. package/dist/primitives/tag/index.d.ts +1 -0
  123. package/dist/primitives/tag/index.js +5 -2
  124. package/dist/primitives/toolbar/index.js +1 -1
  125. package/dist/primitives/value/Copyable.d.ts +22 -22
  126. package/dist/primitives/value/Copyable.js +9 -9
  127. package/dist/primitives/value/Metric.d.ts +7 -2
  128. package/dist/primitives/value/Metric.js +12 -4
  129. package/dist/tokens.css +164 -57
  130. package/dist/views/list/List.d.ts +36 -36
  131. package/dist/views/list/List.js +19 -19
  132. package/dist/views/list/ListView.js +74 -74
  133. package/dist/views/list/columns.d.ts +10 -10
  134. package/dist/views/list/columns.js +10 -10
  135. package/dist/views/list/derive.d.ts +30 -30
  136. package/dist/views/list/derive.js +49 -49
  137. package/dist/views/list/index.js +2 -2
  138. package/dist/views/list/presentations.js +3 -3
  139. package/dist/views/list/types.d.ts +109 -109
  140. package/dist/views/record/Record.d.ts +14 -14
  141. package/dist/views/record/Record.js +24 -24
  142. package/dist/views/record/index.js +1 -1
  143. package/package.json +1 -1
package/README.md CHANGED
@@ -131,6 +131,51 @@ a screen needs no change to work in both.
131
131
  </ThemeProvider>
132
132
  ```
133
133
 
134
+ #### Your brand
135
+
136
+ The colours a brand owns read a `--brand-*` variable before the system's value. Set them once,
137
+ on `:root`, and every palette — light, dark, and a light subtree inside a dark page — follows:
138
+
139
+ ```css
140
+ :root {
141
+ --brand-accent: #d4a73a; /* the primary action */
142
+ --brand-accent-hover: #c0942c;
143
+ --brand-primary: #1f3a6e; /* links, the current place */
144
+ --brand-primary-hover: #152a52;
145
+ --brand-chrome: #10203f; /* the application bar */
146
+ --brand-chrome-raised: #1a2c52;
147
+ --brand-chrome-edge: #10203f;
148
+
149
+ --brand-dark-accent: #e0b850; /* the same, for the dark palette */
150
+ --brand-dark-chrome: #0a1428;
151
+ }
152
+ ```
153
+
154
+ The full list is `accent`, `accent-hover`, `on-accent`, `primary`, `primary-hover`, `chrome`,
155
+ `chrome-raised`, `chrome-edge`, `chrome-accent` and `chrome-link`; `--brand-<token>` is the light
156
+ palette's and `--brand-dark-<token>` the dark's. One left unset keeps the system's value. Do not
157
+ override `--color-*` directly: those are redefined per theme, so an override on `:root` loses to
158
+ `[data-theme="light"]` and leaks into the dark palette. The system measures its own contrasts;
159
+ your brand's are checked by Storybook's a11y pass if you render your stories with it.
160
+
161
+ #### Living beside a site's own CSS
162
+
163
+ The package's styles are in cascade layers (`@layer base`, `utilities`), and **CSS outside any
164
+ layer always beats CSS inside one** — so a site's global `h1 { font-family: … }` restyles every
165
+ heading web-ui draws. Put the site's element rules in a layer too:
166
+
167
+ ```css
168
+ @layer base {
169
+ h1,
170
+ h2 {
171
+ font-family: var(--font-display);
172
+ }
173
+ }
174
+ ```
175
+
176
+ or scope them to the site's own pages (`.site h1`). Classes are not affected; element selectors
177
+ and `*` are.
178
+
134
179
  Rules a new token must follow: define it in **both** palettes with its contrast on the same line
135
180
  (`tests/tokens.test.ts` measures each theme against its own ground, surface and chrome, and fails
136
181
  if a light token has no dark twin or the two dark copies drift); the gold stays the primary
@@ -4,35 +4,34 @@ import { type CalloutProps } from "../../primitives/notice/Callout.js";
4
4
  import type { LucideIcon } from "lucide-react";
5
5
  import { type ReactNode } from "react";
6
6
  /**
7
- * Algo que el sistema anotó.
7
+ * Something the system noted.
8
8
  *
9
- * Deliberadamente NO es el evento del producto: lo que una historia necesita
10
- * para dibujar uno es qué pasó, cuándo, quién, y —cuando las hay— las tres cosas
11
- * que uno termina yendo a buscar a otro lado.
9
+ * Deliberately NOT the product's event: what a story needs to draw one is what happened,
10
+ * when, who, and —when they exist— the three things one ends up going elsewhere to look for.
12
11
  *
13
- * by QUIÉN. Ausente = lo hizo el sistema, que también es una respuesta.
14
- * moved DE QUÉ A QUÉ. «borrador → confirmado» se lee de una.
15
- * error QUÉ falló, entero y textual: quien mira esta pantalla muchas
16
- * veces no tiene acceso a los logs.
12
+ * by WHO. Absent = the system did it, which is also an answer.
13
+ * moved FROM WHAT TO WHAT. «borrador → confirmado» reads at a glance.
14
+ * error WHAT failed, whole and verbatim: whoever looks at this screen many
15
+ * times has no access to the logs.
17
16
  */
18
17
  export type ActivityEvent = {
19
18
  id: string;
20
- /** Qué pasó, en una oración y en pasado. */
19
+ /** What happened, in one sentence and in the past tense. */
21
20
  label: ReactNode;
22
21
  at: Date | string | number;
23
22
  tone?: Tone;
24
- /** Quién lo hizo. Ausente = el sistema. */
23
+ /** Who did it. Absent = the system. */
25
24
  by?: string;
26
- /** El cambio de estado, cuando lo hubo. `from` ausente = nació así. */
25
+ /** The change of state, when there was one. `from` absent = it was born like that. */
27
26
  moved?: {
28
27
  from?: string;
29
28
  to: string;
30
29
  };
31
- /** Lo que hay que saber además del título, cuando el título no alcanza. */
30
+ /** What one needs to know besides the title, when the title is not enough. */
32
31
  detail?: ReactNode;
33
- /** Lo que falló, textual. Se muestra la PRIMERA línea y el resto se abre. */
32
+ /** What failed, verbatim. The FIRST line is shown and the rest opens. */
34
33
  error?: string;
35
- /** El ícono del punto, cuando el rayo no dice lo suficiente. */
34
+ /** The dot's icon, when the bolt does not say enough. */
36
35
  icon?: LucideIcon;
37
36
  };
38
37
  /** A notice of the record, as the panel lists it: a `Callout` without its × label. */
@@ -90,7 +90,7 @@ function ErrorLine({ error }) {
90
90
  return (_jsxs("div", { className: "min-w-0 rounded-control border border-line bg-surface px-2 py-1", children: [_jsx("p", { className: `min-w-0 font-mono text-micro text-ink ${open ? "break-words whitespace-pre-wrap" : "truncate"}`, children: open ? error : first }), !more ? null : (_jsx("button", { type: "button", onClick: () => setOpen(!open), className: "mt-0.5 cursor-pointer text-micro text-muted underline-offset-2 hover:text-ink hover:underline", children: open ? copy.activity.less : copy.activity.more }))] }));
91
91
  }
92
92
  /**
93
- * UN EVENTO: a row that opens, not a line.
93
+ * AN EVENT: a row that opens, not a line.
94
94
  *
95
95
  * Closed it says what happened —in up to two lines, never cut to «se envió …»— and
96
96
  * under it who and when, in the quiet size. That second line is what made the narrow
@@ -48,12 +48,12 @@ export type MessageKind = {
48
48
  placeholder?: string;
49
49
  };
50
50
  /**
51
- * ESCRIBIR UNA NOTA, la manera que toda lista tiene.
51
+ * WRITE A NOTE, the way every list has.
52
52
  *
53
- * Es una función y no una constante porque sus palabras salen de la copia, y una
54
- * constante las congelaría con las que hubiera al cargar el módulo —o sea, las
55
- * de fábrica— por más que después se instale otra. Sin `copy`, las instaladas; un
56
- * componente le pasa las de su rama.
53
+ * It is a function and not a constant because its words come from the copy, and a
54
+ * constant would freeze them with whatever there was when the module loaded —that is, the
55
+ * factory ones— even if another is installed afterwards. Without `copy`, the installed ones; a
56
+ * component passes it those of its branch.
57
57
  */
58
58
  export declare function writeANote(copy?: UiCopy): MessageKind;
59
59
  export type MessageComposerProps = {
@@ -6,12 +6,12 @@ import { TextArea } from "../../primitives/field/Field.js";
6
6
  import { Send, Users, X } from "lucide-react";
7
7
  import { useState } from "react";
8
8
  /**
9
- * ESCRIBIR UNA NOTA, la manera que toda lista tiene.
9
+ * WRITE A NOTE, the way every list has.
10
10
  *
11
- * Es una función y no una constante porque sus palabras salen de la copia, y una
12
- * constante las congelaría con las que hubiera al cargar el módulo —o sea, las
13
- * de fábrica— por más que después se instale otra. Sin `copy`, las instaladas; un
14
- * componente le pasa las de su rama.
11
+ * It is a function and not a constant because its words come from the copy, and a
12
+ * constant would freeze them with whatever there was when the module loaded —that is, the
13
+ * factory ones— even if another is installed afterwards. Without `copy`, the installed ones; a
14
+ * component passes it those of its branch.
15
15
  */
16
16
  export function writeANote(copy = currentCopy()) {
17
17
  return {
@@ -23,9 +23,9 @@ export function writeANote(copy = currentCopy()) {
23
23
  }
24
24
  export function MessageComposer({ kinds, onSend, sending = false, footer, }) {
25
25
  const copy = useUiCopy();
26
- /* La manera por default se arma acá adentro y no en la firma: un default de
27
- parámetro se evalúa en cada render, sí, pero escrito como constante del
28
- módulo congelaría las palabras de fábrica. */
26
+ /* The default way is built in here and not in the signature: a parameter
27
+ default is evaluated on every render, yes, but written as a module
28
+ constant it would freeze the factory words. */
29
29
  const ways = kinds ?? [writeANote(copy)];
30
30
  const [writing, setWriting] = useState(undefined);
31
31
  const [body, setBody] = useState("");
@@ -42,6 +42,12 @@ export type AttachmentsProps = {
42
42
  onRetry?: (file: AttachmentFile) => void;
43
43
  /** The browser's `accept` list for the file dialog (`".pdf,image/*"`). */
44
44
  accept?: string;
45
+ /** Several files per drop or choice, in one `onAdd` — on by default: a record gathers
46
+ * scans and photos in batches. `false` takes one at a time. */
47
+ multiple?: boolean;
48
+ /** At most this many per batch (a gallery's 30 photos); the zone says how many it left
49
+ * out. */
50
+ max?: number;
45
51
  /** `read` for a record that can no longer change. By default, the form's mode. */
46
52
  mode?: FormMode;
47
53
  /** The accessible name of the list. «Adjuntos» by default. */
@@ -53,4 +59,4 @@ export type AttachmentsProps = {
53
59
  * text every minute. */
54
60
  now?: Date;
55
61
  };
56
- export declare function Attachments({ files, onAdd, onRemove, onRestore, onOpen, onRetry, accept, mode, label, empty, now, }: AttachmentsProps): import("react").JSX.Element;
62
+ export declare function Attachments({ files, onAdd, onRemove, onRestore, onOpen, onRetry, accept, multiple, max, mode, label, empty, now, }: AttachmentsProps): import("react").JSX.Element;
@@ -32,7 +32,7 @@ function Thumb({ file, kind }) {
32
32
  say it twice. */
33
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
34
  }
35
- export function Attachments({ files, onAdd, onRemove, onRestore, onOpen, onRetry, accept, mode, label, empty, now, }) {
35
+ export function Attachments({ files, onAdd, onRemove, onRestore, onOpen, onRetry, accept, multiple = true, max, mode, label, empty, now, }) {
36
36
  const copy = useUiCopy();
37
37
  const toast = useToastIfAny();
38
38
  const editable = useFormMode(mode) !== "read";
@@ -89,5 +89,11 @@ export function Attachments({ files, onAdd, onRemove, onRestore, onOpen, onRetry
89
89
  _jsxs("p", { id: detailId, role: "alert", className: "flex min-w-0 items-start gap-1.5 text-meta text-bad", children: [_jsx(TriangleAlert, { "aria-hidden": true, className: "mt-px size-(--size-icon-sm) shrink-0", strokeWidth: 2 }), _jsx("span", { className: "min-w-0", children: file.error ?? copy.attachments.failed })] })) : (_jsxs("p", { id: detailId, className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-meta text-muted", children: [file.size === undefined ? null : (_jsx("span", { className: "tabular-nums whitespace-nowrap", children: formatFileSize(file.size, copy.locale) })), file.by === undefined ? null : (_jsx(UserChip, { name: file.by, size: "sm", ...(file.byAvatar === undefined ? {} : { src: file.byAvatar }) })), file.at === undefined ? null : (_jsx(DateValue, { when: file.at, ...(now === undefined ? {} : { now }) }))] }))] }), _jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [status === "failed" && onRetry !== undefined ? (_jsx(Button, { role: "ghost", size: "sm", icon: RotateCcw, "aria-describedby": nameId, onClick: () => onRetry(file), children: copy.attachments.retry })) : null, status === "ready" && file.url !== undefined ? (_jsx(IconLink, { icon: Download, label: copy.attachments.download, href: file.url, download: file.name, tone: "normal", "aria-describedby": nameId })) : null, editable && onRemove !== undefined ? (_jsx(IconButton, { icon: status === "ready" ? Trash2 : X, label: status === "uploading"
90
90
  ? copy.attachments.cancelUpload
91
91
  : copy.attachments.remove, tone: status === "ready" ? "danger" : "normal", "data-attachment-remove": true, "aria-describedby": nameId, onClick: () => remove(file, index) })) : null] })] }, file.id));
92
- }) })), adding ? (_jsx(DropZone, { id: dropId, mode: "edit", label: files.length === 0 ? (empty ?? copy.attachments.emptyAdd) : copy.attachments.add, ...(accept === undefined ? {} : { accept }), onFile: (file) => onAdd([file]) })) : null] }));
92
+ }) })), adding ? (_jsx(DropZone, { id: dropId, mode: "edit", label: files.length === 0 ? (empty ?? copy.attachments.emptyAdd) : copy.attachments.add, ...(accept === undefined ? {} : { accept }), ...(multiple
93
+ ? {
94
+ multiple: true,
95
+ onFiles: onAdd,
96
+ ...(max === undefined ? {} : { max }),
97
+ }
98
+ : { onFile: (file) => onAdd([file]) }) })) : null] }));
93
99
  }
@@ -18,7 +18,31 @@ import type { ReactNode } from "react";
18
18
  *
19
19
  * It knows no domain and folds nothing: the application reads its data with the filters and
20
20
  * hands each tile what to draw — the same `Pivot` the list's chart and pivot read.
21
+ *
22
+ * ── Each tile reads on its own, and says so ─────────────────────────
23
+ *
24
+ * N tiles are N readings, and they land one at a time. A board that waited for all of them
25
+ * blanked the page for its slowest tile; one that drew nothing for a failed tile left a hole
26
+ * nobody could explain. So a tile takes its `state` — reading, ready, or failed with the
27
+ * server's refusal and a way to ask again — and draws it in ITS OWN space, the height of the
28
+ * chart it will hold (`--size-tile-body`), so a neighbour landing never moves the grid. The
29
+ * board's own `state` is the same for what the board reads as a whole: its headline numbers.
30
+ * The application (or web-framework's boards) decides each state; web-ui only draws it.
21
31
  */
32
+ /** What a tile — or the board's own headline reading — is doing. */
33
+ export type BoardState = {
34
+ status: "ready";
35
+ } | {
36
+ status: "loading";
37
+ } | {
38
+ status: "failed";
39
+ /** Why, in the server's words: the refusal, not «something went wrong». */
40
+ sentence: string;
41
+ /** The technical text — a status, an id — that «Copiar el error» carries. */
42
+ detail?: string;
43
+ /** Ask again. Present = the failure offers «Reintentar». */
44
+ onRetry?: () => void;
45
+ };
22
46
  export type BoardProps = {
23
47
  /** What the board is about: «Ventas». */
24
48
  title: string;
@@ -27,10 +51,13 @@ export type BoardProps = {
27
51
  filters?: ReactNode;
28
52
  /** The headline numbers — `Metrics` — read before the tiles. */
29
53
  metrics?: ReactNode;
54
+ /** What the board reads as a whole — its headline numbers. Reading, they are a quiet strip
55
+ * of their size; failed, the refusal takes their place. The tiles keep their own states. */
56
+ state?: BoardState;
30
57
  /** The tiles: `BoardTile`s. */
31
58
  children: ReactNode;
32
59
  };
33
- export declare function Board({ title, description, filters, metrics, children }: BoardProps): import("react").JSX.Element;
60
+ export declare function Board({ title, description, filters, metrics, state, children, }: BoardProps): import("react").JSX.Element;
34
61
  declare const SPAN: {
35
62
  readonly 1: "";
36
63
  readonly 2: "@3xl:col-span-2";
@@ -44,8 +71,11 @@ export type BoardTileProps = {
44
71
  actions?: ReactNode;
45
72
  /** How many columns it takes: a time series reads better wide. */
46
73
  span?: keyof typeof SPAN;
74
+ /** Reading, ready or failed. Not ready, the body is the state, the height of a chart; the
75
+ * title, its description and its actions stay. */
76
+ state?: BoardState;
47
77
  children: ReactNode;
48
78
  };
49
79
  /** One tile of a `Board`: a titled surface around a chart, a list or a number. */
50
- export declare function BoardTile({ title, description, actions, span, children, }: BoardTileProps): import("react").JSX.Element;
80
+ export declare function BoardTile({ title, description, actions, span, state, children, }: BoardTileProps): import("react").JSX.Element;
51
81
  export {};
@@ -1,8 +1,27 @@
1
+ "use client";
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- export function Board({ title, description, filters, metrics, children }) {
3
+ import { fillCopy, useUiCopy } from "../../foundations/copy.js";
4
+ import { Button } from "../../primitives/button/Button.js";
5
+ import { Failed } from "../../primitives/notice/Notice.js";
6
+ const READY = { status: "ready" };
7
+ function Failure({ heading, state, }) {
8
+ const copy = useUiCopy();
9
+ return (_jsx(Failed, { heading: heading, sentence: state.sentence, ...(state.detail === undefined ? {} : { detail: state.detail }), ...(state.onRetry === undefined
10
+ ? {}
11
+ : {
12
+ action: (_jsx(Button, { role: "secondary", size: "sm", onClick: state.onRetry, children: copy.failed.retry })),
13
+ }) }));
14
+ }
15
+ /** The headline numbers while the board reads them: the strip they will fill, quiet. */
16
+ function MetricsReading() {
17
+ const copy = useUiCopy();
18
+ return (_jsxs("div", { className: "flex min-w-0 animate-reveal-late flex-wrap gap-2", children: [_jsx("span", { className: "sr-only", children: copy.failed.loading }), [0, 1, 2].map((i) => (_jsx("span", { "aria-hidden": true, className: "h-(--size-metric) w-(--container-metric) rounded-box border border-line bg-ink/4" }, i)))] }));
19
+ }
20
+ export function Board({ title, description, filters, metrics, state = READY, children, }) {
21
+ const copy = useUiCopy();
3
22
  return (
4
23
  /* Its own gutter: a board is a page (or a whole panel), not a piece inside one. */
5
- _jsxs("div", { className: "@container flex min-w-0 flex-col gap-5 p-4 sm:p-6", children: [_jsxs("header", { className: "flex min-w-0 flex-wrap items-end justify-between gap-x-6 gap-y-3", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "text-display font-semibold text-ink", children: title }), description === undefined ? null : (_jsx("p", { className: "mt-1 text-body text-muted", children: description }))] }), filters === undefined ? null : (_jsx("div", { className: "flex min-w-0 flex-wrap items-end gap-3", children: filters }))] }), metrics, _jsx("div", { className: "grid min-w-0 grid-cols-1 gap-4 @3xl:grid-cols-2 @7xl:grid-cols-3", children: children })] }));
24
+ _jsxs("div", { className: "@container flex min-w-0 flex-col gap-5 p-4 sm:p-6", ...(state.status === "loading" ? { "aria-busy": true } : {}), children: [_jsxs("header", { className: "flex min-w-0 flex-wrap items-end justify-between gap-x-6 gap-y-3", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "text-display font-semibold text-ink", children: title }), description === undefined ? null : (_jsx("p", { className: "mt-1 text-body text-muted", children: description }))] }), filters === undefined ? null : (_jsx("div", { className: "flex min-w-0 flex-wrap items-end gap-3", children: filters }))] }), state.status === "loading" ? (_jsx(MetricsReading, {})) : state.status === "failed" ? (_jsx(Failure, { heading: copy.board.failed, state: state })) : (metrics), _jsx("div", { className: "grid min-w-0 grid-cols-1 gap-4 @3xl:grid-cols-2 @7xl:grid-cols-3", children: children })] }));
6
25
  }
7
26
  const SPAN = {
8
27
  1: "",
@@ -10,6 +29,10 @@ const SPAN = {
10
29
  full: "col-span-full",
11
30
  };
12
31
  /** One tile of a `Board`: a titled surface around a chart, a list or a number. */
13
- export function BoardTile({ title, description, actions, span = 1, children, }) {
14
- return (_jsxs("section", { "aria-label": title, className: `flex min-w-0 flex-col gap-4 rounded-box border border-line-strong bg-surface 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 }))] }), children] }));
32
+ export function BoardTile({ title, description, actions, span = 1, state = READY, children, }) {
33
+ const copy = useUiCopy();
34
+ return (_jsxs("section", { "aria-label": title, ...(state.status === "loading" ? { "aria-busy": true } : {}), className: `flex min-w-0 flex-col gap-4 rounded-box border border-line-strong bg-surface 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" ? (
35
+ /* A quiet block where the chart goes. It appears late, like every skeleton: a fast
36
+ read never shows it. */
37
+ _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)] }));
15
38
  }
@@ -1 +1 @@
1
- export { Board, type BoardProps, BoardTile, type BoardTileProps, } from "./Board.js";
1
+ export { Board, type BoardProps, type BoardState, BoardTile, type BoardTileProps, } from "./Board.js";
@@ -1,2 +1,3 @@
1
- /* A dashboard: one filter row, the headline numbers, and tiles over the same slice. */
1
+ /* A dashboard: one filter row, the headline numbers, and tiles over the same slice — each
2
+ tile reading on its own, with its loading and failed states. */
2
3
  export { Board, BoardTile, } from "./Board.js";
@@ -4,13 +4,13 @@ import { byDensity, useDensity } from "../../foundations/density.js";
4
4
  import { Hint } from "../../primitives/hint/Hint.js";
5
5
  import { Tag } from "../../primitives/tag/Tag.js";
6
6
  /* ==================================================================== *
7
- * LA COMPOSICIÓN DE UN FORMULARIO: la sección y el pie.
7
+ * THE COMPOSITION OF A FORM: the section and the footer.
8
8
  *
9
- * Vive en `contexts/form` y no junto a los controles porque no es un control:
10
- * es lo que los ACOMODA. `TextInput` no sabe que existe un formulario —se usa
11
- * igual adentro de una celda, de un filtro o de un diálogo— y una sección no
12
- * sabe qué campos le van a poner adentro. Son dos capas y por eso son dos
13
- * carpetas: `primitives/field` es CON QUÉ se escribe, esto es CÓMO se arma.
9
+ * It lives in `contexts/form` and not beside the controls because it is not a control:
10
+ * it is what ARRANGES them. `TextInput` does not know a form exists —it is used
11
+ * the same inside a cell, a filter or a dialog— and a section does not
12
+ * know which fields will be put inside it. They are two layers and so they are two
13
+ * folders: `primitives/field` is WITH WHAT you write, this is HOW it is put together.
14
14
  * ==================================================================== */
15
15
  /** A group of fields with its name and its status.
16
16
  *
@@ -1,4 +1,4 @@
1
- /* FORMULARIO — lo que ACOMODA los campos: la hoja, la sección y el pie. Los
2
- controles con los que se escribe están en `primitives/field`. */
1
+ /* FORM — what ARRANGES the fields: the sheet, the section and the footer. The
2
+ controls fields are written with live in `primitives/field`. */
3
3
  export { FormActions, FormSection } from "./Form.js";
4
4
  export { Sheet, SheetGroup, SheetGroups, } from "./Sheet.js";
@@ -21,12 +21,12 @@ export type FrameViewProps = {
21
21
  search?: ReactNode;
22
22
  pagination?: ReactNode;
23
23
  /**
24
- * El agrupado, con el mismo contrato que usa la lista.
24
+ * The grouping, with the same contract the list uses.
25
25
  *
26
- * Acá lo que se agrupa son ÍNDICES de fila y no registros: un marco es una
27
- * matriz y sus filas no tienen identidad propia —son la fila 12 del archivo—,
28
- * así que `T` es `number` y `of(fila, nivel)` lee la celda que corresponda. El
29
- * contrato no cambia, que es exactamente la prueba de que no es restrictivo.
26
+ * What is grouped here are row INDEXES and not records: a frame is a
27
+ * matrix and its rows have no identity of their own —they are row 12 of the file—,
28
+ * so `T` is `number` and `of(row, level)` reads the matching cell. The
29
+ * contract does not change, which is exactly the proof that it is not restrictive.
30
30
  */
31
31
  grouping?: Grouping<number>;
32
32
  };
@@ -47,10 +47,10 @@ export function FrameView({ frame, identity, caption, present: presentProp, pres
47
47
  const shown = useMemo(() => columns.visibleIds.length === frame.columns.length
48
48
  ? frame
49
49
  : withColumns(frame, columns.visibleIds), [frame, columns.visibleIds]);
50
- /* Los montones aplanados a una SECUENCIA: la planilla está virtualizada por
51
- índice, así que la jerarquía la dice la sangría de cada banda y no el
52
- anidamiento. Es el mismo aplanado que hace la lista, sobre índices en vez de
53
- registros. */
50
+ /* The heaps flattened into a SEQUENCE: the sheet is virtualised by
51
+ index, so the hierarchy is told by each band's indentation and not by
52
+ nesting. It is the same flattening the list does, over indexes instead of
53
+ records. */
54
54
  const bands = useMemo(() => {
55
55
  const piles = pilesOf(Array.from({ length: shown.rows }, (_, index) => index), grouping);
56
56
  if (piles === null)
@@ -2,38 +2,38 @@ import type { GroupingControl } from "./grouping.js";
2
2
  import { type PathPick } from "../search/FieldPath.js";
3
3
  import { type GroupableField, type GroupGrain } from "../../foundations/grouping.js";
4
4
  /**
5
- * «AGRUPAR POR», adentro del panel de recortes.
5
+ * «AGRUPAR POR», inside the cuts panel.
6
6
  *
7
- * Context: va en la MISMA columna donde están los filtros y los favoritos, y no
8
- * en un control aparte. Filtrar y agrupar son la misma pregunta —«qué parte de
9
- * esto estoy mirando»— y separarlos obliga a abrir dos cosas para armar un
10
- * recorte, sin poder ver los dos estados a la vez.
7
+ * Context: it goes in the SAME column where the filters and the favourites are, and not
8
+ * in a separate control. Filtering and grouping are the same question —«which part of
9
+ * this am I looking at»— and separating them forces you to open two things to build a
10
+ * cut, without being able to see both states at once.
11
11
  *
12
- * ── Una fecha se DESPLIEGA, no se elige ─────────────────────────────
12
+ * ── A date UNFOLDS, it is not chosen ───────────────────────────────
13
13
  *
14
- * Un campo común es una opción: se tilda y listo. Un campo de fecha no, porque
15
- * «agrupar por fecha» no quiere decir nada hasta decir con qué corte — y los
16
- * cortes no son excluyentes: «por mes y adentro por día» es una pregunta
17
- * legítima y frecuente. Así que una fecha se abre y ofrece sus granos como
18
- * CASILLAS, que se tildan de a varias.
14
+ * An ordinary field is an option: you tick it and that is it. A date field is not, because
15
+ * «group by date» means nothing until you say with what cut — and the
16
+ * cuts are not exclusive: «by month and inside it by day» is a
17
+ * legitimate and frequent question. So a date opens and offers its grains as
18
+ * CHECKBOXES, which are ticked several at a time.
19
19
  *
20
- * ── Y se ordenan solas ──────────────────────────────────────────────
20
+ * ── And they sort themselves ───────────────────────────────────────
21
21
  *
22
- * Tildar «día» y después «mes» da «mes › día», nunca al revés. No es una
23
- * preferencia: un día entero vive adentro de un solo mes, así que partir primero
24
- * por día deja un nivel de mes que no parte nada. La dirección la pone el
25
- * calendario y por eso la pone el sistema — ver `normalizeLevels`.
22
+ * Ticking «día» and then «mes» gives «mes › día», never the other way round. It is not
23
+ * a preference: a whole day lives inside a single month, so splitting first
24
+ * by day leaves a month level that splits nothing. The direction is set by the
25
+ * calendar and that is why the system sets it — see `normalizeLevels`.
26
26
  */
27
27
  export type GroupingLevelsProps = {
28
- /** Por qué campos se puede partir. Sin ninguno no se dibuja nada: una columna
29
- * vacía en el panel es peor que una columna que no está. */
28
+ /** Which fields it can be split by. With none nothing is drawn: an empty
29
+ * column in the panel is worse than a column that is not there. */
30
30
  fields: readonly GroupableField[];
31
31
  control: GroupingControl;
32
- /** Cómo se llama cada grano, cuando el producto lo dice con otras palabras.
33
- * Sin esto, las de la copia en el idioma activo. */
32
+ /** What each grain is called, when the product says it in other words.
33
+ * Without this, the copy's words in the active language. */
34
34
  grainLabel?: (grain: GroupGrain) => string;
35
- /** «Agrupar por otro campo»: un `FieldPath` que recorre relaciones («Cliente > País»).
36
- * Devuelve el camino; qué nivel se pone con él lo decide quien orquesta la pantalla. */
35
+ /** «Agrupar por otro campo»: a `FieldPath` that walks relations («Cliente > País»).
36
+ * It returns the path; which level is set with it is decided by whoever orchestrates the screen. */
37
37
  addPath?: PathPick;
38
38
  };
39
39
  export declare function GroupingLevels({ fields, control, grainLabel, addPath, }: GroupingLevelsProps): import("react").JSX.Element | null;
@@ -11,9 +11,9 @@ function fieldLabel(fields, field) {
11
11
  }
12
12
  export function GroupingLevels({ fields, control, grainLabel, addPath, }) {
13
13
  const copy = useUiCopy();
14
- /* Qué fechas están desplegadas. Arranca desplegada la que ya tenga algún grano
15
- puesto: si no, lo puesto queda escondido detrás de un chevron y hay que
16
- adivinar dónde. */
14
+ /* Which dates are unfolded. The one that already has some grain
15
+ set starts unfolded: otherwise what is set is hidden behind a chevron and you have to
16
+ guess where. */
17
17
  const [opened, setOpened] = useState(() => control.levels.filter((one) => one.grain !== undefined).map((one) => one.field));
18
18
  if (fields.length === 0 && addPath === undefined)
19
19
  return null;
@@ -23,12 +23,12 @@ export function GroupingLevels({ fields, control, grainLabel, addPath, }) {
23
23
  const toggleOpen = (field) => setOpened((current) => current.includes(field) ? current.filter((one) => one !== field) : [...current, field]);
24
24
  return (_jsxs("div", { className: "flex flex-col gap-0.5", children: [placed.length === 0 ? null : (_jsxs(_Fragment, { children: [_jsx("ol", { className: "flex flex-wrap gap-1 px-1 pb-1.5", children: placed.map((level, index) => (_jsx("li", { children: _jsxs("span", { className: "inline-flex items-center gap-1 rounded-pill border border-accent/40 bg-accent/18 py-0.5 pr-0.5 pl-1.5 text-micro text-ink", children: [_jsx("span", { className: "tabular-nums opacity-70", children: index + 1 }), _jsxs("span", { className: "max-w-32 truncate", children: [fieldLabel(fields, level.field), level.grain === undefined ? "" : ` · ${grain(level.grain)}`] }), _jsx("button", { type: "button", onClick: () => control.move(level.field, -1), disabled: index === 0, "aria-label": copy.grouping.up, title: copy.grouping.up, className: "rounded-pill p-0.5 hover:bg-primary/15 disabled:opacity-30 disabled:hover:bg-transparent", children: _jsx(ChevronUp, { className: "size-3", strokeWidth: 2.5 }) }), _jsx("button", { type: "button", onClick: () => control.move(level.field, 1), disabled: index === placed.length - 1, "aria-label": copy.grouping.down, title: copy.grouping.down, className: "rounded-pill p-0.5 hover:bg-primary/15 disabled:opacity-30 disabled:hover:bg-transparent", children: _jsx(ChevronDown, { className: "size-3", strokeWidth: 2.5 }) }), _jsx("button", { type: "button", onClick: () => control.remove(level.field, level.grain), "aria-label": copy.grouping.remove, title: copy.grouping.remove, className: "rounded-pill p-0.5 hover:bg-primary/15", children: _jsx(X, { className: "size-3", strokeWidth: 2.5 }) })] }) }, levelKey(level)))) }), _jsx("div", { className: "mb-1 h-px bg-line", role: "separator" })] })), fields.map((one) => {
25
25
  const grains = one.grains;
26
- /* Un campo común: una casilla y nada más. */
26
+ /* An ordinary field: a checkbox and nothing more. */
27
27
  if (grains === undefined || grains.length === 0) {
28
28
  const on = control.has(one.field);
29
29
  return (_jsxs("button", { type: "button", onClick: () => control.toggle(one.field), "aria-pressed": on, className: `flex items-center gap-2 rounded-control px-1.5 py-1 text-left transition-colors duration-(--duration-instant) hover:bg-primary/8 ${on ? "bg-primary/6" : ""}`, children: [_jsx(Mark, { on: on }), _jsx("span", { className: `min-w-0 truncate text-meta ${on ? "font-medium text-ink" : "text-ink"}`, children: one.label })] }, one.field));
30
30
  }
31
- /* Una FECHA: se despliega y ofrece sus cortes como casillas. */
31
+ /* A DATE: it unfolds and offers its cuts as checkboxes. */
32
32
  const open = isOpen(one.field);
33
33
  const puestos = placed.filter((level) => level.field === one.field);
34
34
  return (_jsxs("div", { className: "flex flex-col", children: [_jsxs("button", { type: "button", onClick: () => toggleOpen(one.field), "aria-expanded": open, className: "flex items-center gap-1.5 rounded-control px-1.5 py-1 text-left transition-colors duration-(--duration-instant) hover:bg-primary/8", children: [_jsx(ChevronRight, { className: `size-(--size-icon-sm) shrink-0 text-muted transition-transform duration-(--duration-instant) ${open ? "rotate-90" : ""}`, strokeWidth: 2, "aria-hidden": true }), _jsx("span", { className: `min-w-0 flex-1 truncate text-meta ${puestos.length > 0 ? "font-medium text-ink" : "text-ink"}`, children: one.label }), puestos.length === 0 ? null : (_jsx("span", { className: "inline-flex shrink-0 items-center rounded-pill border border-accent/40 bg-accent/18 px-2 py-0.5 text-micro tabular-nums text-ink", children: puestos.length }))] }), !open ? null : (_jsx("div", { className: "flex flex-col pl-(--spacing-indent)", children: GRAIN_ORDER.filter((g) => grains.includes(g)).map((g) => {
@@ -39,10 +39,10 @@ export function GroupingLevels({ fields, control, grainLabel, addPath, }) {
39
39
  ? {}
40
40
  : { followRelations: addPath.followRelations }), value: [], label: copy.fieldPath.addLevel, placeholder: copy.fieldPath.addLevel, onChange: addPath.onPick }) })), placed.length === 0 ? null : (_jsxs(_Fragment, { children: [_jsx("div", { className: "my-1 h-px bg-line", role: "separator" }), _jsx("button", { type: "button", onClick: () => control.clear(), className: "rounded-control px-2 py-1 text-left text-meta text-muted transition-colors duration-(--duration-instant) hover:bg-ink/4 hover:text-ink", children: copy.grouping.clear })] }))] }));
41
41
  }
42
- /** La marca de tildado. La columna existe SIEMPRE, tildada o no: sin ella,
43
- * tildar corre el texto y la lista salta. Apagada se dibuja el aro, la misma
44
- * marca que el panel de filtros, para que las dos columnas se lean como
45
- * casillas y no como texto suelto con un hueco a la izquierda. */
42
+ /** The tick mark. The column ALWAYS exists, ticked or not: without it,
43
+ * ticking shifts the text and the list jumps. When off, the ring is drawn, the same
44
+ * mark as the filters panel, so that both columns read as
45
+ * checkboxes and not as loose text with a gap on the left. */
46
46
  function Mark({ on }) {
47
47
  return (_jsx("span", { className: "flex size-(--size-icon-sm) shrink-0 items-center justify-center", children: on ? (_jsx("span", { className: "size-1.5 rounded-pill bg-primary" })) : (_jsx("span", { className: "size-3 rounded-pill border border-line-strong" })) }));
48
48
  }
@@ -4,20 +4,20 @@ export declare function Listing({ bar, metrics, sticky, surface, children, }: {
4
4
  /** The `ListingBar`: actions, title, search, pagination and views. */
5
5
  bar?: ReactNode;
6
6
  /**
7
- * La barra se queda arriba al scrollear, debajo de lo que ya esté pegado.
7
+ * The bar stays at the top on scroll, below whatever is already stuck.
8
8
  *
9
- * Es opt-in y no el default porque el fondo tiene que ser el de lo que hay
10
- * DETRÁS, y eso depende de dónde esté puesta: el arquetipo de lista vive
11
- * sobre el piso de la página, pero un `FrameView` —«el vistazo» de un
12
- * registro— vive sobre el PAPEL blanco, y ahí la banda color piso se ve como
13
- * una mancha. Se descubrió comparando historias, no razonando.
9
+ * It is opt-in and not the default because the background has to be that of what is
10
+ * BEHIND, and that depends on where it is placed: the list archetype lives
11
+ * on the page floor, but a `FrameView` —a record's «glance»— lives on the white
12
+ * PAPER, and there the floor-coloured band looks like a
13
+ * stain. It was discovered by comparing stories, not by reasoning.
14
14
  */
15
15
  sticky?: boolean;
16
- /** Sobre qué está puesta la lista. Sólo se usa para el fondo de la banda que
17
- * se pega: `chrome` pinta el mismo azul que ya pinta la barra —o sea,
18
- * invisible— y cualquier otra pinta el PISO, que es lo que hay detrás de una
19
- * lista de página. Las que viven adentro de algo blanco —un cajón, una vista
20
- * previa— son compactas, y en compacto la barra no se pega. */
16
+ /** What the list is placed on. It is used only for the background of the band that
17
+ * sticks: `chrome` paints the same blue the bar already paints —that is,
18
+ * invisible— and any other paints the FLOOR, which is what is behind a
19
+ * page list. Those living inside something white —a drawer, a preview—
20
+ * are compact, and in compact the bar does not stick. */
21
21
  surface?: Surface;
22
22
  /** The metrics that also narrow down. They go BELOW the bar and above the
23
23
  * rows: they belong to the set I am looking at, not to the frame that frames