@webstudio-is/sdk-components-react 0.100.1-d89b38d.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.
- package/lib/components.js +18 -48
- package/package.json +8 -8
package/lib/components.js
CHANGED
|
@@ -137,35 +137,10 @@ var Paragraph = forwardRef8((props, ref) => /* @__PURE__ */ jsx5("p", { ...props
|
|
|
137
137
|
Paragraph.displayName = "Paragraph";
|
|
138
138
|
|
|
139
139
|
// src/link.tsx
|
|
140
|
-
import { forwardRef as forwardRef9
|
|
141
|
-
import {
|
|
142
|
-
usePropUrl,
|
|
143
|
-
getInstanceIdFromComponentProps,
|
|
144
|
-
ReactSdkContext as ReactSdkContext2
|
|
145
|
-
} from "@webstudio-is/react-sdk";
|
|
140
|
+
import { forwardRef as forwardRef9 } from "react";
|
|
146
141
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
147
142
|
var Link = forwardRef9((props, ref) => {
|
|
148
|
-
|
|
149
|
-
const href = usePropUrl(getInstanceIdFromComponentProps(props), "href");
|
|
150
|
-
let url = "#";
|
|
151
|
-
switch (href?.type) {
|
|
152
|
-
case "page": {
|
|
153
|
-
url = href.page.path === "" ? "/" : href.page.path;
|
|
154
|
-
const urlTo = new URL(url, "https://any-valid.url");
|
|
155
|
-
url = urlTo.pathname;
|
|
156
|
-
if (href.hash !== void 0) {
|
|
157
|
-
urlTo.hash = encodeURIComponent(href.hash);
|
|
158
|
-
url = `${urlTo.pathname}${urlTo.hash}`;
|
|
159
|
-
}
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
case "asset":
|
|
163
|
-
url = `${assetBaseUrl}${href.asset.name}`;
|
|
164
|
-
break;
|
|
165
|
-
case "string":
|
|
166
|
-
url = href.url;
|
|
167
|
-
}
|
|
168
|
-
return /* @__PURE__ */ jsx6("a", { ...props, href: url, ref });
|
|
143
|
+
return /* @__PURE__ */ jsx6("a", { ...props, href: props.href ?? "#", ref });
|
|
169
144
|
});
|
|
170
145
|
Link.displayName = "Link";
|
|
171
146
|
|
|
@@ -228,14 +203,10 @@ Form.displayName = "Form";
|
|
|
228
203
|
// src/image.tsx
|
|
229
204
|
import {
|
|
230
205
|
forwardRef as forwardRef19,
|
|
231
|
-
useContext as
|
|
206
|
+
useContext as useContext2
|
|
232
207
|
} from "react";
|
|
233
208
|
import { Image as WebstudioImage } from "@webstudio-is/image";
|
|
234
|
-
import {
|
|
235
|
-
usePropAsset,
|
|
236
|
-
getInstanceIdFromComponentProps as getInstanceIdFromComponentProps2,
|
|
237
|
-
ReactSdkContext as ReactSdkContext3
|
|
238
|
-
} from "@webstudio-is/react-sdk";
|
|
209
|
+
import { ReactSdkContext as ReactSdkContext2 } from "@webstudio-is/react-sdk";
|
|
239
210
|
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
240
211
|
var imagePlaceholderSvg = `data:image/svg+xml;base64,${btoa(`<svg
|
|
241
212
|
width="140"
|
|
@@ -262,21 +233,20 @@ var imagePlaceholderSvg = `data:image/svg+xml;base64,${btoa(`<svg
|
|
|
262
233
|
</svg>`)}`;
|
|
263
234
|
var Image = forwardRef19(
|
|
264
235
|
({ loading = "lazy", ...props }, ref) => {
|
|
265
|
-
const { imageLoader } =
|
|
266
|
-
|
|
267
|
-
const src = asset?.name ?? props.src;
|
|
268
|
-
if (asset == null) {
|
|
236
|
+
const { imageLoader, assetBaseUrl } = useContext2(ReactSdkContext2);
|
|
237
|
+
if (props.src === void 0 || props.src.startsWith(assetBaseUrl) === false) {
|
|
269
238
|
return /* @__PURE__ */ jsx16(
|
|
270
239
|
"img",
|
|
271
240
|
{
|
|
272
241
|
loading,
|
|
273
242
|
...props,
|
|
274
|
-
src: src || imagePlaceholderSvg,
|
|
243
|
+
src: props.src || imagePlaceholderSvg,
|
|
275
244
|
ref
|
|
276
245
|
},
|
|
277
|
-
src
|
|
246
|
+
props.src
|
|
278
247
|
);
|
|
279
248
|
}
|
|
249
|
+
const src = props.src.slice(assetBaseUrl.length);
|
|
280
250
|
return /* @__PURE__ */ jsx16(
|
|
281
251
|
WebstudioImage,
|
|
282
252
|
{
|
|
@@ -386,11 +356,11 @@ import {
|
|
|
386
356
|
useState,
|
|
387
357
|
useRef as useRef2,
|
|
388
358
|
useEffect as useEffect2,
|
|
389
|
-
useContext as
|
|
359
|
+
useContext as useContext3,
|
|
390
360
|
createContext,
|
|
391
361
|
useMemo
|
|
392
362
|
} from "react";
|
|
393
|
-
import { ReactSdkContext as
|
|
363
|
+
import { ReactSdkContext as ReactSdkContext3 } from "@webstudio-is/react-sdk";
|
|
394
364
|
import { shallowEqual } from "shallow-equal";
|
|
395
365
|
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
396
366
|
var getUrl = (options) => {
|
|
@@ -573,7 +543,7 @@ var Vimeo = forwardRef29(
|
|
|
573
543
|
children,
|
|
574
544
|
...rest
|
|
575
545
|
}, ref) => {
|
|
576
|
-
const { renderer } =
|
|
546
|
+
const { renderer } = useContext3(ReactSdkContext3);
|
|
577
547
|
const { previewImageUrl, playerStatus, setPlayerStatus, elementRef } = useVimeo({
|
|
578
548
|
renderer,
|
|
579
549
|
showPreview,
|
|
@@ -661,12 +631,12 @@ var VimeoContext = createContext({
|
|
|
661
631
|
// src/vimeo-preview-image.tsx
|
|
662
632
|
import {
|
|
663
633
|
forwardRef as forwardRef30,
|
|
664
|
-
useContext as
|
|
634
|
+
useContext as useContext4
|
|
665
635
|
} from "react";
|
|
666
636
|
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
667
637
|
var base64Preview = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkOAMAANIAzr59FiYAAAAASUVORK5CYII=`;
|
|
668
638
|
var VimeoPreviewImage = forwardRef30(({ src, ...rest }, ref) => {
|
|
669
|
-
const vimeoContext =
|
|
639
|
+
const vimeoContext = useContext4(VimeoContext);
|
|
670
640
|
return /* @__PURE__ */ jsx22(
|
|
671
641
|
Image,
|
|
672
642
|
{
|
|
@@ -681,12 +651,12 @@ VimeoPreviewImage.displayName = "VimeoPreviewImage";
|
|
|
681
651
|
// src/vimeo-play-button.tsx
|
|
682
652
|
import {
|
|
683
653
|
forwardRef as forwardRef31,
|
|
684
|
-
useContext as
|
|
654
|
+
useContext as useContext5
|
|
685
655
|
} from "react";
|
|
686
656
|
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
687
657
|
var VimeoPlayButton = forwardRef31(
|
|
688
658
|
(props, ref) => {
|
|
689
|
-
const vimeoContext =
|
|
659
|
+
const vimeoContext = useContext5(VimeoContext);
|
|
690
660
|
if (vimeoContext.status !== "initial") {
|
|
691
661
|
return null;
|
|
692
662
|
}
|
|
@@ -698,12 +668,12 @@ VimeoPlayButton.displayName = "VimeoPlayButton";
|
|
|
698
668
|
// src/vimeo-spinner.tsx
|
|
699
669
|
import {
|
|
700
670
|
forwardRef as forwardRef32,
|
|
701
|
-
useContext as
|
|
671
|
+
useContext as useContext6
|
|
702
672
|
} from "react";
|
|
703
673
|
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
704
674
|
var VimeoSpinner = forwardRef32(
|
|
705
675
|
(props, ref) => {
|
|
706
|
-
const vimeoContext =
|
|
676
|
+
const vimeoContext = useContext6(VimeoContext);
|
|
707
677
|
if (vimeoContext.status !== "initialized") {
|
|
708
678
|
return null;
|
|
709
679
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/sdk-components-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.101.0",
|
|
4
4
|
"description": "Webstudio default library for react",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"@react-aria/utils": "^3.19.0",
|
|
41
41
|
"colord": "^2.9.3",
|
|
42
42
|
"shallow-equal": "^3.1.0",
|
|
43
|
-
"@webstudio-is/css-vars": "0.
|
|
44
|
-
"@webstudio-is/icons": "0.
|
|
45
|
-
"@webstudio-is/image": "0.
|
|
46
|
-
"@webstudio-is/react-sdk": "0.
|
|
43
|
+
"@webstudio-is/css-vars": "0.101.0",
|
|
44
|
+
"@webstudio-is/icons": "0.101.0",
|
|
45
|
+
"@webstudio-is/image": "0.101.0",
|
|
46
|
+
"@webstudio-is/react-sdk": "0.101.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@storybook/react": "^7.4.0",
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"react": "^18.2.0",
|
|
53
53
|
"react-dom": "^18.2.0",
|
|
54
54
|
"typescript": "5.2.2",
|
|
55
|
-
"@webstudio-is/generate-arg-types": "0.
|
|
56
|
-
"@webstudio-is/storybook-config": "0.0.
|
|
57
|
-
"@webstudio-is/tsconfig": "1.0.
|
|
55
|
+
"@webstudio-is/generate-arg-types": "0.101.0",
|
|
56
|
+
"@webstudio-is/storybook-config": "0.0.0",
|
|
57
|
+
"@webstudio-is/tsconfig": "1.0.7"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"dev": "rm -rf lib && esbuild 'src/**/*.ts' 'src/**/*.tsx' --outdir=lib --watch",
|