@sincpro/web-framework 0.1.0 → 0.3.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 +298 -40
- package/dist/core/cache.js +2 -2
- package/dist/core/copy.d.ts +26 -0
- package/dist/core/copy.js +32 -0
- package/dist/core/edit.d.ts +48 -3
- package/dist/core/edit.js +79 -5
- package/dist/core/entity.d.ts +46 -0
- package/dist/core/entity.js +57 -0
- package/dist/core/form.d.ts +21 -0
- package/dist/core/form.js +30 -0
- package/dist/core/index.d.ts +11 -3
- package/dist/core/index.js +10 -2
- package/dist/core/lines.d.ts +53 -0
- package/dist/core/lines.js +120 -0
- package/dist/core/list.d.ts +64 -0
- package/dist/core/list.js +22 -0
- package/dist/core/lookup.d.ts +7 -2
- package/dist/core/lookup.js +8 -2
- package/dist/core/measure.d.ts +16 -0
- package/dist/core/measure.js +38 -0
- package/dist/core/memory.js +18 -4
- package/dist/core/relation.d.ts +28 -0
- package/dist/core/relation.js +30 -0
- package/dist/core/rest.d.ts +5 -9
- package/dist/core/rest.js +25 -7
- package/dist/core/retry.d.ts +24 -0
- package/dist/core/retry.js +25 -0
- package/dist/core/summary.d.ts +50 -0
- package/dist/core/summary.js +54 -0
- package/dist/core/trail.d.ts +44 -0
- package/dist/core/trail.js +70 -0
- package/dist/core/transport.d.ts +22 -2
- package/dist/react/context.d.ts +20 -1
- package/dist/react/context.js +10 -2
- package/dist/react/index.d.ts +5 -2
- package/dist/react/index.js +4 -1
- package/dist/react/useCommand.d.ts +3 -1
- package/dist/react/useCommand.js +12 -4
- package/dist/react/useGroups.d.ts +52 -0
- package/dist/react/useGroups.js +110 -0
- package/dist/react/useListing.d.ts +29 -7
- package/dist/react/useListing.js +49 -8
- package/dist/react/useLookup.d.ts +30 -5
- package/dist/react/useLookup.js +56 -3
- package/dist/react/usePivot.d.ts +33 -0
- package/dist/react/usePivot.js +59 -0
- package/dist/react/useRecord.d.ts +28 -9
- package/dist/react/useRecord.js +156 -18
- package/dist/react/useSummary.d.ts +15 -0
- package/dist/react/useSummary.js +22 -0
- package/dist/web/index.d.ts +15 -3
- package/dist/web/index.js +14 -2
- package/dist/web/list/EntityList.d.ts +69 -7
- package/dist/web/list/EntityList.js +281 -23
- package/dist/web/list/EntitySearchBar.d.ts +16 -8
- package/dist/web/list/EntitySearchBar.js +52 -4
- package/dist/web/list/columns.d.ts +0 -13
- package/dist/web/list/columns.js +20 -1
- package/dist/web/list/groups.d.ts +17 -0
- package/dist/web/list/groups.js +80 -0
- package/dist/web/list/openIn.d.ts +41 -0
- package/dist/web/list/openIn.js +55 -0
- package/dist/web/list/pivot.d.ts +23 -0
- package/dist/web/list/pivot.js +64 -0
- package/dist/web/list/presentation.d.ts +51 -0
- package/dist/web/list/presentation.js +20 -0
- package/dist/web/list/rowCommands.d.ts +41 -0
- package/dist/web/list/rowCommands.js +56 -0
- package/dist/web/record/EntityPicker.d.ts +45 -14
- package/dist/web/record/EntityPicker.js +64 -20
- package/dist/web/record/EntityTags.d.ts +38 -0
- package/dist/web/record/EntityTags.js +52 -0
- package/dist/web/record/RelatedList.d.ts +8 -1
- package/dist/web/record/RelatedList.js +37 -3
- package/dist/web/record/control.d.ts +42 -0
- package/dist/web/record/control.js +60 -0
- package/dist/web/record/edit.d.ts +27 -12
- package/dist/web/record/edit.js +92 -25
- package/dist/web/record/lines.d.ts +84 -0
- package/dist/web/record/lines.js +190 -0
- package/dist/web/record/opening.d.ts +34 -0
- package/dist/web/record/opening.js +10 -0
- package/dist/web/record/summary.d.ts +22 -0
- package/dist/web/record/summary.js +63 -0
- package/dist/web/workspace/SincproApp.d.ts +4 -1
- package/dist/web/workspace/SincproApp.js +2 -2
- package/dist/web/workspace/composer.d.ts +27 -4
- package/dist/web/workspace/composer.js +75 -7
- package/dist/web/workspace/open.d.ts +49 -0
- package/dist/web/workspace/open.js +51 -0
- package/dist/web/workspace/record.d.ts +30 -0
- package/dist/web/workspace/record.js +83 -0
- package/dist/web/workspace/skin.d.ts +0 -9
- package/dist/web/workspace/skin.js +25 -13
- package/dist/web/workspace/workspace.d.ts +33 -3
- package/dist/web/workspace/workspace.js +63 -4
- package/package.json +9 -9
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { OpenOptions, WorkspaceApi } from "@sincpro/web-composer";
|
|
2
|
+
import { type OpenTarget } from "@sincpro/web-ui";
|
|
3
|
+
/**
|
|
4
|
+
* Where a record may open, and the menu that offers it.
|
|
5
|
+
*
|
|
6
|
+
* Context: a record opened from a list used to go one way — a press opened the page — and the
|
|
7
|
+
* other places (a look, beside, a window) were the composer's `RecordLink` icons, shown only to
|
|
8
|
+
* a pointer hovering the name of a TABLE row: nothing from the rows, the board, a one2many, and
|
|
9
|
+
* never a modal. A record opens anywhere the workspace can put it unless the screen says
|
|
10
|
+
* otherwise (`openTargets`), and «Abrir en…» says so where it is seen, in web-ui's own words
|
|
11
|
+
* (`openIn`) — the same menu a many2one already has.
|
|
12
|
+
*
|
|
13
|
+
* The places allowed depend on where the list is: from inside a modal, no modal (a second one
|
|
14
|
+
* would replace the first and lose what was typed in it) — composer says where a view is
|
|
15
|
+
* (`api.over`).
|
|
16
|
+
*/
|
|
17
|
+
/** A record's form fits; a short task (register a payment) passes its own size. */
|
|
18
|
+
export declare const RECORD_SIZE: {
|
|
19
|
+
readonly w: 760;
|
|
20
|
+
readonly h: 560;
|
|
21
|
+
};
|
|
22
|
+
/** Where a record may open from this view, the default first. */
|
|
23
|
+
export declare function targetsFor(api: Pick<WorkspaceApi, "over">): readonly OpenTarget[];
|
|
24
|
+
/** web-ui's target as composer's options. Destinations share their names, so only the size is
|
|
25
|
+
* added — to the two that have one. */
|
|
26
|
+
export declare function openOptions(to: OpenTarget, size?: {
|
|
27
|
+
w: number;
|
|
28
|
+
h: number;
|
|
29
|
+
}): OpenOptions;
|
|
30
|
+
/**
|
|
31
|
+
* «Abrir en…»: a visible menu of the places a record may open, beside its name. Nothing when
|
|
32
|
+
* there is one place or none — then a press is all there is.
|
|
33
|
+
*
|
|
34
|
+
* <OpenInMenu targets={["modal", "side", "window"]} onOpen={(to) => openIn(api, ref, to)} />
|
|
35
|
+
*/
|
|
36
|
+
export declare function OpenInMenu({ targets, onOpen, name, }: {
|
|
37
|
+
targets: readonly OpenTarget[];
|
|
38
|
+
onOpen: (to: OpenTarget) => void;
|
|
39
|
+
/** Whose menu it is, for a screen reader: «Abrir en… — F-2026-0004». */
|
|
40
|
+
name?: string;
|
|
41
|
+
}): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Menu, useUiCopy } from "@sincpro/web-ui";
|
|
4
|
+
import { AppWindow, Eye, FileText, PanelRight, SquareArrowOutUpRight, SquareStack, } from "lucide-react";
|
|
5
|
+
/**
|
|
6
|
+
* Where a record may open, and the menu that offers it.
|
|
7
|
+
*
|
|
8
|
+
* Context: a record opened from a list used to go one way — a press opened the page — and the
|
|
9
|
+
* other places (a look, beside, a window) were the composer's `RecordLink` icons, shown only to
|
|
10
|
+
* a pointer hovering the name of a TABLE row: nothing from the rows, the board, a one2many, and
|
|
11
|
+
* never a modal. A record opens anywhere the workspace can put it unless the screen says
|
|
12
|
+
* otherwise (`openTargets`), and «Abrir en…» says so where it is seen, in web-ui's own words
|
|
13
|
+
* (`openIn`) — the same menu a many2one already has.
|
|
14
|
+
*
|
|
15
|
+
* The places allowed depend on where the list is: from inside a modal, no modal (a second one
|
|
16
|
+
* would replace the first and lose what was typed in it) — composer says where a view is
|
|
17
|
+
* (`api.over`).
|
|
18
|
+
*/
|
|
19
|
+
/** A record's form fits; a short task (register a payment) passes its own size. */
|
|
20
|
+
export const RECORD_SIZE = { w: 760, h: 560 };
|
|
21
|
+
const EVERYWHERE = ["modal", "peek", "side", "page", "window"];
|
|
22
|
+
const FROM_A_MODAL = ["side", "peek", "page", "window"];
|
|
23
|
+
/** Where a record may open from this view, the default first. */
|
|
24
|
+
export function targetsFor(api) {
|
|
25
|
+
return api.over === null ? EVERYWHERE : FROM_A_MODAL;
|
|
26
|
+
}
|
|
27
|
+
/** web-ui's target as composer's options. Destinations share their names, so only the size is
|
|
28
|
+
* added — to the two that have one. */
|
|
29
|
+
export function openOptions(to, size = RECORD_SIZE) {
|
|
30
|
+
return to === "modal" || to === "window" ? { to, size } : { to };
|
|
31
|
+
}
|
|
32
|
+
const ICON = {
|
|
33
|
+
page: FileText,
|
|
34
|
+
peek: Eye,
|
|
35
|
+
modal: SquareStack,
|
|
36
|
+
side: PanelRight,
|
|
37
|
+
window: AppWindow,
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* «Abrir en…»: a visible menu of the places a record may open, beside its name. Nothing when
|
|
41
|
+
* there is one place or none — then a press is all there is.
|
|
42
|
+
*
|
|
43
|
+
* <OpenInMenu targets={["modal", "side", "window"]} onOpen={(to) => openIn(api, ref, to)} />
|
|
44
|
+
*/
|
|
45
|
+
export function OpenInMenu({ targets, onOpen, name, }) {
|
|
46
|
+
const copy = useUiCopy().picker;
|
|
47
|
+
if (targets.length === 0)
|
|
48
|
+
return null;
|
|
49
|
+
const options = targets.map((to) => ({
|
|
50
|
+
id: to,
|
|
51
|
+
label: copy.openIn[to],
|
|
52
|
+
icon: ICON[to],
|
|
53
|
+
}));
|
|
54
|
+
return (_jsx(Menu, { label: name === undefined ? copy.openMore : `${copy.openMore} ${name}`, title: copy.openMore, groups: [{ options }], onSelect: (id) => onOpen(id), icon: SquareArrowOutUpRight, iconOnly: true, size: "sm", role: "ghost", align: "end", width: "sm" }));
|
|
55
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type AnyRecord, type Bucket, type Meta } from "@sincpro/criteria";
|
|
2
|
+
import type { GroupLevel } from "../../core/list.js";
|
|
3
|
+
import type { Pivot } from "@sincpro/web-ui";
|
|
4
|
+
/**
|
|
5
|
+
* web-ui's `Pivot` (`folded`), from what the SERVER counted (`usePivot`): the rows axis is the
|
|
6
|
+
* outer groups, the columns axis every inner value that appeared, each crossing an inner group,
|
|
7
|
+
* each row's total its outer group, each column's total the grouping by the columns alone.
|
|
8
|
+
* Nothing is added up here — a margin is read from the base, never summed from cells.
|
|
9
|
+
*
|
|
10
|
+
* A key is how its value READS («Pagada», «Efectivo»): the grid draws keys, and the server's
|
|
11
|
+
* value («paid») is not a word for a person.
|
|
12
|
+
*/
|
|
13
|
+
export declare function pivotOf<T extends AnyRecord>({ crossed, byColumn, rows, columns, measures, meta, locale, }: {
|
|
14
|
+
/** Grouped by rows, then columns (`usePivot().crossed`). */
|
|
15
|
+
crossed: readonly Bucket<T>[];
|
|
16
|
+
/** Grouped by the columns alone (`usePivot().columns`). */
|
|
17
|
+
byColumn: readonly Bucket<T>[];
|
|
18
|
+
rows: GroupLevel;
|
|
19
|
+
columns: GroupLevel;
|
|
20
|
+
measures: readonly string[];
|
|
21
|
+
meta: Meta | null | undefined;
|
|
22
|
+
locale: string | undefined;
|
|
23
|
+
}): Pivot;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { labelOf } from "@sincpro/criteria";
|
|
2
|
+
import { frameworkCopy } from "../../core/copy.js";
|
|
3
|
+
import { textOf } from "../../core/present.js";
|
|
4
|
+
/**
|
|
5
|
+
* web-ui's `Pivot` (`folded`), from what the SERVER counted (`usePivot`): the rows axis is the
|
|
6
|
+
* outer groups, the columns axis every inner value that appeared, each crossing an inner group,
|
|
7
|
+
* each row's total its outer group, each column's total the grouping by the columns alone.
|
|
8
|
+
* Nothing is added up here — a margin is read from the base, never summed from cells.
|
|
9
|
+
*
|
|
10
|
+
* A key is how its value READS («Pagada», «Efectivo»): the grid draws keys, and the server's
|
|
11
|
+
* value («paid») is not a word for a person.
|
|
12
|
+
*/
|
|
13
|
+
export function pivotOf({ crossed, byColumn, rows, columns, measures, meta, locale, }) {
|
|
14
|
+
const none = frameworkCopy().list.noValue;
|
|
15
|
+
const keyOf = (bucket) => bucket.value === null || bucket.value === undefined || bucket.value === ""
|
|
16
|
+
? none
|
|
17
|
+
: (textOf(meta, bucket.field, bucket.value, locale) ?? String(bucket.value));
|
|
18
|
+
const cellOf = (bucket) => ({
|
|
19
|
+
count: bucket.count,
|
|
20
|
+
values: Object.fromEntries(measures.map((name) => {
|
|
21
|
+
const value = bucket.measures?.[name];
|
|
22
|
+
return [name, value === null || value === undefined ? null : Number(value)];
|
|
23
|
+
})),
|
|
24
|
+
});
|
|
25
|
+
const rowKeys = crossed.map((bucket) => [keyOf(bucket)]);
|
|
26
|
+
// Columns in the server's order of the columns alone; any value only a crossing has, after.
|
|
27
|
+
const seen = new Set(byColumn.map(keyOf));
|
|
28
|
+
const columnKeys = [...seen];
|
|
29
|
+
for (const outer of crossed)
|
|
30
|
+
for (const inner of outer.groups ?? []) {
|
|
31
|
+
const key = keyOf(inner);
|
|
32
|
+
if (!seen.has(key)) {
|
|
33
|
+
seen.add(key);
|
|
34
|
+
columnKeys.push(key);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const at = new Map();
|
|
38
|
+
const rowTotals = new Map();
|
|
39
|
+
for (const outer of crossed) {
|
|
40
|
+
const row = keyOf(outer);
|
|
41
|
+
rowTotals.set(row, cellOf(outer));
|
|
42
|
+
for (const inner of outer.groups ?? [])
|
|
43
|
+
at.set(`${row}\u0000${keyOf(inner)}`, cellOf(inner));
|
|
44
|
+
}
|
|
45
|
+
const columnTotals = new Map(byColumn.map((bucket) => [keyOf(bucket), cellOf(bucket)]));
|
|
46
|
+
return {
|
|
47
|
+
rows: {
|
|
48
|
+
levels: [{ ...rows, label: labelOf(meta, rows.field, locale) }],
|
|
49
|
+
keys: rowKeys,
|
|
50
|
+
},
|
|
51
|
+
columns: {
|
|
52
|
+
levels: [{ ...columns, label: labelOf(meta, columns.field, locale) }],
|
|
53
|
+
keys: columnKeys.map((key) => [key]),
|
|
54
|
+
},
|
|
55
|
+
measures: measures.map((name) => ({
|
|
56
|
+
id: name,
|
|
57
|
+
header: labelOf(meta, name, locale),
|
|
58
|
+
format: (value) => textOf(meta, name, value, locale) ?? String(value),
|
|
59
|
+
})),
|
|
60
|
+
cell: (row, column) => at.get(`${row[0] ?? ""}\u0000${column[0] ?? ""}`),
|
|
61
|
+
rowTotal: (row) => rowTotals.get(row[0] ?? ""),
|
|
62
|
+
columnTotal: (column) => columnTotals.get(column[0] ?? ""),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { AnyRecord } from "@sincpro/criteria";
|
|
2
|
+
import type { Entity } from "../../core/entity.js";
|
|
3
|
+
import { type ListDefinition } from "../../core/list.js";
|
|
4
|
+
import type { PickerItem, RecordCard, RowOf } from "@sincpro/web-ui";
|
|
5
|
+
import type { ComponentProps } from "react";
|
|
6
|
+
/**
|
|
7
|
+
* How a record of an entity looks at each size — a choice, a row, a card — declared ONCE with
|
|
8
|
+
* the entity and used wherever the framework draws one of its records.
|
|
9
|
+
*
|
|
10
|
+
* Context: the name of a record is the backend's (`meta.display`, Odoo's `display_name`) and
|
|
11
|
+
* its parts are the summary's (`entity(…, { summary })`); what was missing is how it is DRAWN.
|
|
12
|
+
* Every place built its own: the picker's option was always name + key + face, the rows face
|
|
13
|
+
* name + three facts, the board's card whatever the row said. Now an application says it once:
|
|
14
|
+
*
|
|
15
|
+
* export const customers = presented(entity<Customer>("sales:customer", { list: "/customers" }), {
|
|
16
|
+
* option: (c) => ({ meta: c.tax_id, aside: <Saldo value={c.balance} /> }),
|
|
17
|
+
* row: (c) => ({ tags: c.blocked ? <Tag tone="bad">Bloqueado</Tag> : undefined }),
|
|
18
|
+
* card: (c) => ({ subtitle: c.city, figure: <Saldo value={c.balance} /> }),
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* Each size answers the PROPS of web-ui's piece for it (`PickerItem`, `RowOf`, `RecordCard`),
|
|
22
|
+
* merged OVER the default: give only what changes, and what is not given stays as it was.
|
|
23
|
+
* Props and not components for the reason `factsOf`/`columnsOf` give: web-ui keeps the
|
|
24
|
+
* keyboard, the highlight of what was typed, the press rule and the accessibility of the
|
|
25
|
+
* piece, and finds its slots by type. A whole component of the application in an option's
|
|
26
|
+
* place needs web-ui to take one (`ROADMAP.md`).
|
|
27
|
+
*
|
|
28
|
+
* A function around `entity()` and not a field of it: `core/` draws nothing and cannot name a
|
|
29
|
+
* React node; the presentation is the web's, so it is added here. The result IS the entity —
|
|
30
|
+
* every place that takes one takes it — with its presentation on board.
|
|
31
|
+
*/
|
|
32
|
+
/** A choice in a many2one, a many2many and ⌘K. ⌘K writes only text: `name` and `meta`. */
|
|
33
|
+
export type OptionLook = Partial<Omit<PickerItem, "id">>;
|
|
34
|
+
/** A row of the «rows» face — and of the board's card when there is no `card`. */
|
|
35
|
+
export type RowLook = Partial<RowOf>;
|
|
36
|
+
/** The board's card. Opening it stays the list's: `onOpen` is not the presentation's. */
|
|
37
|
+
export type CardLook = Partial<Omit<ComponentProps<typeof RecordCard>, "onOpen">>;
|
|
38
|
+
export type Presentation<T> = {
|
|
39
|
+
option?: (record: T) => OptionLook;
|
|
40
|
+
row?: (record: T) => RowLook;
|
|
41
|
+
card?: (record: T) => CardLook;
|
|
42
|
+
};
|
|
43
|
+
export type Presented<T extends AnyRecord> = Entity<T> & {
|
|
44
|
+
readonly presentation: Presentation<T>;
|
|
45
|
+
};
|
|
46
|
+
/** The entity with how its records look: pass it wherever an entity goes. */
|
|
47
|
+
export declare function presented<T extends AnyRecord>(entity: Entity<T>, presentation: Presentation<T>): Presented<T>;
|
|
48
|
+
/** The presentation an entity — or the entity of a named list — was declared with; none is `{}`. */
|
|
49
|
+
export declare function presentationOf<T extends AnyRecord>(source: Entity<T> | ListDefinition<T>): Presentation<T>;
|
|
50
|
+
/** `look` over `base`, leaving out what `look` sets to `undefined`: «no tags» is not a hole. */
|
|
51
|
+
export declare function over<B extends object, L extends object>(base: B, look: L | undefined): B;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { isList } from "../../core/list.js";
|
|
2
|
+
/** The entity with how its records look: pass it wherever an entity goes. */
|
|
3
|
+
export function presented(entity, presentation) {
|
|
4
|
+
return { ...entity, presentation };
|
|
5
|
+
}
|
|
6
|
+
/** The presentation an entity — or the entity of a named list — was declared with; none is `{}`. */
|
|
7
|
+
export function presentationOf(source) {
|
|
8
|
+
const base = isList(source) ? source.entity : source;
|
|
9
|
+
return "presentation" in base ? base.presentation : {};
|
|
10
|
+
}
|
|
11
|
+
/** `look` over `base`, leaving out what `look` sets to `undefined`: «no tags» is not a hole. */
|
|
12
|
+
export function over(base, look) {
|
|
13
|
+
if (look === undefined)
|
|
14
|
+
return base;
|
|
15
|
+
const out = { ...base };
|
|
16
|
+
for (const [key, value] of Object.entries(look))
|
|
17
|
+
if (value !== undefined)
|
|
18
|
+
out[key] = value;
|
|
19
|
+
return out;
|
|
20
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type AnyRecord, type Expression } from "@sincpro/criteria";
|
|
2
|
+
import type { Listing } from "../../react/useListing.js";
|
|
3
|
+
import type { RowAction } from "@sincpro/web-ui";
|
|
4
|
+
import type { LucideIcon } from "lucide-react";
|
|
5
|
+
/**
|
|
6
|
+
* An entity's Commands as the actions of a row: «Confirmar» on each invoice, without opening it.
|
|
7
|
+
*
|
|
8
|
+
* Context: web-ui draws a row's actions (`rowActions`) and knows nothing of what they do; the
|
|
9
|
+
* entity knows its Commands and their routes. This joins them, with the rules a Command keeps
|
|
10
|
+
* everywhere: sent once per gesture with its `Idempotency-Key` (a retry is the same Command),
|
|
11
|
+
* the row's action disabled while it runs, and the list read again when it is done — the server
|
|
12
|
+
* says what the row became. `when` is a condition over the row, evaluated the way the server's
|
|
13
|
+
* hints are (`matches`): «Confirmar» only on drafts.
|
|
14
|
+
*
|
|
15
|
+
* Only Commands that can be undone belong on a row. One that destroys is confirmed by its dry
|
|
16
|
+
* run, and that is the record's `CommandButton`, where the consequence has room to be read.
|
|
17
|
+
*
|
|
18
|
+
* const commands = useRowCommands(listing, [
|
|
19
|
+
* { command: "confirmar", label: "Confirmar", icon: Check,
|
|
20
|
+
* when: { field: "state", operator: "=", value: "draft" } },
|
|
21
|
+
* ]);
|
|
22
|
+
* <EntityList listing={listing} rowActions={commands.rowActions} />
|
|
23
|
+
*/
|
|
24
|
+
export type RowCommand<T> = {
|
|
25
|
+
/** A Command the entity declares (`entity({ commands })`). */
|
|
26
|
+
command: string;
|
|
27
|
+
label: string;
|
|
28
|
+
icon: LucideIcon;
|
|
29
|
+
tone?: RowAction["tone"];
|
|
30
|
+
/** Offered only on rows that hold it — a hint, not protection: the server decides. */
|
|
31
|
+
when?: Expression<T>;
|
|
32
|
+
/** What the Command is sent with. Without it, an empty body: the route names the row. */
|
|
33
|
+
body?: (row: T) => AnyRecord;
|
|
34
|
+
};
|
|
35
|
+
export type RowCommands<T> = {
|
|
36
|
+
rowActions: (row: T) => readonly RowAction[];
|
|
37
|
+
/** The last refusal, until `dismiss`. */
|
|
38
|
+
error: unknown;
|
|
39
|
+
dismiss: () => void;
|
|
40
|
+
};
|
|
41
|
+
export declare function useRowCommands<T extends AnyRecord>(listing: Listing<T>, commands: readonly RowCommand<T>[]): RowCommands<T>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { matches } from "@sincpro/criteria";
|
|
3
|
+
import { pathFor } from "../../core/entity.js";
|
|
4
|
+
import { retryKeys } from "../../core/retry.js";
|
|
5
|
+
import { useFramework } from "../../react/context.js";
|
|
6
|
+
import { useCallback, useState } from "react";
|
|
7
|
+
export function useRowCommands(listing, commands) {
|
|
8
|
+
const { transport } = useFramework();
|
|
9
|
+
const [running, setRunning] = useState(new Set());
|
|
10
|
+
const [error, setError] = useState(null);
|
|
11
|
+
// One key per row and Command, kept while it goes unanswered: retrying is the same gesture.
|
|
12
|
+
const [keys] = useState(() => new Map());
|
|
13
|
+
const { entity, meta } = listing;
|
|
14
|
+
const key = meta?.get_id || meta?.identity || "id";
|
|
15
|
+
const run = useCallback(async (one, row) => {
|
|
16
|
+
const route = entity.commands[one.command];
|
|
17
|
+
if (route === undefined)
|
|
18
|
+
throw new Error(`${entity.key} declares no command "${one.command}"`);
|
|
19
|
+
const id = String(row[key]);
|
|
20
|
+
const gesture = `${one.command}\u0000${id}`;
|
|
21
|
+
const retry = keys.get(gesture) ?? retryKeys();
|
|
22
|
+
keys.set(gesture, retry);
|
|
23
|
+
const body = one.body?.(row) ?? {};
|
|
24
|
+
setRunning((now) => new Set(now).add(gesture));
|
|
25
|
+
setError(null);
|
|
26
|
+
try {
|
|
27
|
+
await transport.send(route.method, pathFor(route, id), body, undefined, {
|
|
28
|
+
idempotencyKey: retry.keyFor(body),
|
|
29
|
+
});
|
|
30
|
+
retry.settle(null);
|
|
31
|
+
listing.reload();
|
|
32
|
+
}
|
|
33
|
+
catch (failure) {
|
|
34
|
+
retry.settle(failure);
|
|
35
|
+
setError(failure);
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
setRunning((now) => {
|
|
39
|
+
const next = new Set(now);
|
|
40
|
+
next.delete(gesture);
|
|
41
|
+
return next;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}, [transport, entity, key, keys, listing]);
|
|
45
|
+
const rowActions = (row) => commands
|
|
46
|
+
.filter((one) => meta === null || one.when === undefined || matches(row, one.when, meta))
|
|
47
|
+
.map((one) => ({
|
|
48
|
+
id: one.command,
|
|
49
|
+
label: one.label,
|
|
50
|
+
icon: one.icon,
|
|
51
|
+
...(one.tone === undefined ? {} : { tone: one.tone }),
|
|
52
|
+
disabled: running.has(`${one.command}\u0000${String(row[key])}`),
|
|
53
|
+
onSelect: () => void run(one, row),
|
|
54
|
+
}));
|
|
55
|
+
return { rowActions, error, dismiss: () => setError(null) };
|
|
56
|
+
}
|
|
@@ -1,26 +1,57 @@
|
|
|
1
|
-
import type { AnyRecord } from "@sincpro/criteria";
|
|
1
|
+
import type { AnyRecord, Criteria } from "@sincpro/criteria";
|
|
2
2
|
import type { Entity } from "../../core/entity.js";
|
|
3
|
+
import { type ListDefinition } from "../../core/list.js";
|
|
4
|
+
import { type OpenTarget } from "@sincpro/web-ui";
|
|
3
5
|
/**
|
|
4
6
|
* A many2one: pick ONE record of an entity — web-ui's `Picker` fed by `useLookup`, with a way
|
|
5
7
|
* into the whole set however big it is.
|
|
6
8
|
*
|
|
7
|
-
* Context: two ways to choose, for two sizes. The picker
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Context: two ways to choose, for two sizes. The picker opens on the first ten in the entity's
|
|
10
|
+
* order, and what is typed is the entity's literal search, asked of the SERVER (`Picker
|
|
11
|
+
* onSearch`): the record 123 455 of 200 000 is found by its name. The chosen one keeps its name
|
|
12
|
+
* when it is not among the ten (`valueLabel`). For a question the ten cannot answer — two of the
|
|
13
|
+
* same name, a column to compare — «Buscar más…» opens a chooser: the entity's full list,
|
|
14
|
+
* searched, ordered and paged by the server, where clicking a row answers the field. An entity
|
|
15
|
+
* without a search template is filtered where it is.
|
|
12
16
|
*
|
|
13
17
|
* Inside a workspace, «open» and the chooser can be the composer's instead (`api.open`,
|
|
14
|
-
* `api.pick`): pass `onOpen` / `onBrowseAll` and they replace the defaults
|
|
18
|
+
* `api.pick`): pass `onOpen` / `onBrowseAll` and they replace the defaults — `chooserIn(api,
|
|
19
|
+
* entity, onChange)` is that `onBrowseAll`.
|
|
20
|
+
*
|
|
21
|
+
* `criteria` narrows what may be chosen — the contacts of the chosen customer — in the picker
|
|
22
|
+
* and in its chooser alike; the server applies it, and a new one starts the choices over. A
|
|
23
|
+
* named list (`defineList`) does the same declared once: «active customers» brings its cut, its
|
|
24
|
+
* columns and its title to the chooser.
|
|
25
|
+
*
|
|
26
|
+
* The chooser is ALWAYS one click away (`browse`, on by default): web-ui's `Picker` offers
|
|
27
|
+
* «see all…» only while it holds rows it does not draw, so with a short first page there was no
|
|
28
|
+
* way to the server's literal search. The chooser is a table — the columns the list declares,
|
|
29
|
+
* or `columns` — searched by the entity's literal search on the server.
|
|
30
|
+
*
|
|
31
|
+
* <EntityPicker entity={customers} value={id} onChange={set} />
|
|
32
|
+
* <EntityPicker entity={activeCustomers} columns={["name", "tax_id", "city"]} … />
|
|
15
33
|
*/
|
|
16
|
-
export declare function EntityPicker<T extends AnyRecord>({ entity, value, onChange, onOpen, onBrowseAll, placeholder, disabled, "aria-label": ariaLabel, }: {
|
|
17
|
-
|
|
34
|
+
export declare function EntityPicker<T extends AnyRecord>({ entity, value, onChange, onOpen, openTargets, onBrowseAll, criteria, columns, browse, placeholder, disabled, "aria-label": ariaLabel, }: {
|
|
35
|
+
/** What is chosen from: an entity, or a named list of it (its cut, columns and title). */
|
|
36
|
+
entity: Entity<T> | ListDefinition<T>;
|
|
37
|
+
/** The chooser's columns. Without it, the named list's, or every scalar field. */
|
|
38
|
+
columns?: readonly string[];
|
|
39
|
+
/** A button beside the field that opens the chooser: the server's literal search, as a table. */
|
|
40
|
+
browse?: boolean;
|
|
41
|
+
/** Which records may be chosen at all: applied by the server under what is typed. */
|
|
42
|
+
criteria?: Criteria<T>;
|
|
18
43
|
value?: string;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
|
|
44
|
+
/** The key chosen, and its record when the choice brought it — what a line keeps beside the
|
|
45
|
+
* key so its cell names the choice without asking again. */
|
|
46
|
+
onChange: (id: string, chosen?: T) => void;
|
|
47
|
+
/** Open the chosen record where the person asked — in composer,
|
|
48
|
+
* `(id, to) => openIn(api, entity.ref(id), to)`. */
|
|
49
|
+
onOpen?: (id: string, to: OpenTarget) => void;
|
|
50
|
+
/** Where it may open, the default first (a modal; from inside a modal, beside). */
|
|
51
|
+
openTargets?: readonly OpenTarget[];
|
|
52
|
+
/** Replace the built-in chooser — in composer, `api.pick(entity.chooserRef(), …)`. It gets
|
|
53
|
+
* what was typed, so the list opens on the same search. */
|
|
54
|
+
onBrowseAll?: (query: string) => void;
|
|
24
55
|
placeholder?: string;
|
|
25
56
|
disabled?: boolean;
|
|
26
57
|
"aria-label"?: string;
|
|
@@ -1,39 +1,83 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx,
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { nameOf } from "@sincpro/criteria";
|
|
4
|
+
import { frameworkCopy } from "../../core/copy.js";
|
|
5
|
+
import { isList } from "../../core/list.js";
|
|
4
6
|
import { useListing } from "../../react/useListing.js";
|
|
5
7
|
import { useLookup } from "../../react/useLookup.js";
|
|
6
8
|
import { EntityList } from "../list/EntityList.js";
|
|
7
|
-
import {
|
|
9
|
+
import { over, presentationOf } from "../list/presentation.js";
|
|
10
|
+
import { Dialog, IconButton, Picker } from "@sincpro/web-ui";
|
|
11
|
+
import { TextSearch } from "lucide-react";
|
|
8
12
|
import { useState } from "react";
|
|
9
13
|
/**
|
|
10
14
|
* A many2one: pick ONE record of an entity — web-ui's `Picker` fed by `useLookup`, with a way
|
|
11
15
|
* into the whole set however big it is.
|
|
12
16
|
*
|
|
13
|
-
* Context: two ways to choose, for two sizes. The picker
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
17
|
+
* Context: two ways to choose, for two sizes. The picker opens on the first ten in the entity's
|
|
18
|
+
* order, and what is typed is the entity's literal search, asked of the SERVER (`Picker
|
|
19
|
+
* onSearch`): the record 123 455 of 200 000 is found by its name. The chosen one keeps its name
|
|
20
|
+
* when it is not among the ten (`valueLabel`). For a question the ten cannot answer — two of the
|
|
21
|
+
* same name, a column to compare — «Buscar más…» opens a chooser: the entity's full list,
|
|
22
|
+
* searched, ordered and paged by the server, where clicking a row answers the field. An entity
|
|
23
|
+
* without a search template is filtered where it is.
|
|
18
24
|
*
|
|
19
25
|
* Inside a workspace, «open» and the chooser can be the composer's instead (`api.open`,
|
|
20
|
-
* `api.pick`): pass `onOpen` / `onBrowseAll` and they replace the defaults
|
|
26
|
+
* `api.pick`): pass `onOpen` / `onBrowseAll` and they replace the defaults — `chooserIn(api,
|
|
27
|
+
* entity, onChange)` is that `onBrowseAll`.
|
|
28
|
+
*
|
|
29
|
+
* `criteria` narrows what may be chosen — the contacts of the chosen customer — in the picker
|
|
30
|
+
* and in its chooser alike; the server applies it, and a new one starts the choices over. A
|
|
31
|
+
* named list (`defineList`) does the same declared once: «active customers» brings its cut, its
|
|
32
|
+
* columns and its title to the chooser.
|
|
33
|
+
*
|
|
34
|
+
* The chooser is ALWAYS one click away (`browse`, on by default): web-ui's `Picker` offers
|
|
35
|
+
* «see all…» only while it holds rows it does not draw, so with a short first page there was no
|
|
36
|
+
* way to the server's literal search. The chooser is a table — the columns the list declares,
|
|
37
|
+
* or `columns` — searched by the entity's literal search on the server.
|
|
38
|
+
*
|
|
39
|
+
* <EntityPicker entity={customers} value={id} onChange={set} />
|
|
40
|
+
* <EntityPicker entity={activeCustomers} columns={["name", "tax_id", "city"]} … />
|
|
21
41
|
*/
|
|
22
|
-
export function EntityPicker({ entity, value, onChange, onOpen, onBrowseAll, placeholder, disabled, "aria-label": ariaLabel, }) {
|
|
23
|
-
const lookup = useLookup(entity
|
|
42
|
+
export function EntityPicker({ entity, value, onChange, onOpen, openTargets, onBrowseAll, criteria, columns, browse = true, placeholder, disabled, "aria-label": ariaLabel, }) {
|
|
43
|
+
const lookup = useLookup(entity, {
|
|
44
|
+
...(criteria === undefined ? {} : { criteria }),
|
|
45
|
+
...(value === undefined ? {} : { value }),
|
|
46
|
+
});
|
|
47
|
+
const person = (isList(entity) ? entity.entity : entity).summary.person === true;
|
|
48
|
+
const look = presentationOf(entity).option;
|
|
24
49
|
const [choosing, setChoosing] = useState(false);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
50
|
+
const browseAll = onBrowseAll ?? (() => setChoosing(true));
|
|
51
|
+
const picker = (_jsx(Picker, { items: lookup.options.map((one) => over({
|
|
52
|
+
id: one.id,
|
|
53
|
+
name: one.label,
|
|
54
|
+
...(one.detail === undefined ? {} : { meta: one.detail, haystack: one.detail }),
|
|
55
|
+
// A person or a company is chosen by their face: the photo, or their initials.
|
|
56
|
+
...(person ? { avatar: one.image ?? true } : {}),
|
|
57
|
+
},
|
|
58
|
+
// The entity's own look of a choice, over the default (`presented`).
|
|
59
|
+
look === undefined || one.record === undefined ? undefined : look(one.record))), ...(value === undefined ? {} : { value }), ...(lookup.chosen === undefined
|
|
60
|
+
? {}
|
|
61
|
+
: {
|
|
62
|
+
valueLabel: (lookup.chosen.record === undefined || look === undefined
|
|
63
|
+
? undefined
|
|
64
|
+
: look(lookup.chosen.record).name) ?? lookup.chosen.label,
|
|
65
|
+
}), onChange: (id) => onChange(id, lookup.options.find((one) => one.id === id)?.record), ...(lookup.searchable ? { onSearch: lookup.search } : {}),
|
|
66
|
+
// «Loading» only before there is anything: refining keeps the ten on screen.
|
|
67
|
+
loading: lookup.loading && lookup.options.length === 0, ...(onOpen === undefined ? {} : { onOpen }), ...(openTargets === undefined ? {} : { openTargets }), onBrowseAll: browseAll, ...(placeholder === undefined ? {} : { placeholder }), ...(disabled === undefined ? {} : { disabled }), ...(ariaLabel === undefined ? {} : { "aria-label": ariaLabel }) }));
|
|
68
|
+
return (_jsxs(_Fragment, { children: [browse ? (_jsxs("span", { className: "flex min-w-0 items-start gap-1", children: [_jsx("span", { className: "min-w-0 flex-1", children: picker }), _jsx(IconButton, { icon: TextSearch, label: frameworkCopy().picker.browse, onClick: () => browseAll(lookup.text), ...(disabled === undefined ? {} : { disabled }) })] })) : (picker), choosing ? (_jsx(Chooser, { entity: entity, ...(columns === undefined ? {} : { columns }), ...(criteria === undefined ? {} : { criteria }), onChoose: (id, row) => {
|
|
69
|
+
onChange(id, row);
|
|
31
70
|
setChoosing(false);
|
|
32
71
|
}, onClose: () => setChoosing(false) })) : null] }));
|
|
33
72
|
}
|
|
34
|
-
/** The whole set in a window: search and pages on the server, a row
|
|
35
|
-
|
|
36
|
-
|
|
73
|
+
/** The whole set in a window, as a table: literal search and pages on the server, a row
|
|
74
|
+
* answers the field. */
|
|
75
|
+
function Chooser({ entity, columns, criteria, onChoose, onClose, }) {
|
|
76
|
+
const listing = useListing(entity, {
|
|
77
|
+
pageSize: 20,
|
|
78
|
+
...(criteria === undefined ? {} : { criteria }),
|
|
79
|
+
});
|
|
37
80
|
const key = listing.meta?.get_id || listing.meta?.identity || "id";
|
|
38
|
-
return (_jsx(Dialog, { open: true, width: "lg", title:
|
|
81
|
+
return (_jsx(Dialog, { open: true, width: "lg", title: (isList(entity) ? entity.title : nameOf(listing.meta, listing.locale)) ||
|
|
82
|
+
listing.entity.kind, onClose: onClose, children: _jsx(EntityList, { listing: listing, embedded: true, ...(columns === undefined ? {} : { columns }), onOpen: (row) => onChoose(String(row[key]), row) }) }));
|
|
39
83
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { AnyRecord, Criteria } from "@sincpro/criteria";
|
|
2
|
+
import type { Entity } from "../../core/entity.js";
|
|
3
|
+
import { type ListDefinition } from "../../core/list.js";
|
|
4
|
+
import { type OpenTarget } from "@sincpro/web-ui";
|
|
5
|
+
/**
|
|
6
|
+
* A many2many: put SEVERAL records of an entity on this one — the followers of an invoice,
|
|
7
|
+
* the products of a promotion — as web-ui's `TagsField` chips, fed by `useLookup`.
|
|
8
|
+
*
|
|
9
|
+
* Context: the same literal search as a many2one, for N. The field opens on the first ten in
|
|
10
|
+
* the entity's order, and what is typed is asked of the SERVER (`TagsField onSearch`): a
|
|
11
|
+
* product among three thousand is found by its code though no chip shows it. The chosen never
|
|
12
|
+
* come back as options, and they keep their names wherever they lie — remembered, or asked
|
|
13
|
+
* once by their keys. A person or a company (`entity(…, { summary: { person: true } })`) is
|
|
14
|
+
* chosen by their face.
|
|
15
|
+
*
|
|
16
|
+
* Opening a chip is the composer's (`onOpen` — a preview by default: a chip is a glance at one
|
|
17
|
+
* of many), and «Buscar más…» is the list that adds (`onBrowseAll`, `api.pick` with the list in
|
|
18
|
+
* its choosing mode). Without a workspace a chip is a value.
|
|
19
|
+
*
|
|
20
|
+
* <EntityTags entity={people} value={followers} onChange={setFollowers} />
|
|
21
|
+
*/
|
|
22
|
+
export declare function EntityTags<T extends AnyRecord>({ entity, value, onChange, criteria, onOpen, openTarget, onBrowseAll, placeholder, disabled, "aria-label": ariaLabel, }: {
|
|
23
|
+
/** What is chosen from: an entity, or a named list of it. */
|
|
24
|
+
entity: Entity<T> | ListDefinition<T>;
|
|
25
|
+
/** The keys chosen, in the order they were added — what the backend stores. */
|
|
26
|
+
value: readonly string[];
|
|
27
|
+
onChange: (next: string[]) => void;
|
|
28
|
+
/** Which records may be put at all: applied by the server under what is typed. */
|
|
29
|
+
criteria?: Criteria<T>;
|
|
30
|
+
/** Open the record behind a chip — in composer, `(id, to) => openIn(api, entity.ref(id), to)`. */
|
|
31
|
+
onOpen?: (id: string, to: OpenTarget) => void;
|
|
32
|
+
openTarget?: OpenTarget;
|
|
33
|
+
/** «Buscar más…»: the list that adds several at once, opened on what was typed. */
|
|
34
|
+
onBrowseAll?: (query: string) => void;
|
|
35
|
+
placeholder?: string;
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
"aria-label"?: string;
|
|
38
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { isList } from "../../core/list.js";
|
|
4
|
+
import { useLookup } from "../../react/useLookup.js";
|
|
5
|
+
import { presentationOf } from "../list/presentation.js";
|
|
6
|
+
import { TagsField } from "@sincpro/web-ui";
|
|
7
|
+
/**
|
|
8
|
+
* A many2many: put SEVERAL records of an entity on this one — the followers of an invoice,
|
|
9
|
+
* the products of a promotion — as web-ui's `TagsField` chips, fed by `useLookup`.
|
|
10
|
+
*
|
|
11
|
+
* Context: the same literal search as a many2one, for N. The field opens on the first ten in
|
|
12
|
+
* the entity's order, and what is typed is asked of the SERVER (`TagsField onSearch`): a
|
|
13
|
+
* product among three thousand is found by its code though no chip shows it. The chosen never
|
|
14
|
+
* come back as options, and they keep their names wherever they lie — remembered, or asked
|
|
15
|
+
* once by their keys. A person or a company (`entity(…, { summary: { person: true } })`) is
|
|
16
|
+
* chosen by their face.
|
|
17
|
+
*
|
|
18
|
+
* Opening a chip is the composer's (`onOpen` — a preview by default: a chip is a glance at one
|
|
19
|
+
* of many), and «Buscar más…» is the list that adds (`onBrowseAll`, `api.pick` with the list in
|
|
20
|
+
* its choosing mode). Without a workspace a chip is a value.
|
|
21
|
+
*
|
|
22
|
+
* <EntityTags entity={people} value={followers} onChange={setFollowers} />
|
|
23
|
+
*/
|
|
24
|
+
export function EntityTags({ entity, value, onChange, criteria, onOpen, openTarget, onBrowseAll, placeholder, disabled, "aria-label": ariaLabel, }) {
|
|
25
|
+
const lookup = useLookup(entity, {
|
|
26
|
+
...(criteria === undefined ? {} : { criteria }),
|
|
27
|
+
values: value,
|
|
28
|
+
});
|
|
29
|
+
const person = (isList(entity) ? entity.entity : entity).summary.person === true;
|
|
30
|
+
const look = presentationOf(entity).option;
|
|
31
|
+
// A chip says a name and shows a face; the list under it also the datum that tells two apart
|
|
32
|
+
// (web-ui 1.5 `TagOption.meta`, never on the chip). Of the entity's look of a choice, those
|
|
33
|
+
// three — as text: a tag option is plain.
|
|
34
|
+
const asTag = (one) => {
|
|
35
|
+
const own = look === undefined || one.record === undefined ? {} : look(one.record);
|
|
36
|
+
const avatar = own.avatar ?? (person ? (one.image ?? true) : undefined);
|
|
37
|
+
const meta = typeof own.meta === "string" ? own.meta : one.detail;
|
|
38
|
+
return {
|
|
39
|
+
value: one.id,
|
|
40
|
+
label: own.name ?? one.label,
|
|
41
|
+
...(avatar === undefined ? {} : { avatar }),
|
|
42
|
+
...(meta === undefined || meta === "" ? {} : { meta }),
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
const offered = new Set(lookup.options.map((one) => one.id));
|
|
46
|
+
// The chosen ride along for their labels; the field never offers them again.
|
|
47
|
+
const options = [
|
|
48
|
+
...lookup.options.map(asTag),
|
|
49
|
+
...lookup.chosenAll.filter((one) => !offered.has(one.id)).map(asTag),
|
|
50
|
+
];
|
|
51
|
+
return (_jsx(TagsField, { value: value, onChange: onChange, options: options, ...(lookup.searchable ? { onSearch: lookup.search } : {}), ...(onOpen === undefined ? {} : { onOpen }), ...(openTarget === undefined ? {} : { openTarget }), ...(onBrowseAll === undefined ? {} : { onBrowseAll }), ...(placeholder === undefined ? {} : { placeholder }), ...(disabled === undefined ? {} : { disabled }), ...(ariaLabel === undefined ? {} : { "aria-label": ariaLabel }) }));
|
|
52
|
+
}
|