@webstudio-is/sdk-components-react 0.0.0-021f2d4
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/LICENSE +661 -0
- package/README.md +3 -0
- package/lib/__generated__/blockquote.props.js +514 -0
- package/lib/__generated__/body.props.js +508 -0
- package/lib/__generated__/bold.props.js +508 -0
- package/lib/__generated__/box.props.js +527 -0
- package/lib/__generated__/button.props.js +570 -0
- package/lib/__generated__/checkbox.props.js +672 -0
- package/lib/__generated__/code-text.props.js +509 -0
- package/lib/__generated__/form.props.js +556 -0
- package/lib/__generated__/head-link.props.js +620 -0
- package/lib/__generated__/head-meta.props.js +532 -0
- package/lib/__generated__/head-title.props.js +508 -0
- package/lib/__generated__/head.props.js +508 -0
- package/lib/__generated__/heading.props.js +516 -0
- package/lib/__generated__/html-embed.props.js +13 -0
- package/lib/__generated__/image.props.js +593 -0
- package/lib/__generated__/input.props.js +696 -0
- package/lib/__generated__/italic.props.js +508 -0
- package/lib/__generated__/label.props.js +520 -0
- package/lib/__generated__/link.props.js +578 -0
- package/lib/__generated__/list-item.props.js +514 -0
- package/lib/__generated__/list.props.js +534 -0
- package/lib/__generated__/markdown-embed.props.js +7 -0
- package/lib/__generated__/option.props.js +532 -0
- package/lib/__generated__/paragraph.props.js +508 -0
- package/lib/__generated__/radio-button.props.js +672 -0
- package/lib/__generated__/select.props.js +556 -0
- package/lib/__generated__/separator.props.js +508 -0
- package/lib/__generated__/span.props.js +508 -0
- package/lib/__generated__/subscript.props.js +508 -0
- package/lib/__generated__/superscript.props.js +508 -0
- package/lib/__generated__/text.props.js +516 -0
- package/lib/__generated__/textarea.props.js +587 -0
- package/lib/__generated__/time.props.js +312 -0
- package/lib/__generated__/vimeo-play-button.props.js +569 -0
- package/lib/__generated__/vimeo-preview-image.props.js +591 -0
- package/lib/__generated__/vimeo-spinner.props.js +508 -0
- package/lib/__generated__/vimeo.props.js +673 -0
- package/lib/__generated__/webhook-form.props.js +569 -0
- package/lib/__generated__/xml-node.props.js +21 -0
- package/lib/__generated__/xml-time.props.js +18 -0
- package/lib/__generated__/youtube.props.js +665 -0
- package/lib/blockquote.js +9 -0
- package/lib/blockquote.template.js +11 -0
- package/lib/blockquote.ws.js +63 -0
- package/lib/body.js +7 -0
- package/lib/body.ws.js +29 -0
- package/lib/bold.js +7 -0
- package/lib/bold.ws.js +20 -0
- package/lib/box.js +9 -0
- package/lib/box.ws.js +31 -0
- package/lib/button.js +9 -0
- package/lib/button.template.js +11 -0
- package/lib/button.ws.js +27 -0
- package/lib/checkbox.js +15 -0
- package/lib/checkbox.template.js +14 -0
- package/lib/checkbox.ws.js +38 -0
- package/lib/code-text.js +10 -0
- package/lib/code-text.ws.js +59 -0
- package/lib/components.js +89 -0
- package/lib/content-embed.template.js +83 -0
- package/lib/form.js +7 -0
- package/lib/form.ws.js +30 -0
- package/lib/fragment.js +7 -0
- package/lib/fragment.ws.js +10 -0
- package/lib/head-link.js +23 -0
- package/lib/head-link.ws.js +19 -0
- package/lib/head-meta.js +23 -0
- package/lib/head-meta.ws.js +19 -0
- package/lib/head-slot.js +54 -0
- package/lib/head-slot.template.js +15 -0
- package/lib/head-slot.ws.js +25 -0
- package/lib/head-title.js +23 -0
- package/lib/head-title.ws.js +18 -0
- package/lib/heading.js +9 -0
- package/lib/heading.template.js +11 -0
- package/lib/heading.ws.js +28 -0
- package/lib/home_wsKvRSqvkajPPBeycZ-C8.svg +3 -0
- package/lib/hooks.js +6 -0
- package/lib/html-embed-patchers.js +29 -0
- package/lib/html-embed.js +112 -0
- package/lib/html-embed.ws.js +46 -0
- package/lib/image.js +38 -0
- package/lib/image.ws.js +60 -0
- package/lib/input.js +17 -0
- package/lib/input.ws.js +54 -0
- package/lib/italic.js +7 -0
- package/lib/italic.ws.js +26 -0
- package/lib/label.js +7 -0
- package/lib/label.template.js +10 -0
- package/lib/label.ws.js +27 -0
- package/lib/link.js +15 -0
- package/lib/link.template.js +11 -0
- package/lib/link.ws.js +47 -0
- package/lib/list-item.js +9 -0
- package/lib/list-item.template.js +11 -0
- package/lib/list-item.ws.js +26 -0
- package/lib/list.js +6 -0
- package/lib/list.template.js +15 -0
- package/lib/list.ws.js +48 -0
- package/lib/markdown-embed.js +19 -0
- package/lib/markdown-embed.template.js +75 -0
- package/lib/markdown-embed.ws.js +33 -0
- package/lib/metas.js +90 -0
- package/lib/option.js +7 -0
- package/lib/option.ws.js +44 -0
- package/lib/paragraph.js +7 -0
- package/lib/paragraph.template.js +11 -0
- package/lib/paragraph.ws.js +23 -0
- package/lib/props.js +90 -0
- package/lib/radio-button.js +15 -0
- package/lib/radio-button.template.js +14 -0
- package/lib/radio-button.ws.js +40 -0
- package/lib/rich-text-link.ws.js +9 -0
- package/lib/select.js +19 -0
- package/lib/select.template.js +16 -0
- package/lib/select.ws.js +44 -0
- package/lib/separator.js +9 -0
- package/lib/separator.ws.js +48 -0
- package/lib/slot.js +14 -0
- package/lib/slot.ws.js +14 -0
- package/lib/span.js +7 -0
- package/lib/span.ws.js +20 -0
- package/lib/subscript.js +7 -0
- package/lib/subscript.ws.js +20 -0
- package/lib/superscript.js +7 -0
- package/lib/superscript.ws.js +20 -0
- package/lib/templates.js +38 -0
- package/lib/text.js +10 -0
- package/lib/text.template.js +11 -0
- package/lib/text.ws.js +25 -0
- package/lib/textarea.js +7 -0
- package/lib/textarea.ws.js +55 -0
- package/lib/time.js +319 -0
- package/lib/time.ws.js +21 -0
- package/lib/types/__generated__/blockquote.props.d.ts +2 -0
- package/lib/types/__generated__/body.props.d.ts +2 -0
- package/lib/types/__generated__/bold.props.d.ts +2 -0
- package/lib/types/__generated__/box.props.d.ts +2 -0
- package/lib/types/__generated__/button.props.d.ts +2 -0
- package/lib/types/__generated__/checkbox.props.d.ts +2 -0
- package/lib/types/__generated__/code-text.props.d.ts +2 -0
- package/lib/types/__generated__/form.props.d.ts +2 -0
- package/lib/types/__generated__/fragment.props.d.ts +2 -0
- package/lib/types/__generated__/head-link.props.d.ts +2 -0
- package/lib/types/__generated__/head-meta.props.d.ts +2 -0
- package/lib/types/__generated__/head-slot.props.d.ts +2 -0
- package/lib/types/__generated__/head-title.props.d.ts +2 -0
- package/lib/types/__generated__/head.props.d.ts +2 -0
- package/lib/types/__generated__/heading.props.d.ts +2 -0
- package/lib/types/__generated__/html-embed.props.d.ts +2 -0
- package/lib/types/__generated__/image.props.d.ts +2 -0
- package/lib/types/__generated__/input.props.d.ts +2 -0
- package/lib/types/__generated__/italic.props.d.ts +2 -0
- package/lib/types/__generated__/label.props.d.ts +2 -0
- package/lib/types/__generated__/link.props.d.ts +2 -0
- package/lib/types/__generated__/list-item.props.d.ts +2 -0
- package/lib/types/__generated__/list.props.d.ts +2 -0
- package/lib/types/__generated__/markdown-embed.props.d.ts +2 -0
- package/lib/types/__generated__/option.props.d.ts +2 -0
- package/lib/types/__generated__/paragraph.props.d.ts +2 -0
- package/lib/types/__generated__/radio-button.props.d.ts +2 -0
- package/lib/types/__generated__/rich-text-link.props.d.ts +2 -0
- package/lib/types/__generated__/select.props.d.ts +2 -0
- package/lib/types/__generated__/separator.props.d.ts +2 -0
- package/lib/types/__generated__/slot.props.d.ts +2 -0
- package/lib/types/__generated__/span.props.d.ts +2 -0
- package/lib/types/__generated__/subscript.props.d.ts +2 -0
- package/lib/types/__generated__/superscript.props.d.ts +2 -0
- package/lib/types/__generated__/text.props.d.ts +2 -0
- package/lib/types/__generated__/textarea.props.d.ts +2 -0
- package/lib/types/__generated__/time.props.d.ts +2 -0
- package/lib/types/__generated__/vimeo-play-button.props.d.ts +2 -0
- package/lib/types/__generated__/vimeo-preview-image.props.d.ts +2 -0
- package/lib/types/__generated__/vimeo-spinner.props.d.ts +2 -0
- package/lib/types/__generated__/vimeo.props.d.ts +2 -0
- package/lib/types/__generated__/webhook-form.props.d.ts +2 -0
- package/lib/types/__generated__/xml-node.props.d.ts +2 -0
- package/lib/types/__generated__/xml-time.props.d.ts +2 -0
- package/lib/types/__generated__/youtube.props.d.ts +2 -0
- package/lib/types/blockquote.d.ts +2 -0
- package/lib/types/blockquote.template.d.ts +2 -0
- package/lib/types/blockquote.ws.d.ts +3 -0
- package/lib/types/body.d.ts +2 -0
- package/lib/types/body.ws.d.ts +3 -0
- package/lib/types/bold.d.ts +2 -0
- package/lib/types/bold.ws.d.ts +3 -0
- package/lib/types/box.d.ts +8 -0
- package/lib/types/box.ws.d.ts +3 -0
- package/lib/types/button.d.ts +2 -0
- package/lib/types/button.template.d.ts +2 -0
- package/lib/types/button.ws.d.ts +3 -0
- package/lib/types/checkbox.d.ts +4 -0
- package/lib/types/checkbox.template.d.ts +2 -0
- package/lib/types/checkbox.ws.d.ts +3 -0
- package/lib/types/code-text.d.ts +4 -0
- package/lib/types/code-text.ws.d.ts +3 -0
- package/lib/types/components.d.ts +44 -0
- package/lib/types/content-embed.template.d.ts +2 -0
- package/lib/types/form.d.ts +2 -0
- package/lib/types/form.ws.d.ts +3 -0
- package/lib/types/fragment.d.ts +6 -0
- package/lib/types/fragment.ws.d.ts +3 -0
- package/lib/types/head-link.d.ts +8 -0
- package/lib/types/head-link.ws.d.ts +3 -0
- package/lib/types/head-meta.d.ts +2 -0
- package/lib/types/head-meta.ws.d.ts +3 -0
- package/lib/types/head-slot.d.ts +9 -0
- package/lib/types/head-slot.template.d.ts +2 -0
- package/lib/types/head-slot.ws.d.ts +3 -0
- package/lib/types/head-title.d.ts +2 -0
- package/lib/types/head-title.ws.d.ts +3 -0
- package/lib/types/heading.d.ts +8 -0
- package/lib/types/heading.template.d.ts +2 -0
- package/lib/types/heading.ws.d.ts +3 -0
- package/lib/types/hooks.d.ts +2 -0
- package/lib/types/html-embed-patchers.d.ts +2 -0
- package/lib/types/html-embed.d.ts +12 -0
- package/lib/types/html-embed.test.d.ts +1 -0
- package/lib/types/html-embed.ws.d.ts +3 -0
- package/lib/types/image.d.ts +8 -0
- package/lib/types/image.ws.d.ts +3 -0
- package/lib/types/input.d.ts +4 -0
- package/lib/types/input.ws.d.ts +3 -0
- package/lib/types/italic.d.ts +2 -0
- package/lib/types/italic.ws.d.ts +3 -0
- package/lib/types/label.d.ts +2 -0
- package/lib/types/label.template.d.ts +2 -0
- package/lib/types/label.ws.d.ts +3 -0
- package/lib/types/link.d.ts +11 -0
- package/lib/types/link.template.d.ts +2 -0
- package/lib/types/link.ws.d.ts +3 -0
- package/lib/types/list-item.d.ts +2 -0
- package/lib/types/list-item.template.d.ts +2 -0
- package/lib/types/list-item.ws.d.ts +3 -0
- package/lib/types/list.d.ts +10 -0
- package/lib/types/list.template.d.ts +2 -0
- package/lib/types/list.ws.d.ts +3 -0
- package/lib/types/markdown-embed.d.ts +7 -0
- package/lib/types/markdown-embed.template.d.ts +2 -0
- package/lib/types/markdown-embed.ws.d.ts +3 -0
- package/lib/types/metas.d.ts +44 -0
- package/lib/types/option.d.ts +2 -0
- package/lib/types/option.ws.d.ts +3 -0
- package/lib/types/paragraph.d.ts +2 -0
- package/lib/types/paragraph.template.d.ts +2 -0
- package/lib/types/paragraph.ws.d.ts +3 -0
- package/lib/types/props.d.ts +44 -0
- package/lib/types/radio-button.d.ts +4 -0
- package/lib/types/radio-button.template.d.ts +2 -0
- package/lib/types/radio-button.ws.d.ts +3 -0
- package/lib/types/rich-text-link.d.ts +1 -0
- package/lib/types/rich-text-link.ws.d.ts +3 -0
- package/lib/types/select.d.ts +4 -0
- package/lib/types/select.template.d.ts +2 -0
- package/lib/types/select.ws.d.ts +3 -0
- package/lib/types/separator.d.ts +2 -0
- package/lib/types/separator.ws.d.ts +3 -0
- package/lib/types/slot.d.ts +6 -0
- package/lib/types/slot.ws.d.ts +3 -0
- package/lib/types/span.d.ts +2 -0
- package/lib/types/span.ws.d.ts +3 -0
- package/lib/types/subscript.d.ts +2 -0
- package/lib/types/subscript.ws.d.ts +3 -0
- package/lib/types/superscript.d.ts +2 -0
- package/lib/types/superscript.ws.d.ts +3 -0
- package/lib/types/templates.d.ts +18 -0
- package/lib/types/test-utils/cartesian.d.ts +2 -0
- package/lib/types/text.d.ts +8 -0
- package/lib/types/text.template.d.ts +2 -0
- package/lib/types/text.ws.d.ts +3 -0
- package/lib/types/textarea.d.ts +2 -0
- package/lib/types/textarea.ws.d.ts +3 -0
- package/lib/types/time.d.ts +18 -0
- package/lib/types/time.test.d.ts +1 -0
- package/lib/types/time.ws.d.ts +3 -0
- package/lib/types/vimeo-play-button.d.ts +3 -0
- package/lib/types/vimeo-play-button.ws.d.ts +3 -0
- package/lib/types/vimeo-preview-image.d.ts +284 -0
- package/lib/types/vimeo-preview-image.ws.d.ts +3 -0
- package/lib/types/vimeo-spinner.d.ts +1 -0
- package/lib/types/vimeo-spinner.ws.d.ts +3 -0
- package/lib/types/vimeo.d.ts +85 -0
- package/lib/types/vimeo.template.d.ts +2 -0
- package/lib/types/vimeo.ws.d.ts +3 -0
- package/lib/types/webhook-form.d.ts +9 -0
- package/lib/types/webhook-form.template.d.ts +2 -0
- package/lib/types/webhook-form.ws.d.ts +3 -0
- package/lib/types/xml-node.d.ts +13 -0
- package/lib/types/xml-node.ws.d.ts +3 -0
- package/lib/types/xml-time.d.ts +6 -0
- package/lib/types/xml-time.ws.d.ts +3 -0
- package/lib/types/youtube.d.ts +143 -0
- package/lib/types/youtube.template.d.ts +2 -0
- package/lib/types/youtube.ws.d.ts +3 -0
- package/lib/vimeo-play-button.js +18 -0
- package/lib/vimeo-play-button.ws.js +31 -0
- package/lib/vimeo-preview-image.js +19 -0
- package/lib/vimeo-preview-image.ws.js +27 -0
- package/lib/vimeo-spinner.js +13 -0
- package/lib/vimeo-spinner.ws.js +25 -0
- package/lib/vimeo.js +216 -0
- package/lib/vimeo.template.js +93 -0
- package/lib/vimeo.ws.js +40 -0
- package/lib/webhook-form.js +9 -0
- package/lib/webhook-form.template.js +49 -0
- package/lib/webhook-form.ws.js +26 -0
- package/lib/xml-node.js +60 -0
- package/lib/xml-node.ws.js +16 -0
- package/lib/xml-time.js +25 -0
- package/lib/xml-time.ws.js +16 -0
- package/lib/youtube.js +206 -0
- package/lib/youtube.template.js +97 -0
- package/lib/youtube.ws.js +51 -0
- package/package.json +77 -0
package/lib/youtube.js
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { jsx as u, jsxs as R, Fragment as _ } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as L, useState as h, useContext as C, useEffect as y } from "react";
|
|
3
|
+
import { ReactSdkContext as I } from "@webstudio-is/react-sdk/runtime";
|
|
4
|
+
import { VimeoContext as E } from "./vimeo.js";
|
|
5
|
+
const O = "https://www.youtube-nocookie.com", x = "https://www.youtube.com", w = "https://img.youtube.com", k = (e) => {
|
|
6
|
+
if (e)
|
|
7
|
+
try {
|
|
8
|
+
const t = new URL(e);
|
|
9
|
+
return t.pathname === "/embed" ? void 0 : t.hostname === "youtu.be" ? t.pathname.slice(1) : t.searchParams.get("v") || t.pathname.split("/").pop();
|
|
10
|
+
} catch {
|
|
11
|
+
return e;
|
|
12
|
+
}
|
|
13
|
+
}, S = (e, t) => {
|
|
14
|
+
var n, i;
|
|
15
|
+
const l = k(e.url), r = new URL(t);
|
|
16
|
+
if (l)
|
|
17
|
+
r.pathname = `/embed/${l}`;
|
|
18
|
+
else if (e.url)
|
|
19
|
+
try {
|
|
20
|
+
const c = new URL(e.url);
|
|
21
|
+
r.pathname = c.pathname, r.search = c.search;
|
|
22
|
+
} catch {
|
|
23
|
+
}
|
|
24
|
+
const o = Object.keys(e), a = {};
|
|
25
|
+
for (const c of o)
|
|
26
|
+
switch (c) {
|
|
27
|
+
case "autoplay":
|
|
28
|
+
a.autoplay = e.autoplay ? "1" : "0", e.autoplay && e.muted === void 0 && (a.mute = "1");
|
|
29
|
+
break;
|
|
30
|
+
case "muted":
|
|
31
|
+
a.mute = e.muted ? "1" : "0";
|
|
32
|
+
break;
|
|
33
|
+
case "showControls":
|
|
34
|
+
a.controls = e.showControls ? "1" : "0";
|
|
35
|
+
break;
|
|
36
|
+
case "showRelatedVideos":
|
|
37
|
+
a.rel = e.showRelatedVideos ? "1" : "0";
|
|
38
|
+
break;
|
|
39
|
+
case "keyboard":
|
|
40
|
+
a.keyboard = e.keyboard ? "1" : "0";
|
|
41
|
+
break;
|
|
42
|
+
case "loop":
|
|
43
|
+
a.loop = e.loop ? "1" : "0", e.loop && (e.playlist ?? "").trim() === "" && (a.playlist = l);
|
|
44
|
+
break;
|
|
45
|
+
case "inline":
|
|
46
|
+
a.playsinline = e.inline ? "1" : "0";
|
|
47
|
+
break;
|
|
48
|
+
case "allowFullscreen":
|
|
49
|
+
a.fs = e.allowFullscreen ? "1" : "0";
|
|
50
|
+
break;
|
|
51
|
+
case "captionLanguage":
|
|
52
|
+
a.cc_lang_pref = e.captionLanguage;
|
|
53
|
+
break;
|
|
54
|
+
case "showCaptions":
|
|
55
|
+
a.cc_load_policy = e.showCaptions ? "1" : "0";
|
|
56
|
+
break;
|
|
57
|
+
case "showAnnotations":
|
|
58
|
+
a.iv_load_policy = e.showAnnotations ? "1" : "3";
|
|
59
|
+
break;
|
|
60
|
+
case "startTime":
|
|
61
|
+
a.start = (n = e.startTime) == null ? void 0 : n.toString();
|
|
62
|
+
break;
|
|
63
|
+
case "endTime":
|
|
64
|
+
a.end = (i = e.endTime) == null ? void 0 : i.toString();
|
|
65
|
+
break;
|
|
66
|
+
case "disableKeyboard":
|
|
67
|
+
a.disablekb = e.disableKeyboard ? "1" : "0";
|
|
68
|
+
break;
|
|
69
|
+
case "language":
|
|
70
|
+
a.hl = e.language;
|
|
71
|
+
break;
|
|
72
|
+
case "listId":
|
|
73
|
+
a.list = e.listId;
|
|
74
|
+
break;
|
|
75
|
+
case "listType":
|
|
76
|
+
a.listType = e.listType;
|
|
77
|
+
break;
|
|
78
|
+
case "color":
|
|
79
|
+
a.color = e.color;
|
|
80
|
+
break;
|
|
81
|
+
case "origin":
|
|
82
|
+
a.origin = e.origin;
|
|
83
|
+
break;
|
|
84
|
+
case "referrer":
|
|
85
|
+
a.widget_referrer = e.referrer;
|
|
86
|
+
break;
|
|
87
|
+
case "playlist":
|
|
88
|
+
a.playlist = e.playlist;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
return Object.entries(a).forEach(([c, s]) => {
|
|
92
|
+
s !== void 0 && r.searchParams.append(c, s.toString());
|
|
93
|
+
}), r.toString();
|
|
94
|
+
}, p = (e) => {
|
|
95
|
+
const t = document.createElement("link");
|
|
96
|
+
t.rel = "preconnect", t.href = e, t.crossOrigin = "true", document.head.appendChild(t);
|
|
97
|
+
};
|
|
98
|
+
let g = !1;
|
|
99
|
+
const T = (e) => {
|
|
100
|
+
if (!(g || window.matchMedia("(hover: none)").matches)) {
|
|
101
|
+
try {
|
|
102
|
+
const t = new URL(e);
|
|
103
|
+
p(t.origin);
|
|
104
|
+
} catch {
|
|
105
|
+
}
|
|
106
|
+
p(w), g = !0;
|
|
107
|
+
}
|
|
108
|
+
}, j = (e) => new URL(`${w}/vi/${e}/maxresdefault.jpg`), A = () => /* @__PURE__ */ u("div", { className: "flex w-full h-full items-center justify-center text-lg", children: 'Open the "Settings" panel and paste a video URL, e.g. https://youtube.com/watch?v=dQw4w9WgXcQ' }), N = ({
|
|
109
|
+
title: e,
|
|
110
|
+
status: t,
|
|
111
|
+
loading: l,
|
|
112
|
+
videoUrl: r,
|
|
113
|
+
previewImageUrl: o,
|
|
114
|
+
autoplay: a,
|
|
115
|
+
renderer: n,
|
|
116
|
+
showPreview: i,
|
|
117
|
+
onStatusChange: c,
|
|
118
|
+
onPreviewImageUrlChange: s
|
|
119
|
+
}) => {
|
|
120
|
+
const [m, b] = h(0);
|
|
121
|
+
return y(() => {
|
|
122
|
+
a && n !== "canvas" && t === "initial" && c("loading");
|
|
123
|
+
}, [a, t, n, c]), y(() => {
|
|
124
|
+
n !== "canvas" && T(r);
|
|
125
|
+
}, [n, r]), y(() => {
|
|
126
|
+
const d = k(r);
|
|
127
|
+
if (!d || !i) {
|
|
128
|
+
s(void 0);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
o || s(j(d));
|
|
132
|
+
}, [s, i, r, o]), n === "canvas" || t === "initial" ? null : /* @__PURE__ */ u(
|
|
133
|
+
"iframe",
|
|
134
|
+
{
|
|
135
|
+
title: e,
|
|
136
|
+
src: r,
|
|
137
|
+
loading: l,
|
|
138
|
+
allow: "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",
|
|
139
|
+
allowFullScreen: !0,
|
|
140
|
+
style: {
|
|
141
|
+
position: "absolute",
|
|
142
|
+
width: "100%",
|
|
143
|
+
height: "100%",
|
|
144
|
+
opacity: m,
|
|
145
|
+
transition: "opacity 1s",
|
|
146
|
+
border: "none"
|
|
147
|
+
},
|
|
148
|
+
onLoad: () => {
|
|
149
|
+
c("ready"), b(1);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
}, P = L(
|
|
154
|
+
({
|
|
155
|
+
url: e,
|
|
156
|
+
loading: t = "lazy",
|
|
157
|
+
autoplay: l,
|
|
158
|
+
showPreview: r,
|
|
159
|
+
children: o,
|
|
160
|
+
privacyEnhancedMode: a,
|
|
161
|
+
...n
|
|
162
|
+
}, i) => {
|
|
163
|
+
const [c, s] = h("initial"), [m, b] = h(), { renderer: d } = C(I), v = a ?? !0 ? O : x, f = S(
|
|
164
|
+
{
|
|
165
|
+
...n,
|
|
166
|
+
url: e,
|
|
167
|
+
autoplay: !0
|
|
168
|
+
},
|
|
169
|
+
v
|
|
170
|
+
);
|
|
171
|
+
return /* @__PURE__ */ u(
|
|
172
|
+
E.Provider,
|
|
173
|
+
{
|
|
174
|
+
value: {
|
|
175
|
+
status: c,
|
|
176
|
+
previewImageUrl: m,
|
|
177
|
+
onInitPlayer() {
|
|
178
|
+
d !== "canvas" && s("loading");
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
children: /* @__PURE__ */ u("div", { ...n, ref: i, children: f ? /* @__PURE__ */ R(_, { children: [
|
|
182
|
+
o,
|
|
183
|
+
/* @__PURE__ */ u(
|
|
184
|
+
N,
|
|
185
|
+
{
|
|
186
|
+
title: n.title,
|
|
187
|
+
autoplay: l,
|
|
188
|
+
videoUrl: f,
|
|
189
|
+
previewImageUrl: m,
|
|
190
|
+
loading: t,
|
|
191
|
+
showPreview: r,
|
|
192
|
+
renderer: d,
|
|
193
|
+
status: c,
|
|
194
|
+
onStatusChange: s,
|
|
195
|
+
onPreviewImageUrlChange: b
|
|
196
|
+
}
|
|
197
|
+
)
|
|
198
|
+
] }) : /* @__PURE__ */ u(A, {}) })
|
|
199
|
+
}
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
);
|
|
203
|
+
P.displayName = "YouTube";
|
|
204
|
+
export {
|
|
205
|
+
P as YouTube
|
|
206
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { jsxs as i, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { SpinnerIcon as r, PlayIcon as l } from "@webstudio-is/icons/svg";
|
|
3
|
+
import { $ as e, css as o } from "@webstudio-is/template";
|
|
4
|
+
const p = {
|
|
5
|
+
label: "YouTube",
|
|
6
|
+
category: "media",
|
|
7
|
+
order: 1,
|
|
8
|
+
description: "Add a video to your page that is hosted on YouTube. Paste a YouTube URL and configure the video in the Settings tab.",
|
|
9
|
+
template: /* @__PURE__ */ i(
|
|
10
|
+
e.YouTube,
|
|
11
|
+
{
|
|
12
|
+
"ws:label": "YouTube",
|
|
13
|
+
"ws:style": o`
|
|
14
|
+
position: relative;
|
|
15
|
+
aspect-ratio: 640/360;
|
|
16
|
+
width: 100%;
|
|
17
|
+
`,
|
|
18
|
+
children: [
|
|
19
|
+
/* @__PURE__ */ t(
|
|
20
|
+
e.VimeoPreviewImage,
|
|
21
|
+
{
|
|
22
|
+
"ws:label": "Preview Image",
|
|
23
|
+
"ws:style": o`
|
|
24
|
+
position: absolute;
|
|
25
|
+
object-fit: cover;
|
|
26
|
+
object-position: center;
|
|
27
|
+
width: 100%;
|
|
28
|
+
height: 100%;
|
|
29
|
+
border-radius: 20px;
|
|
30
|
+
`,
|
|
31
|
+
alt: "YouTube video preview image",
|
|
32
|
+
sizes: "100vw",
|
|
33
|
+
optimize: !0
|
|
34
|
+
}
|
|
35
|
+
),
|
|
36
|
+
/* @__PURE__ */ t(
|
|
37
|
+
e.VimeoSpinner,
|
|
38
|
+
{
|
|
39
|
+
"ws:label": "Spinner",
|
|
40
|
+
"ws:style": o`
|
|
41
|
+
position: absolute;
|
|
42
|
+
top: 50%;
|
|
43
|
+
left: 50%;
|
|
44
|
+
width: 70px;
|
|
45
|
+
height: 70px;
|
|
46
|
+
margin-top: -35px;
|
|
47
|
+
margin-left: -35px;
|
|
48
|
+
`,
|
|
49
|
+
children: /* @__PURE__ */ t(e.HtmlEmbed, { "ws:label": "Spinner SVG", code: r })
|
|
50
|
+
}
|
|
51
|
+
),
|
|
52
|
+
/* @__PURE__ */ t(
|
|
53
|
+
e.VimeoPlayButton,
|
|
54
|
+
{
|
|
55
|
+
"ws:label": "Play Button",
|
|
56
|
+
"ws:style": o`
|
|
57
|
+
position: absolute;
|
|
58
|
+
width: 140px;
|
|
59
|
+
height: 80px;
|
|
60
|
+
top: 50%;
|
|
61
|
+
left: 50%;
|
|
62
|
+
margin-top: -40px;
|
|
63
|
+
margin-left: -70px;
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
justify-content: center;
|
|
67
|
+
border-style: none;
|
|
68
|
+
border-radius: 5px;
|
|
69
|
+
cursor: pointer;
|
|
70
|
+
background-color: rgb(18, 18, 18);
|
|
71
|
+
color: rgb(255, 255, 255);
|
|
72
|
+
&:hover {
|
|
73
|
+
background-color: rgb(0, 173, 239);
|
|
74
|
+
}
|
|
75
|
+
`,
|
|
76
|
+
"aria-label": "Play button",
|
|
77
|
+
children: /* @__PURE__ */ t(
|
|
78
|
+
e.Box,
|
|
79
|
+
{
|
|
80
|
+
"ws:label": "Play Icon",
|
|
81
|
+
"ws:style": o`
|
|
82
|
+
width: 60px;
|
|
83
|
+
height: 60px;
|
|
84
|
+
`,
|
|
85
|
+
"aria-hidden": !0,
|
|
86
|
+
children: /* @__PURE__ */ t(e.HtmlEmbed, { "ws:label": "Play SVG", code: l })
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
};
|
|
95
|
+
export {
|
|
96
|
+
p as meta
|
|
97
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { YoutubeIcon as o } from "@webstudio-is/icons/svg";
|
|
2
|
+
import { defaultStates as t } from "@webstudio-is/sdk";
|
|
3
|
+
import { div as e } from "@webstudio-is/sdk/normalize.css";
|
|
4
|
+
import { props as n } from "./__generated__/youtube.props.js";
|
|
5
|
+
const i = {
|
|
6
|
+
div: e
|
|
7
|
+
}, c = {
|
|
8
|
+
type: "container",
|
|
9
|
+
icon: o,
|
|
10
|
+
states: t,
|
|
11
|
+
presetStyle: i,
|
|
12
|
+
constraints: {
|
|
13
|
+
relation: "ancestor",
|
|
14
|
+
component: { $nin: ["Button", "Link", "Heading"] }
|
|
15
|
+
}
|
|
16
|
+
}, a = [
|
|
17
|
+
"id",
|
|
18
|
+
"className",
|
|
19
|
+
"url",
|
|
20
|
+
"privacyEnhancedMode",
|
|
21
|
+
"title",
|
|
22
|
+
"loading",
|
|
23
|
+
"showPreview",
|
|
24
|
+
"autoplay",
|
|
25
|
+
"showControls",
|
|
26
|
+
"showRelatedVideos",
|
|
27
|
+
"keyboard",
|
|
28
|
+
"loop",
|
|
29
|
+
"inline",
|
|
30
|
+
"allowFullscreen",
|
|
31
|
+
"showCaptions",
|
|
32
|
+
"showAnnotations",
|
|
33
|
+
"startTime",
|
|
34
|
+
"endTime",
|
|
35
|
+
"disableKeyboard",
|
|
36
|
+
"referrer",
|
|
37
|
+
"listType",
|
|
38
|
+
"listId",
|
|
39
|
+
"origin",
|
|
40
|
+
"captionLanguage",
|
|
41
|
+
"language",
|
|
42
|
+
"color",
|
|
43
|
+
"playlist"
|
|
44
|
+
], d = {
|
|
45
|
+
props: n,
|
|
46
|
+
initialProps: a
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
c as meta,
|
|
50
|
+
d as propsMeta
|
|
51
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webstudio-is/sdk-components-react",
|
|
3
|
+
"version": "0.0.0-021f2d4",
|
|
4
|
+
"description": "Webstudio default library for react",
|
|
5
|
+
"author": "Webstudio <github@webstudio.is>",
|
|
6
|
+
"homepage": "https://webstudio.is",
|
|
7
|
+
"license": "AGPL-3.0-or-later",
|
|
8
|
+
"private": false,
|
|
9
|
+
"type": "module",
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"files": [
|
|
12
|
+
"lib/*",
|
|
13
|
+
"!*.{test,stories}.*"
|
|
14
|
+
],
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"webstudio": "./src/components.ts",
|
|
18
|
+
"types": "./lib/types/components.d.ts",
|
|
19
|
+
"import": "./lib/components.js"
|
|
20
|
+
},
|
|
21
|
+
"./metas": {
|
|
22
|
+
"webstudio": "./src/metas.ts",
|
|
23
|
+
"types": "./lib/types/metas.d.ts",
|
|
24
|
+
"import": "./lib/metas.js"
|
|
25
|
+
},
|
|
26
|
+
"./props": {
|
|
27
|
+
"webstudio": "./src/props.ts",
|
|
28
|
+
"types": "./lib/types/props.d.ts",
|
|
29
|
+
"import": "./lib/props.js"
|
|
30
|
+
},
|
|
31
|
+
"./hooks": {
|
|
32
|
+
"webstudio": "./src/hooks.ts",
|
|
33
|
+
"types": "./lib/types/hooks.d.ts",
|
|
34
|
+
"import": "./lib/hooks.js"
|
|
35
|
+
},
|
|
36
|
+
"./templates": {
|
|
37
|
+
"webstudio": "./src/templates.ts",
|
|
38
|
+
"types": "./lib/types/templates.d.ts",
|
|
39
|
+
"import": "./lib/templates.js"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"react": "18.3.0-canary-14898b6a9-20240318",
|
|
44
|
+
"react-dom": "18.3.0-canary-14898b6a9-20240318"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@react-aria/utils": "^3.27.0",
|
|
48
|
+
"await-interaction-response": "^0.0.2",
|
|
49
|
+
"colord": "^2.9.3",
|
|
50
|
+
"micromark": "^4.0.1",
|
|
51
|
+
"micromark-extension-gfm-table": "^2.1.0",
|
|
52
|
+
"@webstudio-is/image": "0.0.0-021f2d4",
|
|
53
|
+
"@webstudio-is/react-sdk": "0.0.0-021f2d4",
|
|
54
|
+
"@webstudio-is/icons": "0.0.0-021f2d4",
|
|
55
|
+
"@webstudio-is/sdk": "0.0.0-021f2d4"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@testing-library/react": "^14.2.2",
|
|
59
|
+
"@types/react": "^18.2.70",
|
|
60
|
+
"@types/react-dom": "^18.2.25",
|
|
61
|
+
"react": "18.3.0-canary-14898b6a9-20240318",
|
|
62
|
+
"react-dom": "18.3.0-canary-14898b6a9-20240318",
|
|
63
|
+
"vitest": "^3.0.2",
|
|
64
|
+
"@webstudio-is/generate-arg-types": "0.0.0",
|
|
65
|
+
"@webstudio-is/sdk-cli": "0.94.0",
|
|
66
|
+
"@webstudio-is/tsconfig": "1.0.7",
|
|
67
|
+
"@webstudio-is/template": "0.0.0-021f2d4"
|
|
68
|
+
},
|
|
69
|
+
"scripts": {
|
|
70
|
+
"build": "vite build --config ../../vite.sdk-components.config.ts",
|
|
71
|
+
"build:args": "NODE_OPTIONS=--conditions=webstudio generate-arg-types './src/*.tsx !./src/*.stories.tsx !./src/*.test.{ts,tsx} !./src/*.ws.ts !./src/*.ws.ts !./src/*.template.tsx' && prettier --write \"**/*.props.ts\"",
|
|
72
|
+
"build:stories": "webstudio-sdk generate-stories && prettier --write \"src/__generated__/*.stories.tsx\"",
|
|
73
|
+
"dts": "tsc --project tsconfig.dts.json",
|
|
74
|
+
"test": "vitest run",
|
|
75
|
+
"typecheck": "tsc"
|
|
76
|
+
}
|
|
77
|
+
}
|