@hxdhxd/harmony-flow-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 +187 -0
- package/dist/index.cjs +3361 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +6312 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.cts +1496 -0
- package/dist/index.d.ts +1496 -0
- package/dist/index.js +3200 -0
- package/dist/index.js.map +1 -0
- package/package.json +102 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,3361 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
Accordion: () => Accordion,
|
|
24
|
+
ActivityFeed: () => ActivityFeed,
|
|
25
|
+
ActivityIndicator: () => ActivityIndicator,
|
|
26
|
+
AgentRunTimeline: () => AgentRunTimeline,
|
|
27
|
+
Alert: () => Alert,
|
|
28
|
+
ApprovalFlow: () => ApprovalFlow,
|
|
29
|
+
AuditLog: () => AuditLog,
|
|
30
|
+
AuthLayout: () => AuthLayout,
|
|
31
|
+
AvailabilityGrid: () => AvailabilityGrid,
|
|
32
|
+
Avatar: () => Avatar,
|
|
33
|
+
AvatarGroup: () => AvatarGroup,
|
|
34
|
+
Badge: () => Badge,
|
|
35
|
+
Breadcrumb: () => Breadcrumb,
|
|
36
|
+
Button: () => Button,
|
|
37
|
+
ButtonGroup: () => ButtonGroup,
|
|
38
|
+
Calendar: () => Calendar,
|
|
39
|
+
Card: () => Card,
|
|
40
|
+
Cascader: () => Cascader,
|
|
41
|
+
ChartContainer: () => ChartContainer,
|
|
42
|
+
ChatComposer: () => ChatComposer,
|
|
43
|
+
ChatMessage: () => ChatMessage,
|
|
44
|
+
Checkbox: () => Checkbox,
|
|
45
|
+
CheckboxGroup: () => CheckboxGroup,
|
|
46
|
+
ChoiceGroup: () => ChoiceGroup,
|
|
47
|
+
CircularProgress: () => CircularProgress,
|
|
48
|
+
CitationList: () => CitationList,
|
|
49
|
+
CodeBlock: () => CodeBlock,
|
|
50
|
+
CodeEditor: () => CodeEditor,
|
|
51
|
+
ColorPicker: () => ColorPicker,
|
|
52
|
+
Combobox: () => Combobox,
|
|
53
|
+
CommandPalette: () => CommandPalette,
|
|
54
|
+
CommentThread: () => CommentThread,
|
|
55
|
+
Container: () => Container,
|
|
56
|
+
ContextMenu: () => ContextMenu,
|
|
57
|
+
ConversationBranch: () => ConversationBranch,
|
|
58
|
+
DataGrid: () => DataGrid,
|
|
59
|
+
DatePicker: () => DatePicker,
|
|
60
|
+
DateRangePicker: () => DateRangePicker,
|
|
61
|
+
Descriptions: () => Descriptions,
|
|
62
|
+
DiffViewer: () => DiffViewer,
|
|
63
|
+
Divider: () => Divider,
|
|
64
|
+
Drawer: () => Drawer,
|
|
65
|
+
Dropdown: () => Dropdown,
|
|
66
|
+
DropdownMenu: () => DropdownMenu,
|
|
67
|
+
EmptyState: () => EmptyState,
|
|
68
|
+
EventCard: () => EventCard,
|
|
69
|
+
FileExplorer: () => FileExplorer,
|
|
70
|
+
FilePreview: () => FilePreview,
|
|
71
|
+
FilterBuilder: () => FilterBuilder,
|
|
72
|
+
FloatingNav: () => FloatingNav,
|
|
73
|
+
FlowCanvas: () => FlowCanvas,
|
|
74
|
+
Form: () => Form,
|
|
75
|
+
FormItem: () => FormItem,
|
|
76
|
+
GanttChart: () => GanttChart,
|
|
77
|
+
Grid: () => Grid,
|
|
78
|
+
Hero: () => Hero,
|
|
79
|
+
Icon: () => Icon,
|
|
80
|
+
IconButton: () => IconButton,
|
|
81
|
+
Input: () => Input,
|
|
82
|
+
InsightBoard: () => InsightBoard,
|
|
83
|
+
JsonViewer: () => JsonViewer,
|
|
84
|
+
KanbanBoard: () => KanbanBoard,
|
|
85
|
+
Link: () => Link,
|
|
86
|
+
List: () => List,
|
|
87
|
+
LoadingDots: () => LoadingDots,
|
|
88
|
+
LoadingOverlay: () => LoadingOverlay,
|
|
89
|
+
MarkdownContent: () => MarkdownContent,
|
|
90
|
+
Masonry: () => Masonry,
|
|
91
|
+
MegaMenu: () => MegaMenu,
|
|
92
|
+
MemberPicker: () => MemberPicker,
|
|
93
|
+
MentionInput: () => MentionInput,
|
|
94
|
+
MobileNavigation: () => MobileNavigation,
|
|
95
|
+
Modal: () => Modal,
|
|
96
|
+
ModelSelector: () => ModelSelector,
|
|
97
|
+
MultiSelect: () => MultiSelect,
|
|
98
|
+
Notification: () => Notification,
|
|
99
|
+
NotificationCenter: () => NotificationCenter,
|
|
100
|
+
NumberInput: () => NumberInput,
|
|
101
|
+
PageLayout: () => PageLayout,
|
|
102
|
+
Pagination: () => Pagination,
|
|
103
|
+
PermissionMatrix: () => PermissionMatrix,
|
|
104
|
+
PivotTable: () => PivotTable,
|
|
105
|
+
Popconfirm: () => Popconfirm,
|
|
106
|
+
Popover: () => Popover,
|
|
107
|
+
Presence: () => Presence,
|
|
108
|
+
Progress: () => Progress,
|
|
109
|
+
ProgressBar: () => ProgressBar,
|
|
110
|
+
ProgressRing: () => ProgressRing,
|
|
111
|
+
PromptSuggestions: () => PromptSuggestions,
|
|
112
|
+
QueryBuilder: () => QueryBuilder,
|
|
113
|
+
Radio: () => Radio,
|
|
114
|
+
RadioGroup: () => RadioGroup,
|
|
115
|
+
RecurrenceEditor: () => RecurrenceEditor,
|
|
116
|
+
ResizablePanel: () => ResizablePanel,
|
|
117
|
+
ResourceCalendar: () => ResourceCalendar,
|
|
118
|
+
Result: () => Result,
|
|
119
|
+
RichTextEditor: () => RichTextEditor,
|
|
120
|
+
Scheduler: () => Scheduler,
|
|
121
|
+
Scrollspy: () => Scrollspy,
|
|
122
|
+
SearchInput: () => SearchInput,
|
|
123
|
+
SegmentedControl: () => SegmentedControl,
|
|
124
|
+
Select: () => Select,
|
|
125
|
+
SharePanel: () => SharePanel,
|
|
126
|
+
ShrinkNav: () => ShrinkNav,
|
|
127
|
+
Sidebar: () => Sidebar,
|
|
128
|
+
Skeleton: () => Skeleton,
|
|
129
|
+
Slider: () => Slider,
|
|
130
|
+
Sparkline: () => Sparkline,
|
|
131
|
+
Spinner: () => Spinner,
|
|
132
|
+
SplitButton: () => SplitButton,
|
|
133
|
+
Stack: () => Stack,
|
|
134
|
+
Stat: () => Stat,
|
|
135
|
+
StatisticCard: () => StatisticCard,
|
|
136
|
+
StepProgress: () => StepProgress,
|
|
137
|
+
Steps: () => Steps,
|
|
138
|
+
Switch: () => Switch,
|
|
139
|
+
Table: () => Table,
|
|
140
|
+
Tabs: () => Tabs,
|
|
141
|
+
Tag: () => Tag,
|
|
142
|
+
Textarea: () => Textarea,
|
|
143
|
+
ThemeProvider: () => ThemeProvider,
|
|
144
|
+
TimePicker: () => TimePicker,
|
|
145
|
+
Timeline: () => Timeline,
|
|
146
|
+
TimezoneSelect: () => TimezoneSelect,
|
|
147
|
+
Toast: () => Toast,
|
|
148
|
+
TokenUsage: () => TokenUsage,
|
|
149
|
+
ToolCallCard: () => ToolCallCard,
|
|
150
|
+
Tooltip: () => Tooltip,
|
|
151
|
+
Transfer: () => Transfer,
|
|
152
|
+
Tree: () => Tree,
|
|
153
|
+
TreeSelect: () => TreeSelect,
|
|
154
|
+
Typography: () => Typography,
|
|
155
|
+
Upload: () => Upload,
|
|
156
|
+
ValidatedInput: () => ValidatedInput,
|
|
157
|
+
VersionHistory: () => VersionHistory,
|
|
158
|
+
VirtualList: () => VirtualList,
|
|
159
|
+
VoiceInput: () => VoiceInput,
|
|
160
|
+
activateNavigationItem: () => activateNavigationItem,
|
|
161
|
+
darkTheme: () => darkTheme,
|
|
162
|
+
defaultTheme: () => defaultTheme,
|
|
163
|
+
highContrastTheme: () => highContrastTheme,
|
|
164
|
+
tokensToStyle: () => tokensToStyle,
|
|
165
|
+
validateForm: () => validateForm,
|
|
166
|
+
validateValue: () => validateValue
|
|
167
|
+
});
|
|
168
|
+
module.exports = __toCommonJS(index_exports);
|
|
169
|
+
|
|
170
|
+
// src/theme/tokens.ts
|
|
171
|
+
var defaultTheme = {
|
|
172
|
+
colorPrimary: "#0a7cff",
|
|
173
|
+
colorPrimaryHover: "#006fe8",
|
|
174
|
+
colorBackground: "#f5faff",
|
|
175
|
+
colorSurface: "#ffffff",
|
|
176
|
+
colorText: "#142033",
|
|
177
|
+
colorTextMuted: "#66758c",
|
|
178
|
+
colorBorder: "#dce9f7",
|
|
179
|
+
radiusMd: "14px",
|
|
180
|
+
radiusLg: "24px",
|
|
181
|
+
shadowElevated: "0 18px 48px rgba(41, 106, 168, 0.16)",
|
|
182
|
+
motionDuration: "180ms"
|
|
183
|
+
};
|
|
184
|
+
var darkTheme = { ...defaultTheme, colorPrimary: "#58a9ff", colorPrimaryHover: "#7cbbff", colorBackground: "#0d1724", colorSurface: "#152337", colorText: "#f4f8fc", colorTextMuted: "#a9bad0", colorBorder: "#30445b", shadowElevated: "0 20px 54px rgba(0,0,0,.46)" };
|
|
185
|
+
var highContrastTheme = { ...defaultTheme, colorPrimary: "#005fcc", colorPrimaryHover: "#004a9f", colorBackground: "#ffffff", colorSurface: "#ffffff", colorText: "#000000", colorTextMuted: "#303030", colorBorder: "#000000", shadowElevated: "0 0 0 2px #000000", motionDuration: "0ms" };
|
|
186
|
+
var tokenVariables = {
|
|
187
|
+
colorPrimary: "--hf-color-primary",
|
|
188
|
+
colorPrimaryHover: "--hf-color-primary-hover",
|
|
189
|
+
colorBackground: "--hf-color-background",
|
|
190
|
+
colorSurface: "--hf-color-surface",
|
|
191
|
+
colorText: "--hf-color-text",
|
|
192
|
+
colorTextMuted: "--hf-color-text-muted",
|
|
193
|
+
colorBorder: "--hf-color-border",
|
|
194
|
+
radiusMd: "--hf-radius-md",
|
|
195
|
+
radiusLg: "--hf-radius-lg",
|
|
196
|
+
shadowElevated: "--hf-shadow-elevated",
|
|
197
|
+
motionDuration: "--hf-motion-duration"
|
|
198
|
+
};
|
|
199
|
+
function tokensToStyle(tokens) {
|
|
200
|
+
return Object.fromEntries(
|
|
201
|
+
Object.entries(tokens).map(([key, value]) => [tokenVariables[key], value])
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// src/theme/ThemeProvider.tsx
|
|
206
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
207
|
+
function ThemeProvider({ children, tokens, mode = "light", className = "", style, ...props }) {
|
|
208
|
+
const mergedTokens = { ...mode === "dark" ? darkTheme : mode === "high-contrast" ? highContrastTheme : defaultTheme, ...tokens };
|
|
209
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
210
|
+
"div",
|
|
211
|
+
{
|
|
212
|
+
className: `hf-theme hf-theme--${mode} ${className}`.trim(),
|
|
213
|
+
style: { ...tokensToStyle(mergedTokens), ...style },
|
|
214
|
+
...props,
|
|
215
|
+
children
|
|
216
|
+
}
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// src/components/Button.tsx
|
|
221
|
+
var import_react = require("react");
|
|
222
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
223
|
+
var Button = (0, import_react.forwardRef)(function Button2({ children, className = "", variant = "primary", size = "md", shape = "pill", fullWidth = false, loading = false, leadingIcon, trailingIcon, iconOnly = false, disabled, ...props }, ref) {
|
|
224
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
225
|
+
"button",
|
|
226
|
+
{
|
|
227
|
+
ref,
|
|
228
|
+
className: `hf-button hf-button--${variant} hf-button--${size} hf-button--${shape} ${fullWidth ? "hf-button--full" : ""} ${iconOnly ? "hf-button--icon" : ""} ${className}`.trim(),
|
|
229
|
+
disabled: disabled || loading,
|
|
230
|
+
"aria-busy": loading || void 0,
|
|
231
|
+
...props,
|
|
232
|
+
children: [
|
|
233
|
+
loading ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "hf-spinner", "aria-hidden": "true" }) : leadingIcon,
|
|
234
|
+
!iconOnly && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: loading ? "\u5904\u7406\u4E2D" : children }),
|
|
235
|
+
!loading && trailingIcon
|
|
236
|
+
]
|
|
237
|
+
}
|
|
238
|
+
);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
// src/components/SplitButton.tsx
|
|
242
|
+
var import_react3 = require("react");
|
|
243
|
+
|
|
244
|
+
// src/foundations/Icon.tsx
|
|
245
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
246
|
+
var paths = {
|
|
247
|
+
check: "M5 12.5 9.2 17 19 7",
|
|
248
|
+
close: "m7 7 10 10M17 7 7 17",
|
|
249
|
+
info: "M12 11v6M12 7.5h.01",
|
|
250
|
+
warning: "M12 4 3.5 19h17L12 4Zm0 5v4.5m0 2.5h.01",
|
|
251
|
+
error: "M8 8l8 8m0-8-8 8",
|
|
252
|
+
search: "m20 20-4.5-4.5m2.5-4A7 7 0 1 1 4 11a7 7 0 0 1 14 0Z",
|
|
253
|
+
"chevron-down": "m7 10 5 5 5-5",
|
|
254
|
+
"arrow-right": "M5 12h14m-5-5 5 5-5 5",
|
|
255
|
+
user: "M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8Zm7 8a7 7 0 0 0-14 0",
|
|
256
|
+
inbox: "M4 5h16v13H4V5Zm0 9h4l2 2h4l2-2h4"
|
|
257
|
+
};
|
|
258
|
+
function Icon({ name, size = 20, label, className = "", ...props }) {
|
|
259
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { className: `hf-icon ${className}`, width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round", role: label ? "img" : void 0, "aria-label": label, "aria-hidden": label ? void 0 : true, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: paths[name] }) });
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// src/overlays/useOverlay.ts
|
|
263
|
+
var import_react2 = require("react");
|
|
264
|
+
var focusableSelector = [
|
|
265
|
+
"a[href]",
|
|
266
|
+
"button:not([disabled])",
|
|
267
|
+
"input:not([disabled])",
|
|
268
|
+
"select:not([disabled])",
|
|
269
|
+
"textarea:not([disabled])",
|
|
270
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
271
|
+
].join(",");
|
|
272
|
+
var layerStack = [];
|
|
273
|
+
var scrollLockCount = 0;
|
|
274
|
+
var previousBodyOverflow = "";
|
|
275
|
+
function isTopLayer(id) {
|
|
276
|
+
return layerStack.at(-1)?.id === id;
|
|
277
|
+
}
|
|
278
|
+
function addLayer(id) {
|
|
279
|
+
layerStack.push({ id });
|
|
280
|
+
}
|
|
281
|
+
function removeLayer(id) {
|
|
282
|
+
const index = layerStack.findIndex((layer) => layer.id === id);
|
|
283
|
+
if (index >= 0) layerStack.splice(index, 1);
|
|
284
|
+
}
|
|
285
|
+
function lockBodyScroll() {
|
|
286
|
+
if (scrollLockCount === 0) {
|
|
287
|
+
previousBodyOverflow = document.body.style.overflow;
|
|
288
|
+
document.body.style.overflow = "hidden";
|
|
289
|
+
}
|
|
290
|
+
scrollLockCount += 1;
|
|
291
|
+
}
|
|
292
|
+
function unlockBodyScroll() {
|
|
293
|
+
scrollLockCount = Math.max(0, scrollLockCount - 1);
|
|
294
|
+
if (scrollLockCount === 0) document.body.style.overflow = previousBodyOverflow;
|
|
295
|
+
}
|
|
296
|
+
function focusInitialElement(root) {
|
|
297
|
+
const target = root.querySelector("[data-autofocus], [autofocus]") ?? root.querySelector(focusableSelector) ?? root;
|
|
298
|
+
target.focus();
|
|
299
|
+
}
|
|
300
|
+
function trapTabKey(event, root) {
|
|
301
|
+
const nodes = [...root.querySelectorAll(focusableSelector)].filter((node) => !node.hasAttribute("disabled") && node.getAttribute("aria-hidden") !== "true");
|
|
302
|
+
if (!nodes.length) {
|
|
303
|
+
event.preventDefault();
|
|
304
|
+
root.focus();
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
const first = nodes[0];
|
|
308
|
+
const last = nodes[nodes.length - 1];
|
|
309
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
310
|
+
event.preventDefault();
|
|
311
|
+
last.focus();
|
|
312
|
+
} else if (!event.shiftKey && document.activeElement === last) {
|
|
313
|
+
event.preventDefault();
|
|
314
|
+
first.focus();
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
function useDismissibleLayer(open, onClose, modalOrOptions = false) {
|
|
318
|
+
const ref = (0, import_react2.useRef)(null);
|
|
319
|
+
const idRef = (0, import_react2.useRef)(/* @__PURE__ */ Symbol("dismissible-layer"));
|
|
320
|
+
const closeRef = (0, import_react2.useRef)(onClose);
|
|
321
|
+
closeRef.current = onClose;
|
|
322
|
+
const options = typeof modalOrOptions === "boolean" ? { modal: modalOrOptions } : modalOrOptions;
|
|
323
|
+
const modal = options.modal ?? false;
|
|
324
|
+
const closeOnOutside = options.closeOnOutside ?? !modal;
|
|
325
|
+
const trapFocus = options.trapFocus ?? modal;
|
|
326
|
+
const lockScroll = options.lockScroll ?? modal;
|
|
327
|
+
const autoFocus = options.autoFocus ?? true;
|
|
328
|
+
const restoreFocus = options.restoreFocus ?? true;
|
|
329
|
+
(0, import_react2.useEffect)(() => {
|
|
330
|
+
if (!open) return void 0;
|
|
331
|
+
const id = idRef.current;
|
|
332
|
+
const previousFocus = document.activeElement;
|
|
333
|
+
addLayer(id);
|
|
334
|
+
if (lockScroll) lockBodyScroll();
|
|
335
|
+
const handlePointerDown = (event) => {
|
|
336
|
+
if (!isTopLayer(id) || !closeOnOutside) return;
|
|
337
|
+
if (!ref.current?.contains(event.target)) closeRef.current();
|
|
338
|
+
};
|
|
339
|
+
const handleKeyDown = (event) => {
|
|
340
|
+
if (!isTopLayer(id)) return;
|
|
341
|
+
if (event.key === "Escape") {
|
|
342
|
+
event.preventDefault();
|
|
343
|
+
event.stopPropagation();
|
|
344
|
+
closeRef.current();
|
|
345
|
+
} else if (event.key === "Tab" && trapFocus && ref.current) {
|
|
346
|
+
trapTabKey(event, ref.current);
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
document.addEventListener("pointerdown", handlePointerDown);
|
|
350
|
+
document.addEventListener("keydown", handleKeyDown, true);
|
|
351
|
+
const animationFrame = autoFocus ? requestAnimationFrame(() => ref.current && focusInitialElement(ref.current)) : void 0;
|
|
352
|
+
return () => {
|
|
353
|
+
if (animationFrame !== void 0) cancelAnimationFrame(animationFrame);
|
|
354
|
+
document.removeEventListener("pointerdown", handlePointerDown);
|
|
355
|
+
document.removeEventListener("keydown", handleKeyDown, true);
|
|
356
|
+
removeLayer(id);
|
|
357
|
+
if (lockScroll) unlockBodyScroll();
|
|
358
|
+
if (restoreFocus && previousFocus?.isConnected) previousFocus.focus();
|
|
359
|
+
};
|
|
360
|
+
}, [autoFocus, closeOnOutside, lockScroll, modal, open, restoreFocus, trapFocus]);
|
|
361
|
+
return ref;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// src/components/SplitButton.tsx
|
|
365
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
366
|
+
function SplitButton({ label, options, onPrimaryAction, onOptionSelect, variant = "primary", size = "md", disabled }) {
|
|
367
|
+
const [open, setOpen] = (0, import_react3.useState)(false);
|
|
368
|
+
const ref = useDismissibleLayer(open, () => setOpen(false), { autoFocus: false });
|
|
369
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "hf-split-button", ref, children: [
|
|
370
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Button, { variant, size, shape: "rounded", disabled, onClick: onPrimaryAction, children: label }),
|
|
371
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Button, { variant, size, shape: "rounded", disabled, iconOnly: true, leadingIcon: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { name: "chevron-down", size: 16 }), "aria-label": "\u66F4\u591A\u64CD\u4F5C", "aria-expanded": open, onClick: () => setOpen(!open) }),
|
|
372
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "hf-split-button__menu", role: "menu", children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { role: "menuitem", type: "button", disabled: option.disabled, className: option.danger ? "is-danger" : "", onClick: () => {
|
|
373
|
+
onOptionSelect(option.key);
|
|
374
|
+
setOpen(false);
|
|
375
|
+
}, children: option.label }, option.key)) })
|
|
376
|
+
] });
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// src/components/Input.tsx
|
|
380
|
+
var import_react4 = require("react");
|
|
381
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
382
|
+
var Input = (0, import_react4.forwardRef)(function Input2({ className = "", id, label, hint, error, prefix, disabled, ...props }, ref) {
|
|
383
|
+
const generatedId = (0, import_react4.useId)();
|
|
384
|
+
const inputId = id ?? generatedId;
|
|
385
|
+
const descriptionId = `${inputId}-description`;
|
|
386
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: `hf-field ${className}`.trim(), htmlFor: inputId, children: [
|
|
387
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "hf-field__label", children: label }),
|
|
388
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: `hf-input-shell ${error ? "hf-input-shell--error" : ""}`, children: [
|
|
389
|
+
prefix && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "hf-input-shell__prefix", "aria-hidden": "true", children: prefix }),
|
|
390
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
391
|
+
"input",
|
|
392
|
+
{
|
|
393
|
+
ref,
|
|
394
|
+
id: inputId,
|
|
395
|
+
className: "hf-input",
|
|
396
|
+
disabled,
|
|
397
|
+
"aria-invalid": Boolean(error),
|
|
398
|
+
"aria-describedby": hint || error ? descriptionId : void 0,
|
|
399
|
+
...props
|
|
400
|
+
}
|
|
401
|
+
)
|
|
402
|
+
] }),
|
|
403
|
+
(error || hint) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { id: descriptionId, className: `hf-field__hint ${error ? "hf-field__hint--error" : ""}`, children: error ?? hint })
|
|
404
|
+
] });
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
// src/components/Switch.tsx
|
|
408
|
+
var import_react5 = require("react");
|
|
409
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
410
|
+
var Switch = (0, import_react5.forwardRef)(function Switch2({ label, className = "", ...props }, ref) {
|
|
411
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: `hf-switch ${className}`.trim(), children: [
|
|
412
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { ref, className: "hf-switch__input", type: "checkbox", role: "switch", ...props }),
|
|
413
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "hf-switch__track", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "hf-switch__thumb" }) }),
|
|
414
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "hf-switch__label", children: label })
|
|
415
|
+
] });
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
// src/components/SegmentedControl.tsx
|
|
419
|
+
var import_react6 = require("react");
|
|
420
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
421
|
+
function SegmentedControl({ label, options, value, onChange, className = "" }) {
|
|
422
|
+
const name = (0, import_react6.useId)();
|
|
423
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("fieldset", { className: `hf-segmented ${className}`.trim(), "aria-label": label, children: [
|
|
424
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("legend", { className: "hf-sr-only", children: label }),
|
|
425
|
+
options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "hf-segmented__option", children: [
|
|
426
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
427
|
+
"input",
|
|
428
|
+
{
|
|
429
|
+
type: "radio",
|
|
430
|
+
name,
|
|
431
|
+
value: option.value,
|
|
432
|
+
checked: value === option.value,
|
|
433
|
+
onChange: () => onChange(option.value)
|
|
434
|
+
}
|
|
435
|
+
),
|
|
436
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: option.label })
|
|
437
|
+
] }, option.value))
|
|
438
|
+
] });
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// src/components/Card.tsx
|
|
442
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
443
|
+
function Card({ children, title, eyebrow, action, interactive = false, className = "", ...props }) {
|
|
444
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("article", { className: `hf-card ${interactive ? "hf-card--interactive" : ""} ${className}`.trim(), ...props, children: [
|
|
445
|
+
(eyebrow || title || action) && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("header", { className: "hf-card__header", children: [
|
|
446
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
|
|
447
|
+
eyebrow && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "hf-card__eyebrow", children: eyebrow }),
|
|
448
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h3", { className: "hf-card__title", children: title })
|
|
449
|
+
] }),
|
|
450
|
+
action
|
|
451
|
+
] }),
|
|
452
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "hf-card__body", children })
|
|
453
|
+
] });
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// src/components/Modal.tsx
|
|
457
|
+
var import_react7 = require("react");
|
|
458
|
+
var import_react_dom = require("react-dom");
|
|
459
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
460
|
+
function Modal({ open, title, children, onClose, footer }) {
|
|
461
|
+
const titleId = (0, import_react7.useId)();
|
|
462
|
+
const dialogRef = useDismissibleLayer(open, onClose, true);
|
|
463
|
+
if (!open) return null;
|
|
464
|
+
return (0, import_react_dom.createPortal)(
|
|
465
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "hf-modal-backdrop", onMouseDown: (event) => event.target === event.currentTarget && onClose(), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { ref: dialogRef, className: "hf-modal", role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, tabIndex: -1, children: [
|
|
466
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("header", { className: "hf-modal__header", children: [
|
|
467
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h2", { id: titleId, children: title }),
|
|
468
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Button, { variant: "quiet", size: "sm", onClick: onClose, "aria-label": "\u5173\u95ED\u5F39\u7A97", children: "\xD7" })
|
|
469
|
+
] }),
|
|
470
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "hf-modal__body", children }),
|
|
471
|
+
footer && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("footer", { className: "hf-modal__footer", children: footer })
|
|
472
|
+
] }) }),
|
|
473
|
+
document.body
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// src/components/Toast.tsx
|
|
478
|
+
var import_react8 = require("react");
|
|
479
|
+
var import_react_dom2 = require("react-dom");
|
|
480
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
481
|
+
function Toast({ open, message, tone = "info", duration = 2600, onClose }) {
|
|
482
|
+
(0, import_react8.useEffect)(() => {
|
|
483
|
+
if (!open || duration <= 0) return;
|
|
484
|
+
const timer = window.setTimeout(onClose, duration);
|
|
485
|
+
return () => window.clearTimeout(timer);
|
|
486
|
+
}, [duration, onClose, open]);
|
|
487
|
+
if (!open) return null;
|
|
488
|
+
return (0, import_react_dom2.createPortal)(
|
|
489
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: `hf-toast hf-toast--${tone}`, role: tone === "error" ? "alert" : "status", children: [
|
|
490
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "hf-toast__mark", "aria-hidden": "true" }),
|
|
491
|
+
message
|
|
492
|
+
] }),
|
|
493
|
+
document.body
|
|
494
|
+
);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// src/components/Content.tsx
|
|
498
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
499
|
+
function Divider({ orientation = "horizontal", label, className = "" }) {
|
|
500
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: `hf-divider hf-divider--${orientation}${label ? " hf-divider--labelled" : ""} ${className}`, role: "separator", "aria-orientation": orientation, children: label && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: label }) });
|
|
501
|
+
}
|
|
502
|
+
function Link({ external, className = "", children, ...props }) {
|
|
503
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("a", { className: `hf-link ${className}`, target: external ? "_blank" : props.target, rel: external ? "noreferrer" : props.rel, ...props, children: [
|
|
504
|
+
children,
|
|
505
|
+
external && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { "aria-hidden": "true", children: "\u2197" })
|
|
506
|
+
] });
|
|
507
|
+
}
|
|
508
|
+
function Badge({ tone = "neutral", dot, className = "", ...props }) {
|
|
509
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: `hf-badge hf-tone--${tone} ${className}`, ...props, children: [
|
|
510
|
+
dot && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("i", { "aria-hidden": "true" }),
|
|
511
|
+
props.children
|
|
512
|
+
] });
|
|
513
|
+
}
|
|
514
|
+
function Tag({ tone = "neutral", onRemove, removeLabel = "\u79FB\u9664\u6807\u7B7E", className = "", children, ...props }) {
|
|
515
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: `hf-tag hf-tone--${tone} ${className}`, ...props, children: [
|
|
516
|
+
children,
|
|
517
|
+
onRemove && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { type: "button", "aria-label": removeLabel, onClick: onRemove, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon, { name: "close", size: 14 }) })
|
|
518
|
+
] });
|
|
519
|
+
}
|
|
520
|
+
function Avatar({ src, name, alt = "", size = "md", status, className = "" }) {
|
|
521
|
+
const initials = name.trim().split(/\s+/).slice(0, 2).map((part) => part[0]).join("").toUpperCase();
|
|
522
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: `hf-avatar hf-avatar--${size} ${className}`, title: name, children: [
|
|
523
|
+
src ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("img", { src, alt: alt || name }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { "aria-hidden": "true", children: initials }),
|
|
524
|
+
status && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("i", { className: `hf-avatar__status hf-avatar__status--${status}`, "aria-label": { online: "\u5728\u7EBF", busy: "\u5FD9\u788C", away: "\u79BB\u5F00" }[status] })
|
|
525
|
+
] });
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// src/components/Accordion.tsx
|
|
529
|
+
var import_react9 = require("react");
|
|
530
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
531
|
+
function Accordion({ items, value, defaultValue = [], onChange, multiple = false }) {
|
|
532
|
+
const [inner, setInner] = (0, import_react9.useState)([...defaultValue]);
|
|
533
|
+
const active = value ? [...value] : inner;
|
|
534
|
+
const toggle = (key) => {
|
|
535
|
+
const next = active.includes(key) ? active.filter((item) => item !== key) : multiple ? [...active, key] : [key];
|
|
536
|
+
if (!value) setInner(next);
|
|
537
|
+
onChange?.(next);
|
|
538
|
+
};
|
|
539
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "hf-accordion", children: items.map((item) => {
|
|
540
|
+
const open = active.includes(item.key);
|
|
541
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("section", { className: open ? "is-open" : "", children: [
|
|
542
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h3", { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("button", { type: "button", "aria-expanded": open, disabled: item.disabled, onClick: () => toggle(item.key), children: [
|
|
543
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: item.title }),
|
|
544
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { "aria-hidden": "true", children: "\u2304" })
|
|
545
|
+
] }) }),
|
|
546
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "hf-accordion__panel", children: item.content })
|
|
547
|
+
] }, item.key);
|
|
548
|
+
}) });
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
// src/components/Dropdown.tsx
|
|
552
|
+
var import_react10 = require("react");
|
|
553
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
554
|
+
function Dropdown({ trigger, items, onSelect, placement = "left", label = "\u64CD\u4F5C\u83DC\u5355" }) {
|
|
555
|
+
const [open, setOpen] = (0, import_react10.useState)(false);
|
|
556
|
+
const root = useDismissibleLayer(open, () => setOpen(false));
|
|
557
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "hf-dropdown", ref: root, children: [
|
|
558
|
+
(0, import_react10.cloneElement)(trigger, { onClick: () => setOpen((value) => !value), "aria-expanded": open, "aria-haspopup": "menu" }),
|
|
559
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: `hf-dropdown__menu hf-dropdown__menu--${placement}`, role: "menu", "aria-label": label, children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("button", { type: "button", role: "menuitem", className: `${item.danger ? "is-danger" : ""}${item.separatorBefore ? " has-separator" : ""}`, disabled: item.disabled, onClick: () => {
|
|
560
|
+
onSelect(item.key);
|
|
561
|
+
setOpen(false);
|
|
562
|
+
}, children: [
|
|
563
|
+
item.icon,
|
|
564
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { children: [
|
|
565
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("strong", { children: item.label }),
|
|
566
|
+
item.description && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("small", { children: item.description })
|
|
567
|
+
] })
|
|
568
|
+
] }, item.key)) })
|
|
569
|
+
] });
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
// src/components/IconButton.tsx
|
|
573
|
+
var import_react11 = require("react");
|
|
574
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
575
|
+
var IconButton = (0, import_react11.forwardRef)(function IconButton2({ label, icon, variant = "quiet", size = "md", className = "", ...props }, ref) {
|
|
576
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { ref, className: `hf-button hf-button--${variant} hf-button--${size} hf-button--square hf-button--icon ${className}`.trim(), "aria-label": label, title: label, ...props, children: icon });
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
// src/components/AdvancedUtility.tsx
|
|
580
|
+
var import_react12 = require("react");
|
|
581
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
582
|
+
function ButtonGroup({ children, orientation = "horizontal", attached = true, className = "", ...props }) {
|
|
583
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { role: "group", className: `hf-button-group hf-button-group--${orientation}${attached ? " is-attached" : ""} ${className}`.trim(), ...props, children });
|
|
584
|
+
}
|
|
585
|
+
function ColorPicker({ value, onChange, label, presets = ["#0a7cff", "#19a989", "#7657e6", "#f0a11a", "#e5484d"], disabled }) {
|
|
586
|
+
const [open, setOpen] = (0, import_react12.useState)(false);
|
|
587
|
+
const root = useDismissibleLayer(open, () => setOpen(false));
|
|
588
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "hf-field hf-color-picker", ref: root, children: [
|
|
589
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "hf-field__label", children: label }),
|
|
590
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("button", { type: "button", className: "hf-color-picker__trigger", disabled, "aria-expanded": open, onClick: () => setOpen(!open), children: [
|
|
591
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { style: { background: value } }),
|
|
592
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("code", { children: value.toUpperCase() }),
|
|
593
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { "aria-hidden": "true", children: "\u2304" })
|
|
594
|
+
] }),
|
|
595
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "hf-color-picker__panel", children: [
|
|
596
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("input", { type: "color", "aria-label": "\u9009\u62E9\u989C\u8272", value, onChange: (event) => onChange(event.target.value) }),
|
|
597
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { children: presets.map((color) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", "aria-label": `\u9009\u62E9\u989C\u8272 ${color}`, "aria-pressed": value.toLowerCase() === color.toLowerCase(), style: { background: color }, onClick: () => onChange(color) }, color)) }),
|
|
598
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("input", { "aria-label": "\u989C\u8272\u503C", value, onChange: (event) => /^#[0-9a-f]{0,6}$/i.test(event.target.value) && onChange(event.target.value) })
|
|
599
|
+
] })
|
|
600
|
+
] });
|
|
601
|
+
}
|
|
602
|
+
function ContextMenu({ items, onSelect, label = "\u4E0A\u4E0B\u6587\u83DC\u5355", children }) {
|
|
603
|
+
const [position, setPosition] = (0, import_react12.useState)();
|
|
604
|
+
const root = useDismissibleLayer(Boolean(position), () => setPosition(void 0));
|
|
605
|
+
const open = (event) => {
|
|
606
|
+
event.preventDefault();
|
|
607
|
+
setPosition({ x: event.clientX, y: event.clientY });
|
|
608
|
+
};
|
|
609
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "hf-context-target", onContextMenu: open, children: [
|
|
610
|
+
children,
|
|
611
|
+
position && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { ref: root, className: "hf-context-menu", role: "menu", "aria-label": label, style: { left: position.x, top: position.y }, children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("button", { type: "button", role: "menuitem", disabled: item.disabled, className: item.danger ? "is-danger" : "", onClick: () => {
|
|
612
|
+
onSelect(item.key);
|
|
613
|
+
setPosition(void 0);
|
|
614
|
+
}, children: [
|
|
615
|
+
item.icon,
|
|
616
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: item.label })
|
|
617
|
+
] }, item.key)) })
|
|
618
|
+
] });
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
// src/components/Editors.tsx
|
|
622
|
+
var import_react13 = require("react");
|
|
623
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
624
|
+
function RichTextEditor({ value, onChange, label, placeholder = "\u8F93\u5165\u5185\u5BB9\u2026", disabled }) {
|
|
625
|
+
const editor = (0, import_react13.useRef)(null);
|
|
626
|
+
(0, import_react13.useEffect)(() => {
|
|
627
|
+
if (editor.current && editor.current.innerHTML !== value) editor.current.innerHTML = value;
|
|
628
|
+
}, [value]);
|
|
629
|
+
const format = (command) => {
|
|
630
|
+
editor.current?.focus();
|
|
631
|
+
document.execCommand(command);
|
|
632
|
+
onChange(editor.current?.innerHTML ?? "");
|
|
633
|
+
};
|
|
634
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "hf-rich-editor", children: [
|
|
635
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "hf-rich-editor__header", children: [
|
|
636
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("strong", { children: label }),
|
|
637
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { role: "toolbar", "aria-label": "\u6587\u672C\u683C\u5F0F", children: [
|
|
638
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", "aria-label": "\u7C97\u4F53", disabled, onClick: () => format("bold"), children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("b", { children: "B" }) }),
|
|
639
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", "aria-label": "\u659C\u4F53", disabled, onClick: () => format("italic"), children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("i", { children: "I" }) }),
|
|
640
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", "aria-label": "\u65E0\u5E8F\u5217\u8868", disabled, onClick: () => format("insertUnorderedList"), children: "\u2022 \u5217\u8868" })
|
|
641
|
+
] })
|
|
642
|
+
] }),
|
|
643
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { ref: editor, className: "hf-rich-editor__content", contentEditable: !disabled, role: "textbox", "aria-multiline": "true", "aria-label": label ?? "\u5BCC\u6587\u672C\u7F16\u8F91\u5668", "data-placeholder": placeholder, onInput: (event) => onChange(event.currentTarget.innerHTML) })
|
|
644
|
+
] });
|
|
645
|
+
}
|
|
646
|
+
function MentionInput({ value, onChange, options, label, placeholder = "\u8F93\u5165 @ \u63D0\u53CA\u6210\u5458", disabled }) {
|
|
647
|
+
const [active, setActive] = (0, import_react13.useState)(0);
|
|
648
|
+
const match = value.match(/(?:^|\s)@([^\s@]*)$/);
|
|
649
|
+
const query = match?.[1]?.toLowerCase();
|
|
650
|
+
const results = (0, import_react13.useMemo)(() => query === void 0 ? [] : options.filter((item) => `${item.label} ${item.value}`.toLowerCase().includes(query)).slice(0, 6), [options, query]);
|
|
651
|
+
(0, import_react13.useEffect)(() => setActive(0), [query]);
|
|
652
|
+
const choose = (item) => {
|
|
653
|
+
if (!match) return;
|
|
654
|
+
onChange(`${value.slice(0, match.index)}${match[0].startsWith(" ") ? " " : ""}@${item.label} `);
|
|
655
|
+
};
|
|
656
|
+
const keyDown = (event) => {
|
|
657
|
+
if (!results.length) return;
|
|
658
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
659
|
+
event.preventDefault();
|
|
660
|
+
setActive((index) => (index + (event.key === "ArrowDown" ? 1 : -1) + results.length) % results.length);
|
|
661
|
+
} else if (event.key === "Enter" || event.key === "Tab") {
|
|
662
|
+
event.preventDefault();
|
|
663
|
+
choose(results[active]);
|
|
664
|
+
} else if (event.key === "Escape") {
|
|
665
|
+
event.preventDefault();
|
|
666
|
+
onChange(`${value} `);
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "hf-field hf-mention-input", children: [
|
|
670
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "hf-field__label", children: label }),
|
|
671
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("textarea", { value, placeholder, disabled, "aria-autocomplete": "list", "aria-expanded": Boolean(results.length), onChange: (event) => onChange(event.target.value), onKeyDown: keyDown }),
|
|
672
|
+
results.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "hf-mention-input__menu", role: "listbox", children: results.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("button", { type: "button", role: "option", "aria-selected": index === active, onMouseDown: (event) => event.preventDefault(), onClick: () => choose(item), children: [
|
|
673
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { children: [
|
|
674
|
+
"@",
|
|
675
|
+
item.label
|
|
676
|
+
] }),
|
|
677
|
+
item.description && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("small", { children: item.description })
|
|
678
|
+
] }, item.value)) })
|
|
679
|
+
] });
|
|
680
|
+
}
|
|
681
|
+
function CodeEditor({ value, onChange, language = "text", label = "\u4EE3\u7801\u7F16\u8F91\u5668", readOnly, height = 260 }) {
|
|
682
|
+
const lines = value.split("\n").length;
|
|
683
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "hf-code-editor", children: [
|
|
684
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("header", { children: [
|
|
685
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("strong", { children: label }),
|
|
686
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { children: language })
|
|
687
|
+
] }),
|
|
688
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { style: { height }, children: [
|
|
689
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("pre", { "aria-hidden": "true", children: Array.from({ length: lines }, (_, index) => `${index + 1}
|
|
690
|
+
`) }),
|
|
691
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("textarea", { spellCheck: false, readOnly, "aria-label": label, value, onChange: (event) => onChange(event.target.value), onKeyDown: (event) => {
|
|
692
|
+
if (event.key === "Tab" && !readOnly) {
|
|
693
|
+
event.preventDefault();
|
|
694
|
+
const input = event.currentTarget;
|
|
695
|
+
const next = `${value.slice(0, input.selectionStart)} ${value.slice(input.selectionEnd)}`;
|
|
696
|
+
onChange(next);
|
|
697
|
+
requestAnimationFrame(() => input.setSelectionRange(input.selectionStart + 2, input.selectionStart + 2));
|
|
698
|
+
}
|
|
699
|
+
} })
|
|
700
|
+
] })
|
|
701
|
+
] });
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
// src/components/AIInteraction.tsx
|
|
705
|
+
var import_react14 = require("react");
|
|
706
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
707
|
+
function ChatMessage({ role, children, avatar, name, timestamp, actions, streaming, error }) {
|
|
708
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("article", { className: `hf-chat-message hf-chat-message--${role}`, "aria-live": streaming ? "polite" : void 0, children: [
|
|
709
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "hf-chat-message__avatar", "aria-hidden": "true", children: avatar ?? (role === "assistant" ? "AI" : role === "system" ? "S" : "U") }),
|
|
710
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "hf-chat-message__body", children: [
|
|
711
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("header", { children: [
|
|
712
|
+
name && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("strong", { children: name }),
|
|
713
|
+
timestamp && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("time", { children: timestamp })
|
|
714
|
+
] }),
|
|
715
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "hf-chat-message__content", children: [
|
|
716
|
+
children,
|
|
717
|
+
streaming && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "hf-chat-message__cursor", "aria-label": "\u6B63\u5728\u751F\u6210" })
|
|
718
|
+
] }),
|
|
719
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "hf-chat-message__error", role: "alert", children: error }),
|
|
720
|
+
actions && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("footer", { children: actions })
|
|
721
|
+
] })
|
|
722
|
+
] });
|
|
723
|
+
}
|
|
724
|
+
function ChatComposer({ value, onChange, onSend, attachments = [], onRemoveAttachment, onAttach, placeholder = "\u8F93\u5165\u6D88\u606F\uFF0CEnter \u53D1\u9001\uFF0CShift + Enter \u6362\u884C", disabled, sending, footer, maxLength }) {
|
|
725
|
+
const send = () => {
|
|
726
|
+
const content = value.trim();
|
|
727
|
+
if (content && !disabled && !sending) onSend(content);
|
|
728
|
+
};
|
|
729
|
+
const submit = (event) => {
|
|
730
|
+
event.preventDefault();
|
|
731
|
+
send();
|
|
732
|
+
};
|
|
733
|
+
const keyDown = (event) => {
|
|
734
|
+
if (event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing) {
|
|
735
|
+
event.preventDefault();
|
|
736
|
+
send();
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("form", { className: "hf-chat-composer", onSubmit: submit, children: [
|
|
740
|
+
attachments.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "hf-chat-composer__attachments", children: attachments.map((item) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { children: [
|
|
741
|
+
item.icon,
|
|
742
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("strong", { children: item.name }),
|
|
743
|
+
item.size && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("small", { children: item.size }),
|
|
744
|
+
onRemoveAttachment && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", "aria-label": `\u79FB\u9664\u9644\u4EF6 ${item.name}`, onClick: () => onRemoveAttachment(item.id), children: "\xD7" })
|
|
745
|
+
] }, item.id)) }),
|
|
746
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("textarea", { "aria-label": "\u6D88\u606F\u5185\u5BB9", value, maxLength, disabled, placeholder, onChange: (event) => onChange(event.target.value), onKeyDown: keyDown }),
|
|
747
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("footer", { children: [
|
|
748
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { children: [
|
|
749
|
+
onAttach && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: "hf-chat-composer__attach", "aria-label": "\u6DFB\u52A0\u9644\u4EF6", disabled, onClick: onAttach, children: "\uFF0B" }),
|
|
750
|
+
footer
|
|
751
|
+
] }),
|
|
752
|
+
maxLength && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("small", { children: [
|
|
753
|
+
value.length,
|
|
754
|
+
"/",
|
|
755
|
+
maxLength
|
|
756
|
+
] }),
|
|
757
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("button", { type: "submit", className: "hf-chat-composer__send", disabled: disabled || sending || !value.trim(), children: [
|
|
758
|
+
sending ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "hf-spinner" }) : "\u2191",
|
|
759
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "hf-sr-only", children: "\u53D1\u9001\u6D88\u606F" })
|
|
760
|
+
] })
|
|
761
|
+
] })
|
|
762
|
+
] });
|
|
763
|
+
}
|
|
764
|
+
function PromptSuggestions({ items, onSelect, title, columns = 2 }) {
|
|
765
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("section", { className: `hf-prompt-suggestions hf-prompt-suggestions--${columns}`, children: [
|
|
766
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("header", { children: title }),
|
|
767
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("button", { type: "button", onClick: () => onSelect(item), children: [
|
|
768
|
+
item.icon && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: item.icon }),
|
|
769
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("strong", { children: item.title }),
|
|
770
|
+
item.description && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("small", { children: item.description }),
|
|
771
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("i", { "aria-hidden": "true", children: "\u2192" })
|
|
772
|
+
] }, item.id)) })
|
|
773
|
+
] });
|
|
774
|
+
}
|
|
775
|
+
var toolStatusLabel = { queued: "\u7B49\u5F85\u4E2D", running: "\u6267\u884C\u4E2D", success: "\u5DF2\u5B8C\u6210", error: "\u6267\u884C\u5931\u8D25", cancelled: "\u5DF2\u53D6\u6D88" };
|
|
776
|
+
function ToolCallCard({ name, status, description, input, output, duration, icon, defaultExpanded = false, onRetry, onCancel }) {
|
|
777
|
+
const [open, setOpen] = (0, import_react14.useState)(defaultExpanded);
|
|
778
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("section", { className: `hf-tool-call is-${status}`, children: [
|
|
779
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("button", { type: "button", className: "hf-tool-call__summary", "aria-expanded": open, onClick: () => setOpen(!open), children: [
|
|
780
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "hf-tool-call__icon", children: status === "running" ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "hf-spinner" }) : icon ?? "\u25C7" }),
|
|
781
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { children: [
|
|
782
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("strong", { children: name }),
|
|
783
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("small", { children: description })
|
|
784
|
+
] }),
|
|
785
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("i", { children: toolStatusLabel[status] }),
|
|
786
|
+
duration && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("time", { children: duration }),
|
|
787
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("b", { "aria-hidden": "true", children: "\u2304" })
|
|
788
|
+
] }),
|
|
789
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "hf-tool-call__detail", children: [
|
|
790
|
+
input && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("section", { children: [
|
|
791
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("strong", { children: "\u8F93\u5165" }),
|
|
792
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: input })
|
|
793
|
+
] }),
|
|
794
|
+
output && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("section", { children: [
|
|
795
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("strong", { children: "\u8F93\u51FA" }),
|
|
796
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: output })
|
|
797
|
+
] }),
|
|
798
|
+
status === "error" && onRetry || status === "running" && onCancel ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("footer", { children: [
|
|
799
|
+
status === "error" && onRetry && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", onClick: onRetry, children: "\u91CD\u65B0\u6267\u884C" }),
|
|
800
|
+
status === "running" && onCancel && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", onClick: onCancel, children: "\u505C\u6B62\u6267\u884C" })
|
|
801
|
+
] }) : null
|
|
802
|
+
] })
|
|
803
|
+
] });
|
|
804
|
+
}
|
|
805
|
+
function CitationList({ items, title = "\u53C2\u8003\u6765\u6E90", onSelect }) {
|
|
806
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("section", { className: "hf-citation-list", children: [
|
|
807
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("header", { children: [
|
|
808
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("strong", { children: title }),
|
|
809
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: items.length })
|
|
810
|
+
] }),
|
|
811
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("ol", { children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("a", { href: item.url, target: item.url ? "_blank" : void 0, rel: item.url ? "noreferrer" : void 0, onClick: (event) => {
|
|
812
|
+
if (!item.url) event.preventDefault();
|
|
813
|
+
onSelect?.(item);
|
|
814
|
+
}, children: [
|
|
815
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: item.favicon ?? index + 1 }),
|
|
816
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { children: [
|
|
817
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("strong", { children: item.title }),
|
|
818
|
+
item.source && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("small", { children: item.source }),
|
|
819
|
+
item.excerpt && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { children: item.excerpt })
|
|
820
|
+
] }),
|
|
821
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("i", { "aria-hidden": "true", children: "\u2197" })
|
|
822
|
+
] }) }, item.id)) })
|
|
823
|
+
] });
|
|
824
|
+
}
|
|
825
|
+
function AgentRunTimeline({ steps, activeId, onSelect, label = "Agent \u6267\u884C\u8FC7\u7A0B" }) {
|
|
826
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("ol", { className: "hf-agent-run", "aria-label": label, children: steps.map((step) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("li", { className: `is-${step.status}${activeId === step.id ? " is-active" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("button", { type: "button", "aria-pressed": activeId === step.id, onClick: () => onSelect?.(step.id), children: [
|
|
827
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: step.status === "success" ? "\u2713" : step.status === "error" ? "!" : step.status === "running" ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("i", { className: "hf-spinner" }) : "\xB7" }),
|
|
828
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { children: [
|
|
829
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("header", { children: [
|
|
830
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("strong", { children: step.title }),
|
|
831
|
+
step.timestamp && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("time", { children: step.timestamp })
|
|
832
|
+
] }),
|
|
833
|
+
step.description && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { children: step.description }),
|
|
834
|
+
step.detail && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: step.detail })
|
|
835
|
+
] })
|
|
836
|
+
] }) }, step.id)) });
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
// src/components/AIAdvanced.tsx
|
|
840
|
+
var import_react15 = require("react");
|
|
841
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
842
|
+
function inlineMarkdown(text) {
|
|
843
|
+
const pattern = /(\*\*[^*]+\*\*|`[^`]+`|\[[^\]]+\]\(https?:\/\/[^\s)]+\))/g;
|
|
844
|
+
return text.split(pattern).filter(Boolean).map((part, index) => {
|
|
845
|
+
if (part.startsWith("**") && part.endsWith("**")) return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("strong", { children: part.slice(2, -2) }, index);
|
|
846
|
+
if (part.startsWith("`") && part.endsWith("`")) return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("code", { children: part.slice(1, -1) }, index);
|
|
847
|
+
const link = part.match(/^\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)$/);
|
|
848
|
+
return link ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("a", { href: link[2], target: "_blank", rel: "noreferrer", children: link[1] }, index) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react15.Fragment, { children: part }, index);
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
function MarkdownContent({ content, className = "" }) {
|
|
852
|
+
const blocks = (0, import_react15.useMemo)(() => {
|
|
853
|
+
const lines = content.split("\n");
|
|
854
|
+
const result = [];
|
|
855
|
+
let code, language = "";
|
|
856
|
+
let list = [];
|
|
857
|
+
const flushList = () => {
|
|
858
|
+
if (list.length) result.push(/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("ul", { children: list.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("li", { children: inlineMarkdown(item) }, index)) }, `list-${result.length}`));
|
|
859
|
+
list = [];
|
|
860
|
+
};
|
|
861
|
+
lines.forEach((line) => {
|
|
862
|
+
if (line.startsWith("```")) {
|
|
863
|
+
if (code) {
|
|
864
|
+
result.push(/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CodeBlock, { code: code.join("\n"), language }, `code-${result.length}`));
|
|
865
|
+
code = void 0;
|
|
866
|
+
language = "";
|
|
867
|
+
} else {
|
|
868
|
+
flushList();
|
|
869
|
+
code = [];
|
|
870
|
+
language = line.slice(3).trim();
|
|
871
|
+
}
|
|
872
|
+
return;
|
|
873
|
+
}
|
|
874
|
+
if (code) {
|
|
875
|
+
code.push(line);
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
if (line.startsWith("- ")) {
|
|
879
|
+
list.push(line.slice(2));
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
flushList();
|
|
883
|
+
if (!line.trim()) return;
|
|
884
|
+
const heading = line.match(/^(#{1,3})\s+(.+)$/);
|
|
885
|
+
if (heading) {
|
|
886
|
+
const Tag2 = `h${heading[1].length}`;
|
|
887
|
+
result.push(/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Tag2, { children: inlineMarkdown(heading[2]) }, result.length));
|
|
888
|
+
} else if (line.startsWith("> ")) result.push(/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("blockquote", { children: inlineMarkdown(line.slice(2)) }, result.length));
|
|
889
|
+
else result.push(/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { children: inlineMarkdown(line) }, result.length));
|
|
890
|
+
});
|
|
891
|
+
flushList();
|
|
892
|
+
if (code) result.push(/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CodeBlock, { code: code.join("\n"), language }, "code-last"));
|
|
893
|
+
return result;
|
|
894
|
+
}, [content]);
|
|
895
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: `hf-markdown ${className}`.trim(), children: blocks });
|
|
896
|
+
}
|
|
897
|
+
function CodeBlock({ code, language = "text", filename, wrap, showLineNumbers = true, onCopy }) {
|
|
898
|
+
const [copied, setCopied] = (0, import_react15.useState)(false);
|
|
899
|
+
const lines = code.split("\n");
|
|
900
|
+
const copy = async () => {
|
|
901
|
+
try {
|
|
902
|
+
await navigator.clipboard.writeText(code);
|
|
903
|
+
} catch {
|
|
904
|
+
}
|
|
905
|
+
onCopy?.(code);
|
|
906
|
+
setCopied(true);
|
|
907
|
+
window.setTimeout(() => setCopied(false), 1500);
|
|
908
|
+
};
|
|
909
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("section", { className: `hf-code-block${wrap ? " is-wrapped" : ""}`, children: [
|
|
910
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("header", { children: [
|
|
911
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { children: filename ?? language }),
|
|
912
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", onClick: copy, children: copied ? "\u5DF2\u590D\u5236" : "\u590D\u5236\u4EE3\u7801" })
|
|
913
|
+
] }),
|
|
914
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { children: [
|
|
915
|
+
showLineNumbers && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("pre", { "aria-hidden": "true", children: lines.map((_, index) => `${index + 1}
|
|
916
|
+
`) }),
|
|
917
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("pre", { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("code", { children: code }) })
|
|
918
|
+
] })
|
|
919
|
+
] });
|
|
920
|
+
}
|
|
921
|
+
function VoiceInput({ state = "idle", duration = "00:00", level = 0.45, disabled, onStart, onStop, onCancel, error }) {
|
|
922
|
+
const active = state === "listening";
|
|
923
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: `hf-voice-input is-${state}`, role: "status", "aria-label": active ? "\u6B63\u5728\u5F55\u97F3" : state === "processing" ? "\u6B63\u5728\u8BC6\u522B\u8BED\u97F3" : "\u8BED\u97F3\u8F93\u5165", children: [
|
|
924
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: "hf-voice-input__main", disabled: disabled || state === "processing", onClick: active ? onStop : onStart, children: state === "processing" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "hf-spinner" }) : active ? "\u25A0" : "\u25CF" }),
|
|
925
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { children: [
|
|
926
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "hf-voice-input__wave", "aria-hidden": "true", children: Array.from({ length: 18 }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("i", { style: { height: `${Math.max(12, index * 17 % 75 * level + 12)}%` } }, index)) }),
|
|
927
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { children: active ? duration : state === "processing" ? "\u6B63\u5728\u8F6C\u6362\u6587\u5B57\u2026" : error ?? "\u70B9\u51FB\u5F00\u59CB\u8BED\u97F3\u8F93\u5165" })
|
|
928
|
+
] }),
|
|
929
|
+
(active || state === "error") && onCancel && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: "hf-voice-input__cancel", onClick: onCancel, children: "\u53D6\u6D88" })
|
|
930
|
+
] });
|
|
931
|
+
}
|
|
932
|
+
function ModelSelector({ models, value, onChange, label = "\u9009\u62E9\u6A21\u578B", disabled }) {
|
|
933
|
+
const [open, setOpen] = (0, import_react15.useState)(false);
|
|
934
|
+
const root = useDismissibleLayer(open, () => setOpen(false));
|
|
935
|
+
const selected = models.find((item) => item.id === value);
|
|
936
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "hf-model-selector", ref: root, children: [
|
|
937
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("button", { type: "button", className: "hf-model-selector__trigger", disabled, "aria-expanded": open, onClick: () => setOpen(!open), children: [
|
|
938
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { children: selected?.icon ?? "\u2726" }),
|
|
939
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { children: [
|
|
940
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("strong", { children: selected?.name ?? label }),
|
|
941
|
+
selected?.description && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("small", { children: selected.description })
|
|
942
|
+
] }),
|
|
943
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("i", { "aria-hidden": "true", children: "\u2304" })
|
|
944
|
+
] }),
|
|
945
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "hf-model-selector__menu", role: "listbox", "aria-label": label, children: models.map((model) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("button", { type: "button", role: "option", "aria-selected": model.id === value, disabled: model.disabled, onClick: () => {
|
|
946
|
+
onChange(model.id);
|
|
947
|
+
setOpen(false);
|
|
948
|
+
}, children: [
|
|
949
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { children: model.icon ?? "\u2726" }),
|
|
950
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { children: [
|
|
951
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("strong", { children: model.name }),
|
|
952
|
+
model.description && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("small", { children: model.description }),
|
|
953
|
+
model.tags?.length ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("i", { children: model.tags.map((tag) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("b", { children: tag }, tag)) }) : null
|
|
954
|
+
] }),
|
|
955
|
+
model.id === value && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("em", { children: "\u2713" })
|
|
956
|
+
] }, model.id)) })
|
|
957
|
+
] });
|
|
958
|
+
}
|
|
959
|
+
function ConversationBranch({ current, total, onChange, label = "\u56DE\u7B54\u5206\u652F" }) {
|
|
960
|
+
const safeTotal = Math.max(1, total), safeCurrent = Math.min(safeTotal - 1, Math.max(0, current));
|
|
961
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("nav", { className: "hf-conversation-branch", "aria-label": String(label), children: [
|
|
962
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", "aria-label": "\u4E0A\u4E00\u4E2A\u5206\u652F", disabled: safeCurrent === 0, onClick: () => onChange(safeCurrent - 1), children: "\u2039" }),
|
|
963
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { children: [
|
|
964
|
+
safeCurrent + 1,
|
|
965
|
+
" / ",
|
|
966
|
+
safeTotal
|
|
967
|
+
] }),
|
|
968
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", "aria-label": "\u4E0B\u4E00\u4E2A\u5206\u652F", disabled: safeCurrent >= safeTotal - 1, onClick: () => onChange(safeCurrent + 1), children: "\u203A" })
|
|
969
|
+
] });
|
|
970
|
+
}
|
|
971
|
+
function TokenUsage({ used, limit, input, output, cached, label = "\u4E0A\u4E0B\u6587\u7528\u91CF", compact }) {
|
|
972
|
+
const percent = Math.max(0, Math.min(100, limit ? used / limit * 100 : 0));
|
|
973
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("section", { className: `hf-token-usage${compact ? " is-compact" : ""}`, children: [
|
|
974
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "hf-token-usage__ring", role: "progressbar", "aria-label": String(label), "aria-valuemin": 0, "aria-valuemax": limit, "aria-valuenow": used, style: { "--hf-token-percent": `${percent * 3.6}deg` }, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { children: [
|
|
975
|
+
Math.round(percent),
|
|
976
|
+
"%"
|
|
977
|
+
] }) }),
|
|
978
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { children: [
|
|
979
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("header", { children: [
|
|
980
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("strong", { children: label }),
|
|
981
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { children: [
|
|
982
|
+
used.toLocaleString(),
|
|
983
|
+
" / ",
|
|
984
|
+
limit.toLocaleString()
|
|
985
|
+
] })
|
|
986
|
+
] }),
|
|
987
|
+
!compact && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "hf-token-usage__details", children: [
|
|
988
|
+
input !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { children: [
|
|
989
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("i", {}),
|
|
990
|
+
"\u8F93\u5165 ",
|
|
991
|
+
input.toLocaleString()
|
|
992
|
+
] }),
|
|
993
|
+
output !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { children: [
|
|
994
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("i", {}),
|
|
995
|
+
"\u8F93\u51FA ",
|
|
996
|
+
output.toLocaleString()
|
|
997
|
+
] }),
|
|
998
|
+
cached !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { children: [
|
|
999
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("i", {}),
|
|
1000
|
+
"\u7F13\u5B58 ",
|
|
1001
|
+
cached.toLocaleString()
|
|
1002
|
+
] })
|
|
1003
|
+
] })
|
|
1004
|
+
] })
|
|
1005
|
+
] });
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
// src/components/Collaboration.tsx
|
|
1009
|
+
var import_react16 = require("react");
|
|
1010
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1011
|
+
var presenceLabel = { online: "\u5728\u7EBF", away: "\u79BB\u5F00", busy: "\u5FD9\u788C", offline: "\u79BB\u7EBF" };
|
|
1012
|
+
function Presence({ status, label, showLabel = true, pulse = true }) {
|
|
1013
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: `hf-presence is-${status}${pulse && status === "online" ? " is-pulsing" : ""}`, role: "status", children: [
|
|
1014
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("i", { "aria-hidden": "true" }),
|
|
1015
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { children: label ?? (showLabel ? presenceLabel[status] : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "hf-sr-only", children: presenceLabel[status] })) })
|
|
1016
|
+
] });
|
|
1017
|
+
}
|
|
1018
|
+
function AvatarGroup({ items, max = 4, size = "md", onMore, label = "\u534F\u4F5C\u6210\u5458" }) {
|
|
1019
|
+
const shown = items.slice(0, max), remaining = Math.max(0, items.length - shown.length);
|
|
1020
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: `hf-avatar-group hf-avatar-group--${size}`, "aria-label": label, children: [
|
|
1021
|
+
shown.map((item) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Avatar, { src: item.src, name: item.name, size, status: item.status }, item.id)),
|
|
1022
|
+
remaining > 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("button", { type: "button", "aria-label": `\u67E5\u770B\u5176\u4F59 ${remaining} \u4F4D\u6210\u5458`, onClick: onMore, children: [
|
|
1023
|
+
"+",
|
|
1024
|
+
remaining
|
|
1025
|
+
] })
|
|
1026
|
+
] });
|
|
1027
|
+
}
|
|
1028
|
+
function Comment({ item, onReply, onReact, onDelete, depth = 0 }) {
|
|
1029
|
+
const [replying, setReplying] = (0, import_react16.useState)(false), [value, setValue] = (0, import_react16.useState)("");
|
|
1030
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("article", { className: "hf-comment", style: { "--hf-comment-depth": Math.min(depth, 3) }, children: [
|
|
1031
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Avatar, { src: item.author.avatar, name: item.author.name, size: "sm" }),
|
|
1032
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { children: [
|
|
1033
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("header", { children: [
|
|
1034
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("strong", { children: item.author.name }),
|
|
1035
|
+
item.timestamp && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("time", { children: item.timestamp }),
|
|
1036
|
+
item.edited && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("small", { children: "\u5DF2\u7F16\u8F91" })
|
|
1037
|
+
] }),
|
|
1038
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "hf-comment__content", children: item.content }),
|
|
1039
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("footer", { children: [
|
|
1040
|
+
item.reactions?.map((reaction) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("button", { type: "button", className: reaction.active ? "is-active" : "", "aria-pressed": reaction.active, onClick: () => onReact?.(item.id, reaction.emoji), children: [
|
|
1041
|
+
reaction.emoji,
|
|
1042
|
+
" ",
|
|
1043
|
+
reaction.count
|
|
1044
|
+
] }, reaction.emoji)),
|
|
1045
|
+
onReply && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", onClick: () => setReplying(!replying), children: "\u56DE\u590D" }),
|
|
1046
|
+
onDelete && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", onClick: () => onDelete(item.id), children: "\u5220\u9664" })
|
|
1047
|
+
] }),
|
|
1048
|
+
replying && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("form", { className: "hf-comment__reply", onSubmit: (event) => {
|
|
1049
|
+
event.preventDefault();
|
|
1050
|
+
if (value.trim()) {
|
|
1051
|
+
onReply?.(item.id, value.trim());
|
|
1052
|
+
setValue("");
|
|
1053
|
+
setReplying(false);
|
|
1054
|
+
}
|
|
1055
|
+
}, children: [
|
|
1056
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("textarea", { autoFocus: true, "aria-label": `\u56DE\u590D ${item.author.name}`, value, onChange: (event) => setValue(event.target.value) }),
|
|
1057
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { children: [
|
|
1058
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", onClick: () => setReplying(false), children: "\u53D6\u6D88" }),
|
|
1059
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "submit", disabled: !value.trim(), children: "\u53D1\u9001\u56DE\u590D" })
|
|
1060
|
+
] })
|
|
1061
|
+
] }),
|
|
1062
|
+
item.replies?.map((reply) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Comment, { item: reply, onReply, onReact, onDelete, depth: depth + 1 }, reply.id))
|
|
1063
|
+
] })
|
|
1064
|
+
] });
|
|
1065
|
+
}
|
|
1066
|
+
function CommentThread({ comments, onReply, onReact, onDelete, empty = "\u6682\u65E0\u8BC4\u8BBA\uFF0C\u5F00\u59CB\u8BA8\u8BBA\u5427" }) {
|
|
1067
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("section", { className: "hf-comment-thread", "aria-label": "\u8BC4\u8BBA\u8BA8\u8BBA", children: comments.length ? comments.map((item) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Comment, { item, onReply, onReact, onDelete }, item.id)) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "hf-comment-thread__empty", children: empty }) });
|
|
1068
|
+
}
|
|
1069
|
+
function ActivityFeed({ items, grouped, empty = "\u6682\u65E0\u52A8\u6001" }) {
|
|
1070
|
+
if (!items.length) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "hf-activity-feed__empty", children: empty });
|
|
1071
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("ol", { className: `hf-activity-feed${grouped ? " is-grouped" : ""}`, children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("li", { children: [
|
|
1072
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "hf-activity-feed__marker", children: item.avatar ?? item.icon ?? "\u2022" }),
|
|
1073
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { children: [
|
|
1074
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("p", { children: [
|
|
1075
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("strong", { children: item.actor }),
|
|
1076
|
+
" ",
|
|
1077
|
+
item.action,
|
|
1078
|
+
" ",
|
|
1079
|
+
item.target && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("b", { children: item.target })
|
|
1080
|
+
] }),
|
|
1081
|
+
item.timestamp && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("time", { children: item.timestamp }),
|
|
1082
|
+
item.detail && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { children: item.detail })
|
|
1083
|
+
] })
|
|
1084
|
+
] }, item.id)) });
|
|
1085
|
+
}
|
|
1086
|
+
function ApprovalFlow({ steps, currentId, onApprove, onReject, orientation = "vertical" }) {
|
|
1087
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("ol", { className: `hf-approval-flow hf-approval-flow--${orientation}`, children: steps.map((step, index) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("li", { className: `is-${step.status}${currentId === step.id ? " is-current" : ""}`, children: [
|
|
1088
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { children: step.status === "approved" ? "\u2713" : step.status === "rejected" ? "\xD7" : index + 1 }),
|
|
1089
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { children: [
|
|
1090
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("header", { children: [
|
|
1091
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("strong", { children: step.title }),
|
|
1092
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("i", { children: { pending: "\u5F85\u5BA1\u6279", approved: "\u5DF2\u901A\u8FC7", rejected: "\u5DF2\u62D2\u7EDD", skipped: "\u5DF2\u8DF3\u8FC7" }[step.status] })
|
|
1093
|
+
] }),
|
|
1094
|
+
step.approver && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { children: step.approver }),
|
|
1095
|
+
step.comment && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("blockquote", { children: step.comment }),
|
|
1096
|
+
step.timestamp && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("time", { children: step.timestamp }),
|
|
1097
|
+
step.status === "pending" && currentId === step.id && (onApprove || onReject) && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("footer", { children: [
|
|
1098
|
+
onReject && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", onClick: () => onReject(step.id), children: "\u62D2\u7EDD" }),
|
|
1099
|
+
onApprove && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", onClick: () => onApprove(step.id), children: "\u901A\u8FC7" })
|
|
1100
|
+
] })
|
|
1101
|
+
] })
|
|
1102
|
+
] }, step.id)) });
|
|
1103
|
+
}
|
|
1104
|
+
function AuditLog({ events, onSelect, empty = "\u6682\u65E0\u5BA1\u8BA1\u8BB0\u5F55", caption = "\u5BA1\u8BA1\u65E5\u5FD7" }) {
|
|
1105
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "hf-audit-log", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("table", { children: [
|
|
1106
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("caption", { children: caption }),
|
|
1107
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("tr", { children: [
|
|
1108
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("th", { children: "\u65F6\u95F4" }),
|
|
1109
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("th", { children: "\u64CD\u4F5C\u8005" }),
|
|
1110
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("th", { children: "\u64CD\u4F5C" }),
|
|
1111
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("th", { children: "\u8D44\u6E90" }),
|
|
1112
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("th", { children: "\u7ED3\u679C" }),
|
|
1113
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("th", { children: "IP" })
|
|
1114
|
+
] }) }),
|
|
1115
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("tbody", { children: [
|
|
1116
|
+
events.map((event) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("tr", { tabIndex: onSelect ? 0 : void 0, onClick: () => onSelect?.(event.id), onKeyDown: (key) => {
|
|
1117
|
+
if (onSelect && (key.key === "Enter" || key.key === " ")) {
|
|
1118
|
+
key.preventDefault();
|
|
1119
|
+
onSelect(event.id);
|
|
1120
|
+
}
|
|
1121
|
+
}, children: [
|
|
1122
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("td", { children: event.timestamp }),
|
|
1123
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("td", { children: event.actor }),
|
|
1124
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("td", { children: [
|
|
1125
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("strong", { children: event.action }),
|
|
1126
|
+
event.detail && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("small", { children: event.detail })
|
|
1127
|
+
] }),
|
|
1128
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("td", { children: event.resource ?? "\u2014" }),
|
|
1129
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: `is-${event.result ?? "success"}`, children: event.result === "failure" ? "\u5931\u8D25" : event.result === "warning" ? "\u8B66\u544A" : "\u6210\u529F" }) }),
|
|
1130
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("code", { children: event.ip ?? "\u2014" }) })
|
|
1131
|
+
] }, event.id)),
|
|
1132
|
+
!events.length && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("td", { colSpan: 6, className: "hf-audit-log__empty", children: empty }) })
|
|
1133
|
+
] })
|
|
1134
|
+
] }) });
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
// src/components/Assets.tsx
|
|
1138
|
+
var import_react17 = require("react");
|
|
1139
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1140
|
+
function FileExplorer({ items, selectedId, onSelect, empty = "\u6682\u65E0\u6587\u4EF6" }) {
|
|
1141
|
+
const [open, setOpen] = (0, import_react17.useState)([]);
|
|
1142
|
+
const itemRefs = (0, import_react17.useRef)(/* @__PURE__ */ new Map());
|
|
1143
|
+
const visible = (0, import_react17.useMemo)(() => {
|
|
1144
|
+
const result = [];
|
|
1145
|
+
const visit = (nodes, level, parentId) => nodes.forEach((item) => {
|
|
1146
|
+
result.push({ item, level, parentId });
|
|
1147
|
+
if (item.children?.length && open.includes(item.id)) visit(item.children, level + 1, item.id);
|
|
1148
|
+
});
|
|
1149
|
+
visit(items, 1);
|
|
1150
|
+
return result;
|
|
1151
|
+
}, [items, open]);
|
|
1152
|
+
const toggle = (id) => setOpen((value) => value.includes(id) ? value.filter((key) => key !== id) : [...value, id]);
|
|
1153
|
+
const focusAt = (index) => itemRefs.current.get(visible[Math.max(0, Math.min(visible.length - 1, index))]?.item.id ?? "")?.focus();
|
|
1154
|
+
const onKeyDown = (event, entry, index) => {
|
|
1155
|
+
const expandable = Boolean(entry.item.children?.length);
|
|
1156
|
+
if (event.key === "ArrowDown") focusAt(index + 1);
|
|
1157
|
+
else if (event.key === "ArrowUp") focusAt(index - 1);
|
|
1158
|
+
else if (event.key === "Home") focusAt(0);
|
|
1159
|
+
else if (event.key === "End") focusAt(visible.length - 1);
|
|
1160
|
+
else if (event.key === "ArrowRight" && expandable) open.includes(entry.item.id) ? focusAt(index + 1) : toggle(entry.item.id);
|
|
1161
|
+
else if (event.key === "ArrowLeft") {
|
|
1162
|
+
if (expandable && open.includes(entry.item.id)) toggle(entry.item.id);
|
|
1163
|
+
else if (entry.parentId) itemRefs.current.get(entry.parentId)?.focus();
|
|
1164
|
+
else return;
|
|
1165
|
+
} else return;
|
|
1166
|
+
event.preventDefault();
|
|
1167
|
+
};
|
|
1168
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "hf-file-explorer", role: "tree", "aria-label": "\u6587\u4EF6\u76EE\u5F55", children: items.length ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("ul", { role: "none", children: visible.map((entry, index) => {
|
|
1169
|
+
const { item, level } = entry;
|
|
1170
|
+
const expandable = Boolean(item.children?.length);
|
|
1171
|
+
const expanded = expandable && open.includes(item.id);
|
|
1172
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("li", { role: "none", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: selectedId === item.id ? "is-selected" : "", style: { paddingLeft: (level - 1) * 18 + 7 }, children: [
|
|
1173
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "hf-file-explorer__toggle", "aria-hidden": "true", children: expandable ? expanded ? "\u2304" : "\u203A" : "" }),
|
|
1174
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("button", { type: "button", role: "treeitem", "aria-level": level, "aria-selected": selectedId === item.id, "aria-expanded": expandable ? expanded : void 0, ref: (node) => {
|
|
1175
|
+
if (node) itemRefs.current.set(item.id, node);
|
|
1176
|
+
else itemRefs.current.delete(item.id);
|
|
1177
|
+
}, onClick: () => {
|
|
1178
|
+
if (expandable) toggle(item.id);
|
|
1179
|
+
onSelect?.(item.id);
|
|
1180
|
+
}, onKeyDown: (event) => onKeyDown(event, entry, index), children: [
|
|
1181
|
+
item.icon ?? (item.type === "folder" ? "\u25B0" : "\u25A4"),
|
|
1182
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { children: [
|
|
1183
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("strong", { children: item.name }),
|
|
1184
|
+
item.modified && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("small", { children: item.modified })
|
|
1185
|
+
] }),
|
|
1186
|
+
item.size && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("i", { children: item.size })
|
|
1187
|
+
] })
|
|
1188
|
+
] }) }, item.id);
|
|
1189
|
+
}) }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { children: empty }) });
|
|
1190
|
+
}
|
|
1191
|
+
function FilePreview({ name, type, children, size, modified, actions, empty = "\u9009\u62E9\u6587\u4EF6\u540E\u5728\u6B64\u9884\u89C8" }) {
|
|
1192
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("section", { className: "hf-file-preview", children: name ? /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
|
|
1193
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("header", { children: [
|
|
1194
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { children: [
|
|
1195
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("strong", { children: name }),
|
|
1196
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: [type, size, modified].filter(Boolean).join(" \xB7 ") })
|
|
1197
|
+
] }),
|
|
1198
|
+
actions
|
|
1199
|
+
] }),
|
|
1200
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "hf-file-preview__body", children })
|
|
1201
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "hf-file-preview__empty", children: [
|
|
1202
|
+
"\u25A4",
|
|
1203
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: empty })
|
|
1204
|
+
] }) });
|
|
1205
|
+
}
|
|
1206
|
+
function VersionHistory({ versions, selectedId, onSelect, onRestore }) {
|
|
1207
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("ol", { className: "hf-version-history", children: versions.map((item) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("li", { className: `${item.current ? "is-current" : ""}${selectedId === item.id ? " is-selected" : ""}`, children: [
|
|
1208
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("button", { type: "button", onClick: () => onSelect?.(item.id), children: [
|
|
1209
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", {}),
|
|
1210
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { children: [
|
|
1211
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("header", { children: [
|
|
1212
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("strong", { children: item.version }),
|
|
1213
|
+
item.current && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("i", { children: "\u5F53\u524D\u7248\u672C" }),
|
|
1214
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("time", { children: item.timestamp })
|
|
1215
|
+
] }),
|
|
1216
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("p", { children: [
|
|
1217
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Avatar, { name: item.author.name, src: item.author.avatar, size: "sm" }),
|
|
1218
|
+
item.author.name
|
|
1219
|
+
] }),
|
|
1220
|
+
item.description && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { children: item.description }),
|
|
1221
|
+
item.tags?.map((tag) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("small", { children: tag }, tag))
|
|
1222
|
+
] })
|
|
1223
|
+
] }),
|
|
1224
|
+
onRestore && !item.current && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", onClick: () => onRestore(item.id), children: "\u6062\u590D" })
|
|
1225
|
+
] }, item.id)) });
|
|
1226
|
+
}
|
|
1227
|
+
function PermissionMatrix({ subjects, resources, value, onChange, disabled }) {
|
|
1228
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "hf-permission-matrix", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("table", { children: [
|
|
1229
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("tr", { children: [
|
|
1230
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("th", { children: "\u6210\u5458\u6216\u89D2\u8272" }),
|
|
1231
|
+
resources.map((item) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("th", { children: item.name }, item.id))
|
|
1232
|
+
] }) }),
|
|
1233
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("tbody", { children: subjects.map((subject) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("tr", { children: [
|
|
1234
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("th", { children: [
|
|
1235
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: subject.avatar }),
|
|
1236
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { children: [
|
|
1237
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("strong", { children: subject.name }),
|
|
1238
|
+
subject.description && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("small", { children: subject.description })
|
|
1239
|
+
] })
|
|
1240
|
+
] }),
|
|
1241
|
+
resources.map((resource) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("select", { "aria-label": `${String(subject.name)} \u5BF9 ${String(resource.name)} \u7684\u6743\u9650`, disabled, value: value[subject.id]?.[resource.id] ?? "none", onChange: (event) => onChange(subject.id, resource.id, event.target.value), children: [
|
|
1242
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: "none", children: "\u65E0\u6743\u9650" }),
|
|
1243
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: "view", children: "\u67E5\u770B" }),
|
|
1244
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: "comment", children: "\u8BC4\u8BBA" }),
|
|
1245
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: "edit", children: "\u7F16\u8F91" }),
|
|
1246
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: "admin", children: "\u7BA1\u7406" })
|
|
1247
|
+
] }) }, resource.id))
|
|
1248
|
+
] }, subject.id)) })
|
|
1249
|
+
] }) });
|
|
1250
|
+
}
|
|
1251
|
+
function MemberPicker({ members, value, onChange, label = "\u6DFB\u52A0\u6210\u5458", disabled }) {
|
|
1252
|
+
const [query, setQuery] = (0, import_react17.useState)("");
|
|
1253
|
+
const results = (0, import_react17.useMemo)(() => members.filter((item) => !value.includes(item.id) && `${item.name} ${String(item.description ?? "")}`.toLowerCase().includes(query.toLowerCase())), [members, query, value]);
|
|
1254
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "hf-member-picker", children: [
|
|
1255
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { children: value.map((id) => {
|
|
1256
|
+
const item = members.find((member) => member.id === id);
|
|
1257
|
+
return item && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { children: [
|
|
1258
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Avatar, { name: item.name, src: item.avatar, size: "sm" }),
|
|
1259
|
+
item.name,
|
|
1260
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", disabled, "aria-label": `\u79FB\u9664 ${item.name}`, onClick: () => onChange(value.filter((key) => key !== id)), children: "\xD7" })
|
|
1261
|
+
] }, id);
|
|
1262
|
+
}) }),
|
|
1263
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("input", { "aria-label": label, value: query, disabled, placeholder: label, onChange: (event) => setQuery(event.target.value) }),
|
|
1264
|
+
query && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "hf-member-picker__menu", children: [
|
|
1265
|
+
results.map((item) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("button", { type: "button", onClick: () => {
|
|
1266
|
+
onChange([...value, item.id]);
|
|
1267
|
+
setQuery("");
|
|
1268
|
+
}, children: [
|
|
1269
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Avatar, { name: item.name, src: item.avatar, size: "sm" }),
|
|
1270
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { children: [
|
|
1271
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("strong", { children: item.name }),
|
|
1272
|
+
item.description && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("small", { children: item.description })
|
|
1273
|
+
] })
|
|
1274
|
+
] }, item.id)),
|
|
1275
|
+
!results.length && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { children: "\u6CA1\u6709\u5339\u914D\u6210\u5458" })
|
|
1276
|
+
] })
|
|
1277
|
+
] });
|
|
1278
|
+
}
|
|
1279
|
+
function SharePanel({ scope, onScopeChange, members, onCopyLink, linkCopied, footer }) {
|
|
1280
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("section", { className: "hf-share-panel", children: [
|
|
1281
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("header", { children: [
|
|
1282
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("strong", { children: "\u5171\u4EAB\u8BBE\u7F6E" }),
|
|
1283
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: "\u63A7\u5236\u8C01\u53EF\u4EE5\u8BBF\u95EE\u6B64\u5185\u5BB9" })
|
|
1284
|
+
] }),
|
|
1285
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "hf-share-panel__scope", children: ["restricted", "organization", "public"].map((item) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { children: [
|
|
1286
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("input", { type: "radio", name: "hf-share-scope", checked: scope === item, onChange: () => onScopeChange(item) }),
|
|
1287
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { children: [
|
|
1288
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("strong", { children: { restricted: "\u4EC5\u53D7\u9080\u6210\u5458", organization: "\u7EC4\u7EC7\u5185\u6210\u5458", public: "\u62E5\u6709\u94FE\u63A5\u7684\u4EFB\u4F55\u4EBA" }[item] }),
|
|
1289
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("small", { children: { restricted: "\u53EA\u6709\u5217\u8868\u4E2D\u7684\u6210\u5458\u53EF\u4EE5\u8BBF\u95EE", organization: "\u540C\u4E00\u7EC4\u7EC7\u6210\u5458\u5747\u53EF\u8BBF\u95EE", public: "\u65E0\u9700\u767B\u5F55\u5373\u53EF\u8BBF\u95EE" }[item] })
|
|
1290
|
+
] })
|
|
1291
|
+
] }, item)) }),
|
|
1292
|
+
members && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "hf-share-panel__members", children: members }),
|
|
1293
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("footer", { children: [
|
|
1294
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", onClick: onCopyLink, children: linkCopied ? "\u94FE\u63A5\u5DF2\u590D\u5236" : "\u590D\u5236\u94FE\u63A5" }),
|
|
1295
|
+
footer
|
|
1296
|
+
] })
|
|
1297
|
+
] });
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
// src/components/Scheduling.tsx
|
|
1301
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1302
|
+
function EventCard({
|
|
1303
|
+
event,
|
|
1304
|
+
onClick
|
|
1305
|
+
}) {
|
|
1306
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
1307
|
+
"button",
|
|
1308
|
+
{
|
|
1309
|
+
type: "button",
|
|
1310
|
+
className: "hf-event-card",
|
|
1311
|
+
onClick: () => onClick?.(event.id),
|
|
1312
|
+
children: [
|
|
1313
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("strong", { children: event.title }),
|
|
1314
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("time", { children: [
|
|
1315
|
+
event.start,
|
|
1316
|
+
"\u2013",
|
|
1317
|
+
event.end
|
|
1318
|
+
] })
|
|
1319
|
+
]
|
|
1320
|
+
}
|
|
1321
|
+
);
|
|
1322
|
+
}
|
|
1323
|
+
function Scheduler({
|
|
1324
|
+
days,
|
|
1325
|
+
events,
|
|
1326
|
+
onEventClick
|
|
1327
|
+
}) {
|
|
1328
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "hf-scheduler", children: days.map((day2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("section", { children: [
|
|
1329
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("strong", { children: day2 }),
|
|
1330
|
+
events.filter((e) => e.start.startsWith(day2)).map((e) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(EventCard, { event: e, onClick: onEventClick }, e.id))
|
|
1331
|
+
] }, day2)) });
|
|
1332
|
+
}
|
|
1333
|
+
function ResourceCalendar({
|
|
1334
|
+
resources,
|
|
1335
|
+
events
|
|
1336
|
+
}) {
|
|
1337
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "hf-resource-calendar", children: resources.map((r) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("section", { children: [
|
|
1338
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("strong", { children: r.name }),
|
|
1339
|
+
events.filter((e) => e.resourceId === r.id).map((e) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(EventCard, { event: e }, e.id))
|
|
1340
|
+
] }, r.id)) });
|
|
1341
|
+
}
|
|
1342
|
+
function RecurrenceEditor({
|
|
1343
|
+
value,
|
|
1344
|
+
onChange
|
|
1345
|
+
}) {
|
|
1346
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "hf-recurrence", children: [
|
|
1347
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
1348
|
+
"select",
|
|
1349
|
+
{
|
|
1350
|
+
"aria-label": "\u91CD\u590D\u9891\u7387",
|
|
1351
|
+
value: value.frequency,
|
|
1352
|
+
onChange: (e) => onChange({
|
|
1353
|
+
...value,
|
|
1354
|
+
frequency: e.target.value
|
|
1355
|
+
}),
|
|
1356
|
+
children: [
|
|
1357
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: "none", children: "\u4E0D\u91CD\u590D" }),
|
|
1358
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: "daily", children: "\u6BCF\u5929" }),
|
|
1359
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: "weekly", children: "\u6BCF\u5468" }),
|
|
1360
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: "monthly", children: "\u6BCF\u6708" })
|
|
1361
|
+
]
|
|
1362
|
+
}
|
|
1363
|
+
),
|
|
1364
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1365
|
+
"input",
|
|
1366
|
+
{
|
|
1367
|
+
"aria-label": "\u91CD\u590D\u95F4\u9694",
|
|
1368
|
+
type: "number",
|
|
1369
|
+
min: 1,
|
|
1370
|
+
value: value.interval,
|
|
1371
|
+
onChange: (e) => onChange({ ...value, interval: +e.target.value })
|
|
1372
|
+
}
|
|
1373
|
+
)
|
|
1374
|
+
] });
|
|
1375
|
+
}
|
|
1376
|
+
function TimezoneSelect({
|
|
1377
|
+
options,
|
|
1378
|
+
value,
|
|
1379
|
+
onChange
|
|
1380
|
+
}) {
|
|
1381
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1382
|
+
"select",
|
|
1383
|
+
{
|
|
1384
|
+
"aria-label": "\u65F6\u533A",
|
|
1385
|
+
className: "hf-timezone",
|
|
1386
|
+
value,
|
|
1387
|
+
onChange: (e) => onChange(e.target.value),
|
|
1388
|
+
children: options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("option", { value: o.value, children: [
|
|
1389
|
+
o.label,
|
|
1390
|
+
" (",
|
|
1391
|
+
o.offset,
|
|
1392
|
+
")"
|
|
1393
|
+
] }, o.value))
|
|
1394
|
+
}
|
|
1395
|
+
);
|
|
1396
|
+
}
|
|
1397
|
+
function AvailabilityGrid({
|
|
1398
|
+
people,
|
|
1399
|
+
slots,
|
|
1400
|
+
value
|
|
1401
|
+
}) {
|
|
1402
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "hf-availability", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("table", { children: [
|
|
1403
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("tr", { children: [
|
|
1404
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("th", { children: "\u6210\u5458" }),
|
|
1405
|
+
slots.map((s) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("th", { children: s }, s))
|
|
1406
|
+
] }) }),
|
|
1407
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("tbody", { children: people.map((p) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("tr", { children: [
|
|
1408
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("th", { children: p.name }),
|
|
1409
|
+
slots.map((s) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("i", { className: `is-${value[p.id]?.[s] ?? "unavailable"}` }) }, s))
|
|
1410
|
+
] }, p.id)) })
|
|
1411
|
+
] }) });
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
// src/foundations/Typography.tsx
|
|
1415
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1416
|
+
function Typography({ as, variant = "body", muted, truncate, className = "", ...props }) {
|
|
1417
|
+
const defaults = { display: "h1", h1: "h1", h2: "h2", h3: "h3", code: "code" };
|
|
1418
|
+
const Tag2 = as ?? defaults[variant] ?? "p";
|
|
1419
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Tag2, { className: `hf-typography hf-typography--${variant}${muted ? " is-muted" : ""}${truncate ? " is-truncated" : ""} ${className}`, ...props });
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
// src/navigation/types.ts
|
|
1423
|
+
function activateNavigationItem(item, onItemSelect) {
|
|
1424
|
+
onItemSelect?.(item);
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
// src/navigation/FloatingNav.tsx
|
|
1428
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1429
|
+
function FloatingNav({ brand, items, action, activeKey, onItemSelect, className = "", ...props }) {
|
|
1430
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("nav", { className: `hf-floating-nav ${className}`.trim(), "aria-label": "\u4E3B\u5BFC\u822A", ...props, children: [
|
|
1431
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "hf-floating-nav__brand", children: brand }),
|
|
1432
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "hf-floating-nav__items", children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("a", { href: item.href ?? "#", "aria-current": activeKey === item.key ? "page" : void 0, onClick: () => activateNavigationItem(item, onItemSelect), children: item.label }, item.key)) }),
|
|
1433
|
+
action && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "hf-floating-nav__action", children: action })
|
|
1434
|
+
] });
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
// src/navigation/Sidebar.tsx
|
|
1438
|
+
var import_react18 = require("react");
|
|
1439
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
1440
|
+
function Sidebar({ brand, items, activeKey, collapsed, defaultCollapsed = false, onCollapsedChange, onItemSelect, appearance = "flush", className = "", ...props }) {
|
|
1441
|
+
const [internalCollapsed, setInternalCollapsed] = (0, import_react18.useState)(defaultCollapsed);
|
|
1442
|
+
const isCollapsed = collapsed ?? internalCollapsed;
|
|
1443
|
+
const toggle = () => {
|
|
1444
|
+
const next = !isCollapsed;
|
|
1445
|
+
if (collapsed === void 0) setInternalCollapsed(next);
|
|
1446
|
+
onCollapsedChange?.(next);
|
|
1447
|
+
};
|
|
1448
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("aside", { className: `hf-sidebar hf-sidebar--${appearance} ${isCollapsed ? "hf-sidebar--collapsed" : ""} ${className}`.trim(), ...props, children: [
|
|
1449
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "hf-sidebar__top", children: [
|
|
1450
|
+
brand && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "hf-sidebar__brand", children: brand }),
|
|
1451
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("button", { type: "button", onClick: toggle, "aria-label": isCollapsed ? "\u5C55\u5F00\u4FA7\u8FB9\u680F" : "\u6536\u8D77\u4FA7\u8FB9\u680F", "aria-expanded": !isCollapsed, children: "\u2039" })
|
|
1452
|
+
] }),
|
|
1453
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("nav", { "aria-label": "\u4FA7\u8FB9\u5BFC\u822A", children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("a", { href: item.href ?? "#", "aria-current": activeKey === item.key ? "page" : void 0, title: isCollapsed ? item.label : void 0, onClick: () => activateNavigationItem(item, onItemSelect), children: [
|
|
1454
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "hf-sidebar__icon", children: item.icon ?? item.label.slice(0, 1) }),
|
|
1455
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "hf-sidebar__label", children: item.label })
|
|
1456
|
+
] }, item.key)) })
|
|
1457
|
+
] });
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
// src/navigation/Breadcrumb.tsx
|
|
1461
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
1462
|
+
function Breadcrumb({ items, separator = "/", onItemSelect, className = "", ...props }) {
|
|
1463
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("nav", { className: `hf-breadcrumb ${className}`.trim(), "aria-label": "\u9762\u5305\u5C51", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("ol", { children: items.map((item, index) => {
|
|
1464
|
+
const current = index === items.length - 1;
|
|
1465
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("li", { children: [
|
|
1466
|
+
current ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { "aria-current": "page", children: item.label }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("a", { href: item.href ?? "#", onClick: () => activateNavigationItem(item, onItemSelect), children: item.label }),
|
|
1467
|
+
!current && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("i", { "aria-hidden": "true", children: separator })
|
|
1468
|
+
] }, item.key);
|
|
1469
|
+
}) }) });
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
// src/navigation/Menu.tsx
|
|
1473
|
+
var import_react19 = require("react");
|
|
1474
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
1475
|
+
function DropdownMenu({ label, items, activeKey, onItemSelect, className = "", ...props }) {
|
|
1476
|
+
const [open, setOpen] = (0, import_react19.useState)(false);
|
|
1477
|
+
const ref = useDismissibleLayer(open, () => setOpen(false), { autoFocus: false });
|
|
1478
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { ref, className: `hf-menu ${className}`.trim(), ...props, children: [
|
|
1479
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("button", { type: "button", "aria-expanded": open, "aria-haspopup": "menu", onClick: () => setOpen((value) => !value), children: [
|
|
1480
|
+
label,
|
|
1481
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { "aria-hidden": "true", children: "\u2304" })
|
|
1482
|
+
] }),
|
|
1483
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "hf-menu__panel", role: "menu", children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("a", { role: "menuitem", href: item.href ?? "#", "aria-current": activeKey === item.key ? "page" : void 0, onClick: () => {
|
|
1484
|
+
activateNavigationItem(item, onItemSelect);
|
|
1485
|
+
setOpen(false);
|
|
1486
|
+
}, children: item.label }, item.key)) })
|
|
1487
|
+
] });
|
|
1488
|
+
}
|
|
1489
|
+
function MegaMenu({ label, items, onItemSelect, className = "", ...props }) {
|
|
1490
|
+
const [open, setOpen] = (0, import_react19.useState)(false);
|
|
1491
|
+
const ref = useDismissibleLayer(open, () => setOpen(false), { autoFocus: false });
|
|
1492
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { ref, className: `hf-menu hf-mega-menu ${className}`.trim(), ...props, children: [
|
|
1493
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("button", { type: "button", "aria-expanded": open, "aria-haspopup": "menu", onClick: () => setOpen((value) => !value), children: [
|
|
1494
|
+
label,
|
|
1495
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { "aria-hidden": "true", children: "\u2304" })
|
|
1496
|
+
] }),
|
|
1497
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "hf-mega-menu__panel", role: "menu", children: items.map((group) => /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("section", { children: [
|
|
1498
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("h3", { children: group.label }),
|
|
1499
|
+
group.children?.map((item) => /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("a", { role: "menuitem", href: item.href ?? "#", onClick: () => {
|
|
1500
|
+
activateNavigationItem(item, onItemSelect);
|
|
1501
|
+
setOpen(false);
|
|
1502
|
+
}, children: [
|
|
1503
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { children: item.icon }),
|
|
1504
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("span", { children: [
|
|
1505
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("strong", { children: item.label }),
|
|
1506
|
+
item.description && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("small", { children: item.description })
|
|
1507
|
+
] })
|
|
1508
|
+
] }, item.key))
|
|
1509
|
+
] }, group.key)) })
|
|
1510
|
+
] });
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
// src/navigation/MobileNavigation.tsx
|
|
1514
|
+
var import_react20 = require("react");
|
|
1515
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
1516
|
+
function MobileNavigation({ brand, items, mode = "drawer", activeKey, open, onOpenChange, onItemSelect, className = "", ...props }) {
|
|
1517
|
+
const [internalOpen, setInternalOpen] = (0, import_react20.useState)(false);
|
|
1518
|
+
const isOpen = open ?? internalOpen;
|
|
1519
|
+
const panelId = (0, import_react20.useId)();
|
|
1520
|
+
const setOpen = (next) => {
|
|
1521
|
+
if (open === void 0) setInternalOpen(next);
|
|
1522
|
+
onOpenChange?.(next);
|
|
1523
|
+
};
|
|
1524
|
+
const panelRef = useDismissibleLayer(isOpen, () => setOpen(false), true);
|
|
1525
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: `hf-mobile-nav ${className}`.trim(), ...props, children: [
|
|
1526
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "hf-mobile-nav__bar", children: [
|
|
1527
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { children: brand }),
|
|
1528
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("button", { type: "button", "aria-label": "\u6253\u5F00\u5BFC\u822A", "aria-expanded": isOpen, "aria-controls": panelId, onClick: () => setOpen(true), children: [
|
|
1529
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("i", {}),
|
|
1530
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("i", {}),
|
|
1531
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("i", {})
|
|
1532
|
+
] })
|
|
1533
|
+
] }),
|
|
1534
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: `hf-mobile-nav__backdrop hf-mobile-nav__backdrop--${mode}`, onMouseDown: (event) => event.target === event.currentTarget && setOpen(false), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("nav", { ref: panelRef, id: panelId, className: "hf-mobile-nav__panel", "aria-label": "\u79FB\u52A8\u5BFC\u822A", tabIndex: -1, children: [
|
|
1535
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("header", { children: [
|
|
1536
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { children: brand }),
|
|
1537
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("button", { type: "button", "aria-label": "\u5173\u95ED\u5BFC\u822A", onClick: () => setOpen(false), children: "\xD7" })
|
|
1538
|
+
] }),
|
|
1539
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "hf-mobile-nav__links", children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("a", { href: item.href ?? "#", "aria-current": activeKey === item.key ? "page" : void 0, style: { "--hf-nav-index": index }, onClick: () => {
|
|
1540
|
+
activateNavigationItem(item, onItemSelect);
|
|
1541
|
+
setOpen(false);
|
|
1542
|
+
}, children: [
|
|
1543
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { children: item.label }),
|
|
1544
|
+
item.description && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("small", { children: item.description })
|
|
1545
|
+
] }, item.key)) })
|
|
1546
|
+
] }) })
|
|
1547
|
+
] });
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
// src/navigation/Scrollspy.tsx
|
|
1551
|
+
var import_react21 = require("react");
|
|
1552
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
1553
|
+
function Scrollspy({ items, activeKey, onItemSelect, rootMargin = "-20% 0px -65%", className = "", ...props }) {
|
|
1554
|
+
const [observedKey, setObservedKey] = (0, import_react21.useState)(items[0]?.key);
|
|
1555
|
+
const currentKey = activeKey ?? observedKey;
|
|
1556
|
+
(0, import_react21.useEffect)(() => {
|
|
1557
|
+
if (activeKey || !("IntersectionObserver" in window)) return;
|
|
1558
|
+
const observer = new IntersectionObserver((entries) => {
|
|
1559
|
+
const visible = entries.find((entry) => entry.isIntersecting);
|
|
1560
|
+
if (visible?.target.id) setObservedKey(visible.target.id);
|
|
1561
|
+
}, { rootMargin });
|
|
1562
|
+
items.forEach((item) => {
|
|
1563
|
+
const section = document.getElementById(item.key);
|
|
1564
|
+
if (section) observer.observe(section);
|
|
1565
|
+
});
|
|
1566
|
+
return () => observer.disconnect();
|
|
1567
|
+
}, [activeKey, items, rootMargin]);
|
|
1568
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("nav", { className: `hf-scrollspy ${className}`.trim(), "aria-label": "\u9875\u5185\u5BFC\u822A", ...props, children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("a", { href: item.href ?? `#${item.key}`, "aria-current": currentKey === item.key ? "location" : void 0, onClick: () => onItemSelect?.(item), children: item.label }, item.key)) });
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
// src/navigation/ShrinkNav.tsx
|
|
1572
|
+
var import_react22 = require("react");
|
|
1573
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
1574
|
+
function ShrinkNav({ brand, items, threshold = 48, action, activeKey, onItemSelect, className = "", ...props }) {
|
|
1575
|
+
const [compact, setCompact] = (0, import_react22.useState)(false);
|
|
1576
|
+
(0, import_react22.useEffect)(() => {
|
|
1577
|
+
let frame = 0;
|
|
1578
|
+
const update = () => {
|
|
1579
|
+
cancelAnimationFrame(frame);
|
|
1580
|
+
frame = requestAnimationFrame(() => setCompact(window.scrollY > threshold));
|
|
1581
|
+
};
|
|
1582
|
+
update();
|
|
1583
|
+
window.addEventListener("scroll", update, { passive: true });
|
|
1584
|
+
return () => {
|
|
1585
|
+
cancelAnimationFrame(frame);
|
|
1586
|
+
window.removeEventListener("scroll", update);
|
|
1587
|
+
};
|
|
1588
|
+
}, [threshold]);
|
|
1589
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("nav", { className: `hf-shrink-nav ${compact ? "hf-shrink-nav--compact" : ""} ${className}`.trim(), "aria-label": "\u6EDA\u52A8\u5BFC\u822A", ...props, children: [
|
|
1590
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "hf-shrink-nav__brand", children: brand }),
|
|
1591
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "hf-shrink-nav__items", children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("a", { href: item.href ?? "#", "aria-current": activeKey === item.key ? "page" : void 0, onClick: () => onItemSelect?.(item), children: item.label }, item.key)) }),
|
|
1592
|
+
action
|
|
1593
|
+
] });
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
// src/navigation/Tabs.tsx
|
|
1597
|
+
var import_react23 = require("react");
|
|
1598
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
1599
|
+
function Tabs({ items, value, onChange, variant = "line", label = "\u5185\u5BB9\u6807\u7B7E" }) {
|
|
1600
|
+
const id = (0, import_react23.useId)();
|
|
1601
|
+
const active = items.find((item) => item.key === value) ?? items[0];
|
|
1602
|
+
const onKeyDown = (event) => {
|
|
1603
|
+
if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(event.key)) return;
|
|
1604
|
+
event.preventDefault();
|
|
1605
|
+
const enabled = items.filter((item) => !item.disabled);
|
|
1606
|
+
const current = enabled.findIndex((item) => item.key === value);
|
|
1607
|
+
const offset = event.key === "ArrowLeft" || event.key === "ArrowUp" ? -1 : 1;
|
|
1608
|
+
const next = enabled[(current + offset + enabled.length) % enabled.length];
|
|
1609
|
+
if (next) onChange(next.key);
|
|
1610
|
+
};
|
|
1611
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: `hf-tabs hf-tabs--${variant}`, children: [
|
|
1612
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { role: "tablist", "aria-label": label, onKeyDown, children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("button", { type: "button", role: "tab", id: `${id}-${item.key}`, "aria-controls": `${id}-${item.key}-panel`, "aria-selected": item.key === value, tabIndex: item.key === value ? 0 : -1, disabled: item.disabled, onClick: () => onChange(item.key), children: [
|
|
1613
|
+
item.icon,
|
|
1614
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { children: item.label }),
|
|
1615
|
+
item.badge && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("small", { children: item.badge })
|
|
1616
|
+
] }, item.key)) }),
|
|
1617
|
+
active && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { role: "tabpanel", id: `${id}-${active.key}-panel`, "aria-labelledby": `${id}-${active.key}`, tabIndex: 0, children: active.content })
|
|
1618
|
+
] });
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
// src/navigation/Steps.tsx
|
|
1622
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
1623
|
+
function Steps({ items, current, onChange, orientation = "horizontal" }) {
|
|
1624
|
+
const currentIndex = Math.max(0, items.findIndex((item) => item.key === current));
|
|
1625
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("ol", { className: `hf-steps hf-steps--${orientation}`, children: items.map((item, index) => {
|
|
1626
|
+
const state = index < currentIndex ? "complete" : index === currentIndex ? "current" : "upcoming";
|
|
1627
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("li", { className: `is-${state}`, "aria-current": state === "current" ? "step" : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("button", { type: "button", disabled: item.disabled || !onChange, onClick: () => onChange?.(item.key), children: [
|
|
1628
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { children: state === "complete" ? "\u2713" : index + 1 }),
|
|
1629
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("span", { children: [
|
|
1630
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("strong", { children: item.title }),
|
|
1631
|
+
item.optional && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("small", { children: "\u53EF\u9009" }),
|
|
1632
|
+
item.description && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("small", { children: item.description })
|
|
1633
|
+
] })
|
|
1634
|
+
] }) }, item.key);
|
|
1635
|
+
}) });
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
// src/navigation/CommandPalette.tsx
|
|
1639
|
+
var import_react24 = require("react");
|
|
1640
|
+
var import_react_dom3 = require("react-dom");
|
|
1641
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
1642
|
+
function CommandPalette({ open, onOpenChange, items, onSelect, placeholder = "\u8F93\u5165\u547D\u4EE4\u6216\u641C\u7D22\u2026" }) {
|
|
1643
|
+
const [query, setQuery] = (0, import_react24.useState)("");
|
|
1644
|
+
const [active, setActive] = (0, import_react24.useState)(0);
|
|
1645
|
+
const enabled = (0, import_react24.useMemo)(() => items.filter((item) => !item.disabled && `${item.label} ${item.description ?? ""} ${item.group ?? ""}`.toLowerCase().includes(query.toLowerCase())), [items, query]);
|
|
1646
|
+
const dialogRef = useDismissibleLayer(open, () => onOpenChange(false), true);
|
|
1647
|
+
(0, import_react24.useEffect)(() => {
|
|
1648
|
+
if (!open) {
|
|
1649
|
+
setQuery("");
|
|
1650
|
+
setActive(0);
|
|
1651
|
+
}
|
|
1652
|
+
}, [open]);
|
|
1653
|
+
const keydown = (event) => {
|
|
1654
|
+
if (!enabled.length) return;
|
|
1655
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
1656
|
+
event.preventDefault();
|
|
1657
|
+
setActive((current) => (current + (event.key === "ArrowDown" ? 1 : -1) + enabled.length) % enabled.length);
|
|
1658
|
+
} else if (event.key === "Home" || event.key === "End") {
|
|
1659
|
+
event.preventDefault();
|
|
1660
|
+
setActive(event.key === "Home" ? 0 : enabled.length - 1);
|
|
1661
|
+
} else if (event.key === "Enter") {
|
|
1662
|
+
event.preventDefault();
|
|
1663
|
+
const item = enabled[active];
|
|
1664
|
+
if (item) {
|
|
1665
|
+
onSelect(item.key);
|
|
1666
|
+
onOpenChange(false);
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
};
|
|
1670
|
+
if (!open) return null;
|
|
1671
|
+
return (0, import_react_dom3.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "hf-command-backdrop", onMouseDown: (event) => event.target === event.currentTarget && onOpenChange(false), children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { ref: dialogRef, tabIndex: -1, className: "hf-command", role: "dialog", "aria-modal": "true", "aria-label": "\u547D\u4EE4\u9762\u677F", children: [
|
|
1672
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "hf-command__search", children: [
|
|
1673
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { "aria-hidden": "true", children: "\u2315" }),
|
|
1674
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("input", { autoFocus: true, role: "combobox", "aria-expanded": "true", "aria-controls": "hf-command-list", value: query, placeholder, onChange: (event) => {
|
|
1675
|
+
setQuery(event.target.value);
|
|
1676
|
+
setActive(0);
|
|
1677
|
+
}, onKeyDown: keydown }),
|
|
1678
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("kbd", { children: "Esc" })
|
|
1679
|
+
] }),
|
|
1680
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { id: "hf-command-list", className: "hf-command__list", role: "listbox", children: [
|
|
1681
|
+
enabled.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("button", { type: "button", role: "option", "aria-selected": index === active, onPointerMove: () => setActive(index), onClick: () => {
|
|
1682
|
+
onSelect(item.key);
|
|
1683
|
+
onOpenChange(false);
|
|
1684
|
+
}, children: [
|
|
1685
|
+
item.icon,
|
|
1686
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("span", { children: [
|
|
1687
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("strong", { children: item.label }),
|
|
1688
|
+
item.description && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("small", { children: item.description })
|
|
1689
|
+
] }),
|
|
1690
|
+
item.shortcut && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("kbd", { children: item.shortcut })
|
|
1691
|
+
] }, item.key)),
|
|
1692
|
+
!enabled.length && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "hf-command__empty", children: "\u6CA1\u6709\u5339\u914D\u547D\u4EE4" })
|
|
1693
|
+
] })
|
|
1694
|
+
] }) }), document.body);
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
// src/layout/Layout.tsx
|
|
1698
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
1699
|
+
function Container({ size = "lg", padding = 24, className = "", style, ...props }) {
|
|
1700
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: `hf-container hf-container--${size} ${className}`.trim(), style: { "--hf-container-padding": `${padding}px`, ...style }, ...props });
|
|
1701
|
+
}
|
|
1702
|
+
function Stack({ direction = "column", gap = 12, align, justify, wrap = false, className = "", style, ...props }) {
|
|
1703
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: `hf-stack hf-stack--${direction} ${className}`.trim(), style: { "--hf-stack-gap": `${gap}px`, alignItems: align, justifyContent: justify, flexWrap: wrap ? "wrap" : void 0, ...style }, ...props });
|
|
1704
|
+
}
|
|
1705
|
+
function Grid({ columns = "auto", minItemWidth = 240, gap = 16, className = "", style, ...props }) {
|
|
1706
|
+
const gridStyle = {
|
|
1707
|
+
"--hf-grid-columns": columns === "auto" ? `repeat(auto-fit, minmax(min(100%, ${minItemWidth}px), 1fr))` : `repeat(${columns}, minmax(0, 1fr))`,
|
|
1708
|
+
"--hf-grid-gap": `${gap}px`,
|
|
1709
|
+
...style
|
|
1710
|
+
};
|
|
1711
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: `hf-grid ${className}`.trim(), style: gridStyle, ...props });
|
|
1712
|
+
}
|
|
1713
|
+
function Masonry({ columns, minColumnWidth = 260, gap = 16, className = "", style, children, ...props }) {
|
|
1714
|
+
const masonryStyle = {
|
|
1715
|
+
"--hf-masonry-columns": columns ?? "auto",
|
|
1716
|
+
"--hf-masonry-width": `${minColumnWidth}px`,
|
|
1717
|
+
"--hf-masonry-gap": `${gap}px`,
|
|
1718
|
+
...style
|
|
1719
|
+
};
|
|
1720
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: `hf-masonry ${className}`.trim(), style: masonryStyle, ...props, children });
|
|
1721
|
+
}
|
|
1722
|
+
function PageLayout({ variant = "single", sidebar, header, sidebarWidth = 280, className = "", style, children, ...props }) {
|
|
1723
|
+
const layoutStyle = { "--hf-layout-sidebar": `${sidebarWidth}px`, ...style };
|
|
1724
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: `hf-page-layout hf-page-layout--${variant} ${className}`.trim(), style: layoutStyle, ...props, children: [
|
|
1725
|
+
header && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("header", { className: "hf-page-layout__header", children: header }),
|
|
1726
|
+
sidebar && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("aside", { className: "hf-page-layout__sidebar", children: sidebar }),
|
|
1727
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("main", { className: "hf-page-layout__main", children })
|
|
1728
|
+
] });
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
// src/layout/Skeleton.tsx
|
|
1732
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
1733
|
+
function Skeleton({ width = "100%", height = 16, radius, circle, animated = true, className = "", style, ...props }) {
|
|
1734
|
+
const value = (input) => typeof input === "number" ? `${input}px` : input;
|
|
1735
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { "aria-hidden": "true", className: `hf-skeleton ${animated ? "is-animated" : ""} ${circle ? "is-circle" : ""} ${className}`.trim(), style: { width: value(width), height: value(height), borderRadius: radius ? value(radius) : void 0, ...style }, ...props });
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
// src/feedback/Loading.tsx
|
|
1739
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
1740
|
+
function Spinner({ label = "\u6B63\u5728\u52A0\u8F7D", size = 20, className = "" }) {
|
|
1741
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: `hf-loading-spinner ${className}`.trim(), role: "status", "aria-label": label, style: { "--hf-loading-size": `${size}px` } });
|
|
1742
|
+
}
|
|
1743
|
+
function LoadingDots({ label = "\u6B63\u5728\u52A0\u8F7D" }) {
|
|
1744
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("span", { className: "hf-loading-dots", role: "status", "aria-label": label, children: [
|
|
1745
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("i", {}),
|
|
1746
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("i", {}),
|
|
1747
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("i", {})
|
|
1748
|
+
] });
|
|
1749
|
+
}
|
|
1750
|
+
function ProgressBar({ value, label, indeterminate = false, className = "" }) {
|
|
1751
|
+
const percent = Math.min(100, Math.max(0, value ?? 0));
|
|
1752
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: `hf-progress ${indeterminate ? "is-indeterminate" : ""} ${className}`.trim(), children: [
|
|
1753
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "hf-progress__label", children: [
|
|
1754
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { children: label }),
|
|
1755
|
+
!indeterminate && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("strong", { children: [
|
|
1756
|
+
percent,
|
|
1757
|
+
"%"
|
|
1758
|
+
] })
|
|
1759
|
+
] }),
|
|
1760
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "hf-progress__track", role: "progressbar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": indeterminate ? void 0 : percent, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("i", { style: { "--hf-progress": `${percent}%` } }) })
|
|
1761
|
+
] });
|
|
1762
|
+
}
|
|
1763
|
+
function ProgressRing({ value, size = 72, label }) {
|
|
1764
|
+
const percent = Math.min(100, Math.max(0, value));
|
|
1765
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "hf-progress-ring", role: "progressbar", "aria-label": label, "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": percent, style: { "--hf-ring-value": `${percent * 3.6}deg`, "--hf-ring-size": `${size}px` }, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("strong", { children: [
|
|
1766
|
+
percent,
|
|
1767
|
+
"%"
|
|
1768
|
+
] }) });
|
|
1769
|
+
}
|
|
1770
|
+
function LoadingOverlay({ active = true, label = "\u6B63\u5728\u51C6\u5907\u5185\u5BB9", className = "", children, ...props }) {
|
|
1771
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: `hf-loading-overlay ${className}`.trim(), "aria-busy": active, ...props, children: [
|
|
1772
|
+
children,
|
|
1773
|
+
active && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "hf-loading-overlay__veil", role: "status", children: [
|
|
1774
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Spinner, { label, size: 28 }),
|
|
1775
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { children: label })
|
|
1776
|
+
] })
|
|
1777
|
+
] });
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
// src/forms/Select.tsx
|
|
1781
|
+
var import_react25 = require("react");
|
|
1782
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
1783
|
+
var Select = (0, import_react25.forwardRef)(function Select2({ id, label, hint, error, options, placeholder, className = "", value, defaultValue, onChange, disabled, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...props }, forwardedRef) {
|
|
1784
|
+
const generatedId = (0, import_react25.useId)();
|
|
1785
|
+
const inputId = id ?? generatedId;
|
|
1786
|
+
const triggerId = `${inputId}-trigger`;
|
|
1787
|
+
const listboxId = `${inputId}-listbox`;
|
|
1788
|
+
const descriptionId = `${inputId}-description`;
|
|
1789
|
+
const [open, setOpen] = (0, import_react25.useState)(false);
|
|
1790
|
+
const rootRef = useDismissibleLayer(open, () => setOpen(false), { autoFocus: false });
|
|
1791
|
+
const nativeRef = (0, import_react25.useRef)(null);
|
|
1792
|
+
const [innerValue, setInnerValue] = (0, import_react25.useState)(() => String(defaultValue ?? (placeholder ? "" : options.find((option) => !option.disabled)?.value ?? "")));
|
|
1793
|
+
const selectedValue = value === void 0 ? innerValue : String(value);
|
|
1794
|
+
const selectedOption = options.find((option) => option.value === selectedValue);
|
|
1795
|
+
const enabledIndices = options.map((option, index) => option.disabled ? -1 : index).filter((index) => index >= 0);
|
|
1796
|
+
const selectedIndex = options.findIndex((option) => option.value === selectedValue);
|
|
1797
|
+
const [activeIndex, setActiveIndex] = (0, import_react25.useState)(selectedIndex >= 0 ? selectedIndex : enabledIndices[0] ?? -1);
|
|
1798
|
+
const assignRef = (node) => {
|
|
1799
|
+
nativeRef.current = node;
|
|
1800
|
+
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
1801
|
+
else if (forwardedRef) forwardedRef.current = node;
|
|
1802
|
+
};
|
|
1803
|
+
const handleNativeChange = (event) => {
|
|
1804
|
+
if (value === void 0) setInnerValue(event.currentTarget.value);
|
|
1805
|
+
onChange?.(event);
|
|
1806
|
+
};
|
|
1807
|
+
const choose = (nextValue) => {
|
|
1808
|
+
const native = nativeRef.current;
|
|
1809
|
+
if (!native) return;
|
|
1810
|
+
Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, "value")?.set?.call(native, nextValue);
|
|
1811
|
+
native.dispatchEvent(new Event("change", { bubbles: true }));
|
|
1812
|
+
if (value === void 0) setInnerValue(nextValue);
|
|
1813
|
+
setOpen(false);
|
|
1814
|
+
window.requestAnimationFrame(() => document.getElementById(triggerId)?.focus());
|
|
1815
|
+
};
|
|
1816
|
+
(0, import_react25.useEffect)(() => {
|
|
1817
|
+
if (selectedIndex >= 0) setActiveIndex(selectedIndex);
|
|
1818
|
+
}, [selectedIndex]);
|
|
1819
|
+
const move = (direction) => {
|
|
1820
|
+
if (!enabledIndices.length) return;
|
|
1821
|
+
const current = enabledIndices.indexOf(activeIndex);
|
|
1822
|
+
const next = current < 0 ? 0 : (current + direction + enabledIndices.length) % enabledIndices.length;
|
|
1823
|
+
setActiveIndex(enabledIndices[next]);
|
|
1824
|
+
};
|
|
1825
|
+
const handleKeyDown = (event) => {
|
|
1826
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
1827
|
+
event.preventDefault();
|
|
1828
|
+
if (!open) setOpen(true);
|
|
1829
|
+
move(event.key === "ArrowDown" ? 1 : -1);
|
|
1830
|
+
} else if ((event.key === "Enter" || event.key === " ") && open) {
|
|
1831
|
+
event.preventDefault();
|
|
1832
|
+
const option = options[activeIndex];
|
|
1833
|
+
if (option && !option.disabled) choose(option.value);
|
|
1834
|
+
} else if (event.key === "Escape" && open) {
|
|
1835
|
+
event.preventDefault();
|
|
1836
|
+
setOpen(false);
|
|
1837
|
+
} else if (event.key === "Home" && open && enabledIndices.length) {
|
|
1838
|
+
event.preventDefault();
|
|
1839
|
+
setActiveIndex(enabledIndices[0]);
|
|
1840
|
+
} else if (event.key === "End" && open && enabledIndices.length) {
|
|
1841
|
+
event.preventDefault();
|
|
1842
|
+
setActiveIndex(enabledIndices[enabledIndices.length - 1]);
|
|
1843
|
+
} else if (event.key === "Tab") setOpen(false);
|
|
1844
|
+
};
|
|
1845
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: `hf-field ${className}`.trim(), ref: rootRef, children: [
|
|
1846
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("label", { className: "hf-field__label", htmlFor: triggerId, children: label }),
|
|
1847
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: `hf-select-shell ${open ? "hf-select-shell--open" : ""} ${error ? "hf-select-shell--error" : ""}`, children: [
|
|
1848
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("select", { ref: assignRef, id: inputId, className: "hf-select-native", tabIndex: -1, "aria-hidden": "true", value: selectedValue, disabled, onChange: handleNativeChange, ...props, children: [
|
|
1849
|
+
placeholder && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("option", { value: "", disabled: true, children: placeholder }),
|
|
1850
|
+
options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("option", { value: option.value, disabled: option.disabled, children: typeof option.label === "string" ? option.label : option.value }, option.value))
|
|
1851
|
+
] }),
|
|
1852
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("button", { id: triggerId, type: "button", className: "hf-select", disabled, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-haspopup": "listbox", "aria-expanded": open, "aria-controls": open ? listboxId : void 0, "aria-activedescendant": open && activeIndex >= 0 ? `${listboxId}-option-${activeIndex}` : void 0, "aria-invalid": Boolean(error), "aria-describedby": hint || error ? descriptionId : void 0, onClick: () => {
|
|
1853
|
+
setActiveIndex(selectedIndex >= 0 ? selectedIndex : enabledIndices[0] ?? -1);
|
|
1854
|
+
setOpen((current) => !current);
|
|
1855
|
+
}, onKeyDown: handleKeyDown, children: [
|
|
1856
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: !selectedOption ? "hf-select__placeholder" : "", children: selectedOption?.label ?? placeholder ?? "\u8BF7\u9009\u62E9" }),
|
|
1857
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("svg", { className: "hf-select__chevron", viewBox: "0 0 16 16", width: "16", height: "16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("path", { d: open ? "m4.5 9.75 3.5-3.5 3.5 3.5" : "m4.5 6.25 3.5 3.5 3.5-3.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
1858
|
+
] }),
|
|
1859
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { id: listboxId, className: "hf-select-menu", role: "listbox", "aria-labelledby": triggerId, children: options.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("button", { id: `${listboxId}-option-${index}`, type: "button", role: "option", "aria-selected": option.value === selectedValue, disabled: option.disabled, className: index === activeIndex ? "is-active" : "", onPointerMove: () => !option.disabled && setActiveIndex(index), onClick: () => choose(option.value), children: [
|
|
1860
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { children: option.label }),
|
|
1861
|
+
option.value === selectedValue && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("svg", { viewBox: "0 0 16 16", width: "16", height: "16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("path", { d: "m3.5 8 3 3 6-6", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
1862
|
+
] }, option.value)) })
|
|
1863
|
+
] }),
|
|
1864
|
+
(error || hint) && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { id: descriptionId, className: `hf-field__hint ${error ? "hf-field__hint--error" : ""}`, children: error ?? hint })
|
|
1865
|
+
] });
|
|
1866
|
+
});
|
|
1867
|
+
|
|
1868
|
+
// src/forms/MultiSelect.tsx
|
|
1869
|
+
var import_react26 = require("react");
|
|
1870
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
1871
|
+
function MultiSelect({ label, options, value, onChange, placeholder = "\u8BF7\u9009\u62E9", max, hint, disabled }) {
|
|
1872
|
+
const [open, setOpen] = (0, import_react26.useState)(false);
|
|
1873
|
+
const rootRef = useDismissibleLayer(open, () => setOpen(false), { autoFocus: false });
|
|
1874
|
+
const listId = (0, import_react26.useId)();
|
|
1875
|
+
const toggle = (next) => {
|
|
1876
|
+
const selected = value.includes(next);
|
|
1877
|
+
if (!selected && max && value.length >= max) return;
|
|
1878
|
+
onChange(selected ? value.filter((item) => item !== next) : [...value, next]);
|
|
1879
|
+
};
|
|
1880
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "hf-field hf-multiselect", ref: rootRef, children: [
|
|
1881
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "hf-field__label", children: label }),
|
|
1882
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "hf-multiselect__trigger", role: "combobox", tabIndex: disabled ? -1 : 0, "aria-disabled": disabled, "aria-expanded": open, "aria-controls": listId, onClick: () => !disabled && setOpen(!open), onKeyDown: (event) => {
|
|
1883
|
+
if (!disabled && (event.key === "Enter" || event.key === " ")) {
|
|
1884
|
+
event.preventDefault();
|
|
1885
|
+
setOpen(!open);
|
|
1886
|
+
}
|
|
1887
|
+
}, children: [
|
|
1888
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { children: value.length ? value.map((item) => {
|
|
1889
|
+
const option = options.find((candidate) => candidate.value === item);
|
|
1890
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("i", { children: [
|
|
1891
|
+
option?.label,
|
|
1892
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("button", { type: "button", "aria-label": `\u79FB\u9664 ${String(option?.label)}`, onClick: (event) => {
|
|
1893
|
+
event.stopPropagation();
|
|
1894
|
+
toggle(item);
|
|
1895
|
+
}, children: "\xD7" })
|
|
1896
|
+
] }, item);
|
|
1897
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("em", { children: placeholder }) }),
|
|
1898
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Icon, { name: "chevron-down", size: 16, className: "hf-multiselect__chevron" })
|
|
1899
|
+
] }),
|
|
1900
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { id: listId, className: "hf-multiselect__menu", role: "listbox", "aria-multiselectable": "true", children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("button", { type: "button", role: "option", "aria-selected": value.includes(option.value), disabled: option.disabled, onClick: () => toggle(option.value), children: [
|
|
1901
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { children: option.label }),
|
|
1902
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("i", { children: value.includes(option.value) ? "\u2713" : "" })
|
|
1903
|
+
] }, option.value)) }),
|
|
1904
|
+
hint && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "hf-field__hint", children: hint })
|
|
1905
|
+
] });
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
// src/forms/ChoiceGroup.tsx
|
|
1909
|
+
var import_react27 = require("react");
|
|
1910
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
1911
|
+
function ChoiceGroup({ label, options, value, defaultValue, onChange, type = "radio", direction = "column", disabled, name }) {
|
|
1912
|
+
const id = (0, import_react27.useId)();
|
|
1913
|
+
const groupName = name ?? id;
|
|
1914
|
+
const values = Array.isArray(value) ? value : value ? [value] : void 0;
|
|
1915
|
+
const defaults = Array.isArray(defaultValue) ? defaultValue : defaultValue ? [defaultValue] : [];
|
|
1916
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("fieldset", { className: `hf-choice-group hf-choice-group--${direction}`, disabled, children: [
|
|
1917
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("legend", { children: label }),
|
|
1918
|
+
options.map((option) => {
|
|
1919
|
+
const checked = values?.includes(option.value);
|
|
1920
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("label", { className: "hf-choice", children: [
|
|
1921
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("input", { type, name: type === "radio" ? groupName : `${groupName}-${option.value}`, value: option.value, checked, defaultChecked: values ? void 0 : defaults.includes(option.value), disabled: option.disabled, onChange: (event) => {
|
|
1922
|
+
if (type === "radio") onChange?.(option.value);
|
|
1923
|
+
else {
|
|
1924
|
+
const next = new Set(values ?? defaults);
|
|
1925
|
+
event.currentTarget.checked ? next.add(option.value) : next.delete(option.value);
|
|
1926
|
+
onChange?.([...next]);
|
|
1927
|
+
}
|
|
1928
|
+
} }),
|
|
1929
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "hf-choice__control", "aria-hidden": "true" }),
|
|
1930
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("span", { className: "hf-choice__copy", children: [
|
|
1931
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("strong", { children: option.label }),
|
|
1932
|
+
option.description && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("small", { children: option.description })
|
|
1933
|
+
] })
|
|
1934
|
+
] }, option.value);
|
|
1935
|
+
})
|
|
1936
|
+
] });
|
|
1937
|
+
}
|
|
1938
|
+
function RadioGroup(props) {
|
|
1939
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ChoiceGroup, { ...props, type: "radio", onChange: (next) => props.onChange?.(next) });
|
|
1940
|
+
}
|
|
1941
|
+
function CheckboxGroup(props) {
|
|
1942
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ChoiceGroup, { ...props, type: "checkbox", onChange: (next) => props.onChange?.(next) });
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
// src/forms/ValidatedInput.tsx
|
|
1946
|
+
var import_react28 = require("react");
|
|
1947
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
1948
|
+
function validateValue(value, rules) {
|
|
1949
|
+
return rules.find((rule) => !rule.validate(value))?.message;
|
|
1950
|
+
}
|
|
1951
|
+
function ValidatedInput({ value, rules, validateOn = "blur", onChange, onValidityChange, ...props }) {
|
|
1952
|
+
const [touched, setTouched] = (0, import_react28.useState)(false);
|
|
1953
|
+
const error = touched ? validateValue(value, rules) : void 0;
|
|
1954
|
+
const update = (next) => {
|
|
1955
|
+
onChange(next);
|
|
1956
|
+
if (validateOn === "change") setTouched(true);
|
|
1957
|
+
onValidityChange?.(!validateValue(next, rules));
|
|
1958
|
+
};
|
|
1959
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Input, { ...props, value, error, onChange: (event) => update(event.target.value), onBlur: () => setTouched(true) });
|
|
1960
|
+
}
|
|
1961
|
+
function validateForm(event) {
|
|
1962
|
+
if (!event.currentTarget.checkValidity()) {
|
|
1963
|
+
event.preventDefault();
|
|
1964
|
+
event.currentTarget.reportValidity();
|
|
1965
|
+
return false;
|
|
1966
|
+
}
|
|
1967
|
+
return true;
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
// src/forms/Textarea.tsx
|
|
1971
|
+
var import_react29 = require("react");
|
|
1972
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
1973
|
+
var Textarea = (0, import_react29.forwardRef)(function Textarea2({ label, hint, error, resize = "vertical", id, className = "", ...props }, ref) {
|
|
1974
|
+
const generated = (0, import_react29.useId)();
|
|
1975
|
+
const fieldId = id ?? generated;
|
|
1976
|
+
const message = error ?? hint;
|
|
1977
|
+
const messageId = message ? `${fieldId}-message` : void 0;
|
|
1978
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("label", { className: "hf-field", htmlFor: fieldId, children: [
|
|
1979
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "hf-field__label", children: label }),
|
|
1980
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("textarea", { ref, id: fieldId, className: `hf-textarea hf-textarea--${resize}${error ? " hf-textarea--error" : ""} ${className}`, "aria-invalid": error ? true : void 0, "aria-describedby": messageId, ...props }),
|
|
1981
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { id: messageId, className: `hf-field__hint${error ? " hf-field__hint--error" : ""}`, children: message })
|
|
1982
|
+
] });
|
|
1983
|
+
});
|
|
1984
|
+
|
|
1985
|
+
// src/forms/Choice.tsx
|
|
1986
|
+
var import_react30 = require("react");
|
|
1987
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
1988
|
+
var Checkbox = (0, import_react30.forwardRef)(function Checkbox2({ label, description, indeterminate, className = "", ...props }, forwardedRef) {
|
|
1989
|
+
const local = (0, import_react30.useRef)(null);
|
|
1990
|
+
(0, import_react30.useEffect)(() => {
|
|
1991
|
+
if (local.current) local.current.indeterminate = Boolean(indeterminate);
|
|
1992
|
+
}, [indeterminate]);
|
|
1993
|
+
const setRef = (node) => {
|
|
1994
|
+
local.current = node;
|
|
1995
|
+
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
1996
|
+
else if (forwardedRef) forwardedRef.current = node;
|
|
1997
|
+
};
|
|
1998
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { className: `hf-choice-control ${className}`, children: [
|
|
1999
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("input", { ref: setRef, type: "checkbox", ...props }),
|
|
2000
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "hf-choice-control__mark", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(IconCheck, {}) }),
|
|
2001
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("span", { children: [
|
|
2002
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("strong", { children: label }),
|
|
2003
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("small", { children: description })
|
|
2004
|
+
] })
|
|
2005
|
+
] });
|
|
2006
|
+
});
|
|
2007
|
+
var Radio = (0, import_react30.forwardRef)(function Radio2({ label, description, className = "", ...props }, ref) {
|
|
2008
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("label", { className: `hf-choice-control hf-choice-control--radio ${className}`, children: [
|
|
2009
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("input", { ref, type: "radio", ...props }),
|
|
2010
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "hf-choice-control__mark", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("i", {}) }),
|
|
2011
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("span", { children: [
|
|
2012
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("strong", { children: label }),
|
|
2013
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("small", { children: description })
|
|
2014
|
+
] })
|
|
2015
|
+
] });
|
|
2016
|
+
});
|
|
2017
|
+
function IconCheck() {
|
|
2018
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("path", { d: "m3.5 8 3 3 6-6" }) });
|
|
2019
|
+
}
|
|
2020
|
+
|
|
2021
|
+
// src/forms/Advanced.tsx
|
|
2022
|
+
var import_react31 = require("react");
|
|
2023
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
2024
|
+
var iso = (date) => `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
2025
|
+
function Calendar({ value, onChange, min, max, className = "" }) {
|
|
2026
|
+
const initial = value ? /* @__PURE__ */ new Date(`${value}T00:00:00`) : /* @__PURE__ */ new Date();
|
|
2027
|
+
const [view, setView] = (0, import_react31.useState)(new Date(initial.getFullYear(), initial.getMonth(), 1));
|
|
2028
|
+
const first = view.getDay();
|
|
2029
|
+
const days = new Date(view.getFullYear(), view.getMonth() + 1, 0).getDate();
|
|
2030
|
+
const cells = Array.from(
|
|
2031
|
+
{ length: Math.ceil((first + days) / 7) * 7 },
|
|
2032
|
+
(_, index) => index - first + 1
|
|
2033
|
+
);
|
|
2034
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: `hf-calendar ${className}`, children: [
|
|
2035
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("header", { children: [
|
|
2036
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
2037
|
+
"button",
|
|
2038
|
+
{
|
|
2039
|
+
type: "button",
|
|
2040
|
+
"aria-label": "\u4E0A\u4E2A\u6708",
|
|
2041
|
+
onClick: () => setView(new Date(view.getFullYear(), view.getMonth() - 1, 1)),
|
|
2042
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Icon, { name: "chevron-down", className: "hf-calendar__prev" })
|
|
2043
|
+
}
|
|
2044
|
+
),
|
|
2045
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("strong", { children: [
|
|
2046
|
+
view.getFullYear(),
|
|
2047
|
+
" \u5E74 ",
|
|
2048
|
+
view.getMonth() + 1,
|
|
2049
|
+
" \u6708"
|
|
2050
|
+
] }),
|
|
2051
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
2052
|
+
"button",
|
|
2053
|
+
{
|
|
2054
|
+
type: "button",
|
|
2055
|
+
"aria-label": "\u4E0B\u4E2A\u6708",
|
|
2056
|
+
onClick: () => setView(new Date(view.getFullYear(), view.getMonth() + 1, 1)),
|
|
2057
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Icon, { name: "chevron-down", className: "hf-calendar__next" })
|
|
2058
|
+
}
|
|
2059
|
+
)
|
|
2060
|
+
] }),
|
|
2061
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "hf-calendar__week", children: "\u65E5\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D".split("").map((day2) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { children: day2 }, day2)) }),
|
|
2062
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "hf-calendar__days", children: cells.map((day2, index) => {
|
|
2063
|
+
if (day2 < 1 || day2 > days) return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", {}, index);
|
|
2064
|
+
const date = iso(new Date(view.getFullYear(), view.getMonth(), day2));
|
|
2065
|
+
const disabled = Boolean(min && date < min || max && date > max);
|
|
2066
|
+
const stateClass = date === value ? "is-selected" : date === iso(/* @__PURE__ */ new Date()) ? "is-today" : "";
|
|
2067
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
2068
|
+
"button",
|
|
2069
|
+
{
|
|
2070
|
+
type: "button",
|
|
2071
|
+
disabled,
|
|
2072
|
+
className: stateClass,
|
|
2073
|
+
"aria-pressed": date === value,
|
|
2074
|
+
onClick: () => onChange?.(date),
|
|
2075
|
+
children: day2
|
|
2076
|
+
},
|
|
2077
|
+
date
|
|
2078
|
+
);
|
|
2079
|
+
}) })
|
|
2080
|
+
] });
|
|
2081
|
+
}
|
|
2082
|
+
function DatePicker({
|
|
2083
|
+
label,
|
|
2084
|
+
value,
|
|
2085
|
+
onChange,
|
|
2086
|
+
placeholder = "\u9009\u62E9\u65E5\u671F",
|
|
2087
|
+
min,
|
|
2088
|
+
max,
|
|
2089
|
+
error
|
|
2090
|
+
}) {
|
|
2091
|
+
const [open, setOpen] = (0, import_react31.useState)(false);
|
|
2092
|
+
const rootRef = useDismissibleLayer(open, () => setOpen(false), {
|
|
2093
|
+
autoFocus: false
|
|
2094
|
+
});
|
|
2095
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { ref: rootRef, className: "hf-field hf-date-picker", children: [
|
|
2096
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "hf-field__label", children: label }),
|
|
2097
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
|
|
2098
|
+
"button",
|
|
2099
|
+
{
|
|
2100
|
+
type: "button",
|
|
2101
|
+
className: `hf-picker-trigger${error ? " is-error" : ""}`,
|
|
2102
|
+
"aria-expanded": open,
|
|
2103
|
+
onClick: () => setOpen(!open),
|
|
2104
|
+
children: [
|
|
2105
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: value ? "" : "is-placeholder", children: value || placeholder }),
|
|
2106
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Icon, { name: "chevron-down", size: 16 })
|
|
2107
|
+
]
|
|
2108
|
+
}
|
|
2109
|
+
),
|
|
2110
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "hf-date-picker__panel", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
2111
|
+
Calendar,
|
|
2112
|
+
{
|
|
2113
|
+
value,
|
|
2114
|
+
min,
|
|
2115
|
+
max,
|
|
2116
|
+
onChange: (next) => {
|
|
2117
|
+
onChange(next);
|
|
2118
|
+
setOpen(false);
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
) }),
|
|
2122
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "hf-field__hint hf-field__hint--error", children: error })
|
|
2123
|
+
] });
|
|
2124
|
+
}
|
|
2125
|
+
function TimePicker({ label, value, onChange, step = 30 }) {
|
|
2126
|
+
const [open, setOpen] = (0, import_react31.useState)(false);
|
|
2127
|
+
const rootRef = useDismissibleLayer(open, () => setOpen(false), {
|
|
2128
|
+
autoFocus: false
|
|
2129
|
+
});
|
|
2130
|
+
const times = Array.from({ length: Math.ceil(1440 / step) }, (_, index) => {
|
|
2131
|
+
const minutes = index * step;
|
|
2132
|
+
return `${String(Math.floor(minutes / 60)).padStart(2, "0")}:${String(minutes % 60).padStart(2, "0")}`;
|
|
2133
|
+
});
|
|
2134
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { ref: rootRef, className: "hf-field hf-time-picker", children: [
|
|
2135
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "hf-field__label", children: label }),
|
|
2136
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
|
|
2137
|
+
"button",
|
|
2138
|
+
{
|
|
2139
|
+
type: "button",
|
|
2140
|
+
className: "hf-picker-trigger",
|
|
2141
|
+
"aria-expanded": open,
|
|
2142
|
+
onClick: () => setOpen(!open),
|
|
2143
|
+
children: [
|
|
2144
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: value ? "" : "is-placeholder", children: value || "\u9009\u62E9\u65F6\u95F4" }),
|
|
2145
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Icon, { name: "chevron-down", size: 16 })
|
|
2146
|
+
]
|
|
2147
|
+
}
|
|
2148
|
+
),
|
|
2149
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "hf-time-picker__panel", role: "listbox", children: times.map((time) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
2150
|
+
"button",
|
|
2151
|
+
{
|
|
2152
|
+
type: "button",
|
|
2153
|
+
role: "option",
|
|
2154
|
+
"aria-selected": time === value,
|
|
2155
|
+
onClick: () => {
|
|
2156
|
+
onChange(time);
|
|
2157
|
+
setOpen(false);
|
|
2158
|
+
},
|
|
2159
|
+
children: time
|
|
2160
|
+
},
|
|
2161
|
+
time
|
|
2162
|
+
)) })
|
|
2163
|
+
] });
|
|
2164
|
+
}
|
|
2165
|
+
function Slider({
|
|
2166
|
+
label,
|
|
2167
|
+
value,
|
|
2168
|
+
min = 0,
|
|
2169
|
+
max = 100,
|
|
2170
|
+
step = 1,
|
|
2171
|
+
onChange,
|
|
2172
|
+
showValue = true,
|
|
2173
|
+
...props
|
|
2174
|
+
}) {
|
|
2175
|
+
const percent = (value - Number(min)) / (Number(max) - Number(min)) * 100;
|
|
2176
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("label", { className: "hf-slider", children: [
|
|
2177
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("span", { children: [
|
|
2178
|
+
label,
|
|
2179
|
+
showValue && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("strong", { children: value })
|
|
2180
|
+
] }),
|
|
2181
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
2182
|
+
"input",
|
|
2183
|
+
{
|
|
2184
|
+
type: "range",
|
|
2185
|
+
value,
|
|
2186
|
+
min,
|
|
2187
|
+
max,
|
|
2188
|
+
step,
|
|
2189
|
+
style: { "--hf-slider-value": `${percent}%` },
|
|
2190
|
+
onChange: (event) => onChange(Number(event.target.value)),
|
|
2191
|
+
...props
|
|
2192
|
+
}
|
|
2193
|
+
)
|
|
2194
|
+
] });
|
|
2195
|
+
}
|
|
2196
|
+
|
|
2197
|
+
// src/forms/Form.tsx
|
|
2198
|
+
var import_react32 = require("react");
|
|
2199
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
2200
|
+
var FormContext = (0, import_react32.createContext)({});
|
|
2201
|
+
function Form({
|
|
2202
|
+
layout = "vertical",
|
|
2203
|
+
disabled,
|
|
2204
|
+
className = "",
|
|
2205
|
+
children,
|
|
2206
|
+
...props
|
|
2207
|
+
}) {
|
|
2208
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(FormContext.Provider, { value: { disabled }, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
2209
|
+
"form",
|
|
2210
|
+
{
|
|
2211
|
+
className: `hf-form hf-form--${layout} ${className}`.trim(),
|
|
2212
|
+
"aria-disabled": disabled || void 0,
|
|
2213
|
+
...props,
|
|
2214
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("fieldset", { className: "hf-form__fieldset", disabled, children })
|
|
2215
|
+
}
|
|
2216
|
+
) });
|
|
2217
|
+
}
|
|
2218
|
+
function FormItem({
|
|
2219
|
+
label,
|
|
2220
|
+
required,
|
|
2221
|
+
hint,
|
|
2222
|
+
error,
|
|
2223
|
+
children,
|
|
2224
|
+
className = "",
|
|
2225
|
+
...props
|
|
2226
|
+
}) {
|
|
2227
|
+
const { disabled } = (0, import_react32.useContext)(FormContext);
|
|
2228
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
2229
|
+
"div",
|
|
2230
|
+
{
|
|
2231
|
+
className: `hf-form-item${error ? " is-error" : ""} ${className}`.trim(),
|
|
2232
|
+
"aria-disabled": disabled || void 0,
|
|
2233
|
+
...props,
|
|
2234
|
+
children: [
|
|
2235
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "hf-form-item__label", children: [
|
|
2236
|
+
label,
|
|
2237
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { "aria-hidden": "true", children: "*" })
|
|
2238
|
+
] }),
|
|
2239
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { children: [
|
|
2240
|
+
children,
|
|
2241
|
+
(error || hint) && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("small", { className: error ? "is-error" : "", children: error || hint })
|
|
2242
|
+
] })
|
|
2243
|
+
]
|
|
2244
|
+
}
|
|
2245
|
+
);
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2248
|
+
// src/forms/Upload.tsx
|
|
2249
|
+
var import_react33 = require("react");
|
|
2250
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
2251
|
+
function formatFileSize(bytes) {
|
|
2252
|
+
if (bytes >= 1024 * 1024) {
|
|
2253
|
+
const megabytes = bytes / (1024 * 1024);
|
|
2254
|
+
return `${Number.isInteger(megabytes) ? megabytes : megabytes.toFixed(1)} MB`;
|
|
2255
|
+
}
|
|
2256
|
+
if (bytes >= 1024) return `${Math.ceil(bytes / 1024)} KB`;
|
|
2257
|
+
return `${bytes} B`;
|
|
2258
|
+
}
|
|
2259
|
+
function acceptsFile(file, accept) {
|
|
2260
|
+
if (!accept?.trim()) return true;
|
|
2261
|
+
const fileName = file.name.toLowerCase();
|
|
2262
|
+
const mimeType = file.type.toLowerCase();
|
|
2263
|
+
return accept.split(",").map((value) => value.trim().toLowerCase()).filter(Boolean).some((rule) => {
|
|
2264
|
+
if (rule.startsWith(".")) return fileName.endsWith(rule);
|
|
2265
|
+
if (rule.endsWith("/*")) return mimeType.startsWith(rule.slice(0, -1));
|
|
2266
|
+
return mimeType === rule;
|
|
2267
|
+
});
|
|
2268
|
+
}
|
|
2269
|
+
function validateUploadFiles(files, options = {}) {
|
|
2270
|
+
const accepted = [];
|
|
2271
|
+
const rejected = [];
|
|
2272
|
+
const limit = options.maxFiles ?? Number.POSITIVE_INFINITY;
|
|
2273
|
+
files.forEach((file) => {
|
|
2274
|
+
if (!acceptsFile(file, options.accept)) {
|
|
2275
|
+
rejected.push({ file, reason: "file-type-not-accepted", message: "\u4E0D\u652F\u6301\u8BE5\u6587\u4EF6\u7C7B\u578B" });
|
|
2276
|
+
return;
|
|
2277
|
+
}
|
|
2278
|
+
if (options.maxSize !== void 0 && file.size > options.maxSize) {
|
|
2279
|
+
rejected.push({
|
|
2280
|
+
file,
|
|
2281
|
+
reason: "file-too-large",
|
|
2282
|
+
message: `\u6587\u4EF6\u4E0D\u80FD\u8D85\u8FC7 ${formatFileSize(options.maxSize)}`
|
|
2283
|
+
});
|
|
2284
|
+
return;
|
|
2285
|
+
}
|
|
2286
|
+
if (accepted.length >= limit) {
|
|
2287
|
+
rejected.push({
|
|
2288
|
+
file,
|
|
2289
|
+
reason: "too-many-files",
|
|
2290
|
+
message: `\u6700\u591A\u53EA\u80FD\u9009\u62E9 ${limit} \u4E2A\u6587\u4EF6`
|
|
2291
|
+
});
|
|
2292
|
+
return;
|
|
2293
|
+
}
|
|
2294
|
+
accepted.push(file);
|
|
2295
|
+
});
|
|
2296
|
+
return { accepted, rejected };
|
|
2297
|
+
}
|
|
2298
|
+
function Upload({
|
|
2299
|
+
label = "\u4E0A\u4F20\u6587\u4EF6",
|
|
2300
|
+
accept,
|
|
2301
|
+
multiple,
|
|
2302
|
+
maxFiles,
|
|
2303
|
+
maxSize,
|
|
2304
|
+
onFiles,
|
|
2305
|
+
onReject,
|
|
2306
|
+
hint,
|
|
2307
|
+
disabled
|
|
2308
|
+
}) {
|
|
2309
|
+
const id = (0, import_react33.useId)();
|
|
2310
|
+
const ref = (0, import_react33.useRef)(null);
|
|
2311
|
+
const [dragging, setDragging] = (0, import_react33.useState)(false);
|
|
2312
|
+
const [rejections, setRejections] = (0, import_react33.useState)([]);
|
|
2313
|
+
const takeFiles = (list) => {
|
|
2314
|
+
const result = validateUploadFiles(Array.from(list ?? []), {
|
|
2315
|
+
accept,
|
|
2316
|
+
maxFiles,
|
|
2317
|
+
maxSize
|
|
2318
|
+
});
|
|
2319
|
+
setRejections(result.rejected);
|
|
2320
|
+
onFiles(result.accepted);
|
|
2321
|
+
if (result.rejected.length) onReject?.(result.rejected);
|
|
2322
|
+
};
|
|
2323
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "hf-upload", children: [
|
|
2324
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
2325
|
+
"input",
|
|
2326
|
+
{
|
|
2327
|
+
ref,
|
|
2328
|
+
id,
|
|
2329
|
+
type: "file",
|
|
2330
|
+
accept,
|
|
2331
|
+
multiple,
|
|
2332
|
+
disabled,
|
|
2333
|
+
onChange: (event) => takeFiles(event.target.files)
|
|
2334
|
+
}
|
|
2335
|
+
),
|
|
2336
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
|
|
2337
|
+
"button",
|
|
2338
|
+
{
|
|
2339
|
+
type: "button",
|
|
2340
|
+
disabled,
|
|
2341
|
+
className: dragging ? "is-dragging" : "",
|
|
2342
|
+
onClick: () => ref.current?.click(),
|
|
2343
|
+
onDragOver: (event) => {
|
|
2344
|
+
event.preventDefault();
|
|
2345
|
+
if (!disabled) setDragging(true);
|
|
2346
|
+
},
|
|
2347
|
+
onDragLeave: () => setDragging(false),
|
|
2348
|
+
onDrop: (event) => {
|
|
2349
|
+
event.preventDefault();
|
|
2350
|
+
setDragging(false);
|
|
2351
|
+
if (!disabled) takeFiles(event.dataTransfer.files);
|
|
2352
|
+
},
|
|
2353
|
+
children: [
|
|
2354
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Icon, { name: "inbox", size: 24 }),
|
|
2355
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("strong", { children: label }),
|
|
2356
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { children: "\u62D6\u653E\u5230\u8FD9\u91CC\uFF0C\u6216\u70B9\u51FB\u9009\u62E9" })
|
|
2357
|
+
]
|
|
2358
|
+
}
|
|
2359
|
+
),
|
|
2360
|
+
rejections.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "hf-upload__errors", role: "alert", children: rejections.map(({ file, reason, message }, index) => /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("span", { children: [
|
|
2361
|
+
file.name,
|
|
2362
|
+
"\uFF1A",
|
|
2363
|
+
message
|
|
2364
|
+
] }, `${file.name}-${reason}-${index}`)) }),
|
|
2365
|
+
hint && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("small", { children: hint })
|
|
2366
|
+
] });
|
|
2367
|
+
}
|
|
2368
|
+
|
|
2369
|
+
// src/forms/Combobox.tsx
|
|
2370
|
+
var import_react34 = require("react");
|
|
2371
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
2372
|
+
function Combobox({ label, options, value = "", onChange, placeholder = "\u641C\u7D22\u6216\u9009\u62E9", hint, error, disabled, emptyText = "\u6CA1\u6709\u5339\u914D\u9879" }) {
|
|
2373
|
+
const id = (0, import_react34.useId)();
|
|
2374
|
+
const [open, setOpen] = (0, import_react34.useState)(false);
|
|
2375
|
+
const root = useDismissibleLayer(open, () => setOpen(false), { autoFocus: false });
|
|
2376
|
+
const [query, setQuery] = (0, import_react34.useState)("");
|
|
2377
|
+
const [active, setActive] = (0, import_react34.useState)(0);
|
|
2378
|
+
const selected = options.find((item) => item.value === value);
|
|
2379
|
+
const filtered = (0, import_react34.useMemo)(() => options.filter((item) => `${typeof item.label === "string" ? item.label : item.value} ${item.keywords ?? ""}`.toLowerCase().includes(query.toLowerCase())), [options, query]);
|
|
2380
|
+
const choose = (next) => {
|
|
2381
|
+
onChange(next);
|
|
2382
|
+
setQuery("");
|
|
2383
|
+
setOpen(false);
|
|
2384
|
+
};
|
|
2385
|
+
const onKeyDown = (event) => {
|
|
2386
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
2387
|
+
event.preventDefault();
|
|
2388
|
+
setOpen(true);
|
|
2389
|
+
setActive((current) => Math.max(0, Math.min(filtered.length - 1, current + (event.key === "ArrowDown" ? 1 : -1))));
|
|
2390
|
+
} else if (event.key === "Enter" && open) {
|
|
2391
|
+
event.preventDefault();
|
|
2392
|
+
const option = filtered[active];
|
|
2393
|
+
if (option && !option.disabled) choose(option.value);
|
|
2394
|
+
} else if (event.key === "Escape") setOpen(false);
|
|
2395
|
+
};
|
|
2396
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "hf-field hf-combobox", ref: root, children: [
|
|
2397
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("label", { className: "hf-field__label", htmlFor: id, children: label }),
|
|
2398
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: `hf-combobox__control${open ? " is-open" : ""}${error ? " is-error" : ""}`, children: [
|
|
2399
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("input", { id, role: "combobox", "aria-expanded": open, "aria-controls": `${id}-listbox`, "aria-autocomplete": "list", "aria-invalid": Boolean(error), disabled, placeholder: selected && !open ? String(selected.label) : placeholder, value: open ? query : selected ? String(selected.label) : "", onFocus: () => setOpen(true), onChange: (event) => {
|
|
2400
|
+
setQuery(event.target.value);
|
|
2401
|
+
setActive(0);
|
|
2402
|
+
setOpen(true);
|
|
2403
|
+
}, onKeyDown }),
|
|
2404
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("button", { type: "button", "aria-label": open ? "\u5173\u95ED\u9009\u9879" : "\u6253\u5F00\u9009\u9879", disabled, onClick: () => setOpen((current) => !current), children: "\u2304" })
|
|
2405
|
+
] }),
|
|
2406
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { id: `${id}-listbox`, className: "hf-combobox__menu", role: "listbox", children: filtered.length ? filtered.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("button", { type: "button", role: "option", "aria-selected": option.value === value, disabled: option.disabled, className: index === active ? "is-active" : "", onPointerMove: () => setActive(index), onClick: () => choose(option.value), children: [
|
|
2407
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { children: option.label }),
|
|
2408
|
+
option.value === value && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { "aria-hidden": "true", children: "\u2713" })
|
|
2409
|
+
] }, option.value)) : /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "hf-combobox__empty", children: emptyText }) }),
|
|
2410
|
+
(error || hint) && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: `hf-field__hint${error ? " hf-field__hint--error" : ""}`, children: error ?? hint })
|
|
2411
|
+
] });
|
|
2412
|
+
}
|
|
2413
|
+
|
|
2414
|
+
// src/forms/NumberInput.tsx
|
|
2415
|
+
var import_react35 = require("react");
|
|
2416
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
2417
|
+
function NumberInput({ label, value, onChange, min, max, step = 1, prefix, suffix, hint, error, disabled }) {
|
|
2418
|
+
const id = (0, import_react35.useId)();
|
|
2419
|
+
const clamp = (next) => Math.min(max ?? Infinity, Math.max(min ?? -Infinity, next));
|
|
2420
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "hf-field hf-number-input", children: [
|
|
2421
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("label", { className: "hf-field__label", htmlFor: id, children: label }),
|
|
2422
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: `hf-number-input__control${error ? " is-error" : ""}`, children: [
|
|
2423
|
+
prefix && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { children: prefix }),
|
|
2424
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("input", { id, type: "number", value, min, max, step, disabled, "aria-invalid": Boolean(error), onChange: (event) => {
|
|
2425
|
+
const next = event.currentTarget.valueAsNumber;
|
|
2426
|
+
if (!Number.isNaN(next)) onChange(clamp(next));
|
|
2427
|
+
} }),
|
|
2428
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { children: [
|
|
2429
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", disabled: disabled || max !== void 0 && value >= max, "aria-label": "\u589E\u52A0", onClick: () => onChange(clamp(value + step)), children: "\uFF0B" }),
|
|
2430
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("button", { type: "button", disabled: disabled || min !== void 0 && value <= min, "aria-label": "\u51CF\u5C11", onClick: () => onChange(clamp(value - step)), children: "\u2212" })
|
|
2431
|
+
] }),
|
|
2432
|
+
suffix && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { children: suffix })
|
|
2433
|
+
] }),
|
|
2434
|
+
(error || hint) && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: `hf-field__hint${error ? " hf-field__hint--error" : ""}`, children: error ?? hint })
|
|
2435
|
+
] });
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2438
|
+
// src/forms/NextBatch.tsx
|
|
2439
|
+
var import_react36 = require("react");
|
|
2440
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
2441
|
+
function Cascader({ options, value = [], onChange, label }) {
|
|
2442
|
+
const levels = [options];
|
|
2443
|
+
let current = options;
|
|
2444
|
+
for (const key of value) {
|
|
2445
|
+
const next = current.find((item) => item.value === key)?.children;
|
|
2446
|
+
if (!next) break;
|
|
2447
|
+
levels.push(next);
|
|
2448
|
+
current = next;
|
|
2449
|
+
}
|
|
2450
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "hf-field hf-cascader", children: [
|
|
2451
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "hf-field__label", children: label }),
|
|
2452
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { children: levels.map((items, level) => /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("select", { "aria-label": `\u7B2C ${level + 1} \u7EA7`, value: value[level] ?? "", onChange: (event) => onChange([...value.slice(0, level), event.target.value]), children: [
|
|
2453
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("option", { value: "", children: "\u8BF7\u9009\u62E9" }),
|
|
2454
|
+
items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("option", { disabled: item.disabled, value: item.value, children: item.label }, item.value))
|
|
2455
|
+
] }, level)) })
|
|
2456
|
+
] });
|
|
2457
|
+
}
|
|
2458
|
+
function TreeSelect({ options, value, onChange, label, placeholder = "\u9009\u62E9\u8282\u70B9" }) {
|
|
2459
|
+
const [open, setOpen] = (0, import_react36.useState)(false);
|
|
2460
|
+
const flatten = (nodes, depth = 0) => nodes.flatMap((node) => [{ node, depth }, ...flatten(node.children ?? [], depth + 1)]);
|
|
2461
|
+
const all = flatten(options);
|
|
2462
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "hf-field hf-tree-select", children: [
|
|
2463
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "hf-field__label", children: label }),
|
|
2464
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("button", { type: "button", className: "hf-picker-trigger", "aria-expanded": open, onClick: () => setOpen(!open), children: [
|
|
2465
|
+
all.find((item) => item.node.key === value)?.node.label ?? placeholder,
|
|
2466
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "\u2304" })
|
|
2467
|
+
] }),
|
|
2468
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { role: "listbox", children: all.map(({ node, depth }) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("button", { type: "button", role: "option", "aria-selected": node.key === value, disabled: node.disabled, style: { paddingLeft: 12 + depth * 18 }, onClick: () => {
|
|
2469
|
+
onChange(node.key);
|
|
2470
|
+
setOpen(false);
|
|
2471
|
+
}, children: node.label }, node.key)) })
|
|
2472
|
+
] });
|
|
2473
|
+
}
|
|
2474
|
+
function Transfer({ items, value, onChange, titles = ["\u53EF\u9009\u9879", "\u5DF2\u9009\u62E9"] }) {
|
|
2475
|
+
const [marked, setMarked] = (0, import_react36.useState)([]);
|
|
2476
|
+
const pane = (selected) => /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("section", { children: [
|
|
2477
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("strong", { children: titles[selected ? 1 : 0] }),
|
|
2478
|
+
items.filter((item) => value.includes(item.key) === selected).map((item) => /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("label", { children: [
|
|
2479
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("input", { type: "checkbox", disabled: item.disabled, checked: marked.includes(item.key), onChange: () => setMarked((keys) => keys.includes(item.key) ? keys.filter((key) => key !== item.key) : [...keys, item.key]) }),
|
|
2480
|
+
item.label
|
|
2481
|
+
] }, item.key))
|
|
2482
|
+
] });
|
|
2483
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "hf-transfer", children: [
|
|
2484
|
+
pane(false),
|
|
2485
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { children: [
|
|
2486
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("button", { type: "button", "aria-label": "\u79FB\u81F3\u5DF2\u9009\u62E9", onClick: () => {
|
|
2487
|
+
onChange([.../* @__PURE__ */ new Set([...value, ...marked])]);
|
|
2488
|
+
setMarked([]);
|
|
2489
|
+
}, children: "\u2192" }),
|
|
2490
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("button", { type: "button", "aria-label": "\u79FB\u56DE\u53EF\u9009\u9879", onClick: () => {
|
|
2491
|
+
onChange(value.filter((key) => !marked.includes(key)));
|
|
2492
|
+
setMarked([]);
|
|
2493
|
+
}, children: "\u2190" })
|
|
2494
|
+
] }),
|
|
2495
|
+
pane(true)
|
|
2496
|
+
] });
|
|
2497
|
+
}
|
|
2498
|
+
function DateRangePicker({ label, value, onChange, min, max }) {
|
|
2499
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "hf-field hf-date-range", children: [
|
|
2500
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "hf-field__label", children: label }),
|
|
2501
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { children: [
|
|
2502
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("input", { "aria-label": "\u5F00\u59CB\u65E5\u671F", type: "date", value: value[0], min, max: value[1] || max, onChange: (event) => onChange([event.target.value, value[1]]) }),
|
|
2503
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: "\u81F3" }),
|
|
2504
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("input", { "aria-label": "\u7ED3\u675F\u65E5\u671F", type: "date", value: value[1], min: value[0] || min, max, onChange: (event) => onChange([value[0], event.target.value]) })
|
|
2505
|
+
] })
|
|
2506
|
+
] });
|
|
2507
|
+
}
|
|
2508
|
+
function SearchInput({ onSearch, loading, clearable = true, ...props }) {
|
|
2509
|
+
const [value, setValue] = (0, import_react36.useState)(String(props.defaultValue ?? props.value ?? ""));
|
|
2510
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("form", { className: "hf-search-input", role: "search", onSubmit: (event) => {
|
|
2511
|
+
event.preventDefault();
|
|
2512
|
+
onSearch(value);
|
|
2513
|
+
}, children: [
|
|
2514
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { "aria-hidden": "true", children: "\u2315" }),
|
|
2515
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("input", { ...props, value, onChange: (event) => {
|
|
2516
|
+
setValue(event.target.value);
|
|
2517
|
+
props.onChange?.(event);
|
|
2518
|
+
} }),
|
|
2519
|
+
clearable && value && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("button", { type: "button", "aria-label": "\u6E05\u9664\u641C\u7D22", onClick: () => setValue(""), children: "\xD7" }),
|
|
2520
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("button", { type: "submit", disabled: loading, children: loading ? "\u641C\u7D22\u4E2D" : "\u641C\u7D22" })
|
|
2521
|
+
] });
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
// src/feedback/Drawer.tsx
|
|
2525
|
+
var import_react37 = require("react");
|
|
2526
|
+
var import_react_dom4 = require("react-dom");
|
|
2527
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
2528
|
+
function Drawer({ open, title, children, onClose, footer, side = "right", size = "md" }) {
|
|
2529
|
+
const titleId = (0, import_react37.useId)();
|
|
2530
|
+
const drawerRef = useDismissibleLayer(open, onClose, true);
|
|
2531
|
+
if (!open) return null;
|
|
2532
|
+
return (0, import_react_dom4.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "hf-drawer-backdrop", onMouseDown: (event) => event.target === event.currentTarget && onClose(), children: /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { ref: drawerRef, className: `hf-drawer hf-drawer--${side} hf-drawer--${size}`, role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, tabIndex: -1, children: [
|
|
2533
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("header", { children: [
|
|
2534
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("h2", { id: titleId, children: title }),
|
|
2535
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Button, { variant: "quiet", size: "sm", onClick: onClose, "aria-label": "\u5173\u95ED\u62BD\u5C49", children: "\xD7" })
|
|
2536
|
+
] }),
|
|
2537
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "hf-drawer__body", children }),
|
|
2538
|
+
footer && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("footer", { children: footer })
|
|
2539
|
+
] }) }), document.body);
|
|
2540
|
+
}
|
|
2541
|
+
|
|
2542
|
+
// src/feedback/Popover.tsx
|
|
2543
|
+
var import_react38 = require("react");
|
|
2544
|
+
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
2545
|
+
function Popover({ trigger, children, open, defaultOpen = false, onOpenChange, placement = "bottom", label = "\u66F4\u591A\u5185\u5BB9" }) {
|
|
2546
|
+
const [innerOpen, setInnerOpen] = (0, import_react38.useState)(defaultOpen);
|
|
2547
|
+
const controlled = open !== void 0;
|
|
2548
|
+
const visible = controlled ? open : innerOpen;
|
|
2549
|
+
const contentId = (0, import_react38.useId)();
|
|
2550
|
+
const update = (next) => {
|
|
2551
|
+
if (!controlled) setInnerOpen(next);
|
|
2552
|
+
onOpenChange?.(next);
|
|
2553
|
+
};
|
|
2554
|
+
const rootRef = useDismissibleLayer(visible, () => update(false));
|
|
2555
|
+
const triggerProps = { "aria-expanded": visible, "aria-controls": visible ? contentId : void 0, "aria-haspopup": "dialog", onClick: () => update(!visible) };
|
|
2556
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("span", { className: "hf-popover", ref: rootRef, children: [
|
|
2557
|
+
(0, import_react38.isValidElement)(trigger) && (0, import_react38.cloneElement)(trigger, triggerProps),
|
|
2558
|
+
visible && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { id: contentId, role: "dialog", "aria-label": label, className: `hf-popover__content hf-popover__content--${placement}`, children })
|
|
2559
|
+
] });
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2562
|
+
// src/feedback/Status.tsx
|
|
2563
|
+
var import_react39 = require("react");
|
|
2564
|
+
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
2565
|
+
function Tooltip({ content, children, placement = "top" }) {
|
|
2566
|
+
const [open, setOpen] = (0, import_react39.useState)(false);
|
|
2567
|
+
const id = (0, import_react39.useId)();
|
|
2568
|
+
const trigger = (0, import_react39.cloneElement)(children, { "aria-describedby": open ? id : void 0 });
|
|
2569
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("span", { className: "hf-tooltip", onMouseEnter: () => setOpen(true), onMouseLeave: () => setOpen(false), onFocus: () => setOpen(true), onBlur: () => setOpen(false), children: [
|
|
2570
|
+
trigger,
|
|
2571
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { id, role: "tooltip", className: `hf-tooltip__bubble hf-tooltip__bubble--${placement}`, children: content })
|
|
2572
|
+
] });
|
|
2573
|
+
}
|
|
2574
|
+
function Alert({ tone = "info", title, children, onClose, action }) {
|
|
2575
|
+
const icon = { info: "info", success: "check", warning: "warning", danger: "error" };
|
|
2576
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: `hf-alert hf-alert--${tone}`, role: tone === "danger" ? "alert" : "status", children: [
|
|
2577
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Icon, { name: icon[tone] }),
|
|
2578
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { children: [
|
|
2579
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("strong", { children: title }),
|
|
2580
|
+
children && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { children }),
|
|
2581
|
+
action && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "hf-alert__action", children: action })
|
|
2582
|
+
] }),
|
|
2583
|
+
onClose && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("button", { type: "button", onClick: onClose, "aria-label": "\u5173\u95ED\u63D0\u793A", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Icon, { name: "close", size: 16 }) })
|
|
2584
|
+
] });
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2587
|
+
// src/feedback/Essentials.tsx
|
|
2588
|
+
var import_react40 = require("react");
|
|
2589
|
+
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
2590
|
+
function Popconfirm({ trigger, title, description, confirmText = "\u786E\u8BA4", cancelText = "\u53D6\u6D88", tone = "primary", onConfirm }) {
|
|
2591
|
+
const [open, setOpen] = (0, import_react40.useState)(false);
|
|
2592
|
+
const root = useDismissibleLayer(open, () => setOpen(false), { autoFocus: false });
|
|
2593
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("span", { className: "hf-popconfirm", ref: root, children: [
|
|
2594
|
+
(0, import_react40.isValidElement)(trigger) && (0, import_react40.cloneElement)(trigger, { onClick: () => setOpen(true), "aria-expanded": open }),
|
|
2595
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { role: "alertdialog", "aria-modal": "false", className: "hf-popconfirm__panel", children: [
|
|
2596
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("strong", { children: title }),
|
|
2597
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("p", { children: description }),
|
|
2598
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { children: [
|
|
2599
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Button, { size: "sm", variant: "quiet", onClick: () => setOpen(false), children: cancelText }),
|
|
2600
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Button, { size: "sm", variant: tone === "danger" ? "danger" : "primary", onClick: () => {
|
|
2601
|
+
onConfirm();
|
|
2602
|
+
setOpen(false);
|
|
2603
|
+
}, children: confirmText })
|
|
2604
|
+
] })
|
|
2605
|
+
] })
|
|
2606
|
+
] });
|
|
2607
|
+
}
|
|
2608
|
+
function Notification({ title, children, tone = "info", time, unread, action, onClose }) {
|
|
2609
|
+
const icons = { info: "info", success: "check", warning: "warning", danger: "error" };
|
|
2610
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("article", { className: `hf-notification hf-notification--${tone}${unread ? " is-unread" : ""}`, children: [
|
|
2611
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { className: "hf-notification__icon", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Icon, { name: icons[tone], size: 18 }) }),
|
|
2612
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { children: [
|
|
2613
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("header", { children: [
|
|
2614
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("strong", { children: title }),
|
|
2615
|
+
time && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("time", { children: time })
|
|
2616
|
+
] }),
|
|
2617
|
+
children && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("p", { children }),
|
|
2618
|
+
action && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "hf-notification__action", children: action })
|
|
2619
|
+
] }),
|
|
2620
|
+
onClose && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("button", { type: "button", "aria-label": "\u5173\u95ED\u901A\u77E5", onClick: onClose, children: "\xD7" })
|
|
2621
|
+
] });
|
|
2622
|
+
}
|
|
2623
|
+
function Result({ status = "info", title, description, actions, extra }) {
|
|
2624
|
+
const icon = status === "success" ? "\u2713" : status === "error" ? "\xD7" : status === "warning" ? "!" : status === "info" ? "i" : status;
|
|
2625
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("section", { className: `hf-result hf-result--${status}`, children: [
|
|
2626
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { className: "hf-result__icon", "aria-hidden": "true", children: icon }),
|
|
2627
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)("h2", { children: title }),
|
|
2628
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("p", { children: description }),
|
|
2629
|
+
actions && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "hf-result__actions", children: actions }),
|
|
2630
|
+
extra && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "hf-result__extra", children: extra })
|
|
2631
|
+
] });
|
|
2632
|
+
}
|
|
2633
|
+
|
|
2634
|
+
// src/data-display/DataDisplay.tsx
|
|
2635
|
+
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
2636
|
+
function StatisticCard({ label, value, trend, icon, tone = "blue", className = "", ...props }) {
|
|
2637
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("article", { className: `hf-stat hf-stat--${tone} ${className}`.trim(), ...props, children: [
|
|
2638
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: "hf-stat__top", children: [
|
|
2639
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { children: label }),
|
|
2640
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("i", { children: icon })
|
|
2641
|
+
] }),
|
|
2642
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("strong", { children: value }),
|
|
2643
|
+
trend && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("small", { children: trend }),
|
|
2644
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "hf-stat__glow", "aria-hidden": "true" })
|
|
2645
|
+
] });
|
|
2646
|
+
}
|
|
2647
|
+
var Stat = StatisticCard;
|
|
2648
|
+
function Progress({ value, max = 100, label, showValue = true, size = "md", tone = "primary", className = "", ...props }) {
|
|
2649
|
+
const percent = Math.min(100, Math.max(0, max ? value / max * 100 : 0));
|
|
2650
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: `hf-progress hf-progress--${size} hf-progress--${tone} ${className}`.trim(), ...props, children: [
|
|
2651
|
+
(label || showValue) && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: "hf-progress__meta", children: [
|
|
2652
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { children: label }),
|
|
2653
|
+
showValue && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("strong", { children: [
|
|
2654
|
+
Math.round(percent),
|
|
2655
|
+
"%"
|
|
2656
|
+
] })
|
|
2657
|
+
] }),
|
|
2658
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "hf-progress__track", role: "progressbar", "aria-valuemin": 0, "aria-valuemax": max, "aria-valuenow": value, children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { style: { "--hf-progress": `${percent}%` } }) })
|
|
2659
|
+
] });
|
|
2660
|
+
}
|
|
2661
|
+
function CircularProgress({ value, max = 100, label, size = 92, thickness = 8, className = "", ...props }) {
|
|
2662
|
+
const percent = Math.min(100, Math.max(0, max ? value / max * 100 : 0));
|
|
2663
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: `hf-circular-progress ${className}`.trim(), style: { "--hf-circle": `${percent * 3.6}deg`, "--hf-circle-size": `${size}px`, "--hf-circle-thickness": `${thickness}px` }, role: "progressbar", "aria-valuemin": 0, "aria-valuemax": max, "aria-valuenow": value, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("span", { children: [
|
|
2664
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("strong", { children: [
|
|
2665
|
+
Math.round(percent),
|
|
2666
|
+
"%"
|
|
2667
|
+
] }),
|
|
2668
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("small", { children: label })
|
|
2669
|
+
] }) });
|
|
2670
|
+
}
|
|
2671
|
+
function StepProgress({ steps, current, className = "", ...props }) {
|
|
2672
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("ol", { className: `hf-step-progress ${className}`.trim(), ...props, children: steps.map((step, index) => /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("li", { className: index < current ? "is-complete" : index === current ? "is-current" : "", children: [
|
|
2673
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { children: index < current ? "\u2713" : index + 1 }),
|
|
2674
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("small", { children: step })
|
|
2675
|
+
] }, index)) });
|
|
2676
|
+
}
|
|
2677
|
+
function ActivityIndicator({ variant = "spinner", label = "\u6B63\u5728\u52A0\u8F7D", size = "md", className = "", ...props }) {
|
|
2678
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("span", { className: `hf-activity hf-activity--${variant} hf-activity--${size} ${className}`.trim(), role: "status", "aria-label": label, ...props, children: [
|
|
2679
|
+
variant === "dots" && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_jsx_runtime52.Fragment, { children: [
|
|
2680
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("i", {}),
|
|
2681
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("i", {}),
|
|
2682
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("i", {})
|
|
2683
|
+
] }),
|
|
2684
|
+
variant === "wave" && Array.from({ length: 5 }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("i", {}, index)),
|
|
2685
|
+
variant === "radar" && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("i", {})
|
|
2686
|
+
] });
|
|
2687
|
+
}
|
|
2688
|
+
function Sparkline({ data, width = 160, height = 48, label = "\u8D8B\u52BF\u56FE", filled = true, ...props }) {
|
|
2689
|
+
const min = Math.min(...data);
|
|
2690
|
+
const max = Math.max(...data);
|
|
2691
|
+
const range = max - min || 1;
|
|
2692
|
+
const points = data.map((value, index) => `${data.length === 1 ? width / 2 : index / (data.length - 1) * width},${height - ((value - min) / range * (height - 8) + 4)}`).join(" ");
|
|
2693
|
+
const area = `0,${height} ${points} ${width},${height}`;
|
|
2694
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("svg", { className: "hf-sparkline", viewBox: `0 0 ${width} ${height}`, role: "img", "aria-label": label, ...props, children: [
|
|
2695
|
+
filled && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("polygon", { points: area, className: "hf-sparkline__area" }),
|
|
2696
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("polyline", { points, className: "hf-sparkline__line" })
|
|
2697
|
+
] });
|
|
2698
|
+
}
|
|
2699
|
+
|
|
2700
|
+
// src/data-display/Collections.tsx
|
|
2701
|
+
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
2702
|
+
function Table({ columns, data, rowKey, caption, empty = "\u6682\u65E0\u6570\u636E", striped, onRowClick, className = "", ...props }) {
|
|
2703
|
+
const keyOf = (item, index) => typeof rowKey === "function" ? rowKey(item, index) : String(item[rowKey]);
|
|
2704
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: `hf-table-wrap ${className}`, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("table", { className: `hf-table${striped ? " hf-table--striped" : ""}`, children: [
|
|
2705
|
+
caption && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("caption", { children: caption }),
|
|
2706
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("tr", { children: columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("th", { style: { textAlign: column.align, width: column.width }, children: column.header }, column.key)) }) }),
|
|
2707
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("tbody", { children: [
|
|
2708
|
+
data.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("tr", { className: onRowClick ? "is-clickable" : "", onClick: () => onRowClick?.(item, index), tabIndex: onRowClick ? 0 : void 0, onKeyDown: (event) => {
|
|
2709
|
+
if (onRowClick && (event.key === "Enter" || event.key === " ")) {
|
|
2710
|
+
event.preventDefault();
|
|
2711
|
+
onRowClick(item, index);
|
|
2712
|
+
}
|
|
2713
|
+
}, children: columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("td", { style: { textAlign: column.align }, children: column.render ? column.render(item, index) : String(item[column.key] ?? "") }, column.key)) }, keyOf(item, index))),
|
|
2714
|
+
!data.length && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("td", { className: "hf-table__empty", colSpan: columns.length, children: empty }) })
|
|
2715
|
+
] })
|
|
2716
|
+
] }) });
|
|
2717
|
+
}
|
|
2718
|
+
function Pagination({ page, total, pageSize = 10, siblingCount = 1, onChange, className = "", ...props }) {
|
|
2719
|
+
const count = Math.max(1, Math.ceil(total / pageSize));
|
|
2720
|
+
const current = Math.min(count, Math.max(1, page));
|
|
2721
|
+
const visible = Array.from({ length: count }, (_, i) => i + 1).filter((value) => value === 1 || value === count || Math.abs(value - current) <= siblingCount);
|
|
2722
|
+
const parts = [];
|
|
2723
|
+
visible.forEach((value, index) => {
|
|
2724
|
+
if (index && value - visible[index - 1] > 1) parts.push("ellipsis");
|
|
2725
|
+
parts.push(value);
|
|
2726
|
+
});
|
|
2727
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("nav", { className: `hf-pagination ${className}`, "aria-label": "\u5206\u9875", ...props, children: [
|
|
2728
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("button", { disabled: current === 1, onClick: () => onChange(current - 1), "aria-label": "\u4E0A\u4E00\u9875", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Icon, { name: "chevron-down", size: 16, className: "hf-pagination__prev" }) }),
|
|
2729
|
+
parts.map((part, index) => part === "ellipsis" ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { "aria-hidden": "true", children: "\u2026" }, `e-${index}`) : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("button", { className: part === current ? "is-active" : "", "aria-current": part === current ? "page" : void 0, onClick: () => onChange(part), children: part }, part)),
|
|
2730
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("button", { disabled: current === count, onClick: () => onChange(current + 1), "aria-label": "\u4E0B\u4E00\u9875", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Icon, { name: "chevron-down", size: 16, className: "hf-pagination__next" }) })
|
|
2731
|
+
] });
|
|
2732
|
+
}
|
|
2733
|
+
function List({ items, divided = true, className = "", ...props }) {
|
|
2734
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("ul", { className: `hf-list${divided ? " hf-list--divided" : ""} ${className}`, ...props, children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("li", { children: [
|
|
2735
|
+
item.leading && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "hf-list__leading", children: item.leading }),
|
|
2736
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { children: [
|
|
2737
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("strong", { children: item.title }),
|
|
2738
|
+
item.description && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("small", { children: item.description })
|
|
2739
|
+
] }),
|
|
2740
|
+
item.trailing && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "hf-list__trailing", children: item.trailing })
|
|
2741
|
+
] }, item.key)) });
|
|
2742
|
+
}
|
|
2743
|
+
function Descriptions({ items, columns = 2, bordered, className = "", ...props }) {
|
|
2744
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("dl", { className: `hf-descriptions hf-descriptions--${columns}${bordered ? " hf-descriptions--bordered" : ""} ${className}`, ...props, children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { style: { gridColumn: `span ${Math.min(item.span ?? 1, columns)}` }, children: [
|
|
2745
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("dt", { children: item.label }),
|
|
2746
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("dd", { children: item.value })
|
|
2747
|
+
] }, item.key)) });
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2750
|
+
// src/data-display/Insight.tsx
|
|
2751
|
+
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
2752
|
+
function Timeline({ items, label = "\u65F6\u95F4\u8F74" }) {
|
|
2753
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("ol", { className: "hf-timeline", "aria-label": label, children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("li", { className: `hf-timeline--${item.status ?? "upcoming"}`, children: [
|
|
2754
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("i", { "aria-hidden": "true" }),
|
|
2755
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { children: [
|
|
2756
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("strong", { children: item.title }),
|
|
2757
|
+
item.description && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("p", { children: item.description })
|
|
2758
|
+
] }),
|
|
2759
|
+
item.time && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("time", { children: item.time })
|
|
2760
|
+
] }, item.key)) });
|
|
2761
|
+
}
|
|
2762
|
+
function InsightBoard({ summary, trend, detail, heading, filters }) {
|
|
2763
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("section", { className: "hf-insight-board", children: [
|
|
2764
|
+
(heading || filters) && /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("header", { children: [
|
|
2765
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { children: heading }),
|
|
2766
|
+
filters
|
|
2767
|
+
] }),
|
|
2768
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "hf-insight-board__summary", "aria-label": "\u6838\u5FC3\u7ED3\u679C", children: summary }),
|
|
2769
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "hf-insight-board__trend", "aria-label": "\u53D8\u5316\u8D8B\u52BF", children: trend }),
|
|
2770
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "hf-insight-board__detail", "aria-label": "\u660E\u7EC6\u4E0E\u539F\u56E0", children: detail })
|
|
2771
|
+
] });
|
|
2772
|
+
}
|
|
2773
|
+
|
|
2774
|
+
// src/data-display/EmptyState.tsx
|
|
2775
|
+
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
2776
|
+
function EmptyState({ icon = "inbox", title, description, action, size = "md" }) {
|
|
2777
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: `hf-empty hf-empty--${size}`, children: [
|
|
2778
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "hf-empty__icon", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Icon, { name: icon, size: size === "sm" ? 22 : 28 }) }),
|
|
2779
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)("strong", { children: title }),
|
|
2780
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { children: description }),
|
|
2781
|
+
action && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { children: action })
|
|
2782
|
+
] });
|
|
2783
|
+
}
|
|
2784
|
+
|
|
2785
|
+
// src/data-display/DataGrid.tsx
|
|
2786
|
+
var import_react41 = require("react");
|
|
2787
|
+
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
2788
|
+
function DataGrid({ columns, data, rowKey, selectedKeys = [], onSelectionChange, empty = "\u6682\u65E0\u6570\u636E", caption }) {
|
|
2789
|
+
const [sort, setSort] = (0, import_react41.useState)();
|
|
2790
|
+
const keyOf = (item) => typeof rowKey === "function" ? rowKey(item) : String(item[rowKey]);
|
|
2791
|
+
const rows = (0, import_react41.useMemo)(() => {
|
|
2792
|
+
if (!sort) return [...data];
|
|
2793
|
+
const column = columns.find((item) => item.key === sort.key);
|
|
2794
|
+
if (!column) return [...data];
|
|
2795
|
+
return [...data].sort((a, b) => {
|
|
2796
|
+
const av = column.value?.(a) ?? String(a[column.key] ?? "");
|
|
2797
|
+
const bv = column.value?.(b) ?? String(b[column.key] ?? "");
|
|
2798
|
+
const compared = typeof av === "number" && typeof bv === "number" ? av - bv : String(av).localeCompare(String(bv), "zh-CN");
|
|
2799
|
+
return sort.direction === "asc" ? compared : -compared;
|
|
2800
|
+
});
|
|
2801
|
+
}, [columns, data, sort]);
|
|
2802
|
+
const all = data.length > 0 && data.every((item) => selectedKeys.includes(keyOf(item)));
|
|
2803
|
+
const changeAll = () => onSelectionChange?.(all ? [] : data.map(keyOf));
|
|
2804
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { className: "hf-data-grid", onKeyDown: (event) => {
|
|
2805
|
+
if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(event.key)) return;
|
|
2806
|
+
const controls = [...event.currentTarget.querySelectorAll("button,input")];
|
|
2807
|
+
const current = controls.indexOf(event.target);
|
|
2808
|
+
if (current < 0) return;
|
|
2809
|
+
event.preventDefault();
|
|
2810
|
+
const direction = event.key === "ArrowLeft" || event.key === "ArrowUp" ? -1 : 1;
|
|
2811
|
+
controls[(current + direction + controls.length) % controls.length]?.focus();
|
|
2812
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("table", { children: [
|
|
2813
|
+
caption && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("caption", { children: caption }),
|
|
2814
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("tr", { children: [
|
|
2815
|
+
onSelectionChange && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("th", { className: "hf-data-grid__check", children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("input", { type: "checkbox", "aria-label": "\u9009\u62E9\u5168\u90E8", checked: all, onChange: changeAll }) }),
|
|
2816
|
+
columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("th", { style: { width: column.width }, children: column.sortable ? /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("button", { type: "button", onClick: () => setSort((current) => ({ key: column.key, direction: current?.key === column.key && current.direction === "asc" ? "desc" : "asc" })), children: [
|
|
2817
|
+
column.header,
|
|
2818
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { "aria-hidden": "true", children: sort?.key === column.key ? sort.direction === "asc" ? "\u2191" : "\u2193" : "\u2195" })
|
|
2819
|
+
] }) : column.header }, column.key))
|
|
2820
|
+
] }) }),
|
|
2821
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("tbody", { children: [
|
|
2822
|
+
rows.map((item) => {
|
|
2823
|
+
const key = keyOf(item);
|
|
2824
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("tr", { className: selectedKeys.includes(key) ? "is-selected" : "", children: [
|
|
2825
|
+
onSelectionChange && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("input", { type: "checkbox", "aria-label": `\u9009\u62E9\u884C ${key}`, checked: selectedKeys.includes(key), onChange: () => onSelectionChange(selectedKeys.includes(key) ? selectedKeys.filter((item2) => item2 !== key) : [...selectedKeys, key]) }) }),
|
|
2826
|
+
columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("td", { children: column.render ? column.render(item) : String(item[column.key] ?? "") }, column.key))
|
|
2827
|
+
] }, key);
|
|
2828
|
+
}),
|
|
2829
|
+
!rows.length && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("td", { className: "hf-data-grid__empty", colSpan: columns.length + (onSelectionChange ? 1 : 0), children: empty }) })
|
|
2830
|
+
] })
|
|
2831
|
+
] }) });
|
|
2832
|
+
}
|
|
2833
|
+
|
|
2834
|
+
// src/data-display/Tree.tsx
|
|
2835
|
+
var import_react42 = require("react");
|
|
2836
|
+
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
2837
|
+
function Tree({ nodes, selectedKey, onSelect, defaultExpandedKeys = [], label = "\u6811\u5F62\u5217\u8868" }) {
|
|
2838
|
+
const [expanded, setExpanded] = (0, import_react42.useState)([...defaultExpandedKeys]);
|
|
2839
|
+
const render = (items, level) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("ul", { role: level ? "group" : "tree", "aria-label": level ? void 0 : label, children: items.map((node) => {
|
|
2840
|
+
const open = expanded.includes(node.key);
|
|
2841
|
+
const branch = Boolean(node.children?.length);
|
|
2842
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("li", { role: "treeitem", "aria-level": level + 1, "aria-expanded": branch ? open : void 0, "aria-selected": node.key === selectedKey, children: [
|
|
2843
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: node.key === selectedKey ? "is-selected" : "", style: { paddingLeft: level * 18 + 8 }, children: [
|
|
2844
|
+
branch ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("button", { type: "button", "aria-label": open ? "\u6536\u8D77" : "\u5C55\u5F00", onClick: () => setExpanded((keys) => open ? keys.filter((key) => key !== node.key) : [...keys, node.key]), children: open ? "\u2304" : "\u203A" }) : /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", {}),
|
|
2845
|
+
node.icon,
|
|
2846
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("button", { type: "button", disabled: node.disabled, onClick: () => onSelect?.(node.key), children: node.label })
|
|
2847
|
+
] }),
|
|
2848
|
+
branch && open && render(node.children, level + 1)
|
|
2849
|
+
] }, node.key);
|
|
2850
|
+
}) });
|
|
2851
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "hf-tree", onKeyDown: (event) => {
|
|
2852
|
+
const labels = [...event.currentTarget.querySelectorAll("li[role=treeitem]>div>button:last-child:not(:disabled)")];
|
|
2853
|
+
const current = labels.indexOf(event.target);
|
|
2854
|
+
if (current < 0) return;
|
|
2855
|
+
if (["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) {
|
|
2856
|
+
event.preventDefault();
|
|
2857
|
+
const next = event.key === "Home" ? 0 : event.key === "End" ? labels.length - 1 : (current + (event.key === "ArrowDown" ? 1 : -1) + labels.length) % labels.length;
|
|
2858
|
+
labels[next]?.focus();
|
|
2859
|
+
}
|
|
2860
|
+
}, children: render(nodes, 0) });
|
|
2861
|
+
}
|
|
2862
|
+
|
|
2863
|
+
// src/layout/AuthLayout.tsx
|
|
2864
|
+
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
2865
|
+
function AuthLayout({ children, brand, aside, footer, variant = "card", backgroundImage, currentStep = 1, steps = 1 }) {
|
|
2866
|
+
const style = backgroundImage ? { "--hf-auth-image": `url("${backgroundImage}")` } : void 0;
|
|
2867
|
+
return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("section", { className: `hf-auth hf-auth--${variant}`, style, children: [
|
|
2868
|
+
brand && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("header", { className: "hf-auth__brand", children: brand }),
|
|
2869
|
+
aside && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("aside", { className: "hf-auth__aside", children: aside }),
|
|
2870
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("main", { className: "hf-auth__main", children: [
|
|
2871
|
+
variant === "step" && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "hf-auth__steps", "aria-label": `\u7B2C ${currentStep} \u6B65\uFF0C\u5171 ${steps} \u6B65`, children: Array.from({ length: steps }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: index < currentStep ? "is-active" : "" }, index)) }),
|
|
2872
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "hf-auth__card", children }),
|
|
2873
|
+
footer && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("footer", { children: footer })
|
|
2874
|
+
] })
|
|
2875
|
+
] });
|
|
2876
|
+
}
|
|
2877
|
+
|
|
2878
|
+
// src/layout/Hero.tsx
|
|
2879
|
+
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
2880
|
+
function Hero({ eyebrow, title, description, primaryAction, secondaryAction, visual, proof, align = "left", kind = "product" }) {
|
|
2881
|
+
return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("section", { className: `hf-hero hf-hero--${align} hf-hero--${kind}`, children: [
|
|
2882
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { className: "hf-hero__content", children: [
|
|
2883
|
+
eyebrow && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "hf-hero__eyebrow", children: eyebrow }),
|
|
2884
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)("h1", { children: title }),
|
|
2885
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { children: description }),
|
|
2886
|
+
(primaryAction || secondaryAction) && /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { className: "hf-hero__actions", children: [
|
|
2887
|
+
primaryAction,
|
|
2888
|
+
secondaryAction
|
|
2889
|
+
] }),
|
|
2890
|
+
proof && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "hf-hero__proof", children: proof })
|
|
2891
|
+
] }),
|
|
2892
|
+
visual && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "hf-hero__visual", children: visual })
|
|
2893
|
+
] });
|
|
2894
|
+
}
|
|
2895
|
+
|
|
2896
|
+
// src/layout/ResizablePanel.tsx
|
|
2897
|
+
var import_react43 = require("react");
|
|
2898
|
+
var import_jsx_runtime60 = require("react/jsx-runtime");
|
|
2899
|
+
function ResizablePanel({ primary, secondary, defaultSize = 50, minSize = 20, maxSize = 80, direction = "horizontal", onResize }) {
|
|
2900
|
+
const [size, setSize] = (0, import_react43.useState)(defaultSize);
|
|
2901
|
+
const start = (event) => {
|
|
2902
|
+
const root = event.currentTarget.parentElement;
|
|
2903
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
2904
|
+
const move = (next) => {
|
|
2905
|
+
const rect = root.getBoundingClientRect();
|
|
2906
|
+
const raw = direction === "horizontal" ? (next.clientX - rect.left) / rect.width * 100 : (next.clientY - rect.top) / rect.height * 100;
|
|
2907
|
+
const value = Math.min(maxSize, Math.max(minSize, raw));
|
|
2908
|
+
setSize(value);
|
|
2909
|
+
onResize?.(value);
|
|
2910
|
+
};
|
|
2911
|
+
const end = () => {
|
|
2912
|
+
document.removeEventListener("pointermove", move);
|
|
2913
|
+
document.removeEventListener("pointerup", end);
|
|
2914
|
+
};
|
|
2915
|
+
document.addEventListener("pointermove", move);
|
|
2916
|
+
document.addEventListener("pointerup", end);
|
|
2917
|
+
};
|
|
2918
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: `hf-resizable hf-resizable--${direction}`, children: [
|
|
2919
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { style: { flexBasis: `${size}%` }, children: primary }),
|
|
2920
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "hf-resizable__handle", role: "separator", "aria-orientation": direction, "aria-valuemin": minSize, "aria-valuemax": maxSize, "aria-valuenow": Math.round(size), tabIndex: 0, onPointerDown: start, onKeyDown: (event) => {
|
|
2921
|
+
if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(event.key)) return;
|
|
2922
|
+
event.preventDefault();
|
|
2923
|
+
const grow = event.key === "ArrowRight" || event.key === "ArrowDown";
|
|
2924
|
+
const value = Math.min(maxSize, Math.max(minSize, size + (grow ? 2 : -2)));
|
|
2925
|
+
setSize(value);
|
|
2926
|
+
onResize?.(value);
|
|
2927
|
+
} }),
|
|
2928
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { children: secondary })
|
|
2929
|
+
] });
|
|
2930
|
+
}
|
|
2931
|
+
|
|
2932
|
+
// src/feedback/NotificationCenter.tsx
|
|
2933
|
+
var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
2934
|
+
function NotificationCenter({ items, onRead, onDismiss, onReadAll, empty = "\u6682\u65E0\u901A\u77E5", title = "\u901A\u77E5\u4E2D\u5FC3" }) {
|
|
2935
|
+
const unread = items.filter((item) => item.unread).length;
|
|
2936
|
+
return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)("section", { className: "hf-notification-center", children: [
|
|
2937
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsxs)("header", { children: [
|
|
2938
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsxs)("div", { children: [
|
|
2939
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)("strong", { children: title }),
|
|
2940
|
+
unread > 0 && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", { children: unread })
|
|
2941
|
+
] }),
|
|
2942
|
+
unread > 0 && onReadAll && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("button", { type: "button", onClick: onReadAll, children: "\u5168\u90E8\u5DF2\u8BFB" })
|
|
2943
|
+
] }),
|
|
2944
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { children: items.length ? items.map(({ key, content, ...item }) => /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { onClick: () => item.unread && onRead?.(key), children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(Notification, { ...item, onClose: onDismiss ? () => onDismiss(key) : void 0, children: content }) }, key)) : /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("p", { className: "hf-notification-center__empty", children: empty }) })
|
|
2945
|
+
] });
|
|
2946
|
+
}
|
|
2947
|
+
|
|
2948
|
+
// src/data-display/VirtualList.tsx
|
|
2949
|
+
var import_react44 = require("react");
|
|
2950
|
+
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
2951
|
+
function VirtualList({ items, itemHeight, height, renderItem, itemKey, overscan = 3, label = "\u865A\u62DF\u5217\u8868" }) {
|
|
2952
|
+
const [scrollTop, setScrollTop] = (0, import_react44.useState)(0);
|
|
2953
|
+
const start = Math.max(0, Math.floor(scrollTop / itemHeight) - overscan);
|
|
2954
|
+
const end = Math.min(items.length, Math.ceil((scrollTop + height) / itemHeight) + overscan);
|
|
2955
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "hf-virtual-list", role: "list", "aria-label": label, style: { height }, onScroll: (event) => setScrollTop(event.currentTarget.scrollTop), children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { style: { height: items.length * itemHeight, position: "relative" }, children: items.slice(start, end).map((item, offset) => {
|
|
2956
|
+
const index = start + offset;
|
|
2957
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { role: "listitem", style: { height: itemHeight, left: 0, position: "absolute", right: 0, top: index * itemHeight }, children: renderItem(item, index) }, itemKey(item, index));
|
|
2958
|
+
}) }) });
|
|
2959
|
+
}
|
|
2960
|
+
|
|
2961
|
+
// src/data-display/DeveloperView.tsx
|
|
2962
|
+
var import_react45 = require("react");
|
|
2963
|
+
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
2964
|
+
function JsonNode({ name, value, depth, defaultExpanded, maxDepth }) {
|
|
2965
|
+
const complex = value !== null && typeof value === "object";
|
|
2966
|
+
const [open, setOpen] = (0, import_react45.useState)(defaultExpanded && depth < maxDepth);
|
|
2967
|
+
if (!complex) return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: "hf-json-viewer__row", children: [
|
|
2968
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("span", { children: name !== void 0 && `${name}: ` }),
|
|
2969
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("code", { className: `is-${value === null ? "null" : typeof value}`, children: value === null ? "null" : JSON.stringify(value) })
|
|
2970
|
+
] });
|
|
2971
|
+
const entries = Object.entries(value);
|
|
2972
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: "hf-json-viewer__node", children: [
|
|
2973
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("button", { type: "button", "aria-expanded": open, onClick: () => setOpen(!open), children: [
|
|
2974
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("span", { children: open ? "\u2304" : "\u203A" }),
|
|
2975
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("strong", { children: name ?? (Array.isArray(value) ? "Array" : "Object") }),
|
|
2976
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("small", { children: Array.isArray(value) ? `[${entries.length}]` : `{${entries.length}}` })
|
|
2977
|
+
] }),
|
|
2978
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { children: entries.map(([key, item]) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(JsonNode, { name: key, value: item, depth: depth + 1, defaultExpanded, maxDepth }, key)) })
|
|
2979
|
+
] });
|
|
2980
|
+
}
|
|
2981
|
+
function JsonViewer({ data, name, defaultExpanded = true, maxDepth = 2 }) {
|
|
2982
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className: "hf-json-viewer", role: "tree", "aria-label": name ?? "JSON \u67E5\u770B\u5668", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(JsonNode, { name, value: data, depth: 0, defaultExpanded, maxDepth }) });
|
|
2983
|
+
}
|
|
2984
|
+
function compareLines(before, after) {
|
|
2985
|
+
const a = before.split("\n"), b = after.split("\n"), matrix = Array.from({ length: a.length + 1 }, () => Array(b.length + 1).fill(0));
|
|
2986
|
+
for (let i2 = a.length - 1; i2 >= 0; i2--) for (let j2 = b.length - 1; j2 >= 0; j2--) matrix[i2][j2] = a[i2] === b[j2] ? matrix[i2 + 1][j2 + 1] + 1 : Math.max(matrix[i2 + 1][j2], matrix[i2][j2 + 1]);
|
|
2987
|
+
const rows = [];
|
|
2988
|
+
let i = 0, j = 0, leftNo = 1, rightNo = 1;
|
|
2989
|
+
while (i < a.length || j < b.length) {
|
|
2990
|
+
if (i < a.length && j < b.length && a[i] === b[j]) {
|
|
2991
|
+
rows.push({ kind: "same", left: a[i++], right: b[j++], leftNo: leftNo++, rightNo: rightNo++ });
|
|
2992
|
+
} else if (j < b.length && (i === a.length || matrix[i][j + 1] >= matrix[i + 1][j])) {
|
|
2993
|
+
rows.push({ kind: "add", right: b[j++], rightNo: rightNo++ });
|
|
2994
|
+
} else {
|
|
2995
|
+
rows.push({ kind: "remove", left: a[i++], leftNo: leftNo++ });
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
return rows;
|
|
2999
|
+
}
|
|
3000
|
+
function DiffCell({ number, marker, children }) {
|
|
3001
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: "hf-diff-viewer__cell", children: [
|
|
3002
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("span", { children: number ?? "" }),
|
|
3003
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("i", { children: marker }),
|
|
3004
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("code", { children: children ?? "" })
|
|
3005
|
+
] });
|
|
3006
|
+
}
|
|
3007
|
+
function DiffViewer({ before, after, beforeLabel = "\u4FEE\u6539\u524D", afterLabel = "\u4FEE\u6539\u540E", mode = "split" }) {
|
|
3008
|
+
const rows = compareLines(before, after);
|
|
3009
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: `hf-diff-viewer hf-diff-viewer--${mode}`, children: [
|
|
3010
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("header", { children: [
|
|
3011
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("strong", { children: beforeLabel }),
|
|
3012
|
+
mode === "split" && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("strong", { children: afterLabel })
|
|
3013
|
+
] }),
|
|
3014
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { children: rows.map((row, index) => mode === "split" ? /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: `is-${row.kind}`, children: [
|
|
3015
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)(DiffCell, { number: row.leftNo, marker: row.kind === "remove" ? "\u2212" : " ", children: row.left }),
|
|
3016
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)(DiffCell, { number: row.rightNo, marker: row.kind === "add" ? "+" : " ", children: row.right })
|
|
3017
|
+
] }, index) : /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className: `is-${row.kind}`, children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(DiffCell, { number: row.leftNo ?? row.rightNo, marker: row.kind === "add" ? "+" : row.kind === "remove" ? "\u2212" : " ", children: row.kind === "add" ? row.right : row.left }) }, index)) })
|
|
3018
|
+
] });
|
|
3019
|
+
}
|
|
3020
|
+
|
|
3021
|
+
// src/forms/QueryBuilder.tsx
|
|
3022
|
+
var import_jsx_runtime64 = require("react/jsx-runtime");
|
|
3023
|
+
var defaultOperators = [{ value: "equals", label: "\u7B49\u4E8E" }, { value: "notEquals", label: "\u4E0D\u7B49\u4E8E" }, { value: "contains", label: "\u5305\u542B" }];
|
|
3024
|
+
function QueryBuilder({ fields, rules, onChange, conjunction = "and", onConjunctionChange, disabled }) {
|
|
3025
|
+
const update = (id, patch) => onChange(rules.map((rule) => rule.id === id ? { ...rule, ...patch } : rule));
|
|
3026
|
+
const add = () => {
|
|
3027
|
+
const field = fields[0];
|
|
3028
|
+
if (!field) return;
|
|
3029
|
+
const operator = (field.operators ?? defaultOperators)[0]?.value ?? "equals";
|
|
3030
|
+
onChange([...rules, { id: `rule-${Date.now()}`, field: field.key, operator, value: "" }]);
|
|
3031
|
+
};
|
|
3032
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "hf-query-builder", children: [
|
|
3033
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("header", { children: [
|
|
3034
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("strong", { children: "\u6EE1\u8DB3" }),
|
|
3035
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("select", { "aria-label": "\u6761\u4EF6\u5173\u7CFB", value: conjunction, disabled, onChange: (event) => onConjunctionChange?.(event.target.value), children: [
|
|
3036
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: "and", children: "\u5168\u90E8\u6761\u4EF6" }),
|
|
3037
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: "or", children: "\u4EFB\u4E00\u6761\u4EF6" })
|
|
3038
|
+
] })
|
|
3039
|
+
] }),
|
|
3040
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { children: rules.map((rule, index) => {
|
|
3041
|
+
const field = fields.find((item) => item.key === rule.field) ?? fields[0];
|
|
3042
|
+
const operators = field?.operators ?? defaultOperators;
|
|
3043
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "hf-query-builder__rule", children: [
|
|
3044
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { children: index + 1 }),
|
|
3045
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("select", { "aria-label": `\u6761\u4EF6 ${index + 1} \u5B57\u6BB5`, value: rule.field, disabled, onChange: (event) => {
|
|
3046
|
+
const next = fields.find((item) => item.key === event.target.value);
|
|
3047
|
+
update(rule.id, { field: next.key, operator: (next.operators ?? defaultOperators)[0]?.value ?? "equals", value: "" });
|
|
3048
|
+
}, children: fields.map((item) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: item.key, children: item.label }, item.key)) }),
|
|
3049
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("select", { "aria-label": `\u6761\u4EF6 ${index + 1} \u8FD0\u7B97\u7B26`, value: rule.operator, disabled, onChange: (event) => update(rule.id, { operator: event.target.value }), children: operators.map((item) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: item.value, children: item.label }, item.value)) }),
|
|
3050
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("input", { "aria-label": `\u6761\u4EF6 ${index + 1} \u503C`, type: field?.type ?? "text", value: rule.value, disabled, onChange: (event) => update(rule.id, { value: event.target.value }) }),
|
|
3051
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", "aria-label": `\u5220\u9664\u6761\u4EF6 ${index + 1}`, disabled, onClick: () => onChange(rules.filter((item) => item.id !== rule.id)), children: "\xD7" })
|
|
3052
|
+
] }, rule.id);
|
|
3053
|
+
}) }),
|
|
3054
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("button", { type: "button", className: "hf-query-builder__add", disabled: disabled || !fields.length, onClick: add, children: "\uFF0B \u6DFB\u52A0\u6761\u4EF6" })
|
|
3055
|
+
] });
|
|
3056
|
+
}
|
|
3057
|
+
|
|
3058
|
+
// src/data-display/WorkflowViews.tsx
|
|
3059
|
+
var import_react46 = require("react");
|
|
3060
|
+
var import_jsx_runtime65 = require("react/jsx-runtime");
|
|
3061
|
+
function FlowCanvas({ nodes, edges, width = 900, height = 420, selectedId, onSelect, empty = "\u6682\u65E0\u6D41\u7A0B\u8282\u70B9" }) {
|
|
3062
|
+
const map = new Map(nodes.map((node) => [node.id, node]));
|
|
3063
|
+
if (!nodes.length) return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "hf-flow-canvas hf-flow-canvas__empty", children: empty });
|
|
3064
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "hf-flow-canvas", role: "group", "aria-label": "\u6D41\u7A0B\u753B\u5E03", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { style: { width, height }, children: [
|
|
3065
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("svg", { viewBox: `0 0 ${width} ${height}`, "aria-hidden": "true", children: edges.map((edge, index) => {
|
|
3066
|
+
const from = map.get(edge.from), to = map.get(edge.to);
|
|
3067
|
+
if (!from || !to) return null;
|
|
3068
|
+
const x1 = from.x + 82, y1 = from.y + 28, x2 = to.x, y2 = to.y + 28, bend = Math.max(30, Math.abs(x2 - x1) / 2);
|
|
3069
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("g", { children: [
|
|
3070
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("path", { d: `M${x1} ${y1} C${x1 + bend} ${y1},${x2 - bend} ${y2},${x2} ${y2}` }),
|
|
3071
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("circle", { cx: x2, cy: y2, r: "3" }),
|
|
3072
|
+
edge.label && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("text", { x: (x1 + x2) / 2, y: (y1 + y2) / 2 - 8, children: edge.label })
|
|
3073
|
+
] }, edge.id ?? index);
|
|
3074
|
+
}) }),
|
|
3075
|
+
nodes.map((node) => /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("button", { type: "button", className: `hf-flow-canvas__node is-${node.status ?? "default"}${selectedId === node.id ? " is-selected" : ""}`, style: { left: node.x, top: node.y }, "aria-pressed": selectedId === node.id, onClick: () => onSelect?.(node.id), children: [
|
|
3076
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("strong", { children: node.label }),
|
|
3077
|
+
node.description && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("small", { children: node.description })
|
|
3078
|
+
] }, node.id))
|
|
3079
|
+
] }) });
|
|
3080
|
+
}
|
|
3081
|
+
function KanbanBoard({ columns, onMove, onCardClick, empty = "\u6682\u65E0\u770B\u677F\u5217" }) {
|
|
3082
|
+
const drop = (event, target) => {
|
|
3083
|
+
event.preventDefault();
|
|
3084
|
+
const card = event.dataTransfer.getData("application/x-hf-card"), from = event.dataTransfer.getData("application/x-hf-column");
|
|
3085
|
+
if (card && from && from !== target) onMove?.(card, from, target);
|
|
3086
|
+
};
|
|
3087
|
+
if (!columns.length) return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "hf-kanban-board__empty", children: empty });
|
|
3088
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "hf-kanban-board", "aria-label": "\u770B\u677F", children: columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("section", { style: { "--hf-kanban-accent": column.accent }, onDragOver: (event) => event.preventDefault(), onDrop: (event) => drop(event, column.id), children: [
|
|
3089
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("header", { children: [
|
|
3090
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("strong", { children: column.title }),
|
|
3091
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("span", { children: [
|
|
3092
|
+
column.cards.length,
|
|
3093
|
+
column.limit ? ` / ${column.limit}` : ""
|
|
3094
|
+
] })
|
|
3095
|
+
] }),
|
|
3096
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { children: column.cards.map((card) => /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("button", { type: "button", draggable: Boolean(onMove), className: "hf-kanban-card", onDragStart: (event) => {
|
|
3097
|
+
event.dataTransfer.setData("application/x-hf-card", card.id);
|
|
3098
|
+
event.dataTransfer.setData("application/x-hf-column", column.id);
|
|
3099
|
+
}, onClick: () => onCardClick?.(card.id, column.id), children: [
|
|
3100
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("strong", { children: card.title }),
|
|
3101
|
+
card.description && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("p", { children: card.description }),
|
|
3102
|
+
card.tags?.length ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { children: card.tags.map((tag) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("i", { children: tag }, tag)) }) : null,
|
|
3103
|
+
card.meta && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("small", { children: card.meta })
|
|
3104
|
+
] }, card.id)) })
|
|
3105
|
+
] }, column.id)) });
|
|
3106
|
+
}
|
|
3107
|
+
var day = 864e5;
|
|
3108
|
+
var toTime = (value) => new Date(value).setHours(0, 0, 0, 0);
|
|
3109
|
+
function GanttChart({ tasks, start, end, onTaskClick, empty = "\u6682\u65E0\u6392\u671F\u4EFB\u52A1" }) {
|
|
3110
|
+
const range = (0, import_react46.useMemo)(() => {
|
|
3111
|
+
const starts = tasks.map((task) => toTime(task.start)), ends = tasks.map((task) => toTime(task.end));
|
|
3112
|
+
const from = start ? toTime(start) : Math.min(...starts), to = end ? toTime(end) : Math.max(...ends);
|
|
3113
|
+
return { from, days: Math.max(1, Math.round((to - from) / day) + 1) };
|
|
3114
|
+
}, [tasks, start, end]);
|
|
3115
|
+
if (!tasks.length) return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "hf-gantt-chart__empty", children: empty });
|
|
3116
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "hf-gantt-chart", children: [
|
|
3117
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("header", { children: [
|
|
3118
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("strong", { children: "\u4EFB\u52A1" }),
|
|
3119
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { children: Array.from({ length: Math.min(range.days, 31) }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { children: new Date(range.from + index * day).getDate() }, index)) })
|
|
3120
|
+
] }),
|
|
3121
|
+
tasks.map((task) => {
|
|
3122
|
+
const offset = Math.max(0, (toTime(task.start) - range.from) / day), length = Math.max(1, (toTime(task.end) - toTime(task.start)) / day + 1);
|
|
3123
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "hf-gantt-chart__row", children: [
|
|
3124
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("span", { children: [
|
|
3125
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("strong", { children: task.label }),
|
|
3126
|
+
task.group && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("small", { children: task.group })
|
|
3127
|
+
] }),
|
|
3128
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("button", { type: "button", style: { left: `${offset / range.days * 100}%`, width: `${length / range.days * 100}%`, "--hf-gantt-color": task.color }, onClick: () => onTaskClick?.(task.id), children: [
|
|
3129
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("i", { style: { width: `${Math.max(0, Math.min(100, task.progress ?? 0))}%` } }),
|
|
3130
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("span", { children: [
|
|
3131
|
+
task.progress ?? 0,
|
|
3132
|
+
"%"
|
|
3133
|
+
] })
|
|
3134
|
+
] }) })
|
|
3135
|
+
] }, task.id);
|
|
3136
|
+
})
|
|
3137
|
+
] });
|
|
3138
|
+
}
|
|
3139
|
+
function ChartContainer({ title, description, actions, legend, children, height = 320, loading, empty, emptyContent = "\u6682\u65E0\u56FE\u8868\u6570\u636E" }) {
|
|
3140
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("section", { className: "hf-chart-container", children: [
|
|
3141
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("header", { children: [
|
|
3142
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { children: [
|
|
3143
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("strong", { children: title }),
|
|
3144
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("p", { children: description })
|
|
3145
|
+
] }),
|
|
3146
|
+
actions
|
|
3147
|
+
] }),
|
|
3148
|
+
legend?.length ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "hf-chart-container__legend", children: legend.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("span", { children: [
|
|
3149
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("i", { style: { background: item.color } }),
|
|
3150
|
+
item.label,
|
|
3151
|
+
item.value && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("strong", { children: item.value })
|
|
3152
|
+
] }, index)) }) : null,
|
|
3153
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "hf-chart-container__body", style: { height }, children: loading ? /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { className: "hf-chart-container__state", children: [
|
|
3154
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "hf-spinner" }),
|
|
3155
|
+
"\u6B63\u5728\u52A0\u8F7D\u56FE\u8868"
|
|
3156
|
+
] }) : empty ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "hf-chart-container__state", children: emptyContent }) : children })
|
|
3157
|
+
] });
|
|
3158
|
+
}
|
|
3159
|
+
function PivotTable({ data, row, column, values, rowLabel = "\u9879\u76EE", showTotals = true, empty = "\u6682\u65E0\u900F\u89C6\u6570\u636E" }) {
|
|
3160
|
+
const rows = [...new Set(data.map(row))], columns = [...new Set(data.map(column))];
|
|
3161
|
+
const calculate = (items, metric) => {
|
|
3162
|
+
if (metric.aggregate === "count") return items.length;
|
|
3163
|
+
const sum = items.reduce((total, item) => total + metric.value(item), 0);
|
|
3164
|
+
return metric.aggregate === "average" ? items.length ? sum / items.length : 0 : sum;
|
|
3165
|
+
};
|
|
3166
|
+
if (!data.length || !values.length) return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "hf-pivot-table__empty", children: empty });
|
|
3167
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "hf-pivot-table", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("table", { children: [
|
|
3168
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("thead", { children: [
|
|
3169
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("tr", { children: [
|
|
3170
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("th", { rowSpan: 2, children: rowLabel }),
|
|
3171
|
+
columns.map((item) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("th", { colSpan: values.length, children: item }, item)),
|
|
3172
|
+
showTotals && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("th", { colSpan: values.length, children: "\u5408\u8BA1" })
|
|
3173
|
+
] }),
|
|
3174
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("tr", { children: [...columns, ...showTotals ? ["__total"] : []].flatMap((col) => values.map((metric) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("th", { children: metric.label }, `${col}-${metric.key}`))) })
|
|
3175
|
+
] }),
|
|
3176
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("tbody", { children: rows.map((rowName) => /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("tr", { children: [
|
|
3177
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)("th", { children: rowName }),
|
|
3178
|
+
[...columns, ...showTotals ? ["__total"] : []].flatMap((columnName) => values.map((metric) => {
|
|
3179
|
+
const items = data.filter((item) => row(item) === rowName && (columnName === "__total" || column(item) === columnName));
|
|
3180
|
+
const result = calculate(items, metric);
|
|
3181
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("td", { children: metric.format?.(result) ?? result }, `${columnName}-${metric.key}`);
|
|
3182
|
+
}))
|
|
3183
|
+
] }, rowName)) })
|
|
3184
|
+
] }) });
|
|
3185
|
+
}
|
|
3186
|
+
|
|
3187
|
+
// src/forms/FilterBuilder.tsx
|
|
3188
|
+
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
3189
|
+
function FilterBuilder({ fields, value, onChange, disabled, addLabel = "\u6DFB\u52A0\u7B5B\u9009" }) {
|
|
3190
|
+
const add = () => {
|
|
3191
|
+
const field = fields.find((item) => !value.some((filter) => filter.field === item.key)) ?? fields[0];
|
|
3192
|
+
if (field) onChange([...value, { id: `filter-${Date.now()}`, field: field.key, value: "" }]);
|
|
3193
|
+
};
|
|
3194
|
+
const update = (id, patch) => onChange(value.map((item) => item.id === id ? { ...item, ...patch } : item));
|
|
3195
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "hf-filter-builder", role: "group", "aria-label": "\u7B5B\u9009\u6761\u4EF6", children: [
|
|
3196
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { children: value.map((filter, index) => {
|
|
3197
|
+
const field = fields.find((item) => item.key === filter.field) ?? fields[0];
|
|
3198
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "hf-filter-builder__item", children: [
|
|
3199
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("select", { "aria-label": `\u7B5B\u9009 ${index + 1} \u5B57\u6BB5`, value: filter.field, disabled, onChange: (event) => update(filter.id, { field: event.target.value, value: "" }), children: fields.map((item) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("option", { value: item.key, children: item.label }, item.key)) }),
|
|
3200
|
+
field?.options ? /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("select", { "aria-label": `\u7B5B\u9009 ${index + 1} \u503C`, value: filter.value, disabled, onChange: (event) => update(filter.id, { value: event.target.value }), children: [
|
|
3201
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("option", { value: "", children: "\u8BF7\u9009\u62E9" }),
|
|
3202
|
+
field.options.map((item) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("option", { value: item.value, children: item.label }, item.value))
|
|
3203
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("input", { "aria-label": `\u7B5B\u9009 ${index + 1} \u503C`, type: field?.type ?? "text", value: filter.value, disabled, onChange: (event) => update(filter.id, { value: event.target.value }) }),
|
|
3204
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("button", { type: "button", "aria-label": `\u5220\u9664\u7B5B\u9009 ${index + 1}`, disabled, onClick: () => onChange(value.filter((item) => item.id !== filter.id)), children: "\xD7" })
|
|
3205
|
+
] }, filter.id);
|
|
3206
|
+
}) }),
|
|
3207
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("button", { type: "button", className: "hf-filter-builder__add", disabled: disabled || !fields.length, onClick: add, children: [
|
|
3208
|
+
"\uFF0B ",
|
|
3209
|
+
addLabel
|
|
3210
|
+
] }),
|
|
3211
|
+
value.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("button", { type: "button", className: "hf-filter-builder__clear", disabled, onClick: () => onChange([]), children: "\u6E05\u7A7A" })
|
|
3212
|
+
] });
|
|
3213
|
+
}
|
|
3214
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
3215
|
+
0 && (module.exports = {
|
|
3216
|
+
Accordion,
|
|
3217
|
+
ActivityFeed,
|
|
3218
|
+
ActivityIndicator,
|
|
3219
|
+
AgentRunTimeline,
|
|
3220
|
+
Alert,
|
|
3221
|
+
ApprovalFlow,
|
|
3222
|
+
AuditLog,
|
|
3223
|
+
AuthLayout,
|
|
3224
|
+
AvailabilityGrid,
|
|
3225
|
+
Avatar,
|
|
3226
|
+
AvatarGroup,
|
|
3227
|
+
Badge,
|
|
3228
|
+
Breadcrumb,
|
|
3229
|
+
Button,
|
|
3230
|
+
ButtonGroup,
|
|
3231
|
+
Calendar,
|
|
3232
|
+
Card,
|
|
3233
|
+
Cascader,
|
|
3234
|
+
ChartContainer,
|
|
3235
|
+
ChatComposer,
|
|
3236
|
+
ChatMessage,
|
|
3237
|
+
Checkbox,
|
|
3238
|
+
CheckboxGroup,
|
|
3239
|
+
ChoiceGroup,
|
|
3240
|
+
CircularProgress,
|
|
3241
|
+
CitationList,
|
|
3242
|
+
CodeBlock,
|
|
3243
|
+
CodeEditor,
|
|
3244
|
+
ColorPicker,
|
|
3245
|
+
Combobox,
|
|
3246
|
+
CommandPalette,
|
|
3247
|
+
CommentThread,
|
|
3248
|
+
Container,
|
|
3249
|
+
ContextMenu,
|
|
3250
|
+
ConversationBranch,
|
|
3251
|
+
DataGrid,
|
|
3252
|
+
DatePicker,
|
|
3253
|
+
DateRangePicker,
|
|
3254
|
+
Descriptions,
|
|
3255
|
+
DiffViewer,
|
|
3256
|
+
Divider,
|
|
3257
|
+
Drawer,
|
|
3258
|
+
Dropdown,
|
|
3259
|
+
DropdownMenu,
|
|
3260
|
+
EmptyState,
|
|
3261
|
+
EventCard,
|
|
3262
|
+
FileExplorer,
|
|
3263
|
+
FilePreview,
|
|
3264
|
+
FilterBuilder,
|
|
3265
|
+
FloatingNav,
|
|
3266
|
+
FlowCanvas,
|
|
3267
|
+
Form,
|
|
3268
|
+
FormItem,
|
|
3269
|
+
GanttChart,
|
|
3270
|
+
Grid,
|
|
3271
|
+
Hero,
|
|
3272
|
+
Icon,
|
|
3273
|
+
IconButton,
|
|
3274
|
+
Input,
|
|
3275
|
+
InsightBoard,
|
|
3276
|
+
JsonViewer,
|
|
3277
|
+
KanbanBoard,
|
|
3278
|
+
Link,
|
|
3279
|
+
List,
|
|
3280
|
+
LoadingDots,
|
|
3281
|
+
LoadingOverlay,
|
|
3282
|
+
MarkdownContent,
|
|
3283
|
+
Masonry,
|
|
3284
|
+
MegaMenu,
|
|
3285
|
+
MemberPicker,
|
|
3286
|
+
MentionInput,
|
|
3287
|
+
MobileNavigation,
|
|
3288
|
+
Modal,
|
|
3289
|
+
ModelSelector,
|
|
3290
|
+
MultiSelect,
|
|
3291
|
+
Notification,
|
|
3292
|
+
NotificationCenter,
|
|
3293
|
+
NumberInput,
|
|
3294
|
+
PageLayout,
|
|
3295
|
+
Pagination,
|
|
3296
|
+
PermissionMatrix,
|
|
3297
|
+
PivotTable,
|
|
3298
|
+
Popconfirm,
|
|
3299
|
+
Popover,
|
|
3300
|
+
Presence,
|
|
3301
|
+
Progress,
|
|
3302
|
+
ProgressBar,
|
|
3303
|
+
ProgressRing,
|
|
3304
|
+
PromptSuggestions,
|
|
3305
|
+
QueryBuilder,
|
|
3306
|
+
Radio,
|
|
3307
|
+
RadioGroup,
|
|
3308
|
+
RecurrenceEditor,
|
|
3309
|
+
ResizablePanel,
|
|
3310
|
+
ResourceCalendar,
|
|
3311
|
+
Result,
|
|
3312
|
+
RichTextEditor,
|
|
3313
|
+
Scheduler,
|
|
3314
|
+
Scrollspy,
|
|
3315
|
+
SearchInput,
|
|
3316
|
+
SegmentedControl,
|
|
3317
|
+
Select,
|
|
3318
|
+
SharePanel,
|
|
3319
|
+
ShrinkNav,
|
|
3320
|
+
Sidebar,
|
|
3321
|
+
Skeleton,
|
|
3322
|
+
Slider,
|
|
3323
|
+
Sparkline,
|
|
3324
|
+
Spinner,
|
|
3325
|
+
SplitButton,
|
|
3326
|
+
Stack,
|
|
3327
|
+
Stat,
|
|
3328
|
+
StatisticCard,
|
|
3329
|
+
StepProgress,
|
|
3330
|
+
Steps,
|
|
3331
|
+
Switch,
|
|
3332
|
+
Table,
|
|
3333
|
+
Tabs,
|
|
3334
|
+
Tag,
|
|
3335
|
+
Textarea,
|
|
3336
|
+
ThemeProvider,
|
|
3337
|
+
TimePicker,
|
|
3338
|
+
Timeline,
|
|
3339
|
+
TimezoneSelect,
|
|
3340
|
+
Toast,
|
|
3341
|
+
TokenUsage,
|
|
3342
|
+
ToolCallCard,
|
|
3343
|
+
Tooltip,
|
|
3344
|
+
Transfer,
|
|
3345
|
+
Tree,
|
|
3346
|
+
TreeSelect,
|
|
3347
|
+
Typography,
|
|
3348
|
+
Upload,
|
|
3349
|
+
ValidatedInput,
|
|
3350
|
+
VersionHistory,
|
|
3351
|
+
VirtualList,
|
|
3352
|
+
VoiceInput,
|
|
3353
|
+
activateNavigationItem,
|
|
3354
|
+
darkTheme,
|
|
3355
|
+
defaultTheme,
|
|
3356
|
+
highContrastTheme,
|
|
3357
|
+
tokensToStyle,
|
|
3358
|
+
validateForm,
|
|
3359
|
+
validateValue
|
|
3360
|
+
});
|
|
3361
|
+
//# sourceMappingURL=index.cjs.map
|