@sincpro/web-framework 3.12.0 → 3.13.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 +65 -1
- package/dist/core/cache.js +11 -0
- package/dist/core/copy.d.ts +18 -0
- package/dist/core/copy.js +21 -0
- package/dist/core/edit.d.ts +3 -0
- package/dist/core/edit.js +9 -6
- package/dist/core/files.d.ts +58 -0
- package/dist/core/files.js +57 -15
- package/dist/core/index.d.ts +4 -3
- package/dist/core/index.js +4 -3
- package/dist/core/list.d.ts +9 -0
- package/dist/core/present.d.ts +16 -0
- package/dist/core/present.js +41 -4
- package/dist/core/richText.d.ts +39 -0
- package/dist/core/richText.js +45 -0
- package/dist/core/summary.js +5 -1
- package/dist/errors/index.d.ts +3 -1
- package/dist/errors/index.js +14 -2
- package/dist/errors/narrowed.d.ts +2 -0
- package/dist/errors/narrowed.js +7 -0
- package/dist/errors/server.js +1 -7
- package/dist/react/context.d.ts +20 -1
- package/dist/react/context.js +11 -4
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +1 -0
- package/dist/react/useTextOf.d.ts +3 -2
- package/dist/react/useTextOf.js +4 -4
- package/dist/react/useUpload.d.ts +33 -0
- package/dist/react/useUpload.js +69 -0
- package/dist/telemetry/index.d.ts +21 -1
- package/dist/telemetry/index.js +35 -1
- package/dist/web/index.d.ts +5 -1
- package/dist/web/index.js +5 -1
- package/dist/web/list/EntitySearchBar.d.ts +5 -2
- package/dist/web/list/EntitySearchBar.js +43 -12
- package/dist/web/record/ActionButton.d.ts +1 -1
- package/dist/web/record/ActionButton.js +7 -2
- package/dist/web/record/ask.d.ts +18 -0
- package/dist/web/record/ask.js +15 -0
- package/dist/web/record/choice.d.ts +32 -0
- package/dist/web/record/choice.js +36 -0
- package/dist/web/record/control.d.ts +4 -0
- package/dist/web/record/control.js +52 -1
- package/dist/web/record/edit.js +37 -5
- package/dist/web/record/fileControl.d.ts +22 -0
- package/dist/web/record/fileControl.js +48 -0
- package/dist/web/record/person.d.ts +23 -0
- package/dist/web/record/person.js +27 -0
- package/dist/web/record/record.js +8 -2
- package/dist/web/record/richText.d.ts +27 -0
- package/dist/web/record/richText.js +59 -0
- package/dist/web/workspace/SincproApp.d.ts +10 -1
- package/dist/web/workspace/SincproApp.js +2 -2
- package/package.json +5 -5
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { FieldControl } from "./control.js";
|
|
2
|
+
/**
|
|
3
|
+
* A field of formatted text: web-ui's editor while it is written, the HTML cleaned of anything
|
|
4
|
+
* that runs when it is read. How much the editor offers, the video hosts it embeds and whether
|
|
5
|
+
* the backend cleans what it stores are the application's, said once (`FrameworkProvider
|
|
6
|
+
* richText`); pictures go where the application sends files (`uploads`), filed under the record
|
|
7
|
+
* they belong to (`control.about`).
|
|
8
|
+
*
|
|
9
|
+
* <RecordField record={aviso} name="cuerpo" /> // widget "html": by itself
|
|
10
|
+
* <RecordField record={aviso} name="cuerpo" as={richTextControl} /> // a field the model does not mark
|
|
11
|
+
*
|
|
12
|
+
* Context: `RecordField` draws it for a field whose widget is `html`
|
|
13
|
+
* (Sincpro-SRL/sincpro_framework#371). Before the backend names it — or for a field it never
|
|
14
|
+
* will — the screen asks for it in code, by reference: `as={richTextControl}`, never a widget
|
|
15
|
+
* named in a string. Without `uploads` the editor takes no pictures; without `about` it does not
|
|
16
|
+
* know whose they would be, and takes none either.
|
|
17
|
+
*/
|
|
18
|
+
export declare function RichTextControl({ control }: {
|
|
19
|
+
control: FieldControl;
|
|
20
|
+
}): import("react").JSX.Element;
|
|
21
|
+
/** `RichTextControl` as a field's control, by reference: `<RecordField … as={richTextControl} />`. */
|
|
22
|
+
export declare const richTextControl: (control: FieldControl) => import("react").JSX.Element;
|
|
23
|
+
/** Formatted text read — a record's fact: the HTML cleaned of what runs, with the players of the
|
|
24
|
+
* application's video hosts (`FrameworkProvider richText`). */
|
|
25
|
+
export declare function RichTextFact({ value }: {
|
|
26
|
+
value: unknown;
|
|
27
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { sendFile, uploadRefusalOf } from "../../core/files.js";
|
|
4
|
+
import { useFramework, useFrameworkIfAny } from "../../react/context.js";
|
|
5
|
+
import { RichTextInput, RichTextValue } from "@sincpro/web-ui";
|
|
6
|
+
import { useMemo } from "react";
|
|
7
|
+
/**
|
|
8
|
+
* A field of formatted text: web-ui's editor while it is written, the HTML cleaned of anything
|
|
9
|
+
* that runs when it is read. How much the editor offers, the video hosts it embeds and whether
|
|
10
|
+
* the backend cleans what it stores are the application's, said once (`FrameworkProvider
|
|
11
|
+
* richText`); pictures go where the application sends files (`uploads`), filed under the record
|
|
12
|
+
* they belong to (`control.about`).
|
|
13
|
+
*
|
|
14
|
+
* <RecordField record={aviso} name="cuerpo" /> // widget "html": by itself
|
|
15
|
+
* <RecordField record={aviso} name="cuerpo" as={richTextControl} /> // a field the model does not mark
|
|
16
|
+
*
|
|
17
|
+
* Context: `RecordField` draws it for a field whose widget is `html`
|
|
18
|
+
* (Sincpro-SRL/sincpro_framework#371). Before the backend names it — or for a field it never
|
|
19
|
+
* will — the screen asks for it in code, by reference: `as={richTextControl}`, never a widget
|
|
20
|
+
* named in a string. Without `uploads` the editor takes no pictures; without `about` it does not
|
|
21
|
+
* know whose they would be, and takes none either.
|
|
22
|
+
*/
|
|
23
|
+
export function RichTextControl({ control }) {
|
|
24
|
+
const { richText, uploads, transport } = useFramework();
|
|
25
|
+
const { about } = control;
|
|
26
|
+
const html = typeof control.value === "string" ? control.value : "";
|
|
27
|
+
const images = useMemo(() => uploads === undefined || about === undefined
|
|
28
|
+
? undefined
|
|
29
|
+
: {
|
|
30
|
+
upload: async (file) => {
|
|
31
|
+
try {
|
|
32
|
+
const published = await sendFile(transport, uploads, file, about, {
|
|
33
|
+
signal: new AbortController().signal,
|
|
34
|
+
});
|
|
35
|
+
if (published.src === undefined)
|
|
36
|
+
throw new Error("uploads.publish answered no `src`: a picture inside a rich text needs where it is seen");
|
|
37
|
+
return {
|
|
38
|
+
src: published.src,
|
|
39
|
+
...(published.alt === undefined ? {} : { alt: published.alt }),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
// web-ui shows the thrown message as the failure: the copy's words, by reason.
|
|
44
|
+
throw new Error(uploadRefusalOf(error), { cause: error });
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
}, [uploads, about, transport]);
|
|
48
|
+
if (control.readonly)
|
|
49
|
+
return (_jsx(RichTextValue, { value: html, ...(richText.embeds === undefined ? {} : { embeds: richText.embeds }), ...(richText.sanitized === undefined ? {} : { sanitized: richText.sanitized }) }));
|
|
50
|
+
return (_jsx(RichTextInput, { value: html, onChange: (next) => control.set(next), invalid: control.invalid, toolbar: richText.toolbar ?? "full", ...(richText.embeds === undefined ? {} : { embeds: richText.embeds }), ...(images === undefined ? {} : { images }), ...(control.standalone === true ? { "aria-label": control.label } : {}) }));
|
|
51
|
+
}
|
|
52
|
+
/** `RichTextControl` as a field's control, by reference: `<RecordField … as={richTextControl} />`. */
|
|
53
|
+
export const richTextControl = (control) => (_jsx(RichTextControl, { control: control }));
|
|
54
|
+
/** Formatted text read — a record's fact: the HTML cleaned of what runs, with the players of the
|
|
55
|
+
* application's video hosts (`FrameworkProvider richText`). */
|
|
56
|
+
export function RichTextFact({ value }) {
|
|
57
|
+
const settings = useFrameworkIfAny()?.richText ?? {};
|
|
58
|
+
return (_jsx(RichTextValue, { value: typeof value === "string" ? value : null, ...(settings.embeds === undefined ? {} : { embeds: settings.embeds }), ...(settings.sanitized === undefined ? {} : { sanitized: settings.sanitized }) }));
|
|
59
|
+
}
|
|
@@ -2,9 +2,11 @@ import { type ChangeFeed, type Entity, type Transport } from "@sincpro/client-fr
|
|
|
2
2
|
import type { Meta } from "@sincpro/criteria";
|
|
3
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
|
+
import type { Uploads } from "../../core/files.js";
|
|
5
6
|
import type { DateStyle } from "../../core/present.js";
|
|
7
|
+
import type { RichTextSettings } from "../../core/richText.js";
|
|
6
8
|
import { type ReactNode } from "react";
|
|
7
|
-
export declare function SincproApp({ transport, views, start, language, metas, entities, empty, skin, cache, timeZone, dateStyle, currency, events, workspace: given, bar, onViewError, changes, }: {
|
|
9
|
+
export declare function SincproApp({ transport, views, start, language, metas, entities, empty, skin, cache, timeZone, dateStyle, currency, region, richText, uploads, events, workspace: given, bar, onViewError, changes, }: {
|
|
8
10
|
transport: Transport;
|
|
9
11
|
/** The entities as composer views — `entityView(…)` — and any other view of the app. */
|
|
10
12
|
views: readonly ViewSpec[];
|
|
@@ -34,6 +36,13 @@ export declare function SincproApp({ transport, views, start, language, metas, e
|
|
|
34
36
|
dateStyle?: DateStyle;
|
|
35
37
|
/** The business's currency (`"BOB"`): an amount the model draws as money is written in it. */
|
|
36
38
|
currency?: string;
|
|
39
|
+
/** Where numbers and money are written as the business writes them (`"es-BO"`), apart from
|
|
40
|
+
* the language of the words. */
|
|
41
|
+
region?: string;
|
|
42
|
+
/** How a field of formatted text is written and read (`FrameworkProvider richText`). */
|
|
43
|
+
richText?: RichTextSettings;
|
|
44
|
+
/** Where a file a person gives goes — the application's (`FrameworkProvider uploads`). */
|
|
45
|
+
uploads?: Uploads;
|
|
37
46
|
/** Each domain event's definition by its wire name (`eventMetasOf(contract)`): a history
|
|
38
47
|
* names each fact's own fields in its words. */
|
|
39
48
|
events?: Readonly<Record<string, Meta>>;
|
|
@@ -51,7 +51,7 @@ function FrameworkSearch({ children }) {
|
|
|
51
51
|
}
|
|
52
52
|
/** A view that broke while drawing, told to the process's error reporter: `view <ref>`. */
|
|
53
53
|
const reportViewError = (error, { resource }) => reportError(error, `view ${formatRef(resource)}`);
|
|
54
|
-
export function SincproApp({ transport, views, start, language = "es", metas, entities, empty, skin = webUiSkin, cache = {}, timeZone, dateStyle, currency, events, workspace: given, bar, onViewError = reportViewError, changes = processChanges, }) {
|
|
54
|
+
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, }) {
|
|
55
55
|
// Installed once, before anything draws: the three tables are module state of their packages.
|
|
56
56
|
useState(() => {
|
|
57
57
|
if (language === "es") {
|
|
@@ -96,5 +96,5 @@ export function SincproApp({ transport, views, start, language = "es", metas, en
|
|
|
96
96
|
// The first screen only: a re-render must not push it again.
|
|
97
97
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
98
98
|
}, [workspace]);
|
|
99
|
-
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 }), ...(events === undefined ? {} : { events }), children: _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 }) }) })] }) }) }) }));
|
|
99
|
+
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: _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 }) }) })] }) }) }) }));
|
|
100
100
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sincpro/web-framework",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.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.
|
|
54
|
+
"@sincpro/client-framework": "^2.7.0",
|
|
55
55
|
"@sincpro/criteria": "^2.4.0",
|
|
56
56
|
"@sincpro/criteria-react": "^2.4.0",
|
|
57
57
|
"@sincpro/web-composer": "^1.7.0",
|
|
58
|
-
"@sincpro/web-ui": "^2.
|
|
58
|
+
"@sincpro/web-ui": "^2.15.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.
|
|
98
|
+
"@sincpro/client-framework": "^2.7.0",
|
|
99
99
|
"@sincpro/criteria": "^2.5.0",
|
|
100
100
|
"@sincpro/criteria-react": "^2.5.0",
|
|
101
101
|
"@sincpro/web-composer": "^1.9.0",
|
|
102
|
-
"@sincpro/web-ui": "^2.
|
|
102
|
+
"@sincpro/web-ui": "^2.16.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",
|