@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
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { Icon } from "../../../atoms/icon/Icon.js";
|
|
2
|
+
import { useI18n } from "../../../hooks/useI18n.js";
|
|
3
|
+
import { FormOptions } from "../../../interfaces/FormOptions.js";
|
|
2
4
|
import type { Card } from "../../../molecules/card/Card.js";
|
|
3
5
|
import { getComponent } from "../../../registries/components.js";
|
|
4
6
|
|
|
5
7
|
export interface FormExportProps {
|
|
6
|
-
i18n?:
|
|
8
|
+
i18n?: FormOptions["i18n"];
|
|
7
9
|
onClick?: (action: "export:form" | "export:submissions", format: "json" | "csv") => void;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
|
-
export function FormExport({
|
|
12
|
+
export function FormExport({ onClick, ...props }: FormExportProps) {
|
|
11
13
|
const FCard = getComponent<typeof Card>("Card");
|
|
14
|
+
const { t } = useI18n(props?.i18n);
|
|
12
15
|
|
|
13
16
|
return (
|
|
14
17
|
<div>
|
|
@@ -18,15 +21,15 @@ export function FormExport({ i18n = (f: string) => f, onClick }: FormExportProps
|
|
|
18
21
|
label={
|
|
19
22
|
(
|
|
20
23
|
<span className={"flex items-center"}>
|
|
21
|
-
<Icon name={"detail"} className={"mr-1 text-secondary"} /> {
|
|
24
|
+
<Icon name={"detail"} className={"mr-1 text-secondary"} /> {t(`Export schema`)}
|
|
22
25
|
</span>
|
|
23
26
|
) as any
|
|
24
27
|
}
|
|
25
28
|
>
|
|
26
|
-
<p className={"mb-5"}>{
|
|
29
|
+
<p className={"mb-5"}>{t("Export the formIO schema:")}</p>
|
|
27
30
|
<div className={"flex items-center justify-center"}>
|
|
28
31
|
<button className={"btn btn-primary"} onClick={() => onClick?.("export:form", "json")}>
|
|
29
|
-
<Icon name={"code"} className={"mr-1"} /> {
|
|
32
|
+
<Icon name={"code"} className={"mr-1"} /> {t(`Json`)}
|
|
30
33
|
</button>
|
|
31
34
|
</div>
|
|
32
35
|
</FCard>
|
|
@@ -36,18 +39,18 @@ export function FormExport({ i18n = (f: string) => f, onClick }: FormExportProps
|
|
|
36
39
|
label={
|
|
37
40
|
(
|
|
38
41
|
<span className={"flex items-center"}>
|
|
39
|
-
<Icon name={"data"} className={"mr-1 text-secondary"} /> {
|
|
42
|
+
<Icon name={"data"} className={"mr-1 text-secondary"} /> {t(`Export submissions`)}
|
|
40
43
|
</span>
|
|
41
44
|
) as any
|
|
42
45
|
}
|
|
43
46
|
>
|
|
44
|
-
<p className={"mb-5"}>{
|
|
47
|
+
<p className={"mb-5"}>{t("Export all submission as JSON or CSV:")}</p>
|
|
45
48
|
<div className={"flex items-center justify-center"}>
|
|
46
49
|
<button className={"btn btn-primary mr-4"} onClick={() => onClick?.("export:submissions", "json")}>
|
|
47
|
-
<Icon name={"code"} className={"mr-1"} /> {
|
|
50
|
+
<Icon name={"code"} className={"mr-1"} /> {t(`Json`)}
|
|
48
51
|
</button>
|
|
49
52
|
<button className={"btn btn-primary"} onClick={() => onClick?.("export:submissions", "csv")}>
|
|
50
|
-
<Icon name={"spreadsheet"} className={"mr-1"} /> {
|
|
53
|
+
<Icon name={"spreadsheet"} className={"mr-1"} /> {t(`Csv`)}
|
|
51
54
|
</button>
|
|
52
55
|
</div>
|
|
53
56
|
</FCard>
|
|
@@ -38,7 +38,7 @@ type Story = StoryObj<typeof FormPreview>;
|
|
|
38
38
|
export const Usage: Story = {
|
|
39
39
|
args: {
|
|
40
40
|
form: formFirstname as any,
|
|
41
|
-
i18n:
|
|
41
|
+
i18n: {}
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
|
|
@@ -48,14 +48,11 @@ export const Usage: Story = {
|
|
|
48
48
|
export const Translated: Story = {
|
|
49
49
|
args: {
|
|
50
50
|
form: formFirstname as any,
|
|
51
|
-
i18n:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
Submit: "Soumettre"
|
|
57
|
-
};
|
|
58
|
-
return translations[key] || key;
|
|
51
|
+
i18n: {
|
|
52
|
+
"Form with First Name": "Formulaire avec prénom",
|
|
53
|
+
"First name": "Prénom",
|
|
54
|
+
"Last name": "Nom de famille",
|
|
55
|
+
Submit: "Soumettre"
|
|
59
56
|
}
|
|
60
57
|
}
|
|
61
58
|
};
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useI18n } from "../../../hooks/useI18n.js";
|
|
2
|
+
import type { FormOptions, FormType } from "../../../interfaces/index.js";
|
|
2
3
|
import type { Card } from "../../../molecules/card/Card.js";
|
|
3
4
|
import { getComponent } from "../../../registries/components.js";
|
|
4
5
|
import { Form } from "../Form.js";
|
|
5
6
|
|
|
6
7
|
export interface FormPreviewProps {
|
|
7
8
|
form: FormType;
|
|
8
|
-
i18n?:
|
|
9
|
+
i18n?: FormOptions["i18n"];
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
export function FormPreview({ form,
|
|
12
|
+
export function FormPreview({ form, ...props }: FormPreviewProps) {
|
|
13
|
+
const { t } = useI18n(props?.i18n);
|
|
12
14
|
const FCard = getComponent<typeof Card>("Card");
|
|
13
15
|
|
|
14
16
|
return (
|
|
15
17
|
<div className='p-10 bg-gray-500'>
|
|
16
|
-
<FCard label={
|
|
17
|
-
<Form form={form} options={{ i18n }} />
|
|
18
|
+
<FCard label={t(form.title || "")} className={"shadow"}>
|
|
19
|
+
<Form form={form} options={{ i18n: props.i18n }} />
|
|
18
20
|
</FCard>
|
|
19
21
|
</div>
|
|
20
22
|
);
|
|
@@ -2,6 +2,7 @@ import isEqual from "lodash/isEqual";
|
|
|
2
2
|
import noop from "lodash/noop";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
4
|
|
|
5
|
+
import { useI18n } from "../../../hooks/useI18n.js";
|
|
5
6
|
import type { ChangedSubmission, FormOptions, FormType } from "../../../interfaces";
|
|
6
7
|
import { Form } from "../../form/Form";
|
|
7
8
|
import { getFormSettingsSchema } from "./FormSettings.schema";
|
|
@@ -13,7 +14,7 @@ export interface FormSettingsProps {
|
|
|
13
14
|
options?: FormOptions;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
function useFormSettings({ form: formDefinition, onSubmit = noop
|
|
17
|
+
function useFormSettings({ form: formDefinition, onSubmit = noop }: FormSettingsProps) {
|
|
17
18
|
const form = getFormSettingsSchema();
|
|
18
19
|
const [isValid, setIsValid] = useState(true);
|
|
19
20
|
const [submission, setSubmission] = useState(() => formSettingsToSubmission(formDefinition));
|
|
@@ -33,7 +34,6 @@ function useFormSettings({ form: formDefinition, onSubmit = noop, options }: For
|
|
|
33
34
|
}, [formDefinition?._id]);
|
|
34
35
|
|
|
35
36
|
return {
|
|
36
|
-
options,
|
|
37
37
|
form,
|
|
38
38
|
type: formDefinition.type,
|
|
39
39
|
submission,
|
|
@@ -47,16 +47,16 @@ function useFormSettings({ form: formDefinition, onSubmit = noop, options }: For
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export function FormSettings(props: FormSettingsProps) {
|
|
50
|
-
const { form, submission,
|
|
50
|
+
const { form, submission, onChange, onSubmit, isValid } = useFormSettings(props);
|
|
51
51
|
|
|
52
|
-
const
|
|
52
|
+
const { t } = useI18n(props?.options?.i18n);
|
|
53
53
|
|
|
54
54
|
return (
|
|
55
55
|
<div>
|
|
56
|
-
<Form<FormSettingsType> form={form} submission={submission} onChange={onChange} options={options} />
|
|
56
|
+
<Form<FormSettingsType> form={form} submission={submission} onChange={onChange} options={props.options} />
|
|
57
57
|
|
|
58
58
|
<button data-testid='submit' disabled={!isValid} className={"mt-5 btn btn-primary"} onClick={onSubmit} type={"submit"}>
|
|
59
|
-
{
|
|
59
|
+
{t("Save settings")}
|
|
60
60
|
</button>
|
|
61
61
|
</div>
|
|
62
62
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Form } from "@formio/js";
|
|
1
2
|
import { EventEmitter2 } from "eventemitter2";
|
|
2
|
-
import { Form } from "formiojs";
|
|
3
3
|
import { type MutableRefObject, useEffect, useRef, useState } from "react";
|
|
4
4
|
|
|
5
5
|
import type { ChangedSubmission, ComponentType, FormOptions, FormType, JSON, SubmissionType } from "../../interfaces";
|
|
@@ -13,9 +13,8 @@ export interface UseFormProps<Data extends { [key: string]: JSON } = { [key: str
|
|
|
13
13
|
url?: string;
|
|
14
14
|
form?: FormType;
|
|
15
15
|
submission?: SubmissionType<Data>;
|
|
16
|
-
// TODO: once events is typed correctly in @formio/js options, we can remove this override
|
|
17
16
|
options?: FormOptions;
|
|
18
|
-
FormClass?:
|
|
17
|
+
FormClass?: typeof Form;
|
|
19
18
|
onFormReady?: (instance: Webform) => void;
|
|
20
19
|
onPrevPage?: (page: number, submission: SubmissionType<Data>) => void;
|
|
21
20
|
onNextPage?: (page: number, submission: SubmissionType<Data>) => void;
|
|
@@ -3,7 +3,8 @@ import classnames from "classnames";
|
|
|
3
3
|
import noop from "lodash/noop";
|
|
4
4
|
import { useState } from "react";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { useI18n } from "../../../hooks/useI18n.js";
|
|
7
|
+
import { ActionType, type FormOptions } from "../../../interfaces";
|
|
7
8
|
import { Select } from "../../../molecules/forms/select/Select";
|
|
8
9
|
import { Table, type TableProps } from "../../../molecules/table/Table";
|
|
9
10
|
import { iconClass } from "../../../utils/iconClass";
|
|
@@ -11,15 +12,16 @@ import { iconClass } from "../../../utils/iconClass";
|
|
|
11
12
|
export type ActionsTableProps = Omit<TableProps<ActionType>, "columns"> & {
|
|
12
13
|
onAddAction?: (actionName: string) => void;
|
|
13
14
|
availableActions?: { label: string; value: string }[];
|
|
15
|
+
i18n?: FormOptions["i18n"];
|
|
14
16
|
};
|
|
15
17
|
|
|
16
18
|
export function ActionsTable({ availableActions = [], onAddAction = noop, ...props }: ActionsTableProps) {
|
|
17
|
-
const {
|
|
19
|
+
const { t } = useI18n(props.i18n);
|
|
18
20
|
const [currentAction, setAction] = useState("");
|
|
19
21
|
|
|
20
22
|
const columns: ColumnDef<ActionType>[] = [
|
|
21
23
|
{
|
|
22
|
-
header:
|
|
24
|
+
header: t("Action"),
|
|
23
25
|
accessorKey: "title"
|
|
24
26
|
}
|
|
25
27
|
];
|
|
@@ -31,7 +33,7 @@ export function ActionsTable({ availableActions = [], onAddAction = noop, ...pro
|
|
|
31
33
|
data-testid={"action-table-select"}
|
|
32
34
|
name={"actions"}
|
|
33
35
|
value={currentAction}
|
|
34
|
-
options={[{ label:
|
|
36
|
+
options={[{ label: t("Select an action"), value: "" }].concat(availableActions)}
|
|
35
37
|
onChange={(_, action) => setAction(action)}
|
|
36
38
|
/>
|
|
37
39
|
<div className={"pl-3"}>
|
|
@@ -42,7 +44,7 @@ export function ActionsTable({ availableActions = [], onAddAction = noop, ...pro
|
|
|
42
44
|
onClick={() => currentAction && onAddAction(currentAction)}
|
|
43
45
|
type={"submit"}
|
|
44
46
|
>
|
|
45
|
-
<i className={classnames(iconClass(undefined, "plus"), "mr-1")} /> {
|
|
47
|
+
<i className={classnames(iconClass(undefined, "plus"), "mr-1")} /> {t("Add action")}
|
|
46
48
|
</button>
|
|
47
49
|
</div>
|
|
48
50
|
</div>
|
|
@@ -2,6 +2,7 @@ import "./components/FormsCell.js";
|
|
|
2
2
|
|
|
3
3
|
import { ColumnDef } from "@tanstack/react-table";
|
|
4
4
|
|
|
5
|
+
import { useI18n } from "../../../hooks/useI18n.js";
|
|
5
6
|
import type { FormType } from "../../../interfaces";
|
|
6
7
|
import { Table, TableProps } from "../../../molecules/table/Table";
|
|
7
8
|
import { getComponent } from "../../../registries/components.js";
|
|
@@ -11,15 +12,15 @@ export type FormsTableProps = Omit<TableProps<FormType>, "columns"> & {
|
|
|
11
12
|
tags?: { label: string; value: string }[];
|
|
12
13
|
};
|
|
13
14
|
|
|
14
|
-
export function FormsTable({ ...props }: FormsTableProps) {
|
|
15
|
-
const {
|
|
15
|
+
export function FormsTable({ tags, ...props }: FormsTableProps) {
|
|
16
|
+
const { t } = useI18n(props.i18n);
|
|
16
17
|
const Cell = getComponent<typeof FormsCell>("FormsCell");
|
|
17
18
|
|
|
18
19
|
const columns: ColumnDef<any>[] = [
|
|
19
20
|
{
|
|
20
|
-
header:
|
|
21
|
+
header: t("Title"),
|
|
21
22
|
accessorKey: "title",
|
|
22
|
-
cell: (context) => <Cell {...context} i18n={
|
|
23
|
+
cell: (context) => <Cell {...context} i18n={t} />,
|
|
23
24
|
meta: {
|
|
24
25
|
cellProps: {
|
|
25
26
|
colSpan: 2
|
|
@@ -27,7 +28,7 @@ export function FormsTable({ ...props }: FormsTableProps) {
|
|
|
27
28
|
}
|
|
28
29
|
},
|
|
29
30
|
{
|
|
30
|
-
header:
|
|
31
|
+
header: t("Tags"),
|
|
31
32
|
accessorKey: "tags",
|
|
32
33
|
meta: {
|
|
33
34
|
cellProps: {
|
|
@@ -78,7 +78,7 @@ export default {
|
|
|
78
78
|
},
|
|
79
79
|
args: {
|
|
80
80
|
form: FormSchema as any,
|
|
81
|
-
data: formSubmissions,
|
|
81
|
+
data: formSubmissions as any[],
|
|
82
82
|
operations: [
|
|
83
83
|
{
|
|
84
84
|
title: "Edit",
|
|
@@ -125,18 +125,15 @@ export const Empty: Story = {
|
|
|
125
125
|
*/
|
|
126
126
|
export const Translated: Story = {
|
|
127
127
|
args: {
|
|
128
|
-
i18n:
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
Delete: "Supprimer"
|
|
138
|
-
};
|
|
139
|
-
return translations[key] || key;
|
|
128
|
+
i18n: {
|
|
129
|
+
"Search...": "Rechercher...",
|
|
130
|
+
"No results found": "Aucun résultat trouvé",
|
|
131
|
+
"Loading...": "Chargement...",
|
|
132
|
+
Page: "Page",
|
|
133
|
+
of: "sur",
|
|
134
|
+
rows: "lignes",
|
|
135
|
+
Edit: "Éditer",
|
|
136
|
+
Delete: "Supprimer"
|
|
140
137
|
}
|
|
141
138
|
}
|
|
142
139
|
};
|
|
@@ -175,7 +175,7 @@ export const Usage: Story = {
|
|
|
175
175
|
title: "Anonymous"
|
|
176
176
|
}
|
|
177
177
|
],
|
|
178
|
-
i18n:
|
|
178
|
+
i18n: {},
|
|
179
179
|
onAction: () => console.log("Action triggered")
|
|
180
180
|
}
|
|
181
181
|
};
|
|
@@ -203,21 +203,18 @@ export const Translated: Story = {
|
|
|
203
203
|
title: "Anonymous"
|
|
204
204
|
}
|
|
205
205
|
],
|
|
206
|
-
i18n:
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
Submit: "Soumettre"
|
|
219
|
-
};
|
|
220
|
-
return translations[key] || key;
|
|
206
|
+
i18n: {
|
|
207
|
+
Edit: "Éditer",
|
|
208
|
+
Data: "Données",
|
|
209
|
+
Preview: "Aperçu",
|
|
210
|
+
Actions: "Actions",
|
|
211
|
+
Access: "Accès",
|
|
212
|
+
Export: "Exporter",
|
|
213
|
+
Settings: "Paramètres",
|
|
214
|
+
"Form with First Name": "Formulaire avec prénom",
|
|
215
|
+
"First name": "Prénom",
|
|
216
|
+
"Last name": "Nom de famille",
|
|
217
|
+
Submit: "Soumettre"
|
|
221
218
|
},
|
|
222
219
|
onAction: () => console.log("Action triggered")
|
|
223
220
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useI18n } from "../../hooks/useI18n.js";
|
|
2
|
+
import type { FormOptions, FormType, JSON, PermissionsResolver } from "../../interfaces/index.js";
|
|
2
3
|
import type { Tab as DefaultTab } from "../../molecules/tabs/Tab.js";
|
|
3
4
|
import type { TabList as DefaultTabList } from "../../molecules/tabs/TabList.js";
|
|
4
5
|
import type { TabPanel as DefaultTabPanel } from "../../molecules/tabs/TabPanel.js";
|
|
@@ -19,7 +20,7 @@ export type FormViewsProps<Data extends { [key: string]: JSON } = { [key: string
|
|
|
19
20
|
availableActions: ActionsTableProps["availableActions"];
|
|
20
21
|
actions: ActionsTableProps["data"];
|
|
21
22
|
roles?: FormAccessProps["roles"];
|
|
22
|
-
i18n?:
|
|
23
|
+
i18n?: FormOptions["i18n"];
|
|
23
24
|
onAction: () => void;
|
|
24
25
|
permissionsResolver?: PermissionsResolver<Data>;
|
|
25
26
|
};
|
|
@@ -71,8 +72,9 @@ export function FormViews<Data extends { [key: string]: JSON } = { [key: string]
|
|
|
71
72
|
actions,
|
|
72
73
|
permissionsResolver,
|
|
73
74
|
submissions,
|
|
74
|
-
|
|
75
|
+
...props
|
|
75
76
|
}: FormViewsProps<Data>) {
|
|
77
|
+
const { t } = useI18n(props.i18n);
|
|
76
78
|
const Tabs = getComponent<typeof DefaultTabs>("Tabs");
|
|
77
79
|
const TabList = getComponent<typeof DefaultTabList>("TabList");
|
|
78
80
|
const Tab = getComponent<typeof DefaultTab>("Tab");
|
|
@@ -85,42 +87,42 @@ export function FormViews<Data extends { [key: string]: JSON } = { [key: string]
|
|
|
85
87
|
<Tabs>
|
|
86
88
|
<TabList>
|
|
87
89
|
<Tab value={0} icon='edit'>
|
|
88
|
-
{
|
|
90
|
+
{t("Edit")}
|
|
89
91
|
</Tab>
|
|
90
92
|
<Tab value={1} icon='data'>
|
|
91
|
-
{
|
|
93
|
+
{t("Data")}
|
|
92
94
|
</Tab>
|
|
93
95
|
<Tab value={2} icon='test-tube'>
|
|
94
|
-
{
|
|
96
|
+
{t("Preview")}
|
|
95
97
|
</Tab>
|
|
96
98
|
<Tab value={3} icon='paper-plane'>
|
|
97
|
-
{
|
|
99
|
+
{t("Actions")}
|
|
98
100
|
</Tab>
|
|
99
101
|
<Tab value={4} icon='lock'>
|
|
100
|
-
{
|
|
102
|
+
{t("Access")}
|
|
101
103
|
</Tab>
|
|
102
104
|
<Tab value={5} icon='download'>
|
|
103
|
-
{
|
|
105
|
+
{t("Export")}
|
|
104
106
|
</Tab>
|
|
105
107
|
<Tab value={6} icon='cog'>
|
|
106
|
-
{
|
|
108
|
+
{t("Settings")}
|
|
107
109
|
</Tab>
|
|
108
110
|
</TabList>
|
|
109
111
|
<TabsBody>
|
|
110
112
|
<TabPanel value={0} className='p-3 border-l-1 border-b-1 border-r-1 border-gray-300'>
|
|
111
|
-
<FormEdit form={form}
|
|
113
|
+
<FormEdit form={form} />
|
|
112
114
|
</TabPanel>
|
|
113
115
|
<TabPanel value={1}>
|
|
114
116
|
<SubmissionsTable<Data>
|
|
115
117
|
className={"border-top-0"}
|
|
116
118
|
form={form as FormType}
|
|
117
119
|
data={submissions}
|
|
118
|
-
i18n={i18n}
|
|
120
|
+
i18n={props.i18n}
|
|
119
121
|
operations={submissionsOperations}
|
|
120
122
|
/>
|
|
121
123
|
</TabPanel>
|
|
122
124
|
<TabPanel value={2}>
|
|
123
|
-
<FormPreview form={form as FormType} i18n={i18n} />
|
|
125
|
+
<FormPreview form={form as FormType} i18n={props.i18n} />
|
|
124
126
|
</TabPanel>
|
|
125
127
|
<TabPanel value={3}>
|
|
126
128
|
<ActionsTable
|
|
@@ -128,14 +130,14 @@ export function FormViews<Data extends { [key: string]: JSON } = { [key: string]
|
|
|
128
130
|
availableActions={availableActions}
|
|
129
131
|
data={actions}
|
|
130
132
|
operations={actionsOperations as any}
|
|
131
|
-
i18n={i18n}
|
|
133
|
+
i18n={props.i18n}
|
|
132
134
|
/>
|
|
133
135
|
</TabPanel>
|
|
134
136
|
<TabPanel value={4} className='pt-3'>
|
|
135
|
-
<FormAccess form={form as FormType} roles={roles} options={
|
|
137
|
+
<FormAccess form={form as FormType} roles={roles} options={props} />
|
|
136
138
|
</TabPanel>
|
|
137
139
|
<TabPanel value={5} className='pt-3'>
|
|
138
|
-
<FormExport i18n={i18n} />
|
|
140
|
+
<FormExport i18n={props.i18n} />
|
|
139
141
|
</TabPanel>
|
|
140
142
|
<TabPanel value={6} className='p-3 border-l-1 border-b-1 border-r-1 border-gray-300'>
|
|
141
143
|
<FormSettings form={form as FormType} options={{}} />
|
package/src/utils/iconClass.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const { Templates } = formio;
|
|
1
|
+
import { Templates } from "@formio/js";
|
|
4
2
|
|
|
5
3
|
export function iconClass(iconset: string | undefined, name: string, spinning?: boolean): string {
|
|
6
4
|
return Templates.current.iconClass(iconset || Templates.current.defaultIconset, name, spinning);
|
package/dist/typings.d.js
DELETED
package/dist/typings.d.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typings.d.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/src/typings.d.ts
DELETED