@webstudio-is/sdk-components-react 0.195.0 → 0.197.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 (176) 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 -21
  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.template.js +11 -0
  11. package/lib/button.ws.js +2 -18
  12. package/lib/checkbox.template.js +14 -0
  13. package/lib/checkbox.ws.js +5 -25
  14. package/lib/code-text.ws.js +6 -6
  15. package/lib/components.js +35 -33
  16. package/lib/content-embed.template.js +83 -0
  17. package/lib/form.ws.js +1 -1
  18. package/lib/heading.template.js +11 -0
  19. package/lib/heading.ws.js +15 -31
  20. package/lib/image.ws.js +17 -22
  21. package/lib/input.ws.js +1 -1
  22. package/lib/italic.ws.js +1 -1
  23. package/lib/label.template.js +10 -0
  24. package/lib/label.ws.js +13 -28
  25. package/lib/link.template.js +11 -0
  26. package/lib/link.ws.js +3 -23
  27. package/lib/list-item.template.js +11 -0
  28. package/lib/list-item.ws.js +12 -28
  29. package/lib/list.template.js +15 -0
  30. package/lib/list.ws.js +10 -54
  31. package/lib/markdown-embed.js +10 -5
  32. package/lib/markdown-embed.template.js +75 -0
  33. package/lib/markdown-embed.ws.js +9 -87
  34. package/lib/metas.js +59 -59
  35. package/lib/option.ws.js +4 -5
  36. package/lib/paragraph.template.js +11 -0
  37. package/lib/paragraph.ws.js +12 -28
  38. package/lib/props.js +32 -30
  39. package/lib/radio-button.template.js +14 -0
  40. package/lib/radio-button.ws.js +7 -27
  41. package/lib/rich-text-link.ws.js +3 -5
  42. package/lib/select.template.js +16 -0
  43. package/lib/select.ws.js +11 -63
  44. package/lib/separator.ws.js +2 -2
  45. package/lib/span.ws.js +1 -1
  46. package/lib/subscript.ws.js +1 -1
  47. package/lib/superscript.ws.js +1 -1
  48. package/lib/templates.js +36 -0
  49. package/lib/text.template.js +11 -0
  50. package/lib/text.ws.js +8 -24
  51. package/lib/textarea.ws.js +1 -1
  52. package/lib/time.ws.js +5 -6
  53. package/lib/types/__generated__/blockquote.props.d.ts +1 -1
  54. package/lib/types/__generated__/body.props.d.ts +1 -1
  55. package/lib/types/__generated__/bold.props.d.ts +1 -1
  56. package/lib/types/__generated__/box.props.d.ts +1 -1
  57. package/lib/types/__generated__/button.props.d.ts +1 -1
  58. package/lib/types/__generated__/checkbox.props.d.ts +1 -1
  59. package/lib/types/__generated__/code-text.props.d.ts +1 -1
  60. package/lib/types/__generated__/form.props.d.ts +1 -1
  61. package/lib/types/__generated__/fragment.props.d.ts +1 -1
  62. package/lib/types/__generated__/heading.props.d.ts +1 -1
  63. package/lib/types/__generated__/html-embed.props.d.ts +1 -1
  64. package/lib/types/__generated__/image.props.d.ts +1 -1
  65. package/lib/types/__generated__/input.props.d.ts +1 -1
  66. package/lib/types/__generated__/italic.props.d.ts +1 -1
  67. package/lib/types/__generated__/label.props.d.ts +1 -1
  68. package/lib/types/__generated__/link.props.d.ts +1 -1
  69. package/lib/types/__generated__/list-item.props.d.ts +1 -1
  70. package/lib/types/__generated__/list.props.d.ts +1 -1
  71. package/lib/types/__generated__/markdown-embed.props.d.ts +1 -1
  72. package/lib/types/__generated__/option.props.d.ts +1 -1
  73. package/lib/types/__generated__/paragraph.props.d.ts +1 -1
  74. package/lib/types/__generated__/radio-button.props.d.ts +1 -1
  75. package/lib/types/__generated__/rich-text-link.props.d.ts +1 -1
  76. package/lib/types/__generated__/select.props.d.ts +1 -1
  77. package/lib/types/__generated__/separator.props.d.ts +1 -1
  78. package/lib/types/__generated__/slot.props.d.ts +1 -1
  79. package/lib/types/__generated__/span.props.d.ts +1 -1
  80. package/lib/types/__generated__/subscript.props.d.ts +1 -1
  81. package/lib/types/__generated__/superscript.props.d.ts +1 -1
  82. package/lib/types/__generated__/text.props.d.ts +1 -1
  83. package/lib/types/__generated__/textarea.props.d.ts +1 -1
  84. package/lib/types/__generated__/time.props.d.ts +1 -1
  85. package/lib/types/__generated__/vimeo-play-button.props.d.ts +1 -1
  86. package/lib/types/__generated__/vimeo-preview-image.props.d.ts +1 -1
  87. package/lib/types/__generated__/vimeo-spinner.props.d.ts +1 -1
  88. package/lib/types/__generated__/vimeo.props.d.ts +1 -1
  89. package/lib/types/__generated__/webhook-form.props.d.ts +1 -1
  90. package/lib/types/__generated__/xml-node.props.d.ts +1 -1
  91. package/lib/types/__generated__/xml-time.props.d.ts +1 -1
  92. package/lib/types/__generated__/youtube.props.d.ts +2 -0
  93. package/lib/types/blockquote.template.d.ts +2 -0
  94. package/lib/types/blockquote.ws.d.ts +1 -1
  95. package/lib/types/body.ws.d.ts +1 -1
  96. package/lib/types/bold.ws.d.ts +1 -1
  97. package/lib/types/box.ws.d.ts +1 -1
  98. package/lib/types/button.template.d.ts +2 -0
  99. package/lib/types/button.ws.d.ts +1 -1
  100. package/lib/types/checkbox.d.ts +1 -1
  101. package/lib/types/checkbox.template.d.ts +2 -0
  102. package/lib/types/checkbox.ws.d.ts +1 -1
  103. package/lib/types/code-text.ws.d.ts +1 -1
  104. package/lib/types/components.d.ts +1 -0
  105. package/lib/types/content-embed.template.d.ts +2 -0
  106. package/lib/types/form.ws.d.ts +1 -1
  107. package/lib/types/fragment.ws.d.ts +1 -1
  108. package/lib/types/heading.template.d.ts +2 -0
  109. package/lib/types/heading.ws.d.ts +1 -1
  110. package/lib/types/html-embed.ws.d.ts +1 -1
  111. package/lib/types/image.ws.d.ts +1 -9
  112. package/lib/types/input.ws.d.ts +1 -1
  113. package/lib/types/italic.ws.d.ts +1 -1
  114. package/lib/types/label.template.d.ts +2 -0
  115. package/lib/types/label.ws.d.ts +1 -1
  116. package/lib/types/link.template.d.ts +2 -0
  117. package/lib/types/link.ws.d.ts +1 -1
  118. package/lib/types/list-item.template.d.ts +2 -0
  119. package/lib/types/list-item.ws.d.ts +1 -1
  120. package/lib/types/list.template.d.ts +2 -0
  121. package/lib/types/list.ws.d.ts +1 -1
  122. package/lib/types/markdown-embed.template.d.ts +2 -0
  123. package/lib/types/markdown-embed.ws.d.ts +1 -1
  124. package/lib/types/metas.d.ts +1 -1
  125. package/lib/types/option.ws.d.ts +1 -1
  126. package/lib/types/paragraph.template.d.ts +2 -0
  127. package/lib/types/paragraph.ws.d.ts +1 -1
  128. package/lib/types/props.d.ts +1 -0
  129. package/lib/types/radio-button.d.ts +1 -1
  130. package/lib/types/radio-button.template.d.ts +2 -0
  131. package/lib/types/radio-button.ws.d.ts +1 -1
  132. package/lib/types/rich-text-link.ws.d.ts +1 -1
  133. package/lib/types/select.template.d.ts +2 -0
  134. package/lib/types/select.ws.d.ts +1 -1
  135. package/lib/types/separator.ws.d.ts +1 -1
  136. package/lib/types/slot.ws.d.ts +1 -1
  137. package/lib/types/span.ws.d.ts +1 -1
  138. package/lib/types/subscript.ws.d.ts +1 -1
  139. package/lib/types/superscript.ws.d.ts +1 -1
  140. package/lib/types/templates.d.ts +17 -0
  141. package/lib/types/text.template.d.ts +2 -0
  142. package/lib/types/text.ws.d.ts +1 -1
  143. package/lib/types/textarea.ws.d.ts +1 -1
  144. package/lib/types/time.ws.d.ts +1 -1
  145. package/lib/types/vimeo-play-button.ws.d.ts +1 -1
  146. package/lib/types/vimeo-preview-image.d.ts +21 -21
  147. package/lib/types/vimeo-preview-image.ws.d.ts +1 -1
  148. package/lib/types/vimeo-spinner.ws.d.ts +1 -1
  149. package/lib/types/vimeo.d.ts +12 -2
  150. package/lib/types/vimeo.template.d.ts +2 -0
  151. package/lib/types/vimeo.ws.d.ts +1 -1
  152. package/lib/types/webhook-form.template.d.ts +2 -0
  153. package/lib/types/webhook-form.ws.d.ts +1 -1
  154. package/lib/types/xml-node.ws.d.ts +1 -1
  155. package/lib/types/xml-time.ws.d.ts +1 -1
  156. package/lib/types/youtube.d.ts +143 -0
  157. package/lib/types/youtube.template.d.ts +2 -0
  158. package/lib/types/youtube.ws.d.ts +3 -0
  159. package/lib/vimeo-play-button.ws.js +8 -8
  160. package/lib/vimeo-preview-image.ws.js +17 -9
  161. package/lib/vimeo-spinner.ws.js +8 -8
  162. package/lib/vimeo.js +88 -87
  163. package/lib/vimeo.template.js +93 -0
  164. package/lib/vimeo.ws.js +14 -302
  165. package/lib/webhook-form.template.js +49 -0
  166. package/lib/webhook-form.ws.js +17 -118
  167. package/lib/xml-node.js +18 -14
  168. package/lib/xml-node.ws.js +4 -5
  169. package/lib/xml-time.ws.js +4 -5
  170. package/lib/youtube.js +200 -0
  171. package/lib/youtube.template.js +97 -0
  172. package/lib/youtube.ws.js +51 -0
  173. package/package.json +16 -9
  174. package/lib/content-embed.ws.js +0 -77
  175. package/lib/types/__generated__/local-date.props.d.ts +0 -2
  176. package/lib/types/content-embed.ws.d.ts +0 -2
