@tsed/react-formio 1.11.2 → 1.13.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.
Files changed (145) 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/form/form.component.d.ts +2 -0
  6. package/dist/components/form/form.stories.d.ts +37 -0
  7. package/dist/components/form/useForm.hook.d.ts +1 -0
  8. package/dist/components/form-action/formAction.stories.d.ts +90 -414
  9. package/dist/components/input-text/inputText.component.d.ts +1 -1
  10. package/dist/components/input-text/inputText.component.spec.d.ts +1 -0
  11. package/dist/components/select/select.component.spec.d.ts +1 -0
  12. package/dist/components/tabs/tabs.component.spec.d.ts +1 -0
  13. package/dist/index.js +110 -33
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.modern.js +83 -32
  16. package/dist/index.modern.js.map +1 -1
  17. package/jest.config.js +1 -1
  18. package/package.json +5 -9
  19. package/readme.md +114 -86
  20. package/src/components/__fixtures__/form-schema.json +10 -42
  21. package/src/components/__fixtures__/form.fixture.json +1 -1
  22. package/src/components/actions-table/actionsTable.component.spec.tsx +4 -13
  23. package/src/components/actions-table/actionsTable.component.tsx +3 -11
  24. package/src/components/alert/alert.component.spec.tsx +97 -0
  25. package/src/components/alert/alert.component.tsx +2 -8
  26. package/src/components/alert/alert.stories.tsx +17 -0
  27. package/src/components/card/card.component.tsx +1 -5
  28. package/src/components/form/form.component.tsx +4 -8
  29. package/src/components/form/form.stories.tsx +66 -2
  30. package/src/components/form/useForm.hook.ts +29 -14
  31. package/src/components/form-access/formAccess.component.tsx +19 -82
  32. package/src/components/form-access/formAccess.schema.ts +7 -23
  33. package/src/components/form-access/formAccess.stories.tsx +2 -9
  34. package/src/components/form-access/formAccess.utils.spec.ts +4 -22
  35. package/src/components/form-access/formAccess.utils.ts +7 -29
  36. package/src/components/form-action/formAction.component.tsx +3 -19
  37. package/src/components/form-action/formAction.stories.tsx +251 -672
  38. package/src/components/form-builder/formBuilder.component.tsx +4 -13
  39. package/src/components/form-builder/formBuilder.stories.tsx +12 -24
  40. package/src/components/form-control/formControl.component.tsx +2 -8
  41. package/src/components/form-edit/formCtas.component.tsx +5 -23
  42. package/src/components/form-edit/formEdit.component.tsx +2 -20
  43. package/src/components/form-edit/formEdit.reducer.ts +2 -8
  44. package/src/components/form-edit/formEdit.stories.tsx +3 -15
  45. package/src/components/form-edit/formParameters.component.tsx +3 -20
  46. package/src/components/form-edit/useFormEdit.hook.ts +2 -9
  47. package/src/components/form-settings/formSettings.component.spec.tsx +2 -9
  48. package/src/components/form-settings/formSettings.component.tsx +6 -34
  49. package/src/components/form-settings/formSettings.stories.tsx +1 -6
  50. package/src/components/form-settings/formSettings.utils.spec.ts +1 -4
  51. package/src/components/form-settings/formSettings.utils.ts +2 -7
  52. package/src/components/forms-table/components/formCell.component.tsx +2 -6
  53. package/src/components/forms-table/formsTable.component.tsx +2 -7
  54. package/src/components/input-tags/inputTags.component.tsx +10 -34
  55. package/src/components/input-tags/inputTags.stories.tsx +4 -14
  56. package/src/components/input-text/inputText.component.spec.tsx +56 -0
  57. package/src/components/input-text/inputText.component.tsx +3 -4
  58. package/src/components/input-text/inputText.stories.tsx +6 -26
  59. package/src/components/loader/loader.component.tsx +2 -11
  60. package/src/components/modal/modal.component.spec.tsx +8 -14
  61. package/src/components/modal/modal.component.tsx +6 -27
  62. package/src/components/modal/modal.stories.tsx +1 -5
  63. package/src/components/modal/removeModal.component.tsx +4 -22
  64. package/src/components/pagination/pagination.component.spec.tsx +12 -38
  65. package/src/components/pagination/pagination.component.tsx +8 -41
  66. package/src/components/pagination/pagination.stories.tsx +1 -5
  67. package/src/components/react-component/reactComponent.component.tsx +3 -11
  68. package/src/components/select/select.component.spec.tsx +86 -0
  69. package/src/components/select/select.component.tsx +11 -15
  70. package/src/components/select/select.stories.tsx +6 -26
  71. package/src/components/submissions-table/submissionsTable.component.tsx +1 -3
  72. package/src/components/submissions-table/submissionsTable.stories.tsx +1 -1
  73. package/src/components/table/components/defaultArrowSort.component.tsx +1 -10
  74. package/src/components/table/components/defaultCell.component.tsx +1 -4
  75. package/src/components/table/components/defaultCellHeader.component.tsx +4 -14
  76. package/src/components/table/components/defaultCellOperations.component.tsx +14 -25
  77. package/src/components/table/components/defaultOperationButton.component.tsx +2 -10
  78. package/src/components/table/filters/defaultColumnFilter.component.spec.tsx +1 -1
  79. package/src/components/table/filters/selectColumnFilter.component.spec.tsx +2 -10
  80. package/src/components/table/filters/selectColumnFilter.component.tsx +2 -6
  81. package/src/components/table/table.component.tsx +13 -53
  82. package/src/components/table/table.stories.tsx +1 -1
  83. package/src/components/table/utils/getPageNumbers.ts +3 -11
  84. package/src/components/table/utils/mapFormToColumns.tsx +14 -22
  85. package/src/components/table/utils/useOperations.hook.tsx +2 -12
  86. package/src/components/tabs/tabs.component.spec.tsx +86 -0
  87. package/src/components/tabs/tabs.component.stories.tsx +2 -9
  88. package/src/components/tabs/tabs.component.tsx +9 -43
  89. package/src/interfaces/Operation.ts +1 -4
  90. package/src/react-table.d.ts +9 -28
  91. package/src/stores/action/action.actions.ts +31 -33
  92. package/src/stores/action/action.reducers.spec.ts +1 -8
  93. package/src/stores/action/action.reducers.ts +1 -8
  94. package/src/stores/action/action.selectors.ts +1 -2
  95. package/src/stores/action-info/action-info.actions.spec.ts +1 -5
  96. package/src/stores/action-info/action-info.actions.ts +16 -19
  97. package/src/stores/action-info/action-info.reducers.spec.ts +1 -6
  98. package/src/stores/action-info/action-info.reducers.ts +1 -6
  99. package/src/stores/action-info/action-info.selectors.ts +1 -4
  100. package/src/stores/actions/actions.actions.spec.ts +1 -6
  101. package/src/stores/actions/actions.actions.ts +16 -19
  102. package/src/stores/actions/actions.reducers.spec.ts +1 -6
  103. package/src/stores/actions/actions.reducers.ts +1 -6
  104. package/src/stores/actions/actions.selectors.ts +2 -4
  105. package/src/stores/auth/auth.reducers.ts +1 -4
  106. package/src/stores/auth/auth.selectors.spec.ts +1 -5
  107. package/src/stores/auth/auth.selectors.ts +3 -6
  108. package/src/stores/auth/auth.utils.tsx +2 -8
  109. package/src/stores/auth/getAccess.action.spec.ts +11 -54
  110. package/src/stores/auth/getAccess.action.ts +1 -6
  111. package/src/stores/auth/initAuth.action.ts +15 -17
  112. package/src/stores/form/form.actions.spec.ts +8 -39
  113. package/src/stores/form/form.actions.ts +55 -64
  114. package/src/stores/form/form.reducers.spec.ts +1 -7
  115. package/src/stores/form/form.reducers.ts +1 -8
  116. package/src/stores/form/form.selectors.ts +1 -2
  117. package/src/stores/forms/forms.actions.spec.ts +5 -18
  118. package/src/stores/forms/forms.actions.ts +17 -21
  119. package/src/stores/forms/forms.reducers.spec.ts +1 -6
  120. package/src/stores/forms/forms.reducers.ts +2 -13
  121. package/src/stores/forms/forms.selectors.ts +2 -4
  122. package/src/stores/index.spec.ts +6 -9
  123. package/src/stores/root/root.selectors.spec.ts +1 -6
  124. package/src/stores/root/root.selectors.ts +6 -24
  125. package/src/stores/submission/submission.actions.spec.ts +11 -33
  126. package/src/stores/submission/submission.actions.ts +57 -66
  127. package/src/stores/submission/submission.reducers.spec.ts +17 -27
  128. package/src/stores/submission/submission.reducers.ts +1 -4
  129. package/src/stores/submission/submission.selectors.ts +1 -4
  130. package/src/stores/submissions/submissions.actions.spec.ts +5 -18
  131. package/src/stores/submissions/submissions.actions.ts +17 -26
  132. package/src/stores/submissions/submissions.reducers.spec.ts +3 -12
  133. package/src/stores/submissions/submissions.reducers.ts +3 -17
  134. package/src/stores/submissions/submissions.selectors.spec.ts +1 -4
  135. package/src/stores/submissions/submissions.selectors.ts +2 -4
  136. package/src/utils/getEventValue.ts +1 -4
  137. package/src/utils/iconClass.ts +2 -10
  138. package/src/utils/mapPagination.ts +1 -6
  139. package/src/utils/mapRequestParams.ts +2 -12
  140. package/src/utils/url.test.ts +4 -12
  141. package/src/utils/url.ts +2 -7
  142. package/tsconfig.json +4 -12
  143. package/tsconfig.test.json +1 -1
  144. package/.eslintrc +0 -47
  145. package/.prettierrc +0 -10
