@tsed/react-formio 1.11.1 → 1.13.0
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/.env +2 -1
- package/craco.config.js +11 -1
- package/dist/components/alert/alert.component.spec.d.ts +1 -0
- package/dist/components/alert/alert.stories.d.ts +15 -0
- package/dist/components/card/card.component.d.ts +2 -1
- package/dist/components/form/form.component.d.ts +2 -0
- package/dist/components/form/form.stories.d.ts +37 -0
- package/dist/components/form/useForm.hook.d.ts +1 -0
- package/dist/components/form-action/formAction.stories.d.ts +90 -414
- package/dist/components/input-text/inputText.component.d.ts +1 -1
- package/dist/components/input-text/inputText.component.spec.d.ts +1 -0
- package/dist/components/loader/loader.component.d.ts +2 -2
- package/dist/components/loader/loader.stories.d.ts +15 -0
- package/dist/components/pagination/pagination.component.spec.d.ts +1 -0
- package/dist/components/pagination/pagination.stories.d.ts +0 -27
- package/dist/components/select/select.component.spec.d.ts +1 -0
- package/dist/components/tabs/tabs.component.spec.d.ts +1 -0
- package/dist/index.js +114 -35
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +86 -34
- package/dist/index.modern.js.map +1 -1
- package/jest.config.js +1 -1
- package/package.json +5 -9
- package/readme.md +114 -86
- package/src/components/__fixtures__/form-schema.json +10 -42
- package/src/components/__fixtures__/form.fixture.json +1 -1
- package/src/components/actions-table/actionsTable.component.spec.tsx +4 -13
- package/src/components/actions-table/actionsTable.component.tsx +3 -11
- package/src/components/alert/alert.component.spec.tsx +97 -0
- package/src/components/alert/alert.component.tsx +2 -8
- package/src/components/alert/alert.stories.tsx +17 -0
- package/src/components/card/card.component.tsx +2 -5
- package/src/components/form/form.component.tsx +4 -8
- package/src/components/form/form.stories.tsx +66 -2
- package/src/components/form/useForm.hook.ts +29 -14
- package/src/components/form-access/formAccess.component.tsx +19 -82
- package/src/components/form-access/formAccess.schema.ts +7 -23
- package/src/components/form-access/formAccess.stories.tsx +2 -9
- package/src/components/form-access/formAccess.utils.spec.ts +4 -22
- package/src/components/form-access/formAccess.utils.ts +7 -29
- package/src/components/form-action/formAction.component.tsx +3 -19
- package/src/components/form-action/formAction.stories.tsx +251 -672
- package/src/components/form-builder/formBuilder.component.tsx +4 -13
- package/src/components/form-builder/formBuilder.stories.tsx +12 -24
- package/src/components/form-control/formControl.component.tsx +2 -8
- package/src/components/form-edit/formCtas.component.tsx +5 -23
- package/src/components/form-edit/formEdit.component.tsx +2 -20
- package/src/components/form-edit/formEdit.reducer.ts +2 -8
- package/src/components/form-edit/formEdit.stories.tsx +3 -15
- package/src/components/form-edit/formParameters.component.tsx +3 -20
- package/src/components/form-edit/useFormEdit.hook.ts +2 -9
- package/src/components/form-settings/formSettings.component.spec.tsx +2 -9
- package/src/components/form-settings/formSettings.component.tsx +6 -34
- package/src/components/form-settings/formSettings.stories.tsx +1 -6
- package/src/components/form-settings/formSettings.utils.spec.ts +1 -4
- package/src/components/form-settings/formSettings.utils.ts +2 -7
- package/src/components/forms-table/components/formCell.component.tsx +2 -6
- package/src/components/forms-table/formsTable.component.tsx +2 -7
- package/src/components/input-tags/inputTags.component.tsx +10 -34
- package/src/components/input-tags/inputTags.stories.tsx +4 -14
- package/src/components/input-text/inputText.component.spec.tsx +56 -0
- package/src/components/input-text/inputText.component.tsx +4 -5
- package/src/components/input-text/inputText.stories.tsx +6 -26
- package/src/components/loader/loader.component.spec.tsx +7 -6
- package/src/components/loader/loader.component.tsx +3 -12
- package/src/components/loader/loader.stories.tsx +17 -0
- package/src/components/modal/modal.component.spec.tsx +8 -14
- package/src/components/modal/modal.component.tsx +6 -27
- package/src/components/modal/modal.stories.tsx +1 -5
- package/src/components/modal/removeModal.component.tsx +4 -22
- package/src/components/pagination/pagination.component.spec.tsx +111 -0
- package/src/components/pagination/pagination.component.tsx +10 -42
- package/src/components/pagination/pagination.stories.tsx +9 -29
- package/src/components/react-component/reactComponent.component.tsx +3 -11
- package/src/components/select/select.component.spec.tsx +86 -0
- package/src/components/select/select.component.tsx +11 -15
- package/src/components/select/select.stories.tsx +6 -26
- package/src/components/submissions-table/submissionsTable.component.tsx +1 -3
- package/src/components/submissions-table/submissionsTable.stories.tsx +1 -1
- package/src/components/table/components/defaultArrowSort.component.tsx +1 -10
- package/src/components/table/components/defaultCell.component.tsx +1 -4
- package/src/components/table/components/defaultCellHeader.component.tsx +4 -14
- package/src/components/table/components/defaultCellOperations.component.tsx +14 -25
- package/src/components/table/components/defaultOperationButton.component.tsx +2 -10
- package/src/components/table/filters/defaultColumnFilter.component.spec.tsx +1 -1
- package/src/components/table/filters/selectColumnFilter.component.spec.tsx +2 -10
- package/src/components/table/filters/selectColumnFilter.component.tsx +2 -6
- package/src/components/table/table.component.tsx +13 -53
- package/src/components/table/table.stories.tsx +1 -1
- package/src/components/table/utils/getPageNumbers.ts +3 -11
- package/src/components/table/utils/mapFormToColumns.tsx +14 -22
- package/src/components/table/utils/useOperations.hook.tsx +2 -12
- package/src/components/tabs/tabs.component.spec.tsx +86 -0
- package/src/components/tabs/tabs.component.stories.tsx +2 -9
- package/src/components/tabs/tabs.component.tsx +9 -43
- package/src/interfaces/Operation.ts +1 -4
- package/src/react-table.d.ts +9 -28
- package/src/stores/action/action.actions.ts +31 -33
- package/src/stores/action/action.reducers.spec.ts +1 -8
- package/src/stores/action/action.reducers.ts +1 -8
- package/src/stores/action/action.selectors.ts +1 -2
- package/src/stores/action-info/action-info.actions.spec.ts +1 -5
- package/src/stores/action-info/action-info.actions.ts +16 -19
- package/src/stores/action-info/action-info.reducers.spec.ts +1 -6
- package/src/stores/action-info/action-info.reducers.ts +1 -6
- package/src/stores/action-info/action-info.selectors.ts +1 -4
- package/src/stores/actions/actions.actions.spec.ts +1 -6
- package/src/stores/actions/actions.actions.ts +16 -19
- package/src/stores/actions/actions.reducers.spec.ts +1 -6
- package/src/stores/actions/actions.reducers.ts +1 -6
- package/src/stores/actions/actions.selectors.ts +2 -4
- package/src/stores/auth/auth.reducers.ts +1 -4
- package/src/stores/auth/auth.selectors.spec.ts +1 -5
- package/src/stores/auth/auth.selectors.ts +3 -6
- package/src/stores/auth/auth.utils.tsx +2 -8
- package/src/stores/auth/getAccess.action.spec.ts +11 -54
- package/src/stores/auth/getAccess.action.ts +1 -6
- package/src/stores/auth/initAuth.action.ts +15 -17
- package/src/stores/form/form.actions.spec.ts +8 -39
- package/src/stores/form/form.actions.ts +55 -64
- package/src/stores/form/form.reducers.spec.ts +1 -7
- package/src/stores/form/form.reducers.ts +1 -8
- package/src/stores/form/form.selectors.ts +1 -2
- package/src/stores/forms/forms.actions.spec.ts +5 -18
- package/src/stores/forms/forms.actions.ts +17 -21
- package/src/stores/forms/forms.reducers.spec.ts +1 -6
- package/src/stores/forms/forms.reducers.ts +2 -13
- package/src/stores/forms/forms.selectors.ts +2 -4
- package/src/stores/index.spec.ts +6 -9
- package/src/stores/root/root.selectors.spec.ts +1 -6
- package/src/stores/root/root.selectors.ts +6 -24
- package/src/stores/submission/submission.actions.spec.ts +11 -33
- package/src/stores/submission/submission.actions.ts +57 -66
- package/src/stores/submission/submission.reducers.spec.ts +17 -27
- package/src/stores/submission/submission.reducers.ts +1 -4
- package/src/stores/submission/submission.selectors.ts +1 -4
- package/src/stores/submissions/submissions.actions.spec.ts +5 -18
- package/src/stores/submissions/submissions.actions.ts +17 -26
- package/src/stores/submissions/submissions.reducers.spec.ts +3 -12
- package/src/stores/submissions/submissions.reducers.ts +3 -17
- package/src/stores/submissions/submissions.selectors.spec.ts +1 -4
- package/src/stores/submissions/submissions.selectors.ts +2 -4
- package/src/utils/getEventValue.ts +1 -4
- package/src/utils/iconClass.ts +2 -10
- package/src/utils/mapPagination.ts +1 -6
- package/src/utils/mapRequestParams.ts +2 -12
- package/src/utils/url.test.ts +4 -12
- package/src/utils/url.ts +2 -7
- package/tsconfig.json +4 -12
- package/tsconfig.test.json +1 -1
- package/.eslintrc +0 -47
- package/.prettierrc +0 -10
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
failSubmission,
|
|
3
|
-
receiveSubmission,
|
|
4
|
-
requestSubmission,
|
|
5
|
-
resetSubmission,
|
|
6
|
-
sendSubmission
|
|
7
|
-
} from "./submission.actions";
|
|
1
|
+
import { failSubmission, receiveSubmission, requestSubmission, resetSubmission, sendSubmission } from "./submission.actions";
|
|
8
2
|
import { submissionReducer } from "./submission.reducers";
|
|
9
3
|
|
|
10
4
|
describe("Submission reducers", () => {
|
|
@@ -33,16 +27,14 @@ describe("Submission reducers", () => {
|
|
|
33
27
|
url: "url"
|
|
34
28
|
};
|
|
35
29
|
|
|
36
|
-
expect(reducer.$emit(requestSubmission.toString(), state, payload)).toEqual(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
);
|
|
30
|
+
expect(reducer.$emit(requestSubmission.toString(), state, payload)).toEqual({
|
|
31
|
+
name: "name",
|
|
32
|
+
formId: "formId",
|
|
33
|
+
id: "id",
|
|
34
|
+
isActive: true,
|
|
35
|
+
data: {},
|
|
36
|
+
url: "url"
|
|
37
|
+
});
|
|
46
38
|
});
|
|
47
39
|
|
|
48
40
|
it("should return state (sendSubmission)", () => {
|
|
@@ -77,17 +69,15 @@ describe("Submission reducers", () => {
|
|
|
77
69
|
}
|
|
78
70
|
};
|
|
79
71
|
|
|
80
|
-
expect(reducer.$emit(receiveSubmission.toString(), state, payload)).toEqual(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
_id: "id"
|
|
88
|
-
}
|
|
72
|
+
expect(reducer.$emit(receiveSubmission.toString(), state, payload)).toEqual({
|
|
73
|
+
name: "name",
|
|
74
|
+
url: "url",
|
|
75
|
+
error: null,
|
|
76
|
+
isActive: false,
|
|
77
|
+
data: {
|
|
78
|
+
_id: "id"
|
|
89
79
|
}
|
|
90
|
-
);
|
|
80
|
+
});
|
|
91
81
|
});
|
|
92
82
|
|
|
93
83
|
it("should return state (failSubmission)", () => {
|
|
@@ -44,10 +44,7 @@ export const submissionReducer = createReducer<SubmissionState>(
|
|
|
44
44
|
data: {},
|
|
45
45
|
isActive: true
|
|
46
46
|
}),
|
|
47
|
-
[sendSubmission.toString()]: (
|
|
48
|
-
state: any,
|
|
49
|
-
{ formId, submission, id, url }: any
|
|
50
|
-
) => ({
|
|
47
|
+
[sendSubmission.toString()]: (state: any, { formId, submission, id, url }: any) => ({
|
|
51
48
|
...state,
|
|
52
49
|
formId,
|
|
53
50
|
id,
|
|
@@ -2,7 +2,4 @@ import { Submission } from "../../interfaces";
|
|
|
2
2
|
import { selectRoot } from "../root";
|
|
3
3
|
import { SubmissionState } from "./submission.reducers";
|
|
4
4
|
|
|
5
|
-
export const selectSubmission = (
|
|
6
|
-
name: string,
|
|
7
|
-
state: any
|
|
8
|
-
): Partial<Submission> => selectRoot<SubmissionState>(name, state).data;
|
|
5
|
+
export const selectSubmission = (name: string, state: any): Partial<Submission> => selectRoot<SubmissionState>(name, state).data;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { Formio } from "formiojs";
|
|
2
2
|
import { mapRequestParams } from "../../utils/mapRequestParams";
|
|
3
|
-
import {
|
|
4
|
-
failSubmissions,
|
|
5
|
-
getSubmissions,
|
|
6
|
-
receiveSubmissions,
|
|
7
|
-
requestSubmissions
|
|
8
|
-
} from "./submissions.actions";
|
|
3
|
+
import { failSubmissions, getSubmissions, receiveSubmissions, requestSubmissions } from "./submissions.actions";
|
|
9
4
|
|
|
10
5
|
jest.mock("formiojs");
|
|
11
6
|
jest.mock("../../utils/mapRequestParams");
|
|
@@ -17,9 +12,7 @@ describe("Submissions actions", () => {
|
|
|
17
12
|
describe("getSubmissions", () => {
|
|
18
13
|
it("should return a result", async () => {
|
|
19
14
|
// GIVEN
|
|
20
|
-
(Formio.prototype.loadSubmissions as any).mockReturnValue(
|
|
21
|
-
Promise.resolve([{}])
|
|
22
|
-
);
|
|
15
|
+
(Formio.prototype.loadSubmissions as any).mockReturnValue(Promise.resolve([{}]));
|
|
23
16
|
(Formio.getProjectUrl as any).mockReturnValue("https://formio");
|
|
24
17
|
|
|
25
18
|
const dispatch = jest.fn();
|
|
@@ -37,9 +30,7 @@ describe("Submissions actions", () => {
|
|
|
37
30
|
});
|
|
38
31
|
|
|
39
32
|
// WHEN
|
|
40
|
-
await new Promise((resolve) =>
|
|
41
|
-
getSubmissions(name, formId, parameters, resolve)(dispatch, getState)
|
|
42
|
-
);
|
|
33
|
+
await new Promise((resolve) => getSubmissions(name, formId, parameters, resolve)(dispatch, getState));
|
|
43
34
|
|
|
44
35
|
// THEN
|
|
45
36
|
expect(Formio).toHaveBeenCalledWith("https://formio/formId/submission");
|
|
@@ -64,9 +55,7 @@ describe("Submissions actions", () => {
|
|
|
64
55
|
});
|
|
65
56
|
it("should return a error", async () => {
|
|
66
57
|
// GIVEN
|
|
67
|
-
(Formio.prototype.loadSubmissions as any).mockReturnValue(
|
|
68
|
-
Promise.reject(new Error("message"))
|
|
69
|
-
);
|
|
58
|
+
(Formio.prototype.loadSubmissions as any).mockReturnValue(Promise.reject(new Error("message")));
|
|
70
59
|
(Formio.getProjectUrl as any).mockReturnValue("https://formio");
|
|
71
60
|
|
|
72
61
|
const dispatch = jest.fn();
|
|
@@ -84,9 +73,7 @@ describe("Submissions actions", () => {
|
|
|
84
73
|
});
|
|
85
74
|
|
|
86
75
|
// WHEN
|
|
87
|
-
await new Promise((resolve) =>
|
|
88
|
-
getSubmissions(name, formId, parameters, resolve)(dispatch, getState)
|
|
89
|
-
);
|
|
76
|
+
await new Promise((resolve) => getSubmissions(name, formId, parameters, resolve)(dispatch, getState));
|
|
90
77
|
|
|
91
78
|
// THEN
|
|
92
79
|
expect(Formio).toHaveBeenCalledWith("https://formio/formId/submission");
|
|
@@ -10,35 +10,26 @@ export const requestSubmissions = createAction();
|
|
|
10
10
|
export const receiveSubmissions = createAction();
|
|
11
11
|
export const failSubmissions = createAction();
|
|
12
12
|
|
|
13
|
-
export const getSubmissions =
|
|
14
|
-
name: string,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
done = noop
|
|
18
|
-
) => async (dispatch: any, getState: any) => {
|
|
19
|
-
dispatch(requestSubmissions(name, { formId, parameters }));
|
|
13
|
+
export const getSubmissions =
|
|
14
|
+
(name: string, formId: string, parameters: any = {}, done = noop) =>
|
|
15
|
+
async (dispatch: any, getState: any) => {
|
|
16
|
+
dispatch(requestSubmissions(name, { formId, parameters }));
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
selectSubmissionsParameters(name, getState())
|
|
25
|
-
);
|
|
18
|
+
const url = getSubmissionUrl(formId);
|
|
19
|
+
const formio = new Formio(url);
|
|
20
|
+
const requestParams = mapRequestParams(selectSubmissionsParameters(name, getState()));
|
|
26
21
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
22
|
+
try {
|
|
23
|
+
const submissions = await formio.loadSubmissions({ params: requestParams });
|
|
24
|
+
dispatch(receiveSubmissions(name, { submissions }));
|
|
25
|
+
done(null, submissions);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
dispatch(failSubmissions(name, { error }));
|
|
28
|
+
done(error);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
36
31
|
|
|
37
|
-
export const refreshSubmissions = (
|
|
38
|
-
name: string,
|
|
39
|
-
formId: string,
|
|
40
|
-
done = noop
|
|
41
|
-
) => {
|
|
32
|
+
export const refreshSubmissions = (name: string, formId: string, done = noop) => {
|
|
42
33
|
return async (dispatch: any, getState: any) => {
|
|
43
34
|
const parameters = selectSubmissionsParameters(name, getState());
|
|
44
35
|
return getSubmissions(name, formId, parameters, done)(dispatch, getState);
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
failSubmissions,
|
|
3
|
-
receiveSubmissions,
|
|
4
|
-
requestSubmissions,
|
|
5
|
-
resetSubmissions
|
|
6
|
-
} from "./submissions.actions";
|
|
1
|
+
import { failSubmissions, receiveSubmissions, requestSubmissions, resetSubmissions } from "./submissions.actions";
|
|
7
2
|
import { submissionsReducer } from "./submissions.reducers";
|
|
8
3
|
|
|
9
4
|
describe("Submissions reducers", () => {
|
|
@@ -42,9 +37,7 @@ describe("Submissions reducers", () => {
|
|
|
42
37
|
}
|
|
43
38
|
};
|
|
44
39
|
|
|
45
|
-
expect(
|
|
46
|
-
reducer.$emit(requestSubmissions.toString(), state, payload)
|
|
47
|
-
).toEqual({
|
|
40
|
+
expect(reducer.$emit(requestSubmissions.toString(), state, payload)).toEqual({
|
|
48
41
|
error: null,
|
|
49
42
|
formId: undefined,
|
|
50
43
|
name: "name",
|
|
@@ -74,9 +67,7 @@ describe("Submissions reducers", () => {
|
|
|
74
67
|
};
|
|
75
68
|
payload.submissions.serverCount = 100;
|
|
76
69
|
|
|
77
|
-
expect(
|
|
78
|
-
reducer.$emit(receiveSubmissions.toString(), state, payload)
|
|
79
|
-
).toEqual({
|
|
70
|
+
expect(reducer.$emit(receiveSubmissions.toString(), state, payload)).toEqual({
|
|
80
71
|
name: "name",
|
|
81
72
|
data: [
|
|
82
73
|
{
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { createReducer } from "@tsed/redux-utils";
|
|
2
2
|
import { Submission } from "../../interfaces/Submission";
|
|
3
|
-
import {
|
|
4
|
-
failSubmissions,
|
|
5
|
-
receiveSubmissions,
|
|
6
|
-
requestSubmissions,
|
|
7
|
-
resetSubmissions
|
|
8
|
-
} from "./submissions.actions";
|
|
3
|
+
import { failSubmissions, receiveSubmissions, requestSubmissions, resetSubmissions } from "./submissions.actions";
|
|
9
4
|
|
|
10
5
|
export interface SubmissionsState {
|
|
11
6
|
error: null | Error;
|
|
@@ -22,13 +17,7 @@ export interface SubmissionsState {
|
|
|
22
17
|
data: Submission[];
|
|
23
18
|
}
|
|
24
19
|
|
|
25
|
-
export function createInitialState({
|
|
26
|
-
pageIndex = 0,
|
|
27
|
-
pageSize = 10,
|
|
28
|
-
query = {},
|
|
29
|
-
select = "",
|
|
30
|
-
sortBy = []
|
|
31
|
-
}: any = {}): SubmissionsState {
|
|
20
|
+
export function createInitialState({ pageIndex = 0, pageSize = 10, query = {}, select = "", sortBy = [] }: any = {}): SubmissionsState {
|
|
32
21
|
return {
|
|
33
22
|
error: null,
|
|
34
23
|
formId: "",
|
|
@@ -45,10 +34,7 @@ export function createInitialState({
|
|
|
45
34
|
};
|
|
46
35
|
}
|
|
47
36
|
|
|
48
|
-
export const submissionsReducer = createReducer<SubmissionsState>(
|
|
49
|
-
{},
|
|
50
|
-
createInitialState
|
|
51
|
-
)
|
|
37
|
+
export const submissionsReducer = createReducer<SubmissionsState>({}, createInitialState)
|
|
52
38
|
.on(resetSubmissions, (_: any, _2: any, reset: any) => {
|
|
53
39
|
return reset();
|
|
54
40
|
})
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
selectSubmissions,
|
|
3
|
-
selectSubmissionsParameters
|
|
4
|
-
} from "./submissions.selectors";
|
|
1
|
+
import { selectSubmissions, selectSubmissionsParameters } from "./submissions.selectors";
|
|
5
2
|
|
|
6
3
|
describe("Submissions Selectors", () => {
|
|
7
4
|
describe("selectSubmissions()", () => {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { selectRoot } from "../root";
|
|
2
2
|
import { SubmissionsState } from "./submissions.reducers";
|
|
3
3
|
|
|
4
|
-
export const selectSubmissions = (name: string, state: any) =>
|
|
5
|
-
selectRoot<SubmissionsState>(name, state).data;
|
|
4
|
+
export const selectSubmissions = (name: string, state: any) => selectRoot<SubmissionsState>(name, state).data;
|
|
6
5
|
|
|
7
|
-
export const selectSubmissionsParameters = (name: string, state: any) =>
|
|
8
|
-
selectRoot<SubmissionsState>(name, state).parameters;
|
|
6
|
+
export const selectSubmissionsParameters = (name: string, state: any) => selectRoot<SubmissionsState>(name, state).parameters;
|
|
@@ -2,10 +2,7 @@ export function getEventValue(event: any) {
|
|
|
2
2
|
const { target } = event;
|
|
3
3
|
|
|
4
4
|
if (event.target.multiple && event.target.selectedOptions) {
|
|
5
|
-
return Array.from(
|
|
6
|
-
event.target.selectedOptions,
|
|
7
|
-
(option: any) => option.value
|
|
8
|
-
);
|
|
5
|
+
return Array.from(event.target.selectedOptions, (option: any) => option.value);
|
|
9
6
|
}
|
|
10
7
|
|
|
11
8
|
return target.type === "checkbox" ? target.checked : target.value;
|
package/src/utils/iconClass.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { Templates } from "formiojs";
|
|
2
2
|
|
|
3
|
-
export function iconClass(
|
|
4
|
-
iconset
|
|
5
|
-
name: string,
|
|
6
|
-
spinning?: boolean
|
|
7
|
-
): string {
|
|
8
|
-
return Templates.current.iconClass(
|
|
9
|
-
iconset || Templates.current.defaultIconset,
|
|
10
|
-
name,
|
|
11
|
-
spinning
|
|
12
|
-
);
|
|
3
|
+
export function iconClass(iconset: string | undefined, name: string, spinning?: boolean): string {
|
|
4
|
+
return Templates.current.iconClass(iconset || Templates.current.defaultIconset, name, spinning);
|
|
13
5
|
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
export function mapPagination({
|
|
2
|
-
skip,
|
|
3
|
-
limit,
|
|
4
|
-
serverCount,
|
|
5
|
-
length
|
|
6
|
-
}: any = {}): any {
|
|
1
|
+
export function mapPagination({ skip, limit, serverCount, length }: any = {}): any {
|
|
7
2
|
skip = skip || 0;
|
|
8
3
|
limit = limit || 10;
|
|
9
4
|
serverCount = serverCount || length;
|
|
@@ -9,14 +9,7 @@ export interface RequestParamsOptions extends QueryOptions {
|
|
|
9
9
|
[key: string]: any;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export function mapRequestParams({
|
|
13
|
-
query,
|
|
14
|
-
pageSize = 10,
|
|
15
|
-
pageIndex = 0,
|
|
16
|
-
select,
|
|
17
|
-
filters,
|
|
18
|
-
sortBy
|
|
19
|
-
}: Partial<RequestParamsOptions>) {
|
|
12
|
+
export function mapRequestParams({ query, pageSize = 10, pageIndex = 0, select, filters, sortBy }: Partial<RequestParamsOptions>) {
|
|
20
13
|
const requestParams: any = {
|
|
21
14
|
...clean(query),
|
|
22
15
|
limit: pageSize,
|
|
@@ -30,10 +23,7 @@ export function mapRequestParams({
|
|
|
30
23
|
if (filters && filters.length) {
|
|
31
24
|
filters.forEach((filter) => {
|
|
32
25
|
if (filter.value) {
|
|
33
|
-
requestParams[`${filter.id}__regex`] = new RegExp(
|
|
34
|
-
filter.value,
|
|
35
|
-
"gi"
|
|
36
|
-
).toString();
|
|
26
|
+
requestParams[`${filter.id}__regex`] = new RegExp(filter.value, "gi").toString();
|
|
37
27
|
}
|
|
38
28
|
});
|
|
39
29
|
}
|
package/src/utils/url.test.ts
CHANGED
|
@@ -3,24 +3,18 @@ import { getFormUrl, getSubmissionUrl } from "./url";
|
|
|
3
3
|
describe("getUrl", () => {
|
|
4
4
|
describe("getFormUrl()", () => {
|
|
5
5
|
it("should return the url from mongo id", () => {
|
|
6
|
-
expect(getFormUrl("5e455268aed853649e834c4a")).toEqual(
|
|
7
|
-
"https://api.form.io/form/5e455268aed853649e834c4a"
|
|
8
|
-
);
|
|
6
|
+
expect(getFormUrl("5e455268aed853649e834c4a")).toEqual("https://api.form.io/form/5e455268aed853649e834c4a");
|
|
9
7
|
});
|
|
10
8
|
it("should return the url from alias", () => {
|
|
11
9
|
expect(getFormUrl("admin")).toEqual("https://api.form.io/admin");
|
|
12
10
|
});
|
|
13
11
|
it("should return the url from alias (__)", () => {
|
|
14
|
-
expect(getFormUrl("admin__login")).toEqual(
|
|
15
|
-
"https://api.form.io/admin/login"
|
|
16
|
-
);
|
|
12
|
+
expect(getFormUrl("admin__login")).toEqual("https://api.form.io/admin/login");
|
|
17
13
|
});
|
|
18
14
|
});
|
|
19
15
|
describe("getSubmissionUrl()", () => {
|
|
20
16
|
it("should return the url from mongo id", () => {
|
|
21
|
-
expect(
|
|
22
|
-
getSubmissionUrl("5e455268aed853649e834c4a", "5e455268aed853649e834c42")
|
|
23
|
-
).toEqual(
|
|
17
|
+
expect(getSubmissionUrl("5e455268aed853649e834c4a", "5e455268aed853649e834c42")).toEqual(
|
|
24
18
|
"https://api.form.io/form/5e455268aed853649e834c4a/submission/5e455268aed853649e834c42"
|
|
25
19
|
);
|
|
26
20
|
});
|
|
@@ -31,9 +25,7 @@ describe("getUrl", () => {
|
|
|
31
25
|
});
|
|
32
26
|
|
|
33
27
|
it("should return the url without submissionId", () => {
|
|
34
|
-
expect(getSubmissionUrl("admin")).toEqual(
|
|
35
|
-
"https://api.form.io/admin/submission"
|
|
36
|
-
);
|
|
28
|
+
expect(getSubmissionUrl("admin")).toEqual("https://api.form.io/admin/submission");
|
|
37
29
|
});
|
|
38
30
|
});
|
|
39
31
|
});
|
package/src/utils/url.ts
CHANGED
|
@@ -18,11 +18,6 @@ export function getActionUrl(formId: string, actionId?: string): string {
|
|
|
18
18
|
return [getFormUrl(formId), "action", actionId].filter(Boolean).join("/");
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export function getSubmissionUrl(
|
|
22
|
-
formId
|
|
23
|
-
submissionId?: string
|
|
24
|
-
): string {
|
|
25
|
-
return [getFormUrl(formId), "submission", submissionId]
|
|
26
|
-
.filter(Boolean)
|
|
27
|
-
.join("/");
|
|
21
|
+
export function getSubmissionUrl(formId: string, submissionId?: string): string {
|
|
22
|
+
return [getFormUrl(formId), "submission", submissionId].filter(Boolean).join("/");
|
|
28
23
|
}
|
package/tsconfig.json
CHANGED
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"outDir": "dist",
|
|
4
4
|
"module": "esnext",
|
|
5
|
-
"lib": [
|
|
6
|
-
|
|
7
|
-
"esnext"
|
|
8
|
-
],
|
|
5
|
+
"lib": ["dom", "esnext"],
|
|
6
|
+
"downlevelIteration": true,
|
|
9
7
|
"moduleResolution": "node",
|
|
10
8
|
"jsx": "react",
|
|
11
9
|
"sourceMap": true,
|
|
@@ -29,12 +27,6 @@
|
|
|
29
27
|
"isolatedModules": true,
|
|
30
28
|
"noEmit": true
|
|
31
29
|
},
|
|
32
|
-
"include": [
|
|
33
|
-
|
|
34
|
-
],
|
|
35
|
-
"exclude": [
|
|
36
|
-
"node_modules",
|
|
37
|
-
"dist",
|
|
38
|
-
"example"
|
|
39
|
-
]
|
|
30
|
+
"include": ["src"],
|
|
31
|
+
"exclude": ["node_modules", "dist", "example"]
|
|
40
32
|
}
|
package/tsconfig.test.json
CHANGED
package/.eslintrc
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"parser": "@typescript-eslint/parser",
|
|
3
|
-
"extends": [
|
|
4
|
-
"standard",
|
|
5
|
-
"standard-react",
|
|
6
|
-
"prettier/standard",
|
|
7
|
-
"prettier/react",
|
|
8
|
-
"plugin:@typescript-eslint/recommended",
|
|
9
|
-
"prettier/@typescript-eslint",
|
|
10
|
-
"plugin:prettier/recommended",
|
|
11
|
-
"plugin:react/recommended",
|
|
12
|
-
"plugin:jsx-a11y/recommended"
|
|
13
|
-
],
|
|
14
|
-
"env": {
|
|
15
|
-
"node": true,
|
|
16
|
-
"jest": true
|
|
17
|
-
},
|
|
18
|
-
"parserOptions": {
|
|
19
|
-
"ecmaVersion": 2020,
|
|
20
|
-
"ecmaFeatures": {
|
|
21
|
-
"legacyDecorators": true,
|
|
22
|
-
"jsx": true
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"settings": {
|
|
26
|
-
"react": {
|
|
27
|
-
"version": "16"
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"rules": {
|
|
31
|
-
"semi": ["error", "always"],
|
|
32
|
-
"space-before-function-paren": 0,
|
|
33
|
-
"react/prop-types": 0,
|
|
34
|
-
"react/jsx-handler-names": 0,
|
|
35
|
-
"react/jsx-fragments": 0,
|
|
36
|
-
"react/no-unescaped-entities": 0,
|
|
37
|
-
"react/no-unused-prop-types": 0,
|
|
38
|
-
"react/display-name": 1,
|
|
39
|
-
"no-unused-vars": "off",
|
|
40
|
-
"@typescript-eslint/no-explicit-any": 0,
|
|
41
|
-
"@typescript-eslint/explicit-function-return-type": 0,
|
|
42
|
-
"@typescript-eslint/camelcase": 0,
|
|
43
|
-
"@typescript-eslint/no-empty-function": 0,
|
|
44
|
-
"import/export": 0,
|
|
45
|
-
"jsx-a11y/no-autofocus": 1
|
|
46
|
-
}
|
|
47
|
-
}
|