@tsed/react-formio 2.1.2 → 2.1.4

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 (76) hide show
  1. package/coverage.json +4 -4
  2. package/dist/components/actions-table/actionsTable.component.d.ts +3 -2
  3. package/dist/components/actions-table/actionsTable.stories.d.ts +2 -1
  4. package/dist/components/alert/alert.component.d.ts +2 -1
  5. package/dist/components/alert/alert.stories.d.ts +2 -1
  6. package/dist/components/card/card.component.d.ts +1 -1
  7. package/dist/components/card/card.stories.d.ts +2 -1
  8. package/dist/components/form/form.component.d.ts +2 -1
  9. package/dist/components/form/form.stories.d.ts +5 -4
  10. package/dist/components/form-access/formAccess.stories.d.ts +2 -1
  11. package/dist/components/form-access/formAccess.utils.d.ts +3 -3
  12. package/dist/components/form-action/formAction.stories.d.ts +2 -1
  13. package/dist/components/form-builder/formBuilder.component.d.ts +1 -1
  14. package/dist/components/form-builder/formBuilder.stories.d.ts +7 -6
  15. package/dist/components/form-control/formControl.component.d.ts +1 -1
  16. package/dist/components/form-control/formControl.stories.d.ts +11 -10
  17. package/dist/components/form-edit/formEdit.component.d.ts +2 -1
  18. package/dist/components/form-edit/formEdit.stories.d.ts +17 -16
  19. package/dist/components/form-settings/formSettings.component.d.ts +2 -1
  20. package/dist/components/form-settings/formSettings.stories.d.ts +2 -1
  21. package/dist/components/form-settings/formSettings.utils.d.ts +1 -1
  22. package/dist/components/forms-table/components/formCell.component.d.ts +2 -1
  23. package/dist/components/forms-table/formsTable.component.d.ts +3 -2
  24. package/dist/components/forms-table/formsTable.stories.d.ts +3 -2
  25. package/dist/components/input-tags/inputTags.component.d.ts +2 -1
  26. package/dist/components/input-tags/inputTags.stories.d.ts +4 -3
  27. package/dist/components/input-text/inputText.component.d.ts +2 -1
  28. package/dist/components/input-text/inputText.stories.d.ts +6 -5
  29. package/dist/components/loader/loader.component.d.ts +2 -2
  30. package/dist/components/loader/loader.stories.d.ts +2 -1
  31. package/dist/components/modal/modal.component.d.ts +1 -1
  32. package/dist/components/modal/modal.stories.d.ts +5 -4
  33. package/dist/components/modal/removeModal.component.d.ts +2 -2
  34. package/dist/components/pagination/pagination.component.d.ts +2 -1
  35. package/dist/components/pagination/pagination.stories.d.ts +2 -1
  36. package/dist/components/react-component/reactComponent.component.d.ts +1 -1
  37. package/dist/components/select/select.stories.d.ts +9 -8
  38. package/dist/components/submissions-table/submissionsTable.component.d.ts +3 -2
  39. package/dist/components/submissions-table/submissionsTable.stories.d.ts +2 -1
  40. package/dist/components/table/components/defaultArrowSort.component.d.ts +2 -1
  41. package/dist/components/table/components/defaultCellHeader.component.d.ts +2 -1
  42. package/dist/components/table/components/defaultCellOperations.component.d.ts +2 -1
  43. package/dist/components/table/components/defaultCells.component.d.ts +2 -1
  44. package/dist/components/table/components/defaultOperationButton.component.d.ts +2 -1
  45. package/dist/components/table/components/defaultRow.component.d.ts +3 -3
  46. package/dist/components/table/components/dragNDropContainer.d.ts +2 -2
  47. package/dist/components/table/filters/defaultColumnFilter.component.d.ts +2 -1
  48. package/dist/components/table/filters/selectColumnFilter.component.d.ts +2 -1
  49. package/dist/components/table/filters/sliderColumnFilter.component.d.ts +2 -1
  50. package/dist/components/table/hooks/useCustomTable.hook.d.ts +7 -85
  51. package/dist/components/table/hooks/useDragnDropRow.hook.d.ts +25 -18
  52. package/dist/components/table/hooks/useOperations.hook.d.ts +1 -1
  53. package/dist/components/table/table.component.d.ts +2 -2
  54. package/dist/components/table/table.stories.d.ts +3 -2
  55. package/dist/components/tabs/tabs.component.d.ts +3 -3
  56. package/dist/components/tabs/tabs.component.stories.d.ts +3 -2
  57. package/dist/index.js +439 -493
  58. package/dist/index.js.map +1 -1
  59. package/dist/index.modern.js +57 -100
  60. package/dist/index.modern.js.map +1 -1
  61. package/dist/interfaces/FormSchema.d.ts +1 -1
  62. package/dist/interfaces/Operation.d.ts +2 -2
  63. package/dist/interfaces/QueryOptions.d.ts +1 -1
  64. package/package.json +4 -3
  65. package/readme.md +17 -195
  66. package/src/components/form/form.stories.tsx +128 -122
  67. package/src/components/form/useForm.hook.ts +1 -1
  68. package/src/components/form-builder/formBuilder.stories.tsx +3540 -3537
  69. package/src/components/form-edit/formEdit.stories.tsx +320 -317
  70. package/src/components/forms-table/formsTable.component.tsx +1 -1
  71. package/src/components/modal/removeModal.component.tsx +3 -4
  72. package/src/components/table/components/defaultCellHeader.component.tsx +3 -3
  73. package/src/components/table/components/defaultCells.component.tsx +1 -1
  74. package/src/components/table/filters/defaultColumnFilter.component.tsx +1 -1
  75. package/src/components/table/hooks/useCustomTable.hook.tsx +16 -5
  76. package/tsconfig.json +2 -1
