@hxdhxd/harmony-flow-ui 0.1.1 → 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 +19 -1
- package/dist/index.cjs +284 -291
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +252 -31
- package/dist/index.css.map +1 -1
- package/dist/index.js +283 -290
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -500,7 +500,7 @@ function Modal({ open, title, children, onClose, footer }) {
|
|
|
500
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: [
|
|
501
501
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("header", { className: "hf-modal__header", children: [
|
|
502
502
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h2", { id: titleId, children: title }),
|
|
503
|
-
/* @__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" })
|
|
504
504
|
] }),
|
|
505
505
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "hf-modal__body", children }),
|
|
506
506
|
footer && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("footer", { className: "hf-modal__footer", children: footer })
|
|
@@ -576,7 +576,10 @@ function Accordion({ items, value, defaultValue = [], onChange, multiple = false
|
|
|
576
576
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("section", { className: open ? "is-open" : "", children: [
|
|
577
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: [
|
|
578
578
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: item.title }),
|
|
579
|
-
/* @__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
|
+
] })
|
|
580
583
|
] }) }),
|
|
581
584
|
open && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "hf-accordion__panel", children: item.content })
|
|
582
585
|
] }, item.key);
|
|
@@ -625,7 +628,7 @@ function ColorPicker({ value, onChange, label, presets = ["#0a7cff", "#19a989",
|
|
|
625
628
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("button", { type: "button", className: "hf-color-picker__trigger", disabled, "aria-expanded": open, onClick: () => setOpen(!open), children: [
|
|
626
629
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { style: { background: value } }),
|
|
627
630
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("code", { children: value.toUpperCase() }),
|
|
628
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
631
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Icon, { className: "hf-picker-trigger__chevron", name: "chevron-down", size: 16 })
|
|
629
632
|
] }),
|
|
630
633
|
open && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "hf-color-picker__panel", children: [
|
|
631
634
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("input", { type: "color", "aria-label": "\u9009\u62E9\u989C\u8272", value, onChange: (event) => onChange(event.target.value) }),
|
|
@@ -776,7 +779,7 @@ function ChatComposer({ value, onChange, onSend, attachments = [], onRemoveAttac
|
|
|
776
779
|
item.icon,
|
|
777
780
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("strong", { children: item.name }),
|
|
778
781
|
item.size && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("small", { children: item.size }),
|
|
779
|
-
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 }) })
|
|
780
783
|
] }, item.id)) }),
|
|
781
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 }),
|
|
782
785
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("footer", { children: [
|
|
@@ -956,7 +959,7 @@ function CodeBlock({ code, language = "text", filename, wrap, showLineNumbers =
|
|
|
956
959
|
function VoiceInput({ state = "idle", duration = "00:00", level = 0.45, disabled, onStart, onStop, onCancel, error }) {
|
|
957
960
|
const active = state === "listening";
|
|
958
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: [
|
|
959
|
-
/* @__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" }) }),
|
|
960
963
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { children: [
|
|
961
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)) }),
|
|
962
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" })
|
|
@@ -975,7 +978,7 @@ function ModelSelector({ models, value, onChange, label = "\u9009\u62E9\u6A21\u5
|
|
|
975
978
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("strong", { children: selected?.name ?? label }),
|
|
976
979
|
selected?.description && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("small", { children: selected.description })
|
|
977
980
|
] }),
|
|
978
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
981
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Icon, { className: "hf-model-selector__chevron", name: "chevron-down", size: 16 })
|
|
979
982
|
] }),
|
|
980
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: () => {
|
|
981
984
|
onChange(model.id);
|
|
@@ -1292,7 +1295,7 @@ function MemberPicker({ members, value, onChange, label = "\u6DFB\u52A0\u6210\u5
|
|
|
1292
1295
|
return item && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { children: [
|
|
1293
1296
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Avatar, { name: item.name, src: item.avatar, size: "sm" }),
|
|
1294
1297
|
item.name,
|
|
1295
|
-
/* @__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 }) })
|
|
1296
1299
|
] }, id);
|
|
1297
1300
|
}) }),
|
|
1298
1301
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("input", { "aria-label": label, value: query, disabled, placeholder: label, onChange: (event) => setQuery(event.target.value) }),
|
|
@@ -1326,27 +1329,115 @@ function SharePanel({ scope, onScopeChange, members, onCopyLink, linkCopied, foo
|
|
|
1326
1329
|
] }, item)) }),
|
|
1327
1330
|
members && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "hf-share-panel__members", children: members }),
|
|
1328
1331
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("footer", { children: [
|
|
1329
|
-
/* @__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" }),
|
|
1330
1333
|
footer
|
|
1331
1334
|
] })
|
|
1332
1335
|
] });
|
|
1333
1336
|
}
|
|
1334
1337
|
|
|
1335
|
-
// src/
|
|
1338
|
+
// src/forms/Select.tsx
|
|
1339
|
+
var import_react18 = require("react");
|
|
1336
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");
|
|
1337
1428
|
function EventCard({
|
|
1338
1429
|
event,
|
|
1339
1430
|
onClick
|
|
1340
1431
|
}) {
|
|
1341
|
-
return /* @__PURE__ */ (0,
|
|
1432
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
1342
1433
|
"button",
|
|
1343
1434
|
{
|
|
1344
1435
|
type: "button",
|
|
1345
1436
|
className: "hf-event-card",
|
|
1346
1437
|
onClick: () => onClick?.(event.id),
|
|
1347
1438
|
children: [
|
|
1348
|
-
/* @__PURE__ */ (0,
|
|
1349
|
-
/* @__PURE__ */ (0,
|
|
1439
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("strong", { children: event.title }),
|
|
1440
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("time", { children: [
|
|
1350
1441
|
event.start,
|
|
1351
1442
|
"\u2013",
|
|
1352
1443
|
event.end
|
|
@@ -1360,43 +1451,44 @@ function Scheduler({
|
|
|
1360
1451
|
events,
|
|
1361
1452
|
onEventClick
|
|
1362
1453
|
}) {
|
|
1363
|
-
return /* @__PURE__ */ (0,
|
|
1364
|
-
/* @__PURE__ */ (0,
|
|
1365
|
-
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))
|
|
1366
1457
|
] }, day2)) });
|
|
1367
1458
|
}
|
|
1368
1459
|
function ResourceCalendar({
|
|
1369
1460
|
resources,
|
|
1370
1461
|
events
|
|
1371
1462
|
}) {
|
|
1372
|
-
return /* @__PURE__ */ (0,
|
|
1373
|
-
/* @__PURE__ */ (0,
|
|
1374
|
-
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))
|
|
1375
1466
|
] }, r.id)) });
|
|
1376
1467
|
}
|
|
1377
1468
|
function RecurrenceEditor({
|
|
1378
1469
|
value,
|
|
1379
1470
|
onChange
|
|
1380
1471
|
}) {
|
|
1381
|
-
return /* @__PURE__ */ (0,
|
|
1382
|
-
/* @__PURE__ */ (0,
|
|
1383
|
-
|
|
1472
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "hf-recurrence", children: [
|
|
1473
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1474
|
+
Select,
|
|
1384
1475
|
{
|
|
1476
|
+
className: "hf-recurrence__select",
|
|
1385
1477
|
"aria-label": "\u91CD\u590D\u9891\u7387",
|
|
1386
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
|
+
],
|
|
1387
1485
|
onChange: (e) => onChange({
|
|
1388
1486
|
...value,
|
|
1389
1487
|
frequency: e.target.value
|
|
1390
|
-
})
|
|
1391
|
-
children: [
|
|
1392
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: "none", children: "\u4E0D\u91CD\u590D" }),
|
|
1393
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: "daily", children: "\u6BCF\u5929" }),
|
|
1394
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: "weekly", children: "\u6BCF\u5468" }),
|
|
1395
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: "monthly", children: "\u6BCF\u6708" })
|
|
1396
|
-
]
|
|
1488
|
+
})
|
|
1397
1489
|
}
|
|
1398
1490
|
),
|
|
1399
|
-
/* @__PURE__ */ (0,
|
|
1491
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1400
1492
|
"input",
|
|
1401
1493
|
{
|
|
1402
1494
|
"aria-label": "\u91CD\u590D\u95F4\u9694",
|
|
@@ -1413,19 +1505,17 @@ function TimezoneSelect({
|
|
|
1413
1505
|
value,
|
|
1414
1506
|
onChange
|
|
1415
1507
|
}) {
|
|
1416
|
-
return /* @__PURE__ */ (0,
|
|
1417
|
-
|
|
1508
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1509
|
+
Select,
|
|
1418
1510
|
{
|
|
1419
1511
|
"aria-label": "\u65F6\u533A",
|
|
1420
1512
|
className: "hf-timezone",
|
|
1421
1513
|
value,
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
")"
|
|
1428
|
-
] }, 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)
|
|
1429
1519
|
}
|
|
1430
1520
|
);
|
|
1431
1521
|
}
|
|
@@ -1434,24 +1524,24 @@ function AvailabilityGrid({
|
|
|
1434
1524
|
slots,
|
|
1435
1525
|
value
|
|
1436
1526
|
}) {
|
|
1437
|
-
return /* @__PURE__ */ (0,
|
|
1438
|
-
/* @__PURE__ */ (0,
|
|
1439
|
-
/* @__PURE__ */ (0,
|
|
1440
|
-
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))
|
|
1441
1531
|
] }) }),
|
|
1442
|
-
/* @__PURE__ */ (0,
|
|
1443
|
-
/* @__PURE__ */ (0,
|
|
1444
|
-
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))
|
|
1445
1535
|
] }, p.id)) })
|
|
1446
1536
|
] }) });
|
|
1447
1537
|
}
|
|
1448
1538
|
|
|
1449
1539
|
// src/foundations/Typography.tsx
|
|
1450
|
-
var
|
|
1540
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1451
1541
|
function Typography({ as, variant = "body", muted, truncate, className = "", ...props }) {
|
|
1452
1542
|
const defaults = { display: "h1", h1: "h1", h2: "h2", h3: "h3", code: "code" };
|
|
1453
1543
|
const Tag2 = as ?? defaults[variant] ?? "p";
|
|
1454
|
-
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 });
|
|
1455
1545
|
}
|
|
1456
1546
|
|
|
1457
1547
|
// src/navigation/types.ts
|
|
@@ -1460,85 +1550,85 @@ function activateNavigationItem(item, onItemSelect) {
|
|
|
1460
1550
|
}
|
|
1461
1551
|
|
|
1462
1552
|
// src/navigation/FloatingNav.tsx
|
|
1463
|
-
var
|
|
1553
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
1464
1554
|
function FloatingNav({ brand, items, action, activeKey, onItemSelect, className = "", ...props }) {
|
|
1465
|
-
return /* @__PURE__ */ (0,
|
|
1466
|
-
/* @__PURE__ */ (0,
|
|
1467
|
-
/* @__PURE__ */ (0,
|
|
1468
|
-
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 })
|
|
1469
1559
|
] });
|
|
1470
1560
|
}
|
|
1471
1561
|
|
|
1472
1562
|
// src/navigation/Sidebar.tsx
|
|
1473
|
-
var
|
|
1474
|
-
var
|
|
1563
|
+
var import_react19 = require("react");
|
|
1564
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
1475
1565
|
function Sidebar({ brand, items, activeKey, collapsed, defaultCollapsed = false, onCollapsedChange, onItemSelect, appearance = "flush", className = "", ...props }) {
|
|
1476
|
-
const [internalCollapsed, setInternalCollapsed] = (0,
|
|
1566
|
+
const [internalCollapsed, setInternalCollapsed] = (0, import_react19.useState)(defaultCollapsed);
|
|
1477
1567
|
const isCollapsed = collapsed ?? internalCollapsed;
|
|
1478
1568
|
const toggle = () => {
|
|
1479
1569
|
const next = !isCollapsed;
|
|
1480
1570
|
if (collapsed === void 0) setInternalCollapsed(next);
|
|
1481
1571
|
onCollapsedChange?.(next);
|
|
1482
1572
|
};
|
|
1483
|
-
return /* @__PURE__ */ (0,
|
|
1484
|
-
/* @__PURE__ */ (0,
|
|
1485
|
-
brand && /* @__PURE__ */ (0,
|
|
1486
|
-
/* @__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 }) })
|
|
1487
1577
|
] }),
|
|
1488
|
-
/* @__PURE__ */ (0,
|
|
1489
|
-
/* @__PURE__ */ (0,
|
|
1490
|
-
/* @__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 })
|
|
1491
1581
|
] }, item.key)) })
|
|
1492
1582
|
] });
|
|
1493
1583
|
}
|
|
1494
1584
|
|
|
1495
1585
|
// src/navigation/Breadcrumb.tsx
|
|
1496
|
-
var
|
|
1586
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
1497
1587
|
function Breadcrumb({ items, separator = "/", onItemSelect, className = "", ...props }) {
|
|
1498
|
-
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) => {
|
|
1499
1589
|
const current = index === items.length - 1;
|
|
1500
|
-
return /* @__PURE__ */ (0,
|
|
1501
|
-
current ? /* @__PURE__ */ (0,
|
|
1502
|
-
!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 })
|
|
1503
1593
|
] }, item.key);
|
|
1504
1594
|
}) }) });
|
|
1505
1595
|
}
|
|
1506
1596
|
|
|
1507
1597
|
// src/navigation/Menu.tsx
|
|
1508
|
-
var
|
|
1509
|
-
var
|
|
1598
|
+
var import_react20 = require("react");
|
|
1599
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
1510
1600
|
function DropdownMenu({ label, items, activeKey, onItemSelect, className = "", ...props }) {
|
|
1511
|
-
const [open, setOpen] = (0,
|
|
1601
|
+
const [open, setOpen] = (0, import_react20.useState)(false);
|
|
1512
1602
|
const ref = useDismissibleLayer(open, () => setOpen(false), { autoFocus: false });
|
|
1513
|
-
return /* @__PURE__ */ (0,
|
|
1514
|
-
/* @__PURE__ */ (0,
|
|
1515
|
-
label,
|
|
1516
|
-
/* @__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 })
|
|
1517
1607
|
] }),
|
|
1518
|
-
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: () => {
|
|
1519
1609
|
activateNavigationItem(item, onItemSelect);
|
|
1520
1610
|
setOpen(false);
|
|
1521
1611
|
}, children: item.label }, item.key)) })
|
|
1522
1612
|
] });
|
|
1523
1613
|
}
|
|
1524
1614
|
function MegaMenu({ label, items, onItemSelect, className = "", ...props }) {
|
|
1525
|
-
const [open, setOpen] = (0,
|
|
1615
|
+
const [open, setOpen] = (0, import_react20.useState)(false);
|
|
1526
1616
|
const ref = useDismissibleLayer(open, () => setOpen(false), { autoFocus: false });
|
|
1527
|
-
return /* @__PURE__ */ (0,
|
|
1528
|
-
/* @__PURE__ */ (0,
|
|
1529
|
-
label,
|
|
1530
|
-
/* @__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 })
|
|
1531
1621
|
] }),
|
|
1532
|
-
open && /* @__PURE__ */ (0,
|
|
1533
|
-
/* @__PURE__ */ (0,
|
|
1534
|
-
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: () => {
|
|
1535
1625
|
activateNavigationItem(item, onItemSelect);
|
|
1536
1626
|
setOpen(false);
|
|
1537
1627
|
}, children: [
|
|
1538
|
-
/* @__PURE__ */ (0,
|
|
1539
|
-
/* @__PURE__ */ (0,
|
|
1540
|
-
/* @__PURE__ */ (0,
|
|
1541
|
-
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 })
|
|
1542
1632
|
] })
|
|
1543
1633
|
] }, item.key))
|
|
1544
1634
|
] }, group.key)) })
|
|
@@ -1546,49 +1636,49 @@ function MegaMenu({ label, items, onItemSelect, className = "", ...props }) {
|
|
|
1546
1636
|
}
|
|
1547
1637
|
|
|
1548
1638
|
// src/navigation/MobileNavigation.tsx
|
|
1549
|
-
var
|
|
1550
|
-
var
|
|
1639
|
+
var import_react21 = require("react");
|
|
1640
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
1551
1641
|
function MobileNavigation({ brand, items, mode = "drawer", activeKey, open, onOpenChange, onItemSelect, className = "", ...props }) {
|
|
1552
|
-
const [internalOpen, setInternalOpen] = (0,
|
|
1642
|
+
const [internalOpen, setInternalOpen] = (0, import_react21.useState)(false);
|
|
1553
1643
|
const isOpen = open ?? internalOpen;
|
|
1554
|
-
const panelId = (0,
|
|
1644
|
+
const panelId = (0, import_react21.useId)();
|
|
1555
1645
|
const setOpen = (next) => {
|
|
1556
1646
|
if (open === void 0) setInternalOpen(next);
|
|
1557
1647
|
onOpenChange?.(next);
|
|
1558
1648
|
};
|
|
1559
1649
|
const panelRef = useDismissibleLayer(isOpen, () => setOpen(false), true);
|
|
1560
|
-
return /* @__PURE__ */ (0,
|
|
1561
|
-
/* @__PURE__ */ (0,
|
|
1562
|
-
/* @__PURE__ */ (0,
|
|
1563
|
-
/* @__PURE__ */ (0,
|
|
1564
|
-
/* @__PURE__ */ (0,
|
|
1565
|
-
/* @__PURE__ */ (0,
|
|
1566
|
-
/* @__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", {})
|
|
1567
1657
|
] })
|
|
1568
1658
|
] }),
|
|
1569
|
-
isOpen && /* @__PURE__ */ (0,
|
|
1570
|
-
/* @__PURE__ */ (0,
|
|
1571
|
-
/* @__PURE__ */ (0,
|
|
1572
|
-
/* @__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 }) })
|
|
1573
1663
|
] }),
|
|
1574
|
-
/* @__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: () => {
|
|
1575
1665
|
activateNavigationItem(item, onItemSelect);
|
|
1576
1666
|
setOpen(false);
|
|
1577
1667
|
}, children: [
|
|
1578
|
-
/* @__PURE__ */ (0,
|
|
1579
|
-
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 })
|
|
1580
1670
|
] }, item.key)) })
|
|
1581
1671
|
] }) })
|
|
1582
1672
|
] });
|
|
1583
1673
|
}
|
|
1584
1674
|
|
|
1585
1675
|
// src/navigation/Scrollspy.tsx
|
|
1586
|
-
var
|
|
1587
|
-
var
|
|
1676
|
+
var import_react22 = require("react");
|
|
1677
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
1588
1678
|
function Scrollspy({ items, activeKey, onItemSelect, rootMargin = "-20% 0px -65%", className = "", ...props }) {
|
|
1589
|
-
const [observedKey, setObservedKey] = (0,
|
|
1679
|
+
const [observedKey, setObservedKey] = (0, import_react22.useState)(items[0]?.key);
|
|
1590
1680
|
const currentKey = activeKey ?? observedKey;
|
|
1591
|
-
(0,
|
|
1681
|
+
(0, import_react22.useEffect)(() => {
|
|
1592
1682
|
if (activeKey || !("IntersectionObserver" in window)) return;
|
|
1593
1683
|
const observer = new IntersectionObserver((entries) => {
|
|
1594
1684
|
const visible = entries.find((entry) => entry.isIntersecting);
|
|
@@ -1600,15 +1690,15 @@ function Scrollspy({ items, activeKey, onItemSelect, rootMargin = "-20% 0px -65%
|
|
|
1600
1690
|
});
|
|
1601
1691
|
return () => observer.disconnect();
|
|
1602
1692
|
}, [activeKey, items, rootMargin]);
|
|
1603
|
-
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)) });
|
|
1604
1694
|
}
|
|
1605
1695
|
|
|
1606
1696
|
// src/navigation/ShrinkNav.tsx
|
|
1607
|
-
var
|
|
1608
|
-
var
|
|
1697
|
+
var import_react23 = require("react");
|
|
1698
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
1609
1699
|
function ShrinkNav({ brand, items, threshold = 48, action, activeKey, onItemSelect, className = "", ...props }) {
|
|
1610
|
-
const [compact, setCompact] = (0,
|
|
1611
|
-
(0,
|
|
1700
|
+
const [compact, setCompact] = (0, import_react23.useState)(false);
|
|
1701
|
+
(0, import_react23.useEffect)(() => {
|
|
1612
1702
|
let frame = 0;
|
|
1613
1703
|
const update = () => {
|
|
1614
1704
|
cancelAnimationFrame(frame);
|
|
@@ -1621,18 +1711,18 @@ function ShrinkNav({ brand, items, threshold = 48, action, activeKey, onItemSele
|
|
|
1621
1711
|
window.removeEventListener("scroll", update);
|
|
1622
1712
|
};
|
|
1623
1713
|
}, [threshold]);
|
|
1624
|
-
return /* @__PURE__ */ (0,
|
|
1625
|
-
/* @__PURE__ */ (0,
|
|
1626
|
-
/* @__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)) }),
|
|
1627
1717
|
action
|
|
1628
1718
|
] });
|
|
1629
1719
|
}
|
|
1630
1720
|
|
|
1631
1721
|
// src/navigation/Tabs.tsx
|
|
1632
|
-
var
|
|
1633
|
-
var
|
|
1722
|
+
var import_react24 = require("react");
|
|
1723
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
1634
1724
|
function Tabs({ items, value, onChange, variant = "line", label = "\u5185\u5BB9\u6807\u7B7E" }) {
|
|
1635
|
-
const id = (0,
|
|
1725
|
+
const id = (0, import_react24.useId)();
|
|
1636
1726
|
const active = items.find((item) => item.key === value) ?? items[0];
|
|
1637
1727
|
const onKeyDown = (event) => {
|
|
1638
1728
|
if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(event.key)) return;
|
|
@@ -1643,43 +1733,43 @@ function Tabs({ items, value, onChange, variant = "line", label = "\u5185\u5BB9\
|
|
|
1643
1733
|
const next = enabled[(current + offset + enabled.length) % enabled.length];
|
|
1644
1734
|
if (next) onChange(next.key);
|
|
1645
1735
|
};
|
|
1646
|
-
return /* @__PURE__ */ (0,
|
|
1647
|
-
/* @__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: [
|
|
1648
1738
|
item.icon,
|
|
1649
|
-
/* @__PURE__ */ (0,
|
|
1650
|
-
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 })
|
|
1651
1741
|
] }, item.key)) }),
|
|
1652
|
-
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 })
|
|
1653
1743
|
] });
|
|
1654
1744
|
}
|
|
1655
1745
|
|
|
1656
1746
|
// src/navigation/Steps.tsx
|
|
1657
|
-
var
|
|
1747
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
1658
1748
|
function Steps({ items, current, onChange, orientation = "horizontal" }) {
|
|
1659
1749
|
const currentIndex = Math.max(0, items.findIndex((item) => item.key === current));
|
|
1660
|
-
return /* @__PURE__ */ (0,
|
|
1750
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("ol", { className: `hf-steps hf-steps--${orientation}`, children: items.map((item, index) => {
|
|
1661
1751
|
const state = index < currentIndex ? "complete" : index === currentIndex ? "current" : "upcoming";
|
|
1662
|
-
return /* @__PURE__ */ (0,
|
|
1663
|
-
/* @__PURE__ */ (0,
|
|
1664
|
-
/* @__PURE__ */ (0,
|
|
1665
|
-
/* @__PURE__ */ (0,
|
|
1666
|
-
item.optional && /* @__PURE__ */ (0,
|
|
1667
|
-
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 })
|
|
1668
1758
|
] })
|
|
1669
1759
|
] }) }, item.key);
|
|
1670
1760
|
}) });
|
|
1671
1761
|
}
|
|
1672
1762
|
|
|
1673
1763
|
// src/navigation/CommandPalette.tsx
|
|
1674
|
-
var
|
|
1764
|
+
var import_react25 = require("react");
|
|
1675
1765
|
var import_react_dom3 = require("react-dom");
|
|
1676
|
-
var
|
|
1766
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
1677
1767
|
function CommandPalette({ open, onOpenChange, items, onSelect, placeholder = "\u8F93\u5165\u547D\u4EE4\u6216\u641C\u7D22\u2026" }) {
|
|
1678
|
-
const [query, setQuery] = (0,
|
|
1679
|
-
const [active, setActive] = (0,
|
|
1680
|
-
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]);
|
|
1681
1771
|
const dialogRef = useDismissibleLayer(open, () => onOpenChange(false), true);
|
|
1682
|
-
(0,
|
|
1772
|
+
(0, import_react25.useEffect)(() => {
|
|
1683
1773
|
if (!open) {
|
|
1684
1774
|
setQuery("");
|
|
1685
1775
|
setActive(0);
|
|
@@ -1703,39 +1793,39 @@ function CommandPalette({ open, onOpenChange, items, onSelect, placeholder = "\u
|
|
|
1703
1793
|
}
|
|
1704
1794
|
};
|
|
1705
1795
|
if (!open) return null;
|
|
1706
|
-
return (0, import_react_dom3.createPortal)(/* @__PURE__ */ (0,
|
|
1707
|
-
/* @__PURE__ */ (0,
|
|
1708
|
-
/* @__PURE__ */ (0,
|
|
1709
|
-
/* @__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) => {
|
|
1710
1800
|
setQuery(event.target.value);
|
|
1711
1801
|
setActive(0);
|
|
1712
1802
|
}, onKeyDown: keydown }),
|
|
1713
|
-
/* @__PURE__ */ (0,
|
|
1803
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("kbd", { children: "Esc" })
|
|
1714
1804
|
] }),
|
|
1715
|
-
/* @__PURE__ */ (0,
|
|
1716
|
-
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: () => {
|
|
1717
1807
|
onSelect(item.key);
|
|
1718
1808
|
onOpenChange(false);
|
|
1719
1809
|
}, children: [
|
|
1720
1810
|
item.icon,
|
|
1721
|
-
/* @__PURE__ */ (0,
|
|
1722
|
-
/* @__PURE__ */ (0,
|
|
1723
|
-
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 })
|
|
1724
1814
|
] }),
|
|
1725
|
-
item.shortcut && /* @__PURE__ */ (0,
|
|
1815
|
+
item.shortcut && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("kbd", { children: item.shortcut })
|
|
1726
1816
|
] }, item.key)),
|
|
1727
|
-
!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" })
|
|
1728
1818
|
] })
|
|
1729
1819
|
] }) }), document.body);
|
|
1730
1820
|
}
|
|
1731
1821
|
|
|
1732
1822
|
// src/layout/Layout.tsx
|
|
1733
|
-
var
|
|
1823
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
1734
1824
|
function Container({ size = "lg", padding = 24, className = "", style, ...props }) {
|
|
1735
|
-
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 });
|
|
1736
1826
|
}
|
|
1737
1827
|
function Stack({ direction = "column", gap = 12, align, justify, wrap = false, className = "", style, ...props }) {
|
|
1738
|
-
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 });
|
|
1739
1829
|
}
|
|
1740
1830
|
function Grid({ columns = "auto", minItemWidth = 240, gap = 16, className = "", style, ...props }) {
|
|
1741
1831
|
const gridStyle = {
|
|
@@ -1743,7 +1833,7 @@ function Grid({ columns = "auto", minItemWidth = 240, gap = 16, className = "",
|
|
|
1743
1833
|
"--hf-grid-gap": `${gap}px`,
|
|
1744
1834
|
...style
|
|
1745
1835
|
};
|
|
1746
|
-
return /* @__PURE__ */ (0,
|
|
1836
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: `hf-grid ${className}`.trim(), style: gridStyle, ...props });
|
|
1747
1837
|
}
|
|
1748
1838
|
function Masonry({ columns, minColumnWidth = 260, gap = 16, className = "", style, children, ...props }) {
|
|
1749
1839
|
const masonryStyle = {
|
|
@@ -1752,154 +1842,66 @@ function Masonry({ columns, minColumnWidth = 260, gap = 16, className = "", styl
|
|
|
1752
1842
|
"--hf-masonry-gap": `${gap}px`,
|
|
1753
1843
|
...style
|
|
1754
1844
|
};
|
|
1755
|
-
return /* @__PURE__ */ (0,
|
|
1845
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: `hf-masonry ${className}`.trim(), style: masonryStyle, ...props, children });
|
|
1756
1846
|
}
|
|
1757
1847
|
function PageLayout({ variant = "single", sidebar, header, sidebarWidth = 280, className = "", style, children, ...props }) {
|
|
1758
1848
|
const layoutStyle = { "--hf-layout-sidebar": `${sidebarWidth}px`, ...style };
|
|
1759
|
-
return /* @__PURE__ */ (0,
|
|
1760
|
-
header && /* @__PURE__ */ (0,
|
|
1761
|
-
sidebar && /* @__PURE__ */ (0,
|
|
1762
|
-
/* @__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 })
|
|
1763
1853
|
] });
|
|
1764
1854
|
}
|
|
1765
1855
|
|
|
1766
1856
|
// src/layout/Skeleton.tsx
|
|
1767
|
-
var
|
|
1857
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
1768
1858
|
function Skeleton({ width = "100%", height = 16, radius, circle, animated = true, className = "", style, ...props }) {
|
|
1769
1859
|
const value = (input) => typeof input === "number" ? `${input}px` : input;
|
|
1770
|
-
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 });
|
|
1771
1861
|
}
|
|
1772
1862
|
|
|
1773
1863
|
// src/feedback/Loading.tsx
|
|
1774
|
-
var
|
|
1864
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
1775
1865
|
function Spinner({ label = "\u6B63\u5728\u52A0\u8F7D", size = 20, className = "" }) {
|
|
1776
|
-
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` } });
|
|
1777
1867
|
}
|
|
1778
1868
|
function LoadingDots({ label = "\u6B63\u5728\u52A0\u8F7D" }) {
|
|
1779
|
-
return /* @__PURE__ */ (0,
|
|
1780
|
-
/* @__PURE__ */ (0,
|
|
1781
|
-
/* @__PURE__ */ (0,
|
|
1782
|
-
/* @__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", {})
|
|
1783
1873
|
] });
|
|
1784
1874
|
}
|
|
1785
1875
|
function ProgressBar({ value, label, indeterminate = false, className = "" }) {
|
|
1786
1876
|
const percent = Math.min(100, Math.max(0, value ?? 0));
|
|
1787
|
-
return /* @__PURE__ */ (0,
|
|
1788
|
-
label && /* @__PURE__ */ (0,
|
|
1789
|
-
/* @__PURE__ */ (0,
|
|
1790
|
-
!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: [
|
|
1791
1881
|
percent,
|
|
1792
1882
|
"%"
|
|
1793
1883
|
] })
|
|
1794
1884
|
] }),
|
|
1795
|
-
/* @__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}%` } }) })
|
|
1796
1886
|
] });
|
|
1797
1887
|
}
|
|
1798
1888
|
function ProgressRing({ value, size = 72, label }) {
|
|
1799
1889
|
const percent = Math.min(100, Math.max(0, value));
|
|
1800
|
-
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: [
|
|
1801
1891
|
percent,
|
|
1802
1892
|
"%"
|
|
1803
1893
|
] }) });
|
|
1804
1894
|
}
|
|
1805
1895
|
function LoadingOverlay({ active = true, label = "\u6B63\u5728\u51C6\u5907\u5185\u5BB9", className = "", children, ...props }) {
|
|
1806
|
-
return /* @__PURE__ */ (0,
|
|
1896
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: `hf-loading-overlay ${className}`.trim(), "aria-busy": active, ...props, children: [
|
|
1807
1897
|
children,
|
|
1808
|
-
active && /* @__PURE__ */ (0,
|
|
1809
|
-
/* @__PURE__ */ (0,
|
|
1810
|
-
/* @__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 })
|
|
1811
1901
|
] })
|
|
1812
1902
|
] });
|
|
1813
1903
|
}
|
|
1814
1904
|
|
|
1815
|
-
// src/forms/Select.tsx
|
|
1816
|
-
var import_react25 = require("react");
|
|
1817
|
-
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
1818
|
-
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) {
|
|
1819
|
-
const generatedId = (0, import_react25.useId)();
|
|
1820
|
-
const inputId = id ?? generatedId;
|
|
1821
|
-
const triggerId = `${inputId}-trigger`;
|
|
1822
|
-
const listboxId = `${inputId}-listbox`;
|
|
1823
|
-
const descriptionId = `${inputId}-description`;
|
|
1824
|
-
const [open, setOpen] = (0, import_react25.useState)(false);
|
|
1825
|
-
const rootRef = useDismissibleLayer(open, () => setOpen(false), { autoFocus: false });
|
|
1826
|
-
const nativeRef = (0, import_react25.useRef)(null);
|
|
1827
|
-
const [innerValue, setInnerValue] = (0, import_react25.useState)(() => String(defaultValue ?? (placeholder ? "" : options.find((option) => !option.disabled)?.value ?? "")));
|
|
1828
|
-
const selectedValue = value === void 0 ? innerValue : String(value);
|
|
1829
|
-
const selectedOption = options.find((option) => option.value === selectedValue);
|
|
1830
|
-
const enabledIndices = options.map((option, index) => option.disabled ? -1 : index).filter((index) => index >= 0);
|
|
1831
|
-
const selectedIndex = options.findIndex((option) => option.value === selectedValue);
|
|
1832
|
-
const [activeIndex, setActiveIndex] = (0, import_react25.useState)(selectedIndex >= 0 ? selectedIndex : enabledIndices[0] ?? -1);
|
|
1833
|
-
const assignRef = (node) => {
|
|
1834
|
-
nativeRef.current = node;
|
|
1835
|
-
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
1836
|
-
else if (forwardedRef) forwardedRef.current = node;
|
|
1837
|
-
};
|
|
1838
|
-
const handleNativeChange = (event) => {
|
|
1839
|
-
if (value === void 0) setInnerValue(event.currentTarget.value);
|
|
1840
|
-
onChange?.(event);
|
|
1841
|
-
};
|
|
1842
|
-
const choose = (nextValue) => {
|
|
1843
|
-
const native = nativeRef.current;
|
|
1844
|
-
if (!native) return;
|
|
1845
|
-
Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, "value")?.set?.call(native, nextValue);
|
|
1846
|
-
native.dispatchEvent(new Event("change", { bubbles: true }));
|
|
1847
|
-
if (value === void 0) setInnerValue(nextValue);
|
|
1848
|
-
setOpen(false);
|
|
1849
|
-
window.requestAnimationFrame(() => document.getElementById(triggerId)?.focus());
|
|
1850
|
-
};
|
|
1851
|
-
(0, import_react25.useEffect)(() => {
|
|
1852
|
-
if (selectedIndex >= 0) setActiveIndex(selectedIndex);
|
|
1853
|
-
}, [selectedIndex]);
|
|
1854
|
-
const move = (direction) => {
|
|
1855
|
-
if (!enabledIndices.length) return;
|
|
1856
|
-
const current = enabledIndices.indexOf(activeIndex);
|
|
1857
|
-
const next = current < 0 ? 0 : (current + direction + enabledIndices.length) % enabledIndices.length;
|
|
1858
|
-
setActiveIndex(enabledIndices[next]);
|
|
1859
|
-
};
|
|
1860
|
-
const handleKeyDown = (event) => {
|
|
1861
|
-
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
1862
|
-
event.preventDefault();
|
|
1863
|
-
if (!open) setOpen(true);
|
|
1864
|
-
move(event.key === "ArrowDown" ? 1 : -1);
|
|
1865
|
-
} else if ((event.key === "Enter" || event.key === " ") && open) {
|
|
1866
|
-
event.preventDefault();
|
|
1867
|
-
const option = options[activeIndex];
|
|
1868
|
-
if (option && !option.disabled) choose(option.value);
|
|
1869
|
-
} else if (event.key === "Escape" && open) {
|
|
1870
|
-
event.preventDefault();
|
|
1871
|
-
setOpen(false);
|
|
1872
|
-
} else if (event.key === "Home" && open && enabledIndices.length) {
|
|
1873
|
-
event.preventDefault();
|
|
1874
|
-
setActiveIndex(enabledIndices[0]);
|
|
1875
|
-
} else if (event.key === "End" && open && enabledIndices.length) {
|
|
1876
|
-
event.preventDefault();
|
|
1877
|
-
setActiveIndex(enabledIndices[enabledIndices.length - 1]);
|
|
1878
|
-
} else if (event.key === "Tab") setOpen(false);
|
|
1879
|
-
};
|
|
1880
|
-
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: `hf-field ${className}`.trim(), ref: rootRef, children: [
|
|
1881
|
-
label && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("label", { className: "hf-field__label", htmlFor: triggerId, children: label }),
|
|
1882
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: `hf-select-shell ${open ? "hf-select-shell--open" : ""} ${error ? "hf-select-shell--error" : ""}`, children: [
|
|
1883
|
-
/* @__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: [
|
|
1884
|
-
placeholder && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("option", { value: "", disabled: true, children: placeholder }),
|
|
1885
|
-
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))
|
|
1886
|
-
] }),
|
|
1887
|
-
/* @__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: () => {
|
|
1888
|
-
setActiveIndex(selectedIndex >= 0 ? selectedIndex : enabledIndices[0] ?? -1);
|
|
1889
|
-
setOpen((current) => !current);
|
|
1890
|
-
}, onKeyDown: handleKeyDown, children: [
|
|
1891
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: !selectedOption ? "hf-select__placeholder" : "", children: selectedOption?.label ?? placeholder ?? "\u8BF7\u9009\u62E9" }),
|
|
1892
|
-
/* @__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" }) })
|
|
1893
|
-
] }),
|
|
1894
|
-
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: [
|
|
1895
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { children: option.label }),
|
|
1896
|
-
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" }) })
|
|
1897
|
-
] }, option.value)) })
|
|
1898
|
-
] }),
|
|
1899
|
-
(error || hint) && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { id: descriptionId, className: `hf-field__hint ${error ? "hf-field__hint--error" : ""}`, children: error ?? hint })
|
|
1900
|
-
] });
|
|
1901
|
-
});
|
|
1902
|
-
|
|
1903
1905
|
// src/forms/MultiSelect.tsx
|
|
1904
1906
|
var import_react26 = require("react");
|
|
1905
1907
|
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
@@ -1927,7 +1929,7 @@ function MultiSelect({ label, options, value, onChange, placeholder = "\u8BF7\u9
|
|
|
1927
1929
|
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("button", { type: "button", "aria-label": `\u79FB\u9664 ${String(option?.label)}`, onClick: (event) => {
|
|
1928
1930
|
event.stopPropagation();
|
|
1929
1931
|
toggle(item);
|
|
1930
|
-
}, children: "
|
|
1932
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Icon, { name: "close", size: 13 }) })
|
|
1931
1933
|
] }, item);
|
|
1932
1934
|
}) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("em", { children: placeholder }) }),
|
|
1933
1935
|
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Icon, { name: "chevron-down", size: 16, className: "hf-multiselect__chevron" })
|
|
@@ -2436,7 +2438,7 @@ function Combobox({ label, options, value = "", onChange, placeholder = "\u641C\
|
|
|
2436
2438
|
setActive(0);
|
|
2437
2439
|
setOpen(true);
|
|
2438
2440
|
}, onKeyDown }),
|
|
2439
|
-
/* @__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 }) })
|
|
2440
2442
|
] }),
|
|
2441
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: [
|
|
2442
2444
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { children: option.label }),
|
|
@@ -2484,10 +2486,7 @@ function Cascader({ options, value = [], onChange, label }) {
|
|
|
2484
2486
|
}
|
|
2485
2487
|
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "hf-field hf-cascader", children: [
|
|
2486
2488
|
label && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "hf-field__label", children: label }),
|
|
2487
|
-
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { children: levels.map((items, level) => /* @__PURE__ */ (0, import_jsx_runtime47.
|
|
2488
|
-
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("option", { value: "", children: "\u8BF7\u9009\u62E9" }),
|
|
2489
|
-
items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("option", { disabled: item.disabled, value: item.value, children: item.label }, item.value))
|
|
2490
|
-
] }, 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)) })
|
|
2491
2490
|
] });
|
|
2492
2491
|
}
|
|
2493
2492
|
function TreeSelect({ options, value, onChange, label, placeholder = "\u9009\u62E9\u8282\u70B9" }) {
|
|
@@ -2497,8 +2496,8 @@ function TreeSelect({ options, value, onChange, label, placeholder = "\u9009\u62
|
|
|
2497
2496
|
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "hf-field hf-tree-select", children: [
|
|
2498
2497
|
label && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "hf-field__label", children: label }),
|
|
2499
2498
|
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("button", { type: "button", className: "hf-picker-trigger", "aria-expanded": open, onClick: () => setOpen(!open), children: [
|
|
2500
|
-
all.find((item) => item.node.key === value)?.node.label ?? placeholder,
|
|
2501
|
-
/* @__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 })
|
|
2502
2501
|
] }),
|
|
2503
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: () => {
|
|
2504
2503
|
onChange(node.key);
|
|
@@ -2551,7 +2550,7 @@ function SearchInput({ onSearch, loading, clearable = true, ...props }) {
|
|
|
2551
2550
|
setValue(event.target.value);
|
|
2552
2551
|
props.onChange?.(event);
|
|
2553
2552
|
} }),
|
|
2554
|
-
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 }) }),
|
|
2555
2554
|
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("button", { type: "submit", disabled: loading, children: loading ? "\u641C\u7D22\u4E2D" : "\u641C\u7D22" })
|
|
2556
2555
|
] });
|
|
2557
2556
|
}
|
|
@@ -2567,7 +2566,7 @@ function Drawer({ open, title, children, onClose, footer, side = "right", size =
|
|
|
2567
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: [
|
|
2568
2567
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("header", { children: [
|
|
2569
2568
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("h2", { id: titleId, children: title }),
|
|
2570
|
-
/* @__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" })
|
|
2571
2570
|
] }),
|
|
2572
2571
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "hf-drawer__body", children }),
|
|
2573
2572
|
footer && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("footer", { children: footer })
|
|
@@ -2652,7 +2651,7 @@ function Notification({ title, children, tone = "info", time, unread, action, on
|
|
|
2652
2651
|
children && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("p", { children }),
|
|
2653
2652
|
action && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "hf-notification__action", children: action })
|
|
2654
2653
|
] }),
|
|
2655
|
-
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 }) })
|
|
2656
2655
|
] });
|
|
2657
2656
|
}
|
|
2658
2657
|
function Result({ status = "info", title, description, actions, extra }) {
|
|
@@ -3067,23 +3066,20 @@ function QueryBuilder({ fields, rules, onChange, conjunction = "and", onConjunct
|
|
|
3067
3066
|
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "hf-query-builder", children: [
|
|
3068
3067
|
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("header", { children: [
|
|
3069
3068
|
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("strong", { children: "\u6EE1\u8DB3" }),
|
|
3070
|
-
/* @__PURE__ */ (0, import_jsx_runtime64.
|
|
3071
|
-
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: "and", children: "\u5168\u90E8\u6761\u4EF6" }),
|
|
3072
|
-
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("option", { value: "or", children: "\u4EFB\u4E00\u6761\u4EF6" })
|
|
3073
|
-
] })
|
|
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) })
|
|
3074
3070
|
] }),
|
|
3075
3071
|
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { children: rules.map((rule, index) => {
|
|
3076
3072
|
const field = fields.find((item) => item.key === rule.field) ?? fields[0];
|
|
3077
3073
|
const operators = field?.operators ?? defaultOperators;
|
|
3078
3074
|
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "hf-query-builder__rule", children: [
|
|
3079
3075
|
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { children: index + 1 }),
|
|
3080
|
-
/* @__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) => {
|
|
3081
3077
|
const next = fields.find((item) => item.key === event.target.value);
|
|
3082
3078
|
update(rule.id, { field: next.key, operator: (next.operators ?? defaultOperators)[0]?.value ?? "equals", value: "" });
|
|
3083
|
-
}
|
|
3084
|
-
/* @__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 }) }),
|
|
3085
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 }) }),
|
|
3086
|
-
/* @__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 }) })
|
|
3087
3083
|
] }, rule.id);
|
|
3088
3084
|
}) }),
|
|
3089
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" })
|
|
@@ -3231,12 +3227,9 @@ function FilterBuilder({ fields, value, onChange, disabled, addLabel = "\u6DFB\u
|
|
|
3231
3227
|
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { children: value.map((filter, index) => {
|
|
3232
3228
|
const field = fields.find((item) => item.key === filter.field) ?? fields[0];
|
|
3233
3229
|
return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "hf-filter-builder__item", children: [
|
|
3234
|
-
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
3235
|
-
field?.options ? /* @__PURE__ */ (0, import_jsx_runtime66.
|
|
3236
|
-
|
|
3237
|
-
field.options.map((item) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("option", { value: item.value, children: item.label }, item.value))
|
|
3238
|
-
] }) : /* @__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 }) }),
|
|
3239
|
-
/* @__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 }) })
|
|
3240
3233
|
] }, filter.id);
|
|
3241
3234
|
}) }),
|
|
3242
3235
|
/* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("button", { type: "button", className: "hf-filter-builder__add", disabled: disabled || !fields.length, onClick: add, children: [
|