@m4l/components 9.3.29 → 9.3.30-BE211125-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/AppBar/styles.js +1 -1
- package/components/Card/Card.styles.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/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/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/hook-form/RHFormProvider/RHFormProvider.d.ts +14 -0
- package/components/hook-form/RHFormProvider/RHFormProvider.js +98 -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 +133 -0
- package/components/hook-form/RHFormProvider/types.js +8 -0
- package/components/hook-form/index.d.ts +1 -0
- 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 +2 -1
- package/hooks/useFormAddEdit/{index.d.ts → useFormAddEdit.d.ts} +3 -2
- 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 +47 -36
- package/package.json +1 -1
- 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
- /package/hooks/useFormAddEdit/{index.js → useFormAddEdit.js} +0 -0
|
@@ -8,7 +8,7 @@ const appBarStyles = {
|
|
|
8
8
|
display: "flex",
|
|
9
9
|
flexDirection: "row",
|
|
10
10
|
flexWrap: "nowrap",
|
|
11
|
-
alignItems:
|
|
11
|
+
alignItems: "center",
|
|
12
12
|
height: theme.vars.size.baseSpacings.sp12,
|
|
13
13
|
minHeight: theme.vars.size.baseSpacings.sp12,
|
|
14
14
|
padding: `0 ${theme.generalSettings.isMobile ? theme.vars.size.baseSpacings.sp2 : theme.vars.size.baseSpacings.sp4}`,
|
|
@@ -17,7 +17,7 @@ const cardStyles = {
|
|
|
17
17
|
width: "100%",
|
|
18
18
|
outline: "unset!important",
|
|
19
19
|
borderRadius: theme.vars.size.borderRadius.r2,
|
|
20
|
-
backgroundColor: theme.palette.background.
|
|
20
|
+
backgroundColor: theme.vars.palette.background.default,
|
|
21
21
|
height: ownerState?.height ?? "auto",
|
|
22
22
|
minHeight: ownerState?.height ?? "auto",
|
|
23
23
|
maxHeight: ownerState?.height ?? "auto",
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { GetLabelType } from '@m4l/core';
|
|
2
2
|
import { Formatters } from '@m4l/graphics';
|
|
3
3
|
import { DataTypeFilerLabels, FilterField, FilterFieldApplied, FilterValue, FormFilterValueBoolean, InitialFilterApplied } from '../../../types';
|
|
4
|
-
import { IFieldType
|
|
4
|
+
import { IFieldType } from '../FieldTypeInterface';
|
|
5
5
|
import { BooleanFilter } from './index';
|
|
6
|
+
import { ValidationSchema } from '../../../../hook-form/RHFormProvider';
|
|
6
7
|
/**
|
|
7
8
|
* BooleanFilterHelpers es una clase que implementa la interfaz IFieldType
|
|
8
9
|
* para manejar filtros booleanos en un componente de filtro dinámico.
|
|
@@ -28,7 +29,7 @@ export declare class BooleanFilterHelpers implements IFieldType<FormFilterValueB
|
|
|
28
29
|
/**
|
|
29
30
|
* getschema devuelve un esquema de validación para el filtro booleano.
|
|
30
31
|
*/
|
|
31
|
-
getSchema(getLabel: GetLabelType):
|
|
32
|
+
getSchema(getLabel: GetLabelType): ValidationSchema<FormFilterValueBoolean>;
|
|
32
33
|
/**
|
|
33
34
|
* verifyFilter verifica si el filtro es válido.
|
|
34
35
|
*/
|
|
@@ -2,6 +2,7 @@ import * as Yup from "yup";
|
|
|
2
2
|
import { B as BOOLEAN_OPERATORS } from "../../../constants.js";
|
|
3
3
|
import { B as BooleanFilter } from "./index.js";
|
|
4
4
|
import { D as DYNAMIC_FILTER_DICTIONARY_ID, a as DICCTIONARY } from "../../../dictionary.js";
|
|
5
|
+
import { c as createValidationSchema, a as createValidationFullObject, b as createValidationPartialObject } from "../../../../hook-form/RHFormProvider/schema.js";
|
|
5
6
|
class BooleanFilterHelpers {
|
|
6
7
|
getComponent() {
|
|
7
8
|
return BooleanFilter;
|
|
@@ -79,10 +80,10 @@ class BooleanFilterHelpers {
|
|
|
79
80
|
* getschema devuelve un esquema de validación para el filtro booleano.
|
|
80
81
|
*/
|
|
81
82
|
getSchema(getLabel) {
|
|
82
|
-
return
|
|
83
|
+
return createValidationSchema(createValidationFullObject(createValidationPartialObject({
|
|
83
84
|
formValueOperator: Yup.object().nullable().required(getLabel(DICCTIONARY.error_operator_required)),
|
|
84
85
|
formValueOperand1: Yup.object().nullable().required(getLabel(DICCTIONARY.error_operand_required))
|
|
85
|
-
});
|
|
86
|
+
})));
|
|
86
87
|
}
|
|
87
88
|
/**
|
|
88
89
|
* verifyFilter verifica si el filtro es válido.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { GetLabelType } from '@m4l/core';
|
|
2
2
|
import { Formatters } from '@m4l/graphics';
|
|
3
3
|
import { DataTypeFilerLabels, FilterField, FilterFieldApplied, FilterValue, FormFilterValueDateTime, InitialFilterApplied } from '../../../types';
|
|
4
|
-
import { IFieldType
|
|
4
|
+
import { IFieldType } from '../FieldTypeInterface';
|
|
5
5
|
import { DateTimeFilter } from './index';
|
|
6
|
+
import { ValidationSchema } from '../../../../hook-form/RHFormProvider';
|
|
6
7
|
/**
|
|
7
8
|
* DateTimeFilterHelpers es una clase que implementa la interfaz IFieldType
|
|
8
9
|
*/
|
|
@@ -27,7 +28,7 @@ export declare class DateTimeFilterHelpers implements IFieldType<FormFilterValue
|
|
|
27
28
|
/**
|
|
28
29
|
* getschema devuelve el esquema de validación de Yup para un filtro de fecha y hora.
|
|
29
30
|
*/
|
|
30
|
-
getSchema(getLabel: GetLabelType):
|
|
31
|
+
getSchema(getLabel: GetLabelType): ValidationSchema<FormFilterValueDateTime>;
|
|
31
32
|
/**
|
|
32
33
|
* verifyFilter verifica si un filtro de fecha y hora es válido.
|
|
33
34
|
*/
|
|
@@ -4,6 +4,7 @@ import { D as DYNAMIC_FILTER_DICTIONARY_ID, a as DICCTIONARY } from "../../../di
|
|
|
4
4
|
import { D as DateTimeFilter } from "./index.js";
|
|
5
5
|
import { startOfDay, endOfDay } from "date-fns";
|
|
6
6
|
import { i as isValidDate } from "../../../../../utils/isValidDate.js";
|
|
7
|
+
import { c as createValidationSchema, a as createValidationFullObject, b as createValidationPartialObject } from "../../../../hook-form/RHFormProvider/schema.js";
|
|
7
8
|
class DateTimeFilterHelpers {
|
|
8
9
|
getComponent() {
|
|
9
10
|
return DateTimeFilter;
|
|
@@ -109,7 +110,7 @@ class DateTimeFilterHelpers {
|
|
|
109
110
|
* getschema devuelve el esquema de validación de Yup para un filtro de fecha y hora.
|
|
110
111
|
*/
|
|
111
112
|
getSchema(getLabel) {
|
|
112
|
-
return
|
|
113
|
+
return createValidationSchema(createValidationFullObject(createValidationPartialObject({
|
|
113
114
|
formValueOperator: Yup.object().nullable().required(getLabel(DICCTIONARY.error_operator_required)),
|
|
114
115
|
formValueOperand1: Yup.date().required(getLabel(DICCTIONARY.error_invalid_date)).typeError(getLabel(DICCTIONARY.error_invalid_date)),
|
|
115
116
|
formValueOperand2: Yup.mixed().when(["formValueOperator.id"], {
|
|
@@ -119,7 +120,7 @@ class DateTimeFilterHelpers {
|
|
|
119
120
|
getLabel(DICCTIONARY.error_invalid_date)
|
|
120
121
|
)
|
|
121
122
|
})
|
|
122
|
-
});
|
|
123
|
+
})));
|
|
123
124
|
}
|
|
124
125
|
/**
|
|
125
126
|
* verifyFilter verifica si un filtro de fecha y hora es válido.
|
|
@@ -2,18 +2,17 @@ import { GetLabelType } from '@m4l/core';
|
|
|
2
2
|
import { Formatters } from '@m4l/graphics';
|
|
3
3
|
import { FC } from 'react';
|
|
4
4
|
import { DataTypeFilerLabels, FilterField, FilterFieldApplied, FilterValue, InitialFilterApplied } from '../../types';
|
|
5
|
-
import
|
|
6
|
-
export type YupSchema = Yup.SchemaOf<any>;
|
|
5
|
+
import { RHFormValues, ValidationSchema } from '../../../hook-form/RHFormProvider/types';
|
|
7
6
|
/**
|
|
8
7
|
* Interface para crear los helpers de cada tipo de campo
|
|
9
8
|
*/
|
|
10
|
-
export interface IFieldType<T> {
|
|
9
|
+
export interface IFieldType<T extends RHFormValues> {
|
|
11
10
|
getComponent(): FC<{
|
|
12
11
|
[key: string]: any;
|
|
13
12
|
}>;
|
|
14
13
|
getDefaultFilter(field: FilterField, fixed: boolean): FilterFieldApplied;
|
|
15
14
|
getLabels(filter: FilterFieldApplied, getLabel: GetLabelType, formatters: Formatters, field: FilterField): DataTypeFilerLabels;
|
|
16
|
-
getSchema(getLabel: GetLabelType):
|
|
15
|
+
getSchema(getLabel: GetLabelType): ValidationSchema<T>;
|
|
17
16
|
getFormValue(field: FilterField, getLabel: GetLabelType, filterValue?: FilterValue): T;
|
|
18
17
|
getFilterFromFormValue(formFilterValue: T): FilterValue;
|
|
19
18
|
verifyFilter(filter: InitialFilterApplied, field?: FilterField): boolean;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { GetLabelType } from '@m4l/core';
|
|
2
2
|
import { Formatters } from '@m4l/graphics';
|
|
3
3
|
import { DataTypeFilerLabels, FilterField, FilterFieldApplied, FilterValue, FormFilterValueNumber, InitialFilterApplied } from '../../../types';
|
|
4
|
-
import { IFieldType
|
|
4
|
+
import { IFieldType } from '../FieldTypeInterface';
|
|
5
5
|
import { NumberFilter } from './index';
|
|
6
|
+
import { ValidationSchema } from '../../../../hook-form/RHFormProvider/types';
|
|
6
7
|
/**
|
|
7
8
|
* NumberFilterHelpers es una clase que implementa la interfaz IFieldType
|
|
8
9
|
*/
|
|
@@ -27,7 +28,7 @@ export declare class NumberFilterHelpers implements IFieldType<FormFilterValueNu
|
|
|
27
28
|
/**
|
|
28
29
|
* getSchema devuelve el esquema de validación para el filtro.
|
|
29
30
|
*/
|
|
30
|
-
getSchema(getLabel: GetLabelType):
|
|
31
|
+
getSchema(getLabel: GetLabelType): ValidationSchema<FormFilterValueNumber>;
|
|
31
32
|
/**
|
|
32
33
|
* verifyFilter verifica si el filtro es válido.
|
|
33
34
|
*/
|
|
@@ -2,6 +2,7 @@ import * as Yup from "yup";
|
|
|
2
2
|
import { N as NUMBER_OPERATORS } from "../../../constants.js";
|
|
3
3
|
import { N as NumberFilter } from "./index.js";
|
|
4
4
|
import { D as DYNAMIC_FILTER_DICTIONARY_ID, a as DICCTIONARY } from "../../../dictionary.js";
|
|
5
|
+
import { c as createValidationSchema, a as createValidationFullObject, b as createValidationPartialObject } from "../../../../hook-form/RHFormProvider/schema.js";
|
|
5
6
|
class NumberFilterHelpers {
|
|
6
7
|
getComponent() {
|
|
7
8
|
return NumberFilter;
|
|
@@ -93,7 +94,7 @@ class NumberFilterHelpers {
|
|
|
93
94
|
* getSchema devuelve el esquema de validación para el filtro.
|
|
94
95
|
*/
|
|
95
96
|
getSchema(getLabel) {
|
|
96
|
-
return
|
|
97
|
+
return createValidationSchema(createValidationFullObject(createValidationPartialObject({
|
|
97
98
|
formValueOperator: Yup.object().nullable().required(getLabel(DICCTIONARY.error_operator_required)),
|
|
98
99
|
formValueOperand1: Yup.number().typeError(
|
|
99
100
|
getLabel(DICCTIONARY.error_operand_mustbe_number)
|
|
@@ -105,7 +106,7 @@ class NumberFilterHelpers {
|
|
|
105
106
|
getLabel(DICCTIONARY.error_less_than_start)
|
|
106
107
|
)
|
|
107
108
|
})
|
|
108
|
-
});
|
|
109
|
+
})));
|
|
109
110
|
}
|
|
110
111
|
/**
|
|
111
112
|
* verifyFilter verifica si el filtro es válido.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { GetLabelType } from '@m4l/core';
|
|
2
2
|
import { Formatters } from '@m4l/graphics';
|
|
3
3
|
import { DataTypeFilerLabels, FilterField, FilterFieldApplied, FilterValue, FilterValueSelectAsync, FormFilterValueSelectAsync, OperandSelectAsync, InitialFilterApplied } from '../../../types';
|
|
4
|
-
import { IFieldType
|
|
4
|
+
import { IFieldType } from '../FieldTypeInterface';
|
|
5
5
|
import { SelectAsyncFilter } from './index';
|
|
6
|
+
import { ValidationSchema } from '../../../../hook-form/RHFormProvider/types';
|
|
6
7
|
/**
|
|
7
8
|
* Filtra los valores de operandArray para que solo tengan valores validos
|
|
8
9
|
* @param operandsArray valores del OperandsArray
|
|
@@ -34,7 +35,7 @@ export declare class SelectAsyncFilterHelpers implements IFieldType<FormFilterVa
|
|
|
34
35
|
/**
|
|
35
36
|
* getschema devuelve el esquema de validación de Yup para el filtro.
|
|
36
37
|
*/
|
|
37
|
-
getSchema(getLabel: GetLabelType):
|
|
38
|
+
getSchema(getLabel: GetLabelType): ValidationSchema<FormFilterValueSelectAsync>;
|
|
38
39
|
/**
|
|
39
40
|
* verifyFilter verifica si el filtro es válido.
|
|
40
41
|
*/
|
|
@@ -2,6 +2,7 @@ import * as Yup from "yup";
|
|
|
2
2
|
import { S as SELECT_ASYNC_OPERATORS_MULTIPLE, c as SELECT_ASYNC_OPERATORS_SINGLE } from "../../../constants.js";
|
|
3
3
|
import { S as SelectAsyncFilter } from "./index.js";
|
|
4
4
|
import { D as DYNAMIC_FILTER_DICTIONARY_ID, a as DICCTIONARY } from "../../../dictionary.js";
|
|
5
|
+
import { c as createValidationSchema, a as createValidationFullObject, b as createValidationPartialObject } from "../../../../hook-form/RHFormProvider/schema.js";
|
|
5
6
|
function filterValidOperandsArraySelectAsync(operandsArray, field) {
|
|
6
7
|
const operandsArrayFormatted = Array.isArray(operandsArray) ? operandsArray : [operandsArray];
|
|
7
8
|
const getOptionId = field?.selectAsyncOptions?.getOptionId;
|
|
@@ -147,7 +148,7 @@ class SelectAsyncFilterHelpers {
|
|
|
147
148
|
* getschema devuelve el esquema de validación de Yup para el filtro.
|
|
148
149
|
*/
|
|
149
150
|
getSchema(getLabel) {
|
|
150
|
-
return
|
|
151
|
+
return createValidationSchema(createValidationFullObject(createValidationPartialObject({
|
|
151
152
|
formValueOperator: Yup.object().nullable().required(getLabel(DICCTIONARY.error_operator_required)),
|
|
152
153
|
formValueOperandsArray: Yup.mixed().when(["multiple"], {
|
|
153
154
|
is: true,
|
|
@@ -157,7 +158,7 @@ class SelectAsyncFilterHelpers {
|
|
|
157
158
|
is: false,
|
|
158
159
|
then: Yup.object().nullable().required(getLabel(DICCTIONARY.error_operand_required))
|
|
159
160
|
})
|
|
160
|
-
});
|
|
161
|
+
})));
|
|
161
162
|
}
|
|
162
163
|
/**
|
|
163
164
|
* verifyFilter verifica si el filtro es válido.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { GetLabelType } from '@m4l/core';
|
|
2
2
|
import { Formatters } from '@m4l/graphics';
|
|
3
3
|
import { DataTypeFilerLabels, FilterField, FilterFieldApplied, FilterValue, FilterValueSelect, FormFilterValueSelect, OperandSelect, InitialFilterApplied } from '../../../types';
|
|
4
|
-
import { IFieldType
|
|
4
|
+
import { IFieldType } from '../FieldTypeInterface';
|
|
5
5
|
import { SelectFilter } from './index';
|
|
6
|
+
import { ValidationSchema } from '../../../../hook-form/RHFormProvider';
|
|
6
7
|
/**
|
|
7
8
|
* Filtra los valores de operandArray para que solo tengan valores validos
|
|
8
9
|
* @param operandsArray valores del OperandsArray
|
|
@@ -35,7 +36,7 @@ export declare class SelectFilterHelpers implements IFieldType<FormFilterValueSe
|
|
|
35
36
|
/**
|
|
36
37
|
* getSchema devuelve el esquema de validación de Yup para un filtro de selección.
|
|
37
38
|
*/
|
|
38
|
-
getSchema(getLabel: GetLabelType):
|
|
39
|
+
getSchema(getLabel: GetLabelType): ValidationSchema<FormFilterValueSelect>;
|
|
39
40
|
/**
|
|
40
41
|
* TODO: Documentar
|
|
41
42
|
*/
|
|
@@ -2,6 +2,7 @@ import * as Yup from "yup";
|
|
|
2
2
|
import { d as SELECT_OPERATORS_MULTIPLE, e as SELECT_OPERATORS_SINGLE } from "../../../constants.js";
|
|
3
3
|
import { S as SelectFilter } from "./index.js";
|
|
4
4
|
import { D as DYNAMIC_FILTER_DICTIONARY_ID, a as DICCTIONARY } from "../../../dictionary.js";
|
|
5
|
+
import { c as createValidationSchema, a as createValidationFullObject, b as createValidationPartialObject } from "../../../../hook-form/RHFormProvider/schema.js";
|
|
5
6
|
function filterValidOperandsArraySelect(operandsArray, _field) {
|
|
6
7
|
const operandsArrayFormatted = Array.isArray(operandsArray) ? operandsArray : [operandsArray];
|
|
7
8
|
return operandsArrayFormatted?.filter((operand) => {
|
|
@@ -145,7 +146,7 @@ class SelectFilterHelpers {
|
|
|
145
146
|
* getSchema devuelve el esquema de validación de Yup para un filtro de selección.
|
|
146
147
|
*/
|
|
147
148
|
getSchema(getLabel) {
|
|
148
|
-
return
|
|
149
|
+
return createValidationSchema(createValidationFullObject(createValidationPartialObject({
|
|
149
150
|
formValueOperator: Yup.object().nullable().required(getLabel(DICCTIONARY.error_operator_required)),
|
|
150
151
|
formValueOperandsArray: Yup.mixed().when(["multiple"], {
|
|
151
152
|
is: true,
|
|
@@ -161,7 +162,7 @@ class SelectFilterHelpers {
|
|
|
161
162
|
}
|
|
162
163
|
).required(getLabel(DICCTIONARY.error_operand_required))
|
|
163
164
|
})
|
|
164
|
-
});
|
|
165
|
+
})));
|
|
165
166
|
}
|
|
166
167
|
/**
|
|
167
168
|
* TODO: Documentar
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { GetLabelType } from '@m4l/core';
|
|
2
2
|
import { Formatters } from '@m4l/graphics';
|
|
3
3
|
import { DataTypeFilerLabels, FilterField, FilterFieldApplied, FilterValue, FormFilterValueString, InitialFilterApplied } from '../../../types';
|
|
4
|
-
import { IFieldType
|
|
4
|
+
import { IFieldType } from '../FieldTypeInterface';
|
|
5
5
|
import { StringFilter } from './index';
|
|
6
|
+
import { ValidationSchema } from '../../../../hook-form/RHFormProvider/types';
|
|
6
7
|
/**
|
|
7
8
|
* StringFilterHelpers es una clase que implementa la interfaz IFieldType
|
|
8
9
|
*/
|
|
@@ -27,7 +28,7 @@ export declare class StringFilterHelpers implements IFieldType<FormFilterValueSt
|
|
|
27
28
|
/**
|
|
28
29
|
* getSchema devuelve el esquema de validación para el filtro de cadena.
|
|
29
30
|
*/
|
|
30
|
-
getSchema(getLabel: GetLabelType):
|
|
31
|
+
getSchema(getLabel: GetLabelType): ValidationSchema<FormFilterValueString>;
|
|
31
32
|
/**
|
|
32
33
|
* getFilterValue devuelve el valor del filtro.
|
|
33
34
|
*/
|
|
@@ -2,6 +2,7 @@ import * as Yup from "yup";
|
|
|
2
2
|
import { f as STRING_OPERATORS } from "../../../constants.js";
|
|
3
3
|
import { D as DYNAMIC_FILTER_DICTIONARY_ID, a as DICCTIONARY } from "../../../dictionary.js";
|
|
4
4
|
import { S as StringFilter } from "./index.js";
|
|
5
|
+
import { c as createValidationSchema, a as createValidationFullObject, b as createValidationPartialObject } from "../../../../hook-form/RHFormProvider/schema.js";
|
|
5
6
|
class StringFilterHelpers {
|
|
6
7
|
getComponent() {
|
|
7
8
|
return StringFilter;
|
|
@@ -74,12 +75,12 @@ class StringFilterHelpers {
|
|
|
74
75
|
* getSchema devuelve el esquema de validación para el filtro de cadena.
|
|
75
76
|
*/
|
|
76
77
|
getSchema(getLabel) {
|
|
77
|
-
return
|
|
78
|
+
return createValidationSchema(createValidationFullObject(createValidationPartialObject({
|
|
78
79
|
formValueOperator: Yup.object().nullable().required(getLabel(DICCTIONARY.error_operator_required)),
|
|
79
80
|
formValueOperand1: Yup.string().required(
|
|
80
81
|
getLabel(DICCTIONARY.error_operand_required)
|
|
81
82
|
)
|
|
82
|
-
});
|
|
83
|
+
})));
|
|
83
84
|
}
|
|
84
85
|
/**
|
|
85
86
|
* getFilterValue devuelve el valor del filtro.
|
|
@@ -2,7 +2,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { D as DataTypeComponent } from "../FieldTypes/DataTypeComponent.js";
|
|
3
3
|
import { u as usePopoverFilter } from "./usePopoverFilter.js";
|
|
4
4
|
import { P as PopoverStyled, h as PopoverContainerFieldsStyled, i as PopoverHeaderActionsStyled } from "../../slots/dynamicFilterSlots.js";
|
|
5
|
-
import { R as RHFormProvider } from "../../../hook-form/
|
|
5
|
+
import { R as RHFormProvider } from "../../../hook-form/RHFormProvider/RHFormProvider.js";
|
|
6
6
|
import { W as WindowBase } from "../../../WindowBase/WindowBase.js";
|
|
7
7
|
import { A as ActionCancel } from "../../../CommonActions/components/ActionCancel/ActionCancel.js";
|
|
8
8
|
import { A as ActionIntro } from "../../../CommonActions/components/ActionIntro/ActionIntro.js";
|
|
@@ -16,13 +16,7 @@ declare function usePopoverFilter(): {
|
|
|
16
16
|
onClose: () => void;
|
|
17
17
|
filterFormValue: FormFilterValue;
|
|
18
18
|
formFilter: FormFilterFieldApplied;
|
|
19
|
-
popupValidationSchema: import('
|
|
20
|
-
[x: string]: import('yup').ObjectSchema</*elided*/ any, import('yup/lib/object').AnyObject, import('yup/lib/object').TypeOfShape</*elided*/ any>, import('yup/lib/object').AssertsShape</*elided*/ any>> | import('yup').BaseSchema<any, import('yup/lib/object').AnyObject, any> | import('yup').ArraySchema<import('yup').BaseSchema<unknown, import('yup/lib/object').AnyObject, unknown> | import('yup/lib/Lazy').default<import('yup').BaseSchema<unknown, import('yup/lib/object').AnyObject, unknown>, import('yup/lib/object').AnyObject>, import('yup/lib/types').AnyObject, unknown[] | undefined, unknown[] | undefined> | import('yup/lib/Lazy').default<import('yup').ObjectSchema</*elided*/ any, import('yup/lib/object').AnyObject, import('yup/lib/object').TypeOfShape</*elided*/ any>, import('yup/lib/object').AssertsShape</*elided*/ any>>, any>;
|
|
21
|
-
}, import('yup/lib/object').AnyObject, import('yup/lib/object').TypeOfShape<{
|
|
22
|
-
[x: string]: import('yup').ObjectSchema</*elided*/ any, import('yup/lib/object').AnyObject, import('yup/lib/object').TypeOfShape</*elided*/ any>, import('yup/lib/object').AssertsShape</*elided*/ any>> | import('yup').BaseSchema<any, import('yup/lib/object').AnyObject, any> | import('yup').ArraySchema<import('yup').BaseSchema<unknown, import('yup/lib/object').AnyObject, unknown> | import('yup/lib/Lazy').default<import('yup').BaseSchema<unknown, import('yup/lib/object').AnyObject, unknown>, import('yup/lib/object').AnyObject>, import('yup/lib/types').AnyObject, unknown[] | undefined, unknown[] | undefined> | import('yup/lib/Lazy').default<import('yup').ObjectSchema</*elided*/ any, import('yup/lib/object').AnyObject, import('yup/lib/object').TypeOfShape</*elided*/ any>, import('yup/lib/object').AssertsShape</*elided*/ any>>, any>;
|
|
23
|
-
}>, import('yup/lib/object').AssertsShape<{
|
|
24
|
-
[x: string]: import('yup').ObjectSchema</*elided*/ any, import('yup/lib/object').AnyObject, import('yup/lib/object').TypeOfShape</*elided*/ any>, import('yup/lib/object').AssertsShape</*elided*/ any>> | import('yup').BaseSchema<any, import('yup/lib/object').AnyObject, any> | import('yup').ArraySchema<import('yup').BaseSchema<unknown, import('yup/lib/object').AnyObject, unknown> | import('yup/lib/Lazy').default<import('yup').BaseSchema<unknown, import('yup/lib/object').AnyObject, unknown>, import('yup/lib/object').AnyObject>, import('yup/lib/types').AnyObject, unknown[] | undefined, unknown[] | undefined> | import('yup/lib/Lazy').default<import('yup').ObjectSchema</*elided*/ any, import('yup/lib/object').AnyObject, import('yup/lib/object').TypeOfShape</*elided*/ any>, import('yup/lib/object').AssertsShape</*elided*/ any>>, any>;
|
|
25
|
-
}>> | undefined;
|
|
19
|
+
popupValidationSchema: import('../../..').ValidationSchema<import('../../types').FormFilterValueBoolean> | undefined;
|
|
26
20
|
statusLoad: "initial" | "reload_values_provider" | "ready";
|
|
27
21
|
};
|
|
28
22
|
export default usePopoverFilter;
|
|
@@ -2,8 +2,7 @@ import { GetLabelType } from '@m4l/core';
|
|
|
2
2
|
import { Formatters } from '@m4l/graphics';
|
|
3
3
|
import { FC } from 'react';
|
|
4
4
|
import { DataTypeFilerLabels, FormSortValueBase, InitialSortApplied, SortField, SortFieldApplied, SortValue } from '../../types';
|
|
5
|
-
import
|
|
6
|
-
export type YupSchema = Yup.SchemaOf<any>;
|
|
5
|
+
import { ValidationSchema } from '../../../hook-form/RHFormProvider/types';
|
|
7
6
|
/**
|
|
8
7
|
* Interface para crear los helpers de cada tipo de campo
|
|
9
8
|
*/
|
|
@@ -13,7 +12,7 @@ export interface IFieldType {
|
|
|
13
12
|
}>;
|
|
14
13
|
getDefaultSort(field: SortField, fixed: boolean): SortFieldApplied;
|
|
15
14
|
getLabels(Sort: SortFieldApplied, getLabel: GetLabelType, formatters: Formatters, field: SortField): DataTypeFilerLabels;
|
|
16
|
-
getSchema(getLabel: GetLabelType):
|
|
15
|
+
getSchema(getLabel: GetLabelType): ValidationSchema<FormSortValueBase>;
|
|
17
16
|
getFormValue(field: SortField, getLabel: GetLabelType, sortValue?: SortValue): FormSortValueBase;
|
|
18
17
|
getSortFromFormValue(formSortValue: FormSortValueBase): SortValue;
|
|
19
18
|
verifySort(Sort: InitialSortApplied, field?: SortField): boolean;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { GetLabelType } from '@m4l/core';
|
|
2
2
|
import { Formatters } from '@m4l/graphics';
|
|
3
3
|
import { DataTypeFilerLabels, FormSortValueBase, InitialSortApplied, SortField, SortFieldApplied, SortValue } from '../../../types';
|
|
4
|
-
import { IFieldType
|
|
4
|
+
import { IFieldType } from '../FieldTypeInterface';
|
|
5
5
|
import { StringSort } from './index';
|
|
6
|
+
import { ValidationSchema } from '../../../../hook-form/RHFormProvider/types';
|
|
6
7
|
/**
|
|
7
8
|
* Clase que implementa los métodos necesarios para el tipo de campo string
|
|
8
9
|
*/
|
|
@@ -27,7 +28,7 @@ export declare class SortHelpers implements IFieldType {
|
|
|
27
28
|
/**
|
|
28
29
|
* getSchema obtiene el esquema de un campo de tipo string
|
|
29
30
|
*/
|
|
30
|
-
getSchema(getLabel: GetLabelType):
|
|
31
|
+
getSchema(getLabel: GetLabelType): ValidationSchema<FormSortValueBase>;
|
|
31
32
|
/**
|
|
32
33
|
* verifySort verifica si un campo de tipo string es válido
|
|
33
34
|
*/
|
|
@@ -2,6 +2,7 @@ import * as Yup from "yup";
|
|
|
2
2
|
import { O as OPERATORS } from "../../../constants.js";
|
|
3
3
|
import { g as getDynamicSortDictionary } from "../../../dictionary.js";
|
|
4
4
|
import { S as StringSort } from "./index.js";
|
|
5
|
+
import { c as createValidationSchema, a as createValidationFullObject, b as createValidationPartialObject } from "../../../../hook-form/RHFormProvider/schema.js";
|
|
5
6
|
class SortHelpers {
|
|
6
7
|
getComponent() {
|
|
7
8
|
return StringSort;
|
|
@@ -59,9 +60,9 @@ class SortHelpers {
|
|
|
59
60
|
* getSchema obtiene el esquema de un campo de tipo string
|
|
60
61
|
*/
|
|
61
62
|
getSchema(getLabel) {
|
|
62
|
-
return
|
|
63
|
+
return createValidationSchema(createValidationFullObject(createValidationPartialObject({
|
|
63
64
|
formValueOperator: Yup.string().required(getLabel(`dynamic_Sort.error_operator_required`))
|
|
64
|
-
});
|
|
65
|
+
})));
|
|
65
66
|
}
|
|
66
67
|
/**
|
|
67
68
|
* verifySort verifica si un campo de tipo string es válido
|
|
@@ -3,7 +3,7 @@ import { u as useDynamicSortBase } from "../DynamicSortBase/useDynamicSortBase.j
|
|
|
3
3
|
import { D as DataTypeComponent } from "../FieldTypes/DataTypeComponent.js";
|
|
4
4
|
import { u as usePopoverSort } from "./usePopoverSort.js";
|
|
5
5
|
import { e as PopoverStyled, f as PopoverContainerFieldsStyled, g as PopoverHeaderActionsStyled } from "../../slots/DynamicSortSlots.js";
|
|
6
|
-
import { R as RHFormProvider } from "../../../hook-form/
|
|
6
|
+
import { R as RHFormProvider } from "../../../hook-form/RHFormProvider/RHFormProvider.js";
|
|
7
7
|
import { W as WindowBase } from "../../../WindowBase/WindowBase.js";
|
|
8
8
|
import { A as ActionCancel } from "../../../CommonActions/components/ActionCancel/ActionCancel.js";
|
|
9
9
|
import { A as ActionIntro } from "../../../CommonActions/components/ActionIntro/ActionIntro.js";
|
|
@@ -16,13 +16,7 @@ declare function usePopoverSort(): {
|
|
|
16
16
|
onClose: () => void;
|
|
17
17
|
sortFormValue: import('../../types').FormSortValueBase;
|
|
18
18
|
formSort: FormSortFieldApplied;
|
|
19
|
-
popupValidationSchema: import('
|
|
20
|
-
[x: string]: import('yup').ObjectSchema</*elided*/ any, import('yup/lib/object').AnyObject, import('yup/lib/object').TypeOfShape</*elided*/ any>, import('yup/lib/object').AssertsShape</*elided*/ any>> | import('yup').BaseSchema<any, import('yup/lib/object').AnyObject, any> | import('yup').ArraySchema<import('yup').BaseSchema<unknown, import('yup/lib/object').AnyObject, unknown> | import('yup/lib/Lazy').default<import('yup').BaseSchema<unknown, import('yup/lib/object').AnyObject, unknown>, import('yup/lib/object').AnyObject>, import('yup/lib/types').AnyObject, unknown[] | undefined, unknown[] | undefined> | import('yup/lib/Lazy').default<import('yup').ObjectSchema</*elided*/ any, import('yup/lib/object').AnyObject, import('yup/lib/object').TypeOfShape</*elided*/ any>, import('yup/lib/object').AssertsShape</*elided*/ any>>, any>;
|
|
21
|
-
}, import('yup/lib/object').AnyObject, import('yup/lib/object').TypeOfShape<{
|
|
22
|
-
[x: string]: import('yup').ObjectSchema</*elided*/ any, import('yup/lib/object').AnyObject, import('yup/lib/object').TypeOfShape</*elided*/ any>, import('yup/lib/object').AssertsShape</*elided*/ any>> | import('yup').BaseSchema<any, import('yup/lib/object').AnyObject, any> | import('yup').ArraySchema<import('yup').BaseSchema<unknown, import('yup/lib/object').AnyObject, unknown> | import('yup/lib/Lazy').default<import('yup').BaseSchema<unknown, import('yup/lib/object').AnyObject, unknown>, import('yup/lib/object').AnyObject>, import('yup/lib/types').AnyObject, unknown[] | undefined, unknown[] | undefined> | import('yup/lib/Lazy').default<import('yup').ObjectSchema</*elided*/ any, import('yup/lib/object').AnyObject, import('yup/lib/object').TypeOfShape</*elided*/ any>, import('yup/lib/object').AssertsShape</*elided*/ any>>, any>;
|
|
23
|
-
}>, import('yup/lib/object').AssertsShape<{
|
|
24
|
-
[x: string]: import('yup').ObjectSchema</*elided*/ any, import('yup/lib/object').AnyObject, import('yup/lib/object').TypeOfShape</*elided*/ any>, import('yup/lib/object').AssertsShape</*elided*/ any>> | import('yup').BaseSchema<any, import('yup/lib/object').AnyObject, any> | import('yup').ArraySchema<import('yup').BaseSchema<unknown, import('yup/lib/object').AnyObject, unknown> | import('yup/lib/Lazy').default<import('yup').BaseSchema<unknown, import('yup/lib/object').AnyObject, unknown>, import('yup/lib/object').AnyObject>, import('yup/lib/types').AnyObject, unknown[] | undefined, unknown[] | undefined> | import('yup/lib/Lazy').default<import('yup').ObjectSchema</*elided*/ any, import('yup/lib/object').AnyObject, import('yup/lib/object').TypeOfShape</*elided*/ any>, import('yup/lib/object').AssertsShape</*elided*/ any>>, any>;
|
|
25
|
-
}>> | undefined;
|
|
19
|
+
popupValidationSchema: import('../../..').ValidationSchema<import('../../types').FormSortValueBase> | undefined;
|
|
26
20
|
statusLoad: "initial" | "reload_values_provider" | "ready";
|
|
27
21
|
};
|
|
28
22
|
export default usePopoverSort;
|
|
@@ -134,7 +134,7 @@ const AreasAdmin = (props) => {
|
|
|
134
134
|
}
|
|
135
135
|
),
|
|
136
136
|
maximizedId && windowsLayouts.length > 1 && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(ContainerAdminWindowsStyled, { size: currentSize, ownerState, children: [
|
|
137
|
-
/* @__PURE__ */ jsx(Typography, { size: currentSize, children: getLabel(getAreasDictionary(AREAS_DICCTIONARY.label_window)) }),
|
|
137
|
+
/* @__PURE__ */ jsx(Typography, { size: currentSize, skeletonWidth: "80px", children: getLabel(getAreasDictionary(AREAS_DICCTIONARY.label_window)) }),
|
|
138
138
|
/* @__PURE__ */ jsx(
|
|
139
139
|
MenuActions,
|
|
140
140
|
{
|
|
@@ -12,8 +12,9 @@ import { g as getAreasDictionary, A as AREAS_DICCTIONARY } from "../../../../dic
|
|
|
12
12
|
import { A as AREAS_ADMIN_KEY_COMPONENT } from "../../constants.js";
|
|
13
13
|
import { g as getComponentClasses } from "../../../../../../utils/getComponentSlotRoot.js";
|
|
14
14
|
import { u as useComponentSize } from "../../../../../../hooks/useComponentSize/useComponentSize.js";
|
|
15
|
+
import { c as createValidationSchema, a as createValidationFullObject, b as createValidationPartialObject } from "../../../../../hook-form/RHFormProvider/schema.js";
|
|
15
16
|
import { A as AreasAdminSlots } from "../../slots/AreasAdminEnum.js";
|
|
16
|
-
import { R as RHFormProvider } from "../../../../../hook-form/
|
|
17
|
+
import { R as RHFormProvider } from "../../../../../hook-form/RHFormProvider/RHFormProvider.js";
|
|
17
18
|
import { T as Typography } from "../../../../../mui_extended/Typography/Typography.js";
|
|
18
19
|
import { R as RHFTextField } from "../../../../../hook-form/RHFTextField/RHFTextField.js";
|
|
19
20
|
import { A as ActionsContainer } from "../../../../../CommonActions/components/ActionsContainer/ActionsContainer.js";
|
|
@@ -56,11 +57,11 @@ const AreaChip = (props) => {
|
|
|
56
57
|
inputEditArea: areaName
|
|
57
58
|
};
|
|
58
59
|
const validationSchema = useMemo(
|
|
59
|
-
() =>
|
|
60
|
+
() => createValidationSchema(createValidationFullObject(createValidationPartialObject({
|
|
60
61
|
inputEditArea: Yup.string().required(
|
|
61
62
|
getLabel(getAreasDictionary(AREAS_DICCTIONARY.validation_edit_area))
|
|
62
63
|
)
|
|
63
|
-
}),
|
|
64
|
+
}))),
|
|
64
65
|
[getLabel]
|
|
65
66
|
);
|
|
66
67
|
const handlerOnClick = (e) => {
|
|
@@ -9,9 +9,10 @@ import { g as getAreasDictionary, A as AREAS_DICCTIONARY } from "../../../../../
|
|
|
9
9
|
import { I as ICONS } from "../../../../../../icons.js";
|
|
10
10
|
import { C as ChipActionsMobile } from "../../../AreaChip/subcomponents/ChipActionsMobile/ChipActionsMobile.js";
|
|
11
11
|
import { l as ChipMobileRootStyled, m as ChipMobileContentStyled, N as NameChipMobileStyled, n as EditAreaChipMobileContainerStyled } from "../../../../slots/AreasAdminSlots.js";
|
|
12
|
-
import { R as RHFormProvider } from "../../../../../../../hook-form/
|
|
12
|
+
import { R as RHFormProvider } from "../../../../../../../hook-form/RHFormProvider/RHFormProvider.js";
|
|
13
13
|
import { T as Typography } from "../../../../../../../mui_extended/Typography/Typography.js";
|
|
14
14
|
import { A as ActionsContainer } from "../../../../../../../CommonActions/components/ActionsContainer/ActionsContainer.js";
|
|
15
|
+
import { c as createValidationSchema, a as createValidationFullObject, b as createValidationPartialObject } from "../../../../../../../hook-form/RHFormProvider/schema.js";
|
|
15
16
|
import { M as MenuActions } from "../../../../../../../MenuActions/MenuActions.js";
|
|
16
17
|
import { P as Popover } from "../../../../../../../mui_extended/Popover/Popover.js";
|
|
17
18
|
import { R as RHFTextField } from "../../../../../../../hook-form/RHFTextField/RHFTextField.js";
|
|
@@ -44,11 +45,11 @@ const ChipMobile = (props) => {
|
|
|
44
45
|
inputEditArea: areaName
|
|
45
46
|
};
|
|
46
47
|
const validationSchema = useMemo(
|
|
47
|
-
() =>
|
|
48
|
+
() => createValidationSchema(createValidationFullObject(createValidationPartialObject({
|
|
48
49
|
inputEditArea: Yup.string().required(
|
|
49
50
|
getLabel(getAreasDictionary(AREAS_DICCTIONARY.validation_edit_area))
|
|
50
51
|
)
|
|
51
|
-
}),
|
|
52
|
+
}))),
|
|
52
53
|
[getLabel]
|
|
53
54
|
);
|
|
54
55
|
const handlerOnClick = (e) => {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ReactElement, RefAttributes } from 'react';
|
|
2
|
+
import { CustomFormArguments, FormProviderCustomProps, RHFormProviderProps, RHFormProviderRef, RHFormValues } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* useCustomForm se encarga de crear los metodos del formulario y validar el statusLoad para recargar los valores del formulario nuevamente.
|
|
5
|
+
* Cuando statusLoad es 'reload_values_provider' se actualizan los valores del formulario, debido a que se cargaron del backend.
|
|
6
|
+
* Cuando statusLoad es 'ready' se actualiza el statusLoad del formulario a 'ready', para que los que useWatch puedan ser efectivos despues de la carga de los datos.
|
|
7
|
+
* Se recomienda usar useFormReadyForUpdate que se nutre de statusLoad e indica que el formulario esta listo para ser usado.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useCustomForm<T extends RHFormValues>({ validationSchema, values, statusLoad, mode, }: CustomFormArguments<T>): import('react-hook-form').UseFormReturn<T, undefined, T>;
|
|
10
|
+
/**
|
|
11
|
+
* Componente que extiende FormProviderCustomBase para poder ser usado dentro del forwardRef garantizando el tipado.
|
|
12
|
+
*/
|
|
13
|
+
export declare const FormProviderCustom: <T extends RHFormValues>(props: FormProviderCustomProps<T> & RefAttributes<RHFormProviderRef<T>>) => ReactElement;
|
|
14
|
+
export declare const RHFormProvider: <T extends RHFormValues>(props: RHFormProviderProps<T> & RefAttributes<RHFormProviderRef<T>>) => ReactElement;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect, useImperativeHandle } from "react";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import { useForm, FormProvider } 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
|
+
const fieldName = key;
|
|
25
|
+
const fieldValue = values[key];
|
|
26
|
+
formMethods.setValue(fieldName, fieldValue, {
|
|
27
|
+
shouldValidate: false,
|
|
28
|
+
shouldDirty: false,
|
|
29
|
+
shouldTouch: false
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
formMethods.clearErrors();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
}, [formMethods, statusLoad, values]);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (statusLoad === "ready") {
|
|
38
|
+
formMethods.setValue("statusLoad", "ready", {
|
|
39
|
+
shouldValidate: false,
|
|
40
|
+
shouldDirty: false,
|
|
41
|
+
shouldTouch: false
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}, [statusLoad]);
|
|
45
|
+
return formMethods;
|
|
46
|
+
}
|
|
47
|
+
const FormProviderCustomBase = (props, ref) => {
|
|
48
|
+
const { children, onSubmit, onSubmitError, className, formMethods } = props;
|
|
49
|
+
useImperativeHandle(
|
|
50
|
+
ref,
|
|
51
|
+
() => ({
|
|
52
|
+
formMethods,
|
|
53
|
+
onSubmit
|
|
54
|
+
}),
|
|
55
|
+
[formMethods, onSubmit]
|
|
56
|
+
);
|
|
57
|
+
return /* @__PURE__ */ jsx(FormProvider, { ...formMethods, children: /* @__PURE__ */ jsx(
|
|
58
|
+
FormProviderRoot,
|
|
59
|
+
{
|
|
60
|
+
className: clsx(classes.root, className),
|
|
61
|
+
onSubmit: formMethods.handleSubmit(
|
|
62
|
+
onSubmit,
|
|
63
|
+
onSubmitError
|
|
64
|
+
),
|
|
65
|
+
children
|
|
66
|
+
}
|
|
67
|
+
) });
|
|
68
|
+
};
|
|
69
|
+
const FormProviderCustomForward = forwardRef(FormProviderCustomBase);
|
|
70
|
+
FormProviderCustomForward.displayName = "FormProviderCustom";
|
|
71
|
+
const FormProviderCustom = FormProviderCustomForward;
|
|
72
|
+
const RHFormProviderBase = forwardRef(
|
|
73
|
+
(props, ref) => {
|
|
74
|
+
const { children, onSubmit, onSubmitError, values, validationSchema, statusLoad = "ready", className, mode } = props;
|
|
75
|
+
const formMethods = useCustomForm({ validationSchema, statusLoad, values, mode });
|
|
76
|
+
return /* @__PURE__ */ jsx(
|
|
77
|
+
FormProviderCustom,
|
|
78
|
+
{
|
|
79
|
+
ref,
|
|
80
|
+
className,
|
|
81
|
+
values,
|
|
82
|
+
validationSchema,
|
|
83
|
+
statusLoad,
|
|
84
|
+
onSubmit,
|
|
85
|
+
onSubmitError,
|
|
86
|
+
formMethods,
|
|
87
|
+
children
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
RHFormProviderBase.displayName = "RHFormProvider";
|
|
93
|
+
const RHFormProvider = RHFormProviderBase;
|
|
94
|
+
export {
|
|
95
|
+
FormProviderCustom as F,
|
|
96
|
+
RHFormProvider as R,
|
|
97
|
+
useCustomForm as u
|
|
98
|
+
};
|