@sincpro/web-framework 3.19.0 → 3.20.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 +58 -51
- package/dist/core/copy.d.ts +12 -0
- package/dist/core/copy.js +51 -0
- package/dist/core/edit.d.ts +13 -0
- package/dist/core/edit.js +14 -0
- package/dist/core/export.d.ts +29 -0
- package/dist/core/export.js +47 -0
- package/dist/core/groups.js +1 -4
- package/dist/core/index.d.ts +3 -2
- package/dist/core/index.js +3 -2
- package/dist/react/context.d.ts +16 -2
- package/dist/react/context.js +7 -4
- package/dist/react/index.d.ts +3 -1
- package/dist/react/index.js +2 -0
- package/dist/react/useCounts.d.ts +23 -0
- package/dist/react/useCounts.js +43 -0
- package/dist/react/usePeopleOf.d.ts +14 -0
- package/dist/react/usePeopleOf.js +35 -0
- package/dist/react/useRecord.js +2 -2
- package/dist/web/index.d.ts +2 -2
- package/dist/web/index.js +2 -2
- package/dist/web/list/entityList/opening.d.ts +1 -1
- package/dist/web/list/entityList/opening.js +7 -2
- package/dist/web/list/entityList/props.d.ts +3 -2
- package/dist/web/list/export.d.ts +13 -0
- package/dist/web/list/export.js +61 -0
- package/dist/web/record/lines.js +6 -6
- package/dist/web/workspace/RecordScreen.d.ts +56 -6
- package/dist/web/workspace/RecordScreen.js +68 -14
- package/dist/web/workspace/SincproApp.d.ts +11 -1
- package/dist/web/workspace/SincproApp.js +8 -8
- package/dist/web/workspace/record.d.ts +17 -5
- package/dist/web/workspace/record.js +24 -7
- package/dist/web/workspace/workspace.d.ts +2 -0
- package/dist/web/workspace/workspace.js +1 -1
- package/package.json +7 -7
|
@@ -4,11 +4,11 @@ import { processChanges, processContext, reportError, } from "@sincpro/client-fr
|
|
|
4
4
|
import { Composer, installComposerCopy, SPANISH_COMPOSER_COPY, useWorkspace, } from "@sincpro/web-composer";
|
|
5
5
|
import { createRegistry, formatRef, PHONE_WIDTH } from "@sincpro/web-composer/domain";
|
|
6
6
|
import { cachedTransport, } from "../../core/cache.js";
|
|
7
|
-
import { installFrameworkCopy, SPANISH_FRAMEWORK_COPY, } from "../../core/copy.js";
|
|
7
|
+
import { installFrameworkCopy, SPANISH_FRAMEWORK_COPY, SPANISH_FRAMEWORK_COPY_TU, } from "../../core/copy.js";
|
|
8
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
|
-
import { installCopy, SearchProvider, SPANISH_COPY, ToastProvider, useSearchSettings, } from "@sincpro/web-ui";
|
|
11
|
+
import { installCopy, SearchProvider, SPANISH_COPY, SPANISH_COPY_TU, ToastProvider, useSearchSettings, } from "@sincpro/web-ui";
|
|
12
12
|
import { useEffect, useMemo, useState, useSyncExternalStore } from "react";
|
|
13
13
|
/**
|
|
14
14
|
* The application context in one place: who answers (the transport), in which language, which
|
|
@@ -30,7 +30,7 @@ import { useEffect, useMemo, useState, useSyncExternalStore } from "react";
|
|
|
30
30
|
* `FrameworkProvider` around it — its transport and cache, its context, its zone and currency —
|
|
31
31
|
* and brings only what is its own: its entities, the definitions of their models and their facts
|
|
32
32
|
* (`ModelDefinitions`). The configuration of the provider's (`timeZone`, `currency`, `region`,
|
|
33
|
-
* `dateStyle`, `richText`, `uploads`, `cache`, `changes`) is then the provider's: said once.
|
|
33
|
+
* `dateStyle`, `richText`, `uploads`, `people`, `cache`, `changes`) is then the provider's: said once.
|
|
34
34
|
*
|
|
35
35
|
* <FrameworkProvider transport={transport} timeZone="America/La_Paz" currency="BOB">
|
|
36
36
|
* <Site />
|
|
@@ -62,13 +62,13 @@ function FrameworkSearch({ children }) {
|
|
|
62
62
|
}
|
|
63
63
|
/** A view that broke while drawing, told to the process's error reporter: `view <ref>`. */
|
|
64
64
|
const reportViewError = (error, { resource }) => reportError(error, `view ${formatRef(resource)}`);
|
|
65
|
-
export function SincproApp({ transport, views, start, language = "es", metas, entities, empty, skin = webUiSkin, cache = {}, timeZone, dateStyle, currency, region, richText, uploads, events, workspace: given, bar, onViewError = reportViewError, changes = processChanges, }) {
|
|
65
|
+
export function SincproApp({ transport, views, start, language = "es", voice = "vos", metas, entities, empty, skin = webUiSkin, cache = {}, timeZone, dateStyle, currency, region, richText, uploads, people, events, workspace: given, bar, onViewError = reportViewError, changes = processChanges, }) {
|
|
66
66
|
// Installed once, before anything draws: the three tables are module state of their packages.
|
|
67
67
|
useState(() => {
|
|
68
68
|
if (language === "es") {
|
|
69
|
-
installCopy(SPANISH_COPY);
|
|
69
|
+
installCopy(voice === "tú" ? SPANISH_COPY_TU : SPANISH_COPY);
|
|
70
70
|
installComposerCopy(SPANISH_COMPOSER_COPY);
|
|
71
|
-
installFrameworkCopy(SPANISH_FRAMEWORK_COPY);
|
|
71
|
+
installFrameworkCopy(voice === "tú" ? SPANISH_FRAMEWORK_COPY_TU : SPANISH_FRAMEWORK_COPY);
|
|
72
72
|
}
|
|
73
73
|
return null;
|
|
74
74
|
});
|
|
@@ -113,6 +113,6 @@ export function SincproApp({ transport, views, start, language = "es", metas, en
|
|
|
113
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
114
|
// One face of a product: the provider around it is the app's, and this brings only its own.
|
|
115
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 }));
|
|
116
|
+
return (_jsx(ModelDefinitions, { ...(entities === undefined ? {} : { entities }), ...(metas === undefined ? {} : { metas }), ...(events === undefined ? {} : { events }), ...(people === undefined ? {} : { people }), 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 }), ...(people === undefined ? {} : { people }), ...(events === undefined ? {} : { events }), children: shell }));
|
|
118
118
|
}
|
|
@@ -2,11 +2,17 @@ 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 { DockMoment } from "@sincpro/web-ui";
|
|
5
6
|
/** Who made a record, or changed it last, and when: `Record.Audit`'s. */
|
|
6
7
|
export type Stamp = {
|
|
7
8
|
at: string;
|
|
8
9
|
by?: string;
|
|
9
10
|
};
|
|
11
|
+
/** A record's tag in its heading: its word, and the tone that says how it is going. */
|
|
12
|
+
export type RecordTag = {
|
|
13
|
+
label: string;
|
|
14
|
+
tone?: "neutral" | "good" | "warn" | "bad" | "info" | "accent";
|
|
15
|
+
};
|
|
10
16
|
/**
|
|
11
17
|
* What every record screen in a workspace does before drawing its own — what `EntityRecord`
|
|
12
18
|
* does, as values: read the record for editing, follow the workspace's breadcrumb, tell the
|
|
@@ -41,6 +47,15 @@ export declare function useRecordScreen<T extends AnyRecord>(entity: Entity<T>,
|
|
|
41
47
|
/** The line under its name, the screen's way (an enrollment's course, an order's detail).
|
|
42
48
|
* Without it, or when it answers `null`, the record's type when the model has one. */
|
|
43
49
|
subtitle?: ((record: T) => string | null) | undefined;
|
|
50
|
+
/** Its tag, the screen's way («Publicada», good). Without it, or `null`, the record's state
|
|
51
|
+
* in the tone the entity declared. */
|
|
52
|
+
tag?: ((record: T) => RecordTag | null | undefined) | undefined;
|
|
53
|
+
/** How a new one is named in its heading and its tab: «Nueva noticia». Without it, the
|
|
54
|
+
* model's name and «nuevo». */
|
|
55
|
+
creating?: string | undefined;
|
|
56
|
+
/** The dock's word on the record's moment, the screen's way — one that depends on who looks
|
|
57
|
+
* («Comprobante por revisar» for whoever reviews it). Without it, the entity's (`presented`). */
|
|
58
|
+
moment?: ((record: T) => DockMoment | undefined) | undefined;
|
|
44
59
|
/** `false`: the screen draws its own history — it is not read here. */
|
|
45
60
|
history?: boolean | undefined;
|
|
46
61
|
/** The record and its model already read on the server that renders the screen
|
|
@@ -57,16 +72,13 @@ export declare function useRecordScreen<T extends AnyRecord>(entity: Entity<T>,
|
|
|
57
72
|
dirty?: import("@sincpro/web-ui").DirtyState | undefined;
|
|
58
73
|
placement: "page" | "card";
|
|
59
74
|
identity: {
|
|
60
|
-
tag?:
|
|
61
|
-
tone?: import("@sincpro/web-ui").Tone | undefined;
|
|
62
|
-
label: string;
|
|
63
|
-
} | undefined;
|
|
75
|
+
tag?: RecordTag | undefined;
|
|
64
76
|
subtitle?: string | undefined;
|
|
65
77
|
title: string;
|
|
66
78
|
};
|
|
67
79
|
};
|
|
68
80
|
/** `Record.Dock moment`: the application's word on the record's moment (`presented`). */
|
|
69
|
-
moment:
|
|
81
|
+
moment: DockMoment | undefined;
|
|
70
82
|
/** `Record.Pager`'s props, when it was opened from a list and nothing is typed. */
|
|
71
83
|
pager: {
|
|
72
84
|
index: number;
|
|
@@ -8,6 +8,7 @@ import { summaryFieldsOf } from "../../core/summary.js";
|
|
|
8
8
|
import { placeOf, stepIn } from "../../core/trail.js";
|
|
9
9
|
import { useFramework } from "../../react/context.js";
|
|
10
10
|
import { useHistory } from "../../react/useHistory.js";
|
|
11
|
+
import { usePeopleOf } from "../../react/usePeopleOf.js";
|
|
11
12
|
import { useRecord } from "../../react/useRecord.js";
|
|
12
13
|
import { useSummaryOf } from "../../react/useSummary.js";
|
|
13
14
|
import { presentationOf } from "../list/presentation.js";
|
|
@@ -52,7 +53,7 @@ export function useRecordScreen(entity, { api, resource }, options = {}) {
|
|
|
52
53
|
const crumbs = useCrumbs(api);
|
|
53
54
|
useRecordInWorkspace(api, reading, options);
|
|
54
55
|
const look = presentationOf(entity);
|
|
55
|
-
const
|
|
56
|
+
const read = useHistory(entity, reading.isNew || options.history === false ? "" : reading.id, [reading.record], { tones: look.facts });
|
|
56
57
|
const summarize = useSummaryOf(entity);
|
|
57
58
|
const copy = frameworkCopy().record;
|
|
58
59
|
// Opened from a list: where it stands in it, and its neighbours (`Trail`).
|
|
@@ -83,11 +84,23 @@ export function useRecordScreen(entity, { api, resource }, options = {}) {
|
|
|
83
84
|
const dirty = ready ? dirtyOf(reading) : undefined;
|
|
84
85
|
// What the application says of this record's moment — while nothing is being edited: then the
|
|
85
86
|
// pill says the unsaved changes itself.
|
|
86
|
-
const moment = ready && dirty === undefined
|
|
87
|
+
const moment = ready && dirty === undefined
|
|
88
|
+
? (options.moment?.(reading.record) ?? look.moment?.(reading.record))
|
|
89
|
+
: undefined;
|
|
87
90
|
const failure = reading.edit.failure;
|
|
88
91
|
// Who, only when the record says it (an author is optional: the line then says only when).
|
|
89
|
-
const stamp = (one) => one?.at == null
|
|
92
|
+
const stamp = (one) => one?.at == null
|
|
93
|
+
? undefined
|
|
94
|
+
: { at: one.at, ...(one.by == null ? {} : { by: personOf(one.by) }) };
|
|
95
|
+
// Who did it reads as a person, not a username, when the application names its people.
|
|
96
|
+
const personOf = usePeopleOf([
|
|
97
|
+
...(read ?? []).map((one) => one.by),
|
|
98
|
+
summary?.created?.by,
|
|
99
|
+
summary?.updated?.by,
|
|
100
|
+
]);
|
|
101
|
+
const history = read?.map((one) => one.by == null ? one : { ...one, by: personOf(one.by) });
|
|
90
102
|
const created = stamp(summary?.created);
|
|
103
|
+
const ownTag = ready && !reading.isNew ? options.tag?.(reading.record) : undefined;
|
|
91
104
|
const subtitle = (ready && !reading.isNew ? options.subtitle?.(reading.record) : null) ?? summary?.type;
|
|
92
105
|
const updated = stamp(summary?.updated);
|
|
93
106
|
// Moving away with something typed would lose it: «save / discard» comes first.
|
|
@@ -109,11 +122,15 @@ export function useRecordScreen(entity, { api, resource }, options = {}) {
|
|
|
109
122
|
// A new record is «creating»; an existing one has no name until it is read.
|
|
110
123
|
title: (ready && !reading.isNew ? options.title?.(reading.record) : null) ??
|
|
111
124
|
summary?.name ??
|
|
112
|
-
(reading.isNew
|
|
125
|
+
(reading.isNew
|
|
126
|
+
? (options.creating ?? copy.creating(nameOf(reading.meta, reading.locale) || ""))
|
|
127
|
+
: ""),
|
|
113
128
|
...(subtitle == null ? {} : { subtitle }),
|
|
114
|
-
...(
|
|
115
|
-
? {}
|
|
116
|
-
:
|
|
129
|
+
...(ownTag != null
|
|
130
|
+
? { tag: ownTag }
|
|
131
|
+
: summary?.state == null
|
|
132
|
+
? {}
|
|
133
|
+
: { tag: { label: summary.state, ...(tone === undefined ? {} : { tone }) } }),
|
|
117
134
|
},
|
|
118
135
|
...(dirty === undefined ? {} : { dirty }),
|
|
119
136
|
// The refusal in words; its heading when the server said nothing more (no detail).
|
|
@@ -26,6 +26,8 @@ import type { RecordReading } from "../../react/useRecord.js";
|
|
|
26
26
|
*/
|
|
27
27
|
export declare function useRecordInWorkspace<T extends AnyRecord>(api: WorkspaceApi, record: RecordReading<T>, options?: {
|
|
28
28
|
title?: ((record: T) => string | null) | undefined;
|
|
29
|
+
/** How a new one is named in its tab: «Nueva noticia». Without it, «Noticia · nuevo». */
|
|
30
|
+
creating?: string | undefined;
|
|
29
31
|
}): void;
|
|
30
32
|
/**
|
|
31
33
|
* «Browse everything» as the composer's chooser: the entity's own list opens in a window and
|
|
@@ -33,7 +33,7 @@ export function useRecordInWorkspace(api, record, options = {}) {
|
|
|
33
33
|
? options.title(record.record)
|
|
34
34
|
: null;
|
|
35
35
|
const title = record.isNew
|
|
36
|
-
? newTitle(record.meta, record.locale)
|
|
36
|
+
? (options.creating ?? newTitle(record.meta, record.locale))
|
|
37
37
|
: named !== null
|
|
38
38
|
? named
|
|
39
39
|
: record.status === "ready" && display !== ""
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sincpro/web-framework",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.20.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,11 +51,11 @@
|
|
|
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": "^2.
|
|
55
|
-
"@sincpro/criteria": "^2.
|
|
54
|
+
"@sincpro/client-framework": "^2.8.0",
|
|
55
|
+
"@sincpro/criteria": "^2.6.0",
|
|
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.22.0",
|
|
59
59
|
"react": ">=19",
|
|
60
60
|
"react-dom": ">=19"
|
|
61
61
|
},
|
|
@@ -95,11 +95,11 @@
|
|
|
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": "^2.
|
|
99
|
-
"@sincpro/criteria": "^2.
|
|
98
|
+
"@sincpro/client-framework": "^2.8.0",
|
|
99
|
+
"@sincpro/criteria": "^2.6.0",
|
|
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.22.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",
|