@gnwebsoft/ui 2.18.39 → 2.18.40
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-OHRT3LMC.mjs → chunk-RVKKPXZC.mjs} +181 -112
- package/dist/{chunk-NTUP43A7.js → chunk-VNU4ZOUE.js} +163 -94
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/dist/wrappers/index.d.mts +35 -52
- package/dist/wrappers/index.d.ts +35 -52
- package/dist/wrappers/index.js +2 -2
- package/dist/wrappers/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -6,38 +6,45 @@ import {
|
|
|
6
6
|
} from "./chunk-AVNKSUE5.mjs";
|
|
7
7
|
|
|
8
8
|
// src/wrappers/DatePickerElement/DatePickerElement.tsx
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
} from "
|
|
12
|
-
import {
|
|
13
|
-
Grid2,
|
|
14
|
-
useForkRef
|
|
15
|
-
} from "@mui/material";
|
|
16
|
-
import {
|
|
17
|
-
DatePicker
|
|
18
|
-
} from "@mui/x-date-pickers";
|
|
19
|
-
import { useLocalizationContext } from "@mui/x-date-pickers/internals";
|
|
9
|
+
import { useMemo, useCallback } from "react";
|
|
10
|
+
import { useController } from "react-hook-form";
|
|
11
|
+
import { DatePicker } from "@mui/x-date-pickers";
|
|
12
|
+
import { Grid2, useForkRef } from "@mui/material";
|
|
20
13
|
import { jsx } from "react/jsx-runtime";
|
|
14
|
+
function useTransform2(options) {
|
|
15
|
+
const value = useMemo(
|
|
16
|
+
() => typeof options.transform?.input === "function" ? options.transform.input(options.value) : options.value,
|
|
17
|
+
[options.transform, options.value]
|
|
18
|
+
);
|
|
19
|
+
const onChange = useCallback(
|
|
20
|
+
(...event) => {
|
|
21
|
+
if (typeof options.transform?.output === "function") {
|
|
22
|
+
options.onChange(options.transform.output(...event));
|
|
23
|
+
} else {
|
|
24
|
+
options.onChange(...event);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
[options]
|
|
28
|
+
);
|
|
29
|
+
return {
|
|
30
|
+
value,
|
|
31
|
+
onChange
|
|
32
|
+
};
|
|
33
|
+
}
|
|
21
34
|
var Component = function DatePickerElement(props) {
|
|
22
35
|
const {
|
|
23
|
-
parseError,
|
|
24
36
|
name,
|
|
25
37
|
required,
|
|
26
|
-
rules = {},
|
|
27
38
|
inputProps,
|
|
28
39
|
control,
|
|
29
40
|
textReadOnly,
|
|
30
41
|
label,
|
|
31
42
|
placeholder,
|
|
32
|
-
gridProps,
|
|
33
43
|
slotProps,
|
|
34
|
-
transform,
|
|
35
44
|
datePickerProps = {},
|
|
36
|
-
variant,
|
|
37
45
|
sx,
|
|
38
46
|
...rest
|
|
39
47
|
} = props;
|
|
40
|
-
const adapter = useLocalizationContext();
|
|
41
48
|
const { disabled, inputRef, onClose, ...restDatePickerProps } = datePickerProps;
|
|
42
49
|
const {
|
|
43
50
|
field,
|
|
@@ -47,12 +54,15 @@ var Component = function DatePickerElement(props) {
|
|
|
47
54
|
control,
|
|
48
55
|
defaultValue: null
|
|
49
56
|
});
|
|
50
|
-
const { value, onChange } =
|
|
57
|
+
const { value, onChange } = useTransform2({
|
|
51
58
|
value: field.value,
|
|
52
59
|
onChange: field.onChange,
|
|
53
60
|
transform: {
|
|
54
|
-
|
|
55
|
-
output:
|
|
61
|
+
//@ts-ignore
|
|
62
|
+
output: (outputValue, context) => {
|
|
63
|
+
if (outputValue === null) return null;
|
|
64
|
+
return outputValue;
|
|
65
|
+
}
|
|
56
66
|
}
|
|
57
67
|
});
|
|
58
68
|
const handleInputRef = useForkRef(field.ref, inputRef);
|
|
@@ -82,6 +92,9 @@ var Component = function DatePickerElement(props) {
|
|
|
82
92
|
sx,
|
|
83
93
|
slotProps: {
|
|
84
94
|
...slotProps,
|
|
95
|
+
actionBar: {
|
|
96
|
+
actions: ["clear", "today", "cancel", "accept"]
|
|
97
|
+
},
|
|
85
98
|
textField: {
|
|
86
99
|
...inputProps,
|
|
87
100
|
required,
|
|
@@ -485,7 +498,7 @@ import {
|
|
|
485
498
|
useController as useController5
|
|
486
499
|
} from "react-hook-form";
|
|
487
500
|
import { useForkRef as useForkRef4, Grid2 as Grid25 } from "@mui/material";
|
|
488
|
-
import { useLocalizationContext
|
|
501
|
+
import { useLocalizationContext } from "@mui/x-date-pickers/internals";
|
|
489
502
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
490
503
|
var Component5 = function TimePickerElement(props) {
|
|
491
504
|
const {
|
|
@@ -501,7 +514,7 @@ var Component5 = function TimePickerElement(props) {
|
|
|
501
514
|
transform,
|
|
502
515
|
...rest
|
|
503
516
|
} = props;
|
|
504
|
-
const adapter =
|
|
517
|
+
const adapter = useLocalizationContext();
|
|
505
518
|
const {
|
|
506
519
|
field,
|
|
507
520
|
fieldState: { error }
|
|
@@ -575,9 +588,9 @@ import Autocomplete from "@mui/material/Autocomplete";
|
|
|
575
588
|
import { debounce } from "@mui/material/utils";
|
|
576
589
|
import {
|
|
577
590
|
Fragment,
|
|
578
|
-
useCallback,
|
|
591
|
+
useCallback as useCallback2,
|
|
579
592
|
useEffect as useEffect2,
|
|
580
|
-
useMemo,
|
|
593
|
+
useMemo as useMemo2,
|
|
581
594
|
useRef,
|
|
582
595
|
useState as useState2
|
|
583
596
|
} from "react";
|
|
@@ -610,8 +623,8 @@ var Component6 = function AsyncSelectElement(props) {
|
|
|
610
623
|
const [loading, setLoading] = useState2(false);
|
|
611
624
|
const [selectedOption, setSelectedOption] = useState2(null);
|
|
612
625
|
const [inputValue, setInputValue] = useState2("");
|
|
613
|
-
const inputValue2 =
|
|
614
|
-
const setInputValue2 =
|
|
626
|
+
const inputValue2 = useMemo2(() => inputValue, [inputValue]);
|
|
627
|
+
const setInputValue2 = useCallback2(
|
|
615
628
|
(inputValue3) => setInputValue(inputValue3),
|
|
616
629
|
[]
|
|
617
630
|
);
|
|
@@ -620,7 +633,7 @@ var Component6 = function AsyncSelectElement(props) {
|
|
|
620
633
|
!initialValue ? true : !(initialValue != null && initialValue > 0)
|
|
621
634
|
);
|
|
622
635
|
const fieldValue = useRef(field.value);
|
|
623
|
-
const fetchData =
|
|
636
|
+
const fetchData = useMemo2(
|
|
624
637
|
() => debounce(
|
|
625
638
|
(payload, callback) => {
|
|
626
639
|
queryFn(payload).then((c) => callback(c));
|
|
@@ -786,9 +799,9 @@ import _ from "lodash";
|
|
|
786
799
|
import {
|
|
787
800
|
useState as useState3,
|
|
788
801
|
useRef as useRef2,
|
|
789
|
-
useMemo as
|
|
802
|
+
useMemo as useMemo3,
|
|
790
803
|
useEffect as useEffect3,
|
|
791
|
-
useCallback as
|
|
804
|
+
useCallback as useCallback3,
|
|
792
805
|
Fragment as Fragment2
|
|
793
806
|
} from "react";
|
|
794
807
|
import { debounce as debounce2 } from "lodash";
|
|
@@ -834,12 +847,12 @@ var Component7 = function AsyncSelectMultiElement(props) {
|
|
|
834
847
|
const initialValuesLoaded = useRef2(
|
|
835
848
|
!(initialValues && initialValues.length > 0)
|
|
836
849
|
);
|
|
837
|
-
const inputValue2 =
|
|
838
|
-
const setInputValue2 =
|
|
850
|
+
const inputValue2 = useMemo3(() => inputValue, [inputValue]);
|
|
851
|
+
const setInputValue2 = useCallback3(
|
|
839
852
|
(inputValue3) => setInputValue(inputValue3),
|
|
840
853
|
[]
|
|
841
854
|
);
|
|
842
|
-
const fetchData =
|
|
855
|
+
const fetchData = useMemo3(
|
|
843
856
|
() => debounce2(
|
|
844
857
|
(payload, callback) => {
|
|
845
858
|
queryFn(payload).then((c) => callback(c));
|
|
@@ -990,12 +1003,11 @@ AsyncSelectMultiElement2.displayName = "AsyncSelectMulti";
|
|
|
990
1003
|
var AsyncMultiSelect_default = AsyncSelectMultiElement2;
|
|
991
1004
|
|
|
992
1005
|
// src/wrappers/SelectElement/SelectElement.tsx
|
|
993
|
-
import { useMemo as
|
|
994
|
-
import { useEffect as useEffect4 } from "react";
|
|
1006
|
+
import { useMemo as useMemo4, useEffect as useEffect4, useCallback as useCallback4 } from "react";
|
|
995
1007
|
import {
|
|
996
1008
|
useController as useController8
|
|
997
1009
|
} from "react-hook-form";
|
|
998
|
-
import { Grid2 as Grid28, TextField as TextField5, Autocomplete as Autocomplete3 } from "@mui/material";
|
|
1010
|
+
import { Grid2 as Grid28, useTheme as useTheme5, TextField as TextField5, Autocomplete as Autocomplete3 } from "@mui/material";
|
|
999
1011
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1000
1012
|
var Component8 = function SelectElement(props) {
|
|
1001
1013
|
const {
|
|
@@ -1005,24 +1017,32 @@ var Component8 = function SelectElement(props) {
|
|
|
1005
1017
|
isEdit,
|
|
1006
1018
|
options,
|
|
1007
1019
|
label,
|
|
1020
|
+
sx,
|
|
1021
|
+
variant,
|
|
1022
|
+
disabled,
|
|
1008
1023
|
labelKey = "Label",
|
|
1009
1024
|
valueKey = "Value",
|
|
1025
|
+
placeholder,
|
|
1010
1026
|
textFieldProps = {},
|
|
1011
1027
|
...rest
|
|
1012
1028
|
} = props;
|
|
1013
|
-
const { required
|
|
1014
|
-
const {
|
|
1029
|
+
const { required } = textFieldProps;
|
|
1030
|
+
const {
|
|
1031
|
+
field,
|
|
1032
|
+
fieldState: { error }
|
|
1033
|
+
} = useController8({
|
|
1015
1034
|
name,
|
|
1016
1035
|
control
|
|
1017
1036
|
});
|
|
1018
|
-
const
|
|
1037
|
+
const theme = useTheme5();
|
|
1038
|
+
const getOptionValue = useCallback4(
|
|
1019
1039
|
(option) => {
|
|
1020
1040
|
if (typeof option === "string") return option;
|
|
1021
1041
|
return option ? option[valueKey] : null;
|
|
1022
1042
|
},
|
|
1023
1043
|
[valueKey]
|
|
1024
1044
|
);
|
|
1025
|
-
const getOptionLabel =
|
|
1045
|
+
const getOptionLabel = useCallback4(
|
|
1026
1046
|
(option) => {
|
|
1027
1047
|
if (typeof option === "string") return option;
|
|
1028
1048
|
return option ? String(option[labelKey]) : "";
|
|
@@ -1040,8 +1060,8 @@ var Component8 = function SelectElement(props) {
|
|
|
1040
1060
|
const defaultValue = getOptionValue(defaultOption);
|
|
1041
1061
|
field.onChange(defaultValue);
|
|
1042
1062
|
}
|
|
1043
|
-
}, [isEdit, options
|
|
1044
|
-
const autocompleteValue =
|
|
1063
|
+
}, [isEdit, options]);
|
|
1064
|
+
const autocompleteValue = useMemo4(
|
|
1045
1065
|
() => options.find((option) => getOptionValue(option) === field.value) ?? null,
|
|
1046
1066
|
[field.value, options, getOptionValue]
|
|
1047
1067
|
);
|
|
@@ -1053,24 +1073,33 @@ var Component8 = function SelectElement(props) {
|
|
|
1053
1073
|
options,
|
|
1054
1074
|
value: autocompleteValue,
|
|
1055
1075
|
onChange: handleChange,
|
|
1076
|
+
disabled,
|
|
1056
1077
|
getOptionLabel: (option) => getOptionLabel(option),
|
|
1078
|
+
ref: field.ref,
|
|
1057
1079
|
isOptionEqualToValue: (option, value) => getOptionValue(option) === getOptionValue(value),
|
|
1058
|
-
renderInput: (params) =>
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1080
|
+
renderInput: (params) => /* @__PURE__ */ jsx8(
|
|
1081
|
+
TextField5,
|
|
1082
|
+
{
|
|
1083
|
+
...params,
|
|
1084
|
+
fullWidth: true,
|
|
1085
|
+
required,
|
|
1086
|
+
error: !!error,
|
|
1087
|
+
helperText: error ? error.message : "",
|
|
1088
|
+
label,
|
|
1089
|
+
placeholder,
|
|
1090
|
+
variant: variant ? variant : "outlined",
|
|
1091
|
+
sx: {
|
|
1092
|
+
"& .MuiOutlinedInput-root": {
|
|
1093
|
+
bgcolor: disabled ? theme.palette.action.disabledBackground : "transparent"
|
|
1094
|
+
},
|
|
1095
|
+
"& .MuiInputLabel-asterisk": { color: "red" },
|
|
1096
|
+
"& .MuiInputBase-input": {
|
|
1097
|
+
cursor: disabled ? "not-allowed" : "default"
|
|
1098
|
+
},
|
|
1099
|
+
...sx
|
|
1071
1100
|
}
|
|
1072
|
-
|
|
1073
|
-
|
|
1101
|
+
}
|
|
1102
|
+
)
|
|
1074
1103
|
}
|
|
1075
1104
|
);
|
|
1076
1105
|
};
|
|
@@ -1087,29 +1116,26 @@ SelectElement2.displayName = "SelectElement";
|
|
|
1087
1116
|
var SelectElement_default = SelectElement2;
|
|
1088
1117
|
|
|
1089
1118
|
// src/wrappers/SelectMultiElement/SelectMultiElement.tsx
|
|
1090
|
-
import {
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
} from "@mui/material";
|
|
1096
|
-
import {
|
|
1097
|
-
useController as useController9
|
|
1098
|
-
} from "react-hook-form";
|
|
1099
|
-
import { Fragment as Fragment3, useState as useState4 } from "react";
|
|
1119
|
+
import { Fragment as Fragment3 } from "react";
|
|
1120
|
+
import { useController as useController9 } from "react-hook-form";
|
|
1121
|
+
import CheckBoxIcon from "@mui/icons-material/CheckBox";
|
|
1122
|
+
import CheckBoxOutlineBlankIcon from "@mui/icons-material/CheckBoxOutlineBlank";
|
|
1123
|
+
import { Grid2 as Grid29, Checkbox, TextField as TextField6, Autocomplete as Autocomplete4, CircularProgress as CircularProgress3 } from "@mui/material";
|
|
1100
1124
|
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1101
1125
|
var Component9 = function SelectMultiElement(props) {
|
|
1102
1126
|
const {
|
|
1103
1127
|
name,
|
|
1128
|
+
control,
|
|
1104
1129
|
onBlur,
|
|
1105
1130
|
disabled,
|
|
1106
1131
|
options,
|
|
1107
|
-
control,
|
|
1108
1132
|
loading = false,
|
|
1109
1133
|
placeholder,
|
|
1110
1134
|
label,
|
|
1111
1135
|
variant,
|
|
1112
1136
|
sx,
|
|
1137
|
+
labelKey = "Label",
|
|
1138
|
+
valueKey = "Value",
|
|
1113
1139
|
...rest
|
|
1114
1140
|
} = props;
|
|
1115
1141
|
const {
|
|
@@ -1119,27 +1145,38 @@ var Component9 = function SelectMultiElement(props) {
|
|
|
1119
1145
|
name,
|
|
1120
1146
|
control
|
|
1121
1147
|
});
|
|
1122
|
-
const
|
|
1123
|
-
|
|
1148
|
+
const getOptionValue = (option) => {
|
|
1149
|
+
if (typeof option === "string") return option;
|
|
1150
|
+
return option ? option[valueKey] : null;
|
|
1151
|
+
};
|
|
1152
|
+
const getOptionLabel = (option) => {
|
|
1153
|
+
if (typeof option === "string") return option;
|
|
1154
|
+
return option ? option[labelKey] : "";
|
|
1155
|
+
};
|
|
1156
|
+
const selectedValue = field.value && Array.isArray(field.value) ? options.filter((option) => field.value.includes(getOptionValue(option))) : [];
|
|
1157
|
+
const handleChange = (_2, selectedOptions, reason) => {
|
|
1124
1158
|
if (reason === "clear") {
|
|
1125
|
-
setSelectedOptions([]);
|
|
1126
1159
|
field.onChange([]);
|
|
1127
1160
|
} else if (reason === "selectOption" || reason === "removeOption") {
|
|
1128
|
-
|
|
1129
|
-
field.onChange(
|
|
1161
|
+
const newValues = selectedOptions.map((option) => getOptionValue(option));
|
|
1162
|
+
field.onChange(newValues);
|
|
1130
1163
|
}
|
|
1131
1164
|
};
|
|
1165
|
+
const icon = /* @__PURE__ */ jsx9(CheckBoxOutlineBlankIcon, { fontSize: "small" });
|
|
1166
|
+
const checkedIcon = /* @__PURE__ */ jsx9(CheckBoxIcon, { fontSize: "small" });
|
|
1132
1167
|
return /* @__PURE__ */ jsx9(
|
|
1133
1168
|
Autocomplete4,
|
|
1134
1169
|
{
|
|
1135
1170
|
multiple: true,
|
|
1136
|
-
value:
|
|
1171
|
+
value: selectedValue,
|
|
1137
1172
|
loading,
|
|
1138
1173
|
options,
|
|
1139
|
-
getOptionLabel
|
|
1174
|
+
getOptionLabel,
|
|
1175
|
+
isOptionEqualToValue: (option, value) => getOptionValue(option) === getOptionValue(value),
|
|
1140
1176
|
filterSelectedOptions: true,
|
|
1177
|
+
disableCloseOnSelect: true,
|
|
1141
1178
|
ref: field.ref,
|
|
1142
|
-
disabled: field.disabled,
|
|
1179
|
+
disabled: disabled ?? field.disabled,
|
|
1143
1180
|
onChange: handleChange,
|
|
1144
1181
|
onBlur: (event) => {
|
|
1145
1182
|
field.onBlur();
|
|
@@ -1148,6 +1185,13 @@ var Component9 = function SelectMultiElement(props) {
|
|
|
1148
1185
|
}
|
|
1149
1186
|
},
|
|
1150
1187
|
fullWidth: true,
|
|
1188
|
+
renderOption: (props1, option, { selected }) => {
|
|
1189
|
+
const { key, ...optionProps } = props1;
|
|
1190
|
+
return /* @__PURE__ */ jsxs4("li", { ...optionProps, children: [
|
|
1191
|
+
/* @__PURE__ */ jsx9(Checkbox, { icon, checkedIcon, checked: selected }),
|
|
1192
|
+
getOptionLabel(option)
|
|
1193
|
+
] }, key);
|
|
1194
|
+
},
|
|
1151
1195
|
renderInput: (params) => /* @__PURE__ */ jsx9(
|
|
1152
1196
|
TextField6,
|
|
1153
1197
|
{
|
|
@@ -1188,36 +1232,54 @@ SelectMultiElement2.displayName = "SelectMultiElement";
|
|
|
1188
1232
|
var SelectMultiElement_default = SelectMultiElement2;
|
|
1189
1233
|
|
|
1190
1234
|
// src/wrappers/SelectCascadeElement/SelectCascadeElement.tsx
|
|
1235
|
+
import { useRef as useRef3, useState as useState4, useEffect as useEffect5, useCallback as useCallback5 } from "react";
|
|
1236
|
+
import {
|
|
1237
|
+
useController as useController10
|
|
1238
|
+
} from "react-hook-form";
|
|
1191
1239
|
import {
|
|
1192
|
-
Autocomplete as Autocomplete5,
|
|
1193
1240
|
Grid2 as Grid210,
|
|
1241
|
+
useTheme as useTheme6,
|
|
1194
1242
|
TextField as TextField7,
|
|
1195
|
-
|
|
1243
|
+
Autocomplete as Autocomplete5
|
|
1196
1244
|
} from "@mui/material";
|
|
1197
|
-
import { useEffect as useEffect5, useRef as useRef3, useState as useState5 } from "react";
|
|
1198
|
-
import {
|
|
1199
|
-
useController as useController10
|
|
1200
|
-
} from "react-hook-form";
|
|
1201
1245
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1202
|
-
var Component10 = function
|
|
1246
|
+
var Component10 = function SelectCascadeElement2(props) {
|
|
1203
1247
|
const {
|
|
1248
|
+
labelKey = "Label",
|
|
1249
|
+
valueKey = "Value",
|
|
1204
1250
|
name,
|
|
1205
1251
|
onBlur,
|
|
1206
1252
|
onChange,
|
|
1207
1253
|
disabled,
|
|
1208
1254
|
options,
|
|
1209
1255
|
control,
|
|
1210
|
-
gridProps,
|
|
1211
1256
|
loading = false,
|
|
1212
1257
|
placeholder,
|
|
1213
1258
|
label,
|
|
1214
1259
|
dependsOn,
|
|
1215
|
-
|
|
1260
|
+
textFieldProps = {},
|
|
1216
1261
|
variant,
|
|
1217
1262
|
sx,
|
|
1218
1263
|
isEdit = false,
|
|
1219
1264
|
...rest
|
|
1220
1265
|
} = props;
|
|
1266
|
+
const { required } = textFieldProps;
|
|
1267
|
+
const getOptionKey = useCallback5(
|
|
1268
|
+
(option) => {
|
|
1269
|
+
if (typeof option === "string" || typeof option === "number") return option;
|
|
1270
|
+
const key = option ? option[valueKey] : void 0;
|
|
1271
|
+
return key !== void 0 && key !== null ? String(key) : "";
|
|
1272
|
+
},
|
|
1273
|
+
[valueKey]
|
|
1274
|
+
);
|
|
1275
|
+
const getOptionLabel = useCallback5(
|
|
1276
|
+
(option) => {
|
|
1277
|
+
if (typeof option === "string") return option;
|
|
1278
|
+
return option ? String(option[labelKey]) : "";
|
|
1279
|
+
},
|
|
1280
|
+
[labelKey]
|
|
1281
|
+
);
|
|
1282
|
+
const isOptionEqualToValue = (option, value) => getOptionKey(option) === getOptionKey(value);
|
|
1221
1283
|
const {
|
|
1222
1284
|
field,
|
|
1223
1285
|
fieldState: { error }
|
|
@@ -1225,50 +1287,53 @@ var Component10 = function SelectCascadeElement(props) {
|
|
|
1225
1287
|
name,
|
|
1226
1288
|
control
|
|
1227
1289
|
});
|
|
1228
|
-
const theme =
|
|
1290
|
+
const theme = useTheme6();
|
|
1229
1291
|
const { field: dependentField } = useController10({
|
|
1230
1292
|
name: dependsOn,
|
|
1231
1293
|
control
|
|
1232
1294
|
});
|
|
1233
1295
|
const parentValueRef = useRef3(dependentField.value ?? null);
|
|
1234
1296
|
useEffect5(() => {
|
|
1235
|
-
if (!!dependentField.value && parentValueRef?.current
|
|
1297
|
+
if (!!dependentField.value && parentValueRef?.current !== dependentField.value || dependentField.value === null) {
|
|
1236
1298
|
field.onChange(null);
|
|
1237
1299
|
}
|
|
1238
|
-
}, [dependentField.value]);
|
|
1239
|
-
|
|
1240
|
-
if (initialValue) {
|
|
1241
|
-
field.onChange(initialValue);
|
|
1242
|
-
}
|
|
1243
|
-
}, [initialValue]);
|
|
1244
|
-
const [hasAutoSelected, setHasAutoSelected] = useState5(false);
|
|
1300
|
+
}, [dependentField.value, field]);
|
|
1301
|
+
const [hasAutoSelected, setHasAutoSelected] = useState4(false);
|
|
1245
1302
|
useEffect5(() => {
|
|
1246
1303
|
if (isEdit && !disabled && options.length === 1 && field.value == null && !hasAutoSelected) {
|
|
1247
|
-
field.onChange(options[0]
|
|
1304
|
+
field.onChange(getOptionKey(options[0]));
|
|
1248
1305
|
setHasAutoSelected(true);
|
|
1249
1306
|
} else {
|
|
1250
1307
|
if (options.length === 1 && field.value == null && !hasAutoSelected) {
|
|
1251
|
-
field.onChange(options[0]
|
|
1308
|
+
field.onChange(getOptionKey(options[0]));
|
|
1252
1309
|
setHasAutoSelected(true);
|
|
1253
1310
|
}
|
|
1254
1311
|
}
|
|
1255
|
-
}, [
|
|
1312
|
+
}, [
|
|
1313
|
+
options,
|
|
1314
|
+
field.value,
|
|
1315
|
+
field.onChange,
|
|
1316
|
+
hasAutoSelected,
|
|
1317
|
+
isEdit,
|
|
1318
|
+
disabled,
|
|
1319
|
+
field,
|
|
1320
|
+
getOptionKey
|
|
1321
|
+
]);
|
|
1256
1322
|
return /* @__PURE__ */ jsx10(
|
|
1257
1323
|
Autocomplete5,
|
|
1258
1324
|
{
|
|
1259
1325
|
...rest,
|
|
1260
|
-
value: field.value
|
|
1261
|
-
return field.value === option.Value;
|
|
1262
|
-
}) ?? null : null,
|
|
1326
|
+
value: options.map((option) => getOptionKey(option) === field.value ? option : null).find(Boolean) || null,
|
|
1263
1327
|
size: "small",
|
|
1264
1328
|
loading,
|
|
1265
1329
|
options,
|
|
1266
|
-
|
|
1267
|
-
|
|
1330
|
+
getOptionKey,
|
|
1331
|
+
getOptionLabel,
|
|
1332
|
+
isOptionEqualToValue,
|
|
1268
1333
|
ref: field.ref,
|
|
1269
1334
|
disabled,
|
|
1270
1335
|
onChange: (event, newValue, reason) => {
|
|
1271
|
-
field.onChange(newValue ? newValue
|
|
1336
|
+
field.onChange(newValue ? getOptionKey(newValue) : null);
|
|
1272
1337
|
if (onChange && typeof onChange === "function") {
|
|
1273
1338
|
onChange(event, newValue, reason);
|
|
1274
1339
|
}
|
|
@@ -1286,15 +1351,19 @@ var Component10 = function SelectCascadeElement(props) {
|
|
|
1286
1351
|
...params,
|
|
1287
1352
|
fullWidth: true,
|
|
1288
1353
|
error: !!error,
|
|
1354
|
+
required,
|
|
1289
1355
|
helperText: error ? error.message : "",
|
|
1290
1356
|
placeholder,
|
|
1291
1357
|
label,
|
|
1292
1358
|
variant: variant ? variant : "outlined",
|
|
1293
1359
|
sx: {
|
|
1360
|
+
"& .MuiOutlinedInput-root": {
|
|
1361
|
+
bgcolor: disabled ? theme.palette.action.disabledBackground : "transparent"
|
|
1362
|
+
},
|
|
1363
|
+
"& .MuiInputLabel-asterisk": { color: "red" },
|
|
1294
1364
|
"& .MuiInputBase-input": {
|
|
1295
1365
|
cursor: disabled ? "not-allowed" : "default"
|
|
1296
1366
|
},
|
|
1297
|
-
bgcolor: disabled ? theme.palette.action.disabledBackground : "transparent",
|
|
1298
1367
|
...sx
|
|
1299
1368
|
}
|
|
1300
1369
|
}
|
|
@@ -1302,7 +1371,7 @@ var Component10 = function SelectCascadeElement(props) {
|
|
|
1302
1371
|
}
|
|
1303
1372
|
);
|
|
1304
1373
|
};
|
|
1305
|
-
var
|
|
1374
|
+
var SelectCascadeElement = ({
|
|
1306
1375
|
gridProps,
|
|
1307
1376
|
...props
|
|
1308
1377
|
}) => {
|
|
@@ -1311,12 +1380,12 @@ var SelectCascadeElement2 = ({
|
|
|
1311
1380
|
}
|
|
1312
1381
|
return /* @__PURE__ */ jsx10(Component10, { ...props });
|
|
1313
1382
|
};
|
|
1314
|
-
|
|
1315
|
-
var SelectCascadeElement_default =
|
|
1383
|
+
SelectCascadeElement.displayName = "SelectCascadeElement";
|
|
1384
|
+
var SelectCascadeElement_default = SelectCascadeElement;
|
|
1316
1385
|
|
|
1317
1386
|
// src/wrappers/CheckboxElement/CheckboxElement.tsx
|
|
1318
1387
|
import {
|
|
1319
|
-
Checkbox,
|
|
1388
|
+
Checkbox as Checkbox2,
|
|
1320
1389
|
FormControl as FormControl2,
|
|
1321
1390
|
FormControlLabel as FormControlLabel2,
|
|
1322
1391
|
FormGroup,
|
|
@@ -1344,7 +1413,7 @@ var Component11 = function CheckboxElement(props) {
|
|
|
1344
1413
|
label: label || "",
|
|
1345
1414
|
...labelProps,
|
|
1346
1415
|
control: /* @__PURE__ */ jsx11(
|
|
1347
|
-
|
|
1416
|
+
Checkbox2,
|
|
1348
1417
|
{
|
|
1349
1418
|
...rest,
|
|
1350
1419
|
color: rest.color || "primary",
|
|
@@ -1383,14 +1452,14 @@ var CheckboxElement_default = CheckboxElement2;
|
|
|
1383
1452
|
|
|
1384
1453
|
// src/wrappers/CheckboxGroup/CheckboxGroup.tsx
|
|
1385
1454
|
import {
|
|
1386
|
-
Checkbox as
|
|
1455
|
+
Checkbox as Checkbox3,
|
|
1387
1456
|
FormControl as FormControl3,
|
|
1388
1457
|
FormControlLabel as FormControlLabel3,
|
|
1389
1458
|
FormGroup as FormGroup2,
|
|
1390
1459
|
FormHelperText as FormHelperText3,
|
|
1391
1460
|
Grid2 as Grid212
|
|
1392
1461
|
} from "@mui/material";
|
|
1393
|
-
import { useEffect as useEffect6, useState as
|
|
1462
|
+
import { useEffect as useEffect6, useState as useState5 } from "react";
|
|
1394
1463
|
import {
|
|
1395
1464
|
useController as useController12
|
|
1396
1465
|
} from "react-hook-form";
|
|
@@ -1405,7 +1474,7 @@ var Component12 = function CheckboxGroup(props) {
|
|
|
1405
1474
|
control,
|
|
1406
1475
|
disabled: rest.disabled
|
|
1407
1476
|
});
|
|
1408
|
-
const [selectedValues, setSelectedValues] =
|
|
1477
|
+
const [selectedValues, setSelectedValues] = useState5(
|
|
1409
1478
|
options.filter((c) => field.value?.includes(c.Value)).map((c) => c.Value) || []
|
|
1410
1479
|
);
|
|
1411
1480
|
useEffect6(() => {
|
|
@@ -1426,7 +1495,7 @@ var Component12 = function CheckboxGroup(props) {
|
|
|
1426
1495
|
label: option.Label,
|
|
1427
1496
|
...labelProps,
|
|
1428
1497
|
control: /* @__PURE__ */ jsx12(
|
|
1429
|
-
|
|
1498
|
+
Checkbox3,
|
|
1430
1499
|
{
|
|
1431
1500
|
...rest,
|
|
1432
1501
|
color: rest.color || "primary",
|