@sincpro/web-ui 2.7.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 (69) hide show
  1. package/README.md +159 -4
  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/components/search/CriteriaBuilder.d.ts +5 -2
  25. package/dist/components/search/CriteriaBuilder.js +2 -1
  26. package/dist/components/search/FieldPath.js +16 -7
  27. package/dist/components/search/FilterBuilder.d.ts +13 -4
  28. package/dist/components/search/FilterBuilder.js +72 -23
  29. package/dist/components/search/RuleValue.d.ts +6 -2
  30. package/dist/components/search/RuleValue.js +27 -5
  31. package/dist/components/search/SearchBar.d.ts +6 -6
  32. package/dist/components/search/SearchBar.js +41 -4
  33. package/dist/components/search/context.d.ts +6 -2
  34. package/dist/components/search/context.js +5 -2
  35. package/dist/components/search/index.d.ts +1 -1
  36. package/dist/components/search/records.d.ts +23 -0
  37. package/dist/foundations/copy.d.ts +9 -0
  38. package/dist/foundations/copy.es.js +10 -1
  39. package/dist/foundations/copy.js +5 -0
  40. package/dist/foundations/form.d.ts +10 -1
  41. package/dist/foundations/grouping.d.ts +9 -0
  42. package/dist/foundations/index.d.ts +3 -1
  43. package/dist/foundations/index.js +8 -2
  44. package/dist/foundations/keys.d.ts +34 -0
  45. package/dist/foundations/keys.js +99 -0
  46. package/dist/foundations/shortcut.d.ts +17 -1
  47. package/dist/foundations/shortcut.js +57 -1
  48. package/dist/foundations/viewStyle.d.ts +8 -0
  49. package/dist/foundations/viewStyle.js +12 -0
  50. package/dist/primitives/menu/Menu.d.ts +3 -0
  51. package/dist/primitives/menu/Menu.js +7 -1
  52. package/dist/primitives/table/DataTable.d.ts +15 -0
  53. package/dist/primitives/table/DataTable.js +67 -12
  54. package/dist/primitives/table/EditableTable.js +7 -2
  55. package/dist/primitives/table/SheetTable.d.ts +3 -0
  56. package/dist/primitives/table/SheetTable.js +15 -2
  57. package/dist/primitives/value/Value.d.ts +5 -1
  58. package/dist/primitives/value/Value.js +9 -3
  59. package/dist/tokens.css +19 -2
  60. package/dist/views/list/List.d.ts +2 -1
  61. package/dist/views/list/List.js +6 -2
  62. package/dist/views/list/ListView.d.ts +1 -1
  63. package/dist/views/list/ListView.js +53 -14
  64. package/dist/views/list/derive.d.ts +1 -1
  65. package/dist/views/list/derive.js +45 -9
  66. package/dist/views/list/types.d.ts +33 -0
  67. package/dist/views/record/Record.d.ts +16 -2
  68. package/dist/views/record/Record.js +33 -8
  69. package/package.json +1 -1
@@ -6,7 +6,7 @@ import type { Surface } from "../../foundations/types.js";
6
6
  import type { DataColumn, DataTableCreate } from "../../primitives/table/DataTable.js";
7
7
  import type { RowAction } from "../../primitives/table/RowActions.js";
8
8
  import type { SortState } from "../../primitives/table/sorting.js";
9
- import { type CardWays, type ListCalendar, type ListChart, type ListCrumb, type ListEmpty, type ListGantt, type ListGroup, type ListPivot, type ListPresent, type ListReport, type ListSet, type ListSheet, type ListTimeline, type RowOf } from "./types.js";
9
+ import type { CardWays, ListCalendar, ListChart, ListCrumb, ListDock, ListEmpty, ListGantt, ListGroup, ListPivot, ListPresent, ListReport, ListSet, ListSheet, ListTimeline, RowOf } from "./types.js";
10
10
  import type { ReactNode } from "react";
