@tsed/react-formio 1.11.2 → 1.13.1
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/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/select/select.component.spec.d.ts +1 -0
- package/dist/components/tabs/tabs.component.spec.d.ts +1 -0
- package/dist/index.js +110 -33
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +83 -32
- 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 +1 -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 +3 -4
- package/src/components/input-text/inputText.stories.tsx +6 -26
- package/src/components/loader/loader.component.tsx +2 -11
- 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 +12 -38
- package/src/components/pagination/pagination.component.tsx +8 -41
- package/src/components/pagination/pagination.stories.tsx +1 -5
- 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
|
@@ -4,10 +4,7 @@ import isEqual from "lodash/isEqual";
|
|
|
4
4
|
import noop from "lodash/noop";
|
|
5
5
|
import { FormSchema, Submission } from "../../interfaces";
|
|
6
6
|
import { RoleSchema } from "../../interfaces/RoleSchema";
|
|
7
|
-
import {
|
|
8
|
-
getAccessPermissionForm,
|
|
9
|
-
getSubmissionPermissionForm
|
|
10
|
-
} from "./formAccess.schema";
|
|
7
|
+
import { getAccessPermissionForm, getSubmissionPermissionForm } from "./formAccess.schema";
|
|
11
8
|
|
|
12
9
|
export interface Choice {
|
|
13
10
|
label: string;
|
|
@@ -81,30 +78,20 @@ export function getFormAccess(roles: RoleSchema[]): FormAccessSchema {
|
|
|
81
78
|
};
|
|
82
79
|
}
|
|
83
80
|
|
|
84
|
-
export function dataAccessToSubmissions(
|
|
85
|
-
|
|
86
|
-
formAccess: FormAccessSchema
|
|
87
|
-
): SubmissionAccess {
|
|
88
|
-
const getKeys = (components: ExtendedComponentSchema[]) =>
|
|
89
|
-
components.map(({ key }) => key);
|
|
81
|
+
export function dataAccessToSubmissions(form: Partial<FormSchema>, formAccess: FormAccessSchema): SubmissionAccess {
|
|
82
|
+
const getKeys = (components: ExtendedComponentSchema[]) => components.map(({ key }) => key);
|
|
90
83
|
|
|
91
84
|
return {
|
|
92
85
|
access: {
|
|
93
86
|
data: accessToHash(getKeys(formAccess.access.components), form.access)
|
|
94
87
|
},
|
|
95
88
|
submissionAccess: {
|
|
96
|
-
data: accessToHash(
|
|
97
|
-
getKeys(formAccess.submissionAccess.components),
|
|
98
|
-
form.submissionAccess
|
|
99
|
-
)
|
|
89
|
+
data: accessToHash(getKeys(formAccess.submissionAccess.components), form.submissionAccess)
|
|
100
90
|
}
|
|
101
91
|
};
|
|
102
92
|
}
|
|
103
93
|
|
|
104
|
-
export function submissionsToDataAccess(
|
|
105
|
-
form: Partial<FormSchema>,
|
|
106
|
-
submissions: SubmissionAccess
|
|
107
|
-
): Partial<FormSchema> {
|
|
94
|
+
export function submissionsToDataAccess(form: Partial<FormSchema>, submissions: SubmissionAccess): Partial<FormSchema> {
|
|
108
95
|
return {
|
|
109
96
|
...cloneDeep(form),
|
|
110
97
|
access: hashToAccess(submissions.access.data),
|
|
@@ -112,20 +99,11 @@ export function submissionsToDataAccess(
|
|
|
112
99
|
};
|
|
113
100
|
}
|
|
114
101
|
|
|
115
|
-
export function shouldUpdate(
|
|
116
|
-
type: string,
|
|
117
|
-
submission: Submission<AccessRoles>,
|
|
118
|
-
submissions: SubmissionAccess
|
|
119
|
-
) {
|
|
102
|
+
export function shouldUpdate(type: string, submission: Submission<AccessRoles>, submissions: SubmissionAccess) {
|
|
120
103
|
return !isEqual(submission.data, submissions[type].data);
|
|
121
104
|
}
|
|
122
105
|
|
|
123
|
-
export function updateSubmissions(
|
|
124
|
-
type: string,
|
|
125
|
-
submission: Submission<AccessRoles>,
|
|
126
|
-
submissions: SubmissionAccess,
|
|
127
|
-
cb: Function = noop
|
|
128
|
-
) {
|
|
106
|
+
export function updateSubmissions(type: string, submission: Submission<AccessRoles>, submissions: SubmissionAccess, cb: Function = noop) {
|
|
129
107
|
if (shouldUpdate(type, submission, submissions)) {
|
|
130
108
|
submissions = {
|
|
131
109
|
...submissions,
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import FormioUtils from "formiojs/utils";
|
|
2
2
|
import React, { PropsWithChildren, ReactElement, useMemo } from "react";
|
|
3
|
-
import {
|
|
4
|
-
ActionDefaultsSchema,
|
|
5
|
-
ActionSchema,
|
|
6
|
-
FormOptions,
|
|
7
|
-
Submission
|
|
8
|
-
} from "../../interfaces";
|
|
3
|
+
import { ActionDefaultsSchema, ActionSchema, FormOptions, Submission } from "../../interfaces";
|
|
9
4
|
import { Form } from "../form/form.component";
|
|
10
5
|
|
|
11
6
|
function mapData(options: any, defaults: ActionDefaultsSchema): any {
|
|
@@ -42,13 +37,7 @@ export interface FormActionProps {
|
|
|
42
37
|
options: FormOptions;
|
|
43
38
|
}
|
|
44
39
|
|
|
45
|
-
export function FormAction({
|
|
46
|
-
actionInfo,
|
|
47
|
-
children,
|
|
48
|
-
onSubmit,
|
|
49
|
-
options,
|
|
50
|
-
...props
|
|
51
|
-
}: PropsWithChildren<FormActionProps>): ReactElement {
|
|
40
|
+
export function FormAction({ actionInfo, children, onSubmit, options, ...props }: PropsWithChildren<FormActionProps>): ReactElement {
|
|
52
41
|
const { form, submission } = useMemo(() => {
|
|
53
42
|
const submission = mapData(props.submission || {}, actionInfo.defaults);
|
|
54
43
|
const form = mapSettingsForm(actionInfo.settingsForm);
|
|
@@ -60,12 +49,7 @@ export function FormAction({
|
|
|
60
49
|
<div>
|
|
61
50
|
{children}
|
|
62
51
|
|
|
63
|
-
<Form
|
|
64
|
-
form={form}
|
|
65
|
-
submission={submission}
|
|
66
|
-
onSubmit={onSubmit}
|
|
67
|
-
options={options}
|
|
68
|
-
/>
|
|
52
|
+
<Form form={form} submission={submission} onSubmit={onSubmit} options={options} />
|
|
69
53
|
|
|
70
54
|
{children}
|
|
71
55
|
</div>
|