@tsed/react-formio 1.11.1 → 1.13.0

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.
Files changed (152) hide show
  1. package/.env +2 -1
  2. package/craco.config.js +11 -1
  3. package/dist/components/alert/alert.component.spec.d.ts +1 -0
  4. package/dist/components/alert/alert.stories.d.ts +15 -0
  5. package/dist/components/card/card.component.d.ts +2 -1
  6. package/dist/components/form/form.component.d.ts +2 -0
  7. package/dist/components/form/form.stories.d.ts +37 -0
  8. package/dist/components/form/useForm.hook.d.ts +1 -0
  9. package/dist/components/form-action/formAction.stories.d.ts +90 -414
  10. package/dist/components/input-text/inputText.component.d.ts +1 -1
  11. package/dist/components/input-text/inputText.component.spec.d.ts +1 -0
  12. package/dist/components/loader/loader.component.d.ts +2 -2
  13. package/dist/components/loader/loader.stories.d.ts +15 -0
  14. package/dist/components/pagination/pagination.component.spec.d.ts +1 -0
  15. package/dist/components/pagination/pagination.stories.d.ts +0 -27
  16. package/dist/components/select/select.component.spec.d.ts +1 -0
  17. package/dist/components/tabs/tabs.component.spec.d.ts +1 -0
  18. package/dist/index.js +114 -35
  19. package/dist/index.js.map +1 -1
  20. package/dist/index.modern.js +86 -34
  21. package/dist/index.modern.js.map +1 -1
  22. package/jest.config.js +1 -1
  23. package/package.json +5 -9
  24. package/readme.md +114 -86
  25. package/src/components/__fixtures__/form-schema.json +10 -42
  26. package/src/components/__fixtures__/form.fixture.json +1 -1
  27. package/src/components/actions-table/actionsTable.component.spec.tsx +4 -13
  28. package/src/components/actions-table/actionsTable.component.tsx +3 -11
  29. package/src/components/alert/alert.component.spec.tsx +97 -0
  30. package/src/components/alert/alert.component.tsx +2 -8
  31. package/src/components/alert/alert.stories.tsx +17 -0
  32. package/src/components/card/card.component.tsx +2 -5
  33. package/src/components/form/form.component.tsx +4 -8
  34. package/src/components/form/form.stories.tsx +66 -2
  35. package/src/components/form/useForm.hook.ts +29 -14
  36. package/src/components/form-access/formAccess.component.tsx +19 -82
  37. package/src/components/form-access/formAccess.schema.ts +7 -23
  38. package/src/components/form-access/formAccess.stories.tsx +2 -9
  39. package/src/components/form-access/formAccess.utils.spec.ts +4 -22
  40. package/src/components/form-access/formAccess.utils.ts +7 -29
  41. package/src/components/form-action/formAction.component.tsx +3 -19
  42. package/src/components/form-action/formAction.stories.tsx +251 -672
  43. package/src/components/form-builder/formBuilder.component.tsx +4 -13
  44. package/src/components/form-builder/formBuilder.stories.tsx +12 -24
  45. package/src/components/form-control/formControl.component.tsx +2 -8
  46. package/src/components/form-edit/formCtas.component.tsx +5 -23
  47. package/src/components/form-edit/formEdit.component.tsx +2 -20
  48. package/src/components/form-edit/formEdit.reducer.ts +2 -8
  49. package/src/components/form-edit/formEdit.stories.tsx +3 -15
  50. package/src/components/form-edit/formParameters.component.tsx +3 -20
  51. package/src/components/form-edit/useFormEdit.hook.ts +2 -9
  52. package/src/components/form-settings/formSettings.component.spec.tsx +2 -9
  53. package/src/components/form-settings/formSettings.component.tsx +6 -34
  54. package/src/components/form-settings/formSettings.stories.tsx +1 -6
  55. package/src/components/form-settings/formSettings.utils.spec.ts +1 -4
  56. package/src/components/form-settings/formSettings.utils.ts +2 -7
  57. package/src/components/forms-table/components/formCell.component.tsx +2 -6
  58. package/src/components/forms-table/formsTable.component.tsx +2 -7
  59. package/src/components/input-tags/inputTags.component.tsx +10 -34
  60. package/src/components/input-tags/inputTags.stories.tsx +4 -14
  61. package/src/components/input-text/inputText.component.spec.tsx +56 -0
  62. package/src/components/input-text/inputText.component.tsx +4 -5
  63. package/src/components/input-text/inputText.stories.tsx +6 -26
  64. package/src/components/loader/loader.component.spec.tsx +7 -6
  65. package/src/components/loader/loader.component.tsx +3 -12
  66. package/src/components/loader/loader.stories.tsx +17 -0
  67. package/src/components/modal/modal.component.spec.tsx +8 -14
  68. package/src/components/modal/modal.component.tsx +6 -27
  69. package/src/components/modal/modal.stories.tsx +1 -5
  70. package/src/components/modal/removeModal.component.tsx +4 -22
  71. package/src/components/pagination/pagination.component.spec.tsx +111 -0
  72. package/src/components/pagination/pagination.component.tsx +10 -42
  73. package/src/components/pagination/pagination.stories.tsx +9 -29
  74. package/src/components/react-component/reactComponent.component.tsx +3 -11
  75. package/src/components/select/select.component.spec.tsx +86 -0
  76. package/src/components/select/select.component.tsx +11 -15
  77. package/src/components/select/select.stories.tsx +6 -26
  78. package/src/components/submissions-table/submissionsTable.component.tsx +1 -3
  79. package/src/components/submissions-table/submissionsTable.stories.tsx +1 -1
  80. package/src/components/table/components/defaultArrowSort.component.tsx +1 -10
  81. package/src/components/table/components/defaultCell.component.tsx +1 -4
  82. package/src/components/table/components/defaultCellHeader.component.tsx +4 -14
  83. package/src/components/table/components/defaultCellOperations.component.tsx +14 -25
  84. package/src/components/table/components/defaultOperationButton.component.tsx +2 -10
  85. package/src/components/table/filters/defaultColumnFilter.component.spec.tsx +1 -1
  86. package/src/components/table/filters/selectColumnFilter.component.spec.tsx +2 -10
  87. package/src/components/table/filters/selectColumnFilter.component.tsx +2 -6
  88. package/src/components/table/table.component.tsx +13 -53
  89. package/src/components/table/table.stories.tsx +1 -1
  90. package/src/components/table/utils/getPageNumbers.ts +3 -11
  91. package/src/components/table/utils/mapFormToColumns.tsx +14 -22
  92. package/src/components/table/utils/useOperations.hook.tsx +2 -12
  93. package/src/components/tabs/tabs.component.spec.tsx +86 -0
  94. package/src/components/tabs/tabs.component.stories.tsx +2 -9
  95. package/src/components/tabs/tabs.component.tsx +9 -43
  96. package/src/interfaces/Operation.ts +1 -4
  97. package/src/react-table.d.ts +9 -28
  98. package/src/stores/action/action.actions.ts +31 -33
  99. package/src/stores/action/action.reducers.spec.ts +1 -8
  100. package/src/stores/action/action.reducers.ts +1 -8
  101. package/src/stores/action/action.selectors.ts +1 -2
  102. package/src/stores/action-info/action-info.actions.spec.ts +1 -5
  103. package/src/stores/action-info/action-info.actions.ts +16 -19
  104. package/src/stores/action-info/action-info.reducers.spec.ts +1 -6
  105. package/src/stores/action-info/action-info.reducers.ts +1 -6
  106. package/src/stores/action-info/action-info.selectors.ts +1 -4
  107. package/src/stores/actions/actions.actions.spec.ts +1 -6
  108. package/src/stores/actions/actions.actions.ts +16 -19
  109. package/src/stores/actions/actions.reducers.spec.ts +1 -6
  110. package/src/stores/actions/actions.reducers.ts +1 -6
  111. package/src/stores/actions/actions.selectors.ts +2 -4
  112. package/src/stores/auth/auth.reducers.ts +1 -4
  113. package/src/stores/auth/auth.selectors.spec.ts +1 -5
  114. package/src/stores/auth/auth.selectors.ts +3 -6
  115. package/src/stores/auth/auth.utils.tsx +2 -8
  116. package/src/stores/auth/getAccess.action.spec.ts +11 -54
  117. package/src/stores/auth/getAccess.action.ts +1 -6
  118. package/src/stores/auth/initAuth.action.ts +15 -17
  119. package/src/stores/form/form.actions.spec.ts +8 -39
  120. package/src/stores/form/form.actions.ts +55 -64
  121. package/src/stores/form/form.reducers.spec.ts +1 -7
  122. package/src/stores/form/form.reducers.ts +1 -8
  123. package/src/stores/form/form.selectors.ts +1 -2
  124. package/src/stores/forms/forms.actions.spec.ts +5 -18
  125. package/src/stores/forms/forms.actions.ts +17 -21
  126. package/src/stores/forms/forms.reducers.spec.ts +1 -6
  127. package/src/stores/forms/forms.reducers.ts +2 -13
  128. package/src/stores/forms/forms.selectors.ts +2 -4
  129. package/src/stores/index.spec.ts +6 -9
  130. package/src/stores/root/root.selectors.spec.ts +1 -6
  131. package/src/stores/root/root.selectors.ts +6 -24
  132. package/src/stores/submission/submission.actions.spec.ts +11 -33
  133. package/src/stores/submission/submission.actions.ts +57 -66
  134. package/src/stores/submission/submission.reducers.spec.ts +17 -27
  135. package/src/stores/submission/submission.reducers.ts +1 -4
  136. package/src/stores/submission/submission.selectors.ts +1 -4
  137. package/src/stores/submissions/submissions.actions.spec.ts +5 -18
  138. package/src/stores/submissions/submissions.actions.ts +17 -26
  139. package/src/stores/submissions/submissions.reducers.spec.ts +3 -12
  140. package/src/stores/submissions/submissions.reducers.ts +3 -17
  141. package/src/stores/submissions/submissions.selectors.spec.ts +1 -4
  142. package/src/stores/submissions/submissions.selectors.ts +2 -4
  143. package/src/utils/getEventValue.ts +1 -4
  144. package/src/utils/iconClass.ts +2 -10
  145. package/src/utils/mapPagination.ts +1 -6
  146. package/src/utils/mapRequestParams.ts +2 -12
  147. package/src/utils/url.test.ts +4 -12
  148. package/src/utils/url.ts +2 -7
  149. package/tsconfig.json +4 -12
  150. package/tsconfig.test.json +1 -1
  151. package/.eslintrc +0 -47
  152. package/.prettierrc +0 -10
