@tsed/react-formio 2.3.0 → 2.3.2

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 (26) hide show
  1. package/coverage.json +4 -4
  2. package/dist/components/actions-table/actionsTable.stories.d.ts +8 -53
  3. package/dist/components/form-access/formAccess.component.d.ts +2 -13
  4. package/dist/components/form-access/formAccess.stories.d.ts +3 -44
  5. package/dist/components/form-control/formControl.component.d.ts +3 -11
  6. package/dist/components/select/select.component.d.ts +5 -18
  7. package/dist/components/table/components/defaultCellOperations.component.d.ts +12 -1
  8. package/dist/components/table/components/defaultOperationButton.component.d.ts +4 -4
  9. package/dist/components/table/hooks/useOperations.hook.d.ts +2 -2
  10. package/dist/index.js +1113 -1265
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.modern.js +226 -244
  13. package/dist/index.modern.js.map +1 -1
  14. package/package.json +13 -6
  15. package/src/components/__fixtures__/form-actions.json +240 -0
  16. package/src/components/actions-table/__fixtures__/data.json +12 -0
  17. package/src/components/actions-table/actionsTable.component.spec.tsx +42 -11
  18. package/src/components/actions-table/actionsTable.component.tsx +2 -1
  19. package/src/components/actions-table/actionsTable.stories.tsx +71 -289
  20. package/src/components/form-access/formAccess.component.tsx +2 -12
  21. package/src/components/form-access/formAccess.stories.tsx +55 -49
  22. package/src/components/form-control/formControl.component.tsx +4 -11
  23. package/src/components/select/select.component.tsx +9 -22
  24. package/src/components/table/components/defaultCellOperations.component.tsx +17 -4
  25. package/src/components/table/components/defaultOperationButton.component.tsx +9 -4
  26. package/src/components/table/hooks/useOperations.hook.tsx +3 -3
package/package.json CHANGED
@@ -1,9 +1,15 @@
1
1
  {
2
2
  "name": "@tsed/react-formio",
3
- "version": "2.3.0",
3
+ "version": "2.3.2",
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
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.modern.js",
10
+ "require": "./dist/index.js"
11
+ }
12
+ },
7
13
  "source": "src/index.ts",
8
14
  "scripts": {
9
15
  "lint": "eslint \"**/*.{js,jsx,ts,tsx}\"",
@@ -16,7 +22,7 @@
16
22
  "dependencies": {
17
23
  "classnames": "^2.3.1",
18
24
  "eventemitter2": "^6.4.3",
19
- "prop-types": "^15.7.2"
25
+ "prop-types": "15.8.1"
20
26
  },
21
27
  "peerDependencies": {
22
28
  "@formio/choices.js": ">=9.0.1",
@@ -31,8 +37,9 @@
31
37
  "tooltip.js": ">=1.3.3"
32
38
  },
33
39
  "devDependencies": {
34
- "@tsed/tailwind": "2.3.0",
35
- "@tsed/tailwind-formio": "2.3.0"
40
+ "@tsed/tailwind": "2.3.2",
41
+ "@tsed/tailwind-formio": "2.3.2",
42
+ "microbundle": "0.13.0"
36
43
  },
37
44
  "repository": "https://github.com/TypedProject/tsed-formio",
38
45
  "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,32 +2,63 @@ 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 { Sandbox } from "./actionsTable.stories";
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(<Sandbox {...Sandbox.args} onAddAction={onAddAction} />);
42
+ render(<ActionsTable {...args} onAddAction={onAddAction} />);
12
43
 
13
- const btn = screen.getByRole("button", { name: /add action/i });
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(Sandbox.args.availableActions.length + 1);
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("Email");
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(<Sandbox {...Sandbox.args} onAddAction={onAddAction} />);
59
+ render(<ActionsTable {...args} onAddAction={onAddAction} />);
29
60
 
30
- const btn = screen.getByRole("button", { name: /add action/i });
61
+ const btn = screen.getByTestId("action-table-add");
31
62
 
32
63
  await fireEvent.click(btn);
33
64
  expect(onAddAction).not.toHaveBeenCalled();
@@ -35,16 +66,16 @@ describe("ActionsTable", () => {
35
66
  it("should call addAction with the selected action", async () => {
36
67
  const onAddAction = jest.fn();
37
68
 
38
- render(<Sandbox {...Sandbox.args} onAddAction={onAddAction} />);
69
+ render(<ActionsTable {...args} onAddAction={onAddAction} />);
39
70
 
40
- const btn = screen.getByRole("button", { name: /add action/i });
71
+ const btn = screen.getByTestId("action-table-add");
41
72
  const select = screen.getByRole("combobox");
42
73
 
43
- await userEvent.selectOptions(select, String(Sandbox.args.availableActions[1].value));
74
+ await userEvent.selectOptions(select, String(args.availableActions[1].value));
44
75
 
45
76
  await fireEvent.click(btn);
46
77
 
47
78
  expect(btn).not.toHaveProperty("disabled", true);
48
- expect(onAddAction).toHaveBeenCalledWith("webhook");
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={"submit"}
46
+ data-testid={"action-table-add"}
46
47
  disabled={currentAction === ""}
47
48
  className={"btn btn-success"}
48
49
  onClick={() => currentAction && onAddAction(currentAction)}