@digigov/form 2.0.0-555d1027 → 2.0.0-5e7a6790
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Field/ErrorGroup.d.ts +3 -3
- package/Field/ErrorGroup.js.map +1 -1
- package/Field/FieldBase/index.js +0 -1
- package/Field/FieldBase.d.ts +1 -1
- package/Field/FieldBase.js.map +2 -2
- package/Field/FieldBaseContainer/index.js +36 -34
- package/Field/FieldBaseContainer.d.ts +2 -2
- package/Field/FieldBaseContainer.js.map +2 -2
- package/Field/FieldConditional.d.ts +1 -1
- package/Field/FieldConditional.js.map +1 -1
- package/Field/index.d.ts +1 -1
- package/Field/index.js +15 -25
- package/Field/index.js.map +2 -2
- package/Field/types.d.ts +11 -10
- 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 +4 -2
- package/Field/utils/useField.d.ts +1 -1
- package/Field/utils/useField.js.map +2 -2
- package/FieldArray/BaseFieldArray/index.js +76 -0
- package/{inputs/inputsScenarios → FieldArray/BaseFieldArray}/package.json +1 -1
- package/FieldArray/BaseFieldArray.d.ts +5 -0
- package/FieldArray/BaseFieldArray.js.map +7 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayDisplay.stories.d.ts +10 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay/index.js +97 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay/package.json +6 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.d.ts +22 -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__/Default.d.ts +2 -0
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnly.d.ts +2 -0
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/Sortable.d.ts +2 -0
- package/FieldArray/FormDialog/ArrayDisplay/index.d.ts +14 -0
- package/FieldArray/FormDialog/ArrayDisplay/index.js +51 -0
- package/FieldArray/FormDialog/ArrayDisplay/index.js.map +7 -0
- package/FieldArray/FormDialog/ArrayDisplay/package.json +6 -0
- package/FieldArray/FormDialog/ArrayEditModal/index.js +149 -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 +139 -348
- package/FieldArray/FormDialog/index.js.map +7 -0
- package/FieldArray/index.d.ts +4 -2
- package/FieldArray/index.js +28 -54
- package/FieldArray/index.js.map +2 -2
- package/FieldObject/index.d.ts +4 -4
- package/FieldObject/index.js +5 -12
- 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/index.d.ts +1 -1
- package/FormBuilder/index.js +155 -130
- package/FormBuilder/index.js.map +2 -2
- package/FormContext.d.ts +2 -2
- package/FormContext.js.map +2 -2
- package/MultiplicityField/add-objects/index.js +10 -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.map +2 -2
- package/MultiplicityField/types.d.ts +2 -2
- package/Questions/Questions.d.ts +1 -1
- package/Questions/Questions.js.map +1 -1
- 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/getNextStep.d.ts +1 -1
- package/Questions/getNextStep.js.map +1 -1
- package/Questions/types.d.ts +1 -1
- package/cjs/Field/ErrorGroup.js.map +1 -1
- package/cjs/Field/FieldBase/index.js +0 -1
- package/cjs/Field/FieldBase.js.map +2 -2
- package/cjs/Field/FieldBaseContainer/index.js +36 -34
- package/cjs/Field/FieldBaseContainer.js.map +2 -2
- package/cjs/Field/FieldConditional.js.map +1 -1
- package/cjs/Field/index.js +15 -22
- 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 +4 -2
- 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/ArrayItemDisplay/index.js +130 -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 +84 -0
- package/cjs/FieldArray/FormDialog/ArrayDisplay/index.js.map +7 -0
- package/cjs/FieldArray/FormDialog/ArrayEditModal/index.js +177 -0
- package/cjs/FieldArray/FormDialog/ArrayEditModal.js.map +7 -0
- package/cjs/FieldArray/FormDialog/index.js +130 -331
- package/cjs/FieldArray/FormDialog/index.js.map +7 -0
- package/cjs/FieldArray/index.js +27 -53
- package/cjs/FieldArray/index.js.map +3 -3
- package/cjs/FieldObject/index.js +5 -9
- 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 +156 -131
- package/cjs/FormBuilder/index.js.map +3 -3
- package/cjs/FormContext.js.map +2 -2
- package/cjs/MultiplicityField/add-objects/index.js +9 -13
- package/cjs/MultiplicityField/add-objects.js.map +2 -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 -63
- package/cjs/inputs/Checkboxes/index.js.map +2 -2
- package/cjs/inputs/DateInput/index.js +10 -5
- package/cjs/inputs/DateInput/index.js.map +2 -2
- package/cjs/inputs/DateTimeInput/index.js +10 -5
- package/cjs/inputs/DateTimeInput/index.js.map +2 -2
- package/cjs/inputs/FileInput/index.js.map +2 -2
- package/cjs/inputs/ImageInput/index.js.map +1 -1
- package/cjs/inputs/Input/index.js +54 -56
- 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 -31
- 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.map +1 -1
- package/cjs/{Field/utils → inputs/registry}/index.js +4 -4
- package/cjs/inputs/registry.js.map +7 -0
- package/cjs/{lazy/index.js → lazy.js} +10 -9
- package/cjs/lazy.js.map +2 -2
- package/cjs/{registry/index.js → registry.js} +23 -13
- package/cjs/registry.js.map +2 -2
- package/cjs/types.js.map +1 -1
- package/cjs/utils.js.map +2 -2
- package/cjs/validators/index.js.map +2 -2
- package/cjs/validators/types.js.map +1 -1
- package/cjs/validators/utils/date/index.js +6 -1
- package/cjs/validators/utils/date.js.map +2 -2
- package/cjs/validators/utils/datetime/index.js +6 -1
- package/cjs/validators/utils/datetime.js.map +2 -2
- package/cjs/validators/utils/file.js.map +1 -1
- package/cjs/validators/utils/iban.js.map +1 -1
- package/cjs/validators/utils/image.js.map +1 -1
- package/cjs/validators/utils/index.js.map +1 -1
- package/cjs/validators/utils/int.js.map +1 -1
- package/cjs/validators/utils/number.js.map +1 -1
- 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/index.d.ts +3 -3
- package/inputs/AutoCompleteInput/index.js +1 -3
- package/inputs/AutoCompleteInput/index.js.map +2 -2
- package/inputs/Checkboxes/index.d.ts +3 -3
- package/inputs/Checkboxes/index.js +67 -63
- package/inputs/Checkboxes/index.js.map +2 -2
- package/inputs/DateInput/index.d.ts +2 -5
- package/inputs/DateInput/index.js +10 -5
- package/inputs/DateInput/index.js.map +2 -2
- package/inputs/DateTimeInput/index.d.ts +2 -5
- package/inputs/DateTimeInput/index.js +10 -5
- package/inputs/DateTimeInput/index.js.map +2 -2
- package/inputs/FileInput/index.d.ts +4 -4
- package/inputs/FileInput/index.js +1 -4
- package/inputs/FileInput/index.js.map +2 -2
- package/inputs/ImageInput/index.d.ts +2 -2
- package/inputs/ImageInput/index.js.map +1 -1
- package/inputs/Input/index.d.ts +2 -2
- package/inputs/Input/index.js +54 -56
- package/inputs/Input/index.js.map +2 -2
- package/inputs/Label/index.d.ts +1 -1
- package/inputs/Label/index.js.map +1 -1
- package/inputs/OtpInput/index.d.ts +1 -5
- package/inputs/OtpInput/index.js +36 -31
- package/inputs/OtpInput/index.js.map +2 -2
- 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/index.d.ts +2 -2
- package/inputs/Select/index.js.map +1 -1
- package/{Field/utils → inputs/registry}/index.js +1 -1
- 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 +10 -9
- package/package.json +4 -4
- package/registry/index.js +23 -13
- package/src/Field/ErrorGroup.tsx +3 -3
- package/src/Field/FieldBase.tsx +1 -2
- package/src/Field/FieldBaseContainer.tsx +68 -58
- package/src/Field/FieldConditional.tsx +1 -1
- package/src/Field/index.tsx +15 -33
- package/src/Field/types.tsx +11 -12
- package/src/Field/utils/evaluateFieldWithConditions.ts +5 -2
- package/src/Field/utils/resolveField.ts +58 -0
- package/src/Field/utils/useField.ts +3 -1
- package/src/FieldArray/BaseFieldArray.tsx +97 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/ArrayDisplay.stories.js +11 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.tsx +165 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.tsx +15 -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__/Sortable.tsx +93 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/index.tsx +75 -0
- package/src/FieldArray/FormDialog/ArrayEditModal.tsx +233 -0
- package/src/FieldArray/FormDialog/index.tsx +247 -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-required.spec.tsx +131 -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.tsx +34 -61
- package/src/FieldObject/index.tsx +9 -17
- package/src/Fieldset/FieldsetWithContext.tsx +1 -1
- package/src/Fieldset/index.tsx +1 -1
- package/src/Fieldset/types.tsx +2 -2
- package/src/FormBuilder/index.tsx +188 -142
- package/src/FormBuilder/scenarios.test.tsx +759 -1
- package/src/FormContext.tsx +3 -2
- package/src/MultiplicityField/add-objects.tsx +12 -21
- package/src/MultiplicityField/index.tsx +3 -2
- package/src/MultiplicityField/types.ts +5 -2
- 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/getNextStep.tsx +1 -1
- package/src/Questions/types.tsx +1 -1
- 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/index.tsx +4 -6
- package/src/inputs/Checkboxes/index.tsx +95 -87
- package/src/inputs/DateInput/index.tsx +19 -6
- package/src/inputs/DateTimeInput/index.tsx +19 -6
- package/src/inputs/FileInput/index.tsx +9 -7
- package/src/inputs/ImageInput/index.tsx +2 -2
- package/src/inputs/Input/index.tsx +72 -71
- package/src/inputs/Label/index.tsx +1 -1
- package/src/inputs/OtpInput/index.tsx +43 -34
- package/src/inputs/Radio/index.tsx +29 -21
- package/src/inputs/Select/index.tsx +2 -2
- package/src/{Field/utils/index.ts → inputs/registry.ts} +3 -1
- package/src/lazy.js +10 -9
- package/src/registry.js +23 -13
- package/src/types.tsx +12 -5
- package/src/utils.ts +3 -2
- package/src/validators/index.ts +10 -9
- package/src/validators/types.ts +1 -1
- package/src/validators/utils/date.ts +8 -3
- package/src/validators/utils/datetime.ts +8 -3
- package/src/validators/utils/file.ts +2 -2
- package/src/validators/utils/iban.ts +2 -2
- package/src/validators/utils/image.ts +2 -2
- package/src/validators/utils/index.ts +2 -2
- package/src/validators/utils/int.ts +1 -1
- package/src/validators/utils/number.ts +1 -1
- 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 +8 -4
- package/types.js.map +1 -1
- package/utils.d.ts +1 -1
- package/utils.js.map +2 -2
- package/validators/index.d.ts +5 -5
- package/validators/index.js.map +2 -2
- package/validators/types.d.ts +1 -1
- package/validators/utils/date/index.js +6 -1
- package/validators/utils/date.d.ts +2 -2
- package/validators/utils/date.js.map +2 -2
- package/validators/utils/datetime/index.js +6 -1
- package/validators/utils/datetime.d.ts +2 -2
- package/validators/utils/datetime.js.map +2 -2
- package/validators/utils/file.d.ts +2 -2
- package/validators/utils/file.js.map +1 -1
- 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 +2 -2
- package/validators/utils/index.js.map +1 -1
- package/validators/utils/int.d.ts +1 -1
- package/validators/utils/int.js.map +1 -1
- package/validators/utils/number.d.ts +1 -1
- package/validators/utils/number.js.map +1 -1
- 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 -67
- package/FieldArray/FormDialog.js.map +0 -7
- package/FormBuilder/index.test.d.ts +0 -1
- package/FormBuilder/interaction.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/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/index.test.d.ts +0 -1
- package/inputs/Input/index.test.d.ts +0 -1
- 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 -568
- 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
package/FieldArray/index.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { useFieldArray } from "react-hook-form";
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
3
2
|
import { FieldBaseContainer } from "@digigov/form/Field/FieldBaseContainer";
|
|
3
|
+
import BaseFieldArray from "@digigov/form/FieldArray/BaseFieldArray";
|
|
4
4
|
import { FormDialog } from "@digigov/form/FieldArray/FormDialog";
|
|
5
|
-
import { FieldObject } from "@digigov/form/FieldObject";
|
|
6
|
-
import { FieldsetLabel, Fieldset } from "@digigov/form/Fieldset";
|
|
7
|
-
import { Card } from "@digigov/ui/content/Card";
|
|
8
|
-
import { Button } from "@digigov/ui/form/Button";
|
|
9
5
|
const FieldArray = ({
|
|
10
6
|
name,
|
|
11
7
|
trigger,
|
|
@@ -21,13 +17,20 @@ const FieldArray = ({
|
|
|
21
17
|
resetField,
|
|
22
18
|
label,
|
|
23
19
|
Field,
|
|
20
|
+
registerFieldFocus,
|
|
24
21
|
...customField
|
|
25
22
|
}) => {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
const buttonRef = useRef(null);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
let unregister = () => {
|
|
26
|
+
};
|
|
27
|
+
if (buttonRef.current) {
|
|
28
|
+
unregister = registerFieldFocus(name, buttonRef.current);
|
|
29
|
+
}
|
|
30
|
+
return () => {
|
|
31
|
+
unregister(name);
|
|
32
|
+
};
|
|
33
|
+
}, [name, registerFieldFocus]);
|
|
31
34
|
return /* @__PURE__ */ React.createElement(
|
|
32
35
|
FieldBaseContainer,
|
|
33
36
|
{
|
|
@@ -44,6 +47,7 @@ const FieldArray = ({
|
|
|
44
47
|
customField.extra?.variant === "dialog" ? /* @__PURE__ */ React.createElement(
|
|
45
48
|
FormDialog,
|
|
46
49
|
{
|
|
50
|
+
ref: buttonRef,
|
|
47
51
|
name,
|
|
48
52
|
trigger,
|
|
49
53
|
register,
|
|
@@ -61,50 +65,20 @@ const FieldArray = ({
|
|
|
61
65
|
sortable: customField.extra.sortable,
|
|
62
66
|
...customField
|
|
63
67
|
}
|
|
64
|
-
) : /* @__PURE__ */ React.createElement(
|
|
65
|
-
|
|
68
|
+
) : /* @__PURE__ */ React.createElement(
|
|
69
|
+
BaseFieldArray,
|
|
66
70
|
{
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
...customField.extra?.of,
|
|
79
|
-
Field
|
|
80
|
-
}
|
|
81
|
-
), /* @__PURE__ */ React.createElement(
|
|
82
|
-
Button,
|
|
83
|
-
{
|
|
84
|
-
name: `${name}-object-remove`,
|
|
85
|
-
variant: customField.extra?.label.object?.deleteButtonVariant,
|
|
86
|
-
type: "button",
|
|
87
|
-
color: "warning",
|
|
88
|
-
onClick: () => remove(index),
|
|
89
|
-
disabled: !customField?.editable
|
|
90
|
-
},
|
|
91
|
-
customField.extra?.label.object?.delete
|
|
92
|
-
))
|
|
93
|
-
)), customField.editable && /* @__PURE__ */ React.createElement(
|
|
94
|
-
Button,
|
|
95
|
-
{
|
|
96
|
-
type: "button",
|
|
97
|
-
name: `${name}-add-object`,
|
|
98
|
-
color: "secondary",
|
|
99
|
-
variant: customField.extra?.label.object?.addButtonVariant,
|
|
100
|
-
onClick: (ev) => {
|
|
101
|
-
ev.preventDefault();
|
|
102
|
-
append({});
|
|
103
|
-
},
|
|
104
|
-
disabled: !customField?.editable
|
|
105
|
-
},
|
|
106
|
-
customField.extra?.label.object?.add
|
|
107
|
-
))
|
|
71
|
+
ref: buttonRef,
|
|
72
|
+
name,
|
|
73
|
+
register,
|
|
74
|
+
control,
|
|
75
|
+
formState,
|
|
76
|
+
error,
|
|
77
|
+
getValues,
|
|
78
|
+
Field,
|
|
79
|
+
...customField
|
|
80
|
+
}
|
|
81
|
+
)
|
|
108
82
|
);
|
|
109
83
|
};
|
|
110
84
|
var FieldArray_default = FieldArray;
|
package/FieldArray/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/FieldArray/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport { ErrorOption,
|
|
5
|
-
"mappings": "AAAA,OAAO,WAAW
|
|
4
|
+
"sourcesContent": ["import React, { useEffect, useRef } from 'react';\nimport type { ErrorOption, UseFormReturn } from 'react-hook-form';\nimport { FieldBaseContainer } from '@digigov/form/Field/FieldBaseContainer';\nimport type { FieldProps } from '@digigov/form/Field/types';\nimport BaseFieldArray from '@digigov/form/FieldArray/BaseFieldArray';\nimport { FormDialog } from '@digigov/form/FieldArray/FormDialog';\nimport type { registerFieldFocus } from '@digigov/form/types';\n\nexport interface FieldArrayProps extends FieldProps {\n control: UseFormReturn['control'];\n trigger: UseFormReturn['trigger'];\n register: UseFormReturn['register'];\n clearErrors: UseFormReturn['clearErrors'];\n formState: UseFormReturn['formState'];\n error?: ErrorOption;\n getValues: UseFormReturn['getValues'];\n setValue: UseFormReturn['setValue'];\n reset: UseFormReturn['reset'];\n resetField?: UseFormReturn['resetField'];\n Field: React.FC<FieldProps>;\n registerFieldFocus: registerFieldFocus;\n}\nexport const FieldArray: React.FC<FieldArrayProps> = ({\n name,\n trigger,\n register,\n clearErrors,\n control,\n formState,\n error,\n getValues,\n setValue,\n layout,\n reset,\n resetField,\n label,\n Field,\n registerFieldFocus,\n ...customField\n}) => {\n /** The ref of the add-button */\n const buttonRef = useRef<HTMLButtonElement | null>(null);\n\n // Register the button to be focusable\n useEffect(() => {\n let unregister: (name: string) => void = () => {};\n if (buttonRef.current) {\n unregister = registerFieldFocus(name, buttonRef.current);\n }\n\n return () => {\n unregister(name);\n };\n }, [name, registerFieldFocus]);\n\n return (\n <FieldBaseContainer\n label={label}\n layout={layout}\n register={register}\n error={error?.message && error ? error : undefined}\n hasError={formState.isSubmitted && !formState.isSubmitting && !!error}\n wrapper=\"fieldset\"\n name={name}\n labelSize={customField.extra?.labelSize}\n controlled={true}\n >\n {customField.extra?.variant === 'dialog' ? (\n <FormDialog\n ref={buttonRef}\n name={name}\n trigger={trigger}\n register={register}\n clearErrors={clearErrors}\n control={control}\n formState={formState}\n error={error}\n getValues={getValues}\n setValue={setValue}\n layout={layout}\n label={label}\n Field={Field}\n reset={reset}\n resetField={resetField}\n sortable={customField.extra.sortable}\n {...customField}\n />\n ) : (\n <BaseFieldArray\n ref={buttonRef}\n name={name}\n register={register}\n control={control}\n formState={formState}\n error={error}\n getValues={getValues}\n Field={Field}\n {...customField}\n />\n )}\n </FieldBaseContainer>\n );\n};\n\nexport default FieldArray;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS,WAAW,cAAc;AAEzC,SAAS,0BAA0B;AAEnC,OAAO,oBAAoB;AAC3B,SAAS,kBAAkB;AAiBpB,MAAM,aAAwC,CAAC;AAAA,EACpD;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;AAAA,EACA,GAAG;AACL,MAAM;AAEJ,QAAM,YAAY,OAAiC,IAAI;AAGvD,YAAU,MAAM;AACd,QAAI,aAAqC,MAAM;AAAA,IAAC;AAChD,QAAI,UAAU,SAAS;AACrB,mBAAa,mBAAmB,MAAM,UAAU,OAAO;AAAA,IACzD;AAEA,WAAO,MAAM;AACX,iBAAW,IAAI;AAAA,IACjB;AAAA,EACF,GAAG,CAAC,MAAM,kBAAkB,CAAC;AAE7B,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO,OAAO,WAAW,QAAQ,QAAQ;AAAA,MACzC,UAAU,UAAU,eAAe,CAAC,UAAU,gBAAgB,CAAC,CAAC;AAAA,MAChE,SAAQ;AAAA,MACR;AAAA,MACA,WAAW,YAAY,OAAO;AAAA,MAC9B,YAAY;AAAA;AAAA,IAEX,YAAY,OAAO,YAAY,WAC9B;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,UAAU,YAAY,MAAM;AAAA,QAC3B,GAAG;AAAA;AAAA,IACN,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACC,GAAG;AAAA;AAAA,IACN;AAAA,EAEJ;AAEJ;AAEA,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/FieldObject/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ErrorOption, UseFormReturn } from 'react-hook-form';
|
|
3
|
-
import { FieldProps } from '@digigov/form/Field/types';
|
|
4
|
-
import { FieldSpec } from '@digigov/form/types';
|
|
2
|
+
import type { ErrorOption, UseFormReturn } from 'react-hook-form';
|
|
3
|
+
import type { FieldProps } from '@digigov/form/Field/types';
|
|
4
|
+
import type { FieldSpec } from '@digigov/form/types';
|
|
5
5
|
export interface FieldObjectProps extends Omit<FieldProps, 'key'> {
|
|
6
6
|
control: UseFormReturn['control'];
|
|
7
7
|
register: UseFormReturn['register'];
|
|
@@ -9,7 +9,7 @@ export interface FieldObjectProps extends Omit<FieldProps, 'key'> {
|
|
|
9
9
|
resetField: UseFormReturn['resetField'];
|
|
10
10
|
formState: UseFormReturn['formState'];
|
|
11
11
|
error?: ErrorOption;
|
|
12
|
-
defaultValue?:
|
|
12
|
+
defaultValue?: any;
|
|
13
13
|
Field: React.FC<FieldProps>;
|
|
14
14
|
}
|
|
15
15
|
export declare const FieldObject: React.FC<FieldObjectProps>;
|
package/FieldObject/index.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import React, { useMemo } from "react";
|
|
2
2
|
import { FieldBase } from "@digigov/form/Field/FieldBase";
|
|
3
|
-
import {
|
|
4
|
-
FIELD_COMPONENTS,
|
|
5
|
-
ALTERNATIVE_COMPONENTS
|
|
6
|
-
} from "@digigov/form/Field/utils";
|
|
7
|
-
import { calculateField } from "@digigov/form/Field/utils/calculateField";
|
|
3
|
+
import { resolveField } from "@digigov/form/Field/utils/resolveField";
|
|
8
4
|
import { Fieldset, FieldsetCaption } from "@digigov/form/Fieldset";
|
|
9
5
|
import { FieldsetLegend } from "@digigov/ui/form/FieldContainer";
|
|
10
6
|
import { useTranslation } from "@digigov/ui/i18n";
|
|
@@ -25,8 +21,8 @@ const FieldObject = ({
|
|
|
25
21
|
return /* @__PURE__ */ React.createElement(Fieldset, null, label?.primary && /* @__PURE__ */ React.createElement(FieldsetLegend, { size: "sm", marginBottom: 3 }, t(label.primary)), label?.secondary && /* @__PURE__ */ React.createElement(FieldsetCaption, { marginBottom: 3 }, t(label.secondary)), extra?.fields.map((field) => /* @__PURE__ */ React.createElement(
|
|
26
22
|
FieldObjectItem,
|
|
27
23
|
{
|
|
28
|
-
key: `${name}${field.key ?
|
|
29
|
-
name: `${name}${field.key ?
|
|
24
|
+
key: `${name ? name + "." : ""}${field.key ? `${field.key}` : ""}`,
|
|
25
|
+
name: `${name ? name + "." : ""}${field.key ? `${field.key}` : ""}`,
|
|
30
26
|
control,
|
|
31
27
|
register,
|
|
32
28
|
reset,
|
|
@@ -52,10 +48,7 @@ const FieldObjectItem = ({
|
|
|
52
48
|
defaultValue,
|
|
53
49
|
Field
|
|
54
50
|
}) => {
|
|
55
|
-
const
|
|
56
|
-
() => calculateField(children, field, FIELD_COMPONENTS, ALTERNATIVE_COMPONENTS),
|
|
57
|
-
[field]
|
|
58
|
-
);
|
|
51
|
+
const resolvedField = useMemo(() => resolveField(children, field), [field]);
|
|
59
52
|
if (Field) {
|
|
60
53
|
if (!field.type) {
|
|
61
54
|
field.type = "string";
|
|
@@ -66,7 +59,7 @@ const FieldObjectItem = ({
|
|
|
66
59
|
return /* @__PURE__ */ React.createElement(
|
|
67
60
|
FieldBase,
|
|
68
61
|
{
|
|
69
|
-
...
|
|
62
|
+
...resolvedField,
|
|
70
63
|
name,
|
|
71
64
|
Field,
|
|
72
65
|
control,
|
package/FieldObject/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/FieldObject/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useMemo } from 'react';\nimport { ErrorOption, UseFormReturn } from 'react-hook-form';\nimport { FieldBase } from '@digigov/form/Field/FieldBase';\nimport { FieldProps
|
|
5
|
-
"mappings": "AAAA,OAAO,SAAS,eAAe;AAE/B,SAAS,iBAAiB;AAE1B
|
|
4
|
+
"sourcesContent": ["import React, { useMemo } from 'react';\nimport type { ErrorOption, UseFormReturn } from 'react-hook-form';\nimport { FieldBase } from '@digigov/form/Field/FieldBase';\nimport type { FieldProps } from '@digigov/form/Field/types';\nimport { resolveField } from '@digigov/form/Field/utils/resolveField';\nimport { Fieldset, FieldsetCaption } from '@digigov/form/Fieldset';\nimport type { FieldSpec } from '@digigov/form/types';\nimport { FieldsetLegend } from '@digigov/ui/form/FieldContainer';\nimport { useTranslation } from '@digigov/ui/i18n';\n\nexport interface FieldObjectProps extends Omit<FieldProps, 'key'> {\n control: UseFormReturn['control'];\n register: UseFormReturn['register'];\n reset: UseFormReturn['reset'];\n resetField: UseFormReturn['resetField'];\n formState: UseFormReturn['formState'];\n error?: ErrorOption;\n defaultValue?: any;\n Field: React.FC<FieldProps>;\n}\n\nexport const FieldObject: React.FC<FieldObjectProps> = ({\n name,\n label,\n extra,\n control,\n register,\n reset,\n resetField,\n formState,\n error,\n defaultValue,\n Field,\n}) => {\n const { t } = useTranslation();\n\n return (\n <Fieldset>\n {label?.primary && (\n <FieldsetLegend size=\"sm\" marginBottom={3}>\n {t(label.primary)}\n </FieldsetLegend>\n )}\n {label?.secondary && (\n <FieldsetCaption marginBottom={3}>{t(label.secondary)}</FieldsetCaption>\n )}\n {extra?.fields.map((field) => (\n <FieldObjectItem\n key={`${name ? name + '.' : ''}${field.key ? `${field.key}` : ''}`}\n name={`${name ? name + '.' : ''}${field.key ? `${field.key}` : ''}`}\n control={control}\n register={register}\n reset={reset}\n resetField={resetField}\n field={field}\n error={error && error[field.key]}\n formState={formState}\n defaultValue={defaultValue?.[field.key] || undefined}\n Field={Field}\n />\n ))}\n </Fieldset>\n );\n};\n\nexport interface FieldObjectItemProps {\n key: string;\n name: string;\n field: FieldSpec;\n control: UseFormReturn['control'];\n register: UseFormReturn['register'];\n reset: UseFormReturn['reset'];\n resetField: UseFormReturn['resetField'];\n formState: UseFormReturn['formState'];\n error?: ErrorOption;\n children?: React.ReactNode;\n defaultValue?: undefined;\n Field: React.FC<FieldProps>;\n}\n\nconst FieldObjectItem: React.FC<FieldObjectItemProps> = ({\n name,\n children,\n field,\n error,\n control,\n formState,\n reset,\n resetField,\n register,\n defaultValue,\n Field,\n}) => {\n const resolvedField = useMemo(() => resolveField(children, field), [field]);\n if (Field) {\n if (!field.type) {\n field.type = 'string';\n }\n return <Field {...field} name={name} />;\n } else {\n const customError = error ? error : formState?.errors[name];\n return (\n <FieldBase\n {...resolvedField}\n name={name}\n Field={Field}\n control={control}\n reset={reset}\n resetField={resetField}\n register={register}\n error={customError}\n defaultValue={defaultValue}\n />\n );\n }\n};\n\nexport default FieldObject;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS,eAAe;AAE/B,SAAS,iBAAiB;AAE1B,SAAS,oBAAoB;AAC7B,SAAS,UAAU,uBAAuB;AAE1C,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAaxB,MAAM,cAA0C,CAAC;AAAA,EACtD;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,EAAE,IAAI,eAAe;AAE7B,SACE,oCAAC,gBACE,OAAO,WACN,oCAAC,kBAAe,MAAK,MAAK,cAAc,KACrC,EAAE,MAAM,OAAO,CAClB,GAED,OAAO,aACN,oCAAC,mBAAgB,cAAc,KAAI,EAAE,MAAM,SAAS,CAAE,GAEvD,OAAO,OAAO,IAAI,CAAC,UAClB;AAAA,IAAC;AAAA;AAAA,MACC,KAAK,GAAG,OAAO,OAAO,MAAM,EAAE,GAAG,MAAM,MAAM,GAAG,MAAM,GAAG,KAAK,EAAE;AAAA,MAChE,MAAM,GAAG,OAAO,OAAO,MAAM,EAAE,GAAG,MAAM,MAAM,GAAG,MAAM,GAAG,KAAK,EAAE;AAAA,MACjE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO,SAAS,MAAM,MAAM,GAAG;AAAA,MAC/B;AAAA,MACA,cAAc,eAAe,MAAM,GAAG,KAAK;AAAA,MAC3C;AAAA;AAAA,EACF,CACD,CACH;AAEJ;AAiBA,MAAM,kBAAkD,CAAC;AAAA,EACvD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,gBAAgB,QAAQ,MAAM,aAAa,UAAU,KAAK,GAAG,CAAC,KAAK,CAAC;AAC1E,MAAI,OAAO;AACT,QAAI,CAAC,MAAM,MAAM;AACf,YAAM,OAAO;AAAA,IACf;AACA,WAAO,oCAAC,SAAO,GAAG,OAAO,MAAY;AAAA,EACvC,OAAO;AACL,UAAM,cAAc,QAAQ,QAAQ,WAAW,OAAO,IAAI;AAC1D,WACE;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAO;AAAA,QACP;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AAEA,IAAO,sBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Fieldset/FieldsetWithContext.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useContext, useMemo } from 'react';\nimport Field from '@digigov/form/Field';\nimport {\n Fieldset,\n FieldsetLabel,\n FieldsetCaption,\n FieldsetBody,\n} from '@digigov/form/Fieldset/';\nimport { FormContext } from '@digigov/form/FormContext';\nimport { FieldsetSpec } from '@digigov/form/types';\nimport { useTranslation } from '@digigov/ui/i18n';\n\nexport const FieldsetWithContext: React.FC<{ name: string }> = ({ name }) => {\n const { label, body, fields } = useFieldset(name);\n const { t } = useTranslation();\n return useMemo(\n () => (\n <Fieldset>\n {label?.primary && <FieldsetLabel>{t(label.primary)}</FieldsetLabel>}\n {label?.secondary && (\n <FieldsetCaption>{t(label.secondary)}</FieldsetCaption>\n )}\n {body && <FieldsetBody>{body}</FieldsetBody>}\n {fields.map((field) => (\n <Field key={field} name={field} />\n ))}\n </Fieldset>\n ),\n [label?.primary, label?.secondary, body, fields]\n );\n};\n\nconst useFieldset = (name: string): FieldsetSpec => {\n const { fieldsetsMap } = useContext(FormContext);\n if (fieldsetsMap && fieldsetsMap[name]) {\n return useMemo(() => fieldsetsMap[name], [name]);\n } else {\n if (!fieldsetsMap) throw new Error(`Fieldsets is not defined`);\n throw new Error(`No fieldset with name ${name} found`);\n }\n};\n"],
|
|
4
|
+
"sourcesContent": ["import React, { useContext, useMemo } from 'react';\nimport Field from '@digigov/form/Field';\nimport {\n Fieldset,\n FieldsetLabel,\n FieldsetCaption,\n FieldsetBody,\n} from '@digigov/form/Fieldset/';\nimport { FormContext } from '@digigov/form/FormContext';\nimport type { FieldsetSpec } from '@digigov/form/types';\nimport { useTranslation } from '@digigov/ui/i18n';\n\nexport const FieldsetWithContext: React.FC<{ name: string }> = ({ name }) => {\n const { label, body, fields } = useFieldset(name);\n const { t } = useTranslation();\n return useMemo(\n () => (\n <Fieldset>\n {label?.primary && <FieldsetLabel>{t(label.primary)}</FieldsetLabel>}\n {label?.secondary && (\n <FieldsetCaption>{t(label.secondary)}</FieldsetCaption>\n )}\n {body && <FieldsetBody>{body}</FieldsetBody>}\n {fields.map((field) => (\n <Field key={field} name={field} />\n ))}\n </Fieldset>\n ),\n [label?.primary, label?.secondary, body, fields]\n );\n};\n\nconst useFieldset = (name: string): FieldsetSpec => {\n const { fieldsetsMap } = useContext(FormContext);\n if (fieldsetsMap && fieldsetsMap[name]) {\n return useMemo(() => fieldsetsMap[name], [name]);\n } else {\n if (!fieldsetsMap) throw new Error(`Fieldsets is not defined`);\n throw new Error(`No fieldset with name ${name} found`);\n }\n};\n"],
|
|
5
5
|
"mappings": "AAAA,OAAO,SAAS,YAAY,eAAe;AAC3C,OAAO,WAAW;AAClB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAE5B,SAAS,sBAAsB;AAExB,MAAM,sBAAkD,CAAC,EAAE,KAAK,MAAM;AAC3E,QAAM,EAAE,OAAO,MAAM,OAAO,IAAI,YAAY,IAAI;AAChD,QAAM,EAAE,EAAE,IAAI,eAAe;AAC7B,SAAO;AAAA,IACL,MACE,oCAAC,gBACE,OAAO,WAAW,oCAAC,qBAAe,EAAE,MAAM,OAAO,CAAE,GACnD,OAAO,aACN,oCAAC,uBAAiB,EAAE,MAAM,SAAS,CAAE,GAEtC,QAAQ,oCAAC,oBAAc,IAAK,GAC5B,OAAO,IAAI,CAAC,UACX,oCAAC,SAAM,KAAK,OAAO,MAAM,OAAO,CACjC,CACH;AAAA,IAEF,CAAC,OAAO,SAAS,OAAO,WAAW,MAAM,MAAM;AAAA,EACjD;AACF;AAEA,MAAM,cAAc,CAAC,SAA+B;AAClD,QAAM,EAAE,aAAa,IAAI,WAAW,WAAW;AAC/C,MAAI,gBAAgB,aAAa,IAAI,GAAG;AACtC,WAAO,QAAQ,MAAM,aAAa,IAAI,GAAG,CAAC,IAAI,CAAC;AAAA,EACjD,OAAO;AACL,QAAI,CAAC,aAAc,OAAM,IAAI,MAAM,0BAA0B;AAC7D,UAAM,IAAI,MAAM,yBAAyB,IAAI,QAAQ;AAAA,EACvD;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/Fieldset/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { FieldsetLabelProps, FieldsetCaptionProps, FieldsetBodyProps } from '@digigov/form/Fieldset/types';
|
|
2
|
+
import type { FieldsetLabelProps, FieldsetCaptionProps, FieldsetBodyProps } from '@digigov/form/Fieldset/types';
|
|
3
3
|
import { Fieldset } from '@digigov/react-core/Fieldset';
|
|
4
4
|
export declare const FieldsetLabel: React.FC<FieldsetLabelProps>;
|
|
5
5
|
export declare const FieldsetCaption: React.FC<FieldsetCaptionProps>;
|
package/Fieldset/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Fieldset/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport {\n FieldsetLabelProps,\n FieldsetCaptionProps,\n FieldsetBodyProps,\n} from '@digigov/form/Fieldset/types';\nimport { Fieldset } from '@digigov/react-core/Fieldset';\nimport { FieldsetLegend } from '@digigov/ui/form/FieldContainer';\nimport { Grid } from '@digigov/ui/layouts/Grid';\nimport { Hint } from '@digigov/ui/typography/Hint';\nimport { NormalText } from '@digigov/ui/typography/NormalText';\n\nexport const FieldsetLabel: React.FC<FieldsetLabelProps> = ({\n children,\n ...props\n}) => {\n return (\n <FieldsetLegend heading size=\"xl\" {...props}>\n {children}\n </FieldsetLegend>\n );\n};\n\nexport const FieldsetCaption: React.FC<FieldsetCaptionProps> = ({\n children,\n ...props\n}) => {\n return <Hint {...props}>{children}</Hint>;\n};\n\nexport const FieldsetBody: React.FC<FieldsetBodyProps> = ({ children }) => {\n return (\n <Grid item xs={12}>\n <NormalText>{children}</NormalText>\n </Grid>\n );\n};\n\nexport { Fieldset };\nexport default Fieldset;\n"],
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport type {\n FieldsetLabelProps,\n FieldsetCaptionProps,\n FieldsetBodyProps,\n} from '@digigov/form/Fieldset/types';\nimport { Fieldset } from '@digigov/react-core/Fieldset';\nimport { FieldsetLegend } from '@digigov/ui/form/FieldContainer';\nimport { Grid } from '@digigov/ui/layouts/Grid';\nimport { Hint } from '@digigov/ui/typography/Hint';\nimport { NormalText } from '@digigov/ui/typography/NormalText';\n\nexport const FieldsetLabel: React.FC<FieldsetLabelProps> = ({\n children,\n ...props\n}) => {\n return (\n <FieldsetLegend heading size=\"xl\" {...props}>\n {children}\n </FieldsetLegend>\n );\n};\n\nexport const FieldsetCaption: React.FC<FieldsetCaptionProps> = ({\n children,\n ...props\n}) => {\n return <Hint {...props}>{children}</Hint>;\n};\n\nexport const FieldsetBody: React.FC<FieldsetBodyProps> = ({ children }) => {\n return (\n <Grid item xs={12}>\n <NormalText>{children}</NormalText>\n </Grid>\n );\n};\n\nexport { Fieldset };\nexport default Fieldset;\n"],
|
|
5
5
|
"mappings": "AAAA,OAAO,WAAW;AAMlB,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAC/B,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAEpB,MAAM,gBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA,GAAG;AACL,MAAM;AACJ,SACE,oCAAC,kBAAe,SAAO,MAAC,MAAK,MAAM,GAAG,SACnC,QACH;AAEJ;AAEO,MAAM,kBAAkD,CAAC;AAAA,EAC9D;AAAA,EACA,GAAG;AACL,MAAM;AACJ,SAAO,oCAAC,QAAM,GAAG,SAAQ,QAAS;AACpC;AAEO,MAAM,eAA4C,CAAC,EAAE,SAAS,MAAM;AACzE,SACE,oCAAC,QAAK,MAAI,MAAC,IAAI,MACb,oCAAC,kBAAY,QAAS,CACxB;AAEJ;AAGA,IAAO,mBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/Fieldset/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FieldsetLegendProps } from '@digigov/ui/form/FieldContainer';
|
|
2
|
-
import { HintProps } from '@digigov/ui/typography/Hint';
|
|
1
|
+
import type { FieldsetLegendProps } from '@digigov/ui/form/FieldContainer';
|
|
2
|
+
import type { HintProps } from '@digigov/ui/typography/Hint';
|
|
3
3
|
export interface FieldsetLabelProps extends FieldsetLegendProps {
|
|
4
4
|
}
|
|
5
5
|
export interface FieldsetCaptionProps extends HintProps {
|
package/FormBuilder/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useFormContext } from '@digigov/form/FormContext';
|
|
3
|
-
import { FormBaseProps, FormBuilderProps } from '@digigov/form/types';
|
|
3
|
+
import type { FormBaseProps, FormBuilderProps } from '@digigov/form/types';
|
|
4
4
|
declare const FormBase: React.ForwardRefExoticComponent<FormBaseProps & React.RefAttributes<HTMLFormElement>>;
|
|
5
5
|
declare const useFormValues: () => import("react-hook-form").FieldValues;
|
|
6
6
|
declare const FormBuilder: React.ForwardRefExoticComponent<FormBuilderProps & React.RefAttributes<HTMLFormElement>>;
|
package/FormBuilder/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useRef } from "react";
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
2
2
|
import { useForm } from "react-hook-form";
|
|
3
3
|
import { Field } from "@digigov/form/Field";
|
|
4
4
|
import { ErrorGroup } from "@digigov/form/Field/ErrorGroup";
|
|
5
|
-
import { CONTROLLED_FIELD_COMPONENTS } from "@digigov/form/Field/utils";
|
|
6
5
|
import { FieldsetWithContext } from "@digigov/form/Fieldset/FieldsetWithContext";
|
|
7
6
|
import { FormContext, useFormContext } from "@digigov/form/FormContext";
|
|
7
|
+
import useFieldFocusManager from "@digigov/form/hooks/useFieldFocusManager";
|
|
8
|
+
import { CONTROLLED_FIELD_COMPONENTS } from "@digigov/form/inputs/registry";
|
|
8
9
|
import { yupResolver } from "@digigov/form/utils";
|
|
9
10
|
import { useValidationSchema } from "@digigov/form/validators";
|
|
10
11
|
import { Button } from "@digigov/ui/form/Button";
|
|
@@ -32,7 +33,7 @@ const FormBase = React.forwardRef(function FormBase2({
|
|
|
32
33
|
mode,
|
|
33
34
|
defaultValues: initial,
|
|
34
35
|
reValidateMode,
|
|
35
|
-
shouldFocusError,
|
|
36
|
+
shouldFocusError: false,
|
|
36
37
|
criteriaMode
|
|
37
38
|
});
|
|
38
39
|
const handleSubmit = useCallback(
|
|
@@ -43,14 +44,21 @@ const FormBase = React.forwardRef(function FormBase2({
|
|
|
43
44
|
},
|
|
44
45
|
[onSubmit]
|
|
45
46
|
);
|
|
47
|
+
const { setError } = form;
|
|
46
48
|
useEffect(() => {
|
|
47
49
|
if (errors) {
|
|
48
50
|
for (const fieldName in errors) {
|
|
49
|
-
|
|
51
|
+
setError(fieldName, errors[fieldName]);
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
|
-
}, [errors]);
|
|
53
|
-
const
|
|
54
|
+
}, [errors, setError]);
|
|
55
|
+
const { registerCustomFocusableElement: registerFieldFocus, focusOnError } = useFieldFocusManager({
|
|
56
|
+
control: form.control,
|
|
57
|
+
subscribe: form.subscribe,
|
|
58
|
+
enabled: shouldFocusError,
|
|
59
|
+
setFocus: form.setFocus
|
|
60
|
+
});
|
|
61
|
+
const submit = form.handleSubmit(handleSubmit, focusOnError);
|
|
54
62
|
const ctx = {
|
|
55
63
|
fieldsMap,
|
|
56
64
|
fieldsetsMap,
|
|
@@ -59,6 +67,7 @@ const FormBase = React.forwardRef(function FormBase2({
|
|
|
59
67
|
watch: form.watch,
|
|
60
68
|
resetField: form.resetField,
|
|
61
69
|
registerField,
|
|
70
|
+
registerFieldFocus,
|
|
62
71
|
errors: form.formState.errors,
|
|
63
72
|
formState: form.formState,
|
|
64
73
|
reset: form.reset,
|
|
@@ -75,6 +84,144 @@ const FormBase = React.forwardRef(function FormBase2({
|
|
|
75
84
|
};
|
|
76
85
|
return /* @__PURE__ */ React.createElement(FormContext.Provider, { value: ctx }, /* @__PURE__ */ React.createElement(Form, { grid, onSubmit: submit, ref, ...props }, children));
|
|
77
86
|
});
|
|
87
|
+
const useFormValues = () => {
|
|
88
|
+
const ctx = useFormContext();
|
|
89
|
+
return ctx.getValues();
|
|
90
|
+
};
|
|
91
|
+
const FormBuilder = React.forwardRef(
|
|
92
|
+
function FormBuilder2({
|
|
93
|
+
fields = [],
|
|
94
|
+
fieldsets,
|
|
95
|
+
initial = {},
|
|
96
|
+
onSubmit,
|
|
97
|
+
children,
|
|
98
|
+
reValidateMode = "onSubmit",
|
|
99
|
+
mode = "onSubmit",
|
|
100
|
+
shouldFocusError = true,
|
|
101
|
+
criteriaMode = "all",
|
|
102
|
+
auto = false,
|
|
103
|
+
validatorRegistry,
|
|
104
|
+
componentRegistry,
|
|
105
|
+
grid = false,
|
|
106
|
+
...props
|
|
107
|
+
}, ref) {
|
|
108
|
+
const { screenSize } = useScreenSize();
|
|
109
|
+
const transformedFields = useMemo(
|
|
110
|
+
() => fields.map((field) => {
|
|
111
|
+
const layout = field.layout;
|
|
112
|
+
if (!layout) {
|
|
113
|
+
return {
|
|
114
|
+
...field,
|
|
115
|
+
layout: DEFAULT_LAYOUT
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
...field,
|
|
120
|
+
layout: BREAKPOINTS.reduce(
|
|
121
|
+
(expandedLayout, breakpoint, breakpointIndex) => {
|
|
122
|
+
if (field?.layout?.[breakpoint]) {
|
|
123
|
+
expandedLayout[breakpoint] = field?.layout[breakpoint];
|
|
124
|
+
} else if (expandedLayout[BREAKPOINTS[breakpointIndex - 1]]) {
|
|
125
|
+
expandedLayout[breakpoint] = expandedLayout[BREAKPOINTS[breakpointIndex - 1]];
|
|
126
|
+
} else {
|
|
127
|
+
expandedLayout[breakpoint] = 12;
|
|
128
|
+
}
|
|
129
|
+
return expandedLayout;
|
|
130
|
+
},
|
|
131
|
+
{}
|
|
132
|
+
)
|
|
133
|
+
};
|
|
134
|
+
}),
|
|
135
|
+
[fields]
|
|
136
|
+
);
|
|
137
|
+
const fieldsState = useRef(transformedFields);
|
|
138
|
+
const setFieldsState = useCallback((newFields) => {
|
|
139
|
+
fieldsState.current = newFields;
|
|
140
|
+
}, []);
|
|
141
|
+
const registerField = useCallback(
|
|
142
|
+
(field) => {
|
|
143
|
+
const fieldIndex = fieldsState.current.findIndex(
|
|
144
|
+
(f) => f.key === field.key
|
|
145
|
+
);
|
|
146
|
+
if (fieldIndex > -1) {
|
|
147
|
+
fieldsState.current[fieldIndex] = field;
|
|
148
|
+
} else {
|
|
149
|
+
fieldsState.current.push(field);
|
|
150
|
+
}
|
|
151
|
+
setFieldsState(fieldsState.current);
|
|
152
|
+
},
|
|
153
|
+
[setFieldsState]
|
|
154
|
+
);
|
|
155
|
+
const schema = useValidationSchema(fieldsState, validatorRegistry);
|
|
156
|
+
const resolver = useMemo(() => {
|
|
157
|
+
if (!schema) return;
|
|
158
|
+
return yupResolver(schema);
|
|
159
|
+
}, [schema]);
|
|
160
|
+
const fieldsMap = useMemo(() => {
|
|
161
|
+
if (!schema || !transformedFields) return {};
|
|
162
|
+
return transformedFields.reduce(
|
|
163
|
+
(map, field) => ({ ...map, [field.key]: field }),
|
|
164
|
+
{}
|
|
165
|
+
);
|
|
166
|
+
}, [schema, transformedFields]);
|
|
167
|
+
const fieldsetsMap = useMemo(() => {
|
|
168
|
+
if (!schema || !fieldsets) return;
|
|
169
|
+
return fieldsets.reduce(
|
|
170
|
+
(map, fieldset) => ({ ...map, [fieldset.key]: fieldset }),
|
|
171
|
+
{}
|
|
172
|
+
);
|
|
173
|
+
}, [fieldsets, schema]);
|
|
174
|
+
const fieldChildren = useMemo(() => {
|
|
175
|
+
if (!schema || !auto) return;
|
|
176
|
+
if (fieldsets) {
|
|
177
|
+
return fieldsets.map((fieldset) => /* @__PURE__ */ React.createElement(FieldsetWithContext, { key: fieldset.key, name: fieldset.key }));
|
|
178
|
+
}
|
|
179
|
+
if (transformedFields) {
|
|
180
|
+
const fieldsByLayouts = groupFieldsByLayout(transformedFields);
|
|
181
|
+
const fieldsByLayoutSize = fieldsByLayouts[screenSize];
|
|
182
|
+
return fieldsByLayoutSize.map((item, index) => {
|
|
183
|
+
if (Array.isArray(item)) {
|
|
184
|
+
return /* @__PURE__ */ React.createElement(
|
|
185
|
+
ErrorGroup,
|
|
186
|
+
{
|
|
187
|
+
key: index,
|
|
188
|
+
screenSize,
|
|
189
|
+
fieldOrder: item.map((field) => field.key)
|
|
190
|
+
},
|
|
191
|
+
item.map((f) => {
|
|
192
|
+
return /* @__PURE__ */ React.createElement(Field, { key: f.key, name: f.key });
|
|
193
|
+
})
|
|
194
|
+
);
|
|
195
|
+
} else {
|
|
196
|
+
return /* @__PURE__ */ React.createElement(Field, { key: item.key, name: item.key });
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}, [auto, fieldsets, schema, screenSize, transformedFields]);
|
|
201
|
+
return /* @__PURE__ */ React.createElement(
|
|
202
|
+
FormBase,
|
|
203
|
+
{
|
|
204
|
+
resolver,
|
|
205
|
+
fieldsetsMap,
|
|
206
|
+
fieldsMap,
|
|
207
|
+
registerField,
|
|
208
|
+
initial,
|
|
209
|
+
reValidateMode,
|
|
210
|
+
mode,
|
|
211
|
+
shouldFocusError,
|
|
212
|
+
criteriaMode,
|
|
213
|
+
onSubmit,
|
|
214
|
+
componentRegistry,
|
|
215
|
+
ref,
|
|
216
|
+
grid,
|
|
217
|
+
...props
|
|
218
|
+
},
|
|
219
|
+
fieldChildren,
|
|
220
|
+
auto && /* @__PURE__ */ React.createElement(Button, { type: "submit" }, "\u03A3\u03C5\u03BD\u03AD\u03C7\u03B5\u03B9\u03B1"),
|
|
221
|
+
children
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
);
|
|
78
225
|
const DEFAULT_LAYOUT = {
|
|
79
226
|
xs: 12,
|
|
80
227
|
sm: 12,
|
|
@@ -83,7 +230,7 @@ const DEFAULT_LAYOUT = {
|
|
|
83
230
|
xl: 12
|
|
84
231
|
};
|
|
85
232
|
const BREAKPOINTS = ["xs", "sm", "md", "lg", "xl"];
|
|
86
|
-
|
|
233
|
+
function groupFieldsByLayout(fields) {
|
|
87
234
|
return BREAKPOINTS.reduce((sizes, size) => {
|
|
88
235
|
sizes[size] = fields.reduce((acc, item) => {
|
|
89
236
|
const layoutValue = item.layout?.[size] || 12;
|
|
@@ -104,129 +251,7 @@ const groupFieldsByLayout = (fields) => {
|
|
|
104
251
|
});
|
|
105
252
|
return sizes;
|
|
106
253
|
}, {});
|
|
107
|
-
}
|
|
108
|
-
const useFormValues = () => {
|
|
109
|
-
const ctx = useFormContext();
|
|
110
|
-
return ctx.getValues();
|
|
111
|
-
};
|
|
112
|
-
const FormBuilder = React.forwardRef(function FormBuilder2({
|
|
113
|
-
fields = [],
|
|
114
|
-
fieldsets,
|
|
115
|
-
initial = {},
|
|
116
|
-
onSubmit,
|
|
117
|
-
children,
|
|
118
|
-
reValidateMode = "onSubmit",
|
|
119
|
-
mode = "onSubmit",
|
|
120
|
-
shouldFocusError = true,
|
|
121
|
-
criteriaMode = "all",
|
|
122
|
-
auto = false,
|
|
123
|
-
validatorRegistry,
|
|
124
|
-
componentRegistry,
|
|
125
|
-
grid = false,
|
|
126
|
-
...props
|
|
127
|
-
}, ref) {
|
|
128
|
-
const { screenSize } = useScreenSize();
|
|
129
|
-
fields = fields.map((field) => {
|
|
130
|
-
const layout = field.layout;
|
|
131
|
-
if (!layout) {
|
|
132
|
-
return {
|
|
133
|
-
...field,
|
|
134
|
-
layout: DEFAULT_LAYOUT
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
return {
|
|
138
|
-
...field,
|
|
139
|
-
layout: BREAKPOINTS.reduce(
|
|
140
|
-
(expandedLayout, breakpoint, breakpointIndex) => {
|
|
141
|
-
if (field?.layout?.[breakpoint]) {
|
|
142
|
-
expandedLayout[breakpoint] = field?.layout[breakpoint];
|
|
143
|
-
} else if (expandedLayout[BREAKPOINTS[breakpointIndex - 1]]) {
|
|
144
|
-
expandedLayout[breakpoint] = expandedLayout[BREAKPOINTS[breakpointIndex - 1]];
|
|
145
|
-
} else {
|
|
146
|
-
expandedLayout[breakpoint] = 12;
|
|
147
|
-
}
|
|
148
|
-
return expandedLayout;
|
|
149
|
-
},
|
|
150
|
-
{}
|
|
151
|
-
)
|
|
152
|
-
};
|
|
153
|
-
});
|
|
154
|
-
const fieldsState = useRef(fields);
|
|
155
|
-
const setFieldsState = useCallback((newFields) => {
|
|
156
|
-
fieldsState.current = newFields;
|
|
157
|
-
}, []);
|
|
158
|
-
const schema = useValidationSchema(fieldsState, validatorRegistry);
|
|
159
|
-
const registerField = useCallback((field) => {
|
|
160
|
-
const fieldIndex = fieldsState.current.findIndex(
|
|
161
|
-
(f) => f.key === field.key
|
|
162
|
-
);
|
|
163
|
-
if (fieldIndex > -1) {
|
|
164
|
-
fieldsState.current[fieldIndex] = field;
|
|
165
|
-
} else {
|
|
166
|
-
fieldsState.current.push(field);
|
|
167
|
-
}
|
|
168
|
-
setFieldsState(fieldsState.current);
|
|
169
|
-
}, []);
|
|
170
|
-
let resolver;
|
|
171
|
-
let fieldsMap;
|
|
172
|
-
let fieldsetsMap;
|
|
173
|
-
let fieldChildren;
|
|
174
|
-
if (schema) {
|
|
175
|
-
resolver = yupResolver(schema);
|
|
176
|
-
fieldsMap = fields ? fields.reduce((map, field) => ({ ...map, [field.key]: field }), {}) : {};
|
|
177
|
-
fieldsetsMap = fieldsets && fieldsets.reduce(
|
|
178
|
-
(map, fieldset) => ({ ...map, [fieldset.key]: fieldset }),
|
|
179
|
-
{}
|
|
180
|
-
);
|
|
181
|
-
if (auto) {
|
|
182
|
-
if (fieldsets) {
|
|
183
|
-
fieldChildren = fieldsets.map((fieldset) => /* @__PURE__ */ React.createElement(FieldsetWithContext, { key: fieldset.key, name: fieldset.key }));
|
|
184
|
-
} else if (fields) {
|
|
185
|
-
const fieldsByLayouts = groupFieldsByLayout(fields);
|
|
186
|
-
const fieldsByLayoutSize = fieldsByLayouts[screenSize];
|
|
187
|
-
fieldChildren = fieldsByLayoutSize.map((item, index) => {
|
|
188
|
-
if (Array.isArray(item)) {
|
|
189
|
-
return /* @__PURE__ */ React.createElement(
|
|
190
|
-
ErrorGroup,
|
|
191
|
-
{
|
|
192
|
-
key: index,
|
|
193
|
-
screenSize,
|
|
194
|
-
fieldOrder: item.map((field) => field.key)
|
|
195
|
-
},
|
|
196
|
-
item.map((f) => {
|
|
197
|
-
return /* @__PURE__ */ React.createElement(Field, { key: f.key, name: f.key });
|
|
198
|
-
})
|
|
199
|
-
);
|
|
200
|
-
} else {
|
|
201
|
-
return /* @__PURE__ */ React.createElement(Field, { key: item.key, name: item.key });
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return /* @__PURE__ */ React.createElement(
|
|
208
|
-
FormBase,
|
|
209
|
-
{
|
|
210
|
-
resolver,
|
|
211
|
-
fieldsetsMap,
|
|
212
|
-
fieldsMap,
|
|
213
|
-
registerField,
|
|
214
|
-
initial,
|
|
215
|
-
reValidateMode,
|
|
216
|
-
mode,
|
|
217
|
-
shouldFocusError,
|
|
218
|
-
criteriaMode,
|
|
219
|
-
onSubmit,
|
|
220
|
-
componentRegistry,
|
|
221
|
-
ref,
|
|
222
|
-
grid,
|
|
223
|
-
...props
|
|
224
|
-
},
|
|
225
|
-
fieldChildren,
|
|
226
|
-
auto && /* @__PURE__ */ React.createElement(Button, { type: "submit" }, "\u03A3\u03C5\u03BD\u03AD\u03C7\u03B5\u03B9\u03B1"),
|
|
227
|
-
children
|
|
228
|
-
);
|
|
229
|
-
});
|
|
254
|
+
}
|
|
230
255
|
const ControlledFormBuilder = (props) => {
|
|
231
256
|
return /* @__PURE__ */ React.createElement(FormBuilder, { ...props, componentRegistry: CONTROLLED_FIELD_COMPONENTS });
|
|
232
257
|
};
|