package/jest.config.js CHANGED
@@ -1 +1 @@
1
- module.exports = require("@tsed/config/jest.config");
1
+ module.exports = require("@tsed/config/jest.config")("react-formio");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/react-formio",
3
- "version": "1.11.2",
3
+ "version": "1.13.1",
4
4
  "description": "Provide a react formio wrapper. Written in TypeScript.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.modern.js",
@@ -8,13 +8,10 @@
8
8
  "scripts": {
9
9
  "test": "cross-env CI=1 yarn craco test --coverage",
10
10
  "build": "microbundle --no-compress --format modern,cjs --jsx React.createElement",
11
- "watch": "microbundle watch --no-compress --format modern,cjs --jsx React.createElement",
12
- "lint:fix": "yarn lint --fix",
13
- "lint": "yarn eslint --config .eslintrc --cache --quiet \"./src/**/*.{ts,tsx}\"",
14
- "prettier": "prettier '{src,test}/**/*.{ts,tsx}' --write"
11
+ "watch": "microbundle watch --no-compress --format modern,cjs --jsx React.createElement"
15
12
  },
16
13
  "dependencies": {
17
- "@tsed/redux-utils": "1.11.2",
14
+ "@tsed/redux-utils": "1.13.1",
18
15
  "eventemitter2": "^6.4.3",
19
16
  "prop-types": "^15.7.2"
20
17
  },
