@sincpro/web-framework 3.18.0 → 3.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +83 -54
  2. package/dist/core/copy.d.ts +14 -0
  3. package/dist/core/copy.js +57 -2
  4. package/dist/core/edit.d.ts +13 -0
  5. package/dist/core/edit.js +14 -0
  6. package/dist/core/explain.d.ts +4 -0
  7. package/dist/core/explain.js +4 -0
  8. package/dist/core/export.d.ts +29 -0
  9. package/dist/core/export.js +47 -0
  10. package/dist/core/groups.d.ts +3 -1
  11. package/dist/core/groups.js +7 -0
  12. package/dist/core/index.d.ts +4 -3
  13. package/dist/core/index.js +4 -3
  14. package/dist/core/lines.d.ts +10 -0
  15. package/dist/core/lines.js +24 -0
  16. package/dist/core/list.d.ts +12 -0
  17. package/dist/react/context.d.ts +44 -1
  18. package/dist/react/context.js +50 -1
  19. package/dist/react/index.d.ts +4 -2
  20. package/dist/react/index.js +4 -2
  21. package/dist/react/useCounts.d.ts +23 -0
  22. package/dist/react/useCounts.js +43 -0
  23. package/dist/react/useGroups.js +38 -5
  24. package/dist/react/useNameOf.d.ts +13 -0
  25. package/dist/react/useNameOf.js +32 -0
  26. package/dist/react/usePeopleOf.d.ts +14 -0
  27. package/dist/react/usePeopleOf.js +35 -0
  28. package/dist/react/useRecord.js +2 -2
  29. package/dist/react/useServiceReading.d.ts +8 -0
  30. package/dist/react/useServiceReading.js +12 -2
  31. package/dist/web/index.d.ts +4 -2
  32. package/dist/web/index.js +4 -2
  33. package/dist/web/list/EntityList.d.ts +36 -177
  34. package/dist/web/list/EntityList.js +175 -536
  35. package/dist/web/list/entityList/choosing.d.ts +50 -0
  36. package/dist/web/list/entityList/choosing.js +77 -0
  37. package/dist/web/list/entityList/faces.d.ts +53 -0
  38. package/dist/web/list/entityList/faces.js +155 -0
  39. package/dist/web/list/entityList/grouping.d.ts +50 -0
  40. package/dist/web/list/entityList/grouping.js +97 -0
  41. package/dist/web/list/entityList/opening.d.ts +68 -0
  42. package/dist/web/list/entityList/opening.js +149 -0
  43. package/dist/web/list/entityList/paging.d.ts +30 -0
  44. package/dist/web/list/entityList/paging.js +39 -0
  45. package/dist/web/list/entityList/props.d.ts +174 -0
  46. package/dist/web/list/entityList/props.js +16 -0
  47. package/dist/web/list/entityList/rowActions.d.ts +31 -0
  48. package/dist/web/list/entityList/rowActions.js +40 -0
  49. package/dist/web/list/export.d.ts +13 -0
  50. package/dist/web/list/export.js +61 -0
  51. package/dist/web/list/groups.d.ts +16 -0
  52. package/dist/web/list/groups.js +39 -0
  53. package/dist/web/list/useEntityList.d.ts +183 -0
  54. package/dist/web/list/useEntityList.js +225 -0
  55. package/dist/web/parts.d.ts +42 -0
  56. package/dist/web/parts.js +88 -0
  57. package/dist/web/record/lines.d.ts +3 -0
  58. package/dist/web/record/lines.js +75 -9
  59. package/dist/web/workspace/RecordScreen.d.ts +206 -0
  60. package/dist/web/workspace/RecordScreen.js +251 -0
  61. package/dist/web/workspace/SincproApp.d.ts +14 -2
  62. package/dist/web/workspace/SincproApp.js +27 -9
  63. package/dist/web/workspace/composer.js +1 -1
  64. package/dist/web/workspace/record.d.ts +21 -27
  65. package/dist/web/workspace/record.js +29 -77
  66. package/dist/web/workspace/workspace.d.ts +2 -0
  67. package/dist/web/workspace/workspace.js +1 -1
  68. package/package.json +7 -7
