@digigov/form 2.0.0-264e5fff → 2.0.0-290ada95
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.d.ts +2 -2
- package/Field/ErrorGroup.js +53 -0
- package/Field/FieldBase.d.ts +1 -1
- package/Field/FieldBase.js +77 -0
- package/Field/FieldBaseContainer.d.ts +1 -1
- package/Field/FieldBaseContainer.js +43 -0
- package/Field/FieldConditional.d.ts +1 -1
- package/Field/FieldConditional.js +45 -0
- package/Field/index.d.ts +1 -1
- package/Field/index.js +69 -107
- package/Field/types.d.ts +3 -3
- package/Field/types.js +0 -0
- package/Field/utils/evaluateFieldWithConditions.d.ts +1 -1
- package/Field/utils/evaluateFieldWithConditions.js +19 -0
- package/Field/utils/resolveField.d.ts +2 -2
- package/Field/utils/resolveField.js +32 -0
- package/Field/utils/useField.d.ts +1 -1
- package/Field/utils/useField.js +47 -0
- package/FieldArray/BaseFieldArray.d.ts +1 -1
- package/FieldArray/BaseFieldArray.js +46 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.js +13 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.js +117 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.js +6 -0
- package/FieldArray/FormDialog/ArrayDisplay/index.js +32 -57
- package/FieldArray/FormDialog/ArrayEditModal.d.ts +1 -1
- package/FieldArray/FormDialog/ArrayEditModal.js +138 -0
- package/FieldArray/FormDialog/index.d.ts +1 -1
- package/FieldArray/FormDialog/index.js +142 -177
- package/FieldArray/index.d.ts +2 -2
- package/FieldArray/index.js +59 -86
- package/FieldObject/index.d.ts +2 -2
- package/FieldObject/index.js +52 -77
- package/Fieldset/FieldsetWithContext.js +27 -0
- package/Fieldset/index.d.ts +1 -1
- package/Fieldset/index.js +18 -30
- package/Fieldset/types.js +0 -0
- package/FormBuilder/index.d.ts +2 -2
- package/FormBuilder/index.js +226 -254
- package/FormContext.d.ts +1 -1
- package/FormContext.js +7 -0
- package/MultiplicityField/add-objects.d.ts +1 -1
- package/MultiplicityField/add-objects.js +107 -0
- package/MultiplicityField/index.d.ts +1 -1
- package/MultiplicityField/index.js +81 -119
- package/MultiplicityField/types.d.ts +1 -1
- package/MultiplicityField/types.js +0 -0
- package/Questions/Questions.d.ts +1 -1
- package/Questions/Questions.js +48 -0
- package/Questions/QuestionsContext.d.ts +1 -1
- package/Questions/QuestionsContext.js +10 -0
- package/Questions/Step/ReviewStep.js +32 -0
- package/Questions/Step/Step.d.ts +1 -1
- package/Questions/Step/Step.js +39 -0
- package/Questions/Step/StepArrayReview.d.ts +1 -1
- package/Questions/Step/StepArrayReview.js +35 -0
- package/Questions/Step/StepContext.d.ts +1 -1
- package/Questions/Step/StepContext.js +28 -0
- package/Questions/Step/StepDescription.js +18 -0
- package/Questions/Step/StepForm.d.ts +2 -2
- package/Questions/Step/StepForm.js +29 -0
- package/Questions/Step/StepQuote.js +5 -0
- package/Questions/Step/StepTitle.js +25 -0
- package/Questions/Step/getAddMoreFields.d.ts +2 -2
- package/Questions/Step/getAddMoreFields.js +24 -0
- package/Questions/Step/index.d.ts +11 -11
- package/Questions/Step/index.js +13 -16
- package/Questions/Step/types.d.ts +1 -1
- package/Questions/Step/types.js +0 -0
- package/Questions/getNextStep.d.ts +1 -1
- package/Questions/getNextStep.js +13 -0
- package/Questions/index.d.ts +2 -2
- package/Questions/index.js +4 -7
- package/Questions/types.d.ts +1 -1
- package/Questions/types.js +0 -0
- package/hooks/useFieldFocusManager.js +83 -0
- package/hooks/utils.js +60 -0
- package/index.d.ts +5 -5
- package/index.js +8 -13
- package/inputs/AutoCompleteInput/index.d.ts +2 -2
- package/inputs/AutoCompleteInput/index.js +38 -60
- package/inputs/Checkboxes/index.d.ts +2 -2
- package/inputs/Checkboxes/index.js +43 -76
- package/inputs/DateInput/index.d.ts +1 -1
- package/inputs/DateInput/index.js +123 -147
- package/inputs/DateTimeInput/index.d.ts +1 -1
- package/inputs/DateTimeInput/index.js +177 -207
- package/inputs/FileInput/index.d.ts +1 -1
- package/inputs/FileInput/index.js +54 -70
- package/inputs/ImageInput/index.d.ts +1 -1
- package/inputs/ImageInput/index.js +74 -74
- package/inputs/Input/index.d.ts +1 -1
- package/inputs/Input/index.js +60 -73
- package/inputs/Label/index.d.ts +1 -1
- package/inputs/Label/index.js +13 -16
- package/inputs/OtpInput/index.js +116 -145
- package/inputs/Radio/index.d.ts +2 -2
- package/inputs/Radio/index.js +70 -103
- package/inputs/Select/index.d.ts +2 -2
- package/inputs/Select/index.js +23 -32
- package/inputs/index.d.ts +9 -9
- package/inputs/index.js +10 -21
- package/inputs/registry.d.ts +1 -1
- package/inputs/registry.js +80 -0
- package/internal.d.ts +5 -5
- package/internal.js +6 -0
- package/lazy.d.ts +97 -0
- package/lazy.js +163 -0
- package/package.json +8 -8
- package/registry.d.ts +82 -0
- package/registry.js +170 -0
- package/src/Field/ErrorGroup.tsx +1 -1
- package/src/FormBuilder/doc.mdx +1 -1
- package/src/inputs/AutoCompleteInput/doc.mdx +2 -2
- package/src/inputs/Checkboxes/doc.mdx +3 -3
- package/src/inputs/DateInput/doc.mdx +1 -1
- package/src/inputs/DateTimeInput/doc.mdx +1 -1
- package/src/inputs/FileInput/doc.mdx +1 -1
- package/src/inputs/ImageInput/doc.mdx +3 -3
- package/src/inputs/Input/doc.mdx +10 -10
- package/src/inputs/Label/doc.mdx +1 -1
- package/src/inputs/OtpInput/doc.mdx +1 -1
- package/src/inputs/Radio/doc.mdx +3 -3
- package/src/inputs/Select/doc.mdx +1 -1
- package/{lazy/index.js → src/lazy.ts} +0 -25
- package/types.d.ts +4 -4
- package/types.js +1 -0
- package/utils.js +56 -0
- package/validators/index.d.ts +2 -2
- package/validators/index.js +112 -159
- package/validators/types.js +0 -0
- package/validators/utils/afm.js +19 -0
- package/validators/utils/amka.js +27 -0
- package/validators/utils/date.d.ts +2 -2
- package/validators/utils/date.js +95 -0
- package/validators/utils/datetime.d.ts +2 -2
- package/validators/utils/datetime.js +121 -0
- package/validators/utils/email.js +10 -0
- package/validators/utils/file.d.ts +2 -2
- package/validators/utils/file.js +31 -0
- package/validators/utils/iban.d.ts +2 -2
- package/validators/utils/iban.js +104 -0
- package/validators/utils/image.d.ts +2 -2
- package/validators/utils/image.js +65 -0
- package/validators/utils/index.d.ts +14 -14
- package/validators/utils/index.js +58 -96
- package/validators/utils/int.d.ts +1 -1
- package/validators/utils/int.js +13 -0
- package/validators/utils/number.d.ts +1 -1
- package/validators/utils/number.js +12 -0
- package/validators/utils/otp.d.ts +2 -2
- package/validators/utils/otp.js +21 -0
- package/validators/utils/phone.d.ts +2 -2
- package/validators/utils/phone.js +198 -0
- package/validators/utils/postal_code.d.ts +2 -2
- package/validators/utils/postal_code.js +18 -0
- package/validators/utils/text_limit.d.ts +2 -2
- package/validators/utils/text_limit.js +34 -0
- package/validators/utils/uuid4.js +14 -0
- package/Field/ErrorGroup/index.js +0 -48
- package/Field/ErrorGroup/package.json +0 -6
- package/Field/ErrorGroup.js.map +0 -7
- package/Field/FieldBase/index.js +0 -122
- package/Field/FieldBase/package.json +0 -6
- package/Field/FieldBase.js.map +0 -7
- package/Field/FieldBaseContainer/index.js +0 -52
- package/Field/FieldBaseContainer/package.json +0 -6
- package/Field/FieldBaseContainer.js.map +0 -7
- package/Field/FieldConditional/index.js +0 -89
- package/Field/FieldConditional/package.json +0 -6
- package/Field/FieldConditional.js.map +0 -7
- package/Field/index.js.map +0 -7
- package/Field/package.json +0 -6
- package/Field/types/index.js +0 -1
- package/Field/types/package.json +0 -6
- package/Field/types.js.map +0 -7
- package/Field/utils/evaluateFieldWithConditions/index.js +0 -26
- package/Field/utils/evaluateFieldWithConditions/package.json +0 -6
- package/Field/utils/evaluateFieldWithConditions.js.map +0 -7
- package/Field/utils/resolveField/index.js +0 -35
- package/Field/utils/resolveField/package.json +0 -6
- package/Field/utils/resolveField.js.map +0 -7
- package/Field/utils/useField/index.js +0 -66
- package/Field/utils/useField/package.json +0 -6
- package/Field/utils/useField.js.map +0 -7
- package/FieldArray/BaseFieldArray/index.js +0 -76
- package/FieldArray/BaseFieldArray/package.json +0 -6
- package/FieldArray/BaseFieldArray.js.map +0 -7
- package/FieldArray/FieldArray.stories.d.ts +0 -11
- package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay/index.js +0 -23
- package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay/package.json +0 -6
- package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.js.map +0 -7
- package/FieldArray/FormDialog/ArrayDisplay/ArrayDisplay.stories.d.ts +0 -13
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay/index.js +0 -184
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay/package.json +0 -6
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.js.map +0 -7
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader/index.js +0 -11
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader/package.json +0 -6
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.js.map +0 -7
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/Cards.d.ts +0 -2
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/Default.d.ts +0 -2
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnly.d.ts +0 -2
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnlyCards.d.ts +0 -2
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/Sortable.d.ts +0 -2
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/SortableCards.d.ts +0 -2
- package/FieldArray/FormDialog/ArrayDisplay/index.js.map +0 -7
- package/FieldArray/FormDialog/ArrayDisplay/package.json +0 -6
- package/FieldArray/FormDialog/ArrayEditModal/index.js +0 -158
- package/FieldArray/FormDialog/ArrayEditModal/package.json +0 -6
- package/FieldArray/FormDialog/ArrayEditModal.js.map +0 -7
- package/FieldArray/FormDialog/index.js.map +0 -7
- package/FieldArray/FormDialog/package.json +0 -6
- package/FieldArray/__stories__/CardsWithError.d.ts +0 -15
- package/FieldArray/__stories__/Default.d.ts +0 -2
- package/FieldArray/__stories__/WithExactLength.d.ts +0 -2
- package/FieldArray/__stories__/WithModal.d.ts +0 -2
- package/FieldArray/index.js.map +0 -7
- package/FieldArray/package.json +0 -6
- package/FieldObject/index.js.map +0 -7
- package/FieldObject/package.json +0 -6
- package/Fieldset/FieldsetWithContext/index.js +0 -31
- package/Fieldset/FieldsetWithContext/package.json +0 -6
- package/Fieldset/FieldsetWithContext.js.map +0 -7
- package/Fieldset/index.js.map +0 -7
- package/Fieldset/package.json +0 -6
- package/Fieldset/types/index.js +0 -1
- package/Fieldset/types/package.json +0 -6
- package/Fieldset/types.js.map +0 -7
- package/Form.stories.d.ts +0 -4
- package/FormBuilder/FormBuilder.stories.d.ts +0 -12
- package/FormBuilder/__stories__/AutoErrorGrouping.d.ts +0 -3
- package/FormBuilder/__stories__/Default.d.ts +0 -3
- package/FormBuilder/__stories__/ErrorGrouping.d.ts +0 -3
- package/FormBuilder/index.js.map +0 -7
- package/FormBuilder/package.json +0 -6
- package/FormContext/index.js +0 -13
- package/FormContext/package.json +0 -6
- package/FormContext.js.map +0 -7
- package/MultiplicityField/MultiplicityField.stories.d.ts +0 -15
- package/MultiplicityField/__stories__/Default.d.ts +0 -2
- package/MultiplicityField/__stories__/PreviewDisplay.d.ts +0 -2
- package/MultiplicityField/__stories__/WithExactLength.d.ts +0 -2
- package/MultiplicityField/__stories__/WithMaxLength.d.ts +0 -2
- package/MultiplicityField/__stories__/WithMinAndMaxLength.d.ts +0 -2
- package/MultiplicityField/__stories__/WithMinLength.d.ts +0 -2
- package/MultiplicityField/add-objects/index.js +0 -146
- package/MultiplicityField/add-objects/package.json +0 -6
- package/MultiplicityField/add-objects.js.map +0 -7
- package/MultiplicityField/index.js.map +0 -7
- package/MultiplicityField/package.json +0 -6
- package/MultiplicityField/types/index.js +0 -1
- package/MultiplicityField/types/package.json +0 -6
- package/MultiplicityField/types.js.map +0 -7
- package/Questions/Questions/index.js +0 -67
- package/Questions/Questions/package.json +0 -6
- package/Questions/Questions.js.map +0 -7
- package/Questions/Questions.stories.d.ts +0 -10
- package/Questions/QuestionsContext/index.js +0 -11
- package/Questions/QuestionsContext/package.json +0 -6
- package/Questions/QuestionsContext.js.map +0 -7
- package/Questions/Step/ReviewStep/index.js +0 -38
- package/Questions/Step/ReviewStep/package.json +0 -6
- package/Questions/Step/ReviewStep.js.map +0 -7
- package/Questions/Step/Step/index.js +0 -54
- package/Questions/Step/Step/package.json +0 -6
- package/Questions/Step/Step.js.map +0 -7
- package/Questions/Step/StepArrayReview/index.js +0 -42
- package/Questions/Step/StepArrayReview/package.json +0 -6
- package/Questions/Step/StepArrayReview.js.map +0 -7
- package/Questions/Step/StepContext/index.js +0 -23
- package/Questions/Step/StepContext/package.json +0 -6
- package/Questions/Step/StepContext.js.map +0 -7
- package/Questions/Step/StepDescription/index.js +0 -24
- package/Questions/Step/StepDescription/package.json +0 -6
- package/Questions/Step/StepDescription.js.map +0 -7
- package/Questions/Step/StepForm/index.js +0 -34
- package/Questions/Step/StepForm/package.json +0 -6
- package/Questions/Step/StepForm.js.map +0 -7
- package/Questions/Step/StepQuote/index.js +0 -11
- package/Questions/Step/StepQuote/package.json +0 -6
- package/Questions/Step/StepQuote.js.map +0 -7
- package/Questions/Step/StepTitle/index.js +0 -44
- package/Questions/Step/StepTitle/package.json +0 -6
- package/Questions/Step/StepTitle.js.map +0 -7
- package/Questions/Step/getAddMoreFields/index.js +0 -29
- package/Questions/Step/getAddMoreFields/package.json +0 -6
- package/Questions/Step/getAddMoreFields.js.map +0 -7
- package/Questions/Step/index.js.map +0 -7
- package/Questions/Step/package.json +0 -6
- package/Questions/Step/types/index.js +0 -1
- package/Questions/Step/types/package.json +0 -6
- package/Questions/Step/types.js.map +0 -7
- package/Questions/__stories__/Default.d.ts +0 -3
- package/Questions/getNextStep/index.js +0 -22
- package/Questions/getNextStep/package.json +0 -6
- package/Questions/getNextStep.js.map +0 -7
- package/Questions/index.js.map +0 -7
- package/Questions/package.json +0 -6
- package/Questions/types/index.js +0 -1
- package/Questions/types/package.json +0 -6
- package/Questions/types.js.map +0 -7
- package/cjs/Field/ErrorGroup/index.js +0 -82
- package/cjs/Field/ErrorGroup.js.map +0 -7
- package/cjs/Field/FieldBase/index.js +0 -155
- package/cjs/Field/FieldBase.js.map +0 -7
- package/cjs/Field/FieldBaseContainer/index.js +0 -85
- package/cjs/Field/FieldBaseContainer.js.map +0 -7
- package/cjs/Field/FieldConditional/index.js +0 -122
- package/cjs/Field/FieldConditional.js.map +0 -7
- package/cjs/Field/index.js +0 -143
- package/cjs/Field/index.js.map +0 -7
- package/cjs/Field/types/index.js +0 -16
- package/cjs/Field/types.js.map +0 -7
- package/cjs/Field/utils/evaluateFieldWithConditions/index.js +0 -49
- package/cjs/Field/utils/evaluateFieldWithConditions.js.map +0 -7
- package/cjs/Field/utils/resolveField/index.js +0 -55
- package/cjs/Field/utils/resolveField.js.map +0 -7
- package/cjs/Field/utils/useField/index.js +0 -89
- package/cjs/Field/utils/useField.js.map +0 -7
- package/cjs/FieldArray/BaseFieldArray/index.js +0 -109
- package/cjs/FieldArray/BaseFieldArray.js.map +0 -7
- package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay/index.js +0 -56
- package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.js.map +0 -7
- package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay/index.js +0 -209
- package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.js.map +0 -7
- package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader/index.js +0 -44
- package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.js.map +0 -7
- package/cjs/FieldArray/FormDialog/ArrayDisplay/index.js +0 -90
- package/cjs/FieldArray/FormDialog/ArrayDisplay/index.js.map +0 -7
- package/cjs/FieldArray/FormDialog/ArrayEditModal/index.js +0 -186
- package/cjs/FieldArray/FormDialog/ArrayEditModal.js.map +0 -7
- package/cjs/FieldArray/FormDialog/index.js +0 -261
- package/cjs/FieldArray/FormDialog/index.js.map +0 -7
- package/cjs/FieldArray/index.js +0 -126
- package/cjs/FieldArray/index.js.map +0 -7
- package/cjs/FieldObject/index.js +0 -113
- package/cjs/FieldObject/index.js.map +0 -7
- package/cjs/Fieldset/FieldsetWithContext/index.js +0 -59
- package/cjs/Fieldset/FieldsetWithContext.js.map +0 -7
- package/cjs/Fieldset/index.js +0 -66
- package/cjs/Fieldset/index.js.map +0 -7
- package/cjs/Fieldset/types/index.js +0 -16
- package/cjs/Fieldset/types.js.map +0 -7
- package/cjs/FormBuilder/index.js +0 -303
- package/cjs/FormBuilder/index.js.map +0 -7
- package/cjs/FormContext/index.js +0 -37
- package/cjs/FormContext.js.map +0 -7
- package/cjs/MultiplicityField/add-objects/index.js +0 -179
- package/cjs/MultiplicityField/add-objects.js.map +0 -7
- package/cjs/MultiplicityField/index.js +0 -153
- package/cjs/MultiplicityField/index.js.map +0 -7
- package/cjs/MultiplicityField/types/index.js +0 -16
- package/cjs/MultiplicityField/types.js.map +0 -7
- package/cjs/Questions/Questions/index.js +0 -100
- package/cjs/Questions/Questions.js.map +0 -7
- package/cjs/Questions/QuestionsContext/index.js +0 -34
- package/cjs/Questions/QuestionsContext.js.map +0 -7
- package/cjs/Questions/Step/ReviewStep/index.js +0 -65
- package/cjs/Questions/Step/ReviewStep.js.map +0 -7
- package/cjs/Questions/Step/Step/index.js +0 -87
- package/cjs/Questions/Step/Step.js.map +0 -7
- package/cjs/Questions/Step/StepArrayReview/index.js +0 -67
- package/cjs/Questions/Step/StepArrayReview.js.map +0 -7
- package/cjs/Questions/Step/StepContext/index.js +0 -46
- package/cjs/Questions/Step/StepContext.js.map +0 -7
- package/cjs/Questions/Step/StepDescription/index.js +0 -58
- package/cjs/Questions/Step/StepDescription.js.map +0 -7
- package/cjs/Questions/Step/StepForm/index.js +0 -67
- package/cjs/Questions/Step/StepForm.js.map +0 -7
- package/cjs/Questions/Step/StepQuote/index.js +0 -44
- package/cjs/Questions/Step/StepQuote.js.map +0 -7
- package/cjs/Questions/Step/StepTitle/index.js +0 -76
- package/cjs/Questions/Step/StepTitle.js.map +0 -7
- package/cjs/Questions/Step/getAddMoreFields/index.js +0 -52
- package/cjs/Questions/Step/getAddMoreFields.js.map +0 -7
- package/cjs/Questions/Step/index.js +0 -59
- package/cjs/Questions/Step/index.js.map +0 -7
- package/cjs/Questions/Step/types/index.js +0 -16
- package/cjs/Questions/Step/types.js.map +0 -7
- package/cjs/Questions/getNextStep/index.js +0 -45
- package/cjs/Questions/getNextStep.js.map +0 -7
- package/cjs/Questions/index.js +0 -31
- package/cjs/Questions/index.js.map +0 -7
- package/cjs/Questions/types/index.js +0 -16
- package/cjs/Questions/types.js.map +0 -7
- package/cjs/hooks/useFieldFocusManager/index.js +0 -135
- package/cjs/hooks/useFieldFocusManager.js.map +0 -7
- package/cjs/hooks/utils/index.js +0 -98
- package/cjs/hooks/utils.js.map +0 -7
- package/cjs/index.js +0 -49
- package/cjs/index.js.map +0 -7
- package/cjs/inputs/AutoCompleteInput/index.js +0 -98
- package/cjs/inputs/AutoCompleteInput/index.js.map +0 -7
- package/cjs/inputs/Checkboxes/index.js +0 -112
- package/cjs/inputs/Checkboxes/index.js.map +0 -7
- package/cjs/inputs/DateInput/index.js +0 -188
- package/cjs/inputs/DateInput/index.js.map +0 -7
- package/cjs/inputs/DateTimeInput/index.js +0 -250
- package/cjs/inputs/DateTimeInput/index.js.map +0 -7
- package/cjs/inputs/FileInput/index.js +0 -110
- package/cjs/inputs/FileInput/index.js.map +0 -7
- package/cjs/inputs/ImageInput/__stories__/logo.d/index.js +0 -1
- package/cjs/inputs/ImageInput/__stories__/logo.d.js.map +0 -7
- package/cjs/inputs/ImageInput/index.js +0 -130
- package/cjs/inputs/ImageInput/index.js.map +0 -7
- package/cjs/inputs/Input/index.js +0 -115
- package/cjs/inputs/Input/index.js.map +0 -7
- package/cjs/inputs/Label/index.js +0 -50
- package/cjs/inputs/Label/index.js.map +0 -7
- package/cjs/inputs/OtpInput/index.js +0 -186
- package/cjs/inputs/OtpInput/index.js.map +0 -7
- package/cjs/inputs/Radio/index.js +0 -136
- package/cjs/inputs/Radio/index.js.map +0 -7
- package/cjs/inputs/Select/index.js +0 -63
- package/cjs/inputs/Select/index.js.map +0 -7
- package/cjs/inputs/index.js +0 -62
- package/cjs/inputs/index.js.map +0 -7
- package/cjs/inputs/registry/index.js +0 -121
- package/cjs/inputs/registry.js.map +0 -7
- package/cjs/internal/index.js +0 -38
- package/cjs/internal.js.map +0 -7
- package/cjs/lazy/index.js +0 -114
- package/cjs/lazy.js.map +0 -7
- package/cjs/registry/index.js +0 -209
- package/cjs/registry.js.map +0 -7
- package/cjs/types/index.js +0 -22
- package/cjs/types.js.map +0 -7
- package/cjs/utils/index.js +0 -106
- package/cjs/utils.js.map +0 -7
- package/cjs/validators/index.js +0 -179
- package/cjs/validators/index.js.map +0 -7
- package/cjs/validators/types/index.js +0 -16
- package/cjs/validators/types.js.map +0 -7
- package/cjs/validators/utils/afm/index.js +0 -55
- package/cjs/validators/utils/afm.js.map +0 -7
- package/cjs/validators/utils/amka/index.js +0 -60
- package/cjs/validators/utils/amka.js.map +0 -7
- package/cjs/validators/utils/date/index.js +0 -161
- package/cjs/validators/utils/date.js.map +0 -7
- package/cjs/validators/utils/datetime/index.js +0 -245
- package/cjs/validators/utils/datetime.js.map +0 -7
- package/cjs/validators/utils/email/index.js +0 -39
- package/cjs/validators/utils/email.js.map +0 -7
- package/cjs/validators/utils/file/index.js +0 -61
- package/cjs/validators/utils/file.js.map +0 -7
- package/cjs/validators/utils/iban/index.js +0 -142
- package/cjs/validators/utils/iban.js.map +0 -7
- package/cjs/validators/utils/image/index.js +0 -102
- package/cjs/validators/utils/image.js.map +0 -7
- package/cjs/validators/utils/index.js +0 -152
- package/cjs/validators/utils/index.js.map +0 -7
- package/cjs/validators/utils/int/index.js +0 -48
- package/cjs/validators/utils/int.js.map +0 -7
- package/cjs/validators/utils/number/index.js +0 -44
- package/cjs/validators/utils/number.js.map +0 -7
- package/cjs/validators/utils/otp/index.js +0 -54
- package/cjs/validators/utils/otp.js.map +0 -7
- package/cjs/validators/utils/phone/index.js +0 -198
- package/cjs/validators/utils/phone.js.map +0 -7
- package/cjs/validators/utils/postal_code/index.js +0 -54
- package/cjs/validators/utils/postal_code.js.map +0 -7
- package/cjs/validators/utils/text_limit/index.js +0 -69
- package/cjs/validators/utils/text_limit.js.map +0 -7
- package/cjs/validators/utils/uuid4/index.js +0 -46
- package/cjs/validators/utils/uuid4.js.map +0 -7
- package/hooks/__tests__/utils.spec.d.ts +0 -1
- package/hooks/useFieldFocusManager/index.js +0 -116
- package/hooks/useFieldFocusManager/package.json +0 -6
- package/hooks/useFieldFocusManager.js.map +0 -7
- package/hooks/utils/index.js +0 -73
- package/hooks/utils/package.json +0 -6
- package/hooks/utils.js.map +0 -7
- package/index.js.map +0 -7
- package/inputs/AutoCompleteInput/AutoComplete.stories.d.ts +0 -11
- package/inputs/AutoCompleteInput/__stories__/Default.d.ts +0 -3
- package/inputs/AutoCompleteInput/__stories__/Multiple.d.ts +0 -3
- package/inputs/AutoCompleteInput/index.js.map +0 -7
- package/inputs/AutoCompleteInput/package.json +0 -6
- package/inputs/Checkboxes/Checkboxes.stories.d.ts +0 -12
- package/inputs/Checkboxes/__stories__/Conditional.d.ts +0 -3
- package/inputs/Checkboxes/__stories__/Default.d.ts +0 -3
- package/inputs/Checkboxes/__stories__/WithDivider.d.ts +0 -3
- package/inputs/Checkboxes/index.js.map +0 -7
- package/inputs/Checkboxes/package.json +0 -6
- package/inputs/DateInput/DateInput.stories.d.ts +0 -14
- package/inputs/DateInput/__stories__/Default.d.ts +0 -3
- package/inputs/DateInput/__stories__/WithDefaultValue.d.ts +0 -3
- package/inputs/DateInput/__stories__/WithInitialValue.d.ts +0 -3
- package/inputs/DateInput/__stories__/WithWrongDefaultValue.d.ts +0 -3
- package/inputs/DateInput/__stories__/WithWrongInitialValue.d.ts +0 -3
- package/inputs/DateInput/index.js.map +0 -7
- package/inputs/DateInput/package.json +0 -6
- package/inputs/DateTimeInput/DateTimeInput.stories.d.ts +0 -14
- package/inputs/DateTimeInput/__stories__/Default.d.ts +0 -3
- package/inputs/DateTimeInput/__stories__/WithDefaultValue.d.ts +0 -3
- package/inputs/DateTimeInput/__stories__/WithInitialValue.d.ts +0 -3
- package/inputs/DateTimeInput/__stories__/WithWrongDefaultValue.d.ts +0 -3
- package/inputs/DateTimeInput/__stories__/WithWrongInitialValue.d.ts +0 -3
- package/inputs/DateTimeInput/index.js.map +0 -7
- package/inputs/DateTimeInput/package.json +0 -6
- package/inputs/FileInput/FileInput.stories.d.ts +0 -11
- package/inputs/FileInput/__stories__/Default.d.ts +0 -3
- package/inputs/FileInput/__stories__/WithBorderAndLink.d.ts +0 -3
- package/inputs/FileInput/index.js.map +0 -7
- package/inputs/FileInput/package.json +0 -6
- package/inputs/ImageInput/ImageInput.stories.d.ts +0 -13
- package/inputs/ImageInput/__stories__/Default.d.ts +0 -3
- package/inputs/ImageInput/__stories__/MaxSize.d.ts +0 -3
- package/inputs/ImageInput/__stories__/WithInitialValues.d.ts +0 -3
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension.d.ts +0 -3
- package/inputs/ImageInput/__stories__/logo.d/index.js +0 -1
- package/inputs/ImageInput/__stories__/logo.d/package.json +0 -6
- package/inputs/ImageInput/__stories__/logo.d.js.map +0 -7
- package/inputs/ImageInput/index.js.map +0 -7
- package/inputs/ImageInput/package.json +0 -6
- package/inputs/Input/Input.stories.d.ts +0 -23
- package/inputs/Input/__stories__/AFM.d.ts +0 -3
- package/inputs/Input/__stories__/AMKA.d.ts +0 -3
- package/inputs/Input/__stories__/Boolean.d.ts +0 -3
- package/inputs/Input/__stories__/Email.d.ts +0 -3
- package/inputs/Input/__stories__/IBAN.d.ts +0 -3
- package/inputs/Input/__stories__/Integer.d.ts +0 -3
- package/inputs/Input/__stories__/LandlineNumber.d.ts +0 -3
- package/inputs/Input/__stories__/MobilePhone.d.ts +0 -3
- package/inputs/Input/__stories__/PhoneNumber.d.ts +0 -3
- package/inputs/Input/__stories__/PostalCode.d.ts +0 -3
- package/inputs/Input/__stories__/Rate.d.ts +0 -3
- package/inputs/Input/__stories__/String.d.ts +0 -3
- package/inputs/Input/__stories__/StringWithTrimValidation.d.ts +0 -3
- package/inputs/Input/__stories__/TextWithLimit.d.ts +0 -3
- package/inputs/Input/index.js.map +0 -7
- package/inputs/Input/package.json +0 -6
- package/inputs/Label/Label.stories.d.ts +0 -10
- package/inputs/Label/__stories__/Default.d.ts +0 -3
- package/inputs/Label/index.js.map +0 -7
- package/inputs/Label/package.json +0 -6
- package/inputs/OtpInput/OtpInput.stories.d.ts +0 -10
- package/inputs/OtpInput/__stories__/Default.d.ts +0 -3
- package/inputs/OtpInput/index.js.map +0 -7
- package/inputs/OtpInput/package.json +0 -6
- package/inputs/Radio/Radio.stories.d.ts +0 -12
- package/inputs/Radio/__stories__/Conditional.d.ts +0 -3
- package/inputs/Radio/__stories__/Default.d.ts +0 -3
- package/inputs/Radio/__stories__/WithDivider.d.ts +0 -3
- package/inputs/Radio/index.js.map +0 -7
- package/inputs/Radio/package.json +0 -6
- package/inputs/Select/Select.stories.d.ts +0 -10
- package/inputs/Select/__stories__/Default.d.ts +0 -3
- package/inputs/Select/index.js.map +0 -7
- package/inputs/Select/package.json +0 -6
- package/inputs/index.js.map +0 -7
- package/inputs/package.json +0 -6
- package/inputs/registry/index.js +0 -86
- package/inputs/registry/package.json +0 -6
- package/inputs/registry.js.map +0 -7
- package/internal/index.js +0 -10
- package/internal/package.json +0 -6
- package/internal.js.map +0 -7
- package/lazy/package.json +0 -6
- package/registry/index.js +0 -179
- package/registry/package.json +0 -6
- package/src/lazy.js +0 -81
- package/types/index.js +0 -2
- package/types/package.json +0 -6
- package/types.js.map +0 -7
- package/utils/index.js +0 -82
- package/utils/package.json +0 -6
- package/utils.js.map +0 -7
- package/validators/index.js.map +0 -7
- package/validators/package.json +0 -6
- package/validators/types/index.js +0 -1
- package/validators/types/package.json +0 -6
- package/validators/types.js.map +0 -7
- package/validators/utils/afm/index.js +0 -31
- package/validators/utils/afm/package.json +0 -6
- package/validators/utils/afm.js.map +0 -7
- package/validators/utils/amka/index.js +0 -36
- package/validators/utils/amka/package.json +0 -6
- package/validators/utils/amka.js.map +0 -7
- package/validators/utils/date/index.js +0 -126
- package/validators/utils/date/package.json +0 -6
- package/validators/utils/date.js.map +0 -7
- package/validators/utils/datetime/index.js +0 -210
- package/validators/utils/datetime/package.json +0 -6
- package/validators/utils/datetime.js.map +0 -7
- package/validators/utils/email/index.js +0 -16
- package/validators/utils/email/package.json +0 -6
- package/validators/utils/email.js.map +0 -7
- package/validators/utils/file/index.js +0 -38
- package/validators/utils/file/package.json +0 -6
- package/validators/utils/file.js.map +0 -7
- package/validators/utils/iban/index.js +0 -118
- package/validators/utils/iban/package.json +0 -6
- package/validators/utils/iban.js.map +0 -7
- package/validators/utils/image/index.js +0 -79
- package/validators/utils/image/package.json +0 -6
- package/validators/utils/image.js.map +0 -7
- package/validators/utils/index.js.map +0 -7
- package/validators/utils/int/index.js +0 -24
- package/validators/utils/int/package.json +0 -6
- package/validators/utils/int.js.map +0 -7
- package/validators/utils/number/index.js +0 -20
- package/validators/utils/number/package.json +0 -6
- package/validators/utils/number.js.map +0 -7
- package/validators/utils/otp/index.js +0 -30
- package/validators/utils/otp/package.json +0 -6
- package/validators/utils/otp.js.map +0 -7
- package/validators/utils/package.json +0 -6
- package/validators/utils/phone/index.js +0 -172
- package/validators/utils/phone/package.json +0 -6
- package/validators/utils/phone.js.map +0 -7
- package/validators/utils/postal_code/index.js +0 -30
- package/validators/utils/postal_code/package.json +0 -6
- package/validators/utils/postal_code.js.map +0 -7
- package/validators/utils/text_limit/index.js +0 -45
- package/validators/utils/text_limit/package.json +0 -6
- package/validators/utils/text_limit.js.map +0 -7
- package/validators/utils/uuid4/index.js +0 -22
- package/validators/utils/uuid4/package.json +0 -6
- package/validators/utils/uuid4.js.map +0 -7
- package/validators/validators.spec.d.ts +0 -1
- package/src/{registry.js → registry.ts} +6 -6
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var datetime_exports = {};
|
|
29
|
-
__export(datetime_exports, {
|
|
30
|
-
DATETIME_VALIDATOR: () => DATETIME_VALIDATOR,
|
|
31
|
-
EARLIER_THAN_DATETIME_VALIDATOR: () => EARLIER_THAN_DATETIME_VALIDATOR,
|
|
32
|
-
LATER_THAN_DATETIME_VALIDATOR: () => LATER_THAN_DATETIME_VALIDATOR
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(datetime_exports);
|
|
35
|
-
var import_dayjs = __toESM(require("dayjs"));
|
|
36
|
-
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
|
|
37
|
-
import_dayjs.default.extend(import_customParseFormat.default);
|
|
38
|
-
const VALID_DATETIME_FORMATS = ["DD/MM/YYYY HH:mm"];
|
|
39
|
-
const DATETIME_CACHE = {};
|
|
40
|
-
const onlyNumbersRegex = /^\d+$/;
|
|
41
|
-
const getDateTime = (v) => {
|
|
42
|
-
return DATETIME_CACHE[v] ? DATETIME_CACHE[v] : (0, import_dayjs.default)(v, VALID_DATETIME_FORMATS, true);
|
|
43
|
-
};
|
|
44
|
-
const getDaysInMonth = (month, year) => {
|
|
45
|
-
return (0, import_dayjs.default)(`${year}-${month}-01`).daysInMonth();
|
|
46
|
-
};
|
|
47
|
-
const checkPartialDateTime = (value) => {
|
|
48
|
-
const [datePart, timePart] = value.split(" ");
|
|
49
|
-
const [day, month, year] = datePart?.split("/") ?? [];
|
|
50
|
-
const [hours, minutes] = timePart?.split(":") ?? [];
|
|
51
|
-
const hasDay = Boolean(day);
|
|
52
|
-
const hasMonth = Boolean(month);
|
|
53
|
-
const hasYear = Boolean(year);
|
|
54
|
-
const hasHours = Boolean(hours);
|
|
55
|
-
const hasMinutes = Boolean(minutes);
|
|
56
|
-
if (hasDay && !hasMonth && !hasYear && !hasHours && !hasMinutes) {
|
|
57
|
-
return "form.error.datetime.invalid_month_year_hours_minutes";
|
|
58
|
-
}
|
|
59
|
-
if (!hasDay && hasMonth && !hasYear && !hasHours && !hasMinutes) {
|
|
60
|
-
return "form.error.datetime.invalid_day_year_hours_minutes";
|
|
61
|
-
}
|
|
62
|
-
if (!hasDay && !hasMonth && hasYear && !hasHours && !hasMinutes) {
|
|
63
|
-
return "form.error.datetime.invalid_day_month_hours_minutes";
|
|
64
|
-
}
|
|
65
|
-
if (hasDay && hasMonth && !hasYear && !hasHours && !hasMinutes) {
|
|
66
|
-
return "form.error.datetime.invalid_year_hours_minutes";
|
|
67
|
-
}
|
|
68
|
-
if (hasDay && !hasMonth && hasYear && !hasHours && !hasMinutes) {
|
|
69
|
-
return "form.error.datetime.invalid_month_hours_minutes";
|
|
70
|
-
}
|
|
71
|
-
if (!hasDay && hasMonth && hasYear && !hasHours && !hasMinutes) {
|
|
72
|
-
return "form.error.datetime.invalid_day_hours_minutes";
|
|
73
|
-
}
|
|
74
|
-
if (hasDay && hasMonth && hasYear && !hasHours && !hasMinutes) {
|
|
75
|
-
return "form.error.datetime.invalid__hours_minutes";
|
|
76
|
-
}
|
|
77
|
-
if (hasDay && hasMonth && hasYear && hasHours && !hasMinutes) {
|
|
78
|
-
return "form.error.datetime.invalid_minutes";
|
|
79
|
-
}
|
|
80
|
-
if (hasDay && hasMonth && hasYear && !hasHours && hasMinutes) {
|
|
81
|
-
return "form.error.datetime.invalid_hours";
|
|
82
|
-
}
|
|
83
|
-
if (hasDay && !hasMonth && !hasYear && hasHours && !hasMinutes) {
|
|
84
|
-
return "form.error.datetime.invalid_month_year_minutes";
|
|
85
|
-
}
|
|
86
|
-
if (hasDay && !hasMonth && !hasYear && !hasHours && hasMinutes) {
|
|
87
|
-
return "form.error.datetime.invalid_month_year_hours";
|
|
88
|
-
}
|
|
89
|
-
if (hasDay && !hasMonth && !hasYear && hasHours && hasMinutes) {
|
|
90
|
-
return "form.error.datetime.invalid_month_year";
|
|
91
|
-
}
|
|
92
|
-
if (!hasDay && hasMonth && !hasYear && hasHours && !hasMinutes) {
|
|
93
|
-
return "form.error.datetime.invalid_day_year_minutes";
|
|
94
|
-
}
|
|
95
|
-
if (!hasDay && hasMonth && !hasYear && !hasHours && hasMinutes) {
|
|
96
|
-
return "form.error.datetime.invalid_day_year_hours";
|
|
97
|
-
}
|
|
98
|
-
if (!hasDay && hasMonth && !hasYear && hasHours && hasMinutes) {
|
|
99
|
-
return "form.error.datetime.invalid_day_year";
|
|
100
|
-
}
|
|
101
|
-
if (!hasDay && !hasMonth && hasYear && hasHours && !hasMinutes) {
|
|
102
|
-
return "form.error.datetime.invalid_day_month_minutes";
|
|
103
|
-
}
|
|
104
|
-
if (!hasDay && !hasMonth && hasYear && !hasHours && hasMinutes) {
|
|
105
|
-
return "form.error.datetime.invalid_day_month_hours";
|
|
106
|
-
}
|
|
107
|
-
if (!hasDay && !hasMonth && hasYear && hasHours && hasMinutes) {
|
|
108
|
-
return "form.error.datetime.invalid_day_month";
|
|
109
|
-
}
|
|
110
|
-
if (!hasDay && !hasMonth && !hasYear && hasHours && hasMinutes) {
|
|
111
|
-
return "form.error.datetime.invalid_day_month_year";
|
|
112
|
-
}
|
|
113
|
-
if (!hasDay && !hasMonth && !hasYear && !hasHours && hasMinutes) {
|
|
114
|
-
return "form.error.datetime.invalid_day_month_year_hours";
|
|
115
|
-
}
|
|
116
|
-
if (hasDay && hasMonth && !hasYear && hasHours && !hasMinutes) {
|
|
117
|
-
return "form.error.datetime.invalid_year_minutes";
|
|
118
|
-
}
|
|
119
|
-
if (hasDay && hasMonth && !hasYear && !hasHours && hasMinutes) {
|
|
120
|
-
return "form.error.datetime.invalid_year_hours";
|
|
121
|
-
}
|
|
122
|
-
if (hasDay && hasMonth && !hasYear && hasHours && hasMinutes) {
|
|
123
|
-
return "form.error.datetime.invalid_year";
|
|
124
|
-
}
|
|
125
|
-
if (hasDay && !hasMonth && hasYear && hasHours && !hasMinutes) {
|
|
126
|
-
return "form.error.datetime.invalid_month_minutes";
|
|
127
|
-
}
|
|
128
|
-
if (hasDay && !hasMonth && hasYear && !hasHours && hasMinutes) {
|
|
129
|
-
return "form.error.datetime.invalid_month_hours";
|
|
130
|
-
}
|
|
131
|
-
if (hasDay && !hasMonth && hasYear && hasHours && hasMinutes) {
|
|
132
|
-
return "form.error.datetime.invalid_month";
|
|
133
|
-
}
|
|
134
|
-
if (!hasDay && hasMonth && hasYear && hasHours && !hasMinutes) {
|
|
135
|
-
return "form.error.datetime.invalid_day_minutes";
|
|
136
|
-
}
|
|
137
|
-
if (!hasDay && hasMonth && hasYear && !hasHours && hasMinutes) {
|
|
138
|
-
return "form.error.datetime.invalid_day_hours";
|
|
139
|
-
}
|
|
140
|
-
if (!hasDay && hasMonth && hasYear && hasHours && hasMinutes) {
|
|
141
|
-
return "form.error.datetime.invalid_day";
|
|
142
|
-
}
|
|
143
|
-
if (!hasDay && !hasMonth && !hasYear && hasHours && !hasMinutes) {
|
|
144
|
-
return "form.error.datetime.invalid_day_month_year_minutes";
|
|
145
|
-
}
|
|
146
|
-
if (hasDay && hasMonth && hasYear && !hasHours && !hasMinutes) {
|
|
147
|
-
return "form.error.datetime.invalid_hours_minutes";
|
|
148
|
-
}
|
|
149
|
-
if (day && month) {
|
|
150
|
-
const dayNum = parseInt(day);
|
|
151
|
-
const monthNum = parseInt(month);
|
|
152
|
-
const validYear = onlyNumbersRegex.test(year) ? year : void 0;
|
|
153
|
-
if (!validYear || year.length < 4) {
|
|
154
|
-
return "form.error.datetime.invalid";
|
|
155
|
-
}
|
|
156
|
-
const yearNum = parseInt(validYear);
|
|
157
|
-
const maxDay = getDaysInMonth(monthNum, yearNum);
|
|
158
|
-
if (dayNum < 1 || dayNum > maxDay) {
|
|
159
|
-
return {
|
|
160
|
-
key: "form.error.datetime.invalid_day_range",
|
|
161
|
-
context: {
|
|
162
|
-
maxDay
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
if (monthNum < 1 || monthNum > 12) {
|
|
167
|
-
return "form.error.datetime.invalid_month_range";
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
if (hours && minutes) {
|
|
171
|
-
const hoursNum = parseInt(hours);
|
|
172
|
-
const minutesNum = parseInt(minutes);
|
|
173
|
-
if (hoursNum < 0 || hoursNum > 23) {
|
|
174
|
-
return "form.error.datetime.invalid_hours_range";
|
|
175
|
-
}
|
|
176
|
-
if (minutesNum < 0 || minutesNum > 59) {
|
|
177
|
-
return "form.error.datetime.invalid_minutes_range";
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
return "form.error.datetime.invalid";
|
|
181
|
-
};
|
|
182
|
-
const LATER_THAN_DATETIME_VALIDATOR = (field) => {
|
|
183
|
-
let minDateTime;
|
|
184
|
-
const params = field.extra || {};
|
|
185
|
-
if (params.min === "now") {
|
|
186
|
-
minDateTime = (0, import_dayjs.default)();
|
|
187
|
-
} else {
|
|
188
|
-
minDateTime = getDateTime(params.min);
|
|
189
|
-
}
|
|
190
|
-
return {
|
|
191
|
-
name: "later-than-datetime",
|
|
192
|
-
message: {
|
|
193
|
-
key: "form.error.datetime.later_than",
|
|
194
|
-
context: {
|
|
195
|
-
minDateTime: minDateTime.format("DD/MM/YYYY HH:mm")
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
test: function(value) {
|
|
199
|
-
if (!value) return true;
|
|
200
|
-
const datetime = getDateTime(value);
|
|
201
|
-
return datetime.isValid() && datetime.isAfter(minDateTime);
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
};
|
|
205
|
-
const EARLIER_THAN_DATETIME_VALIDATOR = (field) => {
|
|
206
|
-
let maxDateTime;
|
|
207
|
-
const params = field.extra || {};
|
|
208
|
-
if (params.max === "now") {
|
|
209
|
-
maxDateTime = (0, import_dayjs.default)();
|
|
210
|
-
} else {
|
|
211
|
-
maxDateTime = getDateTime(params.max);
|
|
212
|
-
}
|
|
213
|
-
return {
|
|
214
|
-
name: "earlier-than-datetime",
|
|
215
|
-
message: {
|
|
216
|
-
key: "form.error.datetime.earlier_than",
|
|
217
|
-
context: {
|
|
218
|
-
maxDateTime: maxDateTime.format("DD/MM/YYYY HH:mm")
|
|
219
|
-
}
|
|
220
|
-
},
|
|
221
|
-
test: function(value) {
|
|
222
|
-
if (!value) return true;
|
|
223
|
-
const datetime = getDateTime(value);
|
|
224
|
-
return datetime.isValid() && datetime.isBefore(maxDateTime);
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
};
|
|
228
|
-
const DATETIME_VALIDATOR = {
|
|
229
|
-
name: "datetime-validator",
|
|
230
|
-
message: (v) => {
|
|
231
|
-
return checkPartialDateTime(v.value);
|
|
232
|
-
},
|
|
233
|
-
test: function(value) {
|
|
234
|
-
if (!value) return true;
|
|
235
|
-
const datetime = getDateTime(value);
|
|
236
|
-
return datetime.isValid();
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
240
|
-
0 && (module.exports = {
|
|
241
|
-
DATETIME_VALIDATOR,
|
|
242
|
-
EARLIER_THAN_DATETIME_VALIDATOR,
|
|
243
|
-
LATER_THAN_DATETIME_VALIDATOR
|
|
244
|
-
});
|
|
245
|
-
//# sourceMappingURL=datetime.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/validators/utils/datetime.ts"],
|
|
4
|
-
"sourcesContent": ["import dayjs from 'dayjs';\nimport customParseFormat from 'dayjs/plugin/customParseFormat';\nimport type { FieldSpec } from '@digigov/form/types';\nimport type { ValidatorSchema } from '@digigov/form/validators/types';\n\ndayjs.extend(customParseFormat);\n\nconst VALID_DATETIME_FORMATS = ['DD/MM/YYYY HH:mm'];\nconst DATETIME_CACHE = {};\nconst onlyNumbersRegex = /^\\d+$/;\n\nconst getDateTime = (v: string) => {\n return DATETIME_CACHE[v]\n ? DATETIME_CACHE[v]\n : dayjs(v, VALID_DATETIME_FORMATS, true);\n};\n\nconst getDaysInMonth = (month: number, year: number): number => {\n return dayjs(`${year}-${month}-01`).daysInMonth(); // e.g. 29 for Feb 2024\n};\n\nconst checkPartialDateTime = (value: string) => {\n const [datePart, timePart] = value.split(' ');\n const [day, month, year] = datePart?.split('/') ?? [];\n const [hours, minutes] = timePart?.split(':') ?? [];\n\n const hasDay = Boolean(day);\n const hasMonth = Boolean(month);\n const hasYear = Boolean(year);\n const hasHours = Boolean(hours);\n const hasMinutes = Boolean(minutes);\n\n if (hasDay && !hasMonth && !hasYear && !hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_month_year_hours_minutes';\n }\n if (!hasDay && hasMonth && !hasYear && !hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_day_year_hours_minutes';\n }\n if (!hasDay && !hasMonth && hasYear && !hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_day_month_hours_minutes';\n }\n if (hasDay && hasMonth && !hasYear && !hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_year_hours_minutes';\n }\n if (hasDay && !hasMonth && hasYear && !hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_month_hours_minutes';\n }\n if (!hasDay && hasMonth && hasYear && !hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_day_hours_minutes';\n }\n if (hasDay && hasMonth && hasYear && !hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid__hours_minutes';\n }\n if (hasDay && hasMonth && hasYear && hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_minutes';\n }\n if (hasDay && hasMonth && hasYear && !hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_hours';\n }\n if (hasDay && !hasMonth && !hasYear && hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_month_year_minutes';\n }\n if (hasDay && !hasMonth && !hasYear && !hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_month_year_hours';\n }\n if (hasDay && !hasMonth && !hasYear && hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_month_year';\n }\n if (!hasDay && hasMonth && !hasYear && hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_day_year_minutes';\n }\n if (!hasDay && hasMonth && !hasYear && !hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_day_year_hours';\n }\n if (!hasDay && hasMonth && !hasYear && hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_day_year';\n }\n if (!hasDay && !hasMonth && hasYear && hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_day_month_minutes';\n }\n if (!hasDay && !hasMonth && hasYear && !hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_day_month_hours';\n }\n if (!hasDay && !hasMonth && hasYear && hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_day_month';\n }\n if (!hasDay && !hasMonth && !hasYear && hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_day_month_year';\n }\n if (!hasDay && !hasMonth && !hasYear && !hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_day_month_year_hours';\n }\n if (hasDay && hasMonth && !hasYear && hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_year_minutes';\n }\n if (hasDay && hasMonth && !hasYear && !hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_year_hours';\n }\n if (hasDay && hasMonth && !hasYear && hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_year';\n }\n if (hasDay && !hasMonth && hasYear && hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_month_minutes';\n }\n if (hasDay && !hasMonth && hasYear && !hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_month_hours';\n }\n if (hasDay && !hasMonth && hasYear && hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_month';\n }\n if (!hasDay && hasMonth && hasYear && hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_day_minutes';\n }\n if (!hasDay && hasMonth && hasYear && !hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_day_hours';\n }\n if (!hasDay && hasMonth && hasYear && hasHours && hasMinutes) {\n return 'form.error.datetime.invalid_day';\n }\n if (!hasDay && !hasMonth && !hasYear && hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_day_month_year_minutes';\n }\n if (hasDay && hasMonth && hasYear && !hasHours && !hasMinutes) {\n return 'form.error.datetime.invalid_hours_minutes';\n }\n if (day && month) {\n const dayNum = parseInt(day);\n const monthNum = parseInt(month);\n const validYear = onlyNumbersRegex.test(year) ? year : undefined;\n if (!validYear || year.length < 4) {\n return 'form.error.datetime.invalid';\n }\n const yearNum = parseInt(validYear);\n const maxDay = getDaysInMonth(monthNum, yearNum);\n if (dayNum < 1 || dayNum > maxDay) {\n return {\n key: 'form.error.datetime.invalid_day_range',\n context: {\n maxDay: maxDay,\n },\n };\n }\n if (monthNum < 1 || monthNum > 12) {\n return 'form.error.datetime.invalid_month_range';\n }\n }\n if (hours && minutes) {\n const hoursNum = parseInt(hours);\n const minutesNum = parseInt(minutes);\n if (hoursNum < 0 || hoursNum > 23) {\n return 'form.error.datetime.invalid_hours_range';\n }\n if (minutesNum < 0 || minutesNum > 59) {\n return 'form.error.datetime.invalid_minutes_range';\n }\n }\n return 'form.error.datetime.invalid';\n};\n\nexport const LATER_THAN_DATETIME_VALIDATOR = (\n field: FieldSpec\n): ValidatorSchema => {\n let minDateTime;\n const params = field.extra || {};\n if (params.min === 'now') {\n minDateTime = dayjs();\n } else {\n minDateTime = getDateTime(params.min);\n }\n return {\n name: 'later-than-datetime',\n message: {\n key: 'form.error.datetime.later_than',\n context: {\n minDateTime: minDateTime.format('DD/MM/YYYY HH:mm'),\n },\n },\n test: function (value: string) {\n if (!value) return true;\n const datetime = getDateTime(value);\n return datetime.isValid() && datetime.isAfter(minDateTime);\n },\n };\n};\n\nexport const EARLIER_THAN_DATETIME_VALIDATOR = (\n field: FieldSpec\n): ValidatorSchema => {\n let maxDateTime;\n const params = field.extra || {};\n if (params.max === 'now') {\n maxDateTime = dayjs();\n } else {\n maxDateTime = getDateTime(params.max);\n }\n return {\n name: 'earlier-than-datetime',\n message: {\n key: 'form.error.datetime.earlier_than',\n context: {\n maxDateTime: maxDateTime.format('DD/MM/YYYY HH:mm'),\n },\n },\n test: function (value: string) {\n if (!value) return true;\n const datetime = getDateTime(value);\n return datetime.isValid() && datetime.isBefore(maxDateTime);\n },\n };\n};\n\nexport const DATETIME_VALIDATOR = {\n name: 'datetime-validator',\n message: (v): string | object => {\n return checkPartialDateTime(v.value);\n },\n test: function (value: string) {\n if (!value) return true;\n const datetime = getDateTime(value);\n return datetime.isValid();\n },\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,+BAA8B;AAI9B,aAAAA,QAAM,OAAO,yBAAAC,OAAiB;AAE9B,MAAM,yBAAyB,CAAC,kBAAkB;AAClD,MAAM,iBAAiB,CAAC;AACxB,MAAM,mBAAmB;AAEzB,MAAM,cAAc,CAAC,MAAc;AACjC,SAAO,eAAe,CAAC,IACnB,eAAe,CAAC,QAChB,aAAAD,SAAM,GAAG,wBAAwB,IAAI;AAC3C;AAEA,MAAM,iBAAiB,CAAC,OAAe,SAAyB;AAC9D,aAAO,aAAAA,SAAM,GAAG,IAAI,IAAI,KAAK,KAAK,EAAE,YAAY;AAClD;AAEA,MAAM,uBAAuB,CAAC,UAAkB;AAC9C,QAAM,CAAC,UAAU,QAAQ,IAAI,MAAM,MAAM,GAAG;AAC5C,QAAM,CAAC,KAAK,OAAO,IAAI,IAAI,UAAU,MAAM,GAAG,KAAK,CAAC;AACpD,QAAM,CAAC,OAAO,OAAO,IAAI,UAAU,MAAM,GAAG,KAAK,CAAC;AAElD,QAAM,SAAS,QAAQ,GAAG;AAC1B,QAAM,WAAW,QAAQ,KAAK;AAC9B,QAAM,UAAU,QAAQ,IAAI;AAC5B,QAAM,WAAW,QAAQ,KAAK;AAC9B,QAAM,aAAa,QAAQ,OAAO;AAElC,MAAI,UAAU,CAAC,YAAY,CAAC,WAAW,CAAC,YAAY,CAAC,YAAY;AAC/D,WAAO;AAAA,EACT;AACA,MAAI,CAAC,UAAU,YAAY,C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;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,MAAuB;AAC/B,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
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var email_exports = {};
|
|
19
|
-
__export(email_exports, {
|
|
20
|
-
EMAIL_VALIDATOR: () => EMAIL_VALIDATOR
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(email_exports);
|
|
23
|
-
const EMAIL_VALIDATOR = {
|
|
24
|
-
name: "email-validator",
|
|
25
|
-
message: "form.error.email",
|
|
26
|
-
test: (value) => {
|
|
27
|
-
if (!value) return true;
|
|
28
|
-
const EMAIL_REGEX = (
|
|
29
|
-
// eslint-disable-next-line no-useless-escape
|
|
30
|
-
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
|
31
|
-
);
|
|
32
|
-
return EMAIL_REGEX.test(value);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
-
0 && (module.exports = {
|
|
37
|
-
EMAIL_VALIDATOR
|
|
38
|
-
});
|
|
39
|
-
//# sourceMappingURL=email.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/validators/utils/email.ts"],
|
|
4
|
-
"sourcesContent": ["export const EMAIL_VALIDATOR = {\n name: 'email-validator',\n message: 'form.error.email',\n test: (value: string): boolean => {\n if (!value) return true;\n const EMAIL_REGEX =\n // eslint-disable-next-line no-useless-escape\n /^(([^<>()\\[\\]\\\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n return EMAIL_REGEX.test(value);\n },\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,kBAAkB;AAAA,EAC7B,MAAM;AAAA,EACN,SAAS;AAAA,EACT,MAAM,CAAC,UAA2B;AAChC,QAAI,CAAC,MAAO,QAAO;AACnB,UAAM;AAAA;AAAA,MAEJ;AAAA;AACF,WAAO,YAAY,KAAK,KAAK;AAAA,EAC/B;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var file_exports = {};
|
|
19
|
-
__export(file_exports, {
|
|
20
|
-
FILE_MAX_SIZE_VALIDATOR: () => FILE_MAX_SIZE_VALIDATOR
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(file_exports);
|
|
23
|
-
const DEFAULT_FILE_MAX_SIZE = 1e7;
|
|
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
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
-
0 && (module.exports = {
|
|
59
|
-
FILE_MAX_SIZE_VALIDATOR
|
|
60
|
-
});
|
|
61
|
-
//# sourceMappingURL=file.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/validators/utils/file.ts"],
|
|
4
|
-
"sourcesContent": ["import type { FieldSpec } from '@digigov/form/types';\nimport type { 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
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var iban_exports = {};
|
|
19
|
-
__export(iban_exports, {
|
|
20
|
-
IBAN_VALIDATOR: () => IBAN_VALIDATOR,
|
|
21
|
-
validateIban: () => validateIban
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(iban_exports);
|
|
24
|
-
function validateIban(value, countryCode) {
|
|
25
|
-
value = value.replace(/\s/g, "").replace(/-/g, "");
|
|
26
|
-
if (value.match(/^[0-9]*$/i)) {
|
|
27
|
-
if (value.length !== 25) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
} else {
|
|
31
|
-
value = value.toUpperCase();
|
|
32
|
-
if (countryCode) {
|
|
33
|
-
if (!value.startsWith(countryCode.toUpperCase())) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
if (value.length === ibanCountryCodesLengths[countryCode.toUpperCase()]) {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (value.length !== 27) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
const IBAN_VALIDATOR = (field) => {
|
|
47
|
-
const countryCode = field?.extra?.country;
|
|
48
|
-
return {
|
|
49
|
-
name: "iban-validator",
|
|
50
|
-
message: "form.error.iban",
|
|
51
|
-
test: (value) => {
|
|
52
|
-
if (!value) {
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
return validateIban(value, countryCode);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
const ibanCountryCodesLengths = {
|
|
60
|
-
AD: 24,
|
|
61
|
-
AT: 20,
|
|
62
|
-
AZ: 28,
|
|
63
|
-
BH: 22,
|
|
64
|
-
BY: 28,
|
|
65
|
-
BE: 16,
|
|
66
|
-
BA: 20,
|
|
67
|
-
BR: 29,
|
|
68
|
-
BG: 22,
|
|
69
|
-
CR: 22,
|
|
70
|
-
HR: 21,
|
|
71
|
-
CY: 28,
|
|
72
|
-
CZ: 24,
|
|
73
|
-
DK: 18,
|
|
74
|
-
DO: 28,
|
|
75
|
-
EG: 29,
|
|
76
|
-
SV: 28,
|
|
77
|
-
EE: 20,
|
|
78
|
-
FO: 18,
|
|
79
|
-
FI: 18,
|
|
80
|
-
FR: 27,
|
|
81
|
-
GE: 22,
|
|
82
|
-
DE: 22,
|
|
83
|
-
GI: 23,
|
|
84
|
-
GR: 27,
|
|
85
|
-
GL: 18,
|
|
86
|
-
GT: 28,
|
|
87
|
-
VA: 22,
|
|
88
|
-
HU: 28,
|
|
89
|
-
IS: 26,
|
|
90
|
-
IQ: 23,
|
|
91
|
-
IE: 22,
|
|
92
|
-
IL: 23,
|
|
93
|
-
IT: 27,
|
|
94
|
-
JO: 30,
|
|
95
|
-
KZ: 20,
|
|
96
|
-
XK: 20,
|
|
97
|
-
KW: 30,
|
|
98
|
-
LV: 21,
|
|
99
|
-
LB: 28,
|
|
100
|
-
LI: 21,
|
|
101
|
-
LT: 20,
|
|
102
|
-
LU: 20,
|
|
103
|
-
MT: 31,
|
|
104
|
-
MR: 27,
|
|
105
|
-
MU: 30,
|
|
106
|
-
MD: 24,
|
|
107
|
-
MC: 27,
|
|
108
|
-
ME: 22,
|
|
109
|
-
NL: 18,
|
|
110
|
-
MK: 19,
|
|
111
|
-
NO: 15,
|
|
112
|
-
PK: 24,
|
|
113
|
-
PS: 29,
|
|
114
|
-
PL: 28,
|
|
115
|
-
PT: 25,
|
|
116
|
-
QA: 29,
|
|
117
|
-
RO: 24,
|
|
118
|
-
LC: 32,
|
|
119
|
-
SM: 27,
|
|
120
|
-
ST: 25,
|
|
121
|
-
SA: 24,
|
|
122
|
-
RS: 22,
|
|
123
|
-
SC: 31,
|
|
124
|
-
SK: 24,
|
|
125
|
-
SI: 19,
|
|
126
|
-
ES: 24,
|
|
127
|
-
SE: 24,
|
|
128
|
-
CH: 21,
|
|
129
|
-
TL: 23,
|
|
130
|
-
TN: 24,
|
|
131
|
-
TR: 26,
|
|
132
|
-
UA: 29,
|
|
133
|
-
AE: 23,
|
|
134
|
-
GB: 22,
|
|
135
|
-
VG: 24
|
|
136
|
-
};
|
|
137
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
138
|
-
0 && (module.exports = {
|
|
139
|
-
IBAN_VALIDATOR,
|
|
140
|
-
validateIban
|
|
141
|
-
});
|
|
142
|
-
//# sourceMappingURL=iban.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/validators/utils/iban.ts"],
|
|
4
|
-
"sourcesContent": ["import type { FieldSpec } from '@digigov/form/types';\nimport type { ValidatorSchema } from '@digigov/form/validators/types';\nexport function validateIban(value: string, countryCode: string): boolean {\n value = value.replace(/\\s/g, '').replace(/-/g, '');\n if (value.match(/^[0-9]*$/i)) {\n // this is for greek iban without the country code\n if (value.length !== 25) {\n return false;\n }\n } else {\n value = value.toUpperCase();\n if (countryCode) {\n if (!value.startsWith(countryCode.toUpperCase())) {\n return false;\n }\n if (value.length === ibanCountryCodesLengths[countryCode.toUpperCase()]) {\n return true;\n }\n }\n if (value.length !== 27) {\n // this is for greek iban\n return false;\n }\n }\n return true;\n}\n\nexport const IBAN_VALIDATOR = (field: FieldSpec): ValidatorSchema => {\n const countryCode = field?.extra?.country;\n return {\n name: 'iban-validator',\n message: 'form.error.iban',\n test: (value: string): boolean => {\n if (!value) {\n return true;\n }\n return validateIban(value, countryCode);\n },\n };\n};\n\nconst ibanCountryCodesLengths = {\n AD: 24,\n AT: 20,\n AZ: 28,\n BH: 22,\n BY: 28,\n BE: 16,\n BA: 20,\n BR: 29,\n BG: 22,\n CR: 22,\n HR: 21,\n CY: 28,\n CZ: 24,\n DK: 18,\n DO: 28,\n EG: 29,\n SV: 28,\n EE: 20,\n FO: 18,\n FI: 18,\n FR: 27,\n GE: 22,\n DE: 22,\n GI: 23,\n GR: 27,\n GL: 18,\n GT: 28,\n VA: 22,\n HU: 28,\n IS: 26,\n IQ: 23,\n IE: 22,\n IL: 23,\n IT: 27,\n JO: 30,\n KZ: 20,\n XK: 20,\n KW: 30,\n LV: 21,\n LB: 28,\n LI: 21,\n LT: 20,\n LU: 20,\n MT: 31,\n MR: 27,\n MU: 30,\n MD: 24,\n MC: 27,\n ME: 22,\n NL: 18,\n MK: 19,\n NO: 15,\n PK: 24,\n PS: 29,\n PL: 28,\n PT: 25,\n QA: 29,\n RO: 24,\n LC: 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.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var image_exports = {};
|
|
19
|
-
__export(image_exports, {
|
|
20
|
-
IMAGE_DIMENSION_VALIDATOR: () => IMAGE_DIMENSION_VALIDATOR
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(image_exports);
|
|
23
|
-
const DEFAULT_IMAGE_MAX_HEIGHT_SIZE = 2e3;
|
|
24
|
-
const DEFAULT_IMAGE_MAX_WIDTH_SIZE = 2e3;
|
|
25
|
-
const DEFAULT_IMAGE_MIN_HEIGHT_SIZE = 100;
|
|
26
|
-
const DEFAULT_IMAGE_MIN_WIDTH_SIZE = 100;
|
|
27
|
-
function getImageDimensions(file) {
|
|
28
|
-
return new Promise((resolve, reject) => {
|
|
29
|
-
const reader = new FileReader();
|
|
30
|
-
reader.onload = (event) => {
|
|
31
|
-
const img = new Image();
|
|
32
|
-
img.onload = () => {
|
|
33
|
-
resolve({ width: img.width, height: img.height });
|
|
34
|
-
};
|
|
35
|
-
img.onerror = reject;
|
|
36
|
-
const result = event?.target?.result;
|
|
37
|
-
if (result && typeof result === "string") {
|
|
38
|
-
img.src = result;
|
|
39
|
-
} else {
|
|
40
|
-
reject(new Error("Invalid file format"));
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
reader.onerror = reject;
|
|
44
|
-
reader.readAsDataURL(file);
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
const IMAGE_DIMENSION_VALIDATOR = (field) => ({
|
|
48
|
-
name: "image-dimension-validator",
|
|
49
|
-
message: (value) => {
|
|
50
|
-
const minHeight = field?.extra?.limit?.minHeight || DEFAULT_IMAGE_MIN_HEIGHT_SIZE;
|
|
51
|
-
const minWidth = field?.extra?.limit?.minWidth || DEFAULT_IMAGE_MIN_WIDTH_SIZE;
|
|
52
|
-
const maxHeight = field?.extra?.limit?.maxHeight || DEFAULT_IMAGE_MAX_HEIGHT_SIZE;
|
|
53
|
-
const maxWidth = field?.extra?.limit?.maxWidth || DEFAULT_IMAGE_MAX_WIDTH_SIZE;
|
|
54
|
-
if (!value || value.length === 0) {
|
|
55
|
-
return {
|
|
56
|
-
name: "image-validator",
|
|
57
|
-
message: "form.error.required"
|
|
58
|
-
};
|
|
59
|
-
} else {
|
|
60
|
-
return {
|
|
61
|
-
key: "form.error.image.image_dimension_size",
|
|
62
|
-
context: {
|
|
63
|
-
maxHeight,
|
|
64
|
-
maxWidth,
|
|
65
|
-
minHeight,
|
|
66
|
-
minWidth
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
test: async (value) => {
|
|
72
|
-
if (!value || value.length === 0) {
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
const file = value[0];
|
|
76
|
-
const { width, height } = await getImageDimensions(file);
|
|
77
|
-
const maxHeight = field?.extra?.limit?.maxHeight || DEFAULT_IMAGE_MAX_HEIGHT_SIZE;
|
|
78
|
-
const maxWidth = field?.extra?.limit?.maxWidth || DEFAULT_IMAGE_MAX_WIDTH_SIZE;
|
|
79
|
-
const minHeight = field?.extra?.limit?.minHeight || DEFAULT_IMAGE_MIN_HEIGHT_SIZE;
|
|
80
|
-
const minWidth = field?.extra?.limit?.minWidth || DEFAULT_IMAGE_MIN_WIDTH_SIZE;
|
|
81
|
-
if (!file) {
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
try {
|
|
85
|
-
if (height > maxHeight || width > maxWidth) {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
if (height < minHeight || width < minWidth) {
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
return true;
|
|
92
|
-
} catch (error) {
|
|
93
|
-
console.error("Error getting image dimensions:", error);
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
99
|
-
0 && (module.exports = {
|
|
100
|
-
IMAGE_DIMENSION_VALIDATOR
|
|
101
|
-
});
|
|
102
|
-
//# sourceMappingURL=image.js.map
|