@sincpro/web-ui 2.5.0 → 2.7.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 (52) hide show
  1. package/README.md +97 -7
  2. package/dist/components/activity/Activity.d.ts +8 -1
  3. package/dist/components/activity/Activity.js +9 -4
  4. package/dist/components/activity/Messages.d.ts +4 -0
  5. package/dist/components/attachments/Attachments.d.ts +1 -28
  6. package/dist/components/attachments/Attachments.js +5 -24
  7. package/dist/components/attachments/FileList.d.ts +28 -0
  8. package/dist/components/attachments/FileList.js +91 -0
  9. package/dist/components/attachments/FileThumb.d.ts +13 -0
  10. package/dist/components/attachments/FileThumb.js +34 -0
  11. package/dist/components/attachments/download.d.ts +9 -0
  12. package/dist/components/attachments/download.js +36 -0
  13. package/dist/components/attachments/files.d.ts +28 -0
  14. package/dist/components/attachments/index.d.ts +4 -2
  15. package/dist/components/attachments/index.js +4 -1
  16. package/dist/components/calendar/RecordCalendar.d.ts +2 -1
  17. package/dist/components/calendar/RecordCalendar.js +4 -1
  18. package/dist/components/calendar/calendar.css +37 -0
  19. package/dist/components/chat/ChatThread.d.ts +8 -1
  20. package/dist/components/chat/ChatThread.js +9 -4
  21. package/dist/components/chat/model.d.ts +4 -0
  22. package/dist/components/gantt/RecordGantt.d.ts +9 -1
  23. package/dist/components/gantt/RecordGantt.js +16 -3
  24. package/dist/components/gantt/gantt.css +52 -0
  25. package/dist/components/search/CriteriaBuilder.d.ts +11 -2
  26. package/dist/components/search/CriteriaBuilder.js +25 -6
  27. package/dist/components/search/FilterBuilder.d.ts +63 -5
  28. package/dist/components/search/FilterBuilder.js +346 -50
  29. package/dist/components/search/RuleValue.d.ts +17 -0
  30. package/dist/components/search/RuleValue.js +121 -0
  31. package/dist/components/search/SearchBar.d.ts +25 -2
  32. package/dist/components/search/SearchBar.js +360 -39
  33. package/dist/components/search/context.d.ts +45 -0
  34. package/dist/components/search/context.js +25 -0
  35. package/dist/components/search/criteria.d.ts +20 -0
  36. package/dist/components/search/index.d.ts +7 -4
  37. package/dist/components/search/index.js +9 -3
  38. package/dist/components/search/model.d.ts +16 -1
  39. package/dist/components/search/model.js +5 -0
  40. package/dist/components/search/query.d.ts +88 -4
  41. package/dist/components/search/query.js +262 -62
  42. package/dist/components/search/records.d.ts +68 -0
  43. package/dist/components/search/records.js +115 -0
  44. package/dist/foundations/copy.d.ts +27 -0
  45. package/dist/foundations/copy.es.js +15 -0
  46. package/dist/foundations/copy.js +15 -0
  47. package/dist/primitives/button/Button.d.ts +5 -1
  48. package/dist/primitives/button/Button.js +9 -2
  49. package/dist/primitives/value/Markdown.d.ts +1 -0
  50. package/dist/primitives/value/Markdown.js +1 -0
  51. package/dist/tokens.css +6 -85
  52. package/package.json +1 -1
