@digigov/form 2.0.0-4be8f7cc → 2.0.0-555d1027
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/Field/ErrorGroup/index.js +48 -0
- package/{Questions/index.spec → Field/ErrorGroup}/package.json +1 -1
- package/Field/ErrorGroup.d.ts +15 -0
- package/Field/ErrorGroup.js.map +7 -0
- package/Field/FieldBase/index.js +116 -77
- package/Field/FieldBase.js.map +7 -0
- package/Field/FieldBaseContainer/index.js +47 -37
- package/Field/FieldBaseContainer.js.map +7 -0
- package/Field/FieldConditional/index.js +83 -53
- package/Field/FieldConditional.js.map +7 -0
- package/Field/index.js +113 -63
- package/Field/index.js.map +7 -0
- package/Field/types/index.js +1 -1
- package/Field/types.d.ts +52 -5
- package/Field/types.js.map +7 -0
- package/Field/utils/calculateField/index.js +27 -0
- package/{FieldArray/FieldArray.stories → Field/utils/calculateField}/package.json +1 -1
- package/Field/utils/calculateField.d.ts +2 -0
- package/Field/utils/calculateField.js.map +7 -0
- package/Field/utils/evaluateFieldWithConditions/index.js +26 -0
- package/{inputs/DateInput/__stories__/Default → Field/utils/evaluateFieldWithConditions}/package.json +1 -1
- package/Field/utils/evaluateFieldWithConditions.d.ts +2 -0
- package/Field/utils/evaluateFieldWithConditions.js.map +7 -0
- package/Field/utils/index.d.ts +4 -0
- package/Field/utils/index.js +49 -116
- package/Field/utils/index.js.map +7 -0
- package/Field/utils/useField/index.js +64 -0
- package/{FormBuilder/FormBuilder → Field/utils/useField}/package.json +1 -1
- package/Field/utils/useField.d.ts +2 -0
- package/Field/utils/useField.js.map +7 -0
- package/FieldArray/FieldArray.stories.d.ts +3 -2
- package/FieldArray/FormDialog/index.js +399 -0
- package/{validators/validators.spec → FieldArray/FormDialog}/package.json +1 -1
- package/FieldArray/FormDialog.d.ts +67 -0
- package/FieldArray/FormDialog.js.map +7 -0
- package/FieldArray/__stories__/Default.d.ts +2 -2
- package/FieldArray/__stories__/WithExactLength.d.ts +2 -2
- package/FieldArray/__stories__/WithModal.d.ts +2 -0
- package/FieldArray/index.d.ts +7 -0
- package/FieldArray/index.js +113 -59
- package/FieldArray/index.js.map +7 -0
- package/FieldArray/index.test.d.ts +1 -0
- package/FieldObject/index.d.ts +8 -0
- package/FieldObject/index.js +85 -52
- package/FieldObject/index.js.map +7 -0
- package/Fieldset/FieldsetWithContext/index.js +27 -31
- package/Fieldset/FieldsetWithContext.js.map +7 -0
- package/Fieldset/index.d.ts +1 -1
- package/Fieldset/index.js +27 -29
- package/Fieldset/index.js.map +7 -0
- package/Fieldset/types/index.js +1 -1
- package/Fieldset/types.d.ts +3 -2
- package/Fieldset/types.js.map +7 -0
- package/FormBuilder/FormBuilder.stories.d.ts +5 -1
- package/FormBuilder/__stories__/AutoErrorGrouping.d.ts +3 -0
- package/FormBuilder/__stories__/Default.d.ts +2 -2
- package/FormBuilder/__stories__/ErrorGrouping.d.ts +3 -0
- package/FormBuilder/index.d.ts +8 -1
- package/FormBuilder/index.js +241 -2
- package/FormBuilder/index.js.map +7 -0
- package/FormBuilder/index.test.d.ts +1 -0
- package/FormBuilder/interaction.test.d.ts +1 -0
- package/FormBuilder/scenarios.test.d.ts +88 -0
- package/FormContext/index.js +11 -3
- package/FormContext.d.ts +1 -0
- package/FormContext.js.map +7 -0
- package/MultiplicityField/MultiplicityField.stories.d.ts +8 -6
- package/MultiplicityField/__stories__/Default.d.ts +2 -2
- package/MultiplicityField/__stories__/PreviewDisplay.d.ts +2 -2
- package/MultiplicityField/__stories__/WithExactLength.d.ts +2 -2
- package/MultiplicityField/__stories__/WithMaxLength.d.ts +2 -2
- package/MultiplicityField/__stories__/WithMinAndMaxLength.d.ts +2 -2
- package/MultiplicityField/__stories__/WithMinLength.d.ts +2 -2
- package/MultiplicityField/add-objects/index.js +139 -132
- package/MultiplicityField/add-objects.d.ts +2 -1
- package/MultiplicityField/add-objects.js.map +7 -0
- package/MultiplicityField/index.d.ts +2 -19
- package/MultiplicityField/index.js +117 -106
- package/MultiplicityField/index.js.map +7 -0
- package/MultiplicityField/index.test.d.ts +1 -0
- package/MultiplicityField/types/index.js +1 -0
- package/MultiplicityField/types/package.json +6 -0
- package/MultiplicityField/types.d.ts +19 -0
- package/MultiplicityField/types.js.map +7 -0
- package/Questions/Questions/index.js +48 -56
- package/Questions/Questions.js.map +7 -0
- package/Questions/Questions.stories.d.ts +3 -1
- package/Questions/QuestionsContext/index.js +9 -9
- package/Questions/QuestionsContext.d.ts +0 -1
- package/Questions/QuestionsContext.js.map +7 -0
- package/Questions/Step/ReviewStep/index.js +35 -47
- package/Questions/Step/ReviewStep.js.map +7 -0
- package/Questions/Step/Step/index.js +39 -47
- package/Questions/Step/Step.js.map +7 -0
- package/Questions/Step/StepArrayReview/index.js +41 -45
- package/Questions/Step/StepArrayReview.js.map +7 -0
- package/Questions/Step/StepContext/index.js +15 -19
- package/Questions/Step/StepContext.d.ts +0 -1
- package/Questions/Step/StepContext.js.map +7 -0
- package/Questions/Step/StepDescription/index.js +22 -22
- package/Questions/Step/StepDescription.js.map +7 -0
- package/Questions/Step/StepForm/index.js +33 -43
- package/Questions/Step/StepForm.js.map +7 -0
- package/Questions/Step/StepQuote/index.js +10 -9
- package/Questions/Step/StepQuote.js.map +7 -0
- package/Questions/Step/StepTitle/index.js +41 -38
- package/Questions/Step/StepTitle.d.ts +2 -1
- package/Questions/Step/StepTitle.js.map +7 -0
- package/Questions/Step/getAddMoreFields/index.js +28 -20
- package/Questions/Step/getAddMoreFields.js.map +7 -0
- package/Questions/Step/index.d.ts +0 -1
- package/Questions/Step/index.js +16 -13
- package/Questions/Step/index.js.map +7 -0
- package/Questions/Step/types/index.js +1 -1
- package/Questions/Step/types.d.ts +1 -0
- package/Questions/Step/types.js.map +7 -0
- package/Questions/__stories__/Default.d.ts +2 -2
- package/Questions/getNextStep/index.js +12 -10
- package/Questions/getNextStep.js.map +7 -0
- package/Questions/index.js +7 -3
- package/Questions/index.js.map +7 -0
- package/Questions/index.test.d.ts +1 -0
- package/Questions/types/index.js +1 -1
- package/Questions/types.d.ts +1 -0
- package/Questions/types.js.map +7 -0
- package/cjs/Field/ErrorGroup/index.js +82 -0
- package/cjs/Field/ErrorGroup.js.map +7 -0
- package/cjs/Field/FieldBase/index.js +148 -83
- package/cjs/Field/FieldBase.js.map +7 -0
- package/cjs/Field/FieldBaseContainer/index.js +79 -43
- package/cjs/Field/FieldBaseContainer.js.map +7 -0
- package/cjs/Field/FieldConditional/index.js +115 -59
- package/cjs/Field/FieldConditional.js.map +7 -0
- package/cjs/Field/index.js +142 -72
- package/cjs/Field/index.js.map +7 -0
- package/cjs/Field/types/index.js +16 -5
- package/cjs/Field/types.js.map +7 -0
- package/cjs/Field/utils/calculateField/index.js +50 -0
- package/cjs/Field/utils/calculateField.js.map +7 -0
- package/cjs/Field/utils/evaluateFieldWithConditions/index.js +49 -0
- package/cjs/Field/utils/evaluateFieldWithConditions.js.map +7 -0
- package/cjs/Field/utils/index.js +92 -133
- package/cjs/Field/utils/index.js.map +7 -0
- package/cjs/Field/utils/useField/index.js +87 -0
- package/cjs/Field/utils/useField.js.map +7 -0
- package/cjs/FieldArray/FormDialog/index.js +418 -0
- package/cjs/FieldArray/FormDialog.js.map +7 -0
- package/cjs/FieldArray/index.js +145 -65
- package/cjs/FieldArray/index.js.map +7 -0
- package/cjs/FieldObject/index.js +114 -61
- package/cjs/FieldObject/index.js.map +7 -0
- package/cjs/Fieldset/FieldsetWithContext/index.js +54 -40
- package/cjs/Fieldset/FieldsetWithContext.js.map +7 -0
- package/cjs/Fieldset/index.js +61 -39
- package/cjs/Fieldset/index.js.map +7 -0
- package/cjs/Fieldset/types/index.js +16 -5
- package/cjs/Fieldset/types.js.map +7 -0
- package/cjs/FormBuilder/index.js +277 -8
- package/cjs/FormBuilder/index.js.map +7 -0
- package/cjs/FormContext/index.js +34 -8
- package/cjs/FormContext.js.map +7 -0
- package/cjs/MultiplicityField/add-objects/index.js +166 -138
- package/cjs/MultiplicityField/add-objects.js.map +7 -0
- package/cjs/MultiplicityField/index.js +145 -115
- package/cjs/MultiplicityField/index.js.map +7 -0
- package/cjs/MultiplicityField/types/index.js +16 -0
- package/cjs/MultiplicityField/types.js.map +7 -0
- package/cjs/Questions/Questions/index.js +80 -65
- package/cjs/Questions/Questions.js.map +7 -0
- package/cjs/Questions/QuestionsContext/index.js +31 -14
- package/cjs/Questions/QuestionsContext.js.map +7 -0
- package/cjs/Questions/Step/ReviewStep/index.js +61 -56
- package/cjs/Questions/Step/ReviewStep.js.map +7 -0
- package/cjs/Questions/Step/Step/index.js +71 -56
- package/cjs/Questions/Step/Step.js.map +7 -0
- package/cjs/Questions/Step/StepArrayReview/index.js +65 -54
- package/cjs/Questions/Step/StepArrayReview.js.map +7 -0
- package/cjs/Questions/Step/StepContext/index.js +37 -24
- package/cjs/Questions/Step/StepContext.js.map +7 -0
- package/cjs/Questions/Step/StepDescription/index.js +55 -31
- package/cjs/Questions/Step/StepDescription.js.map +7 -0
- package/cjs/Questions/Step/StepForm/index.js +65 -52
- package/cjs/Questions/Step/StepForm.js.map +7 -0
- package/cjs/Questions/Step/StepQuote/index.js +42 -15
- package/cjs/Questions/Step/StepQuote.js.map +7 -0
- package/cjs/Questions/Step/StepTitle/index.js +72 -47
- package/cjs/Questions/Step/StepTitle.js.map +7 -0
- package/cjs/Questions/Step/getAddMoreFields/index.js +50 -25
- package/cjs/Questions/Step/getAddMoreFields.js.map +7 -0
- package/cjs/Questions/Step/index.js +59 -143
- package/cjs/Questions/Step/index.js.map +7 -0
- package/cjs/Questions/Step/types/index.js +16 -5
- package/cjs/Questions/Step/types.js.map +7 -0
- package/cjs/Questions/getNextStep/index.js +33 -14
- package/cjs/Questions/getNextStep.js.map +7 -0
- package/cjs/Questions/index.js +29 -19
- package/cjs/Questions/index.js.map +7 -0
- package/cjs/Questions/types/index.js +16 -5
- package/cjs/Questions/types.js.map +7 -0
- package/cjs/index.js +47 -20
- package/cjs/index.js.map +7 -0
- package/cjs/inputs/AutoCompleteInput/index.js +92 -49
- package/cjs/inputs/AutoCompleteInput/index.js.map +7 -0
- package/cjs/inputs/Checkboxes/index.js +102 -96
- package/cjs/inputs/Checkboxes/index.js.map +7 -0
- package/cjs/inputs/DateInput/index.js +157 -115
- package/cjs/inputs/DateInput/index.js.map +7 -0
- package/cjs/inputs/DateTimeInput/index.js +245 -0
- package/cjs/inputs/DateTimeInput/index.js.map +7 -0
- package/cjs/inputs/FileInput/index.js +115 -65
- package/cjs/inputs/FileInput/index.js.map +7 -0
- package/cjs/inputs/ImageInput/__stories__/logo.d/index.js +1 -0
- package/cjs/inputs/ImageInput/__stories__/logo.d.js.map +7 -0
- package/cjs/inputs/ImageInput/index.js +127 -83
- package/cjs/inputs/ImageInput/index.js.map +7 -0
- package/cjs/inputs/Input/index.js +106 -71
- package/cjs/inputs/Input/index.js.map +7 -0
- package/cjs/inputs/Label/index.js +45 -24
- package/cjs/inputs/Label/index.js.map +7 -0
- package/cjs/inputs/OtpInput/index.js +143 -113
- package/cjs/inputs/OtpInput/index.js.map +7 -0
- package/cjs/inputs/Radio/index.js +131 -61
- package/cjs/inputs/Radio/index.js.map +7 -0
- package/cjs/inputs/Select/index.js +61 -36
- package/cjs/inputs/Select/index.js.map +7 -0
- package/cjs/inputs/index.js +62 -69
- package/cjs/inputs/index.js.map +7 -0
- package/cjs/inputs/inputsScenarios/index.js +533 -0
- package/cjs/inputs/inputsScenarios.js.map +7 -0
- package/cjs/internal/index.js +36 -346
- package/cjs/internal.js.map +7 -0
- package/cjs/lazy/index.js +110 -516
- package/cjs/lazy.js.map +7 -0
- package/cjs/locales/el/index.js +35 -0
- package/cjs/locales/el.js.map +7 -0
- package/cjs/registry/index.js +190 -142
- package/cjs/registry.js.map +7 -0
- package/cjs/types/index.js +22 -5
- package/cjs/types.js.map +7 -0
- package/cjs/utils/index.js +93 -83
- package/cjs/utils.js.map +7 -0
- package/cjs/validators/index.js +139 -167
- package/cjs/validators/index.js.map +7 -0
- package/cjs/validators/types/index.js +16 -5
- package/cjs/validators/types.js.map +7 -0
- package/cjs/validators/utils/afm/index.js +38 -21
- package/cjs/validators/utils/afm.js.map +7 -0
- package/cjs/validators/utils/amka/index.js +60 -0
- package/cjs/validators/utils/amka.js.map +7 -0
- package/cjs/validators/utils/date/index.js +156 -0
- package/cjs/validators/utils/date.js.map +7 -0
- package/cjs/validators/utils/datetime/index.js +240 -0
- package/cjs/validators/utils/datetime.js.map +7 -0
- package/cjs/validators/utils/file/index.js +48 -30
- package/cjs/validators/utils/file.js.map +7 -0
- package/cjs/validators/utils/iban/index.js +36 -17
- package/cjs/validators/utils/iban.js.map +7 -0
- package/cjs/validators/utils/image/index.js +88 -112
- package/cjs/validators/utils/image.js.map +7 -0
- package/cjs/validators/utils/index.js +103 -159
- package/cjs/validators/utils/index.js.map +7 -0
- package/cjs/validators/utils/int/index.js +35 -13
- package/cjs/validators/utils/int.js.map +7 -0
- package/cjs/validators/utils/number/index.js +34 -12
- package/cjs/validators/utils/number.js.map +7 -0
- package/cjs/validators/utils/otp/index.js +35 -13
- package/cjs/validators/utils/otp.js.map +7 -0
- package/cjs/validators/utils/phone/index.js +113 -58
- package/cjs/validators/utils/phone.js.map +7 -0
- package/cjs/validators/utils/postal_code/index.js +36 -16
- package/cjs/validators/utils/postal_code.js.map +7 -0
- package/cjs/validators/utils/text_limit/index.js +40 -25
- package/cjs/validators/utils/text_limit.js.map +7 -0
- package/cjs/validators/utils/uuid4/index.js +34 -13
- package/cjs/validators/utils/uuid4.js.map +7 -0
- package/index.d.ts +4 -1
- package/index.js +13 -4
- package/index.js.map +7 -0
- package/inputs/AutoCompleteInput/AutoComplete.stories.d.ts +4 -2
- package/inputs/AutoCompleteInput/__stories__/Default.d.ts +2 -2
- package/inputs/AutoCompleteInput/__stories__/Multiple.d.ts +2 -2
- package/inputs/AutoCompleteInput/index.d.ts +2 -2
- package/inputs/AutoCompleteInput/index.js +62 -40
- package/inputs/AutoCompleteInput/index.js.map +7 -0
- package/inputs/AutoCompleteInput/index.test.d.ts +1 -0
- package/inputs/Checkboxes/Checkboxes.stories.d.ts +5 -3
- package/inputs/Checkboxes/__stories__/Conditional.d.ts +2 -2
- package/inputs/Checkboxes/__stories__/Default.d.ts +2 -2
- package/inputs/Checkboxes/__stories__/WithDivider.d.ts +2 -2
- package/inputs/Checkboxes/index.d.ts +2 -1
- package/inputs/Checkboxes/index.js +74 -87
- package/inputs/Checkboxes/index.js.map +7 -0
- package/inputs/Checkboxes/index.test.d.ts +1 -0
- package/inputs/DateInput/DateInput.stories.d.ts +7 -1
- package/inputs/DateInput/__stories__/Default.d.ts +2 -2
- package/inputs/DateInput/__stories__/WithDefaultValue.d.ts +3 -0
- package/inputs/DateInput/__stories__/WithInitialValue.d.ts +3 -0
- package/inputs/DateInput/__stories__/WithWrongDefaultValue.d.ts +3 -0
- package/inputs/DateInput/__stories__/WithWrongInitialValue.d.ts +3 -0
- package/inputs/DateInput/index.d.ts +3 -4
- package/inputs/DateInput/index.js +127 -105
- package/inputs/DateInput/index.js.map +7 -0
- package/inputs/DateInput/index.test.d.ts +1 -0
- package/inputs/DateTimeInput/DateTimeInput.stories.d.ts +14 -0
- package/inputs/DateTimeInput/__stories__/Default.d.ts +3 -0
- package/inputs/DateTimeInput/__stories__/WithDefaultValue.d.ts +3 -0
- package/inputs/DateTimeInput/__stories__/WithInitialValue.d.ts +3 -0
- package/inputs/DateTimeInput/__stories__/WithWrongDefaultValue.d.ts +3 -0
- package/inputs/DateTimeInput/__stories__/WithWrongInitialValue.d.ts +3 -0
- package/inputs/DateTimeInput/index.d.ts +13 -0
- package/inputs/DateTimeInput/index.js +215 -0
- package/inputs/DateTimeInput/index.js.map +7 -0
- package/inputs/DateTimeInput/index.test.d.ts +1 -0
- package/inputs/DateTimeInput/package.json +6 -0
- package/inputs/FileInput/FileInput.stories.d.ts +4 -1
- package/inputs/FileInput/__stories__/Default.d.ts +2 -2
- package/inputs/FileInput/__stories__/WithBorderAndLink.d.ts +3 -0
- package/inputs/FileInput/index.d.ts +17 -1
- package/inputs/FileInput/index.js +86 -56
- package/inputs/FileInput/index.js.map +7 -0
- package/inputs/FileInput/index.test.d.ts +1 -0
- package/inputs/ImageInput/ImageInput.stories.d.ts +6 -3
- package/inputs/ImageInput/__stories__/Default.d.ts +2 -2
- package/inputs/ImageInput/__stories__/MaxSize.d.ts +3 -0
- package/inputs/ImageInput/__stories__/WithInitialValues.d.ts +3 -0
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension.d.ts +2 -2
- package/inputs/ImageInput/__stories__/logo.d/index.js +1 -0
- package/inputs/{FileInput/__stories__/Default → ImageInput/__stories__/logo.d}/package.json +1 -1
- package/inputs/ImageInput/__stories__/logo.d.js.map +7 -0
- package/inputs/ImageInput/index.d.ts +9 -1
- package/inputs/ImageInput/index.js +95 -75
- package/inputs/ImageInput/index.js.map +7 -0
- package/inputs/ImageInput/index.test.d.ts +1 -0
- package/inputs/Input/Input.stories.d.ts +15 -10
- package/inputs/Input/__stories__/AFM.d.ts +2 -2
- package/inputs/Input/__stories__/AMKA.d.ts +3 -0
- package/inputs/Input/__stories__/Boolean.d.ts +2 -2
- package/inputs/Input/__stories__/Email.d.ts +3 -0
- package/inputs/Input/__stories__/IBAN.d.ts +2 -2
- package/inputs/Input/__stories__/Integer.d.ts +2 -2
- package/inputs/Input/__stories__/LandlineNumber.d.ts +2 -2
- package/inputs/Input/__stories__/MobilePhone.d.ts +2 -2
- package/inputs/Input/__stories__/PhoneNumber.d.ts +2 -2
- package/inputs/Input/__stories__/PostalCode.d.ts +2 -2
- package/inputs/Input/__stories__/String.d.ts +3 -0
- package/inputs/Input/__stories__/StringWithTrimValidation.d.ts +3 -0
- package/inputs/Input/__stories__/TextWithLimit.d.ts +3 -0
- package/inputs/Input/index.d.ts +2 -1
- package/inputs/Input/index.js +75 -66
- package/inputs/Input/index.js.map +7 -0
- package/inputs/Input/index.test.d.ts +1 -0
- package/inputs/Label/Label.stories.d.ts +3 -1
- package/inputs/Label/__stories__/Default.d.ts +2 -2
- package/inputs/Label/index.d.ts +1 -3
- package/inputs/Label/index.js +12 -17
- package/inputs/Label/index.js.map +7 -0
- package/inputs/Label/index.test.d.ts +1 -0
- package/inputs/OtpInput/OtpInput.stories.d.ts +3 -1
- package/inputs/OtpInput/__stories__/Default.d.ts +2 -2
- package/inputs/OtpInput/index.d.ts +1 -1
- package/inputs/OtpInput/index.js +111 -104
- package/inputs/OtpInput/index.js.map +7 -0
- package/inputs/OtpInput/index.test.d.ts +1 -0
- package/inputs/Radio/Radio.stories.d.ts +5 -3
- package/inputs/Radio/__stories__/Conditional.d.ts +2 -2
- package/inputs/Radio/__stories__/Default.d.ts +2 -2
- package/inputs/Radio/__stories__/WithDivider.d.ts +2 -2
- package/inputs/Radio/index.d.ts +6 -1
- package/inputs/Radio/index.js +102 -55
- package/inputs/Radio/index.js.map +7 -0
- package/inputs/Radio/index.test.d.ts +1 -0
- package/inputs/Select/Select.stories.d.ts +3 -1
- package/inputs/Select/__stories__/Default.d.ts +2 -2
- package/inputs/Select/index.d.ts +3 -2
- package/inputs/Select/index.js +33 -31
- package/inputs/Select/index.js.map +7 -0
- package/inputs/Select/index.test.d.ts +1 -0
- package/inputs/index.js +21 -9
- package/inputs/index.js.map +7 -0
- package/inputs/inputsScenarios/index.js +499 -0
- package/inputs/inputsScenarios/package.json +6 -0
- package/inputs/inputsScenarios.d.ts +296 -0
- package/inputs/inputsScenarios.js.map +7 -0
- package/internal/index.js +10 -34
- package/internal.d.ts +2 -31
- package/internal.js.map +7 -0
- package/lazy/index.js +76 -393
- package/locales/el/index.js +6 -0
- package/{Form.stories → locales/el}/package.json +1 -1
- package/locales/el.d.ts +2 -0
- package/locales/el.js.map +7 -0
- package/package.json +8 -9
- package/registry/index.js +125 -98
- package/src/Field/ErrorGroup.tsx +84 -0
- package/src/Field/FieldBase.tsx +40 -23
- package/src/Field/FieldBaseContainer.tsx +22 -8
- package/src/Field/FieldConditional.tsx +9 -1
- package/src/Field/doc.mdx +207 -0
- package/src/Field/index.tsx +40 -6
- package/src/Field/types.tsx +82 -5
- package/src/Field/utils/calculateField.ts +49 -0
- package/src/Field/utils/evaluateFieldWithConditions.ts +30 -0
- package/src/Field/utils/index.ts +84 -0
- package/src/Field/utils/useField.ts +66 -0
- package/src/FieldArray/FieldArray.stories.js +3 -2
- package/src/FieldArray/FormDialog.tsx +568 -0
- package/src/FieldArray/__stories__/Default.tsx +2 -1
- package/src/FieldArray/__stories__/WithExactLength.tsx +2 -1
- package/src/FieldArray/__stories__/WithModal.tsx +160 -0
- package/src/FieldArray/index.test.tsx +32 -0
- package/src/FieldArray/index.tsx +99 -50
- package/src/FieldObject/index.tsx +56 -22
- package/src/Fieldset/index.tsx +5 -5
- package/src/Fieldset/types.tsx +5 -3
- package/src/FormBuilder/FormBuilder.stories.js +6 -1
- package/src/FormBuilder/__stories__/AutoErrorGrouping.tsx +63 -0
- package/src/FormBuilder/__stories__/Default.tsx +1 -1
- package/src/FormBuilder/__stories__/ErrorGrouping.tsx +43 -0
- package/{FormBuilder/FormBuilder.mdx → src/FormBuilder/doc.mdx} +27 -35
- package/src/FormBuilder/index.test.tsx +32 -0
- package/src/FormBuilder/index.tsx +268 -1
- package/src/FormBuilder/interaction.test.tsx +40 -0
- package/src/FormBuilder/scenarios.test.tsx +1978 -0
- package/src/FormContext.tsx +5 -2
- package/src/MultiplicityField/MultiplicityField.stories.js +9 -6
- package/src/MultiplicityField/__stories__/Default.tsx +1 -1
- package/src/MultiplicityField/__stories__/PreviewDisplay.tsx +3 -3
- package/src/MultiplicityField/__stories__/WithExactLength.tsx +2 -2
- package/src/MultiplicityField/__stories__/WithMaxLength.tsx +2 -2
- package/src/MultiplicityField/__stories__/WithMinAndMaxLength.tsx +2 -2
- package/src/MultiplicityField/__stories__/WithMinLength.tsx +2 -2
- package/src/MultiplicityField/add-objects.tsx +33 -15
- package/{MultiplicityField/MultiplicityField.mdx → src/MultiplicityField/doc.mdx} +112 -98
- package/src/MultiplicityField/index.test.tsx +44 -0
- package/src/MultiplicityField/index.tsx +24 -34
- package/src/MultiplicityField/types.ts +22 -0
- package/src/Questions/Questions.stories.js +4 -1
- package/src/Questions/Questions.tsx +4 -4
- package/src/Questions/Step/StepArrayReview.tsx +1 -1
- package/src/Questions/Step/StepTitle.tsx +5 -3
- package/src/Questions/Step/index.ts +0 -1
- package/src/Questions/Step/types.tsx +1 -0
- package/src/Questions/__snapshots__/index.spec.tsx.snap +74 -587
- package/src/Questions/__stories__/Default.tsx +1 -1
- package/src/Questions/{index.mdx → doc.mdx} +34 -57
- package/src/Questions/index.spec.tsx +17 -5
- package/src/Questions/index.test.tsx +24 -0
- package/src/Questions/types.tsx +1 -0
- package/src/create-simple-form.mdx +2 -6
- package/{index.mdx → src/doc.mdx} +29 -18
- package/src/index.ts +4 -1
- package/src/inputs/AutoCompleteInput/AutoComplete.stories.js +5 -2
- package/src/inputs/AutoCompleteInput/__stories__/Default.tsx +3 -11
- package/src/inputs/AutoCompleteInput/__stories__/Multiple.tsx +3 -10
- package/{inputs/AutoCompleteInput/index.mdx → src/inputs/AutoCompleteInput/doc.mdx} +2 -13
- package/src/inputs/AutoCompleteInput/index.test.tsx +28 -0
- package/src/inputs/AutoCompleteInput/index.tsx +47 -31
- package/src/inputs/Checkboxes/Checkboxes.stories.js +6 -3
- package/src/inputs/Checkboxes/__stories__/Conditional.tsx +1 -1
- package/src/inputs/Checkboxes/__stories__/Default.tsx +1 -1
- package/src/inputs/Checkboxes/__stories__/WithDivider.tsx +1 -1
- package/src/inputs/Checkboxes/{index.mdx → doc.mdx} +5 -15
- package/src/inputs/Checkboxes/index.test.tsx +32 -0
- package/src/inputs/Checkboxes/index.tsx +34 -31
- package/src/inputs/DateInput/DateInput.stories.js +8 -1
- package/src/inputs/DateInput/__stories__/Default.tsx +17 -16
- package/src/inputs/DateInput/__stories__/WithDefaultValue.tsx +26 -0
- package/src/inputs/DateInput/__stories__/WithInitialValue.tsx +28 -0
- package/src/inputs/DateInput/__stories__/WithWrongDefaultValue.tsx +26 -0
- package/src/inputs/DateInput/__stories__/WithWrongInitialValue.tsx +28 -0
- package/src/inputs/DateInput/{index.mdx → doc.mdx} +1 -8
- package/src/inputs/DateInput/index.test.tsx +40 -0
- package/src/inputs/DateInput/index.tsx +60 -23
- package/src/inputs/DateTimeInput/DateTimeInput.stories.js +14 -0
- package/src/inputs/DateTimeInput/__stories__/Default.tsx +25 -0
- package/src/inputs/DateTimeInput/__stories__/WithDefaultValue.tsx +26 -0
- package/src/inputs/DateTimeInput/__stories__/WithInitialValue.tsx +28 -0
- package/src/inputs/DateTimeInput/__stories__/WithWrongDefaultValue.tsx +26 -0
- package/src/inputs/DateTimeInput/__stories__/WithWrongInitialValue.tsx +28 -0
- package/src/inputs/DateTimeInput/doc.mdx +16 -0
- package/src/inputs/DateTimeInput/index.test.tsx +40 -0
- package/src/inputs/DateTimeInput/index.tsx +233 -0
- package/src/inputs/FileInput/FileInput.stories.js +5 -1
- package/src/inputs/FileInput/__stories__/Default.tsx +1 -1
- package/src/inputs/FileInput/__stories__/WithBorderAndLink.tsx +34 -0
- package/src/inputs/FileInput/{index.mdx → doc.mdx} +1 -5
- package/src/inputs/FileInput/index.test.tsx +28 -0
- package/src/inputs/FileInput/index.tsx +106 -41
- package/src/inputs/ImageInput/ImageInput.stories.js +7 -3
- package/src/inputs/ImageInput/__stories__/Default.tsx +1 -1
- package/src/inputs/ImageInput/__stories__/{WithInvalidImageSize.tsx → MaxSize.tsx} +5 -3
- package/src/inputs/ImageInput/__stories__/WithInitialValues.tsx +45 -0
- package/src/inputs/ImageInput/__stories__/WithInvalidImageDimension.tsx +3 -1
- package/src/inputs/ImageInput/__stories__/logo.d.ts +4 -0
- package/src/inputs/ImageInput/__stories__/logo.png +0 -0
- package/src/inputs/ImageInput/doc.mdx +23 -0
- package/src/inputs/ImageInput/index.test.tsx +36 -0
- package/src/inputs/ImageInput/index.tsx +103 -50
- package/src/inputs/Input/Input.stories.js +16 -10
- package/src/inputs/Input/__stories__/AFM.tsx +1 -1
- package/src/inputs/Input/__stories__/AMKA.tsx +23 -0
- package/src/inputs/Input/__stories__/Boolean.tsx +1 -1
- package/src/inputs/Input/__stories__/Email.tsx +23 -0
- package/src/inputs/Input/__stories__/IBAN.tsx +1 -1
- package/src/inputs/Input/__stories__/Integer.tsx +1 -1
- package/src/inputs/Input/__stories__/LandlineNumber.tsx +3 -2
- package/src/inputs/Input/__stories__/MobilePhone.tsx +2 -1
- package/src/inputs/Input/__stories__/PhoneNumber.tsx +2 -1
- package/src/inputs/Input/__stories__/PostalCode.tsx +2 -1
- package/src/inputs/Input/__stories__/{Default.tsx → String.tsx} +2 -2
- package/src/inputs/Input/__stories__/StringWithTrimValidation.tsx +26 -0
- package/src/inputs/Input/__stories__/{TextWithCharacterLimit.tsx → TextWithLimit.tsx} +3 -2
- package/src/inputs/Input/doc.mdx +56 -0
- package/src/inputs/Input/index.test.tsx +72 -0
- package/src/inputs/Input/index.tsx +44 -31
- package/src/inputs/Label/Label.stories.js +4 -1
- package/src/inputs/Label/__stories__/Default.tsx +4 -2
- package/src/inputs/Label/doc.mdx +14 -0
- package/src/inputs/Label/index.test.tsx +24 -0
- package/src/inputs/Label/index.tsx +3 -10
- package/src/inputs/OtpInput/OtpInput.stories.js +4 -1
- package/src/inputs/OtpInput/__stories__/Default.tsx +1 -1
- package/{inputs/OtpInput/index.mdx → src/inputs/OtpInput/doc.mdx} +1 -8
- package/src/inputs/OtpInput/index.test.tsx +24 -0
- package/src/inputs/OtpInput/index.tsx +3 -1
- package/src/inputs/Radio/Radio.stories.js +6 -3
- package/src/inputs/Radio/__stories__/Conditional.tsx +3 -2
- package/src/inputs/Radio/__stories__/Default.tsx +1 -1
- package/src/inputs/Radio/__stories__/WithDivider.tsx +1 -1
- package/{cjs/inputs/Radio/index.mdx → src/inputs/Radio/doc.mdx} +5 -15
- package/src/inputs/Radio/index.test.tsx +32 -0
- package/src/inputs/Radio/index.tsx +79 -9
- package/src/inputs/Select/Select.stories.js +4 -1
- package/src/inputs/Select/__stories__/Default.tsx +1 -1
- package/{inputs/Select/index.mdx → src/inputs/Select/doc.mdx} +1 -5
- package/src/inputs/Select/index.test.tsx +24 -0
- package/src/inputs/Select/index.tsx +18 -7
- package/src/inputs/inputsScenarios.ts +496 -0
- package/src/installation.mdx +2 -5
- package/src/internal.ts +2 -31
- package/src/lazy.js +77 -59
- package/src/locales/el.ts +3 -0
- package/src/registry.js +108 -88
- package/src/types.tsx +13 -65
- package/src/utils.ts +55 -33
- package/src/validators/index.ts +107 -90
- package/src/validators/utils/amka.ts +39 -0
- package/src/validators/utils/date.ts +126 -0
- package/src/validators/utils/datetime.ts +217 -0
- package/src/validators/utils/file.ts +33 -17
- package/src/validators/utils/index.ts +6 -1
- package/src/validators/utils/int.ts +1 -1
- package/src/validators/utils/number.ts +1 -1
- package/src/validators/utils/phone.ts +63 -72
- package/src/validators/utils/postal_code.ts +1 -1
- package/src/validators/utils/uuid4.ts +2 -1
- package/src/validators/validators.spec.ts +6 -40
- package/types/index.js +2 -1
- package/types.d.ts +8 -36
- package/types.js.map +7 -0
- package/utils/index.js +71 -77
- package/utils.d.ts +2 -0
- package/utils.js.map +7 -0
- package/validators/index.d.ts +1 -1
- package/validators/index.js +121 -153
- package/validators/index.js.map +7 -0
- package/validators/types/index.js +1 -1
- package/validators/types.js.map +7 -0
- package/validators/utils/afm/index.js +16 -16
- package/validators/utils/afm.js.map +7 -0
- package/validators/utils/amka/index.js +36 -0
- package/validators/utils/amka/package.json +6 -0
- package/validators/utils/amka.d.ts +6 -0
- package/validators/utils/amka.js.map +7 -0
- package/validators/utils/date/index.js +121 -0
- package/validators/utils/date/package.json +6 -0
- package/validators/utils/date.d.ts +9 -0
- package/validators/utils/date.js.map +7 -0
- package/validators/utils/datetime/index.js +205 -0
- package/{Questions/Questions.stories → validators/utils/datetime}/package.json +1 -1
- package/validators/utils/datetime.d.ts +9 -0
- package/validators/utils/datetime.js.map +7 -0
- package/validators/utils/file/index.js +26 -25
- package/validators/utils/file.js.map +7 -0
- package/validators/utils/iban/index.js +14 -12
- package/validators/utils/iban.js.map +7 -0
- package/validators/utils/image/index.js +66 -106
- package/validators/utils/image.js.map +7 -0
- package/validators/utils/index.d.ts +3 -0
- package/validators/utils/index.js +59 -48
- package/validators/utils/index.js.map +7 -0
- package/validators/utils/int/index.js +13 -8
- package/validators/utils/int.js.map +7 -0
- package/validators/utils/number/index.js +12 -7
- package/validators/utils/number.js.map +7 -0
- package/validators/utils/otp/index.js +13 -8
- package/validators/utils/otp.js.map +7 -0
- package/validators/utils/phone/index.js +89 -51
- package/validators/utils/phone.d.ts +1 -1
- package/validators/utils/phone.js.map +7 -0
- package/validators/utils/postal_code/index.js +14 -11
- package/validators/utils/postal_code.d.ts +1 -1
- package/validators/utils/postal_code.js.map +7 -0
- package/validators/utils/text_limit/index.js +18 -20
- package/validators/utils/text_limit.js.map +7 -0
- package/validators/utils/uuid4/index.js +12 -8
- package/validators/utils/uuid4.js.map +7 -0
- package/Field/index.mdx +0 -6
- package/Field/utils.d.ts +0 -5
- package/FieldArray/FieldArray.stories/index.js +0 -8
- package/FieldArray/FieldArray.stories.playwright.json +0 -353
- package/FieldArray/__stories__/Default/index.js +0 -88
- package/FieldArray/__stories__/Default/package.json +0 -6
- package/FieldArray/__stories__/WithExactLength/index.js +0 -88
- package/FieldArray/__stories__/WithExactLength/package.json +0 -6
- package/Form.stories/index.js +0 -3
- package/FormBuilder/FormBuilder/index.js +0 -152
- package/FormBuilder/FormBuilder.d.ts +0 -5
- package/FormBuilder/FormBuilder.stories/index.js +0 -7
- package/FormBuilder/FormBuilder.stories/package.json +0 -6
- package/FormBuilder/FormBuilder.stories.playwright.json +0 -52
- package/FormBuilder/__stories__/Default/index.js +0 -26
- package/FormBuilder/__stories__/Default/package.json +0 -6
- package/MultiplicityField/MultiplicityField.stories/index.js +0 -12
- package/MultiplicityField/MultiplicityField.stories/package.json +0 -6
- package/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
- package/MultiplicityField/__stories__/Default/index.js +0 -95
- package/MultiplicityField/__stories__/Default/package.json +0 -6
- package/MultiplicityField/__stories__/PreviewDisplay/index.js +0 -72
- package/MultiplicityField/__stories__/PreviewDisplay/package.json +0 -6
- package/MultiplicityField/__stories__/WithExactLength/index.js +0 -90
- package/MultiplicityField/__stories__/WithExactLength/package.json +0 -6
- package/MultiplicityField/__stories__/WithMaxLength/index.js +0 -93
- package/MultiplicityField/__stories__/WithMaxLength/package.json +0 -6
- package/MultiplicityField/__stories__/WithMinAndMaxLength/index.js +0 -94
- package/MultiplicityField/__stories__/WithMinAndMaxLength/package.json +0 -6
- package/MultiplicityField/__stories__/WithMinLength/index.js +0 -93
- package/MultiplicityField/__stories__/WithMinLength/package.json +0 -6
- package/Questions/Questions.stories/index.js +0 -7
- package/Questions/__snapshots__/index.spec.tsx.snap +0 -596
- package/Questions/__stories__/Default/index.js +0 -102
- package/Questions/__stories__/Default/package.json +0 -6
- package/Questions/index.mdx +0 -415
- package/Questions/index.spec/index.js +0 -59
- package/cjs/Field/index.mdx +0 -6
- package/cjs/FieldArray/FieldArray.stories/index.js +0 -38
- package/cjs/FieldArray/FieldArray.stories.playwright.json +0 -353
- package/cjs/FieldArray/__stories__/Default/index.js +0 -98
- package/cjs/FieldArray/__stories__/WithExactLength/index.js +0 -98
- package/cjs/Form.stories/index.js +0 -9
- package/cjs/FormBuilder/FormBuilder/index.js +0 -162
- package/cjs/FormBuilder/FormBuilder.mdx +0 -256
- package/cjs/FormBuilder/FormBuilder.stories/index.js +0 -26
- package/cjs/FormBuilder/FormBuilder.stories.playwright.json +0 -52
- package/cjs/FormBuilder/__stories__/Default/index.js +0 -36
- package/cjs/MultiplicityField/MultiplicityField.mdx +0 -590
- package/cjs/MultiplicityField/MultiplicityField.stories/index.js +0 -86
- package/cjs/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
- package/cjs/MultiplicityField/__stories__/Default/index.js +0 -105
- package/cjs/MultiplicityField/__stories__/PreviewDisplay/index.js +0 -82
- package/cjs/MultiplicityField/__stories__/WithExactLength/index.js +0 -100
- package/cjs/MultiplicityField/__stories__/WithMaxLength/index.js +0 -103
- package/cjs/MultiplicityField/__stories__/WithMinAndMaxLength/index.js +0 -104
- package/cjs/MultiplicityField/__stories__/WithMinLength/index.js +0 -103
- package/cjs/Questions/Questions.stories/index.js +0 -26
- package/cjs/Questions/__snapshots__/index.spec.tsx.snap +0 -596
- package/cjs/Questions/__stories__/Default/index.js +0 -113
- package/cjs/Questions/index.mdx +0 -415
- package/cjs/Questions/index.spec/index.js +0 -63
- package/cjs/create-simple-form.mdx +0 -539
- package/cjs/index.mdx +0 -51
- package/cjs/inputs/AutoCompleteInput/AutoComplete.stories/index.js +0 -38
- package/cjs/inputs/AutoCompleteInput/__stories__/Default/index.js +0 -51
- package/cjs/inputs/AutoCompleteInput/__stories__/Multiple/index.js +0 -52
- package/cjs/inputs/AutoCompleteInput/index.mdx +0 -29
- package/cjs/inputs/Checkboxes/Checkboxes.stories/index.js +0 -50
- package/cjs/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
- package/cjs/inputs/Checkboxes/__stories__/Conditional/index.js +0 -103
- package/cjs/inputs/Checkboxes/__stories__/Default/index.js +0 -50
- package/cjs/inputs/Checkboxes/__stories__/WithDivider/index.js +0 -51
- package/cjs/inputs/Checkboxes/index.mdx +0 -33
- package/cjs/inputs/DateInput/DateInput.stories/index.js +0 -26
- package/cjs/inputs/DateInput/DateInput.stories.playwright.json +0 -72
- package/cjs/inputs/DateInput/__stories__/Default/index.js +0 -33
- package/cjs/inputs/DateInput/index.mdx +0 -23
- package/cjs/inputs/FileInput/FileInput.stories/index.js +0 -26
- package/cjs/inputs/FileInput/FileInput.stories.playwright.json +0 -75
- package/cjs/inputs/FileInput/__stories__/Default/index.js +0 -30
- package/cjs/inputs/FileInput/index.mdx +0 -19
- package/cjs/inputs/ImageInput/ImageInput.stories/index.js +0 -50
- package/cjs/inputs/ImageInput/ImageInput.stories.playwright.json +0 -77
- package/cjs/inputs/ImageInput/__stories__/Default/index.js +0 -38
- package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +0 -46
- package/cjs/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +0 -43
- package/cjs/inputs/ImageInput/index.mdx +0 -19
- package/cjs/inputs/Input/Input.stories/index.js +0 -134
- package/cjs/inputs/Input/Input.stories.playwright.json +0 -376
- package/cjs/inputs/Input/__stories__/AFM/index.js +0 -32
- package/cjs/inputs/Input/__stories__/Boolean/index.js +0 -33
- package/cjs/inputs/Input/__stories__/Default/index.js +0 -33
- package/cjs/inputs/Input/__stories__/IBAN/index.js +0 -33
- package/cjs/inputs/Input/__stories__/Integer/index.js +0 -41
- package/cjs/inputs/Input/__stories__/LandlineNumber/index.js +0 -36
- package/cjs/inputs/Input/__stories__/MobilePhone/index.js +0 -36
- package/cjs/inputs/Input/__stories__/PhoneNumber/index.js +0 -35
- package/cjs/inputs/Input/__stories__/PostalCode/index.js +0 -35
- package/cjs/inputs/Input/__stories__/TextWithCharacterLimit/index.js +0 -39
- package/cjs/inputs/Input/index.mdx +0 -95
- package/cjs/inputs/Label/Label.stories/index.js +0 -26
- package/cjs/inputs/Label/Label.stories.playwright.json +0 -40
- package/cjs/inputs/Label/__stories__/Default/index.js +0 -37
- package/cjs/inputs/Label/index.mdx +0 -0
- package/cjs/inputs/OtpInput/OtpInput.stories/index.js +0 -26
- package/cjs/inputs/OtpInput/__stories__/Default/index.js +0 -39
- package/cjs/inputs/OtpInput/index.mdx +0 -23
- package/cjs/inputs/Radio/Radio.stories/index.js +0 -50
- package/cjs/inputs/Radio/Radio.stories.playwright.json +0 -73
- package/cjs/inputs/Radio/__stories__/Conditional/index.js +0 -103
- package/cjs/inputs/Radio/__stories__/Default/index.js +0 -55
- package/cjs/inputs/Radio/__stories__/WithDivider/index.js +0 -56
- package/cjs/inputs/Select/Select.stories/index.js +0 -26
- package/cjs/inputs/Select/Select.stories.playwright.json +0 -22
- package/cjs/inputs/Select/__stories__/Default/index.js +0 -61
- package/cjs/inputs/Select/index.mdx +0 -17
- package/cjs/installation.mdx +0 -68
- package/cjs/validators/validators.spec/index.js +0 -87
- package/create-simple-form.mdx +0 -539
- package/inputs/AutoCompleteInput/AutoComplete.stories/index.js +0 -8
- package/inputs/AutoCompleteInput/AutoComplete.stories/package.json +0 -6
- package/inputs/AutoCompleteInput/__stories__/Default/index.js +0 -44
- package/inputs/AutoCompleteInput/__stories__/Default/package.json +0 -6
- package/inputs/AutoCompleteInput/__stories__/Multiple/index.js +0 -45
- package/inputs/AutoCompleteInput/__stories__/Multiple/package.json +0 -6
- package/inputs/Checkboxes/Checkboxes.stories/index.js +0 -9
- package/inputs/Checkboxes/Checkboxes.stories/package.json +0 -6
- package/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
- package/inputs/Checkboxes/__stories__/Conditional/index.js +0 -93
- package/inputs/Checkboxes/__stories__/Conditional/package.json +0 -6
- package/inputs/Checkboxes/__stories__/Default/index.js +0 -40
- package/inputs/Checkboxes/__stories__/Default/package.json +0 -6
- package/inputs/Checkboxes/__stories__/WithDivider/index.js +0 -41
- package/inputs/Checkboxes/__stories__/WithDivider/package.json +0 -6
- package/inputs/Checkboxes/index.mdx +0 -33
- package/inputs/DateInput/DateInput.stories/index.js +0 -7
- package/inputs/DateInput/DateInput.stories/package.json +0 -6
- package/inputs/DateInput/DateInput.stories.playwright.json +0 -72
- package/inputs/DateInput/__stories__/Default/index.js +0 -23
- package/inputs/DateInput/index.mdx +0 -23
- package/inputs/FileInput/FileInput.stories/index.js +0 -7
- package/inputs/FileInput/FileInput.stories/package.json +0 -6
- package/inputs/FileInput/FileInput.stories.playwright.json +0 -75
- package/inputs/FileInput/__stories__/Default/index.js +0 -20
- package/inputs/FileInput/index.mdx +0 -19
- package/inputs/ImageInput/ImageInput.stories/index.js +0 -9
- package/inputs/ImageInput/ImageInput.stories/package.json +0 -6
- package/inputs/ImageInput/ImageInput.stories.playwright.json +0 -77
- package/inputs/ImageInput/__stories__/Default/index.js +0 -28
- package/inputs/ImageInput/__stories__/Default/package.json +0 -6
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +0 -36
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension/package.json +0 -6
- package/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +0 -33
- package/inputs/ImageInput/__stories__/WithInvalidImageSize/package.json +0 -6
- package/inputs/ImageInput/__stories__/WithInvalidImageSize.d.ts +0 -3
- package/inputs/ImageInput/index.mdx +0 -19
- package/inputs/Input/Input.stories/index.js +0 -16
- package/inputs/Input/Input.stories/package.json +0 -6
- package/inputs/Input/Input.stories.playwright.json +0 -376
- package/inputs/Input/__stories__/AFM/index.js +0 -22
- package/inputs/Input/__stories__/AFM/package.json +0 -6
- package/inputs/Input/__stories__/Boolean/index.js +0 -23
- package/inputs/Input/__stories__/Boolean/package.json +0 -6
- package/inputs/Input/__stories__/Default/index.js +0 -23
- package/inputs/Input/__stories__/Default/package.json +0 -6
- package/inputs/Input/__stories__/Default.d.ts +0 -3
- package/inputs/Input/__stories__/IBAN/index.js +0 -23
- package/inputs/Input/__stories__/IBAN/package.json +0 -6
- package/inputs/Input/__stories__/Integer/index.js +0 -31
- package/inputs/Input/__stories__/Integer/package.json +0 -6
- package/inputs/Input/__stories__/LandlineNumber/index.js +0 -26
- package/inputs/Input/__stories__/LandlineNumber/package.json +0 -6
- package/inputs/Input/__stories__/MobilePhone/index.js +0 -26
- package/inputs/Input/__stories__/MobilePhone/package.json +0 -6
- package/inputs/Input/__stories__/PhoneNumber/index.js +0 -25
- package/inputs/Input/__stories__/PhoneNumber/package.json +0 -6
- package/inputs/Input/__stories__/PostalCode/index.js +0 -25
- package/inputs/Input/__stories__/PostalCode/package.json +0 -6
- package/inputs/Input/__stories__/TextWithCharacterLimit/index.js +0 -29
- package/inputs/Input/__stories__/TextWithCharacterLimit/package.json +0 -6
- package/inputs/Input/__stories__/TextWithCharacterLimit.d.ts +0 -3
- package/inputs/Input/index.mdx +0 -95
- package/inputs/Label/Label.stories/index.js +0 -7
- package/inputs/Label/Label.stories/package.json +0 -6
- package/inputs/Label/Label.stories.playwright.json +0 -40
- package/inputs/Label/__stories__/Default/index.js +0 -27
- package/inputs/Label/__stories__/Default/package.json +0 -6
- package/inputs/Label/index.mdx +0 -0
- package/inputs/OtpInput/OtpInput.stories/index.js +0 -7
- package/inputs/OtpInput/OtpInput.stories/package.json +0 -6
- package/inputs/OtpInput/__stories__/Default/index.js +0 -29
- package/inputs/OtpInput/__stories__/Default/package.json +0 -6
- package/inputs/Radio/Radio.stories/index.js +0 -9
- package/inputs/Radio/Radio.stories/package.json +0 -6
- package/inputs/Radio/Radio.stories.playwright.json +0 -73
- package/inputs/Radio/__stories__/Conditional/index.js +0 -93
- package/inputs/Radio/__stories__/Conditional/package.json +0 -6
- package/inputs/Radio/__stories__/Default/index.js +0 -45
- package/inputs/Radio/__stories__/Default/package.json +0 -6
- package/inputs/Radio/__stories__/WithDivider/index.js +0 -46
- package/inputs/Radio/__stories__/WithDivider/package.json +0 -6
- package/inputs/Radio/index.mdx +0 -33
- package/inputs/Select/Select.stories/index.js +0 -7
- package/inputs/Select/Select.stories/package.json +0 -6
- package/inputs/Select/Select.stories.playwright.json +0 -22
- package/inputs/Select/__stories__/Default/index.js +0 -51
- package/inputs/Select/__stories__/Default/package.json +0 -6
- package/installation.mdx +0 -68
- package/lazy.d.ts +0 -69
- package/registry.d.ts +0 -64
- package/src/Field/index.mdx +0 -6
- package/src/Field/utils.ts +0 -191
- package/src/FieldArray/FieldArray.stories.playwright.json +0 -353
- package/src/FormBuilder/FormBuilder.mdx +0 -256
- package/src/FormBuilder/FormBuilder.stories.playwright.json +0 -52
- package/src/FormBuilder/FormBuilder.tsx +0 -166
- package/src/MultiplicityField/MultiplicityField.mdx +0 -590
- package/src/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
- package/src/index.mdx +0 -51
- package/src/inputs/AutoCompleteInput/index.mdx +0 -29
- package/src/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
- package/src/inputs/DateInput/DateInput.stories.playwright.json +0 -72
- package/src/inputs/FileInput/FileInput.stories.playwright.json +0 -75
- package/src/inputs/ImageInput/ImageInput.stories.playwright.json +0 -77
- package/src/inputs/ImageInput/index.mdx +0 -19
- package/src/inputs/Input/Input.stories.playwright.json +0 -376
- package/src/inputs/Input/index.mdx +0 -95
- package/src/inputs/Label/Label.stories.playwright.json +0 -40
- package/src/inputs/Label/index.mdx +0 -0
- package/src/inputs/OtpInput/index.mdx +0 -23
- package/src/inputs/Radio/Radio.stories.playwright.json +0 -73
- package/src/inputs/Radio/index.mdx +0 -33
- package/src/inputs/Select/Select.stories.playwright.json +0 -22
- package/src/inputs/Select/index.mdx +0 -17
- package/validators/validators.spec/index.js +0 -85
|
@@ -1,38 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var afm_exports = {};
|
|
19
|
+
__export(afm_exports, {
|
|
20
|
+
AFM_VALIDATOR: () => AFM_VALIDATOR,
|
|
21
|
+
validateAFM: () => validateAFM
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
exports.validateAFM = validateAFM;
|
|
23
|
+
module.exports = __toCommonJS(afm_exports);
|
|
8
24
|
function validateAFM(afm) {
|
|
9
25
|
if (afm.length !== 9) {
|
|
10
|
-
// "afm should be 9 digits"
|
|
11
26
|
return false;
|
|
12
27
|
}
|
|
13
28
|
if (!/^\d+$/.test(afm)) {
|
|
14
|
-
// "This is not a number"
|
|
15
29
|
return false;
|
|
16
30
|
}
|
|
17
|
-
if (afm ===
|
|
18
|
-
// "This is zero number (000000000)"
|
|
31
|
+
if (afm === "0".repeat(9)) {
|
|
19
32
|
return false;
|
|
20
33
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var d9 = parseInt(afm[8]);
|
|
26
|
-
var valid = calc % 10 === d9;
|
|
34
|
+
const sum = afm.substring(0, 8).split("").reduce((s, v, i) => s + (parseInt(v) << 8 - i), 0);
|
|
35
|
+
const calc = sum % 11;
|
|
36
|
+
const d9 = parseInt(afm[8]);
|
|
37
|
+
const valid = calc % 10 === d9;
|
|
27
38
|
return valid;
|
|
28
39
|
}
|
|
29
|
-
|
|
30
|
-
name:
|
|
31
|
-
message:
|
|
32
|
-
test:
|
|
40
|
+
const AFM_VALIDATOR = {
|
|
41
|
+
name: "afm-validator",
|
|
42
|
+
message: "form.error.afm",
|
|
43
|
+
test: (value) => {
|
|
33
44
|
if (value) {
|
|
34
45
|
return validateAFM(value);
|
|
35
46
|
}
|
|
36
47
|
return true;
|
|
37
48
|
}
|
|
38
|
-
};
|
|
49
|
+
};
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
AFM_VALIDATOR,
|
|
53
|
+
validateAFM
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=afm.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/validators/utils/afm.ts"],
|
|
4
|
+
"sourcesContent": ["export function validateAFM(afm: string): boolean {\n if (afm.length !== 9) {\n // \"afm should be 9 digits\"\n return false;\n }\n\n if (!/^\\d+$/.test(afm)) {\n // \"This is not a number\"\n return false;\n }\n\n if (afm === '0'.repeat(9)) {\n // \"This is zero number (000000000)\"\n return false;\n }\n\n const sum = afm\n .substring(0, 8)\n .split('')\n .reduce((s, v, i) => s + (parseInt(v) << (8 - i)), 0);\n\n const calc = sum % 11;\n const d9 = parseInt(afm[8]);\n const valid = calc % 10 === d9;\n return valid;\n}\n\nexport const AFM_VALIDATOR = {\n name: 'afm-validator',\n message: 'form.error.afm',\n test: (value): boolean => {\n if (value) {\n return validateAFM(value);\n }\n return true;\n },\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,YAAY,KAAsB;AAChD,MAAI,IAAI,WAAW,GAAG;AAEpB,WAAO;AAAA,EACT;AAEA,MAAI,CAAC,QAAQ,KAAK,GAAG,GAAG;AAEtB,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ,IAAI,OAAO,CAAC,GAAG;AAEzB,WAAO;AAAA,EACT;AAEA,QAAM,MAAM,IACT,UAAU,GAAG,CAAC,EACd,MAAM,EAAE,EACR,OAAO,CAAC,GAAG,GAAG,MAAM,KAAK,SAAS,CAAC,KAAM,IAAI,IAAK,CAAC;AAEtD,QAAM,OAAO,MAAM;AACnB,QAAM,KAAK,SAAS,IAAI,CAAC,CAAC;AAC1B,QAAM,QAAQ,OAAO,OAAO;AAC5B,SAAO;AACT;AAEO,MAAM,gBAAgB;AAAA,EAC3B,MAAM;AAAA,EACN,SAAS;AAAA,EACT,MAAM,CAAC,UAAmB;AACxB,QAAI,OAAO;AACT,aAAO,YAAY,KAAK;AAAA,IAC1B;AACA,WAAO;AAAA,EACT;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var amka_exports = {};
|
|
19
|
+
__export(amka_exports, {
|
|
20
|
+
AMKA_VALIDATOR: () => AMKA_VALIDATOR,
|
|
21
|
+
validateAMKA: () => validateAMKA
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(amka_exports);
|
|
24
|
+
function digitSum(number) {
|
|
25
|
+
const sum = number > 9 ? 1 : 0;
|
|
26
|
+
return sum + number % 10;
|
|
27
|
+
}
|
|
28
|
+
function validateAMKA(amka) {
|
|
29
|
+
amka = String(amka);
|
|
30
|
+
const checkDigitIndex = amka.length - 1;
|
|
31
|
+
let sum = 0;
|
|
32
|
+
amka.substring(0, checkDigitIndex).split("").reverse().forEach(function(value, index) {
|
|
33
|
+
const weight = (index + 1) % 2 + 1;
|
|
34
|
+
sum += digitSum(parseInt(value, 10) * weight);
|
|
35
|
+
});
|
|
36
|
+
const sumMod10 = sum % 10;
|
|
37
|
+
if (sumMod10 === 0) {
|
|
38
|
+
return amka.substring(checkDigitIndex) === "0";
|
|
39
|
+
} else {
|
|
40
|
+
return amka.substring(checkDigitIndex) === 10 - sumMod10 + "";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const AMKA_VALIDATOR = {
|
|
44
|
+
name: "amka-validator",
|
|
45
|
+
message: "form.error.amka",
|
|
46
|
+
test: (value) => {
|
|
47
|
+
if (!value) return true;
|
|
48
|
+
const AMKA_REGEX = /^[0-9]{11}$/;
|
|
49
|
+
if (!AMKA_REGEX.test(value) || value === "00000000000") {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
return validateAMKA(value);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
AMKA_VALIDATOR,
|
|
58
|
+
validateAMKA
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=amka.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/validators/utils/amka.ts"],
|
|
4
|
+
"sourcesContent": ["function digitSum(number) {\n const sum = number > 9 ? 1 : 0;\n return sum + (number % 10);\n}\n\nexport function validateAMKA(amka: string): boolean {\n // Validate that the last digit is the correct check digit (created using the\n // Luhn algorithm https://en.wikipedia.org/wiki/Luhn_algorithm).\n amka = String(amka);\n const checkDigitIndex = amka.length - 1;\n let sum = 0;\n amka\n .substring(0, checkDigitIndex)\n .split('')\n .reverse()\n .forEach(function (value, index) {\n const weight = ((index + 1) % 2) + 1;\n sum += digitSum(parseInt(value, 10) * weight);\n });\n const sumMod10 = sum % 10;\n if (sumMod10 === 0) {\n return amka.substring(checkDigitIndex) === '0';\n } else {\n return amka.substring(checkDigitIndex) === 10 - sumMod10 + '';\n }\n}\n\nexport const AMKA_VALIDATOR = {\n name: 'amka-validator',\n message: 'form.error.amka',\n test: (value): boolean => {\n if (!value) return true;\n const AMKA_REGEX = /^[0-9]{11}$/;\n if (!AMKA_REGEX.test(value) || value === '00000000000') {\n return false;\n }\n return validateAMKA(value);\n },\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,SAAS,QAAQ;AACxB,QAAM,MAAM,SAAS,IAAI,IAAI;AAC7B,SAAO,MAAO,SAAS;AACzB;AAEO,SAAS,aAAa,MAAuB;AAGlD,SAAO,OAAO,IAAI;AAClB,QAAM,kBAAkB,KAAK,SAAS;AACtC,MAAI,MAAM;AACV,OACG,UAAU,GAAG,eAAe,EAC5B,MAAM,EAAE,EACR,QAAQ,EACR,QAAQ,SAAU,OAAO,OAAO;AAC/B,UAAM,UAAW,QAAQ,KAAK,IAAK;AACnC,WAAO,SAAS,SAAS,OAAO,EAAE,IAAI,MAAM;AAAA,EAC9C,CAAC;AACH,QAAM,WAAW,MAAM;AACvB,MAAI,aAAa,GAAG;AAClB,WAAO,KAAK,UAAU,eAAe,MAAM;AAAA,EAC7C,OAAO;AACL,WAAO,KAAK,UAAU,eAAe,MAAM,KAAK,WAAW;AAAA,EAC7D;AACF;AAEO,MAAM,iBAAiB;AAAA,EAC5B,MAAM;AAAA,EACN,SAAS;AAAA,EACT,MAAM,CAAC,UAAmB;AACxB,QAAI,CAAC,MAAO,QAAO;AACnB,UAAM,aAAa;AACnB,QAAI,CAAC,WAAW,KAAK,KAAK,KAAK,UAAU,eAAe;AACtD,aAAO;AAAA,IACT;AACA,WAAO,aAAa,KAAK;AAAA,EAC3B;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var date_exports = {};
|
|
29
|
+
__export(date_exports, {
|
|
30
|
+
DATE_VALIDATOR: () => DATE_VALIDATOR,
|
|
31
|
+
EARLIER_THAN_VALIDATOR: () => EARLIER_THAN_VALIDATOR,
|
|
32
|
+
LATER_THAN_VALIDATOR: () => LATER_THAN_VALIDATOR
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(date_exports);
|
|
35
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
36
|
+
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
|
|
37
|
+
import_dayjs.default.extend(import_customParseFormat.default);
|
|
38
|
+
const VALID_DATE_FORMATS = ["DD/MM/YYYY"];
|
|
39
|
+
const DATE_CACHE = {};
|
|
40
|
+
const getDate = (v) => {
|
|
41
|
+
return DATE_CACHE[v] ? DATE_CACHE[v] : (0, import_dayjs.default)(v, VALID_DATE_FORMATS, true);
|
|
42
|
+
};
|
|
43
|
+
const getDaysInMonth = (month, year) => {
|
|
44
|
+
return (0, import_dayjs.default)(`${year}-${month}-01`).daysInMonth();
|
|
45
|
+
};
|
|
46
|
+
const checkPartialDate = (value) => {
|
|
47
|
+
const [day, month, year] = value.split("/");
|
|
48
|
+
if (day && !month && !year) {
|
|
49
|
+
return "form.error.date.invalid_month_year";
|
|
50
|
+
}
|
|
51
|
+
if (!day && month && !year) {
|
|
52
|
+
return "form.error.date.invalid_day_year";
|
|
53
|
+
}
|
|
54
|
+
if (!day && !month && year) {
|
|
55
|
+
return "form.error.date.invalid_day_month";
|
|
56
|
+
}
|
|
57
|
+
if (day && month && !year) {
|
|
58
|
+
return "form.error.date.invalid_year";
|
|
59
|
+
}
|
|
60
|
+
if (day && !month && year) {
|
|
61
|
+
return "form.error.date.invalid_month";
|
|
62
|
+
}
|
|
63
|
+
if (!day && month && year) {
|
|
64
|
+
return "form.error.date.invalid_day";
|
|
65
|
+
}
|
|
66
|
+
if (day && month) {
|
|
67
|
+
const dayNum = parseInt(day);
|
|
68
|
+
const monthNum = parseInt(month);
|
|
69
|
+
const yearNum = parseInt(year);
|
|
70
|
+
const maxDay = getDaysInMonth(monthNum, yearNum);
|
|
71
|
+
if (dayNum < 1 || dayNum > maxDay) {
|
|
72
|
+
return {
|
|
73
|
+
key: "form.error.date.invalid_day_range",
|
|
74
|
+
context: {
|
|
75
|
+
maxDay
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (monthNum < 1 || monthNum > 12) {
|
|
80
|
+
return "form.error.datetime.invalid_month_range";
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return "form.error.date.invalid";
|
|
84
|
+
};
|
|
85
|
+
const LATER_THAN_VALIDATOR = (field) => {
|
|
86
|
+
let minDate;
|
|
87
|
+
const params = field.extra || {};
|
|
88
|
+
if (params.min === "now") {
|
|
89
|
+
const today = /* @__PURE__ */ new Date();
|
|
90
|
+
minDate = new Date(today);
|
|
91
|
+
} else {
|
|
92
|
+
minDate = getDate(params.min).toDate();
|
|
93
|
+
}
|
|
94
|
+
const minPreviousDate = new Date(minDate);
|
|
95
|
+
minPreviousDate.setDate(minDate.getDate() - 1);
|
|
96
|
+
return {
|
|
97
|
+
name: "later-than",
|
|
98
|
+
message: {
|
|
99
|
+
key: "form.error.date.later_than",
|
|
100
|
+
context: {
|
|
101
|
+
minDate: minPreviousDate.toLocaleDateString()
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
test: function(value) {
|
|
105
|
+
if (!value) return true;
|
|
106
|
+
const date = getDate(value);
|
|
107
|
+
const isValid = +date.toDate() > +minDate;
|
|
108
|
+
return isValid;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
const EARLIER_THAN_VALIDATOR = (field) => {
|
|
113
|
+
let maxDate;
|
|
114
|
+
const params = field.extra || {};
|
|
115
|
+
if (params.max === "now") {
|
|
116
|
+
const today = /* @__PURE__ */ new Date();
|
|
117
|
+
maxDate = new Date(today);
|
|
118
|
+
} else {
|
|
119
|
+
maxDate = getDate(params.max).toDate();
|
|
120
|
+
}
|
|
121
|
+
const maxNextDate = new Date(maxDate);
|
|
122
|
+
maxNextDate.setDate(maxDate.getDate() + 1);
|
|
123
|
+
return {
|
|
124
|
+
name: "earlier-than",
|
|
125
|
+
message: {
|
|
126
|
+
key: "form.error.date.earlier_than",
|
|
127
|
+
context: {
|
|
128
|
+
maxDate: maxNextDate.toLocaleDateString()
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
test: function(value) {
|
|
132
|
+
if (!value) return true;
|
|
133
|
+
const date = getDate(value);
|
|
134
|
+
const isValid = +date.toDate() < +maxDate;
|
|
135
|
+
return isValid;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
const DATE_VALIDATOR = {
|
|
140
|
+
name: "date-validator",
|
|
141
|
+
message: (v) => {
|
|
142
|
+
return checkPartialDate(v.value);
|
|
143
|
+
},
|
|
144
|
+
test: function(value) {
|
|
145
|
+
if (!value) return true;
|
|
146
|
+
const date = getDate(value);
|
|
147
|
+
return date.isValid();
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
151
|
+
0 && (module.exports = {
|
|
152
|
+
DATE_VALIDATOR,
|
|
153
|
+
EARLIER_THAN_VALIDATOR,
|
|
154
|
+
LATER_THAN_VALIDATOR
|
|
155
|
+
});
|
|
156
|
+
//# sourceMappingURL=date.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/validators/utils/date.ts"],
|
|
4
|
+
"sourcesContent": ["import dayjs from 'dayjs';\nimport customParseFormat from 'dayjs/plugin/customParseFormat';\nimport { FieldSpec } from '@digigov/form/types';\nimport { ValidatorSchema } from '@digigov/form/validators/types';\n\ndayjs.extend(customParseFormat);\n\nconst VALID_DATE_FORMATS = ['DD/MM/YYYY'];\nconst DATE_CACHE = {};\n\nconst getDate = (v: string) => {\n return DATE_CACHE[v] ? DATE_CACHE[v] : dayjs(v, VALID_DATE_FORMATS, true);\n};\n\nconst getDaysInMonth = (month: number, year: number): number => {\n return dayjs(`${year}-${month}-01`).daysInMonth(); // e.g. 29 for Feb 2024\n};\n\n// Function to check partial date completion\nconst checkPartialDate = (value: string) => {\n const [day, month, year] = value.split('/');\n if (day && !month && !year) {\n return 'form.error.date.invalid_month_year';\n }\n if (!day && month && !year) {\n return 'form.error.date.invalid_day_year';\n }\n if (!day && !month && year) {\n return 'form.error.date.invalid_day_month';\n }\n if (day && month && !year) {\n return 'form.error.date.invalid_year';\n }\n if (day && !month && year) {\n return 'form.error.date.invalid_month';\n }\n if (!day && month && year) {\n return 'form.error.date.invalid_day';\n }\n if (day && month) {\n const dayNum = parseInt(day);\n const monthNum = parseInt(month);\n const yearNum = parseInt(year);\n const maxDay = getDaysInMonth(monthNum, yearNum);\n if (dayNum < 1 || dayNum > maxDay) {\n return {\n key: 'form.error.date.invalid_day_range',\n context: {\n maxDay: maxDay,\n },\n };\n }\n if (monthNum < 1 || monthNum > 12) {\n return 'form.error.datetime.invalid_month_range';\n }\n }\n return 'form.error.date.invalid';\n};\n\nexport const LATER_THAN_VALIDATOR = (field: FieldSpec): ValidatorSchema => {\n let minDate;\n const params = field.extra || {};\n if (params.min === 'now') {\n const today = new Date();\n minDate = new Date(today);\n } else {\n minDate = getDate(params.min).toDate();\n }\n const minPreviousDate = new Date(minDate);\n minPreviousDate.setDate(minDate.getDate() - 1);\n return {\n name: 'later-than',\n message: {\n key: 'form.error.date.later_than',\n context: {\n minDate: minPreviousDate.toLocaleDateString(),\n },\n },\n test: function (value: string) {\n if (!value) return true;\n const date = getDate(value);\n const isValid = +date.toDate() > +minDate;\n return isValid;\n },\n };\n};\n\nexport const EARLIER_THAN_VALIDATOR = (field: FieldSpec): ValidatorSchema => {\n let maxDate;\n const params = field.extra || {};\n if (params.max === 'now') {\n const today = new Date();\n maxDate = new Date(today);\n } else {\n maxDate = getDate(params.max).toDate();\n }\n const maxNextDate = new Date(maxDate);\n maxNextDate.setDate(maxDate.getDate() + 1);\n return {\n name: 'earlier-than',\n message: {\n key: 'form.error.date.earlier_than',\n context: {\n maxDate: maxNextDate.toLocaleDateString(),\n },\n },\n test: function (value: string) {\n if (!value) return true;\n const date = getDate(value);\n const isValid = +date.toDate() < +maxDate;\n return isValid;\n },\n };\n};\n\nexport const DATE_VALIDATOR = {\n name: 'date-validator',\n message: (v): string | object => {\n return checkPartialDate(v.value);\n },\n test: function (value: string) {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IACA,MAAM,SAAU,OAAe;AAC7B,UAAI,CAAC,MAAO,QAAO;AACnB,YAAM,OAAO,QAAQ,KAAK;AAC1B,YAAM,UAAU,CAAC,KAAK,OAAO,IAAI,CAAC;AAClC,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEO,MAAM,iBAAiB;AAAA,EAC5B,MAAM;AAAA,EACN,SAAS,CAAC,MAAuB;AAC/B,WAAO,iBAAiB,EAAE,KAAK;AAAA,EACjC;AAAA,EACA,MAAM,SAAU,OAAe;AAC7B,QAAI,CAAC,MAAO,QAAO;AACnB,UAAM,OAAO,QAAQ,KAAK;AAC1B,WAAO,KAAK,QAAQ;AAAA,EACtB;AACF;",
|
|
6
|
+
"names": ["dayjs", "customParseFormat"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var datetime_exports = {};
|
|
29
|
+
__export(datetime_exports, {
|
|
30
|
+
DATETIME_VALIDATOR: () => DATETIME_VALIDATOR,
|
|
31
|
+
EARLIER_THAN_DATETIME_VALIDATOR: () => EARLIER_THAN_DATETIME_VALIDATOR,
|
|
32
|
+
LATER_THAN_DATETIME_VALIDATOR: () => LATER_THAN_DATETIME_VALIDATOR
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(datetime_exports);
|
|
35
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
36
|
+
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
|
|
37
|
+
import_dayjs.default.extend(import_customParseFormat.default);
|
|
38
|
+
const VALID_DATETIME_FORMATS = ["DD/MM/YYYY HH:mm"];
|
|
39
|
+
const DATETIME_CACHE = {};
|
|
40
|
+
const getDateTime = (v) => {
|
|
41
|
+
return DATETIME_CACHE[v] ? DATETIME_CACHE[v] : (0, import_dayjs.default)(v, VALID_DATETIME_FORMATS, true);
|
|
42
|
+
};
|
|
43
|
+
const getDaysInMonth = (month, year) => {
|
|
44
|
+
return (0, import_dayjs.default)(`${year}-${month}-01`).daysInMonth();
|
|
45
|
+
};
|
|
46
|
+
const checkPartialDateTime = (value) => {
|
|
47
|
+
const [datePart, timePart] = value.split(" ");
|
|
48
|
+
const [day, month, year] = datePart?.split("/") ?? [];
|
|
49
|
+
const [hours, minutes] = timePart?.split(":") ?? [];
|
|
50
|
+
const hasDay = Boolean(day);
|
|
51
|
+
const hasMonth = Boolean(month);
|
|
52
|
+
const hasYear = Boolean(year);
|
|
53
|
+
const hasHours = Boolean(hours);
|
|
54
|
+
const hasMinutes = Boolean(minutes);
|
|
55
|
+
if (hasDay && !hasMonth && !hasYear && !hasHours && !hasMinutes) {
|
|
56
|
+
return "form.error.datetime.invalid_month_year_hours_minutes";
|
|
57
|
+
}
|
|
58
|
+
if (!hasDay && hasMonth && !hasYear && !hasHours && !hasMinutes) {
|
|
59
|
+
return "form.error.datetime.invalid_day_year_hours_minutes";
|
|
60
|
+
}
|
|
61
|
+
if (!hasDay && !hasMonth && hasYear && !hasHours && !hasMinutes) {
|
|
62
|
+
return "form.error.datetime.invalid_day_month_hours_minutes";
|
|
63
|
+
}
|
|
64
|
+
if (hasDay && hasMonth && !hasYear && !hasHours && !hasMinutes) {
|
|
65
|
+
return "form.error.datetime.invalid_year_hours_minutes";
|
|
66
|
+
}
|
|
67
|
+
if (hasDay && !hasMonth && hasYear && !hasHours && !hasMinutes) {
|
|
68
|
+
return "form.error.datetime.invalid_month_hours_minutes";
|
|
69
|
+
}
|
|
70
|
+
if (!hasDay && hasMonth && hasYear && !hasHours && !hasMinutes) {
|
|
71
|
+
return "form.error.datetime.invalid_day_hours_minutes";
|
|
72
|
+
}
|
|
73
|
+
if (hasDay && hasMonth && hasYear && !hasHours && !hasMinutes) {
|
|
74
|
+
return "form.error.datetime.invalid__hours_minutes";
|
|
75
|
+
}
|
|
76
|
+
if (hasDay && hasMonth && hasYear && hasHours && !hasMinutes) {
|
|
77
|
+
return "form.error.datetime.invalid_minutes";
|
|
78
|
+
}
|
|
79
|
+
if (hasDay && hasMonth && hasYear && !hasHours && hasMinutes) {
|
|
80
|
+
return "form.error.datetime.invalid_hours";
|
|
81
|
+
}
|
|
82
|
+
if (hasDay && !hasMonth && !hasYear && hasHours && !hasMinutes) {
|
|
83
|
+
return "form.error.datetime.invalid_month_year_minutes";
|
|
84
|
+
}
|
|
85
|
+
if (hasDay && !hasMonth && !hasYear && !hasHours && hasMinutes) {
|
|
86
|
+
return "form.error.datetime.invalid_month_year_hours";
|
|
87
|
+
}
|
|
88
|
+
if (hasDay && !hasMonth && !hasYear && hasHours && hasMinutes) {
|
|
89
|
+
return "form.error.datetime.invalid_month_year";
|
|
90
|
+
}
|
|
91
|
+
if (!hasDay && hasMonth && !hasYear && hasHours && !hasMinutes) {
|
|
92
|
+
return "form.error.datetime.invalid_day_year_minutes";
|
|
93
|
+
}
|
|
94
|
+
if (!hasDay && hasMonth && !hasYear && !hasHours && hasMinutes) {
|
|
95
|
+
return "form.error.datetime.invalid_day_year_hours";
|
|
96
|
+
}
|
|
97
|
+
if (!hasDay && hasMonth && !hasYear && hasHours && hasMinutes) {
|
|
98
|
+
return "form.error.datetime.invalid_day_year";
|
|
99
|
+
}
|
|
100
|
+
if (!hasDay && !hasMonth && hasYear && hasHours && !hasMinutes) {
|
|
101
|
+
return "form.error.datetime.invalid_day_month_minutes";
|
|
102
|
+
}
|
|
103
|
+
if (!hasDay && !hasMonth && hasYear && !hasHours && hasMinutes) {
|
|
104
|
+
return "form.error.datetime.invalid_day_month_hours";
|
|
105
|
+
}
|
|
106
|
+
if (!hasDay && !hasMonth && hasYear && hasHours && hasMinutes) {
|
|
107
|
+
return "form.error.datetime.invalid_day_month";
|
|
108
|
+
}
|
|
109
|
+
if (!hasDay && !hasMonth && !hasYear && hasHours && hasMinutes) {
|
|
110
|
+
return "form.error.datetime.invalid_day_month_year";
|
|
111
|
+
}
|
|
112
|
+
if (!hasDay && !hasMonth && !hasYear && !hasHours && hasMinutes) {
|
|
113
|
+
return "form.error.datetime.invalid_day_month_year_hours";
|
|
114
|
+
}
|
|
115
|
+
if (hasDay && hasMonth && !hasYear && hasHours && !hasMinutes) {
|
|
116
|
+
return "form.error.datetime.invalid_year_minutes";
|
|
117
|
+
}
|
|
118
|
+
if (hasDay && hasMonth && !hasYear && !hasHours && hasMinutes) {
|
|
119
|
+
return "form.error.datetime.invalid_year_hours";
|
|
120
|
+
}
|
|
121
|
+
if (hasDay && hasMonth && !hasYear && hasHours && hasMinutes) {
|
|
122
|
+
return "form.error.datetime.invalid_year";
|
|
123
|
+
}
|
|
124
|
+
if (hasDay && !hasMonth && hasYear && hasHours && !hasMinutes) {
|
|
125
|
+
return "form.error.datetime.invalid_month_minutes";
|
|
126
|
+
}
|
|
127
|
+
if (hasDay && !hasMonth && hasYear && !hasHours && hasMinutes) {
|
|
128
|
+
return "form.error.datetime.invalid_month_hours";
|
|
129
|
+
}
|
|
130
|
+
if (hasDay && !hasMonth && hasYear && hasHours && hasMinutes) {
|
|
131
|
+
return "form.error.datetime.invalid_month";
|
|
132
|
+
}
|
|
133
|
+
if (!hasDay && hasMonth && hasYear && hasHours && !hasMinutes) {
|
|
134
|
+
return "form.error.datetime.invalid_day_minutes";
|
|
135
|
+
}
|
|
136
|
+
if (!hasDay && hasMonth && hasYear && !hasHours && hasMinutes) {
|
|
137
|
+
return "form.error.datetime.invalid_day_hours";
|
|
138
|
+
}
|
|
139
|
+
if (!hasDay && hasMonth && hasYear && hasHours && hasMinutes) {
|
|
140
|
+
return "form.error.datetime.invalid_day";
|
|
141
|
+
}
|
|
142
|
+
if (!hasDay && !hasMonth && !hasYear && hasHours && !hasMinutes) {
|
|
143
|
+
return "form.error.datetime.invalid_day_month_year_minutes";
|
|
144
|
+
}
|
|
145
|
+
if (hasDay && hasMonth && hasYear && !hasHours && !hasMinutes) {
|
|
146
|
+
return "form.error.datetime.invalid_hours_minutes";
|
|
147
|
+
}
|
|
148
|
+
if (day && month) {
|
|
149
|
+
const dayNum = parseInt(day);
|
|
150
|
+
const monthNum = parseInt(month);
|
|
151
|
+
const yearNum = parseInt(year);
|
|
152
|
+
const maxDay = getDaysInMonth(monthNum, yearNum);
|
|
153
|
+
if (dayNum < 1 || dayNum > maxDay) {
|
|
154
|
+
return {
|
|
155
|
+
key: "form.error.datetime.invalid_day_range",
|
|
156
|
+
context: {
|
|
157
|
+
maxDay
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
if (monthNum < 1 || monthNum > 12) {
|
|
162
|
+
return "form.error.datetime.invalid_month_range";
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (hours && minutes) {
|
|
166
|
+
const hoursNum = parseInt(hours);
|
|
167
|
+
const minutesNum = parseInt(minutes);
|
|
168
|
+
if (hoursNum < 0 || hoursNum > 23) {
|
|
169
|
+
return "form.error.datetime.invalid_hours_range";
|
|
170
|
+
}
|
|
171
|
+
if (minutesNum < 0 || minutesNum > 59) {
|
|
172
|
+
return "form.error.datetime.invalid_minutes_range";
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return "form.error.datetime.invalid";
|
|
176
|
+
};
|
|
177
|
+
const LATER_THAN_DATETIME_VALIDATOR = (field) => {
|
|
178
|
+
let minDateTime;
|
|
179
|
+
const params = field.extra || {};
|
|
180
|
+
if (params.min === "now") {
|
|
181
|
+
minDateTime = (0, import_dayjs.default)();
|
|
182
|
+
} else {
|
|
183
|
+
minDateTime = getDateTime(params.min);
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
name: "later-than-datetime",
|
|
187
|
+
message: {
|
|
188
|
+
key: "form.error.datetime.later_than",
|
|
189
|
+
context: {
|
|
190
|
+
minDateTime: minDateTime.format("DD/MM/YYYY HH:mm")
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
test: function(value) {
|
|
194
|
+
if (!value) return true;
|
|
195
|
+
const datetime = getDateTime(value);
|
|
196
|
+
return datetime.isValid() && datetime.isAfter(minDateTime);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
const EARLIER_THAN_DATETIME_VALIDATOR = (field) => {
|
|
201
|
+
let maxDateTime;
|
|
202
|
+
const params = field.extra || {};
|
|
203
|
+
if (params.max === "now") {
|
|
204
|
+
maxDateTime = (0, import_dayjs.default)();
|
|
205
|
+
} else {
|
|
206
|
+
maxDateTime = getDateTime(params.max);
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
name: "earlier-than-datetime",
|
|
210
|
+
message: {
|
|
211
|
+
key: "form.error.datetime.earlier_than",
|
|
212
|
+
context: {
|
|
213
|
+
maxDateTime: maxDateTime.format("DD/MM/YYYY HH:mm")
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
test: function(value) {
|
|
217
|
+
if (!value) return true;
|
|
218
|
+
const datetime = getDateTime(value);
|
|
219
|
+
return datetime.isValid() && datetime.isBefore(maxDateTime);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
const DATETIME_VALIDATOR = {
|
|
224
|
+
name: "datetime-validator",
|
|
225
|
+
message: (v) => {
|
|
226
|
+
return checkPartialDateTime(v.value);
|
|
227
|
+
},
|
|
228
|
+
test: function(value) {
|
|
229
|
+
if (!value) return true;
|
|
230
|
+
const datetime = getDateTime(value);
|
|
231
|
+
return datetime.isValid();
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
235
|
+
0 && (module.exports = {
|
|
236
|
+
DATETIME_VALIDATOR,
|
|
237
|
+
EARLIER_THAN_DATETIME_VALIDATOR,
|
|
238
|
+
LATER_THAN_DATETIME_VALIDATOR
|
|
239
|
+
});
|
|
240
|
+
//# sourceMappingURL=datetime.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/validators/utils/datetime.ts"],
|
|
4
|
+
"sourcesContent": ["import dayjs from 'dayjs';\nimport customParseFormat from 'dayjs/plugin/customParseFormat';\nimport { FieldSpec } from '@digigov/form/types';\nimport { ValidatorSchema } from '@digigov/form/validators/types';\n\ndayjs.extend(customParseFormat);\n\nconst VALID_DATETIME_FORMATS = ['DD/MM/YYYY HH:mm'];\nconst DATETIME_CACHE = {};\n\nconst getDateTime = (v: string) => {\n return DATETIME_CACHE[v]\n ? DATETIME_CACHE[v]\n : dayjs(v, VALID_DATETIME_FORMATS, true);\n};\n\nconst getDaysInMonth = (month: number, year: number): number => {\n return dayjs(`${year}-${month}-01`).daysInMonth(); // e.g. 29 for Feb 2024\n};\n\nconst checkPartialDateTime = (value: string) => {\n const [datePart, timePart] = value.split(' ');\n const [day, month, year] = datePart?.split('/') ?? [];\n const [hours, minutes] = timePart?.split(':') ?? [];\n\n const hasDay = Boolean(day);\n const hasMonth = Boolean(month);\n const hasYear = Boolean(year);\n const hasHours = Boolean(hours);\n const hasMinutes = Boolean(minutes);\n\n if (hasDay && !hasMonth && !hasYear && !hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_month_year_hours_minutes';\n }\n if (!hasDay && hasMonth && !hasYear && !hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_day_year_hours_minutes';\n }\n if (!hasDay && !hasMonth && hasYear && !hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_day_month_hours_minutes';\n }\n if (hasDay && hasMonth && !hasYear && !hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_year_hours_minutes';\n }\n if (hasDay && !hasMonth && hasYear && !hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_month_hours_minutes';\n }\n if (!hasDay && hasMonth && hasYear && !hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_day_hours_minutes';\n }\n if (hasDay && hasMonth && hasYear && !hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid__hours_minutes';\n }\n if (hasDay && hasMonth && hasYear && hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_minutes';\n }\n if (hasDay && hasMonth && hasYear && !hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_hours';\n }\n if (hasDay && !hasMonth && !hasYear && hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_month_year_minutes';\n }\n if (hasDay && !hasMonth && !hasYear && !hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_month_year_hours';\n }\n if (hasDay && !hasMonth && !hasYear && hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_month_year';\n }\n if (!hasDay && hasMonth && !hasYear && hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_day_year_minutes';\n }\n if (!hasDay && hasMonth && !hasYear && !hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_day_year_hours';\n }\n if (!hasDay && hasMonth && !hasYear && hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_day_year';\n }\n if (!hasDay && !hasMonth && hasYear && hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_day_month_minutes';\n }\n if (!hasDay && !hasMonth && hasYear && !hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_day_month_hours';\n }\n if (!hasDay && !hasMonth && hasYear && hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_day_month';\n }\n if (!hasDay && !hasMonth && !hasYear && hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_day_month_year';\n }\n if (!hasDay && !hasMonth && !hasYear && !hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_day_month_year_hours';\n }\n if (hasDay && hasMonth && !hasYear && hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_year_minutes';\n }\n if (hasDay && hasMonth && !hasYear && !hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_year_hours';\n }\n if (hasDay && hasMonth && !hasYear && hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_year';\n }\n if (hasDay && !hasMonth && hasYear && hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_month_minutes';\n }\n if (hasDay && !hasMonth && hasYear && !hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_month_hours';\n }\n if (hasDay && !hasMonth && hasYear && hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_month';\n }\n if (!hasDay && hasMonth && hasYear && hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_day_minutes';\n }\n if (!hasDay && hasMonth && hasYear && !hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_day_hours';\n }\n if (!hasDay && hasMonth && hasYear && hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_day';\n }\n if (!hasDay && !hasMonth && !hasYear && hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_day_month_year_minutes';\n }\n if (hasDay && hasMonth && hasYear && !hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_hours_minutes';\n }\n if (day && month) {\n const dayNum = parseInt(day);\n const monthNum = parseInt(month);\n const yearNum = parseInt(year);\n const maxDay = getDaysInMonth(monthNum, yearNum);\n if (dayNum < 1 || dayNum > maxDay) {\n return {\n key: 'form.error.datetime.invalid_day_range',\n context: {\n maxDay: maxDay,\n },\n };\n }\n if (monthNum < 1 || monthNum > 12) {\n return 'form.error.datetime.invalid_month_range';\n }\n }\n if (hours && minutes) {\n const hoursNum = parseInt(hours);\n const minutesNum = parseInt(minutes);\n if (hoursNum < 0 || hoursNum > 23) {\n return 'form.error.datetime.invalid_hours_range';\n }\n if (minutesNum < 0 || minutesNum > 59) {\n return 'form.error.datetime.invalid_minutes_range';\n }\n }\n return 'form.error.datetime.invalid';\n};\n\nexport const LATER_THAN_DATETIME_VALIDATOR = (\n field: FieldSpec\n): ValidatorSchema => {\n let minDateTime;\n const params = field.extra || {};\n if (params.min === 'now') {\n minDateTime = dayjs();\n } else {\n minDateTime = getDateTime(params.min);\n }\n return {\n name: 'later-than-datetime',\n message: {\n key: 'form.error.datetime.later_than',\n context: {\n minDateTime: minDateTime.format('DD/MM/YYYY HH:mm'),\n },\n },\n test: function (value: string) {\n if (!value) return true;\n const datetime = getDateTime(value);\n return datetime.isValid() && datetime.isAfter(minDateTime);\n },\n };\n};\n\nexport const EARLIER_THAN_DATETIME_VALIDATOR = (\n field: FieldSpec\n): ValidatorSchema => {\n let maxDateTime;\n const params = field.extra || {};\n if (params.max === 'now') {\n maxDateTime = dayjs();\n } else {\n maxDateTime = getDateTime(params.max);\n }\n return {\n name: 'earlier-than-datetime',\n message: {\n key: 'form.error.datetime.earlier_than',\n context: {\n maxDateTime: maxDateTime.format('DD/MM/YYYY HH:mm'),\n },\n },\n test: function (value: string) {\n if (!value) return true;\n const datetime = getDateTime(value);\n return datetime.isValid() && datetime.isBefore(maxDateTime);\n },\n };\n};\n\nexport const DATETIME_VALIDATOR = {\n name: 'datetime-validator',\n message: (v): string | object => {\n return checkPartialDateTime(v.value);\n },\n test: function (value: string) {\n if (!value) return true;\n const datetime = getDateTime(value);\n return datetime.isValid();\n },\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,+BAA8B;AAI9B,aAAAA,QAAM,OAAO,yBAAAC,OAAiB;AAE9B,MAAM,yBAAyB,CAAC,kBAAkB;AAClD,MAAM,iBAAiB,CAAC;AAExB,MAAM,cAAc,CAAC,MAAc;AACjC,SAAO,eAAe,CAAC,IACnB,eAAe,CAAC,QAChB,aAAAD,SAAM,GAAG,wBAAwB,IAAI;AAC3C;AAEA,MAAM,iBAAiB,CAAC,OAAe,SAAyB;AAC9D,aAAO,aAAAA,SAAM,GAAG,IAAI,IAAI,KAAK,KAAK,EAAE,YAAY;AAClD;AAEA,MAAM,uBAAuB,CAAC,UAAkB;AAC9C,QAAM,CAAC,UAAU,QAAQ,IAAI,MAAM,MAAM,GAAG;AAC5C,QAAM,CAAC,KAAK,OAAO,IAAI,IAAI,UAAU,MAAM,GAAG,KAAK,CAAC;AACpD,QAAM,CAAC,OAAO,OAAO,IAAI,UAAU,MAAM,GAAG,KAAK,CAAC;AAElD,QAAM,SAAS,QAAQ,GAAG;AAC1B,QAAM,WAAW,QAAQ,KAAK;AAC9B,QAAM,UAAU,QAAQ,IAAI;AAC5B,QAAM,WAAW,QAAQ,KAAK;AAC9B,QAAM,aAAa,QAAQ,OAAO;AAElC,MAAI,UAAU,CAAC,YAAY,CAAC,WAAW,CAAC,YAAY,CAAC,YAAY;AAC/D,WAAO;AAAA,EACT;AACA,MAAI,CAAC,UAAU,YAAY,CAAC,WAAW,CAAC,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