@momoi-labs/kiso-react 0.35.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/accent-selector.d.ts +1 -1
- package/dist/accent-selector.js +3 -2
- package/dist/alert.d.ts +37 -3
- package/dist/alert.js +104 -5
- package/dist/chart-legend.js +4 -1
- package/dist/chart-style.d.ts +3 -1
- package/dist/chart-style.js +15 -7
- package/dist/chart.js +8 -4
- package/dist/clipboard.d.ts +1 -0
- package/dist/clipboard.js +20 -0
- package/dist/code-block.js +1 -20
- package/dist/loud-mark.d.ts +7 -0
- package/dist/loud-mark.js +27 -0
- package/dist/pane-grid.d.ts +2 -1
- package/dist/pane-grid.js +2 -2
- package/dist/styles.css +4 -4
- package/dist/toast.d.ts +8 -3
- package/dist/toast.js +8 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -85,7 +85,8 @@ Data and structure
|
|
|
85
85
|
- Split, Pane, and Splitter, a list-detail layout with a resizable divider.
|
|
86
86
|
- PaneGrid and GridPane, summary panes on twelve columns that the reader
|
|
87
87
|
resizes at the end edge and moves by the title. `onLayoutChange` reports
|
|
88
|
-
the rows and sizes for the product to persist.
|
|
88
|
+
the rows and sizes for the product to persist. `frame="none"` on a pane
|
|
89
|
+
draws no Card, for a pane that holds one TableFrame.
|
|
89
90
|
- LogView, LogViewLine, LogViewTime, and LogViewLevel.
|
|
90
91
|
- StepList, a run's steps with a state each, and StepBar, the same run as
|
|
91
92
|
one segment per step for a summary, a table cell, or a toast.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const accents: readonly ["violet", "terracotta", "teal", "cobalt", "nocturne", "tangerine", "red", "gold", "lime", "plum", "stone", "steel", "snes", "pine"];
|
|
1
|
+
export declare const accents: readonly ["violet", "terracotta", "teal", "cobalt", "nocturne", "tangerine", "red", "gold", "lime", "plum", "stone", "steel", "snes", "pine", "blueprint"];
|
|
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
|
@@ -15,8 +15,9 @@ export const accents = [
|
|
|
15
15
|
"steel",
|
|
16
16
|
"snes",
|
|
17
17
|
"pine",
|
|
18
|
+
"blueprint",
|
|
18
19
|
];
|
|
19
|
-
const label = (accent) => `${accent[0].toUpperCase()}${accent.slice(1)}`;
|
|
20
|
+
const label = (accent) => accent === "snes" ? "SNES" : `${accent[0].toUpperCase()}${accent.slice(1)}`;
|
|
20
21
|
export function AccentSelector({ accent, onChange, options = accents, preview = true, }) {
|
|
21
|
-
return (_jsxs("div", { className: "accent-row", children: [_jsxs("div", { className: "theme-row", children: [_jsx("span", { className: "t-label", children: "Accent" }), _jsx("div", { className: "accent-pills", role: "group", "aria-label": "Accent", children: options.map((option) => (_jsxs("button", { type: "button", className: "accent-pill", "aria-pressed": accent === option,
|
|
22
|
+
return (_jsxs("div", { className: "accent-row", children: [_jsxs("div", { className: "theme-row", children: [_jsx("span", { className: "t-label", children: "Accent" }), _jsx("div", { className: "accent-pills", role: "group", "aria-label": "Accent", children: options.map((option) => (_jsxs("button", { type: "button", className: "accent-pill", "aria-pressed": accent === option, onClick: () => onChange(option), children: [_jsx("span", { className: "accent-dot", "data-accent": option, "aria-hidden": "true" }), label(option)] }, option))) })] }), preview && (_jsxs("div", { className: "accent-preview", "data-accent": accent, "aria-hidden": "true", children: [_jsxs("span", { className: "accent-preview-sidebar", children: [_jsx("i", {}), _jsx("i", {}), _jsx("i", {}), _jsx("i", {})] }), _jsxs("span", { className: "accent-preview-main", children: [_jsx("i", { className: "accent-preview-title" }), _jsx("i", { className: "accent-preview-text" }), _jsx("i", { className: "accent-preview-link" }), _jsxs("span", { className: "accent-preview-actions", children: [_jsx("i", { className: "accent-preview-primary" }), _jsx("i", { className: "accent-preview-secondary" })] }), _jsx("i", { className: "accent-preview-selected" })] })] }))] }));
|
|
22
23
|
}
|
package/dist/alert.d.ts
CHANGED
|
@@ -2,10 +2,44 @@ import * as React from "react";
|
|
|
2
2
|
import { type VariantProps } from "class-variance-authority";
|
|
3
3
|
declare const alertVariants: (props?: ({
|
|
4
4
|
variant?: "error" | "info" | "success" | "warning" | null | undefined;
|
|
5
|
-
appearance?: "rail" | "tinted" | null | undefined;
|
|
5
|
+
appearance?: "loud" | "rail" | "tinted" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
-
|
|
7
|
+
type AlertVariant = "info" | "success" | "warning" | "error";
|
|
8
|
+
type AlertTape = "top" | "start" | "top-bottom" | "start-end" | "none";
|
|
9
|
+
type AlertLabels = {
|
|
10
|
+
show?: string;
|
|
11
|
+
hide?: string;
|
|
12
|
+
dismiss?: string;
|
|
13
|
+
};
|
|
14
|
+
declare function Alert({ className, variant, appearance, tape, animated, pulse, placement, onDismiss, labels, role, ref, children, ...props }: React.ComponentProps<"div"> & VariantProps<typeof alertVariants> & {
|
|
15
|
+
tape?: AlertTape;
|
|
16
|
+
animated?: boolean;
|
|
17
|
+
pulse?: boolean;
|
|
18
|
+
placement?: "inline" | "overlay";
|
|
19
|
+
onDismiss?: () => void;
|
|
20
|
+
labels?: AlertLabels;
|
|
21
|
+
}): React.JSX.Element;
|
|
8
22
|
declare function AlertContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
9
23
|
declare function AlertTitle({ className, ...props }: React.ComponentProps<"p">): React.JSX.Element;
|
|
24
|
+
declare function AlertLabel({ className, ...props }: React.ComponentProps<"p">): React.JSX.Element;
|
|
25
|
+
declare function AlertMessage({ className, ...props }: React.ComponentProps<"p">): React.JSX.Element;
|
|
26
|
+
declare function AlertMeta({ className, ...props }: React.ComponentProps<"p">): React.JSX.Element;
|
|
10
27
|
declare function AlertDescription({ className, ...props }: React.ComponentProps<"p">): React.JSX.Element;
|
|
11
|
-
|
|
28
|
+
declare function AlertDetails({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
29
|
+
declare function AlertCode({ code, className, ...props }: Omit<React.ComponentProps<"span">, "children"> & {
|
|
30
|
+
code: string;
|
|
31
|
+
}): React.JSX.Element;
|
|
32
|
+
declare function AlertHelp({ action, className, children, ...props }: React.ComponentProps<"div"> & {
|
|
33
|
+
action?: React.ReactNode;
|
|
34
|
+
}): React.JSX.Element;
|
|
35
|
+
declare function AlertEvidence({ origin, className, ...props }: React.ComponentProps<"ol"> & {
|
|
36
|
+
origin: string;
|
|
37
|
+
}): React.JSX.Element;
|
|
38
|
+
declare function AlertLine({ at, role, label, className, children, ...props }: Omit<React.ComponentProps<"li">, "role"> & {
|
|
39
|
+
at: React.ReactNode;
|
|
40
|
+
role?: "primary";
|
|
41
|
+
label?: React.ReactNode;
|
|
42
|
+
}): React.JSX.Element;
|
|
43
|
+
declare function AlertNote({ className, children, ...props }: React.ComponentProps<"p">): React.JSX.Element;
|
|
44
|
+
export { Alert, AlertContent, AlertLabel, AlertTitle, AlertMessage, AlertDescription, AlertMeta, AlertDetails, AlertCode, AlertHelp, AlertEvidence, AlertLine, AlertNote, alertVariants, };
|
|
45
|
+
export type { AlertLabels, AlertTape, AlertVariant };
|
package/dist/alert.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
2
4
|
import { cva } from "class-variance-authority";
|
|
3
5
|
import { clsx as cn } from "clsx";
|
|
6
|
+
import { ChevronDown, X } from "lucide-react";
|
|
7
|
+
import { Portal as PortalPrimitive } from "radix-ui";
|
|
8
|
+
import { Button } from "./button.js";
|
|
9
|
+
import { writeClipboard } from "./clipboard.js";
|
|
10
|
+
import { LoudMark } from "./loud-mark.js";
|
|
11
|
+
import { useIsomorphicLayoutEffect } from "./use-isomorphic-layout-effect.js";
|
|
4
12
|
const alertVariants = cva("alert", {
|
|
5
13
|
variants: {
|
|
6
14
|
variant: {
|
|
@@ -9,12 +17,75 @@ const alertVariants = cva("alert", {
|
|
|
9
17
|
warning: "alert-warning",
|
|
10
18
|
error: "alert-danger",
|
|
11
19
|
},
|
|
12
|
-
appearance: { tinted: "", rail: "alert-rail" },
|
|
20
|
+
appearance: { tinted: "", rail: "alert-rail", loud: "alert-loud" },
|
|
13
21
|
},
|
|
14
22
|
defaultVariants: { variant: "info", appearance: "tinted" },
|
|
15
23
|
});
|
|
16
|
-
|
|
17
|
-
|
|
24
|
+
const overlayStore = {
|
|
25
|
+
stack: [],
|
|
26
|
+
listeners: new Set(),
|
|
27
|
+
set(stack) {
|
|
28
|
+
overlayStore.stack = stack;
|
|
29
|
+
overlayStore.listeners.forEach((listener) => listener());
|
|
30
|
+
},
|
|
31
|
+
subscribe(listener) {
|
|
32
|
+
overlayStore.listeners.add(listener);
|
|
33
|
+
return () => overlayStore.listeners.delete(listener);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
const noOverlays = [];
|
|
37
|
+
function useOverlaySlot(overlay, id) {
|
|
38
|
+
const stack = React.useSyncExternalStore(overlayStore.subscribe, () => overlayStore.stack, () => noOverlays);
|
|
39
|
+
useIsomorphicLayoutEffect(() => {
|
|
40
|
+
if (!overlay)
|
|
41
|
+
return;
|
|
42
|
+
overlayStore.set([...overlayStore.stack.filter((item) => item !== id), id]);
|
|
43
|
+
return () => overlayStore.set(overlayStore.stack.filter((item) => item !== id));
|
|
44
|
+
}, [overlay, id]);
|
|
45
|
+
const index = stack.indexOf(id);
|
|
46
|
+
const top = index === stack.length - 1;
|
|
47
|
+
return { hidden: overlay && index !== -1 && !top, more: overlay && top ? stack.length - 1 : 0 };
|
|
48
|
+
}
|
|
49
|
+
const AlertDetailsContext = React.createContext(null);
|
|
50
|
+
function Alert({ className, variant = "info", appearance = "tinted", tape, animated = false, pulse = false, placement = "inline", onDismiss, labels, role, ref, children, ...props }) {
|
|
51
|
+
const severity = variant ?? "info";
|
|
52
|
+
const loud = appearance === "loud";
|
|
53
|
+
const id = React.useId();
|
|
54
|
+
const detailsId = `${id}-details`;
|
|
55
|
+
const [open, setOpen] = React.useState(false);
|
|
56
|
+
const root = React.useRef(null);
|
|
57
|
+
const returnTo = React.useRef(null);
|
|
58
|
+
const { hidden, more } = useOverlaySlot(placement === "overlay", id);
|
|
59
|
+
const hasDetails = React.Children.toArray(children).some((child) => React.isValidElement(child) && child.type === AlertDetails);
|
|
60
|
+
React.useEffect(() => {
|
|
61
|
+
returnTo.current = document.activeElement;
|
|
62
|
+
}, []);
|
|
63
|
+
const setRef = React.useCallback((node) => {
|
|
64
|
+
root.current = node;
|
|
65
|
+
if (typeof ref === "function")
|
|
66
|
+
return ref(node);
|
|
67
|
+
if (ref)
|
|
68
|
+
ref.current = node;
|
|
69
|
+
}, [ref]);
|
|
70
|
+
function dismiss() {
|
|
71
|
+
const target = returnTo.current;
|
|
72
|
+
onDismiss?.();
|
|
73
|
+
requestAnimationFrame(() => {
|
|
74
|
+
if (target instanceof HTMLElement && target.isConnected && target !== document.body && !root.current?.contains(target)) {
|
|
75
|
+
target.focus();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const heading = document.querySelector("main h1, h1");
|
|
79
|
+
if (!heading)
|
|
80
|
+
return;
|
|
81
|
+
if (!heading.hasAttribute("tabindex"))
|
|
82
|
+
heading.tabIndex = -1;
|
|
83
|
+
heading.focus();
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const resolvedTape = tape ?? (severity === "error" || severity === "warning" ? "top" : "none");
|
|
87
|
+
const alert = (_jsxs("div", { ref: setRef, "data-slot": "alert", "data-variant": variant, "data-appearance": appearance, "data-placement": placement, "data-tape": loud ? resolvedTape : undefined, "data-animated": loud && animated ? "true" : undefined, "data-pulse": loud && pulse ? "true" : undefined, role: role ?? (severity === "error" ? "alert" : "status"), hidden: hidden || undefined, className: cn(alertVariants({ variant, appearance }), placement === "overlay" && "alert-overlay", className), ...props, children: [loud && _jsx(LoudMark, { variant: severity }), _jsx(AlertDetailsContext.Provider, { value: { id: detailsId, open }, children: children }), (hasDetails || onDismiss || more > 0) && (_jsxs("div", { "data-slot": "alert-actions", className: "alert-actions", children: [more > 0 && (_jsxs("span", { className: "alert-count", "aria-label": `${more} more ${more === 1 ? "alert" : "alerts"}`, children: ["+", more] })), hasDetails && (_jsxs(Button, { size: "xs", className: "alert-details-toggle", "aria-expanded": open, "aria-controls": detailsId, onClick: () => setOpen((value) => !value), children: [_jsx(ChevronDown, { className: "icon icon-sm", "aria-hidden": "true" }), open ? (labels?.hide ?? "Hide details") : (labels?.show ?? "Details")] })), onDismiss && (_jsx(Button, { className: "btn-icon", size: "sm", variant: "ghost", "aria-label": labels?.dismiss ?? "Dismiss", onClick: dismiss, children: _jsx(X, { className: "icon icon-sm", "aria-hidden": "true" }) }))] }))] }));
|
|
88
|
+
return placement === "overlay" ? _jsx(PortalPrimitive.Root, { asChild: true, children: alert }) : alert;
|
|
18
89
|
}
|
|
19
90
|
function AlertContent({ className, ...props }) {
|
|
20
91
|
return (_jsx("div", { "data-slot": "alert-content", className: cn("alert-content stack-xs grow", className), ...props }));
|
|
@@ -22,7 +93,35 @@ function AlertContent({ className, ...props }) {
|
|
|
22
93
|
function AlertTitle({ className, ...props }) {
|
|
23
94
|
return (_jsx("p", { "data-slot": "alert-title", className: cn("alert-title", className), ...props }));
|
|
24
95
|
}
|
|
96
|
+
function AlertLabel({ className, ...props }) {
|
|
97
|
+
return (_jsx("p", { "data-slot": "alert-label", className: cn("alert-label", className), ...props }));
|
|
98
|
+
}
|
|
99
|
+
function AlertMessage({ className, ...props }) {
|
|
100
|
+
return (_jsx("p", { "data-slot": "alert-message", className: cn("alert-message", className), ...props }));
|
|
101
|
+
}
|
|
102
|
+
function AlertMeta({ className, ...props }) {
|
|
103
|
+
return (_jsx("p", { "data-slot": "alert-meta", className: cn("alert-meta", className), ...props }));
|
|
104
|
+
}
|
|
25
105
|
function AlertDescription({ className, ...props }) {
|
|
26
106
|
return (_jsx("p", { "data-slot": "alert-description", className: cn("alert-body", className), ...props }));
|
|
27
107
|
}
|
|
28
|
-
|
|
108
|
+
function AlertDetails({ className, ...props }) {
|
|
109
|
+
const details = React.useContext(AlertDetailsContext);
|
|
110
|
+
return (_jsx("div", { "data-slot": "alert-details", id: details?.id, hidden: details ? !details.open : undefined, className: cn("alert-details", className), ...props }));
|
|
111
|
+
}
|
|
112
|
+
function AlertCode({ code, className, ...props }) {
|
|
113
|
+
return (_jsxs("span", { "data-slot": "alert-code", className: cn("alert-code", className), ...props, children: [code, _jsx("button", { type: "button", "aria-label": `Copy code ${code}`, onClick: () => writeClipboard(code).catch(() => { }), children: "copy" })] }));
|
|
114
|
+
}
|
|
115
|
+
function AlertHelp({ action, className, children, ...props }) {
|
|
116
|
+
return (_jsxs("div", { "data-slot": "alert-help", className: cn("alert-help", className), ...props, children: [_jsxs("p", { children: [_jsx("b", { children: "help:" }), " ", children] }), action] }));
|
|
117
|
+
}
|
|
118
|
+
function AlertEvidence({ origin, className, ...props }) {
|
|
119
|
+
return (_jsx("ol", { "data-slot": "alert-evidence", "aria-label": `Evidence from ${origin}`, className: cn("alert-evidence", className), ...props }));
|
|
120
|
+
}
|
|
121
|
+
function AlertLine({ at, role, label, className, children, ...props }) {
|
|
122
|
+
return (_jsxs("li", { "data-slot": "alert-line", "data-role": role, className: cn("alert-line", className), ...props, children: [_jsx("span", { className: "alert-line-at", children: at }), _jsx("span", { className: "alert-line-event", children: children }), _jsx("span", { className: "alert-line-label", children: label })] }));
|
|
123
|
+
}
|
|
124
|
+
function AlertNote({ className, children, ...props }) {
|
|
125
|
+
return (_jsxs("p", { "data-slot": "alert-note", className: cn("alert-note", className), ...props, children: [_jsx("b", { children: "note:" }), " ", _jsx("span", { children: children })] }));
|
|
126
|
+
}
|
|
127
|
+
export { Alert, AlertContent, AlertLabel, AlertTitle, AlertMessage, AlertDescription, AlertMeta, AlertDetails, AlertCode, AlertHelp, AlertEvidence, AlertLine, AlertNote, alertVariants, };
|
package/dist/chart-legend.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
3
4
|
import { clsx as cn } from "clsx";
|
|
4
5
|
import { chartColor, chartSlot, defaultChartSummary, formatChartTime, formatChartValue, measured, seriesSummary, validateChart } from "./chart-data.js";
|
|
6
|
+
import { ChartPattern } from "./chart-style.js";
|
|
5
7
|
const defaultLabels = {
|
|
6
8
|
series: "Series", current: "Current", notCollected: "Not collected",
|
|
7
9
|
min: "Min", max: "Max", avg: "Avg", p50: "p50", p75: "p75", p90: "p90", p95: "p95", p99: "p99",
|
|
8
10
|
};
|
|
9
11
|
export function ChartSeriesLabel({ series, index }) {
|
|
10
12
|
const slot = chartSlot(series, index);
|
|
11
|
-
|
|
13
|
+
const id = React.useId();
|
|
14
|
+
return _jsxs("span", { className: "chart-series-label", children: [_jsxs("svg", { className: "chart-series-swatch", "aria-hidden": "true", width: "28", height: "12", viewBox: "0 0 28 12", children: [_jsx("defs", { children: _jsx(ChartPattern, { id: `${id}-hatch`, color: chartColor(slot), fill: "none", hatch: slot }) }), _jsx("path", { className: "chart-series-line", d: "M0 6H28", stroke: chartColor(slot), strokeWidth: "2" }), _jsx("path", { className: "chart-series-hatch", d: "M1 1H27V11H1Z", stroke: chartColor(slot), strokeWidth: "1", fill: `url(#${id}-hatch)` })] }), _jsxs("span", { children: [slot, ". ", series.label] })] });
|
|
12
15
|
}
|
|
13
16
|
export function ChartLegend({ data, series, label, formatValue = formatChartValue, variant = "table", summary: stats = defaultChartSummary, activeTimestamp, formatTime = formatChartTime, highlightSeries, onHighlightSeriesChange, labels, className, ...props }) {
|
|
14
17
|
validateChart(data, series);
|
package/dist/chart-style.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export type ChartStyle = "solid" | "pixel" | "halftone" | "rounded";
|
|
|
6
6
|
export type ChartTreatment = {
|
|
7
7
|
line: ChartLine;
|
|
8
8
|
fill: ChartFill;
|
|
9
|
+
mono?: boolean;
|
|
9
10
|
};
|
|
10
11
|
export declare const chartStylePresets: Record<ChartStyle, ChartTreatment>;
|
|
11
12
|
export type ChartTreatmentProps = {
|
|
@@ -22,10 +23,11 @@ export declare function useChartPresentation(ref: React.RefObject<HTMLElement |
|
|
|
22
23
|
};
|
|
23
24
|
type CurveFactory = Exclude<NonNullable<React.ComponentProps<typeof Line>["type"]>, string>;
|
|
24
25
|
export declare const pixelCurve: CurveFactory;
|
|
25
|
-
export declare function ChartPattern({ id, color, fill }: {
|
|
26
|
+
export declare function ChartPattern({ id, color, fill, hatch }: {
|
|
26
27
|
id: string;
|
|
27
28
|
color: string;
|
|
28
29
|
fill: ChartFill;
|
|
30
|
+
hatch?: number;
|
|
29
31
|
}): React.JSX.Element;
|
|
30
32
|
export declare function ChartDot({ cx, cy, r, fill, opacity, line }: {
|
|
31
33
|
cx?: number;
|
package/dist/chart-style.js
CHANGED
|
@@ -12,10 +12,8 @@ const chartFills = ["none", "dots", "tint", "squares", "scanlines"];
|
|
|
12
12
|
// Geometry must update with a scoped appearance attribute, not just CSS paint.
|
|
13
13
|
export function useChartStyle(ref, override = {}, mounted = true) {
|
|
14
14
|
const [inherited, setInherited] = React.useState(chartStylePresets.solid);
|
|
15
|
-
const
|
|
15
|
+
const [mono, setMono] = React.useState(false);
|
|
16
16
|
React.useLayoutEffect(() => {
|
|
17
|
-
if (fixed)
|
|
18
|
-
return;
|
|
19
17
|
const element = ref.current;
|
|
20
18
|
if (!element)
|
|
21
19
|
return;
|
|
@@ -23,6 +21,7 @@ export function useChartStyle(ref, override = {}, mounted = true) {
|
|
|
23
21
|
const style = getComputedStyle(element);
|
|
24
22
|
const line = style.getPropertyValue("--chart-line").trim();
|
|
25
23
|
const fill = style.getPropertyValue("--chart-fill").trim();
|
|
24
|
+
setMono(style.getPropertyValue("--chart-palette").trim() === "mono");
|
|
26
25
|
setInherited(current => {
|
|
27
26
|
const next = { line: chartLines.includes(line) ? line : "straight", fill: chartFills.includes(fill) ? fill : "none" };
|
|
28
27
|
return next.line === current.line && next.fill === current.fill ? current : next;
|
|
@@ -30,11 +29,11 @@ export function useChartStyle(ref, override = {}, mounted = true) {
|
|
|
30
29
|
};
|
|
31
30
|
read();
|
|
32
31
|
const observer = new MutationObserver(read);
|
|
33
|
-
observer.observe(element.ownerDocument.documentElement, { attributes: true, subtree: true, attributeFilter: ["data-chart-style", "data-chart-line", "data-chart-fill"] });
|
|
32
|
+
observer.observe(element.ownerDocument.documentElement, { attributes: true, subtree: true, attributeFilter: ["data-chart-style", "data-chart-line", "data-chart-fill", "data-chart-palette"] });
|
|
34
33
|
return () => observer.disconnect();
|
|
35
|
-
}, [ref,
|
|
34
|
+
}, [ref, mounted]);
|
|
36
35
|
const base = override.chartStyle ? chartStylePresets[override.chartStyle] : inherited;
|
|
37
|
-
return { line: override.chartLine ?? base.line, fill: override.chartFill ?? base.fill };
|
|
36
|
+
return { line: override.chartLine ?? base.line, fill: override.chartFill ?? base.fill, mono };
|
|
38
37
|
}
|
|
39
38
|
const chartLayouts = ["standard", "compact", "split"];
|
|
40
39
|
const chartLegends = ["table", "inline", "sidebar"];
|
|
@@ -99,7 +98,16 @@ export const pixelCurve = context => {
|
|
|
99
98
|
};
|
|
100
99
|
/* The texture under a line. Dots and squares sit on a 4px screen; scanlines
|
|
101
100
|
are 1px rules every 3px. None and tint need no pattern. */
|
|
102
|
-
export function ChartPattern({ id, color, fill }) {
|
|
101
|
+
export function ChartPattern({ id, color, fill, hatch }) {
|
|
102
|
+
if (hatch) {
|
|
103
|
+
const kind = hatch % 5;
|
|
104
|
+
const size = kind === 1 ? 10 : kind === 4 ? 4 : 6;
|
|
105
|
+
return _jsx("pattern", { id: id, width: size, height: size, patternUnits: "userSpaceOnUse", children: kind === 1 ? _jsx("path", { d: "M-1 1L1 -1M0 10L10 0M9 11L11 9", stroke: color, strokeWidth: 1 })
|
|
106
|
+
: kind === 2 ? _jsx("path", { d: "M-1 5L1 7M0 0L6 6M5 -1L7 1", stroke: color, strokeWidth: 1 })
|
|
107
|
+
: kind === 3 ? _jsx("path", { d: "M1 1h1.5v1.5h-1.5zM4 4h1.5v1.5h-1.5z", fill: color })
|
|
108
|
+
: kind === 4 ? _jsx("path", { d: "M0 2H4", stroke: color, strokeWidth: 1 })
|
|
109
|
+
: _jsx("path", { d: "M3 0V6", stroke: color, strokeWidth: 1 }) });
|
|
110
|
+
}
|
|
103
111
|
if (fill === "scanlines")
|
|
104
112
|
return _jsx("pattern", { id: id, width: 4, height: 3, patternUnits: "userSpaceOnUse", children: _jsx("rect", { width: 4, height: 1, fill: color }) });
|
|
105
113
|
return _jsx("pattern", { id: id, width: 4, height: 4, patternUnits: "userSpaceOnUse", children: fill === "squares" ? _jsx("rect", { width: 2, height: 2, fill: color }) : _jsx("circle", { cx: 1, cy: 1, r: 0.8, fill: color }) });
|
package/dist/chart.js
CHANGED
|
@@ -36,7 +36,7 @@ export function Chart({ data, series, label, variant = "line", layout: requested
|
|
|
36
36
|
...(fractional ? { fractionalSecondDigits: 3 } : {}), timeZoneName: "longOffset" }).format(timestamp)
|
|
37
37
|
: formatChartTime;
|
|
38
38
|
const frame = React.useRef(null);
|
|
39
|
-
const { line, fill } = useChartStyle(frame, { chartStyle, chartLine, chartFill });
|
|
39
|
+
const { line, fill, mono } = useChartStyle(frame, { chartStyle, chartLine, chartFill });
|
|
40
40
|
const presentation = useChartPresentation(frame, layoutProp, legendProp);
|
|
41
41
|
const legend = presentation.legend;
|
|
42
42
|
// An inherited split cannot hold a stack, so a stacked chart keeps one plot.
|
|
@@ -165,7 +165,7 @@ export function Chart({ data, series, label, variant = "line", layout: requested
|
|
|
165
165
|
paintDrag();
|
|
166
166
|
},
|
|
167
167
|
};
|
|
168
|
-
const renderPlot = (indices, lane) => _jsxs("div", { className: "chart-plot", style: { height }, "data-range-select": selectRange ? "" : undefined, children: [_jsx(ResponsiveContainer, { width: "100%", height: "100%", children: _jsxs(ComposedChart, { data: plot, syncId: layout === "split" ? id : undefined, syncMethod: "value", accessibilityLayer: true, "aria-label": lane ? `${label}: ${lane.label}` : label, "aria-describedby": `${id}-help`, margin: spark ? { top: 4, right: 0, bottom: 0, left: 0 } : { top: 8, right: 20, bottom: 0, left: 0 }, ...pointerHandlers, children: [_jsx("defs", { children: indices.map(index => _jsx(ChartPattern, { id: `${id}-fill-${index}`, color: chartColor(chartSlot(series[index], index)), fill: fill }, series[index].key)) }), !spark && _jsx(CartesianGrid, { vertical:
|
|
168
|
+
const renderPlot = (indices, lane) => _jsxs("div", { className: "chart-plot", style: { height }, "data-range-select": selectRange ? "" : undefined, children: [_jsx(ResponsiveContainer, { width: "100%", height: "100%", children: _jsxs(ComposedChart, { data: plot, syncId: layout === "split" ? id : undefined, syncMethod: "value", accessibilityLayer: true, "aria-label": lane ? `${label}: ${lane.label}` : label, "aria-describedby": `${id}-help`, margin: spark ? { top: 4, right: 0, bottom: 0, left: 0 } : { top: 8, right: 20, bottom: 0, left: 0 }, ...pointerHandlers, children: [_jsx("defs", { children: indices.map(index => _jsx(ChartPattern, { id: `${id}-fill-${index}`, color: chartColor(chartSlot(series[index], index)), fill: fill, hatch: mono && variant === "stacked-area" ? chartSlot(series[index], index) : undefined }, series[index].key)) }), !spark && _jsx(CartesianGrid, { vertical: !!mono, stroke: "var(--color-border)", strokeWidth: 0.5 }), _jsx(XAxis, { dataKey: "timestamp", type: "number", domain: ["dataMin", "dataMax"], scale: "time", axisLine: false, tickLine: mono && !spark ? { stroke: "var(--color-border-strong)" } : false, tickFormatter: formatTime, minTickGap: spark ? 8 : 48, ticks: spark && data.length ? [...new Set([data[0].timestamp, ...(pinned !== null ? [pinned] : []), data.at(-1).timestamp])] : undefined, interval: spark ? 0 : undefined, tick: spark ? (tick) => _jsx("text", { x: tick.x, y: tick.y, dy: 12, textAnchor: tick.payload?.value === data[0]?.timestamp ? "start" : tick.payload?.value === data.at(-1)?.timestamp ? "end" : "middle", className: "chart-spark-tick", "data-pinned": tick.payload?.value === pinned || undefined, children: formatTime(tick.payload?.value ?? 0) })
|
|
169
169
|
: { fill: "var(--color-muted-foreground)" } }), _jsx(YAxis, { domain: layout === "split" ? [splitMin, splitMax]
|
|
170
170
|
: [min ?? (variant === "stacked-area" ? 0 : "auto"), max ?? "auto"], tickCount: 3, axisLine: false, tickLine: false, hide: spark, tickFormatter: formatValue, tick: { fill: "var(--color-muted-foreground)" }, width: 56 }), _jsx(Tooltip, { filterNull: false, isAnimationActive: false, cursor: { stroke: "var(--color-border-strong)", strokeDasharray: "3 3" }, content: ({ active, label: timestamp }) => _jsx(ChartReadout, { active: active, timestamp: Number(timestamp), data: data, series: series, formatTime: formatTime, displayValue: displayValue, sidebar: legend === "sidebar", onInspect: !lane || indices[0] === 0 ? inspect : undefined }) }), indices.map(index => {
|
|
171
171
|
const item = series[index];
|
|
@@ -180,13 +180,17 @@ export function Chart({ data, series, label, variant = "line", layout: requested
|
|
|
180
180
|
const at = dotProps.index ?? -1;
|
|
181
181
|
const isolated = measured(plot[at]?.values[index])
|
|
182
182
|
&& !measured(plot[at - 1]?.values[index]) && !measured(plot[at + 1]?.values[index]);
|
|
183
|
+
const every = Math.max(1, Math.ceil(plot.length / 12));
|
|
184
|
+
if (mono && !spark && !isolated && measured(plot[at]?.values[index]) && (at + index * Math.floor(every / 2)) % every === 0
|
|
185
|
+
&& dotProps.cx !== undefined && dotProps.cy !== undefined)
|
|
186
|
+
return _jsx("rect", { x: dotProps.cx - 2.5, y: dotProps.cy - 2.5, width: 5, height: 5, strokeWidth: 1, stroke: chartColor(slot), fill: slot % 2 ? "var(--color-card)" : chartColor(slot), opacity: dimmed ? 0.3 : 1 }, at);
|
|
183
187
|
return _jsx(ChartDot, { cx: dotProps.cx, cy: dotProps.cy, r: isolated ? 3 : 0, line: line, fill: chartColor(slot), opacity: dimmed ? 0.3 : 1 }, at);
|
|
184
188
|
}, activeDot: (dotProps) => _jsx(ChartDot, { ...dotProps, line: line, fill: chartColor(slot), opacity: dimmed ? 0.3 : 1 }) };
|
|
185
189
|
const curve = line === "stepped" ? pixelCurve : line === "curved" && variant === "line" ? "monotone" : "linear";
|
|
186
190
|
// A stack needs an area even without a fill; it uses the tint.
|
|
187
191
|
const textured = fill === "dots" || fill === "squares" || fill === "scanlines";
|
|
188
192
|
return variant === "stacked-area" || fill !== "none"
|
|
189
|
-
? _jsx(Area, { ...common, type: curve, stackId: variant === "stacked-area" ? "total" : undefined, fill: textured ? `url(#${id}-fill-${index})` : chartColor(slot), fillOpacity: dimmed ? 0.06 : 0.2 }, item.key)
|
|
193
|
+
? _jsx(Area, { ...common, type: curve, stackId: variant === "stacked-area" ? "total" : undefined, fill: textured || (mono && variant === "stacked-area") ? `url(#${id}-fill-${index})` : chartColor(slot), fillOpacity: mono && variant === "stacked-area" ? (dimmed ? 0.15 : slot % 5 === 2 ? 1 : 0.7) : dimmed ? 0.06 : 0.2 }, item.key)
|
|
190
194
|
: _jsx(Line, { ...common, type: curve }, item.key);
|
|
191
195
|
}), _jsx(ChartSyncMarker, { group: group, source: source, plot: plot, data: data, series: series, indices: indices, stacked: variant === "stacked-area", line: line, highlighted: highlighted, pick: !lane || indices[0] === 0 ? pick : undefined, readout: !spark && legend !== "sidebar" && (!lane || indices[0] === 0), formatTime: formatTime, displayValue: displayValue })] }) }), selectRange && _jsx("div", { className: "chart-range-band", hidden: true, "aria-hidden": "true" })] });
|
|
192
196
|
const legendProps = { data, series, label: text.summary(label), variant: legend, summary, formatValue, formatTime,
|
|
@@ -201,7 +205,7 @@ export function Chart({ data, series, label, variant = "line", layout: requested
|
|
|
201
205
|
return ref(element);
|
|
202
206
|
if (ref)
|
|
203
207
|
ref.current = element;
|
|
204
|
-
}, "data-slot": "chart", "data-layout": spark ? "spark" : layout, "data-legend": legend, "data-line": line, "data-fill": fill, className: cn("framed-chart", className), "aria-labelledby": `${id}-title`, onKeyDown: event => {
|
|
208
|
+
}, "data-slot": "chart", "data-variant": variant, "data-layout": spark ? "spark" : layout, "data-legend": legend, "data-line": line, "data-fill": fill, className: cn("framed-chart", className), "aria-labelledby": `${id}-title`, onKeyDown: event => {
|
|
205
209
|
onKeyDown?.(event);
|
|
206
210
|
if (event.defaultPrevented || drag.current)
|
|
207
211
|
return;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function writeClipboard(text: string): Promise<void>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// The console also runs on plain HTTP, where the Clipboard API is missing.
|
|
2
|
+
export async function writeClipboard(text) {
|
|
3
|
+
if (navigator.clipboard && window.isSecureContext)
|
|
4
|
+
return navigator.clipboard.writeText(text);
|
|
5
|
+
const focused = document.activeElement;
|
|
6
|
+
const area = Object.assign(document.createElement("textarea"), { value: text, readOnly: true });
|
|
7
|
+
area.style.cssText = "position:fixed;inset-block-start:0;opacity:0";
|
|
8
|
+
document.body.append(area);
|
|
9
|
+
area.select();
|
|
10
|
+
let copied = false;
|
|
11
|
+
try {
|
|
12
|
+
copied = document.execCommand("copy");
|
|
13
|
+
}
|
|
14
|
+
finally {
|
|
15
|
+
area.remove();
|
|
16
|
+
focused?.focus();
|
|
17
|
+
}
|
|
18
|
+
if (!copied)
|
|
19
|
+
throw new Error("Copy failed");
|
|
20
|
+
}
|
package/dist/code-block.js
CHANGED
|
@@ -5,6 +5,7 @@ import { cloneElement, createElement, isValidElement, useState } from "react";
|
|
|
5
5
|
import { clsx as cn } from "clsx";
|
|
6
6
|
import { Check, Copy } from "lucide-react";
|
|
7
7
|
import { Button } from "./button.js";
|
|
8
|
+
import { writeClipboard } from "./clipboard.js";
|
|
8
9
|
import { TerminalIcon } from "./terminal-icon.js";
|
|
9
10
|
import { useToast } from "./toast.js";
|
|
10
11
|
// A highlight paints the whole value, so a token can span lines. These split
|
|
@@ -81,26 +82,6 @@ function paint(code, highlight) {
|
|
|
81
82
|
return rows;
|
|
82
83
|
return lines.map(parts => createElement("span", null, ...parts));
|
|
83
84
|
}
|
|
84
|
-
// The console also runs on plain HTTP, where the Clipboard API is missing.
|
|
85
|
-
async function writeClipboard(text) {
|
|
86
|
-
if (navigator.clipboard && window.isSecureContext)
|
|
87
|
-
return navigator.clipboard.writeText(text);
|
|
88
|
-
const focused = document.activeElement;
|
|
89
|
-
const area = Object.assign(document.createElement("textarea"), { value: text, readOnly: true });
|
|
90
|
-
area.style.cssText = "position:fixed;inset-block-start:0;opacity:0";
|
|
91
|
-
document.body.append(area);
|
|
92
|
-
area.select();
|
|
93
|
-
let copied = false;
|
|
94
|
-
try {
|
|
95
|
-
copied = document.execCommand("copy");
|
|
96
|
-
}
|
|
97
|
-
finally {
|
|
98
|
-
area.remove();
|
|
99
|
-
focused?.focus();
|
|
100
|
-
}
|
|
101
|
-
if (!copied)
|
|
102
|
-
throw new Error("Copy failed");
|
|
103
|
-
}
|
|
104
85
|
function CopyButton({ code, label, compact = false }) {
|
|
105
86
|
const notify = useToast();
|
|
106
87
|
const [copied, setCopied] = useState(false);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { clsx as cn } from "clsx";
|
|
4
|
+
const loudMarks = {
|
|
5
|
+
error: {
|
|
6
|
+
shape: _jsx("circle", { cx: "12", cy: "12", r: "10" }),
|
|
7
|
+
mark: _jsxs(_Fragment, { children: [_jsx("path", { d: "M12 7.5v5" }), _jsx("path", { d: "M12 16.5h.01" })] }),
|
|
8
|
+
},
|
|
9
|
+
warning: {
|
|
10
|
+
shape: _jsx("path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" }),
|
|
11
|
+
mark: _jsxs(_Fragment, { children: [_jsx("path", { d: "M12 9v4" }), _jsx("path", { d: "M12 17h.01" })] }),
|
|
12
|
+
},
|
|
13
|
+
info: {
|
|
14
|
+
shape: _jsx("circle", { cx: "12", cy: "12", r: "10" }),
|
|
15
|
+
mark: _jsxs(_Fragment, { children: [_jsx("path", { d: "M12 16.5v-5" }), _jsx("path", { d: "M12 7.5h.01" })] }),
|
|
16
|
+
},
|
|
17
|
+
success: {
|
|
18
|
+
shape: _jsx("circle", { cx: "12", cy: "12", r: "10" }),
|
|
19
|
+
mark: _jsx("path", { d: "m8 12 3 3 5-5.5" }),
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
function LoudMark({ variant, className }) {
|
|
23
|
+
const id = `alert-mark-${React.useId().replace(/[^\w-]/g, "")}`;
|
|
24
|
+
const { shape, mark } = loudMarks[variant];
|
|
25
|
+
return (_jsxs("svg", { className: cn("alert-mark", className), viewBox: "0 0 24 24", "aria-hidden": "true", "data-slot": "alert-mark", children: [_jsxs("mask", { id: id, maskUnits: "userSpaceOnUse", x: "0", y: "0", width: "24", height: "24", children: [_jsx("rect", { width: "24", height: "24", fill: "white" }), _jsx("g", { fill: "none", stroke: "black", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: mark })] }), _jsx("g", { mask: `url(#${id})`, fill: "currentColor", stroke: "currentColor", strokeWidth: "1.5", strokeLinejoin: "round", children: shape })] }));
|
|
26
|
+
}
|
|
27
|
+
export { LoudMark };
|
package/dist/pane-grid.d.ts
CHANGED
|
@@ -25,5 +25,6 @@ export type GridPaneProps = Omit<React.ComponentProps<"article">, "title" | "id"
|
|
|
25
25
|
size?: number;
|
|
26
26
|
newRow?: boolean;
|
|
27
27
|
actions?: React.ReactNode;
|
|
28
|
+
frame?: "default" | "none";
|
|
28
29
|
};
|
|
29
|
-
export declare function GridPane({ id, title, min: _min, size: _size, newRow: _newRow, actions, className, style, children, ...props }: GridPaneProps): React.JSX.Element;
|
|
30
|
+
export declare function GridPane({ id, title, min: _min, size: _size, newRow: _newRow, actions, frame, className, style, children, ...props }: GridPaneProps): React.JSX.Element;
|
package/dist/pane-grid.js
CHANGED
|
@@ -462,12 +462,12 @@ export function PaneGrid({ title, layout: controlled, defaultLayout, onLayoutCha
|
|
|
462
462
|
])),
|
|
463
463
|
]), _jsx("div", { ref: dropRef, className: "pane-grid-drop", "aria-hidden": "true", hidden: true })] })] }));
|
|
464
464
|
}
|
|
465
|
-
export function GridPane({ id, title, min: _min, size: _size, newRow: _newRow, actions, className, style, children, ...props }) {
|
|
465
|
+
export function GridPane({ id, title, min: _min, size: _size, newRow: _newRow, actions, frame = "default", className, style, children, ...props }) {
|
|
466
466
|
const context = React.useContext(PaneContext);
|
|
467
467
|
if (!context)
|
|
468
468
|
throw new Error("GridPane must be a child of PaneGrid.");
|
|
469
469
|
const { placement, api } = context;
|
|
470
|
-
return (_jsxs("article", { "data-slot": "grid-pane", "data-pane-id": id, className: cn("grid-pane card", className), style: { "--r": placement.row, "--c": placement.col, "--s": placement.span, ...style }, ...props, children: [_jsx(PanelShadow, {}), _jsxs("div", { "data-slot": "grid-pane-head", className: "grid-pane-head", ...(!placement.static && {
|
|
470
|
+
return (_jsxs("article", { "data-slot": "grid-pane", "data-pane-id": id, "data-frame": frame, className: cn("grid-pane", frame !== "none" && "card", className), style: { "--r": placement.row, "--c": placement.col, "--s": placement.span, ...style }, ...props, children: [frame !== "none" && _jsx(PanelShadow, {}), _jsxs("div", { "data-slot": "grid-pane-head", className: "grid-pane-head", ...(!placement.static && {
|
|
471
471
|
role: "button",
|
|
472
472
|
tabIndex: 0,
|
|
473
473
|
"aria-label": `Move ${title}`,
|
package/dist/styles.css
CHANGED
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
color: var(--color-foreground);
|
|
107
107
|
font-weight: var(--type-weight-medium);
|
|
108
108
|
}
|
|
109
|
-
.accent-pill:is([data-accent="gold"], [data-accent="lime"])
|
|
109
|
+
.accent-pill[aria-pressed="true"]:has(> :is([data-accent="gold"], [data-accent="lime"])) { border-color: var(--color-link); }
|
|
110
110
|
.accent-dot { width: var(--spacing-md); height: var(--spacing-md); border-radius: var(--radius-full); background: var(--color-primary); }
|
|
111
111
|
|
|
112
112
|
.accent-preview {
|
|
@@ -175,7 +175,7 @@
|
|
|
175
175
|
position: fixed;
|
|
176
176
|
top: 50%;
|
|
177
177
|
left: 50%;
|
|
178
|
-
z-index:
|
|
178
|
+
z-index: 50;
|
|
179
179
|
transform: translate(-50%, -50%);
|
|
180
180
|
width: min(32rem, calc(100vw - 2 * var(--spacing-lg)));
|
|
181
181
|
--frame-fill: var(--color-elevated-surface);
|
|
@@ -473,7 +473,7 @@
|
|
|
473
473
|
/* A Drawer is the dialog surface moved to an edge. */
|
|
474
474
|
.kiso-react-drawer {
|
|
475
475
|
position: fixed;
|
|
476
|
-
z-index:
|
|
476
|
+
z-index: 50;
|
|
477
477
|
display: flex;
|
|
478
478
|
flex-direction: column;
|
|
479
479
|
--frame-fill: var(--color-elevated-surface);
|
|
@@ -520,7 +520,7 @@
|
|
|
520
520
|
|
|
521
521
|
.kiso-react-palette {
|
|
522
522
|
position: fixed;
|
|
523
|
-
z-index:
|
|
523
|
+
z-index: 50;
|
|
524
524
|
inset-block-start: 12vh;
|
|
525
525
|
inset-inline-start: 50%;
|
|
526
526
|
translate: -50% 0;
|
package/dist/toast.d.ts
CHANGED
|
@@ -2,13 +2,18 @@ import * as React from "react";
|
|
|
2
2
|
import { type VariantProps } from "class-variance-authority";
|
|
3
3
|
import { Toast as ToastPrimitive } from "radix-ui";
|
|
4
4
|
type ToastVariant = "neutral" | "success" | "warning" | "error";
|
|
5
|
-
type
|
|
5
|
+
type ToastAppearance = "default" | "loud";
|
|
6
|
+
type ToastOptions = {
|
|
7
|
+
appearance?: ToastAppearance;
|
|
8
|
+
pulse?: boolean;
|
|
9
|
+
};
|
|
10
|
+
type ToastNotify = (variant: ToastVariant, title: React.ReactNode, body?: React.ReactNode, options?: ToastOptions) => void;
|
|
6
11
|
declare const toastVariants: (props?: ({
|
|
7
12
|
variant?: "error" | "neutral" | "success" | "warning" | null | undefined;
|
|
8
13
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
9
14
|
declare function ToastProvider({ ...props }: React.ComponentProps<typeof ToastPrimitive.Provider>): React.JSX.Element;
|
|
10
15
|
declare function ToastViewport({ className, ...props }: React.ComponentProps<typeof ToastPrimitive.Viewport>): React.JSX.Element;
|
|
11
|
-
declare function Toast({ className, variant, type, ...props }: React.ComponentProps<typeof ToastPrimitive.Root> & VariantProps<typeof toastVariants>): React.JSX.Element;
|
|
16
|
+
declare function Toast({ className, variant, appearance, pulse, type, duration, children, ...props }: React.ComponentProps<typeof ToastPrimitive.Root> & VariantProps<typeof toastVariants> & ToastOptions): React.JSX.Element;
|
|
12
17
|
declare function ToastTitle({ className, ...props }: React.ComponentProps<typeof ToastPrimitive.Title>): React.JSX.Element;
|
|
13
18
|
declare function ToastDescription({ className, ...props }: React.ComponentProps<typeof ToastPrimitive.Description>): React.JSX.Element;
|
|
14
19
|
declare function ToastContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
@@ -20,4 +25,4 @@ declare function Toasts({ children, duration, }: {
|
|
|
20
25
|
duration?: number;
|
|
21
26
|
}): React.JSX.Element;
|
|
22
27
|
export { ToastProvider, ToastViewport, Toast, ToastTitle, ToastDescription, ToastContent, ToastAction, ToastClose, Toasts, useToast, toastVariants, };
|
|
23
|
-
export type { ToastNotify, ToastVariant };
|
|
28
|
+
export type { ToastAppearance, ToastNotify, ToastOptions, ToastVariant };
|
package/dist/toast.js
CHANGED
|
@@ -6,6 +6,7 @@ import { cva } from "class-variance-authority";
|
|
|
6
6
|
import { clsx as cn } from "clsx";
|
|
7
7
|
import { Toast as ToastPrimitive } from "radix-ui";
|
|
8
8
|
import { Button } from "./button.js";
|
|
9
|
+
import { LoudMark } from "./loud-mark.js";
|
|
9
10
|
const ToastContext = React.createContext(null);
|
|
10
11
|
const toastVariants = cva("toast", {
|
|
11
12
|
variants: {
|
|
@@ -25,8 +26,10 @@ function ToastViewport({ className, ...props }) {
|
|
|
25
26
|
return (_jsx(ToastPrimitive.Viewport, { "data-slot": "toast-viewport", className: cn("toast-region", className), ...props }));
|
|
26
27
|
}
|
|
27
28
|
// An error interrupts (assertive); everything else waits its turn (polite).
|
|
28
|
-
function Toast({ className, variant = "neutral", type, ...props }) {
|
|
29
|
-
|
|
29
|
+
function Toast({ className, variant = "neutral", appearance = "default", pulse = false, type, duration, children, ...props }) {
|
|
30
|
+
const loud = appearance === "loud";
|
|
31
|
+
const severity = variant ?? "neutral";
|
|
32
|
+
return (_jsxs(ToastPrimitive.Root, { "data-slot": "toast", "data-variant": variant, "data-appearance": appearance, "data-tape": loud ? (severity === "error" || severity === "warning" ? "top" : "none") : undefined, "data-pulse": loud && pulse ? "true" : undefined, type: type ?? (severity === "error" ? "foreground" : "background"), duration: duration ?? (loud && severity === "error" ? Infinity : undefined), className: cn(toastVariants({ variant }), loud && "toast-loud", className), ...props, children: [loud && _jsx(LoudMark, { variant: severity === "neutral" ? "info" : severity }), children] }));
|
|
30
33
|
}
|
|
31
34
|
function ToastTitle({ className, ...props }) {
|
|
32
35
|
return (_jsx(ToastPrimitive.Title, { "data-slot": "toast-title", className: cn("alert-title", className), ...props }));
|
|
@@ -52,14 +55,14 @@ function useToast() {
|
|
|
52
55
|
function Toasts({ children, duration = 6000, }) {
|
|
53
56
|
const [notices, setNotices] = React.useState([]);
|
|
54
57
|
const nextId = React.useRef(0);
|
|
55
|
-
const notify = React.useCallback((variant, title, body) => {
|
|
58
|
+
const notify = React.useCallback((variant, title, body, options) => {
|
|
56
59
|
const id = nextId.current++;
|
|
57
|
-
setNotices((current) => [...current, { id, variant, title, body }]);
|
|
60
|
+
setNotices((current) => [...current, { id, variant, title, body, ...options }]);
|
|
58
61
|
}, []);
|
|
59
62
|
const dismiss = React.useCallback((id) => {
|
|
60
63
|
setNotices((current) => current.filter((notice) => notice.id !== id));
|
|
61
64
|
}, []);
|
|
62
|
-
return (_jsx(ToastContext.Provider, { value: notify, children: _jsxs(ToastProvider, { duration: duration, children: [children, notices.map((notice) => (_jsxs(Toast, { variant: notice.variant, onOpenChange: (open) => {
|
|
65
|
+
return (_jsx(ToastContext.Provider, { value: notify, children: _jsxs(ToastProvider, { duration: duration, children: [children, notices.map((notice) => (_jsxs(Toast, { variant: notice.variant, appearance: notice.appearance, pulse: notice.pulse, onOpenChange: (open) => {
|
|
63
66
|
if (!open)
|
|
64
67
|
dismiss(notice.id);
|
|
65
68
|
}, children: [_jsxs(ToastContent, { children: [_jsx(ToastTitle, { children: notice.title }), typeof notice.body === "string" || typeof notice.body === "number"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momoi-labs/kiso-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "Kiso React components built with shadcn/ui and Radix",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"prepack": "npm run build"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@momoi-labs/kiso": "^1.
|
|
35
|
+
"@momoi-labs/kiso": "^1.15.0",
|
|
36
36
|
"class-variance-authority": "0.7.1",
|
|
37
37
|
"clsx": "2.1.1",
|
|
38
38
|
"radix-ui": "1.6.7",
|