@gnwebsoft/ui 2.18.44 → 2.18.46
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-BBDVHJQ3.js → chunk-22MN4IPU.js} +388 -73
- package/dist/{chunk-MM6OQZAY.mjs → chunk-5HOGPCEO.mjs} +1 -1
- package/dist/{chunk-IZSKZD5M.js → chunk-6NOXJGU2.js} +3 -3
- package/dist/{chunk-3LU2Q6FI.mjs → chunk-F6RJXISB.mjs} +401 -86
- package/dist/{chunk-FYN7F5WJ.js → chunk-I7EIUZKK.js} +1 -1
- package/dist/{chunk-GAYZ4QSD.mjs → chunk-RQS44YC7.mjs} +1 -1
- package/dist/index.js +4 -4
- package/dist/index.mjs +5 -5
- package/dist/utils/index.d.mts +2 -2
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +2 -2
- package/dist/utils/index.mjs +1 -1
- package/dist/wrappers/index.d.mts +30 -8
- package/dist/wrappers/index.d.ts +30 -8
- package/dist/wrappers/index.js +3 -3
- package/dist/wrappers/index.mjs +2 -2
- package/dist/wrappers2/index.js +3 -3
- package/dist/wrappers2/index.mjs +2 -2
- package/package.json +1 -1
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
} from "./chunk-GFSTK7KN.mjs";
|
|
4
4
|
import {
|
|
5
5
|
readValueAsDate
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-RQS44YC7.mjs";
|
|
7
7
|
|
|
8
8
|
// src/wrappers/DatePickerElement/DatePickerElement.tsx
|
|
9
9
|
import { useCallback } from "react";
|
|
10
10
|
import { useController } from "react-hook-form";
|
|
11
11
|
import { DatePicker } from "@mui/x-date-pickers";
|
|
12
|
-
import { Grid2, useForkRef } from "@mui/material";
|
|
12
|
+
import { Grid2, useForkRef, useTheme } from "@mui/material";
|
|
13
13
|
import { useLocalizationContext } from "@mui/x-date-pickers/internals";
|
|
14
14
|
import { jsx } from "react/jsx-runtime";
|
|
15
15
|
function readValueAsDate2(adapter, value) {
|
|
@@ -54,6 +54,7 @@ var Component = function DatePickerElement(props) {
|
|
|
54
54
|
...rest
|
|
55
55
|
} = props;
|
|
56
56
|
const adapter = useLocalizationContext();
|
|
57
|
+
const theme = useTheme();
|
|
57
58
|
const { disabled, inputRef, onClose, ...restDatePickerProps } = datePickerProps;
|
|
58
59
|
const {
|
|
59
60
|
field,
|
|
@@ -98,7 +99,16 @@ var Component = function DatePickerElement(props) {
|
|
|
98
99
|
datePickerProps.onChange(newValue, context);
|
|
99
100
|
}
|
|
100
101
|
},
|
|
101
|
-
sx
|
|
102
|
+
sx: {
|
|
103
|
+
"& .MuiOutlinedInput-root": {
|
|
104
|
+
bgcolor: disabled ? theme.palette.action.disabledBackground : "transparent"
|
|
105
|
+
},
|
|
106
|
+
"& .MuiInputLabel-asterisk": { color: "red" },
|
|
107
|
+
"& .MuiInputBase-input": {
|
|
108
|
+
cursor: disabled ? "not-allowed" : "default"
|
|
109
|
+
},
|
|
110
|
+
...sx
|
|
111
|
+
},
|
|
102
112
|
slotProps: {
|
|
103
113
|
...slotProps,
|
|
104
114
|
actionBar: {
|
|
@@ -127,11 +137,17 @@ var Component = function DatePickerElement(props) {
|
|
|
127
137
|
);
|
|
128
138
|
};
|
|
129
139
|
var DatePickerElement2 = ({
|
|
130
|
-
gridProps,
|
|
140
|
+
gridProps = { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } },
|
|
131
141
|
...props
|
|
132
142
|
}) => {
|
|
133
143
|
if (gridProps) {
|
|
134
|
-
return /* @__PURE__ */ jsx(
|
|
144
|
+
return /* @__PURE__ */ jsx(
|
|
145
|
+
Grid2,
|
|
146
|
+
{
|
|
147
|
+
...{ size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }, ...gridProps },
|
|
148
|
+
children: /* @__PURE__ */ jsx(Component, { ...props })
|
|
149
|
+
}
|
|
150
|
+
);
|
|
135
151
|
}
|
|
136
152
|
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
137
153
|
};
|
|
@@ -225,11 +241,17 @@ var Component2 = function PasswordEl(props) {
|
|
|
225
241
|
);
|
|
226
242
|
};
|
|
227
243
|
var PasswordElement = ({
|
|
228
|
-
gridProps,
|
|
244
|
+
gridProps = { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } },
|
|
229
245
|
...props
|
|
230
246
|
}) => {
|
|
231
247
|
if (gridProps) {
|
|
232
|
-
return /* @__PURE__ */ jsx2(
|
|
248
|
+
return /* @__PURE__ */ jsx2(
|
|
249
|
+
Grid22,
|
|
250
|
+
{
|
|
251
|
+
...{ size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }, ...gridProps },
|
|
252
|
+
children: /* @__PURE__ */ jsx2(Component2, { ...props })
|
|
253
|
+
}
|
|
254
|
+
);
|
|
233
255
|
}
|
|
234
256
|
return /* @__PURE__ */ jsx2(Component2, { ...props });
|
|
235
257
|
};
|
|
@@ -247,7 +269,7 @@ import {
|
|
|
247
269
|
FormLabel,
|
|
248
270
|
Radio,
|
|
249
271
|
RadioGroup,
|
|
250
|
-
useTheme,
|
|
272
|
+
useTheme as useTheme2,
|
|
251
273
|
Grid2 as Grid23
|
|
252
274
|
} from "@mui/material";
|
|
253
275
|
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
@@ -276,7 +298,7 @@ var Component3 = function RadioButtonGroup(props) {
|
|
|
276
298
|
rules = {},
|
|
277
299
|
...rest
|
|
278
300
|
} = props;
|
|
279
|
-
const theme =
|
|
301
|
+
const theme = useTheme2();
|
|
280
302
|
const {
|
|
281
303
|
field,
|
|
282
304
|
fieldState: { error }
|
|
@@ -368,11 +390,17 @@ var Component3 = function RadioButtonGroup(props) {
|
|
|
368
390
|
] });
|
|
369
391
|
};
|
|
370
392
|
var RadioButtonGroup2 = ({
|
|
371
|
-
gridProps,
|
|
393
|
+
gridProps = { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } },
|
|
372
394
|
...props
|
|
373
395
|
}) => {
|
|
374
396
|
if (gridProps) {
|
|
375
|
-
return /* @__PURE__ */ jsx3(
|
|
397
|
+
return /* @__PURE__ */ jsx3(
|
|
398
|
+
Grid23,
|
|
399
|
+
{
|
|
400
|
+
...{ size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }, ...gridProps },
|
|
401
|
+
children: /* @__PURE__ */ jsx3(Component3, { ...props })
|
|
402
|
+
}
|
|
403
|
+
);
|
|
376
404
|
}
|
|
377
405
|
return /* @__PURE__ */ jsx3(Component3, { ...props });
|
|
378
406
|
};
|
|
@@ -384,7 +412,7 @@ import {
|
|
|
384
412
|
Grid2 as Grid24,
|
|
385
413
|
TextField as TextField2,
|
|
386
414
|
useForkRef as useForkRef3,
|
|
387
|
-
useTheme as
|
|
415
|
+
useTheme as useTheme3
|
|
388
416
|
} from "@mui/material";
|
|
389
417
|
import {
|
|
390
418
|
useController as useController4
|
|
@@ -422,7 +450,7 @@ var Component4 = function TextFieldElement(props) {
|
|
|
422
450
|
name,
|
|
423
451
|
control
|
|
424
452
|
});
|
|
425
|
-
const theme =
|
|
453
|
+
const theme = useTheme3();
|
|
426
454
|
const { value, onChange } = useTransform({
|
|
427
455
|
value: field.value,
|
|
428
456
|
onChange: field.onChange,
|
|
@@ -488,11 +516,17 @@ var Component4 = function TextFieldElement(props) {
|
|
|
488
516
|
);
|
|
489
517
|
};
|
|
490
518
|
var TextFieldElement2 = ({
|
|
491
|
-
gridProps,
|
|
519
|
+
gridProps = { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } },
|
|
492
520
|
...props
|
|
493
521
|
}) => {
|
|
494
522
|
if (gridProps) {
|
|
495
|
-
return /* @__PURE__ */ jsx4(
|
|
523
|
+
return /* @__PURE__ */ jsx4(
|
|
524
|
+
Grid24,
|
|
525
|
+
{
|
|
526
|
+
...{ size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }, ...gridProps },
|
|
527
|
+
children: /* @__PURE__ */ jsx4(Component4, { ...props })
|
|
528
|
+
}
|
|
529
|
+
);
|
|
496
530
|
}
|
|
497
531
|
return /* @__PURE__ */ jsx4(Component4, { ...props });
|
|
498
532
|
};
|
|
@@ -579,11 +613,17 @@ var Component5 = function TimePickerElement(props) {
|
|
|
579
613
|
);
|
|
580
614
|
};
|
|
581
615
|
var TimePickerElement2 = ({
|
|
582
|
-
gridProps,
|
|
616
|
+
gridProps = { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } },
|
|
583
617
|
...props
|
|
584
618
|
}) => {
|
|
585
619
|
if (gridProps) {
|
|
586
|
-
return /* @__PURE__ */ jsx5(
|
|
620
|
+
return /* @__PURE__ */ jsx5(
|
|
621
|
+
Grid25,
|
|
622
|
+
{
|
|
623
|
+
...{ size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }, ...gridProps },
|
|
624
|
+
children: /* @__PURE__ */ jsx5(Component5, { ...props })
|
|
625
|
+
}
|
|
626
|
+
);
|
|
587
627
|
}
|
|
588
628
|
return /* @__PURE__ */ jsx5(Component5, { ...props });
|
|
589
629
|
};
|
|
@@ -593,11 +633,18 @@ var TimePickerElement_default = TimePickerElement2;
|
|
|
593
633
|
// src/wrappers/AsyncSelect/AsyncSelectElement.tsx
|
|
594
634
|
import * as React from "react";
|
|
595
635
|
import { useController as useController6 } from "react-hook-form";
|
|
596
|
-
import {
|
|
636
|
+
import {
|
|
637
|
+
useRef,
|
|
638
|
+
useMemo,
|
|
639
|
+
Fragment,
|
|
640
|
+
useState as useState2,
|
|
641
|
+
useEffect as useEffect2,
|
|
642
|
+
useCallback as useCallback2
|
|
643
|
+
} from "react";
|
|
597
644
|
import { debounce } from "@mui/material/utils";
|
|
598
645
|
import TextField3 from "@mui/material/TextField";
|
|
599
646
|
import Autocomplete from "@mui/material/Autocomplete";
|
|
600
|
-
import { Grid2 as Grid26, useTheme as
|
|
647
|
+
import { Grid2 as Grid26, useTheme as useTheme4, CircularProgress } from "@mui/material";
|
|
601
648
|
import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
602
649
|
var Component6 = function AsyncSelectElement(props) {
|
|
603
650
|
const {
|
|
@@ -623,21 +670,27 @@ var Component6 = function AsyncSelectElement(props) {
|
|
|
623
670
|
name,
|
|
624
671
|
control
|
|
625
672
|
});
|
|
626
|
-
const theme =
|
|
673
|
+
const theme = useTheme4();
|
|
627
674
|
const [loading, setLoading] = useState2(false);
|
|
628
675
|
const [selectedOption, setSelectedOption] = useState2(null);
|
|
629
676
|
const [inputValue, setInputValue] = useState2("");
|
|
630
677
|
const inputValue2 = useMemo(() => inputValue, [inputValue]);
|
|
631
|
-
const setInputValue2 = useCallback2(
|
|
678
|
+
const setInputValue2 = useCallback2(
|
|
679
|
+
(newValue) => setInputValue(newValue),
|
|
680
|
+
[]
|
|
681
|
+
);
|
|
632
682
|
const [options, setOptions] = useState2([]);
|
|
633
683
|
const initialValueLoaded = useRef(
|
|
634
684
|
!initialValue ? true : !(initialValue != null)
|
|
635
685
|
);
|
|
636
686
|
const fieldValue = useRef(field.value);
|
|
637
687
|
const fetchData = useMemo(
|
|
638
|
-
() => debounce(
|
|
639
|
-
|
|
640
|
-
|
|
688
|
+
() => debounce(
|
|
689
|
+
(payload, callback) => {
|
|
690
|
+
queryFn(payload).then((c) => callback(c));
|
|
691
|
+
},
|
|
692
|
+
400
|
|
693
|
+
),
|
|
641
694
|
[]
|
|
642
695
|
);
|
|
643
696
|
const fillOptions = (results) => {
|
|
@@ -790,11 +843,17 @@ var Component6 = function AsyncSelectElement(props) {
|
|
|
790
843
|
);
|
|
791
844
|
};
|
|
792
845
|
var AsyncSelectElement2 = ({
|
|
793
|
-
gridProps,
|
|
846
|
+
gridProps = { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } },
|
|
794
847
|
...props
|
|
795
848
|
}) => {
|
|
796
849
|
if (gridProps) {
|
|
797
|
-
return /* @__PURE__ */ jsx6(
|
|
850
|
+
return /* @__PURE__ */ jsx6(
|
|
851
|
+
Grid26,
|
|
852
|
+
{
|
|
853
|
+
...{ size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }, ...gridProps },
|
|
854
|
+
children: /* @__PURE__ */ jsx6(Component6, { ...props })
|
|
855
|
+
}
|
|
856
|
+
);
|
|
798
857
|
}
|
|
799
858
|
return /* @__PURE__ */ jsx6(Component6, { ...props });
|
|
800
859
|
};
|
|
@@ -817,7 +876,7 @@ import {
|
|
|
817
876
|
CircularProgress as CircularProgress2,
|
|
818
877
|
Grid2 as Grid27,
|
|
819
878
|
TextField as TextField4,
|
|
820
|
-
useTheme as
|
|
879
|
+
useTheme as useTheme5
|
|
821
880
|
} from "@mui/material";
|
|
822
881
|
import { useController as useController7 } from "react-hook-form";
|
|
823
882
|
import match from "autosuggest-highlight/match";
|
|
@@ -845,7 +904,7 @@ var Component7 = function AsyncSelectMultiElement(props) {
|
|
|
845
904
|
name,
|
|
846
905
|
control
|
|
847
906
|
});
|
|
848
|
-
const theme =
|
|
907
|
+
const theme = useTheme5();
|
|
849
908
|
const multiSelectRef = useRef2(null);
|
|
850
909
|
const [selectedOptions, setSelectedOptions] = useState3([]);
|
|
851
910
|
const [inputValue, setInputValue] = useState3("");
|
|
@@ -1024,7 +1083,7 @@ import {
|
|
|
1024
1083
|
import {
|
|
1025
1084
|
useController as useController8
|
|
1026
1085
|
} from "react-hook-form";
|
|
1027
|
-
import { Grid2 as Grid28, useTheme as
|
|
1086
|
+
import { Grid2 as Grid28, useTheme as useTheme6, TextField as TextField5, Autocomplete as Autocomplete3 } from "@mui/material";
|
|
1028
1087
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1029
1088
|
var Component8 = function SelectElement(props) {
|
|
1030
1089
|
const {
|
|
@@ -1037,6 +1096,7 @@ var Component8 = function SelectElement(props) {
|
|
|
1037
1096
|
sx,
|
|
1038
1097
|
variant,
|
|
1039
1098
|
disabled,
|
|
1099
|
+
initialValue,
|
|
1040
1100
|
labelKey = "Label",
|
|
1041
1101
|
valueKey = "Value",
|
|
1042
1102
|
placeholder,
|
|
@@ -1049,9 +1109,10 @@ var Component8 = function SelectElement(props) {
|
|
|
1049
1109
|
fieldState: { error }
|
|
1050
1110
|
} = useController8({
|
|
1051
1111
|
name,
|
|
1052
|
-
control
|
|
1112
|
+
control,
|
|
1113
|
+
defaultValue: initialValue
|
|
1053
1114
|
});
|
|
1054
|
-
const theme =
|
|
1115
|
+
const theme = useTheme6();
|
|
1055
1116
|
const getOptionValue = useCallback4(
|
|
1056
1117
|
(option) => {
|
|
1057
1118
|
if (typeof option === "string") return option;
|
|
@@ -1072,16 +1133,20 @@ var Component8 = function SelectElement(props) {
|
|
|
1072
1133
|
onChange?.(event, newValue, reason);
|
|
1073
1134
|
};
|
|
1074
1135
|
useEffect4(() => {
|
|
1075
|
-
if (!isEdit && options.length === 1 && (field.value == null || field.value
|
|
1136
|
+
if (!isEdit && options.length === 1 && (field.value == null || field.value === "")) {
|
|
1076
1137
|
const defaultOption = options[0];
|
|
1077
|
-
|
|
1078
|
-
field.onChange(defaultValue);
|
|
1138
|
+
field.onChange(getOptionValue(defaultOption));
|
|
1079
1139
|
}
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1140
|
+
if (isEdit) {
|
|
1141
|
+
if (field.value == null || field.value === "") {
|
|
1142
|
+
return;
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
}, [isEdit, options, field.value, getOptionValue, field.onChange]);
|
|
1146
|
+
const autocompleteValue = useMemo3(() => {
|
|
1147
|
+
if (!field.value) return null;
|
|
1148
|
+
return options.find((option) => getOptionValue(option) === field.value) ?? null;
|
|
1149
|
+
}, [field.value, options, getOptionValue]);
|
|
1085
1150
|
return /* @__PURE__ */ jsx8(
|
|
1086
1151
|
Autocomplete3,
|
|
1087
1152
|
{
|
|
@@ -1141,9 +1206,16 @@ var SelectElement_default = SelectElement2;
|
|
|
1141
1206
|
// src/wrappers/SelectMultiElement/SelectMultiElement.tsx
|
|
1142
1207
|
import { Fragment as Fragment3 } from "react";
|
|
1143
1208
|
import { useController as useController9 } from "react-hook-form";
|
|
1209
|
+
import Chip from "@mui/material/Chip";
|
|
1144
1210
|
import CheckBoxIcon from "@mui/icons-material/CheckBox";
|
|
1145
1211
|
import CheckBoxOutlineBlankIcon from "@mui/icons-material/CheckBoxOutlineBlank";
|
|
1146
|
-
import {
|
|
1212
|
+
import {
|
|
1213
|
+
Grid2 as Grid29,
|
|
1214
|
+
Checkbox,
|
|
1215
|
+
TextField as TextField6,
|
|
1216
|
+
Autocomplete as Autocomplete4,
|
|
1217
|
+
CircularProgress as CircularProgress3
|
|
1218
|
+
} from "@mui/material";
|
|
1147
1219
|
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1148
1220
|
var Component9 = function SelectMultiElement(props) {
|
|
1149
1221
|
const {
|
|
@@ -1159,6 +1231,7 @@ var Component9 = function SelectMultiElement(props) {
|
|
|
1159
1231
|
sx,
|
|
1160
1232
|
labelKey = "Label",
|
|
1161
1233
|
valueKey = "Value",
|
|
1234
|
+
multiple = true,
|
|
1162
1235
|
...rest
|
|
1163
1236
|
} = props;
|
|
1164
1237
|
const {
|
|
@@ -1176,13 +1249,19 @@ var Component9 = function SelectMultiElement(props) {
|
|
|
1176
1249
|
if (typeof option === "string") return option;
|
|
1177
1250
|
return option ? option[labelKey] : "";
|
|
1178
1251
|
};
|
|
1179
|
-
const selectedValue =
|
|
1180
|
-
const handleChange = (_2,
|
|
1181
|
-
if (
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1252
|
+
const selectedValue = multiple ? Array.isArray(field.value) ? options.filter((option) => field.value.includes(getOptionValue(option))) : [] : options.find((option) => getOptionValue(option) === field.value) ?? null;
|
|
1253
|
+
const handleChange = (_2, selected, reason) => {
|
|
1254
|
+
if (multiple) {
|
|
1255
|
+
if (reason === "clear") {
|
|
1256
|
+
field.onChange([]);
|
|
1257
|
+
} else {
|
|
1258
|
+
const newValues = selected.map(
|
|
1259
|
+
(option) => getOptionValue(option)
|
|
1260
|
+
);
|
|
1261
|
+
field.onChange(newValues);
|
|
1262
|
+
}
|
|
1263
|
+
} else {
|
|
1264
|
+
field.onChange(selected ? getOptionValue(selected) : null);
|
|
1186
1265
|
}
|
|
1187
1266
|
};
|
|
1188
1267
|
const icon = /* @__PURE__ */ jsx9(CheckBoxOutlineBlankIcon, { fontSize: "small" });
|
|
@@ -1190,14 +1269,14 @@ var Component9 = function SelectMultiElement(props) {
|
|
|
1190
1269
|
return /* @__PURE__ */ jsx9(
|
|
1191
1270
|
Autocomplete4,
|
|
1192
1271
|
{
|
|
1193
|
-
multiple
|
|
1272
|
+
multiple,
|
|
1194
1273
|
value: selectedValue,
|
|
1195
1274
|
loading,
|
|
1196
1275
|
options,
|
|
1197
|
-
getOptionLabel,
|
|
1276
|
+
getOptionLabel: (option) => getOptionLabel(option),
|
|
1198
1277
|
isOptionEqualToValue: (option, value) => getOptionValue(option) === getOptionValue(value),
|
|
1199
|
-
filterSelectedOptions:
|
|
1200
|
-
disableCloseOnSelect:
|
|
1278
|
+
filterSelectedOptions: multiple,
|
|
1279
|
+
disableCloseOnSelect: multiple,
|
|
1201
1280
|
ref: field.ref,
|
|
1202
1281
|
disabled: disabled ?? field.disabled,
|
|
1203
1282
|
onChange: handleChange,
|
|
@@ -1208,13 +1287,26 @@ var Component9 = function SelectMultiElement(props) {
|
|
|
1208
1287
|
}
|
|
1209
1288
|
},
|
|
1210
1289
|
fullWidth: true,
|
|
1211
|
-
renderOption: (props1, option, { selected }) => {
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1290
|
+
renderOption: (props1, option, { selected }) => multiple ? /* @__PURE__ */ jsxs4("li", { ...props1, children: [
|
|
1291
|
+
/* @__PURE__ */ jsx9(
|
|
1292
|
+
Checkbox,
|
|
1293
|
+
{
|
|
1294
|
+
icon,
|
|
1295
|
+
checkedIcon,
|
|
1296
|
+
checked: selected
|
|
1297
|
+
}
|
|
1298
|
+
),
|
|
1299
|
+
getOptionLabel(option)
|
|
1300
|
+
] }) : /* @__PURE__ */ jsx9("li", { ...props1, children: getOptionLabel(option) }),
|
|
1301
|
+
renderTags: (tagValue, getTagProps) => tagValue.map((option, index) => /* @__PURE__ */ jsx9(
|
|
1302
|
+
Chip,
|
|
1303
|
+
{
|
|
1304
|
+
...getTagProps({ index }),
|
|
1305
|
+
label: getOptionLabel(option),
|
|
1306
|
+
size: "small",
|
|
1307
|
+
variant: "filled"
|
|
1308
|
+
}
|
|
1309
|
+
)),
|
|
1218
1310
|
renderInput: (params) => /* @__PURE__ */ jsx9(
|
|
1219
1311
|
TextField6,
|
|
1220
1312
|
{
|
|
@@ -1243,11 +1335,17 @@ var Component9 = function SelectMultiElement(props) {
|
|
|
1243
1335
|
);
|
|
1244
1336
|
};
|
|
1245
1337
|
var SelectMultiElement2 = ({
|
|
1246
|
-
gridProps,
|
|
1338
|
+
gridProps = { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } },
|
|
1247
1339
|
...props
|
|
1248
1340
|
}) => {
|
|
1249
1341
|
if (gridProps) {
|
|
1250
|
-
return /* @__PURE__ */ jsx9(
|
|
1342
|
+
return /* @__PURE__ */ jsx9(
|
|
1343
|
+
Grid29,
|
|
1344
|
+
{
|
|
1345
|
+
...{ size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }, ...gridProps },
|
|
1346
|
+
children: /* @__PURE__ */ jsx9(Component9, { ...props })
|
|
1347
|
+
}
|
|
1348
|
+
);
|
|
1251
1349
|
}
|
|
1252
1350
|
return /* @__PURE__ */ jsx9(Component9, { ...props });
|
|
1253
1351
|
};
|
|
@@ -1261,7 +1359,7 @@ import {
|
|
|
1261
1359
|
} from "react-hook-form";
|
|
1262
1360
|
import {
|
|
1263
1361
|
Grid2 as Grid210,
|
|
1264
|
-
useTheme as
|
|
1362
|
+
useTheme as useTheme7,
|
|
1265
1363
|
TextField as TextField7,
|
|
1266
1364
|
Autocomplete as Autocomplete5
|
|
1267
1365
|
} from "@mui/material";
|
|
@@ -1280,6 +1378,7 @@ var Component10 = function SelectCascadeElement(props) {
|
|
|
1280
1378
|
placeholder,
|
|
1281
1379
|
label,
|
|
1282
1380
|
dependsOn,
|
|
1381
|
+
initialValue,
|
|
1283
1382
|
textFieldProps = {},
|
|
1284
1383
|
variant,
|
|
1285
1384
|
sx,
|
|
@@ -1289,9 +1388,16 @@ var Component10 = function SelectCascadeElement(props) {
|
|
|
1289
1388
|
const { required } = textFieldProps;
|
|
1290
1389
|
const getOptionKey = useCallback5(
|
|
1291
1390
|
(option) => {
|
|
1292
|
-
if (typeof option === "string" || typeof option === "number")
|
|
1391
|
+
if (typeof option === "string" || typeof option === "number")
|
|
1392
|
+
return option;
|
|
1293
1393
|
const key = option ? option[valueKey] : void 0;
|
|
1294
|
-
|
|
1394
|
+
if (key === void 0 || key === null) {
|
|
1395
|
+
return "";
|
|
1396
|
+
}
|
|
1397
|
+
if (typeof key === "string" || typeof key === "number") {
|
|
1398
|
+
return key;
|
|
1399
|
+
}
|
|
1400
|
+
return String(key);
|
|
1295
1401
|
},
|
|
1296
1402
|
[valueKey]
|
|
1297
1403
|
);
|
|
@@ -1308,9 +1414,10 @@ var Component10 = function SelectCascadeElement(props) {
|
|
|
1308
1414
|
fieldState: { error }
|
|
1309
1415
|
} = useController10({
|
|
1310
1416
|
name,
|
|
1311
|
-
control
|
|
1417
|
+
control,
|
|
1418
|
+
defaultValue: initialValue
|
|
1312
1419
|
});
|
|
1313
|
-
const theme =
|
|
1420
|
+
const theme = useTheme7();
|
|
1314
1421
|
const { field: dependentField } = useController10({
|
|
1315
1422
|
name: dependsOn,
|
|
1316
1423
|
control
|
|
@@ -1318,45 +1425,48 @@ var Component10 = function SelectCascadeElement(props) {
|
|
|
1318
1425
|
const parentValueRef = useRef3(dependentField.value ?? null);
|
|
1319
1426
|
const [hasAutoSelected, setHasAutoSelected] = useState4(false);
|
|
1320
1427
|
useEffect5(() => {
|
|
1321
|
-
if (
|
|
1428
|
+
if (parentValueRef.current !== dependentField.value) {
|
|
1429
|
+
parentValueRef.current = dependentField.value;
|
|
1322
1430
|
field.onChange(null);
|
|
1323
1431
|
setHasAutoSelected(false);
|
|
1324
1432
|
}
|
|
1325
|
-
}, [dependentField.value]);
|
|
1433
|
+
}, [dependentField.value, field]);
|
|
1326
1434
|
useEffect5(() => {
|
|
1327
|
-
if (
|
|
1328
|
-
|
|
1329
|
-
|
|
1435
|
+
if (!dependentField.value) return;
|
|
1436
|
+
if (isEdit) {
|
|
1437
|
+
if (field.value) return;
|
|
1438
|
+
if (options.length === 1 && !hasAutoSelected) {
|
|
1439
|
+
field.onChange(getOptionKey(options[0]));
|
|
1440
|
+
setHasAutoSelected(true);
|
|
1441
|
+
}
|
|
1330
1442
|
} else {
|
|
1331
|
-
if (options.length === 1 && field.value
|
|
1443
|
+
if (options.length === 1 && !field.value && !hasAutoSelected) {
|
|
1332
1444
|
field.onChange(getOptionKey(options[0]));
|
|
1333
1445
|
setHasAutoSelected(true);
|
|
1334
1446
|
}
|
|
1335
1447
|
}
|
|
1336
1448
|
}, [
|
|
1449
|
+
isEdit,
|
|
1337
1450
|
options,
|
|
1338
1451
|
field.value,
|
|
1339
|
-
|
|
1340
|
-
hasAutoSelected,
|
|
1341
|
-
isEdit,
|
|
1342
|
-
disabled,
|
|
1343
|
-
field,
|
|
1452
|
+
dependentField.value,
|
|
1344
1453
|
getOptionKey,
|
|
1345
|
-
|
|
1454
|
+
hasAutoSelected,
|
|
1455
|
+
field
|
|
1346
1456
|
]);
|
|
1457
|
+
const autocompleteValue = options.find((opt) => getOptionKey(opt) === field.value) ?? null;
|
|
1347
1458
|
return /* @__PURE__ */ jsx10(
|
|
1348
1459
|
Autocomplete5,
|
|
1349
1460
|
{
|
|
1350
1461
|
...rest,
|
|
1351
|
-
value:
|
|
1462
|
+
value: autocompleteValue,
|
|
1352
1463
|
size: "small",
|
|
1353
1464
|
loading,
|
|
1354
1465
|
options,
|
|
1355
|
-
getOptionKey,
|
|
1356
1466
|
getOptionLabel,
|
|
1357
1467
|
isOptionEqualToValue,
|
|
1358
1468
|
ref: field.ref,
|
|
1359
|
-
disabled: dependentField.value
|
|
1469
|
+
disabled: !dependentField.value || disabled,
|
|
1360
1470
|
onChange: (event, newValue, reason) => {
|
|
1361
1471
|
field.onChange(newValue ? getOptionKey(newValue) : null);
|
|
1362
1472
|
if (onChange && typeof onChange === "function") {
|
|
@@ -1369,7 +1479,6 @@ var Component10 = function SelectCascadeElement(props) {
|
|
|
1369
1479
|
onBlur(event);
|
|
1370
1480
|
}
|
|
1371
1481
|
},
|
|
1372
|
-
fullWidth: true,
|
|
1373
1482
|
renderInput: (params) => /* @__PURE__ */ jsx10(
|
|
1374
1483
|
TextField7,
|
|
1375
1484
|
{
|
|
@@ -1380,14 +1489,14 @@ var Component10 = function SelectCascadeElement(props) {
|
|
|
1380
1489
|
helperText: error ? error.message : "",
|
|
1381
1490
|
placeholder,
|
|
1382
1491
|
label,
|
|
1383
|
-
variant: variant
|
|
1492
|
+
variant: variant ?? "outlined",
|
|
1384
1493
|
sx: {
|
|
1385
1494
|
"& .MuiOutlinedInput-root": {
|
|
1386
|
-
bgcolor: disabled || dependentField.value
|
|
1495
|
+
bgcolor: disabled || !dependentField.value ? theme.palette.action.disabledBackground : "transparent"
|
|
1387
1496
|
},
|
|
1388
1497
|
"& .MuiInputLabel-asterisk": { color: "red" },
|
|
1389
1498
|
"& .MuiInputBase-input": {
|
|
1390
|
-
cursor: disabled || dependentField.value
|
|
1499
|
+
cursor: disabled || !dependentField.value ? "not-allowed" : "default"
|
|
1391
1500
|
},
|
|
1392
1501
|
...sx
|
|
1393
1502
|
}
|
|
@@ -1401,7 +1510,13 @@ var SelectCascadeElement2 = ({
|
|
|
1401
1510
|
...props
|
|
1402
1511
|
}) => {
|
|
1403
1512
|
if (gridProps) {
|
|
1404
|
-
return /* @__PURE__ */ jsx10(
|
|
1513
|
+
return /* @__PURE__ */ jsx10(
|
|
1514
|
+
Grid210,
|
|
1515
|
+
{
|
|
1516
|
+
...{ size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }, ...gridProps },
|
|
1517
|
+
children: /* @__PURE__ */ jsx10(Component10, { ...props })
|
|
1518
|
+
}
|
|
1519
|
+
);
|
|
1405
1520
|
}
|
|
1406
1521
|
return /* @__PURE__ */ jsx10(Component10, { ...props });
|
|
1407
1522
|
};
|
|
@@ -1553,6 +1668,205 @@ var CheckboxGroup2 = ({
|
|
|
1553
1668
|
CheckboxGroup2.displayName = "CheckboxGroup";
|
|
1554
1669
|
var CheckboxGroup_default = CheckboxGroup2;
|
|
1555
1670
|
|
|
1671
|
+
// src/wrappers/SelectMultiCascadeElement/SelectMultiCascadeElement.tsx
|
|
1672
|
+
import { useController as useController13 } from "react-hook-form";
|
|
1673
|
+
import { useRef as useRef4, Fragment as Fragment4, useState as useState6, useEffect as useEffect7, useCallback as useCallback6 } from "react";
|
|
1674
|
+
import CheckBoxIcon2 from "@mui/icons-material/CheckBox";
|
|
1675
|
+
import CheckBoxOutlineBlankIcon2 from "@mui/icons-material/CheckBoxOutlineBlank";
|
|
1676
|
+
import {
|
|
1677
|
+
Chip as Chip2,
|
|
1678
|
+
Grid2 as Grid213,
|
|
1679
|
+
Checkbox as Checkbox4,
|
|
1680
|
+
TextField as TextField8,
|
|
1681
|
+
Autocomplete as Autocomplete6,
|
|
1682
|
+
CircularProgress as CircularProgress4
|
|
1683
|
+
} from "@mui/material";
|
|
1684
|
+
import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1685
|
+
var Component13 = function SelectMultiCascadeElement(props) {
|
|
1686
|
+
const {
|
|
1687
|
+
name,
|
|
1688
|
+
control,
|
|
1689
|
+
dependsOn,
|
|
1690
|
+
onBlur,
|
|
1691
|
+
disabled,
|
|
1692
|
+
options,
|
|
1693
|
+
loading = false,
|
|
1694
|
+
placeholder,
|
|
1695
|
+
label,
|
|
1696
|
+
variant,
|
|
1697
|
+
sx,
|
|
1698
|
+
labelKey = "Label",
|
|
1699
|
+
valueKey = "Value",
|
|
1700
|
+
multiple = true,
|
|
1701
|
+
isEdit = false,
|
|
1702
|
+
initialValue,
|
|
1703
|
+
...rest
|
|
1704
|
+
} = props;
|
|
1705
|
+
const {
|
|
1706
|
+
field,
|
|
1707
|
+
fieldState: { error }
|
|
1708
|
+
} = useController13({
|
|
1709
|
+
name,
|
|
1710
|
+
control,
|
|
1711
|
+
defaultValue: initialValue
|
|
1712
|
+
});
|
|
1713
|
+
const { field: dependentField } = useController13({
|
|
1714
|
+
name: dependsOn,
|
|
1715
|
+
control
|
|
1716
|
+
});
|
|
1717
|
+
const parentValueRef = useRef4(dependentField.value ?? null);
|
|
1718
|
+
const [hasAutoSelected, setHasAutoSelected] = useState6(false);
|
|
1719
|
+
const getOptionValue = useCallback6(
|
|
1720
|
+
(option) => {
|
|
1721
|
+
if (typeof option === "string") return option;
|
|
1722
|
+
return option ? option[valueKey] : null;
|
|
1723
|
+
},
|
|
1724
|
+
[valueKey]
|
|
1725
|
+
);
|
|
1726
|
+
const getOptionLabel = useCallback6(
|
|
1727
|
+
(option) => {
|
|
1728
|
+
if (typeof option === "string") return option;
|
|
1729
|
+
return option ? option[labelKey] : "";
|
|
1730
|
+
},
|
|
1731
|
+
[labelKey]
|
|
1732
|
+
);
|
|
1733
|
+
useEffect7(() => {
|
|
1734
|
+
if (parentValueRef.current !== dependentField.value) {
|
|
1735
|
+
parentValueRef.current = dependentField.value;
|
|
1736
|
+
field.onChange(multiple ? [] : null);
|
|
1737
|
+
setHasAutoSelected(false);
|
|
1738
|
+
}
|
|
1739
|
+
}, [dependentField.value, field, multiple]);
|
|
1740
|
+
useEffect7(() => {
|
|
1741
|
+
if (!dependentField.value) return;
|
|
1742
|
+
if (isEdit) {
|
|
1743
|
+
if (field.value && (multiple ? field.value.length > 0 : field.value))
|
|
1744
|
+
return;
|
|
1745
|
+
if (options.length === 1 && !hasAutoSelected) {
|
|
1746
|
+
field.onChange(
|
|
1747
|
+
multiple ? [getOptionValue(options[0])] : getOptionValue(options[0])
|
|
1748
|
+
);
|
|
1749
|
+
setHasAutoSelected(true);
|
|
1750
|
+
}
|
|
1751
|
+
} else {
|
|
1752
|
+
if (options.length === 1 && (!field.value || field.value.length === 0) && !hasAutoSelected) {
|
|
1753
|
+
field.onChange(
|
|
1754
|
+
multiple ? [getOptionValue(options[0])] : getOptionValue(options[0])
|
|
1755
|
+
);
|
|
1756
|
+
setHasAutoSelected(true);
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
}, [
|
|
1760
|
+
isEdit,
|
|
1761
|
+
options,
|
|
1762
|
+
field.value,
|
|
1763
|
+
dependentField.value,
|
|
1764
|
+
multiple,
|
|
1765
|
+
getOptionValue,
|
|
1766
|
+
hasAutoSelected,
|
|
1767
|
+
field
|
|
1768
|
+
]);
|
|
1769
|
+
const selectedValue = multiple ? Array.isArray(field.value) ? options.filter((opt) => field.value.includes(getOptionValue(opt))) : [] : options.find((opt) => getOptionValue(opt) === field.value) ?? null;
|
|
1770
|
+
const handleChange = (_2, selected, reason) => {
|
|
1771
|
+
if (multiple) {
|
|
1772
|
+
if (reason === "clear") {
|
|
1773
|
+
field.onChange([]);
|
|
1774
|
+
} else {
|
|
1775
|
+
const newValues = selected.map((opt) => getOptionValue(opt));
|
|
1776
|
+
field.onChange(newValues);
|
|
1777
|
+
}
|
|
1778
|
+
} else {
|
|
1779
|
+
field.onChange(selected ? getOptionValue(selected) : null);
|
|
1780
|
+
}
|
|
1781
|
+
};
|
|
1782
|
+
const icon = /* @__PURE__ */ jsx13(CheckBoxOutlineBlankIcon2, { fontSize: "small" });
|
|
1783
|
+
const checkedIcon = /* @__PURE__ */ jsx13(CheckBoxIcon2, { fontSize: "small" });
|
|
1784
|
+
return /* @__PURE__ */ jsx13(
|
|
1785
|
+
Autocomplete6,
|
|
1786
|
+
{
|
|
1787
|
+
multiple,
|
|
1788
|
+
value: selectedValue,
|
|
1789
|
+
loading,
|
|
1790
|
+
options,
|
|
1791
|
+
getOptionLabel,
|
|
1792
|
+
isOptionEqualToValue: (option, value) => getOptionValue(option) === getOptionValue(value),
|
|
1793
|
+
filterSelectedOptions: multiple,
|
|
1794
|
+
disableCloseOnSelect: multiple,
|
|
1795
|
+
ref: field.ref,
|
|
1796
|
+
disabled: !dependentField.value || disabled,
|
|
1797
|
+
onChange: handleChange,
|
|
1798
|
+
onBlur: (event) => {
|
|
1799
|
+
field.onBlur();
|
|
1800
|
+
if (typeof onBlur === "function") {
|
|
1801
|
+
onBlur(event);
|
|
1802
|
+
}
|
|
1803
|
+
},
|
|
1804
|
+
fullWidth: true,
|
|
1805
|
+
renderOption: (props1, option, { selected }) => multiple ? /* @__PURE__ */ jsxs7("li", { ...props1, children: [
|
|
1806
|
+
/* @__PURE__ */ jsx13(
|
|
1807
|
+
Checkbox4,
|
|
1808
|
+
{
|
|
1809
|
+
icon,
|
|
1810
|
+
checkedIcon,
|
|
1811
|
+
checked: selected
|
|
1812
|
+
}
|
|
1813
|
+
),
|
|
1814
|
+
getOptionLabel(option)
|
|
1815
|
+
] }) : /* @__PURE__ */ jsx13("li", { ...props1, children: getOptionLabel(option) }),
|
|
1816
|
+
renderTags: (tagValue, getTagProps) => tagValue.map((option, index) => /* @__PURE__ */ jsx13(
|
|
1817
|
+
Chip2,
|
|
1818
|
+
{
|
|
1819
|
+
...getTagProps({ index }),
|
|
1820
|
+
label: getOptionLabel(option),
|
|
1821
|
+
size: "small",
|
|
1822
|
+
variant: "filled"
|
|
1823
|
+
}
|
|
1824
|
+
)),
|
|
1825
|
+
renderInput: (params) => /* @__PURE__ */ jsx13(
|
|
1826
|
+
TextField8,
|
|
1827
|
+
{
|
|
1828
|
+
...params,
|
|
1829
|
+
label,
|
|
1830
|
+
error: !!error,
|
|
1831
|
+
helperText: error ? error.message : "",
|
|
1832
|
+
placeholder,
|
|
1833
|
+
slotProps: {
|
|
1834
|
+
input: {
|
|
1835
|
+
...params.InputProps,
|
|
1836
|
+
endAdornment: /* @__PURE__ */ jsxs7(Fragment4, { children: [
|
|
1837
|
+
loading ? /* @__PURE__ */ jsx13(CircularProgress4, { color: "inherit", size: 20 }) : null,
|
|
1838
|
+
params.InputProps.endAdornment
|
|
1839
|
+
] })
|
|
1840
|
+
}
|
|
1841
|
+
},
|
|
1842
|
+
variant: variant ? variant : "outlined",
|
|
1843
|
+
sx: {
|
|
1844
|
+
...sx
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
),
|
|
1848
|
+
...rest
|
|
1849
|
+
}
|
|
1850
|
+
);
|
|
1851
|
+
};
|
|
1852
|
+
var SelectMultiCascadeElement2 = ({
|
|
1853
|
+
gridProps = { size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 } },
|
|
1854
|
+
...props
|
|
1855
|
+
}) => {
|
|
1856
|
+
if (gridProps) {
|
|
1857
|
+
return /* @__PURE__ */ jsx13(
|
|
1858
|
+
Grid213,
|
|
1859
|
+
{
|
|
1860
|
+
...{ size: { xs: 12, sm: 12, md: 12, lg: 12, xl: 12 }, ...gridProps },
|
|
1861
|
+
children: /* @__PURE__ */ jsx13(Component13, { ...props })
|
|
1862
|
+
}
|
|
1863
|
+
);
|
|
1864
|
+
}
|
|
1865
|
+
return /* @__PURE__ */ jsx13(Component13, { ...props });
|
|
1866
|
+
};
|
|
1867
|
+
SelectMultiCascadeElement2.displayName = "SelectMultiCascadeElement";
|
|
1868
|
+
var SelectMultiCascadeElement_default = SelectMultiCascadeElement2;
|
|
1869
|
+
|
|
1556
1870
|
// src/wrappers/Field/index.ts
|
|
1557
1871
|
var Field = {
|
|
1558
1872
|
Text: TextFieldElement_default,
|
|
@@ -1566,7 +1880,8 @@ var Field = {
|
|
|
1566
1880
|
SelectCascade: SelectCascadeElement_default,
|
|
1567
1881
|
AsyncSelect: AsyncSelectElement_default,
|
|
1568
1882
|
AsyncMultiSelect: AsyncMultiSelect_default,
|
|
1569
|
-
CheckboxGroup: CheckboxGroup_default
|
|
1883
|
+
CheckboxGroup: CheckboxGroup_default,
|
|
1884
|
+
SelectMultiCascadeElement: SelectMultiCascadeElement_default
|
|
1570
1885
|
};
|
|
1571
1886
|
var Field_default = Field;
|
|
1572
1887
|
|