@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
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
3
|
+
import { FieldSpec } from '@digigov/form/types';
|
|
4
|
+
import { ValidatorSchema } from '@digigov/form/validators/types';
|
|
5
|
+
|
|
6
|
+
dayjs.extend(customParseFormat);
|
|
7
|
+
|
|
8
|
+
const VALID_DATETIME_FORMATS = ['DD/MM/YYYY HH:mm'];
|
|
9
|
+
const DATETIME_CACHE = {};
|
|
10
|
+
|
|
11
|
+
const getDateTime = (v: string) => {
|
|
12
|
+
return DATETIME_CACHE[v]
|
|
13
|
+
? DATETIME_CACHE[v]
|
|
14
|
+
: dayjs(v, VALID_DATETIME_FORMATS, true);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const getDaysInMonth = (month: number, year: number): number => {
|
|
18
|
+
return dayjs(`${year}-${month}-01`).daysInMonth(); // e.g. 29 for Feb 2024
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const checkPartialDateTime = (value: string) => {
|
|
22
|
+
const [datePart, timePart] = value.split(' ');
|
|
23
|
+
const [day, month, year] = datePart?.split('/') ?? [];
|
|
24
|
+
const [hours, minutes] = timePart?.split(':') ?? [];
|
|
25
|
+
|
|
26
|
+
const hasDay = Boolean(day);
|
|
27
|
+
const hasMonth = Boolean(month);
|
|
28
|
+
const hasYear = Boolean(year);
|
|
29
|
+
const hasHours = Boolean(hours);
|
|
30
|
+
const hasMinutes = Boolean(minutes);
|
|
31
|
+
|
|
32
|
+
if (hasDay && !hasMonth && !hasYear && !hasHours && !hasMinutes) {
|
|
33
|
+
return 'form.error.datetime.invalid_month_year_hours_minutes';
|
|
34
|
+
}
|
|
35
|
+
if (!hasDay && hasMonth && !hasYear && !hasHours && !hasMinutes) {
|
|
36
|
+
return 'form.error.datetime.invalid_day_year_hours_minutes';
|
|
37
|
+
}
|
|
38
|
+
if (!hasDay && !hasMonth && hasYear && !hasHours && !hasMinutes) {
|
|
39
|
+
return 'form.error.datetime.invalid_day_month_hours_minutes';
|
|
40
|
+
}
|
|
41
|
+
if (hasDay && hasMonth && !hasYear && !hasHours && !hasMinutes) {
|
|
42
|
+
return 'form.error.datetime.invalid_year_hours_minutes';
|
|
43
|
+
}
|
|
44
|
+
if (hasDay && !hasMonth && hasYear && !hasHours && !hasMinutes) {
|
|
45
|
+
return 'form.error.datetime.invalid_month_hours_minutes';
|
|
46
|
+
}
|
|
47
|
+
if (!hasDay && hasMonth && hasYear && !hasHours && !hasMinutes) {
|
|
48
|
+
return 'form.error.datetime.invalid_day_hours_minutes';
|
|
49
|
+
}
|
|
50
|
+
if (hasDay && hasMonth && hasYear && !hasHours && !hasMinutes) {
|
|
51
|
+
return 'form.error.datetime.invalid__hours_minutes';
|
|
52
|
+
}
|
|
53
|
+
if (hasDay && hasMonth && hasYear && hasHours && !hasMinutes) {
|
|
54
|
+
return 'form.error.datetime.invalid_minutes';
|
|
55
|
+
}
|
|
56
|
+
if (hasDay && hasMonth && hasYear && !hasHours && hasMinutes) {
|
|
57
|
+
return 'form.error.datetime.invalid_hours';
|
|
58
|
+
}
|
|
59
|
+
if (hasDay && !hasMonth && !hasYear && hasHours && !hasMinutes) {
|
|
60
|
+
return 'form.error.datetime.invalid_month_year_minutes';
|
|
61
|
+
}
|
|
62
|
+
if (hasDay && !hasMonth && !hasYear && !hasHours && hasMinutes) {
|
|
63
|
+
return 'form.error.datetime.invalid_month_year_hours';
|
|
64
|
+
}
|
|
65
|
+
if (hasDay && !hasMonth && !hasYear && hasHours && hasMinutes) {
|
|
66
|
+
return 'form.error.datetime.invalid_month_year';
|
|
67
|
+
}
|
|
68
|
+
if (!hasDay && hasMonth && !hasYear && hasHours && !hasMinutes) {
|
|
69
|
+
return 'form.error.datetime.invalid_day_year_minutes';
|
|
70
|
+
}
|
|
71
|
+
if (!hasDay && hasMonth && !hasYear && !hasHours && hasMinutes) {
|
|
72
|
+
return 'form.error.datetime.invalid_day_year_hours';
|
|
73
|
+
}
|
|
74
|
+
if (!hasDay && hasMonth && !hasYear && hasHours && hasMinutes) {
|
|
75
|
+
return 'form.error.datetime.invalid_day_year';
|
|
76
|
+
}
|
|
77
|
+
if (!hasDay && !hasMonth && hasYear && hasHours && !hasMinutes) {
|
|
78
|
+
return 'form.error.datetime.invalid_day_month_minutes';
|
|
79
|
+
}
|
|
80
|
+
if (!hasDay && !hasMonth && hasYear && !hasHours && hasMinutes) {
|
|
81
|
+
return 'form.error.datetime.invalid_day_month_hours';
|
|
82
|
+
}
|
|
83
|
+
if (!hasDay && !hasMonth && hasYear && hasHours && hasMinutes) {
|
|
84
|
+
return 'form.error.datetime.invalid_day_month';
|
|
85
|
+
}
|
|
86
|
+
if (!hasDay && !hasMonth && !hasYear && hasHours && hasMinutes) {
|
|
87
|
+
return 'form.error.datetime.invalid_day_month_year';
|
|
88
|
+
}
|
|
89
|
+
if (!hasDay && !hasMonth && !hasYear && !hasHours && hasMinutes) {
|
|
90
|
+
return 'form.error.datetime.invalid_day_month_year_hours';
|
|
91
|
+
}
|
|
92
|
+
if (hasDay && hasMonth && !hasYear && hasHours && !hasMinutes) {
|
|
93
|
+
return 'form.error.datetime.invalid_year_minutes';
|
|
94
|
+
}
|
|
95
|
+
if (hasDay && hasMonth && !hasYear && !hasHours && hasMinutes) {
|
|
96
|
+
return 'form.error.datetime.invalid_year_hours';
|
|
97
|
+
}
|
|
98
|
+
if (hasDay && hasMonth && !hasYear && hasHours && hasMinutes) {
|
|
99
|
+
return 'form.error.datetime.invalid_year';
|
|
100
|
+
}
|
|
101
|
+
if (hasDay && !hasMonth && hasYear && hasHours && !hasMinutes) {
|
|
102
|
+
return 'form.error.datetime.invalid_month_minutes';
|
|
103
|
+
}
|
|
104
|
+
if (hasDay && !hasMonth && hasYear && !hasHours && hasMinutes) {
|
|
105
|
+
return 'form.error.datetime.invalid_month_hours';
|
|
106
|
+
}
|
|
107
|
+
if (hasDay && !hasMonth && hasYear && hasHours && hasMinutes) {
|
|
108
|
+
return 'form.error.datetime.invalid_month';
|
|
109
|
+
}
|
|
110
|
+
if (!hasDay && hasMonth && hasYear && hasHours && !hasMinutes) {
|
|
111
|
+
return 'form.error.datetime.invalid_day_minutes';
|
|
112
|
+
}
|
|
113
|
+
if (!hasDay && hasMonth && hasYear && !hasHours && hasMinutes) {
|
|
114
|
+
return 'form.error.datetime.invalid_day_hours';
|
|
115
|
+
}
|
|
116
|
+
if (!hasDay && hasMonth && hasYear && hasHours && hasMinutes) {
|
|
117
|
+
return 'form.error.datetime.invalid_day';
|
|
118
|
+
}
|
|
119
|
+
if (!hasDay && !hasMonth && !hasYear && hasHours && !hasMinutes) {
|
|
120
|
+
return 'form.error.datetime.invalid_day_month_year_minutes';
|
|
121
|
+
}
|
|
122
|
+
if (hasDay && hasMonth && hasYear && !hasHours && !hasMinutes) {
|
|
123
|
+
return 'form.error.datetime.invalid_hours_minutes';
|
|
124
|
+
}
|
|
125
|
+
if (day && month) {
|
|
126
|
+
const dayNum = parseInt(day);
|
|
127
|
+
const monthNum = parseInt(month);
|
|
128
|
+
const yearNum = parseInt(year);
|
|
129
|
+
const maxDay = getDaysInMonth(monthNum, yearNum);
|
|
130
|
+
if (dayNum < 1 || dayNum > maxDay) {
|
|
131
|
+
return {
|
|
132
|
+
key: 'form.error.datetime.invalid_day_range',
|
|
133
|
+
context: {
|
|
134
|
+
maxDay: maxDay,
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
if (monthNum < 1 || monthNum > 12) {
|
|
139
|
+
return 'form.error.datetime.invalid_month_range';
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (hours && minutes) {
|
|
143
|
+
const hoursNum = parseInt(hours);
|
|
144
|
+
const minutesNum = parseInt(minutes);
|
|
145
|
+
if (hoursNum < 0 || hoursNum > 23) {
|
|
146
|
+
return 'form.error.datetime.invalid_hours_range';
|
|
147
|
+
}
|
|
148
|
+
if (minutesNum < 0 || minutesNum > 59) {
|
|
149
|
+
return 'form.error.datetime.invalid_minutes_range';
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return 'form.error.datetime.invalid';
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export const LATER_THAN_DATETIME_VALIDATOR = (
|
|
156
|
+
field: FieldSpec
|
|
157
|
+
): ValidatorSchema => {
|
|
158
|
+
let minDateTime;
|
|
159
|
+
const params = field.extra || {};
|
|
160
|
+
if (params.min === 'now') {
|
|
161
|
+
minDateTime = dayjs();
|
|
162
|
+
} else {
|
|
163
|
+
minDateTime = getDateTime(params.min);
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
name: 'later-than-datetime',
|
|
167
|
+
message: {
|
|
168
|
+
key: 'form.error.datetime.later_than',
|
|
169
|
+
context: {
|
|
170
|
+
minDateTime: minDateTime.format('DD/MM/YYYY HH:mm'),
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
test: function (value: string) {
|
|
174
|
+
if (!value) return true;
|
|
175
|
+
const datetime = getDateTime(value);
|
|
176
|
+
return datetime.isValid() && datetime.isAfter(minDateTime);
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export const EARLIER_THAN_DATETIME_VALIDATOR = (
|
|
182
|
+
field: FieldSpec
|
|
183
|
+
): ValidatorSchema => {
|
|
184
|
+
let maxDateTime;
|
|
185
|
+
const params = field.extra || {};
|
|
186
|
+
if (params.max === 'now') {
|
|
187
|
+
maxDateTime = dayjs();
|
|
188
|
+
} else {
|
|
189
|
+
maxDateTime = getDateTime(params.max);
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
name: 'earlier-than-datetime',
|
|
193
|
+
message: {
|
|
194
|
+
key: 'form.error.datetime.earlier_than',
|
|
195
|
+
context: {
|
|
196
|
+
maxDateTime: maxDateTime.format('DD/MM/YYYY HH:mm'),
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
test: function (value: string) {
|
|
200
|
+
if (!value) return true;
|
|
201
|
+
const datetime = getDateTime(value);
|
|
202
|
+
return datetime.isValid() && datetime.isBefore(maxDateTime);
|
|
203
|
+
},
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
export const DATETIME_VALIDATOR = {
|
|
208
|
+
name: 'datetime-validator',
|
|
209
|
+
message: (v): string | object => {
|
|
210
|
+
return checkPartialDateTime(v.value);
|
|
211
|
+
},
|
|
212
|
+
test: function (value: string) {
|
|
213
|
+
if (!value) return true;
|
|
214
|
+
const datetime = getDateTime(value);
|
|
215
|
+
return datetime.isValid();
|
|
216
|
+
},
|
|
217
|
+
};
|
|
@@ -3,23 +3,39 @@ import { ValidatorSchema } from '@digigov/form/validators/types';
|
|
|
3
3
|
|
|
4
4
|
const DEFAULT_FILE_MAX_SIZE = 10000000;
|
|
5
5
|
|
|
6
|
-
export const FILE_MAX_SIZE_VALIDATOR = (field: FieldSpec): ValidatorSchema =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
export const FILE_MAX_SIZE_VALIDATOR = (field: FieldSpec): ValidatorSchema => {
|
|
7
|
+
const maxSizeInBytes = field?.extra?.limit?.maxSize || DEFAULT_FILE_MAX_SIZE;
|
|
8
|
+
let maxSizeTransformed = maxSizeInBytes / (1024 * 1024); // In MB
|
|
9
|
+
let maxSizeText = 'MB';
|
|
10
|
+
if (Math.round(maxSizeTransformed) === 0) {
|
|
11
|
+
maxSizeTransformed = Math.round(maxSizeInBytes / 1024);
|
|
12
|
+
maxSizeText = 'KB';
|
|
13
|
+
}
|
|
14
|
+
if (Math.round(maxSizeTransformed) === 0) {
|
|
15
|
+
maxSizeTransformed = maxSizeInBytes;
|
|
16
|
+
maxSizeText = 'Bytes';
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
name: 'file-max-size-validator',
|
|
20
|
+
message: {
|
|
21
|
+
key:
|
|
22
|
+
field.type === 'file'
|
|
23
|
+
? 'form.error.file_size'
|
|
24
|
+
: 'form.error.image_size',
|
|
25
|
+
context: {
|
|
26
|
+
maxSize: `${maxSizeTransformed} ${maxSizeText}`,
|
|
27
|
+
},
|
|
12
28
|
},
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
29
|
+
test: (value: File[]): boolean => {
|
|
30
|
+
if (value) {
|
|
31
|
+
for (const file of Array.from(value)) {
|
|
32
|
+
const maxSize = field?.extra?.limit?.maxSize || DEFAULT_FILE_MAX_SIZE;
|
|
33
|
+
if (file.size > maxSize) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
20
36
|
}
|
|
21
37
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
}
|
|
38
|
+
return true;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
};
|
|
@@ -3,6 +3,7 @@ import { FieldSpec } from '@digigov/form/types';
|
|
|
3
3
|
import { ValidatorSchema } from '@digigov/form/validators/types';
|
|
4
4
|
|
|
5
5
|
export * from '@digigov/form/validators/utils/afm';
|
|
6
|
+
export * from '@digigov/form/validators/utils/amka';
|
|
6
7
|
export * from '@digigov/form/validators/utils/file';
|
|
7
8
|
export * from '@digigov/form/validators/utils/iban';
|
|
8
9
|
export * from '@digigov/form/validators/utils/otp';
|
|
@@ -11,6 +12,8 @@ export * from '@digigov/form/validators/utils/phone';
|
|
|
11
12
|
export * from '@digigov/form/validators/utils/postal_code';
|
|
12
13
|
export * from '@digigov/form/validators/utils/uuid4';
|
|
13
14
|
export * from '@digigov/form/validators/utils/text_limit';
|
|
15
|
+
export * from '@digigov/form/validators/utils/date';
|
|
16
|
+
export * from '@digigov/form/validators/utils/datetime';
|
|
14
17
|
|
|
15
18
|
export function getYupField(field: FieldSpec, yupTypeMap: Record<string, any>) {
|
|
16
19
|
const yupField = yupTypeMap[field?.type || 'string'] || yupTypeMap['string'];
|
|
@@ -96,7 +99,9 @@ export function getYupObjectShape(
|
|
|
96
99
|
|
|
97
100
|
return yup.lazy(function () {
|
|
98
101
|
const fieldSchemas = computeShape(
|
|
99
|
-
Object.values(fields.current)
|
|
102
|
+
Object.values(fields.current).filter(
|
|
103
|
+
(f: FieldSpec) => !f.key.includes('.')
|
|
104
|
+
) as FieldSpec[],
|
|
100
105
|
yupTypeMap,
|
|
101
106
|
validatorRegistry
|
|
102
107
|
);
|
|
@@ -13,7 +13,7 @@ export const INT_VALIDATOR = (): ValidatorSchema => {
|
|
|
13
13
|
name: 'int-validator',
|
|
14
14
|
message: 'form.error.positive_integer_number',
|
|
15
15
|
test: (value: number): boolean => {
|
|
16
|
-
if (value ===
|
|
16
|
+
if (value === undefined) {
|
|
17
17
|
return true;
|
|
18
18
|
}
|
|
19
19
|
return validateIntNumber(value);
|
|
@@ -9,7 +9,7 @@ export const NUMBER_VALIDATOR = (): ValidatorSchema => {
|
|
|
9
9
|
name: 'number-validator',
|
|
10
10
|
message: 'form.error.number',
|
|
11
11
|
test: (value: number): boolean => {
|
|
12
|
-
if (value ===
|
|
12
|
+
if (value === undefined) {
|
|
13
13
|
return true;
|
|
14
14
|
}
|
|
15
15
|
return validateNumber(value);
|
|
@@ -4,20 +4,20 @@ import { ValidatorSchema } from '@digigov/form/validators/types';
|
|
|
4
4
|
export type PhoneNumberType = 'landline' | 'mobile' | null;
|
|
5
5
|
// add more countries from here libphonenumber-js/metadata.full.json
|
|
6
6
|
const countryPhoneData = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
GR: [
|
|
8
|
+
'30',
|
|
9
|
+
'00',
|
|
10
|
+
'5005000\\d{3}|8\\d{9,11}|(?:[269]\\d|70)\\d{8}',
|
|
11
11
|
[10, 11, 12],
|
|
12
12
|
[
|
|
13
|
-
[
|
|
13
|
+
['(\\d{2})(\\d{4})(\\d{4})', '$1 $2 $3', ['21|7']],
|
|
14
14
|
[
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
[
|
|
15
|
+
'(\\d{4})(\\d{6})',
|
|
16
|
+
'$1 $2',
|
|
17
|
+
['2(?:2|3[2-57-9]|4[2-469]|5[2-59]|6[2-9]|7[2-69]|8[2-49])|5'],
|
|
18
18
|
],
|
|
19
|
-
[
|
|
20
|
-
[
|
|
19
|
+
['(\\d{3})(\\d{3})(\\d{4})', '$1 $2 $3', ['[2689]']],
|
|
20
|
+
['(\\d{3})(\\d{3,4})(\\d{5})', '$1 $2 $3', ['8']],
|
|
21
21
|
],
|
|
22
22
|
0,
|
|
23
23
|
0,
|
|
@@ -27,93 +27,77 @@ const countryPhoneData = {
|
|
|
27
27
|
0,
|
|
28
28
|
[
|
|
29
29
|
[
|
|
30
|
-
|
|
31
|
-
[10]
|
|
30
|
+
'2(?:1\\d\\d|2(?:2[1-46-9]|[36][1-8]|4[1-7]|5[1-4]|7[1-5]|[89][1-9])|3(?:1\\d|2[1-57]|[35][1-3]|4[13]|7[1-7]|8[124-6]|9[1-79])|4(?:1\\d|2[1-8]|3[1-4]|4[13-5]|6[1-578]|9[1-5])|5(?:1\\d|[29][1-4]|3[1-5]|4[124]|5[1-6])|6(?:1\\d|[269][1-6]|3[1245]|4[1-7]|5[13-9]|7[14]|8[1-5])|7(?:1\\d|2[1-5]|3[1-6]|4[1-7]|5[1-57]|6[135]|9[125-7])|8(?:1\\d|2[1-5]|[34][1-4]|9[1-57]))\\d{6}',
|
|
31
|
+
[10],
|
|
32
32
|
],
|
|
33
|
-
[
|
|
34
|
-
[
|
|
35
|
-
[
|
|
36
|
-
[
|
|
33
|
+
['68[57-9]\\d{7}|(?:69|94)\\d{8}', [10]],
|
|
34
|
+
['800\\d{7,9}'],
|
|
35
|
+
['90[19]\\d{7}', [10]],
|
|
36
|
+
['70\\d{8}', [10]],
|
|
37
37
|
0,
|
|
38
|
-
[
|
|
38
|
+
['5005000\\d{3}', [10]],
|
|
39
39
|
0,
|
|
40
40
|
0,
|
|
41
|
-
[
|
|
42
|
-
]
|
|
43
|
-
]
|
|
44
|
-
}
|
|
41
|
+
['8(?:0[16]|12|[27]5|50)\\d{7}', [10]],
|
|
42
|
+
],
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
45
|
|
|
46
46
|
function expandPhoneNumberStructure(compressed) {
|
|
47
47
|
const countries = Object.keys(compressed);
|
|
48
|
-
const expanded: any = {}
|
|
48
|
+
const expanded: any = {};
|
|
49
49
|
for (const country of countries) {
|
|
50
50
|
expanded[country] = {
|
|
51
51
|
fixedLine: {
|
|
52
52
|
possibleLengths: {
|
|
53
|
-
_national:
|
|
54
|
-
compressed[country][3].map(
|
|
55
|
-
String
|
|
56
|
-
),
|
|
53
|
+
_national: compressed[country][3].map(String),
|
|
57
54
|
},
|
|
58
|
-
nationalNumberPattern:
|
|
59
|
-
compressed[country][11][0][0],
|
|
55
|
+
nationalNumberPattern: compressed[country][11][0][0],
|
|
60
56
|
},
|
|
61
57
|
mobile: {
|
|
62
|
-
nationalNumberPattern:
|
|
63
|
-
compressed[country][11][1][0],
|
|
58
|
+
nationalNumberPattern: compressed[country][11][1][0],
|
|
64
59
|
},
|
|
65
60
|
tollFree: {
|
|
66
|
-
nationalNumberPattern:
|
|
67
|
-
compressed[country][11][2][0],
|
|
61
|
+
nationalNumberPattern: compressed[country][11][2][0],
|
|
68
62
|
},
|
|
69
63
|
premiumRate: {
|
|
70
|
-
nationalNumberPattern:
|
|
71
|
-
compressed[country][11][3][0],
|
|
64
|
+
nationalNumberPattern: compressed[country][11][3][0],
|
|
72
65
|
},
|
|
73
66
|
sharedCost: {
|
|
74
|
-
nationalNumberPattern:
|
|
75
|
-
compressed[country][11][9][0],
|
|
67
|
+
nationalNumberPattern: compressed[country][11][9][0],
|
|
76
68
|
},
|
|
77
69
|
personalNumber: {
|
|
78
|
-
nationalNumberPattern:
|
|
79
|
-
compressed[country][11][4][0],
|
|
70
|
+
nationalNumberPattern: compressed[country][11][4][0],
|
|
80
71
|
},
|
|
81
72
|
uan: {
|
|
82
|
-
nationalNumberPattern:
|
|
83
|
-
compressed[country][11][6][0],
|
|
73
|
+
nationalNumberPattern: compressed[country][11][6][0],
|
|
84
74
|
},
|
|
85
75
|
id: country,
|
|
86
|
-
countryCode:
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
compressed[country][1],
|
|
90
|
-
|
|
91
|
-
}
|
|
76
|
+
countryCode: compressed[country][0],
|
|
77
|
+
internationalPrefix: compressed[country][1],
|
|
78
|
+
};
|
|
92
79
|
}
|
|
93
80
|
return expanded;
|
|
94
81
|
}
|
|
95
82
|
const PHONENUMBER_SPEC = expandPhoneNumberStructure(countryPhoneData);
|
|
96
|
-
export function discoverPhoneType(
|
|
97
|
-
phoneNumber: string,
|
|
98
|
-
config: any
|
|
99
|
-
): string {
|
|
83
|
+
export function discoverPhoneType(phoneNumber: string, config: any): string {
|
|
100
84
|
const cleanNumber = phoneNumber
|
|
101
|
-
.replace(/\D/g,
|
|
102
|
-
.replace(/\s/g,
|
|
103
|
-
.replace(/^\+/,
|
|
104
|
-
.replace(new RegExp(
|
|
105
|
-
.replace(new RegExp(
|
|
85
|
+
.replace(/\D/g, '')
|
|
86
|
+
.replace(/\s/g, '')
|
|
87
|
+
.replace(/^\+/, '')
|
|
88
|
+
.replace(new RegExp('^' + config.internationalPrefix, ''), '')
|
|
89
|
+
.replace(new RegExp('^' + config.countryCode, ''), '');
|
|
106
90
|
const categories = {
|
|
107
|
-
|
|
91
|
+
landline: config.fixedLine,
|
|
108
92
|
mobile: config.mobile,
|
|
109
|
-
|
|
110
|
-
|
|
93
|
+
'toll-free': config.tollFree,
|
|
94
|
+
'premium-rate': config.premiumRate,
|
|
111
95
|
};
|
|
112
96
|
|
|
113
97
|
for (const [categoryName, categoryDetails] of Object.entries(categories)) {
|
|
114
98
|
const pattern = new RegExp(
|
|
115
|
-
|
|
116
|
-
|
|
99
|
+
'^(' + categoryDetails.nationalNumberPattern.replace(/\s/g, '') + ')$',
|
|
100
|
+
''
|
|
117
101
|
);
|
|
118
102
|
if (cleanNumber.match(pattern)) {
|
|
119
103
|
return categoryName; // Returns the category name if the number matches the pattern
|
|
@@ -121,47 +105,54 @@ export function discoverPhoneType(
|
|
|
121
105
|
}
|
|
122
106
|
|
|
123
107
|
// If no category matches, return 'Unknown'
|
|
124
|
-
return
|
|
108
|
+
return 'unknown';
|
|
125
109
|
}
|
|
126
110
|
function getNumberType(phoneNumber: string, country: string) {
|
|
127
111
|
const spec = PHONENUMBER_SPEC[country.toUpperCase()];
|
|
128
|
-
if(!spec) {
|
|
112
|
+
if (!spec) {
|
|
129
113
|
throw new Error(`Country ${country} is not supported`);
|
|
130
114
|
}
|
|
131
115
|
const type = discoverPhoneType(phoneNumber, spec);
|
|
132
116
|
return type;
|
|
133
117
|
}
|
|
134
118
|
|
|
135
|
-
function isPhoneNumberValid(
|
|
119
|
+
function isPhoneNumberValid(
|
|
120
|
+
phoneNumber: string,
|
|
121
|
+
countries: string[],
|
|
122
|
+
types = ['mobile', 'landline']
|
|
123
|
+
) {
|
|
136
124
|
return countries.some((country) => {
|
|
137
125
|
const numberType = getNumberType(phoneNumber, country);
|
|
138
126
|
if (numberType && types.includes(numberType)) {
|
|
139
|
-
return true
|
|
127
|
+
return true;
|
|
140
128
|
}
|
|
141
|
-
return false
|
|
142
|
-
})
|
|
129
|
+
return false;
|
|
130
|
+
});
|
|
143
131
|
}
|
|
144
132
|
function isNumberOfType(phoneNumber: string, country: string, type: string) {
|
|
145
133
|
const numberType = getNumberType(phoneNumber, country);
|
|
146
134
|
if (numberType === type) {
|
|
147
|
-
return true
|
|
135
|
+
return true;
|
|
148
136
|
}
|
|
149
|
-
return false
|
|
137
|
+
return false;
|
|
150
138
|
}
|
|
151
139
|
export function validatePhoneNumber(
|
|
152
140
|
phoneNumber: string,
|
|
153
|
-
countries:
|
|
141
|
+
countries: string[] = ['gr'],
|
|
154
142
|
typeOfPhoneNumber?: PhoneNumberType
|
|
155
143
|
): boolean {
|
|
156
144
|
if (!countries || countries.length === 0) {
|
|
157
145
|
return true;
|
|
158
146
|
}
|
|
159
|
-
return isPhoneNumberValid(
|
|
147
|
+
return isPhoneNumberValid(
|
|
148
|
+
phoneNumber,
|
|
149
|
+
countries,
|
|
150
|
+
typeOfPhoneNumber ? [typeOfPhoneNumber] : undefined
|
|
151
|
+
);
|
|
160
152
|
}
|
|
161
153
|
|
|
162
|
-
|
|
163
154
|
function validateMobile(value): boolean {
|
|
164
|
-
return isNumberOfType(value, 'gr','mobile');
|
|
155
|
+
return isNumberOfType(value, 'gr', 'mobile');
|
|
165
156
|
}
|
|
166
157
|
|
|
167
158
|
export const MOBILE_PHONE_VALIDATOR = {
|
|
@@ -4,7 +4,7 @@ import { ValidatorSchema } from '@digigov/form/validators/types';
|
|
|
4
4
|
const CODE_REGEX = /^[12345678][0-9]{4}$/;
|
|
5
5
|
export function validatePostalCode(
|
|
6
6
|
number: string,
|
|
7
|
-
countries:
|
|
7
|
+
countries: string[]
|
|
8
8
|
): boolean {
|
|
9
9
|
if (!countries) {
|
|
10
10
|
return false;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
const UUID4_PATTERN =
|
|
1
|
+
const UUID4_PATTERN =
|
|
2
|
+
/^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i;
|
|
2
3
|
|
|
3
4
|
export function validateUUID4(uuid4: string): boolean {
|
|
4
5
|
if (uuid4.length !== 36) {
|
|
@@ -69,54 +69,20 @@ it('validates phone number type landline with greek country code', () => {
|
|
|
69
69
|
expect(validatePhoneNumber('2102934896', ['GR'], 'landline')).toBe(true);
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
it('
|
|
73
|
-
expect(validatePhoneNumber('2102934896', ['CH'], 'landline')).
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
it('validates phone number type landline with ch and gr countries code', () => {
|
|
77
|
-
expect(validatePhoneNumber('2102934896', ['GR', 'CH'], 'landline')).toBe(
|
|
78
|
-
true
|
|
79
|
-
);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('validatesphone number type landline with ch and gr countries code', () => {
|
|
83
|
-
expect(validatePhoneNumber('41446681800', ['GR', 'CH'], 'landline')).toBe(
|
|
84
|
-
true
|
|
72
|
+
it('throws if given country is not supported', () => {
|
|
73
|
+
expect(() => validatePhoneNumber('2102934896', ['CH'], 'landline')).toThrow(
|
|
74
|
+
'Country CH is not supported'
|
|
85
75
|
);
|
|
86
76
|
});
|
|
87
77
|
|
|
88
|
-
it('validates phone number type
|
|
89
|
-
expect(validatePhoneNumber('2102934896', ['GR', 'CH'], 'mobile')).toBe(false);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('validates phone number type mobile with ch and gr countries code', () => {
|
|
93
|
-
expect(validatePhoneNumber('6934100982', ['GR', 'CH'], 'mobile')).toBe(true);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('validates phone number type mobile with gr country code', () => {
|
|
78
|
+
it('validates phone number type mobile with gr country code', () => {
|
|
97
79
|
expect(validatePhoneNumber('6934100982', ['GR'], 'mobile')).toBe(true);
|
|
98
80
|
});
|
|
99
81
|
|
|
100
|
-
it('validates
|
|
101
|
-
expect(validatePhoneNumber('6934100982', ['CH'], 'mobile')).toBe(false);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('validates phone number with no type and ch country code', () => {
|
|
105
|
-
expect(validatePhoneNumber('6934100982', ['CH'], null)).toBe(false);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('validates phone number with no type and gr country code', () => {
|
|
82
|
+
it('validates phone number with no type and gr country code', () => {
|
|
109
83
|
expect(validatePhoneNumber('6934100982', ['gr'], null)).toBe(true);
|
|
110
84
|
});
|
|
111
85
|
|
|
112
|
-
it('validates
|
|
113
|
-
expect(validatePhoneNumber('41446681800', ['CH'], null)).toBe(true);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it('validates phone number with no type and gr country code', () => {
|
|
86
|
+
it('validates invalid phone number with no type and gr country code', () => {
|
|
117
87
|
expect(validatePhoneNumber('41446681800', ['gr'], null)).toBe(false);
|
|
118
88
|
});
|
|
119
|
-
|
|
120
|
-
it('validates phone number with no type and gr and ch countries code', () => {
|
|
121
|
-
expect(validatePhoneNumber('41446681800', ['gr', 'ch'], null)).toBe(true);
|
|
122
|
-
});
|
package/types/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "@digigov/form/Field/types";
|
|
2
|
+
//# sourceMappingURL=types.js.map
|