@@ -1,30 +1,15 @@
1
1
  import classnames from "classnames";
2
2
  import noop from "lodash/noop";
3
3
  import React, { PropsWithChildren } from "react";
4
- import {
5
- CellProps,
6
- FilterProps,
7
- Renderer,
8
- TableOptions,
9
- useFilters,
10
- useGroupBy,
11
- usePagination,
12
- useSortBy,
13
- useTable
14
- } from "react-table";
4
+ import { CellProps, FilterProps, Renderer, TableOptions, useFilters, useGroupBy, usePagination, useSortBy, useTable } from "react-table";
15
5
  import { OnClickOperation, Operation, QueryOptions } from "../../interfaces";
16
6
  import { Pagination as DefaultPagination } from "../pagination/pagination.component";
17
7
  import { DefaultArrowSort } from "./components/defaultArrowSort.component";
18
- import {
19
- DefaultCellHeader,
20
- DefaultCellHeaderProps
21
- } from "./components/defaultCellHeader.component";
8
+ import { DefaultCellHeader, DefaultCellHeaderProps } from "./components/defaultCellHeader.component";
22
9
  import { DefaultColumnFilter } from "./filters/defaultColumnFilter.component";
23
10
  import { useOperations } from "./utils/useOperations.hook";
24
11
 
