@sincpro/web-ui 2.8.0 → 2.9.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 (56) hide show
  1. package/README.md +143 -2
  2. package/dist/components/activity/Activity.js +3 -2
  3. package/dist/components/form/Form.js +12 -3
  4. package/dist/components/form/FormIndex.d.ts +5 -1
  5. package/dist/components/form/FormIndex.js +71 -23
  6. package/dist/components/form/Sheet.js +22 -4
  7. package/dist/components/record/ActionDock.d.ts +36 -0
  8. package/dist/components/record/ActionDock.js +58 -0
  9. package/dist/components/record/Breadcrumb.d.ts +3 -1
  10. package/dist/components/record/Breadcrumb.js +13 -5
  11. package/dist/components/record/DirtyActions.js +11 -1
  12. package/dist/components/record/Pager.d.ts +12 -10
  13. package/dist/components/record/Pager.js +39 -6
  14. package/dist/components/record/RecordHeader.d.ts +13 -1
  15. package/dist/components/record/RecordHeader.js +107 -31
  16. package/dist/components/record/SmartButtons.d.ts +8 -2
  17. package/dist/components/record/SmartButtons.js +8 -3
  18. package/dist/components/record/StatusBar.d.ts +68 -1
  19. package/dist/components/record/StatusBar.js +218 -48
  20. package/dist/components/record/dock.d.ts +56 -0
  21. package/dist/components/record/dock.js +58 -0
  22. package/dist/components/record/index.d.ts +3 -1
  23. package/dist/components/record/index.js +5 -1
  24. package/dist/foundations/copy.d.ts +9 -0
  25. package/dist/foundations/copy.es.js +10 -1
  26. package/dist/foundations/copy.js +5 -0
  27. package/dist/foundations/form.d.ts +10 -1
  28. package/dist/foundations/grouping.d.ts +9 -0
  29. package/dist/foundations/index.d.ts +3 -1
  30. package/dist/foundations/index.js +8 -2
  31. package/dist/foundations/keys.d.ts +34 -0
  32. package/dist/foundations/keys.js +99 -0
  33. package/dist/foundations/shortcut.d.ts +17 -1
  34. package/dist/foundations/shortcut.js +57 -1
  35. package/dist/foundations/viewStyle.d.ts +8 -0
  36. package/dist/foundations/viewStyle.js +12 -0
  37. package/dist/primitives/menu/Menu.d.ts +3 -0
  38. package/dist/primitives/menu/Menu.js +7 -1
  39. package/dist/primitives/table/DataTable.d.ts +15 -0
  40. package/dist/primitives/table/DataTable.js +67 -12
  41. package/dist/primitives/table/EditableTable.js +7 -2
  42. package/dist/primitives/table/SheetTable.d.ts +3 -0
  43. package/dist/primitives/table/SheetTable.js +15 -2
  44. package/dist/primitives/value/Value.d.ts +5 -1
  45. package/dist/primitives/value/Value.js +9 -3
  46. package/dist/tokens.css +19 -2
  47. package/dist/views/list/List.d.ts +2 -1
  48. package/dist/views/list/List.js +6 -2
  49. package/dist/views/list/ListView.d.ts +1 -1
  50. package/dist/views/list/ListView.js +53 -14
  51. package/dist/views/list/derive.d.ts +1 -1
  52. package/dist/views/list/derive.js +45 -9
  53. package/dist/views/list/types.d.ts +33 -0
  54. package/dist/views/record/Record.d.ts +16 -2
  55. package/dist/views/record/Record.js +33 -8
  56. package/package.json +1 -1
@@ -4,14 +4,16 @@ import { useUiCopy } from "../../foundations/copy.js";
4
4
  import { byDensity, useDensity } from "../../foundations/density.js";
5
5
  import { useSurface } from "../../foundations/surface.js";
6
6
  import { cn, focusRing, tv } from "../../foundations/variants.js";
7
- import { Check, CircleAlert } from "lucide-react";
8
- import { Radio, RadioGroup } from "react-aria-components";
7
+ import { MenuList } from "../../primitives/menu/Menu.js";
8
+ import { Popover } from "../../primitives/overlay/Popover.js";
9
+ import { Check, ChevronDown, CircleAlert } from "lucide-react";
10
+ import { Button as AriaButton, MenuTrigger, Radio, RadioGroup } from "react-aria-components";
9
11
  /** The track the stages sit in. Same rail as the other grouped controls on each
10
12
  * surface: a tinted well with a hairline, and on the chrome TRANSLUCENT —ink at 8 %
11
13
  * over the navy— so the header's brand wash goes across it and it reads as a layer,
12
14
  * not as one more box stuck on top. */
