@webstudio-is/sdk-components-react-remix 0.98.0 → 0.99.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 +12 -9
- package/lib/metas.js +7 -0
- package/lib/types/form.d.ts +2 -1
- package/package.json +6 -6
package/lib/components.js
CHANGED
|
@@ -40,15 +40,11 @@ var RichTextLink = wrapLinkComponent(BaseLink2);
|
|
|
40
40
|
import {
|
|
41
41
|
forwardRef as forwardRef2,
|
|
42
42
|
useRef,
|
|
43
|
-
useEffect
|
|
44
|
-
useContext
|
|
43
|
+
useEffect
|
|
45
44
|
} from "react";
|
|
46
45
|
import { useFetcher } from "@remix-run/react";
|
|
47
46
|
import { formIdFieldName } from "@webstudio-is/form-handlers";
|
|
48
|
-
import {
|
|
49
|
-
ReactSdkContext,
|
|
50
|
-
getInstanceIdFromComponentProps as getInstanceIdFromComponentProps2
|
|
51
|
-
} from "@webstudio-is/react-sdk";
|
|
47
|
+
import { getInstanceIdFromComponentProps as getInstanceIdFromComponentProps2 } from "@webstudio-is/react-sdk";
|
|
52
48
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
53
49
|
var useOnFetchEnd = (fetcher, handler) => {
|
|
54
50
|
const latestHandler = useRef(handler);
|
|
@@ -61,13 +57,20 @@ var useOnFetchEnd = (fetcher, handler) => {
|
|
|
61
57
|
prevFetcher.current = fetcher;
|
|
62
58
|
}, [fetcher]);
|
|
63
59
|
};
|
|
64
|
-
var Form = forwardRef2((
|
|
65
|
-
const {
|
|
60
|
+
var Form = forwardRef2((props, ref) => {
|
|
61
|
+
const {
|
|
62
|
+
children,
|
|
63
|
+
action,
|
|
64
|
+
method,
|
|
65
|
+
state = "initial",
|
|
66
|
+
onStateChange,
|
|
67
|
+
...rest
|
|
68
|
+
} = props;
|
|
66
69
|
const fetcher = useFetcher();
|
|
67
70
|
const instanceId = getInstanceIdFromComponentProps2(rest);
|
|
68
71
|
useOnFetchEnd(fetcher, (data) => {
|
|
69
72
|
const state2 = data?.success === true ? "success" : "error";
|
|
70
|
-
|
|
73
|
+
onStateChange?.(state2);
|
|
71
74
|
});
|
|
72
75
|
return /* @__PURE__ */ jsxs(fetcher.Form, { ...rest, method: "post", "data-state": state, ref, children: [
|
|
73
76
|
/* @__PURE__ */ jsx2("input", { type: "hidden", name: formIdFieldName, value: instanceId }),
|
package/lib/metas.js
CHANGED
|
@@ -625,6 +625,13 @@ var meta = {
|
|
|
625
625
|
type: "dataSource",
|
|
626
626
|
name: "state",
|
|
627
627
|
dataSourceName: "formState"
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
type: "action",
|
|
631
|
+
name: "onStateChange",
|
|
632
|
+
value: [
|
|
633
|
+
{ type: "execute", args: ["state"], code: `formState = state` }
|
|
634
|
+
]
|
|
628
635
|
}
|
|
629
636
|
],
|
|
630
637
|
children: [
|
package/lib/types/form.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ 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;
|
|
8
8
|
encType?: FormProps["encType"];
|
|
9
|
+
onStateChange?: ((state: State) => void) | undefined;
|
|
9
10
|
}, "ref"> & import("react").RefAttributes<HTMLFormElement>>;
|
|
10
11
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/sdk-components-react-remix",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.99.0",
|
|
4
4
|
"description": "Webstudio components for Remix",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"react-dom": "^18.2.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@webstudio-is/form-handlers": "^0.
|
|
42
|
-
"@webstudio-is/icons": "^0.
|
|
43
|
-
"@webstudio-is/react-sdk": "^0.
|
|
44
|
-
"@webstudio-is/sdk-components-react": "^0.
|
|
41
|
+
"@webstudio-is/form-handlers": "^0.99.0",
|
|
42
|
+
"@webstudio-is/icons": "^0.99.0",
|
|
43
|
+
"@webstudio-is/react-sdk": "^0.99.0",
|
|
44
|
+
"@webstudio-is/sdk-components-react": "^0.99.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@remix-run/react": "^1.19.2",
|
|
@@ -50,7 +50,7 @@
|
|
|
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.
|
|
53
|
+
"@webstudio-is/generate-arg-types": "^0.99.0",
|
|
54
54
|
"@webstudio-is/tsconfig": "^1.0.7"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|