@sincpro/web-ui 1.11.1 → 2.1.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/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/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 +25 -25
- 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/index.js +2 -2
- package/dist/components/record/RecordSkeleton.js +7 -7
- package/dist/components/search/CriteriaBuilder.d.ts +35 -22
- package/dist/components/search/CriteriaBuilder.js +95 -85
- package/dist/components/search/CriteriaChips.d.ts +9 -9
- package/dist/components/search/CriteriaChips.js +13 -13
- package/dist/components/search/FilterBuilder.d.ts +72 -71
- package/dist/components/search/FilterBuilder.js +190 -145
- 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 +21 -18
- package/dist/components/search/SearchBar.d.ts +34 -34
- package/dist/components/search/SearchBar.js +113 -113
- package/dist/components/search/criteria.d.ts +86 -74
- package/dist/components/search/criteria.js +44 -43
- 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.d.ts +2 -2
- package/dist/components/search/index.js +14 -14
- 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.js +3 -3
- package/dist/components/shell/index.js +1 -1
- 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 +104 -94
- package/dist/foundations/copy.es.js +6 -1
- package/dist/foundations/copy.js +6 -1
- 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/menu/Menu.d.ts +3 -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 +7 -7
- package/dist/primitives/tag/index.js +2 -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/tokens.css +17 -17
- 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";
|
|
@@ -15,9 +15,9 @@ 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
|
|
@@ -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>;
|
|
@@ -92,15 +92,15 @@ const FEATURES = tableFeatures({
|
|
|
92
92
|
aggregationFns,
|
|
93
93
|
});
|
|
94
94
|
/**
|
|
95
|
-
*
|
|
95
|
+
* The aggregate of a column over a set of rows.
|
|
96
96
|
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
97
|
+
* It lives outside the component because three places ask for it: the table's
|
|
98
|
+
* foot, a pile's band in the sheet, and the line of a report built
|
|
99
|
+
* from the piles. Three implementations of «how much does this add up to» means
|
|
100
|
+
* the foot says one number and the pile another.
|
|
101
101
|
*
|
|
102
|
-
* `null`
|
|
103
|
-
*
|
|
102
|
+
* `null` when the column declared no aggregate, is not numeric, or there is no
|
|
103
|
+
* number to add — which is not the same as adding zero.
|
|
104
104
|
*/
|
|
105
105
|
export function aggregateOf(column, rows) {
|
|
106
106
|
if (column.aggregate === undefined || column.numeric !== true)
|
|
@@ -214,22 +214,22 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
|
|
|
214
214
|
id: c.id,
|
|
215
215
|
header: c.header,
|
|
216
216
|
enableSorting: c.sortable !== false,
|
|
217
|
-
/*
|
|
218
|
-
|
|
219
|
-
|
|
217
|
+
/* No column groups. What splits the set are the LEVELS, and
|
|
218
|
+
each one comes in as a column of its own —below— that exists only for
|
|
219
|
+
that: nobody draws it and nobody sorts it. */
|
|
220
220
|
enableGrouping: false,
|
|
221
221
|
aggregationFn: c.aggregate ?? "count",
|
|
222
222
|
})),
|
|
223
|
-
/*
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
223
|
+
/* One column per LEVEL, not per field. It is the only way for «by month and
|
|
224
|
+
inside it by day» to be two cuts: with the column's id, the two levels
|
|
225
|
+
of `registered_at` were the same id repeated, and one id cannot be
|
|
226
|
+
grouped twice.
|
|
227
227
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
228
|
+
And the key is set by the level, not the column: `value` is the SORT
|
|
229
|
+
key —for a date, the milliseconds— and grouping by it leaves one
|
|
230
|
+
pile per instant, with «1789294903895» as its label. Here goes the same
|
|
231
|
+
key the other five presentations build, so the table's piles
|
|
232
|
+
are THE SAME ones and what is folded holds for all. */
|
|
233
233
|
...(levels ?? []).map((level) => helper.accessor((row) => level.keyOf(row), {
|
|
234
234
|
id: level.id,
|
|
235
235
|
header: level.label,
|
|
@@ -316,8 +316,8 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
|
|
|
316
316
|
const key = pathKey(path);
|
|
317
317
|
const depth = path.length - 1;
|
|
318
318
|
const level = levels?.find((one) => one.id === row.groupingColumnId);
|
|
319
|
-
/*
|
|
320
|
-
|
|
319
|
+
/* The pile's KEY —the engine's— and the label, which the level sets: they are two
|
|
320
|
+
texts and only the second changes with the language. */
|
|
321
321
|
const value = path[depth] ?? key;
|
|
322
322
|
return {
|
|
323
323
|
kind: "pile",
|
|
@@ -325,9 +325,9 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
|
|
|
325
325
|
depth,
|
|
326
326
|
level: level?.label,
|
|
327
327
|
label: level === undefined ? value : level.labelOf(value),
|
|
328
|
-
/*
|
|
329
|
-
|
|
330
|
-
|
|
328
|
+
/* The rows INSIDE, not the subgroups: `subRows` of a pile with levels
|
|
329
|
+
below are the piles of the next level, and counting them said «2» where there are
|
|
330
|
+
forty rows. */
|
|
331
331
|
count: row.getLeafRows().filter((leaf) => leaf.subRows.length === 0).length,
|
|
332
332
|
detail: undefined,
|
|
333
333
|
open: collapsed === undefined ? row.getIsExpanded() : !collapsed.includes(key),
|
|
@@ -167,9 +167,9 @@ export declare function EditableTable<T>({ rows, columns, getRowId, onChange, on
|
|
|
167
167
|
* knows what adding up means in their domain —a percentage is not summed, it
|
|
168
168
|
* is averaged. */
|
|
169
169
|
totals, empty, grouping,
|
|
170
|
-
/**
|
|
171
|
-
*
|
|
172
|
-
*
|
|
170
|
+
/** A column's total INSIDE a pile, already formatted. Whoever composes
|
|
171
|
+
* computes it, for the same reason as `totals`: adding up means different things
|
|
172
|
+
* depending on the domain, and a percentage is averaged, not added. */
|
|
173
173
|
groupTotal, height, layout, onOpen, onDiscard, bands, adds, flag, onReorder, cellState, rowState, }: {
|
|
174
174
|
rows: readonly T[];
|
|
175
175
|
columns: readonly EditColumn<T>[];
|
|
@@ -188,14 +188,14 @@ groupTotal, height, layout, onOpen, onDiscard, bands, adds, flag, onReorder, cel
|
|
|
188
188
|
totals?: readonly (ReactNode | null)[];
|
|
189
189
|
empty?: string;
|
|
190
190
|
/**
|
|
191
|
-
*
|
|
191
|
+
* Grouping, with the same contract as the rest of the data views.
|
|
192
192
|
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
193
|
+
* Editing and grouping do not get in each other's way: the row being edited is still a row,
|
|
194
|
+
* and the pile only decides where it lands. What is not inherited is the order — the
|
|
195
|
+
* rows of a pile stay together, so adding a new row puts it at the
|
|
196
|
+
* end of everything and not inside the pile you were looking at, which is the
|
|
197
|
+
* honest behaviour: it does not have a value yet in the field it is
|
|
198
|
+
* grouped by.
|
|
199
199
|
*/
|
|
200
200
|
grouping?: Grouping<T>;
|
|
201
201
|
groupTotal?: (column: EditColumn<T>, rows: readonly T[]) => ReactNode | null;
|
|
@@ -280,9 +280,9 @@ export function EditableTable({ rows, columns, getRowId, onChange, onRemove, onA
|
|
|
280
280
|
* knows what adding up means in their domain —a percentage is not summed, it
|
|
281
281
|
* is averaged. */
|
|
282
282
|
totals, empty, grouping,
|
|
283
|
-
/**
|
|
284
|
-
*
|
|
285
|
-
*
|
|
283
|
+
/** A column's total INSIDE a pile, already formatted. Whoever composes
|
|
284
|
+
* computes it, for the same reason as `totals`: adding up means different things
|
|
285
|
+
* depending on the domain, and a percentage is averaged, not added. */
|
|
286
286
|
groupTotal, height, layout = "auto", onOpen, onDiscard, bands, adds, flag, onReorder, cellState, rowState, }) {
|
|
287
287
|
const copy = useUiCopy();
|
|
288
288
|
const bandOf = (row) => bands?.kind(row) ?? null;
|
|
@@ -367,8 +367,8 @@ groupTotal, height, layout = "auto", onOpen, onDiscard, bands, adds, flag, onReo
|
|
|
367
367
|
const [arriving, setArriving] = useState(null);
|
|
368
368
|
const addButton = useRef(null);
|
|
369
369
|
const rowById = useMemo(() => new Map(rows.map((row) => [getRowId(row), row])), [rows, getRowId]);
|
|
370
|
-
/*
|
|
371
|
-
|
|
370
|
+
/* The sequence that gets drawn: piles and rows interleaved. Without grouping, the
|
|
371
|
+
rows as they are — a table that does not group pays nothing for being able to. */
|
|
372
372
|
const drawn = useMemo(() => {
|
|
373
373
|
const piles = pilesOf(rows, grouping);
|
|
374
374
|
if (piles === null)
|
|
@@ -852,10 +852,10 @@ groupTotal, height, layout = "auto", onOpen, onDiscard, bands, adds, flag, onReo
|
|
|
852
852
|
const inside = pile.piles.length === 0 ? pile.items : pileItems(pile.piles);
|
|
853
853
|
return [
|
|
854
854
|
gap,
|
|
855
|
-
/*
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
855
|
+
/* The band respects the grid: the label in the first
|
|
856
|
+
column and each total under its own. A total in a corner
|
|
857
|
+
forces you to look for which column it belongs to; aligned there is nothing to
|
|
858
|
+
look for. */
|
|
859
859
|
_jsxs("tr", { ...windowed, children: [reorderable ? _jsx("td", { className: "w-0 bg-ground" }) : null, columns.map((c, ci) => (_jsx("td", { className: `bg-ground text-meta ${cell} ${c.numeric === true ? "text-right tabular-nums" : ""}`, style: ci === 0 && pile.depth > 0
|
|
860
860
|
? {
|
|
861
861
|
paddingLeft: `calc(var(--spacing-indent) * ${pile.depth} + 0.625rem)`,
|
|
@@ -97,12 +97,12 @@ defaultOpen, caption, height, }) {
|
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
return (
|
|
100
|
-
/*
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
100
|
+
/* Same decision as the other two tables, in the same place: with a height the
|
|
101
|
+
box scrolls and the stack starts from zero inside; without a height and fitting, there is no
|
|
102
|
+
box and the header sticks below the list's bar. This used
|
|
103
|
+
to be `overflow-auto` always, so the header inherited the
|
|
104
|
+
bar's offset and ended up pushed 68 px into its
|
|
105
|
+
own box — a blank band on top and column titles falling between
|
|
106
|
+
the rows. */
|
|
107
107
|
_jsx("div", { ref: caja.ref, tabIndex: caja.tabIndex, className: `min-w-0 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary ${caja.className}`, style: caja.style, children: _jsxs("table", { className: "w-full border-collapse px-1", children: [caption === undefined ? null : (_jsx("caption", { className: `text-left text-meta text-muted ${byDensity(d, "px-3 pb-2", "px-2 pb-1.5")}`, children: caption })), _jsx("thead", { className: "sticky z-20 bg-ground", style: stickyTop, children: _jsxs("tr", { className: "border-b border-line-strong", children: [_jsx("th", { className: `sticky left-0 z-10 bg-ground text-left ${compact ? "px-2 py-1.5" : "px-3 py-2"}`, children: _jsx("span", { className: "sr-only", children: copy.report.concept }) }), columns.map((c) => (_jsx("th", { scope: "col", className: `text-right ${HEADER_TEXT} ${compact ? "px-2 py-1.5" : "px-3 py-2"}`, children: c.header }, c.id))), _jsx("td", { className: "w-0" })] }) }), _jsx("tbody", { children: rows.map((r) => (_jsx(ReportLine, { row: r, columns: columns, open: open, onToggle: toggle, compact: compact }, r.id))) })] }) }));
|
|
108
108
|
}
|