@webstudio-is/sdk-components-react 0.196.0 → 0.198.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/__generated__/image.props.js +1 -0
- package/lib/__generated__/vimeo-preview-image.props.js +6 -1
- package/lib/__generated__/vimeo.props.js +4 -5
- package/lib/__generated__/youtube.props.js +665 -0
- package/lib/blockquote.template.js +11 -0
- package/lib/blockquote.ws.js +5 -15
- package/lib/body.ws.js +1 -1
- package/lib/bold.ws.js +1 -1
- package/lib/box.ws.js +1 -1
- package/lib/button.ws.js +1 -1
- package/lib/checkbox.template.js +14 -0
- package/lib/checkbox.ws.js +5 -25
- package/lib/code-text.ws.js +1 -1
- package/lib/components.js +35 -33
- package/lib/content-embed.template.js +83 -0
- package/lib/form.ws.js +1 -1
- package/lib/heading.template.js +11 -0
- package/lib/heading.ws.js +12 -22
- package/lib/image.ws.js +17 -22
- package/lib/input.ws.js +1 -1
- package/lib/italic.ws.js +1 -1
- package/lib/label.template.js +10 -0
- package/lib/label.ws.js +13 -28
- package/lib/link.template.js +11 -0
- package/lib/link.ws.js +3 -13
- package/lib/list-item.template.js +11 -0
- package/lib/list-item.ws.js +8 -18
- package/lib/list.ws.js +1 -1
- package/lib/markdown-embed.js +10 -5
- package/lib/markdown-embed.template.js +75 -0
- package/lib/markdown-embed.ws.js +9 -87
- package/lib/metas.js +59 -59
- package/lib/option.ws.js +4 -5
- package/lib/paragraph.template.js +11 -0
- package/lib/paragraph.ws.js +10 -20
- package/lib/props.js +32 -30
- package/lib/radio-button.template.js +14 -0
- package/lib/radio-button.ws.js +7 -27
- package/lib/rich-text-link.ws.js +3 -5
- package/lib/select.template.js +16 -0
- package/lib/select.ws.js +11 -63
- package/lib/separator.ws.js +1 -1
- package/lib/span.ws.js +1 -1
- package/lib/subscript.ws.js +1 -1
- package/lib/superscript.ws.js +1 -1
- package/lib/templates.js +34 -6
- package/lib/text.template.js +11 -0
- package/lib/text.ws.js +9 -25
- package/lib/textarea.ws.js +1 -1
- package/lib/time.ws.js +1 -1
- package/lib/types/__generated__/blockquote.props.d.ts +1 -1
- package/lib/types/__generated__/body.props.d.ts +1 -1
- package/lib/types/__generated__/bold.props.d.ts +1 -1
- package/lib/types/__generated__/box.props.d.ts +1 -1
- package/lib/types/__generated__/button.props.d.ts +1 -1
- package/lib/types/__generated__/checkbox.props.d.ts +1 -1
- package/lib/types/__generated__/code-text.props.d.ts +1 -1
- package/lib/types/__generated__/form.props.d.ts +1 -1
- package/lib/types/__generated__/fragment.props.d.ts +1 -1
- package/lib/types/__generated__/heading.props.d.ts +1 -1
- package/lib/types/__generated__/html-embed.props.d.ts +1 -1
- package/lib/types/__generated__/image.props.d.ts +1 -1
- package/lib/types/__generated__/input.props.d.ts +1 -1
- package/lib/types/__generated__/italic.props.d.ts +1 -1
- package/lib/types/__generated__/label.props.d.ts +1 -1
- package/lib/types/__generated__/link.props.d.ts +1 -1
- package/lib/types/__generated__/list-item.props.d.ts +1 -1
- package/lib/types/__generated__/list.props.d.ts +1 -1
- package/lib/types/__generated__/markdown-embed.props.d.ts +1 -1
- package/lib/types/__generated__/option.props.d.ts +1 -1
- package/lib/types/__generated__/paragraph.props.d.ts +1 -1
- package/lib/types/__generated__/radio-button.props.d.ts +1 -1
- package/lib/types/__generated__/rich-text-link.props.d.ts +1 -1
- package/lib/types/__generated__/select.props.d.ts +1 -1
- package/lib/types/__generated__/separator.props.d.ts +1 -1
- package/lib/types/__generated__/slot.props.d.ts +1 -1
- package/lib/types/__generated__/span.props.d.ts +1 -1
- package/lib/types/__generated__/subscript.props.d.ts +1 -1
- package/lib/types/__generated__/superscript.props.d.ts +1 -1
- package/lib/types/__generated__/text.props.d.ts +1 -1
- package/lib/types/__generated__/textarea.props.d.ts +1 -1
- package/lib/types/__generated__/time.props.d.ts +1 -1
- package/lib/types/__generated__/vimeo-play-button.props.d.ts +1 -1
- package/lib/types/__generated__/vimeo-preview-image.props.d.ts +1 -1
- package/lib/types/__generated__/vimeo-spinner.props.d.ts +1 -1
- package/lib/types/__generated__/vimeo.props.d.ts +1 -1
- package/lib/types/__generated__/webhook-form.props.d.ts +1 -1
- package/lib/types/__generated__/xml-node.props.d.ts +1 -1
- package/lib/types/__generated__/xml-time.props.d.ts +1 -1
- package/lib/types/__generated__/youtube.props.d.ts +2 -0
- package/lib/types/blockquote.template.d.ts +2 -0
- package/lib/types/blockquote.ws.d.ts +1 -1
- package/lib/types/body.ws.d.ts +1 -1
- package/lib/types/bold.ws.d.ts +1 -1
- package/lib/types/box.ws.d.ts +1 -1
- package/lib/types/button.ws.d.ts +1 -1
- package/lib/types/checkbox.d.ts +1 -1
- package/lib/types/checkbox.template.d.ts +2 -0
- package/lib/types/checkbox.ws.d.ts +1 -1
- package/lib/types/code-text.ws.d.ts +1 -1
- package/lib/types/components.d.ts +1 -0
- package/lib/types/content-embed.template.d.ts +2 -0
- package/lib/types/form.ws.d.ts +1 -1
- package/lib/types/fragment.ws.d.ts +1 -1
- package/lib/types/heading.template.d.ts +2 -0
- package/lib/types/heading.ws.d.ts +1 -1
- package/lib/types/html-embed.ws.d.ts +1 -1
- package/lib/types/image.ws.d.ts +1 -9
- package/lib/types/input.ws.d.ts +1 -1
- package/lib/types/italic.ws.d.ts +1 -1
- package/lib/types/label.template.d.ts +2 -0
- package/lib/types/label.ws.d.ts +1 -1
- package/lib/types/link.template.d.ts +2 -0
- package/lib/types/link.ws.d.ts +1 -1
- package/lib/types/list-item.template.d.ts +2 -0
- package/lib/types/list-item.ws.d.ts +1 -1
- package/lib/types/list.ws.d.ts +1 -1
- package/lib/types/markdown-embed.template.d.ts +2 -0
- package/lib/types/markdown-embed.ws.d.ts +1 -1
- package/lib/types/metas.d.ts +1 -1
- package/lib/types/option.ws.d.ts +1 -1
- package/lib/types/paragraph.template.d.ts +2 -0
- package/lib/types/paragraph.ws.d.ts +1 -1
- package/lib/types/props.d.ts +1 -0
- package/lib/types/radio-button.d.ts +1 -1
- package/lib/types/radio-button.template.d.ts +2 -0
- package/lib/types/radio-button.ws.d.ts +1 -1
- package/lib/types/rich-text-link.ws.d.ts +1 -1
- package/lib/types/select.template.d.ts +2 -0
- package/lib/types/select.ws.d.ts +1 -1
- package/lib/types/separator.ws.d.ts +1 -1
- package/lib/types/slot.ws.d.ts +1 -1
- package/lib/types/span.ws.d.ts +1 -1
- package/lib/types/subscript.ws.d.ts +1 -1
- package/lib/types/superscript.ws.d.ts +1 -1
- package/lib/types/templates.d.ts +14 -0
- package/lib/types/text.template.d.ts +2 -0
- package/lib/types/text.ws.d.ts +1 -1
- package/lib/types/textarea.ws.d.ts +1 -1
- package/lib/types/time.ws.d.ts +1 -1
- package/lib/types/vimeo-play-button.ws.d.ts +1 -1
- package/lib/types/vimeo-preview-image.d.ts +21 -21
- package/lib/types/vimeo-preview-image.ws.d.ts +1 -1
- package/lib/types/vimeo-spinner.ws.d.ts +1 -1
- package/lib/types/vimeo.d.ts +12 -2
- package/lib/types/vimeo.ws.d.ts +1 -1
- package/lib/types/webhook-form.d.ts +1 -0
- package/lib/types/webhook-form.template.d.ts +2 -0
- package/lib/types/webhook-form.ws.d.ts +1 -1
- package/lib/types/xml-node.ws.d.ts +1 -1
- package/lib/types/xml-time.ws.d.ts +1 -1
- 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.ws.js +8 -8
- package/lib/vimeo-preview-image.ws.js +17 -9
- package/lib/vimeo-spinner.ws.js +8 -8
- package/lib/vimeo.js +88 -87
- package/lib/vimeo.template.js +17 -16
- package/lib/vimeo.ws.js +8 -7
- package/lib/webhook-form.template.js +49 -0
- package/lib/webhook-form.ws.js +17 -118
- package/lib/xml-node.js +18 -14
- package/lib/xml-node.ws.js +4 -5
- package/lib/xml-time.ws.js +4 -5
- package/lib/youtube.js +200 -0
- package/lib/youtube.template.js +97 -0
- package/lib/youtube.ws.js +51 -0
- package/package.json +14 -11
- package/lib/content-embed.ws.js +0 -77
- package/lib/types/__generated__/local-date.props.d.ts +0 -2
- package/lib/types/content-embed.ws.d.ts +0 -2
package/lib/webhook-form.ws.js
CHANGED
|
@@ -1,127 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { props as
|
|
4
|
-
|
|
5
|
-
const c = {
|
|
6
|
-
...t,
|
|
7
|
-
category: "data",
|
|
1
|
+
import { WebhookFormIcon as o } from "@webstudio-is/icons/svg";
|
|
2
|
+
import { form as t } from "@webstudio-is/sdk/normalize.css";
|
|
3
|
+
import { props as e } from "./__generated__/webhook-form.props.js";
|
|
4
|
+
const n = {
|
|
8
5
|
label: "Webhook Form",
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
icon: o,
|
|
7
|
+
type: "container",
|
|
8
|
+
constraints: {
|
|
9
|
+
relation: "ancestor",
|
|
10
|
+
component: { $nin: ["Form", "Button", "Link"] }
|
|
11
|
+
},
|
|
12
|
+
presetStyle: {
|
|
13
|
+
form: t
|
|
14
|
+
},
|
|
12
15
|
states: [
|
|
13
16
|
{ selector: "[data-state=error]", label: "Error" },
|
|
14
17
|
{ selector: "[data-state=success]", label: "Success" }
|
|
15
|
-
],
|
|
16
|
-
template: [
|
|
17
|
-
{
|
|
18
|
-
type: "instance",
|
|
19
|
-
component: "Form",
|
|
20
|
-
variables: {
|
|
21
|
-
formState: { initialValue: "initial" }
|
|
22
|
-
},
|
|
23
|
-
props: [
|
|
24
|
-
{
|
|
25
|
-
type: "expression",
|
|
26
|
-
name: "state",
|
|
27
|
-
code: "formState"
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
type: "action",
|
|
31
|
-
name: "onStateChange",
|
|
32
|
-
value: [
|
|
33
|
-
{ type: "execute", args: ["state"], code: "formState = state" }
|
|
34
|
-
]
|
|
35
|
-
}
|
|
36
|
-
],
|
|
37
|
-
children: [
|
|
38
|
-
{
|
|
39
|
-
type: "instance",
|
|
40
|
-
label: "Form Content",
|
|
41
|
-
component: "Box",
|
|
42
|
-
props: [
|
|
43
|
-
{
|
|
44
|
-
type: "expression",
|
|
45
|
-
name: e,
|
|
46
|
-
code: "formState === 'initial' || formState === 'error'"
|
|
47
|
-
}
|
|
48
|
-
],
|
|
49
|
-
children: [
|
|
50
|
-
{
|
|
51
|
-
type: "instance",
|
|
52
|
-
component: "Label",
|
|
53
|
-
children: [{ type: "text", value: "Name", placeholder: !0 }]
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
type: "instance",
|
|
57
|
-
component: "Input",
|
|
58
|
-
props: [{ type: "string", name: "name", value: "name" }],
|
|
59
|
-
children: []
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
type: "instance",
|
|
63
|
-
component: "Label",
|
|
64
|
-
children: [{ type: "text", value: "Email", placeholder: !0 }]
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
type: "instance",
|
|
68
|
-
component: "Input",
|
|
69
|
-
props: [{ type: "string", name: "name", value: "email" }],
|
|
70
|
-
children: []
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
type: "instance",
|
|
74
|
-
component: "Button",
|
|
75
|
-
children: [{ type: "text", value: "Submit", placeholder: !0 }]
|
|
76
|
-
}
|
|
77
|
-
]
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
type: "instance",
|
|
81
|
-
label: "Success Message",
|
|
82
|
-
component: "Box",
|
|
83
|
-
props: [
|
|
84
|
-
{
|
|
85
|
-
type: "expression",
|
|
86
|
-
name: e,
|
|
87
|
-
code: "formState === 'success'"
|
|
88
|
-
}
|
|
89
|
-
],
|
|
90
|
-
children: [
|
|
91
|
-
{
|
|
92
|
-
type: "text",
|
|
93
|
-
value: "Thank you for getting in touch!",
|
|
94
|
-
placeholder: !0
|
|
95
|
-
}
|
|
96
|
-
]
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
type: "instance",
|
|
100
|
-
label: "Error Message",
|
|
101
|
-
component: "Box",
|
|
102
|
-
props: [
|
|
103
|
-
{
|
|
104
|
-
type: "expression",
|
|
105
|
-
name: e,
|
|
106
|
-
code: "formState === 'error'"
|
|
107
|
-
}
|
|
108
|
-
],
|
|
109
|
-
children: [
|
|
110
|
-
{
|
|
111
|
-
type: "text",
|
|
112
|
-
value: "Sorry, something went wrong.",
|
|
113
|
-
placeholder: !0
|
|
114
|
-
}
|
|
115
|
-
]
|
|
116
|
-
}
|
|
117
|
-
]
|
|
118
|
-
}
|
|
119
18
|
]
|
|
120
|
-
},
|
|
121
|
-
props:
|
|
19
|
+
}, c = {
|
|
20
|
+
props: e,
|
|
122
21
|
initialProps: ["id", "className", "state", "action"]
|
|
123
22
|
};
|
|
124
23
|
export {
|
|
125
|
-
|
|
126
|
-
|
|
24
|
+
n as meta,
|
|
25
|
+
c as propsMeta
|
|
127
26
|
};
|
package/lib/xml-node.js
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
import { jsxs as n, jsx as p } from "react/jsx-runtime";
|
|
2
|
-
import { ReactSdkContext as y } from "@webstudio-is/react-sdk/runtime";
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
const
|
|
5
|
-
({ tag:
|
|
6
|
-
const { renderer: f } =
|
|
2
|
+
import { ReactSdkContext as y, xmlNodeTagSuffix as g } from "@webstudio-is/react-sdk/runtime";
|
|
3
|
+
import { forwardRef as u, useContext as x, createElement as b, Children as h } from "react";
|
|
4
|
+
const N = u(
|
|
5
|
+
({ tag: a = "", children: e, ...o }, c) => {
|
|
6
|
+
const { renderer: f } = x(y), s = Object.entries(o).filter(
|
|
7
7
|
([t]) => t.startsWith("data-") === !1 && t.startsWith("aria-") === !1
|
|
8
|
-
).filter(([t]) => t !== "tabIndex").filter(([, t]) => typeof t != "function");
|
|
8
|
+
).filter(([t]) => t !== "tabIndex").filter(([, t]) => typeof t != "function"), r = a.replace(/^[^\p{L}_]+/u, "").replaceAll(/[^\p{L}\p{N}\-._:]+/gu, "").trim();
|
|
9
9
|
if (f === void 0) {
|
|
10
10
|
const t = Object.fromEntries(s);
|
|
11
|
-
return
|
|
11
|
+
return b(
|
|
12
|
+
`${r}${g}`,
|
|
13
|
+
t,
|
|
14
|
+
e
|
|
15
|
+
);
|
|
12
16
|
}
|
|
13
|
-
const
|
|
14
|
-
([t,
|
|
17
|
+
const i = h.toArray(e), l = i.length > 0 && i.every((t) => typeof t == "string"), m = s.map(
|
|
18
|
+
([t, d]) => `${t}=${JSON.stringify(d)}`
|
|
15
19
|
);
|
|
16
20
|
return /* @__PURE__ */ n("div", { ...o, children: [
|
|
17
21
|
/* @__PURE__ */ n("span", { style: { color: "rgb(16, 23, 233)" }, children: [
|
|
18
22
|
"<",
|
|
19
|
-
[
|
|
23
|
+
[r, ...m].join(" "),
|
|
20
24
|
">"
|
|
21
25
|
] }),
|
|
22
|
-
|
|
26
|
+
i.length > 0 && /* @__PURE__ */ p(
|
|
23
27
|
"div",
|
|
24
28
|
{
|
|
25
29
|
ref: c,
|
|
@@ -32,13 +36,13 @@ const x = b(
|
|
|
32
36
|
),
|
|
33
37
|
/* @__PURE__ */ n("span", { style: { color: "rgb(16, 23, 233)" }, children: [
|
|
34
38
|
"</",
|
|
35
|
-
|
|
39
|
+
r,
|
|
36
40
|
">"
|
|
37
41
|
] })
|
|
38
42
|
] });
|
|
39
43
|
}
|
|
40
44
|
);
|
|
41
|
-
|
|
45
|
+
N.displayName = "XmlNode";
|
|
42
46
|
export {
|
|
43
|
-
|
|
47
|
+
N as XmlNode
|
|
44
48
|
};
|
package/lib/xml-node.ws.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { XmlIcon as o } from "@webstudio-is/icons/svg";
|
|
2
|
-
import "@webstudio-is/react-sdk";
|
|
3
2
|
import { props as t } from "./__generated__/xml-node.props.js";
|
|
4
|
-
const
|
|
3
|
+
const p = {
|
|
5
4
|
category: "xml",
|
|
6
5
|
order: 6,
|
|
7
6
|
type: "container",
|
|
8
7
|
icon: o,
|
|
9
8
|
stylable: !1,
|
|
10
9
|
description: "XML Node"
|
|
11
|
-
},
|
|
10
|
+
}, i = {
|
|
12
11
|
props: t,
|
|
13
12
|
initialProps: ["tag"]
|
|
14
13
|
};
|
|
15
14
|
export {
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
p as meta,
|
|
16
|
+
i as propsMeta
|
|
18
17
|
};
|
package/lib/xml-time.ws.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { CalendarIcon as t } from "@webstudio-is/icons/svg";
|
|
2
|
-
import "@webstudio-is/react-sdk";
|
|
3
2
|
import { props as e } from "./__generated__/xml-time.props.js";
|
|
4
|
-
const
|
|
3
|
+
const r = {
|
|
5
4
|
category: "xml",
|
|
6
5
|
type: "container",
|
|
7
6
|
description: "Converts machine-readable date and time to ISO format.",
|
|
8
7
|
icon: t,
|
|
9
8
|
stylable: !1,
|
|
10
9
|
order: 7
|
|
11
|
-
},
|
|
10
|
+
}, i = {
|
|
12
11
|
props: e,
|
|
13
12
|
initialProps: ["datetime", "dateStyle"]
|
|
14
13
|
};
|
|
15
14
|
export {
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
r as meta,
|
|
16
|
+
i as propsMeta
|
|
18
17
|
};
|
package/lib/youtube.js
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { jsx as u, jsxs as _, Fragment as R } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as C, useState as f, useContext as I, useEffect as y } from "react";
|
|
3
|
+
import { ReactSdkContext as L } 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 a = new URL(e);
|
|
9
|
+
return a.hostname === "youtu.be" ? a.pathname.slice(1) : a.searchParams.get("v") || a.pathname.split("/").pop();
|
|
10
|
+
} catch {
|
|
11
|
+
return e;
|
|
12
|
+
}
|
|
13
|
+
}, S = (e, a) => {
|
|
14
|
+
var r, s;
|
|
15
|
+
const o = k(e.url);
|
|
16
|
+
if (!o)
|
|
17
|
+
return;
|
|
18
|
+
const c = new URL(`${a}/embed/${o}`), l = Object.keys(e), t = {};
|
|
19
|
+
for (const n of l)
|
|
20
|
+
switch (n) {
|
|
21
|
+
case "autoplay":
|
|
22
|
+
t.autoplay = e.autoplay ? "1" : "0", e.autoplay && e.muted === void 0 && (t.mute = "1");
|
|
23
|
+
break;
|
|
24
|
+
case "muted":
|
|
25
|
+
t.mute = e.muted ? "1" : "0";
|
|
26
|
+
break;
|
|
27
|
+
case "showControls":
|
|
28
|
+
t.controls = e.showControls ? "1" : "0";
|
|
29
|
+
break;
|
|
30
|
+
case "showRelatedVideos":
|
|
31
|
+
t.rel = e.showRelatedVideos ? "1" : "0";
|
|
32
|
+
break;
|
|
33
|
+
case "keyboard":
|
|
34
|
+
t.keyboard = e.keyboard ? "1" : "0";
|
|
35
|
+
break;
|
|
36
|
+
case "loop":
|
|
37
|
+
t.loop = e.loop ? "1" : "0", e.loop && (e.playlist ?? "").trim() === "" && (t.playlist = o);
|
|
38
|
+
break;
|
|
39
|
+
case "inline":
|
|
40
|
+
t.playsinline = e.inline ? "1" : "0";
|
|
41
|
+
break;
|
|
42
|
+
case "allowFullscreen":
|
|
43
|
+
t.fs = e.allowFullscreen ? "1" : "0";
|
|
44
|
+
break;
|
|
45
|
+
case "captionLanguage":
|
|
46
|
+
t.cc_lang_pref = e.captionLanguage;
|
|
47
|
+
break;
|
|
48
|
+
case "showCaptions":
|
|
49
|
+
t.cc_load_policy = e.showCaptions ? "1" : "0";
|
|
50
|
+
break;
|
|
51
|
+
case "showAnnotations":
|
|
52
|
+
t.iv_load_policy = e.showAnnotations ? "1" : "3";
|
|
53
|
+
break;
|
|
54
|
+
case "startTime":
|
|
55
|
+
t.start = (r = e.startTime) == null ? void 0 : r.toString();
|
|
56
|
+
break;
|
|
57
|
+
case "endTime":
|
|
58
|
+
t.end = (s = e.endTime) == null ? void 0 : s.toString();
|
|
59
|
+
break;
|
|
60
|
+
case "disableKeyboard":
|
|
61
|
+
t.disablekb = e.disableKeyboard ? "1" : "0";
|
|
62
|
+
break;
|
|
63
|
+
case "language":
|
|
64
|
+
t.hl = e.language;
|
|
65
|
+
break;
|
|
66
|
+
case "listId":
|
|
67
|
+
t.list = e.listId;
|
|
68
|
+
break;
|
|
69
|
+
case "listType":
|
|
70
|
+
t.listType = e.listType;
|
|
71
|
+
break;
|
|
72
|
+
case "color":
|
|
73
|
+
t.color = e.color;
|
|
74
|
+
break;
|
|
75
|
+
case "origin":
|
|
76
|
+
t.origin = e.origin;
|
|
77
|
+
break;
|
|
78
|
+
case "referrer":
|
|
79
|
+
t.widget_referrer = e.referrer;
|
|
80
|
+
break;
|
|
81
|
+
case "playlist":
|
|
82
|
+
t.playlist = e.playlist;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
return Object.entries(t).forEach(([n, i]) => {
|
|
86
|
+
i !== void 0 && c.searchParams.append(n, i.toString());
|
|
87
|
+
}), c.toString();
|
|
88
|
+
}, h = (e) => {
|
|
89
|
+
const a = document.createElement("link");
|
|
90
|
+
a.rel = "preconnect", a.href = e, a.crossOrigin = "true", document.head.appendChild(a);
|
|
91
|
+
};
|
|
92
|
+
let g = !1;
|
|
93
|
+
const T = (e) => {
|
|
94
|
+
if (!(g || window.matchMedia("(hover: none)").matches)) {
|
|
95
|
+
try {
|
|
96
|
+
const a = new URL(e);
|
|
97
|
+
h(a.origin);
|
|
98
|
+
} catch {
|
|
99
|
+
}
|
|
100
|
+
h(w), g = !0;
|
|
101
|
+
}
|
|
102
|
+
}, 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 = ({
|
|
103
|
+
title: e,
|
|
104
|
+
status: a,
|
|
105
|
+
loading: o,
|
|
106
|
+
videoUrl: c,
|
|
107
|
+
previewImageUrl: l,
|
|
108
|
+
autoplay: t,
|
|
109
|
+
renderer: r,
|
|
110
|
+
showPreview: s,
|
|
111
|
+
onStatusChange: n,
|
|
112
|
+
onPreviewImageUrlChange: i
|
|
113
|
+
}) => {
|
|
114
|
+
const [m, b] = f(0);
|
|
115
|
+
return y(() => {
|
|
116
|
+
t && r !== "canvas" && a === "initial" && n("loading");
|
|
117
|
+
}, [t, a, r, n]), y(() => {
|
|
118
|
+
r !== "canvas" && T(c);
|
|
119
|
+
}, [r, c]), y(() => {
|
|
120
|
+
const d = k(c);
|
|
121
|
+
if (!d || !s) {
|
|
122
|
+
i(void 0);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
l || i(j(d));
|
|
126
|
+
}, [i, s, c, l]), r === "canvas" || a === "initial" ? null : /* @__PURE__ */ u(
|
|
127
|
+
"iframe",
|
|
128
|
+
{
|
|
129
|
+
title: e,
|
|
130
|
+
src: c,
|
|
131
|
+
loading: o,
|
|
132
|
+
allow: "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",
|
|
133
|
+
allowFullScreen: !0,
|
|
134
|
+
style: {
|
|
135
|
+
position: "absolute",
|
|
136
|
+
width: "100%",
|
|
137
|
+
height: "100%",
|
|
138
|
+
opacity: m,
|
|
139
|
+
transition: "opacity 1s",
|
|
140
|
+
border: "none"
|
|
141
|
+
},
|
|
142
|
+
onLoad: () => {
|
|
143
|
+
n("ready"), b(1);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
}, P = C(
|
|
148
|
+
({
|
|
149
|
+
url: e,
|
|
150
|
+
loading: a = "lazy",
|
|
151
|
+
autoplay: o,
|
|
152
|
+
showPreview: c,
|
|
153
|
+
children: l,
|
|
154
|
+
privacyEnhancedMode: t,
|
|
155
|
+
...r
|
|
156
|
+
}, s) => {
|
|
157
|
+
const [n, i] = f("initial"), [m, b] = f(), { renderer: d } = I(L), v = t ?? !0 ? O : x, p = S(
|
|
158
|
+
{
|
|
159
|
+
...r,
|
|
160
|
+
url: e,
|
|
161
|
+
autoplay: !0
|
|
162
|
+
},
|
|
163
|
+
v
|
|
164
|
+
);
|
|
165
|
+
return /* @__PURE__ */ u(
|
|
166
|
+
E.Provider,
|
|
167
|
+
{
|
|
168
|
+
value: {
|
|
169
|
+
status: n,
|
|
170
|
+
previewImageUrl: m,
|
|
171
|
+
onInitPlayer() {
|
|
172
|
+
d !== "canvas" && i("loading");
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
children: /* @__PURE__ */ u("div", { ...r, ref: s, children: p ? /* @__PURE__ */ _(R, { children: [
|
|
176
|
+
l,
|
|
177
|
+
/* @__PURE__ */ u(
|
|
178
|
+
N,
|
|
179
|
+
{
|
|
180
|
+
title: r.title,
|
|
181
|
+
autoplay: o,
|
|
182
|
+
videoUrl: p,
|
|
183
|
+
previewImageUrl: m,
|
|
184
|
+
loading: a,
|
|
185
|
+
showPreview: c,
|
|
186
|
+
renderer: d,
|
|
187
|
+
status: n,
|
|
188
|
+
onStatusChange: i,
|
|
189
|
+
onPreviewImageUrlChange: b
|
|
190
|
+
}
|
|
191
|
+
)
|
|
192
|
+
] }) : /* @__PURE__ */ u(A, {}) })
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
);
|
|
197
|
+
P.displayName = "YouTube";
|
|
198
|
+
export {
|
|
199
|
+
P as YouTube
|
|
200
|
+
};
|
|
@@ -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 { Youtube1cIcon 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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/sdk-components-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.198.0",
|
|
4
4
|
"description": "Webstudio default library for react",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -44,14 +44,15 @@
|
|
|
44
44
|
"react-dom": "18.3.0-canary-14898b6a9-20240318"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@react-aria/utils": "^3.
|
|
48
|
-
"colord": "^2.9.3",
|
|
49
|
-
"micromark": "^4.0.0",
|
|
47
|
+
"@react-aria/utils": "^3.26.0",
|
|
50
48
|
"await-interaction-response": "^0.0.2",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"@webstudio-is/
|
|
49
|
+
"colord": "^2.9.3",
|
|
50
|
+
"micromark": "^4.0.1",
|
|
51
|
+
"micromark-extension-gfm-table": "^2.1.0",
|
|
52
|
+
"@webstudio-is/icons": "0.198.0",
|
|
53
|
+
"@webstudio-is/react-sdk": "0.198.0",
|
|
54
|
+
"@webstudio-is/sdk": "0.198.0",
|
|
55
|
+
"@webstudio-is/image": "0.198.0"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
58
|
"@testing-library/react": "^14.2.2",
|
|
@@ -60,13 +61,15 @@
|
|
|
60
61
|
"react": "18.3.0-canary-14898b6a9-20240318",
|
|
61
62
|
"react-dom": "18.3.0-canary-14898b6a9-20240318",
|
|
62
63
|
"vitest": "^2.1.8",
|
|
63
|
-
"@webstudio-is/tsconfig": "1.0.7",
|
|
64
64
|
"@webstudio-is/generate-arg-types": "0.0.0",
|
|
65
|
-
"@webstudio-is/
|
|
65
|
+
"@webstudio-is/sdk-cli": "0.94.0",
|
|
66
|
+
"@webstudio-is/template": "0.198.0",
|
|
67
|
+
"@webstudio-is/tsconfig": "1.0.7"
|
|
66
68
|
},
|
|
67
69
|
"scripts": {
|
|
68
70
|
"build": "vite build --config ../../vite.sdk-components.config.ts",
|
|
69
|
-
"build:args": "NODE_OPTIONS=--conditions=webstudio generate-arg-types './src/*.tsx !./src/*.stories.tsx !./src/*.test.{ts,tsx} !./src/*.ws.ts' && prettier --write \"**/*.props.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\"",
|
|
70
73
|
"dts": "tsc --project tsconfig.dts.json",
|
|
71
74
|
"test": "vitest run",
|
|
72
75
|
"typecheck": "tsc"
|