11
11
  type BarProps = {
12
12
  children?: ReactNode;
@@ -147,6 +147,7 @@ export declare namespace List {
147
147
  var Identity: ((props: ListIdentity) => ReactNode) & import("../../foundations/slots.js").Slotted<"identity">;
148
148
  var Search: ((props: NodeProps) => ReactNode) & import("../../foundations/slots.js").Slotted<"search">;
149
149
  var Actions: ((props: NodeProps) => ReactNode) & import("../../foundations/slots.js").Slotted<"actions">;
150
+ var Dock: ((props: ListDock) => ReactNode) & import("../../foundations/slots.js").Slotted<"dock">;
150
151
  var Pagination: ((props: NodeProps) => ReactNode) & import("../../foundations/slots.js").Slotted<"pagination">;
151
152
  var Views: ((props: NodeProps) => ReactNode) & import("../../foundations/slots.js").Slotted<"views">;
152
153
  var Metrics: ((props: NodeProps) => ReactNode) & import("../../foundations/slots.js").Slotted<"metrics">;
@@ -1,7 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { flatten, loose, pick, propsOf, slot, slotOf, } from "../../foundations/slots.js";
3
3
  import { ListView } from "./ListView.js";
4
- import {} from "./types.js";
5
4
  /** The bar: everything that belongs to the SET and not to a row. Without it there is no
6
5
  * band — which is what a list put inside a dialog wants. */
7
6
  const Bar = slot("bar", (_props) => null);
@@ -14,6 +13,9 @@ const Identity = slot("identity", (_props) => null);
14
13
  const Search = slot("search", (_props) => null);
15
14
  /** What STARTS something new. It stays visible when there is a selection. */
16
15
  const Actions = slot("actions", (_props) => null);
16
+ /** The list's actions FLOATING, as data: what it starts, as a pill in the bar;
17
+ * what is done to the chosen rows, as a pill floating at the bottom. See `ListDock`. */
18
+ const Dock = slot("dock", (_props) => null);
17
19
  const Pagination = slot("pagination", (_props) => null);
18
20
  /** The switcher's escape hatch: a selector of one's own. Almost never needed —
19
21
  * the written faces already draw it. */
@@ -93,6 +95,7 @@ export function List({ items, keyOf, embedded, surface, group, selection: select
93
95
  const identity = propsOf(pick(bar, "identity"));
94
96
  const search = propsOf(pick(bar, "search"))?.children;
95
97
  const actions = propsOf(pick(bar, "actions"))?.children;
98
+ const dock = propsOf(pick(bar, "dock"));
96
99
  const pagination = propsOf(pick(bar, "pagination"))?.children;
97
100
  const views = propsOf(pick(bar, "views"))?.children;
98
101
  const metrics = propsOf(pick(top, "metrics"))?.children;
@@ -127,7 +130,7 @@ export function List({ items, keyOf, embedded, surface, group, selection: select
127
130
  const { actions: _actions, ...rest } = rows.row(item);
128
131
  return rest;
129
132
  }
130
- : rows.row, ...(rows?.header === undefined ? {} : { rowHeader: rows.header }), ...(identity === undefined ? {} : { identity }), ...(crumbs === undefined ? {} : { crumbs }), ...(embedded === undefined ? {} : { embedded }), ...(surface === undefined ? {} : { surface }), ...(search === undefined ? {} : { search }), ...(actions === undefined ? {} : { actions }), ...(pagination === undefined ? {} : { pagination }), ...(views === undefined ? {} : { views }), ...(metrics === undefined ? {} : { metrics }), ...(table === undefined
133
+ : rows.row, ...(rows?.header === undefined ? {} : { rowHeader: rows.header }), ...(identity === undefined ? {} : { identity }), ...(crumbs === undefined ? {} : { crumbs }), ...(embedded === undefined ? {} : { embedded }), ...(surface === undefined ? {} : { surface }), ...(search === undefined ? {} : { search }), ...(actions === undefined ? {} : { actions }), ...(dock === undefined || readOnly ? {} : { dock }), ...(pagination === undefined ? {} : { pagination }), ...(views === undefined ? {} : { views }), ...(metrics === undefined ? {} : { metrics }), ...(table === undefined
131
134
  ? {}
132
135
  : {
133
136
  /* Read-only: a cell that opens an editor is an action too. */
@@ -154,6 +157,7 @@ List.Crumbs = Crumbs;
154
157
  List.Identity = Identity;
155
158
  List.Search = Search;
156
159
  List.Actions = Actions;
160
+ List.Dock = Dock;
157
161
  List.Pagination = Pagination;
158
162
  List.Views = Views;
159
163
  List.Metrics = Metrics;
@@ -1,5 +1,5 @@
1
1
  import type { ListViewProps } from "./types.js";
2
- export declare function ListView<T extends object>({ items, keyOf, identity, crumbs, embedded, surface: requestedSurface, metrics, search, pagination, views, actions, row, rowHeader, columns, visibleColumnIds, onVisibleColumnIdsChange, card, boardStages, calendar, gantt, timeline, sheet, report, pivot, chart, faces, present: requested, presents, onPresentChange, sort, onSortChange, sortable, totals, rowActions, create, group, selection, onOpen, onPeek, rowClick, onChoose, state, filtered, empty, children, }: ListViewProps<T>): import("react").JSX.Element;
2
+ export declare function ListView<T extends object>({ items, keyOf, identity, crumbs, embedded, surface: requestedSurface, metrics, search, pagination, views, actions: written, dock, row, rowHeader, columns, visibleColumnIds, onVisibleColumnIdsChange, card, boardStages, calendar, gantt, timeline, sheet, report, pivot, chart, faces, present: requested, presents, onPresentChange, sort, onSortChange, sortable, totals, rowActions, create, group, selection, onOpen, onPeek, rowClick, onChoose, state, filtered, empty, children, }: ListViewProps<T>): import("react").JSX.Element;
3
3
  /** What a list offers when it fails and can be retried. */
4
4
  export declare function RetryAction({ onRetry }: {
5
5
  onRetry: () => void;
@@ -10,12 +10,15 @@ import { RecordCard } from "../../components/listing/RecordCard.js";
10
10
  import { GroupHeader, GroupMore, Row, RowHeader, } from "../../components/listing/Row.js";
11
11
  import { sortItems, SortMenu, } from "../../components/listing/SortMenu.js";
12
12
  import { ViewSwitcher, } from "../../components/listing/ViewSwitcher.js";
13
+ import { ActionDock } from "../../components/record/ActionDock.js";
13
14
  import { Breadcrumb } from "../../components/record/Breadcrumb.js";
14
15
  import { RecordTimeline } from "../../components/timeline/RecordTimeline.js";
15
- import { useUiCopy } from "../../foundations/copy.js";
16
+ import { fillCopy, useUiCopy } from "../../foundations/copy.js";
16
17
  import { useDensity } from "../../foundations/density.js";
17
18
  import { pathKey, pileFoot, pileIsOpen, pilesOf, } from "../../foundations/grouping.js";
18
19
  import { pivotFrom, pivotIsEmpty } from "../../foundations/pivot.js";
20
+ import { bySurface, useSurface } from "../../foundations/surface.js";
21
+ import { useViewStyle } from "../../foundations/viewStyle.js";
19
22
  import { Button } from "../../primitives/button/Button.js";
20
23
  import { Empty, Failed, Skeleton } from "../../primitives/notice/Notice.js";
21
24
  import { PivotTable } from "../../primitives/table/PivotTable.js";
@@ -25,7 +28,7 @@ import { groupedColumnIds, WIDE_PRESENTS } from "./columns.js";
25
28
  import { groupLevelsOf, reportColumnsOf, reportRowsOf, sheetFromColumns, sheetRowsOf, } from "./derive.js";
26
29
  import { SheetPresentation, TablePresentation, } from "./presentations.js";
27
30
  import { useNarrowList } from "./useNarrowList.js";
28
- import { CalendarDays, CalendarRange, ChartColumnBig, ChartGantt, Grid3x3, LayoutGrid, List, Sheet, Sigma, Table2, } from "lucide-react";
31
+ import { CalendarDays, CalendarRange, ChartColumnBig, ChartGantt, Grid3x3, LayoutGrid, List, Sheet, Sigma, Table2, X, } from "lucide-react";
29
32
  import { Fragment, lazy, Suspense, useCallback, useMemo } from "react";
30
33
  /* The calendar (FullCalendar) and the gantt (SVAR) are each about a third of a list's weight,
31
34
  and most lists never show either face. Each is its own chunk, fetched the first time its
@@ -82,7 +85,7 @@ const PRESENT_ICONS = [
82
85
  { id: "gantt", icon: ChartGantt },
83
86
  { id: "timeline", icon: CalendarRange },
84
87
  ];
85
- export function ListView({ items, keyOf, identity, crumbs, embedded = false, surface: requestedSurface, metrics, search, pagination, views, actions, row, rowHeader, columns, visibleColumnIds, onVisibleColumnIdsChange, card, boardStages, calendar, gantt, timeline, sheet, report, pivot, chart, faces, present: requested = "rows", presents, onPresentChange, sort, onSortChange, sortable, totals = false, rowActions, create, group, selection, onOpen, onPeek, rowClick = "peek", onChoose, state, filtered = false, empty, children, }) {
88
+ export function ListView({ items, keyOf, identity, crumbs, embedded = false, surface: requestedSurface, metrics, search, pagination, views, actions: written, dock, row, rowHeader, columns, visibleColumnIds, onVisibleColumnIdsChange, card, boardStages, calendar, gantt, timeline, sheet, report, pivot, chart, faces, present: requested = "rows", presents, onPresentChange, sort, onSortChange, sortable, totals = false, rowActions, create, group, selection, onOpen, onPeek, rowClick = "peek", onChoose, state, filtered = false, empty, children, }) {
86
89
  const wide = useMemo(() => [
87
90
  ...WIDE_PRESENTS,
88
91
  ...(faces ?? []).filter((f) => f.wide === true).map((f) => f.id),
@@ -93,6 +96,7 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
93
96
  navy switcher inside a white sheet would be a second chrome on the screen. */
94
97
  const surface = embedded ? undefined : requestedSurface;
95
98
  const density = useDensity();
99
+ const viewStyle = useViewStyle();
96
100
  const copy = useUiCopy();
97
101
  const loading = state?.loading === true;
98
102
  const refreshing = state?.refreshing === true && !loading;
@@ -166,6 +170,23 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
166
170
  present === "chart" ? null : (_jsx(SortMenu, { fields: sortable, sort: sort ?? [], onSortChange: (next) => onSortChange?.(next), ...(surface === undefined ? {} : { surface }) }));
167
171
  const rightViews = views ?? switcher;
168
172
  const viewsSlot = columnsMenu === null && sortMenu === null && rightViews === undefined ? undefined : (_jsxs(_Fragment, { children: [sortMenu, columnsMenu, rightViews] }));
173
+ /* THE DOCK: the list's actions and what is done to the chosen rows, from the
174
+ same data. Where they go is the view style's: `traditional` draws them as the bar's buttons
175
+ (the primary first and gold, «⋯» with the rest), and the chosen rows' in the bar in place of
176
+ the search; `modern` floats ONE pill at the bottom, centred, as a record does — the list's
177
+ actions, and while rows are chosen, what is done to them instead («3 elegidas ✕ · …»). */
178
+ const dockAt = dock?.placement ?? (viewStyle === "modern" ? "bottom" : "bar");
179
+ const chosen = selection?.count ?? 0;
180
+ const selectionDock = dock?.selection === undefined || selection === undefined || chosen === 0
181
+ ? undefined
182
+ : dock.selection;
183
+ const floatsChosen = selectionDock !== undefined && (dock?.selectionPlacement ?? dockAt) === "bottom";
184
+ const listPill = dock?.actions === undefined ? undefined : (_jsx(ActionDock, { placement: dockAt === "bottom" ? "bottom" : "inline", actions: dock.actions, look: dock.look ?? (dockAt === "bottom" ? "chrome" : "bare"), ...(dock.visible === undefined ? {} : { visible: dock.visible }), ...(dock.label === undefined ? {} : { label: dock.label }) }));
185
+ const actions = dock?.actions === undefined ? written : dockAt === "bar" ? listPill : undefined;
186
+ const chosenLead = selection === undefined ? null : (_jsx(DockCount, { count: chosen, onClear: selection.clear, ...(selection.matching === undefined ? {} : { matching: selection.matching }) }));
187
+ const chosenPill = selectionDock === undefined ? null : (_jsx(ActionDock, { placement: floatsChosen ? "bottom" : "inline", actions: selectionDock, lead: chosenLead, look: dock?.look ?? (floatsChosen ? "chrome" : "bare"), ...(dock?.visible === undefined ? {} : { visible: dock.visible }), label: dock?.selectionLabel ?? copy.selection.more }));
188
+ /* At the bottom there is ONE pill: the chosen rows' while some are chosen, else the list's. */
189
+ const floating = floatsChosen ? chosenPill : dockAt === "bottom" ? listPill : null;
169
190
  /* Embedded, the line is drawn only if it has something to OFFER: a count alone repeats
170
191
  what the rows (and the footer) already say. */
171
192
  const barHasControls = !embedded ||
@@ -175,20 +196,29 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
175
196
  actions !== undefined ||
176
197
  pagination !== undefined ||
177
198
  (selection?.count ?? 0) > 0;
199
+ /* The chosen rows' pill floats: the bar keeps its search, and does not say the count. */
200
+ const barSelection = floatsChosen ? undefined : selection;
178
201
  const bar = !barHasControls ? undefined : (_jsx(ListingBar, { surface: surface, ...(embedded ? { inline: true, count: items.length } : {}), ...(embedded || crumbs === undefined || crumbs.length === 0 || density === "compact"
179
202
  ? {}
180
203
  : {
181
204
  crumbs: (_jsx(Breadcrumb, { crumbs: crumbs, ...(surface === undefined ? {} : { surface }) })),
182
- }), ...(actions === undefined ? {} : { actions }), ...(identity?.title === undefined ? {} : { title: identity.title }), ...(identity?.description === undefined ? {} : { description: identity.description }), ...(identity?.counters === undefined ? {} : { counters: identity.counters }), ...(selection === undefined
205
+ }), ...(actions === undefined ? {} : { actions }), ...(identity?.title === undefined ? {} : { title: identity.title }), ...(identity?.description === undefined ? {} : { description: identity.description }), ...(identity?.counters === undefined ? {} : { counters: identity.counters }), ...(barSelection === undefined
183
206
  ? {}
184
- : {
185
- selection: {
186
- count: selection.count,
187
- onClear: selection.clear,
188
- ...(selection.actions === undefined ? {} : { actions: selection.actions }),
189
- ...(selection.matching === undefined ? {} : { matching: selection.matching }),
190
- },
191
- }), ...(search === undefined ? {} : { search }), ...(pagination === undefined ? {} : { pagination }), ...(viewsSlot === undefined ? {} : { views: viewsSlot }) }));
207
+ : selectionDock !== undefined
208
+ ? /* In the bar: the pill IS the count and the actions. */
209
+ { selection: { count: barSelection.count, actions: chosenPill } }
210
+ : {
211
+ selection: {
212
+ count: barSelection.count,
213
+ onClear: barSelection.clear,
214
+ ...(barSelection.actions === undefined
215
+ ? {}
216
+ : { actions: barSelection.actions }),
217
+ ...(barSelection.matching === undefined
218
+ ? {}
219
+ : { matching: barSelection.matching }),
220
+ },
221
+ }), ...(search === undefined ? {} : { search }), ...(pagination === undefined ? {} : { pagination }), ...(viewsSlot === undefined ? {} : { views: viewsSlot }) }));
192
222
  /* The body of a row, a card: the look first unless the list says the page. */
193
223
  /* Choosing, the press chooses and the ways in (👁 ↗) are not offered: a chooser's row answers. */
194
224
  const choosing = onChoose !== undefined;
@@ -281,7 +311,7 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
281
311
  : nodes(pile.items), open ? footOf(pile) : null] }, key));
282
312
  });
