@tsed/react-formio 3.0.0-alpha.8 → 3.0.0-rc.1
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/dist/all.d.ts +0 -0
- package/dist/all.js +38 -0
- package/dist/all.js.map +1 -0
- package/dist/atoms/icon/Icon.d.ts +4 -3
- package/dist/atoms/icon/Icon.js +9 -8
- package/dist/atoms/icon/Icon.js.map +1 -1
- package/dist/chunks/_commonjsHelpers.js +30 -3
- package/dist/chunks/_commonjsHelpers.js.map +1 -1
- package/dist/chunks/index.js +33 -30
- package/dist/chunks/index.js.map +1 -1
- package/dist/chunks/index.module.js +16 -16
- package/dist/chunks/index.module.js.map +1 -1
- package/dist/chunks/index2.js +56953 -0
- package/dist/chunks/index2.js.map +1 -0
- package/dist/chunks/react-select-animated.esm.js +3616 -0
- package/dist/chunks/react-select-animated.esm.js.map +1 -0
- package/dist/contexts/FormioContext.d.ts +19 -0
- package/dist/contexts/FormioContext.js +35 -0
- package/dist/contexts/FormioContext.js.map +1 -0
- package/dist/hooks/keyboard.constants.d.ts +38 -0
- package/dist/hooks/keyboard.constants.js +7 -0
- package/dist/hooks/keyboard.constants.js.map +1 -0
- package/dist/hooks/useFormioContext.d.ts +10 -0
- package/dist/hooks/useFormioContext.js +12 -0
- package/dist/hooks/useFormioContext.js.map +1 -0
- package/dist/hooks/useI18n.d.ts +4 -0
- package/dist/hooks/useI18n.js +9 -0
- package/dist/hooks/useI18n.js.map +1 -0
- package/dist/hooks/useKeyboardControls.d.ts +12 -0
- package/dist/hooks/useKeyboardControls.js +35 -0
- package/dist/hooks/useKeyboardControls.js.map +1 -0
- package/dist/hooks/useTooltip.js.map +1 -1
- package/dist/index.d.ts +1 -6
- package/dist/index.js +18 -13
- package/dist/index.js.map +1 -1
- package/dist/interfaces/ComponentType.d.ts +6 -2
- package/dist/interfaces/FormBuilderOptions.d.ts +7 -0
- package/dist/interfaces/FormBuilderOptions.js +2 -0
- package/dist/interfaces/FormBuilderOptions.js.map +1 -0
- package/dist/interfaces/FormOptions.d.ts +6 -13
- package/dist/interfaces/FormType.d.ts +4 -11
- package/dist/interfaces/Operation.d.ts +13 -4
- package/dist/interfaces/SubmissionType.d.ts +5 -10
- package/dist/interfaces/index.d.ts +1 -0
- package/dist/molecules/alert/Alert.js.map +1 -1
- package/dist/molecules/button/Button.d.ts +18 -5
- package/dist/molecules/button/Button.js +24 -28
- package/dist/molecules/button/Button.js.map +1 -1
- package/dist/molecules/card/Card.js +9 -7
- package/dist/molecules/card/Card.js.map +1 -1
- package/dist/molecules/forms/form-control/FormControl.d.ts +14 -12
- package/dist/molecules/forms/form-control/FormControl.js +46 -22
- package/dist/molecules/forms/form-control/FormControl.js.map +1 -1
- package/dist/molecules/forms/input-tags/InputTags.d.ts +2 -8
- package/dist/molecules/forms/input-tags/InputTags.interface.d.ts +7 -0
- package/dist/molecules/forms/input-tags/InputTags.interface.js +2 -0
- package/dist/molecules/forms/input-tags/InputTags.interface.js.map +1 -0
- package/dist/molecules/forms/input-tags/InputTags.js +21 -27
- package/dist/molecules/forms/input-tags/InputTags.js.map +1 -1
- package/dist/molecules/forms/input-tags/all.d.ts +2 -0
- package/dist/molecules/forms/input-tags/all.js +9 -0
- package/dist/molecules/forms/input-tags/all.js.map +1 -0
- package/dist/molecules/forms/input-tags/components/ChoicesTags.d.ts +307 -0
- package/dist/molecules/forms/input-tags/components/ChoicesTags.js +51 -0
- package/dist/molecules/forms/input-tags/components/ChoicesTags.js.map +1 -0
- package/dist/molecules/forms/input-tags/components/ReactTags.d.ts +2 -0
- package/dist/molecules/forms/input-tags/components/ReactTags.js +1926 -0
- package/dist/molecules/forms/input-tags/components/ReactTags.js.map +1 -0
- package/dist/molecules/forms/input-text/InputText.d.ts +2 -14
- package/dist/molecules/forms/input-text/InputText.interface.d.ts +4 -0
- package/dist/molecules/forms/input-text/InputText.interface.js +2 -0
- package/dist/molecules/forms/input-text/InputText.interface.js.map +1 -0
- package/dist/molecules/forms/input-text/InputText.js +46 -56
- package/dist/molecules/forms/input-text/InputText.js.map +1 -1
- package/dist/molecules/forms/select/Select.d.ts +1 -1
- package/dist/molecules/forms/select/{Select.interfaces.d.ts → Select.interface.d.ts} +8 -10
- package/dist/molecules/forms/select/Select.interface.js +2 -0
- package/dist/molecules/forms/select/Select.interface.js.map +1 -0
- package/dist/molecules/forms/select/Select.js +9 -10
- package/dist/molecules/forms/select/Select.js.map +1 -1
- package/dist/molecules/forms/select/all.d.ts +1 -1
- package/dist/molecules/forms/select/all.js +1 -0
- package/dist/molecules/forms/select/all.js.map +1 -1
- package/dist/molecules/forms/select/components/ChoicesSelect.d.ts +1 -1
- package/dist/molecules/forms/select/components/ChoicesSelect.js +72 -83
- package/dist/molecules/forms/select/components/ChoicesSelect.js.map +1 -1
- package/dist/molecules/forms/select/components/HtmlSelect.d.ts +1 -1
- package/dist/molecules/forms/select/components/HtmlSelect.js +17 -16
- package/dist/molecules/forms/select/components/HtmlSelect.js.map +1 -1
- package/dist/molecules/forms/select/components/ReactSelect.d.ts +1 -1
- package/dist/molecules/forms/select/components/ReactSelect.js +28 -3034
- package/dist/molecules/forms/select/components/ReactSelect.js.map +1 -1
- package/dist/molecules/forms/select/components/choices.template.js +2340 -2257
- package/dist/molecules/forms/select/components/choices.template.js.map +1 -1
- package/dist/molecules/forms/select/hooks/useOptions.d.ts +3 -3
- package/dist/molecules/forms/select/hooks/useOptions.js +15 -15
- package/dist/molecules/forms/select/hooks/useOptions.js.map +1 -1
- package/dist/molecules/loader/Loader.d.ts +4 -4
- package/dist/molecules/loader/Loader.js +16 -8
- package/dist/molecules/loader/Loader.js.map +1 -1
- package/dist/molecules/modal/Modal.js +23 -24
- package/dist/molecules/modal/Modal.js.map +1 -1
- package/dist/molecules/pagination/Pagination.d.ts +7 -6
- package/dist/molecules/pagination/Pagination.js +48 -57
- package/dist/molecules/pagination/Pagination.js.map +1 -1
- package/dist/molecules/pagination/PaginationButton.js +10 -10
- package/dist/molecules/pagination/PaginationButton.js.map +1 -1
- package/dist/molecules/pagination/all.js +5 -4
- package/dist/molecules/pagination/all.js.map +1 -1
- package/dist/molecules/pagination/utils/getPageNumbers.js.map +1 -0
- package/dist/molecules/table/Table.d.ts +16 -2
- package/dist/molecules/table/Table.js +53 -77
- package/dist/molecules/table/Table.js.map +1 -1
- package/dist/molecules/table/all.d.ts +0 -0
- package/dist/molecules/table/all.js +19 -0
- package/dist/molecules/table/all.js.map +1 -0
- package/dist/molecules/table/components/DefaultArrowSort.d.ts +5 -1
- package/dist/molecules/table/components/DefaultArrowSort.js +17 -5
- package/dist/molecules/table/components/DefaultArrowSort.js.map +1 -1
- package/dist/molecules/table/components/DefaultCell.d.ts +5 -1
- package/dist/molecules/table/components/DefaultCell.js +8 -6
- package/dist/molecules/table/components/DefaultCell.js.map +1 -1
- package/dist/molecules/table/components/DefaultCellFooter.d.ts +6 -0
- package/dist/molecules/table/components/DefaultCellFooter.js +12 -0
- package/dist/molecules/table/components/DefaultCellFooter.js.map +1 -0
- package/dist/molecules/table/components/DefaultCellHeader.d.ts +5 -8
- package/dist/molecules/table/components/DefaultCellHeader.js +25 -9
- package/dist/molecules/table/components/DefaultCellHeader.js.map +1 -1
- package/dist/molecules/table/components/DefaultCellOperations.d.ts +16 -10
- package/dist/molecules/table/components/DefaultCellOperations.js +23 -14
- package/dist/molecules/table/components/DefaultCellOperations.js.map +1 -1
- package/dist/molecules/table/components/DefaultFilter.d.ts +11 -0
- package/dist/molecules/table/components/DefaultFilter.js +15 -0
- package/dist/molecules/table/components/DefaultFilter.js.map +1 -0
- package/dist/molecules/table/components/DefaultOperationButton.d.ts +16 -12
- package/dist/molecules/table/components/DefaultOperationButton.js +16 -31
- package/dist/molecules/table/components/DefaultOperationButton.js.map +1 -1
- package/dist/molecules/table/filters/Filters.d.js +2 -0
- package/dist/molecules/table/filters/Filters.d.js.map +1 -0
- package/dist/molecules/table/filters/RangeFilter.d.ts +3 -0
- package/dist/molecules/table/filters/RangeFilter.js +41 -0
- package/dist/molecules/table/filters/RangeFilter.js.map +1 -0
- package/dist/molecules/table/filters/SelectFilter.d.ts +3 -0
- package/dist/molecules/table/filters/SelectFilter.js +33 -0
- package/dist/molecules/table/filters/SelectFilter.js.map +1 -0
- package/dist/molecules/table/filters/TextFieldFilter.d.ts +3 -0
- package/dist/molecules/table/filters/TextFieldFilter.js +27 -0
- package/dist/molecules/table/filters/TextFieldFilter.js.map +1 -0
- package/dist/molecules/table/hooks/useTable.d.ts +23 -0
- package/dist/molecules/table/hooks/useTable.js +35 -0
- package/dist/molecules/table/hooks/useTable.js.map +1 -0
- package/dist/molecules/table/hooks/useUniqValues.d.ts +5 -0
- package/dist/molecules/table/hooks/useUniqValues.js +11 -0
- package/dist/molecules/table/hooks/useUniqValues.js.map +1 -0
- package/dist/molecules/table/interfaces/extends.d.ts +14 -0
- package/dist/molecules/table/interfaces/extends.js +2 -0
- package/dist/molecules/table/interfaces/extends.js.map +1 -0
- package/dist/molecules/table/utils/mapFormToColumns.d.ts +2 -2
- package/dist/molecules/table/utils/mapFormToColumns.js +34 -18
- package/dist/molecules/table/utils/mapFormToColumns.js.map +1 -1
- package/dist/molecules/tabs/Tab.d.ts +13 -0
- package/dist/molecules/tabs/Tab.js +66 -0
- package/dist/molecules/tabs/Tab.js.map +1 -0
- package/dist/molecules/tabs/TabList.d.ts +2 -0
- package/dist/molecules/tabs/TabList.js +23 -0
- package/dist/molecules/tabs/TabList.js.map +1 -0
- package/dist/molecules/tabs/TabPanel.d.ts +9 -0
- package/dist/molecules/tabs/TabPanel.js +27 -0
- package/dist/molecules/tabs/TabPanel.js.map +1 -0
- package/dist/molecules/tabs/Tabs.d.ts +4 -16
- package/dist/molecules/tabs/Tabs.js +7 -67
- package/dist/molecules/tabs/Tabs.js.map +1 -1
- package/dist/molecules/tabs/TabsBody.d.ts +1 -0
- package/dist/molecules/tabs/TabsBody.js +10 -0
- package/dist/molecules/tabs/TabsBody.js.map +1 -0
- package/dist/molecules/tabs/TabsLegacy.d.ts +18 -0
- package/dist/molecules/tabs/TabsLegacy.js +49 -0
- package/dist/molecules/tabs/TabsLegacy.js.map +1 -0
- package/dist/molecules/tabs/all.d.ts +5 -0
- package/dist/molecules/tabs/all.js +13 -0
- package/dist/molecules/tabs/all.js.map +1 -0
- package/dist/molecules/tabs/context/TabControl.d.ts +52 -0
- package/dist/molecules/tabs/context/TabControl.js +85 -0
- package/dist/molecules/tabs/context/TabControl.js.map +1 -0
- package/dist/molecules/tabs/hooks/tabControl.d.ts +44 -0
- package/dist/molecules/tabs/hooks/tabControl.js +34 -0
- package/dist/molecules/tabs/hooks/tabControl.js.map +1 -0
- package/dist/organisms/form/Form.js.map +1 -1
- package/dist/organisms/form/access/FormAccess.js +41 -41
- package/dist/organisms/form/access/FormAccess.js.map +1 -1
- package/dist/organisms/form/access/FormAccess.schema.js +1 -0
- package/dist/organisms/form/access/FormAccess.schema.js.map +1 -1
- package/dist/organisms/form/access/FormAccess.utils.js +2 -2
- package/dist/organisms/form/access/FormAccess.utils.js.map +1 -1
- package/dist/organisms/form/actions/FormAction.js +34 -0
- package/dist/organisms/form/actions/FormAction.js.map +1 -0
- package/dist/organisms/form/builder/FormBuilder.js.map +1 -1
- package/dist/organisms/form/builder/FormEdit.d.ts +7 -3
- package/dist/organisms/form/builder/FormEdit.js +46 -42
- package/dist/organisms/form/builder/FormEdit.js.map +1 -1
- package/dist/organisms/form/builder/FormEdit.reducer.js.map +1 -1
- package/dist/organisms/form/builder/FormEditCtas.d.ts +2 -2
- package/dist/organisms/form/builder/FormEditCtas.js +36 -35
- package/dist/organisms/form/builder/FormEditCtas.js.map +1 -1
- package/dist/organisms/form/builder/FormParameters.d.ts +3 -2
- package/dist/organisms/form/builder/FormParameters.js +19 -18
- package/dist/organisms/form/builder/FormParameters.js.map +1 -1
- package/dist/organisms/form/builder/all.js +17 -13
- package/dist/organisms/form/builder/all.js.map +1 -1
- package/dist/organisms/form/builder/useFormBuilder.d.ts +4 -4
- package/dist/organisms/form/builder/useFormBuilder.js +36 -33
- package/dist/organisms/form/builder/useFormBuilder.js.map +1 -1
- package/dist/organisms/form/builder/useFormEdit.d.ts +2 -2
- package/dist/organisms/form/builder/useFormEdit.js +1 -1
- package/dist/organisms/form/builder/useFormEdit.js.map +1 -1
- package/dist/organisms/form/exports/FormExport.d.ts +6 -0
- package/dist/organisms/form/exports/FormExport.js +56 -0
- package/dist/organisms/form/exports/FormExport.js.map +1 -0
- package/dist/organisms/form/preview/FormPreview.d.ts +6 -0
- package/dist/organisms/form/preview/FormPreview.js +12 -0
- package/dist/organisms/form/preview/FormPreview.js.map +1 -0
- package/dist/organisms/form/settings/FormSettings.js +28 -28
- package/dist/organisms/form/settings/FormSettings.js.map +1 -1
- package/dist/organisms/form/settings/FormSettings.schema.js.map +1 -1
- package/dist/organisms/form/settings/FormSettings.utils.js.map +1 -1
- package/dist/organisms/form/useForm.d.ts +2 -1
- package/dist/organisms/form/useForm.js +664 -661
- package/dist/organisms/form/useForm.js.map +1 -1
- package/dist/organisms/modal/RemoveModal.js +16 -17
- package/dist/organisms/modal/RemoveModal.js.map +1 -1
- package/dist/organisms/table/actions/ActionsTable.d.ts +4 -3
- package/dist/organisms/table/actions/ActionsTable.js +21 -33
- package/dist/organisms/table/actions/ActionsTable.js.map +1 -1
- package/dist/organisms/table/forms/FormsTable.d.ts +2 -3
- package/dist/organisms/table/forms/FormsTable.js +48 -27
- package/dist/organisms/table/forms/FormsTable.js.map +1 -1
- package/dist/organisms/table/forms/components/FormsCell.d.ts +5 -0
- package/dist/organisms/table/forms/components/FormsCell.js +50 -0
- package/dist/organisms/table/forms/components/FormsCell.js.map +1 -0
- package/dist/organisms/table/submissions/SubmissionsTable.d.ts +12 -4
- package/dist/organisms/table/submissions/SubmissionsTable.js +10 -17
- package/dist/organisms/table/submissions/SubmissionsTable.js.map +1 -1
- package/dist/organisms/views/FormViews.d.ts +24 -0
- package/dist/organisms/views/FormViews.js +97 -0
- package/dist/organisms/views/FormViews.js.map +1 -0
- package/dist/registries/components.js +12 -11
- package/dist/registries/components.js.map +1 -1
- package/dist/utils/getEventValue.js.map +1 -1
- package/dist/utils/iconClass.js +4 -5
- package/dist/utils/iconClass.js.map +1 -1
- package/dist/utils/mapPagination.js.map +1 -1
- package/dist/utils/stopPropagationWrapper.js.map +1 -1
- package/package.json +10 -8
- package/readme.md +7 -8
- package/src/all.ts +34 -0
- package/src/atoms/icon/Icon.stories.tsx +71 -22
- package/src/atoms/icon/Icon.tsx +14 -4
- package/src/contexts/FormioContext.tsx +89 -0
- package/src/hooks/keyboard.constants.ts +40 -0
- package/src/hooks/useFormioContext.ts +13 -0
- package/src/hooks/useI18n.ts +9 -0
- package/src/hooks/useKeyboardControls.spec.tsx +208 -0
- package/src/hooks/useKeyboardControls.ts +84 -0
- package/src/index.ts +17 -13
- package/src/interfaces/ComponentType.ts +2 -2
- package/src/interfaces/FormBuilderOptions.ts +9 -0
- package/src/interfaces/FormOptions.ts +7 -13
- package/src/interfaces/FormType.ts +5 -11
- package/src/interfaces/Operation.ts +10 -4
- package/src/interfaces/SubmissionType.ts +9 -8
- package/src/interfaces/index.ts +1 -0
- package/src/molecules/__fixtures__/build.js +28 -0
- package/src/molecules/__fixtures__/form-schema.json +76 -195
- package/src/molecules/__fixtures__/form-submissions.json +11846 -46
- package/src/molecules/__fixtures__/products.json +81539 -0
- package/src/molecules/button/Button.stories.tsx +1 -1
- package/src/molecules/button/Button.tsx +43 -24
- package/src/molecules/card/Card.tsx +4 -0
- package/src/molecules/forms/form-control/FormControl.spec.tsx +7 -4
- package/src/molecules/forms/form-control/FormControl.stories.tsx +4 -4
- package/src/molecules/forms/form-control/FormControl.tsx +46 -20
- package/src/molecules/forms/input-tags/InputTags.interface.ts +9 -0
- package/src/molecules/forms/input-tags/InputTags.tsx +20 -42
- package/src/molecules/forms/input-tags/all.ts +6 -0
- package/src/molecules/forms/input-tags/components/ChoicesTags.stories.tsx +110 -0
- package/src/molecules/forms/input-tags/components/ChoicesTags.tsx +72 -0
- package/src/molecules/forms/input-tags/components/ReactTags.stories.tsx +140 -0
- package/src/molecules/forms/input-tags/components/ReactTags.tsx +38 -0
- package/src/molecules/forms/input-text/InputText.interface.ts +5 -0
- package/src/molecules/forms/input-text/InputText.spec.tsx +1 -1
- package/src/molecules/forms/input-text/InputText.stories.tsx +4 -4
- package/src/molecules/forms/input-text/InputText.tsx +38 -53
- package/src/molecules/forms/select/{Select.interfaces.ts → Select.interface.ts} +8 -10
- package/src/molecules/forms/select/Select.tsx +5 -3
- package/src/molecules/forms/select/all.ts +2 -1
- package/src/molecules/forms/select/components/ChoicesSelect.stories.tsx +8 -7
- package/src/molecules/forms/select/components/ChoicesSelect.tsx +9 -18
- package/src/molecules/forms/select/components/HtmlSelect.stories.tsx +7 -7
- package/src/molecules/forms/select/components/HtmlSelect.tsx +3 -2
- package/src/molecules/forms/select/components/ReactSelect.stories.tsx +10 -8
- package/src/molecules/forms/select/components/ReactSelect.tsx +1 -1
- package/src/molecules/forms/select/hooks/useOptions.ts +6 -2
- package/src/molecules/loader/Loader.spec.tsx +2 -2
- package/src/molecules/loader/Loader.stories.tsx +7 -4
- package/src/molecules/loader/Loader.tsx +16 -6
- package/src/molecules/modal/Modal.stories.tsx +1 -1
- package/src/molecules/pagination/Pagination.spec.tsx +11 -11
- package/src/molecules/pagination/Pagination.stories.tsx +32 -10
- package/src/molecules/pagination/Pagination.tsx +29 -26
- package/src/molecules/table/Table.stories.tsx +284 -101
- package/src/molecules/table/Table.tsx +91 -86
- package/src/molecules/table/all.ts +16 -0
- package/src/molecules/table/components/DefaultArrowSort.tsx +20 -4
- package/src/molecules/table/components/DefaultCell.tsx +10 -1
- package/src/molecules/table/components/DefaultCellFooter.tsx +16 -0
- package/src/molecules/table/components/DefaultCellHeader.tsx +33 -13
- package/src/molecules/table/components/DefaultCellOperations.tsx +31 -20
- package/src/molecules/table/components/DefaultFilter.tsx +42 -0
- package/src/molecules/table/components/DefaultOperationButton.tsx +19 -34
- package/src/molecules/table/filters/Filters.d.ts +31 -0
- package/src/molecules/table/filters/RangeFilter.tsx +43 -0
- package/src/molecules/table/filters/SelectFilter.tsx +47 -0
- package/src/molecules/table/filters/TextFieldFilter.tsx +36 -0
- package/src/molecules/table/hooks/useTable.tsx +76 -0
- package/src/molecules/table/hooks/useUniqValues.tsx +10 -0
- package/src/molecules/table/interfaces/extends.ts +18 -0
- package/src/molecules/table/utils/mapFormToColumns.tsx +69 -26
- package/src/molecules/tabs/Tab.tsx +106 -0
- package/src/molecules/tabs/TabList.tsx +37 -0
- package/src/molecules/tabs/TabPanel.tsx +37 -0
- package/src/molecules/tabs/Tabs.spec.tsx +126 -73
- package/src/molecules/tabs/Tabs.stories.tsx +298 -65
- package/src/molecules/tabs/Tabs.tsx +10 -81
- package/src/molecules/tabs/TabsBody.tsx +11 -0
- package/src/molecules/tabs/TabsLegacy.stories.tsx +103 -0
- package/src/molecules/tabs/TabsLegacy.tsx +86 -0
- package/src/molecules/tabs/all.ts +5 -0
- package/src/molecules/tabs/context/TabControl.tsx +166 -0
- package/src/molecules/tabs/hooks/tabControl.spec.tsx +388 -0
- package/src/molecules/tabs/hooks/tabControl.ts +52 -0
- package/src/organisms/__fixtures__/form-firstname.fixture.json +1 -0
- package/src/organisms/__fixtures__/form.fixture.json +1 -0
- package/src/organisms/form/Form.stories.tsx +104 -124
- package/src/organisms/form/access/FormAccess.schema.ts +1 -0
- package/src/organisms/form/access/FormAccess.stories.tsx +6 -4
- package/src/organisms/form/actions/FormAction.stories.tsx +426 -0
- package/src/organisms/form/{action → actions}/FormAction.tsx +2 -2
- package/src/organisms/form/builder/FormBuilder.stories.tsx +7 -4
- package/src/organisms/form/builder/FormEdit.reducer.spec.ts +136 -0
- package/src/organisms/form/builder/FormEdit.stories.tsx +16 -13
- package/src/organisms/form/builder/FormEdit.tsx +15 -7
- package/src/organisms/form/builder/FormEditCtas.tsx +10 -10
- package/src/organisms/form/builder/FormParameters.tsx +8 -4
- package/src/organisms/form/builder/all.ts +4 -0
- package/src/organisms/form/builder/useFormBuilder.ts +12 -7
- package/src/organisms/form/builder/useFormEdit.ts +3 -3
- package/src/organisms/form/exports/FormExport.stories.tsx +68 -0
- package/src/organisms/form/exports/FormExport.tsx +61 -0
- package/src/organisms/form/preview/FormPreview.stories.tsx +58 -0
- package/src/organisms/form/preview/FormPreview.tsx +23 -0
- package/src/organisms/form/settings/FormSettings.component.spec.tsx +3 -1
- package/src/organisms/form/settings/FormSettings.stories.tsx +2 -2
- package/src/organisms/form/settings/FormSettings.tsx +6 -6
- package/src/organisms/form/useForm.ts +2 -3
- package/src/organisms/modal/RemoveModal.stories.tsx +1 -1
- package/src/organisms/table/actions/ActionsTable.spec.tsx +7 -5
- package/src/organisms/table/actions/ActionsTable.stories.tsx +48 -45
- package/src/organisms/table/actions/ActionsTable.tsx +14 -18
- package/src/organisms/table/forms/FormsTable.stories.tsx +2 -0
- package/src/organisms/table/forms/FormsTable.tsx +53 -23
- package/src/organisms/table/forms/components/FormsCell.tsx +53 -0
- package/src/organisms/table/submissions/SubmissionsTable.stories.tsx +101 -57
- package/src/organisms/table/submissions/SubmissionsTable.tsx +12 -5
- package/src/organisms/views/FormViews.stories.tsx +221 -0
- package/src/organisms/views/FormViews.tsx +148 -0
- package/src/registries/components.ts +7 -1
- package/src/utils/iconClass.ts +1 -3
- package/vite.config.mts +2 -2
- package/dist/molecules/forms/select/Select.interfaces.js +0 -2
- package/dist/molecules/forms/select/Select.interfaces.js.map +0 -1
- package/dist/molecules/table/components/DefaultCells.d.ts +0 -4
- package/dist/molecules/table/components/DefaultCells.js +0 -23
- package/dist/molecules/table/components/DefaultCells.js.map +0 -1
- package/dist/molecules/table/components/DefaultRow.d.ts +0 -12
- package/dist/molecules/table/components/DefaultRow.js +0 -26
- package/dist/molecules/table/components/DefaultRow.js.map +0 -1
- package/dist/molecules/table/components/DragNDropContainer.d.ts +0 -4
- package/dist/molecules/table/components/DragNDropContainer.js +0 -10
- package/dist/molecules/table/components/DragNDropContainer.js.map +0 -1
- package/dist/molecules/table/filters/DefaultColumnFilter.d.ts +0 -10
- package/dist/molecules/table/filters/DefaultColumnFilter.js +0 -29
- package/dist/molecules/table/filters/DefaultColumnFilter.js.map +0 -1
- package/dist/molecules/table/filters/SelectColumnFilter.d.ts +0 -10
- package/dist/molecules/table/filters/SelectColumnFilter.js +0 -34
- package/dist/molecules/table/filters/SelectColumnFilter.js.map +0 -1
- package/dist/molecules/table/filters/SliderColumnFilter.d.ts +0 -9
- package/dist/molecules/table/filters/SliderColumnFilter.js +0 -27
- package/dist/molecules/table/filters/SliderColumnFilter.js.map +0 -1
- package/dist/molecules/table/hooks/useCustomTable.d.ts +0 -128
- package/dist/molecules/table/hooks/useCustomTable.js +0 -130
- package/dist/molecules/table/hooks/useCustomTable.js.map +0 -1
- package/dist/molecules/table/hooks/useDragnDropRow.d.ts +0 -272
- package/dist/molecules/table/hooks/useDragnDropRow.js +0 -40
- package/dist/molecules/table/hooks/useDragnDropRow.js.map +0 -1
- package/dist/molecules/table/hooks/useOperations.d.ts +0 -11
- package/dist/molecules/table/hooks/useOperations.js +0 -25
- package/dist/molecules/table/hooks/useOperations.js.map +0 -1
- package/dist/molecules/table/index.d.ts +0 -15
- package/dist/molecules/table/index.js +0 -35
- package/dist/molecules/table/index.js.map +0 -1
- package/dist/molecules/table/utils/getPageNumbers.js.map +0 -1
- package/dist/molecules/table/utils/swapElements.d.ts +0 -1
- package/dist/molecules/table/utils/swapElements.js +0 -5
- package/dist/molecules/table/utils/swapElements.js.map +0 -1
- package/dist/organisms/form/action/FormAction.js +0 -32
- package/dist/organisms/form/action/FormAction.js.map +0 -1
- package/dist/organisms/table/forms/components/FormCell.d.ts +0 -6
- package/dist/organisms/table/forms/components/FormCell.js +0 -50
- package/dist/organisms/table/forms/components/FormCell.js.map +0 -1
- package/dist/typings.d.js +0 -2
- package/dist/typings.d.js.map +0 -1
- package/src/molecules/forms/input-tags/InputTags.stories.tsx +0 -81
- package/src/molecules/table/components/DefaultCells.tsx +0 -30
- package/src/molecules/table/components/DefaultRow.tsx +0 -52
- package/src/molecules/table/components/DragNDropContainer.tsx +0 -7
- package/src/molecules/table/filters/DefaultColumnFilter.spec.tsx +0 -33
- package/src/molecules/table/filters/DefaultColumnFilter.tsx +0 -38
- package/src/molecules/table/filters/SelectColumnFilter.spec.tsx +0 -68
- package/src/molecules/table/filters/SelectColumnFilter.tsx +0 -51
- package/src/molecules/table/filters/SliderColumnFilter.tsx +0 -28
- package/src/molecules/table/hooks/useCustomTable.tsx +0 -268
- package/src/molecules/table/hooks/useDragnDropRow.ts +0 -80
- package/src/molecules/table/hooks/useOperations.tsx +0 -39
- package/src/molecules/table/index.ts +0 -15
- package/src/molecules/table/utils/swapElements.spec.ts +0 -7
- package/src/molecules/table/utils/swapElements.ts +0 -7
- package/src/organisms/form/action/FormAction.stories.tsx +0 -364
- package/src/organisms/table/forms/components/FormCell.tsx +0 -47
- package/src/typings.d.ts +0 -3
- package/tsconfig.app.json +0 -11
- package/tsconfig.json +0 -21
- package/tsconfig.node.json +0 -13
- package/tsconfig.spec.json +0 -14
- /package/dist/molecules/{table → pagination}/utils/getPageNumbers.d.ts +0 -0
- /package/dist/molecules/{table → pagination}/utils/getPageNumbers.js +0 -0
- /package/dist/organisms/form/{action → actions}/FormAction.d.ts +0 -0
- /package/src/molecules/{table → pagination}/utils/getPageNumbers.ts +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import cx from "classnames";
|
|
2
|
-
import { type ButtonHTMLAttributes, forwardRef, type
|
|
2
|
+
import { type ButtonHTMLAttributes, forwardRef, type PropsWithChildren } from "react";
|
|
3
3
|
|
|
4
4
|
import { registerComponent } from "../../registries/components";
|
|
5
5
|
|
|
@@ -24,31 +24,50 @@ export const BUTTON_VARIANTS = [
|
|
|
24
24
|
"outline-link"
|
|
25
25
|
];
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
interface BaseButtonProps<T extends HTMLElement> extends ButtonHTMLAttributes<T> {
|
|
28
|
+
tag?: "button" | "a" | "input" | "div";
|
|
28
29
|
variant?: (typeof BUTTON_VARIANTS)[keyof typeof BUTTON_VARIANTS] | string;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
)
|
|
32
|
+
interface HTMLAnchorProps extends BaseButtonProps<HTMLAnchorElement> {
|
|
33
|
+
tag: "a";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface HTMLButtonProps extends BaseButtonProps<HTMLButtonElement> {
|
|
37
|
+
tag?: "button";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface HTMLInputProps extends BaseButtonProps<HTMLInputElement> {
|
|
41
|
+
tag: "input";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface HTMLDivProps extends BaseButtonProps<HTMLDivElement> {
|
|
45
|
+
tag: "div";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type ButtonProps = HTMLAnchorProps | HTMLButtonProps | HTMLInputProps | HTMLDivProps;
|
|
49
|
+
|
|
50
|
+
export const Button = forwardRef(({ tag: Tag = "button", variant, className, children, ...props }: PropsWithChildren<ButtonProps>, ref) => {
|
|
51
|
+
return (
|
|
52
|
+
<Tag
|
|
53
|
+
{...(props as any)}
|
|
54
|
+
ref={ref as any}
|
|
55
|
+
className={cx(
|
|
56
|
+
"btn flex gap-1",
|
|
57
|
+
{
|
|
58
|
+
disabled: props.disabled
|
|
59
|
+
},
|
|
60
|
+
`btn-${variant}`,
|
|
61
|
+
className
|
|
62
|
+
)}
|
|
63
|
+
disabled={props.disabled}
|
|
64
|
+
onClick={(evt) => !props.disabled && props.onClick?.(evt as any)}
|
|
65
|
+
>
|
|
66
|
+
{children}
|
|
67
|
+
</Tag>
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
Button.displayName = "Button";
|
|
53
72
|
|
|
54
73
|
registerComponent("Button", Button);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import classnames from "classnames";
|
|
2
2
|
import { PropsWithChildren } from "react";
|
|
3
3
|
|
|
4
|
+
import { registerComponent } from "../../registries/components.js";
|
|
5
|
+
|
|
4
6
|
export interface CardProps {
|
|
5
7
|
label: string;
|
|
6
8
|
className?: string;
|
|
@@ -18,3 +20,5 @@ export function Card({ children, label, className }: PropsWithChildren<CardProps
|
|
|
18
20
|
</div>
|
|
19
21
|
);
|
|
20
22
|
}
|
|
23
|
+
|
|
24
|
+
registerComponent("Card", Card);
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { Formio } from "@formio/js";
|
|
1
2
|
import { render, screen } from "@testing-library/react";
|
|
2
3
|
|
|
3
4
|
import { iconClass } from "../../../utils/iconClass";
|
|
4
5
|
import { FormControl } from "./FormControl";
|
|
5
6
|
import { Sandbox } from "./FormControl.stories";
|
|
6
7
|
|
|
8
|
+
Formio.setProjectUrl("https://api.form.io");
|
|
9
|
+
|
|
7
10
|
describe("form-control", () => {
|
|
8
11
|
it("should display form control component", () => {
|
|
9
12
|
render(<FormControl {...Sandbox.args} name='test' />);
|
|
@@ -34,9 +37,9 @@ describe("form-control", () => {
|
|
|
34
37
|
});
|
|
35
38
|
|
|
36
39
|
it("should display prefix", () => {
|
|
37
|
-
const fontAwsomeCalendarIcon = "
|
|
40
|
+
const fontAwsomeCalendarIcon = "bi bi-calendar";
|
|
38
41
|
const prefix = (<i className={iconClass(undefined, "calendar")} />) as JSX.Element;
|
|
39
|
-
render(<FormControl {...Sandbox.args} name='testPrefix'
|
|
42
|
+
render(<FormControl {...Sandbox.args} name='testPrefix' before={prefix} />);
|
|
40
43
|
|
|
41
44
|
const formGroup = screen.getByTestId("form-group-testPrefix") as HTMLFormElement;
|
|
42
45
|
const formControlPrefix = screen.getByTestId("form-control-prefix") as HTMLSpanElement;
|
|
@@ -48,9 +51,9 @@ describe("form-control", () => {
|
|
|
48
51
|
});
|
|
49
52
|
|
|
50
53
|
it("should display suffix", () => {
|
|
51
|
-
const fontAwsomeCalendarIcon = "
|
|
54
|
+
const fontAwsomeCalendarIcon = "bi bi-calendar";
|
|
52
55
|
const suffix = (<i className={iconClass(undefined, "calendar")} />) as JSX.Element;
|
|
53
|
-
render(<FormControl {...Sandbox.args} name='testSuffix'
|
|
56
|
+
render(<FormControl {...Sandbox.args} name='testSuffix' after={suffix} />);
|
|
54
57
|
|
|
55
58
|
const formGroup = screen.getByTestId("form-group-testSuffix") as HTMLFormElement;
|
|
56
59
|
const formControlSuffix = screen.getByTestId("form-control-suffix") as HTMLSpanElement;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Meta, StoryObj } from "@storybook/react";
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
2
|
|
|
3
3
|
import { iconClass } from "../../../utils/iconClass";
|
|
4
4
|
import { FormControl } from "./FormControl";
|
|
@@ -38,15 +38,15 @@ export const Usage: Story = {
|
|
|
38
38
|
args: {
|
|
39
39
|
label: "Label",
|
|
40
40
|
children: "[TEXTFIELD]",
|
|
41
|
-
|
|
41
|
+
before: <i className={iconClass(undefined, "calendar")} />
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
export const
|
|
45
|
+
export const AppendAfter: Story = {
|
|
46
46
|
args: {
|
|
47
47
|
label: "Label",
|
|
48
48
|
children: "[TEXTFIELD]",
|
|
49
|
-
|
|
49
|
+
after: <i className={iconClass(undefined, "calendar")} />
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
|
|
@@ -1,51 +1,75 @@
|
|
|
1
1
|
import classnames from "classnames";
|
|
2
|
-
import
|
|
2
|
+
import omit from "lodash/omit";
|
|
3
|
+
import { HTMLAttributes, InputHTMLAttributes, PropsWithChildren, ReactNode } from "react";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
value?: Data;
|
|
8
|
-
required?: boolean;
|
|
5
|
+
import { registerComponent } from "../../../registries/components";
|
|
6
|
+
|
|
7
|
+
export type BaseFormControlProps<Value = unknown> = {
|
|
9
8
|
label?: string;
|
|
10
|
-
className?: string;
|
|
11
|
-
onChange?: (name: string, value: any) => void;
|
|
12
9
|
description?: string | ReactNode;
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
before?: ReactNode | string;
|
|
11
|
+
after?: ReactNode | string;
|
|
15
12
|
shadow?: boolean;
|
|
13
|
+
value?: Value;
|
|
14
|
+
onChange?: (name: string | undefined, value: Value) => void;
|
|
15
|
+
/**
|
|
16
|
+
* The input size
|
|
17
|
+
*/
|
|
18
|
+
size?: "small" | string;
|
|
19
|
+
};
|
|
20
|
+
export type FormControlProps<
|
|
21
|
+
Value = unknown,
|
|
22
|
+
Attributes extends HTMLAttributes<HTMLElement> = InputHTMLAttributes<HTMLInputElement>
|
|
23
|
+
> = BaseFormControlProps<Value> & Omit<Attributes, "onChange" | "value" | "size">;
|
|
24
|
+
|
|
25
|
+
export function cleanFormControlProps(props: FormControlProps, omitted: string[] = []): any {
|
|
26
|
+
return omit(props, ["label", "description", "prefix", "suffix", "size", "shadow", ...omitted]);
|
|
16
27
|
}
|
|
17
28
|
|
|
18
|
-
export function FormControl({
|
|
29
|
+
export function FormControl<Value = unknown>({
|
|
19
30
|
children,
|
|
20
|
-
name,
|
|
31
|
+
name = "",
|
|
21
32
|
id = name,
|
|
22
33
|
required,
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
before,
|
|
35
|
+
after,
|
|
25
36
|
description,
|
|
26
37
|
label,
|
|
38
|
+
size,
|
|
27
39
|
className
|
|
28
|
-
}: PropsWithChildren<FormControlProps
|
|
40
|
+
}: PropsWithChildren<FormControlProps<Value>>) {
|
|
29
41
|
return (
|
|
30
|
-
<div
|
|
42
|
+
<div
|
|
43
|
+
data-testid={name && `form-group-${name}`}
|
|
44
|
+
id={`form-group-${name || ""}`}
|
|
45
|
+
className={classnames(
|
|
46
|
+
"form-group",
|
|
47
|
+
{
|
|
48
|
+
"-with-before": !!before,
|
|
49
|
+
"-with-after": !!after
|
|
50
|
+
},
|
|
51
|
+
size && `-size-${size}`,
|
|
52
|
+
className
|
|
53
|
+
)}
|
|
54
|
+
>
|
|
31
55
|
{label && (
|
|
32
56
|
<label htmlFor={id} data-testid='form-control-label' className={`col-form-label ${required ? " field-required" : ""}`}>
|
|
33
57
|
{label}
|
|
34
58
|
</label>
|
|
35
59
|
)}
|
|
36
60
|
<div className={"input-group"}>
|
|
37
|
-
{
|
|
61
|
+
{before && (
|
|
38
62
|
<div className='input-group-prepend'>
|
|
39
63
|
<span className='input-group-text' data-testid='form-control-prefix'>
|
|
40
|
-
{
|
|
64
|
+
{before}
|
|
41
65
|
</span>
|
|
42
66
|
</div>
|
|
43
67
|
)}
|
|
44
68
|
{children}
|
|
45
|
-
{
|
|
69
|
+
{after && (
|
|
46
70
|
<div className='input-group-append'>
|
|
47
71
|
<span className='input-group-text' data-testid='form-control-suffix'>
|
|
48
|
-
{
|
|
72
|
+
{after}
|
|
49
73
|
</span>
|
|
50
74
|
</div>
|
|
51
75
|
)}
|
|
@@ -58,3 +82,5 @@ export function FormControl({
|
|
|
58
82
|
</div>
|
|
59
83
|
);
|
|
60
84
|
}
|
|
85
|
+
|
|
86
|
+
registerComponent("FormControl", FormControl);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { InputHTMLAttributes } from "react";
|
|
2
|
+
|
|
3
|
+
import type { FormControlProps } from "../form-control/FormControl";
|
|
4
|
+
|
|
5
|
+
export interface InputTagsProps<Data = string> extends FormControlProps<Data[], InputHTMLAttributes<HTMLInputElement>> {
|
|
6
|
+
layout?: "html5" | "react" | "choicesjs";
|
|
7
|
+
delimiter?: string;
|
|
8
|
+
customProperties?: Record<string, any>;
|
|
9
|
+
}
|
|
@@ -1,50 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import uniq from "lodash/uniq";
|
|
3
|
-
import { useEffect, useRef } from "react";
|
|
1
|
+
import { ComponentType } from "react";
|
|
4
2
|
|
|
5
|
-
import { registerComponent } from "../../../registries/components";
|
|
6
|
-
import { FormControl
|
|
3
|
+
import { getComponent, registerComponent } from "../../../registries/components";
|
|
4
|
+
import { type FormControl as DefaultFormControl } from "../form-control/FormControl";
|
|
5
|
+
import type { InputTagsProps } from "./InputTags.interface";
|
|
7
6
|
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
onChange?: (name: string, value: T) => void;
|
|
11
|
-
placeholder?: string;
|
|
7
|
+
export function InputTags<Data = string>(props: InputTagsProps) {
|
|
8
|
+
const { name, id = name, label, required, description, before, after, size, className, layout = "choicesjs", ...otherProps } = props;
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function InputTags({ name, value = [], label, onChange, required, description, prefix, suffix, ...props }: InputTagsProps) {
|
|
17
|
-
const ref: any = useRef();
|
|
18
|
-
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
const instance = new Choices(ref.current, {
|
|
21
|
-
delimiter: ",",
|
|
22
|
-
editItems: true,
|
|
23
|
-
removeItemButton: true
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
instance.setValue([].concat(value, []));
|
|
27
|
-
|
|
28
|
-
instance.passedElement.element.addEventListener("addItem", (event: any) => {
|
|
29
|
-
onChange && onChange(name, uniq(value.concat(event.detail.value)));
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
instance.passedElement.element.addEventListener("removeItem", (event: any) => {
|
|
33
|
-
onChange &&
|
|
34
|
-
onChange(
|
|
35
|
-
name,
|
|
36
|
-
value.filter((v: string) => v !== event.detail.value)
|
|
37
|
-
);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
return () => {
|
|
41
|
-
instance.destroy();
|
|
42
|
-
};
|
|
43
|
-
}, []);
|
|
10
|
+
const FormControl = getComponent<typeof DefaultFormControl>("FormControl");
|
|
11
|
+
const Component = getComponent<ComponentType<InputTagsProps<Data>>>([`InputTags.${layout}`, "Input"]);
|
|
44
12
|
|
|
45
13
|
return (
|
|
46
|
-
<FormControl
|
|
47
|
-
|
|
14
|
+
<FormControl
|
|
15
|
+
id={id}
|
|
16
|
+
name={name}
|
|
17
|
+
label={label}
|
|
18
|
+
required={required}
|
|
19
|
+
description={description}
|
|
20
|
+
before={before}
|
|
21
|
+
after={after}
|
|
22
|
+
size={size}
|
|
23
|
+
className={className}
|
|
24
|
+
>
|
|
25
|
+
<Component {...(otherProps as any)} id={id} name={name} required={required} />
|
|
48
26
|
</FormControl>
|
|
49
27
|
);
|
|
50
28
|
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import "../all";
|
|
2
|
+
|
|
3
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
4
|
+
|
|
5
|
+
import { iconClass } from "../../../../utils/iconClass";
|
|
6
|
+
import { useValue } from "../../../__fixtures__/useValue.hook";
|
|
7
|
+
import { InputTags } from "../InputTags";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The InputTags component enables users to create new options in the text field.
|
|
11
|
+
*
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import {InputTags} from "@tsed/react-formio/molecules/forms/input-tags/all";
|
|
14
|
+
*
|
|
15
|
+
* or
|
|
16
|
+
*
|
|
17
|
+
* import "@tsed/react-formio/molecules/forms/input-tags/components/ChoicesTags";
|
|
18
|
+
* import "@tsed/react-formio/molecules/forms/input-tags/components/ReactTags";
|
|
19
|
+
* import "@tsed/react-formio/molecules/forms/input-text/InputText";
|
|
20
|
+
* import {InputTags} from "@tsed/react-formio/molecules/forms/input-tags/InputTags";
|
|
21
|
+
*
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export default {
|
|
25
|
+
title: "forms/InputTags/ChoicesJs",
|
|
26
|
+
component: InputTags,
|
|
27
|
+
argTypes: {
|
|
28
|
+
label: {
|
|
29
|
+
control: "text"
|
|
30
|
+
},
|
|
31
|
+
name: {
|
|
32
|
+
control: "text"
|
|
33
|
+
},
|
|
34
|
+
value: {
|
|
35
|
+
control: "object"
|
|
36
|
+
},
|
|
37
|
+
size: {
|
|
38
|
+
control: "select",
|
|
39
|
+
options: ["small", "normal"]
|
|
40
|
+
},
|
|
41
|
+
placeholder: {
|
|
42
|
+
control: "text"
|
|
43
|
+
},
|
|
44
|
+
description: {
|
|
45
|
+
control: "text"
|
|
46
|
+
},
|
|
47
|
+
layout: {
|
|
48
|
+
control: "select",
|
|
49
|
+
options: ["choicesjs", "react"]
|
|
50
|
+
},
|
|
51
|
+
onChange: {
|
|
52
|
+
action: "onChange"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
parameters: {},
|
|
56
|
+
args: {
|
|
57
|
+
layout: "choicesjs"
|
|
58
|
+
},
|
|
59
|
+
tags: ["autodocs"]
|
|
60
|
+
} satisfies Meta<typeof InputTags>;
|
|
61
|
+
|
|
62
|
+
type Story = StoryObj<typeof InputTags>;
|
|
63
|
+
|
|
64
|
+
export const Usage: Story = {
|
|
65
|
+
args: {
|
|
66
|
+
name: "name",
|
|
67
|
+
label: "Label",
|
|
68
|
+
value: ["test"],
|
|
69
|
+
size: "",
|
|
70
|
+
placeholder: "Placeholder"
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const WithSizeOption: Story = {
|
|
75
|
+
args: {
|
|
76
|
+
name: "name",
|
|
77
|
+
label: "Label",
|
|
78
|
+
value: ["test"],
|
|
79
|
+
size: "small",
|
|
80
|
+
placeholder: "Placeholder"
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const AppendBefore: Story = {
|
|
85
|
+
render(args) {
|
|
86
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
87
|
+
return <InputTags before={<i className={iconClass(undefined, "calendar")} />} {...useValue(args)} />;
|
|
88
|
+
},
|
|
89
|
+
args: {
|
|
90
|
+
label: "Label",
|
|
91
|
+
value: [],
|
|
92
|
+
name: "name",
|
|
93
|
+
size: "",
|
|
94
|
+
placeholder: "Placeholder"
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const AppendAfter: Story = {
|
|
99
|
+
render(args) {
|
|
100
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
101
|
+
return <InputTags after={<i className={iconClass(undefined, "calendar")} />} {...useValue(args)} />;
|
|
102
|
+
},
|
|
103
|
+
args: {
|
|
104
|
+
label: "Label",
|
|
105
|
+
value: [],
|
|
106
|
+
name: "name",
|
|
107
|
+
size: "",
|
|
108
|
+
placeholder: "Placeholder"
|
|
109
|
+
}
|
|
110
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import Choices from "@formio/choices.js";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
import { useDebouncedCallback } from "use-debounce";
|
|
4
|
+
|
|
5
|
+
import { registerComponent } from "../../../../registries/components";
|
|
6
|
+
import { cleanFormControlProps } from "../../form-control/FormControl";
|
|
7
|
+
import type { InputTagsProps } from "../InputTags.interface";
|
|
8
|
+
|
|
9
|
+
export function useChoiceTags<Data = string>(props: InputTagsProps<Data>) {
|
|
10
|
+
const { value, onChange, name = "", delimiter, customProperties, ...otherProps } = props;
|
|
11
|
+
const ref = useRef<HTMLInputElement | null>(null);
|
|
12
|
+
const instanceRef = useRef<Choices | null>(null);
|
|
13
|
+
|
|
14
|
+
const onAdd = useDebouncedCallback((add: Data) => {
|
|
15
|
+
const values = ((value || []) as Data[]).concat(add);
|
|
16
|
+
|
|
17
|
+
onChange?.(name, [...values]);
|
|
18
|
+
}, 100);
|
|
19
|
+
|
|
20
|
+
const onDelete = useDebouncedCallback((remove: Data) => {
|
|
21
|
+
const values = (value || []).filter((v) => v !== remove);
|
|
22
|
+
|
|
23
|
+
onChange?.(name, [...values]);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (ref.current) {
|
|
28
|
+
const instance = new Choices(ref.current!, {
|
|
29
|
+
duplicateItemsAllowed: false,
|
|
30
|
+
...customProperties,
|
|
31
|
+
delimiter,
|
|
32
|
+
editItems: true,
|
|
33
|
+
removeItemButton: true
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
instance.setValue((value || []) as string[]);
|
|
37
|
+
|
|
38
|
+
instanceRef.current = instance;
|
|
39
|
+
|
|
40
|
+
instance.passedElement.element.addEventListener("addItem", (event) => {
|
|
41
|
+
onAdd((event.target as any).value as Data);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
instance.passedElement.element.addEventListener("removeItem", (event) => {
|
|
45
|
+
onDelete((event.target as any).value as Data);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return () => {
|
|
50
|
+
if (instanceRef.current) {
|
|
51
|
+
instanceRef.current.destroy();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}, [delimiter]);
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
otherProps: {
|
|
58
|
+
...otherProps,
|
|
59
|
+
name
|
|
60
|
+
},
|
|
61
|
+
ref,
|
|
62
|
+
instanceRef
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function ChoicesTags<Data = string>(props: InputTagsProps<Data>) {
|
|
67
|
+
const { ref, otherProps } = useChoiceTags<Data>(props);
|
|
68
|
+
|
|
69
|
+
return <input type='text' {...cleanFormControlProps(otherProps)} ref={ref} />;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
registerComponent("InputTags.choicesjs", ChoicesTags);
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import "../all";
|
|
2
|
+
|
|
3
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
4
|
+
import { type CreatableProps } from "react-select/creatable";
|
|
5
|
+
|
|
6
|
+
import { iconClass } from "../../../../utils/iconClass";
|
|
7
|
+
import { useValue } from "../../../__fixtures__/useValue.hook";
|
|
8
|
+
import { InputTags } from "../InputTags";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The InputTags component enables users to create new options in the text field.
|
|
12
|
+
*
|
|
13
|
+
* ```tsx
|
|
14
|
+
* import {InputTags} from "@tsed/react-formio/molecules/forms/input-tags/all";
|
|
15
|
+
*
|
|
16
|
+
* or
|
|
17
|
+
*
|
|
18
|
+
* import "@tsed/react-formio/molecules/forms/input-tags/components/ReactTags";
|
|
19
|
+
* import "@tsed/react-formio/molecules/forms/input-text/InputText";
|
|
20
|
+
* import {InputTags} from "@tsed/react-formio/molecules/forms/input-tags/InputTags";
|
|
21
|
+
*
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export default {
|
|
25
|
+
title: "forms/InputTags/React",
|
|
26
|
+
component: InputTags,
|
|
27
|
+
argTypes: {
|
|
28
|
+
label: {
|
|
29
|
+
control: "text"
|
|
30
|
+
},
|
|
31
|
+
name: {
|
|
32
|
+
control: "text"
|
|
33
|
+
},
|
|
34
|
+
value: {
|
|
35
|
+
control: "object"
|
|
36
|
+
},
|
|
37
|
+
size: {
|
|
38
|
+
control: "select",
|
|
39
|
+
options: ["small", "normal"]
|
|
40
|
+
},
|
|
41
|
+
placeholder: {
|
|
42
|
+
control: "text"
|
|
43
|
+
},
|
|
44
|
+
description: {
|
|
45
|
+
control: "text"
|
|
46
|
+
},
|
|
47
|
+
layout: {
|
|
48
|
+
control: "select",
|
|
49
|
+
options: ["choicesjs", "react"]
|
|
50
|
+
},
|
|
51
|
+
onChange: {
|
|
52
|
+
action: "onChange"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
parameters: {},
|
|
56
|
+
args: {
|
|
57
|
+
layout: "react"
|
|
58
|
+
},
|
|
59
|
+
tags: ["autodocs"],
|
|
60
|
+
render(args) {
|
|
61
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
62
|
+
const { value, onChange } = useValue(args);
|
|
63
|
+
|
|
64
|
+
return <InputTags {...args} value={value} onChange={onChange} />;
|
|
65
|
+
}
|
|
66
|
+
} satisfies Meta<typeof InputTags>;
|
|
67
|
+
|
|
68
|
+
type Story = StoryObj<typeof InputTags>;
|
|
69
|
+
|
|
70
|
+
export const Usage: Story = {
|
|
71
|
+
args: {
|
|
72
|
+
name: "name",
|
|
73
|
+
label: "Label",
|
|
74
|
+
value: ["test"],
|
|
75
|
+
size: "",
|
|
76
|
+
placeholder: "Placeholder"
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const WithSizeOption: Story = {
|
|
81
|
+
args: {
|
|
82
|
+
name: "name",
|
|
83
|
+
label: "Label",
|
|
84
|
+
value: ["test"],
|
|
85
|
+
size: "small",
|
|
86
|
+
placeholder: "Placeholder"
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const AppendBefore: Story = {
|
|
91
|
+
render(args) {
|
|
92
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
93
|
+
return <InputTags before={<i className={iconClass(undefined, "calendar")} />} {...useValue(args)} />;
|
|
94
|
+
},
|
|
95
|
+
args: {
|
|
96
|
+
label: "Label",
|
|
97
|
+
value: [],
|
|
98
|
+
name: "name",
|
|
99
|
+
size: "",
|
|
100
|
+
placeholder: "Placeholder"
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export const AppendAfter: Story = {
|
|
105
|
+
render(args) {
|
|
106
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
107
|
+
return <InputTags after={<i className={iconClass(undefined, "calendar")} />} {...useValue(args)} />;
|
|
108
|
+
},
|
|
109
|
+
args: {
|
|
110
|
+
label: "Label",
|
|
111
|
+
value: [],
|
|
112
|
+
name: "name",
|
|
113
|
+
size: "",
|
|
114
|
+
placeholder: "Placeholder"
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* InputTags using the [react-select](https://react-select.com/) library can
|
|
120
|
+
* be customized using the `customProperties` prop.
|
|
121
|
+
*
|
|
122
|
+
* For example, you can use the `customProperties` prop to add a list of options.
|
|
123
|
+
*
|
|
124
|
+
* See the [react-select documentation](https://react-select.com/creatable) for more information.
|
|
125
|
+
*/
|
|
126
|
+
export const CustomProperties: Story = {
|
|
127
|
+
args: {
|
|
128
|
+
value: [],
|
|
129
|
+
name: "name",
|
|
130
|
+
label: "Label",
|
|
131
|
+
placeholder: "Select or Create...",
|
|
132
|
+
customProperties: {
|
|
133
|
+
options: [
|
|
134
|
+
{ value: "chocolate", label: "Chocolate" },
|
|
135
|
+
{ value: "strawberry", label: "Strawberry" },
|
|
136
|
+
{ value: "vanilla", label: "Vanilla" }
|
|
137
|
+
]
|
|
138
|
+
} satisfies CreatableProps<unknown, true, any>
|
|
139
|
+
}
|
|
140
|
+
};
|