@m4l/components 9.3.28 → 9.3.30-JA.beta-1
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/components/Color/Color.js +32 -131
- package/components/Color/Color.styles.js +6 -124
- package/components/Color/slots/ColorEnum.d.ts +1 -3
- package/components/Color/slots/ColorEnum.js +1 -3
- package/components/Color/slots/ColorSlots.d.ts +3 -18
- package/components/Color/slots/ColorSlots.js +6 -19
- package/components/Color/types.d.ts +6 -7
- package/components/DataGrid/DataGrid.js +1 -1
- package/components/DataGrid/formatters/ColumnColorFormatter/formatter.d.ts +6 -0
- package/components/DataGrid/formatters/ColumnColorFormatter/formatter.js +19 -0
- package/components/DataGrid/formatters/ColumnColorFormatter/index.d.ts +3 -0
- package/components/DataGrid/formatters/ColumnColorFormatter/index.js +1 -0
- package/components/DataGrid/formatters/ColumnColorFormatter/types.d.ts +12 -0
- package/components/DataGrid/formatters/ColumnColorFormatter/types.js +1 -0
- package/components/DataGrid/formatters/ColumnColorFormatter/useColumnColor.d.ts +14 -0
- package/components/DataGrid/formatters/ColumnColorFormatter/useColumnColor.js +22 -0
- package/components/DataGrid/formatters/index.d.ts +1 -0
- package/components/DataGrid/tests/helpers/generators.d.ts +26 -0
- package/components/DataGrid/tests/helpers/types.d.ts +2 -0
- package/components/DynamicFilter/subcomponents/DynamicFilterBase/DynamicFilterBase.js +1 -1
- package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/helpers.d.ts +3 -2
- package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/helpers.js +3 -2
- package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/helpers.d.ts +3 -2
- package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/helpers.js +3 -2
- package/components/DynamicFilter/subcomponents/FieldTypes/FieldTypeInterface.d.ts +3 -4
- package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/helpers.d.ts +3 -2
- package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/helpers.js +3 -2
- package/components/DynamicFilter/subcomponents/FieldTypes/SelectAsyncFilter/helpers.d.ts +3 -2
- package/components/DynamicFilter/subcomponents/FieldTypes/SelectAsyncFilter/helpers.js +3 -2
- package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/helpers.d.ts +3 -2
- package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/helpers.js +3 -2
- package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/helpers.d.ts +3 -2
- package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/helpers.js +3 -2
- package/components/DynamicFilter/subcomponents/PopoverFilter/PopoverFilter.js +1 -1
- package/components/DynamicFilter/subcomponents/PopoverFilter/usePopoverFilter.d.ts +1 -7
- package/components/DynamicSort/subcomponents/AppliedSorts/AppliedSorts.js +1 -1
- package/components/DynamicSort/subcomponents/DynamicSortBase/DynamicSortBase.js +1 -1
- package/components/DynamicSort/subcomponents/FieldTypes/FieldTypeInterface.d.ts +2 -3
- package/components/DynamicSort/subcomponents/FieldTypes/StringSort/helpers.d.ts +3 -2
- package/components/DynamicSort/subcomponents/FieldTypes/StringSort/helpers.js +3 -2
- package/components/DynamicSort/subcomponents/PopoverSort/PopoverSort.js +1 -1
- package/components/DynamicSort/subcomponents/PopoverSort/usePopoverSort.d.ts +1 -7
- package/components/Icon/Icon.js +1 -1
- package/components/Image/Image.js +1 -1
- package/components/Image/subcomponents/IntersectComponent/index.js +1 -1
- package/components/ImageText/ImageText.js +1 -1
- package/components/LanguagePopover/LanguagePopover.js +1 -1
- package/components/LinearProgressIndeterminate/LinearProgressIndeterminate.js +1 -1
- package/components/LoadingError/LoadingError.js +1 -1
- package/components/NumberInput/NumberInput.js +1 -1
- package/components/ObjectLogs/subcomponents/ObjectLogsByM4L/ObjectLogsByM4L.js +1 -1
- package/components/ObjectLogs/subcomponents/ObjectLogsByOthers/ObjectLogsByOthers.js +1 -1
- package/components/PDFViewer/PDFViewer.js +1 -1
- package/components/PrintingSystem/PrintingSystem.js +1 -1
- package/components/PropertyValue/PropertyValue.js +1 -1
- package/components/ToastContainer/ToastContainer.js +1 -1
- package/components/WindowBase/WindowBase.js +1 -1
- package/components/WindowConfirm/WindowConfirm.js +1 -1
- package/components/areas/components/AreasAdmin/AreasAdmin.js +1 -1
- package/components/areas/components/AreasAdmin/subcomponents/AreaChip/AreaChip.js +4 -3
- package/components/areas/components/AreasAdmin/subcomponents/AreaChipMobile/subcomponents/ChipMobile/ChipMobile.js +4 -3
- package/components/areas/components/AreasViewer/AreasViewer.js +1 -1
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/Window.js +1 -1
- package/components/areas/contexts/AreasContext/store.js +2 -2
- package/components/commercial/TopBar/TopBar.js +1 -1
- package/components/commercial/TopBar/component/ConteinItem/index.js +1 -1
- package/components/commercial/TopBar/component/ConteinItem/subcomponets/NavItem/index.js +1 -1
- package/components/extended/React-Spinners/PropagateLoaderSpinner/PropagateLoaderSpinner.js +1 -1
- package/components/extended/React-resizable-panels/SplitLayout.js +1 -1
- package/components/formatters/BooleanFormatter/BooleanFormatter.js +1 -1
- package/components/formatters/ColorFormatter/ColorFormatter.d.ts +18 -0
- package/components/formatters/ColorFormatter/ColorFormatter.js +35 -0
- package/components/formatters/ColorFormatter/ColorFormatter.styles.d.ts +2 -0
- package/components/formatters/ColorFormatter/ColorFormatter.styles.js +15 -0
- package/components/formatters/ColorFormatter/constants.d.ts +1 -0
- package/components/formatters/ColorFormatter/constants.js +4 -0
- package/components/formatters/ColorFormatter/index.d.ts +3 -0
- package/components/formatters/ColorFormatter/index.js +1 -0
- package/components/formatters/ColorFormatter/slots/ColorFormatterEnum.d.ts +3 -0
- package/components/formatters/ColorFormatter/slots/ColorFormatterEnum.js +7 -0
- package/components/formatters/ColorFormatter/slots/ColorFormatterSlots.d.ts +4 -0
- package/components/formatters/ColorFormatter/slots/ColorFormatterSlots.js +11 -0
- package/components/formatters/ColorFormatter/types.d.ts +24 -0
- package/components/formatters/ColorFormatter/types.js +1 -0
- package/components/formatters/ConcatenatedFormatter/ConcatenatedFormatter.js +1 -1
- package/components/formatters/DateFormatter/DateFormatter.js +1 -1
- package/components/formatters/DistanceToNowFormatter/DistanceToNowFormatter.js +1 -1
- package/components/formatters/PeriodFormatter/PeriodFormatter.js +1 -1
- package/components/formatters/PointsFormatter/PointsFormatter.js +1 -1
- package/components/formatters/PriceFormatter/PriceFormatter.js +1 -1
- package/components/formatters/UncertaintyFormatter/UncertaintyFormatter.js +1 -1
- package/components/formatters/index.d.ts +1 -0
- package/components/hook-form/RHFColorPicker/RFHColorPicker.js +28 -36
- package/components/hook-form/RHFColorPicker/RHFColorPicker.styles.js +156 -0
- package/components/hook-form/RHFColorPicker/hooks/useColorPicker/index.d.ts +2 -0
- package/components/hook-form/RHFColorPicker/hooks/useColorPicker/types.d.ts +9 -0
- package/components/hook-form/RHFColorPicker/hooks/useColorPicker/useColorPicker.d.ts +41 -0
- package/components/hook-form/RHFColorPicker/hooks/useColorPicker/useColorPicker.js +50 -0
- package/components/hook-form/RHFColorPicker/slots/RHFColorPickerEnum.d.ts +4 -1
- package/components/hook-form/RHFColorPicker/slots/RHFColorPickerEnum.js +3 -0
- package/components/hook-form/RHFColorPicker/slots/RHFColorPickerSlots.d.ts +21 -0
- package/components/hook-form/RHFColorPicker/slots/RHFColorPickerSlots.js +19 -1
- package/components/hook-form/RHFColorPicker/slots/index.js +1 -0
- package/components/hook-form/RHFColorPicker/subcomponents/ColorPickerField/ColorPickerField.d.ts +33 -0
- package/components/hook-form/RHFColorPicker/subcomponents/ColorPickerField/ColorPickerField.js +147 -0
- package/components/hook-form/RHFColorPicker/subcomponents/ColorPickerField/index.d.ts +2 -0
- package/components/hook-form/RHFColorPicker/subcomponents/ColorPickerField/index.js +1 -0
- package/components/hook-form/RHFColorPicker/subcomponents/ColorPickerField/types.d.ts +20 -0
- package/components/hook-form/RHFColorPicker/subcomponents/ColorPickerField/types.js +1 -0
- package/components/hook-form/RHFDateTime/RHFDateTime.js +1 -1
- package/components/hook-form/RHFNumberInput/RHFNumberInput.js +1 -1
- package/components/hook-form/RHFPeriod/RHFPeriod.js +1 -1
- package/components/hook-form/RHFSelect/RHFSelect.js +1 -1
- package/components/hook-form/RHFTextField/RHFTextField.js +1 -1
- package/components/hook-form/RHFUpload/RHFUploadImage/subcomponents/UploadImage/UploadImage.js +1 -1
- package/components/hook-form/RHFUpload/RHFUploadSingleFile/RHFUploadSingleFile.js +1 -1
- package/components/hook-form/RHFormProvider/RHFormProvider.d.ts +31 -0
- package/components/hook-form/RHFormProvider/RHFormProvider.js +93 -0
- package/components/hook-form/RHFormProvider/index.d.ts +4 -0
- package/components/hook-form/RHFormProvider/index.js +1 -0
- package/components/hook-form/RHFormProvider/schema.d.ts +17 -0
- package/components/hook-form/RHFormProvider/schema.js +29 -0
- package/components/hook-form/RHFormProvider/types.d.ts +129 -0
- package/components/hook-form/RHFormProvider/types.js +8 -0
- package/components/hook-form/index.d.ts +1 -0
- package/components/mui_extended/Accordion/Accordion.js +1 -1
- package/components/mui_extended/Avatar/Avatar.js +1 -1
- package/components/mui_extended/Avatar/subcomponents/SkeletonAvatar/index.js +1 -1
- package/components/mui_extended/Badge/Badge.js +1 -1
- package/components/mui_extended/CircularProgress/CircularProgress.js +1 -1
- package/components/mui_extended/DateTimePicker/DateTimePicker.js +1 -1
- package/components/mui_extended/Dialog/Dialog.js +1 -1
- package/components/mui_extended/ImageButton/ImageButton.js +1 -1
- package/components/mui_extended/MenuDivider/MenuDivider.js +1 -1
- package/components/mui_extended/NavLink/NavLink.js +1 -1
- package/components/mui_extended/Popover/Popover.js +1 -1
- package/components/mui_extended/Select/Select.js +1 -1
- package/components/mui_extended/Stack/Stack.js +1 -1
- package/components/mui_extended/TextField/TextField.js +1 -1
- package/components/mui_extended/ToggleButton/ToggleButton.js +1 -1
- package/components/mui_extended/ToggleIconButton/ToggleIconButton.js +1 -1
- package/components/mui_extended/Typography/Typography.js +1 -1
- package/components/popups/components/PopupsViewer/subcomponents/Popup/Popup.js +1 -1
- package/contexts/index.d.ts +3 -3
- package/helpers/getStepsAndValidationSchema/getStepsAndValidationSchema.d.ts +3 -3
- package/helpers/getStepsAndValidationSchema/getStepsAndValidationSchema.js +3 -3
- package/helpers/getStepsAndValidationSchema/types.d.ts +5 -4
- package/hooks/index.d.ts +1 -0
- package/hooks/useDynamicFilterAndSort/useDynamicFilterAndSort.js +1 -1
- package/hooks/useFormAddEdit/index.d.ts +1 -1
- package/hooks/useWatchTyped/index.d.ts +1 -0
- package/hooks/useWatchTyped/index.js +1 -0
- package/hooks/useWatchTyped/types.d.ts +11 -0
- package/hooks/useWatchTyped/useTypedWatch.d.ts +9 -0
- package/hooks/useWatchTyped/useTypedWatch.js +30 -0
- package/index.js +94 -77
- package/package.json +2 -2
- package/test/getNameDataTestId.js +2 -2
- package/components/hook-form/RHFormContext/index.d.ts +0 -120
- package/components/hook-form/RHFormContext/index.js +0 -91
- package/components/hook-form/RHFormContext/types.d.ts +0 -83
- package/hooks/useFormReadyForUpdate/types.d.ts +0 -8
- /package/components/hook-form/{RHFormContext → RHFormProvider}/classes/constants.d.ts +0 -0
- /package/components/hook-form/{RHFormContext → RHFormProvider}/classes/constants.js +0 -0
- /package/components/hook-form/{RHFormContext → RHFormProvider}/classes/index.d.ts +0 -0
- /package/components/hook-form/{RHFormContext → RHFormProvider}/classes/index.js +0 -0
- /package/components/hook-form/{RHFormContext → RHFormProvider}/classes/types.d.ts +0 -0
- /package/components/hook-form/{RHFormContext → RHFormProvider}/dictionary.d.ts +0 -0
- /package/components/hook-form/{RHFormContext → RHFormProvider}/dictionary.js +0 -0
- /package/components/hook-form/{RHFormContext → RHFormProvider}/styles.d.ts +0 -0
- /package/components/hook-form/{RHFormContext → RHFormProvider}/styles.js +0 -0
- /package/components/hook-form/{RHFormContext → RHFormProvider}/subcomponents/FormActions/index.d.ts +0 -0
- /package/components/hook-form/{RHFormContext → RHFormProvider}/subcomponents/FormActions/skeleton.d.ts +0 -0
- /package/components/hook-form/{RHFormContext → RHFormProvider}/subcomponents/FormActions/styles.d.ts +0 -0
- /package/components/hook-form/{RHFormContext → RHFormProvider}/subcomponents/FormActions/types.d.ts +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Control, DeepPartialSkipArrayKey, FieldPath, FieldPathValue, FieldPathValues, FieldValues } from 'react-hook-form';
|
|
2
|
+
export type BaseProps<TFieldValues extends FieldValues> = {
|
|
3
|
+
control: Control<TFieldValues>;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
exact?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export type NameArray<TFieldValues extends FieldValues> = readonly FieldPath<TFieldValues>[];
|
|
8
|
+
export type ExtractFieldPath<TFieldValues extends FieldValues, TName> = Extract<TName, FieldPath<TFieldValues>>;
|
|
9
|
+
export type ExtractNameArray<TFieldValues extends FieldValues, TName> = Extract<TName, NameArray<TFieldValues>>;
|
|
10
|
+
export type DefaultValueFor<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues> | NameArray<TFieldValues>> = TName extends NameArray<TFieldValues> ? DeepPartialSkipArrayKey<TFieldValues> : FieldPathValue<TFieldValues, ExtractFieldPath<TFieldValues, TName>>;
|
|
11
|
+
export type ReturnValueFor<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues> | NameArray<TFieldValues>> = TName extends NameArray<TFieldValues> ? FieldPathValues<TFieldValues, ExtractNameArray<TFieldValues, TName>> : FieldPathValue<TFieldValues, ExtractFieldPath<TFieldValues, TName>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FieldPath, FieldValues } from 'react-hook-form';
|
|
2
|
+
import { BaseProps, DefaultValueFor, NameArray, ReturnValueFor } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Observa campos específicos (uno o varios) y devuelve su valor tipado.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useWatchTyped<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues> | NameArray<TFieldValues>>({ control, name, defaultValue, disabled, exact, }: BaseProps<TFieldValues> & {
|
|
7
|
+
name: TName;
|
|
8
|
+
defaultValue?: DefaultValueFor<TFieldValues, TName>;
|
|
9
|
+
}): ReturnValueFor<TFieldValues, TName>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useWatch } from "react-hook-form";
|
|
2
|
+
function useWatchTyped({
|
|
3
|
+
control,
|
|
4
|
+
name,
|
|
5
|
+
defaultValue,
|
|
6
|
+
disabled,
|
|
7
|
+
exact
|
|
8
|
+
}) {
|
|
9
|
+
if (Array.isArray(name)) {
|
|
10
|
+
const namesArray = name;
|
|
11
|
+
return useWatch({
|
|
12
|
+
control,
|
|
13
|
+
name: namesArray,
|
|
14
|
+
defaultValue,
|
|
15
|
+
disabled,
|
|
16
|
+
exact
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
const fieldName = name;
|
|
20
|
+
return useWatch({
|
|
21
|
+
control,
|
|
22
|
+
name: fieldName,
|
|
23
|
+
defaultValue,
|
|
24
|
+
disabled,
|
|
25
|
+
exact
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
useWatchTyped as u
|
|
30
|
+
};
|
package/index.js
CHANGED
|
@@ -60,6 +60,8 @@ import { C as C14 } from "./components/DataGrid/formatters/ColumnChipStatusForma
|
|
|
60
60
|
import { u as u12 } from "./components/DataGrid/formatters/ColumnChipStatusFormatter/useColumnChipStatus.js";
|
|
61
61
|
import { C as C15 } from "./components/DataGrid/formatters/ColumnTagsFormatter/formatter.js";
|
|
62
62
|
import { u as u13 } from "./components/DataGrid/formatters/ColumnTagsFormatter/useColumnTags.js";
|
|
63
|
+
import { C as C16 } from "./components/DataGrid/formatters/ColumnColorFormatter/formatter.js";
|
|
64
|
+
import { u as u14 } from "./components/DataGrid/formatters/ColumnColorFormatter/useColumnColor.js";
|
|
63
65
|
import { D as D3 } from "./components/DragResizeWindowRND/DragResizeWindowRND.js";
|
|
64
66
|
import { d as d2 } from "./components/DragResizeWindowRND/classes/index.js";
|
|
65
67
|
import { W } from "./components/DragResizeWindowRND/constants.js";
|
|
@@ -81,7 +83,7 @@ import { R as R3 } from "./components/extended/React-Json-Viewer/ReactJsonViewer
|
|
|
81
83
|
import { A as A14 } from "./components/mui_extended/Avatar/Avatar.js";
|
|
82
84
|
import { B as B2 } from "./components/mui_extended/BoxIcon/index.js";
|
|
83
85
|
import { B as B3 } from "./components/mui_extended/Breadcrumbs/index.js";
|
|
84
|
-
import { C as
|
|
86
|
+
import { C as C17 } from "./components/mui_extended/CircularProgress/CircularProgress.js";
|
|
85
87
|
import { B as B4 } from "./components/mui_extended/Badge/Badge.js";
|
|
86
88
|
import { L as L3 } from "./components/mui_extended/LinearProgress/index.js";
|
|
87
89
|
import { L as L4 } from "./components/mui_extended/LinkWithRoute/index.js";
|
|
@@ -91,7 +93,7 @@ import { A as A15 } from "./components/mui_extended/Accordion/Accordion.js";
|
|
|
91
93
|
import { T as T3 } from "./components/mui_extended/Tooltip/Tooltip.js";
|
|
92
94
|
import { I as I2 } from "./components/mui_extended/IconButton/IconButton.js";
|
|
93
95
|
import { B as B5 } from "./components/mui_extended/Button/Button.js";
|
|
94
|
-
import { C as
|
|
96
|
+
import { C as C18 } from "./components/mui_extended/CheckBox/CheckBox.js";
|
|
95
97
|
import { I as I3 } from "./components/mui_extended/ImageButton/ImageButton.js";
|
|
96
98
|
import { P as P2 } from "./components/mui_extended/Popover/Popover.js";
|
|
97
99
|
import { S as S4 } from "./components/mui_extended/Select/Select.js";
|
|
@@ -119,14 +121,15 @@ import { B as B6 } from "./components/formatters/BooleanFormatter/BooleanFormatt
|
|
|
119
121
|
import { D as D8, g as g12 } from "./components/formatters/DateFormatter/DateFormatter.js";
|
|
120
122
|
import { U, g as g13 } from "./components/formatters/UncertaintyFormatter/UncertaintyFormatter.js";
|
|
121
123
|
import { P as P3, g as g14 } from "./components/formatters/PointsFormatter/PointsFormatter.js";
|
|
122
|
-
import { C as
|
|
123
|
-
import { P as P4, u as
|
|
124
|
+
import { C as C19, g as g15 } from "./components/formatters/ConcatenatedFormatter/ConcatenatedFormatter.js";
|
|
125
|
+
import { P as P4, u as u15 } from "./components/formatters/PeriodFormatter/PeriodFormatter.js";
|
|
124
126
|
import { P as P5, g as g16 } from "./components/formatters/PriceFormatter/PriceFormatter.js";
|
|
125
127
|
import { T as T17 } from "./components/formatters/TagsFormatter/TagsFormatter.js";
|
|
126
|
-
import { C as
|
|
128
|
+
import { C as C20 } from "./components/formatters/ColorFormatter/ColorFormatter.js";
|
|
129
|
+
import { C as C21 } from "./components/formatters/ChipStatusFormatter/ChipStatusFormatter.js";
|
|
127
130
|
import { g as g17 } from "./components/formatters/DistanceToNowFormatter/dictionary.js";
|
|
128
131
|
import { D as D9 } from "./components/formatters/DistanceToNowFormatter/DistanceToNowFormatter.js";
|
|
129
|
-
import { u as
|
|
132
|
+
import { u as u16 } from "./components/formatters/DistanceToNowFormatter/hooks/useDistanceToNowFormatter.js";
|
|
130
133
|
import { g as g18 } from "./components/formatters/dictionary.js";
|
|
131
134
|
import { F as F2 } from "./components/FormContainer/FormContainer.js";
|
|
132
135
|
import { G } from "./components/GridLayout/GridLayout.js";
|
|
@@ -158,6 +161,9 @@ import { R as R19 } from "./components/hook-form/RHFPeriod/slots/RHFPeriodEnum.j
|
|
|
158
161
|
import { N as N3, P as P6, R as R20, S as S7 } from "./components/hook-form/RHFPeriod/slots/RHFPeriodSlots.js";
|
|
159
162
|
import { R as R21 } from "./components/hook-form/RHFNumberInput/RHFNumberInput.js";
|
|
160
163
|
import { R as R22 } from "./components/hook-form/RHFUpload/RHFUploadImage/RHFUploadImage.js";
|
|
164
|
+
import { V as V2, b as b4, a as a9 } from "./components/hook-form/RHFormProvider/types.js";
|
|
165
|
+
import { F as F3, R as R23, u as u17 } from "./components/hook-form/RHFormProvider/RHFormProvider.js";
|
|
166
|
+
import { d as d4, a as a10, b as b5, c as c3 } from "./components/hook-form/RHFormProvider/schema.js";
|
|
161
167
|
import { I as I4 } from "./components/Icon/Icon.js";
|
|
162
168
|
import { I as I5 } from "./components/Image/Image.js";
|
|
163
169
|
import { L as L6 } from "./components/Label/Label.js";
|
|
@@ -167,7 +173,7 @@ import { L as L9 } from "./components/Loadable/index.js";
|
|
|
167
173
|
import { L as L10 } from "./components/LoadingError/LoadingError.js";
|
|
168
174
|
import { g as g22 } from "./components/LoadingError/dictionary.js";
|
|
169
175
|
import { g as g23 } from "./components/MenuActions/dictionary.js";
|
|
170
|
-
import { a as
|
|
176
|
+
import { a as a11, M as M3 } from "./components/MenuActions/MenuActions.js";
|
|
171
177
|
import { M as M4 } from "./components/MFIsolationApp/MFIsolationApp.js";
|
|
172
178
|
import { M as M5 } from "./components/MFIsolationAppStorybook/MFIsolationAppStorybook.js";
|
|
173
179
|
import { M as M6 } from "./components/MFLoader/MFLoader.js";
|
|
@@ -181,8 +187,8 @@ import { g as g27 } from "./components/ObjectLogs/dictionary.js";
|
|
|
181
187
|
import { O } from "./components/ObjectLogs/ObjectLogs.js";
|
|
182
188
|
import { P as P7 } from "./components/PaperForm/PaperForm.js";
|
|
183
189
|
import { P as P8 } from "./components/PDFViewer/PDFViewer.js";
|
|
184
|
-
import { u as
|
|
185
|
-
import { a as
|
|
190
|
+
import { u as u18 } from "./components/popups/components/PopupsProvider/hooks/usePopupsStore.js";
|
|
191
|
+
import { a as a12, P as P9 } from "./components/popups/components/PopupsProvider/contexts/PopupsContext/PopupsContext.js";
|
|
186
192
|
import { P as P10 } from "./components/popups/components/PopupsViewer/PopupsViewer.js";
|
|
187
193
|
import { P as P11 } from "./components/PrintingSystem/PrintingSystem.js";
|
|
188
194
|
import { P as P12 } from "./components/PropertyValue/PropertyValue.js";
|
|
@@ -191,17 +197,17 @@ import { S as S9 } from "./components/SideBar/SideBar.js";
|
|
|
191
197
|
import { T as T18 } from "./components/ToastContainer/ToastContainer.js";
|
|
192
198
|
import { T as T19 } from "./components/ToastContainer/subcomponents/ToastMessage/ToastMessage.js";
|
|
193
199
|
import { W as W2 } from "./components/WindowBase/WindowBase.js";
|
|
194
|
-
import { u as
|
|
195
|
-
import { u as
|
|
196
|
-
import { M as M7, W as W3, a as
|
|
197
|
-
import { c as
|
|
198
|
-
import { D as D10, a as
|
|
200
|
+
import { u as u19 } from "./components/WindowBase/hooks/useWindowToolsMF/index.js";
|
|
201
|
+
import { u as u20, a as a13 } from "./components/WindowBase/hooks/useDynamicMFParameters/index.js";
|
|
202
|
+
import { M as M7, W as W3, a as a14 } from "./components/WindowBase/contexts/WindowToolsMFContext/WindowToolsMFContext.js";
|
|
203
|
+
import { c as c4 } from "./components/WindowBase/contexts/DynamicMFParmsContext/store.js";
|
|
204
|
+
import { D as D10, a as a15, M as M8 } from "./components/WindowBase/contexts/DynamicMFParmsContext/DynamicMFParmsContext.js";
|
|
199
205
|
import { W as W4 } from "./components/WindowConfirm/WindowConfirm.js";
|
|
200
|
-
import { a as
|
|
206
|
+
import { a as a16, g as g28 } from "./components/ModalDialog/dictionary.js";
|
|
201
207
|
import { M as M9 } from "./components/ModalDialog/ModalDialog.js";
|
|
202
208
|
import { S as S10 } from "./components/SettingsLayout/SettingsLayout.js";
|
|
203
209
|
import { P as P13 } from "./components/Pager/Pager.js";
|
|
204
|
-
import { u as
|
|
210
|
+
import { u as u21 } from "./components/Stepper/hooks/useStepper/index.js";
|
|
205
211
|
import { S as S11 } from "./components/Stepper/Stepper.js";
|
|
206
212
|
import { S as S12 } from "./components/Stepper/subcomponents/StepperContent/index.js";
|
|
207
213
|
import { S as S13 } from "./components/Stepper/subcomponents/StepperContent/subcomponents/Step/index.js";
|
|
@@ -214,40 +220,40 @@ import { S as S19 } from "./components/Stepper/subcomponents/StepperButtons/Step
|
|
|
214
220
|
import { S as S20 } from "./components/Stepper/subcomponents/StepperButtons/StepperSubmitButton/index.js";
|
|
215
221
|
import { e as e2 } from "./components/Stepper/helpers/evaluateVisibilityStepCondition/index.js";
|
|
216
222
|
import { g as g29 } from "./components/Stepper/dictionary.js";
|
|
217
|
-
import {
|
|
218
|
-
import {
|
|
219
|
-
import { u as u21 } from "./contexts/AppearanceComponentContext/useAppearanceComponentStore.js";
|
|
223
|
+
import { g as g30 } from "./components/hook-form/RHFormProvider/dictionary.js";
|
|
224
|
+
import { u as u22 } from "./contexts/AppearanceComponentContext/useAppearanceComponentStore.js";
|
|
220
225
|
import { A as A16 } from "./contexts/AppearanceComponentContext/AppearanceComponentContext.js";
|
|
221
|
-
import { a as
|
|
222
|
-
import { u as
|
|
223
|
-
import { u as
|
|
224
|
-
import { u as
|
|
226
|
+
import { a as a17, M as M10 } from "./contexts/ModalContext/index.js";
|
|
227
|
+
import { u as u23 } from "./hooks/useFormAddEdit/index.js";
|
|
228
|
+
import { u as u24 } from "./hooks/useModal/index.js";
|
|
229
|
+
import { u as u25 } from "./hooks/useTab/index.js";
|
|
225
230
|
import { g as g31 } from "./hooks/useFormAddEdit/dictionary.js";
|
|
226
|
-
import { u as
|
|
227
|
-
import { u as
|
|
228
|
-
import { u as
|
|
229
|
-
import { u as
|
|
230
|
-
import { u as
|
|
231
|
+
import { u as u26 } from "./hooks/useFormFocus/index.js";
|
|
232
|
+
import { u as u27 } from "./hooks/useInterval/index.js";
|
|
233
|
+
import { u as u28 } from "./hooks/useComponentSize/useComponentSize.js";
|
|
234
|
+
import { u as u29 } from "./hooks/useFormReadyForUpdate/index.js";
|
|
235
|
+
import { u as u30 } from "./hooks/useStateRef/index.js";
|
|
231
236
|
import { S as S21 } from "./hooks/useSvgColor/constants.js";
|
|
232
|
-
import { u as
|
|
233
|
-
import { u as
|
|
234
|
-
import { u as
|
|
235
|
-
import { u as
|
|
236
|
-
import { u as
|
|
237
|
-
import { u as
|
|
238
|
-
import {
|
|
237
|
+
import { u as u31 } from "./hooks/useSvgColor/useSvgColor.js";
|
|
238
|
+
import { u as u32 } from "./hooks/useDynamicFilterAndSort/useDynamicFilterAndSort.js";
|
|
239
|
+
import { u as u33 } from "./hooks/useDataGridPersistence/useDataGridPersistence.js";
|
|
240
|
+
import { u as u34 } from "./hooks/usePopoverContainer/usePopoverContainer.js";
|
|
241
|
+
import { u as u35 } from "./hooks/useIsVisible/useIsVisible.js";
|
|
242
|
+
import { u as u36 } from "./hooks/useSizeContainer/index.js";
|
|
243
|
+
import { u as u37 } from "./hooks/useWatchTyped/useTypedWatch.js";
|
|
244
|
+
import { c as c5 } from "./utils/capitalizeFirstLetter.js";
|
|
239
245
|
import { i as i2 } from "./utils/isValidDate.js";
|
|
240
246
|
import { g as g32 } from "./utils/getComponentUtilityClass.js";
|
|
241
247
|
import { g as g33 } from "./utils/getPaletteColor.js";
|
|
242
248
|
import { g as g34 } from "./utils/getTypographyStyles.js";
|
|
243
249
|
import { g as g35 } from "./utils/getIconColor.js";
|
|
244
|
-
import { a as
|
|
250
|
+
import { a as a18, g as g36 } from "./utils/getSizeStyles/getSizeStyles.js";
|
|
245
251
|
import { O as O2 } from "./utils/ObjectQueue.js";
|
|
246
|
-
import { g as g37, a as
|
|
252
|
+
import { g as g37, a as a19 } from "./utils/getComponentSlotRoot.js";
|
|
247
253
|
import { f as f2 } from "./utils/formatDistanceToNow/formatDistanteToNow.js";
|
|
248
254
|
import { g as g38 } from "./utils/getValidDate.js";
|
|
249
255
|
import { g as g39 } from "./utils/getNullGuard.js";
|
|
250
|
-
import { c as
|
|
256
|
+
import { c as c6, d as d5 } from "./utils/deepShallow.js";
|
|
251
257
|
import { g as g40 } from "./helpers/getStepsAndValidationSchema/getStepsAndValidationSchema.js";
|
|
252
258
|
export {
|
|
253
259
|
A7 as AREAS_DICCTIONARY,
|
|
@@ -275,12 +281,14 @@ export {
|
|
|
275
281
|
B3 as Breadcrumbs,
|
|
276
282
|
B5 as Button,
|
|
277
283
|
C as Card,
|
|
278
|
-
|
|
284
|
+
C18 as CheckBox,
|
|
279
285
|
C2 as Chip,
|
|
280
|
-
|
|
281
|
-
|
|
286
|
+
C21 as ChipStatusFormatter,
|
|
287
|
+
C17 as CircularProgress,
|
|
288
|
+
C20 as ColorFormatter,
|
|
282
289
|
C4 as ColumnBooleanFormatter,
|
|
283
290
|
C14 as ColumnChipStatusFormatter,
|
|
291
|
+
C16 as ColumnColorFormatter,
|
|
284
292
|
C5 as ColumnConcatenatedValueFormatter,
|
|
285
293
|
C6 as ColumnDateFormatter,
|
|
286
294
|
C7 as ColumnIconFormatter,
|
|
@@ -291,7 +299,7 @@ export {
|
|
|
291
299
|
C12 as ColumnSetCheckFormatter,
|
|
292
300
|
C15 as ColumnTagsFormatter,
|
|
293
301
|
C13 as ColumnUncertaintyFormatter,
|
|
294
|
-
|
|
302
|
+
C19 as ConcatenatedFormatter,
|
|
295
303
|
C3 as ContainerFlow,
|
|
296
304
|
b3 as DATAGRID_ROW_HEADER_HEIGHTS,
|
|
297
305
|
a4 as DATAGRID_ROW_HEIGHTS,
|
|
@@ -305,7 +313,7 @@ export {
|
|
|
305
313
|
D3 as DragResizeWindowRND,
|
|
306
314
|
D4 as DynamicFilter,
|
|
307
315
|
D10 as DynamicMFParmsContext,
|
|
308
|
-
|
|
316
|
+
a15 as DynamicMFParmsProvider,
|
|
309
317
|
D5 as DynamicSort,
|
|
310
318
|
F as FixedSizeList,
|
|
311
319
|
F2 as FormContainer,
|
|
@@ -334,10 +342,10 @@ export {
|
|
|
334
342
|
M5 as MFIsolationAppStorybook,
|
|
335
343
|
M6 as MFLoader,
|
|
336
344
|
M8 as MemonizedDynamicMFParmsProvider,
|
|
337
|
-
|
|
345
|
+
a11 as MemonizedMenuActions,
|
|
338
346
|
M7 as MemonizedWindowToolsMFContext,
|
|
339
347
|
M3 as MenuActions,
|
|
340
|
-
|
|
348
|
+
a17 as ModalContext,
|
|
341
349
|
M9 as ModalDialog,
|
|
342
350
|
M10 as ModalProvider,
|
|
343
351
|
M as MotionContainer,
|
|
@@ -356,7 +364,7 @@ export {
|
|
|
356
364
|
P6 as PeriodRootStyled,
|
|
357
365
|
P3 as PointsFormatter,
|
|
358
366
|
P2 as Popover,
|
|
359
|
-
|
|
367
|
+
a12 as PopupsContext,
|
|
360
368
|
P9 as PopupsProvider,
|
|
361
369
|
P10 as PopupsViewer,
|
|
362
370
|
P5 as PriceFormatter,
|
|
@@ -429,20 +437,27 @@ export {
|
|
|
429
437
|
T as TopBar,
|
|
430
438
|
T8 as Typography,
|
|
431
439
|
U as UncertaintyFormatter,
|
|
440
|
+
V2 as VALIDATION_OBJECT_BRAND,
|
|
441
|
+
b4 as VALIDATION_PARTIAL_OBJECT_BRAND,
|
|
442
|
+
a9 as VALIDATION_SCHEMA_BRAND,
|
|
432
443
|
V as VariableSizeList,
|
|
433
444
|
W as WINDOW_SIZES,
|
|
434
445
|
W2 as WindowBase,
|
|
435
446
|
W4 as WindowConfirm,
|
|
436
447
|
W3 as WindowToolsMFContext,
|
|
437
|
-
|
|
448
|
+
a14 as WindowToolsMFProvider,
|
|
438
449
|
c2 as addLayoutItemToBreakPointIfNoExists,
|
|
439
450
|
e as addLayoutItemToBreakPoints,
|
|
440
|
-
|
|
451
|
+
c5 as capitalizeFirstLetter,
|
|
441
452
|
d3 as cloneLayouts,
|
|
442
|
-
|
|
443
|
-
|
|
453
|
+
c6 as createCustomDeepShallow,
|
|
454
|
+
c4 as createDynamicMFStore,
|
|
455
|
+
d4 as createEmptyValidationSchema,
|
|
444
456
|
c as createToaster,
|
|
445
|
-
|
|
457
|
+
a10 as createValidationFullObject,
|
|
458
|
+
b5 as createValidationPartialObject,
|
|
459
|
+
c3 as createValidationSchema,
|
|
460
|
+
d5 as deepShallow,
|
|
446
461
|
d as defaultCommonActionsDictionary,
|
|
447
462
|
d2 as dragResizeWindowRNDClasses,
|
|
448
463
|
e2 as evaluateVisibilityStepCondition,
|
|
@@ -453,7 +468,7 @@ export {
|
|
|
453
468
|
g3 as getAreasDictionary,
|
|
454
469
|
g4 as getCommonActionsDictionary,
|
|
455
470
|
g37 as getComponentClasses,
|
|
456
|
-
|
|
471
|
+
a19 as getComponentSlotRoot,
|
|
457
472
|
g32 as getComponentUtilityClass,
|
|
458
473
|
g5 as getDataGridComponentsDictionary,
|
|
459
474
|
g6 as getDataGridRowsFromSet,
|
|
@@ -467,13 +482,13 @@ export {
|
|
|
467
482
|
g14 as getFormatPoints,
|
|
468
483
|
g16 as getFormatPrice,
|
|
469
484
|
g18 as getFormattersComponentsDictionary,
|
|
470
|
-
|
|
485
|
+
a18 as getHeightSizeStyles,
|
|
471
486
|
g35 as getIconColor,
|
|
472
487
|
g8 as getIsIfInDynamicFilter,
|
|
473
488
|
g22 as getLoadingErrorComponentsDictionary,
|
|
474
489
|
g24 as getMFLoaderComponentsDictionary,
|
|
475
490
|
g23 as getMenuActionsComponentsDictionary,
|
|
476
|
-
|
|
491
|
+
a16 as getModalDialogComponentsDictionary,
|
|
477
492
|
g28 as getModalDictionary,
|
|
478
493
|
g26 as getNoItemPrivilegesComponentsDictionary,
|
|
479
494
|
g25 as getNoItemSelectedComponentsDictionary,
|
|
@@ -499,10 +514,11 @@ export {
|
|
|
499
514
|
r as rhfPeriodStyles,
|
|
500
515
|
t as toggleButtonStyles,
|
|
501
516
|
t2 as toggleIconButtonStyles,
|
|
502
|
-
|
|
517
|
+
u22 as useAppearanceComponentStore,
|
|
503
518
|
u as useAreasStore,
|
|
504
519
|
u2 as useColumnBoolean,
|
|
505
520
|
u12 as useColumnChipStatus,
|
|
521
|
+
u14 as useColumnColor,
|
|
506
522
|
u3 as useColumnConcatenatedValue,
|
|
507
523
|
u4 as useColumnDate,
|
|
508
524
|
u5 as useColumnIcon,
|
|
@@ -513,28 +529,29 @@ export {
|
|
|
513
529
|
u10 as useColumnSetCheck,
|
|
514
530
|
u13 as useColumnTags,
|
|
515
531
|
u11 as useColumnUncertanity,
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
532
|
+
u28 as useComponentSize,
|
|
533
|
+
u17 as useCustomForm,
|
|
534
|
+
u33 as useDataGridPersistence,
|
|
535
|
+
u16 as useDistanceToNowFormatter,
|
|
536
|
+
u32 as useDynamicFilterAndSort,
|
|
537
|
+
u20 as useDynamicMFParameters,
|
|
538
|
+
a13 as useDynamicMFParametersStore,
|
|
539
|
+
u23 as useFormAddEdit,
|
|
540
|
+
u26 as useFormFocus,
|
|
541
|
+
u29 as useFormReadyForUpdate,
|
|
542
|
+
u15 as useFormatPeriod,
|
|
543
|
+
u27 as useInterval,
|
|
544
|
+
u35 as useIsVisible,
|
|
545
|
+
u24 as useModal,
|
|
546
|
+
u34 as usePopoverContainer,
|
|
547
|
+
u18 as usePopupsStore,
|
|
548
|
+
u36 as useSizeContainer,
|
|
549
|
+
u30 as useStateRef,
|
|
550
|
+
u21 as useStepper,
|
|
551
|
+
u31 as useSvgColor,
|
|
552
|
+
u25 as useTab,
|
|
553
|
+
u37 as useWatchTyped,
|
|
554
|
+
u19 as useWindowToolsMF,
|
|
538
555
|
v2 as varBounce,
|
|
539
556
|
v3 as varContainer,
|
|
540
557
|
v as varFade,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4l/components",
|
|
3
|
-
"version": "9.3.
|
|
3
|
+
"version": "9.3.30-JA.beta-1",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "M4L Components",
|
|
6
6
|
"lint-staged": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"rollup": "4.52.5"
|
|
69
69
|
},
|
|
70
70
|
"overrides": {
|
|
71
|
-
"glob": "
|
|
71
|
+
"glob": "10.4.5",
|
|
72
72
|
"eslint": "9.28.0",
|
|
73
73
|
"react": "18.3.1",
|
|
74
74
|
"@types/react": "18.3.23",
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { FieldValues } from 'react-hook-form';
|
|
2
|
-
import { CustomFormArguments, FormProviderProps, RHFormProviderRef } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Hook personalizado que configura y gestiona un formulario usando React Hook Form con validación Yup.
|
|
5
|
-
*
|
|
6
|
-
* Este hook encapsula la lógica de inicialización del formulario, incluyendo la configuración del resolver de Yup,
|
|
7
|
-
* valores por defecto, y la gestión de estados de carga para actualizar valores del formulario.
|
|
8
|
-
* @param validationSchema - Esquema de validación de Yup que define las reglas de validación del formulario
|
|
9
|
-
* @param values - Valores iniciales del formulario
|
|
10
|
-
* @param statusLoad - Estado de carga que determina cuándo actualizar los valores del formulario
|
|
11
|
-
* @param mode - Modo de validación del formulario (ej: 'onChange', 'onBlur', 'onSubmit')
|
|
12
|
-
* @returns Objeto con todos los métodos y propiedades de React Hook Form
|
|
13
|
-
* @example
|
|
14
|
-
* ```tsx
|
|
15
|
-
* const formMethods = useCustomForm({
|
|
16
|
-
* validationSchema: myValidationSchema,
|
|
17
|
-
* values: { name: '', email: '' },
|
|
18
|
-
* statusLoad: 'ready',
|
|
19
|
-
* mode: 'onChange'
|
|
20
|
-
* });
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export declare function useCustomForm({ validationSchema, values, statusLoad, mode, }: CustomFormArguments): import('react-hook-form').UseFormReturn<FieldValues, any, FieldValues>;
|
|
24
|
-
/**
|
|
25
|
-
* Componente que proporciona el contexto de React Hook Form con funcionalidades adicionales.
|
|
26
|
-
*
|
|
27
|
-
* Este componente envuelve el `FormProvider` de React Hook Form y expone métodos del formulario
|
|
28
|
-
* a través de una ref usando `useImperativeHandle`. Permite acceso programático a métodos
|
|
29
|
-
* como submit, reset, setValue, etc.
|
|
30
|
-
* @param props - Propiedades del componente que incluyen los métodos de React Hook Form
|
|
31
|
-
* @param ref - Referencia que expone los métodos del formulario
|
|
32
|
-
* @returns JSX del FormProvider con el formulario envuelto
|
|
33
|
-
* @example
|
|
34
|
-
* ```tsx
|
|
35
|
-
* const formRef = useRef<RHFormProviderRef>(null);
|
|
36
|
-
*
|
|
37
|
-
* const handleReset = () => {
|
|
38
|
-
* formRef.current?.reset();
|
|
39
|
-
* };
|
|
40
|
-
*
|
|
41
|
-
* return (
|
|
42
|
-
* <FormProviderCustom
|
|
43
|
-
* ref={formRef}
|
|
44
|
-
* onSubmit={handleSubmit}
|
|
45
|
-
* {...formMethods}
|
|
46
|
-
* >
|
|
47
|
-
* <input {...register('name')} />
|
|
48
|
-
* </FormProviderCustom>
|
|
49
|
-
* );
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
export declare const FormProviderCustom: import('react').ForwardRefExoticComponent<{
|
|
53
|
-
children: React.ReactNode | React.ReactNode[];
|
|
54
|
-
} & import('react-hook-form').UseFormReturn<FieldValues, any, FieldValues> & FormProviderProps & import('react').RefAttributes<RHFormProviderRef>>;
|
|
55
|
-
/**
|
|
56
|
-
* Componente principal que gestiona el `Provider` de `react-hook-form` y encapsula el formulario para la creación de formularios personalizados.
|
|
57
|
-
*
|
|
58
|
-
* Este componente utiliza internamente `useForm` para inicializar todos los métodos necesarios para la manipulación del formulario,
|
|
59
|
-
* incluyendo validación con Yup, gestión de estados de carga, y exposición de métodos a través de refs.
|
|
60
|
-
*
|
|
61
|
-
* **Características principales:**
|
|
62
|
-
* - Integración completa con React Hook Form
|
|
63
|
-
* - Validación automática usando esquemas de Yup
|
|
64
|
-
* - Gestión de estados de carga para actualización de valores
|
|
65
|
-
* - Exposición de métodos del formulario a través de refs
|
|
66
|
-
* - Soporte para diferentes modos de validación
|
|
67
|
-
*
|
|
68
|
-
* Si necesitas acceso directo a los métodos de `useForm`, puedes utilizar el `Provider` y el hook por separado mediante
|
|
69
|
-
* `FormProviderCustom` y `useCustomForm`, respectivamente.
|
|
70
|
-
* @param props - Propiedades del componente
|
|
71
|
-
* @param props.children - Elementos hijos del formulario
|
|
72
|
-
* @param props.onSubmit - Función que se ejecuta al enviar el formulario
|
|
73
|
-
* @param props.values - Valores iniciales del formulario
|
|
74
|
-
* @param props.validationSchema - Esquema de validación de Yup
|
|
75
|
-
* @param props.statusLoad - Estado de carga del formulario (opcional, por defecto 'ready')
|
|
76
|
-
* @param props.className - Clases CSS adicionales (opcional)
|
|
77
|
-
* @param props.mode - Modo de validación del formulario (opcional)
|
|
78
|
-
* @param ref - Referencia que expone los métodos del formulario
|
|
79
|
-
* @returns JSX del formulario con contexto de React Hook Form
|
|
80
|
-
* @example
|
|
81
|
-
* ```tsx
|
|
82
|
-
* import { useRef } from 'react';
|
|
83
|
-
* import { RHFormProvider, RHFormProviderRef } from './RHFormContext';
|
|
84
|
-
* import * as yup from 'yup';
|
|
85
|
-
*
|
|
86
|
-
* const schema = yup.object({
|
|
87
|
-
* name: yup.string().required('El nombre es requerido'),
|
|
88
|
-
* email: yup.string().email('Email inválido').required('El email es requerido')
|
|
89
|
-
* });
|
|
90
|
-
*
|
|
91
|
-
* const MyForm = () => {
|
|
92
|
-
* const formRef = useRef<RHFormProviderRef>(null);
|
|
93
|
-
*
|
|
94
|
-
* const handleSubmit = (data: any) => {
|
|
95
|
-
* console.log('Datos del formulario:', data);
|
|
96
|
-
* };
|
|
97
|
-
*
|
|
98
|
-
* const handleReset = () => {
|
|
99
|
-
* formRef.current?.reset();
|
|
100
|
-
* };
|
|
101
|
-
*
|
|
102
|
-
* return (
|
|
103
|
-
* <RHFormProvider
|
|
104
|
-
* ref={formRef}
|
|
105
|
-
* onSubmit={handleSubmit}
|
|
106
|
-
* values={{ name: '', email: '' }}
|
|
107
|
-
* validationSchema={schema}
|
|
108
|
-
* statusLoad="ready"
|
|
109
|
-
* mode="onChange"
|
|
110
|
-
* >
|
|
111
|
-
* <input {...register('name')} placeholder="Nombre" />
|
|
112
|
-
* <input {...register('email')} placeholder="Email" />
|
|
113
|
-
* <button type="submit">Enviar</button>
|
|
114
|
-
* <button type="button" onClick={handleReset}>Resetear</button>
|
|
115
|
-
* </RHFormProvider>
|
|
116
|
-
* );
|
|
117
|
-
* };
|
|
118
|
-
* ```
|
|
119
|
-
*/
|
|
120
|
-
export declare const RHFormProvider: import('react').ForwardRefExoticComponent<FormProviderProps & import('react').RefAttributes<RHFormProviderRef>>;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useImperativeHandle, useEffect } from "react";
|
|
3
|
-
import clsx from "clsx";
|
|
4
|
-
import { FormProvider, useForm } from "react-hook-form";
|
|
5
|
-
import { yupResolver } from "@hookform/resolvers/yup";
|
|
6
|
-
import { F as FormProviderRoot } from "./styles.js";
|
|
7
|
-
import { R as RHFormProviderUtilityClasses } from "./classes/index.js";
|
|
8
|
-
const classes = RHFormProviderUtilityClasses();
|
|
9
|
-
function useCustomForm({
|
|
10
|
-
validationSchema,
|
|
11
|
-
values,
|
|
12
|
-
statusLoad,
|
|
13
|
-
mode
|
|
14
|
-
}) {
|
|
15
|
-
const formMethods = useForm({
|
|
16
|
-
resolver: yupResolver(validationSchema),
|
|
17
|
-
defaultValues: values,
|
|
18
|
-
...mode && { mode }
|
|
19
|
-
});
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
if (statusLoad === "reload_values_provider") {
|
|
22
|
-
const keys = Object.keys(values);
|
|
23
|
-
keys.forEach((key) => {
|
|
24
|
-
formMethods.setValue(key, values[key], {
|
|
25
|
-
shouldValidate: false,
|
|
26
|
-
shouldDirty: false,
|
|
27
|
-
shouldTouch: false
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
formMethods.clearErrors();
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
}, [formMethods, statusLoad, values]);
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
if (statusLoad === "ready") {
|
|
36
|
-
formMethods.setValue("statusLoad", "ready", {
|
|
37
|
-
shouldValidate: false,
|
|
38
|
-
shouldDirty: false,
|
|
39
|
-
shouldTouch: false
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}, [statusLoad]);
|
|
43
|
-
return formMethods;
|
|
44
|
-
}
|
|
45
|
-
const FormProviderCustom = forwardRef((props, ref) => {
|
|
46
|
-
const { children, onSubmit, className, handleSubmit, ...formMethods } = props;
|
|
47
|
-
useImperativeHandle(ref, () => ({
|
|
48
|
-
formMethods: { ...formMethods, handleSubmit },
|
|
49
|
-
submit: () => handleSubmit(onSubmit)(),
|
|
50
|
-
reset: formMethods.reset,
|
|
51
|
-
clearErrors: formMethods.clearErrors,
|
|
52
|
-
setValue: formMethods.setValue,
|
|
53
|
-
getValues: formMethods.getValues,
|
|
54
|
-
trigger: formMethods.trigger,
|
|
55
|
-
watch: formMethods.watch,
|
|
56
|
-
setError: formMethods.setError,
|
|
57
|
-
unregister: formMethods.unregister
|
|
58
|
-
}), [formMethods, handleSubmit, onSubmit]);
|
|
59
|
-
return /* @__PURE__ */ jsx(FormProvider, { ...props, children: /* @__PURE__ */ jsx(
|
|
60
|
-
FormProviderRoot,
|
|
61
|
-
{
|
|
62
|
-
className: clsx(classes.root, className),
|
|
63
|
-
onSubmit: handleSubmit(onSubmit),
|
|
64
|
-
children
|
|
65
|
-
}
|
|
66
|
-
) });
|
|
67
|
-
});
|
|
68
|
-
FormProviderCustom.displayName = "FormProviderCustom";
|
|
69
|
-
const RHFormProvider = forwardRef((props, ref) => {
|
|
70
|
-
const { children, onSubmit, values, validationSchema, statusLoad = "ready", className, mode } = props;
|
|
71
|
-
const formMethods = useCustomForm({ validationSchema, statusLoad, values, mode });
|
|
72
|
-
return /* @__PURE__ */ jsx(
|
|
73
|
-
FormProviderCustom,
|
|
74
|
-
{
|
|
75
|
-
ref,
|
|
76
|
-
className,
|
|
77
|
-
values,
|
|
78
|
-
validationSchema,
|
|
79
|
-
statusLoad,
|
|
80
|
-
onSubmit,
|
|
81
|
-
...formMethods,
|
|
82
|
-
children
|
|
83
|
-
}
|
|
84
|
-
);
|
|
85
|
-
});
|
|
86
|
-
RHFormProvider.displayName = "RHFormProvider";
|
|
87
|
-
export {
|
|
88
|
-
FormProviderCustom as F,
|
|
89
|
-
RHFormProvider as R,
|
|
90
|
-
useCustomForm as u
|
|
91
|
-
};
|