@tsed/react-formio 2.3.6 → 3.0.0-alpha.10
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/atoms/icon/Icon.d.ts +6 -0
- package/dist/atoms/icon/Icon.js +12 -0
- package/dist/atoms/icon/Icon.js.map +1 -0
- package/dist/chunks/_commonjsHelpers.js +7 -0
- package/dist/chunks/_commonjsHelpers.js.map +1 -0
- package/dist/chunks/index.js +43 -0
- package/dist/chunks/index.js.map +1 -0
- package/dist/chunks/index.module.js +56 -0
- package/dist/chunks/index.module.js.map +1 -0
- package/dist/chunks/react-select-animated.esm.js +3513 -0
- package/dist/chunks/react-select-animated.esm.js.map +1 -0
- package/dist/hooks/useTooltip.d.ts +2 -3
- package/dist/hooks/useTooltip.js +12 -0
- package/dist/hooks/useTooltip.js.map +1 -0
- package/dist/index.d.ts +7 -13
- package/dist/index.js +14 -7653
- package/dist/index.js.map +1 -1
- package/dist/interfaces/ActionType.d.ts +23 -0
- package/dist/interfaces/ActionType.js +2 -0
- package/dist/interfaces/ActionType.js.map +1 -0
- package/dist/interfaces/ColumnIdentifier.d.ts +14 -14
- package/dist/interfaces/ColumnIdentifier.js +2 -0
- package/dist/interfaces/ColumnIdentifier.js.map +1 -0
- package/dist/interfaces/ComponentType.d.ts +2 -0
- package/dist/interfaces/ComponentType.js +2 -0
- package/dist/interfaces/ComponentType.js.map +1 -0
- package/dist/interfaces/FormOptions.d.ts +13 -10
- package/dist/interfaces/FormOptions.js +2 -0
- package/dist/interfaces/FormOptions.js.map +1 -0
- package/dist/interfaces/{FormSchema.d.ts → FormType.d.ts} +12 -12
- package/dist/interfaces/FormType.js +2 -0
- package/dist/interfaces/FormType.js.map +1 -0
- package/dist/interfaces/Operation.d.ts +28 -29
- package/dist/interfaces/Operation.js +2 -0
- package/dist/interfaces/Operation.js.map +1 -0
- package/dist/interfaces/QueryOptions.d.ts +23 -23
- package/dist/interfaces/QueryOptions.js +2 -0
- package/dist/interfaces/QueryOptions.js.map +1 -0
- package/dist/interfaces/{RoleSchema.d.ts → RoleType.d.ts} +6 -6
- package/dist/interfaces/RoleType.js +2 -0
- package/dist/interfaces/RoleType.js.map +1 -0
- package/dist/interfaces/SubmissionType.d.ts +29 -0
- package/dist/interfaces/SubmissionType.js +2 -0
- package/dist/interfaces/SubmissionType.js.map +1 -0
- package/dist/interfaces/index.d.ts +9 -8
- package/dist/interfaces/index.js +2 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/molecules/alert/Alert.d.ts +6 -0
- package/dist/molecules/alert/Alert.js +27 -0
- package/dist/molecules/alert/Alert.js.map +1 -0
- package/dist/molecules/button/Button.d.ts +8 -0
- package/dist/molecules/button/Button.js +52 -0
- package/dist/molecules/button/Button.js.map +1 -0
- package/dist/{components/card/card.component.d.ts → molecules/card/Card.d.ts} +6 -7
- package/dist/molecules/card/Card.js +12 -0
- package/dist/molecules/card/Card.js.map +1 -0
- package/dist/molecules/forms/form-control/FormControl.d.ts +17 -0
- package/dist/molecules/forms/form-control/FormControl.js +51 -0
- package/dist/molecules/forms/form-control/FormControl.js.map +1 -0
- package/dist/molecules/forms/input-tags/InputTags.d.ts +2 -0
- 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 +25 -0
- package/dist/molecules/forms/input-tags/InputTags.js.map +1 -0
- 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 +1937 -0
- package/dist/molecules/forms/input-tags/components/ReactTags.js.map +1 -0
- package/dist/molecules/forms/input-text/InputText.d.ts +2 -0
- 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 +54 -0
- package/dist/molecules/forms/input-text/InputText.js.map +1 -0
- package/dist/molecules/forms/select/Select.d.ts +2 -0
- package/dist/molecules/forms/select/Select.interface.d.ts +38 -0
- 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 +16 -0
- package/dist/molecules/forms/select/Select.js.map +1 -0
- package/dist/molecules/forms/select/all.d.ts +2 -0
- package/dist/molecules/forms/select/all.js +9 -0
- package/dist/molecules/forms/select/all.js.map +1 -0
- package/dist/molecules/forms/select/components/ChoicesSelect.d.ts +7 -0
- package/dist/molecules/forms/select/components/ChoicesSelect.js +115 -0
- package/dist/molecules/forms/select/components/ChoicesSelect.js.map +1 -0
- package/dist/molecules/forms/select/components/HtmlSelect.d.ts +2 -0
- package/dist/molecules/forms/select/components/HtmlSelect.js +35 -0
- package/dist/molecules/forms/select/components/HtmlSelect.js.map +1 -0
- package/dist/molecules/forms/select/components/ReactSelect.d.ts +2 -0
- package/dist/molecules/forms/select/components/ReactSelect.js +46 -0
- package/dist/molecules/forms/select/components/ReactSelect.js.map +1 -0
- package/dist/molecules/forms/select/components/choices.template.d.ts +7 -0
- package/dist/molecules/forms/select/components/choices.template.js +9654 -0
- package/dist/molecules/forms/select/components/choices.template.js.map +1 -0
- package/dist/molecules/forms/select/hooks/useOptions.d.ts +9 -0
- package/dist/molecules/forms/select/hooks/useOptions.js +35 -0
- package/dist/molecules/forms/select/hooks/useOptions.js.map +1 -0
- package/dist/molecules/loader/Loader.d.ts +8 -0
- package/dist/molecules/loader/Loader.js +19 -0
- package/dist/molecules/loader/Loader.js.map +1 -0
- package/dist/{components/modal/modal.component.d.ts → molecules/modal/Modal.d.ts} +15 -15
- package/dist/molecules/modal/Modal.js +62 -0
- package/dist/molecules/modal/Modal.js.map +1 -0
- package/dist/molecules/pagination/Pagination.d.ts +18 -0
- package/dist/molecules/pagination/Pagination.js +77 -0
- package/dist/molecules/pagination/Pagination.js.map +1 -0
- package/dist/molecules/pagination/PaginationButton.d.ts +7 -0
- package/dist/molecules/pagination/PaginationButton.js +21 -0
- package/dist/molecules/pagination/PaginationButton.js.map +1 -0
- package/dist/molecules/pagination/all.d.ts +2 -0
- package/dist/molecules/pagination/all.js +12 -0
- package/dist/molecules/pagination/all.js.map +1 -0
- package/dist/{components/table → molecules/pagination}/utils/getPageNumbers.d.ts +3 -3
- package/dist/molecules/pagination/utils/getPageNumbers.js +25 -0
- package/dist/molecules/pagination/utils/getPageNumbers.js.map +1 -0
- package/dist/molecules/table/Table.d.ts +9 -0
- package/dist/molecules/table/Table.js +58 -0
- package/dist/molecules/table/Table.js.map +1 -0
- 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 -0
- package/dist/molecules/table/components/DefaultArrowSort.js +22 -0
- package/dist/molecules/table/components/DefaultArrowSort.js.map +1 -0
- package/dist/molecules/table/components/DefaultCell.d.ts +5 -0
- package/dist/molecules/table/components/DefaultCell.js +13 -0
- package/dist/molecules/table/components/DefaultCell.js.map +1 -0
- 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 +6 -0
- package/dist/molecules/table/components/DefaultCellHeader.js +30 -0
- package/dist/molecules/table/components/DefaultCellHeader.js.map +1 -0
- package/dist/molecules/table/components/DefaultCellOperations.d.ts +10 -0
- package/dist/molecules/table/components/DefaultCellOperations.js +24 -0
- package/dist/molecules/table/components/DefaultCellOperations.js.map +1 -0
- 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 +11 -0
- package/dist/molecules/table/components/DefaultOperationButton.js +30 -0
- package/dist/molecules/table/components/DefaultOperationButton.js.map +1 -0
- 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 +42 -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 +35 -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 +15 -0
- package/dist/molecules/table/hooks/useTable.js +34 -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 +3 -0
- package/dist/molecules/table/utils/mapFormToColumns.js +39 -0
- package/dist/molecules/table/utils/mapFormToColumns.js.map +1 -0
- package/dist/{components/tabs/tabs.component.d.ts → molecules/tabs/Tabs.d.ts} +19 -19
- package/dist/molecules/tabs/Tabs.js +72 -0
- package/dist/molecules/tabs/Tabs.js.map +1 -0
- package/dist/organisms/form/Form.d.ts +22 -0
- package/dist/organisms/form/Form.js +15 -0
- package/dist/organisms/form/Form.js.map +1 -0
- package/dist/organisms/form/access/FormAccess.d.ts +9 -0
- package/dist/organisms/form/access/FormAccess.js +94 -0
- package/dist/organisms/form/access/FormAccess.js.map +1 -0
- package/dist/organisms/form/access/FormAccess.schema.d.ts +4 -0
- package/dist/organisms/form/access/FormAccess.schema.js +164 -0
- package/dist/organisms/form/access/FormAccess.schema.js.map +1 -0
- package/dist/organisms/form/access/FormAccess.utils.d.ts +23 -0
- package/dist/organisms/form/access/FormAccess.utils.js +68 -0
- package/dist/organisms/form/access/FormAccess.utils.js.map +1 -0
- package/dist/organisms/form/action/FormAction.d.ts +9 -0
- package/dist/organisms/form/action/FormAction.js +32 -0
- package/dist/organisms/form/action/FormAction.js.map +1 -0
- package/dist/organisms/form/builder/FormBuilder.d.ts +7 -0
- package/dist/organisms/form/builder/FormBuilder.js +17 -0
- package/dist/organisms/form/builder/FormBuilder.js.map +1 -0
- package/dist/organisms/form/builder/FormEdit.d.ts +8 -0
- package/dist/organisms/form/builder/FormEdit.js +70 -0
- package/dist/organisms/form/builder/FormEdit.js.map +1 -0
- package/dist/organisms/form/builder/FormEdit.reducer.d.ts +10 -0
- package/dist/organisms/form/builder/FormEdit.reducer.js +65 -0
- package/dist/organisms/form/builder/FormEdit.reducer.js.map +1 -0
- package/dist/organisms/form/builder/FormEditCtas.d.ts +15 -0
- package/dist/organisms/form/builder/FormEditCtas.js +52 -0
- package/dist/organisms/form/builder/FormEditCtas.js.map +1 -0
- package/dist/organisms/form/builder/FormParameters.d.ts +24 -0
- package/dist/organisms/form/builder/FormParameters.js +84 -0
- package/dist/organisms/form/builder/FormParameters.js.map +1 -0
- package/dist/organisms/form/builder/all.d.ts +6 -0
- package/dist/organisms/form/builder/all.js +26 -0
- package/dist/organisms/form/builder/all.js.map +1 -0
- package/dist/organisms/form/builder/useFormBuilder.d.ts +28 -0
- package/dist/organisms/form/builder/useFormBuilder.js +71 -0
- package/dist/organisms/form/builder/useFormBuilder.js.map +1 -0
- package/dist/{components/form-edit/useFormEdit.hook.d.ts → organisms/form/builder/useFormEdit.d.ts} +29 -29
- package/dist/organisms/form/builder/useFormEdit.js +36 -0
- package/dist/organisms/form/builder/useFormEdit.js.map +1 -0
- package/dist/{components/form-settings/formSettings.component.d.ts → organisms/form/settings/FormSettings.d.ts} +7 -8
- package/dist/organisms/form/settings/FormSettings.js +38 -0
- package/dist/organisms/form/settings/FormSettings.js.map +1 -0
- package/dist/organisms/form/settings/FormSettings.schema.d.ts +2 -0
- package/dist/organisms/form/settings/FormSettings.schema.js +60 -0
- package/dist/organisms/form/settings/FormSettings.schema.js.map +1 -0
- package/dist/organisms/form/settings/FormSettings.utils.d.ts +8 -0
- package/dist/organisms/form/settings/FormSettings.utils.js +23 -0
- package/dist/organisms/form/settings/FormSettings.utils.js.map +1 -0
- package/dist/organisms/form/types.d.ts +15 -0
- package/dist/organisms/form/types.js +2 -0
- package/dist/organisms/form/types.js.map +1 -0
- package/dist/organisms/form/useForm.d.ts +65 -0
- package/dist/organisms/form/useForm.js +776 -0
- package/dist/organisms/form/useForm.js.map +1 -0
- package/dist/{components/modal/removeModal.component.d.ts → organisms/modal/RemoveModal.d.ts} +9 -9
- package/dist/organisms/modal/RemoveModal.js +71 -0
- package/dist/organisms/modal/RemoveModal.js.map +1 -0
- package/dist/organisms/table/actions/ActionsTable.d.ts +10 -0
- package/dist/organisms/table/actions/ActionsTable.js +46 -0
- package/dist/organisms/table/actions/ActionsTable.js.map +1 -0
- package/dist/organisms/table/forms/FormsTable.d.ts +9 -0
- package/dist/organisms/table/forms/FormsTable.js +57 -0
- package/dist/organisms/table/forms/FormsTable.js.map +1 -0
- 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 +6 -0
- package/dist/organisms/table/submissions/SubmissionsTable.js +11 -0
- package/dist/organisms/table/submissions/SubmissionsTable.js.map +1 -0
- package/dist/react-app-env.d.js +2 -0
- package/dist/react-app-env.d.js.map +1 -0
- package/dist/react-table.d.js +2 -0
- package/dist/react-table.d.js.map +1 -0
- package/dist/registries/components.d.ts +3 -0
- package/dist/registries/components.js +19 -0
- package/dist/registries/components.js.map +1 -0
- package/dist/typings.d.js +2 -0
- package/dist/typings.d.js.map +1 -0
- package/dist/utils/getEventValue.d.ts +1 -1
- package/dist/utils/getEventValue.js +8 -0
- package/dist/utils/getEventValue.js.map +1 -0
- package/dist/utils/iconClass.d.ts +1 -1
- package/dist/utils/iconClass.js +9 -0
- package/dist/utils/iconClass.js.map +1 -0
- package/dist/utils/mapPagination.d.ts +1 -1
- package/dist/utils/mapPagination.js +11 -0
- package/dist/utils/mapPagination.js.map +1 -0
- package/dist/utils/stopPropagationWrapper.d.ts +1 -1
- package/dist/utils/stopPropagationWrapper.js +7 -0
- package/dist/utils/stopPropagationWrapper.js.map +1 -0
- package/package.json +29 -18
- package/readme.md +33 -20
- package/src/atoms/icon/Icon.stories.tsx +124 -0
- package/src/atoms/icon/Icon.tsx +16 -0
- package/src/index.ts +1 -6
- package/src/interfaces/ActionType.ts +26 -0
- package/src/interfaces/ComponentType.ts +3 -0
- package/src/interfaces/FormOptions.ts +4 -1
- package/src/interfaces/{FormSchema.ts → FormType.ts} +3 -3
- package/src/interfaces/Operation.ts +2 -2
- package/src/interfaces/{RoleSchema.ts → RoleType.ts} +1 -1
- package/src/interfaces/SubmissionType.ts +20 -0
- package/src/interfaces/index.ts +5 -4
- package/src/molecules/__fixtures__/build.js +28 -0
- package/src/molecules/__fixtures__/form-firstname.fixture.json +256 -0
- package/src/molecules/__fixtures__/form-schema.json +350 -0
- package/src/molecules/__fixtures__/form-submissions.json +11942 -0
- package/src/molecules/__fixtures__/form-wizard.fixture.json +2042 -0
- package/src/molecules/__fixtures__/products.json +81539 -0
- package/src/molecules/__fixtures__/useValue.hook.ts +14 -0
- package/src/{components/alert/alert.component.spec.tsx → molecules/alert/Alert.spec.tsx} +12 -15
- package/src/molecules/alert/Alert.stories.tsx +39 -0
- package/src/{components/alert/alert.component.tsx → molecules/alert/Alert.tsx} +9 -8
- package/src/molecules/button/Button.stories.tsx +106 -0
- package/src/molecules/button/Button.tsx +54 -0
- package/src/{components/card/card.component.spec.tsx → molecules/card/Card.spec.tsx} +3 -3
- package/src/{components/card/card.stories.tsx → molecules/card/Card.stories.tsx} +9 -4
- package/src/{components/card/card.component.tsx → molecules/card/Card.tsx} +1 -2
- package/src/{components/form-control/formControl.component.spec.tsx → molecules/forms/form-control/FormControl.spec.tsx} +9 -9
- package/src/molecules/forms/form-control/FormControl.stories.tsx +58 -0
- package/src/molecules/forms/form-control/FormControl.tsx +86 -0
- package/src/molecules/forms/input-tags/InputTags.interface.ts +9 -0
- package/src/molecules/forms/input-tags/InputTags.tsx +30 -0
- 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/{components/input-text/inputText.component.spec.tsx → molecules/forms/input-text/InputText.spec.tsx} +8 -8
- package/src/molecules/forms/input-text/InputText.stories.tsx +179 -0
- package/src/molecules/forms/input-text/InputText.tsx +63 -0
- package/src/molecules/forms/select/Select.interface.ts +45 -0
- package/src/molecules/forms/select/Select.tsx +28 -0
- package/src/molecules/forms/select/all.ts +7 -0
- package/src/molecules/forms/select/components/ChoicesSelect.stories.tsx +332 -0
- package/src/molecules/forms/select/components/ChoicesSelect.tsx +159 -0
- package/src/molecules/forms/select/components/HtmlSelect.stories.tsx +305 -0
- package/src/molecules/forms/select/components/HtmlSelect.tsx +54 -0
- package/src/molecules/forms/select/components/ReactSelect.stories.tsx +287 -0
- package/src/molecules/forms/select/components/ReactSelect.tsx +60 -0
- package/src/molecules/forms/select/components/choices.template.tsx +38 -0
- package/src/molecules/forms/select/hooks/useOptions.spec.ts +154 -0
- package/src/molecules/forms/select/hooks/useOptions.ts +53 -0
- package/src/{components/loader/loader.component.spec.tsx → molecules/loader/Loader.spec.tsx} +4 -4
- package/src/molecules/loader/Loader.stories.tsx +43 -0
- package/src/{components/loader/loader.component.tsx → molecules/loader/Loader.tsx} +3 -11
- package/src/molecules/modal/Modal.spec.tsx +203 -0
- package/src/molecules/modal/Modal.stories.tsx +178 -0
- package/src/{components/modal/modal.component.tsx → molecules/modal/Modal.tsx} +1 -1
- package/src/{components/pagination/pagination.component.spec.tsx → molecules/pagination/Pagination.spec.tsx} +27 -22
- package/src/molecules/pagination/Pagination.stories.tsx +99 -0
- package/src/{components/pagination/pagination.component.tsx → molecules/pagination/Pagination.tsx} +34 -47
- package/src/molecules/pagination/PaginationButton.tsx +30 -0
- package/src/molecules/pagination/all.ts +3 -0
- package/src/molecules/table/Table.stories.tsx +272 -0
- package/src/molecules/table/Table.tsx +100 -0
- package/src/molecules/table/all.ts +16 -0
- package/src/molecules/table/components/DefaultArrowSort.tsx +26 -0
- package/src/molecules/table/components/DefaultCell.tsx +22 -0
- package/src/molecules/table/components/DefaultCellFooter.tsx +16 -0
- package/src/molecules/table/components/DefaultCellHeader.tsx +42 -0
- package/src/molecules/table/components/DefaultCellOperations.tsx +42 -0
- package/src/molecules/table/components/DefaultFilter.tsx +42 -0
- package/src/molecules/table/components/DefaultOperationButton.tsx +40 -0
- 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 +75 -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 +74 -0
- package/src/{components/tabs/tabs.component.spec.tsx → molecules/tabs/Tabs.spec.tsx} +6 -6
- package/src/molecules/tabs/Tabs.stories.tsx +141 -0
- package/src/{components/tabs/tabs.component.tsx → molecules/tabs/Tabs.tsx} +1 -1
- package/src/organisms/__fixtures__/WrapComponent.tsx +11 -0
- package/src/organisms/__fixtures__/form-actions.json +240 -0
- package/src/organisms/__fixtures__/form-firstname.fixture.json +256 -0
- package/src/organisms/__fixtures__/form-wizard.fixture.json +2042 -0
- package/src/organisms/__fixtures__/form.fixture.json +2067 -0
- package/src/organisms/__fixtures__/useEditForm.tsx +84 -0
- package/src/organisms/__fixtures__/utils.ts +74 -0
- package/src/{components/form/form.component.spec.tsx → organisms/form/Form.spec.tsx} +6 -7
- package/src/organisms/form/Form.stories.tsx +698 -0
- package/src/organisms/form/Form.tsx +29 -0
- package/src/{components/form-access/formAccess.schema.ts → organisms/form/access/FormAccess.schema.ts} +4 -6
- package/src/{components/form-access/formAccess.stories.tsx → organisms/form/access/FormAccess.stories.tsx} +8 -2
- package/src/{components/form-access/formAccess.component.tsx → organisms/form/access/FormAccess.tsx} +16 -18
- package/src/{components/form-access/formAccess.utils.spec.ts → organisms/form/access/FormAccess.utils.spec.ts} +13 -7
- package/src/{components/form-access/formAccess.utils.ts → organisms/form/access/FormAccess.utils.ts} +23 -20
- package/src/{components/form-action/formAction.stories.tsx → organisms/form/action/FormAction.stories.tsx} +11 -13
- package/src/{components/form-action/formAction.component.tsx → organisms/form/action/FormAction.tsx} +8 -8
- package/src/organisms/form/builder/FormBuilder.stories.tsx +97 -0
- package/src/organisms/form/builder/FormBuilder.tsx +28 -0
- package/src/{components/form-edit/formEdit.reducer.ts → organisms/form/builder/FormEdit.reducer.ts} +6 -6
- package/src/{components/form-edit/formEdit.stories.tsx → organisms/form/builder/FormEdit.stories.tsx} +88 -44
- package/src/organisms/form/builder/FormEdit.tsx +75 -0
- package/src/organisms/form/builder/FormEditCtas.tsx +97 -0
- package/src/{components/form-edit/formParameters.component.tsx → organisms/form/builder/FormParameters.tsx} +29 -29
- package/src/organisms/form/builder/all.ts +17 -0
- package/src/organisms/form/builder/useFormBuilder.ts +143 -0
- package/src/{components/form-edit/useFormEdit.hook.ts → organisms/form/builder/useFormEdit.ts} +8 -8
- package/src/{components/form-settings/formSettings.component.spec.tsx → organisms/form/settings/FormSettings.component.spec.tsx} +3 -4
- package/src/{components/form-settings/formSettings.schema.ts → organisms/form/settings/FormSettings.schema.ts} +2 -2
- package/src/{components/form-settings/formSettings.stories.tsx → organisms/form/settings/FormSettings.stories.tsx} +10 -10
- package/src/{components/form-settings/formSettings.component.tsx → organisms/form/settings/FormSettings.tsx} +8 -9
- package/src/{components/form-settings/formSettings.utils.spec.ts → organisms/form/settings/FormSettings.utils.spec.ts} +1 -1
- package/src/{components/form-settings/formSettings.utils.ts → organisms/form/settings/FormSettings.utils.ts} +4 -4
- package/src/organisms/form/types.ts +8 -0
- package/src/organisms/form/useForm.ts +223 -0
- package/src/organisms/modal/RemoveModal.stories.tsx +59 -0
- package/src/{components/modal/removeModal.component.tsx → organisms/modal/RemoveModal.tsx} +3 -3
- package/src/{components/actions-table/actionsTable.component.spec.tsx → organisms/table/actions/ActionsTable.spec.tsx} +14 -11
- package/src/{components/actions-table/actionsTable.stories.tsx → organisms/table/actions/ActionsTable.stories.tsx} +22 -24
- package/src/{components/actions-table/actionsTable.component.tsx → organisms/table/actions/ActionsTable.tsx} +14 -21
- package/src/{components/forms-table/formsTable.stories.tsx → organisms/table/forms/FormsTable.stories.tsx} +24 -28
- package/src/organisms/table/forms/FormsTable.tsx +66 -0
- package/src/organisms/table/forms/components/FormsCell.tsx +53 -0
- package/src/{components/submissions-table/submissionsTable.stories.tsx → organisms/table/submissions/SubmissionsTable.stories.tsx} +28 -31
- package/src/organisms/table/submissions/SubmissionsTable.tsx +13 -0
- package/src/registries/components.ts +23 -0
- package/src/utils/iconClass.ts +3 -1
- package/tsconfig.app.json +11 -0
- package/tsconfig.json +10 -5
- package/tsconfig.node.json +9 -4
- package/tsconfig.spec.json +14 -0
- package/vite.config.mts +69 -0
- package/vitest.config.mts +21 -0
- package/.eslintignore +0 -13
- package/.eslintrc.js +0 -7
- package/coverage.json +0 -6
- package/dist/components/actions-table/actionsTable.component.d.ts +0 -11
- package/dist/components/actions-table/actionsTable.component.spec.d.ts +0 -1
- package/dist/components/actions-table/actionsTable.stories.d.ts +0 -40
- package/dist/components/alert/alert.component.d.ts +0 -6
- package/dist/components/alert/alert.component.spec.d.ts +0 -1
- package/dist/components/alert/alert.stories.d.ts +0 -15
- package/dist/components/card/card.component.spec.d.ts +0 -1
- package/dist/components/card/card.stories.d.ts +0 -16
- package/dist/components/form/form.component.d.ts +0 -63
- package/dist/components/form/form.component.spec.d.ts +0 -1
- package/dist/components/form/form.stories.d.ts +0 -6445
- package/dist/components/form/useForm.hook.d.ts +0 -60
- package/dist/components/form-access/formAccess.component.d.ts +0 -9
- package/dist/components/form-access/formAccess.schema.d.ts +0 -5
- package/dist/components/form-access/formAccess.stories.d.ts +0 -21
- package/dist/components/form-access/formAccess.utils.d.ts +0 -24
- package/dist/components/form-access/formAccess.utils.spec.d.ts +0 -1
- package/dist/components/form-action/formAction.component.d.ts +0 -9
- package/dist/components/form-action/formAction.stories.d.ts +0 -409
- package/dist/components/form-builder/formBuilder.component.d.ts +0 -53
- package/dist/components/form-builder/formBuilder.stories.d.ts +0 -5989
- package/dist/components/form-control/formControl.component.d.ts +0 -14
- package/dist/components/form-control/formControl.component.spec.d.ts +0 -1
- package/dist/components/form-control/formControl.stories.d.ts +0 -58
- package/dist/components/form-edit/formCtas.component.d.ts +0 -28
- package/dist/components/form-edit/formEdit.component.d.ts +0 -19
- package/dist/components/form-edit/formEdit.reducer.d.ts +0 -10
- package/dist/components/form-edit/formEdit.stories.d.ts +0 -396
- package/dist/components/form-edit/formParameters.component.d.ts +0 -34
- package/dist/components/form-settings/formSettings.component.spec.d.ts +0 -1
- package/dist/components/form-settings/formSettings.schema.d.ts +0 -2
- package/dist/components/form-settings/formSettings.stories.d.ts +0 -58
- package/dist/components/form-settings/formSettings.utils.d.ts +0 -8
- package/dist/components/form-settings/formSettings.utils.spec.d.ts +0 -1
- package/dist/components/forms-table/components/formCell.component.d.ts +0 -7
- package/dist/components/forms-table/formsTable.component.d.ts +0 -11
- package/dist/components/forms-table/formsTable.stories.d.ts +0 -117
- package/dist/components/index.d.ts +0 -26
- package/dist/components/input-tags/inputTags.component.d.ts +0 -19
- package/dist/components/input-tags/inputTags.stories.d.ts +0 -76
- package/dist/components/input-text/inputText.component.d.ts +0 -28
- package/dist/components/input-text/inputText.component.spec.d.ts +0 -1
- package/dist/components/input-text/inputText.stories.d.ts +0 -101
- package/dist/components/loader/loader.component.d.ts +0 -17
- package/dist/components/loader/loader.component.spec.d.ts +0 -1
- package/dist/components/loader/loader.stories.d.ts +0 -15
- package/dist/components/modal/modal.component.spec.d.ts +0 -1
- package/dist/components/modal/modal.stories.d.ts +0 -44
- package/dist/components/pagination/pagination.component.d.ts +0 -18
- package/dist/components/pagination/pagination.component.spec.d.ts +0 -1
- package/dist/components/pagination/pagination.stories.d.ts +0 -16
- package/dist/components/react-component/reactComponent.component.d.ts +0 -90
- package/dist/components/select/select.component.d.ts +0 -14
- package/dist/components/select/select.component.spec.d.ts +0 -1
- package/dist/components/select/select.stories.d.ts +0 -164
- package/dist/components/submissions-table/submissionsTable.component.d.ts +0 -7
- package/dist/components/submissions-table/submissionsTable.stories.d.ts +0 -649
- package/dist/components/table/components/defaultArrowSort.component.d.ts +0 -2
- package/dist/components/table/components/defaultCell.component.d.ts +0 -2
- package/dist/components/table/components/defaultCellHeader.component.d.ts +0 -6
- package/dist/components/table/components/defaultCellOperations.component.d.ts +0 -13
- package/dist/components/table/components/defaultCells.component.d.ts +0 -5
- package/dist/components/table/components/defaultOperationButton.component.d.ts +0 -14
- package/dist/components/table/components/defaultRow.component.d.ts +0 -12
- package/dist/components/table/components/dragNDropContainer.d.ts +0 -4
- package/dist/components/table/filters/defaultColumnFilter.component.d.ts +0 -6
- package/dist/components/table/filters/defaultColumnFilter.component.spec.d.ts +0 -1
- package/dist/components/table/filters/selectColumnFilter.component.d.ts +0 -11
- package/dist/components/table/filters/selectColumnFilter.component.spec.d.ts +0 -1
- package/dist/components/table/filters/sliderColumnFilter.component.d.ts +0 -3
- package/dist/components/table/hooks/useCustomTable.hook.d.ts +0 -128
- package/dist/components/table/hooks/useDragnDropRow.hook.d.ts +0 -274
- package/dist/components/table/hooks/useOperations.hook.d.ts +0 -11
- package/dist/components/table/index.d.ts +0 -15
- package/dist/components/table/table.component.d.ts +0 -3
- package/dist/components/table/table.stories.d.ts +0 -71
- package/dist/components/table/utils/mapFormToColumns.d.ts +0 -3
- package/dist/components/table/utils/swapElements.d.ts +0 -1
- package/dist/components/table/utils/swapElements.spec.d.ts +0 -1
- package/dist/components/tabs/tabs.component.spec.d.ts +0 -1
- package/dist/components/tabs/tabs.component.stories.d.ts +0 -47
- package/dist/index.modern.js +0 -7437
- package/dist/index.modern.js.map +0 -1
- package/dist/interfaces/ActionSchema.d.ts +0 -23
- package/dist/interfaces/Submission.d.ts +0 -5
- package/dist/setupTests.d.ts +0 -1
- package/dist/utils/callLast.d.ts +0 -1
- package/jest.config.js +0 -6
- package/src/components/alert/alert.stories.tsx +0 -18
- package/src/components/form/form.component.tsx +0 -73
- package/src/components/form/form.stories.tsx +0 -253
- package/src/components/form/useForm.hook.ts +0 -216
- package/src/components/form-builder/formBuilder.component.tsx +0 -195
- package/src/components/form-builder/formBuilder.stories.tsx +0 -3667
- package/src/components/form-control/formControl.component.tsx +0 -58
- package/src/components/form-control/formControl.stories.tsx +0 -65
- package/src/components/form-edit/formCtas.component.tsx +0 -106
- package/src/components/form-edit/formEdit.component.tsx +0 -60
- package/src/components/forms-table/components/formCell.component.tsx +0 -48
- package/src/components/forms-table/formsTable.component.tsx +0 -42
- package/src/components/index.ts +0 -26
- package/src/components/input-tags/inputTags.component.tsx +0 -58
- package/src/components/input-tags/inputTags.stories.tsx +0 -97
- package/src/components/input-text/inputText.component.tsx +0 -85
- package/src/components/input-text/inputText.stories.tsx +0 -126
- package/src/components/loader/loader.stories.tsx +0 -18
- package/src/components/modal/modal.component.spec.tsx +0 -79
- package/src/components/modal/modal.stories.tsx +0 -192
- package/src/components/pagination/pagination.stories.tsx +0 -40
- package/src/components/react-component/reactComponent.component.tsx +0 -197
- package/src/components/select/select.component.spec.tsx +0 -85
- package/src/components/select/select.component.tsx +0 -88
- package/src/components/select/select.stories.tsx +0 -173
- package/src/components/submissions-table/submissionsTable.component.tsx +0 -16
- package/src/components/table/components/defaultArrowSort.component.tsx +0 -12
- package/src/components/table/components/defaultCell.component.tsx +0 -15
- package/src/components/table/components/defaultCellHeader.component.tsx +0 -19
- package/src/components/table/components/defaultCellOperations.component.tsx +0 -39
- package/src/components/table/components/defaultCells.component.tsx +0 -31
- package/src/components/table/components/defaultOperationButton.component.tsx +0 -53
- package/src/components/table/components/defaultRow.component.tsx +0 -51
- package/src/components/table/components/dragNDropContainer.tsx +0 -7
- package/src/components/table/filters/defaultColumnFilter.component.spec.tsx +0 -34
- package/src/components/table/filters/defaultColumnFilter.component.tsx +0 -39
- package/src/components/table/filters/selectColumnFilter.component.spec.tsx +0 -69
- package/src/components/table/filters/selectColumnFilter.component.tsx +0 -52
- package/src/components/table/filters/sliderColumnFilter.component.tsx +0 -31
- package/src/components/table/hooks/useCustomTable.hook.tsx +0 -272
- package/src/components/table/hooks/useDragnDropRow.hook.ts +0 -80
- package/src/components/table/hooks/useOperations.hook.tsx +0 -39
- package/src/components/table/index.ts +0 -15
- package/src/components/table/table.component.tsx +0 -100
- package/src/components/table/table.stories.tsx +0 -120
- package/src/components/table/utils/mapFormToColumns.tsx +0 -34
- package/src/components/table/utils/swapElements.spec.ts +0 -7
- package/src/components/table/utils/swapElements.ts +0 -7
- package/src/components/tabs/tabs.component.stories.tsx +0 -127
- package/src/interfaces/ActionSchema.ts +0 -26
- package/src/interfaces/Submission.ts +0 -5
- package/src/setupTests.tsx +0 -5
- package/src/utils/callLast.ts +0 -12
- /package/src/{components → molecules}/__fixtures__/form-actions.json +0 -0
- /package/src/{components → molecules}/__fixtures__/form.fixture.json +0 -0
- /package/src/{components/table → molecules/pagination}/utils/getPageNumbers.ts +0 -0
- /package/src/{components → organisms}/__fixtures__/form-schema.json +0 -0
- /package/src/{components → organisms}/__fixtures__/form-submissions.json +0 -0
- /package/src/{components/actions-table → organisms/table/actions}/__fixtures__/data.json +0 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
|
|
3
|
+
import { Modal, ModalProps, useModal } from "./Modal";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The modal component provides a solid foundation for creating dialogs, popovers, lightboxes, or whatever else.
|
|
7
|
+
*
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import {Modal} from "@tsed/react-formio/molecules/modal/Modal";
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export default {
|
|
13
|
+
title: "Modal",
|
|
14
|
+
component: Modal,
|
|
15
|
+
argTypes: {
|
|
16
|
+
onSubmit: {
|
|
17
|
+
title: {
|
|
18
|
+
control: {
|
|
19
|
+
type: "text"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
control: {
|
|
23
|
+
action: "onSubmit"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
parameters: {},
|
|
28
|
+
render(args) {
|
|
29
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
30
|
+
const modal = useModal();
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div>
|
|
34
|
+
<div>
|
|
35
|
+
<button className={"btn btn-primary"} onClick={modal.openModal}>
|
|
36
|
+
Open modal
|
|
37
|
+
</button>
|
|
38
|
+
</div>
|
|
39
|
+
<Modal {...args} {...modal}>
|
|
40
|
+
<div className={"p-5"} style={{ height: "900px" }}>
|
|
41
|
+
Hello body
|
|
42
|
+
</div>
|
|
43
|
+
</Modal>
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
},
|
|
47
|
+
tags: ["autodocs"]
|
|
48
|
+
} satisfies Meta<typeof Modal>;
|
|
49
|
+
|
|
50
|
+
type Story = StoryObj<typeof Modal>;
|
|
51
|
+
|
|
52
|
+
export const Sandbox: Story = {};
|
|
53
|
+
|
|
54
|
+
export const WithTitle: Story = {
|
|
55
|
+
render: (args: ModalProps) => {
|
|
56
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
57
|
+
const modal = useModal();
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<div>
|
|
61
|
+
<div>
|
|
62
|
+
<button className={"btn btn-primary"} onClick={modal.openModal}>
|
|
63
|
+
Open modal
|
|
64
|
+
</button>
|
|
65
|
+
</div>
|
|
66
|
+
<Modal {...args} {...modal}>
|
|
67
|
+
<div className={"p-5"} style={{ height: "900px" }}>
|
|
68
|
+
Hello body
|
|
69
|
+
</div>
|
|
70
|
+
</Modal>
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
},
|
|
74
|
+
args: {
|
|
75
|
+
title: "Modal title"
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const WithFooter = {
|
|
80
|
+
render: (args: ModalProps) => {
|
|
81
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
82
|
+
const modal = useModal();
|
|
83
|
+
|
|
84
|
+
function ModalFooter({ closeModal, onSubmit }: any) {
|
|
85
|
+
return (
|
|
86
|
+
<div className={"flex items-center justify-center bg-white p-2"}>
|
|
87
|
+
<button
|
|
88
|
+
data-testid='customSubmitModal'
|
|
89
|
+
className={"btn btn-primary mx-1"}
|
|
90
|
+
onClick={(e) => {
|
|
91
|
+
onSubmit(e);
|
|
92
|
+
closeModal();
|
|
93
|
+
}}
|
|
94
|
+
>
|
|
95
|
+
Save
|
|
96
|
+
</button>
|
|
97
|
+
|
|
98
|
+
<button data-testid='customCloseModal' className={"btn btn-danger mx-1"} onClick={closeModal}>
|
|
99
|
+
Close
|
|
100
|
+
</button>
|
|
101
|
+
</div>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<div>
|
|
107
|
+
<div>
|
|
108
|
+
<button className={"btn btn-primary"} onClick={modal.openModal}>
|
|
109
|
+
Open modal
|
|
110
|
+
</button>
|
|
111
|
+
</div>
|
|
112
|
+
<Modal {...args} {...modal} footer={ModalFooter}>
|
|
113
|
+
<div className={"px-5"} style={{ height: "900px" }}>
|
|
114
|
+
Hello body
|
|
115
|
+
<br />
|
|
116
|
+
Hello body
|
|
117
|
+
<br />
|
|
118
|
+
Hello body
|
|
119
|
+
<br />
|
|
120
|
+
Hello body
|
|
121
|
+
<br />
|
|
122
|
+
Hello body
|
|
123
|
+
<br />
|
|
124
|
+
Hello body
|
|
125
|
+
<br />
|
|
126
|
+
Hello body
|
|
127
|
+
<br />
|
|
128
|
+
Hello body
|
|
129
|
+
<br />
|
|
130
|
+
Hello body
|
|
131
|
+
<br />
|
|
132
|
+
Hello body
|
|
133
|
+
<br />
|
|
134
|
+
Hello body
|
|
135
|
+
<br />
|
|
136
|
+
Hello body
|
|
137
|
+
<br />
|
|
138
|
+
Hello body
|
|
139
|
+
<br />
|
|
140
|
+
Hello body
|
|
141
|
+
<br />
|
|
142
|
+
Hello body
|
|
143
|
+
<br />
|
|
144
|
+
Hello body
|
|
145
|
+
<br />
|
|
146
|
+
Hello body
|
|
147
|
+
<br />
|
|
148
|
+
Hello body
|
|
149
|
+
<br />
|
|
150
|
+
Hello body
|
|
151
|
+
<br />
|
|
152
|
+
Hello body
|
|
153
|
+
<br />
|
|
154
|
+
Hello body
|
|
155
|
+
<br />
|
|
156
|
+
Hello body
|
|
157
|
+
<br />
|
|
158
|
+
Hello body
|
|
159
|
+
<br />
|
|
160
|
+
Hello body
|
|
161
|
+
<br />
|
|
162
|
+
Hello body
|
|
163
|
+
<br />
|
|
164
|
+
Hello body
|
|
165
|
+
<br />
|
|
166
|
+
Hello body
|
|
167
|
+
<br />
|
|
168
|
+
Hello body
|
|
169
|
+
<br />
|
|
170
|
+
</div>
|
|
171
|
+
</Modal>
|
|
172
|
+
</div>
|
|
173
|
+
);
|
|
174
|
+
},
|
|
175
|
+
args: {
|
|
176
|
+
title: "Modal title"
|
|
177
|
+
}
|
|
178
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
2
2
|
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
3
3
|
import noop from "lodash";
|
|
4
|
-
import
|
|
4
|
+
import { PropsWithChildren, useEffect, useRef, useState } from "react";
|
|
5
5
|
|
|
6
6
|
export function useModal() {
|
|
7
7
|
const [show, setShowModal] = useState(false);
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { fireEvent, render, screen } from "@testing-library/react";
|
|
2
|
-
import React from "react";
|
|
3
2
|
|
|
4
|
-
import {
|
|
3
|
+
import { Pagination } from "./all";
|
|
4
|
+
|
|
5
|
+
const args: any = {
|
|
6
|
+
pageSizes: [10, 25, 50, 100],
|
|
7
|
+
pageCount: 50,
|
|
8
|
+
pageIndex: 1
|
|
9
|
+
};
|
|
5
10
|
|
|
6
11
|
describe("Pagination", () => {
|
|
7
12
|
it("should render the pagination component", () => {
|
|
8
|
-
render(<
|
|
13
|
+
render(<Pagination {...args} />);
|
|
9
14
|
|
|
10
15
|
const paginationBtn = screen.queryAllByTestId("pagination-button");
|
|
11
16
|
const allBtnBlocks = paginationBtn.map((bloc) => bloc.textContent);
|
|
@@ -17,9 +22,9 @@ describe("Pagination", () => {
|
|
|
17
22
|
expect(allBtnBlocks[allBtnBlocks.length - 1]).toBe("Next");
|
|
18
23
|
});
|
|
19
24
|
|
|
20
|
-
it("should call
|
|
21
|
-
const previousPageSpy =
|
|
22
|
-
render(<
|
|
25
|
+
it("should call onClickPreviousPage() callback", () => {
|
|
26
|
+
const previousPageSpy = vi.fn();
|
|
27
|
+
render(<Pagination {...args} onClickPreviousPage={previousPageSpy} canPreviousPage={true} />);
|
|
23
28
|
const paginationBtn = screen.queryAllByTestId("pagination-button");
|
|
24
29
|
const btnPreviousPage = paginationBtn.find((btn) => btn.textContent === "Previous");
|
|
25
30
|
|
|
@@ -28,20 +33,20 @@ describe("Pagination", () => {
|
|
|
28
33
|
expect(previousPageSpy).toHaveBeenCalledTimes(1);
|
|
29
34
|
});
|
|
30
35
|
|
|
31
|
-
it("should call
|
|
32
|
-
const nextPageSpy =
|
|
33
|
-
render(<
|
|
36
|
+
it("should call onClickNextPage() callback", () => {
|
|
37
|
+
const nextPageSpy = vi.fn();
|
|
38
|
+
render(<Pagination {...args} onClickNextPage={nextPageSpy} canNextPage={true} />);
|
|
34
39
|
|
|
35
40
|
fireEvent.click(screen.getByText(/Next/i));
|
|
36
41
|
|
|
37
42
|
expect(nextPageSpy).toHaveBeenCalledTimes(1);
|
|
38
43
|
});
|
|
39
44
|
|
|
40
|
-
it("should call
|
|
41
|
-
const gotoPageSpy =
|
|
45
|
+
it("should call onPageIndexChange() callback when cliking on a button page", () => {
|
|
46
|
+
const gotoPageSpy = vi.fn();
|
|
42
47
|
let page: number;
|
|
43
48
|
|
|
44
|
-
render(<
|
|
49
|
+
render(<Pagination {...args} onPageIndexChange={gotoPageSpy} />);
|
|
45
50
|
|
|
46
51
|
const paginationBtn = screen.queryAllByTestId("pagination-button");
|
|
47
52
|
const buttonsPage = paginationBtn.filter((btn) => btn.textContent !== "Previous" && btn.textContent !== "Next");
|
|
@@ -57,8 +62,8 @@ describe("Pagination", () => {
|
|
|
57
62
|
});
|
|
58
63
|
|
|
59
64
|
it("should have Previous button disabled and not clickable", () => {
|
|
60
|
-
const previousPageSpy =
|
|
61
|
-
render(<
|
|
65
|
+
const previousPageSpy = vi.fn();
|
|
66
|
+
render(<Pagination canPreviousPage={false} onClickPreviousPage={previousPageSpy} {...args} />);
|
|
62
67
|
|
|
63
68
|
const previousButton = screen.getByText("Previous");
|
|
64
69
|
|
|
@@ -68,8 +73,8 @@ describe("Pagination", () => {
|
|
|
68
73
|
});
|
|
69
74
|
|
|
70
75
|
it("should have Previous button NOT disabled and clickable", () => {
|
|
71
|
-
const previousPageSpy =
|
|
72
|
-
render(<
|
|
76
|
+
const previousPageSpy = vi.fn();
|
|
77
|
+
render(<Pagination {...args} canPreviousPage={true} onClickPreviousPage={previousPageSpy} />);
|
|
73
78
|
|
|
74
79
|
const previousButton = screen.getByText("Previous");
|
|
75
80
|
|
|
@@ -79,8 +84,8 @@ describe("Pagination", () => {
|
|
|
79
84
|
});
|
|
80
85
|
|
|
81
86
|
it("should have Next button disabled and not clickable", () => {
|
|
82
|
-
const nextPageSpy =
|
|
83
|
-
render(<
|
|
87
|
+
const nextPageSpy = vi.fn();
|
|
88
|
+
render(<Pagination canNextPage={false} onClickNextPage={nextPageSpy} {...args} />);
|
|
84
89
|
|
|
85
90
|
const nextButton = screen.getByText("Next");
|
|
86
91
|
expect(nextButton).toHaveAttribute("disabled");
|
|
@@ -89,8 +94,8 @@ describe("Pagination", () => {
|
|
|
89
94
|
});
|
|
90
95
|
|
|
91
96
|
it("should have Next button NOT disabled and clickable", () => {
|
|
92
|
-
const nextPageSpy =
|
|
93
|
-
render(<
|
|
97
|
+
const nextPageSpy = vi.fn();
|
|
98
|
+
render(<Pagination canNextPage={true} onClickNextPage={nextPageSpy} {...args} />);
|
|
94
99
|
const nextButton = screen.getByText("Next");
|
|
95
100
|
expect(nextButton).not.toHaveAttribute("disabled");
|
|
96
101
|
fireEvent.click(nextButton);
|
|
@@ -100,7 +105,7 @@ describe("Pagination", () => {
|
|
|
100
105
|
it("should correctly render select component", () => {
|
|
101
106
|
const pageSizes = [10, 25, 50, 100, 200, 500];
|
|
102
107
|
|
|
103
|
-
render(<
|
|
108
|
+
render(<Pagination {...args} pageSizes={pageSizes} />);
|
|
104
109
|
const selectComp = screen.getByTestId("select_page");
|
|
105
110
|
const selectChilds = Array.prototype.map.call(selectComp, function (child) {
|
|
106
111
|
return +child.textContent;
|
|
@@ -113,7 +118,7 @@ describe("Pagination", () => {
|
|
|
113
118
|
it("should display total length", () => {
|
|
114
119
|
const pageSizes = [10, 25, 50, 100, 200, 500];
|
|
115
120
|
|
|
116
|
-
render(<
|
|
121
|
+
render(<Pagination {...args} pageSizes={pageSizes} rowCount={1000} />);
|
|
117
122
|
|
|
118
123
|
expect(screen.getByTestId("pagination-total-items")).toHaveTextContent("1,000 items");
|
|
119
124
|
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import "../forms/select/all";
|
|
2
|
+
|
|
3
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
|
|
6
|
+
import { Pagination } from "./all";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Pagination component.
|
|
10
|
+
*
|
|
11
|
+
* You can import this component and use it like:
|
|
12
|
+
*
|
|
13
|
+
* ```tsx
|
|
14
|
+
* import {Pagination} from "@tsed/react-formio/molecules/pagination/all"
|
|
15
|
+
* import {Pagination} from "@tsed/react-formio/molecules/form/select/Select/all"
|
|
16
|
+
*
|
|
17
|
+
* or
|
|
18
|
+
*
|
|
19
|
+
* import {Pagination} from "@tsed/react-formio/molecules/pagination/Pagination";
|
|
20
|
+
* import "@tsed/react-formio/molecules/pagination/PaginationButton";
|
|
21
|
+
*
|
|
22
|
+
* or
|
|
23
|
+
*
|
|
24
|
+
* import {Pagination} from "@tsed/react-formio/molecules/pagination/Pagination";
|
|
25
|
+
*
|
|
26
|
+
* registerComponent("PaginationButton", MyPaginationButton);
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* Pagination component support DI container and can be used with custom PaginationButton component.
|
|
30
|
+
*
|
|
31
|
+
* You can also override the Pagination component with your own implementation:
|
|
32
|
+
*
|
|
33
|
+
* ```tsx
|
|
34
|
+
* function MyPagination(props: PaginationProps) {
|
|
35
|
+
*
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* registerComponent("Pagination", MyPagination);
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export default {
|
|
42
|
+
title: "Pagination",
|
|
43
|
+
component: Pagination,
|
|
44
|
+
parameters: {},
|
|
45
|
+
argTypes: {
|
|
46
|
+
pageSizes: {
|
|
47
|
+
description: "Pagination steps list"
|
|
48
|
+
},
|
|
49
|
+
pageCount: {
|
|
50
|
+
description: "Total number of pages",
|
|
51
|
+
control: "number"
|
|
52
|
+
},
|
|
53
|
+
pageIndex: {
|
|
54
|
+
description: "Current page index",
|
|
55
|
+
control: "number"
|
|
56
|
+
},
|
|
57
|
+
onPageIndexChange: {
|
|
58
|
+
description: "Change page index event",
|
|
59
|
+
action: "onPageIndexChange"
|
|
60
|
+
},
|
|
61
|
+
onClickPreviousPage: {
|
|
62
|
+
description: "Click previous page event",
|
|
63
|
+
action: "onClickPreviousPage"
|
|
64
|
+
},
|
|
65
|
+
onClickNextPage: {
|
|
66
|
+
description: "Click next page event",
|
|
67
|
+
action: "onClickNextPage"
|
|
68
|
+
},
|
|
69
|
+
onPageSizeChange: {
|
|
70
|
+
description: "Change page size event",
|
|
71
|
+
action: "onPageSizeChange"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
render(args) {
|
|
75
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
76
|
+
const [currentPageIndex, setPageIndex] = useState(args.pageIndex);
|
|
77
|
+
|
|
78
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
args.onPageIndexChange && args.onPageIndexChange(currentPageIndex);
|
|
81
|
+
}, [currentPageIndex]);
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<div>
|
|
85
|
+
<Pagination {...args} pageIndex={currentPageIndex} onPageIndexChange={setPageIndex} />
|
|
86
|
+
</div>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
} satisfies Meta<typeof Pagination>;
|
|
90
|
+
|
|
91
|
+
type Story = StoryObj<typeof Pagination>;
|
|
92
|
+
|
|
93
|
+
export const Sandbox: Story = {
|
|
94
|
+
args: {
|
|
95
|
+
pageSizes: [10, 25, 50, 100],
|
|
96
|
+
pageCount: 50,
|
|
97
|
+
pageIndex: 1
|
|
98
|
+
}
|
|
99
|
+
};
|
package/src/{components/pagination/pagination.component.tsx → molecules/pagination/Pagination.tsx}
RENAMED
|
@@ -1,65 +1,44 @@
|
|
|
1
1
|
import classnames from "classnames";
|
|
2
|
-
import React, { PropsWithChildren } from "react";
|
|
3
2
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
props: PropsWithChildren<
|
|
9
|
-
{
|
|
10
|
-
component?: any;
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
className?: string;
|
|
13
|
-
active?: boolean;
|
|
14
|
-
} & Record<string, any>
|
|
15
|
-
>
|
|
16
|
-
) {
|
|
17
|
-
const { component: Component = "button", children, disabled, active, ...otherProps } = props;
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<Component
|
|
21
|
-
{...otherProps}
|
|
22
|
-
data-testid='pagination-button'
|
|
23
|
-
disabled={disabled}
|
|
24
|
-
className={classnames("page-link", disabled ? "disabled" : "", active ? "" : "", props.className)}
|
|
25
|
-
>
|
|
26
|
-
{children}
|
|
27
|
-
</Component>
|
|
28
|
-
);
|
|
29
|
-
}
|
|
3
|
+
import { getComponent, registerComponent } from "../../registries/components";
|
|
4
|
+
import type { Select as DefaultSelect } from "../forms/select/Select";
|
|
5
|
+
import type { PaginationButton as DefaultPaginationButton } from "./PaginationButton";
|
|
6
|
+
import { getPageNumbers, LEFT_PAGE, RIGHT_PAGE } from "./utils/getPageNumbers.js";
|
|
30
7
|
|
|
31
8
|
export interface PaginationProps {
|
|
32
9
|
className?: string;
|
|
33
10
|
pageSizes?: number[];
|
|
34
|
-
gotoPage: any;
|
|
35
11
|
canPreviousPage: boolean;
|
|
36
|
-
previousPage: any;
|
|
37
|
-
nextPage: any;
|
|
38
12
|
canNextPage: boolean;
|
|
39
13
|
pageCount: number;
|
|
40
14
|
pageIndex: number;
|
|
41
15
|
pageOptions?: number[];
|
|
42
16
|
pageSize: number;
|
|
43
|
-
|
|
44
|
-
|
|
17
|
+
rowCount?: number;
|
|
18
|
+
layout?: "html5" | "react" | "choicesjs";
|
|
45
19
|
i18n?: (f: string) => string;
|
|
20
|
+
|
|
21
|
+
onPageIndexChange: (pageIndex: number) => void;
|
|
22
|
+
onClickPreviousPage: () => void;
|
|
23
|
+
onClickNextPage: () => void;
|
|
24
|
+
onPageSizeChange: (pageSize: number) => void;
|
|
46
25
|
}
|
|
47
26
|
|
|
48
27
|
export function Pagination(props: PaginationProps) {
|
|
49
28
|
const {
|
|
50
29
|
className,
|
|
51
30
|
pageSizes = [10, 25, 50, 100],
|
|
52
|
-
|
|
31
|
+
onPageIndexChange,
|
|
53
32
|
canPreviousPage,
|
|
54
|
-
|
|
55
|
-
|
|
33
|
+
onClickPreviousPage,
|
|
34
|
+
onClickNextPage,
|
|
56
35
|
canNextPage,
|
|
57
36
|
pageCount,
|
|
58
37
|
pageIndex = 1,
|
|
59
38
|
pageOptions,
|
|
60
39
|
pageSize,
|
|
61
|
-
|
|
62
|
-
|
|
40
|
+
onPageSizeChange,
|
|
41
|
+
rowCount,
|
|
63
42
|
i18n = (f: string) => f
|
|
64
43
|
} = props;
|
|
65
44
|
|
|
@@ -68,13 +47,16 @@ export function Pagination(props: PaginationProps) {
|
|
|
68
47
|
// pageNeighbours,
|
|
69
48
|
totalPages: pageCount
|
|
70
49
|
});
|
|
71
|
-
|
|
50
|
+
|
|
51
|
+
const options: any[] = pageSizes.map((value) => ({ value, label: value }));
|
|
52
|
+
const Select = getComponent<typeof DefaultSelect>("Select");
|
|
53
|
+
const PaginationButton = getComponent<typeof DefaultPaginationButton>("PaginationButton");
|
|
72
54
|
|
|
73
55
|
return (
|
|
74
56
|
<nav aria-label='Page navigation' className={classnames("pagination-group -mb-3", className)}>
|
|
75
57
|
<ul className='pagination mb-3 mr-3'>
|
|
76
58
|
<li className={classnames("page-item", !canPreviousPage && "disabled")}>
|
|
77
|
-
<PaginationButton tabIndex={-1} disabled={!canPreviousPage} onClick={() =>
|
|
59
|
+
<PaginationButton tabIndex={-1} disabled={!canPreviousPage} onClick={() => onClickPreviousPage()}>
|
|
78
60
|
{i18n("Previous")}
|
|
79
61
|
</PaginationButton>
|
|
80
62
|
</li>
|
|
@@ -91,7 +73,7 @@ export function Pagination(props: PaginationProps) {
|
|
|
91
73
|
const active = page - 1 === pageIndex;
|
|
92
74
|
return (
|
|
93
75
|
<li className={classnames("page-item", active && "active")} key={page}>
|
|
94
|
-
<PaginationButton tabIndex={pageIndex} active={active} onClick={() =>
|
|
76
|
+
<PaginationButton tabIndex={pageIndex} active={active} onClick={() => onPageIndexChange(page - 1)}>
|
|
95
77
|
{page}
|
|
96
78
|
</PaginationButton>
|
|
97
79
|
</li>
|
|
@@ -99,19 +81,22 @@ export function Pagination(props: PaginationProps) {
|
|
|
99
81
|
})}
|
|
100
82
|
|
|
101
83
|
<li className={classnames("page-item", !canNextPage && "disabled")}>
|
|
102
|
-
<PaginationButton tabIndex={pageNumbers.length} disabled={!canNextPage} onClick={() =>
|
|
84
|
+
<PaginationButton tabIndex={pageNumbers.length} disabled={!canNextPage} onClick={() => onClickNextPage()}>
|
|
103
85
|
{i18n("Next")}
|
|
104
86
|
</PaginationButton>
|
|
105
87
|
</li>
|
|
106
88
|
</ul>
|
|
107
89
|
|
|
108
90
|
<li className='mb-3 mr-3 flex items-center'>
|
|
109
|
-
<Select
|
|
91
|
+
<Select<number>
|
|
110
92
|
name={"page"}
|
|
111
93
|
value={pageSize}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
94
|
+
options={options}
|
|
95
|
+
multiple={false}
|
|
96
|
+
layout={props.layout}
|
|
97
|
+
onChange={(_, value) => {
|
|
98
|
+
console.log("On page change", value);
|
|
99
|
+
onPageSizeChange(+value);
|
|
115
100
|
}}
|
|
116
101
|
/>
|
|
117
102
|
<span className={"ml-3"}>{i18n("items per page")}</span>
|
|
@@ -124,11 +109,13 @@ export function Pagination(props: PaginationProps) {
|
|
|
124
109
|
</strong>
|
|
125
110
|
</li>
|
|
126
111
|
)}
|
|
127
|
-
{
|
|
112
|
+
{rowCount !== undefined && (
|
|
128
113
|
<li className={"mb-3 flex items-center"} data-testid='pagination-total-items'>
|
|
129
|
-
{i18n("Total")}: <strong className='mx-1'>{new Intl.NumberFormat(undefined).format(
|
|
114
|
+
{i18n("Total")}: <strong className='mx-1'>{new Intl.NumberFormat(undefined).format(rowCount)}</strong> {i18n("items")}
|
|
130
115
|
</li>
|
|
131
116
|
)}
|
|
132
117
|
</nav>
|
|
133
118
|
);
|
|
134
119
|
}
|
|
120
|
+
|
|
121
|
+
registerComponent("Pagination", Pagination);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import classnames from "classnames";
|
|
2
|
+
import { PropsWithChildren } from "react";
|
|
3
|
+
|
|
4
|
+
import { registerComponent } from "../../registries/components";
|
|
5
|
+
|
|
6
|
+
export function PaginationButton(
|
|
7
|
+
props: PropsWithChildren<
|
|
8
|
+
{
|
|
9
|
+
component?: any;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
active?: boolean;
|
|
13
|
+
} & Record<string, any>
|
|
14
|
+
>
|
|
15
|
+
) {
|
|
16
|
+
const { component: Component = "button", children, disabled, active, ...otherProps } = props;
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Component
|
|
20
|
+
{...otherProps}
|
|
21
|
+
data-testid='pagination-button'
|
|
22
|
+
disabled={disabled}
|
|
23
|
+
className={classnames("page-link", disabled ? "disabled" : "", active ? "" : "", props.className)}
|
|
24
|
+
>
|
|
25
|
+
{children}
|
|
26
|
+
</Component>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
registerComponent("PaginationButton", PaginationButton);
|