@digigov/form 2.0.0-87b6232d → 2.0.0-8bbad051
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Field/ErrorGroup.d.ts +3 -3
- package/Field/ErrorGroup.js.map +1 -1
- package/Field/FieldBase/index.js +5 -5
- package/Field/FieldBase.d.ts +1 -1
- package/Field/FieldBase.js.map +2 -2
- package/Field/FieldBaseContainer/index.js +37 -19
- package/Field/FieldBaseContainer.d.ts +2 -2
- package/Field/FieldBaseContainer.js.map +2 -2
- package/Field/FieldConditional/index.js +1 -1
- package/Field/FieldConditional.d.ts +1 -1
- package/Field/FieldConditional.js.map +1 -1
- package/Field/index.d.ts +1 -1
- package/Field/index.js +18 -27
- package/Field/index.js.map +2 -2
- package/Field/types.d.ts +13 -12
- package/Field/utils/evaluateFieldWithConditions.d.ts +2 -2
- package/Field/utils/evaluateFieldWithConditions.js.map +2 -2
- package/Field/utils/resolveField/index.js +35 -0
- package/Field/utils/{calculateField → resolveField}/package.json +1 -1
- package/Field/utils/resolveField.d.ts +3 -0
- package/Field/utils/resolveField.js.map +7 -0
- package/Field/utils/useField/index.js +4 -2
- package/Field/utils/useField.d.ts +1 -1
- package/Field/utils/useField.js.map +2 -2
- package/FieldArray/BaseFieldArray/index.js +76 -0
- package/{inputs/inputsScenarios → FieldArray/BaseFieldArray}/package.json +1 -1
- package/FieldArray/BaseFieldArray.d.ts +5 -0
- package/FieldArray/BaseFieldArray.js.map +7 -0
- package/FieldArray/FieldArray.stories.d.ts +1 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay/index.js +23 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay/package.json +6 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.d.ts +9 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.js.map +7 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayDisplay.stories.d.ts +13 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay/index.js +184 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay/package.json +6 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.d.ts +26 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.js.map +7 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader/index.js +11 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader/package.json +6 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.d.ts +5 -0
- package/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.js.map +7 -0
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/Cards.d.ts +2 -0
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/Default.d.ts +2 -0
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnly.d.ts +2 -0
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnlyCards.d.ts +2 -0
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/Sortable.d.ts +2 -0
- package/FieldArray/FormDialog/ArrayDisplay/__stories__/SortableCards.d.ts +2 -0
- package/FieldArray/FormDialog/ArrayDisplay/index.d.ts +15 -0
- package/FieldArray/FormDialog/ArrayDisplay/index.js +57 -0
- package/FieldArray/FormDialog/ArrayDisplay/index.js.map +7 -0
- package/{inputs/Input/inputsInputScenarios → FieldArray/FormDialog/ArrayDisplay}/package.json +1 -1
- package/FieldArray/FormDialog/ArrayEditModal/index.js +158 -0
- package/FieldArray/FormDialog/ArrayEditModal/package.json +6 -0
- package/FieldArray/FormDialog/ArrayEditModal.d.ts +24 -0
- package/FieldArray/FormDialog/ArrayEditModal.js.map +7 -0
- package/FieldArray/FormDialog/index.d.ts +19 -0
- package/FieldArray/FormDialog/index.js +183 -351
- package/FieldArray/FormDialog/index.js.map +7 -0
- package/FieldArray/__stories__/CardsWithError.d.ts +15 -0
- package/FieldArray/__stories__/Default.d.ts +1 -1
- package/FieldArray/__stories__/WithExactLength.d.ts +1 -1
- package/FieldArray/__stories__/WithModal.d.ts +1 -1
- package/FieldArray/index.d.ts +5 -3
- package/FieldArray/index.js +64 -98
- package/FieldArray/index.js.map +3 -3
- package/FieldObject/index.d.ts +4 -4
- package/FieldObject/index.js +5 -12
- package/FieldObject/index.js.map +2 -2
- package/Fieldset/FieldsetWithContext.js.map +1 -1
- package/Fieldset/index.d.ts +1 -1
- package/Fieldset/index.js.map +1 -1
- package/Fieldset/types.d.ts +2 -2
- package/FormBuilder/FormBuilder.stories.d.ts +2 -0
- package/FormBuilder/__stories__/AutoErrorGrouping.d.ts +1 -1
- package/FormBuilder/__stories__/Default.d.ts +1 -1
- package/FormBuilder/__stories__/ErrorGrouping.d.ts +1 -1
- package/FormBuilder/index.d.ts +2 -2
- package/FormBuilder/index.js +159 -137
- package/FormBuilder/index.js.map +2 -2
- package/FormContext/index.js +6 -2
- package/FormContext.d.ts +3 -2
- package/FormContext.js.map +2 -2
- package/MultiplicityField/MultiplicityField.stories.d.ts +2 -0
- package/MultiplicityField/__stories__/Default.d.ts +1 -1
- package/MultiplicityField/__stories__/PreviewDisplay.d.ts +1 -1
- package/MultiplicityField/__stories__/WithExactLength.d.ts +1 -1
- package/MultiplicityField/__stories__/WithMaxLength.d.ts +1 -1
- package/MultiplicityField/__stories__/WithMinAndMaxLength.d.ts +1 -1
- package/MultiplicityField/__stories__/WithMinLength.d.ts +1 -1
- package/MultiplicityField/add-objects/index.js +11 -20
- package/MultiplicityField/add-objects.d.ts +1 -1
- package/MultiplicityField/add-objects.js.map +2 -2
- package/MultiplicityField/index.d.ts +2 -2
- package/MultiplicityField/index.js +4 -2
- package/MultiplicityField/index.js.map +2 -2
- package/MultiplicityField/types.d.ts +3 -2
- package/Questions/Questions.d.ts +1 -1
- package/Questions/Questions.js.map +1 -1
- package/Questions/Questions.stories.d.ts +2 -0
- package/Questions/QuestionsContext.d.ts +1 -1
- package/Questions/QuestionsContext.js.map +1 -1
- package/Questions/Step/Step.d.ts +1 -1
- package/Questions/Step/Step.js.map +1 -1
- package/Questions/Step/StepArrayReview.d.ts +1 -1
- package/Questions/Step/StepArrayReview.js.map +1 -1
- package/Questions/Step/StepContext.d.ts +1 -1
- package/Questions/Step/StepContext.js.map +1 -1
- package/Questions/Step/StepDescription.d.ts +1 -1
- package/Questions/Step/StepDescription.js.map +2 -2
- package/Questions/Step/StepForm.d.ts +2 -2
- package/Questions/Step/StepForm.js.map +1 -1
- package/Questions/Step/StepQuote.d.ts +1 -1
- package/Questions/Step/StepQuote.js.map +2 -2
- package/Questions/Step/StepTitle.d.ts +1 -1
- package/Questions/Step/StepTitle.js.map +2 -2
- package/Questions/Step/getAddMoreFields.d.ts +2 -2
- package/Questions/Step/getAddMoreFields.js.map +1 -1
- package/Questions/Step/types.d.ts +1 -1
- package/Questions/__stories__/Default.d.ts +1 -1
- package/Questions/getNextStep.d.ts +1 -1
- package/Questions/getNextStep.js.map +1 -1
- package/Questions/types.d.ts +1 -1
- package/cjs/Field/ErrorGroup.js.map +1 -1
- package/cjs/Field/FieldBase/index.js +5 -5
- package/cjs/Field/FieldBase.js.map +2 -2
- package/cjs/Field/FieldBaseContainer/index.js +36 -18
- package/cjs/Field/FieldBaseContainer.js.map +3 -3
- package/cjs/Field/FieldConditional/index.js +1 -1
- package/cjs/Field/FieldConditional.js.map +1 -1
- package/cjs/Field/index.js +18 -24
- package/cjs/Field/index.js.map +2 -2
- package/cjs/Field/types.js.map +1 -1
- package/cjs/Field/utils/evaluateFieldWithConditions.js.map +2 -2
- package/cjs/Field/utils/resolveField/index.js +55 -0
- package/cjs/Field/utils/resolveField.js.map +7 -0
- package/cjs/Field/utils/useField/index.js +4 -2
- package/cjs/Field/utils/useField.js.map +2 -2
- package/cjs/FieldArray/BaseFieldArray/index.js +109 -0
- package/cjs/FieldArray/BaseFieldArray.js.map +7 -0
- package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay/index.js +56 -0
- package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.js.map +7 -0
- package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay/index.js +209 -0
- package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.js.map +7 -0
- package/cjs/{locales/el → FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader}/index.js +16 -7
- package/cjs/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.js.map +7 -0
- package/cjs/FieldArray/FormDialog/ArrayDisplay/index.js +90 -0
- package/cjs/FieldArray/FormDialog/ArrayDisplay/index.js.map +7 -0
- package/cjs/FieldArray/FormDialog/ArrayEditModal/index.js +186 -0
- package/cjs/FieldArray/FormDialog/ArrayEditModal.js.map +7 -0
- package/cjs/FieldArray/FormDialog/index.js +174 -334
- package/cjs/FieldArray/FormDialog/index.js.map +7 -0
- package/cjs/FieldArray/index.js +63 -94
- package/cjs/FieldArray/index.js.map +3 -3
- package/cjs/FieldObject/index.js +5 -9
- package/cjs/FieldObject/index.js.map +2 -2
- package/cjs/Fieldset/FieldsetWithContext.js.map +1 -1
- package/cjs/Fieldset/index.js.map +1 -1
- package/cjs/Fieldset/types.js.map +1 -1
- package/cjs/FormBuilder/index.js +160 -138
- package/cjs/FormBuilder/index.js.map +3 -3
- package/cjs/FormContext/index.js +7 -2
- package/cjs/FormContext.js.map +2 -2
- package/cjs/MultiplicityField/add-objects/index.js +10 -14
- package/cjs/MultiplicityField/add-objects.js.map +2 -2
- package/cjs/MultiplicityField/index.js +4 -2
- package/cjs/MultiplicityField/index.js.map +2 -2
- package/cjs/MultiplicityField/types.js.map +1 -1
- package/cjs/Questions/Questions.js.map +1 -1
- package/cjs/Questions/QuestionsContext.js.map +1 -1
- package/cjs/Questions/Step/Step.js.map +1 -1
- package/cjs/Questions/Step/StepArrayReview.js.map +1 -1
- package/cjs/Questions/Step/StepContext.js.map +1 -1
- package/cjs/Questions/Step/StepDescription.js.map +2 -2
- package/cjs/Questions/Step/StepForm.js.map +1 -1
- package/cjs/Questions/Step/StepQuote.js.map +2 -2
- package/cjs/Questions/Step/StepTitle.js.map +2 -2
- package/cjs/Questions/Step/getAddMoreFields.js.map +1 -1
- package/cjs/Questions/Step/types.js.map +1 -1
- package/cjs/Questions/getNextStep.js.map +1 -1
- package/cjs/Questions/types.js.map +1 -1
- package/cjs/hooks/useFieldFocusManager/index.js +135 -0
- package/cjs/hooks/useFieldFocusManager.js.map +7 -0
- package/cjs/hooks/utils/index.js +98 -0
- package/cjs/hooks/utils.js.map +7 -0
- package/cjs/inputs/AutoCompleteInput/index.js.map +2 -2
- package/cjs/inputs/Checkboxes/index.js +68 -62
- package/cjs/inputs/Checkboxes/index.js.map +2 -2
- package/cjs/inputs/DateInput/index.js +37 -17
- package/cjs/inputs/DateInput/index.js.map +2 -2
- package/cjs/inputs/DateTimeInput/index.js +65 -39
- package/cjs/inputs/DateTimeInput/index.js.map +2 -2
- package/cjs/inputs/FileInput/index.js +35 -24
- package/cjs/inputs/FileInput/index.js.map +2 -2
- package/cjs/inputs/ImageInput/__stories__/logo.d/index.js +1 -0
- package/cjs/inputs/ImageInput/__stories__/logo.d.js.map +7 -0
- package/cjs/inputs/ImageInput/index.js +44 -13
- package/cjs/inputs/ImageInput/index.js.map +2 -2
- package/cjs/inputs/Input/index.js +6 -4
- package/cjs/inputs/Input/index.js.map +2 -2
- package/cjs/inputs/Label/index.js.map +1 -1
- package/cjs/inputs/OtpInput/index.js +36 -31
- package/cjs/inputs/OtpInput/index.js.map +2 -2
- package/cjs/inputs/Radio/index.js +7 -5
- package/cjs/inputs/Radio/index.js.map +3 -3
- package/cjs/inputs/Select/index.js +2 -2
- package/cjs/inputs/Select/index.js.map +2 -2
- package/cjs/{Field/utils → inputs/registry}/index.js +8 -7
- package/cjs/inputs/registry.js.map +7 -0
- package/cjs/lazy/index.js +12 -9
- package/cjs/lazy.js.map +2 -2
- package/cjs/registry/index.js +27 -15
- package/cjs/registry.js.map +2 -2
- package/cjs/types.js.map +1 -1
- package/cjs/utils/index.js +9 -0
- package/cjs/utils.js.map +2 -2
- package/cjs/validators/index.js +13 -12
- package/cjs/validators/index.js.map +2 -2
- package/cjs/validators/types.js.map +1 -1
- package/cjs/validators/utils/date/index.js +26 -3
- package/cjs/validators/utils/date.js.map +2 -2
- package/cjs/validators/utils/datetime/index.js +118 -24
- package/cjs/validators/utils/datetime.js.map +2 -2
- package/cjs/validators/utils/email/index.js +39 -0
- package/cjs/validators/utils/email.js.map +7 -0
- package/cjs/validators/utils/file.js.map +1 -1
- package/cjs/validators/utils/iban.js.map +1 -1
- package/cjs/validators/utils/image.js.map +1 -1
- package/cjs/validators/utils/index.js.map +1 -1
- package/cjs/validators/utils/int.js.map +1 -1
- package/cjs/validators/utils/number.js.map +1 -1
- package/cjs/validators/utils/otp.js.map +1 -1
- package/cjs/validators/utils/phone.js.map +1 -1
- package/cjs/validators/utils/postal_code.js.map +1 -1
- package/cjs/validators/utils/text_limit.js.map +1 -1
- package/hooks/useFieldFocusManager/index.js +116 -0
- package/hooks/useFieldFocusManager/package.json +6 -0
- package/hooks/useFieldFocusManager.d.ts +25 -0
- package/hooks/useFieldFocusManager.js.map +7 -0
- package/hooks/utils/index.js +73 -0
- package/{Field → hooks}/utils/package.json +1 -1
- package/hooks/utils.d.ts +18 -0
- package/hooks/utils.js.map +7 -0
- package/index.js +1 -1
- package/inputs/AutoCompleteInput/AutoComplete.stories.d.ts +2 -0
- package/inputs/AutoCompleteInput/__stories__/Default.d.ts +1 -1
- package/inputs/AutoCompleteInput/__stories__/Multiple.d.ts +1 -1
- package/inputs/AutoCompleteInput/index.d.ts +3 -3
- package/inputs/AutoCompleteInput/index.js +1 -3
- package/inputs/AutoCompleteInput/index.js.map +2 -2
- package/inputs/Checkboxes/Checkboxes.stories.d.ts +2 -0
- package/inputs/Checkboxes/__stories__/Conditional.d.ts +1 -1
- package/inputs/Checkboxes/__stories__/Default.d.ts +1 -1
- package/inputs/Checkboxes/__stories__/WithDivider.d.ts +1 -1
- package/inputs/Checkboxes/index.d.ts +5 -3
- package/inputs/Checkboxes/index.js +68 -62
- package/inputs/Checkboxes/index.js.map +2 -2
- package/inputs/DateInput/DateInput.stories.d.ts +6 -0
- package/inputs/DateInput/__stories__/Default.d.ts +1 -1
- package/inputs/DateInput/__stories__/WithDefaultValue.d.ts +3 -0
- package/inputs/DateInput/__stories__/WithInitialValue.d.ts +3 -0
- package/inputs/DateInput/__stories__/WithWrongDefaultValue.d.ts +3 -0
- package/inputs/DateInput/__stories__/WithWrongInitialValue.d.ts +3 -0
- package/inputs/DateInput/index.d.ts +2 -5
- package/inputs/DateInput/index.js +38 -18
- package/inputs/DateInput/index.js.map +2 -2
- package/inputs/DateTimeInput/DateTimeInput.stories.d.ts +10 -3
- package/inputs/DateTimeInput/__stories__/Default.d.ts +1 -1
- package/inputs/DateTimeInput/__stories__/WithDefaultValue.d.ts +3 -0
- package/inputs/DateTimeInput/__stories__/WithInitialValue.d.ts +3 -0
- package/inputs/DateTimeInput/__stories__/WithWrongDefaultValue.d.ts +3 -0
- package/inputs/DateTimeInput/__stories__/WithWrongInitialValue.d.ts +3 -0
- package/inputs/DateTimeInput/index.d.ts +2 -5
- package/inputs/DateTimeInput/index.js +66 -40
- package/inputs/DateTimeInput/index.js.map +2 -2
- package/inputs/FileInput/FileInput.stories.d.ts +2 -0
- package/inputs/FileInput/__stories__/Default.d.ts +1 -1
- package/inputs/FileInput/index.d.ts +8 -4
- package/inputs/FileInput/index.js +37 -29
- package/inputs/FileInput/index.js.map +2 -2
- package/inputs/ImageInput/ImageInput.stories.d.ts +4 -1
- package/inputs/ImageInput/__stories__/Default.d.ts +1 -1
- package/inputs/ImageInput/__stories__/MaxSize.d.ts +1 -1
- package/inputs/ImageInput/__stories__/WithInitialValues.d.ts +3 -0
- package/inputs/ImageInput/__stories__/WithInvalidImageDimension.d.ts +1 -1
- package/inputs/ImageInput/__stories__/logo.d/index.js +1 -0
- package/inputs/ImageInput/__stories__/logo.d/package.json +6 -0
- package/inputs/ImageInput/__stories__/logo.d.js.map +7 -0
- package/inputs/ImageInput/index.d.ts +10 -2
- package/inputs/ImageInput/index.js +45 -14
- package/inputs/ImageInput/index.js.map +2 -2
- package/inputs/Input/Input.stories.d.ts +3 -0
- package/inputs/Input/__stories__/AFM.d.ts +1 -1
- package/inputs/Input/__stories__/Boolean.d.ts +1 -1
- package/inputs/Input/__stories__/Email.d.ts +3 -0
- package/inputs/Input/__stories__/IBAN.d.ts +1 -1
- package/inputs/Input/__stories__/Integer.d.ts +1 -1
- package/inputs/Input/__stories__/LandlineNumber.d.ts +1 -1
- package/inputs/Input/__stories__/MobilePhone.d.ts +1 -1
- package/inputs/Input/__stories__/PhoneNumber.d.ts +1 -1
- package/inputs/Input/__stories__/PostalCode.d.ts +1 -1
- package/inputs/Input/__stories__/String.d.ts +1 -1
- package/inputs/Input/__stories__/StringWithTrimValidation.d.ts +1 -1
- package/inputs/Input/__stories__/TextWithLimit.d.ts +1 -1
- package/inputs/Input/index.d.ts +3 -1
- package/inputs/Input/index.js +6 -4
- package/inputs/Input/index.js.map +2 -2
- package/inputs/Label/Label.stories.d.ts +2 -0
- package/inputs/Label/__stories__/Default.d.ts +1 -1
- package/inputs/Label/index.d.ts +1 -1
- package/inputs/Label/index.js.map +1 -1
- package/inputs/OtpInput/OtpInput.stories.d.ts +2 -0
- package/inputs/OtpInput/__stories__/Default.d.ts +1 -1
- package/inputs/OtpInput/index.d.ts +1 -5
- package/inputs/OtpInput/index.js +36 -31
- package/inputs/OtpInput/index.js.map +2 -2
- package/inputs/Radio/Radio.stories.d.ts +2 -0
- package/inputs/Radio/__stories__/Conditional.d.ts +1 -1
- package/inputs/Radio/__stories__/Default.d.ts +1 -1
- package/inputs/Radio/__stories__/WithDivider.d.ts +1 -1
- package/inputs/Radio/index.d.ts +6 -4
- package/inputs/Radio/index.js +7 -5
- package/inputs/Radio/index.js.map +3 -3
- package/inputs/Select/Select.stories.d.ts +2 -0
- package/inputs/Select/__stories__/Default.d.ts +1 -1
- package/inputs/Select/index.d.ts +4 -2
- package/inputs/Select/index.js +2 -2
- package/inputs/Select/index.js.map +2 -2
- package/{Field/utils → inputs/registry}/index.js +5 -4
- package/{locales/el → inputs/registry}/package.json +1 -1
- package/{Field/utils/index.d.ts → inputs/registry.d.ts} +2 -1
- package/inputs/registry.js.map +7 -0
- package/lazy/index.js +12 -9
- package/package.json +8 -8
- package/registry/index.js +27 -15
- package/src/Field/ErrorGroup.tsx +3 -3
- package/src/Field/FieldBase.tsx +16 -19
- package/src/Field/FieldBaseContainer.tsx +69 -51
- package/src/Field/FieldConditional.tsx +2 -2
- package/src/Field/index.tsx +18 -37
- package/src/Field/types.tsx +13 -14
- package/src/Field/utils/evaluateFieldWithConditions.ts +5 -2
- package/src/Field/utils/resolveField.ts +58 -0
- package/src/Field/utils/useField.ts +3 -1
- package/src/FieldArray/BaseFieldArray.tsx +97 -0
- package/src/FieldArray/FieldArray.stories.js +1 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/ArrayContainerDisplay.tsx +45 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/ArrayDisplay.stories.js +14 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/ArrayItemDisplay.tsx +337 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/ArrayItemHeader.tsx +15 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/Cards.tsx +88 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/Default.tsx +93 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnly.tsx +79 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/ReadOnlyCards.tsx +75 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/Sortable.tsx +93 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/__stories__/SortableCards.tsx +88 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/index.test.tsx +44 -0
- package/src/FieldArray/FormDialog/ArrayDisplay/index.tsx +67 -0
- package/src/FieldArray/FormDialog/ArrayEditModal.tsx +241 -0
- package/src/FieldArray/FormDialog/index.tsx +302 -0
- package/src/FieldArray/__stories__/CardsWithError.tsx +124 -0
- package/src/FieldArray/__stories__/Default.tsx +1 -1
- package/src/FieldArray/__stories__/WithExactLength.tsx +1 -1
- package/src/FieldArray/__stories__/WithModal.tsx +1 -1
- package/src/FieldArray/__tests__/fieldset-multiplicity.spec.tsx +271 -0
- package/src/FieldArray/__tests__/multiplicity-attachment.spec.tsx +280 -0
- package/src/FieldArray/__tests__/multiplicity-optional.spec.tsx +232 -0
- package/src/FieldArray/__tests__/multiplicity-required.spec.tsx +170 -0
- package/src/FieldArray/__tests__/nested-fieldset-multiplicity.spec.tsx +627 -0
- package/src/FieldArray/__tests__/preference-multiple-choice.spec.tsx +222 -0
- package/src/FieldArray/index.spec.tsx +355 -0
- package/src/FieldArray/index.test.tsx +4 -0
- package/src/FieldArray/index.tsx +73 -112
- package/src/FieldObject/index.tsx +9 -17
- package/src/Fieldset/FieldsetWithContext.tsx +1 -1
- package/src/Fieldset/index.tsx +1 -1
- package/src/Fieldset/types.tsx +2 -2
- package/src/FormBuilder/FormBuilder.stories.js +3 -0
- package/src/FormBuilder/__stories__/AutoErrorGrouping.tsx +1 -1
- package/src/FormBuilder/__stories__/Default.tsx +1 -1
- package/src/FormBuilder/__stories__/ErrorGrouping.tsx +1 -1
- package/src/FormBuilder/index.tsx +191 -149
- package/src/FormBuilder/scenarios.test.tsx +761 -2
- package/src/FormContext.tsx +7 -2
- package/src/MultiplicityField/MultiplicityField.stories.js +3 -0
- package/src/MultiplicityField/__stories__/Default.tsx +1 -1
- package/src/MultiplicityField/__stories__/PreviewDisplay.tsx +2 -4
- package/src/MultiplicityField/__stories__/WithExactLength.tsx +1 -1
- package/src/MultiplicityField/__stories__/WithMaxLength.tsx +1 -1
- package/src/MultiplicityField/__stories__/WithMinAndMaxLength.tsx +1 -1
- package/src/MultiplicityField/__stories__/WithMinLength.tsx +1 -1
- package/src/MultiplicityField/add-objects.tsx +13 -22
- package/src/MultiplicityField/index.tsx +6 -3
- package/src/MultiplicityField/types.ts +6 -2
- package/src/Questions/Questions.stories.js +3 -0
- package/src/Questions/Questions.tsx +2 -2
- package/src/Questions/QuestionsContext.tsx +1 -1
- package/src/Questions/Step/Step.tsx +1 -1
- package/src/Questions/Step/StepArrayReview.tsx +2 -2
- package/src/Questions/Step/StepContext.tsx +1 -1
- package/src/Questions/Step/StepDescription.tsx +2 -1
- package/src/Questions/Step/StepForm.tsx +2 -2
- package/src/Questions/Step/StepQuote.tsx +2 -1
- package/src/Questions/Step/StepTitle.tsx +2 -1
- package/src/Questions/Step/getAddMoreFields.tsx +2 -2
- package/src/Questions/Step/types.tsx +1 -1
- package/src/Questions/__stories__/Default.tsx +1 -1
- package/src/Questions/getNextStep.tsx +1 -1
- package/src/Questions/types.tsx +1 -1
- package/src/hooks/__tests__/useFieldFocusManager.spec.tsx +1079 -0
- package/src/hooks/__tests__/utils.spec.ts +568 -0
- package/src/hooks/useFieldFocusManager.ts +162 -0
- package/src/hooks/utils.ts +122 -0
- package/src/inputs/AutoCompleteInput/AutoComplete.stories.js +3 -0
- package/src/inputs/AutoCompleteInput/__stories__/Default.tsx +1 -1
- package/src/inputs/AutoCompleteInput/__stories__/Multiple.tsx +1 -1
- package/src/inputs/AutoCompleteInput/index.tsx +4 -6
- package/src/inputs/Checkboxes/Checkboxes.stories.js +3 -0
- package/src/inputs/Checkboxes/__stories__/Conditional.tsx +1 -1
- package/src/inputs/Checkboxes/__stories__/Default.tsx +1 -1
- package/src/inputs/Checkboxes/__stories__/WithDivider.tsx +1 -1
- package/src/inputs/Checkboxes/index.tsx +98 -88
- package/src/inputs/DateInput/DateInput.stories.js +7 -0
- package/src/inputs/DateInput/__stories__/Default.tsx +1 -1
- package/src/inputs/DateInput/__stories__/WithDefaultValue.tsx +26 -0
- package/src/inputs/DateInput/__stories__/WithInitialValue.tsx +28 -0
- package/src/inputs/DateInput/__stories__/WithWrongDefaultValue.tsx +26 -0
- package/src/inputs/DateInput/__stories__/WithWrongInitialValue.tsx +28 -0
- package/src/inputs/DateInput/index.test.tsx +16 -0
- package/src/inputs/DateInput/index.tsx +50 -19
- package/src/inputs/DateTimeInput/DateTimeInput.stories.js +12 -6
- package/src/inputs/DateTimeInput/__stories__/Default.tsx +1 -1
- package/src/inputs/DateTimeInput/__stories__/WithDefaultValue.tsx +26 -0
- package/src/inputs/DateTimeInput/__stories__/WithInitialValue.tsx +28 -0
- package/src/inputs/DateTimeInput/__stories__/WithWrongDefaultValue.tsx +26 -0
- package/src/inputs/DateTimeInput/__stories__/WithWrongInitialValue.tsx +28 -0
- package/src/inputs/DateTimeInput/index.test.tsx +16 -0
- package/src/inputs/DateTimeInput/index.tsx +78 -41
- package/src/inputs/FileInput/FileInput.stories.js +3 -0
- package/src/inputs/FileInput/__stories__/Default.tsx +1 -1
- package/src/inputs/FileInput/index.tsx +68 -41
- package/src/inputs/ImageInput/ImageInput.stories.js +5 -1
- package/src/inputs/ImageInput/__stories__/Default.tsx +1 -1
- package/src/inputs/ImageInput/__stories__/MaxSize.tsx +3 -2
- package/src/inputs/ImageInput/__stories__/WithInitialValues.tsx +45 -0
- package/src/inputs/ImageInput/__stories__/WithInvalidImageDimension.tsx +1 -1
- package/src/inputs/ImageInput/__stories__/logo.d.ts +4 -0
- package/src/inputs/ImageInput/__stories__/logo.png +0 -0
- package/src/inputs/ImageInput/index.test.tsx +4 -0
- package/src/inputs/ImageInput/index.tsx +102 -50
- package/src/inputs/Input/Input.stories.js +4 -0
- package/src/inputs/Input/__stories__/AFM.tsx +1 -1
- package/src/inputs/Input/__stories__/Boolean.tsx +1 -1
- package/src/inputs/Input/__stories__/Email.tsx +23 -0
- package/src/inputs/Input/__stories__/IBAN.tsx +1 -1
- package/src/inputs/Input/__stories__/Integer.tsx +1 -1
- package/src/inputs/Input/__stories__/LandlineNumber.tsx +1 -1
- package/src/inputs/Input/__stories__/MobilePhone.tsx +1 -1
- package/src/inputs/Input/__stories__/PhoneNumber.tsx +1 -1
- package/src/inputs/Input/__stories__/PostalCode.tsx +1 -1
- package/src/inputs/Input/__stories__/String.tsx +1 -1
- package/src/inputs/Input/__stories__/StringWithTrimValidation.tsx +1 -1
- package/src/inputs/Input/__stories__/TextWithLimit.tsx +1 -1
- package/src/inputs/Input/index.test.tsx +8 -0
- package/src/inputs/Input/index.tsx +13 -8
- package/src/inputs/Label/Label.stories.js +3 -0
- package/src/inputs/Label/__stories__/Default.tsx +1 -1
- package/src/inputs/Label/index.tsx +1 -1
- package/src/inputs/OtpInput/OtpInput.stories.js +3 -0
- package/src/inputs/OtpInput/__stories__/Default.tsx +1 -1
- package/src/inputs/OtpInput/index.tsx +43 -34
- package/src/inputs/Radio/Radio.stories.js +3 -0
- package/src/inputs/Radio/__stories__/Conditional.tsx +1 -1
- package/src/inputs/Radio/__stories__/Default.tsx +1 -1
- package/src/inputs/Radio/__stories__/WithDivider.tsx +1 -1
- package/src/inputs/Radio/index.tsx +33 -22
- package/src/inputs/Select/Select.stories.js +3 -0
- package/src/inputs/Select/__stories__/Default.tsx +1 -1
- package/src/inputs/Select/index.tsx +6 -4
- package/src/{Field/utils/index.ts → inputs/registry.ts} +5 -2
- package/src/lazy.js +12 -9
- package/src/registry.js +27 -15
- package/src/types.tsx +13 -5
- package/src/utils.ts +14 -2
- package/src/validators/index.ts +28 -24
- package/src/validators/types.ts +1 -1
- package/src/validators/utils/date.ts +30 -6
- package/src/validators/utils/datetime.ts +123 -31
- package/src/validators/utils/email.ts +11 -0
- package/src/validators/utils/file.ts +2 -2
- package/src/validators/utils/iban.ts +2 -2
- package/src/validators/utils/image.ts +2 -2
- package/src/validators/utils/index.ts +2 -2
- package/src/validators/utils/int.ts +1 -1
- package/src/validators/utils/number.ts +1 -1
- package/src/validators/utils/otp.ts +2 -2
- package/src/validators/utils/phone.ts +2 -2
- package/src/validators/utils/postal_code.ts +2 -2
- package/src/validators/utils/text_limit.ts +2 -2
- package/types.d.ts +9 -4
- package/types.js.map +1 -1
- package/utils/index.js +8 -0
- package/utils.d.ts +2 -1
- package/utils.js.map +2 -2
- package/validators/index.d.ts +5 -5
- package/validators/index.js +13 -12
- package/validators/index.js.map +2 -2
- package/validators/types.d.ts +1 -1
- package/validators/utils/date/index.js +26 -3
- package/validators/utils/date.d.ts +3 -3
- package/validators/utils/date.js.map +2 -2
- package/validators/utils/datetime/index.js +118 -24
- package/validators/utils/datetime.d.ts +3 -3
- package/validators/utils/datetime.js.map +2 -2
- package/validators/utils/email/index.js +16 -0
- package/validators/utils/email/package.json +6 -0
- package/validators/utils/email.d.ts +5 -0
- package/validators/utils/email.js.map +7 -0
- package/validators/utils/file.d.ts +2 -2
- package/validators/utils/file.js.map +1 -1
- package/validators/utils/iban.d.ts +2 -2
- package/validators/utils/iban.js.map +1 -1
- package/validators/utils/image.d.ts +2 -2
- package/validators/utils/image.js.map +1 -1
- package/validators/utils/index.d.ts +2 -2
- package/validators/utils/index.js.map +1 -1
- package/validators/utils/int.d.ts +1 -1
- package/validators/utils/int.js.map +1 -1
- package/validators/utils/number.d.ts +1 -1
- package/validators/utils/number.js.map +1 -1
- package/validators/utils/otp.d.ts +2 -2
- package/validators/utils/otp.js.map +1 -1
- package/validators/utils/phone.d.ts +2 -2
- package/validators/utils/phone.js.map +1 -1
- package/validators/utils/postal_code.d.ts +2 -2
- package/validators/utils/postal_code.js.map +1 -1
- package/validators/utils/text_limit.d.ts +2 -2
- package/validators/utils/text_limit.js.map +1 -1
- package/Field/utils/calculateField/index.js +0 -27
- package/Field/utils/calculateField.d.ts +0 -2
- package/Field/utils/calculateField.js.map +0 -7
- package/Field/utils/index.js.map +0 -7
- package/FieldArray/FormDialog.d.ts +0 -67
- package/FieldArray/FormDialog.js.map +0 -7
- package/FormBuilder/index.test.d.ts +0 -1
- package/FormBuilder/interaction.test.d.ts +0 -1
- package/FormBuilder/scenarios.test.d.ts +0 -88
- package/MultiplicityField/index.test.d.ts +0 -1
- package/Questions/index.spec.d.ts +0 -1
- package/Questions/index.test.d.ts +0 -1
- package/cjs/Field/utils/calculateField/index.js +0 -50
- package/cjs/Field/utils/calculateField.js.map +0 -7
- package/cjs/Field/utils/index.js.map +0 -7
- package/cjs/FieldArray/FormDialog.js.map +0 -7
- package/cjs/inputs/Input/inputsInputScenarios/index.js +0 -439
- package/cjs/inputs/Input/inputsInputScenarios.js.map +0 -7
- package/cjs/inputs/inputsScenarios/index.js +0 -533
- package/cjs/inputs/inputsScenarios.js.map +0 -7
- package/cjs/locales/el.js.map +0 -7
- package/inputs/AutoCompleteInput/index.test.d.ts +0 -1
- package/inputs/Checkboxes/index.test.d.ts +0 -1
- package/inputs/DateInput/index.test.d.ts +0 -1
- package/inputs/DateTimeInput/index.test.d.ts +0 -1
- package/inputs/FileInput/index.test.d.ts +0 -1
- package/inputs/ImageInput/index.test.d.ts +0 -1
- package/inputs/Input/index.test.d.ts +0 -1
- package/inputs/Input/inputsInputScenarios/index.js +0 -406
- package/inputs/Input/inputsInputScenarios.d.ts +0 -57
- package/inputs/Input/inputsInputScenarios.js.map +0 -7
- package/inputs/Label/index.test.d.ts +0 -1
- package/inputs/OtpInput/index.test.d.ts +0 -1
- package/inputs/Radio/index.test.d.ts +0 -1
- package/inputs/Select/index.test.d.ts +0 -1
- package/inputs/inputsScenarios/index.js +0 -499
- package/inputs/inputsScenarios.d.ts +0 -296
- package/inputs/inputsScenarios.js.map +0 -7
- package/locales/el/index.js +0 -6
- package/locales/el.d.ts +0 -2
- package/locales/el.js.map +0 -7
- package/src/Field/utils/calculateField.ts +0 -49
- package/src/FieldArray/FormDialog.tsx +0 -574
- package/src/inputs/Input/inputsInputScenarios.ts +0 -404
- package/src/inputs/inputsScenarios.ts +0 -496
- package/src/locales/el.ts +0 -3
- /package/{FieldArray/index.test.d.ts → hooks/__tests__/utils.spec.d.ts} +0 -0
package/inputs/Input/index.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { useWatch } from "react-hook-form";
|
|
3
|
+
import { omit } from "@digigov/form/utils";
|
|
3
4
|
import { TextArea } from "@digigov/ui/form/TextArea";
|
|
4
5
|
import { TextInput } from "@digigov/ui/form/TextInput";
|
|
5
6
|
import { useTranslation } from "@digigov/ui/i18n";
|
|
6
7
|
import { Hint } from "@digigov/ui/typography/Hint";
|
|
7
8
|
const TYPES_MAP = {
|
|
8
9
|
string: "text",
|
|
10
|
+
password: "password",
|
|
9
11
|
int: "text",
|
|
10
12
|
text: "text",
|
|
11
13
|
date: "date"
|
|
12
14
|
};
|
|
13
15
|
const Input = React.forwardRef(
|
|
14
16
|
function WrappedInput({ name, control, type, extra, ...props }, ref) {
|
|
15
|
-
delete props["Field"];
|
|
16
17
|
let { multiline = false, rows, limit } = extra || {};
|
|
17
18
|
const { className } = extra || {};
|
|
18
19
|
multiline = multiline === true || type === "text";
|
|
@@ -32,6 +33,7 @@ const Input = React.forwardRef(
|
|
|
32
33
|
remainingText += remainingChars > 0 ? ` ${t("form.info.text.remaining")}.` : ` ${t("form.info.text.too_many")}.`;
|
|
33
34
|
return remainingText;
|
|
34
35
|
};
|
|
36
|
+
const transformedProps = omit(props, ["Field", "resetField"]);
|
|
35
37
|
if (multiline === true) {
|
|
36
38
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
37
39
|
TextArea,
|
|
@@ -42,13 +44,13 @@ const Input = React.forwardRef(
|
|
|
42
44
|
ref,
|
|
43
45
|
id: name,
|
|
44
46
|
...{
|
|
45
|
-
...
|
|
47
|
+
...transformedProps,
|
|
46
48
|
reset: void 0,
|
|
47
49
|
required: void 0,
|
|
48
50
|
type: fieldType
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
|
-
), limit?.max && /* @__PURE__ */ React.createElement(Hint, { display: "flex" }, t("form.info.text.you_have"), /* @__PURE__ */ React.createElement(
|
|
53
|
+
), limit?.max && /* @__PURE__ */ React.createElement(Hint, { display: "flex" }, t("form.info.text.you_have"), /* @__PURE__ */ React.createElement("strong", null, "\xA0", `${Math.abs(getRemainingChars(currentValue, limit))}`, "\xA0"), constructRemainingText(currentValue, limit)));
|
|
52
54
|
} else {
|
|
53
55
|
return /* @__PURE__ */ React.createElement(
|
|
54
56
|
TextInput,
|
|
@@ -60,7 +62,7 @@ const Input = React.forwardRef(
|
|
|
60
62
|
className,
|
|
61
63
|
ref,
|
|
62
64
|
...{
|
|
63
|
-
...
|
|
65
|
+
...transformedProps,
|
|
64
66
|
reset: void 0,
|
|
65
67
|
required: void 0
|
|
66
68
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/inputs/Input/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport { useWatch } from 'react-hook-form';\nimport { UncontrolledFieldProps } from '@digigov/form/Field/types';\nimport { TextArea } from '@digigov/ui/form/TextArea';\nimport { TextInput } from '@digigov/ui/form/TextInput';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport { Hint } from '@digigov/ui/typography/Hint';\n\nconst TYPES_MAP = {\n string: 'text',\n int: 'text',\n text: 'text',\n date: 'date',\n};\n\nexport interface InputProps\n extends Omit<UncontrolledFieldProps, 'extra' | 'Field'> {\n extra?: {\n fullWidth?: boolean;\n multiline?: boolean;\n className?: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n rows?: any;\n limit: {\n min?: number;\n max?: number;\n };\n };\n Field?: UncontrolledFieldProps['Field'];\n}\n\nexport const Input: React.ExoticComponent<InputProps> = React.forwardRef(\n function WrappedInput({ name, control, type, extra, ...props }, ref: never) {\n
|
|
5
|
-
"mappings": "AAAA,OAAO,WAAW;
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport type { UseFormReturn } from 'react-hook-form';\nimport { useWatch } from 'react-hook-form';\nimport type { UncontrolledFieldProps } from '@digigov/form/Field/types';\nimport { omit } from '@digigov/form/utils';\nimport { TextArea } from '@digigov/ui/form/TextArea';\nimport { TextInput } from '@digigov/ui/form/TextInput';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport { Hint } from '@digigov/ui/typography/Hint';\n\nconst TYPES_MAP = {\n string: 'text',\n password: 'password',\n int: 'text',\n text: 'text',\n date: 'date',\n};\n\nexport interface InputProps\n extends Omit<UncontrolledFieldProps, 'extra' | 'Field'> {\n extra?: {\n fullWidth?: boolean;\n multiline?: boolean;\n className?: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n rows?: any;\n limit: {\n min?: number;\n max?: number;\n };\n };\n Field?: UncontrolledFieldProps['Field'];\n resetField: UseFormReturn['resetField'];\n}\n\nexport const Input: React.ExoticComponent<InputProps> = React.forwardRef(\n function WrappedInput({ name, control, type, extra, ...props }, ref: never) {\n // eslint-disable-next-line prefer-const\n let { multiline = false, rows, limit } = extra || {};\n const { className } = extra || {};\n // if enforced to multiline use true. Derive from type otherwise.\n multiline = multiline === true || type === 'text';\n // use explicit rows value if set. Derive from multiline otherwise.\n rows = rows || (multiline ? 4 : 1);\n // translate dilosi type to HTML Input type\n const fieldType = TYPES_MAP[type || 'text'] || 'text';\n const { t } = useTranslation();\n const currentValue: string | '' = useWatch({ control, name });\n\n const getRemainingChars = (currentValue, limit) => {\n if (currentValue) {\n return limit?.max - currentValue.length;\n }\n return limit?.max;\n };\n\n const constructRemainingText = (currentValue, limit) => {\n const remainingChars = getRemainingChars(currentValue, limit);\n let remainingText =\n Math.abs(remainingChars) === 1\n ? t('form.info.text.character')\n : t('form.info.text.characters');\n remainingText +=\n remainingChars > 0\n ? ` ${t('form.info.text.remaining')}.`\n : ` ${t('form.info.text.too_many')}.`;\n return remainingText;\n };\n\n const transformedProps = omit(props, ['Field', 'resetField']);\n\n if (multiline === true) {\n return (\n <>\n <TextArea\n name={name}\n className={className}\n rows={rows}\n ref={ref as React.RefObject<HTMLTextAreaElement>}\n id={name}\n {...{\n ...transformedProps,\n reset: undefined,\n required: undefined,\n type: fieldType,\n }}\n />\n {limit?.max && (\n <Hint display={'flex'}>\n {t('form.info.text.you_have')}\n <strong>\n {`${Math.abs(getRemainingChars(currentValue, limit))}`}\n \n </strong>\n {constructRemainingText(currentValue, limit)}\n </Hint>\n )}\n </>\n );\n } else {\n return (\n <TextInput\n name={name}\n id={name}\n type={fieldType}\n data-type={type}\n className={className}\n ref={ref as React.RefObject<HTMLInputElement>}\n {...{\n ...transformedProps,\n reset: undefined,\n required: undefined,\n }}\n />\n );\n }\n }\n);\n\nexport default Input;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,WAAW;AAElB,SAAS,gBAAgB;AAEzB,SAAS,YAAY;AACrB,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAC/B,SAAS,YAAY;AAErB,MAAM,YAAY;AAAA,EAChB,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM;AACR;AAmBO,MAAM,QAA2C,MAAM;AAAA,EAC5D,SAAS,aAAa,EAAE,MAAM,SAAS,MAAM,OAAO,GAAG,MAAM,GAAG,KAAY;AAE1E,QAAI,EAAE,YAAY,OAAO,MAAM,MAAM,IAAI,SAAS,CAAC;AACnD,UAAM,EAAE,UAAU,IAAI,SAAS,CAAC;AAEhC,gBAAY,cAAc,QAAQ,SAAS;AAE3C,WAAO,SAAS,YAAY,IAAI;AAEhC,UAAM,YAAY,UAAU,QAAQ,MAAM,KAAK;AAC/C,UAAM,EAAE,EAAE,IAAI,eAAe;AAC7B,UAAM,eAA4B,SAAS,EAAE,SAAS,KAAK,CAAC;AAE5D,UAAM,oBAAoB,CAACA,eAAcC,WAAU;AACjD,UAAID,eAAc;AAChB,eAAOC,QAAO,MAAMD,cAAa;AAAA,MACnC;AACA,aAAOC,QAAO;AAAA,IAChB;AAEA,UAAM,yBAAyB,CAACD,eAAcC,WAAU;AACtD,YAAM,iBAAiB,kBAAkBD,eAAcC,MAAK;AAC5D,UAAI,gBACF,KAAK,IAAI,cAAc,MAAM,IACzB,EAAE,0BAA0B,IAC5B,EAAE,2BAA2B;AACnC,uBACE,iBAAiB,IACb,IAAI,EAAE,0BAA0B,CAAC,MACjC,IAAI,EAAE,yBAAyB,CAAC;AACtC,aAAO;AAAA,IACT;AAEA,UAAM,mBAAmB,KAAK,OAAO,CAAC,SAAS,YAAY,CAAC;AAE5D,QAAI,cAAc,MAAM;AACtB,aACE,0DACE;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,IAAI;AAAA,UACH,GAAG;AAAA,YACF,GAAG;AAAA,YACH,OAAO;AAAA,YACP,UAAU;AAAA,YACV,MAAM;AAAA,UACR;AAAA;AAAA,MACF,GACC,OAAO,OACN,oCAAC,QAAK,SAAS,UACZ,EAAE,yBAAyB,GAC5B,oCAAC,gBAAO,QACC,GAAG,KAAK,IAAI,kBAAkB,cAAc,KAAK,CAAC,CAAC,IAAG,MAE/D,GACC,uBAAuB,cAAc,KAAK,CAC7C,CAEJ;AAAA,IAEJ,OAAO;AACL,aACE;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA,IAAI;AAAA,UACJ,MAAM;AAAA,UACN,aAAW;AAAA,UACX;AAAA,UACA;AAAA,UACC,GAAG;AAAA,YACF,GAAG;AAAA,YACH,OAAO;AAAA,YACP,UAAU;AAAA,UACZ;AAAA;AAAA,MACF;AAAA,IAEJ;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;",
|
|
6
6
|
"names": ["currentValue", "limit"]
|
|
7
7
|
}
|
package/inputs/Label/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/inputs/Label/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport { FieldLabelProps } from '@digigov/form/types';\nimport { LabelTitle } from '@digigov/ui/form/LabelContainer';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport { Hint } from '@digigov/ui/typography/Hint';\n\nexport interface FieldOptionProps {\n label?: FieldLabelProps;\n value: string;\n show?: string[];\n disabled?: boolean;\n selected?: () => React.ReactNode;\n divider?: string;\n}\n\nexport interface LabelProps {\n primary?: string;\n secondary?: string;\n className?: string;\n value?: string;\n label?: FieldLabelProps;\n}\n\nexport const Label: React.FC<LabelProps> = ({ className, label, value }) => {\n const { t } = useTranslation();\n if ((!label || (label && !label.primary && !label.secondary)) && !value) {\n return null;\n }\n return (\n <>\n <LabelTitle className={className} size=\"sm\">\n {(label && label.primary && t(label.primary)) || value}\n </LabelTitle>\n {label && label.secondary && <Hint>{t(label.secondary)}</Hint>}\n </>\n );\n};\n\nexport default Label;\n"],
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport type { FieldLabelProps } from '@digigov/form/types';\nimport { LabelTitle } from '@digigov/ui/form/LabelContainer';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport { Hint } from '@digigov/ui/typography/Hint';\n\nexport interface FieldOptionProps {\n label?: FieldLabelProps;\n value: string;\n show?: string[];\n disabled?: boolean;\n selected?: () => React.ReactNode;\n divider?: string;\n}\n\nexport interface LabelProps {\n primary?: string;\n secondary?: string;\n className?: string;\n value?: string;\n label?: FieldLabelProps;\n}\n\nexport const Label: React.FC<LabelProps> = ({ className, label, value }) => {\n const { t } = useTranslation();\n if ((!label || (label && !label.primary && !label.secondary)) && !value) {\n return null;\n }\n return (\n <>\n <LabelTitle className={className} size=\"sm\">\n {(label && label.primary && t(label.primary)) || value}\n </LabelTitle>\n {label && label.secondary && <Hint>{t(label.secondary)}</Hint>}\n </>\n );\n};\n\nexport default Label;\n"],
|
|
5
5
|
"mappings": "AAAA,OAAO,WAAW;AAElB,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,SAAS,YAAY;AAmBd,MAAM,QAA8B,CAAC,EAAE,WAAW,OAAO,MAAM,MAAM;AAC1E,QAAM,EAAE,EAAE,IAAI,eAAe;AAC7B,OAAK,CAAC,SAAU,SAAS,CAAC,MAAM,WAAW,CAAC,MAAM,cAAe,CAAC,OAAO;AACvE,WAAO;AAAA,EACT;AACA,SACE,0DACE,oCAAC,cAAW,WAAsB,MAAK,QACnC,SAAS,MAAM,WAAW,EAAE,MAAM,OAAO,KAAM,KACnD,GACC,SAAS,MAAM,aAAa,oCAAC,YAAM,EAAE,MAAM,SAAS,CAAE,CACzD;AAEJ;AAEA,IAAO,gBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -8,9 +8,5 @@ export declare function useOtp(onChange: any, maxLength: any): {
|
|
|
8
8
|
handleFocus: (e: React.FocusEvent<HTMLInputElement>) => void;
|
|
9
9
|
handlePaste: (e: React.ClipboardEvent<HTMLInputElement>) => void;
|
|
10
10
|
};
|
|
11
|
-
export declare const OtpInput:
|
|
12
|
-
[x: string]: any;
|
|
13
|
-
name: any;
|
|
14
|
-
maxLength?: number | undefined;
|
|
15
|
-
}) => React.JSX.Element;
|
|
11
|
+
export declare const OtpInput: React.ForwardRefExoticComponent<Omit<Record<string, any>, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
16
12
|
export default OtpInput;
|
package/inputs/OtpInput/index.js
CHANGED
|
@@ -105,37 +105,42 @@ function useOtp(onChange, maxLength) {
|
|
|
105
105
|
handlePaste
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
|
-
const SingleCharacterInputPart = ({ ...props }) => {
|
|
109
|
-
return /* @__PURE__ */ React.createElement(SingleCharacterInput, { ...props });
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
108
|
+
const SingleCharacterInputPart = React.forwardRef(({ ...props }, ref) => {
|
|
109
|
+
return /* @__PURE__ */ React.createElement(SingleCharacterInput, { ...props, ref });
|
|
110
|
+
});
|
|
111
|
+
SingleCharacterInputPart.displayName = "SingleCharacterInputPart";
|
|
112
|
+
const OtpInput = React.forwardRef(
|
|
113
|
+
({ name, maxLength = 6, ...props }, ref) => {
|
|
114
|
+
const otp = useOtp(props.onChange, maxLength);
|
|
115
|
+
return /* @__PURE__ */ React.createElement(SingleCharacterInputs, null, otp.otpValues.map((digit, idx) => /* @__PURE__ */ React.createElement(
|
|
116
|
+
SingleCharacterInputPart,
|
|
117
|
+
{
|
|
118
|
+
ref: idx === 0 ? ref : null,
|
|
119
|
+
name: `${name}-${idx}`,
|
|
120
|
+
id: `${name}-${idx}`,
|
|
121
|
+
type: "text",
|
|
122
|
+
key: idx,
|
|
123
|
+
autoComplete: "one-time-code",
|
|
124
|
+
pattern: "\\d{1}",
|
|
125
|
+
maxLength,
|
|
126
|
+
value: digit,
|
|
127
|
+
disabled: props.disabled,
|
|
128
|
+
"aria-required": props["aria-required"],
|
|
129
|
+
onChange: (e) => otp.handleOtpChange(e, idx),
|
|
130
|
+
onInput: (e) => {
|
|
131
|
+
if (e.target.value === digit) {
|
|
132
|
+
otp.handleOtpChange(e, idx);
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
onKeyDown: (e) => otp.handleKeyDown(e, idx),
|
|
136
|
+
onFocus: otp.handleFocus,
|
|
137
|
+
onPaste: otp.handlePaste,
|
|
138
|
+
error: !digit ? props.error : false
|
|
139
|
+
}
|
|
140
|
+
)));
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
OtpInput.displayName = "OtpInput";
|
|
139
144
|
var OtpInput_default = OtpInput;
|
|
140
145
|
export {
|
|
141
146
|
OtpInput,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/inputs/OtpInput/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useState, useCallback } from 'react';\nimport SingleCharacterInputs, {\n SingleCharacterInput,\n} from '@digigov/ui/form/SingleCharacterInputs';\n\nexport const RE_DIGIT = new RegExp(/^\\d+$/);\nexport const REMOVE_SPACES = new RegExp(/\\s+/g);\n\nexport function useOtp(onChange, maxLength) {\n const [otpValues, setOtpValues] = useState(Array<string>(maxLength).fill(''));\n const handleChange = useCallback(\n (otp: string[]) => {\n setOtpValues(otp);\n const otpValue = otp.join('');\n onChange(otpValue);\n },\n [onChange]\n );\n\n const setOtp = (item: string, idx) => {\n const updatedOTPValues = [...otpValues];\n if (item.length === 1 || item.length === 0) {\n updatedOTPValues[idx] = item[0] || '';\n handleChange(updatedOTPValues);\n } else if (item.length === maxLength) {\n const valueArray = item.split('').slice(0, maxLength);\n handleChange(valueArray);\n }\n };\n\n const setSelectionRange = useCallback((target) => {\n return target.setSelectionRange(0, target.value.length);\n }, []);\n\n const focusToNextInput = useCallback((target: HTMLElement) => {\n const nextElement = target.nextElementSibling as HTMLInputElement | null;\n if (nextElement) {\n nextElement.focus();\n }\n }, []);\n\n const focusToPrevInput = useCallback((target: HTMLElement) => {\n const previousElement =\n target.previousElementSibling as HTMLInputElement | null;\n if (previousElement) {\n previousElement.focus();\n }\n }, []);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLInputElement>, idx: number) => {\n const { key } = e;\n const target = e.target as HTMLInputElement;\n let targetValue = target.value;\n setSelectionRange(target);\n if (key === 'ArrowRight' || key === 'ArrowDown') {\n e.preventDefault();\n return focusToNextInput(target);\n }\n if (key === 'ArrowLeft' || key === 'ArrowUp') {\n e.preventDefault();\n return focusToPrevInput(target);\n }\n if (e.key === 'Backspace' || e.key === 'Delete') {\n if (targetValue !== '') {\n targetValue = '';\n } else {\n focusToPrevInput(target);\n }\n setOtp(targetValue, idx);\n return e.preventDefault();\n }\n },\n [setOtp, focusToPrevInput, focusToNextInput]\n );\n\n const handleFocus = useCallback(\n (e: React.FocusEvent<HTMLInputElement>) => {\n const { target } = e;\n setSelectionRange(target);\n },\n [setSelectionRange]\n );\n const handleOtpChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>, idx: number) => {\n const target = e.target;\n const targetValue = target.value;\n const isTargetValueDigit = RE_DIGIT.test(targetValue);\n // We want to pass the empty string when the value is deleted\n // emptry string replaces the deleted value\n if (isTargetValueDigit || targetValue === '') {\n setOtp(targetValue, idx);\n if (target.value.length > 1) {\n target.blur();\n }\n focusToNextInput(target);\n }\n },\n [setOtp, handleKeyDown, handleFocus]\n );\n\n const handlePaste = useCallback(\n (e: React.ClipboardEvent<HTMLInputElement>) => {\n e.preventDefault();\n const pastedData = e.clipboardData\n .getData('text/plain')\n .replace(REMOVE_SPACES, '');\n if (pastedData) {\n setOtp(pastedData, 0);\n }\n },\n []\n );\n return {\n otpValues,\n handleOtpChange,\n handleKeyDown,\n handleFocus,\n handlePaste,\n };\n}\n\nconst SingleCharacterInputPart = ({ ...props }) => {\n return <SingleCharacterInput {...props} />;\n};\n\nexport const OtpInput = ({ name, maxLength = 6, ...props }) => {\n
|
|
5
|
-
"mappings": "AAAA,OAAO,SAAS,UAAU,mBAAmB;AAC7C,OAAO;AAAA,EACL;AAAA,OACK;AAEA,MAAM,WAAW,IAAI,OAAO,OAAO;AACnC,MAAM,gBAAgB,IAAI,OAAO,MAAM;AAEvC,SAAS,OAAO,UAAU,WAAW;AAC1C,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,MAAc,SAAS,EAAE,KAAK,EAAE,CAAC;AAC5E,QAAM,eAAe;AAAA,IACnB,CAAC,QAAkB;AACjB,mBAAa,GAAG;AAChB,YAAM,WAAW,IAAI,KAAK,EAAE;AAC5B,eAAS,QAAQ;AAAA,IACnB;AAAA,IACA,CAAC,QAAQ;AAAA,E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,eAAO,aAAa,GAAG;AACvB,eAAO,EAAE,eAAe;AAAA,MAC1B;AAAA,IACF;AAAA,IACA,CAAC,QAAQ,kBAAkB,gBAAgB;AAAA,EAC7C;AAEA,QAAM,cAAc;AAAA,IAClB,CAAC,MAA0C;AACzC,YAAM,EAAE,OAAO,IAAI;AACnB,wBAAkB,MAAM;AAAA,IAC1B;AAAA,IACA,CAAC,iBAAiB;AAAA,EACpB;AACA,QAAM,kBAAkB;AAAA,IACtB,CAAC,GAAwC,QAAgB;AACvD,YAAM,SAAS,EAAE;AACjB,YAAM,cAAc,OAAO;AAC3B,YAAM,qBAAqB,SAAS,KAAK,WAAW;AAGpD,UAAI,sBAAsB,gBAAgB,IAAI;AAC5C,eAAO,aAAa,GAAG;AACvB,YAAI,OAAO,MAAM,SAAS,GAAG;AAC3B,iBAAO,KAAK;AAAA,QACd;AACA,yBAAiB,MAAM;AAAA,MACzB;AAAA,IACF;AAAA,IACA,CAAC,QAAQ,eAAe,WAAW;AAAA,EACrC;AAEA,QAAM,cAAc;AAAA,IAClB,CAAC,MAA8C;AAC7C,QAAE,eAAe;AACjB,YAAM,aAAa,EAAE,cAClB,QAAQ,YAAY,EACpB,QAAQ,eAAe,EAAE;AAC5B,UAAI,YAAY;AACd,eAAO,YAAY,CAAC;AAAA,MACtB;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AACA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEA,MAAM,2BAA2B,CAAC,EAAE,GAAG,MAAM,
|
|
4
|
+
"sourcesContent": ["import React, { useState, useCallback } from 'react';\nimport SingleCharacterInputs, {\n SingleCharacterInput,\n} from '@digigov/ui/form/SingleCharacterInputs';\n\nexport const RE_DIGIT = new RegExp(/^\\d+$/);\nexport const REMOVE_SPACES = new RegExp(/\\s+/g);\n\nexport function useOtp(onChange, maxLength) {\n const [otpValues, setOtpValues] = useState(Array<string>(maxLength).fill(''));\n const handleChange = useCallback(\n (otp: string[]) => {\n setOtpValues(otp);\n const otpValue = otp.join('');\n onChange(otpValue);\n },\n [onChange]\n );\n\n const setOtp = (item: string, idx) => {\n const updatedOTPValues = [...otpValues];\n if (item.length === 1 || item.length === 0) {\n updatedOTPValues[idx] = item[0] || '';\n handleChange(updatedOTPValues);\n } else if (item.length === maxLength) {\n const valueArray = item.split('').slice(0, maxLength);\n handleChange(valueArray);\n }\n };\n\n const setSelectionRange = useCallback((target) => {\n return target.setSelectionRange(0, target.value.length);\n }, []);\n\n const focusToNextInput = useCallback((target: HTMLElement) => {\n const nextElement = target.nextElementSibling as HTMLInputElement | null;\n if (nextElement) {\n nextElement.focus();\n }\n }, []);\n\n const focusToPrevInput = useCallback((target: HTMLElement) => {\n const previousElement =\n target.previousElementSibling as HTMLInputElement | null;\n if (previousElement) {\n previousElement.focus();\n }\n }, []);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLInputElement>, idx: number) => {\n const { key } = e;\n const target = e.target as HTMLInputElement;\n let targetValue = target.value;\n setSelectionRange(target);\n if (key === 'ArrowRight' || key === 'ArrowDown') {\n e.preventDefault();\n return focusToNextInput(target);\n }\n if (key === 'ArrowLeft' || key === 'ArrowUp') {\n e.preventDefault();\n return focusToPrevInput(target);\n }\n if (e.key === 'Backspace' || e.key === 'Delete') {\n if (targetValue !== '') {\n targetValue = '';\n } else {\n focusToPrevInput(target);\n }\n setOtp(targetValue, idx);\n return e.preventDefault();\n }\n },\n [setOtp, focusToPrevInput, focusToNextInput]\n );\n\n const handleFocus = useCallback(\n (e: React.FocusEvent<HTMLInputElement>) => {\n const { target } = e;\n setSelectionRange(target);\n },\n [setSelectionRange]\n );\n const handleOtpChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>, idx: number) => {\n const target = e.target;\n const targetValue = target.value;\n const isTargetValueDigit = RE_DIGIT.test(targetValue);\n // We want to pass the empty string when the value is deleted\n // emptry string replaces the deleted value\n if (isTargetValueDigit || targetValue === '') {\n setOtp(targetValue, idx);\n if (target.value.length > 1) {\n target.blur();\n }\n focusToNextInput(target);\n }\n },\n [setOtp, handleKeyDown, handleFocus]\n );\n\n const handlePaste = useCallback(\n (e: React.ClipboardEvent<HTMLInputElement>) => {\n e.preventDefault();\n const pastedData = e.clipboardData\n .getData('text/plain')\n .replace(REMOVE_SPACES, '');\n if (pastedData) {\n setOtp(pastedData, 0);\n }\n },\n []\n );\n return {\n otpValues,\n handleOtpChange,\n handleKeyDown,\n handleFocus,\n handlePaste,\n };\n}\n\nconst SingleCharacterInputPart = React.forwardRef<\n HTMLInputElement,\n Record<string, any>\n>(({ ...props }, ref) => {\n return <SingleCharacterInput {...props} ref={ref} />;\n});\nSingleCharacterInputPart.displayName = 'SingleCharacterInputPart';\n\nexport const OtpInput = React.forwardRef<HTMLInputElement, Record<string, any>>(\n ({ name, maxLength = 6, ...props }, ref) => {\n const otp = useOtp(props.onChange, maxLength);\n return (\n <SingleCharacterInputs>\n {otp.otpValues.map((digit, idx) => (\n <SingleCharacterInputPart\n ref={idx === 0 ? ref : null}\n name={`${name}-${idx}`}\n id={`${name}-${idx}`}\n type=\"text\"\n key={idx}\n autoComplete=\"one-time-code\"\n pattern=\"\\d{1}\"\n maxLength={maxLength}\n value={digit}\n disabled={props.disabled}\n aria-required={props['aria-required']}\n onChange={(e) => otp.handleOtpChange(e, idx)}\n onInput={(e) => {\n if (e.target.value === digit) {\n otp.handleOtpChange(e, idx);\n }\n }}\n onKeyDown={(e) => otp.handleKeyDown(e, idx)}\n onFocus={otp.handleFocus}\n onPaste={otp.handlePaste}\n error={!digit ? props.error : false}\n />\n ))}\n </SingleCharacterInputs>\n );\n }\n);\n\nOtpInput.displayName = 'OtpInput';\n\nexport default OtpInput;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS,UAAU,mBAAmB;AAC7C,OAAO;AAAA,EACL;AAAA,OACK;AAEA,MAAM,WAAW,IAAI,OAAO,OAAO;AACnC,MAAM,gBAAgB,IA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BAA2B,MAAM,WAGrC,CAAC,EAAE,GAAG,MAAM,GAAG,QAAQ;AACvB,SAAO,oCAAC,wBAAsB,GAAG,OAAO,KAAU;AACpD,CAAC;AACD,yBAAyB,cAAc;AAEhC,MAAM,WAAW,MAAM;AAAA,EAC5B,CAAC,EAAE,MAAM,YAAY,GAAG,GAAG,MAAM,GAAG,QAAQ;AAC1C,UAAM,MAAM,OAAO,MAAM,UAAU,SAAS;AAC5C,WACE,oCAAC,6BACE,IAAI,UAAU,IAAI,CAAC,OAAO,QACzB;AAAA,MAAC;AAAA;AAAA,QACC,KAAK,QAAQ,IAAI,MAAM;AAAA,QACvB,MAAM,GAAG,IAAI,IAAI,GAAG;AAAA,QACpB,IAAI,GAAG,IAAI,IAAI,GAAG;AAAA,QAClB,MAAK;AAAA,QACL,KAAK;AAAA,QACL,cAAa;AAAA,QACb,SAAQ;AAAA,QACR;AAAA,QACA,OAAO;AAAA,QACP,UAAU,MAAM;AAAA,QAChB,iBAAe,MAAM,eAAe;AAAA,QACpC,UAAU,CAAC,MAAM,IAAI,gBAAgB,GAAG,GAAG;AAAA,QAC3C,SAAS,CAAC,MAAM;AACd,cAAI,EAAE,OAAO,UAAU,OAAO;AAC5B,gBAAI,gBAAgB,GAAG,GAAG;AAAA,UAC5B;AAAA,QACF;AAAA,QACA,WAAW,CAAC,MAAM,IAAI,cAAc,GAAG,GAAG;AAAA,QAC1C,SAAS,IAAI;AAAA,QACb,SAAS,IAAI;AAAA,QACb,OAAO,CAAC,QAAQ,MAAM,QAAQ;AAAA;AAAA,IAChC,CACD,CACH;AAAA,EAEJ;AACF;AAEA,SAAS,cAAc;AAEvB,IAAO,mBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/inputs/Radio/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { UseFormReturn } from 'react-hook-form';
|
|
3
|
+
import type { UncontrolledFieldProps } from '@digigov/form/Field/types';
|
|
4
|
+
import type { FieldOptionProps } from '@digigov/form/inputs/Label';
|
|
4
5
|
export interface RadioButtonsGroupProps extends Omit<UncontrolledFieldProps, 'extra'> {
|
|
5
6
|
extra: {
|
|
6
7
|
className?: string;
|
|
@@ -8,10 +9,11 @@ export interface RadioButtonsGroupProps extends Omit<UncontrolledFieldProps, 'ex
|
|
|
8
9
|
dense?: boolean;
|
|
9
10
|
};
|
|
10
11
|
fieldComponent?: React.FC<Omit<UncontrolledFieldProps, 'register'>>;
|
|
12
|
+
resetField: UseFormReturn['resetField'];
|
|
11
13
|
}
|
|
12
14
|
export declare const RadioButtonsGroup: React.FC<RadioButtonsGroupProps>;
|
|
13
|
-
export declare const ControlledRadioButtonsGroup: React.
|
|
15
|
+
export declare const ControlledRadioButtonsGroup: React.ForwardRefExoticComponent<RadioButtonsGroupProps & {
|
|
14
16
|
onChange: (e: any) => void;
|
|
15
17
|
value: any;
|
|
16
|
-
}
|
|
18
|
+
} & React.RefAttributes<HTMLInputElement>>;
|
|
17
19
|
export default RadioButtonsGroup;
|
package/inputs/Radio/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { useWatch } from "react-hook-form";
|
|
3
|
+
import { omit } from "@digigov/form/utils";
|
|
3
4
|
import {
|
|
4
5
|
RadioContainer,
|
|
5
6
|
RadioItem,
|
|
@@ -36,7 +37,7 @@ const RadioButtonsGroup = ({
|
|
|
36
37
|
disabled: disabled || optionDisabled,
|
|
37
38
|
...option,
|
|
38
39
|
...{
|
|
39
|
-
...props,
|
|
40
|
+
...omit(props, ["resetField"]),
|
|
40
41
|
reset: void 0,
|
|
41
42
|
required: void 0,
|
|
42
43
|
error: void 0,
|
|
@@ -49,7 +50,7 @@ const RadioButtonsGroup = ({
|
|
|
49
50
|
), selected && selected(), currentValue === v && show && Field && /* @__PURE__ */ React.createElement(RadioConditional, null, show.map((fieldName) => /* @__PURE__ */ React.createElement(Field, { name: fieldName, key: fieldName }))))
|
|
50
51
|
));
|
|
51
52
|
};
|
|
52
|
-
const ControlledRadioButtonsGroup = ({
|
|
53
|
+
const ControlledRadioButtonsGroup = React.forwardRef(function ControlledRadioButtonsGroup2({
|
|
53
54
|
name,
|
|
54
55
|
extra: { options, className },
|
|
55
56
|
disabled,
|
|
@@ -57,7 +58,7 @@ const ControlledRadioButtonsGroup = ({
|
|
|
57
58
|
value,
|
|
58
59
|
Field,
|
|
59
60
|
...props
|
|
60
|
-
})
|
|
61
|
+
}, ref) {
|
|
61
62
|
const currentValue = value;
|
|
62
63
|
const { t } = useTranslation();
|
|
63
64
|
return /* @__PURE__ */ React.createElement(RadioContainer, { className, id: name }, options.map(
|
|
@@ -68,9 +69,10 @@ const ControlledRadioButtonsGroup = ({
|
|
|
68
69
|
disabled: optionDisabled,
|
|
69
70
|
selected,
|
|
70
71
|
...option
|
|
71
|
-
}) => /* @__PURE__ */ React.createElement(React.Fragment, { key: `${name}.${v}` }, /* @__PURE__ */ React.createElement(
|
|
72
|
+
}, index) => /* @__PURE__ */ React.createElement(React.Fragment, { key: `${name}.${v}` }, /* @__PURE__ */ React.createElement(
|
|
72
73
|
RadioItem,
|
|
73
74
|
{
|
|
75
|
+
ref: index === 0 ? ref : void 0,
|
|
74
76
|
onChange: (e) => {
|
|
75
77
|
console.log(e);
|
|
76
78
|
onChange(e);
|
|
@@ -94,7 +96,7 @@ const ControlledRadioButtonsGroup = ({
|
|
|
94
96
|
label && label.secondary && /* @__PURE__ */ React.createElement(Hint, null, t(label.secondary))
|
|
95
97
|
), selected && selected(), currentValue === v && show && /* @__PURE__ */ React.createElement(RadioConditional, null, show.map((fieldName) => /* @__PURE__ */ React.createElement(Field, { name: fieldName, key: fieldName }))))
|
|
96
98
|
));
|
|
97
|
-
};
|
|
99
|
+
});
|
|
98
100
|
var Radio_default = RadioButtonsGroup;
|
|
99
101
|
export {
|
|
100
102
|
ControlledRadioButtonsGroup,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/inputs/Radio/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport { useWatch } from 'react-hook-form';\nimport { UncontrolledFieldProps } from '@digigov/form/Field/types';\nimport { FieldOptionProps } from '@digigov/form/inputs/Label';\nimport {\n RadioContainer,\n RadioItem,\n RadioConditional,\n} from '@digigov/ui/form/RadioContainer';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport { Hint } from '@digigov/ui/typography/Hint';\nimport { Base } from '@digigov/ui/utils/Base';\n\nexport interface RadioButtonsGroupProps\n extends Omit<UncontrolledFieldProps, 'extra'> {\n extra: {\n className?: string;\n options: FieldOptionProps[];\n dense?: boolean;\n };\n fieldComponent?: React.FC<Omit<UncontrolledFieldProps, 'register'>>;\n}\n\nexport const RadioButtonsGroup: React.FC<RadioButtonsGroupProps> = ({\n name,\n control,\n register,\n extra: { options, className },\n disabled,\n Field,\n ...props\n}) => {\n const currentValue: string | undefined = useWatch({ control, name });\n const { t } = useTranslation();\n return (\n <RadioContainer className={className} id={name}>\n {options.map(\n ({\n label,\n value: v,\n show,\n disabled: optionDisabled,\n selected,\n ...option\n }) => (\n <Base as=\"div\" key={`${name}.${v}`}>\n <RadioItem\n {...register(name)}\n id={`${name}.${v}`}\n value={v}\n disabled={disabled || optionDisabled}\n {...option}\n {...{\n ...props,\n reset: undefined,\n required: undefined,\n error: undefined,\n 'aria-describedby': undefined,\n type: 'radio',\n }}\n >\n {label && label.primary && (\n <Base as=\"span\">{t(label.primary) || v}</Base>\n )}\n {label && label.secondary && <Hint>{t(label.secondary)}</Hint>}\n </RadioItem>\n {selected && selected()}\n {currentValue === v && show && Field && (\n <RadioConditional>\n {show.map((fieldName) => (\n <Field name={fieldName} key={fieldName} />\n ))}\n </RadioConditional>\n )}\n </Base>\n )\n )}\n </RadioContainer>\n );\n};\nexport const ControlledRadioButtonsGroup
|
|
5
|
-
"mappings": "AAAA,OAAO,WAAW;
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport type { UseFormReturn } from 'react-hook-form';\nimport { useWatch } from 'react-hook-form';\nimport type { UncontrolledFieldProps } from '@digigov/form/Field/types';\nimport type { FieldOptionProps } from '@digigov/form/inputs/Label';\nimport { omit } from '@digigov/form/utils';\nimport {\n RadioContainer,\n RadioItem,\n RadioConditional,\n} from '@digigov/ui/form/RadioContainer';\nimport { useTranslation } from '@digigov/ui/i18n';\nimport { Hint } from '@digigov/ui/typography/Hint';\nimport { Base } from '@digigov/ui/utils/Base';\n\nexport interface RadioButtonsGroupProps\n extends Omit<UncontrolledFieldProps, 'extra'> {\n extra: {\n className?: string;\n options: FieldOptionProps[];\n dense?: boolean;\n };\n fieldComponent?: React.FC<Omit<UncontrolledFieldProps, 'register'>>;\n resetField: UseFormReturn['resetField'];\n}\n\nexport const RadioButtonsGroup: React.FC<RadioButtonsGroupProps> = ({\n name,\n control,\n register,\n extra: { options, className },\n disabled,\n Field,\n ...props\n}) => {\n const currentValue: string | undefined = useWatch({ control, name });\n const { t } = useTranslation();\n return (\n <RadioContainer className={className} id={name}>\n {options.map(\n ({\n label,\n value: v,\n show,\n disabled: optionDisabled,\n selected,\n ...option\n }) => (\n <Base as=\"div\" key={`${name}.${v}`}>\n <RadioItem\n {...register(name)}\n id={`${name}.${v}`}\n value={v}\n disabled={disabled || optionDisabled}\n {...option}\n {...{\n ...omit(props, ['resetField']),\n reset: undefined,\n required: undefined,\n error: undefined,\n 'aria-describedby': undefined,\n type: 'radio',\n }}\n >\n {label && label.primary && (\n <Base as=\"span\">{t(label.primary) || v}</Base>\n )}\n {label && label.secondary && <Hint>{t(label.secondary)}</Hint>}\n </RadioItem>\n {selected && selected()}\n {currentValue === v && show && Field && (\n <RadioConditional>\n {show.map((fieldName) => (\n <Field name={fieldName} key={fieldName} />\n ))}\n </RadioConditional>\n )}\n </Base>\n )\n )}\n </RadioContainer>\n );\n};\nexport const ControlledRadioButtonsGroup = React.forwardRef<\n HTMLInputElement,\n RadioButtonsGroupProps & { onChange: (e: any) => void; value: any }\n>(function ControlledRadioButtonsGroup(\n {\n name,\n extra: { options, className },\n disabled,\n onChange,\n value,\n Field,\n ...props\n },\n ref\n) {\n const currentValue: string | undefined = value;\n const { t } = useTranslation();\n return (\n <RadioContainer className={className} id={name}>\n {options.map(\n (\n {\n label,\n value: v,\n show,\n disabled: optionDisabled,\n selected,\n ...option\n },\n index\n ) => (\n <React.Fragment key={`${name}.${v}`}>\n <RadioItem\n ref={index === 0 ? ref : undefined}\n onChange={(e) => {\n console.log(e);\n onChange(e);\n }}\n id={`${name}.${v}`}\n value={v}\n checked={currentValue === v}\n disabled={disabled || optionDisabled}\n {...option}\n {...{\n ...props,\n reset: undefined,\n required: undefined,\n error: undefined,\n Field: undefined,\n 'aria-describedby': undefined,\n type: 'radio',\n }}\n >\n {(label && label.primary && t(label.primary)) || v}\n {label && label.secondary && <Hint>{t(label.secondary)}</Hint>}\n </RadioItem>\n {selected && selected()}\n {currentValue === v && show && (\n <RadioConditional>\n {show.map((fieldName) => (\n <Field name={fieldName} key={fieldName} />\n ))}\n </RadioConditional>\n )}\n </React.Fragment>\n )\n )}\n </RadioContainer>\n );\n});\n\nexport default RadioButtonsGroup;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,WAAW;AAElB,SAAS,gBAAgB;AAGzB,SAAS,YAAY;AACrB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,SAAS,YAAY;AACrB,SAAS,YAAY;AAad,MAAM,oBAAsD,CAAC;AAAA,EAClE;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO,EAAE,SAAS,UAAU;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,eAAmC,SAAS,EAAE,SAAS,KAAK,CAAC;AACnE,QAAM,EAAE,EAAE,IAAI,eAAe;AAC7B,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AAAA,MACA,GAAG;AAAA,IACL,GACA,UAEA,oCAAC,MAAM,UAAN,EAAe,KAAK,GAAG,IAAI,IAAI,CAAC,MAC/B;AAAA,MAAC;AAAA;AAAA,QACC,KAAK,UAAU,IAAI,MAAM;AAAA,QACzB,UAAU,CAAC,MAAM;AACf,kBAAQ,IAAI,CAAC;AACb,mBAAS,CAAC;AAAA,QACZ;AAAA,QACA,IAAI,GAAG,IAAI,IAAI,CAAC;AAAA,QAChB,OAAO;AAAA,QACP,SAAS,iBAAiB;AAAA,QAC1B,UAAU,YAAY;AAAA,QACrB,GAAG;AAAA,QACH,GAAG;AAAA,UACF,GAAG;AAAA,UACH,OAAO;AAAA,UACP,UAAU;AAAA,UACV,OAAO;AAAA,UACP,OAAO;AAAA,UACP,oBAAoB;AAAA,UACpB,MAAM;AAAA,QACR;AAAA;AAAA,MAEE,SAAS,MAAM,WAAW,EAAE,MAAM,OAAO,KAAM;AAAA,MAChD,SAAS,MAAM,aAAa,oCAAC,YAAM,EAAE,MAAM,SAAS,CAAE;AAAA,IACzD,GACC,YAAY,SAAS,GACrB,iBAAiB,KAAK,QACrB,oCAAC,wBACE,KAAK,IAAI,CAAC,cACT,oCAAC,SAAM,MAAM,WAAW,KAAK,WAAW,CACzC,CACH,CAEJ;AAAA,EAEJ,CACF;AAEJ,CAAC;AAED,IAAO,gBAAQ;",
|
|
6
|
+
"names": ["ControlledRadioButtonsGroup"]
|
|
7
7
|
}
|
package/inputs/Select/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { UseFormReturn } from 'react-hook-form';
|
|
3
|
+
import type { UncontrolledFieldProps } from '@digigov/form/Field/types';
|
|
4
|
+
import type { FieldOptionProps } from '@digigov/form/inputs/Label';
|
|
4
5
|
export interface SelectProps extends Omit<UncontrolledFieldProps, 'extra' | 'Field'> {
|
|
5
6
|
extra: {
|
|
6
7
|
className?: string;
|
|
7
8
|
options: FieldOptionProps[];
|
|
8
9
|
};
|
|
9
10
|
Field?: UncontrolledFieldProps['Field'];
|
|
11
|
+
resetField: UseFormReturn['resetField'];
|
|
10
12
|
}
|
|
11
13
|
export declare const Select: React.ExoticComponent<SelectProps>;
|
|
12
14
|
export default Select;
|
package/inputs/Select/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { omit } from "@digigov/form/utils";
|
|
2
3
|
import {
|
|
3
4
|
SelectContainer,
|
|
4
5
|
SelectOption
|
|
5
6
|
} from "@digigov/ui/form/SelectContainer";
|
|
6
7
|
const Select = React.forwardRef(
|
|
7
8
|
function WrappedSelect({ name, extra: { options, className }, disabled, ...props }, ref) {
|
|
8
|
-
delete props.Field;
|
|
9
9
|
return /* @__PURE__ */ React.createElement(
|
|
10
10
|
SelectContainer,
|
|
11
11
|
{
|
|
@@ -15,7 +15,7 @@ const Select = React.forwardRef(
|
|
|
15
15
|
id: name,
|
|
16
16
|
disabled,
|
|
17
17
|
...{
|
|
18
|
-
...props,
|
|
18
|
+
...omit(props, ["Field", "resetField"]),
|
|
19
19
|
reset: void 0,
|
|
20
20
|
error: void 0,
|
|
21
21
|
required: void 0
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/inputs/Select/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\nimport { UncontrolledFieldProps } from '@digigov/form/Field/types';\nimport { FieldOptionProps } from '@digigov/form/inputs/Label';\nimport {\n SelectContainer,\n SelectOption,\n} from '@digigov/ui/form/SelectContainer';\n\nexport interface SelectProps\n extends Omit<UncontrolledFieldProps, 'extra' | 'Field'> {\n extra: {\n className?: string;\n options: FieldOptionProps[];\n };\n Field?: UncontrolledFieldProps['Field'];\n}\n\nexport const Select: React.ExoticComponent<SelectProps> = React.forwardRef(\n function WrappedSelect(\n { name, extra: { options, className }, disabled, ...props },\n ref: never\n ) {\n
|
|
5
|
-
"mappings": "AAAA,OAAO,WAAW;
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport type { UseFormReturn } from 'react-hook-form';\nimport type { UncontrolledFieldProps } from '@digigov/form/Field/types';\nimport type { FieldOptionProps } from '@digigov/form/inputs/Label';\nimport { omit } from '@digigov/form/utils';\nimport {\n SelectContainer,\n SelectOption,\n} from '@digigov/ui/form/SelectContainer';\n\nexport interface SelectProps\n extends Omit<UncontrolledFieldProps, 'extra' | 'Field'> {\n extra: {\n className?: string;\n options: FieldOptionProps[];\n };\n Field?: UncontrolledFieldProps['Field'];\n resetField: UseFormReturn['resetField'];\n}\n\nexport const Select: React.ExoticComponent<SelectProps> = React.forwardRef(\n function WrappedSelect(\n { name, extra: { options, className }, disabled, ...props },\n ref: never\n ) {\n return (\n <SelectContainer\n className={className}\n ref={ref}\n name={name}\n id={name}\n disabled={disabled}\n {...{\n ...omit(props, ['Field', 'resetField']),\n reset: undefined,\n error: undefined,\n required: undefined,\n }}\n >\n {options.map(({ value, label }, index) => (\n <SelectOption key={index} value={value}>\n {label && label.primary ? label.primary : value}\n </SelectOption>\n ))}\n </SelectContainer>\n );\n }\n);\n\nexport default Select;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,WAAW;AAIlB,SAAS,YAAY;AACrB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAYA,MAAM,SAA6C,MAAM;AAAA,EAC9D,SAAS,cACP,EAAE,MAAM,OAAO,EAAE,SAAS,UAAU,GAAG,UAAU,GAAG,MAAM,GAC1D,KACA;AACA,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA,IAAI;AAAA,QACJ;AAAA,QACC,GAAG;AAAA,UACF,GAAG,KAAK,OAAO,CAAC,SAAS,YAAY,CAAC;AAAA,UACtC,OAAO;AAAA,UACP,OAAO;AAAA,UACP,UAAU;AAAA,QACZ;AAAA;AAAA,MAEC,QAAQ,IAAI,CAAC,EAAE,OAAO,MAAM,GAAG,UAC9B,oCAAC,gBAAa,KAAK,OAAO,SACvB,SAAS,MAAM,UAAU,MAAM,UAAU,KAC5C,CACD;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,IAAO,iBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -17,12 +17,13 @@ const FIELD_COMPONENTS = {
|
|
|
17
17
|
},
|
|
18
18
|
file: {
|
|
19
19
|
wrapper: "fieldset",
|
|
20
|
-
component: FileInput
|
|
21
|
-
controlled: true
|
|
20
|
+
component: FileInput
|
|
21
|
+
// controlled: true,
|
|
22
22
|
},
|
|
23
23
|
image: {
|
|
24
24
|
wrapper: "fieldset",
|
|
25
|
-
component: ImageInput
|
|
25
|
+
component: ImageInput,
|
|
26
|
+
controlled: true
|
|
26
27
|
},
|
|
27
28
|
date: {
|
|
28
29
|
wrapper: "fieldset",
|
|
@@ -82,4 +83,4 @@ export {
|
|
|
82
83
|
CONTROLLED_FIELD_COMPONENTS,
|
|
83
84
|
FIELD_COMPONENTS
|
|
84
85
|
};
|
|
85
|
-
//# sourceMappingURL=
|
|
86
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type FieldComponentItem } from '@digigov/form/Field/types';
|
|
2
|
+
export type FieldComponentRegistry = Record<string, FieldComponentItem>;
|
|
2
3
|
export declare const FIELD_COMPONENTS: FieldComponentRegistry;
|
|
3
4
|
export declare const ALTERNATIVE_COMPONENTS: FieldComponentRegistry;
|
|
4
5
|
export declare const CONTROLLED_FIELD_COMPONENTS: FieldComponentRegistry;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/inputs/registry.ts"],
|
|
4
|
+
"sourcesContent": ["import { type FieldComponentItem } 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 type FieldComponentRegistry = Record<string, FieldComponentItem>;\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 // controlled: true,\n },\n image: {\n wrapper: 'fieldset',\n component: ImageInput,\n controlled: true,\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": "AACA,OAAO,uBAAuB;AAC9B,OAAO,gBAAgB;AACvB,OAAO,eAAe;AACtB,OAAO,mBAAmB;AAC1B,OAAO,eAAe;AACtB,OAAO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