@sincpro/web-ui 2.0.0 → 2.2.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 +45 -0
- package/dist/components/activity/Activity.d.ts +13 -14
- package/dist/components/activity/Activity.js +1 -1
- package/dist/components/activity/Messages.d.ts +5 -5
- package/dist/components/activity/Messages.js +8 -8
- package/dist/components/attachments/Attachments.d.ts +7 -1
- package/dist/components/attachments/Attachments.js +8 -2
- package/dist/components/board/Board.d.ts +32 -2
- package/dist/components/board/Board.js +27 -4
- package/dist/components/board/index.d.ts +1 -1
- package/dist/components/board/index.js +2 -1
- package/dist/components/form/Form.js +6 -6
- package/dist/components/form/index.js +2 -2
- package/dist/components/frame/FrameView.d.ts +5 -5
- package/dist/components/frame/FrameView.js +4 -4
- package/dist/components/listing/GroupingLevels.d.ts +22 -22
- package/dist/components/listing/GroupingLevels.js +9 -9
- package/dist/components/listing/Listing.d.ts +11 -11
- package/dist/components/listing/Listing.js +11 -11
- package/dist/components/listing/ListingBar.js +11 -11
- package/dist/components/listing/Row.d.ts +19 -19
- package/dist/components/listing/Row.js +27 -27
- package/dist/components/listing/SortMenu.d.ts +36 -36
- package/dist/components/listing/SortMenu.js +6 -6
- package/dist/components/listing/grouping.d.ts +16 -16
- package/dist/components/listing/grouping.js +6 -6
- package/dist/components/listing/index.js +1 -1
- package/dist/components/listing/modelColumns.d.ts +25 -25
- package/dist/components/listing/modelColumns.js +24 -24
- package/dist/components/listing/pages.js +4 -4
- package/dist/components/listing/set.d.ts +18 -18
- package/dist/components/navigation/NavigationTree.js +2 -2
- package/dist/components/navigation/index.js +2 -2
- package/dist/components/record/RecordSkeleton.js +7 -7
- package/dist/components/search/CriteriaBuilder.d.ts +22 -22
- package/dist/components/search/CriteriaBuilder.js +31 -31
- package/dist/components/search/CriteriaChips.d.ts +9 -9
- package/dist/components/search/CriteriaChips.js +12 -12
- package/dist/components/search/FilterBuilder.d.ts +67 -67
- package/dist/components/search/FilterBuilder.js +104 -104
- package/dist/components/search/JoinWord.d.ts +1 -1
- package/dist/components/search/JoinWord.js +14 -14
- package/dist/components/search/JsonEditor.d.ts +8 -8
- package/dist/components/search/JsonEditor.js +16 -16
- package/dist/components/search/SearchBar.d.ts +34 -34
- package/dist/components/search/SearchBar.js +140 -117
- package/dist/components/search/criteria.d.ts +61 -61
- package/dist/components/search/criteria.js +39 -39
- package/dist/components/search/datePeriods.d.ts +47 -48
- package/dist/components/search/datePeriods.js +29 -29
- package/dist/components/search/dateRanges.d.ts +27 -27
- package/dist/components/search/dateRanges.js +16 -16
- package/dist/components/search/index.js +13 -13
- package/dist/components/search/model.d.ts +28 -28
- package/dist/components/search/model.js +21 -21
- package/dist/components/search/query.d.ts +71 -71
- package/dist/components/search/query.js +119 -119
- package/dist/components/shell/AppFrame.d.ts +9 -2
- package/dist/components/shell/AppFrame.js +102 -14
- package/dist/components/shell/Sidebar.d.ts +34 -0
- package/dist/components/shell/Sidebar.js +32 -0
- package/dist/components/shell/TopBar.d.ts +2 -0
- package/dist/components/shell/TopBar.js +13 -9
- package/dist/components/shell/index.d.ts +2 -0
- package/dist/components/shell/index.js +5 -1
- package/dist/components/shell/sidebarDrawer.d.ts +26 -0
- package/dist/components/shell/sidebarDrawer.js +22 -0
- package/dist/foundations/calendar.d.ts +27 -27
- package/dist/foundations/calendar.js +72 -72
- package/dist/foundations/chart.d.ts +57 -57
- package/dist/foundations/chart.js +27 -27
- package/dist/foundations/copy.d.ts +109 -94
- package/dist/foundations/copy.es.js +10 -2
- package/dist/foundations/copy.js +10 -2
- package/dist/foundations/grouping.d.ts +175 -175
- package/dist/foundations/grouping.js +0 -0
- package/dist/foundations/index.d.ts +1 -1
- package/dist/foundations/index.js +21 -21
- package/dist/foundations/pivot.d.ts +133 -131
- package/dist/foundations/pivot.js +54 -54
- package/dist/foundations/pivotSheet.d.ts +36 -36
- package/dist/foundations/pivotSheet.js +0 -0
- package/dist/foundations/slots.d.ts +38 -38
- package/dist/foundations/slots.js +18 -18
- package/dist/foundations/sticky.d.ts +28 -28
- package/dist/foundations/sticky.js +59 -59
- package/dist/foundations/xlsx.d.ts +47 -47
- package/dist/foundations/xlsx.js +0 -0
- package/dist/primitives/block/Line.d.ts +4 -4
- package/dist/primitives/block/Line.js +28 -28
- package/dist/primitives/block/index.js +2 -2
- package/dist/primitives/cell/index.js +2 -2
- package/dist/primitives/choice/index.js +3 -3
- package/dist/primitives/date/Calendar.d.ts +7 -1
- package/dist/primitives/date/Calendar.js +13 -3
- package/dist/primitives/date/DatePicker.d.ts +4 -1
- package/dist/primitives/date/DatePicker.js +2 -2
- package/dist/primitives/date/index.js +3 -3
- package/dist/primitives/disclosure/index.js +1 -1
- package/dist/primitives/field/DropZone.d.ts +22 -3
- package/dist/primitives/field/DropZone.js +33 -12
- package/dist/primitives/menu/Menu.d.ts +10 -6
- package/dist/primitives/menu/Menu.js +4 -3
- package/dist/primitives/notice/Callout.d.ts +30 -30
- package/dist/primitives/notice/Callout.js +6 -6
- package/dist/primitives/overlay/index.js +3 -3
- package/dist/primitives/picker/Picker.d.ts +6 -0
- package/dist/primitives/picker/Picker.js +27 -4
- package/dist/primitives/picker/index.js +2 -2
- package/dist/primitives/table/DataTable.d.ts +32 -32
- package/dist/primitives/table/DataTable.js +24 -24
- package/dist/primitives/table/EditableTable.d.ts +10 -10
- package/dist/primitives/table/EditableTable.js +9 -9
- package/dist/primitives/table/ReportTable.js +7 -7
- package/dist/primitives/table/SheetTable.d.ts +13 -13
- package/dist/primitives/table/SheetTable.js +14 -14
- package/dist/primitives/table/Table.js +8 -8
- package/dist/primitives/tabs/Tabs.d.ts +46 -46
- package/dist/primitives/tabs/Tabs.js +4 -30
- package/dist/primitives/tag/Count.d.ts +23 -0
- package/dist/primitives/tag/Count.js +59 -0
- package/dist/primitives/tag/index.d.ts +1 -0
- package/dist/primitives/tag/index.js +5 -2
- package/dist/primitives/toolbar/index.js +1 -1
- package/dist/primitives/value/Copyable.d.ts +22 -22
- package/dist/primitives/value/Copyable.js +9 -9
- package/dist/primitives/value/Metric.d.ts +7 -2
- package/dist/primitives/value/Metric.js +12 -4
- package/dist/tokens.css +164 -57
- package/dist/views/list/List.d.ts +36 -36
- package/dist/views/list/List.js +19 -19
- package/dist/views/list/ListView.js +74 -74
- package/dist/views/list/columns.d.ts +10 -10
- package/dist/views/list/columns.js +10 -10
- package/dist/views/list/derive.d.ts +30 -30
- package/dist/views/list/derive.js +49 -49
- package/dist/views/list/index.js +2 -2
- package/dist/views/list/presentations.js +3 -3
- package/dist/views/list/types.d.ts +109 -109
- package/dist/views/record/Record.d.ts +14 -14
- package/dist/views/record/Record.js +24 -24
- package/dist/views/record/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
3
|
-
`"2026-10-30T09:05"`),
|
|
1
|
+
/* DATES AND TIMES — written by segments or picked on a calendar, in the order
|
|
2
|
+
of the copy table's language. The value is an ISO string (`"2026-10-30"`, `"09:05"`,
|
|
3
|
+
`"2026-10-30T09:05"`), what any backend sends. */
|
|
4
4
|
export { Calendar, RangeCalendar, } from "./Calendar.js";
|
|
5
5
|
export { DateField, DatePicker, DateRangePicker, } from "./DatePicker.js";
|
|
6
6
|
export { DateTimePicker, TimeField } from "./DateTime.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* WHAT FOLDS — a section that opens and closes, and a group of them. */
|
|
2
2
|
export { Accordion, Disclosure, } from "./Disclosure.js";
|
|
@@ -17,8 +17,17 @@ import { type FormMode } from "../../foundations/form.js";
|
|
|
17
17
|
* say a dragged file's extension until it lands, and a drop that silently does
|
|
18
18
|
* nothing reads as a broken zone. The file reaches `onFile`, and the consumer
|
|
19
19
|
* answers with `error` when it cannot read it.
|
|
20
|
+
*
|
|
21
|
+
* ── One file, or several ─────────────────────────────────────────────
|
|
22
|
+
*
|
|
23
|
+
* `multiple` takes every file of a drop or of the dialog in ONE call to `onFiles` —
|
|
24
|
+
* a gallery gets its thirty photos as one batch, not thirty events. Listing what
|
|
25
|
+
* was chosen, with its thumbnails and per-file removal, is `Attachments`, which
|
|
26
|
+
* draws this zone: the zone takes files, it does not keep them. `max` caps the
|
|
27
|
+
* batch: the first `max` go through and the zone SAYS how many were left out — a
|
|
28
|
+
* silent cut is a photo nobody knows is missing.
|
|
20
29
|
*/
|
|
21
|
-
|
|
30
|
+
type DropZoneCommon = {
|
|
22
31
|
/** The browser's `accept` list: extensions and MIME types, comma-separated
|
|
23
32
|
* (`".pdf,application/pdf"`). */
|
|
24
33
|
accept?: string;
|
|
@@ -29,7 +38,6 @@ export type DropZoneProps = {
|
|
|
29
38
|
fileName?: string;
|
|
30
39
|
fileDetail?: string;
|
|
31
40
|
error?: string | null;
|
|
32
|
-
onFile: (file: File) => void;
|
|
33
41
|
onCancel?: () => void;
|
|
34
42
|
onRetry?: () => void;
|
|
35
43
|
id?: string;
|
|
@@ -39,4 +47,15 @@ export type DropZoneProps = {
|
|
|
39
47
|
* file's name. */
|
|
40
48
|
mode?: FormMode;
|
|
41
49
|
};
|
|
42
|
-
export
|
|
50
|
+
export type DropZoneProps = DropZoneCommon & ({
|
|
51
|
+
multiple?: false;
|
|
52
|
+
onFile: (file: File) => void;
|
|
53
|
+
} | {
|
|
54
|
+
multiple: true;
|
|
55
|
+
/** Every file of one drop, paste or choice, in their order. */
|
|
56
|
+
onFiles: (files: File[]) => void;
|
|
57
|
+
/** At most this many per batch; the rest are left out, and the zone says so. */
|
|
58
|
+
max?: number;
|
|
59
|
+
});
|
|
60
|
+
export declare function DropZone(props: DropZoneProps): import("react").JSX.Element;
|
|
61
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useUiCopy } from "../../foundations/copy.js";
|
|
3
|
+
import { fillCopy, useUiCopy } from "../../foundations/copy.js";
|
|
4
4
|
import { useFieldIds } from "../../foundations/form.js";
|
|
5
5
|
import { useFormMode } from "../../foundations/form.js";
|
|
6
6
|
import { cn } from "../../foundations/variants.js";
|
|
@@ -8,9 +8,13 @@ import { Button, buttonClasses } from "../button/Button.js";
|
|
|
8
8
|
import { ReadValue } from "./Field.js";
|
|
9
9
|
import { Failed } from "../notice/Notice.js";
|
|
10
10
|
import { ProgressBar } from "../value/ProgressBar.js";
|
|
11
|
+
import { useState } from "react";
|
|
11
12
|
import { Button as AriaButton, DropZone as AriaDropZone, FileTrigger, } from "react-aria-components";
|
|
12
|
-
export function DropZone(
|
|
13
|
+
export function DropZone(props) {
|
|
14
|
+
const { accept, label, busy = false, progress, fileName, fileDetail, error, onCancel, onRetry, id: ownId, describedBy: ownDescribedBy, invalid: ownInvalid, mode, } = props;
|
|
13
15
|
const copy = useUiCopy();
|
|
16
|
+
/* How many the last batch left out, said under the zone until the next batch. */
|
|
17
|
+
const [leftOut, setLeftOut] = useState(null);
|
|
14
18
|
const { id, labelledBy, describedBy, invalid } = useFieldIds({
|
|
15
19
|
id: ownId,
|
|
16
20
|
describedBy: ownDescribedBy,
|
|
@@ -19,20 +23,36 @@ export function DropZone({ accept, label, busy = false, progress, fileName, file
|
|
|
19
23
|
const readMode = useFormMode(mode) === "read";
|
|
20
24
|
if (readMode)
|
|
21
25
|
return _jsx(ReadValue, { value: fileName ?? null });
|
|
22
|
-
const
|
|
26
|
+
const many = props.multiple === true;
|
|
27
|
+
const sentence = label ?? (many ? copy.field.dropMany : copy.field.drop);
|
|
23
28
|
const types = accept
|
|
24
29
|
?.split(",")
|
|
25
30
|
.map((t) => t.trim())
|
|
26
31
|
.filter((t) => t !== "");
|
|
32
|
+
function take(files) {
|
|
33
|
+
if (files.length === 0)
|
|
34
|
+
return;
|
|
35
|
+
if (props.multiple !== true) {
|
|
36
|
+
props.onFile(files[0]);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const max = props.max;
|
|
40
|
+
const taken = max === undefined ? files : files.slice(0, max);
|
|
41
|
+
setLeftOut(taken.length < files.length ? { taken: taken.length, of: files.length } : null);
|
|
42
|
+
props.onFiles([...taken]);
|
|
43
|
+
}
|
|
27
44
|
async function onDrop(items) {
|
|
28
45
|
if (busy)
|
|
29
46
|
return;
|
|
47
|
+
const files = [];
|
|
30
48
|
for (const item of items) {
|
|
31
|
-
if (item.kind
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
49
|
+
if (item.kind !== "file")
|
|
50
|
+
continue;
|
|
51
|
+
files.push(await item.getFile());
|
|
52
|
+
if (!many)
|
|
53
|
+
break;
|
|
35
54
|
}
|
|
55
|
+
take(files);
|
|
36
56
|
}
|
|
37
57
|
return (_jsxs("div", { className: "flex min-w-0 flex-col gap-2", children: [_jsxs(AriaDropZone, { ...(labelledBy === undefined
|
|
38
58
|
? { "aria-label": sentence }
|
|
@@ -40,11 +60,12 @@ export function DropZone({ accept, label, busy = false, progress, fileName, file
|
|
|
40
60
|
? "border-primary bg-primary/8 forced-colors:border-[Highlight]"
|
|
41
61
|
: invalid
|
|
42
62
|
? "border-danger bg-surface"
|
|
43
|
-
: "border-line-strong bg-surface", isFocusVisible ? "outline-2" : "outline-0"), children: [_jsx("p", { className: "text-body text-muted", children: sentence }), busy ? (_jsxs("div", { className: "flex w-full max-w-sm flex-col items-center gap-2", children: [fileName === undefined ? null : (_jsx("p", { className: "max-w-full truncate text-body text-ink", children: fileName })), _jsx("div", { className: "w-full", children: _jsx(ProgressBar, { value: progress ?? 0, label: copy.field.uploadProgress, width: "w-full" }) }), fileDetail === undefined ? null : (_jsx("p", { className: "text-meta text-muted", children: fileDetail }))] })) : (_jsxs("div", { className: "flex flex-wrap items-center justify-center gap-3", children: [_jsx(FileTrigger, { ...(types === undefined ? {} : { acceptedFileTypes: types }), onSelect: (files) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
63
|
+
: "border-line-strong bg-surface", isFocusVisible ? "outline-2" : "outline-0"), children: [_jsx("p", { className: "text-body text-muted", children: sentence }), busy ? (_jsxs("div", { className: "flex w-full max-w-sm flex-col items-center gap-2", children: [fileName === undefined ? null : (_jsx("p", { className: "max-w-full truncate text-body text-ink", children: fileName })), _jsx("div", { className: "w-full", children: _jsx(ProgressBar, { value: progress ?? 0, label: copy.field.uploadProgress, width: "w-full" }) }), fileDetail === undefined ? null : (_jsx("p", { className: "text-meta text-muted", children: fileDetail }))] })) : (_jsxs("div", { className: "flex flex-wrap items-center justify-center gap-3", children: [_jsx(FileTrigger, { ...(types === undefined ? {} : { acceptedFileTypes: types }), allowsMultiple: many, onSelect: (files) => take(files === null ? [] : Array.from(files)), children: _jsx(AriaButton, { id: id, "data-emphasis": "secondary", className: buttonClasses("secondary", "md"), children: many ? copy.field.chooseFiles : copy.field.chooseFile }) }), onCancel === undefined ? null : (_jsx(Button, { role: "ghost", onClick: onCancel, children: copy.field.cancel }))] }))] }), _jsx("p", { role: "status", className: leftOut === null ? "sr-only" : "text-meta text-warn", children: leftOut === null
|
|
64
|
+
? null
|
|
65
|
+
: fillCopy(copy.field.tooManyFiles, {
|
|
66
|
+
max: leftOut.taken.toLocaleString(copy.locale),
|
|
67
|
+
count: leftOut.of.toLocaleString(copy.locale),
|
|
68
|
+
}) }), error === undefined || error === null ? null : (_jsx(Failed, { heading: copy.field.fileUnreadable, sentence: error, ...(onRetry === undefined
|
|
48
69
|
? {}
|
|
49
70
|
: {
|
|
50
71
|
action: (_jsx(Button, { role: "ghost", onClick: onRetry, children: copy.field.tryAnother })),
|
|
@@ -15,14 +15,14 @@ export interface MenuOption {
|
|
|
15
15
|
* quarters, years— which are one group because they combine, but read as
|
|
16
16
|
* three because they answer at three different zooms. */
|
|
17
17
|
divider?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
/** How this option is REMOVED when drawn as a chip, if removing it is not the same as
|
|
19
|
+
* choosing it again. The custom filter is the case: choosing it opens the builder, and that
|
|
20
|
+
* is not what should happen when its × is tapped. */
|
|
21
21
|
onRemove?: () => void;
|
|
22
22
|
disabled?: boolean;
|
|
23
23
|
/** Visual mark at the end of the label. A string is drawn as a pill
|
|
24
|
-
* —"maqueta", "nuevo"—;
|
|
25
|
-
*
|
|
24
|
+
* —"maqueta", "nuevo"—; a number as a `Count` —«Por aprobar 3», no zero—;
|
|
25
|
+
* anything else is drawn as is, which is how a status `Tag` comes in. */
|
|
26
26
|
badge?: ReactNode;
|
|
27
27
|
/** What THIS option does. It exists on top of the menu's `onSelect` because a
|
|
28
28
|
* menu built from a registry —twenty-five operations, each one with its own
|
|
@@ -84,7 +84,7 @@ export declare function menuTriggerClasses({ variant, surface, active, open, foc
|
|
|
84
84
|
export declare function Menu({ label, groups, onSelect, surface, align, icon: Trigger,
|
|
85
85
|
/** The menu as a control of a list ("filters ▾") carries the chevron; the
|
|
86
86
|
* actions `⋯` does not, because the icon already says there is more. */
|
|
87
|
-
chevron, active, iconOnly, variant, searchPlaceholder, emptyText, width, role, size, title, closeOnSelect, }: {
|
|
87
|
+
chevron, active, iconOnly, variant, searchPlaceholder, emptyText, width, role, size, title, closeOnSelect, count, }: {
|
|
88
88
|
label: string;
|
|
89
89
|
groups: readonly MenuGroup[];
|
|
90
90
|
onSelect?: (id: string) => void;
|
|
@@ -126,6 +126,10 @@ chevron, active, iconOnly, variant, searchPlaceholder, emptyText, width, role, s
|
|
|
126
126
|
/** Column and filter menus toggle several options in a row. Closing after
|
|
127
127
|
* each click turns three hides into three open-close round trips. */
|
|
128
128
|
closeOnSelect?: boolean;
|
|
129
|
+
/** What is waiting inside, on the trigger: «Pagos 5» in an application bar says it
|
|
130
|
+
* without opening the menu. Zero is not drawn. Not with `iconOnly`, where there is no
|
|
131
|
+
* label for it to belong to. */
|
|
132
|
+
count?: number;
|
|
129
133
|
}): import("react").JSX.Element;
|
|
130
134
|
/**
|
|
131
135
|
* The panel of a `Menu`: its groups and rows, and the submenus hanging from them. Internal —
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useUiCopy } from "../../foundations/copy.js";
|
|
4
4
|
import { buttonClasses, } from "../button/Button.js";
|
|
5
5
|
import { Popover } from "../overlay/Popover.js";
|
|
6
|
+
import { Count } from "../tag/Count.js";
|
|
6
7
|
import { Check, ChevronDown, ChevronRight } from "lucide-react";
|
|
7
8
|
import { Autocomplete, Button as AriaButton, Header, Input, Keyboard, Menu as AriaMenu, MenuItem, MenuSection, MenuTrigger, SearchField, Separator, SubmenuTrigger, useFilter, } from "react-aria-components";
|
|
8
9
|
const WIDTH = {
|
|
@@ -52,7 +53,7 @@ export function menuTriggerClasses({ variant = "button", surface = "canvas", act
|
|
|
52
53
|
export function Menu({ label, groups, onSelect, surface = "canvas", align = "start", icon: Trigger,
|
|
53
54
|
/** The menu as a control of a list ("filters ▾") carries the chevron; the
|
|
54
55
|
* actions `⋯` does not, because the icon already says there is more. */
|
|
55
|
-
chevron = true, active = false, iconOnly = false, variant = "button", searchPlaceholder, emptyText, width = "md", role, size = "md", title, closeOnSelect = true, }) {
|
|
56
|
+
chevron = true, active = false, iconOnly = false, variant = "button", searchPlaceholder, emptyText, width = "md", role, size = "md", title, closeOnSelect = true, count, }) {
|
|
56
57
|
const copy = useUiCopy();
|
|
57
58
|
const { contains } = useFilter({ sensitivity: "base" });
|
|
58
59
|
const byId = indexOptions(groups.flatMap((g) => g.options));
|
|
@@ -70,7 +71,7 @@ chevron = true, active = false, iconOnly = false, variant = "button", searchPlac
|
|
|
70
71
|
focusVisible: isFocusVisible,
|
|
71
72
|
iconOnly,
|
|
72
73
|
})
|
|
73
|
-
: `${buttonClasses(role, size, surface)} gap-1.5`, children: _jsxs("span", { className: "contents", title: title ?? (iconOnly ? label : undefined), children: [Trigger === undefined ? (iconOnly ? (_jsx(ChevronDown, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true })) : null) : (_jsx(Trigger, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true })), iconOnly ? null : label, chevron && !iconOnly ? (_jsx(ChevronDown, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true })) : null] }) }), _jsx(Popover, { placement: align === "end" ? "bottom end" : "bottom start", className: WIDTH[width], children: searchPlaceholder === undefined ? (menu) : (
|
|
74
|
+
: `${buttonClasses(role, size, surface)} gap-1.5`, children: _jsxs("span", { className: "contents", title: title ?? (iconOnly ? label : undefined), children: [Trigger === undefined ? (iconOnly ? (_jsx(ChevronDown, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true })) : null) : (_jsx(Trigger, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true })), iconOnly ? null : label, iconOnly || count === undefined ? null : _jsx(Count, { value: count, surface: surface }), chevron && !iconOnly ? (_jsx(ChevronDown, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true })) : null] }) }), _jsx(Popover, { placement: align === "end" ? "bottom end" : "bottom start", className: WIDTH[width], children: searchPlaceholder === undefined ? (menu) : (
|
|
74
75
|
/* The search box stays at the top: in a menu of twenty-five entries,
|
|
75
76
|
scrolling loses exactly the control that explains why only three are
|
|
76
77
|
visible. It filters on label AND hint — half the entries of this
|
|
@@ -91,7 +92,7 @@ export function MenuList({ label, groups, onAction, closeOnSelect, emptyText, wi
|
|
|
91
92
|
const Icon = o.icon;
|
|
92
93
|
const opens = o.items !== undefined;
|
|
93
94
|
const checked = !opens && o.checked === true;
|
|
94
|
-
return (_jsxs(MenuItem, { id: o.id, textValue: o.hint === undefined ? o.label : `${o.label} ${o.hint}`, isDisabled: o.disabled, className: `flex w-full cursor-default rounded-control ${hasHints ? "items-start py-1.5" : "items-center py-1"} gap-2 px-2 text-left outline-0 transition-colors duration-(--duration-instant) data-focused:bg-primary/8 data-open:bg-primary/8 disabled:opacity-45`, children: [hasMarks ? (_jsx("span", { className: `${hasHints ? "mt-0.5" : ""} flex size-(--size-icon-sm) shrink-0 items-center justify-center`, children: checked ? (_jsx(Check, { className: "size-(--size-icon-sm) text-primary", strokeWidth: 2.5, "aria-hidden": true })) : Icon !== undefined ? (_jsx(Icon, { className: "size-(--size-icon-sm) text-muted", strokeWidth: 2, "aria-hidden": true })) : null })) : null, _jsxs("span", { className: "min-w-0 flex-1", children: [_jsxs("span", { className: "flex items-center gap-1.5", children: [_jsx("span", { className: `truncate text-meta ${checked ? "font-medium text-ink" : "text-ink"}`, children: o.label }), o.badge === undefined ? null : typeof o.badge === "string" ? (_jsx("span", { className: "inline-flex shrink-0 items-center rounded-pill border border-warn/30 bg-warn/10 px-2 py-0.5 text-micro text-warn", children: o.badge })) : (_jsx("span", { className: "ml-auto shrink-0", children: o.badge }))] }), o.hint === undefined ? null : (_jsx("span", { className: "mt-0.5 block truncate text-micro text-muted", children: o.hint }))] }), o.shortcut === undefined ? null : (_jsx(Keyboard, { className: "shrink-0 self-center pl-3 font-mono text-micro text-muted", children: o.shortcut })), opens ? (_jsx(ChevronRight, { className: "size-(--size-icon-sm) shrink-0 self-center text-muted", strokeWidth: 2, "aria-hidden": true })) : null] }, o.id));
|
|
95
|
+
return (_jsxs(MenuItem, { id: o.id, textValue: o.hint === undefined ? o.label : `${o.label} ${o.hint}`, isDisabled: o.disabled, className: `flex w-full cursor-default rounded-control ${hasHints ? "items-start py-1.5" : "items-center py-1"} gap-2 px-2 text-left outline-0 transition-colors duration-(--duration-instant) data-focused:bg-primary/8 data-open:bg-primary/8 disabled:opacity-45`, children: [hasMarks ? (_jsx("span", { className: `${hasHints ? "mt-0.5" : ""} flex size-(--size-icon-sm) shrink-0 items-center justify-center`, children: checked ? (_jsx(Check, { className: "size-(--size-icon-sm) text-primary", strokeWidth: 2.5, "aria-hidden": true })) : Icon !== undefined ? (_jsx(Icon, { className: "size-(--size-icon-sm) text-muted", strokeWidth: 2, "aria-hidden": true })) : null })) : null, _jsxs("span", { className: "min-w-0 flex-1", children: [_jsxs("span", { className: "flex items-center gap-1.5", children: [_jsx("span", { className: `truncate text-meta ${checked ? "font-medium text-ink" : "text-ink"}`, children: o.label }), o.badge === undefined ? null : typeof o.badge === "number" ? (_jsx("span", { className: "ml-auto flex shrink-0", children: _jsx(Count, { value: o.badge }) })) : typeof o.badge === "string" ? (_jsx("span", { className: "inline-flex shrink-0 items-center rounded-pill border border-warn/30 bg-warn/10 px-2 py-0.5 text-micro text-warn", children: o.badge })) : (_jsx("span", { className: "ml-auto shrink-0", children: o.badge }))] }), o.hint === undefined ? null : (_jsx("span", { className: "mt-0.5 block truncate text-micro text-muted", children: o.hint }))] }), o.shortcut === undefined ? null : (_jsx(Keyboard, { className: "shrink-0 self-center pl-3 font-mono text-micro text-muted", children: o.shortcut })), opens ? (_jsx(ChevronRight, { className: "size-(--size-icon-sm) shrink-0 self-center text-muted", strokeWidth: 2, "aria-hidden": true })) : null] }, o.id));
|
|
95
96
|
};
|
|
96
97
|
return (_jsx(AriaMenu, { "aria-label": label, shouldCloseOnSelect: closeOnSelect, onAction: onAction, renderEmptyState: () => (_jsx("p", { className: "px-3 py-3 text-meta text-muted italic", children: emptyText })), className: "max-h-[inherit] overflow-y-auto p-1 outline-0", children: groups.map((g, gi) => (_jsxs(MenuSection, { className: "[&:not(:first-child)]:mt-1 [&:not(:first-child)]:border-t [&:not(:first-child)]:border-line [&:not(:first-child)]:pt-1", children: [g.label === undefined ? null : (
|
|
97
98
|
/* Same skeleton as the row: the label sits on the text column. */
|
|
@@ -2,51 +2,51 @@ import type { Tone } from "../../foundations/types.js";
|
|
|
2
2
|
import type { LucideIcon } from "lucide-react";
|
|
3
3
|
import type { ReactNode } from "react";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* A NOTICE about what is being looked at.
|
|
6
6
|
*
|
|
7
|
-
* Context: `Empty`, `Failed`
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
7
|
+
* Context: `Empty`, `Failed` and `Missing` say there is NO content and take the
|
|
8
|
+
* place of the view. This is the opposite: there is content, it is visible, and something
|
|
9
|
+
* ELSE has to be said —«there are unregistered entries in this period», «this period
|
|
10
|
+
* is closed», «saved»—. Without this piece, every screen invented its own
|
|
11
|
+
* with a `div` and a colour by eye, and that is how the same degree of urgency
|
|
12
|
+
* ended up painted in three ways.
|
|
13
13
|
*
|
|
14
|
-
* ──
|
|
14
|
+
* ── The tone is the ONLY decision ───────────────────────────────────
|
|
15
15
|
*
|
|
16
|
-
* info
|
|
17
|
-
* warn
|
|
18
|
-
* bad
|
|
19
|
-
* good
|
|
16
|
+
* info a fact that changes how what is below is read
|
|
17
|
+
* warn something worth looking at before going on
|
|
18
|
+
* bad something that is wrong and has already had consequences
|
|
19
|
+
* good something went well and there is nothing to do
|
|
20
20
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
21
|
+
* The icon comes from the tone and is not chosen: a red notice with a green tick inside
|
|
22
|
+
* is a contradiction that someone will write if we let them write it.
|
|
23
23
|
*
|
|
24
|
-
* ──
|
|
24
|
+
* ── What it does NOT do ─────────────────────────────────────────────
|
|
25
25
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
26
|
+
* It does not close by itself, has no timer and does not stack. A notice that
|
|
27
|
+
* disappears after four seconds is a notice someone did not get to read — that
|
|
28
|
+
* is a `Toast`, which is another piece and another question («something happened away from here»).
|
|
29
|
+
* This one speaks about what is on screen, so it stays as long as it is true.
|
|
30
30
|
*/
|
|
31
31
|
export type CalloutProps = {
|
|
32
|
-
/**
|
|
32
|
+
/** What is happening. One sentence, in the product's voice. */
|
|
33
33
|
children: ReactNode;
|
|
34
|
-
/**
|
|
34
|
+
/** Without this, `info`. */
|
|
35
35
|
tone?: Extract<Tone, "info" | "warn" | "bad" | "good">;
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
36
|
+
/** The heading, when the sentence alone is not enough. Most do not
|
|
37
|
+
* need it: a two-line notice with a title is a poster. */
|
|
38
38
|
title?: ReactNode;
|
|
39
|
-
/**
|
|
39
|
+
/** What resolves the notice, if there is something to press. */
|
|
40
40
|
action?: ReactNode;
|
|
41
|
-
/**
|
|
42
|
-
*
|
|
41
|
+
/** Present = it can be closed. Absent = it cannot, because what it says stays
|
|
42
|
+
* true whoever looks at it. */
|
|
43
43
|
onDismiss?: () => void;
|
|
44
|
-
/**
|
|
44
|
+
/** The accessible label of the ×. */
|
|
45
45
|
dismissLabel?: string;
|
|
46
|
-
/**
|
|
46
|
+
/** An icon of its own, when the tone's does not say enough. */
|
|
47
47
|
icon?: LucideIcon;
|
|
48
|
-
/**
|
|
49
|
-
*
|
|
48
|
+
/** What is copied with «Copiar el error» when the tone is `bad`. Without this, the
|
|
49
|
+
* sentence (if it is text) with the title. For a notice with technical detail, pass it here. */
|
|
50
50
|
report?: string;
|
|
51
51
|
};
|
|
52
52
|
export declare function Callout({ children, tone, title, action, onDismiss, dismissLabel, icon, report, }: CalloutProps): import("react").JSX.Element;
|
|
@@ -9,9 +9,9 @@ const ICON = {
|
|
|
9
9
|
bad: OctagonAlert,
|
|
10
10
|
good: CheckCircle2,
|
|
11
11
|
};
|
|
12
|
-
/*
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
/* The background is a layer of the colour over the paper and not a colour of its own: so the
|
|
13
|
+
notice reads on the floor and on white paper without two sets of tokens, and
|
|
14
|
+
keeps working the day the palette changes. */
|
|
15
15
|
const SKIN = {
|
|
16
16
|
info: "border-info/25 bg-info/8 text-info",
|
|
17
17
|
warn: "border-warn/30 bg-warn/10 text-warn",
|
|
@@ -26,9 +26,9 @@ export function Callout({ children, tone = "info", title, action, onDismiss, dis
|
|
|
26
26
|
const sentence = report ?? (typeof children === "string" ? children : "");
|
|
27
27
|
const copyable = tone === "bad" && sentence !== "";
|
|
28
28
|
return (_jsxs("div", {
|
|
29
|
-
/* `status`
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
/* `status` and not `alert`: `alert` interrupts the screen reader and is
|
|
30
|
+
reserved for what happened RIGHT NOW. A notice that was already there when the
|
|
31
|
+
screen opened interrupts nothing. */
|
|
32
32
|
role: "status", className: `flex min-w-0 items-start gap-2.5 rounded-box border ${SKIN[tone]} ${byDensity(d, "px-3 py-2.5", "px-2.5 py-2")}`, children: [_jsx(Icon, { className: "mt-0.5 size-(--size-icon-sm) shrink-0", strokeWidth: 2, "aria-hidden": true }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-wrap items-start gap-x-3 gap-y-2", children: [_jsxs("div", { className: "flex min-w-0 flex-1 basis-(--container-name) flex-col gap-1", children: [title === undefined ? null : (_jsx("p", { className: "text-meta font-medium text-ink", children: title })), _jsx("div", { className: "min-w-0 text-meta text-ink", children: children })] }), action === undefined ? null : _jsx("span", { className: "shrink-0", children: action }), copyable ? (_jsx("span", { className: "shrink-0", children: _jsx(ErrorCopy, { report: () => errorReport({
|
|
33
33
|
heading: typeof title === "string" ? title : "",
|
|
34
34
|
sentence: typeof title === "string" ? sentence : undefined,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
3
|
-
a
|
|
1
|
+
/* WHAT FLOATS anchored to something: the calendar of a date picker, a combobox's
|
|
2
|
+
list, a small form opened from a button, the name of an icon, a glance
|
|
3
|
+
at a record when hovering its name. */
|
|
4
4
|
export { Popover } from "./Popover.js";
|
|
5
5
|
export { PopoverTrigger, } from "./PopoverTrigger.js";
|
|
6
6
|
export { Preview } from "./Preview.js";
|
|
@@ -55,6 +55,12 @@ export type PickerProps = {
|
|
|
55
55
|
items: readonly PickerItem[];
|
|
56
56
|
value?: string;
|
|
57
57
|
onChange?: (id: string) => void;
|
|
58
|
+
/**
|
|
59
|
+
* The field may be empty: a × beside the chosen name empties it, and so does erasing the name
|
|
60
|
+
* and leaving the field — the way a person says «none». Without it the choice can only be
|
|
61
|
+
* changed, never removed (a required field).
|
|
62
|
+
*/
|
|
63
|
+
onClear?: () => void;
|
|
58
64
|
/**
|
|
59
65
|
* The options are SEARCHED by whoever gives them — the server's literal search — and this
|
|
60
66
|
* hears what is typed (and `""` when the list starts over). With it the picker filters
|
|
@@ -13,7 +13,7 @@ import { Menu } from "../menu/Menu.js";
|
|
|
13
13
|
import { Popover } from "../overlay/Popover.js";
|
|
14
14
|
import { MatchedText } from "./MatchedText.js";
|
|
15
15
|
import { Avatar } from "../value/Person.js";
|
|
16
|
-
import { AppWindow, Check, ChevronDown, Ellipsis, Eye, PanelRight, PictureInPicture2, SquareArrowOutUpRight, } from "lucide-react";
|
|
16
|
+
import { AppWindow, Check, ChevronDown, Ellipsis, Eye, PanelRight, PictureInPicture2, SquareArrowOutUpRight, X, } from "lucide-react";
|
|
17
17
|
import { useContext, useMemo, useRef, useState } from "react";
|
|
18
18
|
import { Collection, ComboBox as AriaComboBox, ComboBoxStateContext, Header, Input, ListBox, ListBoxItem, ListBoxLoadMoreItem, ListBoxSection, useFilter, } from "react-aria-components";
|
|
19
19
|
/** The icon of each place a record opens — the same in every field and list. */
|
|
@@ -98,7 +98,7 @@ export function Picker({ mode, ...props }) {
|
|
|
98
98
|
to be ABOVE the component that asks for it. */
|
|
99
99
|
return (_jsx(AriaLocale, { children: _jsx(EditablePicker, { ...props }) }));
|
|
100
100
|
}
|
|
101
|
-
function EditablePicker({ id: ownId, items, value, onChange, onSearch, valueLabel, placeholder, onBrowseAll, onCreate, onCreateAndEdit, onOpen, openTargets = ["modal", "peek", "side", "page"], emptyText, searchPlaceholder, loading = false, loadingText, onLoadMore, loadingMore = false, renderOption, describedBy: ownDescribedBy, invalid: ownInvalid, disabled = false, "aria-label": ariaLabel, }) {
|
|
101
|
+
function EditablePicker({ id: ownId, items, value, onChange, onClear, onSearch, valueLabel, placeholder, onBrowseAll, onCreate, onCreateAndEdit, onOpen, openTargets = ["modal", "peek", "side", "page"], emptyText, searchPlaceholder, loading = false, loadingText, onLoadMore, loadingMore = false, renderOption, describedBy: ownDescribedBy, invalid: ownInvalid, disabled = false, "aria-label": ariaLabel, }) {
|
|
102
102
|
const { id, labelledBy, describedBy, invalid } = useFieldIds({
|
|
103
103
|
id: ownId,
|
|
104
104
|
describedBy: ownDescribedBy,
|
|
@@ -169,6 +169,8 @@ function EditablePicker({ id: ownId, items, value, onChange, onSearch, valueLabe
|
|
|
169
169
|
];
|
|
170
170
|
const listed = [...visible, ...actions];
|
|
171
171
|
const closeList = useRef(null);
|
|
172
|
+
/** The person erased the chosen name (and did not take it back with Escape). */
|
|
173
|
+
const erased = useRef(false);
|
|
172
174
|
const take = (key) => {
|
|
173
175
|
if (key === null)
|
|
174
176
|
return;
|
|
@@ -199,6 +201,8 @@ function EditablePicker({ id: ownId, items, value, onChange, onSearch, valueLabe
|
|
|
199
201
|
onChange?.(next);
|
|
200
202
|
};
|
|
201
203
|
return (_jsxs(AriaComboBox, { id: id, "aria-labelledby": labelledBy, "aria-label": controlName(labelledBy, ariaLabel), "aria-describedby": describedBy, items: listed, value: value ?? null, onChange: take, inputValue: text, onInputChange: (next) => {
|
|
204
|
+
// What the person typed down to nothing — not a field whose name is still unknown.
|
|
205
|
+
erased.current = next.trim() === "" && text.trim() !== "";
|
|
202
206
|
setText(next);
|
|
203
207
|
setQuery(next);
|
|
204
208
|
}, onOpenChange: (isOpen, trigger) => {
|
|
@@ -206,7 +210,18 @@ function EditablePicker({ id: ownId, items, value, onChange, onSearch, valueLabe
|
|
|
206
210
|
if (isOpen && trigger !== "input")
|
|
207
211
|
setQuery("");
|
|
208
212
|
if (!isOpen) {
|
|
209
|
-
|
|
213
|
+
// The name erased BY THE PERSON and the field left: «none», when the field may be
|
|
214
|
+
// empty. Only then: a field passed through whose name is not known yet shows no text
|
|
215
|
+
// too, and Escape means «leave it as it was».
|
|
216
|
+
if (onClear !== undefined &&
|
|
217
|
+
erased.current &&
|
|
218
|
+
value !== undefined &&
|
|
219
|
+
value !== "" &&
|
|
220
|
+
text.trim() === "")
|
|
221
|
+
onClear();
|
|
222
|
+
else
|
|
223
|
+
setText(chosenName);
|
|
224
|
+
erased.current = false;
|
|
210
225
|
setQuery("");
|
|
211
226
|
}
|
|
212
227
|
},
|
|
@@ -221,6 +236,10 @@ function EditablePicker({ id: ownId, items, value, onChange, onSearch, valueLabe
|
|
|
221
236
|
onFocus: (event) => {
|
|
222
237
|
if (!open)
|
|
223
238
|
event.currentTarget.select();
|
|
239
|
+
}, onKeyDown: (event) => {
|
|
240
|
+
// Escape puts the name back: never an emptied choice.
|
|
241
|
+
if (event.key === "Escape")
|
|
242
|
+
erased.current = false;
|
|
224
243
|
}, className: "h-full min-w-0 flex-1 bg-transparent px-2.5 text-meta text-ink outline-0 placeholder:text-muted disabled:cursor-not-allowed" }), value !== undefined &&
|
|
225
244
|
value !== "" &&
|
|
226
245
|
onOpen !== undefined &&
|
|
@@ -232,7 +251,11 @@ function EditablePicker({ id: ownId, items, value, onChange, onSearch, valueLabe
|
|
|
232
251
|
icon: OPEN_ICON[to],
|
|
233
252
|
})),
|
|
234
253
|
},
|
|
235
|
-
], onSelect: (to) => onOpen(value, to) }))] })) : null,
|
|
254
|
+
], onSelect: (to) => onOpen(value, to) }))] })) : null, onClear === undefined || value === undefined || value === "" || disabled ? null : (_jsx(IconButton, { icon: X, label: copy.picker.clear, size: "sm", onClick: () => {
|
|
255
|
+
setText("");
|
|
256
|
+
setQuery("");
|
|
257
|
+
onClear();
|
|
258
|
+
} })), _jsx(FieldButton, { className: "mr-1", children: _jsx(ChevronDown, { "aria-hidden": true, className: "size-(--size-icon-md)", strokeWidth: 2 }) })] }), _jsxs(Popover, { placement: "bottom start", className: "flex w-(--trigger-width) flex-col overflow-hidden", children: [_jsx(PickerOptions, { items: listed, marks: hasMarks, hints: hasHints, remaining: remaining, query: query, emptyText: loading ? shownLoading : shownEmpty,
|
|
236
259
|
/* Not while the first page loads: the sentinel of an empty list is in view and
|
|
237
260
|
would ask for page two before page one arrived. */
|
|
238
261
|
onLoadMore: loading ? undefined : onLoadMore, loadingMore: loadingMore, ...(renderOption === undefined ? {} : { renderOption }) }), remaining > 0 && !browsable ? (_jsxs("div", { className: "flex shrink-0 items-center gap-2 border-t border-line bg-ground px-2.5 py-1.5", children: [_jsx("span", { className: "text-micro tabular-nums text-muted", children: fillCopy(copy.picker.more, { count: remaining.toLocaleString(copy.locale) }) }), _jsx("span", { className: "text-micro text-muted", children: copy.picker.refine })] })) : null] })] }));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* CHOOSING RECORDS — one (`Picker`, the many2one) or several (`TagsField`, the many2many).
|
|
2
2
|
The replacement for `<select>` when you have to SEE in order to choose. */
|
|
3
3
|
export { Picker, } from "./Picker.js";
|
|
4
|
-
/*
|
|
4
|
+
/* What was searched, marked: so an option of your own (`renderOption`) says it like the others do. */
|
|
5
5
|
export { MatchedText } from "./MatchedText.js";
|
|
6
|
-
/*
|
|
6
|
+
/* The many2many: the chosen chips plus an input that adds the next one. */
|
|
7
7
|
export {} from "./tagChoices.js";
|
|
8
8
|
export { TagsField } from "./TagsField.js";
|
|
@@ -23,9 +23,9 @@ export declare function aggregateText<T>(column: DataColumn<T>, value: number):
|
|
|
23
23
|
export interface DataColumn<T> {
|
|
24
24
|
id: string;
|
|
25
25
|
header: string;
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
26
|
+
/** Which field of the MODEL this column shows, when it is not named the same as
|
|
27
|
+
* it: «filas» shows `row_count`. `columnsFromModel` reads it so as not to add
|
|
28
|
+
* again, raw, a field this column already answers. */
|
|
29
29
|
field?: string;
|
|
30
30
|
/** The raw value: this is what sorting and grouping run on. */
|
|
31
31
|
value: (row: T) => string | number | boolean | null;
|
|
@@ -35,14 +35,14 @@ export interface DataColumn<T> {
|
|
|
35
35
|
* need it: they align with tabular figures in the same face as the rest of the row. */
|
|
36
36
|
mono?: boolean;
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
38
|
+
* How the column is READ where it cannot be drawn: the sheet, which is a
|
|
39
|
+
* grid of text and numbers and cannot take a node.
|
|
40
40
|
*
|
|
41
|
-
* Context:
|
|
42
|
-
*
|
|
43
|
-
* `posted`
|
|
44
|
-
* «pagada»,
|
|
45
|
-
*
|
|
41
|
+
* Context: without this, the sheet fell back to `value`, which is the SORT key and
|
|
42
|
+
* not what a person reads. The «estado» column of Invoices showed
|
|
43
|
+
* `posted` and `paid` —the contract's values— instead of «publicada» and
|
|
44
|
+
* «pagada», which is what the card next to it in the table says. Two
|
|
45
|
+
* presentations of the same set saying different things.
|
|
46
46
|
*/
|
|
47
47
|
text?: (row: T) => string;
|
|
48
48
|
/** Paints the BACKGROUND of the cell, row by row. It is what turns a table
|
|
@@ -118,35 +118,35 @@ export type DataTableCreate<T> = {
|
|
|
118
118
|
label?: string;
|
|
119
119
|
};
|
|
120
120
|
/**
|
|
121
|
-
*
|
|
121
|
+
* The aggregate of a column over a set of rows.
|
|
122
122
|
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
123
|
+
* It lives outside the component because three places ask for it: the table's
|
|
124
|
+
* foot, a pile's band in the sheet, and the line of a report built
|
|
125
|
+
* from the piles. Three implementations of «how much does this add up to» means
|
|
126
|
+
* the foot says one number and the pile another.
|
|
127
127
|
*
|
|
128
|
-
* `null`
|
|
129
|
-
*
|
|
128
|
+
* `null` when the column declared no aggregate, is not numeric, or there is no
|
|
129
|
+
* number to add — which is not the same as adding zero.
|
|
130
130
|
*/
|
|
131
131
|
export declare function aggregateOf<T extends object>(column: DataColumn<T>, rows: readonly T[]): number | null;
|
|
132
132
|
/**
|
|
133
|
-
*
|
|
133
|
+
* ONE LEVEL, as a table needs it.
|
|
134
134
|
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
135
|
+
* The identity is the LEVEL's and not the field's: one `registered_at`
|
|
136
|
+
* set by month and by day makes two cuts, and with the field's name they would be the
|
|
137
|
+
* same one repeated. `keyOf` gives the engine's key —the same one the other
|
|
138
|
+
* presentations build, so what is folded holds for all— and `labelOf` reads it in the
|
|
139
|
+
* active language.
|
|
140
140
|
*/
|
|
141
141
|
export type GroupColumn<T> = {
|
|
142
|
-
/**
|
|
142
|
+
/** The level's identity: `levelKey(level)`. */
|
|
143
143
|
id: string;
|
|
144
|
-
/**
|
|
145
|
-
*
|
|
144
|
+
/** What the cut is called, to the left of the value. Without it, «Septiembre» does not
|
|
145
|
+
* say whether it is when it was registered or when it was run. */
|
|
146
146
|
label: string;
|
|
147
|
-
/**
|
|
147
|
+
/** Which pile each row goes to at this level. */
|
|
148
148
|
keyOf: (item: T) => string;
|
|
149
|
-
/**
|
|
149
|
+
/** How that key is read. */
|
|
150
150
|
labelOf: (key: string) => string;
|
|
151
151
|
};
|
|
152
152
|
export declare function DataTable<T extends object>({ data, columns, getRowId, sort, onSortChange, levels, selected, onSelectedChange, height, onRowClick, rowActions, totals, collapsed, onGroupToggle, piles, onMore, create, copyable, }: {
|
|
@@ -158,11 +158,11 @@ export declare function DataTable<T extends object>({ data, columns, getRowId, s
|
|
|
158
158
|
sort?: readonly SortState[];
|
|
159
159
|
onSortChange?: (next: SortState[]) => void;
|
|
160
160
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
161
|
+
* The LEVELS the set is split by, from the outside in. Empty or absent
|
|
162
|
+
* means «not grouped».
|
|
163
163
|
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
164
|
+
* Several, because grouping is not one question: «by customer and then by
|
|
165
|
+
* month» is a tree and not a list of piles. The order IS the hierarchy.
|
|
166
166
|
*/
|
|
167
167
|
levels?: readonly GroupColumn<T>[];
|
|
168
168
|
selected?: ReadonlySet<string>;
|