@m4l/components 9.3.29 → 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.
Files changed (62) hide show
  1. package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/helpers.d.ts +3 -2
  2. package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/helpers.js +3 -2
  3. package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/helpers.d.ts +3 -2
  4. package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/helpers.js +3 -2
  5. package/components/DynamicFilter/subcomponents/FieldTypes/FieldTypeInterface.d.ts +3 -4
  6. package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/helpers.d.ts +3 -2
  7. package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/helpers.js +3 -2
  8. package/components/DynamicFilter/subcomponents/FieldTypes/SelectAsyncFilter/helpers.d.ts +3 -2
  9. package/components/DynamicFilter/subcomponents/FieldTypes/SelectAsyncFilter/helpers.js +3 -2
  10. package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/helpers.d.ts +3 -2
  11. package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/helpers.js +3 -2
  12. package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/helpers.d.ts +3 -2
  13. package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/helpers.js +3 -2
  14. package/components/DynamicFilter/subcomponents/PopoverFilter/PopoverFilter.js +1 -1
  15. package/components/DynamicFilter/subcomponents/PopoverFilter/usePopoverFilter.d.ts +1 -7
  16. package/components/DynamicSort/subcomponents/FieldTypes/FieldTypeInterface.d.ts +2 -3
  17. package/components/DynamicSort/subcomponents/FieldTypes/StringSort/helpers.d.ts +3 -2
  18. package/components/DynamicSort/subcomponents/FieldTypes/StringSort/helpers.js +3 -2
  19. package/components/DynamicSort/subcomponents/PopoverSort/PopoverSort.js +1 -1
  20. package/components/DynamicSort/subcomponents/PopoverSort/usePopoverSort.d.ts +1 -7
  21. package/components/areas/components/AreasAdmin/subcomponents/AreaChip/AreaChip.js +4 -3
  22. package/components/areas/components/AreasAdmin/subcomponents/AreaChipMobile/subcomponents/ChipMobile/ChipMobile.js +4 -3
  23. package/components/areas/contexts/AreasContext/store.js +2 -2
  24. package/components/hook-form/RHFormProvider/RHFormProvider.d.ts +31 -0
  25. package/components/hook-form/RHFormProvider/RHFormProvider.js +93 -0
  26. package/components/hook-form/RHFormProvider/index.d.ts +4 -0
  27. package/components/hook-form/RHFormProvider/index.js +1 -0
  28. package/components/hook-form/RHFormProvider/schema.d.ts +17 -0
  29. package/components/hook-form/RHFormProvider/schema.js +29 -0
  30. package/components/hook-form/RHFormProvider/types.d.ts +129 -0
  31. package/components/hook-form/RHFormProvider/types.js +8 -0
  32. package/components/hook-form/index.d.ts +1 -0
  33. package/contexts/index.d.ts +3 -3
  34. package/helpers/getStepsAndValidationSchema/getStepsAndValidationSchema.d.ts +3 -3
  35. package/helpers/getStepsAndValidationSchema/getStepsAndValidationSchema.js +3 -3
  36. package/helpers/getStepsAndValidationSchema/types.d.ts +5 -4
  37. package/hooks/index.d.ts +1 -0
  38. package/hooks/useFormAddEdit/index.d.ts +1 -1
  39. package/hooks/useWatchTyped/index.d.ts +1 -0
  40. package/hooks/useWatchTyped/index.js +1 -0
  41. package/hooks/useWatchTyped/types.d.ts +11 -0
  42. package/hooks/useWatchTyped/useTypedWatch.d.ts +9 -0
  43. package/hooks/useWatchTyped/useTypedWatch.js +30 -0
  44. package/index.js +46 -35
  45. package/package.json +1 -1
  46. package/components/hook-form/RHFormContext/index.d.ts +0 -120
  47. package/components/hook-form/RHFormContext/index.js +0 -91
  48. package/components/hook-form/RHFormContext/types.d.ts +0 -83
  49. package/hooks/useFormReadyForUpdate/types.d.ts +0 -8
  50. /package/components/hook-form/{RHFormContext → RHFormProvider}/classes/constants.d.ts +0 -0
  51. /package/components/hook-form/{RHFormContext → RHFormProvider}/classes/constants.js +0 -0
  52. /package/components/hook-form/{RHFormContext → RHFormProvider}/classes/index.d.ts +0 -0
  53. /package/components/hook-form/{RHFormContext → RHFormProvider}/classes/index.js +0 -0
  54. /package/components/hook-form/{RHFormContext → RHFormProvider}/classes/types.d.ts +0 -0
  55. /package/components/hook-form/{RHFormContext → RHFormProvider}/dictionary.d.ts +0 -0
  56. /package/components/hook-form/{RHFormContext → RHFormProvider}/dictionary.js +0 -0
  57. /package/components/hook-form/{RHFormContext → RHFormProvider}/styles.d.ts +0 -0
  58. /package/components/hook-form/{RHFormContext → RHFormProvider}/styles.js +0 -0
  59. /package/components/hook-form/{RHFormContext → RHFormProvider}/subcomponents/FormActions/index.d.ts +0 -0
  60. /package/components/hook-form/{RHFormContext → RHFormProvider}/subcomponents/FormActions/skeleton.d.ts +0 -0
  61. /package/components/hook-form/{RHFormContext → RHFormProvider}/subcomponents/FormActions/styles.d.ts +0 -0
  62. /package/components/hook-form/{RHFormContext → RHFormProvider}/subcomponents/FormActions/types.d.ts +0 -0
