@webstudio-is/sdk-components-react-router 0.198.0 → 0.199.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/body.js ADDED
@@ -0,0 +1,14 @@
1
+ import { jsxs as m, jsx as o } from "react/jsx-runtime";
2
+ import { forwardRef as s } from "react";
3
+ import { Scripts as d, ScrollRestoration as p } from "react-router";
4
+ const e = s(
5
+ ({ children: r, ...t }, i) => /* @__PURE__ */ m("body", { ...t, ref: i, children: [
6
+ r,
7
+ /* @__PURE__ */ o(d, {}),
8
+ /* @__PURE__ */ o(p, {})
9
+ ] })
10
+ );
11
+ e.displayName = "Body";
12
+ export {
13
+ e as Body
14
+ };
@@ -0,0 +1,12 @@
1
+ import { Body as m } from "./body.js";
2
+ import { Link as x } from "./link.js";
3
+ import { RichTextLink as f } from "./rich-text-link.js";
4
+ import { WebhookForm as i } from "./webhook-form.js";
5
+ import { RemixForm as F } from "./remix-form.js";
6
+ export {
7
+ m as Body,
8
+ i as Form,
9
+ x as Link,
10
+ F as RemixForm,
11
+ f as RichTextLink
12
+ };
package/lib/hooks.js ADDED
@@ -0,0 +1 @@
1
+
package/lib/link.js ADDED
@@ -0,0 +1,6 @@
1
+ import { Link as o } from "@webstudio-is/sdk-components-react";
2
+ import { wrapLinkComponent as n } from "./shared/remix-link.js";
3
+ const m = n(o);
4
+ export {
5
+ m as Link
6
+ };
package/lib/metas.js ADDED
@@ -0,0 +1,8 @@
1
+ import { Body as m, Form as r, Link as e, RemixForm as x, RichTextLink as k } from "@webstudio-is/sdk-components-react/metas";
2
+ export {
3
+ m as Body,
4
+ r as Form,
5
+ e as Link,
6
+ x as RemixForm,
7
+ k as RichTextLink
8
+ };
package/lib/props.js ADDED
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,16 @@
1
+ import { jsx as f } from "react/jsx-runtime";
2
+ import { forwardRef as o } from "react";
3
+ import { Form as s } from "react-router";
4
+ const p = o(({ action: r, ...m }, e) => r === void 0 || r === "" || typeof r == "string" && (r != null && r.startsWith("/")) ? /* @__PURE__ */ f(
5
+ s,
6
+ {
7
+ action: r,
8
+ ...m,
9
+ ref: e,
10
+ preventScrollReset: r === void 0 || r === ""
11
+ }
12
+ ) : /* @__PURE__ */ f("form", { ...m, ref: e }));
13
+ p.displayName = "Form";
14
+ export {
15
+ p as RemixForm
16
+ };
@@ -0,0 +1,6 @@
1
+ import { RichTextLink as i } from "@webstudio-is/sdk-components-react";
2
+ import { wrapLinkComponent as o } from "./shared/remix-link.js";
3
+ const r = o(i);
4
+ export {
5
+ r as RichTextLink
6
+ };
@@ -0,0 +1,20 @@
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import { forwardRef as m, useContext as c } from "react";
3
+ import { NavLink as f } from "react-router";
4
+ import { ReactSdkContext as p } from "@webstudio-is/react-sdk/runtime";
5
+ const R = (e) => {
6
+ const o = m((r, s) => {
7
+ const { assetBaseUrl: a } = c(p), t = String(r.href ?? "");
8
+ if (
9
+ // remix appends ?index in runtime but not in ssr
10
+ t === "" || t.startsWith("?") || t.startsWith("#") || t.startsWith("/") && t.startsWith(a) === !1
11
+ )
12
+ return /* @__PURE__ */ n(f, { ...r, to: t, ref: s, end: !0 });
13
+ const { prefetch: l, reloadDocument: h, replace: d, preventScrollReset: u, ...i } = r;
14
+ return /* @__PURE__ */ n(e, { ...i, ref: s });
15
+ });
16
+ return o.displayName = e.displayName, o;
17
+ };
18
+ export {
19
+ R as wrapLinkComponent
20
+ };
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+ export declare const Body: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLBodyElement>, HTMLBodyElement>, "ref"> & import("react").RefAttributes<HTMLBodyElement>>;
@@ -0,0 +1,5 @@
1
+ export { Body } from "./body";
2
+ export { Link } from "./link";
3
+ export { RichTextLink } from "./rich-text-link";
4
+ export { WebhookForm as Form } from "./webhook-form";
5
+ export { RemixForm } from "./remix-form";
File without changes
@@ -0,0 +1,16 @@
1
+ export declare const Link: import("react").ForwardRefExoticComponent<Omit<Omit<Omit<Omit<import("react").DetailedHTMLProps<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "target" | "download"> & {
2
+ target?: "_self" | "_blank" | "_parent" | "_top";
3
+ download?: boolean;
4
+ prefetch?: "none" | "intent" | "render" | "viewport";
5
+ preventScrollReset?: boolean;
6
+ reloadDocument?: boolean;
7
+ replace?: boolean;
8
+ } & {
9
+ $webstudio$canvasOnly$assetId?: string | undefined;
10
+ }, "ref"> & import("react").RefAttributes<HTMLAnchorElement>, "ref">, "target"> & {
11
+ target?: "_self" | "_blank" | "_parent" | "_top";
12
+ prefetch?: "none" | "intent" | "render" | "viewport";
13
+ reloadDocument?: boolean;
14
+ replace?: boolean;
15
+ preventScrollReset?: boolean;
16
+ } & import("react").RefAttributes<HTMLAnchorElement>>;
@@ -0,0 +1 @@
1
+ export { Body, Link, RichTextLink, Form, RemixForm, } from "@webstudio-is/sdk-components-react/metas";
File without changes
@@ -0,0 +1,6 @@
1
+ import { type FormProps } from "react-router";
2
+ export declare const defaultTag = "form";
3
+ export declare const RemixForm: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "action"> & Pick<FormProps, "encType"> & {
4
+ method?: Lowercase<NonNullable<FormProps["method"]>>;
5
+ action?: string;
6
+ }, "ref"> & import("react").RefAttributes<HTMLFormElement>>;
@@ -0,0 +1,16 @@
1
+ export declare const RichTextLink: import("react").ForwardRefExoticComponent<Omit<Omit<Omit<Omit<import("react").DetailedHTMLProps<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "target" | "download"> & {
2
+ target?: "_self" | "_blank" | "_parent" | "_top";
3
+ download?: boolean;
4
+ prefetch?: "none" | "intent" | "render" | "viewport";
5
+ preventScrollReset?: boolean;
6
+ reloadDocument?: boolean;
7
+ replace?: boolean;
8
+ } & {
9
+ $webstudio$canvasOnly$assetId?: string | undefined;
10
+ }, "ref"> & import("react").RefAttributes<HTMLAnchorElement>, "ref">, "target"> & {
11
+ target?: "_self" | "_blank" | "_parent" | "_top";
12
+ prefetch?: "none" | "intent" | "render" | "viewport";
13
+ reloadDocument?: boolean;
14
+ replace?: boolean;
15
+ preventScrollReset?: boolean;
16
+ } & import("react").RefAttributes<HTMLAnchorElement>>;
@@ -0,0 +1,17 @@
1
+ import type { Link } from "@webstudio-is/sdk-components-react";
2
+ export declare const wrapLinkComponent: (BaseLink: typeof Link) => import("react").ForwardRefExoticComponent<Omit<Omit<Omit<Omit<import("react").DetailedHTMLProps<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "target" | "download"> & {
3
+ target?: "_self" | "_blank" | "_parent" | "_top";
4
+ download?: boolean;
5
+ prefetch?: "none" | "intent" | "render" | "viewport";
6
+ preventScrollReset?: boolean;
7
+ reloadDocument?: boolean;
8
+ replace?: boolean;
9
+ } & {
10
+ $webstudio$canvasOnly$assetId?: string | undefined;
11
+ }, "ref"> & import("react").RefAttributes<HTMLAnchorElement>, "ref">, "target"> & {
12
+ target?: "_self" | "_blank" | "_parent" | "_top";
13
+ prefetch?: "none" | "intent" | "render" | "viewport";
14
+ reloadDocument?: boolean;
15
+ replace?: boolean;
16
+ preventScrollReset?: boolean;
17
+ } & import("react").RefAttributes<HTMLAnchorElement>>;
File without changes
@@ -0,0 +1,11 @@
1
+ import { type FormProps } from "react-router";
2
+ export declare const defaultTag = "form";
3
+ type State = "initial" | "success" | "error";
4
+ export declare const WebhookForm: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "action"> & {
5
+ /** 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. */
6
+ state?: State;
7
+ encType?: FormProps["encType"];
8
+ onStateChange?: (state: State) => void;
9
+ action?: string;
10
+ }, "ref"> & import("react").RefAttributes<HTMLFormElement>>;
11
+ export {};
@@ -0,0 +1,63 @@
1
+ import { jsxs as u, jsx as l } from "react/jsx-runtime";
2
+ import { forwardRef as f, useRef as h, useEffect as v } from "react";
3
+ import { useFetcher as F } from "react-router";
4
+ import { formIdFieldName as M, formBotFieldName as g } from "@webstudio-is/sdk/runtime";
5
+ const x = (t, e) => {
6
+ const c = h(e);
7
+ c.current = e;
8
+ const s = h(t);
9
+ v(() => {
10
+ s.current.state !== t.state && t.state === "idle" && t.data !== void 0 && c.current(t.data), s.current = t;
11
+ }, [t]);
12
+ }, p = (t, e) => e === 0 ? t : p(e, t % e), R = (t, e) => {
13
+ const c = p(t, e);
14
+ return `${t / c}/${e / c}`;
15
+ }, $ = () => {
16
+ if (typeof matchMedia > "u")
17
+ return !0;
18
+ const { width: t, height: e } = screen, c = R(t, e), s = matchMedia(
19
+ `(device-aspect-ratio: ${c})`
20
+ ).matches, o = matchMedia(
21
+ `(device-width: ${t}px) and (device-height: ${e}px)`
22
+ ).matches, a = matchMedia(
23
+ `(device-width: ${t - 1}px) and (device-height: ${e}px)`
24
+ ).matches, n = matchMedia("(prefers-color-scheme: light)").matches, d = matchMedia("(prefers-color-scheme: dark)").matches;
25
+ return (s && o && !a && n !== d) === !1;
26
+ }, A = f(
27
+ ({ children: t, action: e, method: c, state: s = "initial", onStateChange: o, ...a }, n) => {
28
+ const d = F();
29
+ x(d, (r) => {
30
+ const i = (r == null ? void 0 : r.success) === !0 ? "success" : "error";
31
+ o == null || o(i);
32
+ });
33
+ const m = (r) => {
34
+ const i = document.createElement("input");
35
+ i.type = "hidden", i.name = g, i.value = $() ? "jsdom" : Date.now().toString(16), r.currentTarget.appendChild(i);
36
+ };
37
+ return /* @__PURE__ */ u(
38
+ d.Form,
39
+ {
40
+ ...a,
41
+ method: "post",
42
+ "data-state": s,
43
+ ref: n,
44
+ onSubmit: m,
45
+ children: [
46
+ /* @__PURE__ */ l(
47
+ "input",
48
+ {
49
+ type: "hidden",
50
+ name: M,
51
+ value: e == null ? void 0 : e.toString()
52
+ }
53
+ ),
54
+ t
55
+ ]
56
+ }
57
+ );
58
+ }
59
+ );
60
+ A.displayName = "WebhookForm";
61
+ export {
62
+ A as WebhookForm
63
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/sdk-components-react-router",
3
- "version": "0.198.0",
3
+ "version": "0.199.0",
4
4
  "description": "Webstudio components for React Router",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -35,9 +35,9 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "react-router": "^7.1.1",
38
- "@webstudio-is/react-sdk": "0.198.0",
39
- "@webstudio-is/sdk": "0.198.0",
40
- "@webstudio-is/sdk-components-react": "0.198.0"
38
+ "@webstudio-is/react-sdk": "0.199.0",
39
+ "@webstudio-is/sdk-components-react": "0.199.0",
40
+ "@webstudio-is/sdk": "0.199.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/react": "^18.2.70",