@sincpro/web-framework 0.2.0 → 0.4.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 +56 -19
- package/dist/core/copy.d.ts +2 -0
- package/dist/core/copy.js +2 -0
- package/dist/core/edit.d.ts +35 -3
- package/dist/core/edit.js +49 -5
- package/dist/core/entity.d.ts +14 -2
- package/dist/core/entity.js +33 -1
- package/dist/core/index.d.ts +4 -2
- package/dist/core/index.js +4 -2
- package/dist/core/lines.d.ts +52 -0
- package/dist/core/lines.js +120 -0
- package/dist/core/list.d.ts +1 -1
- package/dist/core/lookup.d.ts +2 -0
- package/dist/core/lookup.js +3 -1
- package/dist/core/present.js +7 -2
- package/dist/core/rest.d.ts +5 -9
- package/dist/core/rest.js +14 -6
- package/dist/core/transport.d.ts +9 -1
- package/dist/core/zone.d.ts +27 -0
- package/dist/core/zone.js +75 -0
- package/dist/react/context.d.ts +13 -1
- package/dist/react/context.js +10 -2
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +1 -0
- package/dist/react/useGroups.d.ts +13 -1
- package/dist/react/useGroups.js +48 -7
- package/dist/react/useListing.d.ts +8 -4
- package/dist/react/useListing.js +11 -5
- package/dist/react/usePivot.d.ts +33 -0
- package/dist/react/usePivot.js +59 -0
- package/dist/react/useRecord.d.ts +13 -9
- package/dist/react/useRecord.js +55 -13
- package/dist/web/index.d.ts +7 -1
- package/dist/web/index.js +7 -1
- package/dist/web/list/EntityList.d.ts +46 -7
- package/dist/web/list/EntityList.js +132 -21
- package/dist/web/list/EntitySearchBar.js +19 -1
- package/dist/web/list/columns.d.ts +0 -13
- package/dist/web/list/columns.js +20 -1
- package/dist/web/list/groups.d.ts +3 -1
- package/dist/web/list/groups.js +8 -1
- package/dist/web/list/openIn.d.ts +41 -0
- package/dist/web/list/openIn.js +55 -0
- package/dist/web/list/pivot.d.ts +23 -0
- package/dist/web/list/pivot.js +64 -0
- package/dist/web/list/presentation.d.ts +51 -0
- package/dist/web/list/presentation.js +20 -0
- package/dist/web/record/EntityPicker.d.ts +3 -1
- package/dist/web/record/EntityPicker.js +15 -5
- package/dist/web/record/EntityTags.js +16 -5
- package/dist/web/record/RelatedList.d.ts +6 -0
- package/dist/web/record/RelatedList.js +26 -2
- package/dist/web/record/control.d.ts +43 -0
- package/dist/web/record/control.js +67 -0
- package/dist/web/record/edit.d.ts +16 -8
- package/dist/web/record/edit.js +57 -49
- package/dist/web/record/lines.d.ts +84 -0
- package/dist/web/record/lines.js +190 -0
- package/dist/web/record/opening.d.ts +8 -0
- package/dist/web/record/summary.js +14 -6
- package/dist/web/workspace/SincproApp.d.ts +4 -1
- package/dist/web/workspace/SincproApp.js +2 -2
- package/dist/web/workspace/composer.d.ts +2 -1
- package/dist/web/workspace/composer.js +27 -16
- package/dist/web/workspace/open.d.ts +2 -14
- package/dist/web/workspace/open.js +2 -13
- package/dist/web/workspace/record.js +6 -3
- package/dist/web/workspace/workspace.d.ts +4 -2
- package/dist/web/workspace/workspace.js +10 -4
- package/package.json +9 -9
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useSummaryOf } from "../../react/useSummary.js";
|
|
4
|
+
import { openOptions, targetsFor } from "../list/openIn.js";
|
|
4
5
|
import { relationOf } from "../record/summary.js";
|
|
5
6
|
import { RelationValue } from "@sincpro/web-ui";
|
|
6
7
|
/**
|
|
@@ -19,19 +20,7 @@ import { RelationValue } from "@sincpro/web-ui";
|
|
|
19
20
|
*
|
|
20
21
|
* The phone is composer's: a modal becomes a sheet, a side panel the page. No view asks.
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
|
-
export const RECORD_SIZE = { w: 760, h: 560 };
|
|
24
|
-
const IN_PLACE = ["modal", "peek", "side", "page"];
|
|
25
|
-
const FROM_A_MODAL = ["side", "peek", "page"];
|
|
26
|
-
/** Where a related record may open from this view, the default first. */
|
|
27
|
-
export function targetsFor(api) {
|
|
28
|
-
return api.over === null ? IN_PLACE : FROM_A_MODAL;
|
|
29
|
-
}
|
|
30
|
-
/** web-ui's target as composer's options. Destinations share their names, so only the size is
|
|
31
|
-
* added — to the two that have one. */
|
|
32
|
-
export function openOptions(to, size = RECORD_SIZE) {
|
|
33
|
-
return to === "modal" || to === "window" ? { to, size } : { to };
|
|
34
|
-
}
|
|
23
|
+
export { openOptions, RECORD_SIZE, targetsFor } from "../list/openIn.js";
|
|
35
24
|
/**
|
|
36
25
|
* Open a record where it was asked, or where it belongs from here.
|
|
37
26
|
*
|
|
@@ -13,7 +13,7 @@ import { useSummaryOf } from "../../react/useSummary.js";
|
|
|
13
13
|
import { dirtyOf, RecordField } from "../record/edit.js";
|
|
14
14
|
import { Refused } from "../Refused.js";
|
|
15
15
|
import { useRecordInWorkspace } from "./workspace.js";
|
|
16
|
-
import { Button, Callout, Record, Skeleton } from "@sincpro/web-ui";
|
|
16
|
+
import { Button, Callout, FormSection, Record, Skeleton } from "@sincpro/web-ui";
|
|
17
17
|
import { useState } from "react";
|
|
18
18
|
/**
|
|
19
19
|
* The record of an entity, drawn from its model — the screen `entityView` opens when the
|
|
@@ -32,7 +32,7 @@ import { useState } from "react";
|
|
|
32
32
|
* actions={(invoice) => <CommandButton entity={invoices} command="post" … />} /> })
|
|
33
33
|
*/
|
|
34
34
|
export function EntityRecord({ api, resource, entity, fields, pages, actions, }) {
|
|
35
|
-
const reading = useRecord(entity, resource
|
|
35
|
+
const reading = useRecord(entity, resource);
|
|
36
36
|
const crumbs = useCrumbs(api);
|
|
37
37
|
useRecordInWorkspace(api, reading);
|
|
38
38
|
const history = useHistory(entity, reading.isNew ? "" : reading.id, [reading.record]);
|
|
@@ -62,6 +62,7 @@ export function EntityRecord({ api, resource, entity, fields, pages, actions, })
|
|
|
62
62
|
const { meta, locale, edit } = reading;
|
|
63
63
|
const layout = formOf(meta, entity.summary);
|
|
64
64
|
const shown = fields ?? layout.fields;
|
|
65
|
+
const ownActions = actions?.(reading) ?? null;
|
|
65
66
|
const tabs = pages ?? layout.pages;
|
|
66
67
|
const summary = reading.isNew ? undefined : summarize(reading.record, meta);
|
|
67
68
|
const dirty = dirtyOf(reading);
|
|
@@ -76,5 +77,7 @@ export function EntityRecord({ api, resource, entity, fields, pages, actions, })
|
|
|
76
77
|
title: summary?.name ?? copy.creating(nameOf(meta, locale) || ""),
|
|
77
78
|
...(summary?.type == null ? {} : { subtitle: summary.type }),
|
|
78
79
|
...(summary?.state == null ? {} : { tag: { label: summary.state } }),
|
|
79
|
-
}, ...(dirty === undefined ? {} : { dirty }), ...(edit.failure === null ? {} : { error: String(edit.failure.message) }), children: [_jsxs(Record.Rail, { children: [crumbs.length === 0 ? null : _jsx(Record.Crumbs, { crumbs: crumbs }), place === null ? null : (_jsx(Record.Pager, { index: place.index, total: place.total, onPrev: go(-1), onNext: go(1) })), _jsx(Record.Actions, { children:
|
|
80
|
+
}, ...(dirty === undefined ? {} : { dirty }), ...(edit.failure === null ? {} : { error: String(edit.failure.message) }), children: [crumbs.length === 0 && place === null && ownActions === null ? null : (_jsxs(Record.Rail, { children: [crumbs.length === 0 ? null : _jsx(Record.Crumbs, { crumbs: crumbs }), place === null ? null : (_jsx(Record.Pager, { index: place.index, total: place.total, onPrev: go(-1), onNext: go(1) })), 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: api.surface === "page" || api.surface === "modal" ? 2 : 1, children: shown.map((name) => (_jsx(RecordField, { record: reading, name: name }, name))) }), edit.advice
|
|
81
|
+
.filter((one) => (one.path?.length ?? 0) <= 1)
|
|
82
|
+
.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))) })), createdStamp === undefined && updatedStamp === undefined ? null : (_jsx(Record.Audit, { ...(createdStamp === undefined ? {} : { created: createdStamp }), ...(updatedStamp === undefined ? {} : { updated: updatedStamp }) }))] }), history === undefined ? null : _jsx(Record.Activity, { events: history })] }));
|
|
80
83
|
}
|
|
@@ -13,9 +13,11 @@ import type { RecordReading } from "../../react/useRecord.js";
|
|
|
13
13
|
*
|
|
14
14
|
* A NEW record (opened with `entity.newRef()`) reads «Facturas · nuevo» until it exists; the
|
|
15
15
|
* moment its create answers, the surface is REPLACED by the record it became (`api.replace`):
|
|
16
|
-
* no crumb leads back to an empty form, and the window, peek or page it was in stays.
|
|
16
|
+
* no crumb leads back to an empty form, and the window, peek or page it was in stays. Opened
|
|
17
|
+
* to ANSWER (`api.pick(entity.newRef(…))` — «Agregar» on a record's one2many), it answers the
|
|
18
|
+
* record it became instead, and the surface closes: whoever asked reads it again.
|
|
17
19
|
*
|
|
18
|
-
* const invoice = useRecord(invoices, resource
|
|
20
|
+
* const invoice = useRecord(invoices, resource);
|
|
19
21
|
* useRecordInWorkspace(api, invoice);
|
|
20
22
|
*/
|
|
21
23
|
export declare function useRecordInWorkspace<T extends AnyRecord>(api: WorkspaceApi, record: RecordReading<T>): void;
|
|
@@ -15,9 +15,11 @@ import { useEffect } from "react";
|
|
|
15
15
|
*
|
|
16
16
|
* A NEW record (opened with `entity.newRef()`) reads «Facturas · nuevo» until it exists; the
|
|
17
17
|
* moment its create answers, the surface is REPLACED by the record it became (`api.replace`):
|
|
18
|
-
* no crumb leads back to an empty form, and the window, peek or page it was in stays.
|
|
18
|
+
* no crumb leads back to an empty form, and the window, peek or page it was in stays. Opened
|
|
19
|
+
* to ANSWER (`api.pick(entity.newRef(…))` — «Agregar» on a record's one2many), it answers the
|
|
20
|
+
* record it became instead, and the surface closes: whoever asked reads it again.
|
|
19
21
|
*
|
|
20
|
-
* const invoice = useRecord(invoices, resource
|
|
22
|
+
* const invoice = useRecord(invoices, resource);
|
|
21
23
|
* useRecordInWorkspace(api, invoice);
|
|
22
24
|
*/
|
|
23
25
|
export function useRecordInWorkspace(api, record) {
|
|
@@ -30,10 +32,14 @@ export function useRecordInWorkspace(api, record) {
|
|
|
30
32
|
const dirty = record.edit.dirty;
|
|
31
33
|
const opened = api.self.id ?? "";
|
|
32
34
|
const { entity, id } = record;
|
|
33
|
-
// Created here: show what it became
|
|
35
|
+
// Created here: show what it became in place of the form — or hand it to whoever asked.
|
|
34
36
|
useEffect(() => {
|
|
35
|
-
if (opened
|
|
37
|
+
if (opened !== "" || id === "")
|
|
38
|
+
return;
|
|
39
|
+
if (api.choosing === null)
|
|
36
40
|
api.replace(entity.ref(id));
|
|
41
|
+
else
|
|
42
|
+
api.answer(entity.ref(id));
|
|
37
43
|
}, [api, opened, entity, id]);
|
|
38
44
|
useEffect(() => {
|
|
39
45
|
api.setTitle(title);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sincpro/web-framework",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.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",
|
|
@@ -23,19 +23,19 @@
|
|
|
23
23
|
"printWidth": 94
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@sincpro/criteria": "^0.3.
|
|
27
|
-
"@sincpro/criteria-react": "^0.3.
|
|
28
|
-
"@sincpro/web-composer": "^1.
|
|
29
|
-
"@sincpro/web-ui": "^1.
|
|
26
|
+
"@sincpro/criteria": "^0.3.1",
|
|
27
|
+
"@sincpro/criteria-react": "^0.3.1",
|
|
28
|
+
"@sincpro/web-composer": "^1.5.0",
|
|
29
|
+
"@sincpro/web-ui": "^1.7.2",
|
|
30
30
|
"react": ">=19",
|
|
31
31
|
"react-dom": ">=19"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@eslint/js": "^10.0.1",
|
|
35
|
-
"@sincpro/criteria": "^0.3.
|
|
36
|
-
"@sincpro/criteria-react": "^0.3.
|
|
37
|
-
"@sincpro/web-composer": "^1.
|
|
38
|
-
"@sincpro/web-ui": "^1.
|
|
35
|
+
"@sincpro/criteria": "^0.3.1",
|
|
36
|
+
"@sincpro/criteria-react": "^0.3.1",
|
|
37
|
+
"@sincpro/web-composer": "^1.5.0",
|
|
38
|
+
"@sincpro/web-ui": "^1.7.2",
|
|
39
39
|
"@storybook/addon-a11y": "10.6.5",
|
|
40
40
|
"@storybook/addon-docs": "10.6.5",
|
|
41
41
|
"@storybook/addon-mcp": "10.6.5",
|