@tsed/react-formio 1.13.0 → 1.13.3

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 (184) hide show
  1. package/.eslintignore +13 -0
  2. package/.eslintrc.js +7 -0
  3. package/coverage.json +6 -0
  4. package/dist/components/actions-table/actionsTable.component.d.ts +0 -1
  5. package/dist/components/actions-table/actionsTable.stories.d.ts +0 -1
  6. package/dist/components/alert/alert.component.d.ts +1 -2
  7. package/dist/components/alert/alert.stories.d.ts +0 -1
  8. package/dist/components/card/card.stories.d.ts +0 -1
  9. package/dist/components/form/form.component.d.ts +1 -2
  10. package/dist/components/form/form.component.spec.d.ts +1 -0
  11. package/dist/components/form/form.stories.d.ts +3745 -172
  12. package/dist/components/form/useForm.hook.d.ts +1 -2
  13. package/dist/components/form-access/formAccess.stories.d.ts +1 -2
  14. package/dist/components/form-action/formAction.stories.d.ts +0 -1
  15. package/dist/components/form-builder/formBuilder.stories.d.ts +518 -153
  16. package/dist/components/form-control/formControl.component.d.ts +2 -2
  17. package/dist/components/form-control/formControl.component.spec.d.ts +1 -0
  18. package/dist/components/form-control/formControl.stories.d.ts +57 -0
  19. package/dist/components/form-edit/formEdit.component.d.ts +0 -1
  20. package/dist/components/form-edit/formEdit.stories.d.ts +18 -19
  21. package/dist/components/form-settings/formSettings.component.d.ts +0 -1
  22. package/dist/components/form-settings/formSettings.stories.d.ts +1 -2
  23. package/dist/components/forms-table/components/formCell.component.d.ts +0 -1
  24. package/dist/components/forms-table/formsTable.component.d.ts +0 -1
  25. package/dist/components/forms-table/formsTable.stories.d.ts +0 -1
  26. package/dist/components/index.d.ts +2 -2
  27. package/dist/components/input-tags/inputTags.component.d.ts +0 -1
  28. package/dist/components/input-tags/inputTags.stories.d.ts +2 -3
  29. package/dist/components/input-text/inputText.component.d.ts +0 -1
  30. package/dist/components/input-text/inputText.stories.d.ts +0 -1
  31. package/dist/components/loader/loader.component.d.ts +1 -1
  32. package/dist/components/loader/loader.stories.d.ts +0 -1
  33. package/dist/components/modal/modal.component.d.ts +1 -1
  34. package/dist/components/modal/modal.stories.d.ts +0 -1
  35. package/dist/components/pagination/pagination.component.d.ts +0 -1
  36. package/dist/components/pagination/pagination.stories.d.ts +0 -1
  37. package/dist/components/react-component/reactComponent.component.d.ts +3 -3
  38. package/dist/components/select/select.stories.d.ts +2 -3
  39. package/dist/components/submissions-table/submissionsTable.component.d.ts +0 -1
  40. package/dist/components/submissions-table/submissionsTable.stories.d.ts +13 -14
  41. package/dist/components/table/components/defaultArrowSort.component.d.ts +0 -1
  42. package/dist/components/table/components/defaultCell.component.d.ts +0 -1
  43. package/dist/components/table/components/defaultCellHeader.component.d.ts +1 -2
  44. package/dist/components/table/components/defaultCellOperations.component.d.ts +0 -1
  45. package/dist/components/table/components/defaultOperationButton.component.d.ts +0 -1
  46. package/dist/components/table/filters/defaultColumnFilter.component.d.ts +0 -1
  47. package/dist/components/table/filters/selectColumnFilter.component.d.ts +0 -1
  48. package/dist/components/table/filters/sliderColumnFilter.component.d.ts +0 -1
  49. package/dist/components/table/index.d.ts +1 -1
  50. package/dist/components/table/table.stories.d.ts +4 -5
  51. package/dist/components/tabs/tabs.component.stories.d.ts +0 -1
  52. package/dist/hooks/useTooltip.d.ts +1 -1
  53. package/dist/index.d.ts +3 -3
  54. package/dist/index.js +7936 -7913
  55. package/dist/index.js.map +1 -1
  56. package/dist/index.modern.js +7375 -7347
  57. package/dist/index.modern.js.map +1 -1
  58. package/dist/stores/actions/index.d.ts +1 -1
  59. package/dist/stores/auth/auth.selectors.d.ts +1 -1
  60. package/dist/stores/auth/index.d.ts +4 -4
  61. package/dist/stores/index.d.ts +2 -2
  62. package/jest.config.js +6 -1
  63. package/package.json +8 -5
  64. package/src/components/__fixtures__/form.fixture.json +23 -0
  65. package/src/components/actions-table/actionsTable.component.spec.tsx +11 -11
  66. package/src/components/actions-table/actionsTable.component.tsx +8 -9
  67. package/src/components/actions-table/actionsTable.stories.tsx +1 -0
  68. package/src/components/alert/alert.component.spec.tsx +21 -19
  69. package/src/components/alert/alert.stories.tsx +1 -0
  70. package/src/components/card/card.component.spec.tsx +5 -4
  71. package/src/components/card/card.stories.tsx +1 -0
  72. package/src/components/form/form.component.spec.tsx +57 -0
  73. package/src/components/form/form.component.tsx +4 -3
  74. package/src/components/form/form.stories.tsx +157 -65
  75. package/src/components/form/useForm.hook.ts +35 -33
  76. package/src/components/form-access/formAccess.component.tsx +3 -2
  77. package/src/components/form-access/formAccess.schema.ts +1 -0
  78. package/src/components/form-access/formAccess.stories.tsx +1 -0
  79. package/src/components/form-access/formAccess.utils.ts +6 -5
  80. package/src/components/form-action/formAction.component.tsx +5 -4
  81. package/src/components/form-action/formAction.stories.tsx +225 -227
  82. package/src/components/form-builder/formBuilder.component.tsx +2 -1
  83. package/src/components/form-builder/formBuilder.stories.tsx +1 -0
  84. package/src/components/form-control/formControl.component.spec.tsx +76 -0
  85. package/src/components/form-control/formControl.component.tsx +15 -7
  86. package/src/components/form-control/formControl.stories.tsx +65 -0
  87. package/src/components/form-edit/formCtas.component.tsx +10 -9
  88. package/src/components/form-edit/formEdit.component.tsx +2 -1
  89. package/src/components/form-edit/formEdit.reducer.ts +1 -0
  90. package/src/components/form-edit/formEdit.stories.tsx +1 -0
  91. package/src/components/form-edit/formParameters.component.tsx +1 -0
  92. package/src/components/form-edit/useFormEdit.hook.ts +1 -0
  93. package/src/components/form-settings/formSettings.component.spec.tsx +7 -6
  94. package/src/components/form-settings/formSettings.component.tsx +12 -14
  95. package/src/components/form-settings/formSettings.stories.tsx +1 -0
  96. package/src/components/form-settings/formSettings.utils.ts +4 -3
  97. package/src/components/forms-table/components/formCell.component.tsx +1 -0
  98. package/src/components/forms-table/formsTable.component.tsx +23 -25
  99. package/src/components/forms-table/formsTable.stories.tsx +1 -0
  100. package/src/components/index.ts +2 -2
  101. package/src/components/input-tags/inputTags.component.tsx +7 -6
  102. package/src/components/input-tags/inputTags.stories.tsx +1 -0
  103. package/src/components/input-text/inputText.component.spec.tsx +13 -12
  104. package/src/components/input-text/inputText.component.tsx +4 -3
  105. package/src/components/input-text/inputText.stories.tsx +1 -0
  106. package/src/components/loader/loader.component.spec.tsx +6 -5
  107. package/src/components/loader/loader.component.tsx +1 -0
  108. package/src/components/loader/loader.stories.tsx +1 -0
  109. package/src/components/modal/modal.component.spec.tsx +36 -33
  110. package/src/components/modal/modal.component.tsx +3 -3
  111. package/src/components/modal/modal.stories.tsx +1 -0
  112. package/src/components/modal/removeModal.component.tsx +1 -0
  113. package/src/components/pagination/pagination.component.spec.tsx +24 -21
  114. package/src/components/pagination/pagination.component.tsx +1 -0
  115. package/src/components/pagination/pagination.stories.tsx +1 -0
  116. package/src/components/react-component/reactComponent.component.tsx +11 -7
  117. package/src/components/select/select.component.spec.tsx +17 -18
  118. package/src/components/select/select.component.tsx +3 -2
  119. package/src/components/select/select.stories.tsx +1 -0
  120. package/src/components/submissions-table/submissionsTable.component.tsx +3 -2
  121. package/src/components/submissions-table/submissionsTable.stories.tsx +1 -0
  122. package/src/components/table/components/defaultArrowSort.component.tsx +1 -0
  123. package/src/components/table/components/defaultCellHeader.component.tsx +1 -1
  124. package/src/components/table/components/defaultCellOperations.component.tsx +1 -0
  125. package/src/components/table/components/defaultOperationButton.component.tsx +1 -0
  126. package/src/components/table/filters/defaultColumnFilter.component.spec.tsx +5 -3
  127. package/src/components/table/filters/defaultColumnFilter.component.tsx +1 -0
  128. package/src/components/table/filters/selectColumnFilter.component.spec.tsx +9 -7
  129. package/src/components/table/filters/selectColumnFilter.component.tsx +1 -0
  130. package/src/components/table/index.ts +1 -1
  131. package/src/components/table/table.component.tsx +5 -4
  132. package/src/components/table/table.stories.tsx +2 -1
  133. package/src/components/table/utils/mapFormToColumns.tsx +3 -2
  134. package/src/components/table/utils/useOperations.hook.tsx +1 -0
  135. package/src/components/tabs/tabs.component.spec.tsx +6 -5
  136. package/src/components/tabs/tabs.component.stories.tsx +1 -0
  137. package/src/components/tabs/tabs.component.tsx +11 -5
  138. package/src/hooks/useTooltip.ts +1 -1
  139. package/src/index.ts +3 -4
  140. package/src/interfaces/Operation.ts +1 -0
  141. package/src/stores/action/action.actions.spec.ts +1 -0
  142. package/src/stores/action/action.actions.ts +1 -0
  143. package/src/stores/action/action.reducers.ts +1 -1
  144. package/src/stores/action-info/action-info.actions.spec.ts +1 -0
  145. package/src/stores/action-info/action-info.actions.ts +2 -1
  146. package/src/stores/action-info/action-info.reducers.ts +2 -1
  147. package/src/stores/action-info/action-info.selectors.ts +2 -1
  148. package/src/stores/actions/actions.actions.spec.ts +1 -0
  149. package/src/stores/actions/actions.actions.ts +1 -0
  150. package/src/stores/actions/actions.reducers.ts +1 -0
  151. package/src/stores/actions/index.ts +1 -1
  152. package/src/stores/auth/auth.actions.ts +1 -0
  153. package/src/stores/auth/auth.reducers.ts +1 -0
  154. package/src/stores/auth/auth.selectors.ts +1 -0
  155. package/src/stores/auth/auth.utils.tsx +3 -2
  156. package/src/stores/auth/getAccess.action.spec.ts +1 -0
  157. package/src/stores/auth/getAccess.action.ts +3 -2
  158. package/src/stores/auth/getProjectAccess.action.ts +1 -0
  159. package/src/stores/auth/index.ts +4 -4
  160. package/src/stores/auth/initAuth.action.spec.ts +1 -0
  161. package/src/stores/auth/initAuth.action.ts +1 -0
  162. package/src/stores/auth/logout.action.spec.ts +2 -0
  163. package/src/stores/auth/logout.action.ts +1 -0
  164. package/src/stores/auth/setUser.action.spec.ts +1 -0
  165. package/src/stores/auth/setUser.action.ts +1 -0
  166. package/src/stores/form/form.actions.spec.ts +1 -0
  167. package/src/stores/form/form.actions.ts +1 -0
  168. package/src/stores/form/form.reducers.ts +1 -0
  169. package/src/stores/form/form.selectors.ts +1 -1
  170. package/src/stores/forms/forms.actions.spec.ts +1 -0
  171. package/src/stores/forms/forms.actions.ts +1 -0
  172. package/src/stores/forms/forms.reducers.ts +1 -0
  173. package/src/stores/index.ts +3 -2
  174. package/src/stores/root/root.selectors.ts +3 -3
  175. package/src/stores/submission/submission.actions.spec.ts +1 -0
  176. package/src/stores/submission/submission.actions.ts +1 -0
  177. package/src/stores/submission/submission.reducers.ts +1 -0
  178. package/src/stores/submissions/submissions.actions.spec.ts +1 -0
  179. package/src/stores/submissions/submissions.actions.ts +1 -0
  180. package/src/stores/submissions/submissions.reducers.ts +1 -0
  181. package/tsconfig.json +10 -27
  182. package/tsconfig.node.json +8 -0
  183. package/craco.config.js +0 -11
  184. package/tsconfig.test.json +0 -6
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import { FilterProps } from "react-table";
3
+
3
4
  import { Select } from "../../select/select.component";
