@sincpro/web-ui 2.12.0 → 2.13.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 +42 -17
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/listing/BoardColumns.js +10 -6
- package/dist/components/listing/Listing.js +3 -1
- package/dist/components/listing/ListingBar.d.ts +16 -94
- package/dist/components/listing/ListingBar.js +24 -2
- package/dist/components/listing/RecordCard.d.ts +41 -3
- package/dist/components/listing/RecordCard.js +63 -22
- package/dist/components/listing/Row.js +5 -2
- package/dist/components/listing/index.d.ts +2 -2
- package/dist/components/listing/index.js +2 -2
- package/dist/components/listing/set.d.ts +1 -1
- package/dist/components/receipt/Receipt.d.ts +51 -0
- package/dist/components/receipt/Receipt.js +23 -0
- package/dist/components/receipt/index.d.ts +1 -0
- package/dist/components/receipt/index.js +3 -0
- package/dist/components/search/CriteriaChips.js +5 -3
- package/dist/components/shell/KioskFrame.d.ts +35 -0
- package/dist/components/shell/KioskFrame.js +39 -0
- package/dist/components/shell/SearchEntry.js +1 -1
- package/dist/components/shell/index.d.ts +1 -0
- package/dist/components/shell/index.js +1 -0
- package/dist/foundations/clock.d.ts +3 -0
- package/dist/foundations/clock.js +41 -0
- package/dist/foundations/copy.es.js +26 -0
- package/dist/foundations/idle.d.ts +1 -0
- package/dist/foundations/idle.js +34 -0
- package/dist/foundations/index.d.ts +3 -0
- package/dist/foundations/index.js +7 -0
- package/dist/foundations/pointer.d.ts +25 -0
- package/dist/foundations/pointer.js +28 -0
- package/dist/foundations/uiCopy.d.ts +38 -0
- package/dist/foundations/uiCopy.js +26 -0
- package/dist/primitives/choice/RadioGroup.d.ts +8 -1
- package/dist/primitives/choice/RadioGroup.js +9 -1
- package/dist/primitives/choice/options.d.ts +3 -0
- package/dist/primitives/field/Keypad.d.ts +43 -0
- package/dist/primitives/field/Keypad.js +62 -0
- package/dist/primitives/field/Stepper.d.ts +28 -0
- package/dist/primitives/field/Stepper.js +52 -0
- package/dist/primitives/field/clipboard.js +1 -1
- package/dist/primitives/field/index.d.ts +3 -0
- package/dist/primitives/field/index.js +6 -0
- package/dist/primitives/field/keypadKeys.d.ts +24 -0
- package/dist/primitives/field/keypadKeys.js +80 -0
- package/dist/primitives/hint/Hint.js +1 -1
- package/dist/primitives/notice/Flag.js +1 -1
- package/dist/primitives/notice/Outcome.d.ts +28 -0
- package/dist/primitives/notice/Outcome.js +28 -0
- package/dist/primitives/notice/index.d.ts +1 -0
- package/dist/primitives/notice/index.js +2 -0
- package/dist/primitives/table/CellCopy.js +1 -1
- package/dist/primitives/table/ReportTable.js +1 -1
- package/dist/primitives/table/RowActions.js +1 -1
- package/dist/primitives/table/Table.js +9 -5
- package/dist/primitives/tag/Tags.d.ts +22 -1
- package/dist/primitives/tag/Tags.js +57 -14
- package/dist/primitives/tag/index.d.ts +1 -1
- package/dist/primitives/value/Elapsed.d.ts +16 -0
- package/dist/primitives/value/Elapsed.js +37 -0
- package/dist/primitives/value/elapsedTime.d.ts +26 -0
- package/dist/primitives/value/elapsedTime.js +32 -0
- package/dist/primitives/value/index.d.ts +2 -0
- package/dist/primitives/value/index.js +4 -0
- package/dist/tokens.css +87 -1
- package/dist/views/list/List.d.ts +11 -0
- package/dist/views/list/List.js +14 -3
- package/dist/views/list/ListView.d.ts +1 -1
- package/dist/views/list/ListView.js +26 -6
- package/dist/views/list/types.d.ts +7 -0
- package/dist/views/record/Record.js +1 -1
- package/package.json +1 -1
|
@@ -7,23 +7,38 @@ import { chosenTone, tagTone } from "./Tag.js";
|
|
|
7
7
|
import { Avatar } from "../value/Person.js";
|
|
8
8
|
import { X } from "lucide-react";
|
|
9
9
|
import { Button as AriaButton, Tag as AriaTag, TagGroup, TagList, } from "react-aria-components";
|
|
10
|
-
export function Tags({ items, surface, label, labelledBy, stack = false, multiple = false, }) {
|
|
10
|
+
export function Tags({ items, surface, label, labelledBy, stack = false, multiple = false, size = "sm", scroll = false, }) {
|
|
11
11
|
const sup = useSurface(surface);
|
|
12
12
|
if (items.length === 0)
|
|
13
13
|
return null;
|
|
14
14
|
const interactive = items.some((i) => i.onSelect !== undefined || i.onRemove !== undefined);
|
|
15
|
+
const layout = stack ? STACK : scroll ? SCROLL : STRIP[size];
|
|
15
16
|
if (!interactive)
|
|
16
|
-
return _jsx(StillStrip, { items: items, surface: sup, label: label, stack: stack });
|
|
17
|
-
return (_jsx(AriaLocale, { children: _jsx(ChipGroup, { items: items, surface: sup, label: label, labelledBy: labelledBy, stack: stack, multiple: multiple }) }));
|
|
17
|
+
return (_jsx(StillStrip, { items: items, surface: sup, label: label, stack: stack, layout: layout, size: size }));
|
|
18
|
+
return (_jsx(AriaLocale, { children: _jsx(ChipGroup, { items: items, surface: sup, label: label, labelledBy: labelledBy, stack: stack, multiple: multiple, layout: layout, size: size }) }));
|
|
18
19
|
}
|
|
19
|
-
const STRIP =
|
|
20
|
+
const STRIP = {
|
|
21
|
+
sm: "flex min-w-0 flex-wrap items-center gap-1",
|
|
22
|
+
md: "flex min-w-0 flex-wrap items-center gap-1.5",
|
|
23
|
+
lg: "flex min-w-0 flex-wrap items-center gap-2",
|
|
24
|
+
};
|
|
25
|
+
/* The fade at the edges is `scroll-hint`'s, over the surface the strip sits on; the bottom
|
|
26
|
+
padding keeps a focus ring from being clipped by the scroll box. */
|
|
27
|
+
const SCROLL = "scroll-hint scroll-quiet flex min-w-0 flex-nowrap items-center gap-2 overflow-x-auto py-1";
|
|
20
28
|
const STACK = "flex min-w-0 flex-col items-stretch gap-0.5";
|
|
21
29
|
/** A strip nobody presses: text in a row, a list only when it is named. */
|
|
22
|
-
function StillStrip({ items, surface, label, stack, }) {
|
|
30
|
+
function StillStrip({ items, surface, label, stack, layout, size, }) {
|
|
23
31
|
const listed = label !== undefined;
|
|
24
|
-
return (_jsx("span", { className:
|
|
32
|
+
return (_jsx("span", { className: layout, ...(listed ? { role: "list", "aria-label": label } : {}), children: items.map((item) => (_jsx("span", { "data-ui": "tags.item", ...(listed ? { role: "listitem" } : {}), ...(item.title === undefined ? {} : { title: item.title }), "data-size": size, className: shell({
|
|
33
|
+
item,
|
|
34
|
+
surface,
|
|
35
|
+
stack,
|
|
36
|
+
size,
|
|
37
|
+
removable: false,
|
|
38
|
+
pressable: false,
|
|
39
|
+
}), children: _jsx(Inside, { item: item }) }, item.id))) }));
|
|
25
40
|
}
|
|
26
|
-
function ChipGroup({ items, surface, label, labelledBy, stack, multiple, }) {
|
|
41
|
+
function ChipGroup({ items, surface, label, labelledBy, stack, multiple, layout, size, }) {
|
|
27
42
|
const byId = new Map(items.map((item) => [item.id, item]));
|
|
28
43
|
const removable = items.some((i) => i.onRemove !== undefined);
|
|
29
44
|
/* Selection is React Aria's only when the chips SAY whether they are chosen: then the
|
|
@@ -65,19 +80,29 @@ function ChipGroup({ items, surface, label, labelledBy, stack, multiple, }) {
|
|
|
65
80
|
: {}),
|
|
66
81
|
/* Escape belongs to whatever holds the strip — the popover it lives in closes with it —
|
|
67
82
|
and not to «clear the selection», which would erase the choice without a word. */
|
|
68
|
-
escapeKeyBehavior: "none", className: "min-w-0", children: _jsx(TagList, { items: items, className:
|
|
83
|
+
escapeKeyBehavior: "none", className: "min-w-0", children: _jsx(TagList, { items: items, className: layout, children: (item) => (_jsxs(AriaTag, { "data-ui": "tags.item", "data-size": size, id: item.id, textValue: item.note === undefined ? item.label : `${item.label} ${item.note}`, ...(!selecting && item.onSelect !== undefined
|
|
69
84
|
? { onAction: item.onSelect }
|
|
70
85
|
: {}), ...(item.title === undefined ? {} : { title: item.title }), className: ({ isFocusVisible, isHovered }) => cn(shell({
|
|
71
86
|
item,
|
|
72
87
|
surface,
|
|
73
88
|
stack,
|
|
89
|
+
size,
|
|
74
90
|
removable: item.onRemove !== undefined,
|
|
75
91
|
pressable: item.onSelect !== undefined,
|
|
76
|
-
}), item.onSelect !== undefined &&
|
|
92
|
+
}), item.onSelect !== undefined &&
|
|
93
|
+
isHovered &&
|
|
94
|
+
item.active !== true &&
|
|
95
|
+
!(item.selected === true && size !== "sm")
|
|
77
96
|
? bySurface(surface, "border-ink/40", "border-chrome-ink/40")
|
|
78
97
|
: "", "outline-offset-1", focusRing({ isFocusVisible })), children: [_jsx(Inside, { item: item }), item.onRemove === undefined ? null : _jsx(Remove, { item: item, surface: surface })] })) }) }));
|
|
79
98
|
}
|
|
80
|
-
function paint(item, surface) {
|
|
99
|
+
function paint(item, surface, size) {
|
|
100
|
+
/* A chosen chip of a filter row or a till's categories is the CHOICE the screen is in —
|
|
101
|
+
filled, like the chosen segment of a `SegmentedControl`. A chosen `sm` chip stays a tint:
|
|
102
|
+
there it is a value among values. */
|
|
103
|
+
if (item.selected === true && size !== "sm") {
|
|
104
|
+
return bySurface(surface, "border border-primary bg-primary text-surface", "border border-chrome-link bg-chrome-link text-chrome");
|
|
105
|
+
}
|
|
81
106
|
if (item.active === true) {
|
|
82
107
|
return bySurface(surface, "border border-primary bg-primary text-surface", "border border-chrome-link bg-chrome-link text-chrome");
|
|
83
108
|
}
|
|
@@ -90,18 +115,36 @@ function paint(item, surface) {
|
|
|
90
115
|
/* Stacked, each chip takes its whole line: a column of chips of different widths does not
|
|
91
116
|
read as a list, it reads as a mess — and the blank on the right is what lets it be
|
|
92
117
|
pressed without aiming. */
|
|
93
|
-
|
|
94
|
-
|
|
118
|
+
/* The height of each size, and the room the label gets inside it. `sm` is a line of text and
|
|
119
|
+
grows under a finger only if someone can press it. */
|
|
120
|
+
const SIZE = {
|
|
121
|
+
sm: { box: "gap-1 py-0.5 text-micro", pad: "px-2", removePad: "pr-0.5 pl-2" },
|
|
122
|
+
md: {
|
|
123
|
+
box: "h-(--size-control-sm) gap-1.5 text-meta",
|
|
124
|
+
pad: "px-3",
|
|
125
|
+
removePad: "pr-1.5 pl-3",
|
|
126
|
+
},
|
|
127
|
+
lg: {
|
|
128
|
+
box: "h-(--size-control-lg) gap-2 text-body font-medium",
|
|
129
|
+
pad: "px-4",
|
|
130
|
+
removePad: "pr-2 pl-4",
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
function shell({ item, surface, stack, size, removable, pressable, }) {
|
|
134
|
+
const box = SIZE[size];
|
|
135
|
+
return cn(stack ? "flex w-full justify-start" : "inline-flex shrink-0", "min-w-0 items-center rounded-ui-tag transition-colors duration-(--duration-instant)", box.box, size === "sm" && (pressable || removable) ? "touch:min-h-8 touch:text-meta" : "", paint(item, surface, size), removable ? box.removePad : box.pad, pressable ? "cursor-pointer" : "cursor-default");
|
|
95
136
|
}
|
|
96
137
|
function Inside({ item }) {
|
|
97
138
|
const Icon = item.icon;
|
|
98
139
|
return (_jsxs(_Fragment, { children: [Icon === undefined ? null : (_jsx(Icon, { className: "size-3 shrink-0 opacity-70", strokeWidth: 2, "aria-hidden": true })), item.avatar === undefined ? null : (_jsx("span", { "aria-hidden": true, className: "-my-0.5 -ml-1.5 flex shrink-0", children: _jsx(Avatar, { name: item.label, size: "sm", ...(typeof item.avatar === "string" ? { src: item.avatar } : {}) }) })), _jsx("span", { className: "min-w-0 truncate", children: item.label }), item.note === undefined ? null : (
|
|
99
140
|
/* Secondary by its separator and weight, not by fading: at 60 % the note fell
|
|
100
141
|
under 4.5:1 on a tinted chip. */
|
|
101
|
-
_jsxs("span", { className: "shrink-0 font-normal", children: ["\u00B7 ", item.note] }))
|
|
142
|
+
_jsxs("span", { className: "shrink-0 font-normal", children: ["\u00B7 ", item.note] })), item.count === undefined ? null : (
|
|
143
|
+
/* Apart by a gap and lighter, not dimmer — the same reason as the note. */
|
|
144
|
+
_jsx("span", { "data-ui": "tags.count", className: "shrink-0 font-normal tabular-nums", children: item.count }))] }));
|
|
102
145
|
}
|
|
103
146
|
/* The × is React Aria's `remove` slot: it removes THIS chip and never presses it, so
|
|
104
147
|
removing a pressable chip does not also choose it. */
|
|
105
148
|
function Remove({ item, surface }) {
|
|
106
|
-
return (_jsx(AriaButton, { slot: "remove", ...(item.removeLabel === undefined ? {} : { "aria-label": item.removeLabel }), className: ({ isFocusVisible }) => cn("inline-flex size-4 shrink-0 cursor-default items-center justify-center rounded-pill transition-colors duration-(--duration-instant)", bySurface(surface, "hover:bg-ink/15 pressed:bg-ink/20", "hover:bg-chrome-ink/25 pressed:bg-chrome-ink/30"), focusRing({ isFocusVisible })), children: _jsx(X, { className: "size-3", strokeWidth: 2.5, "aria-hidden": true }) }));
|
|
149
|
+
return (_jsx(AriaButton, { slot: "remove", ...(item.removeLabel === undefined ? {} : { "aria-label": item.removeLabel }), className: ({ isFocusVisible }) => cn("hit-target inline-flex size-4 shrink-0 cursor-default items-center justify-center rounded-pill transition-colors duration-(--duration-instant)", bySurface(surface, "hover:bg-ink/15 pressed:bg-ink/20", "hover:bg-chrome-ink/25 pressed:bg-chrome-ink/30"), focusRing({ isFocusVisible })), children: _jsx(X, { className: "size-3", strokeWidth: 2.5, "aria-hidden": true }) }));
|
|
107
150
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ElapsedSince, type ElapsedThresholds } from "./elapsedTime.js";
|
|
2
|
+
export type ElapsedProps = {
|
|
3
|
+
/** When the wait started. */
|
|
4
|
+
since: ElapsedSince;
|
|
5
|
+
/** For a test or a screenshot: a fixed «now» instead of the live clock. */
|
|
6
|
+
now?: number;
|
|
7
|
+
} & ElapsedThresholds;
|
|
8
|
+
/**
|
|
9
|
+
* How long it has been waiting, live: «4:05», amber past `warnAfter`, red past `badAfter`.
|
|
10
|
+
*
|
|
11
|
+
* Context: a kitchen display reads AGE, not arrival — the cook looks for the red ticket, not
|
|
12
|
+
* for «12:40». The figure ticks every second off one shared clock (`useNow`), and the clock
|
|
13
|
+
* icon with the written time keeps the colour from being the only channel. On the server it
|
|
14
|
+
* draws nothing: there is no «now» both sides agree on.
|
|
15
|
+
*/
|
|
16
|
+
export declare function Elapsed({ since, now: fixed, warnAfter, badAfter }: ElapsedProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useNow } from "../../foundations/clock.js";
|
|
4
|
+
import { fillCopy, useUiCopy } from "../../foundations/copy.js";
|
|
5
|
+
import { elapsedMillis, elapsedTone, formatElapsed, } from "./elapsedTime.js";
|
|
6
|
+
import { Timer } from "lucide-react";
|
|
7
|
+
/* The figure in its tone — text on a card, so the readable ones. */
|
|
8
|
+
const TEXT = {
|
|
9
|
+
neutral: "text-muted",
|
|
10
|
+
info: "text-info",
|
|
11
|
+
good: "text-good",
|
|
12
|
+
warn: "text-warn",
|
|
13
|
+
bad: "text-bad",
|
|
14
|
+
accent: "text-ink",
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* How long it has been waiting, live: «4:05», amber past `warnAfter`, red past `badAfter`.
|
|
18
|
+
*
|
|
19
|
+
* Context: a kitchen display reads AGE, not arrival — the cook looks for the red ticket, not
|
|
20
|
+
* for «12:40». The figure ticks every second off one shared clock (`useNow`), and the clock
|
|
21
|
+
* icon with the written time keeps the colour from being the only channel. On the server it
|
|
22
|
+
* draws nothing: there is no «now» both sides agree on.
|
|
23
|
+
*/
|
|
24
|
+
export function Elapsed({ since, now: fixed, warnAfter, badAfter }) {
|
|
25
|
+
const copy = useUiCopy();
|
|
26
|
+
const live = useNow();
|
|
27
|
+
const now = fixed ?? live;
|
|
28
|
+
if (now === null)
|
|
29
|
+
return null;
|
|
30
|
+
const millis = elapsedMillis(since, now);
|
|
31
|
+
const tone = elapsedTone(millis, {
|
|
32
|
+
...(warnAfter === undefined ? {} : { warnAfter }),
|
|
33
|
+
...(badAfter === undefined ? {} : { badAfter }),
|
|
34
|
+
});
|
|
35
|
+
const text = formatElapsed(millis);
|
|
36
|
+
return (_jsxs("span", { "data-ui": "elapsed", "data-tone": tone ?? "neutral", title: fillCopy(copy.elapsed.waiting, { time: text }), className: `inline-flex shrink-0 items-center gap-1 text-meta font-semibold tabular-nums ${TEXT[tone ?? "neutral"]}`, children: [_jsx(Timer, { "aria-hidden": true, className: "size-(--size-icon-sm)", strokeWidth: 2.25 }), _jsx("span", { className: "sr-only", children: copy.elapsed.label }), text] }));
|
|
37
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Tone } from "../../foundations/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* HOW LONG IT HAS BEEN WAITING — the arithmetic of `Elapsed`, pure so a server, a test or a
|
|
4
|
+
* sort can use it: «the oldest ticket first» is the same subtraction.
|
|
5
|
+
*
|
|
6
|
+
* Context: a kitchen's ticket, a support case under an SLA, an order at the counter. What is
|
|
7
|
+
* read is not the hour it arrived but how long ago, and whether that is already too long — so
|
|
8
|
+
* the time carries a tone by two thresholds the domain sets (in minutes): `warnAfter` turns it
|
|
9
|
+
* amber, `badAfter` red. The colour is never alone: the figure is always written.
|
|
10
|
+
*/
|
|
11
|
+
/** When it started: a `Date`, an ISO string or epoch milliseconds — what a record carries. */
|
|
12
|
+
export type ElapsedSince = Date | string | number;
|
|
13
|
+
/** The two thresholds, in minutes. Without them the time has no tone: it only informs. */
|
|
14
|
+
export type ElapsedThresholds = {
|
|
15
|
+
warnAfter?: number;
|
|
16
|
+
badAfter?: number;
|
|
17
|
+
};
|
|
18
|
+
export declare function sinceMillis(since: ElapsedSince): number;
|
|
19
|
+
/** Milliseconds from `since` to `now`; never negative — a clock a little behind the server's
|
|
20
|
+
* must not write «-0:03». */
|
|
21
|
+
export declare function elapsedMillis(since: ElapsedSince, now: number): number;
|
|
22
|
+
/** «4:05» under an hour, «1:02:03» over it — the way a stopwatch reads, in figures that line up. */
|
|
23
|
+
export declare function formatElapsed(millis: number): string;
|
|
24
|
+
/** The tone of a wait: `bad` past `badAfter`, `warn` past `warnAfter`, `good` before them,
|
|
25
|
+
* and `undefined` when no threshold was given (it only informs). */
|
|
26
|
+
export declare function elapsedTone(millis: number, limits: ElapsedThresholds): Tone | undefined;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function sinceMillis(since) {
|
|
2
|
+
return since instanceof Date ? since.getTime() : new Date(since).getTime();
|
|
3
|
+
}
|
|
4
|
+
/** Milliseconds from `since` to `now`; never negative — a clock a little behind the server's
|
|
5
|
+
* must not write «-0:03». */
|
|
6
|
+
export function elapsedMillis(since, now) {
|
|
7
|
+
return Math.max(0, now - sinceMillis(since));
|
|
8
|
+
}
|
|
9
|
+
/** «4:05» under an hour, «1:02:03» over it — the way a stopwatch reads, in figures that line up. */
|
|
10
|
+
export function formatElapsed(millis) {
|
|
11
|
+
const total = Math.floor(millis / 1000);
|
|
12
|
+
const hours = Math.floor(total / 3600);
|
|
13
|
+
const minutes = Math.floor((total % 3600) / 60);
|
|
14
|
+
const seconds = total % 60;
|
|
15
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
16
|
+
return hours > 0
|
|
17
|
+
? `${hours}:${pad(minutes)}:${pad(seconds)}`
|
|
18
|
+
: `${minutes}:${pad(seconds)}`;
|
|
19
|
+
}
|
|
20
|
+
/** The tone of a wait: `bad` past `badAfter`, `warn` past `warnAfter`, `good` before them,
|
|
21
|
+
* and `undefined` when no threshold was given (it only informs). */
|
|
22
|
+
export function elapsedTone(millis, limits) {
|
|
23
|
+
const { warnAfter, badAfter } = limits;
|
|
24
|
+
if (warnAfter === undefined && badAfter === undefined)
|
|
25
|
+
return undefined;
|
|
26
|
+
const minutes = millis / 60_000;
|
|
27
|
+
if (badAfter !== undefined && minutes >= badAfter)
|
|
28
|
+
return "bad";
|
|
29
|
+
if (warnAfter !== undefined && minutes >= warnAfter)
|
|
30
|
+
return "warn";
|
|
31
|
+
return "good";
|
|
32
|
+
}
|
|
@@ -11,6 +11,8 @@ export { RelationCard, type RelationCardProps, type RelationSummary, RelationVal
|
|
|
11
11
|
export { RichTextValue, sanitizeRichText } from "./RichText.js";
|
|
12
12
|
export { isRichTextEmpty, richTextPlain, } from "./richTextPlain.js";
|
|
13
13
|
export { type Rounding, type RoundingMethod, roundTo, } from "./rounding.js";
|
|
14
|
+
export { Elapsed, type ElapsedProps } from "./Elapsed.js";
|
|
15
|
+
export { elapsedMillis, type ElapsedSince, type ElapsedThresholds, elapsedTone, formatElapsed, sinceMillis, } from "./elapsedTime.js";
|
|
14
16
|
export { Totals, type TotalsCredit, type TotalsDeduction, type TotalsFact, type TotalsProps, type TotalsRow, } from "./Totals.js";
|
|
15
17
|
export { Cell, KeyValue, Numeric } from "./Value.js";
|
|
16
18
|
export { YesNo, type YesNoLook } from "./YesNo.js";
|
|
@@ -15,6 +15,10 @@ export { RelationCard, RelationValue, } from "./Relation.js";
|
|
|
15
15
|
export { RichTextValue, sanitizeRichText } from "./RichText.js";
|
|
16
16
|
export { isRichTextEmpty, richTextPlain, } from "./richTextPlain.js";
|
|
17
17
|
export { roundTo, } from "./rounding.js";
|
|
18
|
+
/* HOW LONG IT HAS BEEN WAITING — a kitchen's ticket, a case under an SLA: live, in a tone by
|
|
19
|
+
two thresholds. The arithmetic is pure (`elapsedTime.ts`), so a sort or a server reads it. */
|
|
20
|
+
export { Elapsed } from "./Elapsed.js";
|
|
21
|
+
export { elapsedMillis, elapsedTone, formatElapsed, sinceMillis, } from "./elapsedTime.js";
|
|
18
22
|
export { Totals, } from "./Totals.js";
|
|
19
23
|
export { Cell, KeyValue, Numeric } from "./Value.js";
|
|
20
24
|
export { YesNo } from "./YesNo.js";
|
package/dist/tokens.css
CHANGED
|
@@ -599,6 +599,27 @@
|
|
|
599
599
|
/* One stage of a board by stages: a card with its name, a tag and a figure, without
|
|
600
600
|
wrapping the name into three lines. Five stages fit a desk; more scroll sideways. */
|
|
601
601
|
--container-lane: 18rem;
|
|
602
|
+
/* …and the widest it grows to when the stages fit the screen: lanes share the width
|
|
603
|
+
instead of leaving a blank on the right, but a lane of three cards stretched to 60rem
|
|
604
|
+
reads as a table with one column. */
|
|
605
|
+
--container-lane-max: 26rem;
|
|
606
|
+
/* The narrowest a tile of a grid gets (a product on a till, an item of a shop) — three
|
|
607
|
+
places, like the controls: a dense back-office grid, a till, a shop window. The grid
|
|
608
|
+
fits as many as the width takes (`--grid-tiles-*`). */
|
|
609
|
+
--container-tile-sm: 8.5rem;
|
|
610
|
+
--container-tile-md: 11rem;
|
|
611
|
+
--container-tile-lg: 15rem;
|
|
612
|
+
--grid-tiles-sm: repeat(auto-fill, minmax(min(100%, var(--container-tile-sm)), 1fr));
|
|
613
|
+
--grid-tiles-md: repeat(auto-fill, minmax(min(100%, var(--container-tile-md)), 1fr));
|
|
614
|
+
--grid-tiles-lg: repeat(auto-fill, minmax(min(100%, var(--container-tile-lg)), 1fr));
|
|
615
|
+
/* A kiosk's reduced height: the empty band above the flow, so every target sits below
|
|
616
|
+
~120 cm on a standing kiosk — within a seated person's reach (ADA 308). */
|
|
617
|
+
--size-kiosk-reach: 45dvh;
|
|
618
|
+
/* A printed ticket: the width of an 80 mm thermal roll's printable area (72 mm). */
|
|
619
|
+
--container-receipt: 72mm;
|
|
620
|
+
/* A tile's picture: 4:3, the shape a product photo is taken in and the one that keeps two
|
|
621
|
+
lines of name under it on a 11rem tile. */
|
|
622
|
+
--aspect-tile: 4 / 3;
|
|
602
623
|
/* The names column of a timeline (an employee with an avatar, a room, a machine): wide enough
|
|
603
624
|
for «Ammy Shalem Aranibar Zambrana» before it truncates. */
|
|
604
625
|
--container-timeline-label: 15rem;
|
|
@@ -705,6 +726,11 @@
|
|
|
705
726
|
--size-control-md: 36px;
|
|
706
727
|
--size-control-lg: 42px;
|
|
707
728
|
|
|
729
|
+
/* The least a pressable thing answers to, whatever it LOOKS like (`hit-target`): a chip's
|
|
730
|
+
«×» is drawn at 16px so a bar of ten filters stays one line, but it answers to 24px —
|
|
731
|
+
WCAG 2.2's minimum target (2.5.8) — and to 44px under a finger (TOUCH, below). */
|
|
732
|
+
--size-target: 24px;
|
|
733
|
+
|
|
708
734
|
--size-icon-sm: 12px;
|
|
709
735
|
--size-icon-md: 16px;
|
|
710
736
|
--size-icon-lg: 18px;
|
|
@@ -815,6 +841,13 @@
|
|
|
815
841
|
|
|
816
842
|
/* A box of content: a block, a card of a list, a metric. */
|
|
817
843
|
--radius-ui-card: var(--ui-card-radius, var(--radius-box));
|
|
844
|
+
/* A RECORD's card — one of many on a board or a grid: the control's corner, not the box's.
|
|
845
|
+
Twelve 12px boxes in a lane read as bubbles, not as records. It falls back to the card's
|
|
846
|
+
knob, so an application that re-skinned its cards re-skins these too. */
|
|
847
|
+
--radius-ui-record-card: var(
|
|
848
|
+
--ui-record-card-radius,
|
|
849
|
+
var(--ui-card-radius, var(--radius-control))
|
|
850
|
+
);
|
|
818
851
|
--color-ui-card: var(--ui-card-bg, var(--color-surface));
|
|
819
852
|
--color-ui-card-border: var(--ui-card-border, var(--color-line));
|
|
820
853
|
|
|
@@ -1553,12 +1586,65 @@
|
|
|
1553
1586
|
* a desktop browser narrowed to 400 px keeps the mouse sizes, a tablet in
|
|
1554
1587
|
* landscape gets the finger ones. Every component reads these tokens, so
|
|
1555
1588
|
* nothing else has to know about touch.
|
|
1589
|
+
*
|
|
1590
|
+
* ── The application can SAY it (`data-pointer`) ─────────────────────
|
|
1591
|
+
*
|
|
1592
|
+
* The browser answers for the PRIMARY pointer, and a till is a touch monitor
|
|
1593
|
+
* with a mouse plugged in: `pointer: coarse` is false there and the cashier
|
|
1594
|
+
* gets 30 px targets. So the application can decide instead, on `<html>` or
|
|
1595
|
+
* on any zone: `data-pointer="touch"` sizes for a finger whatever the device
|
|
1596
|
+
* says, `data-pointer="fine"` keeps the mouse sizes on a tablet that drives a
|
|
1597
|
+
* back office. Without it, the device decides, as before.
|
|
1598
|
+
*
|
|
1599
|
+
* What is not a size — a control that only shows on hover, a shortcut hint —
|
|
1600
|
+
* asks the same question with the `touch:` variant, so it follows the same
|
|
1601
|
+
* decision.
|
|
1556
1602
|
* ==================================================================== */
|
|
1557
1603
|
@media (pointer: coarse) {
|
|
1558
|
-
:root {
|
|
1604
|
+
:root:not([data-pointer="fine"]) {
|
|
1559
1605
|
--size-control-sm: 44px;
|
|
1560
1606
|
--size-control-md: 44px;
|
|
1561
1607
|
--size-control-lg: 48px;
|
|
1608
|
+
--size-target: 44px;
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
[data-pointer="touch"] {
|
|
1612
|
+
--size-control-sm: 44px;
|
|
1613
|
+
--size-control-md: 44px;
|
|
1614
|
+
--size-control-lg: 48px;
|
|
1615
|
+
--size-target: 44px;
|
|
1616
|
+
}
|
|
1617
|
+
:root [data-pointer="fine"] {
|
|
1618
|
+
--size-control-sm: 30px;
|
|
1619
|
+
--size-control-md: 36px;
|
|
1620
|
+
--size-control-lg: 42px;
|
|
1621
|
+
--size-target: 24px;
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
/* `touch:` — under a finger, by the device or by the application's word. */
|
|
1625
|
+
@custom-variant touch {
|
|
1626
|
+
@media (pointer: coarse) {
|
|
1627
|
+
&:not(:where([data-pointer="fine"], [data-pointer="fine"] *)) {
|
|
1628
|
+
@slot;
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
&:where([data-pointer="touch"], [data-pointer="touch"] *) {
|
|
1632
|
+
@slot;
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
/* A pressable thing drawn smaller than a finger answers to `--size-target` around its
|
|
1637
|
+
centre: the drawing stays (a bar of chips stays one line), the target grows. */
|
|
1638
|
+
@utility hit-target {
|
|
1639
|
+
position: relative;
|
|
1640
|
+
&::after {
|
|
1641
|
+
content: "";
|
|
1642
|
+
position: absolute;
|
|
1643
|
+
top: 50%;
|
|
1644
|
+
left: 50%;
|
|
1645
|
+
width: max(100%, var(--size-target));
|
|
1646
|
+
height: max(100%, var(--size-target));
|
|
1647
|
+
transform: translate(-50%, -50%);
|
|
1562
1648
|
}
|
|
1563
1649
|
}
|
|
1564
1650
|
|
|
@@ -57,6 +57,15 @@ type BoardProps<T> = {
|
|
|
57
57
|
/** One column per stage, with drag (and Alt + ← / →) to move a card between them. */
|
|
58
58
|
stages?: BoardStages<T>;
|
|
59
59
|
};
|
|
60
|
+
/** The TILES: a grid of `RecordCard layout="tile"` — a till's products, a shop's items.
|
|
61
|
+
* Without `card`, the tile comes from what `List.Rows` says (name, meta, chips). */
|
|
62
|
+
type TilesProps<T> = {
|
|
63
|
+
/** `ways` carries the list's rule of what a press does — call `ways.press` from the tile. */
|
|
64
|
+
card?: (item: T, ways: CardWays) => ReactNode;
|
|
65
|
+
/** How wide a tile gets at least — `sm` a dense back office, `md` a till, `lg` a shop's
|
|
66
|
+
* storefront. The grid fits as many as the width takes. */
|
|
67
|
+
size?: "sm" | "md" | "lg";
|
|
68
|
+
};
|
|
60
69
|
/** The sheet. Without columns of its own, it comes from those `List.Table` declared — the
|
|
61
70
|
* one for RAW data does bring them, because there they come from the file and the code does not know
|
|
62
71
|
* which they are. */
|
|
@@ -155,9 +164,11 @@ export declare namespace List {
|
|
|
155
164
|
var Pagination: ((props: NodeProps) => ReactNode) & import("../../foundations/slots.js").Slotted<"pagination">;
|
|
156
165
|
var Views: ((props: NodeProps) => ReactNode) & import("../../foundations/slots.js").Slotted<"views">;
|
|
157
166
|
var Metrics: ((props: NodeProps) => ReactNode) & import("../../foundations/slots.js").Slotted<"metrics">;
|
|
167
|
+
var Filters: ((props: NodeProps) => ReactNode) & import("../../foundations/slots.js").Slotted<"filters">;
|
|
158
168
|
var Rows: <T>(props: RowsProps<T>) => ReactNode;
|
|
159
169
|
var Table: <T extends object>(props: TableProps<T>) => ReactNode;
|
|
160
170
|
var Board: <T>(props: BoardProps<T>) => ReactNode;
|
|
171
|
+
var Tiles: <T>(props: TilesProps<T>) => ReactNode;
|
|
161
172
|
var Sheet: <T>(props: SheetProps<T>) => ReactNode;
|
|
162
173
|
var Report: ((props: ListReport) => ReactNode) & import("../../foundations/slots.js").Slotted<"report">;
|
|
163
174
|
var Pivot: <T>(props: ListPivot<T>) => ReactNode;
|
package/dist/views/list/List.js
CHANGED
|
@@ -23,11 +23,16 @@ const Views = slot("views", (_props) => null);
|
|
|
23
23
|
/** The metrics that also NARROW: «2 por confirmar». They go below the bar and
|
|
24
24
|
* above the rows, because they belong to the set and not to the frame. */
|
|
25
25
|
const Metrics = slot("metrics", (_props) => null);
|
|
26
|
+
/** The QUICK filters: the few cuts changed all day — a category, a state — always in sight
|
|
27
|
+
* under the bar instead of behind the search's panel. Usually a `Tags size="md"` with
|
|
28
|
+
* `selected` and `count`; under a finger they are the way a till or a shop narrows. */
|
|
29
|
+
const Filters = slot("filters", (_props) => null);
|
|
26
30
|
const Rows = slot("rows", (_props) => null);
|
|
27
31
|
/* Through `unknown`: `create` both receives and hands back a `T` (`onChange`, `draft`),
|
|
28
32
|
so `TableProps` is invariant in `T` and `TableProps<never>` no longer narrows to it. The
|
|
29
33
|
slot only carries the props; `List` reads them back typed against the list's `T`. */
|
|
30
34
|
const TableSlot = slot("table", (_props) => null);
|
|
35
|
+
const Tiles = slot("tiles", (_props) => null);
|
|
31
36
|
const Board = slot("board", (_props) => null);
|
|
32
37
|
const SheetSlot = slot("sheet", (_props) => null);
|
|
33
38
|
const Report = slot("report", (_props) => null);
|
|
@@ -42,6 +47,7 @@ const PRESENT_OF = {
|
|
|
42
47
|
rows: "rows",
|
|
43
48
|
table: "table",
|
|
44
49
|
board: "board",
|
|
50
|
+
tiles: "tiles",
|
|
45
51
|
sheet: "sheet",
|
|
46
52
|
report: "report",
|
|
47
53
|
pivot: "pivot",
|
|
@@ -54,6 +60,7 @@ const FACES = [
|
|
|
54
60
|
"rows",
|
|
55
61
|
"table",
|
|
56
62
|
"board",
|
|
63
|
+
"tiles",
|
|
57
64
|
"sheet",
|
|
58
65
|
"report",
|
|
59
66
|
"pivot",
|
|
@@ -99,9 +106,11 @@ export function List({ items, keyOf, embedded, surface, group, selection: select
|
|
|
99
106
|
const pagination = propsOf(pick(bar, "pagination"))?.children;
|
|
100
107
|
const views = propsOf(pick(bar, "views"))?.children;
|
|
101
108
|
const metrics = propsOf(pick(top, "metrics"))?.children;
|
|
109
|
+
const filters = propsOf(pick(top, "filters"))?.children;
|
|
102
110
|
const rows = propsOf(pick(top, "rows"));
|
|
103
111
|
const table = propsOf(pick(top, "table"));
|
|
104
112
|
const board = propsOf(pick(top, "board"));
|
|
113
|
+
const tiles = propsOf(pick(top, "tiles"));
|
|
105
114
|
const sheet = propsOf(pick(top, "sheet"));
|
|
106
115
|
const report = propsOf(pick(top, "report"));
|
|
107
116
|
const pivot = propsOf(pick(top, "pivot"));
|
|
@@ -122,7 +131,7 @@ export function List({ items, keyOf, embedded, surface, group, selection: select
|
|
|
122
131
|
});
|
|
123
132
|
/* The escape hatch: what the archetype did not foresee is drawn anyway, below.
|
|
124
133
|
Something showing up here is the sign that the archetype is missing a piece. */
|
|
125
|
-
const rest = loose(top, ["bar", "metrics", "present", ...FACES]);
|
|
134
|
+
const rest = loose(top, ["bar", "metrics", "filters", "present", ...FACES]);
|
|
126
135
|
return (_jsx(ListView, { items: items, keyOf: keyOf, row: rows === undefined
|
|
127
136
|
? () => ({ name: "" })
|
|
128
137
|
: readOnly
|
|
@@ -130,7 +139,7 @@ export function List({ items, keyOf, embedded, surface, group, selection: select
|
|
|
130
139
|
const { actions: _actions, ...rest } = rows.row(item);
|
|
131
140
|
return rest;
|
|
132
141
|
}
|
|
133
|
-
: rows.row, ...(rows?.header === undefined ? {} : { rowHeader: rows.header }), ...(identity === undefined ? {} : { identity }), ...(crumbs === undefined ? {} : { crumbs }), ...(embedded === undefined ? {} : { embedded }), ...(surface === undefined ? {} : { surface }), ...(search === undefined ? {} : { search }), ...(actions === undefined ? {} : { actions }), ...(dock === undefined || readOnly ? {} : { dock }), ...(pagination === undefined ? {} : { pagination }), ...(views === undefined ? {} : { views }), ...(metrics === undefined ? {} : { metrics }), ...(table === undefined
|
|
142
|
+
: rows.row, ...(rows?.header === undefined ? {} : { rowHeader: rows.header }), ...(identity === undefined ? {} : { identity }), ...(crumbs === undefined ? {} : { crumbs }), ...(embedded === undefined ? {} : { embedded }), ...(surface === undefined ? {} : { surface }), ...(search === undefined ? {} : { search }), ...(actions === undefined ? {} : { actions }), ...(dock === undefined || readOnly ? {} : { dock }), ...(pagination === undefined ? {} : { pagination }), ...(views === undefined ? {} : { views }), ...(metrics === undefined ? {} : { metrics }), ...(filters === undefined ? {} : { filters }), ...(table === undefined
|
|
134
143
|
? {}
|
|
135
144
|
: {
|
|
136
145
|
/* Read-only: a cell that opens an editor is an action too. */
|
|
@@ -148,7 +157,7 @@ export function List({ items, keyOf, embedded, surface, group, selection: select
|
|
|
148
157
|
...(table.onVisibleColumnIdsChange === undefined
|
|
149
158
|
? {}
|
|
150
159
|
: { onVisibleColumnIdsChange: table.onVisibleColumnIdsChange }),
|
|
151
|
-
}), ...(board?.card === undefined ? {} : { card: board.card }), ...(board?.stages === undefined ? {} : { boardStages: board.stages }), ...(sheet?.columns === undefined || sheet.cell === undefined
|
|
160
|
+
}), ...(board?.card === undefined ? {} : { card: board.card }), ...(board?.stages === undefined ? {} : { boardStages: board.stages }), ...(tiles === undefined ? {} : { tiles }), ...(sheet?.columns === undefined || sheet.cell === undefined
|
|
152
161
|
? {}
|
|
153
162
|
: { sheet: sheet }), ...(report === undefined ? {} : { report }), ...(pivot === undefined ? {} : { pivot }), ...(chart === undefined ? {} : { chart }), ...(calendar === undefined ? {} : { calendar }), ...(gantt === undefined ? {} : { gantt }), ...(timeline === undefined ? {} : { timeline }), ...(faces.length === 0 ? {} : { faces }), ...(presents.length === 0 ? {} : { presents }), ...(present === undefined
|
|
154
163
|
? presents[0] === undefined
|
|
@@ -165,9 +174,11 @@ List.Dock = Dock;
|
|
|
165
174
|
List.Pagination = Pagination;
|
|
166
175
|
List.Views = Views;
|
|
167
176
|
List.Metrics = Metrics;
|
|
177
|
+
List.Filters = Filters;
|
|
168
178
|
List.Rows = Rows;
|
|
169
179
|
List.Table = TableSlot;
|
|
170
180
|
List.Board = Board;
|
|
181
|
+
List.Tiles = Tiles;
|
|
171
182
|
List.Sheet = SheetSlot;
|
|
172
183
|
List.Report = Report;
|
|
173
184
|
List.Pivot = Pivot;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ListViewProps } from "./types.js";
|
|
2
|
-
export declare function ListView<T extends object>({ items, keyOf, identity, crumbs, embedded, surface: requestedSurface, metrics, search, pagination, views, actions: written, dock, row, rowHeader, columns, visibleColumnIds, onVisibleColumnIdsChange, card, boardStages, calendar, gantt, timeline, sheet, report, pivot, chart, faces, present: requested, presents, onPresentChange, sort, onSortChange, sortable, totals, rowActions, create, group, selection, onOpen, onPeek, openTargets, onOpenIn, rowClick, onChoose, state, filtered, empty, children, }: ListViewProps<T>): import("react").JSX.Element;
|
|
2
|
+
export declare function ListView<T extends object>({ items, keyOf, identity, crumbs, embedded, surface: requestedSurface, metrics, filters, search, pagination, views, actions: written, dock, row, rowHeader, columns, visibleColumnIds, onVisibleColumnIdsChange, card, tiles, boardStages, calendar, gantt, timeline, sheet, report, pivot, chart, faces, present: requested, presents, onPresentChange, sort, onSortChange, sortable, totals, rowActions, create, group, selection, onOpen, onPeek, openTargets, onOpenIn, rowClick, onChoose, state, filtered, empty, children, }: ListViewProps<T>): import("react").JSX.Element;
|
|
3
3
|
/** What a list offers when it fails and can be retried. */
|
|
4
4
|
export declare function RetryAction({ onRetry }: {
|
|
5
5
|
onRetry: () => void;
|
|
@@ -30,7 +30,7 @@ import { groupLevelsOf, reportColumnsOf, reportRowsOf, sheetFromColumns, sheetRo
|
|
|
30
30
|
import { SheetPresentation, TablePresentation, } from "./presentations.js";
|
|
31
31
|
import { useNarrowList } from "./useNarrowList.js";
|
|
32
32
|
import { useReachBottom } from "./useReachBottom.js";
|
|
33
|
-
import { CalendarDays, CalendarRange, ChartColumnBig, ChartGantt, Grid3x3, LayoutGrid, List, Sheet, Sigma, Table2, X, } from "lucide-react";
|
|
33
|
+
import { CalendarDays, CalendarRange, ChartColumnBig, ChartGantt, Grid3x3, LayoutGrid, List, Sheet, Sigma, SquareKanban, Table2, X, } from "lucide-react";
|
|
34
34
|
import { Fragment, lazy, Suspense, useCallback, useEffect, useMemo, } from "react";
|
|
35
35
|
import { createPortal } from "react-dom";
|
|
36
36
|
/* The calendar (FullCalendar) and the gantt (SVAR) are each about a third of a list's weight,
|
|
@@ -75,7 +75,8 @@ const ChartExplorer = lazy(() => import("../../components/listing/ChartExplorer.
|
|
|
75
75
|
const PRESENT_ICONS = [
|
|
76
76
|
{ id: "rows", icon: List },
|
|
77
77
|
{ id: "table", icon: Table2 },
|
|
78
|
-
{ id: "board", icon:
|
|
78
|
+
{ id: "board", icon: SquareKanban },
|
|
79
|
+
{ id: "tiles", icon: LayoutGrid },
|
|
79
80
|
{ id: "sheet", icon: Sheet },
|
|
80
81
|
/* The sigma and not a table icon: what sets a report apart from the other
|
|
81
82
|
four is that it SUMS. */
|
|
@@ -88,7 +89,7 @@ const PRESENT_ICONS = [
|
|
|
88
89
|
{ id: "gantt", icon: ChartGantt },
|
|
89
90
|
{ id: "timeline", icon: CalendarRange },
|
|
90
91
|
];
|
|
91
|
-
export function ListView({ items, keyOf, identity, crumbs, embedded = false, surface: requestedSurface, metrics, search, pagination, views, actions: written, dock, row, rowHeader, columns, visibleColumnIds, onVisibleColumnIdsChange, card, boardStages, calendar, gantt, timeline, sheet, report, pivot, chart, faces, present: requested = "rows", presents, onPresentChange, sort, onSortChange, sortable, totals = false, rowActions, create, group, selection, onOpen, onPeek, openTargets, onOpenIn, rowClick = "peek", onChoose, state, filtered = false, empty, children, }) {
|
|
92
|
+
export function ListView({ items, keyOf, identity, crumbs, embedded = false, surface: requestedSurface, metrics, filters, search, pagination, views, actions: written, dock, row, rowHeader, columns, visibleColumnIds, onVisibleColumnIdsChange, card, tiles, boardStages, calendar, gantt, timeline, sheet, report, pivot, chart, faces, present: requested = "rows", presents, onPresentChange, sort, onSortChange, sortable, totals = false, rowActions, create, group, selection, onOpen, onPeek, openTargets, onOpenIn, rowClick = "peek", onChoose, state, filtered = false, empty, children, }) {
|
|
92
93
|
const wide = useMemo(() => [
|
|
93
94
|
...WIDE_PRESENTS,
|
|
94
95
|
...(faces ?? []).filter((f) => f.wide === true).map((f) => f.id),
|
|
@@ -241,8 +242,13 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
|
|
|
241
242
|
/* THE COUNTERS, in the modern style, are mini stats under the bar — with the metrics, where a
|
|
242
243
|
list's numbers are read —, not words beside its trail, where they read as more crumbs. */
|
|
243
244
|
const statsBelow = modern && !embedded && density === "comfortable" && identity?.counters !== undefined;
|
|
244
|
-
const counterStats = !statsBelow || identity?.counters === undefined ? undefined : (_jsx(Metrics, { children: identity.counters.map((c) => (_jsx(Metric, { value: c.value, label: c.label }
|
|
245
|
-
|
|
245
|
+
const counterStats = !statsBelow || identity?.counters === undefined ? undefined : (_jsx(Metrics, { children: identity.counters.map((c) => (_jsx(Metric, { value: c.value, label: c.label, ...(c.tone === undefined ? {} : { tone: c.tone }), ...(c.onClick === undefined
|
|
246
|
+
? {}
|
|
247
|
+
: { onClick: c.onClick, active: c.active === true }) }, c.label))) }));
|
|
248
|
+
/* Under the bar, in the order they are used: the quick filters (what I narrow by), then
|
|
249
|
+
the counters and the metrics (what the set is made of). */
|
|
250
|
+
const statParts = [filters, counterStats, metrics].filter((part) => part !== undefined && part !== null);
|
|
251
|
+
const stats = statParts.length === 0 ? undefined : statParts.length === 1 ? (statParts[0]) : (_jsx("div", { className: "flex min-w-0 flex-col gap-2", children: statParts.map((part, at) => (_jsx(Fragment, { children: part }, at))) }));
|
|
246
252
|
const bar = !barHasControls ? undefined : (_jsx(ListingBar, { surface: surface, look: viewStyle, ...(embedded ? { inline: true, count: items.length } : {}), ...(embedded || crumbs === undefined || crumbs.length === 0 || density === "compact"
|
|
247
253
|
? {}
|
|
248
254
|
: {
|
|
@@ -377,6 +383,20 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
|
|
|
377
383
|
const d = row(item);
|
|
378
384
|
return (_jsx(RecordCard, { title: d.name, ...(d.tags === undefined ? {} : { tags: d.tags }), ...(d.meta === undefined ? {} : { meta: d.meta }), ...(press === undefined ? {} : { onOpen: () => press(item) }) }, keyOf(item)));
|
|
379
385
|
};
|
|
386
|
+
/* A tile is a card in its tile shape: the picture on top, pressed whole. Without a `card` of
|
|
387
|
+
its own, it is told by the row — its name, its meta, its chips, its icon. */
|
|
388
|
+
const renderTile = (item) => {
|
|
389
|
+
if (tiles?.card !== undefined) {
|
|
390
|
+
return _jsx(Fragment, { children: tiles.card(item, waysOf(item)) }, keyOf(item));
|
|
391
|
+
}
|
|
392
|
+
const d = row(item);
|
|
393
|
+
return (_jsx(RecordCard, { layout: "tile", title: d.name, ...(d.tags === undefined ? {} : { tags: d.tags }), ...(d.meta === undefined ? {} : { meta: d.meta }), ...(d.icon === undefined ? {} : { media: { icon: d.icon } }), ...(press === undefined ? {} : { onOpen: () => press(item) }) }, keyOf(item)));
|
|
394
|
+
};
|
|
395
|
+
const TILE_GRID = {
|
|
396
|
+
sm: "grid-cols-(--grid-tiles-sm)",
|
|
397
|
+
md: "grid-cols-(--grid-tiles-md)",
|
|
398
|
+
lg: "grid-cols-(--grid-tiles-lg)",
|
|
399
|
+
};
|
|
380
400
|
const body = face !== undefined ? (face.render({
|
|
381
401
|
items: ordered,
|
|
382
402
|
keyOf,
|
|
@@ -444,7 +464,7 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
|
|
|
444
464
|
? {}
|
|
445
465
|
: { defaultMeasures: chart.defaultMeasures }), ...(chart.stacked === undefined ? {} : { defaultStacked: chart.stacked }), ...(chart.cumulative === undefined
|
|
446
466
|
? {}
|
|
447
|
-
: { defaultCumulative: chart.cumulative }), ...(chart.order === undefined ? {} : { defaultOrder: chart.order }), ...(chart.compare === undefined ? {} : { compare: chart.compare }), ...((group?.levels.length ?? 0) > 0 ? { levels: group.levels } : {}), ...(chart.onPoint === undefined ? {} : { onPoint: chart.onPoint }), ...(chart.height === undefined ? {} : { height: chart.height }), ...(chart.fileName === undefined ? {} : { fileName: chart.fileName }), ...(identity?.title === undefined ? {} : { label: identity.title }) }) }) })) : present === "calendar" && calendar !== undefined ? (_jsx("div", { className: "p-3", children: _jsx(Suspense, { fallback: _jsx(Skeleton, { label: copy.failed.loading }), children: _jsx(RecordCalendar, { ...calendar, items: ordered, keyOf: keyOf, ...(press === undefined ? {} : { onOpen: press }) }) }) })) : present === "gantt" && gantt !== undefined ? (_jsx("div", { className: "p-3", children: _jsx(Suspense, { fallback: _jsx(Skeleton, { label: copy.failed.loading }), children: _jsx(RecordGantt, { ...gantt, items: ordered, keyOf: keyOf, ...(press === undefined ? {} : { onOpen: press }) }) }) })) : present === "timeline" && timeline !== undefined ? (_jsx("div", { className: "p-3", children: _jsx(RecordTimeline, { ...timeline, items: ordered, keyOf: keyOf, ...(press === undefined ? {} : { onOpen: press }) }) })) : present === "board" && boardStages !== undefined ? (_jsx(BoardColumns, { items: ordered, keyOf: keyOf, stages: boardStages, card: renderCard })) : present === "board" ? (_jsx("div", { className: "flex flex-col", children: wrapGroups((inside) => (_jsx("div", { className: "grid gap-3 p-3 @2xl:grid-cols-2 @5xl:grid-cols-3", children: inside.map(renderCard) }))) })) : (
|
|
467
|
+
: { defaultCumulative: chart.cumulative }), ...(chart.order === undefined ? {} : { defaultOrder: chart.order }), ...(chart.compare === undefined ? {} : { compare: chart.compare }), ...((group?.levels.length ?? 0) > 0 ? { levels: group.levels } : {}), ...(chart.onPoint === undefined ? {} : { onPoint: chart.onPoint }), ...(chart.height === undefined ? {} : { height: chart.height }), ...(chart.fileName === undefined ? {} : { fileName: chart.fileName }), ...(identity?.title === undefined ? {} : { label: identity.title }) }) }) })) : present === "calendar" && calendar !== undefined ? (_jsx("div", { className: "p-3", children: _jsx(Suspense, { fallback: _jsx(Skeleton, { label: copy.failed.loading }), children: _jsx(RecordCalendar, { ...calendar, items: ordered, keyOf: keyOf, ...(press === undefined ? {} : { onOpen: press }) }) }) })) : present === "gantt" && gantt !== undefined ? (_jsx("div", { className: "p-3", children: _jsx(Suspense, { fallback: _jsx(Skeleton, { label: copy.failed.loading }), children: _jsx(RecordGantt, { ...gantt, items: ordered, keyOf: keyOf, ...(press === undefined ? {} : { onOpen: press }) }) }) })) : present === "timeline" && timeline !== undefined ? (_jsx("div", { className: "p-3", children: _jsx(RecordTimeline, { ...timeline, items: ordered, keyOf: keyOf, ...(press === undefined ? {} : { onOpen: press }) }) })) : present === "tiles" ? (_jsx("div", { className: "flex flex-col", children: wrapGroups((inside) => (_jsx("div", { "data-ui": "list.tiles", className: `grid gap-3 p-3 ${TILE_GRID[tiles?.size ?? "md"]}`, children: inside.map(renderTile) }))) })) : present === "board" && boardStages !== undefined ? (_jsx(BoardColumns, { items: ordered, keyOf: keyOf, stages: boardStages, card: renderCard })) : present === "board" ? (_jsx("div", { className: "flex flex-col", children: wrapGroups((inside) => (_jsx("div", { className: "grid gap-3 p-3 @2xl:grid-cols-2 @5xl:grid-cols-3", children: inside.map(renderCard) }))) })) : (
|
|
448
468
|
/* The header goes BEFORE the buckets and not inside each one:
|
|
449
469
|
it labels the row, and the row is the same in all five buckets. */
|
|
450
470
|
_jsxs(_Fragment, { children: [rowHeader === undefined || items.length === 0 ? null : (_jsx(RowHeader, { name: rowHeader.name, ...(rowHeader.meta === undefined ? {} : { meta: rowHeader.meta }), ...(rowHeader.tags === undefined ? {} : { tags: rowHeader.tags }), withSelection: selection !== undefined,
|
|
@@ -307,6 +307,8 @@ export type ListViewProps<T extends object> = {
|
|
|
307
307
|
/** The metrics that also NARROW: «2 por confirmar», «41 por entregar». They go
|
|
308
308
|
* below the bar and above the rows — they belong to the set, not to the frame. */
|
|
309
309
|
metrics?: ReactNode;
|
|
310
|
+
/** The quick filters (`List.Filters`): a row under the bar, before the metrics. */
|
|
311
|
+
filters?: ReactNode;
|
|
310
312
|
/** The list is a FIELD of a record (a one2many / many2many) and not a screen: the bar
|
|
311
313
|
* is one line — search, count, sort, columns, switcher, actions —, it does not stick
|
|
312
314
|
* and it does not move into the frame's header. Identity and crumbs are not drawn: the
|
|
@@ -374,6 +376,11 @@ export type ListViewProps<T extends object> = {
|
|
|
374
376
|
card?: (item: T, ways: CardWays) => ReactNode;
|
|
375
377
|
/** The board by stages: one column each, cards moved between them. */
|
|
376
378
|
boardStages?: BoardStages<T>;
|
|
379
|
+
/** The tiles presentation: a grid of tiles, and the tile of one record. */
|
|
380
|
+
tiles?: {
|
|
381
|
+
card?: (item: T, ways: CardWays) => ReactNode;
|
|
382
|
+
size?: "sm" | "md" | "lg";
|
|
383
|
+
};
|
|
377
384
|
/** The calendar presentation: when each record happens. */
|
|
378
385
|
calendar?: ListCalendar<T>;
|
|
379
386
|
/** The Gantt presentation: each record as a span on a timeline. */
|
|
@@ -194,7 +194,7 @@ export function Record({ identity, error = null, dirty, placement, look: ownLook
|
|
|
194
194
|
shorter than the screen. The extra height has no paint of its own: on a desk
|
|
195
195
|
nothing changes. */
|
|
196
196
|
/* The record knows the notes of its fields and rows: their cards register here. */
|
|
197
|
-
_jsx(NoteRegistryContext, { value: registry, children: _jsx("article", { className: "flex min-w-0 flex-1 flex-col", children: _jsx(NotebookScope, { tabs: tabs.length > 0, children: _jsx(RecordHeader, { railSurface: surface, ...(placement === undefined ? {} : { paper: placement === "page" }), ...(ribbon === undefined
|
|
197
|
+
_jsx(NoteRegistryContext, { value: registry, children: _jsx("article", { className: "isolate flex min-w-0 flex-1 flex-col", children: _jsx(NotebookScope, { tabs: tabs.length > 0, children: _jsx(RecordHeader, { railSurface: surface, ...(placement === undefined ? {} : { paper: placement === "page" }), ...(ribbon === undefined
|
|
198
198
|
? {}
|
|
199
199
|
: {
|
|
200
200
|
ribbon: (_jsx(RecordRibbon, { label: ribbon.label, ...(ribbon.tone === undefined ? {} : { tone: ribbon.tone }) })),
|