@webstudio-is/sdk-components-react-router 0.268.0 → 0.270.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 CHANGED
@@ -12,28 +12,17 @@ var Body = forwardRef(
12
12
  Body.displayName = "Body";
13
13
 
14
14
  // src/link.tsx
15
- import { forwardRef as forwardRef2, useContext } from "react";
16
- import { NavLink as RemixLink } from "react-router";
17
- import { ReactSdkContext } from "@webstudio-is/react-sdk/runtime";
18
- import { Link as BaseLink } from "@webstudio-is/sdk-components-react";
19
- import { jsx as jsx2 } from "react/jsx-runtime";
20
- var Link = forwardRef2((props, ref) => {
21
- const { assetBaseUrl } = useContext(ReactSdkContext);
22
- const href = String(props.href ?? "");
23
- if (
24
- // remix appends ?index in runtime but not in ssr
25
- href === "" || href.startsWith("?") || href.startsWith("/") && href.startsWith(assetBaseUrl) === false
26
- ) {
27
- return /* @__PURE__ */ jsx2(RemixLink, { ...props, to: href, ref, end: true });
28
- }
29
- const { prefetch, reloadDocument, replace, preventScrollReset, ...rest } = props;
30
- return /* @__PURE__ */ jsx2(BaseLink, { ...rest, ref });
15
+ import { Link as RouterLink, useLocation, useResolvedPath } from "react-router";
16
+ import { createLink } from "@webstudio-is/sdk-components-react";
17
+ var Link = createLink({
18
+ Link: RouterLink,
19
+ useLocation,
20
+ useResolvedPath
31
21
  });
32
- Link.displayName = BaseLink.displayName;
33
22
 
34
23
  // src/webhook-form.tsx
35
24
  import {
36
- forwardRef as forwardRef3,
25
+ forwardRef as forwardRef2,
37
26
  useRef,
38
27
  useEffect
39
28
  } from "react";
@@ -43,7 +32,7 @@ import {
43
32
  formBotFieldName,
44
33
  isBraveBrowser
45
34
  } from "@webstudio-is/sdk/runtime";
46
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
35
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
47
36
  var useOnFetchEnd = (fetcher, handler) => {
48
37
  const latestHandler = useRef(handler);
49
38
  latestHandler.current = handler;
@@ -81,7 +70,7 @@ var isJSDom = () => {
81
70
  const hasMatchMedia = matchAspectRatio && matchWidthHeight && !matchWidthHeightFail && matchLight !== matchDark;
82
71
  return hasMatchMedia === false;
83
72
  };
84
- var WebhookForm = forwardRef3(
73
+ var WebhookForm = forwardRef2(
85
74
  ({ children, action, method, state = "initial", onStateChange, ...rest }, ref) => {
86
75
  const fetcher = useFetcher();
87
76
  useOnFetchEnd(fetcher, (data) => {
@@ -108,7 +97,7 @@ var WebhookForm = forwardRef3(
108
97
  ref,
109
98
  onSubmit: handleSubmitAndAddHiddenJsField,
110
99
  children: [
111
- /* @__PURE__ */ jsx3(
100
+ /* @__PURE__ */ jsx2(
112
101
  "input",
113
102
  {
114
103
  type: "hidden",
@@ -125,15 +114,15 @@ var WebhookForm = forwardRef3(
125
114
  WebhookForm.displayName = "WebhookForm";
126
115
 
127
116
  // src/remix-form.tsx
128
- import { forwardRef as forwardRef4 } from "react";
117
+ import { forwardRef as forwardRef3 } from "react";
129
118
  import { Form } from "react-router";
130
- import { jsx as jsx4 } from "react/jsx-runtime";
131
- var RemixForm = forwardRef4(({ action, method, ...props }, ref) => {
119
+ import { jsx as jsx3 } from "react/jsx-runtime";
120
+ var RemixForm = forwardRef3(({ action, method, ...props }, ref) => {
132
121
  if (method === "dialog") {
133
- return /* @__PURE__ */ jsx4("form", { ...props, ref });
122
+ return /* @__PURE__ */ jsx3("form", { ...props, ref });
134
123
  }
135
124
  if (action === void 0 || action === "" || typeof action === "string" && action?.startsWith("/")) {
136
- return /* @__PURE__ */ jsx4(
125
+ return /* @__PURE__ */ jsx3(
137
126
  Form,
138
127
  {
139
128
  action,
@@ -144,7 +133,7 @@ var RemixForm = forwardRef4(({ action, method, ...props }, ref) => {
144
133
  }
145
134
  );
146
135
  }
147
- return /* @__PURE__ */ jsx4("form", { ...props, ref });
136
+ return /* @__PURE__ */ jsx3("form", { ...props, ref });
148
137
  });
149
138
  RemixForm.displayName = "Form";
150
139
  export {
@@ -2,15 +2,23 @@ export declare const Link: import("react").ForwardRefExoticComponent<Omit<Omit<O
2
2
  target?: "_self" | "_blank" | "_parent" | "_top";
3
3
  download?: boolean;
4
4
  prefetch?: "none" | "intent" | "render" | "viewport";
5
+ discover?: "render" | "none";
5
6
  preventScrollReset?: boolean;
6
7
  reloadDocument?: boolean;
7
8
  replace?: boolean;
9
+ relative?: "route" | "path";
10
+ state?: unknown;
11
+ viewTransition?: boolean;
8
12
  } & {
9
13
  $webstudio$canvasOnly$assetId?: string | undefined;
10
14
  }, "ref"> & import("react").RefAttributes<HTMLAnchorElement>, "ref">, "target"> & {
11
15
  target?: "_self" | "_blank" | "_parent" | "_top";
12
16
  prefetch?: "none" | "intent" | "render" | "viewport";
17
+ discover?: "render" | "none";
13
18
  reloadDocument?: boolean;
14
19
  replace?: boolean;
15
20
  preventScrollReset?: boolean;
21
+ relative?: "route" | "path";
22
+ state?: unknown;
23
+ viewTransition?: boolean;
16
24
  } & import("react").RefAttributes<HTMLAnchorElement>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/sdk-components-react-router",
3
- "version": "0.268.0",
3
+ "version": "0.270.0",
4
4
  "description": "Webstudio components for React Router",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -25,20 +25,22 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "react-router": "^7.5.3",
28
- "@webstudio-is/react-sdk": "0.268.0",
29
- "@webstudio-is/sdk": "0.268.0",
30
- "@webstudio-is/sdk-components-react": "0.268.0"
28
+ "@webstudio-is/react-sdk": "0.270.0",
29
+ "@webstudio-is/sdk": "0.270.0",
30
+ "@webstudio-is/sdk-components-react": "0.270.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/react": "^18.2.70",
34
34
  "@types/react-dom": "^18.2.25",
35
35
  "react": "18.3.0-canary-14898b6a9-20240318",
36
36
  "react-dom": "18.3.0-canary-14898b6a9-20240318",
37
+ "vitest": "^3.1.2",
37
38
  "@webstudio-is/tsconfig": "1.0.7"
38
39
  },
39
40
  "scripts": {
40
41
  "build": "rm -rf lib && esbuild src/components.ts --outdir=lib --bundle --format=esm --packages=external",
41
42
  "dts": "tsc --project tsconfig.dts.json",
43
+ "test": "vitest run",
42
44
  "typecheck": "tsgo --noEmit"
43
45
  }
44
46
  }