@sincpro/web-framework 3.21.0 → 4.0.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 +114 -112
- package/dist/core/cache.d.ts +20 -23
- package/dist/core/cache.js +37 -52
- package/dist/core/changes.d.ts +10 -18
- package/dist/core/changes.js +11 -30
- package/dist/core/command.d.ts +25 -11
- package/dist/core/command.js +9 -12
- package/dist/core/copy.d.ts +4 -0
- package/dist/core/copy.js +2 -0
- package/dist/core/edit.d.ts +16 -2
- package/dist/core/edit.js +13 -2
- package/dist/core/groups.d.ts +3 -2
- package/dist/core/groups.js +4 -3
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +2 -2
- package/dist/core/list.d.ts +17 -11
- package/dist/core/list.js +17 -11
- package/dist/core/names.d.ts +8 -6
- package/dist/core/names.js +14 -18
- package/dist/core/server.d.ts +9 -7
- package/dist/core/server.js +17 -21
- package/dist/core/trail.d.ts +6 -3
- package/dist/core/trail.js +2 -2
- package/dist/react/context.d.ts +13 -6
- package/dist/react/context.js +11 -9
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/useBatchCommand.d.ts +5 -5
- package/dist/react/useBatchCommand.js +10 -12
- package/dist/react/useCommand.d.ts +11 -15
- package/dist/react/useCommand.js +15 -13
- package/dist/react/useCount.d.ts +2 -2
- package/dist/react/useCounts.js +10 -9
- package/dist/react/useGroups.d.ts +1 -1
- package/dist/react/useGroups.js +22 -13
- package/dist/react/useHistory.js +7 -7
- package/dist/react/useListing.d.ts +14 -7
- package/dist/react/useListing.js +33 -9
- package/dist/react/useLookup.js +5 -7
- package/dist/react/useNameOf.d.ts +2 -2
- package/dist/react/useNameOf.js +4 -13
- package/dist/react/usePivot.d.ts +1 -1
- package/dist/react/usePivot.js +13 -7
- package/dist/react/useRecord.js +49 -57
- package/dist/react/useRecordLifecycle.js +8 -9
- package/dist/react/useServiceReading.js +6 -18
- package/dist/react/useUpload.js +9 -2
- package/dist/react/useWrites.d.ts +13 -12
- package/dist/react/useWrites.js +17 -16
- package/dist/web/board/Dashboard.d.ts +112 -0
- package/dist/web/board/Dashboard.js +106 -0
- package/dist/web/board/index.d.ts +1 -0
- package/dist/web/board/index.js +1 -0
- package/dist/web/index.d.ts +2 -0
- package/dist/web/index.js +2 -0
- package/dist/web/list/EntityList.d.ts +2 -2
- package/dist/web/list/entityList/choosing.d.ts +3 -3
- package/dist/web/list/entityList/faces.d.ts +6 -6
- package/dist/web/list/entityList/grouping.d.ts +3 -3
- package/dist/web/list/entityList/opening.d.ts +4 -4
- package/dist/web/list/entityList/opening.js +2 -1
- package/dist/web/list/entityList/paging.d.ts +3 -3
- package/dist/web/list/entityList/props.d.ts +4 -4
- package/dist/web/list/entityList/rowActions.d.ts +4 -4
- package/dist/web/list/entityList/rowActions.js +1 -1
- package/dist/web/list/export.d.ts +2 -2
- package/dist/web/list/export.js +7 -8
- package/dist/web/list/presentation.d.ts +3 -3
- package/dist/web/list/records.d.ts +13 -10
- package/dist/web/list/records.js +23 -44
- package/dist/web/list/reorder.d.ts +1 -1
- package/dist/web/list/reorder.js +8 -6
- package/dist/web/list/rowCommands.d.ts +10 -9
- package/dist/web/list/rowCommands.js +14 -15
- package/dist/web/list/useEntityList.d.ts +4 -4
- package/dist/web/record/CommandButton.d.ts +8 -8
- package/dist/web/record/EntityTags.js +4 -4
- package/dist/web/record/RelatedList.js +2 -2
- package/dist/web/record/Wizard.d.ts +65 -0
- package/dist/web/record/Wizard.js +90 -0
- package/dist/web/record/lines.js +4 -4
- package/dist/web/record/richText.js +1 -1
- package/dist/web/workspace/SincproApp.d.ts +8 -6
- package/dist/web/workspace/SincproApp.js +17 -19
- package/dist/web/workspace/composer.d.ts +14 -9
- package/dist/web/workspace/composer.js +29 -8
- package/dist/web/workspace/record.js +2 -2
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Entity, type
|
|
1
|
+
import { type Entity, type OperationTransport } 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
4
|
import { type ListDefinition } from "../../core/list.js";
|
|
@@ -21,20 +21,22 @@ import { type ComponentType } from "react";
|
|
|
21
21
|
* ⌘K asks the server with `matching` — 8 records — the same question a many2one asks. Each hit
|
|
22
22
|
* says what it is (`noun`, composer's) and, beside it, what tells it apart: the entity's own
|
|
23
23
|
* `option` look, else its summary's description or type — never its key, which tells a person
|
|
24
|
-
* nothing a UUID long («María Fernanda Apaza Quispe 01a1ebd4…»).
|
|
25
|
-
*
|
|
26
|
-
* without `tenant_id`
|
|
27
|
-
* `search: {
|
|
24
|
+
* nothing a UUID long («María Fernanda Apaza Quispe 01a1ebd4…»). Its model is `meta`, else the workspace's
|
|
25
|
+
* (`SincproApp`: the contract's, `metasOf`); without one, ⌘K finds nothing of it. A search that answers a SCOPE by a field of its input (forge's projects
|
|
26
|
+
* without `tenant_id` are the projects with NO tenant) is searched in the one ⌘K should see:
|
|
27
|
+
* `search: { input }`.
|
|
28
28
|
*
|
|
29
29
|
* The screens can come in a chunk of their own (`load`): the composer asks for a view's
|
|
30
30
|
* component when it first opens, so the application's bundle does not carry every screen of
|
|
31
31
|
* every entity — `entityView` keeps that, where handing it the components had lost it.
|
|
32
32
|
*
|
|
33
|
-
* entityView(invoices, {
|
|
33
|
+
* entityView(invoices, { operations, name: "Facturas",
|
|
34
34
|
* load: () => import("./invoice_views").then((m) => ({ list: m.Invoices, record: m.Invoice })) })
|
|
35
35
|
*/
|
|
36
36
|
export type EntityViewOptions = {
|
|
37
|
-
|
|
37
|
+
/** What ⌘K's search calls — the screens' operations (`screensOperations`, wrapped here when
|
|
38
|
+
* they are not). */
|
|
39
|
+
operations: OperationTransport;
|
|
38
40
|
/** How it reads in the palette, a panel's frame and the breadcrumb. */
|
|
39
41
|
name: string;
|
|
40
42
|
/** What ONE of its records is called — «Colegiado» —, beside each record ⌘K finds, so two
|
|
@@ -54,9 +56,10 @@ export type EntityViewOptions = {
|
|
|
54
56
|
* `useRecordInWorkspace` / `useRecordScreen`. */
|
|
55
57
|
title?: (record: AnyRecord) => string | null;
|
|
56
58
|
actions?: ViewSpec["actions"];
|
|
57
|
-
/** ⌘K's question: the
|
|
59
|
+
/** ⌘K's question: the fields of the search's input, beside the criteria, that say which
|
|
60
|
+
* records it searches. */
|
|
58
61
|
search?: {
|
|
59
|
-
|
|
62
|
+
input?: Readonly<Record<string, unknown>>;
|
|
60
63
|
};
|
|
61
64
|
/** The screens, loaded when the view first opens — a dynamic `import()`. What it does not
|
|
62
65
|
* bring is `list` / `record`, or the defaults. */
|
|
@@ -65,6 +68,8 @@ export type EntityViewOptions = {
|
|
|
65
68
|
record?: ComponentType<ViewProps>;
|
|
66
69
|
}>;
|
|
67
70
|
};
|
|
71
|
+
/** Inside the `FrameworkProvider`: hands its models to the views' searches while mounted. */
|
|
72
|
+
export declare function WorkspaceModels(): null;
|
|
68
73
|
export declare function entityView<T extends AnyRecord>(entity: Entity<T>, options: EntityViewOptions): ViewSpec;
|
|
69
74
|
/**
|
|
70
75
|
* A named list as a view of its own: «Por cobrar» in ⌘K's «Go to», its own breadcrumb, the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { isEntityId,
|
|
3
|
+
import { isEntityId, NEW_PARAM, processContext, scopeNameOf, scopeOfRef, screensOperations, } from "@sincpro/client-framework";
|
|
4
4
|
import { nameOf } from "@sincpro/criteria";
|
|
5
5
|
import { usePhone, } from "@sincpro/web-composer";
|
|
6
6
|
import { CHOOSE_MANY } from "../../core/list.js";
|
|
@@ -13,7 +13,7 @@ import { RecordOpeningProvider, } from "../record/opening.js";
|
|
|
13
13
|
import { openIn, RECORD_SIZE, targetsFor } from "./open.js";
|
|
14
14
|
import { EntityRecord } from "./RecordScreen.js";
|
|
15
15
|
import { useToastIfAny } from "@sincpro/web-ui";
|
|
16
|
-
import { useMemo } from "react";
|
|
16
|
+
import { useEffect, useMemo } from "react";
|
|
17
17
|
/**
|
|
18
18
|
* The fields of a view open their records in the workspace: a modal over this surface by
|
|
19
19
|
* default, beside it from inside a modal, «Buscar más…» as the entity's list that answers, and
|
|
@@ -40,10 +40,10 @@ function InWorkspace({ api, children }) {
|
|
|
40
40
|
};
|
|
41
41
|
}, [api, targets]);
|
|
42
42
|
// «Buscar más…» in the view's search bars: the same choosers, named by the framework's book.
|
|
43
|
-
const {
|
|
43
|
+
const { operations, metas, names, entities } = useFramework();
|
|
44
44
|
const named = useSearchRecords();
|
|
45
45
|
const toast = useToastIfAny();
|
|
46
|
-
const browser = useMemo(() => recordsBrowser({
|
|
46
|
+
const browser = useMemo(() => recordsBrowser({ operations, metas, names, entities }, opening, named, (failure) => toast?.show(refusalNotice(failure))), [operations, metas, names, entities, opening, named, toast]);
|
|
47
47
|
return (_jsx(RecordOpeningProvider, { value: opening, children: _jsx(RecordsBrowserProvider, { value: browser, children: children }) }));
|
|
48
48
|
}
|
|
49
49
|
/** The entity's list when the application writes none: opened under a named cut, it says
|
|
@@ -61,6 +61,25 @@ function recordOf(entity, title) {
|
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
63
|
/** The language the screens speak now — the provider puts it in the process's context. */
|
|
64
|
+
/**
|
|
65
|
+
* The models the mounted workspace knows — its `FrameworkProvider`'s store, the contract's
|
|
66
|
+
* (`metasOf`) and what the screens learned —, for ⌘K: a view searches outside React, before any of
|
|
67
|
+
* its screens is open. Set by `SincproApp` (`WorkspaceModels`); an application that mounts the
|
|
68
|
+
* composer itself gives each view its `meta`.
|
|
69
|
+
*/
|
|
70
|
+
const mounted = { metas: null };
|
|
71
|
+
/** Inside the `FrameworkProvider`: hands its models to the views' searches while mounted. */
|
|
72
|
+
export function WorkspaceModels() {
|
|
73
|
+
const { metas } = useFramework();
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
mounted.metas = metas;
|
|
76
|
+
return () => {
|
|
77
|
+
if (mounted.metas === metas)
|
|
78
|
+
mounted.metas = null;
|
|
79
|
+
};
|
|
80
|
+
}, [metas]);
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
64
83
|
function localeNow() {
|
|
65
84
|
const lang = processContext.get("lang");
|
|
66
85
|
return typeof lang === "string" && lang !== "" ? lang : undefined;
|
|
@@ -80,7 +99,8 @@ function titleOf(ref, name) {
|
|
|
80
99
|
}
|
|
81
100
|
export function entityView(entity, options) {
|
|
82
101
|
let meta = options.meta ?? null;
|
|
83
|
-
const
|
|
102
|
+
const operations = screensOperations(options.operations);
|
|
103
|
+
const input = options.search?.input ?? {};
|
|
84
104
|
async function screens() {
|
|
85
105
|
const loaded = options.load === undefined ? {} : await options.load();
|
|
86
106
|
const List = loaded.list ?? options.list ?? listOf(entity, options.name);
|
|
@@ -114,13 +134,14 @@ export function entityView(entity, options) {
|
|
|
114
134
|
search: async (query) => {
|
|
115
135
|
if (query.trim() === "")
|
|
116
136
|
return [];
|
|
117
|
-
|
|
118
|
-
meta = (await options.transport.list(route, { pagination: { limit: 1 } })).meta;
|
|
137
|
+
meta ??= mounted.metas?.get(entity.key) ?? null;
|
|
119
138
|
if (meta?.search == null)
|
|
120
139
|
return [];
|
|
121
140
|
// A hit reads as a choice anywhere a record is picked by name: its name and what tells it
|
|
122
141
|
// apart, never its key (`findChoices`).
|
|
123
|
-
const choices = await findChoices(
|
|
142
|
+
const choices = await findChoices(operations, entity, meta, query, localeNow(), {
|
|
143
|
+
input,
|
|
144
|
+
});
|
|
124
145
|
return choices.map((one) => ({
|
|
125
146
|
ref: entity.ref(one.id),
|
|
126
147
|
label: one.name,
|
|
@@ -57,13 +57,13 @@ export function useRecordScreen(entity, { api, resource }, options = {}) {
|
|
|
57
57
|
const summarize = useSummaryOf(entity);
|
|
58
58
|
const copy = frameworkCopy().record;
|
|
59
59
|
// Opened from a list: where it stands in it, and its neighbours (`Trail`).
|
|
60
|
-
const { trails,
|
|
60
|
+
const { trails, operations } = useFramework();
|
|
61
61
|
const trailKey = resource.params?.[TRAIL_PARAM];
|
|
62
62
|
const trail = trailKey === undefined ? undefined : trails.get(trailKey);
|
|
63
63
|
const go = (step) => () => {
|
|
64
64
|
if (trail === undefined || trailKey === undefined)
|
|
65
65
|
return;
|
|
66
|
-
void stepIn(
|
|
66
|
+
void stepIn(operations, trail, reading.id, step).then((moved) => {
|
|
67
67
|
if (moved === null)
|
|
68
68
|
return;
|
|
69
69
|
trails.set(trailKey, moved.trail);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sincpro/web-framework",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.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",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@opentelemetry/sdk-trace": "^3.1.0",
|
|
52
52
|
"@sentry/browser": "^11.11.0",
|
|
53
53
|
"@sentry/core": "^11.11.0",
|
|
54
|
-
"@sincpro/client-framework": "^
|
|
54
|
+
"@sincpro/client-framework": "^3.1.0",
|
|
55
55
|
"@sincpro/criteria": "^2.6.0",
|
|
56
56
|
"@sincpro/criteria-react": "^2.5.1",
|
|
57
57
|
"@sincpro/web-composer": "^1.7.0",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"@opentelemetry/sdk-trace": "3.1.0",
|
|
96
96
|
"@sentry/browser": "11.11.0",
|
|
97
97
|
"@sentry/core": "11.11.0",
|
|
98
|
-
"@sincpro/client-framework": "^
|
|
98
|
+
"@sincpro/client-framework": "^3.1.0",
|
|
99
99
|
"@sincpro/criteria": "^2.6.0",
|
|
100
100
|
"@sincpro/criteria-react": "^2.5.1",
|
|
101
101
|
"@sincpro/web-composer": "^1.9.0",
|