@tsed/react-formio 2.3.1 → 2.3.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.
- package/coverage.json +4 -4
- package/dist/components/actions-table/actionsTable.stories.d.ts +8 -53
- package/dist/components/form-access/formAccess.component.d.ts +2 -13
- package/dist/components/form-access/formAccess.stories.d.ts +3 -44
- package/dist/components/form-control/formControl.component.d.ts +3 -11
- package/dist/components/react-component/reactComponent.component.d.ts +1 -1
- package/dist/components/select/select.component.d.ts +5 -18
- package/dist/components/table/components/defaultCellOperations.component.d.ts +12 -1
- package/dist/components/table/components/defaultOperationButton.component.d.ts +4 -4
- package/dist/components/table/hooks/useOperations.hook.d.ts +2 -2
- package/dist/index.js +1184 -1334
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +300 -316
- package/dist/index.modern.js.map +1 -1
- package/package.json +13 -9
- package/src/components/__fixtures__/form-actions.json +240 -0
- package/src/components/actions-table/__fixtures__/data.json +12 -0
- package/src/components/actions-table/actionsTable.component.spec.tsx +44 -13
- package/src/components/actions-table/actionsTable.component.tsx +2 -1
- package/src/components/actions-table/actionsTable.stories.tsx +71 -289
- package/src/components/form/form.stories.tsx +1 -2
- package/src/components/form-access/formAccess.component.tsx +2 -13
- package/src/components/form-access/formAccess.stories.tsx +55 -49
- package/src/components/form-action/formAction.component.tsx +1 -0
- package/src/components/form-control/formControl.component.tsx +3 -10
- package/src/components/form-edit/formEdit.reducer.ts +0 -1
- package/src/components/form-settings/formSettings.component.spec.tsx +4 -4
- package/src/components/pagination/pagination.component.spec.tsx +0 -2
- package/src/components/react-component/reactComponent.component.tsx +5 -5
- package/src/components/select/select.component.tsx +10 -23
- package/src/components/table/components/defaultCellOperations.component.tsx +17 -4
- package/src/components/table/components/defaultOperationButton.component.tsx +11 -4
- package/src/components/table/components/defaultRow.component.tsx +1 -0
- package/src/components/table/filters/defaultColumnFilter.component.tsx +1 -0
- package/src/components/table/hooks/useOperations.hook.tsx +3 -3
- package/src/react-table.d.ts +2 -0
- package/dist/package.json +0 -3
package/package.json
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/react-formio",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.3",
|
|
4
4
|
"description": "Provide a react formio wrapper. Written in TypeScript.",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.modern.js",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.modern.js",
|
|
7
7
|
"exports": {
|
|
8
|
-
"
|
|
9
|
-
|
|
8
|
+
".": {
|
|
9
|
+
"tsed-source": "./src/index.ts",
|
|
10
|
+
"import": "./dist/index.modern.js",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.modern.js"
|
|
13
|
+
}
|
|
10
14
|
},
|
|
11
15
|
"source": "src/index.ts",
|
|
12
16
|
"scripts": {
|
|
13
|
-
"lint": "eslint \"**/*.{js,jsx,ts,tsx}\"",
|
|
14
17
|
"lint:fix": "yarn lint --fix",
|
|
15
18
|
"test": "cross-env NODE_ENV=test jest --coverage",
|
|
16
19
|
"test:coverage:update": "write-coverage",
|
|
@@ -20,7 +23,7 @@
|
|
|
20
23
|
"dependencies": {
|
|
21
24
|
"classnames": "^2.3.1",
|
|
22
25
|
"eventemitter2": "^6.4.3",
|
|
23
|
-
"prop-types": "
|
|
26
|
+
"prop-types": "15.8.1"
|
|
24
27
|
},
|
|
25
28
|
"peerDependencies": {
|
|
26
29
|
"@formio/choices.js": ">=9.0.1",
|
|
@@ -35,8 +38,9 @@
|
|
|
35
38
|
"tooltip.js": ">=1.3.3"
|
|
36
39
|
},
|
|
37
40
|
"devDependencies": {
|
|
38
|
-
"@tsed/tailwind": "2.3.
|
|
39
|
-
"@tsed/tailwind-formio": "2.3.
|
|
41
|
+
"@tsed/tailwind": "2.3.3",
|
|
42
|
+
"@tsed/tailwind-formio": "2.3.3",
|
|
43
|
+
"microbundle": "0.13.0"
|
|
40
44
|
},
|
|
41
45
|
"repository": "https://github.com/TypedProject/tsed-formio",
|
|
42
46
|
"bugs": {
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "webhook",
|
|
4
|
+
"title": "Webhook (Premium)",
|
|
5
|
+
"description": "Allows you to trigger an external interface.",
|
|
6
|
+
"priority": 0,
|
|
7
|
+
"defaults": {
|
|
8
|
+
"handler": ["after"],
|
|
9
|
+
"method": ["create", "update", "delete"],
|
|
10
|
+
"priority": 0,
|
|
11
|
+
"name": "webhook",
|
|
12
|
+
"title": "Webhook (Premium)"
|
|
13
|
+
},
|
|
14
|
+
"premium": true
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "sql",
|
|
18
|
+
"title": "SQL Query",
|
|
19
|
+
"description": "Allows you to execute a remote SQL Query.",
|
|
20
|
+
"priority": 0,
|
|
21
|
+
"defaults": {
|
|
22
|
+
"handler": ["after"],
|
|
23
|
+
"method": ["create"],
|
|
24
|
+
"priority": 0,
|
|
25
|
+
"name": "sql",
|
|
26
|
+
"title": "SQL Query"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "role",
|
|
31
|
+
"title": "Role Assignment",
|
|
32
|
+
"description": "Provides the Role Assignment capabilities.",
|
|
33
|
+
"priority": 1,
|
|
34
|
+
"defaults": {
|
|
35
|
+
"handler": ["after"],
|
|
36
|
+
"method": ["create"],
|
|
37
|
+
"priority": 1,
|
|
38
|
+
"name": "role",
|
|
39
|
+
"title": "Role Assignment"
|
|
40
|
+
},
|
|
41
|
+
"access": {
|
|
42
|
+
"handler": false,
|
|
43
|
+
"method": false
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "resetpass",
|
|
48
|
+
"title": "Reset Password",
|
|
49
|
+
"description": "Provides a way to reset a password field.",
|
|
50
|
+
"defaults": {
|
|
51
|
+
"handler": ["after", "before"],
|
|
52
|
+
"method": ["form", "create"],
|
|
53
|
+
"priority": 0,
|
|
54
|
+
"name": "resetpass",
|
|
55
|
+
"title": "Reset Password"
|
|
56
|
+
},
|
|
57
|
+
"access": {
|
|
58
|
+
"handler": false,
|
|
59
|
+
"method": false
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"name": "save",
|
|
64
|
+
"title": "Save Submission",
|
|
65
|
+
"description": "Saves the submission into the database.",
|
|
66
|
+
"priority": 10,
|
|
67
|
+
"defaults": {
|
|
68
|
+
"handler": ["before"],
|
|
69
|
+
"method": ["create", "update"],
|
|
70
|
+
"priority": 10,
|
|
71
|
+
"name": "save",
|
|
72
|
+
"title": "Save Submission"
|
|
73
|
+
},
|
|
74
|
+
"access": {
|
|
75
|
+
"handler": false,
|
|
76
|
+
"method": false
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"name": "login",
|
|
81
|
+
"title": "Login",
|
|
82
|
+
"description": "Provides a way to login to the application.",
|
|
83
|
+
"priority": 2,
|
|
84
|
+
"defaults": {
|
|
85
|
+
"handler": ["before"],
|
|
86
|
+
"method": ["create"],
|
|
87
|
+
"priority": 2,
|
|
88
|
+
"name": "login",
|
|
89
|
+
"title": "Login"
|
|
90
|
+
},
|
|
91
|
+
"access": {
|
|
92
|
+
"handler": false,
|
|
93
|
+
"method": false
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"name": "office365contact",
|
|
98
|
+
"title": "Office 365 Contacts (Premium)",
|
|
99
|
+
"description": "Allows you to integrate into your Office 365 Contacts.",
|
|
100
|
+
"priority": 0,
|
|
101
|
+
"defaults": {
|
|
102
|
+
"handler": ["after"],
|
|
103
|
+
"method": ["create", "update", "delete"],
|
|
104
|
+
"priority": 0,
|
|
105
|
+
"name": "office365contact",
|
|
106
|
+
"title": "Office 365 Contacts (Premium)"
|
|
107
|
+
},
|
|
108
|
+
"premium": true
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "office365calendar",
|
|
112
|
+
"title": "Office 365 Calendar (Premium)",
|
|
113
|
+
"description": "Allows you to integrate into your Office 365 Calendar.",
|
|
114
|
+
"premium": true,
|
|
115
|
+
"priority": 0,
|
|
116
|
+
"defaults": {
|
|
117
|
+
"handler": ["after"],
|
|
118
|
+
"method": ["create", "update", "delete"],
|
|
119
|
+
"priority": 0,
|
|
120
|
+
"name": "office365calendar",
|
|
121
|
+
"title": "Office 365 Calendar (Premium)"
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"name": "hubspotContact",
|
|
126
|
+
"title": "Hubspot Contact (Premium)",
|
|
127
|
+
"description": "Allows you to change contact fields in hubspot.",
|
|
128
|
+
"priority": 0,
|
|
129
|
+
"defaults": {
|
|
130
|
+
"handler": ["after"],
|
|
131
|
+
"method": ["create"],
|
|
132
|
+
"priority": 0,
|
|
133
|
+
"name": "hubspotContact",
|
|
134
|
+
"title": "Hubspot Contact (Premium)"
|
|
135
|
+
},
|
|
136
|
+
"premium": true
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"name": "oauth",
|
|
140
|
+
"title": "OAuth (Premium)",
|
|
141
|
+
"description": "Provides OAuth authentication behavior to this form.",
|
|
142
|
+
"priority": 20,
|
|
143
|
+
"defaults": {
|
|
144
|
+
"handler": ["after"],
|
|
145
|
+
"method": ["form", "create"],
|
|
146
|
+
"priority": 20,
|
|
147
|
+
"name": "oauth",
|
|
148
|
+
"title": "OAuth (Premium)"
|
|
149
|
+
},
|
|
150
|
+
"premium": true
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"name": "ldap",
|
|
154
|
+
"title": "LDAP Login (Premium)",
|
|
155
|
+
"description": "Provides ldap login.",
|
|
156
|
+
"priority": 3,
|
|
157
|
+
"defaults": {
|
|
158
|
+
"handler": ["before"],
|
|
159
|
+
"method": ["create"],
|
|
160
|
+
"priority": 3,
|
|
161
|
+
"name": "ldap",
|
|
162
|
+
"title": "LDAP Login (Premium)"
|
|
163
|
+
},
|
|
164
|
+
"premium": true
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"name": "googlesheet",
|
|
168
|
+
"title": "Google Sheets (Premium)",
|
|
169
|
+
"description": "Allows you to integrate data into Google sheets.",
|
|
170
|
+
"priority": 0,
|
|
171
|
+
"defaults": {
|
|
172
|
+
"handler": ["after"],
|
|
173
|
+
"method": ["create", "update", "delete"],
|
|
174
|
+
"priority": 0,
|
|
175
|
+
"name": "googlesheet",
|
|
176
|
+
"title": "Google Sheets (Premium)"
|
|
177
|
+
},
|
|
178
|
+
"premium": true
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"name": "sqlconnector",
|
|
182
|
+
"title": "SQL Connector (Premium)",
|
|
183
|
+
"description": "Allows you to execute a remote SQL Query via Resquel.",
|
|
184
|
+
"priority": 0,
|
|
185
|
+
"defaults": {
|
|
186
|
+
"handler": ["after"],
|
|
187
|
+
"method": ["create", "update", "delete"],
|
|
188
|
+
"priority": 0,
|
|
189
|
+
"name": "sqlconnector",
|
|
190
|
+
"title": "SQL Connector (Premium)"
|
|
191
|
+
},
|
|
192
|
+
"premium": true
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"name": "jira",
|
|
196
|
+
"title": "Jira (Premium)",
|
|
197
|
+
"description": "Allows you to create issues within Jira.",
|
|
198
|
+
"priority": 0,
|
|
199
|
+
"defaults": {
|
|
200
|
+
"handler": ["after"],
|
|
201
|
+
"method": ["create", "update", "delete"],
|
|
202
|
+
"priority": 0,
|
|
203
|
+
"name": "jira",
|
|
204
|
+
"title": "Jira (Premium)"
|
|
205
|
+
},
|
|
206
|
+
"premium": true
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"name": "group",
|
|
210
|
+
"title": "Group Assignment (Premium)",
|
|
211
|
+
"premium": true,
|
|
212
|
+
"description": "Provides the Group Assignment capabilities.",
|
|
213
|
+
"priority": 5,
|
|
214
|
+
"defaults": {
|
|
215
|
+
"handler": ["after"],
|
|
216
|
+
"method": ["create", "update", "delete"],
|
|
217
|
+
"priority": 5,
|
|
218
|
+
"name": "group",
|
|
219
|
+
"title": "Group Assignment (Premium)"
|
|
220
|
+
},
|
|
221
|
+
"access": {
|
|
222
|
+
"handler": false,
|
|
223
|
+
"method": false
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"name": "twilioSMS",
|
|
228
|
+
"title": "Twilio SMS (Premium)",
|
|
229
|
+
"premium": true,
|
|
230
|
+
"description": "Allows you to send SMS to phone numbers.",
|
|
231
|
+
"priority": 0,
|
|
232
|
+
"defaults": {
|
|
233
|
+
"handler": ["after"],
|
|
234
|
+
"method": ["create"],
|
|
235
|
+
"priority": 0,
|
|
236
|
+
"name": "twilioSMS",
|
|
237
|
+
"title": "Twilio SMS (Premium)"
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
]
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"_id": "602967600685b2158b24e99a",
|
|
4
|
+
"handler": ["before"],
|
|
5
|
+
"method": ["create", "update"],
|
|
6
|
+
"priority": 10,
|
|
7
|
+
"name": "save",
|
|
8
|
+
"title": "Save Submission",
|
|
9
|
+
"form": "602967600685b24dbe24e999",
|
|
10
|
+
"machineName": "tcspjwhsevrzpcd:testForm:save"
|
|
11
|
+
}
|
|
12
|
+
]
|
|
@@ -2,49 +2,80 @@ import { fireEvent, render, screen } from "@testing-library/react";
|
|
|
2
2
|
import userEvent from "@testing-library/user-event";
|
|
3
3
|
import React from "react";
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import availableActions from "../__fixtures__/form-actions.json";
|
|
6
|
+
import data from "./__fixtures__/data.json";
|
|
7
|
+
import { ActionsTable } from "./actionsTable.component";
|
|
8
|
+
|
|
9
|
+
const args: any = {
|
|
10
|
+
data: data,
|
|
11
|
+
availableActions: availableActions.map(({ name, title }) => ({
|
|
12
|
+
label: title,
|
|
13
|
+
value: name
|
|
14
|
+
})),
|
|
15
|
+
operations: [
|
|
16
|
+
{
|
|
17
|
+
title: "Edit",
|
|
18
|
+
action: "edit",
|
|
19
|
+
alias: "row",
|
|
20
|
+
path: "/resources/:resourceId/submissions/:submissionId",
|
|
21
|
+
icon: "edit",
|
|
22
|
+
permissionsResolver() {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
action: "delete",
|
|
28
|
+
path: "/resources/:resourceId/submissions/:submissionId/delete",
|
|
29
|
+
icon: "trash",
|
|
30
|
+
buttonType: "danger",
|
|
31
|
+
permissionsResolver() {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
};
|
|
6
37
|
|
|
7
38
|
describe("ActionsTable", () => {
|
|
8
39
|
it("should render the table actions", async () => {
|
|
9
40
|
const onAddAction = jest.fn();
|
|
10
41
|
|
|
11
|
-
render(<
|
|
42
|
+
render(<ActionsTable {...args} onAddAction={onAddAction} />);
|
|
12
43
|
|
|
13
|
-
const btn = screen.
|
|
44
|
+
const btn = screen.getByTestId("action-table-add");
|
|
14
45
|
const cells = screen.getAllByRole("cell");
|
|
15
46
|
const options = screen.getAllByRole("option");
|
|
16
47
|
|
|
17
48
|
expect(btn).toHaveProperty("disabled");
|
|
18
49
|
expect(btn.innerHTML).toMatch("Add action");
|
|
19
50
|
expect(cells[0].innerHTML).toMatch("Save Submission");
|
|
20
|
-
expect(options.length).toEqual(
|
|
51
|
+
expect(options.length).toEqual(availableActions.length + 1);
|
|
21
52
|
|
|
22
53
|
expect(options[0].innerHTML).toMatch("Select an action");
|
|
23
|
-
expect(options[1].innerHTML).toMatch("
|
|
54
|
+
expect(options[1].innerHTML).toMatch("Webhook (Premium)");
|
|
24
55
|
});
|
|
25
56
|
it("should not call addAction when the default item is selected", async () => {
|
|
26
57
|
const onAddAction = jest.fn();
|
|
27
58
|
|
|
28
|
-
render(<
|
|
59
|
+
render(<ActionsTable {...args} onAddAction={onAddAction} />);
|
|
29
60
|
|
|
30
|
-
const btn = screen.
|
|
61
|
+
const btn = screen.getByTestId("action-table-add");
|
|
31
62
|
|
|
32
|
-
|
|
63
|
+
fireEvent.click(btn);
|
|
33
64
|
expect(onAddAction).not.toHaveBeenCalled();
|
|
34
65
|
});
|
|
35
66
|
it("should call addAction with the selected action", async () => {
|
|
36
67
|
const onAddAction = jest.fn();
|
|
37
68
|
|
|
38
|
-
render(<
|
|
69
|
+
render(<ActionsTable {...args} onAddAction={onAddAction} />);
|
|
39
70
|
|
|
40
|
-
const btn = screen.
|
|
71
|
+
const btn = screen.getByTestId("action-table-add");
|
|
41
72
|
const select = screen.getByRole("combobox");
|
|
42
73
|
|
|
43
|
-
await userEvent.selectOptions(select, String(
|
|
74
|
+
await userEvent.selectOptions(select, String(args.availableActions[1].value));
|
|
44
75
|
|
|
45
|
-
|
|
76
|
+
fireEvent.click(btn);
|
|
46
77
|
|
|
47
78
|
expect(btn).not.toHaveProperty("disabled", true);
|
|
48
|
-
expect(onAddAction).toHaveBeenCalledWith("
|
|
79
|
+
expect(onAddAction).toHaveBeenCalledWith("sql");
|
|
49
80
|
});
|
|
50
81
|
});
|
|
@@ -35,6 +35,7 @@ export function ActionsTable({
|
|
|
35
35
|
<Table {...props} disableFilters={disableFilters} disablePagination={disablePagination} columns={columns}>
|
|
36
36
|
<div className={"pagination-group"}>
|
|
37
37
|
<Select
|
|
38
|
+
data-testid={"action-table-select"}
|
|
38
39
|
name={"actions"}
|
|
39
40
|
value={currentAction}
|
|
40
41
|
choices={[{ label: i18n("Select an action"), value: "" }].concat(availableActions)}
|
|
@@ -42,7 +43,7 @@ export function ActionsTable({
|
|
|
42
43
|
/>
|
|
43
44
|
<div className={"pl-3"}>
|
|
44
45
|
<button
|
|
45
|
-
data-testid={"
|
|
46
|
+
data-testid={"action-table-add"}
|
|
46
47
|
disabled={currentAction === ""}
|
|
47
48
|
className={"btn btn-success"}
|
|
48
49
|
onClick={() => currentAction && onAddAction(currentAction)}
|