@bixlab/mtone 0.10.3 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-4X67DOKJ.js +377 -0
- package/dist/index.d.ts +113 -42
- package/dist/index.js +1807 -981
- package/dist/styles.css +1 -1
- package/dist/typography-highlight-GAYKSB6L.js +324 -0
- package/llms.txt +90 -57
- 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,794 @@ 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-select-multiple", 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
|
+
|
|
2026
|
+
// src/tabs.tsx
|
|
2027
|
+
import React8, { useEffect as useEffect4, useRef as useRef4, useState as useState4 } from "react";
|
|
2028
|
+
import {
|
|
2029
|
+
DirectionProvider,
|
|
2030
|
+
useDirection as useDirection2
|
|
2031
|
+
} from "@base-ui/react/direction-provider";
|
|
2032
|
+
import { Tabs as BTabs } from "@base-ui/react/tabs";
|
|
2033
|
+
import { Menu } from "@base-ui/react/menu";
|
|
2034
|
+
import { Plus, X as X3, Ellipsis } from "lucide-react";
|
|
2035
|
+
|
|
2036
|
+
// src/accent-colors.ts
|
|
2037
|
+
var accentNames = ["neutral", "blue", "green", "orange", "red", "purple", "teal", "coral"];
|
|
2038
|
+
function resolveAccentColor(color) {
|
|
2039
|
+
return accentNames.includes(color) ? `var(--mt-accent-${color})` : color;
|
|
2040
|
+
}
|
|
2041
|
+
|
|
2042
|
+
// src/tabs.tsx
|
|
2043
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2044
|
+
var Tabs = React8.forwardRef(function Tabs2({
|
|
2045
|
+
items,
|
|
2046
|
+
value,
|
|
2047
|
+
defaultValue,
|
|
2048
|
+
onValueChange,
|
|
2049
|
+
label,
|
|
2050
|
+
placement = "top",
|
|
2051
|
+
variant = "line",
|
|
2052
|
+
size = "medium",
|
|
2053
|
+
indicatorColor,
|
|
2054
|
+
centered = false,
|
|
2055
|
+
gap,
|
|
2056
|
+
extraStart,
|
|
2057
|
+
extraEnd,
|
|
2058
|
+
activateOnFocus = false,
|
|
2059
|
+
destroyOnHidden = true,
|
|
2060
|
+
hideAdd = false,
|
|
2061
|
+
addIcon,
|
|
2062
|
+
addLabel,
|
|
2063
|
+
moreLabel,
|
|
2064
|
+
onEdit,
|
|
2065
|
+
onTabClick,
|
|
2066
|
+
reorderable = false,
|
|
2067
|
+
onOrderChange,
|
|
2068
|
+
className,
|
|
2069
|
+
style,
|
|
2070
|
+
...props
|
|
2071
|
+
}, ref) {
|
|
2072
|
+
const { locale } = useMtone();
|
|
2073
|
+
const zh = locale === "zh";
|
|
2074
|
+
const inheritedDirection = useDirection2();
|
|
2075
|
+
const direction = props.dir === "rtl" || props.dir === "ltr" ? props.dir : inheritedDirection;
|
|
2076
|
+
const [internal, setInternal] = useState4(
|
|
2077
|
+
() => defaultValue ?? items.find((i) => !i.disabled)?.value ?? null
|
|
2078
|
+
);
|
|
2079
|
+
const controlled = value !== void 0;
|
|
2080
|
+
const selected = controlled ? value : internal;
|
|
2081
|
+
const [visited, setVisited] = useState4(
|
|
2082
|
+
() => new Set(selected == null ? [] : [selected])
|
|
1464
2083
|
);
|
|
1465
2084
|
const listRef = useRef4(null);
|
|
1466
2085
|
const [overflow, setOverflow] = useState4(false);
|
|
@@ -1662,7 +2281,7 @@ var Tabs = React8.forwardRef(function Tabs2({
|
|
|
1662
2281
|
disabled: item.disabled || !onEdit,
|
|
1663
2282
|
"aria-label": item.closeLabel ?? `${zh ? "\u5173\u95ED" : "Close"} ${typeof item.label === "string" ? item.label : item.value}`,
|
|
1664
2283
|
onClick: () => requestRemove(item),
|
|
1665
|
-
children: /* @__PURE__ */ jsx6(
|
|
2284
|
+
children: /* @__PURE__ */ jsx6(X3, { size: 12, "aria-hidden": "true" })
|
|
1666
2285
|
}
|
|
1667
2286
|
)
|
|
1668
2287
|
]
|
|
@@ -1897,21 +2516,7 @@ function ToastProvider({
|
|
|
1897
2516
|
}
|
|
1898
2517
|
|
|
1899
2518
|
// 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
|
-
}
|
|
2519
|
+
import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1915
2520
|
function Checkbox({
|
|
1916
2521
|
label,
|
|
1917
2522
|
children,
|
|
@@ -1971,174 +2576,6 @@ function RadioGroup({
|
|
|
1971
2576
|
}
|
|
1972
2577
|
);
|
|
1973
2578
|
}
|
|
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
2579
|
function Slider({ label, className, ...props }) {
|
|
2143
2580
|
props = { ...props, disabled: useFieldsetDisabled(props.disabled) };
|
|
2144
2581
|
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 +2775,7 @@ function InlineSubmenu({
|
|
|
2338
2775
|
}
|
|
2339
2776
|
function MenuItems({ items, onSelect }) {
|
|
2340
2777
|
const inline = React9.useContext(InlineMenuContext);
|
|
2341
|
-
return /* @__PURE__ */ jsx8(
|
|
2778
|
+
return /* @__PURE__ */ jsx8(Fragment5, { children: items.map((item, index) => {
|
|
2342
2779
|
if (item.type === "divider")
|
|
2343
2780
|
return inline ? /* @__PURE__ */ jsx8("hr", { className: "mt-menu-divider" }, item.key) : /* @__PURE__ */ jsx8(BMenu2.Separator, { className: "mt-menu-divider" }, item.key);
|
|
2344
2781
|
if (item.type === "group")
|
|
@@ -2735,84 +3172,30 @@ function PopoverFrame({
|
|
|
2735
3172
|
const { locale } = useMtone();
|
|
2736
3173
|
const hasTitle = title != null && title !== false && title !== "";
|
|
2737
3174
|
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
|
-
);
|
|
3175
|
+
const triggerElement = typeof trigger === "string" ? /* @__PURE__ */ jsx8(Button, { preset: "dropdown", style: { width: "fit-content", maxWidth: "100%" }, children: trigger }) : trigger;
|
|
3176
|
+
return /* @__PURE__ */ jsxs7(BPopover2.Root, { ...props, modal: false, children: [
|
|
3177
|
+
/* @__PURE__ */ jsx8(BPopover2.Trigger, { render: triggerElement }),
|
|
3178
|
+
/* @__PURE__ */ jsxs7(
|
|
3179
|
+
FloatingSurface,
|
|
3180
|
+
{
|
|
3181
|
+
side,
|
|
3182
|
+
align,
|
|
3183
|
+
width,
|
|
3184
|
+
unstyled,
|
|
3185
|
+
initialFocus,
|
|
3186
|
+
label: popupLabel,
|
|
3187
|
+
children: [
|
|
3188
|
+
hasTitle && (label !== void 0 ? /* @__PURE__ */ jsx8("h2", { className: "mt-popup-title", children: title }) : /* @__PURE__ */ jsx8(BPopover2.Title, { className: "mt-popup-title", children: title })),
|
|
3189
|
+
content2
|
|
3190
|
+
]
|
|
3191
|
+
}
|
|
3192
|
+
)
|
|
3193
|
+
] });
|
|
3194
|
+
}
|
|
3195
|
+
function PopoverRoot(props) {
|
|
3196
|
+
return /* @__PURE__ */ jsx8(PopoverFrame, { ...props });
|
|
2814
3197
|
}
|
|
2815
|
-
var Popover = Object.assign(PopoverRoot, { Menu: PopoverMenu
|
|
3198
|
+
var Popover = Object.assign(PopoverRoot, { Menu: PopoverMenu });
|
|
2816
3199
|
function Tooltip({
|
|
2817
3200
|
children,
|
|
2818
3201
|
content: content2,
|
|
@@ -2870,7 +3253,7 @@ function Dialog({
|
|
|
2870
3253
|
{
|
|
2871
3254
|
className: "mt-dialog-close",
|
|
2872
3255
|
"aria-label": locale === "zh" ? "\u5173\u95ED" : "Close",
|
|
2873
|
-
children: /* @__PURE__ */ jsx8(
|
|
3256
|
+
children: /* @__PURE__ */ jsx8(X4, { size: 18, "aria-hidden": "true" })
|
|
2874
3257
|
}
|
|
2875
3258
|
)
|
|
2876
3259
|
] }),
|
|
@@ -2977,7 +3360,7 @@ function Drawer({
|
|
|
2977
3360
|
}
|
|
2978
3361
|
|
|
2979
3362
|
// src/card.tsx
|
|
2980
|
-
import { Fragment as
|
|
3363
|
+
import { Fragment as Fragment7, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2981
3364
|
function hasContent(value) {
|
|
2982
3365
|
return React10.Children.toArray(value).some((child) => {
|
|
2983
3366
|
if (React10.isValidElement(child) && child.type === React10.Fragment) {
|
|
@@ -3083,7 +3466,7 @@ function CardRoot(props) {
|
|
|
3083
3466
|
/* @__PURE__ */ jsx9(Skeleton, { style: { height: 12 } }),
|
|
3084
3467
|
/* @__PURE__ */ jsx9(Skeleton, { style: { width: "80%", height: 12 } })
|
|
3085
3468
|
] }) : content2 });
|
|
3086
|
-
const cardContent = /* @__PURE__ */ jsxs8(
|
|
3469
|
+
const cardContent = /* @__PURE__ */ jsxs8(Fragment7, { children: [
|
|
3087
3470
|
hasContent(cover) && /* @__PURE__ */ jsx9("div", { className: cn("mt-card-cover", classes2.cover), style: css.cover, children: cover }),
|
|
3088
3471
|
hasTabs ? /* @__PURE__ */ jsxs8(
|
|
3089
3472
|
"div",
|
|
@@ -3161,7 +3544,7 @@ function CardRoot(props) {
|
|
|
3161
3544
|
if (collapsed === void 0) setLocalCollapsed(next);
|
|
3162
3545
|
onCollapsedChange?.(next);
|
|
3163
3546
|
},
|
|
3164
|
-
children: /* @__PURE__ */ jsx9(
|
|
3547
|
+
children: /* @__PURE__ */ jsx9(ChevronDown3, { size: 16, "aria-hidden": "true" })
|
|
3165
3548
|
}
|
|
3166
3549
|
),
|
|
3167
3550
|
hasContent(title) && /* @__PURE__ */ jsx9(
|
|
@@ -3275,11 +3658,11 @@ var Card = Object.assign(CardRoot, { Meta: CardMeta, Grid: CardGrid });
|
|
|
3275
3658
|
import * as React16 from "react";
|
|
3276
3659
|
import { Button as BaseButton } from "@base-ui/react/button";
|
|
3277
3660
|
import {
|
|
3278
|
-
ChevronDown as
|
|
3661
|
+
ChevronDown as ChevronDown4,
|
|
3279
3662
|
LoaderCircle as LoaderCircle3,
|
|
3280
3663
|
Pin,
|
|
3281
3664
|
Star,
|
|
3282
|
-
X as
|
|
3665
|
+
X as X6,
|
|
3283
3666
|
FileText,
|
|
3284
3667
|
Inbox,
|
|
3285
3668
|
Info as Info2,
|
|
@@ -3292,12 +3675,13 @@ import {
|
|
|
3292
3675
|
import React11 from "react";
|
|
3293
3676
|
|
|
3294
3677
|
// src/form-store.ts
|
|
3678
|
+
var emptyStringIsValue = /* @__PURE__ */ Symbol("emptyStringIsValue");
|
|
3295
3679
|
var own = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
3296
|
-
|
|
3297
|
-
async function validateRule(name, rule, value, values2) {
|
|
3680
|
+
async function validateRule(name, rule, value, values2, preserveEmptyString) {
|
|
3298
3681
|
const failure = (message) => rule.message ?? message;
|
|
3299
|
-
|
|
3300
|
-
if (
|
|
3682
|
+
const missing = value == null || !preserveEmptyString && value === "" || Array.isArray(value) && value.length === 0;
|
|
3683
|
+
if (missing && rule.required) return failure(`${name} is required`);
|
|
3684
|
+
if (!missing) {
|
|
3301
3685
|
if (rule.whitespace && typeof value === "string" && value.trim() === "")
|
|
3302
3686
|
return failure(`${name} cannot be blank`);
|
|
3303
3687
|
let typeValid = true;
|
|
@@ -3415,6 +3799,9 @@ function createFormStore(initialValues = {}) {
|
|
|
3415
3799
|
get rules() {
|
|
3416
3800
|
return config.rules ?? [];
|
|
3417
3801
|
},
|
|
3802
|
+
get emptyStringIsValue() {
|
|
3803
|
+
return config[emptyStringIsValue] === true;
|
|
3804
|
+
},
|
|
3418
3805
|
epoch: 0,
|
|
3419
3806
|
validating: false,
|
|
3420
3807
|
errors: previous?.errors ?? []
|
|
@@ -3485,13 +3872,15 @@ function createFormStore(initialValues = {}) {
|
|
|
3485
3872
|
const results = await Promise.all(
|
|
3486
3873
|
targets.map(async (target) => {
|
|
3487
3874
|
let error;
|
|
3875
|
+
const preserveEmptyString = target.field.emptyStringIsValue;
|
|
3488
3876
|
for (const rule of target.field.rules) {
|
|
3489
3877
|
if (stale(target)) break;
|
|
3490
3878
|
error = await validateRule(
|
|
3491
3879
|
target.name,
|
|
3492
3880
|
rule,
|
|
3493
3881
|
own(snapshot, target.name) ? snapshot[target.name] : void 0,
|
|
3494
|
-
snapshot
|
|
3882
|
+
snapshot,
|
|
3883
|
+
preserveEmptyString
|
|
3495
3884
|
);
|
|
3496
3885
|
if (error !== void 0) break;
|
|
3497
3886
|
}
|
|
@@ -3549,16 +3938,24 @@ function FormField({
|
|
|
3549
3938
|
const generatedId = React11.useId();
|
|
3550
3939
|
const child = children;
|
|
3551
3940
|
const inputId = child.props.id || generatedId;
|
|
3552
|
-
const
|
|
3941
|
+
const valueType = child.type.formValueType;
|
|
3942
|
+
const kind = typeof valueType === "function" ? valueType(child.props) : valueType;
|
|
3553
3943
|
const trigger = triggerProp ?? (kind ? "onValueChange" : "onChange");
|
|
3554
|
-
const
|
|
3555
|
-
rulesRef
|
|
3944
|
+
const preserveEmptyString = kind === "select-single" && valuePropName === "value";
|
|
3945
|
+
const rulesRef = React11.useRef({ rules, required, preserveEmptyString });
|
|
3946
|
+
rulesRef.current = { rules, required, preserveEmptyString };
|
|
3556
3947
|
React11.useEffect(() => {
|
|
3557
3948
|
if (!form || name === void 0) return;
|
|
3558
|
-
return form.register(name, {
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3949
|
+
return form.register(name, {
|
|
3950
|
+
get rules() {
|
|
3951
|
+
const latest = rulesRef.current;
|
|
3952
|
+
return latest.required && !latest.rules?.some((rule) => rule.required) ? [{ required: true }, ...latest.rules ?? []] : latest.rules ?? [];
|
|
3953
|
+
},
|
|
3954
|
+
get [emptyStringIsValue]() {
|
|
3955
|
+
return rulesRef.current.preserveEmptyString;
|
|
3956
|
+
},
|
|
3957
|
+
initialValue
|
|
3958
|
+
});
|
|
3562
3959
|
}, [form, name]);
|
|
3563
3960
|
const messages = form && name !== void 0 ? form.getFieldError(name) : [];
|
|
3564
3961
|
const managedError = messages.length ? messages.join(" ") : void 0;
|
|
@@ -3577,7 +3974,7 @@ function FormField({
|
|
|
3577
3974
|
};
|
|
3578
3975
|
if (form && name !== void 0) {
|
|
3579
3976
|
const value = form.getFieldValue(name);
|
|
3580
|
-
props[valuePropName] = value ?? (valuePropName === "checked" ? false : trigger === "onValueChange" ? kind === "array" || Array.isArray(initialValue) ? [] : null : "");
|
|
3977
|
+
props[valuePropName] = value ?? (valuePropName === "checked" ? false : trigger === "onValueChange" ? kind === "array" || kind !== "select-single" && Array.isArray(initialValue) ? [] : null : "");
|
|
3581
3978
|
props.name = name;
|
|
3582
3979
|
const modes = validateTrigger ?? context?.validateTrigger ?? "onChange";
|
|
3583
3980
|
const shouldValidate = (mode) => modes !== false && (Array.isArray(modes) ? modes.includes(mode) : modes === mode);
|
|
@@ -3864,8 +4261,8 @@ var Avatar2 = Object.assign(AvatarBase, { Group: AvatarGroup });
|
|
|
3864
4261
|
|
|
3865
4262
|
// src/progress.tsx
|
|
3866
4263
|
import * as React13 from "react";
|
|
3867
|
-
import { Check as Check3, X as
|
|
3868
|
-
import { Fragment as
|
|
4264
|
+
import { Check as Check3, X as X5 } from "lucide-react";
|
|
4265
|
+
import { Fragment as Fragment8, jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3869
4266
|
var finite = (n, fallback) => n !== void 0 && Number.isFinite(n) ? n : fallback;
|
|
3870
4267
|
var clamp = (n, min, max) => Math.min(max, Math.max(min, n));
|
|
3871
4268
|
var percent = (n) => clamp(finite(n, 0), 0, 100);
|
|
@@ -3927,7 +4324,7 @@ function Progress({
|
|
|
3927
4324
|
const paint = gradient ? `url(#mt-progress-${id})` : fill;
|
|
3928
4325
|
const background = gradient ? `linear-gradient(to right, ${fill.from}, ${fill.to})` : fill;
|
|
3929
4326
|
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(
|
|
4327
|
+
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
4328
|
const infoNode = showInfo && /* @__PURE__ */ jsx12("span", { className: "mt-progress-info", "aria-hidden": "true", children: info });
|
|
3932
4329
|
const radius = (100 - thickness) / 2;
|
|
3933
4330
|
const gap = type === "dashboard" ? clamp(finite(gapDegree, 75), 0, 295) : 0;
|
|
@@ -4011,7 +4408,7 @@ function Progress({
|
|
|
4011
4408
|
void 0,
|
|
4012
4409
|
linecap
|
|
4013
4410
|
) }, i);
|
|
4014
|
-
}) : /* @__PURE__ */ jsxs11(
|
|
4411
|
+
}) : /* @__PURE__ */ jsxs11(Fragment8, { children: [
|
|
4015
4412
|
path(
|
|
4016
4413
|
start,
|
|
4017
4414
|
sweep,
|
|
@@ -4060,7 +4457,7 @@ function Progress({
|
|
|
4060
4457
|
},
|
|
4061
4458
|
i
|
|
4062
4459
|
);
|
|
4063
|
-
}) : /* @__PURE__ */ jsxs11(
|
|
4460
|
+
}) : /* @__PURE__ */ jsxs11(Fragment8, { children: [
|
|
4064
4461
|
/* @__PURE__ */ jsx12(
|
|
4065
4462
|
"span",
|
|
4066
4463
|
{
|
|
@@ -4090,16 +4487,6 @@ import { Check as Check4, Copy, Pencil } from "lucide-react";
|
|
|
4090
4487
|
|
|
4091
4488
|
// src/typography-code-tokens.tsx
|
|
4092
4489
|
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
4490
|
function CodeTokens({ tokens }) {
|
|
4104
4491
|
return tokens.map(
|
|
4105
4492
|
({ text, light, dark }, index) => light || dark ? /* @__PURE__ */ jsx13(
|
|
@@ -4118,7 +4505,7 @@ function CodeTokens({ tokens }) {
|
|
|
4118
4505
|
}
|
|
4119
4506
|
|
|
4120
4507
|
// src/typography.tsx
|
|
4121
|
-
import { Fragment as
|
|
4508
|
+
import { Fragment as Fragment9, jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
4122
4509
|
function plainText(node) {
|
|
4123
4510
|
return React14.Children.toArray(node).map(
|
|
4124
4511
|
(child) => typeof child === "string" || typeof child === "number" ? String(child) : React14.isValidElement(child) ? plainText(child.props.children) : ""
|
|
@@ -4147,7 +4534,7 @@ var Content = React14.forwardRef(function Content2({
|
|
|
4147
4534
|
const en = locale === "en";
|
|
4148
4535
|
const copy = typeof copyable === "object" ? copyable : {};
|
|
4149
4536
|
const edit = typeof editable === "object" ? editable : {};
|
|
4150
|
-
const
|
|
4537
|
+
const clamp3 = typeof ellipsis === "object" ? ellipsis : {};
|
|
4151
4538
|
const source = edit.text ?? plainText(children);
|
|
4152
4539
|
const [value, setValue] = React14.useState(source);
|
|
4153
4540
|
React14.useEffect(() => setValue(source), [source]);
|
|
@@ -4155,9 +4542,9 @@ var Content = React14.forwardRef(function Content2({
|
|
|
4155
4542
|
const active = !!editable && !disabled && (edit.editing ?? editing);
|
|
4156
4543
|
const [draft, setDraft] = React14.useState(value);
|
|
4157
4544
|
const [expanded, setExpanded] = React14.useState(
|
|
4158
|
-
|
|
4545
|
+
clamp3.defaultExpanded ?? false
|
|
4159
4546
|
);
|
|
4160
|
-
const isExpanded =
|
|
4547
|
+
const isExpanded = clamp3.expanded ?? expanded;
|
|
4161
4548
|
const [status, setStatus] = React14.useState("idle");
|
|
4162
4549
|
const input = React14.useRef(null);
|
|
4163
4550
|
const editButton = React14.useRef(null);
|
|
@@ -4216,7 +4603,7 @@ var Content = React14.forwardRef(function Content2({
|
|
|
4216
4603
|
if (mark) text = /* @__PURE__ */ jsx14("mark", { children: text });
|
|
4217
4604
|
if (code) text = /* @__PURE__ */ jsx14("code", { children: text });
|
|
4218
4605
|
if (keyboard) text = /* @__PURE__ */ jsx14("kbd", { children: text });
|
|
4219
|
-
const rows = Number.isFinite(
|
|
4606
|
+
const rows = Number.isFinite(clamp3.rows) ? Math.max(1, Math.floor(clamp3.rows)) : 1;
|
|
4220
4607
|
const copyLabel = copy.label ?? (en ? "Copy" : "\u590D\u5236");
|
|
4221
4608
|
const editLabel = edit.label ?? (en ? "Edit" : "\u7F16\u8F91");
|
|
4222
4609
|
const content2 = active ? /* @__PURE__ */ jsx14(
|
|
@@ -4249,7 +4636,7 @@ var Content = React14.forwardRef(function Content2({
|
|
|
4249
4636
|
}
|
|
4250
4637
|
}
|
|
4251
4638
|
}
|
|
4252
|
-
) : /* @__PURE__ */ jsxs12(
|
|
4639
|
+
) : /* @__PURE__ */ jsxs12(Fragment9, { children: [
|
|
4253
4640
|
!ellipsis ? text : /* @__PURE__ */ jsx14(
|
|
4254
4641
|
"span",
|
|
4255
4642
|
{
|
|
@@ -4266,7 +4653,7 @@ var Content = React14.forwardRef(function Content2({
|
|
|
4266
4653
|
children: text
|
|
4267
4654
|
}
|
|
4268
4655
|
),
|
|
4269
|
-
!!ellipsis &&
|
|
4656
|
+
!!ellipsis && clamp3.expandable && /* @__PURE__ */ jsx14(
|
|
4270
4657
|
"button",
|
|
4271
4658
|
{
|
|
4272
4659
|
type: "button",
|
|
@@ -4275,9 +4662,9 @@ var Content = React14.forwardRef(function Content2({
|
|
|
4275
4662
|
"aria-expanded": isExpanded,
|
|
4276
4663
|
onClick: () => {
|
|
4277
4664
|
setExpanded(!isExpanded);
|
|
4278
|
-
|
|
4665
|
+
clamp3.onExpandedChange?.(!isExpanded);
|
|
4279
4666
|
},
|
|
4280
|
-
children: isExpanded ?
|
|
4667
|
+
children: isExpanded ? clamp3.collapseLabel ?? (en ? "Collapse" : "\u6536\u8D77") : clamp3.expandLabel ?? (en ? "Expand" : "\u5C55\u5F00")
|
|
4281
4668
|
}
|
|
4282
4669
|
),
|
|
4283
4670
|
!!copyable && /* @__PURE__ */ jsx14(
|
|
@@ -4431,13 +4818,12 @@ var Code = React14.forwardRef(function Code2({ block = false, language, children
|
|
|
4431
4818
|
}, []);
|
|
4432
4819
|
const [overflows, setOverflows] = React14.useState(false);
|
|
4433
4820
|
const [highlight, setHighlight] = React14.useState();
|
|
4434
|
-
const
|
|
4435
|
-
const supported = block && codeLanguages.find((value) => value === candidateLanguage);
|
|
4821
|
+
const supported = block && language ? resolveCodeLanguage(language) : void 0;
|
|
4436
4822
|
const text = typeof children === "string" ? children : void 0;
|
|
4437
4823
|
React14.useEffect(() => {
|
|
4438
4824
|
if (!supported || !text) return;
|
|
4439
4825
|
let active = true;
|
|
4440
|
-
import("./typography-highlight-
|
|
4826
|
+
import("./typography-highlight-GAYKSB6L.js").then(({ highlightCode }) => highlightCode(text, supported)).then((tokens2) => {
|
|
4441
4827
|
if (active) setHighlight({ text, language: supported, tokens: tokens2 });
|
|
4442
4828
|
}).catch(() => {
|
|
4443
4829
|
});
|
|
@@ -4608,7 +4994,7 @@ var Button = React16.forwardRef(
|
|
|
4608
4994
|
const iconToggle = toggle && typeof toggle === "object" && toggle.mode === "icon" ? toggle : void 0;
|
|
4609
4995
|
const Preset = iconToggle?.preset === "star" ? Star : iconToggle?.preset === "pin" ? Pin : void 0;
|
|
4610
4996
|
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(
|
|
4997
|
+
const trailing = rightSection === void 0 && preset === "dropdown" ? /* @__PURE__ */ jsx16(ChevronDown4, { size: 14, "aria-hidden": "true" }) : rightSection;
|
|
4612
4998
|
return /* @__PURE__ */ jsxs13(
|
|
4613
4999
|
BaseButton,
|
|
4614
5000
|
{
|
|
@@ -4671,7 +5057,7 @@ function Tag({
|
|
|
4671
5057
|
variant: "ghost",
|
|
4672
5058
|
"aria-label": locale === "zh" ? "\u79FB\u9664\u7B5B\u9009" : "Remove filter",
|
|
4673
5059
|
onClick: onRemove,
|
|
4674
|
-
children: /* @__PURE__ */ jsx16(
|
|
5060
|
+
children: /* @__PURE__ */ jsx16(X6, { size: 12, "aria-hidden": "true" })
|
|
4675
5061
|
}
|
|
4676
5062
|
)
|
|
4677
5063
|
] });
|
|
@@ -4684,7 +5070,7 @@ function Tag({
|
|
|
4684
5070
|
type: "button",
|
|
4685
5071
|
onClick: onRemove,
|
|
4686
5072
|
"aria-label": locale === "zh" ? "\u79FB\u9664\u6807\u7B7E" : "Remove tag",
|
|
4687
|
-
children: /* @__PURE__ */ jsx16(
|
|
5073
|
+
children: /* @__PURE__ */ jsx16(X6, { size: 11 })
|
|
4688
5074
|
}
|
|
4689
5075
|
)
|
|
4690
5076
|
] });
|
|
@@ -4753,7 +5139,7 @@ function Alert({
|
|
|
4753
5139
|
title && /* @__PURE__ */ jsx16("strong", { children: title }),
|
|
4754
5140
|
children && /* @__PURE__ */ jsx16("div", { children })
|
|
4755
5141
|
] }),
|
|
4756
|
-
onClose && /* @__PURE__ */ jsx16(Button, { iconOnly: true, "aria-label": "Close", variant: "ghost", onClick: onClose, children: /* @__PURE__ */ jsx16(
|
|
5142
|
+
onClose && /* @__PURE__ */ jsx16(Button, { iconOnly: true, "aria-label": "Close", variant: "ghost", onClick: onClose, children: /* @__PURE__ */ jsx16(X6, { size: 14, "aria-hidden": "true" }) })
|
|
4757
5143
|
]
|
|
4758
5144
|
}
|
|
4759
5145
|
);
|
|
@@ -4783,13 +5169,13 @@ function Spinner({ label = "Loading" }) {
|
|
|
4783
5169
|
import * as React17 from "react";
|
|
4784
5170
|
import {
|
|
4785
5171
|
ChevronRight as ChevronRight2,
|
|
4786
|
-
ChevronDown as
|
|
5172
|
+
ChevronDown as ChevronDown5,
|
|
4787
5173
|
PanelLeftClose,
|
|
4788
5174
|
PanelLeftOpen,
|
|
4789
5175
|
Circle
|
|
4790
5176
|
} from "lucide-react";
|
|
4791
5177
|
import { Popover as BPopover3 } from "@base-ui/react/popover";
|
|
4792
|
-
import { Fragment as
|
|
5178
|
+
import { Fragment as Fragment11, jsx as jsx17, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
4793
5179
|
var SidebarContext = React17.createContext(false);
|
|
4794
5180
|
var NavSubmenuSelectionContext = React17.createContext(null);
|
|
4795
5181
|
function Sidebar({
|
|
@@ -4797,6 +5183,7 @@ function Sidebar({
|
|
|
4797
5183
|
children,
|
|
4798
5184
|
header,
|
|
4799
5185
|
footer,
|
|
5186
|
+
tabs,
|
|
4800
5187
|
collapsePlacement = "header",
|
|
4801
5188
|
collapsible = false,
|
|
4802
5189
|
collapsed,
|
|
@@ -4809,6 +5196,11 @@ function Sidebar({
|
|
|
4809
5196
|
const [internal, setInternal] = React17.useState(defaultCollapsed);
|
|
4810
5197
|
const isCollapsed = collapsible && (collapsed ?? internal);
|
|
4811
5198
|
const contentId = React17.useId();
|
|
5199
|
+
const items = React17.useMemo(() => tabs?.items.map(({ content: content2, ...item }) => ({
|
|
5200
|
+
...item,
|
|
5201
|
+
content: /* @__PURE__ */ jsx17("div", { className: "mt-sidebar-content", children: content2 })
|
|
5202
|
+
})), [tabs?.items]);
|
|
5203
|
+
const hasTabs = !!items?.length;
|
|
4812
5204
|
const toggle = collapsible && /* @__PURE__ */ jsx17(
|
|
4813
5205
|
Button,
|
|
4814
5206
|
{
|
|
@@ -4830,14 +5222,29 @@ function Sidebar({
|
|
|
4830
5222
|
"aside",
|
|
4831
5223
|
{
|
|
4832
5224
|
...p,
|
|
4833
|
-
className: cn("mt-sidebar", className),
|
|
5225
|
+
className: cn("mt-sidebar", hasTabs && "mt-sidebar-with-tabs", className),
|
|
4834
5226
|
"data-collapsed": isCollapsed,
|
|
4835
5227
|
children: [
|
|
4836
5228
|
header !== void 0 ? /* @__PURE__ */ jsxs14("div", { className: "mt-sidebar-heading", children: [
|
|
4837
5229
|
/* @__PURE__ */ jsx17("div", { className: "mt-sidebar-brand", children: typeof header === "function" ? header(isCollapsed) : header }),
|
|
4838
5230
|
collapsePlacement === "header" && toggle
|
|
4839
5231
|
] }) : collapsePlacement === "header" && toggle,
|
|
4840
|
-
|
|
5232
|
+
tabs && items?.length ? /* @__PURE__ */ jsx17("div", { id: contentId, className: "mt-sidebar-tab-region", children: /* @__PURE__ */ jsx17(
|
|
5233
|
+
Tabs,
|
|
5234
|
+
{
|
|
5235
|
+
className: "mt-sidebar-tabs",
|
|
5236
|
+
items,
|
|
5237
|
+
label: tabs.label,
|
|
5238
|
+
value: tabs.value,
|
|
5239
|
+
defaultValue: tabs.defaultValue,
|
|
5240
|
+
onValueChange: tabs.onValueChange,
|
|
5241
|
+
placement: "top",
|
|
5242
|
+
variant: "line",
|
|
5243
|
+
size: "small",
|
|
5244
|
+
indicatorColor: "blue",
|
|
5245
|
+
destroyOnHidden: false
|
|
5246
|
+
}
|
|
5247
|
+
) }) : collapsible || header !== void 0 ? /* @__PURE__ */ jsx17("div", { id: contentId, className: "mt-sidebar-content", children }) : children,
|
|
4841
5248
|
(footer !== void 0 || collapsePlacement === "footer" && collapsible) && /* @__PURE__ */ jsxs14("div", { className: "mt-sidebar-footer", children: [
|
|
4842
5249
|
footer !== void 0 && /* @__PURE__ */ jsx17("div", { className: "mt-sidebar-footer-content", children: typeof footer === "function" ? footer(isCollapsed) : footer }),
|
|
4843
5250
|
collapsePlacement === "footer" && toggle
|
|
@@ -4860,7 +5267,7 @@ var NavItem = React17.forwardRef(
|
|
|
4860
5267
|
"aria-current": active ? "page" : void 0,
|
|
4861
5268
|
className: cn("mt-nav-item", active && "mt-active", collapsed && "mt-nav-item-collapsed", className)
|
|
4862
5269
|
};
|
|
4863
|
-
const content2 = /* @__PURE__ */ jsxs14(
|
|
5270
|
+
const content2 = /* @__PURE__ */ jsxs14(Fragment11, { children: [
|
|
4864
5271
|
icon || (collapsed ? /* @__PURE__ */ jsx17(Circle, { size: 16, "aria-hidden": "true" }) : null),
|
|
4865
5272
|
collapsed ? /* @__PURE__ */ jsx17("span", { className: "mt-sidebar-sr-only", children }) : plainLabel ? /* @__PURE__ */ jsx17("span", { className: "mt-nav-item-label", children }) : children
|
|
4866
5273
|
] });
|
|
@@ -4998,7 +5405,7 @@ function NavSubmenu({
|
|
|
4998
5405
|
collapsed ? "mt-sidebar-sr-only" : "mt-nav-item-label",
|
|
4999
5406
|
hasActiveNavItem(children) && "mt-nav-submenu-label-active"
|
|
5000
5407
|
), children: label }),
|
|
5001
|
-
!collapsed && /* @__PURE__ */ jsx17(
|
|
5408
|
+
!collapsed && /* @__PURE__ */ jsx17(ChevronDown5, { size: 14, className: "mt-nav-submenu-chevron", "aria-hidden": "true" })
|
|
5002
5409
|
]
|
|
5003
5410
|
}
|
|
5004
5411
|
);
|
|
@@ -5052,7 +5459,7 @@ function NavSubmenu({
|
|
|
5052
5459
|
) }) })
|
|
5053
5460
|
]
|
|
5054
5461
|
}
|
|
5055
|
-
) : /* @__PURE__ */ jsxs14(
|
|
5462
|
+
) : /* @__PURE__ */ jsxs14(Fragment11, { children: [
|
|
5056
5463
|
trigger,
|
|
5057
5464
|
/* @__PURE__ */ jsx17("div", { id: panelId, className: "mt-nav-submenu-children", hidden: !inlineOpen, children })
|
|
5058
5465
|
] })
|
|
@@ -5069,7 +5476,7 @@ function Breadcrumb({
|
|
|
5069
5476
|
return /* @__PURE__ */ jsx17("nav", { "aria-label": label, ...props, children: /* @__PURE__ */ jsx17("ol", { className: "mt-breadcrumb", children: items.map((item, i) => {
|
|
5070
5477
|
const current = i === items.length - 1;
|
|
5071
5478
|
const hasMenu = !item.disabled && !!item.menu?.items.length;
|
|
5072
|
-
const content2 = /* @__PURE__ */ jsxs14(
|
|
5479
|
+
const content2 = /* @__PURE__ */ jsxs14(Fragment11, { children: [
|
|
5073
5480
|
item.icon != null && /* @__PURE__ */ jsx17("span", { className: "mt-breadcrumb-icon", "aria-hidden": "true", children: item.icon }),
|
|
5074
5481
|
item.label
|
|
5075
5482
|
] });
|
|
@@ -5115,7 +5522,7 @@ function Breadcrumb({
|
|
|
5115
5522
|
"aria-labelledby": separateTrigger && !item["aria-label"] ? `${id}-${i}` : void 0,
|
|
5116
5523
|
children: [
|
|
5117
5524
|
!separateTrigger && content2,
|
|
5118
|
-
/* @__PURE__ */ jsx17(
|
|
5525
|
+
/* @__PURE__ */ jsx17(ChevronDown5, { size: 12, "aria-hidden": "true" })
|
|
5119
5526
|
]
|
|
5120
5527
|
}
|
|
5121
5528
|
)
|
|
@@ -5132,7 +5539,7 @@ import { Upload as UploadIcon } from "lucide-react";
|
|
|
5132
5539
|
|
|
5133
5540
|
// src/pagination-controls.tsx
|
|
5134
5541
|
import * as React18 from "react";
|
|
5135
|
-
import { Fragment as
|
|
5542
|
+
import { Fragment as Fragment13, jsx as jsx18, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
5136
5543
|
function getPaginationWindow(count2, current) {
|
|
5137
5544
|
return Array.from(
|
|
5138
5545
|
/* @__PURE__ */ new Set([
|
|
@@ -5156,7 +5563,7 @@ function PaginationControls({
|
|
|
5156
5563
|
}) {
|
|
5157
5564
|
const pages = simple ? [] : getPaginationWindow(count2, current);
|
|
5158
5565
|
const content2 = (page, type, label) => renderItem ? renderItem(page, type, label) : label;
|
|
5159
|
-
return /* @__PURE__ */ jsxs15(
|
|
5566
|
+
return /* @__PURE__ */ jsxs15(Fragment13, { children: [
|
|
5160
5567
|
/* @__PURE__ */ jsx18(
|
|
5161
5568
|
Button,
|
|
5162
5569
|
{
|
|
@@ -5204,7 +5611,7 @@ import RcTableImport, {
|
|
|
5204
5611
|
Summary
|
|
5205
5612
|
} from "@rc-component/table";
|
|
5206
5613
|
import {
|
|
5207
|
-
ChevronDown as
|
|
5614
|
+
ChevronDown as ChevronDown7,
|
|
5208
5615
|
ChevronRight as ChevronRight4,
|
|
5209
5616
|
ArrowUp,
|
|
5210
5617
|
ArrowDown,
|
|
@@ -5265,7 +5672,7 @@ function processTableData(data, columns, sorts, filters, textFilters, manual, ch
|
|
|
5265
5672
|
import * as React19 from "react";
|
|
5266
5673
|
import { Popover as Popover3 } from "@base-ui/react/popover";
|
|
5267
5674
|
import { Filter, ChevronRight as ChevronRight3 } from "lucide-react";
|
|
5268
|
-
import { Fragment as
|
|
5675
|
+
import { Fragment as Fragment14, jsx as jsx19, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
5269
5676
|
var sameValues = (a, b) => a.length === b.length && a.every((value, index) => value === b[index]);
|
|
5270
5677
|
function plainText2(node) {
|
|
5271
5678
|
if (typeof node === "string" || typeof node === "number") return String(node);
|
|
@@ -5525,7 +5932,7 @@ function TableFilter({
|
|
|
5525
5932
|
style: column.filterDropdownProps?.style,
|
|
5526
5933
|
"aria-label": filterLabel,
|
|
5527
5934
|
onClick: (event) => event.stopPropagation(),
|
|
5528
|
-
children: column.filterDropdown !== void 0 ? typeof column.filterDropdown === "function" ? column.filterDropdown(customProps) : column.filterDropdown : /* @__PURE__ */ jsxs16(
|
|
5935
|
+
children: column.filterDropdown !== void 0 ? typeof column.filterDropdown === "function" ? column.filterDropdown(customProps) : column.filterDropdown : /* @__PURE__ */ jsxs16(Fragment14, { children: [
|
|
5529
5936
|
column.filterSearch && /* @__PURE__ */ jsx19(
|
|
5530
5937
|
"input",
|
|
5531
5938
|
{
|
|
@@ -5561,7 +5968,7 @@ function TableFilter({
|
|
|
5561
5968
|
|
|
5562
5969
|
// src/table-selection.tsx
|
|
5563
5970
|
import * as React20 from "react";
|
|
5564
|
-
import { ChevronDown as
|
|
5971
|
+
import { ChevronDown as ChevronDown6 } from "lucide-react";
|
|
5565
5972
|
import { INTERNAL_COL_DEFINE } from "@rc-component/table";
|
|
5566
5973
|
import { jsx as jsx20, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
5567
5974
|
function useTableSelection({
|
|
@@ -5800,7 +6207,7 @@ function useTableSelection({
|
|
|
5800
6207
|
className: "mt-table-selection-actions",
|
|
5801
6208
|
"aria-label": locale.selectionActions ?? (zh ? "\u9009\u62E9\u64CD\u4F5C" : "Selection actions"),
|
|
5802
6209
|
onClick: (event) => event.stopPropagation(),
|
|
5803
|
-
children: /* @__PURE__ */ jsx20(
|
|
6210
|
+
children: /* @__PURE__ */ jsx20(ChevronDown6, { size: 12, "aria-hidden": "true" })
|
|
5804
6211
|
}
|
|
5805
6212
|
),
|
|
5806
6213
|
items: commands.map((command, index) => ({
|
|
@@ -5975,7 +6382,7 @@ function TablePaginationBar({
|
|
|
5975
6382
|
}
|
|
5976
6383
|
|
|
5977
6384
|
// src/table.tsx
|
|
5978
|
-
import { Fragment as
|
|
6385
|
+
import { Fragment as Fragment16, jsx as jsx22, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
5979
6386
|
var SELECTION_COLUMN = Object.freeze({ key: "__mt_selection_column" });
|
|
5980
6387
|
function Column(_props) {
|
|
5981
6388
|
return null;
|
|
@@ -6014,7 +6421,7 @@ function useResponsive() {
|
|
|
6014
6421
|
}, []);
|
|
6015
6422
|
return width;
|
|
6016
6423
|
}
|
|
6017
|
-
function useCompactSelectionWidth(ref, compactWidth, virtual, separateHeader,
|
|
6424
|
+
function useCompactSelectionWidth(ref, compactWidth, virtual, separateHeader, empty, scrollX, layoutKey, tableComponent) {
|
|
6018
6425
|
const [fitWidth, setFitWidth] = React22.useState(0);
|
|
6019
6426
|
React22.useLayoutEffect(() => {
|
|
6020
6427
|
if (compactWidth === void 0) return;
|
|
@@ -6024,7 +6431,7 @@ function useCompactSelectionWidth(ref, compactWidth, virtual, separateHeader, em
|
|
|
6024
6431
|
const body = !virtual && root.querySelector(
|
|
6025
6432
|
container + ":is(.mt-table-body, .mt-table-content) > table"
|
|
6026
6433
|
);
|
|
6027
|
-
const holders = !virtual &&
|
|
6434
|
+
const holders = !virtual && empty && separateHeader ? root.querySelectorAll(
|
|
6028
6435
|
container + ":is(.mt-table-header, .mt-table-summary) > table"
|
|
6029
6436
|
) : [];
|
|
6030
6437
|
const tables = body ? [body, ...holders] : [...holders];
|
|
@@ -6072,7 +6479,7 @@ function useCompactSelectionWidth(ref, compactWidth, virtual, separateHeader, em
|
|
|
6072
6479
|
};
|
|
6073
6480
|
}, [
|
|
6074
6481
|
compactWidth,
|
|
6075
|
-
|
|
6482
|
+
empty,
|
|
6076
6483
|
layoutKey,
|
|
6077
6484
|
ref,
|
|
6078
6485
|
scrollX,
|
|
@@ -6129,7 +6536,7 @@ function TableInner(props, forwardedRef) {
|
|
|
6129
6536
|
selectedKeys,
|
|
6130
6537
|
onSelectionChange,
|
|
6131
6538
|
loading = false,
|
|
6132
|
-
empty
|
|
6539
|
+
empty,
|
|
6133
6540
|
locale = {},
|
|
6134
6541
|
size = "middle",
|
|
6135
6542
|
bordered = false,
|
|
@@ -6364,7 +6771,7 @@ function TableInner(props, forwardedRef) {
|
|
|
6364
6771
|
...c,
|
|
6365
6772
|
key,
|
|
6366
6773
|
dataIndex: c.dataIndex ?? (c.key == null ? void 0 : String(c.key)),
|
|
6367
|
-
title: /* @__PURE__ */ jsxs19(
|
|
6774
|
+
title: /* @__PURE__ */ jsxs19(Fragment16, { children: [
|
|
6368
6775
|
/* @__PURE__ */ jsxs19(
|
|
6369
6776
|
"div",
|
|
6370
6777
|
{
|
|
@@ -6473,7 +6880,7 @@ function TableInner(props, forwardedRef) {
|
|
|
6473
6880
|
"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
6881
|
"aria-expanded": p.expanded,
|
|
6475
6882
|
onClick: p.onClick,
|
|
6476
|
-
children: p.expanded ? /* @__PURE__ */ jsx22(
|
|
6883
|
+
children: p.expanded ? /* @__PURE__ */ jsx22(ChevronDown7, { size: 14 }) : /* @__PURE__ */ jsx22(ChevronRight4, { size: 14 })
|
|
6477
6884
|
}
|
|
6478
6885
|
) : /* @__PURE__ */ jsx22("span", { className: "mt-table-expand-placeholder" }))
|
|
6479
6886
|
};
|
|
@@ -6510,7 +6917,7 @@ function TableInner(props, forwardedRef) {
|
|
|
6510
6917
|
scroll,
|
|
6511
6918
|
expandable: resolvedExpandable,
|
|
6512
6919
|
components: rcComponents,
|
|
6513
|
-
emptyText: showLoading ? null :
|
|
6920
|
+
emptyText: showLoading ? null : empty ?? locale.emptyText ?? (zh ? "\u6682\u65E0\u6570\u636E" : "No data"),
|
|
6514
6921
|
classNames: resolvedClasses,
|
|
6515
6922
|
styles: resolvedStyles,
|
|
6516
6923
|
rowClassName: (r, i, indent) => cn(
|
|
@@ -6589,7 +6996,7 @@ var Table = Object.assign(
|
|
|
6589
6996
|
// src/tree.tsx
|
|
6590
6997
|
import * as React23 from "react";
|
|
6591
6998
|
import {
|
|
6592
|
-
ChevronDown as
|
|
6999
|
+
ChevronDown as ChevronDown8,
|
|
6593
7000
|
ChevronRight as ChevronRight5,
|
|
6594
7001
|
LoaderCircle as LoaderCircle4,
|
|
6595
7002
|
Folder,
|
|
@@ -7285,7 +7692,7 @@ var Tree = React23.forwardRef(function Tree2({
|
|
|
7285
7692
|
expand(node, errors.has(node.id) ? true : !isOpen);
|
|
7286
7693
|
}
|
|
7287
7694
|
},
|
|
7288
|
-
children: busy ? switcherLoadingIcon ?? /* @__PURE__ */ jsx23(LoaderCircle4, { size: 14 }) : isBranch ? (typeof switcherIcon === "function" ? switcherIcon(info) : switcherIcon) ?? (isOpen ? /* @__PURE__ */ jsx23(
|
|
7695
|
+
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
7696
|
}
|
|
7290
7697
|
),
|
|
7291
7698
|
checkable && node.checkable !== false && /* @__PURE__ */ jsx23(
|
|
@@ -7339,7 +7746,7 @@ var Tree = React23.forwardRef(function Tree2({
|
|
|
7339
7746
|
});
|
|
7340
7747
|
|
|
7341
7748
|
// src/data.tsx
|
|
7342
|
-
import { Fragment as
|
|
7749
|
+
import { Fragment as Fragment17, jsx as jsx24, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
7343
7750
|
function Pagination({
|
|
7344
7751
|
total,
|
|
7345
7752
|
pageSize = 10,
|
|
@@ -7583,7 +7990,7 @@ function Upload({
|
|
|
7583
7990
|
error: zh ? "\u4E0A\u4F20\u5931\u8D25" : "Failed"
|
|
7584
7991
|
}[f.status] })
|
|
7585
7992
|
] }),
|
|
7586
|
-
f.status === "uploading" && /* @__PURE__ */ jsxs21(
|
|
7993
|
+
f.status === "uploading" && /* @__PURE__ */ jsxs21(Fragment17, { children: [
|
|
7587
7994
|
/* @__PURE__ */ jsx24(
|
|
7588
7995
|
"progress",
|
|
7589
7996
|
{
|
|
@@ -7760,7 +8167,7 @@ var AdminLayout = Object.assign(AdminLayoutRoot, {
|
|
|
7760
8167
|
|
|
7761
8168
|
// src/global-notice.tsx
|
|
7762
8169
|
import * as React26 from "react";
|
|
7763
|
-
import { ShieldAlert, X as
|
|
8170
|
+
import { ShieldAlert, X as X7 } from "lucide-react";
|
|
7764
8171
|
import { jsx as jsx26, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
7765
8172
|
function GlobalNotice({
|
|
7766
8173
|
title,
|
|
@@ -7806,8 +8213,8 @@ function GlobalNotice({
|
|
|
7806
8213
|
"aria-label": label ? void 0 : dismissLabel,
|
|
7807
8214
|
loading,
|
|
7808
8215
|
onClick: onAction,
|
|
7809
|
-
rightSection: label && !loading ? /* @__PURE__ */ jsx26(
|
|
7810
|
-
children: label || !loading && /* @__PURE__ */ jsx26(
|
|
8216
|
+
rightSection: label && !loading ? /* @__PURE__ */ jsx26(X7, { size: 14, "aria-hidden": "true" }) : void 0,
|
|
8217
|
+
children: label || !loading && /* @__PURE__ */ jsx26(X7, { size: 14, "aria-hidden": "true" })
|
|
7811
8218
|
}
|
|
7812
8219
|
)
|
|
7813
8220
|
]
|
|
@@ -8631,7 +9038,7 @@ function SplitterRoot(props) {
|
|
|
8631
9038
|
max,
|
|
8632
9039
|
resizable = true,
|
|
8633
9040
|
collapsible = false,
|
|
8634
|
-
collapsedSize = 0,
|
|
9041
|
+
collapsedSize: collapsedSize2 = 0,
|
|
8635
9042
|
groupResizeBehavior,
|
|
8636
9043
|
children: panelChildren,
|
|
8637
9044
|
...p
|
|
@@ -8653,7 +9060,7 @@ function SplitterRoot(props) {
|
|
|
8653
9060
|
maxSize: max,
|
|
8654
9061
|
disabled: !resizable,
|
|
8655
9062
|
collapsible,
|
|
8656
|
-
collapsedSize,
|
|
9063
|
+
collapsedSize: collapsedSize2,
|
|
8657
9064
|
groupResizeBehavior,
|
|
8658
9065
|
className: cn("mt-splitter-panel", p.className)
|
|
8659
9066
|
},
|
|
@@ -8698,7 +9105,7 @@ var Splitter = Object.assign(SplitterRoot, { Panel: SplitterPanel });
|
|
|
8698
9105
|
// src/mentions.tsx
|
|
8699
9106
|
import * as React31 from "react";
|
|
8700
9107
|
import { createPortal } from "react-dom";
|
|
8701
|
-
import { X as
|
|
9108
|
+
import { X as X8, LoaderCircle as LoaderCircle5 } from "lucide-react";
|
|
8702
9109
|
|
|
8703
9110
|
// src/mentions-model.ts
|
|
8704
9111
|
function mentionPrefixes(prefix) {
|
|
@@ -8789,11 +9196,11 @@ function caretRect(input, caret) {
|
|
|
8789
9196
|
width: `${input.clientWidth ? input.clientWidth + parseFloat(computed.borderLeftWidth) + parseFloat(computed.borderRightWidth) : rect.width}px`
|
|
8790
9197
|
});
|
|
8791
9198
|
mirror.textContent = input.value.slice(0, caret);
|
|
8792
|
-
const
|
|
8793
|
-
|
|
8794
|
-
mirror.append(
|
|
9199
|
+
const marker2 = document.createElement("span");
|
|
9200
|
+
marker2.textContent = input.value.slice(caret) || "\u200B";
|
|
9201
|
+
mirror.append(marker2);
|
|
8795
9202
|
document.body.append(mirror);
|
|
8796
|
-
const markerRect =
|
|
9203
|
+
const markerRect = marker2.getClientRects()[0] ?? marker2.getBoundingClientRect(), mirrorRect = mirror.getBoundingClientRect();
|
|
8797
9204
|
const left = rect.left + markerRect.left - mirrorRect.left - input.scrollLeft;
|
|
8798
9205
|
const top = rect.top + markerRect.top - mirrorRect.top - input.scrollTop;
|
|
8799
9206
|
mirror.remove();
|
|
@@ -9190,7 +9597,7 @@ var Mentions = React31.forwardRef(
|
|
|
9190
9597
|
onClear?.();
|
|
9191
9598
|
inputRef.current?.focus();
|
|
9192
9599
|
},
|
|
9193
|
-
children: clearConfig.clearIcon ?? /* @__PURE__ */ jsx31(
|
|
9600
|
+
children: clearConfig.clearIcon ?? /* @__PURE__ */ jsx31(X8, { size: 13, "aria-hidden": true })
|
|
9194
9601
|
}
|
|
9195
9602
|
),
|
|
9196
9603
|
popup && createPortal(
|
|
@@ -9241,7 +9648,7 @@ function isoWeek(value) {
|
|
|
9241
9648
|
}
|
|
9242
9649
|
|
|
9243
9650
|
// src/calendar.tsx
|
|
9244
|
-
import { Fragment as
|
|
9651
|
+
import { Fragment as Fragment21, jsx as jsx32, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
9245
9652
|
function Calendar({
|
|
9246
9653
|
value,
|
|
9247
9654
|
defaultValue,
|
|
@@ -9282,18 +9689,18 @@ function Calendar({
|
|
|
9282
9689
|
throw new RangeError(
|
|
9283
9690
|
"Calendar validRange must be an ordered pair of YYYY-MM-DD dates"
|
|
9284
9691
|
);
|
|
9285
|
-
const
|
|
9286
|
-
const [local, setLocal] = React32.useState(() =>
|
|
9692
|
+
const clamp3 = (v) => validRange ? v < validRange[0] ? validRange[0] : v > validRange[1] ? validRange[1] : v : v;
|
|
9693
|
+
const [local, setLocal] = React32.useState(() => clamp3(defaultValue ?? today));
|
|
9287
9694
|
const current = value ?? local;
|
|
9288
9695
|
const [localMode, setLocalMode] = React32.useState(defaultMode);
|
|
9289
9696
|
const type = mode ?? localMode;
|
|
9290
|
-
const [view, setView] = React32.useState(() =>
|
|
9291
|
-
const [focus, setFocus] = React32.useState(() =>
|
|
9697
|
+
const [view, setView] = React32.useState(() => clamp3(current));
|
|
9698
|
+
const [focus, setFocus] = React32.useState(() => clamp3(current));
|
|
9292
9699
|
const gridFocused = React32.useRef(false);
|
|
9293
9700
|
React32.useEffect(() => {
|
|
9294
9701
|
pending.current = gridFocused.current;
|
|
9295
|
-
setView(
|
|
9296
|
-
setFocus(
|
|
9702
|
+
setView(clamp3(current));
|
|
9703
|
+
setFocus(clamp3(current));
|
|
9297
9704
|
}, [current, validRange?.[0], validRange?.[1]]);
|
|
9298
9705
|
const root = React32.useRef(null);
|
|
9299
9706
|
const pending = React32.useRef(false);
|
|
@@ -9311,7 +9718,7 @@ function Calendar({
|
|
|
9311
9718
|
const unavailable = (v) => !parseCalendarDate(v) || disabled || Boolean(validRange && (v < validRange[0] || v > validRange[1])) || Boolean(disabledDate?.(v));
|
|
9312
9719
|
const emit = (v, source, nextMode = type) => {
|
|
9313
9720
|
if (!parseCalendarDate(v) || disabled) return;
|
|
9314
|
-
let next =
|
|
9721
|
+
let next = clamp3(v);
|
|
9315
9722
|
if (unavailable(next)) {
|
|
9316
9723
|
if (source !== "month" && source !== "year") return;
|
|
9317
9724
|
const candidate = monthCandidate(next);
|
|
@@ -9361,7 +9768,7 @@ function Calendar({
|
|
|
9361
9768
|
const d = parseCalendarDate(v);
|
|
9362
9769
|
if (!d) return null;
|
|
9363
9770
|
let candidate = setMonth(current, d.getUTCFullYear(), d.getUTCMonth());
|
|
9364
|
-
candidate =
|
|
9771
|
+
candidate = clamp3(candidate);
|
|
9365
9772
|
if (candidate.slice(0, 7) !== v.slice(0, 7)) return null;
|
|
9366
9773
|
if (!unavailable(candidate)) return candidate;
|
|
9367
9774
|
for (let n = 1; n <= 31; n++) {
|
|
@@ -9415,13 +9822,13 @@ function Calendar({
|
|
|
9415
9822
|
}
|
|
9416
9823
|
if (!next) return;
|
|
9417
9824
|
event.preventDefault();
|
|
9418
|
-
next =
|
|
9825
|
+
next = clamp3(next);
|
|
9419
9826
|
const direction = next < v ? -1 : 1;
|
|
9420
9827
|
let attempts = 0;
|
|
9421
9828
|
while ((type === "month" ? unavailable(next) : !monthCandidate(next)) && attempts++ < 366) {
|
|
9422
9829
|
const nd = parseCalendarDate(next);
|
|
9423
9830
|
if (!nd) return;
|
|
9424
|
-
const candidate =
|
|
9831
|
+
const candidate = clamp3(
|
|
9425
9832
|
type === "month" ? addDays(next, direction) : setMonth(next, nd.getUTCFullYear(), nd.getUTCMonth() + direction)
|
|
9426
9833
|
);
|
|
9427
9834
|
if (candidate === next || !parseCalendarDate(candidate)) return;
|
|
@@ -9467,7 +9874,7 @@ function Calendar({
|
|
|
9467
9874
|
type === "year" ? monthCandidate(v) ?? v : v,
|
|
9468
9875
|
type === "year" ? "month" : "date"
|
|
9469
9876
|
),
|
|
9470
|
-
children: fullCellRender ? fullCellRender(v, info) : /* @__PURE__ */ jsxs28(
|
|
9877
|
+
children: fullCellRender ? fullCellRender(v, info) : /* @__PURE__ */ jsxs28(Fragment21, { children: [
|
|
9471
9878
|
originNode,
|
|
9472
9879
|
cellRender && /* @__PURE__ */ jsx32("span", { className: "mt-calendar-content", children: cellRender(v, info) })
|
|
9473
9880
|
] })
|
|
@@ -9486,7 +9893,7 @@ function Calendar({
|
|
|
9486
9893
|
year + (type === "year" ? n : 0),
|
|
9487
9894
|
month + (type === "month" ? n : 0)
|
|
9488
9895
|
);
|
|
9489
|
-
return disabled ||
|
|
9896
|
+
return disabled || clamp3(next) === view;
|
|
9490
9897
|
};
|
|
9491
9898
|
return /* @__PURE__ */ jsxs28(
|
|
9492
9899
|
"div",
|
|
@@ -9523,7 +9930,7 @@ function Calendar({
|
|
|
9523
9930
|
type,
|
|
9524
9931
|
onChange: (v) => emit(v, "customize"),
|
|
9525
9932
|
onTypeChange: changeMode
|
|
9526
|
-
}) : /* @__PURE__ */ jsxs28(
|
|
9933
|
+
}) : /* @__PURE__ */ jsxs28(Fragment21, { children: [
|
|
9527
9934
|
/* @__PURE__ */ jsx32(
|
|
9528
9935
|
Button,
|
|
9529
9936
|
{
|
|
@@ -10147,7 +10554,7 @@ var Timeline = React35.forwardRef(
|
|
|
10147
10554
|
...itemProps
|
|
10148
10555
|
} = item;
|
|
10149
10556
|
const side = placement ?? (position === "left" ? "start" : position === "right" ? "end" : position) ?? (normalizedMode === "alternate" ? index % 2 ? "end" : "start" : normalizedMode);
|
|
10150
|
-
const
|
|
10557
|
+
const marker2 = icon !== void 0 ? icon : dot;
|
|
10151
10558
|
return /* @__PURE__ */ createElement3(
|
|
10152
10559
|
"li",
|
|
10153
10560
|
{
|
|
@@ -10176,7 +10583,7 @@ var Timeline = React35.forwardRef(
|
|
|
10176
10583
|
"aria-hidden": "true",
|
|
10177
10584
|
className: cn("mt-timeline-icon", classNames.icon),
|
|
10178
10585
|
style: styles.icon,
|
|
10179
|
-
children:
|
|
10586
|
+
children: marker2 !== void 0 ? marker2 : loading ? /* @__PURE__ */ jsx35(LoaderCircle6, { className: "mt-timeline-spinner", size: 14 }) : /* @__PURE__ */ jsx35("span", { className: "mt-timeline-dot" })
|
|
10180
10587
|
}
|
|
10181
10588
|
),
|
|
10182
10589
|
(title !== void 0 ? title : label) != null && /* @__PURE__ */ jsx35(
|
|
@@ -10384,7 +10791,7 @@ var Result = React37.forwardRef(
|
|
|
10384
10791
|
import * as React38 from "react";
|
|
10385
10792
|
import { Dialog as BDialog2 } from "@base-ui/react/dialog";
|
|
10386
10793
|
import {
|
|
10387
|
-
X as
|
|
10794
|
+
X as X9,
|
|
10388
10795
|
ZoomIn,
|
|
10389
10796
|
ZoomOut,
|
|
10390
10797
|
RotateCw,
|
|
@@ -10397,7 +10804,7 @@ import {
|
|
|
10397
10804
|
ImageOff,
|
|
10398
10805
|
LoaderCircle as LoaderCircle7
|
|
10399
10806
|
} from "lucide-react";
|
|
10400
|
-
import { Fragment as
|
|
10807
|
+
import { Fragment as Fragment22, jsx as jsx38, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
10401
10808
|
function ImageContent({
|
|
10402
10809
|
fallback,
|
|
10403
10810
|
placeholder,
|
|
@@ -10438,7 +10845,7 @@ function ImageContent({
|
|
|
10438
10845
|
}
|
|
10439
10846
|
),
|
|
10440
10847
|
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(
|
|
10848
|
+
state === "error" && /* @__PURE__ */ jsx38("span", { className: "mt-image-error", role: "status", children: errorContent ?? /* @__PURE__ */ jsxs32(Fragment22, { children: [
|
|
10442
10849
|
/* @__PURE__ */ jsx38(ImageOff, { size: 22 }),
|
|
10443
10850
|
/* @__PURE__ */ jsx38("span", { children: locale === "zh" ? "\u56FE\u7247\u52A0\u8F7D\u5931\u8D25" : "Image failed to load" })
|
|
10444
10851
|
] }) })
|
|
@@ -10511,7 +10918,7 @@ function PreviewContent({
|
|
|
10511
10918
|
children: icon
|
|
10512
10919
|
}
|
|
10513
10920
|
);
|
|
10514
|
-
return /* @__PURE__ */ jsxs32(
|
|
10921
|
+
return /* @__PURE__ */ jsxs32(Fragment22, { children: [
|
|
10515
10922
|
/* @__PURE__ */ jsxs32("div", { className: "mt-image-preview-header", children: [
|
|
10516
10923
|
/* @__PURE__ */ jsx38(BDialog2.Title, { children: item.alt || (zh ? "\u56FE\u7247\u9884\u89C8" : "Image preview") }),
|
|
10517
10924
|
/* @__PURE__ */ jsxs32("span", { "aria-live": "polite", children: [
|
|
@@ -10519,7 +10926,7 @@ function PreviewContent({
|
|
|
10519
10926
|
" / ",
|
|
10520
10927
|
total
|
|
10521
10928
|
] }),
|
|
10522
|
-
/* @__PURE__ */ jsx38(BDialog2.Close, { "aria-label": zh ? "\u5173\u95ED\u9884\u89C8" : "Close preview", children: /* @__PURE__ */ jsx38(
|
|
10929
|
+
/* @__PURE__ */ jsx38(BDialog2.Close, { "aria-label": zh ? "\u5173\u95ED\u9884\u89C8" : "Close preview", children: /* @__PURE__ */ jsx38(X9, { size: 20 }) })
|
|
10523
10930
|
] }),
|
|
10524
10931
|
/* @__PURE__ */ jsx38(
|
|
10525
10932
|
"div",
|
|
@@ -11207,7 +11614,7 @@ var TableOfContents = forwardRef15(function TableOfContents2({
|
|
|
11207
11614
|
// src/auto-complete.tsx
|
|
11208
11615
|
import * as React40 from "react";
|
|
11209
11616
|
import { Autocomplete as A } from "@base-ui/react/autocomplete";
|
|
11210
|
-
import { LoaderCircle as LoaderCircle8, X as
|
|
11617
|
+
import { LoaderCircle as LoaderCircle8, X as X10 } from "lucide-react";
|
|
11211
11618
|
import { jsx as jsx40, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
11212
11619
|
var AutoComplete = React40.forwardRef(function AutoComplete2({
|
|
11213
11620
|
options = [],
|
|
@@ -11338,7 +11745,7 @@ var AutoComplete = React40.forwardRef(function AutoComplete2({
|
|
|
11338
11745
|
{
|
|
11339
11746
|
className: "mt-auto-complete-clear",
|
|
11340
11747
|
"aria-label": zh ? "\u6E05\u9664" : "Clear",
|
|
11341
|
-
children: /* @__PURE__ */ jsx40(
|
|
11748
|
+
children: /* @__PURE__ */ jsx40(X10, { size: 13 })
|
|
11342
11749
|
}
|
|
11343
11750
|
),
|
|
11344
11751
|
suffix && /* @__PURE__ */ jsx40("span", { className: "mt-auto-complete-adornment", children: suffix })
|
|
@@ -11389,11 +11796,11 @@ import * as React41 from "react";
|
|
|
11389
11796
|
import { Popover as Popover5 } from "@base-ui/react/popover";
|
|
11390
11797
|
import {
|
|
11391
11798
|
Check as Check6,
|
|
11392
|
-
ChevronDown as
|
|
11799
|
+
ChevronDown as ChevronDown10,
|
|
11393
11800
|
ChevronRight as ChevronRight9,
|
|
11394
11801
|
LoaderCircle as LoaderCircle9,
|
|
11395
11802
|
Minus as Minus3,
|
|
11396
|
-
X as
|
|
11803
|
+
X as X11
|
|
11397
11804
|
} from "lucide-react";
|
|
11398
11805
|
import { jsx as jsx41, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
11399
11806
|
var keyOf = (path) => JSON.stringify(path);
|
|
@@ -11911,7 +12318,7 @@ var Cascader = React41.forwardRef(
|
|
|
11911
12318
|
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
12319
|
}
|
|
11913
12320
|
),
|
|
11914
|
-
/* @__PURE__ */ jsx41(
|
|
12321
|
+
/* @__PURE__ */ jsx41(ChevronDown10, { size: 14, "aria-hidden": true })
|
|
11915
12322
|
]
|
|
11916
12323
|
}
|
|
11917
12324
|
),
|
|
@@ -11922,7 +12329,7 @@ var Cascader = React41.forwardRef(
|
|
|
11922
12329
|
type: "button",
|
|
11923
12330
|
"aria-label": zh ? "\u6E05\u9664\u9009\u62E9" : "Clear selection",
|
|
11924
12331
|
onClick: clear,
|
|
11925
|
-
children: /* @__PURE__ */ jsx41(
|
|
12332
|
+
children: /* @__PURE__ */ jsx41(X11, { size: 12 })
|
|
11926
12333
|
}
|
|
11927
12334
|
),
|
|
11928
12335
|
props.name && /* @__PURE__ */ jsx41(
|
|
@@ -11957,7 +12364,7 @@ var Cascader = React41.forwardRef(
|
|
|
11957
12364
|
state.selected.filter((p) => !prefixOf(path, p))
|
|
11958
12365
|
);
|
|
11959
12366
|
},
|
|
11960
|
-
children: /* @__PURE__ */ jsx41(
|
|
12367
|
+
children: /* @__PURE__ */ jsx41(X11, { size: 10 })
|
|
11961
12368
|
}
|
|
11962
12369
|
)
|
|
11963
12370
|
] }, keyOf(path))),
|
|
@@ -12001,8 +12408,8 @@ var Cascader = React41.forwardRef(
|
|
|
12001
12408
|
|
|
12002
12409
|
// src/transfer.tsx
|
|
12003
12410
|
import * as React42 from "react";
|
|
12004
|
-
import { ChevronLeft as ChevronLeft3, ChevronRight as ChevronRight10, X as
|
|
12005
|
-
import { Fragment as
|
|
12411
|
+
import { ChevronLeft as ChevronLeft3, ChevronRight as ChevronRight10, X as X12 } from "lucide-react";
|
|
12412
|
+
import { Fragment as Fragment23, jsx as jsx42, jsxs as jsxs36 } from "react/jsx-runtime";
|
|
12006
12413
|
var unique = (keys) => Array.from(new Set(keys));
|
|
12007
12414
|
var Transfer = React42.forwardRef(
|
|
12008
12415
|
function Transfer2({
|
|
@@ -12161,7 +12568,7 @@ var Transfer = React42.forwardRef(
|
|
|
12161
12568
|
className: "mt-transfer-row",
|
|
12162
12569
|
"data-disabled": item.disabled || blocked || void 0,
|
|
12163
12570
|
"data-selected": selectionSet.has(item.key) || void 0,
|
|
12164
|
-
children: oneWay && side === 1 ? /* @__PURE__ */ jsxs36(
|
|
12571
|
+
children: oneWay && side === 1 ? /* @__PURE__ */ jsxs36(Fragment23, { children: [
|
|
12165
12572
|
/* @__PURE__ */ jsxs36("div", { className: "mt-transfer-item", children: [
|
|
12166
12573
|
renderItem?.(item, direction) ?? item.label,
|
|
12167
12574
|
item.description && /* @__PURE__ */ jsx42("small", { children: item.description })
|
|
@@ -12174,7 +12581,7 @@ var Transfer = React42.forwardRef(
|
|
|
12174
12581
|
"aria-label": `${en ? "Remove " : "\u79FB\u9664 "}${item.searchText ?? (typeof item.label === "string" ? item.label : item.key)}`,
|
|
12175
12582
|
disabled: blocked || item.disabled,
|
|
12176
12583
|
onClick: () => move("left", [item.key]),
|
|
12177
|
-
children: /* @__PURE__ */ jsx42(
|
|
12584
|
+
children: /* @__PURE__ */ jsx42(X12, { size: 14 })
|
|
12178
12585
|
}
|
|
12179
12586
|
)
|
|
12180
12587
|
] }) : /* @__PURE__ */ jsx42(
|
|
@@ -12467,7 +12874,7 @@ var Fieldset = React45.forwardRef(
|
|
|
12467
12874
|
// src/tree-select.tsx
|
|
12468
12875
|
import * as React46 from "react";
|
|
12469
12876
|
import { Popover as Popover6 } from "@base-ui/react/popover";
|
|
12470
|
-
import { ChevronDown as
|
|
12877
|
+
import { ChevronDown as ChevronDown11, X as X13 } from "lucide-react";
|
|
12471
12878
|
import { jsx as jsx46, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
12472
12879
|
var textOf2 = (node) => typeof node.textValue === "string" ? node.textValue : typeof node.label === "string" || typeof node.label === "number" ? String(node.label) : String(node.id);
|
|
12473
12880
|
var TreeSelect = React46.forwardRef(
|
|
@@ -12614,7 +13021,7 @@ var TreeSelect = React46.forwardRef(
|
|
|
12614
13021
|
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
13022
|
}
|
|
12616
13023
|
),
|
|
12617
|
-
/* @__PURE__ */ jsx46(
|
|
13024
|
+
/* @__PURE__ */ jsx46(ChevronDown11, { size: 14, "aria-hidden": true })
|
|
12618
13025
|
]
|
|
12619
13026
|
}
|
|
12620
13027
|
),
|
|
@@ -12629,7 +13036,7 @@ var TreeSelect = React46.forwardRef(
|
|
|
12629
13036
|
props.onClear?.();
|
|
12630
13037
|
button.current?.focus();
|
|
12631
13038
|
},
|
|
12632
|
-
children: /* @__PURE__ */ jsx46(
|
|
13039
|
+
children: /* @__PURE__ */ jsx46(X13, { size: 12 })
|
|
12633
13040
|
}
|
|
12634
13041
|
),
|
|
12635
13042
|
props.name && /* @__PURE__ */ jsx46(
|
|
@@ -12662,7 +13069,7 @@ var TreeSelect = React46.forwardRef(
|
|
|
12662
13069
|
type: "button",
|
|
12663
13070
|
"aria-label": `${zh ? "\u79FB\u9664" : "Remove"} ${index.get(key) ? textOf2(index.get(key).item) : key}`,
|
|
12664
13071
|
onClick: () => toggle(key, false),
|
|
12665
|
-
children: /* @__PURE__ */ jsx46(
|
|
13072
|
+
children: /* @__PURE__ */ jsx46(X13, { size: 10 })
|
|
12666
13073
|
}
|
|
12667
13074
|
)
|
|
12668
13075
|
]
|
|
@@ -12773,7 +13180,7 @@ var TreeSelect = React46.forwardRef(
|
|
|
12773
13180
|
|
|
12774
13181
|
// src/tag-select.tsx
|
|
12775
13182
|
import * as React47 from "react";
|
|
12776
|
-
import { ChevronDown as
|
|
13183
|
+
import { ChevronDown as ChevronDown12 } from "lucide-react";
|
|
12777
13184
|
import { jsx as jsx47, jsxs as jsxs41 } from "react/jsx-runtime";
|
|
12778
13185
|
function TagSelect({
|
|
12779
13186
|
options,
|
|
@@ -12926,7 +13333,7 @@ function TagSelect({
|
|
|
12926
13333
|
},
|
|
12927
13334
|
children: [
|
|
12928
13335
|
isExpanded ? collapseLabel : expandLabel,
|
|
12929
|
-
/* @__PURE__ */ jsx47(
|
|
13336
|
+
/* @__PURE__ */ jsx47(ChevronDown12, { size: 14, "aria-hidden": "true" })
|
|
12930
13337
|
]
|
|
12931
13338
|
}
|
|
12932
13339
|
)
|
|
@@ -12936,9 +13343,44 @@ function TagSelect({
|
|
|
12936
13343
|
}
|
|
12937
13344
|
|
|
12938
13345
|
// src/data-list.tsx
|
|
13346
|
+
import * as React49 from "react";
|
|
13347
|
+
import { ChevronDown as ChevronDown13, ChevronRight as ChevronRight11 } from "lucide-react";
|
|
13348
|
+
|
|
13349
|
+
// src/toolbar.tsx
|
|
12939
13350
|
import * as React48 from "react";
|
|
12940
|
-
import {
|
|
12941
|
-
|
|
13351
|
+
import { jsx as jsx48, jsxs as jsxs42 } from "react/jsx-runtime";
|
|
13352
|
+
var hasSlot = (node) => node != null && typeof node !== "boolean" && node !== "";
|
|
13353
|
+
var Toolbar = React48.forwardRef(
|
|
13354
|
+
function Toolbar2({
|
|
13355
|
+
search,
|
|
13356
|
+
start,
|
|
13357
|
+
end,
|
|
13358
|
+
background = "white",
|
|
13359
|
+
className,
|
|
13360
|
+
role,
|
|
13361
|
+
...props
|
|
13362
|
+
}, ref) {
|
|
13363
|
+
const named = props["aria-label"]?.trim() || props["aria-labelledby"]?.trim();
|
|
13364
|
+
return /* @__PURE__ */ jsx48(
|
|
13365
|
+
"div",
|
|
13366
|
+
{
|
|
13367
|
+
...props,
|
|
13368
|
+
ref,
|
|
13369
|
+
className: cn("mt-toolbar", className),
|
|
13370
|
+
"data-background": background,
|
|
13371
|
+
role: role ?? (named ? "group" : void 0),
|
|
13372
|
+
children: /* @__PURE__ */ jsxs42("div", { className: "mt-toolbar-layout", children: [
|
|
13373
|
+
hasSlot(search) && /* @__PURE__ */ jsx48("div", { className: "mt-toolbar-search", children: search }),
|
|
13374
|
+
hasSlot(start) && /* @__PURE__ */ jsx48("div", { className: "mt-toolbar-start", children: start }),
|
|
13375
|
+
hasSlot(end) && /* @__PURE__ */ jsx48("div", { className: "mt-toolbar-end", children: end })
|
|
13376
|
+
] })
|
|
13377
|
+
}
|
|
13378
|
+
);
|
|
13379
|
+
}
|
|
13380
|
+
);
|
|
13381
|
+
|
|
13382
|
+
// src/data-list.tsx
|
|
13383
|
+
import { Fragment as Fragment24, jsx as jsx49, jsxs as jsxs43 } from "react/jsx-runtime";
|
|
12942
13384
|
var integer = (value, fallback, min) => value !== void 0 && Number.isFinite(value) ? Math.max(min, Math.trunc(value)) : fallback;
|
|
12943
13385
|
function updateKeys(keys, changed, add) {
|
|
12944
13386
|
const next = new Set(keys);
|
|
@@ -12954,13 +13396,13 @@ function DataListRow({
|
|
|
12954
13396
|
children,
|
|
12955
13397
|
detail
|
|
12956
13398
|
}) {
|
|
12957
|
-
const detailId =
|
|
12958
|
-
return /* @__PURE__ */
|
|
12959
|
-
/* @__PURE__ */
|
|
13399
|
+
const detailId = React49.useId();
|
|
13400
|
+
return /* @__PURE__ */ jsxs43(Fragment24, { children: [
|
|
13401
|
+
/* @__PURE__ */ jsxs43("div", { className: "mt-data-list-row", children: [
|
|
12960
13402
|
checkbox,
|
|
12961
|
-
/* @__PURE__ */
|
|
12962
|
-
(actions != null || detail) && /* @__PURE__ */
|
|
12963
|
-
detail && /* @__PURE__ */
|
|
13403
|
+
/* @__PURE__ */ jsx49("div", { className: "mt-data-list-content", children }),
|
|
13404
|
+
(actions != null || detail) && /* @__PURE__ */ jsxs43("div", { className: "mt-data-list-actions", children: [
|
|
13405
|
+
detail && /* @__PURE__ */ jsx49(
|
|
12964
13406
|
Button,
|
|
12965
13407
|
{
|
|
12966
13408
|
iconOnly: true,
|
|
@@ -12971,13 +13413,13 @@ function DataListRow({
|
|
|
12971
13413
|
"aria-controls": detailId,
|
|
12972
13414
|
"aria-expanded": detail.expanded,
|
|
12973
13415
|
onClick: detail.onToggle,
|
|
12974
|
-
children: detail.expanded ? /* @__PURE__ */
|
|
13416
|
+
children: detail.expanded ? /* @__PURE__ */ jsx49(ChevronDown13, { size: 16, "aria-hidden": "true" }) : /* @__PURE__ */ jsx49(ChevronRight11, { size: 16, "aria-hidden": "true" })
|
|
12975
13417
|
}
|
|
12976
13418
|
),
|
|
12977
13419
|
actions
|
|
12978
13420
|
] })
|
|
12979
13421
|
] }),
|
|
12980
|
-
detail && /* @__PURE__ */
|
|
13422
|
+
detail && /* @__PURE__ */ jsx49(
|
|
12981
13423
|
"div",
|
|
12982
13424
|
{
|
|
12983
13425
|
className: "mt-data-list-detail",
|
|
@@ -13003,29 +13445,29 @@ function DataList({
|
|
|
13003
13445
|
renderActions,
|
|
13004
13446
|
renderBatchActions,
|
|
13005
13447
|
loading = false,
|
|
13006
|
-
empty
|
|
13448
|
+
empty,
|
|
13007
13449
|
className,
|
|
13008
13450
|
...props
|
|
13009
13451
|
}) {
|
|
13010
13452
|
const zh = useMtone().locale === "zh";
|
|
13011
13453
|
const remote = pagination?.mode === "remote";
|
|
13012
|
-
const [localQuery, setLocalQuery] =
|
|
13454
|
+
const [localQuery, setLocalQuery] = React49.useState(
|
|
13013
13455
|
search?.defaultValue ?? ""
|
|
13014
13456
|
);
|
|
13015
|
-
const [localPage, setLocalPage] =
|
|
13457
|
+
const [localPage, setLocalPage] = React49.useState(
|
|
13016
13458
|
integer(
|
|
13017
13459
|
pagination?.mode === "remote" ? void 0 : pagination?.defaultPage,
|
|
13018
13460
|
1,
|
|
13019
13461
|
1
|
|
13020
13462
|
)
|
|
13021
13463
|
);
|
|
13022
|
-
const [localSelected, setLocalSelected] =
|
|
13023
|
-
const [localExpanded, setLocalExpanded] =
|
|
13464
|
+
const [localSelected, setLocalSelected] = React49.useState(selection?.defaultSelectedKeys ?? []);
|
|
13465
|
+
const [localExpanded, setLocalExpanded] = React49.useState(expansion?.defaultExpandedKeys ?? []);
|
|
13024
13466
|
const query = search?.value ?? localQuery;
|
|
13025
13467
|
const trimmedQuery = query.trim();
|
|
13026
13468
|
const selected = new Set(selection?.selectedKeys ?? localSelected);
|
|
13027
13469
|
const expanded = new Set(expansion?.expandedKeys ?? localExpanded);
|
|
13028
|
-
const rows =
|
|
13470
|
+
const rows = React49.useMemo(() => {
|
|
13029
13471
|
const keys = /* @__PURE__ */ new Set();
|
|
13030
13472
|
return items.map((item) => {
|
|
13031
13473
|
const key = getKey(item);
|
|
@@ -13050,7 +13492,7 @@ function DataList({
|
|
|
13050
13492
|
const enabledKeys = selection ? visible.filter(({ item }) => !selection.getDisabled?.(item)).map(({ key }) => key) : [];
|
|
13051
13493
|
const picked = enabledKeys.filter((key) => selected.has(key)).length;
|
|
13052
13494
|
const all = picked > 0 && picked === enabledKeys.length;
|
|
13053
|
-
|
|
13495
|
+
React49.useEffect(() => {
|
|
13054
13496
|
if (pagination && !remote && pagination.page === void 0 && page !== localPage) {
|
|
13055
13497
|
setLocalPage(page);
|
|
13056
13498
|
}
|
|
@@ -13074,49 +13516,70 @@ function DataList({
|
|
|
13074
13516
|
const clearSelection = () => {
|
|
13075
13517
|
if (selected.size) changeSelection([]);
|
|
13076
13518
|
};
|
|
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
|
-
|
|
13519
|
+
const hasFilters = filters != null && typeof filters !== "boolean" && filters !== "";
|
|
13520
|
+
const hasToolbar = toolbar != null && typeof toolbar !== "boolean" && toolbar !== "";
|
|
13521
|
+
const hasLeadingControls = selection || search;
|
|
13522
|
+
const hasTrailingControls = hasFilters || hasToolbar;
|
|
13523
|
+
return /* @__PURE__ */ jsxs43("section", { ...props, className: cn("mt-data-list", className), children: [
|
|
13524
|
+
(hasLeadingControls || hasTrailingControls) && /* @__PURE__ */ jsx49(
|
|
13525
|
+
Toolbar,
|
|
13526
|
+
{
|
|
13527
|
+
className: "mt-data-list-toolbar",
|
|
13528
|
+
background: "gray",
|
|
13529
|
+
start: hasLeadingControls && /* @__PURE__ */ jsxs43(Fragment24, { children: [
|
|
13530
|
+
selection && /* @__PURE__ */ jsxs43("div", { className: "mt-data-list-selection", children: [
|
|
13531
|
+
/* @__PURE__ */ jsx49(
|
|
13532
|
+
Checkbox,
|
|
13533
|
+
{
|
|
13534
|
+
label: zh ? "\u9009\u62E9\u5F53\u524D\u53EF\u89C1\u9879" : "Select visible items",
|
|
13535
|
+
checked: all,
|
|
13536
|
+
indeterminate: picked > 0 && !all,
|
|
13537
|
+
disabled: !enabledKeys.length,
|
|
13538
|
+
onCheckedChange: (checked) => changeSelection(updateKeys(selected, enabledKeys, checked))
|
|
13539
|
+
}
|
|
13540
|
+
),
|
|
13541
|
+
/* @__PURE__ */ jsx49("span", { className: "mt-data-list-count", "aria-live": "polite", children: zh ? `\u5DF2\u9009\u62E9 ${selected.size} \u9879` : `${selected.size} selected` }),
|
|
13542
|
+
selected.size > 0 && /* @__PURE__ */ jsxs43("div", { className: "mt-data-list-actions", children: [
|
|
13543
|
+
renderBatchActions?.({
|
|
13544
|
+
selectedKeys: [...selected],
|
|
13545
|
+
clearSelection
|
|
13546
|
+
}),
|
|
13547
|
+
/* @__PURE__ */ jsx49(
|
|
13548
|
+
Button,
|
|
13549
|
+
{
|
|
13550
|
+
variant: "ghost",
|
|
13551
|
+
type: "button",
|
|
13552
|
+
onClick: clearSelection,
|
|
13553
|
+
children: zh ? "\u6E05\u9664\u9009\u62E9" : "Clear selection"
|
|
13554
|
+
}
|
|
13555
|
+
)
|
|
13556
|
+
] })
|
|
13557
|
+
] }),
|
|
13558
|
+
search && /* @__PURE__ */ jsx49(
|
|
13559
|
+
Input.Search,
|
|
13560
|
+
{
|
|
13561
|
+
"aria-label": search.label ?? (zh ? "\u641C\u7D22\u5217\u8868" : "Search list"),
|
|
13562
|
+
placeholder: search.placeholder ?? (zh ? "\u641C\u7D22\u2026" : "Search\u2026"),
|
|
13563
|
+
value: query,
|
|
13564
|
+
onChange: (event) => changeQuery(event.currentTarget.value),
|
|
13565
|
+
allowClear: true
|
|
13566
|
+
}
|
|
13567
|
+
)
|
|
13568
|
+
] }),
|
|
13569
|
+
end: hasTrailingControls && /* @__PURE__ */ jsxs43(Fragment24, { children: [
|
|
13570
|
+
hasFilters && /* @__PURE__ */ jsx49("div", { className: "mt-data-list-filters", children: filters }),
|
|
13571
|
+
hasToolbar && toolbar
|
|
13572
|
+
] })
|
|
13573
|
+
}
|
|
13574
|
+
),
|
|
13575
|
+
/* @__PURE__ */ jsx49(
|
|
13113
13576
|
List,
|
|
13114
13577
|
{
|
|
13115
13578
|
items: visible,
|
|
13116
13579
|
getKey: (row) => row.key,
|
|
13117
13580
|
loading,
|
|
13118
13581
|
loadingContent: zh ? "\u52A0\u8F7D\u4E2D\u2026" : "Loading\u2026",
|
|
13119
|
-
emptyContent:
|
|
13582
|
+
emptyContent: empty ?? (zh ? "\u6682\u65E0\u6570\u636E" : "No items"),
|
|
13120
13583
|
renderItem: ({ item, key }, index) => {
|
|
13121
13584
|
const label = getLabel?.(item) ?? String(key);
|
|
13122
13585
|
const isExpanded = expanded.has(key);
|
|
@@ -13131,17 +13594,17 @@ function DataList({
|
|
|
13131
13594
|
expansion.onChange?.(next);
|
|
13132
13595
|
}
|
|
13133
13596
|
} : void 0;
|
|
13134
|
-
return /* @__PURE__ */
|
|
13597
|
+
return /* @__PURE__ */ jsx49(
|
|
13135
13598
|
DataListRow,
|
|
13136
13599
|
{
|
|
13137
|
-
checkbox: selection && /* @__PURE__ */
|
|
13600
|
+
checkbox: selection && /* @__PURE__ */ jsx49(
|
|
13138
13601
|
Checkbox,
|
|
13139
13602
|
{
|
|
13140
13603
|
className: "mt-data-list-row-check",
|
|
13141
13604
|
checked: selected.has(key),
|
|
13142
13605
|
disabled: selection.getDisabled?.(item),
|
|
13143
13606
|
onCheckedChange: (checked) => changeSelection(updateKeys(selected, [key], checked)),
|
|
13144
|
-
children: /* @__PURE__ */
|
|
13607
|
+
children: /* @__PURE__ */ jsx49("span", { className: "mt-data-list-sr-only", children: zh ? `\u9009\u62E9 ${label}` : `Select ${label}` })
|
|
13145
13608
|
}
|
|
13146
13609
|
),
|
|
13147
13610
|
actions: renderActions?.(item),
|
|
@@ -13152,7 +13615,7 @@ function DataList({
|
|
|
13152
13615
|
}
|
|
13153
13616
|
}
|
|
13154
13617
|
),
|
|
13155
|
-
pagination && /* @__PURE__ */
|
|
13618
|
+
pagination && /* @__PURE__ */ jsx49(
|
|
13156
13619
|
Pagination,
|
|
13157
13620
|
{
|
|
13158
13621
|
className: "mt-data-list-pagination",
|
|
@@ -13166,8 +13629,8 @@ function DataList({
|
|
|
13166
13629
|
}
|
|
13167
13630
|
|
|
13168
13631
|
// src/card-group.tsx
|
|
13169
|
-
import * as
|
|
13170
|
-
import { jsx as
|
|
13632
|
+
import * as React50 from "react";
|
|
13633
|
+
import { jsx as jsx50 } from "react/jsx-runtime";
|
|
13171
13634
|
var breakpoints3 = [
|
|
13172
13635
|
"xs",
|
|
13173
13636
|
"sm",
|
|
@@ -13177,7 +13640,7 @@ var breakpoints3 = [
|
|
|
13177
13640
|
"xxl"
|
|
13178
13641
|
];
|
|
13179
13642
|
var defaults = { xs: 1, sm: 2, lg: 3 };
|
|
13180
|
-
var ItemLayout =
|
|
13643
|
+
var ItemLayout = React50.createContext({});
|
|
13181
13644
|
function values(value, fallback, integer2) {
|
|
13182
13645
|
let previous = fallback;
|
|
13183
13646
|
return breakpoints3.map((key) => {
|
|
@@ -13194,8 +13657,8 @@ function CardGroupItem({
|
|
|
13194
13657
|
style,
|
|
13195
13658
|
...props
|
|
13196
13659
|
}) {
|
|
13197
|
-
const layout =
|
|
13198
|
-
return /* @__PURE__ */
|
|
13660
|
+
const layout = React50.useContext(ItemLayout);
|
|
13661
|
+
return /* @__PURE__ */ jsx50(
|
|
13199
13662
|
"div",
|
|
13200
13663
|
{
|
|
13201
13664
|
...props,
|
|
@@ -13205,10 +13668,10 @@ function CardGroupItem({
|
|
|
13205
13668
|
);
|
|
13206
13669
|
}
|
|
13207
13670
|
function flatten(children, prefix = "") {
|
|
13208
|
-
return
|
|
13209
|
-
const key = `${prefix}/${
|
|
13210
|
-
if (
|
|
13211
|
-
return child.type ===
|
|
13671
|
+
return React50.Children.toArray(children).flatMap((child, index) => {
|
|
13672
|
+
const key = `${prefix}/${React50.isValidElement(child) ? child.key ?? index : index}`;
|
|
13673
|
+
if (React50.isValidElement(child)) {
|
|
13674
|
+
return child.type === React50.Fragment ? flatten(child.props.children, key) : [React50.cloneElement(child, { key })];
|
|
13212
13675
|
}
|
|
13213
13676
|
return [child];
|
|
13214
13677
|
});
|
|
@@ -13231,7 +13694,7 @@ function CardGroupRoot({
|
|
|
13231
13694
|
rootStyle[`--mt-card-group-gap-${key}`] = `${gaps[i]}px`;
|
|
13232
13695
|
});
|
|
13233
13696
|
const cursors = breakpoints3.map(() => ({ column: 0, row: 0 }));
|
|
13234
|
-
return /* @__PURE__ */
|
|
13697
|
+
return /* @__PURE__ */ jsx50(
|
|
13235
13698
|
"div",
|
|
13236
13699
|
{
|
|
13237
13700
|
...props,
|
|
@@ -13242,8 +13705,8 @@ function CardGroupRoot({
|
|
|
13242
13705
|
),
|
|
13243
13706
|
style: { ...rootStyle, ...style },
|
|
13244
13707
|
children: flatten(children).map((child, index) => {
|
|
13245
|
-
const explicit =
|
|
13246
|
-
const item = explicit ? child : /* @__PURE__ */
|
|
13708
|
+
const explicit = React50.isValidElement(child) && child.type === CardGroupItem;
|
|
13709
|
+
const item = explicit ? child : /* @__PURE__ */ jsx50(CardGroupItem, { children: child });
|
|
13247
13710
|
const spans = values(explicit ? child.props.span ?? 1 : 1, 1, true);
|
|
13248
13711
|
const layout = {};
|
|
13249
13712
|
breakpoints3.forEach((key, i) => {
|
|
@@ -13263,13 +13726,13 @@ function CardGroupRoot({
|
|
|
13263
13726
|
}
|
|
13264
13727
|
}
|
|
13265
13728
|
});
|
|
13266
|
-
return /* @__PURE__ */
|
|
13729
|
+
return /* @__PURE__ */ jsx50(
|
|
13267
13730
|
ItemLayout.Provider,
|
|
13268
13731
|
{
|
|
13269
13732
|
value: layout,
|
|
13270
13733
|
children: item
|
|
13271
13734
|
},
|
|
13272
|
-
|
|
13735
|
+
React50.isValidElement(child) ? child.key ?? index : index
|
|
13273
13736
|
);
|
|
13274
13737
|
})
|
|
13275
13738
|
}
|
|
@@ -13278,8 +13741,8 @@ function CardGroupRoot({
|
|
|
13278
13741
|
var CardGroup = Object.assign(CardGroupRoot, { Item: CardGroupItem });
|
|
13279
13742
|
|
|
13280
13743
|
// src/questionnaire.tsx
|
|
13281
|
-
import * as
|
|
13282
|
-
import { Fragment as
|
|
13744
|
+
import * as React51 from "react";
|
|
13745
|
+
import { Fragment as Fragment26, jsx as jsx51, jsxs as jsxs44 } from "react/jsx-runtime";
|
|
13283
13746
|
function validateItems(items) {
|
|
13284
13747
|
const ids = /* @__PURE__ */ new Set();
|
|
13285
13748
|
for (const item of items) {
|
|
@@ -13321,21 +13784,21 @@ function Questionnaire({
|
|
|
13321
13784
|
...props
|
|
13322
13785
|
}) {
|
|
13323
13786
|
const zh = useMtone().locale === "zh";
|
|
13324
|
-
const id =
|
|
13787
|
+
const id = React51.useId();
|
|
13325
13788
|
validateItems(items);
|
|
13326
|
-
const [draft, setDraft] =
|
|
13327
|
-
const [step, setStep] =
|
|
13328
|
-
const [error, setError] =
|
|
13329
|
-
const [phase, setPhase] =
|
|
13789
|
+
const [draft, setDraft] = React51.useState(defaultAnswers);
|
|
13790
|
+
const [step, setStep] = React51.useState(0);
|
|
13791
|
+
const [error, setError] = React51.useState();
|
|
13792
|
+
const [phase, setPhase] = React51.useState(
|
|
13330
13793
|
"editing"
|
|
13331
13794
|
);
|
|
13332
|
-
const submitting =
|
|
13333
|
-
const heading =
|
|
13334
|
-
const shouldFocus =
|
|
13795
|
+
const submitting = React51.useRef(false);
|
|
13796
|
+
const heading = React51.useRef(null);
|
|
13797
|
+
const shouldFocus = React51.useRef(false);
|
|
13335
13798
|
const index = Math.min(step, Math.max(items.length - 1, 0));
|
|
13336
13799
|
const item = items[index];
|
|
13337
13800
|
const current = answers ?? draft;
|
|
13338
|
-
|
|
13801
|
+
React51.useEffect(() => {
|
|
13339
13802
|
if (shouldFocus.current) {
|
|
13340
13803
|
heading.current?.focus();
|
|
13341
13804
|
shouldFocus.current = false;
|
|
@@ -13416,16 +13879,16 @@ function Questionnaire({
|
|
|
13416
13879
|
}
|
|
13417
13880
|
let content2;
|
|
13418
13881
|
if (phase === "done")
|
|
13419
|
-
content2 = /* @__PURE__ */
|
|
13420
|
-
else if (!item) content2 = /* @__PURE__ */
|
|
13882
|
+
content2 = /* @__PURE__ */ jsx51("h3", { ref: heading, tabIndex: -1, children: zh ? "\u5DF2\u63D0\u4EA4\u7B54\u5377" : "Responses submitted" });
|
|
13883
|
+
else if (!item) content2 = /* @__PURE__ */ jsx51("p", { children: zh ? "\u6682\u65E0\u95EE\u9898" : "No questions" });
|
|
13421
13884
|
else {
|
|
13422
13885
|
const text = answer?.type === "text" ? answer.value : "";
|
|
13423
13886
|
const selected = answer?.type === "choices" ? answer.values : [];
|
|
13424
13887
|
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__ */
|
|
13888
|
+
content2 = /* @__PURE__ */ jsxs44(Fragment26, { children: [
|
|
13889
|
+
/* @__PURE__ */ jsxs44("div", { className: "mt-questionnaire-progress", children: [
|
|
13890
|
+
/* @__PURE__ */ jsx51("span", { children: progress }),
|
|
13891
|
+
/* @__PURE__ */ jsx51(
|
|
13429
13892
|
Progress,
|
|
13430
13893
|
{
|
|
13431
13894
|
value: 100 * (index + 1) / items.length,
|
|
@@ -13433,7 +13896,7 @@ function Questionnaire({
|
|
|
13433
13896
|
}
|
|
13434
13897
|
)
|
|
13435
13898
|
] }),
|
|
13436
|
-
/* @__PURE__ */
|
|
13899
|
+
/* @__PURE__ */ jsxs44(
|
|
13437
13900
|
"div",
|
|
13438
13901
|
{
|
|
13439
13902
|
className: "mt-questionnaire-main",
|
|
@@ -13441,10 +13904,10 @@ function Questionnaire({
|
|
|
13441
13904
|
"aria-labelledby": titleId,
|
|
13442
13905
|
"aria-describedby": described,
|
|
13443
13906
|
children: [
|
|
13444
|
-
/* @__PURE__ */
|
|
13445
|
-
item.description != null && /* @__PURE__ */
|
|
13446
|
-
item.type === "single" && /* @__PURE__ */
|
|
13447
|
-
/* @__PURE__ */
|
|
13907
|
+
/* @__PURE__ */ jsx51("h3", { id: titleId, ref: heading, tabIndex: -1, children: item.title }),
|
|
13908
|
+
item.description != null && /* @__PURE__ */ jsx51("div", { id: descriptionId, className: "mt-questionnaire-description", children: item.description }),
|
|
13909
|
+
item.type === "single" && /* @__PURE__ */ jsxs44(Fragment26, { children: [
|
|
13910
|
+
/* @__PURE__ */ jsx51(
|
|
13448
13911
|
RadioGroup,
|
|
13449
13912
|
{
|
|
13450
13913
|
"aria-labelledby": titleId,
|
|
@@ -13467,7 +13930,7 @@ function Questionnaire({
|
|
|
13467
13930
|
disabled
|
|
13468
13931
|
}
|
|
13469
13932
|
),
|
|
13470
|
-
item.other && answer?.type === "text" && /* @__PURE__ */
|
|
13933
|
+
item.other && answer?.type === "text" && /* @__PURE__ */ jsx51(
|
|
13471
13934
|
Input,
|
|
13472
13935
|
{
|
|
13473
13936
|
"aria-label": item.other.label ?? (zh ? "\u5176\u4ED6\u7B54\u6848" : "Other answer"),
|
|
@@ -13484,7 +13947,7 @@ function Questionnaire({
|
|
|
13484
13947
|
}
|
|
13485
13948
|
)
|
|
13486
13949
|
] }),
|
|
13487
|
-
item.type === "multiple" && /* @__PURE__ */
|
|
13950
|
+
item.type === "multiple" && /* @__PURE__ */ jsx51("div", { className: "mt-questionnaire-checks", children: item.choices.map((choice) => /* @__PURE__ */ jsx51(
|
|
13488
13951
|
Checkbox,
|
|
13489
13952
|
{
|
|
13490
13953
|
checked: selected.includes(choice.value),
|
|
@@ -13504,7 +13967,7 @@ function Questionnaire({
|
|
|
13504
13967
|
},
|
|
13505
13968
|
choice.value
|
|
13506
13969
|
)) }),
|
|
13507
|
-
item.type === "text" && /* @__PURE__ */
|
|
13970
|
+
item.type === "text" && /* @__PURE__ */ jsx51(
|
|
13508
13971
|
Input.TextArea,
|
|
13509
13972
|
{
|
|
13510
13973
|
rows: 3,
|
|
@@ -13518,13 +13981,13 @@ function Questionnaire({
|
|
|
13518
13981
|
onChange: (e) => change({ type: "text", value: e.currentTarget.value })
|
|
13519
13982
|
}
|
|
13520
13983
|
),
|
|
13521
|
-
error && /* @__PURE__ */
|
|
13984
|
+
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
13985
|
]
|
|
13523
13986
|
},
|
|
13524
13987
|
item.id
|
|
13525
13988
|
),
|
|
13526
|
-
/* @__PURE__ */
|
|
13527
|
-
/* @__PURE__ */
|
|
13989
|
+
/* @__PURE__ */ jsxs44("div", { className: "mt-questionnaire-actions", children: [
|
|
13990
|
+
/* @__PURE__ */ jsx51(
|
|
13528
13991
|
Button,
|
|
13529
13992
|
{
|
|
13530
13993
|
type: "button",
|
|
@@ -13534,8 +13997,8 @@ function Questionnaire({
|
|
|
13534
13997
|
children: zh ? "\u4E0A\u4E00\u9898" : "Previous"
|
|
13535
13998
|
}
|
|
13536
13999
|
),
|
|
13537
|
-
/* @__PURE__ */
|
|
13538
|
-
!item.required && /* @__PURE__ */
|
|
14000
|
+
/* @__PURE__ */ jsxs44("div", { className: "mt-questionnaire-forward", children: [
|
|
14001
|
+
!item.required && /* @__PURE__ */ jsx51(
|
|
13539
14002
|
Button,
|
|
13540
14003
|
{
|
|
13541
14004
|
type: "button",
|
|
@@ -13545,7 +14008,7 @@ function Questionnaire({
|
|
|
13545
14008
|
children: zh ? "\u8DF3\u8FC7" : "Skip"
|
|
13546
14009
|
}
|
|
13547
14010
|
),
|
|
13548
|
-
/* @__PURE__ */
|
|
14011
|
+
/* @__PURE__ */ jsx51(
|
|
13549
14012
|
Button,
|
|
13550
14013
|
{
|
|
13551
14014
|
type: "button",
|
|
@@ -13559,7 +14022,7 @@ function Questionnaire({
|
|
|
13559
14022
|
] })
|
|
13560
14023
|
] });
|
|
13561
14024
|
}
|
|
13562
|
-
return /* @__PURE__ */
|
|
14025
|
+
return /* @__PURE__ */ jsx51(
|
|
13563
14026
|
"div",
|
|
13564
14027
|
{
|
|
13565
14028
|
...props,
|
|
@@ -13571,24 +14034,24 @@ function Questionnaire({
|
|
|
13571
14034
|
}
|
|
13572
14035
|
|
|
13573
14036
|
// src/ai-chat.tsx
|
|
13574
|
-
import * as
|
|
13575
|
-
import { ArrowDown as ArrowDown2, ArrowUp as ArrowUp2, Paperclip, Square, X as
|
|
13576
|
-
import { Fragment as
|
|
14037
|
+
import * as React52 from "react";
|
|
14038
|
+
import { ArrowDown as ArrowDown2, ArrowUp as ArrowUp2, Paperclip, Square, X as X14 } from "lucide-react";
|
|
14039
|
+
import { Fragment as Fragment27, jsx as jsx52, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
13577
14040
|
function AiChat({
|
|
13578
14041
|
autoFollow = true,
|
|
13579
14042
|
bottomThreshold = 64,
|
|
13580
14043
|
scrollToBottomLabel,
|
|
13581
|
-
empty
|
|
14044
|
+
empty,
|
|
13582
14045
|
footer,
|
|
13583
14046
|
children,
|
|
13584
14047
|
className,
|
|
13585
14048
|
...props
|
|
13586
14049
|
}) {
|
|
13587
14050
|
const { locale } = useMtone();
|
|
13588
|
-
const viewport =
|
|
13589
|
-
const follow =
|
|
13590
|
-
const [atBottom, setAtBottom] =
|
|
13591
|
-
const jump =
|
|
14051
|
+
const viewport = React52.useRef(null), content2 = React52.useRef(null);
|
|
14052
|
+
const follow = React52.useRef(true);
|
|
14053
|
+
const [atBottom, setAtBottom] = React52.useState(true);
|
|
14054
|
+
const jump = React52.useCallback(() => {
|
|
13592
14055
|
const el = viewport.current;
|
|
13593
14056
|
if (el) {
|
|
13594
14057
|
el.scrollTop = el.scrollHeight;
|
|
@@ -13596,7 +14059,7 @@ function AiChat({
|
|
|
13596
14059
|
setAtBottom(true);
|
|
13597
14060
|
}
|
|
13598
14061
|
}, []);
|
|
13599
|
-
const update =
|
|
14062
|
+
const update = React52.useCallback(() => {
|
|
13600
14063
|
if (autoFollow && follow.current) jump();
|
|
13601
14064
|
else {
|
|
13602
14065
|
const el = viewport.current;
|
|
@@ -13606,16 +14069,16 @@ function AiChat({
|
|
|
13606
14069
|
);
|
|
13607
14070
|
}
|
|
13608
14071
|
}, [autoFollow, jump, bottomThreshold]);
|
|
13609
|
-
|
|
13610
|
-
|
|
14072
|
+
React52.useEffect(update, [children, update]);
|
|
14073
|
+
React52.useEffect(() => {
|
|
13611
14074
|
if (typeof ResizeObserver === "undefined") return;
|
|
13612
14075
|
const observer = new ResizeObserver(update);
|
|
13613
14076
|
if (content2.current) observer.observe(content2.current);
|
|
13614
14077
|
if (viewport.current) observer.observe(viewport.current);
|
|
13615
14078
|
return () => observer.disconnect();
|
|
13616
14079
|
}, [update]);
|
|
13617
|
-
return /* @__PURE__ */
|
|
13618
|
-
/* @__PURE__ */
|
|
14080
|
+
return /* @__PURE__ */ jsxs45("div", { ...props, className: cn("mt-ai-chat", className), children: [
|
|
14081
|
+
/* @__PURE__ */ jsx52(
|
|
13619
14082
|
"div",
|
|
13620
14083
|
{
|
|
13621
14084
|
ref: viewport,
|
|
@@ -13630,10 +14093,10 @@ function AiChat({
|
|
|
13630
14093
|
follow.current = near;
|
|
13631
14094
|
setAtBottom(near);
|
|
13632
14095
|
},
|
|
13633
|
-
children: /* @__PURE__ */
|
|
14096
|
+
children: /* @__PURE__ */ jsx52("div", { ref: content2, className: "mt-ai-chat-content", children: React52.Children.toArray(children).length ? children : empty })
|
|
13634
14097
|
}
|
|
13635
14098
|
),
|
|
13636
|
-
!atBottom && /* @__PURE__ */
|
|
14099
|
+
!atBottom && /* @__PURE__ */ jsx52("div", { className: "mt-ai-chat-jump", children: /* @__PURE__ */ jsx52(
|
|
13637
14100
|
Button,
|
|
13638
14101
|
{
|
|
13639
14102
|
size: "sm",
|
|
@@ -13641,11 +14104,11 @@ function AiChat({
|
|
|
13641
14104
|
jump();
|
|
13642
14105
|
viewport.current?.focus({ preventScroll: true });
|
|
13643
14106
|
},
|
|
13644
|
-
icon: /* @__PURE__ */
|
|
14107
|
+
icon: /* @__PURE__ */ jsx52(ArrowDown2, { size: 14, "aria-hidden": "true" }),
|
|
13645
14108
|
children: scrollToBottomLabel ?? (locale === "zh" ? "\u56DE\u5230\u6700\u65B0\u6D88\u606F" : "Jump to latest")
|
|
13646
14109
|
}
|
|
13647
14110
|
) }),
|
|
13648
|
-
footer != null && /* @__PURE__ */
|
|
14111
|
+
footer != null && /* @__PURE__ */ jsx52("div", { className: "mt-ai-chat-footer", children: footer })
|
|
13649
14112
|
] });
|
|
13650
14113
|
}
|
|
13651
14114
|
function AiMessage({
|
|
@@ -13665,7 +14128,7 @@ function AiMessage({
|
|
|
13665
14128
|
assistant: locale === "zh" ? "\u52A9\u624B" : "Assistant",
|
|
13666
14129
|
system: locale === "zh" ? "\u7CFB\u7EDF" : "System"
|
|
13667
14130
|
}[from];
|
|
13668
|
-
return /* @__PURE__ */
|
|
14131
|
+
return /* @__PURE__ */ jsxs45(
|
|
13669
14132
|
"article",
|
|
13670
14133
|
{
|
|
13671
14134
|
...props,
|
|
@@ -13673,12 +14136,12 @@ function AiMessage({
|
|
|
13673
14136
|
"data-from": from,
|
|
13674
14137
|
"data-status": status,
|
|
13675
14138
|
children: [
|
|
13676
|
-
avatar != null && /* @__PURE__ */
|
|
13677
|
-
/* @__PURE__ */
|
|
13678
|
-
/* @__PURE__ */
|
|
13679
|
-
/* @__PURE__ */
|
|
13680
|
-
status !== "idle" && /* @__PURE__ */
|
|
13681
|
-
actions != null && /* @__PURE__ */
|
|
14139
|
+
avatar != null && /* @__PURE__ */ jsx52("div", { className: "mt-ai-message-avatar", children: avatar }),
|
|
14140
|
+
/* @__PURE__ */ jsxs45("div", { className: "mt-ai-message-main", children: [
|
|
14141
|
+
/* @__PURE__ */ jsx52("div", { className: "mt-ai-message-name", children: sender }),
|
|
14142
|
+
/* @__PURE__ */ jsx52("div", { className: "mt-ai-message-body", children }),
|
|
14143
|
+
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") }),
|
|
14144
|
+
actions != null && /* @__PURE__ */ jsx52("div", { className: "mt-ai-message-actions", children: actions })
|
|
13682
14145
|
] })
|
|
13683
14146
|
]
|
|
13684
14147
|
}
|
|
@@ -13708,10 +14171,10 @@ function AiPromptInput({
|
|
|
13708
14171
|
}) {
|
|
13709
14172
|
const { locale } = useMtone();
|
|
13710
14173
|
const zh = locale === "zh";
|
|
13711
|
-
const [local, setLocal] =
|
|
13712
|
-
const lock =
|
|
13713
|
-
const mounted =
|
|
13714
|
-
|
|
14174
|
+
const [local, setLocal] = React52.useState(defaultValue), [pending, setPending] = React52.useState(false), [failed, setFailed] = React52.useState(false);
|
|
14175
|
+
const lock = React52.useRef(false), composing = React52.useRef(false), file = React52.useRef(null);
|
|
14176
|
+
const mounted = React52.useRef(true);
|
|
14177
|
+
React52.useEffect(() => {
|
|
13715
14178
|
mounted.current = true;
|
|
13716
14179
|
return () => {
|
|
13717
14180
|
mounted.current = false;
|
|
@@ -13740,9 +14203,9 @@ function AiPromptInput({
|
|
|
13740
14203
|
setFailed(true);
|
|
13741
14204
|
}
|
|
13742
14205
|
};
|
|
13743
|
-
const errorId =
|
|
14206
|
+
const errorId = React52.useId();
|
|
13744
14207
|
const message = error ?? (failed ? zh ? "\u53D1\u9001\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002" : "Could not send. Please retry." : null);
|
|
13745
|
-
return /* @__PURE__ */
|
|
14208
|
+
return /* @__PURE__ */ jsxs45(
|
|
13746
14209
|
"div",
|
|
13747
14210
|
{
|
|
13748
14211
|
...props,
|
|
@@ -13750,18 +14213,18 @@ function AiPromptInput({
|
|
|
13750
14213
|
"data-status": status,
|
|
13751
14214
|
"aria-busy": busy,
|
|
13752
14215
|
children: [
|
|
13753
|
-
attachments.length > 0 && /* @__PURE__ */
|
|
14216
|
+
attachments.length > 0 && /* @__PURE__ */ jsx52(
|
|
13754
14217
|
"ul",
|
|
13755
14218
|
{
|
|
13756
14219
|
className: "mt-ai-prompt-attachments",
|
|
13757
14220
|
"aria-label": zh ? "\u9644\u4EF6" : "Attachments",
|
|
13758
|
-
children: attachments.map((a) => /* @__PURE__ */
|
|
13759
|
-
/* @__PURE__ */
|
|
13760
|
-
a.size !== void 0 && /* @__PURE__ */
|
|
14221
|
+
children: attachments.map((a) => /* @__PURE__ */ jsxs45("li", { children: [
|
|
14222
|
+
/* @__PURE__ */ jsx52("span", { title: a.name, children: a.name }),
|
|
14223
|
+
a.size !== void 0 && /* @__PURE__ */ jsxs45("small", { children: [
|
|
13761
14224
|
Math.max(0, a.size),
|
|
13762
14225
|
" B"
|
|
13763
14226
|
] }),
|
|
13764
|
-
onAttachmentRemove && /* @__PURE__ */
|
|
14227
|
+
onAttachmentRemove && /* @__PURE__ */ jsx52(
|
|
13765
14228
|
Button,
|
|
13766
14229
|
{
|
|
13767
14230
|
size: "sm",
|
|
@@ -13769,13 +14232,13 @@ function AiPromptInput({
|
|
|
13769
14232
|
disabled: disabled || busy,
|
|
13770
14233
|
"aria-label": `${zh ? "\u79FB\u9664" : "Remove"} ${a.name}`,
|
|
13771
14234
|
onClick: () => onAttachmentRemove(a.id),
|
|
13772
|
-
children: /* @__PURE__ */
|
|
14235
|
+
children: /* @__PURE__ */ jsx52(X14, { size: 12 })
|
|
13773
14236
|
}
|
|
13774
14237
|
)
|
|
13775
14238
|
] }, a.id))
|
|
13776
14239
|
}
|
|
13777
14240
|
),
|
|
13778
|
-
/* @__PURE__ */
|
|
14241
|
+
/* @__PURE__ */ jsx52(
|
|
13779
14242
|
Input.TextArea,
|
|
13780
14243
|
{
|
|
13781
14244
|
value: text,
|
|
@@ -13804,10 +14267,10 @@ function AiPromptInput({
|
|
|
13804
14267
|
}
|
|
13805
14268
|
}
|
|
13806
14269
|
),
|
|
13807
|
-
/* @__PURE__ */
|
|
13808
|
-
/* @__PURE__ */
|
|
13809
|
-
onFilesSelect && /* @__PURE__ */
|
|
13810
|
-
/* @__PURE__ */
|
|
14270
|
+
/* @__PURE__ */ jsxs45("div", { className: "mt-ai-prompt-toolbar", children: [
|
|
14271
|
+
/* @__PURE__ */ jsxs45("div", { className: "mt-ai-prompt-tools", children: [
|
|
14272
|
+
onFilesSelect && /* @__PURE__ */ jsxs45(Fragment27, { children: [
|
|
14273
|
+
/* @__PURE__ */ jsx52(
|
|
13811
14274
|
"input",
|
|
13812
14275
|
{
|
|
13813
14276
|
ref: file,
|
|
@@ -13824,7 +14287,7 @@ function AiPromptInput({
|
|
|
13824
14287
|
}
|
|
13825
14288
|
}
|
|
13826
14289
|
),
|
|
13827
|
-
/* @__PURE__ */
|
|
14290
|
+
/* @__PURE__ */ jsx52(
|
|
13828
14291
|
Button,
|
|
13829
14292
|
{
|
|
13830
14293
|
size: "sm",
|
|
@@ -13832,33 +14295,33 @@ function AiPromptInput({
|
|
|
13832
14295
|
disabled: disabled || busy,
|
|
13833
14296
|
"aria-label": attachmentLabel ?? (zh ? "\u6DFB\u52A0\u9644\u4EF6" : "Add attachments"),
|
|
13834
14297
|
onClick: () => file.current?.click(),
|
|
13835
|
-
children: /* @__PURE__ */
|
|
14298
|
+
children: /* @__PURE__ */ jsx52(Paperclip, { size: 15 })
|
|
13836
14299
|
}
|
|
13837
14300
|
)
|
|
13838
14301
|
] }),
|
|
13839
14302
|
toolbar
|
|
13840
14303
|
] }),
|
|
13841
|
-
busy ? /* @__PURE__ */
|
|
14304
|
+
busy ? /* @__PURE__ */ jsx52(
|
|
13842
14305
|
Button,
|
|
13843
14306
|
{
|
|
13844
14307
|
size: "sm",
|
|
13845
14308
|
disabled: disabled || !onStop,
|
|
13846
14309
|
onClick: onStop,
|
|
13847
|
-
icon: /* @__PURE__ */
|
|
14310
|
+
icon: /* @__PURE__ */ jsx52(Square, { size: 12 }),
|
|
13848
14311
|
children: stopLabel ?? (zh ? "\u505C\u6B62\u751F\u6210" : "Stop generating")
|
|
13849
14312
|
}
|
|
13850
|
-
) : /* @__PURE__ */
|
|
14313
|
+
) : /* @__PURE__ */ jsx52(
|
|
13851
14314
|
Button,
|
|
13852
14315
|
{
|
|
13853
14316
|
size: "sm",
|
|
13854
14317
|
disabled: disabled || !text.trim() && !attachments.length,
|
|
13855
14318
|
onClick: send,
|
|
13856
|
-
icon: /* @__PURE__ */
|
|
14319
|
+
icon: /* @__PURE__ */ jsx52(ArrowUp2, { size: 14 }),
|
|
13857
14320
|
children: submitLabel ?? (zh ? "\u53D1\u9001" : "Send")
|
|
13858
14321
|
}
|
|
13859
14322
|
)
|
|
13860
14323
|
] }),
|
|
13861
|
-
message != null && /* @__PURE__ */
|
|
14324
|
+
message != null && /* @__PURE__ */ jsx52("div", { id: errorId, role: "alert", className: "mt-ai-prompt-error", children: message })
|
|
13862
14325
|
]
|
|
13863
14326
|
}
|
|
13864
14327
|
);
|
|
@@ -13871,7 +14334,7 @@ function AiSuggestion({
|
|
|
13871
14334
|
className,
|
|
13872
14335
|
...props
|
|
13873
14336
|
}) {
|
|
13874
|
-
return /* @__PURE__ */
|
|
14337
|
+
return /* @__PURE__ */ jsx52(
|
|
13875
14338
|
Button,
|
|
13876
14339
|
{
|
|
13877
14340
|
variant: "outline",
|
|
@@ -13899,8 +14362,8 @@ function AiModelSelector({
|
|
|
13899
14362
|
...props
|
|
13900
14363
|
}) {
|
|
13901
14364
|
const { locale } = useMtone();
|
|
13902
|
-
return /* @__PURE__ */
|
|
13903
|
-
/* @__PURE__ */
|
|
14365
|
+
return /* @__PURE__ */ jsxs45("div", { ...props, className: cn("mt-ai-model-selector", className), children: [
|
|
14366
|
+
/* @__PURE__ */ jsx52(
|
|
13904
14367
|
Select,
|
|
13905
14368
|
{
|
|
13906
14369
|
options: models,
|
|
@@ -13912,7 +14375,7 @@ function AiModelSelector({
|
|
|
13912
14375
|
label: modelLabel ?? (locale === "zh" ? "\u6A21\u578B" : "Model")
|
|
13913
14376
|
}
|
|
13914
14377
|
),
|
|
13915
|
-
efforts && /* @__PURE__ */
|
|
14378
|
+
efforts && /* @__PURE__ */ jsx52(
|
|
13916
14379
|
Select,
|
|
13917
14380
|
{
|
|
13918
14381
|
options: efforts,
|
|
@@ -13928,7 +14391,7 @@ function AiModelSelector({
|
|
|
13928
14391
|
}
|
|
13929
14392
|
|
|
13930
14393
|
// src/ai-activity.tsx
|
|
13931
|
-
import * as
|
|
14394
|
+
import * as React53 from "react";
|
|
13932
14395
|
import {
|
|
13933
14396
|
Check as Check7,
|
|
13934
14397
|
ChevronRight as ChevronRight12,
|
|
@@ -13936,9 +14399,9 @@ import {
|
|
|
13936
14399
|
CircleAlert,
|
|
13937
14400
|
LoaderCircle as LoaderCircle10,
|
|
13938
14401
|
RotateCcw as RotateCcw2,
|
|
13939
|
-
X as
|
|
14402
|
+
X as X15
|
|
13940
14403
|
} from "lucide-react";
|
|
13941
|
-
import { Fragment as
|
|
14404
|
+
import { Fragment as Fragment28, jsx as jsx53, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
13942
14405
|
var statusNames = {
|
|
13943
14406
|
zh: {
|
|
13944
14407
|
pending: "\u5F85\u5904\u7406",
|
|
@@ -13965,11 +14428,11 @@ function ActivityStatus({
|
|
|
13965
14428
|
running: LoaderCircle10,
|
|
13966
14429
|
completed: Check7,
|
|
13967
14430
|
error: CircleAlert,
|
|
13968
|
-
cancelled:
|
|
14431
|
+
cancelled: X15
|
|
13969
14432
|
}[status];
|
|
13970
|
-
return /* @__PURE__ */
|
|
13971
|
-
/* @__PURE__ */
|
|
13972
|
-
/* @__PURE__ */
|
|
14433
|
+
return /* @__PURE__ */ jsxs46("span", { className: "mt-ai-activity-status", "data-status": status, children: [
|
|
14434
|
+
/* @__PURE__ */ jsx53(Icon, { size: 14, "aria-hidden": "true" }),
|
|
14435
|
+
/* @__PURE__ */ jsx53("span", { children: label ?? statusNames[locale === "en" ? "en" : "zh"][status] })
|
|
13973
14436
|
] });
|
|
13974
14437
|
}
|
|
13975
14438
|
function ActivityDisclosure({
|
|
@@ -13983,18 +14446,18 @@ function ActivityDisclosure({
|
|
|
13983
14446
|
className,
|
|
13984
14447
|
...props
|
|
13985
14448
|
}) {
|
|
13986
|
-
const [internalOpen, setInternalOpen] =
|
|
14449
|
+
const [internalOpen, setInternalOpen] = React53.useState(defaultOpen);
|
|
13987
14450
|
const expanded = open ?? internalOpen;
|
|
13988
|
-
const id =
|
|
13989
|
-
return /* @__PURE__ */
|
|
14451
|
+
const id = React53.useId();
|
|
14452
|
+
return /* @__PURE__ */ jsxs46(
|
|
13990
14453
|
"div",
|
|
13991
14454
|
{
|
|
13992
14455
|
...props,
|
|
13993
14456
|
className: cn("mt-ai-activity", className),
|
|
13994
14457
|
"data-status": status,
|
|
13995
14458
|
children: [
|
|
13996
|
-
/* @__PURE__ */
|
|
13997
|
-
/* @__PURE__ */
|
|
14459
|
+
/* @__PURE__ */ jsxs46("div", { className: "mt-ai-activity-header", children: [
|
|
14460
|
+
/* @__PURE__ */ jsxs46(
|
|
13998
14461
|
"button",
|
|
13999
14462
|
{
|
|
14000
14463
|
type: "button",
|
|
@@ -14008,7 +14471,7 @@ function ActivityDisclosure({
|
|
|
14008
14471
|
onOpenChange?.(!expanded);
|
|
14009
14472
|
},
|
|
14010
14473
|
children: [
|
|
14011
|
-
/* @__PURE__ */
|
|
14474
|
+
/* @__PURE__ */ jsx53(
|
|
14012
14475
|
ChevronRight12,
|
|
14013
14476
|
{
|
|
14014
14477
|
size: 14,
|
|
@@ -14016,13 +14479,13 @@ function ActivityDisclosure({
|
|
|
14016
14479
|
className: "mt-ai-activity-chevron"
|
|
14017
14480
|
}
|
|
14018
14481
|
),
|
|
14019
|
-
/* @__PURE__ */
|
|
14482
|
+
/* @__PURE__ */ jsx53("span", { children: title })
|
|
14020
14483
|
]
|
|
14021
14484
|
}
|
|
14022
14485
|
),
|
|
14023
|
-
/* @__PURE__ */
|
|
14486
|
+
/* @__PURE__ */ jsx53(ActivityStatus, { status, label: statusLabel })
|
|
14024
14487
|
] }),
|
|
14025
|
-
/* @__PURE__ */
|
|
14488
|
+
/* @__PURE__ */ jsx53(
|
|
14026
14489
|
"div",
|
|
14027
14490
|
{
|
|
14028
14491
|
id: `${id}-content`,
|
|
@@ -14043,24 +14506,24 @@ function ActivitySteps({
|
|
|
14043
14506
|
}) {
|
|
14044
14507
|
const { locale } = useMtone();
|
|
14045
14508
|
if (!items.length)
|
|
14046
|
-
return /* @__PURE__ */
|
|
14047
|
-
return /* @__PURE__ */
|
|
14048
|
-
/* @__PURE__ */
|
|
14049
|
-
/* @__PURE__ */
|
|
14050
|
-
/* @__PURE__ */
|
|
14509
|
+
return /* @__PURE__ */ jsx53("p", { className: "mt-ai-activity-empty", children: locale === "en" ? "No items" : "\u6682\u65E0\u4E8B\u9879" });
|
|
14510
|
+
return /* @__PURE__ */ jsx53("ol", { className: "mt-ai-activity-steps", "aria-label": label, children: items.map((item) => /* @__PURE__ */ jsxs46("li", { children: [
|
|
14511
|
+
/* @__PURE__ */ jsxs46("div", { className: "mt-ai-activity-step-heading", children: [
|
|
14512
|
+
/* @__PURE__ */ jsx53("span", { children: item.title }),
|
|
14513
|
+
/* @__PURE__ */ jsx53(ActivityStatus, { status: item.status ?? "pending" })
|
|
14051
14514
|
] }),
|
|
14052
|
-
item.description != null && /* @__PURE__ */
|
|
14515
|
+
item.description != null && /* @__PURE__ */ jsx53("div", { className: "mt-ai-activity-description", children: item.description })
|
|
14053
14516
|
] }, item.id)) });
|
|
14054
14517
|
}
|
|
14055
14518
|
function AiTask({ title, steps = [], children, ...props }) {
|
|
14056
14519
|
const { locale } = useMtone();
|
|
14057
|
-
return /* @__PURE__ */
|
|
14520
|
+
return /* @__PURE__ */ jsxs46(
|
|
14058
14521
|
ActivityDisclosure,
|
|
14059
14522
|
{
|
|
14060
14523
|
...props,
|
|
14061
14524
|
title: title ?? (locale === "en" ? "Task" : "\u4EFB\u52A1"),
|
|
14062
14525
|
children: [
|
|
14063
|
-
/* @__PURE__ */
|
|
14526
|
+
/* @__PURE__ */ jsx53(ActivitySteps, { items: steps }),
|
|
14064
14527
|
children
|
|
14065
14528
|
]
|
|
14066
14529
|
}
|
|
@@ -14073,13 +14536,13 @@ function AiReasoning({
|
|
|
14073
14536
|
...props
|
|
14074
14537
|
}) {
|
|
14075
14538
|
const { locale } = useMtone();
|
|
14076
|
-
return /* @__PURE__ */
|
|
14539
|
+
return /* @__PURE__ */ jsxs46(
|
|
14077
14540
|
ActivityDisclosure,
|
|
14078
14541
|
{
|
|
14079
14542
|
...props,
|
|
14080
14543
|
title: title ?? (locale === "en" ? "Public explanation" : "\u516C\u5F00\u8FC7\u7A0B\u8BF4\u660E"),
|
|
14081
14544
|
children: [
|
|
14082
|
-
/* @__PURE__ */
|
|
14545
|
+
/* @__PURE__ */ jsx53("div", { className: "mt-ai-activity-text", children: text }),
|
|
14083
14546
|
children
|
|
14084
14547
|
]
|
|
14085
14548
|
}
|
|
@@ -14095,9 +14558,9 @@ function AiPlan({
|
|
|
14095
14558
|
const { locale } = useMtone();
|
|
14096
14559
|
const completed = items.filter((item) => item.status === "completed").length;
|
|
14097
14560
|
const label = title ?? (locale === "en" ? "Plan" : "\u8BA1\u5212");
|
|
14098
|
-
return /* @__PURE__ */
|
|
14099
|
-
!!items.length && /* @__PURE__ */
|
|
14100
|
-
/* @__PURE__ */
|
|
14561
|
+
return /* @__PURE__ */ jsxs46(ActivityDisclosure, { ...props, title: label, defaultOpen, children: [
|
|
14562
|
+
!!items.length && /* @__PURE__ */ jsxs46("div", { className: "mt-ai-activity-progress", children: [
|
|
14563
|
+
/* @__PURE__ */ jsx53(
|
|
14101
14564
|
"progress",
|
|
14102
14565
|
{
|
|
14103
14566
|
"aria-label": locale === "en" ? `${label} progress` : `${label}\u8FDB\u5EA6`,
|
|
@@ -14105,13 +14568,13 @@ function AiPlan({
|
|
|
14105
14568
|
max: items.length
|
|
14106
14569
|
}
|
|
14107
14570
|
),
|
|
14108
|
-
/* @__PURE__ */
|
|
14571
|
+
/* @__PURE__ */ jsxs46("span", { children: [
|
|
14109
14572
|
completed,
|
|
14110
14573
|
" / ",
|
|
14111
14574
|
items.length
|
|
14112
14575
|
] })
|
|
14113
14576
|
] }),
|
|
14114
|
-
/* @__PURE__ */
|
|
14577
|
+
/* @__PURE__ */ jsx53(ActivitySteps, { items }),
|
|
14115
14578
|
children
|
|
14116
14579
|
] });
|
|
14117
14580
|
}
|
|
@@ -14126,17 +14589,17 @@ function AiQueue({
|
|
|
14126
14589
|
const en = locale === "en";
|
|
14127
14590
|
const done = (item) => item.status === "completed" || item.status === "cancelled";
|
|
14128
14591
|
const remaining = items.filter((item) => !done(item)), ended = items.filter(done);
|
|
14129
|
-
return /* @__PURE__ */
|
|
14592
|
+
return /* @__PURE__ */ jsxs46(
|
|
14130
14593
|
ActivityDisclosure,
|
|
14131
14594
|
{
|
|
14132
14595
|
...props,
|
|
14133
14596
|
title: title ?? (en ? "Queue" : "\u961F\u5217"),
|
|
14134
14597
|
defaultOpen,
|
|
14135
14598
|
children: [
|
|
14136
|
-
!items.length ? /* @__PURE__ */
|
|
14137
|
-
!!remaining.length && /* @__PURE__ */
|
|
14138
|
-
/* @__PURE__ */
|
|
14139
|
-
/* @__PURE__ */
|
|
14599
|
+
!items.length ? /* @__PURE__ */ jsx53(ActivitySteps, { items: [] }) : /* @__PURE__ */ jsxs46(Fragment28, { children: [
|
|
14600
|
+
!!remaining.length && /* @__PURE__ */ jsxs46("div", { children: [
|
|
14601
|
+
/* @__PURE__ */ jsx53("div", { className: "mt-ai-activity-group-label", children: en ? "Remaining" : "\u5F85\u5B8C\u6210" }),
|
|
14602
|
+
/* @__PURE__ */ jsx53(
|
|
14140
14603
|
ActivitySteps,
|
|
14141
14604
|
{
|
|
14142
14605
|
items: remaining,
|
|
@@ -14144,9 +14607,9 @@ function AiQueue({
|
|
|
14144
14607
|
}
|
|
14145
14608
|
)
|
|
14146
14609
|
] }),
|
|
14147
|
-
!!ended.length && /* @__PURE__ */
|
|
14148
|
-
/* @__PURE__ */
|
|
14149
|
-
/* @__PURE__ */
|
|
14610
|
+
!!ended.length && /* @__PURE__ */ jsxs46("div", { children: [
|
|
14611
|
+
/* @__PURE__ */ jsx53("div", { className: "mt-ai-activity-group-label", children: en ? "Finished" : "\u5DF2\u7ED3\u675F" }),
|
|
14612
|
+
/* @__PURE__ */ jsx53(ActivitySteps, { items: ended, label: en ? "Finished" : "\u5DF2\u7ED3\u675F" })
|
|
14150
14613
|
] })
|
|
14151
14614
|
] }),
|
|
14152
14615
|
children
|
|
@@ -14163,12 +14626,12 @@ function AiSubagent({
|
|
|
14163
14626
|
...props
|
|
14164
14627
|
}) {
|
|
14165
14628
|
const { locale } = useMtone();
|
|
14166
|
-
return /* @__PURE__ */
|
|
14167
|
-
description != null && /* @__PURE__ */
|
|
14629
|
+
return /* @__PURE__ */ jsxs46(ActivityDisclosure, { ...props, title: title ?? name, children: [
|
|
14630
|
+
description != null && /* @__PURE__ */ jsx53("div", { className: "mt-ai-activity-description", children: description }),
|
|
14168
14631
|
children,
|
|
14169
|
-
result != null && /* @__PURE__ */
|
|
14170
|
-
/* @__PURE__ */
|
|
14171
|
-
/* @__PURE__ */
|
|
14632
|
+
result != null && /* @__PURE__ */ jsxs46("div", { children: [
|
|
14633
|
+
/* @__PURE__ */ jsx53("div", { className: "mt-ai-activity-group-label", children: locale === "en" ? "Result" : "\u7ED3\u679C" }),
|
|
14634
|
+
/* @__PURE__ */ jsx53("div", { className: "mt-ai-activity-text", children: result })
|
|
14172
14635
|
] })
|
|
14173
14636
|
] });
|
|
14174
14637
|
}
|
|
@@ -14182,14 +14645,14 @@ function AiTool({
|
|
|
14182
14645
|
}) {
|
|
14183
14646
|
const { locale } = useMtone();
|
|
14184
14647
|
const en = locale === "en";
|
|
14185
|
-
return /* @__PURE__ */
|
|
14186
|
-
input !== void 0 && /* @__PURE__ */
|
|
14187
|
-
/* @__PURE__ */
|
|
14188
|
-
/* @__PURE__ */
|
|
14648
|
+
return /* @__PURE__ */ jsxs46(ActivityDisclosure, { ...props, title: title ?? name, children: [
|
|
14649
|
+
input !== void 0 && /* @__PURE__ */ jsxs46("div", { children: [
|
|
14650
|
+
/* @__PURE__ */ jsx53("div", { className: "mt-ai-activity-group-label", children: en ? "Input" : "\u8F93\u5165" }),
|
|
14651
|
+
/* @__PURE__ */ jsx53("pre", { className: "mt-ai-activity-code", children: input })
|
|
14189
14652
|
] }),
|
|
14190
|
-
output !== void 0 && /* @__PURE__ */
|
|
14191
|
-
/* @__PURE__ */
|
|
14192
|
-
/* @__PURE__ */
|
|
14653
|
+
output !== void 0 && /* @__PURE__ */ jsxs46("div", { children: [
|
|
14654
|
+
/* @__PURE__ */ jsx53("div", { className: "mt-ai-activity-group-label", children: en ? "Output" : "\u8F93\u51FA" }),
|
|
14655
|
+
/* @__PURE__ */ jsx53("pre", { className: "mt-ai-activity-code", children: output })
|
|
14193
14656
|
] }),
|
|
14194
14657
|
children
|
|
14195
14658
|
] });
|
|
@@ -14206,18 +14669,18 @@ function AiCheckpoint({
|
|
|
14206
14669
|
}) {
|
|
14207
14670
|
const { locale } = useMtone();
|
|
14208
14671
|
const en = locale === "en";
|
|
14209
|
-
return /* @__PURE__ */
|
|
14672
|
+
return /* @__PURE__ */ jsxs46(
|
|
14210
14673
|
"div",
|
|
14211
14674
|
{
|
|
14212
14675
|
...props,
|
|
14213
14676
|
className: cn("mt-ai-activity mt-ai-checkpoint", className),
|
|
14214
14677
|
children: [
|
|
14215
|
-
/* @__PURE__ */
|
|
14216
|
-
/* @__PURE__ */
|
|
14217
|
-
description != null && /* @__PURE__ */
|
|
14678
|
+
/* @__PURE__ */ jsxs46("div", { className: "mt-ai-checkpoint-copy", children: [
|
|
14679
|
+
/* @__PURE__ */ jsx53("div", { children: label ?? (en ? "Checkpoint" : "\u68C0\u67E5\u70B9") }),
|
|
14680
|
+
description != null && /* @__PURE__ */ jsx53("div", { className: "mt-ai-activity-description", children: description }),
|
|
14218
14681
|
children
|
|
14219
14682
|
] }),
|
|
14220
|
-
/* @__PURE__ */
|
|
14683
|
+
/* @__PURE__ */ jsxs46(
|
|
14221
14684
|
Button,
|
|
14222
14685
|
{
|
|
14223
14686
|
type: "button",
|
|
@@ -14225,7 +14688,7 @@ function AiCheckpoint({
|
|
|
14225
14688
|
disabled: disabled || !onRestore,
|
|
14226
14689
|
onClick: () => onRestore?.(),
|
|
14227
14690
|
children: [
|
|
14228
|
-
/* @__PURE__ */
|
|
14691
|
+
/* @__PURE__ */ jsx53(RotateCcw2, { size: 14, "aria-hidden": "true" }),
|
|
14229
14692
|
restoreLabel ?? (en ? "Restore" : "\u6062\u590D")
|
|
14230
14693
|
]
|
|
14231
14694
|
}
|
|
@@ -14249,7 +14712,7 @@ function AiConfirmation({
|
|
|
14249
14712
|
}) {
|
|
14250
14713
|
const { locale } = useMtone();
|
|
14251
14714
|
const en = locale === "en";
|
|
14252
|
-
return /* @__PURE__ */
|
|
14715
|
+
return /* @__PURE__ */ jsxs46(
|
|
14253
14716
|
"div",
|
|
14254
14717
|
{
|
|
14255
14718
|
...props,
|
|
@@ -14257,11 +14720,11 @@ function AiConfirmation({
|
|
|
14257
14720
|
"aria-busy": busy || void 0,
|
|
14258
14721
|
"data-state": state,
|
|
14259
14722
|
children: [
|
|
14260
|
-
/* @__PURE__ */
|
|
14261
|
-
description != null && /* @__PURE__ */
|
|
14723
|
+
/* @__PURE__ */ jsx53("div", { className: "mt-ai-confirmation-title", children: title ?? (en ? "Confirmation required" : "\u9700\u8981\u786E\u8BA4") }),
|
|
14724
|
+
description != null && /* @__PURE__ */ jsx53("div", { className: "mt-ai-activity-description", children: description }),
|
|
14262
14725
|
children,
|
|
14263
|
-
state === "pending" ? /* @__PURE__ */
|
|
14264
|
-
/* @__PURE__ */
|
|
14726
|
+
state === "pending" ? /* @__PURE__ */ jsxs46("div", { className: "mt-ai-confirmation-actions", children: [
|
|
14727
|
+
/* @__PURE__ */ jsx53(
|
|
14265
14728
|
Button,
|
|
14266
14729
|
{
|
|
14267
14730
|
type: "button",
|
|
@@ -14271,7 +14734,7 @@ function AiConfirmation({
|
|
|
14271
14734
|
children: confirmLabel ?? (en ? "Confirm" : "\u786E\u8BA4")
|
|
14272
14735
|
}
|
|
14273
14736
|
),
|
|
14274
|
-
/* @__PURE__ */
|
|
14737
|
+
/* @__PURE__ */ jsx53(
|
|
14275
14738
|
Button,
|
|
14276
14739
|
{
|
|
14277
14740
|
type: "button",
|
|
@@ -14281,16 +14744,16 @@ function AiConfirmation({
|
|
|
14281
14744
|
children: rejectLabel ?? (en ? "Reject" : "\u62D2\u7EDD")
|
|
14282
14745
|
}
|
|
14283
14746
|
)
|
|
14284
|
-
] }) : /* @__PURE__ */
|
|
14747
|
+
] }) : /* @__PURE__ */ jsx53("div", { role: "status", className: "mt-ai-activity-description", children: state === "approved" ? en ? "Confirmed" : "\u5DF2\u786E\u8BA4" : en ? "Rejected" : "\u5DF2\u62D2\u7EDD" })
|
|
14285
14748
|
]
|
|
14286
14749
|
}
|
|
14287
14750
|
);
|
|
14288
14751
|
}
|
|
14289
14752
|
|
|
14290
14753
|
// src/ai-evidence.tsx
|
|
14291
|
-
import * as
|
|
14754
|
+
import * as React54 from "react";
|
|
14292
14755
|
import { File as File2, Folder as Folder2 } from "lucide-react";
|
|
14293
|
-
import { Fragment as
|
|
14756
|
+
import { Fragment as Fragment29, jsx as jsx54, jsxs as jsxs47 } from "react/jsx-runtime";
|
|
14294
14757
|
var count = (value) => Number.isFinite(value) ? Math.max(0, Math.floor(value)) : 0;
|
|
14295
14758
|
function useEvidenceText() {
|
|
14296
14759
|
const { locale } = useMtone();
|
|
@@ -14352,33 +14815,33 @@ function AiContext({
|
|
|
14352
14815
|
const name = label ?? text.context;
|
|
14353
14816
|
const used = count(usedTokens);
|
|
14354
14817
|
const max = maxTokens === void 0 ? 0 : count(maxTokens);
|
|
14355
|
-
return /* @__PURE__ */
|
|
14818
|
+
return /* @__PURE__ */ jsxs47(
|
|
14356
14819
|
"section",
|
|
14357
14820
|
{
|
|
14358
14821
|
"aria-label": name,
|
|
14359
14822
|
className: cn("mt-ai-evidence mt-ai-context", className),
|
|
14360
14823
|
style,
|
|
14361
14824
|
children: [
|
|
14362
|
-
/* @__PURE__ */
|
|
14363
|
-
/* @__PURE__ */
|
|
14364
|
-
/* @__PURE__ */
|
|
14825
|
+
/* @__PURE__ */ jsxs47("div", { className: "mt-ai-evidence-heading", children: [
|
|
14826
|
+
/* @__PURE__ */ jsx54("span", { children: name }),
|
|
14827
|
+
/* @__PURE__ */ jsxs47("span", { children: [
|
|
14365
14828
|
used.toLocaleString(),
|
|
14366
14829
|
max > 0 ? ` / ${max.toLocaleString()}` : ""
|
|
14367
14830
|
] })
|
|
14368
14831
|
] }),
|
|
14369
|
-
max > 0 && /* @__PURE__ */
|
|
14370
|
-
(inputTokens !== void 0 || outputTokens !== void 0 || cost !== void 0) && /* @__PURE__ */
|
|
14371
|
-
inputTokens !== void 0 && /* @__PURE__ */
|
|
14372
|
-
/* @__PURE__ */
|
|
14373
|
-
/* @__PURE__ */
|
|
14832
|
+
max > 0 && /* @__PURE__ */ jsx54(Progress, { value: Math.min(100, used / max * 100), label: name }),
|
|
14833
|
+
(inputTokens !== void 0 || outputTokens !== void 0 || cost !== void 0) && /* @__PURE__ */ jsxs47("dl", { className: "mt-ai-evidence-metrics", children: [
|
|
14834
|
+
inputTokens !== void 0 && /* @__PURE__ */ jsxs47("div", { children: [
|
|
14835
|
+
/* @__PURE__ */ jsx54("dt", { children: text.input }),
|
|
14836
|
+
/* @__PURE__ */ jsx54("dd", { children: count(inputTokens).toLocaleString() })
|
|
14374
14837
|
] }),
|
|
14375
|
-
outputTokens !== void 0 && /* @__PURE__ */
|
|
14376
|
-
/* @__PURE__ */
|
|
14377
|
-
/* @__PURE__ */
|
|
14838
|
+
outputTokens !== void 0 && /* @__PURE__ */ jsxs47("div", { children: [
|
|
14839
|
+
/* @__PURE__ */ jsx54("dt", { children: text.output }),
|
|
14840
|
+
/* @__PURE__ */ jsx54("dd", { children: count(outputTokens).toLocaleString() })
|
|
14378
14841
|
] }),
|
|
14379
|
-
cost !== void 0 && /* @__PURE__ */
|
|
14380
|
-
/* @__PURE__ */
|
|
14381
|
-
/* @__PURE__ */
|
|
14842
|
+
cost !== void 0 && /* @__PURE__ */ jsxs47("div", { children: [
|
|
14843
|
+
/* @__PURE__ */ jsx54("dt", { children: text.cost }),
|
|
14844
|
+
/* @__PURE__ */ jsx54("dd", { children: cost })
|
|
14382
14845
|
] })
|
|
14383
14846
|
] })
|
|
14384
14847
|
]
|
|
@@ -14396,10 +14859,10 @@ function AiFileTree({
|
|
|
14396
14859
|
style
|
|
14397
14860
|
}) {
|
|
14398
14861
|
const text = useEvidenceText();
|
|
14399
|
-
const [local, setLocal] =
|
|
14862
|
+
const [local, setLocal] = React54.useState(
|
|
14400
14863
|
defaultSelectedId ?? null
|
|
14401
14864
|
);
|
|
14402
|
-
const { nodes, data } =
|
|
14865
|
+
const { nodes, data } = React54.useMemo(() => {
|
|
14403
14866
|
const nodes2 = /* @__PURE__ */ new Map();
|
|
14404
14867
|
const visit = (values2) => values2.map((node) => {
|
|
14405
14868
|
nodes2.set(node.id, node);
|
|
@@ -14407,7 +14870,7 @@ function AiFileTree({
|
|
|
14407
14870
|
id: node.id,
|
|
14408
14871
|
label: node.name,
|
|
14409
14872
|
disabled: node.disabled,
|
|
14410
|
-
icon: node.kind === "folder" || node.children ? /* @__PURE__ */
|
|
14873
|
+
icon: node.kind === "folder" || node.children ? /* @__PURE__ */ jsx54(Folder2, { size: 14, "aria-hidden": true }) : /* @__PURE__ */ jsx54(File2, { size: 14, "aria-hidden": true }),
|
|
14411
14874
|
children: node.children ? visit(node.children) : void 0
|
|
14412
14875
|
};
|
|
14413
14876
|
});
|
|
@@ -14415,15 +14878,15 @@ function AiFileTree({
|
|
|
14415
14878
|
return { nodes: nodes2, data: data2 };
|
|
14416
14879
|
}, [items]);
|
|
14417
14880
|
const selected = selectedId === void 0 ? local : selectedId;
|
|
14418
|
-
return /* @__PURE__ */
|
|
14881
|
+
return /* @__PURE__ */ jsxs47(
|
|
14419
14882
|
"section",
|
|
14420
14883
|
{
|
|
14421
14884
|
"aria-label": label ?? text.files,
|
|
14422
14885
|
className: cn("mt-ai-evidence mt-ai-files", className),
|
|
14423
14886
|
style,
|
|
14424
14887
|
children: [
|
|
14425
|
-
/* @__PURE__ */
|
|
14426
|
-
items.length ? /* @__PURE__ */
|
|
14888
|
+
/* @__PURE__ */ jsx54("div", { className: "mt-ai-evidence-heading", children: label ?? text.files }),
|
|
14889
|
+
items.length ? /* @__PURE__ */ jsx54(
|
|
14427
14890
|
Tree,
|
|
14428
14891
|
{
|
|
14429
14892
|
"aria-label": label ?? text.files,
|
|
@@ -14440,7 +14903,7 @@ function AiFileTree({
|
|
|
14440
14903
|
onSelect?.(id, node);
|
|
14441
14904
|
}
|
|
14442
14905
|
}
|
|
14443
|
-
) : /* @__PURE__ */
|
|
14906
|
+
) : /* @__PURE__ */ jsx54("p", { className: "mt-ai-evidence-empty", children: text.noFiles })
|
|
14444
14907
|
]
|
|
14445
14908
|
}
|
|
14446
14909
|
);
|
|
@@ -14466,8 +14929,8 @@ function AiInlineCitation({
|
|
|
14466
14929
|
}) {
|
|
14467
14930
|
const url = safeSourceUrl(source.url);
|
|
14468
14931
|
const name = index === void 0 ? source.title : `${index}: ${source.title}`;
|
|
14469
|
-
const content2 = /* @__PURE__ */
|
|
14470
|
-
return url ? /* @__PURE__ */
|
|
14932
|
+
const content2 = /* @__PURE__ */ jsx54(Fragment29, { children: index === void 0 ? source.title : index });
|
|
14933
|
+
return url ? /* @__PURE__ */ jsx54(
|
|
14471
14934
|
"a",
|
|
14472
14935
|
{
|
|
14473
14936
|
className: cn("mt-ai-citation", className),
|
|
@@ -14477,7 +14940,7 @@ function AiInlineCitation({
|
|
|
14477
14940
|
title: source.description ?? source.title,
|
|
14478
14941
|
children: content2
|
|
14479
14942
|
}
|
|
14480
|
-
) : /* @__PURE__ */
|
|
14943
|
+
) : /* @__PURE__ */ jsx54(
|
|
14481
14944
|
"span",
|
|
14482
14945
|
{
|
|
14483
14946
|
className: cn("mt-ai-citation", className),
|
|
@@ -14496,29 +14959,29 @@ function AiSources({
|
|
|
14496
14959
|
style
|
|
14497
14960
|
}) {
|
|
14498
14961
|
const text = useEvidenceText();
|
|
14499
|
-
return /* @__PURE__ */
|
|
14962
|
+
return /* @__PURE__ */ jsxs47(
|
|
14500
14963
|
"details",
|
|
14501
14964
|
{
|
|
14502
14965
|
className: cn("mt-ai-evidence", className),
|
|
14503
14966
|
style,
|
|
14504
14967
|
open: defaultOpen || void 0,
|
|
14505
14968
|
children: [
|
|
14506
|
-
/* @__PURE__ */
|
|
14969
|
+
/* @__PURE__ */ jsxs47("summary", { children: [
|
|
14507
14970
|
label ?? text.sources,
|
|
14508
14971
|
" ",
|
|
14509
|
-
/* @__PURE__ */
|
|
14972
|
+
/* @__PURE__ */ jsxs47("span", { className: "mt-ai-evidence-muted", children: [
|
|
14510
14973
|
"(",
|
|
14511
14974
|
sources.length,
|
|
14512
14975
|
")"
|
|
14513
14976
|
] })
|
|
14514
14977
|
] }),
|
|
14515
|
-
sources.length ? /* @__PURE__ */
|
|
14978
|
+
sources.length ? /* @__PURE__ */ jsx54("ol", { className: "mt-ai-sources", children: sources.map((source) => {
|
|
14516
14979
|
const url = safeSourceUrl(source.url);
|
|
14517
|
-
return /* @__PURE__ */
|
|
14518
|
-
url ? /* @__PURE__ */
|
|
14519
|
-
source.description && /* @__PURE__ */
|
|
14980
|
+
return /* @__PURE__ */ jsxs47("li", { children: [
|
|
14981
|
+
url ? /* @__PURE__ */ jsx54("a", { href: url, children: source.title }) : /* @__PURE__ */ jsx54("span", { children: source.title }),
|
|
14982
|
+
source.description && /* @__PURE__ */ jsx54("p", { children: source.description })
|
|
14520
14983
|
] }, source.id);
|
|
14521
|
-
}) }) : /* @__PURE__ */
|
|
14984
|
+
}) }) : /* @__PURE__ */ jsx54("p", { className: "mt-ai-evidence-empty", children: text.noSources })
|
|
14522
14985
|
]
|
|
14523
14986
|
}
|
|
14524
14987
|
);
|
|
@@ -14532,21 +14995,21 @@ function AiStackTrace({
|
|
|
14532
14995
|
style
|
|
14533
14996
|
}) {
|
|
14534
14997
|
const text = useEvidenceText();
|
|
14535
|
-
return /* @__PURE__ */
|
|
14998
|
+
return /* @__PURE__ */ jsxs47(
|
|
14536
14999
|
"details",
|
|
14537
15000
|
{
|
|
14538
15001
|
className: cn("mt-ai-evidence mt-ai-stack", className),
|
|
14539
15002
|
style,
|
|
14540
15003
|
open: defaultOpen || void 0,
|
|
14541
15004
|
children: [
|
|
14542
|
-
/* @__PURE__ */
|
|
14543
|
-
/* @__PURE__ */
|
|
14544
|
-
frames.length ? /* @__PURE__ */
|
|
15005
|
+
/* @__PURE__ */ jsx54("summary", { children: label ?? text.stack }),
|
|
15006
|
+
/* @__PURE__ */ jsx54("pre", { className: "mt-ai-evidence-code", children: message }),
|
|
15007
|
+
frames.length ? /* @__PURE__ */ jsx54("ol", { className: "mt-ai-stack-frames", children: frames.map((frame, i) => /* @__PURE__ */ jsx54("li", { children: /* @__PURE__ */ jsxs47("code", { children: [
|
|
14545
15008
|
frame.functionName ? `${frame.functionName} \u2014 ` : "",
|
|
14546
15009
|
frame.file,
|
|
14547
15010
|
frame.line === void 0 ? "" : `:${count(frame.line)}`,
|
|
14548
15011
|
frame.column === void 0 ? "" : `:${count(frame.column)}`
|
|
14549
|
-
] }) }, i)) }) : /* @__PURE__ */
|
|
15012
|
+
] }) }, i)) }) : /* @__PURE__ */ jsx54("p", { className: "mt-ai-evidence-empty", children: text.noFrames })
|
|
14550
15013
|
]
|
|
14551
15014
|
}
|
|
14552
15015
|
);
|
|
@@ -14559,18 +15022,18 @@ function AiTerminal({
|
|
|
14559
15022
|
style
|
|
14560
15023
|
}) {
|
|
14561
15024
|
const text = useEvidenceText();
|
|
14562
|
-
return /* @__PURE__ */
|
|
15025
|
+
return /* @__PURE__ */ jsxs47(
|
|
14563
15026
|
"section",
|
|
14564
15027
|
{
|
|
14565
15028
|
"aria-label": label ?? text.terminal,
|
|
14566
15029
|
className: cn("mt-ai-evidence mt-ai-terminal", className),
|
|
14567
15030
|
style,
|
|
14568
15031
|
children: [
|
|
14569
|
-
/* @__PURE__ */
|
|
14570
|
-
/* @__PURE__ */
|
|
14571
|
-
/* @__PURE__ */
|
|
15032
|
+
/* @__PURE__ */ jsxs47("div", { className: "mt-ai-evidence-heading", children: [
|
|
15033
|
+
/* @__PURE__ */ jsx54("span", { children: label ?? text.terminal }),
|
|
15034
|
+
/* @__PURE__ */ jsx54("span", { className: "mt-ai-evidence-status", "data-status": status, children: text[status] })
|
|
14572
15035
|
] }),
|
|
14573
|
-
/* @__PURE__ */
|
|
15036
|
+
/* @__PURE__ */ jsx54(
|
|
14574
15037
|
"pre",
|
|
14575
15038
|
{
|
|
14576
15039
|
className: "mt-ai-evidence-code",
|
|
@@ -14592,24 +15055,24 @@ function AiTestResults({
|
|
|
14592
15055
|
}) {
|
|
14593
15056
|
const text = useEvidenceText();
|
|
14594
15057
|
const statuses = ["passed", "failed", "skipped", "running"];
|
|
14595
|
-
return /* @__PURE__ */
|
|
15058
|
+
return /* @__PURE__ */ jsxs47(
|
|
14596
15059
|
"details",
|
|
14597
15060
|
{
|
|
14598
15061
|
className: cn("mt-ai-evidence mt-ai-tests", className),
|
|
14599
15062
|
style,
|
|
14600
15063
|
open: defaultOpen || void 0,
|
|
14601
15064
|
children: [
|
|
14602
|
-
/* @__PURE__ */
|
|
15065
|
+
/* @__PURE__ */ jsxs47("summary", { children: [
|
|
14603
15066
|
label ?? text.tests,
|
|
14604
15067
|
" ",
|
|
14605
|
-
/* @__PURE__ */
|
|
15068
|
+
/* @__PURE__ */ jsxs47("span", { className: "mt-ai-evidence-muted", children: [
|
|
14606
15069
|
"(",
|
|
14607
15070
|
results.length,
|
|
14608
15071
|
")"
|
|
14609
15072
|
] })
|
|
14610
15073
|
] }),
|
|
14611
|
-
results.length ? /* @__PURE__ */
|
|
14612
|
-
/* @__PURE__ */
|
|
15074
|
+
results.length ? /* @__PURE__ */ jsxs47(Fragment29, { children: [
|
|
15075
|
+
/* @__PURE__ */ jsx54("div", { className: "mt-ai-test-counts", children: statuses.map((status) => /* @__PURE__ */ jsxs47(
|
|
14613
15076
|
"span",
|
|
14614
15077
|
{
|
|
14615
15078
|
className: "mt-ai-evidence-status",
|
|
@@ -14622,10 +15085,10 @@ function AiTestResults({
|
|
|
14622
15085
|
},
|
|
14623
15086
|
status
|
|
14624
15087
|
)) }),
|
|
14625
|
-
/* @__PURE__ */
|
|
14626
|
-
const title = /* @__PURE__ */
|
|
14627
|
-
/* @__PURE__ */
|
|
14628
|
-
/* @__PURE__ */
|
|
15088
|
+
/* @__PURE__ */ jsx54("ul", { className: "mt-ai-test-list", children: results.map((result) => {
|
|
15089
|
+
const title = /* @__PURE__ */ jsxs47(Fragment29, { children: [
|
|
15090
|
+
/* @__PURE__ */ jsx54("span", { className: "mt-ai-test-name", children: result.name }),
|
|
15091
|
+
/* @__PURE__ */ jsx54(
|
|
14629
15092
|
"span",
|
|
14630
15093
|
{
|
|
14631
15094
|
className: "mt-ai-evidence-status",
|
|
@@ -14633,27 +15096,27 @@ function AiTestResults({
|
|
|
14633
15096
|
children: text[result.status]
|
|
14634
15097
|
}
|
|
14635
15098
|
),
|
|
14636
|
-
result.durationMs !== void 0 && /* @__PURE__ */
|
|
15099
|
+
result.durationMs !== void 0 && /* @__PURE__ */ jsxs47("span", { className: "mt-ai-evidence-muted", children: [
|
|
14637
15100
|
count(result.durationMs),
|
|
14638
15101
|
" ms"
|
|
14639
15102
|
] })
|
|
14640
15103
|
] });
|
|
14641
|
-
return /* @__PURE__ */
|
|
14642
|
-
/* @__PURE__ */
|
|
14643
|
-
/* @__PURE__ */
|
|
14644
|
-
] }) : /* @__PURE__ */
|
|
15104
|
+
return /* @__PURE__ */ jsx54("li", { children: result.details ? /* @__PURE__ */ jsxs47("details", { children: [
|
|
15105
|
+
/* @__PURE__ */ jsx54("summary", { children: title }),
|
|
15106
|
+
/* @__PURE__ */ jsx54("pre", { className: "mt-ai-evidence-code", children: result.details })
|
|
15107
|
+
] }) : /* @__PURE__ */ jsx54("div", { className: "mt-ai-test-row", children: title }) }, result.id);
|
|
14645
15108
|
}) })
|
|
14646
|
-
] }) : /* @__PURE__ */
|
|
15109
|
+
] }) : /* @__PURE__ */ jsx54("p", { className: "mt-ai-evidence-empty", children: text.noTests })
|
|
14647
15110
|
]
|
|
14648
15111
|
}
|
|
14649
15112
|
);
|
|
14650
15113
|
}
|
|
14651
15114
|
|
|
14652
15115
|
// src/check-card.tsx
|
|
14653
|
-
import * as
|
|
15116
|
+
import * as React55 from "react";
|
|
14654
15117
|
import { Check as Check8, LoaderCircle as LoaderCircle11 } from "lucide-react";
|
|
14655
|
-
import { jsx as
|
|
14656
|
-
var GroupContext =
|
|
15118
|
+
import { jsx as jsx55, jsxs as jsxs48 } from "react/jsx-runtime";
|
|
15119
|
+
var GroupContext = React55.createContext(null);
|
|
14657
15120
|
var contains = (selection, key) => typeof selection === "string" ? selection === key : selection?.includes(key) ?? false;
|
|
14658
15121
|
function CheckCardGroup(props) {
|
|
14659
15122
|
const {
|
|
@@ -14674,12 +15137,12 @@ function CheckCardGroup(props) {
|
|
|
14674
15137
|
className,
|
|
14675
15138
|
...attrs
|
|
14676
15139
|
} = props;
|
|
14677
|
-
const id =
|
|
15140
|
+
const id = React55.useId();
|
|
14678
15141
|
const groupDisabled = useFieldsetDisabled(disabled);
|
|
14679
|
-
const [initial] =
|
|
15142
|
+
const [initial] = React55.useState(
|
|
14680
15143
|
() => typeof defaultValue === "string" ? defaultValue : [...new Set(defaultValue ?? [])]
|
|
14681
15144
|
);
|
|
14682
|
-
const [local, setLocal] =
|
|
15145
|
+
const [local, setLocal] = React55.useState(initial);
|
|
14683
15146
|
const controlled = value !== void 0;
|
|
14684
15147
|
const selection = controlled ? value : local;
|
|
14685
15148
|
const state = {
|
|
@@ -14713,7 +15176,7 @@ function CheckCardGroup(props) {
|
|
|
14713
15176
|
return contains(controlled ? selection : initial, key);
|
|
14714
15177
|
}
|
|
14715
15178
|
};
|
|
14716
|
-
return /* @__PURE__ */
|
|
15179
|
+
return /* @__PURE__ */ jsx55(GroupContext.Provider, { value: state, children: /* @__PURE__ */ jsxs48(
|
|
14717
15180
|
"fieldset",
|
|
14718
15181
|
{
|
|
14719
15182
|
...attrs,
|
|
@@ -14723,8 +15186,8 @@ function CheckCardGroup(props) {
|
|
|
14723
15186
|
"aria-busy": loading || void 0,
|
|
14724
15187
|
className: cn("mt-check-card-group", className),
|
|
14725
15188
|
children: [
|
|
14726
|
-
legend != null && /* @__PURE__ */
|
|
14727
|
-
/* @__PURE__ */
|
|
15189
|
+
legend != null && /* @__PURE__ */ jsx55("legend", { className: "mt-check-card-legend", children: legend }),
|
|
15190
|
+
/* @__PURE__ */ jsx55("div", { className: "mt-check-card-group-items", children: children ?? options?.map((option) => /* @__PURE__ */ jsx55(CheckCardRoot, { ...option }, option.value)) })
|
|
14728
15191
|
]
|
|
14729
15192
|
}
|
|
14730
15193
|
) });
|
|
@@ -14754,12 +15217,12 @@ function CheckCardRoot({
|
|
|
14754
15217
|
"aria-describedby": describedBy,
|
|
14755
15218
|
...props
|
|
14756
15219
|
}) {
|
|
14757
|
-
const group =
|
|
14758
|
-
const generatedId =
|
|
15220
|
+
const group = React55.useContext(GroupContext);
|
|
15221
|
+
const generatedId = React55.useId();
|
|
14759
15222
|
const controlId = `${generatedId}-input`;
|
|
14760
15223
|
const titleId = `${generatedId}-title`;
|
|
14761
15224
|
const descriptionId = `${generatedId}-description`;
|
|
14762
|
-
const input =
|
|
15225
|
+
const input = React55.useRef(null);
|
|
14763
15226
|
const key = value ?? "on";
|
|
14764
15227
|
const currentChecked = group ? group.isChecked(key) : checked;
|
|
14765
15228
|
const formId = group ? group.form : form;
|
|
@@ -14770,13 +15233,13 @@ function CheckCardRoot({
|
|
|
14770
15233
|
const hasBorder = bordered ?? group?.bordered ?? true;
|
|
14771
15234
|
const descriptionIds = [description != null ? descriptionId : void 0, describedBy].filter(Boolean).join(" ") || void 0;
|
|
14772
15235
|
const hasStateOwner = group !== null || checked !== void 0;
|
|
14773
|
-
const latestResetValue =
|
|
15236
|
+
const latestResetValue = React55.useRef(
|
|
14774
15237
|
() => void 0
|
|
14775
15238
|
);
|
|
14776
|
-
|
|
15239
|
+
React55.useLayoutEffect(() => {
|
|
14777
15240
|
latestResetValue.current = () => group ? group.reset(key) : checked;
|
|
14778
15241
|
}, [group, key, checked]);
|
|
14779
|
-
|
|
15242
|
+
React55.useEffect(() => {
|
|
14780
15243
|
const element = input.current;
|
|
14781
15244
|
const owner = element?.form;
|
|
14782
15245
|
if (!element || !owner || !hasStateOwner) return;
|
|
@@ -14796,7 +15259,7 @@ function CheckCardRoot({
|
|
|
14796
15259
|
clearTimeout(timer);
|
|
14797
15260
|
};
|
|
14798
15261
|
}, [formId, hasStateOwner]);
|
|
14799
|
-
return /* @__PURE__ */
|
|
15262
|
+
return /* @__PURE__ */ jsxs48(
|
|
14800
15263
|
"div",
|
|
14801
15264
|
{
|
|
14802
15265
|
...props,
|
|
@@ -14806,7 +15269,7 @@ function CheckCardRoot({
|
|
|
14806
15269
|
"data-bordered": hasBorder,
|
|
14807
15270
|
"data-loading": loading || void 0,
|
|
14808
15271
|
children: [
|
|
14809
|
-
/* @__PURE__ */
|
|
15272
|
+
/* @__PURE__ */ jsx55(
|
|
14810
15273
|
"input",
|
|
14811
15274
|
{
|
|
14812
15275
|
ref: input,
|
|
@@ -14832,16 +15295,16 @@ function CheckCardRoot({
|
|
|
14832
15295
|
}
|
|
14833
15296
|
}
|
|
14834
15297
|
),
|
|
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__ */
|
|
15298
|
+
/* @__PURE__ */ jsxs48("label", { className: "mt-check-card-label", htmlFor: controlId, children: [
|
|
15299
|
+
cover != null && /* @__PURE__ */ jsx55("span", { className: "mt-check-card-cover", children: cover }),
|
|
15300
|
+
/* @__PURE__ */ jsxs48("span", { className: "mt-check-card-main", children: [
|
|
15301
|
+
avatar != null && /* @__PURE__ */ jsx55("span", { className: "mt-check-card-avatar", children: avatar }),
|
|
15302
|
+
/* @__PURE__ */ jsxs48("span", { className: "mt-check-card-text", children: [
|
|
15303
|
+
title != null && /* @__PURE__ */ jsx55("span", { id: titleId, className: "mt-check-card-title", children: title }),
|
|
15304
|
+
description != null && /* @__PURE__ */ jsx55("span", { id: descriptionId, className: "mt-check-card-description", children: description }),
|
|
15305
|
+
children != null && /* @__PURE__ */ jsx55("span", { className: "mt-check-card-content", children })
|
|
14843
15306
|
] }),
|
|
14844
|
-
/* @__PURE__ */
|
|
15307
|
+
/* @__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
15308
|
Check8,
|
|
14846
15309
|
{
|
|
14847
15310
|
className: "mt-check-card-check",
|
|
@@ -14851,7 +15314,7 @@ function CheckCardRoot({
|
|
|
14851
15314
|
) })
|
|
14852
15315
|
] })
|
|
14853
15316
|
] }),
|
|
14854
|
-
extra != null && /* @__PURE__ */
|
|
15317
|
+
extra != null && /* @__PURE__ */ jsx55("div", { className: "mt-check-card-extra", children: extra })
|
|
14855
15318
|
]
|
|
14856
15319
|
}
|
|
14857
15320
|
);
|
|
@@ -14859,6 +15322,368 @@ function CheckCardRoot({
|
|
|
14859
15322
|
var CheckCard = Object.assign(CheckCardRoot, {
|
|
14860
15323
|
Group: CheckCardGroup
|
|
14861
15324
|
});
|
|
15325
|
+
|
|
15326
|
+
// src/floating-window.tsx
|
|
15327
|
+
import * as React56 from "react";
|
|
15328
|
+
import { createPortal as createPortal2 } from "react-dom";
|
|
15329
|
+
import { GripHorizontal, Maximize2, Minus as Minus4, PanelTop, X as X16 } from "lucide-react";
|
|
15330
|
+
import { Fragment as Fragment30, jsx as jsx56, jsxs as jsxs49 } from "react/jsx-runtime";
|
|
15331
|
+
var inset = 12;
|
|
15332
|
+
var collapsedSize = 40;
|
|
15333
|
+
var clamp2 = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
15334
|
+
var finite2 = (value, fallback) => value !== void 0 && Number.isFinite(value) ? value : fallback;
|
|
15335
|
+
function readBounds() {
|
|
15336
|
+
const visual = window.visualViewport;
|
|
15337
|
+
const width = visual?.width || document.documentElement.clientWidth || window.innerWidth;
|
|
15338
|
+
const height = visual?.height || document.documentElement.clientHeight || window.innerHeight;
|
|
15339
|
+
const left = visual?.offsetLeft ?? 0;
|
|
15340
|
+
const top = visual?.offsetTop ?? 0;
|
|
15341
|
+
const inlineInset = Math.min(inset, width / 4);
|
|
15342
|
+
const blockInset = Math.min(inset, height / 4);
|
|
15343
|
+
return {
|
|
15344
|
+
left: left + inlineInset,
|
|
15345
|
+
top: top + blockInset,
|
|
15346
|
+
right: left + width - inlineInset,
|
|
15347
|
+
bottom: top + height - blockInset
|
|
15348
|
+
};
|
|
15349
|
+
}
|
|
15350
|
+
function readLimits(bounds, props) {
|
|
15351
|
+
const availableWidth = bounds.right - bounds.left;
|
|
15352
|
+
const availableHeight = bounds.bottom - bounds.top;
|
|
15353
|
+
const chromeWidth = Math.min(108, availableWidth);
|
|
15354
|
+
const chromeHeight = Math.min(56, availableHeight);
|
|
15355
|
+
const maxWidth = clamp2(finite2(props.maxWidth, Infinity), chromeWidth, availableWidth);
|
|
15356
|
+
const maxHeight = clamp2(finite2(props.maxHeight, Infinity), chromeHeight, availableHeight);
|
|
15357
|
+
return {
|
|
15358
|
+
maxWidth,
|
|
15359
|
+
maxHeight,
|
|
15360
|
+
minWidth: clamp2(finite2(props.minWidth, 220), chromeWidth, maxWidth),
|
|
15361
|
+
minHeight: clamp2(finite2(props.minHeight, 140), chromeHeight, maxHeight)
|
|
15362
|
+
};
|
|
15363
|
+
}
|
|
15364
|
+
function fitWindow(bounds, limits, position, size) {
|
|
15365
|
+
const width = clamp2(finite2(size?.width, 440), limits.minWidth, limits.maxWidth);
|
|
15366
|
+
const height = clamp2(finite2(size?.height, 320), limits.minHeight, limits.maxHeight);
|
|
15367
|
+
return {
|
|
15368
|
+
width,
|
|
15369
|
+
height,
|
|
15370
|
+
left: clamp2(finite2(position?.left, (bounds.left + bounds.right - width) / 2), bounds.left, bounds.right - width),
|
|
15371
|
+
top: clamp2(finite2(position?.top, (bounds.top + bounds.bottom - height) / 2), bounds.top, bounds.bottom - height)
|
|
15372
|
+
};
|
|
15373
|
+
}
|
|
15374
|
+
function updateGeometry(current, kind, x, y, bounds, limits) {
|
|
15375
|
+
if (kind === "move") {
|
|
15376
|
+
return fitWindow(bounds, limits, { left: current.left + x, top: current.top + y }, current);
|
|
15377
|
+
}
|
|
15378
|
+
const maxWidth = Math.min(limits.maxWidth, bounds.right - current.left);
|
|
15379
|
+
const maxHeight = Math.min(limits.maxHeight, bounds.bottom - current.top);
|
|
15380
|
+
return {
|
|
15381
|
+
...current,
|
|
15382
|
+
width: clamp2(current.width + x, Math.min(limits.minWidth, maxWidth), maxWidth),
|
|
15383
|
+
height: clamp2(current.height + y, Math.min(limits.minHeight, maxHeight), maxHeight)
|
|
15384
|
+
};
|
|
15385
|
+
}
|
|
15386
|
+
function assignRef(ref, node) {
|
|
15387
|
+
if (typeof ref === "function") return ref(node);
|
|
15388
|
+
if (ref) ref.current = node;
|
|
15389
|
+
}
|
|
15390
|
+
function FloatingWindow({
|
|
15391
|
+
title,
|
|
15392
|
+
children,
|
|
15393
|
+
trigger,
|
|
15394
|
+
open: controlledOpen,
|
|
15395
|
+
defaultOpen = false,
|
|
15396
|
+
onOpenChange,
|
|
15397
|
+
initialPosition,
|
|
15398
|
+
initialSize,
|
|
15399
|
+
minWidth,
|
|
15400
|
+
minHeight,
|
|
15401
|
+
maxWidth,
|
|
15402
|
+
maxHeight,
|
|
15403
|
+
draggable = true,
|
|
15404
|
+
resizable = true,
|
|
15405
|
+
minimizable = true,
|
|
15406
|
+
minimizedIcon,
|
|
15407
|
+
zIndex = 1150
|
|
15408
|
+
}) {
|
|
15409
|
+
const { locale } = useMtone();
|
|
15410
|
+
const zh = locale === "zh";
|
|
15411
|
+
const dialogId = React56.useId();
|
|
15412
|
+
const titleId = `${dialogId}-title`;
|
|
15413
|
+
const moveHelp = `${dialogId}-move`;
|
|
15414
|
+
const resizeHelp = `${dialogId}-resize`;
|
|
15415
|
+
const [localOpen, setOpen] = React56.useState(defaultOpen);
|
|
15416
|
+
const open = controlledOpen ?? localOpen;
|
|
15417
|
+
const [minimized, setMinimized] = React56.useState(false);
|
|
15418
|
+
const collapsed = minimizable && minimized;
|
|
15419
|
+
const [bounds, setBounds] = React56.useState();
|
|
15420
|
+
const [storedGeometry, setGeometry] = React56.useState();
|
|
15421
|
+
const initial = React56.useRef({ position: initialPosition, size: initialSize });
|
|
15422
|
+
const triggerRef = React56.useRef(null);
|
|
15423
|
+
const triggerElement = typeof trigger === "object" ? trigger : void 0;
|
|
15424
|
+
const externalTriggerRef = triggerElement?.props.ref;
|
|
15425
|
+
const captureTrigger = React56.useCallback((node) => {
|
|
15426
|
+
triggerRef.current = node;
|
|
15427
|
+
const cleanUp = assignRef(externalTriggerRef, node);
|
|
15428
|
+
if (cleanUp) return () => {
|
|
15429
|
+
triggerRef.current = null;
|
|
15430
|
+
cleanUp();
|
|
15431
|
+
};
|
|
15432
|
+
}, [externalTriggerRef]);
|
|
15433
|
+
const windowRef = React56.useRef(null);
|
|
15434
|
+
const restoreRef = React56.useRef(null);
|
|
15435
|
+
const pendingFocus = React56.useRef(void 0);
|
|
15436
|
+
const focusWithin = React56.useRef(false);
|
|
15437
|
+
const markFocused = () => {
|
|
15438
|
+
focusWithin.current = true;
|
|
15439
|
+
};
|
|
15440
|
+
const handleBlur = (event) => {
|
|
15441
|
+
const next = event.relatedTarget;
|
|
15442
|
+
if (next && !(windowRef.current?.contains(next) || restoreRef.current?.contains(next))) {
|
|
15443
|
+
focusWithin.current = false;
|
|
15444
|
+
if (pendingFocus.current === "trigger") pendingFocus.current = void 0;
|
|
15445
|
+
}
|
|
15446
|
+
};
|
|
15447
|
+
const gesture = React56.useRef(null);
|
|
15448
|
+
React56.useEffect(() => {
|
|
15449
|
+
if (!open) return;
|
|
15450
|
+
const refresh = () => {
|
|
15451
|
+
gesture.current = null;
|
|
15452
|
+
setBounds(readBounds());
|
|
15453
|
+
};
|
|
15454
|
+
refresh();
|
|
15455
|
+
const visual = window.visualViewport;
|
|
15456
|
+
window.addEventListener("resize", refresh);
|
|
15457
|
+
visual?.addEventListener("resize", refresh);
|
|
15458
|
+
visual?.addEventListener("scroll", refresh);
|
|
15459
|
+
return () => {
|
|
15460
|
+
window.removeEventListener("resize", refresh);
|
|
15461
|
+
visual?.removeEventListener("resize", refresh);
|
|
15462
|
+
visual?.removeEventListener("scroll", refresh);
|
|
15463
|
+
gesture.current = null;
|
|
15464
|
+
};
|
|
15465
|
+
}, [open]);
|
|
15466
|
+
React56.useEffect(() => {
|
|
15467
|
+
if (!open) {
|
|
15468
|
+
setMinimized(false);
|
|
15469
|
+
if (pendingFocus.current === "trigger" || focusWithin.current) {
|
|
15470
|
+
triggerRef.current?.focus({ preventScroll: true });
|
|
15471
|
+
}
|
|
15472
|
+
focusWithin.current = false;
|
|
15473
|
+
pendingFocus.current = void 0;
|
|
15474
|
+
return;
|
|
15475
|
+
}
|
|
15476
|
+
const target = pendingFocus.current === "window" && !collapsed ? windowRef.current : pendingFocus.current === "restore" && collapsed ? restoreRef.current : null;
|
|
15477
|
+
if (target) {
|
|
15478
|
+
pendingFocus.current = void 0;
|
|
15479
|
+
target.focus({ preventScroll: true });
|
|
15480
|
+
}
|
|
15481
|
+
}, [open, collapsed, bounds]);
|
|
15482
|
+
const limits = bounds && readLimits(bounds, { minWidth, minHeight, maxWidth, maxHeight });
|
|
15483
|
+
const geometry = bounds && limits && fitWindow(
|
|
15484
|
+
bounds,
|
|
15485
|
+
limits,
|
|
15486
|
+
storedGeometry ?? initial.current.position,
|
|
15487
|
+
storedGeometry ?? initial.current.size
|
|
15488
|
+
);
|
|
15489
|
+
const changeOpen = (next) => {
|
|
15490
|
+
if (controlledOpen === void 0) setOpen(next);
|
|
15491
|
+
onOpenChange?.(next);
|
|
15492
|
+
};
|
|
15493
|
+
const restore = () => {
|
|
15494
|
+
pendingFocus.current = "window";
|
|
15495
|
+
setMinimized(false);
|
|
15496
|
+
};
|
|
15497
|
+
const requestOpen = () => {
|
|
15498
|
+
if (!open) {
|
|
15499
|
+
pendingFocus.current = "window";
|
|
15500
|
+
changeOpen(true);
|
|
15501
|
+
} else if (collapsed) {
|
|
15502
|
+
restore();
|
|
15503
|
+
} else {
|
|
15504
|
+
windowRef.current?.focus({ preventScroll: true });
|
|
15505
|
+
}
|
|
15506
|
+
};
|
|
15507
|
+
const close = () => {
|
|
15508
|
+
pendingFocus.current = "trigger";
|
|
15509
|
+
changeOpen(false);
|
|
15510
|
+
};
|
|
15511
|
+
const minimize = () => {
|
|
15512
|
+
gesture.current = null;
|
|
15513
|
+
pendingFocus.current = "restore";
|
|
15514
|
+
setMinimized(true);
|
|
15515
|
+
};
|
|
15516
|
+
function pointerDown(kind, event) {
|
|
15517
|
+
if (!geometry || gesture.current || event.button !== 0 || event.defaultPrevented) return;
|
|
15518
|
+
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;
|
|
15519
|
+
gesture.current = { id: event.pointerId, kind, x: event.clientX, y: event.clientY, geometry };
|
|
15520
|
+
event.preventDefault();
|
|
15521
|
+
try {
|
|
15522
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
15523
|
+
} catch {
|
|
15524
|
+
}
|
|
15525
|
+
}
|
|
15526
|
+
function pointerMove(event) {
|
|
15527
|
+
const start = gesture.current;
|
|
15528
|
+
if (!start || !bounds || !limits || start.id !== event.pointerId) return;
|
|
15529
|
+
setGeometry(updateGeometry(start.geometry, start.kind, event.clientX - start.x, event.clientY - start.y, bounds, limits));
|
|
15530
|
+
}
|
|
15531
|
+
function pointerEnd(event) {
|
|
15532
|
+
if (gesture.current?.id === event.pointerId) gesture.current = null;
|
|
15533
|
+
}
|
|
15534
|
+
function keyDown(kind, event) {
|
|
15535
|
+
if (!geometry || !bounds || !limits || event.altKey || event.ctrlKey || event.metaKey) return;
|
|
15536
|
+
const step = event.shiftKey ? 24 : 8;
|
|
15537
|
+
const x = event.key === "ArrowLeft" ? -step : event.key === "ArrowRight" ? step : 0;
|
|
15538
|
+
const y = event.key === "ArrowUp" ? -step : event.key === "ArrowDown" ? step : 0;
|
|
15539
|
+
if (!x && !y) return;
|
|
15540
|
+
event.preventDefault();
|
|
15541
|
+
event.stopPropagation();
|
|
15542
|
+
setGeometry(updateGeometry(geometry, kind, x, y, bounds, limits));
|
|
15543
|
+
}
|
|
15544
|
+
const pointerEvents = {
|
|
15545
|
+
onPointerMove: pointerMove,
|
|
15546
|
+
onPointerUp: pointerEnd,
|
|
15547
|
+
onPointerCancel: pointerEnd,
|
|
15548
|
+
onLostPointerCapture: pointerEnd
|
|
15549
|
+
};
|
|
15550
|
+
let opener = null;
|
|
15551
|
+
if (typeof trigger === "string") {
|
|
15552
|
+
opener = /* @__PURE__ */ jsx56(
|
|
15553
|
+
Button,
|
|
15554
|
+
{
|
|
15555
|
+
type: "button",
|
|
15556
|
+
ref: triggerRef,
|
|
15557
|
+
"aria-haspopup": "dialog",
|
|
15558
|
+
"aria-expanded": open && !collapsed,
|
|
15559
|
+
"aria-controls": open ? dialogId : void 0,
|
|
15560
|
+
onClick: requestOpen,
|
|
15561
|
+
children: trigger
|
|
15562
|
+
}
|
|
15563
|
+
);
|
|
15564
|
+
} else if (triggerElement) {
|
|
15565
|
+
opener = React56.cloneElement(triggerElement, {
|
|
15566
|
+
...triggerElement.type === "button" && triggerElement.props.type === void 0 ? { type: "button" } : {},
|
|
15567
|
+
ref: captureTrigger,
|
|
15568
|
+
"aria-haspopup": "dialog",
|
|
15569
|
+
"aria-expanded": open && !collapsed,
|
|
15570
|
+
"aria-controls": open ? dialogId : void 0,
|
|
15571
|
+
onClick(event) {
|
|
15572
|
+
triggerElement.props.onClick?.(event);
|
|
15573
|
+
if (!event.defaultPrevented) {
|
|
15574
|
+
triggerRef.current = event.currentTarget;
|
|
15575
|
+
requestOpen();
|
|
15576
|
+
}
|
|
15577
|
+
}
|
|
15578
|
+
});
|
|
15579
|
+
}
|
|
15580
|
+
const content2 = open && geometry && bounds && createPortal2(
|
|
15581
|
+
/* @__PURE__ */ jsxs49(MtoneScope, { className: "mt-floating-window-scope", children: [
|
|
15582
|
+
/* @__PURE__ */ jsx56(React56.Activity, { mode: collapsed ? "hidden" : "visible", children: /* @__PURE__ */ jsxs49(
|
|
15583
|
+
"section",
|
|
15584
|
+
{
|
|
15585
|
+
ref: windowRef,
|
|
15586
|
+
id: dialogId,
|
|
15587
|
+
role: "dialog",
|
|
15588
|
+
"aria-modal": "false",
|
|
15589
|
+
"aria-labelledby": titleId,
|
|
15590
|
+
tabIndex: -1,
|
|
15591
|
+
onFocusCapture: markFocused,
|
|
15592
|
+
onBlurCapture: handleBlur,
|
|
15593
|
+
className: "mt-floating-window",
|
|
15594
|
+
style: { ...geometry, zIndex },
|
|
15595
|
+
children: [
|
|
15596
|
+
/* @__PURE__ */ jsxs49("header", { className: "mt-floating-window-header", children: [
|
|
15597
|
+
/* @__PURE__ */ jsxs49(
|
|
15598
|
+
"div",
|
|
15599
|
+
{
|
|
15600
|
+
className: "mt-floating-window-caption",
|
|
15601
|
+
"data-draggable": draggable || void 0,
|
|
15602
|
+
...draggable ? { ...pointerEvents, onPointerDown: (event) => pointerDown("move", event) } : {},
|
|
15603
|
+
children: [
|
|
15604
|
+
draggable && /* @__PURE__ */ jsx56(
|
|
15605
|
+
Button,
|
|
15606
|
+
{
|
|
15607
|
+
type: "button",
|
|
15608
|
+
variant: "ghost",
|
|
15609
|
+
size: "sm",
|
|
15610
|
+
iconOnly: true,
|
|
15611
|
+
className: "mt-floating-window-move",
|
|
15612
|
+
"aria-label": zh ? "\u79FB\u52A8\u7A97\u53E3" : "Move window",
|
|
15613
|
+
"aria-describedby": moveHelp,
|
|
15614
|
+
onKeyDown: (event) => keyDown("move", event),
|
|
15615
|
+
children: /* @__PURE__ */ jsx56(GripHorizontal, { size: 15, "aria-hidden": "true" })
|
|
15616
|
+
}
|
|
15617
|
+
),
|
|
15618
|
+
/* @__PURE__ */ jsx56("h2", { id: titleId, className: "mt-floating-window-title", children: title })
|
|
15619
|
+
]
|
|
15620
|
+
}
|
|
15621
|
+
),
|
|
15622
|
+
/* @__PURE__ */ jsxs49("div", { className: "mt-floating-window-actions", children: [
|
|
15623
|
+
minimizable && /* @__PURE__ */ jsx56(
|
|
15624
|
+
Button,
|
|
15625
|
+
{
|
|
15626
|
+
type: "button",
|
|
15627
|
+
variant: "ghost",
|
|
15628
|
+
size: "sm",
|
|
15629
|
+
iconOnly: true,
|
|
15630
|
+
"aria-label": zh ? "\u6700\u5C0F\u5316\u7A97\u53E3" : "Minimize window",
|
|
15631
|
+
onClick: minimize,
|
|
15632
|
+
children: /* @__PURE__ */ jsx56(Minus4, { size: 15, "aria-hidden": "true" })
|
|
15633
|
+
}
|
|
15634
|
+
),
|
|
15635
|
+
/* @__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" }) })
|
|
15636
|
+
] })
|
|
15637
|
+
] }),
|
|
15638
|
+
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." }),
|
|
15639
|
+
/* @__PURE__ */ jsx56("div", { className: "mt-floating-window-content", children }),
|
|
15640
|
+
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." }),
|
|
15641
|
+
resizable && /* @__PURE__ */ jsx56(
|
|
15642
|
+
"button",
|
|
15643
|
+
{
|
|
15644
|
+
type: "button",
|
|
15645
|
+
className: "mt-floating-window-resize",
|
|
15646
|
+
"aria-label": zh ? "\u8C03\u6574\u7A97\u53E3\u5927\u5C0F" : "Resize window",
|
|
15647
|
+
"aria-describedby": resizeHelp,
|
|
15648
|
+
...pointerEvents,
|
|
15649
|
+
onPointerDown: (event) => pointerDown("resize", event),
|
|
15650
|
+
onKeyDown: (event) => keyDown("resize", event),
|
|
15651
|
+
children: /* @__PURE__ */ jsx56(Maximize2, { size: 13, "aria-hidden": "true" })
|
|
15652
|
+
}
|
|
15653
|
+
)
|
|
15654
|
+
]
|
|
15655
|
+
}
|
|
15656
|
+
) }),
|
|
15657
|
+
collapsed && /* @__PURE__ */ jsx56(
|
|
15658
|
+
Button,
|
|
15659
|
+
{
|
|
15660
|
+
type: "button",
|
|
15661
|
+
ref: restoreRef,
|
|
15662
|
+
variant: "outline",
|
|
15663
|
+
iconOnly: true,
|
|
15664
|
+
className: "mt-floating-window-restore",
|
|
15665
|
+
"aria-label": zh ? "\u6062\u590D\u7A97\u53E3" : "Restore window",
|
|
15666
|
+
onClick: restore,
|
|
15667
|
+
onFocus: markFocused,
|
|
15668
|
+
onBlur: handleBlur,
|
|
15669
|
+
style: {
|
|
15670
|
+
left: Math.max(bounds.left, bounds.right - collapsedSize),
|
|
15671
|
+
top: Math.max(bounds.top, bounds.bottom - collapsedSize),
|
|
15672
|
+
width: Math.min(collapsedSize, bounds.right - bounds.left),
|
|
15673
|
+
height: Math.min(collapsedSize, bounds.bottom - bounds.top),
|
|
15674
|
+
zIndex
|
|
15675
|
+
},
|
|
15676
|
+
children: /* @__PURE__ */ jsx56("span", { "aria-hidden": "true", children: minimizedIcon ?? /* @__PURE__ */ jsx56(PanelTop, { size: 18 }) })
|
|
15677
|
+
}
|
|
15678
|
+
)
|
|
15679
|
+
] }),
|
|
15680
|
+
document.body
|
|
15681
|
+
);
|
|
15682
|
+
return /* @__PURE__ */ jsxs49(Fragment30, { children: [
|
|
15683
|
+
opener,
|
|
15684
|
+
content2
|
|
15685
|
+
] });
|
|
15686
|
+
}
|
|
14862
15687
|
export {
|
|
14863
15688
|
AdminLayout,
|
|
14864
15689
|
Affix,
|
|
@@ -14908,6 +15733,7 @@ export {
|
|
|
14908
15733
|
Drawer,
|
|
14909
15734
|
Empty,
|
|
14910
15735
|
Fieldset,
|
|
15736
|
+
FloatingWindow,
|
|
14911
15737
|
Form,
|
|
14912
15738
|
GlobalNotice,
|
|
14913
15739
|
HoverCard,
|
|
@@ -14924,7 +15750,6 @@ export {
|
|
|
14924
15750
|
Menubar,
|
|
14925
15751
|
MtoneProvider,
|
|
14926
15752
|
MtoneScope,
|
|
14927
|
-
MultiSelect,
|
|
14928
15753
|
NavGroup,
|
|
14929
15754
|
NavItem,
|
|
14930
15755
|
NavSubmenu,
|
|
@@ -14960,6 +15785,7 @@ export {
|
|
|
14960
15785
|
Timeline,
|
|
14961
15786
|
Title,
|
|
14962
15787
|
ToastProvider,
|
|
15788
|
+
Toolbar,
|
|
14963
15789
|
Tooltip,
|
|
14964
15790
|
Transfer,
|
|
14965
15791
|
Tree,
|