@sincpro/web-framework 3.5.0 → 3.7.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 (63) hide show
  1. package/README.md +5 -0
  2. package/dist/core/command.d.ts +16 -0
  3. package/dist/core/command.js +17 -0
  4. package/dist/core/copy.d.ts +16 -0
  5. package/dist/core/copy.js +26 -0
  6. package/dist/core/crumbs.d.ts +4 -0
  7. package/dist/core/crumbs.js +24 -0
  8. package/dist/core/history.d.ts +16 -4
  9. package/dist/core/history.js +20 -17
  10. package/dist/core/index.d.ts +4 -3
  11. package/dist/core/index.js +3 -2
  12. package/dist/core/list.d.ts +12 -0
  13. package/dist/core/list.js +14 -0
  14. package/dist/core/present.d.ts +12 -0
  15. package/dist/core/present.js +39 -0
  16. package/dist/react/index.d.ts +2 -0
  17. package/dist/react/index.js +2 -0
  18. package/dist/react/useBatchCommand.d.ts +50 -0
  19. package/dist/react/useBatchCommand.js +124 -0
  20. package/dist/react/useCommand.js +3 -4
  21. package/dist/react/useSelection.d.ts +37 -0
  22. package/dist/react/useSelection.js +40 -0
  23. package/dist/web/index.d.ts +7 -3
  24. package/dist/web/index.js +7 -3
  25. package/dist/web/list/BatchProgress.d.ts +16 -0
  26. package/dist/web/list/BatchProgress.js +40 -0
  27. package/dist/web/list/EntityList.d.ts +31 -8
  28. package/dist/web/list/EntityList.js +122 -39
  29. package/dist/web/list/EntitySearchBar.d.ts +9 -0
  30. package/dist/web/list/EntitySearchBar.js +15 -5
  31. package/dist/web/list/columns.d.ts +4 -1
  32. package/dist/web/list/columns.js +14 -6
  33. package/dist/web/list/dock.d.ts +19 -0
  34. package/dist/web/list/dock.js +20 -0
  35. package/dist/web/list/groups.d.ts +7 -1
  36. package/dist/web/list/groups.js +25 -5
  37. package/dist/web/list/pivot.d.ts +5 -1
  38. package/dist/web/list/pivot.js +28 -11
  39. package/dist/web/list/records.d.ts +100 -0
  40. package/dist/web/list/records.js +219 -0
  41. package/dist/web/list/search.d.ts +0 -17
  42. package/dist/web/list/search.js +33 -5
  43. package/dist/web/record/ActionButton.d.ts +25 -0
  44. package/dist/web/record/ActionButton.js +39 -18
  45. package/dist/web/record/CommandButton.d.ts +22 -2
  46. package/dist/web/record/CommandButton.js +43 -17
  47. package/dist/web/record/EntityTags.d.ts +5 -2
  48. package/dist/web/record/EntityTags.js +34 -12
  49. package/dist/web/record/RecordLifecycle.d.ts +28 -7
  50. package/dist/web/record/RecordLifecycle.js +63 -10
  51. package/dist/web/record/ServiceButton.d.ts +20 -2
  52. package/dist/web/record/ServiceButton.js +35 -27
  53. package/dist/web/record/dock.d.ts +31 -0
  54. package/dist/web/record/dock.js +14 -0
  55. package/dist/web/record/opening.d.ts +6 -2
  56. package/dist/web/record/record.d.ts +14 -3
  57. package/dist/web/record/record.js +39 -6
  58. package/dist/web/workspace/SincproApp.js +13 -2
  59. package/dist/web/workspace/composer.d.ts +1 -1
  60. package/dist/web/workspace/composer.js +23 -25
  61. package/dist/web/workspace/record.d.ts +8 -3
  62. package/dist/web/workspace/record.js +20 -16
  63. package/package.json +9 -9
