@m4l/components 0.1.26 → 0.1.28

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.
Files changed (112) hide show
  1. package/assets/Logo/index.228dcb5a.js +42 -35
  2. package/commonjs.565e6834.js +5 -5
  3. package/components/CommonActions/components/ActionCancel/index.e498eeb2.js +17 -0
  4. package/components/CommonActions/components/ActionFormCancel/index.4ff0ad73.js +64 -0
  5. package/components/CommonActions/components/ActionFormIntro/index.ca4d2674.js +28 -22
  6. package/components/CommonActions/components/ActionIntro/index.60ef7bd7.js +18 -0
  7. package/components/CommonActions/components/Actions/index.0645e30f.js +867 -0
  8. package/components/DataGrid/index.76d8fd25.js +1075 -0
  9. package/components/DynamicFilter/index.342ba5fe.js +1577 -0
  10. package/components/ErrorLabel/index.c8615f16.js +13 -12
  11. package/components/Icon/index.619c31c4.js +96 -0
  12. package/components/Icon/types.d.ts +2 -1
  13. package/components/Image/index.93d5f37f.js +190 -0
  14. package/components/Loadable/index.f5518558.js +8 -8
  15. package/components/ModalDialog/index.9ea10764.js +184 -0
  16. package/components/NoItemSelected/{index.9609a7f7.js → index.46d2f632.js} +52 -41
  17. package/components/ObjectLogs/index.f941fb79.js +288 -0
  18. package/components/Page/index.4237c241.js +22 -20
  19. package/components/PaperForm/index.ec9cb8c9.js +112 -0
  20. package/components/Period/index.2941fbda.js +249 -0
  21. package/components/PropertyValue/index.dfcfe1ba.js +147 -0
  22. package/components/PropertyValue/styles.d.ts +2 -1
  23. package/components/PropertyValue/types.d.ts +3 -3
  24. package/components/Resizeable/index.45995d2b.js +19 -19
  25. package/components/ScrollBar/index.39eeb2de.js +26 -21
  26. package/components/ScrollToTop/index.e06f98f6.js +8 -7
  27. package/components/SplitLayout/index.4032673d.js +35 -33
  28. package/components/animate/LoadingScreen/index.1d0c4307.js +33 -33
  29. package/components/animate/MotionContainer/index.8d9f9d80.js +25 -22
  30. package/components/animate/MotionLazyContainer/index.572dd012.js +10 -10
  31. package/components/animate/features.0fbf41e1.js +3 -3
  32. package/components/animate/variants/bounce.784aaaaa.js +16 -13
  33. package/components/animate/variants/container.11f82b76.js +8 -6
  34. package/components/animate/variants/fade.b561c0fc.js +32 -28
  35. package/components/animate/variants/transition.bd46b9ce.js +17 -12
  36. package/components/formatters/BooleanFormatter/index.8da35c9c.js +55 -0
  37. package/components/formatters/DateFormatter/index.1b9baacc.js +69 -0
  38. package/components/formatters/index.689a8086.js +119 -0
  39. package/components/hook-form/RHFAutocomplete/index.59a68f9f.js +224 -0
  40. package/components/hook-form/RHFAutocompleteAsync/index.c3083062.js +87 -0
  41. package/components/hook-form/RHFCheckbox/index.6dcec9e2.js +49 -39
  42. package/components/hook-form/RHFDateTime/index.9231a7c7.js +69 -56
  43. package/components/hook-form/RHFMultiCheckbox/index.2680b3b6.js +23 -23
  44. package/components/hook-form/RHFPeriod/index.64a228d5.js +55 -0
  45. package/components/hook-form/RHFRadioGroup/index.b3335e13.js +29 -29
  46. package/components/hook-form/RHFSelect/index.b6ca8bb2.js +24 -24
  47. package/components/hook-form/RHFTextField/index.f9aaaa90.js +146 -0
  48. package/components/hook-form/RHFUpload/RHFUploadImage/{components → subcomponents}/UploadImage/index.d.ts +0 -0
  49. package/components/hook-form/RHFUpload/RHFUploadImage/{components → subcomponents}/UploadImage/styles.d.ts +4 -3
  50. package/components/hook-form/RHFUpload/RHFUploadImage/{components → subcomponents}/UploadImage/subcomponents/Skeleton/index.d.ts +0 -0
  51. package/components/hook-form/RHFUpload/RHFUploadImage/{components → subcomponents}/UploadImage/subcomponents/Skeleton/styles.d.ts +0 -0
  52. package/components/hook-form/RHFUpload/RHFUploadImage/{components → subcomponents}/UploadImage/types.d.ts +0 -0
  53. package/components/hook-form/RHFUpload/index.d5cc7c13.js +285 -0
  54. package/components/mui_extended/Accordion/index.a02ac6ae.js +107 -0
  55. package/components/mui_extended/Avatar/index.fe06afd7.js +51 -0
  56. package/components/mui_extended/BoxIcon/index.e638ecc8.js +10 -10
  57. package/components/mui_extended/Breadcrumbs/index.5e37d903.js +49 -44
  58. package/components/mui_extended/Button/index.53b56958.js +178 -0
  59. package/components/mui_extended/CircularProgress/index.ad569afd.js +8 -6
  60. package/components/mui_extended/IconButton/index.a321e5cb.js +120 -0
  61. package/components/mui_extended/IconButton/index.d.ts +1 -1
  62. package/components/mui_extended/LinkWithRoute/index.16436ab8.js +25 -21
  63. package/components/mui_extended/Pager/index.c0865b70.js +141 -0
  64. package/components/mui_extended/Popover/index.705275a4.js +278 -0
  65. package/components/mui_extended/Tab/index.e0653a0a.js +25 -21
  66. package/components/mui_extended/Typography/index.e5494696.js +25 -21
  67. package/contexts/ModalContext/index.b92fa565.js +153 -0
  68. package/contexts/ModalContext/{components → subcomponents}/ContentConfirm/index.d.ts +0 -0
  69. package/contexts/ModalContext/{components → subcomponents}/ContentConfirm/styles.d.ts +0 -0
  70. package/contexts/ModalContext/{components → subcomponents}/ContentConfirm/types.d.ts +0 -0
  71. package/contexts/RHFormContext/index.b142190a.js +63 -0
  72. package/hooks/useFormAddEdit/index.d4845f1a.js +40 -22
  73. package/hooks/useModal/index.5fee01a3.js +11 -0
  74. package/index.js +153 -153
  75. package/package.json +2 -1
  76. package/react-data-grid.d46d625e.js +2206 -1663
  77. package/react-draggable.20e95c61.js +800 -553
  78. package/react-json-view.f56a7f8e.js +2344 -2340
  79. package/react-resizable.5277deaf.js +470 -298
  80. package/react-splitter-layout.7810ac1b.js +130 -128
  81. package/utils/index.214d9542.js +500 -354
  82. package/components/CommonActions/components/ActionCancel/index.6736b782.js +0 -17
  83. package/components/CommonActions/components/ActionFormCancel/index.281ee166.js +0 -49
  84. package/components/CommonActions/components/ActionIntro/index.4665a611.js +0 -18
  85. package/components/CommonActions/components/Actions/index.cd7b2671.js +0 -742
  86. package/components/DataGrid/index.2caf6231.js +0 -894
  87. package/components/DynamicFilter/index.f2377369.js +0 -1157
  88. package/components/Icon/index.f569765b.js +0 -82
  89. package/components/Image/index.c9da2d5a.js +0 -152
  90. package/components/ModalDialog/index.bee344a5.js +0 -168
  91. package/components/ObjectLogs/index.6b6f95e6.js +0 -266
  92. package/components/PaperForm/index.3f8c7ef2.js +0 -105
  93. package/components/Period/index.a112ce37.js +0 -175
  94. package/components/PropertyValue/index.ab3dd7e9.js +0 -116
  95. package/components/contexts/RHFormContext/index.33dba822.js +0 -56
  96. package/components/formatters/BooleanFormatter/index.3ec56305.js +0 -42
  97. package/components/formatters/DateFormatter/index.08d8823b.js +0 -57
  98. package/components/formatters/index.6959c2de.js +0 -106
  99. package/components/hook-form/RHFAutocomplete/index.5eee9d7c.js +0 -174
  100. package/components/hook-form/RHFAutocompleteAsync/index.757b5080.js +0 -65
  101. package/components/hook-form/RHFPeriod/index.979d0898.js +0 -51
  102. package/components/hook-form/RHFTextField/index.ba2a8f67.js +0 -129
  103. package/components/hook-form/RHFUpload/index.6347159a.js +0 -258
  104. package/components/mui_extended/Accordion/index.49f5df8e.js +0 -103
  105. package/components/mui_extended/Avatar/index.dadb0528.js +0 -37
  106. package/components/mui_extended/Button/index.52d18aea.js +0 -144
  107. package/components/mui_extended/IconButton/index.4b5ce8b5.js +0 -103
  108. package/components/mui_extended/Pager/index.951b6975.js +0 -126
  109. package/components/mui_extended/Popover/index.4da8587a.js +0 -252
  110. package/contexts/ModalContext/index.5388dfd5.js +0 -136
  111. package/hooks/useModal/index.3b1ff084.js +0 -11
  112. package/node_modules.168cb897.js +0 -55