@@ -0,0 +1,143 @@
1
+ import { type ComponentProps } from "react";
2
+ /**
3
+ * Options for configuring the YouTube player parameters.
4
+ * https://developers.google.com/youtube/player_parameters
5
+ */
6
+ type YouTubePlayerParameters = {
7
+ /**
8
+ * Whether the video should autoplay.
9
+ * Some browsers require the `muted` parameter to be set to `true` for autoplay to work.
10
+ * @default false
11
+ */
12
+ autoplay?: boolean;
13
+ /**
14
+ * Whether the video should start muted.
15
+ * Useful for enabling autoplay in browsers that require videos to be muted.
16
+ * Original parameter: `mute`
17
+ *@default false
18
+ */
19
+ muted?: boolean;
20
+ /**
21
+ * Whether to show player controls.
22
+ * @default true
23
+ */
24
+ showControls?: boolean;
25
+ /**
26
+ * Whether to show related videos at the end.
27
+ * Original parameter: `rel`
28
+ * @default true
29
+ */
30
+ showRelatedVideos?: boolean;
31
+ /**
32
+ * Whether to enable keyboard controls.
33
+ * @default true
34
+ */
35
+ keyboard?: boolean;
36
+ /**
37
+ * Whether the video should loop continuously.
38
+ * @default false
39
+ */
40
+ loop?: boolean;
41
+ /**
42
+ * Whether to play inline on mobile (not fullscreen).
43
+ * @default false
44
+ */
45
+ inline?: boolean;
46
+ /**
47
+ * Whether to allow fullscreen mode.
48
+ * Original parameter: `fs`
49
+ * @default true
50
+ */
51
+ allowFullscreen?: boolean;
52
+ /**
53
+ * Whether captions should be shown by default.
54
+ * Original parameter: `cc_load_policy`
55
+ * @default false
56
+ */
57
+ showCaptions?: boolean;
58
+ /**
59
+ * Whether to show annotations on the video.
60
+ * Original parameter: `iv_load_policy`
61
+ * @default true
62
+ */
63
+ showAnnotations?: boolean;
64
+ /**
65
+ * Start time of the video in seconds.
66
+ * Original parameter: `start`
67
+ */
68
+ startTime?: number;
69
+ /**
70
+ * End time of the video in seconds.
71
+ * Original parameter: `end`
72
+ */
73
+ endTime?: number;
74
+ /**
75
+ * Whether to disable keyboard controls.
76
+ * Original parameter: `disablekb`
77
+ * @default false
78
+ */
79
+ disableKeyboard?: boolean;
80
+ /**
81
+ * Referrer URL for tracking purposes.
82
+ * Original parameter: `widget_referrer`
83
+ */
84
+ referrer?: string;
85
+ /**
86
+ * Type of playlist to load.
87
+ */
88
+ listType?: "playlist" | "user_uploads";
89
+ /**
90
+ * ID of the playlist to load.
91
+ * Original parameter: `list`
92
+ */
93
+ listId?: string;
94
+ /**
95
+ * Your domain for API compliance (e.g., `https://yourdomain.com`).
96
+ */
97
+ origin?: string;
98
+ /**
99
+ * Specifies the default language that the player will use to display captions.
100
+ * The value is an ISO 639-1 two-letter language code.
101
+ * Original parameter: `cc_lang_pref`
102
+ */
103
+ captionLanguage?: string;
104
+ /**
105
+ * Sets the player's interface language. The value is an ISO 639-1 two-letter language code or a fully specified locale.
106
+ * Original parameter: `hl`
107
+ */
108
+ language?: string;
109
+ /**
110
+ * Specifies the color that will be used in the player's video progress bar to highlight the amount of the video that the viewer has already seen.
111
+ * Valid values are 'red' and 'white'.
112
+ */
113
+ color?: "red" | "white";
114
+ /**
115
+ * This parameter specifies a comma-separated list of video IDs to play
116
+ */
117
+ playlist?: string;
118
+ };
119
+ type YouTubePlayerOptions = {
120
+ /** The YouTube video URL or ID */
121
+ url?: string;
122
+ showPreview?: boolean;
123
+ /**
124
+ * The Privacy Enhanced Mode of the YouTube embedded player prevents the use of views of embedded YouTube content from influencing the viewer’s browsing experience on YouTube.
125
+ * https://support.google.com/youtube/answer/171780?hl=en#zippy=%2Cturn-on-privacy-enhanced-mode
126
+ * @default true
127
+ */
128
+ privacyEnhancedMode?: boolean;
129
+ } & YouTubePlayerParameters & {
130
+ /** Loading strategy for iframe */
131
+ loading?: "eager" | "lazy";
132
+ };
133
+ declare const defaultTag = "div";
134
+ type Props = Omit<ComponentProps<typeof defaultTag>, keyof YouTubePlayerOptions> & YouTubePlayerOptions & {
135
+ /**
136
+ * The `title` attribute for the iframe.
137
+ * Improves accessibility by providing a brief description of the video content for screen readers.
138
+ * Example: "Video about web development tips".
139
+ */
140
+ title?: string | undefined;
141
+ };
142
+ export declare const YouTube: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
143
+ export {};
@@ -0,0 +1,2 @@
1
+ import { type TemplateMeta } from "@webstudio-is/template";
2
+ export declare const meta: TemplateMeta;
@@ -0,0 +1,3 @@
1
+ import { type WsComponentMeta, type WsComponentPropsMeta } from "@webstudio-is/sdk";
2
+ export declare const meta: WsComponentMeta;
3
+ export declare const propsMeta: WsComponentPropsMeta;
@@ -1,16 +1,16 @@
1
- import { defaultStates as t } from "@webstudio-is/react-sdk";
2
- import { props as o } from "./__generated__/vimeo-play-button.props.js";
3
- import { ButtonElementIcon as e } from "@webstudio-is/icons/svg";
4
- import { button as n } from "@webstudio-is/sdk/normalize.css";
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
5
  const r = {
6
- button: n
6
+ button: e
7
7
  }, p = {
8
8
  category: "hidden",
9
9
  type: "container",
10
10
  constraints: [
11
11
  {
12
12
  relation: "ancestor",
13
- component: { $eq: "Vimeo" }
13
+ component: { $in: ["Vimeo", "YouTube"] }
14
14
  },
15
15
  {
16
16
  relation: "ancestor",
@@ -18,11 +18,11 @@ const r = {
18
18
  }
19
19
  ],
20
20
  label: "Play Button",
21
- icon: e,
21
+ icon: o,
22
22
  presetStyle: r,
23
23
  states: t
24
24
  }, c = {
25
- props: o,
25
+ props: n,
26
26
  initialProps: ["id", "className"]
27
27
  };
28
28
  export {
@@ -1,19 +1,27 @@
1
- import "@webstudio-is/react-sdk";
2
- import { meta as o, propsOverrides as r, propsMeta as e } from "./image.ws.js";
3
- import { props as t } from "./__generated__/vimeo-preview-image.props.js";
1
+ import { meta as e, propsMeta as o } from "./image.ws.js";
2
+ import { props as r } from "./__generated__/vimeo-preview-image.props.js";
4
3
  const i = {
5
- ...o,
4
+ ...e,
6
5
  category: "hidden",
7
6
  label: "Preview Image",
8
7
  constraints: {
9
8
  relation: "ancestor",
10
- component: { $eq: "Vimeo" }
9
+ component: { $in: ["Vimeo", "YouTube"] }
11
10
  }
12
- }, m = {
13
- props: { ...t, ...r },
14
- initialProps: e.initialProps
11
+ }, p = {
12
+ props: {
13
+ ...r,
14
+ // Automatically generated props don't have the right control.
15
+ src: {
16
+ type: "string",
17
+ control: "file",
18
+ label: "Source",
19
+ required: !1
20
+ }
21
+ },
22
+ initialProps: o.initialProps
15
23
  };
16
24
  export {
17
25
  i as meta,
18
- m as propsMeta
26
+ p as propsMeta
19
27
  };
@@ -1,22 +1,22 @@
1
- import { defaultStates as o } from "@webstudio-is/react-sdk";
2
- import { props as t } from "./__generated__/vimeo-spinner.props.js";
3
- import { div as e } from "@webstudio-is/sdk/normalize.css";
4
- import { BoxIcon as r } from "@webstudio-is/icons/svg";
1
+ import { defaultStates as o } from "@webstudio-is/sdk";
2
+ import { div as t } from "@webstudio-is/sdk/normalize.css";
3
+ import { BoxIcon as e } from "@webstudio-is/icons/svg";
4
+ import { props as r } from "./__generated__/vimeo-spinner.props.js";
5
5
  const n = {
6
- div: e
6
+ div: t
7
7
  }, m = {
8
8
  type: "container",
9
9
  constraints: {
10
10
  relation: "ancestor",
11
- component: { $eq: "Vimeo" }
11
+ component: { $in: ["Vimeo", "YouTube"] }
12
12
  },
13
- icon: r,
13
+ icon: e,
14
14
  states: o,
15
15
  presetStyle: n,
16
16
  category: "hidden",
17
17
  label: "Spinner"
18
18
  }, c = {
19
- props: t,
19
+ props: r,
20
20
  initialProps: ["id", "className"]
21
21
  };
22
22
  export {
package/lib/vimeo.js CHANGED
@@ -1,19 +1,19 @@
1
- import { jsx as s, jsxs as F, Fragment as z } from "react/jsx-runtime";
2
- import { colord as T } from "colord";
3
- import { createContext as q, forwardRef as G, useState as h, useContext as H, useEffect as u } from "react";
4
- import { ReactSdkContext as Y } from "@webstudio-is/react-sdk/runtime";
5
- const J = (e) => {
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";
4
+ import { ReactSdkContext as H } from "@webstudio-is/react-sdk/runtime";
5
+ const Y = (e) => {
6
6
  if (e.url === void 0)
7
7
  return;
8
8
  let t;
9
9
  try {
10
10
  const o = new URL(e.url);
11
- t = new URL(x), t.pathname = `/video${o.pathname}`;
11
+ t = new URL(R), t.pathname = `/video${o.pathname}`;
12
12
  } catch {
13
13
  }
14
14
  if (t === void 0)
15
15
  return;
16
- const r = {
16
+ const a = {
17
17
  showPortrait: "portrait",
18
18
  showByline: "byline",
19
19
  showTitle: "title",
@@ -23,36 +23,36 @@ const J = (e) => {
23
23
  backgroundMode: "background",
24
24
  doNotTrack: "dnt"
25
25
  };
26
- let n;
27
- for (n in e) {
28
- const o = e[n];
29
- if (n === "url" || o === void 0)
26
+ let r;
27
+ for (r in e) {
28
+ const o = e[r];
29
+ if (r === "url" || o === void 0)
30
30
  continue;
31
- const a = r[n] ?? n;
32
- t.searchParams.append(a, o.toString());
31
+ const i = a[r] ?? r;
32
+ t.searchParams.append(i, o.toString());
33
33
  }
34
34
  if (t.searchParams.set("autoplay", "true"), typeof e.controlsColor == "string") {
35
- const o = T(e.controlsColor).toHex().replace("#", "");
35
+ const o = z(e.controlsColor).toHex().replace("#", "");
36
36
  t.searchParams.set("color", o);
37
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
- }, f = (e) => {
39
+ }, h = (e) => {
40
40
  const t = document.createElement("link");
41
41
  t.rel = "preconnect", t.href = e, t.crossOrigin = "true", document.head.appendChild(t);
42
42
  };
43
- let I = !1;
44
- const K = "https://f.vimeocdn.com", x = "https://player.vimeo.com", b = "https://i.vimeocdn.com", Q = () => {
45
- I || window.matchMedia("(hover: none)").matches || (f(K), f(x), f(b), I = !0);
46
- }, W = (e) => {
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) => {
47
47
  try {
48
- const r = new URL(e).pathname.split("/")[2];
49
- return r === "" || r == null ? void 0 : r;
48
+ const a = new URL(e).pathname.split("/")[2];
49
+ return a === "" || a == null ? void 0 : a;
50
50
  } catch {
51
51
  }
52
- }, X = async (e) => {
53
- const r = `https://vimeo.com/api/v2/video/${W(e)}.json`, o = (await (await fetch(r)).json())[0].thumbnail_large, a = o.substr(o.lastIndexOf("/") + 1).split("_")[0], i = new URL(b);
54
- return i.pathname = `/video/${a}.webp`, i.searchParams.append("mw", "1100"), i.searchParams.append("mh", "619"), i.searchParams.append("q", "70"), i;
55
- }, Z = () => /* @__PURE__ */ s(
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(
56
56
  "div",
57
57
  {
58
58
  style: {
@@ -65,72 +65,73 @@ const K = "https://f.vimeocdn.com", x = "https://player.vimeo.com", b = "https:/
65
65
  },
66
66
  children: 'Open the "Settings" panel and paste a video URL, e.g. https://vimeo.com/831343124.'
67
67
  }
68
- ), tt = ({
69
- status: e,
70
- loading: t,
68
+ ), Z = ({
69
+ title: e,
70
+ status: t,
71
+ loading: a,
71
72
  videoUrl: r,
72
- previewImageUrl: n,
73
- autoplay: o,
74
- renderer: a,
75
- showPreview: i,
73
+ previewImageUrl: o,
74
+ autoplay: i,
75
+ renderer: n,
76
+ showPreview: d,
76
77
  onStatusChange: c,
77
78
  onPreviewImageUrlChange: l
78
79
  }) => {
79
- const [m, p] = h(0);
80
- if (u(() => {
81
- o && a !== "canvas" && e === "initial" && c("loading");
82
- }, [o, e, a, c]), u(() => {
83
- a !== "canvas" && Q();
84
- }, [a]), u(() => {
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(() => {
85
86
  if (r !== void 0) {
86
- if (i === !1) {
87
+ if (d === !1) {
87
88
  l(void 0);
88
89
  return;
89
90
  }
90
- n === void 0 && X(r).then(l).catch(() => {
91
+ o === void 0 && W(r).then(l).catch(() => {
91
92
  console.error(`Could not load preview image for ${r}`);
92
93
  });
93
94
  }
94
- }, [l, i, r, n]), !(a === "canvas" || e === "initial"))
95
+ }, [l, d, r, o]), !(n === "canvas" || t === "initial"))
95
96
  return /* @__PURE__ */ s(
96
97
  "iframe",
97
98
  {
99
+ title: e,
98
100
  src: r,
99
- loading: t,
101
+ loading: a,
100
102
  allow: "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture;",
101
103
  allowFullScreen: !0,
102
104
  style: {
103
105
  position: "absolute",
104
106
  width: "100%",
105
107
  height: "100%",
106
- opacity: m,
108
+ opacity: p,
107
109
  transition: "opacity 1s",
108
110
  border: "none"
109
111
  },
110
112
  onLoad: () => {
111
- c("ready"), p(1);
113
+ c("ready"), u(1);
112
114
  }
113
115
  }
114
116
  );
115
- }, et = q({
117
+ }, tt = T({
116
118
  onInitPlayer: () => {
117
119
  },
118
120
  status: "initial"
119
- }), rt = G(
121
+ }), et = q(
120
122
  ({
121
123
  url: e,
122
124
  loading: t = "lazy",
123
- autoplay: r = !1,
124
- autopause: n = !0,
125
- backgroundMode: o = !1,
126
- showByline: a = !1,
125
+ autoplay: a = !1,
126
+ autopause: r = !0,
127
+ showByline: o = !1,
127
128
  showControls: i = !0,
128
- doNotTrack: c = !1,
129
- keyboard: l = !0,
130
- loop: m = !1,
131
- muted: p = !1,
132
- pip: R = !1,
133
- playsinline: U = !0,
129
+ doNotTrack: n = !1,
130
+ keyboard: d = !0,
131
+ loop: c = !1,
132
+ muted: l = !1,
133
+ pip: p = !1,
134
+ playsinline: u = !0,
134
135
  showPortrait: S = !0,
135
136
  quality: L = "auto",
136
137
  responsive: k = !0,
@@ -143,22 +144,21 @@ const K = "https://f.vimeocdn.com", x = "https://player.vimeo.com", b = "https:/
143
144
  interactiveParams: V,
144
145
  texttrack: $,
145
146
  children: A,
146
- ...B
147
- }, d) => {
148
- const [v, y] = h("initial"), [w, D] = h(), { renderer: g } = H(Y), P = J({
147
+ ...y
148
+ }, m) => {
149
+ const [w, g] = v("initial"), [P, B] = v(), { renderer: C } = G(H), I = Y({
149
150
  url: e,
150
- autoplay: r,
151
- autopause: n,
152
- backgroundMode: o,
151
+ autoplay: a,
152
+ autopause: r,
153
153
  showControls: i,
154
154
  controlsColor: O,
155
- doNotTrack: c,
155
+ doNotTrack: n,
156
156
  interactiveParams: V,
157
- keyboard: l,
158
- loop: m,
159
- muted: p,
160
- pip: R,
161
- playsinline: U,
157
+ keyboard: d,
158
+ loop: c,
159
+ muted: l,
160
+ pip: p,
161
+ playsinline: u,
162
162
  quality: L,
163
163
  responsive: k,
164
164
  speed: E,
@@ -169,36 +169,37 @@ const K = "https://f.vimeocdn.com", x = "https://player.vimeo.com", b = "https:/
169
169
  autopip: N
170
170
  });
171
171
  return /* @__PURE__ */ s(
172
- et.Provider,
172
+ tt.Provider,
173
173
  {
174
174
  value: {
175
- status: v,
176
- previewImageUrl: w,
175
+ status: w,
176
+ previewImageUrl: P,
177
177
  onInitPlayer() {
178
- g !== "canvas" && y("loading");
178
+ C !== "canvas" && g("loading");
179
179
  }
180
180
  },
181
181
  children: /* @__PURE__ */ s(
182
182
  "div",
183
183
  {
184
- ...B,
185
- ref: (C) => {
186
- d !== null && (typeof d == "function" ? d(C) : d.current = C);
184
+ ...y,
185
+ ref: (x) => {
186
+ m !== null && (typeof m == "function" ? m(x) : m.current = x);
187
187
  },
188
- children: P === void 0 ? /* @__PURE__ */ s(Z, {}) : /* @__PURE__ */ F(z, { children: [
188
+ children: I === void 0 ? /* @__PURE__ */ s(X, {}) : /* @__PURE__ */ D(F, { children: [
189
189
  A,
190
190
  /* @__PURE__ */ s(
191
- tt,
191
+ Z,
192
192
  {
193
- autoplay: r,
194
- videoUrl: P,
195
- previewImageUrl: w,
193
+ title: y.title,
194
+ autoplay: a,
195
+ videoUrl: I,
196
+ previewImageUrl: P,
196
197
  loading: t,
197
198
  showPreview: M,
198
- renderer: g,
199
- status: v,
200
- onStatusChange: y,
201
- onPreviewImageUrlChange: D
199
+ renderer: C,
200
+ status: w,
201
+ onStatusChange: g,
202
+ onPreviewImageUrlChange: B
202
203
  }
203
204
  )
204
205
  ] })
@@ -208,8 +209,8 @@ const K = "https://f.vimeocdn.com", x = "https://player.vimeo.com", b = "https:/
208
209
  );
209
210
  }
210
211
  );
211
- rt.displayName = "Vimeo";
212
+ et.displayName = "Vimeo";
212
213
  export {
213
- rt as Vimeo,
214
- et as VimeoContext
214
+ et as Vimeo,
215
+ tt as VimeoContext
215
216
  };
@@ -0,0 +1,93 @@
1
+ import { jsxs as i, jsx as t } from "react/jsx-runtime";
2
+ import { SpinnerIcon as r, PlayIcon as a } from "@webstudio-is/icons/svg";
3
+ import { $ as e, css as o } from "@webstudio-is/template";
4
+ const p = {
5
+ category: "media",
6
+ order: 1,
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,
10
+ {
11
+ "ws:style": o`
12
+ position: relative;
13
+ aspect-ratio: 640/360;
14
+ width: 100%;
15
+ `,
16
+ children: [
17
+ /* @__PURE__ */ t(
18
+ e.VimeoPreviewImage,
19
+ {
20
+ "ws:style": o`
21
+ position: absolute;
22
+ object-fit: cover;
23
+ object-position: cover;
24
+ width: 100%;
25
+ height: 100%;
26
+ border-radius: 20px;
27
+ `,
28
+ alt: "Vimeo video preview image",
29
+ sizes: "100vw",
30
+ optimize: !0
31
+ }
32
+ ),
33
+ /* @__PURE__ */ t(
34
+ e.VimeoSpinner,
35
+ {
36
+ "ws:label": "Spinner",
37
+ "ws:style": o`
38
+ position: absolute;
39
+ top: 50%;
40
+ left: 50%;
41
+ width: 70px;
42
+ height: 70px;
43
+ margin-top: -35px;
44
+ margin-left: -35px;
45
+ `,
46
+ children: /* @__PURE__ */ t(e.HtmlEmbed, { "ws:label": "Spinner SVG", code: r })
47
+ }
48
+ ),
49
+ /* @__PURE__ */ t(
50
+ e.VimeoPlayButton,
51
+ {
52
+ "ws:style": o`
53
+ position: absolute;
54
+ width: 140px;
55
+ height: 80px;
56
+ top: 50%;
57
+ left: 50%;
58
+ margin-top: -40px;
59
+ margin-left: -70px;
60
+ display: flex;
61
+ align-items: center;
62
+ justify-content: center;
63
+ border-style: none;
64
+ border-radius: 5px;
65
+ cursor: pointer;
66
+ background-color: rgb(18, 18, 18);
67
+ color: rgb(255, 255, 255);
68
+ &:hover {
69
+ background-color: rgb(0, 173, 239);
70
+ }
71
+ `,
72
+ "aria-label": "Play button",
73
+ children: /* @__PURE__ */ t(
74
+ e.Box,
75
+ {
76
+ "ws:label": "Play Icon",
77
+ "ws:style": o`
78
+ width: 60px;
79
+ height: 60px;
80
+ `,
81
+ "aria-hidden": !0,
82
+ children: /* @__PURE__ */ t(e.HtmlEmbed, { "ws:label": "Play SVG", code: a })
83
+ }
84
+ )
85
+ }
86
+ )
87
+ ]
88
+ }
89
+ )
90
+ };
91
+ export {
92
+ p as meta
93
+ };