@volvel/ui 0.0.0-stage → 0.7.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/LICENSE +202 -0
- package/THIRD_PARTY_NOTICES.md +23036 -0
- package/dist/Badge.d.ts +20 -0
- package/dist/Badge.js +35 -0
- package/dist/Button.d.ts +56 -0
- package/dist/Button.js +52 -0
- package/dist/Chart.d.ts +23 -0
- package/dist/Chart.js +98 -0
- package/dist/Combobox.d.ts +45 -0
- package/dist/Combobox.js +42 -0
- package/dist/ContextMenu.d.ts +16 -0
- package/dist/ContextMenu.js +38 -0
- package/dist/DateInput.d.ts +31 -0
- package/dist/DateInput.js +329 -0
- package/dist/Details.d.ts +12 -0
- package/dist/Details.js +9 -0
- package/dist/Dialog.d.ts +44 -0
- package/dist/Dialog.js +95 -0
- package/dist/Dialogs.d.ts +56 -0
- package/dist/Dialogs.js +95 -0
- package/dist/Doc.d.ts +25 -0
- package/dist/Doc.js +118 -0
- package/dist/DocServed.d.ts +6 -0
- package/dist/DocServed.js +154 -0
- package/dist/DocZoom.d.ts +11 -0
- package/dist/DocZoom.js +133 -0
- package/dist/Facts.d.ts +12 -0
- package/dist/Facts.js +10 -0
- package/dist/Fields.d.ts +184 -0
- package/dist/Fields.js +249 -0
- package/dist/Form.d.ts +47 -0
- package/dist/Form.js +189 -0
- package/dist/Grid.d.ts +118 -0
- package/dist/Grid.js +475 -0
- package/dist/HeadingSlot.d.ts +13 -0
- package/dist/HeadingSlot.js +19 -0
- package/dist/JsonView.d.ts +11 -0
- package/dist/JsonView.js +68 -0
- package/dist/LogViewer.d.ts +45 -0
- package/dist/LogViewer.js +299 -0
- package/dist/Markdown.d.ts +21 -0
- package/dist/Markdown.js +27 -0
- package/dist/MarkdownBody.d.ts +6 -0
- package/dist/MarkdownBody.js +14 -0
- package/dist/Menu.d.ts +29 -0
- package/dist/Menu.js +8 -0
- package/dist/MoveButtons.d.ts +19 -0
- package/dist/MoveButtons.js +22 -0
- package/dist/Notice.d.ts +47 -0
- package/dist/Notice.js +50 -0
- package/dist/PageShell.d.ts +42 -0
- package/dist/PageShell.js +14 -0
- package/dist/Pagination.d.ts +13 -0
- package/dist/Pagination.js +9 -0
- package/dist/Panel.d.ts +31 -0
- package/dist/Panel.js +33 -0
- package/dist/Pickers.d.ts +37 -0
- package/dist/Pickers.js +44 -0
- package/dist/Popover.d.ts +24 -0
- package/dist/Popover.js +12 -0
- package/dist/ResultView.d.ts +28 -0
- package/dist/ResultView.js +140 -0
- package/dist/SchemaForm.d.ts +45 -0
- package/dist/SchemaForm.js +626 -0
- package/dist/SideSheet.d.ts +31 -0
- package/dist/SideSheet.js +136 -0
- package/dist/Sparkline.d.ts +14 -0
- package/dist/Sparkline.js +23 -0
- package/dist/Surfaces.d.ts +30 -0
- package/dist/Surfaces.js +34 -0
- package/dist/Switch.d.ts +18 -0
- package/dist/Switch.js +11 -0
- package/dist/Table.d.ts +15 -0
- package/dist/Table.js +6 -0
- package/dist/Tabs.d.ts +32 -0
- package/dist/Tabs.js +11 -0
- package/dist/Term.d.ts +82 -0
- package/dist/Term.js +153 -0
- package/dist/Timeline.d.ts +29 -0
- package/dist/Timeline.js +39 -0
- package/dist/Toast.d.ts +43 -0
- package/dist/Toast.js +140 -0
- package/dist/Tooltip.d.ts +34 -0
- package/dist/Tooltip.js +70 -0
- package/dist/Tree.d.ts +51 -0
- package/dist/Tree.js +233 -0
- package/dist/chartEngine.d.ts +32 -0
- package/dist/chartEngine.js +72 -0
- package/dist/chartTheme.d.ts +41 -0
- package/dist/chartTheme.js +131 -0
- package/dist/contrast.d.ts +27 -0
- package/dist/contrast.js +110 -0
- package/dist/dates.d.ts +61 -0
- package/dist/dates.js +294 -0
- package/dist/drawer/Chips.d.ts +37 -0
- package/dist/drawer/Chips.js +32 -0
- package/dist/drawer/Choices.d.ts +47 -0
- package/dist/drawer/Choices.js +81 -0
- package/dist/drawer/Drawer.d.ts +125 -0
- package/dist/drawer/Drawer.js +150 -0
- package/dist/drawer/EditorBodies.d.ts +95 -0
- package/dist/drawer/EditorBodies.js +169 -0
- package/dist/drawer/NumberFormat.d.ts +36 -0
- package/dist/drawer/NumberFormat.js +98 -0
- package/dist/drawer/SortableRows.d.ts +35 -0
- package/dist/drawer/SortableRows.js +23 -0
- package/dist/drawer/edgeShadows.d.ts +7 -0
- package/dist/drawer/edgeShadows.js +17 -0
- package/dist/drawer/index.d.ts +8 -0
- package/dist/drawer/index.js +8 -0
- package/dist/drawer/useSortable.d.ts +53 -0
- package/dist/drawer/useSortable.js +323 -0
- package/dist/format.d.ts +6 -0
- package/dist/format.js +17 -0
- package/dist/icons.d.ts +20 -0
- package/dist/icons.js +16 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +48 -0
- package/dist/markdownKnowledge.d.ts +45 -0
- package/dist/markdownKnowledge.js +37 -0
- package/dist/overlay.d.ts +7 -0
- package/dist/overlay.js +10 -0
- package/dist/pageIcons.d.ts +12 -0
- package/dist/pageIcons.js +32 -0
- package/dist/presence.d.ts +41 -0
- package/dist/presence.js +108 -0
- package/dist/returnFocus.d.ts +9 -0
- package/dist/returnFocus.js +44 -0
- package/dist/tokens.css +437 -0
- package/dist/type-scale.css +34 -0
- package/dist/useFlip.d.ts +32 -0
- package/dist/useFlip.js +118 -0
- package/fonts/OFL.txt +193 -0
- package/fonts/geist-latin.woff2 +0 -0
- package/fonts/geist-mono-latin.woff2 +0 -0
- package/package.json +52 -3
- package/README.md +0 -3
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Dialog as Base } from "@base-ui/react/dialog";
|
|
3
|
+
import { X } from "lucide-react";
|
|
4
|
+
import { useEffect, useRef } from "react";
|
|
5
|
+
import { firstField } from "./Dialog.js";
|
|
6
|
+
import { InOverlay } from "./overlay.js";
|
|
7
|
+
import { useOpening } from "./presence.js";
|
|
8
|
+
import { useReturnFocus } from "./returnFocus.js";
|
|
9
|
+
import { CodeText } from "./Term.js";
|
|
10
|
+
const TABBABLE = 'a[href], button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"]), [contenteditable="true"]';
|
|
11
|
+
/** Whether the browser draws it, so that Tab can stop on it: not `display: none`, not `visibility: hidden`. */
|
|
12
|
+
function drawn(element) {
|
|
13
|
+
if (typeof element.checkVisibility === "function") {
|
|
14
|
+
return element.checkVisibility({ visibilityProperty: true });
|
|
15
|
+
}
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* What a person can reach with Tab inside `root`, in order: the same as the browser's own, so the
|
|
20
|
+
* first and last of them are where Tab really begins and ends. A hidden input, a control that is
|
|
21
|
+
* not drawn, and every radio of a group but the one that holds the group's stop are not among them.
|
|
22
|
+
*/
|
|
23
|
+
function tabbables(root) {
|
|
24
|
+
const found = [...root.querySelectorAll(TABBABLE)].filter((one) => !one.matches(":disabled") &&
|
|
25
|
+
one.getAttribute("tabindex") !== "-1" &&
|
|
26
|
+
!one.closest("[hidden], [inert], fieldset:disabled") &&
|
|
27
|
+
one.getAttribute("aria-hidden") !== "true" &&
|
|
28
|
+
!(one instanceof HTMLInputElement && one.type === "hidden") &&
|
|
29
|
+
drawn(one));
|
|
30
|
+
return found.filter((one) => {
|
|
31
|
+
if (!(one instanceof HTMLInputElement) || one.type !== "radio" || !one.name)
|
|
32
|
+
return true;
|
|
33
|
+
const group = found.filter((other) => other instanceof HTMLInputElement &&
|
|
34
|
+
other.type === "radio" &&
|
|
35
|
+
other.name === one.name &&
|
|
36
|
+
other.form === one.form);
|
|
37
|
+
const stop = group.find((other) => other.checked) ?? group[0];
|
|
38
|
+
return one === stop;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Tab and Shift+Tab stay in the sheet: from its last control to its first, and back. The page
|
|
43
|
+
* beneath is not reached, whatever the sheet holds (fields, a picker, a footer).
|
|
44
|
+
*/
|
|
45
|
+
function keepTabInside(event) {
|
|
46
|
+
if (event.key !== "Tab" || event.defaultPrevented)
|
|
47
|
+
return;
|
|
48
|
+
const root = event.currentTarget;
|
|
49
|
+
const all = tabbables(root);
|
|
50
|
+
const first = all[0];
|
|
51
|
+
const last = all.at(-1);
|
|
52
|
+
if (!first || !last) {
|
|
53
|
+
event.preventDefault();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const at = document.activeElement;
|
|
57
|
+
if (event.shiftKey && (at === first || at === root || !root.contains(at))) {
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
last.focus();
|
|
60
|
+
}
|
|
61
|
+
else if (!event.shiftKey && (at === last || !root.contains(at))) {
|
|
62
|
+
event.preventDefault();
|
|
63
|
+
first.focus();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* What keeps Tab in the sheet when the list above and the browser part: a stop the sheet did not
|
|
68
|
+
* know of. Focus that lands on the page behind it, on the body or on a focus guard, right after a
|
|
69
|
+
* Tab, goes back to the sheet's first control (Shift+Tab: its last). Focus that goes into
|
|
70
|
+
* another layer the sheet opened, such as a menu or a picker, is left alone.
|
|
71
|
+
*/
|
|
72
|
+
function useKeepFocusInside(open, popup) {
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (!open)
|
|
75
|
+
return;
|
|
76
|
+
let tabbed;
|
|
77
|
+
const noteTab = (event) => {
|
|
78
|
+
if (event.key === "Tab")
|
|
79
|
+
tabbed = { shift: event.shiftKey, at: Date.now() };
|
|
80
|
+
};
|
|
81
|
+
const onFocus = (event) => {
|
|
82
|
+
const root = popup.current;
|
|
83
|
+
const target = event.target;
|
|
84
|
+
if (!root || !(target instanceof HTMLElement) || root.contains(target))
|
|
85
|
+
return;
|
|
86
|
+
if (!tabbed || Date.now() - tabbed.at > 500)
|
|
87
|
+
return;
|
|
88
|
+
const page = target === document.body ||
|
|
89
|
+
target === document.documentElement ||
|
|
90
|
+
target.hasAttribute("data-base-ui-focus-guard") ||
|
|
91
|
+
!target.closest('[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], [role="tooltip"], [data-base-ui-portal]');
|
|
92
|
+
if (!page)
|
|
93
|
+
return;
|
|
94
|
+
const all = tabbables(root);
|
|
95
|
+
(tabbed.shift ? all.at(-1) : all[0])?.focus();
|
|
96
|
+
};
|
|
97
|
+
document.addEventListener("keydown", noteTab, true);
|
|
98
|
+
document.addEventListener("focusin", onFocus, true);
|
|
99
|
+
return () => {
|
|
100
|
+
document.removeEventListener("keydown", noteTab, true);
|
|
101
|
+
document.removeEventListener("focusin", onFocus, true);
|
|
102
|
+
};
|
|
103
|
+
}, [open, popup]);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* A panel that slides over the right of the screen, for work that needs more
|
|
107
|
+
* room than a dialog and should keep the page beneath in view. On a phone it
|
|
108
|
+
* takes the whole screen. Escape and the backdrop close it, and focus goes
|
|
109
|
+
* back to what opened it.
|
|
110
|
+
*/
|
|
111
|
+
export function SideSheet({ open, onClose, title, description, icon, footer, size = "regular", width: chosen, side = "right", returnFocus, children, }) {
|
|
112
|
+
const width = size === "wide"
|
|
113
|
+
? "sm:w-[min(44rem,92vw)]"
|
|
114
|
+
: size === "narrow"
|
|
115
|
+
? "sm:w-[min(20rem,92vw)]"
|
|
116
|
+
: "sm:w-[min(30rem,92vw)]";
|
|
117
|
+
const shown = useOpening(open);
|
|
118
|
+
const popup = useRef(null);
|
|
119
|
+
const opener = useReturnFocus(open);
|
|
120
|
+
useKeepFocusInside(shown, popup);
|
|
121
|
+
return (_jsx(InOverlay.Provider, { value: true, children: _jsx(Base.Root, { open: shown, onOpenChange: (next) => !next && onClose(), children: _jsxs(Base.Portal, { children: [_jsx(Base.Backdrop, { className: "fixed inset-0 layer-sheet bg-scrim transition-opacity motion-slow data-[ending-style]:opacity-0 data-[starting-style]:opacity-0" }), _jsxs(Base.Popup, { ref: popup, onKeyDown: keepTabInside,
|
|
122
|
+
// As a dialog does: what marks itself `data-autofocus`, else the first field to type in
|
|
123
|
+
// or choose from, else the first control. A form does not open with Enter on Close.
|
|
124
|
+
initialFocus: () => popup.current?.querySelector("[data-autofocus]") ??
|
|
125
|
+
firstField(popup.current) ??
|
|
126
|
+
true, finalFocus: () => returnFocus?.() ?? opener(), className: `fixed inset-y-0 layer-sheet flex w-full flex-col border-line bg-surface shadow-modal transition-transform motion-slow ${side === "left"
|
|
127
|
+
? "left-0 sm:border-r data-[ending-style]:-translate-x-full data-[starting-style]:-translate-x-full"
|
|
128
|
+
: "right-0 sm:border-l data-[ending-style]:translate-x-full data-[starting-style]:translate-x-full"} ${width}`, ...(chosen !== undefined
|
|
129
|
+
? {
|
|
130
|
+
style: {
|
|
131
|
+
width: chosen === "full" ? "calc(100vw - 2rem)" : `${chosen}px`,
|
|
132
|
+
maxWidth: "100vw",
|
|
133
|
+
},
|
|
134
|
+
}
|
|
135
|
+
: {}), children: [_jsxs("div", { className: "flex items-center justify-between gap-3 border-line border-b px-5 py-3", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-3", children: [icon ? (_jsx("span", { "aria-hidden": "true", className: "flex size-8 shrink-0 items-center justify-center rounded-control border border-action/30 bg-action-soft text-action", children: icon })) : null, _jsxs("div", { className: "flex min-w-0 flex-col", children: [_jsx(Base.Title, { className: "m-0 text-title font-semibold", children: title }), description ? (_jsx(Base.Description, { className: "m-0 text-meta text-ink-muted", children: typeof description === "string" ? (_jsx(CodeText, { children: description })) : (description) })) : null] })] }), _jsx(Base.Close, { "aria-label": "Close", className: "flex size-8 shrink-0 items-center justify-center rounded-control text-ink-muted hover:bg-hover hover:text-ink", children: _jsx(X, { "aria-hidden": "true", size: 16 }) })] }), _jsx("div", { className: "min-h-0 flex-1 overflow-y-auto px-5 py-4", children: children }), footer ? (_jsx("div", { className: "flex flex-wrap items-center justify-end gap-2 border-line border-t px-5 py-3", children: footer })) : null] })] }) }) }));
|
|
136
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A number over time as one small line, with no axes: for under a figure,
|
|
3
|
+
* where the shape matters and the values are read elsewhere. It takes the
|
|
4
|
+
* color of the text around it. To a screen reader it is a picture with
|
|
5
|
+
* `label` as its words, so the label says what the line shows: "Loans over
|
|
6
|
+
* the last 12 weeks: from 18 to 31, lowest 12, highest 46".
|
|
7
|
+
*/
|
|
8
|
+
export declare function Sparkline({ values, label, height, className, }: {
|
|
9
|
+
values: readonly number[];
|
|
10
|
+
label: string;
|
|
11
|
+
/** In pixels. It is as wide as what it is in. */
|
|
12
|
+
height?: number;
|
|
13
|
+
className?: string;
|
|
14
|
+
}): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* A number over time as one small line, with no axes: for under a figure,
|
|
4
|
+
* where the shape matters and the values are read elsewhere. It takes the
|
|
5
|
+
* color of the text around it. To a screen reader it is a picture with
|
|
6
|
+
* `label` as its words, so the label says what the line shows: "Loans over
|
|
7
|
+
* the last 12 weeks: from 18 to 31, lowest 12, highest 46".
|
|
8
|
+
*/
|
|
9
|
+
export function Sparkline({ values, label, height = 32, className = "", }) {
|
|
10
|
+
if (values.length < 2)
|
|
11
|
+
return null;
|
|
12
|
+
const low = Math.min(...values);
|
|
13
|
+
const high = Math.max(...values);
|
|
14
|
+
const span = high - low || 1;
|
|
15
|
+
// Drawn in a box 100 wide and stretched to its width; the stroke keeps its own thickness.
|
|
16
|
+
const points = values.map((value, at) => {
|
|
17
|
+
const x = (at / (values.length - 1)) * 100;
|
|
18
|
+
// A little room above and below, so the line's thickness is not cut at its extremes.
|
|
19
|
+
const y = 2 + (1 - (value - low) / span) * (height - 4);
|
|
20
|
+
return `${x.toFixed(2)},${y.toFixed(2)}`;
|
|
21
|
+
});
|
|
22
|
+
return (_jsx("svg", { role: "img", "aria-label": label, viewBox: `0 0 100 ${height}`, preserveAspectRatio: "none", width: "100%", height: height, className: `block overflow-visible ${className}`, children: _jsx("polyline", { points: points.join(" "), fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinejoin: "round", strokeLinecap: "round", vectorEffect: "non-scaling-stroke" }) }));
|
|
23
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
declare const AVATAR_SIZES: {
|
|
2
|
+
small: string;
|
|
3
|
+
regular: string;
|
|
4
|
+
large: string;
|
|
5
|
+
};
|
|
6
|
+
/** The first letters of a name's first and last words, for an avatar. */
|
|
7
|
+
export declare function initialsOf(name: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* A person or a thing, as a picture or as the initials of its name. The name
|
|
10
|
+
* is its accessible label; mark it `decorative` when the name is written beside it.
|
|
11
|
+
*/
|
|
12
|
+
export declare function Avatar({ name, src, size, decorative, }: {
|
|
13
|
+
name: string;
|
|
14
|
+
src?: string | null;
|
|
15
|
+
size?: keyof typeof AVATAR_SIZES;
|
|
16
|
+
decorative?: boolean;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
18
|
+
/**
|
|
19
|
+
* A gray placeholder where something is loading, in the shape of what will be
|
|
20
|
+
* there. Several lines of text are drawn with `lines`. It pulses unless the
|
|
21
|
+
* person asked for less motion.
|
|
22
|
+
*/
|
|
23
|
+
export declare function Skeleton({ lines, className, label, }: {
|
|
24
|
+
lines?: number;
|
|
25
|
+
/** Sets the shape: `h-24 w-full` for a card, `size-9 rounded-full` for an avatar. */
|
|
26
|
+
className?: string;
|
|
27
|
+
/** Read out once in place of the shapes. */
|
|
28
|
+
label?: string;
|
|
29
|
+
}): import("react").JSX.Element;
|
|
30
|
+
export {};
|
package/dist/Surfaces.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
const AVATAR_SIZES = {
|
|
3
|
+
small: "size-7 text-meta",
|
|
4
|
+
regular: "size-9 text-body",
|
|
5
|
+
large: "size-12 text-emphasis",
|
|
6
|
+
};
|
|
7
|
+
/** The first letters of a name's first and last words, for an avatar. */
|
|
8
|
+
export function initialsOf(name) {
|
|
9
|
+
const words = name.trim().split(/\s+/).filter(Boolean);
|
|
10
|
+
if (words.length === 0)
|
|
11
|
+
return "?";
|
|
12
|
+
const first = words[0]?.[0] ?? "";
|
|
13
|
+
const last = words.length > 1 ? (words[words.length - 1]?.[0] ?? "") : "";
|
|
14
|
+
return (first + last).toUpperCase();
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A person or a thing, as a picture or as the initials of its name. The name
|
|
18
|
+
* is its accessible label; mark it `decorative` when the name is written beside it.
|
|
19
|
+
*/
|
|
20
|
+
export function Avatar({ name, src, size = "regular", decorative = false, }) {
|
|
21
|
+
const box = `inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full ${AVATAR_SIZES[size]}`;
|
|
22
|
+
if (src) {
|
|
23
|
+
return _jsx("img", { src: src, alt: decorative ? "" : name, className: `${box} object-cover` });
|
|
24
|
+
}
|
|
25
|
+
return (_jsx("span", { ...(decorative ? { "aria-hidden": true } : { role: "img", "aria-label": name }), className: `${box} bg-action-soft font-semibold text-action`, children: initialsOf(name) }));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A gray placeholder where something is loading, in the shape of what will be
|
|
29
|
+
* there. Several lines of text are drawn with `lines`. It pulses unless the
|
|
30
|
+
* person asked for less motion.
|
|
31
|
+
*/
|
|
32
|
+
export function Skeleton({ lines = 1, className = "", label = "Loading", }) {
|
|
33
|
+
return (_jsx("div", { role: "status", "aria-label": label, className: "flex flex-col gap-2", children: Array.from({ length: Math.max(1, lines) }, (_, index) => (_jsx("div", { "aria-hidden": "true", className: `animate-pulse rounded-control bg-sunken motion-reduce:animate-none ${className || (index === lines - 1 && lines > 1 ? "h-4 w-2/3" : "h-4 w-full")}` }, index))) }));
|
|
34
|
+
}
|
package/dist/Switch.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* The boards' pill toggle: an on-or-off setting that takes effect as it is
|
|
4
|
+
* pressed ("Full width", "Stored in cents"). The label sits before it, so the
|
|
5
|
+
* whole row reads as one line, and can be pressed too. Use a checkbox for a
|
|
6
|
+
* choice that is made with a form's Save.
|
|
7
|
+
*/
|
|
8
|
+
export declare function Switch({ label, hint, checked, onChange, disabled, name, labelHidden, }: {
|
|
9
|
+
label: ReactNode;
|
|
10
|
+
/** A line under the label that says what on means. */
|
|
11
|
+
hint?: ReactNode;
|
|
12
|
+
checked: boolean;
|
|
13
|
+
onChange: (checked: boolean) => void;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
name?: string;
|
|
16
|
+
/** The label names it for screen readers only, for a row that already says what it is. */
|
|
17
|
+
labelHidden?: boolean;
|
|
18
|
+
}): import("react").JSX.Element;
|
package/dist/Switch.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Switch as Base } from "@base-ui/react/switch";
|
|
3
|
+
/**
|
|
4
|
+
* The boards' pill toggle: an on-or-off setting that takes effect as it is
|
|
5
|
+
* pressed ("Full width", "Stored in cents"). The label sits before it, so the
|
|
6
|
+
* whole row reads as one line, and can be pressed too. Use a checkbox for a
|
|
7
|
+
* choice that is made with a form's Save.
|
|
8
|
+
*/
|
|
9
|
+
export function Switch({ label, hint, checked, onChange, disabled, name, labelHidden = false, }) {
|
|
10
|
+
return (_jsxs("label", { className: "flex cursor-pointer items-center justify-between gap-3 has-[:disabled]:cursor-default has-[:disabled]:opacity-60", children: [_jsxs("span", { className: labelHidden ? "sr-only" : "flex min-w-0 flex-col", children: [_jsx("span", { className: "text-body-sm text-ink", children: label }), hint ? _jsx("span", { className: "text-meta text-ink-muted", children: hint }) : null] }), _jsx(Base.Root, { checked: checked, ...(disabled === undefined ? {} : { disabled }), ...(name === undefined ? {} : { name }), onCheckedChange: (next) => onChange(next), className: "relative h-5 w-9 shrink-0 rounded-full border border-line-strong bg-raised transition-colors motion-fast data-[checked]:border-transparent data-[checked]:bg-action", children: _jsx(Base.Thumb, { className: "block size-3.5 translate-x-0.5 rounded-full bg-ink-muted transition-transform motion-fast data-[checked]:translate-x-[18px] data-[checked]:bg-action-ink" }) })] }));
|
|
11
|
+
}
|
package/dist/Table.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface Column<Row> {
|
|
3
|
+
header: string;
|
|
4
|
+
cell: (row: Row) => ReactNode;
|
|
5
|
+
/** Right-align numbers and row actions. */
|
|
6
|
+
align?: "end";
|
|
7
|
+
}
|
|
8
|
+
export interface TableProps<Row> {
|
|
9
|
+
columns: Column<Row>[];
|
|
10
|
+
rows: Row[];
|
|
11
|
+
rowKey: (row: Row) => string;
|
|
12
|
+
/** Shown instead of the table when there are no rows. */
|
|
13
|
+
empty: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export declare function Table<Row>({ columns, rows, rowKey, empty }: TableProps<Row>): import("react").JSX.Element;
|
package/dist/Table.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export function Table({ columns, rows, rowKey, empty }) {
|
|
3
|
+
if (rows.length === 0)
|
|
4
|
+
return _jsx(_Fragment, { children: empty });
|
|
5
|
+
return (_jsx("div", { className: "overflow-x-auto rounded-panel border border-line bg-surface", children: _jsxs("table", { className: "w-full border-collapse text-left", children: [_jsx("thead", { children: _jsx("tr", { children: columns.map((column, index) => (_jsx("th", { scope: "col", className: `whitespace-nowrap border-b border-line px-3 py-2 text-body-sm font-medium text-ink-muted ${column.align === "end" ? "text-right" : ""}`, children: column.header }, index))) }) }), _jsx("tbody", { children: rows.map((row) => (_jsx("tr", { className: "border-b border-line last:border-b-0", children: columns.map((column, index) => (_jsx("td", { className: `px-3 py-2 align-middle ${column.align === "end" ? "text-right" : ""}`, children: column.cell(row) }, index))) }, rowKey(row)))) })] }) }));
|
|
6
|
+
}
|
package/dist/Tabs.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface TabItem {
|
|
3
|
+
/** Identifies the tab in `value` and `onChange`. */
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
content: ReactNode;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
/** A dot after the label: something in this tab needs fixing, said in these words. No dot otherwise. */
|
|
9
|
+
attention?: string;
|
|
10
|
+
/** A small drawing before the label: a page's icon in the menu. */
|
|
11
|
+
icon?: ReactNode;
|
|
12
|
+
/** A count after the label. */
|
|
13
|
+
count?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface TabsProps {
|
|
16
|
+
/** Names the row of tabs for screen readers: "Order sections". */
|
|
17
|
+
label: string;
|
|
18
|
+
tabs: TabItem[];
|
|
19
|
+
/** The open tab. Leave it out to let the tabs keep track themselves, starting at the first. */
|
|
20
|
+
value?: string;
|
|
21
|
+
onChange?: (id: string) => void;
|
|
22
|
+
/** Tighter tabs for a narrow panel (an inspector), so a row of four fits without scrolling. */
|
|
23
|
+
dense?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* `underline` is a row of words with a line under the open one. `pills` is the
|
|
26
|
+
* boards' segmented bar: a dark track, the open tab raised in it, the tabs
|
|
27
|
+
* sharing its width.
|
|
28
|
+
*/
|
|
29
|
+
variant?: "underline" | "pills";
|
|
30
|
+
}
|
|
31
|
+
/** Sections of one page, one visible at a time. The arrow keys move between the tabs. */
|
|
32
|
+
export declare function Tabs({ label, tabs, value, onChange, dense, variant, }: TabsProps): import("react").JSX.Element;
|
package/dist/Tabs.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Tabs as Base } from "@base-ui/react/tabs";
|
|
3
|
+
/** Sections of one page, one visible at a time. The arrow keys move between the tabs. */
|
|
4
|
+
export function Tabs({ label, tabs, value, onChange, dense = false, variant = "underline", }) {
|
|
5
|
+
const pills = variant === "pills";
|
|
6
|
+
return (_jsxs(Base.Root, { ...(value === undefined ? { defaultValue: tabs[0]?.id } : { value }), onValueChange: (next) => onChange?.(next), children: [_jsx(Base.List, { "aria-label": label, className: pills
|
|
7
|
+
? "grid auto-cols-fr grid-flow-col gap-0.5 overflow-x-auto rounded-control border border-line bg-track p-1"
|
|
8
|
+
: `flex ${dense ? "gap-0" : "gap-1"} overflow-x-auto border-b border-line`, children: tabs.map((tab) => (_jsxs(Base.Tab, { value: tab.id, disabled: tab.disabled === true, className: pills
|
|
9
|
+
? "inline-flex h-7 items-center justify-center gap-1.5 rounded-inner px-2 text-body-sm font-medium whitespace-nowrap text-ink-muted hover:text-ink data-[active]:bg-raised data-[active]:text-ink data-[active]:shadow-[0_0_0_1px_var(--vx-line-strong)] forced-colors:data-[active]:underline forced-colors:data-[active]:underline-offset-4 data-[disabled]:opacity-50"
|
|
10
|
+
: `-mb-px border-b-2 border-transparent forced-colors:border-[Canvas] ${dense ? "px-2 text-body-sm" : "px-3"} py-2 font-medium whitespace-nowrap text-ink-muted hover:text-ink data-[active]:border-action data-[active]:text-action forced-colors:data-[active]:border-[Highlight] forced-colors:data-[active]:underline forced-colors:data-[active]:underline-offset-4 data-[disabled]:opacity-50`, children: [tab.icon ? (_jsx("span", { "aria-hidden": "true", className: "mr-1.5 inline-flex shrink-0 align-text-bottom", children: tab.icon })) : null, tab.label, tab.count !== undefined ? (_jsx("span", { className: "text-meta text-ink-subtle tabular-nums", children: tab.count })) : null, tab.attention ? (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", "data-attention": "", className: "size-1.5 rounded-full bg-attention" }), _jsxs("span", { className: "sr-only", children: [", needs fixing: ", tab.attention] })] })) : null] }, tab.id))) }), tabs.map((tab) => (_jsx(Base.Panel, { value: tab.id, className: pills ? "pt-3" : "pt-4", children: tab.content }, tab.id)))] }));
|
|
11
|
+
}
|
package/dist/Term.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* A few words behind a small ⓘ, for a field or a heading that needs saying
|
|
4
|
+
* more about. It opens when pressed and stays until Escape or a click away,
|
|
5
|
+
* so what it says can be read at any pace and can hold a link, which a
|
|
6
|
+
* tooltip cannot.
|
|
7
|
+
*/
|
|
8
|
+
export declare function Toggletip({ label, title, children, side, }: {
|
|
9
|
+
/** What the button is for, read aloud: "About the schedule's timezone". */
|
|
10
|
+
label: string;
|
|
11
|
+
/** Heads the panel. */
|
|
12
|
+
title: string;
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
side?: "top" | "bottom" | "left" | "right";
|
|
15
|
+
}): import("react").JSX.Element;
|
|
16
|
+
/**
|
|
17
|
+
* Put around one screen. Inside it a term is underlined where it is first
|
|
18
|
+
* used and is plain words after that, so a page that says "workspace" ten
|
|
19
|
+
* times is not ten links.
|
|
20
|
+
*/
|
|
21
|
+
export declare function TermScope({ children }: {
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
}): import("react").JSX.Element;
|
|
24
|
+
/**
|
|
25
|
+
* A word with its meaning behind it. Pressing it, or Enter or Space on it,
|
|
26
|
+
* opens what it means. Escape closes that and puts focus back on the word.
|
|
27
|
+
*/
|
|
28
|
+
export declare function Term({ id, word, short, more, children, }: {
|
|
29
|
+
/** The term's id. Within a `TermScope`, only its first use is underlined. */
|
|
30
|
+
id?: string;
|
|
31
|
+
/** The term as plain text, to name the panel. */
|
|
32
|
+
word: string;
|
|
33
|
+
/** What it means. With neither this nor `more`, the word is drawn alone. */
|
|
34
|
+
short?: ReactNode;
|
|
35
|
+
/** A link or a button to read more, put after the meaning. */
|
|
36
|
+
more?: ReactNode;
|
|
37
|
+
children: ReactNode;
|
|
38
|
+
}): import("react").JSX.Element;
|
|
39
|
+
/** A word the people of a workspace use, and what they mean by it. */
|
|
40
|
+
export interface GlossaryTerm {
|
|
41
|
+
id: string;
|
|
42
|
+
/** The term as it is written in text. */
|
|
43
|
+
term: string;
|
|
44
|
+
/** Other ways it is written. */
|
|
45
|
+
aliases?: readonly string[];
|
|
46
|
+
/** What it means, in plain text. */
|
|
47
|
+
short: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Gives a screen its glossary. Inside it, `TermText` underlines a term where
|
|
51
|
+
* a label first uses it. It is also a `TermScope`, so a term met again further
|
|
52
|
+
* down the same screen is plain words.
|
|
53
|
+
*
|
|
54
|
+
* A term is matched as whole words, whatever its capitals, and the longest
|
|
55
|
+
* term that fits wins: "dev workspace" before "workspace".
|
|
56
|
+
*/
|
|
57
|
+
export declare function GlossaryProvider({ terms, more, children, }: {
|
|
58
|
+
terms: readonly GlossaryTerm[];
|
|
59
|
+
/** Draws the way to read more about a term, when there is somewhere to. */
|
|
60
|
+
more?: (term: GlossaryTerm) => ReactNode;
|
|
61
|
+
children: ReactNode;
|
|
62
|
+
}): import("react").JSX.Element;
|
|
63
|
+
/**
|
|
64
|
+
* The first term of the glossary that a piece of text uses, if any. For a
|
|
65
|
+
* label that cannot hold a button of its own, such as one that is already a
|
|
66
|
+
* button: what the term means is then said beside it.
|
|
67
|
+
*/
|
|
68
|
+
export declare function useGlossaryMatch(text: string): GlossaryTerm | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Text that names things: a column's heading, a resource's title, a
|
|
71
|
+
* description. Where it uses a term of the glossary around it, the term says
|
|
72
|
+
* what it means. Never put around a value from a row, or around free text:
|
|
73
|
+
* a common word would light up down a whole column, and in data it may mean
|
|
74
|
+
* something else.
|
|
75
|
+
*/
|
|
76
|
+
export declare function TermText({ children }: {
|
|
77
|
+
children: string;
|
|
78
|
+
}): import("react").JSX.Element;
|
|
79
|
+
/** Text whose names between backticks are set as code, without the glossary. For a dialog's words. */
|
|
80
|
+
export declare function CodeText({ children }: {
|
|
81
|
+
children: string;
|
|
82
|
+
}): import("react").JSX.Element;
|
package/dist/Term.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Info } from "lucide-react";
|
|
3
|
+
import { createContext, useContext, useEffect, useId, useMemo, useRef, } from "react";
|
|
4
|
+
import { ICON, STROKE } from "./icons.js";
|
|
5
|
+
import { Popover } from "./Popover.js";
|
|
6
|
+
/**
|
|
7
|
+
* A few words behind a small ⓘ, for a field or a heading that needs saying
|
|
8
|
+
* more about. It opens when pressed and stays until Escape or a click away,
|
|
9
|
+
* so what it says can be read at any pace and can hold a link, which a
|
|
10
|
+
* tooltip cannot.
|
|
11
|
+
*/
|
|
12
|
+
export function Toggletip({ label, title, children, side = "top", }) {
|
|
13
|
+
return (_jsx(Popover, { title: title, side: side, trigger: _jsx("button", { type: "button", "aria-label": label, className: "inline-flex size-5 items-center justify-center rounded-inner align-middle text-ink-muted hover:text-ink", children: _jsx(Info, { size: ICON.sm, strokeWidth: STROKE, "aria-hidden": true }) }), children: children }));
|
|
14
|
+
}
|
|
15
|
+
const Scope = createContext(null);
|
|
16
|
+
/**
|
|
17
|
+
* Put around one screen. Inside it a term is underlined where it is first
|
|
18
|
+
* used and is plain words after that, so a page that says "workspace" ten
|
|
19
|
+
* times is not ten links.
|
|
20
|
+
*/
|
|
21
|
+
export function TermScope({ children }) {
|
|
22
|
+
const seen = useMemo(() => new Map(), []);
|
|
23
|
+
return _jsx(Scope.Provider, { value: seen, children: children });
|
|
24
|
+
}
|
|
25
|
+
/** Whether this is the first use of a term in the scope around it. With no scope, every use is. */
|
|
26
|
+
function useFirstUse(id) {
|
|
27
|
+
const seen = useContext(Scope);
|
|
28
|
+
const owner = useId();
|
|
29
|
+
const claimed = useRef(false);
|
|
30
|
+
if (seen && id !== undefined && !seen.has(id)) {
|
|
31
|
+
seen.set(id, owner);
|
|
32
|
+
claimed.current = true;
|
|
33
|
+
}
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (!seen || id === undefined)
|
|
36
|
+
return;
|
|
37
|
+
if (!seen.has(id))
|
|
38
|
+
seen.set(id, owner);
|
|
39
|
+
return () => {
|
|
40
|
+
if (seen.get(id) === owner)
|
|
41
|
+
seen.delete(id);
|
|
42
|
+
};
|
|
43
|
+
}, [seen, id, owner]);
|
|
44
|
+
return !seen || id === undefined || seen.get(id) === owner;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A word with its meaning behind it. Pressing it, or Enter or Space on it,
|
|
48
|
+
* opens what it means. Escape closes that and puts focus back on the word.
|
|
49
|
+
*/
|
|
50
|
+
export function Term({ id, word, short, more, children, }) {
|
|
51
|
+
const first = useFirstUse(id);
|
|
52
|
+
if (!first || (!short && !more))
|
|
53
|
+
return _jsx(_Fragment, { children: children });
|
|
54
|
+
return (_jsxs(Popover, { title: word, trigger: _jsx("button", { type: "button", "data-term": id,
|
|
55
|
+
// A term may sit in a heading that sorts or a row that opens. Pressing the term does neither.
|
|
56
|
+
onClick: (event) => event.stopPropagation(), className: "cursor-help rounded-inner underline decoration-dotted underline-offset-[3px]", children: children }), children: [short, more ? _jsx("div", { className: short ? "mt-2" : "", children: more }) : null] }));
|
|
57
|
+
}
|
|
58
|
+
const GlossaryContext = createContext(null);
|
|
59
|
+
const escaped = (word) => word.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
60
|
+
/**
|
|
61
|
+
* Gives a screen its glossary. Inside it, `TermText` underlines a term where
|
|
62
|
+
* a label first uses it. It is also a `TermScope`, so a term met again further
|
|
63
|
+
* down the same screen is plain words.
|
|
64
|
+
*
|
|
65
|
+
* A term is matched as whole words, whatever its capitals, and the longest
|
|
66
|
+
* term that fits wins: "dev workspace" before "workspace".
|
|
67
|
+
*/
|
|
68
|
+
export function GlossaryProvider({ terms, more, children, }) {
|
|
69
|
+
const glossary = useMemo(() => {
|
|
70
|
+
const byWord = new Map();
|
|
71
|
+
for (const term of terms) {
|
|
72
|
+
for (const word of [term.term, ...(term.aliases ?? [])]) {
|
|
73
|
+
const key = word.trim().toLowerCase();
|
|
74
|
+
if (key !== "" && !byWord.has(key))
|
|
75
|
+
byWord.set(key, term);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const words = [...byWord.keys()].sort((a, b) => b.length - a.length);
|
|
79
|
+
return {
|
|
80
|
+
byWord,
|
|
81
|
+
more,
|
|
82
|
+
find: words.length === 0
|
|
83
|
+
? null
|
|
84
|
+
: new RegExp(`(?<![\\p{L}\\p{N}])(${words.map(escaped).join("|")})(?![\\p{L}\\p{N}])`, "giu"),
|
|
85
|
+
};
|
|
86
|
+
}, [terms, more]);
|
|
87
|
+
return (_jsx(GlossaryContext.Provider, { value: glossary, children: _jsx(TermScope, { children: children }) }));
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The first term of the glossary that a piece of text uses, if any. For a
|
|
91
|
+
* label that cannot hold a button of its own, such as one that is already a
|
|
92
|
+
* button: what the term means is then said beside it.
|
|
93
|
+
*/
|
|
94
|
+
export function useGlossaryMatch(text) {
|
|
95
|
+
const glossary = useContext(GlossaryContext);
|
|
96
|
+
if (!glossary?.find)
|
|
97
|
+
return undefined;
|
|
98
|
+
for (const match of text.matchAll(glossary.find)) {
|
|
99
|
+
const term = glossary.byWord.get(match[0].toLowerCase());
|
|
100
|
+
if (term)
|
|
101
|
+
return term;
|
|
102
|
+
}
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Text that names things: a column's heading, a resource's title, a
|
|
107
|
+
* description. Where it uses a term of the glossary around it, the term says
|
|
108
|
+
* what it means. Never put around a value from a row, or around free text:
|
|
109
|
+
* a common word would light up down a whole column, and in data it may mean
|
|
110
|
+
* something else.
|
|
111
|
+
*/
|
|
112
|
+
export function TermText({ children }) {
|
|
113
|
+
// A name between backticks is set as code (a developer's description says `/health`), and
|
|
114
|
+
// the glossary reads the words around it.
|
|
115
|
+
const pieces = children.split(/`([^`\n]+)`/);
|
|
116
|
+
if (pieces.length === 1)
|
|
117
|
+
return _jsx(TermWords, { children: children });
|
|
118
|
+
return (_jsx(_Fragment, { children: pieces.map((piece, at) =>
|
|
119
|
+
// Odd pieces are what was between backticks; a piece is told by where it stands.
|
|
120
|
+
at % 2 === 1 ? (_jsx("code", { className: "font-mono text-code", children: piece }, at)) : piece === "" ? null : (_jsx(TermWords, { children: piece }, at))) }));
|
|
121
|
+
}
|
|
122
|
+
/** Text whose names between backticks are set as code, without the glossary. For a dialog's words. */
|
|
123
|
+
export function CodeText({ children }) {
|
|
124
|
+
const pieces = children.split(/`([^`\n]+)`/);
|
|
125
|
+
if (pieces.length === 1)
|
|
126
|
+
return _jsx(_Fragment, { children: children });
|
|
127
|
+
return (_jsx(_Fragment, { children: pieces.map((piece, at) => at % 2 === 1 ? (_jsx("code", { className: "font-mono text-code", children: piece }, at)) : (piece)) }));
|
|
128
|
+
}
|
|
129
|
+
function TermWords({ children }) {
|
|
130
|
+
const glossary = useContext(GlossaryContext);
|
|
131
|
+
if (!glossary?.find)
|
|
132
|
+
return _jsx(_Fragment, { children: children });
|
|
133
|
+
const parts = [];
|
|
134
|
+
let last = 0;
|
|
135
|
+
const seen = new Set();
|
|
136
|
+
for (const match of children.matchAll(glossary.find)) {
|
|
137
|
+
const term = glossary.byWord.get(match[0].toLowerCase());
|
|
138
|
+
// Once in one piece of text is enough.
|
|
139
|
+
if (!term || seen.has(term.id))
|
|
140
|
+
continue;
|
|
141
|
+
seen.add(term.id);
|
|
142
|
+
const at = match.index;
|
|
143
|
+
if (at > last)
|
|
144
|
+
parts.push(children.slice(last, at));
|
|
145
|
+
parts.push(_jsx(Term, { id: term.id, word: term.term, short: term.short, more: glossary.more?.(term), children: match[0] }, at));
|
|
146
|
+
last = at + match[0].length;
|
|
147
|
+
}
|
|
148
|
+
if (parts.length === 0)
|
|
149
|
+
return _jsx(_Fragment, { children: children });
|
|
150
|
+
if (last < children.length)
|
|
151
|
+
parts.push(children.slice(last));
|
|
152
|
+
return _jsx(_Fragment, { children: parts });
|
|
153
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type TimelineSegmentKind = "wait" | "run" | "hold";
|
|
2
|
+
export interface TimelineRow {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
/** When the row began, in milliseconds since the epoch. */
|
|
6
|
+
start: number;
|
|
7
|
+
/** When it ended. Leave it out for a row still in progress: it then runs to `now`. */
|
|
8
|
+
end?: number | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* The row cut into parts, each ending at a time. A part left out is not drawn:
|
|
11
|
+
* a row with no parts is all "run".
|
|
12
|
+
*/
|
|
13
|
+
segments?: {
|
|
14
|
+
kind: TimelineSegmentKind;
|
|
15
|
+
until: number;
|
|
16
|
+
}[];
|
|
17
|
+
tone?: "plain" | "danger" | "muted";
|
|
18
|
+
}
|
|
19
|
+
export interface TimelineProps {
|
|
20
|
+
rows: readonly TimelineRow[];
|
|
21
|
+
/** The right-hand end for rows in progress, in milliseconds since the epoch. */
|
|
22
|
+
now?: number;
|
|
23
|
+
selected?: string | undefined;
|
|
24
|
+
onSelect?: (id: string) => void;
|
|
25
|
+
/** What each kind of part is called in the legend. */
|
|
26
|
+
legend?: Partial<Record<TimelineSegmentKind, string>>;
|
|
27
|
+
}
|
|
28
|
+
/** Things that took time, on one axis: what ran side by side, what waited, and for how long. */
|
|
29
|
+
export declare function Timeline({ rows, now, selected, onSelect, legend }: TimelineProps): import("react").JSX.Element | null;
|