@webstudio-is/sdk-components-react 0.0.0-017f1bd

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 (297) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +3 -0
  3. package/lib/__generated__/blockquote.props.js +4 -0
  4. package/lib/__generated__/body.props.js +4 -0
  5. package/lib/__generated__/bold.props.js +4 -0
  6. package/lib/__generated__/box.props.js +6 -0
  7. package/lib/__generated__/button.props.js +4 -0
  8. package/lib/__generated__/checkbox.props.js +11 -0
  9. package/lib/__generated__/code-text.props.js +6 -0
  10. package/lib/__generated__/form.props.js +4 -0
  11. package/lib/__generated__/head-link.props.js +4 -0
  12. package/lib/__generated__/head-meta.props.js +4 -0
  13. package/lib/__generated__/head-slot.props.js +4 -0
  14. package/lib/__generated__/head-title.props.js +4 -0
  15. package/lib/__generated__/heading.props.js +6 -0
  16. package/lib/__generated__/html-embed.props.js +18 -0
  17. package/lib/__generated__/image.props.js +13 -0
  18. package/lib/__generated__/input.props.js +4 -0
  19. package/lib/__generated__/italic.props.js +4 -0
  20. package/lib/__generated__/label.props.js +4 -0
  21. package/lib/__generated__/link.props.js +27 -0
  22. package/lib/__generated__/list-item.props.js +4 -0
  23. package/lib/__generated__/list.props.js +12 -0
  24. package/lib/__generated__/markdown-embed.props.js +6 -0
  25. package/lib/__generated__/option.props.js +4 -0
  26. package/lib/__generated__/paragraph.props.js +4 -0
  27. package/lib/__generated__/radio-button.props.js +11 -0
  28. package/lib/__generated__/select.props.js +4 -0
  29. package/lib/__generated__/separator.props.js +4 -0
  30. package/lib/__generated__/span.props.js +4 -0
  31. package/lib/__generated__/subscript.props.js +4 -0
  32. package/lib/__generated__/superscript.props.js +4 -0
  33. package/lib/__generated__/text.props.js +6 -0
  34. package/lib/__generated__/textarea.props.js +4 -0
  35. package/lib/__generated__/time.props.js +305 -0
  36. package/lib/__generated__/video.props.js +4 -0
  37. package/lib/__generated__/vimeo-play-button.props.js +4 -0
  38. package/lib/__generated__/vimeo-preview-image.props.js +12 -0
  39. package/lib/__generated__/vimeo-spinner.props.js +4 -0
  40. package/lib/__generated__/vimeo.props.js +170 -0
  41. package/lib/__generated__/webhook-form.props.js +13 -0
  42. package/lib/__generated__/xml-node.props.js +26 -0
  43. package/lib/__generated__/xml-time.props.js +19 -0
  44. package/lib/__generated__/youtube.props.js +168 -0
  45. package/lib/blockquote.js +9 -0
  46. package/lib/blockquote.ws.js +56 -0
  47. package/lib/body.js +7 -0
  48. package/lib/body.ws.js +10 -0
  49. package/lib/bold.js +7 -0
  50. package/lib/bold.ws.js +11 -0
  51. package/lib/box.js +12 -0
  52. package/lib/box.ws.js +41 -0
  53. package/lib/button.js +9 -0
  54. package/lib/button.ws.js +10 -0
  55. package/lib/checkbox.js +15 -0
  56. package/lib/checkbox.ws.js +20 -0
  57. package/lib/code-text.js +10 -0
  58. package/lib/code-text.ws.js +51 -0
  59. package/lib/components.js +91 -0
  60. package/lib/content-embed.template.js +83 -0
  61. package/lib/form.js +7 -0
  62. package/lib/form.ws.js +16 -0
  63. package/lib/fragment.js +7 -0
  64. package/lib/fragment.ws.js +4 -0
  65. package/lib/head-link.js +23 -0
  66. package/lib/head-link.ws.js +14 -0
  67. package/lib/head-meta.js +23 -0
  68. package/lib/head-meta.ws.js +14 -0
  69. package/lib/head-slot.js +53 -0
  70. package/lib/head-slot.template.js +15 -0
  71. package/lib/head-slot.ws.js +14 -0
  72. package/lib/head-title.js +23 -0
  73. package/lib/head-title.ws.js +13 -0
  74. package/lib/heading.js +12 -0
  75. package/lib/heading.ws.js +25 -0
  76. package/lib/home_wsKvRSqvkajPPBeycZ-C8.svg +3 -0
  77. package/lib/hooks.js +6 -0
  78. package/lib/html-embed-patchers.js +29 -0
  79. package/lib/html-embed.js +112 -0
  80. package/lib/html-embed.ws.js +48 -0
  81. package/lib/image.js +38 -0
  82. package/lib/image.ws.js +53 -0
  83. package/lib/input.js +21 -0
  84. package/lib/input.ws.js +28 -0
  85. package/lib/italic.js +7 -0
  86. package/lib/italic.ws.js +11 -0
  87. package/lib/label.js +7 -0
  88. package/lib/label.ws.js +16 -0
  89. package/lib/link.js +15 -0
  90. package/lib/link.ws.js +26 -0
  91. package/lib/list-item.js +9 -0
  92. package/lib/list-item.ws.js +10 -0
  93. package/lib/list.js +6 -0
  94. package/lib/list.ws.js +41 -0
  95. package/lib/markdown-embed.js +19 -0
  96. package/lib/markdown-embed.template.js +75 -0
  97. package/lib/markdown-embed.ws.js +35 -0
  98. package/lib/metas.js +92 -0
  99. package/lib/option.js +9 -0
  100. package/lib/option.ws.js +35 -0
  101. package/lib/paragraph.js +7 -0
  102. package/lib/paragraph.ws.js +10 -0
  103. package/lib/radio-button.js +15 -0
  104. package/lib/radio-button.ws.js +21 -0
  105. package/lib/rich-text-link.ws.js +5 -0
  106. package/lib/select.js +32 -0
  107. package/lib/select.ws.js +26 -0
  108. package/lib/separator.js +9 -0
  109. package/lib/separator.ws.js +38 -0
  110. package/lib/shared/video.js +13 -0
  111. package/lib/slot.js +14 -0
  112. package/lib/slot.ws.js +10 -0
  113. package/lib/span.js +7 -0
  114. package/lib/span.ws.js +13 -0
  115. package/lib/subscript.js +7 -0
  116. package/lib/subscript.ws.js +11 -0
  117. package/lib/superscript.js +7 -0
  118. package/lib/superscript.ws.js +11 -0
  119. package/lib/templates.js +14 -0
  120. package/lib/text.js +12 -0
  121. package/lib/text.ws.js +28 -0
  122. package/lib/textarea.js +18 -0
  123. package/lib/textarea.ws.js +33 -0
  124. package/lib/time.js +320 -0
  125. package/lib/time.ws.js +18 -0
  126. package/lib/types/__generated__/blockquote.props.d.ts +2 -0
  127. package/lib/types/__generated__/body.props.d.ts +2 -0
  128. package/lib/types/__generated__/bold.props.d.ts +2 -0
  129. package/lib/types/__generated__/box.props.d.ts +2 -0
  130. package/lib/types/__generated__/button.props.d.ts +2 -0
  131. package/lib/types/__generated__/checkbox.props.d.ts +2 -0
  132. package/lib/types/__generated__/code-text.props.d.ts +2 -0
  133. package/lib/types/__generated__/form.props.d.ts +2 -0
  134. package/lib/types/__generated__/fragment.props.d.ts +2 -0
  135. package/lib/types/__generated__/head-link.props.d.ts +2 -0
  136. package/lib/types/__generated__/head-meta.props.d.ts +2 -0
  137. package/lib/types/__generated__/head-slot.props.d.ts +2 -0
  138. package/lib/types/__generated__/head-title.props.d.ts +2 -0
  139. package/lib/types/__generated__/heading.props.d.ts +2 -0
  140. package/lib/types/__generated__/html-embed.props.d.ts +2 -0
  141. package/lib/types/__generated__/image.props.d.ts +2 -0
  142. package/lib/types/__generated__/input.props.d.ts +2 -0
  143. package/lib/types/__generated__/italic.props.d.ts +2 -0
  144. package/lib/types/__generated__/label.props.d.ts +2 -0
  145. package/lib/types/__generated__/link.props.d.ts +2 -0
  146. package/lib/types/__generated__/list-item.props.d.ts +2 -0
  147. package/lib/types/__generated__/list.props.d.ts +2 -0
  148. package/lib/types/__generated__/markdown-embed.props.d.ts +2 -0
  149. package/lib/types/__generated__/option.props.d.ts +2 -0
  150. package/lib/types/__generated__/paragraph.props.d.ts +2 -0
  151. package/lib/types/__generated__/radio-button.props.d.ts +2 -0
  152. package/lib/types/__generated__/rich-text-link.props.d.ts +2 -0
  153. package/lib/types/__generated__/select.props.d.ts +2 -0
  154. package/lib/types/__generated__/separator.props.d.ts +2 -0
  155. package/lib/types/__generated__/slot.props.d.ts +2 -0
  156. package/lib/types/__generated__/span.props.d.ts +2 -0
  157. package/lib/types/__generated__/subscript.props.d.ts +2 -0
  158. package/lib/types/__generated__/superscript.props.d.ts +2 -0
  159. package/lib/types/__generated__/text.props.d.ts +2 -0
  160. package/lib/types/__generated__/textarea.props.d.ts +2 -0
  161. package/lib/types/__generated__/time.props.d.ts +2 -0
  162. package/lib/types/__generated__/video.props.d.ts +2 -0
  163. package/lib/types/__generated__/vimeo-play-button.props.d.ts +2 -0
  164. package/lib/types/__generated__/vimeo-preview-image.props.d.ts +2 -0
  165. package/lib/types/__generated__/vimeo-spinner.props.d.ts +2 -0
  166. package/lib/types/__generated__/vimeo.props.d.ts +2 -0
  167. package/lib/types/__generated__/webhook-form.props.d.ts +2 -0
  168. package/lib/types/__generated__/xml-node.props.d.ts +2 -0
  169. package/lib/types/__generated__/xml-time.props.d.ts +2 -0
  170. package/lib/types/__generated__/youtube.props.d.ts +2 -0
  171. package/lib/types/blockquote.d.ts +2 -0
  172. package/lib/types/blockquote.ws.d.ts +2 -0
  173. package/lib/types/body.d.ts +2 -0
  174. package/lib/types/body.ws.d.ts +2 -0
  175. package/lib/types/bold.d.ts +2 -0
  176. package/lib/types/bold.ws.d.ts +2 -0
  177. package/lib/types/box.d.ts +7 -0
  178. package/lib/types/box.ws.d.ts +2 -0
  179. package/lib/types/button.d.ts +2 -0
  180. package/lib/types/button.ws.d.ts +2 -0
  181. package/lib/types/checkbox.d.ts +4 -0
  182. package/lib/types/checkbox.ws.d.ts +2 -0
  183. package/lib/types/code-text.d.ts +4 -0
  184. package/lib/types/code-text.ws.d.ts +2 -0
  185. package/lib/types/components.d.ts +45 -0
  186. package/lib/types/content-embed.template.d.ts +2 -0
  187. package/lib/types/form.d.ts +2 -0
  188. package/lib/types/form.ws.d.ts +2 -0
  189. package/lib/types/fragment.d.ts +6 -0
  190. package/lib/types/fragment.ws.d.ts +2 -0
  191. package/lib/types/head-link.d.ts +8 -0
  192. package/lib/types/head-link.ws.d.ts +2 -0
  193. package/lib/types/head-meta.d.ts +2 -0
  194. package/lib/types/head-meta.ws.d.ts +2 -0
  195. package/lib/types/head-slot.d.ts +9 -0
  196. package/lib/types/head-slot.template.d.ts +2 -0
  197. package/lib/types/head-slot.ws.d.ts +2 -0
  198. package/lib/types/head-title.d.ts +2 -0
  199. package/lib/types/head-title.ws.d.ts +2 -0
  200. package/lib/types/heading.d.ts +7 -0
  201. package/lib/types/heading.ws.d.ts +2 -0
  202. package/lib/types/hooks.d.ts +2 -0
  203. package/lib/types/html-embed-patchers.d.ts +2 -0
  204. package/lib/types/html-embed.d.ts +12 -0
  205. package/lib/types/html-embed.test.d.ts +1 -0
  206. package/lib/types/html-embed.ws.d.ts +2 -0
  207. package/lib/types/image.d.ts +8 -0
  208. package/lib/types/image.ws.d.ts +2 -0
  209. package/lib/types/input.d.ts +1 -0
  210. package/lib/types/input.ws.d.ts +2 -0
  211. package/lib/types/italic.d.ts +2 -0
  212. package/lib/types/italic.ws.d.ts +2 -0
  213. package/lib/types/label.d.ts +2 -0
  214. package/lib/types/label.ws.d.ts +2 -0
  215. package/lib/types/link.d.ts +11 -0
  216. package/lib/types/link.ws.d.ts +2 -0
  217. package/lib/types/list-item.d.ts +2 -0
  218. package/lib/types/list-item.ws.d.ts +2 -0
  219. package/lib/types/list.d.ts +10 -0
  220. package/lib/types/list.ws.d.ts +2 -0
  221. package/lib/types/markdown-embed.d.ts +7 -0
  222. package/lib/types/markdown-embed.template.d.ts +2 -0
  223. package/lib/types/markdown-embed.ws.d.ts +2 -0
  224. package/lib/types/metas.d.ts +45 -0
  225. package/lib/types/option.d.ts +1 -0
  226. package/lib/types/option.ws.d.ts +2 -0
  227. package/lib/types/paragraph.d.ts +2 -0
  228. package/lib/types/paragraph.ws.d.ts +2 -0
  229. package/lib/types/radio-button.d.ts +4 -0
  230. package/lib/types/radio-button.ws.d.ts +2 -0
  231. package/lib/types/rich-text-link.d.ts +1 -0
  232. package/lib/types/rich-text-link.ws.d.ts +2 -0
  233. package/lib/types/select.d.ts +3 -0
  234. package/lib/types/select.ws.d.ts +2 -0
  235. package/lib/types/separator.d.ts +2 -0
  236. package/lib/types/separator.ws.d.ts +2 -0
  237. package/lib/types/shared/video.d.ts +7 -0
  238. package/lib/types/slot.d.ts +6 -0
  239. package/lib/types/slot.ws.d.ts +2 -0
  240. package/lib/types/span.d.ts +2 -0
  241. package/lib/types/span.ws.d.ts +2 -0
  242. package/lib/types/subscript.d.ts +2 -0
  243. package/lib/types/subscript.ws.d.ts +2 -0
  244. package/lib/types/superscript.d.ts +2 -0
  245. package/lib/types/superscript.ws.d.ts +2 -0
  246. package/lib/types/templates.d.ts +6 -0
  247. package/lib/types/test-utils/cartesian.d.ts +2 -0
  248. package/lib/types/text.d.ts +7 -0
  249. package/lib/types/text.ws.d.ts +2 -0
  250. package/lib/types/textarea.d.ts +1 -0
  251. package/lib/types/textarea.ws.d.ts +2 -0
  252. package/lib/types/time.d.ts +16 -0
  253. package/lib/types/time.test.d.ts +1 -0
  254. package/lib/types/time.ws.d.ts +2 -0
  255. package/lib/types/video.d.ts +9 -0
  256. package/lib/types/video.ws.d.ts +2 -0
  257. package/lib/types/vimeo-play-button.d.ts +3 -0
  258. package/lib/types/vimeo-play-button.ws.d.ts +2 -0
  259. package/lib/types/vimeo-preview-image.d.ts +284 -0
  260. package/lib/types/vimeo-preview-image.ws.d.ts +2 -0
  261. package/lib/types/vimeo-spinner.d.ts +1 -0
  262. package/lib/types/vimeo-spinner.ws.d.ts +2 -0
  263. package/lib/types/vimeo.d.ts +79 -0
  264. package/lib/types/vimeo.template.d.ts +2 -0
  265. package/lib/types/vimeo.ws.d.ts +2 -0
  266. package/lib/types/webhook-form.d.ts +9 -0
  267. package/lib/types/webhook-form.template.d.ts +2 -0
  268. package/lib/types/webhook-form.ws.d.ts +2 -0
  269. package/lib/types/xml-node.d.ts +13 -0
  270. package/lib/types/xml-node.ws.d.ts +2 -0
  271. package/lib/types/xml-time.d.ts +6 -0
  272. package/lib/types/xml-time.ws.d.ts +2 -0
  273. package/lib/types/youtube.d.ts +143 -0
  274. package/lib/types/youtube.template.d.ts +2 -0
  275. package/lib/types/youtube.ws.d.ts +2 -0
  276. package/lib/video.js +53 -0
  277. package/lib/video.ws.js +44 -0
  278. package/lib/vimeo-play-button.js +18 -0
  279. package/lib/vimeo-play-button.ws.js +18 -0
  280. package/lib/vimeo-preview-image.js +19 -0
  281. package/lib/vimeo-preview-image.ws.js +25 -0
  282. package/lib/vimeo-spinner.js +13 -0
  283. package/lib/vimeo-spinner.ws.js +18 -0
  284. package/lib/vimeo.js +215 -0
  285. package/lib/vimeo.template.js +94 -0
  286. package/lib/vimeo.ws.js +35 -0
  287. package/lib/webhook-form.js +9 -0
  288. package/lib/webhook-form.template.js +88 -0
  289. package/lib/webhook-form.ws.js +27 -0
  290. package/lib/xml-node.js +61 -0
  291. package/lib/xml-node.ws.js +13 -0
  292. package/lib/xml-time.js +25 -0
  293. package/lib/xml-time.ws.js +13 -0
  294. package/lib/youtube.js +227 -0
  295. package/lib/youtube.template.js +98 -0
  296. package/lib/youtube.ws.js +45 -0
  297. package/package.json +74 -0