283
313
  }
284
- const reportRows = useMemo(() => reportRowsOf(piles, columns, row), [piles, columns, row]);
314
+ const reportRows = useMemo(() => reportRowsOf(piles, columns, row, copy.report.total), [piles, columns, row, copy.report.total]);
285
315
  function wrapGroups(nodes) {
286
316
  if (piles === null)
287
317
  return nodes(ordered);
@@ -395,7 +425,16 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
395
425
  ? {}
396
426
  : { action: empty.whenFiltered.action }) })) : (_jsx(Empty, { sentence: empty?.sentence ?? copy.list.empty, ...(empty?.action === undefined ? {} : { action: empty.action }) }))) : null, _jsxs("div", { className: "relative min-w-0", children: [refreshing ? (
397
427
  /* Over the top edge of the rows, not above them: the rows do not move. */
398
- _jsx("div", { className: "pointer-events-none absolute inset-x-0 top-0 z-20", children: _jsx(ProgressBar, { label: copy.list.refreshing, width: "w-full" }) })) : null, loading || isEmpty ? null : body] })] }), error === null ? null : (_jsx("div", { className: "px-3 pt-(--spacing-block)", children: _jsx(Failed, { heading: copy.failed.list, sentence: error }) })), children] }));
428
+ _jsx("div", { className: "pointer-events-none absolute inset-x-0 top-0 z-20", children: _jsx(ProgressBar, { label: copy.list.refreshing, width: "w-full" }) })) : null, loading || isEmpty ? null : body] })] }), error === null ? null : (_jsx("div", { className: "px-3 pt-(--spacing-block)", children: _jsx(Failed, { heading: copy.failed.list, sentence: error }) })), floating, children] }));
429
+ }
430
+ /** «3 elegidas ✕» at the start of the chosen rows' pill, on the pill's band — and «Elegir los
431
+ * 187 que coinciden» while only the page is chosen. */
432
+ function DockCount({ count, onClear, matching, }) {
433
+ const copy = useUiCopy();
434
+ const sup = useSurface();
435
+ return (_jsxs(_Fragment, { children: [_jsxs("span", { className: `inline-flex h-(--size-control-md) items-center gap-1.5 rounded-pill pr-1 pl-3 text-meta font-medium ${bySurface(sup, "bg-ink/8 text-ink", "bg-chrome-ink/14 text-chrome-ink")}`, children: [_jsx("span", { className: "tabular-nums", children: count.toLocaleString(copy.locale) }), copy.selection.chosen, _jsx("button", { type: "button", onClick: onClear, "aria-label": copy.selection.clear, title: copy.selection.clear, className: `inline-flex size-6 items-center justify-center rounded-pill transition-colors duration-(--duration-instant) ${bySurface(sup, "hover:bg-ink/10", "hover:bg-chrome-ink/20")}`, children: _jsx(X, { className: "size-3.5", strokeWidth: 2.5, "aria-hidden": true }) })] }), matching === undefined || matching.total <= count ? null : (_jsx("button", { type: "button", onClick: matching.onSelect, className: `rounded-pill px-2 text-meta font-medium underline-offset-4 hover:underline ${bySurface(sup, "text-primary", "text-chrome-link")}`, children: fillCopy(copy.selection.allMatching, {
436
+ count: matching.total.toLocaleString(copy.locale),
437
+ }) }))] }));
399
438
  }
