Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

Add form fixture (#2329)

Bogdan Chadkinc62b1a2b20d3
diff --git a/fixtures/webstudio-remix-vercel/.webstudio/data.json b/fixtures/webstudio-remix-vercel/.webstudio/data.json
index ccd92cb970..7fb21ec844 100644
--- a/fixtures/webstudio-remix-vercel/.webstudio/data.json
+++ b/fixtures/webstudio-remix-vercel/.webstudio/data.json
@@ -1,9 +1,9 @@
{
"build": {
- "id": "347fa050-f487-412e-a67e-f03f8e3715bc",
+ "id": "4cbe561d-2bae-468c-b9f2-be5cafb59ab5",
"projectId": "cddc1d44-af37-4cb6-a430-d300cf6f932d",
- "version": 107,
- "createdAt": "2023-09-12T09:48:01.245Z",
+ "version": 132,
+ "createdAt": "2023-09-17T13:00:27.518Z",
"pages": {
"homePage": {
"id": "7Db64ZXgYiRqKSQNR-qTQ",
@@ -33,6 +33,16 @@
},
"rootInstanceId": "EDEfpMPRqDejthtwkH7ws",
"path": "/_route_with_symbols_"
+ },
+ {
+ "id": "U1tRJl2ERr8_OFe0g9cN_",
+ "name": "form",
+ "title": "form",
+ "meta": {
+ "description": ""
+ },
+ "rootInstanceId": "a-4nDFkaWy4px1fn38XWJ",
+ "path": "/form"
}
]
},
@@ -1749,6 +1759,198 @@
"type": "page",
"value": "szYLvBduHPmbtqQKCDY0b"
}
+ ],
+ [
+ "OER1GvKVEE4CdEX1yrNe3",
+ {
+ "id": "OER1GvKVEE4CdEX1yrNe3",
+ "instanceId": "isNSM3wXcnHFikwNPlEOL",
+ "name": "state",
+ "type": "dataSource",
+ "value": "KvfuNNCNslj7nAGsD69Fl"
+ }
+ ],
+ [
+ "RHHw5ACTgdDO751J8CgWB",
+ {
+ "id": "RHHw5ACTgdDO751J8CgWB",
+ "instanceId": "isNSM3wXcnHFikwNPlEOL",
+ "name": "onStateChange",
+ "type": "action",
+ "value": [
+ {
+ "type": "execute",
+ "args": ["state"],
+ "code": "$ws$dataSource$KvfuNNCNslj7nAGsD69Fl = state"
+ }
+ ]
+ }
+ ],
+ [
+ "Nyxr4ohgm_MNVtGpsGUn3",
+ {
+ "id": "Nyxr4ohgm_MNVtGpsGUn3",
+ "instanceId": "a5YPRc19IJyhTrjjasA_R",
+ "name": "data-ws-show",
+ "type": "dataSource",
+ "value": "ezyBm7JGcDokMP8DZVzrD"
+ }
+ ],
+ [
+ "3tFb2mZpmJXG5txK78S9g",
+ {
+ "id": "3tFb2mZpmJXG5txK78S9g",
+ "instanceId": "ydR5B_9uMS4PXFS76TmBh",
+ "name": "name",
+ "type": "string",
+ "value": "name"
+ }
+ ],
+ [
+ "7L7d7raf6WNI4_velVRy3",
+ {
+ "id": "7L7d7raf6WNI4_velVRy3",
+ "instanceId": "TsqGP49hjgEW41ReCwrpZ",
+ "name": "name",
+ "type": "string",
+ "value": "email"
+ }
+ ],
+ [
+ "mtOiOi1u0WbNI09rVIS6T",
+ {
+ "id": "mtOiOi1u0WbNI09rVIS6T",
+ "instanceId": "Gw-ta0R4FNFAGBTVRWKep",
+ "name": "data-ws-show",
+ "type": "dataSource",
+ "value": "_NmOL-v4PZhCcmj2vaDy_"
+ }
+ ],
+ [
+ "FTd65V4oEibesTqvAjKp0",
+ {
+ "id": "FTd65V4oEibesTqvAjKp0",
+ "instanceId": "ewk_WKpu4syHLPABMmvUz",
+ "name": "data-ws-show",
+ "type": "dataSource",
+ "value": "VeQ-Tiya3whVhWHbJVHID"
+ }
+ ],
+ [
+ "vtsKrdjJH3YT89prj2K5T",
+ {
+ "id": "vtsKrdjJH3YT89prj2K5T",
+ "instanceId": "-1RvizaBcVpHsjvnYxn1c",
+ "name": "state",
+ "type": "dataSource",
+ "value": "Ip0FRY7L24QrIMdtuMN5j"
+ }
+ ],
+ [
+ "E2n44qWixMBKO6m8kg1wp",
+ {
+ "id": "E2n44qWixMBKO6m8kg1wp",
+ "instanceId": "-1RvizaBcVpHsjvnYxn1c",
+ "name": "onStateChange",
+ "type": "action",
+ "value": [
+ {
+ "type": "execute",
+ "args": ["state"],
+ "code": "$ws$dataSource$Ip0FRY7L24QrIMdtuMN5j = state"
+ }
+ ]
+ }
+ ],
+ [
+ "K6DEgf4WkIDqdiuiwAS5E",
+ {
+ "id": "K6DEgf4WkIDqdiuiwAS5E",
+ "instanceId": "qhnVrmYGlyrMZi3UzqSQA",
+ "name": "data-ws-show",
+ "type": "dataSource",
+ "value": "DUDDZM-QmYH_zBgbIODiu"
+ }
+ ],
+ [
+ "kWwLbf7GOo7-n4xOi8nZi",
+ {
+ "id": "kWwLbf7GOo7-n4xOi8nZi",
+ "instanceId": "e035xi9fcwYtrn9La49Eh",
+ "name": "name",
+ "type": "string",
+ "value": "name"
+ }
+ ],
+ [
+ "dnX31oCvPdAPBQ1JqbnXr",
+ {
+ "id": "dnX31oCvPdAPBQ1JqbnXr",
+ "instanceId": "dcHjdeW_HXPkyQlx3ZiL7",
+ "name": "name",
+ "type": "string",
+ "value": "email"
+ }
+ ],
+ [
+ "JbdIh72OZ8RnHXvYTsLRd",
+ {
+ "id": "JbdIh72OZ8RnHXvYTsLRd",
+ "instanceId": "966cjxuqP_T99N27-mqWE",
+ "name": "data-ws-show",
+ "type": "dataSource",
+ "value": "F72Gu_6DnbW9CGp_747xa"
+ }
+ ],
+ [
+ "6UMH0WLK_fORElv3ffHCg",
+ {
+ "id": "6UMH0WLK_fORElv3ffHCg",
+ "instanceId": "SYG5hhOz31xFJUN_v9zq6",
+ "name": "data-ws-show",
+ "type": "dataSource",
+ "value": "XhDObB85P8I_uDZ_CzGDt"
+ }
+ ],
+ [
+ "cpfLtqW20MR6y68u70Ta2",
+ {
+ "id": "cpfLtqW20MR6y68u70Ta2",
+ "instanceId": "isNSM3wXcnHFikwNPlEOL",
+ "name": "method",
+ "type": "string",
+ "value": "get"
+ }
+ ],
+ [
+ "d5fWTvwp-dtCYQ0rleaQ0",
+ {
+ "id": "d5fWTvwp-dtCYQ0rleaQ0",
+ "instanceId": "isNSM3wXcnHFikwNPlEOL",
+ "name": "action",
+ "type": "string",
+ "value": "/custom"
+ }
+ ],
+ [
+ "Oe1u15XWPgU6oBGnrmT5E",
+ {
+ "id": "Oe1u15XWPgU6oBGnrmT5E",
+ "instanceId": "y4pceTmziuBRIDgUBQNLD",
+ "name": "tag",
+ "type": "string",
+ "value": "h3"
+ }
+ ],
+ [
+ "-QA9iF6dEVIibtNCO1EQp",
+ {
+ "id": "-QA9iF6dEVIibtNCO1EQp",
+ "instanceId": "YdHHf4u3jrdbRIWpB_VfH",
+ "name": "tag",
+ "type": "string",
+ "value": "h3"
+ }
]
],
"dataSources": [
@@ -1764,6 +1966,92 @@
"value": "0"
}
}
+ ],
+ [
+ "KvfuNNCNslj7nAGsD69Fl",
+ {
+ "type": "variable",
+ "id": "KvfuNNCNslj7nAGsD69Fl",
+ "scopeInstanceId": "isNSM3wXcnHFikwNPlEOL",
+ "name": "formState",
+ "value": {
+ "type": "string",
+ "value": "initial"
+ }
+ }
+ ],
+ [
+ "ezyBm7JGcDokMP8DZVzrD",
+ {
+ "type": "expression",
+ "id": "ezyBm7JGcDokMP8DZVzrD",
+ "scopeInstanceId": "a5YPRc19IJyhTrjjasA_R",
+ "name": "formInitial",
+ "code": "$ws$dataSource$KvfuNNCNslj7nAGsD69Fl === 'initial' || $ws$dataSource$KvfuNNCNslj7nAGsD69Fl === 'error'"
+ }
+ ],
+ [
+ "_NmOL-v4PZhCcmj2vaDy_",
+ {
+ "type": "expression",
+ "id": "_NmOL-v4PZhCcmj2vaDy_",
+ "scopeInstanceId": "Gw-ta0R4FNFAGBTVRWKep",
+ "name": "formSuccess",
+ "code": "$ws$dataSource$KvfuNNCNslj7nAGsD69Fl === 'success'"
+ }
+ ],
+ [
+ "VeQ-Tiya3whVhWHbJVHID",
+ {
+ "type": "expression",
+ "id": "VeQ-Tiya3whVhWHbJVHID",
+ "scopeInstanceId": "ewk_WKpu4syHLPABMmvUz",
+ "name": "formError",
+ "code": "$ws$dataSource$KvfuNNCNslj7nAGsD69Fl === 'error'"
+ }
+ ],
+ [
+ "Ip0FRY7L24QrIMdtuMN5j",
+ {
+ "type": "variable",
+ "id": "Ip0FRY7L24QrIMdtuMN5j",
+ "scopeInstanceId": "-1RvizaBcVpHsjvnYxn1c",
+ "name": "formState",
+ "value": {
+ "type": "string",
+ "value": "initial"
+ }
+ }
+ ],
+ [
+ "DUDDZM-QmYH_zBgbIODiu",
+ {
+ "type": "expression",
+ "id": "DUDDZM-QmYH_zBgbIODiu",
+ "scopeInstanceId": "qhnVrmYGlyrMZi3UzqSQA",
+ "name": "formInitial",
+ "code": "$ws$dataSource$Ip0FRY7L24QrIMdtuMN5j === 'initial' || $ws$dataSource$Ip0FRY7L24QrIMdtuMN5j === 'error'"
+ }
+ ],
+ [
+ "F72Gu_6DnbW9CGp_747xa",
+ {
+ "type": "expression",
+ "id": "F72Gu_6DnbW9CGp_747xa",
+ "scopeInstanceId": "966cjxuqP_T99N27-mqWE",
+ "name": "formSuccess",
+ "code": "$ws$dataSource$Ip0FRY7L24QrIMdtuMN5j === 'success'"
+ }
+ ],
+ [
+ "XhDObB85P8I_uDZ_CzGDt",
+ {
+ "type": "expression",
+ "id": "XhDObB85P8I_uDZ_CzGDt",
+ "scopeInstanceId": "SYG5hhOz31xFJUN_v9zq6",
+ "name": "formError",
+ "code": "$ws$dataSource$Ip0FRY7L24QrIMdtuMN5j === 'error'"
+ }
]
],
"instances": [
@@ -2303,6 +2591,348 @@
"component": "Box",
"children": []
}
+ ],
+ [
+ "a-4nDFkaWy4px1fn38XWJ",
+ {
+ "type": "instance",
+ "id": "a-4nDFkaWy4px1fn38XWJ",
+ "component": "Body",
+ "children": [
+ {
+ "type": "id",
+ "value": "-1RvizaBcVpHsjvnYxn1c"
+ },
+ {
+ "type": "id",
+ "value": "isNSM3wXcnHFikwNPlEOL"
+ }
+ ]
+ }
+ ],
+ [
+ "isNSM3wXcnHFikwNPlEOL",
+ {
+ "type": "instance",
+ "id": "isNSM3wXcnHFikwNPlEOL",
+ "component": "Form",
+ "label": "Form with custom props",
+ "children": [
+ {
+ "type": "id",
+ "value": "a5YPRc19IJyhTrjjasA_R"
+ },
+ {
+ "type": "id",
+ "value": "Gw-ta0R4FNFAGBTVRWKep"
+ },
+ {
+ "type": "id",
+ "value": "ewk_WKpu4syHLPABMmvUz"
+ }
+ ]
+ }
+ ],
+ [
+ "a5YPRc19IJyhTrjjasA_R",
+ {
+ "type": "instance",
+ "id": "a5YPRc19IJyhTrjjasA_R",
+ "component": "Box",
+ "label": "Form Content",
+ "children": [
+ {
+ "type": "id",
+ "value": "y4pceTmziuBRIDgUBQNLD"
+ },
+ {
+ "type": "id",
+ "value": "_gLjS0enBOV8KW9Ykz_es"
+ },
+ {
+ "type": "id",
+ "value": "ydR5B_9uMS4PXFS76TmBh"
+ },
+ {
+ "type": "id",
+ "value": "8RU1FyL2QRyqhNUKELGrb"
+ },
+ {
+ "type": "id",
+ "value": "TsqGP49hjgEW41ReCwrpZ"
+ },
+ {
+ "type": "id",
+ "value": "5GWjwVdapuGdn443GIKDW"
+ }
+ ]
+ }
+ ],
+ [
+ "_gLjS0enBOV8KW9Ykz_es",
+ {
+ "type": "instance",
+ "id": "_gLjS0enBOV8KW9Ykz_es",
+ "component": "Label",
+ "children": [
+ {
+ "type": "text",
+ "value": "Name"
+ }
+ ]
+ }
+ ],
+ [
+ "ydR5B_9uMS4PXFS76TmBh",
+ {
+ "type": "instance",
+ "id": "ydR5B_9uMS4PXFS76TmBh",
+ "component": "Input",
+ "children": []
+ }
+ ],
+ [
+ "8RU1FyL2QRyqhNUKELGrb",
+ {
+ "type": "instance",
+ "id": "8RU1FyL2QRyqhNUKELGrb",
+ "component": "Label",
+ "children": [
+ {
+ "type": "text",
+ "value": "Email"
+ }
+ ]
+ }
+ ],
+ [
+ "TsqGP49hjgEW41ReCwrpZ",
+ {
+ "type": "instance",
+ "id": "TsqGP49hjgEW41ReCwrpZ",
+ "component": "Input",
+ "children": []
+ }
+ ],
+ [
+ "5GWjwVdapuGdn443GIKDW",
+ {
+ "type": "instance",
+ "id": "5GWjwVdapuGdn443GIKDW",
+ "component": "Button",
+ "children": [
+ {
+ "type": "text",
+ "value": "Submit"
+ }
+ ]
+ }
+ ],
+ [
+ "Gw-ta0R4FNFAGBTVRWKep",
+ {
+ "type": "instance",
+ "id": "Gw-ta0R4FNFAGBTVRWKep",
+ "component": "Box",
+ "label": "Success Message",
+ "children": [
+ {
+ "type": "text",
+ "value": "Thank you for getting in touch!"
+ }
+ ]
+ }
+ ],
+ [
+ "ewk_WKpu4syHLPABMmvUz",
+ {
+ "type": "instance",
+ "id": "ewk_WKpu4syHLPABMmvUz",
+ "component": "Box",
+ "label": "Error Message",
+ "children": [
+ {
+ "type": "text",
+ "value": "Sorry, something went wrong."
+ }
+ ]
+ }
+ ],
+ [
+ "-1RvizaBcVpHsjvnYxn1c",
+ {
+ "type": "instance",
+ "id": "-1RvizaBcVpHsjvnYxn1c",
+ "component": "Form",
+ "label": "Default form",
+ "children": [
+ {
+ "type": "id",
+ "value": "qhnVrmYGlyrMZi3UzqSQA"
+ },
+ {
+ "type": "id",
+ "value": "966cjxuqP_T99N27-mqWE"
+ },
+ {
+ "type": "id",
+ "value": "SYG5hhOz31xFJUN_v9zq6"
+ }
+ ]
+ }
+ ],
+ [
+ "qhnVrmYGlyrMZi3UzqSQA",
+ {
+ "type": "instance",
+ "id": "qhnVrmYGlyrMZi3UzqSQA",
+ "component": "Box",
+ "label": "Form Content",
+ "children": [
+ {
+ "type": "id",
+ "value": "YdHHf4u3jrdbRIWpB_VfH"
+ },
+ {
+ "type": "id",
+ "value": "A0RNI1WVwOGGDbwYnoZia"
+ },
+ {
+ "type": "id",
+ "value": "e035xi9fcwYtrn9La49Eh"
+ },
+ {
+ "type": "id",
+ "value": "LImtuVzw5R9yQsG4faiGV"
+ },
+ {
+ "type": "id",
+ "value": "dcHjdeW_HXPkyQlx3ZiL7"
+ },
+ {
+ "type": "id",
+ "value": "ZAtG6JgK4sbTnOAZlp2rU"
+ }
+ ]
+ }
+ ],
+ [
+ "A0RNI1WVwOGGDbwYnoZia",
+ {
+ "type": "instance",
+ "id": "A0RNI1WVwOGGDbwYnoZia",
+ "component": "Label",
+ "children": [
+ {
+ "type": "text",
+ "value": "Name"
+ }
+ ]
+ }
+ ],
+ [
+ "e035xi9fcwYtrn9La49Eh",
+ {
+ "type": "instance",
+ "id": "e035xi9fcwYtrn9La49Eh",
+ "component": "Input",
+ "children": []
+ }
+ ],
+ [
+ "LImtuVzw5R9yQsG4faiGV",
+ {
+ "type": "instance",
+ "id": "LImtuVzw5R9yQsG4faiGV",
+ "component": "Label",
+ "children": [
+ {
+ "type": "text",
+ "value": "Email"
+ }
+ ]
+ }
+ ],
+ [
+ "dcHjdeW_HXPkyQlx3ZiL7",
+ {
+ "type": "instance",
+ "id": "dcHjdeW_HXPkyQlx3ZiL7",
+ "component": "Input",
+ "children": []
+ }
+ ],
+ [
+ "ZAtG6JgK4sbTnOAZlp2rU",
+ {
+ "type": "instance",
+ "id": "ZAtG6JgK4sbTnOAZlp2rU",
+ "component": "Button",
+ "children": [
+ {
+ "type": "text",
+ "value": "Submit"
+ }
+ ]
+ }
+ ],
+ [
+ "966cjxuqP_T99N27-mqWE",
+ {
+ "type": "instance",
+ "id": "966cjxuqP_T99N27-mqWE",
+ "component": "Box",
+ "label": "Success Message",
+ "children": [
+ {
+ "type": "text",
+ "value": "Thank you for getting in touch!"
+ }
+ ]
+ }
+ ],
+ [
+ "SYG5hhOz31xFJUN_v9zq6",
+ {
+ "type": "instance",
+ "id": "SYG5hhOz31xFJUN_v9zq6",
+ "component": "Box",
+ "label": "Error Message",
+ "children": [
+ {
+ "type": "text",
+ "value": "Sorry, something went wrong."
+ }
+ ]
+ }
+ ],
+ [
+ "y4pceTmziuBRIDgUBQNLD",
+ {
+ "type": "instance",
+ "id": "y4pceTmziuBRIDgUBQNLD",
+ "component": "Heading",
+ "children": [
+ {
+ "type": "text",
+ "value": "Form with custom action and method"
+ }
+ ]
+ }
+ ],
+ [
+ "YdHHf4u3jrdbRIWpB_VfH",
+ {
+ "type": "instance",
+ "id": "YdHHf4u3jrdbRIWpB_VfH",
+ "component": "Heading",
+ "children": [
+ {
+ "type": "text",
+ "value": "Default form"
+ }
+ ]
+ }
]
],
"deployment": {
@@ -2346,6 +2976,16 @@
},
"rootInstanceId": "EDEfpMPRqDejthtwkH7ws",
"path": "/_route_with_symbols_"
+ },
+ {
+ "id": "U1tRJl2ERr8_OFe0g9cN_",
+ "name": "form",
+ "title": "form",
+ "meta": {
+ "description": ""
+ },
+ "rootInstanceId": "a-4nDFkaWy4px1fn38XWJ",
+ "path": "/form"
}
],
"assets": [
diff --git a/fixtures/webstudio-remix-vercel/app/__generated__/[_route_with_symbols_]._index.tsx b/fixtures/webstudio-remix-vercel/app/__generated__/[_route_with_symbols_]._index.tsx
index e9a63f868b..479b8e9210 100644
--- a/fixtures/webstudio-remix-vercel/app/__generated__/[_route_with_symbols_]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/__generated__/[_route_with_symbols_]._index.tsx
@@ -75,6 +75,14 @@ export const pageData: PageData = {
rootInstanceId: "EDEfpMPRqDejthtwkH7ws",
path: "/_route_with_symbols_",
},
+ {
+ id: "U1tRJl2ERr8_OFe0g9cN_",
+ name: "form",
+ title: "form",
+ meta: { description: "" },
+ rootInstanceId: "a-4nDFkaWy4px1fn38XWJ",
+ path: "/form",
+ },
],
page: {
id: "szYLvBduHPmbtqQKCDY0b",
diff --git a/fixtures/webstudio-remix-vercel/app/__generated__/[form]._index.tsx b/fixtures/webstudio-remix-vercel/app/__generated__/[form]._index.tsx
new file mode 100644
index 0000000000..d0a6f4b4b7
--- /dev/null
+++ b/fixtures/webstudio-remix-vercel/app/__generated__/[form]._index.tsx
@@ -0,0 +1,662 @@
+/* eslint-disable */
+/* This is a auto generated file for building the project */
+
+import type { PageData } from "~/routes/_index";
+import type { Components } from "@webstudio-is/react-sdk";
+import type { Asset } from "@webstudio-is/sdk";
+import {
+ Body as Body,
+ Box as Box,
+ Label as Label,
+ Input as Input,
+ Button as Button,
+ Heading as Heading,
+} from "@webstudio-is/sdk-components-react";
+import { Form as Form } from "@webstudio-is/sdk-components-react-remix";
+
+export const components = new Map(
+ Object.entries({
+ Body: Body,
+ Box: Box,
+ Label: Label,
+ Input: Input,
+ Button: Button,
+ Heading: Heading,
+ Form: Form,
+ })
+) as Components;
+export const fontAssets: Asset[] = [];
+export const pageData: PageData = {
+ build: {
+ props: [
+ [
+ "OER1GvKVEE4CdEX1yrNe3",
+ {
+ id: "OER1GvKVEE4CdEX1yrNe3",
+ instanceId: "isNSM3wXcnHFikwNPlEOL",
+ name: "state",
+ type: "dataSource",
+ value: "KvfuNNCNslj7nAGsD69Fl",
+ },
+ ],
+ [
+ "RHHw5ACTgdDO751J8CgWB",
+ {
+ id: "RHHw5ACTgdDO751J8CgWB",
+ instanceId: "isNSM3wXcnHFikwNPlEOL",
+ name: "onStateChange",
+ type: "action",
+ value: [
+ {
+ type: "execute",
+ args: ["state"],
+ code: "$ws$dataSource$KvfuNNCNslj7nAGsD69Fl = state",
+ },
+ ],
+ },
+ ],
+ [
+ "Nyxr4ohgm_MNVtGpsGUn3",
+ {
+ id: "Nyxr4ohgm_MNVtGpsGUn3",
+ instanceId: "a5YPRc19IJyhTrjjasA_R",
+ name: "data-ws-show",
+ type: "dataSource",
+ value: "ezyBm7JGcDokMP8DZVzrD",
+ },
+ ],
+ [
+ "3tFb2mZpmJXG5txK78S9g",
+ {
+ id: "3tFb2mZpmJXG5txK78S9g",
+ instanceId: "ydR5B_9uMS4PXFS76TmBh",
+ name: "name",
+ type: "string",
+ value: "name",
+ },
+ ],
+ [
+ "7L7d7raf6WNI4_velVRy3",
+ {
+ id: "7L7d7raf6WNI4_velVRy3",
+ instanceId: "TsqGP49hjgEW41ReCwrpZ",
+ name: "name",
+ type: "string",
+ value: "email",
+ },
+ ],
+ [
+ "mtOiOi1u0WbNI09rVIS6T",
+ {
+ id: "mtOiOi1u0WbNI09rVIS6T",
+ instanceId: "Gw-ta0R4FNFAGBTVRWKep",
+ name: "data-ws-show",
+ type: "dataSource",
+ value: "_NmOL-v4PZhCcmj2vaDy_",
+ },
+ ],
+ [
+ "FTd65V4oEibesTqvAjKp0",
+ {
+ id: "FTd65V4oEibesTqvAjKp0",
+ instanceId: "ewk_WKpu4syHLPABMmvUz",
+ name: "data-ws-show",
+ type: "dataSource",
+ value: "VeQ-Tiya3whVhWHbJVHID",
+ },
+ ],
+ [
+ "vtsKrdjJH3YT89prj2K5T",
+ {
+ id: "vtsKrdjJH3YT89prj2K5T",
+ instanceId: "-1RvizaBcVpHsjvnYxn1c",
+ name: "state",
+ type: "dataSource",
+ value: "Ip0FRY7L24QrIMdtuMN5j",
+ },
+ ],
+ [
+ "E2n44qWixMBKO6m8kg1wp",
+ {
+ id: "E2n44qWixMBKO6m8kg1wp",
+ instanceId: "-1RvizaBcVpHsjvnYxn1c",
+ name: "onStateChange",
+ type: "action",
+ value: [
+ {
+ type: "execute",
+ args: ["state"],
+ code: "$ws$dataSource$Ip0FRY7L24QrIMdtuMN5j = state",
+ },
+ ],
+ },
+ ],
+ [
+ "K6DEgf4WkIDqdiuiwAS5E",
+ {
+ id: "K6DEgf4WkIDqdiuiwAS5E",
+ instanceId: "qhnVrmYGlyrMZi3UzqSQA",
+ name: "data-ws-show",
+ type: "dataSource",
+ value: "DUDDZM-QmYH_zBgbIODiu",
+ },
+ ],
+ [
+ "kWwLbf7GOo7-n4xOi8nZi",
+ {
+ id: "kWwLbf7GOo7-n4xOi8nZi",
+ instanceId: "e035xi9fcwYtrn9La49Eh",
+ name: "name",
+ type: "string",
+ value: "name",
+ },
+ ],
+ [
+ "dnX31oCvPdAPBQ1JqbnXr",
+ {
+ id: "dnX31oCvPdAPBQ1JqbnXr",
+ instanceId: "dcHjdeW_HXPkyQlx3ZiL7",
+ name: "name",
+ type: "string",
+ value: "email",
+ },
+ ],
+ [
+ "JbdIh72OZ8RnHXvYTsLRd",
+ {
+ id: "JbdIh72OZ8RnHXvYTsLRd",
+ instanceId: "966cjxuqP_T99N27-mqWE",
+ name: "data-ws-show",
+ type: "dataSource",
+ value: "F72Gu_6DnbW9CGp_747xa",
+ },
+ ],
+ [
+ "6UMH0WLK_fORElv3ffHCg",
+ {
+ id: "6UMH0WLK_fORElv3ffHCg",
+ instanceId: "SYG5hhOz31xFJUN_v9zq6",
+ name: "data-ws-show",
+ type: "dataSource",
+ value: "XhDObB85P8I_uDZ_CzGDt",
+ },
+ ],
+ [
+ "cpfLtqW20MR6y68u70Ta2",
+ {
+ id: "cpfLtqW20MR6y68u70Ta2",
+ instanceId: "isNSM3wXcnHFikwNPlEOL",
+ name: "method",
+ type: "string",
+ value: "get",
+ },
+ ],
+ [
+ "d5fWTvwp-dtCYQ0rleaQ0",
+ {
+ id: "d5fWTvwp-dtCYQ0rleaQ0",
+ instanceId: "isNSM3wXcnHFikwNPlEOL",
+ name: "action",
+ type: "string",
+ value: "/custom",
+ },
+ ],
+ [
+ "Oe1u15XWPgU6oBGnrmT5E",
+ {
+ id: "Oe1u15XWPgU6oBGnrmT5E",
+ instanceId: "y4pceTmziuBRIDgUBQNLD",
+ name: "tag",
+ type: "string",
+ value: "h3",
+ },
+ ],
+ [
+ "-QA9iF6dEVIibtNCO1EQp",
+ {
+ id: "-QA9iF6dEVIibtNCO1EQp",
+ instanceId: "YdHHf4u3jrdbRIWpB_VfH",
+ name: "tag",
+ type: "string",
+ value: "h3",
+ },
+ ],
+ ],
+ instances: [
+ [
+ "a-4nDFkaWy4px1fn38XWJ",
+ {
+ type: "instance",
+ id: "a-4nDFkaWy4px1fn38XWJ",
+ component: "Body",
+ children: [
+ { type: "id", value: "-1RvizaBcVpHsjvnYxn1c" },
+ { type: "id", value: "isNSM3wXcnHFikwNPlEOL" },
+ ],
+ },
+ ],
+ [
+ "isNSM3wXcnHFikwNPlEOL",
+ {
+ type: "instance",
+ id: "isNSM3wXcnHFikwNPlEOL",
+ component: "Form",
+ label: "Form with custom props",
+ children: [
+ { type: "id", value: "a5YPRc19IJyhTrjjasA_R" },
+ { type: "id", value: "Gw-ta0R4FNFAGBTVRWKep" },
+ { type: "id", value: "ewk_WKpu4syHLPABMmvUz" },
+ ],
+ },
+ ],
+ [
+ "a5YPRc19IJyhTrjjasA_R",
+ {
+ type: "instance",
+ id: "a5YPRc19IJyhTrjjasA_R",
+ component: "Box",
+ label: "Form Content",
+ children: [
+ { type: "id", value: "y4pceTmziuBRIDgUBQNLD" },
+ { type: "id", value: "_gLjS0enBOV8KW9Ykz_es" },
+ { type: "id", value: "ydR5B_9uMS4PXFS76TmBh" },
+ { type: "id", value: "8RU1FyL2QRyqhNUKELGrb" },
+ { type: "id", value: "TsqGP49hjgEW41ReCwrpZ" },
+ { type: "id", value: "5GWjwVdapuGdn443GIKDW" },
+ ],
+ },
+ ],
+ [
+ "_gLjS0enBOV8KW9Ykz_es",
+ {
+ type: "instance",
+ id: "_gLjS0enBOV8KW9Ykz_es",
+ component: "Label",
+ children: [{ type: "text", value: "Name" }],
+ },
+ ],
+ [
+ "ydR5B_9uMS4PXFS76TmBh",
+ {
+ type: "instance",
+ id: "ydR5B_9uMS4PXFS76TmBh",
+ component: "Input",
+ children: [],
+ },
+ ],
+ [
+ "8RU1FyL2QRyqhNUKELGrb",
+ {
+ type: "instance",
+ id: "8RU1FyL2QRyqhNUKELGrb",
+ component: "Label",
+ children: [{ type: "text", value: "Email" }],
+ },
+ ],
+ [
+ "TsqGP49hjgEW41ReCwrpZ",
+ {
+ type: "instance",
+ id: "TsqGP49hjgEW41ReCwrpZ",
+ component: "Input",
+ children: [],
+ },
+ ],
+ [
+ "5GWjwVdapuGdn443GIKDW",
+ {
+ type: "instance",
+ id: "5GWjwVdapuGdn443GIKDW",
+ component: "Button",
+ children: [{ type: "text", value: "Submit" }],
+ },
+ ],
+ [
+ "Gw-ta0R4FNFAGBTVRWKep",
+ {
+ type: "instance",
+ id: "Gw-ta0R4FNFAGBTVRWKep",
+ component: "Box",
+ label: "Success Message",
+ children: [
+ { type: "text", value: "Thank you for getting in touch!" },
+ ],
+ },
+ ],
+ [
+ "ewk_WKpu4syHLPABMmvUz",
+ {
+ type: "instance",
+ id: "ewk_WKpu4syHLPABMmvUz",
+ component: "Box",
+ label: "Error Message",
+ children: [{ type: "text", value: "Sorry, something went wrong." }],
+ },
+ ],
+ [
+ "-1RvizaBcVpHsjvnYxn1c",
+ {
+ type: "instance",
+ id: "-1RvizaBcVpHsjvnYxn1c",
+ component: "Form",
+ label: "Default form",
+ children: [
+ { type: "id", value: "qhnVrmYGlyrMZi3UzqSQA" },
+ { type: "id", value: "966cjxuqP_T99N27-mqWE" },
+ { type: "id", value: "SYG5hhOz31xFJUN_v9zq6" },
+ ],
+ },
+ ],
+ [
+ "qhnVrmYGlyrMZi3UzqSQA",
+ {
+ type: "instance",
+ id: "qhnVrmYGlyrMZi3UzqSQA",
+ component: "Box",
+ label: "Form Content",
+ children: [
+ { type: "id", value: "YdHHf4u3jrdbRIWpB_VfH" },
+ { type: "id", value: "A0RNI1WVwOGGDbwYnoZia" },
+ { type: "id", value: "e035xi9fcwYtrn9La49Eh" },
+ { type: "id", value: "LImtuVzw5R9yQsG4faiGV" },
+ { type: "id", value: "dcHjdeW_HXPkyQlx3ZiL7" },
+ { type: "id", value: "ZAtG6JgK4sbTnOAZlp2rU" },
+ ],
+ },
+ ],
+ [
+ "A0RNI1WVwOGGDbwYnoZia",
+ {
+ type: "instance",
+ id: "A0RNI1WVwOGGDbwYnoZia",
+ component: "Label",
+ children: [{ type: "text", value: "Name" }],
+ },
+ ],
+ [
+ "e035xi9fcwYtrn9La49Eh",
+ {
+ type: "instance",
+ id: "e035xi9fcwYtrn9La49Eh",
+ component: "Input",
+ children: [],
+ },
+ ],
+ [
+ "LImtuVzw5R9yQsG4faiGV",
+ {
+ type: "instance",
+ id: "LImtuVzw5R9yQsG4faiGV",
+ component: "Label",
+ children: [{ type: "text", value: "Email" }],
+ },
+ ],
+ [
+ "dcHjdeW_HXPkyQlx3ZiL7",
+ {
+ type: "instance",
+ id: "dcHjdeW_HXPkyQlx3ZiL7",
+ component: "Input",
+ children: [],
+ },
+ ],
+ [
+ "ZAtG6JgK4sbTnOAZlp2rU",
+ {
+ type: "instance",
+ id: "ZAtG6JgK4sbTnOAZlp2rU",
+ component: "Button",
+ children: [{ type: "text", value: "Submit" }],
+ },
+ ],
+ [
+ "966cjxuqP_T99N27-mqWE",
+ {
+ type: "instance",
+ id: "966cjxuqP_T99N27-mqWE",
+ component: "Box",
+ label: "Success Message",
+ children: [
+ { type: "text", value: "Thank you for getting in touch!" },
+ ],
+ },
+ ],
+ [
+ "SYG5hhOz31xFJUN_v9zq6",
+ {
+ type: "instance",
+ id: "SYG5hhOz31xFJUN_v9zq6",
+ component: "Box",
+ label: "Error Message",
+ children: [{ type: "text", value: "Sorry, something went wrong." }],
+ },
+ ],
+ [
+ "y4pceTmziuBRIDgUBQNLD",
+ {
+ type: "instance",
+ id: "y4pceTmziuBRIDgUBQNLD",
+ component: "Heading",
+ children: [
+ { type: "text", value: "Form with custom action and method" },
+ ],
+ },
+ ],
+ [
+ "YdHHf4u3jrdbRIWpB_VfH",
+ {
+ type: "instance",
+ id: "YdHHf4u3jrdbRIWpB_VfH",
+ component: "Heading",
+ children: [{ type: "text", value: "Default form" }],
+ },
+ ],
+ ],
+ dataSources: [
+ [
+ "KvfuNNCNslj7nAGsD69Fl",
+ {
+ type: "variable",
+ id: "KvfuNNCNslj7nAGsD69Fl",
+ scopeInstanceId: "isNSM3wXcnHFikwNPlEOL",
+ name: "formState",
+ value: { type: "string", value: "initial" },
+ },
+ ],
+ [
+ "ezyBm7JGcDokMP8DZVzrD",
+ {
+ type: "expression",
+ id: "ezyBm7JGcDokMP8DZVzrD",
+ scopeInstanceId: "a5YPRc19IJyhTrjjasA_R",
+ name: "formInitial",
+ code: "$ws$dataSource$KvfuNNCNslj7nAGsD69Fl === 'initial' || $ws$dataSource$KvfuNNCNslj7nAGsD69Fl === 'error'",
+ },
+ ],
+ [
+ "_NmOL-v4PZhCcmj2vaDy_",
+ {
+ type: "expression",
+ id: "_NmOL-v4PZhCcmj2vaDy_",
+ scopeInstanceId: "Gw-ta0R4FNFAGBTVRWKep",
+ name: "formSuccess",
+ code: "$ws$dataSource$KvfuNNCNslj7nAGsD69Fl === 'success'",
+ },
+ ],
+ [
+ "VeQ-Tiya3whVhWHbJVHID",
+ {
+ type: "expression",
+ id: "VeQ-Tiya3whVhWHbJVHID",
+ scopeInstanceId: "ewk_WKpu4syHLPABMmvUz",
+ name: "formError",
+ code: "$ws$dataSource$KvfuNNCNslj7nAGsD69Fl === 'error'",
+ },
+ ],
+ [
+ "Ip0FRY7L24QrIMdtuMN5j",
+ {
+ type: "variable",
+ id: "Ip0FRY7L24QrIMdtuMN5j",
+ scopeInstanceId: "-1RvizaBcVpHsjvnYxn1c",
+ name: "formState",
+ value: { type: "string", value: "initial" },
+ },
+ ],
+ [
+ "DUDDZM-QmYH_zBgbIODiu",
+ {
+ type: "expression",
+ id: "DUDDZM-QmYH_zBgbIODiu",
+ scopeInstanceId: "qhnVrmYGlyrMZi3UzqSQA",
+ name: "formInitial",
+ code: "$ws$dataSource$Ip0FRY7L24QrIMdtuMN5j === 'initial' || $ws$dataSource$Ip0FRY7L24QrIMdtuMN5j === 'error'",
+ },
+ ],
+ [
+ "F72Gu_6DnbW9CGp_747xa",
+ {
+ type: "expression",
+ id: "F72Gu_6DnbW9CGp_747xa",
+ scopeInstanceId: "966cjxuqP_T99N27-mqWE",
+ name: "formSuccess",
+ code: "$ws$dataSource$Ip0FRY7L24QrIMdtuMN5j === 'success'",
+ },
+ ],
+ [
+ "XhDObB85P8I_uDZ_CzGDt",
+ {
+ type: "expression",
+ id: "XhDObB85P8I_uDZ_CzGDt",
+ scopeInstanceId: "SYG5hhOz31xFJUN_v9zq6",
+ name: "formError",
+ code: "$ws$dataSource$Ip0FRY7L24QrIMdtuMN5j === 'error'",
+ },
+ ],
+ ],
+ },
+ pages: [
+ {
+ id: "7Db64ZXgYiRqKSQNR-qTQ",
+ name: "Home",
+ title: "Home",
+ meta: {},
+ rootInstanceId: "On9cvWCxr5rdZtY9O1Bv0",
+ path: "",
+ },
+ {
+ id: "xfvB4UThQXmQ_OubPYrkg",
+ name: "radix",
+ title: "radix",
+ meta: { description: "" },
+ rootInstanceId: "uKWGyE9JY3cPwY-xI9vk6",
+ path: "/radix",
+ },
+ {
+ id: "szYLvBduHPmbtqQKCDY0b",
+ name: "RouteWithSymbols",
+ title: "RouteWithSymbols",
+ meta: { description: "" },
+ rootInstanceId: "EDEfpMPRqDejthtwkH7ws",
+ path: "/_route_with_symbols_",
+ },
+ {
+ id: "U1tRJl2ERr8_OFe0g9cN_",
+ name: "form",
+ title: "form",
+ meta: { description: "" },
+ rootInstanceId: "a-4nDFkaWy4px1fn38XWJ",
+ path: "/form",
+ },
+ ],
+ page: {
+ id: "U1tRJl2ERr8_OFe0g9cN_",
+ name: "form",
+ title: "form",
+ meta: { description: "" },
+ rootInstanceId: "a-4nDFkaWy4px1fn38XWJ",
+ path: "/form",
+ },
+ assets: [
+ {
+ id: "9a8bc926-7804-4d3f-af81-69196b1d2ed8",
+ name: "small-avif-kitty_FnabJsioMWpBtXZSGf4DR.webp",
+ description: null,
+ projectId: "cddc1d44-af37-4cb6-a430-d300cf6f932d",
+ size: 2906,
+ type: "image",
+ format: "webp",
+ createdAt: "2023-09-12T09:44:22.120Z",
+ meta: { width: 100, height: 100 },
+ },
+ {
+ id: "cd939c56-bcdd-4e64-bd9c-567a9bccd3da",
+ name: "_937084ed-a798-49fe-8664-df93a2af605e_uiBk3o6UWdqolyakMvQJ9.jpeg",
+ description: null,
+ projectId: "cddc1d44-af37-4cb6-a430-d300cf6f932d",
+ size: 210614,
+ type: "image",
+ format: "jpeg",
+ createdAt: "2023-09-06T11:28:43.031Z",
+ meta: { width: 1024, height: 1024 },
+ },
+ ],
+};
+export const user: { email: string | null } | undefined = {
+ email: "[email protected]",
+};
+export const projectId = "cddc1d44-af37-4cb6-a430-d300cf6f932d";
+
+/* eslint-disable */
+
+const indexesWithinAncestors = new Map<string, number>([]);
+
+const getDataSourcesLogic = (
+ _getVariable: (id: string) => unknown,
+ _setVariable: (id: string, value: unknown) => void
+) => {
+ let formState = _getVariable("KvfuNNCNslj7nAGsD69Fl") ?? "initial";
+ let set$formState = (value: unknown) =>
+ _setVariable("KvfuNNCNslj7nAGsD69Fl", value);
+ let formState_1 = _getVariable("Ip0FRY7L24QrIMdtuMN5j") ?? "initial";
+ let set$formState_1 = (value: unknown) =>
+ _setVariable("Ip0FRY7L24QrIMdtuMN5j", value);
+ let formInitial = formState === "initial" || formState === "error";
+ let formSuccess = formState === "success";
+ let formError = formState === "error";
+ let formInitial_1 = formState_1 === "initial" || formState_1 === "error";
+ let formSuccess_1 = formState_1 === "success";
+ let formError_1 = formState_1 === "error";
+ let onStateChange = (state: any) => {
+ formState = state;
+ set$formState(formState);
+ };
+ let onStateChange_1 = (state: any) => {
+ formState_1 = state;
+ set$formState_1(formState_1);
+ };
+ let _output = new Map();
+ _output.set("KvfuNNCNslj7nAGsD69Fl", formState);
+ _output.set("ezyBm7JGcDokMP8DZVzrD", formInitial);
+ _output.set("_NmOL-v4PZhCcmj2vaDy_", formSuccess);
+ _output.set("VeQ-Tiya3whVhWHbJVHID", formError);
+ _output.set("Ip0FRY7L24QrIMdtuMN5j", formState_1);
+ _output.set("DUDDZM-QmYH_zBgbIODiu", formInitial_1);
+ _output.set("F72Gu_6DnbW9CGp_747xa", formSuccess_1);
+ _output.set("XhDObB85P8I_uDZ_CzGDt", formError_1);
+ _output.set("RHHw5ACTgdDO751J8CgWB", onStateChange);
+ _output.set("E2n44qWixMBKO6m8kg1wp", onStateChange_1);
+ return _output;
+};
+
+export const formsProperties = new Map<
+ string,
+ { method?: string; action?: string }
+>([["isNSM3wXcnHFikwNPlEOL", { method: "get", action: "/custom" }]]);
+
+export const utils = {
+ indexesWithinAncestors,
+ getDataSourcesLogic,
+};
+
+/* eslint-enable */
diff --git a/fixtures/webstudio-remix-vercel/app/__generated__/[radix]._index.tsx b/fixtures/webstudio-remix-vercel/app/__generated__/[radix]._index.tsx
index a91bb70190..97d73d853e 100644
--- a/fixtures/webstudio-remix-vercel/app/__generated__/[radix]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/__generated__/[radix]._index.tsx
@@ -405,6 +405,14 @@ export const pageData: PageData = {
rootInstanceId: "EDEfpMPRqDejthtwkH7ws",
path: "/_route_with_symbols_",
},
+ {
+ id: "U1tRJl2ERr8_OFe0g9cN_",
+ name: "form",
+ title: "form",
+ meta: { description: "" },
+ rootInstanceId: "a-4nDFkaWy4px1fn38XWJ",
+ path: "/form",
+ },
],
page: {
id: "xfvB4UThQXmQ_OubPYrkg",
diff --git a/fixtures/webstudio-remix-vercel/app/__generated__/_index.tsx b/fixtures/webstudio-remix-vercel/app/__generated__/_index.tsx
index 41faee73e3..91c025d33d 100644
--- a/fixtures/webstudio-remix-vercel/app/__generated__/_index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/__generated__/_index.tsx
@@ -211,6 +211,14 @@ export const pageData: PageData = {
rootInstanceId: "EDEfpMPRqDejthtwkH7ws",
path: "/_route_with_symbols_",
},
+ {
+ id: "U1tRJl2ERr8_OFe0g9cN_",
+ name: "form",
+ title: "form",
+ meta: { description: "" },
+ rootInstanceId: "a-4nDFkaWy4px1fn38XWJ",
+ path: "/form",
+ },
],
page: {
id: "7Db64ZXgYiRqKSQNR-qTQ",
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[_route_with_symbols_]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[_route_with_symbols_]._index.tsx
index 5ea7236eac..be42984a0b 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[_route_with_symbols_]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[_route_with_symbols_]._index.tsx
@@ -80,16 +80,16 @@ export const action = async ({ request, context }: ActionArgs) => {
const formData = await request.formData();
const formId = getFormId(formData);
- const formProperties =
- formId === undefined ? undefined : formsProperties.get(formId);
-
- if (formProperties === undefined) {
+ if (formId === undefined) {
// We're throwing rather than returning { success: false }
// because this isn't supposed to happen normally: bug or malicious user
throw json("Form not found", { status: 404 });
}
- const { action, method } = formProperties;
+ const formProperties = formsProperties.get(formId);
+
+ // form properties are not defined when defaults are used
+ const { action, method } = formProperties ?? {};
const email = user?.email;
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx
new file mode 100644
index 0000000000..6c82476941
--- /dev/null
+++ b/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx
@@ -0,0 +1,183 @@
+/* eslint-disable camelcase */
+import {
+ type V2_MetaFunction,
+ type LinksFunction,
+ type LinkDescriptor,
+ type ActionArgs,
+ json,
+} from "@remix-run/node";
+
+import {
+ InstanceRoot,
+ type RootPropsData,
+ type Params,
+} from "@webstudio-is/react-sdk";
+import { n8nHandler, getFormId } from "@webstudio-is/form-handlers";
+import { Scripts, ScrollRestoration } from "@remix-run/react";
+import {
+ fontAssets,
+ components,
+ pageData,
+ user,
+ projectId,
+ utils,
+ formsProperties,
+} from "../__generated__/[form]._index.tsx";
+import css from "../__generated__/index.css";
+import type { Data } from "@webstudio-is/http-client";
+import { assetBaseUrl, imageBaseUrl, imageLoader } from "~/constants.mjs";
+
+export type PageData = Omit<Data, "build"> & {
+ build: Pick<Data["build"], "props" | "instances" | "dataSources">;
+};
+
+export const meta: V2_MetaFunction = () => {
+ const { page } = pageData;
+ return [{ title: page?.title || "Webstudio", ...page?.meta }];
+};
+
+export const links: LinksFunction = () => {
+ const result: LinkDescriptor[] = [];
+
+ result.push({
+ rel: "stylesheet",
+ href: css,
+ });
+
+ for (const asset of fontAssets) {
+ if (asset.type === "font") {
+ result.push({
+ rel: "preload",
+ href: assetBaseUrl + asset.name,
+ as: "font",
+ crossOrigin: "anonymous",
+ // @todo add mimeType
+ // type: asset.mimeType,
+ });
+ }
+ }
+
+ return result;
+};
+
+const getRequestHost = (request: Request): string =>
+ request.headers.get("x-forwarded-host") || request.headers.get("host") || "";
+
+const getMethod = (value: string | undefined) => {
+ if (value === undefined) {
+ return "post";
+ }
+
+ switch (value.toLowerCase()) {
+ case "get":
+ return "get";
+ default:
+ return "post";
+ }
+};
+
+export const action = async ({ request, context }: ActionArgs) => {
+ const formData = await request.formData();
+
+ const formId = getFormId(formData);
+ if (formId === undefined) {
+ // We're throwing rather than returning { success: false }
+ // because this isn't supposed to happen normally: bug or malicious user
+ throw json("Form not found", { status: 404 });
+ }
+
+ const formProperties = formsProperties.get(formId);
+
+ // form properties are not defined when defaults are used
+ const { action, method } = formProperties ?? {};
+
+ const email = user?.email;
+
+ if (email == null) {
+ return { success: false };
+ }
+
+ // wrapped in try/catch just in cases new URL() throws
+ // (should not happen)
+ let pageUrl: URL;
+ try {
+ pageUrl = new URL(request.url);
+ pageUrl.host = getRequestHost(request);
+ } catch {
+ return { success: false };
+ }
+
+ if (action !== undefined) {
+ try {
+ // Test that action is full URL
+ new URL(action);
+ } catch {
+ return json(
+ {
+ success: false,
+ error: "Invalid action URL, must be valid http/https protocol",
+ },
+ { status: 200 }
+ );
+ }
+ }
+
+ const formInfo = {
+ formData,
+ projectId,
+ action: action ?? null,
+ method: getMethod(method),
+ pageUrl: pageUrl.toString(),
+ toEmail: email,
+ fromEmail: pageUrl.hostname + "@webstudio.email",
+ } as const;
+
+ const result = await n8nHandler({
+ formInfo,
+ hookUrl: context.N8N_FORM_EMAIL_HOOK as string,
+ });
+
+ return result;
+};
+
+const Outlet = () => {
+ const pagesCanvasData: PageData = pageData;
+
+ const page = pagesCanvasData.page;
+
+ if (page === undefined) {
+ throw json("Page not found", {
+ status: 404,
+ });
+ }
+
+ const params: Params = {
+ assetBaseUrl,
+ imageBaseUrl,
+ };
+
+ const data: RootPropsData = {
+ build: pagesCanvasData.build,
+ assets: pagesCanvasData.assets,
+ page,
+ pages: pagesCanvasData.pages,
+ params,
+ };
+
+ return (
+ <InstanceRoot
+ imageLoader={imageLoader}
+ data={data}
+ components={components}
+ utils={utils}
+ scripts={
+ <>
+ <Scripts />
+ <ScrollRestoration />
+ </>
+ }
+ />
+ );
+};
+
+export default Outlet;
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx
index 11c4b6d123..a9dd8e2bc5 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx
@@ -80,16 +80,16 @@ export const action = async ({ request, context }: ActionArgs) => {
const formData = await request.formData();
const formId = getFormId(formData);
- const formProperties =
- formId === undefined ? undefined : formsProperties.get(formId);
-
- if (formProperties === undefined) {
+ if (formId === undefined) {
// We're throwing rather than returning { success: false }
// because this isn't supposed to happen normally: bug or malicious user
throw json("Form not found", { status: 404 });
}
- const { action, method } = formProperties;
+ const formProperties = formsProperties.get(formId);
+
+ // form properties are not defined when defaults are used
+ const { action, method } = formProperties ?? {};
const email = user?.email;
diff --git a/fixtures/webstudio-remix-vercel/app/routes/_index.tsx b/fixtures/webstudio-remix-vercel/app/routes/_index.tsx
index 44f8332767..c516eda92f 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/_index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/_index.tsx
@@ -80,16 +80,16 @@ export const action = async ({ request, context }: ActionArgs) => {
const formData = await request.formData();
const formId = getFormId(formData);
- const formProperties =
- formId === undefined ? undefined : formsProperties.get(formId);
-
- if (formProperties === undefined) {
+ if (formId === undefined) {
// We're throwing rather than returning { success: false }
// because this isn't supposed to happen normally: bug or malicious user
throw json("Form not found", { status: 404 });
}
- const { action, method } = formProperties;
+ const formProperties = formsProperties.get(formId);
+
+ // form properties are not defined when defaults are used
+ const { action, method } = formProperties ?? {};
const email = user?.email;
diff --git a/packages/cli/templates/route-template.tsx b/packages/cli/templates/route-template.tsx
index 9e06fa89bc..cb137be5b8 100644
--- a/packages/cli/templates/route-template.tsx
+++ b/packages/cli/templates/route-template.tsx
@@ -80,16 +80,16 @@ export const action = async ({ request, context }: ActionArgs) => {
const formData = await request.formData();
const formId = getFormId(formData);
- const formProperties =
- formId === undefined ? undefined : formsProperties.get(formId);
-
- if (formProperties === undefined) {
+ if (formId === undefined) {
// We're throwing rather than returning { success: false }
// because this isn't supposed to happen normally: bug or malicious user
throw json("Form not found", { status: 404 });
}
- const { action, method } = formProperties;
+ const formProperties = formsProperties.get(formId);
+
+ // form properties are not defined when defaults are used
+ const { action, method } = formProperties ?? {};
const email = user?.email;