4
5
 
5
6
  export function SelectColumnFilter<D extends Record<string, unknown> = {}>({ column }: FilterProps<D>) {
@@ -1,4 +1,3 @@
1
- export * from "./utils/useOperations.hook";
2
1
  export * from "./components/defaultArrowSort.component";
3
2
  export * from "./components/defaultCell.component";
4
3
  export * from "./components/defaultCellHeader.component";
@@ -9,3 +8,4 @@ export * from "./filters/defaultColumnFilter.component";
9
8
  export * from "./filters/selectColumnFilter.component";
10
9
  export * from "./filters/sliderColumnFilter.component";
11
10
  export * from "./table.component";
11
+ export * from "./utils/useOperations.hook";
@@ -2,6 +2,7 @@ import classnames from "classnames";
2
2
  import noop from "lodash/noop";
3
3
  import React, { PropsWithChildren } from "react";
4
4
  import { CellProps, FilterProps, Renderer, TableOptions, useFilters, useGroupBy, usePagination, useSortBy, useTable } from "react-table";
5
+
5
6
  import { OnClickOperation, Operation, QueryOptions } from "../../interfaces";
6
7
  import { Pagination as DefaultPagination } from "../pagination/pagination.component";
7
8
  import { DefaultArrowSort } from "./components/defaultArrowSort.component";
@@ -189,12 +190,12 @@ export function Table<Data extends object = any>(props: PropsWithChildren<TableP
189
190
  >
190
191
  <thead>
191
192
  {tableInstance.headerGroups.map((headerGroup, i) => (
192
- <tr key={`tableInstance.headerGroups${i}`} {...headerGroup.getHeaderGroupProps()}>
193
+ <tr {...headerGroup.getHeaderGroupProps()} key={`tableInstance.headerGroups${i}`}>
193
194
  {headerGroup.headers.map((column) => (
194
195
  <th
195
- key={`tableInstance.headers.column.${column.id}`}
196
196
  /* className='text-left py-2 align-top' */
197
197
  {...column.getHeaderProps()}
198
+ key={`tableInstance.headers.column.${column.id}`}
198
199
  >
199
200
  <CellHeader column={column} />
200
201
  </th>
@@ -207,14 +208,14 @@ export function Table<Data extends object = any>(props: PropsWithChildren<TableP
207
208
  {tableInstance.page.map((row) => {
208
209
  tableInstance.prepareRow(row);
209
210
  return (
210
- <tr key={`tableInstance.page.${row.id}`} onClick={() => _onClick(row.original, "row")} {...row.getRowProps()}>
211
+ <tr onClick={() => _onClick(row.original, "row")} {...row.getRowProps()} key={`tableInstance.page.${row.id}`}>
211
212
  {row.cells.map((cell, i) => {
212
213
  const { hidden, colspan } = cell.column as any;
213
214
  if (hidden) {
214
215
  return null;
215
216
  }
216
217
  return (
217
- <td key={`tableInstance.page.cells.${cell.value || "value"}.${i}`} colSpan={colspan} {...cell.getCellProps()}>
218
+ <td colSpan={colspan} {...cell.getCellProps()} key={`tableInstance.page.cells.${cell.value || "value"}.${i}`}>
218
219
  {cell.render("Cell")}
219
220
  </td>
220
221
  );
@@ -1,9 +1,10 @@
1
1
  import React from "react";
2
+
3
+ import { mapPagination } from "../../utils/mapPagination";
2
4
  import formSchema from "../__fixtures__/form-schema.json";
3
5
  import formSubmissions from "../__fixtures__/form-submissions.json";
4
6
  import { Table } from "./table.component";
5
7
  import { mapFormToColumns } from "./utils/mapFormToColumns";
6
- import { mapPagination } from "../../utils/mapPagination";
7
8
 
8
9
  export default {
9
10
  title: "ReactFormio/Table",
@@ -1,7 +1,8 @@
1
- import React from "react";
2
1
  import { Components, ExtendedComponentSchema } from "formiojs";
3
2
  import FormioUtils from "formiojs/utils";
3
+ import React from "react";
4
4
  import { Column } from "react-table";
5
+
5
6
  import { FormSchema } from "../../../interfaces";
6
7
  import { DefaultCell } from "../components/defaultCell.component";
7
8
  import { SelectColumnFilter } from "../filters/selectColumnFilter.component";
@@ -11,7 +12,7 @@ export function mapFormToColumns(form: FormSchema): Column[] {
11
12
 
12
13
  FormioUtils.eachComponent(form.components, (component: ExtendedComponentSchema) => {
13
14
  if (component.tableView && component.key) {
14
- const cmp: any = Components.create(component, null, null, true);
15
+ const cmp: any = Components.create(component, {}, null, true);
15
16
 
16
17
  const column: Column = {
17
18
  Header: component.label || component.title || component.key,
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import { Hooks } from "react-table";
3
+
3
4
  import { Operation } from "../../../interfaces";
4
5
  import { DefaultCellOperations } from "../components/defaultCellOperations.component";
5
6
 
@@ -1,7 +1,8 @@
1
+ import { fireEvent, render, screen } from "@testing-library/react";
1
2
  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";
3
+
4
+ import { Tabs } from "./tabs.component";
5
+ import { Sandbox } from "./tabs.component.stories";
5
6
 
6
7
  describe("tabs", () => {
7
8
  it("should display the tabs component and children", () => {
@@ -20,7 +21,7 @@ describe("tabs", () => {
20
21
  }
21
22
  ];
22
23
 
23
- render(<Sandbox {...Sandbox.args} items={items}/>);
24
+ render(<Sandbox {...Sandbox.args} items={items} />);
24
25
 
25
26
  const tabsComponent = screen.getByTestId("tabs-comp");
26
27
 
@@ -67,7 +68,7 @@ describe("tabs", () => {
67
68
  ];
68
69
  const onClick = jest.fn();
69
70
 
70
- render(<Tabs items={items} onClick={onClick}/>);
71
+ render(<Tabs items={items} onClick={onClick} />);
71
72
 
72
73
  const buttonsTab = screen.getAllByTitle("button-tab");
73
74
  const chevronLeftButtonTab = buttonsTab[0];
@@ -1,4 +1,5 @@
1
1
  import React, { useState } from "react";
2
+
2
3
  import { Tabs } from "./tabs.component";
3
4
 
4
5
  const useTabs = (args: any) => {
@@ -1,12 +1,16 @@
1
1
  import classnames from "classnames";
2
2
  import React, { PropsWithChildren } from "react";
3
+
3
4
  import { iconClass } from "../../utils/iconClass";
4
5
 
5
6
  export function ButtonTab({ icon, back, onClick, isActive, reverse, children, className, after }: PropsWithChildren<any>) {
6
7
  return (
7
- <div title={'button-wrapper'} className={classnames("tw-tabs__button-wrapper", isActive ? "-active" : "", back ? "-back" : "", className)}>
8
+ <div
9
+ title={"button-wrapper"}
10
+ className={classnames("tw-tabs__button-wrapper", isActive ? "-active" : "", back ? "-back" : "", className)}
11
+ >
8
12
  <button
9
- title={'button-tab'}
13
+ title={"button-tab"}
10
14
  className={classnames("tw-tabs__button", reverse ? "-reverse" : "", isActive ? "-active" : "", back ? "-back" : "")}
11
15
  onClick={onClick}
12
16
  >
@@ -51,7 +55,7 @@ export function Tabs({
51
55
  ...additionalProps
52
56
  }: PropsWithChildren<TabsProps>) {
53
57
  return (
54
- <div data-testid={'tabs-comp'} className={`tw-tabs ${className}`} style={style}>
58
+ <div data-testid={"tabs-comp"} className={`tw-tabs ${className}`} style={style}>
55
59
  <div>
56
60
  <nav className='tw-tabs__header'>
57
61
  <div className='tw-tabs__header-wrapper'>
@@ -71,7 +75,7 @@ export function Tabs({
71
75
  {...additionalProps}
72
76
  {...item}
73
77
  >
74
- {i18n(item.label)}
78
+ {i18n(item.label || "")}
75
79
  </Button>
76
80
  );
77
81
  })}
@@ -80,7 +84,9 @@ export function Tabs({
80
84
  </nav>
81
85
  {HeaderChildren && <HeaderChildren {...additionalProps} current={current} />}
82
86
  </div>
83
- <div title={"tab-body"} className={"tw-tabs__body"}>{children}</div>
87
+ <div title={"tab-body"} className={"tw-tabs__body"}>
88
+ {children}
89
+ </div>
84
90
  </div>
85
91
  );
86
92
  }
@@ -2,7 +2,7 @@ import { useEffect, useRef } from "react";
2
2
  import Tooltip, { Options } from "tooltip.js";
3
3
 
4
4
  export function useTooltip(options: Options) {
5
- const ref = useRef();
5
+ const ref = useRef<any>();
6
6
 
7
7
  useEffect(() => {
8
8
  ref.current && new Tooltip(ref.current as any, options);
package/src/index.ts CHANGED
@@ -11,11 +11,10 @@ export {
11
11
  // editFormUtils,
12
12
  };
13
13
 
14
- export * from "./stores";
15
- export * from "./interfaces";
16
14
  export * from "./components";
17
15
  export * from "./hooks/useTooltip";
16
+ export * from "./interfaces";
17
+ export * from "./stores";
18
18
  export * from "./utils/iconClass";
19
19
  export * from "./utils/url";
20
-
21
- export { Components, Formio, Utils, Templates } from "formiojs";
20
+ export { Components, Formio, Templates, Utils } from "formiojs";
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+
2
3
  import { OperationButtonProps } from "../components/table/components/defaultOperationButton.component";
3
4
 
4
5
  export type PermissionsResolver<Data = any> = (data: Data, ctx: any) => void;
@@ -1,4 +1,5 @@
1
1
  import { Formio } from "formiojs";
2
+
2
3
  import { getActionInfo } from "../action-info";
3
4
  import {
4
5
  clearActionError,
@@ -2,6 +2,7 @@ import { createAction } from "@tsed/redux-utils";
2
2
  import { Formio } from "formiojs";
3
3
  import get from "lodash/get";
4
4
  import noop from "lodash/noop";
5
+
5
6
  import { getActionUrl } from "../../utils/url";
6
7
  import { getActionInfo } from "../action-info";
7
8
  import { ACTION } from "./action.constant";
@@ -1,6 +1,6 @@
1
1
  import { createReducer, InitialStateCreator } from "@tsed/redux-utils";
2
- import { ActionSchema } from "../../interfaces";
3
2
 
3
+ import { ActionSchema } from "../../interfaces";
4
4
  import { clearActionError, failAction, receiveAction, requestAction, resetAction, sendAction } from "./action.actions";
5
5
  import { ACTION } from "./action.constant";
6
6
 
@@ -1,4 +1,5 @@
1
1
  import { Formio } from "formiojs";
2
+
2
3
  import { getActionInfo, receiveActionInfo, requestActionInfo } from "./action-info.actions";
3
4
 
4
5
  jest.mock("formiojs/Formio");
@@ -1,6 +1,7 @@
1
1
  import { createAction } from "@tsed/redux-utils";
2
- import noop from "lodash/noop";
3
2
  import { Formio } from "formiojs";
3
+ import noop from "lodash/noop";
4
+
4
5
  import { getFormUrl } from "../../utils/url";
5
6
  import { ACTION_INFO } from "./action-info.constant";
6
7
 
@@ -1,4 +1,5 @@
1
- import { InitialStateCreator, createReducer } from "@tsed/redux-utils";
1
+ import { createReducer, InitialStateCreator } from "@tsed/redux-utils";
2
+
2
3
  import { ActionSchema } from "../../interfaces";
3
4
  import { failActionInfo, receiveActionInfo, requestActionInfo, resetActionInfo } from "./action-info.actions";
4
5
  import { ACTION_INFO } from "./action-info.constant";
@@ -3,4 +3,5 @@ import { selectRoot } from "../root";
3
3
  import { ACTION_INFO } from "./action-info.constant";
4
4
  import { ActionInfoState } from "./action-info.reducers";
5
5
 
6
- export const selectActionInfo = (state: Record<string, any>): Partial<ActionSchema> => selectRoot<ActionInfoState>(ACTION_INFO, state).data;
6
+ export const selectActionInfo = (state: Record<string, any>): Partial<ActionSchema> =>
7
+ selectRoot<ActionInfoState>(ACTION_INFO, state).data!;
@@ -1,4 +1,5 @@
1
1
  import { Formio } from "formiojs";
2
+
2
3
  import { getActions, receiveActions, requestActions, resetActions } from "./actions.actions";
3
4
 
4
5
  jest.mock("formiojs");
@@ -1,6 +1,7 @@
1
1
  import { createAction } from "@tsed/redux-utils";
2
2
  import { Formio } from "formiojs";
3
3
  import noop from "lodash/noop";
4
+
4
5
  import { getFormUrl } from "../../utils/url";
5
6
  import { ACTIONS } from "./actions.constant";
6
7
 
@@ -1,4 +1,5 @@
1
1
  import { createReducer, InitialStateCreator } from "@tsed/redux-utils";
2
+
2
3
  import { ActionInfoSchema, ActionSchema } from "../../interfaces";
3
4
  import { failActions, receiveActions, requestActions, resetActions } from "./actions.actions";
4
5
  import { ACTIONS } from "./actions.constant";
@@ -1,4 +1,4 @@
1
- export * from "./actions.constant";
2
1
  export * from "./actions.actions";
2
+ export * from "./actions.constant";
3
3
  export * from "./actions.reducers";
4
4
  export * from "./actions.selectors";
@@ -1,4 +1,5 @@
1
1
  import { createAction } from "@tsed/redux-utils";
2
+
2
3
  import { FormSchema, RoleSchema, Submission } from "../../interfaces";
3
4
 
4
5
  export const requestUser = createAction();
@@ -1,4 +1,5 @@
1
1
  import { createReducer } from "@tsed/redux-utils";
2
+
2
3
  import { FormSchema, Submission } from "../../interfaces";
3
4
  import { RoleSchema } from "../../interfaces/RoleSchema";
4
5
  import {
@@ -1,4 +1,5 @@
1
1
  import get from "lodash/get";
2
+
2
3
  import { RoleSchema, Submission } from "../../interfaces";
3
4
  import { selectRoot } from "../root";
4
5
  import { AUTH } from "./auth.constant";
@@ -1,4 +1,5 @@
1
1
  import get from "lodash/get";
2
+
2
3
  import { FormSchema } from "../../interfaces/FormSchema";
3
4
  import { AuthState } from "./auth.reducers";
4
5
 
@@ -7,7 +8,7 @@ export function hasRole(auth: AuthState, role: string): boolean {
7
8
  }
8
9
 
9
10
  export function hasRoles(auth: AuthState, roles: string[]): boolean {
10
- roles = [].concat(roles);
11
+ roles = ([] as string[]).concat(roles);
11
12
 
12
13
  return !!roles.find((role) => hasRole(auth, role));
13
14
  }
@@ -29,7 +30,7 @@ export function checkRoleFormAccess(auth: AuthState, form?: Partial<FormSchema>,
29
30
  return true;
30
31
  }
31
32
 
32
- return !!(roles.includes("owner") && get(form, "owner") === get(auth, "user._id"));
33
+ return roles.includes("owner") && get(form, "owner") === get(auth, "user._id");
33
34
  }
34
35
 
35
36
  return true;
@@ -1,4 +1,5 @@
1
1
  import { Formio } from "formiojs";
2
+
2
3
  import { formAccessUser, submissionAccessUser, userForms, userRoles } from "./auth.actions";
3
4
  import { AUTH } from "./auth.constant";
4
5
  import { getAccess } from "./getAccess.action";
@@ -1,4 +1,5 @@
1
1
  import { Formio } from "formiojs";
2
+
2
3
  import { RoleSchema } from "../../interfaces";
3
4
  import { FormSchema } from "../../interfaces/FormSchema";
4
5
  import { formAccessUser, submissionAccessUser, userForms, userRoles } from "./auth.actions";
@@ -8,7 +9,7 @@ function transformSubmissionAccess(forms: Record<string, FormSchema>) {
8
9
  return Object.values(forms).reduce(
9
10
  (result, form) => ({
10
11
  ...result,
11
- [form.name]: form.submissionAccess.reduce(
12
+ [form.name as string]: form.submissionAccess.reduce(
12
13
  (formSubmissionAccess: any, access: any) => ({
13
14
  ...formSubmissionAccess,
14
15
  [access.type]: access.roles
@@ -24,7 +25,7 @@ function transformFormAccess(forms: Record<string, FormSchema>) {
24
25
  return Object.values(forms).reduce(
25
26
  (result, form) => ({
26
27
  ...result,
27
- [form.name]: form.access.reduce(
28
+ [form.name as string]: form.access.reduce(
28
29
  (formAccess: any, access: any) => ({
29
30
  ...formAccess,
30
31
  [access.type]: access.roles
@@ -1,4 +1,5 @@
1
1
  import { Formio } from "formiojs";
2
+
2
3
  import { projectAccessUser } from "./auth.actions";
3
4
  import { AUTH } from "./auth.constant";
4
5
 
@@ -1,10 +1,10 @@
1
- export * from "./auth.constant";
2
- export * from "./auth.utils";
3
1
  export * from "./auth.actions";
2
+ export * from "./auth.constant";
4
3
  export * from "./auth.reducers";
5
4
  export * from "./auth.selectors";
6
- export * from "./getProjectAccess.action";
5
+ export * from "./auth.utils";
7
6
  export * from "./getAccess.action";
7
+ export * from "./getProjectAccess.action";
8
+ export * from "./initAuth.action";
8
9
  export * from "./logout.action";
9
10
  export * from "./setUser.action";
10
- export * from "./initAuth.action";
@@ -1,4 +1,5 @@
1
1
  import { Formio } from "formiojs";
2
+
2
3
  import { requestUser } from "./auth.actions";
3
4
  import { AUTH } from "./auth.constant";
4
5
  import { getAccess } from "./getAccess.action";
@@ -1,5 +1,6 @@
1
1
  import { Formio } from "formiojs";
2
2
  import noop from "lodash/noop";
3
+
3
4
  import { failUser, requestUser } from "./auth.actions";
4
5
  import { AUTH } from "./auth.constant";
5
6
  import { getAccess } from "./getAccess.action";
@@ -1,9 +1,11 @@
1
1
  import { Formio } from "formiojs";
2
+
2
3
  import { logoutUser } from "./auth.actions";
3
4
  import { AUTH } from "./auth.constant";
4
5
  import { logout } from "./logout.action";
5
6
 
6
7
  jest.mock("./auth.actions");
8
+ jest.mock("formiojs");
7
9
 
8
10
  describe("logout()", () => {
9
11
  beforeEach(() => {
@@ -1,4 +1,5 @@
1
1
  import { Formio } from "formiojs";
2
+
2
3
  import { logoutUser } from "./auth.actions";
3
4
  import { AUTH } from "./auth.constant";
4
5
 
@@ -1,4 +1,5 @@
1
1
  import { Formio } from "formiojs";
2
+
2
3
  import { receiveUser } from "./auth.actions";
3
4
  import { AUTH } from "./auth.constant";
4
5
  import { setUser } from "./setUser.action";
@@ -1,4 +1,5 @@
1
1
  import { Formio } from "formiojs";
2
+
2
3
  import { receiveUser } from "./auth.actions";
3
4
  import { AUTH } from "./auth.constant";
4
5
 
@@ -1,4 +1,5 @@
1
1
  import { Formio } from "formiojs";
2
+
2
3
  import { deleteForm, failForm, getForm, receiveForm, requestForm, resetForm, saveForm, sendForm } from "./form.actions";
3
4
 
4
5
  jest.mock("formiojs");
@@ -1,6 +1,7 @@
1
1
  import { createAction } from "@tsed/redux-utils";
2
2
  import { Formio } from "formiojs";
3
3
  import noop from "lodash/noop";
4
+
4
5
  import { FormSchema } from "../../interfaces";
5
6
  import { getFormUrl } from "../../utils/url";
6
7
  import { getActions } from "../actions";
@@ -1,4 +1,5 @@
1
1
  import { createReducer, InitialStateCreator } from "@tsed/redux-utils";
2
+
2
3
  import { FormSchema } from "../../interfaces";
3
4
  import { clearFormError, failForm, receiveForm, requestForm, resetForm, sendForm } from "./form.actions";
4
5
 
@@ -2,4 +2,4 @@ import { FormSchema } from "../../interfaces";
2
2
  import { selectRoot } from "../root";
3
3
  import { FormState } from "./form.reducers";
4
4
 
5
- export const selectForm = (name: string, state: any): Partial<FormSchema> => selectRoot<FormState>(name, state).data;
5
+ export const selectForm = (name: string, state: any): Partial<FormSchema> => selectRoot<FormState>(name, state).data!;
@@ -1,4 +1,5 @@
1
1
  import { Formio } from "formiojs";
2
+
2
3
  import { mapRequestParams } from "../../utils/mapRequestParams";
3
4
  import { failForms, getForms, receiveForms, requestForms } from "./forms.actions";
4
5
 
@@ -1,6 +1,7 @@
1
1
  import { createAction } from "@tsed/redux-utils";
2
2
  import { Formio } from "formiojs";
3
3
  import noop from "lodash/noop";
4
+
4
5
  import { FormSchema } from "../../interfaces";
5
6
  import type { RequestParamsOptions } from "../../utils/mapRequestParams";
6
7
  import { mapRequestParams } from "../../utils/mapRequestParams";
@@ -1,4 +1,5 @@
1
1
  import { createReducer } from "@tsed/redux-utils";
2
+
2
3
  import { FormSchema } from "../../interfaces";
3
4
  import { failForms, receiveForms, requestForms, resetForms } from "./forms.actions";
4
5
 
@@ -1,4 +1,5 @@
1
1
  import { combine } from "@tsed/redux-utils";
2
+
2
3
  import { actionReducer } from "./action";
3
4
  import { actionInfoReducer } from "./action-info";
4
5
  import { actionsReducer } from "./actions";
@@ -8,15 +9,15 @@ import { formsReducer } from "./forms";
8
9
  import { submissionReducer } from "./submission";
9
10
  import { submissionsReducer } from "./submissions";
10
11
 
11
- export * from "./auth";
12
12
  export * from "./action";
13
13
  export * from "./action-info";
14
14
  export * from "./actions";
15
+ export * from "./auth";
15
16
  export * from "./form";
16
17
  export * from "./forms";
18
+ export * from "./root";
17
19
  export * from "./submission";
18
20
  export * from "./submissions";
19
- export * from "./root";
20
21
 
21
22
  export const defaultFormioReducer = combine(
22
23
  authReducer,
@@ -2,7 +2,7 @@ import get from "lodash/get";
2
2
 
3
3
  export function selectRoot<State = Record<string, any>>(name: string): (state: Record<string, any>) => State;
4
4
  export function selectRoot<State = Record<string, any>>(name: string, state: Record<string, any>): State;
5
- export function selectRoot<State = Record<string, any>>(name: string, state?: Record<string, any>): any {
5
+ export function selectRoot<State = Record<string, any>>(name: string, state?: Record<string, any>): State & any {
6
6
  if (state) {
7
7
  return state[name];
8
8
  }
@@ -10,9 +10,9 @@ export function selectRoot<State = Record<string, any>>(name: string, state?: Re
10
10
  return (state: Record<string, any>) => selectRoot(name, state);
11
11
  }
12
12
 
13
- export const selectError = (name: string, state: Record<string, any>): null | Error => get(selectRoot(name, state), "error");
13
+ export const selectError = (name: string, state: Record<string, any>): null | Error => get(selectRoot(name, state)!, "error");
14
14
 
15
- export const selectIsActive = (name: string, state: Record<string, any>): boolean => get(selectRoot(name, state), "isActive");
15
+ export const selectIsActive = (name: string, state: Record<string, any>): boolean => get(selectRoot(name, state)!, "isActive");
16
16
 
17
17
  export function oneOfIsActive(...names: string[]) {
18
18
  return (state: any) => {
@@ -1,4 +1,5 @@
1
1
  import { Formio } from "formiojs";
2
+
2
3
  import {
3
4
  clearSubmissionError,
4
5
  deleteSubmission,
@@ -1,6 +1,7 @@
1
1
  import { createAction } from "@tsed/redux-utils";
2
2
  import { Formio } from "formiojs";
3
3
  import noop from "lodash/noop";
4
+
4
5
  import { Submission } from "../../interfaces";
5
6
  import { getSubmissionUrl } from "../../utils/url";
6
7
 
@@ -1,4 +1,5 @@
1
1
  import { createReducer, InitialStateCreator } from "@tsed/redux-utils";
2
+
2
3
  import { Submission } from "../../interfaces";
3
4
  import {
4
5
  clearSubmissionError,
@@ -1,4 +1,5 @@
1
1
  import { Formio } from "formiojs";
2
+
2
3
  import { mapRequestParams } from "../../utils/mapRequestParams";
3
4
  import { failSubmissions, getSubmissions, receiveSubmissions, requestSubmissions } from "./submissions.actions";
4
5
 
@@ -1,6 +1,7 @@
1
1
  import { createAction } from "@tsed/redux-utils";
2
2
  import { Formio } from "formiojs";
3
3
  import noop from "lodash/noop";
4
+
4
5
  import { mapRequestParams } from "../../utils/mapRequestParams";
5
6
  import { getSubmissionUrl } from "../../utils/url";
6
7
  import { selectSubmissionsParameters } from "./submissions.selectors";
@@ -1,4 +1,5 @@
1
1
  import { createReducer } from "@tsed/redux-utils";
2
+
2
3
  import { Submission } from "../../interfaces/Submission";
3
4
  import { failSubmissions, receiveSubmissions, requestSubmissions, resetSubmissions } from "./submissions.actions";
4
5