@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.
Files changed (137) hide show
  1. package/LICENSE +202 -0
  2. package/THIRD_PARTY_NOTICES.md +23036 -0
  3. package/dist/Badge.d.ts +20 -0
  4. package/dist/Badge.js +35 -0
  5. package/dist/Button.d.ts +56 -0
  6. package/dist/Button.js +52 -0
  7. package/dist/Chart.d.ts +23 -0
  8. package/dist/Chart.js +98 -0
  9. package/dist/Combobox.d.ts +45 -0
  10. package/dist/Combobox.js +42 -0
  11. package/dist/ContextMenu.d.ts +16 -0
  12. package/dist/ContextMenu.js +38 -0
  13. package/dist/DateInput.d.ts +31 -0
  14. package/dist/DateInput.js +329 -0
  15. package/dist/Details.d.ts +12 -0
  16. package/dist/Details.js +9 -0
  17. package/dist/Dialog.d.ts +44 -0
  18. package/dist/Dialog.js +95 -0
  19. package/dist/Dialogs.d.ts +56 -0
  20. package/dist/Dialogs.js +95 -0
  21. package/dist/Doc.d.ts +25 -0
  22. package/dist/Doc.js +118 -0
  23. package/dist/DocServed.d.ts +6 -0
  24. package/dist/DocServed.js +154 -0
  25. package/dist/DocZoom.d.ts +11 -0
  26. package/dist/DocZoom.js +133 -0
  27. package/dist/Facts.d.ts +12 -0
  28. package/dist/Facts.js +10 -0
  29. package/dist/Fields.d.ts +184 -0
  30. package/dist/Fields.js +249 -0
  31. package/dist/Form.d.ts +47 -0
  32. package/dist/Form.js +189 -0
  33. package/dist/Grid.d.ts +118 -0
  34. package/dist/Grid.js +475 -0
  35. package/dist/HeadingSlot.d.ts +13 -0
  36. package/dist/HeadingSlot.js +19 -0
  37. package/dist/JsonView.d.ts +11 -0
  38. package/dist/JsonView.js +68 -0
  39. package/dist/LogViewer.d.ts +45 -0
  40. package/dist/LogViewer.js +299 -0
  41. package/dist/Markdown.d.ts +21 -0
  42. package/dist/Markdown.js +27 -0
  43. package/dist/MarkdownBody.d.ts +6 -0
  44. package/dist/MarkdownBody.js +14 -0
  45. package/dist/Menu.d.ts +29 -0
  46. package/dist/Menu.js +8 -0
  47. package/dist/MoveButtons.d.ts +19 -0
  48. package/dist/MoveButtons.js +22 -0
  49. package/dist/Notice.d.ts +47 -0
  50. package/dist/Notice.js +50 -0
  51. package/dist/PageShell.d.ts +42 -0
  52. package/dist/PageShell.js +14 -0
  53. package/dist/Pagination.d.ts +13 -0
  54. package/dist/Pagination.js +9 -0
  55. package/dist/Panel.d.ts +31 -0
  56. package/dist/Panel.js +33 -0
  57. package/dist/Pickers.d.ts +37 -0
  58. package/dist/Pickers.js +44 -0
  59. package/dist/Popover.d.ts +24 -0
  60. package/dist/Popover.js +12 -0
  61. package/dist/ResultView.d.ts +28 -0
  62. package/dist/ResultView.js +140 -0
  63. package/dist/SchemaForm.d.ts +45 -0
  64. package/dist/SchemaForm.js +626 -0
  65. package/dist/SideSheet.d.ts +31 -0
  66. package/dist/SideSheet.js +136 -0
  67. package/dist/Sparkline.d.ts +14 -0
  68. package/dist/Sparkline.js +23 -0
  69. package/dist/Surfaces.d.ts +30 -0
  70. package/dist/Surfaces.js +34 -0
  71. package/dist/Switch.d.ts +18 -0
  72. package/dist/Switch.js +11 -0
  73. package/dist/Table.d.ts +15 -0
  74. package/dist/Table.js +6 -0
  75. package/dist/Tabs.d.ts +32 -0
  76. package/dist/Tabs.js +11 -0
  77. package/dist/Term.d.ts +82 -0
  78. package/dist/Term.js +153 -0
  79. package/dist/Timeline.d.ts +29 -0
  80. package/dist/Timeline.js +39 -0
  81. package/dist/Toast.d.ts +43 -0
  82. package/dist/Toast.js +140 -0
  83. package/dist/Tooltip.d.ts +34 -0
  84. package/dist/Tooltip.js +70 -0
  85. package/dist/Tree.d.ts +51 -0
  86. package/dist/Tree.js +233 -0
  87. package/dist/chartEngine.d.ts +32 -0
  88. package/dist/chartEngine.js +72 -0
  89. package/dist/chartTheme.d.ts +41 -0
  90. package/dist/chartTheme.js +131 -0
  91. package/dist/contrast.d.ts +27 -0
  92. package/dist/contrast.js +110 -0
  93. package/dist/dates.d.ts +61 -0
  94. package/dist/dates.js +294 -0
  95. package/dist/drawer/Chips.d.ts +37 -0
  96. package/dist/drawer/Chips.js +32 -0
  97. package/dist/drawer/Choices.d.ts +47 -0
  98. package/dist/drawer/Choices.js +81 -0
  99. package/dist/drawer/Drawer.d.ts +125 -0
  100. package/dist/drawer/Drawer.js +150 -0
  101. package/dist/drawer/EditorBodies.d.ts +95 -0
  102. package/dist/drawer/EditorBodies.js +169 -0
  103. package/dist/drawer/NumberFormat.d.ts +36 -0
  104. package/dist/drawer/NumberFormat.js +98 -0
  105. package/dist/drawer/SortableRows.d.ts +35 -0
  106. package/dist/drawer/SortableRows.js +23 -0
  107. package/dist/drawer/edgeShadows.d.ts +7 -0
  108. package/dist/drawer/edgeShadows.js +17 -0
  109. package/dist/drawer/index.d.ts +8 -0
  110. package/dist/drawer/index.js +8 -0
  111. package/dist/drawer/useSortable.d.ts +53 -0
  112. package/dist/drawer/useSortable.js +323 -0
  113. package/dist/format.d.ts +6 -0
  114. package/dist/format.js +17 -0
  115. package/dist/icons.d.ts +20 -0
  116. package/dist/icons.js +16 -0
  117. package/dist/index.d.ts +48 -0
  118. package/dist/index.js +48 -0
  119. package/dist/markdownKnowledge.d.ts +45 -0
  120. package/dist/markdownKnowledge.js +37 -0
  121. package/dist/overlay.d.ts +7 -0
  122. package/dist/overlay.js +10 -0
  123. package/dist/pageIcons.d.ts +12 -0
  124. package/dist/pageIcons.js +32 -0
  125. package/dist/presence.d.ts +41 -0
  126. package/dist/presence.js +108 -0
  127. package/dist/returnFocus.d.ts +9 -0
  128. package/dist/returnFocus.js +44 -0
  129. package/dist/tokens.css +437 -0
  130. package/dist/type-scale.css +34 -0
  131. package/dist/useFlip.d.ts +32 -0
  132. package/dist/useFlip.js +118 -0
  133. package/fonts/OFL.txt +193 -0
  134. package/fonts/geist-latin.woff2 +0 -0
  135. package/fonts/geist-mono-latin.woff2 +0 -0
  136. package/package.json +52 -3
  137. package/README.md +0 -3