package/README.md CHANGED
@@ -83,7 +83,7 @@ the tokens once — fonts, theme and Tailwind come with it:
83
83
  ```tsx
84
84
  import { Field, installCopy, SPANISH_COPY, TextInput } from "@sincpro/web-ui";
85
85
 
86
- installCopy(SPANISH_COPY); // optional: the interface in Spanish
86
+ installCopy(SPANISH_COPY); // optional: the interface in Spanish — once, where the app starts
87
87
 
88
88
  export function CompanyName({
89
89
  value,
@@ -103,10 +103,56 @@ export function CompanyName({
103
103
  Each level is also its own entry — `@sincpro/web-ui/foundations`, `/primitives`,
104
104
  `/components`, `/views` — so what a level offers is one import away.
105
105
 
106
- **React Server Components.** Every module that needs the browser (hooks, context, events)
107
- starts with `"use client"`, and a test keeps it that way; pure logic (calendar, pivot,
108
- criteria) stays callable from the server. The views are client components: compose
109
- `Record` inside a client component of your own.
106
+ **What your application ships.** Only what it uses: a `Button` alone is ~2.5 KB gzip, a form
107
+ ~74, a `Record` ~130, a `List` ~283 — React aside. The heavy pieces (calendar, Gantt, rich-text
108
+ and JSON editors, charts, PDF) load in their own chunk when they are drawn, and a library's
109
+ stylesheet comes with the component that draws it (the Gantt's alone is ~160 KB), not with
110
+ `tokens.css`. `tests/bundle.test.ts` holds those numbers. Your bundler only needs to handle a
111
+ CSS import from a dependency — Vite, webpack, Turbopack and Next.js do. Tests that load the
112
+ package in Node (Vitest's `node` environment) inline it so those imports go through Vite:
113
+ `test: { server: { deps: { inline: [/@sincpro\/web-ui/] } } }`.
114
+
115
+ ### Server rendering (Next.js)
116
+
117
+ It works as it is with the App Router and the Pages Router, under Turbopack and webpack.
118
+ `tokens.css` goes in your global stylesheet, with Tailwind's PostCSS plugin:
119
+
120
+ ```js
121
+ // postcss.config.mjs
122
+ export default { plugins: { "@tailwindcss/postcss": {} } };
123
+ ```
124
+
125
+ - **Server Components** may import from `@sincpro/web-ui`. Every module that needs the browser
126
+ (hooks, context, events) starts with `"use client"`, and a test keeps it that way; pure logic
127
+ (calendar, pivot, criteria) stays callable from the server. The views are client components:
128
+ compose `Record` or `List` inside a client component of your own.
129
+ - **The language.** `installCopy` sets the one global there is — and on a server, one process
130
+ renders every page and every request. Installed in one page, it leaks into the next page the
131
+ server renders, which the browser then draws in English: a hydration error. Install it in a
132
+ module EVERY page loads (your root layout's client providers), or — when the language changes
133
+ per user — give it with `UiCopyProvider`, which never writes the global:
134
+
135
+ ```tsx
136
+ // app/providers.tsx — rendered by app/layout.tsx around {children}
137
+ "use client";
138
+ import { SPANISH_COPY, UiCopyProvider } from "@sincpro/web-ui";
139
+
140
+ export function Providers({ children }: { children: React.ReactNode }) {
141
+ return <UiCopyProvider copy={SPANISH_COPY}>{children}</UiCopyProvider>;
142
+ }
143
+ ```
144
+
145
+ - **webpack** (`next build --webpack`): a Server Component that imports from the package root
146
+ makes webpack send the WHOLE library to the browser (~1.2 MB gzip for one `Button`). Let Next
147
+ rewrite those imports — Turbopack, the default, does not need it:
148
+
149
+ ```js
150
+ // next.config.mjs
151
+ export default { experimental: { optimizePackageImports: ["@sincpro/web-ui"] } };
152
+ ```
153
+
154
+ - What only a browser can draw is drawn there: the Gantt (SVAR paints its grid on a canvas)
155
+ renders its skeleton on the server and the chart after hydration.
110
156
 
111
157
  ### Theming (light / dark)
112
158
 
@@ -220,8 +266,9 @@ of classes that change with the next refactor:
220
266
 
221
267
  The parts: `button`, `icon-button`, `control`, `popover`, `menu`, `menu.trigger`,
222
268
  `menu.section`, `menu.item`, `menu.fold`, `dialog`, `block`, `record-card`, `board.tile`,
223
- `board.stat`, `board.stat.value`, `activity.changes`, `metric`, `metric.detail`, `tag`, `tags.item`, `search`, `search.field`, `search.chip`,
224
- `search.panel`, `search.suggestions`, `search-entry`, `search-entry.keys`, `table`,
269
+ `board.stat`, `board.stat.value`, `activity.changes`, `file-list`, `file-list.file`, `metric`, `metric.detail`, `tag`, `tags.item`, `search`, `search.field`, `search.chip`,
270
+ `search.panel`, `search.suggestions`, `search.suggestion`, `search.record`, `search.advanced`,
271
+ `search.keys`, `search-entry`, `search-entry.keys`, `table`,
225
272
  `table.head`, `topbar`, `topbar.brand`, `topbar.menus`, `topbar.actions`, `topbar.user`,
226
273
  `frame`, `frame.bar`, `frame.sidebar`, `frame.main`, `sidebar`, `sidebar.brand`,
227
274
  `sidebar.user`, `sidebar.search`, `sidebar.nav`, `sidebar.account`, `navigation`,
@@ -250,6 +297,49 @@ written out under it on the left, the control on the right —, every `FormSecti
250
297
  the rail. The layout (`stacked` / `horizontal`) is still the screen's: stacked, the help and the
251
298
  control go under the label. Without the provider nothing changes.
252
299
 
