@volvel/ui 0.0.0-stage → 0.6.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 +23018 -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 +11 -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 +47 -3
- package/README.md +0 -3
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronRight, Eye, EyeOff, GripVertical } from "lucide-react";
|
|
3
|
+
import { LIFTED, useSortable } from "./useSortable.js";
|
|
4
|
+
const focus = "outline-offset-[-2px] focus-visible:outline-2 focus-visible:outline-focus";
|
|
5
|
+
/**
|
|
6
|
+
* Rows with a drag handle, an optional eye, a value and a chevron. Reorder by dragging the
|
|
7
|
+
* handle (see `useSortable`: the row follows the pointer, the others slide, it settles into
|
|
8
|
+
* place), or with the keyboard: Alt+Up and Alt+Down on a row or its handle (Up and Down alone
|
|
9
|
+
* on the handle). Each move is said to screen readers.
|
|
10
|
+
*/
|
|
11
|
+
export function SortableRows({ items, onReorder, onOpen, onToggleHidden, activeId, label, }) {
|
|
12
|
+
const byId = new Map(items.map((item) => [item.id, item]));
|
|
13
|
+
const sort = useSortable({
|
|
14
|
+
ids: items.map((item) => item.id),
|
|
15
|
+
onReorder: (ids) => onReorder(ids),
|
|
16
|
+
nameOf: (id) => byId.get(id)?.label ?? "",
|
|
17
|
+
});
|
|
18
|
+
return (_jsxs(_Fragment, { children: [_jsx("ul", { ref: sort.list, "aria-label": label, className: "m-0 list-none divide-y divide-line p-0", children: items.map((item) => {
|
|
19
|
+
const id = item.id;
|
|
20
|
+
const active = id === activeId;
|
|
21
|
+
return (_jsxs("li", { ...sort.row(id), "data-active": active ? "" : undefined, onKeyDown: (event) => sort.rowKeyDown(event, id), className: `relative flex min-h-10 items-center before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-action before:opacity-0 data-[active]:bg-selected data-[active]:before:opacity-100 ${LIFTED}`, children: [_jsx("button", { type: "button", ...sort.handle(id), "aria-label": `Reorder ${item.label}. Alt and the up or down arrow move it.`, className: `grid h-10 w-7 shrink-0 cursor-grab touch-none place-items-center text-ink-subtle hover:text-ink ${focus}`, children: _jsx(GripVertical, { "aria-hidden": "true", size: 14 }) }), onToggleHidden ? (_jsx("button", { type: "button", "aria-pressed": !item.hidden, "aria-label": `${item.hidden ? "Show" : "Hide"} ${item.label}`, onClick: () => onToggleHidden(id, !item.hidden), className: `grid h-10 w-7 shrink-0 cursor-pointer place-items-center text-ink-muted hover:text-ink ${focus}`, children: item.hidden ? (_jsx(EyeOff, { "aria-hidden": "true", size: 14 })) : (_jsx(Eye, { "aria-hidden": "true", size: 14 })) })) : null, _jsxs("button", { type: "button", "data-main": "", onClick: onOpen ? () => onOpen(id) : undefined, disabled: !onOpen, className: `flex min-h-10 min-w-0 flex-1 items-center gap-3 py-1.5 pr-3 pl-1 text-left text-body-sm disabled:cursor-default ${onOpen ? "cursor-pointer hover:bg-selected" : ""} ${item.hidden ? "text-ink-muted" : "text-ink"} ${focus}`, children: [item.icon ? (_jsx(item.icon, { "aria-hidden": true, size: 14, className: "shrink-0 text-ink-muted" })) : null, _jsxs("span", { className: "min-w-0 flex-1", children: [_jsx("span", { className: "block truncate", children: item.label }), item.sub ? (_jsx("span", { className: "block truncate text-meta text-ink-muted", children: item.sub })) : null] }), item.value !== undefined ? (_jsx("span", { className: "shrink-0 text-meta text-ink-muted", children: item.value })) : null, onOpen ? (_jsx(ChevronRight, { "aria-hidden": "true", size: 14, className: "shrink-0 text-ink-muted" })) : null] })] }, id));
|
|
22
|
+
}) }), _jsx("div", { role: "status", "aria-live": "polite", className: "sr-only", children: sort.said })] }));
|
|
23
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* For a box that scrolls up and down: a soft shadow at the top or the foot while there is more
|
|
4
|
+
* that way, none when it has all been seen. It needs no script (the covers scroll with the
|
|
5
|
+
* content; the shadows stay). `cover` is the color behind the box.
|
|
6
|
+
*/
|
|
7
|
+
export declare const edgeShadows: (cover?: string) => CSSProperties;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* For a box that scrolls up and down: a soft shadow at the top or the foot while there is more
|
|
3
|
+
* that way, none when it has all been seen. It needs no script (the covers scroll with the
|
|
4
|
+
* content; the shadows stay). `cover` is the color behind the box.
|
|
5
|
+
*/
|
|
6
|
+
export const edgeShadows = (cover = "var(--color-structure)") => ({
|
|
7
|
+
backgroundImage: [
|
|
8
|
+
`linear-gradient(${cover} 30%, transparent)`,
|
|
9
|
+
`linear-gradient(transparent, ${cover} 70%)`,
|
|
10
|
+
"radial-gradient(farthest-side at 50% 0, color-mix(in srgb, var(--color-ink) 22%, transparent), transparent)",
|
|
11
|
+
"radial-gradient(farthest-side at 50% 100%, color-mix(in srgb, var(--color-ink) 22%, transparent), transparent)",
|
|
12
|
+
].join(", "),
|
|
13
|
+
backgroundPosition: "top, bottom, top, bottom",
|
|
14
|
+
backgroundSize: "100% 18px, 100% 18px, 100% 8px, 100% 8px",
|
|
15
|
+
backgroundRepeat: "no-repeat",
|
|
16
|
+
backgroundAttachment: "local, local, scroll, scroll",
|
|
17
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { AddChip, CheckChip, ChipSet, SentenceChip } from "./Chips.tsx";
|
|
2
|
+
export { POSITIONS, type Position, PositionPicker, RadioCards, type TileOption, TilePicker, } from "./Choices.tsx";
|
|
3
|
+
export { DashedAdd, DrawerBlock, DrawerEditor, DrawerGroup, DrawerHeader, type DrawerIcon, DrawerPanel, DrawerRow, DrawerSwitch, type DrawerTab, DrawerTabs, ToggleRow, } from "./Drawer.tsx";
|
|
4
|
+
export { type ConditionChoice, type ConditionColumn, ConditionEditor, type ConditionMoney, type ConditionOperator, type ConditionValue, type ConditionValueFrom, SortEditor, type SortField, type SortKey, valueSource, } from "./EditorBodies.tsx";
|
|
5
|
+
export { edgeShadows } from "./edgeShadows.ts";
|
|
6
|
+
export { CURRENCIES, choiceOf, formatName, formatOfChoice, type NumberFormat, NumberFormatPicker, NumberFormatRow, sampleOf, } from "./NumberFormat.tsx";
|
|
7
|
+
export { type SortableItem, SortableRows } from "./SortableRows.tsx";
|
|
8
|
+
export { LIFTED, moved, type UseSortable, useSortable } from "./useSortable.ts";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { AddChip, CheckChip, ChipSet, SentenceChip } from "./Chips.js";
|
|
2
|
+
export { POSITIONS, PositionPicker, RadioCards, TilePicker, } from "./Choices.js";
|
|
3
|
+
export { DashedAdd, DrawerBlock, DrawerEditor, DrawerGroup, DrawerHeader, DrawerPanel, DrawerRow, DrawerSwitch, DrawerTabs, ToggleRow, } from "./Drawer.js";
|
|
4
|
+
export { ConditionEditor, SortEditor, valueSource, } from "./EditorBodies.js";
|
|
5
|
+
export { edgeShadows } from "./edgeShadows.js";
|
|
6
|
+
export { CURRENCIES, choiceOf, formatName, formatOfChoice, NumberFormatPicker, NumberFormatRow, sampleOf, } from "./NumberFormat.js";
|
|
7
|
+
export { SortableRows } from "./SortableRows.js";
|
|
8
|
+
export { LIFTED, moved, useSortable } from "./useSortable.js";
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type CSSProperties, type KeyboardEvent, type MouseEvent, type PointerEvent, type RefObject } from "react";
|
|
2
|
+
export declare const moved: (ids: readonly string[], from: number, to: number) => string[];
|
|
3
|
+
export interface UseSortable<E extends HTMLElement = HTMLUListElement> {
|
|
4
|
+
/** The element that holds the rows (the `ul`). */
|
|
5
|
+
list: RefObject<E | null>;
|
|
6
|
+
/** Spread on each row. */
|
|
7
|
+
row: (id: string) => {
|
|
8
|
+
ref: (node: HTMLElement | null) => void;
|
|
9
|
+
style: CSSProperties;
|
|
10
|
+
"data-flip-key": string;
|
|
11
|
+
"data-sortable-row": "";
|
|
12
|
+
"data-dragging"?: "";
|
|
13
|
+
};
|
|
14
|
+
/** Spread on each row's drag handle (a button). */
|
|
15
|
+
handle: (id: string) => {
|
|
16
|
+
"data-handle": "";
|
|
17
|
+
onPointerDown: (event: PointerEvent<HTMLElement>) => void;
|
|
18
|
+
onPointerMove: (event: PointerEvent<HTMLElement>) => void;
|
|
19
|
+
onPointerUp: (event: PointerEvent<HTMLElement>) => void;
|
|
20
|
+
onPointerCancel: (event: PointerEvent<HTMLElement>) => void;
|
|
21
|
+
onClickCapture: (event: MouseEvent<HTMLElement>) => void;
|
|
22
|
+
onKeyDown: (event: KeyboardEvent) => void;
|
|
23
|
+
style: CSSProperties;
|
|
24
|
+
};
|
|
25
|
+
/** For the row's own key handler: Alt+Up and Alt+Down move it. Handles move with Up and Down alone. */
|
|
26
|
+
rowKeyDown: (event: KeyboardEvent, id: string) => void;
|
|
27
|
+
/** The row being dragged, if one is. */
|
|
28
|
+
dragging: string | undefined;
|
|
29
|
+
/** What a screen reader is told of the last move. */
|
|
30
|
+
said: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Rows that are put in order by hand, one behavior for every list in the console that has a
|
|
34
|
+
* drag handle. Dragging: the row follows the pointer, lifted; the others slide out of its way
|
|
35
|
+
* over `motion-base`; let go, it slides into its place and only then is the new order handed over,
|
|
36
|
+
* so nothing pops. Esc slides it back. The list scrolls when the pointer is near the edge of its
|
|
37
|
+
* scroller. From the keyboard Alt+Up and Alt+Down on a row, and Up and Down on its handle, move it
|
|
38
|
+
* one place, and `useFlip` slides the move. Nothing moves under reduced motion. Each move is said.
|
|
39
|
+
*
|
|
40
|
+
* `ids` are the rows that can be moved, in order; give `onReorder` the new order. Put `list` on the
|
|
41
|
+
* element that holds the rows and `row(id)` on each row, `handle(id)` on its handle.
|
|
42
|
+
*/
|
|
43
|
+
export declare function useSortable<E extends HTMLElement = HTMLUListElement>({ ids, onReorder, nameOf, focus, }: {
|
|
44
|
+
ids: readonly string[];
|
|
45
|
+
/** The ids in their new order, and which one was moved. */
|
|
46
|
+
onReorder: (ids: string[], moved: string) => void;
|
|
47
|
+
/** Said with each move: "Moved Price to position 2 of 5". */
|
|
48
|
+
nameOf?: (id: string) => string;
|
|
49
|
+
/** What gets the focus back after a keyboard move (the row may be remade). */
|
|
50
|
+
focus?: string;
|
|
51
|
+
}): UseSortable<E>;
|
|
52
|
+
/** Classes that lift the dragged row: put them on each row that `row(id)` is spread on. */
|
|
53
|
+
export declare const LIFTED = "data-[dragging]:bg-raised data-[dragging]:shadow-drag";
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState, } from "react";
|
|
2
|
+
import { useFlip } from "../useFlip.js";
|
|
3
|
+
/** `motion-base` and `--ease-out` (tokens.css), for motion that script starts. */
|
|
4
|
+
const MOVE_MS = 180;
|
|
5
|
+
const EASE = "cubic-bezier(0.2, 0, 0, 1)";
|
|
6
|
+
/** How near an edge of the scroller the pointer must be before the list scrolls, and its top speed. */
|
|
7
|
+
const EDGE = 48;
|
|
8
|
+
const SPEED = 16;
|
|
9
|
+
const still = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
10
|
+
export const moved = (ids, from, to) => {
|
|
11
|
+
const next = [...ids];
|
|
12
|
+
const [one] = next.splice(from, 1);
|
|
13
|
+
if (one !== undefined)
|
|
14
|
+
next.splice(to, 0, one);
|
|
15
|
+
return next;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Rows that are put in order by hand, one behavior for every list in the console that has a
|
|
19
|
+
* drag handle. Dragging: the row follows the pointer, lifted; the others slide out of its way
|
|
20
|
+
* over `motion-base`; let go, it slides into its place and only then is the new order handed over,
|
|
21
|
+
* so nothing pops. Esc slides it back. The list scrolls when the pointer is near the edge of its
|
|
22
|
+
* scroller. From the keyboard Alt+Up and Alt+Down on a row, and Up and Down on its handle, move it
|
|
23
|
+
* one place, and `useFlip` slides the move. Nothing moves under reduced motion. Each move is said.
|
|
24
|
+
*
|
|
25
|
+
* `ids` are the rows that can be moved, in order; give `onReorder` the new order. Put `list` on the
|
|
26
|
+
* element that holds the rows and `row(id)` on each row, `handle(id)` on its handle.
|
|
27
|
+
*/
|
|
28
|
+
export function useSortable({ ids, onReorder, nameOf, focus = "[data-main], [data-handle]", }) {
|
|
29
|
+
const [said, setSaid] = useState("");
|
|
30
|
+
const [drag, setDrag] = useState();
|
|
31
|
+
const rows = useRef(new Map());
|
|
32
|
+
const list = useRef(null);
|
|
33
|
+
const slots = useRef(new Map());
|
|
34
|
+
const gap = useRef(0);
|
|
35
|
+
const pointer = useRef({
|
|
36
|
+
startY: 0,
|
|
37
|
+
y: 0,
|
|
38
|
+
startScroll: 0,
|
|
39
|
+
scroller: undefined,
|
|
40
|
+
});
|
|
41
|
+
const pressedAt = useRef(0);
|
|
42
|
+
const refocus = useRef(undefined);
|
|
43
|
+
const frame = useRef(0);
|
|
44
|
+
const dragRef = useRef(undefined);
|
|
45
|
+
dragRef.current = drag;
|
|
46
|
+
const idsRef = useRef(ids);
|
|
47
|
+
idsRef.current = ids;
|
|
48
|
+
const changed = useRef(onReorder);
|
|
49
|
+
changed.current = onReorder;
|
|
50
|
+
useFlip(ids.join("\n"), { paused: drag !== undefined, ref: list });
|
|
51
|
+
// A reorder may remake the row's element: put the focus back where it was.
|
|
52
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: runs after every reorder
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
const again = refocus.current;
|
|
55
|
+
if (!again)
|
|
56
|
+
return;
|
|
57
|
+
refocus.current = undefined;
|
|
58
|
+
const node = rows.current.get(again.id);
|
|
59
|
+
(again.handle
|
|
60
|
+
? node?.querySelector("[data-handle]")
|
|
61
|
+
: node?.querySelector(focus))?.focus();
|
|
62
|
+
}, [ids.join("\n")]);
|
|
63
|
+
const say = useCallback((id, to, count) => {
|
|
64
|
+
setSaid(`Moved ${nameOf?.(id) ?? "the row"} to position ${to + 1} of ${count}`);
|
|
65
|
+
}, [nameOf]);
|
|
66
|
+
const nudge = (event, id, plain) => {
|
|
67
|
+
if (event.key !== "ArrowUp" && event.key !== "ArrowDown")
|
|
68
|
+
return;
|
|
69
|
+
if (!event.altKey && !plain)
|
|
70
|
+
return;
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
const now = [...idsRef.current];
|
|
73
|
+
const from = now.indexOf(id);
|
|
74
|
+
if (from < 0)
|
|
75
|
+
return;
|
|
76
|
+
const to = Math.min(now.length - 1, Math.max(0, from + (event.key === "ArrowUp" ? -1 : 1)));
|
|
77
|
+
if (to === from)
|
|
78
|
+
return;
|
|
79
|
+
refocus.current = {
|
|
80
|
+
id,
|
|
81
|
+
handle: Boolean(event.target.closest("[data-handle]")),
|
|
82
|
+
};
|
|
83
|
+
say(id, to, now.length);
|
|
84
|
+
changed.current(moved(now, from, to), id);
|
|
85
|
+
};
|
|
86
|
+
const scrollerOf = (node) => {
|
|
87
|
+
for (let up = node.parentElement; up; up = up.parentElement) {
|
|
88
|
+
const overflow = getComputedStyle(up).overflowY;
|
|
89
|
+
if ((overflow === "auto" || overflow === "scroll") && up.scrollHeight > up.clientHeight) {
|
|
90
|
+
return up;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return document.scrollingElement ?? document.documentElement;
|
|
94
|
+
};
|
|
95
|
+
/** Where the dragged row would sit among the others, from where the pointer has it now. */
|
|
96
|
+
const place = (id, from, dy) => {
|
|
97
|
+
const mine = slots.current.get(id);
|
|
98
|
+
if (!mine)
|
|
99
|
+
return from;
|
|
100
|
+
// Its edge that leads, in the way it is going, has to pass the middle of another row to change places.
|
|
101
|
+
const top = mine.top + dy;
|
|
102
|
+
const bottom = top + mine.height;
|
|
103
|
+
const was = from.indexOf(id);
|
|
104
|
+
const others = from.filter((one) => one !== id);
|
|
105
|
+
let to = 0;
|
|
106
|
+
for (const one of others) {
|
|
107
|
+
const slot = slots.current.get(one);
|
|
108
|
+
if (!slot)
|
|
109
|
+
continue;
|
|
110
|
+
const middle = slot.top + slot.height / 2;
|
|
111
|
+
if (from.indexOf(one) < was ? top >= middle : bottom > middle)
|
|
112
|
+
to += 1;
|
|
113
|
+
}
|
|
114
|
+
const next = [...others];
|
|
115
|
+
next.splice(to, 0, id);
|
|
116
|
+
return next;
|
|
117
|
+
};
|
|
118
|
+
/** How far each row is from where it was, once the rows are in `to`. */
|
|
119
|
+
const offsets = (from, to) => {
|
|
120
|
+
const out = new Map();
|
|
121
|
+
const first = slots.current.get(from[0]);
|
|
122
|
+
if (!first)
|
|
123
|
+
return out;
|
|
124
|
+
let top = first.top;
|
|
125
|
+
for (const id of to) {
|
|
126
|
+
const slot = slots.current.get(id);
|
|
127
|
+
if (!slot)
|
|
128
|
+
continue;
|
|
129
|
+
out.set(id, top - slot.top);
|
|
130
|
+
top += slot.height + gap.current;
|
|
131
|
+
}
|
|
132
|
+
return out;
|
|
133
|
+
};
|
|
134
|
+
const finish = (settling) => {
|
|
135
|
+
const now = dragRef.current;
|
|
136
|
+
if (!now || now.settling)
|
|
137
|
+
return;
|
|
138
|
+
cancelAnimationFrame(frame.current);
|
|
139
|
+
const final = settling === "place" ? now.to : now.from;
|
|
140
|
+
const apply = () => {
|
|
141
|
+
document.body.style.removeProperty("user-select");
|
|
142
|
+
setDrag(undefined);
|
|
143
|
+
if (final.join("\n") !== now.from.join("\n")) {
|
|
144
|
+
say(now.id, final.indexOf(now.id), final.length);
|
|
145
|
+
changed.current(final, now.id);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
if (still()) {
|
|
149
|
+
apply();
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
setDrag({ ...now, settling });
|
|
153
|
+
window.setTimeout(apply, MOVE_MS + 20);
|
|
154
|
+
};
|
|
155
|
+
// Esc puts it back.
|
|
156
|
+
const holding = drag !== undefined && !drag.settling;
|
|
157
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: finish reads the refs
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
if (!holding)
|
|
160
|
+
return;
|
|
161
|
+
const key = (event) => {
|
|
162
|
+
if (event.key !== "Escape")
|
|
163
|
+
return;
|
|
164
|
+
event.preventDefault();
|
|
165
|
+
event.stopPropagation();
|
|
166
|
+
finish("back");
|
|
167
|
+
};
|
|
168
|
+
window.addEventListener("keydown", key, true);
|
|
169
|
+
return () => window.removeEventListener("keydown", key, true);
|
|
170
|
+
}, [holding]);
|
|
171
|
+
useEffect(() => () => {
|
|
172
|
+
cancelAnimationFrame(frame.current);
|
|
173
|
+
document.body.style.removeProperty("user-select");
|
|
174
|
+
}, []);
|
|
175
|
+
const follow = () => {
|
|
176
|
+
const now = dragRef.current;
|
|
177
|
+
if (!now || now.settling)
|
|
178
|
+
return;
|
|
179
|
+
const { startY, y, startScroll, scroller } = pointer.current;
|
|
180
|
+
const scrolled = scroller ? scroller.scrollTop - startScroll : 0;
|
|
181
|
+
const mine = slots.current.get(now.id);
|
|
182
|
+
const all = [...slots.current.values()];
|
|
183
|
+
const topmost = Math.min(...all.map((slot) => slot.top));
|
|
184
|
+
const bottom = Math.max(...all.map((slot) => slot.top + slot.height));
|
|
185
|
+
let dy = y - startY + scrolled;
|
|
186
|
+
if (mine)
|
|
187
|
+
dy = Math.min(bottom - mine.height - mine.top, Math.max(topmost - mine.top, dy));
|
|
188
|
+
const to = place(now.id, now.from, dy);
|
|
189
|
+
setDrag({ ...now, dy, to });
|
|
190
|
+
};
|
|
191
|
+
// Near the top or bottom of the scroller, it scrolls, and goes on while the pointer stays there.
|
|
192
|
+
const autoscroll = () => {
|
|
193
|
+
const now = dragRef.current;
|
|
194
|
+
const { scroller, y } = pointer.current;
|
|
195
|
+
if (!now || now.settling || !scroller)
|
|
196
|
+
return;
|
|
197
|
+
const box = scroller === document.scrollingElement || scroller === document.documentElement
|
|
198
|
+
? { top: 0, bottom: window.innerHeight }
|
|
199
|
+
: scroller.getBoundingClientRect();
|
|
200
|
+
let by = 0;
|
|
201
|
+
if (y < box.top + EDGE)
|
|
202
|
+
by = -SPEED * Math.min(1, (box.top + EDGE - y) / EDGE);
|
|
203
|
+
else if (y > box.bottom - EDGE)
|
|
204
|
+
by = SPEED * Math.min(1, (y - (box.bottom - EDGE)) / EDGE);
|
|
205
|
+
if (by !== 0) {
|
|
206
|
+
const before = scroller.scrollTop;
|
|
207
|
+
scroller.scrollTop += by;
|
|
208
|
+
if (scroller.scrollTop !== before)
|
|
209
|
+
follow();
|
|
210
|
+
}
|
|
211
|
+
frame.current = requestAnimationFrame(autoscroll);
|
|
212
|
+
};
|
|
213
|
+
const start = (event, id) => {
|
|
214
|
+
if (event.button !== 0 || dragRef.current)
|
|
215
|
+
return;
|
|
216
|
+
const current = [...idsRef.current];
|
|
217
|
+
const node = rows.current.get(id);
|
|
218
|
+
if (!node)
|
|
219
|
+
return;
|
|
220
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
221
|
+
slots.current.clear();
|
|
222
|
+
for (const one of current) {
|
|
223
|
+
const box = rows.current.get(one)?.getBoundingClientRect();
|
|
224
|
+
if (box)
|
|
225
|
+
slots.current.set(one, { top: box.top, height: box.height });
|
|
226
|
+
}
|
|
227
|
+
const a = slots.current.get(current[0]);
|
|
228
|
+
const z = slots.current.get(current[current.length - 1]);
|
|
229
|
+
const heights = current.reduce((sum, one) => sum + (slots.current.get(one)?.height ?? 0), 0);
|
|
230
|
+
gap.current =
|
|
231
|
+
a && z && current.length > 1
|
|
232
|
+
? (z.top + z.height - a.top - heights) / (current.length - 1)
|
|
233
|
+
: 0;
|
|
234
|
+
const scroller = scrollerOf(node);
|
|
235
|
+
pointer.current = {
|
|
236
|
+
startY: event.clientY,
|
|
237
|
+
y: event.clientY,
|
|
238
|
+
startScroll: scroller.scrollTop,
|
|
239
|
+
scroller,
|
|
240
|
+
};
|
|
241
|
+
document.body.style.userSelect = "none";
|
|
242
|
+
setDrag({ id, from: current, to: current, dy: 0 });
|
|
243
|
+
frame.current = requestAnimationFrame(autoscroll);
|
|
244
|
+
};
|
|
245
|
+
const over = (event) => {
|
|
246
|
+
if (!dragRef.current || dragRef.current.settling)
|
|
247
|
+
return;
|
|
248
|
+
pointer.current.y = event.clientY;
|
|
249
|
+
follow();
|
|
250
|
+
};
|
|
251
|
+
const settledOffsets = drag
|
|
252
|
+
? offsets(drag.from, drag.settling === "back" ? drag.from : drag.to)
|
|
253
|
+
: undefined;
|
|
254
|
+
return {
|
|
255
|
+
list,
|
|
256
|
+
dragging: drag?.id,
|
|
257
|
+
said,
|
|
258
|
+
rowKeyDown: (event, id) => {
|
|
259
|
+
if (!event.target.closest("[data-handle]"))
|
|
260
|
+
nudge(event, id, false);
|
|
261
|
+
},
|
|
262
|
+
row: (id) => {
|
|
263
|
+
const style = {};
|
|
264
|
+
if (drag && settledOffsets) {
|
|
265
|
+
const mine = drag.id === id;
|
|
266
|
+
const reduced = still();
|
|
267
|
+
if (mine) {
|
|
268
|
+
style.position = "relative";
|
|
269
|
+
style.zIndex = 10;
|
|
270
|
+
if (drag.settling) {
|
|
271
|
+
style.transform = `translateY(${settledOffsets.get(id) ?? 0}px)`;
|
|
272
|
+
style.transition = reduced ? "none" : `transform ${MOVE_MS}ms ${EASE}`;
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
style.transform = `translateY(${drag.dy}px)`;
|
|
276
|
+
style.transition = "none";
|
|
277
|
+
}
|
|
278
|
+
style.touchAction = "none";
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
style.transform = `translateY(${settledOffsets.get(id) ?? 0}px)`;
|
|
282
|
+
style.transition = reduced ? "none" : `transform ${MOVE_MS}ms ${EASE}`;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return {
|
|
286
|
+
ref: (node) => {
|
|
287
|
+
if (node)
|
|
288
|
+
rows.current.set(id, node);
|
|
289
|
+
else
|
|
290
|
+
rows.current.delete(id);
|
|
291
|
+
},
|
|
292
|
+
style,
|
|
293
|
+
"data-flip-key": id,
|
|
294
|
+
"data-sortable-row": "",
|
|
295
|
+
...(drag?.id === id ? { "data-dragging": "" } : {}),
|
|
296
|
+
};
|
|
297
|
+
},
|
|
298
|
+
handle: (id) => ({
|
|
299
|
+
"data-handle": "",
|
|
300
|
+
onPointerDown: (event) => {
|
|
301
|
+
pressedAt.current = event.clientY;
|
|
302
|
+
start(event, id);
|
|
303
|
+
},
|
|
304
|
+
onPointerMove: over,
|
|
305
|
+
onPointerUp: (event) => {
|
|
306
|
+
event.currentTarget.releasePointerCapture?.(event.pointerId);
|
|
307
|
+
finish("place");
|
|
308
|
+
},
|
|
309
|
+
onPointerCancel: () => finish("back"),
|
|
310
|
+
// A drag that ends over its handle is not a press of it.
|
|
311
|
+
onClickCapture: (event) => {
|
|
312
|
+
if (Math.abs(event.clientY - pressedAt.current) < 4)
|
|
313
|
+
return;
|
|
314
|
+
event.preventDefault();
|
|
315
|
+
event.stopPropagation();
|
|
316
|
+
},
|
|
317
|
+
onKeyDown: (event) => nudge(event, id, true),
|
|
318
|
+
style: { touchAction: "none", userSelect: "none" },
|
|
319
|
+
}),
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
/** Classes that lift the dragged row: put them on each row that `row(id)` is spread on. */
|
|
323
|
+
export const LIFTED = "data-[dragging]:bg-raised data-[dragging]:shadow-drag";
|
package/dist/format.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Values as a person reads them (07 §7.3), the same in the kit and the console.
|
|
3
|
+
* Durations keep one shape at every size, so a column of them compares by eye.
|
|
4
|
+
*/
|
|
5
|
+
/** A length of time: "420 ms", "3.0 s", "4m 12s", "2h 5m". */
|
|
6
|
+
export declare function duration(ms: number): string;
|
package/dist/format.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Values as a person reads them (07 §7.3), the same in the kit and the console.
|
|
3
|
+
* Durations keep one shape at every size, so a column of them compares by eye.
|
|
4
|
+
*/
|
|
5
|
+
/** A length of time: "420 ms", "3.0 s", "4m 12s", "2h 5m". */
|
|
6
|
+
export function duration(ms) {
|
|
7
|
+
const value = Math.max(0, ms);
|
|
8
|
+
if (value < 1000)
|
|
9
|
+
return `${Math.round(value)} ms`;
|
|
10
|
+
if (value < 60_000)
|
|
11
|
+
return `${(Math.floor(value / 100) / 10).toFixed(1)} s`;
|
|
12
|
+
const seconds = Math.floor(value / 1000);
|
|
13
|
+
const minutes = Math.floor(seconds / 60);
|
|
14
|
+
if (minutes < 60)
|
|
15
|
+
return `${minutes}m ${seconds % 60}s`;
|
|
16
|
+
return `${Math.floor(minutes / 60)}h ${minutes % 60}m`;
|
|
17
|
+
}
|
package/dist/icons.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Icons for apps, from Lucide: `import { Calendar, PawPrint } from "@volvel/ui/icons"`.
|
|
3
|
+
* Each icon is a component that takes `size`, `strokeWidth` and `className`, and
|
|
4
|
+
* draws in the current text color. Only the icons an app imports are built into it.
|
|
5
|
+
* Give an icon that stands alone a label (`aria-label`), and mark one beside its
|
|
6
|
+
* own text `aria-hidden`.
|
|
7
|
+
*
|
|
8
|
+
* Three sizes and one stroke keep icons one texture (07, P4-3): `ICON.sm` (14)
|
|
9
|
+
* beside small text and in controls, `ICON.md` (16) beside body text, `ICON.lg`
|
|
10
|
+
* (20) alone. `PageShell` draws them all at `STROKE`.
|
|
11
|
+
*/
|
|
12
|
+
export * from "lucide-react";
|
|
13
|
+
/** The three icon sizes, in px. */
|
|
14
|
+
export declare const ICON: {
|
|
15
|
+
readonly sm: 14;
|
|
16
|
+
readonly md: 16;
|
|
17
|
+
readonly lg: 20;
|
|
18
|
+
};
|
|
19
|
+
/** The one stroke width. */
|
|
20
|
+
export declare const STROKE = 1.75;
|
package/dist/icons.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Icons for apps, from Lucide: `import { Calendar, PawPrint } from "@volvel/ui/icons"`.
|
|
3
|
+
* Each icon is a component that takes `size`, `strokeWidth` and `className`, and
|
|
4
|
+
* draws in the current text color. Only the icons an app imports are built into it.
|
|
5
|
+
* Give an icon that stands alone a label (`aria-label`), and mark one beside its
|
|
6
|
+
* own text `aria-hidden`.
|
|
7
|
+
*
|
|
8
|
+
* Three sizes and one stroke keep icons one texture (07, P4-3): `ICON.sm` (14)
|
|
9
|
+
* beside small text and in controls, `ICON.md` (16) beside body text, `ICON.lg`
|
|
10
|
+
* (20) alone. `PageShell` draws them all at `STROKE`.
|
|
11
|
+
*/
|
|
12
|
+
export * from "lucide-react";
|
|
13
|
+
/** The three icon sizes, in px. */
|
|
14
|
+
export const ICON = { sm: 14, md: 16, lg: 20 };
|
|
15
|
+
/** The one stroke width. */
|
|
16
|
+
export const STROKE = 1.75;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export { Badge, type BadgeTone, readableOn, ValueChip } from "./Badge.tsx";
|
|
2
|
+
export { Button, type ButtonProps } from "./Button.tsx";
|
|
3
|
+
export { Chart, type ChartProps } from "./Chart.tsx";
|
|
4
|
+
export { ComboboxField, type ComboboxFieldProps, MultiSelectField, type MultiSelectFieldProps, type Option, } from "./Combobox.tsx";
|
|
5
|
+
export { ContextMenu } from "./ContextMenu.tsx";
|
|
6
|
+
export { type ChartTokens, chartConfig, readChartTokens, SURFACE, seriesColors, } from "./chartTheme.ts";
|
|
7
|
+
export { CONTRAST_NEEDED, contrastRatio, luminance, parseColor } from "./contrast.ts";
|
|
8
|
+
export { DateInput, type DateInputProps } from "./DateInput.tsx";
|
|
9
|
+
export { Details } from "./Details.tsx";
|
|
10
|
+
export { Dialog } from "./Dialog.tsx";
|
|
11
|
+
export { type ConfirmOptions, type Dialogs, DialogsProvider, type PromptOptions, type TypeToConfirmOptions, useDialogs, } from "./Dialogs.tsx";
|
|
12
|
+
export { Doc, type DocProps } from "./Doc.tsx";
|
|
13
|
+
export { reveal, servedComponents } from "./DocServed.tsx";
|
|
14
|
+
export * from "./drawer/index.ts";
|
|
15
|
+
export { type Fact, Facts } from "./Facts.tsx";
|
|
16
|
+
export { CheckboxField, control as fieldControl, DateField, FieldFrame, FieldHelp, FieldMarks, LimitNote, MoneyField, type MoneyFieldProps, NumberField, pastLimit, SelectField, TextAreaField, TextField, utcInputValue, utcInstant, } from "./Fields.tsx";
|
|
17
|
+
export { checkForm, Form, type FormProperty, type FormProps, type FormSchema } from "./Form.tsx";
|
|
18
|
+
export { duration } from "./format.ts";
|
|
19
|
+
export { Grid, type GridColumn, type GridSort, instantFromText, keepsKey, localWall, parseValue, showValue, utcOf, } from "./Grid.tsx";
|
|
20
|
+
export { HeadingSlot, hasHeadingControls, OnHeading } from "./HeadingSlot.tsx";
|
|
21
|
+
export { JsonView, type JsonViewProps } from "./JsonView.tsx";
|
|
22
|
+
export { type LogLine, LogViewer, type LogViewerProps, logText, saveText, } from "./LogViewer.tsx";
|
|
23
|
+
export { Markdown } from "./Markdown.tsx";
|
|
24
|
+
export { Menu, type MenuItem, type MenuProps } from "./Menu.tsx";
|
|
25
|
+
export { MoveButtons, type MoveButtonsProps } from "./MoveButtons.tsx";
|
|
26
|
+
export { knowledgeFrom, type MarkdownKnowledge, MarkdownKnows, useMarkdownKnowledge, type WorkspaceWords, } from "./markdownKnowledge.ts";
|
|
27
|
+
export { EmptyState, type FailureHelp, Notice, setFailureExplainer } from "./Notice.tsx";
|
|
28
|
+
export { type PageNavItem, PageShell, type PageShellProps } from "./PageShell.tsx";
|
|
29
|
+
export { Pagination, type PaginationProps } from "./Pagination.tsx";
|
|
30
|
+
export { ContainedArea, Panel, useContained } from "./Panel.tsx";
|
|
31
|
+
export { DateStepper, isoDay, SegmentedControl, type SegmentOption, } from "./Pickers.tsx";
|
|
32
|
+
export { Popover } from "./Popover.tsx";
|
|
33
|
+
export { PAGE_ICONS, pageIconOf } from "./pageIcons.ts";
|
|
34
|
+
export { Appear, Closing, useLast, useOpening } from "./presence.tsx";
|
|
35
|
+
export { columnsOf, MAX_TABLE_ROWS, type ResultShape, ResultView, type ResultViewProps, resultShapes, } from "./ResultView.tsx";
|
|
36
|
+
export { checkValue, cleaned as cleanedValue, type JsonSchema, SchemaForm, type SchemaFormProps, startValue, } from "./SchemaForm.tsx";
|
|
37
|
+
export { SideSheet, type SideSheetProps } from "./SideSheet.tsx";
|
|
38
|
+
export { Sparkline } from "./Sparkline.tsx";
|
|
39
|
+
export { Avatar, initialsOf, Skeleton } from "./Surfaces.tsx";
|
|
40
|
+
export { Switch } from "./Switch.tsx";
|
|
41
|
+
export { type Column, Table } from "./Table.tsx";
|
|
42
|
+
export { type TabItem, Tabs, type TabsProps } from "./Tabs.tsx";
|
|
43
|
+
export { GlossaryProvider, type GlossaryTerm, Term, TermScope, TermText, Toggletip, } from "./Term.tsx";
|
|
44
|
+
export { Timeline, type TimelineProps, type TimelineRow, type TimelineSegmentKind, } from "./Timeline.tsx";
|
|
45
|
+
export { type ToastOptions, ToastProvider, type Toasts, type ToastTone, useToast, } from "./Toast.tsx";
|
|
46
|
+
export { Kbd, Tooltip, TooltipProvider } from "./Tooltip.tsx";
|
|
47
|
+
export { type DropPosition, Tree, type TreeNode } from "./Tree.tsx";
|
|
48
|
+
export { useFlip, useKeys } from "./useFlip.ts";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export { Badge, readableOn, ValueChip } from "./Badge.js";
|
|
2
|
+
export { Button } from "./Button.js";
|
|
3
|
+
export { Chart } from "./Chart.js";
|
|
4
|
+
export { ComboboxField, MultiSelectField, } from "./Combobox.js";
|
|
5
|
+
export { ContextMenu } from "./ContextMenu.js";
|
|
6
|
+
export { chartConfig, readChartTokens, SURFACE, seriesColors, } from "./chartTheme.js";
|
|
7
|
+
export { CONTRAST_NEEDED, contrastRatio, luminance, parseColor } from "./contrast.js";
|
|
8
|
+
export { DateInput } from "./DateInput.js";
|
|
9
|
+
export { Details } from "./Details.js";
|
|
10
|
+
export { Dialog } from "./Dialog.js";
|
|
11
|
+
export { DialogsProvider, useDialogs, } from "./Dialogs.js";
|
|
12
|
+
export { Doc } from "./Doc.js";
|
|
13
|
+
export { reveal, servedComponents } from "./DocServed.js";
|
|
14
|
+
export * from "./drawer/index.js";
|
|
15
|
+
export { Facts } from "./Facts.js";
|
|
16
|
+
export { CheckboxField, control as fieldControl, DateField, FieldFrame, FieldHelp, FieldMarks, LimitNote, MoneyField, NumberField, pastLimit, SelectField, TextAreaField, TextField, utcInputValue, utcInstant, } from "./Fields.js";
|
|
17
|
+
export { checkForm, Form } from "./Form.js";
|
|
18
|
+
export { duration } from "./format.js";
|
|
19
|
+
export { Grid, instantFromText, keepsKey, localWall, parseValue, showValue, utcOf, } from "./Grid.js";
|
|
20
|
+
export { HeadingSlot, hasHeadingControls, OnHeading } from "./HeadingSlot.js";
|
|
21
|
+
export { JsonView } from "./JsonView.js";
|
|
22
|
+
export { LogViewer, logText, saveText, } from "./LogViewer.js";
|
|
23
|
+
export { Markdown } from "./Markdown.js";
|
|
24
|
+
export { Menu } from "./Menu.js";
|
|
25
|
+
export { MoveButtons } from "./MoveButtons.js";
|
|
26
|
+
export { knowledgeFrom, MarkdownKnows, useMarkdownKnowledge, } from "./markdownKnowledge.js";
|
|
27
|
+
export { EmptyState, Notice, setFailureExplainer } from "./Notice.js";
|
|
28
|
+
export { PageShell } from "./PageShell.js";
|
|
29
|
+
export { Pagination } from "./Pagination.js";
|
|
30
|
+
export { ContainedArea, Panel, useContained } from "./Panel.js";
|
|
31
|
+
export { DateStepper, isoDay, SegmentedControl, } from "./Pickers.js";
|
|
32
|
+
export { Popover } from "./Popover.js";
|
|
33
|
+
export { PAGE_ICONS, pageIconOf } from "./pageIcons.js";
|
|
34
|
+
export { Appear, Closing, useLast, useOpening } from "./presence.js";
|
|
35
|
+
export { columnsOf, MAX_TABLE_ROWS, ResultView, resultShapes, } from "./ResultView.js";
|
|
36
|
+
export { checkValue, cleaned as cleanedValue, SchemaForm, startValue, } from "./SchemaForm.js";
|
|
37
|
+
export { SideSheet } from "./SideSheet.js";
|
|
38
|
+
export { Sparkline } from "./Sparkline.js";
|
|
39
|
+
export { Avatar, initialsOf, Skeleton } from "./Surfaces.js";
|
|
40
|
+
export { Switch } from "./Switch.js";
|
|
41
|
+
export { Table } from "./Table.js";
|
|
42
|
+
export { Tabs } from "./Tabs.js";
|
|
43
|
+
export { GlossaryProvider, Term, TermScope, TermText, Toggletip, } from "./Term.js";
|
|
44
|
+
export { Timeline, } from "./Timeline.js";
|
|
45
|
+
export { ToastProvider, useToast, } from "./Toast.js";
|
|
46
|
+
export { Kbd, Tooltip, TooltipProvider } from "./Tooltip.js";
|
|
47
|
+
export { Tree } from "./Tree.js";
|
|
48
|
+
export { useFlip, useKeys } from "./useFlip.js";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type FieldInfo, type TermInfo } from "@volvel/markup";
|
|
2
|
+
/**
|
|
3
|
+
* What a page's Markdown can be told by the app around it: what a `:term[…]` means, and what a
|
|
4
|
+
* `::field{…}` is. A host that knows (the console, a served app: they read the workspace's
|
|
5
|
+
* `GET …/terms`) gives it with `MarkdownKnows`; a text drawn where nothing is given draws a
|
|
6
|
+
* term as its word and a field as its path, which is right for someone who has no use for more.
|
|
7
|
+
*/
|
|
8
|
+
export interface MarkdownKnowledge {
|
|
9
|
+
/** What a term means. `null` when it can't be found. Absent: the host knows nothing of terms. */
|
|
10
|
+
term?: (props: Record<string, string>) => TermInfo | null;
|
|
11
|
+
/** What a field is. `null` when it can't be found. Absent: the host knows nothing of fields. */
|
|
12
|
+
field?: (path: string) => FieldInfo | null;
|
|
13
|
+
}
|
|
14
|
+
/** Gives the Markdown drawn inside it what the host knows. */
|
|
15
|
+
export declare const MarkdownKnows: import("react").Provider<MarkdownKnowledge>;
|
|
16
|
+
export declare const useMarkdownKnowledge: () => MarkdownKnowledge;
|
|
17
|
+
/** What `GET …/terms` says, as far as a text needs it. */
|
|
18
|
+
export interface WorkspaceWords {
|
|
19
|
+
terms?: readonly {
|
|
20
|
+
id: string;
|
|
21
|
+
term: string;
|
|
22
|
+
aliases?: readonly string[];
|
|
23
|
+
short: string;
|
|
24
|
+
page?: {
|
|
25
|
+
url: string;
|
|
26
|
+
} | null;
|
|
27
|
+
}[];
|
|
28
|
+
resources?: readonly {
|
|
29
|
+
kind: string;
|
|
30
|
+
path: string;
|
|
31
|
+
description: string | null;
|
|
32
|
+
columns?: readonly {
|
|
33
|
+
name: string;
|
|
34
|
+
description: string;
|
|
35
|
+
}[];
|
|
36
|
+
}[];
|
|
37
|
+
/** What each field of each kind is, by `<kind>.<path>`. */
|
|
38
|
+
fields?: Readonly<Record<string, string>> | undefined;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The knowledge a host builds from the workspace's words: a term by its `id` (or the word
|
|
42
|
+
* itself) from the glossary, a table, script, flow… by its path, and a column of a table, from
|
|
43
|
+
* their descriptions; a field from the kinds' own descriptions of them.
|
|
44
|
+
*/
|
|
45
|
+
export declare function knowledgeFrom(words: WorkspaceWords): MarkdownKnowledge;
|