@sincpro/web-framework 3.17.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.d.ts +6 -0
- package/dist/react/useGroups.js +84 -11
- 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 -529
- 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 +17 -1
- package/dist/web/list/groups.js +43 -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 +3 -3
package/dist/react/useGroups.js
CHANGED
|
@@ -4,7 +4,7 @@ import { areGroups, groupKeyOf, isGroupedAnswer, levelQuestion, nextGroups, NotG
|
|
|
4
4
|
import { measuresOf, sumsOf } from "../core/measure.js";
|
|
5
5
|
import { useFramework } from "./context.js";
|
|
6
6
|
import { useWrites } from "./useWrites.js";
|
|
7
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
7
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
8
8
|
const IDLE = {
|
|
9
9
|
status: "idle",
|
|
10
10
|
buckets: [],
|
|
@@ -29,6 +29,9 @@ export function useGroups(listing, options = {}) {
|
|
|
29
29
|
const [below, setBelow] = useState(new Map());
|
|
30
30
|
const [rows, setRows] = useState(new Map());
|
|
31
31
|
const [opened, setOpened] = useState(new Set());
|
|
32
|
+
// The order of the groups and how many start open are the named list's (`defineList`).
|
|
33
|
+
const groupOrder = listing.definition?.groupOrder;
|
|
34
|
+
const ordered = useMemo(() => (groupOrder === undefined ? {} : { order: groupOrder }), [groupOrder]);
|
|
32
35
|
const pageSize = options.pageSize ?? 50;
|
|
33
36
|
const groupPageSize = options.groupPageSize ?? 80;
|
|
34
37
|
const maxRows = options.maxRows ?? 500;
|
|
@@ -71,7 +74,9 @@ export function useGroups(listing, options = {}) {
|
|
|
71
74
|
if (inFlight.current.has(tag))
|
|
72
75
|
return;
|
|
73
76
|
const had = now.current.rows.get(key);
|
|
74
|
-
if (mode === "more" && (had === undefined || had.after === null))
|
|
77
|
+
if ((mode === "more" || mode === "next") && (had === undefined || had.after === null))
|
|
78
|
+
return;
|
|
79
|
+
if (mode === "prev" && (had === undefined || had.back.length === 0))
|
|
75
80
|
return;
|
|
76
81
|
inFlight.current.add(tag);
|
|
77
82
|
const { id, signal } = generation.current;
|
|
@@ -80,7 +85,14 @@ export function useGroups(listing, options = {}) {
|
|
|
80
85
|
? Math.min(maxRows, Math.max(pageSize, had?.rows.length ?? 0))
|
|
81
86
|
: pageSize;
|
|
82
87
|
const first = rowsQuestion(bucket, limit);
|
|
83
|
-
|
|
88
|
+
// The page turned back to: where it started, as it was read then.
|
|
89
|
+
const before = mode === "prev" ? had?.back.at(-1) : undefined;
|
|
90
|
+
// Where this reading starts: after the rows in hand («more», «next»), where the page
|
|
91
|
+
// stepped back to started, or the group's first row.
|
|
92
|
+
const at = (mode === "more" || mode === "next") && had !== undefined
|
|
93
|
+
? had.after
|
|
94
|
+
: (before?.at ?? null);
|
|
95
|
+
const criteria = at === null ? first : resumingFrom(first, at);
|
|
84
96
|
if (had !== undefined)
|
|
85
97
|
setRows((map) => new Map(map).set(key, { ...had, reading: true, error: null }));
|
|
86
98
|
transport.list(route, criteria, signal).then((page) => {
|
|
@@ -88,13 +100,27 @@ export function useGroups(listing, options = {}) {
|
|
|
88
100
|
if (generation.current.id !== id)
|
|
89
101
|
return;
|
|
90
102
|
setRows((map) => {
|
|
91
|
-
const
|
|
103
|
+
const held = map.get(key);
|
|
104
|
+
const kept = mode === "more" ? (held?.rows ?? []) : [];
|
|
105
|
+
// «more» adds to the page on screen; «next» and «prev» turn it; the rest start over.
|
|
106
|
+
const place = mode === "more" && held !== undefined
|
|
107
|
+
? { from: held.from, at: held.at, back: held.back }
|
|
108
|
+
: mode === "next" && held !== undefined
|
|
109
|
+
? {
|
|
110
|
+
from: held.from + held.rows.length,
|
|
111
|
+
at,
|
|
112
|
+
back: [...held.back, { from: held.from, at: held.at }],
|
|
113
|
+
}
|
|
114
|
+
: mode === "prev" && held !== undefined && before !== undefined
|
|
115
|
+
? { from: before.from, at: before.at, back: held.back.slice(0, -1) }
|
|
116
|
+
: { from: 0, at: null, back: [] };
|
|
92
117
|
return new Map(map).set(key, {
|
|
93
118
|
path,
|
|
94
|
-
rows: [...
|
|
119
|
+
rows: [...kept, ...page.rows],
|
|
95
120
|
after: page.cursor,
|
|
96
121
|
reading: false,
|
|
97
122
|
error: null,
|
|
123
|
+
...place,
|
|
98
124
|
});
|
|
99
125
|
});
|
|
100
126
|
}, (error) => {
|
|
@@ -102,7 +128,14 @@ export function useGroups(listing, options = {}) {
|
|
|
102
128
|
if (generation.current.id !== id)
|
|
103
129
|
return;
|
|
104
130
|
setRows((map) => new Map(map).set(key, {
|
|
105
|
-
...(map.get(key) ?? {
|
|
131
|
+
...(map.get(key) ?? {
|
|
132
|
+
path,
|
|
133
|
+
rows: [],
|
|
134
|
+
after: null,
|
|
135
|
+
from: 0,
|
|
136
|
+
at: null,
|
|
137
|
+
back: [],
|
|
138
|
+
}),
|
|
106
139
|
reading: false,
|
|
107
140
|
error,
|
|
108
141
|
}));
|
|
@@ -128,7 +161,7 @@ export function useGroups(listing, options = {}) {
|
|
|
128
161
|
const limit = mode === "again" ? Math.max(groupPageSize, had?.buckets.length ?? 0) : groupPageSize;
|
|
129
162
|
const offset = mode === "more" ? (had?.buckets.length ?? 0) : 0;
|
|
130
163
|
const measures = measuresNow();
|
|
131
|
-
const criteria = levelQuestion(bucket.criteria, level, { limit, offset }, measures === undefined ? {} : { measures });
|
|
164
|
+
const criteria = levelQuestion(bucket.criteria, level, { limit, offset }, { ...ordered, ...(measures === undefined ? {} : { measures }) });
|
|
132
165
|
setBelow((map) => new Map(map).set(key, {
|
|
133
166
|
...(had ?? { path, buckets: [], count: null }),
|
|
134
167
|
reading: true,
|
|
@@ -169,7 +202,7 @@ export function useGroups(listing, options = {}) {
|
|
|
169
202
|
error,
|
|
170
203
|
}));
|
|
171
204
|
});
|
|
172
|
-
}, [transport, route, groupPageSize]);
|
|
205
|
+
}, [transport, route, groupPageSize, ordered]);
|
|
173
206
|
arrived.current = (buckets, above) => {
|
|
174
207
|
const deepest = above.length === now.current.levels.length - 1;
|
|
175
208
|
const closed = [];
|
|
@@ -188,6 +221,35 @@ export function useGroups(listing, options = {}) {
|
|
|
188
221
|
setBelow((map) => closed.reduce((kept, path) => without(kept, path), map));
|
|
189
222
|
setRows((map) => closed.reduce((kept, path) => without(kept, path), map));
|
|
190
223
|
};
|
|
224
|
+
/**
|
|
225
|
+
* The named list's grouping opens its first `open` groups once — the first time it arrives.
|
|
226
|
+
* After that what is open is the person's: a search keeps it, and closing one stays closed.
|
|
227
|
+
*/
|
|
228
|
+
const startedOpen = useRef(null);
|
|
229
|
+
const startOpen = (buckets) => {
|
|
230
|
+
const definition = listing.definition;
|
|
231
|
+
const count = definition?.open ?? 0;
|
|
232
|
+
const asked = JSON.stringify(now.current.levels);
|
|
233
|
+
if (count <= 0 || startedOpen.current === asked)
|
|
234
|
+
return;
|
|
235
|
+
if (asked !== JSON.stringify(definition?.groupBy ?? []))
|
|
236
|
+
return;
|
|
237
|
+
startedOpen.current = asked;
|
|
238
|
+
const deepest = now.current.levels.length === 1;
|
|
239
|
+
const first = buckets.slice(0, count);
|
|
240
|
+
setOpened((was) => {
|
|
241
|
+
const next = new Set(was);
|
|
242
|
+
for (const bucket of first)
|
|
243
|
+
next.add(keyOf(pathOf(bucket)));
|
|
244
|
+
return next;
|
|
245
|
+
});
|
|
246
|
+
for (const bucket of first) {
|
|
247
|
+
if (deepest)
|
|
248
|
+
readRows(bucket, pathOf(bucket), "first");
|
|
249
|
+
else
|
|
250
|
+
readLevel(bucket, pathOf(bucket), "first");
|
|
251
|
+
}
|
|
252
|
+
};
|
|
191
253
|
// Another split starts closed; the same split under another question keeps what is open.
|
|
192
254
|
const split = JSON.stringify(levels);
|
|
193
255
|
const shownSplit = useRef(split);
|
|
@@ -218,7 +280,7 @@ export function useGroups(listing, options = {}) {
|
|
|
218
280
|
// As many groups as were on screen: a search does not undo the person's «more groups».
|
|
219
281
|
const shown = fresh ? 0 : now.current.root.buckets.length;
|
|
220
282
|
const measures = measuresNow();
|
|
221
|
-
const criteria = levelQuestion(JSON.parse(question), first, { limit: Math.max(groupPageSize, shown) }, { counted: true, ...(measures === undefined ? {} : { measures }) });
|
|
283
|
+
const criteria = levelQuestion(JSON.parse(question), first, { limit: Math.max(groupPageSize, shown) }, { ...ordered, counted: true, ...(measures === undefined ? {} : { measures }) });
|
|
222
284
|
transport.list(route, criteria, aborter.signal).then((page) => {
|
|
223
285
|
if (generation.current.id !== id)
|
|
224
286
|
return;
|
|
@@ -237,6 +299,7 @@ export function useGroups(listing, options = {}) {
|
|
|
237
299
|
records: page.count?.value ?? null,
|
|
238
300
|
});
|
|
239
301
|
arrived.current(buckets, []);
|
|
302
|
+
startOpen(buckets);
|
|
240
303
|
}, (error) => {
|
|
241
304
|
if (generation.current.id === id)
|
|
242
305
|
setRoot({ ...IDLE, status: "failed", error });
|
|
@@ -256,7 +319,7 @@ export function useGroups(listing, options = {}) {
|
|
|
256
319
|
inFlight.current.add(tag);
|
|
257
320
|
const { id, signal } = generation.current;
|
|
258
321
|
const measures = measuresNow();
|
|
259
|
-
const criteria = levelQuestion(JSON.parse(question), first, { limit: groupPageSize, offset: root.buckets.length }, measures === undefined ? {} : { measures });
|
|
322
|
+
const criteria = levelQuestion(JSON.parse(question), first, { limit: groupPageSize, offset: root.buckets.length }, { ...ordered, ...(measures === undefined ? {} : { measures }) });
|
|
260
323
|
setRoot((was) => ({ ...was, status: "loading" }));
|
|
261
324
|
transport.list(route, criteria, signal).then((page) => {
|
|
262
325
|
inFlight.current.delete(tag);
|
|
@@ -372,9 +435,19 @@ export function useGroups(listing, options = {}) {
|
|
|
372
435
|
return undefined;
|
|
373
436
|
if (!hasMore(bucket))
|
|
374
437
|
return false;
|
|
375
|
-
|
|
438
|
+
// What is left after the rows shown — a group turned to its third page has left what
|
|
439
|
+
// follows it, not what precedes it.
|
|
440
|
+
const left = Math.min(maxRows, bucket.count - read.from) - read.rows.length;
|
|
376
441
|
return Math.max(0, Math.min(pageSize, left));
|
|
377
442
|
},
|
|
443
|
+
page: (bucket, step) => {
|
|
444
|
+
const read = readOf(bucket);
|
|
445
|
+
if (read === undefined || read.reading)
|
|
446
|
+
return;
|
|
447
|
+
if (step === 1 ? read.after !== null : read.back.length > 0)
|
|
448
|
+
readRows(bucket, pathOf(bucket), step === 1 ? "next" : "prev");
|
|
449
|
+
},
|
|
450
|
+
fromOf: (bucket) => readOf(bucket)?.from ?? 0,
|
|
378
451
|
errorOf: (bucket) => (isDeepest(bucket) ? readOf(bucket) : levelOf(bucket))?.error ?? null,
|
|
379
452
|
};
|
|
380
453
|
}
|
|
@@ -12,3 +12,16 @@ import { type Entity } from "@sincpro/client-framework";
|
|
|
12
12
|
* const name = useNameOf(tenants, record.tenant_id) ?? record.tenant_id;
|
|
13
13
|
*/
|
|
14
14
|
export declare function useNameOf(entity: Entity | undefined, id: string): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* The names of several records by key, each of the aggregate it names (`target`) — a grouping's
|
|
17
|
+
* heads, where the number of keys is the page's. Asked through the same book as `useNameOf`: one
|
|
18
|
+
* request per entity for the keys of the moment, a name already known shared. A key of an
|
|
19
|
+
* aggregate the application declared no entity for stays unnamed.
|
|
20
|
+
*
|
|
21
|
+
* const nameOf = useNamesOf([{ target: "directorio.Organo", id: "CONSEJO_TECNICO" }]);
|
|
22
|
+
* nameOf("directorio.Organo", "CONSEJO_TECNICO") // "Consejo Técnico", once it answers
|
|
23
|
+
*/
|
|
24
|
+
export declare function useNamesOf(asked: readonly {
|
|
25
|
+
target: string;
|
|
26
|
+
id: string;
|
|
27
|
+
}[]): (target: string, id: string) => string | undefined;
|
package/dist/react/useNameOf.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { listRoute } from "@sincpro/client-framework";
|
|
3
|
+
import { entityFor } from "../core/relation.js";
|
|
3
4
|
import { useFramework } from "./context.js";
|
|
4
5
|
import { useWrites } from "./useWrites.js";
|
|
5
6
|
import { useEffect, useState } from "react";
|
|
@@ -32,6 +33,37 @@ export function useNameOf(entity, id) {
|
|
|
32
33
|
}, [names, entity, id, context, writes]);
|
|
33
34
|
return named?.id === id ? named.name : undefined;
|
|
34
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* The names of several records by key, each of the aggregate it names (`target`) — a grouping's
|
|
38
|
+
* heads, where the number of keys is the page's. Asked through the same book as `useNameOf`: one
|
|
39
|
+
* request per entity for the keys of the moment, a name already known shared. A key of an
|
|
40
|
+
* aggregate the application declared no entity for stays unnamed.
|
|
41
|
+
*
|
|
42
|
+
* const nameOf = useNamesOf([{ target: "directorio.Organo", id: "CONSEJO_TECNICO" }]);
|
|
43
|
+
* nameOf("directorio.Organo", "CONSEJO_TECNICO") // "Consejo Técnico", once it answers
|
|
44
|
+
*/
|
|
45
|
+
export function useNamesOf(asked) {
|
|
46
|
+
const { names, context, entities, metas } = useFramework();
|
|
47
|
+
const [named, setNamed] = useState(new Map());
|
|
48
|
+
// The keys by their content: a new array of the same keys asks nothing again.
|
|
49
|
+
const question = JSON.stringify(asked.map(({ target, id }) => [target, id]));
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
let current = true;
|
|
52
|
+
for (const [target, id] of JSON.parse(question)) {
|
|
53
|
+
const entity = entityFor(entities, target, metas.get);
|
|
54
|
+
if (entity === undefined || id === "")
|
|
55
|
+
continue;
|
|
56
|
+
void names.nameOf(entity, id).then((name) => {
|
|
57
|
+
if (current && name !== undefined)
|
|
58
|
+
setNamed((was) => new Map(was).set(nameKey(target, id), name));
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return () => void (current = false);
|
|
62
|
+
// `context` asks again: another company names its records its own way.
|
|
63
|
+
}, [names, question, context, entities, metas]);
|
|
64
|
+
return (target, id) => named.get(nameKey(target, id));
|
|
65
|
+
}
|
|
66
|
+
const nameKey = (target, id) => `${target}\u0000${id}`;
|
|
35
67
|
/** Where `entity` is listed — or nothing to follow when it is listed only under a record. */
|
|
36
68
|
function routeOf(entity) {
|
|
37
69
|
try {
|
|
@@ -35,9 +35,17 @@ type UseCase<A extends unknown[], R> = (...args: A) => R | Promise<R>;
|
|
|
35
35
|
* arguments, a followed write or `reload()` read as always.
|
|
36
36
|
*
|
|
37
37
|
* const portada = useServiceReading(sitio.portada, [], { initial: loaderData.portada });
|
|
38
|
+
*
|
|
39
|
+
* `enabled: false` is a reading that cannot ask yet — nobody signed in, a key still unknown: it
|
|
40
|
+
* stays `loading` and asks nothing, and reads as soon as it is enabled. Never answer a pending
|
|
41
|
+
* promise from the use case to hold it back: the reading would wait on a question nobody asked.
|
|
42
|
+
*
|
|
43
|
+
* const perfil = useServiceReading(cuentas.perfil, [usuario], { enabled: usuario !== "" });
|
|
38
44
|
*/
|
|
39
45
|
export declare function useServiceReading<A extends unknown[], R>(useCase: UseCase<A, R>, args: A, options?: {
|
|
40
46
|
follows?: readonly Entity[];
|
|
41
47
|
initial?: Awaited<R>;
|
|
48
|
+
/** `false`: nothing to ask yet — it stays `loading` and asks nothing. `true` by default. */
|
|
49
|
+
enabled?: boolean;
|
|
42
50
|
}): ServiceReading<Awaited<R>>;
|
|
43
51
|
export {};
|
|
@@ -37,6 +37,12 @@ function routeOf(entity) {
|
|
|
37
37
|
* arguments, a followed write or `reload()` read as always.
|
|
38
38
|
*
|
|
39
39
|
* const portada = useServiceReading(sitio.portada, [], { initial: loaderData.portada });
|
|
40
|
+
*
|
|
41
|
+
* `enabled: false` is a reading that cannot ask yet — nobody signed in, a key still unknown: it
|
|
42
|
+
* stays `loading` and asks nothing, and reads as soon as it is enabled. Never answer a pending
|
|
43
|
+
* promise from the use case to hold it back: the reading would wait on a question nobody asked.
|
|
44
|
+
*
|
|
45
|
+
* const perfil = useServiceReading(cuentas.perfil, [usuario], { enabled: usuario !== "" });
|
|
40
46
|
*/
|
|
41
47
|
export function useServiceReading(useCase, args, options = {}) {
|
|
42
48
|
const { context, changes, entities } = useFramework();
|
|
@@ -49,6 +55,7 @@ export function useServiceReading(useCase, args, options = {}) {
|
|
|
49
55
|
// Born answered: the first read on mount is the one the server already made.
|
|
50
56
|
const seeded = useRef(options.initial !== undefined);
|
|
51
57
|
const [again, setAgain] = useState(0);
|
|
58
|
+
const enabled = options.enabled ?? true;
|
|
52
59
|
// A write anyone sends — a save, another use case, a panel beside — to what it follows.
|
|
53
60
|
const followed = (options.follows ?? [])
|
|
54
61
|
.map(routeOf)
|
|
@@ -64,6 +71,8 @@ export function useServiceReading(useCase, args, options = {}) {
|
|
|
64
71
|
});
|
|
65
72
|
}, [changes, entities, followed]);
|
|
66
73
|
useEffect(() => {
|
|
74
|
+
if (!enabled)
|
|
75
|
+
return;
|
|
67
76
|
if (seeded.current) {
|
|
68
77
|
seeded.current = false;
|
|
69
78
|
return;
|
|
@@ -81,8 +90,9 @@ export function useServiceReading(useCase, args, options = {}) {
|
|
|
81
90
|
setAnswered({ key, status: "failed", answer: undefined, error });
|
|
82
91
|
});
|
|
83
92
|
return () => void (current = false);
|
|
84
|
-
// `context` and `again` read again: another company, a followed write, a `reload()
|
|
85
|
-
|
|
93
|
+
// `context` and `again` read again: another company, a followed write, a `reload()`; and
|
|
94
|
+
// being enabled reads what had to wait.
|
|
95
|
+
}, [key, context, again, enabled]);
|
|
86
96
|
const reload = useCallback(() => setAgain((n) => n + 1), []);
|
|
87
97
|
if (answered === null || answered.key !== key)
|
|
88
98
|
return { status: "loading", answer: undefined, error: null, reload };
|
package/dist/web/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { attachmentOf } from "./files.js";
|
|
|
5
5
|
export { BatchProgress } from "./list/BatchProgress.js";
|
|
6
6
|
export { aggregateOf, type ColumnOptions, columnsOf, } from "./list/columns.js";
|
|
7
7
|
export { actionsOf, type ScreenActions } from "./list/dock.js";
|
|
8
|
-
export { type EntityEmpty, type EntityFace, EntityList, type EntityListProps, type View, } from "./list/EntityList.js";
|
|
8
|
+
export { type EntityEmpty, type EntityFace, EntityList, type EntityListProps, useScreenListing, type View, } 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 { type Choice, type Chooser, findChoices, type FrameworkReads, modelLoade
|
|
|
15
15
|
export { type Reorder, useReorder } from "./list/reorder.js";
|
|
16
16
|
export { type RowCommand, type RowCommands, useRowCommands, } from "./list/rowCommands.js";
|
|
17
17
|
export { facetsOf, modelOf } from "./list/search.js";
|
|
18
|
+
export { type EntityListState, useEntityList, } from "./list/useEntityList.js";
|
|
18
19
|
export { type ActionDialog, type Asked, } from "./record/ActionButton.js";
|
|
19
20
|
export { type AskedField, type AskField, type AskForm, askFormOf, unansweredOf, } from "./record/ask.js";
|
|
20
21
|
export { ChoiceTag, type ChoiceTagLook, choiceTagOf, } from "./record/choice.js";
|
|
@@ -38,7 +39,8 @@ export { Refused } from "./Refused.js";
|
|
|
38
39
|
export { RouteError, type RouteErrorProps } from "./RouteError.js";
|
|
39
40
|
export { entityView, type EntityViewOptions, listView, type ListViewOptions, } from "./workspace/composer.js";
|
|
40
41
|
export { openIn, openOptions, RECORD_SIZE, RelatedRecord, targetsFor, } from "./workspace/open.js";
|
|
41
|
-
export {
|
|
42
|
+
export { type Stamp, useRecordScreen } from "./workspace/record.js";
|
|
43
|
+
export { EntityRecord, type ReadyRecord, RecordScreen, type RecordScreenProps, 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";
|
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 {
|
|
42
|
+
export { useRecordScreen } from "./workspace/record.js";
|
|
43
|
+
export { EntityRecord, RecordScreen, 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 {
|
|
2
|
-
import {
|
|
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
|
|
7
|
-
import { type
|
|
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
|
-
*
|
|
13
|
-
*
|
|
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
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
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
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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;
|