@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.
Files changed (172) hide show
  1. package/lib/__generated__/image.props.js +1 -0
  2. package/lib/__generated__/vimeo-preview-image.props.js +6 -1
  3. package/lib/__generated__/vimeo.props.js +4 -5
  4. package/lib/__generated__/youtube.props.js +665 -0
  5. package/lib/blockquote.template.js +11 -0
  6. package/lib/blockquote.ws.js +5 -15
  7. package/lib/body.ws.js +1 -1
  8. package/lib/bold.ws.js +1 -1
  9. package/lib/box.ws.js +1 -1
  10. package/lib/button.ws.js +1 -1
  11. package/lib/checkbox.template.js +14 -0
  12. package/lib/checkbox.ws.js +5 -25
  13. package/lib/code-text.ws.js +1 -1
  14. package/lib/components.js +35 -33
  15. package/lib/content-embed.template.js +83 -0
  16. package/lib/form.ws.js +1 -1
  17. package/lib/heading.template.js +11 -0
  18. package/lib/heading.ws.js +12 -22
  19. package/lib/image.ws.js +17 -22
  20. package/lib/input.ws.js +1 -1
  21. package/lib/italic.ws.js +1 -1
  22. package/lib/label.template.js +10 -0
  23. package/lib/label.ws.js +13 -28
  24. package/lib/link.template.js +11 -0
  25. package/lib/link.ws.js +3 -13
  26. package/lib/list-item.template.js +11 -0
  27. package/lib/list-item.ws.js +8 -18
  28. package/lib/list.ws.js +1 -1
  29. package/lib/markdown-embed.js +10 -5
  30. package/lib/markdown-embed.template.js +75 -0
  31. package/lib/markdown-embed.ws.js +9 -87
  32. package/lib/metas.js +59 -59
  33. package/lib/option.ws.js +4 -5
  34. package/lib/paragraph.template.js +11 -0
  35. package/lib/paragraph.ws.js +10 -20
  36. package/lib/props.js +32 -30
  37. package/lib/radio-button.template.js +14 -0
  38. package/lib/radio-button.ws.js +7 -27
  39. package/lib/rich-text-link.ws.js +3 -5
  40. package/lib/select.template.js +16 -0
  41. package/lib/select.ws.js +11 -63
  42. package/lib/separator.ws.js +1 -1
  43. package/lib/span.ws.js +1 -1
  44. package/lib/subscript.ws.js +1 -1
  45. package/lib/superscript.ws.js +1 -1
  46. package/lib/templates.js +34 -6
  47. package/lib/text.template.js +11 -0
  48. package/lib/text.ws.js +9 -25
  49. package/lib/textarea.ws.js +1 -1
  50. package/lib/time.ws.js +1 -1
  51. package/lib/types/__generated__/blockquote.props.d.ts +1 -1
  52. package/lib/types/__generated__/body.props.d.ts +1 -1
  53. package/lib/types/__generated__/bold.props.d.ts +1 -1
  54. package/lib/types/__generated__/box.props.d.ts +1 -1
  55. package/lib/types/__generated__/button.props.d.ts +1 -1
  56. package/lib/types/__generated__/checkbox.props.d.ts +1 -1
  57. package/lib/types/__generated__/code-text.props.d.ts +1 -1
  58. package/lib/types/__generated__/form.props.d.ts +1 -1
  59. package/lib/types/__generated__/fragment.props.d.ts +1 -1
  60. package/lib/types/__generated__/heading.props.d.ts +1 -1
  61. package/lib/types/__generated__/html-embed.props.d.ts +1 -1
  62. package/lib/types/__generated__/image.props.d.ts +1 -1
  63. package/lib/types/__generated__/input.props.d.ts +1 -1
  64. package/lib/types/__generated__/italic.props.d.ts +1 -1
  65. package/lib/types/__generated__/label.props.d.ts +1 -1
  66. package/lib/types/__generated__/link.props.d.ts +1 -1
  67. package/lib/types/__generated__/list-item.props.d.ts +1 -1
  68. package/lib/types/__generated__/list.props.d.ts +1 -1
  69. package/lib/types/__generated__/markdown-embed.props.d.ts +1 -1
  70. package/lib/types/__generated__/option.props.d.ts +1 -1
  71. package/lib/types/__generated__/paragraph.props.d.ts +1 -1
  72. package/lib/types/__generated__/radio-button.props.d.ts +1 -1
  73. package/lib/types/__generated__/rich-text-link.props.d.ts +1 -1
  74. package/lib/types/__generated__/select.props.d.ts +1 -1
  75. package/lib/types/__generated__/separator.props.d.ts +1 -1
  76. package/lib/types/__generated__/slot.props.d.ts +1 -1
  77. package/lib/types/__generated__/span.props.d.ts +1 -1
  78. package/lib/types/__generated__/subscript.props.d.ts +1 -1
  79. package/lib/types/__generated__/superscript.props.d.ts +1 -1
  80. package/lib/types/__generated__/text.props.d.ts +1 -1
  81. package/lib/types/__generated__/textarea.props.d.ts +1 -1
  82. package/lib/types/__generated__/time.props.d.ts +1 -1
  83. package/lib/types/__generated__/vimeo-play-button.props.d.ts +1 -1
  84. package/lib/types/__generated__/vimeo-preview-image.props.d.ts +1 -1
  85. package/lib/types/__generated__/vimeo-spinner.props.d.ts +1 -1
  86. package/lib/types/__generated__/vimeo.props.d.ts +1 -1
  87. package/lib/types/__generated__/webhook-form.props.d.ts +1 -1
  88. package/lib/types/__generated__/xml-node.props.d.ts +1 -1
  89. package/lib/types/__generated__/xml-time.props.d.ts +1 -1
  90. package/lib/types/__generated__/youtube.props.d.ts +2 -0
  91. package/lib/types/blockquote.template.d.ts +2 -0
  92. package/lib/types/blockquote.ws.d.ts +1 -1
  93. package/lib/types/body.ws.d.ts +1 -1
  94. package/lib/types/bold.ws.d.ts +1 -1
  95. package/lib/types/box.ws.d.ts +1 -1
  96. package/lib/types/button.ws.d.ts +1 -1
  97. package/lib/types/checkbox.d.ts +1 -1
  98. package/lib/types/checkbox.template.d.ts +2 -0
  99. package/lib/types/checkbox.ws.d.ts +1 -1
  100. package/lib/types/code-text.ws.d.ts +1 -1
  101. package/lib/types/components.d.ts +1 -0
  102. package/lib/types/content-embed.template.d.ts +2 -0
  103. package/lib/types/form.ws.d.ts +1 -1
  104. package/lib/types/fragment.ws.d.ts +1 -1
  105. package/lib/types/heading.template.d.ts +2 -0
  106. package/lib/types/heading.ws.d.ts +1 -1
  107. package/lib/types/html-embed.ws.d.ts +1 -1
  108. package/lib/types/image.ws.d.ts +1 -9
  109. package/lib/types/input.ws.d.ts +1 -1
  110. package/lib/types/italic.ws.d.ts +1 -1
  111. package/lib/types/label.template.d.ts +2 -0
  112. package/lib/types/label.ws.d.ts +1 -1
  113. package/lib/types/link.template.d.ts +2 -0
  114. package/lib/types/link.ws.d.ts +1 -1
  115. package/lib/types/list-item.template.d.ts +2 -0
  116. package/lib/types/list-item.ws.d.ts +1 -1
  117. package/lib/types/list.ws.d.ts +1 -1
  118. package/lib/types/markdown-embed.template.d.ts +2 -0
  119. package/lib/types/markdown-embed.ws.d.ts +1 -1
  120. package/lib/types/metas.d.ts +1 -1
  121. package/lib/types/option.ws.d.ts +1 -1
  122. package/lib/types/paragraph.template.d.ts +2 -0
  123. package/lib/types/paragraph.ws.d.ts +1 -1
  124. package/lib/types/props.d.ts +1 -0
  125. package/lib/types/radio-button.d.ts +1 -1
  126. package/lib/types/radio-button.template.d.ts +2 -0
  127. package/lib/types/radio-button.ws.d.ts +1 -1
  128. package/lib/types/rich-text-link.ws.d.ts +1 -1
  129. package/lib/types/select.template.d.ts +2 -0
  130. package/lib/types/select.ws.d.ts +1 -1
  131. package/lib/types/separator.ws.d.ts +1 -1
  132. package/lib/types/slot.ws.d.ts +1 -1
  133. package/lib/types/span.ws.d.ts +1 -1
  134. package/lib/types/subscript.ws.d.ts +1 -1
  135. package/lib/types/superscript.ws.d.ts +1 -1
  136. package/lib/types/templates.d.ts +14 -0
  137. package/lib/types/text.template.d.ts +2 -0
  138. package/lib/types/text.ws.d.ts +1 -1
  139. package/lib/types/textarea.ws.d.ts +1 -1
  140. package/lib/types/time.ws.d.ts +1 -1
  141. package/lib/types/vimeo-play-button.ws.d.ts +1 -1
  142. package/lib/types/vimeo-preview-image.d.ts +21 -21
  143. package/lib/types/vimeo-preview-image.ws.d.ts +1 -1
  144. package/lib/types/vimeo-spinner.ws.d.ts +1 -1
  145. package/lib/types/vimeo.d.ts +12 -2
  146. package/lib/types/vimeo.ws.d.ts +1 -1
  147. package/lib/types/webhook-form.d.ts +1 -0
  148. package/lib/types/webhook-form.template.d.ts +2 -0
  149. package/lib/types/webhook-form.ws.d.ts +1 -1
  150. package/lib/types/xml-node.ws.d.ts +1 -1
  151. package/lib/types/xml-time.ws.d.ts +1 -1
  152. package/lib/types/youtube.d.ts +143 -0
  153. package/lib/types/youtube.template.d.ts +2 -0
  154. package/lib/types/youtube.ws.d.ts +3 -0
  155. package/lib/vimeo-play-button.ws.js +8 -8
  156. package/lib/vimeo-preview-image.ws.js +17 -9
  157. package/lib/vimeo-spinner.ws.js +8 -8
  158. package/lib/vimeo.js +88 -87
  159. package/lib/vimeo.template.js +17 -16
  160. package/lib/vimeo.ws.js +8 -7
  161. package/lib/webhook-form.template.js +49 -0
  162. package/lib/webhook-form.ws.js +17 -118
  163. package/lib/xml-node.js +18 -14
  164. package/lib/xml-node.ws.js +4 -5
  165. package/lib/xml-time.ws.js +4 -5
  166. package/lib/youtube.js +200 -0
  167. package/lib/youtube.template.js +97 -0
  168. package/lib/youtube.ws.js +51 -0
  169. package/package.json +14 -11
  170. package/lib/content-embed.ws.js +0 -77
  171. package/lib/types/__generated__/local-date.props.d.ts +0 -2
  172. package/lib/types/content-embed.ws.d.ts +0 -2
