@tsed/react-formio 2.3.1 → 3.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/index.js +45 -0
- package/dist/chunks/index.js.map +1 -0
- package/dist/components/actions-table/actionsTable.component.d.ts +10 -11
- package/dist/components/actions-table/actionsTable.component.js +53 -0
- package/dist/components/actions-table/actionsTable.component.js.map +1 -0
- package/dist/components/alert/alert.component.d.ts +5 -6
- package/dist/components/alert/alert.component.js +24 -0
- package/dist/components/alert/alert.component.js.map +1 -0
- package/dist/components/card/card.component.d.ts +6 -7
- package/dist/components/card/card.component.js +12 -0
- package/dist/components/card/card.component.js.map +1 -0
- package/dist/components/form/form.component.d.ts +62 -63
- package/dist/components/form/form.component.js +64 -0
- package/dist/components/form/form.component.js.map +1 -0
- package/dist/components/form/useForm.hook.d.ts +59 -60
- package/dist/components/form/useForm.hook.js +64 -0
- package/dist/components/form/useForm.hook.js.map +1 -0
- package/dist/components/form-access/formAccess.component.d.ts +9 -20
- package/dist/components/form-access/formAccess.component.js +95 -0
- package/dist/components/form-access/formAccess.component.js.map +1 -0
- package/dist/components/form-access/formAccess.schema.d.ts +5 -5
- package/dist/components/form-access/formAccess.schema.js +164 -0
- package/dist/components/form-access/formAccess.schema.js.map +1 -0
- package/dist/components/form-access/formAccess.utils.d.ts +24 -24
- package/dist/components/form-access/formAccess.utils.js +68 -0
- package/dist/components/form-access/formAccess.utils.js.map +1 -0
- package/dist/components/form-action/formAction.component.d.ts +9 -9
- package/dist/components/form-action/formAction.component.js +32 -0
- package/dist/components/form-action/formAction.component.js.map +1 -0
- package/dist/components/form-builder/formBuilder.component.d.ts +53 -53
- package/dist/components/form-builder/formBuilder.component.js +142 -0
- package/dist/components/form-builder/formBuilder.component.js.map +1 -0
- package/dist/components/form-control/formControl.component.d.ts +14 -22
- package/dist/components/form-control/formControl.component.js +26 -0
- package/dist/components/form-control/formControl.component.js.map +1 -0
- package/dist/components/form-edit/formCtas.component.d.ts +28 -28
- package/dist/components/form-edit/formCtas.component.js +70 -0
- package/dist/components/form-edit/formCtas.component.js.map +1 -0
- package/dist/components/form-edit/formEdit.component.d.ts +18 -19
- package/dist/components/form-edit/formEdit.component.js +57 -0
- package/dist/components/form-edit/formEdit.component.js.map +1 -0
- package/dist/components/form-edit/formEdit.reducer.d.ts +10 -10
- package/dist/components/form-edit/formEdit.reducer.js +65 -0
- package/dist/components/form-edit/formEdit.reducer.js.map +1 -0
- package/dist/components/form-edit/formParameters.component.d.ts +34 -34
- package/dist/components/form-edit/formParameters.component.js +92 -0
- package/dist/components/form-edit/formParameters.component.js.map +1 -0
- package/dist/components/form-edit/useFormEdit.hook.d.ts +29 -29
- package/dist/components/form-edit/useFormEdit.hook.js +36 -0
- package/dist/components/form-edit/useFormEdit.hook.js.map +1 -0
- package/dist/components/form-settings/formSettings.component.d.ts +7 -8
- package/dist/components/form-settings/formSettings.component.js +38 -0
- package/dist/components/form-settings/formSettings.component.js.map +1 -0
- package/dist/components/form-settings/formSettings.schema.d.ts +2 -2
- package/dist/components/form-settings/formSettings.schema.js +60 -0
- package/dist/components/form-settings/formSettings.schema.js.map +1 -0
- package/dist/components/form-settings/formSettings.utils.d.ts +8 -8
- package/dist/components/form-settings/formSettings.utils.js +23 -0
- package/dist/components/form-settings/formSettings.utils.js.map +1 -0
- package/dist/components/forms-table/components/formCell.component.d.ts +6 -7
- package/dist/components/forms-table/components/formCell.component.js +50 -0
- package/dist/components/forms-table/components/formCell.component.js.map +1 -0
- package/dist/components/forms-table/formsTable.component.d.ts +10 -11
- package/dist/components/forms-table/formsTable.component.js +29 -0
- package/dist/components/forms-table/formsTable.component.js.map +1 -0
- package/dist/components/index.d.ts +25 -26
- package/dist/components/index.js +86 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/input-tags/inputTags.component.d.ts +18 -19
- package/dist/components/input-tags/inputTags.component.js +37 -0
- package/dist/components/input-tags/inputTags.component.js.map +1 -0
- package/dist/components/input-text/inputText.component.d.ts +27 -28
- package/dist/components/input-text/inputText.component.js +70 -0
- package/dist/components/input-text/inputText.component.js.map +1 -0
- package/dist/components/loader/loader.component.d.ts +17 -17
- package/dist/components/loader/loader.component.js +26 -0
- package/dist/components/loader/loader.component.js.map +1 -0
- package/dist/components/modal/modal.component.d.ts +15 -15
- package/dist/components/modal/modal.component.js +62 -0
- package/dist/components/modal/modal.component.js.map +1 -0
- package/dist/components/modal/removeModal.component.d.ts +9 -9
- package/dist/components/modal/removeModal.component.js +71 -0
- package/dist/components/modal/removeModal.component.js.map +1 -0
- package/dist/components/pagination/pagination.component.d.ts +17 -18
- package/dist/components/pagination/pagination.component.js +87 -0
- package/dist/components/pagination/pagination.component.js.map +1 -0
- package/dist/components/select/select.component.d.ts +14 -27
- package/dist/components/select/select.component.js +60 -0
- package/dist/components/select/select.component.js.map +1 -0
- package/dist/components/submissions-table/submissionsTable.component.d.ts +6 -7
- package/dist/components/submissions-table/submissionsTable.component.js +11 -0
- package/dist/components/submissions-table/submissionsTable.component.js.map +1 -0
- package/dist/components/table/components/defaultArrowSort.component.d.ts +1 -2
- package/dist/components/table/components/defaultArrowSort.component.js +10 -0
- package/dist/components/table/components/defaultArrowSort.component.js.map +1 -0
- package/dist/components/table/components/defaultCell.component.d.ts +1 -2
- package/dist/components/table/components/defaultCell.component.js +11 -0
- package/dist/components/table/components/defaultCell.component.js.map +1 -0
- package/dist/components/table/components/defaultCellHeader.component.d.ts +5 -6
- package/dist/components/table/components/defaultCellHeader.component.js +14 -0
- package/dist/components/table/components/defaultCellHeader.component.js.map +1 -0
- package/dist/components/table/components/defaultCellOperations.component.d.ts +12 -2
- package/dist/components/table/components/defaultCellOperations.component.js +21 -0
- package/dist/components/table/components/defaultCellOperations.component.js.map +1 -0
- package/dist/components/table/components/defaultCells.component.d.ts +4 -5
- package/dist/components/table/components/defaultCells.component.js +23 -0
- package/dist/components/table/components/defaultCells.component.js.map +1 -0
- package/dist/components/table/components/defaultOperationButton.component.d.ts +15 -14
- package/dist/components/table/components/defaultOperationButton.component.js +45 -0
- package/dist/components/table/components/defaultOperationButton.component.js.map +1 -0
- package/dist/components/table/components/defaultRow.component.d.ts +12 -12
- package/dist/components/table/components/defaultRow.component.js +25 -0
- package/dist/components/table/components/defaultRow.component.js.map +1 -0
- package/dist/components/table/components/dragNDropContainer.d.ts +4 -4
- package/dist/components/table/components/dragNDropContainer.js +10 -0
- package/dist/components/table/components/dragNDropContainer.js.map +1 -0
- package/dist/components/table/filters/defaultColumnFilter.component.d.ts +5 -6
- package/dist/components/table/filters/defaultColumnFilter.component.js +32 -0
- package/dist/components/table/filters/defaultColumnFilter.component.js.map +1 -0
- package/dist/components/table/filters/selectColumnFilter.component.d.ts +10 -11
- package/dist/components/table/filters/selectColumnFilter.component.js +34 -0
- package/dist/components/table/filters/selectColumnFilter.component.js.map +1 -0
- package/dist/components/table/filters/sliderColumnFilter.component.d.ts +2 -3
- package/dist/components/table/filters/sliderColumnFilter.component.js +27 -0
- package/dist/components/table/filters/sliderColumnFilter.component.js.map +1 -0
- package/dist/components/table/hooks/useCustomTable.hook.d.ts +128 -128
- package/dist/components/table/hooks/useCustomTable.hook.js +130 -0
- package/dist/components/table/hooks/useCustomTable.hook.js.map +1 -0
- package/dist/components/table/hooks/useDragnDropRow.hook.d.ts +272 -274
- package/dist/components/table/hooks/useDragnDropRow.hook.js +40 -0
- package/dist/components/table/hooks/useDragnDropRow.hook.js.map +1 -0
- package/dist/components/table/hooks/useOperations.hook.d.ts +11 -11
- package/dist/components/table/hooks/useOperations.hook.js +25 -0
- package/dist/components/table/hooks/useOperations.hook.js.map +1 -0
- package/dist/components/table/index.d.ts +15 -15
- package/dist/components/table/index.js +35 -0
- package/dist/components/table/index.js.map +1 -0
- package/dist/components/table/table.component.d.ts +3 -3
- package/dist/components/table/table.component.js +81 -0
- package/dist/components/table/table.component.js.map +1 -0
- package/dist/components/table/utils/getPageNumbers.d.ts +3 -3
- package/dist/components/table/utils/getPageNumbers.js +25 -0
- package/dist/components/table/utils/getPageNumbers.js.map +1 -0
- package/dist/components/table/utils/mapFormToColumns.d.ts +3 -3
- package/dist/components/table/utils/mapFormToColumns.js +23 -0
- package/dist/components/table/utils/mapFormToColumns.js.map +1 -0
- package/dist/components/table/utils/swapElements.d.ts +1 -1
- package/dist/components/table/utils/swapElements.js +5 -0
- package/dist/components/table/utils/swapElements.js.map +1 -0
- package/dist/components/tabs/tabs.component.d.ts +19 -19
- package/dist/components/tabs/tabs.component.js +72 -0
- package/dist/components/tabs/tabs.component.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 +13 -13
- package/dist/index.js +107 -7803
- package/dist/index.js.map +1 -1
- package/dist/interfaces/ActionSchema.d.ts +23 -23
- package/dist/interfaces/ActionSchema.js +2 -0
- package/dist/interfaces/ActionSchema.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/FormOptions.d.ts +10 -10
- package/dist/interfaces/FormOptions.js +2 -0
- package/dist/interfaces/FormOptions.js.map +1 -0
- package/dist/interfaces/FormSchema.d.ts +12 -12
- package/dist/interfaces/FormSchema.js +2 -0
- package/dist/interfaces/FormSchema.js.map +1 -0
- package/dist/interfaces/Operation.d.ts +29 -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 +6 -6
- package/dist/interfaces/RoleSchema.js +2 -0
- package/dist/interfaces/RoleSchema.js.map +1 -0
- package/dist/interfaces/Submission.d.ts +5 -5
- package/dist/interfaces/Submission.js +2 -0
- package/dist/interfaces/Submission.js.map +1 -0
- package/dist/interfaces/index.d.ts +8 -8
- package/dist/interfaces/index.js +2 -0
- package/dist/interfaces/index.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/typings.d.js +2 -0
- package/dist/typings.d.js.map +1 -0
- package/dist/utils/callLast.d.ts +1 -1
- package/dist/utils/callLast.js +10 -0
- package/dist/utils/callLast.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 +28 -15
- package/src/components/__fixtures__/form-actions.json +240 -0
- package/src/components/actions-table/__fixtures__/data.json +12 -0
- package/src/components/actions-table/actionsTable.component.spec.tsx +47 -17
- package/src/components/actions-table/actionsTable.component.tsx +3 -2
- package/src/components/actions-table/actionsTable.stories.tsx +71 -289
- package/src/components/alert/alert.component.spec.tsx +0 -1
- package/src/components/alert/alert.component.tsx +0 -2
- package/src/components/alert/alert.stories.tsx +0 -2
- package/src/components/card/card.component.spec.tsx +0 -1
- package/src/components/card/card.component.tsx +1 -2
- package/src/components/card/card.stories.tsx +0 -2
- package/src/components/form/form.component.spec.tsx +1 -1
- package/src/components/form/form.component.tsx +0 -1
- package/src/components/form/form.stories.tsx +2 -3
- package/src/components/form-access/formAccess.component.tsx +2 -13
- package/src/components/form-access/formAccess.stories.tsx +55 -49
- package/src/components/form-action/formAction.component.tsx +2 -1
- package/src/components/form-action/formAction.stories.tsx +0 -2
- package/src/components/form-builder/formBuilder.component.tsx +4 -4
- package/src/components/form-builder/formBuilder.stories.tsx +0 -2
- package/src/components/form-control/formControl.component.spec.tsx +0 -1
- package/src/components/form-control/formControl.component.tsx +8 -15
- package/src/components/form-control/formControl.stories.tsx +0 -2
- package/src/components/form-edit/formCtas.component.tsx +1 -1
- package/src/components/form-edit/formEdit.component.tsx +0 -1
- package/src/components/form-edit/formEdit.reducer.ts +0 -1
- package/src/components/form-edit/formEdit.stories.tsx +0 -2
- package/src/components/form-edit/formParameters.component.tsx +1 -1
- package/src/components/form-settings/formSettings.component.spec.tsx +5 -6
- package/src/components/form-settings/formSettings.component.tsx +1 -1
- package/src/components/form-settings/formSettings.stories.tsx +0 -2
- package/src/components/forms-table/components/formCell.component.tsx +0 -1
- package/src/components/forms-table/formsTable.component.tsx +0 -2
- package/src/components/forms-table/formsTable.stories.tsx +0 -1
- package/src/components/index.ts +0 -1
- package/src/components/input-tags/inputTags.component.tsx +1 -1
- package/src/components/input-tags/inputTags.stories.tsx +1 -1
- package/src/components/input-text/inputText.component.spec.tsx +0 -1
- package/src/components/input-text/inputText.component.tsx +1 -1
- package/src/components/input-text/inputText.stories.tsx +1 -1
- package/src/components/loader/loader.component.spec.tsx +1 -1
- package/src/components/loader/loader.component.tsx +1 -1
- package/src/components/loader/loader.stories.tsx +0 -2
- package/src/components/modal/modal.component.spec.tsx +2 -5
- package/src/components/modal/modal.component.tsx +1 -1
- package/src/components/modal/modal.stories.tsx +0 -2
- package/src/components/modal/removeModal.component.tsx +1 -1
- package/src/components/pagination/pagination.component.spec.tsx +7 -10
- package/src/components/pagination/pagination.component.tsx +1 -1
- package/src/components/pagination/pagination.stories.tsx +1 -1
- package/src/components/select/select.component.spec.tsx +1 -2
- package/src/components/select/select.component.tsx +10 -23
- package/src/components/select/select.stories.tsx +1 -1
- package/src/components/submissions-table/submissionsTable.component.tsx +0 -2
- package/src/components/submissions-table/submissionsTable.stories.tsx +4 -4
- package/src/components/table/components/defaultArrowSort.component.tsx +0 -2
- package/src/components/table/components/defaultCell.component.tsx +0 -2
- package/src/components/table/components/defaultCellHeader.component.tsx +0 -1
- package/src/components/table/components/defaultCellOperations.component.tsx +16 -5
- package/src/components/table/components/defaultCells.component.tsx +0 -1
- package/src/components/table/components/defaultOperationButton.component.tsx +14 -4
- package/src/components/table/components/defaultRow.component.tsx +2 -1
- package/src/components/table/components/dragNDropContainer.tsx +1 -1
- package/src/components/table/filters/defaultColumnFilter.component.spec.tsx +2 -5
- package/src/components/table/filters/defaultColumnFilter.component.tsx +2 -1
- package/src/components/table/filters/selectColumnFilter.component.spec.tsx +3 -6
- package/src/components/table/filters/selectColumnFilter.component.tsx +0 -1
- package/src/components/table/filters/sliderColumnFilter.component.tsx +7 -10
- package/src/components/table/hooks/useCustomTable.hook.tsx +16 -20
- package/src/components/table/hooks/useOperations.hook.tsx +3 -3
- package/src/components/table/table.component.tsx +1 -1
- package/src/components/table/table.stories.tsx +8 -8
- package/src/components/table/utils/mapFormToColumns.tsx +0 -1
- package/src/components/tabs/tabs.component.spec.tsx +2 -2
- package/src/components/tabs/tabs.component.stories.tsx +1 -1
- package/src/components/tabs/tabs.component.tsx +1 -1
- package/src/react-table.d.ts +2 -0
- package/src/utils/iconClass.ts +3 -1
- package/tsconfig.app.json +11 -0
- package/tsconfig.json +8 -6
- 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.spec.d.ts +0 -1
- package/dist/components/actions-table/actionsTable.stories.d.ts +0 -85
- 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.spec.d.ts +0 -1
- package/dist/components/form/form.stories.d.ts +0 -6445
- package/dist/components/form-access/formAccess.stories.d.ts +0 -62
- package/dist/components/form-access/formAccess.utils.spec.d.ts +0 -1
- package/dist/components/form-action/formAction.stories.d.ts +0 -409
- package/dist/components/form-builder/formBuilder.stories.d.ts +0 -5989
- 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/formEdit.stories.d.ts +0 -396
- package/dist/components/form-settings/formSettings.component.spec.d.ts +0 -1
- package/dist/components/form-settings/formSettings.stories.d.ts +0 -58
- package/dist/components/form-settings/formSettings.utils.spec.d.ts +0 -1
- package/dist/components/forms-table/formsTable.stories.d.ts +0 -117
- package/dist/components/input-tags/inputTags.stories.d.ts +0 -76
- 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.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.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.spec.d.ts +0 -1
- package/dist/components/select/select.stories.d.ts +0 -164
- package/dist/components/submissions-table/submissionsTable.stories.d.ts +0 -649
- package/dist/components/table/filters/defaultColumnFilter.component.spec.d.ts +0 -1
- package/dist/components/table/filters/selectColumnFilter.component.spec.d.ts +0 -1
- package/dist/components/table/table.stories.d.ts +0 -71
- 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 -7453
- package/dist/index.modern.js.map +0 -1
- package/dist/package.json +0 -3
- package/dist/setupTests.d.ts +0 -1
- package/jest.config.js +0 -6
- package/src/components/react-component/reactComponent.component.tsx +0 -197
- package/src/setupTests.tsx +0 -5
- package/tsconfig.node.json +0 -8
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import classnames from "classnames";
|
|
2
|
-
import
|
|
3
|
-
import React from "react";
|
|
2
|
+
import type { PropsWithChildren, ReactNode } from "react";
|
|
4
3
|
|
|
5
|
-
export interface FormControlProps {
|
|
4
|
+
export interface FormControlProps<Data = any> {
|
|
6
5
|
name: string;
|
|
6
|
+
value?: Data;
|
|
7
7
|
required?: boolean;
|
|
8
8
|
label?: string;
|
|
9
9
|
className?: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
onChange?: (name: string, value: any) => void;
|
|
11
|
+
description?: string | ReactNode;
|
|
12
|
+
prefix?: ReactNode | string;
|
|
13
|
+
suffix?: ReactNode | string;
|
|
13
14
|
shadow?: boolean;
|
|
14
15
|
}
|
|
15
16
|
|
|
@@ -22,7 +23,7 @@ export function FormControl({
|
|
|
22
23
|
description,
|
|
23
24
|
label,
|
|
24
25
|
className
|
|
25
|
-
}:
|
|
26
|
+
}: PropsWithChildren<FormControlProps>) {
|
|
26
27
|
return (
|
|
27
28
|
<div data-testid={name && `form-group-${name}`} id={`form-group-${name || ""}`} className={classnames("form-group", className)}>
|
|
28
29
|
{label && (
|
|
@@ -55,11 +56,3 @@ export function FormControl({
|
|
|
55
56
|
</div>
|
|
56
57
|
);
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
-
FormControl.propTypes = {
|
|
60
|
-
label: PropTypes.string,
|
|
61
|
-
name: PropTypes.string.isRequired,
|
|
62
|
-
children: PropTypes.any,
|
|
63
|
-
required: PropTypes.bool,
|
|
64
|
-
description: PropTypes.any
|
|
65
|
-
};
|
|
@@ -71,7 +71,6 @@ export const reducer = (state: FormEditState, { type, value }: any): FormEditSta
|
|
|
71
71
|
return update(cloneDeep(state.original));
|
|
72
72
|
|
|
73
73
|
case "formChange":
|
|
74
|
-
// eslint-disable-next-line no-case-declarations
|
|
75
74
|
const newValue = { ...state.current, ...value };
|
|
76
75
|
|
|
77
76
|
if (hasChanged(state.current, newValue)) {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { fireEvent, render, screen } from "@testing-library/react";
|
|
2
|
-
import React from "react";
|
|
3
2
|
|
|
4
3
|
import { FormSettings } from "./formSettings.component";
|
|
5
4
|
import { Sandbox } from "./formSettings.stories";
|
|
6
5
|
|
|
7
6
|
describe("FormSettings", () => {
|
|
8
|
-
it("should render form settings",
|
|
9
|
-
const onSubmit =
|
|
7
|
+
it("should render form settings", () => {
|
|
8
|
+
const onSubmit = vi.fn();
|
|
10
9
|
|
|
11
10
|
// @ts-ignore
|
|
12
11
|
Sandbox.args.form.action = "https://test";
|
|
@@ -23,7 +22,7 @@ describe("FormSettings", () => {
|
|
|
23
22
|
|
|
24
23
|
const btn = screen.getByTestId("submit");
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
fireEvent.click(btn);
|
|
27
26
|
|
|
28
27
|
expect(btn).toHaveTextContent("Save settings");
|
|
29
28
|
expect(onSubmit).toHaveBeenCalledWith({
|
|
@@ -47,7 +46,7 @@ describe("FormSettings", () => {
|
|
|
47
46
|
type: "form"
|
|
48
47
|
});
|
|
49
48
|
});
|
|
50
|
-
it("should render form settings with i18n options",
|
|
49
|
+
it("should render form settings with i18n options", () => {
|
|
51
50
|
render(
|
|
52
51
|
<FormSettings
|
|
53
52
|
{...Sandbox.args}
|
|
@@ -59,7 +58,7 @@ describe("FormSettings", () => {
|
|
|
59
58
|
|
|
60
59
|
const btn = screen.getByTestId("submit");
|
|
61
60
|
|
|
62
|
-
|
|
61
|
+
fireEvent.click(btn);
|
|
63
62
|
|
|
64
63
|
expect(btn).toHaveTextContent("Save settings i18N");
|
|
65
64
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import isEqual from "lodash/isEqual";
|
|
2
2
|
import noop from "lodash/noop";
|
|
3
|
-
import
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
4
|
|
|
5
5
|
import { FormOptions, FormSchema } from "../../interfaces";
|
|
6
6
|
import { Form } from "../form/form.component";
|
package/src/components/index.ts
CHANGED
|
@@ -19,7 +19,6 @@ export * from "./loader/loader.component";
|
|
|
19
19
|
export * from "./modal/modal.component";
|
|
20
20
|
export * from "./modal/removeModal.component";
|
|
21
21
|
export * from "./pagination/pagination.component";
|
|
22
|
-
export * from "./react-component/reactComponent.component";
|
|
23
22
|
export * from "./select/select.component";
|
|
24
23
|
export * from "./submissions-table/submissionsTable.component";
|
|
25
24
|
export * from "./table";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Choices from "@formio/choices.js";
|
|
2
2
|
import uniq from "lodash/uniq";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
-
import
|
|
4
|
+
import { useEffect, useRef } from "react";
|
|
5
5
|
|
|
6
6
|
import { FormControl, FormControlProps } from "../form-control/formControl.component";
|
|
7
7
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import classnames from "classnames";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
|
-
import
|
|
3
|
+
import { useEffect, useMemo, useState } from "react";
|
|
4
4
|
|
|
5
5
|
import { callLast } from "../../utils/callLast";
|
|
6
6
|
import { getEventValue } from "../../utils/getEventValue";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { render, screen } from "@testing-library/react";
|
|
2
|
-
import React from "react";
|
|
3
2
|
|
|
4
3
|
import { Sandbox } from "./loader.stories";
|
|
4
|
+
|
|
5
5
|
describe("Loader", () => {
|
|
6
6
|
it("should render a component (when isActive = true)", () => {
|
|
7
7
|
render(<Sandbox isActive={true} />);
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import "@testing-library/jest-dom/extend-expect";
|
|
2
|
-
|
|
3
1
|
import { fireEvent, render, screen } from "@testing-library/react";
|
|
4
|
-
import React from "react";
|
|
5
2
|
|
|
6
3
|
import { WithFooter, WithTitle } from "./modal.stories";
|
|
7
4
|
|
|
8
5
|
describe("Modal", () => {
|
|
9
6
|
describe("WithTitle", () => {
|
|
10
7
|
it("should display the modal when we click on the button", async () => {
|
|
11
|
-
const onClose =
|
|
8
|
+
const onClose = vi.fn();
|
|
12
9
|
|
|
13
10
|
render(<WithTitle {...WithTitle.args} onClose={onClose} />);
|
|
14
11
|
|
|
@@ -60,7 +57,7 @@ describe("Modal", () => {
|
|
|
60
57
|
expect(screen.queryByTestId("modalFooter")).toBeFalsy();
|
|
61
58
|
});
|
|
62
59
|
it("should call the onSubmit listener", async () => {
|
|
63
|
-
const onSubmit =
|
|
60
|
+
const onSubmit = vi.fn();
|
|
64
61
|
|
|
65
62
|
render(<WithFooter {...WithFooter.args} onSubmit={onSubmit} />);
|
|
66
63
|
|
|
@@ -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,5 +1,5 @@
|
|
|
1
1
|
import classnames from "classnames";
|
|
2
|
-
import
|
|
2
|
+
import { PropsWithChildren, useState } from "react";
|
|
3
3
|
|
|
4
4
|
import { iconClass } from "../../utils/iconClass";
|
|
5
5
|
import { InputText } from "../input-text/inputText.component";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { fireEvent, render, screen } from "@testing-library/react";
|
|
2
|
-
import React from "react";
|
|
3
2
|
|
|
4
3
|
import { Sandbox } from "./pagination.stories";
|
|
5
4
|
|
|
@@ -18,7 +17,7 @@ describe("Pagination", () => {
|
|
|
18
17
|
});
|
|
19
18
|
|
|
20
19
|
it("should call previousPage() callback", () => {
|
|
21
|
-
const previousPageSpy =
|
|
20
|
+
const previousPageSpy = vi.fn();
|
|
22
21
|
render(<Sandbox previousPage={previousPageSpy} canPreviousPage={true} />);
|
|
23
22
|
const paginationBtn = screen.queryAllByTestId("pagination-button");
|
|
24
23
|
const btnPreviousPage = paginationBtn.find((btn) => btn.textContent === "Previous");
|
|
@@ -29,7 +28,7 @@ describe("Pagination", () => {
|
|
|
29
28
|
});
|
|
30
29
|
|
|
31
30
|
it("should call nextPage() callback", () => {
|
|
32
|
-
const nextPageSpy =
|
|
31
|
+
const nextPageSpy = vi.fn();
|
|
33
32
|
render(<Sandbox nextPage={nextPageSpy} canNextPage={true} />);
|
|
34
33
|
|
|
35
34
|
fireEvent.click(screen.getByText(/Next/i));
|
|
@@ -38,7 +37,7 @@ describe("Pagination", () => {
|
|
|
38
37
|
});
|
|
39
38
|
|
|
40
39
|
it("should call gotoPage() callback when cliking on a button page", () => {
|
|
41
|
-
const gotoPageSpy =
|
|
40
|
+
const gotoPageSpy = vi.fn();
|
|
42
41
|
let page: number;
|
|
43
42
|
|
|
44
43
|
render(<Sandbox {...Sandbox.args} gotoPage={gotoPageSpy} />);
|
|
@@ -50,16 +49,14 @@ describe("Pagination", () => {
|
|
|
50
49
|
if (btn.textContent !== "...") {
|
|
51
50
|
page = +btn.textContent!;
|
|
52
51
|
fireEvent.click(btn);
|
|
53
|
-
// eslint-disable-next-line jest/no-conditional-expect
|
|
54
52
|
expect(gotoPageSpy).toHaveBeenCalled();
|
|
55
|
-
// eslint-disable-next-line jest/no-conditional-expect
|
|
56
53
|
expect(gotoPageSpy).toHaveBeenCalledWith(page - 1);
|
|
57
54
|
}
|
|
58
55
|
});
|
|
59
56
|
});
|
|
60
57
|
|
|
61
58
|
it("should have Previous button disabled and not clickable", () => {
|
|
62
|
-
const previousPageSpy =
|
|
59
|
+
const previousPageSpy = vi.fn();
|
|
63
60
|
render(<Sandbox canPreviousPage={false} previousPage={previousPageSpy} {...Sandbox.args} />);
|
|
64
61
|
|
|
65
62
|
const previousButton = screen.getByText("Previous");
|
|
@@ -70,7 +67,7 @@ describe("Pagination", () => {
|
|
|
70
67
|
});
|
|
71
68
|
|
|
72
69
|
it("should have Previous button NOT disabled and clickable", () => {
|
|
73
|
-
const previousPageSpy =
|
|
70
|
+
const previousPageSpy = vi.fn();
|
|
74
71
|
render(<Sandbox {...Sandbox.args} canPreviousPage={true} previousPage={previousPageSpy} />);
|
|
75
72
|
|
|
76
73
|
const previousButton = screen.getByText("Previous");
|
|
@@ -81,7 +78,7 @@ describe("Pagination", () => {
|
|
|
81
78
|
});
|
|
82
79
|
|
|
83
80
|
it("should have Next button disabled and not clickable", () => {
|
|
84
|
-
const nextPageSpy =
|
|
81
|
+
const nextPageSpy = vi.fn();
|
|
85
82
|
render(<Sandbox canNextPage={false} nextPage={nextPageSpy} {...Sandbox.args} />);
|
|
86
83
|
|
|
87
84
|
const nextButton = screen.getByText("Next");
|
|
@@ -91,7 +88,7 @@ describe("Pagination", () => {
|
|
|
91
88
|
});
|
|
92
89
|
|
|
93
90
|
it("should have Next button NOT disabled and clickable", () => {
|
|
94
|
-
const nextPageSpy =
|
|
91
|
+
const nextPageSpy = vi.fn();
|
|
95
92
|
render(<Sandbox canNextPage={true} nextPage={nextPageSpy} {...Sandbox.args} />);
|
|
96
93
|
const nextButton = screen.getByText("Next");
|
|
97
94
|
expect(nextButton).not.toHaveAttribute("disabled");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import classnames from "classnames";
|
|
2
|
-
import
|
|
2
|
+
import { PropsWithChildren } from "react";
|
|
3
3
|
|
|
4
4
|
import { Select } from "../select/select.component";
|
|
5
5
|
import { getPageNumbers, LEFT_PAGE, RIGHT_PAGE } from "../table/utils/getPageNumbers";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { fireEvent, render, screen } from "@testing-library/react";
|
|
2
|
-
import React from "react";
|
|
3
2
|
|
|
4
3
|
import { Choicesjs, Sandbox } from "./select.stories";
|
|
5
4
|
|
|
@@ -52,7 +51,7 @@ describe("Select", () => {
|
|
|
52
51
|
{ label: "test2", value: "value2" }
|
|
53
52
|
];
|
|
54
53
|
const placeHolderTest = "Placeholder test";
|
|
55
|
-
const onChange =
|
|
54
|
+
const onChange = vi.fn();
|
|
56
55
|
|
|
57
56
|
render(<Sandbox {...Sandbox.args} placeholder={placeHolderTest} choices={choices} name={"test-sandbox"} onChange={onChange} />);
|
|
58
57
|
|
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
import Choices from "@formio/choices.js";
|
|
2
2
|
import classnames from "classnames";
|
|
3
|
-
import
|
|
4
|
-
import React, { ReactElement, useEffect, useRef } from "react";
|
|
3
|
+
import { HTMLAttributes, ReactElement, useEffect, useRef } from "react";
|
|
5
4
|
|
|
6
5
|
import { getEventValue } from "../../utils/getEventValue";
|
|
7
6
|
import { FormControl, FormControlProps } from "../form-control/formControl.component";
|
|
8
7
|
|
|
9
|
-
export interface SelectProps<
|
|
10
|
-
value?: any;
|
|
8
|
+
export interface SelectProps<Data = any> extends FormControlProps, Omit<HTMLAttributes<HTMLSelectElement>, "onChange" | "prefix"> {
|
|
11
9
|
size?: string;
|
|
12
|
-
onChange?: (name: string, value: any) => void;
|
|
13
10
|
placeholder?: string;
|
|
14
|
-
choices: { label: string; value:
|
|
11
|
+
choices: { label: string; value: Data }[];
|
|
15
12
|
layout?: "html5" | "choicesjs";
|
|
13
|
+
disabled?: boolean;
|
|
16
14
|
multiple?: boolean;
|
|
17
|
-
|
|
18
|
-
[key: string]: any;
|
|
19
15
|
}
|
|
20
16
|
|
|
21
|
-
export function Select<
|
|
17
|
+
export function Select<Data = any>({
|
|
22
18
|
name,
|
|
23
19
|
label,
|
|
24
20
|
size,
|
|
@@ -33,14 +29,14 @@ export function Select<T = any>({
|
|
|
33
29
|
multiple,
|
|
34
30
|
layout,
|
|
35
31
|
...props
|
|
36
|
-
}: SelectProps<
|
|
37
|
-
const ref = useRef<
|
|
32
|
+
}: SelectProps<Data>): ReactElement {
|
|
33
|
+
const ref = useRef<HTMLSelectElement>(null);
|
|
38
34
|
|
|
39
35
|
useEffect(() => {
|
|
40
36
|
let instance: any;
|
|
41
37
|
|
|
42
38
|
if (layout === "choicesjs") {
|
|
43
|
-
instance = new Choices(ref.current, {
|
|
39
|
+
instance = new Choices(ref.current as unknown as HTMLInputElement, {
|
|
44
40
|
removeItemButton: true,
|
|
45
41
|
placeholderValue: placeholder
|
|
46
42
|
});
|
|
@@ -64,11 +60,11 @@ export function Select<T = any>({
|
|
|
64
60
|
|
|
65
61
|
return (
|
|
66
62
|
<FormControl name={name} label={label} required={required} description={description} prefix={prefix} suffix={suffix} shadow={false}>
|
|
67
|
-
{
|
|
63
|
+
{}
|
|
68
64
|
<select
|
|
69
65
|
ref={ref}
|
|
70
|
-
{...props}
|
|
71
66
|
data-testid={`select_${name}`}
|
|
67
|
+
{...props}
|
|
72
68
|
className={classnames("form-control", size && `form-control-${size}`)}
|
|
73
69
|
name={name}
|
|
74
70
|
id={name}
|
|
@@ -90,12 +86,3 @@ export function Select<T = any>({
|
|
|
90
86
|
</FormControl>
|
|
91
87
|
);
|
|
92
88
|
}
|
|
93
|
-
|
|
94
|
-
Select.propTypes = {
|
|
95
|
-
label: PropTypes.string,
|
|
96
|
-
name: PropTypes.string.isRequired,
|
|
97
|
-
value: PropTypes.any,
|
|
98
|
-
required: PropTypes.bool,
|
|
99
|
-
onChange: PropTypes.func,
|
|
100
|
-
choices: PropTypes.array.isRequired
|
|
101
|
-
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useState } from "react";
|
|
2
2
|
|
|
3
3
|
import { mapPagination } from "../../utils/mapPagination";
|
|
4
4
|
import formSchema from "../__fixtures__/form-schema.json";
|
|
@@ -49,9 +49,9 @@ export default {
|
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
export const Sandbox = (args: any) => {
|
|
52
|
-
const [skip, setSkip] =
|
|
53
|
-
const [limit, setLimit] =
|
|
54
|
-
const [serverCount] =
|
|
52
|
+
const [skip, setSkip] = useState(0);
|
|
53
|
+
const [limit, setLimit] = useState(10);
|
|
54
|
+
const [serverCount] = useState(87);
|
|
55
55
|
|
|
56
56
|
const onChange = (obj: any) => {
|
|
57
57
|
setLimit(obj.pageSize);
|
|
@@ -1,19 +1,30 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { DefaultOperationButton, OperationButtonProps } from "./defaultOperationButton.component";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export interface DefaultCellOperationsProps {
|
|
4
|
+
operations: (OperationButtonProps & {
|
|
5
|
+
OperationButton: typeof DefaultOperationButton;
|
|
6
|
+
permissionsResolver?(data: unknown, ctx: any): boolean;
|
|
7
|
+
})[];
|
|
8
|
+
row: any;
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
onClick: (data: any, action: string) => void;
|
|
11
|
+
ctx: any;
|
|
12
|
+
i18n: (i18n: string) => string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function DefaultCellOperations({ operations, row, onClick, ctx, i18n }: DefaultCellOperationsProps) {
|
|
6
16
|
const data = row.original;
|
|
7
17
|
|
|
8
18
|
return (
|
|
9
19
|
<div className='btn-group'>
|
|
10
20
|
{operations
|
|
11
|
-
.filter(({ permissionsResolver }
|
|
12
|
-
.map(({ OperationButton = DefaultOperationButton, ...operation }:
|
|
21
|
+
.filter(({ permissionsResolver }) => !permissionsResolver || permissionsResolver(data, ctx))
|
|
22
|
+
.map(({ OperationButton = DefaultOperationButton, ...operation }, index: number) => {
|
|
13
23
|
return (
|
|
14
24
|
<OperationButton
|
|
15
25
|
key={operation.action}
|
|
16
26
|
{...operation}
|
|
27
|
+
data-testid={`operation-${index}-${operation.action}`}
|
|
17
28
|
onClick={(action: string) => onClick(data, action)}
|
|
18
29
|
data={data}
|
|
19
30
|
i18n={i18n}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import classnames from "classnames";
|
|
2
|
-
import
|
|
2
|
+
import { HTMLAttributes } from "react";
|
|
3
3
|
|
|
4
4
|
import { iconClass } from "../../../utils/iconClass";
|
|
5
5
|
import { stopPropagationWrapper } from "../../../utils/stopPropagationWrapper";
|
|
6
6
|
|
|
7
|
-
export interface OperationButtonProps {
|
|
8
|
-
className?: string;
|
|
7
|
+
export interface OperationButtonProps extends Omit<HTMLAttributes<HTMLButtonElement>, "onClick"> {
|
|
9
8
|
buttonType?: string;
|
|
10
9
|
buttonSize?: string;
|
|
11
10
|
buttonOutline?: boolean;
|
|
@@ -15,6 +14,8 @@ export interface OperationButtonProps {
|
|
|
15
14
|
icon?: string;
|
|
16
15
|
title?: string;
|
|
17
16
|
i18n?: (i18n: string) => string;
|
|
17
|
+
ctx?: any;
|
|
18
|
+
permissionsResolver?: (ctx: any) => boolean;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export function DefaultOperationButton(props: OperationButtonProps) {
|
|
@@ -27,11 +28,20 @@ export function DefaultOperationButton(props: OperationButtonProps) {
|
|
|
27
28
|
action,
|
|
28
29
|
icon = "",
|
|
29
30
|
title = "",
|
|
30
|
-
i18n = (f: string) => f
|
|
31
|
+
i18n = (f: string) => f,
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
33
|
+
data,
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
35
|
+
ctx,
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
37
|
+
permissionsResolver,
|
|
38
|
+
...otherProps
|
|
31
39
|
} = props;
|
|
32
40
|
|
|
33
41
|
return (
|
|
34
42
|
<button
|
|
43
|
+
{...otherProps}
|
|
44
|
+
aria-label={"Operation button: " + (title || action)}
|
|
35
45
|
className={classnames(className, ["btn", buttonOutline && "outline", buttonType].filter(Boolean).join("-"), `btn-${buttonSize}`)}
|
|
36
46
|
onClick={stopPropagationWrapper(() => onClick(action))}
|
|
37
47
|
>
|