@sincpro/web-ui 2.8.0 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +152 -3
  2. package/dist/components/activity/Activity.js +3 -2
  3. package/dist/components/board/Board.d.ts +2 -1
  4. package/dist/components/board/Board.js +17 -1
  5. package/dist/components/form/Form.js +12 -3
  6. package/dist/components/form/FormIndex.d.ts +5 -1
  7. package/dist/components/form/FormIndex.js +71 -23
  8. package/dist/components/form/Sheet.js +22 -4
  9. package/dist/components/listing/ListingBar.d.ts +25 -1
  10. package/dist/components/listing/ListingBar.js +43 -14
  11. package/dist/components/listing/Pagination.d.ts +4 -1
  12. package/dist/components/listing/Pagination.js +19 -6
  13. package/dist/components/listing/modelCells.js +1 -9
  14. package/dist/components/record/ActionDock.d.ts +58 -0
  15. package/dist/components/record/ActionDock.js +69 -0
  16. package/dist/components/record/Breadcrumb.d.ts +3 -1
  17. package/dist/components/record/Breadcrumb.js +13 -5
  18. package/dist/components/record/DirtyActions.js +11 -1
  19. package/dist/components/record/Pager.d.ts +12 -10
  20. package/dist/components/record/Pager.js +39 -6
  21. package/dist/components/record/RecordHeader.d.ts +13 -1
  22. package/dist/components/record/RecordHeader.js +70 -25
  23. package/dist/components/record/SmartButtons.js +2 -2
  24. package/dist/components/record/StatusBar.d.ts +68 -1
  25. package/dist/components/record/StatusBar.js +218 -48
  26. package/dist/components/record/dock.d.ts +56 -0
  27. package/dist/components/record/dock.js +58 -0
  28. package/dist/components/record/index.d.ts +3 -1
  29. package/dist/components/record/index.js +5 -1
  30. package/dist/foundations/copy.d.ts +9 -0
  31. package/dist/foundations/copy.es.js +10 -1
  32. package/dist/foundations/copy.js +5 -0
  33. package/dist/foundations/form.d.ts +10 -1
  34. package/dist/foundations/grouping.d.ts +9 -0
  35. package/dist/foundations/index.d.ts +3 -1
  36. package/dist/foundations/index.js +8 -2
  37. package/dist/foundations/keys.d.ts +34 -0
  38. package/dist/foundations/keys.js +99 -0
  39. package/dist/foundations/shortcut.d.ts +17 -1
  40. package/dist/foundations/shortcut.js +57 -1
  41. package/dist/foundations/viewStyle.d.ts +8 -0
  42. package/dist/foundations/viewStyle.js +12 -0
  43. package/dist/primitives/choice/Switch.d.ts +4 -1
  44. package/dist/primitives/choice/Switch.js +2 -2
  45. package/dist/primitives/menu/Menu.d.ts +3 -0
  46. package/dist/primitives/menu/Menu.js +7 -1
  47. package/dist/primitives/table/DataTable.d.ts +29 -0
  48. package/dist/primitives/table/DataTable.js +84 -13
  49. package/dist/primitives/table/EditableTable.js +7 -2
  50. package/dist/primitives/table/RowActions.d.ts +5 -0
  51. package/dist/primitives/table/RowActions.js +27 -3
  52. package/dist/primitives/table/SheetTable.d.ts +3 -0
  53. package/dist/primitives/table/SheetTable.js +15 -2
  54. package/dist/primitives/table/index.d.ts +1 -1
  55. package/dist/primitives/value/Value.d.ts +5 -1
  56. package/dist/primitives/value/Value.js +9 -3
  57. package/dist/primitives/value/YesNo.d.ts +22 -0
  58. package/dist/primitives/value/YesNo.js +16 -0
  59. package/dist/primitives/value/index.d.ts +1 -0
  60. package/dist/primitives/value/index.js +1 -0
  61. package/dist/tokens.css +35 -2
  62. package/dist/views/list/List.d.ts +7 -2
  63. package/dist/views/list/List.js +12 -4
  64. package/dist/views/list/ListView.d.ts +1 -1
  65. package/dist/views/list/ListView.js +112 -17
  66. package/dist/views/list/derive.d.ts +1 -1
  67. package/dist/views/list/derive.js +45 -9
  68. package/dist/views/list/presentations.d.ts +2 -2
  69. package/dist/views/list/presentations.js +35 -3
  70. package/dist/views/list/types.d.ts +43 -0
  71. package/dist/views/list/useReachBottom.d.ts +15 -0
  72. package/dist/views/list/useReachBottom.js +55 -0
  73. package/dist/views/record/Record.d.ts +16 -2
  74. package/dist/views/record/Record.js +30 -7
  75. package/package.json +1 -1
package/README.md CHANGED
@@ -268,12 +268,12 @@ The parts: `button`, `icon-button`, `control`, `popover`, `menu`, `menu.trigger`
268
268
  `menu.section`, `menu.item`, `menu.fold`, `dialog`, `block`, `record-card`, `board.tile`,
269
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
270
  `search.panel`, `search.suggestions`, `search.suggestion`, `search.record`, `search.advanced`,
271
- `search.keys`, `search-entry`, `search-entry.keys`, `table`,
272
- `table.head`, `topbar`, `topbar.brand`, `topbar.menus`, `topbar.actions`, `topbar.user`,
271
+ `search.keys`, `search-entry`, `search-entry.keys`, `table`, `table.pile`, `yes-no`,
272
+ `table.head`, `row.ways`, `topbar`, `topbar.brand`, `topbar.menus`, `topbar.actions`, `topbar.user`,
273
273
  `frame`, `frame.bar`, `frame.sidebar`, `frame.main`, `sidebar`, `sidebar.brand`,