400
439
  /** What a list offers when it fails and can be retried. */
401
440
  export function RetryAction({ onRetry }) {
@@ -73,7 +73,7 @@ export declare function sheetRowsOf<T extends object>(piles: readonly Pile<T>[]
73
73
  * are the same ones the table's footer sums — so the report and the table
74
74
  * do not give different totals for the same set.
75
75
  */
76
- export declare function reportRowsOf<T extends object>(piles: readonly Pile<T>[] | null, columns: readonly DataColumn<T>[] | undefined, row: (item: T) => RowOf): readonly ReportRow[];
76
+ export declare function reportRowsOf<T extends object>(piles: readonly Pile<T>[] | null, columns: readonly DataColumn<T>[] | undefined, row: (item: T) => RowOf, totalLabel?: string): readonly ReportRow[];
77
77
  /**
78
78
  * The columns of a report built from the piles, written like the list's own columns.
79
79
  *
@@ -1,5 +1,5 @@
1
- import { levelKey, pathKey, pileItems, pileLabel, } from "../../foundations/grouping.js";
2
- import { aggregateFormat, aggregateOf, aggregateText, } from "../../primitives/table/DataTable.js";
1
+ import { levelKey, pathKey, pileCount, pileItems, pileLabel, } from "../../foundations/grouping.js";
2
+ import { aggregateFormat, aggregateOf, aggregateText, pileAggregate, } from "../../primitives/table/DataTable.js";
3
3
  /**
4
4
  * Context: what a list DERIVES from its set, as pure functions — the table's group levels,
5
5
  * the sheet drawn from the declared columns, the sheet's flattened band/row sequence and
@@ -101,7 +101,6 @@ export function sheetRowsOf(piles, isOpen, columns) {
101
101
  const walk = (list) => {
102
102
  for (const pile of list) {
103
103
  const open = isOpen(pile);
104
- const inside = pile.piles.length === 0 ? pile.items : pileItems(pile.piles);
105
104
  out.push({
106
105
  band: {
107
106
  field: pile.field,
@@ -118,7 +117,9 @@ export function sheetRowsOf(piles, isOpen, columns) {
118
117
  `format`, so the bucket does not say «78752,9» under «Bs.». */
119
118
  total: (column) => {
120
119
  const declared = columns?.find((one) => one.id === column.id);
121
- const value = declared === undefined ? null : aggregateOf(declared, inside);
120
+ /* What the server summed, else the rows' sum when the pile holds them all — the
121
+ same number the table's pile row says (`pileAggregate`). */
122
+ const value = declared === undefined ? null : pileAggregate(declared, pile);
122
123
  return declared === undefined || value === null
123
124
  ? null
124
125
  : aggregateText(declared, value);
@@ -150,7 +151,7 @@ export function sheetRowsOf(piles, isOpen, columns) {
150
151
  * are the same ones the table's footer sums — so the report and the table
151
152
  * do not give different totals for the same set.
152
153
  */
153
- export function reportRowsOf(piles, columns, row) {
154
+ export function reportRowsOf(piles, columns, row, totalLabel) {
154
155
  if (piles === null || columns === undefined)
155
156
  return [];
156
157
  const numeric = columns.filter((column) => column.aggregate !== undefined);
@@ -158,8 +159,11 @@ export function reportRowsOf(piles, columns, row) {
158
159
  person reads in the table — not by the field's id: «stage · pedido» showed the
159
160
  model's name for it. */
160
161
  const fieldName = (field) => columns.find((column) => column.id === field || column.field === field)?.header ?? field;
162
+ /* Every pile is a GROUP — it opens and closes, and it says what it adds up to under each
163
+ column, the number the table's pile row says (`pileAggregate`). A `section` was tried for
164
+ the first level and it drew no amounts: a section is a title over what comes below
165
+ («Activos»), and a pile IS a sum. */
161
166
  const line = (pile) => {
162
- const inside = pile.piles.length === 0 ? pile.items : pileItems(pile.piles);
163
167
  const children = pile.piles.length > 0
164
168
  ? pile.piles.map(line)
165
169
  : pile.items.map((item, index) => ({
@@ -175,13 +179,45 @@ export function reportRowsOf(piles, columns, row) {
175
179
  return {
176
180
  id: pathKey(pile.path),
177
181
  label: `${fieldName(pile.field)} · ${pile.label}`,
178
- kind: pile.depth === 0 ? "section" : "group",
182
+ kind: "group",
179
183
  level: pile.depth,
180
- values: numeric.map((column) => aggregateOf(column, inside)),
184
+ values: numeric.map((column) => pileAggregate(column, pile)),
181
185
  children,
182
186
  };
183
187
  };
184
- return piles.map(line);
188
+ const lines = piles.map(line);
189
+ if (totalLabel === undefined || lines.length === 0)
190
+ return lines;
191
+ /* The line that closes the report: what every pile adds up to, combined from the piles'
192
+ own numbers — so it holds when the piles were counted by the server. */
193
+ const total = {
194
+ id: "\u0000total",
195
+ label: totalLabel,
196
+ kind: "total",
197
+ level: 0,
198
+ values: numeric.map((column, at) => {
199
+ const each = lines.map((one) => one.values[at] ?? null);
200
+ if (each.some((value) => value === null))
201
+ return null;
202
+ const known = each;
203
+ switch (column.aggregate) {
204
+ case "sum":
205
+ case "count":
206
+ return known.reduce((a, b) => a + b, 0);
207
+ case "max":
208
+ return Math.max(...known);
209
+ case "min":
210
+ return Math.min(...known);
211
+ default: {
212
+ /* A mean of means is not the mean, nor a count of distinct values a sum: over the
213
+ rows, when the piles hold them all. */
214
+ const items = pileItems(piles);
215
+ return items.length < pileCount(piles) ? null : aggregateOf(column, items);
216
+ }
217
+ }
218
+ }),
219
+ };
220
+ return [...lines, total];
185
221
  }
186
222
  /**
187
223
  * The columns of a report built from the piles, written like the list's own columns.
@@ -6,6 +6,8 @@ import type { ListIdentity } from "../../components/listing/ListingBar.js";
6
6
  import type { ListPresent } from "../../components/listing/set.js";
7
7
  import type { SortField } from "../../components/listing/SortMenu.js";
8
8
  import type { ViewIcon } from "../../components/listing/ViewSwitcher.js";
9
+ import type { DockLook } from "../../components/record/ActionDock.js";
10
+ import type { DockAction } from "../../components/record/dock.js";
9
11
  import type { RecordTimelineProps } from "../../components/timeline/RecordTimeline.js";
10
12
  import type { ChartKind, ChartOrder } from "../../foundations/chart.js";
11
13
  import type { GroupableField } from "../../foundations/grouping.js";
@@ -262,6 +264,35 @@ export type ListChart<T> = {
262
264
  /** The name it is downloaded under. */
263
265
  fileName?: string;
264
266
  };
267
+ /**
268
+ * A list's actions FLOATING (`List.Dock`, the record's `ActionDock`): what the
269
+ * list starts, as a pill in its bar, and what is done to the chosen rows, as a pill floating at
270
+ * the bottom while some are chosen («3 elegidas ✕ · Enviar · Imprimir ▾ · ⋯») — the search
271
+ * stays in the bar.
272
+ */
273
+ export type ListDock = {
274
+ /** What the list starts or does to the whole set — «Nuevo» (the primary), «Importar»,
275
+ * «Exportar ▸» —, in place of `List.Actions`. */
276
+ actions?: readonly DockAction[];
277
+ /** What is done to the CHOSEN rows — «Enviar», «Imprimir ▸», «Archivar». Give the list a
278
+ * `selection` too. */
279
+ selection?: readonly DockAction[];
280
+ /** Where the actions go: the BAR's buttons, or ONE pill floating at the BOTTOM, centred — the
281
+ * list's actions, and the chosen rows' while some are chosen. Absent, the view style decides
282
+ * (`ViewStyleProvider`): `traditional` → `bar`, `modern` → `bottom`. */
283
+ placement?: "bar" | "bottom";
284
+ /** Where the chosen rows' actions go when it is not where `placement` puts them: the BAR in
285
+ * place of the search, or floating at the BOTTOM while the search stays in the bar. */
286
+ selectionPlacement?: "bottom" | "bar";
287
+ /** The pill's band — `chrome` (dark) or `canvas` (light) — or `bare`, the bar's buttons. By
288
+ * default `bare` in the bar and `chrome` floating. */
289
+ look?: DockLook;
290
+ /** How many secondary actions each pill shows before «Más». */
291
+ visible?: number;
292
+ /** The toolbars' names: «Acciones de las facturas», «Acciones de las elegidas». */
293
+ label?: string;
294
+ selectionLabel?: string;
295
+ };
265
296
  export type ListViewProps<T extends object> = {
266
297
  items: readonly T[];
267
298
  keyOf: (item: T) => string;
@@ -287,6 +318,8 @@ export type ListViewProps<T extends object> = {
287
318
  /** Escape hatch: a custom switcher. Prefer `presents` so the archetype draws it. */
288
319
  views?: ReactNode;
289
320
  actions?: ReactNode;
321
+ /** The actions floating: see `ListDock`. */
322
+ dock?: ListDock;
290
323
  row: (item: T) => RowOf;
291
324
  /**
292
325
  * The labels of a row's zones, above all of them. Without this there is no
@@ -1,12 +1,14 @@
1
1
  import { type ActivityProps } from "../../components/activity/Activity.js";
2
2
  import { type SheetField, type SheetLayout } from "../../components/form/Sheet.js";
3
+ import type { RecordDockProps } from "../../components/record/ActionDock.js";
3
4
  import type { Crumb } from "../../components/record/Breadcrumb.js";
4
5
  import type { DirtyState } from "../../components/record/DirtyActions.js";
5
6
  import { type RecordStamp } from "../../components/record/RecordAudit.js";
6
7
  import { type RecordNoticeSpec } from "../../components/record/RecordNotices.js";
7
8
  import { RecordSkeleton } from "../../components/record/RecordSkeleton.js";
8
- import { type Stage } from "../../components/record/StatusBar.js";
9
+ import { type Stage, type StatusLook } from "../../components/record/StatusBar.js";
9
10
  import type { Surface, Tone } from "../../foundations/types.js";
11
+ import { type ViewStyle } from "../../foundations/viewStyle.js";
10
12
  import { type TabNotice } from "../../primitives/tabs/Tabs.js";
11
13
  import type { LucideIcon } from "lucide-react";
12
14
  import { type ReactNode } from "react";
@@ -43,6 +45,11 @@ export type RecordPager = {
43
45
  total: number;
44
46
  onPrev?: () => void;
45
47
  onNext?: () => void;
48
+ /** The combinations that move — Alt+P and Alt+N by default, `false` for none. */
49
+ keys?: {
50
+ prev: string;
51
+ next: string;
52
+ } | false;
46
53
  };
47
54
  export type { SheetField };
48
55
  /** A notice of the record: the props of `Record.Notice` (a `Callout` without its × label,
@@ -71,6 +78,9 @@ type StatusProps = {
71
78
  failed?: boolean;
72
79
  /** The stages can be chosen: pressing one moves the record there (a CRM's pipeline). */
73
80
  onSelect?: (id: string) => void;
81
+ /** Which widget draws it (`StatusLook`). Absent: `segmented` in the modern style, `track`
82
+ * (Odoo's) in the traditional one. */
83
+ look?: StatusLook;
74
84
  /** The status escape hatch, for whatever is neither of the two. */
75
85
  children?: ReactNode;
76
86
  };
@@ -145,9 +155,12 @@ export type RecordProps = {
145
155
  * whole tree under the paper the moment one of them appears or goes away.
146
156
  */
147
157
  placement?: "page" | "card";
158
+ /** How this record is drawn — `traditional` or `modern`. Absent, the
159
+ * `ViewStyleProvider`'s: an application chooses once. */
160
+ look?: ViewStyle;
148
161
  children?: ReactNode;
149
162
  };
150
- export declare function Record({ identity, error, dirty, placement, children }: RecordProps): import("react").JSX.Element;
163
+ export declare function Record({ identity, error, dirty, placement, look: ownLook, children, }: RecordProps): import("react").JSX.Element;
151
164
  export declare namespace Record {
152
165
  var Skeleton: typeof RecordSkeleton;
153
166
  var Rail: ((props: RailProps) => ReactNode) & import("../../foundations/slots.js").Slotted<"rail">;
@@ -155,6 +168,7 @@ export declare namespace Record {
155
168
  var Pager: ((props: RecordPager) => ReactNode) & import("../../foundations/slots.js").Slotted<"pager">;
156
169
  var Smart: ((props: SmartProps) => ReactNode) & import("../../foundations/slots.js").Slotted<"smart">;
157
170
  var Actions: ((props: ActionsProps) => ReactNode) & import("../../foundations/slots.js").Slotted<"actions">;
171
+ var Dock: ((props: RecordDockProps) => ReactNode) & import("../../foundations/slots.js").Slotted<"dock">;
158
172
  var Status: ((props: StatusProps) => ReactNode) & import("../../foundations/slots.js").Slotted<"status">;
159
173
  var Paper: ((props: PaperProps) => ReactNode) & import("../../foundations/slots.js").Slotted<"paper">;
160
174
  var Activity: ((props: RecordActivityProps) => ReactNode) & import("../../foundations/slots.js").Slotted<"activity">;
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { Activity } from "../../components/activity/Activity.js";
4
+ import { FormSection } from "../../components/form/Form.js";
4
5
  import { Sheet, } from "../../components/form/Sheet.js";
5
6
  import { Pager as PagerControl } from "../../components/record/Pager.js";
6
7
  import { RecordAudit } from "../../components/record/RecordAudit.js";
@@ -9,10 +10,12 @@ import { RecordBlocking, RecordNoticeIndicator, splitNotices, } from "../../comp
9
10
  import { RecordRibbon } from "../../components/record/RecordRibbon.js";
10
11
  import { RecordSkeleton } from "../../components/record/RecordSkeleton.js";
11
12
  import { SmartButton, SmartButtons } from "../../components/record/SmartButtons.js";
12
- import { StatusBar } from "../../components/record/StatusBar.js";
13
+ import { StatusBar, } from "../../components/record/StatusBar.js";
13
14
  import { useUiCopy } from "../../foundations/copy.js";
14
15
  import { byDensity, useDensity } from "../../foundations/density.js";
16
+ import { useFormStyle } from "../../foundations/form.js";
15
17
  import { flatten, pick as pickSlot, pickAll, propsOf, slot, slotOf, } from "../../foundations/slots.js";
18
+ import { useViewStyle } from "../../foundations/viewStyle.js";
16
19
  import { createNoteRegistry, NoteRegistryContext, } from "../../primitives/field/note.js";
17
20
  import { Tabs, TabsPanel, TabsScope, } from "../../primitives/tabs/Tabs.js";
18
21
  import { useEffect, useId, useState, useSyncExternalStore } from "react";
@@ -32,6 +35,7 @@ const Smart = slot("smart", (_props) => null);
32
35
  * where the thumb is — and with `dirty`, Save and Discard take that bar instead. The
33
36
  * rest stay here. Nothing to declare: see THE THUMB BAR in `RecordHeader`. */
34
37
  const Actions = slot("actions", (_props) => null);
38
+ const Dock = slot("dock", (_props) => null);
35
39
  /** The status, as DATA and not as a node: the bar lives in the rail and
36
40
  * whoever passed it already built had to remember the rail's surface. Forgetting it
37
41
  * painted the canvas palette on top of the chrome, and it happened. */
@@ -72,8 +76,10 @@ const Page = slot("page", (_props) => null);
72
76
  function NotebookScope({ tabs, children }) {
73
77
  return tabs ? _jsx(TabsScope, { children: children }) : children;
74
78
  }
75
- export function Record({ identity, error = null, dirty, placement, children }) {
79
+ export function Record({ identity, error = null, dirty, placement, look: ownLook, children, }) {
80
+ const look = useViewStyle(ownLook);
76
81
  const d = useDensity();
82
+ const formStyle = useFormStyle();
77
83
  const copy = useUiCopy();
78
84
  const top = flatten(children);
79
85
  const railNode = pick(top, "rail");
@@ -87,6 +93,7 @@ export function Record({ identity, error = null, dirty, placement, children }) {
87
93
  const pager = propsOf(pick(rail, "pager"));
88
94
  const smart = propsOf(pick(rail, "smart"))?.links;
89
95
  const actions = propsOf(pick(rail, "actions"))?.children;
96
+ const dock = propsOf(pick(rail, "dock"));
90
97
  const status = propsOf(pick(rail, "status"));
91
98
  /* The status's two questions, with the surface already resolved: «¿dónde
92
99
  está?» and «¿qué pasó para llegar acá?». */
@@ -104,7 +111,11 @@ export function Record({ identity, error = null, dirty, placement, children }) {
104
111
  /* Stacked in one block: above where it is, below what happened to get there.
105
112
  Side by side they competed for width with the buttons and both ended up
106
113
  truncated; one under the other, each has its whole line. */
107
- _jsxs("div", { className: "flex min-w-0 flex-col items-end gap-1.5", children: [status.stages === undefined ? null : (_jsx(StatusBar, { stages: status.stages, current: status.current ?? status.stages[0]?.id ?? "", failed: status.failed ?? false, surface: surface, ...(status.onSelect === undefined ? {} : { onSelect: status.onSelect }) })), status.children] }));
114
+ _jsxs("div", { className: "flex min-w-0 flex-col items-end gap-1.5", children: [status.stages === undefined ? null : (_jsx(StatusBar, { stages: status.stages, current: status.current ?? status.stages[0]?.id ?? "", failed: status.failed ?? false, surface: surface, ...(status.look !== undefined
115
+ ? { look: status.look }
116
+ : look === "modern"
117
+ ? { look: "segmented" }
118
+ : {}), ...(status.onSelect === undefined ? {} : { onSelect: status.onSelect }) })), status.children] }));
108
119
  const paper = propsOf(paperNode);
109
120
  const inPaper = [...flatten(paper?.children), ...loose];
110
121
  const fields = propsOf(pick(inPaper, "facts"))?.fields;
@@ -143,7 +154,16 @@ export function Record({ identity, error = null, dirty, placement, children }) {
143
154
  }, [reveal, alertsId]);
144
155
  const notebook = propsOf(pick(inPaper, "pages"));
145
156
  const pages = flatten(notebook?.children).filter((node) => slotOf(node) === "page");
146
- const tabs = pages
157
+ /* «sections» (`FormStyleProvider`): the notebook's pages are not tabs but CARDS, one under
158
+ the other, found by the index — the long record read top to bottom, nothing hidden
159
+ behind a tab. */
160
+ const sectioned = formStyle === "sections";
161
+ const pageCards = sectioned
162
+ ? pages
163
+ .map((node) => propsOf(node))
164
+ .filter((page) => page !== undefined)
165
+ : [];
166
+ const tabs = (sectioned ? [] : pages)
147
167
  .map((node) => propsOf(node))
148
168
  .filter((page) => page !== undefined)
149
169
  .map(({ id, label, icon, count, notice }) => ({
@@ -181,11 +201,15 @@ export function Record({ identity, error = null, dirty, placement, children }) {
181
201
  }), ...(paper?.width === undefined ? {} : { width: paper.width }), ...(dirty === undefined ? {} : { dirty }), ...(crumbs === undefined ? {} : { crumbs }), ...(pager === undefined
182
202
  ? {}
183
203
  : {
184
- pager: (_jsx(PagerControl, { index: pager.index, total: pager.total, surface: surface, ...(pager.onPrev === undefined ? {} : { onPrev: pager.onPrev }), ...(pager.onNext === undefined ? {} : { onNext: pager.onNext }) })),
185
- }), ...(actions === undefined ? {} : { actions }), ...(statusBlock === undefined ? {} : { status: statusBlock }), ...(identity.icon === undefined ? {} : { icon: identity.icon }), title: identity.title, ...(identity.subtitle === undefined ? {} : { subtitle: identity.subtitle }), ...(identity.figure === undefined ? {} : { figure: identity.figure }), ...(identity.tag === undefined ? {} : { tag: identity.tag }), ...(smart === undefined || smart.length === 0
204
+ pager: (_jsx(PagerControl, { index: pager.index, total: pager.total, surface: surface, ...(pager.onPrev === undefined ? {} : { onPrev: pager.onPrev }), ...(pager.onNext === undefined ? {} : { onNext: pager.onNext }), ...(pager.keys === undefined ? {} : { keys: pager.keys }),
205
+ /* The modern style's position stands out: a translucent pill. */
206
+ look: look === "modern" ? "pill" : "plain" })),
207
+ }), ...(actions === undefined ? {} : { actions }), ...(dock === undefined ? {} : { dock }), look: look, ...(statusBlock === undefined ? {} : { status: statusBlock }), ...(identity.icon === undefined ? {} : { icon: identity.icon }), title: identity.title, ...(identity.subtitle === undefined ? {} : { subtitle: identity.subtitle }), ...(identity.figure === undefined ? {} : { figure: identity.figure }), ...(identity.tag === undefined ? {} : { tag: identity.tag }), ...(smart === undefined || smart.length === 0
186
208
  ? {}
187
209
  : {
188
- smart: (_jsx(SmartButtons, { children: smart.map((s) => (_jsx(SmartButton, { icon: s.icon, ...(s.count === undefined ? {} : { count: s.count }), label: s.label, layout: onTheRail && d === "comfortable" ? "inline" : "stacked", ...(s.onClick === undefined ? {} : { onClick: s.onClick }) }, s.label))) })),
210
+ smart: (_jsx(SmartButtons, { children: smart.map((s) => (_jsx(SmartButton, { icon: s.icon, ...(s.count === undefined ? {} : { count: s.count }), label: s.label, layout: onTheRail && d === "comfortable" ? "inline" : "stacked",
211
+ /* The modern style's counters read as ways to another place. */
212
+ look: look === "modern" ? "link" : "box", ...(s.onClick === undefined ? {} : { onClick: s.onClick }) }, s.label))) })),
189
213
  }), ...(aspectsNode === undefined || globalSheet ? {} : { aspects: aspectsNode }), ...(activitySlot === undefined
190
214
  ? {}
191
215
  : {
@@ -215,7 +239,7 @@ export function Record({ identity, error = null, dirty, placement, children }) {
215
239
  ? {
216
240
  head: (_jsxs(_Fragment, { children: [above, globalSheet && aspectsNode !== undefined ? (_jsx("div", { className: `border-b border-line-strong ${byDensity(d, "-mx-4 px-4", "")}`, children: aspectsNode })) : null] })),
217
241
  }
218
- : {}), children: [tabs.length === 0 ? (pageBody) : (_jsx(TabsPanel, { id: current, className: `flex min-w-0 flex-col ${byDensity(d, "gap-(--spacing-block)", "gap-2.5")}`, children: pageBody })), below] }) }), audit === undefined ? null : _jsx(RecordAudit, { ...audit })] }) }) }) }) }));
242
+ : {}), children: [sectioned ? (pageCards.map((page) => (_jsx(FormSection, { title: page.label, children: page.children }, page.id)))) : tabs.length === 0 ? (pageBody) : (_jsx(TabsPanel, { id: current, className: `flex min-w-0 flex-col ${byDensity(d, "gap-(--spacing-block)", "gap-2.5")}`, children: pageBody })), below] }) }), audit === undefined ? null : _jsx(RecordAudit, { ...audit })] }) }) }) }) }));
219
243
  }
220
244
  Record.Skeleton = RecordSkeleton;
221
245
  Record.Rail = Rail;
@@ -223,6 +247,7 @@ Record.Crumbs = Crumbs;
223
247
  Record.Pager = PagerSlot;
224
248
  Record.Smart = Smart;
225
249
  Record.Actions = Actions;
250
+ Record.Dock = Dock;
226
251
  Record.Status = Status;
227
252
  Record.Paper = Paper;
228
253
  Record.Activity = ActivitySlot;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sincpro/web-ui",
3
- "version": "2.7.0",
3
+ "version": "2.9.0",
4
4
  "description": "An enterprise web design system for business software — ERPs, back offices, management tools — in React and Tailwind: tokens, primitives, components and the two views every management screen is made of.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",