@@ -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,2 @@
1
+ import type { WsComponentMeta } from "@webstudio-is/sdk";
2
+ export declare const meta: WsComponentMeta;
package/lib/video.js ADDED
@@ -0,0 +1,53 @@
1
+ import { jsx as p } from "react/jsx-runtime";
2
+ import { forwardRef as y, useId as V, useContext as N, useEffect as x } from "react";
3
+ import { ReactSdkContext as I } from "@webstudio-is/react-sdk/runtime";
4
+ const c = "data-ws-video-id", S = {
5
+ HAVE_METADATA: 1
6
+ }, _ = y(
7
+ ({
8
+ $progress: r,
9
+ $visible: n,
10
+ $timeline: d,
11
+ $webstudio$canvasOnly$assetId: w,
12
+ children: l,
13
+ src: o,
14
+ ...b
15
+ }, m) => {
16
+ const u = V(), A = {
17
+ [c]: u
18
+ }, { videoLoader: f } = N(I), T = o && f ? f({ src: o }) : o;
19
+ return x(() => {
20
+ if (r === void 0 || n === void 0)
21
+ return;
22
+ const e = document.querySelector(`[${c}="${u}"]`);
23
+ if (e === null || !(e instanceof HTMLVideoElement))
24
+ return;
25
+ if (e.play().catch(() => {
26
+ }), e.pause(), d)
27
+ return r.subscribe((t) => {
28
+ if (e.readyState < S.HAVE_METADATA || (e.paused || e.pause(), e.seeking))
29
+ return;
30
+ let s = e.duration;
31
+ Number.isNaN(s) || (Number.isFinite(s) || (s = 60), e.currentTime = (t ?? 0) * s);
32
+ });
33
+ let i = !1, a = !1;
34
+ const v = n.subscribe((t) => {
35
+ a = t, a === !1 && i === !1 && !e.loop && (e.currentTime = 0);
36
+ }), E = r.subscribe((t) => {
37
+ if (i && (t === void 0 || t === 0 || t === 1)) {
38
+ i = !1, e.pause(), a === !1 && i === !1 && !e.loop && (e.currentTime = 0);
39
+ return;
40
+ }
41
+ i || (i = !0, e.ended || e.play().catch(() => {
42
+ }));
43
+ });
44
+ return () => {
45
+ E(), v();
46
+ };
47
+ }, [r, d, n, u]), /* @__PURE__ */ p("video", { src: T, ...b, ...A, ref: m, children: l });
48
+ }
49
+ );
50
+ _.displayName = "Video";
51
+ export {
52
+ _ as Video
53
+ };
@@ -0,0 +1,44 @@
1
+ import { VideoIcon as e } from "@webstudio-is/icons/svg";
2
+ import { props as o } from "./__generated__/video.props.js";
3
+ const i = {
4
+ icon: e,
5
+ contentModel: {
6
+ category: "instance",
7
+ children: []
8
+ },
9
+ presetStyle: {
10
+ video: [
11
+ {
12
+ property: "max-width",
13
+ value: { type: "unit", unit: "%", value: 100 }
14
+ }
15
+ ]
16
+ },
17
+ initialProps: [
18
+ "id",
19
+ "class",
20
+ "width",
21
+ "height",
22
+ "src",
23
+ "autoPlay",
24
+ "controls",
25
+ "loop",
26
+ "muted",
27
+ "preload",
28
+ "playsInline"
29
+ ],
30
+ props: {
31
+ ...o,
32
+ // Automatically generated props don't have the right control.
33
+ src: {
34
+ type: "string",
35
+ control: "file",
36
+ label: "Source",
37
+ required: !1,
38
+ accept: ".mp4,.webm,.mpg,.mpeg,.mov"
39
+ }
40
+ }
41
+ };
42
+ export {
43
+ i as meta
44
+ };
@@ -0,0 +1,18 @@
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import { forwardRef as r, useContext as a, useCallback as m } from "react";
3
+ import s from "await-interaction-response";
4
+ import { Button as l } from "./button.js";
5
+ import { VideoContext as c } from "./shared/video.js";
6
+ const f = r(
7
+ (o, i) => {
8
+ const t = a(c), n = m(async () => {
9
+ await s(), t.onInitPlayer();
10
+ }, [t]);
11
+ if (t.status === "initial")
12
+ return /* @__PURE__ */ e(l, { ...o, onClick: n, ref: i });
13
+ }
14
+ );
15
+ f.displayName = "VimeoPlayButton";
16
+ export {
17
+ f as VimeoPlayButton
18
+ };
@@ -0,0 +1,18 @@
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 = {
5
+ category: "hidden",
6
+ label: "Play Button",
7
+ icon: t,
8
+ contentModel: {
9
+ category: "none",
10
+ children: ["instance"]
11
+ },
12
+ presetStyle: { button: o },
13
+ initialProps: ["id", "class"],
14
+ props: e
15
+ };
16
+ export {
17
+ c as meta
18
+ };
@@ -0,0 +1,19 @@
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { forwardRef as m, useContext as t } from "react";
3
+ import { Image as a } from "./image.js";
4
+ import { VideoContext as g } from "./shared/video.js";
5
+ const n = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkOAMAANIAzr59FiYAAAAASUVORK5CYII=", s = m(({ src: A, ...e }, o) => {
6
+ const r = t(g);
7
+ return /* @__PURE__ */ i(
8
+ a,
9
+ {
10
+ ...e,
11
+ src: String(r.previewImageUrl ?? A ?? n),
12
+ ref: o
13
+ }
14
+ );
15
+ });
16
+ s.displayName = "VimeoPreviewImage";
17
+ export {
18
+ s as VimeoPreviewImage
19
+ };
@@ -0,0 +1,25 @@
1
+ import { meta as e } from "./image.ws.js";
2
+ import { props as r } from "./__generated__/vimeo-preview-image.props.js";
3
+ const i = {
4
+ ...e,
5
+ category: "hidden",
6
+ label: "Preview Image",
7
+ contentModel: {
8
+ category: "none",
9
+ children: []
10
+ },
11
+ initialProps: e.initialProps,
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
+ };
23
+ export {
24
+ i as meta
25
+ };
@@ -0,0 +1,13 @@
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import { forwardRef as r, useContext as i } from "react";
3
+ import { VideoContext as n } from "./shared/video.js";
4
+ const m = r(
5
+ (o, t) => {
6
+ if (i(n).status === "loading")
7
+ return /* @__PURE__ */ e("div", { ...o, ref: t });
8
+ }
9
+ );
10
+ m.displayName = "VimeoSpinner";
11
+ export {
12
+ m as VimeoSpinner
13
+ };
@@ -0,0 +1,18 @@
1
+ import { div as o } from "@webstudio-is/sdk/normalize.css";
2
+ import { BoxIcon as e } from "@webstudio-is/icons/svg";
3
+ import { props as n } from "./__generated__/vimeo-spinner.props.js";
4
+ const c = {
5
+ icon: e,
6
+ category: "hidden",
7
+ label: "Spinner",
8
+ contentModel: {
9
+ category: "none",
10
+ children: ["instance"]
11
+ },
12
+ presetStyle: { div: o },
13
+ initialProps: ["id", "class"],
14
+ props: n
15
+ };
16
+ export {
17
+ c as meta
18
+ };
package/lib/vimeo.js ADDED
@@ -0,0 +1,215 @@
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
+ import { ReactSdkContext as H } from "@webstudio-is/react-sdk/runtime";
5
+ import { VideoContext as Y, requestFullscreen as J } from "./shared/video.js";
6
+ const K = (t) => {
7
+ if (t.url === void 0)
8
+ return;
9
+ let e;
10
+ try {
11
+ const o = new URL(t.url);
12
+ e = new URL(S), e.pathname = `/video${o.pathname}`;
13
+ } catch {
14
+ }
15
+ if (e === void 0)
16
+ return;
17
+ const a = {
18
+ showPortrait: "portrait",
19
+ showByline: "byline",
20
+ showTitle: "title",
21
+ controlsColor: "color",
22
+ showControls: "controls",
23
+ interactiveParams: "interactive_params",
24
+ backgroundMode: "background",
25
+ doNotTrack: "dnt"
26
+ };
27
+ let r;
28
+ for (r in t) {
29
+ const o = t[r];
30
+ if (r === "url" || o === void 0)
31
+ continue;
32
+ const s = a[r] ?? r;
33
+ e.searchParams.append(s, o.toString());
34
+ }
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);
38
+ }
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);
43
+ };
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) => {
48
+ try {
49
+ const a = new URL(t).pathname.split("/")[2];
50
+ return a === "" || a == null ? void 0 : a;
51
+ } catch {
52
+ }
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(
57
+ "div",
58
+ {
59
+ style: {
60
+ display: "flex",
61
+ width: "100%",
62
+ height: "100%",
63
+ alignItems: "center",
64
+ justifyContent: "center",
65
+ fontSize: "1.2em"
66
+ },
67
+ children: 'Open the "Settings" panel and paste a video URL, e.g. https://vimeo.com/831343124.'
68
+ }
69
+ ), te = ({
70
+ title: t,
71
+ status: e,
72
+ loading: a,
73
+ videoUrl: r,
74
+ previewImageUrl: o,
75
+ autoplay: s,
76
+ renderer: n,
77
+ showPreview: m,
78
+ playsinline: f,
79
+ onStatusChange: c,
80
+ onPreviewImageUrlChange: l
81
+ }) => {
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(() => {
88
+ if (r !== void 0) {
89
+ if (m === !1) {
90
+ l(void 0);
91
+ return;
92
+ }
93
+ o === void 0 && Z(r).then(l).catch(() => {
94
+ console.error(`Could not load preview image for ${r}`);
95
+ });
96
+ }
97
+ }, [l, m, r, o]), !(n === "canvas" || e === "initial"))
98
+ return /* @__PURE__ */ i(
99
+ "iframe",
100
+ {
101
+ ref: d,
102
+ title: t,
103
+ src: r,
104
+ loading: a,
105
+ allow: "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture;",
106
+ allowFullScreen: !0,
107
+ style: {
108
+ position: "absolute",
109
+ width: "100%",
110
+ height: "100%",
111
+ opacity: u,
112
+ transition: "opacity 1s",
113
+ border: "none"
114
+ },
115
+ onLoad: () => {
116
+ c("ready"), h(1), d.current && !f && !s && J(d.current);
117
+ }
118
+ }
119
+ );
120
+ }, re = z(
121
+ ({
122
+ url: t,
123
+ loading: e = "lazy",
124
+ autoplay: a = !1,
125
+ autopause: r = !0,
126
+ showByline: o = !1,
127
+ showControls: s = !0,
128
+ doNotTrack: n = !1,
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",
136
+ responsive: k = !0,
137
+ speed: E = !1,
138
+ showTitle: _ = !1,
139
+ transparent: j = !0,
140
+ showPreview: M = !1,
141
+ autopip: N,
142
+ controlsColor: O,
143
+ interactiveParams: V,
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,
150
+ autoplay: a,
151
+ autopause: r,
152
+ showControls: s,
153
+ controlsColor: O,
154
+ doNotTrack: n,
155
+ interactiveParams: V,
156
+ keyboard: m,
157
+ loop: f,
158
+ muted: c,
159
+ pip: l,
160
+ playsinline: u,
161
+ quality: d,
162
+ responsive: k,
163
+ speed: E,
164
+ texttrack: F,
165
+ showTitle: _,
166
+ transparent: j,
167
+ showPortrait: h,
168
+ autopip: N
169
+ });
170
+ return /* @__PURE__ */ i(
171
+ Y.Provider,
172
+ {
173
+ value: {
174
+ status: P,
175
+ previewImageUrl: I,
176
+ onInitPlayer() {
177
+ R !== "canvas" && C("loading");
178
+ }
179
+ },
180
+ children: /* @__PURE__ */ i(
181
+ "div",
182
+ {
183
+ ...g,
184
+ ref: (x) => {
185
+ p !== null && (typeof p == "function" ? p(x) : p.current = x);
186
+ },
187
+ children: b === void 0 ? /* @__PURE__ */ i(ee, {}) : /* @__PURE__ */ B(D, { children: [
188
+ $,
189
+ /* @__PURE__ */ i(
190
+ te,
191
+ {
192
+ title: g.title,
193
+ autoplay: a,
194
+ playsinline: u,
195
+ videoUrl: b,
196
+ previewImageUrl: I,
197
+ loading: e,
198
+ showPreview: M,
199
+ renderer: R,
200
+ status: P,
201
+ onStatusChange: C,
202
+ onPreviewImageUrlChange: A
203
+ }
204
+ )
205
+ ] })
206
+ }
207
+ )
208
+ }
209
+ );
210
+ }
211
+ );
212
+ re.displayName = "Vimeo";
213
+ export {
214
+ re as Vimeo
215
+ };
@@ -0,0 +1,94 @@
1
+ import { jsxs as o, jsx as e } from "react/jsx-runtime";
2
+ import { SpinnerIcon as r, PlayIcon as n } from "@webstudio-is/icons/svg";
3
+ import { $ as t, css as i, ws as a } from "@webstudio-is/template";
4
+ const d = {
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__ */ o(
9
+ t.Vimeo,
10
+ {
11
+ "ws:style": i`
12
+ position: relative;
13
+ aspect-ratio: 640/360;
14
+ width: 100%;
15
+ `,
16
+ children: [
17
+ /* @__PURE__ */ e(
18
+ t.VimeoPreviewImage,
19
+ {
20
+ "ws:style": i`
21
+ position: absolute;
22
+ object-fit: cover;
23
+ object-position: center;
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__ */ e(
34
+ t.VimeoSpinner,
35
+ {
36
+ "ws:label": "Spinner",
37
+ "ws:style": i`
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__ */ e(t.HtmlEmbed, { "ws:label": "Spinner SVG", code: r })
47
+ }
48
+ ),
49
+ /* @__PURE__ */ e(
50
+ t.VimeoPlayButton,
51
+ {
52
+ "ws:style": i`
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__ */ e(
74
+ a.element,
75
+ {
76
+ "ws:tag": "div",
77
+ "ws:label": "Play Icon",
78
+ "ws:style": i`
79
+ width: 60px;
80
+ height: 60px;
81
+ `,
82
+ "aria-hidden": !0,
83
+ children: /* @__PURE__ */ e(t.HtmlEmbed, { "ws:label": "Play SVG", code: n })
84
+ }
85
+ )
86
+ }
87
+ )
88
+ ]
89
+ }
90
+ )
91
+ };
92
+ export {
93
+ d as meta
94
+ };