@@ -0,0 +1,224 @@
1
+ import { useModuleDictionary, useModuleSkeleton } from "@m4l/core";
2
+ import { useFormContext, Controller } from "react-hook-form";
3
+ import { Skeleton, Autocomplete, TextField, CircularProgress } from "@mui/material";
4
+ import { styled } from "@mui/material/styles";
5
+ import { I as Image } from "../../Image/index.93d5f37f.js";
6
+ import { useMemo, useState, useEffect } from "react";
7
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
8
+ const SKTRHFAutocompleteWrapper = styled("div")(() => ({
9
+ display: "flex",
10
+ width: "100%",
11
+ flexDirection: "column"
12
+ }));
13
+ const SKTInputText = styled("div")(({
14
+ theme
15
+ }) => ({
16
+ width: "100%",
17
+ display: "grid",
18
+ gridTemplateColumns: "1fr auto",
19
+ gridGap: theme.spacing(2),
20
+ alignItems: "center",
21
+ height: `${theme.spacing(4.5)}`,
22
+ border: `1px solid ${theme.palette.divider}`,
23
+ borderRadius: `${theme.spacing(1)}`,
24
+ padding: `0 ${theme.spacing(2)}`,
25
+ [theme.breakpoints.down("md")]: {
26
+ width: "100%"
27
+ }
28
+ }));
29
+ const WrapperAutocomplete = styled("div")(({
30
+ theme
31
+ }) => ({
32
+ display: "flex",
33
+ width: "100%",
34
+ "& .MuiAutocomplete-root": {
35
+ width: "100%"
36
+ },
37
+ "& .m4l_image": {
38
+ marginLeft: theme.spacing(1.5)
39
+ }
40
+ }));
41
+ const WrapperOption = styled("li")(({
42
+ theme
43
+ }) => ({
44
+ "& .m4l_image": {
45
+ marginRight: theme.spacing(1.5)
46
+ }
47
+ }));
48
+ function withRenderOption(getUrlImage, imageWidth, imageHeight) {
49
+ return function RenderOption(optionProps, option) {
50
+ return /* @__PURE__ */ jsxs(WrapperOption, {
51
+ ...optionProps,
52
+ children: [/* @__PURE__ */ jsx(Image, {
53
+ src: getUrlImage(option),
54
+ width: imageWidth,
55
+ height: imageHeight
56
+ }), optionProps.key]
57
+ });
58
+ };
59
+ }
60
+ function RHFAutocomplete(props) {
61
+ const {
62
+ name,
63
+ getOptionLabel,
64
+ isOptionEqualToValue,
65
+ label,
66
+ skeletonWidth = 100,
67
+ skeletonHeight = "18px",
68
+ options,
69
+ disabled,
70
+ getOptionUrlImage,
71
+ imageWidth = "24px",
72
+ imageHeight = "24px",
73
+ onOpen,
74
+ onClose,
75
+ loading,
76
+ onChangeFilterParmsLocal,
77
+ ...other
78
+ } = props;
79
+ const {
80
+ getLabel
81
+ } = useModuleDictionary();
82
+ const isSkeleton = useModuleSkeleton();
83
+ const {
84
+ control
85
+ } = useFormContext();
86
+ const withImage = useMemo(() => getOptionUrlImage !== void 0, [getOptionUrlImage]);
87
+ const [open, setOpen] = useState(false);
88
+ const onCloseLocal = (event, reason) => {
89
+ setOpen(false);
90
+ if (onClose)
91
+ onClose(event, reason);
92
+ };
93
+ const onOpenLocal = (event) => {
94
+ setOpen(true);
95
+ if (onOpen)
96
+ onOpen(event);
97
+ };
98
+ const getOptionLabelLocal = (option) => {
99
+ if (option === void 0 || option === null) {
100
+ return "";
101
+ }
102
+ return getOptionLabel(option);
103
+ };
104
+ const getOptionUrlImageLocal = (option) => {
105
+ if (option === void 0 || option === null || getOptionUrlImage === void 0) {
106
+ return "";
107
+ }
108
+ return getOptionUrlImage(option);
109
+ };
110
+ const isOptionEqualToValueLocal = (option, value) => {
111
+ if (value === void 0 || value === null || option === null) {
112
+ return false;
113
+ }
114
+ return isOptionEqualToValue(option, value);
115
+ };
116
+ if (isSkeleton) {
117
+ return /* @__PURE__ */ jsx(SKTRHFAutocompleteWrapper, {
118
+ children: /* @__PURE__ */ jsxs(SKTInputText, {
119
+ children: [/* @__PURE__ */ jsx(Skeleton, {
120
+ variant: "text",
121
+ width: skeletonWidth,
122
+ height: skeletonHeight
123
+ }, "sk1"), /* @__PURE__ */ jsx(Skeleton, {
124
+ variant: "circular",
125
+ width: 16,
126
+ height: 16
127
+ }, "sk2")]
128
+ })
129
+ });
130
+ }
131
+ return /* @__PURE__ */ jsx(Controller, {
132
+ name,
133
+ control,
134
+ render: ({
135
+ field: {
136
+ onChange,
137
+ value
138
+ },
139
+ fieldState: {
140
+ error
141
+ }
142
+ }) => {
143
+ const [inputValue, setInputValue] = useState(getOptionLabelLocal(value));
144
+ useEffect(() => {
145
+ if (!open && value === null && inputValue !== "") {
146
+ setInputValue("");
147
+ }
148
+ if (!open && value !== null && options.length === 0 && onChangeFilterParmsLocal) {
149
+ onChangeFilterParmsLocal(getOptionLabelLocal(value), "reset");
150
+ }
151
+ }, [value]);
152
+ return /* @__PURE__ */ jsx(WrapperAutocomplete, {
153
+ className: "m4l_rhf_autocomplete",
154
+ children: /* @__PURE__ */ jsx(Autocomplete, {
155
+ autoComplete: true,
156
+ autoSelect: false,
157
+ options,
158
+ getOptionLabel: getOptionLabelLocal,
159
+ inputValue,
160
+ clearOnBlur: false,
161
+ onInputChange: (_event, newValue, reason) => {
162
+ if (reason === "input") {
163
+ setInputValue(newValue);
164
+ if (onChangeFilterParmsLocal) {
165
+ onChangeFilterParmsLocal(newValue, reason);
166
+ }
167
+ }
168
+ onChange(null);
169
+ },
170
+ isOptionEqualToValue: isOptionEqualToValueLocal,
171
+ disableClearable: true,
172
+ value: value || null,
173
+ onOpen: onOpenLocal,
174
+ onClose: onCloseLocal,
175
+ onChange: (_e, val) => {
176
+ setInputValue(getOptionLabelLocal(val));
177
+ onChange(val);
178
+ },
179
+ filterOptions: onChangeFilterParmsLocal ? (x) => x : void 0,
180
+ loading,
181
+ loadingText: getLabel("rhf_autocomplete.loading_options"),
182
+ disabled,
183
+ noOptionsText: getLabel("rhf_autocomplete.no_options"),
184
+ renderOption: withImage ? withRenderOption(getOptionUrlImageLocal, imageWidth, imageHeight) : void 0,
185
+ renderInput: (params) => {
186
+ return /* @__PURE__ */ jsx(TextField, {
187
+ ...params,
188
+ label,
189
+ fullWidth: true,
190
+ SelectProps: {
191
+ native: true
192
+ },
193
+ InputProps: {
194
+ ...params.InputProps,
195
+ startAdornment: withImage && value ? /* @__PURE__ */ jsx(Image, {
196
+ src: getOptionUrlImageLocal(value),
197
+ width: imageWidth,
198
+ height: imageHeight
199
+ }, "ImageTextField") : null,
200
+ endAdornment: /* @__PURE__ */ jsxs(Fragment, {
201
+ children: [loading ? /* @__PURE__ */ jsx(CircularProgress, {
202
+ color: "inherit",
203
+ size: 20
204
+ }) : null, params.InputProps.endAdornment]
205
+ })
206
+ },
207
+ autoComplete: "off",
208
+ error: !!error,
209
+ helperText: error?.message,
210
+ ...other
211
+ });
212
+ }
213
+ })
214
+ });
215
+ }
216
+ });
217
+ }
218
+ function getRHFAutocompleteComponentsDictionary() {
219
+ return ["rhf_autocomplete"];
220
+ }
221
+ export {
222
+ RHFAutocomplete as R,
223
+ getRHFAutocompleteComponentsDictionary as g
224
+ };
@@ -0,0 +1,87 @@
1
+ import { useState, useCallback, useEffect } from "react";
2
+ import { useNetwork, getPropertyByString } from "@m4l/core";
3
+ import debounce from "lodash/debounce";
4
+ import { R as RHFAutocomplete, g as getRHFAutocompleteComponentsDictionary } from "../RHFAutocomplete/index.59a68f9f.js";
5
+ import { jsx } from "react/jsx-runtime";
6
+ function RHFAutocompleteAsync(props) {
7
+ const {
8
+ name,
9
+ endPoint,
10
+ timeout = 5e3,
11
+ parms,
12
+ resultField = "data",
13
+ isRemote = true,
14
+ onChangeFilterParms,
15
+ ...other
16
+ } = props;
17
+ const {
18
+ networkOperation
19
+ } = useNetwork();
20
+ const [options, setOptions] = useState([]);
21
+ const [open, setOpen] = useState(false);
22
+ const [loading, setIsloading] = useState(false);
23
+ const [canLoadOptions, setCanLoadOptions] = useState(true);
24
+ const [filterParms, setFilterParms] = useState({});
25
+ const debouncedFilter = useCallback(debounce((newFilterParms) => {
26
+ setCanLoadOptions(true);
27
+ setFilterParms(newFilterParms);
28
+ }, 300), []);
29
+ const onChangeFilterParmsLocal = (newValue) => {
30
+ if (onChangeFilterParms) {
31
+ debouncedFilter(onChangeFilterParms(newValue));
32
+ }
33
+ };
34
+ useEffect(() => {
35
+ setCanLoadOptions(true);
36
+ }, [parms, endPoint]);
37
+ useEffect(() => {
38
+ if (!open || loading) {
39
+ return;
40
+ }
41
+ if (!canLoadOptions) {
42
+ return;
43
+ }
44
+ setIsloading(true);
45
+ setOptions([]);
46
+ setCanLoadOptions(false);
47
+ networkOperation({
48
+ method: "GET",
49
+ endPoint,
50
+ timeout,
51
+ parms: {
52
+ ...parms,
53
+ ...filterParms
54
+ },
55
+ isRemote
56
+ }).then((response) => {
57
+ const newOptions = getPropertyByString(response, resultField);
58
+ setOptions(newOptions);
59
+ }).catch(() => {
60
+ setCanLoadOptions(true);
61
+ }).finally(() => {
62
+ setIsloading(false);
63
+ });
64
+ return () => {
65
+ };
66
+ }, [open, parms, filterParms, endPoint]);
67
+ return /* @__PURE__ */ jsx(RHFAutocomplete, {
68
+ name,
69
+ loading,
70
+ options,
71
+ onChangeFilterParmsLocal: onChangeFilterParms ? onChangeFilterParmsLocal : void 0,
72
+ onOpen: () => {
73
+ setOpen(true);
74
+ },
75
+ onClose: () => {
76
+ setOpen(false);
77
+ },
78
+ ...other
79
+ });
80
+ }
81
+ function getRHFAutocompleteAsyncComponentsDictionary() {
82
+ return getRHFAutocompleteComponentsDictionary();
83
+ }
84
+ export {
85
+ RHFAutocompleteAsync as R,
86
+ getRHFAutocompleteAsyncComponentsDictionary as g
87
+ };
@@ -1,58 +1,68 @@
1
- import { useFormContext as a, Controller as c } from "react-hook-form";
2
- import { styled as m } from "@mui/material/styles";
3
- import { styled as p, Skeleton as d, FormControlLabel as h, Checkbox as x } from "@mui/material";
4
- import { useModuleSkeleton as u } from "@m4l/core";
5
- import { jsx as e, jsxs as f, Fragment as g } from "react/jsx-runtime";
6
- const k = p("div")(() => ({
1
+ import { useFormContext, Controller } from "react-hook-form";
2
+ import { styled as styled$1 } from "@mui/material/styles";
3
+ import { styled, Skeleton, FormControlLabel, Checkbox } from "@mui/material";
4
+ import { useModuleSkeleton } from "@m4l/core";
5
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
6
+ const WrapperSkeletonCheckBox = styled("div")(() => ({
7
7
  display: "flex",
8
8
  justifyContent: "center",
9
9
  alignItems: "center",
10
10
  width: "36px",
11
11
  height: "36px"
12
- })), C = () => /* @__PURE__ */ e(k, {
13
- children: /* @__PURE__ */ e(d, {
14
- variant: "rounded",
15
- width: "18px",
16
- height: "18px"
17
- })
18
- }), y = m("p")(({
19
- theme: t
12
+ }));
13
+ const SkeletonCheckBox = () => {
14
+ return /* @__PURE__ */ jsx(WrapperSkeletonCheckBox, {
15
+ children: /* @__PURE__ */ jsx(Skeleton, {
16
+ variant: "rounded",
17
+ width: "18px",
18
+ height: "18px"
19
+ })
20
+ });
21
+ };
22
+ const ErrorLabel = styled$1("p")(({
23
+ theme
20
24
  }) => ({
21
- ...t.typography.caption,
22
- color: t.palette.error.main,
25
+ ...theme.typography.caption,
26
+ color: theme.palette.error.main,
23
27
  marginRight: 14,
24
28
  marginLeft: 14
25
29
  }));
26
- function L({
27
- name: t,
28
- sizeCheck: n = "small",
29
- ...l
30
+ function RHFCheckbox({
31
+ name,
32
+ sizeCheck = "small",
33
+ ...other
30
34
  }) {
31
35
  const {
32
- control: i
33
- } = a(), s = u();
34
- return /* @__PURE__ */ e(h, {
35
- control: /* @__PURE__ */ e(c, {
36
- name: t,
37
- control: i,
36
+ control
37
+ } = useFormContext();
38
+ const isSkeleton = useModuleSkeleton();
39
+ return /* @__PURE__ */ jsx(FormControlLabel, {
40
+ control: /* @__PURE__ */ jsx(Controller, {
41
+ name,
42
+ control,
38
43
  render: ({
39
- field: o,
44
+ field,
40
45
  fieldState: {
41
- error: r
46
+ error
47
+ }
48
+ }) => {
49
+ if (isSkeleton) {
50
+ return /* @__PURE__ */ jsx(SkeletonCheckBox, {});
42
51
  }
43
- }) => s ? /* @__PURE__ */ e(C, {}) : /* @__PURE__ */ f(g, {
44
- children: [/* @__PURE__ */ e(x, {
45
- size: n,
46
- ...o,
47
- checked: o.value
48
- }), r?.message && /* @__PURE__ */ e(y, {
49
- children: r?.message + ""
50
- })]
51
- })
52
+ return /* @__PURE__ */ jsxs(Fragment, {
53
+ children: [/* @__PURE__ */ jsx(Checkbox, {
54
+ size: sizeCheck,
55
+ ...field,
56
+ checked: field.value
57
+ }), error?.message && /* @__PURE__ */ jsx(ErrorLabel, {
58
+ children: error?.message + ""
59
+ })]
60
+ });
61
+ }
52
62
  }),
53
- ...l
63
+ ...other
54
64
  });
55
65
  }
56
66
  export {
57
- L as R
67
+ RHFCheckbox as R
58
68
  };
@@ -1,81 +1,94 @@
1
- import { useFormContext as c, Controller as f } from "react-hook-form";
2
- import { Skeleton as s, TextField as x } from "@mui/material";
3
- import { DateTimePicker as g } from "@mui/x-date-pickers";
4
- import { useModuleSkeleton as k, useEnvironment as F } from "@m4l/core";
5
- import { styled as v } from "@mui/material/styles";
6
- import { jsxs as C, jsx as t } from "react/jsx-runtime";
7
- const T = v("div")(({
8
- theme: e
1
+ import { useFormContext, Controller } from "react-hook-form";
2
+ import { Skeleton, TextField } from "@mui/material";
3
+ import { DateTimePicker } from "@mui/x-date-pickers";
4
+ import { useModuleSkeleton, useEnvironment } from "@m4l/core";
5
+ import { styled } from "@mui/material/styles";
6
+ import { jsxs, jsx } from "react/jsx-runtime";
7
+ const SKTRHFWrapperTextField = styled("div")(({
8
+ theme
9
9
  }) => ({
10
10
  display: "flex",
11
11
  width: "100%",
12
12
  height: "42.25px",
13
13
  alignItems: "center",
14
14
  justifyContent: "space-between",
15
- border: `1px solid ${e.palette.divider}`,
15
+ border: `1px solid ${theme.palette.divider}`,
16
16
  padding: "0 14px",
17
- borderRadius: e.spacing(0.5)
18
- })), S = (e) => {
17
+ borderRadius: theme.spacing(0.5)
18
+ }));
19
+ const SkeletonRHFDateTime = (props) => {
19
20
  const {
20
- skeletonWidth: n,
21
- skeletonHeight: r
22
- } = e;
23
- return /* @__PURE__ */ C(T, {
24
- children: [/* @__PURE__ */ t(s, {
21
+ skeletonWidth,
22
+ skeletonHeight
23
+ } = props;
24
+ return /* @__PURE__ */ jsxs(SKTRHFWrapperTextField, {
25
+ children: [/* @__PURE__ */ jsx(Skeleton, {
25
26
  variant: "text",
26
- width: n,
27
- height: r
28
- }), /* @__PURE__ */ t(s, {
27
+ width: skeletonWidth,
28
+ height: skeletonHeight
29
+ }), /* @__PURE__ */ jsx(Skeleton, {
29
30
  variant: "circular",
30
31
  width: "20px",
31
32
  height: "20px"
32
33
  })]
33
34
  });
34
35
  };
35
- function y(e) {
36
+ function RHFDateTime(props) {
37
+ const {
38
+ name,
39
+ autoComplete = "off",
40
+ skeletonWidth = "50%",
41
+ skeletonHeight = 14
42
+ } = props;
43
+ const isSkeleton = useModuleSkeleton();
44
+ const {
45
+ control
46
+ } = useFormContext();
36
47
  const {
37
- name: n,
38
- autoComplete: r = "off",
39
- skeletonWidth: l = "50%",
40
- skeletonHeight: m = 14
41
- } = e, d = k(), {
42
- control: p
43
- } = c(), {
44
48
  dfnsFormat: {
45
- datetime_format: h,
46
- datetime_mask: u
49
+ datetime_format,
50
+ datetime_mask
47
51
  }
48
- } = F();
49
- return d ? /* @__PURE__ */ t(S, {
50
- skeletonWidth: l,
51
- skeletonHeight: m
52
- }) : /* @__PURE__ */ t(f, {
53
- name: n,
54
- control: p,
52
+ } = useEnvironment();
53
+ if (isSkeleton) {
54
+ return /* @__PURE__ */ jsx(SkeletonRHFDateTime, {
55
+ skeletonWidth,
56
+ skeletonHeight
57
+ });
58
+ }
59
+ return /* @__PURE__ */ jsx(Controller, {
60
+ name,
61
+ control,
55
62
  render: ({
56
- field: i,
63
+ field,
57
64
  fieldState: {
58
- error: a
65
+ error
59
66
  }
60
- }) => /* @__PURE__ */ t(g, {
61
- ampm: !1,
62
- inputFormat: h,
63
- mask: u,
64
- label: "",
65
- value: i.value,
66
- onChange: (o) => {
67
- isNaN(o) ? i.onChange(void 0) : i.onChange(o);
68
- },
69
- renderInput: (o) => /* @__PURE__ */ t(x, {
70
- autoComplete: r,
71
- fullWidth: !0,
72
- error: !!a,
73
- helperText: a?.message,
74
- ...o
75
- })
76
- })
67
+ }) => {
68
+ return /* @__PURE__ */ jsx(DateTimePicker, {
69
+ ampm: false,
70
+ inputFormat: datetime_format,
71
+ mask: datetime_mask,
72
+ label: "",
73
+ value: field.value,
74
+ onChange: (value) => {
75
+ if (!isNaN(value)) {
76
+ field.onChange(value);
77
+ } else {
78
+ field.onChange(void 0);
79
+ }
80
+ },
81
+ renderInput: (params) => /* @__PURE__ */ jsx(TextField, {
82
+ autoComplete,
83
+ fullWidth: true,
84
+ error: !!error,
85
+ helperText: error?.message,
86
+ ...params
87
+ })
88
+ });
89
+ }
77
90
  });
78
91
  }
79
92
  export {
80
- y as R
93
+ RHFDateTime as R
81
94
  };
@@ -1,34 +1,34 @@
1
- import { useFormContext as m, Controller as s } from "react-hook-form";
2
- import { FormGroup as C, FormControlLabel as h, Checkbox as x } from "@mui/material";
3
- import { jsx as o } from "react/jsx-runtime";
4
- function k({
5
- name: n,
6
- options: l,
7
- ...c
1
+ import { useFormContext, Controller } from "react-hook-form";
2
+ import { FormGroup, FormControlLabel, Checkbox } from "@mui/material";
3
+ import { jsx } from "react/jsx-runtime";
4
+ function RHFMultiCheckbox({
5
+ name,
6
+ options,
7
+ ...other
8
8
  }) {
9
9
  const {
10
- control: t
11
- } = m();
12
- return /* @__PURE__ */ o(s, {
13
- name: n,
14
- control: t,
10
+ control
11
+ } = useFormContext();
12
+ return /* @__PURE__ */ jsx(Controller, {
13
+ name,
14
+ control,
15
15
  render: ({
16
- field: e
16
+ field
17
17
  }) => {
18
- const u = (r) => e.value.includes(r) ? e.value.filter((a) => a !== r) : [...e.value, r];
19
- return /* @__PURE__ */ o(C, {
20
- children: l.map((r) => /* @__PURE__ */ o(h, {
21
- control: /* @__PURE__ */ o(x, {
22
- checked: e.value.includes(r),
23
- onChange: () => e.onChange(u(r))
18
+ const onSelected = (option) => field.value.includes(option) ? field.value.filter((value) => value !== option) : [...field.value, option];
19
+ return /* @__PURE__ */ jsx(FormGroup, {
20
+ children: options.map((option) => /* @__PURE__ */ jsx(FormControlLabel, {
21
+ control: /* @__PURE__ */ jsx(Checkbox, {
22
+ checked: field.value.includes(option),
23
+ onChange: () => field.onChange(onSelected(option))
24
24
  }),
25
- label: r,
26
- ...c
27
- }, r))
25
+ label: option,
26
+ ...other
27
+ }, option))
28
28
  });
29
29
  }
30
30
  });
31
31
  }
32
32
  export {
33
- k as R
33
+ RHFMultiCheckbox as R
34
34
  };
@@ -0,0 +1,55 @@
1
+ import { styled } from "@mui/material";
2
+ import { useFormContext, Controller } from "react-hook-form";
3
+ import { E as ErrorLabel } from "../../ErrorLabel/index.c8615f16.js";
4
+ import { P as Period } from "../../Period/index.2941fbda.js";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ const Wrapper = styled("div")(({
7
+ theme
8
+ }) => ({
9
+ width: "100%",
10
+ display: "flex",
11
+ flexDirection: "column",
12
+ justifyContent: "center",
13
+ alignItems: "flex-start",
14
+ gap: theme.spacing(1)
15
+ }));
16
+ const RHFPeriod = (props) => {
17
+ const {
18
+ name,
19
+ readOnly,
20
+ skeletonWidth,
21
+ skeletonHeight
22
+ } = props;
23
+ const {
24
+ control
25
+ } = useFormContext();
26
+ return /* @__PURE__ */ jsx(Controller, {
27
+ name,
28
+ control,
29
+ render: ({
30
+ field: {
31
+ onChange,
32
+ value
33
+ },
34
+ fieldState: {
35
+ error
36
+ }
37
+ }) => {
38
+ return /* @__PURE__ */ jsxs(Wrapper, {
39
+ children: [/* @__PURE__ */ jsx(Period, {
40
+ value,
41
+ onChange,
42
+ error: !!error,
43
+ readOnly,
44
+ skeletonWidth,
45
+ skeletonHeight
46
+ }), error && /* @__PURE__ */ jsx(ErrorLabel, {
47
+ message: error.message || ""
48
+ })]
49
+ });
50
+ }
51
+ });
52
+ };
53
+ export {
54
+ RHFPeriod as R
55
+ };