@tsed/react-formio 1.13.1 → 1.13.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.
- package/dist/components/actions-table/actionsTable.component.d.ts +0 -1
- package/dist/components/actions-table/actionsTable.stories.d.ts +0 -1
- package/dist/components/alert/alert.component.d.ts +1 -2
- package/dist/components/alert/alert.stories.d.ts +0 -1
- package/dist/components/card/card.stories.d.ts +0 -1
- package/dist/components/form/form.component.d.ts +1 -2
- package/dist/components/form/form.component.spec.d.ts +1 -0
- package/dist/components/form/form.stories.d.ts +3745 -172
- package/dist/components/form/useForm.hook.d.ts +1 -2
- package/dist/components/form-access/formAccess.stories.d.ts +1 -2
- package/dist/components/form-action/formAction.stories.d.ts +0 -1
- package/dist/components/form-builder/formBuilder.stories.d.ts +518 -153
- package/dist/components/form-edit/formEdit.component.d.ts +0 -1
- package/dist/components/form-edit/formEdit.stories.d.ts +18 -19
- package/dist/components/form-settings/formSettings.component.d.ts +0 -1
- package/dist/components/form-settings/formSettings.stories.d.ts +1 -2
- package/dist/components/forms-table/components/formCell.component.d.ts +0 -1
- package/dist/components/forms-table/formsTable.component.d.ts +0 -1
- package/dist/components/forms-table/formsTable.stories.d.ts +0 -1
- package/dist/components/input-tags/inputTags.component.d.ts +0 -1
- package/dist/components/input-tags/inputTags.stories.d.ts +2 -3
- package/dist/components/input-text/inputText.component.d.ts +0 -1
- package/dist/components/input-text/inputText.stories.d.ts +0 -1
- package/dist/components/loader/loader.component.d.ts +1 -1
- package/dist/components/loader/loader.stories.d.ts +0 -1
- package/dist/components/modal/modal.component.d.ts +1 -1
- package/dist/components/modal/modal.stories.d.ts +0 -1
- package/dist/components/pagination/pagination.component.d.ts +0 -1
- package/dist/components/pagination/pagination.stories.d.ts +0 -1
- package/dist/components/react-component/reactComponent.component.d.ts +3 -3
- package/dist/components/select/select.stories.d.ts +2 -3
- package/dist/components/submissions-table/submissionsTable.component.d.ts +0 -1
- package/dist/components/submissions-table/submissionsTable.stories.d.ts +13 -14
- package/dist/components/table/components/defaultArrowSort.component.d.ts +0 -1
- package/dist/components/table/components/defaultCell.component.d.ts +0 -1
- package/dist/components/table/components/defaultCellHeader.component.d.ts +0 -1
- package/dist/components/table/components/defaultCellOperations.component.d.ts +0 -1
- package/dist/components/table/components/defaultOperationButton.component.d.ts +0 -1
- package/dist/components/table/filters/defaultColumnFilter.component.d.ts +0 -1
- package/dist/components/table/filters/selectColumnFilter.component.d.ts +0 -1
- package/dist/components/table/filters/sliderColumnFilter.component.d.ts +0 -1
- package/dist/components/table/table.stories.d.ts +4 -5
- package/dist/components/tabs/tabs.component.stories.d.ts +0 -1
- package/dist/hooks/useTooltip.d.ts +1 -1
- package/dist/index.js +297 -276
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +294 -272
- package/dist/index.modern.js.map +1 -1
- package/dist/stores/auth/auth.selectors.d.ts +1 -1
- package/jest.config.js +1 -1
- package/package.json +5 -5
- package/src/components/__fixtures__/form.fixture.json +23 -0
- package/src/components/form/form.component.spec.tsx +56 -0
- package/src/components/form/form.component.tsx +2 -2
- package/src/components/form/form.stories.tsx +141 -34
- package/src/components/form/useForm.hook.ts +39 -38
- package/src/components/form-access/formAccess.component.tsx +1 -1
- package/src/components/form-access/formAccess.utils.ts +13 -13
- package/src/components/form-action/formAction.component.tsx +1 -1
- package/src/components/form-builder/formBuilder.component.tsx +1 -1
- package/src/components/form-edit/formCtas.component.tsx +32 -30
- package/src/components/form-edit/formEdit.component.tsx +1 -1
- package/src/components/form-settings/formSettings.utils.ts +3 -3
- package/src/components/input-tags/inputTags.component.tsx +3 -3
- package/src/components/input-text/inputText.component.tsx +2 -2
- package/src/components/modal/modal.component.tsx +2 -2
- package/src/components/react-component/reactComponent.component.tsx +9 -6
- package/src/components/select/select.component.tsx +2 -2
- package/src/components/submissions-table/submissionsTable.component.tsx +6 -6
- package/src/components/table/table.component.tsx +58 -44
- package/src/components/table/utils/mapFormToColumns.tsx +1 -1
- package/src/components/tabs/tabs.component.tsx +1 -1
- package/src/hooks/useTooltip.ts +1 -1
- package/src/stores/action-info/action-info.selectors.ts +1 -1
- package/src/stores/auth/auth.utils.tsx +2 -2
- package/src/stores/auth/getAccess.action.ts +2 -2
- package/src/stores/auth/logout.action.spec.ts +1 -0
- package/src/stores/form/form.selectors.ts +1 -1
- package/src/stores/root/root.selectors.ts +2 -2
- package/tsconfig.json +10 -27
- package/tsconfig.node.json +8 -0
- package/craco.config.js +0 -11
- package/tsconfig.test.json +0 -6
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import PropTypes from "prop-types";
|
|
2
|
-
import React, {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import React, {ReactElement} from "react";
|
|
3
|
+
import {useTooltip} from "../../hooks/useTooltip";
|
|
4
|
+
import {FormOptions} from "../../interfaces";
|
|
5
|
+
import {iconClass} from "../../utils/iconClass";
|
|
6
6
|
|
|
7
7
|
export interface FormEditCTAsProps extends Record<string, unknown> {
|
|
8
8
|
saveText?: string;
|
|
@@ -18,38 +18,38 @@ export interface FormEditCTAsProps extends Record<string, unknown> {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export function FormEditCTAs({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}: FormEditCTAsProps): ReactElement {
|
|
32
|
-
const {
|
|
21
|
+
saveText = "Save",
|
|
22
|
+
disabled,
|
|
23
|
+
options = {},
|
|
24
|
+
onCopy,
|
|
25
|
+
hasUndo,
|
|
26
|
+
hasRedo,
|
|
27
|
+
onUndo,
|
|
28
|
+
onRedo,
|
|
29
|
+
onReset,
|
|
30
|
+
onSubmit
|
|
31
|
+
}: FormEditCTAsProps): ReactElement {
|
|
32
|
+
const {i18n: t = (t: string): string => t} = options;
|
|
33
33
|
|
|
34
|
-
const copyTooltipRef = useTooltip({
|
|
34
|
+
const copyTooltipRef: any = useTooltip({
|
|
35
35
|
trigger: "hover",
|
|
36
36
|
placement: "top",
|
|
37
37
|
title: t("Copy")
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
const undoTooltipRef = useTooltip({
|
|
40
|
+
const undoTooltipRef: any = useTooltip({
|
|
41
41
|
trigger: "hover",
|
|
42
42
|
placement: "top",
|
|
43
43
|
title: t("Undo last change")
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
const redoTooltipRef = useTooltip({
|
|
46
|
+
const redoTooltipRef: any = useTooltip({
|
|
47
47
|
trigger: "hover",
|
|
48
48
|
placement: "top",
|
|
49
49
|
title: t("Redo last change")
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
const resetTooltipRef = useTooltip({
|
|
52
|
+
const resetTooltipRef: any = useTooltip({
|
|
53
53
|
trigger: "hover",
|
|
54
54
|
placement: "top",
|
|
55
55
|
title: t("Reset all changes")
|
|
@@ -61,31 +61,33 @@ export function FormEditCTAs({
|
|
|
61
61
|
<button
|
|
62
62
|
className={`btn btn-primary btn-save flex ${disabled ? "disabled" : ""}`}
|
|
63
63
|
disabled={disabled}
|
|
64
|
-
onClick={() => !disabled && onSubmit()}
|
|
64
|
+
onClick={() => !disabled && onSubmit && onSubmit()}
|
|
65
65
|
>
|
|
66
|
-
<i className={`mr-1 ${iconClass(options.iconset, "save")}`}
|
|
66
|
+
<i className={`mr-1 ${iconClass(options.iconset, "save")}`}/>
|
|
67
67
|
{saveText}
|
|
68
68
|
</button>
|
|
69
69
|
|
|
70
70
|
<div>
|
|
71
|
-
<button className={`btn btn-light btn-undo ${hasUndo ? "" : "disabled"}`} onClick={() => onUndo()}
|
|
72
|
-
|
|
71
|
+
<button className={`btn btn-light btn-undo ${hasUndo ? "" : "disabled"}`} onClick={() => onUndo && onUndo()}
|
|
72
|
+
ref={undoTooltipRef}>
|
|
73
|
+
<i className={iconClass(options.iconset, "undo")}/>
|
|
73
74
|
</button>
|
|
74
75
|
|
|
75
|
-
<button className={`btn btn-light btn-redo ${hasRedo ? "" : "disabled"}`} onClick={() => onRedo()}
|
|
76
|
-
|
|
76
|
+
<button className={`btn btn-light btn-redo ${hasRedo ? "" : "disabled"}`} onClick={() => onRedo && onRedo()}
|
|
77
|
+
ref={redoTooltipRef}>
|
|
78
|
+
<i className={iconClass(options.iconset, "redo")}/>
|
|
77
79
|
</button>
|
|
78
80
|
</div>
|
|
79
81
|
|
|
80
82
|
<div>
|
|
81
83
|
{onCopy && (
|
|
82
|
-
<button className=
|
|
83
|
-
<i className={iconClass(options.iconset, "copy")}
|
|
84
|
+
<button className="btn btn-light" onClick={() => onCopy()} ref={copyTooltipRef!}>
|
|
85
|
+
<i className={iconClass(options.iconset, "copy")}/>
|
|
84
86
|
</button>
|
|
85
87
|
)}
|
|
86
88
|
|
|
87
|
-
<button className={`btn btn-light btn-reset`} onClick={() => onReset()} ref={resetTooltipRef}>
|
|
88
|
-
<i className={iconClass(options.iconset, "reset")}
|
|
89
|
+
<button className={`btn btn-light btn-reset`} onClick={() => onReset && onReset()} ref={resetTooltipRef!}>
|
|
90
|
+
<i className={iconClass(options.iconset, "reset")}/>
|
|
89
91
|
</button>
|
|
90
92
|
</div>
|
|
91
93
|
</div>
|
|
@@ -10,9 +10,9 @@ export type FormSettingsSchema = {
|
|
|
10
10
|
export function formSettingsToSubmission(form: Partial<FormSchema>): Submission<FormSettingsSchema> {
|
|
11
11
|
return {
|
|
12
12
|
data: {
|
|
13
|
-
action: form.action
|
|
14
|
-
tags: form.tags
|
|
15
|
-
properties: form.properties
|
|
13
|
+
action: form.action!,
|
|
14
|
+
tags: form.tags!,
|
|
15
|
+
properties: form.properties!
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
}
|
|
@@ -14,7 +14,7 @@ export interface InputTagsProps<T = any> extends Omit<FormControlProps, "descrip
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export function InputTags({ name, value = [], label, onChange, required, description, prefix, suffix, ...props }: InputTagsProps) {
|
|
17
|
-
const ref = useRef();
|
|
17
|
+
const ref: any = useRef();
|
|
18
18
|
|
|
19
19
|
useEffect(() => {
|
|
20
20
|
const instance = new Choices(ref.current, {
|
|
@@ -26,11 +26,11 @@ export function InputTags({ name, value = [], label, onChange, required, descrip
|
|
|
26
26
|
instance.setValue([].concat(value, []));
|
|
27
27
|
|
|
28
28
|
instance.passedElement.element.addEventListener("addItem", (event: any) => {
|
|
29
|
-
onChange(name, uniq(value.concat(event.detail.value)));
|
|
29
|
+
onChange && onChange(name, uniq(value.concat(event.detail.value)));
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
instance.passedElement.element.addEventListener("removeItem", (event: any) => {
|
|
33
|
-
onChange(
|
|
33
|
+
onChange && onChange(
|
|
34
34
|
name,
|
|
35
35
|
value.filter((v: string) => v !== event.detail.value)
|
|
36
36
|
);
|
|
@@ -35,7 +35,7 @@ export function InputText<T = any>({
|
|
|
35
35
|
}: InputTextProps<T>) {
|
|
36
36
|
const [localValue, setValue] = useState(value);
|
|
37
37
|
|
|
38
|
-
const change = useMemo(() => callLast(onChange, 300), [onChange]);
|
|
38
|
+
const change = useMemo(() => onChange && callLast(onChange, 300), [onChange]);
|
|
39
39
|
|
|
40
40
|
useEffect(() => {
|
|
41
41
|
setValue(value);
|
|
@@ -64,7 +64,7 @@ export function InputText<T = any>({
|
|
|
64
64
|
const value = getEventValue(event);
|
|
65
65
|
setValue(value);
|
|
66
66
|
|
|
67
|
-
return change(name, value);
|
|
67
|
+
return change && change(name, value);
|
|
68
68
|
}}
|
|
69
69
|
/>
|
|
70
70
|
</FormControl>
|
|
@@ -37,8 +37,8 @@ export function Modal({
|
|
|
37
37
|
className = "",
|
|
38
38
|
...props
|
|
39
39
|
}: PropsWithChildren<ModalProps>) {
|
|
40
|
-
const titleRef = useRef<HTMLDivElement>();
|
|
41
|
-
const footerRef = useRef<HTMLDivElement>();
|
|
40
|
+
const titleRef: any = useRef<HTMLDivElement>();
|
|
41
|
+
const footerRef: any = useRef<HTMLDivElement>();
|
|
42
42
|
const [maxHeight, setMaxHeight] = useState<string>();
|
|
43
43
|
|
|
44
44
|
const onClickClose = () => {
|
|
@@ -4,8 +4,8 @@ import { Submission } from "../../interfaces/Submission";
|
|
|
4
4
|
|
|
5
5
|
export class ReactComponent<Data = any> extends Components.components.field {
|
|
6
6
|
public reactInstance: any;
|
|
7
|
-
public shouldSetValue
|
|
8
|
-
private dataForSetting
|
|
7
|
+
public shouldSetValue?: boolean;
|
|
8
|
+
private dataForSetting?: Data;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* This is the first phase of component building where the component is instantiated.
|
|
@@ -20,7 +20,7 @@ export class ReactComponent<Data = any> extends Components.components.field {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
get $reactNode() {
|
|
23
|
-
return this.refs[`react-${this.id}`];
|
|
23
|
+
return (this.refs as any)[`react-${this.id}`];
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -67,7 +67,9 @@ export class ReactComponent<Data = any> extends Components.components.field {
|
|
|
67
67
|
[`react-${this.id}`]: "single"
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
+
// @ts-ignore
|
|
70
71
|
if (this.refs[`react-${this.id}`]) {
|
|
72
|
+
// @ts-ignore
|
|
71
73
|
this.reactInstance = this.attachReact(this.refs[`react-${this.id}`]);
|
|
72
74
|
|
|
73
75
|
if (this.shouldSetValue) {
|
|
@@ -82,7 +84,9 @@ export class ReactComponent<Data = any> extends Components.components.field {
|
|
|
82
84
|
* or it is being removed from the form.
|
|
83
85
|
*/
|
|
84
86
|
detach() {
|
|
87
|
+
// @ts-ignore
|
|
85
88
|
if (this.refs[`react-${this.id}`]) {
|
|
89
|
+
// @ts-ignore
|
|
86
90
|
this.detachReact(this.refs[`react-${this.id}`]);
|
|
87
91
|
}
|
|
88
92
|
super.detach();
|
|
@@ -122,8 +126,7 @@ export class ReactComponent<Data = any> extends Components.components.field {
|
|
|
122
126
|
* @param value
|
|
123
127
|
* @param flags
|
|
124
128
|
*/
|
|
125
|
-
|
|
126
|
-
setValue(value: any, flags?: any): boolean {
|
|
129
|
+
setValue(value: any, flags?: any) {
|
|
127
130
|
if (this.reactInstance) {
|
|
128
131
|
this.reactInstance.setState({
|
|
129
132
|
value: value
|
|
@@ -134,7 +137,7 @@ export class ReactComponent<Data = any> extends Components.components.field {
|
|
|
134
137
|
this.dataForSetting = value;
|
|
135
138
|
}
|
|
136
139
|
|
|
137
|
-
return
|
|
140
|
+
return false
|
|
138
141
|
}
|
|
139
142
|
|
|
140
143
|
/**
|
|
@@ -33,7 +33,7 @@ export function Select<T = any>({
|
|
|
33
33
|
layout,
|
|
34
34
|
...props
|
|
35
35
|
}: SelectProps<T>): ReactElement {
|
|
36
|
-
const ref = useRef();
|
|
36
|
+
const ref = useRef<any>();
|
|
37
37
|
|
|
38
38
|
useEffect(() => {
|
|
39
39
|
let instance: any;
|
|
@@ -75,7 +75,7 @@ export function Select<T = any>({
|
|
|
75
75
|
value={value || ("" as any)}
|
|
76
76
|
placeholder={placeholder}
|
|
77
77
|
onChange={(event) => {
|
|
78
|
-
onChange(name, getEventValue(event));
|
|
78
|
+
onChange && onChange(name, getEventValue(event));
|
|
79
79
|
}}
|
|
80
80
|
>
|
|
81
81
|
{choices.map(({ label, value }) => {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import {FormSchema, Submission} from "../../interfaces";
|
|
3
|
+
import {Table, TableProps} from "../table/table.component";
|
|
4
|
+
import {mapFormToColumns} from "../table/utils/mapFormToColumns";
|
|
5
5
|
|
|
6
6
|
export type SubmissionsTableProps = Omit<TableProps<Submission>, "columns"> & {
|
|
7
7
|
form?: FormSchema;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
export function SubmissionsTable({
|
|
11
|
-
const columns: any[]
|
|
10
|
+
export function SubmissionsTable({form, ...props}: SubmissionsTableProps) {
|
|
11
|
+
const columns: any[] | undefined = form && mapFormToColumns(form);
|
|
12
12
|
|
|
13
|
-
return <Table {...props} columns={columns}
|
|
13
|
+
return <Table {...props} columns={columns!}/>;
|
|
14
14
|
}
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import classnames from "classnames";
|
|
2
2
|
import noop from "lodash/noop";
|
|
3
|
-
import React, {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
import React, {PropsWithChildren} from "react";
|
|
4
|
+
import {
|
|
5
|
+
CellProps,
|
|
6
|
+
FilterProps,
|
|
7
|
+
Renderer,
|
|
8
|
+
TableOptions,
|
|
9
|
+
useFilters,
|
|
10
|
+
useGroupBy,
|
|
11
|
+
usePagination,
|
|
12
|
+
useSortBy,
|
|
13
|
+
useTable
|
|
14
|
+
} from "react-table";
|
|
15
|
+
import {OnClickOperation, Operation, QueryOptions} from "../../interfaces";
|
|
16
|
+
import {Pagination as DefaultPagination} from "../pagination/pagination.component";
|
|
17
|
+
import {DefaultArrowSort} from "./components/defaultArrowSort.component";
|
|
18
|
+
import {DefaultCellHeader, DefaultCellHeaderProps} from "./components/defaultCellHeader.component";
|
|
19
|
+
import {DefaultColumnFilter} from "./filters/defaultColumnFilter.component";
|
|
20
|
+
import {useOperations} from "./utils/useOperations.hook";
|
|
11
21
|
|
|
12
22
|
export interface TableProps<Data extends object = any> extends TableOptions<Data>, Partial<QueryOptions> {
|
|
13
23
|
className?: string;
|
|
@@ -92,7 +102,7 @@ function DefaultLoader() {
|
|
|
92
102
|
}
|
|
93
103
|
|
|
94
104
|
function DefaultEmptyData() {
|
|
95
|
-
return <div className=
|
|
105
|
+
return <div className="text-center p-2 pb-4 font-bold">No data found</div>;
|
|
96
106
|
}
|
|
97
107
|
|
|
98
108
|
const hooks = [useFilters, useGroupBy, useSortBy, usePagination];
|
|
@@ -161,12 +171,12 @@ export function Table<Data extends object = any>(props: PropsWithChildren<TableP
|
|
|
161
171
|
setFilterId
|
|
162
172
|
} as any,
|
|
163
173
|
...hooks,
|
|
164
|
-
useOperations({
|
|
174
|
+
useOperations({operations, CellOperations, onClick: _onClick, ctx, i18n})
|
|
165
175
|
);
|
|
166
176
|
|
|
167
177
|
const {
|
|
168
178
|
setPageSize,
|
|
169
|
-
state: {
|
|
179
|
+
state: {pageIndex, pageSize, sortBy, filters}
|
|
170
180
|
} = tableInstance;
|
|
171
181
|
|
|
172
182
|
React.useEffect(() => {
|
|
@@ -188,45 +198,49 @@ export function Table<Data extends object = any>(props: PropsWithChildren<TableP
|
|
|
188
198
|
/* style={{ marginBottom: disablePagination ? "-1px" : "0px" }} */
|
|
189
199
|
>
|
|
190
200
|
<thead>
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
201
|
+
{tableInstance.headerGroups.map((headerGroup, i) => (
|
|
202
|
+
<tr {...headerGroup.getHeaderGroupProps()} key={`tableInstance.headerGroups${i}`}>
|
|
203
|
+
{headerGroup.headers.map((column) => (
|
|
204
|
+
<th
|
|
205
|
+
/* className='text-left py-2 align-top' */
|
|
206
|
+
{...column.getHeaderProps()}
|
|
207
|
+
key={`tableInstance.headers.column.${column.id}`}
|
|
208
|
+
>
|
|
209
|
+
<CellHeader column={column}/>
|
|
210
|
+
</th>
|
|
211
|
+
))}
|
|
212
|
+
</tr>
|
|
213
|
+
))}
|
|
204
214
|
</thead>
|
|
205
215
|
{!isLoading ? (
|
|
206
216
|
<tbody {...tableInstance.getTableBodyProps()}>
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
{row.
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
217
|
+
{tableInstance.page.map((row) => {
|
|
218
|
+
tableInstance.prepareRow(row);
|
|
219
|
+
return (
|
|
220
|
+
<tr onClick={() => _onClick(row.original, "row")} {...row.getRowProps()}
|
|
221
|
+
key={`tableInstance.page.${row.id}`}>
|
|
222
|
+
{row.cells.map((cell, i) => {
|
|
223
|
+
const {hidden, colspan} = cell.column as any;
|
|
224
|
+
if (hidden) {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
return (
|
|
228
|
+
<td
|
|
229
|
+
colSpan={colspan}
|
|
230
|
+
{...cell.getCellProps()}
|
|
231
|
+
key={`tableInstance.page.cells.${cell.value || "value"}.${i}`}>
|
|
232
|
+
{cell.render("Cell")}
|
|
233
|
+
</td>
|
|
234
|
+
);
|
|
235
|
+
})}
|
|
236
|
+
</tr>
|
|
237
|
+
);
|
|
238
|
+
})}
|
|
225
239
|
</tbody>
|
|
226
240
|
) : null}
|
|
227
241
|
</table>
|
|
228
|
-
{isLoading ? <Loader
|
|
229
|
-
{!data.length ? <EmptyData
|
|
242
|
+
{isLoading ? <Loader/> : null}
|
|
243
|
+
{!data.length ? <EmptyData/> : null}
|
|
230
244
|
{!isLoading && data.length && !disablePagination ? (
|
|
231
245
|
<div className={"overflow-hidden"}>
|
|
232
246
|
<Pagination
|
|
@@ -11,7 +11,7 @@ export function mapFormToColumns(form: FormSchema): Column[] {
|
|
|
11
11
|
|
|
12
12
|
FormioUtils.eachComponent(form.components, (component: ExtendedComponentSchema) => {
|
|
13
13
|
if (component.tableView && component.key) {
|
|
14
|
-
const cmp: any = Components.create(component,
|
|
14
|
+
const cmp: any = Components.create(component, {}, null, true);
|
|
15
15
|
|
|
16
16
|
const column: Column = {
|
|
17
17
|
Header: component.label || component.title || component.key,
|
package/src/hooks/useTooltip.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { useEffect, useRef } from "react";
|
|
|
2
2
|
import Tooltip, { Options } from "tooltip.js";
|
|
3
3
|
|
|
4
4
|
export function useTooltip(options: Options) {
|
|
5
|
-
const ref = useRef();
|
|
5
|
+
const ref = useRef<any>();
|
|
6
6
|
|
|
7
7
|
useEffect(() => {
|
|
8
8
|
ref.current && new Tooltip(ref.current as any, options);
|
|
@@ -3,4 +3,4 @@ import { selectRoot } from "../root";
|
|
|
3
3
|
import { ACTION_INFO } from "./action-info.constant";
|
|
4
4
|
import { ActionInfoState } from "./action-info.reducers";
|
|
5
5
|
|
|
6
|
-
export const selectActionInfo = (state: Record<string, any>): Partial<ActionSchema> => selectRoot<ActionInfoState>(ACTION_INFO, state).data
|
|
6
|
+
export const selectActionInfo = (state: Record<string, any>): Partial<ActionSchema> => selectRoot<ActionInfoState>(ACTION_INFO, state).data!;
|
|
@@ -7,7 +7,7 @@ export function hasRole(auth: AuthState, role: string): boolean {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export function hasRoles(auth: AuthState, roles: string[]): boolean {
|
|
10
|
-
roles = [].concat(roles);
|
|
10
|
+
roles = ([] as string[]).concat(roles);
|
|
11
11
|
|
|
12
12
|
return !!roles.find((role) => hasRole(auth, role));
|
|
13
13
|
}
|
|
@@ -29,7 +29,7 @@ export function checkRoleFormAccess(auth: AuthState, form?: Partial<FormSchema>,
|
|
|
29
29
|
return true;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
return
|
|
32
|
+
return (roles.includes("owner") && get(form, "owner") === get(auth, "user._id"));
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
return true;
|
|
@@ -8,7 +8,7 @@ function transformSubmissionAccess(forms: Record<string, FormSchema>) {
|
|
|
8
8
|
return Object.values(forms).reduce(
|
|
9
9
|
(result, form) => ({
|
|
10
10
|
...result,
|
|
11
|
-
[form.name]: form.submissionAccess.reduce(
|
|
11
|
+
[form.name as string]: form.submissionAccess.reduce(
|
|
12
12
|
(formSubmissionAccess: any, access: any) => ({
|
|
13
13
|
...formSubmissionAccess,
|
|
14
14
|
[access.type]: access.roles
|
|
@@ -24,7 +24,7 @@ function transformFormAccess(forms: Record<string, FormSchema>) {
|
|
|
24
24
|
return Object.values(forms).reduce(
|
|
25
25
|
(result, form) => ({
|
|
26
26
|
...result,
|
|
27
|
-
[form.name]: form.access.reduce(
|
|
27
|
+
[form.name as string]: form.access.reduce(
|
|
28
28
|
(formAccess: any, access: any) => ({
|
|
29
29
|
...formAccess,
|
|
30
30
|
[access.type]: access.roles
|
|
@@ -2,4 +2,4 @@ import { FormSchema } from "../../interfaces";
|
|
|
2
2
|
import { selectRoot } from "../root";
|
|
3
3
|
import { FormState } from "./form.reducers";
|
|
4
4
|
|
|
5
|
-
export const selectForm = (name: string, state: any): Partial<FormSchema> => selectRoot<FormState>(name, state).data
|
|
5
|
+
export const selectForm = (name: string, state: any): Partial<FormSchema> => selectRoot<FormState>(name, state).data!;
|
|
@@ -10,9 +10,9 @@ export function selectRoot<State = Record<string, any>>(name: string, state?: Re
|
|
|
10
10
|
return (state: Record<string, any>) => selectRoot(name, state);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export const selectError = (name: string, state: Record<string, any>): null | Error => get(selectRoot(name, state)
|
|
13
|
+
export const selectError = (name: string, state: Record<string, any>): null | Error => get(selectRoot(name, state)!, "error");
|
|
14
14
|
|
|
15
|
-
export const selectIsActive = (name: string, state: Record<string, any>): boolean => get(selectRoot(name, state)
|
|
15
|
+
export const selectIsActive = (name: string, state: Record<string, any>): boolean => get(selectRoot(name, state)!, "isActive");
|
|
16
16
|
|
|
17
17
|
export function oneOfIsActive(...names: string[]) {
|
|
18
18
|
return (state: any) => {
|
package/tsconfig.json
CHANGED
|
@@ -1,32 +1,15 @@
|
|
|
1
1
|
{
|
|
2
|
+
"extends": "@tsed/config/tsconfig.web.json",
|
|
2
3
|
"compilerOptions": {
|
|
3
|
-
"
|
|
4
|
-
"module": "esnext",
|
|
5
|
-
"lib": ["dom", "esnext"],
|
|
6
|
-
"downlevelIteration": true,
|
|
7
|
-
"moduleResolution": "node",
|
|
8
|
-
"jsx": "react",
|
|
9
|
-
"sourceMap": true,
|
|
10
|
-
"declaration": true,
|
|
11
|
-
"esModuleInterop": true,
|
|
12
|
-
"noImplicitReturns": true,
|
|
13
|
-
"noImplicitThis": true,
|
|
14
|
-
"noImplicitAny": true,
|
|
15
|
-
"strictNullChecks": false,
|
|
16
|
-
"suppressImplicitAnyIndexErrors": true,
|
|
17
|
-
"noUnusedLocals": true,
|
|
18
|
-
"noUnusedParameters": false,
|
|
19
|
-
"allowSyntheticDefaultImports": true,
|
|
20
|
-
"target": "es5",
|
|
21
|
-
"allowJs": true,
|
|
22
|
-
"skipLibCheck": true,
|
|
23
|
-
"strict": true,
|
|
24
|
-
"forceConsistentCasingInFileNames": true,
|
|
25
|
-
"noFallthroughCasesInSwitch": true,
|
|
26
|
-
"resolveJsonModule": true,
|
|
27
|
-
"isolatedModules": true,
|
|
28
|
-
"noEmit": true
|
|
4
|
+
"rootDir": "src"
|
|
29
5
|
},
|
|
30
6
|
"include": ["src"],
|
|
31
|
-
"
|
|
7
|
+
"references": [
|
|
8
|
+
{
|
|
9
|
+
"path": "./tsconfig.node.json"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"path": "../redux-utils/tsconfig.json"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
32
15
|
}
|
package/craco.config.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
2
|
-
module.exports = require("@tsed/config/craco.config")("react-formio", {
|
|
3
|
-
coverageThreshold: {
|
|
4
|
-
global: {
|
|
5
|
-
branches: 44.6,
|
|
6
|
-
functions: 60.98,
|
|
7
|
-
lines: 60.98,
|
|
8
|
-
statements: 62.27
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
});
|