@sincpro/web-framework 3.18.0 → 3.19.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 +76 -54
- package/dist/core/copy.d.ts +2 -0
- package/dist/core/copy.js +6 -2
- package/dist/core/explain.d.ts +4 -0
- package/dist/core/explain.js +4 -0
- package/dist/core/groups.d.ts +3 -1
- package/dist/core/groups.js +10 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/lines.d.ts +10 -0
- package/dist/core/lines.js +24 -0
- package/dist/core/list.d.ts +12 -0
- package/dist/react/context.d.ts +29 -0
- package/dist/react/context.js +46 -0
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +2 -2
- package/dist/react/useGroups.js +38 -5
- package/dist/react/useNameOf.d.ts +13 -0
- package/dist/react/useNameOf.js +32 -0
- package/dist/react/useServiceReading.d.ts +8 -0
- package/dist/react/useServiceReading.js +12 -2
- package/dist/web/index.d.ts +4 -2
- package/dist/web/index.js +4 -2
- package/dist/web/list/EntityList.d.ts +36 -177
- package/dist/web/list/EntityList.js +175 -536
- package/dist/web/list/entityList/choosing.d.ts +50 -0
- package/dist/web/list/entityList/choosing.js +77 -0
- package/dist/web/list/entityList/faces.d.ts +53 -0
- package/dist/web/list/entityList/faces.js +155 -0
- package/dist/web/list/entityList/grouping.d.ts +50 -0
- package/dist/web/list/entityList/grouping.js +97 -0
- package/dist/web/list/entityList/opening.d.ts +68 -0
- package/dist/web/list/entityList/opening.js +144 -0
- package/dist/web/list/entityList/paging.d.ts +30 -0
- package/dist/web/list/entityList/paging.js +39 -0
- package/dist/web/list/entityList/props.d.ts +173 -0
- package/dist/web/list/entityList/props.js +16 -0
- package/dist/web/list/entityList/rowActions.d.ts +31 -0
- package/dist/web/list/entityList/rowActions.js +40 -0
- package/dist/web/list/groups.d.ts +16 -0
- package/dist/web/list/groups.js +39 -0
- package/dist/web/list/useEntityList.d.ts +183 -0
- package/dist/web/list/useEntityList.js +225 -0
- package/dist/web/parts.d.ts +42 -0
- package/dist/web/parts.js +88 -0
- package/dist/web/record/lines.d.ts +3 -0
- package/dist/web/record/lines.js +75 -9
- package/dist/web/workspace/RecordScreen.d.ts +156 -0
- package/dist/web/workspace/RecordScreen.js +197 -0
- package/dist/web/workspace/SincproApp.d.ts +3 -1
- package/dist/web/workspace/SincproApp.js +22 -4
- package/dist/web/workspace/composer.js +1 -1
- package/dist/web/workspace/record.d.ts +4 -22
- package/dist/web/workspace/record.js +5 -70
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,11 +33,12 @@ be able to build it here, without asking us and without fighting us. So:
|
|
|
33
33
|
|
|
34
34
|
1. **Defaults, never cages.** Every piece comes in three levels, and any of them can be skipped:
|
|
35
35
|
|
|
36
|
-
| Level | What you write | Example
|
|
37
|
-
| ------------ | ------------------------------------------- |
|
|
38
|
-
| Declarative | names of fields and entities | `<EntityList listing={l} columns={["number", "state"]} />`
|
|
39
|
-
|
|
|
40
|
-
|
|
|
36
|
+
| Level | What you write | Example |
|
|
37
|
+
| ------------ | ------------------------------------------- | ------------------------------------------------------------------ |
|
|
38
|
+
| Declarative | names of fields and entities | `<EntityList listing={l} columns={["number", "state"]} />` |
|
|
39
|
+
| Parts | one region of the screen is yours | `<EntityList listing={l}><EntityList.Bar /><MyMap /></EntityList>` |
|
|
40
|
+
| Hooks | your own screen over our state | `useListing` + web-ui's `List` |
|
|
41
|
+
| Loose pieces | straight to criteria, the transport, web-ui | `transport.list(route, criteria)` |
|
|
41
42
|
|
|
42
43
|
Adding a piece obliges nothing else; removing it breaks nothing else.
|
|
43
44
|
|
|
@@ -272,7 +273,25 @@ const views = [
|
|
|
272
273
|
```
|
|
273
274
|
|
|
274
275
|
They are defaults, not cages: give your own screens, or keep `EntityRecord` and choose what it
|
|
275
|
-
shows.
|
|
276
|
+
shows. A screen of your own is written with the framework's **parts** — what is not written is
|
|
277
|
+
not there, a part written empty is the framework's, and a block of yours reads the record with
|
|
278
|
+
`useScreenRecord` (the list: `EntityList.*` and `useScreenListing`; see `docs/PATTERNS.md`):
|
|
279
|
+
|
|
280
|
+
```tsx
|
|
281
|
+
function InvoiceView(props: ViewProps) {
|
|
282
|
+
return (
|
|
283
|
+
<RecordScreen entity={invoices} {...props}>
|
|
284
|
+
<RecordScreen.Rail />
|
|
285
|
+
<RecordScreen.Paper>
|
|
286
|
+
<RecordScreen.Notices />
|
|
287
|
+
<InvoiceTotals /> {/* useScreenRecord(invoices) */}
|
|
288
|
+
<RecordScreen.Fields names={["customer_id", "due_date"]} />
|
|
289
|
+
<RecordScreen.Audit />
|
|
290
|
+
</RecordScreen.Paper>
|
|
291
|
+
</RecordScreen>
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
```
|
|
276
295
|
|
|
277
296
|
```ts
|
|
278
297
|
const views = [
|
|
@@ -683,54 +702,57 @@ find .next/static -name '*.map' -delete
|
|
|
683
702
|
Each answers one question, and each comes in the three levels — use the component, drop to the
|
|
684
703
|
hook and draw your own, or go straight to the loose piece.
|
|
685
704
|
|
|
686
|
-
| Question | Declarative
|
|
687
|
-
| -------------------------------- |
|
|
688
|
-
| Where is the data? | `entity()` (client-framework)
|
|
689
|
-
| The application's logic | its `Feature`s and `ApplicationService`s (client-framework)
|
|
690
|
-
| Read through a use case | its `Feature`s (client-framework)
|
|
691
|
-
| Read it on the server first | the same use case, before the page is drawn
|
|
692
|
-
| A record read on the server | `EntityRecord initial`
|
|
693
|
-
| What every use case runs with | `processContext`, `project.context` (client-framework)
|
|
694
|
-
| What happened, what broke | `./telemetry`, `./errors` (optional)
|
|
695
|
-
| What happened, on the server | `configureServerProcess` (`./telemetry/server`, optional)
|
|
696
|
-
| What broke, on the server | `reportRequestError` (`./errors/server`, optional)
|
|
697
|
-
| A page that broke | `RouteError`, in the route's error boundary
|
|
698
|
-
| What is each field? | `Meta` from the server, or `defineMeta`
|
|
699
|
-
| A value outside a model | —
|
|
700
|
-
| A file or a photo it holds | `EntityList`, `RecordField`: by its widget, as a `FileValue`
|
|
701
|
-
| A file given in the record | `RecordField` with `uploads`: `FileControl` (`DropZone`)
|
|
702
|
-
| Formatted text | `RecordField` (`widget: "html"`), `factsOf`: `RichTextControl`
|
|
703
|
-
| A person, read | `RecordField`, `factsOf`: `PersonValue` (`UserChip`)
|
|
704
|
-
| A choice's tag outside a list | `ChoiceTag`
|
|
705
|
-
| What is a record, at any size? | `cardOf`, `relationOf`
|
|
706
|
-
| How does a record look? | `presented(entity, { option, row, card, tile })`
|
|
707
|
-
| N records: search, filter, page | `EntityList`, `EntitySearchBar`
|
|
708
|
-
| A named slice (to collect, …) | `defineList` + `listView`
|
|
709
|
-
| A record's whole screen | `EntityRecord`, `entityView` without `record`
|
|
710
|
-
|
|
|
711
|
-
|
|
|
712
|
-
|
|
|
713
|
-
|
|
|
714
|
-
|
|
|
715
|
-
|
|
|
716
|
-
|
|
|
717
|
-
|
|
|
718
|
-
|
|
|
719
|
-
|
|
|
720
|
-
|
|
|
721
|
-
|
|
|
722
|
-
|
|
|
723
|
-
|
|
|
724
|
-
|
|
|
725
|
-
|
|
|
726
|
-
|
|
|
727
|
-
|
|
|
728
|
-
|
|
|
729
|
-
|
|
|
730
|
-
|
|
|
731
|
-
|
|
|
732
|
-
|
|
|
733
|
-
|
|
|
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
|
+
| Previous / next from a record | `EntityRecord` (from a list) | — | `placeOf`, `stepIn` (`Trail`) |
|
|
733
|
+
| How much each group adds up | `EntityList sums` | `useGroups` (`sums`) | `sumsOf`, `detailOf` |
|
|
734
|
+
| One record: read, edit, save | `RecordField`, `factsOf`, `RecordLines` | `useRecord` | `transport.one`, `transport.send` |
|
|
735
|
+
| Its lines: add, edit, remove | `RecordField name="lines"` (`LineItems`) | `useRecord` (`edit.cell`, `errorAt`) | `lineKey`, `editableLines`, `pathOf` |
|
|
736
|
+
| Its relations, inside it | `RelatedList` | `useRelated` | `relatedOf` |
|
|
737
|
+
| What other records hold of it | web-ui's `SmartButton` opening `entity.listRef(cut, name)` | `useCount` | `entity.listRef` (client-framework) |
|
|
738
|
+
| Choose one (literal search) | `EntityPicker`, `chooserIn` | `useLookup` | `lookupOf` + criteria's `matching` |
|
|
739
|
+
| Choose several (many2many) | `EntityTags` | `useLookup` (`values`) | `lookupOf` |
|
|
740
|
+
| A relation, from the model alone | `RecordField name="customer_id"` | `useEntityFor` | `relationFieldOf`, `entityFor` |
|
|
741
|
+
| Open it where it belongs | `RelatedRecord`, `entityView`, `EntityList openTargets` | — | `openIn`, `targetsFor`, `OpenInMenu` |
|
|
742
|
+
| Look at the set several ways | `EntityList views` (table, rows, board, sheet, tiles) | — | web-ui's `List.*` |
|
|
743
|
+
| Cross it by two fields | `EntityList pivot` | `usePivot` | `pivotOf` |
|
|
744
|
+
| Order by several fields | the bar's criteria builder | `listing.orderBy([...])` | criteria's `order` |
|
|
745
|
+
| Act on it (with a dry run) | `ServiceButton` (a use case), `CommandButton`, row commands | `useService`, `useCommand` | `transport.send` |
|
|
746
|
+
| What is chosen in a list | `EntityList selectable selection` | `useSelection` | `Selection`, `chosen`, `allMatching` (client-framework) |
|
|
747
|
+
| Act on each chosen one | `BatchProgress`, `selectionActions={(chosen) => …}` | `useBatchCommand` | `runBatch`, `keysOf` (client-framework), `sendRoute` |
|
|
748
|
+
| A list's actions, by the style | `EntityList actions`, `selectionActions` (`DockAction`s) | — | web-ui's `List.Dock`, `ViewStyleProvider` |
|
|
749
|
+
| A record's actions, by the style | `EntityRecord actions`, web-ui's `Record.Dock` | `useRecordLifecycleActions` | `DockedAction`, `ActionLook` |
|
|
750
|
+
| A use case or a Command, there | `ServiceButton`, `CommandButton` (as buttons) | `useServiceAction`/`useCommandAction` | — |
|
|
751
|
+
| Delete it | `EntityRecord` (`RecordLifecycle`) | `useRecordLifecycle` | `entity.delete`, `useRouteCommand` |
|
|
752
|
+
| Its trash | `EntityRecord` (`RecordLifecycle`), `listView(trashOf(entity))` | `useRecordLifecycle` | `entity.archive`, `entity.restore`, `trashOf` |
|
|
753
|
+
| Read again when it was written | every reading of this package, by itself | `useWrites` | `processChanges` (client-framework) |
|
|
754
|
+
| What happened to it | `Record.Activity` fed by `useHistory` | `useHistory` | `historyOf` |
|
|
755
|
+
| The application context | `SincproApp` | `useRecordInWorkspace`, `useFollowed` | `FrameworkProvider`, `webUiSkin` |
|
|
734
756
|
|
|
735
757
|
The rules behind them, in short:
|
|
736
758
|
|
package/dist/core/copy.d.ts
CHANGED
|
@@ -66,6 +66,8 @@ export type FrameworkCopy = {
|
|
|
66
66
|
create: string;
|
|
67
67
|
/** A record's one2many: the button that opens the form of a new related record. */
|
|
68
68
|
add: string;
|
|
69
|
+
/** Under a record's lines: choose several records, one new line for each. */
|
|
70
|
+
addMany: string;
|
|
69
71
|
/** The record's own `Delete` (its dry run is shown before it runs). */
|
|
70
72
|
delete: string;
|
|
71
73
|
/** Into the entity's trash (`Archive`): out of every reading, nothing lost. */
|
package/dist/core/copy.js
CHANGED
|
@@ -50,6 +50,7 @@ export const ENGLISH_FRAMEWORK_COPY = {
|
|
|
50
50
|
creating: (name) => (name ? `${name} · new` : "New"),
|
|
51
51
|
create: "New",
|
|
52
52
|
add: "Add",
|
|
53
|
+
addMany: "Add several…",
|
|
53
54
|
delete: "Delete",
|
|
54
55
|
archive: "Move to the trash",
|
|
55
56
|
restore: "Restore",
|
|
@@ -93,7 +94,7 @@ export const ENGLISH_FRAMEWORK_COPY = {
|
|
|
93
94
|
retry: "Retry",
|
|
94
95
|
kind: {
|
|
95
96
|
invalid: "The request is not valid",
|
|
96
|
-
unauthenticated: "
|
|
97
|
+
unauthenticated: "We could not identify you",
|
|
97
98
|
permission_denied: "You do not have access",
|
|
98
99
|
not_found: "It does not exist",
|
|
99
100
|
conflict: "Someone changed it first",
|
|
@@ -106,6 +107,7 @@ export const ENGLISH_FRAMEWORK_COPY = {
|
|
|
106
107
|
internal: "Something failed on the server",
|
|
107
108
|
},
|
|
108
109
|
next: {
|
|
110
|
+
unauthenticated: "If the session expired, sign in again.",
|
|
109
111
|
permission_denied: "Ask whoever administers it for access.",
|
|
110
112
|
not_found: "It may have been deleted, or the link is old.",
|
|
111
113
|
conflict: "Read it again before changing it.",
|
|
@@ -156,6 +158,7 @@ export const SPANISH_FRAMEWORK_COPY = {
|
|
|
156
158
|
creating: (name) => (name ? `${name} · nuevo` : "Nuevo"),
|
|
157
159
|
create: "Nuevo",
|
|
158
160
|
add: "Agregar",
|
|
161
|
+
addMany: "Agregar varios…",
|
|
159
162
|
delete: "Eliminar",
|
|
160
163
|
archive: "Mover a la papelera",
|
|
161
164
|
restore: "Restaurar",
|
|
@@ -199,7 +202,7 @@ export const SPANISH_FRAMEWORK_COPY = {
|
|
|
199
202
|
retry: "Reintentar",
|
|
200
203
|
kind: {
|
|
201
204
|
invalid: "El pedido no es válido",
|
|
202
|
-
unauthenticated: "
|
|
205
|
+
unauthenticated: "No pudimos identificarte",
|
|
203
206
|
permission_denied: "No tenés acceso",
|
|
204
207
|
not_found: "No existe",
|
|
205
208
|
conflict: "Alguien lo cambió antes",
|
|
@@ -212,6 +215,7 @@ export const SPANISH_FRAMEWORK_COPY = {
|
|
|
212
215
|
internal: "Algo falló en el servidor",
|
|
213
216
|
},
|
|
214
217
|
next: {
|
|
218
|
+
unauthenticated: "Si la sesión venció, hay que iniciarla de nuevo.",
|
|
215
219
|
permission_denied: "Pedí acceso a quien lo administra.",
|
|
216
220
|
not_found: "Puede que lo hayan eliminado, o el enlace es viejo.",
|
|
217
221
|
conflict: "Volvé a leerlo antes de cambiarlo.",
|
package/dist/core/explain.d.ts
CHANGED
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
* default `guidance` too — so the heading and the generic next step are the copy's, and the
|
|
16
16
|
* server's words are kept where only it knows them: what happened, and how to fix a refusal of
|
|
17
17
|
* its own. quipu drew its own box because the server's English headed every refusal.
|
|
18
|
+
*
|
|
19
|
+
* `unauthenticated` has a fixed next step too: the server's default guidance for it is English,
|
|
20
|
+
* and appended it mixed two languages in one sentence. Its heading does not assume an expired
|
|
21
|
+
* session — on a sign-in form a 401 answers the credentials just typed.
|
|
18
22
|
*/
|
|
19
23
|
export declare function explain(error: unknown): {
|
|
20
24
|
heading: string;
|
package/dist/core/explain.js
CHANGED
|
@@ -18,6 +18,10 @@ import { NotGrouped } from "./groups.js";
|
|
|
18
18
|
* default `guidance` too — so the heading and the generic next step are the copy's, and the
|
|
19
19
|
* server's words are kept where only it knows them: what happened, and how to fix a refusal of
|
|
20
20
|
* its own. quipu drew its own box because the server's English headed every refusal.
|
|
21
|
+
*
|
|
22
|
+
* `unauthenticated` has a fixed next step too: the server's default guidance for it is English,
|
|
23
|
+
* and appended it mixed two languages in one sentence. Its heading does not assume an expired
|
|
24
|
+
* session — on a sign-in form a 401 answers the credentials just typed.
|
|
21
25
|
*/
|
|
22
26
|
export function explain(error) {
|
|
23
27
|
const copy = frameworkCopy().failure;
|
package/dist/core/groups.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AnyRecord, type Bucket, type Criteria, type Measure, type Sort } from "@sincpro/criteria";
|
|
2
2
|
import type { GroupLevel } from "./list.js";
|
|
3
3
|
/**
|
|
4
4
|
* Whether an answer to a grouped question holds groups — each with how many records it holds
|
|
@@ -55,6 +55,8 @@ export type GroupPage = {
|
|
|
55
55
|
export declare function levelQuestion<T extends AnyRecord>(base: Criteria<T>, level: GroupLevel, page: GroupPage, options?: {
|
|
56
56
|
measures?: Readonly<Record<string, Measure>>;
|
|
57
57
|
counted?: boolean;
|
|
58
|
+
/** How the groups come back; only what orders THIS level is asked (see below). */
|
|
59
|
+
order?: readonly Sort<T>[];
|
|
58
60
|
}): Criteria<T>;
|
|
59
61
|
/**
|
|
60
62
|
* The question for the rows of a group of the deepest level: its own criteria, a page of rows.
|
package/dist/core/groups.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {} from "@sincpro/criteria";
|
|
1
2
|
import { frameworkCopy } from "./copy.js";
|
|
2
3
|
/**
|
|
3
4
|
* Whether an answer to a grouped question holds groups — each with how many records it holds
|
|
@@ -40,6 +41,9 @@ export class NotGrouped extends Error {
|
|
|
40
41
|
this.name = "NotGrouped";
|
|
41
42
|
}
|
|
42
43
|
}
|
|
44
|
+
/** What every group answers without being asked — criteria's `GROUP_COUNT`, which its public
|
|
45
|
+
* entry does not export. */
|
|
46
|
+
const GROUP_COUNT = "count";
|
|
43
47
|
/**
|
|
44
48
|
* The question for ONE level of groups — the first page of it, or the next.
|
|
45
49
|
*
|
|
@@ -62,6 +66,11 @@ export function levelQuestion(base, level, page, options = {}) {
|
|
|
62
66
|
// question that made it (its empty grouping, its page of no rows).
|
|
63
67
|
const { pagination: _page, grouping: _grouping, count: _count, ...own } = base;
|
|
64
68
|
const offset = page.offset ?? 0;
|
|
69
|
+
// A level's groups are ordered by its own field, a figure it adds up or its count: any other
|
|
70
|
+
// name is refused by the server, so another level's sort is not sent with this one.
|
|
71
|
+
const order = (options.order ?? []).filter((one) => one.field === level.field ||
|
|
72
|
+
one.field === GROUP_COUNT ||
|
|
73
|
+
(options.measures !== undefined && one.field in options.measures));
|
|
65
74
|
return {
|
|
66
75
|
...own,
|
|
67
76
|
count: options.counted === true ? "exact" : "none",
|
|
@@ -70,6 +79,7 @@ export function levelQuestion(base, level, page, options = {}) {
|
|
|
70
79
|
...(options.measures === undefined || Object.keys(options.measures).length === 0
|
|
71
80
|
? {}
|
|
72
81
|
: { measures: { ...options.measures } }),
|
|
82
|
+
...(order.length === 0 ? {} : { order: order.map((one) => ({ ...one })) }),
|
|
73
83
|
pagination: {
|
|
74
84
|
limit: page.limit,
|
|
75
85
|
...(offset > 0 ? { strategy: { rows: offset } } : {}),
|
package/dist/core/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export { FILE_WIDGETS, holdsFile, type Published, renditionUrl, type RenditionVa
|
|
|
16
16
|
export { type FormLayout, formOf } from "./form.js";
|
|
17
17
|
export { areGroups, groupKeyOf, type GroupPage, isGroupedAnswer, levelQuestion, nextGroups, NotGrouped, rowsQuestion, } from "./groups.js";
|
|
18
18
|
export { FACT_TONES, type FactTone, type HistoryChange, type HistoryEntry, historyOf, toneOfFact, } from "./history.js";
|
|
19
|
-
export { addingOf, type AddingRule, blankLine, type Declared, editableLines, isReference, type LineAdding, lineFields, lineKey, linesAnswered, moved, sameLine, writtenInCell, } from "./lines.js";
|
|
19
|
+
export { addingOf, type AddingRule, addManyOf, blankLine, type Declared, editableLines, isReference, type LineAdding, lineFields, lineKey, linesAnswered, moved, sameLine, writtenInCell, } from "./lines.js";
|
|
20
20
|
export { CHOOSE_MANY, choosesMany, defineList, type GroupLevel, isList, type ListDefinition, listingAsk, type ListingQuestion, type ListSpec, type NamedFilter, readListing, scopeOf, trashOf, } from "./list.js";
|
|
21
21
|
export { lookupOf, type LookupOption } from "./lookup.js";
|
|
22
22
|
export { detailOf, measuresOf, sumsOf, type Total, totalOf, } from "./measure.js";
|
package/dist/core/index.js
CHANGED
|
@@ -16,7 +16,7 @@ export { FILE_WIDGETS, holdsFile, renditionUrl, sendFile, storedFileOf, uploadRe
|
|
|
16
16
|
export { formOf } from "./form.js";
|
|
17
17
|
export { areGroups, groupKeyOf, isGroupedAnswer, levelQuestion, nextGroups, NotGrouped, rowsQuestion, } from "./groups.js";
|
|
18
18
|
export { FACT_TONES, historyOf, toneOfFact, } from "./history.js";
|
|
19
|
-
export { addingOf, blankLine, editableLines, isReference, lineFields, lineKey, linesAnswered, moved, sameLine, writtenInCell, } from "./lines.js";
|
|
19
|
+
export { addingOf, addManyOf, blankLine, editableLines, isReference, lineFields, lineKey, linesAnswered, moved, sameLine, writtenInCell, } from "./lines.js";
|
|
20
20
|
export { CHOOSE_MANY, choosesMany, defineList, isList, listingAsk, readListing, scopeOf, trashOf, } from "./list.js";
|
|
21
21
|
export { lookupOf } from "./lookup.js";
|
|
22
22
|
export { detailOf, measuresOf, sumsOf, totalOf, } from "./measure.js";
|
package/dist/core/lines.d.ts
CHANGED
|
@@ -40,6 +40,16 @@ export declare function lineFields(definition: Meta | null): string[];
|
|
|
40
40
|
* An embedded value or anything the table has no control for needs the dialog's room.
|
|
41
41
|
*/
|
|
42
42
|
export declare function writtenInCell(definition: Meta, field: string, declared: Declared): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* The many2one «Add several…» fills — one new line per record chosen —: the one the screen names
|
|
45
|
+
* (`asked`), else the line's ONLY to-one relation a person writes whose entity the application
|
|
46
|
+
* declared (a product). `false` from the screen, or none or several to choose from: none — two
|
|
47
|
+
* candidates are a question only the screen can answer.
|
|
48
|
+
*
|
|
49
|
+
* addManyOf(lineMeta, declared) // "product_code"
|
|
50
|
+
* addManyOf(lineMeta, declared, "warehouse_id") // the screen's
|
|
51
|
+
*/
|
|
52
|
+
export declare function addManyOf(definition: Meta | null, declared: Declared, asked?: string | false): string | undefined;
|
|
43
53
|
/** What decides where a line is written, besides its model. */
|
|
44
54
|
export type AddingRule = {
|
|
45
55
|
/** Whether the application declared the entity a relation points at. */
|
package/dist/core/lines.js
CHANGED
|
@@ -113,6 +113,30 @@ export function writtenInCell(definition, field, declared) {
|
|
|
113
113
|
return !relation.many && declared(relation.target);
|
|
114
114
|
return CELL_TYPES.has(definition.fields[field]?.type ?? "");
|
|
115
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* The many2one «Add several…» fills — one new line per record chosen —: the one the screen names
|
|
118
|
+
* (`asked`), else the line's ONLY to-one relation a person writes whose entity the application
|
|
119
|
+
* declared (a product). `false` from the screen, or none or several to choose from: none — two
|
|
120
|
+
* candidates are a question only the screen can answer.
|
|
121
|
+
*
|
|
122
|
+
* addManyOf(lineMeta, declared) // "product_code"
|
|
123
|
+
* addManyOf(lineMeta, declared, "warehouse_id") // the screen's
|
|
124
|
+
*/
|
|
125
|
+
export function addManyOf(definition, declared, asked) {
|
|
126
|
+
if (definition === null || asked === false)
|
|
127
|
+
return undefined;
|
|
128
|
+
const candidates = lineFields(definition).filter((field) => {
|
|
129
|
+
const relation = relationFieldOf(definition, field);
|
|
130
|
+
return (relation !== undefined &&
|
|
131
|
+
!relation.many &&
|
|
132
|
+
relation.key === field &&
|
|
133
|
+
definition.fields[field]?.readonly !== true &&
|
|
134
|
+
declared(relation.target));
|
|
135
|
+
});
|
|
136
|
+
if (asked !== undefined)
|
|
137
|
+
return candidates.includes(asked) ? asked : undefined;
|
|
138
|
+
return candidates.length === 1 ? candidates[0] : undefined;
|
|
139
|
+
}
|
|
116
140
|
/**
|
|
117
141
|
* How «Agregar una línea» adds: in the table when every column a person may write fits a cell
|
|
118
142
|
* and nothing required is left out of the columns; in the dialog otherwise — a row that cannot
|
package/dist/core/list.d.ts
CHANGED
|
@@ -59,6 +59,18 @@ export type ListDefinition<T extends AnyRecord = AnyRecord> = {
|
|
|
59
59
|
views?: readonly ("table" | "rows" | "board" | "tiles" | "sheet" | "pivot")[];
|
|
60
60
|
/** Grouped from the start — the server counts the groups. */
|
|
61
61
|
groupBy?: readonly GroupLevel[];
|
|
62
|
+
/**
|
|
63
|
+
* How many groups of `groupBy`'s first level start open — each reading ONE page of what it
|
|
64
|
+
* holds, so the ceiling stays. Without it every group starts closed: right for a million rows,
|
|
65
|
+
* wrong for a directory of six bodies.
|
|
66
|
+
*/
|
|
67
|
+
open?: number;
|
|
68
|
+
/**
|
|
69
|
+
* The order the groups come in (criteria's `grouping.order`): by a level's field, by a figure
|
|
70
|
+
* the list adds up, or by `count`. A sort that names none of them for a level is left out of
|
|
71
|
+
* that level's question — the server would refuse it. Without it, by the group's value.
|
|
72
|
+
*/
|
|
73
|
+
groupOrder?: readonly Sort<T>[];
|
|
62
74
|
/** The fields «Group by» offers, in this order — among those the model lets split the set. */
|
|
63
75
|
groupable?: readonly string[];
|
|
64
76
|
/** The entity's trash (`trashOf`): each row offers «Restore» when the entity declares it. */
|
package/dist/react/context.d.ts
CHANGED
|
@@ -105,4 +105,33 @@ export declare function useFramework(): FrameworkContextValue;
|
|
|
105
105
|
export declare function useFrameworkIfAny(): FrameworkContextValue | null;
|
|
106
106
|
/** The declared entity a relation points at (`"Cliente"`), or `undefined`. */
|
|
107
107
|
export declare function useEntityFor(target: string | undefined): Entity | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* The models one part of the application brings — a face, a lazily loaded bounded context —:
|
|
110
|
+
* their entities, their definitions and their facts, added to the provider's for the screens
|
|
111
|
+
* under it.
|
|
112
|
+
*
|
|
113
|
+
* <FrameworkProvider transport={transport}> ← the public site: none
|
|
114
|
+
* <ModelDefinitions metas={metasOf(billing)} events={eventMetasOf(billing)}>
|
|
115
|
+
* <Backoffice /> ← loads them with its code
|
|
116
|
+
* </ModelDefinitions>
|
|
117
|
+
* </FrameworkProvider>
|
|
118
|
+
*
|
|
119
|
+
* Context: the definitions were the provider's only, so an application that serves a public site
|
|
120
|
+
* and a backoffice from one provider shipped every model to every page (quipu: 1.1 MB on its home
|
|
121
|
+
* page, read by nobody there). Brought here, they travel with the code that needs them.
|
|
122
|
+
*
|
|
123
|
+
* `metas` go into the process's one store — what the provider learned from the server is never
|
|
124
|
+
* replaced by a snapshot written at build time —, so once a face brought them every screen knows
|
|
125
|
+
* them, as if the server had sent them. `entities` (what a relation is resolved to) and `events`
|
|
126
|
+
* (the facts of a history) are added over the provider's for the screens under this one only.
|
|
127
|
+
*/
|
|
128
|
+
export declare function ModelDefinitions({ entities, metas, events, children, }: {
|
|
129
|
+
/** Its entities: a relation of one of its models is drawn with them. */
|
|
130
|
+
entities?: readonly Entity[] | undefined;
|
|
131
|
+
/** Each entity's model by its key (`metasOf(contract)`): drawn with no request for it. */
|
|
132
|
+
metas?: Readonly<Record<string, Meta>> | undefined;
|
|
133
|
+
/** Each domain event's definition by its name (`eventMetasOf(contract)`). */
|
|
134
|
+
events?: Readonly<Record<string, Meta>> | undefined;
|
|
135
|
+
children?: ReactNode;
|
|
136
|
+
}): import("react").JSX.Element;
|
|
108
137
|
export {};
|
package/dist/react/context.js
CHANGED
|
@@ -108,3 +108,49 @@ export function useEntityFor(target) {
|
|
|
108
108
|
const { entities, metas } = useFramework();
|
|
109
109
|
return target === undefined ? undefined : entityFor(entities, target, metas.get);
|
|
110
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* The models one part of the application brings — a face, a lazily loaded bounded context —:
|
|
113
|
+
* their entities, their definitions and their facts, added to the provider's for the screens
|
|
114
|
+
* under it.
|
|
115
|
+
*
|
|
116
|
+
* <FrameworkProvider transport={transport}> ← the public site: none
|
|
117
|
+
* <ModelDefinitions metas={metasOf(billing)} events={eventMetasOf(billing)}>
|
|
118
|
+
* <Backoffice /> ← loads them with its code
|
|
119
|
+
* </ModelDefinitions>
|
|
120
|
+
* </FrameworkProvider>
|
|
121
|
+
*
|
|
122
|
+
* Context: the definitions were the provider's only, so an application that serves a public site
|
|
123
|
+
* and a backoffice from one provider shipped every model to every page (quipu: 1.1 MB on its home
|
|
124
|
+
* page, read by nobody there). Brought here, they travel with the code that needs them.
|
|
125
|
+
*
|
|
126
|
+
* `metas` go into the process's one store — what the provider learned from the server is never
|
|
127
|
+
* replaced by a snapshot written at build time —, so once a face brought them every screen knows
|
|
128
|
+
* them, as if the server had sent them. `entities` (what a relation is resolved to) and `events`
|
|
129
|
+
* (the facts of a history) are added over the provider's for the screens under this one only.
|
|
130
|
+
*/
|
|
131
|
+
export function ModelDefinitions({ entities, metas, events, children, }) {
|
|
132
|
+
const above = useFramework();
|
|
133
|
+
// Added while rendering, before the screens under it render: they read the store as they draw.
|
|
134
|
+
const brought = useRef(undefined);
|
|
135
|
+
if (metas !== undefined && brought.current !== metas) {
|
|
136
|
+
for (const [key, meta] of Object.entries(metas))
|
|
137
|
+
if (above.metas.get(key) === undefined)
|
|
138
|
+
above.metas.set(key, meta);
|
|
139
|
+
brought.current = metas;
|
|
140
|
+
}
|
|
141
|
+
const value = useMemo(() => entities === undefined && events === undefined
|
|
142
|
+
? above
|
|
143
|
+
: {
|
|
144
|
+
...above,
|
|
145
|
+
...(entities === undefined
|
|
146
|
+
? {}
|
|
147
|
+
: {
|
|
148
|
+
entities: [
|
|
149
|
+
...above.entities,
|
|
150
|
+
...entities.filter((one) => !above.entities.includes(one)),
|
|
151
|
+
],
|
|
152
|
+
}),
|
|
153
|
+
...(events === undefined ? {} : { events: { ...above.events, ...events } }),
|
|
154
|
+
}, [above, entities, events]);
|
|
155
|
+
return _jsx(FrameworkContext.Provider, { value: value, children: children });
|
|
156
|
+
}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* DOM, no design system — so a screen can drop `EntityList` and still keep it. `make doctor`
|
|
4
4
|
* keeps it that way.
|
|
5
5
|
*/
|
|
6
|
-
export { FrameworkProvider, useEntityFor, useFramework, } from "./context.js";
|
|
6
|
+
export { FrameworkProvider, ModelDefinitions, useEntityFor, useFramework, } from "./context.js";
|
|
7
7
|
export { type ListScope, ListScopeProvider, useListScope, } from "./scope.js";
|
|
8
8
|
export { BATCH_LIMIT, type BatchCommandState, useBatchCommand, } from "./useBatchCommand.js";
|
|
9
9
|
export { type AnswerOf, type CommandState, type Rehearsal, useCommand, useRouteCommand, } from "./useCommand.js";
|
|
@@ -13,7 +13,7 @@ export { type Groups, useGroups } from "./useGroups.js";
|
|
|
13
13
|
export { useHistory } from "./useHistory.js";
|
|
14
14
|
export { type Listing, type ListingOptions, type Paging, useListing, } from "./useListing.js";
|
|
15
15
|
export { excluding, type Lookup, useLookup } from "./useLookup.js";
|
|
16
|
-
export { useNameOf } from "./useNameOf.js";
|
|
16
|
+
export { useNameOf, useNamesOf } from "./useNameOf.js";
|
|
17
17
|
export { type PivotAxes, type PivotReading, usePivot, } from "./usePivot.js";
|
|
18
18
|
export { type Editing, type RecordReading, type RecordState, useRecord, } from "./useRecord.js";
|
|
19
19
|
export { type LifecycleAction, type RecordLifecycleActions, useRecordLifecycle, } from "./useRecordLifecycle.js";
|
package/dist/react/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* DOM, no design system — so a screen can drop `EntityList` and still keep it. `make doctor`
|
|
4
4
|
* keeps it that way.
|
|
5
5
|
*/
|
|
6
|
-
export { FrameworkProvider, useEntityFor, useFramework, } from "./context.js";
|
|
6
|
+
export { FrameworkProvider, ModelDefinitions, useEntityFor, useFramework, } from "./context.js";
|
|
7
7
|
export { ListScopeProvider, useListScope, } from "./scope.js";
|
|
8
8
|
export { BATCH_LIMIT, useBatchCommand, } from "./useBatchCommand.js";
|
|
9
9
|
export { useCommand, useRouteCommand, } from "./useCommand.js";
|
|
@@ -13,7 +13,7 @@ export { useGroups } from "./useGroups.js";
|
|
|
13
13
|
export { useHistory } from "./useHistory.js";
|
|
14
14
|
export { useListing, } from "./useListing.js";
|
|
15
15
|
export { excluding, useLookup } from "./useLookup.js";
|
|
16
|
-
export { useNameOf } from "./useNameOf.js";
|
|
16
|
+
export { useNameOf, useNamesOf } from "./useNameOf.js";
|
|
17
17
|
export { usePivot, } from "./usePivot.js";
|
|
18
18
|
export { useRecord, } from "./useRecord.js";
|
|
19
19
|
export { useRecordLifecycle, } from "./useRecordLifecycle.js";
|