@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.
- package/README.md +152 -3
- package/dist/components/activity/Activity.js +3 -2
- package/dist/components/board/Board.d.ts +2 -1
- package/dist/components/board/Board.js +17 -1
- package/dist/components/form/Form.js +12 -3
- package/dist/components/form/FormIndex.d.ts +5 -1
- package/dist/components/form/FormIndex.js +71 -23
- package/dist/components/form/Sheet.js +22 -4
- package/dist/components/listing/ListingBar.d.ts +25 -1
- package/dist/components/listing/ListingBar.js +43 -14
- package/dist/components/listing/Pagination.d.ts +4 -1
- package/dist/components/listing/Pagination.js +19 -6
- package/dist/components/listing/modelCells.js +1 -9
- package/dist/components/record/ActionDock.d.ts +58 -0
- package/dist/components/record/ActionDock.js +69 -0
- package/dist/components/record/Breadcrumb.d.ts +3 -1
- package/dist/components/record/Breadcrumb.js +13 -5
- package/dist/components/record/DirtyActions.js +11 -1
- package/dist/components/record/Pager.d.ts +12 -10
- package/dist/components/record/Pager.js +39 -6
- package/dist/components/record/RecordHeader.d.ts +13 -1
- package/dist/components/record/RecordHeader.js +70 -25
- package/dist/components/record/SmartButtons.js +2 -2
- package/dist/components/record/StatusBar.d.ts +68 -1
- package/dist/components/record/StatusBar.js +218 -48
- package/dist/components/record/dock.d.ts +56 -0
- package/dist/components/record/dock.js +58 -0
- package/dist/components/record/index.d.ts +3 -1
- package/dist/components/record/index.js +5 -1
- package/dist/foundations/copy.d.ts +9 -0
- package/dist/foundations/copy.es.js +10 -1
- package/dist/foundations/copy.js +5 -0
- package/dist/foundations/form.d.ts +10 -1
- package/dist/foundations/grouping.d.ts +9 -0
- package/dist/foundations/index.d.ts +3 -1
- package/dist/foundations/index.js +8 -2
- package/dist/foundations/keys.d.ts +34 -0
- package/dist/foundations/keys.js +99 -0
- package/dist/foundations/shortcut.d.ts +17 -1
- package/dist/foundations/shortcut.js +57 -1
- package/dist/foundations/viewStyle.d.ts +8 -0
- package/dist/foundations/viewStyle.js +12 -0
- package/dist/primitives/choice/Switch.d.ts +4 -1
- package/dist/primitives/choice/Switch.js +2 -2
- package/dist/primitives/menu/Menu.d.ts +3 -0
- package/dist/primitives/menu/Menu.js +7 -1
- package/dist/primitives/table/DataTable.d.ts +29 -0
- package/dist/primitives/table/DataTable.js +84 -13
- package/dist/primitives/table/EditableTable.js +7 -2
- package/dist/primitives/table/RowActions.d.ts +5 -0
- package/dist/primitives/table/RowActions.js +27 -3
- package/dist/primitives/table/SheetTable.d.ts +3 -0
- package/dist/primitives/table/SheetTable.js +15 -2
- package/dist/primitives/table/index.d.ts +1 -1
- package/dist/primitives/value/Value.d.ts +5 -1
- package/dist/primitives/value/Value.js +9 -3
- package/dist/primitives/value/YesNo.d.ts +22 -0
- package/dist/primitives/value/YesNo.js +16 -0
- package/dist/primitives/value/index.d.ts +1 -0
- package/dist/primitives/value/index.js +1 -0
- package/dist/tokens.css +35 -2
- package/dist/views/list/List.d.ts +7 -2
- package/dist/views/list/List.js +12 -4
- package/dist/views/list/ListView.d.ts +1 -1
- package/dist/views/list/ListView.js +112 -17
- package/dist/views/list/derive.d.ts +1 -1
- package/dist/views/list/derive.js +45 -9
- package/dist/views/list/presentations.d.ts +2 -2
- package/dist/views/list/presentations.js +35 -3
- package/dist/views/list/types.d.ts +43 -0
- package/dist/views/list/useReachBottom.d.ts +15 -0
- package/dist/views/list/useReachBottom.js +55 -0
- package/dist/views/record/Record.d.ts +16 -2
- package/dist/views/record/Record.js +30 -7
- package/package.json +1 -1
package/dist/views/list/List.js
CHANGED
|
@@ -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. */
|
|
@@ -83,7 +85,7 @@ function facesOf(nodes) {
|
|
|
83
85
|
}
|
|
84
86
|
return faces;
|
|
85
87
|
}
|
|
86
|
-
export function List({ items, keyOf, embedded, surface, group, selection: selectWith, sort, onSortChange, sortable, present, onPresentChange, onOpen: openWith, onPeek: peekWith, isPeeked, readOnly = false, rowClick, onChoose, state, filtered, empty, children, }) {
|
|
88
|
+
export function List({ items, keyOf, embedded, surface, group, selection: selectWith, sort, onSortChange, sortable, present, onPresentChange, onOpen: openWith, onPeek: peekWith, isPeeked, openTargets, onOpenIn, readOnly = false, rowClick, onChoose, state, filtered, empty, children, }) {
|
|
87
89
|
const top = flatten(children);
|
|
88
90
|
const onOpen = readOnly ? undefined : openWith;
|
|
89
91
|
const onPeek = readOnly ? undefined : peekWith;
|
|
@@ -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. */
|
|
@@ -147,13 +150,18 @@ export function List({ items, keyOf, embedded, surface, group, selection: select
|
|
|
147
150
|
: { onVisibleColumnIdsChange: table.onVisibleColumnIdsChange }),
|
|
148
151
|
}), ...(board?.card === undefined ? {} : { card: board.card }), ...(board?.stages === undefined ? {} : { boardStages: board.stages }), ...(sheet?.columns === undefined || sheet.cell === undefined
|
|
149
152
|
? {}
|
|
150
|
-
: { sheet: sheet }), ...(report === undefined ? {} : { report }), ...(pivot === undefined ? {} : { pivot }), ...(chart === undefined ? {} : { chart }), ...(calendar === undefined ? {} : { calendar }), ...(gantt === undefined ? {} : { gantt }), ...(timeline === undefined ? {} : { timeline }), ...(faces.length === 0 ? {} : { faces }), ...(presents.length === 0 ? {} : { presents }), ...(present === undefined
|
|
153
|
+
: { sheet: sheet }), ...(report === undefined ? {} : { report }), ...(pivot === undefined ? {} : { pivot }), ...(chart === undefined ? {} : { chart }), ...(calendar === undefined ? {} : { calendar }), ...(gantt === undefined ? {} : { gantt }), ...(timeline === undefined ? {} : { timeline }), ...(faces.length === 0 ? {} : { faces }), ...(presents.length === 0 ? {} : { presents }), ...(present === undefined
|
|
154
|
+
? presents[0] === undefined
|
|
155
|
+
? {}
|
|
156
|
+
: { present: presents[0] }
|
|
157
|
+
: { present }), ...(onPresentChange === undefined ? {} : { onPresentChange }), ...(group === undefined ? {} : { group }), ...(selection === undefined ? {} : { selection }), ...(sort === undefined ? {} : { sort }), ...(onSortChange === undefined ? {} : { onSortChange }), ...(sortable === undefined ? {} : { sortable }), ...(onOpen === undefined ? {} : { onOpen }), ...(onPeek === undefined ? {} : { onPeek }), ...(isPeeked === undefined ? {} : { isPeeked }), ...(openTargets === undefined || readOnly ? {} : { openTargets }), ...(onOpenIn === undefined || readOnly ? {} : { onOpenIn }), ...(rowClick === undefined ? {} : { rowClick }), ...(onChoose === undefined || readOnly ? {} : { onChoose }), ...(state === undefined ? {} : { state }), ...(filtered === undefined ? {} : { filtered }), ...(empty === undefined ? {} : { empty }), children: rest.length === 0 ? undefined : rest }));
|
|
151
158
|
}
|
|
152
159
|
List.Bar = Bar;
|
|
153
160
|
List.Crumbs = Crumbs;
|
|
154
161
|
List.Identity = Identity;
|
|
155
162
|
List.Search = Search;
|
|
156
163
|
List.Actions = Actions;
|
|
164
|
+
List.Dock = Dock;
|
|
157
165
|
List.Pagination = Pagination;
|
|
158
166
|
List.Views = Views;
|
|
159
167
|
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, openTargets, onOpenIn, 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,23 +10,29 @@ 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, useDockHost } 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";
|
|
22
25
|
import { ReportTable } from "../../primitives/table/ReportTable.js";
|
|
26
|
+
import { Metric, Metrics } from "../../primitives/value/Metric.js";
|
|
23
27
|
import { ProgressBar } from "../../primitives/value/ProgressBar.js";
|
|
24
28
|
import { groupedColumnIds, WIDE_PRESENTS } from "./columns.js";
|
|
25
29
|
import { groupLevelsOf, reportColumnsOf, reportRowsOf, sheetFromColumns, sheetRowsOf, } from "./derive.js";
|
|
26
30
|
import { SheetPresentation, TablePresentation, } from "./presentations.js";
|
|
27
31
|
import { useNarrowList } from "./useNarrowList.js";
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
32
|
+
import { useReachBottom } from "./useReachBottom.js";
|
|
33
|
+
import { CalendarDays, CalendarRange, ChartColumnBig, ChartGantt, Grid3x3, LayoutGrid, List, Sheet, Sigma, Table2, X, } from "lucide-react";
|
|
34
|
+
import { Fragment, lazy, Suspense, useCallback, useEffect, useMemo, } from "react";
|
|
35
|
+
import { createPortal } from "react-dom";
|
|
30
36
|
/* The calendar (FullCalendar) and the gantt (SVAR) are each about a third of a list's weight,
|
|
31
37
|
and most lists never show either face. Each is its own chunk, fetched the first time its
|
|
32
38
|
face is SHOWN. `lazy` erases the generic, so the eager signature is put back: the props
|
|
@@ -82,7 +88,7 @@ const PRESENT_ICONS = [
|
|
|
82
88
|
{ id: "gantt", icon: ChartGantt },
|
|
83
89
|
{ id: "timeline", icon: CalendarRange },
|
|
84
90
|
];
|
|
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, }) {
|
|
91
|
+
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, openTargets, onOpenIn, rowClick = "peek", onChoose, state, filtered = false, empty, children, }) {
|
|
86
92
|
const wide = useMemo(() => [
|
|
87
93
|
...WIDE_PRESENTS,
|
|
88
94
|
...(faces ?? []).filter((f) => f.wide === true).map((f) => f.id),
|
|
@@ -93,6 +99,7 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
|
|
|
93
99
|
navy switcher inside a white sheet would be a second chrome on the screen. */
|
|
94
100
|
const surface = embedded ? undefined : requestedSurface;
|
|
95
101
|
const density = useDensity();
|
|
102
|
+
const viewStyle = useViewStyle();
|
|
96
103
|
const copy = useUiCopy();
|
|
97
104
|
const loading = state?.loading === true;
|
|
98
105
|
const refreshing = state?.refreshing === true && !loading;
|
|
@@ -166,6 +173,60 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
|
|
|
166
173
|
present === "chart" ? null : (_jsx(SortMenu, { fields: sortable, sort: sort ?? [], onSortChange: (next) => onSortChange?.(next), ...(surface === undefined ? {} : { surface }) }));
|
|
167
174
|
const rightViews = views ?? switcher;
|
|
168
175
|
const viewsSlot = columnsMenu === null && sortMenu === null && rightViews === undefined ? undefined : (_jsxs(_Fragment, { children: [sortMenu, columnsMenu, rightViews] }));
|
|
176
|
+
/* THE DOCK: the list's actions and what is done to the chosen rows, from the same data.
|
|
177
|
+
Where they go is the view style's: `traditional` draws them as the bar's buttons (the
|
|
178
|
+
primary first and gold, «⋯» with the rest), and the chosen rows' in the bar in place of the
|
|
179
|
+
search; `modern` floats ONE pill at the bottom of the screen, centred, as a record does —
|
|
180
|
+
named by the list it acts on («Pedidos │ Importar · Exportar ▾ · Nueva cotización»), so one
|
|
181
|
+
action is never a lone button in a ring —, and while rows are chosen, what is done to them
|
|
182
|
+
instead («3 elegidas ✕ │ …»). `placement="bar"` keeps a modern list's actions in its header.
|
|
183
|
+
|
|
184
|
+
A collection (`embedded`) is a field of the record, and the record owns the screen's ONE
|
|
185
|
+
floating place (`DockHost`): its own actions stay on its line, and what is done to its
|
|
186
|
+
chosen rows TAKES the record's place in the modern style — or goes to its line while the
|
|
187
|
+
record is saying Save / Discard, which keeps the place. Without a record that floats
|
|
188
|
+
(a dialog, the traditional style) it floats on its own, as a screen's list does. */
|
|
189
|
+
const host = useDockHost();
|
|
190
|
+
const modern = viewStyle === "modern";
|
|
191
|
+
const dockAt = dock?.placement ?? (modern && !embedded ? "bottom" : "bar");
|
|
192
|
+
const chosenAt = dock?.selectionPlacement ?? (modern ? "bottom" : "bar");
|
|
193
|
+
const intoHost = embedded && host !== null && chosenAt === "bottom";
|
|
194
|
+
const chosen = selection?.count ?? 0;
|
|
195
|
+
const selectionDock = dock?.selection === undefined || selection === undefined || chosen === 0
|
|
196
|
+
? undefined
|
|
197
|
+
: dock.selection;
|
|
198
|
+
const floatsChosen = selectionDock !== undefined && chosenAt === "bottom" && !(intoHost && host.dirty);
|
|
199
|
+
const taking = floatsChosen && intoHost;
|
|
200
|
+
/* ONE gold per screen, and inside a record it is the record's: on its own line a collection
|
|
201
|
+
draws its primary as the others. Taking the record's place, it is the only pill there is. */
|
|
202
|
+
const quiet = (actions) => actions.map((one) => (one.primary === true ? { ...one, primary: false } : one));
|
|
203
|
+
/* While rows are chosen, the gold is what is done to them: «Nuevo» is still there, quiet. */
|
|
204
|
+
const choosingGold = selectionDock?.some((one) => one.primary === true) === true;
|
|
205
|
+
const take = host?.take;
|
|
206
|
+
useEffect(() => (taking ? take?.() : undefined), [taking, take]);
|
|
207
|
+
const listPill = dock?.actions === undefined ? undefined : (_jsx(ActionDock, { placement: dockAt === "bottom" ? "bottom" : "inline", actions: (embedded || choosingGold) && dockAt === "bar" ? quiet(dock.actions) : dock.actions, look: dock.look ?? (dockAt === "bottom" ? "chrome" : "bare"), ...(dock.visible === undefined ? {} : { visible: dock.visible }), ...(dock.label === undefined ? {} : { label: dock.label }), ...(dockAt === "bottom" && identity?.title !== undefined
|
|
208
|
+
? { lead: _jsx(DockName, { name: identity.title }) }
|
|
209
|
+
: {}) }));
|
|
210
|
+
const actions = dock?.actions === undefined ? written : dockAt === "bar" ? listPill : undefined;
|
|
211
|
+
const chosenLead = selection === undefined ? null : (_jsx(DockCount, { count: chosen, onClear: selection.clear, ...(selection.matching === undefined ? {} : { matching: selection.matching }) }));
|
|
212
|
+
const chosenPill = selectionDock === undefined ? null : (_jsx(ActionDock
|
|
213
|
+
/* Into the record's band it is only the pill: the band is the record's. */
|
|
214
|
+
, {
|
|
215
|
+
/* Into the record's band it is only the pill: the band is the record's. */
|
|
216
|
+
placement: floatsChosen && !taking ? "bottom" : "inline", actions: embedded && !floatsChosen ? quiet(selectionDock) : selectionDock, ...(floatsChosen ? { lead: chosenLead } : {}), look: dock?.look ?? (floatsChosen ? "chrome" : "bare"), ...(dock?.visible === undefined ? {} : { visible: dock.visible }), label: dock?.selectionLabel ?? copy.selection.more }));
|
|
217
|
+
/* At the bottom there is ONE pill: the chosen rows' while some are chosen, else the list's. */
|
|
218
|
+
/* Something floats on this list: it reaches the bottom of what scrolls it, so the pill has one
|
|
219
|
+
place — the bottom of the screen — however few the rows (`useReachBottom`). */
|
|
220
|
+
const reach = useReachBottom(frame, !embedded && (dockAt === "bottom" || chosenAt === "bottom"));
|
|
221
|
+
const floating = taking
|
|
222
|
+
? host?.target == null || chosenPill === null
|
|
223
|
+
? null
|
|
224
|
+
: createPortal(chosenPill, host.target)
|
|
225
|
+
: floatsChosen
|
|
226
|
+
? chosenPill
|
|
227
|
+
: dockAt === "bottom"
|
|
228
|
+
? listPill
|
|
229
|
+
: null;
|
|
169
230
|
/* Embedded, the line is drawn only if it has something to OFFER: a count alone repeats
|
|
170
231
|
what the rows (and the footer) already say. */
|
|
171
232
|
const barHasControls = !embedded ||
|
|
@@ -175,18 +236,35 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
|
|
|
175
236
|
actions !== undefined ||
|
|
176
237
|
pagination !== undefined ||
|
|
177
238
|
(selection?.count ?? 0) > 0;
|
|
178
|
-
|
|
239
|
+
/* The chosen rows' pill floats: the bar keeps its search, and does not say the count. */
|
|
240
|
+
const barSelection = floatsChosen ? undefined : selection;
|
|
241
|
+
/* THE COUNTERS, in the modern style, are mini stats under the bar — with the metrics, where a
|
|
242
|
+
list's numbers are read —, not words beside its trail, where they read as more crumbs. */
|
|
243
|
+
const statsBelow = modern && !embedded && density === "comfortable" && identity?.counters !== undefined;
|
|
244
|
+
const counterStats = !statsBelow || identity?.counters === undefined ? undefined : (_jsx(Metrics, { children: identity.counters.map((c) => (_jsx(Metric, { value: c.value, label: c.label }, c.label))) }));
|
|
245
|
+
const stats = counterStats === undefined ? (metrics) : metrics === undefined ? (counterStats) : (_jsxs("div", { className: "flex flex-col gap-2", children: [counterStats, metrics] }));
|
|
246
|
+
const bar = !barHasControls ? undefined : (_jsx(ListingBar, { surface: surface, look: viewStyle, ...(embedded ? { inline: true, count: items.length } : {}), ...(embedded || crumbs === undefined || crumbs.length === 0 || density === "compact"
|
|
179
247
|
? {}
|
|
180
248
|
: {
|
|
181
|
-
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
|
|
249
|
+
crumbs: (_jsx(Breadcrumb, { crumbs: crumbs, size: viewStyle === "modern" ? "lg" : "md", ...(surface === undefined ? {} : { surface }) })),
|
|
250
|
+
}), ...(actions === undefined ? {} : { actions }), ...(identity?.title === undefined ? {} : { title: identity.title }), ...(identity?.description === undefined ? {} : { description: identity.description }), ...(identity?.counters === undefined || statsBelow
|
|
251
|
+
? {}
|
|
252
|
+
: { counters: identity.counters }), ...(barSelection === undefined
|
|
183
253
|
? {}
|
|
184
254
|
: {
|
|
255
|
+
/* In the bar the chosen rows are the bar's own — the count, ✕ and «Elegir los 187
|
|
256
|
+
que coinciden» —, with the dock's buttons as their actions when there is one. */
|
|
185
257
|
selection: {
|
|
186
|
-
count:
|
|
187
|
-
onClear:
|
|
188
|
-
...(
|
|
189
|
-
|
|
258
|
+
count: barSelection.count,
|
|
259
|
+
onClear: barSelection.clear,
|
|
260
|
+
...(chosenPill !== null
|
|
261
|
+
? { actions: chosenPill }
|
|
262
|
+
: barSelection.actions === undefined
|
|
263
|
+
? {}
|
|
264
|
+
: { actions: barSelection.actions }),
|
|
265
|
+
...(barSelection.matching === undefined
|
|
266
|
+
? {}
|
|
267
|
+
: { matching: barSelection.matching }),
|
|
190
268
|
},
|
|
191
269
|
}), ...(search === undefined ? {} : { search }), ...(pagination === undefined ? {} : { pagination }), ...(viewsSlot === undefined ? {} : { views: viewsSlot }) }));
|
|
192
270
|
/* The body of a row, a card: the look first unless the list says the page. */
|
|
@@ -281,7 +359,7 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
|
|
|
281
359
|
: nodes(pile.items), open ? footOf(pile) : null] }, key));
|
|
282
360
|
});
|
|
283
361
|
}
|
|
284
|
-
const reportRows = useMemo(() => reportRowsOf(piles, columns, row), [piles, columns, row]);
|
|
362
|
+
const reportRows = useMemo(() => reportRowsOf(piles, columns, row, copy.report.total), [piles, columns, row, copy.report.total]);
|
|
285
363
|
function wrapGroups(nodes) {
|
|
286
364
|
if (piles === null)
|
|
287
365
|
return nodes(ordered);
|
|
@@ -316,7 +394,9 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
|
|
|
316
394
|
...(onOpen === undefined || choosing ? {} : { open: onOpen }),
|
|
317
395
|
})) : present === "table" && shownColumns !== undefined ? (
|
|
318
396
|
/* The table receives EVERYTHING that belongs to the set: see `TablePresentation`. */
|
|
319
|
-
_jsx(TablePresentation, { items: items, columns: shownColumns, keyOf: keyOf, levels: groupLevels, ...(sort === undefined ? {} : { sort }), ...(onSortChange === undefined ? {} : { onSortChange }), ...(group === undefined ? {} : { group }), ...(selection === undefined ? {} : { selection }), totals: totals, ...(rowActions === undefined ? {} : { rowActions }), ...(create === undefined ? {} : { create }), ...(onPeek === undefined || choosing ? {} : { onPeek }), ...(onOpen === undefined || choosing ? {} : { onOpen }), ...(
|
|
397
|
+
_jsx(TablePresentation, { items: items, columns: shownColumns, keyOf: keyOf, levels: groupLevels, ...(sort === undefined ? {} : { sort }), ...(onSortChange === undefined ? {} : { onSortChange }), ...(group === undefined ? {} : { group }), ...(selection === undefined ? {} : { selection }), totals: totals, ...(rowActions === undefined ? {} : { rowActions }), ...(create === undefined ? {} : { create }), ...(onPeek === undefined || choosing ? {} : { onPeek }), ...(onOpen === undefined || choosing ? {} : { onOpen }), ...(openTargets === undefined || onOpenIn === undefined || choosing
|
|
398
|
+
? {}
|
|
399
|
+
: { openTargets, onOpenIn }), ...(choosing ? { onChoose } : {}), rowClick: rowClick })) : present === "sheet" && sheetSpec !== undefined ? (
|
|
320
400
|
/* The sheet receives the set by INDEX and not an already built matrix: see `SheetPresentation`. */
|
|
321
401
|
_jsx(SheetPresentation, { spec: sheetSpec, entries: sheetRows, ordered: ordered, ...(group === undefined ? {} : { group }) })) : present === "report" && report !== undefined ? (
|
|
322
402
|
/* The report declared by the domain is not SORTED from the bar: the
|
|
@@ -380,22 +460,37 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
|
|
|
380
460
|
/* The list is its own container (`@container`: the presentations adapt to the width
|
|
381
461
|
the LIST has, not the window) and fills the space it is given. Before, every page
|
|
382
462
|
wrapped it in a `div` to get both. */
|
|
383
|
-
_jsxs("div", { ref: frame, "aria-busy": refreshing || loading, className: "@container flex min-w-0 flex-1 flex-col bg-surface", children: [_jsxs(Listing, { bar: bar,
|
|
463
|
+
_jsxs("div", { ref: frame, "aria-busy": refreshing || loading, ...(reach === undefined ? {} : { style: { minHeight: reach } }), className: "@container flex min-w-0 flex-1 flex-col bg-surface", children: [_jsxs(Listing, { bar: bar,
|
|
384
464
|
/* The bar stays on top: with 187 rows, scrolling to see the last one
|
|
385
465
|
left you without search, without pager and without the switcher.
|
|
386
466
|
Embedded it does NOT: the record has its own sticky parts (its rail, its tabs),
|
|
387
467
|
and a second band stuck under them — or carried up into the frame's header slot,
|
|
388
468
|
which is what a sticky list bar does under a sidebar — would cover the record
|
|
389
469
|
for a collection of a dozen rows. */
|
|
390
|
-
sticky: !embedded, ...(surface === undefined ? {} : { surface }), ...(
|
|
470
|
+
sticky: !embedded, ...(surface === undefined ? {} : { surface }), ...(stats === undefined
|
|
391
471
|
? {}
|
|
392
472
|
: {
|
|
393
|
-
metrics: _jsx("div", { className: "px-3.5", children:
|
|
473
|
+
metrics: _jsx("div", { className: "px-3.5", children: stats }),
|
|
394
474
|
}), children: [loading ? _jsx(Skeleton, { label: copy.failed.loading }) : null, isEmpty ? (filtered ? (_jsx(Empty, { sentence: empty?.whenFiltered?.sentence ?? copy.list.emptyFiltered, ...(empty?.whenFiltered?.action === undefined
|
|
395
475
|
? {}
|
|
396
476
|
: { 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
477
|
/* 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] }));
|
|
478
|
+
_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] }));
|
|
479
|
+
}
|
|
480
|
+
/** The list's name at the start of its floating pill: what its actions act on. The same chip as
|
|
481
|
+
* the chosen rows' «3 elegidas ✕», so the pill reads the same way whichever it holds. */
|
|
482
|
+
function DockName({ name }) {
|
|
483
|
+
const sup = useSurface();
|
|
484
|
+
return (_jsx("span", { className: `inline-flex h-(--size-control-md) max-w-(--container-crumb) items-center rounded-pill px-3 text-meta font-medium ${bySurface(sup, "bg-ink/8 text-ink", "bg-chrome-ink/14 text-chrome-ink")}`, children: _jsx("span", { className: "truncate", children: name }) }));
|
|
485
|
+
}
|
|
486
|
+
/** «3 elegidas ✕» at the start of the chosen rows' pill, on the pill's band — and «Elegir los
|
|
487
|
+
* 187 que coinciden» while only the page is chosen. */
|
|
488
|
+
function DockCount({ count, onClear, matching, }) {
|
|
489
|
+
const copy = useUiCopy();
|
|
490
|
+
const sup = useSurface();
|
|
491
|
+
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, {
|
|
492
|
+
count: matching.total.toLocaleString(copy.locale),
|
|
493
|
+
}) }))] }));
|
|
399
494
|
}
|
|
400
495
|
/** What a list offers when it fails and can be retried. */
|
|
401
496
|
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
|
-
|
|
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:
|
|
182
|
+
kind: "group",
|
|
179
183
|
level: pile.depth,
|
|
180
|
-
values: numeric.map((column) =>
|
|
184
|
+
values: numeric.map((column) => pileAggregate(column, pile)),
|
|
181
185
|
children,
|
|
182
186
|
};
|
|
183
187
|
};
|
|
184
|
-
|
|
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.
|
|
@@ -15,14 +15,14 @@ type TableProps<T extends object> = {
|
|
|
15
15
|
levels: NonNullable<Parameters<typeof DataTable<T>>[0]["levels"]>;
|
|
16
16
|
group?: ListGroup<T>;
|
|
17
17
|
totals: boolean;
|
|
18
|
-
} & Pick<ListViewProps<T>, "sort" | "onSortChange" | "selection" | "rowActions" | "create" | "onPeek" | "onOpen"> & {
|
|
18
|
+
} & Pick<ListViewProps<T>, "sort" | "onSortChange" | "selection" | "rowActions" | "create" | "onPeek" | "onOpen" | "openTargets" | "onOpenIn"> & {
|
|
19
19
|
rowClick?: "peek" | "open";
|
|
20
20
|
onChoose?: (item: T) => void;
|
|
21
21
|
};
|
|
22
22
|
/** The table receives EVERYTHING that belongs to the set —sorting, selection, grouping,
|
|
23
23
|
* which columns are on screen— and not a trimmed down version: that was exactly the trap
|
|
24
24
|
* this archetype exists to avoid, that switching presentation loses capabilities. */
|
|
25
|
-
export declare function TablePresentation<T extends object>({ items, columns, keyOf, levels, group, totals, sort, onSortChange, selection, rowActions, create, onPeek, onOpen, rowClick, onChoose, }: TableProps<T>): import("react").JSX.Element;
|
|
25
|
+
export declare function TablePresentation<T extends object>({ items, columns, keyOf, levels, group, totals, sort, onSortChange, selection, rowActions, create, onPeek, onOpen, openTargets, onOpenIn, rowClick, onChoose, }: TableProps<T>): import("react").JSX.Element;
|
|
26
26
|
type SheetProps<T extends object> = {
|
|
27
27
|
spec: ListSheet<T>;
|
|
28
28
|
/** The flattened bands and rows when the set is grouped; `null` when it is not. */
|
|
@@ -3,16 +3,29 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { useUiCopy } from "../../foundations/copy.js";
|
|
4
4
|
import { DataTable } from "../../primitives/table/DataTable.js";
|
|
5
5
|
import { SheetTable } from "../../primitives/table/SheetTable.js";
|
|
6
|
-
import { Eye, SquareArrowOutUpRight } from "lucide-react";
|
|
6
|
+
import { AppWindow, Ellipsis, Eye, PanelRight, PictureInPicture2, SquareArrowOutUpRight, } from "lucide-react";
|
|
7
|
+
/** The icon of each place a record opens — the same as a many2one's (`Picker`). */
|
|
8
|
+
const OPEN_ICON = {
|
|
9
|
+
modal: PictureInPicture2,
|
|
10
|
+
peek: Eye,
|
|
11
|
+
page: SquareArrowOutUpRight,
|
|
12
|
+
side: PanelRight,
|
|
13
|
+
window: AppWindow,
|
|
14
|
+
};
|
|
7
15
|
/** The table receives EVERYTHING that belongs to the set —sorting, selection, grouping,
|
|
8
16
|
* which columns are on screen— and not a trimmed down version: that was exactly the trap
|
|
9
17
|
* this archetype exists to avoid, that switching presentation loses capabilities. */
|
|
10
|
-
export function TablePresentation({ items, columns, keyOf, levels, group, totals, sort, onSortChange, selection, rowActions, create, onPeek, onOpen, rowClick = "peek", onChoose, }) {
|
|
18
|
+
export function TablePresentation({ items, columns, keyOf, levels, group, totals, sort, onSortChange, selection, rowActions, create, onPeek, onOpen, openTargets, onOpenIn, rowClick = "peek", onChoose, }) {
|
|
11
19
|
const copy = useUiCopy();
|
|
12
20
|
const press = onChoose ?? (rowClick === "open" ? (onOpen ?? onPeek) : (onPeek ?? onOpen));
|
|
13
21
|
/* The row's ways in go FIRST among its actions, so they are always the inline ones and
|
|
14
22
|
always in the same place; the domain's actions follow (and fold into ⋯ past two). */
|
|
15
|
-
|
|
23
|
+
/* «Abrir en…»: the places not already a way of their own (👁 is the peek, ↗ the page). */
|
|
24
|
+
const elsewhere = onOpenIn === undefined
|
|
25
|
+
? []
|
|
26
|
+
: (openTargets ?? []).filter((to) => !(to === "peek" && onPeek !== undefined) &&
|
|
27
|
+
!(to === "page" && onOpen !== undefined));
|
|
28
|
+
const withOpeners = onPeek === undefined && onOpen === undefined && elsewhere.length === 0
|
|
16
29
|
? rowActions
|
|
17
30
|
: (item) => [
|
|
18
31
|
...(onPeek === undefined
|
|
@@ -22,6 +35,7 @@ export function TablePresentation({ items, columns, keyOf, levels, group, totals
|
|
|
22
35
|
id: "peek",
|
|
23
36
|
label: copy.list.peek,
|
|
24
37
|
icon: Eye,
|
|
38
|
+
way: true,
|
|
25
39
|
onSelect: () => onPeek(item),
|
|
26
40
|
},
|
|
27
41
|
]),
|
|
@@ -32,9 +46,27 @@ export function TablePresentation({ items, columns, keyOf, levels, group, totals
|
|
|
32
46
|
id: "open",
|
|
33
47
|
label: copy.list.open,
|
|
34
48
|
icon: SquareArrowOutUpRight,
|
|
49
|
+
way: true,
|
|
35
50
|
onSelect: () => onOpen(item),
|
|
36
51
|
},
|
|
37
52
|
]),
|
|
53
|
+
...(elsewhere.length === 0 || onOpenIn === undefined
|
|
54
|
+
? []
|
|
55
|
+
: [
|
|
56
|
+
{
|
|
57
|
+
id: "open-in",
|
|
58
|
+
label: copy.picker.openMore,
|
|
59
|
+
icon: Ellipsis,
|
|
60
|
+
way: true,
|
|
61
|
+
onSelect: () => { },
|
|
62
|
+
menu: elsewhere.map((to) => ({
|
|
63
|
+
id: to,
|
|
64
|
+
label: copy.picker.openIn[to],
|
|
65
|
+
icon: OPEN_ICON[to],
|
|
66
|
+
onSelect: () => onOpenIn(item, to),
|
|
67
|
+
})),
|
|
68
|
+
},
|
|
69
|
+
]),
|
|
38
70
|
...(rowActions?.(item) ?? []),
|
|
39
71
|
];
|
|
40
72
|
/* Piles counted by whoever keeps the data go through as they are: the table draws those,
|
|
@@ -6,11 +6,14 @@ 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";
|
|
12
14
|
import type { Grouping, GroupLevel, Pile } from "../../foundations/grouping.js";
|
|
13
15
|
import type { Pivot, PivotKey, PivotSpec } from "../../foundations/pivot.js";
|
|
16
|
+
import type { OpenTarget } from "../../foundations/types.js";
|
|
14
17
|
import type { Surface, Tone } from "../../foundations/types.js";
|
|
15
18
|
import type { DataColumn, DataTableCreate } from "../../primitives/table/DataTable.js";
|
|
16
19
|
import type { ReportColumn, ReportRow } from "../../primitives/table/ReportTable.js";
|
|
@@ -262,6 +265,39 @@ export type ListChart<T> = {
|
|
|
262
265
|
/** The name it is downloaded under. */
|
|
263
266
|
fileName?: string;
|
|
264
267
|
};
|
|
268
|
+
/**
|
|
269
|
+
* A list's actions FLOATING (`List.Dock`, the record's `ActionDock`): what the
|
|
270
|
+
* list starts, as a pill in its bar, and what is done to the chosen rows, as a pill floating at
|
|
271
|
+
* the bottom while some are chosen («3 elegidas ✕ · Enviar · Imprimir ▾ · ⋯») — the search
|
|
272
|
+
* stays in the bar.
|
|
273
|
+
*/
|
|
274
|
+
export type ListDock = {
|
|
275
|
+
/** What the list starts or does to the whole set — «Nuevo» (the primary), «Importar»,
|
|
276
|
+
* «Exportar ▸» —, in place of `List.Actions`. */
|
|
277
|
+
actions?: readonly DockAction[];
|
|
278
|
+
/** What is done to the CHOSEN rows — «Enviar», «Imprimir ▸», «Archivar». Give the list a
|
|
279
|
+
* `selection` too. */
|
|
280
|
+
selection?: readonly DockAction[];
|
|
281
|
+
/** Where the list's actions go: the BAR's buttons, or ONE pill floating at the BOTTOM of the
|
|
282
|
+
* screen, centred, named by the list it acts on. Absent, the view style decides
|
|
283
|
+
* (`ViewStyleProvider`): `traditional` → `bar`, `modern` → `bottom`; a collection
|
|
284
|
+
* (`embedded`) keeps them on its line. In the modern bar, `bar` puts them at the start of the
|
|
285
|
+
* controls' row. */
|
|
286
|
+
placement?: "bar" | "bottom";
|
|
287
|
+
/** Where the chosen rows' actions go: the BAR in place of the search, or floating at the
|
|
288
|
+
* BOTTOM while the search stays in the bar. Absent, the view style decides
|
|
289
|
+
* (`ViewStyleProvider`): `traditional` → `bar`, `modern` → `bottom`. In a collection
|
|
290
|
+
* (`embedded`) the floating pill takes the record's place — a screen has one (`DockHost`). */
|
|
291
|
+
selectionPlacement?: "bottom" | "bar";
|
|
292
|
+
/** The pill's band — `chrome` (dark) or `canvas` (light) — or `bare`, the bar's buttons. By
|
|
293
|
+
* default `bare` in the bar and `chrome` floating. */
|
|
294
|
+
look?: DockLook;
|
|
295
|
+
/** How many secondary actions each pill shows before «Más». */
|
|
296
|
+
visible?: number;
|
|
297
|
+
/** The toolbars' names: «Acciones de las facturas», «Acciones de las elegidas». */
|
|
298
|
+
label?: string;
|
|
299
|
+
selectionLabel?: string;
|
|
300
|
+
};
|
|
265
301
|
export type ListViewProps<T extends object> = {
|
|
266
302
|
items: readonly T[];
|
|
267
303
|
keyOf: (item: T) => string;
|
|
@@ -287,6 +323,8 @@ export type ListViewProps<T extends object> = {
|
|
|
287
323
|
/** Escape hatch: a custom switcher. Prefer `presents` so the archetype draws it. */
|
|
288
324
|
views?: ReactNode;
|
|
289
325
|
actions?: ReactNode;
|
|
326
|
+
/** The actions floating: see `ListDock`. */
|
|
327
|
+
dock?: ListDock;
|
|
290
328
|
row: (item: T) => RowOf;
|
|
291
329
|
/**
|
|
292
330
|
* The labels of a row's zones, above all of them. Without this there is no
|
|
@@ -396,6 +434,11 @@ export type ListViewProps<T extends object> = {
|
|
|
396
434
|
onOpen?: (item: T) => void;
|
|
397
435
|
onPeek?: (item: T) => void;
|
|
398
436
|
isPeeked?: (item: T) => boolean;
|
|
437
|
+
/** The OTHER places a row's record opens — beside, a window, a modal —, offered as «Abrir
|
|
438
|
+
* en…» among the row's ways in (next to 👁 and ↗), so an application does not draw a second
|
|
439
|
+
* set beside the name. The workspace says which it has; `onOpenIn` opens there. */
|
|
440
|
+
openTargets?: readonly OpenTarget[];
|
|
441
|
+
onOpenIn?: (item: T, to: OpenTarget) => void;
|
|
399
442
|
/** What a press on the row's body does when both ways in exist. `peek` (the default) looks
|
|
400
443
|
* without leaving the list; `open` goes to the record — a workspace whose rule is «a row
|
|
401
444
|
* opens the page» (the composer's) says `open`, and 👁 stays for the look. */
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type RefObject } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* How tall a list must be to reach the bottom of what scrolls it — so its floating pill sits at
|
|
4
|
+
* the bottom of the SCREEN, not right under the last row.
|
|
5
|
+
*
|
|
6
|
+
* Context: the pill is sticky to the bottom of the list (`mt-auto`), which is the bottom of the
|
|
7
|
+
* screen only while the list is taller than the screen. A list of six courses ended a third of the
|
|
8
|
+
* way down and its pill floated there, under the sixth row: its place moved with how many rows
|
|
9
|
+
* there were. With this as its `min-height` the list reaches the bottom of its scroll box (the
|
|
10
|
+
* window, or the view's own box), and the pill has ONE place.
|
|
11
|
+
*
|
|
12
|
+
* Measured once and on resize — never on scroll: where the list starts within what scrolls does
|
|
13
|
+
* not change while scrolling. Nothing is measured on the server; the pill settles after hydration.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useReachBottom(frame: RefObject<HTMLElement | null>, on: boolean): number | undefined;
|