@digigov/form 1.0.0-rc.4 → 1.0.0-rc.5
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/{FieldBase.js → FieldBase/index.js} +19 -22
- package/{inputs/AutoComplete → Field/FieldBase}/package.json +1 -1
- package/Field/{FieldBaseContainer.js → FieldBaseContainer/index.js} +7 -10
- package/Field/FieldBaseContainer/package.json +6 -0
- package/Field/{FieldConditional.js → FieldConditional/index.js} +11 -14
- package/Field/FieldConditional/package.json +6 -0
- package/Field/index.js +19 -25
- package/Field/types/package.json +6 -0
- package/Field/types.d.ts +4 -4
- package/Field/{utils.js → utils/index.js} +33 -42
- package/Field/utils/package.json +6 -0
- package/FieldArray/FieldArray.stories/index.js +8 -0
- package/FieldArray/FieldArray.stories/package.json +6 -0
- package/FieldArray/__stories__/{Default.js → Default/index.js} +1 -3
- package/FieldArray/__stories__/Default/package.json +6 -0
- package/FieldArray/__stories__/Default.d.ts +1 -0
- package/FieldArray/__stories__/{WithExactLength.js → WithExactLength/index.js} +1 -3
- package/FieldArray/__stories__/WithExactLength/package.json +6 -0
- package/FieldArray/__stories__/WithExactLength.d.ts +1 -0
- package/FieldArray/index.js +16 -20
- package/FieldObject/index.js +17 -21
- package/Fieldset/{FieldsetWithContext.js → FieldsetWithContext/index.js} +8 -14
- package/Fieldset/FieldsetWithContext/package.json +6 -0
- package/Fieldset/index.js +3 -5
- package/Fieldset/types/package.json +6 -0
- package/Form.stories/package.json +6 -0
- package/FormBuilder/{FormBuilder.js → FormBuilder/index.js} +40 -48
- package/FormBuilder/FormBuilder/package.json +6 -0
- package/FormBuilder/FormBuilder.mdx +7 -7
- package/FormBuilder/FormBuilder.stories/index.js +7 -0
- package/FormBuilder/FormBuilder.stories/package.json +6 -0
- package/FormBuilder/__stories__/{Default.js → Default/index.js} +1 -3
- package/FormBuilder/__stories__/Default/package.json +6 -0
- package/FormBuilder/__stories__/Default.d.ts +1 -0
- package/FormBuilder/index.js +1 -1
- package/FormContext/package.json +6 -0
- package/MultiplicityField/MultiplicityField.stories/index.js +12 -0
- package/MultiplicityField/MultiplicityField.stories/package.json +6 -0
- package/MultiplicityField/__stories__/{Default.js → Default/index.js} +1 -3
- package/MultiplicityField/__stories__/Default/package.json +6 -0
- package/MultiplicityField/__stories__/Default.d.ts +1 -0
- package/MultiplicityField/__stories__/{PreviewDisplay.js → PreviewDisplay/index.js} +3 -14
- package/MultiplicityField/__stories__/PreviewDisplay/package.json +6 -0
- package/MultiplicityField/__stories__/PreviewDisplay.d.ts +1 -0
- package/MultiplicityField/__stories__/{WithExactLength.js → WithExactLength/index.js} +1 -3
- package/MultiplicityField/__stories__/WithExactLength/package.json +6 -0
- package/MultiplicityField/__stories__/WithExactLength.d.ts +1 -0
- package/MultiplicityField/__stories__/{WithMaxLength.js → WithMaxLength/index.js} +1 -3
- package/MultiplicityField/__stories__/WithMaxLength/package.json +6 -0
- package/MultiplicityField/__stories__/WithMaxLength.d.ts +1 -0
- package/MultiplicityField/__stories__/{WithMinAndMaxLength.js → WithMinAndMaxLength/index.js} +1 -3
- package/MultiplicityField/__stories__/WithMinAndMaxLength/package.json +6 -0
- package/MultiplicityField/__stories__/WithMinAndMaxLength.d.ts +1 -0
- package/MultiplicityField/__stories__/{WithMinLength.js → WithMinLength/index.js} +1 -3
- package/MultiplicityField/__stories__/WithMinLength/package.json +6 -0
- package/MultiplicityField/__stories__/WithMinLength.d.ts +1 -0
- package/MultiplicityField/add-objects/index.js +148 -0
- package/MultiplicityField/add-objects/package.json +6 -0
- package/MultiplicityField/index.d.ts +1 -1
- package/MultiplicityField/index.js +32 -38
- package/Questions/{Questions.js → Questions/index.js} +21 -30
- package/Questions/Questions/package.json +6 -0
- package/Questions/Questions.stories/index.js +7 -0
- package/Questions/Questions.stories/package.json +6 -0
- package/Questions/QuestionsContext/package.json +6 -0
- package/Questions/Step/{ReviewStep.js → ReviewStep/index.js} +11 -14
- package/Questions/Step/ReviewStep/package.json +6 -0
- package/Questions/Step/{Step.js → Step/index.js} +14 -21
- package/Questions/Step/Step/package.json +6 -0
- package/Questions/Step/{StepArrayReview.js → StepArrayReview/index.js} +8 -12
- package/Questions/Step/StepArrayReview/package.json +6 -0
- package/Questions/Step/StepContext/package.json +6 -0
- package/Questions/Step/{StepDescription.js → StepDescription/index.js} +5 -8
- package/Questions/Step/StepDescription/package.json +6 -0
- package/Questions/Step/{StepForm.js → StepForm/index.js} +11 -15
- package/Questions/Step/StepForm/package.json +6 -0
- package/Questions/Step/{StepQuote.js → StepQuote/index.js} +1 -2
- package/Questions/Step/StepQuote/package.json +6 -0
- package/Questions/Step/{StepTitle.js → StepTitle/index.js} +15 -18
- package/Questions/Step/StepTitle/package.json +6 -0
- package/Questions/Step/{getAddMoreFields.js → getAddMoreFields/index.js} +0 -1
- package/Questions/Step/getAddMoreFields/package.json +6 -0
- package/Questions/Step/index.js +12 -12
- package/Questions/Step/types/package.json +6 -0
- package/Questions/Step/types.d.ts +2 -2
- package/Questions/__stories__/{Default.js → Default/index.js} +4 -10
- package/Questions/__stories__/Default/package.json +6 -0
- package/Questions/__stories__/Default.d.ts +1 -0
- package/Questions/{getNextStep.js → getNextStep/index.js} +0 -3
- package/Questions/getNextStep/package.json +6 -0
- package/Questions/index.js +2 -2
- package/Questions/index.mdx +3 -3
- package/Questions/{index.spec.js → index.spec/index.js} +3 -6
- package/Questions/index.spec/package.json +6 -0
- package/Questions/types/package.json +6 -0
- package/cjs/Field/{FieldBase.js → FieldBase/index.js} +21 -34
- package/cjs/Field/{FieldBaseContainer.js → FieldBaseContainer/index.js} +16 -34
- package/cjs/Field/{FieldConditional.js → FieldConditional/index.js} +13 -28
- package/cjs/Field/index.js +23 -46
- package/cjs/Field/{utils.js → utils/index.js} +36 -64
- package/cjs/FieldArray/{FieldArray.stories.js → FieldArray.stories/index.js} +6 -13
- package/cjs/FieldArray/__stories__/{Default.js → Default/index.js} +10 -23
- package/cjs/FieldArray/__stories__/{WithExactLength.js → WithExactLength/index.js} +10 -23
- package/cjs/FieldArray/index.js +19 -38
- package/cjs/FieldObject/index.js +22 -41
- package/cjs/Fieldset/FieldsetWithContext/index.js +45 -0
- package/cjs/Fieldset/index.js +12 -32
- package/cjs/{Form.stories.js → Form.stories/index.js} +2 -3
- package/cjs/FormBuilder/{FormBuilder.js → FormBuilder/index.js} +47 -74
- package/cjs/FormBuilder/FormBuilder.mdx +7 -7
- package/cjs/FormBuilder/{FormBuilder.stories.js → FormBuilder.stories/index.js} +5 -10
- package/cjs/FormBuilder/__stories__/Default/index.js +36 -0
- package/cjs/FormBuilder/index.js +2 -5
- package/cjs/{FormContext.js → FormContext/index.js} +2 -5
- package/cjs/MultiplicityField/{MultiplicityField.stories.js → MultiplicityField.stories/index.js} +10 -25
- package/cjs/MultiplicityField/__stories__/{Default.js → Default/index.js} +10 -23
- package/cjs/MultiplicityField/__stories__/{PreviewDisplay.js → PreviewDisplay/index.js} +10 -34
- package/cjs/MultiplicityField/__stories__/{WithExactLength.js → WithExactLength/index.js} +10 -23
- package/cjs/MultiplicityField/__stories__/{WithMaxLength.js → WithMaxLength/index.js} +10 -23
- package/cjs/MultiplicityField/__stories__/{WithMinAndMaxLength.js → WithMinAndMaxLength/index.js} +10 -23
- package/cjs/MultiplicityField/__stories__/{WithMinLength.js → WithMinLength/index.js} +10 -23
- package/cjs/MultiplicityField/add-objects/index.js +155 -0
- package/cjs/MultiplicityField/index.js +38 -63
- package/cjs/Questions/Questions/index.js +85 -0
- package/cjs/Questions/{Questions.stories.js → Questions.stories/index.js} +5 -10
- package/cjs/Questions/{QuestionsContext.js → QuestionsContext/index.js} +2 -5
- package/cjs/Questions/Step/{ReviewStep.js → ReviewStep/index.js} +18 -37
- package/cjs/Questions/Step/{Step.js → Step/index.js} +18 -39
- package/cjs/Questions/Step/{StepArrayReview.js → StepArrayReview/index.js} +16 -39
- package/cjs/Questions/Step/{StepContext.js → StepContext/index.js} +2 -6
- package/cjs/Questions/Step/StepDescription/index.js +34 -0
- package/cjs/Questions/Step/StepForm/index.js +54 -0
- package/cjs/Questions/Step/{StepQuote.js → StepQuote/index.js} +4 -13
- package/cjs/Questions/Step/StepTitle/index.js +51 -0
- package/cjs/Questions/Step/{getAddMoreFields.js → getAddMoreFields/index.js} +2 -6
- package/cjs/Questions/Step/index.js +17 -44
- package/cjs/Questions/__stories__/{Default.js → Default/index.js} +22 -44
- package/cjs/Questions/{getNextStep.js → getNextStep/index.js} +0 -4
- package/cjs/Questions/index.js +3 -7
- package/cjs/Questions/index.mdx +3 -3
- package/cjs/Questions/index.spec/index.js +63 -0
- package/cjs/index.js +3 -9
- package/cjs/inputs/{AutoComplete/AutoComplete.stories.js → AutoCompleteInput/AutoComplete.stories/index.js} +7 -12
- package/cjs/inputs/AutoCompleteInput/__stories__/Default/index.js +56 -0
- package/cjs/inputs/{AutoComplete → AutoCompleteInput}/index.js +11 -27
- package/cjs/inputs/Checkboxes/{Checkboxes.stories.js → Checkboxes.stories/index.js} +7 -16
- package/cjs/inputs/Checkboxes/__stories__/{Conditional.js → Conditional/index.js} +8 -21
- package/cjs/inputs/Checkboxes/__stories__/Default/index.js +50 -0
- package/cjs/inputs/Checkboxes/__stories__/WithDivider/index.js +51 -0
- package/cjs/inputs/Checkboxes/index.js +30 -56
- package/cjs/inputs/DateInput/{DateInput.stories.js → DateInput.stories/index.js} +5 -10
- package/cjs/inputs/DateInput/__stories__/Default/index.js +33 -0
- package/cjs/inputs/DateInput/index.js +25 -65
- package/cjs/inputs/FileInput/{FileInput.stories.js → FileInput.stories/index.js} +5 -10
- package/cjs/inputs/FileInput/__stories__/Default/index.js +30 -0
- package/cjs/inputs/FileInput/index.js +22 -46
- package/cjs/inputs/ImageInput/ImageInput.stories/index.js +50 -0
- package/cjs/inputs/ImageInput/ImageInput.stories.playwright.json +77 -0
- package/cjs/inputs/ImageInput/__stories__/Default/index.js +38 -0
- package/cjs/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +46 -0
- package/cjs/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +43 -0
- package/cjs/inputs/ImageInput/index.js +86 -0
- package/cjs/inputs/Input/{Input.stories.js → Input.stories/index.js} +13 -34
- package/cjs/inputs/Input/__stories__/AFM/index.js +32 -0
- package/cjs/inputs/Input/__stories__/Boolean/index.js +33 -0
- package/cjs/inputs/Input/__stories__/Default/index.js +33 -0
- package/cjs/inputs/Input/__stories__/IBAN/index.js +33 -0
- package/cjs/inputs/Input/__stories__/Integer/index.js +41 -0
- package/cjs/inputs/Input/__stories__/MobilePhone/index.js +32 -0
- package/cjs/inputs/Input/__stories__/PhoneNumber/index.js +32 -0
- package/cjs/inputs/Input/__stories__/PostalCode/index.js +35 -0
- package/cjs/inputs/Input/__stories__/TextWithCharacterLimit/index.js +39 -0
- package/cjs/inputs/Input/index.js +21 -41
- package/cjs/inputs/Label/{Label.stories.js → Label.stories/index.js} +5 -10
- package/cjs/inputs/Label/__stories__/Default/index.js +37 -0
- package/cjs/inputs/Label/index.js +8 -20
- package/cjs/inputs/OtpInput/{OtpInput.stories.js → OtpInput.stories/index.js} +5 -10
- package/cjs/inputs/OtpInput/__stories__/Default/index.js +39 -0
- package/cjs/inputs/OtpInput/index.js +17 -49
- package/cjs/inputs/Radio/{Radio.stories.js → Radio.stories/index.js} +7 -16
- package/cjs/inputs/Radio/__stories__/{Conditional.js → Conditional/index.js} +8 -21
- package/cjs/inputs/Radio/__stories__/Default/index.js +55 -0
- package/cjs/inputs/Radio/__stories__/WithDivider/index.js +56 -0
- package/cjs/inputs/Radio/index.js +22 -40
- package/cjs/inputs/Select/{Select.stories.js → Select.stories/index.js} +5 -10
- package/cjs/inputs/Select/__stories__/Default/index.js +61 -0
- package/cjs/inputs/Select/index.js +10 -21
- package/cjs/inputs/index.js +15 -17
- package/cjs/{internal.js → internal/index.js} +22 -65
- package/cjs/{registry.js → registry/index.js} +68 -129
- package/cjs/utils/index.js +87 -0
- package/cjs/validators/index.js +14 -35
- package/cjs/validators/utils/{afm.js → afm/index.js} +2 -9
- package/cjs/validators/utils/{file.js → file/index.js} +8 -19
- package/cjs/validators/utils/{iban.js → iban/index.js} +1 -12
- package/cjs/validators/utils/image/index.js +126 -0
- package/cjs/validators/utils/index.js +25 -50
- package/cjs/validators/utils/{int.js → int/index.js} +2 -7
- package/cjs/validators/utils/{number.js → number/index.js} +2 -7
- package/cjs/validators/utils/{otp.js → otp/index.js} +2 -7
- package/cjs/validators/utils/{phone.js → phone/index.js} +7 -32
- package/cjs/validators/utils/{postal_code.js → postal_code/index.js} +2 -8
- package/cjs/validators/utils/{text_limit.js → text_limit/index.js} +2 -13
- package/cjs/validators/utils/{uuid4.js → uuid4/index.js} +2 -7
- package/cjs/validators/{validators.spec.js → validators.spec/index.js} +1 -2
- package/index.js +3 -3
- package/inputs/AutoCompleteInput/AutoComplete.stories/index.js +7 -0
- package/inputs/AutoCompleteInput/AutoComplete.stories/package.json +6 -0
- package/inputs/{AutoComplete → AutoCompleteInput}/AutoComplete.stories.d.ts +2 -2
- package/inputs/{AutoComplete/__stories__/Default.js → AutoCompleteInput/__stories__/Default/index.js} +2 -5
- package/inputs/AutoCompleteInput/__stories__/Default/package.json +6 -0
- package/inputs/{AutoComplete → AutoCompleteInput}/__stories__/Default.d.ts +1 -0
- package/inputs/AutoCompleteInput/index.d.ts +14 -0
- package/inputs/{AutoComplete → AutoCompleteInput}/index.js +7 -10
- package/inputs/AutoCompleteInput/package.json +6 -0
- package/inputs/Checkboxes/Checkboxes.stories/index.js +9 -0
- package/inputs/Checkboxes/Checkboxes.stories/package.json +6 -0
- package/inputs/Checkboxes/__stories__/{Conditional.js → Conditional/index.js} +1 -4
- package/inputs/Checkboxes/__stories__/Conditional/package.json +6 -0
- package/inputs/Checkboxes/__stories__/Conditional.d.ts +1 -0
- package/inputs/Checkboxes/__stories__/{Default.js → Default/index.js} +1 -3
- package/inputs/Checkboxes/__stories__/Default/package.json +6 -0
- package/inputs/Checkboxes/__stories__/Default.d.ts +1 -0
- package/inputs/Checkboxes/__stories__/{WithDivider.js → WithDivider/index.js} +1 -3
- package/inputs/Checkboxes/__stories__/WithDivider/package.json +6 -0
- package/inputs/Checkboxes/__stories__/WithDivider.d.ts +1 -0
- package/inputs/Checkboxes/index.js +21 -30
- package/inputs/DateInput/DateInput.stories/index.js +7 -0
- package/inputs/DateInput/DateInput.stories/package.json +6 -0
- package/inputs/DateInput/__stories__/{Default.js → Default/index.js} +1 -3
- package/inputs/DateInput/__stories__/Default/package.json +6 -0
- package/inputs/DateInput/__stories__/Default.d.ts +1 -0
- package/inputs/DateInput/index.d.ts +1 -0
- package/inputs/DateInput/index.js +18 -42
- package/inputs/FileInput/FileInput.stories/index.js +7 -0
- package/inputs/FileInput/FileInput.stories/package.json +6 -0
- package/inputs/FileInput/__stories__/{Default.js → Default/index.js} +1 -3
- package/inputs/FileInput/__stories__/Default/package.json +6 -0
- package/inputs/FileInput/__stories__/Default.d.ts +1 -0
- package/inputs/FileInput/index.d.ts +3 -1
- package/inputs/FileInput/index.js +12 -16
- package/inputs/ImageInput/ImageInput.stories/index.js +9 -0
- package/inputs/ImageInput/ImageInput.stories/package.json +6 -0
- package/inputs/ImageInput/ImageInput.stories.d.ts +10 -0
- package/inputs/ImageInput/ImageInput.stories.playwright.json +77 -0
- package/inputs/ImageInput/__stories__/Default/index.js +28 -0
- package/inputs/ImageInput/__stories__/Default/package.json +6 -0
- package/inputs/ImageInput/__stories__/Default.d.ts +3 -0
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension/index.js +36 -0
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension/package.json +6 -0
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension.d.ts +3 -0
- package/inputs/ImageInput/__stories__/WithInvalidImageSize/index.js +33 -0
- package/inputs/ImageInput/__stories__/WithInvalidImageSize/package.json +6 -0
- package/inputs/ImageInput/__stories__/WithInvalidImageSize.d.ts +3 -0
- package/inputs/ImageInput/index.d.ts +25 -0
- package/inputs/ImageInput/index.js +76 -0
- package/inputs/ImageInput/package.json +6 -0
- package/inputs/Input/Input.stories/index.js +15 -0
- package/inputs/Input/Input.stories/package.json +6 -0
- package/inputs/Input/__stories__/{AFM.js → AFM/index.js} +1 -3
- package/inputs/Input/__stories__/AFM/package.json +6 -0
- package/inputs/Input/__stories__/AFM.d.ts +1 -0
- package/inputs/Input/__stories__/{Boolean.js → Boolean/index.js} +1 -3
- package/inputs/Input/__stories__/Boolean/package.json +6 -0
- package/inputs/Input/__stories__/Boolean.d.ts +1 -0
- package/inputs/Input/__stories__/{Default.js → Default/index.js} +1 -3
- package/inputs/Input/__stories__/Default/package.json +6 -0
- package/inputs/Input/__stories__/Default.d.ts +1 -0
- package/inputs/Input/__stories__/{IBAN.js → IBAN/index.js} +1 -3
- package/inputs/Input/__stories__/IBAN/package.json +6 -0
- package/inputs/Input/__stories__/IBAN.d.ts +1 -0
- package/inputs/Input/__stories__/{Integer.js → Integer/index.js} +1 -3
- package/inputs/Input/__stories__/Integer/package.json +6 -0
- package/inputs/Input/__stories__/Integer.d.ts +1 -0
- package/inputs/Input/__stories__/{MobilePhone.js → MobilePhone/index.js} +1 -3
- package/inputs/Input/__stories__/MobilePhone/package.json +6 -0
- package/inputs/Input/__stories__/MobilePhone.d.ts +1 -0
- package/inputs/Input/__stories__/{PhoneNumber.js → PhoneNumber/index.js} +1 -3
- package/inputs/Input/__stories__/PhoneNumber/package.json +6 -0
- package/inputs/Input/__stories__/PhoneNumber.d.ts +1 -0
- package/inputs/Input/__stories__/{PostalCode.js → PostalCode/index.js} +1 -3
- package/inputs/Input/__stories__/PostalCode/package.json +6 -0
- package/inputs/Input/__stories__/PostalCode.d.ts +1 -0
- package/inputs/Input/__stories__/{TextWithCharacterLimit.js → TextWithCharacterLimit/index.js} +1 -3
- package/inputs/Input/__stories__/TextWithCharacterLimit/package.json +6 -0
- package/inputs/Input/__stories__/TextWithCharacterLimit.d.ts +1 -0
- package/inputs/Input/index.js +18 -24
- package/inputs/Label/Label.stories/index.js +7 -0
- package/inputs/Label/Label.stories/package.json +6 -0
- package/inputs/Label/__stories__/{Default.js → Default/index.js} +1 -3
- package/inputs/Label/__stories__/Default/package.json +6 -0
- package/inputs/Label/__stories__/Default.d.ts +1 -0
- package/inputs/Label/index.js +3 -6
- package/inputs/OtpInput/OtpInput.stories/index.js +7 -0
- package/inputs/OtpInput/OtpInput.stories/package.json +6 -0
- package/inputs/OtpInput/__stories__/{Default.js → Default/index.js} +1 -3
- package/inputs/OtpInput/__stories__/Default/package.json +6 -0
- package/inputs/OtpInput/__stories__/Default.d.ts +1 -0
- package/inputs/OtpInput/index.d.ts +1 -0
- package/inputs/OtpInput/index.js +10 -27
- package/inputs/Radio/Radio.stories/index.js +9 -0
- package/inputs/Radio/Radio.stories/package.json +6 -0
- package/inputs/Radio/__stories__/{Conditional.js → Conditional/index.js} +1 -4
- package/inputs/Radio/__stories__/Conditional/package.json +6 -0
- package/inputs/Radio/__stories__/Conditional.d.ts +1 -0
- package/inputs/Radio/__stories__/{Default.js → Default/index.js} +1 -3
- package/inputs/Radio/__stories__/Default/package.json +6 -0
- package/inputs/Radio/__stories__/Default.d.ts +1 -0
- package/inputs/Radio/__stories__/{WithDivider.js → WithDivider/index.js} +1 -3
- package/inputs/Radio/__stories__/WithDivider/package.json +6 -0
- package/inputs/Radio/__stories__/WithDivider.d.ts +1 -0
- package/inputs/Radio/index.js +15 -19
- package/inputs/Select/Select.stories/index.js +7 -0
- package/inputs/Select/Select.stories/package.json +6 -0
- package/inputs/Select/__stories__/{Default.js → Default/index.js} +1 -3
- package/inputs/Select/__stories__/Default/package.json +6 -0
- package/inputs/Select/__stories__/Default.d.ts +1 -0
- package/inputs/Select/index.js +6 -7
- package/inputs/index.d.ts +1 -0
- package/inputs/index.js +9 -8
- package/internal/index.js +34 -0
- package/internal/package.json +6 -0
- package/package.json +4 -4
- package/registry/index.js +138 -0
- package/registry/package.json +6 -0
- package/registry.d.ts +4 -2
- package/src/Field/utils.ts +9 -2
- package/src/FormBuilder/FormBuilder.mdx +7 -7
- package/src/MultiplicityField/__stories__/PreviewDisplay.tsx +4 -3
- package/src/Questions/Step/ReviewStep.tsx +2 -2
- package/src/Questions/Step/StepArrayReview.tsx +3 -1
- package/src/Questions/Step/StepTitle.tsx +4 -4
- package/src/Questions/__stories__/Default.tsx +3 -3
- package/src/Questions/index.mdx +3 -3
- package/src/inputs/AutoCompleteInput/AutoComplete.stories.js +7 -0
- package/src/inputs/{AutoComplete → AutoCompleteInput}/index.tsx +5 -5
- package/src/inputs/FileInput/index.tsx +3 -1
- package/src/inputs/ImageInput/ImageInput.stories.js +9 -0
- package/src/inputs/ImageInput/ImageInput.stories.playwright.json +77 -0
- package/src/inputs/ImageInput/__stories__/Default.tsx +31 -0
- package/src/inputs/ImageInput/__stories__/WithInvalidImageDimension.tsx +39 -0
- package/src/inputs/ImageInput/__stories__/WithInvalidImageSize.tsx +36 -0
- package/src/inputs/ImageInput/index.tsx +110 -0
- package/src/inputs/Input/index.tsx +6 -6
- package/src/inputs/index.ts +1 -0
- package/src/registry.js +105 -39
- package/src/types.tsx +2 -0
- package/src/validators/index.ts +14 -0
- package/src/validators/utils/file.ts +2 -2
- package/src/validators/utils/image.ts +92 -0
- package/src/validators/utils/index.ts +1 -0
- package/types/package.json +6 -0
- package/types.d.ts +5 -4
- package/utils/index.js +80 -0
- package/utils/package.json +6 -0
- package/validators/index.js +11 -15
- package/validators/types/package.json +6 -0
- package/validators/types.d.ts +1 -1
- package/validators/utils/{afm.js → afm/index.js} +0 -4
- package/validators/utils/afm/package.json +6 -0
- package/validators/utils/{file.js → file/index.js} +6 -13
- package/validators/utils/file/package.json +6 -0
- package/validators/utils/{iban.js → iban/index.js} +0 -7
- package/validators/utils/iban/package.json +6 -0
- package/validators/utils/image/index.js +119 -0
- package/validators/utils/image/package.json +6 -0
- package/validators/utils/image.d.ts +3 -0
- package/validators/utils/index.d.ts +1 -0
- package/validators/utils/index.js +12 -25
- package/validators/utils/{int.js → int/index.js} +0 -1
- package/validators/utils/int/package.json +6 -0
- package/validators/utils/{number.js → number/index.js} +0 -1
- package/validators/utils/number/package.json +6 -0
- package/validators/utils/{otp.js → otp/index.js} +0 -1
- package/validators/utils/otp/package.json +6 -0
- package/validators/utils/{phone.js → phone/index.js} +2 -16
- package/validators/utils/phone/package.json +6 -0
- package/validators/utils/phone.d.ts +1 -1
- package/validators/utils/{postal_code.js → postal_code/index.js} +0 -2
- package/validators/utils/postal_code/package.json +6 -0
- package/validators/utils/{text_limit.js → text_limit/index.js} +0 -7
- package/validators/utils/text_limit/package.json +6 -0
- package/validators/utils/{uuid4.js → uuid4/index.js} +0 -2
- package/validators/utils/uuid4/package.json +6 -0
- package/validators/{validators.spec.js → validators.spec/index.js} +1 -1
- package/validators/validators.spec/package.json +6 -0
- package/FieldArray/FieldArray.stories.js +0 -8
- package/FormBuilder/FormBuilder.stories.js +0 -7
- package/MultiplicityField/MultiplicityField.stories.js +0 -12
- package/MultiplicityField/add-objects.js +0 -160
- package/Questions/Questions.stories.js +0 -7
- package/cjs/Fieldset/FieldsetWithContext.js +0 -63
- package/cjs/FormBuilder/__stories__/Default.js +0 -49
- package/cjs/MultiplicityField/add-objects.js +0 -184
- package/cjs/Questions/Questions.js +0 -105
- package/cjs/Questions/Step/StepDescription.js +0 -55
- package/cjs/Questions/Step/StepForm.js +0 -74
- package/cjs/Questions/Step/StepTitle.js +0 -75
- package/cjs/Questions/index.spec.js +0 -73
- package/cjs/inputs/AutoComplete/__stories__/Default.js +0 -71
- package/cjs/inputs/Checkboxes/__stories__/Default.js +0 -62
- package/cjs/inputs/Checkboxes/__stories__/WithDivider.js +0 -63
- package/cjs/inputs/DateInput/__stories__/Default.js +0 -45
- package/cjs/inputs/FileInput/__stories__/Default.js +0 -42
- package/cjs/inputs/Input/__stories__/AFM.js +0 -44
- package/cjs/inputs/Input/__stories__/Boolean.js +0 -45
- package/cjs/inputs/Input/__stories__/Default.js +0 -45
- package/cjs/inputs/Input/__stories__/IBAN.js +0 -45
- package/cjs/inputs/Input/__stories__/Integer.js +0 -53
- package/cjs/inputs/Input/__stories__/MobilePhone.js +0 -44
- package/cjs/inputs/Input/__stories__/PhoneNumber.js +0 -44
- package/cjs/inputs/Input/__stories__/PostalCode.js +0 -47
- package/cjs/inputs/Input/__stories__/TextWithCharacterLimit.js +0 -51
- package/cjs/inputs/Label/__stories__/Default.js +0 -49
- package/cjs/inputs/OtpInput/__stories__/Default.js +0 -52
- package/cjs/inputs/Radio/__stories__/Default.js +0 -67
- package/cjs/inputs/Radio/__stories__/WithDivider.js +0 -68
- package/cjs/inputs/Select/__stories__/Default.js +0 -73
- package/cjs/utils.js +0 -113
- package/inputs/AutoComplete/AutoComplete.stories.js +0 -7
- package/inputs/AutoComplete/index.d.ts +0 -14
- package/inputs/Checkboxes/Checkboxes.stories.js +0 -9
- package/inputs/DateInput/DateInput.stories.js +0 -7
- package/inputs/FileInput/FileInput.stories.js +0 -7
- package/inputs/Input/Input.stories.js +0 -15
- package/inputs/Label/Label.stories.js +0 -7
- package/inputs/OtpInput/OtpInput.stories.js +0 -7
- package/inputs/Radio/Radio.stories.js +0 -9
- package/inputs/Select/Select.stories.js +0 -7
- package/internal.js +0 -34
- package/registry.js +0 -136
- package/src/inputs/AutoComplete/AutoComplete.stories.js +0 -7
- package/utils.js +0 -99
- /package/Field/{types.js → types/index.js} +0 -0
- /package/Fieldset/{types.js → types/index.js} +0 -0
- /package/{Form.stories.js → Form.stories/index.js} +0 -0
- /package/{FormContext.js → FormContext/index.js} +0 -0
- /package/Questions/{QuestionsContext.js → QuestionsContext/index.js} +0 -0
- /package/Questions/Step/{StepContext.js → StepContext/index.js} +0 -0
- /package/Questions/Step/{types.js → types/index.js} +0 -0
- /package/Questions/{types.js → types/index.js} +0 -0
- /package/cjs/Field/{types.js → types/index.js} +0 -0
- /package/cjs/Fieldset/{types.js → types/index.js} +0 -0
- /package/cjs/Questions/Step/{types.js → types/index.js} +0 -0
- /package/cjs/Questions/{types.js → types/index.js} +0 -0
- /package/cjs/{types.js → types/index.js} +0 -0
- /package/cjs/validators/{types.js → types/index.js} +0 -0
- /package/src/inputs/{AutoComplete → AutoCompleteInput}/__stories__/Default.tsx +0 -0
- /package/{types.js → types/index.js} +0 -0
- /package/validators/{types.js → types/index.js} +0 -0
|
@@ -3,32 +3,30 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
|
|
|
3
3
|
var _excluded = ["required", "name", "component", "wrapper", "control", "type", "controlled", "enabled", "editable", "defaultValue", "label", "extra", "layout", "error", "register"];
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { Controller } from 'react-hook-form';
|
|
6
|
-
import FieldBaseContainer from
|
|
6
|
+
import FieldBaseContainer from '@digigov/form/Field/FieldBaseContainer';
|
|
7
7
|
export var FieldBase = function FieldBase(props) {
|
|
8
8
|
var required = props.required,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
9
|
+
name = props.name,
|
|
10
|
+
Component = props.component,
|
|
11
|
+
wrapper = props.wrapper,
|
|
12
|
+
control = props.control,
|
|
13
|
+
type = props.type,
|
|
14
|
+
_props$controlled = props.controlled,
|
|
15
|
+
controlled = _props$controlled === void 0 ? false : _props$controlled,
|
|
16
|
+
_props$enabled = props.enabled,
|
|
17
|
+
enabled = _props$enabled === void 0 ? true : _props$enabled,
|
|
18
|
+
editable = props.editable,
|
|
19
|
+
defaultValue = props.defaultValue,
|
|
20
|
+
label = props.label,
|
|
21
|
+
_props$extra = props.extra,
|
|
22
|
+
extra = _props$extra === void 0 ? {} : _props$extra,
|
|
23
|
+
layout = props.layout,
|
|
24
|
+
error = props.error,
|
|
25
|
+
register = props.register,
|
|
26
|
+
componentProps = _objectWithoutProperties(props, _excluded);
|
|
28
27
|
if (!enabled) {
|
|
29
28
|
return null;
|
|
30
29
|
}
|
|
31
|
-
|
|
32
30
|
if (controlled) {
|
|
33
31
|
return /*#__PURE__*/React.createElement(FieldBaseContainer, {
|
|
34
32
|
label: label,
|
|
@@ -54,7 +52,6 @@ export var FieldBase = function FieldBase(props) {
|
|
|
54
52
|
}
|
|
55
53
|
}));
|
|
56
54
|
}
|
|
57
|
-
|
|
58
55
|
return /*#__PURE__*/React.createElement(FieldBaseContainer, {
|
|
59
56
|
label: label,
|
|
60
57
|
layout: layout,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import Label from
|
|
3
|
+
import Label from '@digigov/form/inputs/Label';
|
|
4
4
|
import ErrorMessage from '@digigov/react-core/ErrorMessage';
|
|
5
5
|
import FieldContainer from '@digigov/react-core/FieldContainer';
|
|
6
6
|
import CoreFieldset from '@digigov/react-core/Fieldset';
|
|
@@ -10,18 +10,15 @@ import LabelContainer from '@digigov/react-core/LabelContainer';
|
|
|
10
10
|
import { useTranslation } from '@digigov/ui/i18n';
|
|
11
11
|
export var FieldBaseContainer = function FieldBaseContainer(_ref) {
|
|
12
12
|
var name = _ref.name,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
wrapper = _ref.wrapper,
|
|
14
|
+
label = _ref.label,
|
|
15
|
+
children = _ref.children,
|
|
16
|
+
error = _ref.error,
|
|
17
|
+
layout = _ref.layout;
|
|
19
18
|
var _useTranslation = useTranslation(),
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
t = _useTranslation.t;
|
|
22
20
|
var errorMessage = error !== null && error !== void 0 && error.message.key ? error.message.key : (error === null || error === void 0 ? void 0 : error.message) || '';
|
|
23
21
|
var errorContext = (error === null || error === void 0 ? void 0 : error.message.context) || {};
|
|
24
|
-
|
|
25
22
|
if (wrapper === 'fieldset') {
|
|
26
23
|
return /*#__PURE__*/React.createElement(FieldContainer, _extends({
|
|
27
24
|
error: !!error
|
|
@@ -2,15 +2,15 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { useWatch } from 'react-hook-form';
|
|
5
|
-
import { FieldBase } from
|
|
6
|
-
import { evaluateFieldWithConditions } from
|
|
5
|
+
import { FieldBase } from '@digigov/form/Field/FieldBase';
|
|
6
|
+
import { evaluateFieldWithConditions } from '@digigov/form/Field/utils';
|
|
7
7
|
var ChildFieldMemo = /*#__PURE__*/React.memo(function ChildField(_ref) {
|
|
8
8
|
var dependencies = _ref.dependencies,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
field = _ref.field,
|
|
10
|
+
control = _ref.control,
|
|
11
|
+
reset = _ref.reset,
|
|
12
|
+
register = _ref.register,
|
|
13
|
+
error = _ref.error;
|
|
14
14
|
var newField = evaluateFieldWithConditions(field, dependencies);
|
|
15
15
|
return /*#__PURE__*/React.createElement(FieldBase, _extends({}, newField, {
|
|
16
16
|
name: newField.key,
|
|
@@ -23,25 +23,22 @@ var ChildFieldMemo = /*#__PURE__*/React.memo(function ChildField(_ref) {
|
|
|
23
23
|
if (!prev || !prev.dependencies) {
|
|
24
24
|
return false;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
26
|
if (prev.error !== next.error) {
|
|
28
27
|
return false;
|
|
29
28
|
}
|
|
30
|
-
|
|
31
29
|
for (var dep in next.dependencies) {
|
|
32
30
|
if (next.dependencies[dep] !== prev.dependencies[dep]) {
|
|
33
31
|
return false;
|
|
34
32
|
}
|
|
35
33
|
}
|
|
36
|
-
|
|
37
34
|
return true;
|
|
38
35
|
});
|
|
39
36
|
export var FieldConditional = function FieldConditional(_ref2) {
|
|
40
37
|
var control = _ref2.control,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
field = _ref2.field,
|
|
39
|
+
register = _ref2.register,
|
|
40
|
+
reset = _ref2.reset,
|
|
41
|
+
error = _ref2.error;
|
|
45
42
|
var dependencyKeys = Object.keys(field.condition);
|
|
46
43
|
var dependencyValues = useWatch({
|
|
47
44
|
name: dependencyKeys,
|
package/Field/index.js
CHANGED
|
@@ -2,34 +2,31 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["name", "children"];
|
|
4
4
|
import React, { useMemo } from 'react';
|
|
5
|
-
import { FieldBase } from
|
|
6
|
-
import FieldConditional from
|
|
7
|
-
import { useField, calculateField } from
|
|
8
|
-
import FieldArray from
|
|
9
|
-
import Multiplicity from
|
|
5
|
+
import { FieldBase } from '@digigov/form/Field/FieldBase';
|
|
6
|
+
import FieldConditional from '@digigov/form/Field/FieldConditional';
|
|
7
|
+
import { useField, calculateField } from '@digigov/form/Field/utils';
|
|
8
|
+
import FieldArray from '@digigov/form/FieldArray';
|
|
9
|
+
import Multiplicity from '@digigov/form/MultiplicityField';
|
|
10
10
|
export var Field = function Field(_ref) {
|
|
11
11
|
var name = _ref.name,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
children = _ref.children,
|
|
13
|
+
customField = _objectWithoutProperties(_ref, _excluded);
|
|
15
14
|
var _useField = useField(name, customField !== null && customField !== void 0 && customField.type ? customField : null),
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
field = _useField.field,
|
|
16
|
+
control = _useField.control,
|
|
17
|
+
register = _useField.register,
|
|
18
|
+
reset = _useField.reset,
|
|
19
|
+
error = _useField.error,
|
|
20
|
+
componentRegistry = _useField.componentRegistry,
|
|
21
|
+
formState = _useField.formState,
|
|
22
|
+
setValue = _useField.setValue,
|
|
23
|
+
getValues = _useField.getValues,
|
|
24
|
+
unregister = _useField.unregister,
|
|
25
|
+
trigger = _useField.trigger,
|
|
26
|
+
clearErrors = _useField.clearErrors;
|
|
29
27
|
var calculatedField = useMemo(function () {
|
|
30
28
|
return calculateField(children, field, componentRegistry);
|
|
31
29
|
}, [field]);
|
|
32
|
-
|
|
33
30
|
if (calculatedField.condition) {
|
|
34
31
|
return /*#__PURE__*/React.createElement(FieldConditional, {
|
|
35
32
|
control: control,
|
|
@@ -39,7 +36,6 @@ export var Field = function Field(_ref) {
|
|
|
39
36
|
error: error
|
|
40
37
|
});
|
|
41
38
|
}
|
|
42
|
-
|
|
43
39
|
if (calculatedField.type === 'array' && !calculatedField.multiplicity) {
|
|
44
40
|
calculatedField.name = name;
|
|
45
41
|
return /*#__PURE__*/React.createElement(FieldArray, _extends({
|
|
@@ -49,7 +45,6 @@ export var Field = function Field(_ref) {
|
|
|
49
45
|
formState: formState
|
|
50
46
|
}, calculatedField));
|
|
51
47
|
}
|
|
52
|
-
|
|
53
48
|
if (calculatedField.type === 'array' && calculatedField.multiplicity === true) {
|
|
54
49
|
calculatedField.name = name;
|
|
55
50
|
return /*#__PURE__*/React.createElement(Multiplicity, _extends({
|
|
@@ -64,7 +59,6 @@ export var Field = function Field(_ref) {
|
|
|
64
59
|
unregister: unregister
|
|
65
60
|
}, calculatedField));
|
|
66
61
|
}
|
|
67
|
-
|
|
68
62
|
return /*#__PURE__*/React.createElement(FieldBase, _extends({}, calculatedField, {
|
|
69
63
|
name: name,
|
|
70
64
|
control: control,
|
package/Field/types.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface FieldConditionalProps {
|
|
|
15
15
|
reset: UseFormReturn['reset'];
|
|
16
16
|
error?: ErrorOption;
|
|
17
17
|
}
|
|
18
|
-
export
|
|
18
|
+
export type FieldComponentItem = {
|
|
19
19
|
component: any;
|
|
20
20
|
controlled?: boolean;
|
|
21
21
|
wrapper?: FieldSpec['wrapper'];
|
|
@@ -28,9 +28,9 @@ export interface FieldContainerProps {
|
|
|
28
28
|
children?: React.ReactNode;
|
|
29
29
|
wrapper?: FieldSpec['wrapper'];
|
|
30
30
|
}
|
|
31
|
-
export
|
|
32
|
-
export
|
|
33
|
-
export
|
|
31
|
+
export type FieldComponentRegistry = Record<string, FieldComponentItem>;
|
|
32
|
+
export type OmittedFieldSpec = Omit<FieldSpec, 'component'>;
|
|
33
|
+
export type UnknownValue = never | never[];
|
|
34
34
|
export interface ControlledFieldProps {
|
|
35
35
|
type?: string;
|
|
36
36
|
value: UnknownValue;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import { lazy, useContext, useMemo } from 'react';
|
|
3
|
-
import { FormContext } from
|
|
4
|
-
import Checkboxes from
|
|
5
|
-
import DateInput from
|
|
6
|
-
import FileInput from
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
import { FormContext } from '@digigov/form/FormContext';
|
|
4
|
+
import Checkboxes from '@digigov/form/inputs/Checkboxes';
|
|
5
|
+
import DateInput from '@digigov/form/inputs/DateInput';
|
|
6
|
+
import FileInput from '@digigov/form/inputs/FileInput';
|
|
7
|
+
import ImageInput from '@digigov/form/inputs/ImageInput';
|
|
8
|
+
import Input from '@digigov/form/inputs/Input';
|
|
9
|
+
import OtpInput from '@digigov/form/inputs/OtpInput';
|
|
10
|
+
import Radio from '@digigov/form/inputs/Radio';
|
|
11
|
+
import Select from '@digigov/form/inputs/Select';
|
|
12
|
+
var AutoCompleteInput = /*#__PURE__*/lazy(function () {
|
|
13
|
+
return import('@digigov/form/inputs/AutoCompleteInput');
|
|
13
14
|
});
|
|
14
15
|
var FIELD_COMPONENTS = {
|
|
15
16
|
text: {
|
|
@@ -22,6 +23,10 @@ var FIELD_COMPONENTS = {
|
|
|
22
23
|
wrapper: 'fieldset',
|
|
23
24
|
component: FileInput
|
|
24
25
|
},
|
|
26
|
+
image: {
|
|
27
|
+
wrapper: 'fieldset',
|
|
28
|
+
component: ImageInput
|
|
29
|
+
},
|
|
25
30
|
date: {
|
|
26
31
|
wrapper: 'fieldset',
|
|
27
32
|
controlled: true,
|
|
@@ -49,68 +54,59 @@ var ALTERNATIVE_COMPONENTS = {
|
|
|
49
54
|
controlled: false
|
|
50
55
|
},
|
|
51
56
|
AutoComplete: {
|
|
52
|
-
component:
|
|
57
|
+
component: AutoCompleteInput,
|
|
53
58
|
controlled: true
|
|
54
59
|
}
|
|
55
60
|
};
|
|
56
61
|
export function calculateField(children, field, componentRegistry) {
|
|
57
62
|
var _field$extra;
|
|
58
|
-
|
|
59
63
|
var calculatedField = _extends({}, field);
|
|
60
|
-
|
|
61
64
|
var fieldComponentRegistry = _extends({}, FIELD_COMPONENTS, componentRegistry);
|
|
62
|
-
|
|
63
65
|
if (children) {
|
|
64
66
|
calculatedField.component = children;
|
|
65
67
|
calculatedField.controlled = true;
|
|
66
|
-
} else if (typeof field.component === 'function') {
|
|
68
|
+
} else if (typeof field.component === 'function') {
|
|
69
|
+
// leave as is
|
|
67
70
|
} else if (!field.component && !field.type) {
|
|
68
71
|
var _fieldComponentRegist;
|
|
69
|
-
|
|
70
72
|
calculatedField.component = fieldComponentRegistry.string.component;
|
|
71
73
|
calculatedField.controlled = ((_fieldComponentRegist = fieldComponentRegistry.string) === null || _fieldComponentRegist === void 0 ? void 0 : _fieldComponentRegist.controlled) || false;
|
|
72
74
|
} else if (typeof (field === null || field === void 0 ? void 0 : (_field$extra = field.extra) === null || _field$extra === void 0 ? void 0 : _field$extra.component) === 'string' && ALTERNATIVE_COMPONENTS[field.extra.component]) {
|
|
73
75
|
var _ALTERNATIVE_COMPONEN;
|
|
74
|
-
|
|
75
76
|
calculatedField.controlled = ((_ALTERNATIVE_COMPONEN = ALTERNATIVE_COMPONENTS[field.extra.component]) === null || _ALTERNATIVE_COMPONEN === void 0 ? void 0 : _ALTERNATIVE_COMPONEN.controlled) || false;
|
|
76
77
|
calculatedField.component = ALTERNATIVE_COMPONENTS[field.extra.component].component;
|
|
77
78
|
} else if (!field.component && field.type && fieldComponentRegistry[field.type]) {
|
|
78
79
|
var _fieldComponentRegist2;
|
|
79
|
-
|
|
80
80
|
calculatedField.component = fieldComponentRegistry[field.type].component;
|
|
81
81
|
calculatedField.wrapper = fieldComponentRegistry[field.type].wrapper;
|
|
82
82
|
calculatedField.controlled = ((_fieldComponentRegist2 = fieldComponentRegistry[field.type]) === null || _fieldComponentRegist2 === void 0 ? void 0 : _fieldComponentRegist2.controlled) || false;
|
|
83
83
|
} else {
|
|
84
84
|
var _fieldComponentRegist3;
|
|
85
|
-
|
|
86
85
|
calculatedField.component = fieldComponentRegistry.string.component;
|
|
87
86
|
calculatedField.controlled = ((_fieldComponentRegist3 = fieldComponentRegistry.string) === null || _fieldComponentRegist3 === void 0 ? void 0 : _fieldComponentRegist3.controlled) || false;
|
|
88
87
|
}
|
|
89
|
-
|
|
90
88
|
return calculatedField;
|
|
91
89
|
}
|
|
92
90
|
export var useField = function useField(name, customField) {
|
|
93
91
|
var _useContext = useContext(FormContext),
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
92
|
+
fieldsMap = _useContext.fieldsMap,
|
|
93
|
+
control = _useContext.control,
|
|
94
|
+
register = _useContext.register,
|
|
95
|
+
reset = _useContext.reset,
|
|
96
|
+
trigger = _useContext.trigger,
|
|
97
|
+
clearErrors = _useContext.clearErrors,
|
|
98
|
+
errors = _useContext.errors,
|
|
99
|
+
registerField = _useContext.registerField,
|
|
100
|
+
watch = _useContext.watch,
|
|
101
|
+
componentRegistry = _useContext.componentRegistry,
|
|
102
|
+
getFieldState = _useContext.getFieldState,
|
|
103
|
+
setValue = _useContext.setValue,
|
|
104
|
+
getValues = _useContext.getValues,
|
|
105
|
+
unregister = _useContext.unregister,
|
|
106
|
+
formState = _useContext.formState;
|
|
110
107
|
if (!registerField) {
|
|
111
108
|
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 ");
|
|
112
109
|
}
|
|
113
|
-
|
|
114
110
|
useMemo(function () {
|
|
115
111
|
return (customField === null || customField === void 0 ? void 0 : customField.type) && registerField(_extends({}, customField, {
|
|
116
112
|
key: name
|
|
@@ -135,28 +131,23 @@ export var useField = function useField(name, customField) {
|
|
|
135
131
|
};
|
|
136
132
|
export function evaluateFieldWithConditions(field, variables) {
|
|
137
133
|
var newField = _extends({}, field);
|
|
138
|
-
|
|
139
134
|
if (variables) {
|
|
140
135
|
for (var key in variables) {
|
|
141
136
|
if (field.condition[key] && field.condition[key].is) {
|
|
142
137
|
var is = field.condition[key].is;
|
|
143
|
-
|
|
144
138
|
if (is === variables[key] || Array.isArray(variables[key]) && variables[key].includes(is)) {
|
|
145
139
|
var then = field.condition[key].then || {};
|
|
146
|
-
|
|
147
140
|
for (var attr in then) {
|
|
148
141
|
newField[attr] = then[attr];
|
|
149
142
|
}
|
|
150
143
|
}
|
|
151
144
|
} else if (field.condition[key]) {
|
|
152
145
|
var otherwise = field.condition[key]["else"] || {};
|
|
153
|
-
|
|
154
146
|
for (var _attr in otherwise) {
|
|
155
147
|
newField[_attr] = otherwise[_attr];
|
|
156
148
|
}
|
|
157
149
|
}
|
|
158
150
|
}
|
|
159
151
|
}
|
|
160
|
-
|
|
161
152
|
return newField;
|
|
162
153
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import FieldArray from '@digigov/form/FieldArray';
|
|
2
|
+
export default {
|
|
3
|
+
title: 'Digigov Form/FieldArray',
|
|
4
|
+
component: FieldArray,
|
|
5
|
+
displayName: 'FieldArray'
|
|
6
|
+
};
|
|
7
|
+
export * from '@digigov/form/FieldArray/__stories__/Default';
|
|
8
|
+
export * from '@digigov/form/FieldArray/__stories__/WithExactLength';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import FormBuilder, { Field } from
|
|
3
|
+
import FormBuilder, { Field } from '@digigov/form';
|
|
4
4
|
import { Button } from '@digigov/ui/form/Button';
|
|
5
5
|
var fields = [{
|
|
6
6
|
key: 'string',
|
|
@@ -72,9 +72,7 @@ var fields = [{
|
|
|
72
72
|
secondary: 'Συμπληρώστε τον αριθμό τηλεφώνου'
|
|
73
73
|
}
|
|
74
74
|
}];
|
|
75
|
-
|
|
76
75
|
var _ref = /*#__PURE__*/React.createElement(Button, null, "\u03A3\u03C5\u03BD\u03AD\u03C7\u03B5\u03B9\u03B1");
|
|
77
|
-
|
|
78
76
|
export var Default = function Default() {
|
|
79
77
|
return /*#__PURE__*/React.createElement(FormBuilder, {
|
|
80
78
|
onSubmit: function onSubmit(data) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import FormBuilder, { Field } from
|
|
3
|
+
import FormBuilder, { Field } from '@digigov/form';
|
|
4
4
|
import { Button } from '@digigov/ui/form/Button';
|
|
5
5
|
var fields = [{
|
|
6
6
|
key: 'string',
|
|
@@ -72,9 +72,7 @@ var fields = [{
|
|
|
72
72
|
secondary: 'Συμπληρώστε τον αριθμό τηλεφώνου σας'
|
|
73
73
|
}
|
|
74
74
|
}];
|
|
75
|
-
|
|
76
75
|
var _ref = /*#__PURE__*/React.createElement(Button, null, "\u03A3\u03C5\u03BD\u03AD\u03C7\u03B5\u03B9\u03B1");
|
|
77
|
-
|
|
78
76
|
export var WithExactLength = function WithExactLength() {
|
|
79
77
|
return /*#__PURE__*/React.createElement(FormBuilder, {
|
|
80
78
|
onSubmit: function onSubmit(data) {
|
package/FieldArray/index.js
CHANGED
|
@@ -3,31 +3,28 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
|
|
|
3
3
|
var _excluded = ["name", "register", "control", "formState", "error", "layout", "label"];
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { useFieldArray } from 'react-hook-form';
|
|
6
|
-
import FieldContainer from
|
|
7
|
-
import FieldObject from
|
|
8
|
-
import { FieldsetLabel } from
|
|
6
|
+
import FieldContainer from '@digigov/form/Field/FieldBaseContainer';
|
|
7
|
+
import FieldObject from '@digigov/form/FieldObject';
|
|
8
|
+
import { FieldsetLabel } from '@digigov/form/Fieldset';
|
|
9
9
|
import Fieldset from '@digigov/react-core/Fieldset';
|
|
10
10
|
import { Button, Card, Hint } from '@digigov/ui';
|
|
11
11
|
export var FieldArray = function FieldArray(_ref) {
|
|
12
12
|
var _customField$extra, _customField$extra$la, _customField$extra4, _customField$extra4$l;
|
|
13
|
-
|
|
14
13
|
var name = _ref.name,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
register = _ref.register,
|
|
15
|
+
control = _ref.control,
|
|
16
|
+
formState = _ref.formState,
|
|
17
|
+
error = _ref.error,
|
|
18
|
+
layout = _ref.layout,
|
|
19
|
+
label = _ref.label,
|
|
20
|
+
customField = _objectWithoutProperties(_ref, _excluded);
|
|
23
21
|
var _useFieldArray = useFieldArray({
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
control: control,
|
|
23
|
+
name: name
|
|
24
|
+
}),
|
|
25
|
+
fields = _useFieldArray.fields,
|
|
26
|
+
append = _useFieldArray.append,
|
|
27
|
+
remove = _useFieldArray.remove;
|
|
31
28
|
return /*#__PURE__*/React.createElement(FieldContainer, {
|
|
32
29
|
label: label,
|
|
33
30
|
layout: layout,
|
|
@@ -36,7 +33,6 @@ export var FieldArray = function FieldArray(_ref) {
|
|
|
36
33
|
name: name
|
|
37
34
|
}, fields.length === 0 && /*#__PURE__*/React.createElement(Hint, null, (_customField$extra = customField.extra) === null || _customField$extra === void 0 ? void 0 : (_customField$extra$la = _customField$extra.label.object) === null || _customField$extra$la === void 0 ? void 0 : _customField$extra$la.nothing_added), fields.map(function (field, index) {
|
|
38
35
|
var _customField$extra2, _customField$extra3;
|
|
39
|
-
|
|
40
36
|
return /*#__PURE__*/React.createElement(Card, {
|
|
41
37
|
variant: "border",
|
|
42
38
|
key: field.id
|
package/FieldObject/index.js
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React, { useMemo } from 'react';
|
|
3
|
-
import { FieldBase } from
|
|
4
|
-
import { calculateField } from
|
|
5
|
-
import Fieldset, { FieldsetCaption } from
|
|
3
|
+
import { FieldBase } from '@digigov/form/Field/FieldBase';
|
|
4
|
+
import { calculateField } from '@digigov/form/Field/utils';
|
|
5
|
+
import Fieldset, { FieldsetCaption } from '@digigov/form/Fieldset';
|
|
6
6
|
import { FieldsetLegend } from '@digigov/react-core';
|
|
7
7
|
import { useTranslation } from '@digigov/ui/i18n';
|
|
8
8
|
export var FieldObject = function FieldObject(_ref) {
|
|
9
9
|
var name = _ref.name,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
label = _ref.label,
|
|
11
|
+
extra = _ref.extra,
|
|
12
|
+
control = _ref.control,
|
|
13
|
+
register = _ref.register,
|
|
14
|
+
reset = _ref.reset,
|
|
15
|
+
formState = _ref.formState;
|
|
17
16
|
var _useTranslation = useTranslation(),
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
t = _useTranslation.t;
|
|
20
18
|
return /*#__PURE__*/React.createElement(Fieldset, null, (label === null || label === void 0 ? void 0 : label.primary) && /*#__PURE__*/React.createElement(FieldsetLegend, {
|
|
21
19
|
size: "sm"
|
|
22
20
|
}, t(label.primary)), (label === null || label === void 0 ? void 0 : label.secondary) && /*#__PURE__*/React.createElement(FieldsetCaption, null, t(label.secondary)), extra === null || extra === void 0 ? void 0 : extra.fields.map(function (field) {
|
|
@@ -32,16 +30,15 @@ export var FieldObject = function FieldObject(_ref) {
|
|
|
32
30
|
});
|
|
33
31
|
}));
|
|
34
32
|
};
|
|
35
|
-
|
|
36
33
|
var FieldObjectItem = function FieldObjectItem(_ref2) {
|
|
37
34
|
var name = _ref2.name,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
children = _ref2.children,
|
|
36
|
+
field = _ref2.field,
|
|
37
|
+
error = _ref2.error,
|
|
38
|
+
control = _ref2.control,
|
|
39
|
+
formState = _ref2.formState,
|
|
40
|
+
reset = _ref2.reset,
|
|
41
|
+
register = _ref2.register;
|
|
45
42
|
var calculatedField = useMemo(function () {
|
|
46
43
|
return calculateField(children, field);
|
|
47
44
|
}, [field]);
|
|
@@ -54,5 +51,4 @@ var FieldObjectItem = function FieldObjectItem(_ref2) {
|
|
|
54
51
|
error: customError
|
|
55
52
|
}));
|
|
56
53
|
};
|
|
57
|
-
|
|
58
54
|
export default FieldObject;
|