@sincpro/web-framework 3.20.0 → 3.21.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 +59 -58
- package/dist/web/index.d.ts +1 -1
- package/dist/web/index.js +1 -1
- package/dist/web/workspace/RecordScreen.d.ts +17 -1
- package/dist/web/workspace/RecordScreen.js +33 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -702,64 +702,65 @@ find .next/static -name '*.map' -delete
|
|
|
702
702
|
Each answers one question, and each comes in the three levels — use the component, drop to the
|
|
703
703
|
hook and draw your own, or go straight to the loose piece.
|
|
704
704
|
|
|
705
|
-
| Question
|
|
706
|
-
|
|
|
707
|
-
| Where is the data?
|
|
708
|
-
| The application's logic
|
|
709
|
-
| Read through a use case
|
|
710
|
-
| Read it on the server first
|
|
711
|
-
| A record read on the server
|
|
712
|
-
| What every use case runs with
|
|
713
|
-
| What happened, what broke
|
|
714
|
-
| What happened, on the server
|
|
715
|
-
| What broke, on the server
|
|
716
|
-
| A page that broke
|
|
717
|
-
| What is each field?
|
|
718
|
-
| A value outside a model
|
|
719
|
-
| A file or a photo it holds
|
|
720
|
-
| A file given in the record
|
|
721
|
-
| Formatted text
|
|
722
|
-
| A person, read
|
|
723
|
-
| A choice's tag outside a list
|
|
724
|
-
| What is a record, at any size?
|
|
725
|
-
| How does a record look?
|
|
726
|
-
| N records: search, filter, page
|
|
727
|
-
| A named slice (to collect, …)
|
|
728
|
-
| A record's whole screen
|
|
729
|
-
| One region of a record screen
|
|
730
|
-
| One region of a list
|
|
731
|
-
| The models a face brings
|
|
732
|
-
| What a record screen says of it
|
|
733
|
-
| What hangs off a record, counted
|
|
734
|
-
|
|
|
735
|
-
|
|
|
736
|
-
|
|
|
737
|
-
|
|
|
738
|
-
|
|
|
739
|
-
|
|
|
740
|
-
|
|
|
741
|
-
|
|
|
742
|
-
|
|
|
743
|
-
| Its
|
|
744
|
-
|
|
|
745
|
-
|
|
|
746
|
-
| Choose
|
|
747
|
-
|
|
|
748
|
-
|
|
|
749
|
-
|
|
|
750
|
-
|
|
|
751
|
-
|
|
|
752
|
-
|
|
|
753
|
-
|
|
|
754
|
-
|
|
|
755
|
-
|
|
|
756
|
-
| A
|
|
757
|
-
| A
|
|
758
|
-
|
|
|
759
|
-
|
|
|
760
|
-
|
|
|
761
|
-
|
|
|
762
|
-
|
|
|
705
|
+
| Question | Declarative | Hook | Loose piece |
|
|
706
|
+
| ------------------------------------- | -------------------------------------------------------------------------- | ------------------------------------- | ------------------------------------------------------------ |
|
|
707
|
+
| Where is the data? | `entity()` (client-framework) | — | `restTransport`, `memoryTransport` |
|
|
708
|
+
| The application's logic | its `Feature`s and `ApplicationService`s (client-framework) | `useService` | `project.Issues.close(…)` |
|
|
709
|
+
| Read through a use case | its `Feature`s (client-framework) | `useServiceReading` | `project.Accounts.balance(…)` |
|
|
710
|
+
| Read it on the server first | the same use case, before the page is drawn | `useServiceReading(…, { initial })` | `readOnServer`, `ServerRead` |
|
|
711
|
+
| A record read on the server | `EntityRecord initial` | `useRecord(…, { initial })` | `readRecordOnServer`, `RecordRead` |
|
|
712
|
+
| What every use case runs with | `processContext`, `project.context` (client-framework) | `useContextValues` | `ContextStore` |
|
|
713
|
+
| What happened, what broke | `./telemetry`, `./errors` (optional) | — | `configureProcess({ tracer, reporter })` |
|
|
714
|
+
| What happened, on the server | `configureServerProcess` (`./telemetry/server`, optional) | — | `registerServerTracing`, `serverTracer` |
|
|
715
|
+
| What broke, on the server | `reportRequestError` (`./errors/server`, optional) | — | `registerServerErrors`, `serverReporter` |
|
|
716
|
+
| A page that broke | `RouteError`, in the route's error boundary | — | `reportError` (client-framework) |
|
|
717
|
+
| What is each field? | `Meta` from the server, or `defineMeta` | — | `textOf`, `viewOf`, `metaFromSchema` |
|
|
718
|
+
| A value outside a model | — | `useTextOf` | `moneyTextOf`, `dayTextOf`, `instantTextOf`, `numberTextOf` |
|
|
719
|
+
| A file or a photo it holds | `EntityList`, `RecordField`: by its widget, as a `FileValue` | — | `attachmentOf`, `storedFileOf`, `renditionUrl` |
|
|
720
|
+
| A file given in the record | `RecordField` with `uploads`: `FileControl` (`DropZone`) | `useUpload` | `sendFile`, `uploadRefusalOf` |
|
|
721
|
+
| Formatted text | `RecordField` (`widget: "html"`), `factsOf`: `RichTextControl` | — | `richTextPlainOf`, `holdsRichText` |
|
|
722
|
+
| A person, read | `RecordField`, `factsOf`: `PersonValue` (`UserChip`) | `useSummaryOf` | `isPersonEntity` |
|
|
723
|
+
| A choice's tag outside a list | `ChoiceTag` | — | `choiceTagOf` |
|
|
724
|
+
| What is a record, at any size? | `cardOf`, `relationOf` | `useSummaryOf` | `summaryOf` |
|
|
725
|
+
| How does a record look? | `presented(entity, { option, row, card, tile })` | — | `presentationOf` |
|
|
726
|
+
| N records: search, filter, page | `EntityList`, `EntitySearchBar` | `useListing`, `useGroups` | `transport.list(route, criteria)` |
|
|
727
|
+
| A named slice (to collect, …) | `defineList` + `listView` | `useListing(list)` | `scopeOf` |
|
|
728
|
+
| A record's whole screen | `EntityRecord`, `entityView` without `record` | `useRecordScreen` | `formOf` |
|
|
729
|
+
| One region of a record screen | `RecordScreen.*` (`Rail`, `Paper`, `Fields`, `Pages`, `Audit`…) | `useScreenRecord` | web-ui's `Record.*` |
|
|
730
|
+
| One region of a list | `EntityList.*` (`Bar`, `Search`, `Table`, `Board`, `Pager`…) | `useScreenListing`, `useEntityList` | web-ui's `List.*` |
|
|
731
|
+
| The models a face brings | `ModelDefinitions entities metas events`; `SincproApp` without `transport` | — | `metasOf`, `eventMetasOf` (client-framework) |
|
|
732
|
+
| What a record screen says of it | `RecordScreen title subtitle tag creating moment actions` | `useRecordScreen` (same options) | web-ui's `Record identity`, `Record.Dock moment` |
|
|
733
|
+
| What hangs off a record, counted | `RecordScreen links` (`RelatedLink`: entity, `where`, title) | `useCounts` | `listRef` |
|
|
734
|
+
| The notices, on a hand-written screen | — | `useRecordNotices` | web-ui's `Record.Notice` |
|
|
735
|
+
| A block laid out as the form | — | `useScreenColumns` | — |
|
|
736
|
+
| Who is who in a history | `SincproApp people`, `FrameworkProvider people`, `ModelDefinitions people` | `usePeopleOf` | the application's use case |
|
|
737
|
+
| «New» in the business's words | `EntityList create="Nueva noticia"` | — | `canCreate` (`create` or `Edit`) |
|
|
738
|
+
| The list as a spreadsheet | `EntityList` «Exportar» (the entity's `export`) | — | `csvOf`, `exportColumnsOf`; `exportRoute` (client-framework) |
|
|
739
|
+
| Spanish in tú | `SincproApp voice="tú"` | — | `SPANISH_FRAMEWORK_COPY_TU`, web-ui's `SPANISH_COPY_TU` |
|
|
740
|
+
| Previous / next from a record | `EntityRecord` (from a list) | — | `placeOf`, `stepIn` (`Trail`) |
|
|
741
|
+
| How much each group adds up | `EntityList sums` | `useGroups` (`sums`) | `sumsOf`, `detailOf` |
|
|
742
|
+
| One record: read, edit, save | `RecordField`, `factsOf`, `RecordLines` | `useRecord` | `transport.one`, `transport.send` |
|
|
743
|
+
| Its lines: add, edit, remove | `RecordField name="lines"` (`LineItems`) | `useRecord` (`edit.cell`, `errorAt`) | `lineKey`, `editableLines`, `pathOf` |
|
|
744
|
+
| Its relations, inside it | `RelatedList` | `useRelated` | `relatedOf` |
|
|
745
|
+
| What other records hold of it | web-ui's `SmartButton` opening `entity.listRef(cut, name)` | `useCount` | `entity.listRef` (client-framework) |
|
|
746
|
+
| Choose one (literal search) | `EntityPicker`, `chooserIn` | `useLookup` | `lookupOf` + criteria's `matching` |
|
|
747
|
+
| Choose several (many2many) | `EntityTags` | `useLookup` (`values`) | `lookupOf` |
|
|
748
|
+
| A relation, from the model alone | `RecordField name="customer_id"` | `useEntityFor` | `relationFieldOf`, `entityFor` |
|
|
749
|
+
| Open it where it belongs | `RelatedRecord`, `entityView`, `EntityList openTargets` | — | `openIn`, `targetsFor`, `OpenInMenu` |
|
|
750
|
+
| Look at the set several ways | `EntityList views` (table, rows, board, sheet, tiles) | — | web-ui's `List.*` |
|
|
751
|
+
| Cross it by two fields | `EntityList pivot` | `usePivot` | `pivotOf` |
|
|
752
|
+
| Order by several fields | the bar's criteria builder | `listing.orderBy([...])` | criteria's `order` |
|
|
753
|
+
| Act on it (with a dry run) | `ServiceButton` (a use case), `CommandButton`, row commands | `useService`, `useCommand` | `transport.send` |
|
|
754
|
+
| What is chosen in a list | `EntityList selectable selection` | `useSelection` | `Selection`, `chosen`, `allMatching` (client-framework) |
|
|
755
|
+
| Act on each chosen one | `BatchProgress`, `selectionActions={(chosen) => …}` | `useBatchCommand` | `runBatch`, `keysOf` (client-framework), `sendRoute` |
|
|
756
|
+
| A list's actions, by the style | `EntityList actions`, `selectionActions` (`DockAction`s) | — | web-ui's `List.Dock`, `ViewStyleProvider` |
|
|
757
|
+
| A record's actions, by the style | `EntityRecord actions`, web-ui's `Record.Dock` | `useRecordLifecycleActions` | `DockedAction`, `ActionLook` |
|
|
758
|
+
| A use case or a Command, there | `ServiceButton`, `CommandButton` (as buttons) | `useServiceAction`/`useCommandAction` | — |
|
|
759
|
+
| Delete it | `EntityRecord` (`RecordLifecycle`) | `useRecordLifecycle` | `entity.delete`, `useRouteCommand` |
|
|
760
|
+
| Its trash | `EntityRecord` (`RecordLifecycle`), `listView(trashOf(entity))` | `useRecordLifecycle` | `entity.archive`, `entity.restore`, `trashOf` |
|
|
761
|
+
| Read again when it was written | every reading of this package, by itself | `useWrites` | `processChanges` (client-framework) |
|
|
762
|
+
| What happened to it | `Record.Activity` fed by `useHistory` | `useHistory` | `historyOf` |
|
|
763
|
+
| The application context | `SincproApp` | `useRecordInWorkspace`, `useFollowed` | `FrameworkProvider`, `webUiSkin` |
|
|
763
764
|
|
|
764
765
|
The rules behind them, in short:
|
|
765
766
|
|
package/dist/web/index.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export { RouteError, type RouteErrorProps } from "./RouteError.js";
|
|
|
40
40
|
export { entityView, type EntityViewOptions, listView, type ListViewOptions, } from "./workspace/composer.js";
|
|
41
41
|
export { openIn, openOptions, RECORD_SIZE, RelatedRecord, targetsFor, } from "./workspace/open.js";
|
|
42
42
|
export { type RecordTag, type Stamp, useRecordScreen, } from "./workspace/record.js";
|
|
43
|
-
export { EntityRecord, type FieldDrawn, type ReadyRecord, RecordScreen, type RecordScreenProps, type RelatedLink, useScreenColumns, useScreenRecord, } from "./workspace/RecordScreen.js";
|
|
43
|
+
export { EntityRecord, type FieldDrawn, type ReadyRecord, RecordScreen, type RecordScreenProps, type RelatedLink, useRecordNotices, useScreenColumns, useScreenRecord, } from "./workspace/RecordScreen.js";
|
|
44
44
|
export { SincproApp } from "./workspace/SincproApp.js";
|
|
45
45
|
export { webUiSkin } from "./workspace/skin.js";
|
|
46
46
|
export { chooserIn, useFollowed, useRecordInWorkspace, } from "./workspace/workspace.js";
|
package/dist/web/index.js
CHANGED
|
@@ -40,7 +40,7 @@ export { RouteError } from "./RouteError.js";
|
|
|
40
40
|
export { entityView, listView, } from "./workspace/composer.js";
|
|
41
41
|
export { openIn, openOptions, RECORD_SIZE, RelatedRecord, targetsFor, } from "./workspace/open.js";
|
|
42
42
|
export { useRecordScreen, } from "./workspace/record.js";
|
|
43
|
-
export { EntityRecord, RecordScreen, useScreenColumns, useScreenRecord, } from "./workspace/RecordScreen.js";
|
|
43
|
+
export { EntityRecord, RecordScreen, useRecordNotices, useScreenColumns, useScreenRecord, } from "./workspace/RecordScreen.js";
|
|
44
44
|
export { SincproApp } from "./workspace/SincproApp.js";
|
|
45
45
|
export { webUiSkin } from "./workspace/skin.js";
|
|
46
46
|
export { chooserIn, useFollowed, useRecordInWorkspace, } from "./workspace/workspace.js";
|
|
@@ -93,6 +93,19 @@ export declare function useScreenRecord<T extends AnyRecord>(_entity?: Entity<T>
|
|
|
93
93
|
* asks the workspace where it opened.
|
|
94
94
|
*/
|
|
95
95
|
export declare function useScreenColumns(): 1 | 2;
|
|
96
|
+
/**
|
|
97
|
+
* The record's notices for a screen that writes web-ui's `Record` itself (`useRecordScreen`):
|
|
98
|
+
* the edit's and the server's advice, as `RecordScreen.Notices` and `.Advice` draw them —
|
|
99
|
+
* elements of web-ui's slot, written straight among `Record`'s children. Nothing while the record
|
|
100
|
+
* is not read.
|
|
101
|
+
*
|
|
102
|
+
* const notices = useRecordNotices(screen.reading);
|
|
103
|
+
* <Record {...screen.record}>{notices}<Record.Rail>…</Record.Rail>…</Record>
|
|
104
|
+
*
|
|
105
|
+
* Context: a screen at the hooks level copied the framework's notices — as `Callout`s among the
|
|
106
|
+
* fields, which web-ui says not to do (#112).
|
|
107
|
+
*/
|
|
108
|
+
export declare function useRecordNotices<T extends AnyRecord>(reading: RecordReading<T>): ReactNode[];
|
|
96
109
|
/** A field drawn the screen's way inside `RecordScreen.Fields`: its control, and the record. */
|
|
97
110
|
export type FieldDrawn = (control: FieldControl, record: ReadyRecord<AnyRecord>) => ReactNode;
|
|
98
111
|
/**
|
|
@@ -158,7 +171,10 @@ export declare const RecordScreen: typeof RecordScreenRoot & {
|
|
|
158
171
|
Crumbs: import("../parts.js").Part<NoProps, RecordScreenState>;
|
|
159
172
|
Pager: import("../parts.js").Part<NoProps, RecordScreenState>;
|
|
160
173
|
Smart: import("../parts.js").Part<NoProps, RecordScreenState>;
|
|
161
|
-
Actions: import("../parts.js").Part<
|
|
174
|
+
Actions: import("../parts.js").Part<{
|
|
175
|
+
visible?: number | undefined;
|
|
176
|
+
children?: never;
|
|
177
|
+
}, RecordScreenState>;
|
|
162
178
|
Paper: import("../parts.js").Part<{
|
|
163
179
|
children?: ReactNode;
|
|
164
180
|
layout?: "horizontal" | "stacked";
|
|
@@ -57,12 +57,12 @@ const Crumbs = screenPart("Crumbs", (_props, { screen }) => screen.crumbs.length
|
|
|
57
57
|
const Pager = screenPart("Pager", (_props, { screen }) => screen.pager === undefined ? null : _jsx(Record.Pager, { ...screen.pager }));
|
|
58
58
|
/** The screen's actions and the record's lifecycle — floating in the dock, or in the rail when
|
|
59
59
|
* the screen draws them by hand. The application's word on the record's moment goes with them. */
|
|
60
|
-
const Actions = screenPart("Actions", (
|
|
60
|
+
const Actions = screenPart("Actions", ({ visible }, state) => {
|
|
61
61
|
const { docked, drawn, screen } = state;
|
|
62
62
|
const moment = screen.moment;
|
|
63
63
|
return [
|
|
64
64
|
drawn === null ? null : _jsx(Record.Actions, { children: drawn }, "actions"),
|
|
65
|
-
docked.length === 0 && moment === undefined ? null : (_jsx(Record.Dock, { actions: docked, ...(moment === undefined ? {} : { moment }) }, "dock")),
|
|
65
|
+
docked.length === 0 && moment === undefined ? null : (_jsx(Record.Dock, { actions: docked, ...(moment === undefined ? {} : { moment }), ...(visible === undefined ? {} : { visible }) }, "dock")),
|
|
66
66
|
];
|
|
67
67
|
});
|
|
68
68
|
/** What hangs off the record — its payments, its members —, as web-ui's smart buttons. */
|
|
@@ -95,24 +95,48 @@ const Pages = screenPart("Pages", ({ names }, state) => {
|
|
|
95
95
|
* What happened to the edit itself, as web-ui's notices of the record — never among the fields:
|
|
96
96
|
* someone else saved first (`bad`: it blocks, so it stays in view between the rail and the
|
|
97
97
|
* paper, with «Read it again»), or a kept draft came back (`info`: into the rail's indicator,
|
|
98
|
-
* and it can be put away).
|
|
98
|
+
* and it can be put away). Elements of web-ui's slot, written straight into `Record` or its paper.
|
|
99
99
|
*/
|
|
100
|
-
|
|
101
|
-
const { reading, restoredAway, putRestoredAway } = state;
|
|
100
|
+
function noticesOf(reading, restoredAway, putRestoredAway) {
|
|
102
101
|
const copy = frameworkCopy().record;
|
|
103
102
|
const { conflict, restored } = reading.edit;
|
|
104
103
|
return [
|
|
105
104
|
conflict ? (_jsx(Record.Notice, { tone: "bad", action: _jsx(Button, { size: "sm", role: "secondary", onClick: reading.reload, children: copy.reload }), children: copy.conflict }, "conflict")) : null,
|
|
106
105
|
restored && !restoredAway ? (_jsx(Record.Notice, { tone: "info", onDismiss: putRestoredAway, children: copy.restored }, "restored")) : null,
|
|
107
106
|
];
|
|
108
|
-
}
|
|
107
|
+
}
|
|
109
108
|
/**
|
|
110
109
|
* What the server advised about the record or one of its fields, as notices of the record: one
|
|
111
110
|
* the save will refuse while it holds is a warning. A line's warning goes on its line.
|
|
112
111
|
*/
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
function adviceOf(reading) {
|
|
113
|
+
return reading.edit.advice
|
|
114
|
+
.filter((one) => (one.path?.length ?? 0) <= 1)
|
|
115
|
+
.map((one) => (_jsx(Record.Notice, { tone: one.blocks_save === true ? "warn" : "info", children: one.message }, one.message)));
|
|
116
|
+
}
|
|
117
|
+
/** The edit's notices, at the top of the screen or inside the paper (`noticesOf`). */
|
|
118
|
+
const Notices = screenPart("Notices", (_props, state) => noticesOf(state.reading, state.restoredAway, state.putRestoredAway));
|
|
119
|
+
/** The server's advice, as notices of the record (`adviceOf`). */
|
|
120
|
+
const Advice = screenPart("Advice", (_props, { reading }) => adviceOf(reading));
|
|
121
|
+
/**
|
|
122
|
+
* The record's notices for a screen that writes web-ui's `Record` itself (`useRecordScreen`):
|
|
123
|
+
* the edit's and the server's advice, as `RecordScreen.Notices` and `.Advice` draw them —
|
|
124
|
+
* elements of web-ui's slot, written straight among `Record`'s children. Nothing while the record
|
|
125
|
+
* is not read.
|
|
126
|
+
*
|
|
127
|
+
* const notices = useRecordNotices(screen.reading);
|
|
128
|
+
* <Record {...screen.record}>{notices}<Record.Rail>…</Record.Rail>…</Record>
|
|
129
|
+
*
|
|
130
|
+
* Context: a screen at the hooks level copied the framework's notices — as `Callout`s among the
|
|
131
|
+
* fields, which web-ui says not to do (#112).
|
|
132
|
+
*/
|
|
133
|
+
export function useRecordNotices(reading) {
|
|
134
|
+
const [restoredAway, setRestoredAway] = useState(false);
|
|
135
|
+
if (reading.status !== "ready")
|
|
136
|
+
return [];
|
|
137
|
+
const read = reading;
|
|
138
|
+
return [...noticesOf(read, restoredAway, () => setRestoredAway(true)), ...adviceOf(read)];
|
|
139
|
+
}
|
|
116
140
|
/**
|
|
117
141
|
* The record's fields in web-ui's form grid: two columns on a page and in a modal, one in a
|
|
118
142
|
* panel, a peek or a phone. `names` chooses and orders them; `title` heads the section and
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sincpro/web-framework",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.21.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",
|