@bixlab/mtone 0.10.3 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-4X67DOKJ.js +377 -0
- package/dist/index.d.ts +120 -42
- package/dist/index.js +1811 -980
- package/dist/styles.css +1 -1
- package/dist/typography-highlight-GAYKSB6L.js +324 -0
- package/llms.txt +91 -42
- package/package.json +1 -1
- package/dist/typography-highlight-WZ7OAZVP.js +0 -62
package/dist/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
resolveCodeLanguage
|
|
4
|
+
} from "./chunk-4X67DOKJ.js";
|
|
2
5
|
|
|
3
6
|
// src/list.tsx
|
|
4
7
|
import {
|
|
@@ -416,10 +419,10 @@ function ListRoot({
|
|
|
416
419
|
const row = layout.offsets[index];
|
|
417
420
|
const h = el.clientHeight || viewport || 0;
|
|
418
421
|
const align = "align" in target ? target.align : "start";
|
|
419
|
-
const
|
|
420
|
-
if (align === "auto" && row.top >= el.scrollTop +
|
|
422
|
+
const inset2 = stickyGroups && rows[index].kind === "item" ? layout.offsets[lastMatch(groupIndices, (i) => i < index) ?? -1]?.size ?? 0 : 0;
|
|
423
|
+
if (align === "auto" && row.top >= el.scrollTop + inset2 && row.top + row.size <= el.scrollTop + h)
|
|
421
424
|
return;
|
|
422
|
-
next = row.top - (align === "end" ? h - row.size : align === "center" ? (h - row.size) / 2 :
|
|
425
|
+
next = row.top - (align === "end" ? h - row.size : align === "center" ? (h - row.size) / 2 : inset2) + ("offset" in target ? target.offset ?? 0 : 0);
|
|
423
426
|
}
|
|
424
427
|
}
|
|
425
428
|
if (!Number.isFinite(next)) return;
|
|
@@ -445,13 +448,13 @@ function ListRoot({
|
|
|
445
448
|
const el = element.current;
|
|
446
449
|
const total = windowed ? layout.total : el?.scrollHeight || layout.total;
|
|
447
450
|
const nearEnd = total - scrollTop - viewport <= Math.max(0, endThreshold);
|
|
448
|
-
const
|
|
451
|
+
const marker2 = `${data.length}:${rows.at(-1)?.id ?? ""}`;
|
|
449
452
|
if (!nearEnd) {
|
|
450
453
|
notified.current = null;
|
|
451
454
|
return;
|
|
452
455
|
}
|
|
453
|
-
if (notified.current !==
|
|
454
|
-
notified.current =
|
|
456
|
+
if (notified.current !== marker2) {
|
|
457
|
+
notified.current = marker2;
|
|
455
458
|
onEndReached();
|
|
456
459
|
}
|
|
457
460
|
}, [
|
|
@@ -624,17 +627,15 @@ function isWithinFloatingOwner(element, owner) {
|
|
|
624
627
|
|
|
625
628
|
// src/card.tsx
|
|
626
629
|
import * as React10 from "react";
|
|
627
|
-
import { ChevronDown as
|
|
630
|
+
import { ChevronDown as ChevronDown3 } from "lucide-react";
|
|
628
631
|
|
|
629
632
|
// src/interactive.tsx
|
|
630
633
|
import React9, { useId, useState as useState5 } from "react";
|
|
631
|
-
import { Check as Check2,
|
|
634
|
+
import { Check as Check2, ChevronRight, Minus, X as X4 } from "lucide-react";
|
|
632
635
|
import { Checkbox as BCheckbox } from "@base-ui/react/checkbox";
|
|
633
636
|
import { Switch as BSwitch } from "@base-ui/react/switch";
|
|
634
637
|
import { Radio as BRadio } from "@base-ui/react/radio";
|
|
635
638
|
import { RadioGroup as BRadioGroup } from "@base-ui/react/radio-group";
|
|
636
|
-
import { Select as BSelect } from "@base-ui/react/select";
|
|
637
|
-
import { Combobox } from "@base-ui/react/combobox";
|
|
638
639
|
import { Slider as BSlider } from "@base-ui/react/slider";
|
|
639
640
|
import { NumberField } from "@base-ui/react/number-field";
|
|
640
641
|
import { Menubar as BMenubar } from "@base-ui/react/menubar";
|
|
@@ -678,19 +679,82 @@ async function runConfirmTransaction({
|
|
|
678
679
|
}
|
|
679
680
|
}
|
|
680
681
|
|
|
681
|
-
// src/
|
|
682
|
-
import
|
|
683
|
-
import {
|
|
682
|
+
// src/floating-surface.tsx
|
|
683
|
+
import React4 from "react";
|
|
684
|
+
import { Menu as BMenu } from "@base-ui/react/menu";
|
|
685
|
+
import { ContextMenu as BContextMenu } from "@base-ui/react/context-menu";
|
|
686
|
+
import { Popover as BPopover } from "@base-ui/react/popover";
|
|
687
|
+
import { useDirection } from "@base-ui/react/direction-provider";
|
|
688
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
689
|
+
var MenuSurfaceOwnerContext = React4.createContext(
|
|
690
|
+
void 0
|
|
691
|
+
);
|
|
692
|
+
function FloatingSurface({
|
|
693
|
+
children,
|
|
694
|
+
kind = "popover",
|
|
695
|
+
width,
|
|
696
|
+
align = "start",
|
|
697
|
+
side = "bottom",
|
|
698
|
+
label,
|
|
699
|
+
unstyled,
|
|
700
|
+
finalFocus,
|
|
701
|
+
initialFocus,
|
|
702
|
+
popupRef,
|
|
703
|
+
onKeyDown
|
|
704
|
+
}) {
|
|
705
|
+
const direction = useDirection();
|
|
706
|
+
const owner = React4.useContext(MenuSurfaceOwnerContext);
|
|
707
|
+
const rtl = direction === "rtl" && !(kind === "popover" && (side === "left" || side === "right"));
|
|
708
|
+
const resolvedAlign = align === "left" ? rtl ? "end" : "start" : align === "right" ? rtl ? "start" : "end" : align;
|
|
709
|
+
const Primitive = kind === "popover" ? BPopover : kind === "context" ? BContextMenu : BMenu;
|
|
710
|
+
return /* @__PURE__ */ jsx2(Primitive.Portal, { keepMounted: kind !== "popover", children: /* @__PURE__ */ jsx2(MtoneScope, { children: /* @__PURE__ */ jsx2(
|
|
711
|
+
Primitive.Positioner,
|
|
712
|
+
{
|
|
713
|
+
className: "mt-positioner",
|
|
714
|
+
side: kind === "context" ? void 0 : kind === "submenu" ? "inline-end" : side,
|
|
715
|
+
sideOffset: kind === "context" ? void 0 : kind === "popover" ? 6 : 4,
|
|
716
|
+
align: kind === "submenu" ? "start" : resolvedAlign,
|
|
717
|
+
children: /* @__PURE__ */ jsx2(
|
|
718
|
+
Primitive.Popup,
|
|
719
|
+
{
|
|
720
|
+
ref: popupRef,
|
|
721
|
+
onKeyDown,
|
|
722
|
+
finalFocus,
|
|
723
|
+
initialFocus,
|
|
724
|
+
"data-menu-owner": kind === "popover" ? void 0 : owner,
|
|
725
|
+
className: cn(
|
|
726
|
+
"mt-popup",
|
|
727
|
+
"mt-floating-popup",
|
|
728
|
+
kind === "popover" ? "mt-popover" : "mt-menu-popup",
|
|
729
|
+
kind === "popover" && unstyled && "mt-popover-unstyled"
|
|
730
|
+
),
|
|
731
|
+
style: {
|
|
732
|
+
width: width ?? "max-content",
|
|
733
|
+
minWidth: width === void 0 ? void 0 : 0
|
|
734
|
+
},
|
|
735
|
+
"aria-label": label,
|
|
736
|
+
children
|
|
737
|
+
}
|
|
738
|
+
)
|
|
739
|
+
}
|
|
740
|
+
) }) });
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
// src/select.tsx
|
|
744
|
+
import React7 from "react";
|
|
745
|
+
import { Check, ChevronDown, X as X2 } from "lucide-react";
|
|
746
|
+
import { Select as BSelect } from "@base-ui/react/select";
|
|
747
|
+
import { Combobox } from "@base-ui/react/combobox";
|
|
684
748
|
|
|
685
749
|
// src/input.tsx
|
|
686
|
-
import * as
|
|
750
|
+
import * as React6 from "react";
|
|
687
751
|
import { Search, X, Eye, EyeOff, LoaderCircle } from "lucide-react";
|
|
688
752
|
|
|
689
753
|
// src/input-otp.tsx
|
|
690
|
-
import * as
|
|
691
|
-
import { jsx as
|
|
754
|
+
import * as React5 from "react";
|
|
755
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
692
756
|
var normalize = (value, length) => Array.from(value.replace(/\s/g, "")).slice(0, length).join("");
|
|
693
|
-
var InputOTPRoot =
|
|
757
|
+
var InputOTPRoot = React5.forwardRef(
|
|
694
758
|
function InputOTP({
|
|
695
759
|
length: requestedLength = 6,
|
|
696
760
|
value,
|
|
@@ -717,14 +781,14 @@ var InputOTPRoot = React4.forwardRef(
|
|
|
717
781
|
}, forwardedRef) {
|
|
718
782
|
const length = Number.isFinite(requestedLength) ? Math.max(1, Math.min(32, Math.floor(requestedLength))) : 6;
|
|
719
783
|
const disabled = useFieldsetDisabled(disabledProp);
|
|
720
|
-
const [localValue, setLocalValue] =
|
|
784
|
+
const [localValue, setLocalValue] = React5.useState(
|
|
721
785
|
() => normalize(defaultValue, length)
|
|
722
786
|
);
|
|
723
787
|
const current = normalize(value ?? localValue, length);
|
|
724
788
|
const chars = Array.from(current);
|
|
725
|
-
const inputs =
|
|
726
|
-
const [composition, setComposition] =
|
|
727
|
-
const composing =
|
|
789
|
+
const inputs = React5.useRef([]);
|
|
790
|
+
const [composition, setComposition] = React5.useState(null);
|
|
791
|
+
const composing = React5.useRef(null);
|
|
728
792
|
const commit = (next) => {
|
|
729
793
|
next = normalize(next, length);
|
|
730
794
|
if (next === current) return;
|
|
@@ -732,11 +796,11 @@ var InputOTPRoot = React4.forwardRef(
|
|
|
732
796
|
onValueChange?.(next);
|
|
733
797
|
if (Array.from(next).length === length) onComplete?.(next);
|
|
734
798
|
};
|
|
735
|
-
|
|
799
|
+
React5.useEffect(() => {
|
|
736
800
|
if (value === void 0)
|
|
737
801
|
setLocalValue((previous) => normalize(previous, length));
|
|
738
802
|
}, [length, value]);
|
|
739
|
-
|
|
803
|
+
React5.useEffect(() => {
|
|
740
804
|
const element = inputs.current[0];
|
|
741
805
|
const owner = element?.form;
|
|
742
806
|
if (!owner || value !== void 0) return;
|
|
@@ -786,9 +850,9 @@ var InputOTPRoot = React4.forwardRef(
|
|
|
786
850
|
"aria-invalid": invalid,
|
|
787
851
|
"data-disabled": disabled || void 0,
|
|
788
852
|
children: [
|
|
789
|
-
Array.from({ length }, (_, index) => /* @__PURE__ */ jsxs2(
|
|
790
|
-
index > 0 && separator != null && /* @__PURE__ */
|
|
791
|
-
/* @__PURE__ */
|
|
853
|
+
Array.from({ length }, (_, index) => /* @__PURE__ */ jsxs2(React5.Fragment, { children: [
|
|
854
|
+
index > 0 && separator != null && /* @__PURE__ */ jsx3("span", { className: "mt-input-otp-separator", "aria-hidden": "true", children: separator }),
|
|
855
|
+
/* @__PURE__ */ jsx3(
|
|
792
856
|
"input",
|
|
793
857
|
{
|
|
794
858
|
ref: (element) => {
|
|
@@ -852,7 +916,7 @@ var InputOTPRoot = React4.forwardRef(
|
|
|
852
916
|
}
|
|
853
917
|
)
|
|
854
918
|
] }, index)),
|
|
855
|
-
name && /* @__PURE__ */
|
|
919
|
+
name && /* @__PURE__ */ jsx3(
|
|
856
920
|
"input",
|
|
857
921
|
{
|
|
858
922
|
type: "hidden",
|
|
@@ -872,19 +936,19 @@ var InputOTP2 = Object.assign(InputOTPRoot, {
|
|
|
872
936
|
});
|
|
873
937
|
|
|
874
938
|
// src/input.tsx
|
|
875
|
-
import { Fragment as Fragment3, jsx as
|
|
939
|
+
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
876
940
|
var classes = (...values2) => values2.filter(Boolean).join(" ");
|
|
877
941
|
var stringValue = (value) => value == null ? "" : String(value);
|
|
878
942
|
function useNativeValue(value, defaultValue, forwarded, formId) {
|
|
879
|
-
const ref =
|
|
880
|
-
|
|
881
|
-
const [local, setLocal] =
|
|
943
|
+
const ref = React6.useRef(null);
|
|
944
|
+
React6.useImperativeHandle(forwarded, () => ref.current);
|
|
945
|
+
const [local, setLocal] = React6.useState(() => stringValue(defaultValue));
|
|
882
946
|
const controlled = value !== void 0;
|
|
883
|
-
|
|
947
|
+
React6.useLayoutEffect(() => {
|
|
884
948
|
if (!controlled && ref.current && local !== ref.current.value)
|
|
885
949
|
setLocal(ref.current.value);
|
|
886
950
|
});
|
|
887
|
-
|
|
951
|
+
React6.useEffect(() => {
|
|
888
952
|
const form = ref.current?.form;
|
|
889
953
|
let timer;
|
|
890
954
|
const reset = (event) => {
|
|
@@ -901,7 +965,7 @@ function useNativeValue(value, defaultValue, forwarded, formId) {
|
|
|
901
965
|
}, [controlled, formId]);
|
|
902
966
|
return { ref, text: controlled ? stringValue(value) : local, setLocal };
|
|
903
967
|
}
|
|
904
|
-
var InputRoot =
|
|
968
|
+
var InputRoot = React6.forwardRef(
|
|
905
969
|
function InputRoot2({
|
|
906
970
|
prefix,
|
|
907
971
|
suffix,
|
|
@@ -958,8 +1022,8 @@ var InputRoot = React5.forwardRef(
|
|
|
958
1022
|
"data-disabled": disabled || void 0,
|
|
959
1023
|
"data-status": invalid ? "error" : status,
|
|
960
1024
|
children: [
|
|
961
|
-
prefix != null && /* @__PURE__ */
|
|
962
|
-
/* @__PURE__ */
|
|
1025
|
+
prefix != null && /* @__PURE__ */ jsx4("span", { className: "mt-input-prefix", children: prefix }),
|
|
1026
|
+
/* @__PURE__ */ jsx4(
|
|
963
1027
|
"input",
|
|
964
1028
|
{
|
|
965
1029
|
...props,
|
|
@@ -976,7 +1040,7 @@ var InputRoot = React5.forwardRef(
|
|
|
976
1040
|
}
|
|
977
1041
|
}
|
|
978
1042
|
),
|
|
979
|
-
allowClear && text && !disabled && !readOnly && /* @__PURE__ */
|
|
1043
|
+
allowClear && text && !disabled && !readOnly && /* @__PURE__ */ jsx4(
|
|
980
1044
|
"button",
|
|
981
1045
|
{
|
|
982
1046
|
type: "button",
|
|
@@ -984,10 +1048,10 @@ var InputRoot = React5.forwardRef(
|
|
|
984
1048
|
"aria-label": clearLabel ?? (locale === "zh" ? "\u6E05\u9664\u5185\u5BB9" : "Clear input"),
|
|
985
1049
|
onMouseDown: (event) => event.preventDefault(),
|
|
986
1050
|
onClick: clear,
|
|
987
|
-
children: /* @__PURE__ */
|
|
1051
|
+
children: /* @__PURE__ */ jsx4(X, { size: 13 })
|
|
988
1052
|
}
|
|
989
1053
|
),
|
|
990
|
-
suffix != null && /* @__PURE__ */
|
|
1054
|
+
suffix != null && /* @__PURE__ */ jsx4("span", { className: "mt-input-suffix", children: suffix }),
|
|
991
1055
|
showCount && /* @__PURE__ */ jsxs3("span", { className: "mt-input-count", children: [
|
|
992
1056
|
countCharacters(text),
|
|
993
1057
|
props.maxLength !== void 0 ? ` / ${props.maxLength}` : ""
|
|
@@ -997,7 +1061,7 @@ var InputRoot = React5.forwardRef(
|
|
|
997
1061
|
);
|
|
998
1062
|
}
|
|
999
1063
|
);
|
|
1000
|
-
var SearchInput =
|
|
1064
|
+
var SearchInput = React6.forwardRef(
|
|
1001
1065
|
function SearchInput2({
|
|
1002
1066
|
onSearch,
|
|
1003
1067
|
searchButton,
|
|
@@ -1009,16 +1073,16 @@ var SearchInput = React5.forwardRef(
|
|
|
1009
1073
|
wrapperClassName,
|
|
1010
1074
|
...props
|
|
1011
1075
|
}, forwarded) {
|
|
1012
|
-
const ref =
|
|
1013
|
-
|
|
1076
|
+
const ref = React6.useRef(null);
|
|
1077
|
+
React6.useImperativeHandle(forwarded, () => ref.current);
|
|
1014
1078
|
const disabled = useFieldsetDisabled(disabledProp);
|
|
1015
1079
|
const { locale } = useMtone();
|
|
1016
|
-
const composing =
|
|
1080
|
+
const composing = React6.useRef(false);
|
|
1017
1081
|
const search = () => {
|
|
1018
1082
|
if (!disabled && !loading && !composing.current)
|
|
1019
1083
|
onSearch?.(ref.current?.value ?? "");
|
|
1020
1084
|
};
|
|
1021
|
-
return /* @__PURE__ */
|
|
1085
|
+
return /* @__PURE__ */ jsx4(
|
|
1022
1086
|
InputRoot,
|
|
1023
1087
|
{
|
|
1024
1088
|
...props,
|
|
@@ -1028,7 +1092,7 @@ var SearchInput = React5.forwardRef(
|
|
|
1028
1092
|
"mt-search mt-input-search",
|
|
1029
1093
|
wrapperClassName
|
|
1030
1094
|
),
|
|
1031
|
-
prefix: prefix ?? /* @__PURE__ */
|
|
1095
|
+
prefix: prefix ?? /* @__PURE__ */ jsx4(Search, { size: 15, "aria-hidden": "true" }),
|
|
1032
1096
|
"aria-busy": loading || props["aria-busy"],
|
|
1033
1097
|
onCompositionStart: (event) => {
|
|
1034
1098
|
composing.current = true;
|
|
@@ -1040,7 +1104,7 @@ var SearchInput = React5.forwardRef(
|
|
|
1040
1104
|
},
|
|
1041
1105
|
suffix: suffix != null || loading || searchButton ? /* @__PURE__ */ jsxs3(Fragment3, { children: [
|
|
1042
1106
|
suffix,
|
|
1043
|
-
loading && /* @__PURE__ */
|
|
1107
|
+
loading && /* @__PURE__ */ jsx4(
|
|
1044
1108
|
LoaderCircle,
|
|
1045
1109
|
{
|
|
1046
1110
|
size: 14,
|
|
@@ -1048,7 +1112,7 @@ var SearchInput = React5.forwardRef(
|
|
|
1048
1112
|
"aria-hidden": "true"
|
|
1049
1113
|
}
|
|
1050
1114
|
),
|
|
1051
|
-
searchButton && /* @__PURE__ */
|
|
1115
|
+
searchButton && /* @__PURE__ */ jsx4(
|
|
1052
1116
|
"button",
|
|
1053
1117
|
{
|
|
1054
1118
|
type: "button",
|
|
@@ -1070,7 +1134,7 @@ var SearchInput = React5.forwardRef(
|
|
|
1070
1134
|
);
|
|
1071
1135
|
}
|
|
1072
1136
|
);
|
|
1073
|
-
var InputPassword =
|
|
1137
|
+
var InputPassword = React6.forwardRef(function InputPassword2({
|
|
1074
1138
|
visible,
|
|
1075
1139
|
defaultVisible = false,
|
|
1076
1140
|
onVisibleChange,
|
|
@@ -1078,13 +1142,13 @@ var InputPassword = React5.forwardRef(function InputPassword2({
|
|
|
1078
1142
|
disabled: disabledProp,
|
|
1079
1143
|
...props
|
|
1080
1144
|
}, forwarded) {
|
|
1081
|
-
const [local, setLocal] =
|
|
1145
|
+
const [local, setLocal] = React6.useState(defaultVisible);
|
|
1082
1146
|
const shown = visible ?? local;
|
|
1083
|
-
const ref =
|
|
1084
|
-
|
|
1147
|
+
const ref = React6.useRef(null);
|
|
1148
|
+
React6.useImperativeHandle(forwarded, () => ref.current);
|
|
1085
1149
|
const disabled = useFieldsetDisabled(disabledProp);
|
|
1086
1150
|
const { locale } = useMtone();
|
|
1087
|
-
return /* @__PURE__ */
|
|
1151
|
+
return /* @__PURE__ */ jsx4(
|
|
1088
1152
|
InputRoot,
|
|
1089
1153
|
{
|
|
1090
1154
|
...props,
|
|
@@ -1093,7 +1157,7 @@ var InputPassword = React5.forwardRef(function InputPassword2({
|
|
|
1093
1157
|
type: shown ? "text" : "password",
|
|
1094
1158
|
suffix: /* @__PURE__ */ jsxs3(Fragment3, { children: [
|
|
1095
1159
|
suffix,
|
|
1096
|
-
/* @__PURE__ */
|
|
1160
|
+
/* @__PURE__ */ jsx4(
|
|
1097
1161
|
"button",
|
|
1098
1162
|
{
|
|
1099
1163
|
type: "button",
|
|
@@ -1107,14 +1171,14 @@ var InputPassword = React5.forwardRef(function InputPassword2({
|
|
|
1107
1171
|
onVisibleChange?.(!shown);
|
|
1108
1172
|
ref.current?.focus();
|
|
1109
1173
|
},
|
|
1110
|
-
children: shown ? /* @__PURE__ */
|
|
1174
|
+
children: shown ? /* @__PURE__ */ jsx4(EyeOff, { size: 14 }) : /* @__PURE__ */ jsx4(Eye, { size: 14 })
|
|
1111
1175
|
}
|
|
1112
1176
|
)
|
|
1113
1177
|
] })
|
|
1114
1178
|
}
|
|
1115
1179
|
);
|
|
1116
1180
|
});
|
|
1117
|
-
var Textarea =
|
|
1181
|
+
var Textarea = React6.forwardRef(function Textarea2({
|
|
1118
1182
|
autoSize,
|
|
1119
1183
|
controlSize = "md",
|
|
1120
1184
|
variant = "outlined",
|
|
@@ -1136,7 +1200,7 @@ var Textarea = React5.forwardRef(function Textarea2({
|
|
|
1136
1200
|
forwarded,
|
|
1137
1201
|
props.form
|
|
1138
1202
|
);
|
|
1139
|
-
const resize =
|
|
1203
|
+
const resize = React6.useCallback(() => {
|
|
1140
1204
|
const element = ref.current;
|
|
1141
1205
|
if (!element) return;
|
|
1142
1206
|
if (!autoSize) {
|
|
@@ -1167,8 +1231,8 @@ var Textarea = React5.forwardRef(function Textarea2({
|
|
|
1167
1231
|
element.style.height = `${height}px`;
|
|
1168
1232
|
element.style.overflowY = element.scrollHeight + border > height ? "auto" : "hidden";
|
|
1169
1233
|
}, [autoSize, props.rows, ref, style?.height, style?.overflowY]);
|
|
1170
|
-
|
|
1171
|
-
|
|
1234
|
+
React6.useLayoutEffect(resize, [resize, text]);
|
|
1235
|
+
React6.useEffect(() => {
|
|
1172
1236
|
if (!autoSize || !ref.current || typeof ResizeObserver === "undefined")
|
|
1173
1237
|
return;
|
|
1174
1238
|
let width = ref.current.clientWidth;
|
|
@@ -1193,7 +1257,7 @@ var Textarea = React5.forwardRef(function Textarea2({
|
|
|
1193
1257
|
"data-status": invalid ? "error" : status,
|
|
1194
1258
|
"data-disabled": disabled || void 0,
|
|
1195
1259
|
children: [
|
|
1196
|
-
/* @__PURE__ */
|
|
1260
|
+
/* @__PURE__ */ jsx4(
|
|
1197
1261
|
"textarea",
|
|
1198
1262
|
{
|
|
1199
1263
|
...props,
|
|
@@ -1228,239 +1292,798 @@ var Input = Object.assign(InputRoot, {
|
|
|
1228
1292
|
OTP: InputOTP2
|
|
1229
1293
|
});
|
|
1230
1294
|
|
|
1231
|
-
// src/
|
|
1232
|
-
import { jsx as
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
const hasIcons = items.some((item) => item.icon != null && item.icon !== false);
|
|
1249
|
-
React6.useEffect(() => {
|
|
1250
|
-
if (!open) {
|
|
1251
|
-
setQuery("");
|
|
1252
|
-
setActiveValue(null);
|
|
1253
|
-
composing.current = false;
|
|
1254
|
-
if (listRef.current) listRef.current.scrollTop = 0;
|
|
1255
|
-
}
|
|
1256
|
-
}, [open]);
|
|
1257
|
-
React6.useLayoutEffect(() => {
|
|
1258
|
-
const list = listRef.current;
|
|
1259
|
-
const row = activeId ? list?.ownerDocument.getElementById(activeId) : void 0;
|
|
1260
|
-
if (!open || !list || !row) return;
|
|
1261
|
-
const bounds = list.getBoundingClientRect();
|
|
1262
|
-
const option = row.getBoundingClientRect();
|
|
1263
|
-
if (option.top < bounds.top) list.scrollTop += option.top - bounds.top;
|
|
1264
|
-
else if (option.bottom > bounds.bottom) list.scrollTop += option.bottom - bounds.bottom;
|
|
1265
|
-
}, [activeId, open, query]);
|
|
1266
|
-
return /* @__PURE__ */ jsxs4("div", { className: "mt-popover-searchable-select", children: [
|
|
1267
|
-
/* @__PURE__ */ jsx4(
|
|
1268
|
-
Input,
|
|
1269
|
-
{
|
|
1270
|
-
ref: inputRef,
|
|
1271
|
-
role: "combobox",
|
|
1272
|
-
"aria-label": searchLabel,
|
|
1273
|
-
"aria-autocomplete": "list",
|
|
1274
|
-
"aria-expanded": open,
|
|
1275
|
-
"aria-controls": listId,
|
|
1276
|
-
"aria-activedescendant": open ? activeId : void 0,
|
|
1277
|
-
autoComplete: "off",
|
|
1278
|
-
placeholder: searchPlaceholder ?? searchLabel,
|
|
1279
|
-
prefix: /* @__PURE__ */ jsx4(Search2, { size: 16, "aria-hidden": "true" }),
|
|
1280
|
-
value: query,
|
|
1281
|
-
onCompositionStart: () => {
|
|
1282
|
-
composing.current = true;
|
|
1283
|
-
},
|
|
1284
|
-
onCompositionEnd: () => {
|
|
1285
|
-
composing.current = false;
|
|
1286
|
-
},
|
|
1287
|
-
onChange: (event) => {
|
|
1288
|
-
setQuery(event.currentTarget.value);
|
|
1289
|
-
setActiveValue(null);
|
|
1290
|
-
if (listRef.current) listRef.current.scrollTop = 0;
|
|
1291
|
-
},
|
|
1292
|
-
onKeyDown: (event) => {
|
|
1293
|
-
if (composing.current || event.nativeEvent.isComposing) {
|
|
1294
|
-
if (event.key === "Escape") event.stopPropagation();
|
|
1295
|
-
return;
|
|
1296
|
-
}
|
|
1297
|
-
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
1298
|
-
event.preventDefault();
|
|
1299
|
-
if (!active) return;
|
|
1300
|
-
const index = enabled.indexOf(active) + (event.key === "ArrowDown" ? 1 : -1);
|
|
1301
|
-
setActiveValue(enabled[Math.max(0, Math.min(index, enabled.length - 1))].value);
|
|
1302
|
-
} else if (event.key === "Enter" && active) {
|
|
1303
|
-
event.preventDefault();
|
|
1304
|
-
select(active.value);
|
|
1305
|
-
}
|
|
1306
|
-
}
|
|
1295
|
+
// src/select.tsx
|
|
1296
|
+
import { Fragment as Fragment4, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1297
|
+
var noValues = [];
|
|
1298
|
+
function useOptions(options) {
|
|
1299
|
+
return React7.useMemo(() => {
|
|
1300
|
+
const sections = [];
|
|
1301
|
+
let ungrouped = [];
|
|
1302
|
+
const flush = () => {
|
|
1303
|
+
if (ungrouped.length) sections.push({ items: ungrouped, grouped: false });
|
|
1304
|
+
ungrouped = [];
|
|
1305
|
+
};
|
|
1306
|
+
for (const option of options) {
|
|
1307
|
+
if ("options" in option) {
|
|
1308
|
+
flush();
|
|
1309
|
+
if (option.options.length) sections.push({ items: option.options, grouped: true, label: option.label });
|
|
1310
|
+
} else {
|
|
1311
|
+
ungrouped.push(option);
|
|
1307
1312
|
}
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
)
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1313
|
+
}
|
|
1314
|
+
flush();
|
|
1315
|
+
const items = sections.flatMap((section) => section.items);
|
|
1316
|
+
const comboItems = sections.some((section) => section.grouped) ? sections.map((section, index) => ({ section, index, items: section.items.map((item) => item.value) })) : items.map((item) => item.value);
|
|
1317
|
+
return { sections, items, comboItems, byValue: new Map(items.map((option) => [option.value, option])) };
|
|
1318
|
+
}, [options]);
|
|
1319
|
+
}
|
|
1320
|
+
function optionText(option, value) {
|
|
1321
|
+
return option?.searchText ?? (typeof option?.label === "string" || typeof option?.label === "number" ? String(option.label) : value);
|
|
1322
|
+
}
|
|
1323
|
+
function useSelection(props, empty, resetPopup) {
|
|
1324
|
+
const { value, defaultValue, onValueChange, form } = props;
|
|
1325
|
+
const initial = React7.useRef(defaultValue === void 0 ? empty : defaultValue);
|
|
1326
|
+
const [local, setLocal] = React7.useState(initial.current);
|
|
1327
|
+
const inputRef = React7.useRef(null);
|
|
1328
|
+
React7.useEffect(() => {
|
|
1329
|
+
const owner = inputRef.current?.form;
|
|
1330
|
+
if (!owner) return;
|
|
1331
|
+
const handleReset = (event) => {
|
|
1332
|
+
queueMicrotask(() => {
|
|
1333
|
+
if (event.defaultPrevented || inputRef.current?.form !== owner) return;
|
|
1334
|
+
if (value === void 0) setLocal(initial.current);
|
|
1335
|
+
resetPopup();
|
|
1336
|
+
});
|
|
1337
|
+
};
|
|
1338
|
+
owner.addEventListener("reset", handleReset);
|
|
1339
|
+
return () => owner.removeEventListener("reset", handleReset);
|
|
1340
|
+
}, [value === void 0, form, resetPopup]);
|
|
1341
|
+
return {
|
|
1342
|
+
value: value === void 0 ? local : value,
|
|
1343
|
+
inputRef,
|
|
1344
|
+
change(next) {
|
|
1345
|
+
if (value === void 0) setLocal(next);
|
|
1346
|
+
onValueChange?.(next);
|
|
1347
|
+
}
|
|
1348
|
+
};
|
|
1344
1349
|
}
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
);
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
kind = "popover",
|
|
1359
|
-
width,
|
|
1360
|
-
align = "start",
|
|
1361
|
-
side = "bottom",
|
|
1362
|
-
label,
|
|
1363
|
-
unstyled,
|
|
1364
|
-
finalFocus,
|
|
1365
|
-
initialFocus,
|
|
1366
|
-
popupRef,
|
|
1367
|
-
onKeyDown
|
|
1368
|
-
}) {
|
|
1369
|
-
const direction = useDirection();
|
|
1370
|
-
const owner = React7.useContext(MenuSurfaceOwnerContext);
|
|
1371
|
-
const rtl = direction === "rtl" && !(kind === "popover" && (side === "left" || side === "right"));
|
|
1372
|
-
const resolvedAlign = align === "left" ? rtl ? "end" : "start" : align === "right" ? rtl ? "start" : "end" : align;
|
|
1373
|
-
const Primitive = kind === "popover" ? BPopover : kind === "context" ? BContextMenu : BMenu;
|
|
1374
|
-
return /* @__PURE__ */ jsx5(Primitive.Portal, { keepMounted: kind !== "popover", children: /* @__PURE__ */ jsx5(MtoneScope, { children: /* @__PURE__ */ jsx5(
|
|
1375
|
-
Primitive.Positioner,
|
|
1376
|
-
{
|
|
1377
|
-
className: "mt-positioner",
|
|
1378
|
-
side: kind === "context" ? void 0 : kind === "submenu" ? "inline-end" : side,
|
|
1379
|
-
sideOffset: kind === "context" ? void 0 : kind === "popover" ? 6 : 4,
|
|
1380
|
-
align: kind === "submenu" ? "start" : resolvedAlign,
|
|
1381
|
-
children: /* @__PURE__ */ jsx5(
|
|
1382
|
-
Primitive.Popup,
|
|
1383
|
-
{
|
|
1384
|
-
ref: popupRef,
|
|
1385
|
-
onKeyDown,
|
|
1386
|
-
finalFocus,
|
|
1387
|
-
initialFocus,
|
|
1388
|
-
"data-menu-owner": kind === "popover" ? void 0 : owner,
|
|
1389
|
-
className: cn(
|
|
1390
|
-
"mt-popup",
|
|
1391
|
-
"mt-floating-popup",
|
|
1392
|
-
kind === "popover" ? "mt-popover" : "mt-menu-popup",
|
|
1393
|
-
kind === "popover" && unstyled && "mt-popover-unstyled"
|
|
1394
|
-
),
|
|
1395
|
-
style: {
|
|
1396
|
-
width: width ?? "max-content",
|
|
1397
|
-
minWidth: width === void 0 ? void 0 : 0
|
|
1398
|
-
},
|
|
1399
|
-
"aria-label": label,
|
|
1400
|
-
children
|
|
1401
|
-
}
|
|
1402
|
-
)
|
|
1350
|
+
function useSelectPopup({ open, defaultOpen, onOpenChange }, disabled) {
|
|
1351
|
+
const [local, setLocal] = React7.useState(defaultOpen ?? false);
|
|
1352
|
+
const reset = React7.useCallback(() => setLocal(false), []);
|
|
1353
|
+
React7.useEffect(() => {
|
|
1354
|
+
if (disabled) reset();
|
|
1355
|
+
}, [disabled, reset]);
|
|
1356
|
+
return {
|
|
1357
|
+
open: !disabled && (open ?? local),
|
|
1358
|
+
reset,
|
|
1359
|
+
change(next) {
|
|
1360
|
+
if (next && disabled) return;
|
|
1361
|
+
if (open === void 0) setLocal(next);
|
|
1362
|
+
onOpenChange?.(next);
|
|
1403
1363
|
}
|
|
1404
|
-
|
|
1364
|
+
};
|
|
1405
1365
|
}
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1366
|
+
function ClearSelection({ locale, focus, clear, className = "mt-select-clear" }) {
|
|
1367
|
+
return /* @__PURE__ */ jsx5(
|
|
1368
|
+
"button",
|
|
1369
|
+
{
|
|
1370
|
+
type: "button",
|
|
1371
|
+
className,
|
|
1372
|
+
"aria-label": locale === "zh" ? "\u6E05\u9664\u9009\u62E9" : "Clear selection",
|
|
1373
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
1374
|
+
onClick: () => {
|
|
1375
|
+
focus();
|
|
1376
|
+
clear();
|
|
1377
|
+
},
|
|
1378
|
+
children: /* @__PURE__ */ jsx5(X2, { size: 14, "aria-hidden": "true" })
|
|
1379
|
+
}
|
|
1380
|
+
);
|
|
1421
1381
|
}
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
onValueChange,
|
|
1430
|
-
label,
|
|
1431
|
-
placement = "top",
|
|
1432
|
-
variant = "line",
|
|
1433
|
-
size = "medium",
|
|
1434
|
-
indicatorColor,
|
|
1435
|
-
centered = false,
|
|
1436
|
-
gap,
|
|
1437
|
-
extraStart,
|
|
1438
|
-
extraEnd,
|
|
1439
|
-
activateOnFocus = false,
|
|
1440
|
-
destroyOnHidden = true,
|
|
1441
|
-
hideAdd = false,
|
|
1442
|
-
addIcon,
|
|
1443
|
-
addLabel,
|
|
1444
|
-
moreLabel,
|
|
1445
|
-
onEdit,
|
|
1446
|
-
onTabClick,
|
|
1447
|
-
reorderable = false,
|
|
1448
|
-
onOrderChange,
|
|
1382
|
+
var marker = /* @__PURE__ */ jsx5(Check, { size: 16, strokeWidth: 1.5, "aria-hidden": "true" });
|
|
1383
|
+
function SelectSingle({
|
|
1384
|
+
options,
|
|
1385
|
+
clearable,
|
|
1386
|
+
emptyContent,
|
|
1387
|
+
renderOption,
|
|
1388
|
+
placeholder,
|
|
1449
1389
|
className,
|
|
1450
|
-
|
|
1390
|
+
name,
|
|
1391
|
+
form,
|
|
1392
|
+
label,
|
|
1393
|
+
id,
|
|
1394
|
+
onBlur,
|
|
1395
|
+
required,
|
|
1396
|
+
"aria-invalid": invalid,
|
|
1397
|
+
"aria-busy": busy,
|
|
1398
|
+
"aria-describedby": describedBy,
|
|
1399
|
+
"aria-labelledby": labelledBy,
|
|
1451
1400
|
...props
|
|
1452
|
-
}
|
|
1401
|
+
}) {
|
|
1453
1402
|
const { locale } = useMtone();
|
|
1454
|
-
const
|
|
1455
|
-
const
|
|
1456
|
-
const
|
|
1457
|
-
const
|
|
1458
|
-
|
|
1459
|
-
);
|
|
1460
|
-
const
|
|
1461
|
-
const
|
|
1462
|
-
|
|
1463
|
-
|
|
1403
|
+
const disabled = useFieldsetDisabled(props.disabled);
|
|
1404
|
+
const popup = useSelectPopup(props, disabled);
|
|
1405
|
+
const selection = useSelection({ ...props, form }, null, popup.reset);
|
|
1406
|
+
const optionData = useOptions(options);
|
|
1407
|
+
const triggerRef = React7.useRef(null);
|
|
1408
|
+
const empty = emptyContent ?? (locale === "zh" ? "\u65E0\u5339\u914D\u7ED3\u679C" : "No results");
|
|
1409
|
+
const prompt = placeholder ?? (locale === "zh" ? "\u8BF7\u9009\u62E9" : "Select\u2026");
|
|
1410
|
+
const rootProps = {
|
|
1411
|
+
value: selection.value,
|
|
1412
|
+
onValueChange: selection.change,
|
|
1413
|
+
inputRef: selection.inputRef,
|
|
1414
|
+
open: popup.open,
|
|
1415
|
+
onOpenChange: popup.change,
|
|
1416
|
+
disabled,
|
|
1417
|
+
name,
|
|
1418
|
+
form,
|
|
1419
|
+
// An explicitly chosen empty string is a value, not the unselected state.
|
|
1420
|
+
required: required && selection.value !== ""
|
|
1421
|
+
};
|
|
1422
|
+
const triggerProps = {
|
|
1423
|
+
id,
|
|
1424
|
+
ref: triggerRef,
|
|
1425
|
+
"aria-label": label,
|
|
1426
|
+
"aria-invalid": invalid,
|
|
1427
|
+
"aria-busy": busy,
|
|
1428
|
+
"aria-describedby": describedBy,
|
|
1429
|
+
"aria-labelledby": labelledBy,
|
|
1430
|
+
"aria-required": required || void 0,
|
|
1431
|
+
className: cn("mt-select", className)
|
|
1432
|
+
};
|
|
1433
|
+
const clear = clearable && !disabled && selection.value !== null && /* @__PURE__ */ jsx5(ClearSelection, { locale, focus: () => triggerRef.current?.focus(), clear: () => selection.change(null) });
|
|
1434
|
+
const withClear = (trigger) => clearable ? /* @__PURE__ */ jsxs4("span", { className: "mt-select-clearable", children: [
|
|
1435
|
+
trigger,
|
|
1436
|
+
clear
|
|
1437
|
+
] }) : trigger;
|
|
1438
|
+
const renderItem = (option) => /* @__PURE__ */ jsxs4(
|
|
1439
|
+
BSelect.Item,
|
|
1440
|
+
{
|
|
1441
|
+
className: "mt-option",
|
|
1442
|
+
value: option.value,
|
|
1443
|
+
disabled: option.disabled,
|
|
1444
|
+
label: renderOption ? optionText(option, option.value) : void 0,
|
|
1445
|
+
children: [
|
|
1446
|
+
/* @__PURE__ */ jsx5(BSelect.ItemText, { children: renderOption ? renderOption(option) : option.label }),
|
|
1447
|
+
/* @__PURE__ */ jsx5(BSelect.ItemIndicator, { className: "mt-select-item-indicator", "aria-hidden": "true", children: marker })
|
|
1448
|
+
]
|
|
1449
|
+
},
|
|
1450
|
+
option.value
|
|
1451
|
+
);
|
|
1452
|
+
return /* @__PURE__ */ jsxs4(BSelect.Root, { items: optionData.items, ...rootProps, children: [
|
|
1453
|
+
withClear(
|
|
1454
|
+
/* @__PURE__ */ jsxs4(BSelect.Trigger, { ...triggerProps, onBlur, children: [
|
|
1455
|
+
/* @__PURE__ */ jsx5(BSelect.Value, { className: "mt-select-value", placeholder: prompt, children: renderOption && selection.value !== null ? optionData.byValue.get(selection.value)?.label ?? selection.value : void 0 }),
|
|
1456
|
+
/* @__PURE__ */ jsx5(BSelect.Icon, { className: "mt-select-icon", children: /* @__PURE__ */ jsx5(ChevronDown, { size: 16, "aria-hidden": "true" }) })
|
|
1457
|
+
] })
|
|
1458
|
+
),
|
|
1459
|
+
/* @__PURE__ */ jsx5(BSelect.Portal, { children: /* @__PURE__ */ jsx5(MtoneScope, { children: /* @__PURE__ */ jsx5(BSelect.Positioner, { className: "mt-positioner", sideOffset: 4, alignItemWithTrigger: false, children: /* @__PURE__ */ jsxs4(BSelect.Popup, { className: "mt-popup", children: [
|
|
1460
|
+
!optionData.items.length && /* @__PURE__ */ jsx5("div", { className: "mt-combobox-empty", role: "status", children: empty }),
|
|
1461
|
+
/* @__PURE__ */ jsx5(BSelect.List, { children: optionData.sections.map((section, index) => section.grouped ? /* @__PURE__ */ jsxs4(BSelect.Group, { children: [
|
|
1462
|
+
/* @__PURE__ */ jsx5(BSelect.GroupLabel, { className: "mt-select-group-label", children: section.label }),
|
|
1463
|
+
section.items.map(renderItem)
|
|
1464
|
+
] }, index) : /* @__PURE__ */ jsx5(React7.Fragment, { children: section.items.map(renderItem) }, index)) })
|
|
1465
|
+
] }) }) }) })
|
|
1466
|
+
] });
|
|
1467
|
+
}
|
|
1468
|
+
function SelectSearchable({
|
|
1469
|
+
options,
|
|
1470
|
+
searchPlaceholder,
|
|
1471
|
+
clearable,
|
|
1472
|
+
emptyContent,
|
|
1473
|
+
renderOption,
|
|
1474
|
+
placeholder,
|
|
1475
|
+
className,
|
|
1476
|
+
name,
|
|
1477
|
+
form,
|
|
1478
|
+
label,
|
|
1479
|
+
id,
|
|
1480
|
+
onBlur,
|
|
1481
|
+
required,
|
|
1482
|
+
"aria-invalid": invalid,
|
|
1483
|
+
"aria-busy": busy,
|
|
1484
|
+
"aria-describedby": describedBy,
|
|
1485
|
+
"aria-labelledby": labelledBy,
|
|
1486
|
+
...props
|
|
1487
|
+
}) {
|
|
1488
|
+
const { locale } = useMtone();
|
|
1489
|
+
const disabled = useFieldsetDisabled(props.disabled);
|
|
1490
|
+
const popup = useSelectPopup(props, disabled);
|
|
1491
|
+
const [draft, setDraft] = React7.useState("");
|
|
1492
|
+
const composingRef = React7.useRef(false);
|
|
1493
|
+
const input = React7.useRef(null);
|
|
1494
|
+
const surface = React7.useRef(null);
|
|
1495
|
+
const popupRef = React7.useRef(null);
|
|
1496
|
+
const richLabelId = React7.useId();
|
|
1497
|
+
const reset = React7.useCallback(() => {
|
|
1498
|
+
popup.reset();
|
|
1499
|
+
setDraft("");
|
|
1500
|
+
}, [popup.reset]);
|
|
1501
|
+
const selection = useSelection({ ...props, form }, null, reset);
|
|
1502
|
+
const data = useOptions(options);
|
|
1503
|
+
const selected = selection.value === null ? void 0 : data.byValue.get(selection.value);
|
|
1504
|
+
const selectedLabel = selected?.label ?? selection.value;
|
|
1505
|
+
const plainLabel = typeof selectedLabel === "string" || typeof selectedLabel === "number";
|
|
1506
|
+
const valueText = selection.value === null ? "" : plainLabel ? String(selectedLabel) : optionText(selected, selection.value);
|
|
1507
|
+
const showRichLabel = !popup.open && selectedLabel != null && !plainLabel;
|
|
1508
|
+
const description = showRichLabel ? describedBy ? `${describedBy} ${richLabelId}` : richLabelId : describedBy;
|
|
1509
|
+
const searchPrompt = searchPlaceholder ?? (locale === "zh" ? "\u641C\u7D22\u9009\u9879" : "Search options");
|
|
1510
|
+
const prompt = selection.value !== null && !valueText ? void 0 : placeholder ?? (locale === "zh" ? "\u8BF7\u9009\u62E9" : "Select\u2026");
|
|
1511
|
+
React7.useEffect(() => {
|
|
1512
|
+
if (!popup.open) setDraft("");
|
|
1513
|
+
}, [popup.open]);
|
|
1514
|
+
React7.useLayoutEffect(() => {
|
|
1515
|
+
if (!popup.open && input.current === input.current?.ownerDocument.activeElement) input.current?.select();
|
|
1516
|
+
}, [popup.open, valueText]);
|
|
1517
|
+
return /* @__PURE__ */ jsxs4(
|
|
1518
|
+
Combobox.Root,
|
|
1519
|
+
{
|
|
1520
|
+
items: data.comboItems,
|
|
1521
|
+
itemToStringLabel: (value) => optionText(data.byValue.get(value), value),
|
|
1522
|
+
autoHighlight: true,
|
|
1523
|
+
inputValue: popup.open ? draft : valueText,
|
|
1524
|
+
filter: popup.open ? void 0 : null,
|
|
1525
|
+
value: selection.value,
|
|
1526
|
+
inputRef: selection.inputRef,
|
|
1527
|
+
name,
|
|
1528
|
+
form,
|
|
1529
|
+
disabled,
|
|
1530
|
+
required: required && selection.value !== "",
|
|
1531
|
+
onInputValueChange: (next, details) => {
|
|
1532
|
+
if (details.reason !== "input-change") return;
|
|
1533
|
+
setDraft(next);
|
|
1534
|
+
if (!popup.open && !next.trim()) popup.change(true);
|
|
1535
|
+
},
|
|
1536
|
+
onValueChange: (next, details) => {
|
|
1537
|
+
if (composingRef.current || next === null && details.reason !== "clear-press" || next !== null && data.byValue.get(next)?.disabled) {
|
|
1538
|
+
details.cancel();
|
|
1539
|
+
return;
|
|
1540
|
+
}
|
|
1541
|
+
selection.change(next);
|
|
1542
|
+
setDraft("");
|
|
1543
|
+
},
|
|
1544
|
+
open: popup.open,
|
|
1545
|
+
onOpenChange: (open) => {
|
|
1546
|
+
if (!open) setDraft("");
|
|
1547
|
+
popup.change(open);
|
|
1548
|
+
},
|
|
1549
|
+
children: [
|
|
1550
|
+
/* @__PURE__ */ jsxs4(
|
|
1551
|
+
Combobox.InputGroup,
|
|
1552
|
+
{
|
|
1553
|
+
ref: surface,
|
|
1554
|
+
"aria-invalid": invalid,
|
|
1555
|
+
className: cn("mt-select mt-select-inline-search", className),
|
|
1556
|
+
onBlur: (event) => {
|
|
1557
|
+
if (surface.current?.contains(event.relatedTarget) || popupRef.current?.contains(event.relatedTarget)) return;
|
|
1558
|
+
composingRef.current = false;
|
|
1559
|
+
setDraft("");
|
|
1560
|
+
onBlur?.(event);
|
|
1561
|
+
},
|
|
1562
|
+
children: [
|
|
1563
|
+
/* @__PURE__ */ jsxs4("span", { className: "mt-select-inline-value", children: [
|
|
1564
|
+
/* @__PURE__ */ jsx5(
|
|
1565
|
+
Combobox.Input,
|
|
1566
|
+
{
|
|
1567
|
+
ref: input,
|
|
1568
|
+
id,
|
|
1569
|
+
"aria-label": label,
|
|
1570
|
+
"aria-invalid": invalid,
|
|
1571
|
+
"aria-busy": busy,
|
|
1572
|
+
"aria-describedby": description,
|
|
1573
|
+
"aria-labelledby": labelledBy,
|
|
1574
|
+
"aria-required": required || void 0,
|
|
1575
|
+
className: "mt-select-inline-input",
|
|
1576
|
+
"data-rich-label": showRichLabel || void 0,
|
|
1577
|
+
placeholder: popup.open ? searchPrompt : prompt,
|
|
1578
|
+
onFocus: (event) => {
|
|
1579
|
+
if (!popup.open) event.currentTarget.select();
|
|
1580
|
+
},
|
|
1581
|
+
onCompositionStart: () => {
|
|
1582
|
+
composingRef.current = true;
|
|
1583
|
+
},
|
|
1584
|
+
onCompositionEnd: () => {
|
|
1585
|
+
composingRef.current = false;
|
|
1586
|
+
},
|
|
1587
|
+
onKeyDown: (event) => {
|
|
1588
|
+
const composing = composingRef.current || event.nativeEvent.isComposing;
|
|
1589
|
+
if ((event.key === "Enter" || event.key === "Escape") && (composing || event.nativeEvent.keyCode === 229)) {
|
|
1590
|
+
event.preventBaseUIHandler();
|
|
1591
|
+
if (!composing) event.preventDefault();
|
|
1592
|
+
return;
|
|
1593
|
+
}
|
|
1594
|
+
if (event.key === "Enter") {
|
|
1595
|
+
event.preventDefault();
|
|
1596
|
+
if (!popup.open) {
|
|
1597
|
+
event.preventBaseUIHandler();
|
|
1598
|
+
popup.change(true);
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
),
|
|
1604
|
+
showRichLabel && /* @__PURE__ */ jsx5("span", { id: richLabelId, className: "mt-select-value mt-select-rich-label", "aria-hidden": "true", children: selectedLabel })
|
|
1605
|
+
] }),
|
|
1606
|
+
/* @__PURE__ */ jsxs4("span", { className: "mt-select-action-slot mt-select-inline-action", children: [
|
|
1607
|
+
/* @__PURE__ */ jsx5(
|
|
1608
|
+
Combobox.Trigger,
|
|
1609
|
+
{
|
|
1610
|
+
className: "mt-select-icon mt-select-inline-trigger",
|
|
1611
|
+
tabIndex: -1,
|
|
1612
|
+
"aria-label": locale === "zh" ? "\u5C55\u5F00\u9009\u9879" : "Show options",
|
|
1613
|
+
children: /* @__PURE__ */ jsx5(ChevronDown, { size: 16, "aria-hidden": "true" })
|
|
1614
|
+
}
|
|
1615
|
+
),
|
|
1616
|
+
clearable && !disabled && selection.value !== null && /* @__PURE__ */ jsx5(
|
|
1617
|
+
Combobox.Clear,
|
|
1618
|
+
{
|
|
1619
|
+
className: "mt-select-clear",
|
|
1620
|
+
tabIndex: popup.open ? -1 : 0,
|
|
1621
|
+
"aria-label": locale === "zh" ? "\u6E05\u9664\u9009\u62E9" : "Clear selection",
|
|
1622
|
+
children: /* @__PURE__ */ jsx5(X2, { size: 14, "aria-hidden": "true" })
|
|
1623
|
+
}
|
|
1624
|
+
)
|
|
1625
|
+
] })
|
|
1626
|
+
]
|
|
1627
|
+
}
|
|
1628
|
+
),
|
|
1629
|
+
/* @__PURE__ */ jsx5(
|
|
1630
|
+
ComboboxPopup,
|
|
1631
|
+
{
|
|
1632
|
+
data,
|
|
1633
|
+
empty: emptyContent ?? (locale === "zh" ? "\u65E0\u5339\u914D\u7ED3\u679C" : "No results"),
|
|
1634
|
+
popupRef,
|
|
1635
|
+
label,
|
|
1636
|
+
searchable: true,
|
|
1637
|
+
renderOption
|
|
1638
|
+
}
|
|
1639
|
+
)
|
|
1640
|
+
]
|
|
1641
|
+
}
|
|
1642
|
+
);
|
|
1643
|
+
}
|
|
1644
|
+
function SelectPopupSearch({
|
|
1645
|
+
options,
|
|
1646
|
+
renderOption,
|
|
1647
|
+
trigger,
|
|
1648
|
+
popupWidth = 320,
|
|
1649
|
+
popupTitle,
|
|
1650
|
+
searchPlaceholder,
|
|
1651
|
+
clearable,
|
|
1652
|
+
emptyContent,
|
|
1653
|
+
placeholder,
|
|
1654
|
+
className,
|
|
1655
|
+
name,
|
|
1656
|
+
form,
|
|
1657
|
+
label,
|
|
1658
|
+
id,
|
|
1659
|
+
onBlur,
|
|
1660
|
+
required,
|
|
1661
|
+
"aria-invalid": invalid,
|
|
1662
|
+
"aria-busy": busy,
|
|
1663
|
+
"aria-describedby": describedBy,
|
|
1664
|
+
"aria-labelledby": labelledBy,
|
|
1665
|
+
...props
|
|
1666
|
+
}) {
|
|
1667
|
+
const { locale } = useMtone();
|
|
1668
|
+
const disabled = useFieldsetDisabled(props.disabled);
|
|
1669
|
+
const popup = useSelectPopup(props, disabled);
|
|
1670
|
+
const [draft, setDraft] = React7.useState("");
|
|
1671
|
+
const search = React7.useRef(null);
|
|
1672
|
+
const triggerRef = React7.useRef(null);
|
|
1673
|
+
const popupRef = React7.useRef(null);
|
|
1674
|
+
const surface = React7.useRef(null);
|
|
1675
|
+
const composingRef = React7.useRef(false);
|
|
1676
|
+
const headingId = React7.useId();
|
|
1677
|
+
const reset = React7.useCallback(() => {
|
|
1678
|
+
popup.reset();
|
|
1679
|
+
setDraft("");
|
|
1680
|
+
}, [popup.reset]);
|
|
1681
|
+
const selection = useSelection({ ...props, form }, null, reset);
|
|
1682
|
+
const data = useOptions(options);
|
|
1683
|
+
const searchName = locale === "zh" ? "\u641C\u7D22\u9009\u9879" : "Search options";
|
|
1684
|
+
const prompt = placeholder ?? (locale === "zh" ? "\u8BF7\u9009\u62E9" : "Select\u2026");
|
|
1685
|
+
const title = popupTitle ?? (label ?? (locale === "zh" ? "\u9009\u62E9\u9009\u9879" : "Choose an option"));
|
|
1686
|
+
const selectedLabel = selection.value === null ? prompt : data.byValue.get(selection.value)?.label ?? selection.value;
|
|
1687
|
+
const renderTrigger = typeof trigger === "string" ? /* @__PURE__ */ jsx5(Button, { preset: "dropdown", children: trigger }) : trigger;
|
|
1688
|
+
const clear = clearable && !disabled && selection.value !== null && /* @__PURE__ */ jsx5(
|
|
1689
|
+
ClearSelection,
|
|
1690
|
+
{
|
|
1691
|
+
locale,
|
|
1692
|
+
focus: () => triggerRef.current?.focus(),
|
|
1693
|
+
clear: () => selection.change(null),
|
|
1694
|
+
className: renderTrigger ? "mt-select-popup-custom-clear" : void 0
|
|
1695
|
+
}
|
|
1696
|
+
);
|
|
1697
|
+
const handleBlur = (event) => {
|
|
1698
|
+
if (surface.current?.contains(event.relatedTarget) || popupRef.current?.contains(event.relatedTarget)) return;
|
|
1699
|
+
onBlur?.(event);
|
|
1700
|
+
};
|
|
1701
|
+
React7.useEffect(() => {
|
|
1702
|
+
if (!popup.open) {
|
|
1703
|
+
composingRef.current = false;
|
|
1704
|
+
setDraft("");
|
|
1705
|
+
}
|
|
1706
|
+
}, [popup.open]);
|
|
1707
|
+
return /* @__PURE__ */ jsxs4(
|
|
1708
|
+
Combobox.Root,
|
|
1709
|
+
{
|
|
1710
|
+
items: data.comboItems,
|
|
1711
|
+
inputValue: draft,
|
|
1712
|
+
itemToStringLabel: (value) => optionText(data.byValue.get(value), value),
|
|
1713
|
+
autoHighlight: true,
|
|
1714
|
+
value: selection.value,
|
|
1715
|
+
inputRef: selection.inputRef,
|
|
1716
|
+
name,
|
|
1717
|
+
form,
|
|
1718
|
+
disabled,
|
|
1719
|
+
required: required && selection.value !== "",
|
|
1720
|
+
open: popup.open,
|
|
1721
|
+
onOpenChange: popup.change,
|
|
1722
|
+
onInputValueChange: (next, details) => {
|
|
1723
|
+
if (details.reason === "input-change") setDraft(next);
|
|
1724
|
+
},
|
|
1725
|
+
onValueChange: (next, details) => {
|
|
1726
|
+
if (composingRef.current || next === null || data.byValue.get(next)?.disabled) {
|
|
1727
|
+
details.cancel();
|
|
1728
|
+
return;
|
|
1729
|
+
}
|
|
1730
|
+
if (next !== selection.value) selection.change(next);
|
|
1731
|
+
},
|
|
1732
|
+
children: [
|
|
1733
|
+
/* @__PURE__ */ jsxs4(
|
|
1734
|
+
"span",
|
|
1735
|
+
{
|
|
1736
|
+
ref: surface,
|
|
1737
|
+
onBlur: handleBlur,
|
|
1738
|
+
className: cn(renderTrigger ? "mt-select-popup-trigger-wrap" : clearable ? "mt-select-clearable" : void 0),
|
|
1739
|
+
children: [
|
|
1740
|
+
/* @__PURE__ */ jsx5(
|
|
1741
|
+
Combobox.Trigger,
|
|
1742
|
+
{
|
|
1743
|
+
render: renderTrigger,
|
|
1744
|
+
ref: triggerRef,
|
|
1745
|
+
id,
|
|
1746
|
+
role: "button",
|
|
1747
|
+
"aria-label": label,
|
|
1748
|
+
"aria-invalid": invalid,
|
|
1749
|
+
"aria-busy": busy,
|
|
1750
|
+
"aria-describedby": describedBy,
|
|
1751
|
+
"aria-labelledby": labelledBy,
|
|
1752
|
+
"aria-required": void 0,
|
|
1753
|
+
className: cn(!renderTrigger && "mt-select", className),
|
|
1754
|
+
children: !renderTrigger && /* @__PURE__ */ jsxs4(Fragment4, { children: [
|
|
1755
|
+
/* @__PURE__ */ jsx5("span", { className: "mt-select-value", children: selectedLabel }),
|
|
1756
|
+
/* @__PURE__ */ jsx5(Combobox.Icon, { className: "mt-select-icon", children: /* @__PURE__ */ jsx5(ChevronDown, { size: 16, "aria-hidden": "true" }) })
|
|
1757
|
+
] })
|
|
1758
|
+
}
|
|
1759
|
+
),
|
|
1760
|
+
clear
|
|
1761
|
+
]
|
|
1762
|
+
}
|
|
1763
|
+
),
|
|
1764
|
+
/* @__PURE__ */ jsx5(
|
|
1765
|
+
ComboboxPopup,
|
|
1766
|
+
{
|
|
1767
|
+
data,
|
|
1768
|
+
empty: emptyContent ?? (locale === "zh" ? "\u65E0\u5339\u914D\u7ED3\u679C" : "No results"),
|
|
1769
|
+
popupRef,
|
|
1770
|
+
label,
|
|
1771
|
+
renderOption,
|
|
1772
|
+
searchPanel: { width: popupWidth, titleId: headingId, initialFocus: search, content: /* @__PURE__ */ jsxs4(Fragment4, { children: [
|
|
1773
|
+
/* @__PURE__ */ jsx5("h2", { id: headingId, className: "mt-popup-title", children: title }),
|
|
1774
|
+
/* @__PURE__ */ jsx5(
|
|
1775
|
+
Combobox.Input,
|
|
1776
|
+
{
|
|
1777
|
+
ref: search,
|
|
1778
|
+
"aria-label": searchName,
|
|
1779
|
+
autoComplete: "off",
|
|
1780
|
+
placeholder: searchPlaceholder ?? searchName,
|
|
1781
|
+
render: /* @__PURE__ */ jsx5(Input.Search, {}),
|
|
1782
|
+
onBlur: handleBlur,
|
|
1783
|
+
onCompositionStart: () => {
|
|
1784
|
+
composingRef.current = true;
|
|
1785
|
+
},
|
|
1786
|
+
onCompositionEnd: () => {
|
|
1787
|
+
composingRef.current = false;
|
|
1788
|
+
},
|
|
1789
|
+
onKeyDown: (event) => {
|
|
1790
|
+
const composing = composingRef.current || event.nativeEvent.isComposing;
|
|
1791
|
+
if ((event.key === "Enter" || event.key === "Escape") && (composing || event.nativeEvent.keyCode === 229)) {
|
|
1792
|
+
event.preventBaseUIHandler();
|
|
1793
|
+
if (!composing) event.preventDefault();
|
|
1794
|
+
} else if (event.key === "Enter") {
|
|
1795
|
+
event.preventDefault();
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
)
|
|
1800
|
+
] }) }
|
|
1801
|
+
}
|
|
1802
|
+
)
|
|
1803
|
+
]
|
|
1804
|
+
}
|
|
1805
|
+
);
|
|
1806
|
+
}
|
|
1807
|
+
function ComboboxPopup({ data, empty, popupRef, label, searchable, renderOption, searchPanel, createOption }) {
|
|
1808
|
+
const item = (value) => {
|
|
1809
|
+
const option = data.byValue.get(value);
|
|
1810
|
+
const row = option && renderOption ? renderOption(option) : option?.label ?? (value === createOption?.value ? createOption.label : value);
|
|
1811
|
+
const indicator = /* @__PURE__ */ jsx5(Combobox.ItemIndicator, { className: "mt-select-item-indicator", "aria-hidden": "true", children: marker });
|
|
1812
|
+
return /* @__PURE__ */ jsxs4(Combobox.Item, { className: "mt-option", value, disabled: option?.disabled, children: [
|
|
1813
|
+
searchPanel && /* @__PURE__ */ jsx5("span", { className: "mt-select-popup-check-slot", "aria-hidden": "true", children: indicator }),
|
|
1814
|
+
/* @__PURE__ */ jsx5("span", { className: "mt-select-option-label", children: row }),
|
|
1815
|
+
!searchPanel && indicator
|
|
1816
|
+
] }, value);
|
|
1817
|
+
};
|
|
1818
|
+
const width = searchPanel?.width;
|
|
1819
|
+
const list = /* @__PURE__ */ jsxs4(Fragment4, { children: [
|
|
1820
|
+
/* @__PURE__ */ jsx5(Combobox.Empty, { className: "mt-combobox-empty", children: empty }),
|
|
1821
|
+
/* @__PURE__ */ jsx5(Combobox.List, { className: searchPanel ? "mt-select-popup-search-list" : void 0, "aria-label": label, children: (entry) => {
|
|
1822
|
+
if (typeof entry === "string") return item(entry);
|
|
1823
|
+
if (!entry.section.grouped) {
|
|
1824
|
+
return /* @__PURE__ */ jsx5(Combobox.Group, { items: entry.items, role: "presentation", children: /* @__PURE__ */ jsx5(Combobox.Collection, { children: item }) }, entry.index);
|
|
1825
|
+
}
|
|
1826
|
+
return /* @__PURE__ */ jsxs4(Combobox.Group, { items: entry.items, children: [
|
|
1827
|
+
/* @__PURE__ */ jsx5(Combobox.GroupLabel, { className: "mt-select-group-label", children: entry.section.label }),
|
|
1828
|
+
/* @__PURE__ */ jsx5(Combobox.Collection, { children: item })
|
|
1829
|
+
] }, entry.index);
|
|
1830
|
+
} })
|
|
1831
|
+
] });
|
|
1832
|
+
return /* @__PURE__ */ jsx5(Combobox.Portal, { children: /* @__PURE__ */ jsx5(MtoneScope, { children: /* @__PURE__ */ jsx5(Combobox.Positioner, { className: "mt-positioner", sideOffset: 4, align: searchPanel ? "start" : void 0, children: /* @__PURE__ */ jsx5(
|
|
1833
|
+
Combobox.Popup,
|
|
1834
|
+
{
|
|
1835
|
+
ref: popupRef,
|
|
1836
|
+
className: cn("mt-popup", searchable && "mt-select-inline-popup", searchPanel && "mt-select-popup-search"),
|
|
1837
|
+
"aria-labelledby": searchPanel?.titleId,
|
|
1838
|
+
initialFocus: searchPanel?.initialFocus,
|
|
1839
|
+
style: width === void 0 ? void 0 : { "--mt-select-popup-search-width": typeof width === "number" ? `${width}px` : width },
|
|
1840
|
+
children: searchPanel ? /* @__PURE__ */ jsxs4(Fragment4, { children: [
|
|
1841
|
+
searchPanel.content,
|
|
1842
|
+
/* @__PURE__ */ jsx5("div", { className: "mt-select-popup-search-body", children: list })
|
|
1843
|
+
] }) : list
|
|
1844
|
+
}
|
|
1845
|
+
) }) }) });
|
|
1846
|
+
}
|
|
1847
|
+
function SelectMultiple({
|
|
1848
|
+
mode,
|
|
1849
|
+
options,
|
|
1850
|
+
clearable,
|
|
1851
|
+
emptyContent,
|
|
1852
|
+
renderOption,
|
|
1853
|
+
placeholder,
|
|
1854
|
+
className,
|
|
1855
|
+
name,
|
|
1856
|
+
form,
|
|
1857
|
+
label,
|
|
1858
|
+
id,
|
|
1859
|
+
onBlur,
|
|
1860
|
+
required,
|
|
1861
|
+
"aria-invalid": invalid,
|
|
1862
|
+
"aria-busy": busy,
|
|
1863
|
+
"aria-describedby": describedBy,
|
|
1864
|
+
"aria-labelledby": labelledBy,
|
|
1865
|
+
...props
|
|
1866
|
+
}) {
|
|
1867
|
+
const tags = mode === "tags";
|
|
1868
|
+
const { locale } = useMtone();
|
|
1869
|
+
const disabled = useFieldsetDisabled(props.disabled);
|
|
1870
|
+
const popup = useSelectPopup(props, disabled);
|
|
1871
|
+
const [inputValue, setInputValue] = React7.useState("");
|
|
1872
|
+
const [composing, setComposing] = React7.useState(false);
|
|
1873
|
+
const composingRef = React7.useRef(false);
|
|
1874
|
+
const resetPopup = React7.useCallback(() => {
|
|
1875
|
+
popup.reset();
|
|
1876
|
+
setInputValue("");
|
|
1877
|
+
}, [popup.reset]);
|
|
1878
|
+
const selection = useSelection({ ...props, form }, noValues, tags ? resetPopup : popup.reset);
|
|
1879
|
+
const optionData = useOptions(options);
|
|
1880
|
+
const draft = tags ? inputValue.trim() : "";
|
|
1881
|
+
const exactValues = React7.useMemo(() => {
|
|
1882
|
+
const values2 = /* @__PURE__ */ new Set();
|
|
1883
|
+
if (!draft) return values2;
|
|
1884
|
+
for (const option of optionData.items) {
|
|
1885
|
+
if (option.value === draft || (typeof option.label === "string" || typeof option.label === "number") && String(option.label).trim() === draft) {
|
|
1886
|
+
values2.add(option.value);
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
return values2;
|
|
1890
|
+
}, [draft, optionData]);
|
|
1891
|
+
const createValue = draft && !composing && !exactValues.size && !selection.value.includes(draft) ? draft : void 0;
|
|
1892
|
+
const items = React7.useMemo(() => {
|
|
1893
|
+
if (createValue === void 0) return optionData.comboItems;
|
|
1894
|
+
if (optionData.sections.some((section) => section.grouped)) {
|
|
1895
|
+
const section = { items: [], grouped: false };
|
|
1896
|
+
const createGroup = { items: [createValue], section, index: -1 };
|
|
1897
|
+
return [createGroup, ...optionData.comboItems];
|
|
1898
|
+
}
|
|
1899
|
+
return [createValue, ...optionData.comboItems];
|
|
1900
|
+
}, [optionData, createValue]);
|
|
1901
|
+
const { contains: contains2 } = Combobox.useFilter({ multiple: true });
|
|
1902
|
+
const tagsFilter = (value, query, getLabel) => {
|
|
1903
|
+
const trimmed = query.trim();
|
|
1904
|
+
if (trimmed && trimmed === draft && exactValues.size) return exactValues.has(value);
|
|
1905
|
+
return value === createValue || contains2(value, query, getLabel);
|
|
1906
|
+
};
|
|
1907
|
+
const locked = selection.value.filter((value) => optionData.byValue.get(value)?.disabled);
|
|
1908
|
+
const labelFor = (value) => optionText(optionData.byValue.get(value), value);
|
|
1909
|
+
return /* @__PURE__ */ jsxs4(
|
|
1910
|
+
Combobox.Root,
|
|
1911
|
+
{
|
|
1912
|
+
multiple: true,
|
|
1913
|
+
items,
|
|
1914
|
+
itemToStringLabel: labelFor,
|
|
1915
|
+
...tags ? { inputValue, onInputValueChange: setInputValue, filter: tagsFilter, autoHighlight: true } : {},
|
|
1916
|
+
value: selection.value,
|
|
1917
|
+
inputRef: selection.inputRef,
|
|
1918
|
+
name,
|
|
1919
|
+
form,
|
|
1920
|
+
disabled,
|
|
1921
|
+
required,
|
|
1922
|
+
onValueChange: (next, details) => {
|
|
1923
|
+
if (tags && details.reason === "item-press") {
|
|
1924
|
+
const event = details.event;
|
|
1925
|
+
const repeat = "key" in event && event.key === "Enter" && selection.value.some((value) => exactValues.has(value) && !next.includes(value));
|
|
1926
|
+
if (composingRef.current || repeat) {
|
|
1927
|
+
details.cancel();
|
|
1928
|
+
return;
|
|
1929
|
+
}
|
|
1930
|
+
setInputValue("");
|
|
1931
|
+
}
|
|
1932
|
+
if (details.reason === "clear-press") {
|
|
1933
|
+
if (locked.length < selection.value.length) selection.change(locked);
|
|
1934
|
+
} else if (locked.some((value) => !next.includes(value))) {
|
|
1935
|
+
details.cancel();
|
|
1936
|
+
} else selection.change(next);
|
|
1937
|
+
},
|
|
1938
|
+
open: popup.open,
|
|
1939
|
+
onOpenChange: popup.change,
|
|
1940
|
+
children: [
|
|
1941
|
+
/* @__PURE__ */ jsxs4(Combobox.Chips, { "aria-invalid": invalid, className: cn("mt-multiselect", className), children: [
|
|
1942
|
+
selection.value.map((value) => {
|
|
1943
|
+
const option = optionData.byValue.get(value);
|
|
1944
|
+
return /* @__PURE__ */ jsxs4(Combobox.Chip, { className: "mt-chip", children: [
|
|
1945
|
+
/* @__PURE__ */ jsx5("span", { children: option?.label ?? value }),
|
|
1946
|
+
!option?.disabled && /* @__PURE__ */ jsx5(
|
|
1947
|
+
Combobox.ChipRemove,
|
|
1948
|
+
{
|
|
1949
|
+
"aria-label": `${locale === "zh" ? "\u79FB\u9664" : "Remove"} ${labelFor(value)}`,
|
|
1950
|
+
className: "mt-chip-remove",
|
|
1951
|
+
children: "\xD7"
|
|
1952
|
+
}
|
|
1953
|
+
)
|
|
1954
|
+
] }, value);
|
|
1955
|
+
}),
|
|
1956
|
+
/* @__PURE__ */ jsx5(
|
|
1957
|
+
Combobox.Input,
|
|
1958
|
+
{
|
|
1959
|
+
id,
|
|
1960
|
+
onBlur,
|
|
1961
|
+
...tags ? {
|
|
1962
|
+
onCompositionStart: () => {
|
|
1963
|
+
composingRef.current = true;
|
|
1964
|
+
setComposing(true);
|
|
1965
|
+
},
|
|
1966
|
+
onCompositionEnd: () => {
|
|
1967
|
+
composingRef.current = false;
|
|
1968
|
+
setComposing(false);
|
|
1969
|
+
}
|
|
1970
|
+
} : {},
|
|
1971
|
+
onKeyDown: tags ? (event) => {
|
|
1972
|
+
if (event.key !== "Enter") return;
|
|
1973
|
+
if (composingRef.current || event.nativeEvent.isComposing || event.nativeEvent.keyCode === 229) {
|
|
1974
|
+
event.preventBaseUIHandler();
|
|
1975
|
+
} else if (inputValue && (popup.open || !draft)) {
|
|
1976
|
+
event.preventDefault();
|
|
1977
|
+
if (!draft || !exactValues.size && selection.value.includes(draft)) event.preventBaseUIHandler();
|
|
1978
|
+
}
|
|
1979
|
+
} : void 0,
|
|
1980
|
+
"aria-invalid": invalid,
|
|
1981
|
+
"aria-describedby": describedBy,
|
|
1982
|
+
"aria-labelledby": labelledBy,
|
|
1983
|
+
"aria-busy": busy,
|
|
1984
|
+
"aria-label": label,
|
|
1985
|
+
"aria-required": required || void 0,
|
|
1986
|
+
placeholder: placeholder ?? (tags ? locale === "zh" ? "\u641C\u7D22\u6216\u521B\u5EFA\u6807\u7B7E\u2026" : "Search or create tags\u2026" : locale === "zh" ? "\u641C\u7D22\u2026" : "Search\u2026"),
|
|
1987
|
+
className: "mt-combobox-input"
|
|
1988
|
+
}
|
|
1989
|
+
),
|
|
1990
|
+
/* @__PURE__ */ jsxs4("span", { className: "mt-select-action-slot", children: [
|
|
1991
|
+
clearable && !disabled && locked.length < selection.value.length && /* @__PURE__ */ jsx5(
|
|
1992
|
+
Combobox.Clear,
|
|
1993
|
+
{
|
|
1994
|
+
className: "mt-select-clear",
|
|
1995
|
+
tabIndex: popup.open ? -1 : 0,
|
|
1996
|
+
"aria-label": locale === "zh" ? "\u6E05\u9664\u9009\u62E9" : "Clear selection",
|
|
1997
|
+
children: /* @__PURE__ */ jsx5(X2, { size: 14, "aria-hidden": "true" })
|
|
1998
|
+
}
|
|
1999
|
+
),
|
|
2000
|
+
/* @__PURE__ */ jsx5(Combobox.Trigger, { className: "mt-combobox-trigger", "aria-label": locale === "zh" ? "\u5C55\u5F00\u9009\u9879" : "Show options", children: /* @__PURE__ */ jsx5(ChevronDown, { size: 16, "aria-hidden": "true" }) })
|
|
2001
|
+
] })
|
|
2002
|
+
] }),
|
|
2003
|
+
/* @__PURE__ */ jsx5(
|
|
2004
|
+
ComboboxPopup,
|
|
2005
|
+
{
|
|
2006
|
+
data: optionData,
|
|
2007
|
+
renderOption,
|
|
2008
|
+
empty: emptyContent ?? (locale === "zh" ? "\u65E0\u5339\u914D\u7ED3\u679C" : "No results"),
|
|
2009
|
+
createOption: createValue === void 0 ? void 0 : {
|
|
2010
|
+
value: createValue,
|
|
2011
|
+
label: locale === "zh" ? `\u521B\u5EFA\u201C${createValue}\u201D` : `Create \u201C${createValue}\u201D`
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
)
|
|
2015
|
+
]
|
|
2016
|
+
}
|
|
2017
|
+
);
|
|
2018
|
+
}
|
|
2019
|
+
function Select(props) {
|
|
2020
|
+
if (props.mode === "multiple" || props.mode === "tags") return /* @__PURE__ */ jsx5(SelectMultiple, { ...props });
|
|
2021
|
+
if (props.searchable === "popup") return /* @__PURE__ */ jsx5(SelectPopupSearch, { ...props });
|
|
2022
|
+
return props.searchable ? /* @__PURE__ */ jsx5(SelectSearchable, { ...props }) : /* @__PURE__ */ jsx5(SelectSingle, { ...props });
|
|
2023
|
+
}
|
|
2024
|
+
Select.formValueType = (props) => props.mode === "multiple" || props.mode === "tags" ? "array" : "select-single";
|
|
2025
|
+
function MultiSelect(props) {
|
|
2026
|
+
return /* @__PURE__ */ jsx5(Select, { ...props, mode: "multiple" });
|
|
2027
|
+
}
|
|
2028
|
+
MultiSelect.formValueType = "array";
|
|
2029
|
+
|
|
2030
|
+
// src/tabs.tsx
|
|
2031
|
+
import React8, { useEffect as useEffect4, useRef as useRef4, useState as useState4 } from "react";
|
|
2032
|
+
import {
|
|
2033
|
+
DirectionProvider,
|
|
2034
|
+
useDirection as useDirection2
|
|
2035
|
+
} from "@base-ui/react/direction-provider";
|
|
2036
|
+
import { Tabs as BTabs } from "@base-ui/react/tabs";
|
|
2037
|
+
import { Menu } from "@base-ui/react/menu";
|
|
2038
|
+
import { Plus, X as X3, Ellipsis } from "lucide-react";
|
|
2039
|
+
|
|
2040
|
+
// src/accent-colors.ts
|
|
2041
|
+
var accentNames = ["neutral", "blue", "green", "orange", "red", "purple", "teal", "coral"];
|
|
2042
|
+
function resolveAccentColor(color) {
|
|
2043
|
+
return accentNames.includes(color) ? `var(--mt-accent-${color})` : color;
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
// src/tabs.tsx
|
|
2047
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2048
|
+
var Tabs = React8.forwardRef(function Tabs2({
|
|
2049
|
+
items,
|
|
2050
|
+
value,
|
|
2051
|
+
defaultValue,
|
|
2052
|
+
onValueChange,
|
|
2053
|
+
label,
|
|
2054
|
+
placement = "top",
|
|
2055
|
+
variant = "line",
|
|
2056
|
+
size = "medium",
|
|
2057
|
+
indicatorColor,
|
|
2058
|
+
centered = false,
|
|
2059
|
+
gap,
|
|
2060
|
+
extraStart,
|
|
2061
|
+
extraEnd,
|
|
2062
|
+
activateOnFocus = false,
|
|
2063
|
+
destroyOnHidden = true,
|
|
2064
|
+
hideAdd = false,
|
|
2065
|
+
addIcon,
|
|
2066
|
+
addLabel,
|
|
2067
|
+
moreLabel,
|
|
2068
|
+
onEdit,
|
|
2069
|
+
onTabClick,
|
|
2070
|
+
reorderable = false,
|
|
2071
|
+
onOrderChange,
|
|
2072
|
+
className,
|
|
2073
|
+
style,
|
|
2074
|
+
...props
|
|
2075
|
+
}, ref) {
|
|
2076
|
+
const { locale } = useMtone();
|
|
2077
|
+
const zh = locale === "zh";
|
|
2078
|
+
const inheritedDirection = useDirection2();
|
|
2079
|
+
const direction = props.dir === "rtl" || props.dir === "ltr" ? props.dir : inheritedDirection;
|
|
2080
|
+
const [internal, setInternal] = useState4(
|
|
2081
|
+
() => defaultValue ?? items.find((i) => !i.disabled)?.value ?? null
|
|
2082
|
+
);
|
|
2083
|
+
const controlled = value !== void 0;
|
|
2084
|
+
const selected = controlled ? value : internal;
|
|
2085
|
+
const [visited, setVisited] = useState4(
|
|
2086
|
+
() => new Set(selected == null ? [] : [selected])
|
|
1464
2087
|
);
|
|
1465
2088
|
const listRef = useRef4(null);
|
|
1466
2089
|
const [overflow, setOverflow] = useState4(false);
|
|
@@ -1662,7 +2285,7 @@ var Tabs = React8.forwardRef(function Tabs2({
|
|
|
1662
2285
|
disabled: item.disabled || !onEdit,
|
|
1663
2286
|
"aria-label": item.closeLabel ?? `${zh ? "\u5173\u95ED" : "Close"} ${typeof item.label === "string" ? item.label : item.value}`,
|
|
1664
2287
|
onClick: () => requestRemove(item),
|
|
1665
|
-
children: /* @__PURE__ */ jsx6(
|
|
2288
|
+
children: /* @__PURE__ */ jsx6(X3, { size: 12, "aria-hidden": "true" })
|
|
1666
2289
|
}
|
|
1667
2290
|
)
|
|
1668
2291
|
]
|
|
@@ -1897,21 +2520,7 @@ function ToastProvider({
|
|
|
1897
2520
|
}
|
|
1898
2521
|
|
|
1899
2522
|
// src/interactive.tsx
|
|
1900
|
-
import { Fragment as
|
|
1901
|
-
function useFieldsetOpen(props) {
|
|
1902
|
-
const [localOpen, setLocalOpen] = React9.useState(props.defaultOpen ?? false);
|
|
1903
|
-
React9.useEffect(() => {
|
|
1904
|
-
if (props.disabled) setLocalOpen(false);
|
|
1905
|
-
}, [props.disabled]);
|
|
1906
|
-
return {
|
|
1907
|
-
open: !props.disabled && (props.open ?? localOpen),
|
|
1908
|
-
onOpenChange: (next) => {
|
|
1909
|
-
if (next && props.disabled) return;
|
|
1910
|
-
if (props.open === void 0) setLocalOpen(next);
|
|
1911
|
-
props.onOpenChange?.(next);
|
|
1912
|
-
}
|
|
1913
|
-
};
|
|
1914
|
-
}
|
|
2523
|
+
import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1915
2524
|
function Checkbox({
|
|
1916
2525
|
label,
|
|
1917
2526
|
children,
|
|
@@ -1971,174 +2580,6 @@ function RadioGroup({
|
|
|
1971
2580
|
}
|
|
1972
2581
|
);
|
|
1973
2582
|
}
|
|
1974
|
-
function Select({
|
|
1975
|
-
options,
|
|
1976
|
-
label,
|
|
1977
|
-
placeholder,
|
|
1978
|
-
className,
|
|
1979
|
-
id,
|
|
1980
|
-
onBlur,
|
|
1981
|
-
"aria-invalid": invalid,
|
|
1982
|
-
"aria-describedby": describedBy,
|
|
1983
|
-
"aria-labelledby": labelledBy,
|
|
1984
|
-
"aria-busy": busy,
|
|
1985
|
-
...props
|
|
1986
|
-
}) {
|
|
1987
|
-
props = { ...props, disabled: useFieldsetDisabled(props.disabled) };
|
|
1988
|
-
const popup = useFieldsetOpen(props);
|
|
1989
|
-
const { locale } = useMtone();
|
|
1990
|
-
return /* @__PURE__ */ jsxs7(BSelect.Root, { items: options, ...props, ...popup, children: [
|
|
1991
|
-
/* @__PURE__ */ jsxs7(
|
|
1992
|
-
BSelect.Trigger,
|
|
1993
|
-
{
|
|
1994
|
-
id,
|
|
1995
|
-
onBlur,
|
|
1996
|
-
"aria-invalid": invalid,
|
|
1997
|
-
"aria-describedby": describedBy,
|
|
1998
|
-
"aria-labelledby": labelledBy,
|
|
1999
|
-
"aria-busy": busy,
|
|
2000
|
-
"aria-label": label,
|
|
2001
|
-
className: cn("mt-select", className),
|
|
2002
|
-
children: [
|
|
2003
|
-
/* @__PURE__ */ jsx8(
|
|
2004
|
-
BSelect.Value,
|
|
2005
|
-
{
|
|
2006
|
-
className: "mt-select-value",
|
|
2007
|
-
placeholder: placeholder ?? (locale === "zh" ? "\u8BF7\u9009\u62E9" : "Select\u2026")
|
|
2008
|
-
}
|
|
2009
|
-
),
|
|
2010
|
-
/* @__PURE__ */ jsx8(BSelect.Icon, { className: "mt-select-icon", children: /* @__PURE__ */ jsx8(ChevronDown, { size: 16, "aria-hidden": "true" }) })
|
|
2011
|
-
]
|
|
2012
|
-
}
|
|
2013
|
-
),
|
|
2014
|
-
/* @__PURE__ */ jsx8(BSelect.Portal, { children: /* @__PURE__ */ jsx8(MtoneScope, { children: /* @__PURE__ */ jsx8(
|
|
2015
|
-
BSelect.Positioner,
|
|
2016
|
-
{
|
|
2017
|
-
className: "mt-positioner",
|
|
2018
|
-
sideOffset: 4,
|
|
2019
|
-
alignItemWithTrigger: false,
|
|
2020
|
-
children: /* @__PURE__ */ jsx8(BSelect.Popup, { className: "mt-popup", children: /* @__PURE__ */ jsx8(BSelect.List, { children: options.map((o) => /* @__PURE__ */ jsxs7(
|
|
2021
|
-
BSelect.Item,
|
|
2022
|
-
{
|
|
2023
|
-
className: "mt-option",
|
|
2024
|
-
value: o.value,
|
|
2025
|
-
disabled: o.disabled,
|
|
2026
|
-
children: [
|
|
2027
|
-
/* @__PURE__ */ jsx8(BSelect.ItemText, { children: o.label }),
|
|
2028
|
-
/* @__PURE__ */ jsx8(
|
|
2029
|
-
BSelect.ItemIndicator,
|
|
2030
|
-
{
|
|
2031
|
-
className: "mt-select-item-indicator",
|
|
2032
|
-
"aria-hidden": "true",
|
|
2033
|
-
children: /* @__PURE__ */ jsx8(Check2, { size: 16, strokeWidth: 1.5, "aria-hidden": "true" })
|
|
2034
|
-
}
|
|
2035
|
-
)
|
|
2036
|
-
]
|
|
2037
|
-
},
|
|
2038
|
-
o.value
|
|
2039
|
-
)) }) })
|
|
2040
|
-
}
|
|
2041
|
-
) }) })
|
|
2042
|
-
] });
|
|
2043
|
-
}
|
|
2044
|
-
Select.formValueType = "nullable";
|
|
2045
|
-
function MultiSelect({
|
|
2046
|
-
options,
|
|
2047
|
-
label,
|
|
2048
|
-
placeholder,
|
|
2049
|
-
className,
|
|
2050
|
-
id,
|
|
2051
|
-
onBlur,
|
|
2052
|
-
"aria-invalid": invalid,
|
|
2053
|
-
"aria-describedby": describedBy,
|
|
2054
|
-
"aria-labelledby": labelledBy,
|
|
2055
|
-
"aria-busy": busy,
|
|
2056
|
-
...props
|
|
2057
|
-
}) {
|
|
2058
|
-
props = { ...props, disabled: useFieldsetDisabled(props.disabled) };
|
|
2059
|
-
const popup = useFieldsetOpen(props);
|
|
2060
|
-
const { locale } = useMtone();
|
|
2061
|
-
const values2 = options.map((o) => o.value);
|
|
2062
|
-
const labelFor = (v) => String(options.find((o) => o.value === v)?.label ?? v);
|
|
2063
|
-
return /* @__PURE__ */ jsxs7(
|
|
2064
|
-
Combobox.Root,
|
|
2065
|
-
{
|
|
2066
|
-
multiple: true,
|
|
2067
|
-
items: values2,
|
|
2068
|
-
itemToStringLabel: labelFor,
|
|
2069
|
-
...props,
|
|
2070
|
-
...popup,
|
|
2071
|
-
children: [
|
|
2072
|
-
/* @__PURE__ */ jsxs7(
|
|
2073
|
-
Combobox.Chips,
|
|
2074
|
-
{
|
|
2075
|
-
"aria-invalid": invalid,
|
|
2076
|
-
className: cn("mt-multiselect", className),
|
|
2077
|
-
children: [
|
|
2078
|
-
/* @__PURE__ */ jsx8(Combobox.Value, { children: (selected) => /* @__PURE__ */ jsx8(Fragment4, { children: selected.map((v) => /* @__PURE__ */ jsxs7(Combobox.Chip, { className: "mt-chip", children: [
|
|
2079
|
-
labelFor(v),
|
|
2080
|
-
/* @__PURE__ */ jsx8(
|
|
2081
|
-
Combobox.ChipRemove,
|
|
2082
|
-
{
|
|
2083
|
-
"aria-label": `${locale === "zh" ? "\u79FB\u9664" : "Remove"} ${labelFor(v)}`,
|
|
2084
|
-
className: "mt-chip-remove",
|
|
2085
|
-
children: "\xD7"
|
|
2086
|
-
}
|
|
2087
|
-
)
|
|
2088
|
-
] }, v)) }) }),
|
|
2089
|
-
/* @__PURE__ */ jsx8(
|
|
2090
|
-
Combobox.Input,
|
|
2091
|
-
{
|
|
2092
|
-
id,
|
|
2093
|
-
onBlur,
|
|
2094
|
-
"aria-invalid": invalid,
|
|
2095
|
-
"aria-describedby": describedBy,
|
|
2096
|
-
"aria-labelledby": labelledBy,
|
|
2097
|
-
"aria-busy": busy,
|
|
2098
|
-
"aria-label": label,
|
|
2099
|
-
placeholder: placeholder ?? (locale === "zh" ? "\u641C\u7D22\u2026" : "Search\u2026"),
|
|
2100
|
-
className: "mt-combobox-input"
|
|
2101
|
-
}
|
|
2102
|
-
),
|
|
2103
|
-
/* @__PURE__ */ jsx8(
|
|
2104
|
-
Combobox.Trigger,
|
|
2105
|
-
{
|
|
2106
|
-
className: "mt-combobox-trigger",
|
|
2107
|
-
"aria-label": locale === "zh" ? "\u5C55\u5F00\u9009\u9879" : "Show options",
|
|
2108
|
-
children: /* @__PURE__ */ jsx8(ChevronDown, { size: 16, "aria-hidden": "true" })
|
|
2109
|
-
}
|
|
2110
|
-
)
|
|
2111
|
-
]
|
|
2112
|
-
}
|
|
2113
|
-
),
|
|
2114
|
-
/* @__PURE__ */ jsx8(Combobox.Portal, { children: /* @__PURE__ */ jsx8(MtoneScope, { children: /* @__PURE__ */ jsx8(Combobox.Positioner, { className: "mt-positioner", sideOffset: 4, children: /* @__PURE__ */ jsxs7(Combobox.Popup, { className: "mt-popup", children: [
|
|
2115
|
-
/* @__PURE__ */ jsx8(Combobox.Empty, { className: "mt-combobox-empty", children: locale === "zh" ? "\u65E0\u5339\u914D\u7ED3\u679C" : "No results" }),
|
|
2116
|
-
/* @__PURE__ */ jsx8(Combobox.List, { children: (v) => /* @__PURE__ */ jsxs7(
|
|
2117
|
-
Combobox.Item,
|
|
2118
|
-
{
|
|
2119
|
-
className: "mt-option",
|
|
2120
|
-
value: v,
|
|
2121
|
-
disabled: options.find((o) => o.value === v)?.disabled,
|
|
2122
|
-
children: [
|
|
2123
|
-
labelFor(v),
|
|
2124
|
-
/* @__PURE__ */ jsx8(
|
|
2125
|
-
Combobox.ItemIndicator,
|
|
2126
|
-
{
|
|
2127
|
-
className: "mt-select-item-indicator",
|
|
2128
|
-
"aria-hidden": "true",
|
|
2129
|
-
children: /* @__PURE__ */ jsx8(Check2, { size: 16, strokeWidth: 1.5, "aria-hidden": "true" })
|
|
2130
|
-
}
|
|
2131
|
-
)
|
|
2132
|
-
]
|
|
2133
|
-
},
|
|
2134
|
-
v
|
|
2135
|
-
) })
|
|
2136
|
-
] }) }) }) })
|
|
2137
|
-
]
|
|
2138
|
-
}
|
|
2139
|
-
);
|
|
2140
|
-
}
|
|
2141
|
-
MultiSelect.formValueType = "array";
|
|
2142
2583
|
function Slider({ label, className, ...props }) {
|
|
2143
2584
|
props = { ...props, disabled: useFieldsetDisabled(props.disabled) };
|
|
2144
2585
|
return /* @__PURE__ */ jsx8(BSlider.Root, { className: cn("mt-slider", className), ...props, children: /* @__PURE__ */ jsx8(BSlider.Control, { className: "mt-slider-control", children: /* @__PURE__ */ jsxs7(BSlider.Track, { className: "mt-slider-track", children: [
|
|
@@ -2338,7 +2779,7 @@ function InlineSubmenu({
|
|
|
2338
2779
|
}
|
|
2339
2780
|
function MenuItems({ items, onSelect }) {
|
|
2340
2781
|
const inline = React9.useContext(InlineMenuContext);
|
|
2341
|
-
return /* @__PURE__ */ jsx8(
|
|
2782
|
+
return /* @__PURE__ */ jsx8(Fragment5, { children: items.map((item, index) => {
|
|
2342
2783
|
if (item.type === "divider")
|
|
2343
2784
|
return inline ? /* @__PURE__ */ jsx8("hr", { className: "mt-menu-divider" }, item.key) : /* @__PURE__ */ jsx8(BMenu2.Separator, { className: "mt-menu-divider" }, item.key);
|
|
2344
2785
|
if (item.type === "group")
|
|
@@ -2735,84 +3176,30 @@ function PopoverFrame({
|
|
|
2735
3176
|
const { locale } = useMtone();
|
|
2736
3177
|
const hasTitle = title != null && title !== false && title !== "";
|
|
2737
3178
|
const popupLabel = label ?? (hasTitle ? void 0 : locale === "zh" ? "\u6D6E\u5C42\u5185\u5BB9" : "Popover content");
|
|
2738
|
-
const triggerElement = typeof trigger === "string" ? /* @__PURE__ */ jsx8(Button, { preset: "dropdown", style: { width: "fit-content", maxWidth: "100%" }, children: trigger }) : trigger;
|
|
2739
|
-
return /* @__PURE__ */ jsxs7(BPopover2.Root, { ...props, modal: false, children: [
|
|
2740
|
-
/* @__PURE__ */ jsx8(BPopover2.Trigger, { render: triggerElement }),
|
|
2741
|
-
/* @__PURE__ */ jsxs7(
|
|
2742
|
-
FloatingSurface,
|
|
2743
|
-
{
|
|
2744
|
-
side,
|
|
2745
|
-
align,
|
|
2746
|
-
width,
|
|
2747
|
-
unstyled,
|
|
2748
|
-
initialFocus,
|
|
2749
|
-
label: popupLabel,
|
|
2750
|
-
children: [
|
|
2751
|
-
hasTitle && (label !== void 0 ? /* @__PURE__ */ jsx8("h2", { className: "mt-popup-title", children: title }) : /* @__PURE__ */ jsx8(BPopover2.Title, { className: "mt-popup-title", children: title })),
|
|
2752
|
-
content2
|
|
2753
|
-
]
|
|
2754
|
-
}
|
|
2755
|
-
)
|
|
2756
|
-
] });
|
|
2757
|
-
}
|
|
2758
|
-
function PopoverRoot(props) {
|
|
2759
|
-
return /* @__PURE__ */ jsx8(PopoverFrame, { ...props });
|
|
2760
|
-
}
|
|
2761
|
-
function PopoverSearchableSelect({
|
|
2762
|
-
items,
|
|
2763
|
-
value,
|
|
2764
|
-
defaultValue,
|
|
2765
|
-
onValueChange,
|
|
2766
|
-
open,
|
|
2767
|
-
defaultOpen,
|
|
2768
|
-
onOpenChange,
|
|
2769
|
-
searchPlaceholder,
|
|
2770
|
-
title,
|
|
2771
|
-
width = 320,
|
|
2772
|
-
align = "start",
|
|
2773
|
-
...props
|
|
2774
|
-
}) {
|
|
2775
|
-
const { locale } = useMtone();
|
|
2776
|
-
const [localValue, setLocalValue] = useState5(defaultValue);
|
|
2777
|
-
const [localOpen, setLocalOpen] = useState5(defaultOpen ?? false);
|
|
2778
|
-
const input = React9.useRef(null);
|
|
2779
|
-
const isOpen = open ?? localOpen;
|
|
2780
|
-
const selected = value === void 0 ? localValue : value;
|
|
2781
|
-
function changeOpen(next) {
|
|
2782
|
-
if (open === void 0) setLocalOpen(next);
|
|
2783
|
-
onOpenChange?.(next);
|
|
2784
|
-
}
|
|
2785
|
-
return /* @__PURE__ */ jsx8(
|
|
2786
|
-
PopoverFrame,
|
|
2787
|
-
{
|
|
2788
|
-
...props,
|
|
2789
|
-
width,
|
|
2790
|
-
align,
|
|
2791
|
-
open: isOpen,
|
|
2792
|
-
onOpenChange: changeOpen,
|
|
2793
|
-
title: title ?? (locale === "zh" ? "\u9009\u62E9\u9009\u9879" : "Choose an option"),
|
|
2794
|
-
initialFocus: input,
|
|
2795
|
-
content: /* @__PURE__ */ jsx8(
|
|
2796
|
-
PopoverSearchableSelectContent,
|
|
2797
|
-
{
|
|
2798
|
-
items,
|
|
2799
|
-
value: selected,
|
|
2800
|
-
open: isOpen,
|
|
2801
|
-
searchPlaceholder,
|
|
2802
|
-
inputRef: input,
|
|
2803
|
-
select: (next) => {
|
|
2804
|
-
if (next !== selected) {
|
|
2805
|
-
if (value === void 0) setLocalValue(next);
|
|
2806
|
-
onValueChange?.(next);
|
|
2807
|
-
}
|
|
2808
|
-
changeOpen(false);
|
|
2809
|
-
}
|
|
2810
|
-
}
|
|
2811
|
-
)
|
|
2812
|
-
}
|
|
2813
|
-
);
|
|
3179
|
+
const triggerElement = typeof trigger === "string" ? /* @__PURE__ */ jsx8(Button, { preset: "dropdown", style: { width: "fit-content", maxWidth: "100%" }, children: trigger }) : trigger;
|
|
3180
|
+
return /* @__PURE__ */ jsxs7(BPopover2.Root, { ...props, modal: false, children: [
|
|
3181
|
+
/* @__PURE__ */ jsx8(BPopover2.Trigger, { render: triggerElement }),
|
|
3182
|
+
/* @__PURE__ */ jsxs7(
|
|
3183
|
+
FloatingSurface,
|
|
3184
|
+
{
|
|
3185
|
+
side,
|
|
3186
|
+
align,
|
|
3187
|
+
width,
|
|
3188
|
+
unstyled,
|
|
3189
|
+
initialFocus,
|
|
3190
|
+
label: popupLabel,
|
|
3191
|
+
children: [
|
|
3192
|
+
hasTitle && (label !== void 0 ? /* @__PURE__ */ jsx8("h2", { className: "mt-popup-title", children: title }) : /* @__PURE__ */ jsx8(BPopover2.Title, { className: "mt-popup-title", children: title })),
|
|
3193
|
+
content2
|
|
3194
|
+
]
|
|
3195
|
+
}
|
|
3196
|
+
)
|
|
3197
|
+
] });
|
|
3198
|
+
}
|
|
3199
|
+
function PopoverRoot(props) {
|
|
3200
|
+
return /* @__PURE__ */ jsx8(PopoverFrame, { ...props });
|
|
2814
3201
|
}
|
|
2815
|
-
var Popover = Object.assign(PopoverRoot, { Menu: PopoverMenu
|
|
3202
|
+
var Popover = Object.assign(PopoverRoot, { Menu: PopoverMenu });
|
|
2816
3203
|
function Tooltip({
|
|
2817
3204
|
children,
|
|
2818
3205
|
content: content2,
|
|
@@ -2870,7 +3257,7 @@ function Dialog({
|
|
|
2870
3257
|
{
|
|
2871
3258
|
className: "mt-dialog-close",
|
|
2872
3259
|
"aria-label": locale === "zh" ? "\u5173\u95ED" : "Close",
|
|
2873
|
-
children: /* @__PURE__ */ jsx8(
|
|
3260
|
+
children: /* @__PURE__ */ jsx8(X4, { size: 18, "aria-hidden": "true" })
|
|
2874
3261
|
}
|
|
2875
3262
|
)
|
|
2876
3263
|
] }),
|
|
@@ -2977,7 +3364,7 @@ function Drawer({
|
|
|
2977
3364
|
}
|
|
2978
3365
|
|
|
2979
3366
|
// src/card.tsx
|
|
2980
|
-
import { Fragment as
|
|
3367
|
+
import { Fragment as Fragment7, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2981
3368
|
function hasContent(value) {
|
|
2982
3369
|
return React10.Children.toArray(value).some((child) => {
|
|
2983
3370
|
if (React10.isValidElement(child) && child.type === React10.Fragment) {
|
|
@@ -3083,7 +3470,7 @@ function CardRoot(props) {
|
|
|
3083
3470
|
/* @__PURE__ */ jsx9(Skeleton, { style: { height: 12 } }),
|
|
3084
3471
|
/* @__PURE__ */ jsx9(Skeleton, { style: { width: "80%", height: 12 } })
|
|
3085
3472
|
] }) : content2 });
|
|
3086
|
-
const cardContent = /* @__PURE__ */ jsxs8(
|
|
3473
|
+
const cardContent = /* @__PURE__ */ jsxs8(Fragment7, { children: [
|
|
3087
3474
|
hasContent(cover) && /* @__PURE__ */ jsx9("div", { className: cn("mt-card-cover", classes2.cover), style: css.cover, children: cover }),
|
|
3088
3475
|
hasTabs ? /* @__PURE__ */ jsxs8(
|
|
3089
3476
|
"div",
|
|
@@ -3161,7 +3548,7 @@ function CardRoot(props) {
|
|
|
3161
3548
|
if (collapsed === void 0) setLocalCollapsed(next);
|
|
3162
3549
|
onCollapsedChange?.(next);
|
|
3163
3550
|
},
|
|
3164
|
-
children: /* @__PURE__ */ jsx9(
|
|
3551
|
+
children: /* @__PURE__ */ jsx9(ChevronDown3, { size: 16, "aria-hidden": "true" })
|
|
3165
3552
|
}
|
|
3166
3553
|
),
|
|
3167
3554
|
hasContent(title) && /* @__PURE__ */ jsx9(
|
|
@@ -3275,11 +3662,11 @@ var Card = Object.assign(CardRoot, { Meta: CardMeta, Grid: CardGrid });
|
|
|
3275
3662
|
import * as React16 from "react";
|
|
3276
3663
|
import { Button as BaseButton } from "@base-ui/react/button";
|
|
3277
3664
|
import {
|
|
3278
|
-
ChevronDown as
|
|
3665
|
+
ChevronDown as ChevronDown4,
|
|
3279
3666
|
LoaderCircle as LoaderCircle3,
|
|
3280
3667
|
Pin,
|
|
3281
3668
|
Star,
|
|
3282
|
-
X as
|
|
3669
|
+
X as X6,
|
|
3283
3670
|
FileText,
|
|
3284
3671
|
Inbox,
|
|
3285
3672
|
Info as Info2,
|
|
@@ -3292,12 +3679,13 @@ import {
|
|
|
3292
3679
|
import React11 from "react";
|
|
3293
3680
|
|
|
3294
3681
|
// src/form-store.ts
|
|
3682
|
+
var emptyStringIsValue = /* @__PURE__ */ Symbol("emptyStringIsValue");
|
|
3295
3683
|
var own = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
3296
|
-
|
|
3297
|
-
async function validateRule(name, rule, value, values2) {
|
|
3684
|
+
async function validateRule(name, rule, value, values2, preserveEmptyString) {
|
|
3298
3685
|
const failure = (message) => rule.message ?? message;
|
|
3299
|
-
|
|
3300
|
-
if (
|
|
3686
|
+
const missing = value == null || !preserveEmptyString && value === "" || Array.isArray(value) && value.length === 0;
|
|
3687
|
+
if (missing && rule.required) return failure(`${name} is required`);
|
|
3688
|
+
if (!missing) {
|
|
3301
3689
|
if (rule.whitespace && typeof value === "string" && value.trim() === "")
|
|
3302
3690
|
return failure(`${name} cannot be blank`);
|
|
3303
3691
|
let typeValid = true;
|
|
@@ -3415,6 +3803,9 @@ function createFormStore(initialValues = {}) {
|
|
|
3415
3803
|
get rules() {
|
|
3416
3804
|
return config.rules ?? [];
|
|
3417
3805
|
},
|
|
3806
|
+
get emptyStringIsValue() {
|
|
3807
|
+
return config[emptyStringIsValue] === true;
|
|
3808
|
+
},
|
|
3418
3809
|
epoch: 0,
|
|
3419
3810
|
validating: false,
|
|
3420
3811
|
errors: previous?.errors ?? []
|
|
@@ -3485,13 +3876,15 @@ function createFormStore(initialValues = {}) {
|
|
|
3485
3876
|
const results = await Promise.all(
|
|
3486
3877
|
targets.map(async (target) => {
|
|
3487
3878
|
let error;
|
|
3879
|
+
const preserveEmptyString = target.field.emptyStringIsValue;
|
|
3488
3880
|
for (const rule of target.field.rules) {
|
|
3489
3881
|
if (stale(target)) break;
|
|
3490
3882
|
error = await validateRule(
|
|
3491
3883
|
target.name,
|
|
3492
3884
|
rule,
|
|
3493
3885
|
own(snapshot, target.name) ? snapshot[target.name] : void 0,
|
|
3494
|
-
snapshot
|
|
3886
|
+
snapshot,
|
|
3887
|
+
preserveEmptyString
|
|
3495
3888
|
);
|
|
3496
3889
|
if (error !== void 0) break;
|
|
3497
3890
|
}
|
|
@@ -3549,16 +3942,24 @@ function FormField({
|
|
|
3549
3942
|
const generatedId = React11.useId();
|
|
3550
3943
|
const child = children;
|
|
3551
3944
|
const inputId = child.props.id || generatedId;
|
|
3552
|
-
const
|
|
3945
|
+
const valueType = child.type.formValueType;
|
|
3946
|
+
const kind = typeof valueType === "function" ? valueType(child.props) : valueType;
|
|
3553
3947
|
const trigger = triggerProp ?? (kind ? "onValueChange" : "onChange");
|
|
3554
|
-
const
|
|
3555
|
-
rulesRef
|
|
3948
|
+
const preserveEmptyString = kind === "select-single" && valuePropName === "value";
|
|
3949
|
+
const rulesRef = React11.useRef({ rules, required, preserveEmptyString });
|
|
3950
|
+
rulesRef.current = { rules, required, preserveEmptyString };
|
|
3556
3951
|
React11.useEffect(() => {
|
|
3557
3952
|
if (!form || name === void 0) return;
|
|
3558
|
-
return form.register(name, {
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3953
|
+
return form.register(name, {
|
|
3954
|
+
get rules() {
|
|
3955
|
+
const latest = rulesRef.current;
|
|
3956
|
+
return latest.required && !latest.rules?.some((rule) => rule.required) ? [{ required: true }, ...latest.rules ?? []] : latest.rules ?? [];
|
|
3957
|
+
},
|
|
3958
|
+
get [emptyStringIsValue]() {
|
|
3959
|
+
return rulesRef.current.preserveEmptyString;
|
|
3960
|
+
},
|
|
3961
|
+
initialValue
|
|
3962
|
+
});
|
|
3562
3963
|
}, [form, name]);
|
|
3563
3964
|
const messages = form && name !== void 0 ? form.getFieldError(name) : [];
|
|
3564
3965
|
const managedError = messages.length ? messages.join(" ") : void 0;
|
|
@@ -3577,7 +3978,7 @@ function FormField({
|
|
|
3577
3978
|
};
|
|
3578
3979
|
if (form && name !== void 0) {
|
|
3579
3980
|
const value = form.getFieldValue(name);
|
|
3580
|
-
props[valuePropName] = value ?? (valuePropName === "checked" ? false : trigger === "onValueChange" ? kind === "array" || Array.isArray(initialValue) ? [] : null : "");
|
|
3981
|
+
props[valuePropName] = value ?? (valuePropName === "checked" ? false : trigger === "onValueChange" ? kind === "array" || kind !== "select-single" && Array.isArray(initialValue) ? [] : null : "");
|
|
3581
3982
|
props.name = name;
|
|
3582
3983
|
const modes = validateTrigger ?? context?.validateTrigger ?? "onChange";
|
|
3583
3984
|
const shouldValidate = (mode) => modes !== false && (Array.isArray(modes) ? modes.includes(mode) : modes === mode);
|
|
@@ -3864,8 +4265,8 @@ var Avatar2 = Object.assign(AvatarBase, { Group: AvatarGroup });
|
|
|
3864
4265
|
|
|
3865
4266
|
// src/progress.tsx
|
|
3866
4267
|
import * as React13 from "react";
|
|
3867
|
-
import { Check as Check3, X as
|
|
3868
|
-
import { Fragment as
|
|
4268
|
+
import { Check as Check3, X as X5 } from "lucide-react";
|
|
4269
|
+
import { Fragment as Fragment8, jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3869
4270
|
var finite = (n, fallback) => n !== void 0 && Number.isFinite(n) ? n : fallback;
|
|
3870
4271
|
var clamp = (n, min, max) => Math.min(max, Math.max(min, n));
|
|
3871
4272
|
var percent = (n) => clamp(finite(n, 0), 0, 100);
|
|
@@ -3927,7 +4328,7 @@ function Progress({
|
|
|
3927
4328
|
const paint = gradient ? `url(#mt-progress-${id})` : fill;
|
|
3928
4329
|
const background = gradient ? `linear-gradient(to right, ${fill.from}, ${fill.to})` : fill;
|
|
3929
4330
|
const successColor = success?.color ?? "#548164";
|
|
3930
|
-
const info = format ? format(n, completed) : status === "success" ? /* @__PURE__ */ jsx12(Check3, { size: 16, "aria-hidden": "true" }) : status === "exception" ? /* @__PURE__ */ jsx12(
|
|
4331
|
+
const info = format ? format(n, completed) : status === "success" ? /* @__PURE__ */ jsx12(Check3, { size: 16, "aria-hidden": "true" }) : status === "exception" ? /* @__PURE__ */ jsx12(X5, { size: 16, "aria-hidden": "true" }) : `${n}%`;
|
|
3931
4332
|
const infoNode = showInfo && /* @__PURE__ */ jsx12("span", { className: "mt-progress-info", "aria-hidden": "true", children: info });
|
|
3932
4333
|
const radius = (100 - thickness) / 2;
|
|
3933
4334
|
const gap = type === "dashboard" ? clamp(finite(gapDegree, 75), 0, 295) : 0;
|
|
@@ -4011,7 +4412,7 @@ function Progress({
|
|
|
4011
4412
|
void 0,
|
|
4012
4413
|
linecap
|
|
4013
4414
|
) }, i);
|
|
4014
|
-
}) : /* @__PURE__ */ jsxs11(
|
|
4415
|
+
}) : /* @__PURE__ */ jsxs11(Fragment8, { children: [
|
|
4015
4416
|
path(
|
|
4016
4417
|
start,
|
|
4017
4418
|
sweep,
|
|
@@ -4060,7 +4461,7 @@ function Progress({
|
|
|
4060
4461
|
},
|
|
4061
4462
|
i
|
|
4062
4463
|
);
|
|
4063
|
-
}) : /* @__PURE__ */ jsxs11(
|
|
4464
|
+
}) : /* @__PURE__ */ jsxs11(Fragment8, { children: [
|
|
4064
4465
|
/* @__PURE__ */ jsx12(
|
|
4065
4466
|
"span",
|
|
4066
4467
|
{
|
|
@@ -4090,16 +4491,6 @@ import { Check as Check4, Copy, Pencil } from "lucide-react";
|
|
|
4090
4491
|
|
|
4091
4492
|
// src/typography-code-tokens.tsx
|
|
4092
4493
|
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
4093
|
-
var codeLanguages = [
|
|
4094
|
-
"js",
|
|
4095
|
-
"ts",
|
|
4096
|
-
"jsx",
|
|
4097
|
-
"tsx",
|
|
4098
|
-
"json",
|
|
4099
|
-
"html",
|
|
4100
|
-
"css",
|
|
4101
|
-
"bash"
|
|
4102
|
-
];
|
|
4103
4494
|
function CodeTokens({ tokens }) {
|
|
4104
4495
|
return tokens.map(
|
|
4105
4496
|
({ text, light, dark }, index) => light || dark ? /* @__PURE__ */ jsx13(
|
|
@@ -4118,7 +4509,7 @@ function CodeTokens({ tokens }) {
|
|
|
4118
4509
|
}
|
|
4119
4510
|
|
|
4120
4511
|
// src/typography.tsx
|
|
4121
|
-
import { Fragment as
|
|
4512
|
+
import { Fragment as Fragment9, jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
4122
4513
|
function plainText(node) {
|
|
4123
4514
|
return React14.Children.toArray(node).map(
|
|
4124
4515
|
(child) => typeof child === "string" || typeof child === "number" ? String(child) : React14.isValidElement(child) ? plainText(child.props.children) : ""
|
|
@@ -4147,7 +4538,7 @@ var Content = React14.forwardRef(function Content2({
|
|
|
4147
4538
|
const en = locale === "en";
|
|
4148
4539
|
const copy = typeof copyable === "object" ? copyable : {};
|
|
4149
4540
|
const edit = typeof editable === "object" ? editable : {};
|
|
4150
|
-
const
|
|
4541
|
+
const clamp3 = typeof ellipsis === "object" ? ellipsis : {};
|
|
4151
4542
|
const source = edit.text ?? plainText(children);
|
|
4152
4543
|
const [value, setValue] = React14.useState(source);
|
|
4153
4544
|
React14.useEffect(() => setValue(source), [source]);
|
|
@@ -4155,9 +4546,9 @@ var Content = React14.forwardRef(function Content2({
|
|
|
4155
4546
|
const active = !!editable && !disabled && (edit.editing ?? editing);
|
|
4156
4547
|
const [draft, setDraft] = React14.useState(value);
|
|
4157
4548
|
const [expanded, setExpanded] = React14.useState(
|
|
4158
|
-
|
|
4549
|
+
clamp3.defaultExpanded ?? false
|
|
4159
4550
|
);
|
|
4160
|
-
const isExpanded =
|
|
4551
|
+
const isExpanded = clamp3.expanded ?? expanded;
|
|
4161
4552
|
const [status, setStatus] = React14.useState("idle");
|
|
4162
4553
|
const input = React14.useRef(null);
|
|
4163
4554
|
const editButton = React14.useRef(null);
|
|
@@ -4216,7 +4607,7 @@ var Content = React14.forwardRef(function Content2({
|
|
|
4216
4607
|
if (mark) text = /* @__PURE__ */ jsx14("mark", { children: text });
|
|
4217
4608
|
if (code) text = /* @__PURE__ */ jsx14("code", { children: text });
|
|
4218
4609
|
if (keyboard) text = /* @__PURE__ */ jsx14("kbd", { children: text });
|
|
4219
|
-
const rows = Number.isFinite(
|
|
4610
|
+
const rows = Number.isFinite(clamp3.rows) ? Math.max(1, Math.floor(clamp3.rows)) : 1;
|
|
4220
4611
|
const copyLabel = copy.label ?? (en ? "Copy" : "\u590D\u5236");
|
|
4221
4612
|
const editLabel = edit.label ?? (en ? "Edit" : "\u7F16\u8F91");
|
|
4222
4613
|
const content2 = active ? /* @__PURE__ */ jsx14(
|
|
@@ -4249,7 +4640,7 @@ var Content = React14.forwardRef(function Content2({
|
|
|
4249
4640
|
}
|
|
4250
4641
|
}
|
|
4251
4642
|
}
|
|
4252
|
-
) : /* @__PURE__ */ jsxs12(
|
|
4643
|
+
) : /* @__PURE__ */ jsxs12(Fragment9, { children: [
|
|
4253
4644
|
!ellipsis ? text : /* @__PURE__ */ jsx14(
|
|
4254
4645
|
"span",
|
|
4255
4646
|
{
|
|
@@ -4266,7 +4657,7 @@ var Content = React14.forwardRef(function Content2({
|
|
|
4266
4657
|
children: text
|
|
4267
4658
|
}
|
|
4268
4659
|
),
|
|
4269
|
-
!!ellipsis &&
|
|
4660
|
+
!!ellipsis && clamp3.expandable && /* @__PURE__ */ jsx14(
|
|
4270
4661
|
"button",
|
|
4271
4662
|
{
|
|
4272
4663
|
type: "button",
|
|
@@ -4275,9 +4666,9 @@ var Content = React14.forwardRef(function Content2({
|
|
|
4275
4666
|
"aria-expanded": isExpanded,
|
|
4276
4667
|
onClick: () => {
|
|
4277
4668
|
setExpanded(!isExpanded);
|
|
4278
|
-
|
|
4669
|
+
clamp3.onExpandedChange?.(!isExpanded);
|
|
4279
4670
|
},
|
|
4280
|
-
children: isExpanded ?
|
|
4671
|
+
children: isExpanded ? clamp3.collapseLabel ?? (en ? "Collapse" : "\u6536\u8D77") : clamp3.expandLabel ?? (en ? "Expand" : "\u5C55\u5F00")
|
|
4281
4672
|
}
|
|
4282
4673
|
),
|
|
4283
4674
|
!!copyable && /* @__PURE__ */ jsx14(
|
|
@@ -4431,13 +4822,12 @@ var Code = React14.forwardRef(function Code2({ block = false, language, children
|
|
|
4431
4822
|
}, []);
|
|
4432
4823
|
const [overflows, setOverflows] = React14.useState(false);
|
|
4433
4824
|
const [highlight, setHighlight] = React14.useState();
|
|
4434
|
-
const
|
|
4435
|
-
const supported = block && codeLanguages.find((value) => value === candidateLanguage);
|
|
4825
|
+
const supported = block && language ? resolveCodeLanguage(language) : void 0;
|
|
4436
4826
|
const text = typeof children === "string" ? children : void 0;
|
|
4437
4827
|
React14.useEffect(() => {
|
|
4438
4828
|
if (!supported || !text) return;
|
|
4439
4829
|
let active = true;
|
|
4440
|
-
import("./typography-highlight-
|
|
4830
|
+
import("./typography-highlight-GAYKSB6L.js").then(({ highlightCode }) => highlightCode(text, supported)).then((tokens2) => {
|
|
4441
4831
|
if (active) setHighlight({ text, language: supported, tokens: tokens2 });
|
|
4442
4832
|
}).catch(() => {
|
|
4443
4833
|
});
|
|
@@ -4608,7 +4998,7 @@ var Button = React16.forwardRef(
|
|
|
4608
4998
|
const iconToggle = toggle && typeof toggle === "object" && toggle.mode === "icon" ? toggle : void 0;
|
|
4609
4999
|
const Preset = iconToggle?.preset === "star" ? Star : iconToggle?.preset === "pin" ? Pin : void 0;
|
|
4610
5000
|
const leading = loading ? /* @__PURE__ */ jsx16(LoaderCircle3, { className: "mt-spin", size: 14, "aria-hidden": "true" }) : iconToggle ? Preset ? /* @__PURE__ */ jsx16(Preset, { size: 14, fill: isPressed ? "currentColor" : "none" }) : isPressed ? iconToggle.onIcon : iconToggle.offIcon : leftSection === void 0 ? icon : leftSection;
|
|
4611
|
-
const trailing = rightSection === void 0 && preset === "dropdown" ? /* @__PURE__ */ jsx16(
|
|
5001
|
+
const trailing = rightSection === void 0 && preset === "dropdown" ? /* @__PURE__ */ jsx16(ChevronDown4, { size: 14, "aria-hidden": "true" }) : rightSection;
|
|
4612
5002
|
return /* @__PURE__ */ jsxs13(
|
|
4613
5003
|
BaseButton,
|
|
4614
5004
|
{
|
|
@@ -4671,7 +5061,7 @@ function Tag({
|
|
|
4671
5061
|
variant: "ghost",
|
|
4672
5062
|
"aria-label": locale === "zh" ? "\u79FB\u9664\u7B5B\u9009" : "Remove filter",
|
|
4673
5063
|
onClick: onRemove,
|
|
4674
|
-
children: /* @__PURE__ */ jsx16(
|
|
5064
|
+
children: /* @__PURE__ */ jsx16(X6, { size: 12, "aria-hidden": "true" })
|
|
4675
5065
|
}
|
|
4676
5066
|
)
|
|
4677
5067
|
] });
|
|
@@ -4684,7 +5074,7 @@ function Tag({
|
|
|
4684
5074
|
type: "button",
|
|
4685
5075
|
onClick: onRemove,
|
|
4686
5076
|
"aria-label": locale === "zh" ? "\u79FB\u9664\u6807\u7B7E" : "Remove tag",
|
|
4687
|
-
children: /* @__PURE__ */ jsx16(
|
|
5077
|
+
children: /* @__PURE__ */ jsx16(X6, { size: 11 })
|
|
4688
5078
|
}
|
|
4689
5079
|
)
|
|
4690
5080
|
] });
|
|
@@ -4753,7 +5143,7 @@ function Alert({
|
|
|
4753
5143
|
title && /* @__PURE__ */ jsx16("strong", { children: title }),
|
|
4754
5144
|
children && /* @__PURE__ */ jsx16("div", { children })
|
|
4755
5145
|
] }),
|
|
4756
|
-
onClose && /* @__PURE__ */ jsx16(Button, { iconOnly: true, "aria-label": "Close", variant: "ghost", onClick: onClose, children: /* @__PURE__ */ jsx16(
|
|
5146
|
+
onClose && /* @__PURE__ */ jsx16(Button, { iconOnly: true, "aria-label": "Close", variant: "ghost", onClick: onClose, children: /* @__PURE__ */ jsx16(X6, { size: 14, "aria-hidden": "true" }) })
|
|
4757
5147
|
]
|
|
4758
5148
|
}
|
|
4759
5149
|
);
|
|
@@ -4783,13 +5173,13 @@ function Spinner({ label = "Loading" }) {
|
|
|
4783
5173
|
import * as React17 from "react";
|
|
4784
5174
|
import {
|
|
4785
5175
|
ChevronRight as ChevronRight2,
|
|
4786
|
-
ChevronDown as
|
|
5176
|
+
ChevronDown as ChevronDown5,
|
|
4787
5177
|
PanelLeftClose,
|
|
4788
5178
|
PanelLeftOpen,
|
|
4789
5179
|
Circle
|
|
4790
5180
|
} from "lucide-react";
|
|
4791
5181
|
import { Popover as BPopover3 } from "@base-ui/react/popover";
|
|
4792
|
-
import { Fragment as
|
|
5182
|
+
import { Fragment as Fragment11, jsx as jsx17, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
4793
5183
|
var SidebarContext = React17.createContext(false);
|
|
4794
5184
|
var NavSubmenuSelectionContext = React17.createContext(null);
|
|
4795
5185
|
function Sidebar({
|
|
@@ -4797,6 +5187,7 @@ function Sidebar({
|
|
|
4797
5187
|
children,
|
|
4798
5188
|
header,
|
|
4799
5189
|
footer,
|
|
5190
|
+
tabs,
|
|
4800
5191
|
collapsePlacement = "header",
|
|
4801
5192
|
collapsible = false,
|
|
4802
5193
|
collapsed,
|
|
@@ -4809,6 +5200,11 @@ function Sidebar({
|
|
|
4809
5200
|
const [internal, setInternal] = React17.useState(defaultCollapsed);
|
|
4810
5201
|
const isCollapsed = collapsible && (collapsed ?? internal);
|
|
4811
5202
|
const contentId = React17.useId();
|
|
5203
|
+
const items = React17.useMemo(() => tabs?.items.map(({ content: content2, ...item }) => ({
|
|
5204
|
+
...item,
|
|
5205
|
+
content: /* @__PURE__ */ jsx17("div", { className: "mt-sidebar-content", children: content2 })
|
|
5206
|
+
})), [tabs?.items]);
|
|
5207
|
+
const hasTabs = !!items?.length;
|
|
4812
5208
|
const toggle = collapsible && /* @__PURE__ */ jsx17(
|
|
4813
5209
|
Button,
|
|
4814
5210
|
{
|
|
@@ -4830,14 +5226,29 @@ function Sidebar({
|
|
|
4830
5226
|
"aside",
|
|
4831
5227
|
{
|
|
4832
5228
|
...p,
|
|
4833
|
-
className: cn("mt-sidebar", className),
|
|
5229
|
+
className: cn("mt-sidebar", hasTabs && "mt-sidebar-with-tabs", className),
|
|
4834
5230
|
"data-collapsed": isCollapsed,
|
|
4835
5231
|
children: [
|
|
4836
5232
|
header !== void 0 ? /* @__PURE__ */ jsxs14("div", { className: "mt-sidebar-heading", children: [
|
|
4837
5233
|
/* @__PURE__ */ jsx17("div", { className: "mt-sidebar-brand", children: typeof header === "function" ? header(isCollapsed) : header }),
|
|
4838
5234
|
collapsePlacement === "header" && toggle
|
|
4839
5235
|
] }) : collapsePlacement === "header" && toggle,
|
|
4840
|
-
|
|
5236
|
+
tabs && items?.length ? /* @__PURE__ */ jsx17("div", { id: contentId, className: "mt-sidebar-tab-region", children: /* @__PURE__ */ jsx17(
|
|
5237
|
+
Tabs,
|
|
5238
|
+
{
|
|
5239
|
+
className: "mt-sidebar-tabs",
|
|
5240
|
+
items,
|
|
5241
|
+
label: tabs.label,
|
|
5242
|
+
value: tabs.value,
|
|
5243
|
+
defaultValue: tabs.defaultValue,
|
|
5244
|
+
onValueChange: tabs.onValueChange,
|
|
5245
|
+
placement: "top",
|
|
5246
|
+
variant: "line",
|
|
5247
|
+
size: "small",
|
|
5248
|
+
indicatorColor: "blue",
|
|
5249
|
+
destroyOnHidden: false
|
|
5250
|
+
}
|
|
5251
|
+
) }) : collapsible || header !== void 0 ? /* @__PURE__ */ jsx17("div", { id: contentId, className: "mt-sidebar-content", children }) : children,
|
|
4841
5252
|
(footer !== void 0 || collapsePlacement === "footer" && collapsible) && /* @__PURE__ */ jsxs14("div", { className: "mt-sidebar-footer", children: [
|
|
4842
5253
|
footer !== void 0 && /* @__PURE__ */ jsx17("div", { className: "mt-sidebar-footer-content", children: typeof footer === "function" ? footer(isCollapsed) : footer }),
|
|
4843
5254
|
collapsePlacement === "footer" && toggle
|
|
@@ -4860,7 +5271,7 @@ var NavItem = React17.forwardRef(
|
|
|
4860
5271
|
"aria-current": active ? "page" : void 0,
|
|
4861
5272
|
className: cn("mt-nav-item", active && "mt-active", collapsed && "mt-nav-item-collapsed", className)
|
|
4862
5273
|
};
|
|
4863
|
-
const content2 = /* @__PURE__ */ jsxs14(
|
|
5274
|
+
const content2 = /* @__PURE__ */ jsxs14(Fragment11, { children: [
|
|
4864
5275
|
icon || (collapsed ? /* @__PURE__ */ jsx17(Circle, { size: 16, "aria-hidden": "true" }) : null),
|
|
4865
5276
|
collapsed ? /* @__PURE__ */ jsx17("span", { className: "mt-sidebar-sr-only", children }) : plainLabel ? /* @__PURE__ */ jsx17("span", { className: "mt-nav-item-label", children }) : children
|
|
4866
5277
|
] });
|
|
@@ -4998,7 +5409,7 @@ function NavSubmenu({
|
|
|
4998
5409
|
collapsed ? "mt-sidebar-sr-only" : "mt-nav-item-label",
|
|
4999
5410
|
hasActiveNavItem(children) && "mt-nav-submenu-label-active"
|
|
5000
5411
|
), children: label }),
|
|
5001
|
-
!collapsed && /* @__PURE__ */ jsx17(
|
|
5412
|
+
!collapsed && /* @__PURE__ */ jsx17(ChevronDown5, { size: 14, className: "mt-nav-submenu-chevron", "aria-hidden": "true" })
|
|
5002
5413
|
]
|
|
5003
5414
|
}
|
|
5004
5415
|
);
|
|
@@ -5052,7 +5463,7 @@ function NavSubmenu({
|
|
|
5052
5463
|
) }) })
|
|
5053
5464
|
]
|
|
5054
5465
|
}
|
|
5055
|
-
) : /* @__PURE__ */ jsxs14(
|
|
5466
|
+
) : /* @__PURE__ */ jsxs14(Fragment11, { children: [
|
|
5056
5467
|
trigger,
|
|
5057
5468
|
/* @__PURE__ */ jsx17("div", { id: panelId, className: "mt-nav-submenu-children", hidden: !inlineOpen, children })
|
|
5058
5469
|
] })
|
|
@@ -5069,7 +5480,7 @@ function Breadcrumb({
|
|
|
5069
5480
|
return /* @__PURE__ */ jsx17("nav", { "aria-label": label, ...props, children: /* @__PURE__ */ jsx17("ol", { className: "mt-breadcrumb", children: items.map((item, i) => {
|
|
5070
5481
|
const current = i === items.length - 1;
|
|
5071
5482
|
const hasMenu = !item.disabled && !!item.menu?.items.length;
|
|
5072
|
-
const content2 = /* @__PURE__ */ jsxs14(
|
|
5483
|
+
const content2 = /* @__PURE__ */ jsxs14(Fragment11, { children: [
|
|
5073
5484
|
item.icon != null && /* @__PURE__ */ jsx17("span", { className: "mt-breadcrumb-icon", "aria-hidden": "true", children: item.icon }),
|
|
5074
5485
|
item.label
|
|
5075
5486
|
] });
|
|
@@ -5115,7 +5526,7 @@ function Breadcrumb({
|
|
|
5115
5526
|
"aria-labelledby": separateTrigger && !item["aria-label"] ? `${id}-${i}` : void 0,
|
|
5116
5527
|
children: [
|
|
5117
5528
|
!separateTrigger && content2,
|
|
5118
|
-
/* @__PURE__ */ jsx17(
|
|
5529
|
+
/* @__PURE__ */ jsx17(ChevronDown5, { size: 12, "aria-hidden": "true" })
|
|
5119
5530
|
]
|
|
5120
5531
|
}
|
|
5121
5532
|
)
|
|
@@ -5132,7 +5543,7 @@ import { Upload as UploadIcon } from "lucide-react";
|
|
|
5132
5543
|
|
|
5133
5544
|
// src/pagination-controls.tsx
|
|
5134
5545
|
import * as React18 from "react";
|
|
5135
|
-
import { Fragment as
|
|
5546
|
+
import { Fragment as Fragment13, jsx as jsx18, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
5136
5547
|
function getPaginationWindow(count2, current) {
|
|
5137
5548
|
return Array.from(
|
|
5138
5549
|
/* @__PURE__ */ new Set([
|
|
@@ -5156,7 +5567,7 @@ function PaginationControls({
|
|
|
5156
5567
|
}) {
|
|
5157
5568
|
const pages = simple ? [] : getPaginationWindow(count2, current);
|
|
5158
5569
|
const content2 = (page, type, label) => renderItem ? renderItem(page, type, label) : label;
|
|
5159
|
-
return /* @__PURE__ */ jsxs15(
|
|
5570
|
+
return /* @__PURE__ */ jsxs15(Fragment13, { children: [
|
|
5160
5571
|
/* @__PURE__ */ jsx18(
|
|
5161
5572
|
Button,
|
|
5162
5573
|
{
|
|
@@ -5204,7 +5615,7 @@ import RcTableImport, {
|
|
|
5204
5615
|
Summary
|
|
5205
5616
|
} from "@rc-component/table";
|
|
5206
5617
|
import {
|
|
5207
|
-
ChevronDown as
|
|
5618
|
+
ChevronDown as ChevronDown7,
|
|
5208
5619
|
ChevronRight as ChevronRight4,
|
|
5209
5620
|
ArrowUp,
|
|
5210
5621
|
ArrowDown,
|
|
@@ -5265,7 +5676,7 @@ function processTableData(data, columns, sorts, filters, textFilters, manual, ch
|
|
|
5265
5676
|
import * as React19 from "react";
|
|
5266
5677
|
import { Popover as Popover3 } from "@base-ui/react/popover";
|
|
5267
5678
|
import { Filter, ChevronRight as ChevronRight3 } from "lucide-react";
|
|
5268
|
-
import { Fragment as
|
|
5679
|
+
import { Fragment as Fragment14, jsx as jsx19, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
5269
5680
|
var sameValues = (a, b) => a.length === b.length && a.every((value, index) => value === b[index]);
|
|
5270
5681
|
function plainText2(node) {
|
|
5271
5682
|
if (typeof node === "string" || typeof node === "number") return String(node);
|
|
@@ -5525,7 +5936,7 @@ function TableFilter({
|
|
|
5525
5936
|
style: column.filterDropdownProps?.style,
|
|
5526
5937
|
"aria-label": filterLabel,
|
|
5527
5938
|
onClick: (event) => event.stopPropagation(),
|
|
5528
|
-
children: column.filterDropdown !== void 0 ? typeof column.filterDropdown === "function" ? column.filterDropdown(customProps) : column.filterDropdown : /* @__PURE__ */ jsxs16(
|
|
5939
|
+
children: column.filterDropdown !== void 0 ? typeof column.filterDropdown === "function" ? column.filterDropdown(customProps) : column.filterDropdown : /* @__PURE__ */ jsxs16(Fragment14, { children: [
|
|
5529
5940
|
column.filterSearch && /* @__PURE__ */ jsx19(
|
|
5530
5941
|
"input",
|
|
5531
5942
|
{
|
|
@@ -5561,7 +5972,7 @@ function TableFilter({
|
|
|
5561
5972
|
|
|
5562
5973
|
// src/table-selection.tsx
|
|
5563
5974
|
import * as React20 from "react";
|
|
5564
|
-
import { ChevronDown as
|
|
5975
|
+
import { ChevronDown as ChevronDown6 } from "lucide-react";
|
|
5565
5976
|
import { INTERNAL_COL_DEFINE } from "@rc-component/table";
|
|
5566
5977
|
import { jsx as jsx20, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
5567
5978
|
function useTableSelection({
|
|
@@ -5800,7 +6211,7 @@ function useTableSelection({
|
|
|
5800
6211
|
className: "mt-table-selection-actions",
|
|
5801
6212
|
"aria-label": locale.selectionActions ?? (zh ? "\u9009\u62E9\u64CD\u4F5C" : "Selection actions"),
|
|
5802
6213
|
onClick: (event) => event.stopPropagation(),
|
|
5803
|
-
children: /* @__PURE__ */ jsx20(
|
|
6214
|
+
children: /* @__PURE__ */ jsx20(ChevronDown6, { size: 12, "aria-hidden": "true" })
|
|
5804
6215
|
}
|
|
5805
6216
|
),
|
|
5806
6217
|
items: commands.map((command, index) => ({
|
|
@@ -5975,7 +6386,7 @@ function TablePaginationBar({
|
|
|
5975
6386
|
}
|
|
5976
6387
|
|
|
5977
6388
|
// src/table.tsx
|
|
5978
|
-
import { Fragment as
|
|
6389
|
+
import { Fragment as Fragment16, jsx as jsx22, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
5979
6390
|
var SELECTION_COLUMN = Object.freeze({ key: "__mt_selection_column" });
|
|
5980
6391
|
function Column(_props) {
|
|
5981
6392
|
return null;
|
|
@@ -6014,7 +6425,7 @@ function useResponsive() {
|
|
|
6014
6425
|
}, []);
|
|
6015
6426
|
return width;
|
|
6016
6427
|
}
|
|
6017
|
-
function useCompactSelectionWidth(ref, compactWidth, virtual, separateHeader,
|
|
6428
|
+
function useCompactSelectionWidth(ref, compactWidth, virtual, separateHeader, empty, scrollX, layoutKey, tableComponent) {
|
|
6018
6429
|
const [fitWidth, setFitWidth] = React22.useState(0);
|
|
6019
6430
|
React22.useLayoutEffect(() => {
|
|
6020
6431
|
if (compactWidth === void 0) return;
|
|
@@ -6024,7 +6435,7 @@ function useCompactSelectionWidth(ref, compactWidth, virtual, separateHeader, em
|
|
|
6024
6435
|
const body = !virtual && root.querySelector(
|
|
6025
6436
|
container + ":is(.mt-table-body, .mt-table-content) > table"
|
|
6026
6437
|
);
|
|
6027
|
-
const holders = !virtual &&
|
|
6438
|
+
const holders = !virtual && empty && separateHeader ? root.querySelectorAll(
|
|
6028
6439
|
container + ":is(.mt-table-header, .mt-table-summary) > table"
|
|
6029
6440
|
) : [];
|
|
6030
6441
|
const tables = body ? [body, ...holders] : [...holders];
|
|
@@ -6072,7 +6483,7 @@ function useCompactSelectionWidth(ref, compactWidth, virtual, separateHeader, em
|
|
|
6072
6483
|
};
|
|
6073
6484
|
}, [
|
|
6074
6485
|
compactWidth,
|
|
6075
|
-
|
|
6486
|
+
empty,
|
|
6076
6487
|
layoutKey,
|
|
6077
6488
|
ref,
|
|
6078
6489
|
scrollX,
|
|
@@ -6129,7 +6540,7 @@ function TableInner(props, forwardedRef) {
|
|
|
6129
6540
|
selectedKeys,
|
|
6130
6541
|
onSelectionChange,
|
|
6131
6542
|
loading = false,
|
|
6132
|
-
empty
|
|
6543
|
+
empty,
|
|
6133
6544
|
locale = {},
|
|
6134
6545
|
size = "middle",
|
|
6135
6546
|
bordered = false,
|
|
@@ -6364,7 +6775,7 @@ function TableInner(props, forwardedRef) {
|
|
|
6364
6775
|
...c,
|
|
6365
6776
|
key,
|
|
6366
6777
|
dataIndex: c.dataIndex ?? (c.key == null ? void 0 : String(c.key)),
|
|
6367
|
-
title: /* @__PURE__ */ jsxs19(
|
|
6778
|
+
title: /* @__PURE__ */ jsxs19(Fragment16, { children: [
|
|
6368
6779
|
/* @__PURE__ */ jsxs19(
|
|
6369
6780
|
"div",
|
|
6370
6781
|
{
|
|
@@ -6473,7 +6884,7 @@ function TableInner(props, forwardedRef) {
|
|
|
6473
6884
|
"aria-label": p.type === "all" ? p.expanded ? zh ? "\u6536\u8D77\u6240\u6709\u884C" : "Collapse all rows" : zh ? "\u5C55\u5F00\u6240\u6709\u884C" : "Expand all rows" : p.expanded ? locale.collapse ?? (zh ? "\u6536\u8D77\u884C" : "Collapse row") : locale.expand ?? (zh ? "\u5C55\u5F00\u884C" : "Expand row"),
|
|
6474
6885
|
"aria-expanded": p.expanded,
|
|
6475
6886
|
onClick: p.onClick,
|
|
6476
|
-
children: p.expanded ? /* @__PURE__ */ jsx22(
|
|
6887
|
+
children: p.expanded ? /* @__PURE__ */ jsx22(ChevronDown7, { size: 14 }) : /* @__PURE__ */ jsx22(ChevronRight4, { size: 14 })
|
|
6477
6888
|
}
|
|
6478
6889
|
) : /* @__PURE__ */ jsx22("span", { className: "mt-table-expand-placeholder" }))
|
|
6479
6890
|
};
|
|
@@ -6510,7 +6921,7 @@ function TableInner(props, forwardedRef) {
|
|
|
6510
6921
|
scroll,
|
|
6511
6922
|
expandable: resolvedExpandable,
|
|
6512
6923
|
components: rcComponents,
|
|
6513
|
-
emptyText: showLoading ? null :
|
|
6924
|
+
emptyText: showLoading ? null : empty ?? locale.emptyText ?? (zh ? "\u6682\u65E0\u6570\u636E" : "No data"),
|
|
6514
6925
|
classNames: resolvedClasses,
|
|
6515
6926
|
styles: resolvedStyles,
|
|
6516
6927
|
rowClassName: (r, i, indent) => cn(
|
|
@@ -6589,7 +7000,7 @@ var Table = Object.assign(
|
|
|
6589
7000
|
// src/tree.tsx
|
|
6590
7001
|
import * as React23 from "react";
|
|
6591
7002
|
import {
|
|
6592
|
-
ChevronDown as
|
|
7003
|
+
ChevronDown as ChevronDown8,
|
|
6593
7004
|
ChevronRight as ChevronRight5,
|
|
6594
7005
|
LoaderCircle as LoaderCircle4,
|
|
6595
7006
|
Folder,
|
|
@@ -7285,7 +7696,7 @@ var Tree = React23.forwardRef(function Tree2({
|
|
|
7285
7696
|
expand(node, errors.has(node.id) ? true : !isOpen);
|
|
7286
7697
|
}
|
|
7287
7698
|
},
|
|
7288
|
-
children: busy ? switcherLoadingIcon ?? /* @__PURE__ */ jsx23(LoaderCircle4, { size: 14 }) : isBranch ? (typeof switcherIcon === "function" ? switcherIcon(info) : switcherIcon) ?? (isOpen ? /* @__PURE__ */ jsx23(
|
|
7699
|
+
children: busy ? switcherLoadingIcon ?? /* @__PURE__ */ jsx23(LoaderCircle4, { size: 14 }) : isBranch ? (typeof switcherIcon === "function" ? switcherIcon(info) : switcherIcon) ?? (isOpen ? /* @__PURE__ */ jsx23(ChevronDown8, { size: 14 }) : /* @__PURE__ */ jsx23(ChevronRight5, { size: 14 })) : null
|
|
7289
7700
|
}
|
|
7290
7701
|
),
|
|
7291
7702
|
checkable && node.checkable !== false && /* @__PURE__ */ jsx23(
|
|
@@ -7339,7 +7750,7 @@ var Tree = React23.forwardRef(function Tree2({
|
|
|
7339
7750
|
});
|
|
7340
7751
|
|
|
7341
7752
|
// src/data.tsx
|
|
7342
|
-
import { Fragment as
|
|
7753
|
+
import { Fragment as Fragment17, jsx as jsx24, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
7343
7754
|
function Pagination({
|
|
7344
7755
|
total,
|
|
7345
7756
|
pageSize = 10,
|
|
@@ -7583,7 +7994,7 @@ function Upload({
|
|
|
7583
7994
|
error: zh ? "\u4E0A\u4F20\u5931\u8D25" : "Failed"
|
|
7584
7995
|
}[f.status] })
|
|
7585
7996
|
] }),
|
|
7586
|
-
f.status === "uploading" && /* @__PURE__ */ jsxs21(
|
|
7997
|
+
f.status === "uploading" && /* @__PURE__ */ jsxs21(Fragment17, { children: [
|
|
7587
7998
|
/* @__PURE__ */ jsx24(
|
|
7588
7999
|
"progress",
|
|
7589
8000
|
{
|
|
@@ -7760,7 +8171,7 @@ var AdminLayout = Object.assign(AdminLayoutRoot, {
|
|
|
7760
8171
|
|
|
7761
8172
|
// src/global-notice.tsx
|
|
7762
8173
|
import * as React26 from "react";
|
|
7763
|
-
import { ShieldAlert, X as
|
|
8174
|
+
import { ShieldAlert, X as X7 } from "lucide-react";
|
|
7764
8175
|
import { jsx as jsx26, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
7765
8176
|
function GlobalNotice({
|
|
7766
8177
|
title,
|
|
@@ -7806,8 +8217,8 @@ function GlobalNotice({
|
|
|
7806
8217
|
"aria-label": label ? void 0 : dismissLabel,
|
|
7807
8218
|
loading,
|
|
7808
8219
|
onClick: onAction,
|
|
7809
|
-
rightSection: label && !loading ? /* @__PURE__ */ jsx26(
|
|
7810
|
-
children: label || !loading && /* @__PURE__ */ jsx26(
|
|
8220
|
+
rightSection: label && !loading ? /* @__PURE__ */ jsx26(X7, { size: 14, "aria-hidden": "true" }) : void 0,
|
|
8221
|
+
children: label || !loading && /* @__PURE__ */ jsx26(X7, { size: 14, "aria-hidden": "true" })
|
|
7811
8222
|
}
|
|
7812
8223
|
)
|
|
7813
8224
|
]
|
|
@@ -8631,7 +9042,7 @@ function SplitterRoot(props) {
|
|
|
8631
9042
|
max,
|
|
8632
9043
|
resizable = true,
|
|
8633
9044
|
collapsible = false,
|
|
8634
|
-
collapsedSize = 0,
|
|
9045
|
+
collapsedSize: collapsedSize2 = 0,
|
|
8635
9046
|
groupResizeBehavior,
|
|
8636
9047
|
children: panelChildren,
|
|
8637
9048
|
...p
|
|
@@ -8653,7 +9064,7 @@ function SplitterRoot(props) {
|
|
|
8653
9064
|
maxSize: max,
|
|
8654
9065
|
disabled: !resizable,
|
|
8655
9066
|
collapsible,
|
|
8656
|
-
collapsedSize,
|
|
9067
|
+
collapsedSize: collapsedSize2,
|
|
8657
9068
|
groupResizeBehavior,
|
|
8658
9069
|
className: cn("mt-splitter-panel", p.className)
|
|
8659
9070
|
},
|
|
@@ -8698,7 +9109,7 @@ var Splitter = Object.assign(SplitterRoot, { Panel: SplitterPanel });
|
|
|
8698
9109
|
// src/mentions.tsx
|
|
8699
9110
|
import * as React31 from "react";
|
|
8700
9111
|
import { createPortal } from "react-dom";
|
|
8701
|
-
import { X as
|
|
9112
|
+
import { X as X8, LoaderCircle as LoaderCircle5 } from "lucide-react";
|
|
8702
9113
|
|
|
8703
9114
|
// src/mentions-model.ts
|
|
8704
9115
|
function mentionPrefixes(prefix) {
|
|
@@ -8789,11 +9200,11 @@ function caretRect(input, caret) {
|
|
|
8789
9200
|
width: `${input.clientWidth ? input.clientWidth + parseFloat(computed.borderLeftWidth) + parseFloat(computed.borderRightWidth) : rect.width}px`
|
|
8790
9201
|
});
|
|
8791
9202
|
mirror.textContent = input.value.slice(0, caret);
|
|
8792
|
-
const
|
|
8793
|
-
|
|
8794
|
-
mirror.append(
|
|
9203
|
+
const marker2 = document.createElement("span");
|
|
9204
|
+
marker2.textContent = input.value.slice(caret) || "\u200B";
|
|
9205
|
+
mirror.append(marker2);
|
|
8795
9206
|
document.body.append(mirror);
|
|
8796
|
-
const markerRect =
|
|
9207
|
+
const markerRect = marker2.getClientRects()[0] ?? marker2.getBoundingClientRect(), mirrorRect = mirror.getBoundingClientRect();
|
|
8797
9208
|
const left = rect.left + markerRect.left - mirrorRect.left - input.scrollLeft;
|
|
8798
9209
|
const top = rect.top + markerRect.top - mirrorRect.top - input.scrollTop;
|
|
8799
9210
|
mirror.remove();
|
|
@@ -9190,7 +9601,7 @@ var Mentions = React31.forwardRef(
|
|
|
9190
9601
|
onClear?.();
|
|
9191
9602
|
inputRef.current?.focus();
|
|
9192
9603
|
},
|
|
9193
|
-
children: clearConfig.clearIcon ?? /* @__PURE__ */ jsx31(
|
|
9604
|
+
children: clearConfig.clearIcon ?? /* @__PURE__ */ jsx31(X8, { size: 13, "aria-hidden": true })
|
|
9194
9605
|
}
|
|
9195
9606
|
),
|
|
9196
9607
|
popup && createPortal(
|
|
@@ -9241,7 +9652,7 @@ function isoWeek(value) {
|
|
|
9241
9652
|
}
|
|
9242
9653
|
|
|
9243
9654
|
// src/calendar.tsx
|
|
9244
|
-
import { Fragment as
|
|
9655
|
+
import { Fragment as Fragment21, jsx as jsx32, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
9245
9656
|
function Calendar({
|
|
9246
9657
|
value,
|
|
9247
9658
|
defaultValue,
|
|
@@ -9282,18 +9693,18 @@ function Calendar({
|
|
|
9282
9693
|
throw new RangeError(
|
|
9283
9694
|
"Calendar validRange must be an ordered pair of YYYY-MM-DD dates"
|
|
9284
9695
|
);
|
|
9285
|
-
const
|
|
9286
|
-
const [local, setLocal] = React32.useState(() =>
|
|
9696
|
+
const clamp3 = (v) => validRange ? v < validRange[0] ? validRange[0] : v > validRange[1] ? validRange[1] : v : v;
|
|
9697
|
+
const [local, setLocal] = React32.useState(() => clamp3(defaultValue ?? today));
|
|
9287
9698
|
const current = value ?? local;
|
|
9288
9699
|
const [localMode, setLocalMode] = React32.useState(defaultMode);
|
|
9289
9700
|
const type = mode ?? localMode;
|
|
9290
|
-
const [view, setView] = React32.useState(() =>
|
|
9291
|
-
const [focus, setFocus] = React32.useState(() =>
|
|
9701
|
+
const [view, setView] = React32.useState(() => clamp3(current));
|
|
9702
|
+
const [focus, setFocus] = React32.useState(() => clamp3(current));
|
|
9292
9703
|
const gridFocused = React32.useRef(false);
|
|
9293
9704
|
React32.useEffect(() => {
|
|
9294
9705
|
pending.current = gridFocused.current;
|
|
9295
|
-
setView(
|
|
9296
|
-
setFocus(
|
|
9706
|
+
setView(clamp3(current));
|
|
9707
|
+
setFocus(clamp3(current));
|
|
9297
9708
|
}, [current, validRange?.[0], validRange?.[1]]);
|
|
9298
9709
|
const root = React32.useRef(null);
|
|
9299
9710
|
const pending = React32.useRef(false);
|
|
@@ -9311,7 +9722,7 @@ function Calendar({
|
|
|
9311
9722
|
const unavailable = (v) => !parseCalendarDate(v) || disabled || Boolean(validRange && (v < validRange[0] || v > validRange[1])) || Boolean(disabledDate?.(v));
|
|
9312
9723
|
const emit = (v, source, nextMode = type) => {
|
|
9313
9724
|
if (!parseCalendarDate(v) || disabled) return;
|
|
9314
|
-
let next =
|
|
9725
|
+
let next = clamp3(v);
|
|
9315
9726
|
if (unavailable(next)) {
|
|
9316
9727
|
if (source !== "month" && source !== "year") return;
|
|
9317
9728
|
const candidate = monthCandidate(next);
|
|
@@ -9361,7 +9772,7 @@ function Calendar({
|
|
|
9361
9772
|
const d = parseCalendarDate(v);
|
|
9362
9773
|
if (!d) return null;
|
|
9363
9774
|
let candidate = setMonth(current, d.getUTCFullYear(), d.getUTCMonth());
|
|
9364
|
-
candidate =
|
|
9775
|
+
candidate = clamp3(candidate);
|
|
9365
9776
|
if (candidate.slice(0, 7) !== v.slice(0, 7)) return null;
|
|
9366
9777
|
if (!unavailable(candidate)) return candidate;
|
|
9367
9778
|
for (let n = 1; n <= 31; n++) {
|
|
@@ -9415,13 +9826,13 @@ function Calendar({
|
|
|
9415
9826
|
}
|
|
9416
9827
|
if (!next) return;
|
|
9417
9828
|
event.preventDefault();
|
|
9418
|
-
next =
|
|
9829
|
+
next = clamp3(next);
|
|
9419
9830
|
const direction = next < v ? -1 : 1;
|
|
9420
9831
|
let attempts = 0;
|
|
9421
9832
|
while ((type === "month" ? unavailable(next) : !monthCandidate(next)) && attempts++ < 366) {
|
|
9422
9833
|
const nd = parseCalendarDate(next);
|
|
9423
9834
|
if (!nd) return;
|
|
9424
|
-
const candidate =
|
|
9835
|
+
const candidate = clamp3(
|
|
9425
9836
|
type === "month" ? addDays(next, direction) : setMonth(next, nd.getUTCFullYear(), nd.getUTCMonth() + direction)
|
|
9426
9837
|
);
|
|
9427
9838
|
if (candidate === next || !parseCalendarDate(candidate)) return;
|
|
@@ -9467,7 +9878,7 @@ function Calendar({
|
|
|
9467
9878
|
type === "year" ? monthCandidate(v) ?? v : v,
|
|
9468
9879
|
type === "year" ? "month" : "date"
|
|
9469
9880
|
),
|
|
9470
|
-
children: fullCellRender ? fullCellRender(v, info) : /* @__PURE__ */ jsxs28(
|
|
9881
|
+
children: fullCellRender ? fullCellRender(v, info) : /* @__PURE__ */ jsxs28(Fragment21, { children: [
|
|
9471
9882
|
originNode,
|
|
9472
9883
|
cellRender && /* @__PURE__ */ jsx32("span", { className: "mt-calendar-content", children: cellRender(v, info) })
|
|
9473
9884
|
] })
|
|
@@ -9486,7 +9897,7 @@ function Calendar({
|
|
|
9486
9897
|
year + (type === "year" ? n : 0),
|
|
9487
9898
|
month + (type === "month" ? n : 0)
|
|
9488
9899
|
);
|
|
9489
|
-
return disabled ||
|
|
9900
|
+
return disabled || clamp3(next) === view;
|
|
9490
9901
|
};
|
|
9491
9902
|
return /* @__PURE__ */ jsxs28(
|
|
9492
9903
|
"div",
|
|
@@ -9523,7 +9934,7 @@ function Calendar({
|
|
|
9523
9934
|
type,
|
|
9524
9935
|
onChange: (v) => emit(v, "customize"),
|
|
9525
9936
|
onTypeChange: changeMode
|
|
9526
|
-
}) : /* @__PURE__ */ jsxs28(
|
|
9937
|
+
}) : /* @__PURE__ */ jsxs28(Fragment21, { children: [
|
|
9527
9938
|
/* @__PURE__ */ jsx32(
|
|
9528
9939
|
Button,
|
|
9529
9940
|
{
|
|
@@ -10147,7 +10558,7 @@ var Timeline = React35.forwardRef(
|
|
|
10147
10558
|
...itemProps
|
|
10148
10559
|
} = item;
|
|
10149
10560
|
const side = placement ?? (position === "left" ? "start" : position === "right" ? "end" : position) ?? (normalizedMode === "alternate" ? index % 2 ? "end" : "start" : normalizedMode);
|
|
10150
|
-
const
|
|
10561
|
+
const marker2 = icon !== void 0 ? icon : dot;
|
|
10151
10562
|
return /* @__PURE__ */ createElement3(
|
|
10152
10563
|
"li",
|
|
10153
10564
|
{
|
|
@@ -10176,7 +10587,7 @@ var Timeline = React35.forwardRef(
|
|
|
10176
10587
|
"aria-hidden": "true",
|
|
10177
10588
|
className: cn("mt-timeline-icon", classNames.icon),
|
|
10178
10589
|
style: styles.icon,
|
|
10179
|
-
children:
|
|
10590
|
+
children: marker2 !== void 0 ? marker2 : loading ? /* @__PURE__ */ jsx35(LoaderCircle6, { className: "mt-timeline-spinner", size: 14 }) : /* @__PURE__ */ jsx35("span", { className: "mt-timeline-dot" })
|
|
10180
10591
|
}
|
|
10181
10592
|
),
|
|
10182
10593
|
(title !== void 0 ? title : label) != null && /* @__PURE__ */ jsx35(
|
|
@@ -10384,7 +10795,7 @@ var Result = React37.forwardRef(
|
|
|
10384
10795
|
import * as React38 from "react";
|
|
10385
10796
|
import { Dialog as BDialog2 } from "@base-ui/react/dialog";
|
|
10386
10797
|
import {
|
|
10387
|
-
X as
|
|
10798
|
+
X as X9,
|
|
10388
10799
|
ZoomIn,
|
|
10389
10800
|
ZoomOut,
|
|
10390
10801
|
RotateCw,
|
|
@@ -10397,7 +10808,7 @@ import {
|
|
|
10397
10808
|
ImageOff,
|
|
10398
10809
|
LoaderCircle as LoaderCircle7
|
|
10399
10810
|
} from "lucide-react";
|
|
10400
|
-
import { Fragment as
|
|
10811
|
+
import { Fragment as Fragment22, jsx as jsx38, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
10401
10812
|
function ImageContent({
|
|
10402
10813
|
fallback,
|
|
10403
10814
|
placeholder,
|
|
@@ -10438,7 +10849,7 @@ function ImageContent({
|
|
|
10438
10849
|
}
|
|
10439
10850
|
),
|
|
10440
10851
|
state === "loading" && /* @__PURE__ */ jsx38("span", { className: "mt-image-placeholder", "aria-hidden": "true", children: placeholder ?? /* @__PURE__ */ jsx38(LoaderCircle7, { size: 20, className: "mt-image-spinner" }) }),
|
|
10441
|
-
state === "error" && /* @__PURE__ */ jsx38("span", { className: "mt-image-error", role: "status", children: errorContent ?? /* @__PURE__ */ jsxs32(
|
|
10852
|
+
state === "error" && /* @__PURE__ */ jsx38("span", { className: "mt-image-error", role: "status", children: errorContent ?? /* @__PURE__ */ jsxs32(Fragment22, { children: [
|
|
10442
10853
|
/* @__PURE__ */ jsx38(ImageOff, { size: 22 }),
|
|
10443
10854
|
/* @__PURE__ */ jsx38("span", { children: locale === "zh" ? "\u56FE\u7247\u52A0\u8F7D\u5931\u8D25" : "Image failed to load" })
|
|
10444
10855
|
] }) })
|
|
@@ -10511,7 +10922,7 @@ function PreviewContent({
|
|
|
10511
10922
|
children: icon
|
|
10512
10923
|
}
|
|
10513
10924
|
);
|
|
10514
|
-
return /* @__PURE__ */ jsxs32(
|
|
10925
|
+
return /* @__PURE__ */ jsxs32(Fragment22, { children: [
|
|
10515
10926
|
/* @__PURE__ */ jsxs32("div", { className: "mt-image-preview-header", children: [
|
|
10516
10927
|
/* @__PURE__ */ jsx38(BDialog2.Title, { children: item.alt || (zh ? "\u56FE\u7247\u9884\u89C8" : "Image preview") }),
|
|
10517
10928
|
/* @__PURE__ */ jsxs32("span", { "aria-live": "polite", children: [
|
|
@@ -10519,7 +10930,7 @@ function PreviewContent({
|
|
|
10519
10930
|
" / ",
|
|
10520
10931
|
total
|
|
10521
10932
|
] }),
|
|
10522
|
-
/* @__PURE__ */ jsx38(BDialog2.Close, { "aria-label": zh ? "\u5173\u95ED\u9884\u89C8" : "Close preview", children: /* @__PURE__ */ jsx38(
|
|
10933
|
+
/* @__PURE__ */ jsx38(BDialog2.Close, { "aria-label": zh ? "\u5173\u95ED\u9884\u89C8" : "Close preview", children: /* @__PURE__ */ jsx38(X9, { size: 20 }) })
|
|
10523
10934
|
] }),
|
|
10524
10935
|
/* @__PURE__ */ jsx38(
|
|
10525
10936
|
"div",
|
|
@@ -11207,7 +11618,7 @@ var TableOfContents = forwardRef15(function TableOfContents2({
|
|
|
11207
11618
|
// src/auto-complete.tsx
|
|
11208
11619
|
import * as React40 from "react";
|
|
11209
11620
|
import { Autocomplete as A } from "@base-ui/react/autocomplete";
|
|
11210
|
-
import { LoaderCircle as LoaderCircle8, X as
|
|
11621
|
+
import { LoaderCircle as LoaderCircle8, X as X10 } from "lucide-react";
|
|
11211
11622
|
import { jsx as jsx40, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
11212
11623
|
var AutoComplete = React40.forwardRef(function AutoComplete2({
|
|
11213
11624
|
options = [],
|
|
@@ -11338,7 +11749,7 @@ var AutoComplete = React40.forwardRef(function AutoComplete2({
|
|
|
11338
11749
|
{
|
|
11339
11750
|
className: "mt-auto-complete-clear",
|
|
11340
11751
|
"aria-label": zh ? "\u6E05\u9664" : "Clear",
|
|
11341
|
-
children: /* @__PURE__ */ jsx40(
|
|
11752
|
+
children: /* @__PURE__ */ jsx40(X10, { size: 13 })
|
|
11342
11753
|
}
|
|
11343
11754
|
),
|
|
11344
11755
|
suffix && /* @__PURE__ */ jsx40("span", { className: "mt-auto-complete-adornment", children: suffix })
|
|
@@ -11389,11 +11800,11 @@ import * as React41 from "react";
|
|
|
11389
11800
|
import { Popover as Popover5 } from "@base-ui/react/popover";
|
|
11390
11801
|
import {
|
|
11391
11802
|
Check as Check6,
|
|
11392
|
-
ChevronDown as
|
|
11803
|
+
ChevronDown as ChevronDown10,
|
|
11393
11804
|
ChevronRight as ChevronRight9,
|
|
11394
11805
|
LoaderCircle as LoaderCircle9,
|
|
11395
11806
|
Minus as Minus3,
|
|
11396
|
-
X as
|
|
11807
|
+
X as X11
|
|
11397
11808
|
} from "lucide-react";
|
|
11398
11809
|
import { jsx as jsx41, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
11399
11810
|
var keyOf = (path) => JSON.stringify(path);
|
|
@@ -11911,7 +12322,7 @@ var Cascader = React41.forwardRef(
|
|
|
11911
12322
|
children: props.multiple ? displayed.length ? zh ? `\u5DF2\u9009\u62E9 ${displayed.length} \u9879` : `${displayed.length} selected` : props.placeholder ?? (zh ? "\u8BF7\u9009\u62E9" : "Select\u2026") : state.selected.length ? renderPath(state.selected[0]) : props.placeholder ?? (zh ? "\u8BF7\u9009\u62E9" : "Select\u2026")
|
|
11912
12323
|
}
|
|
11913
12324
|
),
|
|
11914
|
-
/* @__PURE__ */ jsx41(
|
|
12325
|
+
/* @__PURE__ */ jsx41(ChevronDown10, { size: 14, "aria-hidden": true })
|
|
11915
12326
|
]
|
|
11916
12327
|
}
|
|
11917
12328
|
),
|
|
@@ -11922,7 +12333,7 @@ var Cascader = React41.forwardRef(
|
|
|
11922
12333
|
type: "button",
|
|
11923
12334
|
"aria-label": zh ? "\u6E05\u9664\u9009\u62E9" : "Clear selection",
|
|
11924
12335
|
onClick: clear,
|
|
11925
|
-
children: /* @__PURE__ */ jsx41(
|
|
12336
|
+
children: /* @__PURE__ */ jsx41(X11, { size: 12 })
|
|
11926
12337
|
}
|
|
11927
12338
|
),
|
|
11928
12339
|
props.name && /* @__PURE__ */ jsx41(
|
|
@@ -11957,7 +12368,7 @@ var Cascader = React41.forwardRef(
|
|
|
11957
12368
|
state.selected.filter((p) => !prefixOf(path, p))
|
|
11958
12369
|
);
|
|
11959
12370
|
},
|
|
11960
|
-
children: /* @__PURE__ */ jsx41(
|
|
12371
|
+
children: /* @__PURE__ */ jsx41(X11, { size: 10 })
|
|
11961
12372
|
}
|
|
11962
12373
|
)
|
|
11963
12374
|
] }, keyOf(path))),
|
|
@@ -12001,8 +12412,8 @@ var Cascader = React41.forwardRef(
|
|
|
12001
12412
|
|
|
12002
12413
|
// src/transfer.tsx
|
|
12003
12414
|
import * as React42 from "react";
|
|
12004
|
-
import { ChevronLeft as ChevronLeft3, ChevronRight as ChevronRight10, X as
|
|
12005
|
-
import { Fragment as
|
|
12415
|
+
import { ChevronLeft as ChevronLeft3, ChevronRight as ChevronRight10, X as X12 } from "lucide-react";
|
|
12416
|
+
import { Fragment as Fragment23, jsx as jsx42, jsxs as jsxs36 } from "react/jsx-runtime";
|
|
12006
12417
|
var unique = (keys) => Array.from(new Set(keys));
|
|
12007
12418
|
var Transfer = React42.forwardRef(
|
|
12008
12419
|
function Transfer2({
|
|
@@ -12161,7 +12572,7 @@ var Transfer = React42.forwardRef(
|
|
|
12161
12572
|
className: "mt-transfer-row",
|
|
12162
12573
|
"data-disabled": item.disabled || blocked || void 0,
|
|
12163
12574
|
"data-selected": selectionSet.has(item.key) || void 0,
|
|
12164
|
-
children: oneWay && side === 1 ? /* @__PURE__ */ jsxs36(
|
|
12575
|
+
children: oneWay && side === 1 ? /* @__PURE__ */ jsxs36(Fragment23, { children: [
|
|
12165
12576
|
/* @__PURE__ */ jsxs36("div", { className: "mt-transfer-item", children: [
|
|
12166
12577
|
renderItem?.(item, direction) ?? item.label,
|
|
12167
12578
|
item.description && /* @__PURE__ */ jsx42("small", { children: item.description })
|
|
@@ -12174,7 +12585,7 @@ var Transfer = React42.forwardRef(
|
|
|
12174
12585
|
"aria-label": `${en ? "Remove " : "\u79FB\u9664 "}${item.searchText ?? (typeof item.label === "string" ? item.label : item.key)}`,
|
|
12175
12586
|
disabled: blocked || item.disabled,
|
|
12176
12587
|
onClick: () => move("left", [item.key]),
|
|
12177
|
-
children: /* @__PURE__ */ jsx42(
|
|
12588
|
+
children: /* @__PURE__ */ jsx42(X12, { size: 14 })
|
|
12178
12589
|
}
|
|
12179
12590
|
)
|
|
12180
12591
|
] }) : /* @__PURE__ */ jsx42(
|
|
@@ -12467,7 +12878,7 @@ var Fieldset = React45.forwardRef(
|
|
|
12467
12878
|
// src/tree-select.tsx
|
|
12468
12879
|
import * as React46 from "react";
|
|
12469
12880
|
import { Popover as Popover6 } from "@base-ui/react/popover";
|
|
12470
|
-
import { ChevronDown as
|
|
12881
|
+
import { ChevronDown as ChevronDown11, X as X13 } from "lucide-react";
|
|
12471
12882
|
import { jsx as jsx46, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
12472
12883
|
var textOf2 = (node) => typeof node.textValue === "string" ? node.textValue : typeof node.label === "string" || typeof node.label === "number" ? String(node.label) : String(node.id);
|
|
12473
12884
|
var TreeSelect = React46.forwardRef(
|
|
@@ -12614,7 +13025,7 @@ var TreeSelect = React46.forwardRef(
|
|
|
12614
13025
|
children: display.length ? props.multiple ? zh ? `\u5DF2\u9009\u62E9 ${display.length} \u9879` : `${display.length} selected` : valueLabel(display[0]) : props.placeholder ?? (zh ? "\u8BF7\u9009\u62E9" : "Select\u2026")
|
|
12615
13026
|
}
|
|
12616
13027
|
),
|
|
12617
|
-
/* @__PURE__ */ jsx46(
|
|
13028
|
+
/* @__PURE__ */ jsx46(ChevronDown11, { size: 14, "aria-hidden": true })
|
|
12618
13029
|
]
|
|
12619
13030
|
}
|
|
12620
13031
|
),
|
|
@@ -12629,7 +13040,7 @@ var TreeSelect = React46.forwardRef(
|
|
|
12629
13040
|
props.onClear?.();
|
|
12630
13041
|
button.current?.focus();
|
|
12631
13042
|
},
|
|
12632
|
-
children: /* @__PURE__ */ jsx46(
|
|
13043
|
+
children: /* @__PURE__ */ jsx46(X13, { size: 12 })
|
|
12633
13044
|
}
|
|
12634
13045
|
),
|
|
12635
13046
|
props.name && /* @__PURE__ */ jsx46(
|
|
@@ -12662,7 +13073,7 @@ var TreeSelect = React46.forwardRef(
|
|
|
12662
13073
|
type: "button",
|
|
12663
13074
|
"aria-label": `${zh ? "\u79FB\u9664" : "Remove"} ${index.get(key) ? textOf2(index.get(key).item) : key}`,
|
|
12664
13075
|
onClick: () => toggle(key, false),
|
|
12665
|
-
children: /* @__PURE__ */ jsx46(
|
|
13076
|
+
children: /* @__PURE__ */ jsx46(X13, { size: 10 })
|
|
12666
13077
|
}
|
|
12667
13078
|
)
|
|
12668
13079
|
]
|
|
@@ -12773,7 +13184,7 @@ var TreeSelect = React46.forwardRef(
|
|
|
12773
13184
|
|
|
12774
13185
|
// src/tag-select.tsx
|
|
12775
13186
|
import * as React47 from "react";
|
|
12776
|
-
import { ChevronDown as
|
|
13187
|
+
import { ChevronDown as ChevronDown12 } from "lucide-react";
|
|
12777
13188
|
import { jsx as jsx47, jsxs as jsxs41 } from "react/jsx-runtime";
|
|
12778
13189
|
function TagSelect({
|
|
12779
13190
|
options,
|
|
@@ -12926,7 +13337,7 @@ function TagSelect({
|
|
|
12926
13337
|
},
|
|
12927
13338
|
children: [
|
|
12928
13339
|
isExpanded ? collapseLabel : expandLabel,
|
|
12929
|
-
/* @__PURE__ */ jsx47(
|
|
13340
|
+
/* @__PURE__ */ jsx47(ChevronDown12, { size: 14, "aria-hidden": "true" })
|
|
12930
13341
|
]
|
|
12931
13342
|
}
|
|
12932
13343
|
)
|
|
@@ -12936,9 +13347,44 @@ function TagSelect({
|
|
|
12936
13347
|
}
|
|
12937
13348
|
|
|
12938
13349
|
// src/data-list.tsx
|
|
13350
|
+
import * as React49 from "react";
|
|
13351
|
+
import { ChevronDown as ChevronDown13, ChevronRight as ChevronRight11 } from "lucide-react";
|
|
13352
|
+
|
|
13353
|
+
// src/toolbar.tsx
|
|
12939
13354
|
import * as React48 from "react";
|
|
12940
|
-
import {
|
|
12941
|
-
|
|
13355
|
+
import { jsx as jsx48, jsxs as jsxs42 } from "react/jsx-runtime";
|
|
13356
|
+
var hasSlot = (node) => node != null && typeof node !== "boolean" && node !== "";
|
|
13357
|
+
var Toolbar = React48.forwardRef(
|
|
13358
|
+
function Toolbar2({
|
|
13359
|
+
search,
|
|
13360
|
+
start,
|
|
13361
|
+
end,
|
|
13362
|
+
background = "white",
|
|
13363
|
+
className,
|
|
13364
|
+
role,
|
|
13365
|
+
...props
|
|
13366
|
+
}, ref) {
|
|
13367
|
+
const named = props["aria-label"]?.trim() || props["aria-labelledby"]?.trim();
|
|
13368
|
+
return /* @__PURE__ */ jsx48(
|
|
13369
|
+
"div",
|
|
13370
|
+
{
|
|
13371
|
+
...props,
|
|
13372
|
+
ref,
|
|
13373
|
+
className: cn("mt-toolbar", className),
|
|
13374
|
+
"data-background": background,
|
|
13375
|
+
role: role ?? (named ? "group" : void 0),
|
|
13376
|
+
children: /* @__PURE__ */ jsxs42("div", { className: "mt-toolbar-layout", children: [
|
|
13377
|
+
hasSlot(search) && /* @__PURE__ */ jsx48("div", { className: "mt-toolbar-search", children: search }),
|
|
13378
|
+
hasSlot(start) && /* @__PURE__ */ jsx48("div", { className: "mt-toolbar-start", children: start }),
|
|
13379
|
+
hasSlot(end) && /* @__PURE__ */ jsx48("div", { className: "mt-toolbar-end", children: end })
|
|
13380
|
+
] })
|
|
13381
|
+
}
|
|
13382
|
+
);
|
|
13383
|
+
}
|
|
13384
|
+
);
|
|
13385
|
+
|
|
13386
|
+
// src/data-list.tsx
|
|
13387
|
+
import { Fragment as Fragment24, jsx as jsx49, jsxs as jsxs43 } from "react/jsx-runtime";
|
|
12942
13388
|
var integer = (value, fallback, min) => value !== void 0 && Number.isFinite(value) ? Math.max(min, Math.trunc(value)) : fallback;
|
|
12943
13389
|
function updateKeys(keys, changed, add) {
|
|
12944
13390
|
const next = new Set(keys);
|
|
@@ -12954,13 +13400,13 @@ function DataListRow({
|
|
|
12954
13400
|
children,
|
|
12955
13401
|
detail
|
|
12956
13402
|
}) {
|
|
12957
|
-
const detailId =
|
|
12958
|
-
return /* @__PURE__ */
|
|
12959
|
-
/* @__PURE__ */
|
|
13403
|
+
const detailId = React49.useId();
|
|
13404
|
+
return /* @__PURE__ */ jsxs43(Fragment24, { children: [
|
|
13405
|
+
/* @__PURE__ */ jsxs43("div", { className: "mt-data-list-row", children: [
|
|
12960
13406
|
checkbox,
|
|
12961
|
-
/* @__PURE__ */
|
|
12962
|
-
(actions != null || detail) && /* @__PURE__ */
|
|
12963
|
-
detail && /* @__PURE__ */
|
|
13407
|
+
/* @__PURE__ */ jsx49("div", { className: "mt-data-list-content", children }),
|
|
13408
|
+
(actions != null || detail) && /* @__PURE__ */ jsxs43("div", { className: "mt-data-list-actions", children: [
|
|
13409
|
+
detail && /* @__PURE__ */ jsx49(
|
|
12964
13410
|
Button,
|
|
12965
13411
|
{
|
|
12966
13412
|
iconOnly: true,
|
|
@@ -12971,13 +13417,13 @@ function DataListRow({
|
|
|
12971
13417
|
"aria-controls": detailId,
|
|
12972
13418
|
"aria-expanded": detail.expanded,
|
|
12973
13419
|
onClick: detail.onToggle,
|
|
12974
|
-
children: detail.expanded ? /* @__PURE__ */
|
|
13420
|
+
children: detail.expanded ? /* @__PURE__ */ jsx49(ChevronDown13, { size: 16, "aria-hidden": "true" }) : /* @__PURE__ */ jsx49(ChevronRight11, { size: 16, "aria-hidden": "true" })
|
|
12975
13421
|
}
|
|
12976
13422
|
),
|
|
12977
13423
|
actions
|
|
12978
13424
|
] })
|
|
12979
13425
|
] }),
|
|
12980
|
-
detail && /* @__PURE__ */
|
|
13426
|
+
detail && /* @__PURE__ */ jsx49(
|
|
12981
13427
|
"div",
|
|
12982
13428
|
{
|
|
12983
13429
|
className: "mt-data-list-detail",
|
|
@@ -13003,29 +13449,29 @@ function DataList({
|
|
|
13003
13449
|
renderActions,
|
|
13004
13450
|
renderBatchActions,
|
|
13005
13451
|
loading = false,
|
|
13006
|
-
empty
|
|
13452
|
+
empty,
|
|
13007
13453
|
className,
|
|
13008
13454
|
...props
|
|
13009
13455
|
}) {
|
|
13010
13456
|
const zh = useMtone().locale === "zh";
|
|
13011
13457
|
const remote = pagination?.mode === "remote";
|
|
13012
|
-
const [localQuery, setLocalQuery] =
|
|
13458
|
+
const [localQuery, setLocalQuery] = React49.useState(
|
|
13013
13459
|
search?.defaultValue ?? ""
|
|
13014
13460
|
);
|
|
13015
|
-
const [localPage, setLocalPage] =
|
|
13461
|
+
const [localPage, setLocalPage] = React49.useState(
|
|
13016
13462
|
integer(
|
|
13017
13463
|
pagination?.mode === "remote" ? void 0 : pagination?.defaultPage,
|
|
13018
13464
|
1,
|
|
13019
13465
|
1
|
|
13020
13466
|
)
|
|
13021
13467
|
);
|
|
13022
|
-
const [localSelected, setLocalSelected] =
|
|
13023
|
-
const [localExpanded, setLocalExpanded] =
|
|
13468
|
+
const [localSelected, setLocalSelected] = React49.useState(selection?.defaultSelectedKeys ?? []);
|
|
13469
|
+
const [localExpanded, setLocalExpanded] = React49.useState(expansion?.defaultExpandedKeys ?? []);
|
|
13024
13470
|
const query = search?.value ?? localQuery;
|
|
13025
13471
|
const trimmedQuery = query.trim();
|
|
13026
13472
|
const selected = new Set(selection?.selectedKeys ?? localSelected);
|
|
13027
13473
|
const expanded = new Set(expansion?.expandedKeys ?? localExpanded);
|
|
13028
|
-
const rows =
|
|
13474
|
+
const rows = React49.useMemo(() => {
|
|
13029
13475
|
const keys = /* @__PURE__ */ new Set();
|
|
13030
13476
|
return items.map((item) => {
|
|
13031
13477
|
const key = getKey(item);
|
|
@@ -13050,7 +13496,7 @@ function DataList({
|
|
|
13050
13496
|
const enabledKeys = selection ? visible.filter(({ item }) => !selection.getDisabled?.(item)).map(({ key }) => key) : [];
|
|
13051
13497
|
const picked = enabledKeys.filter((key) => selected.has(key)).length;
|
|
13052
13498
|
const all = picked > 0 && picked === enabledKeys.length;
|
|
13053
|
-
|
|
13499
|
+
React49.useEffect(() => {
|
|
13054
13500
|
if (pagination && !remote && pagination.page === void 0 && page !== localPage) {
|
|
13055
13501
|
setLocalPage(page);
|
|
13056
13502
|
}
|
|
@@ -13074,49 +13520,70 @@ function DataList({
|
|
|
13074
13520
|
const clearSelection = () => {
|
|
13075
13521
|
if (selected.size) changeSelection([]);
|
|
13076
13522
|
};
|
|
13077
|
-
|
|
13078
|
-
|
|
13079
|
-
|
|
13080
|
-
|
|
13081
|
-
|
|
13082
|
-
|
|
13083
|
-
|
|
13084
|
-
|
|
13085
|
-
|
|
13086
|
-
|
|
13087
|
-
|
|
13088
|
-
|
|
13089
|
-
|
|
13090
|
-
|
|
13091
|
-
|
|
13092
|
-
|
|
13093
|
-
|
|
13094
|
-
|
|
13095
|
-
|
|
13096
|
-
|
|
13097
|
-
|
|
13098
|
-
|
|
13099
|
-
|
|
13100
|
-
|
|
13101
|
-
|
|
13102
|
-
|
|
13103
|
-
|
|
13104
|
-
|
|
13105
|
-
|
|
13106
|
-
|
|
13107
|
-
|
|
13108
|
-
|
|
13109
|
-
|
|
13110
|
-
|
|
13111
|
-
|
|
13112
|
-
|
|
13523
|
+
const hasFilters = filters != null && typeof filters !== "boolean" && filters !== "";
|
|
13524
|
+
const hasToolbar = toolbar != null && typeof toolbar !== "boolean" && toolbar !== "";
|
|
13525
|
+
const hasLeadingControls = selection || search;
|
|
13526
|
+
const hasTrailingControls = hasFilters || hasToolbar;
|
|
13527
|
+
return /* @__PURE__ */ jsxs43("section", { ...props, className: cn("mt-data-list", className), children: [
|
|
13528
|
+
(hasLeadingControls || hasTrailingControls) && /* @__PURE__ */ jsx49(
|
|
13529
|
+
Toolbar,
|
|
13530
|
+
{
|
|
13531
|
+
className: "mt-data-list-toolbar",
|
|
13532
|
+
background: "gray",
|
|
13533
|
+
start: hasLeadingControls && /* @__PURE__ */ jsxs43(Fragment24, { children: [
|
|
13534
|
+
selection && /* @__PURE__ */ jsxs43("div", { className: "mt-data-list-selection", children: [
|
|
13535
|
+
/* @__PURE__ */ jsx49(
|
|
13536
|
+
Checkbox,
|
|
13537
|
+
{
|
|
13538
|
+
label: zh ? "\u9009\u62E9\u5F53\u524D\u53EF\u89C1\u9879" : "Select visible items",
|
|
13539
|
+
checked: all,
|
|
13540
|
+
indeterminate: picked > 0 && !all,
|
|
13541
|
+
disabled: !enabledKeys.length,
|
|
13542
|
+
onCheckedChange: (checked) => changeSelection(updateKeys(selected, enabledKeys, checked))
|
|
13543
|
+
}
|
|
13544
|
+
),
|
|
13545
|
+
/* @__PURE__ */ jsx49("span", { className: "mt-data-list-count", "aria-live": "polite", children: zh ? `\u5DF2\u9009\u62E9 ${selected.size} \u9879` : `${selected.size} selected` }),
|
|
13546
|
+
selected.size > 0 && /* @__PURE__ */ jsxs43("div", { className: "mt-data-list-actions", children: [
|
|
13547
|
+
renderBatchActions?.({
|
|
13548
|
+
selectedKeys: [...selected],
|
|
13549
|
+
clearSelection
|
|
13550
|
+
}),
|
|
13551
|
+
/* @__PURE__ */ jsx49(
|
|
13552
|
+
Button,
|
|
13553
|
+
{
|
|
13554
|
+
variant: "ghost",
|
|
13555
|
+
type: "button",
|
|
13556
|
+
onClick: clearSelection,
|
|
13557
|
+
children: zh ? "\u6E05\u9664\u9009\u62E9" : "Clear selection"
|
|
13558
|
+
}
|
|
13559
|
+
)
|
|
13560
|
+
] })
|
|
13561
|
+
] }),
|
|
13562
|
+
search && /* @__PURE__ */ jsx49(
|
|
13563
|
+
Input.Search,
|
|
13564
|
+
{
|
|
13565
|
+
"aria-label": search.label ?? (zh ? "\u641C\u7D22\u5217\u8868" : "Search list"),
|
|
13566
|
+
placeholder: search.placeholder ?? (zh ? "\u641C\u7D22\u2026" : "Search\u2026"),
|
|
13567
|
+
value: query,
|
|
13568
|
+
onChange: (event) => changeQuery(event.currentTarget.value),
|
|
13569
|
+
allowClear: true
|
|
13570
|
+
}
|
|
13571
|
+
)
|
|
13572
|
+
] }),
|
|
13573
|
+
end: hasTrailingControls && /* @__PURE__ */ jsxs43(Fragment24, { children: [
|
|
13574
|
+
hasFilters && /* @__PURE__ */ jsx49("div", { className: "mt-data-list-filters", children: filters }),
|
|
13575
|
+
hasToolbar && toolbar
|
|
13576
|
+
] })
|
|
13577
|
+
}
|
|
13578
|
+
),
|
|
13579
|
+
/* @__PURE__ */ jsx49(
|
|
13113
13580
|
List,
|
|
13114
13581
|
{
|
|
13115
13582
|
items: visible,
|
|
13116
13583
|
getKey: (row) => row.key,
|
|
13117
13584
|
loading,
|
|
13118
13585
|
loadingContent: zh ? "\u52A0\u8F7D\u4E2D\u2026" : "Loading\u2026",
|
|
13119
|
-
emptyContent:
|
|
13586
|
+
emptyContent: empty ?? (zh ? "\u6682\u65E0\u6570\u636E" : "No items"),
|
|
13120
13587
|
renderItem: ({ item, key }, index) => {
|
|
13121
13588
|
const label = getLabel?.(item) ?? String(key);
|
|
13122
13589
|
const isExpanded = expanded.has(key);
|
|
@@ -13131,17 +13598,17 @@ function DataList({
|
|
|
13131
13598
|
expansion.onChange?.(next);
|
|
13132
13599
|
}
|
|
13133
13600
|
} : void 0;
|
|
13134
|
-
return /* @__PURE__ */
|
|
13601
|
+
return /* @__PURE__ */ jsx49(
|
|
13135
13602
|
DataListRow,
|
|
13136
13603
|
{
|
|
13137
|
-
checkbox: selection && /* @__PURE__ */
|
|
13604
|
+
checkbox: selection && /* @__PURE__ */ jsx49(
|
|
13138
13605
|
Checkbox,
|
|
13139
13606
|
{
|
|
13140
13607
|
className: "mt-data-list-row-check",
|
|
13141
13608
|
checked: selected.has(key),
|
|
13142
13609
|
disabled: selection.getDisabled?.(item),
|
|
13143
13610
|
onCheckedChange: (checked) => changeSelection(updateKeys(selected, [key], checked)),
|
|
13144
|
-
children: /* @__PURE__ */
|
|
13611
|
+
children: /* @__PURE__ */ jsx49("span", { className: "mt-data-list-sr-only", children: zh ? `\u9009\u62E9 ${label}` : `Select ${label}` })
|
|
13145
13612
|
}
|
|
13146
13613
|
),
|
|
13147
13614
|
actions: renderActions?.(item),
|
|
@@ -13152,7 +13619,7 @@ function DataList({
|
|
|
13152
13619
|
}
|
|
13153
13620
|
}
|
|
13154
13621
|
),
|
|
13155
|
-
pagination && /* @__PURE__ */
|
|
13622
|
+
pagination && /* @__PURE__ */ jsx49(
|
|
13156
13623
|
Pagination,
|
|
13157
13624
|
{
|
|
13158
13625
|
className: "mt-data-list-pagination",
|
|
@@ -13166,8 +13633,8 @@ function DataList({
|
|
|
13166
13633
|
}
|
|
13167
13634
|
|
|
13168
13635
|
// src/card-group.tsx
|
|
13169
|
-
import * as
|
|
13170
|
-
import { jsx as
|
|
13636
|
+
import * as React50 from "react";
|
|
13637
|
+
import { jsx as jsx50 } from "react/jsx-runtime";
|
|
13171
13638
|
var breakpoints3 = [
|
|
13172
13639
|
"xs",
|
|
13173
13640
|
"sm",
|
|
@@ -13177,7 +13644,7 @@ var breakpoints3 = [
|
|
|
13177
13644
|
"xxl"
|
|
13178
13645
|
];
|
|
13179
13646
|
var defaults = { xs: 1, sm: 2, lg: 3 };
|
|
13180
|
-
var ItemLayout =
|
|
13647
|
+
var ItemLayout = React50.createContext({});
|
|
13181
13648
|
function values(value, fallback, integer2) {
|
|
13182
13649
|
let previous = fallback;
|
|
13183
13650
|
return breakpoints3.map((key) => {
|
|
@@ -13194,8 +13661,8 @@ function CardGroupItem({
|
|
|
13194
13661
|
style,
|
|
13195
13662
|
...props
|
|
13196
13663
|
}) {
|
|
13197
|
-
const layout =
|
|
13198
|
-
return /* @__PURE__ */
|
|
13664
|
+
const layout = React50.useContext(ItemLayout);
|
|
13665
|
+
return /* @__PURE__ */ jsx50(
|
|
13199
13666
|
"div",
|
|
13200
13667
|
{
|
|
13201
13668
|
...props,
|
|
@@ -13205,10 +13672,10 @@ function CardGroupItem({
|
|
|
13205
13672
|
);
|
|
13206
13673
|
}
|
|
13207
13674
|
function flatten(children, prefix = "") {
|
|
13208
|
-
return
|
|
13209
|
-
const key = `${prefix}/${
|
|
13210
|
-
if (
|
|
13211
|
-
return child.type ===
|
|
13675
|
+
return React50.Children.toArray(children).flatMap((child, index) => {
|
|
13676
|
+
const key = `${prefix}/${React50.isValidElement(child) ? child.key ?? index : index}`;
|
|
13677
|
+
if (React50.isValidElement(child)) {
|
|
13678
|
+
return child.type === React50.Fragment ? flatten(child.props.children, key) : [React50.cloneElement(child, { key })];
|
|
13212
13679
|
}
|
|
13213
13680
|
return [child];
|
|
13214
13681
|
});
|
|
@@ -13231,7 +13698,7 @@ function CardGroupRoot({
|
|
|
13231
13698
|
rootStyle[`--mt-card-group-gap-${key}`] = `${gaps[i]}px`;
|
|
13232
13699
|
});
|
|
13233
13700
|
const cursors = breakpoints3.map(() => ({ column: 0, row: 0 }));
|
|
13234
|
-
return /* @__PURE__ */
|
|
13701
|
+
return /* @__PURE__ */ jsx50(
|
|
13235
13702
|
"div",
|
|
13236
13703
|
{
|
|
13237
13704
|
...props,
|
|
@@ -13242,8 +13709,8 @@ function CardGroupRoot({
|
|
|
13242
13709
|
),
|
|
13243
13710
|
style: { ...rootStyle, ...style },
|
|
13244
13711
|
children: flatten(children).map((child, index) => {
|
|
13245
|
-
const explicit =
|
|
13246
|
-
const item = explicit ? child : /* @__PURE__ */
|
|
13712
|
+
const explicit = React50.isValidElement(child) && child.type === CardGroupItem;
|
|
13713
|
+
const item = explicit ? child : /* @__PURE__ */ jsx50(CardGroupItem, { children: child });
|
|
13247
13714
|
const spans = values(explicit ? child.props.span ?? 1 : 1, 1, true);
|
|
13248
13715
|
const layout = {};
|
|
13249
13716
|
breakpoints3.forEach((key, i) => {
|
|
@@ -13263,13 +13730,13 @@ function CardGroupRoot({
|
|
|
13263
13730
|
}
|
|
13264
13731
|
}
|
|
13265
13732
|
});
|
|
13266
|
-
return /* @__PURE__ */
|
|
13733
|
+
return /* @__PURE__ */ jsx50(
|
|
13267
13734
|
ItemLayout.Provider,
|
|
13268
13735
|
{
|
|
13269
13736
|
value: layout,
|
|
13270
13737
|
children: item
|
|
13271
13738
|
},
|
|
13272
|
-
|
|
13739
|
+
React50.isValidElement(child) ? child.key ?? index : index
|
|
13273
13740
|
);
|
|
13274
13741
|
})
|
|
13275
13742
|
}
|
|
@@ -13278,8 +13745,8 @@ function CardGroupRoot({
|
|
|
13278
13745
|
var CardGroup = Object.assign(CardGroupRoot, { Item: CardGroupItem });
|
|
13279
13746
|
|
|
13280
13747
|
// src/questionnaire.tsx
|
|
13281
|
-
import * as
|
|
13282
|
-
import { Fragment as
|
|
13748
|
+
import * as React51 from "react";
|
|
13749
|
+
import { Fragment as Fragment26, jsx as jsx51, jsxs as jsxs44 } from "react/jsx-runtime";
|
|
13283
13750
|
function validateItems(items) {
|
|
13284
13751
|
const ids = /* @__PURE__ */ new Set();
|
|
13285
13752
|
for (const item of items) {
|
|
@@ -13321,21 +13788,21 @@ function Questionnaire({
|
|
|
13321
13788
|
...props
|
|
13322
13789
|
}) {
|
|
13323
13790
|
const zh = useMtone().locale === "zh";
|
|
13324
|
-
const id =
|
|
13791
|
+
const id = React51.useId();
|
|
13325
13792
|
validateItems(items);
|
|
13326
|
-
const [draft, setDraft] =
|
|
13327
|
-
const [step, setStep] =
|
|
13328
|
-
const [error, setError] =
|
|
13329
|
-
const [phase, setPhase] =
|
|
13793
|
+
const [draft, setDraft] = React51.useState(defaultAnswers);
|
|
13794
|
+
const [step, setStep] = React51.useState(0);
|
|
13795
|
+
const [error, setError] = React51.useState();
|
|
13796
|
+
const [phase, setPhase] = React51.useState(
|
|
13330
13797
|
"editing"
|
|
13331
13798
|
);
|
|
13332
|
-
const submitting =
|
|
13333
|
-
const heading =
|
|
13334
|
-
const shouldFocus =
|
|
13799
|
+
const submitting = React51.useRef(false);
|
|
13800
|
+
const heading = React51.useRef(null);
|
|
13801
|
+
const shouldFocus = React51.useRef(false);
|
|
13335
13802
|
const index = Math.min(step, Math.max(items.length - 1, 0));
|
|
13336
13803
|
const item = items[index];
|
|
13337
13804
|
const current = answers ?? draft;
|
|
13338
|
-
|
|
13805
|
+
React51.useEffect(() => {
|
|
13339
13806
|
if (shouldFocus.current) {
|
|
13340
13807
|
heading.current?.focus();
|
|
13341
13808
|
shouldFocus.current = false;
|
|
@@ -13416,16 +13883,16 @@ function Questionnaire({
|
|
|
13416
13883
|
}
|
|
13417
13884
|
let content2;
|
|
13418
13885
|
if (phase === "done")
|
|
13419
|
-
content2 = /* @__PURE__ */
|
|
13420
|
-
else if (!item) content2 = /* @__PURE__ */
|
|
13886
|
+
content2 = /* @__PURE__ */ jsx51("h3", { ref: heading, tabIndex: -1, children: zh ? "\u5DF2\u63D0\u4EA4\u7B54\u5377" : "Responses submitted" });
|
|
13887
|
+
else if (!item) content2 = /* @__PURE__ */ jsx51("p", { children: zh ? "\u6682\u65E0\u95EE\u9898" : "No questions" });
|
|
13421
13888
|
else {
|
|
13422
13889
|
const text = answer?.type === "text" ? answer.value : "";
|
|
13423
13890
|
const selected = answer?.type === "choices" ? answer.values : [];
|
|
13424
13891
|
const progress = zh ? `\u7B2C ${index + 1} \u9898\uFF0C\u5171 ${items.length} \u9898` : `Question ${index + 1} of ${items.length}`;
|
|
13425
|
-
content2 = /* @__PURE__ */
|
|
13426
|
-
/* @__PURE__ */
|
|
13427
|
-
/* @__PURE__ */
|
|
13428
|
-
/* @__PURE__ */
|
|
13892
|
+
content2 = /* @__PURE__ */ jsxs44(Fragment26, { children: [
|
|
13893
|
+
/* @__PURE__ */ jsxs44("div", { className: "mt-questionnaire-progress", children: [
|
|
13894
|
+
/* @__PURE__ */ jsx51("span", { children: progress }),
|
|
13895
|
+
/* @__PURE__ */ jsx51(
|
|
13429
13896
|
Progress,
|
|
13430
13897
|
{
|
|
13431
13898
|
value: 100 * (index + 1) / items.length,
|
|
@@ -13433,7 +13900,7 @@ function Questionnaire({
|
|
|
13433
13900
|
}
|
|
13434
13901
|
)
|
|
13435
13902
|
] }),
|
|
13436
|
-
/* @__PURE__ */
|
|
13903
|
+
/* @__PURE__ */ jsxs44(
|
|
13437
13904
|
"div",
|
|
13438
13905
|
{
|
|
13439
13906
|
className: "mt-questionnaire-main",
|
|
@@ -13441,10 +13908,10 @@ function Questionnaire({
|
|
|
13441
13908
|
"aria-labelledby": titleId,
|
|
13442
13909
|
"aria-describedby": described,
|
|
13443
13910
|
children: [
|
|
13444
|
-
/* @__PURE__ */
|
|
13445
|
-
item.description != null && /* @__PURE__ */
|
|
13446
|
-
item.type === "single" && /* @__PURE__ */
|
|
13447
|
-
/* @__PURE__ */
|
|
13911
|
+
/* @__PURE__ */ jsx51("h3", { id: titleId, ref: heading, tabIndex: -1, children: item.title }),
|
|
13912
|
+
item.description != null && /* @__PURE__ */ jsx51("div", { id: descriptionId, className: "mt-questionnaire-description", children: item.description }),
|
|
13913
|
+
item.type === "single" && /* @__PURE__ */ jsxs44(Fragment26, { children: [
|
|
13914
|
+
/* @__PURE__ */ jsx51(
|
|
13448
13915
|
RadioGroup,
|
|
13449
13916
|
{
|
|
13450
13917
|
"aria-labelledby": titleId,
|
|
@@ -13467,7 +13934,7 @@ function Questionnaire({
|
|
|
13467
13934
|
disabled
|
|
13468
13935
|
}
|
|
13469
13936
|
),
|
|
13470
|
-
item.other && answer?.type === "text" && /* @__PURE__ */
|
|
13937
|
+
item.other && answer?.type === "text" && /* @__PURE__ */ jsx51(
|
|
13471
13938
|
Input,
|
|
13472
13939
|
{
|
|
13473
13940
|
"aria-label": item.other.label ?? (zh ? "\u5176\u4ED6\u7B54\u6848" : "Other answer"),
|
|
@@ -13484,7 +13951,7 @@ function Questionnaire({
|
|
|
13484
13951
|
}
|
|
13485
13952
|
)
|
|
13486
13953
|
] }),
|
|
13487
|
-
item.type === "multiple" && /* @__PURE__ */
|
|
13954
|
+
item.type === "multiple" && /* @__PURE__ */ jsx51("div", { className: "mt-questionnaire-checks", children: item.choices.map((choice) => /* @__PURE__ */ jsx51(
|
|
13488
13955
|
Checkbox,
|
|
13489
13956
|
{
|
|
13490
13957
|
checked: selected.includes(choice.value),
|
|
@@ -13504,7 +13971,7 @@ function Questionnaire({
|
|
|
13504
13971
|
},
|
|
13505
13972
|
choice.value
|
|
13506
13973
|
)) }),
|
|
13507
|
-
item.type === "text" && /* @__PURE__ */
|
|
13974
|
+
item.type === "text" && /* @__PURE__ */ jsx51(
|
|
13508
13975
|
Input.TextArea,
|
|
13509
13976
|
{
|
|
13510
13977
|
rows: 3,
|
|
@@ -13518,13 +13985,13 @@ function Questionnaire({
|
|
|
13518
13985
|
onChange: (e) => change({ type: "text", value: e.currentTarget.value })
|
|
13519
13986
|
}
|
|
13520
13987
|
),
|
|
13521
|
-
error && /* @__PURE__ */
|
|
13988
|
+
error && /* @__PURE__ */ jsx51("div", { id: errorId, role: "alert", className: "mt-questionnaire-error", children: error === "required" ? zh ? "\u8BF7\u5148\u56DE\u7B54\u672C\u9898\u3002" : "Answer this question to continue." : zh ? "\u63D0\u4EA4\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002" : "Could not submit. Try again." })
|
|
13522
13989
|
]
|
|
13523
13990
|
},
|
|
13524
13991
|
item.id
|
|
13525
13992
|
),
|
|
13526
|
-
/* @__PURE__ */
|
|
13527
|
-
/* @__PURE__ */
|
|
13993
|
+
/* @__PURE__ */ jsxs44("div", { className: "mt-questionnaire-actions", children: [
|
|
13994
|
+
/* @__PURE__ */ jsx51(
|
|
13528
13995
|
Button,
|
|
13529
13996
|
{
|
|
13530
13997
|
type: "button",
|
|
@@ -13534,8 +14001,8 @@ function Questionnaire({
|
|
|
13534
14001
|
children: zh ? "\u4E0A\u4E00\u9898" : "Previous"
|
|
13535
14002
|
}
|
|
13536
14003
|
),
|
|
13537
|
-
/* @__PURE__ */
|
|
13538
|
-
!item.required && /* @__PURE__ */
|
|
14004
|
+
/* @__PURE__ */ jsxs44("div", { className: "mt-questionnaire-forward", children: [
|
|
14005
|
+
!item.required && /* @__PURE__ */ jsx51(
|
|
13539
14006
|
Button,
|
|
13540
14007
|
{
|
|
13541
14008
|
type: "button",
|
|
@@ -13545,7 +14012,7 @@ function Questionnaire({
|
|
|
13545
14012
|
children: zh ? "\u8DF3\u8FC7" : "Skip"
|
|
13546
14013
|
}
|
|
13547
14014
|
),
|
|
13548
|
-
/* @__PURE__ */
|
|
14015
|
+
/* @__PURE__ */ jsx51(
|
|
13549
14016
|
Button,
|
|
13550
14017
|
{
|
|
13551
14018
|
type: "button",
|
|
@@ -13559,7 +14026,7 @@ function Questionnaire({
|
|
|
13559
14026
|
] })
|
|
13560
14027
|
] });
|
|
13561
14028
|
}
|
|
13562
|
-
return /* @__PURE__ */
|
|
14029
|
+
return /* @__PURE__ */ jsx51(
|
|
13563
14030
|
"div",
|
|
13564
14031
|
{
|
|
13565
14032
|
...props,
|
|
@@ -13571,24 +14038,24 @@ function Questionnaire({
|
|
|
13571
14038
|
}
|
|
13572
14039
|
|
|
13573
14040
|
// src/ai-chat.tsx
|
|
13574
|
-
import * as
|
|
13575
|
-
import { ArrowDown as ArrowDown2, ArrowUp as ArrowUp2, Paperclip, Square, X as
|
|
13576
|
-
import { Fragment as
|
|
14041
|
+
import * as React52 from "react";
|
|
14042
|
+
import { ArrowDown as ArrowDown2, ArrowUp as ArrowUp2, Paperclip, Square, X as X14 } from "lucide-react";
|
|
14043
|
+
import { Fragment as Fragment27, jsx as jsx52, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
13577
14044
|
function AiChat({
|
|
13578
14045
|
autoFollow = true,
|
|
13579
14046
|
bottomThreshold = 64,
|
|
13580
14047
|
scrollToBottomLabel,
|
|
13581
|
-
empty
|
|
14048
|
+
empty,
|
|
13582
14049
|
footer,
|
|
13583
14050
|
children,
|
|
13584
14051
|
className,
|
|
13585
14052
|
...props
|
|
13586
14053
|
}) {
|
|
13587
14054
|
const { locale } = useMtone();
|
|
13588
|
-
const viewport =
|
|
13589
|
-
const follow =
|
|
13590
|
-
const [atBottom, setAtBottom] =
|
|
13591
|
-
const jump =
|
|
14055
|
+
const viewport = React52.useRef(null), content2 = React52.useRef(null);
|
|
14056
|
+
const follow = React52.useRef(true);
|
|
14057
|
+
const [atBottom, setAtBottom] = React52.useState(true);
|
|
14058
|
+
const jump = React52.useCallback(() => {
|
|
13592
14059
|
const el = viewport.current;
|
|
13593
14060
|
if (el) {
|
|
13594
14061
|
el.scrollTop = el.scrollHeight;
|
|
@@ -13596,7 +14063,7 @@ function AiChat({
|
|
|
13596
14063
|
setAtBottom(true);
|
|
13597
14064
|
}
|
|
13598
14065
|
}, []);
|
|
13599
|
-
const update =
|
|
14066
|
+
const update = React52.useCallback(() => {
|
|
13600
14067
|
if (autoFollow && follow.current) jump();
|
|
13601
14068
|
else {
|
|
13602
14069
|
const el = viewport.current;
|
|
@@ -13606,16 +14073,16 @@ function AiChat({
|
|
|
13606
14073
|
);
|
|
13607
14074
|
}
|
|
13608
14075
|
}, [autoFollow, jump, bottomThreshold]);
|
|
13609
|
-
|
|
13610
|
-
|
|
14076
|
+
React52.useEffect(update, [children, update]);
|
|
14077
|
+
React52.useEffect(() => {
|
|
13611
14078
|
if (typeof ResizeObserver === "undefined") return;
|
|
13612
14079
|
const observer = new ResizeObserver(update);
|
|
13613
14080
|
if (content2.current) observer.observe(content2.current);
|
|
13614
14081
|
if (viewport.current) observer.observe(viewport.current);
|
|
13615
14082
|
return () => observer.disconnect();
|
|
13616
14083
|
}, [update]);
|
|
13617
|
-
return /* @__PURE__ */
|
|
13618
|
-
/* @__PURE__ */
|
|
14084
|
+
return /* @__PURE__ */ jsxs45("div", { ...props, className: cn("mt-ai-chat", className), children: [
|
|
14085
|
+
/* @__PURE__ */ jsx52(
|
|
13619
14086
|
"div",
|
|
13620
14087
|
{
|
|
13621
14088
|
ref: viewport,
|
|
@@ -13630,10 +14097,10 @@ function AiChat({
|
|
|
13630
14097
|
follow.current = near;
|
|
13631
14098
|
setAtBottom(near);
|
|
13632
14099
|
},
|
|
13633
|
-
children: /* @__PURE__ */
|
|
14100
|
+
children: /* @__PURE__ */ jsx52("div", { ref: content2, className: "mt-ai-chat-content", children: React52.Children.toArray(children).length ? children : empty })
|
|
13634
14101
|
}
|
|
13635
14102
|
),
|
|
13636
|
-
!atBottom && /* @__PURE__ */
|
|
14103
|
+
!atBottom && /* @__PURE__ */ jsx52("div", { className: "mt-ai-chat-jump", children: /* @__PURE__ */ jsx52(
|
|
13637
14104
|
Button,
|
|
13638
14105
|
{
|
|
13639
14106
|
size: "sm",
|
|
@@ -13641,11 +14108,11 @@ function AiChat({
|
|
|
13641
14108
|
jump();
|
|
13642
14109
|
viewport.current?.focus({ preventScroll: true });
|
|
13643
14110
|
},
|
|
13644
|
-
icon: /* @__PURE__ */
|
|
14111
|
+
icon: /* @__PURE__ */ jsx52(ArrowDown2, { size: 14, "aria-hidden": "true" }),
|
|
13645
14112
|
children: scrollToBottomLabel ?? (locale === "zh" ? "\u56DE\u5230\u6700\u65B0\u6D88\u606F" : "Jump to latest")
|
|
13646
14113
|
}
|
|
13647
14114
|
) }),
|
|
13648
|
-
footer != null && /* @__PURE__ */
|
|
14115
|
+
footer != null && /* @__PURE__ */ jsx52("div", { className: "mt-ai-chat-footer", children: footer })
|
|
13649
14116
|
] });
|
|
13650
14117
|
}
|
|
13651
14118
|
function AiMessage({
|
|
@@ -13665,7 +14132,7 @@ function AiMessage({
|
|
|
13665
14132
|
assistant: locale === "zh" ? "\u52A9\u624B" : "Assistant",
|
|
13666
14133
|
system: locale === "zh" ? "\u7CFB\u7EDF" : "System"
|
|
13667
14134
|
}[from];
|
|
13668
|
-
return /* @__PURE__ */
|
|
14135
|
+
return /* @__PURE__ */ jsxs45(
|
|
13669
14136
|
"article",
|
|
13670
14137
|
{
|
|
13671
14138
|
...props,
|
|
@@ -13673,12 +14140,12 @@ function AiMessage({
|
|
|
13673
14140
|
"data-from": from,
|
|
13674
14141
|
"data-status": status,
|
|
13675
14142
|
children: [
|
|
13676
|
-
avatar != null && /* @__PURE__ */
|
|
13677
|
-
/* @__PURE__ */
|
|
13678
|
-
/* @__PURE__ */
|
|
13679
|
-
/* @__PURE__ */
|
|
13680
|
-
status !== "idle" && /* @__PURE__ */
|
|
13681
|
-
actions != null && /* @__PURE__ */
|
|
14143
|
+
avatar != null && /* @__PURE__ */ jsx52("div", { className: "mt-ai-message-avatar", children: avatar }),
|
|
14144
|
+
/* @__PURE__ */ jsxs45("div", { className: "mt-ai-message-main", children: [
|
|
14145
|
+
/* @__PURE__ */ jsx52("div", { className: "mt-ai-message-name", children: sender }),
|
|
14146
|
+
/* @__PURE__ */ jsx52("div", { className: "mt-ai-message-body", children }),
|
|
14147
|
+
status !== "idle" && /* @__PURE__ */ jsx52("div", { className: "mt-ai-message-status", role: "status", children: statusLabel ?? (status === "streaming" ? locale === "zh" ? "\u751F\u6210\u4E2D" : "Generating" : locale === "zh" ? "\u751F\u6210\u5931\u8D25" : "Generation failed") }),
|
|
14148
|
+
actions != null && /* @__PURE__ */ jsx52("div", { className: "mt-ai-message-actions", children: actions })
|
|
13682
14149
|
] })
|
|
13683
14150
|
]
|
|
13684
14151
|
}
|
|
@@ -13708,10 +14175,10 @@ function AiPromptInput({
|
|
|
13708
14175
|
}) {
|
|
13709
14176
|
const { locale } = useMtone();
|
|
13710
14177
|
const zh = locale === "zh";
|
|
13711
|
-
const [local, setLocal] =
|
|
13712
|
-
const lock =
|
|
13713
|
-
const mounted =
|
|
13714
|
-
|
|
14178
|
+
const [local, setLocal] = React52.useState(defaultValue), [pending, setPending] = React52.useState(false), [failed, setFailed] = React52.useState(false);
|
|
14179
|
+
const lock = React52.useRef(false), composing = React52.useRef(false), file = React52.useRef(null);
|
|
14180
|
+
const mounted = React52.useRef(true);
|
|
14181
|
+
React52.useEffect(() => {
|
|
13715
14182
|
mounted.current = true;
|
|
13716
14183
|
return () => {
|
|
13717
14184
|
mounted.current = false;
|
|
@@ -13740,9 +14207,9 @@ function AiPromptInput({
|
|
|
13740
14207
|
setFailed(true);
|
|
13741
14208
|
}
|
|
13742
14209
|
};
|
|
13743
|
-
const errorId =
|
|
14210
|
+
const errorId = React52.useId();
|
|
13744
14211
|
const message = error ?? (failed ? zh ? "\u53D1\u9001\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002" : "Could not send. Please retry." : null);
|
|
13745
|
-
return /* @__PURE__ */
|
|
14212
|
+
return /* @__PURE__ */ jsxs45(
|
|
13746
14213
|
"div",
|
|
13747
14214
|
{
|
|
13748
14215
|
...props,
|
|
@@ -13750,18 +14217,18 @@ function AiPromptInput({
|
|
|
13750
14217
|
"data-status": status,
|
|
13751
14218
|
"aria-busy": busy,
|
|
13752
14219
|
children: [
|
|
13753
|
-
attachments.length > 0 && /* @__PURE__ */
|
|
14220
|
+
attachments.length > 0 && /* @__PURE__ */ jsx52(
|
|
13754
14221
|
"ul",
|
|
13755
14222
|
{
|
|
13756
14223
|
className: "mt-ai-prompt-attachments",
|
|
13757
14224
|
"aria-label": zh ? "\u9644\u4EF6" : "Attachments",
|
|
13758
|
-
children: attachments.map((a) => /* @__PURE__ */
|
|
13759
|
-
/* @__PURE__ */
|
|
13760
|
-
a.size !== void 0 && /* @__PURE__ */
|
|
14225
|
+
children: attachments.map((a) => /* @__PURE__ */ jsxs45("li", { children: [
|
|
14226
|
+
/* @__PURE__ */ jsx52("span", { title: a.name, children: a.name }),
|
|
14227
|
+
a.size !== void 0 && /* @__PURE__ */ jsxs45("small", { children: [
|
|
13761
14228
|
Math.max(0, a.size),
|
|
13762
14229
|
" B"
|
|
13763
14230
|
] }),
|
|
13764
|
-
onAttachmentRemove && /* @__PURE__ */
|
|
14231
|
+
onAttachmentRemove && /* @__PURE__ */ jsx52(
|
|
13765
14232
|
Button,
|
|
13766
14233
|
{
|
|
13767
14234
|
size: "sm",
|
|
@@ -13769,13 +14236,13 @@ function AiPromptInput({
|
|
|
13769
14236
|
disabled: disabled || busy,
|
|
13770
14237
|
"aria-label": `${zh ? "\u79FB\u9664" : "Remove"} ${a.name}`,
|
|
13771
14238
|
onClick: () => onAttachmentRemove(a.id),
|
|
13772
|
-
children: /* @__PURE__ */
|
|
14239
|
+
children: /* @__PURE__ */ jsx52(X14, { size: 12 })
|
|
13773
14240
|
}
|
|
13774
14241
|
)
|
|
13775
14242
|
] }, a.id))
|
|
13776
14243
|
}
|
|
13777
14244
|
),
|
|
13778
|
-
/* @__PURE__ */
|
|
14245
|
+
/* @__PURE__ */ jsx52(
|
|
13779
14246
|
Input.TextArea,
|
|
13780
14247
|
{
|
|
13781
14248
|
value: text,
|
|
@@ -13804,10 +14271,10 @@ function AiPromptInput({
|
|
|
13804
14271
|
}
|
|
13805
14272
|
}
|
|
13806
14273
|
),
|
|
13807
|
-
/* @__PURE__ */
|
|
13808
|
-
/* @__PURE__ */
|
|
13809
|
-
onFilesSelect && /* @__PURE__ */
|
|
13810
|
-
/* @__PURE__ */
|
|
14274
|
+
/* @__PURE__ */ jsxs45("div", { className: "mt-ai-prompt-toolbar", children: [
|
|
14275
|
+
/* @__PURE__ */ jsxs45("div", { className: "mt-ai-prompt-tools", children: [
|
|
14276
|
+
onFilesSelect && /* @__PURE__ */ jsxs45(Fragment27, { children: [
|
|
14277
|
+
/* @__PURE__ */ jsx52(
|
|
13811
14278
|
"input",
|
|
13812
14279
|
{
|
|
13813
14280
|
ref: file,
|
|
@@ -13824,7 +14291,7 @@ function AiPromptInput({
|
|
|
13824
14291
|
}
|
|
13825
14292
|
}
|
|
13826
14293
|
),
|
|
13827
|
-
/* @__PURE__ */
|
|
14294
|
+
/* @__PURE__ */ jsx52(
|
|
13828
14295
|
Button,
|
|
13829
14296
|
{
|
|
13830
14297
|
size: "sm",
|
|
@@ -13832,33 +14299,33 @@ function AiPromptInput({
|
|
|
13832
14299
|
disabled: disabled || busy,
|
|
13833
14300
|
"aria-label": attachmentLabel ?? (zh ? "\u6DFB\u52A0\u9644\u4EF6" : "Add attachments"),
|
|
13834
14301
|
onClick: () => file.current?.click(),
|
|
13835
|
-
children: /* @__PURE__ */
|
|
14302
|
+
children: /* @__PURE__ */ jsx52(Paperclip, { size: 15 })
|
|
13836
14303
|
}
|
|
13837
14304
|
)
|
|
13838
14305
|
] }),
|
|
13839
14306
|
toolbar
|
|
13840
14307
|
] }),
|
|
13841
|
-
busy ? /* @__PURE__ */
|
|
14308
|
+
busy ? /* @__PURE__ */ jsx52(
|
|
13842
14309
|
Button,
|
|
13843
14310
|
{
|
|
13844
14311
|
size: "sm",
|
|
13845
14312
|
disabled: disabled || !onStop,
|
|
13846
14313
|
onClick: onStop,
|
|
13847
|
-
icon: /* @__PURE__ */
|
|
14314
|
+
icon: /* @__PURE__ */ jsx52(Square, { size: 12 }),
|
|
13848
14315
|
children: stopLabel ?? (zh ? "\u505C\u6B62\u751F\u6210" : "Stop generating")
|
|
13849
14316
|
}
|
|
13850
|
-
) : /* @__PURE__ */
|
|
14317
|
+
) : /* @__PURE__ */ jsx52(
|
|
13851
14318
|
Button,
|
|
13852
14319
|
{
|
|
13853
14320
|
size: "sm",
|
|
13854
14321
|
disabled: disabled || !text.trim() && !attachments.length,
|
|
13855
14322
|
onClick: send,
|
|
13856
|
-
icon: /* @__PURE__ */
|
|
14323
|
+
icon: /* @__PURE__ */ jsx52(ArrowUp2, { size: 14 }),
|
|
13857
14324
|
children: submitLabel ?? (zh ? "\u53D1\u9001" : "Send")
|
|
13858
14325
|
}
|
|
13859
14326
|
)
|
|
13860
14327
|
] }),
|
|
13861
|
-
message != null && /* @__PURE__ */
|
|
14328
|
+
message != null && /* @__PURE__ */ jsx52("div", { id: errorId, role: "alert", className: "mt-ai-prompt-error", children: message })
|
|
13862
14329
|
]
|
|
13863
14330
|
}
|
|
13864
14331
|
);
|
|
@@ -13871,7 +14338,7 @@ function AiSuggestion({
|
|
|
13871
14338
|
className,
|
|
13872
14339
|
...props
|
|
13873
14340
|
}) {
|
|
13874
|
-
return /* @__PURE__ */
|
|
14341
|
+
return /* @__PURE__ */ jsx52(
|
|
13875
14342
|
Button,
|
|
13876
14343
|
{
|
|
13877
14344
|
variant: "outline",
|
|
@@ -13899,8 +14366,8 @@ function AiModelSelector({
|
|
|
13899
14366
|
...props
|
|
13900
14367
|
}) {
|
|
13901
14368
|
const { locale } = useMtone();
|
|
13902
|
-
return /* @__PURE__ */
|
|
13903
|
-
/* @__PURE__ */
|
|
14369
|
+
return /* @__PURE__ */ jsxs45("div", { ...props, className: cn("mt-ai-model-selector", className), children: [
|
|
14370
|
+
/* @__PURE__ */ jsx52(
|
|
13904
14371
|
Select,
|
|
13905
14372
|
{
|
|
13906
14373
|
options: models,
|
|
@@ -13912,7 +14379,7 @@ function AiModelSelector({
|
|
|
13912
14379
|
label: modelLabel ?? (locale === "zh" ? "\u6A21\u578B" : "Model")
|
|
13913
14380
|
}
|
|
13914
14381
|
),
|
|
13915
|
-
efforts && /* @__PURE__ */
|
|
14382
|
+
efforts && /* @__PURE__ */ jsx52(
|
|
13916
14383
|
Select,
|
|
13917
14384
|
{
|
|
13918
14385
|
options: efforts,
|
|
@@ -13928,7 +14395,7 @@ function AiModelSelector({
|
|
|
13928
14395
|
}
|
|
13929
14396
|
|
|
13930
14397
|
// src/ai-activity.tsx
|
|
13931
|
-
import * as
|
|
14398
|
+
import * as React53 from "react";
|
|
13932
14399
|
import {
|
|
13933
14400
|
Check as Check7,
|
|
13934
14401
|
ChevronRight as ChevronRight12,
|
|
@@ -13936,9 +14403,9 @@ import {
|
|
|
13936
14403
|
CircleAlert,
|
|
13937
14404
|
LoaderCircle as LoaderCircle10,
|
|
13938
14405
|
RotateCcw as RotateCcw2,
|
|
13939
|
-
X as
|
|
14406
|
+
X as X15
|
|
13940
14407
|
} from "lucide-react";
|
|
13941
|
-
import { Fragment as
|
|
14408
|
+
import { Fragment as Fragment28, jsx as jsx53, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
13942
14409
|
var statusNames = {
|
|
13943
14410
|
zh: {
|
|
13944
14411
|
pending: "\u5F85\u5904\u7406",
|
|
@@ -13965,11 +14432,11 @@ function ActivityStatus({
|
|
|
13965
14432
|
running: LoaderCircle10,
|
|
13966
14433
|
completed: Check7,
|
|
13967
14434
|
error: CircleAlert,
|
|
13968
|
-
cancelled:
|
|
14435
|
+
cancelled: X15
|
|
13969
14436
|
}[status];
|
|
13970
|
-
return /* @__PURE__ */
|
|
13971
|
-
/* @__PURE__ */
|
|
13972
|
-
/* @__PURE__ */
|
|
14437
|
+
return /* @__PURE__ */ jsxs46("span", { className: "mt-ai-activity-status", "data-status": status, children: [
|
|
14438
|
+
/* @__PURE__ */ jsx53(Icon, { size: 14, "aria-hidden": "true" }),
|
|
14439
|
+
/* @__PURE__ */ jsx53("span", { children: label ?? statusNames[locale === "en" ? "en" : "zh"][status] })
|
|
13973
14440
|
] });
|
|
13974
14441
|
}
|
|
13975
14442
|
function ActivityDisclosure({
|
|
@@ -13983,18 +14450,18 @@ function ActivityDisclosure({
|
|
|
13983
14450
|
className,
|
|
13984
14451
|
...props
|
|
13985
14452
|
}) {
|
|
13986
|
-
const [internalOpen, setInternalOpen] =
|
|
14453
|
+
const [internalOpen, setInternalOpen] = React53.useState(defaultOpen);
|
|
13987
14454
|
const expanded = open ?? internalOpen;
|
|
13988
|
-
const id =
|
|
13989
|
-
return /* @__PURE__ */
|
|
14455
|
+
const id = React53.useId();
|
|
14456
|
+
return /* @__PURE__ */ jsxs46(
|
|
13990
14457
|
"div",
|
|
13991
14458
|
{
|
|
13992
14459
|
...props,
|
|
13993
14460
|
className: cn("mt-ai-activity", className),
|
|
13994
14461
|
"data-status": status,
|
|
13995
14462
|
children: [
|
|
13996
|
-
/* @__PURE__ */
|
|
13997
|
-
/* @__PURE__ */
|
|
14463
|
+
/* @__PURE__ */ jsxs46("div", { className: "mt-ai-activity-header", children: [
|
|
14464
|
+
/* @__PURE__ */ jsxs46(
|
|
13998
14465
|
"button",
|
|
13999
14466
|
{
|
|
14000
14467
|
type: "button",
|
|
@@ -14008,7 +14475,7 @@ function ActivityDisclosure({
|
|
|
14008
14475
|
onOpenChange?.(!expanded);
|
|
14009
14476
|
},
|
|
14010
14477
|
children: [
|
|
14011
|
-
/* @__PURE__ */
|
|
14478
|
+
/* @__PURE__ */ jsx53(
|
|
14012
14479
|
ChevronRight12,
|
|
14013
14480
|
{
|
|
14014
14481
|
size: 14,
|
|
@@ -14016,13 +14483,13 @@ function ActivityDisclosure({
|
|
|
14016
14483
|
className: "mt-ai-activity-chevron"
|
|
14017
14484
|
}
|
|
14018
14485
|
),
|
|
14019
|
-
/* @__PURE__ */
|
|
14486
|
+
/* @__PURE__ */ jsx53("span", { children: title })
|
|
14020
14487
|
]
|
|
14021
14488
|
}
|
|
14022
14489
|
),
|
|
14023
|
-
/* @__PURE__ */
|
|
14490
|
+
/* @__PURE__ */ jsx53(ActivityStatus, { status, label: statusLabel })
|
|
14024
14491
|
] }),
|
|
14025
|
-
/* @__PURE__ */
|
|
14492
|
+
/* @__PURE__ */ jsx53(
|
|
14026
14493
|
"div",
|
|
14027
14494
|
{
|
|
14028
14495
|
id: `${id}-content`,
|
|
@@ -14043,24 +14510,24 @@ function ActivitySteps({
|
|
|
14043
14510
|
}) {
|
|
14044
14511
|
const { locale } = useMtone();
|
|
14045
14512
|
if (!items.length)
|
|
14046
|
-
return /* @__PURE__ */
|
|
14047
|
-
return /* @__PURE__ */
|
|
14048
|
-
/* @__PURE__ */
|
|
14049
|
-
/* @__PURE__ */
|
|
14050
|
-
/* @__PURE__ */
|
|
14513
|
+
return /* @__PURE__ */ jsx53("p", { className: "mt-ai-activity-empty", children: locale === "en" ? "No items" : "\u6682\u65E0\u4E8B\u9879" });
|
|
14514
|
+
return /* @__PURE__ */ jsx53("ol", { className: "mt-ai-activity-steps", "aria-label": label, children: items.map((item) => /* @__PURE__ */ jsxs46("li", { children: [
|
|
14515
|
+
/* @__PURE__ */ jsxs46("div", { className: "mt-ai-activity-step-heading", children: [
|
|
14516
|
+
/* @__PURE__ */ jsx53("span", { children: item.title }),
|
|
14517
|
+
/* @__PURE__ */ jsx53(ActivityStatus, { status: item.status ?? "pending" })
|
|
14051
14518
|
] }),
|
|
14052
|
-
item.description != null && /* @__PURE__ */
|
|
14519
|
+
item.description != null && /* @__PURE__ */ jsx53("div", { className: "mt-ai-activity-description", children: item.description })
|
|
14053
14520
|
] }, item.id)) });
|
|
14054
14521
|
}
|
|
14055
14522
|
function AiTask({ title, steps = [], children, ...props }) {
|
|
14056
14523
|
const { locale } = useMtone();
|
|
14057
|
-
return /* @__PURE__ */
|
|
14524
|
+
return /* @__PURE__ */ jsxs46(
|
|
14058
14525
|
ActivityDisclosure,
|
|
14059
14526
|
{
|
|
14060
14527
|
...props,
|
|
14061
14528
|
title: title ?? (locale === "en" ? "Task" : "\u4EFB\u52A1"),
|
|
14062
14529
|
children: [
|
|
14063
|
-
/* @__PURE__ */
|
|
14530
|
+
/* @__PURE__ */ jsx53(ActivitySteps, { items: steps }),
|
|
14064
14531
|
children
|
|
14065
14532
|
]
|
|
14066
14533
|
}
|
|
@@ -14073,13 +14540,13 @@ function AiReasoning({
|
|
|
14073
14540
|
...props
|
|
14074
14541
|
}) {
|
|
14075
14542
|
const { locale } = useMtone();
|
|
14076
|
-
return /* @__PURE__ */
|
|
14543
|
+
return /* @__PURE__ */ jsxs46(
|
|
14077
14544
|
ActivityDisclosure,
|
|
14078
14545
|
{
|
|
14079
14546
|
...props,
|
|
14080
14547
|
title: title ?? (locale === "en" ? "Public explanation" : "\u516C\u5F00\u8FC7\u7A0B\u8BF4\u660E"),
|
|
14081
14548
|
children: [
|
|
14082
|
-
/* @__PURE__ */
|
|
14549
|
+
/* @__PURE__ */ jsx53("div", { className: "mt-ai-activity-text", children: text }),
|
|
14083
14550
|
children
|
|
14084
14551
|
]
|
|
14085
14552
|
}
|
|
@@ -14095,9 +14562,9 @@ function AiPlan({
|
|
|
14095
14562
|
const { locale } = useMtone();
|
|
14096
14563
|
const completed = items.filter((item) => item.status === "completed").length;
|
|
14097
14564
|
const label = title ?? (locale === "en" ? "Plan" : "\u8BA1\u5212");
|
|
14098
|
-
return /* @__PURE__ */
|
|
14099
|
-
!!items.length && /* @__PURE__ */
|
|
14100
|
-
/* @__PURE__ */
|
|
14565
|
+
return /* @__PURE__ */ jsxs46(ActivityDisclosure, { ...props, title: label, defaultOpen, children: [
|
|
14566
|
+
!!items.length && /* @__PURE__ */ jsxs46("div", { className: "mt-ai-activity-progress", children: [
|
|
14567
|
+
/* @__PURE__ */ jsx53(
|
|
14101
14568
|
"progress",
|
|
14102
14569
|
{
|
|
14103
14570
|
"aria-label": locale === "en" ? `${label} progress` : `${label}\u8FDB\u5EA6`,
|
|
@@ -14105,13 +14572,13 @@ function AiPlan({
|
|
|
14105
14572
|
max: items.length
|
|
14106
14573
|
}
|
|
14107
14574
|
),
|
|
14108
|
-
/* @__PURE__ */
|
|
14575
|
+
/* @__PURE__ */ jsxs46("span", { children: [
|
|
14109
14576
|
completed,
|
|
14110
14577
|
" / ",
|
|
14111
14578
|
items.length
|
|
14112
14579
|
] })
|
|
14113
14580
|
] }),
|
|
14114
|
-
/* @__PURE__ */
|
|
14581
|
+
/* @__PURE__ */ jsx53(ActivitySteps, { items }),
|
|
14115
14582
|
children
|
|
14116
14583
|
] });
|
|
14117
14584
|
}
|
|
@@ -14126,17 +14593,17 @@ function AiQueue({
|
|
|
14126
14593
|
const en = locale === "en";
|
|
14127
14594
|
const done = (item) => item.status === "completed" || item.status === "cancelled";
|
|
14128
14595
|
const remaining = items.filter((item) => !done(item)), ended = items.filter(done);
|
|
14129
|
-
return /* @__PURE__ */
|
|
14596
|
+
return /* @__PURE__ */ jsxs46(
|
|
14130
14597
|
ActivityDisclosure,
|
|
14131
14598
|
{
|
|
14132
14599
|
...props,
|
|
14133
14600
|
title: title ?? (en ? "Queue" : "\u961F\u5217"),
|
|
14134
14601
|
defaultOpen,
|
|
14135
14602
|
children: [
|
|
14136
|
-
!items.length ? /* @__PURE__ */
|
|
14137
|
-
!!remaining.length && /* @__PURE__ */
|
|
14138
|
-
/* @__PURE__ */
|
|
14139
|
-
/* @__PURE__ */
|
|
14603
|
+
!items.length ? /* @__PURE__ */ jsx53(ActivitySteps, { items: [] }) : /* @__PURE__ */ jsxs46(Fragment28, { children: [
|
|
14604
|
+
!!remaining.length && /* @__PURE__ */ jsxs46("div", { children: [
|
|
14605
|
+
/* @__PURE__ */ jsx53("div", { className: "mt-ai-activity-group-label", children: en ? "Remaining" : "\u5F85\u5B8C\u6210" }),
|
|
14606
|
+
/* @__PURE__ */ jsx53(
|
|
14140
14607
|
ActivitySteps,
|
|
14141
14608
|
{
|
|
14142
14609
|
items: remaining,
|
|
@@ -14144,9 +14611,9 @@ function AiQueue({
|
|
|
14144
14611
|
}
|
|
14145
14612
|
)
|
|
14146
14613
|
] }),
|
|
14147
|
-
!!ended.length && /* @__PURE__ */
|
|
14148
|
-
/* @__PURE__ */
|
|
14149
|
-
/* @__PURE__ */
|
|
14614
|
+
!!ended.length && /* @__PURE__ */ jsxs46("div", { children: [
|
|
14615
|
+
/* @__PURE__ */ jsx53("div", { className: "mt-ai-activity-group-label", children: en ? "Finished" : "\u5DF2\u7ED3\u675F" }),
|
|
14616
|
+
/* @__PURE__ */ jsx53(ActivitySteps, { items: ended, label: en ? "Finished" : "\u5DF2\u7ED3\u675F" })
|
|
14150
14617
|
] })
|
|
14151
14618
|
] }),
|
|
14152
14619
|
children
|
|
@@ -14163,12 +14630,12 @@ function AiSubagent({
|
|
|
14163
14630
|
...props
|
|
14164
14631
|
}) {
|
|
14165
14632
|
const { locale } = useMtone();
|
|
14166
|
-
return /* @__PURE__ */
|
|
14167
|
-
description != null && /* @__PURE__ */
|
|
14633
|
+
return /* @__PURE__ */ jsxs46(ActivityDisclosure, { ...props, title: title ?? name, children: [
|
|
14634
|
+
description != null && /* @__PURE__ */ jsx53("div", { className: "mt-ai-activity-description", children: description }),
|
|
14168
14635
|
children,
|
|
14169
|
-
result != null && /* @__PURE__ */
|
|
14170
|
-
/* @__PURE__ */
|
|
14171
|
-
/* @__PURE__ */
|
|
14636
|
+
result != null && /* @__PURE__ */ jsxs46("div", { children: [
|
|
14637
|
+
/* @__PURE__ */ jsx53("div", { className: "mt-ai-activity-group-label", children: locale === "en" ? "Result" : "\u7ED3\u679C" }),
|
|
14638
|
+
/* @__PURE__ */ jsx53("div", { className: "mt-ai-activity-text", children: result })
|
|
14172
14639
|
] })
|
|
14173
14640
|
] });
|
|
14174
14641
|
}
|
|
@@ -14182,14 +14649,14 @@ function AiTool({
|
|
|
14182
14649
|
}) {
|
|
14183
14650
|
const { locale } = useMtone();
|
|
14184
14651
|
const en = locale === "en";
|
|
14185
|
-
return /* @__PURE__ */
|
|
14186
|
-
input !== void 0 && /* @__PURE__ */
|
|
14187
|
-
/* @__PURE__ */
|
|
14188
|
-
/* @__PURE__ */
|
|
14652
|
+
return /* @__PURE__ */ jsxs46(ActivityDisclosure, { ...props, title: title ?? name, children: [
|
|
14653
|
+
input !== void 0 && /* @__PURE__ */ jsxs46("div", { children: [
|
|
14654
|
+
/* @__PURE__ */ jsx53("div", { className: "mt-ai-activity-group-label", children: en ? "Input" : "\u8F93\u5165" }),
|
|
14655
|
+
/* @__PURE__ */ jsx53("pre", { className: "mt-ai-activity-code", children: input })
|
|
14189
14656
|
] }),
|
|
14190
|
-
output !== void 0 && /* @__PURE__ */
|
|
14191
|
-
/* @__PURE__ */
|
|
14192
|
-
/* @__PURE__ */
|
|
14657
|
+
output !== void 0 && /* @__PURE__ */ jsxs46("div", { children: [
|
|
14658
|
+
/* @__PURE__ */ jsx53("div", { className: "mt-ai-activity-group-label", children: en ? "Output" : "\u8F93\u51FA" }),
|
|
14659
|
+
/* @__PURE__ */ jsx53("pre", { className: "mt-ai-activity-code", children: output })
|
|
14193
14660
|
] }),
|
|
14194
14661
|
children
|
|
14195
14662
|
] });
|
|
@@ -14206,18 +14673,18 @@ function AiCheckpoint({
|
|
|
14206
14673
|
}) {
|
|
14207
14674
|
const { locale } = useMtone();
|
|
14208
14675
|
const en = locale === "en";
|
|
14209
|
-
return /* @__PURE__ */
|
|
14676
|
+
return /* @__PURE__ */ jsxs46(
|
|
14210
14677
|
"div",
|
|
14211
14678
|
{
|
|
14212
14679
|
...props,
|
|
14213
14680
|
className: cn("mt-ai-activity mt-ai-checkpoint", className),
|
|
14214
14681
|
children: [
|
|
14215
|
-
/* @__PURE__ */
|
|
14216
|
-
/* @__PURE__ */
|
|
14217
|
-
description != null && /* @__PURE__ */
|
|
14682
|
+
/* @__PURE__ */ jsxs46("div", { className: "mt-ai-checkpoint-copy", children: [
|
|
14683
|
+
/* @__PURE__ */ jsx53("div", { children: label ?? (en ? "Checkpoint" : "\u68C0\u67E5\u70B9") }),
|
|
14684
|
+
description != null && /* @__PURE__ */ jsx53("div", { className: "mt-ai-activity-description", children: description }),
|
|
14218
14685
|
children
|
|
14219
14686
|
] }),
|
|
14220
|
-
/* @__PURE__ */
|
|
14687
|
+
/* @__PURE__ */ jsxs46(
|
|
14221
14688
|
Button,
|
|
14222
14689
|
{
|
|
14223
14690
|
type: "button",
|
|
@@ -14225,7 +14692,7 @@ function AiCheckpoint({
|
|
|
14225
14692
|
disabled: disabled || !onRestore,
|
|
14226
14693
|
onClick: () => onRestore?.(),
|
|
14227
14694
|
children: [
|
|
14228
|
-
/* @__PURE__ */
|
|
14695
|
+
/* @__PURE__ */ jsx53(RotateCcw2, { size: 14, "aria-hidden": "true" }),
|
|
14229
14696
|
restoreLabel ?? (en ? "Restore" : "\u6062\u590D")
|
|
14230
14697
|
]
|
|
14231
14698
|
}
|
|
@@ -14249,7 +14716,7 @@ function AiConfirmation({
|
|
|
14249
14716
|
}) {
|
|
14250
14717
|
const { locale } = useMtone();
|
|
14251
14718
|
const en = locale === "en";
|
|
14252
|
-
return /* @__PURE__ */
|
|
14719
|
+
return /* @__PURE__ */ jsxs46(
|
|
14253
14720
|
"div",
|
|
14254
14721
|
{
|
|
14255
14722
|
...props,
|
|
@@ -14257,11 +14724,11 @@ function AiConfirmation({
|
|
|
14257
14724
|
"aria-busy": busy || void 0,
|
|
14258
14725
|
"data-state": state,
|
|
14259
14726
|
children: [
|
|
14260
|
-
/* @__PURE__ */
|
|
14261
|
-
description != null && /* @__PURE__ */
|
|
14727
|
+
/* @__PURE__ */ jsx53("div", { className: "mt-ai-confirmation-title", children: title ?? (en ? "Confirmation required" : "\u9700\u8981\u786E\u8BA4") }),
|
|
14728
|
+
description != null && /* @__PURE__ */ jsx53("div", { className: "mt-ai-activity-description", children: description }),
|
|
14262
14729
|
children,
|
|
14263
|
-
state === "pending" ? /* @__PURE__ */
|
|
14264
|
-
/* @__PURE__ */
|
|
14730
|
+
state === "pending" ? /* @__PURE__ */ jsxs46("div", { className: "mt-ai-confirmation-actions", children: [
|
|
14731
|
+
/* @__PURE__ */ jsx53(
|
|
14265
14732
|
Button,
|
|
14266
14733
|
{
|
|
14267
14734
|
type: "button",
|
|
@@ -14271,7 +14738,7 @@ function AiConfirmation({
|
|
|
14271
14738
|
children: confirmLabel ?? (en ? "Confirm" : "\u786E\u8BA4")
|
|
14272
14739
|
}
|
|
14273
14740
|
),
|
|
14274
|
-
/* @__PURE__ */
|
|
14741
|
+
/* @__PURE__ */ jsx53(
|
|
14275
14742
|
Button,
|
|
14276
14743
|
{
|
|
14277
14744
|
type: "button",
|
|
@@ -14281,16 +14748,16 @@ function AiConfirmation({
|
|
|
14281
14748
|
children: rejectLabel ?? (en ? "Reject" : "\u62D2\u7EDD")
|
|
14282
14749
|
}
|
|
14283
14750
|
)
|
|
14284
|
-
] }) : /* @__PURE__ */
|
|
14751
|
+
] }) : /* @__PURE__ */ jsx53("div", { role: "status", className: "mt-ai-activity-description", children: state === "approved" ? en ? "Confirmed" : "\u5DF2\u786E\u8BA4" : en ? "Rejected" : "\u5DF2\u62D2\u7EDD" })
|
|
14285
14752
|
]
|
|
14286
14753
|
}
|
|
14287
14754
|
);
|
|
14288
14755
|
}
|
|
14289
14756
|
|
|
14290
14757
|
// src/ai-evidence.tsx
|
|
14291
|
-
import * as
|
|
14758
|
+
import * as React54 from "react";
|
|
14292
14759
|
import { File as File2, Folder as Folder2 } from "lucide-react";
|
|
14293
|
-
import { Fragment as
|
|
14760
|
+
import { Fragment as Fragment29, jsx as jsx54, jsxs as jsxs47 } from "react/jsx-runtime";
|
|
14294
14761
|
var count = (value) => Number.isFinite(value) ? Math.max(0, Math.floor(value)) : 0;
|
|
14295
14762
|
function useEvidenceText() {
|
|
14296
14763
|
const { locale } = useMtone();
|
|
@@ -14352,33 +14819,33 @@ function AiContext({
|
|
|
14352
14819
|
const name = label ?? text.context;
|
|
14353
14820
|
const used = count(usedTokens);
|
|
14354
14821
|
const max = maxTokens === void 0 ? 0 : count(maxTokens);
|
|
14355
|
-
return /* @__PURE__ */
|
|
14822
|
+
return /* @__PURE__ */ jsxs47(
|
|
14356
14823
|
"section",
|
|
14357
14824
|
{
|
|
14358
14825
|
"aria-label": name,
|
|
14359
14826
|
className: cn("mt-ai-evidence mt-ai-context", className),
|
|
14360
14827
|
style,
|
|
14361
14828
|
children: [
|
|
14362
|
-
/* @__PURE__ */
|
|
14363
|
-
/* @__PURE__ */
|
|
14364
|
-
/* @__PURE__ */
|
|
14829
|
+
/* @__PURE__ */ jsxs47("div", { className: "mt-ai-evidence-heading", children: [
|
|
14830
|
+
/* @__PURE__ */ jsx54("span", { children: name }),
|
|
14831
|
+
/* @__PURE__ */ jsxs47("span", { children: [
|
|
14365
14832
|
used.toLocaleString(),
|
|
14366
14833
|
max > 0 ? ` / ${max.toLocaleString()}` : ""
|
|
14367
14834
|
] })
|
|
14368
14835
|
] }),
|
|
14369
|
-
max > 0 && /* @__PURE__ */
|
|
14370
|
-
(inputTokens !== void 0 || outputTokens !== void 0 || cost !== void 0) && /* @__PURE__ */
|
|
14371
|
-
inputTokens !== void 0 && /* @__PURE__ */
|
|
14372
|
-
/* @__PURE__ */
|
|
14373
|
-
/* @__PURE__ */
|
|
14836
|
+
max > 0 && /* @__PURE__ */ jsx54(Progress, { value: Math.min(100, used / max * 100), label: name }),
|
|
14837
|
+
(inputTokens !== void 0 || outputTokens !== void 0 || cost !== void 0) && /* @__PURE__ */ jsxs47("dl", { className: "mt-ai-evidence-metrics", children: [
|
|
14838
|
+
inputTokens !== void 0 && /* @__PURE__ */ jsxs47("div", { children: [
|
|
14839
|
+
/* @__PURE__ */ jsx54("dt", { children: text.input }),
|
|
14840
|
+
/* @__PURE__ */ jsx54("dd", { children: count(inputTokens).toLocaleString() })
|
|
14374
14841
|
] }),
|
|
14375
|
-
outputTokens !== void 0 && /* @__PURE__ */
|
|
14376
|
-
/* @__PURE__ */
|
|
14377
|
-
/* @__PURE__ */
|
|
14842
|
+
outputTokens !== void 0 && /* @__PURE__ */ jsxs47("div", { children: [
|
|
14843
|
+
/* @__PURE__ */ jsx54("dt", { children: text.output }),
|
|
14844
|
+
/* @__PURE__ */ jsx54("dd", { children: count(outputTokens).toLocaleString() })
|
|
14378
14845
|
] }),
|
|
14379
|
-
cost !== void 0 && /* @__PURE__ */
|
|
14380
|
-
/* @__PURE__ */
|
|
14381
|
-
/* @__PURE__ */
|
|
14846
|
+
cost !== void 0 && /* @__PURE__ */ jsxs47("div", { children: [
|
|
14847
|
+
/* @__PURE__ */ jsx54("dt", { children: text.cost }),
|
|
14848
|
+
/* @__PURE__ */ jsx54("dd", { children: cost })
|
|
14382
14849
|
] })
|
|
14383
14850
|
] })
|
|
14384
14851
|
]
|
|
@@ -14396,10 +14863,10 @@ function AiFileTree({
|
|
|
14396
14863
|
style
|
|
14397
14864
|
}) {
|
|
14398
14865
|
const text = useEvidenceText();
|
|
14399
|
-
const [local, setLocal] =
|
|
14866
|
+
const [local, setLocal] = React54.useState(
|
|
14400
14867
|
defaultSelectedId ?? null
|
|
14401
14868
|
);
|
|
14402
|
-
const { nodes, data } =
|
|
14869
|
+
const { nodes, data } = React54.useMemo(() => {
|
|
14403
14870
|
const nodes2 = /* @__PURE__ */ new Map();
|
|
14404
14871
|
const visit = (values2) => values2.map((node) => {
|
|
14405
14872
|
nodes2.set(node.id, node);
|
|
@@ -14407,7 +14874,7 @@ function AiFileTree({
|
|
|
14407
14874
|
id: node.id,
|
|
14408
14875
|
label: node.name,
|
|
14409
14876
|
disabled: node.disabled,
|
|
14410
|
-
icon: node.kind === "folder" || node.children ? /* @__PURE__ */
|
|
14877
|
+
icon: node.kind === "folder" || node.children ? /* @__PURE__ */ jsx54(Folder2, { size: 14, "aria-hidden": true }) : /* @__PURE__ */ jsx54(File2, { size: 14, "aria-hidden": true }),
|
|
14411
14878
|
children: node.children ? visit(node.children) : void 0
|
|
14412
14879
|
};
|
|
14413
14880
|
});
|
|
@@ -14415,15 +14882,15 @@ function AiFileTree({
|
|
|
14415
14882
|
return { nodes: nodes2, data: data2 };
|
|
14416
14883
|
}, [items]);
|
|
14417
14884
|
const selected = selectedId === void 0 ? local : selectedId;
|
|
14418
|
-
return /* @__PURE__ */
|
|
14885
|
+
return /* @__PURE__ */ jsxs47(
|
|
14419
14886
|
"section",
|
|
14420
14887
|
{
|
|
14421
14888
|
"aria-label": label ?? text.files,
|
|
14422
14889
|
className: cn("mt-ai-evidence mt-ai-files", className),
|
|
14423
14890
|
style,
|
|
14424
14891
|
children: [
|
|
14425
|
-
/* @__PURE__ */
|
|
14426
|
-
items.length ? /* @__PURE__ */
|
|
14892
|
+
/* @__PURE__ */ jsx54("div", { className: "mt-ai-evidence-heading", children: label ?? text.files }),
|
|
14893
|
+
items.length ? /* @__PURE__ */ jsx54(
|
|
14427
14894
|
Tree,
|
|
14428
14895
|
{
|
|
14429
14896
|
"aria-label": label ?? text.files,
|
|
@@ -14440,7 +14907,7 @@ function AiFileTree({
|
|
|
14440
14907
|
onSelect?.(id, node);
|
|
14441
14908
|
}
|
|
14442
14909
|
}
|
|
14443
|
-
) : /* @__PURE__ */
|
|
14910
|
+
) : /* @__PURE__ */ jsx54("p", { className: "mt-ai-evidence-empty", children: text.noFiles })
|
|
14444
14911
|
]
|
|
14445
14912
|
}
|
|
14446
14913
|
);
|
|
@@ -14466,8 +14933,8 @@ function AiInlineCitation({
|
|
|
14466
14933
|
}) {
|
|
14467
14934
|
const url = safeSourceUrl(source.url);
|
|
14468
14935
|
const name = index === void 0 ? source.title : `${index}: ${source.title}`;
|
|
14469
|
-
const content2 = /* @__PURE__ */
|
|
14470
|
-
return url ? /* @__PURE__ */
|
|
14936
|
+
const content2 = /* @__PURE__ */ jsx54(Fragment29, { children: index === void 0 ? source.title : index });
|
|
14937
|
+
return url ? /* @__PURE__ */ jsx54(
|
|
14471
14938
|
"a",
|
|
14472
14939
|
{
|
|
14473
14940
|
className: cn("mt-ai-citation", className),
|
|
@@ -14477,7 +14944,7 @@ function AiInlineCitation({
|
|
|
14477
14944
|
title: source.description ?? source.title,
|
|
14478
14945
|
children: content2
|
|
14479
14946
|
}
|
|
14480
|
-
) : /* @__PURE__ */
|
|
14947
|
+
) : /* @__PURE__ */ jsx54(
|
|
14481
14948
|
"span",
|
|
14482
14949
|
{
|
|
14483
14950
|
className: cn("mt-ai-citation", className),
|
|
@@ -14496,29 +14963,29 @@ function AiSources({
|
|
|
14496
14963
|
style
|
|
14497
14964
|
}) {
|
|
14498
14965
|
const text = useEvidenceText();
|
|
14499
|
-
return /* @__PURE__ */
|
|
14966
|
+
return /* @__PURE__ */ jsxs47(
|
|
14500
14967
|
"details",
|
|
14501
14968
|
{
|
|
14502
14969
|
className: cn("mt-ai-evidence", className),
|
|
14503
14970
|
style,
|
|
14504
14971
|
open: defaultOpen || void 0,
|
|
14505
14972
|
children: [
|
|
14506
|
-
/* @__PURE__ */
|
|
14973
|
+
/* @__PURE__ */ jsxs47("summary", { children: [
|
|
14507
14974
|
label ?? text.sources,
|
|
14508
14975
|
" ",
|
|
14509
|
-
/* @__PURE__ */
|
|
14976
|
+
/* @__PURE__ */ jsxs47("span", { className: "mt-ai-evidence-muted", children: [
|
|
14510
14977
|
"(",
|
|
14511
14978
|
sources.length,
|
|
14512
14979
|
")"
|
|
14513
14980
|
] })
|
|
14514
14981
|
] }),
|
|
14515
|
-
sources.length ? /* @__PURE__ */
|
|
14982
|
+
sources.length ? /* @__PURE__ */ jsx54("ol", { className: "mt-ai-sources", children: sources.map((source) => {
|
|
14516
14983
|
const url = safeSourceUrl(source.url);
|
|
14517
|
-
return /* @__PURE__ */
|
|
14518
|
-
url ? /* @__PURE__ */
|
|
14519
|
-
source.description && /* @__PURE__ */
|
|
14984
|
+
return /* @__PURE__ */ jsxs47("li", { children: [
|
|
14985
|
+
url ? /* @__PURE__ */ jsx54("a", { href: url, children: source.title }) : /* @__PURE__ */ jsx54("span", { children: source.title }),
|
|
14986
|
+
source.description && /* @__PURE__ */ jsx54("p", { children: source.description })
|
|
14520
14987
|
] }, source.id);
|
|
14521
|
-
}) }) : /* @__PURE__ */
|
|
14988
|
+
}) }) : /* @__PURE__ */ jsx54("p", { className: "mt-ai-evidence-empty", children: text.noSources })
|
|
14522
14989
|
]
|
|
14523
14990
|
}
|
|
14524
14991
|
);
|
|
@@ -14532,21 +14999,21 @@ function AiStackTrace({
|
|
|
14532
14999
|
style
|
|
14533
15000
|
}) {
|
|
14534
15001
|
const text = useEvidenceText();
|
|
14535
|
-
return /* @__PURE__ */
|
|
15002
|
+
return /* @__PURE__ */ jsxs47(
|
|
14536
15003
|
"details",
|
|
14537
15004
|
{
|
|
14538
15005
|
className: cn("mt-ai-evidence mt-ai-stack", className),
|
|
14539
15006
|
style,
|
|
14540
15007
|
open: defaultOpen || void 0,
|
|
14541
15008
|
children: [
|
|
14542
|
-
/* @__PURE__ */
|
|
14543
|
-
/* @__PURE__ */
|
|
14544
|
-
frames.length ? /* @__PURE__ */
|
|
15009
|
+
/* @__PURE__ */ jsx54("summary", { children: label ?? text.stack }),
|
|
15010
|
+
/* @__PURE__ */ jsx54("pre", { className: "mt-ai-evidence-code", children: message }),
|
|
15011
|
+
frames.length ? /* @__PURE__ */ jsx54("ol", { className: "mt-ai-stack-frames", children: frames.map((frame, i) => /* @__PURE__ */ jsx54("li", { children: /* @__PURE__ */ jsxs47("code", { children: [
|
|
14545
15012
|
frame.functionName ? `${frame.functionName} \u2014 ` : "",
|
|
14546
15013
|
frame.file,
|
|
14547
15014
|
frame.line === void 0 ? "" : `:${count(frame.line)}`,
|
|
14548
15015
|
frame.column === void 0 ? "" : `:${count(frame.column)}`
|
|
14549
|
-
] }) }, i)) }) : /* @__PURE__ */
|
|
15016
|
+
] }) }, i)) }) : /* @__PURE__ */ jsx54("p", { className: "mt-ai-evidence-empty", children: text.noFrames })
|
|
14550
15017
|
]
|
|
14551
15018
|
}
|
|
14552
15019
|
);
|
|
@@ -14559,18 +15026,18 @@ function AiTerminal({
|
|
|
14559
15026
|
style
|
|
14560
15027
|
}) {
|
|
14561
15028
|
const text = useEvidenceText();
|
|
14562
|
-
return /* @__PURE__ */
|
|
15029
|
+
return /* @__PURE__ */ jsxs47(
|
|
14563
15030
|
"section",
|
|
14564
15031
|
{
|
|
14565
15032
|
"aria-label": label ?? text.terminal,
|
|
14566
15033
|
className: cn("mt-ai-evidence mt-ai-terminal", className),
|
|
14567
15034
|
style,
|
|
14568
15035
|
children: [
|
|
14569
|
-
/* @__PURE__ */
|
|
14570
|
-
/* @__PURE__ */
|
|
14571
|
-
/* @__PURE__ */
|
|
15036
|
+
/* @__PURE__ */ jsxs47("div", { className: "mt-ai-evidence-heading", children: [
|
|
15037
|
+
/* @__PURE__ */ jsx54("span", { children: label ?? text.terminal }),
|
|
15038
|
+
/* @__PURE__ */ jsx54("span", { className: "mt-ai-evidence-status", "data-status": status, children: text[status] })
|
|
14572
15039
|
] }),
|
|
14573
|
-
/* @__PURE__ */
|
|
15040
|
+
/* @__PURE__ */ jsx54(
|
|
14574
15041
|
"pre",
|
|
14575
15042
|
{
|
|
14576
15043
|
className: "mt-ai-evidence-code",
|
|
@@ -14592,24 +15059,24 @@ function AiTestResults({
|
|
|
14592
15059
|
}) {
|
|
14593
15060
|
const text = useEvidenceText();
|
|
14594
15061
|
const statuses = ["passed", "failed", "skipped", "running"];
|
|
14595
|
-
return /* @__PURE__ */
|
|
15062
|
+
return /* @__PURE__ */ jsxs47(
|
|
14596
15063
|
"details",
|
|
14597
15064
|
{
|
|
14598
15065
|
className: cn("mt-ai-evidence mt-ai-tests", className),
|
|
14599
15066
|
style,
|
|
14600
15067
|
open: defaultOpen || void 0,
|
|
14601
15068
|
children: [
|
|
14602
|
-
/* @__PURE__ */
|
|
15069
|
+
/* @__PURE__ */ jsxs47("summary", { children: [
|
|
14603
15070
|
label ?? text.tests,
|
|
14604
15071
|
" ",
|
|
14605
|
-
/* @__PURE__ */
|
|
15072
|
+
/* @__PURE__ */ jsxs47("span", { className: "mt-ai-evidence-muted", children: [
|
|
14606
15073
|
"(",
|
|
14607
15074
|
results.length,
|
|
14608
15075
|
")"
|
|
14609
15076
|
] })
|
|
14610
15077
|
] }),
|
|
14611
|
-
results.length ? /* @__PURE__ */
|
|
14612
|
-
/* @__PURE__ */
|
|
15078
|
+
results.length ? /* @__PURE__ */ jsxs47(Fragment29, { children: [
|
|
15079
|
+
/* @__PURE__ */ jsx54("div", { className: "mt-ai-test-counts", children: statuses.map((status) => /* @__PURE__ */ jsxs47(
|
|
14613
15080
|
"span",
|
|
14614
15081
|
{
|
|
14615
15082
|
className: "mt-ai-evidence-status",
|
|
@@ -14622,10 +15089,10 @@ function AiTestResults({
|
|
|
14622
15089
|
},
|
|
14623
15090
|
status
|
|
14624
15091
|
)) }),
|
|
14625
|
-
/* @__PURE__ */
|
|
14626
|
-
const title = /* @__PURE__ */
|
|
14627
|
-
/* @__PURE__ */
|
|
14628
|
-
/* @__PURE__ */
|
|
15092
|
+
/* @__PURE__ */ jsx54("ul", { className: "mt-ai-test-list", children: results.map((result) => {
|
|
15093
|
+
const title = /* @__PURE__ */ jsxs47(Fragment29, { children: [
|
|
15094
|
+
/* @__PURE__ */ jsx54("span", { className: "mt-ai-test-name", children: result.name }),
|
|
15095
|
+
/* @__PURE__ */ jsx54(
|
|
14629
15096
|
"span",
|
|
14630
15097
|
{
|
|
14631
15098
|
className: "mt-ai-evidence-status",
|
|
@@ -14633,27 +15100,27 @@ function AiTestResults({
|
|
|
14633
15100
|
children: text[result.status]
|
|
14634
15101
|
}
|
|
14635
15102
|
),
|
|
14636
|
-
result.durationMs !== void 0 && /* @__PURE__ */
|
|
15103
|
+
result.durationMs !== void 0 && /* @__PURE__ */ jsxs47("span", { className: "mt-ai-evidence-muted", children: [
|
|
14637
15104
|
count(result.durationMs),
|
|
14638
15105
|
" ms"
|
|
14639
15106
|
] })
|
|
14640
15107
|
] });
|
|
14641
|
-
return /* @__PURE__ */
|
|
14642
|
-
/* @__PURE__ */
|
|
14643
|
-
/* @__PURE__ */
|
|
14644
|
-
] }) : /* @__PURE__ */
|
|
15108
|
+
return /* @__PURE__ */ jsx54("li", { children: result.details ? /* @__PURE__ */ jsxs47("details", { children: [
|
|
15109
|
+
/* @__PURE__ */ jsx54("summary", { children: title }),
|
|
15110
|
+
/* @__PURE__ */ jsx54("pre", { className: "mt-ai-evidence-code", children: result.details })
|
|
15111
|
+
] }) : /* @__PURE__ */ jsx54("div", { className: "mt-ai-test-row", children: title }) }, result.id);
|
|
14645
15112
|
}) })
|
|
14646
|
-
] }) : /* @__PURE__ */
|
|
15113
|
+
] }) : /* @__PURE__ */ jsx54("p", { className: "mt-ai-evidence-empty", children: text.noTests })
|
|
14647
15114
|
]
|
|
14648
15115
|
}
|
|
14649
15116
|
);
|
|
14650
15117
|
}
|
|
14651
15118
|
|
|
14652
15119
|
// src/check-card.tsx
|
|
14653
|
-
import * as
|
|
15120
|
+
import * as React55 from "react";
|
|
14654
15121
|
import { Check as Check8, LoaderCircle as LoaderCircle11 } from "lucide-react";
|
|
14655
|
-
import { jsx as
|
|
14656
|
-
var GroupContext =
|
|
15122
|
+
import { jsx as jsx55, jsxs as jsxs48 } from "react/jsx-runtime";
|
|
15123
|
+
var GroupContext = React55.createContext(null);
|
|
14657
15124
|
var contains = (selection, key) => typeof selection === "string" ? selection === key : selection?.includes(key) ?? false;
|
|
14658
15125
|
function CheckCardGroup(props) {
|
|
14659
15126
|
const {
|
|
@@ -14674,12 +15141,12 @@ function CheckCardGroup(props) {
|
|
|
14674
15141
|
className,
|
|
14675
15142
|
...attrs
|
|
14676
15143
|
} = props;
|
|
14677
|
-
const id =
|
|
15144
|
+
const id = React55.useId();
|
|
14678
15145
|
const groupDisabled = useFieldsetDisabled(disabled);
|
|
14679
|
-
const [initial] =
|
|
15146
|
+
const [initial] = React55.useState(
|
|
14680
15147
|
() => typeof defaultValue === "string" ? defaultValue : [...new Set(defaultValue ?? [])]
|
|
14681
15148
|
);
|
|
14682
|
-
const [local, setLocal] =
|
|
15149
|
+
const [local, setLocal] = React55.useState(initial);
|
|
14683
15150
|
const controlled = value !== void 0;
|
|
14684
15151
|
const selection = controlled ? value : local;
|
|
14685
15152
|
const state = {
|
|
@@ -14713,7 +15180,7 @@ function CheckCardGroup(props) {
|
|
|
14713
15180
|
return contains(controlled ? selection : initial, key);
|
|
14714
15181
|
}
|
|
14715
15182
|
};
|
|
14716
|
-
return /* @__PURE__ */
|
|
15183
|
+
return /* @__PURE__ */ jsx55(GroupContext.Provider, { value: state, children: /* @__PURE__ */ jsxs48(
|
|
14717
15184
|
"fieldset",
|
|
14718
15185
|
{
|
|
14719
15186
|
...attrs,
|
|
@@ -14723,8 +15190,8 @@ function CheckCardGroup(props) {
|
|
|
14723
15190
|
"aria-busy": loading || void 0,
|
|
14724
15191
|
className: cn("mt-check-card-group", className),
|
|
14725
15192
|
children: [
|
|
14726
|
-
legend != null && /* @__PURE__ */
|
|
14727
|
-
/* @__PURE__ */
|
|
15193
|
+
legend != null && /* @__PURE__ */ jsx55("legend", { className: "mt-check-card-legend", children: legend }),
|
|
15194
|
+
/* @__PURE__ */ jsx55("div", { className: "mt-check-card-group-items", children: children ?? options?.map((option) => /* @__PURE__ */ jsx55(CheckCardRoot, { ...option }, option.value)) })
|
|
14728
15195
|
]
|
|
14729
15196
|
}
|
|
14730
15197
|
) });
|
|
@@ -14754,12 +15221,12 @@ function CheckCardRoot({
|
|
|
14754
15221
|
"aria-describedby": describedBy,
|
|
14755
15222
|
...props
|
|
14756
15223
|
}) {
|
|
14757
|
-
const group =
|
|
14758
|
-
const generatedId =
|
|
15224
|
+
const group = React55.useContext(GroupContext);
|
|
15225
|
+
const generatedId = React55.useId();
|
|
14759
15226
|
const controlId = `${generatedId}-input`;
|
|
14760
15227
|
const titleId = `${generatedId}-title`;
|
|
14761
15228
|
const descriptionId = `${generatedId}-description`;
|
|
14762
|
-
const input =
|
|
15229
|
+
const input = React55.useRef(null);
|
|
14763
15230
|
const key = value ?? "on";
|
|
14764
15231
|
const currentChecked = group ? group.isChecked(key) : checked;
|
|
14765
15232
|
const formId = group ? group.form : form;
|
|
@@ -14770,13 +15237,13 @@ function CheckCardRoot({
|
|
|
14770
15237
|
const hasBorder = bordered ?? group?.bordered ?? true;
|
|
14771
15238
|
const descriptionIds = [description != null ? descriptionId : void 0, describedBy].filter(Boolean).join(" ") || void 0;
|
|
14772
15239
|
const hasStateOwner = group !== null || checked !== void 0;
|
|
14773
|
-
const latestResetValue =
|
|
15240
|
+
const latestResetValue = React55.useRef(
|
|
14774
15241
|
() => void 0
|
|
14775
15242
|
);
|
|
14776
|
-
|
|
15243
|
+
React55.useLayoutEffect(() => {
|
|
14777
15244
|
latestResetValue.current = () => group ? group.reset(key) : checked;
|
|
14778
15245
|
}, [group, key, checked]);
|
|
14779
|
-
|
|
15246
|
+
React55.useEffect(() => {
|
|
14780
15247
|
const element = input.current;
|
|
14781
15248
|
const owner = element?.form;
|
|
14782
15249
|
if (!element || !owner || !hasStateOwner) return;
|
|
@@ -14796,7 +15263,7 @@ function CheckCardRoot({
|
|
|
14796
15263
|
clearTimeout(timer);
|
|
14797
15264
|
};
|
|
14798
15265
|
}, [formId, hasStateOwner]);
|
|
14799
|
-
return /* @__PURE__ */
|
|
15266
|
+
return /* @__PURE__ */ jsxs48(
|
|
14800
15267
|
"div",
|
|
14801
15268
|
{
|
|
14802
15269
|
...props,
|
|
@@ -14806,7 +15273,7 @@ function CheckCardRoot({
|
|
|
14806
15273
|
"data-bordered": hasBorder,
|
|
14807
15274
|
"data-loading": loading || void 0,
|
|
14808
15275
|
children: [
|
|
14809
|
-
/* @__PURE__ */
|
|
15276
|
+
/* @__PURE__ */ jsx55(
|
|
14810
15277
|
"input",
|
|
14811
15278
|
{
|
|
14812
15279
|
ref: input,
|
|
@@ -14832,16 +15299,16 @@ function CheckCardRoot({
|
|
|
14832
15299
|
}
|
|
14833
15300
|
}
|
|
14834
15301
|
),
|
|
14835
|
-
/* @__PURE__ */
|
|
14836
|
-
cover != null && /* @__PURE__ */
|
|
14837
|
-
/* @__PURE__ */
|
|
14838
|
-
avatar != null && /* @__PURE__ */
|
|
14839
|
-
/* @__PURE__ */
|
|
14840
|
-
title != null && /* @__PURE__ */
|
|
14841
|
-
description != null && /* @__PURE__ */
|
|
14842
|
-
children != null && /* @__PURE__ */
|
|
15302
|
+
/* @__PURE__ */ jsxs48("label", { className: "mt-check-card-label", htmlFor: controlId, children: [
|
|
15303
|
+
cover != null && /* @__PURE__ */ jsx55("span", { className: "mt-check-card-cover", children: cover }),
|
|
15304
|
+
/* @__PURE__ */ jsxs48("span", { className: "mt-check-card-main", children: [
|
|
15305
|
+
avatar != null && /* @__PURE__ */ jsx55("span", { className: "mt-check-card-avatar", children: avatar }),
|
|
15306
|
+
/* @__PURE__ */ jsxs48("span", { className: "mt-check-card-text", children: [
|
|
15307
|
+
title != null && /* @__PURE__ */ jsx55("span", { id: titleId, className: "mt-check-card-title", children: title }),
|
|
15308
|
+
description != null && /* @__PURE__ */ jsx55("span", { id: descriptionId, className: "mt-check-card-description", children: description }),
|
|
15309
|
+
children != null && /* @__PURE__ */ jsx55("span", { className: "mt-check-card-content", children })
|
|
14843
15310
|
] }),
|
|
14844
|
-
/* @__PURE__ */
|
|
15311
|
+
/* @__PURE__ */ jsx55("span", { className: "mt-check-card-indicator", "aria-hidden": "true", children: loading ? /* @__PURE__ */ jsx55(LoaderCircle11, { className: "mt-spin", size: 14 }) : group && !group.multiple ? /* @__PURE__ */ jsx55("span", { className: "mt-check-card-radio-dot" }) : /* @__PURE__ */ jsx55(
|
|
14845
15312
|
Check8,
|
|
14846
15313
|
{
|
|
14847
15314
|
className: "mt-check-card-check",
|
|
@@ -14851,7 +15318,7 @@ function CheckCardRoot({
|
|
|
14851
15318
|
) })
|
|
14852
15319
|
] })
|
|
14853
15320
|
] }),
|
|
14854
|
-
extra != null && /* @__PURE__ */
|
|
15321
|
+
extra != null && /* @__PURE__ */ jsx55("div", { className: "mt-check-card-extra", children: extra })
|
|
14855
15322
|
]
|
|
14856
15323
|
}
|
|
14857
15324
|
);
|
|
@@ -14859,6 +15326,368 @@ function CheckCardRoot({
|
|
|
14859
15326
|
var CheckCard = Object.assign(CheckCardRoot, {
|
|
14860
15327
|
Group: CheckCardGroup
|
|
14861
15328
|
});
|
|
15329
|
+
|
|
15330
|
+
// src/floating-window.tsx
|
|
15331
|
+
import * as React56 from "react";
|
|
15332
|
+
import { createPortal as createPortal2 } from "react-dom";
|
|
15333
|
+
import { GripHorizontal, Maximize2, Minus as Minus4, PanelTop, X as X16 } from "lucide-react";
|
|
15334
|
+
import { Fragment as Fragment30, jsx as jsx56, jsxs as jsxs49 } from "react/jsx-runtime";
|
|
15335
|
+
var inset = 12;
|
|
15336
|
+
var collapsedSize = 40;
|
|
15337
|
+
var clamp2 = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
15338
|
+
var finite2 = (value, fallback) => value !== void 0 && Number.isFinite(value) ? value : fallback;
|
|
15339
|
+
function readBounds() {
|
|
15340
|
+
const visual = window.visualViewport;
|
|
15341
|
+
const width = visual?.width || document.documentElement.clientWidth || window.innerWidth;
|
|
15342
|
+
const height = visual?.height || document.documentElement.clientHeight || window.innerHeight;
|
|
15343
|
+
const left = visual?.offsetLeft ?? 0;
|
|
15344
|
+
const top = visual?.offsetTop ?? 0;
|
|
15345
|
+
const inlineInset = Math.min(inset, width / 4);
|
|
15346
|
+
const blockInset = Math.min(inset, height / 4);
|
|
15347
|
+
return {
|
|
15348
|
+
left: left + inlineInset,
|
|
15349
|
+
top: top + blockInset,
|
|
15350
|
+
right: left + width - inlineInset,
|
|
15351
|
+
bottom: top + height - blockInset
|
|
15352
|
+
};
|
|
15353
|
+
}
|
|
15354
|
+
function readLimits(bounds, props) {
|
|
15355
|
+
const availableWidth = bounds.right - bounds.left;
|
|
15356
|
+
const availableHeight = bounds.bottom - bounds.top;
|
|
15357
|
+
const chromeWidth = Math.min(108, availableWidth);
|
|
15358
|
+
const chromeHeight = Math.min(56, availableHeight);
|
|
15359
|
+
const maxWidth = clamp2(finite2(props.maxWidth, Infinity), chromeWidth, availableWidth);
|
|
15360
|
+
const maxHeight = clamp2(finite2(props.maxHeight, Infinity), chromeHeight, availableHeight);
|
|
15361
|
+
return {
|
|
15362
|
+
maxWidth,
|
|
15363
|
+
maxHeight,
|
|
15364
|
+
minWidth: clamp2(finite2(props.minWidth, 220), chromeWidth, maxWidth),
|
|
15365
|
+
minHeight: clamp2(finite2(props.minHeight, 140), chromeHeight, maxHeight)
|
|
15366
|
+
};
|
|
15367
|
+
}
|
|
15368
|
+
function fitWindow(bounds, limits, position, size) {
|
|
15369
|
+
const width = clamp2(finite2(size?.width, 440), limits.minWidth, limits.maxWidth);
|
|
15370
|
+
const height = clamp2(finite2(size?.height, 320), limits.minHeight, limits.maxHeight);
|
|
15371
|
+
return {
|
|
15372
|
+
width,
|
|
15373
|
+
height,
|
|
15374
|
+
left: clamp2(finite2(position?.left, (bounds.left + bounds.right - width) / 2), bounds.left, bounds.right - width),
|
|
15375
|
+
top: clamp2(finite2(position?.top, (bounds.top + bounds.bottom - height) / 2), bounds.top, bounds.bottom - height)
|
|
15376
|
+
};
|
|
15377
|
+
}
|
|
15378
|
+
function updateGeometry(current, kind, x, y, bounds, limits) {
|
|
15379
|
+
if (kind === "move") {
|
|
15380
|
+
return fitWindow(bounds, limits, { left: current.left + x, top: current.top + y }, current);
|
|
15381
|
+
}
|
|
15382
|
+
const maxWidth = Math.min(limits.maxWidth, bounds.right - current.left);
|
|
15383
|
+
const maxHeight = Math.min(limits.maxHeight, bounds.bottom - current.top);
|
|
15384
|
+
return {
|
|
15385
|
+
...current,
|
|
15386
|
+
width: clamp2(current.width + x, Math.min(limits.minWidth, maxWidth), maxWidth),
|
|
15387
|
+
height: clamp2(current.height + y, Math.min(limits.minHeight, maxHeight), maxHeight)
|
|
15388
|
+
};
|
|
15389
|
+
}
|
|
15390
|
+
function assignRef(ref, node) {
|
|
15391
|
+
if (typeof ref === "function") return ref(node);
|
|
15392
|
+
if (ref) ref.current = node;
|
|
15393
|
+
}
|
|
15394
|
+
function FloatingWindow({
|
|
15395
|
+
title,
|
|
15396
|
+
children,
|
|
15397
|
+
trigger,
|
|
15398
|
+
open: controlledOpen,
|
|
15399
|
+
defaultOpen = false,
|
|
15400
|
+
onOpenChange,
|
|
15401
|
+
initialPosition,
|
|
15402
|
+
initialSize,
|
|
15403
|
+
minWidth,
|
|
15404
|
+
minHeight,
|
|
15405
|
+
maxWidth,
|
|
15406
|
+
maxHeight,
|
|
15407
|
+
draggable = true,
|
|
15408
|
+
resizable = true,
|
|
15409
|
+
minimizable = true,
|
|
15410
|
+
minimizedIcon,
|
|
15411
|
+
zIndex = 1150
|
|
15412
|
+
}) {
|
|
15413
|
+
const { locale } = useMtone();
|
|
15414
|
+
const zh = locale === "zh";
|
|
15415
|
+
const dialogId = React56.useId();
|
|
15416
|
+
const titleId = `${dialogId}-title`;
|
|
15417
|
+
const moveHelp = `${dialogId}-move`;
|
|
15418
|
+
const resizeHelp = `${dialogId}-resize`;
|
|
15419
|
+
const [localOpen, setOpen] = React56.useState(defaultOpen);
|
|
15420
|
+
const open = controlledOpen ?? localOpen;
|
|
15421
|
+
const [minimized, setMinimized] = React56.useState(false);
|
|
15422
|
+
const collapsed = minimizable && minimized;
|
|
15423
|
+
const [bounds, setBounds] = React56.useState();
|
|
15424
|
+
const [storedGeometry, setGeometry] = React56.useState();
|
|
15425
|
+
const initial = React56.useRef({ position: initialPosition, size: initialSize });
|
|
15426
|
+
const triggerRef = React56.useRef(null);
|
|
15427
|
+
const triggerElement = typeof trigger === "object" ? trigger : void 0;
|
|
15428
|
+
const externalTriggerRef = triggerElement?.props.ref;
|
|
15429
|
+
const captureTrigger = React56.useCallback((node) => {
|
|
15430
|
+
triggerRef.current = node;
|
|
15431
|
+
const cleanUp = assignRef(externalTriggerRef, node);
|
|
15432
|
+
if (cleanUp) return () => {
|
|
15433
|
+
triggerRef.current = null;
|
|
15434
|
+
cleanUp();
|
|
15435
|
+
};
|
|
15436
|
+
}, [externalTriggerRef]);
|
|
15437
|
+
const windowRef = React56.useRef(null);
|
|
15438
|
+
const restoreRef = React56.useRef(null);
|
|
15439
|
+
const pendingFocus = React56.useRef(void 0);
|
|
15440
|
+
const focusWithin = React56.useRef(false);
|
|
15441
|
+
const markFocused = () => {
|
|
15442
|
+
focusWithin.current = true;
|
|
15443
|
+
};
|
|
15444
|
+
const handleBlur = (event) => {
|
|
15445
|
+
const next = event.relatedTarget;
|
|
15446
|
+
if (next && !(windowRef.current?.contains(next) || restoreRef.current?.contains(next))) {
|
|
15447
|
+
focusWithin.current = false;
|
|
15448
|
+
if (pendingFocus.current === "trigger") pendingFocus.current = void 0;
|
|
15449
|
+
}
|
|
15450
|
+
};
|
|
15451
|
+
const gesture = React56.useRef(null);
|
|
15452
|
+
React56.useEffect(() => {
|
|
15453
|
+
if (!open) return;
|
|
15454
|
+
const refresh = () => {
|
|
15455
|
+
gesture.current = null;
|
|
15456
|
+
setBounds(readBounds());
|
|
15457
|
+
};
|
|
15458
|
+
refresh();
|
|
15459
|
+
const visual = window.visualViewport;
|
|
15460
|
+
window.addEventListener("resize", refresh);
|
|
15461
|
+
visual?.addEventListener("resize", refresh);
|
|
15462
|
+
visual?.addEventListener("scroll", refresh);
|
|
15463
|
+
return () => {
|
|
15464
|
+
window.removeEventListener("resize", refresh);
|
|
15465
|
+
visual?.removeEventListener("resize", refresh);
|
|
15466
|
+
visual?.removeEventListener("scroll", refresh);
|
|
15467
|
+
gesture.current = null;
|
|
15468
|
+
};
|
|
15469
|
+
}, [open]);
|
|
15470
|
+
React56.useEffect(() => {
|
|
15471
|
+
if (!open) {
|
|
15472
|
+
setMinimized(false);
|
|
15473
|
+
if (pendingFocus.current === "trigger" || focusWithin.current) {
|
|
15474
|
+
triggerRef.current?.focus({ preventScroll: true });
|
|
15475
|
+
}
|
|
15476
|
+
focusWithin.current = false;
|
|
15477
|
+
pendingFocus.current = void 0;
|
|
15478
|
+
return;
|
|
15479
|
+
}
|
|
15480
|
+
const target = pendingFocus.current === "window" && !collapsed ? windowRef.current : pendingFocus.current === "restore" && collapsed ? restoreRef.current : null;
|
|
15481
|
+
if (target) {
|
|
15482
|
+
pendingFocus.current = void 0;
|
|
15483
|
+
target.focus({ preventScroll: true });
|
|
15484
|
+
}
|
|
15485
|
+
}, [open, collapsed, bounds]);
|
|
15486
|
+
const limits = bounds && readLimits(bounds, { minWidth, minHeight, maxWidth, maxHeight });
|
|
15487
|
+
const geometry = bounds && limits && fitWindow(
|
|
15488
|
+
bounds,
|
|
15489
|
+
limits,
|
|
15490
|
+
storedGeometry ?? initial.current.position,
|
|
15491
|
+
storedGeometry ?? initial.current.size
|
|
15492
|
+
);
|
|
15493
|
+
const changeOpen = (next) => {
|
|
15494
|
+
if (controlledOpen === void 0) setOpen(next);
|
|
15495
|
+
onOpenChange?.(next);
|
|
15496
|
+
};
|
|
15497
|
+
const restore = () => {
|
|
15498
|
+
pendingFocus.current = "window";
|
|
15499
|
+
setMinimized(false);
|
|
15500
|
+
};
|
|
15501
|
+
const requestOpen = () => {
|
|
15502
|
+
if (!open) {
|
|
15503
|
+
pendingFocus.current = "window";
|
|
15504
|
+
changeOpen(true);
|
|
15505
|
+
} else if (collapsed) {
|
|
15506
|
+
restore();
|
|
15507
|
+
} else {
|
|
15508
|
+
windowRef.current?.focus({ preventScroll: true });
|
|
15509
|
+
}
|
|
15510
|
+
};
|
|
15511
|
+
const close = () => {
|
|
15512
|
+
pendingFocus.current = "trigger";
|
|
15513
|
+
changeOpen(false);
|
|
15514
|
+
};
|
|
15515
|
+
const minimize = () => {
|
|
15516
|
+
gesture.current = null;
|
|
15517
|
+
pendingFocus.current = "restore";
|
|
15518
|
+
setMinimized(true);
|
|
15519
|
+
};
|
|
15520
|
+
function pointerDown(kind, event) {
|
|
15521
|
+
if (!geometry || gesture.current || event.button !== 0 || event.defaultPrevented) return;
|
|
15522
|
+
if (kind === "move" && event.target instanceof Element && event.target.closest("button, a[href], input, select, textarea, [contenteditable], [role=button]") && !event.target.closest(".mt-floating-window-move")) return;
|
|
15523
|
+
gesture.current = { id: event.pointerId, kind, x: event.clientX, y: event.clientY, geometry };
|
|
15524
|
+
event.preventDefault();
|
|
15525
|
+
try {
|
|
15526
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
15527
|
+
} catch {
|
|
15528
|
+
}
|
|
15529
|
+
}
|
|
15530
|
+
function pointerMove(event) {
|
|
15531
|
+
const start = gesture.current;
|
|
15532
|
+
if (!start || !bounds || !limits || start.id !== event.pointerId) return;
|
|
15533
|
+
setGeometry(updateGeometry(start.geometry, start.kind, event.clientX - start.x, event.clientY - start.y, bounds, limits));
|
|
15534
|
+
}
|
|
15535
|
+
function pointerEnd(event) {
|
|
15536
|
+
if (gesture.current?.id === event.pointerId) gesture.current = null;
|
|
15537
|
+
}
|
|
15538
|
+
function keyDown(kind, event) {
|
|
15539
|
+
if (!geometry || !bounds || !limits || event.altKey || event.ctrlKey || event.metaKey) return;
|
|
15540
|
+
const step = event.shiftKey ? 24 : 8;
|
|
15541
|
+
const x = event.key === "ArrowLeft" ? -step : event.key === "ArrowRight" ? step : 0;
|
|
15542
|
+
const y = event.key === "ArrowUp" ? -step : event.key === "ArrowDown" ? step : 0;
|
|
15543
|
+
if (!x && !y) return;
|
|
15544
|
+
event.preventDefault();
|
|
15545
|
+
event.stopPropagation();
|
|
15546
|
+
setGeometry(updateGeometry(geometry, kind, x, y, bounds, limits));
|
|
15547
|
+
}
|
|
15548
|
+
const pointerEvents = {
|
|
15549
|
+
onPointerMove: pointerMove,
|
|
15550
|
+
onPointerUp: pointerEnd,
|
|
15551
|
+
onPointerCancel: pointerEnd,
|
|
15552
|
+
onLostPointerCapture: pointerEnd
|
|
15553
|
+
};
|
|
15554
|
+
let opener = null;
|
|
15555
|
+
if (typeof trigger === "string") {
|
|
15556
|
+
opener = /* @__PURE__ */ jsx56(
|
|
15557
|
+
Button,
|
|
15558
|
+
{
|
|
15559
|
+
type: "button",
|
|
15560
|
+
ref: triggerRef,
|
|
15561
|
+
"aria-haspopup": "dialog",
|
|
15562
|
+
"aria-expanded": open && !collapsed,
|
|
15563
|
+
"aria-controls": open ? dialogId : void 0,
|
|
15564
|
+
onClick: requestOpen,
|
|
15565
|
+
children: trigger
|
|
15566
|
+
}
|
|
15567
|
+
);
|
|
15568
|
+
} else if (triggerElement) {
|
|
15569
|
+
opener = React56.cloneElement(triggerElement, {
|
|
15570
|
+
...triggerElement.type === "button" && triggerElement.props.type === void 0 ? { type: "button" } : {},
|
|
15571
|
+
ref: captureTrigger,
|
|
15572
|
+
"aria-haspopup": "dialog",
|
|
15573
|
+
"aria-expanded": open && !collapsed,
|
|
15574
|
+
"aria-controls": open ? dialogId : void 0,
|
|
15575
|
+
onClick(event) {
|
|
15576
|
+
triggerElement.props.onClick?.(event);
|
|
15577
|
+
if (!event.defaultPrevented) {
|
|
15578
|
+
triggerRef.current = event.currentTarget;
|
|
15579
|
+
requestOpen();
|
|
15580
|
+
}
|
|
15581
|
+
}
|
|
15582
|
+
});
|
|
15583
|
+
}
|
|
15584
|
+
const content2 = open && geometry && bounds && createPortal2(
|
|
15585
|
+
/* @__PURE__ */ jsxs49(MtoneScope, { className: "mt-floating-window-scope", children: [
|
|
15586
|
+
/* @__PURE__ */ jsx56(React56.Activity, { mode: collapsed ? "hidden" : "visible", children: /* @__PURE__ */ jsxs49(
|
|
15587
|
+
"section",
|
|
15588
|
+
{
|
|
15589
|
+
ref: windowRef,
|
|
15590
|
+
id: dialogId,
|
|
15591
|
+
role: "dialog",
|
|
15592
|
+
"aria-modal": "false",
|
|
15593
|
+
"aria-labelledby": titleId,
|
|
15594
|
+
tabIndex: -1,
|
|
15595
|
+
onFocusCapture: markFocused,
|
|
15596
|
+
onBlurCapture: handleBlur,
|
|
15597
|
+
className: "mt-floating-window",
|
|
15598
|
+
style: { ...geometry, zIndex },
|
|
15599
|
+
children: [
|
|
15600
|
+
/* @__PURE__ */ jsxs49("header", { className: "mt-floating-window-header", children: [
|
|
15601
|
+
/* @__PURE__ */ jsxs49(
|
|
15602
|
+
"div",
|
|
15603
|
+
{
|
|
15604
|
+
className: "mt-floating-window-caption",
|
|
15605
|
+
"data-draggable": draggable || void 0,
|
|
15606
|
+
...draggable ? { ...pointerEvents, onPointerDown: (event) => pointerDown("move", event) } : {},
|
|
15607
|
+
children: [
|
|
15608
|
+
draggable && /* @__PURE__ */ jsx56(
|
|
15609
|
+
Button,
|
|
15610
|
+
{
|
|
15611
|
+
type: "button",
|
|
15612
|
+
variant: "ghost",
|
|
15613
|
+
size: "sm",
|
|
15614
|
+
iconOnly: true,
|
|
15615
|
+
className: "mt-floating-window-move",
|
|
15616
|
+
"aria-label": zh ? "\u79FB\u52A8\u7A97\u53E3" : "Move window",
|
|
15617
|
+
"aria-describedby": moveHelp,
|
|
15618
|
+
onKeyDown: (event) => keyDown("move", event),
|
|
15619
|
+
children: /* @__PURE__ */ jsx56(GripHorizontal, { size: 15, "aria-hidden": "true" })
|
|
15620
|
+
}
|
|
15621
|
+
),
|
|
15622
|
+
/* @__PURE__ */ jsx56("h2", { id: titleId, className: "mt-floating-window-title", children: title })
|
|
15623
|
+
]
|
|
15624
|
+
}
|
|
15625
|
+
),
|
|
15626
|
+
/* @__PURE__ */ jsxs49("div", { className: "mt-floating-window-actions", children: [
|
|
15627
|
+
minimizable && /* @__PURE__ */ jsx56(
|
|
15628
|
+
Button,
|
|
15629
|
+
{
|
|
15630
|
+
type: "button",
|
|
15631
|
+
variant: "ghost",
|
|
15632
|
+
size: "sm",
|
|
15633
|
+
iconOnly: true,
|
|
15634
|
+
"aria-label": zh ? "\u6700\u5C0F\u5316\u7A97\u53E3" : "Minimize window",
|
|
15635
|
+
onClick: minimize,
|
|
15636
|
+
children: /* @__PURE__ */ jsx56(Minus4, { size: 15, "aria-hidden": "true" })
|
|
15637
|
+
}
|
|
15638
|
+
),
|
|
15639
|
+
/* @__PURE__ */ jsx56(Button, { type: "button", variant: "ghost", size: "sm", iconOnly: true, "aria-label": zh ? "\u5173\u95ED\u7A97\u53E3" : "Close window", onClick: close, children: /* @__PURE__ */ jsx56(X16, { size: 15, "aria-hidden": "true" }) })
|
|
15640
|
+
] })
|
|
15641
|
+
] }),
|
|
15642
|
+
draggable && /* @__PURE__ */ jsx56("span", { className: "mt-floating-window-sr-only", id: moveHelp, children: zh ? "\u7528\u65B9\u5411\u952E\u79FB\u52A8\uFF0C\u6309\u4F4F Shift \u52A0\u5FEB\u79FB\u52A8\u3002" : "Use the arrow keys to move. Hold Shift for larger steps." }),
|
|
15643
|
+
/* @__PURE__ */ jsx56("div", { className: "mt-floating-window-content", children }),
|
|
15644
|
+
resizable && /* @__PURE__ */ jsx56("span", { className: "mt-floating-window-sr-only", id: resizeHelp, children: zh ? "\u7528\u65B9\u5411\u952E\u8C03\u6574\u5927\u5C0F\uFF0C\u6309\u4F4F Shift \u589E\u5927\u6B65\u957F\u3002" : "Use the arrow keys to resize. Hold Shift for larger steps." }),
|
|
15645
|
+
resizable && /* @__PURE__ */ jsx56(
|
|
15646
|
+
"button",
|
|
15647
|
+
{
|
|
15648
|
+
type: "button",
|
|
15649
|
+
className: "mt-floating-window-resize",
|
|
15650
|
+
"aria-label": zh ? "\u8C03\u6574\u7A97\u53E3\u5927\u5C0F" : "Resize window",
|
|
15651
|
+
"aria-describedby": resizeHelp,
|
|
15652
|
+
...pointerEvents,
|
|
15653
|
+
onPointerDown: (event) => pointerDown("resize", event),
|
|
15654
|
+
onKeyDown: (event) => keyDown("resize", event),
|
|
15655
|
+
children: /* @__PURE__ */ jsx56(Maximize2, { size: 13, "aria-hidden": "true" })
|
|
15656
|
+
}
|
|
15657
|
+
)
|
|
15658
|
+
]
|
|
15659
|
+
}
|
|
15660
|
+
) }),
|
|
15661
|
+
collapsed && /* @__PURE__ */ jsx56(
|
|
15662
|
+
Button,
|
|
15663
|
+
{
|
|
15664
|
+
type: "button",
|
|
15665
|
+
ref: restoreRef,
|
|
15666
|
+
variant: "outline",
|
|
15667
|
+
iconOnly: true,
|
|
15668
|
+
className: "mt-floating-window-restore",
|
|
15669
|
+
"aria-label": zh ? "\u6062\u590D\u7A97\u53E3" : "Restore window",
|
|
15670
|
+
onClick: restore,
|
|
15671
|
+
onFocus: markFocused,
|
|
15672
|
+
onBlur: handleBlur,
|
|
15673
|
+
style: {
|
|
15674
|
+
left: Math.max(bounds.left, bounds.right - collapsedSize),
|
|
15675
|
+
top: Math.max(bounds.top, bounds.bottom - collapsedSize),
|
|
15676
|
+
width: Math.min(collapsedSize, bounds.right - bounds.left),
|
|
15677
|
+
height: Math.min(collapsedSize, bounds.bottom - bounds.top),
|
|
15678
|
+
zIndex
|
|
15679
|
+
},
|
|
15680
|
+
children: /* @__PURE__ */ jsx56("span", { "aria-hidden": "true", children: minimizedIcon ?? /* @__PURE__ */ jsx56(PanelTop, { size: 18 }) })
|
|
15681
|
+
}
|
|
15682
|
+
)
|
|
15683
|
+
] }),
|
|
15684
|
+
document.body
|
|
15685
|
+
);
|
|
15686
|
+
return /* @__PURE__ */ jsxs49(Fragment30, { children: [
|
|
15687
|
+
opener,
|
|
15688
|
+
content2
|
|
15689
|
+
] });
|
|
15690
|
+
}
|
|
14862
15691
|
export {
|
|
14863
15692
|
AdminLayout,
|
|
14864
15693
|
Affix,
|
|
@@ -14908,6 +15737,7 @@ export {
|
|
|
14908
15737
|
Drawer,
|
|
14909
15738
|
Empty,
|
|
14910
15739
|
Fieldset,
|
|
15740
|
+
FloatingWindow,
|
|
14911
15741
|
Form,
|
|
14912
15742
|
GlobalNotice,
|
|
14913
15743
|
HoverCard,
|
|
@@ -14960,6 +15790,7 @@ export {
|
|
|
14960
15790
|
Timeline,
|
|
14961
15791
|
Title,
|
|
14962
15792
|
ToastProvider,
|
|
15793
|
+
Toolbar,
|
|
14963
15794
|
Tooltip,
|
|
14964
15795
|
Transfer,
|
|
14965
15796
|
Tree,
|