@@ -1,127 +1,26 @@
1
- import { meta as t } from "./form.ws.js";
2
- import { showAttribute as e } from "@webstudio-is/react-sdk";
3
- import { props as o } from "./__generated__/webhook-form.props.js";
4
- import { WebhookFormIcon as a } from "@webstudio-is/icons/svg";
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
- description: "Collect user data and send it to any webhook.",
10
- order: 1,
11
- icon: a,
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
- }, i = {
121
- props: o,
19
+ }, c = {
20
+ props: e,
122
21
  initialProps: ["id", "className", "state", "action"]
123
22
  };
124
23
  export {
125
- c as meta,
126
- i as propsMeta
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 b, useContext as h, createElement as u, Children as g } from "react";
4
- const x = b(
5
- ({ tag: i = "", children: e, ...o }, c) => {
6
- const { renderer: f } = h(y), s = Object.entries(o).filter(
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 u(i, t, e);
11
+ return b(
12
+ `${r}${g}`,
13
+ t,
14
+ e
15
+ );
12
16
  }
13
- const r = g.toArray(e), l = r.length > 0 && r.every((t) => typeof t == "string"), a = i.replace(/^[^\p{L}_]+/u, "").replaceAll(/[^\p{L}\p{N}\-._:]+/gu, ""), d = s.map(
14
- ([t, m]) => `${t}=${JSON.stringify(m)}`
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
- [a, ...d].join(" "),
23
+ [r, ...m].join(" "),
20
24
  ">"
21
25
  ] }),
22
- r.length > 0 && /* @__PURE__ */ p(
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
- a,
39
+ r,
36
40
  ">"
37
41
  ] })
38
42
  ] });
39
43
  }
40
44
  );
41
- x.displayName = "XmlNode";
45
+ N.displayName = "XmlNode";
42
46
  export {
43
- x as XmlNode
47
+ N as XmlNode
44
48
  };
@@ -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 i = {
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
- }, a = {
10
+ }, i = {
12
11
  props: t,
13
12
  initialProps: ["tag"]
14
13
  };
15
14
  export {
16
- i as meta,
17
- a as propsMeta
15
+ p as meta,
16
+ i as propsMeta
18
17
  };
@@ -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 i = {
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
- }, n = {
10
+ }, i = {
12
11
  props: e,
13
12
  initialProps: ["datetime", "dateStyle"]
14
13
  };
15
14
  export {
16
- i as meta,
17
- n as propsMeta
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.196.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.25.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
- "@webstudio-is/icons": "0.196.0",
52
- "@webstudio-is/image": "0.196.0",
53
- "@webstudio-is/react-sdk": "0.196.0",
54
- "@webstudio-is/sdk": "0.196.0"
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/template": "0.196.0"
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"