@webstudio-is/sdk-components-react-remix 0.100.1-c4ae8b2.0 → 0.101.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.
Files changed (2) hide show
  1. package/lib/components.js +10 -16
  2. package/package.json +11 -11
package/lib/components.js CHANGED
@@ -2,25 +2,19 @@
2
2
  import { Link as BaseLink } from "@webstudio-is/sdk-components-react";
3
3
 
4
4
  // src/shared/remix-link.tsx
5
- import { forwardRef } from "react";
5
+ import { forwardRef, useContext } from "react";
6
6
  import { NavLink as RemixLink } from "@remix-run/react";
7
- import {
8
- usePropUrl,
9
- getInstanceIdFromComponentProps
10
- } from "@webstudio-is/react-sdk";
7
+ import { ReactSdkContext } from "@webstudio-is/react-sdk";
11
8
  import { jsx } from "react/jsx-runtime";
12
9
  var wrapLinkComponent = (BaseLink3) => {
13
10
  const Component = forwardRef((props, ref) => {
14
- const href = usePropUrl(getInstanceIdFromComponentProps(props), "href");
15
- if (href?.type === "page") {
16
- let to = href.page.path === "" ? "/" : href.page.path;
17
- const urlTo = new URL(to, "https://any-valid.url");
18
- to = urlTo.pathname;
19
- if (href.hash !== void 0) {
20
- urlTo.hash = encodeURIComponent(href.hash);
21
- to = `${urlTo.pathname}${urlTo.hash}`;
11
+ const { pagesPaths } = useContext(ReactSdkContext);
12
+ const href = props.href;
13
+ if (href !== void 0) {
14
+ const url = new URL(href, "https://any-valid.url");
15
+ if (pagesPaths.has(url.pathname === "/" ? "" : url.pathname)) {
16
+ return /* @__PURE__ */ jsx(RemixLink, { ...props, to: href, ref });
22
17
  }
23
- return /* @__PURE__ */ jsx(RemixLink, { ...props, to, ref });
24
18
  }
25
19
  const { prefetch, reloadDocument, replace, preventScrollReset, ...rest } = props;
26
20
  return /* @__PURE__ */ jsx(BaseLink3, { ...rest, ref });
@@ -44,7 +38,7 @@ import {
44
38
  } from "react";
45
39
  import { useFetcher } from "@remix-run/react";
46
40
  import { formIdFieldName } from "@webstudio-is/form-handlers";
47
- import { getInstanceIdFromComponentProps as getInstanceIdFromComponentProps2 } from "@webstudio-is/react-sdk";
41
+ import { getInstanceIdFromComponentProps } from "@webstudio-is/react-sdk";
48
42
  import { jsx as jsx2, jsxs } from "react/jsx-runtime";
49
43
  var useOnFetchEnd = (fetcher, handler) => {
50
44
  const latestHandler = useRef(handler);
@@ -60,7 +54,7 @@ var useOnFetchEnd = (fetcher, handler) => {
60
54
  var Form = forwardRef2(
61
55
  ({ children, action, method, state = "initial", onStateChange, ...rest }, ref) => {
62
56
  const fetcher = useFetcher();
63
- const instanceId = getInstanceIdFromComponentProps2(rest);
57
+ const instanceId = getInstanceIdFromComponentProps(rest);
64
58
  useOnFetchEnd(fetcher, (data) => {
65
59
  const state2 = data?.success === true ? "success" : "error";
66
60
  onStateChange?.(state2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/sdk-components-react-remix",
3
- "version": "0.100.1-c4ae8b2.0",
3
+ "version": "0.101.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
- "source": "./src/components.ts",
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
- "source": "./src/metas.ts",
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
- "source": "./src/props.ts",
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.1-c4ae8b2.0",
42
- "@webstudio-is/icons": "0.100.1-c4ae8b2.0",
43
- "@webstudio-is/react-sdk": "0.100.1-c4ae8b2.0",
44
- "@webstudio-is/sdk-components-react": "0.100.1-c4ae8b2.0"
41
+ "@webstudio-is/form-handlers": "0.101.0",
42
+ "@webstudio-is/icons": "0.101.0",
43
+ "@webstudio-is/react-sdk": "0.101.0",
44
+ "@webstudio-is/sdk-components-react": "0.101.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.1-c4ae8b2.0",
54
- "@webstudio-is/tsconfig": "1.0.8-c4ae8b2.0"
53
+ "@webstudio-is/generate-arg-types": "0.101.0",
54
+ "@webstudio-is/tsconfig": "1.0.7"
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=source generate-arg-types './src/*.tsx !./src/**/*.stories.tsx !./src/**/*.ws.tsx' && prettier --write \"**/*.props.ts\"",
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"