lldlab-ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +909 -0
- package/dist/index.d.ts +657 -0
- package/dist/index.js +1584 -0
- package/dist/index.js.map +1 -0
- package/dist/theme.css +259 -0
- package/package.json +51 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1584 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// src/theme/Theme.tsx
|
|
4
|
+
import { createContext, useContext } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
var ThemeToneContext = createContext(void 0);
|
|
7
|
+
function useThemeTone() {
|
|
8
|
+
return useContext(ThemeToneContext);
|
|
9
|
+
}
|
|
10
|
+
function Theme({ as, tone = "light", ...rest }) {
|
|
11
|
+
const C = as ?? "div";
|
|
12
|
+
return /* @__PURE__ */ jsx(ThemeToneContext.Provider, { value: tone, children: /* @__PURE__ */ jsx(C, { ...rest, "data-theme": tone, className: "bg-surface text-on-surface" }) });
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// src/internal/cx.ts
|
|
16
|
+
function cx(...parts) {
|
|
17
|
+
return parts.filter(Boolean).join(" ");
|
|
18
|
+
}
|
|
19
|
+
var FOCUS_RING = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand-cobalt";
|
|
20
|
+
var TOUCH = "max-md:min-h-11";
|
|
21
|
+
var TOUCH_ICON = "max-md:min-h-11 max-md:min-w-11";
|
|
22
|
+
|
|
23
|
+
// src/internal/responsive.ts
|
|
24
|
+
var BREAKPOINTS = ["base", "sm", "md", "lg", "xl"];
|
|
25
|
+
function responsive(table, value) {
|
|
26
|
+
if (value === void 0) return "";
|
|
27
|
+
if (typeof value !== "object") return table.base[value];
|
|
28
|
+
return BREAKPOINTS.flatMap((bp) => {
|
|
29
|
+
const v = value[bp];
|
|
30
|
+
return v === void 0 ? [] : [table[bp][v]];
|
|
31
|
+
}).join(" ");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/internal/tables.ts
|
|
35
|
+
var GAP = {
|
|
36
|
+
base: { none: "gap-0", "2xs": "gap-space-2xs", xs: "gap-space-xs", sm: "gap-space-sm", md: "gap-space-md", lg: "gap-space-lg", xl: "gap-space-xl", "2xl": "gap-space-2xl" },
|
|
37
|
+
sm: { none: "sm:gap-0", "2xs": "sm:gap-space-2xs", xs: "sm:gap-space-xs", sm: "sm:gap-space-sm", md: "sm:gap-space-md", lg: "sm:gap-space-lg", xl: "sm:gap-space-xl", "2xl": "sm:gap-space-2xl" },
|
|
38
|
+
md: { none: "md:gap-0", "2xs": "md:gap-space-2xs", xs: "md:gap-space-xs", sm: "md:gap-space-sm", md: "md:gap-space-md", lg: "md:gap-space-lg", xl: "md:gap-space-xl", "2xl": "md:gap-space-2xl" },
|
|
39
|
+
lg: { none: "lg:gap-0", "2xs": "lg:gap-space-2xs", xs: "lg:gap-space-xs", sm: "lg:gap-space-sm", md: "lg:gap-space-md", lg: "lg:gap-space-lg", xl: "lg:gap-space-xl", "2xl": "lg:gap-space-2xl" },
|
|
40
|
+
xl: { none: "xl:gap-0", "2xs": "xl:gap-space-2xs", xs: "xl:gap-space-xs", sm: "xl:gap-space-sm", md: "xl:gap-space-md", lg: "xl:gap-space-lg", xl: "xl:gap-space-xl", "2xl": "xl:gap-space-2xl" }
|
|
41
|
+
};
|
|
42
|
+
var PADDING = {
|
|
43
|
+
base: { none: "p-0", "2xs": "p-space-2xs", xs: "p-space-xs", sm: "p-space-sm", md: "p-space-md", lg: "p-space-lg", xl: "p-space-xl", "2xl": "p-space-2xl" },
|
|
44
|
+
sm: { none: "sm:p-0", "2xs": "sm:p-space-2xs", xs: "sm:p-space-xs", sm: "sm:p-space-sm", md: "sm:p-space-md", lg: "sm:p-space-lg", xl: "sm:p-space-xl", "2xl": "sm:p-space-2xl" },
|
|
45
|
+
md: { none: "md:p-0", "2xs": "md:p-space-2xs", xs: "md:p-space-xs", sm: "md:p-space-sm", md: "md:p-space-md", lg: "md:p-space-lg", xl: "md:p-space-xl", "2xl": "md:p-space-2xl" },
|
|
46
|
+
lg: { none: "lg:p-0", "2xs": "lg:p-space-2xs", xs: "lg:p-space-xs", sm: "lg:p-space-sm", md: "lg:p-space-md", lg: "lg:p-space-lg", xl: "lg:p-space-xl", "2xl": "lg:p-space-2xl" },
|
|
47
|
+
xl: { none: "xl:p-0", "2xs": "xl:p-space-2xs", xs: "xl:p-space-xs", sm: "xl:p-space-sm", md: "xl:p-space-md", lg: "xl:p-space-lg", xl: "xl:p-space-xl", "2xl": "xl:p-space-2xl" }
|
|
48
|
+
};
|
|
49
|
+
var COLS = {
|
|
50
|
+
base: { 1: "grid-cols-1", 2: "grid-cols-2", 3: "grid-cols-3", 4: "grid-cols-4", 5: "grid-cols-5", 6: "grid-cols-6" },
|
|
51
|
+
sm: { 1: "sm:grid-cols-1", 2: "sm:grid-cols-2", 3: "sm:grid-cols-3", 4: "sm:grid-cols-4", 5: "sm:grid-cols-5", 6: "sm:grid-cols-6" },
|
|
52
|
+
md: { 1: "md:grid-cols-1", 2: "md:grid-cols-2", 3: "md:grid-cols-3", 4: "md:grid-cols-4", 5: "md:grid-cols-5", 6: "md:grid-cols-6" },
|
|
53
|
+
lg: { 1: "lg:grid-cols-1", 2: "lg:grid-cols-2", 3: "lg:grid-cols-3", 4: "lg:grid-cols-4", 5: "lg:grid-cols-5", 6: "lg:grid-cols-6" },
|
|
54
|
+
xl: { 1: "xl:grid-cols-1", 2: "xl:grid-cols-2", 3: "xl:grid-cols-3", 4: "xl:grid-cols-4", 5: "xl:grid-cols-5", 6: "xl:grid-cols-6" }
|
|
55
|
+
};
|
|
56
|
+
var DIRECTION = {
|
|
57
|
+
base: { row: "flex-row", column: "flex-col" },
|
|
58
|
+
sm: { row: "sm:flex-row", column: "sm:flex-col" },
|
|
59
|
+
md: { row: "md:flex-row", column: "md:flex-col" },
|
|
60
|
+
lg: { row: "lg:flex-row", column: "lg:flex-col" },
|
|
61
|
+
xl: { row: "xl:flex-row", column: "xl:flex-col" }
|
|
62
|
+
};
|
|
63
|
+
var ALIGN = {
|
|
64
|
+
base: { start: "items-start", center: "items-center", end: "items-end", stretch: "items-stretch", baseline: "items-baseline" },
|
|
65
|
+
sm: { start: "sm:items-start", center: "sm:items-center", end: "sm:items-end", stretch: "sm:items-stretch", baseline: "sm:items-baseline" },
|
|
66
|
+
md: { start: "md:items-start", center: "md:items-center", end: "md:items-end", stretch: "md:items-stretch", baseline: "md:items-baseline" },
|
|
67
|
+
lg: { start: "lg:items-start", center: "lg:items-center", end: "lg:items-end", stretch: "lg:items-stretch", baseline: "lg:items-baseline" },
|
|
68
|
+
xl: { start: "xl:items-start", center: "xl:items-center", end: "xl:items-end", stretch: "xl:items-stretch", baseline: "xl:items-baseline" }
|
|
69
|
+
};
|
|
70
|
+
var JUSTIFY = {
|
|
71
|
+
base: { start: "justify-start", center: "justify-center", end: "justify-end", between: "justify-between" },
|
|
72
|
+
sm: { start: "sm:justify-start", center: "sm:justify-center", end: "sm:justify-end", between: "sm:justify-between" },
|
|
73
|
+
md: { start: "md:justify-start", center: "md:justify-center", end: "md:justify-end", between: "md:justify-between" },
|
|
74
|
+
lg: { start: "lg:justify-start", center: "lg:justify-center", end: "lg:justify-end", between: "lg:justify-between" },
|
|
75
|
+
xl: { start: "xl:justify-start", center: "xl:justify-center", end: "xl:justify-end", between: "xl:justify-between" }
|
|
76
|
+
};
|
|
77
|
+
var HEADING_SIZE = {
|
|
78
|
+
base: { display: "text-display", xl: "text-headline-xl", lg: "text-headline-lg", md: "text-headline-md", sm: "text-headline-sm" },
|
|
79
|
+
sm: { display: "sm:text-display", xl: "sm:text-headline-xl", lg: "sm:text-headline-lg", md: "sm:text-headline-md", sm: "sm:text-headline-sm" },
|
|
80
|
+
md: { display: "md:text-display", xl: "md:text-headline-xl", lg: "md:text-headline-lg", md: "md:text-headline-md", sm: "md:text-headline-sm" },
|
|
81
|
+
lg: { display: "lg:text-display", xl: "lg:text-headline-xl", lg: "lg:text-headline-lg", md: "lg:text-headline-md", sm: "lg:text-headline-sm" },
|
|
82
|
+
xl: { display: "xl:text-display", xl: "xl:text-headline-xl", lg: "xl:text-headline-lg", md: "xl:text-headline-md", sm: "xl:text-headline-sm" }
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// src/primitives/Box.tsx
|
|
86
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
87
|
+
var SURFACE_TONE = {
|
|
88
|
+
surface: "bg-surface text-on-surface",
|
|
89
|
+
subtle: "bg-surface-subtle text-on-surface",
|
|
90
|
+
elevated: "bg-surface-elevated text-on-surface",
|
|
91
|
+
low: "bg-surface-container-low text-on-surface",
|
|
92
|
+
inverse: "bg-brand-obsidian text-on-primary"
|
|
93
|
+
};
|
|
94
|
+
var RADIUS = { none: "", sm: "rounded", md: "rounded-lg", lg: "rounded-xl" };
|
|
95
|
+
var BORDER = { none: "", subtle: "border border-border-subtle", strong: "border border-border-strong" };
|
|
96
|
+
var SHADOW = { none: "", sm: "shadow-sm", md: "shadow-md" };
|
|
97
|
+
function Box({ as, padding, radius = "none", tone, border = "none", shadow = "none", ...rest }) {
|
|
98
|
+
const C = as ?? "div";
|
|
99
|
+
return /* @__PURE__ */ jsx2(
|
|
100
|
+
C,
|
|
101
|
+
{
|
|
102
|
+
...rest,
|
|
103
|
+
className: cx("min-w-0 max-w-full", tone && SURFACE_TONE[tone], responsive(PADDING, padding), RADIUS[radius], BORDER[border], SHADOW[shadow])
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// src/primitives/Stack.tsx
|
|
109
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
110
|
+
function Stack({ as, direction = "column", gap = "md", align, justify, wrap, ...rest }) {
|
|
111
|
+
const C = as ?? "div";
|
|
112
|
+
return /* @__PURE__ */ jsx3(
|
|
113
|
+
C,
|
|
114
|
+
{
|
|
115
|
+
...rest,
|
|
116
|
+
className: cx(
|
|
117
|
+
"flex min-w-0",
|
|
118
|
+
responsive(DIRECTION, direction),
|
|
119
|
+
responsive(GAP, gap),
|
|
120
|
+
responsive(ALIGN, align),
|
|
121
|
+
responsive(JUSTIFY, justify),
|
|
122
|
+
wrap && "flex-wrap"
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// src/primitives/Grid.tsx
|
|
129
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
130
|
+
function Grid({ as, cols = 1, gap = "md", ...rest }) {
|
|
131
|
+
const C = as ?? "div";
|
|
132
|
+
const c = typeof cols === "object" ? { base: 1, ...cols } : { base: 1, md: cols };
|
|
133
|
+
return /* @__PURE__ */ jsx4(C, { ...rest, className: cx("grid min-w-0", responsive(COLS, c), responsive(GAP, gap)) });
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// src/primitives/Container.tsx
|
|
137
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
138
|
+
var SIZE = { md: "max-w-3xl", lg: "max-w-5xl", xl: "max-w-7xl" };
|
|
139
|
+
function Container({ as, size = "xl", ...rest }) {
|
|
140
|
+
const C = as ?? "div";
|
|
141
|
+
return /* @__PURE__ */ jsx5(C, { ...rest, className: cx("mx-auto w-full min-w-0 px-gutter-fluid", SIZE[size]) });
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/primitives/Section.tsx
|
|
145
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
146
|
+
var PADDING2 = { md: "py-section-md", lg: "py-section-lg", xl: "py-section-xl" };
|
|
147
|
+
var PATTERN = { none: "", dots: "bg-pattern-dots", grid: "bg-pattern-grid" };
|
|
148
|
+
function Section({ as, tone, padding = "lg", pattern = "none", ...rest }) {
|
|
149
|
+
const C = as ?? "section";
|
|
150
|
+
return /* @__PURE__ */ jsx6(C, { ...rest, className: cx("w-full min-w-0", tone && SURFACE_TONE[tone], PADDING2[padding], PATTERN[pattern]) });
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// src/primitives/Split.tsx
|
|
154
|
+
import { jsx as jsx7, jsxs } from "react/jsx-runtime";
|
|
155
|
+
var MAIN = { "8/4": "xl:col-span-8", "1/1": "xl:col-span-6", "9/3": "xl:col-span-9" };
|
|
156
|
+
var ASIDE = { "8/4": "xl:col-span-4", "1/1": "xl:col-span-6", "9/3": "xl:col-span-3" };
|
|
157
|
+
function Split({ ratio = "8/4", aside, sticky, gap = "lg", children, ...rest }) {
|
|
158
|
+
return /* @__PURE__ */ jsxs("div", { ...rest, className: cx("grid min-w-0 grid-cols-1 xl:grid-cols-12", responsive(GAP, gap)), children: [
|
|
159
|
+
/* @__PURE__ */ jsx7("div", { className: cx("min-w-0", MAIN[ratio]), children }),
|
|
160
|
+
/* @__PURE__ */ jsx7("aside", { className: cx("min-w-0", ASIDE[ratio], sticky && "xl:sticky xl:top-space-lg xl:self-start"), children: aside })
|
|
161
|
+
] });
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// src/internal/tones.ts
|
|
165
|
+
var TEXT_TONE = {
|
|
166
|
+
default: "text-on-surface",
|
|
167
|
+
muted: "text-on-surface-variant",
|
|
168
|
+
strong: "text-ink",
|
|
169
|
+
brand: "text-fg-brand",
|
|
170
|
+
success: "text-fg-success",
|
|
171
|
+
warning: "text-fg-warning",
|
|
172
|
+
danger: "text-fg-danger",
|
|
173
|
+
inverse: "text-on-primary"
|
|
174
|
+
};
|
|
175
|
+
var DOT_TONE = {
|
|
176
|
+
neutral: "bg-border-strong",
|
|
177
|
+
brand: "bg-brand-cobalt",
|
|
178
|
+
success: "bg-brand-emerald",
|
|
179
|
+
warning: "bg-brand-amber",
|
|
180
|
+
danger: "bg-brand-crimson"
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
// src/components/Icon.tsx
|
|
184
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
185
|
+
var SIZE2 = { sm: "text-[16px]", md: "text-[20px]", lg: "text-[24px]" };
|
|
186
|
+
function Icon({ name, size = "md", tone = "inherit", filled, spin, label, ...rest }) {
|
|
187
|
+
return /* @__PURE__ */ jsx8(
|
|
188
|
+
"span",
|
|
189
|
+
{
|
|
190
|
+
...rest,
|
|
191
|
+
"aria-hidden": label ? void 0 : true,
|
|
192
|
+
role: label ? "img" : void 0,
|
|
193
|
+
"aria-label": label,
|
|
194
|
+
className: cx(
|
|
195
|
+
"material-symbols-outlined inline-block shrink-0 select-none leading-none",
|
|
196
|
+
SIZE2[size],
|
|
197
|
+
tone !== "inherit" && TEXT_TONE[tone],
|
|
198
|
+
filled && "icon-filled",
|
|
199
|
+
spin && "animate-spin"
|
|
200
|
+
),
|
|
201
|
+
children: name
|
|
202
|
+
}
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// src/components/Dot.tsx
|
|
207
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
208
|
+
var SIZE3 = { sm: "size-1.5", md: "size-2" };
|
|
209
|
+
function Dot({ tone = "neutral", size = "sm", pulse, ...rest }) {
|
|
210
|
+
return /* @__PURE__ */ jsx9("span", { ...rest, "aria-hidden": "true", className: cx("inline-block shrink-0 rounded-full", DOT_TONE[tone], SIZE3[size], pulse && "animate-pulse") });
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// src/primitives/Text.tsx
|
|
214
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
215
|
+
var VARIANT = {
|
|
216
|
+
"body-lead": "font-body-lead text-body-lead",
|
|
217
|
+
"body-md": "font-body-md text-body-md",
|
|
218
|
+
"body-sm": "font-body-sm text-body-sm",
|
|
219
|
+
label: "font-label-mono text-label-mono uppercase",
|
|
220
|
+
code: "font-code-inline text-code-inline"
|
|
221
|
+
};
|
|
222
|
+
var WEIGHT = { regular: "", medium: "font-medium", semibold: "font-semibold" };
|
|
223
|
+
var CLAMP = { 1: "line-clamp-1", 2: "line-clamp-2", 3: "line-clamp-3", 4: "line-clamp-4" };
|
|
224
|
+
function Text({ as, variant = "body-md", tone = "default", weight = "regular", truncate, clamp: clamp2, ...rest }) {
|
|
225
|
+
const C = as ?? "p";
|
|
226
|
+
return /* @__PURE__ */ jsx10(
|
|
227
|
+
C,
|
|
228
|
+
{
|
|
229
|
+
...rest,
|
|
230
|
+
className: cx("min-w-0 wrap-break-word", VARIANT[variant], TEXT_TONE[tone], WEIGHT[weight], truncate && "truncate", clamp2 && CLAMP[clamp2])
|
|
231
|
+
}
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// src/primitives/Heading.tsx
|
|
236
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
237
|
+
var TAG = { 1: "h1", 2: "h2", 3: "h3", 4: "h4" };
|
|
238
|
+
var DEFAULT_SIZE = { 1: "xl", 2: "lg", 3: "md", 4: "sm" };
|
|
239
|
+
var TONE = { default: "text-ink", muted: "text-on-surface-variant", brand: "text-fg-brand", inverse: "text-on-primary" };
|
|
240
|
+
function Heading({ level, size, tone = "default", ...rest }) {
|
|
241
|
+
const C = TAG[level];
|
|
242
|
+
return /* @__PURE__ */ jsx11(C, { ...rest, className: cx("min-w-0 font-display text-balance wrap-break-word", responsive(HEADING_SIZE, size ?? DEFAULT_SIZE[level]), TONE[tone]) });
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// src/primitives/Eyebrow.tsx
|
|
246
|
+
import { jsx as jsx12, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
247
|
+
function Eyebrow({ tone = "brand", children, ...rest }) {
|
|
248
|
+
return /* @__PURE__ */ jsxs2("span", { ...rest, className: "inline-flex max-w-full items-center gap-space-xs rounded-full border border-border-subtle bg-surface-elevated px-space-sm py-space-2xs font-label-mono text-label-mono uppercase text-on-surface-variant", children: [
|
|
249
|
+
/* @__PURE__ */ jsx12(Dot, { tone }),
|
|
250
|
+
/* @__PURE__ */ jsx12("span", { className: "truncate", children })
|
|
251
|
+
] });
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// src/primitives/Code.tsx
|
|
255
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
256
|
+
function Code({ children, ...rest }) {
|
|
257
|
+
return /* @__PURE__ */ jsx13("code", { ...rest, className: "rounded bg-surface-muted px-space-xs py-space-2xs font-code-inline text-code-inline text-ink wrap-break-word", children });
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// src/primitives/CodeBlock.tsx
|
|
261
|
+
import { jsx as jsx14, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
262
|
+
function CodeBlock({ language, children, ...rest }) {
|
|
263
|
+
return /* @__PURE__ */ jsxs3("figure", { ...rest, className: "min-w-0 max-w-full overflow-hidden rounded-xl bg-brand-obsidian", children: [
|
|
264
|
+
language && /* @__PURE__ */ jsx14("figcaption", { className: "border-b border-white/10 px-space-md py-space-xs font-label-mono text-label-mono uppercase text-slate-300", children: language }),
|
|
265
|
+
/* @__PURE__ */ jsx14("pre", { tabIndex: 0, className: "overflow-x-auto p-space-md font-code-inline text-code-inline text-slate-100 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-brand-cobalt", children: /* @__PURE__ */ jsx14("code", { children }) })
|
|
266
|
+
] });
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// src/components/Markdown.tsx
|
|
270
|
+
import ReactMarkdown from "react-markdown";
|
|
271
|
+
import remarkGfm from "remark-gfm";
|
|
272
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
273
|
+
var components = {
|
|
274
|
+
h1: ({ children }) => /* @__PURE__ */ jsx15(Heading, { level: 1, size: "lg", children }),
|
|
275
|
+
h2: ({ children }) => /* @__PURE__ */ jsx15(Heading, { level: 2, size: "md", children }),
|
|
276
|
+
h3: ({ children }) => /* @__PURE__ */ jsx15(Heading, { level: 3, size: "sm", children }),
|
|
277
|
+
h4: ({ children }) => /* @__PURE__ */ jsx15(Heading, { level: 4, size: "sm", children }),
|
|
278
|
+
h5: ({ children }) => /* @__PURE__ */ jsx15(Heading, { level: 4, size: "sm", children }),
|
|
279
|
+
h6: ({ children }) => /* @__PURE__ */ jsx15(Heading, { level: 4, size: "sm", children }),
|
|
280
|
+
p: ({ children }) => /* @__PURE__ */ jsx15("p", { className: "font-body-md text-body-md text-on-surface wrap-break-word", children }),
|
|
281
|
+
strong: ({ children }) => /* @__PURE__ */ jsx15("strong", { className: "font-semibold text-ink", children }),
|
|
282
|
+
a: ({ href, children }) => /* @__PURE__ */ jsx15("a", { href, className: "text-fg-brand underline underline-offset-2 hover:text-brand-cobalt-hover wrap-break-word", children }),
|
|
283
|
+
ul: ({ className, children }) => /* @__PURE__ */ jsx15("ul", { className: cx("flex flex-col gap-space-xs", className === "contains-task-list" ? "pl-0" : "list-disc pl-space-lg"), children }),
|
|
284
|
+
ol: ({ children }) => /* @__PURE__ */ jsx15("ol", { className: "flex list-decimal flex-col gap-space-xs pl-space-lg", children }),
|
|
285
|
+
li: ({ className, children }) => /* @__PURE__ */ jsx15("li", { className: cx("font-body-md text-body-md text-on-surface", className === "task-list-item" ? "flex list-none items-start gap-space-xs wrap-anywhere" : "wrap-break-word"), children }),
|
|
286
|
+
input: ({ checked }) => /* @__PURE__ */ jsx15(Icon, { name: checked ? "check_box" : "check_box_outline_blank", size: "sm", tone: checked ? "success" : "muted" }),
|
|
287
|
+
code: ({ children }) => /* @__PURE__ */ jsx15(Code, { children }),
|
|
288
|
+
pre: ({ children }) => /* @__PURE__ */ jsx15(
|
|
289
|
+
"pre",
|
|
290
|
+
{
|
|
291
|
+
tabIndex: 0,
|
|
292
|
+
className: "min-w-0 max-w-full overflow-x-auto rounded-xl bg-brand-obsidian p-space-md font-code-inline text-code-inline text-slate-100 [&_code]:bg-transparent [&_code]:p-0 [&_code]:text-slate-100 focus-visible:outline-2 focus-visible:outline-brand-cobalt",
|
|
293
|
+
children
|
|
294
|
+
}
|
|
295
|
+
),
|
|
296
|
+
blockquote: ({ children }) => /* @__PURE__ */ jsx15("blockquote", { className: "border-l-2 border-border-strong pl-space-md text-on-surface-variant wrap-break-word", children }),
|
|
297
|
+
hr: () => /* @__PURE__ */ jsx15("hr", { className: "border-border-subtle" }),
|
|
298
|
+
table: ({ children }) => /* @__PURE__ */ jsx15("div", { tabIndex: 0, className: "min-w-0 max-w-full overflow-x-auto focus-visible:outline-2 focus-visible:outline-brand-cobalt", children: /* @__PURE__ */ jsx15("table", { className: "w-full border-collapse font-body-sm text-body-sm text-on-surface", children }) }),
|
|
299
|
+
th: ({ children }) => /* @__PURE__ */ jsx15("th", { className: "border border-border-subtle bg-surface-subtle px-space-sm py-space-xs text-left font-semibold", children }),
|
|
300
|
+
td: ({ children }) => /* @__PURE__ */ jsx15("td", { className: "border border-border-subtle px-space-sm py-space-xs", children })
|
|
301
|
+
};
|
|
302
|
+
function Markdown({ children, ...rest }) {
|
|
303
|
+
return /* @__PURE__ */ jsx15("div", { ...rest, className: "flex min-w-0 flex-col gap-space-sm", children: /* @__PURE__ */ jsx15(ReactMarkdown, { remarkPlugins: [remarkGfm], components, children }) });
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// src/components/Badge.tsx
|
|
307
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
308
|
+
var TONE2 = {
|
|
309
|
+
neutral: "bg-surface-muted text-on-surface-variant",
|
|
310
|
+
brand: "bg-ink text-on-ink",
|
|
311
|
+
success: "bg-badge-beginner-bg text-badge-beginner-text",
|
|
312
|
+
warning: "bg-badge-amber-bg text-badge-amber-text",
|
|
313
|
+
danger: "bg-badge-advanced-bg text-badge-advanced-text",
|
|
314
|
+
info: "bg-badge-intermediate-bg text-badge-intermediate-text"
|
|
315
|
+
};
|
|
316
|
+
var SIZE4 = { sm: "px-space-xs py-space-2xs", md: "px-space-sm py-space-xs" };
|
|
317
|
+
function Badge({ tone = "neutral", uppercase, size = "sm", children, ...rest }) {
|
|
318
|
+
return /* @__PURE__ */ jsx16("span", { ...rest, className: cx("inline-flex max-w-full items-center gap-space-2xs whitespace-nowrap rounded font-label-mono text-label-mono", TONE2[tone], SIZE4[size], uppercase && "uppercase tracking-wider"), children: /* @__PURE__ */ jsx16("span", { className: "min-w-0 truncate", children }) });
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// src/components/Chip.tsx
|
|
322
|
+
import { jsx as jsx17, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
323
|
+
var TONE3 = { neutral: "border-border-subtle text-on-surface", brand: "border-brand-cobalt/40 text-fg-brand" };
|
|
324
|
+
function Chip({ tone = "neutral", icon, onRemove, children, ...rest }) {
|
|
325
|
+
return /* @__PURE__ */ jsxs4("span", { ...rest, className: cx("inline-flex max-w-full items-center gap-space-2xs rounded-full border bg-surface-elevated px-space-sm py-space-2xs font-body-sm text-body-sm", TONE3[tone]), children: [
|
|
326
|
+
icon && /* @__PURE__ */ jsx17(Icon, { name: icon, size: "sm" }),
|
|
327
|
+
/* @__PURE__ */ jsx17("span", { className: "truncate", children }),
|
|
328
|
+
onRemove && /* @__PURE__ */ jsx17(
|
|
329
|
+
"button",
|
|
330
|
+
{
|
|
331
|
+
type: "button",
|
|
332
|
+
"aria-label": `Remove ${children}`,
|
|
333
|
+
onClick: onRemove,
|
|
334
|
+
className: cx("-mr-space-2xs inline-flex items-center justify-center rounded-full text-on-surface-variant hover:text-on-surface", FOCUS_RING, TOUCH_ICON),
|
|
335
|
+
children: /* @__PURE__ */ jsx17(Icon, { name: "close", size: "sm" })
|
|
336
|
+
}
|
|
337
|
+
)
|
|
338
|
+
] });
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// src/components/Stat.tsx
|
|
342
|
+
import { jsx as jsx18, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
343
|
+
function Stat({ icon, label, value, ...rest }) {
|
|
344
|
+
return /* @__PURE__ */ jsxs5("div", { ...rest, className: "flex min-w-0 items-center gap-space-sm", children: [
|
|
345
|
+
/* @__PURE__ */ jsx18(Icon, { name: icon, tone: "muted" }),
|
|
346
|
+
/* @__PURE__ */ jsxs5("div", { className: "min-w-0", children: [
|
|
347
|
+
/* @__PURE__ */ jsx18("p", { className: "truncate font-label-mono text-label-mono uppercase text-on-surface-variant", children: label }),
|
|
348
|
+
/* @__PURE__ */ jsx18("p", { className: "truncate font-display text-headline-sm text-ink", children: value })
|
|
349
|
+
] })
|
|
350
|
+
] });
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// src/components/ProgressBar.tsx
|
|
354
|
+
import { useId } from "react";
|
|
355
|
+
import { jsx as jsx19, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
356
|
+
var TONE4 = { brand: "bg-brand-cobalt", success: "bg-brand-emerald", warning: "bg-brand-amber", danger: "bg-brand-crimson" };
|
|
357
|
+
function ProgressBar({ value, max = 100, tone = "brand", label, hideLabel, ...rest }) {
|
|
358
|
+
const id = useId();
|
|
359
|
+
const safeMax = max > 0 ? max : 0;
|
|
360
|
+
const clamped = safeMax ? Math.min(safeMax, Math.max(0, value)) : 0;
|
|
361
|
+
const pct = safeMax ? Math.round(clamped / safeMax * 100) : 0;
|
|
362
|
+
return /* @__PURE__ */ jsxs6("div", { ...rest, className: "flex min-w-0 flex-col gap-space-2xs", children: [
|
|
363
|
+
/* @__PURE__ */ jsxs6("div", { className: cx("flex justify-between gap-space-sm font-body-sm text-body-sm text-on-surface-variant", hideLabel && "sr-only"), children: [
|
|
364
|
+
/* @__PURE__ */ jsx19("span", { id, className: "truncate", children: label }),
|
|
365
|
+
/* @__PURE__ */ jsxs6("span", { className: "shrink-0 tabular-nums", children: [
|
|
366
|
+
pct,
|
|
367
|
+
"%"
|
|
368
|
+
] })
|
|
369
|
+
] }),
|
|
370
|
+
/* @__PURE__ */ jsx19(
|
|
371
|
+
"div",
|
|
372
|
+
{
|
|
373
|
+
role: "progressbar",
|
|
374
|
+
"aria-labelledby": id,
|
|
375
|
+
"aria-valuemin": 0,
|
|
376
|
+
"aria-valuemax": safeMax,
|
|
377
|
+
"aria-valuenow": clamped,
|
|
378
|
+
className: "h-1.5 w-full overflow-hidden rounded-full bg-surface-muted",
|
|
379
|
+
children: /* @__PURE__ */ jsx19("div", { className: cx("h-full rounded-full transition-[width]", TONE4[tone]), style: { width: `${pct}%` } })
|
|
380
|
+
}
|
|
381
|
+
)
|
|
382
|
+
] });
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// src/components/SectionHeader.tsx
|
|
386
|
+
import { jsx as jsx20, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
387
|
+
function SectionHeader({ title, level = 2, dot, tag, meta, ...rest }) {
|
|
388
|
+
return /* @__PURE__ */ jsxs7("div", { ...rest, className: "flex min-w-0 flex-wrap items-center gap-x-space-sm gap-y-space-xs border-b border-border-subtle pb-space-sm", children: [
|
|
389
|
+
dot && /* @__PURE__ */ jsx20(Dot, { tone: dot, size: "md" }),
|
|
390
|
+
/* @__PURE__ */ jsx20(Heading, { level, size: "sm", children: title }),
|
|
391
|
+
tag && /* @__PURE__ */ jsx20(Badge, { uppercase: true, children: tag }),
|
|
392
|
+
meta && /* @__PURE__ */ jsx20("span", { className: "ml-auto min-w-0 truncate font-label-mono text-label-mono uppercase text-on-surface-variant", children: meta })
|
|
393
|
+
] });
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// src/components/Callout.tsx
|
|
397
|
+
import { jsx as jsx21, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
398
|
+
var TONE5 = {
|
|
399
|
+
danger: "bg-badge-advanced-bg text-badge-advanced-text",
|
|
400
|
+
info: "bg-badge-intermediate-bg text-badge-intermediate-text",
|
|
401
|
+
success: "bg-badge-beginner-bg text-badge-beginner-text",
|
|
402
|
+
warning: "bg-badge-amber-bg text-badge-amber-text"
|
|
403
|
+
};
|
|
404
|
+
var ICON = { danger: "error", info: "info", success: "check_circle", warning: "warning" };
|
|
405
|
+
function Callout({ tone = "info", title, action, children, ...rest }) {
|
|
406
|
+
return /* @__PURE__ */ jsxs8("div", { ...rest, role: tone === "danger" ? "alert" : "status", className: cx("flex min-w-0 flex-wrap items-start gap-space-sm rounded-xl border border-current/20 p-space-md", TONE5[tone]), children: [
|
|
407
|
+
/* @__PURE__ */ jsx21(Icon, { name: ICON[tone] }),
|
|
408
|
+
/* @__PURE__ */ jsxs8("div", { className: "min-w-0 flex-1", children: [
|
|
409
|
+
title && /* @__PURE__ */ jsx21("p", { className: "font-display text-headline-sm wrap-break-word", children: title }),
|
|
410
|
+
/* @__PURE__ */ jsx21("div", { className: "font-body-sm text-body-sm wrap-break-word", children })
|
|
411
|
+
] }),
|
|
412
|
+
action && /* @__PURE__ */ jsx21("div", { className: "shrink-0", children: action })
|
|
413
|
+
] });
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// src/components/ResultRow.tsx
|
|
417
|
+
import { jsx as jsx22, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
418
|
+
var STATUS = {
|
|
419
|
+
pass: { icon: "check_circle", tone: "success", label: "Passed" },
|
|
420
|
+
fail: { icon: "cancel", tone: "danger", label: "Failed" },
|
|
421
|
+
pending: { icon: "schedule", tone: "muted", label: "Pending" }
|
|
422
|
+
};
|
|
423
|
+
function ResultRow({ status, title, detail, meta, ...rest }) {
|
|
424
|
+
const s = STATUS[status];
|
|
425
|
+
return /* @__PURE__ */ jsxs9("div", { ...rest, className: "flex min-w-0 items-start gap-space-sm py-space-sm", children: [
|
|
426
|
+
/* @__PURE__ */ jsx22(Icon, { name: s.icon, tone: s.tone, filled: true, label: s.label }),
|
|
427
|
+
/* @__PURE__ */ jsxs9("div", { className: "min-w-0 flex-1", children: [
|
|
428
|
+
/* @__PURE__ */ jsx22("p", { className: "font-body-md text-body-md text-on-surface wrap-break-word", children: title }),
|
|
429
|
+
detail && /* @__PURE__ */ jsx22("p", { className: "whitespace-pre-wrap font-code-inline text-code-inline text-on-surface-variant wrap-break-word", children: detail })
|
|
430
|
+
] }),
|
|
431
|
+
meta && /* @__PURE__ */ jsx22("span", { className: "shrink-0 font-label-mono text-label-mono text-on-surface-variant", children: meta })
|
|
432
|
+
] });
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// src/components/Message.tsx
|
|
436
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
437
|
+
function Message({ tone = "default", children, ...rest }) {
|
|
438
|
+
return /* @__PURE__ */ jsx23("p", { ...rest, role: tone === "danger" ? "alert" : "status", className: cx("min-w-0 font-body-md text-body-md wrap-break-word", tone === "danger" ? "text-fg-danger" : "text-on-surface-variant"), children });
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// src/components/EmptyState.tsx
|
|
442
|
+
import { jsx as jsx24, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
443
|
+
function EmptyState({ icon = "inbox", title, description, action, ...rest }) {
|
|
444
|
+
return /* @__PURE__ */ jsxs10("div", { ...rest, className: "flex min-w-0 flex-col items-center gap-space-sm px-space-md py-space-xl text-center", children: [
|
|
445
|
+
/* @__PURE__ */ jsx24("span", { className: "inline-flex size-12 items-center justify-center rounded-full bg-surface-muted text-on-surface-variant", children: /* @__PURE__ */ jsx24(Icon, { name: icon, size: "lg" }) }),
|
|
446
|
+
/* @__PURE__ */ jsx24("div", { className: "w-full", children: /* @__PURE__ */ jsx24(Heading, { level: 3, size: "sm", children: title }) }),
|
|
447
|
+
description && /* @__PURE__ */ jsx24("p", { className: "w-full max-w-prose font-body-sm text-body-sm text-on-surface-variant wrap-break-word", children: description }),
|
|
448
|
+
action
|
|
449
|
+
] });
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// src/components/CheckList.tsx
|
|
453
|
+
import { jsx as jsx25, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
454
|
+
function CheckList({ items, ...rest }) {
|
|
455
|
+
return /* @__PURE__ */ jsx25("ul", { ...rest, className: "flex min-w-0 flex-col gap-space-xs", children: items.map((item, i) => /* @__PURE__ */ jsxs11("li", { className: "flex items-start gap-space-xs font-body-md text-body-md text-on-surface", children: [
|
|
456
|
+
/* @__PURE__ */ jsx25(Icon, { name: "check", size: "sm", tone: "success" }),
|
|
457
|
+
/* @__PURE__ */ jsx25("span", { className: "min-w-0 wrap-break-word", children: item })
|
|
458
|
+
] }, i)) });
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// src/components/Card.tsx
|
|
462
|
+
import { Children, isValidElement } from "react";
|
|
463
|
+
import { jsx as jsx26, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
464
|
+
var TONE6 = {
|
|
465
|
+
default: "bg-surface-elevated border border-border-subtle text-on-surface",
|
|
466
|
+
inverse: "bg-brand-obsidian border border-brand-slate text-on-primary"
|
|
467
|
+
};
|
|
468
|
+
var PATTERN2 = { none: "", dots: "bg-pattern-dots", grid: "bg-pattern-grid" };
|
|
469
|
+
var ASPECT = { video: "aspect-video", wide: "aspect-[21/9]", square: "aspect-square" };
|
|
470
|
+
function CardMedia({ pattern = "dots", aspect = "video", children, ...rest }) {
|
|
471
|
+
return /* @__PURE__ */ jsx26("div", { ...rest, className: cx("relative flex min-w-0 items-center justify-center border-b border-border-subtle bg-surface-subtle group-data-[tone=inverse]/card:border-white/10 group-data-[tone=inverse]/card:bg-white/5", PATTERN2[pattern], ASPECT[aspect]), children });
|
|
472
|
+
}
|
|
473
|
+
function CardFooter({ children, ...rest }) {
|
|
474
|
+
return /* @__PURE__ */ jsx26("div", { ...rest, className: "flex min-w-0 flex-wrap items-center justify-between gap-space-sm border-t border-border-subtle bg-surface-subtle px-space-lg py-space-sm group-data-[tone=inverse]/card:border-white/10 group-data-[tone=inverse]/card:bg-white/5", children });
|
|
475
|
+
}
|
|
476
|
+
function CardRoot({ as, padding = "lg", interactive, tone = "default", children, ...rest }) {
|
|
477
|
+
const C = as ?? "div";
|
|
478
|
+
const parts = Children.toArray(children);
|
|
479
|
+
const isType = (t) => (p) => isValidElement(p) && p.type === t;
|
|
480
|
+
const media = parts.filter(isType(CardMedia));
|
|
481
|
+
const footer = parts.filter(isType(CardFooter));
|
|
482
|
+
const body = parts.filter((p) => !media.includes(p) && !footer.includes(p));
|
|
483
|
+
return /* @__PURE__ */ jsxs12(
|
|
484
|
+
C,
|
|
485
|
+
{
|
|
486
|
+
...rest,
|
|
487
|
+
"data-tone": tone,
|
|
488
|
+
className: cx("group/card flex min-w-0 flex-col overflow-hidden rounded-xl", TONE6[tone], interactive && cx("transition-shadow hover:shadow-md", FOCUS_RING)),
|
|
489
|
+
children: [
|
|
490
|
+
media,
|
|
491
|
+
/* @__PURE__ */ jsx26("div", { className: cx("flex min-w-0 flex-1 flex-col gap-space-sm", responsive(PADDING, padding)), children: body }),
|
|
492
|
+
footer
|
|
493
|
+
]
|
|
494
|
+
}
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
var Card = Object.assign(CardRoot, { Media: CardMedia, Footer: CardFooter });
|
|
498
|
+
|
|
499
|
+
// src/components/Button.tsx
|
|
500
|
+
import { jsx as jsx27, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
501
|
+
var VARIANT2 = {
|
|
502
|
+
primary: "bg-ink text-on-ink shadow-sm hover:bg-ink-hover",
|
|
503
|
+
secondary: "border border-border-subtle bg-surface-elevated text-ink shadow-sm hover:bg-surface-muted",
|
|
504
|
+
subtle: "bg-surface-subtle text-on-surface hover:bg-surface-muted",
|
|
505
|
+
ghost: "bg-transparent text-on-surface hover:bg-surface-muted",
|
|
506
|
+
danger: "bg-danger text-white shadow-sm hover:bg-danger-hover"
|
|
507
|
+
};
|
|
508
|
+
var SIZE5 = { sm: "h-8 px-space-md", md: "h-10 px-space-lg", lg: "h-12 px-space-lg" };
|
|
509
|
+
function Button({
|
|
510
|
+
as,
|
|
511
|
+
variant = "primary",
|
|
512
|
+
size = "md",
|
|
513
|
+
icon,
|
|
514
|
+
iconRight,
|
|
515
|
+
fullWidth,
|
|
516
|
+
loading,
|
|
517
|
+
disabled,
|
|
518
|
+
children,
|
|
519
|
+
...rest
|
|
520
|
+
}) {
|
|
521
|
+
const C = as ?? "button";
|
|
522
|
+
const native = C === "button";
|
|
523
|
+
const off = Boolean(disabled || loading);
|
|
524
|
+
const state = native ? { type: rest.type ?? "button", disabled: off } : { "aria-disabled": off || void 0 };
|
|
525
|
+
return /* @__PURE__ */ jsxs13(
|
|
526
|
+
C,
|
|
527
|
+
{
|
|
528
|
+
...rest,
|
|
529
|
+
...state,
|
|
530
|
+
"aria-busy": loading || void 0,
|
|
531
|
+
className: cx(
|
|
532
|
+
"inline-flex max-w-full items-center justify-center gap-space-xs whitespace-nowrap rounded-lg font-button-text text-button-text transition-colors",
|
|
533
|
+
"disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50",
|
|
534
|
+
VARIANT2[variant],
|
|
535
|
+
SIZE5[size],
|
|
536
|
+
FOCUS_RING,
|
|
537
|
+
TOUCH,
|
|
538
|
+
fullWidth && "w-full"
|
|
539
|
+
),
|
|
540
|
+
children: [
|
|
541
|
+
loading ? /* @__PURE__ */ jsx27(Icon, { name: "progress_activity", size: "sm", spin: true }) : icon && /* @__PURE__ */ jsx27(Icon, { name: icon, size: "sm" }),
|
|
542
|
+
/* @__PURE__ */ jsx27("span", { className: "truncate", children }),
|
|
543
|
+
iconRight && /* @__PURE__ */ jsx27(Icon, { name: iconRight, size: "sm" })
|
|
544
|
+
]
|
|
545
|
+
}
|
|
546
|
+
);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// src/components/IconButton.tsx
|
|
550
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
551
|
+
var VARIANT3 = {
|
|
552
|
+
ghost: "text-on-surface-variant hover:bg-surface-muted hover:text-on-surface",
|
|
553
|
+
subtle: "bg-surface-subtle text-on-surface hover:bg-surface-muted",
|
|
554
|
+
primary: "bg-ink text-on-ink hover:bg-ink-hover"
|
|
555
|
+
};
|
|
556
|
+
var SIZE6 = { sm: "size-8", md: "size-10" };
|
|
557
|
+
function IconButton({ icon, label, variant = "ghost", size = "md", type = "button", ...rest }) {
|
|
558
|
+
return /* @__PURE__ */ jsx28(
|
|
559
|
+
"button",
|
|
560
|
+
{
|
|
561
|
+
...rest,
|
|
562
|
+
type,
|
|
563
|
+
"aria-label": label,
|
|
564
|
+
title: label,
|
|
565
|
+
className: cx("inline-flex shrink-0 items-center justify-center rounded-lg transition-colors disabled:pointer-events-none disabled:opacity-50", VARIANT3[variant], SIZE6[size], FOCUS_RING, TOUCH_ICON),
|
|
566
|
+
children: /* @__PURE__ */ jsx28(Icon, { name: icon, size: size === "sm" ? "sm" : "md" })
|
|
567
|
+
}
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// src/components/Kbd.tsx
|
|
572
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
573
|
+
function Kbd({ children, ...rest }) {
|
|
574
|
+
return /* @__PURE__ */ jsx29("kbd", { ...rest, className: "inline-flex items-center rounded border border-border-subtle bg-surface-subtle px-space-xs font-label-mono text-[11px] leading-5 text-on-surface-variant", children });
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// src/components/TextField.tsx
|
|
578
|
+
import { useId as useId2 } from "react";
|
|
579
|
+
import { jsx as jsx30, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
580
|
+
function TextField({ label, hideLabel, icon, hint, error, id, ...rest }) {
|
|
581
|
+
const generated = useId2();
|
|
582
|
+
const inputId = id ?? generated;
|
|
583
|
+
const errorId = `${inputId}-error`;
|
|
584
|
+
return /* @__PURE__ */ jsxs14("div", { className: "flex min-w-0 flex-col gap-space-2xs", children: [
|
|
585
|
+
/* @__PURE__ */ jsx30("label", { htmlFor: inputId, className: cx("font-body-sm text-body-sm font-medium text-on-surface", hideLabel && "sr-only"), children: label }),
|
|
586
|
+
/* @__PURE__ */ jsxs14(
|
|
587
|
+
"div",
|
|
588
|
+
{
|
|
589
|
+
className: cx(
|
|
590
|
+
"flex h-10 min-w-0 items-center gap-space-xs rounded-lg border bg-surface-subtle px-space-sm focus-within:ring-2 focus-within:ring-brand-cobalt",
|
|
591
|
+
error ? "border-fg-danger" : "border-border-subtle",
|
|
592
|
+
TOUCH
|
|
593
|
+
),
|
|
594
|
+
children: [
|
|
595
|
+
icon && /* @__PURE__ */ jsx30(Icon, { name: icon, size: "sm", tone: "muted" }),
|
|
596
|
+
/* @__PURE__ */ jsx30(
|
|
597
|
+
"input",
|
|
598
|
+
{
|
|
599
|
+
...rest,
|
|
600
|
+
id: inputId,
|
|
601
|
+
"aria-invalid": error ? true : rest["aria-invalid"],
|
|
602
|
+
"aria-describedby": cx(rest["aria-describedby"], error && errorId) || void 0,
|
|
603
|
+
className: "h-full min-w-0 flex-1 bg-transparent font-body-md text-body-md text-on-surface outline-none placeholder:text-on-surface-variant"
|
|
604
|
+
}
|
|
605
|
+
),
|
|
606
|
+
hint && /* @__PURE__ */ jsx30("span", { className: "shrink-0", children: hint })
|
|
607
|
+
]
|
|
608
|
+
}
|
|
609
|
+
),
|
|
610
|
+
error && /* @__PURE__ */ jsx30("p", { id: errorId, className: "font-body-sm text-body-sm text-fg-danger", children: error })
|
|
611
|
+
] });
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
// src/components/Select.tsx
|
|
615
|
+
import { useId as useId3 } from "react";
|
|
616
|
+
import { jsx as jsx31, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
617
|
+
function Select({ label, hideLabel, options, id, ...rest }) {
|
|
618
|
+
const generated = useId3();
|
|
619
|
+
const selectId = id ?? generated;
|
|
620
|
+
return /* @__PURE__ */ jsxs15("div", { className: "flex min-w-0 flex-col gap-space-2xs", children: [
|
|
621
|
+
/* @__PURE__ */ jsx31("label", { htmlFor: selectId, className: cx("font-body-sm text-body-sm font-medium text-on-surface", hideLabel && "sr-only"), children: label }),
|
|
622
|
+
/* @__PURE__ */ jsxs15("div", { className: "relative min-w-0", children: [
|
|
623
|
+
/* @__PURE__ */ jsx31(
|
|
624
|
+
"select",
|
|
625
|
+
{
|
|
626
|
+
...rest,
|
|
627
|
+
id: selectId,
|
|
628
|
+
className: cx("h-10 w-full min-w-0 appearance-none rounded-lg border border-border-subtle bg-surface-subtle pl-space-sm pr-space-xl font-body-md text-body-md text-on-surface", FOCUS_RING, TOUCH),
|
|
629
|
+
children: options.map((o) => /* @__PURE__ */ jsx31("option", { value: o.value, children: o.label }, o.value))
|
|
630
|
+
}
|
|
631
|
+
),
|
|
632
|
+
/* @__PURE__ */ jsx31("span", { className: "pointer-events-none absolute inset-y-0 right-space-sm flex items-center text-on-surface-variant", children: /* @__PURE__ */ jsx31(Icon, { name: "expand_more", size: "sm" }) })
|
|
633
|
+
] })
|
|
634
|
+
] });
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
// src/components/Tabs.tsx
|
|
638
|
+
import { useId as useId4, useRef } from "react";
|
|
639
|
+
|
|
640
|
+
// src/internal/roving.ts
|
|
641
|
+
function rovingIndex(key, index, count) {
|
|
642
|
+
switch (key) {
|
|
643
|
+
case "ArrowRight":
|
|
644
|
+
case "ArrowDown":
|
|
645
|
+
return (index + 1) % count;
|
|
646
|
+
case "ArrowLeft":
|
|
647
|
+
case "ArrowUp":
|
|
648
|
+
return (index - 1 + count) % count;
|
|
649
|
+
case "Home":
|
|
650
|
+
return 0;
|
|
651
|
+
case "End":
|
|
652
|
+
return count - 1;
|
|
653
|
+
default:
|
|
654
|
+
return null;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
// src/components/Tabs.tsx
|
|
659
|
+
import { Fragment, jsx as jsx32, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
660
|
+
var VARIANT4 = {
|
|
661
|
+
underline: {
|
|
662
|
+
list: "flex min-w-0 max-w-full gap-space-lg overflow-x-auto border-b border-border-subtle [scrollbar-width:none]",
|
|
663
|
+
tab: "inline-flex shrink-0 items-center gap-space-xs whitespace-nowrap border-b-2 py-space-sm font-button-text text-button-text transition-colors",
|
|
664
|
+
active: "border-ink text-ink",
|
|
665
|
+
idle: "border-transparent text-on-surface-variant hover:text-on-surface"
|
|
666
|
+
},
|
|
667
|
+
pills: {
|
|
668
|
+
list: "inline-flex min-w-0 max-w-full gap-space-2xs overflow-x-auto rounded-lg bg-surface-subtle p-space-2xs [scrollbar-width:none]",
|
|
669
|
+
tab: "inline-flex shrink-0 items-center gap-space-xs whitespace-nowrap rounded-md px-space-md py-space-xs font-button-text text-button-text transition-colors",
|
|
670
|
+
active: "bg-surface-elevated text-ink shadow-sm",
|
|
671
|
+
idle: "text-on-surface-variant hover:text-on-surface"
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
function TabBody({ item }) {
|
|
675
|
+
return /* @__PURE__ */ jsxs16(Fragment, { children: [
|
|
676
|
+
item.label,
|
|
677
|
+
item.count !== void 0 && /* @__PURE__ */ jsx32(Badge, { children: item.count }),
|
|
678
|
+
item.dot && /* @__PURE__ */ jsx32(Dot, { tone: item.dot })
|
|
679
|
+
] });
|
|
680
|
+
}
|
|
681
|
+
function Tabs({ items, value, onChange, variant = "underline", label, ...rest }) {
|
|
682
|
+
const baseId = useId4();
|
|
683
|
+
const refs = useRef([]);
|
|
684
|
+
if (!items.length) return null;
|
|
685
|
+
const v = VARIANT4[variant];
|
|
686
|
+
if (items.some((i) => i.href)) {
|
|
687
|
+
return /* @__PURE__ */ jsx32("nav", { ...rest, "aria-label": label, className: "min-w-0 max-w-full", children: /* @__PURE__ */ jsx32("ul", { className: v.list, children: items.map((item) => {
|
|
688
|
+
const C = item.as ?? "a";
|
|
689
|
+
const active = item.id === value;
|
|
690
|
+
return /* @__PURE__ */ jsx32("li", { className: "flex shrink-0", children: /* @__PURE__ */ jsx32(C, { href: item.href, "aria-current": active ? "page" : void 0, className: cx(v.tab, active ? v.active : v.idle, FOCUS_RING, TOUCH), children: /* @__PURE__ */ jsx32(TabBody, { item }) }) }, item.id);
|
|
691
|
+
}) }) });
|
|
692
|
+
}
|
|
693
|
+
const activeIndex = Math.max(0, items.findIndex((i) => i.id === value));
|
|
694
|
+
const onKeyDown = (e, index) => {
|
|
695
|
+
const next = rovingIndex(e.key, index, items.length);
|
|
696
|
+
if (next === null) return;
|
|
697
|
+
e.preventDefault();
|
|
698
|
+
refs.current[next]?.focus();
|
|
699
|
+
onChange?.(items[next].id);
|
|
700
|
+
};
|
|
701
|
+
return /* @__PURE__ */ jsx32("div", { ...rest, role: "tablist", "aria-label": label, className: v.list, children: items.map((item, i) => {
|
|
702
|
+
const active = i === activeIndex;
|
|
703
|
+
return /* @__PURE__ */ jsx32(
|
|
704
|
+
"button",
|
|
705
|
+
{
|
|
706
|
+
ref: (el) => {
|
|
707
|
+
refs.current[i] = el;
|
|
708
|
+
},
|
|
709
|
+
type: "button",
|
|
710
|
+
role: "tab",
|
|
711
|
+
id: item.panelId ? `${item.panelId}-tab` : `${baseId}-${item.id}`,
|
|
712
|
+
"aria-controls": item.panelId,
|
|
713
|
+
"aria-selected": active,
|
|
714
|
+
tabIndex: active ? 0 : -1,
|
|
715
|
+
onClick: () => onChange?.(item.id),
|
|
716
|
+
onKeyDown: (e) => onKeyDown(e, i),
|
|
717
|
+
className: cx(v.tab, active ? v.active : v.idle, FOCUS_RING, TOUCH),
|
|
718
|
+
children: /* @__PURE__ */ jsx32(TabBody, { item })
|
|
719
|
+
},
|
|
720
|
+
item.id
|
|
721
|
+
);
|
|
722
|
+
}) });
|
|
723
|
+
}
|
|
724
|
+
function TabPanel({ id, active, children, ...rest }) {
|
|
725
|
+
return /* @__PURE__ */ jsx32("div", { ...rest, role: "tabpanel", id, "aria-labelledby": `${id}-tab`, hidden: !active, tabIndex: 0, className: cx("min-w-0 outline-none", FOCUS_RING), children });
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
// src/components/SegmentedControl.tsx
|
|
729
|
+
import { useRef as useRef2 } from "react";
|
|
730
|
+
import { jsx as jsx33, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
731
|
+
function SegmentedControl({ label, options, value, onChange, ...rest }) {
|
|
732
|
+
const refs = useRef2([]);
|
|
733
|
+
const checkedIndex = options.findIndex((o) => o.value === value);
|
|
734
|
+
const tabbable = checkedIndex === -1 ? 0 : checkedIndex;
|
|
735
|
+
const onKeyDown = (e, index) => {
|
|
736
|
+
const next = rovingIndex(e.key, index, options.length);
|
|
737
|
+
if (next === null) return;
|
|
738
|
+
e.preventDefault();
|
|
739
|
+
refs.current[next]?.focus();
|
|
740
|
+
onChange(options[next].value);
|
|
741
|
+
};
|
|
742
|
+
return /* @__PURE__ */ jsx33("div", { ...rest, role: "radiogroup", "aria-label": label, className: "inline-flex min-w-0 max-w-full gap-space-2xs overflow-x-auto rounded-lg border border-border-subtle bg-surface-subtle p-space-2xs [scrollbar-width:none]", children: options.map((o, i) => {
|
|
743
|
+
const checked = i === checkedIndex;
|
|
744
|
+
return /* @__PURE__ */ jsxs17(
|
|
745
|
+
"button",
|
|
746
|
+
{
|
|
747
|
+
ref: (el) => {
|
|
748
|
+
refs.current[i] = el;
|
|
749
|
+
},
|
|
750
|
+
type: "button",
|
|
751
|
+
role: "radio",
|
|
752
|
+
"aria-checked": checked,
|
|
753
|
+
tabIndex: i === tabbable ? 0 : -1,
|
|
754
|
+
onClick: () => onChange(o.value),
|
|
755
|
+
onKeyDown: (e) => onKeyDown(e, i),
|
|
756
|
+
className: cx(
|
|
757
|
+
"inline-flex shrink-0 items-center gap-space-xs whitespace-nowrap rounded-md px-space-sm py-space-xs font-button-text text-button-text transition-colors",
|
|
758
|
+
checked ? "bg-surface-elevated text-ink shadow-sm" : "text-on-surface-variant hover:text-on-surface",
|
|
759
|
+
FOCUS_RING,
|
|
760
|
+
TOUCH
|
|
761
|
+
),
|
|
762
|
+
children: [
|
|
763
|
+
o.icon && /* @__PURE__ */ jsx33(Icon, { name: o.icon, size: "sm" }),
|
|
764
|
+
o.label
|
|
765
|
+
]
|
|
766
|
+
},
|
|
767
|
+
o.value
|
|
768
|
+
);
|
|
769
|
+
}) });
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
// src/components/Dialog.tsx
|
|
773
|
+
import { useEffect, useId as useId5, useRef as useRef3 } from "react";
|
|
774
|
+
import { createPortal } from "react-dom";
|
|
775
|
+
import { jsx as jsx34, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
776
|
+
var SIZE7 = { sm: "max-w-sm", md: "max-w-md", lg: "max-w-2xl" };
|
|
777
|
+
var FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
778
|
+
function Dialog({ open, onClose, title, description, footer, size = "md", children, ...rest }) {
|
|
779
|
+
const titleId = useId5();
|
|
780
|
+
const descId = useId5();
|
|
781
|
+
const panelRef = useRef3(null);
|
|
782
|
+
const contentRef = useRef3(null);
|
|
783
|
+
const onCloseRef = useRef3(onClose);
|
|
784
|
+
const theme = useThemeTone();
|
|
785
|
+
useEffect(() => {
|
|
786
|
+
onCloseRef.current = onClose;
|
|
787
|
+
});
|
|
788
|
+
useEffect(() => {
|
|
789
|
+
if (!open) return;
|
|
790
|
+
const opener = document.activeElement;
|
|
791
|
+
const previousOverflow = document.body.style.overflow;
|
|
792
|
+
document.body.style.overflow = "hidden";
|
|
793
|
+
const panel = panelRef.current;
|
|
794
|
+
const focusables = () => [...panel.querySelectorAll(FOCUSABLE)];
|
|
795
|
+
(contentRef.current?.querySelector(FOCUSABLE) ?? focusables()[0] ?? panel).focus();
|
|
796
|
+
const onKey = (e) => {
|
|
797
|
+
if (e.defaultPrevented) return;
|
|
798
|
+
if (e.key === "Escape") {
|
|
799
|
+
e.preventDefault();
|
|
800
|
+
onCloseRef.current();
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
803
|
+
if (e.key !== "Tab") return;
|
|
804
|
+
const els = focusables();
|
|
805
|
+
if (!els.length) return;
|
|
806
|
+
const first = els[0];
|
|
807
|
+
const last = els[els.length - 1];
|
|
808
|
+
const active = document.activeElement;
|
|
809
|
+
const onEdge = active === panel || !panel.contains(active);
|
|
810
|
+
if (e.shiftKey && (active === first || onEdge)) {
|
|
811
|
+
e.preventDefault();
|
|
812
|
+
last.focus();
|
|
813
|
+
} else if (!e.shiftKey && (active === last || onEdge)) {
|
|
814
|
+
e.preventDefault();
|
|
815
|
+
first.focus();
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
document.addEventListener("keydown", onKey);
|
|
819
|
+
return () => {
|
|
820
|
+
document.removeEventListener("keydown", onKey);
|
|
821
|
+
document.body.style.overflow = previousOverflow;
|
|
822
|
+
if (opener?.isConnected) opener.focus();
|
|
823
|
+
else {
|
|
824
|
+
document.activeElement?.blur();
|
|
825
|
+
document.body.focus();
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
}, [open]);
|
|
829
|
+
if (!open || typeof document === "undefined") return null;
|
|
830
|
+
return createPortal(
|
|
831
|
+
/* @__PURE__ */ jsx34(
|
|
832
|
+
"div",
|
|
833
|
+
{
|
|
834
|
+
"data-theme": theme,
|
|
835
|
+
className: "fixed inset-0 z-50 flex items-end justify-center bg-brand-obsidian/40 p-space-md backdrop-blur-sm sm:items-center",
|
|
836
|
+
onMouseDown: (e) => {
|
|
837
|
+
if (e.target === e.currentTarget) onCloseRef.current();
|
|
838
|
+
},
|
|
839
|
+
children: /* @__PURE__ */ jsxs18(
|
|
840
|
+
"div",
|
|
841
|
+
{
|
|
842
|
+
...rest,
|
|
843
|
+
ref: panelRef,
|
|
844
|
+
role: "dialog",
|
|
845
|
+
"aria-modal": "true",
|
|
846
|
+
"aria-labelledby": titleId,
|
|
847
|
+
"aria-describedby": description ? descId : void 0,
|
|
848
|
+
tabIndex: -1,
|
|
849
|
+
className: cx("relative flex max-h-[calc(100dvh-2rem)] w-full min-w-0 flex-col gap-space-md overflow-y-auto rounded-xl bg-surface-elevated p-space-lg text-on-surface shadow-md outline-none", SIZE7[size]),
|
|
850
|
+
children: [
|
|
851
|
+
/* @__PURE__ */ jsxs18("div", { className: "min-w-0 pr-space-xl", children: [
|
|
852
|
+
/* @__PURE__ */ jsx34("h2", { id: titleId, className: "font-display text-headline-md text-ink wrap-break-word", children: title }),
|
|
853
|
+
description && /* @__PURE__ */ jsx34("p", { id: descId, className: "font-body-sm text-body-sm text-on-surface-variant", children: description })
|
|
854
|
+
] }),
|
|
855
|
+
/* @__PURE__ */ jsx34("div", { ref: contentRef, className: "flex min-w-0 flex-col gap-space-sm", children }),
|
|
856
|
+
footer && /* @__PURE__ */ jsx34("div", { className: "flex flex-wrap justify-end gap-space-sm", children: footer }),
|
|
857
|
+
/* @__PURE__ */ jsx34("div", { className: "absolute right-space-md top-space-md", children: /* @__PURE__ */ jsx34(IconButton, { icon: "close", label: "Close", onClick: () => onCloseRef.current() }) })
|
|
858
|
+
]
|
|
859
|
+
}
|
|
860
|
+
)
|
|
861
|
+
}
|
|
862
|
+
),
|
|
863
|
+
document.body
|
|
864
|
+
);
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
// src/components/Menu.tsx
|
|
868
|
+
import { useEffect as useEffect2, useId as useId6, useRef as useRef4, useState } from "react";
|
|
869
|
+
import { jsx as jsx35, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
870
|
+
function Menu({ label, trigger, items, align = "end", ...rest }) {
|
|
871
|
+
const [open, setOpen] = useState(false);
|
|
872
|
+
const triggerId = useId6();
|
|
873
|
+
const menuId = useId6();
|
|
874
|
+
const rootRef = useRef4(null);
|
|
875
|
+
const triggerRef = useRef4(null);
|
|
876
|
+
const itemRefs = useRef4([]);
|
|
877
|
+
const pendingFocus = useRef4(null);
|
|
878
|
+
const openAt = (index) => {
|
|
879
|
+
pendingFocus.current = index;
|
|
880
|
+
setOpen(true);
|
|
881
|
+
};
|
|
882
|
+
const close = (refocus) => {
|
|
883
|
+
setOpen(false);
|
|
884
|
+
if (refocus) triggerRef.current?.focus();
|
|
885
|
+
};
|
|
886
|
+
useEffect2(() => {
|
|
887
|
+
if (!open) return;
|
|
888
|
+
if (pendingFocus.current !== null) itemRefs.current[pendingFocus.current]?.focus();
|
|
889
|
+
pendingFocus.current = null;
|
|
890
|
+
const onDown = (e) => {
|
|
891
|
+
if (!rootRef.current?.contains(e.target)) setOpen(false);
|
|
892
|
+
};
|
|
893
|
+
document.addEventListener("mousedown", onDown);
|
|
894
|
+
return () => document.removeEventListener("mousedown", onDown);
|
|
895
|
+
}, [open]);
|
|
896
|
+
const focusItem = (index) => open ? itemRefs.current[index]?.focus() : openAt(index);
|
|
897
|
+
const onTriggerKeyDown = (e) => {
|
|
898
|
+
if (e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") {
|
|
899
|
+
e.preventDefault();
|
|
900
|
+
focusItem(0);
|
|
901
|
+
} else if (e.key === "ArrowUp") {
|
|
902
|
+
e.preventDefault();
|
|
903
|
+
focusItem(items.length - 1);
|
|
904
|
+
} else if (e.key === "Escape" && open) {
|
|
905
|
+
e.preventDefault();
|
|
906
|
+
close(true);
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
const onMenuKeyDown = (e) => {
|
|
910
|
+
if (e.key === "Escape") {
|
|
911
|
+
e.preventDefault();
|
|
912
|
+
close(true);
|
|
913
|
+
return;
|
|
914
|
+
}
|
|
915
|
+
if (e.key === "Tab") {
|
|
916
|
+
setOpen(false);
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
919
|
+
const current = itemRefs.current.indexOf(document.activeElement);
|
|
920
|
+
const next = rovingIndex(e.key, Math.max(0, current), items.length);
|
|
921
|
+
if (next === null) return;
|
|
922
|
+
e.preventDefault();
|
|
923
|
+
itemRefs.current[next]?.focus();
|
|
924
|
+
};
|
|
925
|
+
return /* @__PURE__ */ jsxs19("div", { ...rest, ref: rootRef, className: "relative inline-flex", children: [
|
|
926
|
+
trigger({
|
|
927
|
+
ref: triggerRef,
|
|
928
|
+
id: triggerId,
|
|
929
|
+
"aria-haspopup": "menu",
|
|
930
|
+
"aria-expanded": open,
|
|
931
|
+
"aria-controls": open ? menuId : void 0,
|
|
932
|
+
onClick: () => open ? close(false) : openAt(0),
|
|
933
|
+
onKeyDown: onTriggerKeyDown
|
|
934
|
+
}),
|
|
935
|
+
open && /* @__PURE__ */ jsx35(
|
|
936
|
+
"div",
|
|
937
|
+
{
|
|
938
|
+
id: menuId,
|
|
939
|
+
role: "menu",
|
|
940
|
+
"aria-label": label,
|
|
941
|
+
onKeyDown: onMenuKeyDown,
|
|
942
|
+
className: cx(
|
|
943
|
+
"absolute top-full z-40 mt-space-xs flex min-w-48 max-w-[calc(100vw-2rem)] flex-col rounded-xl border border-border-subtle bg-surface-elevated p-space-2xs shadow-md",
|
|
944
|
+
align === "end" ? "right-0" : "left-0"
|
|
945
|
+
),
|
|
946
|
+
children: items.map((item, i) => {
|
|
947
|
+
const C = item.href ? item.as ?? "a" : "button";
|
|
948
|
+
return /* @__PURE__ */ jsxs19(
|
|
949
|
+
C,
|
|
950
|
+
{
|
|
951
|
+
ref: (el) => {
|
|
952
|
+
itemRefs.current[i] = el;
|
|
953
|
+
},
|
|
954
|
+
role: "menuitem",
|
|
955
|
+
tabIndex: -1,
|
|
956
|
+
...item.href ? { href: item.href } : { type: "button" },
|
|
957
|
+
onClick: () => {
|
|
958
|
+
item.onSelect?.();
|
|
959
|
+
close(!item.href);
|
|
960
|
+
},
|
|
961
|
+
className: cx(
|
|
962
|
+
"flex w-full items-center gap-space-sm rounded-lg px-space-sm py-space-xs text-left font-body-md text-body-md outline-none hover:bg-surface-muted focus:bg-surface-muted",
|
|
963
|
+
item.tone === "danger" ? "text-fg-danger" : "text-on-surface",
|
|
964
|
+
TOUCH
|
|
965
|
+
),
|
|
966
|
+
children: [
|
|
967
|
+
item.icon && /* @__PURE__ */ jsx35(Icon, { name: item.icon, size: "sm" }),
|
|
968
|
+
/* @__PURE__ */ jsx35("span", { className: "truncate", children: item.label })
|
|
969
|
+
]
|
|
970
|
+
},
|
|
971
|
+
item.label
|
|
972
|
+
);
|
|
973
|
+
})
|
|
974
|
+
}
|
|
975
|
+
)
|
|
976
|
+
] });
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
// src/ide/Breadcrumbs.tsx
|
|
980
|
+
import { jsx as jsx36, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
981
|
+
function Breadcrumbs({ items, label = "Breadcrumb", ...rest }) {
|
|
982
|
+
const collapse = items.length > 2;
|
|
983
|
+
return /* @__PURE__ */ jsx36("nav", { ...rest, "aria-label": label, className: "min-w-0", children: /* @__PURE__ */ jsx36("ol", { className: "flex min-w-0 items-center gap-space-xs font-body-sm text-body-sm text-on-surface-variant", children: items.map((c, i) => {
|
|
984
|
+
const last = i === items.length - 1;
|
|
985
|
+
const middle = i > 0 && !last;
|
|
986
|
+
const C = c.as ?? "a";
|
|
987
|
+
return [
|
|
988
|
+
/* @__PURE__ */ jsxs20("li", { className: cx("flex min-w-0 items-center gap-space-xs", middle && collapse && "max-md:hidden", last && "min-w-0"), children: [
|
|
989
|
+
i > 0 && /* @__PURE__ */ jsx36(Icon, { name: "chevron_right", size: "sm" }),
|
|
990
|
+
last ? /* @__PURE__ */ jsx36("span", { "aria-current": "page", className: "truncate font-medium text-on-surface", children: c.label }) : c.href ? /* @__PURE__ */ jsx36(C, { href: c.href, className: cx("truncate rounded hover:text-on-surface", FOCUS_RING), children: c.label }) : /* @__PURE__ */ jsx36("span", { className: "truncate", children: c.label })
|
|
991
|
+
] }, c.label + i),
|
|
992
|
+
i === 0 && collapse && /* @__PURE__ */ jsxs20("li", { "aria-hidden": "true", className: "flex items-center gap-space-xs md:hidden", children: [
|
|
993
|
+
/* @__PURE__ */ jsx36(Icon, { name: "chevron_right", size: "sm" }),
|
|
994
|
+
/* @__PURE__ */ jsx36("span", { children: "\u2026" })
|
|
995
|
+
] }, "ellipsis")
|
|
996
|
+
];
|
|
997
|
+
}) }) });
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
// src/ide/StatusBar.tsx
|
|
1001
|
+
import { jsx as jsx37, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
1002
|
+
var TONE7 = { default: "", success: TEXT_TONE.success, danger: TEXT_TONE.danger, warning: TEXT_TONE.warning, brand: TEXT_TONE.brand };
|
|
1003
|
+
function StatusItem({ icon, tone = "default", children, ...rest }) {
|
|
1004
|
+
return /* @__PURE__ */ jsxs21("span", { ...rest, className: cx("inline-flex shrink-0 items-center gap-space-2xs", TONE7[tone]), children: [
|
|
1005
|
+
icon && /* @__PURE__ */ jsx37(Icon, { name: icon, size: "sm" }),
|
|
1006
|
+
children
|
|
1007
|
+
] });
|
|
1008
|
+
}
|
|
1009
|
+
function StatusBarRoot({ start, end, label = "Status", ...rest }) {
|
|
1010
|
+
return /* @__PURE__ */ jsxs21("footer", { ...rest, "aria-label": label, className: "flex h-7 min-w-0 shrink-0 items-center justify-between gap-space-md overflow-hidden border-t border-border-subtle bg-surface-subtle px-space-sm font-label-mono text-[11px] text-on-surface-variant", children: [
|
|
1011
|
+
/* @__PURE__ */ jsx37("div", { className: "flex min-w-0 items-center gap-space-md overflow-hidden", children: start }),
|
|
1012
|
+
/* @__PURE__ */ jsx37("div", { className: "flex min-w-0 items-center gap-space-md overflow-hidden", children: end })
|
|
1013
|
+
] });
|
|
1014
|
+
}
|
|
1015
|
+
var StatusBar = Object.assign(StatusBarRoot, { Item: StatusItem });
|
|
1016
|
+
|
|
1017
|
+
// src/ide/MetricTile.tsx
|
|
1018
|
+
import { jsx as jsx38, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
1019
|
+
var TONE8 = { success: "text-fg-success", danger: "text-fg-danger", neutral: "text-ink" };
|
|
1020
|
+
function MetricTile({ label, value, tone = "neutral", icon, ...rest }) {
|
|
1021
|
+
return /* @__PURE__ */ jsxs22("div", { ...rest, className: "flex min-w-0 flex-col gap-space-2xs rounded-lg border border-border-subtle bg-surface-subtle p-space-sm", children: [
|
|
1022
|
+
/* @__PURE__ */ jsxs22("span", { className: "flex min-w-0 items-center gap-space-2xs font-label-mono text-label-mono uppercase text-on-surface-variant", children: [
|
|
1023
|
+
icon && /* @__PURE__ */ jsx38(Icon, { name: icon, size: "sm" }),
|
|
1024
|
+
/* @__PURE__ */ jsx38("span", { className: "truncate", children: label })
|
|
1025
|
+
] }),
|
|
1026
|
+
/* @__PURE__ */ jsx38("span", { className: cx("truncate font-display text-headline-sm", TONE8[tone]), children: value })
|
|
1027
|
+
] });
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
// src/ide/Avatar.tsx
|
|
1031
|
+
import { useState as useState2 } from "react";
|
|
1032
|
+
import { jsx as jsx39, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
1033
|
+
var SIZE8 = { sm: "size-7 text-[11px]", md: "size-9 text-xs", lg: "size-12 text-sm" };
|
|
1034
|
+
function initials(name) {
|
|
1035
|
+
return name.split(/\s+/).filter(Boolean).slice(0, 2).map((w) => w[0].toUpperCase()).join("");
|
|
1036
|
+
}
|
|
1037
|
+
function Avatar({ name, src, size = "md", badge, ...rest }) {
|
|
1038
|
+
const [failed, setFailed] = useState2(false);
|
|
1039
|
+
return /* @__PURE__ */ jsxs23("span", { ...rest, className: "relative inline-flex shrink-0", children: [
|
|
1040
|
+
src && !failed ? /* @__PURE__ */ jsx39("img", { src, alt: name, onError: () => setFailed(true), className: cx("rounded-full object-cover", SIZE8[size]) }) : /* @__PURE__ */ jsx39("span", { role: "img", "aria-label": name, className: cx("inline-flex items-center justify-center rounded-full bg-ink font-label-mono text-on-ink", SIZE8[size]), children: initials(name) }),
|
|
1041
|
+
badge && /* @__PURE__ */ jsx39("span", { className: "absolute -bottom-1 -right-1 rounded-full border-2 border-surface-elevated bg-brand-cobalt px-1 font-label-mono text-[10px] leading-4 text-white", children: badge })
|
|
1042
|
+
] });
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
// src/ide/EditorTabs.tsx
|
|
1046
|
+
import { Fragment as Fragment2, jsx as jsx40, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
1047
|
+
function EditorTabs({ tabs, activeId, onSelect, onClose, label = "Open files", ...rest }) {
|
|
1048
|
+
if (!tabs.length) return null;
|
|
1049
|
+
return /* @__PURE__ */ jsx40("nav", { ...rest, "aria-label": label, className: "min-w-0 max-w-full border-b border-border-subtle bg-surface-subtle", children: /* @__PURE__ */ jsx40("ul", { className: "flex min-w-0 overflow-x-auto [scrollbar-width:none]", children: tabs.map((t) => {
|
|
1050
|
+
const active = t.id === activeId;
|
|
1051
|
+
return /* @__PURE__ */ jsxs24(
|
|
1052
|
+
"li",
|
|
1053
|
+
{
|
|
1054
|
+
className: cx(
|
|
1055
|
+
"flex shrink-0 items-center border-r border-border-subtle",
|
|
1056
|
+
active ? "bg-surface-elevated text-ink shadow-[inset_0_-2px_0_var(--color-brand-cobalt)]" : "text-on-surface-variant hover:text-on-surface"
|
|
1057
|
+
),
|
|
1058
|
+
children: [
|
|
1059
|
+
/* @__PURE__ */ jsxs24(
|
|
1060
|
+
"button",
|
|
1061
|
+
{
|
|
1062
|
+
type: "button",
|
|
1063
|
+
"aria-current": active ? "page" : void 0,
|
|
1064
|
+
onClick: () => onSelect(t.id),
|
|
1065
|
+
onAuxClick: (e) => {
|
|
1066
|
+
if (e.button === 1 && onClose) {
|
|
1067
|
+
e.preventDefault();
|
|
1068
|
+
onClose(t.id);
|
|
1069
|
+
}
|
|
1070
|
+
},
|
|
1071
|
+
className: cx("flex items-center gap-space-xs whitespace-nowrap px-space-md py-space-xs font-code-inline text-code-inline", FOCUS_RING, TOUCH),
|
|
1072
|
+
children: [
|
|
1073
|
+
t.readOnly && /* @__PURE__ */ jsx40(Icon, { name: "lock", size: "sm", label: "Read-only" }),
|
|
1074
|
+
t.readOnly && " ",
|
|
1075
|
+
t.label,
|
|
1076
|
+
t.modified && /* @__PURE__ */ jsxs24(Fragment2, { children: [
|
|
1077
|
+
" ",
|
|
1078
|
+
/* @__PURE__ */ jsx40(Dot, { tone: "brand" }),
|
|
1079
|
+
/* @__PURE__ */ jsx40("span", { className: "sr-only", children: "(modified)" })
|
|
1080
|
+
] })
|
|
1081
|
+
]
|
|
1082
|
+
}
|
|
1083
|
+
),
|
|
1084
|
+
onClose && /* @__PURE__ */ jsx40(
|
|
1085
|
+
"button",
|
|
1086
|
+
{
|
|
1087
|
+
type: "button",
|
|
1088
|
+
"aria-label": `Close ${t.label}`,
|
|
1089
|
+
onClick: () => onClose(t.id),
|
|
1090
|
+
className: cx("mr-space-2xs inline-flex size-6 items-center justify-center rounded text-on-surface-variant hover:bg-surface-muted hover:text-on-surface", FOCUS_RING, TOUCH_ICON),
|
|
1091
|
+
children: /* @__PURE__ */ jsx40(Icon, { name: "close", size: "sm" })
|
|
1092
|
+
}
|
|
1093
|
+
)
|
|
1094
|
+
]
|
|
1095
|
+
},
|
|
1096
|
+
t.id
|
|
1097
|
+
);
|
|
1098
|
+
}) }) });
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
// src/ide/Countdown.tsx
|
|
1102
|
+
import { useEffect as useEffect3, useRef as useRef5, useState as useState3 } from "react";
|
|
1103
|
+
import { jsx as jsx41, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
1104
|
+
var pad = (n) => String(n).padStart(2, "0");
|
|
1105
|
+
function formatClock(totalSeconds) {
|
|
1106
|
+
const s = Math.max(0, Math.floor(totalSeconds));
|
|
1107
|
+
const h = Math.floor(s / 3600);
|
|
1108
|
+
const m = Math.floor(s % 3600 / 60);
|
|
1109
|
+
return h > 0 ? `${h}:${pad(m)}:${pad(s % 60)}` : `${pad(m)}:${pad(s % 60)}`;
|
|
1110
|
+
}
|
|
1111
|
+
function Countdown({ seconds, until, direction = "down", warnAt, onExpire, label = "Time remaining", ...rest }) {
|
|
1112
|
+
const [start] = useState3(() => Date.now());
|
|
1113
|
+
const [now, setNow] = useState3(() => until ? null : start);
|
|
1114
|
+
const onExpireRef = useRef5(onExpire);
|
|
1115
|
+
const fired = useRef5(false);
|
|
1116
|
+
useEffect3(() => {
|
|
1117
|
+
onExpireRef.current = onExpire;
|
|
1118
|
+
});
|
|
1119
|
+
const value = (() => {
|
|
1120
|
+
if (now === null) return null;
|
|
1121
|
+
const elapsed = Math.floor((now - start) / 1e3);
|
|
1122
|
+
if (direction === "up") return (seconds ?? 0) + elapsed;
|
|
1123
|
+
return Math.max(0, until ? Math.ceil((until.getTime() - now) / 1e3) : (seconds ?? 0) - elapsed);
|
|
1124
|
+
})();
|
|
1125
|
+
const expired = direction === "down" && value === 0;
|
|
1126
|
+
useEffect3(() => {
|
|
1127
|
+
if (expired) return;
|
|
1128
|
+
setNow((n) => n ?? Date.now());
|
|
1129
|
+
const id = setInterval(() => setNow(Date.now()), 1e3);
|
|
1130
|
+
return () => clearInterval(id);
|
|
1131
|
+
}, [expired]);
|
|
1132
|
+
useEffect3(() => {
|
|
1133
|
+
if (expired && !fired.current) {
|
|
1134
|
+
fired.current = true;
|
|
1135
|
+
onExpireRef.current?.();
|
|
1136
|
+
}
|
|
1137
|
+
}, [expired]);
|
|
1138
|
+
const warn = direction === "down" && warnAt !== void 0 && value !== null && value <= warnAt;
|
|
1139
|
+
return /* @__PURE__ */ jsxs25("span", { ...rest, role: "timer", "aria-label": label, className: cx("inline-flex items-center gap-space-2xs font-code-inline text-code-inline tabular-nums", warn ? "text-fg-danger" : "text-on-surface"), children: [
|
|
1140
|
+
/* @__PURE__ */ jsx41(Icon, { name: "timer", size: "sm" }),
|
|
1141
|
+
value === null ? "--:--" : formatClock(value)
|
|
1142
|
+
] });
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
// src/ide/FileTree.tsx
|
|
1146
|
+
import { useId as useId7, useMemo, useRef as useRef6, useState as useState4 } from "react";
|
|
1147
|
+
|
|
1148
|
+
// src/ide/tree.ts
|
|
1149
|
+
function buildTree(nodes) {
|
|
1150
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
1151
|
+
const roots = [];
|
|
1152
|
+
const ensure = (path, kind, extra) => {
|
|
1153
|
+
const existing = byPath.get(path);
|
|
1154
|
+
if (existing) return existing;
|
|
1155
|
+
const parts = path.split("/");
|
|
1156
|
+
const parentPath = parts.length > 1 ? parts.slice(0, -1).join("/") : null;
|
|
1157
|
+
const parent = parentPath ? ensure(parentPath, "dir") : null;
|
|
1158
|
+
const item = {
|
|
1159
|
+
path,
|
|
1160
|
+
name: parts[parts.length - 1],
|
|
1161
|
+
kind,
|
|
1162
|
+
readOnly: extra?.readOnly,
|
|
1163
|
+
modified: extra?.modified,
|
|
1164
|
+
level: parts.length,
|
|
1165
|
+
parent: parentPath,
|
|
1166
|
+
children: []
|
|
1167
|
+
};
|
|
1168
|
+
byPath.set(path, item);
|
|
1169
|
+
(parent ? parent.children : roots).push(item);
|
|
1170
|
+
return item;
|
|
1171
|
+
};
|
|
1172
|
+
for (const n of nodes) {
|
|
1173
|
+
const path = n.path.replace(/^\/+|\/+$/g, "");
|
|
1174
|
+
if (path && !byPath.has(path)) ensure(path, n.kind, n);
|
|
1175
|
+
}
|
|
1176
|
+
const sort = (items) => {
|
|
1177
|
+
items.sort((a, b) => a.kind === b.kind ? a.name.localeCompare(b.name) : a.kind === "dir" ? -1 : 1);
|
|
1178
|
+
items.forEach((i) => sort(i.children));
|
|
1179
|
+
};
|
|
1180
|
+
sort(roots);
|
|
1181
|
+
return roots;
|
|
1182
|
+
}
|
|
1183
|
+
function flattenVisible(roots, expanded) {
|
|
1184
|
+
const out = [];
|
|
1185
|
+
const walk = (items) => {
|
|
1186
|
+
for (const i of items) {
|
|
1187
|
+
out.push(i);
|
|
1188
|
+
if (i.kind === "dir" && expanded.has(i.path)) walk(i.children);
|
|
1189
|
+
}
|
|
1190
|
+
};
|
|
1191
|
+
walk(roots);
|
|
1192
|
+
return out;
|
|
1193
|
+
}
|
|
1194
|
+
function allDirs(roots) {
|
|
1195
|
+
const out = [];
|
|
1196
|
+
const walk = (items) => items.forEach((i) => i.kind === "dir" && (out.push(i.path), walk(i.children)));
|
|
1197
|
+
walk(roots);
|
|
1198
|
+
return out;
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
// src/ide/FileTree.tsx
|
|
1202
|
+
import { Fragment as Fragment3, jsx as jsx42, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
1203
|
+
var EXT_ICON = {
|
|
1204
|
+
ts: "code",
|
|
1205
|
+
tsx: "code",
|
|
1206
|
+
js: "javascript",
|
|
1207
|
+
jsx: "javascript",
|
|
1208
|
+
py: "code",
|
|
1209
|
+
go: "code",
|
|
1210
|
+
json: "data_object",
|
|
1211
|
+
md: "article"
|
|
1212
|
+
};
|
|
1213
|
+
function fileIcon(name) {
|
|
1214
|
+
const ext = name.includes(".") ? name.split(".").pop().toLowerCase() : "";
|
|
1215
|
+
return EXT_ICON[ext] ?? "description";
|
|
1216
|
+
}
|
|
1217
|
+
function FileTree({ nodes, activePath, onOpen, defaultExpanded = "all", label, ...rest }) {
|
|
1218
|
+
const baseId = useId7();
|
|
1219
|
+
const roots = useMemo(() => buildTree(nodes), [nodes]);
|
|
1220
|
+
const allOpen = defaultExpanded === "all";
|
|
1221
|
+
const [toggled, setToggled] = useState4(() => new Set(allOpen ? [] : defaultExpanded));
|
|
1222
|
+
const [focused, setFocused] = useState4(activePath);
|
|
1223
|
+
const refs = useRef6(/* @__PURE__ */ new Map());
|
|
1224
|
+
if (!roots.length) return null;
|
|
1225
|
+
const expanded = new Set(allDirs(roots).filter((d) => toggled.has(d) !== allOpen));
|
|
1226
|
+
const visible = flattenVisible(roots, expanded);
|
|
1227
|
+
const tabbable = visible.some((i) => i.path === focused) ? focused : visible[0]?.path;
|
|
1228
|
+
const focusPath = (path) => {
|
|
1229
|
+
setFocused(path);
|
|
1230
|
+
refs.current.get(path)?.focus();
|
|
1231
|
+
};
|
|
1232
|
+
const toggle = (path, open) => setToggled((prev) => {
|
|
1233
|
+
const next = new Set(prev);
|
|
1234
|
+
const shouldOpen = open ?? !expanded.has(path);
|
|
1235
|
+
if (shouldOpen !== allOpen) next.add(path);
|
|
1236
|
+
else next.delete(path);
|
|
1237
|
+
return next;
|
|
1238
|
+
});
|
|
1239
|
+
const activate = (item) => item.kind === "dir" ? toggle(item.path) : onOpen(item.path);
|
|
1240
|
+
const onKeyDown = (e, item) => {
|
|
1241
|
+
const i = visible.findIndex((v) => v.path === item.path);
|
|
1242
|
+
const isOpen = item.kind === "dir" && expanded.has(item.path);
|
|
1243
|
+
let handled = true;
|
|
1244
|
+
switch (e.key) {
|
|
1245
|
+
case "ArrowDown":
|
|
1246
|
+
if (i < visible.length - 1) focusPath(visible[i + 1].path);
|
|
1247
|
+
break;
|
|
1248
|
+
case "ArrowUp":
|
|
1249
|
+
if (i > 0) focusPath(visible[i - 1].path);
|
|
1250
|
+
break;
|
|
1251
|
+
case "Home":
|
|
1252
|
+
focusPath(visible[0].path);
|
|
1253
|
+
break;
|
|
1254
|
+
case "End":
|
|
1255
|
+
focusPath(visible[visible.length - 1].path);
|
|
1256
|
+
break;
|
|
1257
|
+
case "ArrowRight":
|
|
1258
|
+
if (item.kind === "dir") {
|
|
1259
|
+
if (!isOpen) toggle(item.path, true);
|
|
1260
|
+
else if (item.children[0]) focusPath(item.children[0].path);
|
|
1261
|
+
}
|
|
1262
|
+
break;
|
|
1263
|
+
case "ArrowLeft":
|
|
1264
|
+
if (isOpen) toggle(item.path, false);
|
|
1265
|
+
else if (item.parent) focusPath(item.parent);
|
|
1266
|
+
break;
|
|
1267
|
+
case "Enter":
|
|
1268
|
+
activate(item);
|
|
1269
|
+
break;
|
|
1270
|
+
default:
|
|
1271
|
+
handled = false;
|
|
1272
|
+
}
|
|
1273
|
+
if (handled) {
|
|
1274
|
+
e.preventDefault();
|
|
1275
|
+
e.stopPropagation();
|
|
1276
|
+
}
|
|
1277
|
+
};
|
|
1278
|
+
const renderItems = (items) => items.map((item) => {
|
|
1279
|
+
const isDir = item.kind === "dir";
|
|
1280
|
+
const isOpen = isDir && expanded.has(item.path);
|
|
1281
|
+
const rowId = `${baseId}-${encodeURIComponent(item.path)}`;
|
|
1282
|
+
return /* @__PURE__ */ jsxs26(
|
|
1283
|
+
"li",
|
|
1284
|
+
{
|
|
1285
|
+
ref: (el) => {
|
|
1286
|
+
if (el) refs.current.set(item.path, el);
|
|
1287
|
+
else refs.current.delete(item.path);
|
|
1288
|
+
},
|
|
1289
|
+
role: "treeitem",
|
|
1290
|
+
"aria-labelledby": rowId,
|
|
1291
|
+
"aria-level": item.level,
|
|
1292
|
+
"aria-expanded": isDir ? isOpen : void 0,
|
|
1293
|
+
"aria-selected": item.path === activePath,
|
|
1294
|
+
tabIndex: item.path === tabbable ? 0 : -1,
|
|
1295
|
+
onKeyDown: (e) => onKeyDown(e, item),
|
|
1296
|
+
onFocus: (e) => {
|
|
1297
|
+
if (e.target === e.currentTarget) setFocused(item.path);
|
|
1298
|
+
},
|
|
1299
|
+
className: "outline-none [&:focus-visible>div]:ring-2 [&:focus-visible>div]:ring-inset [&:focus-visible>div]:ring-brand-cobalt",
|
|
1300
|
+
children: [
|
|
1301
|
+
/* @__PURE__ */ jsxs26(
|
|
1302
|
+
"div",
|
|
1303
|
+
{
|
|
1304
|
+
id: rowId,
|
|
1305
|
+
onClick: () => {
|
|
1306
|
+
focusPath(item.path);
|
|
1307
|
+
activate(item);
|
|
1308
|
+
},
|
|
1309
|
+
style: { paddingLeft: `calc(${item.level - 1} * 0.75rem + 0.5rem)` },
|
|
1310
|
+
className: cx(
|
|
1311
|
+
"flex min-w-0 cursor-pointer items-center gap-space-xs py-space-2xs pr-space-sm font-code-inline text-code-inline max-md:min-h-11",
|
|
1312
|
+
item.path === activePath ? "bg-surface-muted text-ink" : "text-on-surface-variant hover:bg-surface-muted hover:text-on-surface"
|
|
1313
|
+
),
|
|
1314
|
+
children: [
|
|
1315
|
+
isDir ? /* @__PURE__ */ jsx42(Icon, { name: isOpen ? "expand_more" : "chevron_right", size: "sm" }) : /* @__PURE__ */ jsx42("span", { className: "inline-block w-4 shrink-0" }),
|
|
1316
|
+
/* @__PURE__ */ jsx42(Icon, { name: isDir ? isOpen ? "folder_open" : "folder" : fileIcon(item.name), size: "sm", tone: isDir ? "brand" : "inherit" }),
|
|
1317
|
+
/* @__PURE__ */ jsx42("span", { className: "truncate", children: item.name }),
|
|
1318
|
+
item.readOnly && " ",
|
|
1319
|
+
item.readOnly && /* @__PURE__ */ jsx42(Icon, { name: "lock", size: "sm", label: "Read-only" }),
|
|
1320
|
+
item.modified && /* @__PURE__ */ jsxs26(Fragment3, { children: [
|
|
1321
|
+
" ",
|
|
1322
|
+
/* @__PURE__ */ jsx42(Dot, { tone: "brand" }),
|
|
1323
|
+
/* @__PURE__ */ jsx42("span", { className: "sr-only", children: "(modified)" })
|
|
1324
|
+
] })
|
|
1325
|
+
]
|
|
1326
|
+
}
|
|
1327
|
+
),
|
|
1328
|
+
isDir && isOpen && item.children.length > 0 && /* @__PURE__ */ jsx42("ul", { role: "group", children: renderItems(item.children) })
|
|
1329
|
+
]
|
|
1330
|
+
},
|
|
1331
|
+
item.path
|
|
1332
|
+
);
|
|
1333
|
+
});
|
|
1334
|
+
return /* @__PURE__ */ jsx42("ul", { ...rest, role: "tree", "aria-label": label, className: "min-w-0 overflow-auto py-space-xs", children: renderItems(roots) });
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
// src/ide/Workbench.tsx
|
|
1338
|
+
import {
|
|
1339
|
+
createContext as createContext2,
|
|
1340
|
+
useContext as useContext2,
|
|
1341
|
+
useEffect as useEffect4,
|
|
1342
|
+
useId as useId8,
|
|
1343
|
+
useRef as useRef7,
|
|
1344
|
+
useState as useState5
|
|
1345
|
+
} from "react";
|
|
1346
|
+
import { Fragment as Fragment4, jsx as jsx43, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
1347
|
+
var DEFAULT_SIZES = { left: 240, right: 380, bottom: 30 };
|
|
1348
|
+
var DEFAULT_LIMITS = { left: [160, 480], right: [260, 640], bottom: [15, 70] };
|
|
1349
|
+
var DEFAULT_LABELS = { left: "Explorer", main: "Editor", right: "Details", bottom: "Panel" };
|
|
1350
|
+
var STEP = { left: 16, right: 16, bottom: 5 };
|
|
1351
|
+
var PANELS = ["left", "right", "bottom"];
|
|
1352
|
+
var COLUMNS = {
|
|
1353
|
+
both: "lg:grid-cols-[var(--wb-left)_4px_minmax(0,1fr)_4px_var(--wb-right)]",
|
|
1354
|
+
left: "lg:grid-cols-[var(--wb-left)_4px_minmax(0,1fr)]",
|
|
1355
|
+
right: "lg:grid-cols-[minmax(0,1fr)_4px_var(--wb-right)]",
|
|
1356
|
+
none: "lg:grid-cols-1"
|
|
1357
|
+
};
|
|
1358
|
+
var clamp = (v, [min, max]) => Math.min(max, Math.max(min, v));
|
|
1359
|
+
function readSizes(raw, defaults, limits) {
|
|
1360
|
+
let parsed;
|
|
1361
|
+
try {
|
|
1362
|
+
parsed = raw ? JSON.parse(raw) : null;
|
|
1363
|
+
} catch {
|
|
1364
|
+
parsed = null;
|
|
1365
|
+
}
|
|
1366
|
+
const out = { ...defaults };
|
|
1367
|
+
if (parsed && typeof parsed === "object") {
|
|
1368
|
+
for (const k of PANELS) {
|
|
1369
|
+
const v = parsed[k];
|
|
1370
|
+
if (typeof v === "number" && Number.isFinite(v) && v >= limits[k][0] && v <= limits[k][1]) out[k] = v;
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
return out;
|
|
1374
|
+
}
|
|
1375
|
+
var WorkbenchContext = createContext2(null);
|
|
1376
|
+
function Toggle({ panel }) {
|
|
1377
|
+
const ctx = useContext2(WorkbenchContext);
|
|
1378
|
+
if (!ctx) return null;
|
|
1379
|
+
const open = ctx.drawer === panel;
|
|
1380
|
+
return /* @__PURE__ */ jsx43("span", { className: "lg:hidden", children: /* @__PURE__ */ jsx43(
|
|
1381
|
+
IconButton,
|
|
1382
|
+
{
|
|
1383
|
+
icon: panel === "left" ? "left_panel_open" : "right_panel_open",
|
|
1384
|
+
label: `${open ? "Hide" : "Show"} ${ctx.labels[panel]}`,
|
|
1385
|
+
"aria-expanded": open,
|
|
1386
|
+
"aria-controls": ctx.ids[panel],
|
|
1387
|
+
onClick: () => ctx.setDrawer(open ? null : panel)
|
|
1388
|
+
}
|
|
1389
|
+
) });
|
|
1390
|
+
}
|
|
1391
|
+
function Separator({ panel, value, limits, label, controls, onChange, centerHeight }) {
|
|
1392
|
+
const drag = useRef7(null);
|
|
1393
|
+
const vertical = panel !== "bottom";
|
|
1394
|
+
const grow = panel === "left" ? "ArrowRight" : panel === "right" ? "ArrowLeft" : "ArrowUp";
|
|
1395
|
+
const shrink = panel === "left" ? "ArrowLeft" : panel === "right" ? "ArrowRight" : "ArrowDown";
|
|
1396
|
+
const onKeyDown = (e) => {
|
|
1397
|
+
const next = e.key === grow ? value + STEP[panel] : e.key === shrink ? value - STEP[panel] : e.key === "Home" ? limits[0] : e.key === "End" ? limits[1] : null;
|
|
1398
|
+
if (next === null) return;
|
|
1399
|
+
e.preventDefault();
|
|
1400
|
+
onChange(next);
|
|
1401
|
+
};
|
|
1402
|
+
const onPointerDown = (e) => {
|
|
1403
|
+
drag.current = { x: e.clientX, y: e.clientY, value };
|
|
1404
|
+
try {
|
|
1405
|
+
e.currentTarget.setPointerCapture?.(e.pointerId);
|
|
1406
|
+
} catch {
|
|
1407
|
+
}
|
|
1408
|
+
};
|
|
1409
|
+
const onPointerMove = (e) => {
|
|
1410
|
+
const d = drag.current;
|
|
1411
|
+
if (!d) return;
|
|
1412
|
+
if (panel === "left") onChange(d.value + (e.clientX - d.x));
|
|
1413
|
+
else if (panel === "right") onChange(d.value - (e.clientX - d.x));
|
|
1414
|
+
else {
|
|
1415
|
+
const h = centerHeight();
|
|
1416
|
+
if (h > 0) onChange(d.value - (e.clientY - d.y) / h * 100);
|
|
1417
|
+
}
|
|
1418
|
+
};
|
|
1419
|
+
const end = () => {
|
|
1420
|
+
drag.current = null;
|
|
1421
|
+
};
|
|
1422
|
+
return /* @__PURE__ */ jsx43(
|
|
1423
|
+
"div",
|
|
1424
|
+
{
|
|
1425
|
+
role: "separator",
|
|
1426
|
+
tabIndex: 0,
|
|
1427
|
+
"aria-orientation": vertical ? "vertical" : "horizontal",
|
|
1428
|
+
"aria-label": label,
|
|
1429
|
+
"aria-controls": controls,
|
|
1430
|
+
"aria-valuenow": Math.round(value),
|
|
1431
|
+
"aria-valuemin": limits[0],
|
|
1432
|
+
"aria-valuemax": limits[1],
|
|
1433
|
+
onKeyDown,
|
|
1434
|
+
onPointerDown,
|
|
1435
|
+
onPointerMove,
|
|
1436
|
+
onPointerUp: end,
|
|
1437
|
+
onPointerCancel: end,
|
|
1438
|
+
className: cx(
|
|
1439
|
+
"shrink-0 touch-none bg-border-subtle outline-none transition-colors hover:bg-brand-cobalt focus-visible:bg-brand-cobalt",
|
|
1440
|
+
vertical ? "w-1 cursor-col-resize max-lg:hidden" : "h-1 cursor-row-resize max-md:hidden"
|
|
1441
|
+
)
|
|
1442
|
+
}
|
|
1443
|
+
);
|
|
1444
|
+
}
|
|
1445
|
+
function WorkbenchRoot({ header, left, main, right, bottom, labels: labelsProp, defaultSizes, limits: limitsProp, persistKey, ...rest }) {
|
|
1446
|
+
const labels = { ...DEFAULT_LABELS, ...labelsProp };
|
|
1447
|
+
const limits = { ...DEFAULT_LIMITS, ...limitsProp };
|
|
1448
|
+
const defaults = { ...DEFAULT_SIZES, ...defaultSizes };
|
|
1449
|
+
const [sizes, setSizes] = useState5(defaults);
|
|
1450
|
+
const [drawer, setDrawer] = useState5(null);
|
|
1451
|
+
const [mobileView, setMobileView] = useState5("main");
|
|
1452
|
+
const baseId = useId8();
|
|
1453
|
+
const ids = { left: `${baseId}-left`, main: `${baseId}-main`, right: `${baseId}-right`, bottom: `${baseId}-bottom` };
|
|
1454
|
+
const centerRef = useRef7(null);
|
|
1455
|
+
useEffect4(() => {
|
|
1456
|
+
if (!persistKey) return;
|
|
1457
|
+
let raw;
|
|
1458
|
+
try {
|
|
1459
|
+
raw = window.localStorage.getItem(persistKey);
|
|
1460
|
+
} catch {
|
|
1461
|
+
raw = null;
|
|
1462
|
+
}
|
|
1463
|
+
setSizes(readSizes(raw, defaults, limits));
|
|
1464
|
+
}, [persistKey]);
|
|
1465
|
+
useEffect4(() => {
|
|
1466
|
+
if (!drawer) return;
|
|
1467
|
+
const onKey = (e) => {
|
|
1468
|
+
if (e.key === "Escape" && !e.defaultPrevented) setDrawer(null);
|
|
1469
|
+
};
|
|
1470
|
+
document.addEventListener("keydown", onKey);
|
|
1471
|
+
return () => document.removeEventListener("keydown", onKey);
|
|
1472
|
+
}, [drawer]);
|
|
1473
|
+
const resize = (panel) => (value) => setSizes((prev) => {
|
|
1474
|
+
const next = { ...prev, [panel]: clamp(value, limits[panel]) };
|
|
1475
|
+
if (persistKey) {
|
|
1476
|
+
try {
|
|
1477
|
+
window.localStorage.setItem(persistKey, JSON.stringify(next));
|
|
1478
|
+
} catch {
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
return next;
|
|
1482
|
+
});
|
|
1483
|
+
const centerHeight = () => centerRef.current?.getBoundingClientRect().height ?? 0;
|
|
1484
|
+
const vars = { "--wb-left": `${sizes.left}px`, "--wb-right": `${sizes.right}px`, "--wb-bottom": `${sizes.bottom}%` };
|
|
1485
|
+
const columns = left && right ? COLUMNS.both : left ? COLUMNS.left : right ? COLUMNS.right : COLUMNS.none;
|
|
1486
|
+
const drawerClass = (side) => cx(
|
|
1487
|
+
"min-h-0 min-w-0 overflow-auto bg-surface-subtle",
|
|
1488
|
+
"max-lg:fixed max-lg:inset-y-0 max-lg:z-40 max-lg:w-[min(85vw,320px)] max-lg:shadow-md",
|
|
1489
|
+
side === "left" ? "border-r border-border-subtle max-lg:left-0" : "border-l border-border-subtle max-lg:right-0",
|
|
1490
|
+
drawer !== side && "max-lg:hidden"
|
|
1491
|
+
);
|
|
1492
|
+
return /* @__PURE__ */ jsx43(WorkbenchContext.Provider, { value: { drawer, setDrawer, ids, labels }, children: /* @__PURE__ */ jsxs27("div", { ...rest, className: "flex h-full min-h-0 w-full min-w-0 flex-col overflow-hidden bg-surface text-on-surface", children: [
|
|
1493
|
+
header && /* @__PURE__ */ jsx43("div", { className: "flex min-w-0 shrink-0 items-center gap-space-sm border-b border-border-subtle px-space-sm py-space-xs", children: header }),
|
|
1494
|
+
/* @__PURE__ */ jsxs27("div", { style: vars, className: cx("relative grid min-h-0 min-w-0 flex-1 grid-cols-1 grid-rows-[minmax(0,1fr)]", columns), children: [
|
|
1495
|
+
left && /* @__PURE__ */ jsxs27(Fragment4, { children: [
|
|
1496
|
+
/* @__PURE__ */ jsx43("section", { id: ids.left, "aria-label": labels.left, className: drawerClass("left"), children: left }),
|
|
1497
|
+
/* @__PURE__ */ jsx43(Separator, { panel: "left", value: sizes.left, limits: limits.left, label: `Resize ${labels.left}`, controls: ids.left, onChange: resize("left"), centerHeight })
|
|
1498
|
+
] }),
|
|
1499
|
+
/* @__PURE__ */ jsxs27("div", { ref: centerRef, className: "flex min-h-0 min-w-0 flex-col", children: [
|
|
1500
|
+
bottom && /* @__PURE__ */ jsx43("div", { className: "flex shrink-0 border-b border-border-subtle p-space-2xs md:hidden", children: /* @__PURE__ */ jsx43(
|
|
1501
|
+
SegmentedControl,
|
|
1502
|
+
{
|
|
1503
|
+
label: "View",
|
|
1504
|
+
options: [
|
|
1505
|
+
{ value: "main", label: labels.main },
|
|
1506
|
+
{ value: "bottom", label: labels.bottom }
|
|
1507
|
+
],
|
|
1508
|
+
value: mobileView,
|
|
1509
|
+
onChange: (v) => setMobileView(v === "bottom" ? "bottom" : "main")
|
|
1510
|
+
}
|
|
1511
|
+
) }),
|
|
1512
|
+
/* @__PURE__ */ jsx43("section", { id: ids.main, "aria-label": labels.main, className: cx("min-h-0 min-w-0 flex-1 overflow-auto", Boolean(bottom) && mobileView === "bottom" && "max-md:hidden"), children: main }),
|
|
1513
|
+
bottom && /* @__PURE__ */ jsxs27(Fragment4, { children: [
|
|
1514
|
+
/* @__PURE__ */ jsx43(Separator, { panel: "bottom", value: sizes.bottom, limits: limits.bottom, label: `Resize ${labels.bottom}`, controls: ids.bottom, onChange: resize("bottom"), centerHeight }),
|
|
1515
|
+
/* @__PURE__ */ jsx43(
|
|
1516
|
+
"section",
|
|
1517
|
+
{
|
|
1518
|
+
id: ids.bottom,
|
|
1519
|
+
"aria-label": labels.bottom,
|
|
1520
|
+
className: cx("min-h-0 min-w-0 overflow-auto border-t border-border-subtle md:h-(--wb-bottom) md:shrink-0", mobileView === "main" ? "max-md:hidden" : "max-md:flex-1"),
|
|
1521
|
+
children: bottom
|
|
1522
|
+
}
|
|
1523
|
+
)
|
|
1524
|
+
] })
|
|
1525
|
+
] }),
|
|
1526
|
+
right && /* @__PURE__ */ jsxs27(Fragment4, { children: [
|
|
1527
|
+
/* @__PURE__ */ jsx43(Separator, { panel: "right", value: sizes.right, limits: limits.right, label: `Resize ${labels.right}`, controls: ids.right, onChange: resize("right"), centerHeight }),
|
|
1528
|
+
/* @__PURE__ */ jsx43("section", { id: ids.right, "aria-label": labels.right, className: drawerClass("right"), children: right })
|
|
1529
|
+
] }),
|
|
1530
|
+
drawer && /* @__PURE__ */ jsx43("button", { type: "button", "aria-label": "Close panel", tabIndex: -1, onClick: () => setDrawer(null), className: "fixed inset-0 z-30 bg-brand-obsidian/40 lg:hidden" })
|
|
1531
|
+
] })
|
|
1532
|
+
] }) });
|
|
1533
|
+
}
|
|
1534
|
+
var Workbench = Object.assign(WorkbenchRoot, { Toggle });
|
|
1535
|
+
export {
|
|
1536
|
+
Avatar,
|
|
1537
|
+
Badge,
|
|
1538
|
+
Box,
|
|
1539
|
+
Breadcrumbs,
|
|
1540
|
+
Button,
|
|
1541
|
+
Callout,
|
|
1542
|
+
Card,
|
|
1543
|
+
CardFooter,
|
|
1544
|
+
CardMedia,
|
|
1545
|
+
CheckList,
|
|
1546
|
+
Chip,
|
|
1547
|
+
Code,
|
|
1548
|
+
CodeBlock,
|
|
1549
|
+
Container,
|
|
1550
|
+
Countdown,
|
|
1551
|
+
Dialog,
|
|
1552
|
+
Dot,
|
|
1553
|
+
EditorTabs,
|
|
1554
|
+
EmptyState,
|
|
1555
|
+
Eyebrow,
|
|
1556
|
+
FileTree,
|
|
1557
|
+
Grid,
|
|
1558
|
+
Heading,
|
|
1559
|
+
Icon,
|
|
1560
|
+
IconButton,
|
|
1561
|
+
Kbd,
|
|
1562
|
+
Markdown,
|
|
1563
|
+
Menu,
|
|
1564
|
+
Message,
|
|
1565
|
+
MetricTile,
|
|
1566
|
+
ProgressBar,
|
|
1567
|
+
ResultRow,
|
|
1568
|
+
Section,
|
|
1569
|
+
SectionHeader,
|
|
1570
|
+
SegmentedControl,
|
|
1571
|
+
Select,
|
|
1572
|
+
Split,
|
|
1573
|
+
Stack,
|
|
1574
|
+
Stat,
|
|
1575
|
+
StatusBar,
|
|
1576
|
+
TabPanel,
|
|
1577
|
+
Tabs,
|
|
1578
|
+
Text,
|
|
1579
|
+
TextField,
|
|
1580
|
+
Theme,
|
|
1581
|
+
Workbench,
|
|
1582
|
+
useThemeTone
|
|
1583
|
+
};
|
|
1584
|
+
//# sourceMappingURL=index.js.map
|