nish-ui 1.9.0 → 2.0.1
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 +218 -58
- package/dist/base-tailwind.css +1757 -0
- package/dist/base.css +1590 -1445
- package/dist/chart.d.ts +4 -1
- package/dist/chart.js +122 -49
- package/dist/elements-all.d.ts +8 -0
- package/dist/elements-all.js +178 -0
- package/dist/elements-charts.d.ts +71 -0
- package/dist/elements-charts.js +56 -57
- package/dist/elements-data.d.ts +71 -0
- package/dist/elements-data.js +5 -6
- package/dist/elements-forms.d.ts +71 -0
- package/dist/elements-forms.js +24 -25
- package/dist/elements.d.ts +71 -0
- package/dist/elements.js +4 -5
- package/dist/esm/chart-values.js +58 -0
- package/dist/esm/chart.js +10 -0
- package/dist/esm/cn.js +19 -0
- package/dist/esm/combobox-filter.js +13 -0
- package/dist/esm/components/accordion.js +166 -0
- package/dist/esm/components/app-shell.js +198 -0
- package/dist/esm/components/avatar-classes.js +28 -0
- package/dist/esm/components/avatar.js +113 -0
- package/dist/esm/components/breadcrumbs.js +154 -0
- package/dist/esm/components/canvas/follow-caption.js +32 -0
- package/dist/esm/components/canvas/follow.js +119 -0
- package/dist/esm/components/canvas/icons.js +70 -0
- package/dist/esm/components/canvas/index.js +10 -0
- package/dist/esm/components/canvas/layout.js +258 -0
- package/dist/esm/components/canvas/legend.js +93 -0
- package/dist/esm/components/canvas/minimap.js +127 -0
- package/dist/esm/components/canvas/node.js +87 -0
- package/dist/esm/components/canvas/route.js +262 -0
- package/dist/esm/components/canvas/system-canvas.js +837 -0
- package/dist/esm/components/canvas/types.js +10 -0
- package/dist/esm/components/canvas/view.js +47 -0
- package/dist/esm/components/chart-hooks.js +19 -0
- package/dist/esm/components/charts.js +467 -0
- package/dist/esm/components/client.js +24 -0
- package/dist/esm/components/combobox.js +343 -0
- package/dist/esm/components/command.js +403 -0
- package/dist/esm/components/data-classes.js +159 -0
- package/dist/esm/components/data.js +517 -0
- package/dist/esm/components/display-classes.js +130 -0
- package/dist/esm/components/display.js +755 -0
- package/dist/esm/components/error-boundary.js +64 -0
- package/dist/esm/components/feedback.js +136 -0
- package/dist/esm/components/file-dropzone.js +184 -0
- package/dist/esm/components/filters.js +108 -0
- package/dist/esm/components/flow.js +746 -0
- package/dist/esm/components/forms-classes.js +43 -0
- package/dist/esm/components/forms.js +581 -0
- package/dist/esm/components/hooks-classes.js +9 -0
- package/dist/esm/components/hooks.js +236 -0
- package/dist/esm/components/icons.js +96 -0
- package/dist/esm/components/inbox-classes.js +29 -0
- package/dist/esm/components/inbox.js +257 -0
- package/dist/esm/components/latest.js +13 -0
- package/dist/esm/components/layout-vars.js +96 -0
- package/dist/esm/components/layout.js +272 -0
- package/dist/esm/components/media.js +143 -0
- package/dist/esm/components/nav.js +614 -0
- package/dist/esm/components/overlay-classes.js +66 -0
- package/dist/esm/components/overlay.js +1461 -0
- package/dist/esm/components/pagination-classes.js +29 -0
- package/dist/esm/components/pagination.js +154 -0
- package/dist/esm/components/portal.js +16 -0
- package/dist/esm/components/primitives-classes.js +198 -0
- package/dist/esm/components/primitives.js +268 -0
- package/dist/esm/components/progress.js +77 -0
- package/dist/esm/components/provider.js +32 -0
- package/dist/esm/components/radio-group.js +186 -0
- package/dist/esm/components/resource-classes.js +133 -0
- package/dist/esm/components/resource.js +209 -0
- package/dist/esm/components/segmented.js +178 -0
- package/dist/esm/components/separator.js +38 -0
- package/dist/esm/components/service-tokens.js +221 -0
- package/dist/esm/components/settings.js +301 -0
- package/dist/esm/components/slider.js +262 -0
- package/dist/esm/components/split-classes.js +8 -0
- package/dist/esm/components/split.js +411 -0
- package/dist/esm/components/strings.js +119 -0
- package/dist/esm/components/table.js +144 -0
- package/dist/esm/components/tabs-classes.js +21 -0
- package/dist/esm/components/tabs.js +201 -0
- package/dist/esm/components/tag-input.js +257 -0
- package/dist/esm/components/theme-toggle.js +177 -0
- package/dist/esm/components/toast.js +361 -0
- package/dist/esm/components/url-state.js +118 -0
- package/dist/esm/components/visually-hidden.js +20 -0
- package/dist/esm/format.js +320 -0
- package/dist/esm/inbox-client.js +2 -0
- package/dist/esm/inbox-types.js +2 -0
- package/dist/esm/index.js +320 -0
- package/dist/esm/runtime.js +37 -0
- package/dist/esm/server/inbox/client.js +297 -0
- package/dist/esm/server/inbox/types.js +24 -0
- package/dist/esm/sparkline-path.js +59 -0
- package/dist/esm/split-layout.js +419 -0
- package/dist/esm/system-canvas.js +2 -0
- package/dist/esm/theme.js +804 -0
- package/dist/esm/tokens.mjs +425 -0
- package/dist/esm/url.js +20 -0
- package/dist/files.json +5 -1
- package/dist/fonts/LICENSE-Inter.txt +93 -0
- package/dist/format.d.ts +32 -18
- package/dist/format.js +227 -82
- package/dist/inbox-client.js +3 -1
- package/dist/index.d.ts +1686 -667
- package/dist/nish-components.css +4649 -4506
- package/dist/nish-components.min.css +1 -0
- package/dist/nish.css +1603 -1450
- package/dist/nish.min.css +1 -0
- package/dist/node/eslint.js +29 -14
- package/dist/node/th-check.js +29 -14
- package/dist/node/vite.d.ts +12 -0
- package/dist/node/vite.js +12 -2
- package/dist/server/hono.d.ts +15 -6
- package/dist/server/hono.js +30 -25
- package/dist/server/index.d.ts +3 -10
- package/dist/server/index.js +71 -38
- package/dist/{spa-DuVB5O7S.d.ts → spa-BLlMc0eI.d.ts} +38 -5
- package/dist/system-canvas-BLuWd69H.d.ts +183 -0
- package/dist/system-canvas.d.ts +2 -168
- package/dist/tailwind-core.css +114 -0
- package/dist/tailwind.css +3 -7
- package/dist/theme-init.js +23 -9
- package/dist/theme-init.sha256 +1 -0
- package/dist/theme.d.ts +243 -4
- package/dist/theme.global.js +356 -89
- package/dist/theme.js +337 -67
- package/dist/tokens.css +14 -6
- package/dist/tokens.dtcg.json +1513 -0
- package/dist/tokens.js +29 -14
- package/dist/tokens.json +512 -0
- package/package.json +51 -13
- package/dist/chart.js.map +0 -1
- package/dist/elements-charts.js.map +0 -1
- package/dist/elements-data.js.map +0 -1
- package/dist/elements-forms.js.map +0 -1
- package/dist/elements.js.map +0 -1
- package/dist/format.js.map +0 -1
- package/dist/inbox-client.js.map +0 -1
- package/dist/index.js +0 -10260
- package/dist/index.js.map +0 -1
- package/dist/server/hono.js.map +0 -1
- package/dist/server/index.js.map +0 -1
- package/dist/split-layout.js.map +0 -1
- package/dist/system-canvas.js +0 -2204
- package/dist/system-canvas.js.map +0 -1
- package/dist/theme.global.js.map +0 -1
- package/dist/theme.js.map +0 -1
|
@@ -0,0 +1,755 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/display.tsx
|
|
4
|
+
import {
|
|
5
|
+
createContext,
|
|
6
|
+
useContext,
|
|
7
|
+
useEffect,
|
|
8
|
+
useMemo,
|
|
9
|
+
useRef,
|
|
10
|
+
useState
|
|
11
|
+
} from "react";
|
|
12
|
+
import { cn } from "../cn.js";
|
|
13
|
+
import { sparklineGeometry } from "../sparkline-path.js";
|
|
14
|
+
import { safeUrl } from "../url.js";
|
|
15
|
+
import { mergeRefs } from "./data-classes.js";
|
|
16
|
+
import { displayInternals, FORCED_MARK, toneFor, warnDev } from "./display-classes.js";
|
|
17
|
+
import { Skeleton } from "./feedback.js";
|
|
18
|
+
import { AlertTriangleIcon, CheckCircleIcon, ChevronDownIcon, InfoIcon, XIcon } from "./icons.js";
|
|
19
|
+
import { useHeightVar, useStuck } from "./layout-vars.js";
|
|
20
|
+
import { DropdownMenu, Tooltip } from "./overlay.js";
|
|
21
|
+
import { Badge, Button, Card, IconButton } from "./primitives.js";
|
|
22
|
+
import { useNishStrings } from "./provider.js";
|
|
23
|
+
import { ThemeToggle } from "./theme-toggle.js";
|
|
24
|
+
import { signTone, toneFor as toneFor2 } from "./display-classes.js";
|
|
25
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
26
|
+
var {
|
|
27
|
+
FILL,
|
|
28
|
+
CALLOUT_TONE,
|
|
29
|
+
CALLOUT_CLAMP,
|
|
30
|
+
DOT_SIZE,
|
|
31
|
+
HALO,
|
|
32
|
+
STAT_VALUE_SIZE,
|
|
33
|
+
STAT_SKELETON,
|
|
34
|
+
STAT_TONE,
|
|
35
|
+
GRID_BASE,
|
|
36
|
+
GRID_MD,
|
|
37
|
+
METER_FILL,
|
|
38
|
+
METER_THICK,
|
|
39
|
+
METER_THICK_V,
|
|
40
|
+
SPARK_TONE,
|
|
41
|
+
LEGEND_FILL
|
|
42
|
+
} = displayInternals;
|
|
43
|
+
function Svg({ size = 16, children, ...rest }) {
|
|
44
|
+
return /* @__PURE__ */ jsx(
|
|
45
|
+
"svg",
|
|
46
|
+
{
|
|
47
|
+
width: size,
|
|
48
|
+
height: size,
|
|
49
|
+
viewBox: "0 0 24 24",
|
|
50
|
+
fill: "none",
|
|
51
|
+
stroke: "currentColor",
|
|
52
|
+
strokeWidth: 2,
|
|
53
|
+
strokeLinecap: "round",
|
|
54
|
+
strokeLinejoin: "round",
|
|
55
|
+
"aria-hidden": "true",
|
|
56
|
+
focusable: "false",
|
|
57
|
+
...rest,
|
|
58
|
+
children
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
var CopyIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
63
|
+
/* @__PURE__ */ jsx("rect", { width: "14", height: "14", x: "8", y: "8", rx: "2" }),
|
|
64
|
+
/* @__PURE__ */ jsx("path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" })
|
|
65
|
+
] });
|
|
66
|
+
var CheckIcon = (p) => /* @__PURE__ */ jsx(Svg, { ...p, children: /* @__PURE__ */ jsx("path", { d: "M20 6 9 17l-5-5" }) });
|
|
67
|
+
var ChevronRightIcon = (p) => /* @__PURE__ */ jsx(Svg, { ...p, children: /* @__PURE__ */ jsx("path", { d: "m9 18 6-6-6-6" }) });
|
|
68
|
+
function defaultCalloutIcon(tone, size) {
|
|
69
|
+
if (tone === "ok") return /* @__PURE__ */ jsx(CheckCircleIcon, { size });
|
|
70
|
+
if (tone === "warn" || tone === "loss") return /* @__PURE__ */ jsx(AlertTriangleIcon, { size });
|
|
71
|
+
return /* @__PURE__ */ jsx(InfoIcon, { size });
|
|
72
|
+
}
|
|
73
|
+
function Callout({
|
|
74
|
+
tone = "info",
|
|
75
|
+
icon,
|
|
76
|
+
title,
|
|
77
|
+
children,
|
|
78
|
+
action,
|
|
79
|
+
onDismiss,
|
|
80
|
+
dismissLabel,
|
|
81
|
+
variant = "box",
|
|
82
|
+
compact = false,
|
|
83
|
+
live = false,
|
|
84
|
+
sticky = false,
|
|
85
|
+
clamp,
|
|
86
|
+
href: hrefProp,
|
|
87
|
+
onClick,
|
|
88
|
+
count,
|
|
89
|
+
className,
|
|
90
|
+
ref,
|
|
91
|
+
...rest
|
|
92
|
+
}) {
|
|
93
|
+
const strings = useNishStrings();
|
|
94
|
+
const t = CALLOUT_TONE[tone];
|
|
95
|
+
const shown = icon === false ? null : icon ?? defaultCalloutIcon(tone, compact ? 14 : 16);
|
|
96
|
+
const href = hrefProp == null ? void 0 : safeUrl(hrefProp) ?? void 0;
|
|
97
|
+
if (hrefProp != null && href === void 0) warnDev(`nish-ui: Callout dropped an unsafe href (${hrefProp.slice(0, 40)}).`);
|
|
98
|
+
const interactive = href != null || onClick != null;
|
|
99
|
+
const iconEl = shown ? /* @__PURE__ */ jsx("span", { className: cn("shrink-0", compact ? "mt-px" : "mt-0.5", t.icon), children: shown }) : null;
|
|
100
|
+
const text = /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 basis-60", children: [
|
|
101
|
+
title || count != null ? /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-2 font-medium leading-snug text-th-hi", children: [
|
|
102
|
+
title ? /* @__PURE__ */ jsx("span", { className: "min-w-0", children: title }) : null,
|
|
103
|
+
count != null ? /* @__PURE__ */ jsxs(Badge, { tone, "aria-label": strings.moreCount(count), className: "shrink-0", children: [
|
|
104
|
+
"+",
|
|
105
|
+
count
|
|
106
|
+
] }) : null
|
|
107
|
+
] }) : null,
|
|
108
|
+
children ? /* @__PURE__ */ jsx("div", { className: cn("leading-snug text-th-hi2", title || count != null ? "mt-0.5" : null, clamp && CALLOUT_CLAMP[clamp]), children }) : null
|
|
109
|
+
] });
|
|
110
|
+
const actionEl = action ? /* @__PURE__ */ jsx("div", { className: "flex shrink-0 items-center gap-2", children: action }) : null;
|
|
111
|
+
const dismissEl = onDismiss ? /* @__PURE__ */ jsx(IconButton, { label: dismissLabel ?? strings.dismiss, size: "xs", onClick: onDismiss, className: "-my-0.5 -me-1", children: /* @__PURE__ */ jsx(XIcon, { size: 14 }) }) : null;
|
|
112
|
+
const chevron = /* @__PURE__ */ jsx(ChevronDownIcon, { size: 16, className: "-rotate-90 shrink-0 self-center text-th-hi3 rtl:rotate-90" });
|
|
113
|
+
const hit = cn(
|
|
114
|
+
"flex min-h-11 min-w-0 flex-1 items-start text-start outline-none focus-visible:ring-2 focus-visible:ring-th-accent/40",
|
|
115
|
+
compact ? "gap-2" : "gap-3",
|
|
116
|
+
// Pull the padding of the row into the link so the whole row is the target.
|
|
117
|
+
compact ? "-my-2 py-2" : "-my-3 py-3"
|
|
118
|
+
);
|
|
119
|
+
return /* @__PURE__ */ jsx(
|
|
120
|
+
"div",
|
|
121
|
+
{
|
|
122
|
+
ref,
|
|
123
|
+
role: live ? tone === "loss" ? "alert" : "status" : void 0,
|
|
124
|
+
"data-nish-bar": sticky ? "" : void 0,
|
|
125
|
+
className: cn(
|
|
126
|
+
"flex border",
|
|
127
|
+
variant === "bar" && action ? "items-center" : "items-start",
|
|
128
|
+
compact ? "gap-2 px-3 py-2 text-xs" : "gap-3 px-4 py-3 text-sm",
|
|
129
|
+
variant === "bar" ? "w-full rounded-none border-x-0" : "rounded-xl",
|
|
130
|
+
variant === "bar" ? t.bar : t.box,
|
|
131
|
+
sticky && "sticky top-[var(--nish-header-h,0px)] z-[var(--nish-z-sticky,20)]",
|
|
132
|
+
className
|
|
133
|
+
),
|
|
134
|
+
...rest,
|
|
135
|
+
children: interactive ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
136
|
+
href != null ? /* @__PURE__ */ jsxs("a", { href, className: hit, children: [
|
|
137
|
+
iconEl,
|
|
138
|
+
/* @__PURE__ */ jsx("span", { className: "flex min-w-0 flex-1 flex-wrap items-center gap-x-4 gap-y-2", children: text }),
|
|
139
|
+
chevron
|
|
140
|
+
] }) : /* @__PURE__ */ jsxs("button", { type: "button", onClick, className: hit, children: [
|
|
141
|
+
iconEl,
|
|
142
|
+
/* @__PURE__ */ jsx("span", { className: "flex min-w-0 flex-1 flex-wrap items-center gap-x-4 gap-y-2", children: text }),
|
|
143
|
+
chevron
|
|
144
|
+
] }),
|
|
145
|
+
actionEl,
|
|
146
|
+
dismissEl
|
|
147
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
148
|
+
iconEl,
|
|
149
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-wrap items-center gap-x-4 gap-y-2", children: [
|
|
150
|
+
text,
|
|
151
|
+
actionEl
|
|
152
|
+
] }),
|
|
153
|
+
dismissEl
|
|
154
|
+
] })
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
function StatusDot({ tone, size = "sm", pulse = false, halo = false, label, className, ref, ...rest }) {
|
|
159
|
+
return /* @__PURE__ */ jsx(
|
|
160
|
+
"span",
|
|
161
|
+
{
|
|
162
|
+
ref,
|
|
163
|
+
role: label ? "img" : void 0,
|
|
164
|
+
"aria-label": label,
|
|
165
|
+
"aria-hidden": label ? void 0 : true,
|
|
166
|
+
"data-tone": tone,
|
|
167
|
+
className: cn(
|
|
168
|
+
"inline-block shrink-0 rounded-full",
|
|
169
|
+
DOT_SIZE[size],
|
|
170
|
+
FILL[tone],
|
|
171
|
+
halo && HALO[tone],
|
|
172
|
+
pulse && "motion-safe:animate-pulse",
|
|
173
|
+
FORCED_MARK,
|
|
174
|
+
"forced-colors:border forced-colors:border-[CanvasText]",
|
|
175
|
+
className
|
|
176
|
+
),
|
|
177
|
+
...rest
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
var InStatGrid = /* @__PURE__ */ createContext(false);
|
|
182
|
+
function Stat({
|
|
183
|
+
label,
|
|
184
|
+
value,
|
|
185
|
+
sub,
|
|
186
|
+
tone = "neutral",
|
|
187
|
+
tip,
|
|
188
|
+
size = "md",
|
|
189
|
+
variant = "card",
|
|
190
|
+
loading = false,
|
|
191
|
+
className,
|
|
192
|
+
ref,
|
|
193
|
+
...rest
|
|
194
|
+
}) {
|
|
195
|
+
const inGrid = useContext(InStatGrid);
|
|
196
|
+
const quiet = variant === "inset" ? "text-th-hi2" : "text-th-hi3";
|
|
197
|
+
const body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
198
|
+
/* @__PURE__ */ jsx("dt", { className: cn("text-xs", quiet), children: tip ? /* @__PURE__ */ jsx(Tooltip, { tip, variant: "hint", children: label }) : label }),
|
|
199
|
+
loading ? /* @__PURE__ */ jsxs("dd", { className: "mt-1", "aria-busy": "true", children: [
|
|
200
|
+
/* @__PURE__ */ jsx(Skeleton, { className: cn("w-24", STAT_SKELETON[size]) }),
|
|
201
|
+
sub ? /* @__PURE__ */ jsx(Skeleton, { className: "mt-1.5 h-3 w-16" }) : null
|
|
202
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
203
|
+
/* @__PURE__ */ jsx(
|
|
204
|
+
"dd",
|
|
205
|
+
{
|
|
206
|
+
className: cn(
|
|
207
|
+
"mt-0.5 font-semibold tabular-nums tracking-tight [overflow-wrap:anywhere]",
|
|
208
|
+
STAT_VALUE_SIZE[size],
|
|
209
|
+
STAT_TONE[tone]
|
|
210
|
+
),
|
|
211
|
+
children: value
|
|
212
|
+
}
|
|
213
|
+
),
|
|
214
|
+
sub ? /* @__PURE__ */ jsx("dd", { className: cn("mt-0.5 text-xs", quiet), children: sub }) : null
|
|
215
|
+
] })
|
|
216
|
+
] });
|
|
217
|
+
if (variant === "card") {
|
|
218
|
+
return /* @__PURE__ */ jsx(Card, { ref, padding: "sm", className: cn("min-w-0", className), ...rest, children: inGrid ? body : /* @__PURE__ */ jsx("dl", { children: body }) });
|
|
219
|
+
}
|
|
220
|
+
const Box = inGrid ? "div" : "dl";
|
|
221
|
+
return /* @__PURE__ */ jsx(
|
|
222
|
+
Box,
|
|
223
|
+
{
|
|
224
|
+
ref,
|
|
225
|
+
className: cn("min-w-0", variant === "inset" && "rounded-lg bg-th-elevated p-3", className),
|
|
226
|
+
...rest,
|
|
227
|
+
children: body
|
|
228
|
+
}
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
function StatGrid({ cols, children, className, ref, ...rest }) {
|
|
232
|
+
return /* @__PURE__ */ jsx("dl", { ref, className: cn("grid gap-3", GRID_BASE[cols?.base ?? 2], GRID_MD[cols?.md ?? 4], className), ...rest, children: /* @__PURE__ */ jsx(InStatGrid.Provider, { value: true, children }) });
|
|
233
|
+
}
|
|
234
|
+
function Meter({
|
|
235
|
+
value,
|
|
236
|
+
min = 0,
|
|
237
|
+
max = 100,
|
|
238
|
+
label,
|
|
239
|
+
tone,
|
|
240
|
+
thresholds,
|
|
241
|
+
size = "sm",
|
|
242
|
+
orientation = "horizontal",
|
|
243
|
+
track = "elevated",
|
|
244
|
+
kind = "meter",
|
|
245
|
+
showValue = false,
|
|
246
|
+
className,
|
|
247
|
+
ref,
|
|
248
|
+
...rest
|
|
249
|
+
}) {
|
|
250
|
+
const span = max - min || 1;
|
|
251
|
+
const clamped = Math.min(Math.max(value, min), max);
|
|
252
|
+
const pct = (clamped - min) / span * 100;
|
|
253
|
+
const resolved = tone ?? (thresholds ? toneFor(clamped, thresholds) : "accent");
|
|
254
|
+
const vertical = orientation === "vertical";
|
|
255
|
+
const bar = /* @__PURE__ */ jsx(
|
|
256
|
+
"div",
|
|
257
|
+
{
|
|
258
|
+
...rest,
|
|
259
|
+
ref,
|
|
260
|
+
role: kind === "progress" ? "progressbar" : "meter",
|
|
261
|
+
"aria-label": label,
|
|
262
|
+
"aria-valuemin": min,
|
|
263
|
+
"aria-valuemax": max,
|
|
264
|
+
"aria-valuenow": clamped,
|
|
265
|
+
"aria-valuetext": `${Math.round(pct)}%`,
|
|
266
|
+
"data-tone": resolved,
|
|
267
|
+
className: cn(
|
|
268
|
+
"relative shrink-0 overflow-hidden rounded-full",
|
|
269
|
+
track === "overlay" ? "bg-th-overlay" : "bg-th-elevated",
|
|
270
|
+
"forced-colors:border forced-colors:border-[CanvasText] forced-colors:bg-[Canvas]",
|
|
271
|
+
vertical ? cn("h-full", METER_THICK_V[size]) : cn("w-full", METER_THICK[size]),
|
|
272
|
+
!showValue && className
|
|
273
|
+
),
|
|
274
|
+
children: /* @__PURE__ */ jsx(
|
|
275
|
+
"div",
|
|
276
|
+
{
|
|
277
|
+
className: cn(
|
|
278
|
+
"absolute rounded-full duration-300 ease-out motion-reduce:transition-none",
|
|
279
|
+
vertical ? "inset-x-0 bottom-0 transition-[height]" : "inset-y-0 start-0 transition-[width]",
|
|
280
|
+
METER_FILL[resolved],
|
|
281
|
+
FORCED_MARK
|
|
282
|
+
),
|
|
283
|
+
style: vertical ? { height: `${pct}%` } : { width: `${pct}%` }
|
|
284
|
+
}
|
|
285
|
+
)
|
|
286
|
+
}
|
|
287
|
+
);
|
|
288
|
+
if (!showValue || vertical) return bar;
|
|
289
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("flex w-full items-center gap-2", className), children: [
|
|
290
|
+
bar,
|
|
291
|
+
/* @__PURE__ */ jsxs("span", { "aria-hidden": "true", className: "w-9 shrink-0 text-end text-xs tabular-nums text-th-hi3", children: [
|
|
292
|
+
Math.round(pct),
|
|
293
|
+
"%"
|
|
294
|
+
] })
|
|
295
|
+
] });
|
|
296
|
+
}
|
|
297
|
+
function Sparkline({
|
|
298
|
+
values,
|
|
299
|
+
label,
|
|
300
|
+
tone = "chart-1",
|
|
301
|
+
width = 120,
|
|
302
|
+
height = 28,
|
|
303
|
+
fill = false,
|
|
304
|
+
min,
|
|
305
|
+
max,
|
|
306
|
+
className,
|
|
307
|
+
ref,
|
|
308
|
+
...rest
|
|
309
|
+
}) {
|
|
310
|
+
const strings = useNishStrings();
|
|
311
|
+
const { empty, lines, areas, baseline } = useMemo(
|
|
312
|
+
() => sparklineGeometry(values, width, height, min, max),
|
|
313
|
+
[values, width, height, min, max]
|
|
314
|
+
);
|
|
315
|
+
return /* @__PURE__ */ jsx(
|
|
316
|
+
"svg",
|
|
317
|
+
{
|
|
318
|
+
role: "img",
|
|
319
|
+
"aria-label": empty ? strings.noDataNamed(label) : label,
|
|
320
|
+
width,
|
|
321
|
+
height,
|
|
322
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
323
|
+
preserveAspectRatio: "none",
|
|
324
|
+
...rest,
|
|
325
|
+
ref,
|
|
326
|
+
className: cn("block shrink-0 overflow-visible", empty ? "text-th-line-strong" : SPARK_TONE[tone], className),
|
|
327
|
+
children: empty ? /* @__PURE__ */ jsx(
|
|
328
|
+
"path",
|
|
329
|
+
{
|
|
330
|
+
d: baseline,
|
|
331
|
+
stroke: "currentColor",
|
|
332
|
+
strokeWidth: 1.5,
|
|
333
|
+
strokeDasharray: "3 3",
|
|
334
|
+
vectorEffect: "non-scaling-stroke"
|
|
335
|
+
}
|
|
336
|
+
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
337
|
+
fill ? areas.map((d, i) => /* @__PURE__ */ jsx("path", { d, fill: "currentColor", fillOpacity: 0.15 }, `a${i}`)) : null,
|
|
338
|
+
lines.map((d, i) => /* @__PURE__ */ jsx(
|
|
339
|
+
"path",
|
|
340
|
+
{
|
|
341
|
+
d,
|
|
342
|
+
fill: "none",
|
|
343
|
+
stroke: "currentColor",
|
|
344
|
+
strokeWidth: 1.5,
|
|
345
|
+
strokeLinecap: "round",
|
|
346
|
+
strokeLinejoin: "round",
|
|
347
|
+
vectorEffect: "non-scaling-stroke"
|
|
348
|
+
},
|
|
349
|
+
i
|
|
350
|
+
))
|
|
351
|
+
] })
|
|
352
|
+
}
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
function Disclosure({
|
|
356
|
+
summary,
|
|
357
|
+
children,
|
|
358
|
+
defaultOpen = false,
|
|
359
|
+
open,
|
|
360
|
+
onOpenChange,
|
|
361
|
+
variant = "plain",
|
|
362
|
+
className,
|
|
363
|
+
ref,
|
|
364
|
+
...rest
|
|
365
|
+
}) {
|
|
366
|
+
const card = variant === "card";
|
|
367
|
+
const [inner, setInner] = useState(defaultOpen);
|
|
368
|
+
const isOpen = open ?? inner;
|
|
369
|
+
return /* @__PURE__ */ jsxs(
|
|
370
|
+
"details",
|
|
371
|
+
{
|
|
372
|
+
...rest,
|
|
373
|
+
ref,
|
|
374
|
+
open: isOpen,
|
|
375
|
+
"data-state": isOpen ? "open" : "closed",
|
|
376
|
+
onToggle: (e) => {
|
|
377
|
+
const now = e.currentTarget.open;
|
|
378
|
+
if (open === void 0) setInner(now);
|
|
379
|
+
if (open === void 0 || now !== open) onOpenChange?.(now);
|
|
380
|
+
},
|
|
381
|
+
className: cn(
|
|
382
|
+
"group",
|
|
383
|
+
card && "rounded-xl border border-th-line bg-th-surface shadow-card",
|
|
384
|
+
className
|
|
385
|
+
),
|
|
386
|
+
children: [
|
|
387
|
+
/* @__PURE__ */ jsxs(
|
|
388
|
+
"summary",
|
|
389
|
+
{
|
|
390
|
+
className: cn(
|
|
391
|
+
"flex cursor-pointer list-none items-center gap-2 rounded-lg text-sm font-medium text-th-hi select-none",
|
|
392
|
+
"[&::-webkit-details-marker]:hidden hover:text-th-hi pointer-coarse:min-h-11",
|
|
393
|
+
card ? "px-4 py-3" : "py-1.5"
|
|
394
|
+
),
|
|
395
|
+
children: [
|
|
396
|
+
/* @__PURE__ */ jsx(
|
|
397
|
+
ChevronRightIcon,
|
|
398
|
+
{
|
|
399
|
+
size: 14,
|
|
400
|
+
className: "shrink-0 text-th-hi3 transition-transform duration-150 group-open:rotate-90 rtl:rotate-180 rtl:group-open:rotate-90 motion-reduce:transition-none"
|
|
401
|
+
}
|
|
402
|
+
),
|
|
403
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1", children: summary })
|
|
404
|
+
]
|
|
405
|
+
}
|
|
406
|
+
),
|
|
407
|
+
/* @__PURE__ */ jsx("div", { className: cn("text-sm text-th-hi2", card ? "border-t border-th-line px-4 py-3" : "pb-2 ps-6 pt-1"), children })
|
|
408
|
+
]
|
|
409
|
+
}
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
function Kbd({ className, ref, ...rest }) {
|
|
413
|
+
return /* @__PURE__ */ jsx(
|
|
414
|
+
"kbd",
|
|
415
|
+
{
|
|
416
|
+
ref,
|
|
417
|
+
className: cn(
|
|
418
|
+
"inline-flex min-w-[1.5em] items-center justify-center rounded border border-th-line-strong bg-th-elevated px-1.5 font-mono text-2xs leading-4 text-th-hi2",
|
|
419
|
+
className
|
|
420
|
+
),
|
|
421
|
+
...rest
|
|
422
|
+
}
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
async function copyText(text) {
|
|
426
|
+
try {
|
|
427
|
+
if (typeof navigator !== "undefined" && navigator.clipboard && typeof window !== "undefined" && window.isSecureContext) {
|
|
428
|
+
await navigator.clipboard.writeText(text);
|
|
429
|
+
return true;
|
|
430
|
+
}
|
|
431
|
+
} catch {
|
|
432
|
+
}
|
|
433
|
+
if (typeof document === "undefined" || !document.body) return false;
|
|
434
|
+
const ta = document.createElement("textarea");
|
|
435
|
+
ta.value = text;
|
|
436
|
+
ta.setAttribute("readonly", "");
|
|
437
|
+
ta.setAttribute("aria-hidden", "true");
|
|
438
|
+
ta.style.position = "fixed";
|
|
439
|
+
ta.style.top = "-1000px";
|
|
440
|
+
ta.style.opacity = "0";
|
|
441
|
+
const active = document.activeElement;
|
|
442
|
+
document.body.appendChild(ta);
|
|
443
|
+
ta.select();
|
|
444
|
+
try {
|
|
445
|
+
ta.setSelectionRange(0, text.length);
|
|
446
|
+
} catch {
|
|
447
|
+
}
|
|
448
|
+
let ok = false;
|
|
449
|
+
try {
|
|
450
|
+
ok = typeof document.execCommand === "function" && document.execCommand("copy");
|
|
451
|
+
} catch {
|
|
452
|
+
ok = false;
|
|
453
|
+
}
|
|
454
|
+
ta.remove();
|
|
455
|
+
active?.focus?.();
|
|
456
|
+
return ok;
|
|
457
|
+
}
|
|
458
|
+
var COPIED_MS = 1500;
|
|
459
|
+
function CopyButton({
|
|
460
|
+
text,
|
|
461
|
+
label,
|
|
462
|
+
copiedLabel,
|
|
463
|
+
failedLabel = "Copy failed",
|
|
464
|
+
iconOnly = false,
|
|
465
|
+
size = "sm",
|
|
466
|
+
variant = "secondary",
|
|
467
|
+
onCopy,
|
|
468
|
+
className,
|
|
469
|
+
ref,
|
|
470
|
+
...rest
|
|
471
|
+
}) {
|
|
472
|
+
const strings = useNishStrings();
|
|
473
|
+
const idleText = label ?? strings.copy;
|
|
474
|
+
const doneText = copiedLabel ?? strings.copied;
|
|
475
|
+
const [state, setState] = useState("idle");
|
|
476
|
+
const timer = useRef(null);
|
|
477
|
+
useEffect(
|
|
478
|
+
() => () => {
|
|
479
|
+
if (timer.current) clearTimeout(timer.current);
|
|
480
|
+
},
|
|
481
|
+
[]
|
|
482
|
+
);
|
|
483
|
+
const onClick = async () => {
|
|
484
|
+
const ok = await copyText(text);
|
|
485
|
+
onCopy?.(ok);
|
|
486
|
+
setState(ok ? "copied" : "failed");
|
|
487
|
+
if (timer.current) clearTimeout(timer.current);
|
|
488
|
+
timer.current = setTimeout(() => setState("idle"), COPIED_MS);
|
|
489
|
+
};
|
|
490
|
+
const shownText = state === "copied" ? doneText : state === "failed" ? failedLabel : idleText;
|
|
491
|
+
const iconSize = size === "sm" ? 14 : 16;
|
|
492
|
+
const icon = state === "copied" ? /* @__PURE__ */ jsx(CheckIcon, { size: iconSize, className: "text-th-ok" }) : /* @__PURE__ */ jsx(CopyIcon, { size: iconSize });
|
|
493
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
494
|
+
iconOnly ? /* @__PURE__ */ jsx(IconButton, { ref, label: shownText, size, onClick, className, "data-state": state, ...rest, children: icon }) : /* @__PURE__ */ jsx(Button, { ref, variant, size, icon, onClick, className, "data-state": state, ...rest, children: shownText }),
|
|
495
|
+
/* @__PURE__ */ jsx("span", { role: "status", "aria-live": "polite", className: "sr-only", children: state === "copied" ? doneText : state === "failed" ? failedLabel : "" })
|
|
496
|
+
] });
|
|
497
|
+
}
|
|
498
|
+
function PageHeader({
|
|
499
|
+
title,
|
|
500
|
+
description,
|
|
501
|
+
eyebrow,
|
|
502
|
+
back,
|
|
503
|
+
actions,
|
|
504
|
+
as: H = "h1",
|
|
505
|
+
sticky = false,
|
|
506
|
+
collapseWhenStuck = true,
|
|
507
|
+
className,
|
|
508
|
+
ref: refProp,
|
|
509
|
+
...rest
|
|
510
|
+
}) {
|
|
511
|
+
const ref = useRef(null);
|
|
512
|
+
const stuck = useStuck(ref) && sticky;
|
|
513
|
+
const collapsed = stuck && collapseWhenStuck;
|
|
514
|
+
return /* @__PURE__ */ jsxs(
|
|
515
|
+
"header",
|
|
516
|
+
{
|
|
517
|
+
...rest,
|
|
518
|
+
ref: mergeRefs(ref, refProp),
|
|
519
|
+
"data-nish-bar": sticky ? "" : void 0,
|
|
520
|
+
className: cn(
|
|
521
|
+
"flex flex-col gap-2",
|
|
522
|
+
sticky && cn(
|
|
523
|
+
"sticky top-[var(--nish-header-h,0px)] z-[var(--nish-z-sticky,20)] -mx-[var(--nish-page-gutter,1rem)] border-b bg-th-bg px-[var(--nish-page-gutter,1rem)] py-3",
|
|
524
|
+
stuck ? "border-th-line" : "border-transparent"
|
|
525
|
+
),
|
|
526
|
+
className
|
|
527
|
+
),
|
|
528
|
+
children: [
|
|
529
|
+
back ? /* @__PURE__ */ jsx("div", { className: "text-sm", children: back }) : null,
|
|
530
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-end justify-between gap-x-4 gap-y-3", children: [
|
|
531
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 basis-64", children: [
|
|
532
|
+
eyebrow ? /* @__PURE__ */ jsx("p", { className: "mb-1 text-xs font-medium uppercase tracking-wider text-th-hi3", children: eyebrow }) : null,
|
|
533
|
+
/* @__PURE__ */ jsx(
|
|
534
|
+
H,
|
|
535
|
+
{
|
|
536
|
+
className: cn(
|
|
537
|
+
"text-2xl font-semibold tracking-tight text-th-hi [overflow-wrap:anywhere]",
|
|
538
|
+
collapsed && "max-sm:truncate max-sm:text-base max-sm:[overflow-wrap:normal]"
|
|
539
|
+
),
|
|
540
|
+
children: title
|
|
541
|
+
}
|
|
542
|
+
),
|
|
543
|
+
description ? /* @__PURE__ */ jsx("p", { className: cn("mt-1 text-sm text-th-hi2", collapsed && "max-sm:hidden"), children: description }) : null
|
|
544
|
+
] }),
|
|
545
|
+
actions ? /* @__PURE__ */ jsx("div", { className: "flex flex-wrap items-center gap-2", children: actions }) : null
|
|
546
|
+
] })
|
|
547
|
+
]
|
|
548
|
+
}
|
|
549
|
+
);
|
|
550
|
+
}
|
|
551
|
+
function MoreVerticalIcon({ size = 18 }) {
|
|
552
|
+
return /* @__PURE__ */ jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", focusable: "false", children: [
|
|
553
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "5", r: "1.8" }),
|
|
554
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "1.8" }),
|
|
555
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "19", r: "1.8" })
|
|
556
|
+
] });
|
|
557
|
+
}
|
|
558
|
+
function AppHeader({
|
|
559
|
+
name,
|
|
560
|
+
icon,
|
|
561
|
+
brand,
|
|
562
|
+
hub = false,
|
|
563
|
+
actions,
|
|
564
|
+
nav,
|
|
565
|
+
themeToggle,
|
|
566
|
+
sticky = true,
|
|
567
|
+
innerClassName,
|
|
568
|
+
homeHref,
|
|
569
|
+
hideNameBelow,
|
|
570
|
+
navLabel,
|
|
571
|
+
compactPill = false,
|
|
572
|
+
glass = false,
|
|
573
|
+
overflowActions,
|
|
574
|
+
className,
|
|
575
|
+
ref: refProp,
|
|
576
|
+
...rest
|
|
577
|
+
}) {
|
|
578
|
+
const strings = useNishStrings();
|
|
579
|
+
const ref = useRef(null);
|
|
580
|
+
useHeightVar(ref, "--nish-header-h", sticky);
|
|
581
|
+
const stuck = useStuck(ref) && sticky;
|
|
582
|
+
const inlineActionsRef = useRef(null);
|
|
583
|
+
useEffect(() => {
|
|
584
|
+
inlineActionsRef.current?.querySelectorAll('[role="menuitem"]').forEach((el) => {
|
|
585
|
+
el.removeAttribute("role");
|
|
586
|
+
el.tabIndex = el.getAttribute("aria-disabled") === "true" ? -1 : 0;
|
|
587
|
+
});
|
|
588
|
+
});
|
|
589
|
+
const toggle = themeToggle === false ? null : themeToggle ?? /* @__PURE__ */ jsx(ThemeToggle, {});
|
|
590
|
+
const hideName = hideNameBelow === "sm" && icon != null;
|
|
591
|
+
const hubHref = hub ? safeUrl(hub.href) : null;
|
|
592
|
+
const homeUrl = homeHref == null ? null : safeUrl(homeHref);
|
|
593
|
+
if (homeHref != null && homeUrl == null) warnDev(`AppHeader: homeHref "${homeHref}" is not a safe URL and was dropped`);
|
|
594
|
+
if (hub && hubHref == null) warnDev(`nish-ui: AppHeader hid the hub pill because its href is not safe (${hub.href.slice(0, 40)}).`);
|
|
595
|
+
const mark = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
596
|
+
icon ? /* @__PURE__ */ jsx("span", { className: "shrink-0 text-th-accent [&>svg]:size-5", children: icon }) : null,
|
|
597
|
+
/* @__PURE__ */ jsx("span", { className: cn("truncate", hideName && "max-sm:sr-only"), children: name })
|
|
598
|
+
] });
|
|
599
|
+
const markClass = "inline-flex min-w-0 items-center gap-2 text-xl font-bold tracking-tight text-th-hi";
|
|
600
|
+
const pillArrow = /* @__PURE__ */ jsx("span", { className: "inline-block rtl:-scale-x-100", children: "\u2190" });
|
|
601
|
+
return /* @__PURE__ */ jsxs(
|
|
602
|
+
"header",
|
|
603
|
+
{
|
|
604
|
+
...rest,
|
|
605
|
+
ref: mergeRefs(ref, refProp),
|
|
606
|
+
"data-nish-bar": sticky ? "" : void 0,
|
|
607
|
+
className: cn(
|
|
608
|
+
"border-b border-th-line pl-[env(safe-area-inset-left)] pr-[env(safe-area-inset-right)] pt-[env(safe-area-inset-top)]",
|
|
609
|
+
glass ? "bg-th-bg supports-[backdrop-filter]:bg-th-bg/80 supports-[backdrop-filter]:backdrop-blur-xl" : "bg-th-bg",
|
|
610
|
+
sticky && "sticky top-0 z-[calc(var(--nish-z-sticky,20)+10)] transition-shadow",
|
|
611
|
+
stuck && "shadow-[var(--nish-shadow-card)]",
|
|
612
|
+
className
|
|
613
|
+
),
|
|
614
|
+
children: [
|
|
615
|
+
/* @__PURE__ */ jsxs(
|
|
616
|
+
"div",
|
|
617
|
+
{
|
|
618
|
+
className: cn(
|
|
619
|
+
"@container/header flex min-h-14 flex-nowrap items-center gap-2 px-[var(--nish-page-gutter,1rem)] py-2 sm:gap-3",
|
|
620
|
+
innerClassName
|
|
621
|
+
),
|
|
622
|
+
children: [
|
|
623
|
+
hub && hubHref != null ? compactPill ? /* @__PURE__ */ jsxs("a", { className: "nish-pill-link nish-pill-link--compact", href: hubHref, title: hub.title ?? strings.hubTitle, children: [
|
|
624
|
+
pillArrow,
|
|
625
|
+
" ",
|
|
626
|
+
/* @__PURE__ */ jsx("span", { className: "nish-pill-link-label", children: hub.label })
|
|
627
|
+
] }) : /* @__PURE__ */ jsxs(
|
|
628
|
+
"a",
|
|
629
|
+
{
|
|
630
|
+
className: "nish-pill-link @max-[400px]/header:min-w-11 @max-[400px]/header:justify-center @max-[400px]/header:px-1.5 @max-[400px]/header:[&_.nish-pill-link-label]:sr-only",
|
|
631
|
+
href: hubHref,
|
|
632
|
+
title: hub.title ?? strings.hubTitle,
|
|
633
|
+
children: [
|
|
634
|
+
pillArrow,
|
|
635
|
+
" ",
|
|
636
|
+
/* @__PURE__ */ jsx("span", { className: "nish-pill-link-label", children: hub.label })
|
|
637
|
+
]
|
|
638
|
+
}
|
|
639
|
+
) : null,
|
|
640
|
+
brand != null ? /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center", children: [
|
|
641
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: name }),
|
|
642
|
+
brand
|
|
643
|
+
] }) : homeUrl != null ? /* @__PURE__ */ jsx("a", { href: homeUrl, className: cn(markClass, "min-h-11 min-w-11 rounded-lg", hideName && "max-sm:justify-center"), children: mark }) : /* @__PURE__ */ jsx("span", { className: markClass, children: mark }),
|
|
644
|
+
/* @__PURE__ */ jsxs("div", { className: "ms-auto flex shrink-0 items-center gap-2", children: [
|
|
645
|
+
actions,
|
|
646
|
+
overflowActions ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
647
|
+
/* @__PURE__ */ jsx("div", { ref: inlineActionsRef, className: "hidden items-center gap-2 sm:flex [&>button]:w-auto", children: overflowActions }),
|
|
648
|
+
/* @__PURE__ */ jsx("div", { className: "sm:hidden", children: /* @__PURE__ */ jsx(
|
|
649
|
+
DropdownMenu,
|
|
650
|
+
{
|
|
651
|
+
align: "end",
|
|
652
|
+
trigger: /* @__PURE__ */ jsx(IconButton, { label: strings.moreActions, children: /* @__PURE__ */ jsx(MoreVerticalIcon, {}) }),
|
|
653
|
+
children: overflowActions
|
|
654
|
+
}
|
|
655
|
+
) })
|
|
656
|
+
] }) : null,
|
|
657
|
+
toggle
|
|
658
|
+
] })
|
|
659
|
+
]
|
|
660
|
+
}
|
|
661
|
+
),
|
|
662
|
+
nav ? /* @__PURE__ */ jsx(
|
|
663
|
+
"nav",
|
|
664
|
+
{
|
|
665
|
+
"aria-label": navLabel ?? strings.sections,
|
|
666
|
+
className: cn("nish-no-scrollbar -mb-px flex gap-6 overflow-x-auto px-[var(--nish-page-gutter,1rem)]", innerClassName),
|
|
667
|
+
children: nav
|
|
668
|
+
}
|
|
669
|
+
) : null
|
|
670
|
+
]
|
|
671
|
+
}
|
|
672
|
+
);
|
|
673
|
+
}
|
|
674
|
+
function SectionHeader({ title, id, as: H = "h2", meta, action, className, ref, ...rest }) {
|
|
675
|
+
return /* @__PURE__ */ jsxs("div", { ref, className: cn("mb-3 flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1", className), ...rest, children: [
|
|
676
|
+
/* @__PURE__ */ jsx(H, { id, className: "min-w-0 text-lg font-semibold tracking-tight text-th-hi [overflow-wrap:anywhere]", children: title }),
|
|
677
|
+
meta != null || action != null ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
678
|
+
meta != null ? /* @__PURE__ */ jsx("span", { className: "text-sm text-th-hi3", children: meta }) : null,
|
|
679
|
+
action
|
|
680
|
+
] }) : null
|
|
681
|
+
] });
|
|
682
|
+
}
|
|
683
|
+
function KeyValueList({ items, dense = false, as = "ul", className, ref, ...rest }) {
|
|
684
|
+
const row = (wrap) => cn(
|
|
685
|
+
"flex min-w-0 items-center justify-between gap-3 border-b border-th-line last:border-b-0",
|
|
686
|
+
dense ? "min-h-8" : "min-h-11",
|
|
687
|
+
wrap && (dense ? "py-1" : "py-2")
|
|
688
|
+
);
|
|
689
|
+
const labelCls = (wrap) => wrap === "words" ? "min-w-0 shrink-0 max-w-[calc(60%_-_0.75rem)] [overflow-wrap:anywhere]" : wrap ? "shrink-0" : "min-w-0";
|
|
690
|
+
const valueCls = (wrap) => wrap === "words" ? "min-w-0 flex-1 [overflow-wrap:anywhere]" : wrap ? "min-w-0 break-all" : "shrink-0";
|
|
691
|
+
if (as === "dl") {
|
|
692
|
+
return /* @__PURE__ */ jsx(
|
|
693
|
+
"dl",
|
|
694
|
+
{
|
|
695
|
+
ref,
|
|
696
|
+
className: cn("grid text-sm text-th-hi", className),
|
|
697
|
+
...rest,
|
|
698
|
+
children: items.map((it) => /* @__PURE__ */ jsxs("div", { className: row(it.wrap), children: [
|
|
699
|
+
/* @__PURE__ */ jsx("dt", { className: cn("text-th-hi2", labelCls(it.wrap)), children: it.label }),
|
|
700
|
+
/* @__PURE__ */ jsx("dd", { className: cn("m-0 text-end", valueCls(it.wrap)), children: it.value })
|
|
701
|
+
] }, it.key))
|
|
702
|
+
}
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
return /* @__PURE__ */ jsx("ul", { ref, className: cn("grid text-sm text-th-hi", className), ...rest, children: items.map((it) => /* @__PURE__ */ jsxs("li", { className: row(it.wrap), children: [
|
|
706
|
+
/* @__PURE__ */ jsx("span", { className: cn("flex items-center gap-2", labelCls(it.wrap)), children: it.label }),
|
|
707
|
+
/* @__PURE__ */ jsx("span", { className: cn("flex items-center justify-end gap-2 text-end", valueCls(it.wrap)), children: it.value })
|
|
708
|
+
] }, it.key)) });
|
|
709
|
+
}
|
|
710
|
+
function ChartLegend({ items, marker = "line", label, className, ref, ...rest }) {
|
|
711
|
+
const strings = useNishStrings();
|
|
712
|
+
return /* @__PURE__ */ jsx(
|
|
713
|
+
"ul",
|
|
714
|
+
{
|
|
715
|
+
ref,
|
|
716
|
+
"aria-label": label ?? strings.legend,
|
|
717
|
+
className: cn("flex flex-wrap gap-x-4 gap-y-1 text-xs text-th-hi2", className),
|
|
718
|
+
...rest,
|
|
719
|
+
children: items.map((it) => /* @__PURE__ */ jsxs("li", { className: "inline-flex items-center gap-1.5", children: [
|
|
720
|
+
/* @__PURE__ */ jsx(
|
|
721
|
+
"i",
|
|
722
|
+
{
|
|
723
|
+
"aria-hidden": "true",
|
|
724
|
+
className: cn(
|
|
725
|
+
"inline-block shrink-0",
|
|
726
|
+
marker === "dot" ? "size-2 rounded-full" : "h-0.75 w-2.5 rounded-sm",
|
|
727
|
+
LEGEND_FILL[it.tone],
|
|
728
|
+
"forced-colors:forced-color-adjust-none forced-colors:bg-[CanvasText]"
|
|
729
|
+
)
|
|
730
|
+
}
|
|
731
|
+
),
|
|
732
|
+
it.label
|
|
733
|
+
] }, it.label))
|
|
734
|
+
}
|
|
735
|
+
);
|
|
736
|
+
}
|
|
737
|
+
export {
|
|
738
|
+
AppHeader,
|
|
739
|
+
Callout,
|
|
740
|
+
ChartLegend,
|
|
741
|
+
CopyButton,
|
|
742
|
+
Disclosure,
|
|
743
|
+
Kbd,
|
|
744
|
+
KeyValueList,
|
|
745
|
+
Meter,
|
|
746
|
+
PageHeader,
|
|
747
|
+
SectionHeader,
|
|
748
|
+
Sparkline,
|
|
749
|
+
Stat,
|
|
750
|
+
StatGrid,
|
|
751
|
+
StatusDot,
|
|
752
|
+
copyText,
|
|
753
|
+
signTone,
|
|
754
|
+
toneFor2 as toneFor
|
|
755
|
+
};
|