@gnwebsoft/ui 2.18.39 → 2.18.41
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/{AsyncSelectPayload-CiwoX8EE.d.mts → AsyncSelectPayload-Cz4bgak0.d.mts} +2 -2
- package/dist/{AsyncSelectPayload-CiwoX8EE.d.ts → AsyncSelectPayload-Cz4bgak0.d.ts} +2 -2
- package/dist/{chunk-NTUP43A7.js → chunk-4XSPG2IF.js} +197 -128
- package/dist/{chunk-DKBPCLEC.js → chunk-FYN7F5WJ.js} +0 -2
- package/dist/{chunk-AVNKSUE5.mjs → chunk-GAYZ4QSD.mjs} +0 -2
- package/dist/{chunk-OHRT3LMC.mjs → chunk-H7MQZPJ6.mjs} +212 -143
- package/dist/{chunk-STC2BZ2L.js → chunk-IZSKZD5M.js} +3 -3
- package/dist/{chunk-34X2YRTY.mjs → chunk-MM6OQZAY.mjs} +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/index.mjs +3 -3
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +2 -2
- package/dist/utils/index.mjs +1 -1
- package/dist/wrappers/index.d.mts +43 -70
- package/dist/wrappers/index.d.ts +43 -70
- package/dist/wrappers/index.js +3 -3
- package/dist/wrappers/index.mjs +2 -2
- package/dist/wrappers2/index.d.mts +1 -1
- package/dist/wrappers2/index.d.ts +1 -1
- package/dist/wrappers2/index.js +3 -3
- package/dist/wrappers2/index.mjs +2 -2
- package/package.json +1 -1
|
@@ -3,41 +3,48 @@ import {
|
|
|
3
3
|
} from "./chunk-GFSTK7KN.mjs";
|
|
4
4
|
import {
|
|
5
5
|
readValueAsDate
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-GAYZ4QSD.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 }
|
|
@@ -568,21 +581,14 @@ var TimePickerElement2 = ({
|
|
|
568
581
|
TimePickerElement2.displayName = "TimePickerElement";
|
|
569
582
|
var TimePickerElement_default = TimePickerElement2;
|
|
570
583
|
|
|
571
|
-
// src/wrappers/AsyncSelect/
|
|
584
|
+
// src/wrappers/AsyncSelect/AsyncSelectElement.tsx
|
|
572
585
|
import * as React from "react";
|
|
586
|
+
import { useController as useController6 } from "react-hook-form";
|
|
587
|
+
import { useRef, useMemo as useMemo2, Fragment, useState as useState2, useEffect as useEffect2, useCallback as useCallback2 } from "react";
|
|
588
|
+
import { debounce } from "@mui/material/utils";
|
|
573
589
|
import TextField3 from "@mui/material/TextField";
|
|
574
590
|
import Autocomplete from "@mui/material/Autocomplete";
|
|
575
|
-
import {
|
|
576
|
-
import {
|
|
577
|
-
Fragment,
|
|
578
|
-
useCallback,
|
|
579
|
-
useEffect as useEffect2,
|
|
580
|
-
useMemo,
|
|
581
|
-
useRef,
|
|
582
|
-
useState as useState2
|
|
583
|
-
} from "react";
|
|
584
|
-
import { useController as useController6 } from "react-hook-form";
|
|
585
|
-
import { CircularProgress, Grid2 as Grid26, useTheme as useTheme3 } from "@mui/material";
|
|
591
|
+
import { Grid2 as Grid26, useTheme as useTheme3, CircularProgress } from "@mui/material";
|
|
586
592
|
import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
587
593
|
var Component6 = function AsyncSelectElement(props) {
|
|
588
594
|
const {
|
|
@@ -596,6 +602,8 @@ var Component6 = function AsyncSelectElement(props) {
|
|
|
596
602
|
label,
|
|
597
603
|
queryFn,
|
|
598
604
|
variant,
|
|
605
|
+
labelKey = "Label",
|
|
606
|
+
valueKey = "Value",
|
|
599
607
|
sx,
|
|
600
608
|
...rest
|
|
601
609
|
} = props;
|
|
@@ -610,23 +618,17 @@ var Component6 = function AsyncSelectElement(props) {
|
|
|
610
618
|
const [loading, setLoading] = useState2(false);
|
|
611
619
|
const [selectedOption, setSelectedOption] = useState2(null);
|
|
612
620
|
const [inputValue, setInputValue] = useState2("");
|
|
613
|
-
const inputValue2 =
|
|
614
|
-
const setInputValue2 =
|
|
615
|
-
(inputValue3) => setInputValue(inputValue3),
|
|
616
|
-
[]
|
|
617
|
-
);
|
|
621
|
+
const inputValue2 = useMemo2(() => inputValue, [inputValue]);
|
|
622
|
+
const setInputValue2 = useCallback2((newValue) => setInputValue(newValue), []);
|
|
618
623
|
const [options, setOptions] = useState2([]);
|
|
619
624
|
const initialValueLoaded = useRef(
|
|
620
|
-
!initialValue ? true : !(initialValue != null
|
|
625
|
+
!initialValue ? true : !(initialValue != null)
|
|
621
626
|
);
|
|
622
627
|
const fieldValue = useRef(field.value);
|
|
623
|
-
const fetchData =
|
|
624
|
-
() => debounce(
|
|
625
|
-
(payload
|
|
626
|
-
|
|
627
|
-
},
|
|
628
|
-
400
|
|
629
|
-
),
|
|
628
|
+
const fetchData = useMemo2(
|
|
629
|
+
() => debounce((payload, callback) => {
|
|
630
|
+
queryFn(payload).then((c) => callback(c));
|
|
631
|
+
}, 400),
|
|
630
632
|
[]
|
|
631
633
|
);
|
|
632
634
|
const fillOptions = (results) => {
|
|
@@ -671,7 +673,7 @@ var Component6 = function AsyncSelectElement(props) {
|
|
|
671
673
|
setLoading(false);
|
|
672
674
|
return void 0;
|
|
673
675
|
}
|
|
674
|
-
if (
|
|
676
|
+
if (fieldValue.current) {
|
|
675
677
|
if (field.value === fieldValue.current) {
|
|
676
678
|
return void 0;
|
|
677
679
|
}
|
|
@@ -691,16 +693,16 @@ var Component6 = function AsyncSelectElement(props) {
|
|
|
691
693
|
};
|
|
692
694
|
}, [initialValue, inputValue2, fetchData]);
|
|
693
695
|
const selectRef = useRef(null);
|
|
694
|
-
const handleChange = (_2,
|
|
696
|
+
const handleChange = (_2, newSelectedOption, reason) => {
|
|
695
697
|
if (reason === "clear") {
|
|
696
698
|
setSelectedOption(null);
|
|
697
699
|
field.onChange(null);
|
|
698
700
|
setLoading(false);
|
|
699
701
|
} else if (reason === "selectOption" || reason === "removeOption") {
|
|
700
|
-
if (
|
|
701
|
-
setSelectedOption(
|
|
702
|
-
field.onChange(
|
|
703
|
-
fieldValue.current =
|
|
702
|
+
if (newSelectedOption) {
|
|
703
|
+
setSelectedOption(newSelectedOption);
|
|
704
|
+
field.onChange(newSelectedOption.Value);
|
|
705
|
+
fieldValue.current = newSelectedOption.Value;
|
|
704
706
|
setLoading(false);
|
|
705
707
|
}
|
|
706
708
|
}
|
|
@@ -714,6 +716,14 @@ var Component6 = function AsyncSelectElement(props) {
|
|
|
714
716
|
setLoading(false);
|
|
715
717
|
}
|
|
716
718
|
}, [field.value]);
|
|
719
|
+
const getOptionValue = (option) => {
|
|
720
|
+
if (typeof option === "string") return option;
|
|
721
|
+
return option ? option[valueKey] : null;
|
|
722
|
+
};
|
|
723
|
+
const getOptionLabel = (option) => {
|
|
724
|
+
if (typeof option === "string") return option;
|
|
725
|
+
return option ? option[labelKey] : "";
|
|
726
|
+
};
|
|
717
727
|
return /* @__PURE__ */ jsx6(
|
|
718
728
|
Autocomplete,
|
|
719
729
|
{
|
|
@@ -721,13 +731,14 @@ var Component6 = function AsyncSelectElement(props) {
|
|
|
721
731
|
ref: selectRef,
|
|
722
732
|
fullWidth: true,
|
|
723
733
|
loading,
|
|
724
|
-
getOptionLabel
|
|
725
|
-
getOptionKey:
|
|
726
|
-
isOptionEqualToValue: (option,
|
|
734
|
+
getOptionLabel,
|
|
735
|
+
getOptionKey: getOptionValue,
|
|
736
|
+
isOptionEqualToValue: (option, value) => getOptionValue(option) === getOptionValue(value),
|
|
727
737
|
autoComplete: true,
|
|
728
738
|
disabled,
|
|
729
739
|
includeInputInList: true,
|
|
730
740
|
options,
|
|
741
|
+
filterOptions: (x) => x,
|
|
731
742
|
value: selectedOption,
|
|
732
743
|
filterSelectedOptions: true,
|
|
733
744
|
onChange: handleChange,
|
|
@@ -762,8 +773,8 @@ var Component6 = function AsyncSelectElement(props) {
|
|
|
762
773
|
}
|
|
763
774
|
}
|
|
764
775
|
),
|
|
765
|
-
renderOption: (
|
|
766
|
-
const { key, ...optionProps } =
|
|
776
|
+
renderOption: (renderProps, option) => {
|
|
777
|
+
const { key, ...optionProps } = renderProps;
|
|
767
778
|
return /* @__PURE__ */ jsx6("li", { ...optionProps, children: option.Label }, key);
|
|
768
779
|
}
|
|
769
780
|
}
|
|
@@ -779,16 +790,16 @@ var AsyncSelectElement2 = ({
|
|
|
779
790
|
return /* @__PURE__ */ jsx6(Component6, { ...props });
|
|
780
791
|
};
|
|
781
792
|
AsyncSelectElement2.displayName = "AsyncSelectElement";
|
|
782
|
-
var
|
|
793
|
+
var AsyncSelectElement_default = AsyncSelectElement2;
|
|
783
794
|
|
|
784
795
|
// src/wrappers/AsyncMultiSelect/AsyncMultiSelect.tsx
|
|
785
796
|
import _ from "lodash";
|
|
786
797
|
import {
|
|
787
798
|
useState as useState3,
|
|
788
799
|
useRef as useRef2,
|
|
789
|
-
useMemo as
|
|
800
|
+
useMemo as useMemo3,
|
|
790
801
|
useEffect as useEffect3,
|
|
791
|
-
useCallback as
|
|
802
|
+
useCallback as useCallback3,
|
|
792
803
|
Fragment as Fragment2
|
|
793
804
|
} from "react";
|
|
794
805
|
import { debounce as debounce2 } from "lodash";
|
|
@@ -834,12 +845,12 @@ var Component7 = function AsyncSelectMultiElement(props) {
|
|
|
834
845
|
const initialValuesLoaded = useRef2(
|
|
835
846
|
!(initialValues && initialValues.length > 0)
|
|
836
847
|
);
|
|
837
|
-
const inputValue2 =
|
|
838
|
-
const setInputValue2 =
|
|
848
|
+
const inputValue2 = useMemo3(() => inputValue, [inputValue]);
|
|
849
|
+
const setInputValue2 = useCallback3(
|
|
839
850
|
(inputValue3) => setInputValue(inputValue3),
|
|
840
851
|
[]
|
|
841
852
|
);
|
|
842
|
-
const fetchData =
|
|
853
|
+
const fetchData = useMemo3(
|
|
843
854
|
() => debounce2(
|
|
844
855
|
(payload, callback) => {
|
|
845
856
|
queryFn(payload).then((c) => callback(c));
|
|
@@ -990,12 +1001,11 @@ AsyncSelectMultiElement2.displayName = "AsyncSelectMulti";
|
|
|
990
1001
|
var AsyncMultiSelect_default = AsyncSelectMultiElement2;
|
|
991
1002
|
|
|
992
1003
|
// src/wrappers/SelectElement/SelectElement.tsx
|
|
993
|
-
import { useMemo as
|
|
994
|
-
import { useEffect as useEffect4 } from "react";
|
|
1004
|
+
import { useMemo as useMemo4, useEffect as useEffect4, useCallback as useCallback4 } from "react";
|
|
995
1005
|
import {
|
|
996
1006
|
useController as useController8
|
|
997
1007
|
} from "react-hook-form";
|
|
998
|
-
import { Grid2 as Grid28, TextField as TextField5, Autocomplete as Autocomplete3 } from "@mui/material";
|
|
1008
|
+
import { Grid2 as Grid28, useTheme as useTheme5, TextField as TextField5, Autocomplete as Autocomplete3 } from "@mui/material";
|
|
999
1009
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1000
1010
|
var Component8 = function SelectElement(props) {
|
|
1001
1011
|
const {
|
|
@@ -1005,24 +1015,32 @@ var Component8 = function SelectElement(props) {
|
|
|
1005
1015
|
isEdit,
|
|
1006
1016
|
options,
|
|
1007
1017
|
label,
|
|
1018
|
+
sx,
|
|
1019
|
+
variant,
|
|
1020
|
+
disabled,
|
|
1008
1021
|
labelKey = "Label",
|
|
1009
1022
|
valueKey = "Value",
|
|
1023
|
+
placeholder,
|
|
1010
1024
|
textFieldProps = {},
|
|
1011
1025
|
...rest
|
|
1012
1026
|
} = props;
|
|
1013
|
-
const { required
|
|
1014
|
-
const {
|
|
1027
|
+
const { required } = textFieldProps;
|
|
1028
|
+
const {
|
|
1029
|
+
field,
|
|
1030
|
+
fieldState: { error }
|
|
1031
|
+
} = useController8({
|
|
1015
1032
|
name,
|
|
1016
1033
|
control
|
|
1017
1034
|
});
|
|
1018
|
-
const
|
|
1035
|
+
const theme = useTheme5();
|
|
1036
|
+
const getOptionValue = useCallback4(
|
|
1019
1037
|
(option) => {
|
|
1020
1038
|
if (typeof option === "string") return option;
|
|
1021
1039
|
return option ? option[valueKey] : null;
|
|
1022
1040
|
},
|
|
1023
1041
|
[valueKey]
|
|
1024
1042
|
);
|
|
1025
|
-
const getOptionLabel =
|
|
1043
|
+
const getOptionLabel = useCallback4(
|
|
1026
1044
|
(option) => {
|
|
1027
1045
|
if (typeof option === "string") return option;
|
|
1028
1046
|
return option ? String(option[labelKey]) : "";
|
|
@@ -1040,8 +1058,8 @@ var Component8 = function SelectElement(props) {
|
|
|
1040
1058
|
const defaultValue = getOptionValue(defaultOption);
|
|
1041
1059
|
field.onChange(defaultValue);
|
|
1042
1060
|
}
|
|
1043
|
-
}, [isEdit, options
|
|
1044
|
-
const autocompleteValue =
|
|
1061
|
+
}, [isEdit, options]);
|
|
1062
|
+
const autocompleteValue = useMemo4(
|
|
1045
1063
|
() => options.find((option) => getOptionValue(option) === field.value) ?? null,
|
|
1046
1064
|
[field.value, options, getOptionValue]
|
|
1047
1065
|
);
|
|
@@ -1053,24 +1071,33 @@ var Component8 = function SelectElement(props) {
|
|
|
1053
1071
|
options,
|
|
1054
1072
|
value: autocompleteValue,
|
|
1055
1073
|
onChange: handleChange,
|
|
1074
|
+
disabled,
|
|
1056
1075
|
getOptionLabel: (option) => getOptionLabel(option),
|
|
1076
|
+
ref: field.ref,
|
|
1057
1077
|
isOptionEqualToValue: (option, value) => getOptionValue(option) === getOptionValue(value),
|
|
1058
|
-
renderInput: (params) =>
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1078
|
+
renderInput: (params) => /* @__PURE__ */ jsx8(
|
|
1079
|
+
TextField5,
|
|
1080
|
+
{
|
|
1081
|
+
...params,
|
|
1082
|
+
fullWidth: true,
|
|
1083
|
+
required,
|
|
1084
|
+
error: !!error,
|
|
1085
|
+
helperText: error ? error.message : "",
|
|
1086
|
+
label,
|
|
1087
|
+
placeholder,
|
|
1088
|
+
variant: variant ? variant : "outlined",
|
|
1089
|
+
sx: {
|
|
1090
|
+
"& .MuiOutlinedInput-root": {
|
|
1091
|
+
bgcolor: disabled ? theme.palette.action.disabledBackground : "transparent"
|
|
1092
|
+
},
|
|
1093
|
+
"& .MuiInputLabel-asterisk": { color: "red" },
|
|
1094
|
+
"& .MuiInputBase-input": {
|
|
1095
|
+
cursor: disabled ? "not-allowed" : "default"
|
|
1096
|
+
},
|
|
1097
|
+
...sx
|
|
1071
1098
|
}
|
|
1072
|
-
|
|
1073
|
-
|
|
1099
|
+
}
|
|
1100
|
+
)
|
|
1074
1101
|
}
|
|
1075
1102
|
);
|
|
1076
1103
|
};
|
|
@@ -1087,29 +1114,26 @@ SelectElement2.displayName = "SelectElement";
|
|
|
1087
1114
|
var SelectElement_default = SelectElement2;
|
|
1088
1115
|
|
|
1089
1116
|
// 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";
|
|
1117
|
+
import { Fragment as Fragment3 } from "react";
|
|
1118
|
+
import { useController as useController9 } from "react-hook-form";
|
|
1119
|
+
import CheckBoxIcon from "@mui/icons-material/CheckBox";
|
|
1120
|
+
import CheckBoxOutlineBlankIcon from "@mui/icons-material/CheckBoxOutlineBlank";
|
|
1121
|
+
import { Grid2 as Grid29, Checkbox, TextField as TextField6, Autocomplete as Autocomplete4, CircularProgress as CircularProgress3 } from "@mui/material";
|
|
1100
1122
|
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1101
1123
|
var Component9 = function SelectMultiElement(props) {
|
|
1102
1124
|
const {
|
|
1103
1125
|
name,
|
|
1126
|
+
control,
|
|
1104
1127
|
onBlur,
|
|
1105
1128
|
disabled,
|
|
1106
1129
|
options,
|
|
1107
|
-
control,
|
|
1108
1130
|
loading = false,
|
|
1109
1131
|
placeholder,
|
|
1110
1132
|
label,
|
|
1111
1133
|
variant,
|
|
1112
1134
|
sx,
|
|
1135
|
+
labelKey = "Label",
|
|
1136
|
+
valueKey = "Value",
|
|
1113
1137
|
...rest
|
|
1114
1138
|
} = props;
|
|
1115
1139
|
const {
|
|
@@ -1119,27 +1143,38 @@ var Component9 = function SelectMultiElement(props) {
|
|
|
1119
1143
|
name,
|
|
1120
1144
|
control
|
|
1121
1145
|
});
|
|
1122
|
-
const
|
|
1123
|
-
|
|
1146
|
+
const getOptionValue = (option) => {
|
|
1147
|
+
if (typeof option === "string") return option;
|
|
1148
|
+
return option ? option[valueKey] : null;
|
|
1149
|
+
};
|
|
1150
|
+
const getOptionLabel = (option) => {
|
|
1151
|
+
if (typeof option === "string") return option;
|
|
1152
|
+
return option ? option[labelKey] : "";
|
|
1153
|
+
};
|
|
1154
|
+
const selectedValue = field.value && Array.isArray(field.value) ? options.filter((option) => field.value.includes(getOptionValue(option))) : [];
|
|
1155
|
+
const handleChange = (_2, selectedOptions, reason) => {
|
|
1124
1156
|
if (reason === "clear") {
|
|
1125
|
-
setSelectedOptions([]);
|
|
1126
1157
|
field.onChange([]);
|
|
1127
1158
|
} else if (reason === "selectOption" || reason === "removeOption") {
|
|
1128
|
-
|
|
1129
|
-
field.onChange(
|
|
1159
|
+
const newValues = selectedOptions.map((option) => getOptionValue(option));
|
|
1160
|
+
field.onChange(newValues);
|
|
1130
1161
|
}
|
|
1131
1162
|
};
|
|
1163
|
+
const icon = /* @__PURE__ */ jsx9(CheckBoxOutlineBlankIcon, { fontSize: "small" });
|
|
1164
|
+
const checkedIcon = /* @__PURE__ */ jsx9(CheckBoxIcon, { fontSize: "small" });
|
|
1132
1165
|
return /* @__PURE__ */ jsx9(
|
|
1133
1166
|
Autocomplete4,
|
|
1134
1167
|
{
|
|
1135
1168
|
multiple: true,
|
|
1136
|
-
value:
|
|
1169
|
+
value: selectedValue,
|
|
1137
1170
|
loading,
|
|
1138
1171
|
options,
|
|
1139
|
-
getOptionLabel
|
|
1172
|
+
getOptionLabel,
|
|
1173
|
+
isOptionEqualToValue: (option, value) => getOptionValue(option) === getOptionValue(value),
|
|
1140
1174
|
filterSelectedOptions: true,
|
|
1175
|
+
disableCloseOnSelect: true,
|
|
1141
1176
|
ref: field.ref,
|
|
1142
|
-
disabled: field.disabled,
|
|
1177
|
+
disabled: disabled ?? field.disabled,
|
|
1143
1178
|
onChange: handleChange,
|
|
1144
1179
|
onBlur: (event) => {
|
|
1145
1180
|
field.onBlur();
|
|
@@ -1148,6 +1183,13 @@ var Component9 = function SelectMultiElement(props) {
|
|
|
1148
1183
|
}
|
|
1149
1184
|
},
|
|
1150
1185
|
fullWidth: true,
|
|
1186
|
+
renderOption: (props1, option, { selected }) => {
|
|
1187
|
+
const { key, ...optionProps } = props1;
|
|
1188
|
+
return /* @__PURE__ */ jsxs4("li", { ...optionProps, children: [
|
|
1189
|
+
/* @__PURE__ */ jsx9(Checkbox, { icon, checkedIcon, checked: selected }),
|
|
1190
|
+
getOptionLabel(option)
|
|
1191
|
+
] }, key);
|
|
1192
|
+
},
|
|
1151
1193
|
renderInput: (params) => /* @__PURE__ */ jsx9(
|
|
1152
1194
|
TextField6,
|
|
1153
1195
|
{
|
|
@@ -1188,36 +1230,54 @@ SelectMultiElement2.displayName = "SelectMultiElement";
|
|
|
1188
1230
|
var SelectMultiElement_default = SelectMultiElement2;
|
|
1189
1231
|
|
|
1190
1232
|
// src/wrappers/SelectCascadeElement/SelectCascadeElement.tsx
|
|
1233
|
+
import { useRef as useRef3, useState as useState4, useEffect as useEffect5, useCallback as useCallback5 } from "react";
|
|
1234
|
+
import {
|
|
1235
|
+
useController as useController10
|
|
1236
|
+
} from "react-hook-form";
|
|
1191
1237
|
import {
|
|
1192
|
-
Autocomplete as Autocomplete5,
|
|
1193
1238
|
Grid2 as Grid210,
|
|
1239
|
+
useTheme as useTheme6,
|
|
1194
1240
|
TextField as TextField7,
|
|
1195
|
-
|
|
1241
|
+
Autocomplete as Autocomplete5
|
|
1196
1242
|
} 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
1243
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1202
1244
|
var Component10 = function SelectCascadeElement(props) {
|
|
1203
1245
|
const {
|
|
1246
|
+
labelKey = "Label",
|
|
1247
|
+
valueKey = "Value",
|
|
1204
1248
|
name,
|
|
1205
1249
|
onBlur,
|
|
1206
1250
|
onChange,
|
|
1207
1251
|
disabled,
|
|
1208
1252
|
options,
|
|
1209
1253
|
control,
|
|
1210
|
-
gridProps,
|
|
1211
1254
|
loading = false,
|
|
1212
1255
|
placeholder,
|
|
1213
1256
|
label,
|
|
1214
1257
|
dependsOn,
|
|
1215
|
-
|
|
1258
|
+
textFieldProps = {},
|
|
1216
1259
|
variant,
|
|
1217
1260
|
sx,
|
|
1218
1261
|
isEdit = false,
|
|
1219
1262
|
...rest
|
|
1220
1263
|
} = props;
|
|
1264
|
+
const { required } = textFieldProps;
|
|
1265
|
+
const getOptionKey = useCallback5(
|
|
1266
|
+
(option) => {
|
|
1267
|
+
if (typeof option === "string" || typeof option === "number") return option;
|
|
1268
|
+
const key = option ? option[valueKey] : void 0;
|
|
1269
|
+
return key !== void 0 && key !== null ? String(key) : "";
|
|
1270
|
+
},
|
|
1271
|
+
[valueKey]
|
|
1272
|
+
);
|
|
1273
|
+
const getOptionLabel = useCallback5(
|
|
1274
|
+
(option) => {
|
|
1275
|
+
if (typeof option === "string") return option;
|
|
1276
|
+
return option ? String(option[labelKey]) : "";
|
|
1277
|
+
},
|
|
1278
|
+
[labelKey]
|
|
1279
|
+
);
|
|
1280
|
+
const isOptionEqualToValue = (option, value) => getOptionKey(option) === getOptionKey(value);
|
|
1221
1281
|
const {
|
|
1222
1282
|
field,
|
|
1223
1283
|
fieldState: { error }
|
|
@@ -1225,50 +1285,55 @@ var Component10 = function SelectCascadeElement(props) {
|
|
|
1225
1285
|
name,
|
|
1226
1286
|
control
|
|
1227
1287
|
});
|
|
1228
|
-
const theme =
|
|
1288
|
+
const theme = useTheme6();
|
|
1229
1289
|
const { field: dependentField } = useController10({
|
|
1230
1290
|
name: dependsOn,
|
|
1231
1291
|
control
|
|
1232
1292
|
});
|
|
1233
1293
|
const parentValueRef = useRef3(dependentField.value ?? null);
|
|
1294
|
+
const [hasAutoSelected, setHasAutoSelected] = useState4(false);
|
|
1234
1295
|
useEffect5(() => {
|
|
1235
|
-
if (!!dependentField.value && parentValueRef?.current
|
|
1296
|
+
if (!!dependentField.value && parentValueRef?.current !== dependentField.value || dependentField.value === null) {
|
|
1236
1297
|
field.onChange(null);
|
|
1298
|
+
setHasAutoSelected(false);
|
|
1237
1299
|
}
|
|
1238
1300
|
}, [dependentField.value]);
|
|
1239
|
-
useEffect5(() => {
|
|
1240
|
-
if (initialValue) {
|
|
1241
|
-
field.onChange(initialValue);
|
|
1242
|
-
}
|
|
1243
|
-
}, [initialValue]);
|
|
1244
|
-
const [hasAutoSelected, setHasAutoSelected] = useState5(false);
|
|
1245
1301
|
useEffect5(() => {
|
|
1246
1302
|
if (isEdit && !disabled && options.length === 1 && field.value == null && !hasAutoSelected) {
|
|
1247
|
-
field.onChange(options[0]
|
|
1303
|
+
field.onChange(getOptionKey(options[0]));
|
|
1248
1304
|
setHasAutoSelected(true);
|
|
1249
1305
|
} else {
|
|
1250
1306
|
if (options.length === 1 && field.value == null && !hasAutoSelected) {
|
|
1251
|
-
field.onChange(options[0]
|
|
1307
|
+
field.onChange(getOptionKey(options[0]));
|
|
1252
1308
|
setHasAutoSelected(true);
|
|
1253
1309
|
}
|
|
1254
1310
|
}
|
|
1255
|
-
}, [
|
|
1311
|
+
}, [
|
|
1312
|
+
options,
|
|
1313
|
+
field.value,
|
|
1314
|
+
field.onChange,
|
|
1315
|
+
hasAutoSelected,
|
|
1316
|
+
isEdit,
|
|
1317
|
+
disabled,
|
|
1318
|
+
field,
|
|
1319
|
+
getOptionKey,
|
|
1320
|
+
dependentField.onChange
|
|
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
|
-
disabled,
|
|
1334
|
+
disabled: dependentField.value == null || 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 || dependentField.value == null ? theme.palette.action.disabledBackground : "transparent"
|
|
1362
|
+
},
|
|
1363
|
+
"& .MuiInputLabel-asterisk": { color: "red" },
|
|
1294
1364
|
"& .MuiInputBase-input": {
|
|
1295
|
-
cursor: disabled ? "not-allowed" : "default"
|
|
1365
|
+
cursor: disabled || dependentField.value == null ? "not-allowed" : "default"
|
|
1296
1366
|
},
|
|
1297
|
-
bgcolor: disabled ? theme.palette.action.disabledBackground : "transparent",
|
|
1298
1367
|
...sx
|
|
1299
1368
|
}
|
|
1300
1369
|
}
|
|
@@ -1316,7 +1385,7 @@ var SelectCascadeElement_default = SelectCascadeElement2;
|
|
|
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",
|
|
@@ -1470,7 +1539,7 @@ var Field = {
|
|
|
1470
1539
|
Select: SelectElement_default,
|
|
1471
1540
|
SelectMulti: SelectMultiElement_default,
|
|
1472
1541
|
SelectCascade: SelectCascadeElement_default,
|
|
1473
|
-
AsyncSelect:
|
|
1542
|
+
AsyncSelect: AsyncSelectElement_default,
|
|
1474
1543
|
AsyncMultiSelect: AsyncMultiSelect_default,
|
|
1475
1544
|
CheckboxGroup: CheckboxGroup_default
|
|
1476
1545
|
};
|