274
274
  `sidebar.user`, `sidebar.search`, `sidebar.nav`, `sidebar.account`, `navigation`,
275
275
  `navigation.item`, `dirty.blocked`, `dirty.bar`, `field`, `field.label`, `form.section`,
276
- `form.index`, `guide`, `guide.veil`, `guide.spot`, `guide.card`,
276
+ `form.index`, `dock`, `dock.pill`, `dock.bare`, `pager`, `pagination`, `smart`, `guide`, `guide.veil`, `guide.spot`, `guide.card`,
277
277
  `guide.progress`, `guide.title`, `guide.body`, `guide.actions`. A part that is one of many
278
278
  carries `data-key` too (`navigation.item`). Put your rules in a cascade layer above web-ui's, or
279
279
  outside any layer.
@@ -297,6 +297,21 @@ written out under it on the left, the control on the right —, every `FormSecti
297
297
  the rail. The layout (`stacked` / `horizontal`) is still the screen's: stacked, the help and the
298
298
  control go under the label. Without the provider nothing changes.
299
299
 
300
+ #### A dense record found by its index: the «sections» style
301
+
302
+ `FormStyleProvider value="sections"` keeps the ERP's density and takes the settings' shape:
303
+ every `SheetGroup` on the paper and every notebook page (`Record.Page`) is a card on the
304
+ ground, listed in the index at the left (sticky under the application bar, marking the one
305
+ being read), and inside each card the dense grid stays — label | value, two or three columns,
306
+ a group inside a card stays a titled group. The notebook's pages are not tabs any more: a long
307
+ record is read top to bottom and found by its index, nothing hidden behind a tab. Save and
308
+ Discard float as in settings, and the activity stands apart. Pair it with the modern style:
309
+ `5 · Plantillas/Registros/Ficha de contacto › En secciones`.
310
+
311
+ A table's TITLE column (the card's title on a phone: `stack: "title"`, or the first column)
312
+ keeps `--size-cell-title` (14 rem): a product name cut with «…» asks for no width of its own,
313
+ and beside figures with a width it was squeezed to «Imp…».
314
+
300
315
  #### Searching the records of a relation — and extending the search
301
316
 
302
317
  Typing «andres» in the bar offers «Cliente con «andres» ▸», and the ▸ (or →) unfolds the
@@ -354,6 +369,140 @@ What can be extended, and how:
354
369
  | Your own builder | `SelectionTree`, `RuleValue`, `liftRecords`, `recordsFilter`, `recordOps` |
355
370
  | The words of an operator («no está establecido») | the copy table: `ops` |
356
371
 
372
+ #### A group says what it adds up to, under each column
373
+
374
+ A table grouped by a field draws each pile's row like Odoo's grouped list: its name, how many,
375
+ and under every column that declared an `aggregate` what the pile adds up to — written like
376
+ the footer («185.200,50», «máx 5»). Whoever counts the piles (the server's grouped read) sends
377
+ the sums in `Pile.totals`, by column id; without them the table sums the rows when the pile
378
+ holds all of them — the sum of one page of a pile of thousands looks like its total and is
379
+ not. The sheet's bands and the report built from the piles say the same numbers: in the report
380
+ every pile is a group with its amounts, and a «Total» line closes it.
381
+
382
+ A column's numbers are written ONE way, in its cells, its piles and its footer: its `format`,
383
+ else its `decimals` (`DataColumn.decimals`, `SheetColumn.decimals`): `2` writes «6.057,10»
384
+ under «8.370,57», not «6.057,1».
385
+
386
+ #### The direction: the modern style (`ViewStyleProvider`)
387
+
388
+ **Modern is Sincpro's own style, and where the system is going.** It is not a trial: it is how
389
+ new screens are drawn, and it keeps being iterated — small things that help, one round at a
390
+ time. `traditional` stays, for good — same API, same data —: it is how business software is
391
+ done (Odoo's way), and the applications already drawn in it keep it. The API both styles read
392
+ (settled in #68): `ViewStyleProvider` / `Record look`; `Record.Dock` (`rail` | `bottom`);
393
+ `List.Dock` (`placement`, `selectionPlacement`, the pill named by the list); `List openTargets`
394
+
395
+ - `onOpenIn`; `DataColumn.yesNo`; `Pagination look` / `Pager look`; `StatusBar look`. What the
396
+ direction is:
397
+
398
+ * **The page breathes on the ground.** No white band on top of the paper: the trail IS the
399
+ page's heading (`Breadcrumb size="lg"`), and a step down, what the record has (the
400
+ counters, boxes) and where it is at (the state).
401
+ * **One floating pill holds the actions** — at the bottom of the screen, centred, under the
402
+ thumb —: a record's, a settings form's, and a list's, named by the list it acts on
403
+ («Pedidos │ Importar · Nueva cotización») so one action is never a lone button. It turns into
404
+ «N cambios · Descartar · Guardar» while there are changes, and into what is done to the chosen
405
+ rows while some are chosen. One per screen: a collection's chosen rows take the record's
406
+ place.
407
+ * **Pills are the shape of the identity**: the actions' pill, the pager (a translucent primary
408
+ pill), the state as a pill of pills (`StatusBar look="segmented"`), the row's ways in.
409
+ * **Colour means something**: the gold is the one action that moves the record forward; the
410
+ translucent primary, where you are; red, what undoes.
411
+ * **The keyboard reaches everything**: every action can carry its shortcut, drawn for the
412
+ person's keyboard (see below).
413
+ * **A number reads the same everywhere**: its column's decimals and format in the cells, the
414
+ groups, the footer and the report.
415
+
416
+ Already in the direction: dense records in sections with an index (`FormStyleProvider
417
+ value="sections"`, below) and the state on a phone (`display="auto"`). Next: the rest of the
418
+ screens taking the floating pill, and the phone's pill when an action does not fit.
419
+
420
+ A record and a list are written once — `Record.Dock` and `List.Dock` with their actions as
421
+ data — and the application's style decides how they are drawn, the way it chooses its density:
422
+
423
+ ```tsx
424
+ // "traditional" is the default; a single Record can say its own with `look`.
425
+ <ViewStyleProvider value="modern">
426
+ <App />
427
+ </ViewStyleProvider>
428
+ ```
429
+
430
+ - **traditional**: the ERP rail — a band with the trail, the counters and the pager; the
431
+ actions as the bar's buttons (the primary first and gold, «⋯» with the rest), in a record
432
+ and in a list alike.
433
+ - **modern**: the trail is the page's heading with the pager as a translucent primary pill on
434
+ its line (`Pager look="pill"`); a step down, the counters (boxes) and the state; the band is
435
+ the ground; and the actions float in ONE pill at the bottom of the screen, centred — a
436
+ record's, and a list's named by the list (`List.Dock placement="bar"` keeps a list's in its
437
+ header). Two things were tried and dropped: a pill resting in the rail and floating at the
438
+ TOP, and the counters as links.
439
+
440
+ **The state.** `StatusBar look`: `track` (Odoo's — the traditional style's), `segmented` (a
441
+ pill of pills, the actions' shape — the modern style's), `steps`, `progress` and `pill` (one chip that unfolds the stages). Each
442
+ stage can carry an `icon`, an `activeIcon` (worn when it is the current or the chosen one:
443
+ ○ → ◉), a `hint` (said when pointed at) and a `count` (how many are there, in a list grouped by
444
+ stage). `display` says what a stage shows — `auto` (the default: every name where there is
445
+ room, on a phone only the current one's), `both`, `label`, `icon` (the name said to a screen
446
+ reader and on hover) or `current` (the icons, and the current stage's name) —, and
447
+ `renderStage` draws a stage your way inside the system's segment, which keeps the order, the
448
+ paint, the focus and the names. `Record.Status look` picks one; all side by side in
449
+ `3 · Componentes/Registro/Riel, estado y contadores`.
450
+
451
+ #### Keyboard shortcuts that run
452
+
453
+ A combination is written once — `"Alt+D"`, `"Mod+S"` (⌘ on a Mac, Ctrl elsewhere) — and is
454
+ pressed, drawn and announced for the person's keyboard (`foundations/keys`: «⌥D» / «Alt+D»,
455
+ `aria-keyshortcuts`). It RUNS while the piece that declares it is on screen, and declarations
456
+ stack: the record in a peek over the page answers, not the page under it.
457
+
458
+ - `DockAction.shortcut` — any action, a sub-action or one waiting in «Más» included.
459
+ - `Record.Pager` / `Pager keys` — Alt+P and Alt+N by default (Odoo's), `false` for none.
460
+ - Save answers Mod+S wherever it is (`DirtyActions`).
461
+ - Your own: `useShortcuts([{ keys: "Alt+K", run, enabled }])`, and `useKeysHint(keys)` to draw
462
+ it.
463
+
464
+ A combination with a modifier works while a field is being typed in; a bare key does not.
465
+
466
+ #### The record's actions floating (`Record.Dock`)
467
+
468
+ The «settings» style floats Save and Discard in a dark pill; `Record.Dock` tries that pill for
469
+ ALL of a record's actions. In place of `Record.Actions`, the actions are written as data, and the
470
+ pill decides what is seen: the primary, gold and last; `visible` secondary ones (one with
471
+ sub-actions is a menu button, «Imprimir ▾»); the rest in «Más ⋯», sub-actions as submenus, what
472
+ undoes apart and last, in red. Where it goes is `placement`: `rail` (the traditional buttons),
473
+ `bottom` (the modern default, floating centred) or `top` (resting in the rail, a layer of the
474
+ sticky stack once it scrolls away); while there are changes the same pill holds «N cambios ·
475
+ Descartar · Guardar».
476
+
477
+ ```tsx
478
+ <Record.Rail>
479
+ <Record.Crumbs crumbs={…} />
480
+ <Record.Dock
481
+ label="Acciones de la factura"
482
+ actions={[
483
+ { id: "pay", label: "Registrar pago", icon: CreditCard, primary: true, onSelect: pay },
484
+ { id: "send", label: "Enviar", icon: Send, onSelect: send },
485
+ { id: "print", label: "Imprimir", icon: Printer, items: [
486
+ { id: "print-invoice", label: "Factura", shortcut: "Mod+P", onSelect: printInvoice },
487
+ { id: "print-note", label: "Remito", onSelect: printNote },
488
+ ] },
489
+ { id: "copy", label: "Duplicar", icon: Copy, shortcut: "Alt+D", onSelect: duplicate },
490
+ { id: "void", label: "Anular en el SIAT", icon: Ban, danger: true, onSelect: voidIt },
491
+ ]}
492
+ // placement="rail" | "bottom" | "top", align="center" | "end", look="chrome" | "canvas", visible={2}
493
+ />
494
+ <Record.Status stages={…} current="posted" />
495
+ </Record.Rail>
496
+ ```
497
+
498
+ A list says the same with `List.Dock` — `actions` (what it starts) and `selection` (what is
499
+ done to the chosen rows). `placement` is `bar` (the bar's buttons; the chosen rows' in place of
500
+ the search) or `bottom` (ONE floating pill, the chosen rows' while some are chosen); absent,
501
+ the view style decides. `selectionPlacement` overrides where the chosen rows' actions go.
502
+
503
+ `ActionDock` is the pill alone (`placement="inline"`, or sticky `top` / `bottom` anywhere, with
504
+ a `lead` before the actions) and `dockPlan` the rule, for a screen that is neither.
505
+
357
506
  #### A guided tour: the screen says what each thing is
358
507
 
359
508
  `Guide` walks a person through a screen: the rest dims, the thing being explained is cut out,
@@ -190,8 +190,9 @@ export function Activity({ messages, events, alerts = [], alertsId: ownAlertsId,
190
190
  const alertsId = ownAlertsId ?? autoAlertsId;
191
191
  const auto = layout === "auto";
192
192
  /* Beside the sheet it is joined to it — the sheet's right edge is the line between the two.
193
- In the «settings» form style there is no sheet, only cards on the ground: it stands apart. */
194
- const joined = useFormStyle() !== "settings";
193
+ In the «settings» and «sections» form styles there is no sheet, only cards on the ground:
194
+ it stands apart. */
195
+ const joined = useFormStyle() === "dense";
195
196
  /* The notes of the fields and rows of the record around — `Record` keeps them. */
196
197
  const notes = useNoteEntries();
197
198
  const byTime = (items) => [...items].sort((x, y) => at(y.at) - at(x.at));
@@ -118,7 +118,8 @@ export type BoardStatProps = {
118
118
  change?: MetricProps["change"];
119
119
  /** The last periods, oldest first: drawn as a sparkline beside the figure. */
120
120
  trend?: readonly (number | null)[];
121
- /** The ONE figure the board leads with: the hero step (≥ 48 px). At most one per board. */
121
+ /** The ONE figure the board leads with: the hero step (≥ 48 px) in a tile that holds it
122
+ * (≥ 20 rem), the figure step in a narrower one. At most one per board. */
122
123
  hero?: boolean;
123
124
  /**
124
125
  * The STATE of the reading, never decoration: a share of clean mail under its floor is
@@ -89,7 +89,23 @@ export function BoardStat({ label, value, icon, hint, detail, change, trend, her
89
89
  ? value.toLocaleString(copy.locale)
90
90
  : value;
91
91
  const shade = tone === undefined ? "" : TONE[tone].tile;
92
- return (_jsxs("section", { "aria-label": label, ...(loading ? { "aria-busy": true } : {}), "data-ui": "board.stat", ...(tone === undefined ? {} : { "data-tone": tone }), className: `flex min-w-0 flex-col gap-3 p-5 ${TILE} ${shade} ${span === 2 ? "@xl:col-span-2" : ""}`, children: [_jsx(TileHeading, { title: label, icon: icon, hint: hint, tone: tone, size: "label" }), state.status === "failed" ? (_jsx(Failure, { heading: fillCopy(copy.board.tileFailed, { title: label }), state: state })) : (_jsxs("div", { className: "flex min-w-0 items-end justify-between gap-4", children: [_jsxs("div", { className: "flex min-w-0 flex-col gap-1", children: [loading ? (_jsx("span", { "aria-hidden": true, className: `inline-block w-24 animate-reveal-late rounded-control bg-ink/8 ${hero ? "h-(--text-hero)" : "h-(--text-figure)"}` })) : (_jsx("span", { "data-ui": "board.stat.value", className: `min-w-0 truncate font-semibold text-ink ${hero ? "text-hero" : "text-figure"} ${missing ? "text-muted" : ""}`, children: figure })), loading ? _jsx("span", { className: "sr-only", children: copy.failed.loading }) : null, loading || (detail === undefined && change === undefined) ? null : (_jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5", children: [change === undefined ? null : (_jsx(MetricChange, { change: change, format: percent.format })), detail === undefined ? null : (_jsx("span", { className: "min-w-0 truncate text-micro text-muted", children: detail }))] }))] }), loading || trend === undefined ? null : (_jsx("div", { className: "w-2/5 max-w-40 shrink-0 pb-1", children: _jsx(Sparkline, { values: trend, label: label }) }))] }))] }));
92
+ return (_jsxs("section", { "aria-label": label, ...(loading ? { "aria-busy": true } : {}), "data-ui": "board.stat", ...(tone === undefined ? {} : { "data-tone": tone }),
93
+ /* Its own container: the lead figure's step is the tile's width, not the window's. */
94
+ className: `@container flex min-w-0 flex-col gap-3 p-5 ${TILE} ${shade} ${span === 2 ? "@xl:col-span-2" : ""}`, children: [_jsx(TileHeading, { title: label, icon: icon, hint: hint, tone: tone, size: "label" }), state.status === "failed" ? (_jsx(Failure, { heading: fillCopy(copy.board.tileFailed, { title: label }), state: state })) : (
95
+ /* The figure first: when it and its trend do not fit side by side the trend goes under
96
+ it (wraps), and the lead figure (`hero`) takes its big step only in a tile that holds
97
+ it (≥ 20 rem) — the number the tile exists for is never the part that is cut. Only a
98
+ figure wider than its tile alone truncates. */
99
+ _jsxs("div", { className: "flex min-w-0 flex-wrap items-end justify-between gap-x-4 gap-y-2", children: [_jsxs("div", { className: "flex min-w-0 flex-col gap-1", children: [loading ? (_jsx("span", { "aria-hidden": true, className: `inline-block w-24 animate-reveal-late rounded-control bg-ink/8 ${hero ? "h-(--text-figure) @xs:h-(--text-hero)" : "h-(--text-figure)"}` })) : (_jsx("span", { "data-ui": "board.stat.value",
100
+ /* Sized to fit its tile (`figure-fit`): a long figure steps down instead of
101
+ being cut. The title step is the floor — past it, «…» and the whole figure
102
+ in the title, the last resort for a tile narrower than any number. */
103
+ title: typeof figure === "string" ? figure : undefined, style: {
104
+ ...(typeof figure === "string"
105
+ ? { "--figure-length": figure.length }
106
+ : {}),
107
+ ...(hero ? { "--figure-step": "var(--text-hero)" } : {}),
108
+ }, className: `figure-fit min-w-0 truncate font-semibold text-ink ${missing ? "text-muted" : ""}`, children: figure })), loading ? _jsx("span", { className: "sr-only", children: copy.failed.loading }) : null, loading || (detail === undefined && change === undefined) ? null : (_jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5", children: [change === undefined ? null : (_jsx(MetricChange, { change: change, format: percent.format })), detail === undefined ? null : (_jsx("span", { className: "min-w-0 truncate text-micro text-muted", children: detail }))] }))] }), loading || trend === undefined ? null : (_jsx("div", { className: "w-2/5 max-w-40 shrink-0 pb-1", children: _jsx(Sparkline, { values: trend, label: label }) }))] }))] }));
93
109
  }
94
110
  /**
95
111
  * The row of a board's stat tiles: as wide as the grid under it, every tile the same width —
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useFormIndexEntry } from "./FormIndex.js";
3
+ import { InCardScope, useFormIndexEntry } from "./FormIndex.js";
4
4
  import { byDensity, useDensity } from "../../foundations/density.js";
5
5
  import { useFormStyle } from "../../foundations/form.js";
6
6
  import { Hint } from "../../primitives/hint/Hint.js";
@@ -22,8 +22,10 @@ import { Tag } from "../../primitives/tag/Tag.js";
22
22
  * go into every aspect to discover it was empty. */
23
23
  export function FormSection({ title, hint, status, actions, columns = 1, children, }) {
24
24
  const d = useDensity();
25
- const settings = useFormStyle() === "settings";
26
- const indexed = useFormIndexEntry(settings ? title : undefined);
25
+ const style = useFormStyle();
26
+ const settings = style === "settings";
27
+ const sections = style === "sections";
28
+ const indexed = useFormIndexEntry(settings || sections ? title : undefined);
27
29
  const asGrid = columns > 1 && d === "comfortable";
28
30
  const grid = columns === 3 ? "grid-cols-3" : "grid-cols-2";
29
31
  const withHeader = title !== undefined ||
@@ -37,6 +39,13 @@ export function FormSection({ title, hint, status, actions, columns = 1, childre
37
39
  to decide whether its label still fits beside the control (`grid-setting`). */
38
40
  return (_jsxs("section", { ...(indexed === undefined ? {} : { id: indexed }), "data-ui": "form.section", className: "@container flex min-w-0 scroll-mt-3 flex-col gap-1 rounded-ui-card border border-ui-card-border bg-ui-card px-5 py-4", children: [withHeader ? (_jsxs("header", { className: "flex min-w-0 flex-wrap items-start gap-x-2.5 gap-y-1 pb-2", children: [title === undefined && hint === undefined ? null : (_jsxs("div", { className: "flex min-w-0 flex-col gap-0.5", children: [title === undefined ? null : (_jsx("h2", { className: "min-w-0 text-title font-semibold text-ink", children: title })), hint === undefined ? null : (_jsx("p", { className: "max-w-prose text-micro text-muted", children: hint }))] })), status === undefined ? null : _jsx(Tag, { tone: status.tone, children: status.label }), actions === undefined ? null : (_jsx("span", { className: "ml-auto flex shrink-0 items-center gap-1.5", children: actions }))] })) : null, _jsx("div", { className: "flex min-w-0 flex-col divide-y divide-line *:py-3.5 *:first:pt-0 *:last:pb-0", children: children })] }));
39
41
  }
42
+ if (sections) {
43
+ /* «sections»: the settings' card, the dense sheet's body — label | value in its columns,
44
+ not rows that explain themselves. A group inside stays a group (`InCardScope`). */
45
+ return (_jsxs("section", { ...(indexed === undefined ? {} : { id: indexed }), "data-ui": "form.section", className: `@container flex min-w-0 scroll-mt-3 flex-col rounded-ui-card border border-ui-card-border bg-ui-card ${byDensity(d, "gap-3 px-5 py-4", "gap-2 px-3 py-3")}`, children: [withHeader ? (_jsxs("header", { className: "flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-1", children: [title === undefined ? null : (_jsx("h2", { className: "min-w-0 text-title font-semibold text-ink first-letter:uppercase", children: title })), hint === undefined ? null : _jsx(Hint, { children: hint }), status === undefined ? null : _jsx(Tag, { tone: status.tone, children: status.label }), actions === undefined ? null : (_jsx("span", { className: "ml-auto flex shrink-0 items-center gap-1.5", children: actions }))] })) : null, _jsx(InCardScope, { children: _jsx("div", { className: `min-w-0 ${asGrid
46
+ ? `grid ${grid} gap-x-8 ${byDensity(d, "gap-y-3.5", "gap-y-2.5")}`
47
+ : `flex flex-col ${byDensity(d, "gap-3.5", "gap-2.5")}`}`, children: children }) })] }));
48
+ }
40
49
  return (_jsxs("section", { className: `flex min-w-0 flex-col ${byDensity(d, "gap-3", "gap-2")}`, children: [withHeader ? (_jsxs("header", { className: "flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-1", children: [title === undefined && hint === undefined ? null : (_jsxs("h3", { className: "flex min-w-0 items-center gap-1 text-meta font-medium text-ink", children: [title === undefined ? null : _jsx("span", { className: "min-w-0 truncate", children: title }), hint === undefined ? null : _jsx(Hint, { children: hint })] })), status === undefined ? null : _jsx(Tag, { tone: status.tone, children: status.label }), actions === undefined ? null : (_jsx("span", { className: "ml-auto flex shrink-0 items-center gap-1.5", children: actions }))] })) : null, _jsx("div", { className: `min-w-0 ${asGrid
41
50
  ? `grid ${grid} gap-x-8 ${byDensity(d, "gap-y-3.5", "gap-y-2.5")}`
42
51
  : `flex flex-col ${byDensity(d, "gap-3.5", "gap-2.5")}`}`, children: children })] }));
@@ -1,5 +1,9 @@
1
1
  import { type ReactNode } from "react";
2
- /** Where a form's sections register: the sheet of a «settings» form. */
2
+ export declare function InCardScope({ children }: {
3
+ children: ReactNode;
4
+ }): import("react").JSX.Element;
5
+ export declare function useInCard(): boolean;
6
+ /** Where a form's sections register: the sheet of a «settings» or «sections» form. */
3
7
  export declare function FormIndexScope({ children }: {
4
8
  children: ReactNode;
5
9
  }): import("react").JSX.Element;
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { useUiCopy } from "../../foundations/copy.js";
4
+ import { STICKY_TOP } from "../../foundations/sticky.js";
4
5
  import { createContext, useContext, useEffect, useId, useMemo, useState, useSyncExternalStore, } from "react";
5
6
  function createRegistry() {
6
7
  let entries = [];
@@ -26,8 +27,21 @@ function createRegistry() {
26
27
  };
27
28
  }
28
29
  const NONE = [];
30
+ /* A step below what sticks above it — the same step the cards keep from the bar. */
31
+ const INDEX_TOP = {
32
+ top: `calc(var(${STICKY_TOP}, 0px) + var(--spacing) * 3)`,
33
+ };
29
34
  const IndexContext = createContext(null);
30
- /** Where a form's sections register: the sheet of a «settings» form. */
35
+ /** Whether what is drawn is already INSIDE a card — a section of the «sections» style: a
36
+ * group in it stays a group (titled, hairline columns), not a card inside a card. */
37
+ const InCard = createContext(false);
38
+ export function InCardScope({ children }) {
39
+ return _jsx(InCard, { value: true, children: children });
40
+ }
41
+ export function useInCard() {
42
+ return useContext(InCard);
43
+ }
44
+ /** Where a form's sections register: the sheet of a «settings» or «sections» form. */
31
45
  export function FormIndexScope({ children }) {
32
46
  const [registry] = useState(createRegistry);
33
47
  return _jsx(IndexContext, { value: registry, children: children });
@@ -61,36 +75,70 @@ export function FormIndex() {
61
75
  const entries = useSyncExternalStore(registry?.subscribe ?? (() => () => undefined), registry?.snapshot ?? (() => NONE), () => NONE);
62
76
  const ordered = useMemo(() => inDocumentOrder(entries), [entries]);
63
77
  const [current, setCurrent] = useState(undefined);
64
- /* The section being read is the first one crossing the top two fifths of the screen:
65
- the one whose title just went by is still the one being read until the next arrives. */
78
+ /* The section being read is the LAST one whose top went past the upper two fifths of what
79
+ scrolls — the one whose title just went by is still being read until the next arrives —,
80
+ and at the end of the scroll, the last section: a short last card never reaches that
81
+ line, and pressing it in the index must mark it. Measured on scroll (capture: a record in
82
+ a panel scrolls its own box), once a frame. */
66
83
  useEffect(() => {
67
- if (ordered.length < 2 || typeof IntersectionObserver === "undefined")
84
+ if (ordered.length < 2)
68
85
  return;
69
- const seen = new Set();
70
- const observer = new IntersectionObserver((changes) => {
71
- for (const change of changes) {
72
- if (change.isIntersecting)
73
- seen.add(change.target.id);
74
- else
75
- seen.delete(change.target.id);
86
+ let frame = 0;
87
+ const measure = (scroller) => {
88
+ const height = scroller === null ? window.innerHeight : scroller.clientHeight;
89
+ const top = scroller === null ? 0 : scroller.getBoundingClientRect().top;
90
+ const atEnd = scroller === null
91
+ ? Math.ceil(window.innerHeight + window.scrollY) >=
92
+ document.documentElement.scrollHeight - 2
93
+ : Math.ceil(scroller.scrollTop + scroller.clientHeight) >=
94
+ scroller.scrollHeight - 2;
95
+ if (atEnd && (scroller !== null || window.scrollY > 0)) {
96
+ setCurrent(ordered.at(-1)?.id);
97
+ return;
98
+ }
99
+ const atStart = scroller === null ? window.scrollY <= 2 : scroller.scrollTop <= 2;
100
+ if (atStart) {
101
+ setCurrent(ordered[0]?.id);
102
+ return;
103
+ }
104
+ const line = top + height * 0.4;
105
+ /* Cards side by side share their top: the first of them is the one being read. */
106
+ let reading = ordered[0]?.id;
107
+ let readingTop = Number.NEGATIVE_INFINITY;
108
+ for (const entry of ordered) {
109
+ const element = document.getElementById(entry.id);
110
+ if (element === null)
111
+ continue;
112
+ const at = element.getBoundingClientRect().top;
113
+ if (at <= line && at > readingTop + 1) {
114
+ reading = entry.id;
115
+ readingTop = at;
116
+ }
76
117
  }
77
- const first = ordered.find((entry) => seen.has(entry.id));
78
- if (first !== undefined)
79
- setCurrent(first.id);
80
- }, { rootMargin: "0px 0px -60% 0px" });
81
- for (const entry of ordered) {
82
- const element = document.getElementById(entry.id);
83
- if (element !== null)
84
- observer.observe(element);
85
- }
86
- return () => observer.disconnect();
118
+ setCurrent(reading);
119
+ };
120
+ const onScroll = (event) => {
121
+ const target = event.target;
122
+ const scroller = target instanceof Element && target !== document.documentElement ? target : null;
123
+ /* Only the scroll that moves the sections: a table scrolling sideways inside one is not. */
124
+ if (scroller !== null &&
125
+ !ordered.some((one) => scroller.querySelector(`[id="${one.id}"]`)))
126
+ return;
127
+ cancelAnimationFrame(frame);
128
+ frame = requestAnimationFrame(() => measure(scroller));
129
+ };
130
+ document.addEventListener("scroll", onScroll, { capture: true, passive: true });
131
+ return () => {
132
+ cancelAnimationFrame(frame);
133
+ document.removeEventListener("scroll", onScroll, { capture: true });
134
+ };
87
135
  }, [ordered]);
88
136
  if (ordered.length < 2)
89
137
  return null;
90
138
  const marked = current ?? ordered[0]?.id;
91
- return (_jsx("nav", { "aria-label": copy.field.sections, "data-ui": "form.index", className: "hidden w-(--container-form-index) shrink-0 @3xl/form:block", children: _jsx("ul", { className: "sticky top-3 flex flex-col gap-0.5", children: ordered.map((entry) => (_jsx("li", { children: _jsx("a", { href: `#${entry.id}`, ...(entry.id === marked ? { "aria-current": "location" } : {}), onClick: (event) => {
139
+ return (_jsx("nav", { "aria-label": copy.field.sections, "data-ui": "form.index", className: "hidden w-(--container-form-index) shrink-0 @3xl/form:block", children: _jsx("ul", { className: "sticky flex flex-col gap-0.5", style: INDEX_TOP, children: ordered.map((entry) => (_jsx("li", { children: _jsx("a", { href: `#${entry.id}`, ...(entry.id === marked ? { "aria-current": "location" } : {}), onClick: (event) => {
92
140
  event.preventDefault();
93
141
  document.getElementById(entry.id)?.scrollIntoView({ block: "start" });
94
142
  setCurrent(entry.id);
95
- }, className: "block truncate rounded-ui-nav px-2.5 py-1.5 text-meta text-muted transition-colors duration-(--duration-instant) outline-0 hover:bg-ink/5 hover:text-ink focus-visible:outline-2 focus-visible:outline-primary aria-[current]:bg-ui-nav-current aria-[current]:font-medium aria-[current]:text-ink", children: entry.title }) }, entry.id))) }) }));
143
+ }, className: "block truncate rounded-ui-nav px-2.5 py-1.5 text-meta first-letter:uppercase text-muted transition-colors duration-(--duration-instant) outline-0 hover:bg-ink/5 hover:text-ink focus-visible:outline-2 focus-visible:outline-primary aria-[current]:bg-ui-nav-current aria-[current]:font-medium aria-[current]:text-ink", children: entry.title }) }, entry.id))) }) }));
96
144
  }
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { FormIndex, FormIndexScope } from "./FormIndex.js";
3
+ import { FormIndex, FormIndexScope, InCardScope, useFormIndexEntry, useInCard, } from "./FormIndex.js";
4
4
  import { byDensity, useDensity } from "../../foundations/density.js";
