@webstudio-is/sdk-components-react 0.0.0-588fe22 → 0.0.0-73cd6ea

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 (204) hide show
  1. package/lib/__generated__/blockquote.props.js +2 -512
  2. package/lib/__generated__/body.props.js +2 -506
  3. package/lib/__generated__/bold.props.js +2 -506
  4. package/lib/__generated__/box.props.js +3 -524
  5. package/lib/__generated__/button.props.js +2 -568
  6. package/lib/__generated__/checkbox.props.js +1 -662
  7. package/lib/__generated__/code-text.props.js +1 -504
  8. package/lib/__generated__/form.props.js +2 -554
  9. package/lib/__generated__/head-link.props.js +2 -618
  10. package/lib/__generated__/head-meta.props.js +2 -530
  11. package/lib/__generated__/head-slot.props.js +4 -0
  12. package/lib/__generated__/head-title.props.js +2 -506
  13. package/lib/__generated__/heading.props.js +3 -513
  14. package/lib/__generated__/html-embed.props.js +6 -1
  15. package/lib/__generated__/image.props.js +1 -581
  16. package/lib/__generated__/input.props.js +2 -694
  17. package/lib/__generated__/italic.props.js +2 -506
  18. package/lib/__generated__/label.props.js +2 -518
  19. package/lib/__generated__/link.props.js +4 -555
  20. package/lib/__generated__/list-item.props.js +2 -512
  21. package/lib/__generated__/list.props.js +1 -523
  22. package/lib/__generated__/markdown-embed.props.js +2 -3
  23. package/lib/__generated__/option.props.js +2 -530
  24. package/lib/__generated__/paragraph.props.js +2 -506
  25. package/lib/__generated__/radio-button.props.js +1 -662
  26. package/lib/__generated__/select.props.js +2 -554
  27. package/lib/__generated__/separator.props.js +2 -506
  28. package/lib/__generated__/span.props.js +2 -506
  29. package/lib/__generated__/subscript.props.js +2 -506
  30. package/lib/__generated__/superscript.props.js +2 -506
  31. package/lib/__generated__/text.props.js +3 -513
  32. package/lib/__generated__/textarea.props.js +2 -585
  33. package/lib/__generated__/time.props.js +1 -8
  34. package/lib/__generated__/video.props.js +4 -0
  35. package/lib/__generated__/vimeo-play-button.props.js +2 -567
  36. package/lib/__generated__/vimeo-preview-image.props.js +1 -580
  37. package/lib/__generated__/vimeo-spinner.props.js +2 -506
  38. package/lib/__generated__/vimeo.props.js +2 -505
  39. package/lib/__generated__/webhook-form.props.js +1 -557
  40. package/lib/__generated__/xml-node.props.js +8 -3
  41. package/lib/__generated__/xml-time.props.js +4 -3
  42. package/lib/__generated__/youtube.props.js +1 -498
  43. package/lib/blockquote.ws.js +18 -25
  44. package/lib/body.ws.js +6 -25
  45. package/lib/bold.ws.js +6 -15
  46. package/lib/box.js +9 -6
  47. package/lib/box.ws.js +37 -27
  48. package/lib/button.ws.js +7 -24
  49. package/lib/checkbox.ws.js +8 -26
  50. package/lib/code-text.ws.js +18 -26
  51. package/lib/components.js +6 -4
  52. package/lib/form.ws.js +9 -23
  53. package/lib/fragment.ws.js +2 -8
  54. package/lib/head-link.ws.js +9 -14
  55. package/lib/head-meta.ws.js +9 -14
  56. package/lib/head-slot.js +4 -5
  57. package/lib/head-slot.template.js +1 -1
  58. package/lib/head-slot.ws.js +9 -20
  59. package/lib/head-title.ws.js +6 -11
  60. package/lib/heading.js +9 -6
  61. package/lib/heading.ws.js +20 -23
  62. package/lib/html-embed.ws.js +22 -20
  63. package/lib/image.ws.js +21 -28
  64. package/lib/input.js +18 -14
  65. package/lib/input.ws.js +11 -37
  66. package/lib/italic.ws.js +6 -21
  67. package/lib/label.ws.js +7 -18
  68. package/lib/link.ws.js +11 -32
  69. package/lib/list-item.ws.js +6 -22
  70. package/lib/list.ws.js +15 -22
  71. package/lib/markdown-embed.js +3 -3
  72. package/lib/markdown-embed.ws.js +13 -11
  73. package/lib/metas.js +6 -4
  74. package/lib/option.js +3 -1
  75. package/lib/option.ws.js +9 -18
  76. package/lib/paragraph.ws.js +7 -20
  77. package/lib/radio-button.ws.js +10 -29
  78. package/lib/rich-text-link.ws.js +3 -7
  79. package/lib/select.js +27 -14
  80. package/lib/select.ws.js +10 -28
  81. package/lib/separator.ws.js +14 -24
  82. package/lib/shared/video.js +13 -0
  83. package/lib/slot.ws.js +3 -7
  84. package/lib/span.ws.js +8 -15
  85. package/lib/subscript.ws.js +7 -16
  86. package/lib/superscript.ws.js +7 -16
  87. package/lib/templates.js +12 -36
  88. package/lib/text.js +9 -7
  89. package/lib/text.ws.js +22 -19
  90. package/lib/textarea.js +16 -5
  91. package/lib/textarea.ws.js +13 -35
  92. package/lib/time.js +2 -1
  93. package/lib/time.ws.js +12 -15
  94. package/lib/types/blockquote.ws.d.ts +1 -2
  95. package/lib/types/body.ws.d.ts +1 -2
  96. package/lib/types/bold.ws.d.ts +1 -2
  97. package/lib/types/box.d.ts +2 -3
  98. package/lib/types/box.ws.d.ts +1 -2
  99. package/lib/types/button.ws.d.ts +1 -2
  100. package/lib/types/checkbox.d.ts +1 -1
  101. package/lib/types/checkbox.ws.d.ts +1 -2
  102. package/lib/types/code-text.ws.d.ts +1 -2
  103. package/lib/types/components.d.ts +1 -0
  104. package/lib/types/form.ws.d.ts +1 -2
  105. package/lib/types/fragment.ws.d.ts +1 -2
  106. package/lib/types/head-link.ws.d.ts +1 -2
  107. package/lib/types/head-meta.ws.d.ts +1 -2
  108. package/lib/types/head-slot.ws.d.ts +1 -2
  109. package/lib/types/head-title.ws.d.ts +1 -2
  110. package/lib/types/heading.d.ts +1 -2
  111. package/lib/types/heading.ws.d.ts +1 -2
  112. package/lib/types/html-embed.ws.d.ts +1 -2
  113. package/lib/types/image.ws.d.ts +1 -2
  114. package/lib/types/input.d.ts +1 -4
  115. package/lib/types/input.ws.d.ts +1 -2
  116. package/lib/types/italic.ws.d.ts +1 -2
  117. package/lib/types/label.ws.d.ts +1 -2
  118. package/lib/types/link.ws.d.ts +1 -2
  119. package/lib/types/list-item.ws.d.ts +1 -2
  120. package/lib/types/list.ws.d.ts +1 -2
  121. package/lib/types/markdown-embed.d.ts +3 -3
  122. package/lib/types/markdown-embed.ws.d.ts +1 -2
  123. package/lib/types/metas.d.ts +1 -0
  124. package/lib/types/option.d.ts +0 -1
  125. package/lib/types/option.ws.d.ts +1 -2
  126. package/lib/types/paragraph.ws.d.ts +1 -2
  127. package/lib/types/radio-button.d.ts +1 -1
  128. package/lib/types/radio-button.ws.d.ts +1 -2
  129. package/lib/types/rich-text-link.ws.d.ts +1 -2
  130. package/lib/types/select.d.ts +0 -1
  131. package/lib/types/select.ws.d.ts +1 -2
  132. package/lib/types/separator.ws.d.ts +1 -2
  133. package/lib/types/shared/video.d.ts +7 -0
  134. package/lib/types/slot.ws.d.ts +1 -2
  135. package/lib/types/span.ws.d.ts +1 -2
  136. package/lib/types/subscript.ws.d.ts +1 -2
  137. package/lib/types/superscript.ws.d.ts +1 -2
  138. package/lib/types/templates.d.ts +0 -12
  139. package/lib/types/text.d.ts +2 -3
  140. package/lib/types/text.ws.d.ts +1 -2
  141. package/lib/types/textarea.d.ts +0 -1
  142. package/lib/types/textarea.ws.d.ts +1 -2
  143. package/lib/types/time.d.ts +2 -4
  144. package/lib/types/time.ws.d.ts +1 -2
  145. package/lib/types/video.d.ts +9 -0
  146. package/lib/types/video.ws.d.ts +2 -0
  147. package/lib/types/vimeo-play-button.ws.d.ts +1 -2
  148. package/lib/types/vimeo-preview-image.d.ts +21 -21
  149. package/lib/types/vimeo-preview-image.ws.d.ts +1 -2
  150. package/lib/types/vimeo-spinner.ws.d.ts +1 -2
  151. package/lib/types/vimeo.d.ts +0 -6
  152. package/lib/types/vimeo.ws.d.ts +1 -2
  153. package/lib/types/webhook-form.ws.d.ts +1 -2
  154. package/lib/types/xml-node.ws.d.ts +1 -2
  155. package/lib/types/xml-time.ws.d.ts +1 -2
  156. package/lib/types/youtube.ws.d.ts +1 -2
  157. package/lib/video.js +53 -0
  158. package/lib/video.ws.js +44 -0
  159. package/lib/vimeo-play-button.js +4 -4
  160. package/lib/vimeo-play-button.ws.js +13 -26
  161. package/lib/vimeo-preview-image.js +5 -5
  162. package/lib/vimeo-preview-image.ws.js +8 -10
  163. package/lib/vimeo-spinner.js +1 -1
  164. package/lib/vimeo-spinner.ws.js +12 -19
  165. package/lib/vimeo.js +98 -99
  166. package/lib/vimeo.template.js +22 -21
  167. package/lib/vimeo.ws.js +16 -21
  168. package/lib/webhook-form.template.js +59 -20
  169. package/lib/webhook-form.ws.js +16 -15
  170. package/lib/xml-node.js +17 -16
  171. package/lib/xml-node.ws.js +5 -8
  172. package/lib/xml-time.ws.js +4 -7
  173. package/lib/youtube.js +152 -131
  174. package/lib/youtube.template.js +16 -15
  175. package/lib/youtube.ws.js +15 -21
  176. package/package.json +13 -16
  177. package/lib/__generated__/head.props.js +0 -508
  178. package/lib/blockquote.template.js +0 -11
  179. package/lib/button.template.js +0 -11
  180. package/lib/checkbox.template.js +0 -14
  181. package/lib/heading.template.js +0 -11
  182. package/lib/label.template.js +0 -10
  183. package/lib/link.template.js +0 -11
  184. package/lib/list-item.template.js +0 -11
  185. package/lib/list.template.js +0 -15
  186. package/lib/paragraph.template.js +0 -11
  187. package/lib/props.js +0 -90
  188. package/lib/radio-button.template.js +0 -14
  189. package/lib/select.template.js +0 -16
  190. package/lib/text.template.js +0 -11
  191. package/lib/types/blockquote.template.d.ts +0 -2
  192. package/lib/types/button.template.d.ts +0 -2
  193. package/lib/types/checkbox.template.d.ts +0 -2
  194. package/lib/types/heading.template.d.ts +0 -2
  195. package/lib/types/label.template.d.ts +0 -2
  196. package/lib/types/link.template.d.ts +0 -2
  197. package/lib/types/list-item.template.d.ts +0 -2
  198. package/lib/types/list.template.d.ts +0 -2
  199. package/lib/types/paragraph.template.d.ts +0 -2
  200. package/lib/types/props.d.ts +0 -44
  201. package/lib/types/radio-button.template.d.ts +0 -2
  202. package/lib/types/select.template.d.ts +0 -2
  203. package/lib/types/text.template.d.ts +0 -2
  204. /package/lib/types/__generated__/{head.props.d.ts → video.props.d.ts} +0 -0
