@tsed/react-formio 3.0.0-alpha.11 → 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/atoms/icon/Icon.js.map +1 -1
- package/dist/chunks/_commonjsHelpers.js +30 -3
- package/dist/chunks/_commonjsHelpers.js.map +1 -1
- package/dist/chunks/index.js +33 -30
- package/dist/chunks/index.js.map +1 -1
- package/dist/chunks/index.module.js +16 -16
- package/dist/chunks/index.module.js.map +1 -1
- package/dist/chunks/index2.js +56953 -0
- package/dist/chunks/index2.js.map +1 -0
- package/dist/chunks/react-select-animated.esm.js +1204 -1101
- package/dist/chunks/react-select-animated.esm.js.map +1 -1
- 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/keyboard.constants.js.map +1 -1
- 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/hooks/useKeyboardControls.js.map +1 -1
- package/dist/hooks/useTooltip.js.map +1 -1
- 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/alert/Alert.js.map +1 -1
- package/dist/molecules/button/Button.js +17 -20
- package/dist/molecules/button/Button.js.map +1 -1
- package/dist/molecules/card/Card.js.map +1 -1
- package/dist/molecules/forms/form-control/FormControl.js.map +1 -1
- package/dist/molecules/forms/input-tags/InputTags.js.map +1 -1
- package/dist/molecules/forms/input-tags/components/ChoicesTags.d.ts +19 -19
- package/dist/molecules/forms/input-tags/components/ChoicesTags.js +32 -32
- package/dist/molecules/forms/input-tags/components/ChoicesTags.js.map +1 -1
- package/dist/molecules/forms/input-tags/components/ReactTags.js +289 -300
- package/dist/molecules/forms/input-tags/components/ReactTags.js.map +1 -1
- package/dist/molecules/forms/input-text/InputText.js +3 -3
- package/dist/molecules/forms/input-text/InputText.js.map +1 -1
- package/dist/molecules/forms/select/Select.js.map +1 -1
- package/dist/molecules/forms/select/components/ChoicesSelect.js +71 -73
- package/dist/molecules/forms/select/components/ChoicesSelect.js.map +1 -1
- package/dist/molecules/forms/select/components/HtmlSelect.js.map +1 -1
- package/dist/molecules/forms/select/components/ReactSelect.js +13 -14
- package/dist/molecules/forms/select/components/ReactSelect.js.map +1 -1
- package/dist/molecules/forms/select/components/choices.template.js +2340 -2257
- package/dist/molecules/forms/select/components/choices.template.js.map +1 -1
- package/dist/molecules/forms/select/hooks/useOptions.js.map +1 -1
- package/dist/molecules/loader/Loader.js.map +1 -1
- package/dist/molecules/modal/Modal.js +23 -24
- package/dist/molecules/modal/Modal.js.map +1 -1
- package/dist/molecules/pagination/Pagination.d.ts +2 -1
- package/dist/molecules/pagination/Pagination.js +29 -29
- package/dist/molecules/pagination/Pagination.js.map +1 -1
- package/dist/molecules/pagination/PaginationButton.js.map +1 -1
- package/dist/molecules/pagination/utils/getPageNumbers.js.map +1 -1
- package/dist/molecules/table/Table.js +35 -41
- package/dist/molecules/table/Table.js.map +1 -1
- package/dist/molecules/table/components/DefaultArrowSort.js.map +1 -1
- package/dist/molecules/table/components/DefaultCell.js.map +1 -1
- package/dist/molecules/table/components/DefaultCellFooter.js.map +1 -1
- package/dist/molecules/table/components/DefaultCellHeader.js.map +1 -1
- package/dist/molecules/table/components/DefaultCellOperations.js +10 -10
- package/dist/molecules/table/components/DefaultCellOperations.js.map +1 -1
- package/dist/molecules/table/components/DefaultFilter.js.map +1 -1
- package/dist/molecules/table/components/DefaultOperationButton.js +1 -1
- package/dist/molecules/table/components/DefaultOperationButton.js.map +1 -1
- package/dist/molecules/table/filters/RangeFilter.js +23 -24
- package/dist/molecules/table/filters/RangeFilter.js.map +1 -1
- package/dist/molecules/table/filters/SelectFilter.js +11 -13
- package/dist/molecules/table/filters/SelectFilter.js.map +1 -1
- package/dist/molecules/table/filters/TextFieldFilter.js.map +1 -1
- package/dist/molecules/table/hooks/useTable.d.ts +3 -3
- package/dist/molecules/table/hooks/useTable.js +17 -16
- package/dist/molecules/table/hooks/useTable.js.map +1 -1
- package/dist/molecules/table/hooks/useUniqValues.js.map +1 -1
- package/dist/molecules/table/utils/mapFormToColumns.js +21 -22
- package/dist/molecules/table/utils/mapFormToColumns.js.map +1 -1
- package/dist/molecules/tabs/Tab.js +36 -37
- package/dist/molecules/tabs/Tab.js.map +1 -1
- package/dist/molecules/tabs/TabList.js +9 -10
- package/dist/molecules/tabs/TabList.js.map +1 -1
- package/dist/molecules/tabs/TabPanel.js.map +1 -1
- package/dist/molecules/tabs/Tabs.js.map +1 -1
- package/dist/molecules/tabs/TabsBody.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/molecules/tabs/context/TabControl.js.map +1 -1
- package/dist/molecules/tabs/hooks/tabControl.js.map +1 -1
- package/dist/organisms/form/Form.js.map +1 -1
- package/dist/organisms/form/access/FormAccess.js +41 -41
- package/dist/organisms/form/access/FormAccess.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/access/FormAccess.utils.js +2 -2
- package/dist/organisms/form/access/FormAccess.utils.js.map +1 -1
- package/dist/organisms/form/actions/FormAction.js +15 -13
- package/dist/organisms/form/actions/FormAction.js.map +1 -1
- package/dist/organisms/form/builder/FormBuilder.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/FormEdit.reducer.js.map +1 -1
- package/dist/organisms/form/builder/FormEditCtas.d.ts +2 -2
- package/dist/organisms/form/builder/FormEditCtas.js +36 -35
- package/dist/organisms/form/builder/FormEditCtas.js.map +1 -1
- package/dist/organisms/form/builder/FormParameters.js.map +1 -1
- package/dist/organisms/form/builder/useFormBuilder.d.ts +4 -4
- package/dist/organisms/form/builder/useFormBuilder.js +36 -33
- package/dist/organisms/form/builder/useFormBuilder.js.map +1 -1
- package/dist/organisms/form/builder/useFormEdit.d.ts +1 -1
- package/dist/organisms/form/builder/useFormEdit.js +17 -17
- package/dist/organisms/form/builder/useFormEdit.js.map +1 -1
- package/dist/organisms/form/exports/FormExport.d.ts +3 -2
- package/dist/organisms/form/exports/FormExport.js +23 -22
- 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 +28 -28
- package/dist/organisms/form/settings/FormSettings.js.map +1 -1
- package/dist/organisms/form/settings/FormSettings.schema.js.map +1 -1
- package/dist/organisms/form/settings/FormSettings.utils.js.map +1 -1
- package/dist/organisms/form/useForm.d.ts +2 -1
- package/dist/organisms/form/useForm.js +664 -661
- package/dist/organisms/form/useForm.js.map +1 -1
- package/dist/organisms/modal/RemoveModal.js +16 -17
- package/dist/organisms/modal/RemoveModal.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/table/forms/components/FormsCell.js.map +1 -1
- package/dist/organisms/table/submissions/SubmissionsTable.js.map +1 -1
- 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/registries/components.js.map +1 -1
- package/dist/utils/getEventValue.js.map +1 -1
- package/dist/utils/iconClass.js +4 -5
- package/dist/utils/iconClass.js.map +1 -1
- package/dist/utils/mapPagination.js.map +1 -1
- package/dist/utils/stopPropagationWrapper.js.map +1 -1
- package/package.json +7 -7
- package/src/all.ts +34 -0
- package/src/atoms/icon/Icon.stories.tsx +1 -1
- 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/button/Button.stories.tsx +1 -1
- package/src/molecules/forms/form-control/FormControl.spec.tsx +5 -2
- package/src/molecules/forms/form-control/FormControl.stories.tsx +1 -1
- package/src/molecules/forms/input-tags/components/ChoicesTags.stories.tsx +1 -1
- package/src/molecules/forms/input-tags/components/ChoicesTags.tsx +4 -4
- package/src/molecules/forms/input-tags/components/ReactTags.stories.tsx +1 -1
- package/src/molecules/forms/input-text/InputText.stories.tsx +2 -2
- package/src/molecules/forms/select/components/ChoicesSelect.stories.tsx +2 -2
- package/src/molecules/forms/select/components/ChoicesSelect.tsx +2 -2
- package/src/molecules/forms/select/components/HtmlSelect.stories.tsx +2 -2
- package/src/molecules/forms/select/components/ReactSelect.stories.tsx +2 -2
- package/src/molecules/loader/Loader.stories.tsx +1 -1
- package/src/molecules/modal/Modal.stories.tsx +1 -1
- package/src/molecules/pagination/Pagination.stories.tsx +1 -1
- package/src/molecules/pagination/Pagination.tsx +10 -10
- package/src/molecules/table/Table.stories.tsx +8 -8
- package/src/molecules/table/Table.tsx +1 -1
- package/src/molecules/table/filters/SelectFilter.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/Tabs.stories.tsx +2 -2
- package/src/molecules/tabs/TabsLegacy.stories.tsx +2 -2
- package/src/molecules/tabs/TabsLegacy.tsx +5 -3
- package/src/organisms/form/Form.stories.tsx +98 -118
- package/src/organisms/form/access/FormAccess.schema.ts +1 -0
- package/src/organisms/form/access/FormAccess.stories.tsx +5 -3
- package/src/organisms/form/actions/FormAction.stories.tsx +6 -2
- package/src/organisms/form/actions/FormAction.tsx +2 -2
- package/src/organisms/form/builder/FormBuilder.stories.tsx +4 -1
- package/src/organisms/form/builder/FormEdit.stories.tsx +11 -7
- 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 +12 -7
- package/src/organisms/form/exports/FormExport.stories.tsx +9 -12
- package/src/organisms/form/exports/FormExport.tsx +12 -9
- package/src/organisms/form/preview/FormPreview.stories.tsx +7 -10
- 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/modal/RemoveModal.stories.tsx +1 -1
- package/src/organisms/table/actions/ActionsTable.stories.tsx +2 -2
- 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 +11 -14
- package/src/organisms/views/FormViews.stories.tsx +14 -17
- package/src/organisms/views/FormViews.tsx +18 -16
- package/src/utils/iconClass.ts +1 -3
- package/vite.config.mts +2 -2
- package/dist/typings.d.js +0 -2
- package/dist/typings.d.js.map +0 -1
- package/src/typings.d.ts +0 -3
- package/tsconfig.app.json +0 -11
- package/tsconfig.json +0 -21
- package/tsconfig.node.json +0 -13
- package/tsconfig.spec.json +0 -14
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./all.js";
|
|
2
2
|
|
|
3
|
-
import { Meta, StoryObj } from "@storybook/react";
|
|
4
|
-
import { expect, fn, userEvent, waitFor, within } from "
|
|
3
|
+
import { Meta, StoryObj } from "@storybook/react-vite";
|
|
4
|
+
import { expect, fn, userEvent, waitFor, within } from "storybook/test";
|
|
5
5
|
|
|
6
6
|
import { Icon } from "../../atoms/icon/Icon.js";
|
|
7
7
|
import { Button } from "../button/Button.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./all.js";
|
|
2
2
|
|
|
3
|
-
import { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { Meta, StoryObj } from "@storybook/react-vite";
|
|
4
4
|
|
|
5
5
|
import { TabsLegacy } from "./TabsLegacy.js";
|
|
6
6
|
|
|
@@ -37,7 +37,7 @@ export default {
|
|
|
37
37
|
render: (args: any) => {
|
|
38
38
|
return (
|
|
39
39
|
<div className={"border-gray-300 border-1 shadow"}>
|
|
40
|
-
<TabsLegacy {...args}
|
|
40
|
+
<TabsLegacy {...args} />
|
|
41
41
|
</div>
|
|
42
42
|
);
|
|
43
43
|
}
|
|
@@ -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
|
})}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import {
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { delay, http, HttpResponse } from "msw";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
|
+
import { expect, fn, userEvent, waitFor, within } from "storybook/test";
|
|
4
5
|
|
|
5
6
|
import { SubmissionType } from "../../interfaces";
|
|
6
7
|
import { InputText } from "../../molecules/forms/input-text/InputText";
|
|
@@ -9,12 +10,6 @@ import formFirstname from "../__fixtures__/form-firstname.fixture.json";
|
|
|
9
10
|
import { useEditForm } from "../__fixtures__/useEditForm";
|
|
10
11
|
import { Form } from "./Form";
|
|
11
12
|
|
|
12
|
-
async function delay(number: number) {
|
|
13
|
-
return new Promise((resolve) => {
|
|
14
|
-
setTimeout(resolve, number);
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
|
|
18
13
|
/**
|
|
19
14
|
* The form component is the primary component of the system. It is what takes the form definition (json) and renders the
|
|
20
15
|
* form into html. There are multiple ways to send the form to the Form component. The two main ways are to pass the `src`
|
|
@@ -332,15 +327,15 @@ export const WithOnSubmit: Story = {
|
|
|
332
327
|
expect(firstnameInput).toHaveValue("John");
|
|
333
328
|
expect(lastNameInput).toHaveValue("Doe");
|
|
334
329
|
|
|
335
|
-
userEvent.clear(firstnameInput);
|
|
336
|
-
userEvent.type(firstnameInput, "Jane", { delay: 100 });
|
|
330
|
+
await userEvent.clear(firstnameInput);
|
|
331
|
+
await userEvent.type(firstnameInput, "Jane", { delay: 100 });
|
|
337
332
|
|
|
338
333
|
await waitFor(() => {
|
|
339
334
|
expect(firstnameInput).toHaveValue("Jane");
|
|
340
335
|
});
|
|
341
336
|
|
|
342
|
-
userEvent.clear(lastNameInput);
|
|
343
|
-
userEvent.type(lastNameInput, "Smith", { delay: 100 });
|
|
337
|
+
await userEvent.clear(lastNameInput);
|
|
338
|
+
await userEvent.type(lastNameInput, "Smith", { delay: 100 });
|
|
344
339
|
|
|
345
340
|
await waitFor(() => {
|
|
346
341
|
expect(lastNameInput).toHaveValue("Smith");
|
|
@@ -397,42 +392,20 @@ export const WithOnSubmit: Story = {
|
|
|
397
392
|
* Form with custom validation hook
|
|
398
393
|
*/
|
|
399
394
|
export const CustomValidation: Story = {
|
|
400
|
-
parameters: {
|
|
401
|
-
mockData: [
|
|
402
|
-
{
|
|
403
|
-
url: "https://test.dev/todos/1",
|
|
404
|
-
method: "GET",
|
|
405
|
-
status: 500,
|
|
406
|
-
response: {
|
|
407
|
-
message: "My custom message about this field",
|
|
408
|
-
type: "custom",
|
|
409
|
-
path: ["firstName"],
|
|
410
|
-
level: "error"
|
|
411
|
-
},
|
|
412
|
-
delay: 800
|
|
413
|
-
}
|
|
414
|
-
]
|
|
415
|
-
},
|
|
395
|
+
parameters: {},
|
|
416
396
|
args: {
|
|
417
397
|
form: formFirstname as never,
|
|
418
398
|
options: {
|
|
419
399
|
hooks: {
|
|
420
400
|
async customValidation(submission: SubmissionType, callback: (error: any) => void) {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
const responseData = await response.json();
|
|
430
|
-
|
|
431
|
-
if (response.ok) {
|
|
432
|
-
callback(null);
|
|
433
|
-
} else {
|
|
434
|
-
callback(responseData);
|
|
435
|
-
}
|
|
401
|
+
setTimeout(() => {
|
|
402
|
+
callback({
|
|
403
|
+
message: "My custom message about this field",
|
|
404
|
+
type: "custom",
|
|
405
|
+
path: ["firstName"],
|
|
406
|
+
level: "error"
|
|
407
|
+
});
|
|
408
|
+
}, 200);
|
|
436
409
|
}
|
|
437
410
|
}
|
|
438
411
|
}
|
|
@@ -451,15 +424,15 @@ export const CustomValidation: Story = {
|
|
|
451
424
|
let firstnameInput = canvas.getByRole("textbox", { name: "First name" });
|
|
452
425
|
let lastNameInput = canvas.getByRole("textbox", { name: "Last name" });
|
|
453
426
|
|
|
454
|
-
userEvent.clear(firstnameInput);
|
|
455
|
-
userEvent.type(firstnameInput, "Jane", { delay: 100 });
|
|
427
|
+
await userEvent.clear(firstnameInput);
|
|
428
|
+
await userEvent.type(firstnameInput, "Jane", { delay: 100 });
|
|
456
429
|
|
|
457
430
|
await waitFor(() => {
|
|
458
431
|
expect(firstnameInput).toHaveValue("Jane");
|
|
459
432
|
});
|
|
460
433
|
|
|
461
|
-
userEvent.clear(lastNameInput);
|
|
462
|
-
userEvent.type(lastNameInput, "Smith", { delay: 100 });
|
|
434
|
+
await userEvent.clear(lastNameInput);
|
|
435
|
+
await userEvent.type(lastNameInput, "Smith", { delay: 100 });
|
|
463
436
|
|
|
464
437
|
await waitFor(() => {
|
|
465
438
|
expect(lastNameInput).toHaveValue("Smith");
|
|
@@ -467,7 +440,7 @@ export const CustomValidation: Story = {
|
|
|
467
440
|
|
|
468
441
|
let submitButton = canvas.getByRole("button", { name: "Submit" });
|
|
469
442
|
|
|
470
|
-
userEvent.click(submitButton);
|
|
443
|
+
await userEvent.click(submitButton);
|
|
471
444
|
|
|
472
445
|
await waitFor(async () => {
|
|
473
446
|
expect(canvas.getByText("Please fix the following errors before submitting.")).toBeInTheDocument();
|
|
@@ -490,35 +463,29 @@ export const FetchSubmissionWithCustomAction: Story = {
|
|
|
490
463
|
}
|
|
491
464
|
},
|
|
492
465
|
parameters: {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
firstName: "John",
|
|
517
|
-
lastName: "Doe"
|
|
518
|
-
},
|
|
519
|
-
delay: 800
|
|
520
|
-
}
|
|
521
|
-
]
|
|
466
|
+
chromatic: { disableSnapshot: false },
|
|
467
|
+
msw: {
|
|
468
|
+
handlers: [
|
|
469
|
+
http.get("https://local.dev/form/Test", async () => {
|
|
470
|
+
await delay(200);
|
|
471
|
+
return HttpResponse.json(JSON.parse(JSON.stringify(formFirstname)));
|
|
472
|
+
}),
|
|
473
|
+
http.get("https://local.dev/form/Test/submissions/1", async () => {
|
|
474
|
+
await delay(300);
|
|
475
|
+
return HttpResponse.json({
|
|
476
|
+
firstName: "Jane",
|
|
477
|
+
lastName: "Doe"
|
|
478
|
+
});
|
|
479
|
+
}),
|
|
480
|
+
http.put("https://local.dev/form/Test/submissions/1", async () => {
|
|
481
|
+
await delay(800);
|
|
482
|
+
return HttpResponse.json({
|
|
483
|
+
firstName: "Jane",
|
|
484
|
+
lastName: "Doe"
|
|
485
|
+
});
|
|
486
|
+
})
|
|
487
|
+
]
|
|
488
|
+
}
|
|
522
489
|
},
|
|
523
490
|
render(args) {
|
|
524
491
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -559,18 +526,25 @@ export const FetchSubmissionWithCustomAction: Story = {
|
|
|
559
526
|
expect(canvas.getByTestId("formio-container")).toHaveClass("formio-form-ready");
|
|
560
527
|
});
|
|
561
528
|
|
|
529
|
+
await delay(200);
|
|
530
|
+
|
|
562
531
|
let firstnameInput = canvas.getByRole("textbox", { name: "First name" });
|
|
563
532
|
let lastNameInput = canvas.getByRole("textbox", { name: "Last name" });
|
|
564
533
|
|
|
565
|
-
userEvent.clear(firstnameInput);
|
|
566
|
-
|
|
534
|
+
await userEvent.clear(firstnameInput);
|
|
535
|
+
|
|
536
|
+
await waitFor(() => {
|
|
537
|
+
expect(firstnameInput).toHaveValue("");
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
await userEvent.type(firstnameInput, "Jane", { delay: 100 });
|
|
567
541
|
|
|
568
542
|
await waitFor(() => {
|
|
569
543
|
expect(firstnameInput).toHaveValue("Jane");
|
|
570
544
|
});
|
|
571
545
|
|
|
572
|
-
userEvent.clear(lastNameInput);
|
|
573
|
-
userEvent.type(lastNameInput, "Smith", { delay: 100 });
|
|
546
|
+
await userEvent.clear(lastNameInput);
|
|
547
|
+
await userEvent.type(lastNameInput, "Smith", { delay: 100 });
|
|
574
548
|
|
|
575
549
|
await waitFor(() => {
|
|
576
550
|
expect(lastNameInput).toHaveValue("Smith");
|
|
@@ -578,7 +552,7 @@ export const FetchSubmissionWithCustomAction: Story = {
|
|
|
578
552
|
|
|
579
553
|
let submitButton = canvas.getByRole("button", { name: "Submit" });
|
|
580
554
|
|
|
581
|
-
userEvent.click(submitButton);
|
|
555
|
+
await userEvent.click(submitButton);
|
|
582
556
|
|
|
583
557
|
await delay(1000);
|
|
584
558
|
|
|
@@ -597,37 +571,36 @@ export const ErrorOnSubmitServer: Story = {
|
|
|
597
571
|
}
|
|
598
572
|
},
|
|
599
573
|
parameters: {
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
]
|
|
574
|
+
chromatic: { disableSnapshot: false },
|
|
575
|
+
msw: {
|
|
576
|
+
handlers: [
|
|
577
|
+
http.get("https://local.dev/form/Test2", async () => {
|
|
578
|
+
await delay(200);
|
|
579
|
+
return HttpResponse.json(JSON.parse(JSON.stringify(formFirstname)));
|
|
580
|
+
}),
|
|
581
|
+
http.get("https://local.dev/form/Test2/submissions/2", async () => {
|
|
582
|
+
await delay(300);
|
|
583
|
+
return HttpResponse.json({
|
|
584
|
+
firstName: "John",
|
|
585
|
+
lastName: "Doe"
|
|
586
|
+
});
|
|
587
|
+
}),
|
|
588
|
+
http.put("https://local.dev/form/Test2/submissions/2", async () => {
|
|
589
|
+
await delay(800);
|
|
590
|
+
return HttpResponse.json(
|
|
591
|
+
{
|
|
592
|
+
message: "My custom message about this field",
|
|
593
|
+
type: "custom",
|
|
594
|
+
path: ["firstName"],
|
|
595
|
+
level: "error"
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
status: 400
|
|
599
|
+
}
|
|
600
|
+
);
|
|
601
|
+
})
|
|
602
|
+
]
|
|
603
|
+
}
|
|
631
604
|
},
|
|
632
605
|
render(args) {
|
|
633
606
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -668,18 +641,25 @@ export const ErrorOnSubmitServer: Story = {
|
|
|
668
641
|
expect(canvas.getByTestId("formio-container")).toHaveClass("formio-form-ready");
|
|
669
642
|
});
|
|
670
643
|
|
|
644
|
+
await delay(200);
|
|
645
|
+
|
|
671
646
|
let firstnameInput = canvas.getByRole("textbox", { name: "First name" });
|
|
672
647
|
let lastNameInput = canvas.getByRole("textbox", { name: "Last name" });
|
|
673
648
|
|
|
674
|
-
userEvent.clear(firstnameInput);
|
|
675
|
-
|
|
649
|
+
await userEvent.clear(firstnameInput);
|
|
650
|
+
|
|
651
|
+
await waitFor(() => {
|
|
652
|
+
expect(firstnameInput).toHaveValue("");
|
|
653
|
+
});
|
|
654
|
+
|
|
655
|
+
await userEvent.type(firstnameInput, "Jane", { delay: 100 });
|
|
676
656
|
|
|
677
657
|
await waitFor(() => {
|
|
678
658
|
expect(firstnameInput).toHaveValue("Jane");
|
|
679
659
|
});
|
|
680
660
|
|
|
681
|
-
userEvent.clear(lastNameInput);
|
|
682
|
-
userEvent.type(lastNameInput, "Smith", { delay: 100 });
|
|
661
|
+
await userEvent.clear(lastNameInput);
|
|
662
|
+
await userEvent.type(lastNameInput, "Smith", { delay: 100 });
|
|
683
663
|
|
|
684
664
|
await waitFor(() => {
|
|
685
665
|
expect(lastNameInput).toHaveValue("Smith");
|
|
@@ -687,7 +667,7 @@ export const ErrorOnSubmitServer: Story = {
|
|
|
687
667
|
|
|
688
668
|
let submitButton = canvas.getByRole("button", { name: "Submit" });
|
|
689
669
|
|
|
690
|
-
userEvent.click(submitButton);
|
|
670
|
+
await userEvent.click(submitButton);
|
|
691
671
|
|
|
692
672
|
await delay(1000);
|
|
693
673
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import { expect, fn, userEvent, within } from "
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { expect, fn, userEvent, within } from "storybook/test";
|
|
3
3
|
|
|
4
4
|
import { FormAccess } from "./FormAccess";
|
|
5
5
|
|
|
@@ -63,7 +63,9 @@ export const Sandbox: Story = {
|
|
|
63
63
|
],
|
|
64
64
|
controller: "",
|
|
65
65
|
properties: {},
|
|
66
|
-
settings: {
|
|
66
|
+
settings: {
|
|
67
|
+
hideTitle: false
|
|
68
|
+
},
|
|
67
69
|
name: "textField",
|
|
68
70
|
path: "textfield",
|
|
69
71
|
machineName: "tcspjwhsevrzpcd:textField"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../../../molecules/card/Card.js";
|
|
2
2
|
import "../Form.js";
|
|
3
3
|
|
|
4
|
-
import { Meta, StoryObj } from "@storybook/react";
|
|
4
|
+
import { Meta, StoryObj } from "@storybook/react-vite";
|
|
5
5
|
|
|
6
6
|
import { FormAction } from "./FormAction.js";
|
|
7
7
|
|
|
@@ -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 (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
2
|
|
|
3
3
|
import form from "../../__fixtures__/form.fixture.json";
|
|
4
4
|
import formWizard from "../../__fixtures__/form-wizard.fixture.json";
|
|
@@ -59,6 +59,9 @@ export default {
|
|
|
59
59
|
action: "onDeleteComponent"
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
|
+
render(args) {
|
|
63
|
+
return <FormBuilder display={args.display} components={args.components} options={args.options} />;
|
|
64
|
+
},
|
|
62
65
|
tags: ["autodocs"]
|
|
63
66
|
} satisfies Meta<typeof FormBuilder>;
|
|
64
67
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Meta, StoryObj } from "@storybook/react";
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
2
|
|
|
3
3
|
import { FormEdit } from "./all";
|
|
4
4
|
import { defaultDisplayChoices } from "./FormParameters";
|
|
@@ -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>
|