@gnwebsoft/ui 2.18.38 → 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-KADZH5FM.mjs → chunk-FSU3H777.mjs} +23 -1
- package/dist/{chunk-RWMC36UO.js → chunk-JKUOV3MN.js} +23 -1
- package/dist/{chunk-VOOWINZA.mjs → chunk-RVKKPXZC.mjs} +207 -122
- package/dist/{chunk-DIGNPXO5.js → chunk-VNU4ZOUE.js} +192 -107
- package/dist/components/index.d.mts +8 -1
- package/dist/components/index.d.ts +8 -1
- package/dist/components/index.js +4 -2
- package/dist/components/index.mjs +3 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -3
- package/dist/index.mjs +4 -2
- package/dist/wrappers/index.d.mts +36 -52
- package/dist/wrappers/index.d.ts +36 -52
- package/dist/wrappers/index.js +2 -2
- package/dist/wrappers/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -438,6 +438,27 @@ var AuthorizedView = ({ children, show }) => {
|
|
|
438
438
|
};
|
|
439
439
|
var AuthorizedView_default = AuthorizedView;
|
|
440
440
|
|
|
441
|
+
// src/components/CancelButton/CancelButton.tsx
|
|
442
|
+
import { Button as Button3 } from "@mui/material";
|
|
443
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
444
|
+
var CancelButton = ({
|
|
445
|
+
isSubmitting,
|
|
446
|
+
handleCancel,
|
|
447
|
+
sx
|
|
448
|
+
}) => {
|
|
449
|
+
return /* @__PURE__ */ jsx10(
|
|
450
|
+
Button3,
|
|
451
|
+
{
|
|
452
|
+
variant: "outlined",
|
|
453
|
+
onClick: handleCancel,
|
|
454
|
+
disabled: isSubmitting,
|
|
455
|
+
sx,
|
|
456
|
+
children: "Cancel"
|
|
457
|
+
}
|
|
458
|
+
);
|
|
459
|
+
};
|
|
460
|
+
var CancelButton_default = CancelButton;
|
|
461
|
+
|
|
441
462
|
export {
|
|
442
463
|
ClearButton_default,
|
|
443
464
|
FilterButton_default,
|
|
@@ -447,5 +468,6 @@ export {
|
|
|
447
468
|
ListWrapper_default,
|
|
448
469
|
SimpleToolbar_default,
|
|
449
470
|
SimpleButton_default,
|
|
450
|
-
AuthorizedView_default
|
|
471
|
+
AuthorizedView_default,
|
|
472
|
+
CancelButton_default
|
|
451
473
|
};
|
|
@@ -438,6 +438,28 @@ var AuthorizedView = ({ children, show }) => {
|
|
|
438
438
|
};
|
|
439
439
|
var AuthorizedView_default = AuthorizedView;
|
|
440
440
|
|
|
441
|
+
// src/components/CancelButton/CancelButton.tsx
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
var CancelButton = ({
|
|
445
|
+
isSubmitting,
|
|
446
|
+
handleCancel,
|
|
447
|
+
sx
|
|
448
|
+
}) => {
|
|
449
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
450
|
+
_material.Button,
|
|
451
|
+
{
|
|
452
|
+
variant: "outlined",
|
|
453
|
+
onClick: handleCancel,
|
|
454
|
+
disabled: isSubmitting,
|
|
455
|
+
sx,
|
|
456
|
+
children: "Cancel"
|
|
457
|
+
}
|
|
458
|
+
);
|
|
459
|
+
};
|
|
460
|
+
var CancelButton_default = CancelButton;
|
|
461
|
+
|
|
462
|
+
|
|
441
463
|
|
|
442
464
|
|
|
443
465
|
|
|
@@ -448,4 +470,4 @@ var AuthorizedView_default = AuthorizedView;
|
|
|
448
470
|
|
|
449
471
|
|
|
450
472
|
|
|
451
|
-
exports.ClearButton_default = ClearButton_default; exports.FilterButton_default = FilterButton_default; exports.FilterWrapper_default = FilterWrapper_default; exports.FormWrapper_default = FormWrapper_default; exports.LabelText_default = LabelText_default; exports.ListWrapper_default = ListWrapper_default; exports.SimpleToolbar_default = SimpleToolbar_default; exports.SimpleButton_default = SimpleButton_default; exports.AuthorizedView_default = AuthorizedView_default;
|
|
473
|
+
exports.ClearButton_default = ClearButton_default; exports.FilterButton_default = FilterButton_default; exports.FilterWrapper_default = FilterWrapper_default; exports.FormWrapper_default = FormWrapper_default; exports.LabelText_default = LabelText_default; exports.ListWrapper_default = ListWrapper_default; exports.SimpleToolbar_default = SimpleToolbar_default; exports.SimpleButton_default = SimpleButton_default; exports.AuthorizedView_default = AuthorizedView_default; exports.CancelButton_default = CancelButton_default;
|
|
@@ -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,19 +1003,12 @@ AsyncSelectMultiElement2.displayName = "AsyncSelectMulti";
|
|
|
990
1003
|
var AsyncMultiSelect_default = AsyncSelectMultiElement2;
|
|
991
1004
|
|
|
992
1005
|
// src/wrappers/SelectElement/SelectElement.tsx
|
|
993
|
-
import {
|
|
994
|
-
Autocomplete as Autocomplete3,
|
|
995
|
-
TextField as TextField5,
|
|
996
|
-
Grid2 as Grid28
|
|
997
|
-
} from "@mui/material";
|
|
998
|
-
import { useEffect as useEffect4, useState as useState4 } from "react";
|
|
1006
|
+
import { useMemo as useMemo4, useEffect as useEffect4, useCallback as useCallback4 } from "react";
|
|
999
1007
|
import {
|
|
1000
1008
|
useController as useController8
|
|
1001
1009
|
} from "react-hook-form";
|
|
1010
|
+
import { Grid2 as Grid28, useTheme as useTheme5, TextField as TextField5, Autocomplete as Autocomplete3 } from "@mui/material";
|
|
1002
1011
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1003
|
-
function isOptionType(option, key) {
|
|
1004
|
-
return typeof option === "object" && option !== null && key in option;
|
|
1005
|
-
}
|
|
1006
1012
|
var Component8 = function SelectElement(props) {
|
|
1007
1013
|
const {
|
|
1008
1014
|
name,
|
|
@@ -1011,50 +1017,89 @@ var Component8 = function SelectElement(props) {
|
|
|
1011
1017
|
isEdit,
|
|
1012
1018
|
options,
|
|
1013
1019
|
label,
|
|
1020
|
+
sx,
|
|
1021
|
+
variant,
|
|
1022
|
+
disabled,
|
|
1014
1023
|
labelKey = "Label",
|
|
1015
1024
|
valueKey = "Value",
|
|
1025
|
+
placeholder,
|
|
1026
|
+
textFieldProps = {},
|
|
1016
1027
|
...rest
|
|
1017
1028
|
} = props;
|
|
1018
|
-
const {
|
|
1029
|
+
const { required } = textFieldProps;
|
|
1030
|
+
const {
|
|
1031
|
+
field,
|
|
1032
|
+
fieldState: { error }
|
|
1033
|
+
} = useController8({
|
|
1019
1034
|
name,
|
|
1020
1035
|
control
|
|
1021
1036
|
});
|
|
1022
|
-
const
|
|
1037
|
+
const theme = useTheme5();
|
|
1038
|
+
const getOptionValue = useCallback4(
|
|
1039
|
+
(option) => {
|
|
1040
|
+
if (typeof option === "string") return option;
|
|
1041
|
+
return option ? option[valueKey] : null;
|
|
1042
|
+
},
|
|
1043
|
+
[valueKey]
|
|
1044
|
+
);
|
|
1045
|
+
const getOptionLabel = useCallback4(
|
|
1046
|
+
(option) => {
|
|
1047
|
+
if (typeof option === "string") return option;
|
|
1048
|
+
return option ? String(option[labelKey]) : "";
|
|
1049
|
+
},
|
|
1050
|
+
[labelKey]
|
|
1051
|
+
);
|
|
1023
1052
|
const handleChange = (event, newValue, reason) => {
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
setHasAutoSelected(true);
|
|
1027
|
-
} else {
|
|
1028
|
-
const option = newValue;
|
|
1029
|
-
field.onChange(option[valueKey] ?? null);
|
|
1030
|
-
setHasAutoSelected(true);
|
|
1031
|
-
}
|
|
1053
|
+
const option = newValue;
|
|
1054
|
+
field.onChange(option ? getOptionValue(option) : null);
|
|
1032
1055
|
onChange?.(event, newValue, reason);
|
|
1033
1056
|
};
|
|
1034
1057
|
useEffect4(() => {
|
|
1035
|
-
if (isEdit) {
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
const option = options[0];
|
|
1040
|
-
field.onChange(option);
|
|
1041
|
-
setHasAutoSelected(true);
|
|
1042
|
-
}
|
|
1058
|
+
if (!isEdit && options.length === 1 && (field.value == null || field.value == void 0 || field.value === "")) {
|
|
1059
|
+
const defaultOption = options[0];
|
|
1060
|
+
const defaultValue = getOptionValue(defaultOption);
|
|
1061
|
+
field.onChange(defaultValue);
|
|
1043
1062
|
}
|
|
1044
|
-
}, [
|
|
1063
|
+
}, [isEdit, options]);
|
|
1064
|
+
const autocompleteValue = useMemo4(
|
|
1065
|
+
() => options.find((option) => getOptionValue(option) === field.value) ?? null,
|
|
1066
|
+
[field.value, options, getOptionValue]
|
|
1067
|
+
);
|
|
1045
1068
|
return /* @__PURE__ */ jsx8(
|
|
1046
1069
|
Autocomplete3,
|
|
1047
1070
|
{
|
|
1048
1071
|
...rest,
|
|
1049
1072
|
filterSelectedOptions: false,
|
|
1050
1073
|
options,
|
|
1051
|
-
value:
|
|
1052
|
-
(option) => isOptionType(option, valueKey) && field.value === option[valueKey]
|
|
1053
|
-
) ?? null : null,
|
|
1074
|
+
value: autocompleteValue,
|
|
1054
1075
|
onChange: handleChange,
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1076
|
+
disabled,
|
|
1077
|
+
getOptionLabel: (option) => getOptionLabel(option),
|
|
1078
|
+
ref: field.ref,
|
|
1079
|
+
isOptionEqualToValue: (option, value) => getOptionValue(option) === getOptionValue(value),
|
|
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
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
)
|
|
1058
1103
|
}
|
|
1059
1104
|
);
|
|
1060
1105
|
};
|
|
@@ -1071,29 +1116,26 @@ SelectElement2.displayName = "SelectElement";
|
|
|
1071
1116
|
var SelectElement_default = SelectElement2;
|
|
1072
1117
|
|
|
1073
1118
|
// src/wrappers/SelectMultiElement/SelectMultiElement.tsx
|
|
1074
|
-
import {
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
} from "@mui/material";
|
|
1080
|
-
import {
|
|
1081
|
-
useController as useController9
|
|
1082
|
-
} from "react-hook-form";
|
|
1083
|
-
import { Fragment as Fragment3, useState as useState5 } 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";
|
|
1084
1124
|
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1085
1125
|
var Component9 = function SelectMultiElement(props) {
|
|
1086
1126
|
const {
|
|
1087
1127
|
name,
|
|
1128
|
+
control,
|
|
1088
1129
|
onBlur,
|
|
1089
1130
|
disabled,
|
|
1090
1131
|
options,
|
|
1091
|
-
control,
|
|
1092
1132
|
loading = false,
|
|
1093
1133
|
placeholder,
|
|
1094
1134
|
label,
|
|
1095
1135
|
variant,
|
|
1096
1136
|
sx,
|
|
1137
|
+
labelKey = "Label",
|
|
1138
|
+
valueKey = "Value",
|
|
1097
1139
|
...rest
|
|
1098
1140
|
} = props;
|
|
1099
1141
|
const {
|
|
@@ -1103,27 +1145,38 @@ var Component9 = function SelectMultiElement(props) {
|
|
|
1103
1145
|
name,
|
|
1104
1146
|
control
|
|
1105
1147
|
});
|
|
1106
|
-
const
|
|
1107
|
-
|
|
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) => {
|
|
1108
1158
|
if (reason === "clear") {
|
|
1109
|
-
setSelectedOptions([]);
|
|
1110
1159
|
field.onChange([]);
|
|
1111
1160
|
} else if (reason === "selectOption" || reason === "removeOption") {
|
|
1112
|
-
|
|
1113
|
-
field.onChange(
|
|
1161
|
+
const newValues = selectedOptions.map((option) => getOptionValue(option));
|
|
1162
|
+
field.onChange(newValues);
|
|
1114
1163
|
}
|
|
1115
1164
|
};
|
|
1165
|
+
const icon = /* @__PURE__ */ jsx9(CheckBoxOutlineBlankIcon, { fontSize: "small" });
|
|
1166
|
+
const checkedIcon = /* @__PURE__ */ jsx9(CheckBoxIcon, { fontSize: "small" });
|
|
1116
1167
|
return /* @__PURE__ */ jsx9(
|
|
1117
1168
|
Autocomplete4,
|
|
1118
1169
|
{
|
|
1119
1170
|
multiple: true,
|
|
1120
|
-
value:
|
|
1171
|
+
value: selectedValue,
|
|
1121
1172
|
loading,
|
|
1122
1173
|
options,
|
|
1123
|
-
getOptionLabel
|
|
1174
|
+
getOptionLabel,
|
|
1175
|
+
isOptionEqualToValue: (option, value) => getOptionValue(option) === getOptionValue(value),
|
|
1124
1176
|
filterSelectedOptions: true,
|
|
1177
|
+
disableCloseOnSelect: true,
|
|
1125
1178
|
ref: field.ref,
|
|
1126
|
-
disabled: field.disabled,
|
|
1179
|
+
disabled: disabled ?? field.disabled,
|
|
1127
1180
|
onChange: handleChange,
|
|
1128
1181
|
onBlur: (event) => {
|
|
1129
1182
|
field.onBlur();
|
|
@@ -1132,6 +1185,13 @@ var Component9 = function SelectMultiElement(props) {
|
|
|
1132
1185
|
}
|
|
1133
1186
|
},
|
|
1134
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
|
+
},
|
|
1135
1195
|
renderInput: (params) => /* @__PURE__ */ jsx9(
|
|
1136
1196
|
TextField6,
|
|
1137
1197
|
{
|
|
@@ -1172,36 +1232,54 @@ SelectMultiElement2.displayName = "SelectMultiElement";
|
|
|
1172
1232
|
var SelectMultiElement_default = SelectMultiElement2;
|
|
1173
1233
|
|
|
1174
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";
|
|
1175
1239
|
import {
|
|
1176
|
-
Autocomplete as Autocomplete5,
|
|
1177
1240
|
Grid2 as Grid210,
|
|
1241
|
+
useTheme as useTheme6,
|
|
1178
1242
|
TextField as TextField7,
|
|
1179
|
-
|
|
1243
|
+
Autocomplete as Autocomplete5
|
|
1180
1244
|
} from "@mui/material";
|
|
1181
|
-
import { useEffect as useEffect5, useRef as useRef3, useState as useState6 } from "react";
|
|
1182
|
-
import {
|
|
1183
|
-
useController as useController10
|
|
1184
|
-
} from "react-hook-form";
|
|
1185
1245
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1186
|
-
var Component10 = function
|
|
1246
|
+
var Component10 = function SelectCascadeElement2(props) {
|
|
1187
1247
|
const {
|
|
1248
|
+
labelKey = "Label",
|
|
1249
|
+
valueKey = "Value",
|
|
1188
1250
|
name,
|
|
1189
1251
|
onBlur,
|
|
1190
1252
|
onChange,
|
|
1191
1253
|
disabled,
|
|
1192
1254
|
options,
|
|
1193
1255
|
control,
|
|
1194
|
-
gridProps,
|
|
1195
1256
|
loading = false,
|
|
1196
1257
|
placeholder,
|
|
1197
1258
|
label,
|
|
1198
1259
|
dependsOn,
|
|
1199
|
-
|
|
1260
|
+
textFieldProps = {},
|
|
1200
1261
|
variant,
|
|
1201
1262
|
sx,
|
|
1202
1263
|
isEdit = false,
|
|
1203
1264
|
...rest
|
|
1204
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);
|
|
1205
1283
|
const {
|
|
1206
1284
|
field,
|
|
1207
1285
|
fieldState: { error }
|
|
@@ -1209,50 +1287,53 @@ var Component10 = function SelectCascadeElement(props) {
|
|
|
1209
1287
|
name,
|
|
1210
1288
|
control
|
|
1211
1289
|
});
|
|
1212
|
-
const theme =
|
|
1290
|
+
const theme = useTheme6();
|
|
1213
1291
|
const { field: dependentField } = useController10({
|
|
1214
1292
|
name: dependsOn,
|
|
1215
1293
|
control
|
|
1216
1294
|
});
|
|
1217
1295
|
const parentValueRef = useRef3(dependentField.value ?? null);
|
|
1218
1296
|
useEffect5(() => {
|
|
1219
|
-
if (!!dependentField.value && parentValueRef?.current
|
|
1297
|
+
if (!!dependentField.value && parentValueRef?.current !== dependentField.value || dependentField.value === null) {
|
|
1220
1298
|
field.onChange(null);
|
|
1221
1299
|
}
|
|
1222
|
-
}, [dependentField.value]);
|
|
1223
|
-
|
|
1224
|
-
if (initialValue) {
|
|
1225
|
-
field.onChange(initialValue);
|
|
1226
|
-
}
|
|
1227
|
-
}, [initialValue]);
|
|
1228
|
-
const [hasAutoSelected, setHasAutoSelected] = useState6(false);
|
|
1300
|
+
}, [dependentField.value, field]);
|
|
1301
|
+
const [hasAutoSelected, setHasAutoSelected] = useState4(false);
|
|
1229
1302
|
useEffect5(() => {
|
|
1230
1303
|
if (isEdit && !disabled && options.length === 1 && field.value == null && !hasAutoSelected) {
|
|
1231
|
-
field.onChange(options[0]
|
|
1304
|
+
field.onChange(getOptionKey(options[0]));
|
|
1232
1305
|
setHasAutoSelected(true);
|
|
1233
1306
|
} else {
|
|
1234
1307
|
if (options.length === 1 && field.value == null && !hasAutoSelected) {
|
|
1235
|
-
field.onChange(options[0]
|
|
1308
|
+
field.onChange(getOptionKey(options[0]));
|
|
1236
1309
|
setHasAutoSelected(true);
|
|
1237
1310
|
}
|
|
1238
1311
|
}
|
|
1239
|
-
}, [
|
|
1312
|
+
}, [
|
|
1313
|
+
options,
|
|
1314
|
+
field.value,
|
|
1315
|
+
field.onChange,
|
|
1316
|
+
hasAutoSelected,
|
|
1317
|
+
isEdit,
|
|
1318
|
+
disabled,
|
|
1319
|
+
field,
|
|
1320
|
+
getOptionKey
|
|
1321
|
+
]);
|
|
1240
1322
|
return /* @__PURE__ */ jsx10(
|
|
1241
1323
|
Autocomplete5,
|
|
1242
1324
|
{
|
|
1243
1325
|
...rest,
|
|
1244
|
-
value: field.value
|
|
1245
|
-
return field.value === option.Value;
|
|
1246
|
-
}) ?? null : null,
|
|
1326
|
+
value: options.map((option) => getOptionKey(option) === field.value ? option : null).find(Boolean) || null,
|
|
1247
1327
|
size: "small",
|
|
1248
1328
|
loading,
|
|
1249
1329
|
options,
|
|
1250
|
-
|
|
1251
|
-
|
|
1330
|
+
getOptionKey,
|
|
1331
|
+
getOptionLabel,
|
|
1332
|
+
isOptionEqualToValue,
|
|
1252
1333
|
ref: field.ref,
|
|
1253
1334
|
disabled,
|
|
1254
1335
|
onChange: (event, newValue, reason) => {
|
|
1255
|
-
field.onChange(newValue ? newValue
|
|
1336
|
+
field.onChange(newValue ? getOptionKey(newValue) : null);
|
|
1256
1337
|
if (onChange && typeof onChange === "function") {
|
|
1257
1338
|
onChange(event, newValue, reason);
|
|
1258
1339
|
}
|
|
@@ -1270,15 +1351,19 @@ var Component10 = function SelectCascadeElement(props) {
|
|
|
1270
1351
|
...params,
|
|
1271
1352
|
fullWidth: true,
|
|
1272
1353
|
error: !!error,
|
|
1354
|
+
required,
|
|
1273
1355
|
helperText: error ? error.message : "",
|
|
1274
1356
|
placeholder,
|
|
1275
1357
|
label,
|
|
1276
1358
|
variant: variant ? variant : "outlined",
|
|
1277
1359
|
sx: {
|
|
1360
|
+
"& .MuiOutlinedInput-root": {
|
|
1361
|
+
bgcolor: disabled ? theme.palette.action.disabledBackground : "transparent"
|
|
1362
|
+
},
|
|
1363
|
+
"& .MuiInputLabel-asterisk": { color: "red" },
|
|
1278
1364
|
"& .MuiInputBase-input": {
|
|
1279
1365
|
cursor: disabled ? "not-allowed" : "default"
|
|
1280
1366
|
},
|
|
1281
|
-
bgcolor: disabled ? theme.palette.action.disabledBackground : "transparent",
|
|
1282
1367
|
...sx
|
|
1283
1368
|
}
|
|
1284
1369
|
}
|
|
@@ -1286,7 +1371,7 @@ var Component10 = function SelectCascadeElement(props) {
|
|
|
1286
1371
|
}
|
|
1287
1372
|
);
|
|
1288
1373
|
};
|
|
1289
|
-
var
|
|
1374
|
+
var SelectCascadeElement = ({
|
|
1290
1375
|
gridProps,
|
|
1291
1376
|
...props
|
|
1292
1377
|
}) => {
|
|
@@ -1295,12 +1380,12 @@ var SelectCascadeElement2 = ({
|
|
|
1295
1380
|
}
|
|
1296
1381
|
return /* @__PURE__ */ jsx10(Component10, { ...props });
|
|
1297
1382
|
};
|
|
1298
|
-
|
|
1299
|
-
var SelectCascadeElement_default =
|
|
1383
|
+
SelectCascadeElement.displayName = "SelectCascadeElement";
|
|
1384
|
+
var SelectCascadeElement_default = SelectCascadeElement;
|
|
1300
1385
|
|
|
1301
1386
|
// src/wrappers/CheckboxElement/CheckboxElement.tsx
|
|
1302
1387
|
import {
|
|
1303
|
-
Checkbox,
|
|
1388
|
+
Checkbox as Checkbox2,
|
|
1304
1389
|
FormControl as FormControl2,
|
|
1305
1390
|
FormControlLabel as FormControlLabel2,
|
|
1306
1391
|
FormGroup,
|
|
@@ -1328,7 +1413,7 @@ var Component11 = function CheckboxElement(props) {
|
|
|
1328
1413
|
label: label || "",
|
|
1329
1414
|
...labelProps,
|
|
1330
1415
|
control: /* @__PURE__ */ jsx11(
|
|
1331
|
-
|
|
1416
|
+
Checkbox2,
|
|
1332
1417
|
{
|
|
1333
1418
|
...rest,
|
|
1334
1419
|
color: rest.color || "primary",
|
|
@@ -1367,14 +1452,14 @@ var CheckboxElement_default = CheckboxElement2;
|
|
|
1367
1452
|
|
|
1368
1453
|
// src/wrappers/CheckboxGroup/CheckboxGroup.tsx
|
|
1369
1454
|
import {
|
|
1370
|
-
Checkbox as
|
|
1455
|
+
Checkbox as Checkbox3,
|
|
1371
1456
|
FormControl as FormControl3,
|
|
1372
1457
|
FormControlLabel as FormControlLabel3,
|
|
1373
1458
|
FormGroup as FormGroup2,
|
|
1374
1459
|
FormHelperText as FormHelperText3,
|
|
1375
1460
|
Grid2 as Grid212
|
|
1376
1461
|
} from "@mui/material";
|
|
1377
|
-
import { useEffect as useEffect6, useState as
|
|
1462
|
+
import { useEffect as useEffect6, useState as useState5 } from "react";
|
|
1378
1463
|
import {
|
|
1379
1464
|
useController as useController12
|
|
1380
1465
|
} from "react-hook-form";
|
|
@@ -1389,7 +1474,7 @@ var Component12 = function CheckboxGroup(props) {
|
|
|
1389
1474
|
control,
|
|
1390
1475
|
disabled: rest.disabled
|
|
1391
1476
|
});
|
|
1392
|
-
const [selectedValues, setSelectedValues] =
|
|
1477
|
+
const [selectedValues, setSelectedValues] = useState5(
|
|
1393
1478
|
options.filter((c) => field.value?.includes(c.Value)).map((c) => c.Value) || []
|
|
1394
1479
|
);
|
|
1395
1480
|
useEffect6(() => {
|
|
@@ -1410,7 +1495,7 @@ var Component12 = function CheckboxGroup(props) {
|
|
|
1410
1495
|
label: option.Label,
|
|
1411
1496
|
...labelProps,
|
|
1412
1497
|
control: /* @__PURE__ */ jsx12(
|
|
1413
|
-
|
|
1498
|
+
Checkbox3,
|
|
1414
1499
|
{
|
|
1415
1500
|
...rest,
|
|
1416
1501
|
color: rest.color || "primary",
|