@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,35 @@
1
+ import { VimeoIcon as o } from "@webstudio-is/icons/svg";
2
+ import { div as e } from "@webstudio-is/sdk/normalize.css";
3
+ import { props as t } from "./__generated__/vimeo.props.js";
4
+ const i = [
5
+ "id",
6
+ "className",
7
+ "url",
8
+ "title",
9
+ "quality",
10
+ "loading",
11
+ "showPreview",
12
+ "autoplay",
13
+ "doNotTrack",
14
+ "loop",
15
+ "muted",
16
+ "showPortrait",
17
+ "showByline",
18
+ "showTitle",
19
+ "showControls",
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
32
+ };
33
+ export {
34
+ s as meta
35
+ };
@@ -0,0 +1,9 @@
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { forwardRef as e } from "react";
3
+ const i = e(
4
+ ({ children: o, state: a = "initial", ...r }, m) => /* @__PURE__ */ t("form", { ...r, ref: m, children: o })
5
+ );
6
+ i.displayName = "WebhookForm";
7
+ export {
8
+ i as WebhookForm
9
+ };
@@ -0,0 +1,88 @@
1
+ import { jsxs as o, jsx as t } from "react/jsx-runtime";
2
+ import { $ as r, ActionValue as i, ws as e, PlaceholderValue as a, css as n, Variable as w, expression as l } from "@webstudio-is/template";
3
+ const s = new w("formState", "initial"), d = {
4
+ category: "data",
5
+ order: 1,
6
+ description: "Collect user data and send it to any webhook.",
7
+ template: /* @__PURE__ */ o(
8
+ r.Form,
9
+ {
10
+ state: l`${s}`,
11
+ onStateChange: new i(["state"], l`${s} = state`),
12
+ children: [
13
+ /* @__PURE__ */ o(
14
+ e.element,
15
+ {
16
+ "ws:tag": "div",
17
+ "ws:label": "Form Content",
18
+ "ws:show": l`${s} === 'initial' || ${s} === 'error'`,
19
+ children: [
20
+ /* @__PURE__ */ t(
21
+ e.element,
22
+ {
23
+ "ws:tag": "label",
24
+ "ws:style": n`
25
+ display: block;
26
+ `,
27
+ children: new a("Name")
28
+ }
29
+ ),
30
+ /* @__PURE__ */ t(
31
+ e.element,
32
+ {
33
+ "ws:tag": "input",
34
+ "ws:style": n`
35
+ display: block;
36
+ `,
37
+ name: "name"
38
+ }
39
+ ),
40
+ /* @__PURE__ */ t(
41
+ e.element,
42
+ {
43
+ "ws:tag": "label",
44
+ "ws:style": n`
45
+ display: block;
46
+ `,
47
+ children: new a("Email")
48
+ }
49
+ ),
50
+ /* @__PURE__ */ t(
51
+ e.element,
52
+ {
53
+ "ws:tag": "input",
54
+ "ws:style": n`
55
+ display: block;
56
+ `,
57
+ name: "email"
58
+ }
59
+ ),
60
+ /* @__PURE__ */ t(e.element, { "ws:tag": "button", children: new a("Submit") })
61
+ ]
62
+ }
63
+ ),
64
+ /* @__PURE__ */ t(
65
+ e.element,
66
+ {
67
+ "ws:tag": "div",
68
+ "ws:label": "Success Message",
69
+ "ws:show": l`${s} === 'success'`,
70
+ children: new a("Thank you for getting in touch!")
71
+ }
72
+ ),
73
+ /* @__PURE__ */ t(
74
+ e.element,
75
+ {
76
+ "ws:tag": "div",
77
+ "ws:label": "Error Message",
78
+ "ws:show": l`${s} === 'error'`,
79
+ children: new a("Sorry, something went wrong.")
80
+ }
81
+ )
82
+ ]
83
+ }
84
+ )
85
+ };
86
+ export {
87
+ d as meta
88
+ };
@@ -0,0 +1,27 @@
1
+ import { WebhookFormIcon as o } from "@webstudio-is/icons/svg";
2
+ import { form as e } from "@webstudio-is/sdk/normalize.css";
3
+ import { props as r } from "./__generated__/webhook-form.props.js";
4
+ const c = {
5
+ label: "Webhook Form",
6
+ icon: o,
7
+ presetStyle: {
8
+ form: e
9
+ },
10
+ states: [
11
+ { selector: "[data-state=error]", label: "Error" },
12
+ { selector: "[data-state=success]", label: "Success" }
13
+ ],
14
+ initialProps: ["id", "class", "state", "action"],
15
+ props: {
16
+ ...r,
17
+ action: {
18
+ type: "resource",
19
+ control: "resource",
20
+ description: "The URI of a program that processes the information submitted via the form.",
21
+ required: !1
22
+ }
23
+ }
24
+ };
25
+ export {
26
+ c as meta
27
+ };
@@ -0,0 +1,61 @@
1
+ import { jsxs as r, jsx as t, Fragment as u } from "react/jsx-runtime";
2
+ import { ReactSdkContext as g, xmlNodeTagSuffix as x } from "@webstudio-is/react-sdk/runtime";
3
+ import { forwardRef as b, useContext as C, createElement as N, Children as F } from "react";
4
+ const j = b(
5
+ ({ tag: c = "", children: l, ...i }, d) => {
6
+ const { renderer: p } = C(g), o = Object.entries(i).filter(
7
+ ([e]) => e.startsWith("data-") === !1 && e.startsWith("aria-") === !1
8
+ ).filter(([e]) => e.toLowerCase() !== "tabindex").filter(([, e]) => typeof e != "function"), s = c.replace(/^[^\p{L}_]+/u, "").replaceAll(/[^\p{L}\p{N}\-._:]+/gu, "").trim();
9
+ if (p === void 0) {
10
+ const e = Object.fromEntries(o);
11
+ return N(
12
+ `${s}${x}`,
13
+ e,
14
+ l
15
+ );
16
+ }
17
+ const n = F.toArray(l), a = n.length > 0 && n.every((e) => typeof e == "string"), m = (e) => e.map(([f, h], y) => /* @__PURE__ */ r("span", { children: [
18
+ " ",
19
+ /* @__PURE__ */ t("span", { style: { color: "#FF0000" }, children: f }),
20
+ /* @__PURE__ */ t("span", { style: { color: "#000000" }, children: "=" }),
21
+ /* @__PURE__ */ r("span", { style: { color: "#0000FF" }, children: [
22
+ '"',
23
+ h,
24
+ '"'
25
+ ] })
26
+ ] }, y));
27
+ return /* @__PURE__ */ r("div", { ...i, style: { backgroundColor: "rgba(255,255,255,1)" }, children: [
28
+ /* @__PURE__ */ r("span", { children: [
29
+ /* @__PURE__ */ r("span", { style: { color: "#800000" }, children: [
30
+ "<",
31
+ s
32
+ ] }),
33
+ o.length > 0 && m(o),
34
+ n.length === 0 ? /* @__PURE__ */ t("span", { style: { color: "#800000" }, children: "/>" }) : /* @__PURE__ */ t("span", { style: { color: "#800000" }, children: ">" })
35
+ ] }),
36
+ n.length > 0 && /* @__PURE__ */ r(u, { children: [
37
+ /* @__PURE__ */ t(
38
+ "div",
39
+ {
40
+ ref: d,
41
+ style: {
42
+ display: a ? "inline" : "block",
43
+ marginLeft: a ? 0 : "1rem",
44
+ color: "#000000"
45
+ },
46
+ children: l
47
+ }
48
+ ),
49
+ /* @__PURE__ */ r("span", { style: { color: "#800000" }, children: [
50
+ "</",
51
+ s,
52
+ ">"
53
+ ] })
54
+ ] })
55
+ ] });
56
+ }
57
+ );
58
+ j.displayName = "XmlNode";
59
+ export {
60
+ j as XmlNode
61
+ };
@@ -0,0 +1,13 @@
1
+ import { XmlIcon as o } from "@webstudio-is/icons/svg";
2
+ import { props as r } from "./__generated__/xml-node.props.js";
3
+ const m = {
4
+ category: "xml",
5
+ order: 6,
6
+ icon: o,
7
+ description: "XML Node",
8
+ initialProps: ["tag"],
9
+ props: r
10
+ };
11
+ export {
12
+ m as meta
13
+ };
@@ -0,0 +1,25 @@
1
+ import { jsx as f } from "react/jsx-runtime";
2
+ import { forwardRef as m, useContext as a } from "react";
3
+ import { ReactSdkContext as T } from "@webstudio-is/react-sdk/runtime";
4
+ const l = "short", u = "dateTime attribute is not set", N = "", c = (e) => {
5
+ if (e === "")
6
+ return;
7
+ let t = new Date(e);
8
+ if (Number.isNaN(t.getTime()) === !1)
9
+ return t;
10
+ if (/^\d+$/.test(e)) {
11
+ let o = Number(e);
12
+ e.length === 10 && (o *= 1e3), t = new Date(o);
13
+ }
14
+ if (Number.isNaN(t.getTime()) === !1)
15
+ return t;
16
+ }, d = m(
17
+ ({ dateStyle: e = l, datetime: t = u }, o) => {
18
+ const { renderer: i } = a(T), s = t === null ? N : t.toString(), n = c(s);
19
+ let r = s;
20
+ return n && (r = n.toISOString(), e === "short" && (r = r.split("T")[0])), i === void 0 ? r : /* @__PURE__ */ f("time", { ref: o, children: r });
21
+ }
22
+ );
23
+ export {
24
+ d as XmlTime
25
+ };
@@ -0,0 +1,13 @@
1
+ import { CalendarIcon as t } from "@webstudio-is/icons/svg";
2
+ import { props as e } from "./__generated__/xml-time.props.js";
3
+ const a = {
4
+ category: "xml",
5
+ description: "Converts machine-readable date and time to ISO format.",
6
+ icon: t,
7
+ order: 7,
8
+ initialProps: ["datetime", "dateStyle"],
9
+ props: e
10
+ };
11
+ export {
12
+ a as meta
13
+ };
package/lib/youtube.js ADDED
@@ -0,0 +1,227 @@
1
+ import { jsx as u, jsxs as E, Fragment as O } from "react/jsx-runtime";
2
+ import { forwardRef as x, useState as p, useContext as S, useRef as T, useEffect as y } from "react";
3
+ import { ReactSdkContext as A } from "@webstudio-is/react-sdk/runtime";
4
+ import { VideoContext as N, requestFullscreen as P } from "./shared/video.js";
5
+ const U = "https://www.youtube-nocookie.com", V = "https://www.youtube.com", j = "https://img.youtube.com", L = (e) => {
6
+ if (e)
7
+ try {
8
+ const t = new URL(e);
9
+ return t.pathname === "/embed" ? void 0 : t.hostname === "youtu.be" ? t.pathname.slice(1) : t.searchParams.get("v") || t.pathname.split("/").pop();
10
+ } catch {
11
+ return e;
12
+ }
13
+ }, D = (e, t) => {
14
+ var o, n;
15
+ const s = L(e.url), r = new URL(t);
16
+ if (s)
17
+ r.pathname = `/embed/${s}`;
18
+ else if (e.url)
19
+ try {
20
+ const c = new URL(e.url);
21
+ r.pathname = c.pathname, r.search = c.search;
22
+ } catch {
23
+ }
24
+ const i = Object.keys(e), a = {};
25
+ a.autoplay = "1";
26
+ for (const c of i)
27
+ if (e[c] !== void 0)
28
+ switch (c) {
29
+ case "autoplay":
30
+ e.autoplay && e.muted === void 0 && (a.mute = "1");
31
+ break;
32
+ case "muted":
33
+ a.mute = e.muted ? "1" : "0";
34
+ break;
35
+ case "showControls":
36
+ a.controls = e.showControls ? "1" : "0";
37
+ break;
38
+ case "showRelatedVideos":
39
+ a.rel = e.showRelatedVideos ? "1" : "0";
40
+ break;
41
+ case "keyboard":
42
+ a.keyboard = e.keyboard ? "1" : "0";
43
+ break;
44
+ case "loop":
45
+ a.loop = e.loop ? "1" : "0", e.loop && (e.playlist ?? "").trim() === "" && (a.playlist = s);
46
+ break;
47
+ case "inline":
48
+ a.playsinline = e.inline ? "1" : "0";
49
+ break;
50
+ case "allowFullscreen":
51
+ a.fs = e.allowFullscreen ? "1" : "0";
52
+ break;
53
+ case "captionLanguage":
54
+ a.cc_lang_pref = e.captionLanguage;
55
+ break;
56
+ case "showCaptions":
57
+ a.cc_load_policy = e.showCaptions ? "1" : "0";
58
+ break;
59
+ case "showAnnotations":
60
+ a.iv_load_policy = e.showAnnotations ? "1" : "3";
61
+ break;
62
+ case "startTime":
63
+ a.start = (o = e.startTime) == null ? void 0 : o.toString();
64
+ break;
65
+ case "endTime":
66
+ a.end = (n = e.endTime) == null ? void 0 : n.toString();
67
+ break;
68
+ case "disableKeyboard":
69
+ a.disablekb = e.disableKeyboard ? "1" : "0";
70
+ break;
71
+ case "language":
72
+ a.hl = e.language;
73
+ break;
74
+ case "listId":
75
+ a.list = e.listId;
76
+ break;
77
+ case "listType":
78
+ a.listType = e.listType;
79
+ break;
80
+ case "color":
81
+ a.color = e.color;
82
+ break;
83
+ case "origin":
84
+ a.origin = e.origin;
85
+ break;
86
+ case "referrer":
87
+ a.widget_referrer = e.referrer;
88
+ break;
89
+ case "playlist":
90
+ a.playlist = e.playlist;
91
+ break;
92
+ case "enablejsapi":
93
+ a.enablejsapi = e.enablejsapi ? "1" : "0";
94
+ break;
95
+ }
96
+ return Object.entries(a).forEach(([c, l]) => {
97
+ l !== void 0 && r.searchParams.append(c, l.toString());
98
+ }), r.toString();
99
+ }, R = (e) => {
100
+ const t = document.createElement("link");
101
+ t.rel = "preconnect", t.href = e, t.crossOrigin = "true", document.head.appendChild(t);
102
+ };
103
+ let _ = !1;
104
+ const F = (e) => {
105
+ if (!(_ || window.matchMedia("(hover: none)").matches)) {
106
+ try {
107
+ const t = new URL(e);
108
+ R(t.origin);
109
+ } catch {
110
+ }
111
+ R(j), _ = !0;
112
+ }
113
+ }, Y = (e) => new URL(`${j}/vi/${e}/maxresdefault.jpg`), K = () => /* @__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' }), M = ({
114
+ title: e,
115
+ status: t,
116
+ loading: s,
117
+ videoUrl: r,
118
+ previewImageUrl: i,
119
+ autoplay: a,
120
+ inline: o,
121
+ renderer: n,
122
+ showPreview: c,
123
+ onStatusChange: l,
124
+ onPreviewImageUrlChange: d
125
+ }) => {
126
+ const [h, m] = p(0), b = T(null);
127
+ return y(() => {
128
+ a && n !== "canvas" && t === "initial" && l("loading");
129
+ }, [a, t, n, l]), y(() => {
130
+ n !== "canvas" && F(r);
131
+ }, [n, r]), y(() => {
132
+ const f = L(r);
133
+ if (!f || !c) {
134
+ d(void 0);
135
+ return;
136
+ }
137
+ i || d(Y(f));
138
+ }, [d, c, r, i]), n === "canvas" || t === "initial" ? null : /* @__PURE__ */ u(
139
+ "iframe",
140
+ {
141
+ ref: b,
142
+ title: e,
143
+ src: r,
144
+ loading: s,
145
+ allow: "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",
146
+ allowFullScreen: !0,
147
+ style: {
148
+ position: "absolute",
149
+ width: "100%",
150
+ height: "100%",
151
+ opacity: h,
152
+ transition: "opacity 1s",
153
+ border: "none"
154
+ },
155
+ onLoad: () => {
156
+ l("ready"), m(1), !o && !a && b.current && P(b.current);
157
+ }
158
+ }
159
+ );
160
+ }, $ = x(
161
+ ({
162
+ url: e,
163
+ loading: t = "lazy",
164
+ autoplay: s,
165
+ showPreview: r,
166
+ showAnnotations: i,
167
+ showCaptions: a,
168
+ showControls: o,
169
+ allowFullscreen: n,
170
+ keyboard: c,
171
+ children: l,
172
+ privacyEnhancedMode: d,
173
+ inline: h = !1,
174
+ ...m
175
+ }, b) => {
176
+ const [f, g] = p("initial"), [w, C] = p(), { renderer: k } = S(A), I = d ?? !0 ? U : V, v = D(
177
+ {
178
+ ...m,
179
+ inline: h,
180
+ url: e,
181
+ keyboard: c,
182
+ showAnnotations: i,
183
+ showCaptions: a,
184
+ allowFullscreen: n,
185
+ showControls: o,
186
+ autoplay: s,
187
+ enablejsapi: !1
188
+ },
189
+ I
190
+ );
191
+ return /* @__PURE__ */ u(
192
+ N.Provider,
193
+ {
194
+ value: {
195
+ status: f,
196
+ previewImageUrl: w,
197
+ onInitPlayer() {
198
+ k !== "canvas" && g("loading");
199
+ }
200
+ },
201
+ children: /* @__PURE__ */ u("div", { ...m, ref: b, children: v ? /* @__PURE__ */ E(O, { children: [
202
+ l,
203
+ /* @__PURE__ */ u(
204
+ M,
205
+ {
206
+ title: m.title,
207
+ autoplay: s,
208
+ videoUrl: v,
209
+ previewImageUrl: w,
210
+ loading: t,
211
+ inline: h,
212
+ showPreview: r,
213
+ renderer: k,
214
+ status: f,
215
+ onStatusChange: g,
216
+ onPreviewImageUrlChange: C
217
+ }
218
+ )
219
+ ] }) : /* @__PURE__ */ u(K, {}) })
220
+ }
221
+ );
222
+ }
223
+ );
224
+ $.displayName = "YouTube";
225
+ export {
226
+ $ as YouTube
227
+ };
@@ -0,0 +1,98 @@
1
+ import { jsxs as i, jsx as e } from "react/jsx-runtime";
2
+ import { SpinnerIcon as r, PlayIcon as l } from "@webstudio-is/icons/svg";
3
+ import { $ as t, css as o, ws as a } from "@webstudio-is/template";
4
+ const d = {
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
+ t.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__ */ e(
20
+ t.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__ */ e(
37
+ t.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__ */ e(t.HtmlEmbed, { "ws:label": "Spinner SVG", code: r })
50
+ }
51
+ ),
52
+ /* @__PURE__ */ e(
53
+ t.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__ */ e(
78
+ a.element,
79
+ {
80
+ "ws:tag": "div",
81
+ "ws:label": "Play Icon",
82
+ "ws:style": o`
83
+ width: 60px;
84
+ height: 60px;
85
+ `,
86
+ "aria-hidden": !0,
87
+ children: /* @__PURE__ */ e(t.HtmlEmbed, { "ws:label": "Play SVG", code: l })
88
+ }
89
+ )
90
+ }
91
+ )
92
+ ]
93
+ }
94
+ )
95
+ };
96
+ export {
97
+ d as meta
98
+ };
@@ -0,0 +1,45 @@
1
+ import { YoutubeIcon as e } from "@webstudio-is/icons/svg";
2
+ import { div as o } from "@webstudio-is/sdk/normalize.css";
3
+ import { props as i } from "./__generated__/youtube.props.js";
4
+ const n = [
5
+ "id",
6
+ "className",
7
+ "url",
8
+ "privacyEnhancedMode",
9
+ "title",
10
+ "loading",
11
+ "showPreview",
12
+ "autoplay",
13
+ "showControls",
14
+ "showRelatedVideos",
15
+ "keyboard",
16
+ "loop",
17
+ "inline",
18
+ "allowFullscreen",
19
+ "showCaptions",
20
+ "showAnnotations",
21
+ "startTime",
22
+ "endTime",
23
+ "disableKeyboard",
24
+ "referrer",
25
+ "listType",
26
+ "listId",
27
+ "origin",
28
+ "captionLanguage",
29
+ "language",
30
+ "color",
31
+ "playlist"
32
+ ], s = {
33
+ icon: e,
34
+ contentModel: {
35
+ category: "instance",
36
+ children: ["instance"],
37
+ descendants: ["VimeoSpinner", "VimeoPlayButton", "VimeoPreviewImage"]
38
+ },
39
+ presetStyle: { div: o },
40
+ initialProps: n,
41
+ props: i
42
+ };
43
+ export {
44
+ s as meta
45
+ };