@hxdhxd/harmony-flow-ui 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -5
- package/dist/index.cjs +322 -294
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +347 -183
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +321 -293
- package/dist/index.js.map +1 -1
- package/package.json +15 -1
package/dist/index.cjs
CHANGED
|
@@ -176,13 +176,43 @@ var defaultTheme = {
|
|
|
176
176
|
colorText: "#142033",
|
|
177
177
|
colorTextMuted: "#66758c",
|
|
178
178
|
colorBorder: "#dce9f7",
|
|
179
|
+
radiusControl: "6px",
|
|
180
|
+
radiusPanel: "8px",
|
|
181
|
+
radiusOverlay: "10px",
|
|
182
|
+
shadowPopover: "0 8px 24px rgba(41, 106, 168, 0.12)",
|
|
183
|
+
shadowModal: "0 18px 48px rgba(41, 106, 168, 0.16)",
|
|
179
184
|
radiusMd: "14px",
|
|
180
185
|
radiusLg: "24px",
|
|
181
186
|
shadowElevated: "0 18px 48px rgba(41, 106, 168, 0.16)",
|
|
182
187
|
motionDuration: "180ms"
|
|
183
188
|
};
|
|
184
|
-
var darkTheme = {
|
|
185
|
-
|
|
189
|
+
var darkTheme = {
|
|
190
|
+
...defaultTheme,
|
|
191
|
+
colorPrimary: "#58a9ff",
|
|
192
|
+
colorPrimaryHover: "#7cbbff",
|
|
193
|
+
colorBackground: "#0d1724",
|
|
194
|
+
colorSurface: "#152337",
|
|
195
|
+
colorText: "#f4f8fc",
|
|
196
|
+
colorTextMuted: "#a9bad0",
|
|
197
|
+
colorBorder: "#30445b",
|
|
198
|
+
shadowPopover: "0 8px 24px rgba(0, 0, 0, 0.32)",
|
|
199
|
+
shadowModal: "0 20px 54px rgba(0, 0, 0, 0.46)",
|
|
200
|
+
shadowElevated: "0 20px 54px rgba(0, 0, 0, 0.46)"
|
|
201
|
+
};
|
|
202
|
+
var highContrastTheme = {
|
|
203
|
+
...defaultTheme,
|
|
204
|
+
colorPrimary: "#005fcc",
|
|
205
|
+
colorPrimaryHover: "#004a9f",
|
|
206
|
+
colorBackground: "#ffffff",
|
|
207
|
+
colorSurface: "#ffffff",
|
|
208
|
+
colorText: "#000000",
|
|
209
|
+
colorTextMuted: "#303030",
|
|
210
|
+
colorBorder: "#000000",
|
|
211
|
+
shadowPopover: "0 0 0 2px #000000",
|
|
212
|
+
shadowModal: "0 0 0 2px #000000",
|
|
213
|
+
shadowElevated: "0 0 0 2px #000000",
|
|
214
|
+
motionDuration: "0ms"
|
|
215
|
+
};
|
|
186
216
|
var tokenVariables = {
|
|
187
217
|
colorPrimary: "--hf-color-primary",
|
|
188
218
|
colorPrimaryHover: "--hf-color-primary-hover",
|
|
@@ -191,6 +221,11 @@ var tokenVariables = {
|
|
|
191
221
|
colorText: "--hf-color-text",
|
|
192
222
|
colorTextMuted: "--hf-color-text-muted",
|
|
193
223
|
colorBorder: "--hf-color-border",
|
|
224
|
+
radiusControl: "--hf-radius-control",
|
|
225
|
+
radiusPanel: "--hf-radius-panel",
|
|
226
|
+
radiusOverlay: "--hf-radius-overlay",
|
|
227
|
+
shadowPopover: "--hf-shadow-popover",
|
|
228
|
+
shadowModal: "--hf-shadow-modal",
|
|
194
229
|
radiusMd: "--hf-radius-md",
|
|
195
230
|
radiusLg: "--hf-radius-lg",
|
|
196
231
|
shadowElevated: "--hf-shadow-elevated",
|
|
@@ -220,7 +255,7 @@ function ThemeProvider({ children, tokens, mode = "light", className = "", style
|
|
|
220
255
|
// src/components/Button.tsx
|
|
221
256
|
var import_react = require("react");
|
|
222
257
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
223
|
-
var Button = (0, import_react.forwardRef)(function Button2({ children, className = "", variant = "primary", size = "md", shape = "
|
|
258
|
+
var Button = (0, import_react.forwardRef)(function Button2({ children, className = "", variant = "primary", size = "md", shape = "rounded", fullWidth = false, loading = false, leadingIcon, trailingIcon, iconOnly = false, disabled, ...props }, ref) {
|
|
224
259
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
225
260
|
"button",
|
|
226
261
|
{
|
|
@@ -465,7 +500,7 @@ function Modal({ open, title, children, onClose, footer }) {
|
|
|
465
500
|
/* @__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
501
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("header", { className: "hf-modal__header", children: [
|
|
467
502
|
/* @__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"
|
|
503
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Button, { variant: "quiet", size: "sm", iconOnly: true, leadingIcon: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "close", size: 16 }), onClick: onClose, "aria-label": "\u5173\u95ED\u5F39\u7A97" })
|
|
469
504
|
] }),
|
|
470
505
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "hf-modal__body", children }),
|
|
471
506
|
footer && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("footer", { className: "hf-modal__footer", children: footer })
|
|
@@ -541,7 +576,10 @@ function Accordion({ items, value, defaultValue = [], onChange, multiple = false
|
|
|
541
576
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("section", { className: open ? "is-open" : "", children: [
|
|
542
577
|
/* @__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
578
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: item.title }),
|
|
544
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.
|
|
579
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "hf-accordion__toggle", "aria-hidden": "true", children: [
|
|
580
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("i", {}),
|
|
581
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("i", {})
|
|
582
|
+
] })
|
|
545
583
|
] }) }),
|
|
546
584
|
open && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "hf-accordion__panel", children: item.content })
|
|
547
585
|
] }, item.key);
|
|
@@ -590,7 +628,7 @@ function ColorPicker({ value, onChange, label, presets = ["#0a7cff", "#19a989",
|
|
|
590
628
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("button", { type: "button", className: "hf-color-picker__trigger", disabled, "aria-expanded": open, onClick: () => setOpen(!open), children: [
|
|
591
629
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { style: { background: value } }),
|
|
592
630
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("code", { children: value.toUpperCase() }),
|
|
593
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
631
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Icon, { className: "hf-picker-trigger__chevron", name: "chevron-down", size: 16 })
|
|
594
632
|
] }),
|
|
595
633
|
open && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "hf-color-picker__panel", children: [
|
|
596
634
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("input", { type: "color", "aria-label": "\u9009\u62E9\u989C\u8272", value, onChange: (event) => onChange(event.target.value) }),
|
|
@@ -741,7 +779,7 @@ function ChatComposer({ value, onChange, onSend, attachments = [], onRemoveAttac
|
|
|
741
779
|
item.icon,
|
|
742
780
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("strong", { children: item.name }),
|
|
743
781
|
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: "
|
|
782
|
+
onRemoveAttachment && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", "aria-label": `\u79FB\u9664\u9644\u4EF6 ${item.name}`, onClick: () => onRemoveAttachment(item.id), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Icon, { name: "close", size: 14 }) })
|
|
745
783
|
] }, item.id)) }),
|
|
746
784
|
/* @__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
785
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("footer", { children: [
|
|
@@ -921,7 +959,7 @@ function CodeBlock({ code, language = "text", filename, wrap, showLineNumbers =
|
|
|
921
959
|
function VoiceInput({ state = "idle", duration = "00:00", level = 0.45, disabled, onStart, onStop, onCancel, error }) {
|
|
922
960
|
const active = state === "listening";
|
|
923
961
|
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 ? "
|
|
962
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: "hf-voice-input__main", "aria-label": active ? "\u505C\u6B62\u5F55\u97F3" : state === "processing" ? "\u6B63\u5728\u8BC6\u522B\u8BED\u97F3" : "\u5F00\u59CB\u8BED\u97F3\u8F93\u5165", disabled: disabled || state === "processing", onClick: active ? onStop : onStart, children: state === "processing" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "hf-spinner" }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: active ? "hf-voice-input__stop-icon" : "hf-voice-input__record-icon" }) }),
|
|
925
963
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { children: [
|
|
926
964
|
/* @__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
965
|
/* @__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" })
|
|
@@ -940,7 +978,7 @@ function ModelSelector({ models, value, onChange, label = "\u9009\u62E9\u6A21\u5
|
|
|
940
978
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("strong", { children: selected?.name ?? label }),
|
|
941
979
|
selected?.description && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("small", { children: selected.description })
|
|
942
980
|
] }),
|
|
943
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
981
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Icon, { className: "hf-model-selector__chevron", name: "chevron-down", size: 16 })
|
|
944
982
|
] }),
|
|
945
983
|
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
984
|
onChange(model.id);
|
|
@@ -1257,7 +1295,7 @@ function MemberPicker({ members, value, onChange, label = "\u6DFB\u52A0\u6210\u5
|
|
|
1257
1295
|
return item && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { children: [
|
|
1258
1296
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Avatar, { name: item.name, src: item.avatar, size: "sm" }),
|
|
1259
1297
|
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: "
|
|
1298
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", disabled, "aria-label": `\u79FB\u9664 ${item.name}`, onClick: () => onChange(value.filter((key) => key !== id)), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Icon, { name: "close", size: 14 }) })
|
|
1261
1299
|
] }, id);
|
|
1262
1300
|
}) }),
|
|
1263
1301
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("input", { "aria-label": label, value: query, disabled, placeholder: label, onChange: (event) => setQuery(event.target.value) }),
|
|
@@ -1291,27 +1329,115 @@ function SharePanel({ scope, onScopeChange, members, onCopyLink, linkCopied, foo
|
|
|
1291
1329
|
] }, item)) }),
|
|
1292
1330
|
members && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "hf-share-panel__members", children: members }),
|
|
1293
1331
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("footer", { children: [
|
|
1294
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1332
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Button, { type: "button", size: "sm", variant: "secondary", onClick: onCopyLink, children: linkCopied ? "\u94FE\u63A5\u5DF2\u590D\u5236" : "\u590D\u5236\u94FE\u63A5" }),
|
|
1295
1333
|
footer
|
|
1296
1334
|
] })
|
|
1297
1335
|
] });
|
|
1298
1336
|
}
|
|
1299
1337
|
|
|
1300
|
-
// src/
|
|
1338
|
+
// src/forms/Select.tsx
|
|
1339
|
+
var import_react18 = require("react");
|
|
1301
1340
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1341
|
+
var Select = (0, import_react18.forwardRef)(function Select2({ id, label, hint, error, options, placeholder, className = "", value, defaultValue, onChange, disabled, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...props }, forwardedRef) {
|
|
1342
|
+
const generatedId = (0, import_react18.useId)();
|
|
1343
|
+
const inputId = id ?? generatedId;
|
|
1344
|
+
const triggerId = `${inputId}-trigger`;
|
|
1345
|
+
const listboxId = `${inputId}-listbox`;
|
|
1346
|
+
const descriptionId = `${inputId}-description`;
|
|
1347
|
+
const [open, setOpen] = (0, import_react18.useState)(false);
|
|
1348
|
+
const rootRef = useDismissibleLayer(open, () => setOpen(false), { autoFocus: false });
|
|
1349
|
+
const nativeRef = (0, import_react18.useRef)(null);
|
|
1350
|
+
const [innerValue, setInnerValue] = (0, import_react18.useState)(() => String(defaultValue ?? (placeholder ? "" : options.find((option) => !option.disabled)?.value ?? "")));
|
|
1351
|
+
const selectedValue = value === void 0 ? innerValue : String(value);
|
|
1352
|
+
const selectedOption = options.find((option) => option.value === selectedValue);
|
|
1353
|
+
const enabledIndices = options.map((option, index) => option.disabled ? -1 : index).filter((index) => index >= 0);
|
|
1354
|
+
const selectedIndex = options.findIndex((option) => option.value === selectedValue);
|
|
1355
|
+
const [activeIndex, setActiveIndex] = (0, import_react18.useState)(selectedIndex >= 0 ? selectedIndex : enabledIndices[0] ?? -1);
|
|
1356
|
+
const assignRef = (node) => {
|
|
1357
|
+
nativeRef.current = node;
|
|
1358
|
+
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
1359
|
+
else if (forwardedRef) forwardedRef.current = node;
|
|
1360
|
+
};
|
|
1361
|
+
const handleNativeChange = (event) => {
|
|
1362
|
+
if (value === void 0) setInnerValue(event.currentTarget.value);
|
|
1363
|
+
onChange?.(event);
|
|
1364
|
+
};
|
|
1365
|
+
const choose = (nextValue) => {
|
|
1366
|
+
const native = nativeRef.current;
|
|
1367
|
+
if (!native) return;
|
|
1368
|
+
Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, "value")?.set?.call(native, nextValue);
|
|
1369
|
+
native.dispatchEvent(new Event("change", { bubbles: true }));
|
|
1370
|
+
if (value === void 0) setInnerValue(nextValue);
|
|
1371
|
+
setOpen(false);
|
|
1372
|
+
window.requestAnimationFrame(() => document.getElementById(triggerId)?.focus());
|
|
1373
|
+
};
|
|
1374
|
+
(0, import_react18.useEffect)(() => {
|
|
1375
|
+
if (selectedIndex >= 0) setActiveIndex(selectedIndex);
|
|
1376
|
+
}, [selectedIndex]);
|
|
1377
|
+
const move = (direction) => {
|
|
1378
|
+
if (!enabledIndices.length) return;
|
|
1379
|
+
const current = enabledIndices.indexOf(activeIndex);
|
|
1380
|
+
const next = current < 0 ? 0 : (current + direction + enabledIndices.length) % enabledIndices.length;
|
|
1381
|
+
setActiveIndex(enabledIndices[next]);
|
|
1382
|
+
};
|
|
1383
|
+
const handleKeyDown = (event) => {
|
|
1384
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
1385
|
+
event.preventDefault();
|
|
1386
|
+
if (!open) setOpen(true);
|
|
1387
|
+
move(event.key === "ArrowDown" ? 1 : -1);
|
|
1388
|
+
} else if ((event.key === "Enter" || event.key === " ") && open) {
|
|
1389
|
+
event.preventDefault();
|
|
1390
|
+
const option = options[activeIndex];
|
|
1391
|
+
if (option && !option.disabled) choose(option.value);
|
|
1392
|
+
} else if (event.key === "Escape" && open) {
|
|
1393
|
+
event.preventDefault();
|
|
1394
|
+
setOpen(false);
|
|
1395
|
+
} else if (event.key === "Home" && open && enabledIndices.length) {
|
|
1396
|
+
event.preventDefault();
|
|
1397
|
+
setActiveIndex(enabledIndices[0]);
|
|
1398
|
+
} else if (event.key === "End" && open && enabledIndices.length) {
|
|
1399
|
+
event.preventDefault();
|
|
1400
|
+
setActiveIndex(enabledIndices[enabledIndices.length - 1]);
|
|
1401
|
+
} else if (event.key === "Tab") setOpen(false);
|
|
1402
|
+
};
|
|
1403
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: `hf-field ${className}`.trim(), ref: rootRef, children: [
|
|
1404
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("label", { className: "hf-field__label", htmlFor: triggerId, children: label }),
|
|
1405
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: `hf-select-shell ${open ? "hf-select-shell--open" : ""} ${error ? "hf-select-shell--error" : ""}`, children: [
|
|
1406
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("select", { ref: assignRef, id: inputId, className: "hf-select-native", tabIndex: -1, "aria-hidden": "true", value: selectedValue, disabled, onChange: handleNativeChange, ...props, children: [
|
|
1407
|
+
placeholder && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: "", disabled: true, children: placeholder }),
|
|
1408
|
+
options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: option.value, disabled: option.disabled, children: typeof option.label === "string" ? option.label : option.value }, option.value))
|
|
1409
|
+
] }),
|
|
1410
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.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: () => {
|
|
1411
|
+
setActiveIndex(selectedIndex >= 0 ? selectedIndex : enabledIndices[0] ?? -1);
|
|
1412
|
+
setOpen((current) => !current);
|
|
1413
|
+
}, onKeyDown: handleKeyDown, children: [
|
|
1414
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: !selectedOption ? "hf-select__placeholder" : "", children: selectedOption?.label ?? placeholder ?? "\u8BF7\u9009\u62E9" }),
|
|
1415
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.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_runtime21.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" }) })
|
|
1416
|
+
] }),
|
|
1417
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { id: listboxId, className: "hf-select-menu", role: "listbox", "aria-labelledby": triggerId, children: options.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime21.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: [
|
|
1418
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { children: option.label }),
|
|
1419
|
+
option.value === selectedValue && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("svg", { viewBox: "0 0 16 16", width: "16", height: "16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("path", { d: "m3.5 8 3 3 6-6", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
1420
|
+
] }, option.value)) })
|
|
1421
|
+
] }),
|
|
1422
|
+
(error || hint) && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { id: descriptionId, className: `hf-field__hint ${error ? "hf-field__hint--error" : ""}`, children: error ?? hint })
|
|
1423
|
+
] });
|
|
1424
|
+
});
|
|
1425
|
+
|
|
1426
|
+
// src/components/Scheduling.tsx
|
|
1427
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1302
1428
|
function EventCard({
|
|
1303
1429
|
event,
|
|
1304
1430
|
onClick
|
|
1305
1431
|
}) {
|
|
1306
|
-
return /* @__PURE__ */ (0,
|
|
1432
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
1307
1433
|
"button",
|
|
1308
1434
|
{
|
|
1309
1435
|
type: "button",
|
|
1310
1436
|
className: "hf-event-card",
|
|
1311
1437
|
onClick: () => onClick?.(event.id),
|
|
1312
1438
|
children: [
|
|
1313
|
-
/* @__PURE__ */ (0,
|
|
1314
|
-
/* @__PURE__ */ (0,
|
|
1439
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("strong", { children: event.title }),
|
|
1440
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("time", { children: [
|
|
1315
1441
|
event.start,
|
|
1316
1442
|
"\u2013",
|
|
1317
1443
|
event.end
|
|
@@ -1325,43 +1451,44 @@ function Scheduler({
|
|
|
1325
1451
|
events,
|
|
1326
1452
|
onEventClick
|
|
1327
1453
|
}) {
|
|
1328
|
-
return /* @__PURE__ */ (0,
|
|
1329
|
-
/* @__PURE__ */ (0,
|
|
1330
|
-
events.filter((e) => e.start.startsWith(day2)).map((e) => /* @__PURE__ */ (0,
|
|
1454
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "hf-scheduler", children: days.map((day2) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("section", { children: [
|
|
1455
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("strong", { children: day2 }),
|
|
1456
|
+
events.filter((e) => e.start.startsWith(day2)).map((e) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(EventCard, { event: e, onClick: onEventClick }, e.id))
|
|
1331
1457
|
] }, day2)) });
|
|
1332
1458
|
}
|
|
1333
1459
|
function ResourceCalendar({
|
|
1334
1460
|
resources,
|
|
1335
1461
|
events
|
|
1336
1462
|
}) {
|
|
1337
|
-
return /* @__PURE__ */ (0,
|
|
1338
|
-
/* @__PURE__ */ (0,
|
|
1339
|
-
events.filter((e) => e.resourceId === r.id).map((e) => /* @__PURE__ */ (0,
|
|
1463
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "hf-resource-calendar", children: resources.map((r) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("section", { children: [
|
|
1464
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("strong", { children: r.name }),
|
|
1465
|
+
events.filter((e) => e.resourceId === r.id).map((e) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(EventCard, { event: e }, e.id))
|
|
1340
1466
|
] }, r.id)) });
|
|
1341
1467
|
}
|
|
1342
1468
|
function RecurrenceEditor({
|
|
1343
1469
|
value,
|
|
1344
1470
|
onChange
|
|
1345
1471
|
}) {
|
|
1346
|
-
return /* @__PURE__ */ (0,
|
|
1347
|
-
/* @__PURE__ */ (0,
|
|
1348
|
-
|
|
1472
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "hf-recurrence", children: [
|
|
1473
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1474
|
+
Select,
|
|
1349
1475
|
{
|
|
1476
|
+
className: "hf-recurrence__select",
|
|
1350
1477
|
"aria-label": "\u91CD\u590D\u9891\u7387",
|
|
1351
1478
|
value: value.frequency,
|
|
1479
|
+
options: [
|
|
1480
|
+
{ value: "none", label: "\u4E0D\u91CD\u590D" },
|
|
1481
|
+
{ value: "daily", label: "\u6BCF\u5929" },
|
|
1482
|
+
{ value: "weekly", label: "\u6BCF\u5468" },
|
|
1483
|
+
{ value: "monthly", label: "\u6BCF\u6708" }
|
|
1484
|
+
],
|
|
1352
1485
|
onChange: (e) => onChange({
|
|
1353
1486
|
...value,
|
|
1354
1487
|
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
|
-
]
|
|
1488
|
+
})
|
|
1362
1489
|
}
|
|
1363
1490
|
),
|
|
1364
|
-
/* @__PURE__ */ (0,
|
|
1491
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1365
1492
|
"input",
|
|
1366
1493
|
{
|
|
1367
1494
|
"aria-label": "\u91CD\u590D\u95F4\u9694",
|
|
@@ -1378,19 +1505,17 @@ function TimezoneSelect({
|
|
|
1378
1505
|
value,
|
|
1379
1506
|
onChange
|
|
1380
1507
|
}) {
|
|
1381
|
-
return /* @__PURE__ */ (0,
|
|
1382
|
-
|
|
1508
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1509
|
+
Select,
|
|
1383
1510
|
{
|
|
1384
1511
|
"aria-label": "\u65F6\u533A",
|
|
1385
1512
|
className: "hf-timezone",
|
|
1386
1513
|
value,
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
")"
|
|
1393
|
-
] }, o.value))
|
|
1514
|
+
options: options.map((option) => ({
|
|
1515
|
+
value: option.value,
|
|
1516
|
+
label: `${option.label} (${option.offset})`
|
|
1517
|
+
})),
|
|
1518
|
+
onChange: (e) => onChange(e.target.value)
|
|
1394
1519
|
}
|
|
1395
1520
|
);
|
|
1396
1521
|
}
|
|
@@ -1399,24 +1524,24 @@ function AvailabilityGrid({
|
|
|
1399
1524
|
slots,
|
|
1400
1525
|
value
|
|
1401
1526
|
}) {
|
|
1402
|
-
return /* @__PURE__ */ (0,
|
|
1403
|
-
/* @__PURE__ */ (0,
|
|
1404
|
-
/* @__PURE__ */ (0,
|
|
1405
|
-
slots.map((s) => /* @__PURE__ */ (0,
|
|
1527
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "hf-availability", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("table", { children: [
|
|
1528
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("tr", { children: [
|
|
1529
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("th", { children: "\u6210\u5458" }),
|
|
1530
|
+
slots.map((s) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("th", { children: s }, s))
|
|
1406
1531
|
] }) }),
|
|
1407
|
-
/* @__PURE__ */ (0,
|
|
1408
|
-
/* @__PURE__ */ (0,
|
|
1409
|
-
slots.map((s) => /* @__PURE__ */ (0,
|
|
1532
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("tbody", { children: people.map((p) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("tr", { children: [
|
|
1533
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("th", { children: p.name }),
|
|
1534
|
+
slots.map((s) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("i", { className: `is-${value[p.id]?.[s] ?? "unavailable"}` }) }, s))
|
|
1410
1535
|
] }, p.id)) })
|
|
1411
1536
|
] }) });
|
|
1412
1537
|
}
|
|
1413
1538
|
|
|
1414
1539
|
// src/foundations/Typography.tsx
|
|
1415
|
-
var
|
|
1540
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1416
1541
|
function Typography({ as, variant = "body", muted, truncate, className = "", ...props }) {
|
|
1417
1542
|
const defaults = { display: "h1", h1: "h1", h2: "h2", h3: "h3", code: "code" };
|
|
1418
1543
|
const Tag2 = as ?? defaults[variant] ?? "p";
|
|
1419
|
-
return /* @__PURE__ */ (0,
|
|
1544
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Tag2, { className: `hf-typography hf-typography--${variant}${muted ? " is-muted" : ""}${truncate ? " is-truncated" : ""} ${className}`, ...props });
|
|
1420
1545
|
}
|
|
1421
1546
|
|
|
1422
1547
|
// src/navigation/types.ts
|
|
@@ -1425,85 +1550,85 @@ function activateNavigationItem(item, onItemSelect) {
|
|
|
1425
1550
|
}
|
|
1426
1551
|
|
|
1427
1552
|
// src/navigation/FloatingNav.tsx
|
|
1428
|
-
var
|
|
1553
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
1429
1554
|
function FloatingNav({ brand, items, action, activeKey, onItemSelect, className = "", ...props }) {
|
|
1430
|
-
return /* @__PURE__ */ (0,
|
|
1431
|
-
/* @__PURE__ */ (0,
|
|
1432
|
-
/* @__PURE__ */ (0,
|
|
1433
|
-
action && /* @__PURE__ */ (0,
|
|
1555
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("nav", { className: `hf-floating-nav ${className}`.trim(), "aria-label": "\u4E3B\u5BFC\u822A", ...props, children: [
|
|
1556
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "hf-floating-nav__brand", children: brand }),
|
|
1557
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "hf-floating-nav__items", children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("a", { href: item.href ?? "#", "aria-current": activeKey === item.key ? "page" : void 0, onClick: () => activateNavigationItem(item, onItemSelect), children: item.label }, item.key)) }),
|
|
1558
|
+
action && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "hf-floating-nav__action", children: action })
|
|
1434
1559
|
] });
|
|
1435
1560
|
}
|
|
1436
1561
|
|
|
1437
1562
|
// src/navigation/Sidebar.tsx
|
|
1438
|
-
var
|
|
1439
|
-
var
|
|
1563
|
+
var import_react19 = require("react");
|
|
1564
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
1440
1565
|
function Sidebar({ brand, items, activeKey, collapsed, defaultCollapsed = false, onCollapsedChange, onItemSelect, appearance = "flush", className = "", ...props }) {
|
|
1441
|
-
const [internalCollapsed, setInternalCollapsed] = (0,
|
|
1566
|
+
const [internalCollapsed, setInternalCollapsed] = (0, import_react19.useState)(defaultCollapsed);
|
|
1442
1567
|
const isCollapsed = collapsed ?? internalCollapsed;
|
|
1443
1568
|
const toggle = () => {
|
|
1444
1569
|
const next = !isCollapsed;
|
|
1445
1570
|
if (collapsed === void 0) setInternalCollapsed(next);
|
|
1446
1571
|
onCollapsedChange?.(next);
|
|
1447
1572
|
};
|
|
1448
|
-
return /* @__PURE__ */ (0,
|
|
1449
|
-
/* @__PURE__ */ (0,
|
|
1450
|
-
brand && /* @__PURE__ */ (0,
|
|
1451
|
-
/* @__PURE__ */ (0,
|
|
1573
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("aside", { className: `hf-sidebar hf-sidebar--${appearance} ${isCollapsed ? "hf-sidebar--collapsed" : ""} ${className}`.trim(), ...props, children: [
|
|
1574
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "hf-sidebar__top", children: [
|
|
1575
|
+
brand && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "hf-sidebar__brand", children: brand }),
|
|
1576
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { className: "hf-sidebar__collapse", type: "button", onClick: toggle, "aria-label": isCollapsed ? "\u5C55\u5F00\u4FA7\u8FB9\u680F" : "\u6536\u8D77\u4FA7\u8FB9\u680F", "aria-expanded": !isCollapsed, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Icon, { name: "arrow-right", size: 17 }) })
|
|
1452
1577
|
] }),
|
|
1453
|
-
/* @__PURE__ */ (0,
|
|
1454
|
-
/* @__PURE__ */ (0,
|
|
1455
|
-
/* @__PURE__ */ (0,
|
|
1578
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("nav", { "aria-label": "\u4FA7\u8FB9\u5BFC\u822A", children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("a", { href: item.href ?? "#", "aria-current": activeKey === item.key ? "page" : void 0, title: isCollapsed ? item.label : void 0, onClick: () => activateNavigationItem(item, onItemSelect), children: [
|
|
1579
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "hf-sidebar__icon", children: item.icon ?? item.label.slice(0, 1) }),
|
|
1580
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "hf-sidebar__label", children: item.label })
|
|
1456
1581
|
] }, item.key)) })
|
|
1457
1582
|
] });
|
|
1458
1583
|
}
|
|
1459
1584
|
|
|
1460
1585
|
// src/navigation/Breadcrumb.tsx
|
|
1461
|
-
var
|
|
1586
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
1462
1587
|
function Breadcrumb({ items, separator = "/", onItemSelect, className = "", ...props }) {
|
|
1463
|
-
return /* @__PURE__ */ (0,
|
|
1588
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("nav", { className: `hf-breadcrumb ${className}`.trim(), "aria-label": "\u9762\u5305\u5C51", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("ol", { children: items.map((item, index) => {
|
|
1464
1589
|
const current = index === items.length - 1;
|
|
1465
|
-
return /* @__PURE__ */ (0,
|
|
1466
|
-
current ? /* @__PURE__ */ (0,
|
|
1467
|
-
!current && /* @__PURE__ */ (0,
|
|
1590
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("li", { children: [
|
|
1591
|
+
current ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { "aria-current": "page", children: item.label }) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("a", { href: item.href ?? "#", onClick: () => activateNavigationItem(item, onItemSelect), children: item.label }),
|
|
1592
|
+
!current && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("i", { "aria-hidden": "true", children: separator })
|
|
1468
1593
|
] }, item.key);
|
|
1469
1594
|
}) }) });
|
|
1470
1595
|
}
|
|
1471
1596
|
|
|
1472
1597
|
// src/navigation/Menu.tsx
|
|
1473
|
-
var
|
|
1474
|
-
var
|
|
1598
|
+
var import_react20 = require("react");
|
|
1599
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
1475
1600
|
function DropdownMenu({ label, items, activeKey, onItemSelect, className = "", ...props }) {
|
|
1476
|
-
const [open, setOpen] = (0,
|
|
1601
|
+
const [open, setOpen] = (0, import_react20.useState)(false);
|
|
1477
1602
|
const ref = useDismissibleLayer(open, () => setOpen(false), { autoFocus: false });
|
|
1478
|
-
return /* @__PURE__ */ (0,
|
|
1479
|
-
/* @__PURE__ */ (0,
|
|
1480
|
-
label,
|
|
1481
|
-
/* @__PURE__ */ (0,
|
|
1603
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { ref, className: `hf-menu ${className}`.trim(), ...props, children: [
|
|
1604
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("button", { type: "button", "aria-expanded": open, "aria-haspopup": "menu", onClick: () => setOpen((value) => !value), children: [
|
|
1605
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { children: label }),
|
|
1606
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Icon, { className: "hf-menu__chevron", name: "chevron-down", size: 16 })
|
|
1482
1607
|
] }),
|
|
1483
|
-
open && /* @__PURE__ */ (0,
|
|
1608
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "hf-menu__panel", role: "menu", children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("a", { role: "menuitem", href: item.href ?? "#", "aria-current": activeKey === item.key ? "page" : void 0, onClick: () => {
|
|
1484
1609
|
activateNavigationItem(item, onItemSelect);
|
|
1485
1610
|
setOpen(false);
|
|
1486
1611
|
}, children: item.label }, item.key)) })
|
|
1487
1612
|
] });
|
|
1488
1613
|
}
|
|
1489
1614
|
function MegaMenu({ label, items, onItemSelect, className = "", ...props }) {
|
|
1490
|
-
const [open, setOpen] = (0,
|
|
1615
|
+
const [open, setOpen] = (0, import_react20.useState)(false);
|
|
1491
1616
|
const ref = useDismissibleLayer(open, () => setOpen(false), { autoFocus: false });
|
|
1492
|
-
return /* @__PURE__ */ (0,
|
|
1493
|
-
/* @__PURE__ */ (0,
|
|
1494
|
-
label,
|
|
1495
|
-
/* @__PURE__ */ (0,
|
|
1617
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { ref, className: `hf-menu hf-mega-menu ${className}`.trim(), ...props, children: [
|
|
1618
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("button", { type: "button", "aria-expanded": open, "aria-haspopup": "menu", onClick: () => setOpen((value) => !value), children: [
|
|
1619
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { children: label }),
|
|
1620
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Icon, { className: "hf-menu__chevron", name: "chevron-down", size: 16 })
|
|
1496
1621
|
] }),
|
|
1497
|
-
open && /* @__PURE__ */ (0,
|
|
1498
|
-
/* @__PURE__ */ (0,
|
|
1499
|
-
group.children?.map((item) => /* @__PURE__ */ (0,
|
|
1622
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "hf-mega-menu__panel", role: "menu", children: items.map((group) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("section", { children: [
|
|
1623
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("h3", { children: group.label }),
|
|
1624
|
+
group.children?.map((item) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("a", { role: "menuitem", href: item.href ?? "#", onClick: () => {
|
|
1500
1625
|
activateNavigationItem(item, onItemSelect);
|
|
1501
1626
|
setOpen(false);
|
|
1502
1627
|
}, children: [
|
|
1503
|
-
/* @__PURE__ */ (0,
|
|
1504
|
-
/* @__PURE__ */ (0,
|
|
1505
|
-
/* @__PURE__ */ (0,
|
|
1506
|
-
item.description && /* @__PURE__ */ (0,
|
|
1628
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { children: item.icon }),
|
|
1629
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("span", { children: [
|
|
1630
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("strong", { children: item.label }),
|
|
1631
|
+
item.description && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("small", { children: item.description })
|
|
1507
1632
|
] })
|
|
1508
1633
|
] }, item.key))
|
|
1509
1634
|
] }, group.key)) })
|
|
@@ -1511,49 +1636,49 @@ function MegaMenu({ label, items, onItemSelect, className = "", ...props }) {
|
|
|
1511
1636
|
}
|
|
1512
1637
|
|
|
1513
1638
|
// src/navigation/MobileNavigation.tsx
|
|
1514
|
-
var
|
|
1515
|
-
var
|
|
1639
|
+
var import_react21 = require("react");
|
|
1640
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
1516
1641
|
function MobileNavigation({ brand, items, mode = "drawer", activeKey, open, onOpenChange, onItemSelect, className = "", ...props }) {
|
|
1517
|
-
const [internalOpen, setInternalOpen] = (0,
|
|
1642
|
+
const [internalOpen, setInternalOpen] = (0, import_react21.useState)(false);
|
|
1518
1643
|
const isOpen = open ?? internalOpen;
|
|
1519
|
-
const panelId = (0,
|
|
1644
|
+
const panelId = (0, import_react21.useId)();
|
|
1520
1645
|
const setOpen = (next) => {
|
|
1521
1646
|
if (open === void 0) setInternalOpen(next);
|
|
1522
1647
|
onOpenChange?.(next);
|
|
1523
1648
|
};
|
|
1524
1649
|
const panelRef = useDismissibleLayer(isOpen, () => setOpen(false), true);
|
|
1525
|
-
return /* @__PURE__ */ (0,
|
|
1526
|
-
/* @__PURE__ */ (0,
|
|
1527
|
-
/* @__PURE__ */ (0,
|
|
1528
|
-
/* @__PURE__ */ (0,
|
|
1529
|
-
/* @__PURE__ */ (0,
|
|
1530
|
-
/* @__PURE__ */ (0,
|
|
1531
|
-
/* @__PURE__ */ (0,
|
|
1650
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: `hf-mobile-nav ${className}`.trim(), ...props, children: [
|
|
1651
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "hf-mobile-nav__bar", children: [
|
|
1652
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: brand }),
|
|
1653
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("button", { type: "button", "aria-label": "\u6253\u5F00\u5BFC\u822A", "aria-expanded": isOpen, "aria-controls": panelId, onClick: () => setOpen(true), children: [
|
|
1654
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("i", {}),
|
|
1655
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("i", {}),
|
|
1656
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("i", {})
|
|
1532
1657
|
] })
|
|
1533
1658
|
] }),
|
|
1534
|
-
isOpen && /* @__PURE__ */ (0,
|
|
1535
|
-
/* @__PURE__ */ (0,
|
|
1536
|
-
/* @__PURE__ */ (0,
|
|
1537
|
-
/* @__PURE__ */ (0,
|
|
1659
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime28.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_runtime28.jsxs)("nav", { ref: panelRef, id: panelId, className: "hf-mobile-nav__panel", "aria-label": "\u79FB\u52A8\u5BFC\u822A", tabIndex: -1, children: [
|
|
1660
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("header", { children: [
|
|
1661
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: brand }),
|
|
1662
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("button", { type: "button", "aria-label": "\u5173\u95ED\u5BFC\u822A", onClick: () => setOpen(false), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Icon, { name: "close", size: 18 }) })
|
|
1538
1663
|
] }),
|
|
1539
|
-
/* @__PURE__ */ (0,
|
|
1664
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "hf-mobile-nav__links", children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("a", { href: item.href ?? "#", "aria-current": activeKey === item.key ? "page" : void 0, style: { "--hf-nav-index": index }, onClick: () => {
|
|
1540
1665
|
activateNavigationItem(item, onItemSelect);
|
|
1541
1666
|
setOpen(false);
|
|
1542
1667
|
}, children: [
|
|
1543
|
-
/* @__PURE__ */ (0,
|
|
1544
|
-
item.description && /* @__PURE__ */ (0,
|
|
1668
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { children: item.label }),
|
|
1669
|
+
item.description && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("small", { children: item.description })
|
|
1545
1670
|
] }, item.key)) })
|
|
1546
1671
|
] }) })
|
|
1547
1672
|
] });
|
|
1548
1673
|
}
|
|
1549
1674
|
|
|
1550
1675
|
// src/navigation/Scrollspy.tsx
|
|
1551
|
-
var
|
|
1552
|
-
var
|
|
1676
|
+
var import_react22 = require("react");
|
|
1677
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
1553
1678
|
function Scrollspy({ items, activeKey, onItemSelect, rootMargin = "-20% 0px -65%", className = "", ...props }) {
|
|
1554
|
-
const [observedKey, setObservedKey] = (0,
|
|
1679
|
+
const [observedKey, setObservedKey] = (0, import_react22.useState)(items[0]?.key);
|
|
1555
1680
|
const currentKey = activeKey ?? observedKey;
|
|
1556
|
-
(0,
|
|
1681
|
+
(0, import_react22.useEffect)(() => {
|
|
1557
1682
|
if (activeKey || !("IntersectionObserver" in window)) return;
|
|
1558
1683
|
const observer = new IntersectionObserver((entries) => {
|
|
1559
1684
|
const visible = entries.find((entry) => entry.isIntersecting);
|
|
@@ -1565,15 +1690,15 @@ function Scrollspy({ items, activeKey, onItemSelect, rootMargin = "-20% 0px -65%
|
|
|
1565
1690
|
});
|
|
1566
1691
|
return () => observer.disconnect();
|
|
1567
1692
|
}, [activeKey, items, rootMargin]);
|
|
1568
|
-
return /* @__PURE__ */ (0,
|
|
1693
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("nav", { className: `hf-scrollspy ${className}`.trim(), "aria-label": "\u9875\u5185\u5BFC\u822A", ...props, children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("a", { href: item.href ?? `#${item.key}`, "aria-current": currentKey === item.key ? "location" : void 0, onClick: () => onItemSelect?.(item), children: item.label }, item.key)) });
|
|
1569
1694
|
}
|
|
1570
1695
|
|
|
1571
1696
|
// src/navigation/ShrinkNav.tsx
|
|
1572
|
-
var
|
|
1573
|
-
var
|
|
1697
|
+
var import_react23 = require("react");
|
|
1698
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
1574
1699
|
function ShrinkNav({ brand, items, threshold = 48, action, activeKey, onItemSelect, className = "", ...props }) {
|
|
1575
|
-
const [compact, setCompact] = (0,
|
|
1576
|
-
(0,
|
|
1700
|
+
const [compact, setCompact] = (0, import_react23.useState)(false);
|
|
1701
|
+
(0, import_react23.useEffect)(() => {
|
|
1577
1702
|
let frame = 0;
|
|
1578
1703
|
const update = () => {
|
|
1579
1704
|
cancelAnimationFrame(frame);
|
|
@@ -1586,18 +1711,18 @@ function ShrinkNav({ brand, items, threshold = 48, action, activeKey, onItemSele
|
|
|
1586
1711
|
window.removeEventListener("scroll", update);
|
|
1587
1712
|
};
|
|
1588
1713
|
}, [threshold]);
|
|
1589
|
-
return /* @__PURE__ */ (0,
|
|
1590
|
-
/* @__PURE__ */ (0,
|
|
1591
|
-
/* @__PURE__ */ (0,
|
|
1714
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("nav", { className: `hf-shrink-nav ${compact ? "hf-shrink-nav--compact" : ""} ${className}`.trim(), "aria-label": "\u6EDA\u52A8\u5BFC\u822A", ...props, children: [
|
|
1715
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "hf-shrink-nav__brand", children: brand }),
|
|
1716
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "hf-shrink-nav__items", children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("a", { href: item.href ?? "#", "aria-current": activeKey === item.key ? "page" : void 0, onClick: () => onItemSelect?.(item), children: item.label }, item.key)) }),
|
|
1592
1717
|
action
|
|
1593
1718
|
] });
|
|
1594
1719
|
}
|
|
1595
1720
|
|
|
1596
1721
|
// src/navigation/Tabs.tsx
|
|
1597
|
-
var
|
|
1598
|
-
var
|
|
1722
|
+
var import_react24 = require("react");
|
|
1723
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
1599
1724
|
function Tabs({ items, value, onChange, variant = "line", label = "\u5185\u5BB9\u6807\u7B7E" }) {
|
|
1600
|
-
const id = (0,
|
|
1725
|
+
const id = (0, import_react24.useId)();
|
|
1601
1726
|
const active = items.find((item) => item.key === value) ?? items[0];
|
|
1602
1727
|
const onKeyDown = (event) => {
|
|
1603
1728
|
if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(event.key)) return;
|
|
@@ -1608,43 +1733,43 @@ function Tabs({ items, value, onChange, variant = "line", label = "\u5185\u5BB9\
|
|
|
1608
1733
|
const next = enabled[(current + offset + enabled.length) % enabled.length];
|
|
1609
1734
|
if (next) onChange(next.key);
|
|
1610
1735
|
};
|
|
1611
|
-
return /* @__PURE__ */ (0,
|
|
1612
|
-
/* @__PURE__ */ (0,
|
|
1736
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: `hf-tabs hf-tabs--${variant}`, children: [
|
|
1737
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { role: "tablist", "aria-label": label, onKeyDown, children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime31.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
1738
|
item.icon,
|
|
1614
|
-
/* @__PURE__ */ (0,
|
|
1615
|
-
item.badge && /* @__PURE__ */ (0,
|
|
1739
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { children: item.label }),
|
|
1740
|
+
item.badge && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("small", { children: item.badge })
|
|
1616
1741
|
] }, item.key)) }),
|
|
1617
|
-
active && /* @__PURE__ */ (0,
|
|
1742
|
+
active && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { role: "tabpanel", id: `${id}-${active.key}-panel`, "aria-labelledby": `${id}-${active.key}`, tabIndex: 0, children: active.content })
|
|
1618
1743
|
] });
|
|
1619
1744
|
}
|
|
1620
1745
|
|
|
1621
1746
|
// src/navigation/Steps.tsx
|
|
1622
|
-
var
|
|
1747
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
1623
1748
|
function Steps({ items, current, onChange, orientation = "horizontal" }) {
|
|
1624
1749
|
const currentIndex = Math.max(0, items.findIndex((item) => item.key === current));
|
|
1625
|
-
return /* @__PURE__ */ (0,
|
|
1750
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("ol", { className: `hf-steps hf-steps--${orientation}`, children: items.map((item, index) => {
|
|
1626
1751
|
const state = index < currentIndex ? "complete" : index === currentIndex ? "current" : "upcoming";
|
|
1627
|
-
return /* @__PURE__ */ (0,
|
|
1628
|
-
/* @__PURE__ */ (0,
|
|
1629
|
-
/* @__PURE__ */ (0,
|
|
1630
|
-
/* @__PURE__ */ (0,
|
|
1631
|
-
item.optional && /* @__PURE__ */ (0,
|
|
1632
|
-
item.description && /* @__PURE__ */ (0,
|
|
1752
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("li", { className: `is-${state}`, "aria-current": state === "current" ? "step" : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("button", { type: "button", disabled: item.disabled || !onChange, onClick: () => onChange?.(item.key), children: [
|
|
1753
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { children: state === "complete" ? "\u2713" : index + 1 }),
|
|
1754
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("span", { children: [
|
|
1755
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("strong", { children: item.title }),
|
|
1756
|
+
item.optional && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("small", { children: "\u53EF\u9009" }),
|
|
1757
|
+
item.description && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("small", { children: item.description })
|
|
1633
1758
|
] })
|
|
1634
1759
|
] }) }, item.key);
|
|
1635
1760
|
}) });
|
|
1636
1761
|
}
|
|
1637
1762
|
|
|
1638
1763
|
// src/navigation/CommandPalette.tsx
|
|
1639
|
-
var
|
|
1764
|
+
var import_react25 = require("react");
|
|
1640
1765
|
var import_react_dom3 = require("react-dom");
|
|
1641
|
-
var
|
|
1766
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
1642
1767
|
function CommandPalette({ open, onOpenChange, items, onSelect, placeholder = "\u8F93\u5165\u547D\u4EE4\u6216\u641C\u7D22\u2026" }) {
|
|
1643
|
-
const [query, setQuery] = (0,
|
|
1644
|
-
const [active, setActive] = (0,
|
|
1645
|
-
const enabled = (0,
|
|
1768
|
+
const [query, setQuery] = (0, import_react25.useState)("");
|
|
1769
|
+
const [active, setActive] = (0, import_react25.useState)(0);
|
|
1770
|
+
const enabled = (0, import_react25.useMemo)(() => items.filter((item) => !item.disabled && `${item.label} ${item.description ?? ""} ${item.group ?? ""}`.toLowerCase().includes(query.toLowerCase())), [items, query]);
|
|
1646
1771
|
const dialogRef = useDismissibleLayer(open, () => onOpenChange(false), true);
|
|
1647
|
-
(0,
|
|
1772
|
+
(0, import_react25.useEffect)(() => {
|
|
1648
1773
|
if (!open) {
|
|
1649
1774
|
setQuery("");
|
|
1650
1775
|
setActive(0);
|
|
@@ -1668,39 +1793,39 @@ function CommandPalette({ open, onOpenChange, items, onSelect, placeholder = "\u
|
|
|
1668
1793
|
}
|
|
1669
1794
|
};
|
|
1670
1795
|
if (!open) return null;
|
|
1671
|
-
return (0, import_react_dom3.createPortal)(/* @__PURE__ */ (0,
|
|
1672
|
-
/* @__PURE__ */ (0,
|
|
1673
|
-
/* @__PURE__ */ (0,
|
|
1674
|
-
/* @__PURE__ */ (0,
|
|
1796
|
+
return (0, import_react_dom3.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "hf-command-backdrop", onMouseDown: (event) => event.target === event.currentTarget && onOpenChange(false), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { ref: dialogRef, tabIndex: -1, className: "hf-command", role: "dialog", "aria-modal": "true", "aria-label": "\u547D\u4EE4\u9762\u677F", children: [
|
|
1797
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "hf-command__search", children: [
|
|
1798
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { "aria-hidden": "true", children: "\u2315" }),
|
|
1799
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("input", { autoFocus: true, role: "combobox", "aria-expanded": "true", "aria-controls": "hf-command-list", value: query, placeholder, onChange: (event) => {
|
|
1675
1800
|
setQuery(event.target.value);
|
|
1676
1801
|
setActive(0);
|
|
1677
1802
|
}, onKeyDown: keydown }),
|
|
1678
|
-
/* @__PURE__ */ (0,
|
|
1803
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("kbd", { children: "Esc" })
|
|
1679
1804
|
] }),
|
|
1680
|
-
/* @__PURE__ */ (0,
|
|
1681
|
-
enabled.map((item, index) => /* @__PURE__ */ (0,
|
|
1805
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { id: "hf-command-list", className: "hf-command__list", role: "listbox", children: [
|
|
1806
|
+
enabled.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("button", { type: "button", role: "option", "aria-selected": index === active, onPointerMove: () => setActive(index), onClick: () => {
|
|
1682
1807
|
onSelect(item.key);
|
|
1683
1808
|
onOpenChange(false);
|
|
1684
1809
|
}, children: [
|
|
1685
1810
|
item.icon,
|
|
1686
|
-
/* @__PURE__ */ (0,
|
|
1687
|
-
/* @__PURE__ */ (0,
|
|
1688
|
-
item.description && /* @__PURE__ */ (0,
|
|
1811
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("span", { children: [
|
|
1812
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("strong", { children: item.label }),
|
|
1813
|
+
item.description && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("small", { children: item.description })
|
|
1689
1814
|
] }),
|
|
1690
|
-
item.shortcut && /* @__PURE__ */ (0,
|
|
1815
|
+
item.shortcut && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("kbd", { children: item.shortcut })
|
|
1691
1816
|
] }, item.key)),
|
|
1692
|
-
!enabled.length && /* @__PURE__ */ (0,
|
|
1817
|
+
!enabled.length && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "hf-command__empty", children: "\u6CA1\u6709\u5339\u914D\u547D\u4EE4" })
|
|
1693
1818
|
] })
|
|
1694
1819
|
] }) }), document.body);
|
|
1695
1820
|
}
|
|
1696
1821
|
|
|
1697
1822
|
// src/layout/Layout.tsx
|
|
1698
|
-
var
|
|
1823
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
1699
1824
|
function Container({ size = "lg", padding = 24, className = "", style, ...props }) {
|
|
1700
|
-
return /* @__PURE__ */ (0,
|
|
1825
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: `hf-container hf-container--${size} ${className}`.trim(), style: { "--hf-container-padding": `${padding}px`, ...style }, ...props });
|
|
1701
1826
|
}
|
|
1702
1827
|
function Stack({ direction = "column", gap = 12, align, justify, wrap = false, className = "", style, ...props }) {
|
|
1703
|
-
return /* @__PURE__ */ (0,
|
|
1828
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.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
1829
|
}
|
|
1705
1830
|
function Grid({ columns = "auto", minItemWidth = 240, gap = 16, className = "", style, ...props }) {
|
|
1706
1831
|
const gridStyle = {
|
|
@@ -1708,7 +1833,7 @@ function Grid({ columns = "auto", minItemWidth = 240, gap = 16, className = "",
|
|
|
1708
1833
|
"--hf-grid-gap": `${gap}px`,
|
|
1709
1834
|
...style
|
|
1710
1835
|
};
|
|
1711
|
-
return /* @__PURE__ */ (0,
|
|
1836
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: `hf-grid ${className}`.trim(), style: gridStyle, ...props });
|
|
1712
1837
|
}
|
|
1713
1838
|
function Masonry({ columns, minColumnWidth = 260, gap = 16, className = "", style, children, ...props }) {
|
|
1714
1839
|
const masonryStyle = {
|
|
@@ -1717,154 +1842,66 @@ function Masonry({ columns, minColumnWidth = 260, gap = 16, className = "", styl
|
|
|
1717
1842
|
"--hf-masonry-gap": `${gap}px`,
|
|
1718
1843
|
...style
|
|
1719
1844
|
};
|
|
1720
|
-
return /* @__PURE__ */ (0,
|
|
1845
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: `hf-masonry ${className}`.trim(), style: masonryStyle, ...props, children });
|
|
1721
1846
|
}
|
|
1722
1847
|
function PageLayout({ variant = "single", sidebar, header, sidebarWidth = 280, className = "", style, children, ...props }) {
|
|
1723
1848
|
const layoutStyle = { "--hf-layout-sidebar": `${sidebarWidth}px`, ...style };
|
|
1724
|
-
return /* @__PURE__ */ (0,
|
|
1725
|
-
header && /* @__PURE__ */ (0,
|
|
1726
|
-
sidebar && /* @__PURE__ */ (0,
|
|
1727
|
-
/* @__PURE__ */ (0,
|
|
1849
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: `hf-page-layout hf-page-layout--${variant} ${className}`.trim(), style: layoutStyle, ...props, children: [
|
|
1850
|
+
header && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("header", { className: "hf-page-layout__header", children: header }),
|
|
1851
|
+
sidebar && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("aside", { className: "hf-page-layout__sidebar", children: sidebar }),
|
|
1852
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("main", { className: "hf-page-layout__main", children })
|
|
1728
1853
|
] });
|
|
1729
1854
|
}
|
|
1730
1855
|
|
|
1731
1856
|
// src/layout/Skeleton.tsx
|
|
1732
|
-
var
|
|
1857
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
1733
1858
|
function Skeleton({ width = "100%", height = 16, radius, circle, animated = true, className = "", style, ...props }) {
|
|
1734
1859
|
const value = (input) => typeof input === "number" ? `${input}px` : input;
|
|
1735
|
-
return /* @__PURE__ */ (0,
|
|
1860
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.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
1861
|
}
|
|
1737
1862
|
|
|
1738
1863
|
// src/feedback/Loading.tsx
|
|
1739
|
-
var
|
|
1864
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
1740
1865
|
function Spinner({ label = "\u6B63\u5728\u52A0\u8F7D", size = 20, className = "" }) {
|
|
1741
|
-
return /* @__PURE__ */ (0,
|
|
1866
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: `hf-loading-spinner ${className}`.trim(), role: "status", "aria-label": label, style: { "--hf-loading-size": `${size}px` } });
|
|
1742
1867
|
}
|
|
1743
1868
|
function LoadingDots({ label = "\u6B63\u5728\u52A0\u8F7D" }) {
|
|
1744
|
-
return /* @__PURE__ */ (0,
|
|
1745
|
-
/* @__PURE__ */ (0,
|
|
1746
|
-
/* @__PURE__ */ (0,
|
|
1747
|
-
/* @__PURE__ */ (0,
|
|
1869
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("span", { className: "hf-loading-dots", role: "status", "aria-label": label, children: [
|
|
1870
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("i", {}),
|
|
1871
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("i", {}),
|
|
1872
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("i", {})
|
|
1748
1873
|
] });
|
|
1749
1874
|
}
|
|
1750
1875
|
function ProgressBar({ value, label, indeterminate = false, className = "" }) {
|
|
1751
1876
|
const percent = Math.min(100, Math.max(0, value ?? 0));
|
|
1752
|
-
return /* @__PURE__ */ (0,
|
|
1753
|
-
label && /* @__PURE__ */ (0,
|
|
1754
|
-
/* @__PURE__ */ (0,
|
|
1755
|
-
!indeterminate && /* @__PURE__ */ (0,
|
|
1877
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: `hf-progress ${indeterminate ? "is-indeterminate" : ""} ${className}`.trim(), children: [
|
|
1878
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "hf-progress__label", children: [
|
|
1879
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { children: label }),
|
|
1880
|
+
!indeterminate && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("strong", { children: [
|
|
1756
1881
|
percent,
|
|
1757
1882
|
"%"
|
|
1758
1883
|
] })
|
|
1759
1884
|
] }),
|
|
1760
|
-
/* @__PURE__ */ (0,
|
|
1885
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.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_runtime36.jsx)("i", { style: { "--hf-progress": `${percent}%` } }) })
|
|
1761
1886
|
] });
|
|
1762
1887
|
}
|
|
1763
1888
|
function ProgressRing({ value, size = 72, label }) {
|
|
1764
1889
|
const percent = Math.min(100, Math.max(0, value));
|
|
1765
|
-
return /* @__PURE__ */ (0,
|
|
1890
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.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_runtime36.jsxs)("strong", { children: [
|
|
1766
1891
|
percent,
|
|
1767
1892
|
"%"
|
|
1768
1893
|
] }) });
|
|
1769
1894
|
}
|
|
1770
1895
|
function LoadingOverlay({ active = true, label = "\u6B63\u5728\u51C6\u5907\u5185\u5BB9", className = "", children, ...props }) {
|
|
1771
|
-
return /* @__PURE__ */ (0,
|
|
1896
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: `hf-loading-overlay ${className}`.trim(), "aria-busy": active, ...props, children: [
|
|
1772
1897
|
children,
|
|
1773
|
-
active && /* @__PURE__ */ (0,
|
|
1774
|
-
/* @__PURE__ */ (0,
|
|
1775
|
-
/* @__PURE__ */ (0,
|
|
1898
|
+
active && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "hf-loading-overlay__veil", role: "status", children: [
|
|
1899
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Spinner, { label, size: 28 }),
|
|
1900
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { children: label })
|
|
1776
1901
|
] })
|
|
1777
1902
|
] });
|
|
1778
1903
|
}
|
|
1779
1904
|
|
|
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
1905
|
// src/forms/MultiSelect.tsx
|
|
1869
1906
|
var import_react26 = require("react");
|
|
1870
1907
|
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
@@ -1892,7 +1929,7 @@ function MultiSelect({ label, options, value, onChange, placeholder = "\u8BF7\u9
|
|
|
1892
1929
|
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("button", { type: "button", "aria-label": `\u79FB\u9664 ${String(option?.label)}`, onClick: (event) => {
|
|
1893
1930
|
event.stopPropagation();
|
|
1894
1931
|
toggle(item);
|
|
1895
|
-
}, children: "
|
|
1932
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Icon, { name: "close", size: 13 }) })
|
|
1896
1933
|
] }, item);
|
|
1897
1934
|
}) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("em", { children: placeholder }) }),
|
|
1898
1935
|
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Icon, { name: "chevron-down", size: 16, className: "hf-multiselect__chevron" })
|
|
@@ -2401,7 +2438,7 @@ function Combobox({ label, options, value = "", onChange, placeholder = "\u641C\
|
|
|
2401
2438
|
setActive(0);
|
|
2402
2439
|
setOpen(true);
|
|
2403
2440
|
}, 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: "
|
|
2441
|
+
/* @__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: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Icon, { name: "chevron-down", size: 16 }) })
|
|
2405
2442
|
] }),
|
|
2406
2443
|
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
2444
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { children: option.label }),
|
|
@@ -2449,10 +2486,7 @@ function Cascader({ options, value = [], onChange, label }) {
|
|
|
2449
2486
|
}
|
|
2450
2487
|
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "hf-field hf-cascader", children: [
|
|
2451
2488
|
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.
|
|
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)) })
|
|
2489
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { children: levels.map((items, level) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Select, { "aria-label": `\u7B2C ${level + 1} \u7EA7`, className: "hf-cascader__level", value: value[level] ?? "", placeholder: "\u8BF7\u9009\u62E9", options: items.map((item) => ({ label: item.label, value: item.value, disabled: item.disabled })), onChange: (event) => onChange([...value.slice(0, level), event.target.value]) }, level)) })
|
|
2456
2490
|
] });
|
|
2457
2491
|
}
|
|
2458
2492
|
function TreeSelect({ options, value, onChange, label, placeholder = "\u9009\u62E9\u8282\u70B9" }) {
|
|
@@ -2462,8 +2496,8 @@ function TreeSelect({ options, value, onChange, label, placeholder = "\u9009\u62
|
|
|
2462
2496
|
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "hf-field hf-tree-select", children: [
|
|
2463
2497
|
label && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "hf-field__label", children: label }),
|
|
2464
2498
|
/* @__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)(
|
|
2499
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { children: all.find((item) => item.node.key === value)?.node.label ?? placeholder }),
|
|
2500
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Icon, { className: "hf-picker-trigger__chevron", name: "chevron-down", size: 16 })
|
|
2467
2501
|
] }),
|
|
2468
2502
|
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
2503
|
onChange(node.key);
|
|
@@ -2516,7 +2550,7 @@ function SearchInput({ onSearch, loading, clearable = true, ...props }) {
|
|
|
2516
2550
|
setValue(event.target.value);
|
|
2517
2551
|
props.onChange?.(event);
|
|
2518
2552
|
} }),
|
|
2519
|
-
clearable && value && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("button", { type: "button", "aria-label": "\u6E05\u9664\u641C\u7D22", onClick: () => setValue(""), children: "
|
|
2553
|
+
clearable && value && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("button", { type: "button", "aria-label": "\u6E05\u9664\u641C\u7D22", onClick: () => setValue(""), children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Icon, { name: "close", size: 14 }) }),
|
|
2520
2554
|
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("button", { type: "submit", disabled: loading, children: loading ? "\u641C\u7D22\u4E2D" : "\u641C\u7D22" })
|
|
2521
2555
|
] });
|
|
2522
2556
|
}
|
|
@@ -2532,7 +2566,7 @@ function Drawer({ open, title, children, onClose, footer, side = "right", size =
|
|
|
2532
2566
|
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
2567
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("header", { children: [
|
|
2534
2568
|
/* @__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"
|
|
2569
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Button, { variant: "quiet", size: "sm", iconOnly: true, leadingIcon: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Icon, { name: "close", size: 16 }), onClick: onClose, "aria-label": "\u5173\u95ED\u62BD\u5C49" })
|
|
2536
2570
|
] }),
|
|
2537
2571
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "hf-drawer__body", children }),
|
|
2538
2572
|
footer && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("footer", { children: footer })
|
|
@@ -2617,7 +2651,7 @@ function Notification({ title, children, tone = "info", time, unread, action, on
|
|
|
2617
2651
|
children && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("p", { children }),
|
|
2618
2652
|
action && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "hf-notification__action", children: action })
|
|
2619
2653
|
] }),
|
|
2620
|
-
onClose && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("button", { type: "button", "aria-label": "\u5173\u95ED\u901A\u77E5", onClick: onClose, children: "
|
|
2654
|
+
onClose && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("button", { type: "button", "aria-label": "\u5173\u95ED\u901A\u77E5", onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Icon, { name: "close", size: 15 }) })
|
|
2621
2655
|
] });
|
|
2622
2656
|
}
|
|
2623
2657
|
function Result({ status = "info", title, description, actions, extra }) {
|
|
@@ -3032,23 +3066,20 @@ function QueryBuilder({ fields, rules, onChange, conjunction = "and", onConjunct
|
|
|
3032
3066
|
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "hf-query-builder", children: [
|
|
3033
3067
|
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("header", { children: [
|
|
3034
3068
|
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("strong", { children: "\u6EE1\u8DB3" }),
|
|
3035
|
-
/* @__PURE__ */ (0, import_jsx_runtime64.
|
|
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
|
-
] })
|
|
3069
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Select, { className: "hf-query-builder__select", "aria-label": "\u6761\u4EF6\u5173\u7CFB", value: conjunction, disabled, options: [{ value: "and", label: "\u5168\u90E8\u6761\u4EF6" }, { value: "or", label: "\u4EFB\u4E00\u6761\u4EF6" }], onChange: (event) => onConjunctionChange?.(event.target.value) })
|
|
3039
3070
|
] }),
|
|
3040
3071
|
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { children: rules.map((rule, index) => {
|
|
3041
3072
|
const field = fields.find((item) => item.key === rule.field) ?? fields[0];
|
|
3042
3073
|
const operators = field?.operators ?? defaultOperators;
|
|
3043
3074
|
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "hf-query-builder__rule", children: [
|
|
3044
3075
|
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { children: index + 1 }),
|
|
3045
|
-
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
3076
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Select, { className: "hf-query-builder__select", "aria-label": `\u6761\u4EF6 ${index + 1} \u5B57\u6BB5`, value: rule.field, disabled, options: fields.map((item) => ({ value: item.key, label: item.label })), onChange: (event) => {
|
|
3046
3077
|
const next = fields.find((item) => item.key === event.target.value);
|
|
3047
3078
|
update(rule.id, { field: next.key, operator: (next.operators ?? defaultOperators)[0]?.value ?? "equals", value: "" });
|
|
3048
|
-
}
|
|
3049
|
-
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
3079
|
+
} }),
|
|
3080
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Select, { className: "hf-query-builder__select", "aria-label": `\u6761\u4EF6 ${index + 1} \u8FD0\u7B97\u7B26`, value: rule.operator, disabled, options: operators, onChange: (event) => update(rule.id, { operator: event.target.value }) }),
|
|
3050
3081
|
/* @__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: "
|
|
3082
|
+
/* @__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: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Icon, { name: "close", size: 15 }) })
|
|
3052
3083
|
] }, rule.id);
|
|
3053
3084
|
}) }),
|
|
3054
3085
|
/* @__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" })
|
|
@@ -3196,12 +3227,9 @@ function FilterBuilder({ fields, value, onChange, disabled, addLabel = "\u6DFB\u
|
|
|
3196
3227
|
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { children: value.map((filter, index) => {
|
|
3197
3228
|
const field = fields.find((item) => item.key === filter.field) ?? fields[0];
|
|
3198
3229
|
return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "hf-filter-builder__item", children: [
|
|
3199
|
-
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
3200
|
-
field?.options ? /* @__PURE__ */ (0, import_jsx_runtime66.
|
|
3201
|
-
|
|
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" })
|
|
3230
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Select, { className: "hf-filter-builder__select", "aria-label": `\u7B5B\u9009 ${index + 1} \u5B57\u6BB5`, value: filter.field, disabled, options: fields.map((item) => ({ value: item.key, label: item.label })), onChange: (event) => update(filter.id, { field: event.target.value, value: "" }) }),
|
|
3231
|
+
field?.options ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Select, { className: "hf-filter-builder__select", "aria-label": `\u7B5B\u9009 ${index + 1} \u503C`, value: filter.value, placeholder: "\u8BF7\u9009\u62E9", disabled, options: field.options, onChange: (event) => update(filter.id, { value: event.target.value }) }) : /* @__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 }) }),
|
|
3232
|
+
/* @__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: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Icon, { name: "close", size: 15 }) })
|
|
3205
3233
|
] }, filter.id);
|
|
3206
3234
|
}) }),
|
|
3207
3235
|
/* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("button", { type: "button", className: "hf-filter-builder__add", disabled: disabled || !fields.length, onClick: add, children: [
|