@digigov/form 1.0.0-8ae63a77 → 1.0.0-8b33e4c8
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/FieldBase.js +14 -31
- package/Field/FieldBaseContainer.js +19 -41
- package/Field/FieldConditional.js +14 -33
- package/Field/index.js +18 -45
- package/Field/package.json +6 -0
- package/Field/types.js +1 -5
- package/Field/utils.js +30 -63
- package/FieldArray/FieldArray.stories.js +5 -42
- package/FieldArray/__stories__/Default.js +11 -32
- package/FieldArray/__stories__/WithExactLength.js +11 -32
- package/FieldArray/index.js +19 -41
- package/FieldArray/package.json +6 -0
- package/FieldObject/index.js +16 -41
- package/FieldObject/package.json +6 -0
- package/Fieldset/FieldsetWithContext.js +13 -35
- package/Fieldset/index.js +21 -51
- package/Fieldset/package.json +6 -0
- package/Fieldset/types.js +1 -5
- package/Form.stories.js +2 -9
- package/FormBuilder/FormBuilder.js +33 -62
- package/FormBuilder/FormBuilder.stories.js +4 -28
- package/FormBuilder/__stories__/Default.js +8 -29
- package/FormBuilder/index.js +2 -11
- package/FormBuilder/package.json +6 -0
- package/FormContext.js +3 -12
- package/MultiplicityField/MultiplicityField.stories.js +9 -98
- package/MultiplicityField/__stories__/Default.js +11 -32
- package/MultiplicityField/__stories__/PreviewDisplay.js +29 -52
- package/MultiplicityField/__stories__/WithExactLength.js +11 -32
- package/MultiplicityField/__stories__/WithMaxLength.js +11 -32
- package/MultiplicityField/__stories__/WithMinAndMaxLength.js +11 -32
- package/MultiplicityField/__stories__/WithMinLength.js +11 -32
- package/MultiplicityField/add-objects.js +25 -49
- package/MultiplicityField/index.js +26 -55
- package/MultiplicityField/package.json +6 -0
- package/Questions/Questions.js +14 -35
- package/Questions/Questions.stories.js +4 -28
- package/Questions/QuestionsContext.js +3 -12
- package/Questions/Step/ReviewStep.js +21 -47
- package/Questions/Step/Step.js +18 -42
- package/Questions/Step/StepArrayReview.js +23 -52
- package/Questions/Step/StepContext.js +3 -13
- package/Questions/Step/StepDescription.js +14 -42
- package/Questions/Step/StepForm.js +19 -45
- package/Questions/Step/StepQuote.js +8 -23
- package/Questions/Step/StepTitle.js +17 -48
- package/Questions/Step/getAddMoreFields.js +2 -11
- package/Questions/Step/index.js +13 -170
- package/Questions/Step/package.json +6 -0
- package/Questions/Step/types.js +1 -5
- package/Questions/__stories__/Default.js +24 -51
- package/Questions/getNextStep.js +1 -8
- package/Questions/index.js +3 -25
- package/Questions/index.spec.js +12 -23
- package/Questions/package.json +6 -0
- package/Questions/types.js +1 -5
- package/{es → cjs}/Field/FieldBase.js +31 -14
- package/cjs/Field/FieldBaseContainer.js +65 -0
- package/cjs/Field/FieldConditional.js +81 -0
- package/cjs/Field/index.js +103 -0
- package/cjs/Field/types.js +5 -0
- package/{es → cjs}/Field/utils.js +63 -30
- package/cjs/FieldArray/FieldArray.stories.js +45 -0
- package/cjs/FieldArray/__stories__/Default.js +111 -0
- package/cjs/FieldArray/__stories__/WithExactLength.js +111 -0
- package/cjs/FieldArray/index.js +87 -0
- package/cjs/FieldObject/index.js +83 -0
- package/cjs/Fieldset/FieldsetWithContext.js +63 -0
- package/cjs/Fieldset/index.js +64 -0
- package/cjs/Fieldset/types.js +5 -0
- package/cjs/Form.stories.js +10 -0
- package/{esm → cjs}/FormBuilder/FormBuilder.js +62 -33
- package/cjs/FormBuilder/FormBuilder.stories.js +31 -0
- package/cjs/FormBuilder/__stories__/Default.js +49 -0
- package/cjs/FormBuilder/index.js +11 -0
- package/cjs/FormContext.js +14 -0
- package/cjs/MultiplicityField/MultiplicityField.stories.js +101 -0
- package/{es → cjs}/MultiplicityField/__stories__/Default.js +32 -11
- package/cjs/MultiplicityField/__stories__/PreviewDisplay.js +106 -0
- package/{esm → cjs}/MultiplicityField/__stories__/WithExactLength.js +32 -11
- package/{es → cjs}/MultiplicityField/__stories__/WithMaxLength.js +32 -11
- package/{es → cjs}/MultiplicityField/__stories__/WithMinAndMaxLength.js +32 -11
- package/{esm → cjs}/MultiplicityField/__stories__/WithMinLength.js +32 -11
- package/{esm → cjs}/MultiplicityField/add-objects.js +49 -25
- package/cjs/MultiplicityField/index.js +143 -0
- package/cjs/Questions/Questions.js +105 -0
- package/cjs/Questions/Questions.stories.js +31 -0
- package/cjs/Questions/QuestionsContext.js +20 -0
- package/cjs/Questions/Step/ReviewStep.js +79 -0
- package/cjs/Questions/Step/Step.js +93 -0
- package/cjs/Questions/Step/StepArrayReview.js +79 -0
- package/{esm → cjs}/Questions/Step/StepContext.js +13 -3
- package/cjs/Questions/Step/StepDescription.js +55 -0
- package/cjs/Questions/Step/StepForm.js +74 -0
- package/cjs/Questions/Step/StepQuote.js +26 -0
- package/cjs/Questions/Step/StepTitle.js +75 -0
- package/{es → cjs}/Questions/Step/getAddMoreFields.js +11 -2
- package/cjs/Questions/Step/index.js +170 -0
- package/cjs/Questions/Step/types.js +5 -0
- package/cjs/Questions/__stories__/Default.js +135 -0
- package/{es → cjs}/Questions/getNextStep.js +8 -1
- package/cjs/Questions/index.js +25 -0
- package/cjs/Questions/index.spec.js +73 -0
- package/cjs/Questions/types.js +5 -0
- package/cjs/index.js +28 -0
- package/cjs/inputs/AutoComplete/AutoComplete.stories.js +31 -0
- package/cjs/inputs/AutoComplete/__stories__/Default.js +71 -0
- package/cjs/inputs/AutoComplete/index.js +68 -0
- package/cjs/inputs/Checkboxes/Checkboxes.stories.js +59 -0
- package/{es → cjs}/inputs/Checkboxes/__stories__/Conditional.js +28 -8
- package/cjs/inputs/Checkboxes/__stories__/Default.js +62 -0
- package/cjs/inputs/Checkboxes/__stories__/WithDivider.js +63 -0
- package/cjs/inputs/Checkboxes/index.js +127 -0
- package/cjs/inputs/DateInput/DateInput.stories.js +31 -0
- package/cjs/inputs/DateInput/__stories__/Default.js +45 -0
- package/cjs/inputs/DateInput/index.js +181 -0
- package/cjs/inputs/FileInput/FileInput.stories.js +31 -0
- package/cjs/inputs/FileInput/__stories__/Default.js +42 -0
- package/cjs/inputs/FileInput/index.js +92 -0
- package/cjs/inputs/Input/Input.stories.js +143 -0
- package/cjs/inputs/Input/__stories__/AFM.js +44 -0
- package/cjs/inputs/Input/__stories__/Boolean.js +45 -0
- package/cjs/inputs/Input/__stories__/Default.js +45 -0
- package/cjs/inputs/Input/__stories__/IBAN.js +45 -0
- package/cjs/inputs/Input/__stories__/Integer.js +53 -0
- package/cjs/inputs/Input/__stories__/MobilePhone.js +44 -0
- package/cjs/inputs/Input/__stories__/PhoneNumber.js +44 -0
- package/cjs/inputs/Input/__stories__/PostalCode.js +47 -0
- package/cjs/inputs/Input/__stories__/TextWithCharacterLimit.js +51 -0
- package/cjs/inputs/Input/index.js +96 -0
- package/cjs/inputs/Label/Label.stories.js +31 -0
- package/cjs/inputs/Label/__stories__/Default.js +49 -0
- package/cjs/inputs/Label/index.js +41 -0
- package/cjs/inputs/OtpInput/OtpInput.stories.js +31 -0
- package/cjs/inputs/OtpInput/__stories__/Default.js +52 -0
- package/cjs/inputs/OtpInput/index.js +182 -0
- package/cjs/inputs/Radio/Radio.stories.js +59 -0
- package/{es → cjs}/inputs/Radio/__stories__/Conditional.js +28 -8
- package/cjs/inputs/Radio/__stories__/Default.js +67 -0
- package/cjs/inputs/Radio/__stories__/WithDivider.js +68 -0
- package/cjs/inputs/Radio/index.js +82 -0
- package/cjs/inputs/Select/Select.stories.js +31 -0
- package/cjs/inputs/Select/__stories__/Default.js +73 -0
- package/cjs/inputs/Select/index.js +49 -0
- package/cjs/inputs/index.js +71 -0
- package/cjs/internal.js +391 -0
- package/cjs/registry.js +208 -0
- package/cjs/types.js +5 -0
- package/{es → cjs}/utils.js +26 -12
- package/{es → cjs}/validators/index.js +54 -26
- package/cjs/validators/types.js +5 -0
- package/{es → cjs}/validators/utils/afm.js +13 -3
- package/{es → cjs}/validators/utils/file.js +12 -2
- package/{esm → cjs}/validators/utils/iban.js +13 -2
- package/cjs/validators/utils/index.js +229 -0
- package/{es → cjs}/validators/utils/int.js +14 -3
- package/cjs/validators/utils/number.js +27 -0
- package/{esm → cjs}/validators/utils/otp.js +14 -3
- package/{esm → cjs}/validators/utils/phone.js +28 -6
- package/{es → cjs}/validators/utils/postal_code.js +14 -3
- package/{esm → cjs}/validators/utils/text_limit.js +14 -3
- package/{es → cjs}/validators/utils/uuid4.js +13 -3
- package/cjs/validators/validators.spec.js +88 -0
- package/index.js +8 -28
- package/inputs/AutoComplete/AutoComplete.stories.js +4 -28
- package/inputs/AutoComplete/__stories__/Default.js +13 -35
- package/inputs/AutoComplete/index.js +12 -35
- package/inputs/AutoComplete/package.json +6 -0
- package/inputs/Checkboxes/Checkboxes.stories.js +6 -56
- package/inputs/Checkboxes/__stories__/Conditional.js +8 -28
- package/inputs/Checkboxes/__stories__/Default.js +8 -28
- package/inputs/Checkboxes/__stories__/WithDivider.js +8 -28
- package/inputs/Checkboxes/index.js +25 -52
- package/inputs/Checkboxes/package.json +6 -0
- package/inputs/DateInput/DateInput.stories.js +4 -28
- package/inputs/DateInput/__stories__/Default.js +8 -28
- package/inputs/DateInput/index.js +26 -52
- package/inputs/DateInput/package.json +6 -0
- package/inputs/FileInput/FileInput.stories.js +4 -28
- package/inputs/FileInput/__stories__/Default.js +8 -28
- package/inputs/FileInput/index.js +22 -52
- package/inputs/FileInput/package.json +6 -0
- package/inputs/Input/Input.stories.js +12 -140
- package/inputs/Input/__stories__/AFM.js +8 -28
- package/inputs/Input/__stories__/Boolean.js +8 -28
- package/inputs/Input/__stories__/Default.js +8 -28
- package/inputs/Input/__stories__/IBAN.js +8 -28
- package/inputs/Input/__stories__/Integer.js +9 -29
- package/inputs/Input/__stories__/MobilePhone.js +8 -28
- package/inputs/Input/__stories__/PhoneNumber.js +8 -28
- package/inputs/Input/__stories__/PostalCode.js +8 -28
- package/inputs/Input/__stories__/TextWithCharacterLimit.js +8 -28
- package/inputs/Input/index.js +19 -40
- package/inputs/Input/package.json +6 -0
- package/inputs/Label/Label.stories.js +4 -28
- package/inputs/Label/__stories__/Default.js +9 -29
- package/inputs/Label/index.js +9 -25
- package/inputs/Label/package.json +6 -0
- package/inputs/OtpInput/OtpInput.stories.js +4 -28
- package/inputs/OtpInput/__stories__/Default.js +9 -30
- package/inputs/OtpInput/index.js +28 -53
- package/inputs/OtpInput/package.json +6 -0
- package/inputs/Radio/Radio.stories.js +6 -56
- package/inputs/Radio/__stories__/Conditional.js +8 -28
- package/inputs/Radio/__stories__/Default.js +8 -28
- package/inputs/Radio/__stories__/WithDivider.js +8 -28
- package/inputs/Radio/index.js +24 -45
- package/inputs/Radio/package.json +6 -0
- package/inputs/Select/Select.stories.js +4 -28
- package/inputs/Select/__stories__/Default.js +8 -28
- package/inputs/Select/index.js +12 -29
- package/inputs/Select/package.json +6 -0
- package/inputs/index.js +8 -71
- package/inputs/package.json +6 -0
- package/internal.js +34 -391
- package/package.json +6 -6
- package/registry.js +61 -133
- package/types.js +1 -5
- package/utils.js +12 -26
- package/validators/index.js +26 -54
- package/validators/package.json +6 -0
- package/validators/types.js +1 -5
- package/validators/utils/afm.js +3 -13
- package/validators/utils/file.js +2 -12
- package/validators/utils/iban.js +2 -13
- package/validators/utils/index.js +12 -139
- package/validators/utils/int.js +3 -14
- package/validators/utils/number.js +3 -14
- package/validators/utils/otp.js +3 -14
- package/validators/utils/package.json +6 -0
- package/validators/utils/phone.js +6 -28
- package/validators/utils/postal_code.js +3 -14
- package/validators/utils/text_limit.js +3 -14
- package/validators/utils/uuid4.js +3 -13
- package/validators/validators.spec.js +29 -32
- package/es/Field/FieldBaseContainer.js +0 -43
- package/es/Field/FieldConditional.js +0 -62
- package/es/Field/index.js +0 -76
- package/es/Field/types.js +0 -1
- package/es/FieldArray/FieldArray.stories.js +0 -8
- package/es/FieldArray/__stories__/Default.js +0 -90
- package/es/FieldArray/__stories__/WithExactLength.js +0 -90
- package/es/FieldArray/index.js +0 -65
- package/es/FieldObject/index.js +0 -58
- package/es/Fieldset/FieldsetWithContext.js +0 -41
- package/es/Fieldset/index.js +0 -34
- package/es/Fieldset/types.js +0 -1
- package/es/Form.stories.js +0 -3
- package/es/FormBuilder/FormBuilder.js +0 -160
- package/es/FormBuilder/FormBuilder.stories.js +0 -7
- package/es/FormBuilder/__stories__/Default.js +0 -28
- package/es/FormBuilder/index.js +0 -2
- package/es/FormContext.js +0 -5
- package/es/MultiplicityField/MultiplicityField.stories.js +0 -12
- package/es/MultiplicityField/__stories__/PreviewDisplay.js +0 -83
- package/es/MultiplicityField/__stories__/WithExactLength.js +0 -92
- package/es/MultiplicityField/__stories__/WithMinLength.js +0 -95
- package/es/MultiplicityField/add-objects.js +0 -160
- package/es/MultiplicityField/index.js +0 -114
- package/es/Questions/Questions.js +0 -84
- package/es/Questions/Questions.stories.js +0 -7
- package/es/Questions/QuestionsContext.js +0 -11
- package/es/Questions/Step/ReviewStep.js +0 -53
- package/es/Questions/Step/Step.js +0 -69
- package/es/Questions/Step/StepArrayReview.js +0 -50
- package/es/Questions/Step/StepContext.js +0 -27
- package/es/Questions/Step/StepDescription.js +0 -27
- package/es/Questions/Step/StepForm.js +0 -48
- package/es/Questions/Step/StepQuote.js +0 -11
- package/es/Questions/Step/StepTitle.js +0 -44
- package/es/Questions/Step/index.js +0 -13
- package/es/Questions/Step/types.js +0 -1
- package/es/Questions/__stories__/Default.js +0 -108
- package/es/Questions/index.js +0 -3
- package/es/Questions/index.spec.js +0 -62
- package/es/Questions/types.js +0 -1
- package/es/index.js +0 -3
- package/es/inputs/AutoComplete/AutoComplete.stories.js +0 -7
- package/es/inputs/AutoComplete/__stories__/Default.js +0 -49
- package/es/inputs/AutoComplete/index.js +0 -45
- package/es/inputs/Checkboxes/Checkboxes.stories.js +0 -9
- package/es/inputs/Checkboxes/__stories__/Default.js +0 -42
- package/es/inputs/Checkboxes/__stories__/WithDivider.js +0 -43
- package/es/inputs/Checkboxes/index.js +0 -100
- package/es/inputs/DateInput/DateInput.stories.js +0 -7
- package/es/inputs/DateInput/__stories__/Default.js +0 -25
- package/es/inputs/DateInput/index.js +0 -155
- package/es/inputs/FileInput/FileInput.stories.js +0 -7
- package/es/inputs/FileInput/__stories__/Default.js +0 -22
- package/es/inputs/FileInput/index.js +0 -62
- package/es/inputs/Input/Input.stories.js +0 -15
- package/es/inputs/Input/__stories__/AFM.js +0 -24
- package/es/inputs/Input/__stories__/Boolean.js +0 -25
- package/es/inputs/Input/__stories__/Default.js +0 -25
- package/es/inputs/Input/__stories__/IBAN.js +0 -25
- package/es/inputs/Input/__stories__/Integer.js +0 -33
- package/es/inputs/Input/__stories__/MobilePhone.js +0 -24
- package/es/inputs/Input/__stories__/PhoneNumber.js +0 -24
- package/es/inputs/Input/__stories__/PostalCode.js +0 -27
- package/es/inputs/Input/__stories__/TextWithCharacterLimit.js +0 -31
- package/es/inputs/Input/index.js +0 -75
- package/es/inputs/Label/Label.stories.js +0 -7
- package/es/inputs/Label/__stories__/Default.js +0 -29
- package/es/inputs/Label/index.js +0 -25
- package/es/inputs/OtpInput/OtpInput.stories.js +0 -7
- package/es/inputs/OtpInput/__stories__/Default.js +0 -31
- package/es/inputs/OtpInput/index.js +0 -157
- package/es/inputs/Radio/Radio.stories.js +0 -9
- package/es/inputs/Radio/__stories__/Default.js +0 -47
- package/es/inputs/Radio/__stories__/WithDivider.js +0 -48
- package/es/inputs/Radio/index.js +0 -61
- package/es/inputs/Select/Select.stories.js +0 -7
- package/es/inputs/Select/__stories__/Default.js +0 -53
- package/es/inputs/Select/index.js +0 -32
- package/es/inputs/index.js +0 -8
- package/es/internal.js +0 -34
- package/es/registry.js +0 -136
- package/es/types.js +0 -1
- package/es/validators/types.js +0 -1
- package/es/validators/utils/iban.js +0 -123
- package/es/validators/utils/index.js +0 -102
- package/es/validators/utils/number.js +0 -16
- package/es/validators/utils/otp.js +0 -26
- package/es/validators/utils/phone.js +0 -122
- package/es/validators/utils/text_limit.js +0 -54
- package/es/validators/validators.spec.js +0 -85
- package/esm/Field/FieldBase.js +0 -84
- package/esm/Field/FieldBaseContainer.js +0 -43
- package/esm/Field/FieldConditional.js +0 -62
- package/esm/Field/index.js +0 -76
- package/esm/Field/index.mdx +0 -6
- package/esm/Field/types.js +0 -1
- package/esm/Field/utils.js +0 -162
- package/esm/FieldArray/FieldArray.stories.js +0 -8
- package/esm/FieldArray/FieldArray.stories.playwright.json +0 -353
- package/esm/FieldArray/__stories__/Default.js +0 -90
- package/esm/FieldArray/__stories__/WithExactLength.js +0 -90
- package/esm/FieldArray/index.js +0 -65
- package/esm/FieldObject/index.js +0 -58
- package/esm/Fieldset/FieldsetWithContext.js +0 -41
- package/esm/Fieldset/index.js +0 -34
- package/esm/Fieldset/types.js +0 -1
- package/esm/Form.stories.js +0 -3
- package/esm/FormBuilder/FormBuilder.mdx +0 -256
- package/esm/FormBuilder/FormBuilder.stories.js +0 -7
- package/esm/FormBuilder/FormBuilder.stories.playwright.json +0 -52
- package/esm/FormBuilder/__stories__/Default.js +0 -28
- package/esm/FormBuilder/index.js +0 -2
- package/esm/FormContext.js +0 -5
- package/esm/MultiplicityField/MultiplicityField.mdx +0 -590
- package/esm/MultiplicityField/MultiplicityField.stories.js +0 -12
- package/esm/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
- package/esm/MultiplicityField/__stories__/Default.js +0 -97
- package/esm/MultiplicityField/__stories__/PreviewDisplay.js +0 -83
- package/esm/MultiplicityField/__stories__/WithMaxLength.js +0 -95
- package/esm/MultiplicityField/__stories__/WithMinAndMaxLength.js +0 -96
- package/esm/MultiplicityField/index.js +0 -114
- package/esm/Questions/Questions.js +0 -84
- package/esm/Questions/Questions.stories.js +0 -7
- package/esm/Questions/QuestionsContext.js +0 -11
- package/esm/Questions/Step/ReviewStep.js +0 -53
- package/esm/Questions/Step/Step.js +0 -69
- package/esm/Questions/Step/StepArrayReview.js +0 -50
- package/esm/Questions/Step/StepDescription.js +0 -27
- package/esm/Questions/Step/StepForm.js +0 -48
- package/esm/Questions/Step/StepQuote.js +0 -11
- package/esm/Questions/Step/StepTitle.js +0 -44
- package/esm/Questions/Step/getAddMoreFields.js +0 -22
- package/esm/Questions/Step/index.js +0 -13
- package/esm/Questions/Step/types.js +0 -1
- package/esm/Questions/__snapshots__/index.spec.tsx.snap +0 -596
- package/esm/Questions/__stories__/Default.js +0 -108
- package/esm/Questions/getNextStep.js +0 -23
- package/esm/Questions/index.js +0 -3
- package/esm/Questions/index.mdx +0 -415
- package/esm/Questions/index.spec.js +0 -62
- package/esm/Questions/types.js +0 -1
- package/esm/create-simple-form.mdx +0 -539
- package/esm/index.js +0 -8
- package/esm/index.mdx +0 -51
- package/esm/inputs/AutoComplete/AutoComplete.stories.js +0 -7
- package/esm/inputs/AutoComplete/__stories__/Default.js +0 -49
- package/esm/inputs/AutoComplete/index.js +0 -45
- package/esm/inputs/Checkboxes/Checkboxes.stories.js +0 -9
- package/esm/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
- package/esm/inputs/Checkboxes/__stories__/Conditional.js +0 -95
- package/esm/inputs/Checkboxes/__stories__/Default.js +0 -42
- package/esm/inputs/Checkboxes/__stories__/WithDivider.js +0 -43
- package/esm/inputs/Checkboxes/index.js +0 -100
- package/esm/inputs/Checkboxes/index.mdx +0 -0
- package/esm/inputs/DateInput/DateInput.stories.js +0 -7
- package/esm/inputs/DateInput/DateInput.stories.playwright.json +0 -72
- package/esm/inputs/DateInput/__stories__/Default.js +0 -25
- package/esm/inputs/DateInput/index.js +0 -155
- package/esm/inputs/FileInput/FileInput.stories.js +0 -7
- package/esm/inputs/FileInput/FileInput.stories.playwright.json +0 -75
- package/esm/inputs/FileInput/__stories__/Default.js +0 -22
- package/esm/inputs/FileInput/index.js +0 -62
- package/esm/inputs/Input/Input.stories.js +0 -15
- package/esm/inputs/Input/Input.stories.playwright.json +0 -376
- package/esm/inputs/Input/__stories__/AFM.js +0 -24
- package/esm/inputs/Input/__stories__/Boolean.js +0 -25
- package/esm/inputs/Input/__stories__/Default.js +0 -25
- package/esm/inputs/Input/__stories__/IBAN.js +0 -25
- package/esm/inputs/Input/__stories__/Integer.js +0 -33
- package/esm/inputs/Input/__stories__/MobilePhone.js +0 -24
- package/esm/inputs/Input/__stories__/PhoneNumber.js +0 -24
- package/esm/inputs/Input/__stories__/PostalCode.js +0 -27
- package/esm/inputs/Input/__stories__/TextWithCharacterLimit.js +0 -31
- package/esm/inputs/Input/index.js +0 -75
- package/esm/inputs/Input/index.mdx +0 -8
- package/esm/inputs/Label/Label.stories.js +0 -7
- package/esm/inputs/Label/Label.stories.playwright.json +0 -40
- package/esm/inputs/Label/__stories__/Default.js +0 -29
- package/esm/inputs/Label/index.js +0 -25
- package/esm/inputs/Label/index.mdx +0 -0
- package/esm/inputs/OtpInput/OtpInput.stories.js +0 -7
- package/esm/inputs/OtpInput/__stories__/Default.js +0 -31
- package/esm/inputs/OtpInput/index.js +0 -157
- package/esm/inputs/Radio/Radio.stories.js +0 -9
- package/esm/inputs/Radio/Radio.stories.playwright.json +0 -73
- package/esm/inputs/Radio/__stories__/Conditional.js +0 -95
- package/esm/inputs/Radio/__stories__/Default.js +0 -47
- package/esm/inputs/Radio/__stories__/WithDivider.js +0 -48
- package/esm/inputs/Radio/index.js +0 -61
- package/esm/inputs/Radio/index.mdx +0 -0
- package/esm/inputs/Select/Select.stories.js +0 -7
- package/esm/inputs/Select/Select.stories.playwright.json +0 -22
- package/esm/inputs/Select/__stories__/Default.js +0 -53
- package/esm/inputs/Select/index.js +0 -32
- package/esm/inputs/index.js +0 -8
- package/esm/installation.mdx +0 -68
- package/esm/internal.js +0 -34
- package/esm/registry.js +0 -136
- package/esm/types.js +0 -1
- package/esm/utils.js +0 -99
- package/esm/validators/index.js +0 -186
- package/esm/validators/types.js +0 -1
- package/esm/validators/utils/afm.js +0 -35
- package/esm/validators/utils/file.js +0 -52
- package/esm/validators/utils/index.js +0 -102
- package/esm/validators/utils/int.js +0 -20
- package/esm/validators/utils/number.js +0 -16
- package/esm/validators/utils/postal_code.js +0 -29
- package/esm/validators/utils/uuid4.js +0 -20
- package/esm/validators/validators.spec.js +0 -85
- /package/{es → cjs}/Field/index.mdx +0 -0
- /package/{es → cjs}/FieldArray/FieldArray.stories.playwright.json +0 -0
- /package/{es → cjs}/FormBuilder/FormBuilder.mdx +0 -0
- /package/{es → cjs}/FormBuilder/FormBuilder.stories.playwright.json +0 -0
- /package/{es → cjs}/MultiplicityField/MultiplicityField.mdx +0 -0
- /package/{es → cjs}/MultiplicityField/MultiplicityField.stories.playwright.json +0 -0
- /package/{es → cjs}/Questions/__snapshots__/index.spec.tsx.snap +0 -0
- /package/{es → cjs}/Questions/index.mdx +0 -0
- /package/{es → cjs}/create-simple-form.mdx +0 -0
- /package/{es → cjs}/index.mdx +0 -0
- /package/{es → cjs}/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -0
- /package/{es → cjs}/inputs/Checkboxes/index.mdx +0 -0
- /package/{es → cjs}/inputs/DateInput/DateInput.stories.playwright.json +0 -0
- /package/{es → cjs}/inputs/FileInput/FileInput.stories.playwright.json +0 -0
- /package/{es → cjs}/inputs/Input/Input.stories.playwright.json +0 -0
- /package/{es → cjs}/inputs/Input/index.mdx +0 -0
- /package/{es → cjs}/inputs/Label/Label.stories.playwright.json +0 -0
- /package/{es → cjs}/inputs/Label/index.mdx +0 -0
- /package/{es → cjs}/inputs/Radio/Radio.stories.playwright.json +0 -0
- /package/{es → cjs}/inputs/Radio/index.mdx +0 -0
- /package/{es → cjs}/inputs/Select/Select.stories.playwright.json +0 -0
- /package/{es → cjs}/installation.mdx +0 -0
package/esm/utils.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
-
|
|
5
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
6
|
-
|
|
7
|
-
import { validateFieldsNatively } from '@hookform/resolvers';
|
|
8
|
-
import { appendErrors } from 'react-hook-form';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Why `path!` ? because it could be `undefined` in some case
|
|
12
|
-
* https://github.com/jquense/yup#validationerrorerrors-string--arraystring-value-any-path-string
|
|
13
|
-
*/
|
|
14
|
-
var parseErrorSchema = function parseErrorSchema(error, validateAllFieldCriteria) {
|
|
15
|
-
return (error.inner || []).reduce(function (previous, error) {
|
|
16
|
-
var _error$path;
|
|
17
|
-
|
|
18
|
-
error.path = (_error$path = error.path) === null || _error$path === void 0 ? void 0 : _error$path.replace(/\[([0-9]+)\]/g, '.$1');
|
|
19
|
-
|
|
20
|
-
if (!previous[error.path]) {
|
|
21
|
-
previous[error.path] = {
|
|
22
|
-
message: error.message,
|
|
23
|
-
type: error.type
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (validateAllFieldCriteria) {
|
|
28
|
-
var types = previous[error.path].types;
|
|
29
|
-
var messages = types && types[error.type];
|
|
30
|
-
previous[error.path] = appendErrors(error.path, validateAllFieldCriteria, previous, error.type, messages ? [].concat(messages, error.message) : error.message);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return previous;
|
|
34
|
-
}, {});
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export var yupResolver = function yupResolver(schema) {
|
|
38
|
-
var schemaOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
39
|
-
var resolverOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
40
|
-
return /*#__PURE__*/function () {
|
|
41
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(values, context, options) {
|
|
42
|
-
var result, parsed;
|
|
43
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
44
|
-
while (1) {
|
|
45
|
-
switch (_context.prev = _context.next) {
|
|
46
|
-
case 0:
|
|
47
|
-
_context.prev = 0;
|
|
48
|
-
|
|
49
|
-
if (schemaOptions.context && process.env.NODE_ENV === 'development') {
|
|
50
|
-
// eslint-disable-next-line no-console
|
|
51
|
-
console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead");
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
_context.next = 4;
|
|
55
|
-
return schema[resolverOptions.mode === 'sync' ? 'validateSync' : 'validate'](values, _extends({
|
|
56
|
-
abortEarly: false
|
|
57
|
-
}, schemaOptions, {
|
|
58
|
-
context: context
|
|
59
|
-
}));
|
|
60
|
-
|
|
61
|
-
case 4:
|
|
62
|
-
result = _context.sent;
|
|
63
|
-
options.shouldUseNativeValidation && validateFieldsNatively({}, options);
|
|
64
|
-
return _context.abrupt("return", {
|
|
65
|
-
values: resolverOptions.rawValues ? values : result,
|
|
66
|
-
errors: {}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
case 9:
|
|
70
|
-
_context.prev = 9;
|
|
71
|
-
_context.t0 = _context["catch"](0);
|
|
72
|
-
|
|
73
|
-
if (_context.t0.inner) {
|
|
74
|
-
_context.next = 13;
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
throw _context.t0;
|
|
79
|
-
|
|
80
|
-
case 13:
|
|
81
|
-
parsed = parseErrorSchema(_context.t0, !options.shouldUseNativeValidation && options.criteriaMode === 'all');
|
|
82
|
-
return _context.abrupt("return", {
|
|
83
|
-
values: {},
|
|
84
|
-
errors: parsed
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
case 15:
|
|
88
|
-
case "end":
|
|
89
|
-
return _context.stop();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}, _callee, null, [[0, 9]]);
|
|
93
|
-
}));
|
|
94
|
-
|
|
95
|
-
return function (_x, _x2, _x3) {
|
|
96
|
-
return _ref.apply(this, arguments);
|
|
97
|
-
};
|
|
98
|
-
}();
|
|
99
|
-
};
|
package/esm/validators/index.js
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
-
import { useMemo } from 'react';
|
|
3
|
-
import dayjs from 'dayjs';
|
|
4
|
-
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
5
|
-
import * as yup from 'yup';
|
|
6
|
-
import { getYupObjectShape, AFM_VALIDATOR, FILE_MAX_SIZE_VALIDATOR, IBAN_VALIDATOR, OTP_VALIDATOR, MOBILE_PHONE_VALIDATOR, PHONE_NUMBER_VALIDATOR, TEXT_LIMIT_VALIDATOR, POSTALCODE_VALIDATOR, UUID4_VALIDATOR } from '@digigov/form/validators/utils';
|
|
7
|
-
import { INT_VALIDATOR } from '@digigov/form/validators/utils/int';
|
|
8
|
-
import { NUMBER_VALIDATOR } from '@digigov/form/validators/utils/number';
|
|
9
|
-
dayjs.extend(customParseFormat);
|
|
10
|
-
var VALID_DATE_FORMATS = ['DD/MM/YYYY'];
|
|
11
|
-
var DATE_CACHE = {};
|
|
12
|
-
|
|
13
|
-
var getDate = function getDate(v) {
|
|
14
|
-
return DATE_CACHE[v] ? DATE_CACHE[v] : dayjs(v, VALID_DATE_FORMATS, true);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export var getYUPTypeMap = function getYUPTypeMap() {
|
|
18
|
-
var yupTypeMap = {
|
|
19
|
-
file: function file(field) {
|
|
20
|
-
return yup.mixed().transform(function (value) {
|
|
21
|
-
if (!value.length) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return value;
|
|
26
|
-
}).nullable().test(FILE_MAX_SIZE_VALIDATOR(field));
|
|
27
|
-
},
|
|
28
|
-
string: yup.string,
|
|
29
|
-
"boolean": yup["boolean"],
|
|
30
|
-
object: function object(field) {
|
|
31
|
-
return getYupObjectShape(field.extra.fields, yupTypeMap);
|
|
32
|
-
},
|
|
33
|
-
array: function array(field) {
|
|
34
|
-
if (_typeof(field.extra.of) === 'object') {
|
|
35
|
-
// else if the field is an object then it is a scalar type
|
|
36
|
-
// eg. number, string etc.
|
|
37
|
-
var arrayValidator = yup.array().of(yupTypeMap[field.extra.of.type](field.extra.of)).required(field.required);
|
|
38
|
-
if (field.extra.length) arrayValidator = arrayValidator.length(field.extra.length, {
|
|
39
|
-
key: 'form.error.array.length',
|
|
40
|
-
context: {
|
|
41
|
-
length: field.extra.length
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
if (field.extra.min) arrayValidator = arrayValidator.min(field.extra.min, {
|
|
45
|
-
key: 'form.error.array.min',
|
|
46
|
-
context: {
|
|
47
|
-
min: field.extra.min
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
if (field.extra.max) arrayValidator = arrayValidator.max(field.extra.max, {
|
|
51
|
-
key: 'form.error.array.max',
|
|
52
|
-
context: {
|
|
53
|
-
max: field.extra.max
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
return arrayValidator;
|
|
57
|
-
} else if (typeof field.extra.of === 'string') {
|
|
58
|
-
return yup.array().of(yupTypeMap[field.extra.of]());
|
|
59
|
-
} else {
|
|
60
|
-
// in any other case it will be string
|
|
61
|
-
return yup.array().of(yup.string());
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
"int": function int() {
|
|
65
|
-
return yup.mixed().transform(function (_, val) {
|
|
66
|
-
return val !== '' ? Number(val) : null;
|
|
67
|
-
}).test(NUMBER_VALIDATOR()).test(INT_VALIDATOR());
|
|
68
|
-
},
|
|
69
|
-
email: function email() {
|
|
70
|
-
return yup.string().email('form.error.email');
|
|
71
|
-
},
|
|
72
|
-
afm: function afm() {
|
|
73
|
-
return yup.string().test(AFM_VALIDATOR);
|
|
74
|
-
},
|
|
75
|
-
uuid4: function uuid4() {
|
|
76
|
-
return yup.string().test(UUID4_VALIDATOR);
|
|
77
|
-
},
|
|
78
|
-
iban: function iban(field) {
|
|
79
|
-
return yup.string().test(IBAN_VALIDATOR(field));
|
|
80
|
-
},
|
|
81
|
-
otp: function otp(field) {
|
|
82
|
-
return yup.string().test(OTP_VALIDATOR(field));
|
|
83
|
-
},
|
|
84
|
-
text: function text(field) {
|
|
85
|
-
var _field$extra, _field$extra$limit, _field$extra2, _field$extra2$limit;
|
|
86
|
-
|
|
87
|
-
if (field !== null && field !== void 0 && (_field$extra = field.extra) !== null && _field$extra !== void 0 && (_field$extra$limit = _field$extra.limit) !== null && _field$extra$limit !== void 0 && _field$extra$limit.max || !!(field !== null && field !== void 0 && (_field$extra2 = field.extra) !== null && _field$extra2 !== void 0 && (_field$extra2$limit = _field$extra2.limit) !== null && _field$extra2$limit !== void 0 && _field$extra2$limit.min)) {
|
|
88
|
-
return yup.string().test(TEXT_LIMIT_VALIDATOR(field));
|
|
89
|
-
} else {
|
|
90
|
-
return yup.string();
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
postal_code: function postal_code(field) {
|
|
94
|
-
return yup.string().test(POSTALCODE_VALIDATOR(field));
|
|
95
|
-
},
|
|
96
|
-
mobile_phone: function mobile_phone() {
|
|
97
|
-
return yup.string().test(MOBILE_PHONE_VALIDATOR);
|
|
98
|
-
},
|
|
99
|
-
phone_number: function phone_number(field) {
|
|
100
|
-
return yup.string().test(PHONE_NUMBER_VALIDATOR(field));
|
|
101
|
-
},
|
|
102
|
-
'choice:multiple': function choiceMultiple() {
|
|
103
|
-
return yup.array().of(yup.string()).nullable();
|
|
104
|
-
},
|
|
105
|
-
'choice:single': function choiceSingle() {
|
|
106
|
-
return yup.string().nullable();
|
|
107
|
-
},
|
|
108
|
-
date: function date(field) {
|
|
109
|
-
var simpleDate = yup.string().nullable(true).test('date', 'form.error.date.invalid', function (value) {
|
|
110
|
-
if (!value) return true;
|
|
111
|
-
var date = getDate(value);
|
|
112
|
-
return date.isValid();
|
|
113
|
-
});
|
|
114
|
-
var params = field.extra || {};
|
|
115
|
-
|
|
116
|
-
if (params.max) {
|
|
117
|
-
var maxDate;
|
|
118
|
-
|
|
119
|
-
if (params.max === 'now') {
|
|
120
|
-
var today = new Date();
|
|
121
|
-
maxDate = new Date(today);
|
|
122
|
-
} else {
|
|
123
|
-
maxDate = getDate(params.max).toDate();
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
var maxNextDate = new Date(maxDate);
|
|
127
|
-
maxNextDate.setDate(maxDate.getDate() + 1);
|
|
128
|
-
simpleDate = simpleDate.test({
|
|
129
|
-
name: 'earlier-than',
|
|
130
|
-
message: {
|
|
131
|
-
key: 'form.error.date.earlier_than',
|
|
132
|
-
context: {
|
|
133
|
-
maxDate: maxNextDate.toLocaleDateString()
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
test: function test(value) {
|
|
137
|
-
if (!value) return true;
|
|
138
|
-
var date = getDate(value);
|
|
139
|
-
var isValid = +date.toDate() < +maxDate;
|
|
140
|
-
return isValid;
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (params.min) {
|
|
146
|
-
var minDate;
|
|
147
|
-
|
|
148
|
-
if (params.min === 'now') {
|
|
149
|
-
var _today = new Date();
|
|
150
|
-
|
|
151
|
-
minDate = new Date(_today);
|
|
152
|
-
} else {
|
|
153
|
-
minDate = getDate(params.min).toDate();
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
var minPreviousDate = new Date(minDate);
|
|
157
|
-
minPreviousDate.setDate(minDate.getDate() - 1);
|
|
158
|
-
simpleDate = simpleDate.test({
|
|
159
|
-
name: 'later-than',
|
|
160
|
-
message: {
|
|
161
|
-
key: 'form.error.date.later_than',
|
|
162
|
-
context: {
|
|
163
|
-
minDate: minPreviousDate.toLocaleDateString()
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
test: function test(value) {
|
|
167
|
-
if (!value) return true;
|
|
168
|
-
var date = getDate(value);
|
|
169
|
-
var isValid = +date.toDate() > +minDate;
|
|
170
|
-
return isValid;
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return simpleDate;
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
return yupTypeMap;
|
|
179
|
-
};
|
|
180
|
-
// Create a yup validation schema from given fields input
|
|
181
|
-
export function useValidationSchema(fields, validatorRegistry) {
|
|
182
|
-
return useMemo(function () {
|
|
183
|
-
var yupTypeMap = getYUPTypeMap();
|
|
184
|
-
return getYupObjectShape(fields, yupTypeMap, validatorRegistry);
|
|
185
|
-
}, []);
|
|
186
|
-
}
|
package/esm/validators/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export function validateAFM(afm) {
|
|
2
|
-
if (afm.length !== 9) {
|
|
3
|
-
// "afm should be 9 digits"
|
|
4
|
-
return false;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
if (!/^\d+$/.test(afm)) {
|
|
8
|
-
// "This is not a number"
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if (afm === '0'.repeat(9)) {
|
|
13
|
-
// "This is zero number (000000000)"
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
var sum = afm.substring(0, 8).split('').reduce(function (s, v, i) {
|
|
18
|
-
return s + (parseInt(v) << 8 - i);
|
|
19
|
-
}, 0);
|
|
20
|
-
var calc = sum % 11;
|
|
21
|
-
var d9 = parseInt(afm[8]);
|
|
22
|
-
var valid = calc % 10 === d9;
|
|
23
|
-
return valid;
|
|
24
|
-
}
|
|
25
|
-
export var AFM_VALIDATOR = {
|
|
26
|
-
name: 'afm-validator',
|
|
27
|
-
message: 'form.error.afm',
|
|
28
|
-
test: function test(value) {
|
|
29
|
-
if (value) {
|
|
30
|
-
return validateAFM(value);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
2
|
-
|
|
3
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
-
|
|
5
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
6
|
-
|
|
7
|
-
var DEFAULT_FILE_MAX_SIZE = 10000000;
|
|
8
|
-
export var FILE_MAX_SIZE_VALIDATOR = function FILE_MAX_SIZE_VALIDATOR(field) {
|
|
9
|
-
return {
|
|
10
|
-
name: 'file-max-size-validator',
|
|
11
|
-
message: 'form.error.file_size',
|
|
12
|
-
test: function test(value) {
|
|
13
|
-
if (field.extra && field.extra.maxSize && value) {
|
|
14
|
-
var _iterator = _createForOfIteratorHelper(value),
|
|
15
|
-
_step;
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
19
|
-
var file = _step.value;
|
|
20
|
-
|
|
21
|
-
if (file.size >= field.extra.maxSize) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
} catch (err) {
|
|
26
|
-
_iterator.e(err);
|
|
27
|
-
} finally {
|
|
28
|
-
_iterator.f();
|
|
29
|
-
}
|
|
30
|
-
} else if (value) {
|
|
31
|
-
var _iterator2 = _createForOfIteratorHelper(value),
|
|
32
|
-
_step2;
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
36
|
-
var _file = _step2.value;
|
|
37
|
-
|
|
38
|
-
if (_file.size >= DEFAULT_FILE_MAX_SIZE) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
} catch (err) {
|
|
43
|
-
_iterator2.e(err);
|
|
44
|
-
} finally {
|
|
45
|
-
_iterator2.f();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import * as yup from 'yup';
|
|
2
|
-
export * from '@digigov/form/validators/utils/afm';
|
|
3
|
-
export * from '@digigov/form/validators/utils/file';
|
|
4
|
-
export * from '@digigov/form/validators/utils/iban';
|
|
5
|
-
export * from '@digigov/form/validators/utils/otp';
|
|
6
|
-
export * from '@digigov/form/validators/utils/phone';
|
|
7
|
-
export * from '@digigov/form/validators/utils/postal_code';
|
|
8
|
-
export * from '@digigov/form/validators/utils/uuid4';
|
|
9
|
-
export * from '@digigov/form/validators/utils/text_limit';
|
|
10
|
-
export function getYupField(field, yupTypeMap) {
|
|
11
|
-
var yupField = yupTypeMap[(field === null || field === void 0 ? void 0 : field.type) || 'string'] || yupTypeMap['string'];
|
|
12
|
-
return yupField(field);
|
|
13
|
-
}
|
|
14
|
-
export function computeShape(fields, yupTypeMap, validatorRegistry) {
|
|
15
|
-
var fieldSchemas = {};
|
|
16
|
-
var objectFields = {};
|
|
17
|
-
fields.forEach(function (field) {
|
|
18
|
-
var yupField = getYupField(field, yupTypeMap);
|
|
19
|
-
|
|
20
|
-
if (field.condition) {
|
|
21
|
-
var _loop = function _loop(key) {
|
|
22
|
-
var then = void 0,
|
|
23
|
-
otherwise = void 0;
|
|
24
|
-
|
|
25
|
-
if (field.condition[key].then) {
|
|
26
|
-
var _field$condition$key$, _field$condition$key$2;
|
|
27
|
-
|
|
28
|
-
if (((_field$condition$key$ = field.condition[key].then) === null || _field$condition$key$ === void 0 ? void 0 : _field$condition$key$.required) === false) {
|
|
29
|
-
then = yupField.nullable();
|
|
30
|
-
} else if (((_field$condition$key$2 = field.condition[key].then) === null || _field$condition$key$2 === void 0 ? void 0 : _field$condition$key$2.required) === true) {
|
|
31
|
-
then = yupField.nullable().required('form.error.required');
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (field.condition[key]["else"]) {
|
|
36
|
-
var _field$condition$key$3, _field$condition$key$4;
|
|
37
|
-
|
|
38
|
-
if (((_field$condition$key$3 = field.condition[key]["else"]) === null || _field$condition$key$3 === void 0 ? void 0 : _field$condition$key$3.required) === false) {
|
|
39
|
-
otherwise = yupField.nullable();
|
|
40
|
-
} else if (((_field$condition$key$4 = field.condition[key]["else"]) === null || _field$condition$key$4 === void 0 ? void 0 : _field$condition$key$4.required) === true) {
|
|
41
|
-
otherwise = yupField.nullable().required('form.error.required');
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (then || otherwise) {
|
|
46
|
-
yupField = yupField.when(key, {
|
|
47
|
-
is: function is(val) {
|
|
48
|
-
//@ts-ignore
|
|
49
|
-
var is = field.condition[key].is;
|
|
50
|
-
|
|
51
|
-
if (is === val || Array.isArray(val) && val.includes(is)) {
|
|
52
|
-
return true;
|
|
53
|
-
} else {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
then: then,
|
|
58
|
-
otherwise: otherwise
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
for (var key in field.condition) {
|
|
64
|
-
_loop(key);
|
|
65
|
-
}
|
|
66
|
-
} else if (field.required) {
|
|
67
|
-
yupField = yupField.nullable().required('form.error.required');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (validatorRegistry && field.type && validatorRegistry[field.type]) {
|
|
71
|
-
validatorRegistry[field.type].forEach(function (validator) {
|
|
72
|
-
yupField = yupField.test(validator);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (field.validators) {
|
|
77
|
-
field.validators.forEach(function (validator) {
|
|
78
|
-
yupField = yupField.test(validator);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
fieldSchemas[field.key] = yupField;
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
for (var objectKey in objectFields) {
|
|
86
|
-
fieldSchemas[objectKey] = getYupObjectShape(objectFields[objectKey], yupTypeMap, validatorRegistry);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return fieldSchemas;
|
|
90
|
-
}
|
|
91
|
-
export function getYupObjectShape( // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
|
-
fields, yupTypeMap, validatorRegistry) {
|
|
93
|
-
if (!fields.current) {
|
|
94
|
-
var fieldSchemas = computeShape(fields, yupTypeMap, validatorRegistry);
|
|
95
|
-
return yup.object().shape(fieldSchemas);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return yup.lazy(function () {
|
|
99
|
-
var fieldSchemas = computeShape(Object.values(fields.current), yupTypeMap, validatorRegistry);
|
|
100
|
-
return yup.object().shape(fieldSchemas);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export function validateIntNumber(number) {
|
|
2
|
-
if (number === undefined) {
|
|
3
|
-
return false;
|
|
4
|
-
} else {
|
|
5
|
-
return Number.isInteger(number) && Number(number) > 0;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
export var INT_VALIDATOR = function INT_VALIDATOR() {
|
|
9
|
-
return {
|
|
10
|
-
name: 'int-validator',
|
|
11
|
-
message: 'form.error.positive_integer_number',
|
|
12
|
-
test: function test(value) {
|
|
13
|
-
if (value === null) {
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return validateIntNumber(value);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export function validateNumber(number) {
|
|
2
|
-
return !Number.isNaN(number);
|
|
3
|
-
}
|
|
4
|
-
export var NUMBER_VALIDATOR = function NUMBER_VALIDATOR() {
|
|
5
|
-
return {
|
|
6
|
-
name: 'number-validator',
|
|
7
|
-
message: 'form.error.number',
|
|
8
|
-
test: function test(value) {
|
|
9
|
-
if (value === null) {
|
|
10
|
-
return true;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return validateNumber(value);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
var CODE_REGEX = /^[12345678][0-9]{4}$/;
|
|
2
|
-
export function validatePostalCode(number, countries) {
|
|
3
|
-
if (!countries) {
|
|
4
|
-
return false;
|
|
5
|
-
} else {
|
|
6
|
-
if (countries.length === 1 && countries[0].toUpperCase() === 'GR') {
|
|
7
|
-
// Greek postal code must be 5 digits long and shouldn't start with 0 or 9.
|
|
8
|
-
return CODE_REGEX.test(number);
|
|
9
|
-
} else {
|
|
10
|
-
return true;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export var POSTALCODE_VALIDATOR = function POSTALCODE_VALIDATOR(field) {
|
|
15
|
-
var _field$extra;
|
|
16
|
-
|
|
17
|
-
var countryCode = field === null || field === void 0 ? void 0 : (_field$extra = field.extra) === null || _field$extra === void 0 ? void 0 : _field$extra.countries;
|
|
18
|
-
return {
|
|
19
|
-
name: 'postal-code-validator',
|
|
20
|
-
message: 'form.error.postalCode',
|
|
21
|
-
test: function test(value) {
|
|
22
|
-
if (!value) {
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return validatePostalCode(value, countryCode);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
var UUID4_PATTERN = /^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i;
|
|
2
|
-
export function validateUUID4(uuid4) {
|
|
3
|
-
if (uuid4.length !== 36) {
|
|
4
|
-
// This uuid4 should be 36 characters long
|
|
5
|
-
return false;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return UUID4_PATTERN.test(uuid4);
|
|
9
|
-
}
|
|
10
|
-
export var UUID4_VALIDATOR = {
|
|
11
|
-
name: 'uuid4-validator',
|
|
12
|
-
message: 'form.error.uuid4',
|
|
13
|
-
test: function test(value) {
|
|
14
|
-
if (value) {
|
|
15
|
-
return validateUUID4(value);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
};
|