@digigov/form 2.0.0-d0adc9fb → 2.0.0-d2ffc726
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Field/ErrorGroup/index.js +48 -0
- package/{inputs/inputsScenarios → Field/ErrorGroup}/package.json +1 -1
- package/Field/ErrorGroup.d.ts +15 -0
- package/Field/ErrorGroup.js.map +7 -0
- package/Field/FieldBase/index.js +37 -26
- package/Field/FieldBase.d.ts +1 -1
- package/Field/FieldBase.js.map +2 -2
- package/Field/FieldBaseContainer/index.js +37 -17
- package/Field/FieldBaseContainer.d.ts +2 -2
- package/Field/FieldBaseContainer.js.map +2 -2
- package/Field/FieldConditional/index.js +4 -0
- package/Field/FieldConditional.d.ts +1 -1
- package/Field/FieldConditional.js.map +2 -2
- package/Field/index.d.ts +1 -1
- package/Field/index.js +24 -28
- package/Field/index.js.map +2 -2
- package/Field/types.d.ts +23 -12
- package/Field/utils/evaluateFieldWithConditions.d.ts +2 -2
- package/Field/utils/evaluateFieldWithConditions.js.map +2 -2
- package/Field/utils/resolveField/index.js +35 -0
- package/Field/utils/{calculateField → resolveField}/package.json +1 -1
- package/Field/utils/resolveField.d.ts +3 -0
- package/Field/utils/resolveField.js.map +7 -0
- package/Field/utils/useField/index.js +12 -3
- package/Field/utils/useField.d.ts +1 -1
- package/Field/utils/useField.js.map +2 -2
- package/FieldArray/BaseFieldArray/index.js +76 -0
- package/FieldArray/BaseFieldArray/package.json +6 -0
- package/FieldArray/BaseFieldArray.d.ts +5 -0
- package/FieldArray/BaseFieldArray.js.map +7 -0
- package/FieldArray/FieldArray.stories.d.ts +2 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay/index.js +23 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay/package.json +6 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.d.ts +9 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.js.map +7 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayDisplay.stories.d.ts +13 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay/index.js +184 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay/package.json +6 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.d.ts +26 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.js.map +7 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader/index.js +11 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader/package.json +6 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.d.ts +5 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.js.map +7 -0
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/Cards.d.ts +2 -0
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/Default.d.ts +2 -0
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnly.d.ts +2 -0
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnlyCards.d.ts +2 -0
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/Sortable.d.ts +2 -0
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/SortableCards.d.ts +2 -0
- package/FieldArray/FormDialog/ArrayDisplay/index.d.ts +15 -0
- package/FieldArray/FormDialog/ArrayDisplay/index.js +57 -0
- package/FieldArray/FormDialog/ArrayDisplay/index.js.map +7 -0
- package/{inputs/Input/inputsInputScenarios → FieldArray/FormDialog/ArrayDisplay}/package.json +1 -1
- package/FieldArray/FormDialog/ArrayEditModal/index.js +158 -0
- package/FieldArray/FormDialog/ArrayEditModal/package.json +6 -0
- package/FieldArray/FormDialog/ArrayEditModal.d.ts +26 -0
- package/FieldArray/FormDialog/ArrayEditModal.js.map +7 -0
- package/FieldArray/FormDialog/index.d.ts +19 -0
- package/FieldArray/FormDialog/index.js +213 -257
- package/FieldArray/FormDialog/index.js.map +7 -0
- package/FieldArray/__stories__/CardsWithError.d.ts +15 -0
- package/FieldArray/__stories__/Default.d.ts +1 -1
- package/FieldArray/__stories__/WithExactLength.d.ts +1 -1
- package/FieldArray/__stories__/WithModal.d.ts +2 -0
- package/FieldArray/index.d.ts +5 -2
- package/FieldArray/index.js +41 -57
- package/FieldArray/index.js.map +2 -2
- package/FieldObject/index.d.ts +7 -4
- package/FieldObject/index.js +30 -27
- package/FieldObject/index.js.map +2 -2
- package/Fieldset/FieldsetWithContext.js.map +1 -1
- package/Fieldset/index.d.ts +1 -1
- package/Fieldset/index.js.map +1 -1
- package/Fieldset/types.d.ts +2 -2
- package/FormBuilder/FormBuilder.stories.d.ts +4 -0
- package/FormBuilder/__stories__/AutoErrorGrouping.d.ts +3 -0
- package/FormBuilder/__stories__/Default.d.ts +1 -1
- package/FormBuilder/__stories__/ErrorGrouping.d.ts +3 -0
- package/FormBuilder/index.d.ts +2 -2
- package/FormBuilder/index.js +186 -80
- package/FormBuilder/index.js.map +2 -2
- package/FormContext/index.js +6 -2
- package/FormContext.d.ts +3 -2
- package/FormContext.js.map +2 -2
- package/MultiplicityField/MultiplicityField.stories.d.ts +2 -0
- package/MultiplicityField/__stories__/Default.d.ts +1 -1
- package/MultiplicityField/__stories__/PreviewDisplay.d.ts +1 -1
- package/MultiplicityField/__stories__/WithExactLength.d.ts +1 -1
- package/MultiplicityField/__stories__/WithMaxLength.d.ts +1 -1
- package/MultiplicityField/__stories__/WithMinAndMaxLength.d.ts +1 -1
- package/MultiplicityField/__stories__/WithMinLength.d.ts +1 -1
- package/MultiplicityField/add-objects/index.js +12 -19
- package/MultiplicityField/add-objects.d.ts +1 -1
- package/MultiplicityField/add-objects.js.map +2 -2
- package/MultiplicityField/index.d.ts +2 -2
- package/MultiplicityField/index.js +6 -2
- package/MultiplicityField/index.js.map +2 -2
- package/MultiplicityField/types.d.ts +3 -2
- package/Questions/Questions.d.ts +1 -1
- package/Questions/Questions.js.map +1 -1
- package/Questions/Questions.stories.d.ts +2 -0
- package/Questions/QuestionsContext.d.ts +1 -1
- package/Questions/QuestionsContext.js.map +1 -1
- package/Questions/Step/Step.d.ts +1 -1
- package/Questions/Step/Step.js.map +1 -1
- package/Questions/Step/StepArrayReview.d.ts +1 -1
- package/Questions/Step/StepArrayReview.js.map +1 -1
- package/Questions/Step/StepContext.d.ts +1 -1
- package/Questions/Step/StepContext.js.map +1 -1
- package/Questions/Step/StepDescription.d.ts +1 -1
- package/Questions/Step/StepDescription.js.map +2 -2
- package/Questions/Step/StepForm.d.ts +2 -2
- package/Questions/Step/StepForm.js.map +1 -1
- package/Questions/Step/StepQuote.d.ts +1 -1
- package/Questions/Step/StepQuote.js.map +2 -2
- package/Questions/Step/StepTitle.d.ts +1 -1
- package/Questions/Step/StepTitle.js.map +2 -2
- package/Questions/Step/getAddMoreFields.d.ts +2 -2
- package/Questions/Step/getAddMoreFields.js.map +1 -1
- package/Questions/Step/types.d.ts +1 -1
- package/Questions/__stories__/Default.d.ts +1 -1
- package/Questions/getNextStep.d.ts +1 -1
- package/Questions/getNextStep.js.map +1 -1
- package/Questions/types.d.ts +1 -1
- package/cjs/Field/ErrorGroup/index.js +82 -0
- package/cjs/Field/ErrorGroup.js.map +7 -0
- package/cjs/Field/FieldBase/index.js +36 -25
- package/cjs/Field/FieldBase.js.map +2 -2
- package/cjs/Field/FieldBaseContainer/index.js +36 -16
- package/cjs/Field/FieldBaseContainer.js.map +3 -3
- package/cjs/Field/FieldConditional/index.js +4 -0
- package/cjs/Field/FieldConditional.js.map +2 -2
- package/cjs/Field/index.js +24 -25
- package/cjs/Field/index.js.map +2 -2
- package/cjs/Field/types.js.map +1 -1
- package/cjs/Field/utils/evaluateFieldWithConditions.js.map +2 -2
- package/cjs/Field/utils/resolveField/index.js +55 -0
- package/cjs/Field/utils/resolveField.js.map +7 -0
- package/cjs/Field/utils/useField/index.js +12 -3
- package/cjs/Field/utils/useField.js.map +2 -2
- package/cjs/FieldArray/BaseFieldArray/index.js +109 -0
- package/cjs/FieldArray/BaseFieldArray.js.map +7 -0
- package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay/index.js +56 -0
- package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.js.map +7 -0
- package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay/index.js +209 -0
- package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.js.map +7 -0
- package/cjs/{locales/el → FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader}/index.js +16 -7
- package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.js.map +7 -0
- package/cjs/FieldArray/FormDialog/ArrayDisplay/index.js +90 -0
- package/cjs/FieldArray/FormDialog/ArrayDisplay/index.js.map +7 -0
- package/cjs/FieldArray/FormDialog/ArrayEditModal/index.js +186 -0
- package/cjs/FieldArray/FormDialog/ArrayEditModal.js.map +7 -0
- package/cjs/FieldArray/FormDialog/index.js +204 -243
- package/cjs/FieldArray/FormDialog/index.js.map +7 -0
- package/cjs/FieldArray/index.js +40 -56
- package/cjs/FieldArray/index.js.map +3 -3
- package/cjs/FieldObject/index.js +30 -24
- package/cjs/FieldObject/index.js.map +2 -2
- package/cjs/Fieldset/FieldsetWithContext.js.map +1 -1
- package/cjs/Fieldset/index.js.map +1 -1
- package/cjs/Fieldset/types.js.map +1 -1
- package/cjs/FormBuilder/index.js +188 -82
- package/cjs/FormBuilder/index.js.map +3 -3
- package/cjs/FormContext/index.js +7 -2
- package/cjs/FormContext.js.map +2 -2
- package/cjs/MultiplicityField/add-objects/index.js +11 -13
- package/cjs/MultiplicityField/add-objects.js.map +2 -2
- package/cjs/MultiplicityField/index.js +6 -2
- package/cjs/MultiplicityField/index.js.map +2 -2
- package/cjs/MultiplicityField/types.js.map +1 -1
- package/cjs/Questions/Questions.js.map +1 -1
- package/cjs/Questions/QuestionsContext.js.map +1 -1
- package/cjs/Questions/Step/Step.js.map +1 -1
- package/cjs/Questions/Step/StepArrayReview.js.map +1 -1
- package/cjs/Questions/Step/StepContext.js.map +1 -1
- package/cjs/Questions/Step/StepDescription.js.map +2 -2
- package/cjs/Questions/Step/StepForm.js.map +1 -1
- package/cjs/Questions/Step/StepQuote.js.map +2 -2
- package/cjs/Questions/Step/StepTitle.js.map +2 -2
- package/cjs/Questions/Step/getAddMoreFields.js.map +1 -1
- package/cjs/Questions/Step/types.js.map +1 -1
- package/cjs/Questions/getNextStep.js.map +1 -1
- package/cjs/Questions/types.js.map +1 -1
- package/cjs/hooks/useFieldFocusManager/index.js +135 -0
- package/cjs/hooks/useFieldFocusManager.js.map +7 -0
- package/cjs/hooks/utils/index.js +98 -0
- package/cjs/hooks/utils.js.map +7 -0
- package/cjs/inputs/AutoCompleteInput/index.js.map +2 -2
- package/cjs/inputs/Checkboxes/index.js +67 -62
- package/cjs/inputs/Checkboxes/index.js.map +2 -2
- package/cjs/inputs/DateInput/index.js +54 -19
- package/cjs/inputs/DateInput/index.js.map +2 -2
- package/cjs/inputs/DateTimeInput/index.js +83 -39
- package/cjs/inputs/DateTimeInput/index.js.map +2 -2
- package/cjs/inputs/FileInput/index.js +68 -30
- package/cjs/inputs/FileInput/index.js.map +2 -2
- package/cjs/inputs/ImageInput/__stories__/logo.d/index.js +1 -0
- package/cjs/inputs/ImageInput/__stories__/logo.d.js.map +7 -0
- package/cjs/inputs/ImageInput/index.js +42 -10
- package/cjs/inputs/ImageInput/index.js.map +2 -2
- package/cjs/inputs/Input/index.js +55 -55
- package/cjs/inputs/Input/index.js.map +2 -2
- package/cjs/inputs/Label/index.js.map +1 -1
- package/cjs/inputs/OtpInput/index.js +36 -30
- package/cjs/inputs/OtpInput/index.js.map +2 -2
- package/cjs/inputs/Radio/index.js +5 -4
- package/cjs/inputs/Radio/index.js.map +3 -3
- package/cjs/inputs/Select/index.js +5 -3
- package/cjs/inputs/Select/index.js.map +2 -2
- package/cjs/{Field/utils → inputs/registry}/index.js +7 -5
- package/cjs/inputs/registry.js.map +7 -0
- package/cjs/lazy/index.js +16 -10
- package/cjs/lazy.js.map +2 -2
- package/cjs/registry/index.js +31 -15
- package/cjs/registry.js.map +2 -2
- package/cjs/types.js.map +1 -1
- package/cjs/utils/index.js +20 -6
- package/cjs/utils.js.map +2 -2
- package/cjs/validators/index.js +33 -19
- package/cjs/validators/index.js.map +2 -2
- package/cjs/validators/types.js.map +1 -1
- package/cjs/validators/utils/amka/index.js +60 -0
- package/cjs/validators/utils/amka.js.map +7 -0
- package/cjs/validators/utils/date/index.js +26 -3
- package/cjs/validators/utils/date.js.map +2 -2
- package/cjs/validators/utils/datetime/index.js +118 -24
- package/cjs/validators/utils/datetime.js.map +2 -2
- package/cjs/validators/utils/email/index.js +39 -0
- package/cjs/validators/utils/email.js.map +7 -0
- package/cjs/validators/utils/file/index.js +30 -17
- package/cjs/validators/utils/file.js.map +2 -2
- package/cjs/validators/utils/iban.js.map +1 -1
- package/cjs/validators/utils/image.js.map +1 -1
- package/cjs/validators/utils/index.js +5 -1
- package/cjs/validators/utils/index.js.map +2 -2
- package/cjs/validators/utils/int/index.js +1 -1
- package/cjs/validators/utils/int.js.map +2 -2
- package/cjs/validators/utils/number/index.js +1 -1
- package/cjs/validators/utils/number.js.map +2 -2
- package/cjs/validators/utils/otp.js.map +1 -1
- package/cjs/validators/utils/phone.js.map +1 -1
- package/cjs/validators/utils/postal_code.js.map +1 -1
- package/cjs/validators/utils/text_limit.js.map +1 -1
- package/hooks/useFieldFocusManager/index.js +116 -0
- package/hooks/useFieldFocusManager/package.json +6 -0
- package/hooks/useFieldFocusManager.d.ts +25 -0
- package/hooks/useFieldFocusManager.js.map +7 -0
- package/hooks/utils/index.js +73 -0
- package/{Field → hooks}/utils/package.json +1 -1
- package/hooks/utils.d.ts +18 -0
- package/hooks/utils.js.map +7 -0
- package/index.js +1 -1
- package/inputs/AutoCompleteInput/AutoComplete.stories.d.ts +2 -0
- package/inputs/AutoCompleteInput/__stories__/Default.d.ts +1 -1
- package/inputs/AutoCompleteInput/__stories__/Multiple.d.ts +1 -1
- package/inputs/AutoCompleteInput/index.d.ts +3 -3
- package/inputs/AutoCompleteInput/index.js +1 -3
- package/inputs/AutoCompleteInput/index.js.map +2 -2
- package/inputs/Checkboxes/Checkboxes.stories.d.ts +2 -0
- package/inputs/Checkboxes/__stories__/Conditional.d.ts +1 -1
- package/inputs/Checkboxes/__stories__/Default.d.ts +1 -1
- package/inputs/Checkboxes/__stories__/WithDivider.d.ts +1 -1
- package/inputs/Checkboxes/index.d.ts +3 -3
- package/inputs/Checkboxes/index.js +67 -62
- package/inputs/Checkboxes/index.js.map +2 -2
- package/inputs/DateInput/DateInput.stories.d.ts +6 -0
- package/inputs/DateInput/__stories__/Default.d.ts +1 -1
- package/inputs/DateInput/__stories__/WithDefaultValue.d.ts +3 -0
- package/inputs/DateInput/__stories__/WithInitialValue.d.ts +3 -0
- package/inputs/DateInput/__stories__/WithWrongDefaultValue.d.ts +3 -0
- package/inputs/DateInput/__stories__/WithWrongInitialValue.d.ts +3 -0
- package/inputs/DateInput/index.d.ts +2 -5
- package/inputs/DateInput/index.js +55 -20
- package/inputs/DateInput/index.js.map +2 -2
- package/inputs/DateTimeInput/DateTimeInput.stories.d.ts +10 -3
- package/inputs/DateTimeInput/__stories__/Default.d.ts +1 -1
- package/inputs/DateTimeInput/__stories__/WithDefaultValue.d.ts +3 -0
- package/inputs/DateTimeInput/__stories__/WithInitialValue.d.ts +3 -0
- package/inputs/DateTimeInput/__stories__/WithWrongDefaultValue.d.ts +3 -0
- package/inputs/DateTimeInput/__stories__/WithWrongInitialValue.d.ts +3 -0
- package/inputs/DateTimeInput/index.d.ts +2 -5
- package/inputs/DateTimeInput/index.js +84 -40
- package/inputs/DateTimeInput/index.js.map +2 -2
- package/inputs/FileInput/FileInput.stories.d.ts +3 -0
- package/inputs/FileInput/__stories__/Default.d.ts +1 -1
- package/inputs/FileInput/__stories__/WithBorderAndLink.d.ts +3 -0
- package/inputs/FileInput/index.d.ts +18 -2
- package/inputs/FileInput/index.js +69 -31
- package/inputs/FileInput/index.js.map +2 -2
- package/inputs/ImageInput/ImageInput.stories.d.ts +4 -1
- package/inputs/ImageInput/__stories__/Default.d.ts +1 -1
- package/inputs/ImageInput/__stories__/MaxSize.d.ts +1 -1
- package/inputs/ImageInput/__stories__/WithInitialValues.d.ts +3 -0
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension.d.ts +1 -1
- package/inputs/ImageInput/__stories__/logo.d/index.js +1 -0
- package/inputs/ImageInput/__stories__/logo.d/package.json +6 -0
- package/inputs/ImageInput/__stories__/logo.d.js.map +7 -0
- package/inputs/ImageInput/index.d.ts +10 -2
- package/inputs/ImageInput/index.js +43 -11
- package/inputs/ImageInput/index.js.map +2 -2
- package/inputs/Input/Input.stories.d.ts +5 -0
- package/inputs/Input/__stories__/AFM.d.ts +1 -1
- package/inputs/Input/__stories__/AMKA.d.ts +3 -0
- package/inputs/Input/__stories__/Boolean.d.ts +1 -1
- package/inputs/Input/__stories__/Email.d.ts +3 -0
- package/inputs/Input/__stories__/IBAN.d.ts +1 -1
- package/inputs/Input/__stories__/Integer.d.ts +1 -1
- package/inputs/Input/__stories__/LandlineNumber.d.ts +1 -1
- package/inputs/Input/__stories__/MobilePhone.d.ts +1 -1
- package/inputs/Input/__stories__/PhoneNumber.d.ts +1 -1
- package/inputs/Input/__stories__/PostalCode.d.ts +1 -1
- package/inputs/Input/__stories__/String.d.ts +1 -1
- package/inputs/Input/__stories__/StringWithTrimValidation.d.ts +3 -0
- package/inputs/Input/__stories__/TextWithLimit.d.ts +1 -1
- package/inputs/Input/index.d.ts +4 -3
- package/inputs/Input/index.js +55 -55
- package/inputs/Input/index.js.map +2 -2
- package/inputs/Label/Label.stories.d.ts +2 -0
- package/inputs/Label/__stories__/Default.d.ts +1 -1
- package/inputs/Label/index.d.ts +1 -1
- package/inputs/Label/index.js.map +1 -1
- package/inputs/OtpInput/OtpInput.stories.d.ts +2 -0
- package/inputs/OtpInput/__stories__/Default.d.ts +1 -1
- package/inputs/OtpInput/index.d.ts +1 -5
- package/inputs/OtpInput/index.js +36 -30
- package/inputs/OtpInput/index.js.map +2 -2
- package/inputs/Radio/Radio.stories.d.ts +2 -0
- package/inputs/Radio/__stories__/Conditional.d.ts +1 -1
- package/inputs/Radio/__stories__/Default.d.ts +1 -1
- package/inputs/Radio/__stories__/WithDivider.d.ts +1 -1
- package/inputs/Radio/index.d.ts +4 -4
- package/inputs/Radio/index.js +5 -4
- package/inputs/Radio/index.js.map +3 -3
- package/inputs/Select/Select.stories.d.ts +2 -0
- package/inputs/Select/__stories__/Default.d.ts +1 -1
- package/inputs/Select/index.d.ts +4 -3
- package/inputs/Select/index.js +5 -3
- package/inputs/Select/index.js.map +2 -2
- package/{Field/utils → inputs/registry}/index.js +4 -2
- package/{locales/el → inputs/registry}/package.json +1 -1
- package/{Field/utils/index.d.ts → inputs/registry.d.ts} +2 -1
- package/inputs/registry.js.map +7 -0
- package/lazy/index.js +16 -10
- package/package.json +8 -8
- package/registry/index.js +31 -15
- package/src/Field/ErrorGroup.tsx +84 -0
- package/src/Field/FieldBase.tsx +40 -26
- package/src/Field/FieldBaseContainer.tsx +69 -47
- package/src/Field/FieldConditional.tsx +5 -1
- package/src/Field/doc.mdx +202 -1
- package/src/Field/index.tsx +27 -37
- package/src/Field/types.tsx +24 -14
- package/src/Field/utils/evaluateFieldWithConditions.ts +5 -2
- package/src/Field/utils/resolveField.ts +58 -0
- package/src/Field/utils/useField.ts +12 -2
- package/src/FieldArray/BaseFieldArray.tsx +97 -0
- package/src/FieldArray/FieldArray.stories.js +2 -0
- 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 +335 -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 +243 -0
- package/src/FieldArray/FormDialog/index.tsx +304 -0
- package/src/FieldArray/__stories__/CardsWithError.tsx +124 -0
- package/src/FieldArray/__stories__/Default.tsx +1 -1
- package/src/FieldArray/__stories__/WithExactLength.tsx +15 -78
- package/src/FieldArray/__stories__/WithModal.tsx +160 -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 +12 -0
- package/src/FieldArray/index.tsx +49 -72
- package/src/FieldObject/index.tsx +40 -34
- package/src/Fieldset/FieldsetWithContext.tsx +1 -1
- package/src/Fieldset/index.tsx +1 -1
- package/src/Fieldset/types.tsx +2 -2
- package/src/FormBuilder/FormBuilder.stories.js +5 -0
- package/src/FormBuilder/__stories__/AutoErrorGrouping.tsx +63 -0
- package/src/FormBuilder/__stories__/Default.tsx +1 -1
- package/src/FormBuilder/__stories__/ErrorGrouping.tsx +43 -0
- package/src/FormBuilder/doc.mdx +9 -4
- package/src/FormBuilder/index.test.tsx +12 -0
- package/src/FormBuilder/index.tsx +223 -89
- package/src/FormBuilder/interaction.test.tsx +40 -0
- package/src/FormBuilder/scenarios.test.tsx +1002 -129
- package/src/FormContext.tsx +7 -2
- package/src/MultiplicityField/MultiplicityField.stories.js +3 -0
- package/src/MultiplicityField/__stories__/Default.tsx +1 -1
- package/src/MultiplicityField/__stories__/PreviewDisplay.tsx +1 -1
- package/src/MultiplicityField/__stories__/WithExactLength.tsx +1 -1
- package/src/MultiplicityField/__stories__/WithMaxLength.tsx +1 -1
- package/src/MultiplicityField/__stories__/WithMinAndMaxLength.tsx +1 -1
- package/src/MultiplicityField/__stories__/WithMinLength.tsx +1 -1
- package/src/MultiplicityField/add-objects.tsx +14 -21
- package/src/MultiplicityField/doc.mdx +101 -83
- package/src/MultiplicityField/index.test.tsx +4 -0
- package/src/MultiplicityField/index.tsx +8 -3
- package/src/MultiplicityField/types.ts +6 -2
- package/src/Questions/Questions.stories.js +3 -0
- package/src/Questions/Questions.tsx +2 -2
- package/src/Questions/QuestionsContext.tsx +1 -1
- package/src/Questions/Step/Step.tsx +1 -1
- package/src/Questions/Step/StepArrayReview.tsx +2 -2
- 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 +2 -1
- package/src/Questions/Step/getAddMoreFields.tsx +2 -2
- package/src/Questions/Step/types.tsx +1 -1
- package/src/Questions/__snapshots__/index.spec.tsx.snap +3 -1
- package/src/Questions/__stories__/Default.tsx +1 -1
- package/src/Questions/doc.mdx +21 -41
- package/src/Questions/getNextStep.tsx +1 -1
- package/src/Questions/index.spec.tsx +8 -0
- package/src/Questions/index.test.tsx +4 -0
- package/src/Questions/types.tsx +1 -1
- package/src/doc.mdx +26 -11
- 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/inputs/AutoCompleteInput/AutoComplete.stories.js +3 -0
- package/src/inputs/AutoCompleteInput/__stories__/Default.tsx +1 -1
- package/src/inputs/AutoCompleteInput/__stories__/Multiple.tsx +1 -1
- package/src/inputs/AutoCompleteInput/index.test.tsx +4 -0
- package/src/inputs/AutoCompleteInput/index.tsx +4 -6
- package/src/inputs/Checkboxes/Checkboxes.stories.js +3 -0
- package/src/inputs/Checkboxes/__stories__/Conditional.tsx +1 -1
- package/src/inputs/Checkboxes/__stories__/Default.tsx +1 -1
- package/src/inputs/Checkboxes/__stories__/WithDivider.tsx +1 -1
- package/src/inputs/Checkboxes/index.test.tsx +4 -0
- package/src/inputs/Checkboxes/index.tsx +95 -90
- package/src/inputs/DateInput/DateInput.stories.js +7 -0
- package/src/inputs/DateInput/__stories__/Default.tsx +1 -1
- 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.test.tsx +20 -0
- package/src/inputs/DateInput/index.tsx +68 -20
- package/src/inputs/DateTimeInput/DateTimeInput.stories.js +12 -6
- package/src/inputs/DateTimeInput/__stories__/Default.tsx +1 -1
- 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/index.test.tsx +27 -5
- package/src/inputs/DateTimeInput/index.tsx +97 -40
- package/src/inputs/FileInput/FileInput.stories.js +4 -0
- package/src/inputs/FileInput/__stories__/Default.tsx +1 -1
- package/src/inputs/FileInput/__stories__/WithBorderAndLink.tsx +34 -0
- package/src/inputs/FileInput/index.test.tsx +8 -0
- package/src/inputs/FileInput/index.tsx +106 -38
- package/src/inputs/ImageInput/ImageInput.stories.js +5 -1
- package/src/inputs/ImageInput/__stories__/Default.tsx +1 -1
- package/src/inputs/ImageInput/__stories__/MaxSize.tsx +3 -2
- package/src/inputs/ImageInput/__stories__/{WithInvalidImageSize.tsx → WithInitialValues.tsx} +12 -3
- package/src/inputs/ImageInput/__stories__/WithInvalidImageDimension.tsx +1 -1
- package/src/inputs/ImageInput/__stories__/logo.d.ts +4 -0
- package/src/inputs/ImageInput/__stories__/logo.png +0 -0
- package/src/inputs/ImageInput/index.test.tsx +8 -4
- package/src/inputs/ImageInput/index.tsx +101 -48
- package/src/inputs/Input/Input.stories.js +6 -0
- package/src/inputs/Input/__stories__/AFM.tsx +1 -1
- package/src/inputs/Input/__stories__/AMKA.tsx +23 -0
- package/src/inputs/Input/__stories__/Boolean.tsx +1 -1
- package/src/inputs/Input/__stories__/Email.tsx +23 -0
- package/src/inputs/Input/__stories__/IBAN.tsx +1 -1
- package/src/inputs/Input/__stories__/Integer.tsx +1 -1
- package/src/inputs/Input/__stories__/LandlineNumber.tsx +1 -1
- package/src/inputs/Input/__stories__/MobilePhone.tsx +1 -1
- package/src/inputs/Input/__stories__/PhoneNumber.tsx +1 -1
- package/src/inputs/Input/__stories__/PostalCode.tsx +1 -1
- package/src/inputs/Input/__stories__/String.tsx +1 -1
- package/src/inputs/Input/__stories__/StringWithTrimValidation.tsx +26 -0
- package/src/inputs/Input/__stories__/TextWithLimit.tsx +2 -1
- package/src/inputs/Input/index.test.tsx +16 -0
- package/src/inputs/Input/index.tsx +76 -71
- package/src/inputs/Label/Label.stories.js +3 -0
- package/src/inputs/Label/__stories__/Default.tsx +1 -1
- package/src/inputs/Label/index.test.tsx +4 -0
- package/src/inputs/Label/index.tsx +1 -1
- package/src/inputs/OtpInput/OtpInput.stories.js +3 -0
- package/src/inputs/OtpInput/__stories__/Default.tsx +1 -1
- package/src/inputs/OtpInput/index.test.tsx +4 -0
- package/src/inputs/OtpInput/index.tsx +43 -33
- package/src/inputs/Radio/Radio.stories.js +3 -0
- package/src/inputs/Radio/__stories__/Conditional.tsx +1 -1
- package/src/inputs/Radio/__stories__/Default.tsx +1 -1
- package/src/inputs/Radio/__stories__/WithDivider.tsx +1 -1
- package/src/inputs/Radio/index.test.tsx +4 -0
- package/src/inputs/Radio/index.tsx +29 -21
- package/src/inputs/Select/Select.stories.js +3 -0
- package/src/inputs/Select/__stories__/Default.tsx +1 -1
- package/src/inputs/Select/index.test.tsx +4 -0
- package/src/inputs/Select/index.tsx +10 -6
- package/src/{Field/utils/index.ts → inputs/registry.ts} +5 -1
- package/src/lazy.js +16 -10
- package/src/registry.js +31 -15
- package/src/types.tsx +14 -5
- package/src/utils.ts +30 -8
- package/src/validators/index.ts +68 -28
- package/src/validators/types.ts +1 -1
- package/src/validators/utils/amka.ts +39 -0
- package/src/validators/utils/date.ts +30 -6
- package/src/validators/utils/datetime.ts +123 -31
- package/src/validators/utils/email.ts +11 -0
- package/src/validators/utils/file.ts +35 -21
- package/src/validators/utils/iban.ts +2 -2
- package/src/validators/utils/image.ts +2 -2
- package/src/validators/utils/index.ts +6 -3
- 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 +2 -2
- package/src/validators/utils/postal_code.ts +2 -2
- package/src/validators/utils/text_limit.ts +2 -2
- package/types.d.ts +10 -4
- package/types.js.map +1 -1
- package/utils/index.js +20 -6
- package/utils.d.ts +3 -1
- package/utils.js.map +2 -2
- package/validators/index.d.ts +6 -6
- package/validators/index.js +34 -19
- package/validators/index.js.map +2 -2
- package/validators/types.d.ts +1 -1
- package/validators/utils/amka/index.js +36 -0
- package/validators/utils/amka/package.json +6 -0
- package/validators/utils/amka.d.ts +6 -0
- package/validators/utils/amka.js.map +7 -0
- package/validators/utils/date/index.js +26 -3
- package/validators/utils/date.d.ts +3 -3
- package/validators/utils/date.js.map +2 -2
- package/validators/utils/datetime/index.js +118 -24
- package/validators/utils/datetime.d.ts +3 -3
- package/validators/utils/datetime.js.map +2 -2
- package/validators/utils/email/index.js +16 -0
- package/validators/utils/email/package.json +6 -0
- package/validators/utils/email.d.ts +5 -0
- package/validators/utils/email.js.map +7 -0
- package/validators/utils/file/index.js +30 -17
- package/validators/utils/file.d.ts +2 -2
- package/validators/utils/file.js.map +2 -2
- package/validators/utils/iban.d.ts +2 -2
- package/validators/utils/iban.js.map +1 -1
- package/validators/utils/image.d.ts +2 -2
- package/validators/utils/image.js.map +1 -1
- package/validators/utils/index.d.ts +3 -2
- package/validators/utils/index.js +4 -1
- package/validators/utils/index.js.map +2 -2
- package/validators/utils/int/index.js +1 -1
- package/validators/utils/int.d.ts +1 -1
- package/validators/utils/int.js.map +2 -2
- package/validators/utils/number/index.js +1 -1
- package/validators/utils/number.d.ts +1 -1
- package/validators/utils/number.js.map +2 -2
- package/validators/utils/otp.d.ts +2 -2
- package/validators/utils/otp.js.map +1 -1
- package/validators/utils/phone.d.ts +2 -2
- package/validators/utils/phone.js.map +1 -1
- package/validators/utils/postal_code.d.ts +2 -2
- package/validators/utils/postal_code.js.map +1 -1
- package/validators/utils/text_limit.d.ts +2 -2
- package/validators/utils/text_limit.js.map +1 -1
- package/Field/utils/calculateField/index.js +0 -27
- package/Field/utils/calculateField.d.ts +0 -2
- package/Field/utils/calculateField.js.map +0 -7
- package/Field/utils/index.js.map +0 -7
- package/FieldArray/FormDialog.d.ts +0 -53
- package/FieldArray/FormDialog.js.map +0 -7
- package/FormBuilder/index.test.d.ts +0 -1
- package/FormBuilder/scenarios.test.d.ts +0 -88
- package/MultiplicityField/index.test.d.ts +0 -1
- package/Questions/index.spec.d.ts +0 -1
- package/Questions/index.test.d.ts +0 -1
- package/cjs/Field/utils/calculateField/index.js +0 -50
- package/cjs/Field/utils/calculateField.js.map +0 -7
- package/cjs/Field/utils/index.js.map +0 -7
- package/cjs/FieldArray/FormDialog.js.map +0 -7
- package/cjs/inputs/Input/inputsInputScenarios/index.js +0 -439
- package/cjs/inputs/Input/inputsInputScenarios.js.map +0 -7
- package/cjs/inputs/inputsScenarios/index.js +0 -533
- package/cjs/inputs/inputsScenarios.js.map +0 -7
- package/cjs/locales/el.js.map +0 -7
- package/inputs/AutoCompleteInput/index.test.d.ts +0 -1
- package/inputs/Checkboxes/index.test.d.ts +0 -1
- package/inputs/DateInput/index.test.d.ts +0 -1
- package/inputs/DateTimeInput/index.test.d.ts +0 -1
- package/inputs/FileInput/index.test.d.ts +0 -1
- package/inputs/ImageInput/__stories__/WithInvalidImageSize.d.ts +0 -3
- package/inputs/ImageInput/index.test.d.ts +0 -1
- package/inputs/Input/index.test.d.ts +0 -1
- package/inputs/Input/inputsInputScenarios/index.js +0 -406
- package/inputs/Input/inputsInputScenarios.d.ts +0 -57
- package/inputs/Input/inputsInputScenarios.js.map +0 -7
- package/inputs/Label/index.test.d.ts +0 -1
- package/inputs/OtpInput/index.test.d.ts +0 -1
- package/inputs/Radio/index.test.d.ts +0 -1
- package/inputs/Select/index.test.d.ts +0 -1
- package/inputs/inputsScenarios/index.js +0 -499
- package/inputs/inputsScenarios.d.ts +0 -296
- package/inputs/inputsScenarios.js.map +0 -7
- package/locales/el/index.js +0 -6
- package/locales/el.d.ts +0 -2
- package/locales/el.js.map +0 -7
- package/src/Field/utils/calculateField.ts +0 -49
- package/src/FieldArray/FormDialog.tsx +0 -379
- package/src/inputs/Input/inputsInputScenarios.ts +0 -404
- package/src/inputs/inputsScenarios.ts +0 -496
- package/src/locales/el.ts +0 -3
- /package/{FieldArray/index.test.d.ts → hooks/__tests__/utils.spec.d.ts} +0 -0
|
@@ -25,6 +25,7 @@ const Multiplicity = ({
|
|
|
25
25
|
setValue,
|
|
26
26
|
getValues,
|
|
27
27
|
unregister,
|
|
28
|
+
resetField,
|
|
28
29
|
Field
|
|
29
30
|
}) => {
|
|
30
31
|
const { fields, append, remove } = useFieldArray({
|
|
@@ -47,8 +48,10 @@ const Multiplicity = ({
|
|
|
47
48
|
label,
|
|
48
49
|
layout,
|
|
49
50
|
error: formState.isSubmitted && !formState.isSubmitting && error?.message ? error : void 0,
|
|
51
|
+
hasError: formState.isSubmitted && !formState.isSubmitting && !!error,
|
|
50
52
|
wrapper: "fieldset",
|
|
51
|
-
name
|
|
53
|
+
name,
|
|
54
|
+
register
|
|
52
55
|
},
|
|
53
56
|
stashedObjects.length > 0 ? /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Heading, { size: "md" }, extra?.label.object.title_added), stashedObjects.map((_Object, index) => {
|
|
54
57
|
return /* @__PURE__ */ React.createElement(
|
|
@@ -83,6 +86,7 @@ const Multiplicity = ({
|
|
|
83
86
|
getValues,
|
|
84
87
|
unregister,
|
|
85
88
|
trigger,
|
|
89
|
+
resetField,
|
|
86
90
|
clearErrors,
|
|
87
91
|
Field
|
|
88
92
|
}
|
|
@@ -101,7 +105,7 @@ const ListObject = ({
|
|
|
101
105
|
// onEdit,
|
|
102
106
|
}) => {
|
|
103
107
|
const currentName = `${name}.${index}`;
|
|
104
|
-
return /* @__PURE__ */ React.createElement(Card, { variant: extra?.border
|
|
108
|
+
return /* @__PURE__ */ React.createElement(Card, { variant: extra?.border && "border" }, /* @__PURE__ */ React.createElement(CardHeading, null, extra?.label.object.title, " #", index + 1), /* @__PURE__ */ React.createElement(CardContent, null, /* @__PURE__ */ React.createElement(
|
|
105
109
|
FieldObject,
|
|
106
110
|
{
|
|
107
111
|
name: currentName,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/MultiplicityField/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useState } from 'react';\nimport {
|
|
5
|
-
"mappings": "AAAA,OAAO,SAAS,gBAAgB;
|
|
4
|
+
"sourcesContent": ["import React, { useState } from 'react';\nimport type { UseFormReturn } from 'react-hook-form';\nimport { useFieldArray } from 'react-hook-form';\nimport { FieldBaseContainer } from '@digigov/form/Field/FieldBaseContainer';\nimport { FieldObject } from '@digigov/form/FieldObject';\nimport { AddObjects } from '@digigov/form/MultiplicityField/add-objects';\nimport type {\n MultiplicityProps,\n StashedObject,\n} from '@digigov/form/MultiplicityField/types';\nimport {\n Card,\n CardHeading,\n CardContent,\n CardAction,\n} from '@digigov/ui/content/Card';\nimport { Button } from '@digigov/ui/form/Button';\nimport { Heading } from '@digigov/ui/typography/Heading';\n\n// epeidh einai forwardRef to ref mas to dinei xwrista apo ta props\nexport const Multiplicity: React.FC<MultiplicityProps> = ({\n extra,\n name,\n control,\n error,\n register,\n trigger,\n clearErrors,\n formState,\n label,\n layout,\n setValue,\n getValues,\n unregister,\n resetField,\n Field,\n}) => {\n const { fields, append, remove } = useFieldArray({\n control,\n name,\n });\n const [stashedObjects, setStashedObjects] = useState<StashedObject[]>([]);\n const handleStash = (data) => {\n setStashedObjects([...stashedObjects, data]);\n };\n const handleDelete = (index) => {\n remove(index);\n // creating a new array to maintain immutability\n const newStashedObjects = [...stashedObjects];\n newStashedObjects.splice(index, 1);\n setStashedObjects(newStashedObjects);\n };\n return (\n <FieldBaseContainer\n label={label}\n layout={layout}\n error={\n formState.isSubmitted && !formState.isSubmitting && error?.message\n ? error\n : undefined\n }\n hasError={formState.isSubmitted && !formState.isSubmitting && !!error}\n wrapper=\"fieldset\"\n name={name}\n register={register}\n >\n {stashedObjects.length > 0 ? (\n <div>\n <Heading size=\"md\">{extra?.label.object.title_added}</Heading>\n {stashedObjects.map((_Object, index) => {\n return (\n <ListObject\n key={`${name}.${index}`}\n index={index}\n name={name}\n extra={extra}\n control={control}\n register={register}\n formState={formState}\n onDelete={handleDelete}\n />\n );\n })}\n </div>\n ) : (\n ''\n )}\n <AddObjects\n name={name}\n register={register}\n control={control}\n fields={fields}\n formState={formState}\n error={error}\n stashedObjects={stashedObjects}\n extra={extra}\n append={append}\n remove={remove}\n onStash={handleStash}\n setValue={setValue}\n getValues={getValues}\n unregister={unregister}\n trigger={trigger}\n resetField={resetField}\n clearErrors={clearErrors}\n Field={Field}\n />\n </FieldBaseContainer>\n );\n};\n\nexport default Multiplicity;\n\nexport interface ListObjectProps {\n index: number;\n name: string;\n control: UseFormReturn['control'];\n register: UseFormReturn['register'];\n formState: UseFormReturn['formState'];\n onDelete: (index: number) => void;\n extra?: Record<string, any>;\n}\n\nexport const ListObject: React.FC<ListObjectProps> = ({\n index,\n name,\n extra,\n control,\n register,\n onDelete,\n formState,\n // onEdit,\n}) => {\n const currentName = `${name}.${index}`;\n return (\n <Card variant={extra?.border && 'border'}>\n <CardHeading>\n {extra?.label.object.title} #{index + 1}\n </CardHeading>\n <CardContent>\n <FieldObject\n name={currentName}\n formState={formState}\n register={register}\n control={control}\n {...extra?.of}\n />\n </CardContent>\n <CardAction>\n <Button type=\"button\" variant=\"link\" onClick={() => onDelete(index)}>\n {extra?.label.object.delete}\n </Button>\n </CardAction>\n </Card>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS,gBAAgB;AAEhC,SAAS,qBAAqB;AAC9B,SAAS,0BAA0B;AACnC,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAK3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc;AACvB,SAAS,eAAe;AAGjB,MAAM,eAA4C,CAAC;AAAA,EACxD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,QAAQ,QAAQ,OAAO,IAAI,cAAc;AAAA,IAC/C;AAAA,IACA;AAAA,EACF,CAAC;AACD,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAA0B,CAAC,CAAC;AACxE,QAAM,cAAc,CAAC,SAAS;AAC5B,sBAAkB,CAAC,GAAG,gBAAgB,IAAI,CAAC;AAAA,EAC7C;AACA,QAAM,eAAe,CAAC,UAAU;AAC9B,WAAO,KAAK;AAEZ,UAAM,oBAAoB,CAAC,GAAG,cAAc;AAC5C,sBAAkB,OAAO,OAAO,CAAC;AACjC,sBAAkB,iBAAiB;AAAA,EACrC;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,OACE,UAAU,eAAe,CAAC,UAAU,gBAAgB,OAAO,UACvD,QACA;AAAA,MAEN,UAAU,UAAU,eAAe,CAAC,UAAU,gBAAgB,CAAC,CAAC;AAAA,MAChE,SAAQ;AAAA,MACR;AAAA,MACA;AAAA;AAAA,IAEC,eAAe,SAAS,IACvB,oCAAC,aACC,oCAAC,WAAQ,MAAK,QAAM,OAAO,MAAM,OAAO,WAAY,GACnD,eAAe,IAAI,CAAC,SAAS,UAAU;AACtC,aACE;AAAA,QAAC;AAAA;AAAA,UACC,KAAK,GAAG,IAAI,IAAI,KAAK;AAAA,UACrB;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,UAAU;AAAA;AAAA,MACZ;AAAA,IAEJ,CAAC,CACH,IAEA;AAAA,IAEF;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,SAAS;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF;AAAA,EACF;AAEJ;AAEA,IAAO,4BAAQ;AAYR,MAAM,aAAwC,CAAC;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAEF,MAAM;AACJ,QAAM,cAAc,GAAG,IAAI,IAAI,KAAK;AACpC,SACE,oCAAC,QAAK,SAAS,OAAO,UAAU,YAC9B,oCAAC,mBACE,OAAO,MAAM,OAAO,OAAM,MAAG,QAAQ,CACxC,GACA,oCAAC,mBACC;AAAA,IAAC;AAAA;AAAA,MACC,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACC,GAAG,OAAO;AAAA;AAAA,EACb,CACF,GACA,oCAAC,kBACC,oCAAC,UAAO,MAAK,UAAS,SAAQ,QAAO,SAAS,MAAM,SAAS,KAAK,KAC/D,OAAO,MAAM,OAAO,MACvB,CACF,CACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ErrorOption, UseFormReturn } from 'react-hook-form';
|
|
2
|
-
import { FieldSpec, ControlledFieldProps } from '@digigov/form/Field/types';
|
|
1
|
+
import type { ErrorOption, UseFormReturn } from 'react-hook-form';
|
|
2
|
+
import type { FieldSpec, ControlledFieldProps } from '@digigov/form/Field/types';
|
|
3
3
|
export interface MultiplicityProps extends Omit<ControlledFieldProps, 'value' | 'onChange' | 'error' | 'extra'> {
|
|
4
4
|
name: string;
|
|
5
5
|
control: UseFormReturn['control'];
|
|
@@ -10,6 +10,7 @@ export interface MultiplicityProps extends Omit<ControlledFieldProps, 'value' |
|
|
|
10
10
|
setValue: UseFormReturn['setValue'];
|
|
11
11
|
getValues: UseFormReturn['getValues'];
|
|
12
12
|
unregister: UseFormReturn['unregister'];
|
|
13
|
+
resetField?: UseFormReturn['resetField'];
|
|
13
14
|
error?: ErrorOption;
|
|
14
15
|
extra?: Record<string, any>;
|
|
15
16
|
label?: FieldSpec['label'];
|
package/Questions/Questions.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { QuestionsInterface } from '@digigov/form/Questions/types';
|
|
2
|
+
import type { QuestionsInterface } from '@digigov/form/Questions/types';
|
|
3
3
|
/**
|
|
4
4
|
* The Question component accepts question data as props
|
|
5
5
|
* uses composable components to provide a wholesome UX
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Questions/Questions.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useState, useEffect } from 'react';\nimport { getNextStep } from '@digigov/form/Questions/getNextStep';\nimport { QuestionsContext } from '@digigov/form/Questions/QuestionsContext';\nimport { StepInterface } from '@digigov/form/Questions/Step/types';\nimport { QuestionsInterface } from '@digigov/form/Questions/types';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/**\n * The Question component accepts question data as props\n * uses composable components to provide a wholesome UX\n *\n */\nexport const Questions: React.FC<QuestionsInterface> = ({\n name,\n steps,\n initialData = {},\n onChange,\n onSubmit,\n onActiveStep,\n forceStepName,\n localDraft = false,\n children,\n}) => {\n const [currentStep, setCurrentStep] = useState<StepInterface>({ name: '' });\n useEffect(() => {\n if (!forceStepName) {\n setCurrentStep(steps[0]);\n }\n }, [forceStepName, steps]);\n useEffect(() => {\n if (forceStepName !== currentStep.name) {\n const forceStep = steps.find(({ name }) => name === forceStepName);\n if (forceStep) setCurrentStep(forceStep);\n }\n }, [forceStepName]);\n const localData =\n isBrowser && localDraft && window.localStorage.getItem(`questions-${name}`);\n const [data, setData] = useState(\n (localData && JSON.parse(localData)) || initialData\n );\n const submitStep = (stepName, stepData): void => {\n data[stepName] = stepData;\n if (localDraft) {\n if (isBrowser)\n window.localStorage.setItem(`questions-${name}`, JSON.stringify(data));\n }\n if (onChange) {\n onChange(data);\n }\n setData(data);\n const nextStep = getNextStep(currentStep, steps, data);\n if (nextStep) {\n if (onActiveStep) onActiveStep(nextStep);\n setCurrentStep(nextStep);\n } else {\n onSubmit(data);\n }\n };\n\n return (\n <QuestionsContext.Provider\n value={{\n steps,\n currentStep,\n submitStep,\n data,\n onActiveStep,\n }}\n >\n {children}\n </QuestionsContext.Provider>\n );\n};\n"],
|
|
4
|
+
"sourcesContent": ["import React, { useState, useEffect } from 'react';\nimport { getNextStep } from '@digigov/form/Questions/getNextStep';\nimport { QuestionsContext } from '@digigov/form/Questions/QuestionsContext';\nimport type { StepInterface } from '@digigov/form/Questions/Step/types';\nimport type { QuestionsInterface } from '@digigov/form/Questions/types';\n\nconst isBrowser = typeof window !== 'undefined';\n\n/**\n * The Question component accepts question data as props\n * uses composable components to provide a wholesome UX\n *\n */\nexport const Questions: React.FC<QuestionsInterface> = ({\n name,\n steps,\n initialData = {},\n onChange,\n onSubmit,\n onActiveStep,\n forceStepName,\n localDraft = false,\n children,\n}) => {\n const [currentStep, setCurrentStep] = useState<StepInterface>({ name: '' });\n useEffect(() => {\n if (!forceStepName) {\n setCurrentStep(steps[0]);\n }\n }, [forceStepName, steps]);\n useEffect(() => {\n if (forceStepName !== currentStep.name) {\n const forceStep = steps.find(({ name }) => name === forceStepName);\n if (forceStep) setCurrentStep(forceStep);\n }\n }, [forceStepName]);\n const localData =\n isBrowser && localDraft && window.localStorage.getItem(`questions-${name}`);\n const [data, setData] = useState(\n (localData && JSON.parse(localData)) || initialData\n );\n const submitStep = (stepName, stepData): void => {\n data[stepName] = stepData;\n if (localDraft) {\n if (isBrowser)\n window.localStorage.setItem(`questions-${name}`, JSON.stringify(data));\n }\n if (onChange) {\n onChange(data);\n }\n setData(data);\n const nextStep = getNextStep(currentStep, steps, data);\n if (nextStep) {\n if (onActiveStep) onActiveStep(nextStep);\n setCurrentStep(nextStep);\n } else {\n onSubmit(data);\n }\n };\n\n return (\n <QuestionsContext.Provider\n value={{\n steps,\n currentStep,\n submitStep,\n data,\n onActiveStep,\n }}\n >\n {children}\n </QuestionsContext.Provider>\n );\n};\n"],
|
|
5
5
|
"mappings": "AAAA,OAAO,SAAS,UAAU,iBAAiB;AAC3C,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AAIjC,MAAM,YAAY,OAAO,WAAW;AAO7B,MAAM,YAA0C,CAAC;AAAA,EACtD;AAAA,EACA;AAAA,EACA,cAAc,CAAC;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb;AACF,MAAM;AACJ,QAAM,CAAC,aAAa,cAAc,IAAI,SAAwB,EAAE,MAAM,GAAG,CAAC;AAC1E,YAAU,MAAM;AACd,QAAI,CAAC,eAAe;AAClB,qBAAe,MAAM,CAAC,CAAC;AAAA,IACzB;AAAA,EACF,GAAG,CAAC,eAAe,KAAK,CAAC;AACzB,YAAU,MAAM;AACd,QAAI,kBAAkB,YAAY,MAAM;AACtC,YAAM,YAAY,MAAM,KAAK,CAAC,EAAE,MAAAA,MAAK,MAAMA,UAAS,aAAa;AACjE,UAAI,UAAW,gBAAe,SAAS;AAAA,IACzC;AAAA,EACF,GAAG,CAAC,aAAa,CAAC;AAClB,QAAM,YACJ,aAAa,cAAc,OAAO,aAAa,QAAQ,aAAa,IAAI,EAAE;AAC5E,QAAM,CAAC,MAAM,OAAO,IAAI;AAAA,IACrB,aAAa,KAAK,MAAM,SAAS,KAAM;AAAA,EAC1C;AACA,QAAM,aAAa,CAAC,UAAU,aAAmB;AAC/C,SAAK,QAAQ,IAAI;AACjB,QAAI,YAAY;AACd,UAAI;AACF,eAAO,aAAa,QAAQ,aAAa,IAAI,IAAI,KAAK,UAAU,IAAI,CAAC;AAAA,IACzE;AACA,QAAI,UAAU;AACZ,eAAS,IAAI;AAAA,IACf;AACA,YAAQ,IAAI;AACZ,UAAM,WAAW,YAAY,aAAa,OAAO,IAAI;AACrD,QAAI,UAAU;AACZ,UAAI,aAAc,cAAa,QAAQ;AACvC,qBAAe,QAAQ;AAAA,IACzB,OAAO;AACL,eAAS,IAAI;AAAA,IACf;AAAA,EACF;AAEA,SACE;AAAA,IAAC,iBAAiB;AAAA,IAAjB;AAAA,MACC,OAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA;AAAA,IAEC;AAAA,EACH;AAEJ;",
|
|
6
6
|
"names": ["name"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { QuestionsContextInterface } from '@digigov/form/Questions/types';
|
|
1
|
+
import type { QuestionsContextInterface } from '@digigov/form/Questions/types';
|
|
2
2
|
export declare const QuestionsContext: import("react").Context<QuestionsContextInterface>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Questions/QuestionsContext.tsx"],
|
|
4
|
-
"sourcesContent": ["import { createContext } from 'react';\nimport { QuestionsContextInterface } from '@digigov/form/Questions/types';\n\nconst defaultStep = { name: '' };\nexport const QuestionsContext = createContext<QuestionsContextInterface>({\n currentStep: defaultStep,\n steps: [],\n submitStep: () => null,\n});\n"],
|
|
4
|
+
"sourcesContent": ["import { createContext } from 'react';\nimport type { QuestionsContextInterface } from '@digigov/form/Questions/types';\n\nconst defaultStep = { name: '' };\nexport const QuestionsContext = createContext<QuestionsContextInterface>({\n currentStep: defaultStep,\n steps: [],\n submitStep: () => null,\n});\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,qBAAqB;AAG9B,MAAM,cAAc,EAAE,MAAM,GAAG;AACxB,MAAM,mBAAmB,cAAyC;AAAA,EACvE,aAAa;AAAA,EACb,OAAO,CAAC;AAAA,EACR,YAAY,MAAM;AACpB,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/Questions/Step/Step.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { StepInterface } from '@digigov/form/Questions/Step/types';
|
|
2
|
+
import type { StepInterface } from '@digigov/form/Questions/Step/types';
|
|
3
3
|
/**
|
|
4
4
|
* The Step component accepts Step data as props
|
|
5
5
|
* uses composable components to provide a wholesome UX
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Questions/Step/Step.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useContext, useState } from 'react';\nimport { QuestionsContext } from '@digigov/form/Questions/QuestionsContext';\nimport { StepArrayReview } from '@digigov/form/Questions/Step/StepArrayReview';\nimport { StepContext } from '@digigov/form/Questions/Step/StepContext';\nimport { StepInterface } from '@digigov/form/Questions/Step/types';\n\n/**\n * The Step component accepts Step data as props\n * uses composable components to provide a wholesome UX\n *\n */\nexport const Step: React.FC<StepInterface> = (props) => {\n // or return all Questions and currentStepName\n // or return a specific Step object\n const { currentStep, submitStep, data } = useContext(QuestionsContext);\n\n const [stepData, setStepData] = useState<Record<string, any>[]>([]);\n const [reviewActive, setReviewActive] = useState(false);\n\n const handleArraySubmit = (_name: string, data: any): void => {\n setStepData([...stepData, data]);\n setReviewActive(true);\n };\n\n const handleArrayDeleteItem = (deleteIndex: number): void => {\n const nextStepData = stepData.filter((_item, stepIndex) => {\n return stepIndex !== deleteIndex;\n });\n setStepData(nextStepData);\n if (nextStepData.length === 0) {\n setReviewActive(false);\n }\n };\n\n const handleArrayReviewStep = (data): void => {\n if (data.addMore === 'yes') {\n setReviewActive(false);\n } else if (data.addMore === 'no') {\n submitStep(currentStep.name, stepData);\n }\n };\n if (!currentStep || props.name !== currentStep.name) return null;\n\n // then provide the currentStep object\n return (\n <StepContext.Provider\n value={{\n ...currentStep,\n submitStep:\n currentStep.type === 'array' ? handleArraySubmit : submitStep,\n initial: data[props.name],\n }}\n >\n {reviewActive ? (\n <StepArrayReview\n array={stepData}\n handleSubmit={handleArrayReviewStep}\n handleDelete={handleArrayDeleteItem}\n />\n ) : (\n props.children\n )}\n </StepContext.Provider>\n );\n};\n\nexport default Step;\n"],
|
|
4
|
+
"sourcesContent": ["import React, { useContext, useState } from 'react';\nimport { QuestionsContext } from '@digigov/form/Questions/QuestionsContext';\nimport { StepArrayReview } from '@digigov/form/Questions/Step/StepArrayReview';\nimport { StepContext } from '@digigov/form/Questions/Step/StepContext';\nimport type { StepInterface } from '@digigov/form/Questions/Step/types';\n\n/**\n * The Step component accepts Step data as props\n * uses composable components to provide a wholesome UX\n *\n */\nexport const Step: React.FC<StepInterface> = (props) => {\n // or return all Questions and currentStepName\n // or return a specific Step object\n const { currentStep, submitStep, data } = useContext(QuestionsContext);\n\n const [stepData, setStepData] = useState<Record<string, any>[]>([]);\n const [reviewActive, setReviewActive] = useState(false);\n\n const handleArraySubmit = (_name: string, data: any): void => {\n setStepData([...stepData, data]);\n setReviewActive(true);\n };\n\n const handleArrayDeleteItem = (deleteIndex: number): void => {\n const nextStepData = stepData.filter((_item, stepIndex) => {\n return stepIndex !== deleteIndex;\n });\n setStepData(nextStepData);\n if (nextStepData.length === 0) {\n setReviewActive(false);\n }\n };\n\n const handleArrayReviewStep = (data): void => {\n if (data.addMore === 'yes') {\n setReviewActive(false);\n } else if (data.addMore === 'no') {\n submitStep(currentStep.name, stepData);\n }\n };\n if (!currentStep || props.name !== currentStep.name) return null;\n\n // then provide the currentStep object\n return (\n <StepContext.Provider\n value={{\n ...currentStep,\n submitStep:\n currentStep.type === 'array' ? handleArraySubmit : submitStep,\n initial: data[props.name],\n }}\n >\n {reviewActive ? (\n <StepArrayReview\n array={stepData}\n handleSubmit={handleArrayReviewStep}\n handleDelete={handleArrayDeleteItem}\n />\n ) : (\n props.children\n )}\n </StepContext.Provider>\n );\n};\n\nexport default Step;\n"],
|
|
5
5
|
"mappings": "AAAA,OAAO,SAAS,YAAY,gBAAgB;AAC5C,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAQrB,MAAM,OAAgC,CAAC,UAAU;AAGtD,QAAM,EAAE,aAAa,YAAY,KAAK,IAAI,WAAW,gBAAgB;AAErE,QAAM,CAAC,UAAU,WAAW,IAAI,SAAgC,CAAC,CAAC;AAClE,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS,KAAK;AAEtD,QAAM,oBAAoB,CAAC,OAAeA,UAAoB;AAC5D,gBAAY,CAAC,GAAG,UAAUA,KAAI,CAAC;AAC/B,oBAAgB,IAAI;AAAA,EACtB;AAEA,QAAM,wBAAwB,CAAC,gBAA8B;AAC3D,UAAM,eAAe,SAAS,OAAO,CAAC,OAAO,cAAc;AACzD,aAAO,cAAc;AAAA,IACvB,CAAC;AACD,gBAAY,YAAY;AACxB,QAAI,aAAa,WAAW,GAAG;AAC7B,sBAAgB,KAAK;AAAA,IACvB;AAAA,EACF;AAEA,QAAM,wBAAwB,CAACA,UAAe;AAC5C,QAAIA,MAAK,YAAY,OAAO;AAC1B,sBAAgB,KAAK;AAAA,IACvB,WAAWA,MAAK,YAAY,MAAM;AAChC,iBAAW,YAAY,MAAM,QAAQ;AAAA,IACvC;AAAA,EACF;AACA,MAAI,CAAC,eAAe,MAAM,SAAS,YAAY,KAAM,QAAO;AAG5D,SACE;AAAA,IAAC,YAAY;AAAA,IAAZ;AAAA,MACC,OAAO;AAAA,QACL,GAAG;AAAA,QACH,YACE,YAAY,SAAS,UAAU,oBAAoB;AAAA,QACrD,SAAS,KAAK,MAAM,IAAI;AAAA,MAC1B;AAAA;AAAA,IAEC,eACC;AAAA,MAAC;AAAA;AAAA,QACC,OAAO;AAAA,QACP,cAAc;AAAA,QACd,cAAc;AAAA;AAAA,IAChB,IAEA,MAAM;AAAA,EAEV;AAEJ;AAEA,IAAO,eAAQ;",
|
|
6
6
|
"names": ["data"]
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { StepArrayReviewInterface } from '@digigov/form/Questions/Step/types';
|
|
2
|
+
import type { StepArrayReviewInterface } from '@digigov/form/Questions/Step/types';
|
|
3
3
|
export declare const StepArrayReview: React.FC<StepArrayReviewInterface>;
|
|
4
4
|
export default StepArrayReview;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Questions/Step/StepArrayReview.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useContext } from 'react';\nimport { Field } from '@digigov/form/Field';\nimport { Fieldset } from '@digigov/form/Fieldset';\nimport FormBuilder from '@digigov/form/FormBuilder';\nimport Label from '@digigov/form/inputs/Label';\nimport { QuestionsContext } from '@digigov/form/Questions/QuestionsContext';\nimport { getAddMoreFields } from '@digigov/form/Questions/Step/getAddMoreFields';\nimport { StepArrayReviewInterface } from '@digigov/form/Questions/Step/types';\nimport { FieldSpec } from '@digigov/form/types';\nimport PageTitleContainer, {\n PageTitleHeading,\n} from '@digigov/ui/app/PageTitleContainer';\nimport {\n SummaryList,\n SummaryListItem,\n SummaryListItemKey,\n SummaryListItemValue,\n SummaryListItemAction,\n} from '@digigov/ui/content/SummaryList';\nimport Button from '@digigov/ui/form/Button';\nimport { useTranslation } from '@digigov/ui/i18n';\n\nexport const StepArrayReview: React.FC<StepArrayReviewInterface> = (props) => {\n const { t } = useTranslation();\n const { currentStep } = useContext(QuestionsContext);\n const fields = getAddMoreFields(currentStep);\n const primaryField =\n currentStep.fields.find(\n (field: { key: any }) => field.key === currentStep.review?.primaryFieldKey\n ) || {};\n return (\n <>\n <PageTitleContainer>\n <PageTitleHeading>\n {currentStep.review?.title && t(currentStep.review?.title)}\n </PageTitleHeading>\n </PageTitleContainer>\n <SummaryList>\n {props.array.map(\n (item: Record<string, React.ReactNode>, idx: number) => (\n <SummaryListItem key={idx}>\n <SummaryListItemKey>\n {t(primaryField.label.primary)}\n </SummaryListItemKey>\n <SummaryListItemValue>\n {item[primaryField.key]}\n </SummaryListItemValue>\n <SummaryListItemAction\n onClick={(): void => props.handleDelete(idx)}\n >\n {t('button.delete')}\n </SummaryListItemAction>\n </SummaryListItem>\n )\n )}\n </SummaryList>\n <FormBuilder key=\"addmore\" fields={fields} onSubmit={props.handleSubmit}>\n <Fieldset>\n <Label label={currentStep.review?.addMore.title} />\n {fields.map((field: FieldSpec) => (\n <Field key={field.key} name={field.key} />\n ))}\n </Fieldset>\n <Button type=\"submit\">{t('button.submit')}</Button>\n </FormBuilder>\n </>\n );\n};\n\nexport default StepArrayReview;\n"],
|
|
4
|
+
"sourcesContent": ["import React, { useContext } from 'react';\nimport { Field } from '@digigov/form/Field';\nimport { Fieldset } from '@digigov/form/Fieldset';\nimport FormBuilder from '@digigov/form/FormBuilder';\nimport Label from '@digigov/form/inputs/Label';\nimport { QuestionsContext } from '@digigov/form/Questions/QuestionsContext';\nimport { getAddMoreFields } from '@digigov/form/Questions/Step/getAddMoreFields';\nimport type { StepArrayReviewInterface } from '@digigov/form/Questions/Step/types';\nimport type { FieldSpec } from '@digigov/form/types';\nimport PageTitleContainer, {\n PageTitleHeading,\n} from '@digigov/ui/app/PageTitleContainer';\nimport {\n SummaryList,\n SummaryListItem,\n SummaryListItemKey,\n SummaryListItemValue,\n SummaryListItemAction,\n} from '@digigov/ui/content/SummaryList';\nimport Button from '@digigov/ui/form/Button';\nimport { useTranslation } from '@digigov/ui/i18n';\n\nexport const StepArrayReview: React.FC<StepArrayReviewInterface> = (props) => {\n const { t } = useTranslation();\n const { currentStep } = useContext(QuestionsContext);\n const fields = getAddMoreFields(currentStep);\n const primaryField =\n currentStep.fields.find(\n (field: { key: any }) => field.key === currentStep.review?.primaryFieldKey\n ) || {};\n return (\n <>\n <PageTitleContainer>\n <PageTitleHeading>\n {currentStep.review?.title && t(currentStep.review?.title)}\n </PageTitleHeading>\n </PageTitleContainer>\n <SummaryList>\n {props.array.map(\n (item: Record<string, React.ReactNode>, idx: number) => (\n <SummaryListItem key={idx}>\n <SummaryListItemKey>\n {t(primaryField.label.primary)}\n </SummaryListItemKey>\n <SummaryListItemValue>\n {item[primaryField.key]}\n </SummaryListItemValue>\n <SummaryListItemAction\n onClick={(): void => props.handleDelete(idx)}\n >\n {t('button.delete')}\n </SummaryListItemAction>\n </SummaryListItem>\n )\n )}\n </SummaryList>\n <FormBuilder key=\"addmore\" fields={fields} onSubmit={props.handleSubmit}>\n <Fieldset>\n <Label label={currentStep.review?.addMore.title} />\n {fields.map((field: FieldSpec) => (\n <Field key={field.key} name={field.key} />\n ))}\n </Fieldset>\n <Button type=\"submit\">{t('button.submit')}</Button>\n </FormBuilder>\n </>\n );\n};\n\nexport default StepArrayReview;\n"],
|
|
5
5
|
"mappings": "AAAA,OAAO,SAAS,kBAAkB;AAClC,SAAS,aAAa;AACtB,SAAS,gBAAgB;AACzB,OAAO,iBAAiB;AACxB,OAAO,WAAW;AAClB,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AAGjC,OAAO;AAAA,EACL;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,OAAO,YAAY;AACnB,SAAS,sBAAsB;AAExB,MAAM,kBAAsD,CAAC,UAAU;AAC5E,QAAM,EAAE,EAAE,IAAI,eAAe;AAC7B,QAAM,EAAE,YAAY,IAAI,WAAW,gBAAgB;AACnD,QAAM,SAAS,iBAAiB,WAAW;AAC3C,QAAM,eACJ,YAAY,OAAO;AAAA,IACjB,CAAC,UAAwB,MAAM,QAAQ,YAAY,QAAQ;AAAA,EAC7D,KAAK,CAAC;AACR,SACE,0DACE,oCAAC,0BACC,oCAAC,wBACE,YAAY,QAAQ,SAAS,EAAE,YAAY,QAAQ,KAAK,CAC3D,CACF,GACA,oCAAC,mBACE,MAAM,MAAM;AAAA,IACX,CAAC,MAAuC,QACtC,oCAAC,mBAAgB,KAAK,OACpB,oCAAC,0BACE,EAAE,aAAa,MAAM,OAAO,CAC/B,GACA,oCAAC,4BACE,KAAK,aAAa,GAAG,CACxB,GACA;AAAA,MAAC;AAAA;AAAA,QACC,SAAS,MAAY,MAAM,aAAa,GAAG;AAAA;AAAA,MAE1C,EAAE,eAAe;AAAA,IACpB,CACF;AAAA,EAEJ,CACF,GACA,oCAAC,eAAY,KAAI,WAAU,QAAgB,UAAU,MAAM,gBACzD,oCAAC,gBACC,oCAAC,SAAM,OAAO,YAAY,QAAQ,QAAQ,OAAO,GAChD,OAAO,IAAI,CAAC,UACX,oCAAC,SAAM,KAAK,MAAM,KAAK,MAAM,MAAM,KAAK,CACzC,CACH,GACA,oCAAC,UAAO,MAAK,YAAU,EAAE,eAAe,CAAE,CAC5C,CACF;AAEJ;AAEA,IAAO,0BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Questions/Step/StepContext.tsx"],
|
|
4
|
-
"sourcesContent": ["import { createContext } from 'react';\nimport { StepInterface } from '@digigov/form/Questions/Step/types';\n\nexport const StepContext = createContext<StepInterface>({\n name: '',\n fields: [],\n initial: [],\n errorLabels: [],\n submitStep: '',\n review: {\n title: '',\n primaryFieldKey: '',\n addMore: {\n title: { primary: '' },\n answers: { positive: { primary: 'Yes' }, negative: { primary: 'No' } },\n },\n },\n type: 'object',\n});\n\nexport default StepContext;\n"],
|
|
4
|
+
"sourcesContent": ["import { createContext } from 'react';\nimport type { StepInterface } from '@digigov/form/Questions/Step/types';\n\nexport const StepContext = createContext<StepInterface>({\n name: '',\n fields: [],\n initial: [],\n errorLabels: [],\n submitStep: '',\n review: {\n title: '',\n primaryFieldKey: '',\n addMore: {\n title: { primary: '' },\n answers: { positive: { primary: 'Yes' }, negative: { primary: 'No' } },\n },\n },\n type: 'object',\n});\n\nexport default StepContext;\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,qBAAqB;AAGvB,MAAM,cAAc,cAA6B;AAAA,EACtD,MAAM;AAAA,EACN,QAAQ,CAAC;AAAA,EACT,SAAS,CAAC;AAAA,EACV,aAAa,CAAC;AAAA,EACd,YAAY;AAAA,EACZ,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,iBAAiB;AAAA,IACjB,SAAS;AAAA,MACP,OAAO,EAAE,SAAS,GAAG;AAAA,MACrB,SAAS,EAAE,UAAU,EAAE,SAAS,MAAM,GAAG,UAAU,EAAE,SAAS,KAAK,EAAE;AAAA,IACvE;AAAA,EACF;AAAA,EACA,MAAM;AACR,CAAC;AAED,IAAO,sBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Questions/Step/StepDescription.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useContext } from 'react';\nimport { StepContext } from '@digigov/form/Questions/Step/StepContext';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport
|
|
5
|
-
"mappings": "AAAA,OAAO,SAAS,kBAAkB;AAClC,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;
|
|
4
|
+
"sourcesContent": ["import React, { useContext } from 'react';\nimport { StepContext } from '@digigov/form/Questions/Step/StepContext';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport type { ParagraphProps } from '@digigov/ui/typography/Paragraph';\nimport Paragraph from '@digigov/ui/typography/Paragraph';\n\nexport interface StepDescriptionInterface extends ParagraphProps {\n description?: string;\n}\n\nexport const StepDescriptionBase: React.FC<StepDescriptionInterface> = ({\n children,\n description,\n ...props\n}) => {\n const { t } = useTranslation();\n return (\n <Paragraph {...props}>\n {children || (description && t(description))}\n </Paragraph>\n );\n};\n\nexport const StepDescription: React.FC<StepDescriptionInterface> = (props) => {\n const { description: descriptionContext } = useContext(StepContext);\n const description = props.description || descriptionContext;\n return (\n <StepDescriptionBase description={description} {...props}>\n {props.children}\n </StepDescriptionBase>\n );\n};\n\nexport default StepDescription;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS,kBAAkB;AAClC,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAE/B,OAAO,eAAe;AAMf,MAAM,sBAA0D,CAAC;AAAA,EACtE;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,EAAE,IAAI,eAAe;AAC7B,SACE,oCAAC,aAAW,GAAG,SACZ,YAAa,eAAe,EAAE,WAAW,CAC5C;AAEJ;AAEO,MAAM,kBAAsD,CAAC,UAAU;AAC5E,QAAM,EAAE,aAAa,mBAAmB,IAAI,WAAW,WAAW;AAClE,QAAM,cAAc,MAAM,eAAe;AACzC,SACE,oCAAC,uBAAoB,aAA2B,GAAG,SAChD,MAAM,QACT;AAEJ;AAEA,IAAO,0BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { FieldProps } from '@digigov/form/Field/types';
|
|
3
|
-
import { FormBuilderProps } from '@digigov/form/types';
|
|
2
|
+
import type { FieldProps } from '@digigov/form/Field/types';
|
|
3
|
+
import type { FormBuilderProps } from '@digigov/form/types';
|
|
4
4
|
export interface StepFormProps {
|
|
5
5
|
submitButton: boolean;
|
|
6
6
|
children: React.ReactNode;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Questions/Step/StepForm.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useContext } from 'react';\nimport Field from '@digigov/form/Field';\nimport { FieldProps } from '@digigov/form/Field/types';\nimport Fieldset from '@digigov/form/Fieldset';\nimport FormBuilder from '@digigov/form/FormBuilder';\nimport { StepContext } from '@digigov/form/Questions/Step/StepContext';\nimport { FormBuilderProps } from '@digigov/form/types';\nimport Button from '@digigov/ui/form/Button';\nimport { useTranslation } from '@digigov/ui/i18n';\n\nexport interface StepFormProps {\n submitButton: boolean;\n children: React.ReactNode;\n fields?: FieldProps[];\n initial?: FormBuilderProps['initial'];\n}\n\n/**\n * The StepForm component accepts a title, a caption and a\n * decription about the Step asked to the User\n */\nexport const StepForm: React.FC<StepFormProps> = ({\n children,\n submitButton,\n ...props\n}) => {\n const { t } = useTranslation();\n const { name, submitStep, ...rest } = useContext(StepContext);\n const fields = rest.fields.length ? rest.fields : props.fields;\n const initial = rest.initial ? rest.initial : props.initial;\n return (\n <FormBuilder\n initial={initial}\n fields={fields}\n onSubmit={(data): void => {\n submitStep(name, data);\n }}\n >\n {children ? (\n <>\n {children}\n {submitButton && (\n <Button type=\"submit\">{t('button.continue')}</Button>\n )}\n </>\n ) : (\n <>\n <Fieldset>\n {fields.map((field) => (\n <Field key={field.key} name={field.key} />\n ))}\n </Fieldset>\n <Button type=\"submit\">{t('button.continue')}</Button>\n </>\n )}\n </FormBuilder>\n );\n};\n\nexport default StepForm;\n"],
|
|
4
|
+
"sourcesContent": ["import React, { useContext } from 'react';\nimport Field from '@digigov/form/Field';\nimport type { FieldProps } from '@digigov/form/Field/types';\nimport Fieldset from '@digigov/form/Fieldset';\nimport FormBuilder from '@digigov/form/FormBuilder';\nimport { StepContext } from '@digigov/form/Questions/Step/StepContext';\nimport type { FormBuilderProps } from '@digigov/form/types';\nimport Button from '@digigov/ui/form/Button';\nimport { useTranslation } from '@digigov/ui/i18n';\n\nexport interface StepFormProps {\n submitButton: boolean;\n children: React.ReactNode;\n fields?: FieldProps[];\n initial?: FormBuilderProps['initial'];\n}\n\n/**\n * The StepForm component accepts a title, a caption and a\n * decription about the Step asked to the User\n */\nexport const StepForm: React.FC<StepFormProps> = ({\n children,\n submitButton,\n ...props\n}) => {\n const { t } = useTranslation();\n const { name, submitStep, ...rest } = useContext(StepContext);\n const fields = rest.fields.length ? rest.fields : props.fields;\n const initial = rest.initial ? rest.initial : props.initial;\n return (\n <FormBuilder\n initial={initial}\n fields={fields}\n onSubmit={(data): void => {\n submitStep(name, data);\n }}\n >\n {children ? (\n <>\n {children}\n {submitButton && (\n <Button type=\"submit\">{t('button.continue')}</Button>\n )}\n </>\n ) : (\n <>\n <Fieldset>\n {fields.map((field) => (\n <Field key={field.key} name={field.key} />\n ))}\n </Fieldset>\n <Button type=\"submit\">{t('button.continue')}</Button>\n </>\n )}\n </FormBuilder>\n );\n};\n\nexport default StepForm;\n"],
|
|
5
5
|
"mappings": "AAAA,OAAO,SAAS,kBAAkB;AAClC,OAAO,WAAW;AAElB,OAAO,cAAc;AACrB,OAAO,iBAAiB;AACxB,SAAS,mBAAmB;AAE5B,OAAO,YAAY;AACnB,SAAS,sBAAsB;AAaxB,MAAM,WAAoC,CAAC;AAAA,EAChD;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,EAAE,IAAI,eAAe;AAC7B,QAAM,EAAE,MAAM,YAAY,GAAG,KAAK,IAAI,WAAW,WAAW;AAC5D,QAAM,SAAS,KAAK,OAAO,SAAS,KAAK,SAAS,MAAM;AACxD,QAAM,UAAU,KAAK,UAAU,KAAK,UAAU,MAAM;AACpD,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,UAAU,CAAC,SAAe;AACxB,mBAAW,MAAM,IAAI;AAAA,MACvB;AAAA;AAAA,IAEC,WACC,0DACG,UACA,gBACC,oCAAC,UAAO,MAAK,YAAU,EAAE,iBAAiB,CAAE,CAEhD,IAEA,0DACE,oCAAC,gBACE,OAAO,IAAI,CAAC,UACX,oCAAC,SAAM,KAAK,MAAM,KAAK,MAAM,MAAM,KAAK,CACzC,CACH,GACA,oCAAC,UAAO,MAAK,YAAU,EAAE,iBAAiB,CAAE,CAC9C;AAAA,EAEJ;AAEJ;AAEA,IAAO,mBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Questions/Step/StepQuote.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport
|
|
5
|
-
"mappings": "AAAA,OAAO,WAAW;
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport type { ParagraphProps } from '@digigov/ui/typography/Paragraph';\nimport Paragraph from '@digigov/ui/typography/Paragraph';\n\nexport const StepQuote: React.FC<ParagraphProps> = ({ children, ...props }) => {\n return <Paragraph {...props}>{children}</Paragraph>;\n};\n\nexport default StepQuote;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,WAAW;AAElB,OAAO,eAAe;AAEf,MAAM,YAAsC,CAAC,EAAE,UAAU,GAAG,MAAM,MAAM;AAC7E,SAAO,oCAAC,aAAW,GAAG,SAAQ,QAAS;AACzC;AAEA,IAAO,oBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Questions/Step/StepTitle.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useContext } from 'react';\nimport { StepContext } from '@digigov/form/Questions/Step/StepContext';\nimport {\n PageTitleContainer,\n PageTitleCaption,\n} from '@digigov/ui/app/PageTitleContainer';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport { BackLink } from '@digigov/ui/navigation/BackLink';\nimport { Heading
|
|
5
|
-
"mappings": "AAAA,OAAO,SAAS,kBAAkB;AAClC,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;
|
|
4
|
+
"sourcesContent": ["import React, { useContext } from 'react';\nimport { StepContext } from '@digigov/form/Questions/Step/StepContext';\nimport {\n PageTitleContainer,\n PageTitleCaption,\n} from '@digigov/ui/app/PageTitleContainer';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport { BackLink } from '@digigov/ui/navigation/BackLink';\nimport type { HeadingProps } from '@digigov/ui/typography/Heading';\nimport { Heading } from '@digigov/ui/typography/Heading';\nimport { HeadingCaption } from '@digigov/ui/typography/HeadingCaption';\n\nexport interface StepTitleInterface {\n title?: string;\n backButton?: string;\n caption?: string;\n step?: string;\n children?: React.ReactNode;\n}\n\nexport const StepTitleHeading: React.FC<HeadingProps> = (props) => {\n return <Heading>{props.children}</Heading>;\n};\n\nexport const StepTitleBase: React.FC<StepTitleInterface> = ({\n caption,\n step,\n title,\n backButton,\n children,\n}): React.ReactElement => {\n const { t } = useTranslation();\n return (\n <>\n <BackLink>{backButton || t('button.back')}</BackLink>\n <PageTitleContainer>\n {children || (\n <>\n <HeadingCaption size=\"xl\">{caption && t(caption)}</HeadingCaption>\n {step && <PageTitleCaption>{step}</PageTitleCaption>}\n <StepTitleHeading>{title && t(title)}</StepTitleHeading>\n </>\n )}\n </PageTitleContainer>\n </>\n );\n};\n\n/**\n * The StepTitle component accepts a title, a caption and a step indicator\n * about the Step asked to the User\n */\nexport const StepTitle: React.FC<StepTitleInterface> = (props) => {\n const { caption, title, step, backButton } = useContext(StepContext);\n return (\n <StepTitleBase\n backButton={backButton}\n caption={caption}\n step={step}\n title={title}\n >\n {props.children}\n </StepTitleBase>\n );\n};\n\nexport default StepTitle;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS,kBAAkB;AAClC,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AAEzB,SAAS,eAAe;AACxB,SAAS,sBAAsB;AAUxB,MAAM,mBAA2C,CAAC,UAAU;AACjE,SAAO,oCAAC,eAAS,MAAM,QAAS;AAClC;AAEO,MAAM,gBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAA0B;AACxB,QAAM,EAAE,EAAE,IAAI,eAAe;AAC7B,SACE,0DACE,oCAAC,gBAAU,cAAc,EAAE,aAAa,CAAE,GAC1C,oCAAC,0BACE,YACC,0DACE,oCAAC,kBAAe,MAAK,QAAM,WAAW,EAAE,OAAO,CAAE,GAChD,QAAQ,oCAAC,wBAAkB,IAAK,GACjC,oCAAC,wBAAkB,SAAS,EAAE,KAAK,CAAE,CACvC,CAEJ,CACF;AAEJ;AAMO,MAAM,YAA0C,CAAC,UAAU;AAChE,QAAM,EAAE,SAAS,OAAO,MAAM,WAAW,IAAI,WAAW,WAAW;AACnE,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,IAEC,MAAM;AAAA,EACT;AAEJ;AAEA,IAAO,oBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { StepInterface } from '@digigov/form/Questions/Step/types';
|
|
2
|
-
import { FieldSpec } from '@digigov/form/types';
|
|
1
|
+
import type { StepInterface } from '@digigov/form/Questions/Step/types';
|
|
2
|
+
import type { FieldSpec } from '@digigov/form/types';
|
|
3
3
|
export declare const getAddMoreFields: (currentStep: StepInterface) => FieldSpec[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Questions/Step/getAddMoreFields.tsx"],
|
|
4
|
-
"sourcesContent": ["import { StepInterface } from '@digigov/form/Questions/Step/types';\nimport { FieldSpec } from '@digigov/form/types';\n\nexport const getAddMoreFields = (currentStep: StepInterface): FieldSpec[] => {\n return [\n {\n key: 'addMore',\n type: 'choice:single',\n required: true,\n extra: {\n options: [\n {\n label: currentStep.review?.addMore.answers.positive || {\n primary: 'Yes',\n },\n value: 'yes',\n },\n {\n label: currentStep.review?.addMore.answers.negative || {\n primary: 'No',\n },\n value: 'no',\n },\n ],\n },\n },\n ];\n};\n"],
|
|
4
|
+
"sourcesContent": ["import type { StepInterface } from '@digigov/form/Questions/Step/types';\nimport type { FieldSpec } from '@digigov/form/types';\n\nexport const getAddMoreFields = (currentStep: StepInterface): FieldSpec[] => {\n return [\n {\n key: 'addMore',\n type: 'choice:single',\n required: true,\n extra: {\n options: [\n {\n label: currentStep.review?.addMore.answers.positive || {\n primary: 'Yes',\n },\n value: 'yes',\n },\n {\n label: currentStep.review?.addMore.answers.negative || {\n primary: 'No',\n },\n value: 'no',\n },\n ],\n },\n },\n ];\n};\n"],
|
|
5
5
|
"mappings": "AAGO,MAAM,mBAAmB,CAAC,gBAA4C;AAC3E,SAAO;AAAA,IACL;AAAA,MACE,KAAK;AAAA,MACL,MAAM;AAAA,MACN,UAAU;AAAA,MACV,OAAO;AAAA,QACL,SAAS;AAAA,UACP;AAAA,YACE,OAAO,YAAY,QAAQ,QAAQ,QAAQ,YAAY;AAAA,cACrD,SAAS;AAAA,YACX;AAAA,YACA,OAAO;AAAA,UACT;AAAA,UACA;AAAA,YACE,OAAO,YAAY,QAAQ,QAAQ,QAAQ,YAAY;AAAA,cACrD,SAAS;AAAA,YACX;AAAA,YACA,OAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { StepInterface } from '@digigov/form/Questions/Step/types';
|
|
1
|
+
import type { StepInterface } from '@digigov/form/Questions/Step/types';
|
|
2
2
|
export declare function getNextStep(currentStep: any, steps: any[], data: any): StepInterface | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Questions/getNextStep.tsx"],
|
|
4
|
-
"sourcesContent": ["import { StepInterface } from '@digigov/form/Questions/Step/types';\n\nexport function getNextStep(\n currentStep: any,\n steps: any[],\n data: any\n): StepInterface | null {\n if (currentStep.nextStep) {\n const nextStepName = currentStep.nextStep(data);\n if (nextStepName) {\n return steps.find((step) => step.name === nextStepName);\n }\n }\n const currentStepIndex = steps.findIndex(\n (step) => step.name === currentStep.name\n );\n const nextStep = steps.slice(currentStepIndex + 1).find((step) => {\n if (step.show) {\n return step.show(data);\n }\n return true;\n });\n return nextStep;\n}\n"],
|
|
4
|
+
"sourcesContent": ["import type { StepInterface } from '@digigov/form/Questions/Step/types';\n\nexport function getNextStep(\n currentStep: any,\n steps: any[],\n data: any\n): StepInterface | null {\n if (currentStep.nextStep) {\n const nextStepName = currentStep.nextStep(data);\n if (nextStepName) {\n return steps.find((step) => step.name === nextStepName);\n }\n }\n const currentStepIndex = steps.findIndex(\n (step) => step.name === currentStep.name\n );\n const nextStep = steps.slice(currentStepIndex + 1).find((step) => {\n if (step.show) {\n return step.show(data);\n }\n return true;\n });\n return nextStep;\n}\n"],
|
|
5
5
|
"mappings": "AAEO,SAAS,YACd,aACA,OACA,MACsB;AACtB,MAAI,YAAY,UAAU;AACxB,UAAM,eAAe,YAAY,SAAS,IAAI;AAC9C,QAAI,cAAc;AAChB,aAAO,MAAM,KAAK,CAAC,SAAS,KAAK,SAAS,YAAY;AAAA,IACxD;AAAA,EACF;AACA,QAAM,mBAAmB,MAAM;AAAA,IAC7B,CAAC,SAAS,KAAK,SAAS,YAAY;AAAA,EACtC;AACA,QAAM,WAAW,MAAM,MAAM,mBAAmB,CAAC,EAAE,KAAK,CAAC,SAAS;AAChE,QAAI,KAAK,MAAM;AACb,aAAO,KAAK,KAAK,IAAI;AAAA,IACvB;AACA,WAAO;AAAA,EACT,CAAC;AACD,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/Questions/types.d.ts
CHANGED
|
@@ -0,0 +1,82 @@
|
|
|
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 ErrorGroup_exports = {};
|
|
29
|
+
__export(ErrorGroup_exports, {
|
|
30
|
+
ErrorGroup: () => ErrorGroup,
|
|
31
|
+
ErrorGroupContext: () => ErrorGroupContext,
|
|
32
|
+
default: () => ErrorGroup_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(ErrorGroup_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_List = require("@digigov/ui/content/List");
|
|
37
|
+
var import_ErrorSummary = require("@digigov/ui/feedback/ErrorSummary");
|
|
38
|
+
var import_i18n = require("@digigov/ui/i18n");
|
|
39
|
+
var import_Link = require("@digigov/ui/navigation/Link");
|
|
40
|
+
var import_Heading = require("@digigov/ui/typography/Heading");
|
|
41
|
+
var import_Base = require("@digigov/ui/utils/Base");
|
|
42
|
+
const ErrorGroupContext = (0, import_react.createContext)(
|
|
43
|
+
null
|
|
44
|
+
);
|
|
45
|
+
const ErrorGroup = ({
|
|
46
|
+
children,
|
|
47
|
+
screenSize,
|
|
48
|
+
fieldOrder
|
|
49
|
+
}) => {
|
|
50
|
+
const [errors, setErrors] = (0, import_react.useState)({});
|
|
51
|
+
const { t } = (0, import_i18n.useTranslation)();
|
|
52
|
+
const setError = (name, label, error) => {
|
|
53
|
+
if (errors[name] !== error && errors[name]?.message !== error?.message) {
|
|
54
|
+
if (!error?.message) {
|
|
55
|
+
const updatedErrors = { ...errors };
|
|
56
|
+
delete updatedErrors[name];
|
|
57
|
+
setErrors(updatedErrors);
|
|
58
|
+
} else {
|
|
59
|
+
setErrors({
|
|
60
|
+
...errors,
|
|
61
|
+
[name]: {
|
|
62
|
+
...error,
|
|
63
|
+
label: label.primary
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
(0, import_react.useEffect)(() => {
|
|
70
|
+
setErrors({});
|
|
71
|
+
}, [screenSize]);
|
|
72
|
+
return /* @__PURE__ */ import_react.default.createElement(ErrorGroupContext.Provider, { value: { setError } }, Object.keys(errors).length !== 0 && /* @__PURE__ */ import_react.default.createElement(import_ErrorSummary.ErrorSummary, { variant: "error-group" }, /* @__PURE__ */ import_react.default.createElement(import_Heading.Heading, { size: "sm" }, "\u03A4\u03B1 \u03C0\u03B1\u03C1\u03B1\u03BA\u03AC\u03C4\u03C9 \u03C0\u03B5\u03B4\u03AF\u03B1 \u03C4\u03B7\u03C2 \u03C6\u03CC\u03C1\u03BC\u03B1\u03C2 \u03B5\u03B9\u03BD\u03B1\u03B9 \u03BB\u03AC\u03B8\u03BF\u03C2.", " "), /* @__PURE__ */ import_react.default.createElement(import_List.List, { listStyle: "bullet" }, (fieldOrder || Object.keys(errors).reverse()).filter((fieldName) => errors[fieldName]).map((fieldName, index) => {
|
|
73
|
+
return /* @__PURE__ */ import_react.default.createElement(import_List.ListItem, { key: index, id: `${fieldName}-error` }, /* @__PURE__ */ import_react.default.createElement(import_Base.Base, { as: "b" }, t(errors[fieldName]?.label), ":"), " ", /* @__PURE__ */ import_react.default.createElement(import_Link.Link, { href: `#${fieldName}` }, t(errors[fieldName]?.message)));
|
|
74
|
+
}))), children);
|
|
75
|
+
};
|
|
76
|
+
var ErrorGroup_default = ErrorGroup;
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
ErrorGroup,
|
|
80
|
+
ErrorGroupContext
|
|
81
|
+
});
|
|
82
|
+
//# sourceMappingURL=ErrorGroup.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/Field/ErrorGroup.tsx"],
|
|
4
|
+
"sourcesContent": ["import React, { createContext, useEffect, useState } from 'react';\nimport type { ErrorOption } from 'react-hook-form';\nimport type { FieldLabelProps } from '@digigov/form/Field/types';\nimport { List, ListItem } from '@digigov/ui/content/List';\nimport { ErrorSummary } from '@digigov/ui/feedback/ErrorSummary';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport { Link } from '@digigov/ui/navigation/Link';\nimport { Heading } from '@digigov/ui/typography/Heading';\nimport { Base } from '@digigov/ui/utils/Base';\nimport type { Breakpoints } from '@digigov/ui/utils/hooks/useScreen';\ninterface ErrorGroupContextType {\n setError: (\n name?: string,\n label?: FieldLabelProps,\n error?: ErrorOption\n ) => void;\n}\nexport const ErrorGroupContext = createContext<ErrorGroupContextType | null>(\n null\n);\n\nexport interface ErrorGroupProps {\n children: React.ReactNode;\n screenSize?: Breakpoints | undefined;\n fieldOrder?: any[];\n}\n\nexport const ErrorGroup: React.FC<ErrorGroupProps> = ({\n children,\n screenSize,\n fieldOrder,\n}) => {\n const [errors, setErrors] = useState<ErrorOption>({});\n const { t } = useTranslation();\n const setError = (name, label, error) => {\n if (errors[name] !== error && errors[name]?.message !== error?.message) {\n if (!error?.message) {\n const updatedErrors = { ...errors };\n delete updatedErrors[name];\n setErrors(updatedErrors);\n } else {\n setErrors({\n ...errors,\n [name]: {\n ...error,\n label: label.primary,\n },\n });\n }\n }\n };\n\n useEffect(() => {\n setErrors({});\n }, [screenSize]);\n return (\n <ErrorGroupContext.Provider value={{ setError }}>\n {Object.keys(errors).length !== 0 && (\n <ErrorSummary variant=\"error-group\">\n <Heading size=\"sm\">\n \u03A4\u03B1 \u03C0\u03B1\u03C1\u03B1\u03BA\u03AC\u03C4\u03C9 \u03C0\u03B5\u03B4\u03AF\u03B1 \u03C4\u03B7\u03C2 \u03C6\u03CC\u03C1\u03BC\u03B1\u03C2 \u03B5\u03B9\u03BD\u03B1\u03B9 \u03BB\u03AC\u03B8\u03BF\u03C2.{' '}\n </Heading>\n <List listStyle=\"bullet\">\n {(fieldOrder || Object.keys(errors).reverse())\n .filter((fieldName) => errors[fieldName])\n .map((fieldName, index) => {\n return (\n <ListItem key={index} id={`${fieldName}-error`}>\n <Base as=\"b\">{t(errors[fieldName]?.label)}:</Base>{' '}\n <Link href={`#${fieldName}`}>\n {t(errors[fieldName]?.message)}\n </Link>\n </ListItem>\n );\n })}\n </List>\n </ErrorSummary>\n )}\n {children}\n </ErrorGroupContext.Provider>\n );\n};\n\nexport default ErrorGroup;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0D;AAG1D,kBAA+B;AAC/B,0BAA6B;AAC7B,kBAA+B;AAC/B,kBAAqB;AACrB,qBAAwB;AACxB,kBAAqB;AASd,MAAM,wBAAoB;AAAA,EAC/B;AACF;AAQO,MAAM,aAAwC,CAAC;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,CAAC,QAAQ,SAAS,QAAI,uBAAsB,CAAC,CAAC;AACpD,QAAM,EAAE,EAAE,QAAI,4BAAe;AAC7B,QAAM,WAAW,CAAC,MAAM,OAAO,UAAU;AACvC,QAAI,OAAO,IAAI,MAAM,SAAS,OAAO,IAAI,GAAG,YAAY,OAAO,SAAS;AACtE,UAAI,CAAC,OAAO,SAAS;AACnB,cAAM,gBAAgB,EAAE,GAAG,OAAO;AAClC,eAAO,cAAc,IAAI;AACzB,kBAAU,aAAa;AAAA,MACzB,OAAO;AACL,kBAAU;AAAA,UACR,GAAG;AAAA,UACH,CAAC,IAAI,GAAG;AAAA,YACN,GAAG;AAAA,YACH,OAAO,MAAM;AAAA,UACf;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEA,8BAAU,MAAM;AACd,cAAU,CAAC,CAAC;AAAA,EACd,GAAG,CAAC,UAAU,CAAC;AACf,SACE,6BAAAA,QAAA,cAAC,kBAAkB,UAAlB,EAA2B,OAAO,EAAE,SAAS,KAC3C,OAAO,KAAK,MAAM,EAAE,WAAW,KAC9B,6BAAAA,QAAA,cAAC,oCAAa,SAAQ,iBACpB,6BAAAA,QAAA,cAAC,0BAAQ,MAAK,QAAK,uNACyB,GAC5C,GACA,6BAAAA,QAAA,cAAC,oBAAK,WAAU,aACZ,cAAc,OAAO,KAAK,MAAM,EAAE,QAAQ,GACzC,OAAO,CAAC,cAAc,OAAO,SAAS,CAAC,EACvC,IAAI,CAAC,WAAW,UAAU;AACzB,WACE,6BAAAA,QAAA,cAAC,wBAAS,KAAK,OAAO,IAAI,GAAG,SAAS,YACpC,6BAAAA,QAAA,cAAC,oBAAK,IAAG,OAAK,EAAE,OAAO,SAAS,GAAG,KAAK,GAAE,GAAC,GAAQ,KACnD,6BAAAA,QAAA,cAAC,oBAAK,MAAM,IAAI,SAAS,MACtB,EAAE,OAAO,SAAS,GAAG,OAAO,CAC/B,CACF;AAAA,EAEJ,CAAC,CACL,CACF,GAED,QACH;AAEJ;AAEA,IAAO,qBAAQ;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -32,26 +32,32 @@ __export(FieldBase_exports, {
|
|
|
32
32
|
module.exports = __toCommonJS(FieldBase_exports);
|
|
33
33
|
var import_react = __toESM(require("react"));
|
|
34
34
|
var import_react_hook_form = require("react-hook-form");
|
|
35
|
+
var import_ErrorGroup = require("@digigov/form/Field/ErrorGroup");
|
|
35
36
|
var import_FieldBaseContainer = __toESM(require("@digigov/form/Field/FieldBaseContainer"));
|
|
36
|
-
const FieldBase = (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
37
|
+
const FieldBase = ({
|
|
38
|
+
required,
|
|
39
|
+
name,
|
|
40
|
+
component: Component,
|
|
41
|
+
wrapper,
|
|
42
|
+
control,
|
|
43
|
+
type,
|
|
44
|
+
controlled = false,
|
|
45
|
+
enabled = true,
|
|
46
|
+
editable,
|
|
47
|
+
defaultValue,
|
|
48
|
+
label,
|
|
49
|
+
extra = {},
|
|
50
|
+
layout,
|
|
51
|
+
error,
|
|
52
|
+
register,
|
|
53
|
+
...componentProps
|
|
54
|
+
}) => {
|
|
55
|
+
const errorGroupContext = (0, import_react.useContext)(import_ErrorGroup.ErrorGroupContext);
|
|
56
|
+
(0, import_react.useEffect)(() => {
|
|
57
|
+
if (errorGroupContext) {
|
|
58
|
+
errorGroupContext.setError(name, label, error);
|
|
59
|
+
}
|
|
60
|
+
}, [error, name, errorGroupContext?.setError]);
|
|
55
61
|
if (!enabled) {
|
|
56
62
|
return null;
|
|
57
63
|
}
|
|
@@ -61,9 +67,12 @@ const FieldBase = (props) => {
|
|
|
61
67
|
{
|
|
62
68
|
label,
|
|
63
69
|
layout,
|
|
64
|
-
|
|
70
|
+
register,
|
|
71
|
+
error: errorGroupContext ? void 0 : error,
|
|
72
|
+
hasError: !!error,
|
|
65
73
|
wrapper,
|
|
66
|
-
name
|
|
74
|
+
name,
|
|
75
|
+
controlled
|
|
67
76
|
},
|
|
68
77
|
/* @__PURE__ */ import_react.default.createElement(
|
|
69
78
|
import_react_hook_form.Controller,
|
|
@@ -76,8 +85,7 @@ const FieldBase = (props) => {
|
|
|
76
85
|
{
|
|
77
86
|
...field,
|
|
78
87
|
control,
|
|
79
|
-
|
|
80
|
-
defaultValue,
|
|
88
|
+
defaultValue: defaultValue ?? field.value,
|
|
81
89
|
extra,
|
|
82
90
|
error: !!error,
|
|
83
91
|
type,
|
|
@@ -98,7 +106,9 @@ const FieldBase = (props) => {
|
|
|
98
106
|
{
|
|
99
107
|
label,
|
|
100
108
|
layout,
|
|
101
|
-
|
|
109
|
+
register,
|
|
110
|
+
error: errorGroupContext ? void 0 : error,
|
|
111
|
+
hasError: !!error,
|
|
102
112
|
wrapper,
|
|
103
113
|
name
|
|
104
114
|
},
|
|
@@ -114,6 +124,7 @@ const FieldBase = (props) => {
|
|
|
114
124
|
"aria-describedby": error && `${name}-error`,
|
|
115
125
|
required,
|
|
116
126
|
disabled: editable === false,
|
|
127
|
+
defaultValue,
|
|
117
128
|
...componentProps
|
|
118
129
|
}
|
|
119
130
|
) : /* @__PURE__ */ import_react.default.createElement(
|
|
@@ -125,11 +136,11 @@ const FieldBase = (props) => {
|
|
|
125
136
|
error: !!error,
|
|
126
137
|
extra,
|
|
127
138
|
type,
|
|
139
|
+
defaultValue,
|
|
128
140
|
"aria-required": !!required,
|
|
129
141
|
"aria-describedby": error && `${name}-error`,
|
|
130
142
|
required,
|
|
131
143
|
disabled: editable === false,
|
|
132
|
-
ref: void 0,
|
|
133
144
|
...componentProps
|
|
134
145
|
}
|
|
135
146
|
)
|