13
15
  const trackStyles = tv({
14
- base: "min-w-0 gap-0.5 rounded-control border p-0.5",
16
+ base: "min-w-0 gap-0.5 border p-0.5",
15
17
  variants: {
16
18
  surface: {
17
19
  canvas: "border-line bg-ground",
@@ -21,7 +23,15 @@ const trackStyles = tv({
21
23
  trail: "inline-flex max-w-full shrink-0 items-stretch",
22
24
  stacked: "flex w-full flex-col",
23
25
  },
26
+ /* `well` is Odoo's track; `pill` the segmented control — the action dock's shape: a pill
27
+ holding pills, on the paper's surface. */
28
+ shape: { well: "rounded-control", pill: "rounded-pill" },
24
29
  },
30
+ compoundVariants: [
31
+ { shape: "pill", surface: "canvas", class: "border-line-strong bg-surface" },
32
+ /* Stacked, a pill of rows is a capsule nobody reads as a list: the box's corners. */
33
+ { shape: "pill", layout: "stacked", class: "rounded-box" },
34
+ ],
25
35
  });
26
36
  /** One stage. Three steps —done, current, next— and ONE way of painting each, the
27
37
  * same in both layouts and with or without `onSelect`:
@@ -36,8 +46,9 @@ const trackStyles = tv({
36
46
  * one included — without competing with the fill. */
37
47
  const stageStyles = tv({
38
48
  extend: focusRing,
39
- base: "relative flex min-w-0 items-center gap-1.5 rounded-mark px-2.5 text-meta whitespace-nowrap transition-colors duration-(--duration-instant)",
49
+ base: "relative flex min-w-0 items-center gap-1.5 text-meta whitespace-nowrap transition-colors duration-(--duration-instant)",
40
50
  variants: {
51
+ shape: { well: "rounded-mark px-2.5", pill: "rounded-pill px-3" },
41
52
  surface: { canvas: "", chrome: "outline-chrome-link" },
42
53
  step: { done: "font-medium", current: "font-semibold", next: "" },
43
54
  failed: { true: "", false: "" },
@@ -82,38 +93,7 @@ const stageStyles = tv({
82
93
  },
83
94
  ],
84
95
  });
85
- /** Which step something is on, **with the steps that come next in sight**.
86
- *
87
- * ── One track, one language ──────────────────────────────────────────
88
- *
89
- * The stages are segments of ONE track, Odoo's statusbar: the order is the
90
- * direction. What is behind is ink with a check, what comes next is muted, and the
91
- * current stage is the only FILLED segment — `primary` on the canvas, the chrome's
92
- * ink inverted on the rail. With `failed` that fill turns `danger` and carries an
93
- * alert mark, so the failure is not only a color.
94
- *
95
- * A clipped arrow per step was tried and dropped: the notch between two arrows
96
- * reads as a gap — four chips, not a path.
97
- *
98
- * ── Narrow: it STACKS, it does not hide ──────────────────────────────
99
- *
100
- * Four stages side by side do not fit in a 480 px drawer, and the answer is not
101
- * tucking them behind a chevron: a state you have to open stops answering «where
102
- * is this at?», which is the only question it has. It stacks — one stage per row —
103
- * in the same track, with the same three paints and the same marks. What changes
104
- * is the DIRECTION, not how much is shown nor how it is painted.
105
- *
106
- * ── And it can be CHOSEN ─────────────────────────────────────────────
107
- *
108
- * With `onSelect` the track is a React Aria `RadioGroup`: one stage at a time,
109
- * arrow keys move between them, Tab enters at the chosen one. It is not
110
- * «advancing» — a stage does not change by pressing it — it is choosing which
111
- * stage we are talking about: in a list grouped by stage, pressing «generando» asks
112
- * for those. So the record's CURRENT stage (`current`, the fill, `aria-current`)
113
- * and the stage being VIEWED (`selected`, the underline, the checked radio) are two
114
- * different things and are painted differently. Without `onSelect` it is a plain
115
- * ordered list and the current stage is `aria-current="step"`. */
116
- export function StatusBar({ stages, current, failed = false, surface: surfaceProp, onSelect, selected, layout, }) {
96
+ export function StatusBar({ stages, current, failed = false, surface: surfaceProp, onSelect, selected, layout, look = "track", display = "auto", renderStage, }) {
117
97
  const d = useDensity();
118
98
  const surface = useSurface(surfaceProp);
119
99
  const copy = useUiCopy();
@@ -126,32 +106,221 @@ export function StatusBar({ stages, current, failed = false, surface: surfacePro
126
106
  return "current";
127
107
  return at >= 0 && i < at ? "done" : "next";
128
108
  }
129
- /** The check, the alert, or nothing. Stacked keeps the slot even when it is
130
- * empty, so the labels line up in a column; side by side an empty slot would
131
- * only be a gap. */
132
- function mark(step) {
109
+ /** The icon a stage wears now: its `activeIcon` when it is current or looked at. */
110
+ function iconOf(stage, step, viewed) {
111
+ return (step === "current" || viewed) && stage.activeIcon !== undefined
112
+ ? stage.activeIcon
113
+ : stage.icon;
114
+ }
115
+ /** Whether the stage's name is SEEN — otherwise it is said (visually hidden, and on hover). */
116
+ function nameShown(step, viewed) {
117
+ return (display === "auto" ||
118
+ display === "both" ||
119
+ display === "label" ||
120
+ (display === "current" && (step === "current" || viewed)));
121
+ }
122
+ /** `auto`, side by side, a stage that is not where the record is: its name is SAID on a
123
+ * phone and seen where there is room. */
124
+ function namedWide(step, viewed) {
125
+ return display === "auto" && !stacked && step !== "current" && !viewed;
126
+ }
127
+ /** The class of a stage's name: seen, said, or seen only where there is room. */
128
+ function nameClass(step, viewed, seen) {
129
+ if (!nameShown(step, viewed))
130
+ return "sr-only";
131
+ return namedWide(step, viewed) ? `${seen} max-sm:sr-only` : seen;
132
+ }
133
+ /** On a phone, a stage whose name is only said and that has no icon shows its number. */
134
+ function numberOnPhone(i) {
135
+ return (_jsx("span", { "aria-hidden": true, className: "min-w-(--size-icon-sm) text-center tabular-nums sm:hidden", children: (i + 1).toLocaleString(copy.locale) }));
136
+ }
137
+ /** The alert, the stage's icon, the check, its number — or nothing. Stacked keeps the slot
138
+ * even when it is empty, so the labels line up in a column; side by side an empty slot
139
+ * would only be a gap. */
140
+ function mark(stage, i, step, viewed) {
133
141
  const icon = "size-(--size-icon-sm) shrink-0";
134
- if (step === "done")
135
- return _jsx(Check, { className: icon, strokeWidth: 2, "aria-hidden": true });
136
142
  if (step === "current" && failed) {
137
143
  return _jsx(CircleAlert, { className: icon, strokeWidth: 2, "aria-hidden": true });
138
144
  }
145
+ const Icon = display === "label" ? undefined : iconOf(stage, step, viewed);
146
+ /* The stage's own icon says it better than the check: done is still read in its ink. */
147
+ if (Icon !== undefined)
148
+ return _jsx(Icon, { className: icon, strokeWidth: 2, "aria-hidden": true });
149
+ /* Its name hidden and no icon of its own: its place in the order. */
150
+ if (!nameShown(step, viewed)) {
151
+ return (_jsx("span", { "aria-hidden": true, className: "min-w-(--size-icon-sm) text-center tabular-nums", children: (i + 1).toLocaleString(copy.locale) }));
152
+ }
153
+ if (namedWide(step, viewed)) {
154
+ return (_jsxs(_Fragment, { children: [step === "done" ? (_jsx(Check, { className: `${icon} max-sm:hidden`, strokeWidth: 2, "aria-hidden": true })) : null, numberOnPhone(i)] }));
155
+ }
156
+ if (step === "done" && display !== "label") {
157
+ return _jsx(Check, { className: icon, strokeWidth: 2, "aria-hidden": true });
158
+ }
139
159
  return stacked ? _jsx("span", { className: icon, "aria-hidden": true }) : null;
140
160
  }
141
- function content(stage, step, viewed) {
142
- return (_jsxs(_Fragment, { children: [mark(step), _jsx("span", { "aria-current": step === "current" && selectable ? "step" : undefined, className: cn("min-w-0 truncate", viewed &&
161
+ /** How many are on the stage, after its name — quieter than the name. */
162
+ function countOf(stage) {
163
+ return stage.count === undefined ? null : (_jsx("span", { className: "shrink-0 tabular-nums opacity-70", children: stage.count.toLocaleString(copy.locale) }));
164
+ }
165
+ function content(stage, i, step, viewed) {
166
+ if (renderStage !== undefined) {
167
+ return renderStage(stage, {
168
+ step,
169
+ failed: step === "current" && failed,
170
+ viewed,
171
+ index: i,
172
+ });
173
+ }
174
+ const seen = nameShown(step, viewed);
175
+ return (
176
+ /* Its name hidden, the hint — else the name — is what pointing at it says. */
177
+ _jsxs("span", { className: "flex min-w-0 items-center gap-1.5", title: seen ? undefined : (stage.hint ?? stage.label), children: [mark(stage, i, step, viewed), _jsx("span", { title: seen ? stage.hint : undefined, "aria-current": step === "current" && selectable ? "step" : undefined, className: cn(nameClass(step, viewed, "min-w-0 truncate"), viewed &&
143
178
  "underline decoration-2 underline-offset-4 " +
144
179
  (step === "current"
145
180
  ? "decoration-current"
146
181
  : surface === "chrome"
147
182
  ? "decoration-chrome-link"
148
- : "decoration-primary")), children: stage.label })] }));
183
+ : "decoration-primary")), children: stage.label }), countOf(stage)] }));
184
+ }
185
+ const rounded = look === "segmented" ? "pill" : "well";
186
+ const track = trackStyles({ surface, layout: shape, shape: rounded });
187
+ if (look === "pill") {
188
+ const chrome = surface === "chrome";
189
+ const now = stages[at];
190
+ const dot = failed
191
+ ? chrome
192
+ ? "bg-chrome-bad"
193
+ : "bg-danger"
194
+ : chrome
195
+ ? "bg-chrome-link"
196
+ : "bg-primary";
197
+ /* Its name is what it shows, said first what it is: «Estado: Publicada 2/3». As a button
198
+ the name comes from its content (voice control matches what is SEEN); a status takes no
199
+ name from content, so it says it in a label. */
200
+ const said = `${copy.record.status}: ${now?.label ?? current} ${at + 1}/${stages.length}`;
201
+ const NowIcon = now === undefined || display === "label" ? undefined : iconOf(now, "current", false);
202
+ const chip = (_jsxs(_Fragment, { children: [NowIcon !== undefined && !failed ? (_jsx(NowIcon, { className: `size-(--size-icon-sm) shrink-0 ${chrome ? "text-chrome-link" : "text-primary"}`, strokeWidth: 2, "aria-hidden": true })) : (_jsx("span", { "aria-hidden": true, className: `size-2 shrink-0 rounded-pill ${dot}` })), _jsx("span", { className: "font-semibold", children: now?.label ?? current }), _jsx("span", { className: `tabular-nums ${chrome ? "text-chrome-muted" : "text-muted"}`, children: `${at + 1}/${stages.length}` })] }));
203
+ const frame = `inline-flex h-(--size-control-sm) shrink-0 items-center gap-1.5 rounded-pill border px-2.5 text-meta ${chrome
204
+ ? "border-chrome-ink/20 bg-chrome-ink/8 text-chrome-ink"
205
+ : "border-line-strong bg-surface text-ink"}`;
206
+ if (!selectable) {
207
+ return (_jsx("span", { role: "status", "aria-label": said, "data-failed": failed ? true : undefined, className: frame, children: chip }));
208
+ }
209
+ /* The chip IS the trigger: the same face, a chevron added — the stages open below it. */
210
+ return (_jsxs(MenuTrigger, { children: [_jsxs(AriaButton, { className: ({ isFocusVisible }) => cn(frame, "cursor-pointer transition-colors duration-(--duration-instant)", chrome
211
+ ? "hover:bg-chrome-ink/14"
212
+ : "hover:border-primary/45 hover:bg-primary/5", isFocusVisible && "outline-2 outline-offset-2 outline-primary"), children: [_jsx("span", { className: "sr-only", children: `${copy.record.status}: ` }), chip, _jsx(ChevronDown, { className: `size-(--size-icon-sm) ${chrome ? "text-chrome-muted" : "text-muted"}`, strokeWidth: 2, "aria-hidden": true })] }), _jsx(Popover, { placement: "bottom end", className: "min-w-44", children: _jsx(MenuList, { label: copy.record.status, closeOnSelect: true, emptyText: "", width: "sm", groups: [
213
+ {
214
+ options: stages.map((stage) => ({
215
+ id: stage.id,
216
+ label: stage.label,
217
+ ...(display === "label" || stage.icon === undefined
218
+ ? {}
219
+ : { icon: stage.icon }),
220
+ ...(stage.count === undefined
221
+ ? {}
222
+ : { hint: stage.count.toLocaleString(copy.locale) }),
223
+ checked: stage.id === (selected ?? current),
224
+ })),
225
+ },
226
+ ], onAction: (id) => onSelect?.(String(id)) }) })] }));
227
+ }
228
+ if (look === "progress" && !stacked) {
229
+ const chrome = surface === "chrome";
230
+ const barOf = (step) => step === "current"
231
+ ? failed
232
+ ? chrome
233
+ ? "bg-chrome-bad"
234
+ : "bg-danger"
235
+ : chrome
236
+ ? "bg-chrome-link"
237
+ : "bg-primary"
238
+ : step === "done"
239
+ ? chrome
240
+ ? "bg-chrome-link/45"
241
+ : "bg-primary/40"
242
+ : chrome
243
+ ? "bg-chrome-ink/15"
244
+ : "bg-ink/10";
245
+ const labelOf = (step) => step === "current"
246
+ ? `font-semibold ${chrome ? "text-chrome-ink" : "text-ink"}`
247
+ : step === "done"
248
+ ? chrome
249
+ ? "text-chrome-ink"
250
+ : "text-ink"
251
+ : chrome
252
+ ? "text-chrome-muted"
253
+ : "text-muted";
254
+ const segment = (stage, i, viewed) => {
255
+ const where = stepOf(i);
256
+ return (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": true, className: `block h-1.5 w-full rounded-pill ${barOf(where)}` }), _jsxs("span", { "aria-current": where === "current" && selectable ? "step" : undefined, className: cn("mt-1 flex min-w-0 items-center gap-1 text-micro whitespace-nowrap", labelOf(where), viewed && "underline decoration-2 underline-offset-4"), children: [(() => {
257
+ const Icon = display === "label" ? undefined : iconOf(stage, where, viewed);
258
+ return where === "current" && failed ? (_jsx(CircleAlert, { className: "size-3 shrink-0", strokeWidth: 2.5, "aria-hidden": true })) : Icon !== undefined ? (_jsx(Icon, { className: "size-3 shrink-0", strokeWidth: 2.5, "aria-hidden": true })) : where === "done" && display !== "label" ? (_jsx(Check, { className: "size-3 shrink-0", strokeWidth: 2.5, "aria-hidden": true })) : null;
259
+ })(), _jsx("span", { className: nameClass(where, viewed, "min-w-0 truncate"), title: stage.hint, children: stage.label }), countOf(stage)] })] }));
260
+ };
261
+ /* Each stage asks for room for its name: squeezed, «Borrador Publicada» read as one. */
262
+ const row = "grid shrink-0 auto-cols-fr grid-flow-col gap-1.5";
263
+ if (!selectable) {
264
+ return (_jsx("ol", { "aria-label": copy.record.status, "data-look": "progress", className: row, children: stages.map((stage, i) => (_jsx("li", { "aria-current": stepOf(i) === "current" ? "step" : undefined, "data-failed": stepOf(i) === "current" && failed ? true : undefined, className: "flex w-24 min-w-0 flex-col", children: segment(stage, i, false) }, stage.id))) }));
265
+ }
266
+ return (_jsx(RadioGroup, { "aria-label": copy.record.status, orientation: "horizontal", ...(selected === undefined ? {} : { value: selected }), onChange: onSelect, "data-look": "progress", className: row, children: stages.map((stage, i) => (_jsx(Radio, { value: stage.id, className: ({ isFocusVisible }) => cn("flex w-24 min-w-0 cursor-pointer flex-col rounded-mark", isFocusVisible && "outline-2 outline-offset-2 outline-primary"), children: ({ isSelected }) => segment(stage, i, isSelected) }, stage.id))) }));
267
+ }
268
+ if (look === "steps" && !stacked) {
269
+ const chrome = surface === "chrome";
270
+ const dotOf = (step) => step === "current"
271
+ ? failed
272
+ ? `${chrome ? "bg-chrome-bad" : "bg-danger"} ring-3 ${chrome ? "ring-chrome-bad/25" : "ring-danger/20"}`
273
+ : `${chrome ? "bg-chrome-ink" : "bg-primary"} ring-3 ${chrome ? "ring-chrome-ink/25" : "ring-primary/20"}`
274
+ : step === "done"
275
+ ? chrome
276
+ ? "bg-chrome-ink/60"
277
+ : "bg-ink/55"
278
+ : `border ${chrome ? "border-chrome-muted/60" : "border-line-strong"} bg-transparent`;
279
+ const labelOf = (step) => step === "current"
280
+ ? `font-semibold ${chrome ? "text-chrome-ink" : "text-ink"}`
281
+ : step === "done"
282
+ ? chrome
283
+ ? "text-chrome-ink"
284
+ : "text-ink"
285
+ : chrome
286
+ ? "text-chrome-muted"
287
+ : "text-muted";
288
+ const joinOf = (i) => i <= at
289
+ ? chrome
290
+ ? "bg-chrome-ink/45"
291
+ : "bg-ink/35"
292
+ : chrome
293
+ ? "bg-chrome-muted/35"
294
+ : "bg-line-strong";
295
+ const step = (stage, i, viewed) => {
296
+ const where = stepOf(i);
297
+ if (renderStage !== undefined) {
298
+ return (_jsxs(_Fragment, { children: [i === 0 ? null : (_jsx("span", { "aria-hidden": true, className: `h-px w-5 shrink-0 ${joinOf(i)}` })), renderStage(stage, {
299
+ step: where,
300
+ failed: where === "current" && failed,
301
+ viewed,
302
+ index: i,
303
+ })] }));
304
+ }
305
+ const StepIcon = display === "label" ? undefined : iconOf(stage, where, viewed);
306
+ return (_jsxs(_Fragment, { children: [i === 0 ? null : _jsx("span", { "aria-hidden": true, className: `h-px w-5 shrink-0 ${joinOf(i)}` }), _jsx("span", { "aria-hidden": true, className: `size-2 shrink-0 rounded-pill ${dotOf(where)}` }), where === "current" && failed ? (_jsx(CircleAlert, { className: `size-(--size-icon-sm) shrink-0 ${chrome ? "text-chrome-bad" : "text-danger"}`, strokeWidth: 2, "aria-hidden": true })) : StepIcon !== undefined ? (_jsx(StepIcon, { className: `size-(--size-icon-sm) shrink-0 ${labelOf(where)}`, strokeWidth: 2, "aria-hidden": true })) : null, _jsx("span", { title: stage.hint, "aria-current": where === "current" && selectable ? "step" : undefined, className: cn(nameClass(where, viewed, "min-w-0 truncate text-meta whitespace-nowrap"), labelOf(where), viewed && "underline decoration-2 underline-offset-4"), children: stage.label }), stage.count === undefined ? null : (_jsx("span", { className: `text-meta ${labelOf(where)}`, children: countOf(stage) }))] }));
307
+ };
308
+ if (!selectable) {
309
+ return (_jsx("ol", { "aria-label": copy.record.status, className: "flex min-w-0 shrink-0 items-center gap-2", children: stages.map((stage, i) => (_jsx("li", { "aria-current": stepOf(i) === "current" ? "step" : undefined, "data-failed": stepOf(i) === "current" && failed ? true : undefined, className: "flex min-w-0 items-center gap-2", children: step(stage, i, false) }, stage.id))) }));
310
+ }
311
+ return (_jsx(RadioGroup, { "aria-label": copy.record.status, orientation: "horizontal", ...(selected === undefined ? {} : { value: selected }), onChange: onSelect, className: "flex min-w-0 shrink-0 items-center gap-2", children: stages.map((stage, i) => (_jsx(Radio, { value: stage.id, className: ({ isFocusVisible }) => cn("flex min-w-0 cursor-pointer items-center gap-2 rounded-mark", isFocusVisible && "outline-2 outline-offset-2 outline-primary"), children: ({ isSelected }) => step(stage, i, isSelected) }, stage.id))) }));
149
312
  }