5
5
  import { useFormStyle } from "../../foundations/form.js";
6
6
  import { FieldLayoutProvider, } from "../../primitives/field/layout.js";
@@ -48,11 +48,15 @@ function Facts({ fields, columns, layout, }) {
48
48
  }
49
49
  export function Sheet({ fields, columns = 2, layout = "stacked", head, children, }) {
50
50
  const d = useDensity();
51
- const settings = useFormStyle() === "settings";
51
+ const style = useFormStyle();
52
+ const settings = style === "settings" || style === "sections";
52
53
  const facts = fields !== undefined && fields.length > 0;
53
54
  if (!facts && head === undefined && children === undefined)
54
55
  return null;
55
- const top = facts || head !== undefined ? (_jsxs("div", { className: `flex min-w-0 flex-col ${byDensity(d, "gap-4", "gap-3")}`, children: [facts ? _jsx(Facts, { fields: fields, columns: columns, layout: layout }) : null, head] })) : null;
56
+ const top = facts || head !== undefined ? (_jsxs("div", { className: `flex min-w-0 flex-col ${byDensity(d, "gap-4", "gap-3")}`, children: [facts ? (style === "sections" ? (
57
+ /* The record's own facts, a card with no name: they are its head, not a section
58
+ to find. */
59
+ _jsx("div", { className: CARD, children: _jsx(InCardScope, { children: _jsx(Facts, { fields: fields, columns: columns, layout: layout }) }) })) : (_jsx(Facts, { fields: fields, columns: columns, layout: layout }))) : null, head] })) : null;
56
60
  if (settings)
57
61
  return (_jsx(FieldLayoutProvider, { value: layout, children: _jsx(FormIndexScope, { children: _jsx("div", { className: "@container/form min-w-0", children: _jsxs("div", { className: "flex min-w-0 gap-6", children: [_jsx(FormIndex, {}), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-4", children: [top, children] })] }) }) }) }));
58
62
  return (_jsx(FieldLayoutProvider, { value: layout, children: _jsxs("div", { className: `flex min-w-0 flex-col ${byDensity(d, "gap-(--spacing-block)", "gap-2.5")}`, children: [top, children] }) }));
@@ -62,6 +66,8 @@ export function Sheet({ fields, columns = 2, layout = "stacked", head, children,
62
66
  * groups them when a column has no title. */
63
67
  export function SheetGroups({ children, columns = 2, }) {
64
68
  const d = useDensity();
69
+ const inCard = useInCard();
70
+ const cards = useFormStyle() === "sections" && !inCard;
65
71
  const stacked = d === "compact";
66
72
  // Below `handheld` the columns stack the way compact density does: two 180 px
67
73
  // columns on a phone left each label beside a control with no width at all. The
@@ -74,6 +80,11 @@ export function SheetGroups({ children, columns = 2, }) {
74
80
  ? "grid-cols-3 @max-handheld:grid-cols-1"
75
81
  : "grid-cols-2 @max-handheld:grid-cols-1";
76
82
  const items = Children.toArray(children);
83
+ /* «sections»: each group is a card of its own, side by side with a gap — no hairline: the
84
+ cards' edges already part them. */
85
+ if (cards) {
86
+ return (_jsx("div", { className: "@container min-w-0", children: _jsx("div", { className: `grid min-w-0 items-start gap-4 ${grid}`, children: children }) }));
87
+ }
77
88
  return (_jsx("div", { className: "@container min-w-0", children: _jsx("div", { className: `grid min-w-0 ${grid}`, children: items.map((child, i) => {
78
89
  const first = i === 0;
79
90
  const last = i === items.length - 1;
@@ -94,9 +105,16 @@ export function SheetGroups({ children, columns = 2, }) {
94
105
  export function SheetGroup({ title, hint, icon: Icon, children, }) {
95
106
  const d = useDensity();
96
107
  const withHeader = title !== undefined;
97
- return (_jsxs("section", { className: `flex min-w-0 flex-col ${byDensity(d, "gap-2.5", "gap-2")}`, children: [withHeader ? (
108
+ /* «sections», on the ground: the group is a card, listed in the index by its title. */
109
+ const inCard = useInCard();
110
+ const card = useFormStyle() === "sections" && !inCard;
111
+ const indexed = useFormIndexEntry(card ? title : undefined);
112
+ const body = (_jsxs("section", { ...(indexed === undefined ? {} : { id: indexed }), ...(card ? { "data-ui": "form.section" } : {}), className: `flex min-w-0 flex-col ${byDensity(d, "gap-2.5", "gap-2")} ${card ? `scroll-mt-3 ${CARD}` : ""}`, children: [withHeader ? (
98
113
  /* A group title is ABOVE its labels, not one of them: at the labels' size and weight
99
114
  «Cliente» the group read like «Cliente» the field. One step up in size and weight,
100
115
  and a hairline that says where the group starts. */
101
116
  _jsxs("header", { className: "flex min-w-0 items-center gap-2 border-b border-line pb-1.5", children: [Icon === undefined ? null : (_jsx(Icon, { className: "size-(--size-icon-sm) shrink-0 text-muted", strokeWidth: 1.75, "aria-hidden": true })), _jsx("h2", { className: "min-w-0 truncate text-body font-semibold text-ink", children: title }), hint === undefined ? null : _jsx(Hint, { children: hint })] })) : hint === undefined ? null : (_jsx(Hint, { children: hint })), _jsx("div", { className: `flex min-w-0 flex-col ${byDensity(d, "gap-2.5", "gap-2")}`, children: children })] }));
117
+ return card ? _jsx(InCardScope, { children: body }) : body;
102
118
  }
119
+ /* A card of the «sections» style: the settings' card, at the dense sheet's padding. */
120
+ const CARD = "rounded-ui-card border border-ui-card-border bg-ui-card px-5 py-4 @max-handheld:px-3 @max-handheld:py-3";
@@ -1,4 +1,5 @@
1
1
  import type { Surface } from "../../foundations/types.js";
2
+ import type { ViewStyle } from "../../foundations/viewStyle.js";
2
3
  import type { ReactNode } from "react";
3
4
  /** THE BAR — two rows, two questions.
4
5
  *
@@ -34,6 +35,26 @@ import type { ReactNode } from "react";
34
35
  * The actions on the left do NOT go away: «Nuevo» stays available with three
35
36
  * rows selected, because selecting is not entering a mode.
36
37
  *
38
+ * ── The modern style: the trail is the heading ──────────────────────
39
+ *
40
+ * ┌──────────────────────────────────────────────────────────────────┐
41
+ * │ Ventas › Andina › Pedidos ( 1–12 / 12 ‹ › ) │
42
+ * │ what it is made of 🔍 search… [sort][cols] [▤▦] │
43
+ * └──────────────────────────────────────────────────────────────────┘
44
+ * ( Pedidos │ Importar · Exportar ▾ · + Nueva cotización ) ← floats
45
+ *
46
+ * As a record in the modern style, WHERE I AM is the page's heading: the trail at the
47
+ * title's size (`Breadcrumb size="lg"`), its last crumb the list's name — so the title is
48
+ * not said twice —, and the page range at the other end, as the record's pager pill. Its
49
+ * counters are not here: beside the trail they read as more crumbs; the list draws them as
50
+ * mini stats under the bar (`List.Metrics`). The second row is how I look at the set: what
51
+ * it is made of (the description), the search centred, sort, columns and the faces. The
52
+ * list's actions float at the bottom of the screen in a pill named by the list
53
+ * (`List.Dock`), which turns into what is done to the chosen rows while some are chosen;
54
+ * given `placement="bar"`, or drawn by hand, they take the start of the second row and the
55
+ * description goes on demand (`Hint`) beside the heading. Without crumbs the title is the
56
+ * heading. Compact keeps the one bar below.
57
+ *
37
58
  * ── Inside a record it is ONE line (`inline`) ────────────────────────
38
59
  *
39
60
  * ┌───────────────────────────────────────────────────────────────┐
@@ -65,7 +86,10 @@ import type { ReactNode } from "react";
65
86
  * The count is a live region: typing in the search changes it, and somebody
66
87
  * who cannot see the rows thin out hears how many are left. With
67
88
  * `pagination` the page range replaces it — it already says how many. */
68
- export declare function ListingBar({ actions, title, description, counters, selection, search, pagination, views, crumbs, surface, inline, count, }: {
89
+ export declare function ListingBar({ actions, title, description, counters, selection, search, pagination, views, crumbs, surface, inline, count, look, }: {
90
+ /** How the bar is drawn: `modern` makes the trail the heading and puts the search on the
91
+ * row of the controls (see the header). The list passes its view style. */
92
+ look?: ViewStyle;
69
93
  /** What starts something new. It stays visible even when there is a selection. */
70
94
  actions?: ReactNode;
71
95
  title?: string;