@sincpro/web-framework 2.6.0 → 3.1.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 +62 -31
- package/dist/core/copy.d.ts +19 -1
- package/dist/core/copy.js +36 -0
- package/dist/core/explain.d.ts +12 -4
- package/dist/core/explain.js +18 -6
- package/dist/core/form.d.ts +7 -3
- package/dist/core/form.js +11 -5
- package/dist/core/groups.d.ts +17 -0
- package/dist/core/groups.js +31 -0
- package/dist/core/history.d.ts +45 -1
- package/dist/core/history.js +84 -12
- package/dist/core/index.d.ts +5 -4
- package/dist/core/index.js +5 -4
- package/dist/core/list.d.ts +14 -16
- package/dist/core/list.js +18 -25
- package/dist/core/measure.d.ts +14 -5
- package/dist/core/measure.js +32 -7
- package/dist/core/present.d.ts +51 -3
- package/dist/core/present.js +162 -15
- package/dist/core/summary.d.ts +6 -2
- package/dist/react/context.d.ts +23 -2
- package/dist/react/context.js +51 -2
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +2 -1
- package/dist/react/useCommand.d.ts +7 -1
- package/dist/react/useCommand.js +12 -2
- package/dist/react/useGroups.js +15 -4
- package/dist/react/useHistory.d.ts +4 -2
- package/dist/react/useHistory.js +20 -5
- package/dist/react/usePivot.js +18 -3
- package/dist/react/useRecord.d.ts +5 -2
- package/dist/react/useRecord.js +14 -2
- package/dist/react/useRecordLifecycle.d.ts +43 -0
- package/dist/react/useRecordLifecycle.js +49 -0
- package/dist/web/Refused.d.ts +3 -3
- package/dist/web/Refused.js +3 -3
- package/dist/web/index.d.ts +3 -2
- package/dist/web/index.js +2 -1
- package/dist/web/list/EntityList.js +70 -17
- package/dist/web/list/columns.d.ts +6 -1
- package/dist/web/list/columns.js +53 -8
- package/dist/web/list/presentation.d.ts +20 -1
- package/dist/web/list/rowCommands.d.ts +2 -0
- package/dist/web/list/rowCommands.js +6 -1
- package/dist/web/record/RecordLifecycle.d.ts +23 -0
- package/dist/web/record/RecordLifecycle.js +29 -0
- package/dist/web/record/RelatedList.d.ts +0 -15
- package/dist/web/record/RelatedList.js +35 -6
- package/dist/web/record/edit.d.ts +5 -0
- package/dist/web/record/edit.js +48 -8
- package/dist/web/record/opening.d.ts +2 -2
- package/dist/web/record/record.js +5 -2
- package/dist/web/workspace/SincproApp.d.ts +10 -1
- package/dist/web/workspace/SincproApp.js +18 -4
- package/dist/web/workspace/composer.d.ts +1 -1
- package/dist/web/workspace/composer.js +3 -4
- package/dist/web/workspace/record.d.ts +7 -2
- package/dist/web/workspace/record.js +41 -8
- package/package.json +6 -6
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AnyRecord } from "@sincpro/criteria";
|
|
2
|
+
import type { RecordReading } from "../../react/useRecord.js";
|
|
3
|
+
/**
|
|
4
|
+
* The record's own lifecycle as buttons — «Mover a la papelera» / «Restaurar» and «Eliminar»,
|
|
5
|
+
* each when its entity declares sincpro_framework's `Archive`, `Restore`, `Delete` — a deletion
|
|
6
|
+
* asking the server first what it would do (its dry run) and doing it on «Hacerlo», the trash's
|
|
7
|
+
* two on the click (they can be undone). Nothing when the entity declares none, or the record is
|
|
8
|
+
* new.
|
|
9
|
+
*
|
|
10
|
+
* <Record.Actions>
|
|
11
|
+
* <RecordLifecycle record={member} onDone={() => api.close()} />
|
|
12
|
+
* </Record.Actions>
|
|
13
|
+
*
|
|
14
|
+
* Context: `EntityRecord` draws it; a screen of its own draws it the same, or drops to
|
|
15
|
+
* `useRecordLifecycle` and draws its own. What happens after is the screen's (`onDone`): in a
|
|
16
|
+
* workspace the surface closes — the record is gone —, and every list that showed it reads
|
|
17
|
+
* again by itself (the write is announced).
|
|
18
|
+
*/
|
|
19
|
+
export declare function RecordLifecycle<T extends AnyRecord>({ record, onDone, }: {
|
|
20
|
+
record: RecordReading<T>;
|
|
21
|
+
/** Done: which action — after `delete` and `archive` the record is out of every reading. */
|
|
22
|
+
onDone?: (action: "delete" | "archive" | "restore") => void;
|
|
23
|
+
}): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { frameworkCopy } from "../../core/copy.js";
|
|
4
|
+
import { useRecordLifecycle } from "../../react/useRecordLifecycle.js";
|
|
5
|
+
import { ActionButton } from "./ActionButton.js";
|
|
6
|
+
/**
|
|
7
|
+
* The record's own lifecycle as buttons — «Mover a la papelera» / «Restaurar» and «Eliminar»,
|
|
8
|
+
* each when its entity declares sincpro_framework's `Archive`, `Restore`, `Delete` — a deletion
|
|
9
|
+
* asking the server first what it would do (its dry run) and doing it on «Hacerlo», the trash's
|
|
10
|
+
* two on the click (they can be undone). Nothing when the entity declares none, or the record is
|
|
11
|
+
* new.
|
|
12
|
+
*
|
|
13
|
+
* <Record.Actions>
|
|
14
|
+
* <RecordLifecycle record={member} onDone={() => api.close()} />
|
|
15
|
+
* </Record.Actions>
|
|
16
|
+
*
|
|
17
|
+
* Context: `EntityRecord` draws it; a screen of its own draws it the same, or drops to
|
|
18
|
+
* `useRecordLifecycle` and draws its own. What happens after is the screen's (`onDone`): in a
|
|
19
|
+
* workspace the surface closes — the record is gone —, and every list that showed it reads
|
|
20
|
+
* again by itself (the write is announced).
|
|
21
|
+
*/
|
|
22
|
+
export function RecordLifecycle({ record, onDone, }) {
|
|
23
|
+
const lifecycle = useRecordLifecycle(record);
|
|
24
|
+
const copy = frameworkCopy().record;
|
|
25
|
+
const shown = ["archive", "restore", "delete"].filter((one) => lifecycle[one] !== undefined);
|
|
26
|
+
if (shown.length === 0)
|
|
27
|
+
return null;
|
|
28
|
+
return (_jsx(_Fragment, { children: shown.map((one) => (_jsx(ActionButton, { action: lifecycle[one], label: copy[one], onDone: () => onDone?.(one) }, one))) }));
|
|
29
|
+
}
|
|
@@ -2,21 +2,6 @@ import { type Entity } from "@sincpro/client-framework";
|
|
|
2
2
|
import type { AnyRecord } from "@sincpro/criteria";
|
|
3
3
|
import type { RecordReading } from "../../react/useRecord.js";
|
|
4
4
|
import { type EntityListProps } from "../list/EntityList.js";
|
|
5
|
-
/**
|
|
6
|
-
* A relation of a record as a list inside it — searched, ordered and paged by the server.
|
|
7
|
-
*
|
|
8
|
-
* Context: the same `EntityList` a screen uses, `embedded` so it reads as a field of the record
|
|
9
|
-
* (a one-line bar that does not stick), over `useRelated`. Its search box fills the RELATED
|
|
10
|
-
* entity's own search template: the lines of an order are searched by product, the invoices of
|
|
11
|
-
* a customer by number. The column that points back to this record is left out — it is the
|
|
12
|
-
* same on every row. Use `RecordLines` when the page the record brought is all there is.
|
|
13
|
-
*
|
|
14
|
-
* «Agregar» opens the form of a new related record already pointing back here, where the view
|
|
15
|
-
* says (`RecordOpening.create`: a modal that answers, in a workspace), and the list is read
|
|
16
|
-
* again once it exists. Never a row of the table: each one is an aggregate with its own create,
|
|
17
|
-
* rules and preview. There is none while this record does not exist yet — there is nothing to
|
|
18
|
-
* point back to — nor when the relation is read only or the entity cannot be created.
|
|
19
|
-
*/
|
|
20
5
|
export declare function RelatedList<P extends AnyRecord, T extends AnyRecord>({ record, name, entity, pageSize, ...list }: {
|
|
21
6
|
record: RecordReading<P>;
|
|
22
7
|
name: string;
|
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import {} from "@sincpro/client-framework";
|
|
4
4
|
import { frameworkCopy } from "../../core/copy.js";
|
|
5
|
-
import {
|
|
5
|
+
import { fieldStateOf } from "../../core/edit.js";
|
|
6
|
+
import { defaultFields, STAMPS } from "../../core/present.js";
|
|
6
7
|
import { backReference, isKeyValue } from "../../core/relation.js";
|
|
7
8
|
import { useRelated } from "../../react/useRelated.js";
|
|
8
9
|
import { EntityList } from "../list/EntityList.js";
|
|
10
|
+
import { presentationOf } from "../list/presentation.js";
|
|
9
11
|
import { useRecordOpening } from "./opening.js";
|
|
10
12
|
import { Button } from "@sincpro/web-ui";
|
|
11
|
-
import { useMemo } from "react";
|
|
13
|
+
import { useMemo, useRef } from "react";
|
|
12
14
|
/**
|
|
13
15
|
* A relation of a record as a list inside it — searched, ordered and paged by the server.
|
|
14
16
|
*
|
|
@@ -18,12 +20,20 @@ import { useMemo } from "react";
|
|
|
18
20
|
* a customer by number. The column that points back to this record is left out — it is the
|
|
19
21
|
* same on every row. Use `RecordLines` when the page the record brought is all there is.
|
|
20
22
|
*
|
|
23
|
+
* It reads as a part of the record, not as a screen: its columns are the related entity's own
|
|
24
|
+
* (`presented(entity, { columns })`), else its fields without the framework's stamps (created,
|
|
25
|
+
* updated, version) and without a key nobody reads (a UUID identity that is not its name); and a
|
|
26
|
+
* relation of ten records or fewer has no search bar — three dues of a payment are read, not
|
|
27
|
+
* searched. A screen that wants them passes `columns` / `search`.
|
|
28
|
+
*
|
|
21
29
|
* «Agregar» opens the form of a new related record already pointing back here, where the view
|
|
22
30
|
* says (`RecordOpening.create`: a modal that answers, in a workspace), and the list is read
|
|
23
31
|
* again once it exists. Never a row of the table: each one is an aggregate with its own create,
|
|
24
32
|
* rules and preview. There is none while this record does not exist yet — there is nothing to
|
|
25
33
|
* point back to — nor when the relation is read only or the entity cannot be created.
|
|
26
34
|
*/
|
|
35
|
+
/** As many related records as are read at a glance — a picker opens with as many. */
|
|
36
|
+
const SHORT = 10;
|
|
27
37
|
export function RelatedList({ record, name, entity, pageSize, ...list }) {
|
|
28
38
|
const listing = useRelated(record, name, entity, pageSize === undefined ? {} : { pageSize });
|
|
29
39
|
const opening = useRecordOpening();
|
|
@@ -33,10 +43,24 @@ export function RelatedList({ record, name, entity, pageSize, ...list }) {
|
|
|
33
43
|
const pointing = backReference(record.record, record.meta?.fields[name], identity);
|
|
34
44
|
const back = pointing?.field;
|
|
35
45
|
const own = list.columns;
|
|
46
|
+
const look = presentationOf(entity).columns;
|
|
47
|
+
const meta = listing.meta;
|
|
36
48
|
const columns = useMemo(() => own ??
|
|
37
|
-
(
|
|
49
|
+
look?.filter((field) => field !== back) ??
|
|
50
|
+
(meta === null
|
|
38
51
|
? undefined
|
|
39
|
-
: defaultFields(
|
|
52
|
+
: defaultFields(meta).filter((field) => field !== back &&
|
|
53
|
+
!STAMPS.has(field) &&
|
|
54
|
+
// The identity is a column only when it is the record's name (a code, a number).
|
|
55
|
+
(field !== meta.identity || meta.display === field || !meta.display))), [own, look, meta, back]);
|
|
56
|
+
// A relation of a few records is read whole; the bar comes once there is more to find, and
|
|
57
|
+
// stays: a search that narrowed it to one must not take away the bar that undoes it.
|
|
58
|
+
const long = listing.count !== null &&
|
|
59
|
+
(!listing.count.exact || listing.count.value > Math.min(SHORT, listing.page.size));
|
|
60
|
+
const searching = listing.text !== "" || listing.selection !== undefined;
|
|
61
|
+
const barred = useRef(false);
|
|
62
|
+
if (long || searching)
|
|
63
|
+
barred.current = true;
|
|
40
64
|
const create = opening?.create;
|
|
41
65
|
// The value the rows point back with.
|
|
42
66
|
const here = pointing?.value;
|
|
@@ -45,8 +69,13 @@ export function RelatedList({ record, name, entity, pageSize, ...list }) {
|
|
|
45
69
|
!back ||
|
|
46
70
|
record.isNew ||
|
|
47
71
|
!isKeyValue(here) ||
|
|
48
|
-
|
|
49
|
-
|
|
72
|
+
// The relation's own hint — not whether THIS record can be written: adding stores another
|
|
73
|
+
// record (a customer only Commands move still gets new invoices).
|
|
74
|
+
fieldStateOf(record.meta, name, record.edit.values).readonly ? null : (_jsx(Button, { size: "sm", role: "secondary", onClick: () => create(entity, { [back]: here }, listing.reload), children: frameworkCopy().record.add }));
|
|
75
|
+
return (_jsx(EntityList, { listing: listing, embedded: true,
|
|
76
|
+
// The bar, not a box: a relation of records is searched like any list of records —
|
|
77
|
+
// named filters, the criteria builder, grouping. A screen that wants a box passes one.
|
|
78
|
+
search: barred.current ? "bar" : false, ...list, ...(columns === undefined ? {} : { columns }), ...(adding === null && list.actions === undefined
|
|
50
79
|
? {}
|
|
51
80
|
: {
|
|
52
81
|
actions: (_jsxs(_Fragment, { children: [list.actions, adding] })),
|
|
@@ -26,9 +26,14 @@ import type { ReactNode } from "react";
|
|
|
26
26
|
* A one2many is a block: its lines (`lines`) or its related list (`list`), each with every piece
|
|
27
27
|
* replaceable the screen's way.
|
|
28
28
|
*
|
|
29
|
+
* A value the record embeds (a payment's receipt) is drawn from its definition: `name="recibo"`
|
|
30
|
+
* is a section of its fields, and `name="recibo.numero"` is one of them — its label and type the
|
|
31
|
+
* definition's, read only when the embedded value is, and written back into the value whole.
|
|
32
|
+
*
|
|
29
33
|
* <RecordField record={invoice} name="due_date" />
|
|
30
34
|
* <RecordField record={invoice} name="customer_id" />
|
|
31
35
|
* <RecordField record={invoice} name="lines" lines={{ controls: { qty: Stepper } }} />
|
|
36
|
+
* <RecordField record={pago} name="recibo.numero" />
|
|
32
37
|
*/
|
|
33
38
|
export declare function RecordField<T extends Record<string, unknown>>({ record, name, as, bare, lines: look, list: listed, }: {
|
|
34
39
|
record: RecordReading<T>;
|
package/dist/web/record/edit.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import {} from "@sincpro/client-framework";
|
|
4
4
|
import { choicesOf } from "@sincpro/criteria";
|
|
5
5
|
import { frameworkCopy } from "../../core/copy.js";
|
|
6
6
|
import { errorAt } from "../../core/edit.js";
|
|
7
7
|
import { editableLines } from "../../core/lines.js";
|
|
8
|
-
import { textOf, viewOf } from "../../core/present.js";
|
|
8
|
+
import { fieldAt, fieldMetaOf, isMoneyDefinition, textOf, valueAt, viewOf, } from "../../core/present.js";
|
|
9
9
|
import { relationFieldOf } from "../../core/relation.js";
|
|
10
10
|
import { useEntityFor, useFramework } from "../../react/context.js";
|
|
11
11
|
import { useNameOf } from "../../react/useNameOf.js";
|
|
@@ -15,6 +15,15 @@ import { useRecordOpening } from "./opening.js";
|
|
|
15
15
|
import { RecordLines } from "./record.js";
|
|
16
16
|
import { RelatedList } from "./RelatedList.js";
|
|
17
17
|
import { Checkbox, Field, FormSection, ReadValue, RelationValue, } from "@sincpro/web-ui";
|
|
18
|
+
/** `value` with `path` (`numero`, or `emisor.nit`) set to `next` — a new object, the rest kept. */
|
|
19
|
+
function setAt(value, path, next) {
|
|
20
|
+
const base = typeof value === "object" && value !== null ? value : {};
|
|
21
|
+
const dot = path.indexOf(".");
|
|
22
|
+
if (dot < 0)
|
|
23
|
+
return { ...base, [path]: next };
|
|
24
|
+
const head = path.slice(0, dot);
|
|
25
|
+
return { ...base, [head]: setAt(base[head], path.slice(dot + 1), next) };
|
|
26
|
+
}
|
|
18
27
|
/** A key alone, read: the name of the record it points at, asked once by key — the key until
|
|
19
28
|
* then, and when nothing answers. */
|
|
20
29
|
function KeyValue({ target, id, ...rest }) {
|
|
@@ -41,15 +50,32 @@ function KeyValue({ target, id, ...rest }) {
|
|
|
41
50
|
* A one2many is a block: its lines (`lines`) or its related list (`list`), each with every piece
|
|
42
51
|
* replaceable the screen's way.
|
|
43
52
|
*
|
|
53
|
+
* A value the record embeds (a payment's receipt) is drawn from its definition: `name="recibo"`
|
|
54
|
+
* is a section of its fields, and `name="recibo.numero"` is one of them — its label and type the
|
|
55
|
+
* definition's, read only when the embedded value is, and written back into the value whole.
|
|
56
|
+
*
|
|
44
57
|
* <RecordField record={invoice} name="due_date" />
|
|
45
58
|
* <RecordField record={invoice} name="customer_id" />
|
|
46
59
|
* <RecordField record={invoice} name="lines" lines={{ controls: { qty: Stepper } }} />
|
|
60
|
+
* <RecordField record={pago} name="recibo.numero" />
|
|
47
61
|
*/
|
|
48
62
|
export function RecordField({ record, name, as, bare = false, lines: look, list: listed, }) {
|
|
49
63
|
const { meta, locale, edit } = record;
|
|
50
64
|
const view = viewOf(meta, name, locale);
|
|
51
|
-
|
|
52
|
-
const
|
|
65
|
+
// A field of an embedded value (`recibo.numero`): the embedded value's state, its own hints.
|
|
66
|
+
const place = fieldAt(meta, name);
|
|
67
|
+
const nested = place.meta !== meta;
|
|
68
|
+
const head = nested ? name.slice(0, name.indexOf(".")) : name;
|
|
69
|
+
const part = nested ? place.meta?.fields[place.name] : undefined;
|
|
70
|
+
const whole = edit.state(head);
|
|
71
|
+
const state = nested
|
|
72
|
+
? {
|
|
73
|
+
visible: whole.visible,
|
|
74
|
+
readonly: whole.readonly || part?.readonly === true,
|
|
75
|
+
required: !whole.readonly && part?.required === true,
|
|
76
|
+
}
|
|
77
|
+
: whole;
|
|
78
|
+
const relation = nested ? undefined : relationFieldOf(meta, name);
|
|
53
79
|
const target = useEntityFor(relation?.target);
|
|
54
80
|
const opening = useRecordOpening();
|
|
55
81
|
const { metas } = useFramework();
|
|
@@ -67,6 +93,17 @@ export function RecordField({ record, name, as, bare = false, lines: look, list:
|
|
|
67
93
|
// project's channels, an inventory's components) — no model of its own, no id — is edited the
|
|
68
94
|
// same way as lines: a whole list, local keys, through the record's own save.
|
|
69
95
|
const own = meta?.fields[name];
|
|
96
|
+
const parts = Object.keys(own?.definition?.fields ?? {});
|
|
97
|
+
if (as === undefined &&
|
|
98
|
+
own?.type === "embedded" &&
|
|
99
|
+
own.many !== true &&
|
|
100
|
+
own.definition &&
|
|
101
|
+
own.widget !== "money" &&
|
|
102
|
+
!isMoneyDefinition(own.definition)) {
|
|
103
|
+
// One value the record embeds: its fields, each by its label — a section of the record.
|
|
104
|
+
const block = parts.map((one) => (_jsx(RecordField, { record: record, name: `${name}.${one}` }, one)));
|
|
105
|
+
return bare ? _jsx(_Fragment, { children: block }) : _jsx(FormSection, { title: view.label, children: block });
|
|
106
|
+
}
|
|
70
107
|
if (as === undefined && own?.type === "embedded" && own.many === true && own.definition) {
|
|
71
108
|
// A page of them stays read only, as a one2many's: written back whole it would drop what
|
|
72
109
|
// it did not bring.
|
|
@@ -102,16 +139,19 @@ export function RecordField({ record, name, as, bare = false, lines: look, list:
|
|
|
102
139
|
})()), ...listed }));
|
|
103
140
|
return bare ? list : _jsx(FormSection, { title: view.label, children: list });
|
|
104
141
|
}
|
|
105
|
-
const value = edit.values[name];
|
|
142
|
+
const value = nested ? valueAt(meta, edit.values, name) : edit.values[name];
|
|
106
143
|
const error = errorAt(edit.errors, name);
|
|
107
144
|
const control = {
|
|
108
145
|
value,
|
|
109
|
-
|
|
146
|
+
// A field of an embedded value is written back into the value, whole.
|
|
147
|
+
set: nested
|
|
148
|
+
? (next) => edit.set(head, setAt(edit.values[head], name.slice(head.length + 1), next))
|
|
149
|
+
: (next) => edit.set(name, next),
|
|
110
150
|
readonly: state.readonly,
|
|
111
151
|
invalid: error !== undefined,
|
|
112
152
|
label: view.label,
|
|
113
153
|
};
|
|
114
|
-
const field = meta
|
|
154
|
+
const field = fieldMetaOf(meta, name);
|
|
115
155
|
/** A many2one of a declared entity: chosen by the server's literal search, opened where the
|
|
116
156
|
* view says. Written by its key; read by the record it points at. */
|
|
117
157
|
function manyToOne() {
|
|
@@ -143,7 +183,7 @@ export function RecordField({ record, name, as, bare = false, lines: look, list:
|
|
|
143
183
|
}
|
|
144
184
|
if (view.type === "boolean" && as === undefined)
|
|
145
185
|
return (_jsx(Checkbox, { checked: value === true, onChange: control.set, label: view.label, disabled: state.readonly }));
|
|
146
|
-
return (_jsx(Field, { label: view.label, required: state.required && !state.readonly, ...(view.help === undefined ? {} : { hint: view.help }), ...(error === undefined ? {} : { error }), children: as !== undefined ? (as(control)) : relation !== undefined && !relation.many && target !== undefined ? (manyToOne()) : state.readonly ? (_jsx(ReadValue, { value: textOf(meta, name, value, locale) ?? "—" })) : (controlFor(control, view.type, field?.exact === true, choicesOf(meta, name, locale), field?.widget)) }));
|
|
186
|
+
return (_jsx(Field, { label: view.label, required: state.required && !state.readonly, ...(view.help === undefined ? {} : { hint: view.help }), ...(error === undefined ? {} : { error }), children: as !== undefined ? (as(control)) : relation !== undefined && !relation.many && target !== undefined ? (manyToOne()) : state.readonly ? (_jsx(ReadValue, { value: textOf(meta, name, value, locale) ?? "—" })) : (controlFor(control, view.type, field?.exact === true, choicesOf(place.meta, place.name, locale), field?.widget)) }));
|
|
147
187
|
}
|
|
148
188
|
/**
|
|
149
189
|
* The record's «save / discard», for `<Record dirty={…}>`: present only while something changed,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Entity, type
|
|
1
|
+
import { type Entity, type ResourceRef } from "@sincpro/client-framework";
|
|
2
2
|
import { type AnyRecord, type Criteria, type Expression } from "@sincpro/criteria";
|
|
3
3
|
import { type ListDefinition } from "../../core/list.js";
|
|
4
4
|
import type { OpenTarget } from "@sincpro/web-ui";
|
|
@@ -20,7 +20,7 @@ import { type ReactNode } from "react";
|
|
|
20
20
|
* that already committed — the holder gives an opening without `choose`.
|
|
21
21
|
*/
|
|
22
22
|
export type RecordOpening = {
|
|
23
|
-
open: (ref:
|
|
23
|
+
open: (ref: ResourceRef, to: OpenTarget) => void;
|
|
24
24
|
/** Where it may open from here, the default first. */
|
|
25
25
|
targets: readonly OpenTarget[];
|
|
26
26
|
/** The form is not on a page — a panel, a peek, a modal: a list inside it starts as rows
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { describeRows } from "@sincpro/criteria";
|
|
4
4
|
import { frameworkCopy } from "../../core/copy.js";
|
|
5
|
-
import { textOf, viewOf } from "../../core/present.js";
|
|
5
|
+
import { textOf, valueAt, viewOf } from "../../core/present.js";
|
|
6
6
|
import { relatedOf } from "../../core/related.js";
|
|
7
7
|
import { relationFieldOf } from "../../core/relation.js";
|
|
8
8
|
import { useEntityFor } from "../../react/context.js";
|
|
@@ -20,6 +20,7 @@ import { List, RelationValue, } from "@sincpro/web-ui";
|
|
|
20
20
|
*
|
|
21
21
|
* <Record.Paper>
|
|
22
22
|
* <Record.Facts fields={factsOf(record, meta, ["number", "customer", "due"])} />
|
|
23
|
+
* <Record.Facts fields={factsOf(pago, meta, ["recibo.numero", "recibo.concepto"])} />
|
|
23
24
|
* <Record.Pages>
|
|
24
25
|
* <Record.Page id="lines" label={labelOf(meta, "lines")} count={countOf(record, "lines")}>
|
|
25
26
|
* <RecordLines record={record} meta={meta} name="lines" />
|
|
@@ -35,7 +36,9 @@ export function factsOf(record, meta, names, options = {}) {
|
|
|
35
36
|
const relation = relationFieldOf(meta, name);
|
|
36
37
|
return {
|
|
37
38
|
label: view.label,
|
|
38
|
-
value: own ? (own(record)) : relation !== undefined && !relation.many ? (_jsx(RelationFact, { record: record, meta: meta, name: name, relation: relation, locale: options.locale })) : (
|
|
39
|
+
value: own ? (own(record)) : relation !== undefined && !relation.many ? (_jsx(RelationFact, { record: record, meta: meta, name: name, relation: relation, locale: options.locale })) : (
|
|
40
|
+
// A field of an embedded value is named by its path: `recibo.numero`.
|
|
41
|
+
(textOf(meta, name, valueAt(meta, record, name), options.locale) ?? EMPTY)),
|
|
39
42
|
...(view.help === undefined ? {} : { hint: view.help }),
|
|
40
43
|
...(name === meta?.identity ? { mono: true } : {}),
|
|
41
44
|
};
|
|
@@ -2,8 +2,9 @@ import { type ChangeFeed, type Entity, type Transport } from "@sincpro/client-fr
|
|
|
2
2
|
import type { Meta } from "@sincpro/criteria";
|
|
3
3
|
import { type ComposerSkin, type OnViewError, type ResourceRef, type ViewSpec, type WorkspaceStore } from "@sincpro/web-composer";
|
|
4
4
|
import { type CacheOptions } from "../../core/cache.js";
|
|
5
|
+
import type { DateStyle } from "../../core/present.js";
|
|
5
6
|
import { type ReactNode } from "react";
|
|
6
|
-
export declare function SincproApp({ transport, views, start, language, metas, entities, empty, skin, cache, timeZone, workspace: given, bar, onViewError, changes, }: {
|
|
7
|
+
export declare function SincproApp({ transport, views, start, language, metas, entities, empty, skin, cache, timeZone, dateStyle, currency, events, workspace: given, bar, onViewError, changes, }: {
|
|
7
8
|
transport: Transport;
|
|
8
9
|
/** The entities as composer views — `entityView(…)` — and any other view of the app. */
|
|
9
10
|
views: readonly ViewSpec[];
|
|
@@ -28,6 +29,14 @@ export declare function SincproApp({ transport, views, start, language, metas, e
|
|
|
28
29
|
/** Where the business is (`"America/La_Paz"`): every date and time on its wall clock.
|
|
29
30
|
* Without it, the browser's. */
|
|
30
31
|
timeZone?: string;
|
|
32
|
+
/** How dates are written. Without it, numeric — «16/11/2026» — and the month in words on a
|
|
33
|
+
* phone, where a word reads better than a column of digits. */
|
|
34
|
+
dateStyle?: DateStyle;
|
|
35
|
+
/** The business's currency (`"BOB"`): an amount the model draws as money is written in it. */
|
|
36
|
+
currency?: string;
|
|
37
|
+
/** Each domain event's definition by its wire name (`eventMetasOf(contract)`): a history
|
|
38
|
+
* names each fact's own fields in its words. */
|
|
39
|
+
events?: Readonly<Record<string, Meta>>;
|
|
31
40
|
/** The workspace, when the app needs to reach it (a menu of its bar): composer's
|
|
32
41
|
* `useWorkspace()`. Without it, the app keeps one of its own. */
|
|
33
42
|
workspace?: WorkspaceStore;
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { processChanges, processContext, reportError, } from "@sincpro/client-framework";
|
|
4
4
|
import { Composer, installComposerCopy, SPANISH_COMPOSER_COPY, useWorkspace, } from "@sincpro/web-composer";
|
|
5
|
-
import { createRegistry, formatRef } from "@sincpro/web-composer/domain";
|
|
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
8
|
import { FrameworkProvider } from "../../react/context.js";
|
|
9
9
|
import { webUiSkin } from "./skin.js";
|
|
10
10
|
import { installCopy, SPANISH_COPY, ToastProvider } from "@sincpro/web-ui";
|
|
11
|
-
import { useEffect, useMemo, useState } from "react";
|
|
11
|
+
import { useEffect, useMemo, useState, useSyncExternalStore } from "react";
|
|
12
12
|
/**
|
|
13
13
|
* The application context in one place: who answers (the transport), in which language, which
|
|
14
14
|
* model definitions are already known, the toasts, and the workspace with its views, ⌘K and
|
|
@@ -25,9 +25,22 @@ import { useEffect, useMemo, useState } from "react";
|
|
|
25
25
|
* const workspace = useWorkspace();
|
|
26
26
|
* <SincproApp workspace={workspace} bar={<Menu onOpen={(ref) => workspace.push(ref)} />} … />
|
|
27
27
|
*/
|
|
28
|
+
/** Narrower than composer's phone (`PHONE_WIDTH`): the workspace fills the window here, so the
|
|
29
|
+
* window's width is the workspace's. */
|
|
30
|
+
const PHONE = `(max-width: ${PHONE_WIDTH - 1}px)`;
|
|
31
|
+
function onPhone(changed) {
|
|
32
|
+
if (typeof window === "undefined" || window.matchMedia === undefined)
|
|
33
|
+
return () => undefined;
|
|
34
|
+
const query = window.matchMedia(PHONE);
|
|
35
|
+
query.addEventListener("change", changed);
|
|
36
|
+
return () => query.removeEventListener("change", changed);
|
|
37
|
+
}
|
|
38
|
+
const isPhone = () => typeof window !== "undefined" && window.matchMedia !== undefined
|
|
39
|
+
? window.matchMedia(PHONE).matches
|
|
40
|
+
: false;
|
|
28
41
|
/** A view that broke while drawing, told to the process's error reporter: `view <ref>`. */
|
|
29
42
|
const reportViewError = (error, { resource }) => reportError(error, `view ${formatRef(resource)}`);
|
|
30
|
-
export function SincproApp({ transport, views, start, language = "es", metas, entities, empty, skin = webUiSkin, cache = {}, timeZone, workspace: given, bar, onViewError = reportViewError, changes = processChanges, }) {
|
|
43
|
+
export function SincproApp({ transport, views, start, language = "es", metas, entities, empty, skin = webUiSkin, cache = {}, timeZone, dateStyle, currency, events, workspace: given, bar, onViewError = reportViewError, changes = processChanges, }) {
|
|
31
44
|
// Installed once, before anything draws: the three tables are module state of their packages.
|
|
32
45
|
useState(() => {
|
|
33
46
|
if (language === "es") {
|
|
@@ -62,6 +75,7 @@ export function SincproApp({ transport, views, start, language = "es", metas, en
|
|
|
62
75
|
// The cache is read once, as `cached` is.
|
|
63
76
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
64
77
|
}, [cached, changes]);
|
|
78
|
+
const phone = useSyncExternalStore(onPhone, isPhone, () => false);
|
|
65
79
|
const own = useWorkspace();
|
|
66
80
|
const workspace = given ?? own;
|
|
67
81
|
const registry = useMemo(() => createRegistry(views), [views]);
|
|
@@ -71,5 +85,5 @@ export function SincproApp({ transport, views, start, language = "es", metas, en
|
|
|
71
85
|
// The first screen only: a re-render must not push it again.
|
|
72
86
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
73
87
|
}, [workspace]);
|
|
74
|
-
return (_jsx(FrameworkProvider, { transport: cached, locale: language, changes: changes, ...(metas === undefined ? {} : { metas }), ...(entities === undefined ? {} : { entities }), ...(timeZone === undefined ? {} : { timeZone }), 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 }) }) })] }) }) }));
|
|
88
|
+
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 }), ...(events === undefined ? {} : { events }), 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 }) }) })] }) }) }));
|
|
75
89
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Entity, type Transport } from "@sincpro/client-framework";
|
|
2
2
|
import { type AnyRecord, type Meta } from "@sincpro/criteria";
|
|
3
3
|
import { type ViewProps, type ViewSpec } from "@sincpro/web-composer";
|
|
4
|
-
import {
|
|
4
|
+
import type { ListDefinition } from "../../core/list.js";
|
|
5
5
|
import { type ComponentType } from "react";
|
|
6
6
|
/**
|
|
7
7
|
* An entity as the composer's view: one `ViewSpec` for its list (a reference without an id)
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { isEntityId, listRoute, NEW_PARAM, scopeOfRef, } from "@sincpro/client-framework";
|
|
3
|
+
import { isEntityId, listRoute, NEW_PARAM, scopeNameOf, scopeOfRef, } from "@sincpro/client-framework";
|
|
4
4
|
import { matching } from "@sincpro/criteria";
|
|
5
5
|
import { usePhone, } from "@sincpro/web-composer";
|
|
6
|
-
import { scopeNameOf } from "../../core/list.js";
|
|
7
6
|
import { lookupOf } from "../../core/lookup.js";
|
|
8
7
|
import { ListScopeProvider } from "../../react/scope.js";
|
|
9
8
|
import { useListing } from "../../react/useListing.js";
|
|
@@ -52,7 +51,7 @@ function recordOf(entity, title) {
|
|
|
52
51
|
}
|
|
53
52
|
/**
|
|
54
53
|
* What a reference reads as before its view names it — a crumb whose view is not mounted, a
|
|
55
|
-
* record still loading: the list is the view's name (with its cut's, `
|
|
54
|
+
* record still loading: the list is the view's name (with its cut's, `entity.listRef`); a record
|
|
56
55
|
* its key when the key is something a person reads (`F-2026-0004`), the view's name when it is
|
|
57
56
|
* a machine's (a UUID v7, `isEntityId`).
|
|
58
57
|
*/
|
|
@@ -73,7 +72,7 @@ export function entityView(entity, options) {
|
|
|
73
72
|
return function EntityView(props) {
|
|
74
73
|
const record = props.resource.id !== undefined || props.resource.params?.[NEW_PARAM] !== undefined;
|
|
75
74
|
// A chooser opened by a picker offers only what the picker may choose, and a list opened
|
|
76
|
-
// under a cut (`
|
|
75
|
+
// under a cut (`entity.listRef`) shows only what it cuts: the cut travels in the reference, and
|
|
77
76
|
// the list — the application's own too — reads under it.
|
|
78
77
|
const cut = record ? undefined : scopeOfRef(props.resource);
|
|
79
78
|
const list = cut === undefined ? (_jsx(List, { ...props })) : (_jsx(ListScopeProvider, { value: { key: entity.key, selection: cut }, children: _jsx(List, { ...props }) }));
|
|
@@ -13,7 +13,9 @@ export type Stamp = {
|
|
|
13
13
|
* does, as values: read the record for editing, follow the workspace's breadcrumb, tell the
|
|
14
14
|
* workspace its name and its unsaved work, read its history, step to its neighbours in the list
|
|
15
15
|
* it was opened from, and say its name, state, unsaved work, refusal and authorship the way
|
|
16
|
-
* web-ui's `Record` takes them.
|
|
16
|
+
* web-ui's `Record` takes them. A screen that draws its own history passes `history: false`, and
|
|
17
|
+
* nothing asks for it. The state's tag and each fact of the history take the colours the entity
|
|
18
|
+
* was presented with (`presented(entity, { tones, facts })`).
|
|
17
19
|
*
|
|
18
20
|
* function InvoiceScreen(props: ViewProps) {
|
|
19
21
|
* const screen = useRecordScreen(invoices, props);
|
|
@@ -37,11 +39,13 @@ export type Stamp = {
|
|
|
37
39
|
*/
|
|
38
40
|
export declare function useRecordScreen<T extends AnyRecord>(entity: Entity<T>, { api, resource }: Pick<ViewProps, "api" | "resource">, options?: {
|
|
39
41
|
title?: ((record: T) => string | null) | undefined;
|
|
42
|
+
/** `false`: the screen draws its own history — it is not read here. */
|
|
43
|
+
history?: boolean | undefined;
|
|
40
44
|
}): {
|
|
41
45
|
reading: RecordReading<T>;
|
|
42
46
|
crumbs: readonly import("@sincpro/web-composer").Crumb[];
|
|
43
47
|
history: import("../../index.js").HistoryEntry[] | undefined;
|
|
44
|
-
summary: import("../../
|
|
48
|
+
summary: import("../../core/summary.js").RecordSummary | undefined;
|
|
45
49
|
/** web-ui `Record`'s own props: where it is drawn, its name, its unsaved work, its refusal. */
|
|
46
50
|
record: {
|
|
47
51
|
error?: string | undefined;
|
|
@@ -49,6 +53,7 @@ export declare function useRecordScreen<T extends AnyRecord>(entity: Entity<T>,
|
|
|
49
53
|
placement: "page" | "card";
|
|
50
54
|
identity: {
|
|
51
55
|
tag?: {
|
|
56
|
+
tone?: import("@sincpro/web-ui").Tone | undefined;
|
|
52
57
|
label: string;
|
|
53
58
|
} | undefined;
|
|
54
59
|
subtitle?: string | undefined;
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { TRAIL_PARAM } from "@sincpro/client-framework";
|
|
4
4
|
import { labelOf, nameOf } from "@sincpro/criteria";
|
|
5
|
-
import { useCrumbs } from "@sincpro/web-composer";
|
|
5
|
+
import { useCrumbs, usePhone } from "@sincpro/web-composer";
|
|
6
6
|
import { frameworkCopy } from "../../core/copy.js";
|
|
7
7
|
import { explain } from "../../core/explain.js";
|
|
8
8
|
import { formOf } from "../../core/form.js";
|
|
9
|
+
import { summaryFieldsOf } from "../../core/summary.js";
|
|
9
10
|
import { placeOf, stepIn } from "../../core/trail.js";
|
|
10
11
|
import { useFramework } from "../../react/context.js";
|
|
11
12
|
import { useHistory } from "../../react/useHistory.js";
|
|
12
13
|
import { useRecord } from "../../react/useRecord.js";
|
|
13
14
|
import { useSummaryOf } from "../../react/useSummary.js";
|
|
15
|
+
import { presentationOf } from "../list/presentation.js";
|
|
14
16
|
import { dirtyOf, RecordField } from "../record/edit.js";
|
|
17
|
+
import { RecordLifecycle } from "../record/RecordLifecycle.js";
|
|
15
18
|
import { Refused } from "../Refused.js";
|
|
16
19
|
import { useRecordInWorkspace } from "./workspace.js";
|
|
17
20
|
import { Button, Callout, FormSection, Record, Skeleton } from "@sincpro/web-ui";
|
|
@@ -42,7 +45,9 @@ function refusalOf(failure) {
|
|
|
42
45
|
* does, as values: read the record for editing, follow the workspace's breadcrumb, tell the
|
|
43
46
|
* workspace its name and its unsaved work, read its history, step to its neighbours in the list
|
|
44
47
|
* it was opened from, and say its name, state, unsaved work, refusal and authorship the way
|
|
45
|
-
* web-ui's `Record` takes them.
|
|
48
|
+
* web-ui's `Record` takes them. A screen that draws its own history passes `history: false`, and
|
|
49
|
+
* nothing asks for it. The state's tag and each fact of the history take the colours the entity
|
|
50
|
+
* was presented with (`presented(entity, { tones, facts })`).
|
|
46
51
|
*
|
|
47
52
|
* function InvoiceScreen(props: ViewProps) {
|
|
48
53
|
* const screen = useRecordScreen(invoices, props);
|
|
@@ -68,7 +73,8 @@ export function useRecordScreen(entity, { api, resource }, options = {}) {
|
|
|
68
73
|
const reading = useRecord(entity, resource);
|
|
69
74
|
const crumbs = useCrumbs(api);
|
|
70
75
|
useRecordInWorkspace(api, reading, options);
|
|
71
|
-
const
|
|
76
|
+
const look = presentationOf(entity);
|
|
77
|
+
const history = useHistory(entity, reading.isNew || options.history === false ? "" : reading.id, [reading.record], { tones: look.facts });
|
|
72
78
|
const summarize = useSummaryOf(entity);
|
|
73
79
|
const copy = frameworkCopy().record;
|
|
74
80
|
// Opened from a list: where it stands in it, and its neighbours (`Trail`).
|
|
@@ -89,6 +95,13 @@ export function useRecordScreen(entity, { api, resource }, options = {}) {
|
|
|
89
95
|
};
|
|
90
96
|
const ready = reading.status === "ready";
|
|
91
97
|
const summary = ready && !reading.isNew ? summarize(reading.record, reading.meta) : undefined;
|
|
98
|
+
// The state's colour is the application's, declared once with the entity.
|
|
99
|
+
const stateField = ready
|
|
100
|
+
? summaryFieldsOf(reading.meta, reading.record, entity.summary).state
|
|
101
|
+
: undefined;
|
|
102
|
+
const tone = stateField === undefined || !ready
|
|
103
|
+
? undefined
|
|
104
|
+
: look.tones?.[stateField]?.[String(reading.record[stateField])];
|
|
92
105
|
const dirty = ready ? dirtyOf(reading) : undefined;
|
|
93
106
|
const failure = reading.edit.failure;
|
|
94
107
|
// Who, only when the record says it (an author is optional: the line then says only when).
|
|
@@ -116,7 +129,9 @@ export function useRecordScreen(entity, { api, resource }, options = {}) {
|
|
|
116
129
|
summary?.name ??
|
|
117
130
|
(reading.isNew ? copy.creating(nameOf(reading.meta, reading.locale) || "") : ""),
|
|
118
131
|
...(summary?.type == null ? {} : { subtitle: summary.type }),
|
|
119
|
-
...(summary?.state == null
|
|
132
|
+
...(summary?.state == null
|
|
133
|
+
? {}
|
|
134
|
+
: { tag: { label: summary.state, ...(tone === undefined ? {} : { tone }) } }),
|
|
120
135
|
},
|
|
121
136
|
...(dirty === undefined ? {} : { dirty }),
|
|
122
137
|
// The refusal in words; its heading when the server said nothing more (no detail).
|
|
@@ -140,16 +155,34 @@ export function EntityRecord({ api, resource, entity, fields, pages, actions, ti
|
|
|
140
155
|
const { reading, crumbs, history, pager } = screen;
|
|
141
156
|
const [page, setPage] = useState(undefined);
|
|
142
157
|
const copy = frameworkCopy().record;
|
|
158
|
+
// On a phone a form is one column, its label over its value: two side by side at 400 px
|
|
159
|
+
// squeezed a text area beside its word (web-ui's grid does not narrow by itself).
|
|
160
|
+
const phone = usePhone(api);
|
|
143
161
|
if (reading.status === "loading")
|
|
144
162
|
return _jsx(Skeleton, { rows: 6, label: copy.loading });
|
|
145
163
|
if (reading.status === "failed")
|
|
146
164
|
return _jsx(Refused, { error: reading.error, onRetry: reading.reload });
|
|
147
165
|
const { meta, locale, edit } = reading;
|
|
148
166
|
const layout = formOf(meta, entity.summary);
|
|
149
|
-
|
|
150
|
-
|
|
167
|
+
// What the header already says — the name, the state, the type — is not said again as a
|
|
168
|
+
// field, unless it can be typed in now: then the field is its control, not a repetition.
|
|
169
|
+
const parts = summaryFieldsOf(meta, reading.record ?? {}, entity.summary);
|
|
170
|
+
const said = new Set([meta?.display, parts.state, parts.type]);
|
|
171
|
+
const shown = fields ??
|
|
172
|
+
layout.fields.filter((name) => reading.isNew || !said.has(name) || !edit.state(name).readonly);
|
|
173
|
+
const columns = phone || (api.surface !== "page" && api.surface !== "modal") ? 1 : 2;
|
|
174
|
+
// The record's own lifecycle (its `Delete`, its trash) beside the screen's commands; once it is
|
|
175
|
+
// out of every reading the surface closes — every list that showed it reads again by itself.
|
|
176
|
+
const lifecycle = reading.isNew ||
|
|
177
|
+
(entity.delete === undefined &&
|
|
178
|
+
entity.archive === undefined &&
|
|
179
|
+
entity.restore === undefined) ? null : (_jsx(RecordLifecycle, { record: reading, onDone: (done) => (done === "restore" ? reading.reload() : api.close()) }));
|
|
180
|
+
const own = actions?.(reading) ?? null;
|
|
181
|
+
const ownActions = own === null && lifecycle === null ? null : (_jsxs(_Fragment, { children: [own, lifecycle] }));
|
|
151
182
|
const tabs = pages ?? layout.pages;
|
|
152
|
-
return (_jsxs(Record, { ...screen.record, children: [crumbs.length === 0 && pager === undefined && ownActions === null ? null : (_jsxs(Record.Rail, { children: [crumbs.length === 0 ? null : _jsx(Record.Crumbs, { crumbs: crumbs }), pager === undefined ? null : _jsx(Record.Pager, { ...pager }), ownActions === null ? null : _jsx(Record.Actions, { children: ownActions })] })), _jsxs(Record.Paper, { layout: "horizontal", children: [edit.conflict || edit.restored ? (_jsxs("div", { className: "flex flex-col gap-3", children: [edit.conflict ? (_jsx(Callout, { tone: "warn", title: copy.conflict, children: _jsx(Button, { size: "sm", role: "secondary", onClick: reading.reload, children: copy.reload }) })) : null, edit.restored ? (_jsx(Callout, { tone: "info", title: copy.restored, children: null })) : null] })) : null, _jsx(FormSection, { columns:
|
|
183
|
+
return (_jsxs(Record, { ...screen.record, children: [crumbs.length === 0 && pager === undefined && ownActions === null ? null : (_jsxs(Record.Rail, { children: [crumbs.length === 0 ? null : _jsx(Record.Crumbs, { crumbs: crumbs }), pager === undefined ? null : _jsx(Record.Pager, { ...pager }), ownActions === null ? null : _jsx(Record.Actions, { children: ownActions })] })), _jsxs(Record.Paper, { layout: phone ? "stacked" : "horizontal", children: [edit.conflict || edit.restored ? (_jsxs("div", { className: "flex flex-col gap-3", children: [edit.conflict ? (_jsx(Callout, { tone: "warn", title: copy.conflict, children: _jsx(Button, { size: "sm", role: "secondary", onClick: reading.reload, children: copy.reload }) })) : null, edit.restored ? (_jsx(Callout, { tone: "info", title: copy.restored, children: null })) : null] })) : null, _jsx(FormSection, { columns: columns, children: shown.map((name) => (_jsx(RecordField, { record: reading, name: name }, name))) }), fields !== undefined
|
|
184
|
+
? null
|
|
185
|
+
: layout.sections.map((name) => (_jsx(FormSection, { title: labelOf(meta, name, locale), columns: columns, children: Object.keys(meta?.fields[name]?.definition?.fields ?? {}).map((part) => (_jsx(RecordField, { record: reading, name: `${name}.${part}` }, part))) }, name))), edit.advice
|
|
153
186
|
.filter((one) => (one.path?.length ?? 0) <= 1)
|
|
154
187
|
.map((one) => (_jsx(Callout, { tone: "info", title: one.message, children: null }, one.message))), tabs.length === 0 || reading.isNew ? null : (_jsx(Record.Pages, { current: page ?? tabs[0], onChange: setPage, children: tabs.map((name) => (_jsx(Record.Page, { id: name, label: labelOf(meta, name, locale), children: _jsx(RecordField, { record: reading, name: name, bare: true }) }, name))) })), screen.audit === undefined ? null : _jsx(Record.Audit, { ...screen.audit })] }), history === undefined ? null : _jsx(Record.Activity, { events: history })] }));
|
|
155
188
|
}
|