300
+ #### Searching the records of a relation — and extending the search
301
+
302
+ Typing «andres» in the bar offers «Cliente con «andres» ▸», and the ▸ (or →) unfolds the
303
+ CLIENTS that match — the way Odoo's «Search Contact for: …» does. Choosing one filters by that
304
+ record: what travels is its key, what reads is its name («Cliente: Andrés Pérez»), and a second
305
+ one lands in the same chip («… o Andrés Gutiérrez», sent as `in`). An enum unfolds into its
306
+ words («Pagada», sent as `paid`), and the builder asks the same way: «Cliente es [Andrés Pérez]»
307
+ with a picker, «está en» with tags, «está vacío» with nothing.
308
+
309
+ web-ui does not know where the records live. The application gives **one** search, by prop or
310
+ once for the whole app — web-framework wires it to the relation's literal search, the one a
311
+ many2one already asks:
312
+
313
+ ```tsx
314
+ const searchRecords: SearchRecords = ({ relation, path, text, keys, signal }) =>
315
+ keys !== undefined
316
+ ? api.names(relation, keys, { signal }) // name what a filter read back carries
317
+ : api.literalSearch(relation, text, { limit: 8, signal }); // what was typed
318
+
319
+ <SearchProvider searchRecords={searchRecords} valueEditor={myValueEditor}>
320
+ <App /> {/* every SearchBar, FilterBuilder and CriteriaBuilder inside */}
321
+ </SearchProvider>;
322
+ ```
323
+
324
+ `RecordOption.id` is what the relation compares: for a many2one, what its identifying column
325
+ (`identifiedBy`, its foreign key) holds; for a to-many relation, the key of the record on the
326
+ other side (`relationKey`, `id` by default) — the filter crosses it with `through`. An enum's
327
+ words come from `translations.choices`.
328
+
329
+ What can be extended, and how:
330
+
331
+ | You want | Use |
332
+ | ------------------------------------------------ | -------------------------------------------------------------------------------------------- |
333
+ | The records of a relation, from your server | `searchRecords` (prop, or `SearchProvider` once) |
334
+ | A record drawn your way in the dropdown | `SearchBar renderRecord` |
335
+ | «Buscar más…» under the records: your chooser | `SearchBar onBrowseRecords(field, text)` + `withValue` |
336
+ | A field's value drawn your way in the builder | `valueEditor` (prop or `SearchProvider`): answer `undefined` to keep ours |
337
+ | A list that opens filtered (defaults, a link) | `queryField` + `valuesCriteria` / `conditionCriteria` / `toggleNamed` |
338
+ | One more value into a chip, by code | `withValue(criteria, field, record)` |
339
+ | The filter said with names, for your own chip | `describeFilter(selection, model, modelAt, names)`, `FilterBuilder onApply(selection, said)` |
340
+ | Your own builder | `SelectionTree`, `RuleValue`, `liftRecords`, `recordsFilter`, `recordOps` |
341
+ | The words of an operator («no está establecido») | the copy table: `ops` |
342
+
253
343
  #### A guided tour: the screen says what each thing is
254
344
 
255
345
  `Guide` walks a person through a screen: the rest dims, the thing being explained is cut out,
@@ -1,4 +1,5 @@
1
1
  import type { Message } from "./Messages.js";
2
+ import type { AttachmentFile } from "../attachments/files.js";
2
3
  import type { Tone } from "../../foundations/types.js";
3
4
  import { type CalloutProps } from "../../primitives/notice/Callout.js";
4
5
  import type { LucideIcon } from "lucide-react";
@@ -75,8 +76,14 @@ export type ActivityProps = {
75
76
  /** The panel's name. «Actividad» by default. */
76
77
  label?: string;
77
78
  layout?: ActivityLayout;
79
+ /** Open a file a message carries. Present = its name is a button; WHERE it opens — a
80
+ * peek, a `FilePreview` — is the application's. */
81
+ onOpenFile?: (file: AttachmentFile, message: Message) => void;
82
+ /** Download a file a message carries by code (a token, a signed URL). Without it, a file
83
+ * with a `url` downloads by link. Busy while the promise runs; a rejection is said. */
84
+ onDownloadFile?: (file: AttachmentFile, message: Message) => void | Promise<unknown>;
78
85
  };
79
- export declare function Activity({ messages, events, alerts, alertsId: ownAlertsId, composer, open, onToggle, label: ownLabel, layout, }: ActivityProps): import("react").JSX.Element;
86
+ export declare function Activity({ messages, events, alerts, alertsId: ownAlertsId, composer, open, onToggle, label: ownLabel, layout, onOpenFile, onDownloadFile, }: ActivityProps): import("react").JSX.Element;
80
87
  /** Whether a standalone activity panel is open. Inside a `Record`, `Record.Activity`
81
88
  * keeps this state itself (open by default: on a big screen you see what the record has). */
