@digigov/form 2.0.0-36b707c1 → 2.0.0-44e7106a
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/{Form.stories → 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 +36 -23
- package/Field/FieldBase.js.map +2 -2
- package/Field/FieldBaseContainer/index.js +8 -5
- package/Field/FieldBaseContainer.js.map +2 -2
- package/Field/FieldConditional/index.js +4 -0
- package/Field/FieldConditional.js.map +2 -2
- package/Field/index.js +15 -4
- package/Field/index.js.map +2 -2
- package/Field/types.d.ts +21 -10
- package/Field/utils/index.js +7 -0
- package/Field/utils/index.js.map +2 -2
- package/Field/utils/useField/index.js +14 -1
- package/Field/utils/useField.js.map +2 -2
- package/FieldArray/FieldArray.stories.d.ts +1 -0
- package/FieldArray/FormDialog/index.js +397 -0
- package/{Questions/Questions.stories → FieldArray/FormDialog}/package.json +1 -1
- package/FieldArray/FormDialog.d.ts +66 -0
- package/FieldArray/FormDialog.js.map +7 -0
- package/FieldArray/__stories__/Default.d.ts +1 -1
- package/FieldArray/__stories__/WithExactLength.d.ts +1 -1
- package/FieldArray/__stories__/WithModal.d.ts +2 -0
- package/FieldArray/index.d.ts +6 -0
- package/FieldArray/index.js +67 -28
- package/FieldArray/index.js.map +2 -2
- package/FieldObject/index.d.ts +5 -0
- package/FieldObject/index.js +32 -17
- package/FieldObject/index.js.map +2 -2
- package/Fieldset/index.d.ts +1 -1
- package/Fieldset/index.js +5 -5
- package/Fieldset/index.js.map +2 -2
- package/Fieldset/types.d.ts +2 -2
- package/FormBuilder/FormBuilder.stories.d.ts +4 -0
- package/FormBuilder/__stories__/AutoErrorGrouping.d.ts +3 -0
- package/FormBuilder/__stories__/Default.d.ts +1 -1
- package/FormBuilder/__stories__/ErrorGrouping.d.ts +3 -0
- package/FormBuilder/index.js +95 -8
- package/FormBuilder/index.js.map +2 -2
- package/FormBuilder/interaction.test.d.ts +1 -0
- package/FormContext.js.map +2 -2
- package/MultiplicityField/MultiplicityField.stories.d.ts +2 -0
- package/MultiplicityField/__stories__/Default.d.ts +1 -1
- package/MultiplicityField/__stories__/PreviewDisplay.d.ts +1 -1
- package/MultiplicityField/__stories__/WithExactLength.d.ts +1 -1
- package/MultiplicityField/__stories__/WithMaxLength.d.ts +1 -1
- package/MultiplicityField/__stories__/WithMinAndMaxLength.d.ts +1 -1
- package/MultiplicityField/__stories__/WithMinLength.d.ts +1 -1
- package/MultiplicityField/add-objects/index.js +10 -6
- package/MultiplicityField/add-objects.js.map +2 -2
- package/MultiplicityField/index.js +17 -11
- package/MultiplicityField/index.js.map +2 -2
- package/MultiplicityField/types.d.ts +2 -2
- package/Questions/Questions/index.js +5 -4
- package/Questions/Questions.js.map +2 -2
- package/Questions/Questions.stories.d.ts +2 -0
- package/Questions/Step/StepArrayReview.js.map +2 -2
- package/Questions/Step/StepTitle/index.js +4 -3
- package/Questions/Step/StepTitle.d.ts +1 -1
- package/Questions/Step/StepTitle.js.map +2 -2
- package/Questions/__stories__/Default.d.ts +1 -1
- package/cjs/Field/ErrorGroup/index.js +82 -0
- package/cjs/Field/ErrorGroup.js.map +7 -0
- package/cjs/Field/FieldBase/index.js +35 -22
- package/cjs/Field/FieldBase.js.map +2 -2
- package/cjs/Field/FieldBaseContainer/index.js +7 -4
- package/cjs/Field/FieldBaseContainer.js.map +3 -3
- package/cjs/Field/FieldConditional/index.js +4 -0
- package/cjs/Field/FieldConditional.js.map +2 -2
- package/cjs/Field/index.js +15 -4
- package/cjs/Field/index.js.map +2 -2
- package/cjs/Field/types.js.map +1 -1
- package/cjs/Field/utils/index.js +7 -0
- package/cjs/Field/utils/index.js.map +3 -3
- package/cjs/Field/utils/useField/index.js +14 -1
- package/cjs/Field/utils/useField.js.map +2 -2
- package/cjs/FieldArray/FormDialog/index.js +416 -0
- package/cjs/FieldArray/FormDialog.js.map +7 -0
- package/cjs/FieldArray/index.js +66 -27
- package/cjs/FieldArray/index.js.map +3 -3
- package/cjs/FieldObject/index.js +32 -17
- package/cjs/FieldObject/index.js.map +3 -3
- package/cjs/Fieldset/index.js +10 -10
- package/cjs/Fieldset/index.js.map +3 -3
- package/cjs/Fieldset/types.js.map +1 -1
- package/cjs/FormBuilder/index.js +94 -7
- package/cjs/FormBuilder/index.js.map +3 -3
- package/cjs/FormContext/index.js +2 -2
- package/cjs/FormContext.js.map +3 -3
- package/cjs/MultiplicityField/add-objects/index.js +14 -10
- package/cjs/MultiplicityField/add-objects.js.map +3 -3
- package/cjs/MultiplicityField/index.js +16 -15
- package/cjs/MultiplicityField/index.js.map +3 -3
- package/cjs/MultiplicityField/types.js.map +1 -1
- package/cjs/Questions/Questions/index.js +5 -4
- package/cjs/Questions/Questions.js.map +2 -2
- package/cjs/Questions/Step/StepArrayReview.js.map +2 -2
- package/cjs/Questions/Step/StepTitle/index.js +5 -5
- package/cjs/Questions/Step/StepTitle.js.map +3 -3
- package/cjs/inputs/AutoCompleteInput/index.js +8 -7
- package/cjs/inputs/AutoCompleteInput/index.js.map +3 -3
- package/cjs/inputs/Checkboxes/index.js +8 -8
- package/cjs/inputs/Checkboxes/index.js.map +3 -3
- package/cjs/inputs/DateInput/index.js +30 -16
- package/cjs/inputs/DateInput/index.js.map +3 -3
- package/cjs/inputs/DateTimeInput/index.js +224 -0
- package/cjs/inputs/DateTimeInput/index.js.map +7 -0
- package/cjs/inputs/FileInput/index.js +55 -36
- package/cjs/inputs/FileInput/index.js.map +3 -3
- package/cjs/inputs/ImageInput/index.js +15 -10
- package/cjs/inputs/ImageInput/index.js.map +3 -3
- package/cjs/inputs/Input/index.js +11 -4
- package/cjs/inputs/Input/index.js.map +2 -2
- package/cjs/inputs/Label/index.js +3 -3
- package/cjs/inputs/Label/index.js.map +3 -3
- package/cjs/inputs/OtpInput/index.js +1 -0
- package/cjs/inputs/OtpInput/index.js.map +2 -2
- package/cjs/inputs/Radio/index.js +12 -13
- package/cjs/inputs/Radio/index.js.map +3 -3
- package/cjs/inputs/Select/index.js +11 -5
- package/cjs/inputs/Select/index.js.map +3 -3
- package/cjs/inputs/inputsScenarios/index.js +6 -12
- package/cjs/inputs/inputsScenarios.js.map +2 -2
- package/cjs/lazy/index.js +48 -34
- package/cjs/lazy.js.map +3 -3
- package/cjs/locales/el.js.map +1 -1
- package/cjs/registry/index.js +70 -60
- package/cjs/registry.js.map +3 -3
- package/cjs/types.js.map +1 -1
- package/cjs/utils/index.js +22 -7
- package/cjs/utils.js.map +2 -2
- package/cjs/validators/index.js +54 -84
- package/cjs/validators/index.js.map +3 -3
- 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 +138 -0
- package/cjs/validators/utils/date.js.map +7 -0
- package/cjs/validators/utils/datetime/index.js +151 -0
- package/cjs/validators/utils/datetime.js.map +7 -0
- package/cjs/validators/utils/file/index.js +30 -17
- package/cjs/validators/utils/file.js.map +2 -2
- package/cjs/validators/utils/index.js +10 -2
- package/cjs/validators/utils/index.js.map +2 -2
- package/cjs/validators/utils/int/index.js +1 -1
- package/cjs/validators/utils/int.js.map +2 -2
- package/cjs/validators/utils/number/index.js +1 -1
- package/cjs/validators/utils/number.js.map +2 -2
- package/cjs/validators/utils/phone.js.map +2 -2
- package/cjs/validators/utils/postal_code.js.map +1 -1
- package/cjs/validators/utils/uuid4.js.map +2 -2
- package/index.js +1 -1
- package/inputs/AutoCompleteInput/AutoComplete.stories.d.ts +2 -0
- package/inputs/AutoCompleteInput/__stories__/Default.d.ts +1 -1
- package/inputs/AutoCompleteInput/__stories__/Multiple.d.ts +1 -1
- package/inputs/AutoCompleteInput/index.d.ts +1 -1
- package/inputs/AutoCompleteInput/index.js +10 -7
- package/inputs/AutoCompleteInput/index.js.map +2 -2
- package/inputs/Checkboxes/Checkboxes.stories.d.ts +2 -0
- package/inputs/Checkboxes/__stories__/Conditional.d.ts +1 -1
- package/inputs/Checkboxes/__stories__/Default.d.ts +1 -1
- package/inputs/Checkboxes/__stories__/WithDivider.d.ts +1 -1
- package/inputs/Checkboxes/index.d.ts +1 -1
- package/inputs/Checkboxes/index.js +9 -5
- package/inputs/Checkboxes/index.js.map +2 -2
- package/inputs/DateInput/DateInput.stories.d.ts +2 -0
- package/inputs/DateInput/__stories__/Default.d.ts +1 -1
- package/inputs/DateInput/index.d.ts +1 -2
- package/inputs/DateInput/index.js +32 -15
- package/inputs/DateInput/index.js.map +2 -2
- package/inputs/DateTimeInput/DateTimeInput.stories.d.ts +9 -0
- package/inputs/DateTimeInput/__stories__/Default.d.ts +3 -0
- package/inputs/DateTimeInput/index.d.ts +13 -0
- package/inputs/DateTimeInput/index.js +194 -0
- package/inputs/DateTimeInput/index.js.map +7 -0
- package/inputs/DateTimeInput/index.test.d.ts +1 -0
- package/inputs/{Input/Input.stories → DateTimeInput}/package.json +1 -1
- package/inputs/FileInput/FileInput.stories.d.ts +3 -0
- package/inputs/FileInput/__stories__/Default.d.ts +1 -1
- package/inputs/FileInput/__stories__/WithBorderAndLink.d.ts +3 -0
- package/inputs/FileInput/index.d.ts +12 -0
- package/inputs/FileInput/index.js +59 -37
- package/inputs/FileInput/index.js.map +2 -2
- package/inputs/ImageInput/ImageInput.stories.d.ts +2 -0
- package/inputs/ImageInput/__stories__/Default.d.ts +1 -1
- package/inputs/ImageInput/__stories__/MaxSize.d.ts +1 -1
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension.d.ts +1 -1
- package/inputs/ImageInput/index.js +14 -9
- package/inputs/ImageInput/index.js.map +2 -2
- package/inputs/Input/Input.stories.d.ts +5 -0
- package/inputs/Input/__stories__/AFM.d.ts +1 -1
- package/inputs/Input/__stories__/AMKA.d.ts +3 -0
- package/inputs/Input/__stories__/Boolean.d.ts +1 -1
- package/inputs/Input/__stories__/Email.d.ts +3 -0
- package/inputs/Input/__stories__/IBAN.d.ts +1 -1
- package/inputs/Input/__stories__/Integer.d.ts +1 -1
- package/inputs/Input/__stories__/LandlineNumber.d.ts +1 -1
- package/inputs/Input/__stories__/MobilePhone.d.ts +1 -1
- package/inputs/Input/__stories__/PhoneNumber.d.ts +1 -1
- package/inputs/Input/__stories__/PostalCode.d.ts +1 -1
- package/inputs/Input/__stories__/String.d.ts +1 -1
- package/inputs/Input/__stories__/StringWithTrimValidation.d.ts +3 -0
- package/inputs/Input/__stories__/TextWithLimit.d.ts +1 -1
- package/inputs/Input/index.d.ts +2 -1
- package/inputs/Input/index.js +11 -4
- package/inputs/Input/index.js.map +2 -2
- package/inputs/Label/Label.stories.d.ts +2 -0
- package/inputs/Label/__stories__/Default.d.ts +1 -1
- package/inputs/Label/index.d.ts +0 -2
- package/inputs/Label/index.js +2 -2
- package/inputs/Label/index.js.map +2 -2
- package/inputs/OtpInput/OtpInput.stories.d.ts +2 -0
- package/inputs/OtpInput/__stories__/Default.d.ts +1 -1
- package/inputs/OtpInput/index.js +1 -0
- package/inputs/OtpInput/index.js.map +2 -2
- package/inputs/Radio/Radio.stories.d.ts +2 -0
- package/inputs/Radio/__stories__/Conditional.d.ts +1 -1
- package/inputs/Radio/__stories__/Default.d.ts +1 -1
- package/inputs/Radio/__stories__/WithDivider.d.ts +1 -1
- package/inputs/Radio/index.d.ts +1 -1
- package/inputs/Radio/index.js +8 -5
- package/inputs/Radio/index.js.map +2 -2
- package/inputs/Select/Select.stories.d.ts +2 -0
- package/inputs/Select/__stories__/Default.d.ts +1 -1
- package/inputs/Select/index.d.ts +3 -2
- package/inputs/Select/index.js +13 -4
- package/inputs/Select/index.js.map +2 -2
- package/inputs/inputsScenarios/index.js +6 -12
- package/inputs/inputsScenarios.d.ts +1 -1
- package/inputs/inputsScenarios.js.map +2 -2
- package/lazy/index.js +77 -67
- package/locales/el.js.map +1 -1
- package/package.json +5 -5
- package/registry/index.js +115 -106
- package/src/Field/ErrorGroup.tsx +84 -0
- package/src/Field/FieldBase.tsx +38 -22
- package/src/Field/FieldBaseContainer.tsx +15 -8
- package/src/Field/FieldConditional.tsx +6 -2
- package/src/Field/doc.mdx +207 -0
- package/src/Field/index.tsx +20 -5
- package/src/Field/types.tsx +42 -29
- package/src/Field/utils/index.ts +7 -0
- package/src/Field/utils/useField.ts +14 -2
- package/src/FieldArray/FieldArray.stories.js +1 -0
- package/src/FieldArray/FormDialog.tsx +565 -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 +8 -0
- package/src/FieldArray/index.tsx +92 -54
- package/src/FieldObject/index.tsx +41 -20
- package/src/Fieldset/index.tsx +5 -5
- package/src/Fieldset/types.tsx +2 -2
- package/src/FormBuilder/FormBuilder.stories.js +5 -0
- 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/src/FormBuilder/{FormBuilder.mdx → doc.mdx} +27 -35
- package/src/FormBuilder/index.test.tsx +12 -0
- package/src/FormBuilder/index.tsx +105 -11
- package/src/FormBuilder/interaction.test.tsx +40 -0
- package/src/FormBuilder/scenarios.test.tsx +125 -11
- package/src/FormContext.tsx +1 -2
- package/src/MultiplicityField/MultiplicityField.stories.js +3 -0
- package/src/MultiplicityField/__stories__/Default.tsx +1 -1
- package/src/MultiplicityField/__stories__/PreviewDisplay.tsx +1 -1
- package/src/MultiplicityField/__stories__/WithExactLength.tsx +1 -1
- package/src/MultiplicityField/__stories__/WithMaxLength.tsx +1 -1
- package/src/MultiplicityField/__stories__/WithMinAndMaxLength.tsx +1 -1
- package/src/MultiplicityField/__stories__/WithMinLength.tsx +1 -1
- package/src/MultiplicityField/add-objects.tsx +11 -9
- package/src/MultiplicityField/{MultiplicityField.mdx → doc.mdx} +112 -98
- package/src/MultiplicityField/index.test.tsx +4 -0
- package/src/MultiplicityField/index.tsx +17 -12
- package/src/MultiplicityField/types.ts +2 -2
- package/src/Questions/Questions.stories.js +3 -0
- package/src/Questions/Questions.tsx +4 -4
- package/src/Questions/Step/StepArrayReview.tsx +1 -1
- package/src/Questions/Step/StepTitle.tsx +4 -3
- package/src/Questions/__snapshots__/index.spec.tsx.snap +12 -5
- package/src/Questions/__stories__/Default.tsx +1 -1
- package/src/Questions/{index.mdx → doc.mdx} +30 -53
- package/src/Questions/index.spec.tsx +14 -2
- package/src/Questions/index.test.tsx +4 -0
- package/src/create-simple-form.mdx +2 -6
- package/src/{index.mdx → doc.mdx} +29 -18
- package/src/inputs/AutoCompleteInput/AutoComplete.stories.js +3 -0
- package/src/inputs/AutoCompleteInput/__stories__/Default.tsx +3 -11
- package/src/inputs/AutoCompleteInput/__stories__/Multiple.tsx +2 -8
- package/src/inputs/AutoCompleteInput/{index.mdx → doc.mdx} +2 -13
- package/src/inputs/AutoCompleteInput/index.test.tsx +4 -0
- package/src/inputs/AutoCompleteInput/index.tsx +32 -28
- package/src/inputs/Checkboxes/Checkboxes.stories.js +3 -0
- 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 +4 -0
- package/src/inputs/Checkboxes/index.tsx +32 -28
- package/src/inputs/DateInput/DateInput.stories.js +3 -0
- package/src/inputs/DateInput/__stories__/Default.tsx +8 -13
- package/src/inputs/DateInput/{index.mdx → doc.mdx} +1 -8
- package/src/inputs/DateInput/index.test.tsx +4 -0
- package/src/inputs/DateInput/index.tsx +33 -14
- package/src/inputs/DateTimeInput/DateTimeInput.stories.js +11 -0
- package/src/inputs/DateTimeInput/__stories__/Default.tsx +25 -0
- package/src/inputs/DateTimeInput/doc.mdx +16 -0
- package/src/inputs/DateTimeInput/index.test.tsx +24 -0
- package/src/inputs/DateTimeInput/index.tsx +209 -0
- package/src/inputs/FileInput/FileInput.stories.js +4 -0
- 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 +8 -0
- package/src/inputs/FileInput/index.tsx +59 -25
- package/src/inputs/ImageInput/ImageInput.stories.js +3 -1
- package/src/inputs/ImageInput/__stories__/Default.tsx +1 -1
- package/src/inputs/ImageInput/__stories__/MaxSize.tsx +3 -3
- package/src/inputs/ImageInput/__stories__/WithInvalidImageDimension.tsx +3 -1
- package/src/inputs/ImageInput/doc.mdx +23 -0
- package/src/inputs/ImageInput/index.test.tsx +4 -4
- package/src/inputs/ImageInput/index.tsx +17 -16
- package/src/inputs/Input/Input.stories.js +6 -0
- 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__/String.tsx +1 -1
- package/src/inputs/Input/__stories__/StringWithTrimValidation.tsx +26 -0
- package/src/inputs/Input/__stories__/TextWithLimit.tsx +2 -1
- package/src/inputs/Input/doc.mdx +56 -0
- package/src/inputs/Input/index.test.tsx +16 -0
- package/src/inputs/Input/index.tsx +29 -12
- package/src/inputs/Label/Label.stories.js +3 -0
- package/src/inputs/Label/__stories__/Default.tsx +1 -1
- package/src/inputs/Label/doc.mdx +14 -0
- package/src/inputs/Label/index.test.tsx +4 -0
- package/src/inputs/Label/index.tsx +2 -6
- package/src/inputs/OtpInput/OtpInput.stories.js +3 -0
- package/src/inputs/OtpInput/__stories__/Default.tsx +1 -1
- package/src/inputs/OtpInput/{index.mdx → doc.mdx} +1 -8
- package/src/inputs/OtpInput/index.test.tsx +4 -0
- package/src/inputs/OtpInput/index.tsx +3 -1
- package/src/inputs/Radio/Radio.stories.js +3 -0
- package/src/inputs/Radio/__stories__/Conditional.tsx +1 -1
- package/src/inputs/Radio/__stories__/Default.tsx +1 -1
- package/src/inputs/Radio/__stories__/WithDivider.tsx +1 -1
- package/src/inputs/Radio/{index.mdx → doc.mdx} +5 -15
- package/src/inputs/Radio/index.test.tsx +4 -0
- package/src/inputs/Radio/index.tsx +59 -56
- package/src/inputs/Select/Select.stories.js +3 -0
- package/src/inputs/Select/__stories__/Default.tsx +1 -1
- package/src/inputs/Select/{index.mdx → doc.mdx} +1 -5
- package/src/inputs/Select/index.test.tsx +4 -0
- package/src/inputs/Select/index.tsx +18 -7
- package/src/inputs/inputsScenarios.ts +36 -42
- package/src/installation.mdx +2 -5
- package/src/lazy.js +77 -64
- package/src/locales/el.ts +1 -1
- package/src/registry.js +107 -99
- package/src/types.tsx +4 -3
- package/src/utils.ts +29 -8
- package/src/validators/index.ts +102 -90
- package/src/validators/utils/amka.ts +39 -0
- package/src/validators/utils/date.ts +107 -0
- package/src/validators/utils/datetime.ts +130 -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 +1 -1
- package/src/validators/utils/postal_code.ts +1 -1
- package/src/validators/utils/uuid4.ts +2 -1
- package/src/validators/validators.spec.ts +3 -3
- package/types.d.ts +4 -3
- package/types.js.map +1 -1
- package/utils/index.js +22 -7
- package/utils.d.ts +2 -0
- package/utils.js.map +2 -2
- package/validators/index.d.ts +1 -1
- package/validators/index.js +62 -85
- package/validators/index.js.map +2 -2
- package/validators/utils/amka/index.js +36 -0
- package/{FieldArray/FieldArray.stories → validators/utils/amka}/package.json +1 -1
- package/validators/utils/amka.d.ts +6 -0
- package/validators/utils/amka.js.map +7 -0
- package/validators/utils/date/index.js +103 -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 +116 -0
- package/validators/utils/datetime/package.json +6 -0
- package/validators/utils/datetime.d.ts +9 -0
- package/validators/utils/datetime.js.map +7 -0
- package/validators/utils/file/index.js +30 -17
- package/validators/utils/file.js.map +2 -2
- package/validators/utils/index.d.ts +3 -0
- package/validators/utils/index.js +6 -1
- package/validators/utils/index.js.map +2 -2
- package/validators/utils/int/index.js +1 -1
- package/validators/utils/int.js.map +2 -2
- package/validators/utils/number/index.js +1 -1
- package/validators/utils/number.js.map +2 -2
- package/validators/utils/phone.d.ts +1 -1
- package/validators/utils/phone.js.map +2 -2
- package/validators/utils/postal_code.d.ts +1 -1
- package/validators/utils/postal_code.js.map +1 -1
- package/validators/utils/uuid4.js.map +2 -2
- package/FieldArray/FieldArray.stories/index.js +0 -14
- package/FieldArray/FieldArray.stories.js.map +0 -7
- package/FieldArray/__stories__/Default/index.js +0 -95
- package/FieldArray/__stories__/Default/package.json +0 -6
- package/FieldArray/__stories__/Default.js.map +0 -7
- package/FieldArray/__stories__/WithExactLength/index.js +0 -95
- package/FieldArray/__stories__/WithExactLength/package.json +0 -6
- package/FieldArray/__stories__/WithExactLength.js.map +0 -7
- package/Form.stories/index.js +0 -7
- package/Form.stories.js.map +0 -7
- package/FormBuilder/FormBuilder.stories/index.js +0 -12
- package/FormBuilder/FormBuilder.stories/package.json +0 -6
- package/FormBuilder/FormBuilder.stories.js.map +0 -7
- package/FormBuilder/__stories__/Default/index.js +0 -32
- package/FormBuilder/__stories__/Default/package.json +0 -6
- package/FormBuilder/__stories__/Default.js.map +0 -7
- package/MultiplicityField/MultiplicityField.stories/index.js +0 -22
- package/MultiplicityField/MultiplicityField.stories/package.json +0 -6
- package/MultiplicityField/MultiplicityField.stories.js.map +0 -7
- package/MultiplicityField/__stories__/Default/index.js +0 -100
- package/MultiplicityField/__stories__/Default/package.json +0 -6
- package/MultiplicityField/__stories__/Default.js.map +0 -7
- package/MultiplicityField/__stories__/PreviewDisplay/index.js +0 -70
- package/MultiplicityField/__stories__/PreviewDisplay/package.json +0 -6
- package/MultiplicityField/__stories__/PreviewDisplay.js.map +0 -7
- package/MultiplicityField/__stories__/WithExactLength/index.js +0 -97
- package/MultiplicityField/__stories__/WithExactLength/package.json +0 -6
- package/MultiplicityField/__stories__/WithExactLength.js.map +0 -7
- package/MultiplicityField/__stories__/WithMaxLength/index.js +0 -100
- package/MultiplicityField/__stories__/WithMaxLength/package.json +0 -6
- package/MultiplicityField/__stories__/WithMaxLength.js.map +0 -7
- package/MultiplicityField/__stories__/WithMinAndMaxLength/index.js +0 -101
- package/MultiplicityField/__stories__/WithMinAndMaxLength/package.json +0 -6
- package/MultiplicityField/__stories__/WithMinAndMaxLength.js.map +0 -7
- package/MultiplicityField/__stories__/WithMinLength/index.js +0 -100
- package/MultiplicityField/__stories__/WithMinLength/package.json +0 -6
- package/MultiplicityField/__stories__/WithMinLength.js.map +0 -7
- package/Questions/Questions.stories/index.js +0 -12
- package/Questions/Questions.stories.js.map +0 -7
- package/Questions/__stories__/Default/index.js +0 -108
- package/Questions/__stories__/Default/package.json +0 -6
- package/Questions/__stories__/Default.js.map +0 -7
- package/cjs/FieldArray/FieldArray.stories/index.js +0 -48
- package/cjs/FieldArray/FieldArray.stories.js.map +0 -7
- package/cjs/FieldArray/__stories__/Default/index.js +0 -128
- package/cjs/FieldArray/__stories__/Default.js.map +0 -7
- package/cjs/FieldArray/__stories__/WithExactLength/index.js +0 -128
- package/cjs/FieldArray/__stories__/WithExactLength.js.map +0 -7
- package/cjs/Form.stories/index.js +0 -26
- package/cjs/Form.stories.js.map +0 -7
- package/cjs/FormBuilder/FormBuilder.stories/index.js +0 -45
- package/cjs/FormBuilder/FormBuilder.stories.js.map +0 -7
- package/cjs/FormBuilder/__stories__/Default/index.js +0 -65
- package/cjs/FormBuilder/__stories__/Default.js.map +0 -7
- package/cjs/MultiplicityField/MultiplicityField.stories/index.js +0 -60
- package/cjs/MultiplicityField/MultiplicityField.stories.js.map +0 -7
- package/cjs/MultiplicityField/__stories__/Default/index.js +0 -133
- package/cjs/MultiplicityField/__stories__/Default.js.map +0 -7
- package/cjs/MultiplicityField/__stories__/PreviewDisplay/index.js +0 -86
- package/cjs/MultiplicityField/__stories__/PreviewDisplay.js.map +0 -7
- package/cjs/MultiplicityField/__stories__/WithExactLength/index.js +0 -130
- package/cjs/MultiplicityField/__stories__/WithExactLength.js.map +0 -7
- package/cjs/MultiplicityField/__stories__/WithMaxLength/index.js +0 -133
- package/cjs/MultiplicityField/__stories__/WithMaxLength.js.map +0 -7
- package/cjs/MultiplicityField/__stories__/WithMinAndMaxLength/index.js +0 -134
- package/cjs/MultiplicityField/__stories__/WithMinAndMaxLength.js.map +0 -7
- package/cjs/MultiplicityField/__stories__/WithMinLength/index.js +0 -133
- package/cjs/MultiplicityField/__stories__/WithMinLength.js.map +0 -7
- package/cjs/Questions/Questions.stories/index.js +0 -45
- package/cjs/Questions/Questions.stories.js.map +0 -7
- package/cjs/Questions/__stories__/Default/index.js +0 -136
- package/cjs/Questions/__stories__/Default.js.map +0 -7
- package/cjs/inputs/AutoCompleteInput/AutoComplete.stories/index.js +0 -48
- package/cjs/inputs/AutoCompleteInput/AutoComplete.stories.js.map +0 -7
- package/cjs/inputs/AutoCompleteInput/__stories__/Default/index.js +0 -83
- package/cjs/inputs/AutoCompleteInput/__stories__/Default.js.map +0 -7
- package/cjs/inputs/AutoCompleteInput/__stories__/Multiple/index.js +0 -83
- package/cjs/inputs/AutoCompleteInput/__stories__/Multiple.js.map +0 -7
- package/cjs/inputs/Checkboxes/Checkboxes.stories/index.js +0 -51
- package/cjs/inputs/Checkboxes/Checkboxes.stories.js.map +0 -7
- package/cjs/inputs/Checkboxes/__stories__/Conditional/index.js +0 -133
- package/cjs/inputs/Checkboxes/__stories__/Conditional.js.map +0 -7
- package/cjs/inputs/Checkboxes/__stories__/Default/index.js +0 -77
- package/cjs/inputs/Checkboxes/__stories__/Default.js.map +0 -7
- package/cjs/inputs/Checkboxes/__stories__/WithDivider/index.js +0 -78
- package/cjs/inputs/Checkboxes/__stories__/WithDivider.js.map +0 -7
- package/cjs/inputs/DateInput/DateInput.stories/index.js +0 -45
- package/cjs/inputs/DateInput/DateInput.stories.js.map +0 -7
- package/cjs/inputs/DateInput/__stories__/Default/index.js +0 -61
- package/cjs/inputs/DateInput/__stories__/Default.js.map +0 -7
- package/cjs/inputs/FileInput/FileInput.stories/index.js +0 -45
- package/cjs/inputs/FileInput/FileInput.stories.js.map +0 -7
- package/cjs/inputs/FileInput/__stories__/Default/index.js +0 -61
- package/cjs/inputs/FileInput/__stories__/Default.js.map +0 -7
- package/cjs/inputs/ImageInput/ImageInput.stories/index.js +0 -51
- package/cjs/inputs/ImageInput/ImageInput.stories.js.map +0 -7
- package/cjs/inputs/ImageInput/__stories__/Default/index.js +0 -63
- package/cjs/inputs/ImageInput/__stories__/Default.js.map +0 -7
- package/cjs/inputs/ImageInput/__stories__/MaxSize/index.js +0 -69
- package/cjs/inputs/ImageInput/__stories__/MaxSize.js.map +0 -7
- package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +0 -71
- package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension.js.map +0 -7
- package/cjs/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +0 -68
- package/cjs/inputs/ImageInput/__stories__/WithInvalidImageSize.js.map +0 -7
- package/cjs/inputs/Input/Input.stories/index.js +0 -72
- package/cjs/inputs/Input/Input.stories.js.map +0 -7
- package/cjs/inputs/Input/__stories__/AFM/index.js +0 -63
- package/cjs/inputs/Input/__stories__/AFM.js.map +0 -7
- package/cjs/inputs/Input/__stories__/Boolean/index.js +0 -64
- package/cjs/inputs/Input/__stories__/Boolean.js.map +0 -7
- package/cjs/inputs/Input/__stories__/IBAN/index.js +0 -64
- package/cjs/inputs/Input/__stories__/IBAN.js.map +0 -7
- package/cjs/inputs/Input/__stories__/Integer/index.js +0 -78
- package/cjs/inputs/Input/__stories__/Integer.js.map +0 -7
- package/cjs/inputs/Input/__stories__/LandlineNumber/index.js +0 -67
- package/cjs/inputs/Input/__stories__/LandlineNumber.js.map +0 -7
- package/cjs/inputs/Input/__stories__/MobilePhone/index.js +0 -67
- package/cjs/inputs/Input/__stories__/MobilePhone.js.map +0 -7
- package/cjs/inputs/Input/__stories__/PhoneNumber/index.js +0 -66
- package/cjs/inputs/Input/__stories__/PhoneNumber.js.map +0 -7
- package/cjs/inputs/Input/__stories__/PostalCode/index.js +0 -64
- package/cjs/inputs/Input/__stories__/PostalCode.js.map +0 -7
- package/cjs/inputs/Input/__stories__/String/index.js +0 -64
- package/cjs/inputs/Input/__stories__/String.js.map +0 -7
- package/cjs/inputs/Input/__stories__/TextWithLimit/index.js +0 -64
- package/cjs/inputs/Input/__stories__/TextWithLimit.js.map +0 -7
- package/cjs/inputs/Input/inputsInputScenarios/index.js +0 -439
- package/cjs/inputs/Input/inputsInputScenarios.js.map +0 -7
- package/cjs/inputs/Label/Label.stories/index.js +0 -45
- package/cjs/inputs/Label/Label.stories.js.map +0 -7
- package/cjs/inputs/Label/__stories__/Default/index.js +0 -72
- package/cjs/inputs/Label/__stories__/Default.js.map +0 -7
- package/cjs/inputs/OtpInput/OtpInput.stories/index.js +0 -45
- package/cjs/inputs/OtpInput/OtpInput.stories.js.map +0 -7
- package/cjs/inputs/OtpInput/__stories__/Default/index.js +0 -64
- package/cjs/inputs/OtpInput/__stories__/Default.js.map +0 -7
- package/cjs/inputs/Radio/Radio.stories/index.js +0 -51
- package/cjs/inputs/Radio/Radio.stories.js.map +0 -7
- package/cjs/inputs/Radio/__stories__/Conditional/index.js +0 -133
- package/cjs/inputs/Radio/__stories__/Conditional.js.map +0 -7
- package/cjs/inputs/Radio/__stories__/Default/index.js +0 -81
- package/cjs/inputs/Radio/__stories__/Default.js.map +0 -7
- package/cjs/inputs/Radio/__stories__/WithDivider/index.js +0 -82
- package/cjs/inputs/Radio/__stories__/WithDivider.js.map +0 -7
- package/cjs/inputs/Select/Select.stories/index.js +0 -45
- package/cjs/inputs/Select/Select.stories.js.map +0 -7
- package/cjs/inputs/Select/__stories__/Default/index.js +0 -86
- package/cjs/inputs/Select/__stories__/Default.js.map +0 -7
- package/inputs/AutoCompleteInput/AutoComplete.stories/index.js +0 -14
- package/inputs/AutoCompleteInput/AutoComplete.stories/package.json +0 -6
- package/inputs/AutoCompleteInput/AutoComplete.stories.js.map +0 -7
- package/inputs/AutoCompleteInput/__stories__/Default/index.js +0 -50
- package/inputs/AutoCompleteInput/__stories__/Default/package.json +0 -6
- package/inputs/AutoCompleteInput/__stories__/Default.js.map +0 -7
- package/inputs/AutoCompleteInput/__stories__/Multiple/index.js +0 -50
- package/inputs/AutoCompleteInput/__stories__/Multiple/package.json +0 -6
- package/inputs/AutoCompleteInput/__stories__/Multiple.js.map +0 -7
- package/inputs/Checkboxes/Checkboxes.stories/index.js +0 -16
- package/inputs/Checkboxes/Checkboxes.stories/package.json +0 -6
- package/inputs/Checkboxes/Checkboxes.stories.js.map +0 -7
- package/inputs/Checkboxes/__stories__/Conditional/index.js +0 -100
- package/inputs/Checkboxes/__stories__/Conditional/package.json +0 -6
- package/inputs/Checkboxes/__stories__/Conditional.js.map +0 -7
- package/inputs/Checkboxes/__stories__/Default/index.js +0 -44
- package/inputs/Checkboxes/__stories__/Default/package.json +0 -6
- package/inputs/Checkboxes/__stories__/Default.js.map +0 -7
- package/inputs/Checkboxes/__stories__/WithDivider/index.js +0 -45
- package/inputs/Checkboxes/__stories__/WithDivider/package.json +0 -6
- package/inputs/Checkboxes/__stories__/WithDivider.js.map +0 -7
- package/inputs/DateInput/DateInput.stories/index.js +0 -12
- package/inputs/DateInput/DateInput.stories/package.json +0 -6
- package/inputs/DateInput/DateInput.stories.js.map +0 -7
- package/inputs/DateInput/__stories__/Default/index.js +0 -28
- package/inputs/DateInput/__stories__/Default/package.json +0 -6
- package/inputs/DateInput/__stories__/Default.js.map +0 -7
- package/inputs/FileInput/FileInput.stories/index.js +0 -12
- package/inputs/FileInput/FileInput.stories/package.json +0 -6
- package/inputs/FileInput/FileInput.stories.js.map +0 -7
- package/inputs/FileInput/__stories__/Default/index.js +0 -28
- package/inputs/FileInput/__stories__/Default/package.json +0 -6
- package/inputs/FileInput/__stories__/Default.js.map +0 -7
- package/inputs/ImageInput/ImageInput.stories/index.js +0 -16
- package/inputs/ImageInput/ImageInput.stories/package.json +0 -6
- package/inputs/ImageInput/ImageInput.stories.js.map +0 -7
- package/inputs/ImageInput/__stories__/Default/index.js +0 -30
- package/inputs/ImageInput/__stories__/Default/package.json +0 -6
- package/inputs/ImageInput/__stories__/Default.js.map +0 -7
- package/inputs/ImageInput/__stories__/MaxSize/index.js +0 -36
- package/inputs/ImageInput/__stories__/MaxSize/package.json +0 -6
- package/inputs/ImageInput/__stories__/MaxSize.js.map +0 -7
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +0 -38
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension/package.json +0 -6
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension.js.map +0 -7
- package/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +0 -35
- package/inputs/ImageInput/__stories__/WithInvalidImageSize/package.json +0 -6
- package/inputs/ImageInput/__stories__/WithInvalidImageSize.d.ts +0 -3
- package/inputs/ImageInput/__stories__/WithInvalidImageSize.js.map +0 -7
- package/inputs/Input/Input.stories/index.js +0 -30
- package/inputs/Input/Input.stories.js.map +0 -7
- package/inputs/Input/__stories__/AFM/index.js +0 -30
- package/inputs/Input/__stories__/AFM/package.json +0 -6
- package/inputs/Input/__stories__/AFM.js.map +0 -7
- package/inputs/Input/__stories__/Boolean/index.js +0 -31
- package/inputs/Input/__stories__/Boolean/package.json +0 -6
- package/inputs/Input/__stories__/Boolean.js.map +0 -7
- package/inputs/Input/__stories__/IBAN/index.js +0 -31
- package/inputs/Input/__stories__/IBAN/package.json +0 -6
- package/inputs/Input/__stories__/IBAN.js.map +0 -7
- package/inputs/Input/__stories__/Integer/index.js +0 -45
- package/inputs/Input/__stories__/Integer/package.json +0 -6
- package/inputs/Input/__stories__/Integer.js.map +0 -7
- package/inputs/Input/__stories__/LandlineNumber/index.js +0 -34
- package/inputs/Input/__stories__/LandlineNumber/package.json +0 -6
- package/inputs/Input/__stories__/LandlineNumber.js.map +0 -7
- package/inputs/Input/__stories__/MobilePhone/index.js +0 -34
- package/inputs/Input/__stories__/MobilePhone/package.json +0 -6
- package/inputs/Input/__stories__/MobilePhone.js.map +0 -7
- package/inputs/Input/__stories__/PhoneNumber/index.js +0 -33
- package/inputs/Input/__stories__/PhoneNumber/package.json +0 -6
- package/inputs/Input/__stories__/PhoneNumber.js.map +0 -7
- package/inputs/Input/__stories__/PostalCode/index.js +0 -31
- package/inputs/Input/__stories__/PostalCode/package.json +0 -6
- package/inputs/Input/__stories__/PostalCode.js.map +0 -7
- package/inputs/Input/__stories__/String/index.js +0 -31
- package/inputs/Input/__stories__/String/package.json +0 -6
- package/inputs/Input/__stories__/String.js.map +0 -7
- package/inputs/Input/__stories__/TextWithLimit/index.js +0 -31
- package/inputs/Input/__stories__/TextWithLimit/package.json +0 -6
- package/inputs/Input/__stories__/TextWithLimit.js.map +0 -7
- package/inputs/Input/inputsInputScenarios/index.js +0 -406
- package/inputs/Input/inputsInputScenarios/package.json +0 -6
- package/inputs/Input/inputsInputScenarios.d.ts +0 -57
- package/inputs/Input/inputsInputScenarios.js.map +0 -7
- package/inputs/Label/Label.stories/index.js +0 -12
- package/inputs/Label/Label.stories/package.json +0 -6
- package/inputs/Label/Label.stories.js.map +0 -7
- package/inputs/Label/__stories__/Default/index.js +0 -39
- package/inputs/Label/__stories__/Default/package.json +0 -6
- package/inputs/Label/__stories__/Default.js.map +0 -7
- package/inputs/OtpInput/OtpInput.stories/index.js +0 -12
- package/inputs/OtpInput/OtpInput.stories/package.json +0 -6
- package/inputs/OtpInput/OtpInput.stories.js.map +0 -7
- package/inputs/OtpInput/__stories__/Default/index.js +0 -31
- package/inputs/OtpInput/__stories__/Default/package.json +0 -6
- package/inputs/OtpInput/__stories__/Default.js.map +0 -7
- package/inputs/Radio/Radio.stories/index.js +0 -16
- package/inputs/Radio/Radio.stories/package.json +0 -6
- package/inputs/Radio/Radio.stories.js.map +0 -7
- package/inputs/Radio/__stories__/Conditional/index.js +0 -100
- package/inputs/Radio/__stories__/Conditional/package.json +0 -6
- package/inputs/Radio/__stories__/Conditional.js.map +0 -7
- package/inputs/Radio/__stories__/Default/index.js +0 -48
- package/inputs/Radio/__stories__/Default/package.json +0 -6
- package/inputs/Radio/__stories__/Default.js.map +0 -7
- package/inputs/Radio/__stories__/WithDivider/index.js +0 -49
- package/inputs/Radio/__stories__/WithDivider/package.json +0 -6
- package/inputs/Radio/__stories__/WithDivider.js.map +0 -7
- package/inputs/Select/Select.stories/index.js +0 -12
- package/inputs/Select/Select.stories/package.json +0 -6
- package/inputs/Select/Select.stories.js.map +0 -7
- package/inputs/Select/__stories__/Default/index.js +0 -53
- package/inputs/Select/__stories__/Default/package.json +0 -6
- package/inputs/Select/__stories__/Default.js.map +0 -7
- package/lazy.d.ts +0 -77
- package/lazy.js.map +0 -7
- package/registry.d.ts +0 -70
- package/registry.js.map +0 -7
- package/src/Field/index.mdx +0 -6
- package/src/inputs/ImageInput/__stories__/WithInvalidImageSize.tsx +0 -36
- package/src/inputs/ImageInput/index.mdx +0 -19
- package/src/inputs/Input/index.mdx +0 -95
- package/src/inputs/Input/inputsInputScenarios.ts +0 -405
- package/src/inputs/Label/index.mdx +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/validators/utils/datetime.ts"],
|
|
4
|
+
"sourcesContent": ["import dayjs from 'dayjs';\nimport customParseFormat from 'dayjs/plugin/customParseFormat';\nimport { FieldSpec } from '@digigov/form/types';\nimport { ValidatorSchema } from '@digigov/form/validators/types';\n\ndayjs.extend(customParseFormat);\n\nconst VALID_DATETIME_FORMATS = ['DD/MM/YYYY HH:mm'];\nconst DATETIME_CACHE = {};\n\nconst getDateTime = (v: string) => {\n return DATETIME_CACHE[v]\n ? DATETIME_CACHE[v]\n : dayjs(v, VALID_DATETIME_FORMATS, true);\n};\n\n// Function to check partial datetime completion\nconst checkPartialDateTime = (value: string) => {\n const [datePart, timePart] = value.split(' ');\n const [day, month, year] = datePart.split('/');\n const [hours, minutes] = timePart ? timePart.split(':') : [null, null];\n\n // Check date part first\n if (day && !month && !year) {\n return 'form.error.datetime.invalid_month_year';\n }\n if (!day && month && !year) {\n return 'form.error.datetime.invalid_day_year';\n }\n if (!day && !month && year) {\n return 'form.error.datetime.invalid_day_month';\n }\n if (day && month && !year) {\n return 'form.error.datetime.invalid_year';\n }\n if (day && !month && year) {\n return 'form.error.datetime.invalid_month';\n }\n if (!day && month && year) {\n return 'form.error.datetime.invalid_day';\n }\n // If date is complete, check time part\n if (day && month && year) {\n if (hours && !minutes) {\n return 'form.error.datetime.invalid_minutes';\n }\n if (!hours && minutes) {\n return 'form.error.datetime.invalid_hours';\n }\n if (!hours && !minutes) {\n return 'form.error.datetime.invalid';\n }\n if (hours && minutes) {\n const hoursNum = parseInt(hours);\n const minutesNum = parseInt(minutes);\n if (hoursNum < 0 || hoursNum > 23) {\n return 'form.error.datetime.invalid_hours_range';\n }\n if (minutesNum < 0 || minutesNum > 59) {\n return 'form.error.datetime.invalid_minutes_range';\n }\n }\n }\n\n return 'form.error.datetime.invalid';\n};\n\nexport const LATER_THAN_DATETIME_VALIDATOR = (\n field: FieldSpec\n): ValidatorSchema => {\n let minDateTime;\n const params = field.extra || {};\n if (params.min === 'now') {\n minDateTime = dayjs();\n } else {\n minDateTime = getDateTime(params.min);\n }\n return {\n name: 'later-than-datetime',\n message: {\n key: 'form.error.datetime.later_than',\n context: {\n minDateTime: minDateTime.format('DD/MM/YYYY HH:mm'),\n },\n },\n test: function (value: string) {\n if (!value) return true;\n const datetime = getDateTime(value);\n return datetime.isValid() && datetime.isAfter(minDateTime);\n },\n };\n};\n\nexport const EARLIER_THAN_DATETIME_VALIDATOR = (\n field: FieldSpec\n): ValidatorSchema => {\n let maxDateTime;\n const params = field.extra || {};\n if (params.max === 'now') {\n maxDateTime = dayjs();\n } else {\n maxDateTime = getDateTime(params.max);\n }\n return {\n name: 'earlier-than-datetime',\n message: {\n key: 'form.error.datetime.earlier_than',\n context: {\n maxDateTime: maxDateTime.format('DD/MM/YYYY HH:mm'),\n },\n },\n test: function (value: string) {\n if (!value) return true;\n const datetime = getDateTime(value);\n return datetime.isValid() && datetime.isBefore(maxDateTime);\n },\n };\n};\n\nexport const DATETIME_VALIDATOR = {\n name: 'datetime-validator',\n message: (v): string => {\n return checkPartialDateTime(v.value);\n },\n test: function (value: string) {\n if (!value) return true;\n const datetime = getDateTime(value);\n return datetime.isValid();\n },\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,+BAA8B;AAI9B,aAAAA,QAAM,OAAO,yBAAAC,OAAiB;AAE9B,MAAM,yBAAyB,CAAC,kBAAkB;AAClD,MAAM,iBAAiB,CAAC;AAExB,MAAM,cAAc,CAAC,MAAc;AACjC,SAAO,eAAe,CAAC,IACnB,eAAe,CAAC,QAChB,aAAAD,SAAM,GAAG,wBAAwB,IAAI;AAC3C;AAGA,MAAM,uBAAuB,CAAC,UAAkB;AAC9C,QAAM,CAAC,UAAU,QAAQ,IAAI,MAAM,MAAM,GAAG;AAC5C,QAAM,CAAC,KAAK,OAAO,IAAI,IAAI,SAAS,MAAM,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;AAAA,IACA,MAAM,SAAU,OAAe;AAC7B,UAAI,CAAC,MAAO,QAAO;AACnB,YAAM,WAAW,YAAY,KAAK;AAClC,aAAO,SAAS,QAAQ,KAAK,SAAS,QAAQ,WAAW;AAAA,IAC3D;AAAA,EACF;AACF;AAEO,MAAM,kCAAkC,CAC7C,UACoB;AACpB,MAAI;AACJ,QAAM,SAAS,MAAM,SAAS,CAAC;AAC/B,MAAI,OAAO,QAAQ,OAAO;AACxB,sBAAc,aAAAA,SAAM;AAAA,EACtB,OAAO;AACL,kBAAc,YAAY,OAAO,GAAG;AAAA,EACtC;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,MACP,KAAK;AAAA,MACL,SAAS;AAAA,QACP,aAAa,YAAY,OAAO,kBAAkB;AAAA,MACpD;AAAA,IACF;AAAA,IACA,MAAM,SAAU,OAAe;AAC7B,UAAI,CAAC,MAAO,QAAO;AACnB,YAAM,WAAW,YAAY,KAAK;AAClC,aAAO,SAAS,QAAQ,KAAK,SAAS,SAAS,WAAW;AAAA,IAC5D;AAAA,EACF;AACF;AAEO,MAAM,qBAAqB;AAAA,EAChC,MAAM;AAAA,EACN,SAAS,CAAC,MAAc;AACtB,WAAO,qBAAqB,EAAE,KAAK;AAAA,EACrC;AAAA,EACA,MAAM,SAAU,OAAe;AAC7B,QAAI,CAAC,MAAO,QAAO;AACnB,UAAM,WAAW,YAAY,KAAK;AAClC,WAAO,SAAS,QAAQ;AAAA,EAC1B;AACF;",
|
|
6
|
+
"names": ["dayjs", "customParseFormat"]
|
|
7
|
+
}
|
|
@@ -21,26 +21,39 @@ __export(file_exports, {
|
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(file_exports);
|
|
23
23
|
const DEFAULT_FILE_MAX_SIZE = 1e7;
|
|
24
|
-
const FILE_MAX_SIZE_VALIDATOR = (field) =>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
24
|
+
const FILE_MAX_SIZE_VALIDATOR = (field) => {
|
|
25
|
+
const maxSizeInBytes = field?.extra?.limit?.maxSize || DEFAULT_FILE_MAX_SIZE;
|
|
26
|
+
let maxSizeTransformed = maxSizeInBytes / (1024 * 1024);
|
|
27
|
+
let maxSizeText = "MB";
|
|
28
|
+
if (Math.round(maxSizeTransformed) === 0) {
|
|
29
|
+
maxSizeTransformed = Math.round(maxSizeInBytes / 1024);
|
|
30
|
+
maxSizeText = "KB";
|
|
31
|
+
}
|
|
32
|
+
if (Math.round(maxSizeTransformed) === 0) {
|
|
33
|
+
maxSizeTransformed = maxSizeInBytes;
|
|
34
|
+
maxSizeText = "Bytes";
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
name: "file-max-size-validator",
|
|
38
|
+
message: {
|
|
39
|
+
key: field.type === "file" ? "form.error.file_size" : "form.error.image_size",
|
|
40
|
+
context: {
|
|
41
|
+
maxSize: `${maxSizeTransformed} ${maxSizeText}`
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
test: (value) => {
|
|
45
|
+
if (value) {
|
|
46
|
+
for (const file of Array.from(value)) {
|
|
47
|
+
const maxSize = field?.extra?.limit?.maxSize || DEFAULT_FILE_MAX_SIZE;
|
|
48
|
+
if (file.size > maxSize) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
38
51
|
}
|
|
39
52
|
}
|
|
53
|
+
return true;
|
|
40
54
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
});
|
|
55
|
+
};
|
|
56
|
+
};
|
|
44
57
|
// Annotate the CommonJS export names for ESM import in node:
|
|
45
58
|
0 && (module.exports = {
|
|
46
59
|
FILE_MAX_SIZE_VALIDATOR
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/validators/utils/file.ts"],
|
|
4
|
-
"sourcesContent": ["import { FieldSpec } from '@digigov/form/types';\nimport { ValidatorSchema } from '@digigov/form/validators/types';\n\nconst DEFAULT_FILE_MAX_SIZE = 10000000;\n\nexport const FILE_MAX_SIZE_VALIDATOR = (field: FieldSpec): ValidatorSchema => ({\n name: 'file-max-size-validator',\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,MAAM,wBAAwB;AAEvB,MAAM,0BAA0B,CAAC,
|
|
4
|
+
"sourcesContent": ["import { FieldSpec } from '@digigov/form/types';\nimport { ValidatorSchema } from '@digigov/form/validators/types';\n\nconst DEFAULT_FILE_MAX_SIZE = 10000000;\n\nexport const FILE_MAX_SIZE_VALIDATOR = (field: FieldSpec): ValidatorSchema => {\n const maxSizeInBytes = field?.extra?.limit?.maxSize || DEFAULT_FILE_MAX_SIZE;\n let maxSizeTransformed = maxSizeInBytes / (1024 * 1024); // In MB\n let maxSizeText = 'MB';\n if (Math.round(maxSizeTransformed) === 0) {\n maxSizeTransformed = Math.round(maxSizeInBytes / 1024);\n maxSizeText = 'KB';\n }\n if (Math.round(maxSizeTransformed) === 0) {\n maxSizeTransformed = maxSizeInBytes;\n maxSizeText = 'Bytes';\n }\n return {\n name: 'file-max-size-validator',\n message: {\n key:\n field.type === 'file'\n ? 'form.error.file_size'\n : 'form.error.image_size',\n context: {\n maxSize: `${maxSizeTransformed} ${maxSizeText}`,\n },\n },\n test: (value: File[]): boolean => {\n if (value) {\n for (const file of Array.from(value)) {\n const maxSize = field?.extra?.limit?.maxSize || DEFAULT_FILE_MAX_SIZE;\n if (file.size > maxSize) {\n return false;\n }\n }\n }\n return true;\n },\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,MAAM,wBAAwB;AAEvB,MAAM,0BAA0B,CAAC,UAAsC;AAC5E,QAAM,iBAAiB,OAAO,OAAO,OAAO,WAAW;AACvD,MAAI,qBAAqB,kBAAkB,OAAO;AAClD,MAAI,cAAc;AAClB,MAAI,KAAK,MAAM,kBAAkB,MAAM,GAAG;AACxC,yBAAqB,KAAK,MAAM,iBAAiB,IAAI;AACrD,kBAAc;AAAA,EAChB;AACA,MAAI,KAAK,MAAM,kBAAkB,MAAM,GAAG;AACxC,yBAAqB;AACrB,kBAAc;AAAA,EAChB;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,MACP,KACE,MAAM,SAAS,SACX,yBACA;AAAA,MACN,SAAS;AAAA,QACP,SAAS,GAAG,kBAAkB,IAAI,WAAW;AAAA,MAC/C;AAAA,IACF;AAAA,IACA,MAAM,CAAC,UAA2B;AAChC,UAAI,OAAO;AACT,mBAAW,QAAQ,MAAM,KAAK,KAAK,GAAG;AACpC,gBAAM,UAAU,OAAO,OAAO,OAAO,WAAW;AAChD,cAAI,KAAK,OAAO,SAAS;AACvB,mBAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -35,6 +35,7 @@ __export(utils_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(utils_exports);
|
|
36
36
|
var yup = __toESM(require("yup"));
|
|
37
37
|
__reExport(utils_exports, require("@digigov/form/validators/utils/afm"), module.exports);
|
|
38
|
+
__reExport(utils_exports, require("@digigov/form/validators/utils/amka"), module.exports);
|
|
38
39
|
__reExport(utils_exports, require("@digigov/form/validators/utils/file"), module.exports);
|
|
39
40
|
__reExport(utils_exports, require("@digigov/form/validators/utils/iban"), module.exports);
|
|
40
41
|
__reExport(utils_exports, require("@digigov/form/validators/utils/otp"), module.exports);
|
|
@@ -43,6 +44,8 @@ __reExport(utils_exports, require("@digigov/form/validators/utils/phone"), modul
|
|
|
43
44
|
__reExport(utils_exports, require("@digigov/form/validators/utils/postal_code"), module.exports);
|
|
44
45
|
__reExport(utils_exports, require("@digigov/form/validators/utils/uuid4"), module.exports);
|
|
45
46
|
__reExport(utils_exports, require("@digigov/form/validators/utils/text_limit"), module.exports);
|
|
47
|
+
__reExport(utils_exports, require("@digigov/form/validators/utils/date"), module.exports);
|
|
48
|
+
__reExport(utils_exports, require("@digigov/form/validators/utils/datetime"), module.exports);
|
|
46
49
|
function getYupField(field, yupTypeMap) {
|
|
47
50
|
const yupField = yupTypeMap[field?.type || "string"] || yupTypeMap["string"];
|
|
48
51
|
return yupField(field);
|
|
@@ -115,7 +118,9 @@ function getYupObjectShape(fields, yupTypeMap, validatorRegistry) {
|
|
|
115
118
|
}
|
|
116
119
|
return yup.lazy(function() {
|
|
117
120
|
const fieldSchemas = computeShape(
|
|
118
|
-
Object.values(fields.current)
|
|
121
|
+
Object.values(fields.current).filter(
|
|
122
|
+
(f) => !f.key.includes(".")
|
|
123
|
+
),
|
|
119
124
|
yupTypeMap,
|
|
120
125
|
validatorRegistry
|
|
121
126
|
);
|
|
@@ -128,6 +133,7 @@ function getYupObjectShape(fields, yupTypeMap, validatorRegistry) {
|
|
|
128
133
|
getYupField,
|
|
129
134
|
getYupObjectShape,
|
|
130
135
|
...require("@digigov/form/validators/utils/afm"),
|
|
136
|
+
...require("@digigov/form/validators/utils/amka"),
|
|
131
137
|
...require("@digigov/form/validators/utils/file"),
|
|
132
138
|
...require("@digigov/form/validators/utils/iban"),
|
|
133
139
|
...require("@digigov/form/validators/utils/otp"),
|
|
@@ -135,6 +141,8 @@ function getYupObjectShape(fields, yupTypeMap, validatorRegistry) {
|
|
|
135
141
|
...require("@digigov/form/validators/utils/phone"),
|
|
136
142
|
...require("@digigov/form/validators/utils/postal_code"),
|
|
137
143
|
...require("@digigov/form/validators/utils/uuid4"),
|
|
138
|
-
...require("@digigov/form/validators/utils/text_limit")
|
|
144
|
+
...require("@digigov/form/validators/utils/text_limit"),
|
|
145
|
+
...require("@digigov/form/validators/utils/date"),
|
|
146
|
+
...require("@digigov/form/validators/utils/datetime")
|
|
139
147
|
});
|
|
140
148
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/validators/utils/index.ts"],
|
|
4
|
-
"sourcesContent": ["import * as yup from 'yup';\nimport { FieldSpec } from '@digigov/form/types';\nimport { ValidatorSchema } from '@digigov/form/validators/types';\n\nexport * from '@digigov/form/validators/utils/afm';\nexport * from '@digigov/form/validators/utils/file';\nexport * from '@digigov/form/validators/utils/iban';\nexport * from '@digigov/form/validators/utils/otp';\nexport * from '@digigov/form/validators/utils/image';\nexport * from '@digigov/form/validators/utils/phone';\nexport * from '@digigov/form/validators/utils/postal_code';\nexport * from '@digigov/form/validators/utils/uuid4';\nexport * from '@digigov/form/validators/utils/text_limit';\n\nexport function getYupField(field: FieldSpec, yupTypeMap: Record<string, any>) {\n const yupField = yupTypeMap[field?.type || 'string'] || yupTypeMap['string'];\n return yupField(field);\n}\nexport function computeShape(\n fields: FieldSpec[],\n yupTypeMap: Record<string, ValidatorSchema>,\n validatorRegistry: Record<string, ValidatorSchema[]> | undefined\n) {\n const fieldSchemas = {};\n const objectFields: Record<string, FieldSpec[]> = {};\n fields.forEach((field) => {\n let yupField = getYupField(field, yupTypeMap);\n if (field.condition) {\n for (const key in field.condition) {\n let then: any, otherwise: any;\n if (field.condition[key].then) {\n if (field.condition[key].then?.required === false) {\n then = yupField.nullable();\n } else if (field.condition[key].then?.required === true) {\n then = yupField.nullable().required('form.error.required');\n }\n }\n if (field.condition[key].else) {\n if (field.condition[key].else?.required === false) {\n otherwise = yupField.nullable();\n } else if (field.condition[key].else?.required === true) {\n otherwise = yupField.nullable().required('form.error.required');\n }\n }\n if (then || otherwise) {\n yupField = yupField.when(key, {\n is: (val) => {\n //@ts-ignore\n const is = field.condition[key].is;\n if (is === val || (Array.isArray(val) && val.includes(is))) {\n return true;\n } else {\n return false;\n }\n },\n then,\n otherwise,\n });\n }\n }\n } else if (field.required) {\n yupField = yupField.nullable().required('form.error.required');\n }\n if (validatorRegistry && field.type && validatorRegistry[field.type]) {\n validatorRegistry[field.type].forEach((validator: any) => {\n yupField = yupField.test(validator);\n });\n }\n if (field.validators) {\n field.validators.forEach((validator) => {\n yupField = yupField.test(validator);\n });\n }\n fieldSchemas[field.key] = yupField;\n });\n for (const objectKey in objectFields) {\n fieldSchemas[objectKey] = getYupObjectShape(\n objectFields[objectKey],\n yupTypeMap,\n validatorRegistry\n );\n }\n return fieldSchemas;\n}\n\nexport function getYupObjectShape(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n fields: FieldSpec[] | any,\n yupTypeMap: Record<string, any>,\n validatorRegistry?: Record<string, ValidatorSchema[]>\n) {\n if (!fields.current) {\n const fieldSchemas = computeShape(fields, yupTypeMap, validatorRegistry);\n return yup.object().shape(fieldSchemas);\n }\n\n return yup.lazy(function () {\n const fieldSchemas = computeShape(\n Object.values(fields.current),\n yupTypeMap,\n validatorRegistry\n );\n return yup.object().shape(fieldSchemas);\n });\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAAqB;AAIrB,0BAAc,+CAJd;AAKA,0BAAc,gDALd;AAMA,0BAAc,gDANd;AAOA,0BAAc
|
|
4
|
+
"sourcesContent": ["import * as yup from 'yup';\nimport { FieldSpec } from '@digigov/form/types';\nimport { ValidatorSchema } from '@digigov/form/validators/types';\n\nexport * from '@digigov/form/validators/utils/afm';\nexport * from '@digigov/form/validators/utils/amka';\nexport * from '@digigov/form/validators/utils/file';\nexport * from '@digigov/form/validators/utils/iban';\nexport * from '@digigov/form/validators/utils/otp';\nexport * from '@digigov/form/validators/utils/image';\nexport * from '@digigov/form/validators/utils/phone';\nexport * from '@digigov/form/validators/utils/postal_code';\nexport * from '@digigov/form/validators/utils/uuid4';\nexport * from '@digigov/form/validators/utils/text_limit';\nexport * from '@digigov/form/validators/utils/date';\nexport * from '@digigov/form/validators/utils/datetime';\n\nexport function getYupField(field: FieldSpec, yupTypeMap: Record<string, any>) {\n const yupField = yupTypeMap[field?.type || 'string'] || yupTypeMap['string'];\n return yupField(field);\n}\nexport function computeShape(\n fields: FieldSpec[],\n yupTypeMap: Record<string, ValidatorSchema>,\n validatorRegistry: Record<string, ValidatorSchema[]> | undefined\n) {\n const fieldSchemas = {};\n const objectFields: Record<string, FieldSpec[]> = {};\n fields.forEach((field) => {\n let yupField = getYupField(field, yupTypeMap);\n if (field.condition) {\n for (const key in field.condition) {\n let then: any, otherwise: any;\n if (field.condition[key].then) {\n if (field.condition[key].then?.required === false) {\n then = yupField.nullable();\n } else if (field.condition[key].then?.required === true) {\n then = yupField.nullable().required('form.error.required');\n }\n }\n if (field.condition[key].else) {\n if (field.condition[key].else?.required === false) {\n otherwise = yupField.nullable();\n } else if (field.condition[key].else?.required === true) {\n otherwise = yupField.nullable().required('form.error.required');\n }\n }\n if (then || otherwise) {\n yupField = yupField.when(key, {\n is: (val) => {\n //@ts-ignore\n const is = field.condition[key].is;\n if (is === val || (Array.isArray(val) && val.includes(is))) {\n return true;\n } else {\n return false;\n }\n },\n then,\n otherwise,\n });\n }\n }\n } else if (field.required) {\n yupField = yupField.nullable().required('form.error.required');\n }\n if (validatorRegistry && field.type && validatorRegistry[field.type]) {\n validatorRegistry[field.type].forEach((validator: any) => {\n yupField = yupField.test(validator);\n });\n }\n if (field.validators) {\n field.validators.forEach((validator) => {\n yupField = yupField.test(validator);\n });\n }\n fieldSchemas[field.key] = yupField;\n });\n for (const objectKey in objectFields) {\n fieldSchemas[objectKey] = getYupObjectShape(\n objectFields[objectKey],\n yupTypeMap,\n validatorRegistry\n );\n }\n return fieldSchemas;\n}\n\nexport function getYupObjectShape(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n fields: FieldSpec[] | any,\n yupTypeMap: Record<string, any>,\n validatorRegistry?: Record<string, ValidatorSchema[]>\n) {\n if (!fields.current) {\n const fieldSchemas = computeShape(fields, yupTypeMap, validatorRegistry);\n return yup.object().shape(fieldSchemas);\n }\n\n return yup.lazy(function () {\n const fieldSchemas = computeShape(\n Object.values(fields.current).filter(\n (f: FieldSpec) => !f.key.includes('.')\n ) as FieldSpec[],\n yupTypeMap,\n validatorRegistry\n );\n return yup.object().shape(fieldSchemas);\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAAqB;AAIrB,0BAAc,+CAJd;AAKA,0BAAc,gDALd;AAMA,0BAAc,gDANd;AAOA,0BAAc,gDAPd;AAQA,0BAAc,+CARd;AASA,0BAAc,iDATd;AAUA,0BAAc,iDAVd;AAWA,0BAAc,uDAXd;AAYA,0BAAc,iDAZd;AAaA,0BAAc,sDAbd;AAcA,0BAAc,gDAdd;AAeA,0BAAc,oDAfd;AAiBO,SAAS,YAAY,OAAkB,YAAiC;AAC7E,QAAM,WAAW,WAAW,OAAO,QAAQ,QAAQ,KAAK,WAAW,QAAQ;AAC3E,SAAO,SAAS,KAAK;AACvB;AACO,SAAS,aACd,QACA,YACA,mBACA;AACA,QAAM,eAAe,CAAC;AACtB,QAAM,eAA4C,CAAC;AACnD,SAAO,QAAQ,CAAC,UAAU;AACxB,QAAI,WAAW,YAAY,OAAO,UAAU;AAC5C,QAAI,MAAM,WAAW;AACnB,iBAAW,OAAO,MAAM,WAAW;AACjC,YAAI,MAAW;AACf,YAAI,MAAM,UAAU,GAAG,EAAE,MAAM;AAC7B,cAAI,MAAM,UAAU,GAAG,EAAE,MAAM,aAAa,OAAO;AACjD,mBAAO,SAAS,SAAS;AAAA,UAC3B,WAAW,MAAM,UAAU,GAAG,EAAE,MAAM,aAAa,MAAM;AACvD,mBAAO,SAAS,SAAS,EAAE,SAAS,qBAAqB;AAAA,UAC3D;AAAA,QACF;AACA,YAAI,MAAM,UAAU,GAAG,EAAE,MA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I,OAAO,EAAE,MAAM,YAAY;AAAA,EACxC;AAEA,SAAO,IAAI,KAAK,WAAY;AAC1B,UAAM,eAAe;AAAA,MACnB,OAAO,OAAO,OAAO,OAAO,EAAE;AAAA,QAC5B,CAAC,MAAiB,CAAC,EAAE,IAAI,SAAS,GAAG;AAAA,MACvC;AAAA,MACA;AAAA,MACA;AAAA,IACF;AACA,WAAO,IAAI,OAAO,EAAE,MAAM,YAAY;AAAA,EACxC,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/validators/utils/int.ts"],
|
|
4
|
-
"sourcesContent": ["import { ValidatorSchema } from '@digigov/form/validators/types';\n\nexport function validateIntNumber(number: number): boolean {\n if (number === undefined) {\n return false;\n } else {\n return Number.isInteger(number) && Number(number) > 0;\n }\n}\n\nexport const INT_VALIDATOR = (): ValidatorSchema => {\n return {\n name: 'int-validator',\n message: 'form.error.positive_integer_number',\n test: (value: number): boolean => {\n if (value ===
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,SAAS,kBAAkB,QAAyB;AACzD,MAAI,WAAW,QAAW;AACxB,WAAO;AAAA,EACT,OAAO;AACL,WAAO,OAAO,UAAU,MAAM,KAAK,OAAO,MAAM,IAAI;AAAA,EACtD;AACF;AAEO,MAAM,gBAAgB,MAAuB;AAClD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MAAM,CAAC,UAA2B;AAChC,UAAI,UAAU,
|
|
4
|
+
"sourcesContent": ["import { ValidatorSchema } from '@digigov/form/validators/types';\n\nexport function validateIntNumber(number: number): boolean {\n if (number === undefined) {\n return false;\n } else {\n return Number.isInteger(number) && Number(number) > 0;\n }\n}\n\nexport const INT_VALIDATOR = (): ValidatorSchema => {\n return {\n name: 'int-validator',\n message: 'form.error.positive_integer_number',\n test: (value: number): boolean => {\n if (value === undefined) {\n return true;\n }\n return validateIntNumber(value);\n },\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,SAAS,kBAAkB,QAAyB;AACzD,MAAI,WAAW,QAAW;AACxB,WAAO;AAAA,EACT,OAAO;AACL,WAAO,OAAO,UAAU,MAAM,KAAK,OAAO,MAAM,IAAI;AAAA,EACtD;AACF;AAEO,MAAM,gBAAgB,MAAuB;AAClD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MAAM,CAAC,UAA2B;AAChC,UAAI,UAAU,QAAW;AACvB,eAAO;AAAA,MACT;AACA,aAAO,kBAAkB,KAAK;AAAA,IAChC;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/validators/utils/number.ts"],
|
|
4
|
-
"sourcesContent": ["import { ValidatorSchema } from '@digigov/form/validators/types';\n\nexport function validateNumber(number: number): boolean {\n return !Number.isNaN(number);\n}\n\nexport const NUMBER_VALIDATOR = (): ValidatorSchema => {\n return {\n name: 'number-validator',\n message: 'form.error.number',\n test: (value: number): boolean => {\n if (value ===
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,SAAS,eAAe,QAAyB;AACtD,SAAO,CAAC,OAAO,MAAM,MAAM;AAC7B;AAEO,MAAM,mBAAmB,MAAuB;AACrD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MAAM,CAAC,UAA2B;AAChC,UAAI,UAAU,
|
|
4
|
+
"sourcesContent": ["import { ValidatorSchema } from '@digigov/form/validators/types';\n\nexport function validateNumber(number: number): boolean {\n return !Number.isNaN(number);\n}\n\nexport const NUMBER_VALIDATOR = (): ValidatorSchema => {\n return {\n name: 'number-validator',\n message: 'form.error.number',\n test: (value: number): boolean => {\n if (value === undefined) {\n return true;\n }\n return validateNumber(value);\n },\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,SAAS,eAAe,QAAyB;AACtD,SAAO,CAAC,OAAO,MAAM,MAAM;AAC7B;AAEO,MAAM,mBAAmB,MAAuB;AACrD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MAAM,CAAC,UAA2B;AAChC,UAAI,UAAU,QAAW;AACvB,eAAO;AAAA,MACT;AACA,aAAO,eAAe,KAAK;AAAA,IAC7B;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/validators/utils/phone.ts"],
|
|
4
|
-
"sourcesContent": ["import { FieldSpec } from '@digigov/form/types';\nimport { ValidatorSchema } from '@digigov/form/validators/types';\n\nexport type PhoneNumberType = 'landline' | 'mobile' | null;\n// add more countries from here libphonenumber-js/metadata.full.json\nconst countryPhoneData = {\n GR: [\n '30',\n '00',\n '5005000\\\\d{3}|8\\\\d{9,11}|(?:[269]\\\\d|70)\\\\d{8}',\n [10, 11, 12],\n [\n ['(\\\\d{2})(\\\\d{4})(\\\\d{4})', '$1 $2 $3', ['21|7']],\n [\n '(\\\\d{4})(\\\\d{6})',\n '$1 $2',\n ['2(?:2|3[2-57-9]|4[2-469]|5[2-59]|6[2-9]|7[2-69]|8[2-49])|5'],\n ],\n ['(\\\\d{3})(\\\\d{3})(\\\\d{4})', '$1 $2 $3', ['[2689]']],\n ['(\\\\d{3})(\\\\d{3,4})(\\\\d{5})', '$1 $2 $3', ['8']],\n ],\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n [\n [\n '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}',\n [10],\n ],\n ['68[57-9]\\\\d{7}|(?:69|94)\\\\d{8}', [10]],\n ['800\\\\d{7,9}'],\n ['90[19]\\\\d{7}', [10]],\n ['70\\\\d{8}', [10]],\n 0,\n ['5005000\\\\d{3}', [10]],\n 0,\n 0,\n ['8(?:0[16]|12|[27]5|50)\\\\d{7}', [10]],\n ],\n ],\n};\n\nfunction expandPhoneNumberStructure(compressed) {\n const countries = Object.keys(compressed);\n const expanded: any = {};\n for (const country of countries) {\n expanded[country] = {\n fixedLine: {\n possibleLengths: {\n _national: compressed[country][3].map(String),\n },\n nationalNumberPattern: compressed[country][11][0][0],\n },\n mobile: {\n nationalNumberPattern: compressed[country][11][1][0],\n },\n tollFree: {\n nationalNumberPattern: compressed[country][11][2][0],\n },\n premiumRate: {\n nationalNumberPattern: compressed[country][11][3][0],\n },\n sharedCost: {\n nationalNumberPattern: compressed[country][11][9][0],\n },\n personalNumber: {\n nationalNumberPattern: compressed[country][11][4][0],\n },\n uan: {\n nationalNumberPattern: compressed[country][11][6][0],\n },\n id: country,\n countryCode: compressed[country][0],\n internationalPrefix: compressed[country][1],\n };\n }\n return expanded;\n}\nconst PHONENUMBER_SPEC = expandPhoneNumberStructure(countryPhoneData);\nexport function discoverPhoneType(phoneNumber: string, config: any): string {\n const cleanNumber = phoneNumber\n .replace(/\\D/g, '')\n .replace(/\\s/g, '')\n .replace(/^\\+/, '')\n .replace(new RegExp('^' + config.internationalPrefix, ''), '')\n .replace(new RegExp('^' + config.countryCode, ''), '');\n const categories = {\n landline: config.fixedLine,\n mobile: config.mobile,\n 'toll-free': config.tollFree,\n 'premium-rate': config.premiumRate,\n };\n\n for (const [categoryName, categoryDetails] of Object.entries(categories)) {\n const pattern = new RegExp(\n '^(' + categoryDetails.nationalNumberPattern.replace(/\\s/g, '') + ')$',\n ''\n );\n if (cleanNumber.match(pattern)) {\n return categoryName; // Returns the category name if the number matches the pattern\n }\n }\n\n // If no category matches, return 'Unknown'\n return 'unknown';\n}\nfunction getNumberType(phoneNumber: string, country: string) {\n const spec = PHONENUMBER_SPEC[country.toUpperCase()];\n if (!spec) {\n throw new Error(`Country ${country} is not supported`);\n }\n const type = discoverPhoneType(phoneNumber, spec);\n return type;\n}\n\nfunction isPhoneNumberValid(\n phoneNumber: string,\n countries: string[],\n types = ['mobile', 'landline']\n) {\n return countries.some((country) => {\n const numberType = getNumberType(phoneNumber, country);\n if (numberType && types.includes(numberType)) {\n return true;\n }\n return false;\n });\n}\nfunction isNumberOfType(phoneNumber: string, country: string, type: string) {\n const numberType = getNumberType(phoneNumber, country);\n if (numberType === type) {\n return true;\n }\n return false;\n}\nexport function validatePhoneNumber(\n phoneNumber: string,\n countries:
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,MAAM,mBAAmB;AAAA,EACvB,IAAI;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA,CAAC,IAAI,IAAI,EAAE;AAAA,IACX;AAAA,MACE,CAAC,4BAA4B,YAAY,CAAC,MAAM,CAAC;AAAA,MACjD;AAAA,QACE;AAAA,QACA;AAAA,QACA,CAAC,4DAA4D;AAAA,MAC/D;AAAA,MACA,CAAC,4BAA4B,YAAY,CAAC,QAAQ,CAAC;AAAA,MACnD,CAAC,8BAA8B,Y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C7B;AACA,SAAO,UAAU,KAAK,CAAC,YAAY;AACjC,UAAM,aAAa,cAAc,aAAa,OAAO;AACrD,QAAI,cAAc,MAAM,SAAS,UAAU,GAAG;AAC5C,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT,CAAC;AACH;AACA,SAAS,eAAe,aAAqB,SAAiB,MAAc;AAC1E,QAAM,aAAa,cAAc,aAAa,OAAO;AACrD,MAAI,eAAe,MAAM;AACvB,WAAO;AAAA,EACT;AACA,SAAO;AACT;AACO,SAAS,oBACd,aACA,
|
|
4
|
+
"sourcesContent": ["import { FieldSpec } from '@digigov/form/types';\nimport { ValidatorSchema } from '@digigov/form/validators/types';\n\nexport type PhoneNumberType = 'landline' | 'mobile' | null;\n// add more countries from here libphonenumber-js/metadata.full.json\nconst countryPhoneData = {\n GR: [\n '30',\n '00',\n '5005000\\\\d{3}|8\\\\d{9,11}|(?:[269]\\\\d|70)\\\\d{8}',\n [10, 11, 12],\n [\n ['(\\\\d{2})(\\\\d{4})(\\\\d{4})', '$1 $2 $3', ['21|7']],\n [\n '(\\\\d{4})(\\\\d{6})',\n '$1 $2',\n ['2(?:2|3[2-57-9]|4[2-469]|5[2-59]|6[2-9]|7[2-69]|8[2-49])|5'],\n ],\n ['(\\\\d{3})(\\\\d{3})(\\\\d{4})', '$1 $2 $3', ['[2689]']],\n ['(\\\\d{3})(\\\\d{3,4})(\\\\d{5})', '$1 $2 $3', ['8']],\n ],\n 0,\n 0,\n 0,\n 0,\n 0,\n 0,\n [\n [\n '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}',\n [10],\n ],\n ['68[57-9]\\\\d{7}|(?:69|94)\\\\d{8}', [10]],\n ['800\\\\d{7,9}'],\n ['90[19]\\\\d{7}', [10]],\n ['70\\\\d{8}', [10]],\n 0,\n ['5005000\\\\d{3}', [10]],\n 0,\n 0,\n ['8(?:0[16]|12|[27]5|50)\\\\d{7}', [10]],\n ],\n ],\n};\n\nfunction expandPhoneNumberStructure(compressed) {\n const countries = Object.keys(compressed);\n const expanded: any = {};\n for (const country of countries) {\n expanded[country] = {\n fixedLine: {\n possibleLengths: {\n _national: compressed[country][3].map(String),\n },\n nationalNumberPattern: compressed[country][11][0][0],\n },\n mobile: {\n nationalNumberPattern: compressed[country][11][1][0],\n },\n tollFree: {\n nationalNumberPattern: compressed[country][11][2][0],\n },\n premiumRate: {\n nationalNumberPattern: compressed[country][11][3][0],\n },\n sharedCost: {\n nationalNumberPattern: compressed[country][11][9][0],\n },\n personalNumber: {\n nationalNumberPattern: compressed[country][11][4][0],\n },\n uan: {\n nationalNumberPattern: compressed[country][11][6][0],\n },\n id: country,\n countryCode: compressed[country][0],\n internationalPrefix: compressed[country][1],\n };\n }\n return expanded;\n}\nconst PHONENUMBER_SPEC = expandPhoneNumberStructure(countryPhoneData);\nexport function discoverPhoneType(phoneNumber: string, config: any): string {\n const cleanNumber = phoneNumber\n .replace(/\\D/g, '')\n .replace(/\\s/g, '')\n .replace(/^\\+/, '')\n .replace(new RegExp('^' + config.internationalPrefix, ''), '')\n .replace(new RegExp('^' + config.countryCode, ''), '');\n const categories = {\n landline: config.fixedLine,\n mobile: config.mobile,\n 'toll-free': config.tollFree,\n 'premium-rate': config.premiumRate,\n };\n\n for (const [categoryName, categoryDetails] of Object.entries(categories)) {\n const pattern = new RegExp(\n '^(' + categoryDetails.nationalNumberPattern.replace(/\\s/g, '') + ')$',\n ''\n );\n if (cleanNumber.match(pattern)) {\n return categoryName; // Returns the category name if the number matches the pattern\n }\n }\n\n // If no category matches, return 'Unknown'\n return 'unknown';\n}\nfunction getNumberType(phoneNumber: string, country: string) {\n const spec = PHONENUMBER_SPEC[country.toUpperCase()];\n if (!spec) {\n throw new Error(`Country ${country} is not supported`);\n }\n const type = discoverPhoneType(phoneNumber, spec);\n return type;\n}\n\nfunction isPhoneNumberValid(\n phoneNumber: string,\n countries: string[],\n types = ['mobile', 'landline']\n) {\n return countries.some((country) => {\n const numberType = getNumberType(phoneNumber, country);\n if (numberType && types.includes(numberType)) {\n return true;\n }\n return false;\n });\n}\nfunction isNumberOfType(phoneNumber: string, country: string, type: string) {\n const numberType = getNumberType(phoneNumber, country);\n if (numberType === type) {\n return true;\n }\n return false;\n}\nexport function validatePhoneNumber(\n phoneNumber: string,\n countries: string[] = ['gr'],\n typeOfPhoneNumber?: PhoneNumberType\n): boolean {\n if (!countries || countries.length === 0) {\n return true;\n }\n return isPhoneNumberValid(\n phoneNumber,\n countries,\n typeOfPhoneNumber ? [typeOfPhoneNumber] : undefined\n );\n}\n\nfunction validateMobile(value): boolean {\n return isNumberOfType(value, 'gr', 'mobile');\n}\n\nexport const MOBILE_PHONE_VALIDATOR = {\n name: 'mobile-phone-validator',\n message: 'form.error.mobile_phone',\n test: (value): boolean => {\n if (value) {\n return validateMobile(value);\n }\n return true;\n },\n};\n\nexport const PHONE_NUMBER_VALIDATOR = (field: FieldSpec): ValidatorSchema => {\n const countryCodes = field?.extra?.countries;\n const typeOfPhone: PhoneNumberType | null = field?.extra?.phoneType;\n return {\n name: 'phone-number-validator',\n message: (): string => {\n if (typeOfPhone === 'mobile') {\n return 'form.error.mobile_phone';\n }\n if (typeOfPhone === 'landline') {\n return 'form.error.landline';\n } else {\n return 'form.error.phone_number';\n }\n },\n test: (value: string): boolean => {\n if (!value) {\n return true;\n }\n return validatePhoneNumber(value, countryCodes, typeOfPhone);\n },\n };\n};\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nC,QAAM,cAAsC,OAAO,OAAO;AAC1D,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS,MAAc;AACrB,UAAI,gBAAgB,UAAU;AAC5B,eAAO;AAAA,MACT;AACA,UAAI,gBAAgB,YAAY;AAC9B,eAAO;AAAA,MACT,OAAO;AACL,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,MAAM,CAAC,UAA2B;AAChC,UAAI,CAAC,OAAO;AACV,eAAO;AAAA,MACT;AACA,aAAO,oBAAoB,OAAO,cAAc,WAAW;AAAA,IAC7D;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/validators/utils/postal_code.ts"],
|
|
4
|
-
"sourcesContent": ["import { FieldSpec } from '@digigov/form/types';\nimport { ValidatorSchema } from '@digigov/form/validators/types';\n\nconst CODE_REGEX = /^[12345678][0-9]{4}$/;\nexport function validatePostalCode(\n number: string,\n countries:
|
|
4
|
+
"sourcesContent": ["import { FieldSpec } from '@digigov/form/types';\nimport { ValidatorSchema } from '@digigov/form/validators/types';\n\nconst CODE_REGEX = /^[12345678][0-9]{4}$/;\nexport function validatePostalCode(\n number: string,\n countries: string[]\n): boolean {\n if (!countries) {\n return false;\n } else {\n if (countries.length === 1 && countries[0].toUpperCase() === 'GR') {\n // Greek postal code must be 5 digits long and shouldn't start with 0 or 9.\n return CODE_REGEX.test(number);\n } else {\n return true;\n }\n }\n}\n\nexport const POSTALCODE_VALIDATOR = (field: FieldSpec): ValidatorSchema => {\n const countryCode = field?.extra?.countries;\n return {\n name: 'postal-code-validator',\n message: 'form.error.postalCode',\n test: (value: string): boolean => {\n if (!value) {\n return true;\n }\n return validatePostalCode(value, countryCode);\n },\n };\n};\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,MAAM,aAAa;AACZ,SAAS,mBACd,QACA,WACS;AACT,MAAI,CAAC,WAAW;AACd,WAAO;AAAA,EACT,OAAO;AACL,QAAI,UAAU,WAAW,KAAK,UAAU,CAAC,EAAE,YAAY,MAAM,MAAM;AAEjE,aAAO,WAAW,KAAK,MAAM;AAAA,IAC/B,OAAO;AACL,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEO,MAAM,uBAAuB,CAAC,UAAsC;AACzE,QAAM,cAAc,OAAO,OAAO;AAClC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MAAM,CAAC,UAA2B;AAChC,UAAI,CAAC,OAAO;AACV,eAAO;AAAA,MACT;AACA,aAAO,mBAAmB,OAAO,WAAW;AAAA,IAC9C;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/validators/utils/uuid4.ts"],
|
|
4
|
-
"sourcesContent": ["const UUID4_PATTERN
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAAM,
|
|
4
|
+
"sourcesContent": ["const UUID4_PATTERN =\n /^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i;\n\nexport function validateUUID4(uuid4: string): boolean {\n if (uuid4.length !== 36) {\n // This uuid4 should be 36 characters long\n return false;\n }\n\n return UUID4_PATTERN.test(uuid4);\n}\n\nexport const UUID4_VALIDATOR = {\n name: 'uuid4-validator',\n message: 'form.error.uuid4',\n test: (value): boolean => {\n if (value) {\n return validateUUID4(value);\n }\n return true;\n },\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAAM,gBACJ;AAEK,SAAS,cAAc,OAAwB;AACpD,MAAI,MAAM,WAAW,IAAI;AAEvB,WAAO;AAAA,EACT;AAEA,SAAO,cAAc,KAAK,KAAK;AACjC;AAEO,MAAM,kBAAkB;AAAA,EAC7B,MAAM;AAAA,EACN,SAAS;AAAA,EACT,MAAM,CAAC,UAAmB;AACxB,QAAI,OAAO;AACT,aAAO,cAAc,KAAK;AAAA,IAC5B;AACA,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { ControlledFieldProps } from '@digigov/form/Field/types';
|
|
|
3
3
|
import { FieldOptionProps } from '@digigov/form/inputs/Label';
|
|
4
4
|
import { AutoCompleteProps as UIAutoCompleteProps } from '@digigov/ui/form/AutoComplete';
|
|
5
5
|
export interface AutoCompleteInputExtra extends Omit<UIAutoCompleteProps, 'source' | 'id' | 'templates' | 'defaultValue' | 'onConfirm' | 'dropdownArrow'> {
|
|
6
|
-
options:
|
|
6
|
+
options: FieldOptionProps[];
|
|
7
7
|
}
|
|
8
8
|
export interface AutoCompleteInputProps extends Omit<ControlledFieldProps, 'value' | 'onChange' | 'extra'> {
|
|
9
9
|
extra: AutoCompleteInputExtra;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import {
|
|
3
|
+
AutoComplete
|
|
4
|
+
} from "@digigov/ui/form/AutoComplete";
|
|
5
|
+
import { Hint } from "@digigov/ui/typography/Hint";
|
|
6
|
+
import { Base } from "@digigov/ui/utils/Base";
|
|
5
7
|
const AutoCompleteInput = ({
|
|
6
8
|
name,
|
|
7
9
|
type,
|
|
8
10
|
extra: { options },
|
|
9
11
|
onChange,
|
|
10
12
|
value,
|
|
11
|
-
error,
|
|
12
13
|
...props
|
|
13
14
|
}) => {
|
|
14
15
|
const suggest = useCallback(
|
|
@@ -22,14 +23,15 @@ const AutoCompleteInput = ({
|
|
|
22
23
|
[options]
|
|
23
24
|
);
|
|
24
25
|
return /* @__PURE__ */ React.createElement(
|
|
25
|
-
|
|
26
|
+
AutoComplete,
|
|
26
27
|
{
|
|
27
28
|
multiple: type === "choice:multiple" ? true : false,
|
|
28
29
|
source: suggest,
|
|
29
30
|
onConfirm: (value2) => {
|
|
30
31
|
if (Array.isArray(value2)) {
|
|
31
32
|
const selectedValues = value2.map((item) => item.value);
|
|
32
|
-
selectedValues.length > 0
|
|
33
|
+
if (selectedValues.length > 0) onChange(selectedValues);
|
|
34
|
+
else onChange(void 0);
|
|
33
35
|
} else {
|
|
34
36
|
onChange(value2.value);
|
|
35
37
|
}
|
|
@@ -48,7 +50,8 @@ const AutoCompleteInput = ({
|
|
|
48
50
|
...{
|
|
49
51
|
...props,
|
|
50
52
|
reset: void 0,
|
|
51
|
-
required: void 0
|
|
53
|
+
required: void 0,
|
|
54
|
+
Field: void 0
|
|
52
55
|
},
|
|
53
56
|
name,
|
|
54
57
|
id: `${name}-id`,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/inputs/AutoCompleteInput/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useCallback } from 'react';\nimport { ControlledFieldProps } from '@digigov/form/Field/types';\nimport { FieldOptionProps } from '@digigov/form/inputs/Label';\nimport {
|
|
5
|
-
"mappings": "AAAA,OAAO,SAAS,mBAAmB;AAGnC,SAAS,YAAY;AACrB,
|
|
4
|
+
"sourcesContent": ["import React, { useCallback } from 'react';\nimport { ControlledFieldProps } from '@digigov/form/Field/types';\nimport { FieldOptionProps } from '@digigov/form/inputs/Label';\nimport {\n AutoComplete,\n AutoCompleteProps as UIAutoCompleteProps,\n} from '@digigov/ui/form/AutoComplete';\nimport { Hint } from '@digigov/ui/typography/Hint';\nimport { Base } from '@digigov/ui/utils/Base';\nexport interface AutoCompleteInputExtra\n extends Omit<\n UIAutoCompleteProps,\n | 'source'\n | 'id'\n | 'templates'\n | 'defaultValue'\n | 'onConfirm'\n | 'dropdownArrow'\n > {\n options: FieldOptionProps[];\n}\n\nexport interface AutoCompleteInputProps\n extends Omit<ControlledFieldProps, 'value' | 'onChange' | 'extra'> {\n extra: AutoCompleteInputExtra;\n value: string;\n onChange: (v: string | string[] | undefined) => void;\n}\n\nexport const AutoCompleteInput: React.FC<AutoCompleteInputProps> = ({\n name,\n type,\n extra: { options },\n onChange,\n value,\n ...props\n}) => {\n const suggest = useCallback(\n function suggest(\n query: string,\n syncResults: (options: any[]) => void\n ): void {\n syncResults(\n query\n ? options.filter(function (option) {\n return (\n `${option.value} ${option.label?.primary || ''} ${\n option.label?.secondary || ''\n }`\n .toLowerCase()\n .indexOf(query.toLowerCase()) !== -1\n );\n })\n : options\n );\n },\n [options]\n );\n\n return (\n <AutoComplete\n multiple={type === 'choice:multiple' ? true : false}\n source={suggest}\n onConfirm={(value) => {\n if (Array.isArray(value)) {\n const selectedValues = value.map((item) => item.value);\n if (selectedValues.length > 0) onChange(selectedValues);\n else onChange(undefined);\n } else {\n onChange(value.value);\n }\n }}\n templates={{\n suggestion({ label, value }) {\n return (\n <Base as=\"div\">\n {(label && label.primary && label.primary) || value}\n {label && label.secondary && <Hint>{label.secondary}</Hint>}\n </Base>\n );\n },\n inputValue: (option) => {\n if (!option) {\n return '';\n }\n return option.label.primary || option.value;\n },\n }}\n {...{\n ...props,\n reset: undefined,\n required: undefined,\n Field: undefined,\n }}\n name={name}\n id={`${name}-id`}\n defaultValue={value}\n />\n );\n};\n\nexport default AutoCompleteInput;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS,mBAAmB;AAGnC;AAAA,EACE;AAAA,OAEK;AACP,SAAS,YAAY;AACrB,SAAS,YAAY;AAqBd,MAAM,oBAAsD,CAAC;AAAA,EAClE;AAAA,EACA;AAAA,EACA,OAAO,EAAE,QAAQ;AAAA,EACjB;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,UA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@@ -5,7 +5,7 @@ export interface CheckboxesProps extends Omit<ControlledFieldProps, 'extra' | 'v
|
|
|
5
5
|
value?: string[];
|
|
6
6
|
extra: {
|
|
7
7
|
className?: string;
|
|
8
|
-
options:
|
|
8
|
+
options: FieldOptionProps[];
|
|
9
9
|
};
|
|
10
10
|
fieldComponent: React.FC<Omit<ControlledFieldProps, 'value' | 'onChange'>>;
|
|
11
11
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import {
|
|
3
|
+
Checkbox,
|
|
4
|
+
CheckboxItem,
|
|
5
|
+
CheckboxConditional
|
|
6
|
+
} from "@digigov/ui/form/Checkbox";
|
|
6
7
|
import { useTranslation } from "@digigov/ui/i18n";
|
|
8
|
+
import { Hint } from "@digigov/ui/typography/Hint";
|
|
7
9
|
const Checkboxes = ({
|
|
8
10
|
name,
|
|
9
11
|
onChange,
|
|
@@ -33,7 +35,7 @@ const Checkboxes = ({
|
|
|
33
35
|
const [checked, setChecked] = useState(
|
|
34
36
|
Array(options.length).fill(false)
|
|
35
37
|
);
|
|
36
|
-
return /* @__PURE__ */ React.createElement(
|
|
38
|
+
return /* @__PURE__ */ React.createElement(Checkbox, { className }, options.map(
|
|
37
39
|
({
|
|
38
40
|
label,
|
|
39
41
|
value: v,
|
|
@@ -46,6 +48,7 @@ const Checkboxes = ({
|
|
|
46
48
|
{
|
|
47
49
|
key: `${name}.${index}`,
|
|
48
50
|
name: `${name}.${v}`,
|
|
51
|
+
id: `${name}.${v}`,
|
|
49
52
|
value: v,
|
|
50
53
|
disabled: disabled || optionDisabled,
|
|
51
54
|
checked: value?.includes(v),
|
|
@@ -55,6 +58,7 @@ const Checkboxes = ({
|
|
|
55
58
|
...props,
|
|
56
59
|
reset: void 0,
|
|
57
60
|
defaultValue: void 0,
|
|
61
|
+
error: void 0,
|
|
58
62
|
onBlur: void 0,
|
|
59
63
|
required: void 0,
|
|
60
64
|
"aria-describedby": void 0,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/inputs/Checkboxes/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useState } from 'react';\nimport { ControlledFieldProps } from '@digigov/form/Field/types';\nimport { FieldOptionProps } from '@digigov/form/inputs/Label';\nimport
|
|
5
|
-
"mappings": "AAAA,OAAO,SAAS,gBAAgB;AAGhC,
|
|
4
|
+
"sourcesContent": ["import React, { useState } from 'react';\nimport { ControlledFieldProps } from '@digigov/form/Field/types';\nimport { FieldOptionProps } from '@digigov/form/inputs/Label';\nimport {\n Checkbox,\n CheckboxItem,\n CheckboxConditional,\n} from '@digigov/ui/form/Checkbox';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport { Hint } from '@digigov/ui/typography/Hint';\n\nexport interface CheckboxesProps\n extends Omit<ControlledFieldProps, 'extra' | 'value'> {\n value?: string[];\n extra: {\n className?: string;\n options: FieldOptionProps[];\n };\n fieldComponent: React.FC<Omit<ControlledFieldProps, 'value' | 'onChange'>>;\n}\n\nexport const Checkboxes: React.FC<CheckboxesProps> = ({\n name,\n onChange,\n value,\n extra: { options, className },\n disabled,\n Field,\n ...props\n}) => {\n if (!value) value = [];\n const handleChange =\n (optionValue, idx, show) =>\n (evt): void => {\n let newValue;\n if (evt.currentTarget.checked) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n newValue = value.concat([optionValue]);\n } else {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n newValue = value.filter((val) => val !== optionValue);\n }\n if (show && show.length > 0) {\n setChecked((items) =>\n items.map((item, index) => (index === idx ? !item : item))\n );\n }\n\n // reset value to undefined instead of an empty array\n // so the error state mechanism can throw validation errors\n if (newValue.length === 0) newValue = undefined;\n onChange(newValue);\n };\n const { t } = useTranslation();\n const [checked, setChecked] = useState(\n Array<boolean>(options.length).fill(false)\n );\n return (\n <Checkbox className={className}>\n {options.map(\n (\n {\n label,\n value: v,\n show,\n disabled: optionDisabled,\n selected,\n ...option\n },\n index\n ) => (\n <React.Fragment key={index}>\n <CheckboxItem\n key={`${name}.${index}`}\n name={`${name}.${v}`}\n id={`${name}.${v}`}\n value={v}\n disabled={disabled || optionDisabled}\n checked={value?.includes(v)}\n onChange={handleChange(v, index, show)}\n {...option}\n {...{\n ...props,\n reset: undefined,\n defaultValue: undefined,\n error: undefined,\n onBlur: undefined,\n required: undefined,\n 'aria-describedby': undefined,\n type: 'checkbox',\n }}\n >\n {(label && label.primary && t(label.primary)) || value}\n {label && label.secondary && <Hint>{t(label.secondary)}</Hint>}\n </CheckboxItem>\n\n {!!checked[index] && show && Field && (\n <CheckboxConditional>\n {show.map((fieldName) => (\n <Field name={fieldName} key={fieldName} />\n ))}\n </CheckboxConditional>\n )}\n {selected && selected()}\n </React.Fragment>\n )\n )}\n </Checkbox>\n );\n};\n\nexport default Checkboxes;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS,gBAAgB;AAGhC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,SAAS,YAAY;AAYd,MAAM,aAAwC,CAAC;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO,EAAE,SAAS,UAAU;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,MAAI,CAAC,MAAO,SAAQ,CAAC;AACrB,QAAM,eACJ,CAAC,aAAa,KAAK,SACnB,CAAC,QAAc;AACb,QAAI;AACJ,QAAI,IAAI,cAAc,SAAS;AAG7B,iBAAW,MAAM,OAAO,CAAC,WAAW,CAAC;AAAA,IACvC,OAAO;AAGL,iBAAW,MAAM,OAAO,CAAC,QAAQ,QAAQ,WAAW;AAAA,IACtD;AACA,QAAI,QAAQ,KAAK,SAAS,GAAG;AAC3B;AAAA,QAAW,CAAC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;AAAA,EAEJ,CACF;AAEJ;AAEA,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -6,9 +6,8 @@ export interface DateInputProps extends Omit<UncontrolledFieldProps, 'extra'> {
|
|
|
6
6
|
min?: string;
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
-
export declare const DateInput: ({ name,
|
|
9
|
+
export declare const DateInput: ({ name, ...props }: {
|
|
10
10
|
[x: string]: any;
|
|
11
11
|
name: any;
|
|
12
|
-
type: any;
|
|
13
12
|
}) => React.JSX.Element;
|
|
14
13
|
export default DateInput;
|