@webstudio-is/sdk-components-react-remix 0.189.0 → 0.191.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/sdk-components-react-remix",
3
- "version": "0.189.0",
3
+ "version": "0.191.4",
4
4
  "description": "Webstudio components for Remix",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -35,24 +35,23 @@
35
35
  "react-dom": "18.3.0-canary-14898b6a9-20240318"
36
36
  },
37
37
  "dependencies": {
38
- "@webstudio-is/react-sdk": "0.189.0",
39
- "@webstudio-is/sdk": "0.189.0",
40
- "@webstudio-is/sdk-components-react": "0.189.0",
41
- "@webstudio-is/icons": "0.189.0"
38
+ "@webstudio-is/icons": "0.191.4",
39
+ "@webstudio-is/react-sdk": "0.191.4",
40
+ "@webstudio-is/sdk": "0.191.4",
41
+ "@webstudio-is/sdk-components-react": "0.191.4"
42
42
  },
43
43
  "devDependencies": {
44
- "@remix-run/react": "^2.12.1",
45
- "@types/node": "^22.8.1",
44
+ "@remix-run/react": "^2.15.0",
45
+ "@types/node": "^22.9.3",
46
46
  "@types/react": "^18.2.70",
47
47
  "@types/react-dom": "^18.2.25",
48
48
  "react": "18.3.0-canary-14898b6a9-20240318",
49
49
  "react-dom": "18.3.0-canary-14898b6a9-20240318",
50
- "typescript": "5.6.3",
51
50
  "@webstudio-is/generate-arg-types": "0.0.0",
52
51
  "@webstudio-is/tsconfig": "1.0.7"
53
52
  },