@@ -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, YupSchema } from '../FieldTypeInterface';
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): YupSchema;
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 Yup.object({
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, YupSchema } from '../FieldTypeInterface';
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): YupSchema;
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 Yup.object({
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 * as Yup from 'yup';
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): YupSchema;
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, YupSchema } from '../FieldTypeInterface';
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): YupSchema;
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 Yup.object({
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, YupSchema } from '../FieldTypeInterface';
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): YupSchema;
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 Yup.object({
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, YupSchema } from '../FieldTypeInterface';
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): YupSchema;
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 Yup.object({
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, YupSchema } from '../FieldTypeInterface';
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): YupSchema;
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 Yup.object({
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/RHFormContext/index.js";
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('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').BaseSchema<any, import('yup/lib/object').AnyObject, any> | import('yup').ObjectSchema<{
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 * as Yup from 'yup';
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): YupSchema;
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, YupSchema } from '../FieldTypeInterface';
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): YupSchema;
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 Yup.object({
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/RHFormContext/index.js";
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('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').BaseSchema<any, import('yup/lib/object').AnyObject, any> | import('yup').ObjectSchema<{
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;
@@ -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/RHFormContext/index.js";
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
- () => Yup.object().shape({
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/RHFormContext/index.js";
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
- () => Yup.object().shape({
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) => {
@@ -441,8 +441,8 @@ const createAreasStore = (initProps, storeDevtoolsEnabled = false) => {
441
441
  bounds: {
442
442
  left: MARGIN_GRIDLAYOUT,
443
443
  top: MARGIN_GRIDLAYOUT,
444
- right: -MARGIN_GRIDLAYOUT,
445
- bottom: -MARGIN_GRIDLAYOUT
444
+ right: -10,
445
+ bottom: -10
446
446
  }
447
447
  });
448
448
  }
@@ -0,0 +1,31 @@
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, any, undefined>;
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
+ /**
15
+ * Componente principal que gestiona el `Provider` de `react-hook-form` y encapsula el formulario para la creación de formularios personalizados.
16
+ *
17
+ * Este componente utiliza internamente `useCustomForm` para inicializar todos los métodos necesarios para la manipulación del formulario,
18
+ * incluyendo validación con Yup, protegida con ValidationSchema<T> para garantizar que solo se usen claves declaradas en el tipo del formulario sean las que participen
19
+ *
20
+ *
21
+ * **Características principales:**
22
+ * - Integración completa con React Hook Form
23
+ * - Validación automática usando esquemas de Yup
24
+ * - Gestión de estados de carga para actualización de valores
25
+ * - Exposición de métodos del formulario a través de refs
26
+ * - Soporte para diferentes modos de validación
27
+ *
28
+ * Si necesitas acceso directo a los métodos de `useForm`, puedes utilizar el `Provider` y el hook por separado mediante
29
+ * `FormProviderCustom` y `useCustomForm`, respectivamente.
30
+ */
31
+ export declare const RHFormProvider: import('react').ForwardRefExoticComponent<RHFormProviderProps<RHFormValues> & RefAttributes<RHFormProviderRef<RHFormValues>>>;
@@ -0,0 +1,93 @@
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, 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(onSubmit),
62
+ children
63
+ }
64
+ ) });
65
+ };
66
+ const FormProviderCustomForward = forwardRef(FormProviderCustomBase);
67
+ FormProviderCustomForward.displayName = "FormProviderCustom";
68
+ const FormProviderCustom = FormProviderCustomForward;
69
+ const RHFormProvider = forwardRef(
70
+ (props, ref) => {
71
+ const { children, onSubmit, values, validationSchema, statusLoad = "ready", className, mode } = props;
72
+ const formMethods = useCustomForm({ validationSchema, statusLoad, values, mode });
73
+ return /* @__PURE__ */ jsx(
74
+ FormProviderCustom,
75
+ {
76
+ ref,
77
+ className,
78
+ values,
79
+ validationSchema,
80
+ statusLoad,
81
+ onSubmit,
82
+ formMethods,
83
+ children
84
+ }
85
+ );
86
+ }
87
+ );
88
+ RHFormProvider.displayName = "RHFormProvider";
89
+ export {
90
+ FormProviderCustom as F,
91
+ RHFormProvider as R,
92
+ useCustomForm as u
93
+ };
@@ -0,0 +1,4 @@
1
+ export * from './RHFormProvider';
2
+ export type { ValidationSchema, ValidationShape, ValidationFullObject as ValidationObject, ValidationPartialObject, RHFormInitialValues, RHFormValues, } from './types';
3
+ export { VALIDATION_SCHEMA_BRAND, VALIDATION_PARTIAL_OBJECT_BRAND, VALIDATION_OBJECT_BRAND, } from './types';
4
+ export * from './schema';