@@ -1,5 +1,5 @@
1
1
  import { ExtendedComponentSchema } from "formiojs";
2
- export declare type FormSchema = {
2
+ export type FormSchema = {
3
3
  _id?: string;
4
4
  title?: string;
5
5
  name?: string;
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { OperationButtonProps } from "../components/table/components/defaultOperationButton.component";
3
- export declare type PermissionsResolver<Data = any> = (data: Data, ctx: any) => void;
4
- export declare type OnClickOperation<Data = any> = (data: Data, operation: Operation) => void;
3
+ export type PermissionsResolver<Data = any> = (data: Data, ctx: any) => void;
4
+ export type OnClickOperation<Data = any> = (data: Data, operation: Operation) => void;
5
5
  export interface Operation<Data = any> {
6
6
  /**
7
7
  * Action identifier
@@ -1,5 +1,5 @@
1
1
  import { ColumnIdentifier } from "./ColumnIdentifier";
2
- export declare type QueryOptions = {
2
+ export type QueryOptions = {
3
3
  /**
4
4
  * Current displayed page
5
5
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/react-formio",
3
- "version": "2.1.2",
3
+ "version": "2.1.4",
4
4
  "description": "Provide a react formio wrapper. Written in TypeScript.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.modern.js",
@@ -14,6 +14,7 @@
14
14
  "watch": "microbundle watch --no-compress --format modern,cjs --jsx React.createElement --jsxFragment React.Fragment --globals react/jsx-runtime=jsx"
15
15
  },
16
16
  "dependencies": {
17
+ "classnames": "^2.3.1",
17
18
  "eventemitter2": "^6.4.3",
18
19
  "prop-types": "^15.7.2"
19
20
  },
@@ -30,8 +31,8 @@
30
31
  "tooltip.js": ">=1.3.3"
31
32
  },
32
33
  "devDependencies": {
33
- "@tsed/tailwind": "2.1.2",
34
- "@tsed/tailwind-formio": "2.1.2"
34
+ "@tsed/tailwind": "2.1.4",
35
+ "@tsed/tailwind-formio": "2.1.4"
35
36
  },
36
37
  "repository": "https://github.com/TypedProject/tsed-formio",
37
38
  "bugs": {
package/readme.md CHANGED
@@ -31,24 +31,25 @@ platform.
31
31
  This module is based on the original [react-formio](https://github.com/formio/react-formio) and add extra features
32
32
  listed above.
33
33
 
34
- See our [storybook](https://formio.tsed.io/) to see all available components.
34
+ See our [storybook](https://formio.tsed.io/?path=/docs/getting-started--docs) to see all available components.
35
35
 
36
36
  ## Features
37
37
 
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),
38
+ Many components are provided to build your own backoffice based on Formio.js API:
39
+
40
+ - [ActionsTable](https://formio.tsed.io/?path=story/reactformio-actionstable--sandbox),
41
+ - [FormAccess](https://formio.tsed.io/?path=story/reactformio-formaccess--sandbox),
42
+ - [FormAction](https://formio.tsed.io/?path=story/reactformio-formaction--sandbox),
43
+ - [Form](https://formio.tsed.io/?path=docs/documentation-form--docs),
44
+ - [FormBuilder](https://formio.tsed.io/?path=docs/documentation-formbuilder--docs),
45
+ - [FormEdit](https://formio.tsed.io/?path=docs/documentation-formedit--docs),
46
+ - [FormsTable](https://formio.tsed.io/?path=docs/documentation-formstable--docs),
47
+ - [InputTags](https://formio.tsed.io/?path=story/reactformio-inputtags--sandbox),
48
+ - [InputText](https://formio.tsed.io/?path=story/reactformio-inputtext--sandbox),
49
+ - [Pagination](https://formio.tsed.io/?path=story/reactformio-pagination--sandbox),
50
+ - [Select](https://formio.tsed.io/?path=/story/reactformio-select--sandbox),
51
+ - [SubmissionsTable](https://formio.tsed.io/?path=/docs/documentation-submissionstable--docs).
52
+ - [Table](https://formio.tsed.io/?path=/story/reactformio-table--sandbox),
52
53
  - Predefined Reducers for Actions, Action, Form, Forms, Submission, Submissions, etc...,
53
54
  - TypeScript support.
54
55
  - Tailwind support.
@@ -90,186 +91,7 @@ function App() {
90
91
  export default App;
91
92
  ```
92
93
 
93
- ## Components
94
-
95
- ### Form
96
-
97
- The form component is the primary component of the system. It is what takes the form definition (json) and renders the
98
- form into html. There are multiple ways to send the form to the Form component. The two main ways are to pass the `src`
99
- prop with a url to the form definition, usually a form.io server. The other is to pass the `form` prop with the json
100
- definition and optionally a `url` prop with the location of the form.
101
-
102
- #### Props
103
-
104
- | Name | Type | Default | Description |
105
- | ------------ | ------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
106
- | `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. |
107
- | `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` |
108
- | `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. |
109
- | `submission` | object | | Submission data to fill the form. You can either load a previous submission or create a submission with some pre-filled data. If you do not provide a submissions the form will initialize an empty submission using default values from the form. |
110
- | `options` | object | | an options object that can pass options to the formio.js Form that is rendered. You can set options such as `readOnly`, `noAlerts` or `hide`. There are [many options to be found in the formio.js library](https://github.com/formio/formio.js/wiki/Form-Renderer#options). |
111
-
112
- #### Event Props
113
-
114
- You can respond to various events in the form. Simply pass in a prop with a function for one of these events.
115
-
116
- | Name | Parameters | Description |
117
- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
118
- | `onAsyncSubmit` | `submission`: object | When the submit button is pressed and the submission has started. Use this event if you submit data to external service. |
119
- | `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. |
120
- | `onSubmitDone` | `submission`: object | When the submission has successfully been made to the server. This will only fire if `src` is set. |
121
- | `onChange` | `submission`: object, `submission.changed`: object of what changed, `submission.isValid`: boolean - if the submission passes validations. | A value in the submission has changed. |
122
- | `onError` | `errors`: array or string or boolean | Called when an error occurs during submission such as a validation issue. |
123
- | `onRender` | | Triggers when the form is finished rendering. |
124
- | `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. |
125
- | `onPrevPage` | { `page`: integer - new page number, `submission`: object - submission data } | Triggered for wizards when "Previous" button is pressed |
126
- | `onNextPage` | { `page`: integer - new page number, `submission`: object - submission data } | Triggered for wizards when "Next" button is pressed |
127
- | `onFormReady` | `formInstance`: Webform/Wizard - form class instance | Called when the form gets ready state |
128
-
129
- #### Example
130
-
131
- ##### With src/url
132
-
133
- Give `Form` a `src` property and render:
134
-
135
- ```tsx
136
- import React from "react";
137
- import ReactDOM from "react-dom";
138
- import { Form } from "@tsed/react-formio";
139
-
140
- ReactDOM.render(<Form src='https://example.form.io/example' onSubmit={console.log} />, document.getElementById("example"));
141
- ```
142
-
143
- ##### With form
144
-
145
- Give `Form` a `src` property and render:
146
-
147
- ```tsx
148
- import React from "react";
149
- import ReactDOM from "react-dom";
150
- import { Form } from "@tsed/react-formio";
151
-
152
- interface MyFormData {
153
- title: string;
154
- }
155
-
156
- const form = {
157
- display: "form",
158
- components: [
159
- {
160
- key: "title",
161
- type: "textfield"
162
- }
163
- ]
164
- };
165
-
166
- ReactDOM.render(
167
- <Form<MyFormData>
168
- form={form}
169
- onAsyncSubmit={(submission) => {
170
- return httpClient.post("/path/to/external/service", { data: submission }).catch((er) => {
171
- err.errors = [
172
- {
173
- message: "My custom message about this field",
174
- type: "custom",
175
- path: ["title"],
176
- level: "error"
177
- }
178
- ];
179
- throw error;
180
- });
181
- }}
182
- />,
183
- document.getElementById("example")
184
- );
185
- ```
186
-
187
- > See [Form with error from server](https://formio.tsed.io/?path=/story/reactformio-form--trigger-error)
188
-
189
- ### FormBuilder
190
-
191
- The [FormBuilder](https://formio.tsed.io/?path=/story/reactformio-formbuilder--sandbox)) class can be
192
- used
193
- to embed a form builder directly in your react application.
194
- Please note that you'll need to include the CSS for the form builder from formio.js as well.
195
-
196
- Please note that the [FormBuilder](<[FormsTable](https://formio.tsed.io/?path=/story/reactformio-formbuilder--sandbox)>)
197
- component
198
- does not load and save from/to a url. You must handle the form definition loading and saving yourself or use
199
- the [FormEdit](https://formio.tsed.io/?path=/story/reactformio-formedit--sandbox) component.
200
-
201
- #### Props
202
-
203
- | Name | Type | Default | Description |
204
- | --------- | ------ | ------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
205
- | `form` | object | | This is the form definition object. It should at least have a `display` property set to form, wizard or pdf. |
206
- | `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. |
207
-
208
- #### Event Props
209
-
210
- | Name | Parameters | Description |
211
- | ------------------- | ------------------- | ---------------------------------------------------------------- |
212
- | `onChange` | `schema`: object | Triggered any time the form definition changes |
213
- | `onEditComponent` | `component`: object | Triggered when the component settings dialog is opened |
214
- | `onSaveComponent` | `component`: object | Triggered when the component settings dialog is saved and closed |
215
- | `onCancelComponent` | `component`: object | Triggered when the component settings dialog is cancelled |
216
- | `onDeleteComponent` | `component`: object | Triggered when a component is removed from the form |
217
- | `onUpdateComponent` | `component`: object | Triggered when a component is added or moved in the form |
218
-
219
- #### Example
220
-
221
- ```tsx
222
- import React from "react";
223
- import ReactDOM from "react-dom";
224
- import { FormBuilder } from "@tsed/react-formio";
225
-
226
- ReactDOM.render(<FormBuilder form={{ display: "form" }} onChange={(schema) => console.log(schema)} />, document.getElementById("builder"));
227
- ```
228
-
229
- ### FormEdit
230
-
231
- The [FormEdit](https://formio.tsed.io/?path=/story/reactformio-formedit--sandbox) component wraps
232
- the [FormBuilder](<[FormsTable](https://formio.tsed.io/?path=/story/reactformio-formbuilder--sandbox)>) component and
233
- adds the title, display, name and path fields at the top along with a save button.
234
-
235
- #### Props
236
-
237
- | Name | Type | Default | Description |
238
- | --------------------------------------------------------------- | ------ | ------------------- | ----------- | --------------------------------------------------------------- |
239
- | --------------------------------------------------------------- |
240
- | `form` | object | {display: 'form' \ | 'wizard'} | The form definition of the exiting form that is to be modified. |
241
-
242
- |
243
- | `options` | object | {} | The options to be passed to FormBuilder |
244
- | `saveText` | string | '' | The string that will be displayed in the save-button |
245
-
246
- #### Event Props
247
-
248
- | Name | Parameters | Description |
249
- | ---------- | ---------- | -------------------------------------------------------------------------------------- |
250
- | `onSubmit` | form | Called when the save button is pressed. Will pass the form definition to the callback. |
251
-
252
- ### FormsTable
253
-
254
- The [FormsTable](https://formio.tsed.io/?path=/story/reactformio-formstable--sandbox) component can be used to render a
255
- list of forms with buttons to edit, view, delete, etc on each row.
256
-
257
- #### Props
258
-
259
- | Name | Type | Default | Description |
260
- | ------ | -------------- | ------- | ------------------------------------------- |
261
- | `data` | array of forms | [] | A list of forms to be rendered in the grid. |
262
-
263
- ### SubmissionsTable
264
-
265
- The submisison grid will render a list of submissions and allow clicking on one row to select it.
266
-
267
- #### Props
268
-
269
- | Name | Type | Default | Description |
270
- | ------ | -------------------- | ------- | -------------------------------------------------------------------------------- |
271
- | `data` | array of submissions | [] | A list of submissions to be rendered in the grid. |
272
- | `form` | object | {} | The form definition for the submissions. This is used to render the submissions. |
94
+ See more on http://formio.tsed.io/?path=/docs/getting-started--docs
273
95
 
274
96
  ## Contributors
275
97
 
@@ -112,137 +112,143 @@ function wrap(args: any) {
112
112
  };
113
113
  }
114
114
 
115
- export const Sandbox = (args: any) => {
116
- return <Form {...wrap(args)} form={args.form} options={{ template: "tailwind", iconset: "bx" }} />;
117
- };
118
-
119
- Sandbox.args = {
120
- form
121
- };
122
-
123
- export const TriggerError = (args: any) => {
124
- const onAsyncSubmit = (submission: Submission) => {
125
- return new Promise((resolve, reject) => {
126
- setTimeout(() => {
127
- reject(new Error("server error"));
128
- }, 500);
129
- }).catch((error) => {
130
- error.errors = {
131
- message: "My custom message about this field",
132
- type: "custom",
133
- path: ["firstName"],
134
- level: "error"
135
- };
136
- throw error;
137
- });
138
- };
139
-
140
- return <Form<any> {...wrap(args)} form={args.form} onAsyncSubmit={onAsyncSubmit} />;
141
- };
142
-
143
- TriggerError.args = {
144
- form: {
145
- type: "form",
146
- display: "form",
147
- tags: [],
148
- components: [
149
- {
150
- label: "First name",
151
- widget: {
152
- type: "input"
153
- },
154
- errorLabel: "",
155
- key: "firstName",
156
- inputType: "text",
157
- type: "textfield",
158
- id: "eqb1o4r",
159
- defaultValue: ""
160
- },
161
- {
162
- label: "Submit",
163
- showValidations: false,
164
- tableView: false,
165
- key: "submit",
166
- type: "button",
167
- input: true
168
- }
169
- ]
115
+ export const Sandbox = {
116
+ args: {
117
+ form
118
+ },
119
+ render: (args: any) => {
120
+ return <Form {...wrap(args)} form={args.form} options={{ template: "tailwind", iconset: "bx" }} />;
170
121
  }
171
122
  };
172
123
 
173
- export const ReadOnly = (args: any) => {
174
- return (
175
- <Form
176
- {...wrap(args)}
177
- options={{ template: "tailwind", iconset: "bx", readOnly: args.readOnly }}
178
- form={args.form}
179
- submission={{
180
- data: {
181
- editGrid: [{ currency: "EUR" }]
124
+ export const TriggerError = {
125
+ render: (args: any) => {
126
+ const onAsyncSubmit = (submission: Submission) => {
127
+ return new Promise((resolve, reject) => {
128
+ setTimeout(() => {
129
+ reject(new Error("server error"));
130
+ }, 500);
131
+ }).catch((error) => {
132
+ error.errors = {
133
+ message: "My custom message about this field",
134
+ type: "custom",
135
+ path: ["firstName"],
136
+ level: "error"
137
+ };
138
+ throw error;
139
+ });
140
+ };
141
+
142
+ return <Form<any> {...wrap(args)} form={args.form} onAsyncSubmit={onAsyncSubmit} />;
143
+ },
144
+ args: {
145
+ form: {
146
+ type: "form",
147
+ display: "form",
148
+ tags: [],
149
+ components: [
150
+ {
151
+ label: "First name",
152
+ widget: {
153
+ type: "input"
154
+ },
155
+ errorLabel: "",
156
+ key: "firstName",
157
+ inputType: "text",
158
+ type: "textfield",
159
+ id: "eqb1o4r",
160
+ defaultValue: ""
161
+ },
162
+ {
163
+ label: "Submit",
164
+ showValidations: false,
165
+ tableView: false,
166
+ key: "submit",
167
+ type: "button",
168
+ input: true
182
169
  }
183
- }}
184
- />
185
- );
186
- };
187
-
188
- ReadOnly.args = {
189
- readonly: true,
190
- form
170
+ ]
171
+ }
172
+ }
191
173
  };
192
174
 
193
- export const OnChange = (args: any) => {
194
- const [data, setForm] = useState<any>(() => {});
195
- const props = wrap(args);
196
-
197
- return (
198
- <Form
199
- {...props}
200
- options={{ template: "tailwind", iconset: "bx", readOnly: args.readOnly }}
201
- form={args.form}
202
- submission={{ data }}
203
- onChange={(changedSubmission) => {
204
- setForm(changedSubmission.data);
205
- }}
206
- />
207
- );
175
+ export const ReadOnly = {
176
+ render: (args: any) => {
177
+ return (
178
+ <Form
179
+ {...wrap(args)}
180
+ options={{ template: "tailwind", iconset: "bx", readOnly: args.readOnly }}
181
+ form={args.form}
182
+ submission={{
183
+ data: {
184
+ editGrid: [{ currency: "EUR" }]
185
+ }
186
+ }}
187
+ />
188
+ );
189
+ },
190
+
191
+ args: {
192
+ readonly: true,
193
+ form
194
+ }
208
195
  };
209
196
 
210
- OnChange.args = {
211
- form: {
212
- type: "form",
213
- display: "form",
214
- tags: [],
215
- components: [
216
- {
217
- label: "First name",
218
- widget: {
219
- type: "input"
220
- },
221
- errorLabel: "",
222
- key: "firstName",
223
- inputType: "text",
224
- type: "textfield",
225
- id: "eqb1o4r",
226
- defaultValue: "",
227
- validate: {
228
- required: true
229
- }
230
- },
231
- {
232
- label: "Last name",
233
- widget: {
234
- type: "input"
197
+ export const OnChange = {
198
+ render: function Render(args: any) {
199
+ const [data, setForm] = useState<any>(() => {});
200
+ const props = wrap(args);
201
+
202
+ return (
203
+ <Form
204
+ {...props}
205
+ options={{ template: "tailwind", iconset: "bx", readOnly: args.readOnly }}
206
+ form={args.form}
207
+ submission={{ data }}
208
+ onChange={(changedSubmission) => {
209
+ setForm(changedSubmission.data);
210
+ }}
211
+ />
212
+ );
213
+ },
214
+
215
+ args: {
216
+ form: {
217
+ type: "form",
218
+ display: "form",
219
+ tags: [],
220
+ components: [
221
+ {
222
+ label: "First name",
223
+ widget: {
224
+ type: "input"
225
+ },
226
+ errorLabel: "",
227
+ key: "firstName",
228
+ inputType: "text",
229
+ type: "textfield",
230
+ id: "eqb1o4r",
231
+ defaultValue: "",
232
+ validate: {
233
+ required: true
234
+ }
235
235
  },
236
- errorLabel: "",
237
- key: "lastName",
238
- inputType: "text",
239
- type: "textfield",
240
- id: "eqb1o4r",
241
- defaultValue: "",
242
- validate: {
243
- required: true
236
+ {
237
+ label: "Last name",
238
+ widget: {
239
+ type: "input"
240
+ },
241
+ errorLabel: "",
242
+ key: "lastName",
243
+ inputType: "text",
244
+ type: "textfield",
245
+ id: "eqb1o4r",
246
+ defaultValue: "",
247
+ validate: {
248
+ required: true
249
+ }
244
250
  }
245
- }
246
- ]
251
+ ]
252
+ }
247
253
  }
248
254
  };
@@ -114,7 +114,7 @@ export function useForm<Data = any>(props: UseFormHookProps<Data>) {
114
114
  if (hasEvent("onAsyncSubmit")) {
115
115
  try {
116
116
  await emit("onAsyncSubmit", submission, instance.current);
117
- } catch (err) {
117
+ } catch (err: any) {
118
118
  callback(err?.errors || err);
119
119
  }
120
120
  } else {