@webstudio-is/sdk-components-react-remix 0.100.0 → 0.100.1-d89b38d.0
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/lib/components.js +14 -20
- package/lib/types/form.d.ts +1 -1
- package/package.json +11 -11
package/lib/components.js
CHANGED
|
@@ -57,26 +57,20 @@ var useOnFetchEnd = (fetcher, handler) => {
|
|
|
57
57
|
prevFetcher.current = fetcher;
|
|
58
58
|
}, [fetcher]);
|
|
59
59
|
};
|
|
60
|
-
var Form = forwardRef2(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
});
|
|
75
|
-
return /* @__PURE__ */ jsxs(fetcher.Form, { ...rest, method: "post", "data-state": state, ref, children: [
|
|
76
|
-
/* @__PURE__ */ jsx2("input", { type: "hidden", name: formIdFieldName, value: instanceId }),
|
|
77
|
-
children
|
|
78
|
-
] });
|
|
79
|
-
});
|
|
60
|
+
var Form = forwardRef2(
|
|
61
|
+
({ children, action, method, state = "initial", onStateChange, ...rest }, ref) => {
|
|
62
|
+
const fetcher = useFetcher();
|
|
63
|
+
const instanceId = getInstanceIdFromComponentProps2(rest);
|
|
64
|
+
useOnFetchEnd(fetcher, (data) => {
|
|
65
|
+
const state2 = data?.success === true ? "success" : "error";
|
|
66
|
+
onStateChange?.(state2);
|
|
67
|
+
});
|
|
68
|
+
return /* @__PURE__ */ jsxs(fetcher.Form, { ...rest, method: "post", "data-state": state, ref, children: [
|
|
69
|
+
/* @__PURE__ */ jsx2("input", { type: "hidden", name: formIdFieldName, value: instanceId }),
|
|
70
|
+
children
|
|
71
|
+
] });
|
|
72
|
+
}
|
|
73
|
+
);
|
|
80
74
|
Form.displayName = "Form";
|
|
81
75
|
export {
|
|
82
76
|
Form,
|
package/lib/types/form.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare const defaultTag = "form";
|
|
|
4
4
|
type State = "initial" | "success" | "error";
|
|
5
5
|
export declare const Form: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLFormElement> & import("react").FormHTMLAttributes<HTMLFormElement> & {
|
|
6
6
|
/** Use this property to reveal the Success and Error states on the canvas so they can be styled. The Initial state is displayed when the page first opens. The Success and Error states are displayed depending on whether the Form submits successfully or unsuccessfully. */
|
|
7
|
-
state
|
|
7
|
+
state?: State | undefined;
|
|
8
8
|
encType?: FormProps["encType"];
|
|
9
9
|
onStateChange?: ((state: State) => void) | undefined;
|
|
10
10
|
}, "ref"> & import("react").RefAttributes<HTMLFormElement>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/sdk-components-react-remix",
|
|
3
|
-
"version": "0.100.0",
|
|
3
|
+
"version": "0.100.1-d89b38d.0",
|
|
4
4
|
"description": "Webstudio components for Remix",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -14,19 +14,19 @@
|
|
|
14
14
|
"sideEffects": false,
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
17
|
-
"
|
|
17
|
+
"webstudio": "./src/components.ts",
|
|
18
18
|
"types": "./lib/types/components.d.ts",
|
|
19
19
|
"import": "./lib/components.js",
|
|
20
20
|
"require": "./lib/components.js"
|
|
21
21
|
},
|
|
22
22
|
"./metas": {
|
|
23
|
-
"
|
|
23
|
+
"webstudio": "./src/metas.ts",
|
|
24
24
|
"types": "./lib/types/metas.d.ts",
|
|
25
25
|
"import": "./lib/metas.js",
|
|
26
26
|
"require": "./lib/metas.js"
|
|
27
27
|
},
|
|
28
28
|
"./props": {
|
|
29
|
-
"
|
|
29
|
+
"webstudio": "./src/props.ts",
|
|
30
30
|
"types": "./lib/types/props.d.ts",
|
|
31
31
|
"import": "./lib/props.js",
|
|
32
32
|
"require": "./lib/props.js"
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"react-dom": "^18.2.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@webstudio-is/form-handlers": "0.100.0",
|
|
42
|
-
"@webstudio-is/icons": "0.100.0",
|
|
43
|
-
"@webstudio-is/react-sdk": "0.100.0",
|
|
44
|
-
"@webstudio-is/sdk-components-react": "0.100.0"
|
|
41
|
+
"@webstudio-is/form-handlers": "0.100.1-d89b38d.0",
|
|
42
|
+
"@webstudio-is/icons": "0.100.1-d89b38d.0",
|
|
43
|
+
"@webstudio-is/react-sdk": "0.100.1-d89b38d.0",
|
|
44
|
+
"@webstudio-is/sdk-components-react": "0.100.1-d89b38d.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@remix-run/react": "^1.19.2",
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
"react": "^18.2.0",
|
|
51
51
|
"react-dom": "^18.2.0",
|
|
52
52
|
"typescript": "5.2.2",
|
|
53
|
-
"@webstudio-is/generate-arg-types": "0.100.0",
|
|
54
|
-
"@webstudio-is/tsconfig": "1.0.
|
|
53
|
+
"@webstudio-is/generate-arg-types": "0.100.1-d89b38d.0",
|
|
54
|
+
"@webstudio-is/tsconfig": "1.0.8-d89b38d.0"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"dev": "rm -rf lib && esbuild 'src/**/*.ts' 'src/**/*.tsx' --outdir=lib --watch",
|
|
58
58
|
"build": "rm -rf lib && esbuild src/components.ts src/metas.ts src/props.ts --outdir=lib --bundle --format=esm --packages=external",
|
|
59
|
-
"build:args": "NODE_OPTIONS=--conditions=
|
|
59
|
+
"build:args": "NODE_OPTIONS=--conditions=webstudio generate-arg-types './src/*.tsx !./src/**/*.stories.tsx !./src/**/*.ws.tsx' && prettier --write \"**/*.props.ts\"",
|
|
60
60
|
"dts": "tsc --project tsconfig.dts.json",
|
|
61
61
|
"typecheck": "tsc",
|
|
62
62
|
"checks": "pnpm typecheck"
|