@momoi-labs/kiso-react 0.22.1 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accent-selector.d.ts +1 -1
- package/dist/accent-selector.js +3 -0
- package/dist/chart.d.ts +6 -2
- package/dist/chart.js +17 -3
- package/dist/code-block.d.ts +21 -0
- package/dist/code-block.js +148 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/scope-switcher.d.ts +49 -0
- package/dist/scope-switcher.js +297 -0
- package/dist/time-range-calendar.d.ts +12 -0
- package/dist/time-range-calendar.js +102 -0
- package/dist/time-range-control.d.ts +28 -12
- package/dist/time-range-control.js +41 -22
- package/dist/time-range-live.d.ts +18 -0
- package/dist/time-range-live.js +305 -0
- package/dist/time-range-shared.d.ts +91 -0
- package/dist/time-range-shared.js +87 -0
- package/dist/time-range-text.d.ts +13 -0
- package/dist/time-range-text.js +44 -0
- package/dist/time-zone.d.ts +15 -0
- package/dist/time-zone.js +121 -0
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const accents: readonly ["violet", "terracotta", "teal", "cobalt", "nocturne", "tangerine", "red", "gold", "lime"];
|
|
1
|
+
export declare const accents: readonly ["violet", "terracotta", "teal", "cobalt", "nocturne", "tangerine", "red", "gold", "lime", "plum", "stone", "steel"];
|
|
2
2
|
export type Accent = (typeof accents)[number];
|
|
3
3
|
export declare function AccentSelector({ accent, onChange, options, preview, }: {
|
|
4
4
|
accent: string;
|
package/dist/accent-selector.js
CHANGED
|
@@ -10,6 +10,9 @@ export const accents = [
|
|
|
10
10
|
"red",
|
|
11
11
|
"gold",
|
|
12
12
|
"lime",
|
|
13
|
+
"plum",
|
|
14
|
+
"stone",
|
|
15
|
+
"steel",
|
|
13
16
|
];
|
|
14
17
|
const label = (accent) => `${accent[0].toUpperCase()}${accent.slice(1)}`;
|
|
15
18
|
export function AccentSelector({ accent, onChange, options = accents, preview = true, }) {
|
package/dist/chart.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ declare const defaultLabels: {
|
|
|
11
11
|
values: string;
|
|
12
12
|
help: string;
|
|
13
13
|
summary: (label: string) => string;
|
|
14
|
-
samples: (label: string) => string;
|
|
14
|
+
samples: (label: string, timeZone: string) => string;
|
|
15
15
|
};
|
|
16
16
|
export type ChartProps = Omit<React.ComponentProps<"figure">, "children"> & {
|
|
17
17
|
data: readonly ChartSample[];
|
|
@@ -31,6 +31,10 @@ export type ChartProps = Omit<React.ComponentProps<"figure">, "children"> & {
|
|
|
31
31
|
/** Panels in a group inspect the same timestamp, not the same array index. */
|
|
32
32
|
syncId?: string;
|
|
33
33
|
formatTime?: (timestamp: number) => string;
|
|
34
|
+
/** IANA time zone for times. With timeZone and locale both omitted, times
|
|
35
|
+
stay UTC ISO strings. */
|
|
36
|
+
timeZone?: string;
|
|
37
|
+
locale?: string;
|
|
34
38
|
formatValue?: (value: number) => string;
|
|
35
39
|
min?: number;
|
|
36
40
|
max?: number;
|
|
@@ -40,4 +44,4 @@ export type ChartProps = Omit<React.ComponentProps<"figure">, "children"> & {
|
|
|
40
44
|
/** Localizes the fixed text. Chart passes the legend's keys on to ChartLegend. */
|
|
41
45
|
labels?: Partial<typeof defaultLabels> & NonNullable<ChartLegendProps["labels"]>;
|
|
42
46
|
} & ChartTreatmentProps;
|
|
43
|
-
export declare function Chart({ data, series, label, variant, layout: layoutProp, legend: legendProp, summary, highlightSeries, onHighlightSeriesChange, height: heightProp, syncId, formatTime, formatValue, min, max, onRangeSelect, labels, chartStyle, chartLine, chartFill, ref, className, onKeyDown, ...props }: ChartProps): React.JSX.Element;
|
|
47
|
+
export declare function Chart({ data, series, label, variant, layout: layoutProp, legend: legendProp, summary, highlightSeries, onHighlightSeriesChange, height: heightProp, syncId, formatTime: formatTimeProp, timeZone, locale, formatValue, min, max, onRangeSelect, labels, chartStyle, chartLine, chartFill, ref, className, onKeyDown, ...props }: ChartProps): React.JSX.Element;
|
package/dist/chart.js
CHANGED
|
@@ -9,16 +9,30 @@ import { ChartDot, ChartPattern, pixelCurve, useChartPresentation, useChartStyle
|
|
|
9
9
|
import { useChartFill } from "./chart-fill.js";
|
|
10
10
|
import { chartPinned, clearChartPin, setChartHover, toggleChartPin, useChartSync } from "./chart-sync.js";
|
|
11
11
|
import { chartColor, chartSlot, formatChartTime, formatChartValue, measured, validateChart } from "./chart-data.js";
|
|
12
|
+
import { dateFormat, validTimeZone } from "./time-zone.js";
|
|
12
13
|
const defaultLabels = {
|
|
13
14
|
notCollected: "Not collected", empty: "No collected samples in this window.",
|
|
14
15
|
timestamp: "Timestamp", values: "View exact values",
|
|
15
16
|
help: "Focus the chart and use Left and Right to inspect samples. Press Enter to mark the inspected sample in every synchronized chart, and Escape to clear it. Select a series in the legend to highlight it. Exact values are available below.",
|
|
16
17
|
summary: (label) => `${label}: summary`,
|
|
17
|
-
samples: (label) => `${label}: collected samples, timestamps in
|
|
18
|
+
samples: (label, timeZone) => `${label}: collected samples, timestamps in ${timeZone}`,
|
|
18
19
|
};
|
|
19
|
-
export function Chart({ data, series, label, variant = "line", layout: layoutProp, legend: legendProp, summary, highlightSeries, onHighlightSeriesChange, height: heightProp, syncId, formatTime
|
|
20
|
+
export function Chart({ data, series, label, variant = "line", layout: layoutProp, legend: legendProp, summary, highlightSeries, onHighlightSeriesChange, height: heightProp, syncId, formatTime: formatTimeProp, timeZone, locale, formatValue = formatChartValue, min, max, onRangeSelect, labels, chartStyle, chartLine, chartFill, ref, className, onKeyDown, ...props }) {
|
|
20
21
|
const id = React.useId();
|
|
21
22
|
const text = { ...defaultLabels, ...labels };
|
|
23
|
+
const zoned = timeZone !== undefined || locale !== undefined;
|
|
24
|
+
const zone = timeZone ?? "UTC";
|
|
25
|
+
if (zoned && !validTimeZone(zone))
|
|
26
|
+
throw new RangeError("Chart time zone must be a valid IANA name.");
|
|
27
|
+
const zonedTime = React.useCallback((timestamp) => dateFormat(locale, { timeZone: zone,
|
|
28
|
+
hour: "2-digit", minute: "2-digit", second: "2-digit" }).format(timestamp), [locale, zone]);
|
|
29
|
+
const formatTime = formatTimeProp ?? (zoned ? zonedTime : formatChartTime);
|
|
30
|
+
// The exact table always names the date, the second, and the offset.
|
|
31
|
+
const fractional = data.some(sample => sample.timestamp % 1000 !== 0);
|
|
32
|
+
const exactTime = zoned ? (timestamp) => dateFormat(locale, { timeZone: zone, year: "numeric",
|
|
33
|
+
month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit",
|
|
34
|
+
...(fractional ? { fractionalSecondDigits: 3 } : {}), timeZoneName: "longOffset" }).format(timestamp)
|
|
35
|
+
: formatChartTime;
|
|
22
36
|
const frame = React.useRef(null);
|
|
23
37
|
const { line, fill } = useChartStyle(frame, { chartStyle, chartLine, chartFill });
|
|
24
38
|
const presentation = useChartPresentation(frame, layoutProp, legendProp);
|
|
@@ -193,7 +207,7 @@ export function Chart({ data, series, label, variant = "line", layout: layoutPro
|
|
|
193
207
|
toggleChartPin(group, inspected.current);
|
|
194
208
|
}
|
|
195
209
|
}, children: [_jsx("figcaption", { id: `${id}-title`, className: "t-h3", children: label }), _jsx("p", { id: `${id}-help`, className: "chart-help", children: text.help }), _jsxs("div", { className: "chart-body", children: [_jsx("div", { className: "chart-plots", children: hasData ? layout === "split" ? series.map((item, index) => _jsxs("div", { className: "chart-lane", children: [_jsxs("div", { className: "chart-lane-heading", children: [_jsx(ChartSeriesLabel, { series: item, index: index }), _jsx("span", { children: displayValue(data.at(-1)?.values[item.key]) })] }), renderPlot([index], item)] }, item.key)) : renderPlot(series.map((_, index) => index))
|
|
196
|
-
: _jsx("div", { className: "chart-empty hatch", style: { minHeight: height }, children: text.empty }) }), legend === "sidebar" && legendContent] }), legend !== "sidebar" && legendContent, _jsxs("details", { className: "disclosure chart-values", children: [_jsx("summary", { children: text.values }), _jsx("div", { className: "chart-table-scroll", children: _jsxs("table", { className: "chart-table", children: [_jsx("caption", { children: text.samples(label) }), _jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", children: text.timestamp }), series.map(item => _jsx("th", { scope: "col", children: item.label }, item.key))] }) }), _jsx("tbody", { children: data.map(sample => _jsxs("tr", { children: [_jsx("th", { scope: "row", children:
|
|
210
|
+
: _jsx("div", { className: "chart-empty hatch", style: { minHeight: height }, children: text.empty }) }), legend === "sidebar" && legendContent] }), legend !== "sidebar" && legendContent, _jsxs("details", { className: "disclosure chart-values", children: [_jsx("summary", { children: text.values }), _jsx("div", { className: "chart-table-scroll", children: _jsxs("table", { className: "chart-table", children: [_jsx("caption", { children: text.samples(label, zone) }), _jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", children: text.timestamp }), series.map(item => _jsx("th", { scope: "col", children: item.label }, item.key))] }) }), _jsx("tbody", { children: data.map(sample => _jsxs("tr", { children: [_jsx("th", { scope: "row", children: exactTime(sample.timestamp) }), series.map(item => _jsx("td", { children: measured(sample.values[item.key]) ? String(sample.values[item.key]) : text.notCollected }, item.key))] }, sample.timestamp)) })] }) })] })] });
|
|
197
211
|
}
|
|
198
212
|
// Observe Recharts' synchronized tooltip state after render. This keeps the
|
|
199
213
|
// sidebar on the same timestamp for mouse, keyboard, touch, and sibling panels.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ComponentProps, type ReactNode } from "react";
|
|
2
|
+
import type { CodeEditorHighlight } from "./code-editor.js";
|
|
3
|
+
export type CodeBlockProps = Omit<ComponentProps<"figure">, "children" | "title"> & {
|
|
4
|
+
code: string;
|
|
5
|
+
/** Paints the code, as CodeEditor's `highlight`: React nodes or HTML as `{ __html }`. */
|
|
6
|
+
highlight?: CodeEditorHighlight;
|
|
7
|
+
title?: ReactNode;
|
|
8
|
+
/** Marks the block as commands to run in a terminal. */
|
|
9
|
+
terminal?: boolean;
|
|
10
|
+
lineNumbers?: boolean;
|
|
11
|
+
/** Reads the first column as `+`, `-` or a space, marks the line and paints the rest. */
|
|
12
|
+
diff?: boolean;
|
|
13
|
+
/** 1-based line numbers to mark as added or removed. */
|
|
14
|
+
added?: number[];
|
|
15
|
+
removed?: number[];
|
|
16
|
+
/** 1-based, inclusive line ranges that start folded. */
|
|
17
|
+
collapse?: [number, number][];
|
|
18
|
+
/** The value type for the copy action, as in "command". Shows Copy; needs Toasts. */
|
|
19
|
+
copy?: string;
|
|
20
|
+
};
|
|
21
|
+
export declare function CodeBlock({ code, highlight, title, terminal, lineNumbers, diff, added, removed, collapse, copy, className, ...props }: CodeBlockProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cloneElement, createElement, isValidElement, useState } from "react";
|
|
4
|
+
import { clsx as cn } from "clsx";
|
|
5
|
+
import { Check, Copy } from "lucide-react";
|
|
6
|
+
import { Button } from "./button.js";
|
|
7
|
+
import { TerminalIcon } from "./terminal-icon.js";
|
|
8
|
+
import { useToast } from "./toast.js";
|
|
9
|
+
// A highlight paints the whole value, so a token can span lines. These split
|
|
10
|
+
// the painted value back into lines, reopening any element a newline cuts.
|
|
11
|
+
function splitNode(node) {
|
|
12
|
+
if (node == null || typeof node === "boolean")
|
|
13
|
+
return [[]];
|
|
14
|
+
if (typeof node === "string" || typeof node === "number")
|
|
15
|
+
return String(node).split("\n").map(part => part ? [part] : []);
|
|
16
|
+
if (Array.isArray(node))
|
|
17
|
+
return node.reduce((lines, child) => {
|
|
18
|
+
const [first, ...rest] = splitNode(child);
|
|
19
|
+
lines[lines.length - 1].push(...first);
|
|
20
|
+
return [...lines, ...rest];
|
|
21
|
+
}, [[]]);
|
|
22
|
+
if (isValidElement(node)) {
|
|
23
|
+
return splitNode(node.props.children).map((parts, index) => parts.length ? [cloneElement(node, { key: `${node.key ?? ""}:${index}` }, ...parts)] : []);
|
|
24
|
+
}
|
|
25
|
+
return [[node]];
|
|
26
|
+
}
|
|
27
|
+
// A tag, with `>` allowed inside quoted attribute values, or a run of text.
|
|
28
|
+
const htmlPart = /<\/?[a-z][^>"']*(?:(?:"[^"]*"|'[^']*')[^>"']*)*>|[^<]+|</gi;
|
|
29
|
+
function splitHTML(html) {
|
|
30
|
+
const lines = [""];
|
|
31
|
+
const open = [];
|
|
32
|
+
for (const [part] of html.matchAll(htmlPart)) {
|
|
33
|
+
if (part === "<") {
|
|
34
|
+
lines[lines.length - 1] += "<";
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (part.startsWith("</"))
|
|
38
|
+
open.pop();
|
|
39
|
+
else if (part.startsWith("<") && !part.endsWith("/>"))
|
|
40
|
+
open.push([part, /^<([a-z0-9-]+)/i.exec(part)[1]]);
|
|
41
|
+
if (part.startsWith("<")) {
|
|
42
|
+
lines[lines.length - 1] += part;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
part.split("\n").forEach((text, index) => {
|
|
46
|
+
if (index) {
|
|
47
|
+
lines[lines.length - 1] += open.map(([, name]) => `</${name}>`).reverse().join("");
|
|
48
|
+
lines.push(open.map(([tag]) => tag).join(""));
|
|
49
|
+
}
|
|
50
|
+
lines[lines.length - 1] += text;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return lines;
|
|
54
|
+
}
|
|
55
|
+
const entities = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'", nbsp: "\u00a0" };
|
|
56
|
+
const htmlText = (html) => html.replace(/<[^>"']*(?:(?:"[^"]*"|'[^']*')[^>"']*)*>/g, "")
|
|
57
|
+
.replace(/&(#x[\da-f]+|#\d+|[a-z]+);/gi, (entity, name) => name[0] !== "#" ? entities[name.toLowerCase()] ?? entity
|
|
58
|
+
: String.fromCodePoint(parseInt(name.slice(name[1].toLowerCase() === "x" ? 2 : 1), name[1].toLowerCase() === "x" ? 16 : 10)));
|
|
59
|
+
// The text a split line will show. A component that takes its text from
|
|
60
|
+
// another prop yields none here, so its line no longer matches the source.
|
|
61
|
+
const nodeText = (node) => node == null || typeof node === "boolean" ? ""
|
|
62
|
+
: typeof node === "string" || typeof node === "number" ? String(node)
|
|
63
|
+
: Array.isArray(node) ? node.map(nodeText).join("")
|
|
64
|
+
: isValidElement(node) ? nodeText(node.props.children) : "";
|
|
65
|
+
// A highlight must keep the value's characters. When the painted lines do not
|
|
66
|
+
// read the same as the source, the block shows the source unpainted.
|
|
67
|
+
function paint(code, highlight) {
|
|
68
|
+
const rows = code.split("\n");
|
|
69
|
+
const painted = highlight?.(code);
|
|
70
|
+
if (painted == null || painted === false || painted === "")
|
|
71
|
+
return rows;
|
|
72
|
+
if (typeof painted === "object" && "__html" in painted) {
|
|
73
|
+
const lines = splitHTML(painted.__html);
|
|
74
|
+
if (lines.length !== rows.length || lines.some((line, index) => htmlText(line) !== rows[index]))
|
|
75
|
+
return rows;
|
|
76
|
+
return lines.map((__html, index) => _jsx("span", { dangerouslySetInnerHTML: { __html } }, index));
|
|
77
|
+
}
|
|
78
|
+
const lines = splitNode(painted);
|
|
79
|
+
if (lines.length !== rows.length || lines.some((parts, index) => nodeText(parts) !== rows[index]))
|
|
80
|
+
return rows;
|
|
81
|
+
return lines.map(parts => createElement("span", null, ...parts));
|
|
82
|
+
}
|
|
83
|
+
// The console also runs on plain HTTP, where the Clipboard API is missing.
|
|
84
|
+
async function writeClipboard(text) {
|
|
85
|
+
if (navigator.clipboard && window.isSecureContext)
|
|
86
|
+
return navigator.clipboard.writeText(text);
|
|
87
|
+
const focused = document.activeElement;
|
|
88
|
+
const area = Object.assign(document.createElement("textarea"), { value: text, readOnly: true });
|
|
89
|
+
area.style.cssText = "position:fixed;inset-block-start:0;opacity:0";
|
|
90
|
+
document.body.append(area);
|
|
91
|
+
area.select();
|
|
92
|
+
let copied = false;
|
|
93
|
+
try {
|
|
94
|
+
copied = document.execCommand("copy");
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
area.remove();
|
|
98
|
+
focused?.focus();
|
|
99
|
+
}
|
|
100
|
+
if (!copied)
|
|
101
|
+
throw new Error("Copy failed");
|
|
102
|
+
}
|
|
103
|
+
function CopyButton({ code, label }) {
|
|
104
|
+
const notify = useToast();
|
|
105
|
+
const [copied, setCopied] = useState(false);
|
|
106
|
+
const name = label[0].toUpperCase() + label.slice(1);
|
|
107
|
+
return _jsxs(Button, { size: "xs", variant: "ghost", "aria-label": `${copied ? "Copied" : "Copy"} ${label}`, onClick: async () => {
|
|
108
|
+
try {
|
|
109
|
+
await writeClipboard(code);
|
|
110
|
+
notify("success", `${name} copied`);
|
|
111
|
+
setCopied(true);
|
|
112
|
+
setTimeout(() => setCopied(false), 6000);
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
notify("error", `${name} was not copied`, "Clipboard access was blocked. Select the value and copy it manually.");
|
|
116
|
+
}
|
|
117
|
+
}, children: [copied ? _jsx(Check, { className: "icon", "aria-hidden": "true" }) : _jsx(Copy, { className: "icon", "aria-hidden": "true" }), copied ? "Copied" : "Copy"] });
|
|
118
|
+
}
|
|
119
|
+
export function CodeBlock({ code, highlight, title, terminal = false, lineNumbers = false, diff = false, added = [], removed = [], collapse = [], copy, className, ...props }) {
|
|
120
|
+
const rows = code.split("\n");
|
|
121
|
+
const changes = rows.map((row, index) => diff
|
|
122
|
+
? (row[0] === "+" ? "added" : row[0] === "-" ? "removed" : undefined)
|
|
123
|
+
: added.includes(index + 1) ? "added" : removed.includes(index + 1) ? "removed" : undefined);
|
|
124
|
+
const source = diff ? rows.map(row => /^[+\- ]/.test(row) ? row.slice(1) : row).join("\n") : code;
|
|
125
|
+
const lines = paint(source, highlight);
|
|
126
|
+
const markers = changes.some(Boolean);
|
|
127
|
+
const [open, setOpen] = useState([]);
|
|
128
|
+
// A title captions the figure; without one, the header holds only controls.
|
|
129
|
+
const Header = title != null ? "figcaption" : "div";
|
|
130
|
+
const line = (index) => _jsxs("span", { className: "code-block-line", "data-change": changes[index], children: [lineNumbers && _jsx("span", { className: "code-block-number", "aria-hidden": "true", children: index + 1 }), markers && _jsx("span", { className: "code-block-marker", "aria-hidden": "true", children: changes[index] === "added" ? "+" : changes[index] === "removed" ? "−" : " " }), changes[index] && _jsx("span", { className: "code-block-change", children: changes[index] === "added" ? "Added line: " : "Removed line: " }), lines[index], "\n"] }, index);
|
|
131
|
+
const body = [];
|
|
132
|
+
for (let index = 0; index < lines.length; index++) {
|
|
133
|
+
const range = collapse.findIndex(([from, to]) => from === index + 1 && to >= from && to <= lines.length);
|
|
134
|
+
if (range === -1) {
|
|
135
|
+
body.push(line(index));
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
const [from, to] = collapse[range];
|
|
139
|
+
const expanded = open.includes(range);
|
|
140
|
+
const count = to - from + 1;
|
|
141
|
+
body.push(_jsxs("span", { className: "code-block-line code-block-fold", children: [_jsx("button", { type: "button", "aria-expanded": expanded, onClick: () => setOpen(current => expanded ? current.filter(item => item !== range) : [...current, range]), children: expanded ? `Hide ${count} lines` : `Show ${count} hidden lines` }), "\n"] }, `fold-${range}`));
|
|
142
|
+
if (expanded)
|
|
143
|
+
for (let folded = from - 1; folded < to; folded++)
|
|
144
|
+
body.push(line(folded));
|
|
145
|
+
index = to - 1;
|
|
146
|
+
}
|
|
147
|
+
return (_jsxs("figure", { className: cn("code-block", className), "data-slot": "code-block", "data-terminal": terminal || undefined, style: { "--code-block-digits": String(lines.length).length }, ...props, children: [(title != null || terminal || copy) && _jsxs(Header, { className: "code-block-header", children: [terminal && _jsx(TerminalIcon, {}), title != null && _jsx("span", { className: "code-block-title", children: title }), copy && _jsx(CopyButton, { code: code, label: copy })] }), _jsx("pre", { children: _jsx("code", { children: body }) })] }));
|
|
148
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from "./button.js";
|
|
|
9
9
|
export * from "./card.js";
|
|
10
10
|
export * from "./checkbox.js";
|
|
11
11
|
export * from "./chip-input.js";
|
|
12
|
+
export * from "./code-block.js";
|
|
12
13
|
export * from "./code-editor.js";
|
|
13
14
|
export * from "./filter-input.js";
|
|
14
15
|
export * from "./filter-expression.js";
|
|
@@ -31,6 +32,7 @@ export * from "./navigation.js";
|
|
|
31
32
|
export * from "./page-header.js";
|
|
32
33
|
export * from "./pagination.js";
|
|
33
34
|
export * from "./popover.js";
|
|
35
|
+
export * from "./scope-switcher.js";
|
|
34
36
|
export * from "./search.js";
|
|
35
37
|
export * from "./select.js";
|
|
36
38
|
export * from "./detail-select.js";
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export * from "./button.js";
|
|
|
10
10
|
export * from "./card.js";
|
|
11
11
|
export * from "./checkbox.js";
|
|
12
12
|
export * from "./chip-input.js";
|
|
13
|
+
export * from "./code-block.js";
|
|
13
14
|
export * from "./code-editor.js";
|
|
14
15
|
export * from "./filter-input.js";
|
|
15
16
|
export * from "./filter-expression.js";
|
|
@@ -32,6 +33,7 @@ export * from "./navigation.js";
|
|
|
32
33
|
export * from "./page-header.js";
|
|
33
34
|
export * from "./pagination.js";
|
|
34
35
|
export * from "./popover.js";
|
|
36
|
+
export * from "./scope-switcher.js";
|
|
35
37
|
export * from "./search.js";
|
|
36
38
|
export * from "./select.js";
|
|
37
39
|
export * from "./detail-select.js";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
type ScopeOption = {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
group?: string;
|
|
7
|
+
};
|
|
8
|
+
type ScopeSegmentLabels = {
|
|
9
|
+
/** Popup name. Defaults to "Switch <level>". */
|
|
10
|
+
dialog?: string;
|
|
11
|
+
/** Listbox name. Defaults to the level. */
|
|
12
|
+
list?: string;
|
|
13
|
+
/** Filter name. Defaults to "Filter <list>". */
|
|
14
|
+
filter?: string;
|
|
15
|
+
loading?: string;
|
|
16
|
+
error?: string;
|
|
17
|
+
retry?: string;
|
|
18
|
+
/** Status and trigger text when the level has no choices. */
|
|
19
|
+
empty?: string;
|
|
20
|
+
noMatches?: (query: string) => string;
|
|
21
|
+
/** Trigger name suffix while the current name is unknown. */
|
|
22
|
+
unknown?: string;
|
|
23
|
+
};
|
|
24
|
+
type ScopeSegmentProps = {
|
|
25
|
+
/** Level name, the start of the trigger's accessible name. */
|
|
26
|
+
level: string;
|
|
27
|
+
value?: string;
|
|
28
|
+
options: ScopeOption[];
|
|
29
|
+
all?: {
|
|
30
|
+
value: string;
|
|
31
|
+
label: string;
|
|
32
|
+
};
|
|
33
|
+
/** Current name while options are not loaded, for example from the URL. */
|
|
34
|
+
currentLabel?: string;
|
|
35
|
+
searchable?: boolean;
|
|
36
|
+
status?: "ready" | "loading" | "error";
|
|
37
|
+
onRetry?: () => void;
|
|
38
|
+
onValueChange: (value: string) => void;
|
|
39
|
+
destinations?: React.ReactNode;
|
|
40
|
+
labels?: ScopeSegmentLabels;
|
|
41
|
+
className?: string;
|
|
42
|
+
};
|
|
43
|
+
declare function ScopeSwitcher({ className, children, "aria-label": ariaLabel, ...props }: React.ComponentProps<"nav">): React.JSX.Element;
|
|
44
|
+
declare function ScopeSegment(props: ScopeSegmentProps): React.JSX.Element;
|
|
45
|
+
declare function ScopeDestination({ className, asChild, onClick, ...props }: React.ComponentProps<"a"> & {
|
|
46
|
+
asChild?: boolean;
|
|
47
|
+
}): React.JSX.Element;
|
|
48
|
+
export { ScopeSwitcher, ScopeSegment, ScopeDestination };
|
|
49
|
+
export type { ScopeOption, ScopeSegmentProps, ScopeSegmentLabels };
|