82
89
  export declare function useActivity(initial?: boolean): {
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { FileList } from "../attachments/FileList.js";
3
4
  import { usePagination } from "../listing/pages.js";
4
5
  import { Pagination } from "../listing/Pagination.js";
5
6
  import { fillCopy, useUiCopy } from "../../foundations/copy.js";
@@ -71,10 +72,14 @@ function at(when) {
71
72
  /* The stream's two kinds of entry share one GEOMETRY: a 1.5rem disc (the face, or the
72
73
  event's node) on the left, the text beside it, the meta line under it. Two geometries
73
74
  in one list read as two lists glued together. */
74
- function MessageEntry({ message }) {
75
+ function MessageEntry({ message, onOpenFile, onDownloadFile, }) {
75
76
  const copy = useUiCopy();
76
77
  const internal = message.internal === true;
77
- return (_jsxs("li", { className: "flex min-w-0 gap-2.5 px-2 py-2", children: [_jsx(Avatar, { name: message.author, size: "md" }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [_jsxs("div", { className: "flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-0.5", children: [_jsx("span", { className: "truncate text-meta font-medium text-ink", children: message.author }), _jsx("span", { className: "text-micro text-muted", children: _jsx(DateValue, { when: message.at, format: "relative" }) }), internal ? (_jsxs("span", { className: "inline-flex items-center gap-1 text-micro text-muted", title: copy.activity.internalNote, children: [_jsx(Lock, { className: "size-3", "aria-hidden": true }), copy.activity.internal] })) : null] }), _jsx("p", { className: cn("max-w-(--container-prose) rounded-box px-2.5 py-1.5 text-body whitespace-pre-line text-ink", internal ? "border border-warn/35 bg-warn/6" : "bg-ground"), children: message.body })] })] }));
78
+ return (_jsxs("li", { className: "flex min-w-0 gap-2.5 px-2 py-2", children: [_jsx(Avatar, { name: message.author, size: "md" }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [_jsxs("div", { className: "flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-0.5", children: [_jsx("span", { className: "truncate text-meta font-medium text-ink", children: message.author }), _jsx("span", { className: "text-micro text-muted", children: _jsx(DateValue, { when: message.at, format: "relative" }) }), internal ? (_jsxs("span", { className: "inline-flex items-center gap-1 text-micro text-muted", title: copy.activity.internalNote, children: [_jsx(Lock, { className: "size-3", "aria-hidden": true }), copy.activity.internal] })) : null] }), message.body === "" ? null : (_jsx("p", { className: cn("max-w-(--container-prose) rounded-box px-2.5 py-1.5 text-body whitespace-pre-line text-ink", internal ? "border border-warn/35 bg-warn/6" : "bg-ground"), children: message.body })), message.files === undefined ? null : (_jsx(FileList, { files: message.files, ...(onOpenFile === undefined
79
+ ? {}
80
+ : { onOpen: (file) => onOpenFile(file, message) }), ...(onDownloadFile === undefined
81
+ ? {}
82
+ : { onDownload: (file) => onDownloadFile(file, message) }) }))] })] }));
78
83
  }
79
84
  /** The change of state: from what to what. The old one quiet, the new one in ink. */
80
85
  const STATE_CHIP = "inline-flex max-w-32 min-w-0 items-center truncate rounded-pill border border-line-strong bg-ink/5 px-2 py-0.5 text-micro";
@@ -177,7 +182,7 @@ const TONE_TEXT = {
177
182
  info: "text-info",
178
183
  good: "text-good",
179
184
  };
180
- export function Activity({ messages, events, alerts = [], alertsId: ownAlertsId, composer, open, onToggle, label: ownLabel, layout = "auto", }) {
185
+ export function Activity({ messages, events, alerts = [], alertsId: ownAlertsId, composer, open, onToggle, label: ownLabel, layout = "auto", onOpenFile, onDownloadFile, }) {
181
186
  const copy = useUiCopy();
182
187
  const label = ownLabel ?? copy.activity.title;
183
188
  const titleId = useId();
@@ -300,7 +305,7 @@ export function Activity({ messages, events, alerts = [], alertsId: ownAlertsId,
300
305
  _jsxs("li", { "aria-hidden": true, className: "flex items-center gap-2 px-1 pt-2 pb-1 text-micro font-medium text-muted first:pt-0", children: [_jsx("span", { className: "first-letter:uppercase", children: dayLabel(day, copy.locale, {
301
306
  today: copy.activity.today,
302
307
  yesterday: copy.activity.yesterday,
303
- }) }), _jsx("span", { className: "h-px flex-1 bg-line" })] })) : null, entry.kind === "message" ? (_jsx(MessageEntry, { message: entry.message })) : (_jsx(EventEntry, { event: entry.event }))] }, entry.id));
308
+ }) }), _jsx("span", { className: "h-px flex-1 bg-line" })] })) : null, entry.kind === "message" ? (_jsx(MessageEntry, { message: entry.message, onOpenFile: onOpenFile, onDownloadFile: onDownloadFile })) : (_jsx(EventEntry, { event: entry.event }))] }, entry.id));
304
309
  }) }), kept.length <= 20 ? null : _jsx(Pagination, { ...pages.bridge })] }))] })] }));
