@tsed/react-formio 1.10.8 → 1.10.12
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/.eslintrc +7 -2
- package/dist/components/form/form.component.d.ts +2 -44
- package/dist/components/form/useForm.hook.d.ts +56 -1
- package/dist/components/form-action/formAction.component.d.ts +1 -1
- package/dist/components/form-edit/formEdit.component.d.ts +4 -15
- package/dist/components/form-edit/useFormEdit.hook.d.ts +29 -0
- package/dist/index.js +7368 -7146
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +7292 -7066
- package/dist/index.modern.js.map +1 -1
- package/package.json +12 -12
- package/readme.md +81 -55
- package/src/components/actions-table/actionsTable.component.spec.tsx +15 -17
- package/src/components/actions-table/actionsTable.component.tsx +1 -0
- package/src/components/card/card.component.spec.tsx +2 -2
- package/src/components/card/card.component.tsx +2 -4
- package/src/components/form/form.component.tsx +3 -47
- package/src/components/form/useForm.hook.ts +62 -8
- package/src/components/form-access/formAccess.component.tsx +2 -1
- package/src/components/form-action/formAction.component.tsx +1 -1
- package/src/components/form-builder/formBuilder.component.tsx +2 -0
- package/src/components/form-edit/formEdit.component.tsx +5 -11
- package/src/components/form-edit/{useForm.hook.ts → useFormEdit.hook.ts} +8 -14
- package/src/components/form-settings/formSettings.component.tsx +3 -1
- package/src/components/forms-table/components/formCell.component.tsx +2 -2
- package/src/components/input-text/inputText.component.tsx +1 -1
- package/src/components/loader/loader.component.spec.tsx +2 -2
- package/src/components/loader/loader.component.tsx +1 -1
- package/src/components/modal/modal.component.spec.tsx +3 -3
- package/src/components/modal/modal.component.tsx +6 -1
- package/src/components/modal/modal.stories.tsx +5 -21
- package/src/components/modal/removeModal.component.tsx +1 -1
- package/src/components/react-component/reactComponent.component.tsx +1 -0
- package/src/components/select/select.component.tsx +1 -1
- package/src/components/table/components/defaultOperationButton.component.tsx +2 -2
- package/src/components/table/filters/defaultColumnFilter.component.spec.tsx +2 -2
- package/src/components/table/table.component.tsx +16 -5
- package/src/components/tabs/tabs.component.stories.tsx +1 -1
- package/dist/components/form-edit/useForm.hook.d.ts +0 -16
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useState } from "react";
|
|
2
2
|
import { FormOptions, FormSchema } from "../../interfaces";
|
|
3
3
|
import { getFormSettingsSchema } from "./formSettings.schema";
|
|
4
|
-
import {
|
|
4
|
+
import { Form } from "../form/form.component";
|
|
5
5
|
import {
|
|
6
6
|
FormSettingsSchema,
|
|
7
7
|
formSettingsToSubmission,
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from "./formSettings.utils";
|
|
10
10
|
import isEqual from "lodash/isEqual";
|
|
11
11
|
import noop from "lodash/noop";
|
|
12
|
+
import { ChangedSubmission } from "../form/useForm.hook";
|
|
12
13
|
|
|
13
14
|
export interface FormSettingsProps {
|
|
14
15
|
form: Partial<FormSchema>;
|
|
@@ -84,6 +85,7 @@ export function FormSettings(props: FormSettingsProps) {
|
|
|
84
85
|
disabled={!isValid}
|
|
85
86
|
className={"mt-5 btn btn-primary"}
|
|
86
87
|
onClick={onSubmit}
|
|
88
|
+
type={"submit"}
|
|
87
89
|
>
|
|
88
90
|
{i18n("Save settings")}
|
|
89
91
|
</button>
|
|
@@ -32,7 +32,7 @@ export function FormsCell(
|
|
|
32
32
|
</span>
|
|
33
33
|
|
|
34
34
|
{(form.tags || []).map((tag, index) => (
|
|
35
|
-
<
|
|
35
|
+
<button
|
|
36
36
|
key={index}
|
|
37
37
|
className='badge badge-hover bg-secondary mr-1'
|
|
38
38
|
onClick={stopPropagationWrapper(() => {
|
|
@@ -42,7 +42,7 @@ export function FormsCell(
|
|
|
42
42
|
>
|
|
43
43
|
<i className={classnames(iconClass(undefined, "tags"), "mr-1")} />
|
|
44
44
|
{tag}
|
|
45
|
-
</
|
|
45
|
+
</button>
|
|
46
46
|
))}
|
|
47
47
|
</li>
|
|
48
48
|
</ul>
|
|
@@ -6,7 +6,7 @@ describe("Loader", () => {
|
|
|
6
6
|
it("should render a component (with isActive = true)", () => {
|
|
7
7
|
const { getByTestId } = render(<Loader isActive={true} />);
|
|
8
8
|
|
|
9
|
-
const icon = getByTestId("
|
|
9
|
+
const icon = getByTestId("icon_radio-circle");
|
|
10
10
|
|
|
11
11
|
expect(icon).toBeTruthy();
|
|
12
12
|
});
|
|
@@ -14,7 +14,7 @@ describe("Loader", () => {
|
|
|
14
14
|
it("should render a component (with isActive = false)", () => {
|
|
15
15
|
const { queryByTestId } = render(<Loader isActive={false} />);
|
|
16
16
|
|
|
17
|
-
const icon = queryByTestId("
|
|
17
|
+
const icon = queryByTestId("icon_radio-circle");
|
|
18
18
|
|
|
19
19
|
expect(icon).toBeFalsy();
|
|
20
20
|
});
|
|
@@ -16,7 +16,7 @@ describe("Modal", () => {
|
|
|
16
16
|
expect(queryByTestId("modalBody")).toBeFalsy();
|
|
17
17
|
expect(queryByTestId("modalFooter")).toBeFalsy();
|
|
18
18
|
|
|
19
|
-
fireEvent.click(screen.getByRole("
|
|
19
|
+
fireEvent.click(screen.getByRole("button", { name: "Open modal" }));
|
|
20
20
|
|
|
21
21
|
await waitFor(() => getByTestId("modalTitle"));
|
|
22
22
|
|
|
@@ -45,7 +45,7 @@ describe("Modal", () => {
|
|
|
45
45
|
expect(queryByTestId("modalBody")).toBeFalsy();
|
|
46
46
|
expect(queryByTestId("modalFooter")).toBeFalsy();
|
|
47
47
|
|
|
48
|
-
fireEvent.click(getByRole("
|
|
48
|
+
fireEvent.click(getByRole("button", { name: "Open modal" }));
|
|
49
49
|
|
|
50
50
|
await waitFor(() => getByTestId("modalTitle"));
|
|
51
51
|
|
|
@@ -67,7 +67,7 @@ describe("Modal", () => {
|
|
|
67
67
|
<WithFooter {...WithFooter.args} onSubmit={onSubmit} />
|
|
68
68
|
);
|
|
69
69
|
|
|
70
|
-
fireEvent.click(getByRole("
|
|
70
|
+
fireEvent.click(getByRole("button", { name: "Open modal" }));
|
|
71
71
|
|
|
72
72
|
await waitFor(() => getByTestId("modalTitle"));
|
|
73
73
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
2
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
1
3
|
import React, { PropsWithChildren, useEffect, useRef, useState } from "react";
|
|
2
4
|
import noop from "lodash";
|
|
3
5
|
|
|
@@ -61,7 +63,10 @@ export function Modal({
|
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
return (
|
|
64
|
-
<div
|
|
66
|
+
<div
|
|
67
|
+
role={"dialog"}
|
|
68
|
+
className={`formio-dialog formio-dialog-theme-default ${className}`}
|
|
69
|
+
>
|
|
65
70
|
<div className='formio-dialog-overlay' onClick={onClickClose} />
|
|
66
71
|
<div style={style} className={"formio-dialog-content"}>
|
|
67
72
|
<div className={"formio-dialog-wrapper"}>
|
|
@@ -26,11 +26,7 @@ export const Sandbox = (args: ModalProps) => {
|
|
|
26
26
|
return (
|
|
27
27
|
<div>
|
|
28
28
|
<div>
|
|
29
|
-
<button
|
|
30
|
-
role={"openModal"}
|
|
31
|
-
className={"btn btn-primary"}
|
|
32
|
-
onClick={modal.openModal}
|
|
33
|
-
>
|
|
29
|
+
<button className={"btn btn-primary"} onClick={modal.openModal}>
|
|
34
30
|
Open modal
|
|
35
31
|
</button>
|
|
36
32
|
</div>
|
|
@@ -51,11 +47,7 @@ export const WithTitle = (args: ModalProps) => {
|
|
|
51
47
|
return (
|
|
52
48
|
<div>
|
|
53
49
|
<div>
|
|
54
|
-
<button
|
|
55
|
-
role={"openModal"}
|
|
56
|
-
className={"btn btn-primary"}
|
|
57
|
-
onClick={modal.openModal}
|
|
58
|
-
>
|
|
50
|
+
<button className={"btn btn-primary"} onClick={modal.openModal}>
|
|
59
51
|
Open modal
|
|
60
52
|
</button>
|
|
61
53
|
</div>
|
|
@@ -103,11 +95,7 @@ export const WithFooter = (args: ModalProps) => {
|
|
|
103
95
|
return (
|
|
104
96
|
<div>
|
|
105
97
|
<div>
|
|
106
|
-
<button
|
|
107
|
-
className={"btn btn-primary"}
|
|
108
|
-
role={"openModal"}
|
|
109
|
-
onClick={modal.openModal}
|
|
110
|
-
>
|
|
98
|
+
<button className={"btn btn-primary"} onClick={modal.openModal}>
|
|
111
99
|
Open modal
|
|
112
100
|
</button>
|
|
113
101
|
</div>
|
|
@@ -185,12 +173,8 @@ export const WithRemoveModal = (args: RemoveModalProps) => {
|
|
|
185
173
|
return (
|
|
186
174
|
<div>
|
|
187
175
|
<div>
|
|
188
|
-
<button
|
|
189
|
-
|
|
190
|
-
role={"openModal"}
|
|
191
|
-
onClick={modal.openModal}
|
|
192
|
-
>
|
|
193
|
-
Open
|
|
176
|
+
<button className={"btn btn-primary"} onClick={modal.openModal}>
|
|
177
|
+
Open modal
|
|
194
178
|
</button>
|
|
195
179
|
</div>
|
|
196
180
|
<RemoveModal
|
|
@@ -106,6 +106,7 @@ export class ReactComponent<Data = any> extends Components.components.field {
|
|
|
106
106
|
*/
|
|
107
107
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
108
108
|
attachReact(element?: any) {
|
|
109
|
+
// eslint-disable-next-line react/no-render-return-value
|
|
109
110
|
return ReactDOM.render(this.renderReact(), element);
|
|
110
111
|
}
|
|
111
112
|
|
|
@@ -30,7 +30,7 @@ export function DefaultOperationButton(props: OperationButtonProps) {
|
|
|
30
30
|
} = props;
|
|
31
31
|
|
|
32
32
|
return (
|
|
33
|
-
<
|
|
33
|
+
<button
|
|
34
34
|
className={classnames(
|
|
35
35
|
className,
|
|
36
36
|
["btn", buttonOutline && "outline", buttonType]
|
|
@@ -48,6 +48,6 @@ export function DefaultOperationButton(props: OperationButtonProps) {
|
|
|
48
48
|
{title && (
|
|
49
49
|
<span className={icon && title ? "ml-1" : ""}>{i18n(title)}</span>
|
|
50
50
|
)}
|
|
51
|
-
</
|
|
51
|
+
</button>
|
|
52
52
|
);
|
|
53
53
|
}
|
|
@@ -12,13 +12,13 @@ describe("DefaultColumnFilter", () => {
|
|
|
12
12
|
column: { id: "id", filterValue: "", setFilter: jest.fn() }
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
const {
|
|
15
|
+
const { getByRole } = render(
|
|
16
16
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
17
17
|
// @ts-ignore
|
|
18
18
|
<DefaultColumnFilter {...props} />
|
|
19
19
|
);
|
|
20
20
|
|
|
21
|
-
const input =
|
|
21
|
+
const input = getByRole("textbox");
|
|
22
22
|
|
|
23
23
|
await act(async () => {
|
|
24
24
|
fireEvent.change(input, { target: { value: "value-test" } });
|
|
@@ -215,10 +215,14 @@ export function Table<Data extends object = any>(
|
|
|
215
215
|
/* style={{ marginBottom: disablePagination ? "-1px" : "0px" }} */
|
|
216
216
|
>
|
|
217
217
|
<thead>
|
|
218
|
-
{tableInstance.headerGroups.map((headerGroup) => (
|
|
219
|
-
<tr
|
|
218
|
+
{tableInstance.headerGroups.map((headerGroup, i) => (
|
|
219
|
+
<tr
|
|
220
|
+
key={`tableInstance.headerGroups${i}`}
|
|
221
|
+
{...headerGroup.getHeaderGroupProps()}
|
|
222
|
+
>
|
|
220
223
|
{headerGroup.headers.map((column) => (
|
|
221
224
|
<th
|
|
225
|
+
key={`tableInstance.headers.column.${column.id}`}
|
|
222
226
|
/* className='text-left py-2 align-top' */
|
|
223
227
|
{...column.getHeaderProps()}
|
|
224
228
|
>
|
|
@@ -230,20 +234,27 @@ export function Table<Data extends object = any>(
|
|
|
230
234
|
</thead>
|
|
231
235
|
{!isLoading ? (
|
|
232
236
|
<tbody {...tableInstance.getTableBodyProps()}>
|
|
233
|
-
{tableInstance.page.map((row
|
|
237
|
+
{tableInstance.page.map((row) => {
|
|
234
238
|
tableInstance.prepareRow(row);
|
|
235
239
|
return (
|
|
236
240
|
<tr
|
|
241
|
+
key={`tableInstance.page.${row.id}`}
|
|
237
242
|
onClick={() => _onClick(row.original, "row")}
|
|
238
243
|
{...row.getRowProps()}
|
|
239
244
|
>
|
|
240
|
-
{row.cells.map((cell) => {
|
|
245
|
+
{row.cells.map((cell, i) => {
|
|
241
246
|
const { hidden, colspan } = cell.column as any;
|
|
242
247
|
if (hidden) {
|
|
243
248
|
return null;
|
|
244
249
|
}
|
|
245
250
|
return (
|
|
246
|
-
<td
|
|
251
|
+
<td
|
|
252
|
+
key={`tableInstance.page.cells.${
|
|
253
|
+
cell.value || "value"
|
|
254
|
+
}.${i}`}
|
|
255
|
+
colSpan={colspan}
|
|
256
|
+
{...cell.getCellProps()}
|
|
257
|
+
>
|
|
247
258
|
{cell.render("Cell")}
|
|
248
259
|
</td>
|
|
249
260
|
);
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { FormSchema } from "../../interfaces/FormSchema";
|
|
2
|
-
export interface UseFormHookProps {
|
|
3
|
-
form: Partial<FormSchema>;
|
|
4
|
-
redo: Function;
|
|
5
|
-
undo: Function;
|
|
6
|
-
reset: Function;
|
|
7
|
-
hasChanged: boolean;
|
|
8
|
-
isValid: boolean;
|
|
9
|
-
hasUndo: boolean;
|
|
10
|
-
hasRedo: boolean;
|
|
11
|
-
onSubmit: () => void;
|
|
12
|
-
onCopy: () => void;
|
|
13
|
-
formChange: (newForm: Partial<FormSchema>) => void;
|
|
14
|
-
setChange: (path: string, value: any) => void;
|
|
15
|
-
}
|
|
16
|
-
export declare function useForm(props: any): UseFormHookProps;
|