@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,41 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { TRAIL_PARAM } from "@sincpro/client-framework";
|
|
4
|
-
import {
|
|
5
|
-
import { useCrumbs
|
|
3
|
+
import { nameOf } from "@sincpro/criteria";
|
|
4
|
+
import { useCrumbs } from "@sincpro/web-composer";
|
|
6
5
|
import { frameworkCopy } from "../../core/copy.js";
|
|
7
6
|
import { explain } from "../../core/explain.js";
|
|
8
|
-
import { formOf } from "../../core/form.js";
|
|
9
7
|
import { summaryFieldsOf } from "../../core/summary.js";
|
|
10
8
|
import { placeOf, stepIn } from "../../core/trail.js";
|
|
11
9
|
import { useFramework } from "../../react/context.js";
|
|
12
10
|
import { useHistory } from "../../react/useHistory.js";
|
|
13
11
|
import { useRecord } from "../../react/useRecord.js";
|
|
14
12
|
import { useSummaryOf } from "../../react/useSummary.js";
|
|
15
|
-
import { actionsOf } from "../list/dock.js";
|
|
16
13
|
import { presentationOf } from "../list/presentation.js";
|
|
17
|
-
import { dirtyOf
|
|
18
|
-
import { LifecycleButtons, useRecordLifecycleActions, } from "../record/RecordLifecycle.js";
|
|
19
|
-
import { Refused } from "../Refused.js";
|
|
14
|
+
import { dirtyOf } from "../record/edit.js";
|
|
20
15
|
import { useRecordInWorkspace } from "./workspace.js";
|
|
21
|
-
import { Button, Callout, FormSection, Record, Skeleton, useFormStyle, } from "@sincpro/web-ui";
|
|
22
|
-
import { useState } from "react";
|
|
23
|
-
/**
|
|
24
|
-
* The record of an entity, drawn from its model — the screen `entityView` opens when the
|
|
25
|
-
* application writes none: in the page, a modal, the preview or a panel, the same.
|
|
26
|
-
*
|
|
27
|
-
* Context: every Sincpro record screen was the same hundred lines: read it, tell the workspace
|
|
28
|
-
* its name and its unsaved work, draw its name and state on top, its fields, its lines, the
|
|
29
|
-
* conflict and the restored draft, who made it, its history. Here once, from what the model and
|
|
30
|
-
* the entity already say (`formOf`, `summaryOf`): a new entity has a useful screen before anyone
|
|
31
|
-
* writes it. It is a default, not a cage — `fields`/`pages` choose and order, `actions` puts the
|
|
32
|
-
* record's commands, and any screen can drop this and keep `useRecord` + `RecordField`.
|
|
33
|
-
*
|
|
34
|
-
* entityView(invoices, { transport, name: "Facturas" }) // this screen
|
|
35
|
-
* entityView(invoices, { …, record: (props) =>
|
|
36
|
-
* <EntityRecord {...props} entity={invoices} fields={["customer_id", "due_date"]}
|
|
37
|
-
* actions={(invoice) => <CommandButton entity={invoices} command="post" … />} /> })
|
|
38
|
-
*/
|
|
39
16
|
/** A save's refusal as a sentence — its heading when the server gave no detail. */
|
|
40
17
|
function refusalOf(failure) {
|
|
41
18
|
const said = explain(failure);
|
|
@@ -111,6 +88,7 @@ export function useRecordScreen(entity, { api, resource }, options = {}) {
|
|
|
111
88
|
// Who, only when the record says it (an author is optional: the line then says only when).
|
|
112
89
|
const stamp = (one) => one?.at == null ? undefined : { at: one.at, ...(one.by == null ? {} : { by: one.by }) };
|
|
113
90
|
const created = stamp(summary?.created);
|
|
91
|
+
const subtitle = (ready && !reading.isNew ? options.subtitle?.(reading.record) : null) ?? summary?.type;
|
|
114
92
|
const updated = stamp(summary?.updated);
|
|
115
93
|
// Moving away with something typed would lose it: «save / discard» comes first.
|
|
116
94
|
const place = trail === undefined || reading.isNew || reading.edit.dirty
|
|
@@ -132,7 +110,7 @@ export function useRecordScreen(entity, { api, resource }, options = {}) {
|
|
|
132
110
|
title: (ready && !reading.isNew ? options.title?.(reading.record) : null) ??
|
|
133
111
|
summary?.name ??
|
|
134
112
|
(reading.isNew ? copy.creating(nameOf(reading.meta, reading.locale) || "") : ""),
|
|
135
|
-
...(
|
|
113
|
+
...(subtitle == null ? {} : { subtitle }),
|
|
136
114
|
...(summary?.state == null
|
|
137
115
|
? {}
|
|
138
116
|
: { tag: { label: summary.state, ...(tone === undefined ? {} : { tone }) } }),
|
|
@@ -156,46 +134,3 @@ export function useRecordScreen(entity, { api, resource }, options = {}) {
|
|
|
156
134
|
},
|
|
157
135
|
};
|
|
158
136
|
}
|
|
159
|
-
export function EntityRecord({ api, resource, entity, fields, pages, actions, title, initial, }) {
|
|
160
|
-
const screen = useRecordScreen(entity, { api, resource }, { title, initial });
|
|
161
|
-
const { reading, crumbs, history, pager, moment } = screen;
|
|
162
|
-
const [page, setPage] = useState(undefined);
|
|
163
|
-
const copy = frameworkCopy().record;
|
|
164
|
-
// On a phone a form is one column, its label over its value: two side by side at 400 px
|
|
165
|
-
// squeezed a text area beside its word (web-ui's grid does not narrow by itself).
|
|
166
|
-
const phone = usePhone(api);
|
|
167
|
-
const settings = useFormStyle() === "settings";
|
|
168
|
-
// The record's own lifecycle (its `Delete`, its trash); once it is out of every reading the
|
|
169
|
-
// surface closes — every list that showed it reads again by itself.
|
|
170
|
-
const lifecycle = useRecordLifecycleActions(reading, (done) => done === "restore" ? reading.reload() : api.close());
|
|
171
|
-
if (reading.status === "loading")
|
|
172
|
-
return _jsx(Skeleton, { rows: 6, label: copy.loading });
|
|
173
|
-
if (reading.status === "failed")
|
|
174
|
-
return _jsx(Refused, { error: reading.error, onRetry: reading.reload });
|
|
175
|
-
const { meta, locale, edit } = reading;
|
|
176
|
-
const layout = formOf(meta, entity.summary);
|
|
177
|
-
// What the header already says — the name, the state, the type — is not said again as a
|
|
178
|
-
// field, unless it can be typed in now: then the field is its control, not a repetition.
|
|
179
|
-
const parts = summaryFieldsOf(meta, reading.record ?? {}, entity.summary);
|
|
180
|
-
const said = new Set([meta?.display, parts.state, parts.type]);
|
|
181
|
-
const shown = fields ??
|
|
182
|
-
layout.fields.filter((name) => reading.isNew || !said.has(name) || !edit.state(name).readonly);
|
|
183
|
-
const columns = phone || (api.surface !== "page" && api.surface !== "modal") ? 1 : 2;
|
|
184
|
-
// The screen's actions and the lifecycle's. As data they go to the dock, where the view style
|
|
185
|
-
// draws them; drawn by hand, in the rail with the lifecycle's buttons beside them.
|
|
186
|
-
const own = actionsOf(actions?.(reading) ?? null);
|
|
187
|
-
const docked = own.drawn === null ? [...own.dock, ...lifecycle.actions] : [];
|
|
188
|
-
const drawn = own.drawn === null ? null : (_jsxs(_Fragment, { children: [own.drawn, _jsx(LifecycleButtons, { actions: lifecycle.actions })] }));
|
|
189
|
-
const tabs = pages ?? layout.pages;
|
|
190
|
-
return (_jsxs(_Fragment, { children: [_jsxs(Record, { ...screen.record, children: [crumbs.length === 0 &&
|
|
191
|
-
pager === undefined &&
|
|
192
|
-
docked.length === 0 &&
|
|
193
|
-
moment === undefined &&
|
|
194
|
-
drawn === null ? null : (_jsxs(Record.Rail, { children: [crumbs.length === 0 ? null : _jsx(Record.Crumbs, { crumbs: crumbs }), pager === undefined ? null : _jsx(Record.Pager, { ...pager }), drawn === null ? null : _jsx(Record.Actions, { children: drawn }), docked.length === 0 && moment === undefined ? null : (_jsx(Record.Dock, { actions: docked, ...(moment === undefined ? {} : { moment }) }))] })), _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, ...(settings && fields === undefined && layout.sections.length > 0
|
|
195
|
-
? { title: copy.general }
|
|
196
|
-
: {}), children: shown.map((name) => (_jsx(RecordField, { record: reading, name: name }, name))) }), fields !== undefined
|
|
197
|
-
? null
|
|
198
|
-
: 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
|
|
199
|
-
.filter((one) => (one.path?.length ?? 0) <= 1)
|
|
200
|
-
.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 })] }), lifecycle.dialog] }));
|
|
201
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sincpro/web-framework",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.19.0",
|
|
4
4
|
"description": "The web client of sincpro_framework: entities, lists and records bound to the metadata the server publishes, drawn with @sincpro/web-ui and arranged with @sincpro/web-composer.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@sincpro/criteria": "^2.5.1",
|
|
56
56
|
"@sincpro/criteria-react": "^2.5.1",
|
|
57
57
|
"@sincpro/web-composer": "^1.7.0",
|
|
58
|
-
"@sincpro/web-ui": "^2.
|
|
58
|
+
"@sincpro/web-ui": "^2.20.0",
|
|
59
59
|
"react": ">=19",
|
|
60
60
|
"react-dom": ">=19"
|
|
61
61
|
},
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"@sincpro/criteria": "^2.5.1",
|
|
100
100
|
"@sincpro/criteria-react": "^2.5.1",
|
|
101
101
|
"@sincpro/web-composer": "^1.9.0",
|
|
102
|
-
"@sincpro/web-ui": "^2.
|
|
102
|
+
"@sincpro/web-ui": "^2.20.0",
|
|
103
103
|
"@storybook/addon-a11y": "10.6.5",
|
|
104
104
|
"@storybook/addon-docs": "10.6.5",
|
|
105
105
|
"@storybook/addon-mcp": "10.6.5",
|