305
310
  }
306
311
  /** Whether a standalone activity panel is open. Inside a `Record`, `Record.Activity`
@@ -1,3 +1,4 @@
1
+ import type { AttachmentFile } from "../attachments/files.js";
1
2
  import { type UiCopy } from "../../foundations/copy.js";
2
3
  import { type ReactNode } from "react";
3
4
  /**
@@ -33,6 +34,9 @@ export type Message = {
33
34
  body: string;
34
35
  /** An internal note: it stays inside. Drawn differently on purpose. */
35
36
  internal?: boolean;
37
+ /** What it carries — the receipt, the signed contract —, drawn under the text as cards
38
+ * (`FileList`). A message may be only its files: then `body` is empty. */
39
+ files?: readonly AttachmentFile[];
36
40
  };
37
41
  /** A way of writing. `note` stays inside; everything else leaves, and what
38
42
  * changes between them is only the channel and who is on the other side. */
@@ -1,32 +1,5 @@
1
+ import { type AttachmentFile } from "./files.js";
1
2
  import { type FormMode } from "../../foundations/form.js";
2
- export type AttachmentStatus = "ready" | "uploading" | "failed";
3
- export type AttachmentFile = {
4
- /** The attachment's identity: the server's id, or a local key while it uploads. */
5
- id: string;
6
- /** The file name as it was saved: «Factura proveedor 0418.pdf». */
7
- name: string;
8
- /** In bytes. Written in the copy's locale: «1,2 MB». */
9
- size?: number;
10
- /** The MIME type, when the server knows it. With the name, it picks the icon. */
11
- type?: string;
12
- /** Where it downloads from. Absent = no download (still uploading, or not allowed). */
13
- url?: string;
14
- /** A small image for the thumbnail. Defaults to `url` for an image — pass a smaller one
15
- * when the server has it, so a list of 4 MB photos does not load 4 MB photos. */
16
- thumbnail?: string;
17
- /** Who added it. */
18
- by?: string;
19
- /** Their face, for the chip. */
20
- byAvatar?: string;
21
- /** When it was added. */
22
- at?: Date | string | number;
23
- /** `ready` by default. The application owns it: it is what the upload is really doing. */
24
- status?: AttachmentStatus;
25
- /** 0 to 100 while `uploading`. Absent = under way without a figure yet. */
26
- progress?: number;
27
- /** Why it `failed`, in the server's words. */
28
- error?: string;
29
- };
30
3
  export type AttachmentsProps = {
31
4
  files: readonly AttachmentFile[];
32
5
  /** Files to add: dropped, pasted or chosen. Present = the drop zone is drawn (in edit
@@ -1,6 +1,7 @@
1
1
  "use client";
2
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { attachmentKind, fileExtension, formatFileSize, } from "./files.js";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { attachmentKind, formatFileSize, } from "./files.js";
4
+ import { FileThumb } from "./FileThumb.js";
4
5
  import { fillCopy, useUiCopy } from "../../foundations/copy.js";
5
6
  import { useFormMode } from "../../foundations/form.js";
6
7
  import { Button, IconButton, IconLink } from "../../primitives/button/Button.js";
@@ -10,28 +11,8 @@ import { useToastIfAny } from "../../primitives/notice/Toast.js";
10
11
  import { DateValue } from "../../primitives/value/DateValue.js";
11
12
  import { UserChip } from "../../primitives/value/Person.js";
12
13
  import { ProgressBar } from "../../primitives/value/ProgressBar.js";
13
- import { Download, File, FileImage, FileSpreadsheet, FileText, FileType, RotateCcw, Trash2, TriangleAlert, X, } from "lucide-react";
14
+ import { Download, RotateCcw, Trash2, TriangleAlert, X } from "lucide-react";
14
15
  import { useEffect, useId, useRef } from "react";
15
- const KIND_ICON = {
16
- image: FileImage,
17
- pdf: FileText,
18
- sheet: FileSpreadsheet,
19
- doc: FileType,
20
- other: File,
21
- };
22
- /** The type, at the size of a row: the image itself when there is one, otherwise the icon
23
- * of its kind over its extension. The extension is written because three of the five
24
- * icons are a page with lines on it — «PDF» and «DOCX» are what tell them apart, and a
25
- * word is never a colour that only some people see. */
26
- function Thumb({ file, kind }) {
27
- const picture = kind === "image" && file.status !== "failed" ? (file.thumbnail ?? file.url) : undefined;
28
- const Icon = KIND_ICON[kind];
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
- }
35
16
  export function Attachments({ files, onAdd, onRemove, onRestore, onOpen, onRetry, accept, multiple = true, max, mode, label, empty, now, }) {
36
17
  const copy = useUiCopy();
37
18
  const toast = useToastIfAny();
@@ -84,7 +65,7 @@ export function Attachments({ files, onAdd, onRemove, onRestore, onOpen, onRetry
84
65
  const nameId = `${base}-${index}-name`;
85
66
  const detailId = `${base}-${index}-detail`;
86
67
  const kind = attachmentKind(file.name, file.type);
87
- return (_jsxs("li", { "data-attachment-id": file.id, "data-status": status, className: "flex min-w-0 items-center gap-3 py-2", children: [_jsx(Thumb, { file: file, kind: kind }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [onOpen === undefined || status !== "ready" ? (_jsx("span", { id: nameId, title: file.name, className: "max-w-full truncate text-body font-medium text-ink", children: file.name })) : (_jsx("button", { type: "button", id: nameId, title: file.name, "data-attachment-name": true, "aria-describedby": detailId, onClick: () => onOpen(file), className: "max-w-full cursor-pointer truncate rounded-control text-left text-body font-medium text-ink outline-primary outline-offset-2 hover:underline hover:underline-offset-4 focus-visible:outline-2 forced-colors:outline-[Highlight]", children: file.name })), status === "uploading" ? (_jsx("div", { className: "w-full", children: _jsx(ProgressBar, { label: fillCopy(copy.attachments.uploading, { name: file.name }), width: "w-full", ...(file.progress === undefined ? {} : { value: file.progress }) }) })) : status === "failed" ? (
68
+ return (_jsxs("li", { "data-attachment-id": file.id, "data-status": status, className: "flex min-w-0 items-center gap-3 py-2", children: [_jsx(FileThumb, { file: file, kind: kind }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [onOpen === undefined || status !== "ready" ? (_jsx("span", { id: nameId, title: file.name, className: "max-w-full truncate text-body font-medium text-ink", children: file.name })) : (_jsx("button", { type: "button", id: nameId, title: file.name, "data-attachment-name": true, "aria-describedby": detailId, onClick: () => onOpen(file), className: "max-w-full cursor-pointer truncate rounded-control text-left text-body font-medium text-ink outline-primary outline-offset-2 hover:underline hover:underline-offset-4 focus-visible:outline-2 forced-colors:outline-[Highlight]", children: file.name })), status === "uploading" ? (_jsx("div", { className: "w-full", children: _jsx(ProgressBar, { label: fillCopy(copy.attachments.uploading, { name: file.name }), width: "w-full", ...(file.progress === undefined ? {} : { value: file.progress }) }) })) : status === "failed" ? (
88
69
  /* The icon AND the words: red alone is a colour some people do not see. */
89
70
  _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
71
  ? copy.attachments.cancelUpload
@@ -0,0 +1,28 @@
1
+ import { type AttachmentFile } from "./files.js";
2
+ export type FileListLayout = "cards" | "rows";
3
+ export type FileListProps = {
4
+ files: readonly AttachmentFile[];
5
+ /** `cards` (default): a file someone sent, under a message. `rows`: the files of
6
+ * something, in a bordered list. */
7
+ layout?: FileListLayout;
8
+ /** What these files are — «Assets», «Comprobantes» —, drawn with their count. Without it
9
+ * the list is named by `label`. */
10
+ title?: string;
11
+ /** The title folds the list (it needs a `title`). Open by default; `defaultOpen={false}`
12
+ * starts it folded. */
13
+ collapsible?: boolean;
14
+ defaultOpen?: boolean;
15
+ /** Open the file. Present = its name is a button; WHERE it opens is the application's. */
16
+ onOpen?: (file: AttachmentFile) => void;
17
+ /** Download by code. Present = every ready file has a download button that calls it,
18
+ * busy while its promise runs. Without it, a file with a `url` downloads by link. */
19
+ onDownload?: (file: AttachmentFile) => void | Promise<unknown>;
20
+ /** «Download all», shown when there are two or more files. */
21
+ onDownloadAll?: (files: readonly AttachmentFile[]) => void | Promise<unknown>;
22
+ /** The accessible name when there is no `title`. «Archivos» by default. */
23
+ label?: string;
24
+ /** The «now» the dates are relative to — so a story or a test does not change its text
25
+ * every minute. */
26
+ now?: Date;
27
+ };
28
+ export declare function FileList({ files, layout, title, collapsible, defaultOpen, onOpen, onDownload, onDownloadAll, label, now, }: FileListProps): import("react").JSX.Element | null;
@@ -0,0 +1,91 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { attachmentKind, fileExtension, formatFileSize, } from "./files.js";
4
+ import { FileThumb } from "./FileThumb.js";
5
+ import { fillCopy, useUiCopy } from "../../foundations/copy.js";
6
+ import { Button, IconButton, IconLink } from "../../primitives/button/Button.js";
7
+ import { Disclosure } from "../../primitives/disclosure/Disclosure.js";
8
+ import { DateValue } from "../../primitives/value/DateValue.js";
9
+ import { ProgressBar } from "../../primitives/value/ProgressBar.js";
10
+ import { Download, TriangleAlert } from "lucide-react";
11
+ import { useId, useState } from "react";
12
+ const add = (marks, id) => new Set(marks).add(id);
13
+ const drop = (marks, id) => {
14
+ const next = new Set(marks);
15
+ next.delete(id);
16
+ return next;
17
+ };
18
+ /* The ring every name shares, as a button or as a link. */
19
+ const NAME = "max-w-full cursor-pointer truncate rounded-control text-left font-medium text-ink outline-primary outline-offset-2 hover:underline hover:underline-offset-4 focus-visible:outline-2 forced-colors:outline-[Highlight]";
20
+ export function FileList({ files, layout = "cards", title, collapsible = false, defaultOpen = true, onOpen, onDownload, onDownloadAll, label, now, }) {
21
+ const copy = useUiCopy();
22
+ const base = useId();
23
+ const titleId = `${base}-title`;
24
+ const [pending, setPending] = useState(() => new Set());
25
+ const [failed, setFailed] = useState(() => new Set());
26
+ const [allPending, setAllPending] = useState(false);
27
+ const [allFailed, setAllFailed] = useState(false);
28
+ if (files.length === 0)
29
+ return null;
30
+ const download = async (file) => {
31
+ if (onDownload === undefined)
32
+ return;
33
+ setFailed((marks) => drop(marks, file.id));
34
+ setPending((marks) => add(marks, file.id));
35
+ try {
36
+ await onDownload(file);
37
+ }
38
+ catch {
39
+ setFailed((marks) => add(marks, file.id));
40
+ }
41
+ finally {
42
+ setPending((marks) => drop(marks, file.id));
43
+ }
44
+ };
45
+ const downloadAll = async () => {
46
+ if (onDownloadAll === undefined)
47
+ return;
48
+ setAllFailed(false);
49
+ setAllPending(true);
50
+ try {
51
+ await onDownloadAll(files);
52
+ }
53
+ catch {
54
+ setAllFailed(true);
55
+ }
56
+ finally {
57
+ setAllPending(false);
58
+ }
59
+ };
60
+ const cards = layout === "cards";
61
+ const list = (_jsx("ul", { ...(title === undefined
62
+ ? { "aria-label": label ?? copy.attachments.files }
63
+ : { "aria-labelledby": titleId }), className: cards
64
+ ? "flex min-w-0 flex-wrap gap-2"
65
+ : "flex min-w-0 flex-col divide-y divide-line rounded-box border border-line bg-surface", children: files.map((file, index) => {
66
+ const status = file.status ?? "ready";
67
+ const ready = status === "ready";
68
+ const nameId = `${base}-${index}-name`;
69
+ const kind = attachmentKind(file.name, file.type);
70
+ const busy = pending.has(file.id);
71
+ const extension = fileExtension(file.name).toUpperCase();
72
+ const name = ready && onOpen !== undefined ? (_jsx("button", { type: "button", id: nameId, title: file.name, onClick: () => onOpen(file), className: NAME, children: file.name })) : ready && file.url !== undefined && onDownload === undefined ? (_jsx("a", { id: nameId, href: file.url, download: file.name, title: file.name, className: NAME, children: file.name })) : (_jsx("span", { id: nameId, title: file.name, className: "max-w-full truncate font-medium text-ink", children: file.name }));
73
+ /* What the file is, or what is happening to it — in words: red alone is a colour some
74
+ people do not see. */
75
+ const detail = status === "uploading" ? (_jsx(ProgressBar, { label: fillCopy(copy.attachments.uploading, { name: file.name }), width: "w-full", ...(file.progress === undefined ? {} : { value: file.progress }) })) : status === "failed" || failed.has(file.id) ? (_jsxs("span", { role: "alert", className: "flex min-w-0 items-start gap-1.5 text-micro text-bad", children: [_jsx(TriangleAlert, { "aria-hidden": true, className: "mt-px size-(--size-icon-sm) shrink-0" }), _jsx("span", { className: "min-w-0", children: status === "failed"
76
+ ? (file.error ?? copy.attachments.failed)
77
+ : fillCopy(copy.attachments.downloadFailed, { name: file.name }) })] })) : (_jsxs("span", { className: "flex min-w-0 flex-wrap items-center gap-x-2 text-micro text-muted tabular-nums", children: [cards && extension !== "" ? _jsx("span", { children: extension }) : null, cards && extension !== "" && file.size !== undefined ? (_jsx("span", { "aria-hidden": true, children: "\u00B7" })) : null, file.size === undefined ? null : (_jsx("span", { className: "whitespace-nowrap", children: formatFileSize(file.size, copy.locale) })), !cards && file.at !== undefined ? (_jsx(DateValue, { when: file.at, ...(now === undefined ? {} : { now }) })) : null] }));
78
+ const action = !ready ? null : onDownload !== undefined ? (_jsx(IconButton, { icon: Download, label: copy.attachments.download, busy: busy, "aria-describedby": nameId, onClick: () => void download(file) })) : file.url !== undefined ? (_jsx(IconLink, { icon: Download, label: copy.attachments.download, href: file.url, download: file.name, tone: "normal", "aria-describedby": nameId })) : null;
79
+ return (_jsxs("li", { "data-ui": "file-list.file", "data-status": status, className: cards
80
+ ? "flex w-full max-w-sm min-w-0 items-center gap-3 rounded-box border border-line bg-surface p-2"
81
+ : "flex min-w-0 items-center gap-3 px-3 py-2", children: [_jsx(FileThumb, { file: file, kind: kind, size: cards ? "md" : "sm" }), cards ? (_jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5 text-meta", children: [name, detail] })) : (_jsxs("div", { className: "flex min-w-0 flex-1 flex-wrap items-center justify-between gap-x-3 gap-y-0.5 text-body", children: [name, detail] })), action] }, file.id));
82
+ }) }));
83
+ const all = onDownloadAll !== undefined && files.length > 1 ? (_jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-2", children: [_jsx(Button, { role: "ghost", size: "sm", icon: Download, busy: allPending, onClick: () => void downloadAll(), children: copy.attachments.downloadAll }), allFailed ? (_jsx("span", { role: "alert", className: "text-micro text-bad", children: fillCopy(copy.attachments.downloadFailed, {
84
+ name: title ?? copy.attachments.files,
85
+ }) })) : null] })) : null;
86
+ const count = (_jsx("span", { className: "rounded-pill bg-ink/6 px-1.5 text-micro font-medium text-muted tabular-nums", children: files.length }));
87
+ if (title !== undefined && collapsible) {
88
+ return (_jsx("div", { "data-ui": "file-list", "data-layout": layout, className: "min-w-0", children: _jsx(Disclosure, { title: _jsxs("span", { id: titleId, className: "inline-flex items-center gap-2", children: [title, count] }), defaultExpanded: defaultOpen, children: _jsxs("div", { className: "flex min-w-0 flex-col gap-2", children: [list, all] }) }) }));
89
+ }
90
+ return (_jsxs("div", { "data-ui": "file-list", "data-layout": layout, className: "flex min-w-0 flex-col gap-2", children: [title === undefined ? null : (_jsxs("p", { id: titleId, className: "flex items-center gap-2 text-meta font-medium text-ink", children: [title, count] })), list, all] }));
91
+ }
@@ -0,0 +1,13 @@
1
+ import { type AttachmentFile, type AttachmentKind } from "./files.js";
2
+ /** The type, at the size of a row: the image itself when there is one, otherwise the icon
3
+ * of its kind over its extension. The extension is written because three of the five
4
+ * icons are a page with lines on it — «PDF» and «DOCX» are what tell them apart, and a
5
+ * word is never a colour that only some people see.
6
+ *
7
+ * `sm` is the icon alone, for a line of text (a list of a release's assets): the name next
8
+ * to it already ends in its extension. */
9
+ export declare function FileThumb({ file, kind, size, }: {
10
+ file: AttachmentFile;
11
+ kind: AttachmentKind;
12
+ size?: "sm" | "md";
13
+ }): import("react").JSX.Element;
@@ -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,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