@tsed/react-formio 3.0.0-alpha.12 → 3.0.0-alpha.13
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/all.d.ts +0 -0
- package/dist/all.js +38 -0
- package/dist/all.js.map +1 -0
- package/dist/chunks/_commonjsHelpers.js +30 -3
- package/dist/chunks/_commonjsHelpers.js.map +1 -1
- package/dist/chunks/index2.js +56953 -0
- package/dist/chunks/index2.js.map +1 -0
- package/dist/contexts/FormioContext.d.ts +20 -0
- package/dist/contexts/FormioContext.js +40 -0
- package/dist/contexts/FormioContext.js.map +1 -0
- package/dist/hooks/useFormioContext.d.ts +10 -0
- package/dist/hooks/useFormioContext.js +12 -0
- package/dist/hooks/useFormioContext.js.map +1 -0
- package/dist/hooks/useI18n.d.ts +4 -0
- package/dist/hooks/useI18n.js +9 -0
- package/dist/hooks/useI18n.js.map +1 -0
- package/dist/index.d.ts +1 -6
- package/dist/index.js +18 -13
- package/dist/index.js.map +1 -1
- package/dist/interfaces/ComponentType.d.ts +6 -2
- package/dist/interfaces/FormBuilderOptions.d.ts +7 -0
- package/dist/interfaces/FormBuilderOptions.js +2 -0
- package/dist/interfaces/FormBuilderOptions.js.map +1 -0
- package/dist/interfaces/FormOptions.d.ts +6 -13
- package/dist/interfaces/FormType.d.ts +4 -11
- package/dist/interfaces/SubmissionType.d.ts +5 -10
- package/dist/interfaces/index.d.ts +1 -0
- package/dist/molecules/forms/input-tags/components/ChoicesTags.d.ts +19 -19
- package/dist/molecules/forms/input-tags/components/ChoicesTags.js +16 -16
- package/dist/molecules/forms/input-tags/components/ChoicesTags.js.map +1 -1
- package/dist/molecules/forms/select/components/ChoicesSelect.js.map +1 -1
- package/dist/molecules/modal/Modal.js +6 -6
- package/dist/molecules/modal/Modal.js.map +1 -1
- package/dist/molecules/pagination/Pagination.d.ts +2 -1
- package/dist/molecules/pagination/Pagination.js +24 -24
- package/dist/molecules/pagination/Pagination.js.map +1 -1
- package/dist/molecules/table/Table.js +27 -27
- package/dist/molecules/table/Table.js.map +1 -1
- package/dist/molecules/table/hooks/useTable.d.ts +3 -3
- package/dist/molecules/table/hooks/useTable.js +13 -12
- package/dist/molecules/table/hooks/useTable.js.map +1 -1
- package/dist/molecules/table/utils/mapFormToColumns.js +22 -22
- package/dist/molecules/table/utils/mapFormToColumns.js.map +1 -1
- package/dist/molecules/tabs/TabsLegacy.d.ts +3 -2
- package/dist/molecules/tabs/TabsLegacy.js +30 -30
- package/dist/molecules/tabs/TabsLegacy.js.map +1 -1
- package/dist/organisms/form/access/FormAccess.schema.js +1 -0
- package/dist/organisms/form/access/FormAccess.schema.js.map +1 -1
- package/dist/organisms/form/actions/FormAction.js +14 -11
- package/dist/organisms/form/actions/FormAction.js.map +1 -1
- package/dist/organisms/form/builder/FormEdit.d.ts +4 -3
- package/dist/organisms/form/builder/FormEdit.js +36 -36
- package/dist/organisms/form/builder/FormEdit.js.map +1 -1
- package/dist/organisms/form/builder/FormEditCtas.d.ts +2 -2
- package/dist/organisms/form/builder/FormEditCtas.js +14 -13
- package/dist/organisms/form/builder/FormEditCtas.js.map +1 -1
- package/dist/organisms/form/builder/useFormBuilder.d.ts +4 -4
- package/dist/organisms/form/builder/useFormBuilder.js +12 -12
- package/dist/organisms/form/builder/useFormBuilder.js.map +1 -1
- package/dist/organisms/form/builder/useFormEdit.d.ts +1 -1
- package/dist/organisms/form/exports/FormExport.d.ts +3 -2
- package/dist/organisms/form/exports/FormExport.js +21 -20
- package/dist/organisms/form/exports/FormExport.js.map +1 -1
- package/dist/organisms/form/preview/FormPreview.d.ts +3 -3
- package/dist/organisms/form/preview/FormPreview.js +5 -4
- package/dist/organisms/form/preview/FormPreview.js.map +1 -1
- package/dist/organisms/form/settings/FormSettings.js +21 -21
- package/dist/organisms/form/settings/FormSettings.js.map +1 -1
- package/dist/organisms/form/useForm.d.ts +2 -1
- package/dist/organisms/form/useForm.js +2 -2
- package/dist/organisms/form/useForm.js.map +1 -1
- package/dist/organisms/table/actions/ActionsTable.d.ts +2 -1
- package/dist/organisms/table/actions/ActionsTable.js +10 -9
- package/dist/organisms/table/actions/ActionsTable.js.map +1 -1
- package/dist/organisms/table/forms/FormsTable.d.ts +1 -1
- package/dist/organisms/table/forms/FormsTable.js +9 -8
- package/dist/organisms/table/forms/FormsTable.js.map +1 -1
- package/dist/organisms/table/forms/components/FormsCell.js +10 -10
- package/dist/organisms/views/FormViews.d.ts +3 -3
- package/dist/organisms/views/FormViews.js +47 -46
- package/dist/organisms/views/FormViews.js.map +1 -1
- package/dist/utils/iconClass.js +4 -5
- package/dist/utils/iconClass.js.map +1 -1
- package/package.json +3 -3
- package/src/all.ts +34 -0
- package/src/contexts/FormioContext.tsx +96 -0
- package/src/hooks/useFormioContext.ts +13 -0
- package/src/hooks/useI18n.ts +9 -0
- package/src/index.ts +17 -13
- package/src/interfaces/ComponentType.ts +2 -2
- package/src/interfaces/FormBuilderOptions.ts +9 -0
- package/src/interfaces/FormOptions.ts +7 -13
- package/src/interfaces/FormType.ts +5 -11
- package/src/interfaces/SubmissionType.ts +9 -8
- package/src/interfaces/index.ts +1 -0
- package/src/molecules/forms/form-control/FormControl.spec.tsx +5 -2
- package/src/molecules/forms/input-tags/components/ChoicesTags.tsx +4 -4
- package/src/molecules/forms/select/components/ChoicesSelect.tsx +2 -2
- package/src/molecules/pagination/Pagination.tsx +10 -9
- package/src/molecules/table/Table.stories.tsx +6 -6
- package/src/molecules/table/Table.tsx +1 -1
- package/src/molecules/table/hooks/useTable.tsx +7 -6
- package/src/molecules/table/utils/mapFormToColumns.tsx +6 -5
- package/src/molecules/tabs/TabsLegacy.stories.tsx +1 -1
- package/src/molecules/tabs/TabsLegacy.tsx +5 -3
- package/src/organisms/form/Form.stories.tsx +4 -0
- package/src/organisms/form/access/FormAccess.schema.ts +1 -0
- package/src/organisms/form/access/FormAccess.stories.tsx +3 -1
- package/src/organisms/form/actions/FormAction.stories.tsx +5 -1
- package/src/organisms/form/actions/FormAction.tsx +2 -2
- package/src/organisms/form/builder/FormEdit.stories.tsx +10 -6
- package/src/organisms/form/builder/FormEdit.tsx +6 -6
- package/src/organisms/form/builder/FormEditCtas.tsx +10 -10
- package/src/organisms/form/builder/useFormBuilder.ts +7 -6
- package/src/organisms/form/exports/FormExport.stories.tsx +8 -11
- package/src/organisms/form/exports/FormExport.tsx +12 -9
- package/src/organisms/form/preview/FormPreview.stories.tsx +6 -9
- package/src/organisms/form/preview/FormPreview.tsx +7 -5
- package/src/organisms/form/settings/FormSettings.component.spec.tsx +3 -1
- package/src/organisms/form/settings/FormSettings.stories.tsx +1 -1
- package/src/organisms/form/settings/FormSettings.tsx +6 -6
- package/src/organisms/form/useForm.ts +2 -3
- package/src/organisms/table/actions/ActionsTable.tsx +7 -5
- package/src/organisms/table/forms/FormsTable.tsx +6 -5
- package/src/organisms/table/submissions/SubmissionsTable.stories.tsx +10 -13
- package/src/organisms/views/FormViews.stories.tsx +13 -16
- package/src/organisms/views/FormViews.tsx +18 -16
- package/src/utils/iconClass.ts +1 -3
- package/dist/typings.d.js +0 -2
- package/dist/typings.d.js.map +0 -1
- package/src/typings.d.ts +0 -3
|
@@ -37,12 +37,12 @@ export function useChoiceTags<Data = string>(props: InputTagsProps<Data>) {
|
|
|
37
37
|
|
|
38
38
|
instanceRef.current = instance;
|
|
39
39
|
|
|
40
|
-
instance.passedElement.element.addEventListener("addItem", (event
|
|
41
|
-
onAdd(event.
|
|
40
|
+
instance.passedElement.element.addEventListener("addItem", (event) => {
|
|
41
|
+
onAdd((event.target as any).value as Data);
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
instance.passedElement.element.addEventListener("removeItem", (event
|
|
45
|
-
onDelete(event.
|
|
44
|
+
instance.passedElement.element.addEventListener("removeItem", (event) => {
|
|
45
|
+
onDelete((event.target as any).value as Data);
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -66,9 +66,9 @@ export function useChoices({
|
|
|
66
66
|
if (choicesRef.current) {
|
|
67
67
|
if (multiple) {
|
|
68
68
|
choicesRef.current.clearStore();
|
|
69
|
-
choicesRef.current.setChoices(opts, "value", "label", true);
|
|
69
|
+
choicesRef.current.setChoices(opts as any, "value", "label", true);
|
|
70
70
|
} else {
|
|
71
|
-
choicesRef.current.setChoices(opts, "value", "label", true);
|
|
71
|
+
choicesRef.current.setChoices(opts as any, "value", "label", true);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
}, [opts]);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import classnames from "classnames";
|
|
2
2
|
|
|
3
|
+
import { useI18n } from "../../hooks/useI18n.js";
|
|
4
|
+
import type { FormOptions } from "../../interfaces/index.js";
|
|
3
5
|
import { getComponent, registerComponent } from "../../registries/components";
|
|
4
6
|
import type { Select as DefaultSelect } from "../forms/select/Select";
|
|
5
7
|
import type { PaginationButton as DefaultPaginationButton } from "./PaginationButton";
|
|
@@ -16,8 +18,7 @@ export interface PaginationProps {
|
|
|
16
18
|
pageSize: number;
|
|
17
19
|
rowCount?: number;
|
|
18
20
|
layout?: "html5" | "react" | "choicesjs";
|
|
19
|
-
i18n?:
|
|
20
|
-
|
|
21
|
+
i18n?: FormOptions["i18n"];
|
|
21
22
|
onPageIndexChange: (pageIndex: number) => void;
|
|
22
23
|
onClickPreviousPage: () => void;
|
|
23
24
|
onClickNextPage: () => void;
|
|
@@ -38,9 +39,9 @@ export function Pagination(props: PaginationProps) {
|
|
|
38
39
|
pageOptions,
|
|
39
40
|
pageSize,
|
|
40
41
|
onPageSizeChange,
|
|
41
|
-
rowCount
|
|
42
|
-
i18n = (f: string) => f
|
|
42
|
+
rowCount
|
|
43
43
|
} = props;
|
|
44
|
+
const { t } = useI18n(props.i18n);
|
|
44
45
|
|
|
45
46
|
const pageNumbers = getPageNumbers({
|
|
46
47
|
currentPage: pageIndex,
|
|
@@ -57,7 +58,7 @@ export function Pagination(props: PaginationProps) {
|
|
|
57
58
|
<ul className='pagination mb-3 mr-3'>
|
|
58
59
|
<li className={classnames("page-item", !canPreviousPage && "disabled")}>
|
|
59
60
|
<PaginationButton tabIndex={-1} disabled={!canPreviousPage} onClick={() => onClickPreviousPage()}>
|
|
60
|
-
{
|
|
61
|
+
{t("Previous")}
|
|
61
62
|
</PaginationButton>
|
|
62
63
|
</li>
|
|
63
64
|
|
|
@@ -82,7 +83,7 @@ export function Pagination(props: PaginationProps) {
|
|
|
82
83
|
|
|
83
84
|
<li className={classnames("page-item", !canNextPage && "disabled")}>
|
|
84
85
|
<PaginationButton tabIndex={pageNumbers.length} disabled={!canNextPage} onClick={() => onClickNextPage()}>
|
|
85
|
-
{
|
|
86
|
+
{t("Next")}
|
|
86
87
|
</PaginationButton>
|
|
87
88
|
</li>
|
|
88
89
|
</ul>
|
|
@@ -98,11 +99,11 @@ export function Pagination(props: PaginationProps) {
|
|
|
98
99
|
onPageSizeChange(+value);
|
|
99
100
|
}}
|
|
100
101
|
/>
|
|
101
|
-
<span className={"ml-3"}>{
|
|
102
|
+
<span className={"ml-3"}>{t("items per page")}</span>
|
|
102
103
|
</li>
|
|
103
104
|
{pageOptions && (
|
|
104
105
|
<li className={"mb-3 mr-3 flex items-center"}>
|
|
105
|
-
<span>{
|
|
106
|
+
<span>{t("Page")} </span>
|
|
106
107
|
<strong>
|
|
107
108
|
{pageIndex + 1} of {pageOptions.length}
|
|
108
109
|
</strong>
|
|
@@ -110,7 +111,7 @@ export function Pagination(props: PaginationProps) {
|
|
|
110
111
|
)}
|
|
111
112
|
{rowCount !== undefined && (
|
|
112
113
|
<li className={"mb-3 flex items-center"} data-testid='pagination-total-items'>
|
|
113
|
-
{
|
|
114
|
+
{t("Total")}: <strong className='mx-1'>{new Intl.NumberFormat(undefined).format(rowCount)}</strong> {t("items")}
|
|
114
115
|
</li>
|
|
115
116
|
)}
|
|
116
117
|
</nav>
|
|
@@ -73,7 +73,7 @@ type Story = StoryObj<typeof Table<ProductSubmission>>;
|
|
|
73
73
|
|
|
74
74
|
export const Usage: Story = {
|
|
75
75
|
args: {
|
|
76
|
-
data: formSubmissions as ProductSubmission[],
|
|
76
|
+
data: formSubmissions as unknown as ProductSubmission[],
|
|
77
77
|
columns: mapFormToColumns(FormType as any),
|
|
78
78
|
operations: [
|
|
79
79
|
{
|
|
@@ -93,7 +93,7 @@ export const Usage: Story = {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
],
|
|
96
|
-
i18n:
|
|
96
|
+
i18n: {},
|
|
97
97
|
onClick: fn(),
|
|
98
98
|
onChange: fn()
|
|
99
99
|
},
|
|
@@ -182,7 +182,7 @@ export const Usage: Story = {
|
|
|
182
182
|
|
|
183
183
|
export const WithFilters: Story = {
|
|
184
184
|
args: {
|
|
185
|
-
data: formSubmissions as ProductSubmission[],
|
|
185
|
+
data: formSubmissions as unknown as ProductSubmission[],
|
|
186
186
|
columns: mapFormToColumns(FormType as any, [
|
|
187
187
|
{
|
|
188
188
|
accessorKey: "data.id",
|
|
@@ -212,14 +212,14 @@ export const WithFilters: Story = {
|
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
],
|
|
215
|
-
i18n:
|
|
215
|
+
i18n: {},
|
|
216
216
|
onClick: fn()
|
|
217
217
|
}
|
|
218
218
|
};
|
|
219
219
|
|
|
220
220
|
export const WithCustomCell: Story = {
|
|
221
221
|
args: {
|
|
222
|
-
data: formSubmissions as ProductSubmission[],
|
|
222
|
+
data: formSubmissions as unknown as ProductSubmission[],
|
|
223
223
|
columns: mapFormToColumns<ProductSubmission>(FormType as any, [
|
|
224
224
|
{
|
|
225
225
|
accessorKey: "data.id",
|
|
@@ -299,7 +299,7 @@ export const WithCustomCell: Story = {
|
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
],
|
|
302
|
-
i18n:
|
|
302
|
+
i18n: {},
|
|
303
303
|
onClick: fn()
|
|
304
304
|
}
|
|
305
305
|
};
|
|
@@ -90,7 +90,7 @@ export function Table<Data extends { [key: string]: JSON } = { [key: string]: JS
|
|
|
90
90
|
pageIndex={pagination.pageIndex}
|
|
91
91
|
pageSize={pagination.pageSize}
|
|
92
92
|
pageSizes={props.pageSizes}
|
|
93
|
-
i18n={i18n}
|
|
93
|
+
i18n={props.i18n}
|
|
94
94
|
pageCount={tableInstance.getPageCount()}
|
|
95
95
|
rowCount={props.rowCount}
|
|
96
96
|
onPageIndexChange={(page) => tableInstance.setPageIndex(page)}
|
|
@@ -12,7 +12,8 @@ import {
|
|
|
12
12
|
} from "@tanstack/react-table";
|
|
13
13
|
import { useEffect } from "react";
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { useI18n } from "../../../hooks/useI18n.js";
|
|
16
|
+
import { type FormOptions, type JSON, Operation } from "../../../interfaces";
|
|
16
17
|
import { getComponent } from "../../../registries/components";
|
|
17
18
|
import type { DefaultCellOperations } from "../components/DefaultCellOperations";
|
|
18
19
|
|
|
@@ -20,7 +21,7 @@ export interface UseTableProps<Data extends { [key: string]: JSON } = { [key: st
|
|
|
20
21
|
extends Omit<TableOptions<Data>, "getCoreRowModel" | "onClick"> {
|
|
21
22
|
operations: Operation<Data>[];
|
|
22
23
|
metadata?: Record<string, unknown>;
|
|
23
|
-
i18n?:
|
|
24
|
+
i18n?: FormOptions["i18n"];
|
|
24
25
|
onClick?: (data: any, operation: Operation<Data>) => void;
|
|
25
26
|
manualFaceted?: boolean;
|
|
26
27
|
onChange?: (query: TableState) => void;
|
|
@@ -29,7 +30,7 @@ export interface UseTableProps<Data extends { [key: string]: JSON } = { [key: st
|
|
|
29
30
|
|
|
30
31
|
export function useTable<Data extends { [key: string]: JSON } = { [key: string]: JSON }>(props: UseTableProps<Data>) {
|
|
31
32
|
const Operations = getComponent<typeof DefaultCellOperations<Data>>("CellOperations");
|
|
32
|
-
const
|
|
33
|
+
const { t } = useI18n(props.i18n);
|
|
33
34
|
|
|
34
35
|
// const [pagination, setPagination] = useState({
|
|
35
36
|
// pageIndex: 0, //initial page index
|
|
@@ -40,9 +41,9 @@ export function useTable<Data extends { [key: string]: JSON } = { [key: string]:
|
|
|
40
41
|
? ([
|
|
41
42
|
{
|
|
42
43
|
id: "operations",
|
|
43
|
-
header:
|
|
44
|
+
header: t("Operations"),
|
|
44
45
|
cell: (info) => (
|
|
45
|
-
<Operations info={info} operations={props.operations} metadata={props.metadata} onClick={props.onClick} i18n={
|
|
46
|
+
<Operations info={info} operations={props.operations} metadata={props.metadata} onClick={props.onClick} i18n={t} />
|
|
46
47
|
)
|
|
47
48
|
}
|
|
48
49
|
] satisfies ColumnDef<Data>[])
|
|
@@ -69,7 +70,7 @@ export function useTable<Data extends { [key: string]: JSON } = { [key: string]:
|
|
|
69
70
|
}, [columnFilters, sorting, pagination, columnOrder, columnPinning, columnSizing, columnSizingInfo, columnVisibility, globalFilter]);
|
|
70
71
|
|
|
71
72
|
return {
|
|
72
|
-
i18n,
|
|
73
|
+
i18n: t,
|
|
73
74
|
tableInstance
|
|
74
75
|
};
|
|
75
76
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../interfaces/extends";
|
|
2
2
|
|
|
3
|
+
import { Components } from "@formio/js";
|
|
3
4
|
import { ColumnDef, ColumnDefResolved, createColumnHelper } from "@tanstack/react-table";
|
|
4
|
-
import { Components } from "formiojs";
|
|
5
5
|
import cloneDeep from "lodash/cloneDeep";
|
|
6
6
|
import get from "lodash/get";
|
|
7
7
|
|
|
@@ -25,14 +25,15 @@ export function mapFormToColumns<Data = any>(form: FormType, columns: ColumnDefR
|
|
|
25
25
|
const columnsFromComponents = form.components
|
|
26
26
|
.flatMap((component) => {
|
|
27
27
|
if (component.type === "tabs") {
|
|
28
|
-
return component.components
|
|
28
|
+
return component.components?.flatMap((subComponent: ComponentType) => subComponent.components);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
return [component];
|
|
32
32
|
})
|
|
33
|
-
.filter((component) => component
|
|
34
|
-
.map((
|
|
35
|
-
const
|
|
33
|
+
.filter((component) => component?.tableView)
|
|
34
|
+
.map((c) => {
|
|
35
|
+
const component = c as ComponentType;
|
|
36
|
+
const cmp: any = Components.create(component, {}, null);
|
|
36
37
|
|
|
37
38
|
const columnIndex = columnsToKeep.findIndex(({ accessorKey }) => {
|
|
38
39
|
return accessorKey === `data.${component.key}`;
|
|
@@ -2,6 +2,8 @@ import "./all.js";
|
|
|
2
2
|
|
|
3
3
|
import { CSSProperties, ReactNode } from "react";
|
|
4
4
|
|
|
5
|
+
import { useI18n } from "../../hooks/useI18n.js";
|
|
6
|
+
import type { FormOptions } from "../../interfaces/index.js";
|
|
5
7
|
import { getComponent } from "../../registries/components.js";
|
|
6
8
|
import type { Tab as DefaultTab } from "./Tab.js";
|
|
7
9
|
import type { TabList as DefaultTabList } from "./TabList.js";
|
|
@@ -23,7 +25,7 @@ export interface TabsLegacyProps extends Record<string, any> {
|
|
|
23
25
|
className?: string;
|
|
24
26
|
reverse?: boolean;
|
|
25
27
|
onClick?: (item: TabsItemProps) => void;
|
|
26
|
-
i18n?:
|
|
28
|
+
i18n?: FormOptions["i18n"];
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
export function TabsLegacy({
|
|
@@ -34,7 +36,6 @@ export function TabsLegacy({
|
|
|
34
36
|
AddButton,
|
|
35
37
|
className,
|
|
36
38
|
onClick,
|
|
37
|
-
i18n = (f) => f,
|
|
38
39
|
reverse,
|
|
39
40
|
after,
|
|
40
41
|
...additionalProps
|
|
@@ -45,6 +46,7 @@ export function TabsLegacy({
|
|
|
45
46
|
const TabPanel = getComponent<typeof DefaultTabPanel>("TabPanel");
|
|
46
47
|
const Tabs = getComponent<typeof DefaultTabs>("Tabs");
|
|
47
48
|
const tabs = items.filter((item) => item.label || item.icon);
|
|
49
|
+
const { t } = useI18n(additionalProps.i18n);
|
|
48
50
|
|
|
49
51
|
return (
|
|
50
52
|
<Tabs className={className} style={style}>
|
|
@@ -62,7 +64,7 @@ export function TabsLegacy({
|
|
|
62
64
|
className={reverse ? "-reverse" : ""}
|
|
63
65
|
after={after}
|
|
64
66
|
>
|
|
65
|
-
{
|
|
67
|
+
{t(item.label || "")}
|
|
66
68
|
</Tab>
|
|
67
69
|
);
|
|
68
70
|
})}
|
|
@@ -526,6 +526,8 @@ export const FetchSubmissionWithCustomAction: Story = {
|
|
|
526
526
|
expect(canvas.getByTestId("formio-container")).toHaveClass("formio-form-ready");
|
|
527
527
|
});
|
|
528
528
|
|
|
529
|
+
await delay(200);
|
|
530
|
+
|
|
529
531
|
let firstnameInput = canvas.getByRole("textbox", { name: "First name" });
|
|
530
532
|
let lastNameInput = canvas.getByRole("textbox", { name: "Last name" });
|
|
531
533
|
|
|
@@ -639,6 +641,8 @@ export const ErrorOnSubmitServer: Story = {
|
|
|
639
641
|
expect(canvas.getByTestId("formio-container")).toHaveClass("formio-form-ready");
|
|
640
642
|
});
|
|
641
643
|
|
|
644
|
+
await delay(200);
|
|
645
|
+
|
|
642
646
|
let firstnameInput = canvas.getByRole("textbox", { name: "First name" });
|
|
643
647
|
let lastNameInput = canvas.getByRole("textbox", { name: "Last name" });
|
|
644
648
|
|
|
@@ -88,6 +88,7 @@ export const SaveAction: Story = {
|
|
|
88
88
|
input: false,
|
|
89
89
|
tree: true,
|
|
90
90
|
legend: "Action Settings",
|
|
91
|
+
key: "settings",
|
|
91
92
|
components: [
|
|
92
93
|
{
|
|
93
94
|
input: false,
|
|
@@ -101,7 +102,8 @@ export const SaveAction: Story = {
|
|
|
101
102
|
placeholder: "This form",
|
|
102
103
|
basePath: "/project/5d0797bc872fc7d140559857/form",
|
|
103
104
|
form: "62b18b10fbbba513555c6c5e",
|
|
104
|
-
required: false
|
|
105
|
+
required: false,
|
|
106
|
+
input: true
|
|
105
107
|
}
|
|
106
108
|
]
|
|
107
109
|
}
|
|
@@ -205,6 +207,7 @@ export const EmailAction: Story = {
|
|
|
205
207
|
input: false,
|
|
206
208
|
tree: true,
|
|
207
209
|
legend: "Email Settings",
|
|
210
|
+
key: "settings",
|
|
208
211
|
components: [
|
|
209
212
|
{
|
|
210
213
|
type: "textfield",
|
|
@@ -340,6 +343,7 @@ export const WebhookAction: Story = {
|
|
|
340
343
|
input: false,
|
|
341
344
|
tree: true,
|
|
342
345
|
legend: "Webhook Settings",
|
|
346
|
+
key: "settings",
|
|
343
347
|
components: [
|
|
344
348
|
{
|
|
345
349
|
type: "textfield",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import FormioUtils from "
|
|
1
|
+
import FormioUtils from "@formio/js/utils";
|
|
2
2
|
import { PropsWithChildren, ReactElement } from "react";
|
|
3
3
|
|
|
4
4
|
import { ActionDefaultsType, ActionType, FormOptions, SubmissionType } from "../../../interfaces";
|
|
@@ -44,7 +44,7 @@ export function FormAction({ actionInfo, children, onSubmit, options, ...props }
|
|
|
44
44
|
const submission = mapData(props.submission || {}, actionInfo.defaults!);
|
|
45
45
|
const form = mapSettingsForm(actionInfo.settingsForm);
|
|
46
46
|
|
|
47
|
-
return { form, submission: { data: submission } };
|
|
47
|
+
return { form, submission: { data: submission } as SubmissionType<ActionType> };
|
|
48
48
|
})();
|
|
49
49
|
|
|
50
50
|
return (
|
|
@@ -92,7 +92,14 @@ export default {
|
|
|
92
92
|
options: ["choicesjs", "react"]
|
|
93
93
|
}
|
|
94
94
|
},
|
|
95
|
-
parameters: {}
|
|
95
|
+
parameters: {},
|
|
96
|
+
args: {
|
|
97
|
+
options: {
|
|
98
|
+
template: "tailwind",
|
|
99
|
+
iconset: "bx",
|
|
100
|
+
noDefaultSubmitButton: true
|
|
101
|
+
}
|
|
102
|
+
}
|
|
96
103
|
} satisfies Meta<typeof FormEdit>;
|
|
97
104
|
|
|
98
105
|
type Story = StoryObj<typeof FormEdit>;
|
|
@@ -106,7 +113,6 @@ export const EditWebForm: Story = {
|
|
|
106
113
|
],
|
|
107
114
|
displayChoices: defaultDisplayChoices,
|
|
108
115
|
enableTags: true,
|
|
109
|
-
options: { template: "tailwind", iconset: "bx" },
|
|
110
116
|
form: {
|
|
111
117
|
type: "form",
|
|
112
118
|
tags: [],
|
|
@@ -307,8 +313,7 @@ export const WithoutTypeChoices: Story = {
|
|
|
307
313
|
machineName: "tcspjwhsevrzpcd:textField"
|
|
308
314
|
} as any,
|
|
309
315
|
displayChoices: defaultDisplayChoices,
|
|
310
|
-
enableTags: true
|
|
311
|
-
options: { template: "tailwind", iconset: "bx" }
|
|
316
|
+
enableTags: true
|
|
312
317
|
}
|
|
313
318
|
};
|
|
314
319
|
|
|
@@ -412,7 +417,6 @@ export const WithoutTags: Story = {
|
|
|
412
417
|
machineName: "tcspjwhsevrzpcd:textField"
|
|
413
418
|
} as any,
|
|
414
419
|
displayChoices: defaultDisplayChoices,
|
|
415
|
-
enableTags: false
|
|
416
|
-
options: { template: "tailwind", iconset: "bx" }
|
|
420
|
+
enableTags: false
|
|
417
421
|
}
|
|
418
422
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import classnames from "classnames";
|
|
2
|
+
import type { CSSProperties } from "react";
|
|
2
3
|
|
|
3
|
-
import type { FormOptions } from "../../../interfaces";
|
|
4
|
+
import type { FormBuilderOptions, FormOptions } from "../../../interfaces/index.js";
|
|
4
5
|
import { getComponent } from "../../../registries/components";
|
|
5
6
|
import { FormBuilder as DefaultFormBuilder } from "./FormBuilder";
|
|
6
7
|
import { FormEditCTAs as DefaultFormEditCTAs } from "./FormEditCtas";
|
|
@@ -9,10 +10,10 @@ import { FormBuilderEvents } from "./useFormBuilder";
|
|
|
9
10
|
import { useFormEdit, UseFormEditHookProps } from "./useFormEdit";
|
|
10
11
|
|
|
11
12
|
export interface FormEditProps extends UseFormEditHookProps, FormBuilderEvents {
|
|
12
|
-
options?: FormOptions;
|
|
13
|
+
options?: FormBuilderOptions & FormOptions;
|
|
13
14
|
layout?: "html5" | "choicesjs" | "react";
|
|
14
15
|
className?: string;
|
|
15
|
-
style?:
|
|
16
|
+
style?: CSSProperties;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export function FormEdit({
|
|
@@ -35,7 +36,6 @@ export function FormEdit({
|
|
|
35
36
|
onCopy: initialOnCopy
|
|
36
37
|
});
|
|
37
38
|
|
|
38
|
-
const { options = {} } = props;
|
|
39
39
|
const FormParameters = getComponent<typeof DefaultFormParameters>("FormParameters");
|
|
40
40
|
const FormBuilder = getComponent<typeof DefaultFormBuilder>("FormBuilder");
|
|
41
41
|
const FormEditCTAs = getComponent<typeof DefaultFormEditCTAs>("FormEditCTAs");
|
|
@@ -54,7 +54,7 @@ export function FormEdit({
|
|
|
54
54
|
/>
|
|
55
55
|
<FormEditCTAs
|
|
56
56
|
key={`form-edit-ctas-${form._id}`}
|
|
57
|
-
options={options}
|
|
57
|
+
options={props.options}
|
|
58
58
|
hasRedo={hasRedo}
|
|
59
59
|
hasUndo={hasUndo}
|
|
60
60
|
disabled={!(isValid && hasChanged)}
|
|
@@ -71,7 +71,7 @@ export function FormEdit({
|
|
|
71
71
|
key={`form-builder-${form._id}`}
|
|
72
72
|
components={form.components!}
|
|
73
73
|
display={form.display}
|
|
74
|
-
options={options}
|
|
74
|
+
options={props.options}
|
|
75
75
|
onChange={(components) => {
|
|
76
76
|
setChange("components", components);
|
|
77
77
|
}}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ReactElement } from "react";
|
|
2
2
|
|
|
3
3
|
import { Icon as DefaultIcon } from "../../../atoms/icon/Icon";
|
|
4
|
+
import { useI18n } from "../../../hooks/useI18n";
|
|
4
5
|
import { useTooltip } from "../../../hooks/useTooltip";
|
|
5
|
-
import type { FormOptions } from "../../../interfaces";
|
|
6
|
+
import type { FormOptions } from "../../../interfaces/index.js";
|
|
6
7
|
import { Button as DefaultButton } from "../../../molecules/button/Button";
|
|
7
8
|
import { getComponent, registerComponent } from "../../../registries/components";
|
|
8
9
|
|
|
@@ -22,17 +23,16 @@ export interface FormEditCTAsProps extends Record<string, unknown> {
|
|
|
22
23
|
export function FormEditCTAs({
|
|
23
24
|
saveText = "Save",
|
|
24
25
|
disabled,
|
|
25
|
-
options = {},
|
|
26
26
|
onCopy,
|
|
27
27
|
hasUndo,
|
|
28
28
|
hasRedo,
|
|
29
29
|
onUndo,
|
|
30
30
|
onRedo,
|
|
31
31
|
onReset,
|
|
32
|
-
onSubmit
|
|
32
|
+
onSubmit,
|
|
33
|
+
options
|
|
33
34
|
}: FormEditCTAsProps): ReactElement {
|
|
34
|
-
const {
|
|
35
|
-
|
|
35
|
+
const { t } = useI18n(options?.i18n);
|
|
36
36
|
const copyTooltipRef: any = useTooltip({
|
|
37
37
|
trigger: "hover",
|
|
38
38
|
placement: "top",
|
|
@@ -64,29 +64,29 @@ export function FormEditCTAs({
|
|
|
64
64
|
<div className={"form-edit__actions"}>
|
|
65
65
|
<div>
|
|
66
66
|
<Button variant='primary' className='btn-save' disabled={disabled} onClick={() => onSubmit?.()}>
|
|
67
|
-
<Icon name='save' iconset={options
|
|
67
|
+
<Icon name='save' iconset={options?.iconset} />
|
|
68
68
|
{saveText}
|
|
69
69
|
</Button>
|
|
70
70
|
|
|
71
71
|
<div>
|
|
72
72
|
<Button variant='light' className='btn-undo' disabled={!hasUndo} onClick={() => onUndo?.()} ref={undoTooltipRef}>
|
|
73
|
-
<Icon name='undo' iconset={options
|
|
73
|
+
<Icon name='undo' iconset={options?.iconset} />
|
|
74
74
|
</Button>
|
|
75
75
|
|
|
76
76
|
<Button variant='light' className='btn-redo' disabled={!hasRedo} onClick={() => onRedo?.()} ref={redoTooltipRef}>
|
|
77
|
-
<Icon name='redo' iconset={options
|
|
77
|
+
<Icon name='redo' iconset={options?.iconset} />
|
|
78
78
|
</Button>
|
|
79
79
|
</div>
|
|
80
80
|
|
|
81
81
|
<div>
|
|
82
82
|
{onCopy && (
|
|
83
83
|
<Button variant='light' className='btn-copy' onClick={() => onCopy()} ref={copyTooltipRef}>
|
|
84
|
-
<Icon name='copy' iconset={options
|
|
84
|
+
<Icon name='copy' iconset={options?.iconset} />
|
|
85
85
|
</Button>
|
|
86
86
|
)}
|
|
87
87
|
|
|
88
88
|
<Button variant='light' className='btn-reset' onClick={() => onReset && onReset()} ref={resetTooltipRef!}>
|
|
89
|
-
<Icon name='reset' iconset={options
|
|
89
|
+
<Icon name='reset' iconset={options?.iconset} />
|
|
90
90
|
</Button>
|
|
91
91
|
</div>
|
|
92
92
|
</div>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { FormBuilder as FormioFormBuilder } from "
|
|
1
|
+
import { FormBuilder as FormioFormBuilder } from "@formio/js";
|
|
2
2
|
import cloneDeep from "lodash/cloneDeep";
|
|
3
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
|
|
5
|
-
import type { ComponentType,
|
|
5
|
+
import type { ComponentType, FormBuilderOptions, FormType } from "../../../interfaces";
|
|
6
6
|
|
|
7
7
|
interface BuilderConstructor {
|
|
8
|
-
new (element: HTMLDivElement, form: FormType, options:
|
|
8
|
+
new (element: HTMLDivElement, form: FormType, options: FormBuilderOptions): FormioFormBuilder;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
const EVENTS = [
|
|
@@ -29,7 +29,7 @@ async function createBuilder(el: Element, { components = [], display, options, o
|
|
|
29
29
|
components: [...components]
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
const builder = await new FormioFormBuilder(el, form, { ...options }).ready;
|
|
32
|
+
const builder = await new FormioFormBuilder(el as HTMLElement, form, { ...options }).ready;
|
|
33
33
|
|
|
34
34
|
const handleEvent = (event: string) => {
|
|
35
35
|
return (...args: any[]) => {
|
|
@@ -45,6 +45,7 @@ async function createBuilder(el: Element, { components = [], display, options, o
|
|
|
45
45
|
|
|
46
46
|
return builder;
|
|
47
47
|
}
|
|
48
|
+
|
|
48
49
|
export interface FormBuilderEvents {
|
|
49
50
|
onAddComponent?: Function;
|
|
50
51
|
onRemoveComponent?: Function;
|
|
@@ -73,7 +74,7 @@ export interface UseFormBuilderProps extends FormBuilderEvents {
|
|
|
73
74
|
Builder?: BuilderConstructor;
|
|
74
75
|
components: ComponentType[];
|
|
75
76
|
display?: string;
|
|
76
|
-
options?:
|
|
77
|
+
options?: FormBuilderOptions;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
export function useFormBuilder({ components, display, options = {}, onBuilderReady, onChange, ...props }: UseFormBuilderProps) {
|
|
@@ -111,7 +112,7 @@ export function useFormBuilder({ components, display, options = {}, onBuilderRea
|
|
|
111
112
|
|
|
112
113
|
useEffect(() => {
|
|
113
114
|
if (builderRef.current) {
|
|
114
|
-
if (display !== builderRef.current.form.display) {
|
|
115
|
+
if (display !== (builderRef.current.form as FormType).display) {
|
|
115
116
|
createBuilder(renderElement.current!.firstChild as Element, {
|
|
116
117
|
display,
|
|
117
118
|
options: { ...options },
|
|
@@ -36,7 +36,7 @@ type Story = StoryObj<typeof FormExport>;
|
|
|
36
36
|
*/
|
|
37
37
|
export const Usage: Story = {
|
|
38
38
|
args: {
|
|
39
|
-
i18n:
|
|
39
|
+
i18n: {},
|
|
40
40
|
onClick: (action: string, format: string) => console.log(`Action: ${action}, Format: ${format}`)
|
|
41
41
|
}
|
|
42
42
|
};
|
|
@@ -46,7 +46,7 @@ export const Usage: Story = {
|
|
|
46
46
|
*/
|
|
47
47
|
export const Resource: Story = {
|
|
48
48
|
args: {
|
|
49
|
-
i18n:
|
|
49
|
+
i18n: {},
|
|
50
50
|
onClick: (action: string, format: string) => console.log(`Action: ${action}, Format: ${format}`)
|
|
51
51
|
}
|
|
52
52
|
};
|
|
@@ -56,15 +56,12 @@ export const Resource: Story = {
|
|
|
56
56
|
*/
|
|
57
57
|
export const Translated: Story = {
|
|
58
58
|
args: {
|
|
59
|
-
i18n:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
"Export form submissions": "Exporter les soumissions du formulaire"
|
|
66
|
-
};
|
|
67
|
-
return translations[key] || key;
|
|
59
|
+
i18n: {
|
|
60
|
+
"Export schema": "Exporter le schéma",
|
|
61
|
+
"Export the formIO schema:": "Exporter le schéma formIO :",
|
|
62
|
+
Json: "Json",
|
|
63
|
+
Csv: "Csv",
|
|
64
|
+
"Export form submissions": "Exporter les soumissions du formulaire"
|
|
68
65
|
},
|
|
69
66
|
onClick: (action: string, format: string) => console.log(`Action: ${action}, Format: ${format}`)
|
|
70
67
|
}
|