25
- export interface TableProps<Data extends object = any>
26
- extends TableOptions<Data>,
27
- Partial<QueryOptions> {
12
+ export interface TableProps<Data extends object = any> extends TableOptions<Data>, Partial<QueryOptions> {
28
13
  className?: string;
29
14
  /**
30
15
  * Call the listener when a filter / pagination / sort change.
@@ -93,14 +78,9 @@ export interface TableProps<Data extends object = any>
93
78
  i18n?: (f: string) => string;
94
79
  }
95
80
 
96
- function getOperationCallback(
97
- operations: Operation[],
98
- onClick: OnClickOperation
99
- ) {
81
+ function getOperationCallback(operations: Operation[], onClick: OnClickOperation) {
100
82
  return (data: any, action: string) => {
101
- const operation = operations.find(
102
- (operation) => operation.action === action || operation.alias === action
103
- );
83
+ const operation = operations.find((operation) => operation.action === action || operation.alias === action);
104
84
  if (operation) {
105
85
  onClick(data, operation);
106
86
  }
@@ -108,9 +88,7 @@ function getOperationCallback(
108
88
  }
109
89
 
110
90
  function DefaultLoader() {
111
- return (
112
- <div className={"text-center p-2 pb-4 font-bold"}>Loading in progress</div>
113
- );
91
+ return <div className={"text-center p-2 pb-4 font-bold"}>Loading in progress</div>;
114
92
  }
115
93
 
116
94
  function DefaultEmptyData() {
@@ -119,9 +97,7 @@ function DefaultEmptyData() {
119
97
 
120
98
  const hooks = [useFilters, useGroupBy, useSortBy, usePagination];
121
99
 
122
- export function Table<Data extends object = any>(
123
- props: PropsWithChildren<TableProps<Data>>
124
- ) {
100
+ export function Table<Data extends object = any>(props: PropsWithChildren<TableProps<Data>>) {
125
101
  const {
126
102
  children,
127
103
  className = "",
@@ -177,12 +153,9 @@ export function Table<Data extends object = any>(
177
153
  pageSize: controlledPageSize || 10,
178
154
  sortBy: controlledSortBy || []
179
155
  } as any,
180
- manualPagination:
181
- props.manualPagination === undefined ? true : props.manualPagination,
182
- manualSortBy:
183
- props.manualSortBy === undefined ? true : props.manualPagination,
184
- manualFilters:
185
- props.manualFilters === undefined ? true : props.manualFilters,
156
+ manualPagination: props.manualPagination === undefined ? true : props.manualPagination,
157
+ manualSortBy: props.manualSortBy === undefined ? true : props.manualPagination,
158
+ manualFilters: props.manualFilters === undefined ? true : props.manualFilters,
186
159
  disableFilters,
187
160
  filterId,
188
161
  setFilterId
@@ -216,10 +189,7 @@ export function Table<Data extends object = any>(
216
189
  >
217
190
  <thead>
218
191
  {tableInstance.headerGroups.map((headerGroup, i) => (
219
- <tr
220
- key={`tableInstance.headerGroups${i}`}
221
- {...headerGroup.getHeaderGroupProps()}
222
- >
192
+ <tr key={`tableInstance.headerGroups${i}`} {...headerGroup.getHeaderGroupProps()}>
223
193
  {headerGroup.headers.map((column) => (
224
194
  <th
225
195
  key={`tableInstance.headers.column.${column.id}`}
@@ -237,24 +207,14 @@ export function Table<Data extends object = any>(
237
207
  {tableInstance.page.map((row) => {
238
208
  tableInstance.prepareRow(row);
239
209
  return (
240
- <tr
241
- key={`tableInstance.page.${row.id}`}
242
- onClick={() => _onClick(row.original, "row")}
243
- {...row.getRowProps()}
244
- >
210
+ <tr key={`tableInstance.page.${row.id}`} onClick={() => _onClick(row.original, "row")} {...row.getRowProps()}>
245
211
  {row.cells.map((cell, i) => {
246
212
  const { hidden, colspan } = cell.column as any;
247
213
  if (hidden) {
248
214
  return null;
249
215
  }
250
216
  return (
251
- <td
252
- key={`tableInstance.page.cells.${
253
- cell.value || "value"
254
- }.${i}`}
255
- colSpan={colspan}
256
- {...cell.getCellProps()}
257
- >
217
+ <td key={`tableInstance.page.cells.${cell.value || "value"}.${i}`} colSpan={colspan} {...cell.getCellProps()}>
258
218
  {cell.render("Cell")}
259
219
  </td>
260
220
  );
@@ -20,7 +20,7 @@ export const Sandbox = (args: any) => {
20
20
  const onChange = (obj: any) => {
21
21
  setLimit(obj.pageSize);
22
22
  setSkip(obj.pageIndex * obj.pageSize);
23
- args.onChange(obj);
23
+ args.onChange && args.onChange(obj);
24
24
  };
25
25
 
26
26
  return (
@@ -13,23 +13,15 @@ function range(from: number, to: number, step = 1): any[] {
13
13
  return range;
14
14
  }
15
15
 
16
- export function getPageNumbers({
17
- currentPage,
18
- pageNeighbours = 1,
19
- totalPages
20
- }: any) {
16
+ export function getPageNumbers({ currentPage, pageNeighbours = 1, totalPages }: any) {
21
17
  const totalNumbers = pageNeighbours * 2 + 3;
22
18
  const totalBlocks = totalNumbers + 2;
23
19
 
24
20
  if (totalPages > totalBlocks) {
25
21
  const calculatedStartPage = Math.max(2, currentPage - pageNeighbours);
26
- const calculatedEndPage = Math.min(
27
- totalPages - 1,
28
- currentPage + pageNeighbours
29
- );
22
+ const calculatedEndPage = Math.min(totalPages - 1, currentPage + pageNeighbours);
30
23
  const startPage = calculatedStartPage === 3 ? 2 : calculatedStartPage;
31
- const endPage =
32
- calculatedEndPage === totalPages - 2 ? totalPages - 1 : calculatedEndPage;
24
+ const endPage = calculatedEndPage === totalPages - 2 ? totalPages - 1 : calculatedEndPage;
33
25
 
34
26
  let pages = range(startPage, endPage);
35
27
 
@@ -9,32 +9,24 @@ import { SelectColumnFilter } from "../filters/selectColumnFilter.component";
9
9
  export function mapFormToColumns(form: FormSchema): Column[] {
10
10
  const columns: Column[] = [];
11
11
 
12
- FormioUtils.eachComponent(
13
- form.components,
14
- (component: ExtendedComponentSchema) => {
15
- if (component.tableView && component.key) {
16
- const cmp: any = Components.create(component, null, null, true);
12
+ FormioUtils.eachComponent(form.components, (component: ExtendedComponentSchema) => {
13
+ if (component.tableView && component.key) {
14
+ const cmp: any = Components.create(component, null, null, true);
17
15
 
18
- const column: Column = {
19
- Header: component.label || component.title || component.key,
20
- accessor: `data.${component.key}`,
21
- Cell: (props: any) => (
22
- <DefaultCell
23
- {...props}
24
- render={(value: any) => cmp.asString(value)}
25
- />
26
- )
27
- };
16
+ const column: Column = {
17
+ Header: component.label || component.title || component.key,
18
+ accessor: `data.${component.key}`,
19
+ Cell: (props: any) => <DefaultCell {...props} render={(value: any) => cmp.asString(value)} />
20
+ };
28
21
 
29
- if (component.type === "select" && component.dataSrc === "values") {
30
- column.Filter = SelectColumnFilter;
31
- (column as any).choices = component.data.values;
32
- }
33
-
34
- columns.push(column);
22
+ if (component.type === "select" && component.dataSrc === "values") {
23
+ column.Filter = SelectColumnFilter;
24
+ (column as any).choices = component.data.values;
35
25
  }
26
+
27
+ columns.push(column);
36
28
  }
37
- );
29
+ });
38
30
 
39
31
  return columns;
40
32
  }
@@ -29,18 +29,8 @@ export function useOperations<D extends object = {}>({
29
29
  {
30
30
  id: "operations",
31
31
  groupByBoundary: true,
32
- Header: () => (
33
- <div className={"text-center"}>{i18n("Operations")}</div>
34
- ),
35
- Cell: (props: any) => (
36
- <CellOperations
37
- {...props}
38
- operations={operations}
39
- onClick={onClick}
40
- ctx={ctx}
41
- i18n={i18n}
42
- />
43
- )
32
+ Header: () => <div className={"text-center"}>{i18n("Operations")}</div>,
33
+ Cell: (props: any) => <CellOperations {...props} operations={operations} onClick={onClick} ctx={ctx} i18n={i18n} />
44
34
  }
45
35
  ];
46
36
  });
@@ -0,0 +1,86 @@
1
+ import * as React from "react";
2
+ import {fireEvent, render, screen} from "@testing-library/react";
3
+ import {Sandbox} from "./tabs.component.stories";
4
+ import {Tabs} from "./tabs.component";
5
+
6
+ describe("tabs", () => {
7
+ it("should display the tabs component and children", () => {
8
+ const items = [
9
+ {
10
+ action: "back",
11
+ exact: true,
12
+ icon: "chevron-left",
13
+ back: true
14
+ },
15
+ {
16
+ action: "edit",
17
+ exact: true,
18
+ icon: "edit",
19
+ label: "Edit"
20
+ }
21
+ ];
22
+
23
+ render(<Sandbox {...Sandbox.args} items={items}/>);
24
+
25
+ const tabsComponent = screen.getByTestId("tabs-comp");
26
+
27
+ const buttonsTabWrapper = screen.getAllByTitle("button-wrapper");
28
+ const chevronLeftButtonTabWrapper = buttonsTabWrapper[0];
29
+ const editButtonTabWrapper = buttonsTabWrapper[1];
30
+
31
+ const buttonsTab = screen.getAllByTitle("button-tab");
32
+ const chevronLeftButtonTab = buttonsTab[0];
33
+ const editButtonTab = buttonsTab[1];
34
+
35
+ const fontAwsomeChevronLeftIcon = "fa fa-chevron-left";
36
+ const fontAwsomeEditIcon = "fa fa-edit";
37
+
38
+ expect(tabsComponent).toBeInTheDocument();
39
+
40
+ expect(chevronLeftButtonTabWrapper).toContainElement(chevronLeftButtonTab);
41
+ expect(chevronLeftButtonTabWrapper).toContainHTML("-back");
42
+ expect(chevronLeftButtonTab).toBeInTheDocument();
43
+ expect(chevronLeftButtonTab).toContainHTML(fontAwsomeChevronLeftIcon);
44
+ expect(chevronLeftButtonTab).toHaveTextContent("");
45
+
46
+ expect(editButtonTabWrapper).toContainElement(editButtonTab);
47
+ expect(editButtonTabWrapper).not.toContainHTML("-back");
48
+ expect(editButtonTab).toBeInTheDocument();
49
+ expect(editButtonTab).toContainHTML(fontAwsomeEditIcon);
50
+ expect(editButtonTab).toHaveTextContent("Edit");
51
+ });
52
+
53
+ it("should call dispatcher when clicking on a button tab", () => {
54
+ const items = [
55
+ {
56
+ action: "back",
57
+ exact: true,
58
+ icon: "chevron-left",
59
+ back: true
60
+ },
61
+ {
62
+ action: "edit",
63
+ exact: true,
64
+ icon: "edit",
65
+ label: "Edit"
66
+ }
67
+ ];
68
+ const onClick = jest.fn();
69
+
70
+ render(<Tabs items={items} onClick={onClick}/>);
71
+
72
+ const buttonsTab = screen.getAllByTitle("button-tab");
73
+ const chevronLeftButtonTab = buttonsTab[0];
74
+ const editButtonTab = buttonsTab[1];
75
+
76
+ fireEvent.click(chevronLeftButtonTab);
77
+
78
+ expect(onClick).toHaveBeenCalledTimes(1);
79
+ expect(onClick).toHaveBeenCalledWith(items[0]);
80
+
81
+ fireEvent.click(editButtonTab);
82
+
83
+ expect(onClick).toHaveBeenCalledTimes(2);
84
+ expect(onClick).toHaveBeenCalledWith(items[1]);
85
+ });
86
+ });
@@ -93,9 +93,7 @@ function AddButton({ onCreate }: any) {
93
93
  }
94
94
 
95
95
  function HeaderChildren() {
96
- return (
97
- <div className={"px-3 bg-gray-100 border-b-1 border-gray-light"}>test</div>
98
- );
96
+ return <div className={"px-3 bg-gray-100 border-b-1 border-gray-light"}>test</div>;
99
97
  }
100
98
 
101
99
  export const WithCloseable = (args: any) => {
@@ -104,12 +102,7 @@ export const WithCloseable = (args: any) => {
104
102
 
105
103
  return (
106
104
  <div className={"border-gray-300 border-1 shadow"}>
107
- <Tabs
108
- {...tabs}
109
- i18n={(f) => f}
110
- AddButton={AddButton}
111
- HeaderChildren={HeaderChildren}
112
- >
105
+ <Tabs {...tabs} i18n={(f) => f} AddButton={AddButton} HeaderChildren={HeaderChildren}>
113
106
  <div className={"p-5"}>{tabs?.current?.action}</div>
114
107
  </Tabs>
115
108
  </div>
@@ -2,51 +2,19 @@ import classnames from "classnames";
2
2
  import React, { PropsWithChildren } from "react";
3
3
  import { iconClass } from "../../utils/iconClass";
4
4
 
5
- export function ButtonTab({
6
- icon,
7
- back,
8
- onClick,
9
- isActive,
10
- reverse,
11
- children,
12
- className,
13
- after
14
- }: PropsWithChildren<any>) {
5
+ export function ButtonTab({ icon, back, onClick, isActive, reverse, children, className, after }: PropsWithChildren<any>) {
15
6
  return (
16
- <div
17
- className={classnames(
18
- "tw-tabs__button-wrapper",
19
- isActive ? "-active" : "",
20
- back ? "-back" : "",
21
- className
22
- )}
23
- >
7
+ <div title={'button-wrapper'} className={classnames("tw-tabs__button-wrapper", isActive ? "-active" : "", back ? "-back" : "", className)}>
24
8
  <button
25
- className={classnames(
26
- "tw-tabs__button",
27
- reverse ? "-reverse" : "",
28
- isActive ? "-active" : "",
29
- back ? "-back" : ""
30
- )}
9
+ title={'button-tab'}
10
+ className={classnames("tw-tabs__button", reverse ? "-reverse" : "", isActive ? "-active" : "", back ? "-back" : "")}
31
11
  onClick={onClick}
32
12
  >
33
- {icon && (
34
- <i
35
- className={classnames(
36
- iconClass(undefined, icon),
37
- "tw-tabs__button-icon"
38
- )}
39
- />
40
- )}
13
+ {icon && <i className={classnames(iconClass(undefined, icon), "tw-tabs__button-icon")} />}
41
14
  <span className={"tw-tabs__button-label"}>{children}</span>
42
15
  {after}
43
16
  </button>
44
- <div
45
- className={classnames(
46
- "tw-tabs__button-border",
47
- isActive ? "-active" : ""
48
- )}
49
- />
17
+ <div className={classnames("tw-tabs__button-border", isActive ? "-active" : "")} />
50
18
  </div>
51
19
  );
52
20
  }
@@ -83,7 +51,7 @@ export function Tabs({
83
51
  ...additionalProps
84
52
  }: PropsWithChildren<TabsProps>) {
85
53
  return (
86
- <div className={`tw-tabs ${className}`} style={style}>
54
+ <div data-testid={'tabs-comp'} className={`tw-tabs ${className}`} style={style}>
87
55
  <div>
88
56
  <nav className='tw-tabs__header'>
89
57
  <div className='tw-tabs__header-wrapper'>
@@ -110,11 +78,9 @@ export function Tabs({
110
78
  {AddButton && <AddButton {...additionalProps} current={current} />}
111
79
  </div>
112
80
  </nav>
113
- {HeaderChildren && (
114
- <HeaderChildren {...additionalProps} current={current} />
115
- )}
81
+ {HeaderChildren && <HeaderChildren {...additionalProps} current={current} />}
116
82
  </div>
117
- <div className={"tw-tabs__body"}>{children}</div>
83
+ <div title={"tab-body"} className={"tw-tabs__body"}>{children}</div>
118
84
  </div>
119
85
  );
120
86
  }
@@ -2,10 +2,7 @@ import React from "react";
2
2
  import { OperationButtonProps } from "../components/table/components/defaultOperationButton.component";
3
3
 
4
4
  export type PermissionsResolver<Data = any> = (data: Data, ctx: any) => void;
5
- export type OnClickOperation<Data = any> = (
6
- data: Data,
7
- operation: Operation
8
- ) => void;
5
+ export type OnClickOperation<Data = any> = (data: Data, operation: Operation) => void;
9
6
 
10
7
  export interface Operation<Data = any> {
11
8
  /**
@@ -45,9 +45,7 @@ import {
45
45
  } from "react-table";
46
46
 
47
47
  declare module "react-table" {
48
- export interface UseFlexLayoutInstanceProps<
49
- D extends Record<string, unknown>
50
- > {
48
+ export interface UseFlexLayoutInstanceProps<D extends Record<string, unknown>> {
51
49
  totalColumnsMinWidth: number;
52
50
  }
53
51
 
@@ -66,17 +64,13 @@ declare module "react-table" {
66
64
  UseRowSelectOptions<D>,
67
65
  UseSortByOptions<D> {}
68
66
 
69
- export interface Hooks<
70
- D extends Record<string, unknown> = Record<string, unknown>
71
- >
67
+ export interface Hooks<D extends Record<string, unknown> = Record<string, unknown>>
72
68
  extends UseExpandedHooks<D>,
73
69
  UseGroupByHooks<D>,
74
70
  UseRowSelectHooks<D>,
75
71
  UseSortByHooks<D> {}
76
72
 
77
- export interface TableInstance<
78
- D extends Record<string, unknown> = Record<string, unknown>
79
- >
73
+ export interface TableInstance<D extends Record<string, unknown> = Record<string, unknown>>
80
74
  extends UseColumnOrderInstanceProps<D>,
81
75
  UseExpandedInstanceProps<D>,
82
76
  UseFiltersInstanceProps<D>,
@@ -88,9 +82,7 @@ declare module "react-table" {
88
82
  UsePaginationInstanceProps<D>,
89
83
  UseSortByInstanceProps<D> {}
90
84
 
91
- export interface TableState<
92
- D extends Record<string, unknown> = Record<string, unknown>
93
- >
85
+ export interface TableState<D extends Record<string, unknown> = Record<string, unknown>>
94
86
  extends UseColumnOrderState<D>,
95
87
  UseExpandedState<D>,
96
88
  UseFiltersState<D>,
@@ -103,9 +95,7 @@ declare module "react-table" {
103
95
  rowCount: number;
104
96
  }
105
97
 
106
- export interface ColumnInterface<
107
- D extends Record<string, unknown> = Record<string, unknown>
108
- >
98
+ export interface ColumnInterface<D extends Record<string, unknown> = Record<string, unknown>>
109
99
  extends UseFiltersColumnOptions<D>,
110
100
  UseGroupByColumnOptions<D>,
111
101
  UseResizeColumnsColumnOptions<D>,
@@ -113,25 +103,16 @@ declare module "react-table" {
113
103
  align?: string;
114
104
  }
115
105
 
116
- export interface ColumnInstance<
117
- D extends Record<string, unknown> = Record<string, unknown>
118
- >
106
+ export interface ColumnInstance<D extends Record<string, unknown> = Record<string, unknown>>
119
107
  extends UseFiltersColumnProps<D>,
120
108
  UseGroupByColumnProps<D>,
121
109
  UseResizeColumnsColumnProps<D>,
122
110
  UseFlexLayoutColumnProps<D>,
123
111
  UseSortByColumnProps<D> {}
124
112
 
125
- export type Cell<
126
- D extends Record<string, unknown> = Record<string, unknown>
127
- > = UseGroupByCellProps<D>;
113
+ export type Cell<D extends Record<string, unknown> = Record<string, unknown>> = UseGroupByCellProps<D>;
128
114
 
129
- export interface Row<D extends object = {}>
130
- extends UseExpandedRowProps<D>,
131
- UseGroupByRowProps<D>,
132
- UseRowSelectRowProps<D> {}
115
+ export interface Row<D extends object = {}> extends UseExpandedRowProps<D>, UseGroupByRowProps<D>, UseRowSelectRowProps<D> {}
133
116
  }
134
117
 
135
- export type TableMouseEventHandler = (
136
- instance: TableInstance<T>
137
- ) => MouseEventHandler;
118
+ export type TableMouseEventHandler = (instance: TableInstance<T>) => MouseEventHandler;
@@ -18,45 +18,43 @@ function getFormio(formId: string, id: string) {
18
18
  return new Formio(url);
19
19
  }
20
20
 
21
- export const getAction = (
22
- formId: string,
23
- actionId: string,
24
- done = noop
25
- ) => async (dispatch: any) => {
26
- dispatch(clearActionError(ACTION));
27
- dispatch(requestAction(ACTION));
21
+ export const getAction =
22
+ (formId: string, actionId: string, done = noop) =>
23
+ async (dispatch: any) => {
24
+ dispatch(clearActionError(ACTION));
25
+ dispatch(requestAction(ACTION));
28
26
 
29
- const formio = getFormio(formId, actionId);
27
+ const formio = getFormio(formId, actionId);
30
28
 
31
- try {
32
- const action = await formio.loadAction();
29
+ try {
30
+ const action = await formio.loadAction();
33
31
 
34
- dispatch(getActionInfo(formId, action.name));
35
- dispatch(receiveAction(ACTION, { action }));
36
- done(null, action);
37
- } catch (error) {
38
- dispatch(failAction(ACTION, { error }));
39
- done(error);
40
- }
41
- };
32
+ dispatch(getActionInfo(formId, action.name));
33
+ dispatch(receiveAction(ACTION, { action }));
34
+ done(null, action);
35
+ } catch (error) {
36
+ dispatch(failAction(ACTION, { error }));
37
+ done(error);
38
+ }
39
+ };
42
40
 
43
- export const saveAction = (formId: string, action: any, done = noop) => async (
44
- dispatch: any
45
- ) => {
46
- dispatch(clearActionError(ACTION));
47
- dispatch(sendAction(ACTION, { action }));
41
+ export const saveAction =
42
+ (formId: string, action: any, done = noop) =>
43
+ async (dispatch: any) => {
44
+ dispatch(clearActionError(ACTION));
45
+ dispatch(sendAction(ACTION, { action }));
48
46
 
49
- const formio = getFormio(formId, get(action, "data._id", ""));
47
+ const formio = getFormio(formId, get(action, "data._id", ""));
50
48
 
51
- try {
52
- const result = await formio.saveAction(action);
53
- dispatch(receiveAction(ACTION, { action: result }));
54
- done(null, result);
55
- } catch (error) {
56
- dispatch(failAction(ACTION, { error }));
57
- done(error);
58
- }
59
- };
49
+ try {
50
+ const result = await formio.saveAction(action);
51
+ dispatch(receiveAction(ACTION, { action: result }));
52
+ done(null, result);
53
+ } catch (error) {
54
+ dispatch(failAction(ACTION, { error }));
55
+ done(error);
56
+ }
57
+ };
60
58
 
61
59
  export const deleteAction = (formId: string, actionId: string, done = noop) => {
62
60
  return async (dispatch: any) => {
@@ -1,11 +1,4 @@
1
- import {
2
- clearActionError,
3
- failAction,
4
- receiveAction,
5
- requestAction,
6
- resetAction,
7
- sendAction
8
- } from "./action.actions";
1
+ import { clearActionError, failAction, receiveAction, requestAction, resetAction, sendAction } from "./action.actions";
9
2
  import { ACTION } from "./action.constant";
10
3
  import { actionReducer } from "./action.reducers";
11
4
 
@@ -1,14 +1,7 @@
1
1
  import { createReducer, InitialStateCreator } from "@tsed/redux-utils";
2
2
  import { ActionSchema } from "../../interfaces";
3
3
 
4
- import {
5
- clearActionError,
6
- failAction,
7
- receiveAction,
8
- requestAction,
9
- resetAction,
10
- sendAction
11
- } from "./action.actions";
4
+ import { clearActionError, failAction, receiveAction, requestAction, resetAction, sendAction } from "./action.actions";
12
5
  import { ACTION } from "./action.constant";
13
6
 
14
7
  export interface ActionState {
@@ -3,5 +3,4 @@ import { selectRoot } from "../root";
3
3
  import { ACTION } from "./action.constant";
4
4
  import { ActionState } from "./action.reducers";
5
5
 
6
- export const selectAction = (state: Record<string, any>): ActionSchema =>
7
- selectRoot<ActionState>(ACTION, state).data;
6
+ export const selectAction = (state: Record<string, any>): ActionSchema => selectRoot<ActionState>(ACTION, state).data;
@@ -1,9 +1,5 @@
1
1
  import { Formio } from "formiojs";
2
- import {
3
- getActionInfo,
4
- receiveActionInfo,
5
- requestActionInfo
6
- } from "./action-info.actions";
2
+ import { getActionInfo, receiveActionInfo, requestActionInfo } from "./action-info.actions";
7
3
 
8
4
  jest.mock("formiojs/Formio");
9
5