@digigov/form 2.0.0-rc.8 → 2.0.3
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/CHANGELOG.md +118 -3
- package/Field/ErrorGroup.d.ts +15 -0
- package/Field/ErrorGroup.js +53 -0
- package/Field/FieldBase.d.ts +1 -1
- package/Field/FieldBase.js +77 -0
- package/Field/FieldBaseContainer.d.ts +2 -2
- 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 +70 -68
- package/Field/types.d.ts +61 -11
- package/Field/utils/evaluateFieldWithConditions.d.ts +2 -0
- package/Field/utils/evaluateFieldWithConditions.js +19 -0
- package/Field/utils/resolveField.d.ts +3 -0
- package/Field/utils/resolveField.js +32 -0
- package/Field/utils/useField.d.ts +2 -0
- package/Field/utils/useField.js +47 -0
- package/FieldArray/BaseFieldArray.d.ts +5 -0
- package/FieldArray/BaseFieldArray.js +46 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.d.ts +9 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.js +13 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.d.ts +26 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.js +134 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.d.ts +5 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.js +6 -0
- package/FieldArray/FormDialog/ArrayDisplay/index.d.ts +15 -0
- package/FieldArray/FormDialog/ArrayDisplay/index.js +32 -0
- package/FieldArray/FormDialog/ArrayEditModal.d.ts +24 -0
- package/FieldArray/FormDialog/ArrayEditModal.js +138 -0
- package/FieldArray/FormDialog/index.d.ts +19 -0
- package/FieldArray/FormDialog/index.js +199 -0
- package/FieldArray/index.d.ts +11 -2
- package/FieldArray/index.js +65 -60
- package/FieldObject/index.d.ts +11 -3
- package/FieldObject/index.js +53 -52
- package/Fieldset/FieldsetWithContext.js +27 -0
- package/Fieldset/index.d.ts +2 -2
- package/Fieldset/index.js +18 -32
- package/Fieldset/types.d.ts +3 -2
- package/FormBuilder/index.d.ts +8 -1
- package/FormBuilder/index.js +239 -2
- package/FormContext.d.ts +3 -2
- package/FormContext.js +7 -0
- package/MultiplicityField/add-objects.d.ts +3 -2
- package/MultiplicityField/add-objects.js +107 -0
- package/MultiplicityField/index.d.ts +2 -19
- package/MultiplicityField/index.js +84 -111
- package/MultiplicityField/types.d.ts +19 -0
- package/Questions/Questions.d.ts +1 -1
- package/Questions/Questions.js +48 -0
- package/Questions/QuestionsContext.d.ts +1 -2
- 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 -2
- package/Questions/Step/StepContext.js +28 -0
- package/Questions/Step/StepDescription.d.ts +1 -1
- 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.d.ts +1 -1
- package/Questions/Step/StepQuote.js +5 -0
- package/Questions/Step/StepTitle.d.ts +2 -1
- 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 -12
- package/Questions/Step/index.js +13 -13
- package/Questions/Step/types.d.ts +2 -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 -3
- package/Questions/types.d.ts +2 -1
- package/Questions/types.js +0 -0
- package/hooks/useFieldFocusManager.d.ts +25 -0
- package/hooks/useFieldFocusManager.js +83 -0
- package/hooks/utils.d.ts +18 -0
- package/hooks/utils.js +60 -0
- package/index.d.ts +5 -2
- package/index.js +8 -4
- package/inputs/AutoCompleteInput/index.d.ts +4 -4
- package/inputs/AutoCompleteInput/index.js +42 -55
- package/inputs/Checkboxes/index.d.ts +7 -4
- package/inputs/Checkboxes/index.js +50 -91
- package/inputs/DateInput/index.d.ts +3 -7
- package/inputs/DateInput/index.js +128 -125
- package/inputs/DateTimeInput/index.d.ts +10 -0
- package/inputs/DateTimeInput/index.js +190 -0
- package/inputs/FileInput/index.d.ts +18 -2
- package/inputs/FileInput/index.js +59 -56
- package/inputs/ImageInput/index.d.ts +10 -2
- package/inputs/ImageInput/index.js +94 -74
- package/inputs/Input/index.d.ts +5 -2
- package/inputs/Input/index.js +67 -67
- package/inputs/Label/index.d.ts +2 -4
- package/inputs/Label/index.js +13 -21
- package/inputs/OtpInput/index.d.ts +1 -5
- package/inputs/OtpInput/index.js +122 -139
- package/inputs/Radio/index.d.ts +10 -3
- package/inputs/Radio/index.js +72 -56
- package/inputs/Select/index.d.ts +7 -4
- package/inputs/Select/index.js +23 -30
- package/inputs/index.d.ts +9 -9
- package/inputs/index.js +10 -9
- package/inputs/registry.d.ts +5 -0
- package/inputs/registry.js +80 -0
- package/internal.d.ts +5 -34
- package/internal.js +6 -0
- package/lazy.d.ts +94 -66
- package/lazy.js +163 -0
- package/package.json +12 -13
- package/registry.d.ts +45 -27
- package/registry.js +170 -0
- package/src/Field/ErrorGroup.tsx +84 -0
- package/src/Field/FieldBase.tsx +43 -25
- package/src/Field/FieldBaseContainer.tsx +71 -47
- package/src/Field/FieldConditional.tsx +10 -2
- package/src/Field/doc.mdx +207 -0
- package/src/Field/index.tsx +37 -23
- package/src/Field/types.tsx +92 -13
- package/src/Field/utils/evaluateFieldWithConditions.ts +33 -0
- package/src/Field/utils/resolveField.ts +58 -0
- package/src/Field/utils/useField.ts +68 -0
- package/src/FieldArray/BaseFieldArray.tsx +97 -0
- package/src/FieldArray/FieldArray.stories.js +4 -2
- package/src/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.tsx +45 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/ArrayDisplay.stories.js +14 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.tsx +370 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.tsx +15 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/Cards.tsx +88 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/Default.tsx +93 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnly.tsx +79 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnlyCards.tsx +75 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/Sortable.tsx +93 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/SortableCards.tsx +88 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/index.test.tsx +44 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/index.tsx +67 -0
- package/src/FieldArray/FormDialog/ArrayEditModal.tsx +241 -0
- package/src/FieldArray/FormDialog/index.tsx +302 -0
- package/src/FieldArray/__stories__/CardsWithError.tsx +110 -0
- package/src/FieldArray/__stories__/Default.tsx +2 -1
- package/src/FieldArray/__stories__/TableWithError.tsx +111 -0
- package/src/FieldArray/__stories__/WithExactLength.tsx +2 -1
- package/src/FieldArray/__stories__/WithModal.tsx +188 -0
- package/src/FieldArray/__tests__/fieldset-multiplicity.spec.tsx +271 -0
- package/src/FieldArray/__tests__/multiplicity-attachment.spec.tsx +280 -0
- package/src/FieldArray/__tests__/multiplicity-optional.spec.tsx +232 -0
- package/src/FieldArray/__tests__/multiplicity-required.spec.tsx +170 -0
- package/src/FieldArray/__tests__/nested-fieldset-multiplicity.spec.tsx +627 -0
- package/src/FieldArray/__tests__/preference-multiple-choice.spec.tsx +222 -0
- package/src/FieldArray/index.spec.tsx +355 -0
- package/src/FieldArray/index.test.tsx +43 -0
- package/src/FieldArray/index.tsx +84 -55
- package/src/FieldObject/index.tsx +53 -27
- package/src/Fieldset/FieldsetWithContext.tsx +1 -1
- package/src/Fieldset/index.tsx +6 -6
- package/src/Fieldset/types.tsx +5 -3
- package/src/FormBuilder/FormBuilder.stories.js +6 -1
- package/src/FormBuilder/__stories__/AutoErrorGrouping.tsx +63 -0
- package/src/FormBuilder/__stories__/Default.tsx +1 -1
- package/src/FormBuilder/__stories__/ErrorGrouping.tsx +43 -0
- package/src/FormBuilder/{FormBuilder.mdx → doc.mdx} +27 -35
- package/src/FormBuilder/index.test.tsx +32 -0
- package/src/FormBuilder/index.tsx +314 -1
- package/src/FormBuilder/interaction.test.tsx +40 -0
- package/src/FormBuilder/scenarios.test.tsx +2775 -0
- package/src/FormContext.tsx +7 -3
- package/src/MultiplicityField/MultiplicityField.stories.js +9 -6
- package/src/MultiplicityField/__stories__/Default.tsx +1 -1
- package/src/MultiplicityField/__stories__/PreviewDisplay.tsx +2 -4
- package/src/MultiplicityField/__stories__/WithExactLength.tsx +2 -2
- package/src/MultiplicityField/__stories__/WithMaxLength.tsx +2 -2
- package/src/MultiplicityField/__stories__/WithMinAndMaxLength.tsx +2 -2
- package/src/MultiplicityField/__stories__/WithMinLength.tsx +2 -2
- package/src/MultiplicityField/add-objects.tsx +39 -30
- package/{cjs/MultiplicityField/MultiplicityField.mdx → src/MultiplicityField/doc.mdx} +112 -98
- package/src/MultiplicityField/index.test.tsx +44 -0
- package/src/MultiplicityField/index.tsx +25 -34
- package/src/MultiplicityField/types.ts +25 -0
- package/src/Questions/Questions.stories.js +4 -1
- package/src/Questions/Questions.tsx +6 -6
- package/src/Questions/QuestionsContext.tsx +1 -1
- package/src/Questions/Step/Step.tsx +1 -1
- package/src/Questions/Step/StepArrayReview.tsx +3 -3
- package/src/Questions/Step/StepContext.tsx +1 -1
- package/src/Questions/Step/StepDescription.tsx +2 -1
- package/src/Questions/Step/StepForm.tsx +2 -2
- package/src/Questions/Step/StepQuote.tsx +2 -1
- package/src/Questions/Step/StepTitle.tsx +6 -3
- package/src/Questions/Step/getAddMoreFields.tsx +2 -2
- package/src/Questions/Step/index.ts +0 -1
- package/src/Questions/Step/types.tsx +2 -1
- package/src/Questions/__snapshots__/index.spec.tsx.snap +74 -587
- package/src/Questions/__stories__/Default.tsx +1 -1
- package/{Questions/index.mdx → src/Questions/doc.mdx} +34 -57
- package/src/Questions/getNextStep.tsx +1 -1
- package/src/Questions/index.spec.tsx +17 -5
- package/src/Questions/index.test.tsx +24 -0
- package/src/Questions/types.tsx +2 -1
- package/src/create-simple-form.mdx +2 -6
- package/src/{index.mdx → doc.mdx} +29 -18
- package/src/hooks/__tests__/useFieldFocusManager.spec.tsx +1079 -0
- package/src/hooks/__tests__/utils.spec.ts +568 -0
- package/src/hooks/useFieldFocusManager.ts +162 -0
- package/src/hooks/utils.ts +122 -0
- package/src/index.ts +4 -1
- package/src/inputs/AutoCompleteInput/AutoComplete.stories.js +5 -2
- package/src/inputs/AutoCompleteInput/__stories__/Default.tsx +3 -11
- package/src/inputs/AutoCompleteInput/__stories__/Multiple.tsx +2 -9
- package/{cjs/inputs/AutoCompleteInput/index.mdx → src/inputs/AutoCompleteInput/doc.mdx} +2 -13
- package/src/inputs/AutoCompleteInput/index.test.tsx +28 -0
- package/src/inputs/AutoCompleteInput/index.tsx +40 -35
- package/src/inputs/Checkboxes/Checkboxes.stories.js +6 -3
- package/src/inputs/Checkboxes/__stories__/Conditional.tsx +1 -1
- package/src/inputs/Checkboxes/__stories__/Default.tsx +1 -1
- package/src/inputs/Checkboxes/__stories__/WithDivider.tsx +1 -1
- package/src/inputs/Checkboxes/{index.mdx → doc.mdx} +5 -15
- package/src/inputs/Checkboxes/index.test.tsx +32 -0
- package/src/inputs/Checkboxes/index.tsx +106 -92
- package/src/inputs/DateInput/DateInput.stories.js +8 -1
- package/src/inputs/DateInput/__stories__/Default.tsx +17 -16
- package/src/inputs/DateInput/__stories__/WithDefaultValue.tsx +26 -0
- package/src/inputs/DateInput/__stories__/WithInitialValue.tsx +28 -0
- package/src/inputs/DateInput/__stories__/WithWrongDefaultValue.tsx +26 -0
- package/src/inputs/DateInput/__stories__/WithWrongInitialValue.tsx +28 -0
- package/src/inputs/DateInput/{index.mdx → doc.mdx} +1 -8
- package/src/inputs/DateInput/index.test.tsx +40 -0
- package/src/inputs/DateInput/index.tsx +77 -27
- package/src/inputs/DateTimeInput/DateTimeInput.stories.js +14 -0
- package/src/inputs/DateTimeInput/__stories__/Default.tsx +25 -0
- package/src/inputs/DateTimeInput/__stories__/WithDefaultValue.tsx +26 -0
- package/src/inputs/DateTimeInput/__stories__/WithInitialValue.tsx +28 -0
- package/src/inputs/DateTimeInput/__stories__/WithWrongDefaultValue.tsx +26 -0
- package/src/inputs/DateTimeInput/__stories__/WithWrongInitialValue.tsx +28 -0
- package/src/inputs/DateTimeInput/doc.mdx +16 -0
- package/src/inputs/DateTimeInput/index.test.tsx +40 -0
- package/src/inputs/DateTimeInput/index.tsx +246 -0
- package/src/inputs/FileInput/FileInput.stories.js +5 -1
- package/src/inputs/FileInput/__stories__/Default.tsx +1 -1
- package/src/inputs/FileInput/__stories__/WithBorderAndLink.tsx +34 -0
- package/{inputs/FileInput/index.mdx → src/inputs/FileInput/doc.mdx} +1 -5
- package/src/inputs/FileInput/index.test.tsx +28 -0
- package/src/inputs/FileInput/index.tsx +102 -43
- package/src/inputs/ImageInput/ImageInput.stories.js +7 -3
- package/src/inputs/ImageInput/__stories__/Default.tsx +1 -1
- package/src/inputs/ImageInput/__stories__/{WithInvalidImageSize.tsx → MaxSize.tsx} +5 -3
- package/src/inputs/ImageInput/__stories__/WithInitialValues.tsx +45 -0
- package/src/inputs/ImageInput/__stories__/WithInvalidImageDimension.tsx +3 -1
- package/src/inputs/ImageInput/__stories__/logo.d.ts +4 -0
- package/src/inputs/ImageInput/__stories__/logo.png +0 -0
- package/src/inputs/ImageInput/doc.mdx +23 -0
- package/src/inputs/ImageInput/index.test.tsx +36 -0
- package/src/inputs/ImageInput/index.tsx +105 -52
- package/src/inputs/Input/Input.stories.js +17 -10
- package/src/inputs/Input/__stories__/AFM.tsx +1 -1
- package/src/inputs/Input/__stories__/AMKA.tsx +23 -0
- package/src/inputs/Input/__stories__/Boolean.tsx +1 -1
- package/src/inputs/Input/__stories__/Email.tsx +23 -0
- package/src/inputs/Input/__stories__/IBAN.tsx +1 -1
- package/src/inputs/Input/__stories__/Integer.tsx +1 -1
- package/src/inputs/Input/__stories__/LandlineNumber.tsx +3 -2
- package/src/inputs/Input/__stories__/MobilePhone.tsx +2 -1
- package/src/inputs/Input/__stories__/PhoneNumber.tsx +2 -1
- package/src/inputs/Input/__stories__/PostalCode.tsx +2 -1
- package/src/inputs/Input/__stories__/Rate.tsx +25 -0
- package/src/inputs/Input/__stories__/{Default.tsx → String.tsx} +2 -2
- package/src/inputs/Input/__stories__/StringWithTrimValidation.tsx +26 -0
- package/src/inputs/Input/__stories__/{TextWithCharacterLimit.tsx → TextWithLimit.tsx} +3 -2
- package/src/inputs/Input/doc.mdx +56 -0
- package/src/inputs/Input/index.test.tsx +76 -0
- package/src/inputs/Input/index.tsx +55 -35
- package/src/inputs/Label/Label.stories.js +4 -1
- package/src/inputs/Label/__stories__/Default.tsx +4 -2
- package/src/inputs/Label/doc.mdx +14 -0
- package/src/inputs/Label/index.test.tsx +24 -0
- package/src/inputs/Label/index.tsx +4 -11
- package/src/inputs/OtpInput/OtpInput.stories.js +4 -1
- package/src/inputs/OtpInput/__stories__/Default.tsx +1 -1
- package/{cjs/inputs/OtpInput/index.mdx → src/inputs/OtpInput/doc.mdx} +1 -8
- package/src/inputs/OtpInput/index.test.tsx +24 -0
- package/src/inputs/OtpInput/index.tsx +45 -34
- package/src/inputs/Radio/Radio.stories.js +6 -3
- package/src/inputs/Radio/__stories__/Conditional.tsx +3 -2
- package/src/inputs/Radio/__stories__/Default.tsx +1 -1
- package/src/inputs/Radio/__stories__/WithDivider.tsx +1 -1
- package/{cjs/inputs/Radio/index.mdx → src/inputs/Radio/doc.mdx} +5 -15
- package/src/inputs/Radio/index.test.tsx +32 -0
- package/src/inputs/Radio/index.tsx +93 -12
- package/src/inputs/Select/Select.stories.js +4 -1
- 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 +24 -0
- package/src/inputs/Select/index.tsx +22 -9
- package/src/inputs/registry.ts +86 -0
- package/src/installation.mdx +2 -5
- package/src/internal.ts +2 -31
- package/src/lazy.ts +56 -0
- package/src/registry.ts +179 -0
- package/src/types.tsx +21 -65
- package/src/utils.ts +67 -33
- package/src/validators/index.ts +138 -99
- package/src/validators/types.ts +1 -1
- package/src/validators/utils/amka.ts +39 -0
- package/src/validators/utils/date.ts +131 -0
- package/src/validators/utils/datetime.ts +222 -0
- package/src/validators/utils/email.ts +11 -0
- package/src/validators/utils/file.ts +35 -19
- package/src/validators/utils/iban.ts +2 -2
- package/src/validators/utils/image.ts +2 -2
- package/src/validators/utils/index.ts +15 -6
- package/src/validators/utils/int.ts +2 -2
- package/src/validators/utils/number.ts +2 -2
- package/src/validators/utils/otp.ts +2 -2
- package/src/validators/utils/phone.ts +65 -74
- package/src/validators/utils/postal_code.ts +3 -3
- package/src/validators/utils/text_limit.ts +2 -2
- package/src/validators/utils/uuid4.ts +2 -1
- package/src/validators/validators.spec.ts +6 -40
- package/types.d.ts +14 -37
- package/types.js +1 -0
- package/utils.d.ts +4 -1
- package/utils.js +56 -0
- package/validators/index.d.ts +6 -6
- package/validators/index.js +115 -180
- package/validators/types.d.ts +1 -1
- package/validators/types.js +0 -0
- package/validators/utils/afm.js +19 -0
- package/validators/utils/amka.d.ts +6 -0
- package/validators/utils/amka.js +27 -0
- package/validators/utils/date.d.ts +9 -0
- package/validators/utils/date.js +95 -0
- package/validators/utils/datetime.d.ts +9 -0
- package/validators/utils/datetime.js +121 -0
- package/validators/utils/email.d.ts +5 -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 -11
- package/validators/utils/index.js +62 -85
- 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 +3 -3
- package/validators/utils/phone.js +198 -0
- package/validators/utils/postal_code.d.ts +3 -3
- 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/FieldBase/index.js +0 -82
- package/Field/FieldBase/package.json +0 -6
- package/Field/FieldBaseContainer/index.js +0 -40
- package/Field/FieldBaseContainer/package.json +0 -6
- package/Field/FieldConditional/index.js +0 -59
- package/Field/FieldConditional/package.json +0 -6
- package/Field/index.mdx +0 -6
- package/Field/package.json +0 -6
- package/Field/types/index.js +0 -1
- package/Field/types/package.json +0 -6
- package/Field/utils/index.js +0 -153
- package/Field/utils/package.json +0 -6
- package/Field/utils.d.ts +0 -5
- package/FieldArray/FieldArray.stories/index.js +0 -8
- package/FieldArray/FieldArray.stories/package.json +0 -6
- package/FieldArray/FieldArray.stories.d.ts +0 -9
- package/FieldArray/FieldArray.stories.playwright.json +0 -353
- package/FieldArray/__stories__/Default/index.js +0 -88
- package/FieldArray/__stories__/Default/package.json +0 -6
- package/FieldArray/__stories__/Default.d.ts +0 -2
- package/FieldArray/__stories__/WithExactLength/index.js +0 -88
- package/FieldArray/__stories__/WithExactLength/package.json +0 -6
- package/FieldArray/__stories__/WithExactLength.d.ts +0 -2
- package/FieldArray/package.json +0 -6
- package/FieldObject/package.json +0 -6
- package/Fieldset/FieldsetWithContext/index.js +0 -35
- package/Fieldset/FieldsetWithContext/package.json +0 -6
- package/Fieldset/package.json +0 -6
- package/Fieldset/types/index.js +0 -1
- package/Fieldset/types/package.json +0 -6
- package/Form.stories/index.js +0 -3
- package/Form.stories/package.json +0 -6
- package/Form.stories.d.ts +0 -4
- package/FormBuilder/FormBuilder/index.js +0 -152
- package/FormBuilder/FormBuilder/package.json +0 -6
- package/FormBuilder/FormBuilder.d.ts +0 -5
- package/FormBuilder/FormBuilder.mdx +0 -256
- package/FormBuilder/FormBuilder.stories/index.js +0 -7
- package/FormBuilder/FormBuilder.stories/package.json +0 -6
- package/FormBuilder/FormBuilder.stories.d.ts +0 -8
- package/FormBuilder/FormBuilder.stories.playwright.json +0 -52
- package/FormBuilder/__stories__/Default/index.js +0 -26
- package/FormBuilder/__stories__/Default/package.json +0 -6
- package/FormBuilder/__stories__/Default.d.ts +0 -3
- package/FormBuilder/package.json +0 -6
- package/FormContext/index.js +0 -5
- package/FormContext/package.json +0 -6
- package/MultiplicityField/MultiplicityField.mdx +0 -590
- package/MultiplicityField/MultiplicityField.stories/index.js +0 -12
- package/MultiplicityField/MultiplicityField.stories/package.json +0 -6
- package/MultiplicityField/MultiplicityField.stories.d.ts +0 -13
- package/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
- package/MultiplicityField/__stories__/Default/index.js +0 -95
- package/MultiplicityField/__stories__/Default/package.json +0 -6
- package/MultiplicityField/__stories__/Default.d.ts +0 -2
- package/MultiplicityField/__stories__/PreviewDisplay/index.js +0 -78
- package/MultiplicityField/__stories__/PreviewDisplay/package.json +0 -6
- package/MultiplicityField/__stories__/PreviewDisplay.d.ts +0 -2
- package/MultiplicityField/__stories__/WithExactLength/index.js +0 -90
- package/MultiplicityField/__stories__/WithExactLength/package.json +0 -6
- package/MultiplicityField/__stories__/WithExactLength.d.ts +0 -2
- package/MultiplicityField/__stories__/WithMaxLength/index.js +0 -93
- package/MultiplicityField/__stories__/WithMaxLength/package.json +0 -6
- package/MultiplicityField/__stories__/WithMaxLength.d.ts +0 -2
- package/MultiplicityField/__stories__/WithMinAndMaxLength/index.js +0 -94
- package/MultiplicityField/__stories__/WithMinAndMaxLength/package.json +0 -6
- package/MultiplicityField/__stories__/WithMinAndMaxLength.d.ts +0 -2
- package/MultiplicityField/__stories__/WithMinLength/index.js +0 -93
- package/MultiplicityField/__stories__/WithMinLength/package.json +0 -6
- package/MultiplicityField/__stories__/WithMinLength.d.ts +0 -2
- package/MultiplicityField/add-objects/index.js +0 -148
- package/MultiplicityField/add-objects/package.json +0 -6
- package/MultiplicityField/package.json +0 -6
- package/Questions/Questions/index.js +0 -75
- package/Questions/Questions/package.json +0 -6
- package/Questions/Questions.stories/index.js +0 -7
- package/Questions/Questions.stories/package.json +0 -6
- package/Questions/Questions.stories.d.ts +0 -8
- package/Questions/QuestionsContext/index.js +0 -11
- package/Questions/QuestionsContext/package.json +0 -6
- package/Questions/Step/ReviewStep/index.js +0 -50
- package/Questions/Step/ReviewStep/package.json +0 -6
- package/Questions/Step/Step/index.js +0 -62
- package/Questions/Step/Step/package.json +0 -6
- package/Questions/Step/StepArrayReview/index.js +0 -46
- package/Questions/Step/StepArrayReview/package.json +0 -6
- package/Questions/Step/StepContext/index.js +0 -27
- package/Questions/Step/StepContext/package.json +0 -6
- package/Questions/Step/StepDescription/index.js +0 -24
- package/Questions/Step/StepDescription/package.json +0 -6
- package/Questions/Step/StepForm/index.js +0 -44
- package/Questions/Step/StepForm/package.json +0 -6
- package/Questions/Step/StepQuote/index.js +0 -10
- package/Questions/Step/StepQuote/package.json +0 -6
- package/Questions/Step/StepTitle/index.js +0 -41
- package/Questions/Step/StepTitle/package.json +0 -6
- package/Questions/Step/getAddMoreFields/index.js +0 -21
- package/Questions/Step/getAddMoreFields/package.json +0 -6
- 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/__snapshots__/index.spec.tsx.snap +0 -596
- package/Questions/__stories__/Default/index.js +0 -102
- package/Questions/__stories__/Default/package.json +0 -6
- package/Questions/__stories__/Default.d.ts +0 -3
- package/Questions/getNextStep/index.js +0 -20
- package/Questions/getNextStep/package.json +0 -6
- package/Questions/index.spec/index.js +0 -59
- package/Questions/index.spec/package.json +0 -6
- package/Questions/index.spec.d.ts +0 -1
- package/Questions/package.json +0 -6
- package/Questions/types/index.js +0 -1
- package/Questions/types/package.json +0 -6
- package/cjs/Field/FieldBase/index.js +0 -89
- package/cjs/Field/FieldBaseContainer/index.js +0 -47
- package/cjs/Field/FieldConditional/index.js +0 -66
- package/cjs/Field/index.js +0 -80
- package/cjs/Field/index.mdx +0 -6
- package/cjs/Field/types/index.js +0 -5
- package/cjs/Field/utils/index.js +0 -162
- package/cjs/FieldArray/FieldArray.stories/index.js +0 -38
- package/cjs/FieldArray/FieldArray.stories.playwright.json +0 -353
- package/cjs/FieldArray/__stories__/Default/index.js +0 -98
- package/cjs/FieldArray/__stories__/WithExactLength/index.js +0 -98
- package/cjs/FieldArray/index.js +0 -68
- package/cjs/FieldObject/index.js +0 -64
- package/cjs/Fieldset/FieldsetWithContext/index.js +0 -45
- package/cjs/Fieldset/index.js +0 -44
- package/cjs/Fieldset/types/index.js +0 -5
- package/cjs/Form.stories/index.js +0 -9
- package/cjs/FormBuilder/FormBuilder/index.js +0 -162
- package/cjs/FormBuilder/FormBuilder.mdx +0 -256
- package/cjs/FormBuilder/FormBuilder.stories/index.js +0 -26
- package/cjs/FormBuilder/FormBuilder.stories.playwright.json +0 -52
- package/cjs/FormBuilder/__stories__/Default/index.js +0 -36
- package/cjs/FormBuilder/index.js +0 -8
- package/cjs/FormContext/index.js +0 -11
- package/cjs/MultiplicityField/MultiplicityField.stories/index.js +0 -86
- package/cjs/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
- package/cjs/MultiplicityField/__stories__/Default/index.js +0 -105
- package/cjs/MultiplicityField/__stories__/PreviewDisplay/index.js +0 -88
- package/cjs/MultiplicityField/__stories__/WithExactLength/index.js +0 -100
- package/cjs/MultiplicityField/__stories__/WithMaxLength/index.js +0 -103
- package/cjs/MultiplicityField/__stories__/WithMinAndMaxLength/index.js +0 -104
- package/cjs/MultiplicityField/__stories__/WithMinLength/index.js +0 -103
- package/cjs/MultiplicityField/add-objects/index.js +0 -155
- package/cjs/MultiplicityField/index.js +0 -123
- package/cjs/Questions/Questions/index.js +0 -85
- package/cjs/Questions/Questions.stories/index.js +0 -26
- package/cjs/Questions/QuestionsContext/index.js +0 -17
- package/cjs/Questions/Step/ReviewStep/index.js +0 -60
- package/cjs/Questions/Step/Step/index.js +0 -72
- package/cjs/Questions/Step/StepArrayReview/index.js +0 -56
- package/cjs/Questions/Step/StepContext/index.js +0 -33
- package/cjs/Questions/Step/StepDescription/index.js +0 -34
- package/cjs/Questions/Step/StepForm/index.js +0 -54
- package/cjs/Questions/Step/StepQuote/index.js +0 -17
- package/cjs/Questions/Step/StepTitle/index.js +0 -51
- package/cjs/Questions/Step/getAddMoreFields/index.js +0 -27
- package/cjs/Questions/Step/index.js +0 -143
- package/cjs/Questions/Step/types/index.js +0 -5
- package/cjs/Questions/__snapshots__/index.spec.tsx.snap +0 -596
- package/cjs/Questions/__stories__/Default/index.js +0 -113
- package/cjs/Questions/getNextStep/index.js +0 -26
- package/cjs/Questions/index.js +0 -21
- package/cjs/Questions/index.mdx +0 -415
- package/cjs/Questions/index.spec/index.js +0 -63
- package/cjs/Questions/types/index.js +0 -5
- package/cjs/create-simple-form.mdx +0 -539
- package/cjs/index.js +0 -22
- package/cjs/index.mdx +0 -51
- package/cjs/inputs/AutoCompleteInput/AutoComplete.stories/index.js +0 -38
- package/cjs/inputs/AutoCompleteInput/__stories__/Default/index.js +0 -51
- package/cjs/inputs/AutoCompleteInput/__stories__/Multiple/index.js +0 -52
- package/cjs/inputs/AutoCompleteInput/index.js +0 -66
- package/cjs/inputs/Checkboxes/Checkboxes.stories/index.js +0 -50
- package/cjs/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
- package/cjs/inputs/Checkboxes/__stories__/Conditional/index.js +0 -103
- package/cjs/inputs/Checkboxes/__stories__/Default/index.js +0 -50
- package/cjs/inputs/Checkboxes/__stories__/WithDivider/index.js +0 -51
- package/cjs/inputs/Checkboxes/index.js +0 -101
- package/cjs/inputs/Checkboxes/index.mdx +0 -33
- package/cjs/inputs/DateInput/DateInput.stories/index.js +0 -26
- package/cjs/inputs/DateInput/DateInput.stories.playwright.json +0 -72
- package/cjs/inputs/DateInput/__stories__/Default/index.js +0 -33
- package/cjs/inputs/DateInput/index.js +0 -141
- package/cjs/inputs/DateInput/index.mdx +0 -23
- package/cjs/inputs/FileInput/FileInput.stories/index.js +0 -26
- package/cjs/inputs/FileInput/FileInput.stories.playwright.json +0 -75
- package/cjs/inputs/FileInput/__stories__/Default/index.js +0 -30
- package/cjs/inputs/FileInput/index.js +0 -68
- package/cjs/inputs/FileInput/index.mdx +0 -19
- package/cjs/inputs/ImageInput/ImageInput.stories/index.js +0 -50
- package/cjs/inputs/ImageInput/ImageInput.stories.playwright.json +0 -77
- package/cjs/inputs/ImageInput/__stories__/Default/index.js +0 -38
- package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +0 -46
- package/cjs/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +0 -43
- package/cjs/inputs/ImageInput/index.js +0 -86
- package/cjs/inputs/ImageInput/index.mdx +0 -19
- package/cjs/inputs/Input/Input.stories/index.js +0 -134
- package/cjs/inputs/Input/Input.stories.playwright.json +0 -376
- package/cjs/inputs/Input/__stories__/AFM/index.js +0 -32
- package/cjs/inputs/Input/__stories__/Boolean/index.js +0 -33
- package/cjs/inputs/Input/__stories__/Default/index.js +0 -33
- package/cjs/inputs/Input/__stories__/IBAN/index.js +0 -33
- package/cjs/inputs/Input/__stories__/Integer/index.js +0 -41
- package/cjs/inputs/Input/__stories__/LandlineNumber/index.js +0 -36
- package/cjs/inputs/Input/__stories__/MobilePhone/index.js +0 -36
- package/cjs/inputs/Input/__stories__/PhoneNumber/index.js +0 -35
- package/cjs/inputs/Input/__stories__/PostalCode/index.js +0 -35
- package/cjs/inputs/Input/__stories__/TextWithCharacterLimit/index.js +0 -39
- package/cjs/inputs/Input/index.js +0 -76
- package/cjs/inputs/Input/index.mdx +0 -95
- package/cjs/inputs/Label/Label.stories/index.js +0 -26
- package/cjs/inputs/Label/Label.stories.playwright.json +0 -40
- package/cjs/inputs/Label/__stories__/Default/index.js +0 -37
- package/cjs/inputs/Label/index.js +0 -29
- package/cjs/inputs/OtpInput/OtpInput.stories/index.js +0 -26
- package/cjs/inputs/OtpInput/__stories__/Default/index.js +0 -39
- package/cjs/inputs/OtpInput/index.js +0 -151
- package/cjs/inputs/Radio/Radio.stories/index.js +0 -50
- package/cjs/inputs/Radio/Radio.stories.playwright.json +0 -73
- package/cjs/inputs/Radio/__stories__/Conditional/index.js +0 -103
- package/cjs/inputs/Radio/__stories__/Default/index.js +0 -55
- package/cjs/inputs/Radio/__stories__/WithDivider/index.js +0 -56
- package/cjs/inputs/Radio/index.js +0 -64
- package/cjs/inputs/Select/Select.stories/index.js +0 -26
- package/cjs/inputs/Select/Select.stories.playwright.json +0 -22
- package/cjs/inputs/Select/__stories__/Default/index.js +0 -61
- package/cjs/inputs/Select/index.js +0 -38
- package/cjs/inputs/Select/index.mdx +0 -17
- package/cjs/inputs/index.js +0 -69
- package/cjs/installation.mdx +0 -68
- package/cjs/internal/index.js +0 -348
- package/cjs/lazy/index.js +0 -517
- package/cjs/registry/index.js +0 -147
- package/cjs/types/index.js +0 -5
- package/cjs/utils/index.js +0 -87
- package/cjs/validators/index.js +0 -193
- package/cjs/validators/types/index.js +0 -5
- package/cjs/validators/utils/afm/index.js +0 -38
- package/cjs/validators/utils/file/index.js +0 -43
- package/cjs/validators/utils/iban/index.js +0 -123
- package/cjs/validators/utils/image/index.js +0 -126
- package/cjs/validators/utils/index.js +0 -204
- package/cjs/validators/utils/int/index.js +0 -26
- package/cjs/validators/utils/number/index.js +0 -22
- package/cjs/validators/utils/otp/index.js +0 -32
- package/cjs/validators/utils/phone/index.js +0 -143
- package/cjs/validators/utils/postal_code/index.js +0 -34
- package/cjs/validators/utils/text_limit/index.js +0 -54
- package/cjs/validators/utils/uuid4/index.js +0 -25
- package/cjs/validators/validators.spec/index.js +0 -87
- package/create-simple-form.mdx +0 -539
- package/index.mdx +0 -51
- package/inputs/AutoCompleteInput/AutoComplete.stories/index.js +0 -8
- package/inputs/AutoCompleteInput/AutoComplete.stories/package.json +0 -6
- package/inputs/AutoCompleteInput/AutoComplete.stories.d.ts +0 -9
- package/inputs/AutoCompleteInput/__stories__/Default/index.js +0 -44
- package/inputs/AutoCompleteInput/__stories__/Default/package.json +0 -6
- package/inputs/AutoCompleteInput/__stories__/Default.d.ts +0 -3
- package/inputs/AutoCompleteInput/__stories__/Multiple/index.js +0 -45
- package/inputs/AutoCompleteInput/__stories__/Multiple/package.json +0 -6
- package/inputs/AutoCompleteInput/__stories__/Multiple.d.ts +0 -3
- package/inputs/AutoCompleteInput/index.mdx +0 -29
- package/inputs/AutoCompleteInput/package.json +0 -6
- package/inputs/Checkboxes/Checkboxes.stories/index.js +0 -9
- package/inputs/Checkboxes/Checkboxes.stories/package.json +0 -6
- package/inputs/Checkboxes/Checkboxes.stories.d.ts +0 -10
- package/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
- package/inputs/Checkboxes/__stories__/Conditional/index.js +0 -93
- package/inputs/Checkboxes/__stories__/Conditional/package.json +0 -6
- package/inputs/Checkboxes/__stories__/Conditional.d.ts +0 -3
- package/inputs/Checkboxes/__stories__/Default/index.js +0 -40
- package/inputs/Checkboxes/__stories__/Default/package.json +0 -6
- package/inputs/Checkboxes/__stories__/Default.d.ts +0 -3
- package/inputs/Checkboxes/__stories__/WithDivider/index.js +0 -41
- package/inputs/Checkboxes/__stories__/WithDivider/package.json +0 -6
- package/inputs/Checkboxes/__stories__/WithDivider.d.ts +0 -3
- package/inputs/Checkboxes/index.mdx +0 -33
- package/inputs/Checkboxes/package.json +0 -6
- package/inputs/DateInput/DateInput.stories/index.js +0 -7
- package/inputs/DateInput/DateInput.stories/package.json +0 -6
- package/inputs/DateInput/DateInput.stories.d.ts +0 -8
- package/inputs/DateInput/DateInput.stories.playwright.json +0 -72
- package/inputs/DateInput/__stories__/Default/index.js +0 -23
- package/inputs/DateInput/__stories__/Default/package.json +0 -6
- package/inputs/DateInput/__stories__/Default.d.ts +0 -3
- package/inputs/DateInput/index.mdx +0 -23
- package/inputs/DateInput/package.json +0 -6
- package/inputs/FileInput/FileInput.stories/index.js +0 -7
- package/inputs/FileInput/FileInput.stories/package.json +0 -6
- package/inputs/FileInput/FileInput.stories.d.ts +0 -8
- package/inputs/FileInput/FileInput.stories.playwright.json +0 -75
- package/inputs/FileInput/__stories__/Default/index.js +0 -20
- package/inputs/FileInput/__stories__/Default/package.json +0 -6
- package/inputs/FileInput/__stories__/Default.d.ts +0 -3
- package/inputs/FileInput/package.json +0 -6
- package/inputs/ImageInput/ImageInput.stories/index.js +0 -9
- package/inputs/ImageInput/ImageInput.stories/package.json +0 -6
- package/inputs/ImageInput/ImageInput.stories.d.ts +0 -10
- package/inputs/ImageInput/ImageInput.stories.playwright.json +0 -77
- package/inputs/ImageInput/__stories__/Default/index.js +0 -28
- package/inputs/ImageInput/__stories__/Default/package.json +0 -6
- package/inputs/ImageInput/__stories__/Default.d.ts +0 -3
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +0 -36
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension/package.json +0 -6
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension.d.ts +0 -3
- package/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +0 -33
- package/inputs/ImageInput/__stories__/WithInvalidImageSize/package.json +0 -6
- package/inputs/ImageInput/__stories__/WithInvalidImageSize.d.ts +0 -3
- package/inputs/ImageInput/index.mdx +0 -19
- package/inputs/ImageInput/package.json +0 -6
- package/inputs/Input/Input.stories/index.js +0 -16
- package/inputs/Input/Input.stories/package.json +0 -6
- package/inputs/Input/Input.stories.d.ts +0 -17
- package/inputs/Input/Input.stories.playwright.json +0 -376
- package/inputs/Input/__stories__/AFM/index.js +0 -22
- package/inputs/Input/__stories__/AFM/package.json +0 -6
- package/inputs/Input/__stories__/AFM.d.ts +0 -3
- package/inputs/Input/__stories__/Boolean/index.js +0 -23
- package/inputs/Input/__stories__/Boolean/package.json +0 -6
- package/inputs/Input/__stories__/Boolean.d.ts +0 -3
- package/inputs/Input/__stories__/Default/index.js +0 -23
- package/inputs/Input/__stories__/Default/package.json +0 -6
- package/inputs/Input/__stories__/Default.d.ts +0 -3
- package/inputs/Input/__stories__/IBAN/index.js +0 -23
- package/inputs/Input/__stories__/IBAN/package.json +0 -6
- package/inputs/Input/__stories__/IBAN.d.ts +0 -3
- package/inputs/Input/__stories__/Integer/index.js +0 -31
- package/inputs/Input/__stories__/Integer/package.json +0 -6
- package/inputs/Input/__stories__/Integer.d.ts +0 -3
- package/inputs/Input/__stories__/LandlineNumber/index.js +0 -26
- package/inputs/Input/__stories__/LandlineNumber/package.json +0 -6
- package/inputs/Input/__stories__/LandlineNumber.d.ts +0 -3
- package/inputs/Input/__stories__/MobilePhone/index.js +0 -26
- package/inputs/Input/__stories__/MobilePhone/package.json +0 -6
- package/inputs/Input/__stories__/MobilePhone.d.ts +0 -3
- package/inputs/Input/__stories__/PhoneNumber/index.js +0 -25
- package/inputs/Input/__stories__/PhoneNumber/package.json +0 -6
- package/inputs/Input/__stories__/PhoneNumber.d.ts +0 -3
- package/inputs/Input/__stories__/PostalCode/index.js +0 -25
- package/inputs/Input/__stories__/PostalCode/package.json +0 -6
- package/inputs/Input/__stories__/PostalCode.d.ts +0 -3
- package/inputs/Input/__stories__/TextWithCharacterLimit/index.js +0 -29
- package/inputs/Input/__stories__/TextWithCharacterLimit/package.json +0 -6
- package/inputs/Input/__stories__/TextWithCharacterLimit.d.ts +0 -3
- package/inputs/Input/index.mdx +0 -95
- package/inputs/Input/package.json +0 -6
- package/inputs/Label/Label.stories/index.js +0 -7
- package/inputs/Label/Label.stories/package.json +0 -6
- package/inputs/Label/Label.stories.d.ts +0 -8
- package/inputs/Label/Label.stories.playwright.json +0 -40
- package/inputs/Label/__stories__/Default/index.js +0 -27
- package/inputs/Label/__stories__/Default/package.json +0 -6
- package/inputs/Label/__stories__/Default.d.ts +0 -3
- package/inputs/Label/package.json +0 -6
- package/inputs/OtpInput/OtpInput.stories/index.js +0 -7
- package/inputs/OtpInput/OtpInput.stories/package.json +0 -6
- package/inputs/OtpInput/OtpInput.stories.d.ts +0 -8
- package/inputs/OtpInput/__stories__/Default/index.js +0 -29
- package/inputs/OtpInput/__stories__/Default/package.json +0 -6
- package/inputs/OtpInput/__stories__/Default.d.ts +0 -3
- package/inputs/OtpInput/index.mdx +0 -23
- package/inputs/OtpInput/package.json +0 -6
- package/inputs/Radio/Radio.stories/index.js +0 -9
- package/inputs/Radio/Radio.stories/package.json +0 -6
- package/inputs/Radio/Radio.stories.d.ts +0 -10
- package/inputs/Radio/Radio.stories.playwright.json +0 -73
- package/inputs/Radio/__stories__/Conditional/index.js +0 -93
- package/inputs/Radio/__stories__/Conditional/package.json +0 -6
- package/inputs/Radio/__stories__/Conditional.d.ts +0 -3
- package/inputs/Radio/__stories__/Default/index.js +0 -45
- package/inputs/Radio/__stories__/Default/package.json +0 -6
- package/inputs/Radio/__stories__/Default.d.ts +0 -3
- package/inputs/Radio/__stories__/WithDivider/index.js +0 -46
- package/inputs/Radio/__stories__/WithDivider/package.json +0 -6
- package/inputs/Radio/__stories__/WithDivider.d.ts +0 -3
- package/inputs/Radio/index.mdx +0 -33
- package/inputs/Radio/package.json +0 -6
- package/inputs/Select/Select.stories/index.js +0 -7
- package/inputs/Select/Select.stories/package.json +0 -6
- package/inputs/Select/Select.stories.d.ts +0 -8
- package/inputs/Select/Select.stories.playwright.json +0 -22
- package/inputs/Select/__stories__/Default/index.js +0 -51
- package/inputs/Select/__stories__/Default/package.json +0 -6
- package/inputs/Select/__stories__/Default.d.ts +0 -3
- package/inputs/Select/index.mdx +0 -17
- package/inputs/Select/package.json +0 -6
- package/inputs/package.json +0 -6
- package/installation.mdx +0 -68
- package/internal/index.js +0 -34
- package/internal/package.json +0 -6
- package/lazy/index.js +0 -395
- package/lazy/package.json +0 -6
- package/registry/index.js +0 -138
- package/registry/package.json +0 -6
- package/src/Field/index.mdx +0 -6
- package/src/Field/utils.ts +0 -191
- package/src/FieldArray/FieldArray.stories.playwright.json +0 -353
- package/src/FormBuilder/FormBuilder.stories.playwright.json +0 -52
- package/src/FormBuilder/FormBuilder.tsx +0 -166
- package/src/MultiplicityField/MultiplicityField.mdx +0 -590
- package/src/MultiplicityField/MultiplicityField.stories.playwright.json +0 -1370
- package/src/Questions/index.mdx +0 -415
- package/src/inputs/AutoCompleteInput/index.mdx +0 -29
- package/src/inputs/Checkboxes/Checkboxes.stories.playwright.json +0 -85
- package/src/inputs/DateInput/DateInput.stories.playwright.json +0 -72
- package/src/inputs/FileInput/FileInput.stories.playwright.json +0 -75
- package/src/inputs/FileInput/index.mdx +0 -19
- package/src/inputs/ImageInput/ImageInput.stories.playwright.json +0 -77
- package/src/inputs/ImageInput/index.mdx +0 -19
- package/src/inputs/Input/Input.stories.playwright.json +0 -376
- package/src/inputs/Input/index.mdx +0 -95
- package/src/inputs/Label/Label.stories.playwright.json +0 -40
- package/src/inputs/OtpInput/index.mdx +0 -23
- package/src/inputs/Radio/Radio.stories.playwright.json +0 -73
- package/src/inputs/Radio/index.mdx +0 -33
- package/src/inputs/Select/Select.stories.playwright.json +0 -22
- package/src/lazy.js +0 -60
- package/src/registry.js +0 -145
- package/types/index.js +0 -1
- package/types/package.json +0 -6
- package/utils/index.js +0 -80
- package/utils/package.json +0 -6
- package/validators/package.json +0 -6
- package/validators/types/index.js +0 -1
- package/validators/types/package.json +0 -6
- package/validators/utils/afm/index.js +0 -31
- package/validators/utils/afm/package.json +0 -6
- package/validators/utils/file/index.js +0 -37
- package/validators/utils/file/package.json +0 -6
- package/validators/utils/iban/index.js +0 -116
- package/validators/utils/iban/package.json +0 -6
- package/validators/utils/image/index.js +0 -119
- package/validators/utils/image/package.json +0 -6
- package/validators/utils/int/index.js +0 -19
- package/validators/utils/int/package.json +0 -6
- package/validators/utils/number/index.js +0 -15
- package/validators/utils/number/package.json +0 -6
- package/validators/utils/otp/index.js +0 -25
- package/validators/utils/otp/package.json +0 -6
- package/validators/utils/package.json +0 -6
- package/validators/utils/phone/index.js +0 -134
- package/validators/utils/phone/package.json +0 -6
- package/validators/utils/postal_code/index.js +0 -27
- package/validators/utils/postal_code/package.json +0 -6
- package/validators/utils/text_limit/index.js +0 -47
- package/validators/utils/text_limit/package.json +0 -6
- package/validators/utils/uuid4/index.js +0 -18
- package/validators/utils/uuid4/package.json +0 -6
- package/validators/validators.spec/index.js +0 -85
- package/validators/validators.spec/package.json +0 -6
- package/validators/validators.spec.d.ts +0 -1
- /package/{cjs/inputs/Label/index.mdx → Field/types.js} +0 -0
- /package/{inputs/Label/index.mdx → Fieldset/types.js} +0 -0
- /package/{src/inputs/Label/index.mdx → MultiplicityField/types.js} +0 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Form
|
|
3
|
+
parent: docs/form/components
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Field
|
|
7
|
+
|
|
8
|
+
Field allow users to create different types of inputs based on data that is described by a particular config schema.
|
|
9
|
+
|
|
10
|
+
```jsx
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import FormBuilder, { Field } from '@digigov/form';
|
|
13
|
+
import { Button } from '@digigov/ui/form/Button';
|
|
14
|
+
|
|
15
|
+
const fields = [
|
|
16
|
+
{
|
|
17
|
+
key: 'first_name',
|
|
18
|
+
type: 'string',
|
|
19
|
+
required: true,
|
|
20
|
+
label: {
|
|
21
|
+
primary: 'Ποιo είναι το όνομά σας;',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
export const MyComponent = () => (
|
|
27
|
+
<FormBuilder onSubmit={(data) => console.log(data)}>
|
|
28
|
+
{fields.map(({ key, ...field }) => {
|
|
29
|
+
return <Field {...field} name={key} key={key} />;
|
|
30
|
+
})}
|
|
31
|
+
<Button type="submit">Συνέχεια</Button>
|
|
32
|
+
</FormBuilder>
|
|
33
|
+
);
|
|
34
|
+
export default MyComponent;
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Accessibility & Usability
|
|
38
|
+
|
|
39
|
+
Our goal is to create semantically correct and valid forms, which means
|
|
40
|
+
we must avoid mixing form-related HTML elements (like form, input, label) with generic
|
|
41
|
+
ones (such as div, cards, or custom components). For instance, if a paragraph element is
|
|
42
|
+
placed inside a form, React will display warnings in the console. Rather than building overly
|
|
43
|
+
complex interfaces that attempt to accomplish too much too quickly, Digigov Form encourages
|
|
44
|
+
using forms in their intended way—filling out and validating inputs, and then submitting the form
|
|
45
|
+
as a whole.
|
|
46
|
+
|
|
47
|
+
Additionally, we must ensure our interfaces are fully accessible to screen readers and other
|
|
48
|
+
assistive technologies. This is why we designed the flow to be as guided and recoverable as possible.
|
|
49
|
+
Forms and fields should be clear and logical, reading like well-written text for the users.
|
|
50
|
+
If validation fails, the system provides users with meaningful error messages and clear instructions on how to correct the errors.
|
|
51
|
+
Once validation is successful, the data can be submitted. It is crucial to provide helpful information to users at each step.
|
|
52
|
+
Therefore, we should avoid relying on flashy “magic” UX solutions that assume users have advanced digital skills,
|
|
53
|
+
as these are often intended for expert use cases.
|
|
54
|
+
|
|
55
|
+
## Introducing the Field component
|
|
56
|
+
|
|
57
|
+
Field is a component that creates `form` inputs dynamically based on a `data config` schema.
|
|
58
|
+
The config structure is a `key-value` pair of data that describes the input fields and its usage.
|
|
59
|
+
In order to create an input, we need to provide a specific type of input for each field,
|
|
60
|
+
and we can use the `type` property for this.
|
|
61
|
+
|
|
62
|
+
## Field types
|
|
63
|
+
|
|
64
|
+
The `type` property determines the type of input field to be rendered. Below are the available types and their descriptions.
|
|
65
|
+
|
|
66
|
+
| Type | Input Description |
|
|
67
|
+
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|
|
68
|
+
| `int` | A whole number. |
|
|
69
|
+
| `string` | A text string (e.g., name, address). |
|
|
70
|
+
| `text` | A larger text input, suitable for paragraphs or multiline text. |
|
|
71
|
+
| `boolean` | A binary value, typically a checkbox or toggle (true/false). |
|
|
72
|
+
| `email` | An email address (e.g., example@example.com). |
|
|
73
|
+
| `uuid4` | A universally unique identifier (UUID) in version 4 format. |
|
|
74
|
+
| `choice:multiple` | A selection of multiple options from a list (e.g., checkboxes). |
|
|
75
|
+
| `choice:single` | A single selection from a list (e.g., radio buttons). |
|
|
76
|
+
| `mobile_phone` | A phone number, typically with country code (e.g., +1-234-567-890). |
|
|
77
|
+
| `date` | A date input, typically in the format YYYY-MM-DD. |
|
|
78
|
+
| `datetime` | A date and time input, typically in the format YYYY-MM-DD HH:MM:SS. |
|
|
79
|
+
| `otp` | A one-time password, typically a short numeric or alphanumeric string. |
|
|
80
|
+
| `afm` | A Greek Tax Identification Number (AFM). |
|
|
81
|
+
| `iban` | An International Bank Account Number (IBAN). |
|
|
82
|
+
| `file` | A file upload input (e.g., for documents, images). |
|
|
83
|
+
| `image` | A file input that specifically handles images. |
|
|
84
|
+
| `postal_code` | A postal code input (e.g., ZIP code, postcode). |
|
|
85
|
+
| `phone_number` | A phone number input (e.g., with or without country code). |
|
|
86
|
+
| `array` | A list of values, typically displayed as multiple inputs ([MultiplicityField](/components/@digigov/form/MultiplicityField.html)). |
|
|
87
|
+
| `object` | A structured data object, often used for more complex or nested forms. |
|
|
88
|
+
|
|
89
|
+
## Field properties
|
|
90
|
+
|
|
91
|
+
The Field component accepts several properties, that describes the input fields and its usage.
|
|
92
|
+
|
|
93
|
+
| Property | Type | Description |
|
|
94
|
+
| -------------- | ----------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
|
|
95
|
+
| `key` | `string` | The name of the field (TODO: rename to `name`). |
|
|
96
|
+
| `type` | Describes the format of each field, e.g., `type: 'string'` is a simple input format field | The type of input field. Defines the kind of value it accepts. |
|
|
97
|
+
| `trim` | `boolean` | If `true`, trims the input value. |
|
|
98
|
+
| `component` | `any` | A custom React component for the input field. |
|
|
99
|
+
| `autoComplete` | `string` | The `autocomplete` attribute value for the input field (e.g., 'on', 'off'). |
|
|
100
|
+
| `maxLength` | `number` | The maximum number of characters the input can accept. |
|
|
101
|
+
| `condition` | `Record<string, FieldCondition>` | Conditions for when the field should be shown, enabled, or validated. |
|
|
102
|
+
| `controlled` | `boolean` | If `true`, the input value is controlled by React state. |
|
|
103
|
+
| `label` | `FieldLabelProps` | The label associated with the input field. |
|
|
104
|
+
| `extra` | `Record<string, any>` | Extra custom attributes or settings for the field. |
|
|
105
|
+
| `editable` | `boolean` | If `false`, the field cannot be edited. |
|
|
106
|
+
| `variant` | `'inline' \| 'dialog'` | Defines the display variant of the field (e.g., inline or in a dialog). |
|
|
107
|
+
| `required` | `boolean` | If `true`, the field is required to be filled. |
|
|
108
|
+
| `enabled` | `boolean` | If `false`, the field is disabled and cannot be interacted with. |
|
|
109
|
+
| `disabled` | `boolean` | If `true`, the field is disabled. |
|
|
110
|
+
| `layout` | `Record<string, GridProps['xs' \| 'sm' \| 'md' \| 'lg' \| 'xl']>` | Defines the layout settings for the field (grid system). |
|
|
111
|
+
| `validators` | `ValidatorSchema[]` | Array of validators to be applied to the input field. |
|
|
112
|
+
| `wrapper` | `'label' \| 'fieldset'` | Defines the wrapping element for the field (label or fieldset). |
|
|
113
|
+
| `maxWidth` | `string` | The maximum width of the field. |
|
|
114
|
+
| `maxHeight` | `string` | The maximum height of the field. |
|
|
115
|
+
| `width` | `string` | The width of the field. |
|
|
116
|
+
|
|
117
|
+
### How to use it
|
|
118
|
+
|
|
119
|
+
The `Field` component is a fundamental building block of the `form`.
|
|
120
|
+
We can implement a `Field` by using the `data config` or we can fill the `Field` directly with its properties.
|
|
121
|
+
|
|
122
|
+
First, we need to import the `FormBuilder` component from the `@digigov/form` path.
|
|
123
|
+
|
|
124
|
+
```jsx pure
|
|
125
|
+
import React from 'react';
|
|
126
|
+
import FormBuilder from '@digigov/form';
|
|
127
|
+
import Button from '@digigov/ui/form/Button';
|
|
128
|
+
|
|
129
|
+
export default function MyFieldComponent() {
|
|
130
|
+
return (
|
|
131
|
+
<FormBuilder>
|
|
132
|
+
{/* this is where all fields will eventually be rendered */}
|
|
133
|
+
<Button type="submit">Συνέχεια</Button>
|
|
134
|
+
</FormBuilder>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
#### Data config
|
|
140
|
+
|
|
141
|
+
The `data config` is an array of objects that contains the configuration for each field.
|
|
142
|
+
|
|
143
|
+
```jsx pure
|
|
144
|
+
const fields = [
|
|
145
|
+
{
|
|
146
|
+
key: 'first_name',
|
|
147
|
+
type: 'string',
|
|
148
|
+
required: true,
|
|
149
|
+
label: {
|
|
150
|
+
primary: 'Ποιo είναι το όνομά σας;',
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
];
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Then we can use the `fields` array to render the Field(s).
|
|
157
|
+
|
|
158
|
+
```jsx pure
|
|
159
|
+
import React from 'react';
|
|
160
|
+
import FormBuilder, { Field } from '@digigov/form';
|
|
161
|
+
import { Button } from '@digigov/ui/form/Button';
|
|
162
|
+
|
|
163
|
+
const fields = [
|
|
164
|
+
{
|
|
165
|
+
key: 'first_name',
|
|
166
|
+
type: 'string',
|
|
167
|
+
required: true,
|
|
168
|
+
label: {
|
|
169
|
+
primary: 'Ποιo είναι το όνομά σας;',
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
];
|
|
173
|
+
|
|
174
|
+
export const MyComponent = () => (
|
|
175
|
+
<FormBuilder onSubmit={(data) => console.log(data)}>
|
|
176
|
+
{fields.map(({ key, ...field }) => {
|
|
177
|
+
return <Field {...field} name={key} key={key} />;
|
|
178
|
+
})}
|
|
179
|
+
<Button type="submit">Συνέχεια</Button>
|
|
180
|
+
</FormBuilder>
|
|
181
|
+
);
|
|
182
|
+
export default MyComponent;
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
#### Directly
|
|
186
|
+
|
|
187
|
+
We can also use the `Field` component directly and pass the properties to it.
|
|
188
|
+
|
|
189
|
+
```jsx pure
|
|
190
|
+
import React from 'react';
|
|
191
|
+
import FormBuilder, { Field } from '@digigov/form';
|
|
192
|
+
import { Button } from '@digigov/ui/form/Button';
|
|
193
|
+
|
|
194
|
+
export const MyComponent = () => (
|
|
195
|
+
<FormBuilder onSubmit={(data) => console.log(data)}>
|
|
196
|
+
<Field
|
|
197
|
+
key="first_name"
|
|
198
|
+
name="first_name"
|
|
199
|
+
label={{ primary: 'Οχήματα' }}
|
|
200
|
+
type="sting"
|
|
201
|
+
required
|
|
202
|
+
/>
|
|
203
|
+
<Button type="submit">Συνέχεια</Button>
|
|
204
|
+
</FormBuilder>
|
|
205
|
+
);
|
|
206
|
+
export default MyComponent;
|
|
207
|
+
```
|
package/src/Field/index.tsx
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import { FieldBase } from '@digigov/form/Field/FieldBase';
|
|
3
3
|
import FieldConditional from '@digigov/form/Field/FieldConditional';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
FieldProps,
|
|
8
|
-
} from '@digigov/form/Field/types';
|
|
9
|
-
import { useField, calculateField } from '@digigov/form/Field/utils';
|
|
4
|
+
import type { FieldWithCondition, FieldProps } from '@digigov/form/Field/types';
|
|
5
|
+
import { resolveField } from '@digigov/form/Field/utils/resolveField';
|
|
6
|
+
import { useField } from '@digigov/form/Field/utils/useField';
|
|
10
7
|
import FieldArray from '@digigov/form/FieldArray';
|
|
11
8
|
import Multiplicity from '@digigov/form/MultiplicityField';
|
|
12
|
-
|
|
13
9
|
export const Field: React.FC<FieldProps> = ({
|
|
14
10
|
name,
|
|
15
11
|
children,
|
|
@@ -20,6 +16,7 @@ export const Field: React.FC<FieldProps> = ({
|
|
|
20
16
|
control,
|
|
21
17
|
register,
|
|
22
18
|
reset,
|
|
19
|
+
resetField,
|
|
23
20
|
error,
|
|
24
21
|
componentRegistry,
|
|
25
22
|
formState,
|
|
@@ -28,40 +25,47 @@ export const Field: React.FC<FieldProps> = ({
|
|
|
28
25
|
unregister,
|
|
29
26
|
trigger,
|
|
30
27
|
clearErrors,
|
|
28
|
+
registerFieldFocus,
|
|
31
29
|
} = useField(name, customField?.type ? customField : null);
|
|
32
|
-
const
|
|
33
|
-
() =>
|
|
30
|
+
const resolvedField = useMemo(
|
|
31
|
+
() => resolveField(children, field, componentRegistry),
|
|
34
32
|
[field]
|
|
35
33
|
);
|
|
36
|
-
|
|
37
|
-
if (calculatedField.condition) {
|
|
34
|
+
if (resolvedField.condition) {
|
|
38
35
|
return (
|
|
39
36
|
<FieldConditional
|
|
40
37
|
control={control}
|
|
41
38
|
reset={reset}
|
|
39
|
+
resetField={resetField}
|
|
42
40
|
register={register}
|
|
43
|
-
field={
|
|
41
|
+
field={resolvedField as FieldWithCondition}
|
|
44
42
|
error={error}
|
|
43
|
+
Field={Field}
|
|
45
44
|
/>
|
|
46
45
|
);
|
|
47
46
|
}
|
|
48
|
-
if (
|
|
49
|
-
|
|
47
|
+
if (resolvedField.type === 'array' && !resolvedField.multiplicity) {
|
|
48
|
+
resolvedField.name = name;
|
|
50
49
|
return (
|
|
51
50
|
<FieldArray
|
|
52
51
|
control={control}
|
|
52
|
+
trigger={trigger}
|
|
53
53
|
register={register}
|
|
54
|
+
clearErrors={clearErrors}
|
|
54
55
|
error={error}
|
|
56
|
+
getValues={getValues}
|
|
57
|
+
setValue={setValue}
|
|
55
58
|
formState={formState}
|
|
56
|
-
{
|
|
59
|
+
Field={Field}
|
|
60
|
+
reset={reset}
|
|
61
|
+
resetField={resetField}
|
|
62
|
+
registerFieldFocus={registerFieldFocus}
|
|
63
|
+
{...resolvedField}
|
|
57
64
|
/>
|
|
58
65
|
);
|
|
59
66
|
}
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
calculatedField.multiplicity === true
|
|
63
|
-
) {
|
|
64
|
-
calculatedField.name = name;
|
|
67
|
+
if (resolvedField.type === 'array' && resolvedField.multiplicity === true) {
|
|
68
|
+
resolvedField.name = name;
|
|
65
69
|
return (
|
|
66
70
|
<Multiplicity
|
|
67
71
|
control={control}
|
|
@@ -73,18 +77,28 @@ export const Field: React.FC<FieldProps> = ({
|
|
|
73
77
|
setValue={setValue}
|
|
74
78
|
getValues={getValues}
|
|
75
79
|
unregister={unregister}
|
|
76
|
-
{
|
|
80
|
+
resetField={resetField}
|
|
81
|
+
Field={Field}
|
|
82
|
+
{...resolvedField}
|
|
77
83
|
/>
|
|
78
84
|
);
|
|
79
85
|
}
|
|
86
|
+
const editable =
|
|
87
|
+
customField.editable === false || customField.disabled === true
|
|
88
|
+
? false
|
|
89
|
+
: true;
|
|
90
|
+
const customError = error ? error : formState?.errors[name];
|
|
80
91
|
return (
|
|
81
92
|
<FieldBase
|
|
82
|
-
{...
|
|
93
|
+
{...resolvedField}
|
|
94
|
+
editable={editable}
|
|
83
95
|
name={name}
|
|
84
96
|
control={control}
|
|
85
97
|
register={register}
|
|
86
98
|
reset={reset}
|
|
87
|
-
error={
|
|
99
|
+
error={customError}
|
|
100
|
+
resetField={resetField}
|
|
101
|
+
Field={Field}
|
|
88
102
|
/>
|
|
89
103
|
);
|
|
90
104
|
};
|
package/src/Field/types.tsx
CHANGED
|
@@ -1,13 +1,84 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ErrorOption, UseFormReturn } from 'react-hook-form';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { ErrorOption, UseFormReturn, UseFormProps } from 'react-hook-form';
|
|
3
|
+
import type { FieldComponentRegistry } from '@digigov/form/inputs/registry';
|
|
4
|
+
import type { registerFieldFocus } from '@digigov/form/types';
|
|
5
|
+
import type { ValidatorSchema } from '@digigov/form/validators/types';
|
|
6
|
+
import type { FieldsetLegendProps } from '@digigov/ui/form/FieldContainer';
|
|
7
|
+
import type { GridProps } from '@digigov/ui/layouts/Grid';
|
|
5
8
|
|
|
9
|
+
export interface FieldLabelProps {
|
|
10
|
+
primary?: string;
|
|
11
|
+
secondary?: string;
|
|
12
|
+
hint?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface FieldSpec {
|
|
16
|
+
key: string; // !TODO rename key to name;
|
|
17
|
+
type?:
|
|
18
|
+
| 'int'
|
|
19
|
+
| 'string'
|
|
20
|
+
| 'text'
|
|
21
|
+
| 'boolean'
|
|
22
|
+
| 'email'
|
|
23
|
+
| 'uuid4'
|
|
24
|
+
| 'choice:multiple'
|
|
25
|
+
| 'choice:single'
|
|
26
|
+
| 'mobile_phone'
|
|
27
|
+
| 'date'
|
|
28
|
+
| 'datetime'
|
|
29
|
+
| 'otp'
|
|
30
|
+
| 'afm'
|
|
31
|
+
| 'amka'
|
|
32
|
+
| 'iban'
|
|
33
|
+
| 'file'
|
|
34
|
+
| 'rate'
|
|
35
|
+
| 'image'
|
|
36
|
+
| 'postal_code'
|
|
37
|
+
| 'phone_number'
|
|
38
|
+
| 'array'
|
|
39
|
+
| 'object';
|
|
40
|
+
trim?: boolean;
|
|
41
|
+
component?: any;
|
|
42
|
+
autoComplete?: string;
|
|
43
|
+
placeholder?: string;
|
|
44
|
+
maxLength?: number;
|
|
45
|
+
condition?: Record<string, FieldCondition>;
|
|
46
|
+
controlled?: boolean;
|
|
47
|
+
label?: FieldLabelProps;
|
|
48
|
+
extra?: Record<string, any>;
|
|
49
|
+
editable?: boolean;
|
|
50
|
+
variant?: 'inline' | 'dialog';
|
|
51
|
+
required?: boolean;
|
|
52
|
+
enabled?: boolean;
|
|
53
|
+
disabled?: boolean; // TODO: keep disabled or editable
|
|
54
|
+
layout?: Record<
|
|
55
|
+
string,
|
|
56
|
+
| GridProps['xs']
|
|
57
|
+
| GridProps['sm']
|
|
58
|
+
| GridProps['md']
|
|
59
|
+
| GridProps['lg']
|
|
60
|
+
| GridProps['xl']
|
|
61
|
+
>;
|
|
62
|
+
validators?: ValidatorSchema[];
|
|
63
|
+
wrapper?: 'label' | 'fieldset';
|
|
64
|
+
maxWidth?: string;
|
|
65
|
+
maxHeight?: string;
|
|
66
|
+
width?: string;
|
|
67
|
+
min?: number;
|
|
68
|
+
max?: number;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface FieldCondition {
|
|
72
|
+
is: string | string[] | number | number[] | boolean | boolean[];
|
|
73
|
+
then?: Partial<FieldSpec>;
|
|
74
|
+
else?: Partial<FieldSpec>;
|
|
75
|
+
}
|
|
6
76
|
export interface ChildFieldMemoProps extends FieldConditionalProps {
|
|
7
77
|
dependencies: FormData;
|
|
8
78
|
}
|
|
79
|
+
export type FormData = UseFormProps['defaultValues'];
|
|
9
80
|
|
|
10
|
-
export interface FieldWithCondition extends Omit<
|
|
81
|
+
export interface FieldWithCondition extends Omit<ResolvedField, 'condition'> {
|
|
11
82
|
condition: Record<string, FieldCondition>;
|
|
12
83
|
}
|
|
13
84
|
|
|
@@ -16,29 +87,31 @@ export interface FieldConditionalProps {
|
|
|
16
87
|
control: UseFormReturn['control'];
|
|
17
88
|
register: UseFormReturn['register'];
|
|
18
89
|
reset: UseFormReturn['reset'];
|
|
90
|
+
resetField?: UseFormReturn['resetField'];
|
|
19
91
|
error?: ErrorOption;
|
|
92
|
+
Field: React.FC<FieldProps>;
|
|
20
93
|
}
|
|
21
94
|
|
|
22
|
-
export
|
|
95
|
+
export interface FieldComponentItem {
|
|
23
96
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
97
|
component: any;
|
|
25
98
|
controlled?: boolean;
|
|
26
99
|
wrapper?: FieldSpec['wrapper'];
|
|
27
|
-
}
|
|
100
|
+
}
|
|
28
101
|
|
|
29
102
|
export interface FieldContainerProps {
|
|
30
103
|
name?: FieldSpec['key'];
|
|
104
|
+
register: FieldBaseProps['register'];
|
|
31
105
|
layout?: FieldSpec['layout'];
|
|
32
106
|
label?: FieldSpec['label'];
|
|
33
107
|
error?: ErrorOption | Record<string, any>;
|
|
108
|
+
hasError?: boolean;
|
|
34
109
|
children?: React.ReactNode;
|
|
110
|
+
controlled?: boolean;
|
|
35
111
|
wrapper?: FieldSpec['wrapper'];
|
|
112
|
+
labelSize?: FieldsetLegendProps['size'];
|
|
36
113
|
}
|
|
37
114
|
|
|
38
|
-
export type FieldComponentRegistry = Record<string, FieldComponentItem>;
|
|
39
|
-
|
|
40
|
-
export type OmittedFieldSpec = Omit<FieldSpec, 'component'>;
|
|
41
|
-
|
|
42
115
|
export type UnknownValue = never | never[];
|
|
43
116
|
|
|
44
117
|
export interface ControlledFieldProps {
|
|
@@ -51,6 +124,7 @@ export interface ControlledFieldProps {
|
|
|
51
124
|
error?: boolean;
|
|
52
125
|
name?: string;
|
|
53
126
|
disabled?: boolean;
|
|
127
|
+
Field?: React.FC<FieldProps>;
|
|
54
128
|
}
|
|
55
129
|
|
|
56
130
|
export interface UncontrolledFieldProps {
|
|
@@ -61,9 +135,10 @@ export interface UncontrolledFieldProps {
|
|
|
61
135
|
extra?: Record<string, never>;
|
|
62
136
|
type?: string;
|
|
63
137
|
disabled?: boolean;
|
|
138
|
+
Field: React.FC<FieldProps>;
|
|
64
139
|
}
|
|
65
140
|
|
|
66
|
-
export interface
|
|
141
|
+
export interface ResolvedField extends Omit<FieldSpec, 'component'> {
|
|
67
142
|
name: string;
|
|
68
143
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
144
|
component: any;
|
|
@@ -73,10 +148,12 @@ export interface CalculatedField extends OmittedFieldSpec {
|
|
|
73
148
|
multiplicity?: boolean;
|
|
74
149
|
}
|
|
75
150
|
|
|
76
|
-
export interface FieldBaseProps extends
|
|
151
|
+
export interface FieldBaseProps extends ResolvedField {
|
|
77
152
|
control: UseFormReturn['control'];
|
|
78
153
|
register: UseFormReturn['register'];
|
|
79
154
|
reset: UseFormReturn['reset'];
|
|
155
|
+
resetField?: UseFormReturn['resetField'];
|
|
156
|
+
Field?: React.FC<FieldProps>;
|
|
80
157
|
}
|
|
81
158
|
|
|
82
159
|
export interface FieldProps extends FieldSpec {
|
|
@@ -89,6 +166,7 @@ export interface UseFieldProps {
|
|
|
89
166
|
control: FieldBaseProps['control'];
|
|
90
167
|
register: FieldBaseProps['register'];
|
|
91
168
|
reset: FieldBaseProps['reset'];
|
|
169
|
+
resetField: FieldBaseProps['resetField'];
|
|
92
170
|
watch: UseFormReturn['watch'];
|
|
93
171
|
formState: UseFormReturn['formState'];
|
|
94
172
|
getFieldState: UseFormReturn['getFieldState'];
|
|
@@ -98,5 +176,6 @@ export interface UseFieldProps {
|
|
|
98
176
|
trigger: UseFormReturn['trigger'];
|
|
99
177
|
clearErrors: UseFormReturn['clearErrors'];
|
|
100
178
|
error?: ErrorOption;
|
|
179
|
+
registerFieldFocus: registerFieldFocus;
|
|
101
180
|
componentRegistry?: FieldComponentRegistry;
|
|
102
181
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FieldWithCondition,
|
|
3
|
+
ResolvedField,
|
|
4
|
+
} from '@digigov/form/Field/types';
|
|
5
|
+
|
|
6
|
+
export function evaluateFieldWithConditions(
|
|
7
|
+
field: FieldWithCondition,
|
|
8
|
+
variables: FormData
|
|
9
|
+
): ResolvedField {
|
|
10
|
+
const newField = { ...field };
|
|
11
|
+
if (variables) {
|
|
12
|
+
for (const key in variables) {
|
|
13
|
+
if (field.condition[key] && field.condition[key].is) {
|
|
14
|
+
const is = field.condition[key].is;
|
|
15
|
+
if (
|
|
16
|
+
is === variables[key] ||
|
|
17
|
+
(Array.isArray(variables[key]) && variables[key].includes(is))
|
|
18
|
+
) {
|
|
19
|
+
const then = field.condition[key].then || {};
|
|
20
|
+
for (const attr in then) {
|
|
21
|
+
newField[attr] = then[attr];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
} else if (field.condition[key]) {
|
|
25
|
+
const otherwise = field.condition[key].else || {};
|
|
26
|
+
for (const attr in otherwise) {
|
|
27
|
+
newField[attr] = otherwise[attr];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return newField;
|
|
33
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FieldProps,
|
|
3
|
+
FieldSpec,
|
|
4
|
+
ResolvedField,
|
|
5
|
+
} from '@digigov/form/Field/types';
|
|
6
|
+
import {
|
|
7
|
+
ALTERNATIVE_COMPONENTS,
|
|
8
|
+
FIELD_COMPONENTS,
|
|
9
|
+
type FieldComponentRegistry,
|
|
10
|
+
} from '@digigov/form/inputs/registry';
|
|
11
|
+
|
|
12
|
+
export function resolveField(
|
|
13
|
+
children: FieldProps['children'],
|
|
14
|
+
field: FieldSpec,
|
|
15
|
+
customComponentRegistry?: FieldComponentRegistry
|
|
16
|
+
): ResolvedField {
|
|
17
|
+
const fieldComponentRegistry = {
|
|
18
|
+
...FIELD_COMPONENTS,
|
|
19
|
+
...(customComponentRegistry ?? {}),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const resolvedField = { ...field };
|
|
23
|
+
|
|
24
|
+
if (children) {
|
|
25
|
+
resolvedField.component = children;
|
|
26
|
+
resolvedField.controlled = true;
|
|
27
|
+
} else if (typeof field.component === 'function') {
|
|
28
|
+
// leave as is
|
|
29
|
+
} else if (!field.component && !field.type) {
|
|
30
|
+
resolvedField.component = fieldComponentRegistry.string.component;
|
|
31
|
+
resolvedField.controlled =
|
|
32
|
+
fieldComponentRegistry.string?.controlled || false;
|
|
33
|
+
} else if (
|
|
34
|
+
typeof field?.extra?.component === 'string' &&
|
|
35
|
+
ALTERNATIVE_COMPONENTS[field.extra.component]
|
|
36
|
+
) {
|
|
37
|
+
resolvedField.controlled =
|
|
38
|
+
ALTERNATIVE_COMPONENTS[field.extra.component]?.controlled || false;
|
|
39
|
+
resolvedField.component =
|
|
40
|
+
ALTERNATIVE_COMPONENTS[field.extra.component].component;
|
|
41
|
+
resolvedField.wrapper =
|
|
42
|
+
ALTERNATIVE_COMPONENTS[field.extra.component].wrapper;
|
|
43
|
+
} else if (
|
|
44
|
+
!field.component &&
|
|
45
|
+
field.type &&
|
|
46
|
+
fieldComponentRegistry[field.type]
|
|
47
|
+
) {
|
|
48
|
+
resolvedField.component = fieldComponentRegistry[field.type].component;
|
|
49
|
+
resolvedField.wrapper = fieldComponentRegistry[field.type].wrapper;
|
|
50
|
+
resolvedField.controlled =
|
|
51
|
+
fieldComponentRegistry[field.type]?.controlled || false;
|
|
52
|
+
} else {
|
|
53
|
+
resolvedField.component = fieldComponentRegistry.string.component;
|
|
54
|
+
resolvedField.controlled =
|
|
55
|
+
fieldComponentRegistry.string?.controlled || false;
|
|
56
|
+
}
|
|
57
|
+
return resolvedField as ResolvedField;
|
|
58
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { useContext, useMemo } from 'react';
|
|
2
|
+
import type { FieldSpec, UseFieldProps } from '@digigov/form/Field/types';
|
|
3
|
+
import { FormContext } from '@digigov/form/FormContext';
|
|
4
|
+
|
|
5
|
+
export const useField = (
|
|
6
|
+
name: string,
|
|
7
|
+
customField: FieldSpec | null
|
|
8
|
+
): UseFieldProps => {
|
|
9
|
+
const {
|
|
10
|
+
fieldsMap,
|
|
11
|
+
control,
|
|
12
|
+
register,
|
|
13
|
+
reset,
|
|
14
|
+
resetField,
|
|
15
|
+
trigger,
|
|
16
|
+
clearErrors,
|
|
17
|
+
errors,
|
|
18
|
+
registerField,
|
|
19
|
+
watch,
|
|
20
|
+
componentRegistry,
|
|
21
|
+
getFieldState,
|
|
22
|
+
setValue,
|
|
23
|
+
getValues,
|
|
24
|
+
unregister,
|
|
25
|
+
formState,
|
|
26
|
+
registerFieldFocus,
|
|
27
|
+
} = useContext(FormContext);
|
|
28
|
+
if (!registerField) {
|
|
29
|
+
throw new Error(`
|
|
30
|
+
You can't use the Field component without wrapping it in FormBuilder.
|
|
31
|
+
https://devs.pages.grnet.gr/digigov/digigov-sdk/sdk-docs/forms/create-simple-form/
|
|
32
|
+
`);
|
|
33
|
+
}
|
|
34
|
+
let error = errors[name];
|
|
35
|
+
|
|
36
|
+
const nameIndexRegex = name.match(/^\[*(.*?)\.(\d+)\]*$/);
|
|
37
|
+
if (nameIndexRegex) {
|
|
38
|
+
const [, fieldArrayName, indexStr] = nameIndexRegex;
|
|
39
|
+
error = errors[fieldArrayName]?.[Number(indexStr)];
|
|
40
|
+
}
|
|
41
|
+
const nestedNameIndexRegex = name.match(/^\[*(.*?)\.(\d+)\.(.*?)\]*$/);
|
|
42
|
+
if (nestedNameIndexRegex) {
|
|
43
|
+
const [, fieldArrayName, indexStr, fieldItemName] = nestedNameIndexRegex;
|
|
44
|
+
error = errors[fieldArrayName]?.[Number(indexStr)]?.[fieldItemName];
|
|
45
|
+
}
|
|
46
|
+
useMemo(
|
|
47
|
+
() => customField?.type && registerField({ ...customField, key: name }),
|
|
48
|
+
[customField, name, registerField]
|
|
49
|
+
);
|
|
50
|
+
return {
|
|
51
|
+
field: customField || fieldsMap[name],
|
|
52
|
+
control,
|
|
53
|
+
register,
|
|
54
|
+
reset,
|
|
55
|
+
resetField,
|
|
56
|
+
trigger,
|
|
57
|
+
watch,
|
|
58
|
+
componentRegistry,
|
|
59
|
+
getFieldState,
|
|
60
|
+
setValue,
|
|
61
|
+
clearErrors,
|
|
62
|
+
getValues,
|
|
63
|
+
unregister,
|
|
64
|
+
formState,
|
|
65
|
+
error,
|
|
66
|
+
registerFieldFocus,
|
|
67
|
+
};
|
|
68
|
+
};
|