@@ -0,0 +1,20 @@
1
+ import type { ReactNode } from "react";
2
+ export type BadgeTone = "neutral" | "action" | "attention" | "danger" | "success";
3
+ export declare function Badge({ tone, children }: {
4
+ tone?: BadgeTone;
5
+ children: ReactNode;
6
+ }): import("react").JSX.Element;
7
+ /**
8
+ * Black or white, whichever is easier to read on `color`. One of the two
9
+ * always reaches 4.5 to 1, the contrast text needs, whatever the color is.
10
+ */
11
+ export declare function readableOn(color: string): string;
12
+ /**
13
+ * One value of a column that holds a choice, on the color its table gives it.
14
+ * The text is black or white, worked out from the color, so any color a
15
+ * table's author picks can be read. A value with no color is a plain badge.
16
+ */
17
+ export declare function ValueChip({ color, children, }: {
18
+ color?: string | undefined;
19
+ children: ReactNode;
20
+ }): import("react").JSX.Element;
package/dist/Badge.js ADDED
@@ -0,0 +1,35 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { contrastRatio } from "./contrast.js";
3
+ const tones = {
4
+ neutral: "bg-sunken text-ink-muted",
5
+ action: "bg-action-soft text-action",
6
+ attention: "bg-attention-soft text-attention",
7
+ danger: "bg-danger-soft text-danger",
8
+ success: "bg-success-soft text-success",
9
+ };
10
+ export function Badge({ tone = "neutral", children }) {
11
+ return (_jsx("span", { className: `inline-flex items-center rounded-full px-2 py-0.5 text-meta font-medium forced-colors:border forced-colors:border-[CanvasText] ${tones[tone]}`, children: children }));
12
+ }
13
+ const BLACK = "#000000";
14
+ const WHITE = "#ffffff";
15
+ /**
16
+ * Black or white, whichever is easier to read on `color`. One of the two
17
+ * always reaches 4.5 to 1, the contrast text needs, whatever the color is.
18
+ */
19
+ export function readableOn(color) {
20
+ // The color is the ground; one with some transparency is laid over a white page first.
21
+ const onBlack = contrastRatio(BLACK, color) ?? 0;
22
+ const onWhite = contrastRatio(WHITE, color) ?? 0;
23
+ return onBlack >= onWhite ? BLACK : WHITE;
24
+ }
25
+ /**
26
+ * One value of a column that holds a choice, on the color its table gives it.
27
+ * The text is black or white, worked out from the color, so any color a
28
+ * table's author picks can be read. A value with no color is a plain badge.
29
+ */
30
+ export function ValueChip({ color, children, }) {
31
+ if (!color || contrastRatio(color, BLACK) === undefined) {
32
+ return _jsx(Badge, { children: children });
33
+ }
34
+ return (_jsx("span", { className: "inline-flex items-center rounded-full px-2 py-0.5 text-meta font-medium forced-colors:border forced-colors:border-[CanvasText]", style: { backgroundColor: color, color: readableOn(color) }, children: children }));
35
+ }
@@ -0,0 +1,56 @@
1
+ import type { AnchorHTMLAttributes, ButtonHTMLAttributes, ReactNode } from "react";
2
+ /**
3
+ * The boards' four looks: `primary` (main) is solid cyan with dark text,
4
+ * `secondary` (normal) an outline, `quiet` words alone, `danger` an outline
5
+ * with red words. `dashed` is the dashed box that stands for an add place:
6
+ * "+ Add a step".
7
+ */
8
+ declare const styles: {
9
+ primary: string;
10
+ secondary: string;
11
+ quiet: string;
12
+ danger: string;
13
+ "danger-solid": string;
14
+ /** Reserved for the one action that changes production. */
15
+ promote: string;
16
+ dashed: string;
17
+ };
18
+ /** The boards' names for the same looks, so a call reads as the board does. */
19
+ declare const ALIASES: {
20
+ readonly main: "primary";
21
+ readonly normal: "secondary";
22
+ };
23
+ interface Shared {
24
+ variant?: keyof typeof styles | keyof typeof ALIASES;
25
+ /**
26
+ * `regular` is the page's own control height, 36 px. `small` is 28 px (32 on a touch screen), for
27
+ * toolbars inside a pane; `large` is 40 px, for sign-in.
28
+ */
29
+ size?: "regular" | "small" | "large";
30
+ /**
31
+ * The work it started is under way: a spinner beside the label, which stays,
32
+ * and it cannot be pressed again. Screen readers hear it as busy.
33
+ */
34
+ loading?: boolean;
35
+ /**
36
+ * Said when the button is pointed at or focused: what an icon-only button
37
+ * does, or why a disabled one cannot be pressed. Not a replacement for an
38
+ * accessible name.
39
+ */
40
+ tooltip?: ReactNode;
41
+ /** The shortcut that does the same, shown in the tooltip: `⌘Z`. */
42
+ keys?: string | undefined;
43
+ children: ReactNode;
44
+ }
45
+ /**
46
+ * A button, or with `href` a link that looks like one. Use the link form when
47
+ * pressing it goes somewhere, so it opens in a new tab and reads as a link to a
48
+ * screen reader.
49
+ */
50
+ export type ButtonProps = Shared & ((Omit<ButtonHTMLAttributes<HTMLButtonElement>, "size"> & {
51
+ href?: undefined;
52
+ }) | (Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "size"> & {
53
+ href: string;
54
+ }));
55
+ export declare function Button({ tooltip, keys, ...props }: ButtonProps): import("react").JSX.Element;
56
+ export {};
package/dist/Button.js ADDED
@@ -0,0 +1,52 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { LoaderCircle } from "lucide-react";
3
+ import { Tooltip } from "./Tooltip.js";
4
+ /**
5
+ * The boards' four looks: `primary` (main) is solid cyan with dark text,
6
+ * `secondary` (normal) an outline, `quiet` words alone, `danger` an outline
7
+ * with red words. `dashed` is the dashed box that stands for an add place:
8
+ * "+ Add a step".
9
+ */
10
+ const styles = {
11
+ primary: "bg-action text-action-ink font-semibold hover:brightness-110 forced-colors:border-2 forced-colors:border-[ButtonText]",
12
+ secondary: "border border-line-strong bg-transparent text-ink hover:bg-hover",
13
+ quiet: "text-ink hover:bg-hover",
14
+ danger: "border border-danger/50 text-danger hover:bg-danger-soft",
15
+ "danger-solid": "bg-danger text-action-ink font-semibold hover:brightness-110 forced-colors:border-2 forced-colors:border-[ButtonText]",
16
+ /** Reserved for the one action that changes production. */
17
+ promote: "bg-attention text-canvas font-semibold hover:brightness-110 forced-colors:border-2 forced-colors:border-[ButtonText]",
18
+ dashed: "border border-dashed border-line-strong bg-transparent text-ink-muted hover:bg-hover hover:text-ink",
19
+ };
20
+ /** The boards' names for the same looks, so a call reads as the board does. */
21
+ const ALIASES = { main: "primary", normal: "secondary" };
22
+ const SIZES = {
23
+ small: "h-7 gap-1.5 px-2 pointer-coarse:h-8",
24
+ regular: "h-control gap-2 px-3",
25
+ large: "h-10 gap-2 px-4",
26
+ };
27
+ const classesOf = (named, size, extra = "") => {
28
+ const variant = named in ALIASES ? ALIASES[named] : named;
29
+ return `inline-flex items-center justify-center rounded-control text-body-sm font-medium whitespace-nowrap no-underline transition-[background-color,filter] motion-fast forced-colors:border forced-colors:border-[ButtonText] forced-colors:disabled:border-[GrayText] active:brightness-95 disabled:opacity-50 disabled:pointer-events-none aria-disabled:opacity-50 aria-disabled:pointer-events-none ${SIZES[size]} ${styles[variant]} ${extra}`;
30
+ };
31
+ export function Button({ tooltip, keys, ...props }) {
32
+ const drawn = _jsx(Plain, { ...props });
33
+ if (tooltip === undefined)
34
+ return drawn;
35
+ // A disabled button takes no pointer or focus: a wrapper that does says why.
36
+ // A loading button is not disabled: it keeps the focus it has while it works.
37
+ const disabled = props.href === undefined && props.disabled;
38
+ return (_jsx(Tooltip, { label: tooltip, keys: keys, tapToShow: disabled === true, children: disabled ? (_jsx("span", { tabIndex: 0, className: "inline-flex rounded-control", children: drawn })) : drawn }));
39
+ }
40
+ function Plain({ variant = "secondary", size = "regular", loading = false, children, ...rest }) {
41
+ const label = loading ? (_jsxs(_Fragment, { children: [_jsx(LoaderCircle, { "aria-hidden": "true", size: 14, className: "shrink-0 animate-spin" }), children] })) : (children);
42
+ if (rest.href !== undefined) {
43
+ const { className, ...link } = rest;
44
+ return (_jsx("a", { ...link, ...(loading ? { "aria-busy": true, "aria-disabled": true } : {}), className: classesOf(variant, size, className), children: label }));
45
+ }
46
+ const { className, ...button } = rest;
47
+ return (_jsx("button", { type: "button", ...button, disabled: button.disabled, "aria-disabled": loading || undefined, "aria-busy": loading || undefined, onClick: loading
48
+ ? (event) => {
49
+ event.preventDefault();
50
+ }
51
+ : button.onClick, className: classesOf(variant, size, className), children: label }));
52
+ }
@@ -0,0 +1,23 @@
1
+ export interface ChartProps {
2
+ /** A Vega-Lite spec. */
3
+ spec: object;
4
+ /** Rows to draw. When given, they replace the spec's own data. */
5
+ data?: readonly Record<string, unknown>[];
6
+ /** Names the chart for screen readers. */
7
+ title: string;
8
+ /** Says what the chart shows, for someone who cannot see it. */
9
+ description?: string;
10
+ /** In pixels, unless the spec sets its own height. */
11
+ height?: number;
12
+ /**
13
+ * Called with the row a bar, a point or a slice was drawn from when it is
14
+ * pressed. With it, marks show they can be pressed. A chart is a picture to
15
+ * a screen reader, so whatever this opens has another way in as well.
16
+ */
17
+ onPick?: ((row: Record<string, unknown>) => void) | undefined;
18
+ }
19
+ /**
20
+ * A chart drawn from a Vega-Lite spec, in the theme's colors and font. The
21
+ * engine is fetched when the first chart appears.
22
+ */
23
+ export declare function Chart({ spec, data, title, description, height, onPick }: ChartProps): import("react").JSX.Element;
package/dist/Chart.js ADDED
@@ -0,0 +1,98 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from "react";
3
+ import { chartSpec, createChartView, loadChartEngine } from "./chartEngine.js";
4
+ import { chartConfig, readChartTokens, SURFACE } from "./chartTheme.js";
5
+ import { Notice } from "./Notice.js";
6
+ /**
7
+ * A chart drawn from a Vega-Lite spec, in the theme's colors and font. The
8
+ * engine is fetched when the first chart appears.
9
+ */
10
+ export function Chart({ spec, data, title, description, height = 240, onPick }) {
11
+ const picking = useRef(onPick);
12
+ picking.current = onPick;
13
+ const picks = onPick !== undefined;
14
+ const container = useRef(null);
15
+ /** How to take down the drawing that is shown. */
16
+ const shown = useRef([]);
17
+ const [drawn, setDrawn] = useState(false);
18
+ const [failure, setFailure] = useState();
19
+ const [scheme, setScheme] = useState(0);
20
+ // A spec written inline is a new object on every render. Its text says whether it changed.
21
+ const specText = JSON.stringify(spec);
22
+ // Its rows too: the same rows read again draw nothing again.
23
+ const dataText = data === undefined ? undefined : JSON.stringify(data);
24
+ // The tokens change with the color scheme, and the chart holds their values, not the variables.
25
+ useEffect(() => {
26
+ const dark = globalThis.matchMedia?.("(prefers-color-scheme: dark)");
27
+ if (!dark)
28
+ return;
29
+ const redraw = () => setScheme((count) => count + 1);
30
+ dark.addEventListener("change", redraw);
31
+ return () => dark.removeEventListener("change", redraw);
32
+ }, []);
33
+ // `scheme` is a dependency so that the chart is drawn again with the new token values.
34
+ // biome-ignore lint/correctness/useExhaustiveDependencies: `scheme` is listed so the chart is drawn again with the new token values
35
+ useEffect(() => {
36
+ const element = container.current;
37
+ if (!element)
38
+ return;
39
+ let left = false;
40
+ let view;
41
+ // It is drawn out of sight over the one that is shown, and takes its place once it is drawn:
42
+ // a chart that changes is never blank in between.
43
+ const layer = document.createElement("div");
44
+ layer.className = "w-full";
45
+ const waiting = element.childElementCount > 0;
46
+ if (waiting) {
47
+ layer.style.cssText = "position:absolute;inset:0;visibility:hidden;pointer-events:none";
48
+ }
49
+ element.append(layer);
50
+ loadChartEngine()
51
+ .then((engine) => {
52
+ if (left)
53
+ return;
54
+ const tokens = readChartTokens(element);
55
+ const config = chartConfig(tokens);
56
+ // Where the spec names the color of what the chart sits on, the theme's value goes.
57
+ const painted = specText.replaceAll(JSON.stringify(SURFACE), JSON.stringify(tokens.surface || "transparent"));
58
+ view = createChartView(engine, chartSpec(JSON.parse(painted), dataText === undefined ? undefined : JSON.parse(dataText), height), config, layer);
59
+ if (picks) {
60
+ view.addEventListener("click", (_event, item) => {
61
+ const row = item?.datum;
62
+ if (row && typeof row === "object")
63
+ picking.current?.(row);
64
+ });
65
+ }
66
+ return view.runAsync();
67
+ })
68
+ .then(() => {
69
+ if (left)
70
+ return;
71
+ layer.removeAttribute("style");
72
+ for (const old of shown.current)
73
+ old();
74
+ shown.current = [remove];
75
+ setFailure(undefined);
76
+ setDrawn(true);
77
+ }, (caught) => {
78
+ if (!left)
79
+ setFailure(caught instanceof Error ? caught.message : String(caught));
80
+ });
81
+ const remove = () => {
82
+ view?.finalize();
83
+ layer.remove();
84
+ };
85
+ return () => {
86
+ left = true;
87
+ // One that is shown stays until the next is drawn; one that never was goes now.
88
+ if (!shown.current.includes(remove))
89
+ remove();
90
+ };
91
+ }, [specText, dataText, height, scheme, picks]);
92
+ useEffect(() => () => {
93
+ for (const old of shown.current)
94
+ old();
95
+ shown.current = [];
96
+ }, []);
97
+ return (_jsxs("div", { className: "relative w-full", children: [failure ? _jsxs(Notice, { tone: "danger", children: ["This chart could not be drawn. ", failure] }) : null, _jsx("div", { role: "img", "aria-label": description ? `${title}. ${description}` : title, hidden: failure !== undefined, children: _jsx("div", { ref: container, className: `relative w-full ${picks ? "[&_path]:cursor-pointer" : ""}`, style: { minHeight: `${height}px` } }) }), drawn || failure ? null : (_jsx("div", { "aria-hidden": "true", className: "absolute inset-0 flex animate-pulse items-center justify-center rounded-control bg-sunken text-body-sm text-ink-muted", children: "Loading chart" }))] }));
98
+ }
@@ -0,0 +1,45 @@
1
+ export interface Option {
2
+ value: string;
3
+ label: string;
4
+ /** A second line under the label, in muted text. */
5
+ hint?: string;
6
+ disabled?: boolean;
7
+ }
8
+ interface Common {
9
+ label: string;
10
+ /** Shown under the control. Says what is expected, not what went wrong. */
11
+ hint?: string | undefined;
12
+ error?: string | undefined;
13
+ options: readonly Option[];
14
+ placeholder?: string;
15
+ disabled?: boolean;
16
+ /** Marked with an asterisk, and read as required; `false` says it is optional (as the other fields do). */
17
+ required?: boolean | undefined;
18
+ /** What the list says when nothing matches what was typed. */
19
+ empty?: string;
20
+ }
21
+ export interface ComboboxFieldProps extends Common {
22
+ /** The chosen option's value, or nothing. */
23
+ value: string | undefined;
24
+ onChange: (value: string | undefined) => void;
25
+ /**
26
+ * Called with what is typed, for a list the server searches: `options` are
27
+ * then shown as given, without being narrowed here.
28
+ */
29
+ onSearch?: (typed: string) => void;
30
+ }
31
+ /** One choice from a list that can be searched by typing. Use it when a list is too long for a select. */
32
+ export declare function ComboboxField({ label, hint, error, options, value, onChange, onSearch, placeholder, disabled, required, empty, }: ComboboxFieldProps): import("react").JSX.Element;
33
+ export interface MultiSelectFieldProps extends Common {
34
+ /** The chosen options' values, in the order they were chosen. */
35
+ value: readonly string[];
36
+ onChange: (value: string[]) => void;
37
+ /**
38
+ * The list is drawn in the flow, under the box, and pushes what follows down (a dialog's Done),
39
+ * instead of over it as a popup. For a field in a dialog, where a popup would cover the button.
40
+ */
41
+ inline?: boolean;
42
+ }
43
+ /** Several choices from a list that can be searched by typing. Each choice shows as a chip. */
44
+ export declare function MultiSelectField({ label, hint, error, options, value, onChange, placeholder, disabled, required, empty, inline, }: MultiSelectFieldProps): import("react").JSX.Element;
45
+ export {};
@@ -0,0 +1,42 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Combobox as Base } from "@base-ui/react/combobox";
3
+ import { Check, X } from "lucide-react";
4
+ import { useState } from "react";
5
+ import { FieldFrame } from "./Fields.js";
6
+ const box = "flex min-h-control w-full flex-wrap items-center gap-1 rounded-control border border-line-control bg-surface px-1.5 py-1 focus-within:outline-2 focus-within:outline-offset-1 focus-within:outline-action data-[disabled]:opacity-60 has-[[aria-invalid=true]]:border-danger";
7
+ const input = "min-w-24 flex-1 bg-transparent px-1 text-ink outline-none! placeholder:text-ink-muted/70";
8
+ const popup = "max-h-72 w-[var(--anchor-width)] min-w-56 overflow-y-auto rounded-control border border-line bg-surface p-1 shadow-overlay transition-[opacity,translate] motion-base data-[ending-style]:opacity-0 data-[starting-style]:-translate-y-1 data-[starting-style]:opacity-0";
9
+ const row = "flex cursor-default items-start gap-2 rounded-inner px-2 py-1.5 data-[highlighted]:bg-action-soft data-[disabled]:opacity-50";
10
+ function Items({ empty }) {
11
+ return (_jsx(Base.Portal, { children: _jsx(Base.Positioner, { sideOffset: 4, className: "layer-popover", children: _jsxs(Base.Popup, { className: popup, children: [_jsx(Base.Empty, { className: "px-2 py-1.5 text-ink-muted empty:hidden", children: empty }), _jsx(Base.List, { children: (option) => (_jsxs(Base.Item, { value: option, className: row, ...(option.disabled ? { disabled: true } : {}), children: [_jsx(Base.ItemIndicator, { className: "flex w-3.5 text-action", children: _jsx(Check, { "aria-hidden": "true", size: 14 }) }), _jsxs("span", { className: "col-start-2 flex min-w-0 flex-col data-[selected]:font-medium", children: [_jsx("span", { className: "truncate", children: option.label }), option.hint ? (_jsx("span", { className: "text-meta break-words text-ink-muted", children: option.hint })) : null] })] }, option.value)) })] }) }) }));
12
+ }
13
+ const same = (a, b) => a.value === b.value;
14
+ const text = (option) => option.label;
15
+ /** One choice from a list that can be searched by typing. Use it when a list is too long for a select. */
16
+ export function ComboboxField({ label, hint, error, options, value, onChange, onSearch, placeholder, disabled, required, empty = "Nothing matches.", }) {
17
+ const chosen = options.find((option) => option.value === value) ?? null;
18
+ return (_jsx(FieldFrame, { label: label, ...(hint ? { hint } : {}), error: error, required: required, children: _jsxs(Base.Root, { items: options, value: chosen, onValueChange: (next) => onChange(next?.value), itemToStringLabel: text, isItemEqualToValue: same, ...(onSearch
19
+ ? { filter: null, onInputValueChange: (typed) => onSearch(typed) }
20
+ : {}), ...(disabled ? { disabled: true } : {}), ...(required ? { required: true } : {}), children: [_jsxs("div", { className: box, children: [_jsx(Base.Input, { className: input, ...(placeholder ? { placeholder } : {}) }), _jsx(Base.Clear, { "aria-label": "Clear", className: "px-1 text-ink-muted hover:text-ink", children: _jsx(X, { "aria-hidden": "true", size: 14 }) })] }), _jsx(Items, { empty: empty })] }) }));
21
+ }
22
+ /** The list drawn in place, for a field whose popup would cover what follows it. */
23
+ function InlineItems({ empty }) {
24
+ return (_jsxs("div", { className: "mt-1 max-h-56 overflow-y-auto rounded-control border border-line bg-surface p-1", children: [_jsx(Base.Empty, { className: "px-2 py-1.5 text-ink-muted empty:hidden", children: empty }), _jsx(Base.List, { children: (option) => (_jsxs(Base.Item, { value: option, className: row, ...(option.disabled ? { disabled: true } : {}), children: [_jsx(Base.ItemIndicator, { className: "flex w-3.5 text-action", children: _jsx(Check, { "aria-hidden": "true", size: 14 }) }), _jsx("span", { className: "truncate", children: option.label })] }, option.value)) })] }));
25
+ }
26
+ /** Several choices from a list that can be searched by typing. Each choice shows as a chip. */
27
+ export function MultiSelectField({ label, hint, error, options, value, onChange, placeholder, disabled, required, empty = "Nothing matches.", inline = false, }) {
28
+ // The list opens when the box takes the focus, not only when it is pressed. Esc closes the
29
+ // list first, and keeps what was picked: the dialog around it stays until the next Esc.
30
+ const [open, setOpen] = useState(false);
31
+ const chosen = value
32
+ .map((one) => options.find((option) => option.value === one))
33
+ .filter((option) => option !== undefined);
34
+ return (_jsx(FieldFrame, { label: label, ...(hint ? { hint } : {}), error: error, required: required, children: _jsxs(Base.Root, { multiple: true, items: options, value: chosen, onValueChange: (next) => onChange(next.map((option) => option.value)), itemToStringLabel: text, isItemEqualToValue: same, open: open, onOpenChange: (next) => setOpen(next), autoHighlight: true, ...(inline ? { inline: true } : {}), ...(disabled ? { disabled: true } : {}), ...(required ? { required: true } : {}), children: [_jsx(Base.Chips, { className: box, children: _jsx(Base.Value, { children: (selected) => (_jsxs(_Fragment, { children: [selected.map((option) => (_jsxs(Base.Chip, { "aria-label": option.label, className: "inline-flex items-center gap-1 rounded-inner bg-action-soft px-1.5 py-0.5 text-body-sm", children: [option.label, _jsx(Base.ChipRemove, { "aria-label": `Remove ${option.label}`, className: "text-ink-muted hover:text-ink", children: _jsx(X, { "aria-hidden": "true", size: 14 }) })] }, option.value))), _jsx(Base.Input, { className: input, onFocus: () => setOpen(true), onKeyDown: (event) => {
35
+ if (event.key === "Escape" && open) {
36
+ event.preventDefault();
37
+ event.stopPropagation();
38
+ event.nativeEvent.stopImmediatePropagation();
39
+ setOpen(false);
40
+ }
41
+ }, ...(placeholder && selected.length === 0 ? { placeholder } : {}) })] })) }) }), inline ? open ? _jsx(InlineItems, { empty: empty }) : null : _jsx(Items, { empty: empty })] }) }));
42
+ }
@@ -0,0 +1,16 @@
1
+ import type { ReactNode } from "react";
2
+ import type { MenuItem } from "./Menu.tsx";
3
+ /**
4
+ * A menu that opens where something is right-clicked, or from the keyboard
5
+ * with Shift+F10 or the Menu key on what has focus (08 §3.16). Its items have
6
+ * the same shape as `Menu`'s, so an action is offered the same way in both.
7
+ * `items` may depend on what was clicked: read it in `onOpen`.
8
+ */
9
+ export declare function ContextMenu({ items, children, onOpen, className, }: {
10
+ items: MenuItem[];
11
+ /** What a right-click opens the menu on. */
12
+ children: ReactNode;
13
+ /** Called as the menu opens, with what was right-clicked, so the items can be for it. */
14
+ onOpen?: ((target: Element | null) => void) | undefined;
15
+ className?: string;
16
+ }): import("react").JSX.Element;
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ContextMenu as Base } from "@base-ui/react/context-menu";
3
+ /** Shift+F10 and the Menu key: the keyboard's way to a context menu. */
4
+ const asksForMenu = (event) => event.key === "ContextMenu" || (event.key === "F10" && event.shiftKey);
5
+ /**
6
+ * A menu that opens where something is right-clicked, or from the keyboard
7
+ * with Shift+F10 or the Menu key on what has focus (08 §3.16). Its items have
8
+ * the same shape as `Menu`'s, so an action is offered the same way in both.
9
+ * `items` may depend on what was clicked: read it in `onOpen`.
10
+ */
11
+ export function ContextMenu({ items, children, onOpen, className = "", }) {
12
+ return (_jsxs(Base.Root, { children: [_jsx(Base.Trigger, { className: className,
13
+ // Browsers do not all send a right click for these keys, nor to the focused element, so the
14
+ // menu is opened here, at the element that has focus: the step or the canvas.
15
+ onKeyDown: (event) => {
16
+ const on = event.target;
17
+ if (event.defaultPrevented || !asksForMenu(event) || !(on instanceof HTMLElement))
18
+ return;
19
+ if (on.matches("input, textarea, select, [contenteditable]"))
20
+ return;
21
+ event.preventDefault();
22
+ const at = on.getBoundingClientRect();
23
+ // A small element is opened on at its lower edge; a large one (the canvas) near its corner.
24
+ const big = at.width > 320 || at.height > 240;
25
+ on.dispatchEvent(new MouseEvent("contextmenu", {
26
+ bubbles: true,
27
+ cancelable: true,
28
+ button: 2,
29
+ clientX: Math.round(big ? at.left + 24 : at.left + at.width / 2),
30
+ clientY: Math.round(big ? at.top + 24 : at.bottom),
31
+ }));
32
+ },
33
+ // Some systems send the menu on the key coming up: that one is already answered.
34
+ onKeyUp: (event) => {
35
+ if (asksForMenu(event))
36
+ event.preventDefault();
37
+ }, onContextMenu: (event) => onOpen?.(event.target instanceof Element ? event.target : null), children: children }), _jsx(Base.Portal, { children: _jsx(Base.Positioner, { className: "layer-popover", children: _jsx(Base.Popup, { className: "max-h-[70vh] min-w-44 overflow-y-auto rounded-control border border-line bg-surface p-1 shadow-overlay transition-[opacity,translate] motion-base data-[ending-style]:opacity-0 data-[starting-style]:opacity-0 data-[starting-style]:-translate-y-1", children: items.map((item) => (_jsxs("div", { children: [item.separated ? _jsx(Base.Separator, { className: "my-1 h-px bg-line" }) : null, _jsxs(Base.Item, { onClick: item.onSelect, className: `flex cursor-default items-center gap-2 rounded-inner px-3 py-1.5 data-[highlighted]:bg-action-soft ${item.danger ? "text-danger data-[highlighted]:bg-danger-soft" : ""}`, children: [item.icon ? _jsx("span", { className: "flex w-4 justify-center", children: item.icon }) : null, _jsx("span", { className: "min-w-0 flex-1 truncate", children: item.label }), item.keys ? (_jsx("kbd", { className: "font-mono text-code-sm text-ink-subtle", children: item.keys })) : null] })] }, item.label))) }) }) })] }));
38
+ }
@@ -0,0 +1,31 @@
1
+ export interface DateInputProps {
2
+ /** `2026-11-21`, or with `withTime` `2026-11-21T14:30`: no zone, the wall clock the field shows. */
3
+ value: string;
4
+ onChange: (value: string) => void;
5
+ withTime?: boolean;
6
+ /** Earliest and latest, in the same form as `value`. */
7
+ min?: string | undefined;
8
+ max?: string | undefined;
9
+ required?: boolean | undefined;
10
+ disabled?: boolean | undefined;
11
+ /** For a form posted as it is: the box is named and holds the value as `formValue`. */
12
+ name?: string | undefined;
13
+ formValue?: string | undefined;
14
+ /** Said under the box when what was typed can't be read. Without it, the box says so itself. */
15
+ onProblem?: (problem: string | undefined) => void;
16
+ /** What a surrounding field gives its control: id, aria-*, ref, focus handlers. */
17
+ boxProps?: Record<string, unknown> | undefined;
18
+ /** For a box that stands without a field: its name. */
19
+ "aria-label"?: string | undefined;
20
+ id?: string | undefined;
21
+ compact?: boolean;
22
+ /** A word inside the box, before the date ("From"), as a filter bar's other controls say theirs. */
23
+ inlineLabel?: string;
24
+ }
25
+ /**
26
+ * A date, or a date and a time, in a box the person types in: "Nov 21, 2026" in their locale, with
27
+ * a calendar behind the button at its end. What is typed is read by the locale's order, ISO, month
28
+ * names, "today", "tomorrow", "yesterday"; what can't be read is said and left as it was typed.
29
+ * The value in and out is a wall string. On a touch screen the button opens the phone's own picker.
30
+ */
31
+ export declare function DateInput({ value, onChange, withTime, min, max, required, disabled, name, formValue, onProblem, boxProps, id, compact, inlineLabel, ...rest }: DateInputProps): import("react").JSX.Element;