@m4l/components 0.0.8 → 0.0.11

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 (76) hide show
  1. package/dist/can-use-dom.js +3 -0
  2. package/dist/components/DataGrid/formatters/BooleanFormatter/index.d.ts +3 -0
  3. package/dist/components/DataGrid/formatters/BooleanFormatter/index.js +26 -0
  4. package/dist/components/DataGrid/formatters/BooleanFormatter/types.d.ts +5 -0
  5. package/dist/components/DataGrid/formatters/DateFormatter/index.js +33 -0
  6. package/dist/components/DataGrid/formatters/index.d.ts +2 -0
  7. package/dist/components/DataGrid/index.js +4 -37
  8. package/dist/components/DataGrid/types.d.ts +1 -1
  9. package/dist/components/ModalDialog/index.js +0 -5
  10. package/dist/components/ObjectLogs/index.js +2 -1
  11. package/dist/components/PaperForm/index.d.ts +3 -0
  12. package/dist/components/PaperForm/index.js +122 -0
  13. package/dist/components/PaperForm/skeleton.d.ts +6 -0
  14. package/dist/components/PaperForm/styles.d.ts +8 -0
  15. package/dist/components/PaperForm/types.d.ts +7 -0
  16. package/dist/components/PropertyValue/index.d.ts +3 -0
  17. package/dist/components/PropertyValue/index.js +108 -0
  18. package/dist/components/PropertyValue/skeleton.d.ts +2 -0
  19. package/dist/components/PropertyValue/styles.d.ts +6 -0
  20. package/dist/components/PropertyValue/types.d.ts +11 -0
  21. package/dist/components/ScrollBar/index.d.ts +3 -0
  22. package/dist/components/ScrollBar/index.js +60 -0
  23. package/dist/components/ScrollBar/styles.d.ts +6 -0
  24. package/dist/components/ScrollBar/types.d.ts +7 -0
  25. package/dist/components/hook-form/FormProvider/components/FormActions/index.d.ts +3 -0
  26. package/dist/components/hook-form/FormProvider/components/FormActions/skeleton.d.ts +2 -0
  27. package/dist/components/hook-form/FormProvider/components/FormActions/styles.d.ts +3 -0
  28. package/dist/components/hook-form/FormProvider/components/FormActions/types.d.ts +4 -0
  29. package/dist/components/hook-form/FormProvider/index.d.ts +3 -0
  30. package/dist/components/hook-form/FormProvider/index.js +162 -0
  31. package/dist/components/hook-form/FormProvider/styles.d.ts +2 -0
  32. package/dist/components/hook-form/FormProvider/types.d.ts +10 -0
  33. package/dist/components/hook-form/RHFAutocompleteAsync/index.d.ts +4 -0
  34. package/dist/components/hook-form/RHFAutocompleteAsync/index.js +184 -0
  35. package/dist/components/hook-form/RHFAutocompleteAsync/styles.d.ts +4 -0
  36. package/dist/components/hook-form/RHFAutocompleteAsync/types.d.ts +17 -0
  37. package/dist/components/hook-form/RHFCheckbox/index.d.ts +3 -0
  38. package/dist/components/hook-form/RHFCheckbox/index.js +41 -0
  39. package/dist/components/hook-form/RHFCheckbox/skeleton.d.ts +2 -0
  40. package/dist/components/hook-form/RHFCheckbox/styles.d.ts +2 -0
  41. package/dist/components/hook-form/RHFCheckbox/types.d.ts +10 -0
  42. package/dist/components/hook-form/RHFMultiCheckbox/index.d.ts +3 -0
  43. package/dist/components/hook-form/RHFMultiCheckbox/index.js +32 -0
  44. package/dist/components/hook-form/RHFMultiCheckbox/types.d.ts +10 -0
  45. package/dist/components/hook-form/RHFRadioGroup.d.ts +9 -0
  46. package/dist/components/hook-form/RHFRadioGroup.js +41 -0
  47. package/dist/components/hook-form/RHFSelect.d.ts +8 -0
  48. package/dist/components/hook-form/RHFSelect.js +34 -0
  49. package/dist/components/hook-form/RHFTextField/index.d.ts +4 -0
  50. package/dist/components/hook-form/RHFTextField/index.js +57 -0
  51. package/dist/components/hook-form/RHFTextField/styles.d.ts +2 -0
  52. package/dist/components/hook-form/RHFTextField/types.d.ts +9 -0
  53. package/dist/components/hook-form/index.d.ts +7 -0
  54. package/dist/components/index.d.ts +12 -5
  55. package/dist/components/mui_extended/Accordion/index.d.ts +3 -0
  56. package/dist/components/mui_extended/Accordion/index.js +45 -0
  57. package/dist/components/mui_extended/Accordion/types.d.ts +11 -0
  58. package/dist/components/mui_extended/BoxIcon/index.js +1 -1
  59. package/dist/components/mui_extended/Breadcrumbs/index.d.ts +2 -1
  60. package/dist/components/mui_extended/MenuPopover/index.d.ts +2 -1
  61. package/dist/components/mui_extended/Tab/index.d.ts +2 -0
  62. package/dist/components/mui_extended/Tab/index.js +29 -0
  63. package/dist/components/mui_extended/Tab/styles.d.ts +2 -0
  64. package/dist/components/mui_extended/index.d.ts +8 -6
  65. package/dist/contexts/ModalContext/index.js +1 -1
  66. package/dist/core-js.js +2645 -0
  67. package/dist/index.js +39 -18
  68. package/dist/juggle.js +511 -0
  69. package/dist/lodash.js +489 -0
  70. package/dist/node_modules.js +54 -0
  71. package/dist/react-draggable.js +3 -3
  72. package/dist/react-resizable.js +3 -3
  73. package/dist/react-splitter-layout.js +2 -2
  74. package/dist/simplebar.js +849 -0
  75. package/dist/vendor.js +29 -13
  76. package/package.json +7 -2