@@ -29,9 +26,8 @@
29
26
  "tooltip.js": ">=1.3.3"
30
27
  },
31
28
  "devDependencies": {
32
- "@tsed/tailwind": "1.11.2",
33
- "@tsed/tailwind-formio": "1.11.2",
34
- "eslint-plugin-jsx-a11y": "^6.5.1"
29
+ "@tsed/tailwind": "1.13.1",
30
+ "@tsed/tailwind-formio": "1.13.1"
35
31
  },
36
32
  "repository": "https://github.com/TypedProject/tsed-formio",
37
33
  "bugs": {
package/readme.md CHANGED
@@ -25,31 +25,33 @@
25
25
 
26
26
  <hr />
27
27
 
28
- A [React](http://facebook.github.io/react/) library for rendering out forms based on the [Form.io](https://www.form.io) platform.
28
+ A [React](http://facebook.github.io/react/) library for rendering out forms based on the [Form.io](https://www.form.io)
29
+ platform.
29
30
 
30
- This module is based on the original [react-formio](https://github.com/formio/react-formio) and add extra features listed above.
31
+ This module is based on the original [react-formio](https://github.com/formio/react-formio) and add extra features
32
+ listed above.
31
33
 
32
34
  See our [storybook](https://formio.tsed.io/) to see all available components.
33
35
 
34
36
  ## Features
35
37
 
36
- * Many components are provided to build your own backoffice based on Formio.js API:
37
- * [ActionsTable](https://formio.tsed.io/?path=/story/reactformio-actionstable--sandbox),
38
- * [FormAccess](https://formio.tsed.io/?path=/story/reactformio-formaccess--sandbox),
39
- * [FormAction](https://formio.tsed.io/?path=/story/reactformio-formaction--sandbox),
40
- * [Form](https://formio.tsed.io/?path=/story/reactformio-form--sandbox),
41
- * [FormBuilder](https://formio.tsed.io/?path=/story/reactformio-formbuilder--sandbox),
42
- * [FormEdit](https://formio.tsed.io/?path=/story/reactformio-formedit--sandbox),
43
- * [FormsTable](https://formio.tsed.io/?path=/story/reactformio-formstable--sandbox),
44
- * [InputTags](https://formio.tsed.io/?path=/story/reactformio-inputtags--sandbox),
45
- * [InputText](https://formio.tsed.io/?path=/story/reactformio-inputtext--sandbox),
46
- * [Pagination](https://formio.tsed.io/?path=/story/reactformio-pagination--sandbox),
47
- * [Select](https://formio.tsed.io/?path=/story/reactformio-select--sandbox),
48
- * [SubmissionsTable](https://formio.tsed.io/?path=/story/reactformio-subssionsstable--sandbox).
49
- * [Table](https://formio.tsed.io/?path=/story/reactformio-table--sandbox),
50
- * Predefined Reducers for Actions, Action, Form, Forms, Submission, Submissions, etc...,
51
- * TypeScript support.
52
- * Tailwind support.
38
+ - Many components are provided to build your own backoffice based on Formio.js API:
39
+ - [ActionsTable](https://formio.tsed.io/?path=/story/reactformio-actionstable--sandbox),
40
+ - [FormAccess](https://formio.tsed.io/?path=/story/reactformio-formaccess--sandbox),
41
+ - [FormAction](https://formio.tsed.io/?path=/story/reactformio-formaction--sandbox),
42
+ - [Form](https://formio.tsed.io/?path=/story/reactformio-form--sandbox),
43
+ - [FormBuilder](https://formio.tsed.io/?path=/story/reactformio-formbuilder--sandbox),
44
+ - [FormEdit](https://formio.tsed.io/?path=/story/reactformio-formedit--sandbox),
45
+ - [FormsTable](https://formio.tsed.io/?path=/story/reactformio-formstable--sandbox),
46
+ - [InputTags](https://formio.tsed.io/?path=/story/reactformio-inputtags--sandbox),
47
+ - [InputText](https://formio.tsed.io/?path=/story/reactformio-inputtext--sandbox),
48
+ - [Pagination](https://formio.tsed.io/?path=/story/reactformio-pagination--sandbox),
49
+ - [Select](https://formio.tsed.io/?path=/story/reactformio-select--sandbox),
50
+ - [SubmissionsTable](https://formio.tsed.io/?path=/story/reactformio-subssionsstable--sandbox).
51
+ - [Table](https://formio.tsed.io/?path=/story/reactformio-table--sandbox),
52
+ - Predefined Reducers for Actions, Action, Form, Forms, Submission, Submissions, etc...,
53
+ - TypeScript support.
54
+ - Tailwind support.
53
55
 
54
56
  ## Install
55
57
 
@@ -66,30 +68,32 @@ npm install formiojs choices.js --save // Install formiojs since it is a peerDep
66
68
 
67
69
  ```tsx
68
70
  import React from "react";
69
- import {FormBuilder} from "@tsed/react-formio";
71
+ import { FormBuilder } from "@tsed/react-formio";
70
72
 
71
73
  function App() {
72
74
  return (
73
- <div className="App">
74
- <FormBuilder display={'form'} components={[]} />
75
+ <div className='App'>
76
+ <FormBuilder display={"form"} components={[]} />
75
77
  </div>
76
78
  );
77
79
  }
78
80
 
79
81
  export default App;
80
-
81
82
  ```
82
83
 
83
84
  ## Components
84
85
 
85
86
  ### Form
86
87
 
87
- The form component is the primary component of the system. It is what takes the form definition (json) and renders the form into html. There are multiple ways to send the form to the Form component. The two main ways are to pass the ```src``` prop with a url to the form definition, usually a form.io server. The other is to pass the ```form``` prop with the json definition and optionally a ```url``` prop with the location of the form.
88
+ The form component is the primary component of the system. It is what takes the form definition (json) and renders the
89
+ form into html. There are multiple ways to send the form to the Form component. The two main ways are to pass the `src`
90
+ prop with a url to the form definition, usually a form.io server. The other is to pass the `form` prop with the json
91
+ definition and optionally a `url` prop with the location of the form.
88
92
 
89
93
  #### Props
90
94
 
91
95
  | Name | Type | Default | Description |
92
- |--------------|--------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
96
+ | ------------ | ------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
93
97
  | `src` | url | | The url of the form definition. This is commonly from a form.io server. When using src, the form will automatically submit the data to that url as well. |
94
98
  | `url` | url | | The url of the form definition. The form will not be loaded from this url and the submission will not be saved here either. This is used for file upload, oauth and other components or actions that need to know where the server is. Use this in connection with `form` |
95
99
  | `form` | object | | Instead of loading a form from the `src` url, you can preload the form definition and pass it in with the `form` prop. You should also set `url` if you are using any advanced components like file upload or oauth. |
@@ -101,13 +105,14 @@ The form component is the primary component of the system. It is what takes the
101
105
  You can respond to various events in the form. Simply pass in a prop with a function for one of these events.
102
106
 
103
107
  | Name | Parameters | Description |
104
- |-----------------|-----------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------|
108
+ | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
109
+ | `onAsyncSubmit` | `submission`: object | When the submit button is pressed and the submission has started. Use this event if you submit data to external service. |
105
110
  | `onSubmit` | `submission`: object | When the submit button is pressed and the submission has started. If `src` is not provided, this will be the final submit event. |
106
111
  | `onSubmitDone` | `submission`: object | When the submission has successfully been made to the server. This will only fire if `src` is set. |
107
112
  | `onChange` | `submission`: object, `submission.changed`: object of what changed, `submission.isValid`: boolean - if the submission passes validations. | A value in the submission has changed. |
108
113
  | `onError` | `errors`: array or string or boolean | Called when an error occurs during submission such as a validation issue. |
109
114
  | `onRender` | | Triggers when the form is finished rendering. |
110
- | `onCustomEvent` | { `type`: string - event type, `component`: object - triggering component, `data`: object - data for component, `event`: string - raw event } | Event that is triggered from a button configured with "Event" type. |
115
+ | `onCustomEvent` | { `type`: string - event type, `component`: object - triggering component, `data`: object - data for component, `event`: string - raw event } | Event that is triggered from a button configured with "Event" type. |
111
116
  | `onPrevPage` | { `page`: integer - new page number, `submission`: object - submission data } | Triggered for wizards when "Previous" button is pressed |
112
117
  | `onNextPage` | { `page`: integer - new page number, `submission`: object - submission data } | Triggered for wizards when "Next" button is pressed |
113
118
  | `onFormReady` | `formInstance`: Webform/Wizard - form class instance | Called when the form gets ready state |
@@ -119,14 +124,11 @@ You can respond to various events in the form. Simply pass in a prop with a func
119
124
  Give `Form` a `src` property and render:
120
125
 
121
126
  ```tsx
122
- import React from 'react';
123
- import ReactDOM from 'react-dom';
124
- import {Form} from '@tsed/react-formio';
127
+ import React from "react";
128
+ import ReactDOM from "react-dom";
129
+ import { Form } from "@tsed/react-formio";
125
130
 
126
- ReactDOM.render(
127
- <Form src="https://example.form.io/example" onSubmit={console.log} />
128
- , document.getElementById('example')
129
- );
131
+ ReactDOM.render(<Form src='https://example.form.io/example' onSubmit={console.log} />, document.getElementById("example"));
130
132
  ```
131
133
 
132
134
  ##### With form
@@ -134,53 +136,70 @@ ReactDOM.render(
134
136
  Give `Form` a `src` property and render:
135
137
 
136
138
  ```tsx
137
- import React from 'react';
138
- import ReactDOM from 'react-dom';
139
- import {Form} from '@tsed/react-formio';
140
-
139
+ import React from "react";
140
+ import ReactDOM from "react-dom";
141
+ import { Form } from "@tsed/react-formio";
142
+
141
143
  interface MyFormData {
142
144
  title: string;
143
- }
145
+ }
144
146
 
145
147
  const form = {
146
- display: 'form',
148
+ display: "form",
147
149
  components: [
148
150
  {
149
- key: 'title',
150
- type: 'textfield'
151
+ key: "title",
152
+ type: "textfield"
151
153
  }
152
154
  ]
153
- }
155
+ };
154
156
 
155
157
  ReactDOM.render(
156
- <Form<MyFormData> form={form} onSubmit={(submission) => {
157
- console.log(submission)
158
- }} />
159
- , document.getElementById('example')
158
+ <Form<MyFormData>
159
+ form={form}
160
+ onAsyncSubmit={(submission) => {
161
+ return httpClient.post("/path/to/external/service", { data: submission }).catch((er) => {
162
+ err.errors = [
163
+ {
164
+ message: "My custom message about this field",
165
+ type: "custom",
166
+ path: ["title"],
167
+ level: "error"
168
+ }
169
+ ];
170
+ throw error;
171
+ });
172
+ }}
173
+ />,
174
+ document.getElementById("example")
160
175
  );
161
176
  ```
162
177
 
178
+ > See [Form with error from server](https://formio.tsed.io/?path=/story/reactformio-form--trigger-error)
179
+
163
180
  ### FormBuilder
164
181
 
165
- The [FormBuilder]([FormsTable](https://formio.tsed.io/?path=/story/reactformio-formbuilder--sandbox)) class can be used
166
- to embed a form builder directly in your react application.
182
+ The [FormBuilder](https://formio.tsed.io/?path=/story/reactformio-formbuilder--sandbox)) class can be
183
+ used
184
+ to embed a form builder directly in your react application.
167
185
  Please note that you'll need to include the CSS for the form builder from formio.js as well.
168
186
 
169
- Please note that the [FormBuilder]([FormsTable](https://formio.tsed.io/?path=/story/reactformio-formbuilder--sandbox)) component
170
- does not load and save from/to a url. You must handle the form definition loading and saving yourself or use
187
+ Please note that the [FormBuilder](<[FormsTable](https://formio.tsed.io/?path=/story/reactformio-formbuilder--sandbox)>)
188
+ component
189
+ does not load and save from/to a url. You must handle the form definition loading and saving yourself or use
171
190
  the [FormEdit](https://formio.tsed.io/?path=/story/reactformio-formedit--sandbox) component.
172
191
 
173
192
  #### Props
174
193
 
175
194
  | Name | Type | Default | Description |
176
- |-----------|--------|---------|----------------------------------------------------------------------------------------------------------------------------------------------|
195
+ | --------- | ------ | ------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
177
196
  | `form` | object | | This is the form definition object. It should at least have a `display` property set to form, wizard or pdf. |
178
197
  | `options` | object | | an options object that can pass options to the formio.js Form that is rendered. There are many options to be found in the formio.js library. |
179
198
 
180
199
  #### Event Props
181
200
 
182
201
  | Name | Parameters | Description |
183
- |---------------------|---------------------|------------------------------------------------------------------|
202
+ | ------------------- | ------------------- | ---------------------------------------------------------------- |
184
203
  | `onChange` | `schema`: object | Triggered any time the form definition changes |
185
204
  | `onEditComponent` | `component`: object | Triggered when the component settings dialog is opened |
186
205
  | `onSaveComponent` | `component`: object | Triggered when the component settings dialog is saved and closed |
@@ -191,43 +210,45 @@ the [FormEdit](https://formio.tsed.io/?path=/story/reactformio-formedit--sandbox
191
210
  #### Example
192
211
 
193
212
  ```tsx
194
- import React from 'react';
195
- import ReactDOM from 'react-dom';
196
- import {FormBuilder} from '@tsed/react-formio';
213
+ import React from "react";
214
+ import ReactDOM from "react-dom";
215
+ import { FormBuilder } from "@tsed/react-formio";
197
216
 
198
- ReactDOM.render(
199
- <FormBuilder form={{display: 'form'}} onChange={(schema) => console.log(schema)} />
200
- , document.getElementById('builder')
201
- );
217
+ ReactDOM.render(<FormBuilder form={{ display: "form" }} onChange={(schema) => console.log(schema)} />, document.getElementById("builder"));
202
218
  ```
203
219
 
204
220
  ### FormEdit
205
221
 
206
- The [FormEdit](https://formio.tsed.io/?path=/story/reactformio-formedit--sandbox) component wraps
207
- the [FormBuilder]([FormsTable](https://formio.tsed.io/?path=/story/reactformio-formbuilder--sandbox)) component and adds the title, display, name and path fields at the top along with a save button.
222
+ The [FormEdit](https://formio.tsed.io/?path=/story/reactformio-formedit--sandbox) component wraps
223
+ the [FormBuilder](<[FormsTable](https://formio.tsed.io/?path=/story/reactformio-formbuilder--sandbox)>) component and
224
+ adds the title, display, name and path fields at the top along with a save button.
208
225
 
209
226
  #### Props
210
227
 
211
- | Name | Type | Default | Description |
212
- |------------|--------|--------------------|------------------------------------------------------|
213
- | `form` | object | {display: 'form' \ | 'wizard'} | The form definition of the exiting form that is to be modified. |
214
- | `options` | object | {} | The options to be passed to FormBuilder |
215
- | `saveText` | string | '' | The string that will be displayed in the save-button |
228
+ | Name | Type | Default | Description |
229
+ | --------------------------------------------------------------- | ------ | ------------------- | ----------- | --------------------------------------------------------------- |
230
+ | --------------------------------------------------------------- |
231
+ | `form` | object | {display: 'form' \ | 'wizard'} | The form definition of the exiting form that is to be modified. |
232
+
233
+ |
234
+ | `options` | object | {} | The options to be passed to FormBuilder |
235
+ | `saveText` | string | '' | The string that will be displayed in the save-button |
216
236
 
217
237
  #### Event Props
218
238
 
219
239
  | Name | Parameters | Description |
220
- |------------|------------|----------------------------------------------------------------------------------------|
240
+ | ---------- | ---------- | -------------------------------------------------------------------------------------- |
221
241
  | `onSubmit` | form | Called when the save button is pressed. Will pass the form definition to the callback. |
222
242
 
223
243
  ### FormsTable
224
244
 
225
- The [FormsTable](https://formio.tsed.io/?path=/story/reactformio-formstable--sandbox) component can be used to render a list of forms with buttons to edit, view, delete, etc on each row.
245
+ The [FormsTable](https://formio.tsed.io/?path=/story/reactformio-formstable--sandbox) component can be used to render a
246
+ list of forms with buttons to edit, view, delete, etc on each row.
226
247
 
227
248
  #### Props
228
249
 
229
250
  | Name | Type | Default | Description |
230
- |--------|----------------|---------|---------------------------------------------|
251
+ | ------ | -------------- | ------- | ------------------------------------------- |
231
252
  | `data` | array of forms | [] | A list of forms to be rendered in the grid. |
232
253
 
233
254
  ### SubmissionsTable
@@ -237,7 +258,7 @@ The submisison grid will render a list of submissions and allow clicking on one
237
258
  #### Props
238
259
 
239
260
  | Name | Type | Default | Description |
240
- |--------|----------------------|---------|----------------------------------------------------------------------------------|
261
+ | ------ | -------------------- | ------- | -------------------------------------------------------------------------------- |
241
262
  | `data` | array of submissions | [] | A list of submissions to be rendered in the grid. |
242
263
  | `form` | object | {} | The form definition for the submissions. This is used to render the submissions. |
243
264
 
@@ -287,33 +308,33 @@ import { connectRouter } from "connected-react-router";
287
308
  import { combineReducers } from "redux";
288
309
 
289
310
  export const rootReducers = (history: any) =>
290
- combineReducers({
291
- router: connectRouter(history),
292
- ...defaultFormioReducer,
293
- // override defaultFormioReducer can done as following
294
- ...combine(
295
- formsReducer("forms", { query: { type: "form", tags: ['common'] } }), // return only forms with the common tags
296
- formsReducer("resources", { query: { type: "resource", tags: ['common'] } }) // return only resources with the common tags
297
- )
298
- });
311
+ combineReducers({
312
+ router: connectRouter(history),
313
+ ...defaultFormioReducer,
314
+ // override defaultFormioReducer can done as following
315
+ ...combine(
316
+ formsReducer("forms", { query: { type: "form", tags: ["common"] } }), // return only forms with the common tags
317
+ formsReducer("resources", { query: { type: "resource", tags: ["common"] } }) // return only resources with the common tags
318
+ )
319
+ });
299
320
  ```
300
321
 
301
322
  ## Contributors
323
+
302
324
  Please read [contributing guidelines here](./CONTRIBUTING.md).
303
325
 
304
326
  <a href="https://github.com/TypedProject/tsed/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>
305
327
 
306
-
307
328
  ## Backers
308
329
 
309
330
  Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)]
310
331
 
311
332
  <a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/tiers/backer.svg?width=890"></a>
312
333
 
313
-
314
334
  ## Sponsors
315
335
 
316
- Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]
336
+ Support this project by becoming a sponsor. Your logo will show up here with a link to your
337
+ website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]
317
338
 
318
339
  ## License
319
340
 
@@ -321,8 +342,15 @@ The MIT License (MIT)
321
342
 
322
343
  Copyright (c) 2016 - 2021 Romain Lenzotti
323
344
 
324
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
345
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
346
+ documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
347
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
348
+ persons to whom the Software is furnished to do so, subject to the following conditions:
325
349
 
326
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
350
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
351
+ Software.
327
352
 
328
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
353
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
354
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
355
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
356
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,10 +1,7 @@
1
1
  {
2
2
  "_id": "5e972ae7a1a692917cf54f9e",
3
3
  "type": "resource",
4
- "tags": [
5
- "common",
6
- "products"
7
- ],
4
+ "tags": ["common", "products"],
8
5
  "owner": null,
9
6
  "components": [
10
7
  {
@@ -430,70 +427,41 @@
430
427
  "modified": "2020-04-15T15:40:23.647Z",
431
428
  "access": [
432
429
  {
433
- "roles": [
434
- "5e97026c50bcd9815878809a",
435
- "5e97026c50bcd98158788099",
436
- "5e97026c50bcd98158788098"
437
- ],
430
+ "roles": ["5e97026c50bcd9815878809a", "5e97026c50bcd98158788099", "5e97026c50bcd98158788098"],
438
431
  "type": "read_all"
439
432
  }
440
433
  ],
441
434
  "submissionAccess": [
442
435
  {
443
- "roles": [
444
- "5e97026c50bcd98158788098",
445
- "5e97026c50bcd98158788099"
446
- ],
436
+ "roles": ["5e97026c50bcd98158788098", "5e97026c50bcd98158788099"],
447
437
  "type": "create_all"
448
438
  },
449
439
  {
450
- "roles": [
451
- "5e97026c50bcd98158788098",
452
- "5e97026c50bcd98158788099",
453
- "5e97026c50bcd9815878809a"
454
- ],
440
+ "roles": ["5e97026c50bcd98158788098", "5e97026c50bcd98158788099", "5e97026c50bcd9815878809a"],
455
441
  "type": "read_all"
456
442
  },
457
443
  {
458
- "roles": [
459
- "5e97026c50bcd98158788098",
460
- "5e97026c50bcd98158788099"
461
- ],
444
+ "roles": ["5e97026c50bcd98158788098", "5e97026c50bcd98158788099"],
462
445
  "type": "update_all"
463
446
  },
464
447
  {
465
- "roles": [
466
- "5e97026c50bcd98158788098",
467
- "5e97026c50bcd98158788099"
468
- ],
448
+ "roles": ["5e97026c50bcd98158788098", "5e97026c50bcd98158788099"],
469
449
  "type": "delete_all"
470
450
  },
471
451
  {
472
- "roles": [
473
- "5e97026c50bcd98158788098",
474
- "5e97026c50bcd98158788099"
475
- ],
452
+ "roles": ["5e97026c50bcd98158788098", "5e97026c50bcd98158788099"],
476
453
  "type": "create_own"
477
454
  },
478
455
  {
479
- "roles": [
480
- "5e97026c50bcd98158788098",
481
- "5e97026c50bcd98158788099"
482
- ],
456
+ "roles": ["5e97026c50bcd98158788098", "5e97026c50bcd98158788099"],
483
457
  "type": "read_own"
484
458
  },
485
459
  {
486
- "roles": [
487
- "5e97026c50bcd98158788098",
488
- "5e97026c50bcd98158788099"
489
- ],
460
+ "roles": ["5e97026c50bcd98158788098", "5e97026c50bcd98158788099"],
490
461
  "type": "update_own"
491
462
  },
492
463
  {
493
- "roles": [
494
- "5e97026c50bcd98158788098",
495
- "5e97026c50bcd98158788099"
496
- ],
464
+ "roles": ["5e97026c50bcd98158788098", "5e97026c50bcd98158788099"],
497
465
  "type": "delete_own"
498
466
  }
499
467
  ],
@@ -2041,4 +2041,4 @@
2041
2041
  }
2042
2042
  ],
2043
2043
  "display": "form"
2044
- }
2044
+ }
@@ -8,9 +8,7 @@ describe("ActionsTable", () => {
8
8
  it("should render the table actions", async () => {
9
9
  const onAddAction = jest.fn();
10
10
 
11
- const { getByRole, getAllByRole } = render(
12
- <Sandbox {...Sandbox.args} onAddAction={onAddAction} />
13
- );
11
+ const { getByRole, getAllByRole } = render(<Sandbox {...Sandbox.args} onAddAction={onAddAction} />);
14
12
 
15
13
  const btn = getByRole("button", { name: /add action/i });
16
14
  const cells = getAllByRole("cell");
@@ -27,9 +25,7 @@ describe("ActionsTable", () => {
27
25
  it("should not call addAction when the default item is selected", async () => {
28
26
  const onAddAction = jest.fn();
29
27
 
30
- const { getByRole } = render(
31
- <Sandbox {...Sandbox.args} onAddAction={onAddAction} />
32
- );
28
+ const { getByRole } = render(<Sandbox {...Sandbox.args} onAddAction={onAddAction} />);
33
29
 
34
30
  const btn = getByRole("button", { name: /add action/i });
35
31
 
@@ -39,17 +35,12 @@ describe("ActionsTable", () => {
39
35
  it("should call addAction with the selected action", async () => {
40
36
  const onAddAction = jest.fn();
41
37
 
42
- const { getByRole } = render(
43
- <Sandbox {...Sandbox.args} onAddAction={onAddAction} />
44
- );
38
+ const { getByRole } = render(<Sandbox {...Sandbox.args} onAddAction={onAddAction} />);
45
39
 
46
40
  const btn = getByRole("button", { name: /add action/i });
47
41
  const select = getByRole("combobox");
48
42
 
49
- await userEvent.selectOptions(
50
- select,
51
- String(Sandbox.args.availableActions[1].value)
52
- );
43
+ await userEvent.selectOptions(select, String(Sandbox.args.availableActions[1].value));
53
44
 
54
45
  await fireEvent.click(btn);
55
46
 
@@ -32,19 +32,12 @@ export function ActionsTable({
32
32
  }, []);
33
33
 
34
34
  return (
35
- <Table
36
- {...props}
37
- disableFilters={disableFilters}
38
- disablePagination={disablePagination}
39
- columns={columns}
40
- >
35
+ <Table {...props} disableFilters={disableFilters} disablePagination={disablePagination} columns={columns}>
41
36
  <div className={"pagination-group"}>
42
37
  <Select
43
38
  name={"actions"}
44
39
  value={currentAction}
45
- choices={[{ label: i18n("Select an action"), value: "" }].concat(
46
- availableActions
47
- )}
40
+ choices={[{ label: i18n("Select an action"), value: "" }].concat(availableActions)}
48
41
  onChange={(name: string, action: string) => setAction(action)}
49
42
  />
50
43
  <div className={"pl-3"}>
@@ -55,8 +48,7 @@ export function ActionsTable({
55
48
  onClick={() => currentAction && onAddAction(currentAction)}
56
49
  type={"submit"}
57
50
  >
58
- <i className={classnames(iconClass(undefined, "plus"), "mr-1")} />{" "}
59
- {i18n("Add action")}
51
+ <i className={classnames(iconClass(undefined, "plus"), "mr-1")} /> {i18n("Add action")}
60
52
  </button>
61
53
  </div>
62
54
  </div>