@m4l/components 9.4.34 → 9.4.35-beta-feature-dynamicform-crear-componente.0
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/CheckableList/slots/styled.d.ts +1 -1
- package/components/DaysOfWeekPicker/hooks/types.d.ts +2 -1
- package/components/DaysOfWeekPicker/hooks/types.d.ts.map +1 -1
- package/components/DaysOfWeekPicker/hooks/useDaysOfWeekPicker.d.ts.map +1 -1
- package/components/DaysOfWeekPicker/hooks/useDaysOfWeekPicker.js +32 -32
- package/components/DaysOfWeekPicker/types.d.ts +1 -1
- package/components/DaysOfWeekPicker/types.d.ts.map +1 -1
- package/components/DynamicForm/DynamicForm.d.ts +29 -0
- package/components/DynamicForm/DynamicForm.d.ts.map +1 -0
- package/components/DynamicForm/DynamicForm.js +96 -0
- package/components/DynamicForm/DynamicForm.styles.d.ts +3 -0
- package/components/DynamicForm/DynamicForm.styles.d.ts.map +1 -0
- package/components/DynamicForm/DynamicForm.styles.js +78 -0
- package/components/DynamicForm/constants.d.ts +15 -0
- package/components/DynamicForm/constants.d.ts.map +1 -0
- package/components/DynamicForm/constants.js +16 -0
- package/components/DynamicForm/dictionary.d.ts +15 -0
- package/components/DynamicForm/dictionary.d.ts.map +1 -0
- package/components/DynamicForm/dictionary.js +16 -0
- package/components/DynamicForm/helpers/applyRequiredValidation/applyRequiredValidation.d.ts +13 -0
- package/components/DynamicForm/helpers/applyRequiredValidation/applyRequiredValidation.d.ts.map +1 -0
- package/components/DynamicForm/helpers/applyRequiredValidation/applyRequiredValidation.js +19 -0
- package/components/DynamicForm/helpers/applyRequiredValidation/index.d.ts +3 -0
- package/components/DynamicForm/helpers/applyRequiredValidation/index.d.ts.map +1 -0
- package/components/DynamicForm/helpers/applyRequiredValidation/types.d.ts +7 -0
- package/components/DynamicForm/helpers/applyRequiredValidation/types.d.ts.map +1 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/createFieldValidationSchema.d.ts +13 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/createFieldValidationSchema.d.ts.map +1 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/createFieldValidationSchema.js +35 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/index.d.ts +3 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/index.d.ts.map +1 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/strategies/baseSchema/baseSchemaStrategies.d.ts +43 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/strategies/baseSchema/baseSchemaStrategies.d.ts.map +1 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/strategies/baseSchema/baseSchemaStrategies.js +134 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/strategies/baseSchema/createBaseSchema.d.ts +7 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/strategies/baseSchema/createBaseSchema.d.ts.map +1 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/strategies/baseSchema/createBaseSchema.js +9 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/strategies/baseSchema/index.d.ts +4 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/strategies/baseSchema/index.d.ts.map +1 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/strategies/baseSchema/types.d.ts +22 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/strategies/baseSchema/types.d.ts.map +1 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/strategies/validation/index.d.ts +3 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/strategies/validation/index.d.ts.map +1 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/strategies/validation/types.d.ts +27 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/strategies/validation/types.d.ts.map +1 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/strategies/validation/validationStrategies.d.ts +25 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/strategies/validation/validationStrategies.d.ts.map +1 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/strategies/validation/validationStrategies.js +200 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/types.d.ts +6 -0
- package/components/DynamicForm/helpers/createFieldValidationSchema/types.d.ts.map +1 -0
- package/components/DynamicForm/helpers/createIsOptionEqualToValue/createIsOptionEqualToValue.d.ts +7 -0
- package/components/DynamicForm/helpers/createIsOptionEqualToValue/createIsOptionEqualToValue.d.ts.map +1 -0
- package/components/DynamicForm/helpers/createIsOptionEqualToValue/createIsOptionEqualToValue.js +6 -0
- package/components/DynamicForm/helpers/createIsOptionEqualToValue/index.d.ts +2 -0
- package/components/DynamicForm/helpers/createIsOptionEqualToValue/index.d.ts.map +1 -0
- package/components/DynamicForm/helpers/evaluateConditionalRule/evaluateConditionalRule.d.ts +11 -0
- package/components/DynamicForm/helpers/evaluateConditionalRule/evaluateConditionalRule.d.ts.map +1 -0
- package/components/DynamicForm/helpers/evaluateConditionalRule/evaluateConditionalRule.js +26 -0
- package/components/DynamicForm/helpers/evaluateConditionalRule/index.d.ts +3 -0
- package/components/DynamicForm/helpers/evaluateConditionalRule/index.d.ts.map +1 -0
- package/components/DynamicForm/helpers/evaluateConditionalRule/types.d.ts +7 -0
- package/components/DynamicForm/helpers/evaluateConditionalRule/types.d.ts.map +1 -0
- package/components/DynamicForm/helpers/index.d.ts +9 -0
- package/components/DynamicForm/helpers/index.d.ts.map +1 -0
- package/components/DynamicForm/helpers/normalizeValidation/index.d.ts +3 -0
- package/components/DynamicForm/helpers/normalizeValidation/index.d.ts.map +1 -0
- package/components/DynamicForm/helpers/normalizeValidation/normalizeValidation.d.ts +9 -0
- package/components/DynamicForm/helpers/normalizeValidation/normalizeValidation.d.ts.map +1 -0
- package/components/DynamicForm/helpers/normalizeValidation/normalizeValidation.js +9 -0
- package/components/DynamicForm/helpers/normalizeValidation/types.d.ts +6 -0
- package/components/DynamicForm/helpers/normalizeValidation/types.d.ts.map +1 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/index.d.ts +3 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/index.d.ts.map +1 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/resolveFieldComponent.d.ts +12 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/resolveFieldComponent.d.ts.map +1 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/resolveFieldComponent.js +56 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/autocompleteStrategy/autocompleteStrategy.d.ts +7 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/autocompleteStrategy/autocompleteStrategy.d.ts.map +1 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/autocompleteStrategy/autocompleteStrategy.js +36 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/checkableListStrategy/checkableListStrategy.d.ts +7 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/checkableListStrategy/checkableListStrategy.d.ts.map +1 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/checkableListStrategy/checkableListStrategy.js +28 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/checkboxStrategy/checkboxStrategy.d.ts +4 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/checkboxStrategy/checkboxStrategy.d.ts.map +1 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/checkboxStrategy/checkboxStrategy.js +24 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/dateRangePickerStrategy/dateRangePickerStrategy.d.ts +4 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/dateRangePickerStrategy/dateRangePickerStrategy.d.ts.map +1 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/dateRangePickerStrategy/dateRangePickerStrategy.js +24 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/daysOfWeekPickerStrategy/daysOfWeekPickerStrategy.d.ts +4 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/daysOfWeekPickerStrategy/daysOfWeekPickerStrategy.d.ts.map +1 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/daysOfWeekPickerStrategy/daysOfWeekPickerStrategy.js +27 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/index.d.ts +12 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/index.d.ts.map +1 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/numberInputStrategy/numberInputStrategy.d.ts +4 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/numberInputStrategy/numberInputStrategy.d.ts.map +1 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/numberInputStrategy/numberInputStrategy.js +24 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/radioGroupStrategy/radioGroupStrategy.d.ts +7 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/radioGroupStrategy/radioGroupStrategy.d.ts.map +1 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/radioGroupStrategy/radioGroupStrategy.js +27 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/registry.d.ts +7 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/registry.d.ts.map +1 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/registry.js +29 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/selectStrategy/selectStrategy.d.ts +4 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/selectStrategy/selectStrategy.d.ts.map +1 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/selectStrategy/selectStrategy.js +27 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/textFieldStrategy/textFieldStrategy.d.ts +4 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/textFieldStrategy/textFieldStrategy.d.ts.map +1 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/textFieldStrategy/textFieldStrategy.js +25 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/types.d.ts +34 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/strategies/types.d.ts.map +1 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/types.d.ts +9 -0
- package/components/DynamicForm/helpers/resolveFieldComponent/types.d.ts.map +1 -0
- package/components/DynamicForm/helpers/resolveInitialValue/index.d.ts +3 -0
- package/components/DynamicForm/helpers/resolveInitialValue/index.d.ts.map +1 -0
- package/components/DynamicForm/helpers/resolveInitialValue/resolveInitialValue.d.ts +19 -0
- package/components/DynamicForm/helpers/resolveInitialValue/resolveInitialValue.d.ts.map +1 -0
- package/components/DynamicForm/helpers/resolveInitialValue/resolveInitialValue.js +64 -0
- package/components/DynamicForm/helpers/resolveInitialValue/types.d.ts +13 -0
- package/components/DynamicForm/helpers/resolveInitialValue/types.d.ts.map +1 -0
- package/components/DynamicForm/helpers/stringifyJsonFieldsForSubmit/index.d.ts +2 -0
- package/components/DynamicForm/helpers/stringifyJsonFieldsForSubmit/index.d.ts.map +1 -0
- package/components/DynamicForm/helpers/stringifyJsonFieldsForSubmit/stringifyJsonFieldsForSubmit.d.ts +14 -0
- package/components/DynamicForm/helpers/stringifyJsonFieldsForSubmit/stringifyJsonFieldsForSubmit.d.ts.map +1 -0
- package/components/DynamicForm/helpers/stringifyJsonFieldsForSubmit/stringifyJsonFieldsForSubmit.js +16 -0
- package/components/DynamicForm/hooks/useDynamicForm/useDynamicForm.d.ts +16 -0
- package/components/DynamicForm/hooks/useDynamicForm/useDynamicForm.d.ts.map +1 -0
- package/components/DynamicForm/hooks/useDynamicForm/useDynamicForm.js +90 -0
- package/components/DynamicForm/hooks/useDynamicFormConditionals/useDynamicFormConditionals.d.ts +13 -0
- package/components/DynamicForm/hooks/useDynamicFormConditionals/useDynamicFormConditionals.d.ts.map +1 -0
- package/components/DynamicForm/hooks/useDynamicFormConditionals/useDynamicFormConditionals.js +25 -0
- package/components/DynamicForm/hooks/useDynamicFormCoupled/index.d.ts +3 -0
- package/components/DynamicForm/hooks/useDynamicFormCoupled/index.d.ts.map +1 -0
- package/components/DynamicForm/hooks/useDynamicFormCoupled/types.d.ts +43 -0
- package/components/DynamicForm/hooks/useDynamicFormCoupled/types.d.ts.map +1 -0
- package/components/DynamicForm/hooks/useDynamicFormCoupled/useDynamicFormCoupled.d.ts +54 -0
- package/components/DynamicForm/hooks/useDynamicFormCoupled/useDynamicFormCoupled.d.ts.map +1 -0
- package/components/DynamicForm/hooks/useDynamicFormCoupled/useDynamicFormCoupled.js +53 -0
- package/components/DynamicForm/hooks/useDynamicFormData/types.d.ts +20 -0
- package/components/DynamicForm/hooks/useDynamicFormData/types.d.ts.map +1 -0
- package/components/DynamicForm/hooks/useDynamicFormData/useDynamicFormData.d.ts +14 -0
- package/components/DynamicForm/hooks/useDynamicFormData/useDynamicFormData.d.ts.map +1 -0
- package/components/DynamicForm/hooks/useDynamicFormData/useDynamicFormData.js +74 -0
- package/components/DynamicForm/hooks/useFieldsWithFetchedOptions/index.d.ts +3 -0
- package/components/DynamicForm/hooks/useFieldsWithFetchedOptions/index.d.ts.map +1 -0
- package/components/DynamicForm/hooks/useFieldsWithFetchedOptions/normalizeOptionsResponse.d.ts +7 -0
- package/components/DynamicForm/hooks/useFieldsWithFetchedOptions/normalizeOptionsResponse.d.ts.map +1 -0
- package/components/DynamicForm/hooks/useFieldsWithFetchedOptions/normalizeOptionsResponse.js +20 -0
- package/components/DynamicForm/hooks/useFieldsWithFetchedOptions/types.d.ts +12 -0
- package/components/DynamicForm/hooks/useFieldsWithFetchedOptions/types.d.ts.map +1 -0
- package/components/DynamicForm/hooks/useFieldsWithFetchedOptions/useFieldsWithFetchedOptions.d.ts +7 -0
- package/components/DynamicForm/hooks/useFieldsWithFetchedOptions/useFieldsWithFetchedOptions.d.ts.map +1 -0
- package/components/DynamicForm/hooks/useFieldsWithFetchedOptions/useFieldsWithFetchedOptions.js +56 -0
- package/components/DynamicForm/index.d.ts +7 -0
- package/components/DynamicForm/index.d.ts.map +1 -0
- package/components/DynamicForm/slots/DynamicFormEnum.d.ts +13 -0
- package/components/DynamicForm/slots/DynamicFormEnum.d.ts.map +1 -0
- package/components/DynamicForm/slots/DynamicFormEnum.js +4 -0
- package/components/DynamicForm/slots/DynamicFormSlots.d.ts +11 -0
- package/components/DynamicForm/slots/DynamicFormSlots.d.ts.map +1 -0
- package/components/DynamicForm/slots/DynamicFormSlots.js +40 -0
- package/components/DynamicForm/slots/index.d.ts +4 -0
- package/components/DynamicForm/slots/index.d.ts.map +1 -0
- package/components/DynamicForm/subcomponents/DynamicFormContent/DynamicFormContent.d.ts +3 -0
- package/components/DynamicForm/subcomponents/DynamicFormContent/DynamicFormContent.d.ts.map +1 -0
- package/components/DynamicForm/subcomponents/DynamicFormContent/DynamicFormContent.js +56 -0
- package/components/DynamicForm/types.d.ts +346 -0
- package/components/DynamicForm/types.d.ts.map +1 -0
- package/components/EditLabel/slots/EditLabelSlots.d.ts +1 -1
- package/components/extended/mui/Autocomplete/slots/AutocompleteSlots.d.ts +1 -1
- package/components/extended/mui/DatePicker/slots/DatePickerSlots.d.ts +1 -1
- package/components/extended/mui/Select/slots/SelectSlots.d.ts +1 -1
- package/components/extended/mui/TextField/slots/TextFieldSlots.d.ts +1 -1
- package/components/extended/rsuite/DateRangePicker/DateRangePicker.d.ts.map +1 -1
- package/components/extended/rsuite/DateRangePicker/DateRangePicker.js +30 -32
- package/components/hook-form/RHFAutocomplete/RHFAutocomplete.d.ts.map +1 -1
- package/components/hook-form/RHFAutocomplete/RHFAutocomplete.js +48 -46
- package/components/hook-form/RHFDatePicker/slots/RHFDatePickerSlots.d.ts +1 -1
- package/components/hook-form/RHFPeriod/slots/RHFPeriodSlots.d.ts +1 -1
- package/components/hook-form/RHFSelect/slots/RHFSlots.d.ts +1 -1
- package/components/hook-form/RHFTextField/slots/RHFTextFieldSlots.d.ts +1 -1
- package/components/hook-form/RHFTextFieldPassword/slots/RHFTextFieldPasswordSlots.d.ts +1 -1
- package/components/hook-form/RHFormProvider/styles.d.ts.map +1 -1
- package/components/hook-form/RHFormProvider/styles.js +11 -2
- package/components/hook-form/RHFormProvider/types.d.ts +7 -7
- package/components/index.d.ts +1 -0
- package/components/index.d.ts.map +1 -1
- package/index.js +467 -457
- package/package.json +9 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseSchemaStrategies.d.ts","sourceRoot":"","sources":["../../../../../../../../../../packages/components/src/components/DynamicForm/helpers/createFieldValidationSchema/strategies/baseSchema/baseSchemaStrategies.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAoB,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAmBpE,uDAAuD;AACvD,eAAO,MAAM,2BAA2B,EAAE,kBAczC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,+BAA+B,EAAE,kBAkB7C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAE,kBAmBtC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,kBAkBvC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,4BAA4B,EAAE,kBAa1C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAE,kBAetC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,8BAA8B,EAAE,kBAiB5C,CAAC;AAEF,wCAAwC;AACxC,eAAO,MAAM,2BAA2B,EAAE,kBAOzC,CAAC;AAEF,oDAAoD;AACpD,eAAO,MAAM,+BAA+B,EAAE,kBAO7C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,kBAAkB,EAUtD,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import * as t from "yup";
|
|
2
|
+
const n = () => t.object().shape({
|
|
3
|
+
start: t.date().nullable(),
|
|
4
|
+
end: t.date().nullable()
|
|
5
|
+
}).nullable(), a = () => t.array().of(t.mixed()), o = {
|
|
6
|
+
/**
|
|
7
|
+
* Returns true if this strategy applies to the field (i.e. field is a date range).
|
|
8
|
+
* @param field - Form field to check (uses fieldType.rhfComponent and fieldType.id).
|
|
9
|
+
* @returns True if the field is a date range field (RHFDateRangePicker or fft_date_range).
|
|
10
|
+
*/
|
|
11
|
+
applies(e) {
|
|
12
|
+
return e.fieldType.rhfComponent === "RHFDateRangePicker" || e.fieldType.id === "fft_date_range";
|
|
13
|
+
},
|
|
14
|
+
create() {
|
|
15
|
+
return n();
|
|
16
|
+
}
|
|
17
|
+
}, p = {
|
|
18
|
+
/**
|
|
19
|
+
* Returns true if this strategy applies to the field (checkable list or days of week).
|
|
20
|
+
* @param field - Form field to check.
|
|
21
|
+
* @returns True if the field is RHFCheckableList, RHFDaysOfWeekPicker, or fft_checkable_list.
|
|
22
|
+
*/
|
|
23
|
+
applies(e) {
|
|
24
|
+
const r = e.fieldType.rhfComponent;
|
|
25
|
+
return r === "RHFCheckableList" || r === "RHFDaysOfWeekPicker" || e.fieldType.id === "fft_checkable_list";
|
|
26
|
+
},
|
|
27
|
+
/** Returns a Yup array-of-mixed schema for the field. */
|
|
28
|
+
create() {
|
|
29
|
+
return a();
|
|
30
|
+
}
|
|
31
|
+
}, l = {
|
|
32
|
+
/**
|
|
33
|
+
* Returns true if this strategy applies to the field (number/integer/double type).
|
|
34
|
+
* @param field - Form field to check.
|
|
35
|
+
* @returns True if the field is RHFNumberInput or fft_number, fft_integer, fft_double.
|
|
36
|
+
*/
|
|
37
|
+
applies(e) {
|
|
38
|
+
const r = e.fieldType.id;
|
|
39
|
+
return e.fieldType.rhfComponent === "RHFNumberInput" || r === "fft_number" || r === "fft_integer" || r === "fft_double";
|
|
40
|
+
},
|
|
41
|
+
/** Returns a Yup number schema for the field. */
|
|
42
|
+
create() {
|
|
43
|
+
return t.number();
|
|
44
|
+
}
|
|
45
|
+
}, i = {
|
|
46
|
+
/**
|
|
47
|
+
* Returns true if this strategy applies to the field (checkbox/boolean type).
|
|
48
|
+
* @param field - Form field to check (uses fieldType.rhfComponent and fieldType.id).
|
|
49
|
+
* @returns True if the field is RHFCheckbox or fft_boolean or fft_checkbox.
|
|
50
|
+
*/
|
|
51
|
+
applies(e) {
|
|
52
|
+
const r = e.fieldType.id;
|
|
53
|
+
return e.fieldType.rhfComponent === "RHFCheckbox" || r === "fft_boolean" || r === "fft_checkbox";
|
|
54
|
+
},
|
|
55
|
+
/** Returns a Yup boolean schema for the field. */
|
|
56
|
+
create() {
|
|
57
|
+
return t.boolean();
|
|
58
|
+
}
|
|
59
|
+
}, s = {
|
|
60
|
+
/**
|
|
61
|
+
* Returns true if this strategy applies to the field (RHFRadioGroup).
|
|
62
|
+
* @param field - Form field to check.
|
|
63
|
+
* @returns True if the field is RHFRadioGroup.
|
|
64
|
+
*/
|
|
65
|
+
applies(e) {
|
|
66
|
+
return e.fieldType.rhfComponent === "RHFRadioGroup";
|
|
67
|
+
},
|
|
68
|
+
/** Returns a Yup mixed schema for string or number (selected option value). */
|
|
69
|
+
create() {
|
|
70
|
+
return t.mixed();
|
|
71
|
+
}
|
|
72
|
+
}, c = {
|
|
73
|
+
/**
|
|
74
|
+
* Returns true if this strategy applies to the field (RHFSelect).
|
|
75
|
+
* @param field - Form field to check.
|
|
76
|
+
* @returns True if the field is RHFSelect.
|
|
77
|
+
*/
|
|
78
|
+
applies(e) {
|
|
79
|
+
return e.fieldType.rhfComponent === "RHFSelect";
|
|
80
|
+
},
|
|
81
|
+
/** Returns a Yup string or array schema depending on isMultiple. */
|
|
82
|
+
create(e) {
|
|
83
|
+
return e.fieldType.rhfComponentProps?.isMultiple === !0 ? a() : t.string();
|
|
84
|
+
}
|
|
85
|
+
}, u = {
|
|
86
|
+
/**
|
|
87
|
+
* Returns true if this strategy applies to the field (RHFAutoComplete).
|
|
88
|
+
* @param field - Form field to check.
|
|
89
|
+
* @returns True if the field is RHFAutoComplete.
|
|
90
|
+
*/
|
|
91
|
+
applies(e) {
|
|
92
|
+
return e.fieldType.rhfComponent === "RHFAutoComplete";
|
|
93
|
+
},
|
|
94
|
+
/** Returns a Yup mixed/array schema depending on isMultiple. */
|
|
95
|
+
create(e) {
|
|
96
|
+
return e.fieldType.rhfComponentProps?.isMultiple === !0 ? t.array().of(t.mixed()) : t.mixed().nullable();
|
|
97
|
+
}
|
|
98
|
+
}, f = {
|
|
99
|
+
applies(e) {
|
|
100
|
+
return e.fieldType.rhfComponent === "RHFTextField";
|
|
101
|
+
},
|
|
102
|
+
create() {
|
|
103
|
+
return t.string();
|
|
104
|
+
}
|
|
105
|
+
}, d = {
|
|
106
|
+
applies() {
|
|
107
|
+
return !0;
|
|
108
|
+
},
|
|
109
|
+
create() {
|
|
110
|
+
return t.string();
|
|
111
|
+
}
|
|
112
|
+
}, m = [
|
|
113
|
+
o,
|
|
114
|
+
p,
|
|
115
|
+
l,
|
|
116
|
+
i,
|
|
117
|
+
s,
|
|
118
|
+
c,
|
|
119
|
+
u,
|
|
120
|
+
f,
|
|
121
|
+
d
|
|
122
|
+
];
|
|
123
|
+
export {
|
|
124
|
+
m as BASE_SCHEMA_STRATEGIES,
|
|
125
|
+
u as autocompleteBaseSchemaStrategy,
|
|
126
|
+
i as booleanBaseSchemaStrategy,
|
|
127
|
+
p as checkableListBaseSchemaStrategy,
|
|
128
|
+
o as dateRangeBaseSchemaStrategy,
|
|
129
|
+
d as defaultStringBaseSchemaStrategy,
|
|
130
|
+
l as numberBaseSchemaStrategy,
|
|
131
|
+
s as radioGroupBaseSchemaStrategy,
|
|
132
|
+
c as selectBaseSchemaStrategy,
|
|
133
|
+
f as textFieldBaseSchemaStrategy
|
|
134
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Field } from '../../../../types';
|
|
2
|
+
import { BaseSchemaResult } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Creates the base Yup schema for a field using the first matching base schema strategy.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createBaseSchema(field: Field): BaseSchemaResult;
|
|
7
|
+
//# sourceMappingURL=createBaseSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createBaseSchema.d.ts","sourceRoot":"","sources":["../../../../../../../../../../packages/components/src/components/DynamicForm/helpers/createFieldValidationSchema/strategies/baseSchema/createBaseSchema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,gBAAgB,CAG/D"}
|
package/components/DynamicForm/helpers/createFieldValidationSchema/strategies/baseSchema/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createBaseSchema } from './createBaseSchema';
|
|
2
|
+
export type { BaseSchemaResult, BaseSchemaStrategy } from './types';
|
|
3
|
+
export { BASE_SCHEMA_STRATEGIES, dateRangeBaseSchemaStrategy, checkableListBaseSchemaStrategy, numberBaseSchemaStrategy, booleanBaseSchemaStrategy, selectBaseSchemaStrategy, autocompleteBaseSchemaStrategy, textFieldBaseSchemaStrategy, defaultStringBaseSchemaStrategy, } from './baseSchemaStrategies';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../../packages/components/src/components/DynamicForm/helpers/createFieldValidationSchema/strategies/baseSchema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EACL,sBAAsB,EACtB,2BAA2B,EAC3B,+BAA+B,EAC/B,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,8BAA8B,EAC9B,2BAA2B,EAC3B,+BAA+B,GAChC,MAAM,wBAAwB,CAAC"}
|
package/components/DynamicForm/helpers/createFieldValidationSchema/strategies/baseSchema/types.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Field } from '../../../../types';
|
|
2
|
+
import * as Yup from 'yup';
|
|
3
|
+
/**
|
|
4
|
+
* Result type for base schema creation.
|
|
5
|
+
* Matches the schema union used by createFieldValidationSchema.
|
|
6
|
+
*/
|
|
7
|
+
export type BaseSchemaResult = Yup.StringSchema | Yup.NumberSchema | Yup.BooleanSchema | Yup.ArraySchema<any, any, any, any> | Yup.ObjectSchema<any, any, any, any> | ReturnType<typeof Yup.mixed>;
|
|
8
|
+
/**
|
|
9
|
+
* Strategy for creating the base Yup schema for a field based on its type.
|
|
10
|
+
* Each implementation handles one or more field types (by rhfComponent or fieldType.id).
|
|
11
|
+
*/
|
|
12
|
+
export interface BaseSchemaStrategy {
|
|
13
|
+
/**
|
|
14
|
+
* Returns true if this strategy should be used for the given field.
|
|
15
|
+
*/
|
|
16
|
+
applies(field: Field): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Creates the base Yup schema for the field.
|
|
19
|
+
*/
|
|
20
|
+
create(field: Field): BaseSchemaResult;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../../../../packages/components/src/components/DynamicForm/helpers/createFieldValidationSchema/strategies/baseSchema/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GACxB,GAAG,CAAC,YAAY,GAChB,GAAG,CAAC,YAAY,GAChB,GAAG,CAAC,aAAa,GACjB,GAAG,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GACnC,GAAG,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GACpC,UAAU,CAAC,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AAEjC;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC;IAE/B;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,gBAAgB,CAAC;CACxC"}
|
package/components/DynamicForm/helpers/createFieldValidationSchema/strategies/validation/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type { ValidationStrategy, ValidationStrategyContext } from './types';
|
|
2
|
+
export { VALIDATION_STRATEGY_REGISTRY, requiredValidationStrategy, maxLengthValidationStrategy, minLengthValidationStrategy, maxValidationStrategy, minValidationStrategy, emailValidationStrategy, urlValidationStrategy, patternValidationStrategy, customValidationStrategy, } from './validationStrategies';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../../packages/components/src/components/DynamicForm/helpers/createFieldValidationSchema/strategies/validation/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,2BAA2B,EAC3B,2BAA2B,EAC3B,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC"}
|
package/components/DynamicForm/helpers/createFieldValidationSchema/strategies/validation/types.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Field, FieldValidation } from '../../../../types';
|
|
2
|
+
import { GetLabelType } from '@m4l/core';
|
|
3
|
+
import { YupFieldSchema } from '../../../applyRequiredValidation/types';
|
|
4
|
+
/**
|
|
5
|
+
* Context passed to each validation strategy when applying a validation rule.
|
|
6
|
+
*/
|
|
7
|
+
export interface ValidationStrategyContext {
|
|
8
|
+
field: Field;
|
|
9
|
+
getLabel: GetLabelType;
|
|
10
|
+
baseSchema: YupFieldSchema;
|
|
11
|
+
schema: YupFieldSchema;
|
|
12
|
+
validation: FieldValidation;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Strategy for applying a single validation type (e.g. required, max_length) to a Yup schema.
|
|
16
|
+
* Each implementation handles one validation type id and returns the schema with that validation applied.
|
|
17
|
+
*/
|
|
18
|
+
export interface ValidationStrategy {
|
|
19
|
+
/** Validation type id from the API (e.g. 'fvl_required', 'fvl_max_length'). */
|
|
20
|
+
readonly validationTypeId: string;
|
|
21
|
+
/**
|
|
22
|
+
* Applies this validation to the current schema.
|
|
23
|
+
* Returns the schema (possibly modified); may return the same schema if the validation does not apply.
|
|
24
|
+
*/
|
|
25
|
+
apply(ctx: ValidationStrategyContext): YupFieldSchema;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../../../../packages/components/src/components/DynamicForm/helpers/createFieldValidationSchema/strategies/validation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAE7E;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,YAAY,CAAC;IACvB,UAAU,EAAE,cAAc,CAAC;IAC3B,MAAM,EAAE,cAAc,CAAC;IACvB,UAAU,EAAE,eAAe,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,+EAA+E;IAC/E,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAElC;;;OAGG;IACH,KAAK,CAAC,GAAG,EAAE,yBAAyB,GAAG,cAAc,CAAC;CACvD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ValidationStrategy } from './types';
|
|
2
|
+
/** Required validation: uses applyRequiredValidation with message from validation or dictionary. */
|
|
3
|
+
export declare const requiredValidationStrategy: ValidationStrategy;
|
|
4
|
+
/** Max length (string). */
|
|
5
|
+
export declare const maxLengthValidationStrategy: ValidationStrategy;
|
|
6
|
+
/** Min length (string). */
|
|
7
|
+
export declare const minLengthValidationStrategy: ValidationStrategy;
|
|
8
|
+
/** Max value (number). */
|
|
9
|
+
export declare const maxValidationStrategy: ValidationStrategy;
|
|
10
|
+
/** Min value (number). */
|
|
11
|
+
export declare const minValidationStrategy: ValidationStrategy;
|
|
12
|
+
/** Email format (string). */
|
|
13
|
+
export declare const emailValidationStrategy: ValidationStrategy;
|
|
14
|
+
/** URL format (string). */
|
|
15
|
+
export declare const urlValidationStrategy: ValidationStrategy;
|
|
16
|
+
/** Pattern/regex (string). */
|
|
17
|
+
export declare const patternValidationStrategy: ValidationStrategy;
|
|
18
|
+
/** Custom validation: regex or exact value for string/number. */
|
|
19
|
+
export declare const customValidationStrategy: ValidationStrategy;
|
|
20
|
+
/**
|
|
21
|
+
* Registry of validation strategies by validation type id.
|
|
22
|
+
* Used to apply each active validation without a switch.
|
|
23
|
+
*/
|
|
24
|
+
export declare const VALIDATION_STRATEGY_REGISTRY: Record<string, ValidationStrategy>;
|
|
25
|
+
//# sourceMappingURL=validationStrategies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validationStrategies.d.ts","sourceRoot":"","sources":["../../../../../../../../../../packages/components/src/components/DynamicForm/helpers/createFieldValidationSchema/strategies/validation/validationStrategies.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,oGAAoG;AACpG,eAAO,MAAM,0BAA0B,EAAE,kBAuBxC,CAAC;AAEF,2BAA2B;AAC3B,eAAO,MAAM,2BAA2B,EAAE,kBAoBzC,CAAC;AAEF,2BAA2B;AAC3B,eAAO,MAAM,2BAA2B,EAAE,kBAoBzC,CAAC;AAEF,0BAA0B;AAC1B,eAAO,MAAM,qBAAqB,EAAE,kBAoBnC,CAAC;AAEF,0BAA0B;AAC1B,eAAO,MAAM,qBAAqB,EAAE,kBAoBnC,CAAC;AAEF,6BAA6B;AAC7B,eAAO,MAAM,uBAAuB,EAAE,kBAerC,CAAC;AAEF,2BAA2B;AAC3B,eAAO,MAAM,qBAAqB,EAAE,kBAenC,CAAC;AAEF,8BAA8B;AAC9B,eAAO,MAAM,yBAAyB,EAAE,kBAuBvC,CAAC;AAEF,iEAAiE;AACjE,eAAO,MAAM,wBAAwB,EAAE,kBA6DtC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,4BAA4B,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAU3E,CAAC"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import * as u from "yup";
|
|
2
|
+
import { applyRequiredValidation as h } from "../../../applyRequiredValidation/applyRequiredValidation.js";
|
|
3
|
+
import { DYNAMIC_FORM_DICTIONARY as l } from "../../../../dictionary.js";
|
|
4
|
+
const d = {
|
|
5
|
+
validationTypeId: "fvl_required",
|
|
6
|
+
/**
|
|
7
|
+
* Applies required validation when the field is required; otherwise returns the schema unchanged.
|
|
8
|
+
* @param ctx - Context with field, getLabel, baseSchema, schema, and validation
|
|
9
|
+
* @returns Schema with required validation applied, or unchanged schema
|
|
10
|
+
*/
|
|
11
|
+
apply(i) {
|
|
12
|
+
const { field: e, getLabel: n, baseSchema: r, schema: t, validation: o } = i;
|
|
13
|
+
if (!e.isRequired)
|
|
14
|
+
return t;
|
|
15
|
+
const a = e.fieldType.rhfComponent === "RHFDateRangePicker" || e.fieldType.id === "fft_date_range", s = o.errorMessage || (a && e.helperText ? e.helperText : n(a ? l.DATE_RANGE_REQUIRED_MESSAGE : l.IS_REQUIRED_MESSAGE));
|
|
16
|
+
return h(e, t, r, s);
|
|
17
|
+
}
|
|
18
|
+
}, p = {
|
|
19
|
+
validationTypeId: "fvl_max_length",
|
|
20
|
+
/**
|
|
21
|
+
* Applies max length constraint to string schema when validation value is present.
|
|
22
|
+
* @param ctx - Context with field, getLabel, baseSchema, schema, and validation
|
|
23
|
+
* @returns Schema with `.max(length)` applied, or unchanged schema if not applicable
|
|
24
|
+
*/
|
|
25
|
+
apply(i) {
|
|
26
|
+
const { validation: e, getLabel: n, baseSchema: r, schema: t } = i;
|
|
27
|
+
if (!(e.validationType || e.type)?.requiresValue || !e.value || !(r instanceof u.StringSchema))
|
|
28
|
+
return t;
|
|
29
|
+
const a = parseInt(e.value, 10);
|
|
30
|
+
if (isNaN(a))
|
|
31
|
+
return t;
|
|
32
|
+
const s = e.errorMessage || n(l.MAX_LENGTH_MESSAGE, a);
|
|
33
|
+
return t.max(a, s);
|
|
34
|
+
}
|
|
35
|
+
}, v = {
|
|
36
|
+
validationTypeId: "fvl_min_length",
|
|
37
|
+
/**
|
|
38
|
+
* Applies min length constraint to string schema when validation value is present.
|
|
39
|
+
* @param ctx - Context with field, getLabel, baseSchema, schema, and validation
|
|
40
|
+
* @returns Schema with `.min(length)` applied, or unchanged schema if not applicable
|
|
41
|
+
*/
|
|
42
|
+
apply(i) {
|
|
43
|
+
const { validation: e, getLabel: n, baseSchema: r, schema: t } = i;
|
|
44
|
+
if (!(e.validationType || e.type)?.requiresValue || !e.value || !(r instanceof u.StringSchema))
|
|
45
|
+
return t;
|
|
46
|
+
const a = parseInt(e.value, 10);
|
|
47
|
+
if (isNaN(a))
|
|
48
|
+
return t;
|
|
49
|
+
const s = e.errorMessage || n(l.MIN_LENGTH_MESSAGE, a);
|
|
50
|
+
return t.min(a, s);
|
|
51
|
+
}
|
|
52
|
+
}, S = {
|
|
53
|
+
validationTypeId: "fvl_max",
|
|
54
|
+
/**
|
|
55
|
+
* Applies maximum numeric value constraint when validation value is present.
|
|
56
|
+
* @param ctx - Context with field, getLabel, baseSchema, schema, and validation
|
|
57
|
+
* @returns Schema with `.max(value)` applied, or unchanged schema if not applicable
|
|
58
|
+
*/
|
|
59
|
+
apply(i) {
|
|
60
|
+
const { validation: e, getLabel: n, baseSchema: r, schema: t } = i;
|
|
61
|
+
if (!(e.validationType || e.type)?.requiresValue || !e.value || !(r instanceof u.NumberSchema))
|
|
62
|
+
return t;
|
|
63
|
+
const a = parseFloat(e.value);
|
|
64
|
+
if (isNaN(a))
|
|
65
|
+
return t;
|
|
66
|
+
const s = e.errorMessage || n(l.MAX_VALUE_MESSAGE, a);
|
|
67
|
+
return t.max(a, s);
|
|
68
|
+
}
|
|
69
|
+
}, g = {
|
|
70
|
+
validationTypeId: "fvl_min",
|
|
71
|
+
/**
|
|
72
|
+
* Applies minimum numeric value constraint when validation value is present.
|
|
73
|
+
* @param ctx - Context with field, getLabel, baseSchema, schema, and validation
|
|
74
|
+
* @returns Schema with `.min(value)` applied, or unchanged schema if not applicable
|
|
75
|
+
*/
|
|
76
|
+
apply(i) {
|
|
77
|
+
const { validation: e, getLabel: n, baseSchema: r, schema: t } = i;
|
|
78
|
+
if (!(e.validationType || e.type)?.requiresValue || !e.value || !(r instanceof u.NumberSchema))
|
|
79
|
+
return t;
|
|
80
|
+
const a = parseFloat(e.value);
|
|
81
|
+
if (isNaN(a))
|
|
82
|
+
return t;
|
|
83
|
+
const s = e.errorMessage || n(l.MIN_VALUE_MESSAGE, a);
|
|
84
|
+
return t.min(a, s);
|
|
85
|
+
}
|
|
86
|
+
}, y = {
|
|
87
|
+
validationTypeId: "fvl_email",
|
|
88
|
+
/**
|
|
89
|
+
* Applies email format validation to string schema.
|
|
90
|
+
* @param ctx - Context with field, getLabel, baseSchema, schema, and validation
|
|
91
|
+
* @returns Schema with `.email()` applied, or unchanged schema if base is not string
|
|
92
|
+
*/
|
|
93
|
+
apply(i) {
|
|
94
|
+
const { validation: e, getLabel: n, baseSchema: r, schema: t } = i;
|
|
95
|
+
if (!(r instanceof u.StringSchema))
|
|
96
|
+
return t;
|
|
97
|
+
const o = e.errorMessage || n(l.EMAIL_INVALID_MESSAGE);
|
|
98
|
+
return t.email(o);
|
|
99
|
+
}
|
|
100
|
+
}, f = {
|
|
101
|
+
validationTypeId: "fvl_url",
|
|
102
|
+
/**
|
|
103
|
+
* Applies URL format validation to string schema.
|
|
104
|
+
* @param ctx - Context with field, getLabel, baseSchema, schema, and validation
|
|
105
|
+
* @returns Schema with `.url()` applied, or unchanged schema if base is not string
|
|
106
|
+
*/
|
|
107
|
+
apply(i) {
|
|
108
|
+
const { validation: e, getLabel: n, baseSchema: r, schema: t } = i;
|
|
109
|
+
if (!(r instanceof u.StringSchema))
|
|
110
|
+
return t;
|
|
111
|
+
const o = e.errorMessage || n(l.URL_INVALID_MESSAGE);
|
|
112
|
+
return t.url(o);
|
|
113
|
+
}
|
|
114
|
+
}, I = {
|
|
115
|
+
validationTypeId: "fvl_pattern",
|
|
116
|
+
/**
|
|
117
|
+
* Applies regex pattern validation to string schema when validation value is present.
|
|
118
|
+
* Invalid regex is caught and schema is returned unchanged (with console warning).
|
|
119
|
+
* @param ctx - Context with field, getLabel, baseSchema, schema, and validation
|
|
120
|
+
* @returns Schema with `.matches(regex)` applied, or unchanged schema if not applicable
|
|
121
|
+
*/
|
|
122
|
+
apply(i) {
|
|
123
|
+
const { validation: e, getLabel: n, baseSchema: r, schema: t } = i;
|
|
124
|
+
if (!(e.validationType || e.type)?.requiresValue || !e.value || !(r instanceof u.StringSchema))
|
|
125
|
+
return t;
|
|
126
|
+
try {
|
|
127
|
+
const a = new RegExp(e.value), s = e.errorMessage || n(l.PATTERN_INVALID_MESSAGE);
|
|
128
|
+
return t.matches(a, s);
|
|
129
|
+
} catch (a) {
|
|
130
|
+
return console.warn(`Invalid regex pattern: ${e.value}`, a), t;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}, T = {
|
|
134
|
+
validationTypeId: "fvl_custom",
|
|
135
|
+
/**
|
|
136
|
+
* Applies custom validation: for string, regex or exact match; for number, exact value match.
|
|
137
|
+
* When no value is configured, string schema accepts any non-empty value.
|
|
138
|
+
* @param ctx - Context with field, getLabel, baseSchema, schema, and validation
|
|
139
|
+
* @returns Schema with custom `.test()` applied, or unchanged schema if base type not supported
|
|
140
|
+
*/
|
|
141
|
+
apply(i) {
|
|
142
|
+
const { validation: e, getLabel: n, baseSchema: r, schema: t } = i, a = (e.validationType || e.type)?.requiresValue && e.value;
|
|
143
|
+
if (r instanceof u.StringSchema) {
|
|
144
|
+
const s = e.errorMessage || n(l.CUSTOM_VALIDATION_MESSAGE);
|
|
145
|
+
return a ? t.test(
|
|
146
|
+
"custom",
|
|
147
|
+
s,
|
|
148
|
+
(c) => {
|
|
149
|
+
if (!c)
|
|
150
|
+
return !0;
|
|
151
|
+
try {
|
|
152
|
+
return new RegExp(e.value).test(c);
|
|
153
|
+
} catch {
|
|
154
|
+
return c === e.value;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
) : t.test(
|
|
158
|
+
"custom",
|
|
159
|
+
s,
|
|
160
|
+
(c) => !c || !0
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
if (r instanceof u.NumberSchema && a) {
|
|
164
|
+
const s = e.errorMessage || n(l.CUSTOM_VALIDATION_MESSAGE);
|
|
165
|
+
return t.test(
|
|
166
|
+
"custom",
|
|
167
|
+
s,
|
|
168
|
+
(c) => {
|
|
169
|
+
if (c == null)
|
|
170
|
+
return !0;
|
|
171
|
+
const m = parseFloat(e.value);
|
|
172
|
+
return isNaN(m) ? !0 : c === m;
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
return t;
|
|
177
|
+
}
|
|
178
|
+
}, M = {
|
|
179
|
+
[d.validationTypeId]: d,
|
|
180
|
+
[p.validationTypeId]: p,
|
|
181
|
+
[v.validationTypeId]: v,
|
|
182
|
+
[S.validationTypeId]: S,
|
|
183
|
+
[g.validationTypeId]: g,
|
|
184
|
+
[y.validationTypeId]: y,
|
|
185
|
+
[f.validationTypeId]: f,
|
|
186
|
+
[I.validationTypeId]: I,
|
|
187
|
+
[T.validationTypeId]: T
|
|
188
|
+
};
|
|
189
|
+
export {
|
|
190
|
+
M as VALIDATION_STRATEGY_REGISTRY,
|
|
191
|
+
T as customValidationStrategy,
|
|
192
|
+
y as emailValidationStrategy,
|
|
193
|
+
p as maxLengthValidationStrategy,
|
|
194
|
+
S as maxValidationStrategy,
|
|
195
|
+
v as minLengthValidationStrategy,
|
|
196
|
+
g as minValidationStrategy,
|
|
197
|
+
I as patternValidationStrategy,
|
|
198
|
+
d as requiredValidationStrategy,
|
|
199
|
+
f as urlValidationStrategy
|
|
200
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as Yup from 'yup';
|
|
2
|
+
/**
|
|
3
|
+
* Result type of createFieldValidationSchema: a Yup schema for a single field or undefined.
|
|
4
|
+
*/
|
|
5
|
+
export type FieldValidationSchemaResult = Yup.StringSchema | Yup.NumberSchema | Yup.BooleanSchema | Yup.ArraySchema<any, any, any, any> | Yup.ObjectSchema<any, any, any, any> | ReturnType<typeof Yup.mixed> | undefined;
|
|
6
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/DynamicForm/helpers/createFieldValidationSchema/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAE3B;;GAEG;AACH,MAAM,MAAM,2BAA2B,GACnC,GAAG,CAAC,YAAY,GAChB,GAAG,CAAC,YAAY,GAChB,GAAG,CAAC,aAAa,GACjB,GAAG,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GACnC,GAAG,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GACpC,UAAU,CAAC,OAAO,GAAG,CAAC,KAAK,CAAC,GAC5B,SAAS,CAAC"}
|
package/components/DynamicForm/helpers/createIsOptionEqualToValue/createIsOptionEqualToValue.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates isOptionEqualToValue comparator for RHFAutocomplete given the field key to compare.
|
|
3
|
+
* @param compareField - Key of T to compare (e.g. "id")
|
|
4
|
+
* @returns Comparator (option, value) => boolean
|
|
5
|
+
*/
|
|
6
|
+
export declare function createIsOptionEqualToValue<T extends Record<string, unknown>>(compareField: keyof T): (option: T | T[], value: T | null) => boolean;
|
|
7
|
+
//# sourceMappingURL=createIsOptionEqualToValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createIsOptionEqualToValue.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/DynamicForm/helpers/createIsOptionEqualToValue/createIsOptionEqualToValue.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1E,YAAY,EAAE,MAAM,CAAC,GACpB,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,KAAK,OAAO,CAU/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/DynamicForm/helpers/createIsOptionEqualToValue/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ConditionalRule } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Pure function that evaluates a conditional rule against a source field value.
|
|
4
|
+
* Used by useDynamicFormConditionals (visibility) and useDynamicForm (validation schema .when()).
|
|
5
|
+
* Keeps visibility and validation logic in sync.
|
|
6
|
+
* @param rule - Conditional rule (source field, operator, condition value, action type)
|
|
7
|
+
* @param sourceValue - Current value of the source field
|
|
8
|
+
* @returns true when the condition is met
|
|
9
|
+
*/
|
|
10
|
+
export declare function evaluateConditionalRule(rule: ConditionalRule, sourceValue: unknown): boolean;
|
|
11
|
+
//# sourceMappingURL=evaluateConditionalRule.d.ts.map
|
package/components/DynamicForm/helpers/evaluateConditionalRule/evaluateConditionalRule.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluateConditionalRule.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/DynamicForm/helpers/evaluateConditionalRule/evaluateConditionalRule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,eAAe,EACrB,WAAW,EAAE,OAAO,GACnB,OAAO,CA0BT"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function a(e, n) {
|
|
2
|
+
const { operator: t, conditionValue: r } = e;
|
|
3
|
+
switch (t.name) {
|
|
4
|
+
case "equals":
|
|
5
|
+
return String(n) === String(r);
|
|
6
|
+
case "not_equals":
|
|
7
|
+
return String(n) !== String(r);
|
|
8
|
+
case "greater_than":
|
|
9
|
+
return Number(n) > Number(r);
|
|
10
|
+
case "less_than":
|
|
11
|
+
return Number(n) < Number(r);
|
|
12
|
+
case "greater_than_or_equal":
|
|
13
|
+
return Number(n) >= Number(r);
|
|
14
|
+
case "less_than_or_equal":
|
|
15
|
+
return Number(n) <= Number(r);
|
|
16
|
+
case "contains":
|
|
17
|
+
return String(n).includes(String(r));
|
|
18
|
+
case "not_contains":
|
|
19
|
+
return !String(n).includes(String(r));
|
|
20
|
+
default:
|
|
21
|
+
return process.env.NODE_ENV !== "production" && console.warn(`Unsupported conditional operator: ${t.name}`), !1;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
a as evaluateConditionalRule
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/DynamicForm/helpers/evaluateConditionalRule/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,YAAY,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConditionalRule } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Result of evaluating a single conditional rule against a source value.
|
|
4
|
+
* Used for visibility and validation schema (e.g. Yup .when()).
|
|
5
|
+
*/
|
|
6
|
+
export type EvaluateConditionalRule = (rule: ConditionalRule, sourceValue: unknown) => boolean;
|
|
7
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/DynamicForm/helpers/evaluateConditionalRule/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,CACpC,IAAI,EAAE,eAAe,EACrB,WAAW,EAAE,OAAO,KACjB,OAAO,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './applyRequiredValidation';
|
|
2
|
+
export * from './createFieldValidationSchema';
|
|
3
|
+
export * from './createIsOptionEqualToValue';
|
|
4
|
+
export * from './evaluateConditionalRule';
|
|
5
|
+
export * from './normalizeValidation';
|
|
6
|
+
export * from './resolveFieldComponent';
|
|
7
|
+
export * from './resolveInitialValue';
|
|
8
|
+
export * from './stringifyJsonFieldsForSubmit';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../packages/components/src/components/DynamicForm/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/DynamicForm/helpers/normalizeValidation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FieldValidation } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes a validation to support both `validationType` and `type`.
|
|
4
|
+
* API JSON can be inconsistent; this helper unifies the format.
|
|
5
|
+
* @param validation - Field validation
|
|
6
|
+
* @returns Normalized validation with `validationType` always present
|
|
7
|
+
*/
|
|
8
|
+
export declare function normalizeValidation(validation: FieldValidation): FieldValidation;
|
|
9
|
+
//# sourceMappingURL=normalizeValidation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeValidation.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/DynamicForm/helpers/normalizeValidation/normalizeValidation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,eAAe,GAAG,eAAe,CAahF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/components/src/components/DynamicForm/helpers/normalizeValidation/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
|