@digigov/form 2.0.0-b4cd6916 → 2.0.0-d0adc9fb
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/FieldBaseContainer/index.js +3 -3
- package/Field/FieldBaseContainer.js.map +2 -2
- package/Field/FieldConditional.js.map +1 -1
- package/Field/index.js +5 -0
- package/Field/index.js.map +2 -2
- package/Field/types.d.ts +9 -8
- package/Field/utils/index.js +6 -0
- package/Field/utils/index.js.map +2 -2
- package/Field/utils/useField/index.js +7 -1
- package/Field/utils/useField.js.map +2 -2
- package/FieldArray/FormDialog/index.js +280 -0
- package/{Questions/Questions.stories → FieldArray/FormDialog}/package.json +1 -1
- package/FieldArray/FormDialog.d.ts +53 -0
- package/FieldArray/FormDialog.js.map +7 -0
- package/FieldArray/index.d.ts +5 -0
- package/FieldArray/index.js +57 -24
- package/FieldArray/index.js.map +2 -2
- package/FieldObject/index.d.ts +2 -0
- package/FieldObject/index.js +10 -5
- package/FieldObject/index.js.map +2 -2
- package/Fieldset/index.d.ts +1 -1
- package/Fieldset/index.js +5 -5
- package/Fieldset/index.js.map +2 -2
- package/Fieldset/types.d.ts +2 -2
- package/FormBuilder/index.js +7 -4
- package/FormBuilder/index.js.map +2 -2
- package/FormContext.js.map +2 -2
- package/MultiplicityField/add-objects/index.js +8 -6
- package/MultiplicityField/add-objects.js.map +2 -2
- package/MultiplicityField/index.js +13 -11
- package/MultiplicityField/index.js.map +2 -2
- package/MultiplicityField/types.d.ts +1 -2
- package/Questions/Questions/index.js +5 -4
- package/Questions/Questions.js.map +2 -2
- package/Questions/Step/StepArrayReview.js.map +2 -2
- package/Questions/Step/StepTitle/index.js +4 -3
- package/Questions/Step/StepTitle.d.ts +1 -1
- package/Questions/Step/StepTitle.js.map +2 -2
- package/cjs/Field/FieldBaseContainer/index.js +3 -3
- package/cjs/Field/FieldBaseContainer.js.map +3 -3
- package/cjs/Field/FieldConditional.js.map +1 -1
- package/cjs/Field/index.js +5 -0
- package/cjs/Field/index.js.map +2 -2
- package/cjs/Field/types.js.map +1 -1
- package/cjs/Field/utils/index.js +6 -0
- package/cjs/Field/utils/index.js.map +3 -3
- package/cjs/Field/utils/useField/index.js +7 -1
- package/cjs/Field/utils/useField.js.map +2 -2
- package/cjs/FieldArray/FormDialog/index.js +302 -0
- package/cjs/FieldArray/FormDialog.js.map +7 -0
- package/cjs/FieldArray/index.js +56 -23
- package/cjs/FieldArray/index.js.map +3 -3
- package/cjs/FieldObject/index.js +11 -6
- package/cjs/FieldObject/index.js.map +3 -3
- package/cjs/Fieldset/index.js +10 -10
- package/cjs/Fieldset/index.js.map +3 -3
- package/cjs/Fieldset/types.js.map +1 -1
- package/cjs/FormBuilder/index.js +9 -6
- package/cjs/FormBuilder/index.js.map +3 -3
- package/cjs/FormContext/index.js +2 -2
- package/cjs/FormContext.js.map +3 -3
- package/cjs/MultiplicityField/add-objects/index.js +12 -10
- package/cjs/MultiplicityField/add-objects.js.map +3 -3
- package/cjs/MultiplicityField/index.js +11 -14
- package/cjs/MultiplicityField/index.js.map +3 -3
- package/cjs/MultiplicityField/types.js.map +1 -1
- package/cjs/Questions/Questions/index.js +5 -4
- package/cjs/Questions/Questions.js.map +2 -2
- package/cjs/Questions/Step/StepArrayReview.js.map +2 -2
- package/cjs/Questions/Step/StepTitle/index.js +5 -5
- package/cjs/Questions/Step/StepTitle.js.map +3 -3
- package/cjs/inputs/AutoCompleteInput/index.js +8 -7
- package/cjs/inputs/AutoCompleteInput/index.js.map +3 -3
- package/cjs/inputs/Checkboxes/index.js +7 -8
- package/cjs/inputs/Checkboxes/index.js.map +3 -3
- package/cjs/inputs/DateInput/index.js +7 -8
- package/cjs/inputs/DateInput/index.js.map +3 -3
- package/cjs/inputs/DateTimeInput/index.js +206 -0
- package/cjs/inputs/DateTimeInput/index.js.map +7 -0
- package/cjs/inputs/FileInput/index.js +9 -10
- package/cjs/inputs/FileInput/index.js.map +3 -3
- package/cjs/inputs/ImageInput/index.js +14 -10
- package/cjs/inputs/ImageInput/index.js.map +3 -3
- package/cjs/inputs/Input/index.js +11 -5
- package/cjs/inputs/Input/index.js.map +2 -2
- package/cjs/inputs/Input/inputsInputScenarios.js.map +2 -2
- package/cjs/inputs/Label/index.js +3 -3
- package/cjs/inputs/Label/index.js.map +3 -3
- package/cjs/inputs/OtpInput/index.js.map +2 -2
- package/cjs/inputs/Radio/index.js +12 -13
- package/cjs/inputs/Radio/index.js.map +3 -3
- package/cjs/inputs/Select/index.js +9 -5
- package/cjs/inputs/Select/index.js.map +3 -3
- package/cjs/inputs/inputsScenarios/index.js +4 -10
- package/cjs/inputs/inputsScenarios.js.map +2 -2
- package/cjs/lazy/index.js +46 -35
- package/cjs/lazy.js.map +3 -3
- package/cjs/locales/el.js.map +1 -1
- package/cjs/registry/index.js +70 -62
- package/cjs/registry.js.map +3 -3
- package/cjs/types.js.map +1 -1
- package/cjs/utils/index.js +2 -1
- package/cjs/utils.js.map +2 -2
- package/cjs/validators/index.js +33 -74
- package/cjs/validators/index.js.map +3 -3
- package/cjs/validators/utils/date/index.js +138 -0
- package/cjs/validators/utils/date.js.map +7 -0
- package/cjs/validators/utils/datetime/index.js +151 -0
- package/cjs/validators/utils/datetime.js.map +7 -0
- package/cjs/validators/utils/file/index.js +1 -1
- package/cjs/validators/utils/file.js.map +2 -2
- package/cjs/validators/utils/index.js +5 -1
- package/cjs/validators/utils/index.js.map +2 -2
- package/cjs/validators/utils/phone.js.map +2 -2
- package/cjs/validators/utils/postal_code.js.map +1 -1
- package/cjs/validators/utils/uuid4.js.map +2 -2
- package/index.js +1 -1
- package/inputs/AutoCompleteInput/index.d.ts +1 -1
- package/inputs/AutoCompleteInput/index.js +10 -7
- package/inputs/AutoCompleteInput/index.js.map +2 -2
- package/inputs/Checkboxes/index.d.ts +1 -1
- package/inputs/Checkboxes/index.js +8 -5
- package/inputs/Checkboxes/index.js.map +2 -2
- package/inputs/DateInput/index.d.ts +1 -2
- package/inputs/DateInput/index.js +9 -7
- package/inputs/DateInput/index.js.map +2 -2
- package/inputs/DateTimeInput/DateTimeInput.stories.d.ts +7 -0
- package/inputs/DateTimeInput/__stories__/Default.d.ts +3 -0
- package/inputs/DateTimeInput/index.d.ts +13 -0
- package/inputs/DateTimeInput/index.js +176 -0
- package/inputs/DateTimeInput/index.js.map +7 -0
- package/inputs/DateTimeInput/index.test.d.ts +1 -0
- package/{Form.stories → inputs/DateTimeInput}/package.json +1 -1
- package/inputs/FileInput/index.js +7 -8
- package/inputs/FileInput/index.js.map +2 -2
- package/inputs/ImageInput/index.js +13 -9
- package/inputs/ImageInput/index.js.map +2 -2
- package/inputs/Input/index.js +11 -5
- package/inputs/Input/index.js.map +2 -2
- package/inputs/Input/inputsInputScenarios.js.map +2 -2
- package/inputs/Label/index.d.ts +0 -2
- package/inputs/Label/index.js +2 -2
- package/inputs/Label/index.js.map +2 -2
- package/inputs/OtpInput/index.js.map +2 -2
- package/inputs/Radio/index.d.ts +1 -1
- package/inputs/Radio/index.js +8 -5
- package/inputs/Radio/index.js.map +2 -2
- package/inputs/Select/index.d.ts +1 -1
- package/inputs/Select/index.js +10 -3
- package/inputs/Select/index.js.map +2 -2
- package/inputs/inputsScenarios/index.js +4 -10
- package/inputs/inputsScenarios.js.map +2 -2
- package/lazy/index.js +74 -67
- package/locales/el.js.map +1 -1
- package/package.json +4 -4
- package/registry/index.js +114 -107
- package/src/Field/FieldBaseContainer.tsx +4 -2
- package/src/Field/FieldConditional.tsx +2 -2
- package/src/Field/index.tsx +5 -0
- package/src/Field/types.tsx +28 -26
- package/src/Field/utils/index.ts +6 -0
- package/src/Field/utils/useField.ts +7 -3
- package/src/FieldArray/FormDialog.tsx +379 -0
- package/src/FieldArray/__stories__/Default.tsx +1 -0
- package/src/FieldArray/__stories__/WithExactLength.tsx +77 -13
- package/src/FieldArray/index.tsx +88 -47
- package/src/FieldObject/index.tsx +12 -5
- package/src/Fieldset/index.tsx +5 -5
- package/src/Fieldset/types.tsx +2 -2
- package/src/FormBuilder/{FormBuilder.mdx → doc.mdx} +20 -33
- package/src/FormBuilder/index.tsx +7 -5
- package/src/FormBuilder/scenarios.test.tsx +2 -2
- package/src/FormContext.tsx +1 -2
- package/src/MultiplicityField/add-objects.tsx +9 -9
- package/src/MultiplicityField/{MultiplicityField.mdx → doc.mdx} +12 -16
- package/src/MultiplicityField/index.tsx +14 -13
- package/src/MultiplicityField/types.ts +1 -2
- package/src/Questions/Questions.tsx +4 -4
- package/src/Questions/Step/StepArrayReview.tsx +1 -1
- package/src/Questions/Step/StepTitle.tsx +4 -3
- package/src/Questions/__snapshots__/index.spec.tsx.snap +8 -4
- package/src/Questions/{index.mdx → doc.mdx} +9 -12
- package/src/Questions/index.spec.tsx +6 -2
- package/src/create-simple-form.mdx +2 -6
- package/src/{index.mdx → doc.mdx} +4 -8
- package/src/inputs/AutoCompleteInput/__stories__/Default.tsx +2 -10
- package/src/inputs/AutoCompleteInput/__stories__/Multiple.tsx +1 -7
- package/src/inputs/AutoCompleteInput/{index.mdx → doc.mdx} +2 -13
- package/src/inputs/AutoCompleteInput/index.tsx +32 -28
- package/src/inputs/Checkboxes/{index.mdx → doc.mdx} +5 -15
- package/src/inputs/Checkboxes/index.tsx +31 -28
- package/src/inputs/DateInput/__stories__/Default.tsx +7 -12
- package/src/inputs/DateInput/{index.mdx → doc.mdx} +1 -8
- package/src/inputs/DateInput/index.tsx +9 -7
- package/src/inputs/DateTimeInput/DateTimeInput.stories.js +8 -0
- package/src/inputs/DateTimeInput/__stories__/Default.tsx +25 -0
- package/src/inputs/DateTimeInput/doc.mdx +16 -0
- package/src/inputs/DateTimeInput/index.test.tsx +18 -0
- package/src/inputs/DateTimeInput/index.tsx +189 -0
- package/src/inputs/FileInput/{index.mdx → doc.mdx} +1 -5
- package/src/inputs/FileInput/index.tsx +8 -9
- package/src/inputs/ImageInput/ImageInput.stories.js +0 -1
- package/src/inputs/ImageInput/__stories__/MaxSize.tsx +2 -2
- package/src/inputs/ImageInput/__stories__/WithInvalidImageDimension.tsx +2 -0
- package/src/inputs/ImageInput/doc.mdx +23 -0
- package/src/inputs/ImageInput/index.tsx +16 -16
- package/src/inputs/Input/__stories__/LandlineNumber.tsx +2 -1
- package/src/inputs/Input/__stories__/MobilePhone.tsx +1 -0
- package/src/inputs/Input/__stories__/PhoneNumber.tsx +1 -0
- package/src/inputs/Input/__stories__/PostalCode.tsx +1 -0
- package/src/inputs/Input/doc.mdx +56 -0
- package/src/inputs/Input/index.tsx +25 -11
- package/src/inputs/Input/inputsInputScenarios.ts +244 -245
- package/src/inputs/Label/doc.mdx +14 -0
- package/src/inputs/Label/index.tsx +2 -6
- package/src/inputs/OtpInput/{index.mdx → doc.mdx} +1 -8
- package/src/inputs/OtpInput/index.tsx +2 -1
- package/src/inputs/Radio/{index.mdx → doc.mdx} +5 -15
- package/src/inputs/Radio/index.tsx +59 -56
- package/src/inputs/Select/{index.mdx → doc.mdx} +1 -5
- package/src/inputs/Select/index.tsx +11 -4
- package/src/inputs/inputsScenarios.ts +36 -42
- package/src/installation.mdx +2 -5
- package/src/lazy.js +74 -64
- package/src/locales/el.ts +1 -1
- package/src/registry.js +106 -100
- package/src/types.tsx +2 -2
- package/src/utils.ts +2 -2
- package/src/validators/index.ts +55 -79
- package/src/validators/utils/date.ts +107 -0
- package/src/validators/utils/datetime.ts +130 -0
- package/src/validators/utils/file.ts +5 -3
- package/src/validators/utils/index.ts +2 -0
- package/src/validators/utils/phone.ts +1 -1
- package/src/validators/utils/postal_code.ts +1 -1
- package/src/validators/utils/uuid4.ts +2 -1
- package/src/validators/validators.spec.ts +3 -3
- package/types.d.ts +2 -2
- package/types.js.map +1 -1
- package/utils/index.js +2 -1
- package/utils.js.map +2 -2
- package/validators/index.js +40 -75
- package/validators/index.js.map +2 -2
- package/validators/utils/date/index.js +103 -0
- package/{inputs/Input/Input.stories → validators/utils/date}/package.json +1 -1
- package/validators/utils/date.d.ts +9 -0
- package/validators/utils/date.js.map +7 -0
- package/validators/utils/datetime/index.js +116 -0
- package/{FieldArray/FieldArray.stories → validators/utils/datetime}/package.json +1 -1
- package/validators/utils/datetime.d.ts +9 -0
- package/validators/utils/datetime.js.map +7 -0
- package/validators/utils/file/index.js +1 -1
- package/validators/utils/file.js.map +2 -2
- package/validators/utils/index.d.ts +2 -0
- package/validators/utils/index.js +2 -0
- package/validators/utils/index.js.map +2 -2
- package/validators/utils/phone.d.ts +1 -1
- package/validators/utils/phone.js.map +2 -2
- package/validators/utils/postal_code.d.ts +1 -1
- package/validators/utils/postal_code.js.map +1 -1
- package/validators/utils/uuid4.js.map +2 -2
- package/FieldArray/FieldArray.stories/index.js +0 -14
- package/FieldArray/FieldArray.stories.js.map +0 -7
- package/FieldArray/__stories__/Default/index.js +0 -95
- package/FieldArray/__stories__/Default/package.json +0 -6
- package/FieldArray/__stories__/Default.js.map +0 -7
- package/FieldArray/__stories__/WithExactLength/index.js +0 -95
- package/FieldArray/__stories__/WithExactLength/package.json +0 -6
- package/FieldArray/__stories__/WithExactLength.js.map +0 -7
- package/Form.stories/index.js +0 -7
- package/Form.stories.js.map +0 -7
- package/FormBuilder/FormBuilder.stories/index.js +0 -12
- package/FormBuilder/FormBuilder.stories/package.json +0 -6
- package/FormBuilder/FormBuilder.stories.js.map +0 -7
- package/FormBuilder/__stories__/Default/index.js +0 -32
- package/FormBuilder/__stories__/Default/package.json +0 -6
- package/FormBuilder/__stories__/Default.js.map +0 -7
- package/MultiplicityField/MultiplicityField.stories/index.js +0 -22
- package/MultiplicityField/MultiplicityField.stories/package.json +0 -6
- package/MultiplicityField/MultiplicityField.stories.js.map +0 -7
- package/MultiplicityField/__stories__/Default/index.js +0 -100
- package/MultiplicityField/__stories__/Default/package.json +0 -6
- package/MultiplicityField/__stories__/Default.js.map +0 -7
- package/MultiplicityField/__stories__/PreviewDisplay/index.js +0 -70
- package/MultiplicityField/__stories__/PreviewDisplay/package.json +0 -6
- package/MultiplicityField/__stories__/PreviewDisplay.js.map +0 -7
- package/MultiplicityField/__stories__/WithExactLength/index.js +0 -97
- package/MultiplicityField/__stories__/WithExactLength/package.json +0 -6
- package/MultiplicityField/__stories__/WithExactLength.js.map +0 -7
- package/MultiplicityField/__stories__/WithMaxLength/index.js +0 -100
- package/MultiplicityField/__stories__/WithMaxLength/package.json +0 -6
- package/MultiplicityField/__stories__/WithMaxLength.js.map +0 -7
- package/MultiplicityField/__stories__/WithMinAndMaxLength/index.js +0 -101
- package/MultiplicityField/__stories__/WithMinAndMaxLength/package.json +0 -6
- package/MultiplicityField/__stories__/WithMinAndMaxLength.js.map +0 -7
- package/MultiplicityField/__stories__/WithMinLength/index.js +0 -100
- package/MultiplicityField/__stories__/WithMinLength/package.json +0 -6
- package/MultiplicityField/__stories__/WithMinLength.js.map +0 -7
- package/Questions/Questions.stories/index.js +0 -12
- package/Questions/Questions.stories.js.map +0 -7
- package/Questions/__stories__/Default/index.js +0 -108
- package/Questions/__stories__/Default/package.json +0 -6
- package/Questions/__stories__/Default.js.map +0 -7
- package/cjs/FieldArray/FieldArray.stories/index.js +0 -48
- package/cjs/FieldArray/FieldArray.stories.js.map +0 -7
- package/cjs/FieldArray/__stories__/Default/index.js +0 -128
- package/cjs/FieldArray/__stories__/Default.js.map +0 -7
- package/cjs/FieldArray/__stories__/WithExactLength/index.js +0 -128
- package/cjs/FieldArray/__stories__/WithExactLength.js.map +0 -7
- package/cjs/Form.stories/index.js +0 -26
- package/cjs/Form.stories.js.map +0 -7
- package/cjs/FormBuilder/FormBuilder.stories/index.js +0 -45
- package/cjs/FormBuilder/FormBuilder.stories.js.map +0 -7
- package/cjs/FormBuilder/__stories__/Default/index.js +0 -65
- package/cjs/FormBuilder/__stories__/Default.js.map +0 -7
- package/cjs/MultiplicityField/MultiplicityField.stories/index.js +0 -60
- package/cjs/MultiplicityField/MultiplicityField.stories.js.map +0 -7
- package/cjs/MultiplicityField/__stories__/Default/index.js +0 -133
- package/cjs/MultiplicityField/__stories__/Default.js.map +0 -7
- package/cjs/MultiplicityField/__stories__/PreviewDisplay/index.js +0 -86
- package/cjs/MultiplicityField/__stories__/PreviewDisplay.js.map +0 -7
- package/cjs/MultiplicityField/__stories__/WithExactLength/index.js +0 -130
- package/cjs/MultiplicityField/__stories__/WithExactLength.js.map +0 -7
- package/cjs/MultiplicityField/__stories__/WithMaxLength/index.js +0 -133
- package/cjs/MultiplicityField/__stories__/WithMaxLength.js.map +0 -7
- package/cjs/MultiplicityField/__stories__/WithMinAndMaxLength/index.js +0 -134
- package/cjs/MultiplicityField/__stories__/WithMinAndMaxLength.js.map +0 -7
- package/cjs/MultiplicityField/__stories__/WithMinLength/index.js +0 -133
- package/cjs/MultiplicityField/__stories__/WithMinLength.js.map +0 -7
- package/cjs/Questions/Questions.stories/index.js +0 -45
- package/cjs/Questions/Questions.stories.js.map +0 -7
- package/cjs/Questions/__stories__/Default/index.js +0 -136
- package/cjs/Questions/__stories__/Default.js.map +0 -7
- package/cjs/inputs/AutoCompleteInput/AutoComplete.stories/index.js +0 -48
- package/cjs/inputs/AutoCompleteInput/AutoComplete.stories.js.map +0 -7
- package/cjs/inputs/AutoCompleteInput/__stories__/Default/index.js +0 -83
- package/cjs/inputs/AutoCompleteInput/__stories__/Default.js.map +0 -7
- package/cjs/inputs/AutoCompleteInput/__stories__/Multiple/index.js +0 -83
- package/cjs/inputs/AutoCompleteInput/__stories__/Multiple.js.map +0 -7
- package/cjs/inputs/Checkboxes/Checkboxes.stories/index.js +0 -51
- package/cjs/inputs/Checkboxes/Checkboxes.stories.js.map +0 -7
- package/cjs/inputs/Checkboxes/__stories__/Conditional/index.js +0 -133
- package/cjs/inputs/Checkboxes/__stories__/Conditional.js.map +0 -7
- package/cjs/inputs/Checkboxes/__stories__/Default/index.js +0 -77
- package/cjs/inputs/Checkboxes/__stories__/Default.js.map +0 -7
- package/cjs/inputs/Checkboxes/__stories__/WithDivider/index.js +0 -78
- package/cjs/inputs/Checkboxes/__stories__/WithDivider.js.map +0 -7
- package/cjs/inputs/DateInput/DateInput.stories/index.js +0 -45
- package/cjs/inputs/DateInput/DateInput.stories.js.map +0 -7
- package/cjs/inputs/DateInput/__stories__/Default/index.js +0 -61
- package/cjs/inputs/DateInput/__stories__/Default.js.map +0 -7
- package/cjs/inputs/FileInput/FileInput.stories/index.js +0 -45
- package/cjs/inputs/FileInput/FileInput.stories.js.map +0 -7
- package/cjs/inputs/FileInput/__stories__/Default/index.js +0 -61
- package/cjs/inputs/FileInput/__stories__/Default.js.map +0 -7
- package/cjs/inputs/ImageInput/ImageInput.stories/index.js +0 -51
- package/cjs/inputs/ImageInput/ImageInput.stories.js.map +0 -7
- package/cjs/inputs/ImageInput/__stories__/Default/index.js +0 -63
- package/cjs/inputs/ImageInput/__stories__/Default.js.map +0 -7
- package/cjs/inputs/ImageInput/__stories__/MaxSize/index.js +0 -69
- package/cjs/inputs/ImageInput/__stories__/MaxSize.js.map +0 -7
- package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +0 -71
- package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension.js.map +0 -7
- package/cjs/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +0 -68
- package/cjs/inputs/ImageInput/__stories__/WithInvalidImageSize.js.map +0 -7
- package/cjs/inputs/Input/Input.stories/index.js +0 -72
- package/cjs/inputs/Input/Input.stories.js.map +0 -7
- package/cjs/inputs/Input/__stories__/AFM/index.js +0 -63
- package/cjs/inputs/Input/__stories__/AFM.js.map +0 -7
- package/cjs/inputs/Input/__stories__/Boolean/index.js +0 -64
- package/cjs/inputs/Input/__stories__/Boolean.js.map +0 -7
- package/cjs/inputs/Input/__stories__/IBAN/index.js +0 -64
- package/cjs/inputs/Input/__stories__/IBAN.js.map +0 -7
- package/cjs/inputs/Input/__stories__/Integer/index.js +0 -78
- package/cjs/inputs/Input/__stories__/Integer.js.map +0 -7
- package/cjs/inputs/Input/__stories__/LandlineNumber/index.js +0 -67
- package/cjs/inputs/Input/__stories__/LandlineNumber.js.map +0 -7
- package/cjs/inputs/Input/__stories__/MobilePhone/index.js +0 -67
- package/cjs/inputs/Input/__stories__/MobilePhone.js.map +0 -7
- package/cjs/inputs/Input/__stories__/PhoneNumber/index.js +0 -66
- package/cjs/inputs/Input/__stories__/PhoneNumber.js.map +0 -7
- package/cjs/inputs/Input/__stories__/PostalCode/index.js +0 -64
- package/cjs/inputs/Input/__stories__/PostalCode.js.map +0 -7
- package/cjs/inputs/Input/__stories__/String/index.js +0 -64
- package/cjs/inputs/Input/__stories__/String.js.map +0 -7
- package/cjs/inputs/Input/__stories__/TextWithLimit/index.js +0 -64
- package/cjs/inputs/Input/__stories__/TextWithLimit.js.map +0 -7
- package/cjs/inputs/Label/Label.stories/index.js +0 -45
- package/cjs/inputs/Label/Label.stories.js.map +0 -7
- package/cjs/inputs/Label/__stories__/Default/index.js +0 -72
- package/cjs/inputs/Label/__stories__/Default.js.map +0 -7
- package/cjs/inputs/OtpInput/OtpInput.stories/index.js +0 -45
- package/cjs/inputs/OtpInput/OtpInput.stories.js.map +0 -7
- package/cjs/inputs/OtpInput/__stories__/Default/index.js +0 -64
- package/cjs/inputs/OtpInput/__stories__/Default.js.map +0 -7
- package/cjs/inputs/Radio/Radio.stories/index.js +0 -51
- package/cjs/inputs/Radio/Radio.stories.js.map +0 -7
- package/cjs/inputs/Radio/__stories__/Conditional/index.js +0 -133
- package/cjs/inputs/Radio/__stories__/Conditional.js.map +0 -7
- package/cjs/inputs/Radio/__stories__/Default/index.js +0 -81
- package/cjs/inputs/Radio/__stories__/Default.js.map +0 -7
- package/cjs/inputs/Radio/__stories__/WithDivider/index.js +0 -82
- package/cjs/inputs/Radio/__stories__/WithDivider.js.map +0 -7
- package/cjs/inputs/Select/Select.stories/index.js +0 -45
- package/cjs/inputs/Select/Select.stories.js.map +0 -7
- package/cjs/inputs/Select/__stories__/Default/index.js +0 -86
- package/cjs/inputs/Select/__stories__/Default.js.map +0 -7
- package/inputs/AutoCompleteInput/AutoComplete.stories/index.js +0 -14
- package/inputs/AutoCompleteInput/AutoComplete.stories/package.json +0 -6
- package/inputs/AutoCompleteInput/AutoComplete.stories.js.map +0 -7
- package/inputs/AutoCompleteInput/__stories__/Default/index.js +0 -50
- package/inputs/AutoCompleteInput/__stories__/Default/package.json +0 -6
- package/inputs/AutoCompleteInput/__stories__/Default.js.map +0 -7
- package/inputs/AutoCompleteInput/__stories__/Multiple/index.js +0 -50
- package/inputs/AutoCompleteInput/__stories__/Multiple/package.json +0 -6
- package/inputs/AutoCompleteInput/__stories__/Multiple.js.map +0 -7
- package/inputs/Checkboxes/Checkboxes.stories/index.js +0 -16
- package/inputs/Checkboxes/Checkboxes.stories/package.json +0 -6
- package/inputs/Checkboxes/Checkboxes.stories.js.map +0 -7
- package/inputs/Checkboxes/__stories__/Conditional/index.js +0 -100
- package/inputs/Checkboxes/__stories__/Conditional/package.json +0 -6
- package/inputs/Checkboxes/__stories__/Conditional.js.map +0 -7
- package/inputs/Checkboxes/__stories__/Default/index.js +0 -44
- package/inputs/Checkboxes/__stories__/Default/package.json +0 -6
- package/inputs/Checkboxes/__stories__/Default.js.map +0 -7
- package/inputs/Checkboxes/__stories__/WithDivider/index.js +0 -45
- package/inputs/Checkboxes/__stories__/WithDivider/package.json +0 -6
- package/inputs/Checkboxes/__stories__/WithDivider.js.map +0 -7
- package/inputs/DateInput/DateInput.stories/index.js +0 -12
- package/inputs/DateInput/DateInput.stories/package.json +0 -6
- package/inputs/DateInput/DateInput.stories.js.map +0 -7
- package/inputs/DateInput/__stories__/Default/index.js +0 -28
- package/inputs/DateInput/__stories__/Default/package.json +0 -6
- package/inputs/DateInput/__stories__/Default.js.map +0 -7
- package/inputs/FileInput/FileInput.stories/index.js +0 -12
- package/inputs/FileInput/FileInput.stories/package.json +0 -6
- package/inputs/FileInput/FileInput.stories.js.map +0 -7
- package/inputs/FileInput/__stories__/Default/index.js +0 -28
- package/inputs/FileInput/__stories__/Default/package.json +0 -6
- package/inputs/FileInput/__stories__/Default.js.map +0 -7
- package/inputs/ImageInput/ImageInput.stories/index.js +0 -16
- package/inputs/ImageInput/ImageInput.stories/package.json +0 -6
- package/inputs/ImageInput/ImageInput.stories.js.map +0 -7
- package/inputs/ImageInput/__stories__/Default/index.js +0 -30
- package/inputs/ImageInput/__stories__/Default/package.json +0 -6
- package/inputs/ImageInput/__stories__/Default.js.map +0 -7
- package/inputs/ImageInput/__stories__/MaxSize/index.js +0 -36
- package/inputs/ImageInput/__stories__/MaxSize/package.json +0 -6
- package/inputs/ImageInput/__stories__/MaxSize.js.map +0 -7
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +0 -38
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension/package.json +0 -6
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension.js.map +0 -7
- package/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +0 -35
- package/inputs/ImageInput/__stories__/WithInvalidImageSize/package.json +0 -6
- package/inputs/ImageInput/__stories__/WithInvalidImageSize.js.map +0 -7
- package/inputs/Input/Input.stories/index.js +0 -30
- package/inputs/Input/Input.stories.js.map +0 -7
- package/inputs/Input/__stories__/AFM/index.js +0 -30
- package/inputs/Input/__stories__/AFM/package.json +0 -6
- package/inputs/Input/__stories__/AFM.js.map +0 -7
- package/inputs/Input/__stories__/Boolean/index.js +0 -31
- package/inputs/Input/__stories__/Boolean/package.json +0 -6
- package/inputs/Input/__stories__/Boolean.js.map +0 -7
- package/inputs/Input/__stories__/IBAN/index.js +0 -31
- package/inputs/Input/__stories__/IBAN/package.json +0 -6
- package/inputs/Input/__stories__/IBAN.js.map +0 -7
- package/inputs/Input/__stories__/Integer/index.js +0 -45
- package/inputs/Input/__stories__/Integer/package.json +0 -6
- package/inputs/Input/__stories__/Integer.js.map +0 -7
- package/inputs/Input/__stories__/LandlineNumber/index.js +0 -34
- package/inputs/Input/__stories__/LandlineNumber/package.json +0 -6
- package/inputs/Input/__stories__/LandlineNumber.js.map +0 -7
- package/inputs/Input/__stories__/MobilePhone/index.js +0 -34
- package/inputs/Input/__stories__/MobilePhone/package.json +0 -6
- package/inputs/Input/__stories__/MobilePhone.js.map +0 -7
- package/inputs/Input/__stories__/PhoneNumber/index.js +0 -33
- package/inputs/Input/__stories__/PhoneNumber/package.json +0 -6
- package/inputs/Input/__stories__/PhoneNumber.js.map +0 -7
- package/inputs/Input/__stories__/PostalCode/index.js +0 -31
- package/inputs/Input/__stories__/PostalCode/package.json +0 -6
- package/inputs/Input/__stories__/PostalCode.js.map +0 -7
- package/inputs/Input/__stories__/String/index.js +0 -31
- package/inputs/Input/__stories__/String/package.json +0 -6
- package/inputs/Input/__stories__/String.js.map +0 -7
- package/inputs/Input/__stories__/TextWithLimit/index.js +0 -31
- package/inputs/Input/__stories__/TextWithLimit/package.json +0 -6
- package/inputs/Input/__stories__/TextWithLimit.js.map +0 -7
- package/inputs/Label/Label.stories/index.js +0 -12
- package/inputs/Label/Label.stories/package.json +0 -6
- package/inputs/Label/Label.stories.js.map +0 -7
- package/inputs/Label/__stories__/Default/index.js +0 -39
- package/inputs/Label/__stories__/Default/package.json +0 -6
- package/inputs/Label/__stories__/Default.js.map +0 -7
- package/inputs/OtpInput/OtpInput.stories/index.js +0 -12
- package/inputs/OtpInput/OtpInput.stories/package.json +0 -6
- package/inputs/OtpInput/OtpInput.stories.js.map +0 -7
- package/inputs/OtpInput/__stories__/Default/index.js +0 -31
- package/inputs/OtpInput/__stories__/Default/package.json +0 -6
- package/inputs/OtpInput/__stories__/Default.js.map +0 -7
- package/inputs/Radio/Radio.stories/index.js +0 -16
- package/inputs/Radio/Radio.stories/package.json +0 -6
- package/inputs/Radio/Radio.stories.js.map +0 -7
- package/inputs/Radio/__stories__/Conditional/index.js +0 -100
- package/inputs/Radio/__stories__/Conditional/package.json +0 -6
- package/inputs/Radio/__stories__/Conditional.js.map +0 -7
- package/inputs/Radio/__stories__/Default/index.js +0 -48
- package/inputs/Radio/__stories__/Default/package.json +0 -6
- package/inputs/Radio/__stories__/Default.js.map +0 -7
- package/inputs/Radio/__stories__/WithDivider/index.js +0 -49
- package/inputs/Radio/__stories__/WithDivider/package.json +0 -6
- package/inputs/Radio/__stories__/WithDivider.js.map +0 -7
- package/inputs/Select/Select.stories/index.js +0 -12
- package/inputs/Select/Select.stories/package.json +0 -6
- package/inputs/Select/Select.stories.js.map +0 -7
- package/inputs/Select/__stories__/Default/index.js +0 -53
- package/inputs/Select/__stories__/Default/package.json +0 -6
- package/inputs/Select/__stories__/Default.js.map +0 -7
- package/lazy.d.ts +0 -77
- package/lazy.js.map +0 -7
- package/registry.d.ts +0 -70
- package/registry.js.map +0 -7
- package/src/inputs/ImageInput/index.mdx +0 -19
- package/src/inputs/Input/index.mdx +0 -95
- package/src/inputs/Label/index.mdx +0 -0
- /package/src/Field/{index.mdx → doc.mdx} +0 -0
|
@@ -22,7 +22,7 @@ const Questions = ({
|
|
|
22
22
|
useEffect(() => {
|
|
23
23
|
if (forceStepName !== currentStep.name) {
|
|
24
24
|
const forceStep = steps.find(({ name: name2 }) => name2 === forceStepName);
|
|
25
|
-
forceStep
|
|
25
|
+
if (forceStep) setCurrentStep(forceStep);
|
|
26
26
|
}
|
|
27
27
|
}, [forceStepName]);
|
|
28
28
|
const localData = isBrowser && localDraft && window.localStorage.getItem(`questions-${name}`);
|
|
@@ -32,15 +32,16 @@ const Questions = ({
|
|
|
32
32
|
const submitStep = (stepName, stepData) => {
|
|
33
33
|
data[stepName] = stepData;
|
|
34
34
|
if (localDraft) {
|
|
35
|
-
|
|
35
|
+
if (isBrowser)
|
|
36
|
+
window.localStorage.setItem(`questions-${name}`, JSON.stringify(data));
|
|
36
37
|
}
|
|
37
38
|
if (onChange) {
|
|
38
|
-
onChange
|
|
39
|
+
onChange(data);
|
|
39
40
|
}
|
|
40
41
|
setData(data);
|
|
41
42
|
const nextStep = getNextStep(currentStep, steps, data);
|
|
42
43
|
if (nextStep) {
|
|
43
|
-
onActiveStep
|
|
44
|
+
if (onActiveStep) onActiveStep(nextStep);
|
|
44
45
|
setCurrentStep(nextStep);
|
|
45
46
|
} else {
|
|
46
47
|
onSubmit(data);
|
|
@@ -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 forceStep
|
|
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,
|
|
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"],
|
|
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,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:
|
|
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,
|
|
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"],
|
|
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,12 +1,13 @@
|
|
|
1
1
|
import React, { useContext } from "react";
|
|
2
2
|
import { StepContext } from "@digigov/form/Questions/Step/StepContext";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import PageTitleContainer, {
|
|
3
|
+
import {
|
|
4
|
+
PageTitleContainer,
|
|
6
5
|
PageTitleCaption
|
|
7
6
|
} from "@digigov/ui/app/PageTitleContainer";
|
|
8
7
|
import { useTranslation } from "@digigov/ui/i18n";
|
|
9
8
|
import { BackLink } from "@digigov/ui/navigation/BackLink";
|
|
9
|
+
import { Heading } from "@digigov/ui/typography/Heading";
|
|
10
|
+
import { HeadingCaption } from "@digigov/ui/typography/HeadingCaption";
|
|
10
11
|
const StepTitleHeading = (props) => {
|
|
11
12
|
return /* @__PURE__ */ React.createElement(Heading, null, props.children);
|
|
12
13
|
};
|
|
@@ -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
|
|
5
|
-
"mappings": "AAAA,OAAO,SAAS,kBAAkB;AAClC,SAAS,mBAAmB;AAC5B
|
|
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, HeadingProps } 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;AACzB,SAAS,eAA6B;AACtC,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
|
}
|
|
@@ -37,9 +37,9 @@ var import_ErrorMessage = require("@digigov/react-core/ErrorMessage");
|
|
|
37
37
|
var import_FieldContainer = __toESM(require("@digigov/react-core/FieldContainer"));
|
|
38
38
|
var import_Fieldset = __toESM(require("@digigov/react-core/Fieldset"));
|
|
39
39
|
var import_FieldsetLegend = __toESM(require("@digigov/react-core/FieldsetLegend"));
|
|
40
|
-
var import_Hint = __toESM(require("@digigov/react-core/Hint"));
|
|
41
40
|
var import_LabelContainer = __toESM(require("@digigov/react-core/LabelContainer"));
|
|
42
41
|
var import_i18n = require("@digigov/ui/i18n");
|
|
42
|
+
var import_Hint = require("@digigov/ui/typography/Hint");
|
|
43
43
|
const FieldBaseContainer = ({
|
|
44
44
|
name,
|
|
45
45
|
wrapper,
|
|
@@ -52,9 +52,9 @@ const FieldBaseContainer = ({
|
|
|
52
52
|
const errorMessage = error?.message.key ? error.message.key : error?.message || "";
|
|
53
53
|
const errorContext = error?.message.context || {};
|
|
54
54
|
if (wrapper === "fieldset") {
|
|
55
|
-
return /* @__PURE__ */ import_react.default.createElement(import_FieldContainer.default, { error: !!error, ...layout }, /* @__PURE__ */ import_react.default.createElement(import_Fieldset.default, null, /* @__PURE__ */ import_react.default.createElement(import_FieldsetLegend.default, { size: "sm" }, label && label.primary), label && label.secondary && /* @__PURE__ */ import_react.default.createElement(import_Hint.
|
|
55
|
+
return /* @__PURE__ */ import_react.default.createElement(import_FieldContainer.default, { error: !!error, ...layout }, /* @__PURE__ */ import_react.default.createElement(import_Fieldset.default, null, /* @__PURE__ */ import_react.default.createElement(import_FieldsetLegend.default, { size: "sm" }, label && label.primary), label && label.secondary && /* @__PURE__ */ import_react.default.createElement(import_Hint.Hint, null, t(label.secondary)), error && /* @__PURE__ */ import_react.default.createElement(import_ErrorMessage.ErrorMessage, { id: `${name}-error` }, t(errorMessage, errorContext)), children, label && label.hint && /* @__PURE__ */ import_react.default.createElement(import_Hint.Hint, { size: "sm" }, label.hint)));
|
|
56
56
|
} else {
|
|
57
|
-
return /* @__PURE__ */ import_react.default.createElement(import_FieldContainer.default, { error: !!error, ...layout }, /* @__PURE__ */ import_react.default.createElement(import_LabelContainer.default, null, label && /* @__PURE__ */ import_react.default.createElement(import_Label.default, { label }), error && /* @__PURE__ */ import_react.default.createElement(import_ErrorMessage.ErrorMessage, { id: `${name}-error` }, t(errorMessage, errorContext)), children));
|
|
57
|
+
return /* @__PURE__ */ import_react.default.createElement(import_FieldContainer.default, { error: !!error, ...layout }, /* @__PURE__ */ import_react.default.createElement(import_LabelContainer.default, null, label && /* @__PURE__ */ import_react.default.createElement(import_Label.default, { label }), error && /* @__PURE__ */ import_react.default.createElement(import_ErrorMessage.ErrorMessage, { id: `${name}-error` }, t(errorMessage, errorContext)), children, label && label.hint && /* @__PURE__ */ import_react.default.createElement(import_Hint.Hint, { size: "sm" }, label.hint)));
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
var FieldBaseContainer_default = FieldBaseContainer;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Field/FieldBaseContainer.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport { FieldContainerProps } from '@digigov/form/Field/types';\nimport Label from '@digigov/form/inputs/Label';\nimport {ErrorMessage} from '@digigov/react-core/ErrorMessage';\nimport FieldContainer from '@digigov/react-core/FieldContainer';\nimport CoreFieldset from '@digigov/react-core/Fieldset';\nimport FieldsetLegend from '@digigov/react-core/FieldsetLegend';\nimport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,mBAAkB;AAClB,
|
|
6
|
-
"names": ["React", "FieldContainer", "CoreFieldset", "FieldsetLegend", "
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { FieldContainerProps } from '@digigov/form/Field/types';\nimport Label from '@digigov/form/inputs/Label';\nimport { ErrorMessage } from '@digigov/react-core/ErrorMessage';\nimport FieldContainer from '@digigov/react-core/FieldContainer';\nimport CoreFieldset from '@digigov/react-core/Fieldset';\nimport FieldsetLegend from '@digigov/react-core/FieldsetLegend';\nimport LabelContainer from '@digigov/react-core/LabelContainer';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport { Hint } from '@digigov/ui/typography/Hint';\n\nexport const FieldBaseContainer: React.FC<FieldContainerProps> = ({\n name,\n wrapper,\n label,\n children,\n error,\n layout,\n}) => {\n const { t } = useTranslation();\n const errorMessage = error?.message.key\n ? error.message.key\n : error?.message || '';\n const errorContext = error?.message.context || {};\n if (wrapper === 'fieldset') {\n return (\n <FieldContainer error={!!error} {...layout}>\n <CoreFieldset>\n <FieldsetLegend size=\"sm\">{label && label.primary}</FieldsetLegend>\n {label && label.secondary && <Hint>{t(label.secondary)}</Hint>}\n {error && (\n <ErrorMessage id={`${name}-error`}>\n {t(errorMessage, errorContext)}\n </ErrorMessage>\n )}\n {children}\n {label && label.hint && <Hint size=\"sm\">{label.hint}</Hint>}\n </CoreFieldset>\n </FieldContainer>\n );\n } else {\n return (\n <FieldContainer error={!!error} {...layout}>\n <LabelContainer>\n {label && <Label label={label} />}\n {error && (\n <ErrorMessage id={`${name}-error`}>\n {t(errorMessage, errorContext)}\n </ErrorMessage>\n )}\n {children}\n {label && label.hint && <Hint size=\"sm\">{label.hint}</Hint>}\n </LabelContainer>\n </FieldContainer>\n );\n }\n};\n\nexport default FieldBaseContainer;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,mBAAkB;AAClB,0BAA6B;AAC7B,4BAA2B;AAC3B,sBAAyB;AACzB,4BAA2B;AAC3B,4BAA2B;AAC3B,kBAA+B;AAC/B,kBAAqB;AAEd,MAAM,qBAAoD,CAAC;AAAA,EAChE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,EAAE,QAAI,4BAAe;AAC7B,QAAM,eAAe,OAAO,QAAQ,MAChC,MAAM,QAAQ,MACd,OAAO,WAAW;AACtB,QAAM,eAAe,OAAO,QAAQ,WAAW,CAAC;AAChD,MAAI,YAAY,YAAY;AAC1B,WACE,6BAAAA,QAAA,cAAC,sBAAAC,SAAA,EAAe,OAAO,CAAC,CAAC,OAAQ,GAAG,UAClC,6BAAAD,QAAA,cAAC,gBAAAE,SAAA,MACC,6BAAAF,QAAA,cAAC,sBAAAG,SAAA,EAAe,MAAK,QAAM,SAAS,MAAM,OAAQ,GACjD,SAAS,MAAM,aAAa,6BAAAH,QAAA,cAAC,wBAAM,EAAE,MAAM,SAAS,CAAE,GACtD,SACC,6BAAAA,QAAA,cAAC,oCAAa,IAAI,GAAG,IAAI,YACtB,EAAE,cAAc,YAAY,CAC/B,GAED,UACA,SAAS,MAAM,QAAQ,6BAAAA,QAAA,cAAC,oBAAK,MAAK,QAAM,MAAM,IAAK,CACtD,CACF;AAAA,EAEJ,OAAO;AACL,WACE,6BAAAA,QAAA,cAAC,sBAAAC,SAAA,EAAe,OAAO,CAAC,CAAC,OAAQ,GAAG,UAClC,6BAAAD,QAAA,cAAC,sBAAAI,SAAA,MACE,SAAS,6BAAAJ,QAAA,cAAC,aAAAK,SAAA,EAAM,OAAc,GAC9B,SACC,6BAAAL,QAAA,cAAC,oCAAa,IAAI,GAAG,IAAI,YACtB,EAAE,cAAc,YAAY,CAC/B,GAED,UACA,SAAS,MAAM,QAAQ,6BAAAA,QAAA,cAAC,oBAAK,MAAK,QAAM,MAAM,IAAK,CACtD,CACF;AAAA,EAEJ;AACF;AAEA,IAAO,6BAAQ;",
|
|
6
|
+
"names": ["React", "FieldContainer", "CoreFieldset", "FieldsetLegend", "LabelContainer", "Label"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Field/FieldConditional.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport { useWatch } from 'react-hook-form';\nimport { FieldBase } from '@digigov/form/Field/FieldBase';\nimport {\n ChildFieldMemoProps,\n FieldConditionalProps,\n} from '@digigov/form/Field/types';\nimport { evaluateFieldWithConditions } from '@digigov/form/Field/utils/evaluateFieldWithConditions';\n\nconst ChildFieldMemo = React.memo(\n function ChildField({\n dependencies,\n field,\n control,\n reset,\n register,\n error,\n Field
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { useWatch } from 'react-hook-form';\nimport { FieldBase } from '@digigov/form/Field/FieldBase';\nimport {\n ChildFieldMemoProps,\n FieldConditionalProps,\n} from '@digigov/form/Field/types';\nimport { evaluateFieldWithConditions } from '@digigov/form/Field/utils/evaluateFieldWithConditions';\n\nconst ChildFieldMemo = React.memo(\n function ChildField({\n dependencies,\n field,\n control,\n reset,\n register,\n error,\n Field,\n }: ChildFieldMemoProps) {\n const newField = evaluateFieldWithConditions(\n field,\n dependencies as FormData\n );\n return (\n <FieldBase\n {...newField}\n Field={Field}\n name={newField.key}\n reset={reset}\n control={control}\n register={register}\n error={error}\n />\n );\n },\n (prev, next) => {\n if (!prev || !prev.dependencies) {\n return false;\n }\n if (prev.error !== next.error) {\n return false;\n }\n for (const dep in next.dependencies) {\n if (next.dependencies[dep] !== prev.dependencies[dep]) {\n return false;\n }\n }\n return true;\n }\n);\n\nexport const FieldConditional: React.FC<FieldConditionalProps> = ({\n control,\n field,\n register,\n reset,\n error,\n Field,\n}) => {\n const dependencyKeys = Object.keys(field.condition);\n const dependencyValues = useWatch({\n name: dependencyKeys,\n control,\n });\n const variables = dependencyKeys.reduce(\n (data, fieldKey, index) => ({\n ...data,\n [fieldKey]: dependencyValues[index],\n }),\n {}\n );\n return (\n <ChildFieldMemo\n dependencies={variables}\n field={field}\n control={control}\n register={register}\n reset={reset}\n error={error}\n Field={Field}\n />\n );\n};\n\nexport default FieldConditional;\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,6BAAyB;AACzB,uBAA0B;AAK1B,yCAA4C;AAE5C,MAAM,iBAAiB,aAAAA,QAAM;AAAA,EAC3B,SAAS,WAAW;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAAwB;AACtB,UAAM,eAAW;AAAA,MACf;AAAA,MACA;AAAA,IACF;AACA,WACE,6BAAAA,QAAA;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ;AAAA,QACA,MAAM,SAAS;AAAA,QACf;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF;AAAA,EAEJ;AAAA,EACA,CAAC,MAAM,SAAS;AACd,QAAI,CAAC,QAAQ,CAAC,KAAK,cAAc;AAC/B,aAAO;AAAA,IACT;AACA,QAAI,KAAK,UAAU,KAAK,OAAO;AAC7B,aAAO;AAAA,IACT;AACA,eAAW,OAAO,KAAK,cAAc;AACnC,UAAI,KAAK,aAAa,GAAG,MAAM,KAAK,aAAa,GAAG,GAAG;AACrD,eAAO;AAAA,MACT;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;AAEO,MAAM,mBAAoD,CAAC;AAAA,EAChE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,iBAAiB,OAAO,KAAK,MAAM,SAAS;AAClD,QAAM,uBAAmB,iCAAS;AAAA,IAChC,MAAM;AAAA,IACN;AAAA,EACF,CAAC;AACD,QAAM,YAAY,eAAe;AAAA,IAC/B,CAAC,MAAM,UAAU,WAAW;AAAA,MAC1B,GAAG;AAAA,MACH,CAAC,QAAQ,GAAG,iBAAiB,KAAK;AAAA,IACpC;AAAA,IACA,CAAC;AAAA,EACH;AACA,SACE,6BAAAA,QAAA;AAAA,IAAC;AAAA;AAAA,MACC,cAAc;AAAA,MACd;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,2BAAQ;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
package/cjs/Field/index.js
CHANGED
package/cjs/Field/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Field/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useMemo } from 'react';\nimport { FieldBase } from '@digigov/form/Field/FieldBase';\nimport FieldConditional from '@digigov/form/Field/FieldConditional';\nimport {\n FieldWithCondition,\n CalculatedField,\n FieldProps,\n} from '@digigov/form/Field/types';\nimport {\n FIELD_COMPONENTS,\n ALTERNATIVE_COMPONENTS,\n} from '@digigov/form/Field/utils';\nimport { calculateField } from '@digigov/form/Field/utils/calculateField';\nimport { useField } from '@digigov/form/Field/utils/useField';\nimport FieldArray from '@digigov/form/FieldArray';\nimport Multiplicity from '@digigov/form/MultiplicityField';\nexport const Field: React.FC<FieldProps> = ({\n name,\n disabled,\n children,\n ...customField\n}) => {\n const {\n field,\n control,\n register,\n reset,\n error,\n componentRegistry,\n formState,\n setValue,\n getValues,\n unregister,\n trigger,\n clearErrors,\n } = useField(name, customField?.type ? customField : null);\n const calculatedField: CalculatedField = useMemo(\n () =>\n calculateField(\n children,\n field,\n {\n ...FIELD_COMPONENTS,\n ...componentRegistry,\n },\n ALTERNATIVE_COMPONENTS\n ),\n [field]\n );\n\n if (calculatedField.condition) {\n return (\n <FieldConditional\n control={control}\n reset={reset}\n register={register}\n field={calculatedField as FieldWithCondition}\n error={error}\n Field={Field}\n />\n );\n }\n if (calculatedField.type === 'array' && !calculatedField.multiplicity) {\n calculatedField.name = name;\n return (\n <FieldArray\n control={control}\n register={register}\n error={error}\n formState={formState}\n Field={Field}\n {...calculatedField}\n />\n );\n }\n if (\n calculatedField.type === 'array' &&\n calculatedField.multiplicity === true\n ) {\n calculatedField.name = name;\n return (\n <Multiplicity\n control={control}\n register={register}\n trigger={trigger}\n clearErrors={clearErrors}\n error={error}\n formState={formState}\n setValue={setValue}\n getValues={getValues}\n unregister={unregister}\n Field={Field}\n {...calculatedField}\n />\n );\n }\n return (\n <FieldBase\n {...calculatedField}\n name={name}\n disabled={disabled}\n control={control}\n register={register}\n reset={reset}\n error={error}\n Field={Field}\n />\n );\n};\n\nexport default Field;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA+B;AAC/B,uBAA0B;AAC1B,8BAA6B;AAM7B,mBAGO;AACP,4BAA+B;AAC/B,sBAAyB;AACzB,wBAAuB;AACvB,+BAAyB;AAClB,MAAM,QAA8B,CAAC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,0BAAS,MAAM,aAAa,OAAO,cAAc,IAAI;AACzD,QAAM,sBAAmC;AAAA,IACvC,UACE;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,QACE,GAAG;AAAA,QACH,GAAG;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,IACF,CAAC,KAAK;AAAA,EACR;AAEA,MAAI,gBAAgB,WAAW;AAC7B,WACE,6BAAAA,QAAA;AAAA,MAAC,wBAAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAO;AAAA,QACP;AAAA,QACA;AAAA;AAAA,IACF;AAAA,EAEJ;AACA,MAAI,gBAAgB,SAAS,WAAW,CAAC,gBAAgB,cAAc;AACrE,oBAAgB,OAAO;AACvB,WACE,6BAAAD,QAAA;AAAA,MAAC,kBAAAE;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACC,GAAG;AAAA;AAAA,IACN;AAAA,EAEJ;AACA,MACE,gBAAgB,SAAS,WACzB,gBAAgB,iBAAiB,MACjC;AACA,oBAAgB,OAAO;AACvB,WACE,6BAAAF,QAAA;AAAA,MAAC,yBAAAG;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACC,GAAG;AAAA;AAAA,IACN;AAAA,EAEJ;AACA,SACE,6BAAAH,QAAA;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,gBAAQ;",
|
|
4
|
+
"sourcesContent": ["import React, { useMemo } from 'react';\nimport { FieldBase } from '@digigov/form/Field/FieldBase';\nimport FieldConditional from '@digigov/form/Field/FieldConditional';\nimport {\n FieldWithCondition,\n CalculatedField,\n FieldProps,\n} from '@digigov/form/Field/types';\nimport {\n FIELD_COMPONENTS,\n ALTERNATIVE_COMPONENTS,\n} from '@digigov/form/Field/utils';\nimport { calculateField } from '@digigov/form/Field/utils/calculateField';\nimport { useField } from '@digigov/form/Field/utils/useField';\nimport FieldArray from '@digigov/form/FieldArray';\nimport Multiplicity from '@digigov/form/MultiplicityField';\nexport const Field: React.FC<FieldProps> = ({\n name,\n disabled,\n children,\n ...customField\n}) => {\n const {\n field,\n control,\n register,\n reset,\n error,\n componentRegistry,\n formState,\n setValue,\n getValues,\n unregister,\n trigger,\n clearErrors,\n } = useField(name, customField?.type ? customField : null);\n const calculatedField: CalculatedField = useMemo(\n () =>\n calculateField(\n children,\n field,\n {\n ...FIELD_COMPONENTS,\n ...componentRegistry,\n },\n ALTERNATIVE_COMPONENTS\n ),\n [field]\n );\n\n if (calculatedField.condition) {\n return (\n <FieldConditional\n control={control}\n reset={reset}\n register={register}\n field={calculatedField as FieldWithCondition}\n error={error}\n Field={Field}\n />\n );\n }\n if (calculatedField.type === 'array' && !calculatedField.multiplicity) {\n calculatedField.name = name;\n return (\n <FieldArray\n control={control}\n trigger={trigger}\n register={register}\n clearErrors={clearErrors}\n error={error}\n getValues={getValues}\n setValue={setValue}\n formState={formState}\n Field={Field}\n reset={reset}\n {...calculatedField}\n />\n );\n }\n if (\n calculatedField.type === 'array' &&\n calculatedField.multiplicity === true\n ) {\n calculatedField.name = name;\n return (\n <Multiplicity\n control={control}\n register={register}\n trigger={trigger}\n clearErrors={clearErrors}\n error={error}\n formState={formState}\n setValue={setValue}\n getValues={getValues}\n unregister={unregister}\n Field={Field}\n {...calculatedField}\n />\n );\n }\n return (\n <FieldBase\n {...calculatedField}\n name={name}\n disabled={disabled}\n control={control}\n register={register}\n reset={reset}\n error={error}\n Field={Field}\n />\n );\n};\n\nexport default Field;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA+B;AAC/B,uBAA0B;AAC1B,8BAA6B;AAM7B,mBAGO;AACP,4BAA+B;AAC/B,sBAAyB;AACzB,wBAAuB;AACvB,+BAAyB;AAClB,MAAM,QAA8B,CAAC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,0BAAS,MAAM,aAAa,OAAO,cAAc,IAAI;AACzD,QAAM,sBAAmC;AAAA,IACvC,UACE;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,QACE,GAAG;AAAA,QACH,GAAG;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,IACF,CAAC,KAAK;AAAA,EACR;AAEA,MAAI,gBAAgB,WAAW;AAC7B,WACE,6BAAAA,QAAA;AAAA,MAAC,wBAAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAO;AAAA,QACP;AAAA,QACA;AAAA;AAAA,IACF;AAAA,EAEJ;AACA,MAAI,gBAAgB,SAAS,WAAW,CAAC,gBAAgB,cAAc;AACrE,oBAAgB,OAAO;AACvB,WACE,6BAAAD,QAAA;AAAA,MAAC,kBAAAE;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACC,GAAG;AAAA;AAAA,IACN;AAAA,EAEJ;AACA,MACE,gBAAgB,SAAS,WACzB,gBAAgB,iBAAiB,MACjC;AACA,oBAAgB,OAAO;AACvB,WACE,6BAAAF,QAAA;AAAA,MAAC,yBAAAG;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACC,GAAG;AAAA;AAAA,IACN;AAAA,EAEJ;AACA,SACE,6BAAAH,QAAA;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,gBAAQ;",
|
|
6
6
|
"names": ["React", "FieldConditional", "FieldArray", "Multiplicity"]
|
|
7
7
|
}
|
package/cjs/Field/types.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Field/types.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport { ErrorOption, UseFormReturn, UseFormProps } from 'react-hook-form';\nimport { ValidatorSchema } from '@digigov/form/validators/types';\nimport { GridProps } from '@digigov/ui/layouts/Grid';\n\nexport
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { ErrorOption, UseFormReturn, UseFormProps } from 'react-hook-form';\nimport { ValidatorSchema } from '@digigov/form/validators/types';\nimport { GridProps } from '@digigov/ui/layouts/Grid';\n\nexport interface FieldLabelProps {\n primary?: string;\n secondary?: string;\n hint?: string;\n}\n\nexport interface FieldSpec {\n key: string; // !TODO rename key to name;\n type?:\n | 'int'\n | 'string'\n | 'text'\n | 'boolean'\n | 'email'\n | 'uuid4'\n | 'choice:multiple'\n | 'choice:single'\n | 'mobile_phone'\n | 'date'\n | 'datetime'\n | 'otp'\n | 'afm'\n | 'iban'\n | 'file'\n | 'image'\n | 'postal_code'\n | 'phone_number'\n | 'array'\n | 'object';\n component?: any;\n autoComplete?: string;\n maxLength?: number;\n condition?: Record<string, FieldCondition>;\n controlled?: boolean;\n label?: FieldLabelProps;\n extra?: Record<string, any>;\n editable?: boolean;\n variant?: 'inline' | 'dialog';\n required?: boolean;\n enabled?: boolean;\n disabled?: boolean;\n layout?: Record<\n string,\n | GridProps['xs']\n | GridProps['sm']\n | GridProps['md']\n | GridProps['lg']\n | GridProps['xl']\n >;\n validators?: ValidatorSchema[];\n wrapper?: 'label' | 'fieldset';\n maxWidth?: string;\n maxHeight?: string;\n width?: string;\n}\n\nexport interface FieldCondition {\n is: string | string[] | number | number[] | boolean | boolean[];\n then?: Partial<FieldSpec>;\n else?: Partial<FieldSpec>;\n}\nexport interface ChildFieldMemoProps extends FieldConditionalProps {\n dependencies: FormData;\n}\nexport type FormData = UseFormProps['defaultValues'];\n\nexport interface FieldWithCondition extends Omit<CalculatedField, 'condition'> {\n condition: Record<string, FieldCondition>;\n}\n\nexport interface FieldConditionalProps {\n field: FieldWithCondition;\n control: UseFormReturn['control'];\n register: UseFormReturn['register'];\n reset: UseFormReturn['reset'];\n error?: ErrorOption;\n Field: React.FC<FieldProps>;\n}\n\nexport interface FieldComponentItem {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n component: any;\n controlled?: boolean;\n wrapper?: FieldSpec['wrapper'];\n}\n\nexport interface FieldContainerProps {\n name?: FieldSpec['key'];\n layout?: FieldSpec['layout'];\n label?: FieldSpec['label'];\n error?: ErrorOption | Record<string, any>;\n children?: React.ReactNode;\n wrapper?: FieldSpec['wrapper'];\n}\n\nexport type FieldComponentRegistry = Record<string, FieldComponentItem>;\n\nexport type OmittedFieldSpec = Omit<FieldSpec, 'component'>;\n\nexport type UnknownValue = never | never[];\n\nexport interface ControlledFieldProps {\n type?: string;\n value: UnknownValue;\n onChange: (v: UnknownValue) => void;\n defaultValue?: UnknownValue;\n onBlur?: (e: Event) => void;\n extra?: never;\n error?: boolean;\n name?: string;\n disabled?: boolean;\n Field: React.FC<FieldProps>;\n}\n\nexport interface UncontrolledFieldProps {\n name: string;\n register: FieldBaseProps['register'];\n control?: FieldBaseProps['control'];\n error?: boolean;\n extra?: Record<string, never>;\n type?: string;\n disabled?: boolean;\n Field: React.FC<FieldProps>;\n}\n\nexport interface CalculatedField extends OmittedFieldSpec {\n name: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n component: any;\n defaultValue?: never;\n error?: ErrorOption;\n wrapper?: FieldComponentItem['wrapper'];\n multiplicity?: boolean;\n}\n\nexport interface FieldBaseProps extends CalculatedField {\n control: UseFormReturn['control'];\n register: UseFormReturn['register'];\n reset: UseFormReturn['reset'];\n Field: React.FC<FieldProps>;\n}\n\nexport interface FieldProps extends FieldSpec {\n name: string;\n children?: React.ReactNode;\n}\n\nexport interface UseFieldProps {\n field: FieldSpec;\n control: FieldBaseProps['control'];\n register: FieldBaseProps['register'];\n reset: FieldBaseProps['reset'];\n watch: UseFormReturn['watch'];\n formState: UseFormReturn['formState'];\n getFieldState: UseFormReturn['getFieldState'];\n setValue: UseFormReturn['setValue'];\n getValues: UseFormReturn['getValues'];\n unregister: UseFormReturn['unregister'];\n trigger: UseFormReturn['trigger'];\n clearErrors: UseFormReturn['clearErrors'];\n error?: ErrorOption;\n componentRegistry?: FieldComponentRegistry;\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/cjs/Field/utils/index.js
CHANGED
|
@@ -35,6 +35,7 @@ module.exports = __toCommonJS(utils_exports);
|
|
|
35
35
|
var import_AutoCompleteInput = __toESM(require("@digigov/form/inputs/AutoCompleteInput"));
|
|
36
36
|
var import_Checkboxes = __toESM(require("@digigov/form/inputs/Checkboxes"));
|
|
37
37
|
var import_DateInput = __toESM(require("@digigov/form/inputs/DateInput"));
|
|
38
|
+
var import_DateTimeInput = __toESM(require("@digigov/form/inputs/DateTimeInput"));
|
|
38
39
|
var import_FileInput = __toESM(require("@digigov/form/inputs/FileInput"));
|
|
39
40
|
var import_ImageInput = __toESM(require("@digigov/form/inputs/ImageInput"));
|
|
40
41
|
var import_Input = __toESM(require("@digigov/form/inputs/Input"));
|
|
@@ -61,6 +62,11 @@ const FIELD_COMPONENTS = {
|
|
|
61
62
|
controlled: true,
|
|
62
63
|
component: import_DateInput.default
|
|
63
64
|
},
|
|
65
|
+
datetime: {
|
|
66
|
+
wrapper: "fieldset",
|
|
67
|
+
controlled: true,
|
|
68
|
+
component: import_DateTimeInput.default
|
|
69
|
+
},
|
|
64
70
|
otp: {
|
|
65
71
|
wrapper: "fieldset",
|
|
66
72
|
controlled: true,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/Field/utils/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { FieldComponentRegistry } from '@digigov/form/Field/types';\nimport AutoCompleteInput from '@digigov/form/inputs/AutoCompleteInput';\nimport Checkboxes from '@digigov/form/inputs/Checkboxes';\nimport DateInput from '@digigov/form/inputs/DateInput';\nimport FileInput from '@digigov/form/inputs/FileInput';\nimport ImageInput from '@digigov/form/inputs/ImageInput';\nimport Input from '@digigov/form/inputs/Input';\nimport OtpInput from '@digigov/form/inputs/OtpInput';\nimport Radio, { ControlledRadioButtonsGroup } from '@digigov/form/inputs/Radio';\nimport Select from '@digigov/form/inputs/Select';\n\nexport const FIELD_COMPONENTS: FieldComponentRegistry = {\n text: {\n component: Input,\n },\n string: {\n component: Input,\n },\n file: {\n wrapper: 'fieldset',\n component: FileInput,\n },\n image: {\n wrapper: 'fieldset',\n component: ImageInput,\n },\n date: {\n wrapper: 'fieldset',\n controlled: true,\n component: DateInput,\n },\n otp: {\n wrapper: 'fieldset',\n controlled: true,\n component: OtpInput,\n },\n 'choice:multiple': {\n wrapper: 'fieldset',\n controlled: true,\n component: Checkboxes,\n },\n 'choice:single': {\n wrapper: 'fieldset',\n controlled: false,\n component: Radio,\n },\n};\n\nexport const ALTERNATIVE_COMPONENTS: FieldComponentRegistry = {\n Select: {\n component: Select,\n controlled: false,\n },\n AutoComplete: {\n component: AutoCompleteInput,\n controlled: true,\n wrapper: 'fieldset',\n },\n};\n\nexport const CONTROLLED_FIELD_COMPONENTS: FieldComponentRegistry = {\n ...FIELD_COMPONENTS,\n 'choice:single': {\n wrapper: 'fieldset',\n controlled: true,\n component: ControlledRadioButtonsGroup,\n },\n text: {\n component: Input,\n controlled: true,\n },\n string: {\n component: Input,\n controlled: true,\n },\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,+BAA8B;AAC9B,wBAAuB;AACvB,uBAAsB;AACtB,uBAAsB;AACtB,wBAAuB;AACvB,mBAAkB;AAClB,sBAAqB;AACrB,mBAAmD;AACnD,oBAAmB;AAEZ,MAAM,mBAA2C;AAAA,EACtD,MAAM;AAAA,IACJ,WAAW,aAAAA;AAAA,EACb;AAAA,EACA,QAAQ;AAAA,IACN,WAAW,aAAAA;AAAA,EACb;AAAA,EACA,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,WAAW,iBAAAC;AAAA,EACb;AAAA,EACA,OAAO;AAAA,IACL,SAAS;AAAA,IACT,WAAW,kBAAAC;AAAA,EACb;AAAA,EACA,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,WAAW,iBAAAC;AAAA,EACb;AAAA,EACA,KAAK;AAAA,IACH,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,WAAW,gBAAAC;AAAA,EACb;AAAA,EACA,mBAAmB;AAAA,IACjB,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,WAAW,kBAAAC;AAAA,EACb;AAAA,EACA,iBAAiB;AAAA,IACf,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,WAAW,aAAAC;AAAA,EACb;AACF;AAEO,MAAM,yBAAiD;AAAA,EAC5D,QAAQ;AAAA,IACN,WAAW,cAAAC;AAAA,IACX,YAAY;AAAA,EACd;AAAA,EACA,cAAc;AAAA,IACZ,WAAW,yBAAAC;AAAA,IACX,YAAY;AAAA,IACZ,SAAS;AAAA,EACX;AACF;AAEO,MAAM,8BAAsD;AAAA,EACjE,GAAG;AAAA,EACH,iBAAiB;AAAA,IACf,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,MAAM;AAAA,IACJ,WAAW,
|
|
6
|
-
"names": ["Input", "FileInput", "ImageInput", "DateInput", "OtpInput", "Checkboxes", "Radio", "Select", "AutoCompleteInput"]
|
|
4
|
+
"sourcesContent": ["import { FieldComponentRegistry } from '@digigov/form/Field/types';\nimport AutoCompleteInput from '@digigov/form/inputs/AutoCompleteInput';\nimport Checkboxes from '@digigov/form/inputs/Checkboxes';\nimport DateInput from '@digigov/form/inputs/DateInput';\nimport DateTimeInput from '@digigov/form/inputs/DateTimeInput';\nimport FileInput from '@digigov/form/inputs/FileInput';\nimport ImageInput from '@digigov/form/inputs/ImageInput';\nimport Input from '@digigov/form/inputs/Input';\nimport OtpInput from '@digigov/form/inputs/OtpInput';\nimport Radio, { ControlledRadioButtonsGroup } from '@digigov/form/inputs/Radio';\nimport Select from '@digigov/form/inputs/Select';\n\nexport const FIELD_COMPONENTS: FieldComponentRegistry = {\n text: {\n component: Input,\n },\n string: {\n component: Input,\n },\n file: {\n wrapper: 'fieldset',\n component: FileInput,\n },\n image: {\n wrapper: 'fieldset',\n component: ImageInput,\n },\n date: {\n wrapper: 'fieldset',\n controlled: true,\n component: DateInput,\n },\n datetime: {\n wrapper: 'fieldset',\n controlled: true,\n component: DateTimeInput,\n },\n otp: {\n wrapper: 'fieldset',\n controlled: true,\n component: OtpInput,\n },\n 'choice:multiple': {\n wrapper: 'fieldset',\n controlled: true,\n component: Checkboxes,\n },\n 'choice:single': {\n wrapper: 'fieldset',\n controlled: false,\n component: Radio,\n },\n};\n\nexport const ALTERNATIVE_COMPONENTS: FieldComponentRegistry = {\n Select: {\n component: Select,\n controlled: false,\n },\n AutoComplete: {\n component: AutoCompleteInput,\n controlled: true,\n wrapper: 'fieldset',\n },\n};\n\nexport const CONTROLLED_FIELD_COMPONENTS: FieldComponentRegistry = {\n ...FIELD_COMPONENTS,\n 'choice:single': {\n wrapper: 'fieldset',\n controlled: true,\n component: ControlledRadioButtonsGroup,\n },\n text: {\n component: Input,\n controlled: true,\n },\n string: {\n component: Input,\n controlled: true,\n },\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,+BAA8B;AAC9B,wBAAuB;AACvB,uBAAsB;AACtB,2BAA0B;AAC1B,uBAAsB;AACtB,wBAAuB;AACvB,mBAAkB;AAClB,sBAAqB;AACrB,mBAAmD;AACnD,oBAAmB;AAEZ,MAAM,mBAA2C;AAAA,EACtD,MAAM;AAAA,IACJ,WAAW,aAAAA;AAAA,EACb;AAAA,EACA,QAAQ;AAAA,IACN,WAAW,aAAAA;AAAA,EACb;AAAA,EACA,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,WAAW,iBAAAC;AAAA,EACb;AAAA,EACA,OAAO;AAAA,IACL,SAAS;AAAA,IACT,WAAW,kBAAAC;AAAA,EACb;AAAA,EACA,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,WAAW,iBAAAC;AAAA,EACb;AAAA,EACA,UAAU;AAAA,IACR,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,WAAW,qBAAAC;AAAA,EACb;AAAA,EACA,KAAK;AAAA,IACH,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,WAAW,gBAAAC;AAAA,EACb;AAAA,EACA,mBAAmB;AAAA,IACjB,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,WAAW,kBAAAC;AAAA,EACb;AAAA,EACA,iBAAiB;AAAA,IACf,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,WAAW,aAAAC;AAAA,EACb;AACF;AAEO,MAAM,yBAAiD;AAAA,EAC5D,QAAQ;AAAA,IACN,WAAW,cAAAC;AAAA,IACX,YAAY;AAAA,EACd;AAAA,EACA,cAAc;AAAA,IACZ,WAAW,yBAAAC;AAAA,IACX,YAAY;AAAA,IACZ,SAAS;AAAA,EACX;AACF;AAEO,MAAM,8BAAsD;AAAA,EACjE,GAAG;AAAA,EACH,iBAAiB;AAAA,IACf,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,MAAM;AAAA,IACJ,WAAW,aAAAT;AAAA,IACX,YAAY;AAAA,EACd;AAAA,EACA,QAAQ;AAAA,IACN,WAAW,aAAAA;AAAA,IACX,YAAY;AAAA,EACd;AACF;",
|
|
6
|
+
"names": ["Input", "FileInput", "ImageInput", "DateInput", "DateTimeInput", "OtpInput", "Checkboxes", "Radio", "Select", "AutoCompleteInput"]
|
|
7
7
|
}
|
|
@@ -46,6 +46,12 @@ const useField = (name, customField) => {
|
|
|
46
46
|
https://devs.pages.grnet.gr/digigov/digigov-sdk/sdk-docs/forms/create-simple-form/
|
|
47
47
|
`);
|
|
48
48
|
}
|
|
49
|
+
let error = errors[name];
|
|
50
|
+
const nameIndexRegex = name.match(/^(.*?)\.(\d+)$/);
|
|
51
|
+
if (nameIndexRegex) {
|
|
52
|
+
const [, fieldArrayName, indexStr] = nameIndexRegex;
|
|
53
|
+
error = errors[fieldArrayName]?.[Number(indexStr)];
|
|
54
|
+
}
|
|
49
55
|
(0, import_react.useMemo)(
|
|
50
56
|
() => customField?.type && registerField({ ...customField, key: name }),
|
|
51
57
|
[customField, name, registerField]
|
|
@@ -64,7 +70,7 @@ const useField = (name, customField) => {
|
|
|
64
70
|
getValues,
|
|
65
71
|
unregister,
|
|
66
72
|
formState,
|
|
67
|
-
error
|
|
73
|
+
error
|
|
68
74
|
};
|
|
69
75
|
};
|
|
70
76
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/Field/utils/useField.ts"],
|
|
4
|
-
"sourcesContent": ["import { useContext, useMemo } from 'react';\nimport { FieldSpec, UseFieldProps } from '@digigov/form/Field/types';\nimport { FormContext } from '@digigov/form/FormContext';\n\nexport const useField = (\n name: string,\n customField: FieldSpec | null\n): UseFieldProps => {\n const {\n fieldsMap,\n control,\n register,\n reset,\n trigger,\n clearErrors,\n errors,\n registerField,\n watch,\n componentRegistry,\n getFieldState,\n setValue,\n getValues,\n unregister,\n formState,\n } = useContext(FormContext);\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAoC;AAEpC,yBAA4B;AAErB,MAAM,WAAW,CACtB,MACA,gBACkB;AAClB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,yBAAW,8BAAW;
|
|
4
|
+
"sourcesContent": ["import { useContext, useMemo } from 'react';\nimport { FieldSpec, UseFieldProps } from '@digigov/form/Field/types';\nimport { FormContext } from '@digigov/form/FormContext';\n\nexport const useField = (\n name: string,\n customField: FieldSpec | null\n): UseFieldProps => {\n const {\n fieldsMap,\n control,\n register,\n reset,\n trigger,\n clearErrors,\n errors,\n registerField,\n watch,\n componentRegistry,\n getFieldState,\n setValue,\n getValues,\n unregister,\n formState,\n } = useContext(FormContext);\n if (!registerField) {\n throw new Error(`\n You can't use the Field component without wrapping it in FormBuilder.\n https://devs.pages.grnet.gr/digigov/digigov-sdk/sdk-docs/forms/create-simple-form/\n `);\n }\n let error = errors[name];\n const nameIndexRegex = name.match(/^(.*?)\\.(\\d+)$/);\n if (nameIndexRegex) {\n const [, fieldArrayName, indexStr] = nameIndexRegex;\n error = errors[fieldArrayName]?.[Number(indexStr)];\n }\n useMemo(\n () => customField?.type && registerField({ ...customField, key: name }),\n [customField, name, registerField]\n );\n return {\n field: customField || fieldsMap[name],\n control,\n register,\n reset,\n trigger,\n watch,\n componentRegistry,\n getFieldState,\n setValue,\n clearErrors,\n getValues,\n unregister,\n formState,\n error,\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAoC;AAEpC,yBAA4B;AAErB,MAAM,WAAW,CACtB,MACA,gBACkB;AAClB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,yBAAW,8BAAW;AAC1B,MAAI,CAAC,eAAe;AAClB,UAAM,IAAI,MAAM;AAAA;AAAA;AAAA,KAGf;AAAA,EACH;AACA,MAAI,QAAQ,OAAO,IAAI;AACvB,QAAM,iBAAiB,KAAK,MAAM,gBAAgB;AAClD,MAAI,gBAAgB;AAClB,UAAM,CAAC,EAAE,gBAAgB,QAAQ,IAAI;AACrC,YAAQ,OAAO,cAAc,IAAI,OAAO,QAAQ,CAAC;AAAA,EACnD;AACA;AAAA,IACE,MAAM,aAAa,QAAQ,cAAc,EAAE,GAAG,aAAa,KAAK,KAAK,CAAC;AAAA,IACtE,CAAC,aAAa,MAAM,aAAa;AAAA,EACnC;AACA,SAAO;AAAA,IACL,OAAO,eAAe,UAAU,IAAI;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|