@webstudio-is/sdk-components-react-remix 0.79.0 → 0.81.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/__generated__/form.props.js +10 -1
- package/lib/cjs/__generated__/form.props.js +10 -1
- package/lib/cjs/form.js +2 -2
- package/lib/cjs/form.ws.js +1 -1
- package/lib/cjs/link.ws.js +1 -1
- package/lib/form.js +2 -2
- package/lib/form.ws.js +1 -1
- package/lib/link.ws.js +1 -1
- package/lib/types/form.d.ts +2 -0
- package/package.json +8 -8
- package/src/__generated__/form.props.ts +10 -1
- package/src/form.tsx +7 -4
- package/src/form.ws.tsx +1 -1
- package/src/link.ws.ts +1 -1
|
@@ -322,7 +322,16 @@ const props = {
|
|
|
322
322
|
defaultChecked: { required: false, control: "boolean", type: "boolean" },
|
|
323
323
|
dir: { required: false, control: "text", type: "string" },
|
|
324
324
|
draggable: { required: false, control: "boolean", type: "boolean" },
|
|
325
|
-
encType: {
|
|
325
|
+
encType: {
|
|
326
|
+
required: false,
|
|
327
|
+
control: "radio",
|
|
328
|
+
type: "string",
|
|
329
|
+
options: [
|
|
330
|
+
"application/x-www-form-urlencoded",
|
|
331
|
+
"multipart/form-data",
|
|
332
|
+
"text/plain"
|
|
333
|
+
]
|
|
334
|
+
},
|
|
326
335
|
hidden: { required: false, control: "boolean", type: "boolean" },
|
|
327
336
|
id: { required: false, control: "text", type: "string" },
|
|
328
337
|
inputMode: {
|
|
@@ -345,7 +345,16 @@ const props = {
|
|
|
345
345
|
defaultChecked: { required: false, control: "boolean", type: "boolean" },
|
|
346
346
|
dir: { required: false, control: "text", type: "string" },
|
|
347
347
|
draggable: { required: false, control: "boolean", type: "boolean" },
|
|
348
|
-
encType: {
|
|
348
|
+
encType: {
|
|
349
|
+
required: false,
|
|
350
|
+
control: "radio",
|
|
351
|
+
type: "string",
|
|
352
|
+
options: [
|
|
353
|
+
"application/x-www-form-urlencoded",
|
|
354
|
+
"multipart/form-data",
|
|
355
|
+
"text/plain"
|
|
356
|
+
]
|
|
357
|
+
},
|
|
349
358
|
hidden: { required: false, control: "boolean", type: "boolean" },
|
|
350
359
|
id: { required: false, control: "text", type: "string" },
|
|
351
360
|
inputMode: {
|
package/lib/cjs/form.js
CHANGED
|
@@ -40,12 +40,12 @@ const useOnFetchEnd = (fetcher, handler) => {
|
|
|
40
40
|
}, [fetcher]);
|
|
41
41
|
};
|
|
42
42
|
const Form = (0, import_react.forwardRef)(({ children, action, method, state = "initial", ...rest }, ref) => {
|
|
43
|
-
const {
|
|
43
|
+
const { setBoundDataSourceValue } = (0, import_react.useContext)(import_react_sdk.ReactSdkContext);
|
|
44
44
|
const fetcher = (0, import_react2.useFetcher)();
|
|
45
45
|
const instanceId = (0, import_react_sdk.getInstanceIdFromComponentProps)(rest);
|
|
46
46
|
useOnFetchEnd(fetcher, (data) => {
|
|
47
47
|
const state2 = data?.success === true ? "success" : "error";
|
|
48
|
-
|
|
48
|
+
setBoundDataSourceValue(instanceId, "state", state2);
|
|
49
49
|
});
|
|
50
50
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(fetcher.Form, { ...rest, method: "post", "data-state": state, ref, children: [
|
|
51
51
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "hidden", name: import_form_handlers.formIdFieldName, value: instanceId }),
|
package/lib/cjs/form.ws.js
CHANGED
package/lib/cjs/link.ws.js
CHANGED
package/lib/form.js
CHANGED
|
@@ -24,12 +24,12 @@ const useOnFetchEnd = (fetcher, handler) => {
|
|
|
24
24
|
}, [fetcher]);
|
|
25
25
|
};
|
|
26
26
|
const Form = forwardRef(({ children, action, method, state = "initial", ...rest }, ref) => {
|
|
27
|
-
const {
|
|
27
|
+
const { setBoundDataSourceValue } = useContext(ReactSdkContext);
|
|
28
28
|
const fetcher = useFetcher();
|
|
29
29
|
const instanceId = getInstanceIdFromComponentProps(rest);
|
|
30
30
|
useOnFetchEnd(fetcher, (data) => {
|
|
31
31
|
const state2 = data?.success === true ? "success" : "error";
|
|
32
|
-
|
|
32
|
+
setBoundDataSourceValue(instanceId, "state", state2);
|
|
33
33
|
});
|
|
34
34
|
return /* @__PURE__ */ jsxs(fetcher.Form, { ...rest, method: "post", "data-state": state, ref, children: [
|
|
35
35
|
/* @__PURE__ */ jsx("input", { type: "hidden", name: formIdFieldName, value: instanceId }),
|
package/lib/form.ws.js
CHANGED
package/lib/link.ws.js
CHANGED
package/lib/types/form.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { type FormProps } from "@remix-run/react";
|
|
2
3
|
export declare const defaultTag = "form";
|
|
3
4
|
type State = "initial" | "success" | "error";
|
|
4
5
|
export declare const Form: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLFormElement> & import("react").FormHTMLAttributes<HTMLFormElement> & {
|
|
5
6
|
state?: State | undefined;
|
|
7
|
+
encType?: FormProps["encType"];
|
|
6
8
|
}, "ref"> & import("react").RefAttributes<HTMLFormElement>>;
|
|
7
9
|
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.81.0",
|
|
4
4
|
"description": "Webstudio components for Remix",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -33,19 +33,19 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@remix-run/react": "^1.
|
|
36
|
+
"@remix-run/react": "^1.18.0",
|
|
37
37
|
"react": "^18.2.0",
|
|
38
38
|
"react-dom": "^18.2.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@webstudio-is/form-handlers": "^0.
|
|
42
|
-
"@webstudio-is/generate-arg-types": "^0.
|
|
43
|
-
"@webstudio-is/icons": "^0.
|
|
44
|
-
"@webstudio-is/react-sdk": "^0.
|
|
45
|
-
"@webstudio-is/sdk-components-react": "^0.
|
|
41
|
+
"@webstudio-is/form-handlers": "^0.81.0",
|
|
42
|
+
"@webstudio-is/generate-arg-types": "^0.81.0",
|
|
43
|
+
"@webstudio-is/icons": "^0.81.0",
|
|
44
|
+
"@webstudio-is/react-sdk": "^0.81.0",
|
|
45
|
+
"@webstudio-is/sdk-components-react": "^0.81.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@remix-run/react": "^1.
|
|
48
|
+
"@remix-run/react": "^1.18.1",
|
|
49
49
|
"@types/react": "^18.0.35",
|
|
50
50
|
"@types/react-dom": "^18.0.11",
|
|
51
51
|
"react": "^18.2.0",
|
|
@@ -368,7 +368,16 @@ export const props: Record<string, PropMeta> = {
|
|
|
368
368
|
defaultChecked: { required: false, control: "boolean", type: "boolean" },
|
|
369
369
|
dir: { required: false, control: "text", type: "string" },
|
|
370
370
|
draggable: { required: false, control: "boolean", type: "boolean" },
|
|
371
|
-
encType: {
|
|
371
|
+
encType: {
|
|
372
|
+
required: false,
|
|
373
|
+
control: "radio",
|
|
374
|
+
type: "string",
|
|
375
|
+
options: [
|
|
376
|
+
"application/x-www-form-urlencoded",
|
|
377
|
+
"multipart/form-data",
|
|
378
|
+
"text/plain",
|
|
379
|
+
],
|
|
380
|
+
},
|
|
372
381
|
hidden: { required: false, control: "boolean", type: "boolean" },
|
|
373
382
|
id: { required: false, control: "text", type: "string" },
|
|
374
383
|
inputMode: {
|
package/src/form.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
useEffect,
|
|
7
7
|
useContext,
|
|
8
8
|
} from "react";
|
|
9
|
-
import { useFetcher, type Fetcher } from "@remix-run/react";
|
|
9
|
+
import { useFetcher, type Fetcher, type FormProps } from "@remix-run/react";
|
|
10
10
|
import { formIdFieldName } from "@webstudio-is/form-handlers";
|
|
11
11
|
import {
|
|
12
12
|
ReactSdkContext,
|
|
@@ -39,9 +39,12 @@ type State = "initial" | "success" | "error";
|
|
|
39
39
|
|
|
40
40
|
export const Form = forwardRef<
|
|
41
41
|
ElementRef<typeof defaultTag>,
|
|
42
|
-
ComponentProps<typeof defaultTag> & {
|
|
42
|
+
ComponentProps<typeof defaultTag> & {
|
|
43
|
+
state?: State;
|
|
44
|
+
encType?: FormProps["encType"];
|
|
45
|
+
}
|
|
43
46
|
>(({ children, action, method, state = "initial", ...rest }, ref) => {
|
|
44
|
-
const {
|
|
47
|
+
const { setBoundDataSourceValue } = useContext(ReactSdkContext);
|
|
45
48
|
|
|
46
49
|
const fetcher = useFetcher();
|
|
47
50
|
|
|
@@ -49,7 +52,7 @@ export const Form = forwardRef<
|
|
|
49
52
|
|
|
50
53
|
useOnFetchEnd(fetcher, (data) => {
|
|
51
54
|
const state: State = data?.success === true ? "success" : "error";
|
|
52
|
-
|
|
55
|
+
setBoundDataSourceValue(instanceId, "state", state);
|
|
53
56
|
});
|
|
54
57
|
|
|
55
58
|
return (
|
package/src/form.ws.tsx
CHANGED
package/src/link.ws.ts
CHANGED