150
- const track = trackStyles({ surface, layout: shape });
151
313
  if (!selectable) {
152
314
  return (_jsx("ol", { "aria-label": copy.record.status, className: track, children: stages.map((stage, i) => {
153
315
  const step = stepOf(i);
154
- return (_jsx("li", { "aria-current": step === "current" ? "step" : undefined, "data-failed": step === "current" && failed ? true : undefined, className: stageStyles({ surface, step, failed, selectable, layout: shape }), children: content(stage, step, false) }, stage.id));
316
+ return (_jsx("li", { "aria-current": step === "current" ? "step" : undefined, "data-failed": step === "current" && failed ? true : undefined, className: stageStyles({
317
+ surface,
318
+ step,
319
+ failed,
320
+ selectable,
321
+ layout: shape,
322
+ shape: rounded,
323
+ }), children: content(stage, i, step, false) }, stage.id));
155
324
  }) }));
156
325
  }
157
326
  return (_jsx(RadioGroup, { "aria-label": copy.record.status, orientation: stacked ? "vertical" : "horizontal", ...(selected === undefined ? {} : { value: selected }), onChange: onSelect, className: track, children: stages.map((stage, i) => {
@@ -162,7 +331,8 @@ export function StatusBar({ stages, current, failed = false, surface: surfacePro
162
331
  failed,
163
332
  selectable,
164
333
  layout: shape,
334
+ shape: rounded,
165
335
  isFocusVisible,
166
- }), children: ({ isSelected }) => content(stage, step, isSelected) }, stage.id));
336
+ }), children: ({ isSelected }) => content(stage, i, step, isSelected) }, stage.id));
167
337
  }) }));