54
53
  "scripts": {
55
- "build": "rm -rf lib && esbuild src/components.ts src/metas.ts src/props.ts --outdir=lib --bundle --format=esm --packages=external",
54
+ "build": "vite build --config ../../vite.sdk-components.config.ts",
56
55
  "build:args": "NODE_OPTIONS=--conditions=webstudio generate-arg-types './src/*.tsx !./src/**/*.stories.tsx !./src/**/*.ws.ts' && prettier --write \"**/*.props.ts\"",
57
56
  "dts": "tsc --project tsconfig.dts.json",
58
57
  "typecheck": "tsc"
package/lib/components.js DELETED
@@ -1,165 +0,0 @@
1
- // src/body.tsx
2
- import { forwardRef } from "react";
3
- import { Scripts, ScrollRestoration } from "@remix-run/react";
4
- import { jsx, jsxs } from "react/jsx-runtime";
5
- var Body = forwardRef(
6
- ({ children, ...props }, ref) => /* @__PURE__ */ jsxs("body", { ...props, ref, children: [
7
- children,
8
- /* @__PURE__ */ jsx(Scripts, {}),
9
- /* @__PURE__ */ jsx(ScrollRestoration, {})
10
- ] })
11
- );
12
- Body.displayName = "Body";
13
-
14
- // src/link.tsx
15
- import { Link as BaseLink } from "@webstudio-is/sdk-components-react";
16
-
17
- // src/shared/remix-link.tsx
18
- import { forwardRef as forwardRef2, useContext } from "react";
19
- import { NavLink as RemixLink } from "@remix-run/react";
20
- import { ReactSdkContext } from "@webstudio-is/react-sdk/runtime";
21
- import { jsx as jsx2 } from "react/jsx-runtime";
22
- var wrapLinkComponent = (BaseLink3) => {
23
- const Component = forwardRef2((props, ref) => {
24
- const { assetBaseUrl, renderer } = useContext(ReactSdkContext);
25
- const href = String(props.href ?? "");
26
- if (
27
- // remix appends ?index in runtime but not in ssr
28
- href === "" || href.startsWith("?") || href.startsWith("#") || href.startsWith("/") && href.startsWith(assetBaseUrl) === false
29
- ) {
30
- if (renderer !== "canvas" && renderer !== "preview") {
31
- return /* @__PURE__ */ jsx2(RemixLink, { ...props, to: href, ref, end: true });
32
- }
33
- }
34
- const { prefetch, reloadDocument, replace, preventScrollReset, ...rest } = props;
35
- return /* @__PURE__ */ jsx2(BaseLink3, { ...rest, ref });
36
- });
37
- Component.displayName = BaseLink3.displayName;
38
- return Component;
39
- };
40
-
41
- // src/link.tsx
42
- var Link = wrapLinkComponent(BaseLink);
43
-
44
- // src/rich-text-link.tsx
45
- import { RichTextLink as BaseLink2 } from "@webstudio-is/sdk-components-react";
46
- var RichTextLink = wrapLinkComponent(BaseLink2);
47
-
48
- // src/webhook-form.tsx
49
- import {
50
- forwardRef as forwardRef3,
51
- useRef,
52
- useEffect
53
- } from "react";
54
- import { useFetcher } from "@remix-run/react";
55
- import { formIdFieldName, formBotFieldName } from "@webstudio-is/sdk";
56
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
57
- var useOnFetchEnd = (fetcher, handler) => {
58
- const latestHandler = useRef(handler);
59
- latestHandler.current = handler;
60
- const prevFetcher = useRef(fetcher);
61
- useEffect(() => {
62
- if (prevFetcher.current.state !== fetcher.state && fetcher.state === "idle" && fetcher.data !== void 0) {
63
- latestHandler.current(fetcher.data);
64
- }
65
- prevFetcher.current = fetcher;
66
- }, [fetcher]);
67
- };
68
- var gcd = (a, b) => b === 0 ? a : gcd(b, a % b);
69
- var getAspectRatioString = (width, height) => {
70
- const r = gcd(width, height);
71
- const aspectRatio = `${width / r}/${height / r}`;
72
- return aspectRatio;
73
- };
74
- var isJSDom = () => {
75
- if (typeof matchMedia === "undefined") {
76
- return true;
77
- }
78
- const { width, height } = screen;
79
- const deviceAspectRatio = getAspectRatioString(width, height);
80
- const matchAspectRatio = matchMedia(
81
- `(device-aspect-ratio: ${deviceAspectRatio})`
82
- ).matches;
83
- const matchWidthHeight = matchMedia(
84
- `(device-width: ${width}px) and (device-height: ${height}px)`
85
- ).matches;
86
- const matchWidthHeightFail = matchMedia(
87
- `(device-width: ${width - 1}px) and (device-height: ${height}px)`
88
- ).matches;
89
- const matchLight = matchMedia("(prefers-color-scheme: light)").matches;
90
- const matchDark = matchMedia("(prefers-color-scheme: dark)").matches;
91
- const hasMatchMedia = matchAspectRatio && matchWidthHeight && !matchWidthHeightFail && matchLight !== matchDark;
92
- return hasMatchMedia === false;
93
- };
94
- var WebhookForm = forwardRef3(
95
- ({ children, action, method, state = "initial", onStateChange, ...rest }, ref) => {
96
- const fetcher = useFetcher();
97
- useOnFetchEnd(fetcher, (data) => {
98
- const state2 = data?.success === true ? "success" : "error";
99
- onStateChange?.(state2);
100
- });
101
- const handleSubmitAndAddHiddenJsField = (event) => {
102
- const hiddenInput = document.createElement("input");
103
- hiddenInput.type = "hidden";
104
- hiddenInput.name = formBotFieldName;
105
- hiddenInput.value = isJSDom() ? "jsdom" : Date.now().toString(16);
106
- event.currentTarget.appendChild(hiddenInput);
107
- };
108
- return /* @__PURE__ */ jsxs2(
109
- fetcher.Form,
110
- {
111
- ...rest,
112
- method: "post",
113
- "data-state": state,
114
- ref,
115
- onSubmit: handleSubmitAndAddHiddenJsField,
116
- children: [
117
- /* @__PURE__ */ jsx3(
118
- "input",
119
- {
120
- type: "hidden",
121
- name: formIdFieldName,
122
- value: action?.toString()
123
- }
124
- ),
125
- children
126
- ]
127
- }
128
- );
129
- }
130
- );
131
- WebhookForm.displayName = "WebhookForm";
132
-
133
- // src/remix-form.tsx
134
- import {
135
- forwardRef as forwardRef4,
136
- useContext as useContext2
137
- } from "react";
138
- import { Form } from "@remix-run/react";
139
- import { ReactSdkContext as ReactSdkContext2 } from "@webstudio-is/react-sdk/runtime";
140
- import { jsx as jsx4 } from "react/jsx-runtime";
141
- var RemixForm = forwardRef4(({ action, ...props }, ref) => {
142
- const { renderer } = useContext2(ReactSdkContext2);
143
- if (action === void 0 || action === "" || typeof action === "string" && action?.startsWith("/")) {
144
- if (renderer !== "canvas" && renderer !== "preview") {
145
- return /* @__PURE__ */ jsx4(
146
- Form,
147
- {
148
- action,
149
- ...props,
150
- ref,
151
- preventScrollReset: action === void 0 || action === ""
152
- }
153
- );
154
- }
155
- }
156
- return /* @__PURE__ */ jsx4("form", { ...props, ref });
157
- });
158
- RemixForm.displayName = "Form";
159
- export {
160
- Body,
161
- WebhookForm as Form,
162
- Link,
163
- RemixForm,
164
- RichTextLink
165
- };