@tsed/react-formio 3.0.0-alpha.9 → 3.0.0-rc.2
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/_baseClone.js +1268 -0
- package/dist/chunks/_baseClone.js.map +1 -0
- package/dist/chunks/_baseSlice.js +70 -0
- package/dist/chunks/_baseSlice.js.map +1 -0
- package/dist/chunks/_commonjsHelpers.js +30 -3
- package/dist/chunks/_commonjsHelpers.js.map +1 -1
- package/dist/chunks/_stringToArray.js +57 -0
- package/dist/chunks/_stringToArray.js.map +1 -0
- package/dist/chunks/camelCase.js +343 -0
- package/dist/chunks/camelCase.js.map +1 -0
- package/dist/chunks/cloneDeep.js +18 -0
- package/dist/chunks/cloneDeep.js.map +1 -0
- 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 +60074 -0
- package/dist/chunks/index2.js.map +1 -0
- package/dist/chunks/isEqual.js +8 -0
- package/dist/chunks/isEqual.js.map +1 -0
- package/dist/chunks/isEqual2.js +251 -0
- package/dist/chunks/isEqual2.js.map +1 -0
- package/dist/chunks/lodash.js +3678 -0
- package/dist/chunks/lodash.js.map +1 -0
- package/dist/chunks/noop.js +15 -0
- package/dist/chunks/noop.js.map +1 -0
- package/dist/chunks/omit.js +325 -0
- package/dist/chunks/omit.js.map +1 -0
- package/dist/chunks/react-select-animated.esm.js +1204 -1101
- package/dist/chunks/react-select-animated.esm.js.map +1 -1
- 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.js +22 -19
- package/dist/molecules/forms/form-control/FormControl.js.map +1 -1
- package/dist/molecules/forms/input-tags/InputTags.js +14 -14
- package/dist/molecules/forms/input-tags/InputTags.js.map +1 -1
- package/dist/molecules/forms/input-tags/components/ChoicesTags.d.ts +27 -27
- package/dist/molecules/forms/input-tags/components/ChoicesTags.js +32 -32
- package/dist/molecules/forms/input-tags/components/ChoicesTags.js.map +1 -1
- package/dist/molecules/forms/input-tags/components/ReactTags.js +289 -300
- package/dist/molecules/forms/input-tags/components/ReactTags.js.map +1 -1
- package/dist/molecules/forms/input-text/InputText.js +3 -3
- package/dist/molecules/forms/input-text/InputText.js.map +1 -1
- package/dist/molecules/forms/select/Select.interface.d.ts +5 -2
- package/dist/molecules/forms/select/Select.js.map +1 -1
- package/dist/molecules/forms/select/components/ChoicesSelect.js +70 -72
- package/dist/molecules/forms/select/components/ChoicesSelect.js.map +1 -1
- package/dist/molecules/forms/select/components/HtmlSelect.js +8 -8
- package/dist/molecules/forms/select/components/HtmlSelect.js.map +1 -1
- package/dist/molecules/forms/select/components/ReactSelect.js +13 -14
- 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 +1 -1
- 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 +25 -23
- 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/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 +35 -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 +5 -5
- 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 +6 -3
- package/dist/organisms/form/builder/FormEdit.js +45 -42
- package/dist/organisms/form/builder/FormEdit.js.map +1 -1
- package/dist/organisms/form/builder/FormEdit.reducer.js +3 -3
- 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.js.map +1 -1
- package/dist/organisms/form/builder/useFormBuilder.d.ts +4 -4
- package/dist/organisms/form/builder/useFormBuilder.js +37 -34
- package/dist/organisms/form/builder/useFormBuilder.js.map +1 -1
- package/dist/organisms/form/builder/useFormEdit.d.ts +1 -1
- package/dist/organisms/form/builder/useFormEdit.js +10 -10
- 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 +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 +19 -31
- 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 +19 -12
- 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 +5 -2
- package/src/molecules/forms/form-control/FormControl.stories.tsx +1 -1
- package/src/molecules/forms/input-tags/InputTags.tsx +1 -1
- package/src/molecules/forms/input-tags/components/ChoicesTags.stories.tsx +1 -1
- package/src/molecules/forms/input-tags/components/ChoicesTags.tsx +4 -4
- package/src/molecules/forms/input-tags/components/ReactTags.stories.tsx +1 -1
- package/src/molecules/forms/input-text/InputText.stories.tsx +2 -2
- package/src/molecules/forms/select/Select.interface.ts +5 -2
- package/src/molecules/forms/select/components/ChoicesSelect.stories.tsx +2 -2
- package/src/molecules/forms/select/components/ChoicesSelect.tsx +2 -2
- package/src/molecules/forms/select/components/HtmlSelect.stories.tsx +2 -2
- package/src/molecules/forms/select/components/ReactSelect.stories.tsx +2 -2
- package/src/molecules/forms/select/hooks/useOptions.ts +5 -1
- 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 +28 -25
- 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 +11 -7
- package/src/organisms/form/builder/FormEdit.tsx +12 -6
- package/src/organisms/form/builder/FormEditCtas.tsx +10 -10
- package/src/organisms/form/builder/useFormBuilder.ts +12 -7
- package/src/organisms/form/builder/useFormEdit.ts +1 -1
- 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 +13 -17
- 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 +14 -7
- 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/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
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
import "../../../molecules/card/Card.js";
|
|
2
|
+
import "../Form.js";
|
|
3
|
+
|
|
4
|
+
import { Meta, StoryObj } from "@storybook/react-vite";
|
|
5
|
+
|
|
6
|
+
import { FormAction } from "./FormAction.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* FormAction component displays a form for configuring form action
|
|
10
|
+
*
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import {FormAction} from "@tsed/react-formio/organisms/form/action/FormAction";
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export default {
|
|
16
|
+
title: "form/action/FormAction",
|
|
17
|
+
component: FormAction,
|
|
18
|
+
argTypes: {
|
|
19
|
+
actionInfo: {
|
|
20
|
+
description: "Information about the action including defaults and settings form",
|
|
21
|
+
control: "object"
|
|
22
|
+
},
|
|
23
|
+
submission: {
|
|
24
|
+
description: "Submission data to fill the form",
|
|
25
|
+
control: "object"
|
|
26
|
+
},
|
|
27
|
+
onSubmit: {
|
|
28
|
+
action: "onSubmit",
|
|
29
|
+
description: "Callback when the form is submitted"
|
|
30
|
+
},
|
|
31
|
+
options: {
|
|
32
|
+
description: "Form options",
|
|
33
|
+
control: "object"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
parameters: {
|
|
37
|
+
docs: {
|
|
38
|
+
description: {
|
|
39
|
+
component: "Component that displays a form for configuring form actions such as save, email, webhook, etc."
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
} satisfies Meta<typeof FormAction>;
|
|
44
|
+
|
|
45
|
+
type Story = StoryObj<typeof FormAction>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Basic save action configuration
|
|
49
|
+
*/
|
|
50
|
+
export const SaveAction: Story = {
|
|
51
|
+
args: {
|
|
52
|
+
actionInfo: {
|
|
53
|
+
name: "save",
|
|
54
|
+
title: "Save Submission",
|
|
55
|
+
description: "Saves the submission into the database.",
|
|
56
|
+
priority: 10,
|
|
57
|
+
defaults: {
|
|
58
|
+
handler: ["before"],
|
|
59
|
+
method: ["create", "update"],
|
|
60
|
+
priority: 10,
|
|
61
|
+
name: "save",
|
|
62
|
+
title: "Save Submission"
|
|
63
|
+
},
|
|
64
|
+
access: {
|
|
65
|
+
handler: false,
|
|
66
|
+
method: false
|
|
67
|
+
},
|
|
68
|
+
settingsForm: {
|
|
69
|
+
components: [
|
|
70
|
+
{
|
|
71
|
+
type: "hidden",
|
|
72
|
+
input: true,
|
|
73
|
+
key: "priority"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
type: "hidden",
|
|
77
|
+
input: true,
|
|
78
|
+
key: "name"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: "textfield",
|
|
82
|
+
input: true,
|
|
83
|
+
label: "Title",
|
|
84
|
+
key: "title"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
type: "fieldset",
|
|
88
|
+
input: false,
|
|
89
|
+
tree: true,
|
|
90
|
+
legend: "Action Settings",
|
|
91
|
+
key: "settings",
|
|
92
|
+
components: [
|
|
93
|
+
{
|
|
94
|
+
input: false,
|
|
95
|
+
type: "container",
|
|
96
|
+
key: "settings",
|
|
97
|
+
components: [
|
|
98
|
+
{
|
|
99
|
+
type: "resourcefields",
|
|
100
|
+
key: "resource",
|
|
101
|
+
title: "Save submission to",
|
|
102
|
+
placeholder: "This form",
|
|
103
|
+
basePath: "/project/5d0797bc872fc7d140559857/form",
|
|
104
|
+
form: "62b18b10fbbba513555c6c5e",
|
|
105
|
+
required: false,
|
|
106
|
+
input: true
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
type: "fieldset",
|
|
114
|
+
input: false,
|
|
115
|
+
tree: false,
|
|
116
|
+
key: "conditions",
|
|
117
|
+
legend: "Action Execution",
|
|
118
|
+
components: [
|
|
119
|
+
{
|
|
120
|
+
type: "select",
|
|
121
|
+
input: true,
|
|
122
|
+
key: "handler",
|
|
123
|
+
label: "Handler",
|
|
124
|
+
placeholder: "Select which handler(s) you would like to trigger",
|
|
125
|
+
dataSrc: "json",
|
|
126
|
+
data: {
|
|
127
|
+
json: '[{"name":"before","title":"Before"},{"name":"after","title":"After"}]'
|
|
128
|
+
},
|
|
129
|
+
template: "<span>{{ item.title }}</span>",
|
|
130
|
+
valueProperty: "name",
|
|
131
|
+
multiple: true
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
type: "select",
|
|
135
|
+
input: true,
|
|
136
|
+
label: "Methods",
|
|
137
|
+
key: "method",
|
|
138
|
+
placeholder: "Trigger action on method(s)",
|
|
139
|
+
dataSrc: "json",
|
|
140
|
+
data: {
|
|
141
|
+
json: '[{"name":"create","title":"Create"},{"name":"update","title":"Update"},{"name":"read","title":"Read"},{"name":"delete","title":"Delete"},{"name":"index","title":"Index"}]'
|
|
142
|
+
},
|
|
143
|
+
template: "<span>{{ item.title }}</span>",
|
|
144
|
+
valueProperty: "name",
|
|
145
|
+
multiple: true
|
|
146
|
+
}
|
|
147
|
+
]
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
type: "button",
|
|
151
|
+
input: true,
|
|
152
|
+
label: "Save Action",
|
|
153
|
+
key: "submit",
|
|
154
|
+
size: "md",
|
|
155
|
+
action: "submit",
|
|
156
|
+
disableOnInvalid: true,
|
|
157
|
+
theme: "primary"
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
options: { template: "tailwind", iconset: "lu" }
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Email action configuration
|
|
168
|
+
*/
|
|
169
|
+
export const EmailAction: Story = {
|
|
170
|
+
args: {
|
|
171
|
+
actionInfo: {
|
|
172
|
+
name: "email",
|
|
173
|
+
title: "Email",
|
|
174
|
+
description: "Sends an email when a form is submitted.",
|
|
175
|
+
priority: 0,
|
|
176
|
+
defaults: {
|
|
177
|
+
handler: ["after"],
|
|
178
|
+
method: ["create"],
|
|
179
|
+
priority: 0,
|
|
180
|
+
name: "email",
|
|
181
|
+
title: "Email"
|
|
182
|
+
},
|
|
183
|
+
access: {
|
|
184
|
+
handler: false,
|
|
185
|
+
method: false
|
|
186
|
+
},
|
|
187
|
+
settingsForm: {
|
|
188
|
+
components: [
|
|
189
|
+
{
|
|
190
|
+
type: "hidden",
|
|
191
|
+
input: true,
|
|
192
|
+
key: "priority"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
type: "hidden",
|
|
196
|
+
input: true,
|
|
197
|
+
key: "name"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
type: "textfield",
|
|
201
|
+
input: true,
|
|
202
|
+
label: "Title",
|
|
203
|
+
key: "title"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
type: "fieldset",
|
|
207
|
+
input: false,
|
|
208
|
+
tree: true,
|
|
209
|
+
legend: "Email Settings",
|
|
210
|
+
key: "settings",
|
|
211
|
+
components: [
|
|
212
|
+
{
|
|
213
|
+
type: "textfield",
|
|
214
|
+
input: true,
|
|
215
|
+
label: "From",
|
|
216
|
+
key: "from",
|
|
217
|
+
placeholder: "no-reply@example.com",
|
|
218
|
+
defaultValue: "no-reply@example.com",
|
|
219
|
+
multiple: false
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
type: "textfield",
|
|
223
|
+
input: true,
|
|
224
|
+
label: "To",
|
|
225
|
+
key: "to",
|
|
226
|
+
placeholder: "user@example.com",
|
|
227
|
+
multiple: true
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
type: "textfield",
|
|
231
|
+
input: true,
|
|
232
|
+
label: "Subject",
|
|
233
|
+
key: "subject",
|
|
234
|
+
placeholder: "New submission for {{ form.title }}",
|
|
235
|
+
defaultValue: "New submission for {{ form.title }}"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
type: "textarea",
|
|
239
|
+
input: true,
|
|
240
|
+
label: "Message",
|
|
241
|
+
key: "message",
|
|
242
|
+
placeholder: "{{ submission.data }}",
|
|
243
|
+
defaultValue: "{{ submission.data }}",
|
|
244
|
+
rows: 5
|
|
245
|
+
}
|
|
246
|
+
]
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
type: "fieldset",
|
|
250
|
+
input: false,
|
|
251
|
+
tree: false,
|
|
252
|
+
key: "conditions",
|
|
253
|
+
legend: "Action Execution",
|
|
254
|
+
components: [
|
|
255
|
+
{
|
|
256
|
+
type: "select",
|
|
257
|
+
input: true,
|
|
258
|
+
key: "handler",
|
|
259
|
+
label: "Handler",
|
|
260
|
+
placeholder: "Select which handler(s) you would like to trigger",
|
|
261
|
+
dataSrc: "json",
|
|
262
|
+
data: {
|
|
263
|
+
json: '[{"name":"before","title":"Before"},{"name":"after","title":"After"}]'
|
|
264
|
+
},
|
|
265
|
+
template: "<span>{{ item.title }}</span>",
|
|
266
|
+
valueProperty: "name",
|
|
267
|
+
multiple: true
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
type: "select",
|
|
271
|
+
input: true,
|
|
272
|
+
label: "Methods",
|
|
273
|
+
key: "method",
|
|
274
|
+
placeholder: "Trigger action on method(s)",
|
|
275
|
+
dataSrc: "json",
|
|
276
|
+
data: {
|
|
277
|
+
json: '[{"name":"create","title":"Create"},{"name":"update","title":"Update"},{"name":"read","title":"Read"},{"name":"delete","title":"Delete"},{"name":"index","title":"Index"}]'
|
|
278
|
+
},
|
|
279
|
+
template: "<span>{{ item.title }}</span>",
|
|
280
|
+
valueProperty: "name",
|
|
281
|
+
multiple: true
|
|
282
|
+
}
|
|
283
|
+
]
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
type: "button",
|
|
287
|
+
input: true,
|
|
288
|
+
label: "Save Action",
|
|
289
|
+
key: "submit",
|
|
290
|
+
size: "md",
|
|
291
|
+
action: "submit",
|
|
292
|
+
disableOnInvalid: true,
|
|
293
|
+
theme: "primary"
|
|
294
|
+
}
|
|
295
|
+
]
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
options: { template: "tailwind", iconset: "lu" }
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Webhook action configuration
|
|
304
|
+
*/
|
|
305
|
+
export const WebhookAction: Story = {
|
|
306
|
+
args: {
|
|
307
|
+
actionInfo: {
|
|
308
|
+
name: "webhook",
|
|
309
|
+
title: "Webhook",
|
|
310
|
+
description: "Sends a submission to a URL.",
|
|
311
|
+
priority: 0,
|
|
312
|
+
defaults: {
|
|
313
|
+
handler: ["after"],
|
|
314
|
+
method: ["create", "update"],
|
|
315
|
+
priority: 0,
|
|
316
|
+
name: "webhook",
|
|
317
|
+
title: "Webhook"
|
|
318
|
+
},
|
|
319
|
+
access: {
|
|
320
|
+
handler: false,
|
|
321
|
+
method: false
|
|
322
|
+
},
|
|
323
|
+
settingsForm: {
|
|
324
|
+
components: [
|
|
325
|
+
{
|
|
326
|
+
type: "hidden",
|
|
327
|
+
input: true,
|
|
328
|
+
key: "priority"
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
type: "hidden",
|
|
332
|
+
input: true,
|
|
333
|
+
key: "name"
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
type: "textfield",
|
|
337
|
+
input: true,
|
|
338
|
+
label: "Title",
|
|
339
|
+
key: "title"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
type: "fieldset",
|
|
343
|
+
input: false,
|
|
344
|
+
tree: true,
|
|
345
|
+
legend: "Webhook Settings",
|
|
346
|
+
key: "settings",
|
|
347
|
+
components: [
|
|
348
|
+
{
|
|
349
|
+
type: "textfield",
|
|
350
|
+
input: true,
|
|
351
|
+
label: "URL",
|
|
352
|
+
key: "url",
|
|
353
|
+
placeholder: "https://example.com/webhook",
|
|
354
|
+
multiple: false
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
type: "select",
|
|
358
|
+
input: true,
|
|
359
|
+
label: "Method",
|
|
360
|
+
key: "webhookMethod",
|
|
361
|
+
placeholder: "Select HTTP method",
|
|
362
|
+
dataSrc: "values",
|
|
363
|
+
data: {
|
|
364
|
+
values: [
|
|
365
|
+
{ label: "POST", value: "post" },
|
|
366
|
+
{ label: "PUT", value: "put" },
|
|
367
|
+
{ label: "PATCH", value: "patch" }
|
|
368
|
+
]
|
|
369
|
+
},
|
|
370
|
+
defaultValue: "post"
|
|
371
|
+
}
|
|
372
|
+
]
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
type: "fieldset",
|
|
376
|
+
input: false,
|
|
377
|
+
tree: false,
|
|
378
|
+
key: "conditions",
|
|
379
|
+
legend: "Action Execution",
|
|
380
|
+
components: [
|
|
381
|
+
{
|
|
382
|
+
type: "select",
|
|
383
|
+
input: true,
|
|
384
|
+
key: "handler",
|
|
385
|
+
label: "Handler",
|
|
386
|
+
placeholder: "Select which handler(s) you would like to trigger",
|
|
387
|
+
dataSrc: "json",
|
|
388
|
+
data: {
|
|
389
|
+
json: '[{"name":"before","title":"Before"},{"name":"after","title":"After"}]'
|
|
390
|
+
},
|
|
391
|
+
template: "<span>{{ item.title }}</span>",
|
|
392
|
+
valueProperty: "name",
|
|
393
|
+
multiple: true
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
type: "select",
|
|
397
|
+
input: true,
|
|
398
|
+
label: "Methods",
|
|
399
|
+
key: "method",
|
|
400
|
+
placeholder: "Trigger action on method(s)",
|
|
401
|
+
dataSrc: "json",
|
|
402
|
+
data: {
|
|
403
|
+
json: '[{"name":"create","title":"Create"},{"name":"update","title":"Update"},{"name":"read","title":"Read"},{"name":"delete","title":"Delete"},{"name":"index","title":"Index"}]'
|
|
404
|
+
},
|
|
405
|
+
template: "<span>{{ item.title }}</span>",
|
|
406
|
+
valueProperty: "name",
|
|
407
|
+
multiple: true
|
|
408
|
+
}
|
|
409
|
+
]
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
type: "button",
|
|
413
|
+
input: true,
|
|
414
|
+
label: "Save Action",
|
|
415
|
+
key: "submit",
|
|
416
|
+
size: "md",
|
|
417
|
+
action: "submit",
|
|
418
|
+
disableOnInvalid: true,
|
|
419
|
+
theme: "primary"
|
|
420
|
+
}
|
|
421
|
+
]
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
options: { template: "tailwind", iconset: "lu" }
|
|
425
|
+
}
|
|
426
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import FormioUtils from "
|
|
1
|
+
import FormioUtils from "@formio/js/utils";
|
|
2
2
|
import { PropsWithChildren, ReactElement } from "react";
|
|
3
3
|
|
|
4
4
|
import { ActionDefaultsType, ActionType, FormOptions, SubmissionType } from "../../../interfaces";
|
|
@@ -44,7 +44,7 @@ export function FormAction({ actionInfo, children, onSubmit, options, ...props }
|
|
|
44
44
|
const submission = mapData(props.submission || {}, actionInfo.defaults!);
|
|
45
45
|
const form = mapSettingsForm(actionInfo.settingsForm);
|
|
46
46
|
|
|
47
|
-
return { form, submission: { data: submission } };
|
|
47
|
+
return { form, submission: { data: submission } as SubmissionType<ActionType> };
|
|
48
48
|
})();
|
|
49
49
|
|
|
50
50
|
return (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
2
|
|
|
3
3
|
import form from "../../__fixtures__/form.fixture.json";
|
|
4
4
|
import formWizard from "../../__fixtures__/form-wizard.fixture.json";
|
|
@@ -59,6 +59,9 @@ export default {
|
|
|
59
59
|
action: "onDeleteComponent"
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
|
+
render(args) {
|
|
63
|
+
return <FormBuilder display={args.display} components={args.components} options={args.options} />;
|
|
64
|
+
},
|
|
62
65
|
tags: ["autodocs"]
|
|
63
66
|
} satisfies Meta<typeof FormBuilder>;
|
|
64
67
|
|
|
@@ -69,7 +72,7 @@ type Story = StoryObj<typeof FormBuilder>;
|
|
|
69
72
|
export const WebForm: Story = {
|
|
70
73
|
args: {
|
|
71
74
|
display: form.display as any,
|
|
72
|
-
options: { template: "tailwind", iconset: "
|
|
75
|
+
options: { template: "tailwind", iconset: "lu" },
|
|
73
76
|
components: form.components as any
|
|
74
77
|
}
|
|
75
78
|
};
|
|
@@ -81,7 +84,7 @@ export const Wizard: Story = {
|
|
|
81
84
|
args: {
|
|
82
85
|
display: formWizard.display as any,
|
|
83
86
|
components: formWizard.components as any,
|
|
84
|
-
options: { template: "tailwind", iconset: "
|
|
87
|
+
options: { template: "tailwind", iconset: "lu" }
|
|
85
88
|
}
|
|
86
89
|
};
|
|
87
90
|
/**
|
|
@@ -92,6 +95,6 @@ export const Pdf: Story = {
|
|
|
92
95
|
args: {
|
|
93
96
|
display: "pdf",
|
|
94
97
|
components: [],
|
|
95
|
-
options: { template: "tailwind", iconset: "
|
|
98
|
+
options: { template: "tailwind", iconset: "lu" }
|
|
96
99
|
}
|
|
97
100
|
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import cloneDeep from "lodash/cloneDeep";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
|
|
4
|
+
import type { FormType } from "../../../interfaces";
|
|
5
|
+
import { createInitialState, type FormEditState, hasChanged, reducer } from "./FormEdit.reducer";
|
|
6
|
+
|
|
7
|
+
const baseForm = (): Partial<FormType> => ({
|
|
8
|
+
title: "My Form",
|
|
9
|
+
name: "myForm",
|
|
10
|
+
path: "myform",
|
|
11
|
+
display: "form",
|
|
12
|
+
components: []
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe("FormEdit.reducer helpers", () => {
|
|
16
|
+
it("hasChanged: returns false when objects are equal", () => {
|
|
17
|
+
const a = baseForm();
|
|
18
|
+
const b = cloneDeep(a);
|
|
19
|
+
|
|
20
|
+
expect(hasChanged(a, b)).toBe(false);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("hasChanged: returns true when objects differ", () => {
|
|
24
|
+
const a = baseForm();
|
|
25
|
+
const b = { ...a, title: "Other" };
|
|
26
|
+
|
|
27
|
+
expect(hasChanged(a, b)).toBe(true);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("createInitialState: initializes with clones and empty history", () => {
|
|
31
|
+
const form = baseForm();
|
|
32
|
+
const state = createInitialState({ form });
|
|
33
|
+
|
|
34
|
+
expect(state.past).toEqual([]);
|
|
35
|
+
expect(state.future).toEqual([]);
|
|
36
|
+
expect(state.current).toEqual(form);
|
|
37
|
+
expect(state.original).toEqual(form);
|
|
38
|
+
|
|
39
|
+
// ensure deep clone (different references)
|
|
40
|
+
expect(state.current).not.toBe(form);
|
|
41
|
+
expect(state.original).not.toBe(form);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe("FormEdit.reducer", () => {
|
|
46
|
+
const initState = (form: Partial<FormType> = baseForm()): FormEditState => createInitialState({ form });
|
|
47
|
+
|
|
48
|
+
it("formChange: updates state and pushes previous current into past when changed", () => {
|
|
49
|
+
const state = initState();
|
|
50
|
+
const next = reducer(state, { type: "formChange", value: { title: "Updated" } });
|
|
51
|
+
|
|
52
|
+
expect(next.current.title).toBe("Updated");
|
|
53
|
+
expect(next.past).toHaveLength(1);
|
|
54
|
+
expect(next.past[0]).toEqual(state.current);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("formChange: updates name and path from title when no _id is set", () => {
|
|
58
|
+
const form = { ...baseForm(), _id: undefined } as any;
|
|
59
|
+
const state = initState(form);
|
|
60
|
+
|
|
61
|
+
const next = reducer(state, { type: "formChange", value: { title: "My New Title" } });
|
|
62
|
+
|
|
63
|
+
expect(next.current.title).toBe("My New Title");
|
|
64
|
+
// name/path should be derived from title via camelCase
|
|
65
|
+
expect(next.current.name).toBe("myNewTitle");
|
|
66
|
+
expect(next.current.path).toBe("mynewtitle");
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("formChange: does nothing when value has no changes", () => {
|
|
70
|
+
const state = initState();
|
|
71
|
+
const next = reducer(state, { type: "formChange", value: {} });
|
|
72
|
+
|
|
73
|
+
// state reference should be unchanged (no history push)
|
|
74
|
+
expect(next).toBe(state);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("undo: reverts to previous state and moves current to future", () => {
|
|
78
|
+
let state = initState();
|
|
79
|
+
state = reducer(state, { type: "formChange", value: { title: "Step1" } });
|
|
80
|
+
state = reducer(state, { type: "formChange", value: { title: "Step2" } });
|
|
81
|
+
|
|
82
|
+
const afterUndo = reducer(state, { type: "undo" });
|
|
83
|
+
|
|
84
|
+
expect(afterUndo.current.title).toBe("Step1");
|
|
85
|
+
expect(afterUndo.future).toHaveLength(1);
|
|
86
|
+
expect(afterUndo.future[0].title).toBe("Step2");
|
|
87
|
+
expect(afterUndo.past).toHaveLength(1); // original current stored
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("redo: reapplies next state and moves current back to past", () => {
|
|
91
|
+
let state = initState();
|
|
92
|
+
state = reducer(state, { type: "formChange", value: { title: "Step1" } });
|
|
93
|
+
state = reducer(state, { type: "formChange", value: { title: "Step2" } });
|
|
94
|
+
state = reducer(state, { type: "undo" });
|
|
95
|
+
|
|
96
|
+
const afterRedo = reducer(state, { type: "redo" });
|
|
97
|
+
|
|
98
|
+
expect(afterRedo.current.title).toBe("Step2");
|
|
99
|
+
expect(afterRedo.past).toHaveLength(2); // original + step1
|
|
100
|
+
expect(afterRedo.future).toHaveLength(0);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("reset: restores original form and adds current to past", () => {
|
|
104
|
+
// Ensure current has an _id so reset doesn't try to derive name/path from undefined action value
|
|
105
|
+
const state0 = initState({ ...baseForm(), _id: "123" } as any);
|
|
106
|
+
const state1 = reducer(state0, { type: "formChange", value: { title: "Changed" } });
|
|
107
|
+
|
|
108
|
+
const reset = reducer(state1, { type: "reset" });
|
|
109
|
+
|
|
110
|
+
expect(reset.current).toEqual(state0.original);
|
|
111
|
+
expect(reset.past).toHaveLength(2); // initial current, then changed
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("replaceForm: replaces current and original, clears history", () => {
|
|
115
|
+
let state = initState();
|
|
116
|
+
state = reducer(state, { type: "formChange", value: { title: "Changed" } });
|
|
117
|
+
|
|
118
|
+
const newForm: Partial<FormType> = { title: "Another", name: "another", path: "another", components: [] };
|
|
119
|
+
const replaced = reducer(state, { type: "replaceForm", value: newForm });
|
|
120
|
+
|
|
121
|
+
expect(replaced.current).toEqual(newForm);
|
|
122
|
+
expect(replaced.original).toEqual(newForm);
|
|
123
|
+
expect(replaced.past).toEqual([]);
|
|
124
|
+
expect(replaced.future).toEqual([]);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it("undo on empty past and redo on empty future: no changes", () => {
|
|
128
|
+
const state = initState();
|
|
129
|
+
|
|
130
|
+
const afterUndo = reducer(state, { type: "undo" });
|
|
131
|
+
expect(afterUndo).toBe(state);
|
|
132
|
+
|
|
133
|
+
const afterRedo = reducer(state, { type: "redo" });
|
|
134
|
+
expect(afterRedo).toBe(state);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Meta, StoryObj } from "@storybook/react";
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
2
|
|
|
3
3
|
import { FormEdit } from "./all";
|
|
4
4
|
import { defaultDisplayChoices } from "./FormParameters";
|
|
@@ -92,7 +92,14 @@ export default {
|
|
|
92
92
|
options: ["choicesjs", "react"]
|
|
93
93
|
}
|
|
94
94
|
},
|
|
95
|
-
parameters: {}
|
|
95
|
+
parameters: {},
|
|
96
|
+
args: {
|
|
97
|
+
options: {
|
|
98
|
+
template: "tailwind",
|
|
99
|
+
iconset: "lu",
|
|
100
|
+
noDefaultSubmitButton: true
|
|
101
|
+
}
|
|
102
|
+
}
|
|
96
103
|
} satisfies Meta<typeof FormEdit>;
|
|
97
104
|
|
|
98
105
|
type Story = StoryObj<typeof FormEdit>;
|
|
@@ -106,7 +113,6 @@ export const EditWebForm: Story = {
|
|
|
106
113
|
],
|
|
107
114
|
displayChoices: defaultDisplayChoices,
|
|
108
115
|
enableTags: true,
|
|
109
|
-
options: { template: "tailwind", iconset: "bx" },
|
|
110
116
|
form: {
|
|
111
117
|
type: "form",
|
|
112
118
|
tags: [],
|
|
@@ -307,8 +313,7 @@ export const WithoutTypeChoices: Story = {
|
|
|
307
313
|
machineName: "tcspjwhsevrzpcd:textField"
|
|
308
314
|
} as any,
|
|
309
315
|
displayChoices: defaultDisplayChoices,
|
|
310
|
-
enableTags: true
|
|
311
|
-
options: { template: "tailwind", iconset: "bx" }
|
|
316
|
+
enableTags: true
|
|
312
317
|
}
|
|
313
318
|
};
|
|
314
319
|
|
|
@@ -412,7 +417,6 @@ export const WithoutTags: Story = {
|
|
|
412
417
|
machineName: "tcspjwhsevrzpcd:textField"
|
|
413
418
|
} as any,
|
|
414
419
|
displayChoices: defaultDisplayChoices,
|
|
415
|
-
enableTags: false
|
|
416
|
-
options: { template: "tailwind", iconset: "bx" }
|
|
420
|
+
enableTags: false
|
|
417
421
|
}
|
|
418
422
|
};
|