168
338
  }
@@ -0,0 +1,56 @@
1
+ import type { MenuGroup, MenuOption } from "../../primitives/menu/Menu.js";
2
+ import type { LucideIcon } from "lucide-react";
3
+ /** One action of a dock. */
4
+ export interface DockAction {
5
+ id: string;
6
+ label: string;
7
+ icon?: LucideIcon;
8
+ /** THE action the screen exists for: gold, always seen. One per dock — a second one is
9
+ * read as a secondary. */
10
+ primary?: boolean;
11
+ /** It destroys or undoes: drawn last in «Más», apart, never beside the primary. */
12
+ danger?: boolean;
13
+ /** In «Más» even with room: what is rarely done. */
14
+ tucked?: boolean;
15
+ onSelect?: () => void;
16
+ /** Sub-actions: «Imprimir ▸ Factura · Remito». Seen, the action is a menu button; in
17
+ * «Más», a submenu. Its own `onSelect` is not run — a row that opens does not also do. */
18
+ items?: readonly DockAction[];
19
+ /** The keys that run it, as people read them — «Ctrl+P». A hint in the menu. */
20
+ shortcut?: string;
21
+ /** The line under it, in the menu. */
22
+ hint?: string;
23
+ disabled?: boolean;
24
+ }
25
+ export interface DockPlan {
26
+ primary: DockAction | undefined;
27
+ /** The secondary actions seen, in order. */
28
+ shown: DockAction[];
29
+ /** «Más»: the rest, and the destructive ones apart. */
30
+ more: DockAction[];
31
+ danger: DockAction[];
32
+ }
33
+ /**
34
+ * What a dock shows for these actions, with room for `visible` secondary ones.
35
+ *
36
+ * in [Registrar pago*, Enviar, Imprimir▸, Duplicar, Anular!], visible 2
37
+ * out shown [Enviar, Imprimir] more [Duplicar] danger [Anular] primary Registrar pago
38
+ */
39
+ export declare function dockPlan(actions: readonly DockAction[], visible?: number): DockPlan;
40
+ /** How a combination is drawn — the platform's way («⌥D», «Alt+D»); as written without one. */
41
+ export type KeysLabel = (keys: string) => string;
42
+ /** An action as a menu row — its sub-actions as a submenu, its shortcut drawn for this
43
+ * keyboard. */
44
+ export declare function dockOption(action: DockAction, label?: KeysLabel): MenuOption;
45
+ /** «Más» as menu groups: the rest, then the destructive ones apart. */
46
+ export declare function moreGroups(plan: DockPlan, label?: KeysLabel): MenuGroup[];
47
+ /**
48
+ * The combinations a dock answers: every action with a `shortcut` — sub-actions and what waits
49
+ * in «Más» included, a shortcut is how one reaches what is not in sight. None while there are
50
+ * changes: the actions are not there, and Save answers Mod+S itself (`DirtyActions`).
51
+ */
52
+ export declare function dockShortcuts(actions: readonly DockAction[], dirty?: boolean): {
53
+ keys: string;
54
+ run: () => void;
55
+ enabled: boolean;
56
+ }[];
@@ -0,0 +1,58 @@
1
+ /**
2
+ * What a dock shows for these actions, with room for `visible` secondary ones.
3
+ *
4
+ * in [Registrar pago*, Enviar, Imprimir▸, Duplicar, Anular!], visible 2
5
+ * out shown [Enviar, Imprimir] more [Duplicar] danger [Anular] primary Registrar pago
6
+ */
7
+ export function dockPlan(actions, visible = 2) {
8
+ const primary = actions.find((one) => one.primary === true);
9
+ const rest = actions.filter((one) => one !== primary);
10
+ const danger = rest.filter((one) => one.danger === true);
11
+ const candidates = rest.filter((one) => one.danger !== true && one.tucked !== true);
12
+ const shown = candidates.slice(0, Math.max(0, visible));
13
+ const more = rest.filter((one) => one.danger !== true && !shown.includes(one));
14
+ /* One action alone in «Más» is drawn instead of the menu — unless it was tucked on purpose
15
+ or something destructive shares the menu with it. */
16
+ if (more.length === 1 && danger.length === 0 && more[0].tucked !== true) {
17
+ return { primary, shown: [...shown, more[0]], more: [], danger };
18
+ }
19
+ return { primary, shown, more, danger };
20
+ }
21
+ /** An action as a menu row — its sub-actions as a submenu, its shortcut drawn for this
22
+ * keyboard. */
23
+ export function dockOption(action, label = (keys) => keys) {
24
+ return {
25
+ id: action.id,
26
+ label: action.label,
27
+ ...(action.icon === undefined ? {} : { icon: action.icon }),
28
+ ...(action.hint === undefined ? {} : { hint: action.hint }),
29
+ ...(action.shortcut === undefined ? {} : { shortcut: label(action.shortcut) }),
30
+ ...(action.disabled === undefined ? {} : { disabled: action.disabled }),
31
+ ...(action.danger === true ? { danger: true } : {}),
32
+ ...(action.onSelect === undefined ? {} : { onSelect: action.onSelect }),
33
+ ...(action.items === undefined
34
+ ? {}
35
+ : { items: action.items.map((one) => dockOption(one, label)) }),
36
+ };
37
+ }
38
+ /** «Más» as menu groups: the rest, then the destructive ones apart. */
39
+ export function moreGroups(plan, label) {
40
+ const option = (one) => dockOption(one, label);
41
+ return [
42
+ ...(plan.more.length === 0 ? [] : [{ options: plan.more.map(option) }]),
43
+ ...(plan.danger.length === 0 ? [] : [{ options: plan.danger.map(option) }]),
44
+ ];
45
+ }
46
+ /**
47
+ * The combinations a dock answers: every action with a `shortcut` — sub-actions and what waits
48
+ * in «Más» included, a shortcut is how one reaches what is not in sight. None while there are
49
+ * changes: the actions are not there, and Save answers Mod+S itself (`DirtyActions`).
50
+ */
51
+ export function dockShortcuts(actions, dirty = false) {
52
+ if (dirty)
53
+ return [];
54
+ const all = (list) => list.flatMap((one) => [one, ...(one.items === undefined ? [] : all(one.items))]);
55
+ return all(actions).flatMap((one) => one.shortcut === undefined || one.onSelect === undefined
56
+ ? []
57
+ : [{ keys: one.shortcut, run: one.onSelect, enabled: one.disabled !== true }]);
58
+ }
@@ -1,8 +1,10 @@
1
+ export { ActionDock, type ActionDockProps, type DockLook, type DockPlacement, type RecordDockPlacement, type RecordDockProps, } from "./ActionDock.js";
1
2
  export { Breadcrumb, type Crumb } from "./Breadcrumb.js";