@@ -0,0 +1,162 @@
1
+ import { useCallback, useEffect } from "react";
2
+ import { useFormContext, useFormState, useForm, FormProvider as FormProvider$1 } from "react-hook-form";
3
+ import { o } from "../../../node_modules.js";
4
+ import { styled } from "@mui/material/styles";
5
+ import { useNavigate } from "react-router-dom";
6
+ import { useModuleDictionary, useFlagsPresent } from "@m4l/core";
7
+ import { LoadingButton } from "@mui/lab";
8
+ import { Skeleton, Button } from "@mui/material";
9
+ import { u as useModal } from "../../../hooks/useModal/index.js";
10
+ import { jsxs, jsx } from "react/jsx-runtime";
11
+ const WrapperFormProvider = styled("form")(({
12
+ theme
13
+ }) => ({
14
+ display: "flex",
15
+ flexDirection: "column",
16
+ width: "100%",
17
+ overflow: "scroll",
18
+ marginBottom: theme.spacing(1)
19
+ }));
20
+ const WrapperFormActions = styled("div")(({
21
+ theme
22
+ }) => ({
23
+ paddingTop: theme.spacing(3),
24
+ marginRight: theme.spacing(1.5),
25
+ display: "flex",
26
+ flexDirection: "row",
27
+ justifyContent: "flex-end",
28
+ "& > button": {
29
+ marginLeft: "10px"
30
+ },
31
+ "& .MuiLoadingButton-root ": {
32
+ minWidth: "80px"
33
+ }
34
+ }));
35
+ const WrapperSKTFormActions = styled("div")(({
36
+ theme
37
+ }) => ({
38
+ display: "grid",
39
+ gridTemplateColumns: "auto auto",
40
+ margin: "0px",
41
+ gridGap: `${theme.spacing(3)}`,
42
+ justifyContent: "flex-end",
43
+ paddingTop: `${theme.spacing(3)}`,
44
+ borderTop: `1px solid ${theme.palette.divider}`,
45
+ [theme.breakpoints.up("sm")]: {
46
+ margin: `0 ${theme.spacing(4.5)}`
47
+ }
48
+ }));
49
+ function SKTFormActions() {
50
+ return /* @__PURE__ */ jsxs(WrapperSKTFormActions, {
51
+ children: [/* @__PURE__ */ jsx(Skeleton, {
52
+ variant: "text",
53
+ width: 57,
54
+ height: 30
55
+ }), /* @__PURE__ */ jsx(Skeleton, {
56
+ variant: "text",
57
+ width: 57,
58
+ height: 30
59
+ })]
60
+ });
61
+ }
62
+ function FormActions(props) {
63
+ const {
64
+ withIntro,
65
+ urlCancel
66
+ } = props;
67
+ const navigate = useNavigate();
68
+ const {
69
+ getLabel
70
+ } = useModuleDictionary();
71
+ const isSkeleton = !useFlagsPresent(["dictionary_loaded", "form_loaded"]);
72
+ const {
73
+ openModalConfirm
74
+ } = useModal();
75
+ const {
76
+ control
77
+ } = useFormContext();
78
+ const {
79
+ isDirty,
80
+ isSubmitting
81
+ } = useFormState({
82
+ control
83
+ });
84
+ const onConfirmCancel = useCallback(() => {
85
+ if (typeof urlCancel === "number") {
86
+ navigate(urlCancel);
87
+ }
88
+ if (urlCancel && typeof urlCancel === "undefined") {
89
+ navigate(urlCancel, {
90
+ replace: false
91
+ });
92
+ }
93
+ }, [navigate, urlCancel]);
94
+ const onClickCancel = useCallback(() => {
95
+ if (isDirty) {
96
+ openModalConfirm({
97
+ variant: "warning",
98
+ title: getLabel("form_provider.confirm_quit_title"),
99
+ msg: getLabel("form_provider.confirm_quit_msg"),
100
+ onClickIntro: onConfirmCancel
101
+ });
102
+ } else {
103
+ onConfirmCancel();
104
+ }
105
+ }, [getLabel, isDirty, onConfirmCancel, openModalConfirm]);
106
+ if (isSkeleton) {
107
+ return /* @__PURE__ */ jsx(SKTFormActions, {});
108
+ }
109
+ return /* @__PURE__ */ jsxs(WrapperFormActions, {
110
+ children: [urlCancel && /* @__PURE__ */ jsx(Button, {
111
+ variant: "outlined",
112
+ color: "inherit",
113
+ onClick: onClickCancel,
114
+ children: getLabel("actions.action_cancel")
115
+ }), withIntro && /* @__PURE__ */ jsx(LoadingButton, {
116
+ variant: "contained",
117
+ type: "submit",
118
+ loading: isSubmitting,
119
+ children: getLabel("actions.action_accept")
120
+ })]
121
+ });
122
+ }
123
+ function FormProvider(props) {
124
+ const {
125
+ children,
126
+ onSubmit,
127
+ values,
128
+ validationSchema,
129
+ withIntro,
130
+ urlCancel = -1
131
+ } = props;
132
+ const methods = useForm({
133
+ resolver: o(validationSchema),
134
+ defaultValues: values
135
+ });
136
+ useEffect(() => {
137
+ if (values.initial) {
138
+ return;
139
+ }
140
+ console.log("****\xB7\xB7\xB7\xB7\xB7\xB7useEffect FormProvider", values);
141
+ const keys = Object.keys(values);
142
+ keys.forEach((key) => {
143
+ methods.setValue(key, values[key], {
144
+ shouldValidate: false,
145
+ shouldDirty: false,
146
+ shouldTouch: false
147
+ });
148
+ });
149
+ }, [methods, values]);
150
+ return /* @__PURE__ */ jsx(FormProvider$1, {
151
+ ...methods,
152
+ children: /* @__PURE__ */ jsxs(WrapperFormProvider, {
153
+ id: "formProvider",
154
+ onSubmit: methods.handleSubmit(onSubmit),
155
+ children: [children, withIntro && /* @__PURE__ */ jsx(FormActions, {
156
+ withIntro,
157
+ urlCancel
158
+ })]
159
+ })
160
+ });
161
+ }
162
+ export { FormProvider as F };
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const WrapperFormProvider: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, {}>;
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from 'react';
2
+ import { FieldValues } from 'react-hook-form';
3
+ export interface FormProviderProps {
4
+ children: ReactNode;
5
+ onSubmit: (data: FieldValues) => void;
6
+ values: FieldValues;
7
+ validationSchema: any;
8
+ withIntro?: boolean;
9
+ urlCancel?: string | number;
10
+ }
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { TextFieldProps } from '@mui/material';
3
+ import type { RHFAutocompleteAsyncProps } from './types';
4
+ export declare function RHFAutocompleteAsync<T>(props: RHFAutocompleteAsyncProps<T> & TextFieldProps): JSX.Element;
@@ -0,0 +1,184 @@
1
+ import { useState, useEffect, Fragment } from "react";
2
+ import { useModuleDictionary, useNetwork, getPropertyByString } from "@m4l/core";
3
+ import { useFormContext, Controller } from "react-hook-form";
4
+ import { Skeleton, Autocomplete, TextField, CircularProgress } from "@mui/material";
5
+ import { styled } from "@mui/material/styles";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ const SKTRHFAutocompleteAsyncWrapper = styled("div")(() => ({
8
+ display: "flex",
9
+ width: "100%",
10
+ flexDirection: "column"
11
+ }));
12
+ styled("div")(({
13
+ theme
14
+ }) => ({
15
+ display: "flex",
16
+ justifyContent: "flex-end",
17
+ paddingRight: `${theme.spacing(2)}`,
18
+ [theme.breakpoints.down("md")]: {
19
+ justifyContent: "flex-start"
20
+ }
21
+ }));
22
+ const SKTInputText = styled("div")(({
23
+ theme
24
+ }) => ({
25
+ width: "100%",
26
+ display: "grid",
27
+ gridTemplateColumns: "1fr auto",
28
+ gridGap: theme.spacing(2),
29
+ alignItems: "center",
30
+ height: `${theme.spacing(4.5)}`,
31
+ border: `1px solid ${theme.palette.divider}`,
32
+ borderRadius: `${theme.spacing(1)}`,
33
+ padding: `0 ${theme.spacing(2)}`,
34
+ [theme.breakpoints.down("md")]: {
35
+ width: "100%"
36
+ }
37
+ }));
38
+ function RHFAutocompleteAsync(props) {
39
+ const {
40
+ name,
41
+ getOptionLabel,
42
+ isOptionEqualToValue,
43
+ label,
44
+ endPoint,
45
+ timeout = 5e3,
46
+ parms = {},
47
+ resultField = "data",
48
+ skeletonProps = {},
49
+ isRemote = true,
50
+ ...other
51
+ } = props;
52
+ const {
53
+ isSkeleton = false,
54
+ width = 100,
55
+ height = "18px"
56
+ } = skeletonProps;
57
+ const {
58
+ getLabel
59
+ } = useModuleDictionary();
60
+ const {
61
+ control,
62
+ getValues
63
+ } = useFormContext();
64
+ const {
65
+ networkOperation
66
+ } = useNetwork();
67
+ const initialValue = getValues(name);
68
+ const [options, setOptions] = useState(initialValue === null ? [] : [initialValue]);
69
+ const [open, setOpen] = useState(false);
70
+ const [optionsLoaded, setOptionsLoaded] = useState(false);
71
+ const loading = open && !optionsLoaded;
72
+ useEffect(() => {
73
+ if (!optionsLoaded && initialValue) {
74
+ setOptions([initialValue]);
75
+ }
76
+ }, [initialValue, optionsLoaded]);
77
+ console.log("***2022Render RHFAutocompleteAsync", loading, options, initialValue);
78
+ const getOptionLabelLocal = (option) => {
79
+ if (option === void 0 || option === null) {
80
+ return "";
81
+ }
82
+ return getOptionLabel(option);
83
+ };
84
+ const isOptionEqualToValueLocal = (option, value) => {
85
+ if (value === void 0 || value === null || option === null) {
86
+ return false;
87
+ }
88
+ return isOptionEqualToValue(option, value);
89
+ };
90
+ useEffect(() => {
91
+ let mounted = true;
92
+ if (!loading) {
93
+ return void 0;
94
+ }
95
+ console.debug("useEffect - RHFAutocompleteAsync - initial", endPoint, loading, parms, resultField, timeout);
96
+ networkOperation({
97
+ method: "GET",
98
+ endPoint,
99
+ timeout,
100
+ parms,
101
+ isRemote
102
+ }).then((response) => {
103
+ if (mounted) {
104
+ setOptions(getPropertyByString(response, resultField));
105
+ setOptionsLoaded(true);
106
+ }
107
+ });
108
+ return () => {
109
+ mounted = false;
110
+ };
111
+ }, [loading]);
112
+ if (isSkeleton) {
113
+ return /* @__PURE__ */ jsx(SKTRHFAutocompleteAsyncWrapper, {
114
+ children: /* @__PURE__ */ jsxs(SKTInputText, {
115
+ children: [/* @__PURE__ */ jsx(Skeleton, {
116
+ variant: "text",
117
+ width,
118
+ height
119
+ }, "sk1"), /* @__PURE__ */ jsx(Skeleton, {
120
+ variant: "circular",
121
+ width: 16,
122
+ height: 16
123
+ }, "sk2")]
124
+ })
125
+ });
126
+ }
127
+ return /* @__PURE__ */ jsx(Controller, {
128
+ name,
129
+ control,
130
+ render: ({
131
+ field: {
132
+ onChange,
133
+ value
134
+ },
135
+ fieldState: {
136
+ error
137
+ }
138
+ }) => /* @__PURE__ */ jsx(Autocomplete, {
139
+ options,
140
+ getOptionLabel: getOptionLabelLocal,
141
+ defaultValue: initialValue,
142
+ isOptionEqualToValue: isOptionEqualToValueLocal,
143
+ disableClearable: true,
144
+ value: value || null,
145
+ onOpen: () => {
146
+ setOpen(true);
147
+ },
148
+ onClose: () => {
149
+ setOpen(false);
150
+ },
151
+ onChange: (_e, val) => {
152
+ onChange(val);
153
+ },
154
+ loading,
155
+ loadingText: "",
156
+ noOptionsText: getLabel("component_no_options"),
157
+ renderInput: (params) => {
158
+ console.log("TextField", params);
159
+ return /* @__PURE__ */ jsx(TextField, {
160
+ ...params,
161
+ label,
162
+ fullWidth: true,
163
+ SelectProps: {
164
+ native: true
165
+ },
166
+ InputProps: {
167
+ ...params.InputProps,
168
+ endAdornment: /* @__PURE__ */ jsxs(Fragment, {
169
+ children: [loading ? /* @__PURE__ */ jsx(CircularProgress, {
170
+ color: "primary",
171
+ size: 20
172
+ }, `cp_async${params.id}`) : null, params.InputProps.endAdornment]
173
+ }, `fr_async_${params.id}`)
174
+ },
175
+ autoComplete: "off",
176
+ error: !!error,
177
+ helperText: error?.message,
178
+ ...other
179
+ }, `tx_async_${params.id}`);
180
+ }
181
+ }, "at_async")
182
+ });
183
+ }
184
+ export { RHFAutocompleteAsync as R };
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ export declare const SKTRHFAutocompleteAsyncWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
3
+ export declare const PropertieValueLabel: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
4
+ export declare const SKTInputText: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -0,0 +1,17 @@
1
+ export interface SkeletonProps {
2
+ isSkeleton?: boolean;
3
+ width?: string | number;
4
+ height?: string | number;
5
+ }
6
+ export interface RHFAutocompleteAsyncProps<T> {
7
+ name: string;
8
+ getOptionLabel: (option: T) => string;
9
+ isOptionEqualToValue: (option: T, value: T) => boolean;
10
+ skeletonProps?: SkeletonProps;
11
+ endPoint: string;
12
+ timeout?: number;
13
+ parms?: any;
14
+ resultField?: string;
15
+ label: string;
16
+ isRemote?: boolean;
17
+ }
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { RHFCheckboxProps } from './types';
3
+ export declare function RHFCheckbox({ name, sizeCheck, isSkeleton, ...other }: RHFCheckboxProps): JSX.Element;
@@ -0,0 +1,41 @@
1
+ import { useFormContext, Controller } from "react-hook-form";
2
+ import { Skeleton, FormControlLabel, Checkbox } from "@mui/material";
3
+ import { styled } from "@mui/material/styles";
4
+ import { jsx } from "react/jsx-runtime";
5
+ const WrapperSKTRHFCheckbox = styled("div")(() => ({
6
+ display: "flex"
7
+ }));
8
+ function SKTRHFCheckbox() {
9
+ return /* @__PURE__ */ jsx(WrapperSKTRHFCheckbox, {
10
+ children: /* @__PURE__ */ jsx(Skeleton, {
11
+ variant: "rectangular",
12
+ width: 16,
13
+ height: 16
14
+ })
15
+ });
16
+ }
17
+ function RHFCheckbox({
18
+ name,
19
+ sizeCheck = "small",
20
+ isSkeleton = false,
21
+ ...other
22
+ }) {
23
+ const {
24
+ control
25
+ } = useFormContext();
26
+ return /* @__PURE__ */ jsx(FormControlLabel, {
27
+ control: /* @__PURE__ */ jsx(Controller, {
28
+ name,
29
+ control,
30
+ render: ({
31
+ field
32
+ }) => isSkeleton ? /* @__PURE__ */ jsx(SKTRHFCheckbox, {}) : /* @__PURE__ */ jsx(Checkbox, {
33
+ size: sizeCheck,
34
+ ...field,
35
+ checked: field.value
36
+ })
37
+ }),
38
+ ...other
39
+ });
40
+ }
41
+ export { RHFCheckbox as R };
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function SKTRHFCheckbox(): JSX.Element;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const WrapperSKTRHFCheckbox: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -0,0 +1,10 @@
1
+ import { FormControlLabelProps } from '@mui/material';
2
+ export interface RHFCheckboxProps extends Omit<FormControlLabelProps, 'control'> {
3
+ name: string;
4
+ sizeCheck?: 'small' | 'medium';
5
+ isSkeleton?: boolean;
6
+ }
7
+ export interface RHFMultiCheckboxProps extends Omit<FormControlLabelProps, 'control' | 'label'> {
8
+ name: string;
9
+ options: string[];
10
+ }
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { RHFMultiCheckboxProps } from './types';
3
+ export declare function RHFMultiCheckbox({ name, options, ...other }: RHFMultiCheckboxProps): JSX.Element;
@@ -0,0 +1,32 @@
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
+ }) {
9
+ const {
10
+ control
11
+ } = useFormContext();
12
+ return /* @__PURE__ */ jsx(Controller, {
13
+ name,
14
+ control,
15
+ render: ({
16
+ field
17
+ }) => {
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
+ }),
25
+ label: option,
26
+ ...other
27
+ }, option))
28
+ });
29
+ }
30
+ });
31
+ }
32
+ export { RHFMultiCheckbox as R };
@@ -0,0 +1,10 @@
1
+ import { FormControlLabelProps } from '@mui/material';
2
+ export interface RHFCheckboxProps extends Omit<FormControlLabelProps, 'control'> {
3
+ name: string;
4
+ sizeCheck?: 'small' | 'medium';
5
+ isSkeleton?: boolean;
6
+ }
7
+ export interface RHFMultiCheckboxProps extends Omit<FormControlLabelProps, 'control' | 'label'> {
8
+ name: string;
9
+ options: string[];
10
+ }
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { RadioGroupProps } from '@mui/material';
3
+ interface IProps {
4
+ name: string;
5
+ options: string[];
6
+ getOptionLabel?: string[];
7
+ }
8
+ export declare function RHFRadioGroup({ name, options, getOptionLabel, ...other }: IProps & RadioGroupProps): JSX.Element;
9
+ export {};
@@ -0,0 +1,41 @@
1
+ import { useFormContext, Controller } from "react-hook-form";
2
+ import { RadioGroup, FormControlLabel, Radio, FormHelperText } from "@mui/material";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ function RHFRadioGroup({
5
+ name,
6
+ options,
7
+ getOptionLabel,
8
+ ...other
9
+ }) {
10
+ const {
11
+ control
12
+ } = useFormContext();
13
+ return /* @__PURE__ */ jsx(Controller, {
14
+ name,
15
+ control,
16
+ render: ({
17
+ field,
18
+ fieldState: {
19
+ error
20
+ }
21
+ }) => /* @__PURE__ */ jsxs("div", {
22
+ children: [/* @__PURE__ */ jsx(RadioGroup, {
23
+ ...field,
24
+ row: true,
25
+ ...other,
26
+ children: options.map((option, index) => /* @__PURE__ */ jsx(FormControlLabel, {
27
+ value: option,
28
+ control: /* @__PURE__ */ jsx(Radio, {}),
29
+ label: getOptionLabel?.length ? getOptionLabel[index] : option
30
+ }, option))
31
+ }), !!error && /* @__PURE__ */ jsx(FormHelperText, {
32
+ error: true,
33
+ sx: {
34
+ px: 2
35
+ },
36
+ children: error.message
37
+ })]
38
+ })
39
+ });
40
+ }
41
+ export { RHFRadioGroup as R };
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { TextFieldProps } from '@mui/material';
3
+ interface IProps {
4
+ name: string;
5
+ children: any;
6
+ }
7
+ export declare function RHFSelect({ name, children, ...other }: IProps & TextFieldProps): JSX.Element;
8
+ export {};
@@ -0,0 +1,34 @@
1
+ import { useFormContext, Controller } from "react-hook-form";
2
+ import { TextField } from "@mui/material";
3
+ import { jsx } from "react/jsx-runtime";
4
+ function RHFSelect({
5
+ name,
6
+ children,
7
+ ...other
8
+ }) {
9
+ const {
10
+ control
11
+ } = useFormContext();
12
+ return /* @__PURE__ */ jsx(Controller, {
13
+ name,
14
+ control,
15
+ render: ({
16
+ field,
17
+ fieldState: {
18
+ error
19
+ }
20
+ }) => /* @__PURE__ */ jsx(TextField, {
21
+ ...field,
22
+ select: true,
23
+ fullWidth: true,
24
+ SelectProps: {
25
+ native: true
26
+ },
27
+ error: !!error,
28
+ helperText: error?.message,
29
+ ...other,
30
+ children
31
+ })
32
+ });
33
+ }
34
+ export { RHFSelect as R };
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { TextFieldProps } from '@mui/material';
3
+ import { RHFTextFieldProps } from './types';
4
+ export declare function RHFTextField(props: RHFTextFieldProps & TextFieldProps): JSX.Element;
@@ -0,0 +1,57 @@
1
+ import { useFormContext, Controller } from "react-hook-form";
2
+ import { Skeleton, TextField } from "@mui/material";
3
+ import { styled } from "@mui/material/styles";
4
+ import { jsx } from "react/jsx-runtime";
5
+ const SKTRHFWrapperTextField = styled("div")(({
6
+ theme
7
+ }) => ({
8
+ display: "flex",
9
+ width: "100%",
10
+ alignItems: "center",
11
+ border: `1px solid ${theme.palette.divider}`,
12
+ padding: "12px 14px",
13
+ borderRadius: theme.spacing(1)
14
+ }));
15
+ function RHFTextField(props) {
16
+ const {
17
+ name,
18
+ autoComplete = "off",
19
+ skeletonProps: skeletoProps = {},
20
+ ...other
21
+ } = props;
22
+ const {
23
+ isSkeleton = true,
24
+ width = "100%",
25
+ height = 14
26
+ } = skeletoProps;
27
+ const {
28
+ control
29
+ } = useFormContext();
30
+ if (isSkeleton) {
31
+ return /* @__PURE__ */ jsx(SKTRHFWrapperTextField, {
32
+ children: /* @__PURE__ */ jsx(Skeleton, {
33
+ variant: "text",
34
+ width,
35
+ height
36
+ })
37
+ });
38
+ }
39
+ return /* @__PURE__ */ jsx(Controller, {
40
+ name,
41
+ control,
42
+ render: ({
43
+ field,
44
+ fieldState: {
45
+ error
46
+ }
47
+ }) => /* @__PURE__ */ jsx(TextField, {
48
+ autoComplete,
49
+ ...field,
50
+ fullWidth: true,
51
+ error: !!error,
52
+ helperText: error?.message,
53
+ ...other
54
+ })
55
+ });
56
+ }
57
+ export { RHFTextField as R };
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const SKTRHFWrapperTextField: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -0,0 +1,9 @@
1
+ export interface SkeletonProps {
2
+ isSkeleton?: boolean;
3
+ width?: string | number;
4
+ height?: string | number;
5
+ }
6
+ export interface RHFTextFieldProps {
7
+ skeletonProps?: SkeletonProps;
8
+ name: string;
9
+ }