@@ -0,0 +1,124 @@
1
+ "use client";
2
+ import { keysOf, listRoute, retryKeys, runBatch, } from "@sincpro/client-framework";
3
+ import { sendRoute } from "../core/command.js";
4
+ import { useFramework } from "./context.js";
5
+ import { useCallback, useEffect, useRef, useState } from "react";
6
+ /** The most records a Command runs on at once from a screen, unless the screen says otherwise. */
7
+ export const BATCH_LIMIT = 200;
8
+ /**
9
+ * One Command of an entity, run once per record of a selection — «Confirmar» on the invoices
10
+ * ticked, «Aprobar» on every payment a filter shows —, one outcome per record.
11
+ *
12
+ * const confirm = useBatchCommand(invoices, "confirm");
13
+ * <Button onPress={() => confirm.run(chosen.selection)}>Confirmar</Button>
14
+ * <BatchProgress batch={confirm} /> // «2 de 3», then «2 hechos · 1 falló: F-7 — …»
15
+ *
16
+ * Context: `for rec in self` from a screen. The keys come from the selection (`keysOf`: in
17
+ * hand, or read once as references — never more than `limit`); each record is the Command sent
18
+ * through the screens' transport — a use case of its own, traced — with an idempotency key of
19
+ * its own, kept while it goes unanswered (`retryKeys`): a retry after a dropped request is the
20
+ * same confirmation, never a second one. A failure is that record's (`runBatch`); the lists
21
+ * follow every write as they do for one.
22
+ *
23
+ * In order, one at a time, by default: a server is not asked for two hundred writes at once
24
+ * because a person ticked them. `concurrency` changes that.
25
+ *
26
+ * Not here: a batch the server runs in one request («everything matching» as a criteria) —
27
+ * sincpro_framework#185.
28
+ */
29
+ export function useBatchCommand(entity, name, options = {}) {
30
+ const route = entity.commands[name];
31
+ if (route === undefined)
32
+ throw new Error(`${entity.key} declares no command "${name}"`);
33
+ const { limit = BATCH_LIMIT, concurrency = 1 } = options;
34
+ const { transport, metas } = useFramework();
35
+ const [running, setRunning] = useState(false);
36
+ const [progress, setProgress] = useState(null);
37
+ const [result, setResult] = useState(null);
38
+ const [error, setError] = useState(null);
39
+ // The answers must not land on a screen that left; the Commands themselves go on.
40
+ const mounted = useRef(true);
41
+ useEffect(() => {
42
+ mounted.current = true;
43
+ return () => void (mounted.current = false);
44
+ }, []);
45
+ /** One gesture per record, kept across a retry: what went unanswered keeps its key. */
46
+ const gestures = useRef(new Map());
47
+ const last = useRef(null);
48
+ const stopping = useRef(null);
49
+ const execute = useCallback(async (keys, body) => {
50
+ const stopper = new AbortController();
51
+ stopping.current = stopper;
52
+ last.current = { body };
53
+ setRunning(true);
54
+ setResult(null);
55
+ setProgress({ settled: 0, total: keys.length });
56
+ const done = await runBatch(keys, async (key) => {
57
+ const gesture = gestures.current.get(key) ?? retryKeys();
58
+ gestures.current.set(key, gesture);
59
+ try {
60
+ const answer = await sendRoute(transport, route, key, body, {
61
+ idempotencyKey: gesture.keyFor({ id: key, body }),
62
+ });
63
+ gesture.settle(null);
64
+ return answer;
65
+ }
66
+ catch (failure) {
67
+ gesture.settle(failure);
68
+ throw failure;
69
+ }
70
+ }, {
71
+ concurrency,
72
+ // Never handed to the send: a Command sent is not taken back, only the next ones.
73
+ signal: stopper.signal,
74
+ onOutcome: (_, now) => {
75
+ if (mounted.current)
76
+ setProgress(now);
77
+ },
78
+ });
79
+ if (mounted.current) {
80
+ setResult(done);
81
+ setRunning(false);
82
+ }
83
+ return done;
84
+ }, [transport, route, concurrency]);
85
+ return {
86
+ run: async (selection, body) => {
87
+ setError(null);
88
+ const meta = metas.get(entity.key);
89
+ let keys;
90
+ try {
91
+ keys = await keysOf(selection, {
92
+ transport,
93
+ route: listRoute(entity.list),
94
+ identity: meta?.get_id || meta?.identity || "id",
95
+ limit,
96
+ });
97
+ }
98
+ catch (failure) {
99
+ if (mounted.current)
100
+ setError(failure);
101
+ return undefined;
102
+ }
103
+ return execute(keys, body ?? {});
104
+ },
105
+ retry: async () => {
106
+ const failed = (result?.outcomes ?? [])
107
+ .filter((one) => one.status !== "done")
108
+ .map((one) => one.item);
109
+ if (failed.length === 0 || last.current === null)
110
+ return undefined;
111
+ return execute(failed, last.current.body);
112
+ },
113
+ stop: () => stopping.current?.abort(),
114
+ running,
115
+ progress,
116
+ result,
117
+ error,
118
+ reset: () => {
119
+ setResult(null);
120
+ setError(null);
121
+ setProgress(null);
122
+ },
123
+ };
124
+ }
@@ -1,5 +1,6 @@
1
1
  "use client";
