@sincpro/web-framework 3.17.0 → 3.19.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 +76 -54
- package/dist/core/copy.d.ts +2 -0
- package/dist/core/copy.js +6 -2
- package/dist/core/explain.d.ts +4 -0
- package/dist/core/explain.js +4 -0
- package/dist/core/groups.d.ts +3 -1
- package/dist/core/groups.js +10 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/lines.d.ts +10 -0
- package/dist/core/lines.js +24 -0
- package/dist/core/list.d.ts +12 -0
- package/dist/react/context.d.ts +29 -0
- package/dist/react/context.js +46 -0
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +2 -2
- package/dist/react/useGroups.d.ts +6 -0
- package/dist/react/useGroups.js +84 -11
- package/dist/react/useNameOf.d.ts +13 -0
- package/dist/react/useNameOf.js +32 -0
- package/dist/react/useServiceReading.d.ts +8 -0
- package/dist/react/useServiceReading.js +12 -2
- package/dist/web/index.d.ts +4 -2
- package/dist/web/index.js +4 -2
- package/dist/web/list/EntityList.d.ts +36 -177
- package/dist/web/list/EntityList.js +175 -529
- package/dist/web/list/entityList/choosing.d.ts +50 -0
- package/dist/web/list/entityList/choosing.js +77 -0
- package/dist/web/list/entityList/faces.d.ts +53 -0
- package/dist/web/list/entityList/faces.js +155 -0
- package/dist/web/list/entityList/grouping.d.ts +50 -0
- package/dist/web/list/entityList/grouping.js +97 -0
- package/dist/web/list/entityList/opening.d.ts +68 -0
- package/dist/web/list/entityList/opening.js +144 -0
- package/dist/web/list/entityList/paging.d.ts +30 -0
- package/dist/web/list/entityList/paging.js +39 -0
- package/dist/web/list/entityList/props.d.ts +173 -0
- package/dist/web/list/entityList/props.js +16 -0
- package/dist/web/list/entityList/rowActions.d.ts +31 -0
- package/dist/web/list/entityList/rowActions.js +40 -0
- package/dist/web/list/groups.d.ts +17 -1
- package/dist/web/list/groups.js +43 -0
- package/dist/web/list/useEntityList.d.ts +183 -0
- package/dist/web/list/useEntityList.js +225 -0
- package/dist/web/parts.d.ts +42 -0
- package/dist/web/parts.js +88 -0
- package/dist/web/record/lines.d.ts +3 -0
- package/dist/web/record/lines.js +75 -9
- package/dist/web/workspace/RecordScreen.d.ts +156 -0
- package/dist/web/workspace/RecordScreen.js +197 -0
- package/dist/web/workspace/SincproApp.d.ts +3 -1
- package/dist/web/workspace/SincproApp.js +22 -4
- package/dist/web/workspace/composer.js +1 -1
- package/dist/web/workspace/record.d.ts +4 -22
- package/dist/web/workspace/record.js +5 -70
- package/package.json +3 -3
|
@@ -1,540 +1,186 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx,
|
|
3
|
-
import { PICK_PARAM, QUERY_PARAM, TRAIL_PARAM, } from "@sincpro/client-framework";
|
|
4
|
-
import { nameOf } from "@sincpro/criteria";
|
|
5
|
-
import { RecordLink, useCrumbs, usePhone } from "@sincpro/web-composer";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
6
3
|
import { frameworkCopy } from "../../core/copy.js";
|
|
7
|
-
import {
|
|
8
|
-
import { explain } from "../../core/explain.js";
|
|
9
|
-
import { choosesMany, } from "../../core/list.js";
|
|
10
|
-
import { textOf, viewOf } from "../../core/present.js";
|
|
11
|
-
import { summaryFieldsOf } from "../../core/summary.js";
|
|
12
|
-
import { trailKeyOf } from "../../core/trail.js";
|
|
13
|
-
import { useFramework } from "../../react/context.js";
|
|
14
|
-
import { useGroups } from "../../react/useGroups.js";
|
|
15
|
-
import { usePivot } from "../../react/usePivot.js";
|
|
16
|
-
import { useSelection } from "../../react/useSelection.js";
|
|
17
|
-
import { columnsOf } from "./columns.js";
|
|
18
|
-
import { actionsOf } from "./dock.js";
|
|
4
|
+
import { textOf } from "../../core/present.js";
|
|
19
5
|
import { EntitySearchBar } from "./EntitySearchBar.js";
|
|
20
|
-
import { pilesOf } from "./groups.js";
|
|
21
|
-
import { OpenInMenu, openOptions, targetsFor } from "./openIn.js";
|
|
22
6
|
import { pivotOf } from "./pivot.js";
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
7
|
+
import { useEntityList, } from "./useEntityList.js";
|
|
8
|
+
import { kindsIn, part, resolveParts } from "../parts.js";
|
|
9
|
+
import { Button, Callout, List, SearchField } from "@sincpro/web-ui";
|
|
10
|
+
import { createContext, useContext } from "react";
|
|
11
|
+
/**
|
|
12
|
+
* A whole collection from a `Listing`: the bar, the search, the set in the faces it offers, and
|
|
13
|
+
* the way through it — written as a tree of the framework's parts.
|
|
14
|
+
*
|
|
15
|
+
* <EntityList listing={invoices} api={api} /> ← the whole default
|
|
16
|
+
*
|
|
17
|
+
* <EntityList listing={invoices} api={api}>
|
|
18
|
+
* <EntityList.Bar /> ← crumbs, title, search, pager
|
|
19
|
+
* <EntityList.Table />
|
|
20
|
+
* <EntityList.Board />
|
|
21
|
+
* <InvoicesMap /> ← the application's own block
|
|
22
|
+
* </EntityList>
|
|
23
|
+
*
|
|
24
|
+
* The same rules as `RecordScreen` (docs/PATTERNS.md): with no children it draws the default;
|
|
25
|
+
* with children only what is written — the faces offered are the faces written; a part written
|
|
26
|
+
* empty draws its default content. A block of the application reads the list with
|
|
27
|
+
* `useScreenListing`.
|
|
28
|
+
*
|
|
29
|
+
* Built for sets of any size: in `pages` mode (the default) the screen holds ONE page and walks
|
|
30
|
+
* the server's cursor, so a million rows cost what fifty do; in `more` mode it stops growing at
|
|
31
|
+
* its ceiling and asks to narrow the search. Nothing is filtered, ordered or counted on the
|
|
32
|
+
* page: every gesture is a question to the server. Grouping obeys the same rule: the SERVER
|
|
33
|
+
* counts the groups, and a group's rows are read when it is opened (`useGroups`).
|
|
34
|
+
*
|
|
35
|
+
* Where a record opens is the composer's question: with `api`, a row opens the page and the
|
|
36
|
+
* identity column is the composer's `RecordLink` (peek, side panel, window); without it, the
|
|
37
|
+
* screen passes `onOpen`. What the list knows before it draws is `useEntityList`'s.
|
|
38
|
+
*/
|
|
39
|
+
const ListContext = createContext(null);
|
|
40
|
+
/**
|
|
41
|
+
* The listing on the list around it, for a block the application writes inside an
|
|
42
|
+
* `EntityList` — a map of the same set, a summary over its page. The entity is only its type.
|
|
43
|
+
*
|
|
44
|
+
* function InvoicesMap() {
|
|
45
|
+
* const invoices = useScreenListing(facturas);
|
|
46
|
+
* return <Map points={invoices.rows.map(pointOf)} />;
|
|
47
|
+
* }
|
|
48
|
+
*/
|
|
49
|
+
export function useScreenListing(_entity) {
|
|
50
|
+
const state = useContext(ListContext);
|
|
51
|
+
if (state === null)
|
|
52
|
+
throw new Error("useScreenListing is called inside an EntityList.");
|
|
53
|
+
return state.listing;
|
|
49
54
|
}
|
|
50
|
-
/**
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
definition?.views ??
|
|
68
|
-
(embedded ? ["table"] : pivotAsked === undefined ? EVERY_VIEW : [...EVERY_VIEW, "pivot"]);
|
|
69
|
-
const filters = askedFilters ?? definition?.filters ?? [];
|
|
70
|
-
const groupable = askedGroupable ?? definition?.groupable;
|
|
71
|
-
const facets = askedFacets ?? definition?.facets;
|
|
72
|
-
const title = askedTitle ?? definition?.title;
|
|
73
|
-
const description = askedDescription ?? definition?.description;
|
|
55
|
+
/** A part of the list, resolved against its state. */
|
|
56
|
+
function listPart(name, resolve, kind) {
|
|
57
|
+
return part(`EntityList.${name}`, resolve, kind);
|
|
58
|
+
}
|
|
59
|
+
/* ----------------------------------------------------------------------------------------- *
|
|
60
|
+
* The bar
|
|
61
|
+
* ----------------------------------------------------------------------------------------- */
|
|
62
|
+
/** Where the list stands in the workspace: the crumbs that lead back. */
|
|
63
|
+
const Crumbs = listPart("Crumbs", (_props, { bar }) => bar.trail === undefined || bar.trail.length === 0 ? null : (_jsx(List.Crumbs, { crumbs: bar.trail })));
|
|
64
|
+
/** Its name and what it is for. Not inside a record: there the field's label says it. */
|
|
65
|
+
const Identity = listPart("Identity", (_props, { bar, embedded }) => embedded ? null : (_jsx(List.Identity, { title: bar.title, ...(bar.description === undefined ? {} : { description: bar.description }) })));
|
|
66
|
+
/** The search: the full bar with the criteria builder, or one box over the search template. */
|
|
67
|
+
const Search = listPart("Search", (_props, { bar, listing, meta }) => {
|
|
68
|
+
if (bar.search === "bar")
|
|
69
|
+
return (_jsx(List.Search, { children: _jsx(EntitySearchBar, { listing: listing, filters: bar.filters, groups: bar.groups, ...(bar.groupable === undefined ? {} : { groupable: bar.groupable }), ...(bar.facets === undefined ? {} : { facets: bar.facets }), ...(bar.asked === "" ? {} : { seed: bar.asked }), ...(bar.recent === undefined ? {} : { recentKey: bar.recent }) }) }));
|
|
70
|
+
if (bar.search !== "box" || meta?.search == null)
|
|
71
|
+
return null;
|
|
74
72
|
const copy = frameworkCopy().list;
|
|
75
|
-
const { meta, locale, count, page } = listing;
|
|
76
|
-
const identity = meta?.identity ?? "id";
|
|
77
|
-
const idOf = (row) => String(row[identity]);
|
|
78
|
-
const failed = listing.status === "failed" ? explain(listing.error) : null;
|
|
79
|
-
const dropped = listing.dropped.map((d) => viewOf(meta, d.field, locale).label);
|
|
80
|
-
const [present, setPresent] = useState(views[0] ?? "table");
|
|
81
|
-
// Opened to choose on what was typed in a picker (`chooserRef(query)`): it starts searched.
|
|
82
|
-
const asked = api?.self.params?.[QUERY_PARAM] ?? "";
|
|
83
73
|
// The box's text is a draft until Enter: typing asks the server nothing.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}, [
|
|
132
|
-
api,
|
|
133
|
-
trails,
|
|
134
|
-
trailKey,
|
|
135
|
-
listing.rows,
|
|
136
|
-
listing.count,
|
|
137
|
-
listing.page.from,
|
|
138
|
-
listing.page.after,
|
|
139
|
-
]);
|
|
140
|
-
const refOf = (row) => {
|
|
141
|
-
const ref = listing.entity.ref(idOf(row));
|
|
142
|
-
return { ...ref, params: { ...ref.params, [TRAIL_PARAM]: trailKey } };
|
|
143
|
-
};
|
|
144
|
-
const openWithTrail = (row) => api?.open(refOf(row));
|
|
145
|
-
const opening = onOpen ??
|
|
146
|
-
(api === undefined
|
|
147
|
-
? undefined
|
|
148
|
-
: choosingMany
|
|
149
|
-
? (row) => chosen.toggle(idOf(row))
|
|
150
|
-
: choosing
|
|
151
|
-
? (row) => api.answer(listing.entity.ref(idOf(row)))
|
|
152
|
-
: openWithTrail);
|
|
153
|
-
const creating = create &&
|
|
154
|
-
api !== undefined &&
|
|
155
|
-
!choosing &&
|
|
156
|
-
!embedded &&
|
|
157
|
-
listing.entity.create !== undefined
|
|
158
|
-
? () => api.open(listing.entity.newRef())
|
|
159
|
-
: undefined;
|
|
160
|
-
// What the list starts, as data: «Nuevo» — the primary — and the screen's, drawn by the view
|
|
161
|
-
// style (`List.Dock`). Actions drawn by hand stay in the bar, with «Nuevo» beside them.
|
|
162
|
-
const started = actionsOf(actions);
|
|
163
|
-
const startDock = started.drawn !== null
|
|
164
|
-
? []
|
|
165
|
-
: [
|
|
166
|
-
...(creating === undefined
|
|
167
|
-
? []
|
|
168
|
-
: [
|
|
169
|
-
{
|
|
170
|
-
id: "create",
|
|
171
|
-
label: frameworkCopy().record.create,
|
|
172
|
-
icon: Plus,
|
|
173
|
-
primary: true,
|
|
174
|
-
onSelect: creating,
|
|
175
|
-
},
|
|
176
|
-
]),
|
|
177
|
-
...started.dock,
|
|
178
|
-
];
|
|
179
|
-
// A press opens the page — the composer's one predictable gesture. Every other place the
|
|
180
|
-
// record may open is among the row's ways in, web-ui's (`openTargets` + `onOpenIn`, web-ui
|
|
181
|
-
// 2.10): 👁 for a look (`onPeek` with `rowClick="open"`: the press stays «open»), and «Abrir
|
|
182
|
-
// en…» with the rest — in ONE place at the row's end, a pill in the modern style. Drawn beside
|
|
183
|
-
// the name as well, a row offered three unaligned sets. A chooser only chooses.
|
|
184
|
-
const openingIn = onOpenIn ??
|
|
185
|
-
(api === undefined
|
|
74
|
+
return (_jsx(List.Search, { children: _jsx(SearchField, { value: bar.draft, onChange: (next) => {
|
|
75
|
+
bar.setDraft(next);
|
|
76
|
+
// Emptied (or cleared with ×): the whole set again, at once.
|
|
77
|
+
if (next === "" && listing.text !== "")
|
|
78
|
+
listing.search("", { now: true });
|
|
79
|
+
}, onSubmit: (text) => listing.search(text, { now: true }), placeholder: copy.search, "aria-label": copy.search }) }));
|
|
80
|
+
});
|
|
81
|
+
/** What the list starts — «Nuevo» and the screen's — floating in the dock as data, or in the
|
|
82
|
+
* bar when drawn by hand; and what is done to the chosen rows. */
|
|
83
|
+
const Actions = listPart("Actions", (_props, { bar }) => [
|
|
84
|
+
bar.drawn === null ? null : (_jsxs(List.Actions, { children: [bar.drawn, bar.creating === undefined ? null : (_jsx(Button, { role: "primary", size: "sm", onClick: bar.creating, children: frameworkCopy().record.create }))] }, "actions")),
|
|
85
|
+
bar.startDock.length === 0 && bar.chosenDock.length === 0 ? null : (_jsx(List.Dock, { ...(bar.startDock.length === 0 ? {} : { actions: bar.startDock }), ...(bar.chosenDock.length === 0 ? {} : { selection: bar.chosenDock }) }, "dock")),
|
|
86
|
+
]);
|
|
87
|
+
/** The way through the set: the pager, «more», the groups counted. Written only when it says
|
|
88
|
+
* something — web-ui draws an embedded list's bar for any slot written, an empty one too. */
|
|
89
|
+
const Pager = listPart("Pager", (_props, { bar }) => bar.paging === null ? null : _jsx(List.Pagination, { children: bar.paging }));
|
|
90
|
+
/** The bar over the set. Empty, it draws crumbs, name, search, actions and the pager. */
|
|
91
|
+
const Bar = listPart("Bar", ({ children }, state) => (_jsx(List.Bar, { children: resolveParts(children ?? [
|
|
92
|
+
_jsx(Crumbs, {}, "crumbs"),
|
|
93
|
+
_jsx(Identity, {}, "identity"),
|
|
94
|
+
_jsx(Search, {}, "search"),
|
|
95
|
+
_jsx(Actions, {}, "actions"),
|
|
96
|
+
_jsx(Pager, {}, "pager"),
|
|
97
|
+
], state) })));
|
|
98
|
+
/* ----------------------------------------------------------------------------------------- *
|
|
99
|
+
* The faces: the same set, read several ways
|
|
100
|
+
* ----------------------------------------------------------------------------------------- */
|
|
101
|
+
/** Columns: the fields shown, their totals at the foot, the row's actions, a grip to reorder. */
|
|
102
|
+
const Table = listPart("Table", (_props, { face }) => (_jsx(List.Table, { columns: face.columns, ...(face.totalled ? { totals: true } : {}), ...(face.rowActions === undefined ? {} : { rowActions: face.rowActions }), ...(face.reorder === undefined ? {} : { onReorder: face.reorder }) })), "table");
|
|
103
|
+
/** A name and its facts per row: what a narrow panel wants. */
|
|
104
|
+
const Rows = listPart("Rows", (_props, { face }) => _jsx(List.Rows, { row: face.rowOf }), "rows");
|
|
105
|
+
/** A spreadsheet of the page: every cell a value, the states in their tones. */
|
|
106
|
+
const Sheet = listPart("Sheet", (_props, { face, meta, locale }) => (_jsx(List.Sheet, {
|
|
107
|
+
// The set comes in pages (50 by default): the sheet grows with its page, as the table
|
|
108
|
+
// does, instead of web-ui's fixed box — which suits a sheet of thousands, not a page.
|
|
109
|
+
height: "auto", columns: face.sheetColumns, cell: (row, column) => {
|
|
110
|
+
const value = row[column.id];
|
|
111
|
+
return value === null || value === undefined
|
|
112
|
+
? null
|
|
113
|
+
: (textOf(meta, column.id, value, locale) ?? String(value));
|
|
114
|
+
},
|
|
115
|
+
// The tones the application gave its choices (`presented(entity, { tones })`): the same
|
|
116
|
+
// colour a state has in the table, the record and its tag.
|
|
117
|
+
tone: (row, column) => {
|
|
118
|
+
const tones = face.tones?.[column.id];
|
|
119
|
+
const value = row[column.id];
|
|
120
|
+
return tones === undefined || value === null || value === undefined
|
|
186
121
|
? undefined
|
|
187
|
-
: (
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
:
|
|
196
|
-
|
|
197
|
-
// a ref, so a screen's inline `onOpenIn` is always the current one without redrawing.
|
|
198
|
-
const openingNow = useRef(openingIn);
|
|
199
|
-
openingNow.current = openingIn;
|
|
200
|
-
// The rows face (not the table) takes «Abrir en…» as its row's actions.
|
|
201
|
-
const openInOf = (row) => elsewhere.length === 0 || openingIn === undefined ? null : (_jsx(OpenInMenu, { targets: elsewhere, name: idOf(row), onOpen: (to) => openingNow.current?.(row, to) }));
|
|
202
|
-
// The column that names a row carries its link: the identity, or — in a list that does not
|
|
203
|
-
// show it (a relation inside a record) — the record's name, else the first. The link is only
|
|
204
|
-
// the name (`compact`): the places it opens in are the row's ways.
|
|
205
|
-
const named = columns === undefined || columns.includes(identity)
|
|
206
|
-
? identity
|
|
207
|
-
: meta?.display && columns.includes(meta.display)
|
|
208
|
-
? meta.display
|
|
209
|
-
: (columns[0] ?? identity);
|
|
210
|
-
const rowName = (row) => named === identity ? idOf(row) : (textOf(meta, named, row[named], locale) ?? idOf(row));
|
|
211
|
-
const linked = choosing || cells?.[named] !== undefined || api === undefined
|
|
212
|
-
? cells
|
|
213
|
-
: {
|
|
214
|
-
...cells,
|
|
215
|
-
[named]: (row) => (_jsx(RecordLink, { api: api, resource: refOf(row), compact: true, children: rowName(row) })),
|
|
216
|
-
};
|
|
217
|
-
// `useCrumbs`, not `api.crumbs()`: the crumb must follow a name given later (`setTitle`).
|
|
218
|
-
// Without a workspace it reads a trail that never changes — a hook cannot be skipped.
|
|
219
|
-
const following = useCrumbs(api ?? NO_WORKSPACE);
|
|
220
|
-
usePhone(api ?? NO_WORKSPACE); // where a row opens follows the mode (`targetsFor`)
|
|
221
|
-
// The workspace's crumbs say each view's whole name (its tab's); in the trail a crumb says only
|
|
222
|
-
// what is its own — «Pagos», not «Pagos · María Fernanda» under «María Fernanda».
|
|
223
|
-
const trail = crumbs ?? (embedded || api === undefined ? undefined : ownCrumbs(following));
|
|
224
|
-
// The workspace hears what is chosen: the keys, or — «all that match» — the ones on screen.
|
|
225
|
-
const published = (chosen.selection.by === "keys"
|
|
226
|
-
? chosen.selection.keys
|
|
227
|
-
: listing.rows.map((row) => idOf(row)).filter((id) => chosen.isChosen(id))).join("\u0000");
|
|
228
|
-
const heard = useRef(published);
|
|
229
|
-
useEffect(() => {
|
|
230
|
-
if (!ticking || heard.current === published)
|
|
231
|
-
return;
|
|
232
|
-
heard.current = published;
|
|
233
|
-
api?.select(published === "" ? [] : published.split("\u0000").map((id) => listing.entity.ref(id)));
|
|
234
|
-
}, [api, ticking, published, listing.entity]);
|
|
235
|
-
// «Elegir los 187 que coinciden» only past the page, and only with the server's exact count.
|
|
236
|
-
const total = listing.count?.exact === true ? listing.count.value : null;
|
|
237
|
-
// What is done to the chosen rows: answering whoever asked for several, else the screen's.
|
|
238
|
-
const onChosen = choosingMany
|
|
239
|
-
? [
|
|
240
|
-
{
|
|
241
|
-
id: "add-chosen",
|
|
242
|
-
label: frameworkCopy().picker.addChosen(chosen.size),
|
|
243
|
-
primary: true,
|
|
244
|
-
onSelect: () => api?.answer(chosen.selection),
|
|
245
|
-
},
|
|
246
|
-
]
|
|
247
|
-
: typeof selectionActions === "function"
|
|
248
|
-
? selectionActions(chosen)
|
|
249
|
-
: selectionActions;
|
|
250
|
-
// As data they go to the dock, where the view style draws them; by hand, in the bar.
|
|
251
|
-
const forChosen = actionsOf(onChosen);
|
|
252
|
-
const selection = ticking
|
|
253
|
-
? {
|
|
254
|
-
has: chosen.isChosen,
|
|
255
|
-
toggle: chosen.toggle,
|
|
256
|
-
count: chosen.size ?? 0,
|
|
257
|
-
clear: chosen.clear,
|
|
258
|
-
...(total !== null && total > listing.rows.length
|
|
259
|
-
? { matching: { total, onSelect: chosen.chooseAllMatching } }
|
|
260
|
-
: {}),
|
|
261
|
-
...(forChosen.drawn === null ? {} : { actions: forChosen.drawn }),
|
|
262
|
-
}
|
|
263
|
-
: undefined;
|
|
264
|
-
// Rebuilt only when what it reads changes: a new set of columns on every render redraws
|
|
265
|
-
// every cell of the table. `columns` is compared by content (it is usually a literal);
|
|
266
|
-
// `cells` by identity, since its functions may close over state — memoise it to keep this.
|
|
267
|
-
const names = columns?.join("\u0000");
|
|
268
|
-
const shown = useMemo(() => columnsOf(meta, columns, {
|
|
269
|
-
locale,
|
|
270
|
-
...(linked ? { cells: linked } : {}),
|
|
271
|
-
...(look.tones === undefined ? {} : { tones: look.tones }),
|
|
272
|
-
...(yesNo === undefined ? {} : { yesNo }),
|
|
273
|
-
}),
|
|
274
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
275
|
-
[
|
|
276
|
-
meta,
|
|
277
|
-
locale,
|
|
278
|
-
names,
|
|
279
|
-
cells,
|
|
280
|
-
yesNo,
|
|
281
|
-
api,
|
|
282
|
-
elsewhere.join(),
|
|
283
|
-
openingIn === undefined,
|
|
284
|
-
dateStyle,
|
|
285
|
-
// The tags' colours: a new map of tones redraws the table's cells, as it does the sheet's.
|
|
286
|
-
look.tones,
|
|
287
|
-
]);
|
|
288
|
-
// A state the application gave colours to is the row's tag — and not again among its facts.
|
|
289
|
-
const stateField = summaryFieldsOf(meta, {}, listing.entity.summary).state;
|
|
290
|
-
const stateTones = stateField === undefined ? undefined : look.tones?.[stateField];
|
|
291
|
-
// A row and a card read the record by its display and the first fields shown beside it.
|
|
292
|
-
const display = meta?.display || identity;
|
|
293
|
-
const facts = shown
|
|
294
|
-
.filter((c) => c.id !== display &&
|
|
295
|
-
c.id !== identity &&
|
|
296
|
-
!c.defaultHidden &&
|
|
297
|
-
(stateTones === undefined || c.id !== stateField))
|
|
298
|
-
.slice(0, 3);
|
|
299
|
-
// The pivot asks the server only while it is the face on screen.
|
|
300
|
-
const axes = pivotAsked === undefined || present !== "pivot" || !views.includes("pivot")
|
|
301
|
-
? null
|
|
302
|
-
: {
|
|
303
|
-
rows: typeof pivotAsked.rows === "string"
|
|
304
|
-
? { field: pivotAsked.rows }
|
|
305
|
-
: pivotAsked.rows,
|
|
306
|
-
columns: typeof pivotAsked.columns === "string"
|
|
307
|
-
? { field: pivotAsked.columns }
|
|
308
|
-
: pivotAsked.columns,
|
|
309
|
-
...(pivotAsked.measures === undefined ? {} : { measures: pivotAsked.measures }),
|
|
310
|
-
};
|
|
311
|
-
const crossing = usePivot(listing, axes);
|
|
312
|
-
const folded = axes === null
|
|
313
|
-
? null
|
|
314
|
-
: pivotOf({
|
|
315
|
-
crossed: crossing.crossed,
|
|
316
|
-
byColumn: crossing.columns,
|
|
317
|
-
rows: axes.rows,
|
|
318
|
-
columns: axes.columns,
|
|
319
|
-
measures: crossing.measures,
|
|
122
|
+
: (tones[String(value)] ?? "neutral");
|
|
123
|
+
} })), "sheet");
|
|
124
|
+
/** The set crossed by two fields, counted by the server (`EntityList pivot`). */
|
|
125
|
+
const Pivot = listPart("Pivot", (_props, { face, meta, locale }) => (_jsx(List.Pivot, { folded: face.folded ??
|
|
126
|
+
pivotOf({
|
|
127
|
+
crossed: [],
|
|
128
|
+
byColumn: [],
|
|
129
|
+
rows: { field: "" },
|
|
130
|
+
columns: { field: "" },
|
|
131
|
+
measures: [],
|
|
320
132
|
meta,
|
|
321
133
|
locale,
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
const word = textOf(meta, stateField, row[stateField], locale);
|
|
356
|
-
return word === null
|
|
357
|
-
? {}
|
|
358
|
-
: {
|
|
359
|
-
tags: (_jsx(Tag, { tone: stateTones[String(row[stateField])] ?? "neutral", children: word })),
|
|
360
|
-
};
|
|
361
|
-
})()),
|
|
362
|
-
}, look.row?.(row));
|
|
363
|
-
// Without a look of its own, the board's card — and the tile — is web-ui's, made of the row.
|
|
364
|
-
// With one, the same card — the row's name, meta and tags — under it, and pressing it is still
|
|
365
|
-
// the list's: web-ui (1.5) hands an own card the list's press rule (`ways.press`: open, or
|
|
366
|
-
// choose). A tile is the same card in its `tile` shape (web-ui 2.13), under its own look.
|
|
367
|
-
const cardFrom = (own, layout) => own === undefined
|
|
368
|
-
? undefined
|
|
369
|
-
: (row, ways) => {
|
|
370
|
-
const d = rowOf(row);
|
|
371
|
-
return (_jsx(RecordCard, { ...over({
|
|
372
|
-
title: d.name,
|
|
373
|
-
...(d.tags === undefined ? {} : { tags: d.tags }),
|
|
374
|
-
...(d.meta === undefined ? {} : { meta: d.meta }),
|
|
375
|
-
}, own(row)), ...(layout === undefined ? {} : { layout }), ...(ways.press === undefined ? {} : { onOpen: ways.press }) }));
|
|
376
|
-
};
|
|
377
|
-
const cardOfRow = cardFrom(look.card);
|
|
378
|
-
const tileOfRow = cardFrom(look.tile, "tile");
|
|
379
|
-
// Grouped: the SERVER counts the groups, a page of them at a time; a level below and a group's
|
|
380
|
-
// rows are read when it is opened, so every group starts closed. Every face of web-ui (1.4)
|
|
381
|
-
// draws these piles, the table included; each says what its next «more» brings (1.5), and a
|
|
382
|
-
// level that holds fewer groups than it counts offers the next page of them (2.19).
|
|
383
|
-
const groups = useGroups(listing, sums === undefined ? {} : { sums: sums || [] });
|
|
384
|
-
const grouped = groups.levels.length > 0;
|
|
385
|
-
// A table and a sheet say a group's sums under their columns (web-ui 2.9): beside the group's
|
|
386
|
-
// name, only what no column shown adds up.
|
|
387
|
-
const columnar = present === "table" || present === "sheet";
|
|
388
|
-
const underColumns = new Set(columnar
|
|
389
|
-
? shown.flatMap((column) => column.aggregate === undefined || column.defaultHidden || column.field === undefined
|
|
390
|
-
? []
|
|
391
|
-
: [column.field])
|
|
392
|
-
: []);
|
|
393
|
-
const { piles, bucketAt } = pilesOf(groups.buckets, groups.levels, meta, locale, groups.rowsOf, groups.brings, underColumns, groups);
|
|
394
|
-
// What is open is the groups' (it survives a search); a group above another is drawn open
|
|
395
|
-
// only once its level arrived — an empty open group would read as one with no rows.
|
|
396
|
-
const collapsed = [...bucketAt].flatMap(([key, bucket]) => groups.isOpen(bucket) &&
|
|
397
|
-
(groups.isDeepest(bucket) || groups.groupsOf(bucket) !== undefined)
|
|
398
|
-
? []
|
|
399
|
-
: [key]);
|
|
400
|
-
const toggle = (key) => {
|
|
401
|
-
const bucket = bucketAt.get(key);
|
|
402
|
-
if (bucket !== undefined)
|
|
403
|
-
groups.toggle(bucket);
|
|
404
|
-
};
|
|
405
|
-
const failure = grouped && groups.status === "failed" ? explain(groups.error) : grouped ? null : failed;
|
|
406
|
-
const morePiles = groups.bringsGroups(null);
|
|
407
|
-
const grouping = grouped
|
|
408
|
-
? {
|
|
409
|
-
group: {
|
|
410
|
-
levels: groups.levels,
|
|
411
|
-
of: (row, level) => String(row[level.field] ?? ""),
|
|
412
|
-
piles,
|
|
413
|
-
collapsed,
|
|
414
|
-
onToggle: toggle,
|
|
415
|
-
// «See N more» inside an open group: its next page, on the server's cursor (web-ui 1.4).
|
|
416
|
-
onMore: (pile) => {
|
|
417
|
-
const bucket = bucketAt.get(pathKey(pile.path));
|
|
418
|
-
if (bucket !== undefined)
|
|
419
|
-
groups.more(bucket);
|
|
420
|
-
},
|
|
421
|
-
// «Ver N grupos más» after the last group of a level: the first level, or the one
|
|
422
|
-
// under an open group — counted by the server (`groups_count`).
|
|
423
|
-
...(groups.groupsCount === null ? {} : { pilesCount: groups.groupsCount }),
|
|
424
|
-
...(morePiles === undefined ? {} : { morePiles }),
|
|
425
|
-
onMorePiles: (parent) => {
|
|
426
|
-
if (parent === null)
|
|
427
|
-
return groups.moreGroups(null);
|
|
428
|
-
const bucket = bucketAt.get(pathKey(parent.path));
|
|
429
|
-
if (bucket !== undefined)
|
|
430
|
-
groups.moreGroups(bucket);
|
|
431
|
-
},
|
|
432
|
-
},
|
|
433
|
-
}
|
|
434
|
-
: {};
|
|
435
|
-
// How many groups and records the SERVER counted — never the sum of the groups in hand.
|
|
436
|
-
const records = groups.records ?? groups.buckets.reduce((sum, bucket) => sum + bucket.count, 0);
|
|
437
|
-
// The foot adds up what the model says adds up (`total`) — over the rows in hand, never a
|
|
438
|
-
// grouped set (each group says its own, counted by the server). While the rows are not the
|
|
439
|
-
// whole set the list says the figures are this page's (`pageTotals`): the server's total over
|
|
440
|
-
// everything filtered waits on a reading of measures (sincpro_framework, PRD_09).
|
|
441
|
-
const partial = listing.paging === "pages"
|
|
442
|
-
? page.hasPrev || page.hasNext
|
|
443
|
-
: listing.hasMore || listing.capped;
|
|
444
|
-
// Inside a record or a panel a list is its rows: a page's sum there reads as THE total, so an
|
|
445
|
-
// embedded list adds up only when every row is in hand.
|
|
446
|
-
const totalled = !grouped &&
|
|
447
|
-
!(embedded && partial) &&
|
|
448
|
-
listing.rows.length > 0 &&
|
|
449
|
-
shown.some((column) => column.aggregate !== undefined && !column.defaultHidden);
|
|
450
|
-
// A row's actions: the entity's Commands, then whatever else the screen offers.
|
|
451
|
-
// The trash (`trashOf`): each row is brought back from where it is, with the entity's own
|
|
452
|
-
// `restore` — it can be undone, so it runs on the click; the list reads again after.
|
|
453
|
-
const restoring = listing.definition?.trash === true && listing.entity.restore !== undefined;
|
|
454
|
-
const offered = useMemo(() => restoring
|
|
455
|
-
? [
|
|
456
|
-
...commands,
|
|
457
|
-
{
|
|
458
|
-
command: RESTORE,
|
|
459
|
-
label: frameworkCopy().record.restore,
|
|
460
|
-
icon: RotateCcw,
|
|
461
|
-
},
|
|
462
|
-
]
|
|
463
|
-
: commands, [restoring, commands]);
|
|
464
|
-
const rowCommands = useRowCommands(listing, offered);
|
|
465
|
-
const rowActions = offered.length === 0 && askedRowActions === undefined
|
|
466
|
-
? undefined
|
|
467
|
-
: (row) => [...rowCommands.rowActions(row), ...(askedRowActions?.(row) ?? [])];
|
|
468
|
-
// Rows put in their order by hand: only on the whole order, never grouped or while choosing.
|
|
469
|
-
const reorder = useReorder(listing, idOf, !grouped && !choosing);
|
|
470
|
-
const refusal = rowCommands.error ?? reorder.error;
|
|
471
|
-
const refused = refusal === null ? null : explain(refusal);
|
|
472
|
-
// The way through the set. Inside a record or a panel, only while there is more than what is
|
|
473
|
-
// on screen: «1–5 / 5» repeats the rows.
|
|
474
|
-
const fits = embedded && !partial;
|
|
475
|
-
const through = grouped ? (groups.status !== "ready" ? null : (_jsx("span", { className: "text-meta text-muted", children: copy.groups(groups.groupsCount ?? groups.buckets.length, records) }))) : fits ? null : listing.paging === "pages" ? (page.from === 0 ? null : (_jsx(Pagination, { from: page.from, to: page.to, total: count?.value ?? page.to,
|
|
476
|
-
/* The range is touched to choose how many rows fit — in both styles. Without these two
|
|
477
|
-
the modern pill and the plain range drew a size nobody could change. */
|
|
478
|
-
pageSize: page.size, onPageSizeChange: listing.resize, ...(page.hasPrev ? { onPrev: listing.prev } : {}), ...(page.hasNext ? { onNext: listing.next } : {}) }))) : (_jsxs(_Fragment, { children: [count === null ? null : (_jsx("span", { className: "text-meta text-muted", children: copy.shown(listing.rows.length, count.value, count.exact) })), listing.capped ? (_jsx("span", { className: "text-meta text-muted", children: copy.capped(listing.rows.length) })) : listing.hasMore ? (_jsx(Button, { size: "sm", role: "secondary", disabled: listing.status === "loadingMore", onClick: listing.more, children: listing.status === "loadingMore" ? copy.loading : copy.loadMore })) : null] }));
|
|
479
|
-
const pageTotals = totalled && partial && present === "table";
|
|
480
|
-
// Written only when it says something: web-ui draws an embedded list's bar for any slot
|
|
481
|
-
// written, an empty one too. Its parts side by side and apart: the slot does not space them,
|
|
482
|
-
// and «Totales de esta página» read glued to «1–50 / 112».
|
|
483
|
-
const paging = !pageTotals && dropped.length === 0 && through === null ? null : (_jsxs("span", { className: "flex items-center gap-3", children: [pageTotals ? _jsx("span", { className: "text-meta text-muted", children: copy.pageTotals }) : null, dropped.length === 0 ? null : (_jsx(Tag, { tone: "warn", title: copy.dropped(dropped), children: copy.dropped(dropped) })), through] }));
|
|
484
|
-
return (_jsxs(List, { items: reorder.rows, keyOf: idOf, embedded: embedded, present: present, onPresentChange: setPresent, ...grouping,
|
|
485
|
-
// The whole order, as web-ui 1.7 shows and sets it: ⇧-click on a header adds a field,
|
|
486
|
-
// the sort menu reorders them — the same list the criteria builder writes.
|
|
487
|
-
// While the rows can be dragged the order shown IS their position: the table gets no column
|
|
488
|
-
// sort (web-ui turns its grip off under one), the list keeps its order as it is.
|
|
489
|
-
sort: reorder.move === undefined ? sortStates : [], ...(embedded ? {} : { sortable }), onSortChange: (next) => listing.orderBy(next.map((one) => ({ field: one.key, descending: one.direction === "desc" }))), state: {
|
|
490
|
-
// Only the FIRST reading shows the skeleton. Refining (typing, a filter, the next
|
|
491
|
-
// page) keeps the rows on screen until the server answers: web-ui swaps the body for
|
|
492
|
-
// a skeleton while `loading`, and a row that vanished under the pointer lost a click.
|
|
493
|
-
// Meanwhile `refreshing` (web-ui 1.4) draws a quiet bar over the rows: asking, not gone.
|
|
494
|
-
loading: grouped
|
|
495
|
-
? groups.status === "loading" && groups.buckets.length === 0
|
|
496
|
-
: listing.status === "loading" && listing.rows.length === 0,
|
|
497
|
-
refreshing: grouped
|
|
498
|
-
? groups.status === "loading" && groups.buckets.length > 0
|
|
499
|
-
: listing.status === "loading" && listing.rows.length > 0,
|
|
500
|
-
error: failure === null
|
|
501
|
-
? null
|
|
502
|
-
: [failure.heading, failure.sentence].filter(Boolean).join(". "),
|
|
503
|
-
}, filtered: listing.selection !== undefined || listing.text !== "", empty: emptyOf(empty, copy), ...(selection === undefined ? {} : { selection }), ...(opening === undefined ? {} : { onOpen: opening }), ...(peeking === undefined ? {} : { onPeek: peeking, rowClick: "open" }), ...(elsewhere.length === 0 || openingIn === undefined
|
|
504
|
-
? {}
|
|
505
|
-
: {
|
|
506
|
-
openTargets: elsewhere,
|
|
507
|
-
onOpenIn: (row, to) => openingNow.current?.(row, to),
|
|
508
|
-
}), children: [_jsxs(List.Bar, { children: [trail === undefined || trail.length === 0 ? null : _jsx(List.Crumbs, { crumbs: trail }), embedded ? null : (_jsx(List.Identity, { title: title ?? nameOf(meta, locale), ...(description === undefined ? {} : { description }) })), search === "bar" ? (_jsx(List.Search, { children: _jsx(EntitySearchBar, { listing: listing, filters: filters, groups: groups, ...(groupable === undefined ? {} : { groupable }), ...(facets === undefined ? {} : { facets }), ...(asked === "" ? {} : { seed: asked }), ...(recent === undefined ? {} : { recentKey: recent }) }) })) : null, search === "box" && meta?.search != null ? (_jsx(List.Search, { children: _jsx(SearchField, { value: draft, onChange: (next) => {
|
|
509
|
-
setDraft(next);
|
|
510
|
-
// Emptied (or cleared with ×): the whole set again, at once.
|
|
511
|
-
if (next === "" && listing.text !== "")
|
|
512
|
-
listing.search("", { now: true });
|
|
513
|
-
}, onSubmit: (text) => listing.search(text, { now: true }), placeholder: copy.search, "aria-label": copy.search }) })) : null, started.drawn === null ? null : (_jsxs(List.Actions, { children: [started.drawn, creating === undefined ? null : (_jsx(Button, { role: "primary", size: "sm", onClick: creating, children: frameworkCopy().record.create }))] })), startDock.length === 0 && forChosen.dock.length === 0 ? null : (_jsx(List.Dock, { ...(startDock.length === 0 ? {} : { actions: startDock }), ...(forChosen.dock.length === 0 ? {} : { selection: forChosen.dock }) })), paging === null ? null : _jsx(List.Pagination, { children: paging })] }), views.includes("table") ? (_jsx(List.Table, { columns: shown, ...(totalled ? { totals: true } : {}), ...(rowActions === undefined ? {} : { rowActions }), ...(reorder.move === undefined ? {} : { onReorder: reorder.move }) })) : null, _jsx(List.Rows, { row: rowOf }), views.includes("sheet") ? (_jsx(List.Sheet, {
|
|
514
|
-
// The set comes in pages (50 by default): the sheet grows with its page, as the table
|
|
515
|
-
// does, instead of web-ui's fixed box — which suits a sheet of thousands, not a page.
|
|
516
|
-
height: "auto", columns: sheetColumns, cell: (row, column) => {
|
|
517
|
-
const value = row[column.id];
|
|
518
|
-
return value === null || value === undefined
|
|
519
|
-
? null
|
|
520
|
-
: (textOf(meta, column.id, value, locale) ?? String(value));
|
|
521
|
-
},
|
|
522
|
-
// The tones the application gave its choices (`presented(entity, { tones })`): the
|
|
523
|
-
// same colour a state has in the table, the record and its tag.
|
|
524
|
-
tone: (row, column) => {
|
|
525
|
-
const tones = look.tones?.[column.id];
|
|
526
|
-
const value = row[column.id];
|
|
527
|
-
return tones === undefined || value === null || value === undefined
|
|
528
|
-
? undefined
|
|
529
|
-
: (tones[String(value)] ?? "neutral");
|
|
530
|
-
} })) : null, views.includes("pivot") ? (_jsx(List.Pivot, { folded: folded ??
|
|
531
|
-
pivotOf({
|
|
532
|
-
crossed: [],
|
|
533
|
-
byColumn: [],
|
|
534
|
-
rows: { field: "" },
|
|
535
|
-
columns: { field: "" },
|
|
536
|
-
measures: [],
|
|
537
|
-
meta,
|
|
538
|
-
locale,
|
|
539
|
-
}) })) : null, views.includes("board") ? (_jsx(List.Board, { ...(cardOfRow === undefined ? {} : { card: cardOfRow }) })) : null, views.includes("tiles") ? (_jsx(List.Tiles, { ...(tileOfRow === undefined ? {} : { card: tileOfRow }) })) : null, (faces ?? []).map((face) => (_jsx(List.Present, { id: face.id, label: face.label, icon: face.icon, ...(face.wide === undefined ? {} : { wide: face.wide }), children: face.render }, face.id))), reorder.elsewhere ? (_jsx(Callout, { tone: "warn", onDismiss: reorder.dismiss, children: copy.reorderElsewhere })) : null, refused === null ? null : (_jsx(Callout, { tone: "bad", title: refused.heading, children: refused.sentence }))] }));
|
|
134
|
+
}) })), "pivot");
|
|
135
|
+
/** Cards: the entity's own (`presented card`), else web-ui's made of the row. */
|
|
136
|
+
const Board = listPart("Board", (_props, { face }) => (_jsx(List.Board, { ...(face.cardOfRow === undefined ? {} : { card: face.cardOfRow }) })), "board");
|
|
137
|
+
/** A grid of pictures — a till's products, a shop's items. */
|
|
138
|
+
const Tiles = listPart("Tiles", (_props, { face }) => (_jsx(List.Tiles, { ...(face.tileOfRow === undefined ? {} : { card: face.tileOfRow }) })), "tiles");
|
|
139
|
+
/** The faces the screen gave as data (`faces`), each one web-ui's `List.Present`. */
|
|
140
|
+
const Faces = listPart("Faces", (_props, { face }) => face.faces.map((one) => (_jsx(List.Present, { id: one.id, label: one.label, icon: one.icon, ...(one.wide === undefined ? {} : { wide: one.wide }), children: one.render }, one.id))));
|
|
141
|
+
/** What happened to a gesture on the list: rows moved by someone else, a command refused. */
|
|
142
|
+
const Notices = listPart("Notices", (_props, { notices }) => [
|
|
143
|
+
notices.movedElsewhere ? (_jsx(Callout, { tone: "warn", onDismiss: notices.dismissMoved, children: frameworkCopy().list.reorderElsewhere }, "moved")) : null,
|
|
144
|
+
notices.refused === null ? null : (_jsx(Callout, { tone: "bad", title: notices.refused.heading, children: notices.refused.sentence }, "refused")),
|
|
145
|
+
]);
|
|
146
|
+
/** The built-in faces in the order the switcher offers them. */
|
|
147
|
+
const FACES = [
|
|
148
|
+
["table", Table],
|
|
149
|
+
["rows", Rows],
|
|
150
|
+
["sheet", Sheet],
|
|
151
|
+
["pivot", Pivot],
|
|
152
|
+
["board", Board],
|
|
153
|
+
["tiles", Tiles],
|
|
154
|
+
];
|
|
155
|
+
/* ----------------------------------------------------------------------------------------- *
|
|
156
|
+
* The root
|
|
157
|
+
* ----------------------------------------------------------------------------------------- */
|
|
158
|
+
function EntityListRoot(props) {
|
|
159
|
+
const { children, ...asked } = props;
|
|
160
|
+
const written = children === undefined ? undefined : kindsIn(children);
|
|
161
|
+
const state = useEntityList(asked, written === undefined || written.length === 0 ? undefined : written);
|
|
162
|
+
// A rows face is always there, asked for or not: web-ui draws a NARROW list — a window, a side
|
|
163
|
+
// panel, a phone — as rows whatever was asked, and a list with no rows face draws nothing there.
|
|
164
|
+
const tree = children ?? (_jsxs(_Fragment, { children: [_jsx(Bar, {}), FACES.flatMap(([view, Face]) => view === "rows" || state.views.includes(view) ? [_jsx(Face, {}, view)] : []), _jsx(Faces, {}), _jsx(Notices, {})] }));
|
|
165
|
+
const rows = written === undefined || written.includes("rows") ? null : _jsx(Rows, {}, "rows");
|
|
166
|
+
return (_jsx(ListContext.Provider, { value: state, children: _jsx(List, { ...state.root, children: resolveParts(_jsxs(_Fragment, { children: [tree, rows] }), state) }) }));
|
|
540
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* A list by parts: the framework's default, or any part of it replaced. See the top of this file.
|
|
170
|
+
*/
|
|
171
|
+
export const EntityList = Object.assign(EntityListRoot, {
|
|
172
|
+
Bar,
|
|
173
|
+
Crumbs,
|
|
174
|
+
Identity,
|
|
175
|
+
Search,
|
|
176
|
+
Actions,
|
|
177
|
+
Pager,
|
|
178
|
+
Table,
|
|
179
|
+
Rows,
|
|
180
|
+
Sheet,
|
|
181
|
+
Pivot,
|
|
182
|
+
Board,
|
|
183
|
+
Tiles,
|
|
184
|
+
Faces,
|
|
185
|
+
Notices,
|
|
186
|
+
});
|