package/dist/web/index.js CHANGED
@@ -5,7 +5,7 @@ export { attachmentOf } from "./files.js";
5
5
  export { BatchProgress } from "./list/BatchProgress.js";
6
6
  export { aggregateOf, columnsOf, } from "./list/columns.js";
7
7
  export { actionsOf } from "./list/dock.js";
8
- export { EntityList, } from "./list/EntityList.js";
8
+ export { EntityList, useScreenListing, } from "./list/EntityList.js";
9
9
  export { EntitySearchBar } from "./list/EntitySearchBar.js";
10
10
  export { groupableOf, pilesOf } from "./list/groups.js";
11
11
  export { OpenInMenu } from "./list/openIn.js";
@@ -15,6 +15,7 @@ export { findChoices, modelLoader, recordsBrowser, RecordsBrowserProvider, recor
15
15
  export { useReorder } from "./list/reorder.js";
16
16
  export { useRowCommands, } from "./list/rowCommands.js";
17
17
  export { facetsOf, modelOf } from "./list/search.js";
18
+ export { useEntityList, } from "./list/useEntityList.js";
18
19
  export {} from "./record/ActionButton.js";
19
20
  export { askFormOf, unansweredOf, } from "./record/ask.js";
20
21
  export { ChoiceTag, choiceTagOf, } from "./record/choice.js";
@@ -38,7 +39,8 @@ export { Refused } from "./Refused.js";
38
39
  export { RouteError } from "./RouteError.js";
39
40
  export { entityView, listView, } from "./workspace/composer.js";
40
41
  export { openIn, openOptions, RECORD_SIZE, RelatedRecord, targetsFor, } from "./workspace/open.js";
41
- export { EntityRecord, useRecordScreen, } from "./workspace/record.js";
42
+ export { useRecordScreen, } from "./workspace/record.js";
43
+ export { EntityRecord, RecordScreen, useScreenColumns, useScreenRecord, } from "./workspace/RecordScreen.js";
42
44
  export { SincproApp } from "./workspace/SincproApp.js";
43
45
  export { webUiSkin } from "./workspace/skin.js";
44
46
  export { chooserIn, useFollowed, useRecordInWorkspace, } from "./workspace/workspace.js";
@@ -1,183 +1,42 @@
1
- import { type CommandBodies } from "@sincpro/client-framework";
2
- import { type AnyRecord } from "@sincpro/criteria";
3
- import { type WorkspaceApi } from "@sincpro/web-composer";
4
- import { type GroupLevel, type NamedFilter } from "../../core/list.js";
1
+ import type { CommandBodies, Entity } from "@sincpro/client-framework";
2
+ import type { AnyRecord } from "@sincpro/criteria";
5
3
  import type { Listing } from "../../react/useListing.js";
6
- import { type ListSelection } from "../../react/useSelection.js";
7
- import { type ScreenActions } from "./dock.js";
8
- import { type RowCommand } from "./rowCommands.js";
9
- import { type ListCrumb, type ListEmpty, type ListPresentProps, type ListSet, type OpenTarget, type RowAction, type YesNoColumn } from "@sincpro/web-ui";
4
+ import { type EntityListProps, type EntityListState } from "./useEntityList.js";
5
+ import { type NoProps } from "../parts.js";
10
6
  import { type ReactNode } from "react";
7
+ export type { EntityEmpty, EntityFace, EntityListProps, NamedFilter, View, } from "./useEntityList.js";
11
8
  /**
12
- * A whole collection from a `Listing`: the bar, the search, the set in the views it offers,
13
- * and the way through it — the screen forge wrote five times by hand, written once.
9
+ * The listing on the list around it, for a block the application writes inside an
10
+ * `EntityList` — a map of the same set, a summary over its page. The entity is only its type.
14
11
  *
15
- * Context: this is the ready-made composition, not a cage. Everything it does is reachable on
16
- * its own — `columnsOf` for the columns, `EntitySearchBar` for the search, `useListing` for the
17
- * state — so a screen that needs its own bar or a second table writes `List` with those.
18
- *
19
- * Built for sets of any size: in `pages` mode (the default) the screen holds ONE page and walks
20
- * the server's cursor, so a million rows cost what fifty do; in `more` mode it stops growing at
21
- * its ceiling and asks to narrow the search. Nothing is filtered, ordered or counted on the
22
- * page: every gesture is a question to the server.
23
- *
24
- * Grouping obeys the same rule: «Group by» in the search bar asks the SERVER for the groups of
25
- * the whole set (`useGroups`), drawn as piles with their real count; a group's rows are read
26
- * when it is opened, and «See N more» reads its next page on the server's cursor. Since web-ui
27
- * 1.4 every face draws piles counted elsewhere — the table too — so grouping keeps the face.
28
- *
29
- * Where a record opens is the composer's question: with `api`, a row opens the page and the
30
- * identity column is the composer's `RecordLink` (peek, side panel, window); without it, the
31
- * screen passes `onOpen`.
12
+ * function InvoicesMap() {
13
+ * const invoices = useScreenListing(facturas);
14
+ * return <Map points={invoices.rows.map(pointOf)} />;
15
+ * }
32
16
  */
33
- export type { NamedFilter };
34
- export type EntityListProps<T extends AnyRecord, C extends CommandBodies = CommandBodies> = {
35
- listing: Listing<T, C>;
36
- /**
37
- * The workspace this list is a view of. With it, a row opens its record as a page, the
38
- * identity column is the composer's `RecordLink` (peek, side panel, window on hover) and the
39
- * breadcrumb is the composer's — nothing for the screen to write.
40
- */
41
- api?: WorkspaceApi;
42
- /** The fields shown, in order. Without it, the named list's, or every scalar field. */
43
- columns?: readonly string[];
44
- /** The cells that are not plain text: a link, a tag. Memoise it: compared by identity. */
45
- cells?: Readonly<Partial<Record<string, (row: T) => ReactNode>>>;
46
- /**
47
- * How a yes/no column reads, by field — web-ui's `yesNo`: `check` (the default: ✓ and
48
- * nothing), `icon` (a green ✓ and a quiet ✕), `word` — or a `checkbox` / `switch` that
49
- * changes it from the list with `onToggle` (an update, a Command). Memoise it.
50
- *
51
- * yesNo={{ published: { look: "switch", onToggle: (course, on) => publish.run(course.id, on) } }}
52
- */
53
- yesNo?: Readonly<Partial<Record<string, YesNoColumn<T>>>>;
54
- /**
55
- * The ways to look at the set, the first one shown: `table` (columns), `rows` (a name and
56
- * its facts, what a narrow panel wants), `board` (cards), `sheet` (a spreadsheet, every
57
- * cell a value — web-ui's, windowed) and `tiles` (a grid of pictures — a till's products, a
58
- * shop's items; asked for, never offered by itself: a set of invoices has no picture). The
59
- * same set, the same search, the same page in each. Without it, a named list's; else the
60
- * first four on a screen, and the table (rows when narrow) inside a record. The id of one
61
- * of `faces` opens on that face.
62
- */
63
- views?: readonly (View | (string & {}))[];
64
- /**
65
- * The set crossed by two fields — `{ rows: "state", columns: "payment" }` — counted and added
66
- * up by the server (`usePivot`), offered as the `pivot` face. Only while it is on screen does
67
- * it ask; never folded from the page.
68
- */
69
- pivot?: {
70
- rows: string | GroupLevel;
71
- columns: string | GroupLevel;
72
- /** What each crossing adds up. Without it, the figures the model computes. */
73
- measures?: readonly string[];
74
- };
75
- /** Without it, the model's own name. */
76
- title?: string;
77
- description?: string;
78
- crumbs?: readonly ListCrumb[];
79
- /**
80
- * What the list starts — «Importar», «Exportar ▸» —, beside «Nuevo». As data (`DockAction`s)
81
- * the application's view style draws them with «Nuevo»: the bar's buttons in `traditional`,
82
- * one pill floating at the bottom in `modern` (web-ui's `ViewStyleProvider`). A node drawn
83
- * by hand stays in the bar.
84
- */
85
- actions?: ScreenActions;
86
- onOpen?: (row: T) => void;
87
- onPeek?: (row: T) => void;
88
- /**
89
- * Where a row's record may open besides a press (the page): a look (👁), a modal, beside, a
90
- * window — offered in «Abrir en…» by the row's name. With `api`, everywhere the workspace
91
- * allows from here (`targetsFor`: no modal from inside a modal); `[]` or a few restrict it.
92
- */
93
- openTargets?: readonly OpenTarget[];
94
- /** Open a row's record there — without `api`, how a screen (a one2many) places it. */
95
- onOpenIn?: (row: T, to: OpenTarget) => void;
96
- /**
97
- * What an empty list says. A text is its sentence; an object is web-ui's empty (2.14) — a
98
- * `title`, an `icon` or the application's `illustration`, an `action` — for a list that IS the
99
- * screen («Todavía no hay facturas» with a button to create one). What it leaves out is the
100
- * framework's words, and `whenFiltered` is what it says when a search emptied it.
101
- */
102
- empty?: string | EntityEmpty;
103
- /**
104
- * `"bar"` (the default) is the full search bar with the criteria builder; `"box"` is one
105
- * text box over the entity's search template — a chooser, a narrow panel; `false` is none.
106
- * Both ask the server on Enter, never per keystroke: a table is searched on purpose.
107
- */
108
- search?: "bar" | "box" | false;
109
- /**
110
- * The bar remembers, in this browser, the last searches put on this list, and offers them
111
- * when it takes the focus empty («Recientes»). `true` keeps them under the list's key (a
112
- * named list's, else its entity's); a text, under that name — one per tenant, say. Off by
113
- * default: what was searched may name a customer, and whether a browser may keep it is the
114
- * application's call.
115
- */
116
- recent?: boolean | string;
117
- /** What each group adds up when the list is grouped — «Total 1.204.933,00» in its header,
118
- * summed by the server over every row of it. Without it, the figures the model computes
119
- * (read-only exact numbers, `sumsOf`); `false` adds nothing up. */
120
- sums?: readonly string[] | false;
121
- /** The cuts this list offers by name: «sólo pagadas», «vencidas». */
122
- filters?: readonly NamedFilter<T>[];
123
- /** The fields the search bar offers to look a typed text up in. Without it, the list
124
- * definition's, else the entity's search template's, else its display (`facetsOf`). */
125
- facets?: readonly string[];
126
- /** The fields «Group by» offers, in this order — among those the model lets split the set.
127
- * Without it, the list definition's, else every one the model does. */
128
- groupable?: readonly string[];
129
- /**
130
- * Rows can be ticked — and, past the page, «Elegir los 187 que coinciden». With `api`, what is
131
- * chosen is PUBLISHED to the workspace (`api.select`): a panel beside it follows the selection
132
- * without knowing this list.
133
- */
134
- selectable?: boolean;
135
- /** The selection, held by the screen (`useSelection(listing)`): read and set from outside the
136
- * list. Without it the list holds its own. */
137
- selection?: ListSelection<T>;
138
- /** What to do with what is chosen, while something is — handed the selection to act on it
139
- * (`useBatchCommand`). As data, the view style draws it: in the bar in place of the search
140
- * in `traditional`, a pill floating at the bottom in `modern` («3 elegidas ✕ · Confirmar»).
141
- * Giving it makes the rows choosable: `selectable` is not needed with it. */
142
- selectionActions?: ScreenActions | ((selection: ListSelection<T>) => ScreenActions);
143
- /** The list is a FIELD of a record — its lines, its members — and not a screen. */
144
- embedded?: boolean;
145
- /**
146
- * With `api` and an entity that declares `create`, the bar offers «New», which opens the
147
- * record's form with no id (`entity.newRef()`). `false` hides it — a list of what only a
148
- * Command produces, or a caller who may not create.
149
- */
150
- create?: boolean;
151
- /**
152
- * The entity's Commands offered on each row («Confirmar»), sent with their idempotency key;
153
- * the list is read again when one is done (`useRowCommands`).
154
- */
155
- commands?: readonly RowCommand<T, C>[];
156
- /** Any other action of a row — or the commands built by hand with `useRowCommands`. */
157
- rowActions?: (row: T) => readonly RowAction[];
158
- /**
159
- * Ways of looking at the set the SCREEN writes — a gallery, a map, a record with its lines and
160
- * its buttons — offered beside the built-in ones (web-ui's `List.Present`). Each is handed the
161
- * same set the others draw: the page, the search's grouping, the selection and what a press
162
- * does (`ListSet`). Offered after `views`; name one in `views` to open on it.
163
- */
164
- faces?: readonly EntityFace<T>[];
165
- };
166
- /** A face of a list written by the screen: its name and icon in the switcher, and how it draws
167
- * the set. `wide` when it needs width (a narrow list does not offer it). */
168
- export type EntityFace<T> = {
169
- id: string;
170
- label: string;
171
- icon: ListPresentProps<T>["icon"];
172
- wide?: boolean;
173
- render: (set: ListSet<T>) => ReactNode;
174
- };
175
- /** An empty list as web-ui draws it (`ListEmpty`), every sentence optional: the copy's words. */
176
- export type EntityEmpty = Omit<ListEmpty, "sentence" | "whenFiltered"> & {
177
- sentence?: string;
178
- whenFiltered?: Omit<NonNullable<ListEmpty["whenFiltered"]>, "sentence"> & {
179
- sentence?: string;
180
- };
17
+ export declare function useScreenListing<T extends AnyRecord>(_entity?: Entity<T>): Listing<T>;
18
+ declare function EntityListRoot<T extends AnyRecord, C extends CommandBodies = CommandBodies>(props: EntityListProps<T, C> & {
19
+ /** The list's tree. Without it, the default: the bar, the faces of `views`, the notices. */
20
+ children?: ReactNode;
21
+ }): import("react").JSX.Element;
22
+ /**
23
+ * A list by parts: the framework's default, or any part of it replaced. See the top of this file.
24
+ */
25
+ export declare const EntityList: typeof EntityListRoot & {
26
+ Bar: import("../parts.js").Part<{
27
+ children?: ReactNode;
28
+ }, EntityListState>;
29
+ Crumbs: import("../parts.js").Part<NoProps, EntityListState>;
30
+ Identity: import("../parts.js").Part<NoProps, EntityListState>;
31
+ Search: import("../parts.js").Part<NoProps, EntityListState>;
32
+ Actions: import("../parts.js").Part<NoProps, EntityListState>;
33
+ Pager: import("../parts.js").Part<NoProps, EntityListState>;
34
+ Table: import("../parts.js").Part<NoProps, EntityListState>;
35
+ Rows: import("../parts.js").Part<NoProps, EntityListState>;
36
+ Sheet: import("../parts.js").Part<NoProps, EntityListState>;
37
+ Pivot: import("../parts.js").Part<NoProps, EntityListState>;
38
+ Board: import("../parts.js").Part<NoProps, EntityListState>;
39
+ Tiles: import("../parts.js").Part<NoProps, EntityListState>;
40
+ Faces: import("../parts.js").Part<NoProps, EntityListState>;
41
+ Notices: import("../parts.js").Part<NoProps, EntityListState>;
181
42
  };
182
- export type View = "table" | "rows" | "board" | "tiles" | "sheet" | "pivot";
183
- export declare function EntityList<T extends AnyRecord, C extends CommandBodies = CommandBodies>({ listing, api, columns: askedColumns, cells, yesNo, views: askedViews, title: askedTitle, description: askedDescription, crumbs, actions, onOpen, onPeek, openTargets, onOpenIn, pivot: pivotAsked, empty, search, recent: askedRecent, sums, filters: askedFilters, facets: askedFacets, groupable: askedGroupable, selectable, selection: held, selectionActions, embedded, create, commands, rowActions: askedRowActions, faces, }: EntityListProps<T, C>): import("react").JSX.Element;