2
- import { bodyFor, pathFor, retryKeys, } from "@sincpro/client-framework";
2
+ import { retryKeys, } from "@sincpro/client-framework";
3
+ import { sendRoute } from "../core/command.js";
3
4
  import { useFramework } from "./context.js";
4
5
  import { useCallback, useEffect, useRef, useState } from "react";
5
6
  export function useCommand(entity, name) {
@@ -35,10 +36,8 @@ export function useRouteCommand(route, owner) {
35
36
  setBusy(true);
36
37
  setError(null);
37
38
  const idempotencyKey = gesture.keyFor({ id, body });
38
- // A Command whose body names its record (`target`) gets the id there.
39
- const sent = bodyFor(route, id, body);
40
39
  try {
41
- const answer = await transport.send(route.method, pathFor(route, id, sent), sent, undefined, { idempotencyKey });
40
+ const answer = await sendRoute(transport, route, id, body, { idempotencyKey });
42
41
  gesture.settle(null);
43
42
  return answer;
44
43
  }
@@ -0,0 +1,37 @@
1
+ import { type Selection } from "@sincpro/client-framework";
2
+ import type { AnyRecord } from "@sincpro/criteria";
3
+ import type { Listing } from "./useListing.js";
4
+ /**
5
+ * What is chosen in a list, and how a screen changes it — one state, reachable from outside the
6
+ * list: a bulk action reads it, a screen sets it, a chooser answers it.
7
+ */
8
+ export type ListSelection<T extends AnyRecord = AnyRecord> = {
9
+ /** The value (@sincpro/client-framework's `Selection`): these keys, or every record the
10
+ * list's question matches but some. */
11
+ selection: Selection<T>;
12
+ /** How many are chosen; `null` when «all that match» has no exact count. */
13
+ size: number | null;
14
+ isChosen: (key: string) => boolean;
15
+ toggle: (key: string) => void;
16
+ /** Every record the list's question matches, as the server counted them. */
17
+ chooseAllMatching: () => void;
18
+ clear: () => void;
19
+ set: (selection: Selection<T>) => void;
20
+ };
21
+ /**
22
+ * The selection of a list: ticking chooses keys, «Elegir los 187 que coinciden» chooses the
23
+ * list's question — its scope, search and filter — with the total the server counted.
24
+ *
25
+ * const listing = useListing(invoices);
26
+ * const chosen = useSelection(listing);
27
+ * <EntityList listing={listing} selectable selection={chosen} />
28
+ * <ConfirmAll selection={chosen.selection} />
29
+ *
30
+ * Context: `EntityList` kept what was ticked in its own state — the page's keys, reachable by
31
+ * nothing outside it. The value is client-framework's, the same a phone or a script holds; this
32
+ * is only where a screen keeps it.
33
+ *
34
+ * Another question is another set: a selection made under one filter is forgotten when the
35
+ * list's question changes — what was chosen is not among what is on screen anymore.
36
+ */
37
+ export declare function useSelection<T extends AnyRecord>(listing: Listing<T>): ListSelection<T>;
@@ -0,0 +1,40 @@
1
+ "use client";
2
+ import { allMatching, isChosen, NOTHING_CHOSEN, sizeOf, toggled, } from "@sincpro/client-framework";
3
+ import { useCallback, useMemo, useState } from "react";
4
+ /**
5
+ * The selection of a list: ticking chooses keys, «Elegir los 187 que coinciden» chooses the
6
+ * list's question — its scope, search and filter — with the total the server counted.
7
+ *
8
+ * const listing = useListing(invoices);
9
+ * const chosen = useSelection(listing);
10
+ * <EntityList listing={listing} selectable selection={chosen} />
11
+ * <ConfirmAll selection={chosen.selection} />
12
+ *
13
+ * Context: `EntityList` kept what was ticked in its own state — the page's keys, reachable by
14
+ * nothing outside it. The value is client-framework's, the same a phone or a script holds; this
15
+ * is only where a screen keeps it.
16
+ *
17
+ * Another question is another set: a selection made under one filter is forgotten when the
18
+ * list's question changes — what was chosen is not among what is on screen anymore.
19
+ */
20
+ export function useSelection(listing) {
21
+ const asked = listing.question.selection;
22
+ const question = useMemo(() => JSON.stringify(asked ?? null), [asked]);
23
+ const [held, setHeld] = useState({
24
+ question,
25
+ selection: NOTHING_CHOSEN,
26
+ });
27
+ // Held under the question it was made for: under another one, nothing is chosen.
28
+ const selection = held.question === question ? held.selection : NOTHING_CHOSEN;
29
+ const set = useCallback((next) => setHeld({ question, selection: next }), [question]);
30
+ const total = listing.count?.exact === true ? listing.count.value : null;
31
+ return {
32
+ selection,
33
+ size: sizeOf(selection),
34
+ isChosen: (key) => isChosen(selection, key),
35
+ toggle: (key) => set(toggled(selection, key)),
36
+ chooseAllMatching: () => set(allMatching(asked, total)),
37
+ clear: () => set(NOTHING_CHOSEN),
38
+ set,
39
+ };
40
+ }
@@ -1,28 +1,32 @@
1
1
  /**
2
2
  * The web bindings: what draws a `Listing` and a record with `@sincpro/web-ui`.
3
3
  */
4
+ export { BatchProgress } from "./list/BatchProgress.js";
4
5
  export { aggregateOf, type ColumnOptions, columnsOf, } from "./list/columns.js";
6
+ export { actionsOf, type ScreenActions } from "./list/dock.js";
5
7
  export { type EntityFace, EntityList, type EntityListProps, type View, } from "./list/EntityList.js";
6
8
  export { EntitySearchBar } from "./list/EntitySearchBar.js";
7
9
  export { groupableOf, pilesOf } from "./list/groups.js";
8
10
  export { OpenInMenu } from "./list/openIn.js";
9
11
  export { pivotOf } from "./list/pivot.js";
10
12
  export { type CardLook, type ChoiceTones, type OptionLook, type PartLook, partLookOf, type PartLooks, type PartOf, type Presentation, presentationOf, type Presented, presented, type RowLook, tonesOver, } from "./list/presentation.js";
13
+ export { type Choice, type Chooser, findChoices, type FrameworkReads, modelLoader, recordsBrowser, RecordsBrowserProvider, recordsSearch, refusalNotice, useLoadModel, useRecordsBrowser, useSearchRecords, } from "./list/records.js";
11
14
  export { type RowCommand, type RowCommands, useRowCommands, } from "./list/rowCommands.js";
12
15
  export { facetsOf, modelOf } from "./list/search.js";
13
16
  export { type ActionDialog, type Asked, } from "./record/ActionButton.js";
14
17
  export { type AskedField, type AskField, type AskForm, askFormOf, } from "./record/ask.js";
15
- export { CommandButton } from "./record/CommandButton.js";
18
+ export { type CommandActionProps, CommandButton, useCommandAction, } from "./record/CommandButton.js";
16
19
  export { RelationPicker } from "./record/control.js";
20
+ export { type ActionLook, type DockedAction } from "./record/dock.js";
17
21
  export { dirtyOf, type FieldControl, RecordField, } from "./record/edit.js";
18
22
  export { EntityPicker } from "./record/EntityPicker.js";
19
23
  export { EntityTags } from "./record/EntityTags.js";
20
24
  export { type LineColumn, type LineControl, type LinesLook, RecordLinesEditor, } from "./record/lines.js";
21
25
  export { type RecordOpening, RecordOpeningProvider, useRecordOpening, } from "./record/opening.js";
22
26
  export { countOf, factsOf, RecordLines, usePartLook, } from "./record/record.js";
23
- export { RecordLifecycle } from "./record/RecordLifecycle.js";
27
+ export { type LifecycleDone, RecordLifecycle, useRecordLifecycleActions, } from "./record/RecordLifecycle.js";
24
28
  export { RelatedList } from "./record/RelatedList.js";
25
- export { ServiceButton } from "./record/ServiceButton.js";
29
+ export { type ServiceActionProps, ServiceButton, useServiceAction, } from "./record/ServiceButton.js";
26
30
  export { cardOf, relationOf } from "./record/summary.js";
27
31
  export { Refused } from "./Refused.js";
28
32
  export { entityView, type EntityViewOptions, listView, type ListViewOptions, } from "./workspace/composer.js";
package/dist/web/index.js CHANGED
@@ -1,28 +1,32 @@
1
1
  /**
2
2
  * The web bindings: what draws a `Listing` and a record with `@sincpro/web-ui`.
3
3
  */
4
+ export { BatchProgress } from "./list/BatchProgress.js";
4
5
  export { aggregateOf, columnsOf, } from "./list/columns.js";
6
+ export { actionsOf } from "./list/dock.js";
5
7
  export { EntityList, } from "./list/EntityList.js";
6
8
  export { EntitySearchBar } from "./list/EntitySearchBar.js";
7
9
  export { groupableOf, pilesOf } from "./list/groups.js";
8
10
  export { OpenInMenu } from "./list/openIn.js";
9
11
  export { pivotOf } from "./list/pivot.js";
10
12
  export { partLookOf, presentationOf, presented, tonesOver, } from "./list/presentation.js";
13
+ export { findChoices, modelLoader, recordsBrowser, RecordsBrowserProvider, recordsSearch, refusalNotice, useLoadModel, useRecordsBrowser, useSearchRecords, } from "./list/records.js";
11
14
  export { useRowCommands, } from "./list/rowCommands.js";
12
15
  export { facetsOf, modelOf } from "./list/search.js";
13
16
  export {} from "./record/ActionButton.js";
14
17
  export { askFormOf, } from "./record/ask.js";
15
- export { CommandButton } from "./record/CommandButton.js";
18
+ export { CommandButton, useCommandAction, } from "./record/CommandButton.js";
16
19
  export { RelationPicker } from "./record/control.js";
20
+ export {} from "./record/dock.js";
17
21
  export { dirtyOf, RecordField, } from "./record/edit.js";
18
22
  export { EntityPicker } from "./record/EntityPicker.js";
19
23
  export { EntityTags } from "./record/EntityTags.js";
20
24
  export { RecordLinesEditor, } from "./record/lines.js";
21
25
  export { RecordOpeningProvider, useRecordOpening, } from "./record/opening.js";
22
26
  export { countOf, factsOf, RecordLines, usePartLook, } from "./record/record.js";
23
- export { RecordLifecycle } from "./record/RecordLifecycle.js";
27
+ export { RecordLifecycle, useRecordLifecycleActions, } from "./record/RecordLifecycle.js";
24
28
  export { RelatedList } from "./record/RelatedList.js";
25
- export { ServiceButton } from "./record/ServiceButton.js";
29
+ export { ServiceButton, useServiceAction, } from "./record/ServiceButton.js";
26
30
  export { cardOf, relationOf } from "./record/summary.js";
27
31
  export { Refused } from "./Refused.js";
28
32
  export { entityView, listView, } from "./workspace/composer.js";
@@ -0,0 +1,16 @@
1
+ import type { BatchCommandState } from "../../react/useBatchCommand.js";
2
+ /**
3
+ * A Command running once per record, drawn: how far it is while it runs, then what became of
4
+ * each — «2 hechos · 1 falló», every failure named by its record and its reason, «Reintentar los
5
+ * que fallaron». Before it starts, why it did not: too many chosen.
6
+ *
7
+ * const confirm = useBatchCommand(invoices, "confirm");
8
+ * <BatchProgress batch={confirm} />
9
+ *
10
+ * Context: a batch's result is one outcome per record, and a person needs the ones that failed —
11
+ * by name, with the server's reason —, not a count. web-ui draws (`ProgressBar`, `Callout`); the
12
+ * words are the framework's copy, the reasons the server's (`explain`).
13
+ */
14
+ export declare function BatchProgress<R>({ batch, }: {
15
+ batch: Pick<BatchCommandState<R>, "running" | "progress" | "result" | "error" | "retry" | "stop" | "reset">;
16
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,40 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { SelectionTooLarge } from "@sincpro/client-framework";
4
+ import { frameworkCopy } from "../../core/copy.js";
5
+ import { explain } from "../../core/explain.js";
6
+ import { Button, Callout, ProgressBar } from "@sincpro/web-ui";
7
+ /**
8
+ * A Command running once per record, drawn: how far it is while it runs, then what became of
9
+ * each — «2 hechos · 1 falló», every failure named by its record and its reason, «Reintentar los
10
+ * que fallaron». Before it starts, why it did not: too many chosen.
11
+ *
12
+ * const confirm = useBatchCommand(invoices, "confirm");
13
+ * <BatchProgress batch={confirm} />
14
+ *
15
+ * Context: a batch's result is one outcome per record, and a person needs the ones that failed —
16
+ * by name, with the server's reason —, not a count. web-ui draws (`ProgressBar`, `Callout`); the
17
+ * words are the framework's copy, the reasons the server's (`explain`).
18
+ */
19
+ export function BatchProgress({ batch, }) {
20
+ const copy = frameworkCopy().batch;
21
+ const { running, progress, result, error } = batch;
22
+ if (running && progress !== null)
23
+ return (_jsxs("div", { className: "flex items-center gap-3", children: [_jsx(ProgressBar, { label: copy.running, value: progress.settled, maxValue: progress.total, valueLabel: copy.progress(progress.settled, progress.total), tone: "brand" }), _jsx(Button, { role: "ghost", size: "sm", onClick: batch.stop, children: copy.stop })] }));
24
+ if (error instanceof SelectionTooLarge)
25
+ return (_jsx(Callout, { tone: "warn", onDismiss: batch.reset, children: copy.tooMany(error.size, error.limit) }));
26
+ if (error !== null && error !== undefined) {
27
+ const { heading, sentence } = explain(error);
28
+ return (_jsx(Callout, { tone: "bad", title: heading, onDismiss: batch.reset, children: sentence }));
29
+ }
30
+ if (result === null || result.outcomes.length === 0)
31
+ return null;
32
+ const left = result.outcomes.filter((one) => one.status !== "done");
33
+ return (_jsx(Callout, { tone: left.length === 0 ? "good" : result.done === 0 ? "bad" : "warn", title: copy.outcome(result.done, result.failed, result.skipped), onDismiss: batch.reset, ...(left.length === 0
34
+ ? {}
35
+ : {
36
+ action: (_jsx(Button, { role: "secondary", size: "sm", onClick: () => void batch.retry(), children: copy.retry })),
37
+ }), children: left.length === 0 ? null : (_jsx("ul", { className: "flex flex-col gap-1", children: left
38
+ .filter((one) => one.status === "failed")
39
+ .map((one) => (_jsxs("li", { children: [_jsx("span", { className: "font-medium", children: one.item }), " — ", explain(one.error).sentence] }, one.item))) })) }));
40
+ }
@@ -1,10 +1,12 @@
1
1
  import { type CommandBodies } from "@sincpro/client-framework";
2
2
  import { type AnyRecord } from "@sincpro/criteria";
3
3
  import { type WorkspaceApi } from "@sincpro/web-composer";
4
- import type { GroupLevel, NamedFilter } from "../../core/list.js";
4
+ import { type GroupLevel, type NamedFilter } from "../../core/list.js";
5
5
  import type { Listing } from "../../react/useListing.js";
6
+ import { type ListSelection } from "../../react/useSelection.js";
7
+ import { type ScreenActions } from "./dock.js";
6
8
  import { type RowCommand } from "./rowCommands.js";
7
- import { type ListCrumb, type ListPresentProps, type ListSet, type OpenTarget, type RowAction } from "@sincpro/web-ui";
9
+ import { type ListCrumb, type ListPresentProps, type ListSet, type OpenTarget, type RowAction, type YesNoColumn } from "@sincpro/web-ui";
8
10
  import { type ReactNode } from "react";
9
11
  /**
10
12
  * A whole collection from a `Listing`: the bar, the search, the set in the views it offers,
@@ -41,6 +43,14 @@ export type EntityListProps<T extends AnyRecord, C extends CommandBodies = Comma
41
43
  columns?: readonly string[];
42
44
  /** The cells that are not plain text: a link, a tag. Memoise it: compared by identity. */
43
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>>>>;
44
54
  /**
45
55
  * The ways to look at the set, the first one shown: `table` (columns), `rows` (a name and
46
56
  * its facts, what a narrow panel wants), `board` (cards) and `sheet` (a spreadsheet, every
@@ -64,7 +74,13 @@ export type EntityListProps<T extends AnyRecord, C extends CommandBodies = Comma
64
74
  title?: string;
65
75
  description?: string;
66
76
  crumbs?: readonly ListCrumb[];
67
- actions?: ReactNode;
77
+ /**
78
+ * What the list starts — «Importar», «Exportar ▸» —, beside «Nuevo». As data (`DockAction`s)
79
+ * the application's view style draws them with «Nuevo»: the bar's buttons in `traditional`,
80
+ * one pill floating at the bottom in `modern` (web-ui's `ViewStyleProvider`). A node drawn
81
+ * by hand stays in the bar.
82
+ */
83
+ actions?: ScreenActions;
68
84
  onOpen?: (row: T) => void;
69
85
  onPeek?: (row: T) => void;
70
86
  /**
@@ -96,12 +112,19 @@ export type EntityListProps<T extends AnyRecord, C extends CommandBodies = Comma
96
112
  * Without it, the list definition's, else every one the model does. */
97
113
  groupable?: readonly string[];
98
114
  /**
99
- * Rows can be ticked. With `api`, what is ticked is PUBLISHED to the workspace
100
- * (`api.select`): a panel beside it follows the selection without knowing this list.
115
+ * Rows can be ticked — and, past the page, «Elegir los 187 que coinciden». With `api`, what is
116
+ * chosen is PUBLISHED to the workspace (`api.select`): a panel beside it follows the selection
117
+ * without knowing this list.
101
118
  */
102
119
  selectable?: boolean;
103
- /** What to do with what is ticked: drawn in the bar while something is. */
104
- selectionActions?: ReactNode;
120
+ /** The selection, held by the screen (`useSelection(listing)`): read and set from outside the
121
+ * list. Without it the list holds its own. */
122
+ selection?: ListSelection<T>;
123
+ /** What to do with what is chosen, while something is — handed the selection to act on it
124
+ * (`useBatchCommand`). As data, the view style draws it: in the bar in place of the search
125
+ * in `traditional`, a pill floating at the bottom in `modern` («3 elegidas ✕ · Confirmar»).
126
+ * Giving it makes the rows choosable: `selectable` is not needed with it. */
127
+ selectionActions?: ScreenActions | ((selection: ListSelection<T>) => ScreenActions);
105
128
  /** The list is a FIELD of a record — its lines, its members — and not a screen. */
106
129
  embedded?: boolean;
107
130
  /**
@@ -135,4 +158,4 @@ export type EntityFace<T> = {
135
158
  render: (set: ListSet<T>) => ReactNode;
136
159
  };
137
160
  export type View = "table" | "rows" | "board" | "sheet" | "pivot";
138
- export declare function EntityList<T extends AnyRecord, C extends CommandBodies = CommandBodies>({ listing, api, columns: askedColumns, cells, views: askedViews, title: askedTitle, description: askedDescription, crumbs, actions, onOpen, onPeek, openTargets, onOpenIn, pivot: pivotAsked, empty, search, sums, filters: askedFilters, facets: askedFacets, groupable: askedGroupable, selectable, selectionActions, embedded, create, commands, rowActions: askedRowActions, faces, }: EntityListProps<T, C>): import("react").JSX.Element;
161
+ 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, sums, filters: askedFilters, facets: askedFacets, groupable: askedGroupable, selectable, selection: held, selectionActions, embedded, create, commands, rowActions: askedRowActions, faces, }: EntityListProps<T, C>): import("react").JSX.Element;