@@ -1,12 +1,12 @@
1
1
  import { jsx as e } from "react/jsx-runtime";
2
2
  import { forwardRef as r, useContext as a, useCallback as m } from "react";
3
- import { VimeoContext as s } from "./vimeo.js";
3
+ import s from "await-interaction-response";
4
4
  import { Button as l } from "./button.js";
5
- import c from "await-interaction-response";
5
+ import { VideoContext as c } from "./shared/video.js";
6
6
  const f = r(
7
7
  (o, i) => {
8
- const t = a(s), n = m(async () => {
9
- await c(), t.onInitPlayer();
8
+ const t = a(c), n = m(async () => {
9
+ await s(), t.onInitPlayer();
10
10
  }, [t]);
11
11
  if (t.status === "initial")
12
12
  return /* @__PURE__ */ e(l, { ...o, onClick: n, ref: i });
@@ -1,31 +1,18 @@
1
- import { defaultStates as t } from "@webstudio-is/sdk";
2
- import { ButtonElementIcon as o } from "@webstudio-is/icons/svg";
3
- import { button as e } from "@webstudio-is/sdk/normalize.css";
4
- import { props as n } from "./__generated__/vimeo-play-button.props.js";
5
- const r = {
6
- button: e
7
- }, p = {
1
+ import { ButtonElementIcon as t } from "@webstudio-is/icons/svg";
2
+ import { button as o } from "@webstudio-is/sdk/normalize.css";
3
+ import { props as e } from "./__generated__/vimeo-play-button.props.js";
4
+ const c = {
8
5
  category: "hidden",
9
- type: "container",
10
- constraints: [
11
- {
12
- relation: "ancestor",
13
- component: { $in: ["Vimeo", "YouTube"] }
14
- },
15
- {
16
- relation: "ancestor",
17
- component: { $neq: "Button" }
18
- }
19
- ],
20
6
  label: "Play Button",
21
- icon: o,
22
- presetStyle: r,
23
- states: t
24
- }, c = {
25
- props: n,
26
- initialProps: ["id", "className"]
7
+ icon: t,
8
+ contentModel: {
9
+ category: "none",
10
+ children: ["instance"]
11
+ },
12
+ presetStyle: { button: o },
13
+ initialProps: ["id", "class"],
14
+ props: e
27
15
  };
28
16
  export {
29
- p as meta,
30
- c as propsMeta
17
+ c as meta
31
18
  };
@@ -1,10 +1,10 @@
1
- import { jsx as m } from "react/jsx-runtime";
2
- import { forwardRef as i, useContext as t } from "react";
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { forwardRef as m, useContext as t } from "react";
3
3
  import { Image as a } from "./image.js";
4
- import { VimeoContext as g } from "./vimeo.js";
5
- const n = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkOAMAANIAzr59FiYAAAAASUVORK5CYII=", s = i(({ src: A, ...e }, o) => {
4
+ import { VideoContext as g } from "./shared/video.js";
5
+ const n = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkOAMAANIAzr59FiYAAAAASUVORK5CYII=", s = m(({ src: A, ...e }, o) => {
6
6
  const r = t(g);
7
- return /* @__PURE__ */ m(
7
+ return /* @__PURE__ */ i(
8
8
  a,
9
9
  {
10
10
  ...e,
@@ -1,14 +1,14 @@
1
- import { meta as e, propsMeta as o } from "./image.ws.js";
1
+ import { meta as e } from "./image.ws.js";
2
2
  import { props as r } from "./__generated__/vimeo-preview-image.props.js";
3
3
  const i = {
4
4
  ...e,
5
5
  category: "hidden",
6
6
  label: "Preview Image",
7
- constraints: {
8
- relation: "ancestor",
9
- component: { $in: ["Vimeo", "YouTube"] }
10
- }
11
- }, p = {
7
+ contentModel: {
8
+ category: "none",
9
+ children: []
10
+ },
11
+ initialProps: e.initialProps,
12
12
  props: {
13
13
  ...r,
14
14
  // Automatically generated props don't have the right control.
@@ -18,10 +18,8 @@ const i = {
18
18
  label: "Source",
19
19
  required: !1
20
20
  }
21
- },
22
- initialProps: o.initialProps
21
+ }
23
22
  };
24
23
  export {
25
- i as meta,
26
- p as propsMeta
24
+ i as meta
27
25
  };
@@ -1,6 +1,6 @@
1
1
  import { jsx as e } from "react/jsx-runtime";
2
2
  import { forwardRef as r, useContext as i } from "react";
3
- import { VimeoContext as n } from "./vimeo.js";
3
+ import { VideoContext as n } from "./shared/video.js";
4
4
  const m = r(
5
5
  (o, t) => {
6
6
  if (i(n).status === "loading")
@@ -1,25 +1,18 @@
1
- import { defaultStates as o } from "@webstudio-is/sdk";
2
- import { div as t } from "@webstudio-is/sdk/normalize.css";
1
+ import { div as o } from "@webstudio-is/sdk/normalize.css";
3
2
  import { BoxIcon as e } from "@webstudio-is/icons/svg";
4
- import { props as r } from "./__generated__/vimeo-spinner.props.js";
5
- const n = {
6
- div: t
7
- }, m = {
8
- type: "container",
9
- constraints: {
10
- relation: "ancestor",
11
- component: { $in: ["Vimeo", "YouTube"] }
12
- },
3
+ import { props as n } from "./__generated__/vimeo-spinner.props.js";
4
+ const c = {
13
5
  icon: e,
14
- states: o,
15
- presetStyle: n,
16
6
  category: "hidden",
17
- label: "Spinner"
18
- }, c = {
19
- props: r,
20
- initialProps: ["id", "className"]
7
+ label: "Spinner",
8
+ contentModel: {
9
+ category: "none",
10
+ children: ["instance"]
11
+ },
12
+ presetStyle: { div: o },
13
+ initialProps: ["id", "class"],
14
+ props: n
21
15
  };
22
16
  export {
23
- m as meta,
24
- c as propsMeta
17
+ c as meta
25
18
  };
package/lib/vimeo.js CHANGED
@@ -1,17 +1,18 @@
1
- import { jsx as s, jsxs as D, Fragment as F } from "react/jsx-runtime";
2
- import { colord as z } from "colord";
3
- import { createContext as T, forwardRef as q, useState as v, useContext as G, useEffect as f } from "react";
1
+ import { jsx as i, jsxs as B, Fragment as D } from "react/jsx-runtime";
2
+ import { colord as q } from "colord";
3
+ import { forwardRef as z, useState as y, useContext as T, useRef as G, useEffect as v } from "react";
4
4
  import { ReactSdkContext as H } from "@webstudio-is/react-sdk/runtime";
5
- const Y = (e) => {
6
- if (e.url === void 0)
5
+ import { VideoContext as Y, requestFullscreen as J } from "./shared/video.js";
6
+ const K = (t) => {
7
+ if (t.url === void 0)
7
8
  return;
8
- let t;
9
+ let e;
9
10
  try {
10
- const o = new URL(e.url);
11
- t = new URL(R), t.pathname = `/video${o.pathname}`;
11
+ const o = new URL(t.url);
12
+ e = new URL(S), e.pathname = `/video${o.pathname}`;
12
13
  } catch {
13
14
  }
14
- if (t === void 0)
15
+ if (e === void 0)
15
16
  return;
16
17
  const a = {
17
18
  showPortrait: "portrait",
@@ -24,35 +25,35 @@ const Y = (e) => {
24
25
  doNotTrack: "dnt"
25
26
  };
26
27
  let r;
27
- for (r in e) {
28
- const o = e[r];
28
+ for (r in t) {
29
+ const o = t[r];
29
30
  if (r === "url" || o === void 0)
30
31
  continue;
31
- const i = a[r] ?? r;
32
- t.searchParams.append(i, o.toString());
32
+ const s = a[r] ?? r;
33
+ e.searchParams.append(s, o.toString());
33
34
  }
34
- if (t.searchParams.set("autoplay", "true"), typeof e.controlsColor == "string") {
35
- const o = z(e.controlsColor).toHex().replace("#", "");
36
- t.searchParams.set("color", o);
35
+ if (e.searchParams.set("autoplay", "true"), typeof t.controlsColor == "string") {
36
+ const o = q(t.controlsColor).toHex().replace("#", "");
37
+ e.searchParams.set("color", o);
37
38
  }
38
- return e.showPortrait && t.searchParams.set("title", "true"), e.showByline && (t.searchParams.set("portrait", "true"), t.searchParams.set("title", "true")), t.toString();
39
- }, h = (e) => {
40
- const t = document.createElement("link");
41
- t.rel = "preconnect", t.href = e, t.crossOrigin = "true", document.head.appendChild(t);
39
+ return t.showPortrait && e.searchParams.set("title", "true"), t.showByline && (e.searchParams.set("portrait", "true"), e.searchParams.set("title", "true")), e.toString();
40
+ }, w = (t) => {
41
+ const e = document.createElement("link");
42
+ e.rel = "preconnect", e.href = t, e.crossOrigin = "true", document.head.appendChild(e);
42
43
  };
43
- let b = !1;
44
- const J = "https://f.vimeocdn.com", R = "https://player.vimeo.com", U = "https://i.vimeocdn.com", K = () => {
45
- b || window.matchMedia("(hover: none)").matches || (h(J), h(R), h(U), b = !0);
46
- }, Q = (e) => {
44
+ let U = !1;
45
+ const Q = "https://f.vimeocdn.com", S = "https://player.vimeo.com", L = "https://i.vimeocdn.com", W = () => {
46
+ U || window.matchMedia("(hover: none)").matches || (w(Q), w(S), w(L), U = !0);
47
+ }, X = (t) => {
47
48
  try {
48
- const a = new URL(e).pathname.split("/")[2];
49
+ const a = new URL(t).pathname.split("/")[2];
49
50
  return a === "" || a == null ? void 0 : a;
50
51
  } catch {
51
52
  }
52
- }, W = async (e) => {
53
- const a = `https://vimeo.com/api/v2/video/${Q(e)}.json`, o = (await (await fetch(a)).json())[0].thumbnail_large, i = o.substr(o.lastIndexOf("/") + 1).split("_")[0], n = new URL(U);
54
- return n.pathname = `/video/${i}.webp`, n.searchParams.append("mw", "1100"), n.searchParams.append("mh", "619"), n.searchParams.append("q", "70"), n;
55
- }, X = () => /* @__PURE__ */ s(
53
+ }, Z = async (t) => {
54
+ const a = `https://vimeo.com/api/v2/video/${X(t)}.json`, o = (await (await fetch(a)).json())[0].thumbnail_large, s = o.substr(o.lastIndexOf("/") + 1).split("_")[0], n = new URL(L);
55
+ return n.pathname = `/video/${s}.webp`, n.searchParams.append("mw", "1100"), n.searchParams.append("mh", "619"), n.searchParams.append("q", "70"), n;
56
+ }, ee = () => /* @__PURE__ */ i(
56
57
  "div",
57
58
  {
58
59
  style: {
@@ -65,38 +66,40 @@ const J = "https://f.vimeocdn.com", R = "https://player.vimeo.com", U = "https:/
65
66
  },
66
67
  children: 'Open the "Settings" panel and paste a video URL, e.g. https://vimeo.com/831343124.'
67
68
  }
68
- ), Z = ({
69
- title: e,
70
- status: t,
69
+ ), te = ({
70
+ title: t,
71
+ status: e,
71
72
  loading: a,
72
73
  videoUrl: r,
73
74
  previewImageUrl: o,
74
- autoplay: i,
75
+ autoplay: s,
75
76
  renderer: n,
76
- showPreview: d,
77
+ showPreview: m,
78
+ playsinline: f,
77
79
  onStatusChange: c,
78
80
  onPreviewImageUrlChange: l
79
81
  }) => {
80
- const [p, u] = v(0);
81
- if (f(() => {
82
- i && n !== "canvas" && t === "initial" && c("loading");
83
- }, [i, t, n, c]), f(() => {
84
- n !== "canvas" && K();
85
- }, [n]), f(() => {
82
+ const [u, h] = y(0), d = G(null);
83
+ if (v(() => {
84
+ s && n !== "canvas" && e === "initial" && c("loading");
85
+ }, [s, e, n, c]), v(() => {
86
+ n !== "canvas" && W();
87
+ }, [n]), v(() => {
86
88
  if (r !== void 0) {
87
- if (d === !1) {
89
+ if (m === !1) {
88
90
  l(void 0);
89
91
  return;
90
92
  }
91
- o === void 0 && W(r).then(l).catch(() => {
93
+ o === void 0 && Z(r).then(l).catch(() => {
92
94
  console.error(`Could not load preview image for ${r}`);
93
95
  });
94
96
  }
95
- }, [l, d, r, o]), !(n === "canvas" || t === "initial"))
96
- return /* @__PURE__ */ s(
97
+ }, [l, m, r, o]), !(n === "canvas" || e === "initial"))
98
+ return /* @__PURE__ */ i(
97
99
  "iframe",
98
100
  {
99
- title: e,
101
+ ref: d,
102
+ title: t,
100
103
  src: r,
101
104
  loading: a,
102
105
  allow: "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture;",
@@ -105,35 +108,31 @@ const J = "https://f.vimeocdn.com", R = "https://player.vimeo.com", U = "https:/
105
108
  position: "absolute",
106
109
  width: "100%",
107
110
  height: "100%",
108
- opacity: p,
111
+ opacity: u,
109
112
  transition: "opacity 1s",
110
113
  border: "none"
111
114
  },
112
115
  onLoad: () => {
113
- c("ready"), u(1);
116
+ c("ready"), h(1), d.current && !f && !s && J(d.current);
114
117
  }
115
118
  }
116
119
  );
117
- }, tt = T({
118
- onInitPlayer: () => {
119
- },
120
- status: "initial"
121
- }), et = q(
120
+ }, re = z(
122
121
  ({
123
- url: e,
124
- loading: t = "lazy",
122
+ url: t,
123
+ loading: e = "lazy",
125
124
  autoplay: a = !1,
126
125
  autopause: r = !0,
127
126
  showByline: o = !1,
128
- showControls: i = !0,
127
+ showControls: s = !0,
129
128
  doNotTrack: n = !1,
130
- keyboard: d = !0,
131
- loop: c = !1,
132
- muted: l = !1,
133
- pip: p = !1,
134
- playsinline: u = !0,
135
- showPortrait: S = !0,
136
- quality: L = "auto",
129
+ keyboard: m = !0,
130
+ loop: f = !1,
131
+ muted: c = !1,
132
+ pip: l = !1,
133
+ playsinline: u = !1,
134
+ showPortrait: h = !0,
135
+ quality: d = "auto",
137
136
  responsive: k = !0,
138
137
  speed: E = !1,
139
138
  showTitle: _ = !1,
@@ -142,64 +141,65 @@ const J = "https://f.vimeocdn.com", R = "https://player.vimeo.com", U = "https:/
142
141
  autopip: N,
143
142
  controlsColor: O,
144
143
  interactiveParams: V,
145
- texttrack: $,
146
- children: A,
147
- ...y
148
- }, m) => {
149
- const [w, g] = v("initial"), [P, B] = v(), { renderer: C } = G(H), I = Y({
150
- url: e,
144
+ texttrack: F,
145
+ children: $,
146
+ ...g
147
+ }, p) => {
148
+ const [P, C] = y("initial"), [I, A] = y(), { renderer: R } = T(H), b = K({
149
+ url: t,
151
150
  autoplay: a,
152
151
  autopause: r,
153
- showControls: i,
152
+ showControls: s,
154
153
  controlsColor: O,
155
154
  doNotTrack: n,
156
155
  interactiveParams: V,
157
- keyboard: d,
158
- loop: c,
159
- muted: l,
160
- pip: p,
156
+ keyboard: m,
157
+ loop: f,
158
+ muted: c,
159
+ pip: l,
161
160
  playsinline: u,
162
- quality: L,
161
+ quality: d,
163
162
  responsive: k,
164
163
  speed: E,
165
- texttrack: $,
164
+ texttrack: F,
166
165
  showTitle: _,
167
166
  transparent: j,
168
- showPortrait: S,
167
+ showPortrait: h,
169
168
  autopip: N
170
169
  });
171
- return /* @__PURE__ */ s(
172
- tt.Provider,
170
+ return /* @__PURE__ */ i(
171
+ Y.Provider,
173
172
  {
174
173
  value: {
175
- status: w,
176
- previewImageUrl: P,
174
+ status: P,
175
+ previewImageUrl: I,
177
176
  onInitPlayer() {
178
- C !== "canvas" && g("loading");
177
+ R !== "canvas" && C("loading");
179
178
  }
180
179
  },
181
- children: /* @__PURE__ */ s(
180
+ children: /* @__PURE__ */ i(
182
181
  "div",
183
182
  {
184
- ...y,
183
+ ...g,
185
184
  ref: (x) => {
186
- m !== null && (typeof m == "function" ? m(x) : m.current = x);
185
+ p !== null && (typeof p == "function" ? p(x) : p.current = x);
187
186
  },
188
- children: I === void 0 ? /* @__PURE__ */ s(X, {}) : /* @__PURE__ */ D(F, { children: [
189
- A,
190
- /* @__PURE__ */ s(
191
- Z,
187
+ children: b === void 0 ? /* @__PURE__ */ i(ee, {}) : /* @__PURE__ */ B(D, { children: [
188
+ $,
189
+ /* @__PURE__ */ i(
190
+ te,
192
191
  {
193
- title: y.title,
192
+ title: g.title,
194
193
  autoplay: a,
195
- videoUrl: I,
196
- previewImageUrl: P,
197
- loading: t,
194
+ playsinline: u,
195
+ videoUrl: b,
196
+ previewImageUrl: I,
197
+ loading: e,
198
198
  showPreview: M,
199
- renderer: C,
200
- status: w,
201
- onStatusChange: g,
202
- onPreviewImageUrlChange: B
199
+ renderer: R,
200
+ status: P,
201
+ onStatusChange: C,
202
+ onPreviewImageUrlChange: A
203
203
  }
204
204
  )
205
205
  ] })
@@ -209,8 +209,7 @@ const J = "https://f.vimeocdn.com", R = "https://player.vimeo.com", U = "https:/
209
209
  );
210
210
  }
211
211
  );
212
- et.displayName = "Vimeo";
212
+ re.displayName = "Vimeo";
213
213
  export {
214
- et as Vimeo,
215
- tt as VimeoContext
214
+ re as Vimeo
216
215
  };
@@ -1,23 +1,23 @@
1
- import { jsxs as i, jsx as t } from "react/jsx-runtime";
1
+ import { jsxs as o, jsx as e } from "react/jsx-runtime";
2
2
  import { SpinnerIcon as r, PlayIcon as n } from "@webstudio-is/icons/svg";
3
- import { $ as e, css as o } from "@webstudio-is/template";
4
- const p = {
3
+ import { $ as t, css as i, ws as a } from "@webstudio-is/template";
4
+ const d = {
5
5
  category: "media",
6
6
  order: 1,
7
7
  description: "Add a video to your page that is hosted on Vimeo. Paste a Vimeo URL and configure the video in the Settings tab.",
8
- template: /* @__PURE__ */ i(
9
- e.Vimeo,
8
+ template: /* @__PURE__ */ o(
9
+ t.Vimeo,
10
10
  {
11
- "ws:style": o`
11
+ "ws:style": i`
12
12
  position: relative;
13
13
  aspect-ratio: 640/360;
14
14
  width: 100%;
15
15
  `,
16
16
  children: [
17
- /* @__PURE__ */ t(
18
- e.VimeoPreviewImage,
17
+ /* @__PURE__ */ e(
18
+ t.VimeoPreviewImage,
19
19
  {
20
- "ws:style": o`
20
+ "ws:style": i`
21
21
  position: absolute;
22
22
  object-fit: cover;
23
23
  object-position: center;
@@ -30,11 +30,11 @@ const p = {
30
30
  optimize: !0
31
31
  }
32
32
  ),
33
- /* @__PURE__ */ t(
34
- e.VimeoSpinner,
33
+ /* @__PURE__ */ e(
34
+ t.VimeoSpinner,
35
35
  {
36
36
  "ws:label": "Spinner",
37
- "ws:style": o`
37
+ "ws:style": i`
38
38
  position: absolute;
39
39
  top: 50%;
40
40
  left: 50%;
@@ -43,13 +43,13 @@ const p = {
43
43
  margin-top: -35px;
44
44
  margin-left: -35px;
45
45
  `,
46
- children: /* @__PURE__ */ t(e.HtmlEmbed, { "ws:label": "Spinner SVG", code: r })
46
+ children: /* @__PURE__ */ e(t.HtmlEmbed, { "ws:label": "Spinner SVG", code: r })
47
47
  }
48
48
  ),
49
- /* @__PURE__ */ t(
50
- e.VimeoPlayButton,
49
+ /* @__PURE__ */ e(
50
+ t.VimeoPlayButton,
51
51
  {
52
- "ws:style": o`
52
+ "ws:style": i`
53
53
  position: absolute;
54
54
  width: 140px;
55
55
  height: 80px;
@@ -70,16 +70,17 @@ const p = {
70
70
  }
71
71
  `,
72
72
  "aria-label": "Play button",
73
- children: /* @__PURE__ */ t(
74
- e.Box,
73
+ children: /* @__PURE__ */ e(
74
+ a.element,
75
75
  {
76
+ "ws:tag": "div",
76
77
  "ws:label": "Play Icon",
77
- "ws:style": o`
78
+ "ws:style": i`
78
79
  width: 60px;
79
80
  height: 60px;
80
81
  `,
81
82
  "aria-hidden": !0,
82
- children: /* @__PURE__ */ t(e.HtmlEmbed, { "ws:label": "Play SVG", code: n })
83
+ children: /* @__PURE__ */ e(t.HtmlEmbed, { "ws:label": "Play SVG", code: n })
83
84
  }
84
85
  )
85
86
  }
@@ -89,5 +90,5 @@ const p = {
89
90
  )
90
91
  };
91
92
  export {
92
- p as meta
93
+ d as meta
93
94
  };
package/lib/vimeo.ws.js CHANGED
@@ -1,19 +1,7 @@
1
1
  import { VimeoIcon as o } from "@webstudio-is/icons/svg";
2
- import { defaultStates as t } from "@webstudio-is/sdk";
3
- import { div as r } from "@webstudio-is/sdk/normalize.css";
4
- import { props as i } from "./__generated__/vimeo.props.js";
5
- const n = {
6
- div: r
7
- }, c = {
8
- type: "container",
9
- icon: o,
10
- states: t,
11
- presetStyle: n,
12
- constraints: {
13
- relation: "ancestor",
14
- component: { $nin: ["Button", "Link", "Heading"] }
15
- }
16
- }, e = [
2
+ import { div as e } from "@webstudio-is/sdk/normalize.css";
3
+ import { props as t } from "./__generated__/vimeo.props.js";
4
+ const i = [
17
5
  "id",
18
6
  "className",
19
7
  "url",
@@ -29,12 +17,19 @@ const n = {
29
17
  "showByline",
30
18
  "showTitle",
31
19
  "showControls",
32
- "controlsColor"
33
- ], m = {
34
- props: i,
35
- initialProps: e
20
+ "controlsColor",
21
+ "playsinline"
22
+ ], s = {
23
+ icon: o,
24
+ contentModel: {
25
+ category: "instance",
26
+ children: ["instance"],
27
+ descendants: ["VimeoSpinner", "VimeoPlayButton", "VimeoPreviewImage"]
28
+ },
29
+ presetStyle: { div: e },
30
+ initialProps: i,
31
+ props: t
36
32
  };
37
33
  export {
38
- c as meta,
39
- m as propsMeta
34
+ s as meta
40
35
  };