@flatwork-ui/react 0.0.0-stage → 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/dist/index.js ADDED
@@ -0,0 +1,1166 @@
1
+ "use client";
2
+
3
+ // src/cx.ts
4
+ function cx(...classes) {
5
+ return classes.filter(Boolean).join(" ");
6
+ }
7
+
8
+ // src/base.tsx
9
+ import { forwardRef } from "react";
10
+ import { jsx } from "react/jsx-runtime";
11
+ var FlatworkRoot = forwardRef(function FlatworkRoot2({ mode, className, ...props }, ref) {
12
+ return /* @__PURE__ */ jsx("div", { ref, className: cx("fw", className), "data-theme": mode, ...props });
13
+ });
14
+ var defaultTag = {
15
+ display: "h1",
16
+ title: "h2",
17
+ heading: "h3",
18
+ body: "p",
19
+ label: "span",
20
+ caption: "span",
21
+ mono: "span"
22
+ };
23
+ function Text({ variant = "body", muted, as, className, ...props }) {
24
+ const Tag2 = as ?? defaultTag[variant];
25
+ return /* @__PURE__ */ jsx(Tag2, { className: cx(`fw-t-${variant}`, muted && "fw-t-muted", className), ...props });
26
+ }
27
+ function Kbd(props) {
28
+ return /* @__PURE__ */ jsx("kbd", { ...props });
29
+ }
30
+ function Spinner({ size = "md", label, className, ...props }) {
31
+ return /* @__PURE__ */ jsx(
32
+ "span",
33
+ {
34
+ className: cx("fw-spinner", size === "lg" && "fw-spinner-lg", className),
35
+ ...label ? { role: "status", "aria-label": label } : { "aria-hidden": true },
36
+ ...props
37
+ }
38
+ );
39
+ }
40
+ function VisuallyHidden({ children }) {
41
+ return /* @__PURE__ */ jsx("span", { style: { position: "absolute", width: 1, height: 1, overflow: "hidden", clip: "rect(0 0 0 0)", whiteSpace: "nowrap" }, children });
42
+ }
43
+
44
+ // src/Button.tsx
45
+ import { forwardRef as forwardRef2 } from "react";
46
+ import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
47
+ function buttonClass({ variant = "secondary", size = "md", iconOnly, block }, className) {
48
+ return cx(
49
+ "fw-btn",
50
+ `fw-btn-${variant}`,
51
+ size !== "md" && `fw-btn-${size}`,
52
+ iconOnly && "fw-btn-icon",
53
+ block && "fw-btn-block",
54
+ className
55
+ );
56
+ }
57
+ function content({ loading, leadingIcon, trailingIcon }, children) {
58
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
59
+ loading ? /* @__PURE__ */ jsx2(Spinner, {}) : leadingIcon,
60
+ children,
61
+ trailingIcon
62
+ ] });
63
+ }
64
+ var Button = forwardRef2(function Button2({ variant, size, iconOnly, block, loading, leadingIcon, trailingIcon, className, children, type = "button", disabled, ...props }, ref) {
65
+ const own = { variant, size, iconOnly, block, loading, leadingIcon, trailingIcon };
66
+ return /* @__PURE__ */ jsx2(
67
+ "button",
68
+ {
69
+ ref,
70
+ type,
71
+ className: buttonClass(own, className),
72
+ disabled: disabled || loading,
73
+ "aria-busy": loading || void 0,
74
+ ...props,
75
+ children: content(own, children)
76
+ }
77
+ );
78
+ });
79
+ var ButtonLink = forwardRef2(function ButtonLink2({ variant, size, iconOnly, block, loading, leadingIcon, trailingIcon, className, children, ...props }, ref) {
80
+ const own = { variant, size, iconOnly, block, loading, leadingIcon, trailingIcon };
81
+ return /* @__PURE__ */ jsx2("a", { ref, className: buttonClass(own, className), ...props, children: content(own, children) });
82
+ });
83
+ function ButtonGroup({ className, ...props }) {
84
+ return /* @__PURE__ */ jsx2("div", { role: "group", className: cx("fw-btn-group", className), ...props });
85
+ }
86
+
87
+ // src/Form.tsx
88
+ import {
89
+ createContext,
90
+ forwardRef as forwardRef3,
91
+ useContext,
92
+ useEffect,
93
+ useId,
94
+ useImperativeHandle,
95
+ useRef
96
+ } from "react";
97
+
98
+ // src/icons.tsx
99
+ import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
100
+ function icon(name, paths) {
101
+ const Icon = (props) => /* @__PURE__ */ jsx3(
102
+ "svg",
103
+ {
104
+ "aria-hidden": "true",
105
+ viewBox: "0 0 16 16",
106
+ width: "16",
107
+ height: "16",
108
+ fill: "none",
109
+ stroke: "currentColor",
110
+ strokeWidth: 1.4,
111
+ strokeLinecap: "round",
112
+ strokeLinejoin: "round",
113
+ ...props,
114
+ children: paths
115
+ }
116
+ );
117
+ Icon.displayName = name;
118
+ return Icon;
119
+ }
120
+ var IconHome = icon("IconHome", /* @__PURE__ */ jsxs2(Fragment2, { children: [
121
+ /* @__PURE__ */ jsx3("path", { d: "M2 6.5 8 2l6 4.5V14H2z" }),
122
+ /* @__PURE__ */ jsx3("path", { d: "M6.25 14V9.5h3.5V14" })
123
+ ] }));
124
+ var IconUser = icon("IconUser", /* @__PURE__ */ jsxs2(Fragment2, { children: [
125
+ /* @__PURE__ */ jsx3("circle", { cx: "8", cy: "5.5", r: "2.75" }),
126
+ /* @__PURE__ */ jsx3("path", { d: "M2.75 14c.6-2.6 2.7-4 5.25-4s4.65 1.4 5.25 4" })
127
+ ] }));
128
+ var IconSettings = icon("IconSettings", /* @__PURE__ */ jsxs2(Fragment2, { children: [
129
+ /* @__PURE__ */ jsx3("circle", { cx: "8", cy: "8", r: "2" }),
130
+ /* @__PURE__ */ jsx3("path", { d: "M8 1.5v2M8 12.5v2M1.5 8h2M12.5 8h2M3.4 3.4l1.4 1.4M11.2 11.2l1.4 1.4M3.4 12.6l1.4-1.4M11.2 4.8l1.4-1.4" })
131
+ ] }));
132
+ var IconPlus = icon("IconPlus", /* @__PURE__ */ jsx3("path", { d: "M8 3v10M3 8h10" }));
133
+ var IconDownload = icon("IconDownload", /* @__PURE__ */ jsx3("path", { d: "M8 2.5v8M4.5 7 8 10.5 11.5 7M2.5 13.5h11" }));
134
+ var IconUpload = icon("IconUpload", /* @__PURE__ */ jsx3("path", { d: "M8 10.5v-8M4.5 6 8 2.5 11.5 6M2.5 13.5h11" }));
135
+ var IconChevronDown = icon("IconChevronDown", /* @__PURE__ */ jsx3("path", { d: "m4 6 4 4 4-4" }));
136
+ var IconChevronUp = icon("IconChevronUp", /* @__PURE__ */ jsx3("path", { d: "m4 10 4-4 4 4" }));
137
+ var IconChevronRight = icon("IconChevronRight", /* @__PURE__ */ jsx3("path", { d: "m6 3.5 4 4.5-4 4.5" }));
138
+ var IconChevronLeft = icon("IconChevronLeft", /* @__PURE__ */ jsx3("path", { d: "m10 3.5-4 4.5 4 4.5" }));
139
+ var IconArrowRight = icon("IconArrowRight", /* @__PURE__ */ jsx3("path", { d: "M3 8h10M9 4l4 4-4 4" }));
140
+ var IconPencil = icon("IconPencil", /* @__PURE__ */ jsx3("path", { d: "M10.5 2.5 13.5 5.5 5.5 13.5H2.5V10.5z" }));
141
+ var IconCopy = icon("IconCopy", /* @__PURE__ */ jsxs2(Fragment2, { children: [
142
+ /* @__PURE__ */ jsx3("rect", { x: "5", y: "5", width: "8.5", height: "8.5", rx: "1.5" }),
143
+ /* @__PURE__ */ jsx3("path", { d: "M3 10.5V3.5A1 1 0 0 1 4 2.5h6.5" })
144
+ ] }));
145
+ var IconMore = icon("IconMore", /* @__PURE__ */ jsxs2(Fragment2, { children: [
146
+ /* @__PURE__ */ jsx3("circle", { cx: "3.5", cy: "8", r: "1.25" }),
147
+ /* @__PURE__ */ jsx3("circle", { cx: "8", cy: "8", r: "1.25" }),
148
+ /* @__PURE__ */ jsx3("circle", { cx: "12.5", cy: "8", r: "1.25" })
149
+ ] }));
150
+ var IconX = icon("IconX", /* @__PURE__ */ jsx3("path", { d: "m4 4 8 8M12 4l-8 8" }));
151
+ var IconTrash = icon("IconTrash", /* @__PURE__ */ jsx3("path", { d: "M2.5 4.5h11M6 4.5V3h4v1.5M4 4.5l.7 9h6.6l.7-9" }));
152
+ var IconSearch = icon("IconSearch", /* @__PURE__ */ jsxs2(Fragment2, { children: [
153
+ /* @__PURE__ */ jsx3("circle", { cx: "7", cy: "7", r: "4.5" }),
154
+ /* @__PURE__ */ jsx3("path", { d: "m10.5 10.5 3.5 3.5" })
155
+ ] }));
156
+ var IconEye = icon("IconEye", /* @__PURE__ */ jsxs2(Fragment2, { children: [
157
+ /* @__PURE__ */ jsx3("path", { d: "M1.5 8S3.9 3.5 8 3.5 14.5 8 14.5 8 12.1 12.5 8 12.5 1.5 8 1.5 8z" }),
158
+ /* @__PURE__ */ jsx3("circle", { cx: "8", cy: "8", r: "2" })
159
+ ] }));
160
+ var IconInfo = icon("IconInfo", /* @__PURE__ */ jsxs2(Fragment2, { children: [
161
+ /* @__PURE__ */ jsx3("circle", { cx: "8", cy: "8", r: "6.25" }),
162
+ /* @__PURE__ */ jsx3("path", { d: "M8 7.25v4M8 4.75v.25" })
163
+ ] }));
164
+ var IconCheckCircle = icon("IconCheckCircle", /* @__PURE__ */ jsxs2(Fragment2, { children: [
165
+ /* @__PURE__ */ jsx3("circle", { cx: "8", cy: "8", r: "6.25" }),
166
+ /* @__PURE__ */ jsx3("path", { d: "m5.5 8.25 1.75 1.75 3.25-3.5" })
167
+ ] }));
168
+ var IconWarning = icon("IconWarning", /* @__PURE__ */ jsxs2(Fragment2, { children: [
169
+ /* @__PURE__ */ jsx3("path", { d: "M8 2 14.5 13.5h-13z" }),
170
+ /* @__PURE__ */ jsx3("path", { d: "M8 6.5v3.25M8 11.5v.25" })
171
+ ] }));
172
+ var IconError = icon("IconError", /* @__PURE__ */ jsxs2(Fragment2, { children: [
173
+ /* @__PURE__ */ jsx3("circle", { cx: "8", cy: "8", r: "6.25" }),
174
+ /* @__PURE__ */ jsx3("path", { d: "M8 4.75v3.75M8 10.75v.5" })
175
+ ] }));
176
+ var IconFolder = icon("IconFolder", /* @__PURE__ */ jsx3("path", { d: "M2 4.5h4l1.5 1.5H14V13H2z" }));
177
+ var IconBell = icon("IconBell", /* @__PURE__ */ jsxs2(Fragment2, { children: [
178
+ /* @__PURE__ */ jsx3("path", { d: "M4 6.5a4 4 0 0 1 8 0c0 3.5 1.5 4.5 1.5 4.5h-11S4 10 4 6.5z" }),
179
+ /* @__PURE__ */ jsx3("path", { d: "M6.75 13.5a1.4 1.4 0 0 0 2.5 0" })
180
+ ] }));
181
+ var IconChart = icon("IconChart", /* @__PURE__ */ jsx3("path", { d: "M2 13V9M6 13V5M10 13V7M14 13V3" }));
182
+ var IconLock = icon("IconLock", /* @__PURE__ */ jsxs2(Fragment2, { children: [
183
+ /* @__PURE__ */ jsx3("rect", { x: "3", y: "7", width: "10", height: "7", rx: "1.5" }),
184
+ /* @__PURE__ */ jsx3("path", { d: "M5.5 7V5a2.5 2.5 0 0 1 5 0v2" })
185
+ ] }));
186
+ var IconGrid = icon("IconGrid", /* @__PURE__ */ jsxs2(Fragment2, { children: [
187
+ /* @__PURE__ */ jsx3("rect", { x: "2.5", y: "2.5", width: "4.5", height: "4.5", rx: "1" }),
188
+ /* @__PURE__ */ jsx3("rect", { x: "9", y: "2.5", width: "4.5", height: "4.5", rx: "1" }),
189
+ /* @__PURE__ */ jsx3("rect", { x: "2.5", y: "9", width: "4.5", height: "4.5", rx: "1" }),
190
+ /* @__PURE__ */ jsx3("rect", { x: "9", y: "9", width: "4.5", height: "4.5", rx: "1" })
191
+ ] }));
192
+ var IconList = icon("IconList", /* @__PURE__ */ jsx3("path", { d: "M2.5 4h11M2.5 8h11M2.5 12h11" }));
193
+ var IconCheck = icon("IconCheck", /* @__PURE__ */ jsx3("path", { d: "m3 8.5 3 3 7-7" }));
194
+
195
+ // src/Form.tsx
196
+ import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
197
+ var FieldContext = createContext(null);
198
+ function useFieldProps(props) {
199
+ const field = useContext(FieldContext);
200
+ const invalid = props.invalid ?? field?.invalid ?? false;
201
+ return {
202
+ id: props.id ?? field?.id,
203
+ "aria-describedby": props["aria-describedby"] ?? field?.describedBy,
204
+ "aria-invalid": props["aria-invalid"] ?? (invalid || void 0),
205
+ invalid
206
+ };
207
+ }
208
+ function Field({ label, optional, help, error, labelEnd, labelAsText, id, className, children, ...props }) {
209
+ const autoId = useId();
210
+ const controlId = id ?? autoId;
211
+ const messageId = `${controlId}-message`;
212
+ const message = error ?? help;
213
+ const labelEl = labelAsText ? /* @__PURE__ */ jsx4("span", { className: "fw-label", children: label }) : /* @__PURE__ */ jsxs3("label", { className: "fw-label", htmlFor: controlId, children: [
214
+ label,
215
+ optional && /* @__PURE__ */ jsx4("span", { className: "fw-opt", children: " (optional)" })
216
+ ] });
217
+ return /* @__PURE__ */ jsx4(FieldContext.Provider, { value: { id: controlId, describedBy: message ? messageId : void 0, invalid: Boolean(error) }, children: /* @__PURE__ */ jsxs3("div", { className: cx("fw-field", className), ...props, children: [
218
+ labelEnd ? /* @__PURE__ */ jsxs3("div", { style: { display: "flex", justifyContent: "space-between", gap: 8 }, children: [
219
+ labelEl,
220
+ labelEnd
221
+ ] }) : labelEl,
222
+ children,
223
+ error ? /* @__PURE__ */ jsx4("span", { className: "fw-field-error", id: messageId, children: error }) : help ? /* @__PURE__ */ jsx4("span", { className: "fw-help", id: messageId, children: help }) : null
224
+ ] }) });
225
+ }
226
+ var Input = forwardRef3(function Input2({ size = "md", invalid: _invalid, mono, className, ...props }, ref) {
227
+ const { invalid, ...field } = useFieldProps({ ...props, invalid: _invalid });
228
+ return /* @__PURE__ */ jsx4(
229
+ "input",
230
+ {
231
+ ref,
232
+ className: cx("fw-input", size === "sm" && "fw-input-sm", invalid && "is-error", mono && "is-mono", className),
233
+ ...props,
234
+ ...field
235
+ }
236
+ );
237
+ });
238
+ var Textarea = forwardRef3(function Textarea2({ invalid: _invalid, className, ...props }, ref) {
239
+ const { invalid, ...field } = useFieldProps({ ...props, invalid: _invalid });
240
+ return /* @__PURE__ */ jsx4("textarea", { ref, className: cx("fw-textarea", invalid && "is-error", className), ...props, ...field });
241
+ });
242
+ var Select = forwardRef3(function Select2({ invalid: _invalid, className, children, ...props }, ref) {
243
+ const { invalid, ...field } = useFieldProps({ ...props, invalid: _invalid });
244
+ return /* @__PURE__ */ jsxs3("span", { className: "fw-select-wrap", children: [
245
+ /* @__PURE__ */ jsx4("select", { ref, className: cx("fw-select", invalid && "is-error", className), ...props, ...field, children }),
246
+ /* @__PURE__ */ jsx4(IconChevronDown, {})
247
+ ] });
248
+ });
249
+ function InputGroup({ className, ...props }) {
250
+ return /* @__PURE__ */ jsx4("div", { className: cx("fw-input-affix", className), ...props });
251
+ }
252
+ function Affix({ boxed, end, className, ...props }) {
253
+ return /* @__PURE__ */ jsx4("span", { className: cx("fw-affix", boxed && "fw-affix-box", boxed && end && "fw-end", className), ...props });
254
+ }
255
+ function ChoiceLabel({ label, description, children, center, spread, style, className }) {
256
+ if (label === void 0) return /* @__PURE__ */ jsx4(Fragment3, { children });
257
+ const text = description ? /* @__PURE__ */ jsxs3("span", { children: [
258
+ label,
259
+ /* @__PURE__ */ jsx4("small", { children: description })
260
+ ] }) : label;
261
+ return /* @__PURE__ */ jsx4(
262
+ "label",
263
+ {
264
+ className: cx("fw-check", className),
265
+ style: { ...center && { alignItems: "center" }, ...spread && { justifyContent: "space-between", width: "100%" }, ...style },
266
+ children: spread ? /* @__PURE__ */ jsxs3(Fragment3, { children: [
267
+ text,
268
+ children
269
+ ] }) : /* @__PURE__ */ jsxs3(Fragment3, { children: [
270
+ children,
271
+ text
272
+ ] })
273
+ }
274
+ );
275
+ }
276
+ var Checkbox = forwardRef3(function Checkbox2({ label, description, indeterminate, className, style, ...props }, ref) {
277
+ const inner = useRef(null);
278
+ useImperativeHandle(ref, () => inner.current);
279
+ useEffect(() => {
280
+ if (inner.current) inner.current.indeterminate = Boolean(indeterminate);
281
+ }, [indeterminate]);
282
+ return /* @__PURE__ */ jsx4(ChoiceLabel, { label, description, className: label !== void 0 ? className : void 0, style: label !== void 0 ? style : void 0, children: /* @__PURE__ */ jsx4(
283
+ "input",
284
+ {
285
+ ref: inner,
286
+ type: "checkbox",
287
+ className: cx("fw-checkbox", indeterminate && "is-indeterminate", label === void 0 && className),
288
+ "aria-checked": indeterminate ? "mixed" : void 0,
289
+ style: label === void 0 ? style : void 0,
290
+ ...props
291
+ }
292
+ ) });
293
+ });
294
+ var Radio = forwardRef3(function Radio2({ label, description, className, style, ...props }, ref) {
295
+ return /* @__PURE__ */ jsx4(ChoiceLabel, { label, description, className: label !== void 0 ? className : void 0, style: label !== void 0 ? style : void 0, children: /* @__PURE__ */ jsx4("input", { ref, type: "radio", className: cx("fw-radio", label === void 0 && className), style: label === void 0 ? style : void 0, ...props }) });
296
+ });
297
+ var Switch = forwardRef3(function Switch2({ label, description, spread, className, style, ...props }, ref) {
298
+ return /* @__PURE__ */ jsx4(ChoiceLabel, { label, description, center: true, spread, className: label !== void 0 ? className : void 0, style: label !== void 0 ? style : void 0, children: /* @__PURE__ */ jsx4("input", { ref, type: "checkbox", role: "switch", className: cx("fw-switch", label === void 0 && className), style: label === void 0 ? style : void 0, ...props }) });
299
+ });
300
+ var Range = forwardRef3(function Range2({ className, style, min = 0, max = 100, value, defaultValue, onChange, ...props }, ref) {
301
+ const field = useFieldProps(props);
302
+ const inner = useRef(null);
303
+ useImperativeHandle(ref, () => inner.current);
304
+ const setFill = (el) => {
305
+ const lo = Number(el.min), hi = Number(el.max);
306
+ el.style.setProperty("--fw-fill", `${hi > lo ? (Number(el.value) - lo) / (hi - lo) * 100 : 0}%`);
307
+ };
308
+ useEffect(() => {
309
+ if (inner.current) setFill(inner.current);
310
+ }, [value, min, max]);
311
+ return /* @__PURE__ */ jsx4(
312
+ "input",
313
+ {
314
+ ref: inner,
315
+ type: "range",
316
+ className: cx("fw-range", className),
317
+ style,
318
+ min,
319
+ max,
320
+ value,
321
+ defaultValue,
322
+ onChange: (e) => {
323
+ setFill(e.currentTarget);
324
+ onChange?.(e);
325
+ },
326
+ ...props,
327
+ id: field.id,
328
+ "aria-describedby": field["aria-describedby"]
329
+ }
330
+ );
331
+ });
332
+ function Dropzone({ title, hint, onFiles, onChange, className, ...props }) {
333
+ const field = useFieldProps(props);
334
+ return /* @__PURE__ */ jsxs3(
335
+ "label",
336
+ {
337
+ className: cx("fw-dropzone", className),
338
+ style: { cursor: "pointer", position: "relative" },
339
+ onDragOver: (e) => e.preventDefault(),
340
+ onDrop: (e) => {
341
+ e.preventDefault();
342
+ if (e.dataTransfer.files.length) onFiles?.(e.dataTransfer.files);
343
+ },
344
+ children: [
345
+ /* @__PURE__ */ jsx4(IconUpload, {}),
346
+ /* @__PURE__ */ jsx4("span", { children: title ?? /* @__PURE__ */ jsxs3(Fragment3, { children: [
347
+ /* @__PURE__ */ jsx4("strong", { children: "Click to upload" }),
348
+ " or drag and drop"
349
+ ] }) }),
350
+ hint && /* @__PURE__ */ jsx4("span", { style: { fontFamily: "var(--fw-mono)", fontSize: 12 }, children: hint }),
351
+ /* @__PURE__ */ jsx4(
352
+ "input",
353
+ {
354
+ type: "file",
355
+ style: { position: "absolute", width: 1, height: 1, opacity: 0 },
356
+ onChange: (e) => {
357
+ if (e.currentTarget.files?.length) onFiles?.(e.currentTarget.files);
358
+ onChange?.(e);
359
+ },
360
+ ...props,
361
+ id: field.id,
362
+ "aria-describedby": field["aria-describedby"]
363
+ }
364
+ )
365
+ ]
366
+ }
367
+ );
368
+ }
369
+ function Fieldset({ legend, className, children, ...props }) {
370
+ return /* @__PURE__ */ jsxs3("fieldset", { className: cx("fw-fieldset", className), ...props, children: [
371
+ /* @__PURE__ */ jsx4("legend", { children: legend }),
372
+ children
373
+ ] });
374
+ }
375
+
376
+ // src/Feedback.tsx
377
+ import {
378
+ createContext as createContext2,
379
+ useCallback,
380
+ useContext as useContext2,
381
+ useEffect as useEffect2,
382
+ useMemo,
383
+ useRef as useRef2,
384
+ useState
385
+ } from "react";
386
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
387
+ var toneIcon = {
388
+ info: /* @__PURE__ */ jsx5(IconInfo, {}),
389
+ success: /* @__PURE__ */ jsx5(IconCheckCircle, {}),
390
+ warning: /* @__PURE__ */ jsx5(IconWarning, {}),
391
+ error: /* @__PURE__ */ jsx5(IconError, {}),
392
+ neutral: /* @__PURE__ */ jsx5(IconInfo, {})
393
+ };
394
+ function Alert({ tone = "info", title, icon: icon2, onDismiss, className, children, ...props }) {
395
+ return /* @__PURE__ */ jsxs4(
396
+ "div",
397
+ {
398
+ role: tone === "error" ? "alert" : "status",
399
+ className: cx("fw-alert", tone !== "info" && `fw-alert-${tone}`, className),
400
+ ...props,
401
+ children: [
402
+ icon2 === void 0 ? toneIcon[tone] : icon2,
403
+ /* @__PURE__ */ jsxs4("div", { className: "fw-alert-body", children: [
404
+ title && /* @__PURE__ */ jsx5("span", { className: "fw-alert-title", children: title }),
405
+ children && /* @__PURE__ */ jsx5("span", { className: "fw-alert-text", children })
406
+ ] }),
407
+ onDismiss && /* @__PURE__ */ jsx5(Button, { variant: "ghost", size: "sm", iconOnly: true, "aria-label": "Dismiss", onClick: onDismiss, style: { margin: "-6px -6px 0 0", color: "inherit" }, children: /* @__PURE__ */ jsx5(IconX, {}) })
408
+ ]
409
+ }
410
+ );
411
+ }
412
+ function Toast({ tone = "success", title, description, actions, onDismiss, className, ...props }) {
413
+ return /* @__PURE__ */ jsxs4("div", { role: tone === "error" ? "alert" : "status", className: cx("fw-toast", className), ...props, children: [
414
+ /* @__PURE__ */ jsx5("span", { style: { color: `var(--fw-${tone === "neutral" ? "muted" : tone})`, display: "contents" }, children: toneIcon[tone] }),
415
+ /* @__PURE__ */ jsxs4("div", { className: "fw-alert-body", children: [
416
+ /* @__PURE__ */ jsx5("span", { className: "fw-alert-title", children: title }),
417
+ description && /* @__PURE__ */ jsx5("span", { children: description }),
418
+ actions && /* @__PURE__ */ jsx5("div", { className: "fw-toast-actions", children: actions })
419
+ ] }),
420
+ onDismiss && /* @__PURE__ */ jsx5(Button, { variant: "ghost", size: "sm", iconOnly: true, "aria-label": "Dismiss", onClick: onDismiss, style: { margin: "-6px -8px 0 0" }, children: /* @__PURE__ */ jsx5(IconX, {}) })
421
+ ] });
422
+ }
423
+ var ToastContext = createContext2(null);
424
+ function ToastProvider({ children }) {
425
+ const [toasts, setToasts] = useState([]);
426
+ const timers = useRef2(/* @__PURE__ */ new Map());
427
+ const dismiss = useCallback((id) => {
428
+ clearTimeout(timers.current.get(id));
429
+ timers.current.delete(id);
430
+ setToasts((list) => list.filter((t) => t.id !== id));
431
+ }, []);
432
+ const show = useCallback(
433
+ (toast) => {
434
+ const id = Math.random().toString(36).slice(2);
435
+ setToasts((list) => [...list, { ...toast, id }]);
436
+ const duration = toast.duration ?? (toast.tone === "error" ? Infinity : 5e3);
437
+ if (Number.isFinite(duration)) timers.current.set(id, setTimeout(() => dismiss(id), duration));
438
+ return id;
439
+ },
440
+ [dismiss]
441
+ );
442
+ useEffect2(() => () => timers.current.forEach(clearTimeout), []);
443
+ const api = useMemo(() => ({ show, dismiss }), [show, dismiss]);
444
+ return /* @__PURE__ */ jsxs4(ToastContext.Provider, { value: api, children: [
445
+ children,
446
+ /* @__PURE__ */ jsx5("div", { className: "fw-toaster", "aria-live": "polite", children: toasts.map(({ id, duration: _duration, ...toast }) => /* @__PURE__ */ jsx5(Toast, { ...toast, onDismiss: () => dismiss(id) }, id)) })
447
+ ] });
448
+ }
449
+ function useToast() {
450
+ const api = useContext2(ToastContext);
451
+ if (!api) throw new Error("useToast must be used inside <ToastProvider>");
452
+ return api;
453
+ }
454
+ function Badge({ tone = "neutral", dot, count, className, children, ...props }) {
455
+ return /* @__PURE__ */ jsxs4("span", { className: cx("fw-badge", tone !== "neutral" && `fw-badge-${tone}`, count && "fw-badge-count", className), ...props, children: [
456
+ dot && /* @__PURE__ */ jsx5("span", { className: "fw-dot" }),
457
+ children
458
+ ] });
459
+ }
460
+ function Tag({ onRemove, removeLabel, className, children, ...props }) {
461
+ return /* @__PURE__ */ jsxs4("span", { className: cx("fw-tag", className), ...props, children: [
462
+ children,
463
+ onRemove && /* @__PURE__ */ jsx5("button", { type: "button", "aria-label": removeLabel ?? (typeof children === "string" ? `Remove ${children}` : "Remove"), onClick: onRemove, children: /* @__PURE__ */ jsx5(IconX, {}) })
464
+ ] });
465
+ }
466
+ function Progress({ value, max = 100, tone = "accent", meter, className, ...props }) {
467
+ const indeterminate = value === void 0;
468
+ const pct = indeterminate ? void 0 : Math.max(0, Math.min(100, value / max * 100));
469
+ return /* @__PURE__ */ jsx5(
470
+ "div",
471
+ {
472
+ role: meter ? "meter" : "progressbar",
473
+ "aria-valuenow": value,
474
+ "aria-valuemin": indeterminate ? void 0 : 0,
475
+ "aria-valuemax": indeterminate ? void 0 : max,
476
+ className: cx("fw-progress", indeterminate && "fw-progress-indeterminate", tone !== "accent" && `is-${tone}`, className),
477
+ ...props,
478
+ children: /* @__PURE__ */ jsx5("span", { style: pct === void 0 ? void 0 : { width: `${pct}%` } })
479
+ }
480
+ );
481
+ }
482
+ function Skeleton({ width, height = 12, circle, className, style, ...props }) {
483
+ return /* @__PURE__ */ jsx5(
484
+ "span",
485
+ {
486
+ "aria-hidden": "true",
487
+ className: cx("fw-skeleton", className),
488
+ style: { display: "block", width, height, ...circle && { borderRadius: "50%" }, ...style },
489
+ ...props
490
+ }
491
+ );
492
+ }
493
+ function EmptyState({ icon: icon2, title, description, action, className, ...props }) {
494
+ return /* @__PURE__ */ jsxs4("div", { className: cx("fw-empty", className), ...props, children: [
495
+ icon2 && /* @__PURE__ */ jsx5("span", { className: "fw-empty-icon", children: icon2 }),
496
+ /* @__PURE__ */ jsx5("span", { className: "fw-t-heading", children: title }),
497
+ description && /* @__PURE__ */ jsx5("span", { className: "fw-t-caption", style: { maxWidth: 260 }, children: description }),
498
+ action && /* @__PURE__ */ jsx5("div", { style: { marginTop: 8 }, children: action })
499
+ ] });
500
+ }
501
+
502
+ // src/Menu.tsx
503
+ import { forwardRef as forwardRef4 } from "react";
504
+ import { Fragment as Fragment4, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
505
+ var Menu = forwardRef4(function Menu2({ className, role = "menu", ...props }, ref) {
506
+ return /* @__PURE__ */ jsx6("ul", { ref, role, className: cx("fw-menu", className), ...props });
507
+ });
508
+ function MenuLabel({ className, ...props }) {
509
+ return /* @__PURE__ */ jsx6("li", { role: "presentation", className: cx("fw-menu-label", className), ...props });
510
+ }
511
+ function MenuSeparator({ className, ...props }) {
512
+ return /* @__PURE__ */ jsx6("li", { role: "separator", className: cx("fw-menu-sep", className), ...props });
513
+ }
514
+ function MenuItem({ icon: icon2, shortcut, danger, selected, disabled, as = "button", className, children, ...props }) {
515
+ const classes = cx("fw-menu-item", danger && "is-danger", selected && "is-selected", className);
516
+ const inner = /* @__PURE__ */ jsxs5(Fragment4, { children: [
517
+ icon2,
518
+ children,
519
+ shortcut ? /* @__PURE__ */ jsx6("span", { className: "fw-end", children: shortcut }) : selected ? /* @__PURE__ */ jsx6(IconCheck, { style: { marginLeft: "auto", color: "var(--fw-accent)" } }) : null
520
+ ] });
521
+ if (as === "li") {
522
+ return /* @__PURE__ */ jsx6("li", { className: classes, "aria-disabled": disabled || void 0, ...props, children: inner });
523
+ }
524
+ return /* @__PURE__ */ jsx6("li", { role: "none", children: /* @__PURE__ */ jsx6("button", { type: "button", role: "menuitem", className: classes, disabled, ...props, children: inner }) });
525
+ }
526
+
527
+ // src/Overlay.tsx
528
+ import {
529
+ cloneElement,
530
+ useEffect as useEffect3,
531
+ useId as useId2,
532
+ useMemo as useMemo2,
533
+ useRef as useRef3,
534
+ useState as useState2
535
+ } from "react";
536
+ import { Fragment as Fragment5, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
537
+ function useDismiss(ref, active, onOutside) {
538
+ useEffect3(() => {
539
+ if (!active) return;
540
+ const onPointer = (e) => {
541
+ if (ref.current && !ref.current.contains(e.target)) onOutside();
542
+ };
543
+ const onKey = (e) => {
544
+ if (e.key === "Escape") onOutside();
545
+ };
546
+ document.addEventListener("pointerdown", onPointer);
547
+ document.addEventListener("keydown", onKey);
548
+ return () => {
549
+ document.removeEventListener("pointerdown", onPointer);
550
+ document.removeEventListener("keydown", onKey);
551
+ };
552
+ }, [ref, active, onOutside]);
553
+ }
554
+ function Tooltip({ content: content2, shortcut, children, delay = 500 }) {
555
+ const [open, setOpen] = useState2(false);
556
+ const timer = useRef3(void 0);
557
+ const id = useId2();
558
+ const show = (wait) => {
559
+ clearTimeout(timer.current);
560
+ if (wait <= 0) setOpen(true);
561
+ else timer.current = setTimeout(() => setOpen(true), wait);
562
+ };
563
+ const hide = () => {
564
+ clearTimeout(timer.current);
565
+ setOpen(false);
566
+ };
567
+ useEffect3(() => () => clearTimeout(timer.current), []);
568
+ return /* @__PURE__ */ jsxs6(
569
+ "span",
570
+ {
571
+ className: "fw-anchor",
572
+ onPointerEnter: () => show(delay),
573
+ onPointerLeave: hide,
574
+ onFocus: () => show(0),
575
+ onBlur: hide,
576
+ onKeyDown: (e) => e.key === "Escape" && hide(),
577
+ children: [
578
+ cloneElement(children, { "aria-describedby": open ? id : void 0 }),
579
+ open && /* @__PURE__ */ jsxs6("span", { className: "fw-tooltip", role: "tooltip", id, children: [
580
+ content2,
581
+ shortcut && /* @__PURE__ */ jsx7("kbd", { children: shortcut })
582
+ ] })
583
+ ]
584
+ }
585
+ );
586
+ }
587
+ function Popover({ trigger, children, open: controlled, defaultOpen = false, onOpenChange, alignEnd, label, className, ...props }) {
588
+ const [uncontrolled, setUncontrolled] = useState2(defaultOpen);
589
+ const open = controlled ?? uncontrolled;
590
+ const setOpen = (next) => {
591
+ setUncontrolled(next);
592
+ onOpenChange?.(next);
593
+ };
594
+ const ref = useRef3(null);
595
+ const id = useId2();
596
+ useDismiss(ref, open, () => setOpen(false));
597
+ return /* @__PURE__ */ jsxs6("span", { className: "fw-anchor", ref, children: [
598
+ cloneElement(trigger, {
599
+ "aria-expanded": open,
600
+ "aria-haspopup": "dialog",
601
+ "aria-controls": open ? id : void 0,
602
+ onClick: () => setOpen(!open)
603
+ }),
604
+ open && /* @__PURE__ */ jsx7("div", { id, role: "dialog", "aria-label": label, className: cx("fw-popover", alignEnd && "is-end", className), ...props, children })
605
+ ] });
606
+ }
607
+ function DropdownMenu({ trigger, children, alignEnd, label }) {
608
+ const [open, setOpen] = useState2(false);
609
+ const ref = useRef3(null);
610
+ const menuRef = useRef3(null);
611
+ const id = useId2();
612
+ useDismiss(ref, open, () => setOpen(false));
613
+ useEffect3(() => {
614
+ if (open) menuRef.current?.querySelector('[role="menuitem"]:not(:disabled)')?.focus();
615
+ }, [open]);
616
+ const onKeyDown = (e) => {
617
+ const items = [...menuRef.current?.querySelectorAll('[role="menuitem"]:not(:disabled)') ?? []];
618
+ const i = items.indexOf(document.activeElement);
619
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
620
+ e.preventDefault();
621
+ items[(i + (e.key === "ArrowDown" ? 1 : -1) + items.length) % items.length]?.focus();
622
+ } else if (e.key === "Home" || e.key === "End") {
623
+ e.preventDefault();
624
+ items[e.key === "Home" ? 0 : items.length - 1]?.focus();
625
+ }
626
+ };
627
+ return /* @__PURE__ */ jsxs6("span", { className: "fw-anchor", ref, children: [
628
+ cloneElement(trigger, {
629
+ "aria-expanded": open,
630
+ "aria-haspopup": "menu",
631
+ "aria-controls": open ? id : void 0,
632
+ onClick: () => setOpen(!open)
633
+ }),
634
+ open && /* @__PURE__ */ jsx7(
635
+ Menu,
636
+ {
637
+ ref: menuRef,
638
+ id,
639
+ "aria-label": label,
640
+ className: alignEnd ? "is-end" : void 0,
641
+ onKeyDown,
642
+ onClick: (e) => e.target.closest('[role="menuitem"]') && setOpen(false),
643
+ children
644
+ }
645
+ )
646
+ ] });
647
+ }
648
+ function useModal(open, onClose) {
649
+ const ref = useRef3(null);
650
+ useEffect3(() => {
651
+ const dialog = ref.current;
652
+ if (!dialog) return;
653
+ if (open && !dialog.open) dialog.showModal();
654
+ if (!open && dialog.open) dialog.close();
655
+ }, [open]);
656
+ const props = {
657
+ ref,
658
+ onCancel: (e) => {
659
+ e.preventDefault();
660
+ onClose();
661
+ },
662
+ onClick: (e) => {
663
+ if (e.target === e.currentTarget) onClose();
664
+ }
665
+ };
666
+ return props;
667
+ }
668
+ function DialogHead({ titleId, title, subtitle, onClose, hideClose, divided }) {
669
+ return /* @__PURE__ */ jsxs6("div", { className: "fw-dialog-head", style: divided ? { paddingBottom: 16, borderBottom: "1px solid var(--fw-border)" } : void 0, children: [
670
+ /* @__PURE__ */ jsxs6("div", { children: [
671
+ /* @__PURE__ */ jsx7("h3", { className: "fw-dialog-title", id: titleId, children: title }),
672
+ subtitle && /* @__PURE__ */ jsx7("p", { className: "fw-card-sub", children: subtitle })
673
+ ] }),
674
+ !hideClose && /* @__PURE__ */ jsx7(Button, { variant: "ghost", size: "sm", iconOnly: true, "aria-label": "Close", onClick: onClose, style: { margin: "-6px -10px 0 0" }, children: /* @__PURE__ */ jsx7(IconX, {}) })
675
+ ] });
676
+ }
677
+ function Dialog({ open, onClose, title, subtitle, footer, alert, hideClose, className, children, ...props }) {
678
+ const modal = useModal(open, onClose);
679
+ const titleId = useId2();
680
+ return /* @__PURE__ */ jsx7("dialog", { ...modal, role: alert ? "alertdialog" : void 0, "aria-labelledby": titleId, className: cx("fw-dialog", className), ...props, children: open && /* @__PURE__ */ jsxs6(Fragment5, { children: [
681
+ /* @__PURE__ */ jsx7(DialogHead, { titleId, title, subtitle, onClose, hideClose }),
682
+ /* @__PURE__ */ jsx7("div", { className: "fw-dialog-body", children }),
683
+ footer && /* @__PURE__ */ jsx7("div", { className: "fw-dialog-foot", children: footer })
684
+ ] }) });
685
+ }
686
+ function Drawer({ open, onClose, title, subtitle, footer, hideClose, className, children, ...props }) {
687
+ const modal = useModal(open, onClose);
688
+ const titleId = useId2();
689
+ return /* @__PURE__ */ jsx7("dialog", { ...modal, "aria-labelledby": titleId, className: cx("fw-drawer", className), ...props, children: open && /* @__PURE__ */ jsxs6(Fragment5, { children: [
690
+ /* @__PURE__ */ jsx7(DialogHead, { titleId, title, subtitle, onClose, hideClose, divided: true }),
691
+ /* @__PURE__ */ jsx7("div", { className: "fw-dialog-body", style: { paddingTop: 20 }, children }),
692
+ footer && /* @__PURE__ */ jsx7("div", { className: "fw-dialog-foot", children: footer })
693
+ ] }) });
694
+ }
695
+ function CommandPalette({ open, onClose, commands, placeholder = "Search commands", onOpenShortcut }) {
696
+ const modal = useModal(open, onClose);
697
+ const [query, setQuery] = useState2("");
698
+ const [active, setActive] = useState2(0);
699
+ const listId = useId2();
700
+ useEffect3(() => {
701
+ if (!onOpenShortcut) return;
702
+ const onKey = (e) => {
703
+ if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "k") {
704
+ e.preventDefault();
705
+ onOpenShortcut();
706
+ }
707
+ };
708
+ document.addEventListener("keydown", onKey);
709
+ return () => document.removeEventListener("keydown", onKey);
710
+ }, [onOpenShortcut]);
711
+ useEffect3(() => {
712
+ if (open) {
713
+ setQuery("");
714
+ setActive(0);
715
+ }
716
+ }, [open]);
717
+ const results = useMemo2(() => {
718
+ const q = query.trim().toLowerCase();
719
+ return q ? commands.filter((c) => [c.label, c.group ?? "", ...c.keywords ?? []].some((s) => s.toLowerCase().includes(q))) : commands;
720
+ }, [commands, query]);
721
+ const run = (c) => {
722
+ if (!c) return;
723
+ onClose();
724
+ c.onSelect();
725
+ };
726
+ const onKeyDown = (e) => {
727
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
728
+ e.preventDefault();
729
+ if (results.length) setActive((i) => (i + (e.key === "ArrowDown" ? 1 : -1) + results.length) % results.length);
730
+ } else if (e.key === "Enter") {
731
+ e.preventDefault();
732
+ run(results[active]);
733
+ }
734
+ };
735
+ let lastGroup;
736
+ return /* @__PURE__ */ jsx7("dialog", { ...modal, "aria-label": "Command palette", className: "fw-command", children: open && /* @__PURE__ */ jsxs6(Fragment5, { children: [
737
+ /* @__PURE__ */ jsxs6("div", { className: "fw-command-input", children: [
738
+ /* @__PURE__ */ jsx7(IconSearch, {}),
739
+ /* @__PURE__ */ jsx7(
740
+ "input",
741
+ {
742
+ autoFocus: true,
743
+ role: "combobox",
744
+ "aria-expanded": "true",
745
+ "aria-controls": listId,
746
+ "aria-activedescendant": results[active] ? `${listId}-${results[active].id}` : void 0,
747
+ "aria-label": placeholder,
748
+ placeholder,
749
+ value: query,
750
+ onChange: (e) => {
751
+ setQuery(e.target.value);
752
+ setActive(0);
753
+ },
754
+ onKeyDown
755
+ }
756
+ ),
757
+ /* @__PURE__ */ jsx7("kbd", { children: "Esc" })
758
+ ] }),
759
+ /* @__PURE__ */ jsxs6(Menu, { id: listId, role: "listbox", children: [
760
+ results.length === 0 && /* @__PURE__ */ jsx7(MenuLabel, { children: "No results" }),
761
+ results.map((c, i) => {
762
+ const header = c.group && c.group !== lastGroup ? /* @__PURE__ */ jsx7(MenuLabel, { children: c.group }, `g-${c.group}`) : null;
763
+ lastGroup = c.group;
764
+ return [
765
+ header,
766
+ /* @__PURE__ */ jsx7(
767
+ MenuItem,
768
+ {
769
+ as: "li",
770
+ id: `${listId}-${c.id}`,
771
+ role: "option",
772
+ "aria-selected": i === active,
773
+ className: i === active ? "is-hover" : void 0,
774
+ icon: c.icon,
775
+ shortcut: c.shortcut ?? (i === active ? "\u21B5" : void 0),
776
+ onPointerMove: () => setActive(i),
777
+ onClick: () => run(c),
778
+ children: c.label
779
+ },
780
+ c.id
781
+ )
782
+ ];
783
+ })
784
+ ] }),
785
+ /* @__PURE__ */ jsxs6("div", { className: "fw-command-foot", children: [
786
+ /* @__PURE__ */ jsxs6("span", { children: [
787
+ /* @__PURE__ */ jsx7("kbd", { children: "\u2191" }),
788
+ /* @__PURE__ */ jsx7("kbd", { children: "\u2193" }),
789
+ "navigate"
790
+ ] }),
791
+ /* @__PURE__ */ jsxs6("span", { children: [
792
+ /* @__PURE__ */ jsx7("kbd", { children: "\u21B5" }),
793
+ "select"
794
+ ] }),
795
+ /* @__PURE__ */ jsxs6("span", { children: [
796
+ /* @__PURE__ */ jsx7("kbd", { children: "Esc" }),
797
+ "close"
798
+ ] })
799
+ ] })
800
+ ] }) });
801
+ }
802
+
803
+ // src/Navigation.tsx
804
+ import {
805
+ createContext as createContext3,
806
+ Fragment as Fragment6,
807
+ useContext as useContext3,
808
+ useId as useId3,
809
+ useState as useState3
810
+ } from "react";
811
+ import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
812
+ function rovingKeys(selector, orientation = "horizontal") {
813
+ return (e) => {
814
+ const [prev, next] = orientation === "horizontal" ? ["ArrowLeft", "ArrowRight"] : ["ArrowUp", "ArrowDown"];
815
+ if (![prev, next, "Home", "End"].includes(e.key)) return;
816
+ const items = [...e.currentTarget.querySelectorAll(selector)].filter((el) => !el.hasAttribute("disabled"));
817
+ const i = items.indexOf(document.activeElement);
818
+ const target = e.key === "Home" ? 0 : e.key === "End" ? items.length - 1 : (i + (e.key === next ? 1 : -1) + items.length) % items.length;
819
+ e.preventDefault();
820
+ items[target]?.focus();
821
+ items[target]?.click();
822
+ };
823
+ }
824
+ function TopNav({ brand, end, navLabel = "Primary", className, children, ...props }) {
825
+ return /* @__PURE__ */ jsxs7("header", { className: cx("fw-topnav", className), ...props, children: [
826
+ brand,
827
+ children && /* @__PURE__ */ jsx8("nav", { "aria-label": navLabel, children }),
828
+ end && /* @__PURE__ */ jsx8("div", { className: "fw-end", children: end })
829
+ ] });
830
+ }
831
+ function Brand({ mark, className, children, style, ...props }) {
832
+ return /* @__PURE__ */ jsxs7("a", { className: cx("fw-brand", className), style: { textDecoration: "none", ...style }, ...props, children: [
833
+ mark && /* @__PURE__ */ jsx8("span", { className: "fw-logo-mark", "aria-hidden": "true", children: mark }),
834
+ children
835
+ ] });
836
+ }
837
+ function SideNav({ className, ...props }) {
838
+ return /* @__PURE__ */ jsx8("nav", { className: cx("fw-sidenav", className), ...props });
839
+ }
840
+ function NavGroupLabel({ className, ...props }) {
841
+ return /* @__PURE__ */ jsx8("span", { className: cx("fw-group-label", className), ...props });
842
+ }
843
+ function NavItem({ icon: icon2, badge, current, as, className, children, ...props }) {
844
+ const Tag2 = as ?? "a";
845
+ return /* @__PURE__ */ jsxs7(Tag2, { className: cx("fw-nav-item", className), "aria-current": current ? "page" : void 0, ...props, children: [
846
+ icon2,
847
+ children,
848
+ badge
849
+ ] });
850
+ }
851
+ var TabsContext = createContext3(null);
852
+ function useTabs() {
853
+ const ctx = useContext3(TabsContext);
854
+ if (!ctx) throw new Error("Tab components must be used inside <Tabs>");
855
+ return ctx;
856
+ }
857
+ function Tabs({ value: controlled, defaultValue = "", onValueChange, children }) {
858
+ const [uncontrolled, setUncontrolled] = useState3(defaultValue);
859
+ const baseId = useId3();
860
+ const value = controlled ?? uncontrolled;
861
+ const setValue = (v) => {
862
+ setUncontrolled(v);
863
+ onValueChange?.(v);
864
+ };
865
+ return /* @__PURE__ */ jsx8(TabsContext.Provider, { value: { value, setValue, baseId }, children });
866
+ }
867
+ function TabList({ className, ...props }) {
868
+ return /* @__PURE__ */ jsx8("div", { role: "tablist", className: cx("fw-tabs", className), onKeyDown: rovingKeys('[role="tab"]'), ...props });
869
+ }
870
+ function Tab({ value, badge, className, children, ...props }) {
871
+ const tabs = useTabs();
872
+ const selected = tabs.value === value;
873
+ return /* @__PURE__ */ jsxs7(
874
+ "button",
875
+ {
876
+ type: "button",
877
+ role: "tab",
878
+ id: `${tabs.baseId}-tab-${value}`,
879
+ "aria-selected": selected,
880
+ "aria-controls": `${tabs.baseId}-panel-${value}`,
881
+ tabIndex: selected ? 0 : -1,
882
+ className: cx("fw-tab", selected && "is-active", className),
883
+ onClick: () => tabs.setValue(value),
884
+ ...props,
885
+ children: [
886
+ children,
887
+ badge
888
+ ]
889
+ }
890
+ );
891
+ }
892
+ function TabPanel({ value, ...props }) {
893
+ const tabs = useTabs();
894
+ if (tabs.value !== value) return null;
895
+ return /* @__PURE__ */ jsx8("div", { role: "tabpanel", id: `${tabs.baseId}-panel-${value}`, "aria-labelledby": `${tabs.baseId}-tab-${value}`, tabIndex: 0, ...props });
896
+ }
897
+ function SegmentedControl({ options, value: controlled, defaultValue, onValueChange, label, className, ...props }) {
898
+ const [uncontrolled, setUncontrolled] = useState3(defaultValue ?? options[0]?.value);
899
+ const value = controlled ?? uncontrolled;
900
+ return /* @__PURE__ */ jsx8("div", { role: "radiogroup", "aria-label": label, className: cx("fw-segmented", className), onKeyDown: rovingKeys('[role="radio"]'), ...props, children: options.map((o) => /* @__PURE__ */ jsxs7(
901
+ "button",
902
+ {
903
+ type: "button",
904
+ role: "radio",
905
+ "aria-checked": o.value === value,
906
+ "aria-label": o.ariaLabel,
907
+ tabIndex: o.value === value ? 0 : -1,
908
+ className: cx("fw-seg", o.value === value && "is-active"),
909
+ onClick: () => {
910
+ setUncontrolled(o.value);
911
+ onValueChange?.(o.value);
912
+ },
913
+ children: [
914
+ o.icon,
915
+ o.label
916
+ ]
917
+ },
918
+ o.value
919
+ )) });
920
+ }
921
+ function Breadcrumb({ items, renderLink, className, ...props }) {
922
+ return /* @__PURE__ */ jsx8("nav", { "aria-label": "Breadcrumb", className, ...props, children: /* @__PURE__ */ jsx8("ol", { className: "fw-breadcrumb", children: items.map((c, i) => {
923
+ const last = i === items.length - 1;
924
+ return /* @__PURE__ */ jsxs7(Fragment6, { children: [
925
+ /* @__PURE__ */ jsx8("li", { children: last ? /* @__PURE__ */ jsx8("span", { "aria-current": "page", children: c.label }) : renderLink ? renderLink(c) : /* @__PURE__ */ jsx8("a", { href: c.href, children: c.label }) }),
926
+ !last && /* @__PURE__ */ jsx8("li", { "aria-hidden": "true", children: /* @__PURE__ */ jsx8(IconChevronRight, { className: "fw-sep" }) })
927
+ ] }, i);
928
+ }) }) });
929
+ }
930
+ function pageRange(page, count) {
931
+ const pages = new Set([1, count, page - 1, page, page + 1].filter((p) => p >= 1 && p <= count));
932
+ const sorted = [...pages].sort((a, b) => a - b);
933
+ const out = [];
934
+ sorted.forEach((p, i) => {
935
+ if (i > 0 && p - sorted[i - 1] > 1) out.push("gap");
936
+ out.push(p);
937
+ });
938
+ return out;
939
+ }
940
+ function Pagination({ page, count, onPageChange, className, ...props }) {
941
+ return /* @__PURE__ */ jsx8("nav", { "aria-label": "Pagination", className, ...props, children: /* @__PURE__ */ jsxs7("ul", { className: "fw-pagination", children: [
942
+ /* @__PURE__ */ jsx8("li", { children: /* @__PURE__ */ jsx8("button", { className: "fw-page", type: "button", "aria-label": "Previous page", disabled: page <= 1, onClick: () => onPageChange(page - 1), children: /* @__PURE__ */ jsx8(IconChevronLeft, {}) }) }),
943
+ pageRange(page, count).map(
944
+ (p, i) => p === "gap" ? /* @__PURE__ */ jsx8("li", { children: /* @__PURE__ */ jsx8("span", { className: "fw-page", "aria-hidden": "true", style: { cursor: "default" }, children: "\u2026" }) }, `gap-${i}`) : /* @__PURE__ */ jsx8("li", { children: /* @__PURE__ */ jsx8(
945
+ "button",
946
+ {
947
+ type: "button",
948
+ className: cx("fw-page", p === page && "is-active"),
949
+ "aria-current": p === page ? "page" : void 0,
950
+ onClick: () => onPageChange(p),
951
+ children: p
952
+ }
953
+ ) }, p)
954
+ ),
955
+ /* @__PURE__ */ jsx8("li", { children: /* @__PURE__ */ jsx8("button", { className: "fw-page", type: "button", "aria-label": "Next page", disabled: page >= count, onClick: () => onPageChange(page + 1), children: /* @__PURE__ */ jsx8(IconChevronRight, {}) }) })
956
+ ] }) });
957
+ }
958
+ function Stepper({ steps, current, className, ...props }) {
959
+ return /* @__PURE__ */ jsx8("ol", { className: cx("fw-stepper", className), ...props, children: steps.map((label, i) => /* @__PURE__ */ jsxs7(Fragment6, { children: [
960
+ i > 0 && /* @__PURE__ */ jsx8("li", { className: "fw-step-line", "aria-hidden": "true" }),
961
+ /* @__PURE__ */ jsxs7("li", { className: cx("fw-step", i < current && "is-done", i === current && "is-active"), "aria-current": i === current ? "step" : void 0, children: [
962
+ /* @__PURE__ */ jsx8("span", { className: "fw-step-n", children: i < current ? /* @__PURE__ */ jsx8(IconCheck, {}) : i + 1 }),
963
+ label
964
+ ] })
965
+ ] }, i)) });
966
+ }
967
+
968
+ // src/Data.tsx
969
+ import { Fragment as Fragment7 } from "react";
970
+ import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
971
+ function Card({ className, ...props }) {
972
+ return /* @__PURE__ */ jsx9("div", { className: cx("fw-card", className), ...props });
973
+ }
974
+ function CardHeader({ title, subtitle, action, className, children, ...props }) {
975
+ return /* @__PURE__ */ jsxs8("div", { className: cx("fw-card-head", className), ...props, children: [
976
+ children ?? /* @__PURE__ */ jsxs8("div", { children: [
977
+ title && /* @__PURE__ */ jsx9("h3", { className: "fw-card-title", children: title }),
978
+ subtitle && /* @__PURE__ */ jsx9("p", { className: "fw-card-sub", children: subtitle })
979
+ ] }),
980
+ action
981
+ ] });
982
+ }
983
+ function CardBody({ className, ...props }) {
984
+ return /* @__PURE__ */ jsx9("div", { className: cx("fw-card-body", className), ...props });
985
+ }
986
+ function CardFooter({ className, ...props }) {
987
+ return /* @__PURE__ */ jsx9("div", { className: cx("fw-card-foot", className), ...props });
988
+ }
989
+ function StatCard({ label, value, delta, caption, ...props }) {
990
+ return /* @__PURE__ */ jsxs8(Card, { ...props, children: [
991
+ /* @__PURE__ */ jsxs8(CardHeader, { children: [
992
+ /* @__PURE__ */ jsx9("span", { className: "fw-t-caption", children: label }),
993
+ delta
994
+ ] }),
995
+ /* @__PURE__ */ jsxs8(CardBody, { children: [
996
+ /* @__PURE__ */ jsx9("span", { className: "fw-stat-value", children: value }),
997
+ caption && /* @__PURE__ */ jsx9("span", { className: "fw-t-caption", children: caption })
998
+ ] })
999
+ ] });
1000
+ }
1001
+ function Table({ caption, footer, className, children, ...props }) {
1002
+ return /* @__PURE__ */ jsxs8("div", { className: "fw-table-wrap", children: [
1003
+ /* @__PURE__ */ jsxs8("table", { className: cx("fw-table", className), ...props, children: [
1004
+ caption && /* @__PURE__ */ jsx9("caption", { children: caption }),
1005
+ children
1006
+ ] }),
1007
+ footer && /* @__PURE__ */ jsx9("div", { className: "fw-table-foot", children: footer })
1008
+ ] });
1009
+ }
1010
+ function SortableHeader({ sort = "none", onSort, className, children, ...props }) {
1011
+ return /* @__PURE__ */ jsx9("th", { className: cx("fw-sortable", className), "aria-sort": sort, ...props, children: /* @__PURE__ */ jsxs8("button", { type: "button", onClick: onSort, style: { background: "none", border: 0, padding: 0, font: "inherit", color: "inherit", cursor: "pointer" }, children: [
1012
+ children,
1013
+ sort === "descending" ? /* @__PURE__ */ jsx9(IconChevronDown, {}) : /* @__PURE__ */ jsx9(IconChevronUp, { style: sort === "none" ? { opacity: 0.4 } : void 0 })
1014
+ ] }) });
1015
+ }
1016
+ function List({ className, ...props }) {
1017
+ return /* @__PURE__ */ jsx9("ul", { className: cx("fw-list", className), ...props });
1018
+ }
1019
+ function ListItem({ leading, title, meta, trailing, ...props }) {
1020
+ return /* @__PURE__ */ jsxs8("li", { ...props, children: [
1021
+ leading,
1022
+ /* @__PURE__ */ jsxs8("span", { className: "fw-grow", children: [
1023
+ /* @__PURE__ */ jsx9("span", { className: "fw-title", children: title }),
1024
+ meta && /* @__PURE__ */ jsx9("span", { className: "fw-meta", children: meta })
1025
+ ] }),
1026
+ trailing
1027
+ ] });
1028
+ }
1029
+ function DescriptionList({ items, className, ...props }) {
1030
+ return /* @__PURE__ */ jsx9("dl", { className: cx("fw-dl", className), ...props, children: items.map((it, i) => /* @__PURE__ */ jsxs8(Fragment7, { children: [
1031
+ /* @__PURE__ */ jsx9("dt", { children: it.term }),
1032
+ /* @__PURE__ */ jsx9("dd", { className: it.mono ? "fw-mono" : void 0, children: it.value })
1033
+ ] }, i)) });
1034
+ }
1035
+ function Accordion({ className, ...props }) {
1036
+ return /* @__PURE__ */ jsx9("div", { className: cx("fw-accordion", className), ...props });
1037
+ }
1038
+ function AccordionItem({ title, children, ...props }) {
1039
+ return /* @__PURE__ */ jsxs8("details", { ...props, children: [
1040
+ /* @__PURE__ */ jsxs8("summary", { children: [
1041
+ title,
1042
+ /* @__PURE__ */ jsx9(IconChevronDown, {})
1043
+ ] }),
1044
+ /* @__PURE__ */ jsx9("div", { className: "fw-acc-body", children })
1045
+ ] });
1046
+ }
1047
+ function CodeBlock({ className, ...props }) {
1048
+ return /* @__PURE__ */ jsx9("pre", { className: cx("fw-code-block", className), ...props });
1049
+ }
1050
+ function Divider({ label }) {
1051
+ if (!label) return /* @__PURE__ */ jsx9("hr", {});
1052
+ const line = /* @__PURE__ */ jsx9("span", { style: { flex: 1, height: 1, background: "var(--fw-border)" } });
1053
+ return /* @__PURE__ */ jsxs8("div", { role: "separator", style: { display: "flex", alignItems: "center", gap: 12, color: "var(--fw-muted)", fontSize: 12 }, children: [
1054
+ line,
1055
+ label,
1056
+ line
1057
+ ] });
1058
+ }
1059
+ function Avatar({ size = "md", square, online, className, ...props }) {
1060
+ return /* @__PURE__ */ jsx9("span", { className: cx("fw-avatar", size !== "md" && `fw-avatar-${size}`, square && "fw-avatar-sq", online && "fw-presence", className), ...props });
1061
+ }
1062
+ function AvatarGroup({ className, ...props }) {
1063
+ return /* @__PURE__ */ jsx9("div", { className: cx("fw-avatar-group", className), ...props });
1064
+ }
1065
+ export {
1066
+ Accordion,
1067
+ AccordionItem,
1068
+ Affix,
1069
+ Alert,
1070
+ Avatar,
1071
+ AvatarGroup,
1072
+ Badge,
1073
+ Brand,
1074
+ Breadcrumb,
1075
+ Button,
1076
+ ButtonGroup,
1077
+ ButtonLink,
1078
+ Card,
1079
+ CardBody,
1080
+ CardFooter,
1081
+ CardHeader,
1082
+ Checkbox,
1083
+ CodeBlock,
1084
+ CommandPalette,
1085
+ DescriptionList,
1086
+ Dialog,
1087
+ Divider,
1088
+ Drawer,
1089
+ DropdownMenu,
1090
+ Dropzone,
1091
+ EmptyState,
1092
+ Field,
1093
+ Fieldset,
1094
+ FlatworkRoot,
1095
+ IconArrowRight,
1096
+ IconBell,
1097
+ IconChart,
1098
+ IconCheck,
1099
+ IconCheckCircle,
1100
+ IconChevronDown,
1101
+ IconChevronLeft,
1102
+ IconChevronRight,
1103
+ IconChevronUp,
1104
+ IconCopy,
1105
+ IconDownload,
1106
+ IconError,
1107
+ IconEye,
1108
+ IconFolder,
1109
+ IconGrid,
1110
+ IconHome,
1111
+ IconInfo,
1112
+ IconList,
1113
+ IconLock,
1114
+ IconMore,
1115
+ IconPencil,
1116
+ IconPlus,
1117
+ IconSearch,
1118
+ IconSettings,
1119
+ IconTrash,
1120
+ IconUpload,
1121
+ IconUser,
1122
+ IconWarning,
1123
+ IconX,
1124
+ Input,
1125
+ InputGroup,
1126
+ Kbd,
1127
+ List,
1128
+ ListItem,
1129
+ Menu,
1130
+ MenuItem,
1131
+ MenuLabel,
1132
+ MenuSeparator,
1133
+ NavGroupLabel,
1134
+ NavItem,
1135
+ Pagination,
1136
+ Popover,
1137
+ Progress,
1138
+ Radio,
1139
+ Range,
1140
+ SegmentedControl,
1141
+ Select,
1142
+ SideNav,
1143
+ Skeleton,
1144
+ SortableHeader,
1145
+ Spinner,
1146
+ StatCard,
1147
+ Stepper,
1148
+ Switch,
1149
+ Tab,
1150
+ TabList,
1151
+ TabPanel,
1152
+ Table,
1153
+ Tabs,
1154
+ Tag,
1155
+ Text,
1156
+ Textarea,
1157
+ Toast,
1158
+ ToastProvider,
1159
+ Tooltip,
1160
+ TopNav,
1161
+ VisuallyHidden,
1162
+ cx,
1163
+ pageRange,
1164
+ useToast
1165
+ };
1166
+ //# sourceMappingURL=index.js.map