@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
package/dist/web/record/lines.js
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { keysOf, listRoute } from "@sincpro/client-framework";
|
|
3
4
|
import { choicesOf } from "@sincpro/criteria";
|
|
5
|
+
import { frameworkCopy } from "../../core/copy.js";
|
|
4
6
|
import { adviceAt, defaultsOf, errorAt, linePlacesOf, pathOf, } from "../../core/edit.js";
|
|
5
|
-
import { addingOf, blankLine, lineFields, lineKey, moved, sameLine, writtenInCell, } from "../../core/lines.js";
|
|
7
|
+
import { addingOf, addManyOf, blankLine, lineFields, lineKey, moved, sameLine, writtenInCell, } from "../../core/lines.js";
|
|
6
8
|
import { textOf, viewOf } from "../../core/present.js";
|
|
7
9
|
import { entityFor, relationFieldOf, } from "../../core/relation.js";
|
|
8
10
|
import { useEntityFor, useFramework } from "../../react/context.js";
|
|
11
|
+
import { BATCH_LIMIT } from "../../react/useBatchCommand.js";
|
|
12
|
+
import { useNameOf } from "../../react/useNameOf.js";
|
|
13
|
+
import { refusalNotice } from "../list/records.js";
|
|
9
14
|
import { controlFor, RelationPicker, } from "./control.js";
|
|
10
15
|
import { RecordOpeningProvider, useRecordOpening, } from "./opening.js";
|
|
11
16
|
import { usePartLook } from "./record.js";
|
|
12
|
-
import { Field, LineItems, ReadValue, Tag, } from "@sincpro/web-ui";
|
|
17
|
+
import { Button, Field, LineItems, ReadValue, Tag, useToastIfAny, } from "@sincpro/web-ui";
|
|
13
18
|
import { useRef } from "react";
|
|
14
19
|
/** How a field of a line reads: a many2one's key by the name of what it points at. */
|
|
15
20
|
function textIn(definition, field, relation, line, locale) {
|
|
@@ -18,6 +23,26 @@ function textIn(definition, field, relation, line, locale) {
|
|
|
18
23
|
: textOf(definition, relation.relation, line[relation.relation], locale);
|
|
19
24
|
return named ?? textOf(definition, field, line[field], locale) ?? "";
|
|
20
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* A line's many2one whose record is not in hand — a key alone (`EntityID`), or a line added with
|
|
28
|
+
* only its key («Agregar varios…») — read by the record's name, as a list's column reads it: the
|
|
29
|
+
* keys drawn in one request per entity (`useNameOf`), the key until it answers.
|
|
30
|
+
*/
|
|
31
|
+
function LineKeyName({ target, id }) {
|
|
32
|
+
return _jsx(_Fragment, { children: useNameOf(useEntityFor(target), id) ?? id });
|
|
33
|
+
}
|
|
34
|
+
/** The key of `line`'s many2one when its record is not beside it — what `LineKeyName` names. */
|
|
35
|
+
function unnamedKey(relation, line) {
|
|
36
|
+
if (relation === undefined || relation.many)
|
|
37
|
+
return undefined;
|
|
38
|
+
const held = relation.relation === relation.key ? null : line[relation.relation];
|
|
39
|
+
const key = line[relation.key];
|
|
40
|
+
return held === null || held === undefined
|
|
41
|
+
? key === null || key === undefined || key === ""
|
|
42
|
+
? undefined
|
|
43
|
+
: String(key)
|
|
44
|
+
: undefined;
|
|
45
|
+
}
|
|
21
46
|
/**
|
|
22
47
|
* One field of a line, written — in its cell or in its dialog: a many2one of a declared entity
|
|
23
48
|
* is its picker, anything else the control its type asks for.
|
|
@@ -97,8 +122,9 @@ function LineValue({ definition, field, line, set, label, invalid, locale, inCel
|
|
|
97
122
|
*/
|
|
98
123
|
export function RecordLinesEditor({ record, name, lines, look = {}, }) {
|
|
99
124
|
const { meta, locale, edit } = record;
|
|
100
|
-
const { entities, metas } = useFramework();
|
|
125
|
+
const { entities, metas, transport } = useFramework();
|
|
101
126
|
const opening = useRecordOpening();
|
|
127
|
+
const toast = useToastIfAny();
|
|
102
128
|
const definition = meta?.fields[name]?.definition ?? null;
|
|
103
129
|
// A value inside the record (an embedded list) has no identity of its own: every line is
|
|
104
130
|
// keyed locally — falling back to `id` would key it by whatever it holds under that name.
|
|
@@ -136,6 +162,30 @@ export function RecordLinesEditor({ record, name, lines, look = {}, }) {
|
|
|
136
162
|
const now = useRef(lines);
|
|
137
163
|
now.current = lines;
|
|
138
164
|
const write = (change) => edit.set(name, change(now.current));
|
|
165
|
+
const newLine = () => blankLine(defaultsOf(definition), identity);
|
|
166
|
+
// «Agregar varios…»: the workspace's chooser of several on the line's many2one (a product),
|
|
167
|
+
// one new line per record chosen — its key set, the rest as «Agregar una línea» leaves it.
|
|
168
|
+
// The chosen are read once with a ceiling, as a many2many's are (`keysOf`, `BATCH_LIMIT`).
|
|
169
|
+
const many = writing ? addManyOf(definition, declared, look.addMany) : undefined;
|
|
170
|
+
const manyKey = many === undefined ? undefined : relations.get(many)?.key;
|
|
171
|
+
const manyEntity = many === undefined
|
|
172
|
+
? undefined
|
|
173
|
+
: entityFor(entities, relations.get(many).target, metas.get);
|
|
174
|
+
const chooseMany = opening?.chooseMany;
|
|
175
|
+
const addMany = manyKey === undefined || manyEntity === undefined || chooseMany === undefined
|
|
176
|
+
? undefined
|
|
177
|
+
: () => chooseMany(manyEntity, (selection) => {
|
|
178
|
+
const meta = metas.get(manyEntity.key);
|
|
179
|
+
keysOf(selection, {
|
|
180
|
+
transport,
|
|
181
|
+
route: listRoute(manyEntity.list),
|
|
182
|
+
identity: meta?.get_id || meta?.identity || "id",
|
|
183
|
+
limit: BATCH_LIMIT,
|
|
184
|
+
}).then((keys) => write((all) => [
|
|
185
|
+
...all,
|
|
186
|
+
...keys.map((key) => ({ ...newLine(), [manyKey]: key })),
|
|
187
|
+
]), (failure) => toast?.show(refusalNotice(failure)));
|
|
188
|
+
}, "");
|
|
139
189
|
const drawn = new Set(shown);
|
|
140
190
|
const fieldColumns = shown.map((field) => {
|
|
141
191
|
const view = viewOf(definition, field, locale);
|
|
@@ -159,7 +209,14 @@ export function RecordLinesEditor({ record, name, lines, look = {}, }) {
|
|
|
159
209
|
value: (line) => line[field],
|
|
160
210
|
// Drawn as read: «Cemento 50 kg», not «CEM-50»; «1.552,00», not «1552.00».
|
|
161
211
|
// A choice the record's entity coloured reads as its tag, as in a list.
|
|
162
|
-
cell: ownCell ??
|
|
212
|
+
cell: ownCell ??
|
|
213
|
+
toned ??
|
|
214
|
+
((line) => {
|
|
215
|
+
const key = relation !== undefined && declared(relation.target)
|
|
216
|
+
? unnamedKey(relation, line)
|
|
217
|
+
: undefined;
|
|
218
|
+
return key === undefined ? (textIn(definition, field, relation, line, locale)) : (_jsx(LineKeyName, { target: relation.target, id: key }));
|
|
219
|
+
}),
|
|
163
220
|
text: (line) => textIn(definition, field, relation, line, locale),
|
|
164
221
|
numeric: view.type === "number" || view.type === "integer",
|
|
165
222
|
...(inCell
|
|
@@ -180,7 +237,7 @@ export function RecordLinesEditor({ record, name, lines, look = {}, }) {
|
|
|
180
237
|
...(one.numeric === undefined ? {} : { numeric: one.numeric }),
|
|
181
238
|
})),
|
|
182
239
|
];
|
|
183
|
-
const table = (_jsx(LineItems, { lines: lines, columns: columns, getLineId: keyOf, mode: writing ? "edit" : "read", adding: adding, onChange: (key, next) => write((all) => all.map((one) => (keyOf(one) === key ? sameLine(one, next) : one))), newLine:
|
|
240
|
+
const table = (_jsx(LineItems, { lines: lines, columns: columns, getLineId: keyOf, mode: writing ? "edit" : "read", adding: adding, onChange: (key, next) => write((all) => all.map((one) => (keyOf(one) === key ? sameLine(one, next) : one))), newLine: newLine, onAdd: (line) => write((all) => [...all, line]), onRemove: (key) => write((all) => all.filter((one) => keyOf(one) !== key)), onRestore: (line, index) => write((all) => [...all.slice(0, index), line, ...all.slice(index)]), onReorder: (key, before) => write((all) => moved(all, identity, key, before)),
|
|
184
241
|
// A cell says its own (web-ui 1.6 `cellState`): the line model's hints refined by the
|
|
185
242
|
// server's `items[i]`, the error pointing at it (under its value) and its warning.
|
|
186
243
|
cellState: (line, column) => {
|
|
@@ -232,8 +289,17 @@ export function RecordLinesEditor({ record, name, lines, look = {}, }) {
|
|
|
232
289
|
// screen's own controls included: the workspace opens it outside the line, a row commits when
|
|
233
290
|
// the focus leaves it, and the answer would land on a line no longer being written (over the
|
|
234
291
|
// line's dialog, a modal over a modal). Opening a chosen record is still the workspace's.
|
|
235
|
-
|
|
236
|
-
|
|
292
|
+
const inLine = opening === null ? null : withoutChoose(opening);
|
|
293
|
+
const lined = inLine === null ? (table) : (_jsx(RecordOpeningProvider, { value: inLine, children: table }));
|
|
294
|
+
if (addMany === undefined)
|
|
295
|
+
return lined;
|
|
296
|
+
return (_jsxs("div", { className: "flex flex-col gap-2", children: [lined, _jsx("div", { children: _jsx(Button, { size: "sm", role: "secondary", onClick: addMany, children: frameworkCopy().record.addMany }) })] }));
|
|
297
|
+
}
|
|
298
|
+
/** The opening inside a line: without the workspace's chooser (see the end of the editor), or
|
|
299
|
+
* `null` when there is none to take away. */
|
|
300
|
+
function withoutChoose(opening) {
|
|
301
|
+
if (opening.choose === undefined)
|
|
302
|
+
return null;
|
|
237
303
|
const { choose: _, ...inLine } = opening;
|
|
238
|
-
return
|
|
304
|
+
return inLine;
|
|
239
305
|
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import type { Entity } from "@sincpro/client-framework";
|
|
2
|
+
import type { AnyRecord } from "@sincpro/criteria";
|
|
3
|
+
import { type ViewProps } from "@sincpro/web-composer";
|
|
4
|
+
import type { RecordRead } from "../../core/server.js";
|
|
5
|
+
import type { RecordReading } from "../../react/useRecord.js";
|
|
6
|
+
import { actionsOf, type ScreenActions } from "../list/dock.js";
|
|
7
|
+
import { type NoProps } from "../parts.js";
|
|
8
|
+
import { useRecordScreen } from "./record.js";
|
|
9
|
+
import { type ReactNode } from "react";
|
|
10
|
+
/**
|
|
11
|
+
* A record screen written as a tree of the framework's parts.
|
|
12
|
+
*
|
|
13
|
+
* <RecordScreen entity={invoices} {...props} actions={(invoice) => [...]}>
|
|
14
|
+
* <RecordScreen.Rail /> ← crumbs, pager and actions
|
|
15
|
+
* <RecordScreen.Paper>
|
|
16
|
+
* <RecordScreen.Notices />
|
|
17
|
+
* <InvoiceTotals /> ← the application's own block
|
|
18
|
+
* <RecordScreen.Fields names={["customer_id", "due_date"]} />
|
|
19
|
+
* <RecordScreen.Audit />
|
|
20
|
+
* </RecordScreen.Paper>
|
|
21
|
+
* </RecordScreen>
|
|
22
|
+
*
|
|
23
|
+
* With no children it draws the whole default screen (`EntityRecord` is exactly that). With
|
|
24
|
+
* children it draws only what is written: a part that is not written is not there, as in web-ui.
|
|
25
|
+
* A part written with no children of its own (`Rail`, `Paper`) draws its default content.
|
|
26
|
+
*
|
|
27
|
+
* Context: before it, a screen of its own had two choices — the whole `EntityRecord`, or
|
|
28
|
+
* `useRecordScreen` and web-ui's slot tree written by hand: the loading and failure guards, the
|
|
29
|
+
* crumbs, the pager, the audit, the notices `EntityRecord` drew and nobody else could. Each
|
|
30
|
+
* application wrote that again, or built a factory of screens to avoid it (quipu's
|
|
31
|
+
* `registroSimple`). The parts close that gap: take the default, replace one piece, keep the rest.
|
|
32
|
+
*
|
|
33
|
+
* How the parts reach web-ui: web-ui's `Record` reads its slots as DATA, by a mark on the
|
|
34
|
+
* element, and a slot wrapped in one of our components is never found (AGENTS.md). So a part
|
|
35
|
+
* here draws nothing itself: it is a mark (`part`, `web/parts.tsx`), and the root replaces it by
|
|
36
|
+
* web-ui's own slot, filled from the screen, before handing the tree to `Record`. A part that is
|
|
37
|
+
* drawn inside the paper (`Fields`, `Sections`) is an ordinary component that reads the screen
|
|
38
|
+
* from context. Anything else — web-ui's own slots, the application's components — passes as it
|
|
39
|
+
* was written.
|
|
40
|
+
*/
|
|
41
|
+
/** A record that is on screen: read, never loading or failed. */
|
|
42
|
+
export type ReadyRecord<T> = RecordReading<T> & {
|
|
43
|
+
status: "ready";
|
|
44
|
+
record: T;
|
|
45
|
+
error: null;
|
|
46
|
+
};
|
|
47
|
+
type Screen = ReturnType<typeof useRecordScreen<AnyRecord>>;
|
|
48
|
+
type RecordScreenState = {
|
|
49
|
+
screen: Screen;
|
|
50
|
+
reading: ReadyRecord<AnyRecord>;
|
|
51
|
+
/** The fields the screen shows by default: the root's `fields`, or the model's form. */
|
|
52
|
+
fields: readonly string[];
|
|
53
|
+
/** The embedded values drawn as sections of their own (a payment's receipt). */
|
|
54
|
+
sections: readonly string[];
|
|
55
|
+
/** The one2many drawn as pages. */
|
|
56
|
+
pages: readonly string[];
|
|
57
|
+
page: string | undefined;
|
|
58
|
+
setPage: (page: string) => void;
|
|
59
|
+
/** How many columns the form takes where it is mounted. */
|
|
60
|
+
columns: 1 | 2;
|
|
61
|
+
phone: boolean;
|
|
62
|
+
/** web-ui's «settings» form style: each section a card, so the main one needs its name. */
|
|
63
|
+
settings: boolean;
|
|
64
|
+
/** The actions the view style floats in the dock (the screen's and the lifecycle's). */
|
|
65
|
+
docked: ReturnType<typeof actionsOf>["dock"];
|
|
66
|
+
/** The actions the screen draws by hand, with the lifecycle's buttons beside them. */
|
|
67
|
+
drawn: ReactNode | null;
|
|
68
|
+
/** The restored draft's notice was put away: the draft stays, its notice is read. */
|
|
69
|
+
restoredAway: boolean;
|
|
70
|
+
putRestoredAway: () => void;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* The record on the screen around it, for a block the application writes inside a
|
|
74
|
+
* `RecordScreen`. It is always read: the screen draws its children only then.
|
|
75
|
+
*
|
|
76
|
+
* function InvoiceTotals() {
|
|
77
|
+
* const invoice = useScreenRecord(invoices);
|
|
78
|
+
* return <Money value={invoice.record.total} />;
|
|
79
|
+
* }
|
|
80
|
+
*
|
|
81
|
+
* The entity is only its type: the record is the screen's.
|
|
82
|
+
*/
|
|
83
|
+
export declare function useScreenRecord<T extends AnyRecord>(_entity?: Entity<T>): ReadyRecord<T>;
|
|
84
|
+
/**
|
|
85
|
+
* The record's fields in web-ui's form grid: two columns on a page and in a modal, one in a
|
|
86
|
+
* panel, a peek or a phone. `names` chooses and orders them; `title` heads the section.
|
|
87
|
+
*/
|
|
88
|
+
declare function Fields({ names, title, }: {
|
|
89
|
+
names?: readonly string[] | undefined;
|
|
90
|
+
title?: string | undefined;
|
|
91
|
+
}): import("react").JSX.Element;
|
|
92
|
+
/** Each value the record embeds (a payment's receipt) as a section of its own fields. */
|
|
93
|
+
declare function Sections(): import("react").JSX.Element;
|
|
94
|
+
export type RecordScreenProps<T extends AnyRecord> = ViewProps & {
|
|
95
|
+
entity: Entity<T>;
|
|
96
|
+
/** The record and its model already read on the server that renders the screen
|
|
97
|
+
* (`readRecordOnServer`): drawn filled there, and not asked again in the browser. */
|
|
98
|
+
initial?: RecordRead<T> | undefined;
|
|
99
|
+
/** Its name, the screen's way — for a record whose model has no display field. */
|
|
100
|
+
title?: ((record: T) => string | null) | undefined;
|
|
101
|
+
/** The line under its name, the screen's way. Without it, the record's type, if any. */
|
|
102
|
+
subtitle?: ((record: T) => string | null) | undefined;
|
|
103
|
+
/** The fields `RecordScreen.Fields` shows, in this order. Without it, the model's (`formOf`). */
|
|
104
|
+
fields?: readonly string[] | undefined;
|
|
105
|
+
/** The one2many `RecordScreen.Pages` shows, in this order. Without it, every one the model has. */
|
|
106
|
+
pages?: readonly string[] | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* The record's own actions, beside «save / discard» and its lifecycle («Eliminar»). As data
|
|
109
|
+
* (`DockAction`s) the view style draws them with the lifecycle's: the rail's buttons in
|
|
110
|
+
* `traditional`, one floating pill in `modern`. A node drawn by hand stays in the rail.
|
|
111
|
+
*/
|
|
112
|
+
actions?: ((record: RecordReading<T>) => ScreenActions) | undefined;
|
|
113
|
+
/** `false`: the screen draws its own history — it is not read. */
|
|
114
|
+
history?: boolean | undefined;
|
|
115
|
+
/** The screen's tree. Without it, the default screen. */
|
|
116
|
+
children?: ReactNode;
|
|
117
|
+
};
|
|
118
|
+
declare function RecordScreenRoot<T extends AnyRecord>({ api, resource, entity, initial, title, subtitle, fields, pages, actions, history, children, }: RecordScreenProps<T>): import("react").JSX.Element;
|
|
119
|
+
/**
|
|
120
|
+
* A record screen by parts: the framework's default, or any part of it replaced. See the top of
|
|
121
|
+
* this file.
|
|
122
|
+
*/
|
|
123
|
+
export declare const RecordScreen: typeof RecordScreenRoot & {
|
|
124
|
+
Rail: import("../parts.js").Part<{
|
|
125
|
+
children?: ReactNode;
|
|
126
|
+
}, RecordScreenState>;
|
|
127
|
+
Crumbs: import("../parts.js").Part<NoProps, RecordScreenState>;
|
|
128
|
+
Pager: import("../parts.js").Part<NoProps, RecordScreenState>;
|
|
129
|
+
Actions: import("../parts.js").Part<NoProps, RecordScreenState>;
|
|
130
|
+
Paper: import("../parts.js").Part<{
|
|
131
|
+
children?: ReactNode;
|
|
132
|
+
layout?: "horizontal" | "stacked";
|
|
133
|
+
width?: "reading" | "full";
|
|
134
|
+
}, RecordScreenState>;
|
|
135
|
+
Notices: import("../parts.js").Part<NoProps, RecordScreenState>;
|
|
136
|
+
Fields: typeof Fields;
|
|
137
|
+
Sections: typeof Sections;
|
|
138
|
+
Advice: import("../parts.js").Part<NoProps, RecordScreenState>;
|
|
139
|
+
Pages: import("../parts.js").Part<{
|
|
140
|
+
names?: readonly string[];
|
|
141
|
+
}, RecordScreenState>;
|
|
142
|
+
Audit: import("../parts.js").Part<NoProps, RecordScreenState>;
|
|
143
|
+
Activity: import("../parts.js").Part<NoProps, RecordScreenState>;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* The record of an entity, drawn from its model — the screen `entityView` opens when the
|
|
147
|
+
* application writes none: in the page, a modal, the preview or a panel, the same. It is
|
|
148
|
+
* `RecordScreen` with no tree of its own.
|
|
149
|
+
*
|
|
150
|
+
* entityView(invoices, { transport, name: "Facturas" }) // this screen
|
|
151
|
+
* entityView(invoices, { …, record: (props) =>
|
|
152
|
+
* <EntityRecord {...props} entity={invoices} fields={["customer_id", "due_date"]}
|
|
153
|
+
* actions={(invoice) => <CommandButton entity={invoices} command="post" … />} /> })
|
|
154
|
+
*/
|
|
155
|
+
export declare function EntityRecord<T extends AnyRecord>(props: Omit<RecordScreenProps<T>, "children" | "history">): import("react").JSX.Element;
|
|
156
|
+
export {};
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { labelOf } from "@sincpro/criteria";
|
|
4
|
+
import { usePhone } from "@sincpro/web-composer";
|
|
5
|
+
import { frameworkCopy } from "../../core/copy.js";
|
|
6
|
+
import { formOf } from "../../core/form.js";
|
|
7
|
+
import { summaryFieldsOf } from "../../core/summary.js";
|
|
8
|
+
import { actionsOf } from "../list/dock.js";
|
|
9
|
+
import { part, resolveParts, written } from "../parts.js";
|
|
10
|
+
import { RecordField } from "../record/edit.js";
|
|
11
|
+
import { LifecycleButtons, useRecordLifecycleActions, } from "../record/RecordLifecycle.js";
|
|
12
|
+
import { Refused } from "../Refused.js";
|
|
13
|
+
import { useRecordScreen } from "./record.js";
|
|
14
|
+
import { Button, FormSection, Record, Skeleton, useFormStyle } from "@sincpro/web-ui";
|
|
15
|
+
import { createContext, useContext, useState } from "react";
|
|
16
|
+
const RecordScreenContext = createContext(null);
|
|
17
|
+
function useScreenState(part) {
|
|
18
|
+
const state = useContext(RecordScreenContext);
|
|
19
|
+
if (state === null)
|
|
20
|
+
throw new Error(`RecordScreen.${part} is drawn inside a RecordScreen.`);
|
|
21
|
+
return state;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The record on the screen around it, for a block the application writes inside a
|
|
25
|
+
* `RecordScreen`. It is always read: the screen draws its children only then.
|
|
26
|
+
*
|
|
27
|
+
* function InvoiceTotals() {
|
|
28
|
+
* const invoice = useScreenRecord(invoices);
|
|
29
|
+
* return <Money value={invoice.record.total} />;
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* The entity is only its type: the record is the screen's.
|
|
33
|
+
*/
|
|
34
|
+
export function useScreenRecord(_entity) {
|
|
35
|
+
return useScreenState("useScreenRecord").reading;
|
|
36
|
+
}
|
|
37
|
+
/* ----------------------------------------------------------------------------------------- *
|
|
38
|
+
* Parts that become web-ui slots
|
|
39
|
+
* ----------------------------------------------------------------------------------------- */
|
|
40
|
+
/** A part of the record screen, resolved against its state. */
|
|
41
|
+
function screenPart(name, resolve) {
|
|
42
|
+
return part(`RecordScreen.${name}`, resolve);
|
|
43
|
+
}
|
|
44
|
+
/** The crumbs that lead back, when the workspace opened it from somewhere. */
|
|
45
|
+
const Crumbs = screenPart("Crumbs", (_props, { screen }) => screen.crumbs.length === 0 ? null : _jsx(Record.Crumbs, { crumbs: screen.crumbs }));
|
|
46
|
+
/** «3 / 64» and the neighbours, when it was opened from a list and nothing is typed. */
|
|
47
|
+
const Pager = screenPart("Pager", (_props, { screen }) => screen.pager === undefined ? null : _jsx(Record.Pager, { ...screen.pager }));
|
|
48
|
+
/** The screen's actions and the record's lifecycle — floating in the dock, or in the rail when
|
|
49
|
+
* the screen draws them by hand. The application's word on the record's moment goes with them. */
|
|
50
|
+
const Actions = screenPart("Actions", (_props, state) => {
|
|
51
|
+
const { docked, drawn, screen } = state;
|
|
52
|
+
const moment = screen.moment;
|
|
53
|
+
return [
|
|
54
|
+
drawn === null ? null : _jsx(Record.Actions, { children: drawn }, "actions"),
|
|
55
|
+
docked.length === 0 && moment === undefined ? null : (_jsx(Record.Dock, { actions: docked, ...(moment === undefined ? {} : { moment }) }, "dock")),
|
|
56
|
+
];
|
|
57
|
+
});
|
|
58
|
+
/** The band in front of the record. Empty, it draws crumbs, pager and actions — and no band at
|
|
59
|
+
* all when none of them has anything to say (an empty one is a blank strip in a modal). */
|
|
60
|
+
const Rail = screenPart("Rail", ({ children }, state) => {
|
|
61
|
+
const inside = written(resolveParts(children ?? [_jsx(Crumbs, {}, "crumbs"), _jsx(Pager, {}, "pager"), _jsx(Actions, {}, "actions")], state));
|
|
62
|
+
return inside.length === 0 ? null : _jsx(Record.Rail, { children: inside });
|
|
63
|
+
});
|
|
64
|
+
/** Who made it and who changed it last, when the record says so. */
|
|
65
|
+
const Audit = screenPart("Audit", (_props, { screen }) => screen.audit === undefined ? null : _jsx(Record.Audit, { ...screen.audit }));
|
|
66
|
+
/** The record's history beside the paper, unless the screen read none. */
|
|
67
|
+
const Activity = screenPart("Activity", (_props, { screen }) => screen.history === undefined ? null : _jsx(Record.Activity, { events: screen.history }));
|
|
68
|
+
/** The one2many as pages of a notebook — `names` chooses and orders them. Not on a new record:
|
|
69
|
+
* it has no lines on the server yet. */
|
|
70
|
+
const Pages = screenPart("Pages", ({ names }, state) => {
|
|
71
|
+
const { reading, page, setPage } = state;
|
|
72
|
+
const tabs = names ?? state.pages;
|
|
73
|
+
if (tabs.length === 0 || reading.isNew)
|
|
74
|
+
return null;
|
|
75
|
+
return (_jsx(Record.Pages, { current: page ?? tabs[0], onChange: setPage, children: tabs.map((name) => (_jsx(Record.Page, { id: name, label: labelOf(reading.meta, name, reading.locale), children: _jsx(RecordField, { record: reading, name: name, bare: true }) }, name))) }));
|
|
76
|
+
});
|
|
77
|
+
/**
|
|
78
|
+
* What happened to the edit itself, as web-ui's notices of the record — never among the fields:
|
|
79
|
+
* someone else saved first (`bad`: it blocks, so it stays in view between the rail and the
|
|
80
|
+
* paper, with «Read it again»), or a kept draft came back (`info`: into the rail's indicator,
|
|
81
|
+
* and it can be put away). Written at the top of the screen or inside the paper, the same.
|
|
82
|
+
*/
|
|
83
|
+
const Notices = screenPart("Notices", (_props, state) => {
|
|
84
|
+
const { reading, restoredAway, putRestoredAway } = state;
|
|
85
|
+
const copy = frameworkCopy().record;
|
|
86
|
+
const { conflict, restored } = reading.edit;
|
|
87
|
+
return [
|
|
88
|
+
conflict ? (_jsx(Record.Notice, { tone: "bad", action: _jsx(Button, { size: "sm", role: "secondary", onClick: reading.reload, children: copy.reload }), children: copy.conflict }, "conflict")) : null,
|
|
89
|
+
restored && !restoredAway ? (_jsx(Record.Notice, { tone: "info", onDismiss: putRestoredAway, children: copy.restored }, "restored")) : null,
|
|
90
|
+
];
|
|
91
|
+
});
|
|
92
|
+
/**
|
|
93
|
+
* What the server advised about the record or one of its fields, as notices of the record: one
|
|
94
|
+
* the save will refuse while it holds is a warning. A line's warning goes on its line.
|
|
95
|
+
*/
|
|
96
|
+
const Advice = screenPart("Advice", (_props, { reading }) => reading.edit.advice
|
|
97
|
+
.filter((one) => (one.path?.length ?? 0) <= 1)
|
|
98
|
+
.map((one) => (_jsx(Record.Notice, { tone: one.blocks_save === true ? "warn" : "info", children: one.message }, one.message))));
|
|
99
|
+
/* ----------------------------------------------------------------------------------------- *
|
|
100
|
+
* Parts drawn inside the paper
|
|
101
|
+
* ----------------------------------------------------------------------------------------- */
|
|
102
|
+
/**
|
|
103
|
+
* The record's fields in web-ui's form grid: two columns on a page and in a modal, one in a
|
|
104
|
+
* panel, a peek or a phone. `names` chooses and orders them; `title` heads the section.
|
|
105
|
+
*/
|
|
106
|
+
function Fields({ names, title, }) {
|
|
107
|
+
const state = useScreenState("Fields");
|
|
108
|
+
return (_jsx(FormSection, { columns: state.columns, ...(title === undefined ? {} : { title }), children: (names ?? state.fields).map((name) => (_jsx(RecordField, { record: state.reading, name: name }, name))) }));
|
|
109
|
+
}
|
|
110
|
+
/** Each value the record embeds (a payment's receipt) as a section of its own fields. */
|
|
111
|
+
function Sections() {
|
|
112
|
+
const { reading, sections, columns } = useScreenState("Sections");
|
|
113
|
+
const { meta, locale } = reading;
|
|
114
|
+
return (_jsx(_Fragment, { children: sections.map((name) => (_jsx(FormSection, { title: labelOf(meta, name, locale), columns: columns, children: Object.keys(meta?.fields[name]?.definition?.fields ?? {}).map((one) => (_jsx(RecordField, { record: reading, name: `${name}.${one}` }, one))) }, name))) }));
|
|
115
|
+
}
|
|
116
|
+
/** The paper's default content, in the order every record screen draws it — as elements, never
|
|
117
|
+
* a component: web-ui finds `Pages` and `Audit` among the paper's own children. */
|
|
118
|
+
function paperContent(titled) {
|
|
119
|
+
return (_jsxs(_Fragment, { children: [_jsx(Notices, {}), _jsx(Fields, { title: titled ? frameworkCopy().record.general : undefined }), _jsx(Sections, {}), _jsx(Advice, {}), _jsx(Pages, {}), _jsx(Audit, {})] }));
|
|
120
|
+
}
|
|
121
|
+
/** The paper: the record itself. Empty, it draws the default content. */
|
|
122
|
+
const Paper = screenPart("Paper", ({ children, layout, width }, state) => (_jsx(Record.Paper, { layout: layout ?? (state.phone ? "stacked" : "horizontal"), ...(width === undefined ? {} : { width }), children: resolveParts(children ?? paperContent(state.settings && state.sections.length > 0), state) })));
|
|
123
|
+
function RecordScreenRoot({ api, resource, entity, initial, title, subtitle, fields, pages, actions, history, children, }) {
|
|
124
|
+
const screen = useRecordScreen(entity, { api, resource }, { title, subtitle, initial, history });
|
|
125
|
+
const { reading } = screen;
|
|
126
|
+
const [page, setPage] = useState(undefined);
|
|
127
|
+
const [restoredAway, setRestoredAway] = useState(false);
|
|
128
|
+
const phone = usePhone(api);
|
|
129
|
+
const settings = useFormStyle() === "settings";
|
|
130
|
+
// Its own lifecycle (`Delete`, the trash): once it is out of every reading the surface closes,
|
|
131
|
+
// and every list that showed it reads again by itself.
|
|
132
|
+
const lifecycle = useRecordLifecycleActions(reading, (done) => done === "restore" ? reading.reload() : api.close());
|
|
133
|
+
if (reading.status === "loading")
|
|
134
|
+
return _jsx(Skeleton, { rows: 6, label: frameworkCopy().record.loading });
|
|
135
|
+
if (reading.status === "failed")
|
|
136
|
+
return _jsx(Refused, { error: reading.error, onRetry: reading.reload });
|
|
137
|
+
const { meta, edit } = reading;
|
|
138
|
+
const layout = formOf(meta, entity.summary);
|
|
139
|
+
// What the header already says — the name, the state, the type — is not said again as a
|
|
140
|
+
// field, unless it can be typed in now: then the field is its control, not a repetition.
|
|
141
|
+
const parts = summaryFieldsOf(meta, reading.record, entity.summary);
|
|
142
|
+
const said = new Set([meta?.display, parts.state, parts.type]);
|
|
143
|
+
const own = actionsOf(actions?.(reading) ?? null);
|
|
144
|
+
const state = {
|
|
145
|
+
screen: screen,
|
|
146
|
+
reading: reading,
|
|
147
|
+
fields: fields ??
|
|
148
|
+
layout.fields.filter((name) => reading.isNew || !said.has(name) || !edit.state(name).readonly),
|
|
149
|
+
// Chosen fields are the whole form: the embedded sections come only with the model's.
|
|
150
|
+
sections: fields === undefined ? layout.sections : [],
|
|
151
|
+
pages: pages ?? layout.pages,
|
|
152
|
+
page,
|
|
153
|
+
setPage,
|
|
154
|
+
// On a phone a form is one column: two side by side at 400 px squeezed a text area beside
|
|
155
|
+
// its word (web-ui's grid does not narrow by itself).
|
|
156
|
+
columns: phone || (api.surface !== "page" && api.surface !== "modal") ? 1 : 2,
|
|
157
|
+
phone,
|
|
158
|
+
settings,
|
|
159
|
+
docked: own.drawn === null ? [...own.dock, ...lifecycle.actions] : [],
|
|
160
|
+
drawn: own.drawn === null ? null : (_jsxs(_Fragment, { children: [own.drawn, _jsx(LifecycleButtons, { actions: lifecycle.actions })] })),
|
|
161
|
+
restoredAway,
|
|
162
|
+
putRestoredAway: () => setRestoredAway(true),
|
|
163
|
+
};
|
|
164
|
+
const tree = children ?? (_jsxs(_Fragment, { children: [_jsx(Rail, {}), _jsx(Paper, {}), _jsx(Activity, {})] }));
|
|
165
|
+
return (_jsxs(RecordScreenContext.Provider, { value: state, children: [_jsx(Record, { ...screen.record, children: resolveParts(tree, state) }), lifecycle.dialog] }));
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* A record screen by parts: the framework's default, or any part of it replaced. See the top of
|
|
169
|
+
* this file.
|
|
170
|
+
*/
|
|
171
|
+
export const RecordScreen = Object.assign(RecordScreenRoot, {
|
|
172
|
+
Rail,
|
|
173
|
+
Crumbs,
|
|
174
|
+
Pager,
|
|
175
|
+
Actions,
|
|
176
|
+
Paper,
|
|
177
|
+
Notices,
|
|
178
|
+
Fields,
|
|
179
|
+
Sections,
|
|
180
|
+
Advice,
|
|
181
|
+
Pages,
|
|
182
|
+
Audit,
|
|
183
|
+
Activity,
|
|
184
|
+
});
|
|
185
|
+
/**
|
|
186
|
+
* The record of an entity, drawn from its model — the screen `entityView` opens when the
|
|
187
|
+
* application writes none: in the page, a modal, the preview or a panel, the same. It is
|
|
188
|
+
* `RecordScreen` with no tree of its own.
|
|
189
|
+
*
|
|
190
|
+
* entityView(invoices, { transport, name: "Facturas" }) // this screen
|
|
191
|
+
* entityView(invoices, { …, record: (props) =>
|
|
192
|
+
* <EntityRecord {...props} entity={invoices} fields={["customer_id", "due_date"]}
|
|
193
|
+
* actions={(invoice) => <CommandButton entity={invoices} command="post" … />} /> })
|
|
194
|
+
*/
|
|
195
|
+
export function EntityRecord(props) {
|
|
196
|
+
return _jsx(RecordScreen, { ...props });
|
|
197
|
+
}
|
|
@@ -7,7 +7,9 @@ import type { DateStyle } from "../../core/present.js";
|
|
|
7
7
|
import type { RichTextSettings } from "../../core/richText.js";
|
|
8
8
|
import { type ReactNode } from "react";
|
|
9
9
|
export declare function SincproApp({ transport, views, start, language, metas, entities, empty, skin, cache, timeZone, dateStyle, currency, region, richText, uploads, events, workspace: given, bar, onViewError, changes, }: {
|
|
10
|
-
|
|
10
|
+
/** Who answers. Without it, the `FrameworkProvider` around the app — one provider for every
|
|
11
|
+
* face of a product. */
|
|
12
|
+
transport?: Transport;
|
|
11
13
|
/** The entities as composer views — `entityView(…)` — and any other view of the app. */
|
|
12
14
|
views: readonly ViewSpec[];
|
|
13
15
|
/** The application's entities: a form draws a many2one of any of them without being told. */
|
|
@@ -5,7 +5,7 @@ import { Composer, installComposerCopy, SPANISH_COMPOSER_COPY, useWorkspace, } f
|
|
|
5
5
|
import { createRegistry, formatRef, PHONE_WIDTH } from "@sincpro/web-composer/domain";
|
|
6
6
|
import { cachedTransport, } from "../../core/cache.js";
|
|
7
7
|
import { installFrameworkCopy, SPANISH_FRAMEWORK_COPY, } from "../../core/copy.js";
|
|
8
|
-
import { FrameworkProvider } from "../../react/context.js";
|
|
8
|
+
import { FrameworkProvider, ModelDefinitions, useFrameworkIfAny, } from "../../react/context.js";
|
|
9
9
|
import { useSearchRecords } from "../list/records.js";
|
|
10
10
|
import { webUiSkin } from "./skin.js";
|
|
11
11
|
import { installCopy, SearchProvider, SPANISH_COPY, ToastProvider, useSearchSettings, } from "@sincpro/web-ui";
|
|
@@ -25,6 +25,17 @@ import { useEffect, useMemo, useState, useSyncExternalStore } from "react";
|
|
|
25
25
|
*
|
|
26
26
|
* const workspace = useWorkspace();
|
|
27
27
|
* <SincproApp workspace={workspace} bar={<Menu onOpen={(ref) => workspace.push(ref)} />} … />
|
|
28
|
+
*
|
|
29
|
+
* Inside a product with several faces it is ONE of them: without `transport` it joins the
|
|
30
|
+
* `FrameworkProvider` around it — its transport and cache, its context, its zone and currency —
|
|
31
|
+
* and brings only what is its own: its entities, the definitions of their models and their facts
|
|
32
|
+
* (`ModelDefinitions`). The configuration of the provider's (`timeZone`, `currency`, `region`,
|
|
33
|
+
* `dateStyle`, `richText`, `uploads`, `cache`, `changes`) is then the provider's: said once.
|
|
34
|
+
*
|
|
35
|
+
* <FrameworkProvider transport={transport} timeZone="America/La_Paz" currency="BOB">
|
|
36
|
+
* <Site />
|
|
37
|
+
* <SincproApp views={views} entities={billing.entities} metas={metasOf(billing)} />
|
|
38
|
+
* </FrameworkProvider>
|
|
28
39
|
*/
|
|
29
40
|
/** Narrower than composer's phone (`PHONE_WIDTH`): the workspace fills the window here, so the
|
|
30
41
|
* window's width is the workspace's. */
|
|
@@ -61,7 +72,10 @@ export function SincproApp({ transport, views, start, language = "es", metas, en
|
|
|
61
72
|
}
|
|
62
73
|
return null;
|
|
63
74
|
});
|
|
64
|
-
const
|
|
75
|
+
const around = useFrameworkIfAny();
|
|
76
|
+
if (transport === undefined && around === null)
|
|
77
|
+
throw new Error("SincproApp needs a transport, or a FrameworkProvider around it.");
|
|
78
|
+
const cached = useMemo(() => transport === undefined || cache === false
|
|
65
79
|
? transport
|
|
66
80
|
: cachedTransport(transport, {
|
|
67
81
|
...(entities === undefined ? {} : { entities }),
|
|
@@ -74,7 +88,7 @@ export function SincproApp({ transport, views, start, language = "es", metas, en
|
|
|
74
88
|
// read: a change of context forgets every answer, a write what it touched — whoever wrote it, a
|
|
75
89
|
// use case's client as much as a screen — before the screens read again.
|
|
76
90
|
useEffect(() => {
|
|
77
|
-
if (cache === false)
|
|
91
|
+
if (cached === undefined || cache === false)
|
|
78
92
|
return;
|
|
79
93
|
const forgetting = cached;
|
|
80
94
|
const unwatch = processContext.watch(() => forgetting.invalidate());
|
|
@@ -96,5 +110,9 @@ export function SincproApp({ transport, views, start, language = "es", metas, en
|
|
|
96
110
|
// The first screen only: a re-render must not push it again.
|
|
97
111
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
98
112
|
}, [workspace]);
|
|
99
|
-
|
|
113
|
+
const shell = (_jsx(FrameworkSearch, { children: _jsx(ToastProvider, { children: _jsxs("div", { className: "flex h-dvh min-h-0 flex-col bg-ground", children: [bar, _jsx("div", { className: "flex min-h-0 flex-1 flex-col", children: _jsx(Composer, { workspace: workspace, registry: registry, skin: skin, onViewError: onViewError, ...(empty === undefined ? {} : { empty }) }) })] }) }) }));
|
|
114
|
+
// One face of a product: the provider around it is the app's, and this brings only its own.
|
|
115
|
+
if (cached === undefined)
|
|
116
|
+
return (_jsx(ModelDefinitions, { ...(entities === undefined ? {} : { entities }), ...(metas === undefined ? {} : { metas }), ...(events === undefined ? {} : { events }), children: shell }));
|
|
117
|
+
return (_jsx(FrameworkProvider, { transport: cached, locale: language, changes: changes, ...(metas === undefined ? {} : { metas }), ...(entities === undefined ? {} : { entities }), ...(timeZone === undefined ? {} : { timeZone }), dateStyle: dateStyle ?? (phone ? "literal" : "numeric"), ...(currency === undefined ? {} : { currency }), ...(region === undefined ? {} : { region }), ...(richText === undefined ? {} : { richText }), ...(uploads === undefined ? {} : { uploads }), ...(events === undefined ? {} : { events }), children: shell }));
|
|
100
118
|
}
|
|
@@ -11,7 +11,7 @@ import { EntityList } from "../list/EntityList.js";
|
|
|
11
11
|
import { findChoices, recordsBrowser, RecordsBrowserProvider, refusalNotice, useSearchRecords, } from "../list/records.js";
|
|
12
12
|
import { RecordOpeningProvider, } from "../record/opening.js";
|
|
13
13
|
import { openIn, RECORD_SIZE, targetsFor } from "./open.js";
|
|
14
|
-
import { EntityRecord } from "./
|
|
14
|
+
import { EntityRecord } from "./RecordScreen.js";
|
|
15
15
|
import { useToastIfAny } from "@sincpro/web-ui";
|
|
16
16
|
import { useMemo } from "react";
|
|
17
17
|
/**
|
|
@@ -2,8 +2,6 @@ import { type Entity } from "@sincpro/client-framework";
|
|
|
2
2
|
import type { AnyRecord } from "@sincpro/criteria";
|
|
3
3
|
import { type ViewProps } from "@sincpro/web-composer";
|
|
4
4
|
import type { RecordRead } from "../../core/server.js";
|
|
5
|
-
import { type RecordReading } from "../../react/useRecord.js";
|
|
6
|
-
import { type ScreenActions } from "../list/dock.js";
|
|
7
5
|
/** Who made a record, or changed it last, and when: `Record.Audit`'s. */
|
|
8
6
|
export type Stamp = {
|
|
9
7
|
at: string;
|
|
@@ -40,13 +38,16 @@ export type Stamp = {
|
|
|
40
38
|
*/
|
|
41
39
|
export declare function useRecordScreen<T extends AnyRecord>(entity: Entity<T>, { api, resource }: Pick<ViewProps, "api" | "resource">, options?: {
|
|
42
40
|
title?: ((record: T) => string | null) | undefined;
|
|
41
|
+
/** The line under its name, the screen's way (an enrollment's course, an order's detail).
|
|
42
|
+
* Without it, or when it answers `null`, the record's type when the model has one. */
|
|
43
|
+
subtitle?: ((record: T) => string | null) | undefined;
|
|
43
44
|
/** `false`: the screen draws its own history — it is not read here. */
|
|
44
45
|
history?: boolean | undefined;
|
|
45
46
|
/** The record and its model already read on the server that renders the screen
|
|
46
47
|
* (`readRecordOnServer`): it starts from it, filled in the HTML (`useRecord`). */
|
|
47
48
|
initial?: RecordRead<T> | undefined;
|
|
48
49
|
}): {
|
|
49
|
-
reading: RecordReading<T>;
|
|
50
|
+
reading: import("../../react/useRecord.js").RecordReading<T>;
|
|
50
51
|
crumbs: readonly import("@sincpro/web-composer").Crumb[];
|
|
51
52
|
history: import("../../index.js").HistoryEntry[] | undefined;
|
|
52
53
|
summary: import("../../core/summary.js").RecordSummary | undefined;
|
|
@@ -79,22 +80,3 @@ export declare function useRecordScreen<T extends AnyRecord>(entity: Entity<T>,
|
|
|
79
80
|
created?: Stamp | undefined;
|
|
80
81
|
} | undefined;
|
|
81
82
|
};
|
|
82
|
-
export declare function EntityRecord<T extends AnyRecord>({ api, resource, entity, fields, pages, actions, title, initial, }: ViewProps & {
|
|
83
|
-
entity: Entity<T>;
|
|
84
|
-
/** The record and its model already read on the server that renders the screen
|
|
85
|
-
* (`readRecordOnServer`): drawn filled there, and not asked again in the browser. */
|
|
86
|
-
initial?: RecordRead<T> | undefined;
|
|
87
|
-
/** Its name, the screen's way — for a record whose model has no display field. */
|
|
88
|
-
title?: (record: T) => string | null;
|
|
89
|
-
/** The fields, in this order. Without it, the model's (`formOf`). */
|
|
90
|
-
fields?: readonly string[];
|
|
91
|
-
/** The one2many shown as pages, in this order. Without it, every one the model has. */
|
|
92
|
-
pages?: readonly string[];
|
|
93
|
-
/**
|
|
94
|
-
* The record's own actions, beside «save / discard» and its lifecycle («Eliminar»). As data
|
|
95
|
-
* (`DockAction`s) the application's view style draws them with the lifecycle's: the rail's
|
|
96
|
-
* buttons in `traditional`, one pill floating at the bottom in `modern` (web-ui's
|
|
97
|
-
* `Record.Dock`). A node drawn by hand stays in the rail.
|
|
98
|
-
*/
|
|
99
|
-
actions?: (record: RecordReading<T>) => ScreenActions;
|
|
100
|
-
}): import("react").JSX.Element;
|