@sincpro/web-framework 2.0.0 → 2.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 +10 -10
- package/dist/core/present.d.ts +1 -0
- package/dist/core/present.js +54 -6
- package/dist/react/context.d.ts +5 -1
- package/dist/react/context.js +11 -2
- package/dist/react/useGroups.js +2 -2
- package/dist/react/useHistory.js +2 -2
- package/dist/react/useListing.js +10 -1
- package/dist/react/useLookup.js +2 -2
- package/dist/react/useNameOf.js +2 -2
- package/dist/react/usePivot.js +2 -2
- package/dist/react/useRecord.js +17 -2
- package/dist/web/index.d.ts +1 -1
- package/dist/web/index.js +1 -1
- package/dist/web/record/EntityPicker.d.ts +7 -4
- package/dist/web/record/EntityPicker.js +5 -5
- package/dist/web/record/control.d.ts +3 -1
- package/dist/web/record/control.js +8 -5
- package/dist/web/record/edit.js +20 -1
- package/dist/web/record/lines.js +13 -2
- package/dist/web/record/record.d.ts +12 -2
- package/dist/web/record/record.js +10 -2
- package/dist/web/workspace/SincproApp.d.ts +8 -18
- package/dist/web/workspace/SincproApp.js +17 -5
- package/dist/web/workspace/record.d.ts +59 -12
- package/dist/web/workspace/record.js +88 -27
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -427,7 +427,7 @@ hook and draw your own, or go straight to the loose piece.
|
|
|
427
427
|
| How does a record look? | `presented(entity, { option, row, card })` | — | `presentationOf` |
|
|
428
428
|
| N records: search, filter, page | `EntityList`, `EntitySearchBar` | `useListing`, `useGroups` | `transport.list(route, criteria)` |
|
|
429
429
|
| A named slice (to collect, …) | `defineList` + `listView` | `useListing(list)` | `scopeOf` |
|
|
430
|
-
| A record's whole screen | `EntityRecord`, `entityView` without `record` |
|
|
430
|
+
| A record's whole screen | `EntityRecord`, `entityView` without `record` | `useRecordScreen` | `formOf` |
|
|
431
431
|
| Previous / next from a record | `EntityRecord` (from a list) | — | `placeOf`, `stepIn` (`Trail`) |
|
|
432
432
|
| How much each group adds up | `EntityList sums` | `useGroups` (`sums`) | `sumsOf`, `detailOf` |
|
|
433
433
|
| One record: read, edit, save | `RecordField`, `factsOf`, `RecordLines` | `useRecord` | `transport.one`, `transport.send` |
|
|
@@ -459,15 +459,15 @@ The rules behind them, in short:
|
|
|
459
459
|
|
|
460
460
|
There is no store of ours to learn: each kind of state already has its owner.
|
|
461
461
|
|
|
462
|
-
| State | Lives in
|
|
463
|
-
| -------------------------------------------- |
|
|
464
|
-
| Who answers, language, known models | `FrameworkProvider` (this package)
|
|
465
|
-
| What the backend sees on every request |
|
|
466
|
-
| What an opening carries (company, a default) | composer: the reference's `params`
|
|
467
|
-
| The record a modal covers | composer: `api.over`
|
|
468
|
-
| What a chooser was asked | composer: `pick(…, { question })`
|
|
469
|
-
| What the user is on, what is selected | composer: `api.context`
|
|
470
|
-
| A screen's list, record, groups | the hooks
|
|
462
|
+
| State | Lives in | Read with |
|
|
463
|
+
| -------------------------------------------- | --------------------------------------------------------- | ---------------------------------- |
|
|
464
|
+
| Who answers, language, known models | `FrameworkProvider` (this package) | the hooks, through context |
|
|
465
|
+
| What the backend sees on every request | `processContext` (client-framework), as `sincpro-context` | the backend's `use_context()` |
|
|
466
|
+
| What an opening carries (company, a default) | composer: the reference's `params` | `api.self.params`, `api.setParams` |
|
|
467
|
+
| The record a modal covers | composer: `api.over` | `api.over` |
|
|
468
|
+
| What a chooser was asked | composer: `pick(…, { question })` | `api.choosing` |
|
|
469
|
+
| What the user is on, what is selected | composer: `api.context` | `useWorkspaceContext(api)` |
|
|
470
|
+
| A screen's list, record, groups | the hooks | `useListing`, `useRecord`, … |
|
|
471
471
|
|
|
472
472
|
Not yet: a new record does not take the `params` it was opened with as its initial values
|
|
473
473
|
(`ROADMAP.md`, «Estado y contexto»).
|
package/dist/core/present.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export declare const BOOKKEEPING: ReadonlySet<string>;
|
|
|
38
38
|
* textOf(meta, "active", true, "es") -> "sí"
|
|
39
39
|
* textOf(meta, "due", "2026-03-12", "es") -> "12 mar 2026"
|
|
40
40
|
* textOf(meta, "total", "1150.5", "es") -> "1150,5" (exact: digits kept)
|
|
41
|
+
* textOf(meta, "price", { amount: "19.9", currency: "BOB" }, "es") -> "19,90 Bs"
|
|
41
42
|
* textOf(meta, "lines", {items, count: {value: 30}}) -> "30 elementos"
|
|
42
43
|
*/
|
|
43
44
|
export declare function textOf(meta: Meta | null | undefined, name: string, value: unknown, locale?: string): string | null;
|
package/dist/core/present.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { timeZoneNow } from "@sincpro/client-framework";
|
|
1
|
+
import { Money, timeZoneNow } from "@sincpro/client-framework";
|
|
2
2
|
import { choiceLabelOf, labelOf, } from "@sincpro/criteria";
|
|
3
3
|
import { frameworkCopy } from "./copy.js";
|
|
4
4
|
import { relatedOf } from "./related.js";
|
|
@@ -85,6 +85,50 @@ function numberFormat(locale, kept) {
|
|
|
85
85
|
}
|
|
86
86
|
return format;
|
|
87
87
|
}
|
|
88
|
+
/** The currency codes `Intl` refused, by locale: asked once, not on every cell. */
|
|
89
|
+
const unknownCurrencies = new Set();
|
|
90
|
+
function currencyFormat(locale, currency) {
|
|
91
|
+
const key = `c|${locale ?? ""}|${currency}`;
|
|
92
|
+
if (unknownCurrencies.has(key))
|
|
93
|
+
return null;
|
|
94
|
+
let format = formatters.get(key);
|
|
95
|
+
if (format === undefined) {
|
|
96
|
+
try {
|
|
97
|
+
format = new Intl.NumberFormat(locale, {
|
|
98
|
+
style: "currency",
|
|
99
|
+
currency,
|
|
100
|
+
minimumFractionDigits: Money.decimalsOf(currency),
|
|
101
|
+
maximumFractionDigits: Money.decimalsOf(currency),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
// Not an ISO 4217 code Intl knows (a token, a loyalty point): drawn as «amount CODE».
|
|
106
|
+
unknownCurrencies.add(key);
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
formatters.set(key, format);
|
|
110
|
+
}
|
|
111
|
+
return format;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* A money as a person reads it: `{ amount: "1150.5", currency: "BOB" }` → «Bs 1.150,50». The
|
|
115
|
+
* amount goes to `Intl` as text, so no digit passes through a float, rounded to the currency's
|
|
116
|
+
* decimals as an invoice shows it (`Money.rounded`).
|
|
117
|
+
*/
|
|
118
|
+
function moneyText(value, locale) {
|
|
119
|
+
let money;
|
|
120
|
+
try {
|
|
121
|
+
money = Money.fromJSON(value).rounded();
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
// A money of the right shape with an amount or a code that is not one (`"1,50"`, `""`): no
|
|
125
|
+
// text, as any value object — never an error that takes the whole view down.
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
const amount = money.amount;
|
|
129
|
+
return (currencyFormat(locale, money.currency)?.format(amount) ??
|
|
130
|
+
`${numberFormat(locale, money.decimals).format(amount)} ${money.currency}`);
|
|
131
|
+
}
|
|
88
132
|
/** The record a many2one points at, read by the display its definition names. */
|
|
89
133
|
function displayOf(field, value) {
|
|
90
134
|
const definition = field.definition;
|
|
@@ -101,6 +145,7 @@ function displayOf(field, value) {
|
|
|
101
145
|
* textOf(meta, "active", true, "es") -> "sí"
|
|
102
146
|
* textOf(meta, "due", "2026-03-12", "es") -> "12 mar 2026"
|
|
103
147
|
* textOf(meta, "total", "1150.5", "es") -> "1150,5" (exact: digits kept)
|
|
148
|
+
* textOf(meta, "price", { amount: "19.9", currency: "BOB" }, "es") -> "19,90 Bs"
|
|
104
149
|
* textOf(meta, "lines", {items, count: {value: 30}}) -> "30 elementos"
|
|
105
150
|
*/
|
|
106
151
|
export function textOf(meta, name, value, locale) {
|
|
@@ -125,11 +170,13 @@ export function textOf(meta, name, value, locale) {
|
|
|
125
170
|
}
|
|
126
171
|
case "integer":
|
|
127
172
|
case "number": {
|
|
128
|
-
|
|
129
|
-
if (Number.isNaN(number))
|
|
173
|
+
if (Number.isNaN(Number(value)))
|
|
130
174
|
return String(value);
|
|
131
|
-
|
|
132
|
-
|
|
175
|
+
// A decimal that travels as text goes to `Intl` as text: every digit kept, none through a
|
|
176
|
+
// float (`"12345678901234567.89"` reads whole).
|
|
177
|
+
if (typeof value === "string")
|
|
178
|
+
return numberFormat(locale, decimals(value)).format(value.trim());
|
|
179
|
+
return numberFormat(locale, undefined).format(Number(value));
|
|
133
180
|
}
|
|
134
181
|
case "text[]":
|
|
135
182
|
return Array.isArray(value)
|
|
@@ -145,7 +192,8 @@ export function textOf(meta, name, value, locale) {
|
|
|
145
192
|
case "many2one":
|
|
146
193
|
return typeof value === "object" ? displayOf(field, value) : String(value);
|
|
147
194
|
case "embedded":
|
|
148
|
-
|
|
195
|
+
// A value object has no text of its own — but a money, the one every ERP holds, does.
|
|
196
|
+
return Money.isMoney(value) ? moneyText(value, locale) : null;
|
|
149
197
|
default:
|
|
150
198
|
return typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
151
199
|
}
|
package/dist/react/context.d.ts
CHANGED
|
@@ -16,7 +16,9 @@ import { type ReactNode } from "react";
|
|
|
16
16
|
* `api.choosing` (what a chooser was asked, in memory) and `api.context` (what the user is on,
|
|
17
17
|
* what is selected). Read `~/dev/sincpro_web_composer/README.md` before writing a second one
|
|
18
18
|
* here. A value the backend must see on every request (the active company) goes in the
|
|
19
|
-
*
|
|
19
|
+
* process's context (`processContext.set({ company_id })`, @sincpro/client-framework): every
|
|
20
|
+
* request under this provider carries it in `sincpro-context` (`screensTransport`), and a change
|
|
21
|
+
* reads every screen again.
|
|
20
22
|
*/
|
|
21
23
|
type FrameworkContextValue = {
|
|
22
24
|
transport: Transport;
|
|
@@ -26,6 +28,8 @@ type FrameworkContextValue = {
|
|
|
26
28
|
entities: readonly Entity[];
|
|
27
29
|
/** Where each open record came from (`Trail`), by the key its reference carries. */
|
|
28
30
|
trails: Map<string, Trail>;
|
|
31
|
+
/** The process's context now: a reading reads again when it changes (another company). */
|
|
32
|
+
context: Readonly<Record<string, unknown>>;
|
|
29
33
|
};
|
|
30
34
|
export declare function FrameworkProvider({ transport, locale, metas: seed, entities, timeZone, children, }: {
|
|
31
35
|
transport: Transport;
|
package/dist/react/context.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { installTimeZone, metaStore, } from "@sincpro/client-framework";
|
|
3
|
+
import { installTimeZone, metaStore, processContext, screensTransport, } from "@sincpro/client-framework";
|
|
4
4
|
import { entityFor } from "../core/relation.js";
|
|
5
|
+
import { useContextValues } from "./useContextValues.js";
|
|
5
6
|
import { createContext, useContext, useMemo, useRef, useState } from "react";
|
|
6
7
|
const FrameworkContext = createContext(null);
|
|
7
8
|
export function FrameworkProvider({ transport, locale, metas: seed, entities = NO_ENTITIES, timeZone, children, }) {
|
|
@@ -16,7 +17,15 @@ export function FrameworkProvider({ transport, locale, metas: seed, entities = N
|
|
|
16
17
|
// the screens already learned.
|
|
17
18
|
const [metas] = useState(() => metaStore(seed));
|
|
18
19
|
const [trails] = useState(() => new Map());
|
|
19
|
-
|
|
20
|
+
// What the screens read and write is a use case of `screens` (`screensTransport`,
|
|
21
|
+
// client-framework): each request traced, carrying the process's context (the company, the
|
|
22
|
+
// tenant) read at the moment it is sent, and reported when it failed unexpectedly.
|
|
23
|
+
const screens = useMemo(() => screensTransport(transport), [transport]);
|
|
24
|
+
// When the context changes, every reading on screen reads its same question again — a list
|
|
25
|
+
// keeps its filter, order and page, a record what was typed (`useListing`, `useRecord`). The
|
|
26
|
+
// transport stays the same one: a new one would start every reading over.
|
|
27
|
+
const context = useContextValues(processContext);
|
|
28
|
+
const value = useMemo(() => ({ transport: screens, locale, metas, entities, trails, context }), [screens, locale, metas, entities, trails, context]);
|
|
20
29
|
return _jsx(FrameworkContext.Provider, { value: value, children: children });
|
|
21
30
|
}
|
|
22
31
|
const NO_ENTITIES = [];
|
package/dist/react/useGroups.js
CHANGED
|
@@ -8,7 +8,7 @@ const MAX_GROUPS = 100;
|
|
|
8
8
|
/** A group is known by its criteria: unique per group, and stable across renders. */
|
|
9
9
|
const keyOf = (bucket) => JSON.stringify(bucket.criteria);
|
|
10
10
|
export function useGroups(listing, options = {}) {
|
|
11
|
-
const { transport } = useFramework();
|
|
11
|
+
const { transport, context } = useFramework();
|
|
12
12
|
// A named list may open grouped (`groupBy`); a person regroups from there.
|
|
13
13
|
const [levels, setLevels] = useState(() => listing.definition?.groupBy ?? []);
|
|
14
14
|
const [state, setState] = useState({ status: "idle", buckets: [], error: null });
|
|
@@ -54,7 +54,7 @@ export function useGroups(listing, options = {}) {
|
|
|
54
54
|
setState({ status: "failed", buckets: [], error });
|
|
55
55
|
});
|
|
56
56
|
return () => aborter.abort();
|
|
57
|
-
}, [transport, route, question, levels, sums, waiting]);
|
|
57
|
+
}, [transport, route, question, levels, sums, waiting, context]);
|
|
58
58
|
/** One page of a group: the first (`after` null) or the one the cursor points at. */
|
|
59
59
|
const read = useCallback((bucket, after) => {
|
|
60
60
|
const key = keyOf(bucket);
|
package/dist/react/useHistory.js
CHANGED
|
@@ -17,7 +17,7 @@ import { useEffect, useState } from "react";
|
|
|
17
17
|
*/
|
|
18
18
|
const SHOWN = 100;
|
|
19
19
|
export function useHistory(entity, id, deps = []) {
|
|
20
|
-
const { transport, locale } = useFramework();
|
|
20
|
+
const { transport, locale, context } = useFramework();
|
|
21
21
|
const [entries, setEntries] = useState(undefined);
|
|
22
22
|
const history = entity.history;
|
|
23
23
|
useEffect(() => {
|
|
@@ -37,6 +37,6 @@ export function useHistory(entity, id, deps = []) {
|
|
|
37
37
|
transport.list(history.route, criteria, aborter.signal).then((page) => aborter.signal.aborted || setEntries(historyOf(page.rows, page.meta, locale)), () => aborter.signal.aborted || setEntries(undefined));
|
|
38
38
|
return () => aborter.abort();
|
|
39
39
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- the caller names what reloads it
|
|
40
|
-
}, [transport, history, id, locale, ...deps]);
|
|
40
|
+
}, [transport, history, id, locale, context, ...deps]);
|
|
41
41
|
return entries;
|
|
42
42
|
}
|
package/dist/react/useListing.js
CHANGED
|
@@ -9,7 +9,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
|
9
9
|
/** How long typing has to pause before the search goes out. */
|
|
10
10
|
const TYPING_PAUSE = 200;
|
|
11
11
|
export function useListing(given, own = {}) {
|
|
12
|
-
const { transport, locale, metas } = useFramework();
|
|
12
|
+
const { transport, locale, metas, context } = useFramework();
|
|
13
13
|
// A named list is its entity under a fixed scope: the scope ANDs under the caller's own.
|
|
14
14
|
const definition = isList(given) ? given : undefined;
|
|
15
15
|
// A named list's entity has no typed Commands of its own: the default, as `C` then is.
|
|
@@ -56,6 +56,15 @@ export function useListing(given, own = {}) {
|
|
|
56
56
|
});
|
|
57
57
|
const typing = useRef(null);
|
|
58
58
|
useEffect(() => () => void (typing.current && clearTimeout(typing.current)), []);
|
|
59
|
+
// Another company (the process's context changed): the same question read again — its filter,
|
|
60
|
+
// order and page kept, never a reading started over.
|
|
61
|
+
const askedIn = useRef(context);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (askedIn.current === context)
|
|
64
|
+
return;
|
|
65
|
+
askedIn.current = context;
|
|
66
|
+
void reading.reload();
|
|
67
|
+
}, [context, reading]);
|
|
59
68
|
const narrowed = (next) => {
|
|
60
69
|
let criteria = base;
|
|
61
70
|
const found = searchOver(meta, next.text);
|
package/dist/react/useLookup.js
CHANGED
|
@@ -24,7 +24,7 @@ export function excluding(criteria, exclude, meta) {
|
|
|
24
24
|
export function useLookup(
|
|
25
25
|
/** The entity, or a named list of it: «active customers» chooses only those. */
|
|
26
26
|
entity, options = {}) {
|
|
27
|
-
const { transport, metas } = useFramework();
|
|
27
|
+
const { transport, metas, context } = useFramework();
|
|
28
28
|
const base = isList(entity) ? entity.entity : entity;
|
|
29
29
|
// The key field to exclude by comes with the definition: known already, or with the first
|
|
30
30
|
// answer — then this renders again and the reading starts over without the excluded.
|
|
@@ -77,7 +77,7 @@ entity, options = {}) {
|
|
|
77
77
|
})
|
|
78
78
|
.catch(() => undefined); // unnamed is not an error: the field shows its key
|
|
79
79
|
return () => aborter.abort();
|
|
80
|
-
}, [transport, route, meta, missingKey, base.summary]);
|
|
80
|
+
}, [transport, route, meta, missingKey, base.summary, context]);
|
|
81
81
|
const known = value === "" ? undefined : seen.current.get(value);
|
|
82
82
|
const chosenAll = wanted.map((id) => seen.current.get(id) ?? { id, label: id });
|
|
83
83
|
return {
|
package/dist/react/useNameOf.js
CHANGED
|
@@ -15,7 +15,7 @@ import { useEffect, useState } from "react";
|
|
|
15
15
|
* const name = useNameOf(tenants, record.tenant_id) ?? record.tenant_id;
|
|
16
16
|
*/
|
|
17
17
|
export function useNameOf(entity, id) {
|
|
18
|
-
const { transport, metas } = useFramework();
|
|
18
|
+
const { transport, metas, context } = useFramework();
|
|
19
19
|
const [named, setNamed] = useState(undefined);
|
|
20
20
|
useEffect(() => {
|
|
21
21
|
if (entity === undefined || id === "")
|
|
@@ -39,6 +39,6 @@ export function useNameOf(entity, id) {
|
|
|
39
39
|
})
|
|
40
40
|
.catch(() => undefined);
|
|
41
41
|
return () => aborter.abort();
|
|
42
|
-
}, [transport, metas, entity, id]);
|
|
42
|
+
}, [transport, metas, entity, id, context]);
|
|
43
43
|
return named?.id === id ? named.name : undefined;
|
|
44
44
|
}
|
package/dist/react/usePivot.js
CHANGED
|
@@ -5,7 +5,7 @@ import { useEffect, useState } from "react";
|
|
|
5
5
|
/** The most groups an axis answers: a pivot of ten thousand rows is a list. */
|
|
6
6
|
const MAX_KEYS = 100;
|
|
7
7
|
export function usePivot(listing, axes) {
|
|
8
|
-
const { transport } = useFramework();
|
|
8
|
+
const { transport, context } = useFramework();
|
|
9
9
|
const [state, setState] = useState({
|
|
10
10
|
status: "idle",
|
|
11
11
|
crossed: [],
|
|
@@ -53,6 +53,6 @@ export function usePivot(listing, axes) {
|
|
|
53
53
|
setState({ status: "failed", crossed: [], columns: [], error });
|
|
54
54
|
});
|
|
55
55
|
return () => aborter.abort();
|
|
56
|
-
}, [transport, listing.route, question, shape, sums, waiting]);
|
|
56
|
+
}, [transport, listing.route, question, shape, sums, waiting, context]);
|
|
57
57
|
return { ...state, measures };
|
|
58
58
|
}
|
package/dist/react/useRecord.js
CHANGED
|
@@ -7,7 +7,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
|
7
7
|
/** How long typing has to pause before the server is asked what the record becomes. */
|
|
8
8
|
const PREVIEW_PAUSE = 300;
|
|
9
9
|
export function useRecord(entity, opened) {
|
|
10
|
-
const { transport, locale, metas } = useFramework();
|
|
10
|
+
const { transport, locale, metas, context } = useFramework();
|
|
11
11
|
const given = typeof opened === "string" ? opened : (opened.id ?? "");
|
|
12
12
|
// As written in the reference: a text compares by value, so a new render with the same
|
|
13
13
|
// reference is not a new start.
|
|
@@ -33,6 +33,8 @@ export function useRecord(entity, opened) {
|
|
|
33
33
|
const [readFor, setReadFor] = useState(null);
|
|
34
34
|
const [round, setRound] = useState(0);
|
|
35
35
|
const [typed, setTyped] = useState({});
|
|
36
|
+
const typedNow = useRef(typed);
|
|
37
|
+
typedNow.current = typed;
|
|
36
38
|
const [computed, setComputed] = useState({});
|
|
37
39
|
const [fromServer, setFromServer] = useState({});
|
|
38
40
|
const [advice, setAdvice] = useState([]);
|
|
@@ -136,6 +138,16 @@ export function useRecord(entity, opened) {
|
|
|
136
138
|
};
|
|
137
139
|
}, []);
|
|
138
140
|
const reload = useCallback(() => setRound((n) => n + 1), []);
|
|
141
|
+
// Another company (the process's context changed): a record with nothing typed reads again;
|
|
142
|
+
// one being edited keeps what was typed — losing it is never the framework's decision.
|
|
143
|
+
const askedIn = useRef(context);
|
|
144
|
+
useEffect(() => {
|
|
145
|
+
if (askedIn.current === context)
|
|
146
|
+
return;
|
|
147
|
+
askedIn.current = context;
|
|
148
|
+
if (Object.keys(typedNow.current).length === 0)
|
|
149
|
+
reload();
|
|
150
|
+
}, [context, reload]);
|
|
139
151
|
const record = useMemo(() => (state.record ?? {}), [state.record]);
|
|
140
152
|
const values = useMemo(() => ({ ...record, ...computed, ...typed }), [record, computed, typed]);
|
|
141
153
|
const changed = useMemo(() => changesOf(record, typed), [record, typed]);
|
|
@@ -234,7 +246,10 @@ export function useRecord(entity, opened) {
|
|
|
234
246
|
changed,
|
|
235
247
|
dirty: Object.keys(changed).length > 0,
|
|
236
248
|
set: (name, value) => {
|
|
237
|
-
|
|
249
|
+
// Over what was typed last, not this render's: two fields set in one gesture (a key and
|
|
250
|
+
// the record held beside it) both land.
|
|
251
|
+
const next = { ...typedNow.current, [name]: value };
|
|
252
|
+
typedNow.current = next;
|
|
238
253
|
setTyped(next);
|
|
239
254
|
ask(next, name);
|
|
240
255
|
},
|
package/dist/web/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export { cardOf, relationOf } from "./record/summary.js";
|
|
|
23
23
|
export { Refused } from "./Refused.js";
|
|
24
24
|
export { entityView, type EntityViewOptions, listView, type ListViewOptions, } from "./workspace/composer.js";
|
|
25
25
|
export { openIn, openOptions, RECORD_SIZE, RelatedRecord, targetsFor, } from "./workspace/open.js";
|
|
26
|
-
export { EntityRecord } from "./workspace/record.js";
|
|
26
|
+
export { EntityRecord, type Stamp, useRecordScreen, } from "./workspace/record.js";
|
|
27
27
|
export { SincproApp } from "./workspace/SincproApp.js";
|
|
28
28
|
export { webUiSkin } from "./workspace/skin.js";
|
|
29
29
|
export { chooserIn, useFollowed, useRecordInWorkspace, } from "./workspace/workspace.js";
|
package/dist/web/index.js
CHANGED
|
@@ -23,7 +23,7 @@ export { cardOf, relationOf } from "./record/summary.js";
|
|
|
23
23
|
export { Refused } from "./Refused.js";
|
|
24
24
|
export { entityView, listView, } from "./workspace/composer.js";
|
|
25
25
|
export { openIn, openOptions, RECORD_SIZE, RelatedRecord, targetsFor, } from "./workspace/open.js";
|
|
26
|
-
export { EntityRecord } from "./workspace/record.js";
|
|
26
|
+
export { EntityRecord, useRecordScreen, } from "./workspace/record.js";
|
|
27
27
|
export { SincproApp } from "./workspace/SincproApp.js";
|
|
28
28
|
export { webUiSkin } from "./workspace/skin.js";
|
|
29
29
|
export { chooserIn, useFollowed, useRecordInWorkspace, } from "./workspace/workspace.js";
|
|
@@ -32,9 +32,9 @@ import { type OpenTarget } from "@sincpro/web-ui";
|
|
|
32
32
|
* way to the server's literal search. The chooser is a table — the columns the list declares,
|
|
33
33
|
* or `columns` — searched by the entity's literal search on the server.
|
|
34
34
|
*
|
|
35
|
-
* A field that may stay empty
|
|
36
|
-
*
|
|
37
|
-
*
|
|
35
|
+
* A field that may stay empty says so with `onClear`: a × beside the chosen name, or the name
|
|
36
|
+
* erased and the field left (web-ui's `Picker onClear`). Where the empty choice has a word of its
|
|
37
|
+
* own («Sin tenant»), `none` also offers it as the first option, answered as `""`. `exclude` leaves keys out of the choices — the
|
|
38
38
|
* tenants a project is already shared with —, in the picker and its chooser, and the SERVER
|
|
39
39
|
* leaves them out (`useLookup exclude`).
|
|
40
40
|
*
|
|
@@ -42,7 +42,7 @@ import { type OpenTarget } from "@sincpro/web-ui";
|
|
|
42
42
|
* <EntityPicker entity={activeCustomers} columns={["name", "tax_id", "city"]} … />
|
|
43
43
|
* <EntityPicker entity={tenants} none="Sin tenant" exclude={sharedWith} … />
|
|
44
44
|
*/
|
|
45
|
-
export declare function EntityPicker<T extends AnyRecord>({ entity, value, onChange, onOpen, openTargets, onBrowseAll, ownChooser, criteria, columns, browse, none, exclude, placeholder, disabled, "aria-label": ariaLabel, }: {
|
|
45
|
+
export declare function EntityPicker<T extends AnyRecord>({ entity, value, onChange, onOpen, openTargets, onBrowseAll, ownChooser, criteria, columns, browse, none, onClear, exclude, placeholder, disabled, "aria-label": ariaLabel, }: {
|
|
46
46
|
/** What is chosen from: an entity, or a named list of it (its cut, columns and title). */
|
|
47
47
|
entity: Entity<T> | ListDefinition<T>;
|
|
48
48
|
/** The chooser's columns. Without it, the named list's, or every scalar field. */
|
|
@@ -54,6 +54,9 @@ export declare function EntityPicker<T extends AnyRecord>({ entity, value, onCha
|
|
|
54
54
|
/** The field may stay empty: a first choice that answers `""` — `true` says «Ninguno», a
|
|
55
55
|
* text is the screen's own word for it. */
|
|
56
56
|
none?: boolean | string;
|
|
57
|
+
/** The choice can be removed: a × beside it, and erasing the name and leaving the field
|
|
58
|
+
* (web-ui's `Picker onClear`). A field that is not required passes it. */
|
|
59
|
+
onClear?: () => void;
|
|
57
60
|
/** Keys never offered — those already chosen elsewhere. Left out by the server. */
|
|
58
61
|
exclude?: readonly string[];
|
|
59
62
|
value?: string;
|
|
@@ -43,9 +43,9 @@ import { useState } from "react";
|
|
|
43
43
|
* way to the server's literal search. The chooser is a table — the columns the list declares,
|
|
44
44
|
* or `columns` — searched by the entity's literal search on the server.
|
|
45
45
|
*
|
|
46
|
-
* A field that may stay empty
|
|
47
|
-
*
|
|
48
|
-
*
|
|
46
|
+
* A field that may stay empty says so with `onClear`: a × beside the chosen name, or the name
|
|
47
|
+
* erased and the field left (web-ui's `Picker onClear`). Where the empty choice has a word of its
|
|
48
|
+
* own («Sin tenant»), `none` also offers it as the first option, answered as `""`. `exclude` leaves keys out of the choices — the
|
|
49
49
|
* tenants a project is already shared with —, in the picker and its chooser, and the SERVER
|
|
50
50
|
* leaves them out (`useLookup exclude`).
|
|
51
51
|
*
|
|
@@ -53,7 +53,7 @@ import { useState } from "react";
|
|
|
53
53
|
* <EntityPicker entity={activeCustomers} columns={["name", "tax_id", "city"]} … />
|
|
54
54
|
* <EntityPicker entity={tenants} none="Sin tenant" exclude={sharedWith} … />
|
|
55
55
|
*/
|
|
56
|
-
export function EntityPicker({ entity, value, onChange, onOpen, openTargets, onBrowseAll, ownChooser = false, criteria, columns, browse = true, none, exclude, placeholder, disabled, "aria-label": ariaLabel, }) {
|
|
56
|
+
export function EntityPicker({ entity, value, onChange, onOpen, openTargets, onBrowseAll, ownChooser = false, criteria, columns, browse = true, none, onClear, exclude, placeholder, disabled, "aria-label": ariaLabel, }) {
|
|
57
57
|
const base = isList(entity) ? entity.entity : entity;
|
|
58
58
|
const { metas } = useFramework();
|
|
59
59
|
const opening = useRecordOpening();
|
|
@@ -101,7 +101,7 @@ export function EntityPicker({ entity, value, onChange, onOpen, openTargets, onB
|
|
|
101
101
|
: look(lookup.chosen.record).name) ?? lookup.chosen.label,
|
|
102
102
|
}), onChange: (id) => onChange(id, lookup.options.find((one) => one.id === id)?.record), ...(lookup.searchable ? { onSearch: lookup.search } : {}),
|
|
103
103
|
// «Loading» only before there is anything: refining keeps the ten on screen.
|
|
104
|
-
loading: lookup.loading && lookup.options.length === 0, ...(opens === undefined || value === "" ? {} : { onOpen: opens }), ...(targets === undefined ? {} : { openTargets: targets }), onBrowseAll: browseAll, ...(placeholder === undefined ? {} : { placeholder }), ...(disabled === undefined ? {} : { disabled }), ...(ariaLabel === undefined ? {} : { "aria-label": ariaLabel }) }));
|
|
104
|
+
loading: lookup.loading && lookup.options.length === 0, ...(onClear === undefined || disabled === true ? {} : { onClear }), ...(opens === undefined || value === "" ? {} : { onOpen: opens }), ...(targets === undefined ? {} : { openTargets: targets }), onBrowseAll: browseAll, ...(placeholder === undefined ? {} : { placeholder }), ...(disabled === undefined ? {} : { disabled }), ...(ariaLabel === undefined ? {} : { "aria-label": ariaLabel }) }));
|
|
105
105
|
return (_jsxs(_Fragment, { children: [browse ? (_jsxs("span", { className: "flex min-w-0 items-start gap-1", children: [_jsx("span", { className: "min-w-0 flex-1", children: picker }), _jsx(IconButton, { icon: TextSearch, label: frameworkCopy().picker.browse, onClick: () => browseAll(lookup.text), ...(disabled === undefined ? {} : { disabled }) })] })) : (picker), choosing ? (_jsx(Chooser, { entity: entity, ...(columns === undefined ? {} : { columns }), ...(scope === undefined ? {} : { criteria: scope }), onChoose: (id, row) => {
|
|
106
106
|
onChange(id, row);
|
|
107
107
|
setChoosing(false);
|
|
@@ -32,12 +32,14 @@ export declare function controlFor(control: FieldControl, type: string, exact: b
|
|
|
32
32
|
* workspace's chooser (`RecordLinesEditor`), so «Buscar más…» is the picker's own there;
|
|
33
33
|
* `ownChooser` asks for it anywhere else.
|
|
34
34
|
*/
|
|
35
|
-
export declare function RelationPicker({ target, value, onChange, label, ownChooser, standalone, }: {
|
|
35
|
+
export declare function RelationPicker({ target, value, onChange, label, ownChooser, standalone, onClear, }: {
|
|
36
36
|
target: Entity;
|
|
37
37
|
value: string;
|
|
38
38
|
onChange: (id: string, chosen?: AnyRecord) => void;
|
|
39
39
|
label: string;
|
|
40
40
|
ownChooser?: boolean;
|
|
41
|
+
/** The choice can be removed — a field that is not required. */
|
|
42
|
+
onClear?: () => void;
|
|
41
43
|
/** No `Field` names it (a cell): it carries `label` itself — as `FieldControl.standalone`. */
|
|
42
44
|
standalone?: boolean;
|
|
43
45
|
}): import("react").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { instantOf, timeZoneNow, wallTimeOf } from "@sincpro/client-framework";
|
|
3
|
+
import { dayOf, instantOf, timeZoneNow, wallTimeOf, } from "@sincpro/client-framework";
|
|
4
4
|
import { EntityPicker } from "./EntityPicker.js";
|
|
5
5
|
import { Checkbox, DatePicker, DateTimePicker, NumberInput, Select, TagsField, TextInput, } from "@sincpro/web-ui";
|
|
6
6
|
/**
|
|
@@ -28,8 +28,11 @@ export function controlFor(control, type, exact, choices) {
|
|
|
28
28
|
const zone = timeZoneNow();
|
|
29
29
|
return (_jsx(DateTimePicker, { value: typeof value === "string" && value !== "" ? wallTimeOf(value, zone) : null, onChange: (wall) => set(wall === null ? null : instantOf(wall, zone)), ...named }));
|
|
30
30
|
}
|
|
31
|
-
case "date":
|
|
32
|
-
|
|
31
|
+
case "date": {
|
|
32
|
+
// «Today» is the business's day, on the installed zone — never the browser's.
|
|
33
|
+
const today = dayOf(new Date().toISOString(), timeZoneNow());
|
|
34
|
+
return (_jsx(DatePicker, { ...(today === null ? {} : { today }), value: typeof value === "string" && value !== "" ? value : null, onChange: set, ...named }));
|
|
35
|
+
}
|
|
33
36
|
case "text[]": {
|
|
34
37
|
// A list of words is chips: each word is its own key, and typing a new one adds it.
|
|
35
38
|
const words = Array.isArray(value) ? value.map(String) : [];
|
|
@@ -48,10 +51,10 @@ export function controlFor(control, type, exact, choices) {
|
|
|
48
51
|
* workspace's chooser (`RecordLinesEditor`), so «Buscar más…» is the picker's own there;
|
|
49
52
|
* `ownChooser` asks for it anywhere else.
|
|
50
53
|
*/
|
|
51
|
-
export function RelationPicker({ target, value, onChange, label, ownChooser = false, standalone = false, }) {
|
|
54
|
+
export function RelationPicker({ target, value, onChange, label, ownChooser = false, standalone = false, onClear, }) {
|
|
52
55
|
// Opening the chosen record and «Buscar más…» are the workspace's when there is one: the
|
|
53
56
|
// picker reads it (`RecordOpening`); a line keeps its own chooser.
|
|
54
57
|
return (_jsx(EntityPicker, { entity: target, value: value, onChange: onChange,
|
|
55
58
|
// «Buscar más…» is an option of the picker already: no second button beside it.
|
|
56
|
-
browse: false, ownChooser: ownChooser, ...(standalone ? { "aria-label": label } : {}) }));
|
|
59
|
+
browse: false, ownChooser: ownChooser, ...(onClear === undefined ? {} : { onClear }), ...(standalone ? { "aria-label": label } : {}) }));
|
|
57
60
|
}
|
package/dist/web/record/edit.js
CHANGED
|
@@ -63,6 +63,17 @@ export function RecordField({ record, name, as, bare = false, lines: look, list:
|
|
|
63
63
|
// A one2many of no declared entity (the lines of an invoice): edited inside the record as a
|
|
64
64
|
// whole list (`RecordLinesEditor`) — or, when the record brought only a page, that page read
|
|
65
65
|
// only with its real total.
|
|
66
|
+
// A list of values inside the record (`field.embedded(definition, { many: true })`: a
|
|
67
|
+
// project's channels, an inventory's components) — no model of its own, no id — is edited the
|
|
68
|
+
// same way as lines: a whole list, local keys, through the record's own save.
|
|
69
|
+
const own = meta?.fields[name];
|
|
70
|
+
if (as === undefined && own?.type === "embedded" && own.many === true && own.definition) {
|
|
71
|
+
// A page of them stays read only, as a one2many's: written back whole it would drop what
|
|
72
|
+
// it did not bring.
|
|
73
|
+
const whole = editableLines(edit.values[name]);
|
|
74
|
+
const lines = whole === null ? (_jsx(RecordLines, { record: record.record ?? {}, meta: meta, name: name, locale: locale })) : (_jsx(RecordLinesEditor, { record: record, name: name, lines: whole, ...(look === undefined ? {} : { look }) }));
|
|
75
|
+
return bare ? lines : _jsx(FormSection, { title: view.label, children: lines });
|
|
76
|
+
}
|
|
66
77
|
if (as === undefined && relation?.field.type === "one2many" && target === undefined) {
|
|
67
78
|
// Editable when the record holds ALL its lines; a page of them stays read only.
|
|
68
79
|
const whole = editableLines(edit.values[name]);
|
|
@@ -119,7 +130,15 @@ export function RecordField({ record, name, as, bare = false, lines: look, list:
|
|
|
119
130
|
return _jsx(KeyValue, { target: target, id: id, ...opens });
|
|
120
131
|
return (_jsx(RelationValue, { name: textOf(meta, relation.relation, edit.values[relation.relation], locale) ?? id, ...opens }));
|
|
121
132
|
}
|
|
122
|
-
return (_jsx(RelationPicker, { target: target, value: id, onChange: (next) => edit.set(relation.key, next), label: view.label
|
|
133
|
+
return (_jsx(RelationPicker, { target: target, value: id, onChange: (next) => edit.set(relation.key, next), label: view.label, ...(state.required || edit.state(relation.key).required
|
|
134
|
+
? {}
|
|
135
|
+
: {
|
|
136
|
+
onClear: () => {
|
|
137
|
+
edit.set(relation.key, null);
|
|
138
|
+
if (relation.held)
|
|
139
|
+
edit.set(relation.relation, null);
|
|
140
|
+
},
|
|
141
|
+
}) }));
|
|
123
142
|
}
|
|
124
143
|
if (view.type === "boolean" && as === undefined)
|
|
125
144
|
return (_jsx(Checkbox, { checked: value === true, onChange: control.set, label: view.label, disabled: state.readonly }));
|
package/dist/web/record/lines.js
CHANGED
|
@@ -48,7 +48,14 @@ function LineValue({ definition, field, line, set, label, invalid, locale, inCel
|
|
|
48
48
|
// would put the record IN the key.
|
|
49
49
|
write(relation.held
|
|
50
50
|
? { [relation.key]: id, [relation.relation]: chosen ?? null }
|
|
51
|
-
: { [relation.key]: id })
|
|
51
|
+
: { [relation.key]: id }), ...(definition?.fields[relation.key]?.required === true ||
|
|
52
|
+
definition?.fields[relation.key]?.required_when !== undefined
|
|
53
|
+
? {}
|
|
54
|
+
: {
|
|
55
|
+
onClear: () => write(relation.held
|
|
56
|
+
? { [relation.key]: null, [relation.relation]: null }
|
|
57
|
+
: { [relation.key]: null }),
|
|
58
|
+
}) }));
|
|
52
59
|
}
|
|
53
60
|
return controlFor({
|
|
54
61
|
value: line[field],
|
|
@@ -92,7 +99,11 @@ export function RecordLinesEditor({ record, name, lines, look = {}, }) {
|
|
|
92
99
|
const { entities, metas } = useFramework();
|
|
93
100
|
const opening = useRecordOpening();
|
|
94
101
|
const definition = meta?.fields[name]?.definition ?? null;
|
|
95
|
-
|
|
102
|
+
// A value inside the record (an embedded list) has no identity of its own: every line is
|
|
103
|
+
// keyed locally — falling back to `id` would key it by whatever it holds under that name.
|
|
104
|
+
const identity = meta?.fields[name]?.type === "embedded"
|
|
105
|
+
? (definition?.identity ?? "")
|
|
106
|
+
: definition?.identity || "id";
|
|
96
107
|
const fields = lineFields(definition);
|
|
97
108
|
const shown = look.columns === undefined ? fields : look.columns.filter((one) => fields.includes(one));
|
|
98
109
|
const controls = look.controls ?? {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AnyRecord, type Meta } from "@sincpro/criteria";
|
|
2
|
-
import { type SheetField } from "@sincpro/web-ui";
|
|
2
|
+
import { type RowAction, type SheetField } from "@sincpro/web-ui";
|
|
3
3
|
import type { ReactNode } from "react";
|
|
4
4
|
export declare function factsOf<T extends AnyRecord>(record: T, meta: Meta | null | undefined, names: readonly string[], options?: {
|
|
5
5
|
locale?: string | undefined;
|
|
@@ -13,8 +13,16 @@ export declare function countOf(record: AnyRecord, name: string): number;
|
|
|
13
13
|
* Its columns come from the relation's own definition when the server expanded it, and are
|
|
14
14
|
* read off the rows otherwise. When the record brought only one page of them, it says so —
|
|
15
15
|
* «se muestran 50 de 1000» — instead of drawing 50 as if they were all.
|
|
16
|
+
*
|
|
17
|
+
* `rowActions` acts on a part from its row — a group's member, a project's share — with a
|
|
18
|
+
* Command of the record (`useCommand(projects, "unshareProject")`): the parts have no route of
|
|
19
|
+
* their own, so what removes one is the record's, and the screen names it.
|
|
20
|
+
*
|
|
21
|
+
* <RecordLines record={project} meta={meta} name="shares"
|
|
22
|
+
* rowActions={(share) => [{ id: "unshare", label: "Quitar", icon: X, tone: "danger",
|
|
23
|
+
* onSelect: () => unshare.run(project.id, { tenant_id: share.tenant_id }) }]} />
|
|
16
24
|
*/
|
|
17
|
-
export declare function RecordLines<T extends AnyRecord>({ record, meta, name, columns, cells, locale, onOpen, }: {
|
|
25
|
+
export declare function RecordLines<T extends AnyRecord>({ record, meta, name, columns, cells, locale, onOpen, rowActions, }: {
|
|
18
26
|
record: AnyRecord;
|
|
19
27
|
meta: Meta | null | undefined;
|
|
20
28
|
name: string;
|
|
@@ -22,4 +30,6 @@ export declare function RecordLines<T extends AnyRecord>({ record, meta, name, c
|
|
|
22
30
|
cells?: Readonly<Partial<Record<string, (row: T) => ReactNode>>>;
|
|
23
31
|
locale?: string | undefined;
|
|
24
32
|
onOpen?: (row: T) => void;
|
|
33
|
+
/** What a row's part can be acted on with — a Command of the record. */
|
|
34
|
+
rowActions?: (row: T) => readonly RowAction[];
|
|
25
35
|
}): import("react").JSX.Element;
|
|
@@ -46,11 +46,19 @@ export function countOf(record, name) {
|
|
|
46
46
|
* Its columns come from the relation's own definition when the server expanded it, and are
|
|
47
47
|
* read off the rows otherwise. When the record brought only one page of them, it says so —
|
|
48
48
|
* «se muestran 50 de 1000» — instead of drawing 50 as if they were all.
|
|
49
|
+
*
|
|
50
|
+
* `rowActions` acts on a part from its row — a group's member, a project's share — with a
|
|
51
|
+
* Command of the record (`useCommand(projects, "unshareProject")`): the parts have no route of
|
|
52
|
+
* their own, so what removes one is the record's, and the screen names it.
|
|
53
|
+
*
|
|
54
|
+
* <RecordLines record={project} meta={meta} name="shares"
|
|
55
|
+
* rowActions={(share) => [{ id: "unshare", label: "Quitar", icon: X, tone: "danger",
|
|
56
|
+
* onSelect: () => unshare.run(project.id, { tenant_id: share.tenant_id }) }]} />
|
|
49
57
|
*/
|
|
50
|
-
export function RecordLines({ record, meta, name, columns, cells, locale, onOpen, }) {
|
|
58
|
+
export function RecordLines({ record, meta, name, columns, cells, locale, onOpen, rowActions, }) {
|
|
51
59
|
const related = relatedOf(record[name]);
|
|
52
60
|
const definition = meta?.fields[name]?.definition ?? describeRows(related.items);
|
|
53
61
|
const identity = definition.identity || "id";
|
|
54
62
|
const copy = frameworkCopy();
|
|
55
|
-
return (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(List, { embedded: true, items: related.items, keyOf: (row) => String(row[identity]), present: "table", empty: { sentence: copy.list.empty }, ...(onOpen === undefined ? {} : { onOpen }), children: _jsx(List.Table, { columns: columnsOf(definition, columns, { locale, ...(cells ? { cells } : {}) }) }) }), related.partial ? (_jsx("p", { className: "text-meta text-muted", children: copy.record.partial(related.items.length, related.count.value) })) : null] }));
|
|
63
|
+
return (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(List, { embedded: true, items: related.items, keyOf: (row) => String(row[identity]), present: "table", empty: { sentence: copy.list.empty }, ...(onOpen === undefined ? {} : { onOpen }), children: _jsx(List.Table, { columns: columnsOf(definition, columns, { locale, ...(cells ? { cells } : {}) }), ...(rowActions === undefined ? {} : { rowActions }) }) }), related.partial ? (_jsx("p", { className: "text-meta text-muted", children: copy.record.partial(related.items.length, related.count.value) })) : null] }));
|
|
56
64
|
}
|
|
@@ -1,25 +1,9 @@
|
|
|
1
1
|
import { type Entity, type Transport } from "@sincpro/client-framework";
|
|
2
2
|
import type { Meta } from "@sincpro/criteria";
|
|
3
|
-
import { type ComposerSkin, type ResourceRef, type ViewSpec, type WorkspaceStore } from "@sincpro/web-composer";
|
|
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
5
|
import { type ReactNode } from "react";
|
|
6
|
-
|
|
7
|
-
* The application context in one place: who answers (the transport), in which language, which
|
|
8
|
-
* model definitions are already known, the toasts, and the workspace with its views, ⌘K and
|
|
9
|
-
* shortcuts.
|
|
10
|
-
*
|
|
11
|
-
* Context: forge's `main.tsx` + `console.tsx` installed three copy tables, a toast provider, a
|
|
12
|
-
* context of its own and a composer by hand. This is that, once. It is a convenience, not the
|
|
13
|
-
* only door: everything it mounts is exported, and an app with its own shell mounts them itself.
|
|
14
|
-
* What it does NOT own: the session (the app builds the transport with its headers) and what the
|
|
15
|
-
* application bar says. The bar is the app's (`bar`), drawn above the workspace inside every
|
|
16
|
-
* provider; a menu in it opens views through the workspace the app holds (`workspace`, from
|
|
17
|
-
* composer's `useWorkspace()`) — a workspace owned in here could not be reached from outside.
|
|
18
|
-
*
|
|
19
|
-
* const workspace = useWorkspace();
|
|
20
|
-
* <SincproApp workspace={workspace} bar={<Menu onOpen={(ref) => workspace.push(ref)} />} … />
|
|
21
|
-
*/
|
|
22
|
-
export declare function SincproApp({ transport, views, start, language, metas, entities, empty, skin, cache, timeZone, workspace: given, bar, }: {
|
|
6
|
+
export declare function SincproApp({ transport, views, start, language, metas, entities, empty, skin, cache, timeZone, workspace: given, bar, onViewError, }: {
|
|
23
7
|
transport: Transport;
|
|
24
8
|
/** The entities as composer views — `entityView(…)` — and any other view of the app. */
|
|
25
9
|
views: readonly ViewSpec[];
|
|
@@ -50,4 +34,10 @@ export declare function SincproApp({ transport, views, start, language, metas, e
|
|
|
50
34
|
/** The application's bar, above the workspace and inside the providers: its menus may read
|
|
51
35
|
* the framework (`useFramework`) and open views through `workspace`. */
|
|
52
36
|
bar?: ReactNode;
|
|
37
|
+
/**
|
|
38
|
+
* Told when a view breaks while drawing. By default it reaches the process's error reporter
|
|
39
|
+
* (`reportError`, @sincpro/client-framework) — the one the use cases report to — as
|
|
40
|
+
* `view <ref>`; without a reporter configured, nothing is sent.
|
|
41
|
+
*/
|
|
42
|
+
onViewError?: OnViewError;
|
|
53
43
|
}): import("react").JSX.Element;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {} from "@sincpro/client-framework";
|
|
3
|
+
import { processContext, reportError, } from "@sincpro/client-framework";
|
|
4
4
|
import { Composer, installComposerCopy, SPANISH_COMPOSER_COPY, useWorkspace, } from "@sincpro/web-composer";
|
|
5
|
-
import { createRegistry } from "@sincpro/web-composer/domain";
|
|
6
|
-
import { cachedTransport } from "../../core/cache.js";
|
|
5
|
+
import { createRegistry, formatRef } from "@sincpro/web-composer/domain";
|
|
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";
|
|
@@ -25,7 +25,9 @@ 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
|
-
|
|
28
|
+
/** A view that broke while drawing, told to the process's error reporter: `view <ref>`. */
|
|
29
|
+
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, }) {
|
|
29
31
|
// Installed once, before anything draws: the three tables are module state of their packages.
|
|
30
32
|
useState(() => {
|
|
31
33
|
if (language === "es") {
|
|
@@ -44,6 +46,16 @@ export function SincproApp({ transport, views, start, language = "es", metas, en
|
|
|
44
46
|
// The options are read once: a cache that changes shape mid-session forgets everything.
|
|
45
47
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
48
|
[transport]);
|
|
49
|
+
// What was read in one company is not the other's: a change of context forgets every answer
|
|
50
|
+
// before the screens read again (`FrameworkProvider` gives them another transport).
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (cache === false)
|
|
53
|
+
return;
|
|
54
|
+
const forgetting = cached;
|
|
55
|
+
return processContext.watch(() => forgetting.invalidate());
|
|
56
|
+
// The cache is read once, as `cached` is.
|
|
57
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
58
|
+
}, [cached]);
|
|
47
59
|
const own = useWorkspace();
|
|
48
60
|
const workspace = given ?? own;
|
|
49
61
|
const registry = useMemo(() => createRegistry(views), [views]);
|
|
@@ -53,5 +65,5 @@ export function SincproApp({ transport, views, start, language = "es", metas, en
|
|
|
53
65
|
// The first screen only: a re-render must not push it again.
|
|
54
66
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
55
67
|
}, [workspace]);
|
|
56
|
-
return (_jsx(FrameworkProvider, { transport: cached, locale: language, ...(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, ...(empty === undefined ? {} : { empty }) }) })] }) }) }));
|
|
68
|
+
return (_jsx(FrameworkProvider, { transport: cached, locale: language, ...(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 }) }) })] }) }) }));
|
|
57
69
|
}
|
|
@@ -3,22 +3,69 @@ import type { AnyRecord } from "@sincpro/criteria";
|
|
|
3
3
|
import { type ViewProps } from "@sincpro/web-composer";
|
|
4
4
|
import { type RecordReading } from "../../react/useRecord.js";
|
|
5
5
|
import { type ReactNode } from "react";
|
|
6
|
+
/** Who made a record, or changed it last, and when: `Record.Audit`'s. */
|
|
7
|
+
export type Stamp = {
|
|
8
|
+
at: string;
|
|
9
|
+
by?: string;
|
|
10
|
+
};
|
|
6
11
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
12
|
+
* What every record screen in a workspace does before drawing its own — what `EntityRecord`
|
|
13
|
+
* does, as values: read the record for editing, follow the workspace's breadcrumb, tell the
|
|
14
|
+
* workspace its name and its unsaved work, read its history, step to its neighbours in the list
|
|
15
|
+
* it was opened from, and say its name, state, unsaved work, refusal and authorship the way
|
|
16
|
+
* web-ui's `Record` takes them.
|
|
9
17
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
18
|
+
* function InvoiceScreen(props: ViewProps) {
|
|
19
|
+
* const screen = useRecordScreen(invoices, props);
|
|
20
|
+
* if (screen.reading.status !== "ready") return <Skeleton rows={6} />;
|
|
21
|
+
* return (
|
|
22
|
+
* <Record {...screen.record}>
|
|
23
|
+
* <Record.Rail>
|
|
24
|
+
* <Record.Crumbs crumbs={screen.crumbs} />
|
|
25
|
+
* {screen.pager ? <Record.Pager {...screen.pager} /> : null}
|
|
26
|
+
* </Record.Rail>
|
|
27
|
+
* <Record.Paper>…your own fields…</Record.Paper>
|
|
28
|
+
* </Record>
|
|
29
|
+
* );
|
|
30
|
+
* }
|
|
16
31
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
32
|
+
* Context: the level between `EntityRecord` and `useRecord` — a screen of its own keeps every
|
|
33
|
+
* behaviour of the framework's record and writes its own tree. It answers PROPS, never
|
|
34
|
+
* components: web-ui finds a record's regions by type (`Record.Crumbs` a direct child of
|
|
35
|
+
* `Record.Rail`), and a region wrapped in one of ours is not found. Before it, forge's console
|
|
36
|
+
* carried these 150 lines itself (`shared/record_screen.tsx`).
|
|
21
37
|
*/
|
|
38
|
+
export declare function useRecordScreen<T extends AnyRecord>(entity: Entity<T>, { api, resource }: Pick<ViewProps, "api" | "resource">): {
|
|
39
|
+
reading: RecordReading<T>;
|
|
40
|
+
crumbs: readonly import("@sincpro/web-composer").Crumb[];
|
|
41
|
+
history: import("../../index.js").HistoryEntry[] | undefined;
|
|
42
|
+
summary: import("../../index.js").RecordSummary | undefined;
|
|
43
|
+
/** web-ui `Record`'s own props: where it is drawn, its name, its unsaved work, its refusal. */
|
|
44
|
+
record: {
|
|
45
|
+
error?: string | undefined;
|
|
46
|
+
dirty?: import("@sincpro/web-ui").DirtyState | undefined;
|
|
47
|
+
placement: "page" | "card";
|
|
48
|
+
identity: {
|
|
49
|
+
tag?: {
|
|
50
|
+
label: string;
|
|
51
|
+
} | undefined;
|
|
52
|
+
subtitle?: string | undefined;
|
|
53
|
+
title: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
/** `Record.Pager`'s props, when it was opened from a list and nothing is typed. */
|
|
57
|
+
pager: {
|
|
58
|
+
index: number;
|
|
59
|
+
total: number;
|
|
60
|
+
onPrev: () => void;
|
|
61
|
+
onNext: () => void;
|
|
62
|
+
} | undefined;
|
|
63
|
+
/** `Record.Audit`'s props, when the record says who made it or changed it. */
|
|
64
|
+
audit: {
|
|
65
|
+
updated?: Stamp | undefined;
|
|
66
|
+
created?: Stamp | undefined;
|
|
67
|
+
} | undefined;
|
|
68
|
+
};
|
|
22
69
|
export declare function EntityRecord<T extends AnyRecord>({ api, resource, entity, fields, pages, actions, }: ViewProps & {
|
|
23
70
|
entity: Entity<T>;
|
|
24
71
|
/** The fields, in this order. Without it, the model's (`formOf`). */
|
|
@@ -4,6 +4,7 @@ import { TRAIL_PARAM } from "@sincpro/client-framework";
|
|
|
4
4
|
import { labelOf, nameOf } from "@sincpro/criteria";
|
|
5
5
|
import { useCrumbs } from "@sincpro/web-composer";
|
|
6
6
|
import { frameworkCopy } from "../../core/copy.js";
|
|
7
|
+
import { explain } from "../../core/explain.js";
|
|
7
8
|
import { formOf } from "../../core/form.js";
|
|
8
9
|
import { placeOf, stepIn } from "../../core/trail.js";
|
|
9
10
|
import { useFramework } from "../../react/context.js";
|
|
@@ -31,13 +32,44 @@ import { useState } from "react";
|
|
|
31
32
|
* <EntityRecord {...props} entity={invoices} fields={["customer_id", "due_date"]}
|
|
32
33
|
* actions={(invoice) => <CommandButton entity={invoices} command="post" … />} /> })
|
|
33
34
|
*/
|
|
34
|
-
|
|
35
|
+
/** A save's refusal as a sentence — its heading when the server gave no detail. */
|
|
36
|
+
function refusalOf(failure) {
|
|
37
|
+
const said = explain(failure);
|
|
38
|
+
return said.sentence || said.heading;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* What every record screen in a workspace does before drawing its own — what `EntityRecord`
|
|
42
|
+
* does, as values: read the record for editing, follow the workspace's breadcrumb, tell the
|
|
43
|
+
* workspace its name and its unsaved work, read its history, step to its neighbours in the list
|
|
44
|
+
* it was opened from, and say its name, state, unsaved work, refusal and authorship the way
|
|
45
|
+
* web-ui's `Record` takes them.
|
|
46
|
+
*
|
|
47
|
+
* function InvoiceScreen(props: ViewProps) {
|
|
48
|
+
* const screen = useRecordScreen(invoices, props);
|
|
49
|
+
* if (screen.reading.status !== "ready") return <Skeleton rows={6} />;
|
|
50
|
+
* return (
|
|
51
|
+
* <Record {...screen.record}>
|
|
52
|
+
* <Record.Rail>
|
|
53
|
+
* <Record.Crumbs crumbs={screen.crumbs} />
|
|
54
|
+
* {screen.pager ? <Record.Pager {...screen.pager} /> : null}
|
|
55
|
+
* </Record.Rail>
|
|
56
|
+
* <Record.Paper>…your own fields…</Record.Paper>
|
|
57
|
+
* </Record>
|
|
58
|
+
* );
|
|
59
|
+
* }
|
|
60
|
+
*
|
|
61
|
+
* Context: the level between `EntityRecord` and `useRecord` — a screen of its own keeps every
|
|
62
|
+
* behaviour of the framework's record and writes its own tree. It answers PROPS, never
|
|
63
|
+
* components: web-ui finds a record's regions by type (`Record.Crumbs` a direct child of
|
|
64
|
+
* `Record.Rail`), and a region wrapped in one of ours is not found. Before it, forge's console
|
|
65
|
+
* carried these 150 lines itself (`shared/record_screen.tsx`).
|
|
66
|
+
*/
|
|
67
|
+
export function useRecordScreen(entity, { api, resource }) {
|
|
35
68
|
const reading = useRecord(entity, resource);
|
|
36
69
|
const crumbs = useCrumbs(api);
|
|
37
70
|
useRecordInWorkspace(api, reading);
|
|
38
71
|
const history = useHistory(entity, reading.isNew ? "" : reading.id, [reading.record]);
|
|
39
72
|
const summarize = useSummaryOf(entity);
|
|
40
|
-
const [page, setPage] = useState(undefined);
|
|
41
73
|
const copy = frameworkCopy().record;
|
|
42
74
|
// Opened from a list: where it stands in it, and its neighbours (`Trail`).
|
|
43
75
|
const { trails, transport } = useFramework();
|
|
@@ -55,6 +87,58 @@ export function EntityRecord({ api, resource, entity, fields, pages, actions, })
|
|
|
55
87
|
api.replace({ ...ref, params: { ...ref.params, [TRAIL_PARAM]: trailKey } });
|
|
56
88
|
});
|
|
57
89
|
};
|
|
90
|
+
const ready = reading.status === "ready";
|
|
91
|
+
const summary = ready && !reading.isNew ? summarize(reading.record, reading.meta) : undefined;
|
|
92
|
+
const dirty = ready ? dirtyOf(reading) : undefined;
|
|
93
|
+
const failure = reading.edit.failure;
|
|
94
|
+
// Who, only when the record says it (an author is optional: the line then says only when).
|
|
95
|
+
const stamp = (one) => one?.at == null ? undefined : { at: one.at, ...(one.by == null ? {} : { by: one.by }) };
|
|
96
|
+
const created = stamp(summary?.created);
|
|
97
|
+
const updated = stamp(summary?.updated);
|
|
98
|
+
// Moving away with something typed would lose it: «save / discard» comes first.
|
|
99
|
+
const place = trail === undefined || reading.isNew || reading.edit.dirty
|
|
100
|
+
? null
|
|
101
|
+
: placeOf(trail, reading.id);
|
|
102
|
+
return {
|
|
103
|
+
reading,
|
|
104
|
+
crumbs,
|
|
105
|
+
history,
|
|
106
|
+
summary,
|
|
107
|
+
/** web-ui `Record`'s own props: where it is drawn, its name, its unsaved work, its refusal. */
|
|
108
|
+
record: {
|
|
109
|
+
// Where it is mounted decides the paper, not what the rail carries: crumbs, pager and
|
|
110
|
+
// actions come and go while it is on screen, and the paper flipping with them remounted
|
|
111
|
+
// the form under the field being typed in. A modal is already a card.
|
|
112
|
+
placement: api.surface === "modal" ? "card" : "page",
|
|
113
|
+
identity: {
|
|
114
|
+
// A new record is «creating»; an existing one has no name until it is read.
|
|
115
|
+
title: summary?.name ??
|
|
116
|
+
(reading.isNew ? copy.creating(nameOf(reading.meta, reading.locale) || "") : ""),
|
|
117
|
+
...(summary?.type == null ? {} : { subtitle: summary.type }),
|
|
118
|
+
...(summary?.state == null ? {} : { tag: { label: summary.state } }),
|
|
119
|
+
},
|
|
120
|
+
...(dirty === undefined ? {} : { dirty }),
|
|
121
|
+
// The refusal in words; its heading when the server said nothing more (no detail).
|
|
122
|
+
...(failure === null || failure === undefined ? {} : { error: refusalOf(failure) }),
|
|
123
|
+
},
|
|
124
|
+
/** `Record.Pager`'s props, when it was opened from a list and nothing is typed. */
|
|
125
|
+
pager: place === null
|
|
126
|
+
? undefined
|
|
127
|
+
: { index: place.index, total: place.total, onPrev: go(-1), onNext: go(1) },
|
|
128
|
+
/** `Record.Audit`'s props, when the record says who made it or changed it. */
|
|
129
|
+
audit: created === undefined && updated === undefined
|
|
130
|
+
? undefined
|
|
131
|
+
: {
|
|
132
|
+
...(created === undefined ? {} : { created }),
|
|
133
|
+
...(updated === undefined ? {} : { updated }),
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
export function EntityRecord({ api, resource, entity, fields, pages, actions, }) {
|
|
138
|
+
const screen = useRecordScreen(entity, { api, resource });
|
|
139
|
+
const { reading, crumbs, history, pager } = screen;
|
|
140
|
+
const [page, setPage] = useState(undefined);
|
|
141
|
+
const copy = frameworkCopy().record;
|
|
58
142
|
if (reading.status === "loading")
|
|
59
143
|
return _jsx(Skeleton, { rows: 6, label: copy.loading });
|
|
60
144
|
if (reading.status === "failed")
|
|
@@ -64,30 +148,7 @@ export function EntityRecord({ api, resource, entity, fields, pages, actions, })
|
|
|
64
148
|
const shown = fields ?? layout.fields;
|
|
65
149
|
const ownActions = actions?.(reading) ?? null;
|
|
66
150
|
const tabs = pages ?? layout.pages;
|
|
67
|
-
|
|
68
|
-
const dirty = dirtyOf(reading);
|
|
69
|
-
const created = summary?.created;
|
|
70
|
-
const updated = summary?.updated;
|
|
71
|
-
// Who, only when the record says it (web-ui 1.9: an author is optional, the line then says
|
|
72
|
-
// only when). The moment goes as the framework writes every fact of the record.
|
|
73
|
-
const stamp = (one) => one?.at == null ? undefined : { at: one.at, ...(one.by == null ? {} : { by: one.by }) };
|
|
74
|
-
const createdStamp = stamp(created);
|
|
75
|
-
const updatedStamp = stamp(updated);
|
|
76
|
-
// Moving away with something typed would lose it: «save / discard» comes first.
|
|
77
|
-
const place = trail === undefined || reading.isNew || edit.dirty ? null : placeOf(trail, reading.id);
|
|
78
|
-
return (_jsxs(Record
|
|
79
|
-
// Where it is mounted decides the paper, not what the rail carries: crumbs, pager and
|
|
80
|
-
// actions come and go while it is on screen (loading, a draft), and the paper flipping
|
|
81
|
-
// with them remounted the form under the field being typed in. A modal is already a card.
|
|
82
|
-
, {
|
|
83
|
-
// Where it is mounted decides the paper, not what the rail carries: crumbs, pager and
|
|
84
|
-
// actions come and go while it is on screen (loading, a draft), and the paper flipping
|
|
85
|
-
// with them remounted the form under the field being typed in. A modal is already a card.
|
|
86
|
-
placement: api.surface === "modal" ? "card" : "page", identity: {
|
|
87
|
-
title: summary?.name ?? copy.creating(nameOf(meta, locale) || ""),
|
|
88
|
-
...(summary?.type == null ? {} : { subtitle: summary.type }),
|
|
89
|
-
...(summary?.state == null ? {} : { tag: { label: summary.state } }),
|
|
90
|
-
}, ...(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
|
|
151
|
+
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: api.surface === "page" || api.surface === "modal" ? 2 : 1, children: shown.map((name) => (_jsx(RecordField, { record: reading, name: name }, name))) }), edit.advice
|
|
91
152
|
.filter((one) => (one.path?.length ?? 0) <= 1)
|
|
92
|
-
.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))) })),
|
|
153
|
+
.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 })] }));
|
|
93
154
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sincpro/web-framework",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.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",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"@opentelemetry/resources": "^3.1.0",
|
|
41
41
|
"@opentelemetry/sdk-trace": "^3.1.0",
|
|
42
42
|
"@sentry/browser": "^11.11.0",
|
|
43
|
-
"@sincpro/client-framework": "^0.
|
|
43
|
+
"@sincpro/client-framework": "^0.5.0",
|
|
44
44
|
"@sincpro/criteria": "^2.0.0",
|
|
45
45
|
"@sincpro/criteria-react": "^2.0.0",
|
|
46
|
-
"@sincpro/web-composer": "^1.
|
|
47
|
-
"@sincpro/web-ui": "^2.
|
|
46
|
+
"@sincpro/web-composer": "^1.6.0",
|
|
47
|
+
"@sincpro/web-ui": "^2.1.0",
|
|
48
48
|
"react": ">=19",
|
|
49
49
|
"react-dom": ">=19"
|
|
50
50
|
},
|
|
@@ -72,11 +72,11 @@
|
|
|
72
72
|
"@opentelemetry/resources": "3.1.0",
|
|
73
73
|
"@opentelemetry/sdk-trace": "3.1.0",
|
|
74
74
|
"@sentry/browser": "11.11.0",
|
|
75
|
-
"@sincpro/client-framework": "^0.
|
|
75
|
+
"@sincpro/client-framework": "^0.5.0",
|
|
76
76
|
"@sincpro/criteria": "^2.0.0",
|
|
77
77
|
"@sincpro/criteria-react": "^2.0.0",
|
|
78
|
-
"@sincpro/web-composer": "^1.
|
|
79
|
-
"@sincpro/web-ui": "^2.
|
|
78
|
+
"@sincpro/web-composer": "^1.6.0",
|
|
79
|
+
"@sincpro/web-ui": "^2.1.0",
|
|
80
80
|
"@storybook/addon-a11y": "10.6.5",
|
|
81
81
|
"@storybook/addon-docs": "10.6.5",
|
|
82
82
|
"@storybook/addon-mcp": "10.6.5",
|