2
3
  export { DirtyActions, type DirtyState, } from "./DirtyActions.js";
4
+ export { type DockAction, dockOption, type DockPlan, dockPlan, moreGroups, } from "./dock.js";
3
5
  export { Pager } from "./Pager.js";
4
6
  export { RecordAudit, type RecordStamp } from "./RecordAudit.js";
5
7
  export { RecordRibbon } from "./RecordRibbon.js";
6
8
  export { RecordSkeleton } from "./RecordSkeleton.js";
7
9
  export { SmartButton, SmartButtons } from "./SmartButtons.js";
8
- export { type Stage, StatusBar } from "./StatusBar.js";
10
+ export { type Stage, type StageState, StatusBar, type StatusDisplay, type StatusLook, } from "./StatusBar.js";
@@ -1,10 +1,14 @@
1
1
  /* RECORD PARTS — the header, status bar, pager and skeleton of one record. The `Record` view
2
2
  composes them. */
3
+ /* The actions FLOATING, as data: what is seen and what waits in «Más» is
4
+ decided by `dockPlan`. */
5
+ export { ActionDock, } from "./ActionDock.js";
3
6
  export { Breadcrumb } from "./Breadcrumb.js";
4
7
  export { DirtyActions, } from "./DirtyActions.js";
8
+ export { dockOption, dockPlan, moreGroups, } from "./dock.js";
5
9
  export { Pager } from "./Pager.js";
