@sincpro/web-framework 3.6.0 → 3.8.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 +4 -0
- package/dist/core/crumbs.d.ts +4 -0
- package/dist/core/crumbs.js +24 -0
- package/dist/core/files.d.ts +47 -0
- package/dist/core/files.js +35 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/present.d.ts +4 -3
- package/dist/core/present.js +9 -4
- package/dist/web/files.d.ts +9 -0
- package/dist/web/files.js +22 -0
- package/dist/web/index.d.ts +6 -3
- package/dist/web/index.js +6 -3
- package/dist/web/list/EntityList.d.ts +23 -6
- package/dist/web/list/EntityList.js +89 -21
- package/dist/web/list/columns.d.ts +4 -1
- package/dist/web/list/columns.js +31 -17
- package/dist/web/list/dock.d.ts +19 -0
- package/dist/web/list/dock.js +20 -0
- package/dist/web/list/groups.d.ts +7 -1
- package/dist/web/list/groups.js +25 -5
- package/dist/web/record/ActionButton.d.ts +25 -0
- package/dist/web/record/ActionButton.js +39 -18
- package/dist/web/record/CommandButton.d.ts +22 -2
- package/dist/web/record/CommandButton.js +43 -17
- package/dist/web/record/RecordLifecycle.d.ts +28 -7
- package/dist/web/record/RecordLifecycle.js +63 -10
- package/dist/web/record/ServiceButton.d.ts +20 -2
- package/dist/web/record/ServiceButton.js +35 -27
- package/dist/web/record/dock.d.ts +31 -0
- package/dist/web/record/dock.js +14 -0
- package/dist/web/record/edit.js +10 -1
- package/dist/web/record/record.d.ts +14 -3
- package/dist/web/record/record.js +39 -6
- package/dist/web/workspace/record.d.ts +8 -3
- package/dist/web/workspace/record.js +20 -16
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -480,6 +480,7 @@ hook and draw your own, or go straight to the loose piece.
|
|
|
480
480
|
| What happened, what broke | `./telemetry`, `./errors` (optional) | — | `configureProcess({ tracer, reporter })` |
|
|
481
481
|
| What is each field? | `Meta` from the server, or `defineMeta` | — | `textOf`, `viewOf`, `metaFromSchema` |
|
|
482
482
|
| A value outside a model | — | `useTextOf` | `moneyTextOf`, `dayTextOf`, `instantTextOf`, `numberTextOf` |
|
|
483
|
+
| A file or a photo it holds | `EntityList`, `RecordField`: by its widget, as a `FileValue` | — | `attachmentOf`, `storedFileOf`, `renditionUrl` |
|
|
483
484
|
| What is a record, at any size? | `cardOf`, `relationOf` | `useSummaryOf` | `summaryOf` |
|
|
484
485
|
| How does a record look? | `presented(entity, { option, row, card })` | — | `presentationOf` |
|
|
485
486
|
| N records: search, filter, page | `EntityList`, `EntitySearchBar` | `useListing`, `useGroups` | `transport.list(route, criteria)` |
|
|
@@ -501,6 +502,9 @@ hook and draw your own, or go straight to the loose piece.
|
|
|
501
502
|
| Act on it (with a dry run) | `ServiceButton` (a use case), `CommandButton`, row commands | `useService`, `useCommand` | `transport.send` |
|
|
502
503
|
| What is chosen in a list | `EntityList selectable selection` | `useSelection` | `Selection`, `chosen`, `allMatching` (client-framework) |
|
|
503
504
|
| Act on each chosen one | `BatchProgress`, `selectionActions={(chosen) => …}` | `useBatchCommand` | `runBatch`, `keysOf` (client-framework), `sendRoute` |
|
|
505
|
+
| A list's actions, by the style | `EntityList actions`, `selectionActions` (`DockAction`s) | — | web-ui's `List.Dock`, `ViewStyleProvider` |
|
|
506
|
+
| A record's actions, by the style | `EntityRecord actions`, web-ui's `Record.Dock` | `useRecordLifecycleActions` | `DockedAction`, `ActionLook` |
|
|
507
|
+
| A use case or a Command, there | `ServiceButton`, `CommandButton` (as buttons) | `useServiceAction`/`useCommandAction` | — |
|
|
504
508
|
| Delete it | `EntityRecord` (`RecordLifecycle`) | `useRecordLifecycle` | `entity.delete`, `useRouteCommand` |
|
|
505
509
|
| Its trash | `EntityRecord` (`RecordLifecycle`), `listView(trashOf(entity))` | `useRecordLifecycle` | `entity.archive`, `entity.restore`, `trashOf` |
|
|
506
510
|
| Read again when it was written | every reading of this package, by itself | `useWrites` | `processChanges` (client-framework) |
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A crumb says only what is its OWN.
|
|
3
|
+
*
|
|
4
|
+
* Context: a view names itself whole so its tab stands alone in the workspace — «Pagos · María
|
|
5
|
+
* Fernanda Apaza Quispe» —, and the trail takes that name: `Pagos › María Fernanda Apaza Quispe ›
|
|
6
|
+
* Pagos · María Fernanda Apaza Quispe`. The crumb before already says whose; the last one wrapped
|
|
7
|
+
* onto a second line to say it again. Under its parent, a crumb drops the parent's name and the
|
|
8
|
+
* joint that held it («·», «:», «—», «de», «of»…) — «Pagos» —, and is left whole when the parent's
|
|
9
|
+
* name is not in it or is all of it.
|
|
10
|
+
*/
|
|
11
|
+
const JOINT = /^(?:[\s·:—–|/-]|de\b|del\b|of\b|for\b|para\b)+|(?:[\s·:—–|/-]|\bde|\bdel|\bof|\bfor|\bpara)+$/giu;
|
|
12
|
+
export function ownLabel(label, parent) {
|
|
13
|
+
const before = parent?.trim();
|
|
14
|
+
if (before === undefined || before === "" || !label.includes(before))
|
|
15
|
+
return label;
|
|
16
|
+
const own = label.replace(before, "").replace(JOINT, "").trim();
|
|
17
|
+
return own === "" ? label : own;
|
|
18
|
+
}
|
|
19
|
+
export function ownCrumbs(crumbs) {
|
|
20
|
+
return crumbs.map((crumb, at) => {
|
|
21
|
+
const own = ownLabel(crumb.label, crumbs[at - 1]?.label);
|
|
22
|
+
return own === crumb.label ? crumb : { ...crumb, label: own };
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A file a record holds — sincpro_framework's `StoredFile`, as a read answers it: its name as it
|
|
3
|
+
* was sent, its type, its size, a link to see it (`url`), and for a picture its renditions,
|
|
4
|
+
* `thumb` for a list's line and `view` for a record.
|
|
5
|
+
*
|
|
6
|
+
* holdsFile(meta.fields.foto) -> true (widget "image" or "file")
|
|
7
|
+
* storedFileOf({ key: "fotos/01a1e.jpg", name: "Directorio.jpg", … }) -> StoredFileValue
|
|
8
|
+
* storedFileOf("fotos/01a1e.jpg") -> null (a bare key names nothing)
|
|
9
|
+
* renditionUrl(foto, "thumb") -> "/files/cGhv…" (else the original's)
|
|
10
|
+
*
|
|
11
|
+
* Context: the model publishes such a field as `embedded` with the widget `file` — or `image`,
|
|
12
|
+
* by its presentation —; read as any embedded value it was a section of its parts (key, name,
|
|
13
|
+
* type…) and a list's cell its JSON. Drawn by its widget it is ONE value: the picture and the
|
|
14
|
+
* name it was sent with, the name downloading it (web-ui's `FileValue`).
|
|
15
|
+
*/
|
|
16
|
+
/** A rendition of a stored picture, as answered. */
|
|
17
|
+
export type RenditionValue = {
|
|
18
|
+
name: string;
|
|
19
|
+
key: string;
|
|
20
|
+
content_type: string;
|
|
21
|
+
size: number;
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
url?: string;
|
|
25
|
+
};
|
|
26
|
+
/** A stored file, as answered. */
|
|
27
|
+
export type StoredFileValue = {
|
|
28
|
+
key: string;
|
|
29
|
+
name: string;
|
|
30
|
+
content_type: string;
|
|
31
|
+
size: number;
|
|
32
|
+
width?: number | null;
|
|
33
|
+
height?: number | null;
|
|
34
|
+
url?: string;
|
|
35
|
+
renditions?: readonly RenditionValue[];
|
|
36
|
+
};
|
|
37
|
+
/** The widgets that draw a field as one file: sincpro_framework's `Widget.FILE` / `IMAGE`. */
|
|
38
|
+
export declare const FILE_WIDGETS: ReadonlySet<string>;
|
|
39
|
+
/** Whether a field holds a file — drawn as one value, by its widget. */
|
|
40
|
+
export declare function holdsFile(field: {
|
|
41
|
+
widget?: string | undefined;
|
|
42
|
+
} | null | undefined): boolean;
|
|
43
|
+
/** The stored file a value is — `null` for nothing, or for anything that is not one. */
|
|
44
|
+
export declare function storedFileOf(value: unknown): StoredFileValue | null;
|
|
45
|
+
/** Where to see the rendition `name` of a stored picture — the original's link when it has
|
|
46
|
+
* none (a file put whole, a picture smaller than the rendition). */
|
|
47
|
+
export declare function renditionUrl(file: StoredFileValue, name: string): string | undefined;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A file a record holds — sincpro_framework's `StoredFile`, as a read answers it: its name as it
|
|
3
|
+
* was sent, its type, its size, a link to see it (`url`), and for a picture its renditions,
|
|
4
|
+
* `thumb` for a list's line and `view` for a record.
|
|
5
|
+
*
|
|
6
|
+
* holdsFile(meta.fields.foto) -> true (widget "image" or "file")
|
|
7
|
+
* storedFileOf({ key: "fotos/01a1e.jpg", name: "Directorio.jpg", … }) -> StoredFileValue
|
|
8
|
+
* storedFileOf("fotos/01a1e.jpg") -> null (a bare key names nothing)
|
|
9
|
+
* renditionUrl(foto, "thumb") -> "/files/cGhv…" (else the original's)
|
|
10
|
+
*
|
|
11
|
+
* Context: the model publishes such a field as `embedded` with the widget `file` — or `image`,
|
|
12
|
+
* by its presentation —; read as any embedded value it was a section of its parts (key, name,
|
|
13
|
+
* type…) and a list's cell its JSON. Drawn by its widget it is ONE value: the picture and the
|
|
14
|
+
* name it was sent with, the name downloading it (web-ui's `FileValue`).
|
|
15
|
+
*/
|
|
16
|
+
/** The widgets that draw a field as one file: sincpro_framework's `Widget.FILE` / `IMAGE`. */
|
|
17
|
+
export const FILE_WIDGETS = new Set(["file", "image"]);
|
|
18
|
+
/** Whether a field holds a file — drawn as one value, by its widget. */
|
|
19
|
+
export function holdsFile(field) {
|
|
20
|
+
return field?.widget !== undefined && FILE_WIDGETS.has(field.widget);
|
|
21
|
+
}
|
|
22
|
+
/** The stored file a value is — `null` for nothing, or for anything that is not one. */
|
|
23
|
+
export function storedFileOf(value) {
|
|
24
|
+
if (typeof value !== "object" || value === null)
|
|
25
|
+
return null;
|
|
26
|
+
const held = value;
|
|
27
|
+
return typeof held.key === "string" && typeof held.name === "string"
|
|
28
|
+
? held
|
|
29
|
+
: null;
|
|
30
|
+
}
|
|
31
|
+
/** Where to see the rendition `name` of a stored picture — the original's link when it has
|
|
32
|
+
* none (a file put whole, a picture smaller than the rendition). */
|
|
33
|
+
export function renditionUrl(file, name) {
|
|
34
|
+
return file.renditions?.find((one) => one.name === name)?.url ?? file.url;
|
|
35
|
+
}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export { sendRoute } from "./command.js";
|
|
|
12
12
|
export { ENGLISH_FRAMEWORK_COPY, type FrameworkCopy, frameworkCopy, installFrameworkCopy, SPANISH_FRAMEWORK_COPY, } from "./copy.js";
|
|
13
13
|
export { type Advice, adviceAt, changesOf, computedLocally, creationOf, defaultsOf, editedOf, errorAt, errorsByField, type FieldState, fieldStateOf, type FieldStates, linePlacesOf, lineStatesOf, missingOf, needsPreview, pathOf, type ServerFieldState, } from "./edit.js";
|
|
14
14
|
export { explain } from "./explain.js";
|
|
15
|
+
export { FILE_WIDGETS, holdsFile, renditionUrl, type RenditionValue, storedFileOf, type StoredFileValue, } from "./files.js";
|
|
15
16
|
export { type FormLayout, formOf } from "./form.js";
|
|
16
17
|
export { areGroups, NotGrouped } from "./groups.js";
|
|
17
18
|
export { FACT_TONES, type FactTone, type HistoryChange, type HistoryEntry, historyOf, toneOfFact, } from "./history.js";
|
package/dist/core/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export { sendRoute } from "./command.js";
|
|
|
12
12
|
export { ENGLISH_FRAMEWORK_COPY, frameworkCopy, installFrameworkCopy, SPANISH_FRAMEWORK_COPY, } from "./copy.js";
|
|
13
13
|
export { adviceAt, changesOf, computedLocally, creationOf, defaultsOf, editedOf, errorAt, errorsByField, fieldStateOf, linePlacesOf, lineStatesOf, missingOf, needsPreview, pathOf, } from "./edit.js";
|
|
14
14
|
export { explain } from "./explain.js";
|
|
15
|
+
export { FILE_WIDGETS, holdsFile, renditionUrl, storedFileOf, } from "./files.js";
|
|
15
16
|
export { formOf } from "./form.js";
|
|
16
17
|
export { areGroups, NotGrouped } from "./groups.js";
|
|
17
18
|
export { FACT_TONES, historyOf, toneOfFact, } from "./history.js";
|
package/dist/core/present.d.ts
CHANGED
|
@@ -41,9 +41,10 @@ export declare function valueAt(meta: Meta | null | undefined, record: Readonly<
|
|
|
41
41
|
export declare function fieldMetaOf(meta: Meta | null | undefined, name: string): FieldMeta | undefined;
|
|
42
42
|
export declare function viewOf(meta: Meta | null | undefined, name: string, locale?: string): FieldView;
|
|
43
43
|
/**
|
|
44
|
-
* The fields a screen shows when it names none: every scalar the model holds,
|
|
45
|
-
*
|
|
46
|
-
*
|
|
44
|
+
* The fields a screen shows when it names none: every scalar the model holds, and every file
|
|
45
|
+
* (`holdsFile` — one value, though it travels as an object), in the order it declares them.
|
|
46
|
+
* Relations and other value objects are left out — they are not a column, they are a page of
|
|
47
|
+
* their own (`RecordLines`) or a section.
|
|
47
48
|
*/
|
|
48
49
|
export declare function defaultFields(meta: Meta | null | undefined): string[];
|
|
49
50
|
/** The bookkeeping every framework entity carries; shown on demand, never by default. */
|
package/dist/core/present.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Money, timeZoneNow } from "@sincpro/client-framework";
|
|
2
2
|
import { choiceLabelOf, labelOf, } from "@sincpro/criteria";
|
|
3
3
|
import { frameworkCopy } from "./copy.js";
|
|
4
|
+
import { holdsFile, storedFileOf } from "./files.js";
|
|
4
5
|
import { relatedOf } from "./related.js";
|
|
5
6
|
/** Present when a field is named that the model does not declare: drawn plain, never thrown. */
|
|
6
7
|
const UNKNOWN = {
|
|
@@ -72,15 +73,16 @@ export function viewOf(meta, name, locale) {
|
|
|
72
73
|
};
|
|
73
74
|
}
|
|
74
75
|
/**
|
|
75
|
-
* The fields a screen shows when it names none: every scalar the model holds,
|
|
76
|
-
*
|
|
77
|
-
*
|
|
76
|
+
* The fields a screen shows when it names none: every scalar the model holds, and every file
|
|
77
|
+
* (`holdsFile` — one value, though it travels as an object), in the order it declares them.
|
|
78
|
+
* Relations and other value objects are left out — they are not a column, they are a page of
|
|
79
|
+
* their own (`RecordLines`) or a section.
|
|
78
80
|
*/
|
|
79
81
|
export function defaultFields(meta) {
|
|
80
82
|
if (!meta)
|
|
81
83
|
return [];
|
|
82
84
|
return Object.entries(meta.fields)
|
|
83
|
-
.filter(([, field]) => field.kind === "scalar")
|
|
85
|
+
.filter(([, field]) => field.kind === "scalar" || holdsFile(field))
|
|
84
86
|
.map(([name]) => name);
|
|
85
87
|
}
|
|
86
88
|
/** The bookkeeping every framework entity carries; shown on demand, never by default. */
|
|
@@ -341,6 +343,9 @@ export function textOf(meta, name, value, locale) {
|
|
|
341
343
|
const copy = frameworkCopy();
|
|
342
344
|
if (field.choices && field.choices.length > 0)
|
|
343
345
|
return choiceLabelOf(meta, name, value, locale);
|
|
346
|
+
// A file reads as the name it was sent with — never its storage key, never its JSON.
|
|
347
|
+
if (holdsFile(field))
|
|
348
|
+
return storedFileOf(value)?.name ?? null;
|
|
344
349
|
// An amount the model draws as money is money, though it travels bare.
|
|
345
350
|
if (field.widget === "money" && field.kind === "scalar") {
|
|
346
351
|
const amount = amountText(value, locale);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AttachmentFile } from "@sincpro/web-ui";
|
|
2
|
+
/**
|
|
3
|
+
* A stored file as web-ui draws one (`AttachmentFile`): its name, type and size, its link, and
|
|
4
|
+
* the `thumb` rendition as its thumbnail — so a list of fifty photos loads fifty thumbnails.
|
|
5
|
+
* `null` when the value is no file.
|
|
6
|
+
*
|
|
7
|
+
* attachmentOf(organo.foto) -> { id: "fotos/01a1e.jpg", name: "Directorio.jpg", url, thumbnail }
|
|
8
|
+
*/
|
|
9
|
+
export declare function attachmentOf(value: unknown): AttachmentFile | null;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { renditionUrl, storedFileOf } from "../core/files.js";
|
|
2
|
+
/**
|
|
3
|
+
* A stored file as web-ui draws one (`AttachmentFile`): its name, type and size, its link, and
|
|
4
|
+
* the `thumb` rendition as its thumbnail — so a list of fifty photos loads fifty thumbnails.
|
|
5
|
+
* `null` when the value is no file.
|
|
6
|
+
*
|
|
7
|
+
* attachmentOf(organo.foto) -> { id: "fotos/01a1e.jpg", name: "Directorio.jpg", url, thumbnail }
|
|
8
|
+
*/
|
|
9
|
+
export function attachmentOf(value) {
|
|
10
|
+
const file = storedFileOf(value);
|
|
11
|
+
if (file === null)
|
|
12
|
+
return null;
|
|
13
|
+
const thumbnail = renditionUrl(file, "thumb");
|
|
14
|
+
return {
|
|
15
|
+
id: file.key,
|
|
16
|
+
name: file.name,
|
|
17
|
+
type: file.content_type,
|
|
18
|
+
size: file.size,
|
|
19
|
+
...(file.url === undefined ? {} : { url: file.url }),
|
|
20
|
+
...(thumbnail === undefined ? {} : { thumbnail }),
|
|
21
|
+
};
|
|
22
|
+
}
|
package/dist/web/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The web bindings: what draws a `Listing` and a record with `@sincpro/web-ui`.
|
|
3
3
|
*/
|
|
4
|
+
export { attachmentOf } from "./files.js";
|
|
4
5
|
export { BatchProgress } from "./list/BatchProgress.js";
|
|
5
6
|
export { aggregateOf, type ColumnOptions, columnsOf, } from "./list/columns.js";
|
|
7
|
+
export { actionsOf, type ScreenActions } from "./list/dock.js";
|
|
6
8
|
export { type EntityFace, EntityList, type EntityListProps, type View, } from "./list/EntityList.js";
|
|
7
9
|
export { EntitySearchBar } from "./list/EntitySearchBar.js";
|
|
8
10
|
export { groupableOf, pilesOf } from "./list/groups.js";
|
|
@@ -14,17 +16,18 @@ export { type RowCommand, type RowCommands, useRowCommands, } from "./list/rowCo
|
|
|
14
16
|
export { facetsOf, modelOf } from "./list/search.js";
|
|
15
17
|
export { type ActionDialog, type Asked, } from "./record/ActionButton.js";
|
|
16
18
|
export { type AskedField, type AskField, type AskForm, askFormOf, } from "./record/ask.js";
|
|
17
|
-
export { CommandButton } from "./record/CommandButton.js";
|
|
19
|
+
export { type CommandActionProps, CommandButton, useCommandAction, } from "./record/CommandButton.js";
|
|
18
20
|
export { RelationPicker } from "./record/control.js";
|
|
21
|
+
export { type ActionLook, type DockedAction } from "./record/dock.js";
|
|
19
22
|
export { dirtyOf, type FieldControl, RecordField, } from "./record/edit.js";
|
|
20
23
|
export { EntityPicker } from "./record/EntityPicker.js";
|
|
21
24
|
export { EntityTags } from "./record/EntityTags.js";
|
|
22
25
|
export { type LineColumn, type LineControl, type LinesLook, RecordLinesEditor, } from "./record/lines.js";
|
|
23
26
|
export { type RecordOpening, RecordOpeningProvider, useRecordOpening, } from "./record/opening.js";
|
|
24
27
|
export { countOf, factsOf, RecordLines, usePartLook, } from "./record/record.js";
|
|
25
|
-
export { RecordLifecycle } from "./record/RecordLifecycle.js";
|
|
28
|
+
export { type LifecycleDone, RecordLifecycle, useRecordLifecycleActions, } from "./record/RecordLifecycle.js";
|
|
26
29
|
export { RelatedList } from "./record/RelatedList.js";
|
|
27
|
-
export { ServiceButton } from "./record/ServiceButton.js";
|
|
30
|
+
export { type ServiceActionProps, ServiceButton, useServiceAction, } from "./record/ServiceButton.js";
|
|
28
31
|
export { cardOf, relationOf } from "./record/summary.js";
|
|
29
32
|
export { Refused } from "./Refused.js";
|
|
30
33
|
export { entityView, type EntityViewOptions, listView, type ListViewOptions, } from "./workspace/composer.js";
|
package/dist/web/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The web bindings: what draws a `Listing` and a record with `@sincpro/web-ui`.
|
|
3
3
|
*/
|
|
4
|
+
export { attachmentOf } from "./files.js";
|
|
4
5
|
export { BatchProgress } from "./list/BatchProgress.js";
|
|
5
6
|
export { aggregateOf, columnsOf, } from "./list/columns.js";
|
|
7
|
+
export { actionsOf } from "./list/dock.js";
|
|
6
8
|
export { EntityList, } from "./list/EntityList.js";
|
|
7
9
|
export { EntitySearchBar } from "./list/EntitySearchBar.js";
|
|
8
10
|
export { groupableOf, pilesOf } from "./list/groups.js";
|
|
@@ -14,17 +16,18 @@ export { useRowCommands, } from "./list/rowCommands.js";
|
|
|
14
16
|
export { facetsOf, modelOf } from "./list/search.js";
|
|
15
17
|
export {} from "./record/ActionButton.js";
|
|
16
18
|
export { askFormOf, } from "./record/ask.js";
|
|
17
|
-
export { CommandButton } from "./record/CommandButton.js";
|
|
19
|
+
export { CommandButton, useCommandAction, } from "./record/CommandButton.js";
|
|
18
20
|
export { RelationPicker } from "./record/control.js";
|
|
21
|
+
export {} from "./record/dock.js";
|
|
19
22
|
export { dirtyOf, RecordField, } from "./record/edit.js";
|
|
20
23
|
export { EntityPicker } from "./record/EntityPicker.js";
|
|
21
24
|
export { EntityTags } from "./record/EntityTags.js";
|
|
22
25
|
export { RecordLinesEditor, } from "./record/lines.js";
|
|
23
26
|
export { RecordOpeningProvider, useRecordOpening, } from "./record/opening.js";
|
|
24
27
|
export { countOf, factsOf, RecordLines, usePartLook, } from "./record/record.js";
|
|
25
|
-
export { RecordLifecycle } from "./record/RecordLifecycle.js";
|
|
28
|
+
export { RecordLifecycle, useRecordLifecycleActions, } from "./record/RecordLifecycle.js";
|
|
26
29
|
export { RelatedList } from "./record/RelatedList.js";
|
|
27
|
-
export { ServiceButton } from "./record/ServiceButton.js";
|
|
30
|
+
export { ServiceButton, useServiceAction, } from "./record/ServiceButton.js";
|
|
28
31
|
export { cardOf, relationOf } from "./record/summary.js";
|
|
29
32
|
export { Refused } from "./Refused.js";
|
|
30
33
|
export { entityView, listView, } from "./workspace/composer.js";
|
|
@@ -4,8 +4,9 @@ import { type WorkspaceApi } from "@sincpro/web-composer";
|
|
|
4
4
|
import { type GroupLevel, type NamedFilter } from "../../core/list.js";
|
|
5
5
|
import type { Listing } from "../../react/useListing.js";
|
|
6
6
|
import { type ListSelection } from "../../react/useSelection.js";
|
|
7
|
+
import { type ScreenActions } from "./dock.js";
|
|
7
8
|
import { type RowCommand } from "./rowCommands.js";
|
|
8
|
-
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";
|
|
9
10
|
import { type ReactNode } from "react";
|
|
10
11
|
/**
|
|
11
12
|
* A whole collection from a `Listing`: the bar, the search, the set in the views it offers,
|
|
@@ -42,6 +43,14 @@ export type EntityListProps<T extends AnyRecord, C extends CommandBodies = Comma
|
|
|
42
43
|
columns?: readonly string[];
|
|
43
44
|
/** The cells that are not plain text: a link, a tag. Memoise it: compared by identity. */
|
|
44
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>>>>;
|
|
45
54
|
/**
|
|
46
55
|
* The ways to look at the set, the first one shown: `table` (columns), `rows` (a name and
|
|
47
56
|
* its facts, what a narrow panel wants), `board` (cards) and `sheet` (a spreadsheet, every
|
|
@@ -65,7 +74,13 @@ export type EntityListProps<T extends AnyRecord, C extends CommandBodies = Comma
|
|
|
65
74
|
title?: string;
|
|
66
75
|
description?: string;
|
|
67
76
|
crumbs?: readonly ListCrumb[];
|
|
68
|
-
|
|
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;
|
|
69
84
|
onOpen?: (row: T) => void;
|
|
70
85
|
onPeek?: (row: T) => void;
|
|
71
86
|
/**
|
|
@@ -105,9 +120,11 @@ export type EntityListProps<T extends AnyRecord, C extends CommandBodies = Comma
|
|
|
105
120
|
/** The selection, held by the screen (`useSelection(listing)`): read and set from outside the
|
|
106
121
|
* list. Without it the list holds its own. */
|
|
107
122
|
selection?: ListSelection<T>;
|
|
108
|
-
/** What to do with what is chosen,
|
|
109
|
-
*
|
|
110
|
-
|
|
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);
|
|
111
128
|
/** The list is a FIELD of a record — its lines, its members — and not a screen. */
|
|
112
129
|
embedded?: boolean;
|
|
113
130
|
/**
|
|
@@ -141,4 +158,4 @@ export type EntityFace<T> = {
|
|
|
141
158
|
render: (set: ListSet<T>) => ReactNode;
|
|
142
159
|
};
|
|
143
160
|
export type View = "table" | "rows" | "board" | "sheet" | "pivot";
|
|
144
|
-
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, selection: held, 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;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx,
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { PICK_PARAM, QUERY_PARAM, TRAIL_PARAM, } from "@sincpro/client-framework";
|
|
4
4
|
import { nameOf } from "@sincpro/criteria";
|
|
5
5
|
import { RecordLink, useCrumbs, usePhone } from "@sincpro/web-composer";
|
|
6
6
|
import { frameworkCopy } from "../../core/copy.js";
|
|
7
|
+
import { ownCrumbs } from "../../core/crumbs.js";
|
|
7
8
|
import { explain } from "../../core/explain.js";
|
|
8
9
|
import { choosesMany, } from "../../core/list.js";
|
|
9
10
|
import { textOf, viewOf } from "../../core/present.js";
|
|
@@ -13,6 +14,7 @@ import { useGroups } from "../../react/useGroups.js";
|
|
|
13
14
|
import { usePivot } from "../../react/usePivot.js";
|
|
14
15
|
import { useSelection } from "../../react/useSelection.js";
|
|
15
16
|
import { columnsOf } from "./columns.js";
|
|
17
|
+
import { actionsOf } from "./dock.js";
|
|
16
18
|
import { EntitySearchBar } from "./EntitySearchBar.js";
|
|
17
19
|
import { pilesOf } from "./groups.js";
|
|
18
20
|
import { OpenInMenu, openOptions, targetsFor } from "./openIn.js";
|
|
@@ -20,7 +22,7 @@ import { pivotOf } from "./pivot.js";
|
|
|
20
22
|
import { over, presentationOf } from "./presentation.js";
|
|
21
23
|
import { RESTORE, useRowCommands, } from "./rowCommands.js";
|
|
22
24
|
import { Button, Callout, List, Pagination, pathKey, RecordCard, SearchField, Tag, } from "@sincpro/web-ui";
|
|
23
|
-
import { RotateCcw } from "lucide-react";
|
|
25
|
+
import { Plus, RotateCcw } from "lucide-react";
|
|
24
26
|
import { useEffect, useId, useMemo, useRef, useState } from "react";
|
|
25
27
|
/** What `useCrumbs` reads when the list is not in a workspace: no trail, and nothing to follow. */
|
|
26
28
|
const NO_TRAIL = [];
|
|
@@ -35,7 +37,7 @@ const TRAILS = 50;
|
|
|
35
37
|
const NO_COMMANDS = [];
|
|
36
38
|
/** What a list offers when nobody said: every face that needs no configuration. */
|
|
37
39
|
const EVERY_VIEW = ["table", "rows", "board", "sheet"];
|
|
38
|
-
export function EntityList({ listing, api, columns: askedColumns, cells, views: askedViews, title: askedTitle, description: askedDescription, crumbs, actions, onOpen, onPeek, openTargets, onOpenIn, pivot: pivotAsked, empty, search = "bar", sums, filters: askedFilters, facets: askedFacets, groupable: askedGroupable, selectable = false, selection: held, selectionActions, embedded = false, create = true, commands = NO_COMMANDS, rowActions: askedRowActions, faces, }) {
|
|
40
|
+
export function EntityList({ listing, api, columns: askedColumns, cells, yesNo, views: askedViews, title: askedTitle, description: askedDescription, crumbs, actions, onOpen, onPeek, openTargets, onOpenIn, pivot: pivotAsked, empty, search = "bar", sums, filters: askedFilters, facets: askedFacets, groupable: askedGroupable, selectable = false, selection: held, selectionActions, embedded = false, create = true, commands = NO_COMMANDS, rowActions: askedRowActions, faces, }) {
|
|
39
41
|
// A named list (`defineList`) brings its own columns, filters, faces and words; what the
|
|
40
42
|
// screen passes wins.
|
|
41
43
|
const definition = listing.definition;
|
|
@@ -74,7 +76,9 @@ export function EntityList({ listing, api, columns: askedColumns, cells, views:
|
|
|
74
76
|
const choosingMany = choosing && choosesMany(api?.choosing?.question);
|
|
75
77
|
const own = useSelection(listing);
|
|
76
78
|
const chosen = held ?? own;
|
|
77
|
-
|
|
79
|
+
// Actions for the chosen rows make the rows choosable: given without `selectable` they were
|
|
80
|
+
// silently never shown — no ticks, nothing to act on.
|
|
81
|
+
const ticking = selectable || choosingMany || selectionActions !== undefined;
|
|
78
82
|
// The record opened from a row knows the page it came from: «3 / 64» and its neighbours.
|
|
79
83
|
const { trails, dateStyle } = useFramework();
|
|
80
84
|
const trailKey = `trail:${useId()}`;
|
|
@@ -134,9 +138,30 @@ export function EntityList({ listing, api, columns: askedColumns, cells, views:
|
|
|
134
138
|
listing.entity.create !== undefined
|
|
135
139
|
? () => api.open(listing.entity.newRef())
|
|
136
140
|
: undefined;
|
|
141
|
+
// What the list starts, as data: «Nuevo» — the primary — and the screen's, drawn by the view
|
|
142
|
+
// style (`List.Dock`). Actions drawn by hand stay in the bar, with «Nuevo» beside them.
|
|
143
|
+
const started = actionsOf(actions);
|
|
144
|
+
const startDock = started.drawn !== null
|
|
145
|
+
? []
|
|
146
|
+
: [
|
|
147
|
+
...(creating === undefined
|
|
148
|
+
? []
|
|
149
|
+
: [
|
|
150
|
+
{
|
|
151
|
+
id: "create",
|
|
152
|
+
label: frameworkCopy().record.create,
|
|
153
|
+
icon: Plus,
|
|
154
|
+
primary: true,
|
|
155
|
+
onSelect: creating,
|
|
156
|
+
},
|
|
157
|
+
]),
|
|
158
|
+
...started.dock,
|
|
159
|
+
];
|
|
137
160
|
// A press opens the page — the composer's one predictable gesture. Every other place the
|
|
138
|
-
// record may open is
|
|
139
|
-
// (`onPeek` with `rowClick="open"`: the press stays «open»)
|
|
161
|
+
// record may open is among the row's ways in, web-ui's (`openTargets` + `onOpenIn`, web-ui
|
|
162
|
+
// 2.10): 👁 for a look (`onPeek` with `rowClick="open"`: the press stays «open»), and «Abrir
|
|
163
|
+
// en…» with the rest — in ONE place at the row's end, a pill in the modern style. Drawn beside
|
|
164
|
+
// the name as well, a row offered three unaligned sets. A chooser only chooses.
|
|
140
165
|
const openingIn = onOpenIn ??
|
|
141
166
|
(api === undefined
|
|
142
167
|
? undefined
|
|
@@ -149,30 +174,34 @@ export function EntityList({ listing, api, columns: askedColumns, cells, views:
|
|
|
149
174
|
(targets.includes("peek") && openingIn !== undefined
|
|
150
175
|
? (row) => openingIn(row, "peek")
|
|
151
176
|
: undefined);
|
|
152
|
-
// The cells are memoised (below)
|
|
153
|
-
// `onOpenIn` is always the current one without redrawing
|
|
177
|
+
// The cells are memoised (below) and web-ui holds the row ways: both reach the opener through
|
|
178
|
+
// a ref, so a screen's inline `onOpenIn` is always the current one without redrawing.
|
|
154
179
|
const openingNow = useRef(openingIn);
|
|
155
180
|
openingNow.current = openingIn;
|
|
181
|
+
// The rows face (not the table) takes «Abrir en…» as its row's actions.
|
|
156
182
|
const openInOf = (row) => elsewhere.length === 0 || openingIn === undefined ? null : (_jsx(OpenInMenu, { targets: elsewhere, name: idOf(row), onOpen: (to) => openingNow.current?.(row, to) }));
|
|
157
|
-
// The column that names a row carries its link
|
|
158
|
-
//
|
|
183
|
+
// The column that names a row carries its link: the identity, or — in a list that does not
|
|
184
|
+
// show it (a relation inside a record) — the record's name, else the first. The link is only
|
|
185
|
+
// the name (`compact`): the places it opens in are the row's ways.
|
|
159
186
|
const named = columns === undefined || columns.includes(identity)
|
|
160
187
|
? identity
|
|
161
188
|
: meta?.display && columns.includes(meta.display)
|
|
162
189
|
? meta.display
|
|
163
190
|
: (columns[0] ?? identity);
|
|
164
191
|
const rowName = (row) => named === identity ? idOf(row) : (textOf(meta, named, row[named], locale) ?? idOf(row));
|
|
165
|
-
const linked = choosing || cells?.[named] !== undefined ||
|
|
192
|
+
const linked = choosing || cells?.[named] !== undefined || api === undefined
|
|
166
193
|
? cells
|
|
167
194
|
: {
|
|
168
195
|
...cells,
|
|
169
|
-
[named]: (row) => (
|
|
196
|
+
[named]: (row) => (_jsx(RecordLink, { api: api, resource: refOf(row), compact: true, children: rowName(row) })),
|
|
170
197
|
};
|
|
171
198
|
// `useCrumbs`, not `api.crumbs()`: the crumb must follow a name given later (`setTitle`).
|
|
172
199
|
// Without a workspace it reads a trail that never changes — a hook cannot be skipped.
|
|
173
200
|
const following = useCrumbs(api ?? NO_WORKSPACE);
|
|
174
201
|
usePhone(api ?? NO_WORKSPACE); // where a row opens follows the mode (`targetsFor`)
|
|
175
|
-
|
|
202
|
+
// The workspace's crumbs say each view's whole name (its tab's); in the trail a crumb says only
|
|
203
|
+
// what is its own — «Pagos», not «Pagos · María Fernanda» under «María Fernanda».
|
|
204
|
+
const trail = crumbs ?? (embedded || api === undefined ? undefined : ownCrumbs(following));
|
|
176
205
|
// The workspace hears what is chosen: the keys, or — «all that match» — the ones on screen.
|
|
177
206
|
const published = (chosen.selection.by === "keys"
|
|
178
207
|
? chosen.selection.keys
|
|
@@ -186,7 +215,21 @@ export function EntityList({ listing, api, columns: askedColumns, cells, views:
|
|
|
186
215
|
}, [api, ticking, published, listing.entity]);
|
|
187
216
|
// «Elegir los 187 que coinciden» only past the page, and only with the server's exact count.
|
|
188
217
|
const total = listing.count?.exact === true ? listing.count.value : null;
|
|
189
|
-
|
|
218
|
+
// What is done to the chosen rows: answering whoever asked for several, else the screen's.
|
|
219
|
+
const onChosen = choosingMany
|
|
220
|
+
? [
|
|
221
|
+
{
|
|
222
|
+
id: "add-chosen",
|
|
223
|
+
label: frameworkCopy().picker.addChosen(chosen.size),
|
|
224
|
+
primary: true,
|
|
225
|
+
onSelect: () => api?.answer(chosen.selection),
|
|
226
|
+
},
|
|
227
|
+
]
|
|
228
|
+
: typeof selectionActions === "function"
|
|
229
|
+
? selectionActions(chosen)
|
|
230
|
+
: selectionActions;
|
|
231
|
+
// As data they go to the dock, where the view style draws them; by hand, in the bar.
|
|
232
|
+
const forChosen = actionsOf(onChosen);
|
|
190
233
|
const selection = ticking
|
|
191
234
|
? {
|
|
192
235
|
has: chosen.isChosen,
|
|
@@ -196,7 +239,7 @@ export function EntityList({ listing, api, columns: askedColumns, cells, views:
|
|
|
196
239
|
...(total !== null && total > listing.rows.length
|
|
197
240
|
? { matching: { total, onSelect: chosen.chooseAllMatching } }
|
|
198
241
|
: {}),
|
|
199
|
-
...(
|
|
242
|
+
...(forChosen.drawn === null ? {} : { actions: forChosen.drawn }),
|
|
200
243
|
}
|
|
201
244
|
: undefined;
|
|
202
245
|
// Rebuilt only when what it reads changes: a new set of columns on every render redraws
|
|
@@ -207,9 +250,20 @@ export function EntityList({ listing, api, columns: askedColumns, cells, views:
|
|
|
207
250
|
locale,
|
|
208
251
|
...(linked ? { cells: linked } : {}),
|
|
209
252
|
...(look.tones === undefined ? {} : { tones: look.tones }),
|
|
253
|
+
...(yesNo === undefined ? {} : { yesNo }),
|
|
210
254
|
}),
|
|
211
255
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
212
|
-
[
|
|
256
|
+
[
|
|
257
|
+
meta,
|
|
258
|
+
locale,
|
|
259
|
+
names,
|
|
260
|
+
cells,
|
|
261
|
+
yesNo,
|
|
262
|
+
api,
|
|
263
|
+
elsewhere.join(),
|
|
264
|
+
openingIn === undefined,
|
|
265
|
+
dateStyle,
|
|
266
|
+
]);
|
|
213
267
|
// A state the application gave colours to is the row's tag — and not again among its facts.
|
|
214
268
|
const stateField = summaryFieldsOf(meta, {}, listing.entity.summary).state;
|
|
215
269
|
const stateTones = stateField === undefined ? undefined : look.tones?.[stateField];
|
|
@@ -299,7 +353,15 @@ export function EntityList({ listing, api, columns: askedColumns, cells, views:
|
|
|
299
353
|
// each says what its next «more» brings (1.5).
|
|
300
354
|
const groups = useGroups(listing, sums === undefined ? {} : { sums: sums || [] });
|
|
301
355
|
const grouped = groups.levels.length > 0;
|
|
302
|
-
|
|
356
|
+
// A table and a sheet say a group's sums under their columns (web-ui 2.9): beside the group's
|
|
357
|
+
// name, only what no column shown adds up.
|
|
358
|
+
const columnar = present === "table" || present === "sheet";
|
|
359
|
+
const underColumns = new Set(columnar
|
|
360
|
+
? shown.flatMap((column) => column.aggregate === undefined || column.defaultHidden || column.field === undefined
|
|
361
|
+
? []
|
|
362
|
+
: [column.field])
|
|
363
|
+
: []);
|
|
364
|
+
const { piles, bucketAt } = pilesOf(groups.buckets, groups.levels, meta, locale, groups.rowsOf, groups.brings, underColumns);
|
|
303
365
|
const [opened, setOpened] = useState(() => new Set());
|
|
304
366
|
useEffect(() => setOpened(new Set()), [groups.buckets]);
|
|
305
367
|
const collapsed = [...bucketAt.keys()].filter((key) => !opened.has(key));
|
|
@@ -375,8 +437,9 @@ export function EntityList({ listing, api, columns: askedColumns, cells, views:
|
|
|
375
437
|
: copy.groups(groups.buckets.length, records) }))) : fits ? null : listing.paging === "pages" ? (page.from === 0 ? null : (_jsx(Pagination, { from: page.from, to: page.to, total: count?.value ?? page.to, ...(page.hasPrev ? { onPrev: listing.prev } : {}), ...(page.hasNext ? { onNext: listing.next } : {}) }))) : (_jsxs(_Fragment, { children: [count === null ? null : (_jsx("span", { className: "text-meta text-muted", children: copy.shown(listing.rows.length, count.value, count.exact) })), listing.capped ? (_jsx("span", { className: "text-meta text-muted", children: copy.capped(listing.rows.length) })) : listing.hasMore ? (_jsx(Button, { size: "sm", role: "secondary", disabled: listing.status === "loadingMore", onClick: listing.more, children: listing.status === "loadingMore" ? copy.loading : copy.loadMore })) : null] }));
|
|
376
438
|
const pageTotals = totalled && partial && present === "table";
|
|
377
439
|
// Written only when it says something: web-ui draws an embedded list's bar for any slot
|
|
378
|
-
// written, an empty one too.
|
|
379
|
-
|
|
440
|
+
// written, an empty one too. Its parts side by side and apart: the slot does not space them,
|
|
441
|
+
// and «Totales de esta página» read glued to «1–50 / 112».
|
|
442
|
+
const paging = !pageTotals && dropped.length === 0 && through === null ? null : (_jsxs("span", { className: "flex items-center gap-3", children: [pageTotals ? _jsx("span", { className: "text-meta text-muted", children: copy.pageTotals }) : null, dropped.length === 0 ? null : (_jsx(Tag, { tone: "warn", title: copy.dropped(dropped), children: copy.dropped(dropped) })), through] }));
|
|
380
443
|
return (_jsxs(List, { items: listing.rows, keyOf: idOf, embedded: embedded, present: present, onPresentChange: setPresent, ...grouping,
|
|
381
444
|
// The whole order, as web-ui 1.7 shows and sets it: ⇧-click on a header adds a field,
|
|
382
445
|
// the sort menu reorders them — the same list the criteria builder writes.
|
|
@@ -397,12 +460,17 @@ export function EntityList({ listing, api, columns: askedColumns, cells, views:
|
|
|
397
460
|
}, filtered: listing.selection !== undefined || listing.text !== "", empty: {
|
|
398
461
|
sentence: empty ?? copy.empty,
|
|
399
462
|
whenFiltered: { sentence: copy.emptyFiltered },
|
|
400
|
-
}, ...(selection === undefined ? {} : { selection }), ...(opening === undefined ? {} : { onOpen: opening }), ...(peeking === undefined ? {} : { onPeek: peeking, rowClick: "open" }),
|
|
463
|
+
}, ...(selection === undefined ? {} : { selection }), ...(opening === undefined ? {} : { onOpen: opening }), ...(peeking === undefined ? {} : { onPeek: peeking, rowClick: "open" }), ...(elsewhere.length === 0 || openingIn === undefined
|
|
464
|
+
? {}
|
|
465
|
+
: {
|
|
466
|
+
openTargets: elsewhere,
|
|
467
|
+
onOpenIn: (row, to) => openingNow.current?.(row, to),
|
|
468
|
+
}), children: [_jsxs(List.Bar, { children: [trail === undefined || trail.length === 0 ? null : _jsx(List.Crumbs, { crumbs: trail }), embedded ? null : (_jsx(List.Identity, { title: title ?? nameOf(meta, locale), ...(description === undefined ? {} : { description }) })), search === "bar" ? (_jsx(List.Search, { children: _jsx(EntitySearchBar, { listing: listing, filters: filters, groups: groups, ...(groupable === undefined ? {} : { groupable }), ...(facets === undefined ? {} : { facets }), ...(asked === "" ? {} : { seed: asked }) }) })) : null, search === "box" && meta?.search != null ? (_jsx(List.Search, { children: _jsx(SearchField, { value: draft, onChange: (next) => {
|
|
401
469
|
setDraft(next);
|
|
402
470
|
// Emptied (or cleared with ×): the whole set again, at once.
|
|
403
471
|
if (next === "" && listing.text !== "")
|
|
404
472
|
listing.search("", { now: true });
|
|
405
|
-
}, onSubmit: (text) => listing.search(text, { now: true }), placeholder: copy.search, "aria-label": copy.search }) })) : null,
|
|
473
|
+
}, onSubmit: (text) => listing.search(text, { now: true }), placeholder: copy.search, "aria-label": copy.search }) })) : null, started.drawn === null ? null : (_jsxs(List.Actions, { children: [started.drawn, creating === undefined ? null : (_jsx(Button, { role: "primary", size: "sm", onClick: creating, children: frameworkCopy().record.create }))] })), startDock.length === 0 && forChosen.dock.length === 0 ? null : (_jsx(List.Dock, { ...(startDock.length === 0 ? {} : { actions: startDock }), ...(forChosen.dock.length === 0 ? {} : { selection: forChosen.dock }) })), paging === null ? null : _jsx(List.Pagination, { children: paging })] }), views.includes("table") ? (_jsx(List.Table, { columns: shown, ...(totalled ? { totals: true } : {}), ...(rowActions === undefined ? {} : { rowActions }) })) : null, _jsx(List.Rows, { row: rowOf }), views.includes("sheet") ? (_jsx(List.Sheet, { columns: sheetColumns, cell: (row, column) => {
|
|
406
474
|
const value = row[column.id];
|
|
407
475
|
return value === null || value === undefined
|
|
408
476
|
? null
|