@sincpro/web-ui 2.9.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 +32 -24
- package/dist/components/board/Board.d.ts +2 -1
- package/dist/components/board/Board.js +17 -1
- 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 +30 -8
- package/dist/components/record/ActionDock.js +17 -6
- package/dist/components/record/RecordHeader.js +42 -73
- package/dist/components/record/SmartButtons.d.ts +2 -8
- package/dist/components/record/SmartButtons.js +1 -6
- package/dist/primitives/choice/Switch.d.ts +4 -1
- package/dist/primitives/choice/Switch.js +2 -2
- package/dist/primitives/table/DataTable.d.ts +14 -0
- package/dist/primitives/table/DataTable.js +17 -1
- package/dist/primitives/table/RowActions.d.ts +5 -0
- package/dist/primitives/table/RowActions.js +27 -3
- package/dist/primitives/table/index.d.ts +1 -1
- 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 +16 -0
- package/dist/views/list/List.d.ts +5 -1
- package/dist/views/list/List.js +6 -2
- package/dist/views/list/ListView.d.ts +1 -1
- package/dist/views/list/ListView.js +89 -33
- package/dist/views/list/presentations.d.ts +2 -2
- package/dist/views/list/presentations.js +35 -3
- package/dist/views/list/types.d.ts +15 -5
- package/dist/views/list/useReachBottom.d.ts +15 -0
- package/dist/views/list/useReachBottom.js +55 -0
- package/dist/views/record/Record.js +1 -3
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ 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
|
+
import { ActionDock, useDockHost } from "../../components/record/ActionDock.js";
|
|
14
14
|
import { Breadcrumb } from "../../components/record/Breadcrumb.js";
|
|
15
15
|
import { RecordTimeline } from "../../components/timeline/RecordTimeline.js";
|
|
16
16
|
import { fillCopy, useUiCopy } from "../../foundations/copy.js";
|
|
@@ -23,13 +23,16 @@ import { Button } from "../../primitives/button/Button.js";
|
|
|
23
23
|
import { Empty, Failed, Skeleton } from "../../primitives/notice/Notice.js";
|
|
24
24
|
import { PivotTable } from "../../primitives/table/PivotTable.js";
|
|
25
25
|
import { ReportTable } from "../../primitives/table/ReportTable.js";
|
|
26
|
+
import { Metric, Metrics } from "../../primitives/value/Metric.js";
|
|
26
27
|
import { ProgressBar } from "../../primitives/value/ProgressBar.js";
|
|
27
28
|
import { groupedColumnIds, WIDE_PRESENTS } from "./columns.js";
|
|
28
29
|
import { groupLevelsOf, reportColumnsOf, reportRowsOf, sheetFromColumns, sheetRowsOf, } from "./derive.js";
|
|
29
30
|
import { SheetPresentation, TablePresentation, } from "./presentations.js";
|
|
30
31
|
import { useNarrowList } from "./useNarrowList.js";
|
|
32
|
+
import { useReachBottom } from "./useReachBottom.js";
|
|
31
33
|
import { CalendarDays, CalendarRange, ChartColumnBig, ChartGantt, Grid3x3, LayoutGrid, List, Sheet, Sigma, Table2, X, } from "lucide-react";
|
|
32
|
-
import { Fragment, lazy, Suspense, useCallback, useMemo } from "react";
|
|
34
|
+
import { Fragment, lazy, Suspense, useCallback, useEffect, useMemo, } from "react";
|
|
35
|
+
import { createPortal } from "react-dom";
|
|
33
36
|
/* The calendar (FullCalendar) and the gantt (SVAR) are each about a third of a list's weight,
|
|
34
37
|
and most lists never show either face. Each is its own chunk, fetched the first time its
|
|
35
38
|
face is SHOWN. `lazy` erases the generic, so the eager signature is put back: the props
|
|
@@ -85,7 +88,7 @@ const PRESENT_ICONS = [
|
|
|
85
88
|
{ id: "gantt", icon: ChartGantt },
|
|
86
89
|
{ id: "timeline", icon: CalendarRange },
|
|
87
90
|
];
|
|
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, }) {
|
|
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, }) {
|
|
89
92
|
const wide = useMemo(() => [
|
|
90
93
|
...WIDE_PRESENTS,
|
|
91
94
|
...(faces ?? []).filter((f) => f.wide === true).map((f) => f.id),
|
|
@@ -170,23 +173,60 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
|
|
|
170
173
|
present === "chart" ? null : (_jsx(SortMenu, { fields: sortable, sort: sort ?? [], onSortChange: (next) => onSortChange?.(next), ...(surface === undefined ? {} : { surface }) }));
|
|
171
174
|
const rightViews = views ?? switcher;
|
|
172
175
|
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
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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";
|
|
179
194
|
const chosen = selection?.count ?? 0;
|
|
180
195
|
const selectionDock = dock?.selection === undefined || selection === undefined || chosen === 0
|
|
181
196
|
? undefined
|
|
182
197
|
: dock.selection;
|
|
183
|
-
const floatsChosen = selectionDock !== undefined &&
|
|
184
|
-
const
|
|
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
|
+
: {}) }));
|
|
185
210
|
const actions = dock?.actions === undefined ? written : dockAt === "bar" ? listPill : undefined;
|
|
186
211
|
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
|
|
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 }));
|
|
188
217
|
/* At the bottom there is ONE pill: the chosen rows' while some are chosen, else the list's. */
|
|
189
|
-
|
|
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;
|
|
190
230
|
/* Embedded, the line is drawn only if it has something to OFFER: a count alone repeats
|
|
191
231
|
what the rows (and the footer) already say. */
|
|
192
232
|
const barHasControls = !embedded ||
|
|
@@ -198,27 +238,35 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
|
|
|
198
238
|
(selection?.count ?? 0) > 0;
|
|
199
239
|
/* The chosen rows' pill floats: the bar keeps its search, and does not say the count. */
|
|
200
240
|
const barSelection = floatsChosen ? undefined : selection;
|
|
201
|
-
|
|
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"
|
|
202
247
|
? {}
|
|
203
248
|
: {
|
|
204
|
-
crumbs: (_jsx(Breadcrumb, { crumbs: crumbs, ...(surface === undefined ? {} : { surface }) })),
|
|
205
|
-
}), ...(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
|
|
206
251
|
? {}
|
|
207
|
-
:
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
252
|
+
: { counters: identity.counters }), ...(barSelection === undefined
|
|
253
|
+
? {}
|
|
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. */
|
|
257
|
+
selection: {
|
|
258
|
+
count: barSelection.count,
|
|
259
|
+
onClear: barSelection.clear,
|
|
260
|
+
...(chosenPill !== null
|
|
261
|
+
? { actions: chosenPill }
|
|
262
|
+
: barSelection.actions === undefined
|
|
215
263
|
? {}
|
|
216
264
|
: { actions: barSelection.actions }),
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
265
|
+
...(barSelection.matching === undefined
|
|
266
|
+
? {}
|
|
267
|
+
: { matching: barSelection.matching }),
|
|
268
|
+
},
|
|
269
|
+
}), ...(search === undefined ? {} : { search }), ...(pagination === undefined ? {} : { pagination }), ...(viewsSlot === undefined ? {} : { views: viewsSlot }) }));
|
|
222
270
|
/* The body of a row, a card: the look first unless the list says the page. */
|
|
223
271
|
/* Choosing, the press chooses and the ways in (👁 ↗) are not offered: a chooser's row answers. */
|
|
224
272
|
const choosing = onChoose !== undefined;
|
|
@@ -346,7 +394,9 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
|
|
|
346
394
|
...(onOpen === undefined || choosing ? {} : { open: onOpen }),
|
|
347
395
|
})) : present === "table" && shownColumns !== undefined ? (
|
|
348
396
|
/* The table receives EVERYTHING that belongs to the set: see `TablePresentation`. */
|
|
349
|
-
_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 ? (
|
|
350
400
|
/* The sheet receives the set by INDEX and not an already built matrix: see `SheetPresentation`. */
|
|
351
401
|
_jsx(SheetPresentation, { spec: sheetSpec, entries: sheetRows, ordered: ordered, ...(group === undefined ? {} : { group }) })) : present === "report" && report !== undefined ? (
|
|
352
402
|
/* The report declared by the domain is not SORTED from the bar: the
|
|
@@ -410,23 +460,29 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
|
|
|
410
460
|
/* The list is its own container (`@container`: the presentations adapt to the width
|
|
411
461
|
the LIST has, not the window) and fills the space it is given. Before, every page
|
|
412
462
|
wrapped it in a `div` to get both. */
|
|
413
|
-
_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,
|
|
414
464
|
/* The bar stays on top: with 187 rows, scrolling to see the last one
|
|
415
465
|
left you without search, without pager and without the switcher.
|
|
416
466
|
Embedded it does NOT: the record has its own sticky parts (its rail, its tabs),
|
|
417
467
|
and a second band stuck under them — or carried up into the frame's header slot,
|
|
418
468
|
which is what a sticky list bar does under a sidebar — would cover the record
|
|
419
469
|
for a collection of a dozen rows. */
|
|
420
|
-
sticky: !embedded, ...(surface === undefined ? {} : { surface }), ...(
|
|
470
|
+
sticky: !embedded, ...(surface === undefined ? {} : { surface }), ...(stats === undefined
|
|
421
471
|
? {}
|
|
422
472
|
: {
|
|
423
|
-
metrics: _jsx("div", { className: "px-3.5", children:
|
|
473
|
+
metrics: _jsx("div", { className: "px-3.5", children: stats }),
|
|
424
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
|
|
425
475
|
? {}
|
|
426
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 ? (
|
|
427
477
|
/* Over the top edge of the rows, not above them: the rows do not move. */
|
|
428
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] }));
|
|
429
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
|
+
}
|
|
430
486
|
/** «3 elegidas ✕» at the start of the chosen rows' pill, on the pill's band — and «Elegir los
|
|
431
487
|
* 187 que coinciden» while only the page is chosen. */
|
|
432
488
|
function DockCount({ count, onClear, matching, }) {
|
|
@@ -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,
|
|
@@ -13,6 +13,7 @@ import type { ChartKind, ChartOrder } from "../../foundations/chart.js";
|
|
|
13
13
|
import type { GroupableField } from "../../foundations/grouping.js";
|
|
14
14
|
import type { Grouping, GroupLevel, Pile } from "../../foundations/grouping.js";
|
|
15
15
|
import type { Pivot, PivotKey, PivotSpec } from "../../foundations/pivot.js";
|
|
16
|
+
import type { OpenTarget } from "../../foundations/types.js";
|
|
16
17
|
import type { Surface, Tone } from "../../foundations/types.js";
|
|
17
18
|
import type { DataColumn, DataTableCreate } from "../../primitives/table/DataTable.js";
|
|
18
19
|
import type { ReportColumn, ReportRow } from "../../primitives/table/ReportTable.js";
|
|
@@ -277,12 +278,16 @@ export type ListDock = {
|
|
|
277
278
|
/** What is done to the CHOSEN rows — «Enviar», «Imprimir ▸», «Archivar». Give the list a
|
|
278
279
|
* `selection` too. */
|
|
279
280
|
selection?: readonly DockAction[];
|
|
280
|
-
/** Where the actions go: the BAR's buttons, or ONE pill floating at the BOTTOM
|
|
281
|
-
*
|
|
282
|
-
* (`ViewStyleProvider`): `traditional` → `bar`, `modern` → `bottom
|
|
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. */
|
|
283
286
|
placement?: "bar" | "bottom";
|
|
284
|
-
/** Where the chosen rows' actions go
|
|
285
|
-
*
|
|
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`). */
|
|
286
291
|
selectionPlacement?: "bottom" | "bar";
|
|
287
292
|
/** The pill's band — `chrome` (dark) or `canvas` (light) — or `bare`, the bar's buttons. By
|
|
288
293
|
* default `bare` in the bar and `chrome` floating. */
|
|
@@ -429,6 +434,11 @@ export type ListViewProps<T extends object> = {
|
|
|
429
434
|
onOpen?: (item: T) => void;
|
|
430
435
|
onPeek?: (item: T) => void;
|
|
431
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;
|
|
432
442
|
/** What a press on the row's body does when both ways in exist. `peek` (the default) looks
|
|
433
443
|
* without leaving the list; `open` goes to the record — a workspace whose rule is «a row
|
|
434
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;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useLayoutEffect, useState } from "react";
|
|
3
|
+
/** The nearest ancestor that scrolls vertically; `null` when it is the window. */
|
|
4
|
+
function scrollerOf(el) {
|
|
5
|
+
for (let at = el.parentElement; at !== null; at = at.parentElement) {
|
|
6
|
+
const y = getComputedStyle(at).overflowY;
|
|
7
|
+
if (y === "auto" || y === "scroll")
|
|
8
|
+
return at;
|
|
9
|
+
}
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* How tall a list must be to reach the bottom of what scrolls it — so its floating pill sits at
|
|
14
|
+
* the bottom of the SCREEN, not right under the last row.
|
|
15
|
+
*
|
|
16
|
+
* Context: the pill is sticky to the bottom of the list (`mt-auto`), which is the bottom of the
|
|
17
|
+
* screen only while the list is taller than the screen. A list of six courses ended a third of the
|
|
18
|
+
* way down and its pill floated there, under the sixth row: its place moved with how many rows
|
|
19
|
+
* there were. With this as its `min-height` the list reaches the bottom of its scroll box (the
|
|
20
|
+
* window, or the view's own box), and the pill has ONE place.
|
|
21
|
+
*
|
|
22
|
+
* Measured once and on resize — never on scroll: where the list starts within what scrolls does
|
|
23
|
+
* not change while scrolling. Nothing is measured on the server; the pill settles after hydration.
|
|
24
|
+
*/
|
|
25
|
+
export function useReachBottom(frame, on) {
|
|
26
|
+
const [min, setMin] = useState();
|
|
27
|
+
useLayoutEffect(() => {
|
|
28
|
+
const el = frame.current;
|
|
29
|
+
if (!on || el === null) {
|
|
30
|
+
setMin(undefined);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const scroller = scrollerOf(el);
|
|
34
|
+
const measure = () => {
|
|
35
|
+
const viewTop = scroller === null ? 0 : scroller.getBoundingClientRect().top;
|
|
36
|
+
const viewHeight = scroller === null ? window.innerHeight : scroller.clientHeight;
|
|
37
|
+
const scrolled = scroller === null ? window.scrollY : scroller.scrollTop;
|
|
38
|
+
const padded = scroller === null
|
|
39
|
+
? 0
|
|
40
|
+
: Number.parseFloat(getComputedStyle(scroller).paddingBottom) || 0;
|
|
41
|
+
const top = el.getBoundingClientRect().top - viewTop + scrolled;
|
|
42
|
+
const rest = Math.floor(viewHeight - top - padded);
|
|
43
|
+
setMin(rest > 0 ? rest : undefined);
|
|
44
|
+
};
|
|
45
|
+
measure();
|
|
46
|
+
const watch = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
|
|
47
|
+
watch?.observe(scroller ?? document.documentElement);
|
|
48
|
+
window.addEventListener("resize", measure);
|
|
49
|
+
return () => {
|
|
50
|
+
watch?.disconnect();
|
|
51
|
+
window.removeEventListener("resize", measure);
|
|
52
|
+
};
|
|
53
|
+
}, [frame, on]);
|
|
54
|
+
return min;
|
|
55
|
+
}
|
|
@@ -207,9 +207,7 @@ export function Record({ identity, error = null, dirty, placement, look: ownLook
|
|
|
207
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
|
|
208
208
|
? {}
|
|
209
209
|
: {
|
|
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))) })),
|
|
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", ...(s.onClick === undefined ? {} : { onClick: s.onClick }) }, s.label))) })),
|
|
213
211
|
}), ...(aspectsNode === undefined || globalSheet ? {} : { aspects: aspectsNode }), ...(activitySlot === undefined
|
|
214
212
|
? {}
|
|
215
213
|
: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sincpro/web-ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.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",
|