6
10
  export { RecordAudit } from "./RecordAudit.js";
7
11
  export { RecordRibbon } from "./RecordRibbon.js";
8
12
  export { RecordSkeleton } from "./RecordSkeleton.js";
9
13
  export { SmartButton, SmartButtons } from "./SmartButtons.js";
10
- export { StatusBar } from "./StatusBar.js";
14
+ export { StatusBar, } from "./StatusBar.js";
@@ -62,6 +62,13 @@ export type UiCopy = {
62
62
  prev: string;
63
63
  next: string;
64
64
  };
65
+ /** The floating action dock (`ActionDock`). */
66
+ dock: {
67
+ /** The toolbar's name, when the screen does not give one. */
68
+ label: string;
69
+ /** «Más»: the actions that did not fit. */
70
+ more: string;
71
+ };
65
72
  record: {
66
73
  prev: string;
67
74
  next: string;
@@ -621,6 +628,8 @@ export type UiCopy = {
621
628
  /** The header of the first column, which is read aloud and not
622
629
  * drawn: without it, a screen reader announces a column with no name. */
623
630
  concept: string;
631
+ /** The line that closes a report built from the piles: what all of them add up to. */
632
+ total: string;
624
633
  };
625
634
  /**
626
635
  * THE BUILDER of criteria: the words of its sections and its controls.
@@ -65,6 +65,10 @@ export const SPANISH_COPY = {
65
65
  prev: "Página anterior",
66
66
  next: "Página siguiente",
67
67
  },
68
+ dock: {
69
+ label: "Acciones",
70
+ more: "Más acciones",
71
+ },
68
72
  record: {
69
73
  prev: "Anterior",
70
74
  next: "Siguiente",
@@ -410,7 +414,12 @@ export const SPANISH_COPY = {
410
414
  finish: "Terminar",
411
415
  working: "Procesando…",
412
416
  },
413
- report: { open: "Abrir {name}", close: "Cerrar {name}", concept: "Concepto" },
417
+ report: {
418
+ open: "Abrir {name}",
419
+ close: "Cerrar {name}",
420
+ concept: "Concepto",
421
+ total: "Total",
422
+ },
414
423
  builder: {
415
424
  filter: "Filtro",
416
425
  order: "Orden",
@@ -41,6 +41,10 @@ export const ENGLISH_COPY = {
41
41
  prev: "Previous page",
42
42
  next: "Next page",
43
43
  },
44
+ dock: {
45
+ label: "Actions",
46
+ more: "More actions",
47
+ },
44
48
  record: {
45
49
  prev: "Previous record",
46
50
  next: "Next record",
@@ -400,6 +404,7 @@ export const ENGLISH_COPY = {
400
404
  open: "Open {name}",
401
405
  close: "Close {name}",
402
406
  concept: "Item",
407
+ total: "Total",
403
408
  },
404
409
  builder: {
405
410
  filter: "Filter",
@@ -79,7 +79,16 @@ export declare function FormModeProvider({ value, children, }: {
79
79
  /** The mode of this field. The prop beats the context — a computed field stays
80
80
  * in read mode inside a form that is being edited. */
81
81
  export declare function useFormMode(explicit?: FormMode): FormMode;
82
- export type FormStyle = "dense" | "settings";
82
+ /**
83
+ * dense the ERP's sheet: one white paper, groups side by side, a notebook of tabs.
84
+ * settings a back office's form: each section a card of rows that explain themselves —
85
+ * the label, its help under it, the control beside —, an index at the left.
86
+ * sections the DENSE sheet in the settings' shape: each group and each notebook page a
87
+ * card, on the ground, with the index at the left — and inside, the dense grid
88
+ * (label | value, two or three columns). A long record found by its index
89
+ * instead of hidden behind tabs, without losing a line of density.
90
+ */
91
+ export type FormStyle = "dense" | "settings" | "sections";
83
92
  export declare function FormStyleProvider({ value, children, }: {
84
93
  value: FormStyle;
85
94
  children: ReactNode;
@@ -99,6 +99,15 @@ export type Pile<T> = {
99
99
  /** What the pile ADDS UP TO, already written — «Total Bs 1.204.933» — summed by whoever
100
100
  * keeps the data over EVERY row in it, like the count. Drawn in the pile's header. */
101
101
  detail?: string;
102
+ /**
103
+ * What each COLUMN adds up to over every row in the pile, by column id (or the column's
104
+ * `field`) — what the server's grouped read summed: `{ amount_total: 1204933.5 }`. Drawn in
105
+ * the pile's row, UNDER its column, written like the column's footer.
106
+ *
107
+ * Absent, a table sums the rows the pile holds — only when it holds all of them: the sum of
108
+ * one page of a pile of thousands looks like its total and is not.
109
+ */
110
+ totals?: Readonly<Record<string, number>>;
102
111
  /** The rows, at the DEEPEST level. Empty in the ones above: a pile that
103
112
  * has piles inside has no rows of its own. */
104
113
  items: readonly T[];
@@ -1,8 +1,10 @@
1
1
  export { type CopyCatalog, type CopyOverride, createCopy, mergeCopyOver, } from "./catalog.js";
2
2
  export { currentCopy, currentCopyLocale, ENGLISH_COPY, fillCopy, installCopy, mergeCopy, type UiCopy, type UiCopyOverride, UiCopyProvider, useUiCopy, } from "./copy.js";
3
3
  export { byDensity, type Density, DensityProvider, useDensity, } from "./density.js";
4
+ export { useViewStyle, type ViewStyle, ViewStyleProvider, } from "./viewStyle.js";
4
5
  export { controlName, FieldBoundary, type FieldIds, type FormMode, FormModeProvider, type FormStyle, FormStyleProvider, useFieldIds, useFormMode, useFormStyle, } from "./form.js";
5
- export { type KeyboardPlatform, type ModShortcut, modShortcut, useKeyboardPlatform, } from "./shortcut.js";
6
+ export { type KeyPress, type Keys, keysAria, keysLabel, matchesKeys, needsModifier, type ParsedKeys, parseKeys, } from "./keys.js";
7
+ export { type KeyboardPlatform, type ModShortcut, modShortcut, type Shortcut, useKeyboardPlatform, useKeysHint, useShortcuts, } from "./shortcut.js";
6
8
  export { bySurface, SurfaceProvider, useSurface } from "./surface.js";
7
9
  export { applyTheme, isTheme, type ResolvedTheme, resolveTheme, type Theme, THEME_ATTRIBUTE, ThemeProvider, type ThemeProviderProps, THEMES, useTheme, } from "./theme.js";
8
10
  export type { OpenTarget, Size, Surface, Tone } from "./types.js";
@@ -3,11 +3,17 @@
3
3
  export { createCopy, mergeCopyOver, } from "./catalog.js";
4
4
  export { currentCopy, currentCopyLocale, ENGLISH_COPY, fillCopy, installCopy, mergeCopy, UiCopyProvider, useUiCopy, } from "./copy.js";
5
5
  export { byDensity, DensityProvider, useDensity, } from "./density.js";
6
+ /* How a whole application draws its views — `traditional` or `modern` (the direction): the
7
+ record's rail and the actions of a record and of a list. Set once, like the density. */
8
+ export { useViewStyle, ViewStyleProvider, } from "./viewStyle.js";
6
9
  /* A CONTROL'S CONTRACT — the ids its `Field` gives it and whether it is viewed or written. The
7
10
  package's controls and the application's speak it alike. */
8
11
  export { controlName, FieldBoundary, FormModeProvider, FormStyleProvider, useFieldIds, useFormMode, useFormStyle, } from "./form.js";
9
- /* A SHORTCUT, drawn the way the person's keyboard says it: «⌘K» on a Mac, «Ctrl K» elsewhere. */
10
- export { modShortcut, useKeyboardPlatform, } from "./shortcut.js";
12
+ /* A SHORTCUT, drawn the way the person's keyboard says it («⌘K» on a Mac, «Ctrl K» elsewhere),
13
+ and BOUND: `useShortcuts` runs it while the piece that declares it is on screen — the last
14
+ mounted wins. A combination is written once («Alt+D», «Mod+S») and read by `foundations/keys`. */
15
+ export { keysAria, keysLabel, matchesKeys, needsModifier, parseKeys, } from "./keys.js";
16
+ export { modShortcut, useKeyboardPlatform, useKeysHint, useShortcuts, } from "./shortcut.js";
11
17
  /* THE THEME — light, dark or the operating system's. The palettes live in `tokens.css`; this
12
18
  only writes `data-theme`. */
13
19
  export { bySurface, SurfaceProvider, useSurface } from "./surface.js";