@webstudio-is/sdk-components-react 0.0.1-c87cdba.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 (280) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +3 -0
  3. package/lib/__generated__/blockquote.props.js +514 -0
  4. package/lib/__generated__/body.props.js +508 -0
  5. package/lib/__generated__/bold.props.js +508 -0
  6. package/lib/__generated__/box.props.js +527 -0
  7. package/lib/__generated__/button.props.js +570 -0
  8. package/lib/__generated__/checkbox.props.js +672 -0
  9. package/lib/__generated__/code-text.props.js +509 -0
  10. package/lib/__generated__/form.props.js +556 -0
  11. package/lib/__generated__/heading.props.js +516 -0
  12. package/lib/__generated__/html-embed.props.js +13 -0
  13. package/lib/__generated__/image.props.js +593 -0
  14. package/lib/__generated__/input.props.js +696 -0
  15. package/lib/__generated__/italic.props.js +508 -0
  16. package/lib/__generated__/label.props.js +520 -0
  17. package/lib/__generated__/link.props.js +578 -0
  18. package/lib/__generated__/list-item.props.js +514 -0
  19. package/lib/__generated__/list.props.js +534 -0
  20. package/lib/__generated__/markdown-embed.props.js +7 -0
  21. package/lib/__generated__/option.props.js +532 -0
  22. package/lib/__generated__/paragraph.props.js +508 -0
  23. package/lib/__generated__/radio-button.props.js +672 -0
  24. package/lib/__generated__/select.props.js +556 -0
  25. package/lib/__generated__/separator.props.js +508 -0
  26. package/lib/__generated__/span.props.js +508 -0
  27. package/lib/__generated__/subscript.props.js +508 -0
  28. package/lib/__generated__/superscript.props.js +508 -0
  29. package/lib/__generated__/text.props.js +516 -0
  30. package/lib/__generated__/textarea.props.js +587 -0
  31. package/lib/__generated__/time.props.js +312 -0
  32. package/lib/__generated__/vimeo-play-button.props.js +569 -0
  33. package/lib/__generated__/vimeo-preview-image.props.js +591 -0
  34. package/lib/__generated__/vimeo-spinner.props.js +508 -0
  35. package/lib/__generated__/vimeo.props.js +673 -0
  36. package/lib/__generated__/webhook-form.props.js +569 -0
  37. package/lib/__generated__/xml-node.props.js +21 -0
  38. package/lib/__generated__/xml-time.props.js +18 -0
  39. package/lib/blockquote.js +9 -0
  40. package/lib/blockquote.template.js +11 -0
  41. package/lib/blockquote.ws.js +63 -0
  42. package/lib/body.js +7 -0
  43. package/lib/body.ws.js +29 -0
  44. package/lib/bold.js +7 -0
  45. package/lib/bold.ws.js +20 -0
  46. package/lib/box.js +9 -0
  47. package/lib/box.ws.js +31 -0
  48. package/lib/button.js +9 -0
  49. package/lib/button.template.js +11 -0
  50. package/lib/button.ws.js +27 -0
  51. package/lib/checkbox.js +15 -0
  52. package/lib/checkbox.template.js +14 -0
  53. package/lib/checkbox.ws.js +38 -0
  54. package/lib/code-text.js +10 -0
  55. package/lib/code-text.ws.js +59 -0
  56. package/lib/components.js +79 -0
  57. package/lib/content-embed.template.js +83 -0
  58. package/lib/form.js +7 -0
  59. package/lib/form.ws.js +30 -0
  60. package/lib/fragment.js +7 -0
  61. package/lib/fragment.ws.js +11 -0
  62. package/lib/heading.js +9 -0
  63. package/lib/heading.template.js +11 -0
  64. package/lib/heading.ws.js +28 -0
  65. package/lib/home_wsKvRSqvkajPPBeycZ-C8.svg +3 -0
  66. package/lib/hooks.js +5 -0
  67. package/lib/html-embed-patchers.js +29 -0
  68. package/lib/html-embed.js +112 -0
  69. package/lib/html-embed.ws.js +46 -0
  70. package/lib/image.js +38 -0
  71. package/lib/image.ws.js +60 -0
  72. package/lib/input.js +17 -0
  73. package/lib/input.ws.js +54 -0
  74. package/lib/italic.js +7 -0
  75. package/lib/italic.ws.js +26 -0
  76. package/lib/label.js +7 -0
  77. package/lib/label.template.js +10 -0
  78. package/lib/label.ws.js +27 -0
  79. package/lib/link.js +15 -0
  80. package/lib/link.template.js +11 -0
  81. package/lib/link.ws.js +47 -0
  82. package/lib/list-item.js +9 -0
  83. package/lib/list-item.template.js +11 -0
  84. package/lib/list-item.ws.js +26 -0
  85. package/lib/list.js +6 -0
  86. package/lib/list.template.js +15 -0
  87. package/lib/list.ws.js +48 -0
  88. package/lib/markdown-embed.js +19 -0
  89. package/lib/markdown-embed.template.js +75 -0
  90. package/lib/markdown-embed.ws.js +33 -0
  91. package/lib/metas.js +80 -0
  92. package/lib/option.js +7 -0
  93. package/lib/option.ws.js +45 -0
  94. package/lib/paragraph.js +7 -0
  95. package/lib/paragraph.template.js +11 -0
  96. package/lib/paragraph.ws.js +23 -0
  97. package/lib/props.js +80 -0
  98. package/lib/radio-button.js +15 -0
  99. package/lib/radio-button.template.js +14 -0
  100. package/lib/radio-button.ws.js +40 -0
  101. package/lib/rich-text-link.ws.js +9 -0
  102. package/lib/select.js +19 -0
  103. package/lib/select.template.js +16 -0
  104. package/lib/select.ws.js +44 -0
  105. package/lib/separator.js +9 -0
  106. package/lib/separator.ws.js +48 -0
  107. package/lib/slot.js +14 -0
  108. package/lib/slot.ws.js +15 -0
  109. package/lib/span.js +7 -0
  110. package/lib/span.ws.js +20 -0
  111. package/lib/subscript.js +7 -0
  112. package/lib/subscript.ws.js +20 -0
  113. package/lib/superscript.js +7 -0
  114. package/lib/superscript.ws.js +20 -0
  115. package/lib/templates.js +32 -0
  116. package/lib/text.js +10 -0
  117. package/lib/text.template.js +11 -0
  118. package/lib/text.ws.js +25 -0
  119. package/lib/textarea.js +7 -0
  120. package/lib/textarea.ws.js +55 -0
  121. package/lib/time.js +319 -0
  122. package/lib/time.ws.js +21 -0
  123. package/lib/types/__generated__/blockquote.props.d.ts +2 -0
  124. package/lib/types/__generated__/body.props.d.ts +2 -0
  125. package/lib/types/__generated__/bold.props.d.ts +2 -0
  126. package/lib/types/__generated__/box.props.d.ts +2 -0
  127. package/lib/types/__generated__/button.props.d.ts +2 -0
  128. package/lib/types/__generated__/checkbox.props.d.ts +2 -0
  129. package/lib/types/__generated__/code-text.props.d.ts +2 -0
  130. package/lib/types/__generated__/form.props.d.ts +2 -0
  131. package/lib/types/__generated__/fragment.props.d.ts +2 -0
  132. package/lib/types/__generated__/heading.props.d.ts +2 -0
  133. package/lib/types/__generated__/html-embed.props.d.ts +2 -0
  134. package/lib/types/__generated__/image.props.d.ts +2 -0
  135. package/lib/types/__generated__/input.props.d.ts +2 -0
  136. package/lib/types/__generated__/italic.props.d.ts +2 -0
  137. package/lib/types/__generated__/label.props.d.ts +2 -0
  138. package/lib/types/__generated__/link.props.d.ts +2 -0
  139. package/lib/types/__generated__/list-item.props.d.ts +2 -0
  140. package/lib/types/__generated__/list.props.d.ts +2 -0
  141. package/lib/types/__generated__/local-date.props.d.ts +2 -0
  142. package/lib/types/__generated__/markdown-embed.props.d.ts +2 -0
  143. package/lib/types/__generated__/option.props.d.ts +2 -0
  144. package/lib/types/__generated__/paragraph.props.d.ts +2 -0
  145. package/lib/types/__generated__/radio-button.props.d.ts +2 -0
  146. package/lib/types/__generated__/rich-text-link.props.d.ts +2 -0
  147. package/lib/types/__generated__/select.props.d.ts +2 -0
  148. package/lib/types/__generated__/separator.props.d.ts +2 -0
  149. package/lib/types/__generated__/slot.props.d.ts +2 -0
  150. package/lib/types/__generated__/span.props.d.ts +2 -0
  151. package/lib/types/__generated__/subscript.props.d.ts +2 -0
  152. package/lib/types/__generated__/superscript.props.d.ts +2 -0
  153. package/lib/types/__generated__/text.props.d.ts +2 -0
  154. package/lib/types/__generated__/textarea.props.d.ts +2 -0
  155. package/lib/types/__generated__/time.props.d.ts +2 -0
  156. package/lib/types/__generated__/vimeo-play-button.props.d.ts +2 -0
  157. package/lib/types/__generated__/vimeo-preview-image.props.d.ts +2 -0
  158. package/lib/types/__generated__/vimeo-spinner.props.d.ts +2 -0
  159. package/lib/types/__generated__/vimeo.props.d.ts +2 -0
  160. package/lib/types/__generated__/webhook-form.props.d.ts +2 -0
  161. package/lib/types/__generated__/xml-node.props.d.ts +2 -0
  162. package/lib/types/__generated__/xml-time.props.d.ts +2 -0
  163. package/lib/types/blockquote.d.ts +2 -0
  164. package/lib/types/blockquote.template.d.ts +2 -0
  165. package/lib/types/blockquote.ws.d.ts +3 -0
  166. package/lib/types/body.d.ts +2 -0
  167. package/lib/types/body.ws.d.ts +3 -0
  168. package/lib/types/bold.d.ts +2 -0
  169. package/lib/types/bold.ws.d.ts +3 -0
  170. package/lib/types/box.d.ts +8 -0
  171. package/lib/types/box.ws.d.ts +3 -0
  172. package/lib/types/button.d.ts +2 -0
  173. package/lib/types/button.template.d.ts +2 -0
  174. package/lib/types/button.ws.d.ts +3 -0
  175. package/lib/types/checkbox.d.ts +4 -0
  176. package/lib/types/checkbox.template.d.ts +2 -0
  177. package/lib/types/checkbox.ws.d.ts +3 -0
  178. package/lib/types/code-text.d.ts +4 -0
  179. package/lib/types/code-text.ws.d.ts +3 -0
  180. package/lib/types/components.d.ts +39 -0
  181. package/lib/types/content-embed.template.d.ts +2 -0
  182. package/lib/types/form.d.ts +2 -0
  183. package/lib/types/form.ws.d.ts +3 -0
  184. package/lib/types/fragment.d.ts +6 -0
  185. package/lib/types/fragment.ws.d.ts +3 -0
  186. package/lib/types/heading.d.ts +8 -0
  187. package/lib/types/heading.template.d.ts +2 -0
  188. package/lib/types/heading.ws.d.ts +3 -0
  189. package/lib/types/hooks.d.ts +2 -0
  190. package/lib/types/html-embed-patchers.d.ts +2 -0
  191. package/lib/types/html-embed.d.ts +12 -0
  192. package/lib/types/html-embed.test.d.ts +1 -0
  193. package/lib/types/html-embed.ws.d.ts +3 -0
  194. package/lib/types/image.d.ts +8 -0
  195. package/lib/types/image.ws.d.ts +3 -0
  196. package/lib/types/input.d.ts +4 -0
  197. package/lib/types/input.ws.d.ts +3 -0
  198. package/lib/types/italic.d.ts +2 -0
  199. package/lib/types/italic.ws.d.ts +3 -0
  200. package/lib/types/label.d.ts +2 -0
  201. package/lib/types/label.template.d.ts +2 -0
  202. package/lib/types/label.ws.d.ts +3 -0
  203. package/lib/types/link.d.ts +11 -0
  204. package/lib/types/link.template.d.ts +2 -0
  205. package/lib/types/link.ws.d.ts +3 -0
  206. package/lib/types/list-item.d.ts +2 -0
  207. package/lib/types/list-item.template.d.ts +2 -0
  208. package/lib/types/list-item.ws.d.ts +3 -0
  209. package/lib/types/list.d.ts +10 -0
  210. package/lib/types/list.template.d.ts +2 -0
  211. package/lib/types/list.ws.d.ts +3 -0
  212. package/lib/types/markdown-embed.d.ts +7 -0
  213. package/lib/types/markdown-embed.template.d.ts +2 -0
  214. package/lib/types/markdown-embed.ws.d.ts +3 -0
  215. package/lib/types/metas.d.ts +39 -0
  216. package/lib/types/option.d.ts +2 -0
  217. package/lib/types/option.ws.d.ts +3 -0
  218. package/lib/types/paragraph.d.ts +2 -0
  219. package/lib/types/paragraph.template.d.ts +2 -0
  220. package/lib/types/paragraph.ws.d.ts +3 -0
  221. package/lib/types/props.d.ts +39 -0
  222. package/lib/types/radio-button.d.ts +4 -0
  223. package/lib/types/radio-button.template.d.ts +2 -0
  224. package/lib/types/radio-button.ws.d.ts +3 -0
  225. package/lib/types/rich-text-link.d.ts +1 -0
  226. package/lib/types/rich-text-link.ws.d.ts +3 -0
  227. package/lib/types/select.d.ts +4 -0
  228. package/lib/types/select.template.d.ts +2 -0
  229. package/lib/types/select.ws.d.ts +3 -0
  230. package/lib/types/separator.d.ts +2 -0
  231. package/lib/types/separator.ws.d.ts +3 -0
  232. package/lib/types/slot.d.ts +6 -0
  233. package/lib/types/slot.ws.d.ts +3 -0
  234. package/lib/types/span.d.ts +2 -0
  235. package/lib/types/span.ws.d.ts +3 -0
  236. package/lib/types/subscript.d.ts +2 -0
  237. package/lib/types/subscript.ws.d.ts +3 -0
  238. package/lib/types/superscript.d.ts +2 -0
  239. package/lib/types/superscript.ws.d.ts +3 -0
  240. package/lib/types/templates.d.ts +15 -0
  241. package/lib/types/test-utils/cartesian.d.ts +2 -0
  242. package/lib/types/text.d.ts +8 -0
  243. package/lib/types/text.template.d.ts +2 -0
  244. package/lib/types/text.ws.d.ts +3 -0
  245. package/lib/types/textarea.d.ts +2 -0
  246. package/lib/types/textarea.ws.d.ts +3 -0
  247. package/lib/types/time.d.ts +18 -0
  248. package/lib/types/time.test.d.ts +1 -0
  249. package/lib/types/time.ws.d.ts +3 -0
  250. package/lib/types/vimeo-play-button.d.ts +3 -0
  251. package/lib/types/vimeo-play-button.ws.d.ts +3 -0
  252. package/lib/types/vimeo-preview-image.d.ts +284 -0
  253. package/lib/types/vimeo-preview-image.ws.d.ts +3 -0
  254. package/lib/types/vimeo-spinner.d.ts +1 -0
  255. package/lib/types/vimeo-spinner.ws.d.ts +3 -0
  256. package/lib/types/vimeo.d.ts +75 -0
  257. package/lib/types/vimeo.template.d.ts +2 -0
  258. package/lib/types/vimeo.ws.d.ts +3 -0
  259. package/lib/types/webhook-form.d.ts +8 -0
  260. package/lib/types/webhook-form.ws.d.ts +3 -0
  261. package/lib/types/xml-node.d.ts +13 -0
  262. package/lib/types/xml-node.ws.d.ts +3 -0
  263. package/lib/types/xml-time.d.ts +6 -0
  264. package/lib/types/xml-time.ws.d.ts +3 -0
  265. package/lib/vimeo-play-button.js +18 -0
  266. package/lib/vimeo-play-button.ws.js +31 -0
  267. package/lib/vimeo-preview-image.js +19 -0
  268. package/lib/vimeo-preview-image.ws.js +28 -0
  269. package/lib/vimeo-spinner.js +13 -0
  270. package/lib/vimeo-spinner.ws.js +25 -0
  271. package/lib/vimeo.js +213 -0
  272. package/lib/vimeo.template.js +92 -0
  273. package/lib/vimeo.ws.js +39 -0
  274. package/lib/webhook-form.js +9 -0
  275. package/lib/webhook-form.ws.js +127 -0
  276. package/lib/xml-node.js +44 -0
  277. package/lib/xml-node.ws.js +18 -0
  278. package/lib/xml-time.js +25 -0
  279. package/lib/xml-time.ws.js +18 -0
  280. package/package.json +75 -0
@@ -0,0 +1,25 @@
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";
5
+ const n = {
6
+ div: e
7
+ }, m = {
8
+ type: "container",
9
+ constraints: {
10
+ relation: "ancestor",
11
+ component: { $eq: "Vimeo" }
12
+ },
13
+ icon: r,
14
+ states: o,
15
+ presetStyle: n,
16
+ category: "hidden",
17
+ label: "Spinner"
18
+ }, c = {
19
+ props: t,
20
+ initialProps: ["id", "className"]
21
+ };
22
+ export {
23
+ m as meta,
24
+ c as propsMeta
25
+ };
package/lib/vimeo.js ADDED
@@ -0,0 +1,213 @@
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 h, useContext as G, useEffect as u } from "react";
4
+ import { ReactSdkContext as H } from "@webstudio-is/react-sdk/runtime";
5
+ const Y = (e) => {
6
+ if (e.url === void 0)
7
+ return;
8
+ let t;
9
+ try {
10
+ const o = new URL(e.url);
11
+ t = new URL(x), t.pathname = `/video${o.pathname}`;
12
+ } catch {
13
+ }
14
+ if (t === void 0)
15
+ return;
16
+ const r = {
17
+ showPortrait: "portrait",
18
+ showByline: "byline",
19
+ showTitle: "title",
20
+ controlsColor: "color",
21
+ showControls: "controls",
22
+ interactiveParams: "interactive_params",
23
+ backgroundMode: "background",
24
+ doNotTrack: "dnt"
25
+ };
26
+ let n;
27
+ for (n in e) {
28
+ const o = e[n];
29
+ if (n === "url" || o === void 0)
30
+ continue;
31
+ const a = r[n] ?? n;
32
+ t.searchParams.append(a, o.toString());
33
+ }
34
+ if (t.searchParams.set("autoplay", "true"), typeof e.controlsColor == "string") {
35
+ const o = z(e.controlsColor).toHex().replace("#", "");
36
+ t.searchParams.set("color", o);
37
+ }
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) => {
40
+ const t = document.createElement("link");
41
+ t.rel = "preconnect", t.href = e, t.crossOrigin = "true", document.head.appendChild(t);
42
+ };
43
+ let I = !1;
44
+ const J = "https://f.vimeocdn.com", x = "https://player.vimeo.com", b = "https://i.vimeocdn.com", K = () => {
45
+ I || window.matchMedia("(hover: none)").matches || (f(J), f(x), f(b), I = !0);
46
+ }, Q = (e) => {
47
+ try {
48
+ const r = new URL(e).pathname.split("/")[2];
49
+ return r === "" || r == null ? void 0 : r;
50
+ } catch {
51
+ }
52
+ }, W = async (e) => {
53
+ const r = `https://vimeo.com/api/v2/video/${Q(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
+ }, X = () => /* @__PURE__ */ s(
56
+ "div",
57
+ {
58
+ style: {
59
+ display: "flex",
60
+ width: "100%",
61
+ height: "100%",
62
+ alignItems: "center",
63
+ justifyContent: "center",
64
+ fontSize: "1.2em"
65
+ },
66
+ children: 'Open the "Settings" panel and paste a video URL, e.g. https://vimeo.com/831343124.'
67
+ }
68
+ ), Z = ({
69
+ status: e,
70
+ loading: t,
71
+ videoUrl: r,
72
+ previewImageUrl: n,
73
+ autoplay: o,
74
+ renderer: a,
75
+ showPreview: i,
76
+ onStatusChange: c,
77
+ onPreviewImageUrlChange: l
78
+ }) => {
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" && K();
84
+ }, [a]), u(() => {
85
+ if (r !== void 0) {
86
+ if (i === !1) {
87
+ l(void 0);
88
+ return;
89
+ }
90
+ n === void 0 && W(r).then(l).catch(() => {
91
+ console.error(`Could not load preview image for ${r}`);
92
+ });
93
+ }
94
+ }, [l, i, r, n]), !(a === "canvas" || e === "initial"))
95
+ return /* @__PURE__ */ s(
96
+ "iframe",
97
+ {
98
+ src: r,
99
+ loading: t,
100
+ allow: "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture;",
101
+ allowFullScreen: !0,
102
+ style: {
103
+ position: "absolute",
104
+ width: "100%",
105
+ height: "100%",
106
+ opacity: m,
107
+ transition: "opacity 1s",
108
+ border: "none"
109
+ },
110
+ onLoad: () => {
111
+ c("ready"), p(1);
112
+ }
113
+ }
114
+ );
115
+ }, tt = T({
116
+ onInitPlayer: () => {
117
+ },
118
+ status: "initial"
119
+ }), et = q(
120
+ ({
121
+ url: e,
122
+ loading: t = "lazy",
123
+ autoplay: r = !1,
124
+ autopause: n = !0,
125
+ showByline: o = !1,
126
+ showControls: a = !0,
127
+ doNotTrack: i = !1,
128
+ keyboard: c = !0,
129
+ loop: l = !1,
130
+ muted: m = !1,
131
+ pip: p = !1,
132
+ playsinline: R = !0,
133
+ showPortrait: U = !0,
134
+ quality: S = "auto",
135
+ responsive: L = !0,
136
+ speed: k = !1,
137
+ showTitle: E = !1,
138
+ transparent: _ = !0,
139
+ showPreview: j = !1,
140
+ autopip: M,
141
+ controlsColor: N,
142
+ interactiveParams: O,
143
+ texttrack: V,
144
+ children: $,
145
+ ...A
146
+ }, d) => {
147
+ const [v, y] = h("initial"), [w, B] = h(), { renderer: g } = G(H), P = Y({
148
+ url: e,
149
+ autoplay: r,
150
+ autopause: n,
151
+ showControls: a,
152
+ controlsColor: N,
153
+ doNotTrack: i,
154
+ interactiveParams: O,
155
+ keyboard: c,
156
+ loop: l,
157
+ muted: m,
158
+ pip: p,
159
+ playsinline: R,
160
+ quality: S,
161
+ responsive: L,
162
+ speed: k,
163
+ texttrack: V,
164
+ showTitle: E,
165
+ transparent: _,
166
+ showPortrait: U,
167
+ autopip: M
168
+ });
169
+ return /* @__PURE__ */ s(
170
+ tt.Provider,
171
+ {
172
+ value: {
173
+ status: v,
174
+ previewImageUrl: w,
175
+ onInitPlayer() {
176
+ g !== "canvas" && y("loading");
177
+ }
178
+ },
179
+ children: /* @__PURE__ */ s(
180
+ "div",
181
+ {
182
+ ...A,
183
+ ref: (C) => {
184
+ d !== null && (typeof d == "function" ? d(C) : d.current = C);
185
+ },
186
+ children: P === void 0 ? /* @__PURE__ */ s(X, {}) : /* @__PURE__ */ D(F, { children: [
187
+ $,
188
+ /* @__PURE__ */ s(
189
+ Z,
190
+ {
191
+ autoplay: r,
192
+ videoUrl: P,
193
+ previewImageUrl: w,
194
+ loading: t,
195
+ showPreview: j,
196
+ renderer: g,
197
+ status: v,
198
+ onStatusChange: y,
199
+ onPreviewImageUrlChange: B
200
+ }
201
+ )
202
+ ] })
203
+ }
204
+ )
205
+ }
206
+ );
207
+ }
208
+ );
209
+ et.displayName = "Vimeo";
210
+ export {
211
+ et as Vimeo,
212
+ tt as VimeoContext
213
+ };
@@ -0,0 +1,92 @@
1
+ import { jsxs as i, jsx as o } from "react/jsx-runtime";
2
+ import { SpinnerIcon as r, PlayIcon as a } from "@webstudio-is/icons/svg";
3
+ import { $ as e, css as t } 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": t`
12
+ position: relative;
13
+ aspect-ratio: 640/360;
14
+ width: 100%;
15
+ `,
16
+ children: [
17
+ /* @__PURE__ */ o(
18
+ e.VimeoPreviewImage,
19
+ {
20
+ "ws:style": t`
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
+ }
31
+ ),
32
+ /* @__PURE__ */ o(
33
+ e.VimeoSpinner,
34
+ {
35
+ "ws:label": "Spinner",
36
+ "ws:style": t`
37
+ position: absolute;
38
+ top: 50%;
39
+ left: 50%;
40
+ width: 70px;
41
+ height: 70px;
42
+ margin-top: -35px;
43
+ margin-left: -35px;
44
+ `,
45
+ children: /* @__PURE__ */ o(e.HtmlEmbed, { "ws:label": "Spinner SVG", code: r })
46
+ }
47
+ ),
48
+ /* @__PURE__ */ o(
49
+ e.VimeoPlayButton,
50
+ {
51
+ "ws:style": t`
52
+ position: absolute;
53
+ width: 140px;
54
+ height: 80px;
55
+ top: 50%;
56
+ left: 50%;
57
+ margin-top: -40px;
58
+ margin-left: -70px;
59
+ display: flex;
60
+ align-items: center;
61
+ justify-content: center;
62
+ border-style: none;
63
+ border-radius: 5px;
64
+ cursor: pointer;
65
+ background-color: rgb(18, 18, 18);
66
+ color: rgb(255, 255, 255);
67
+ &:hover {
68
+ background-color: rgb(0, 173, 239);
69
+ }
70
+ `,
71
+ "aria-label": "Play button",
72
+ children: /* @__PURE__ */ o(
73
+ e.Box,
74
+ {
75
+ "ws:label": "Play Icon",
76
+ "ws:style": t`
77
+ width: 60px;
78
+ height: 60px;
79
+ `,
80
+ "aria-hidden": !0,
81
+ children: /* @__PURE__ */ o(e.HtmlEmbed, { "ws:label": "Play SVG", code: a })
82
+ }
83
+ )
84
+ }
85
+ )
86
+ ]
87
+ }
88
+ )
89
+ };
90
+ export {
91
+ p as meta
92
+ };
@@ -0,0 +1,39 @@
1
+ import { VimeoIcon as o } from "@webstudio-is/icons/svg";
2
+ import { defaultStates as t } from "@webstudio-is/react-sdk";
3
+ import { div as r } from "@webstudio-is/sdk/normalize.css";
4
+ import { props as n } from "./__generated__/vimeo.props.js";
5
+ const i = {
6
+ div: r
7
+ }, c = {
8
+ type: "container",
9
+ icon: o,
10
+ states: t,
11
+ presetStyle: i,
12
+ constraints: {
13
+ relation: "ancestor",
14
+ component: { $nin: ["Button", "Link", "Heading"] }
15
+ }
16
+ }, s = [
17
+ "id",
18
+ "className",
19
+ "url",
20
+ "quality",
21
+ "loading",
22
+ "showPreview",
23
+ "autoplay",
24
+ "doNotTrack",
25
+ "loop",
26
+ "muted",
27
+ "showPortrait",
28
+ "showByline",
29
+ "showTitle",
30
+ "showControls",
31
+ "controlsColor"
32
+ ], m = {
33
+ props: n,
34
+ initialProps: s
35
+ };
36
+ export {
37
+ c as meta,
38
+ m as propsMeta
39
+ };
@@ -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,127 @@
1
+ import { meta as t } from "./form.ws.js";
2
+ import { showAttribute as e } from "@webstudio-is/react-sdk";
3
+ import { props as o } from "./__generated__/webhook-form.props.js";
4
+ import { WebhookFormIcon as a } from "@webstudio-is/icons/svg";
5
+ const c = {
6
+ ...t,
7
+ category: "data",
8
+ label: "Webhook Form",
9
+ description: "Collect user data and send it to any webhook.",
10
+ order: 1,
11
+ icon: a,
12
+ states: [
13
+ { selector: "[data-state=error]", label: "Error" },
14
+ { selector: "[data-state=success]", label: "Success" }
15
+ ],
16
+ template: [
17
+ {
18
+ type: "instance",
19
+ component: "Form",
20
+ variables: {
21
+ formState: { initialValue: "initial" }
22
+ },
23
+ props: [
24
+ {
25
+ type: "expression",
26
+ name: "state",
27
+ code: "formState"
28
+ },
29
+ {
30
+ type: "action",
31
+ name: "onStateChange",
32
+ value: [
33
+ { type: "execute", args: ["state"], code: "formState = state" }
34
+ ]
35
+ }
36
+ ],
37
+ children: [
38
+ {
39
+ type: "instance",
40
+ label: "Form Content",
41
+ component: "Box",
42
+ props: [
43
+ {
44
+ type: "expression",
45
+ name: e,
46
+ code: "formState === 'initial' || formState === 'error'"
47
+ }
48
+ ],
49
+ children: [
50
+ {
51
+ type: "instance",
52
+ component: "Label",
53
+ children: [{ type: "text", value: "Name", placeholder: !0 }]
54
+ },
55
+ {
56
+ type: "instance",
57
+ component: "Input",
58
+ props: [{ type: "string", name: "name", value: "name" }],
59
+ children: []
60
+ },
61
+ {
62
+ type: "instance",
63
+ component: "Label",
64
+ children: [{ type: "text", value: "Email", placeholder: !0 }]
65
+ },
66
+ {
67
+ type: "instance",
68
+ component: "Input",
69
+ props: [{ type: "string", name: "name", value: "email" }],
70
+ children: []
71
+ },
72
+ {
73
+ type: "instance",
74
+ component: "Button",
75
+ children: [{ type: "text", value: "Submit", placeholder: !0 }]
76
+ }
77
+ ]
78
+ },
79
+ {
80
+ type: "instance",
81
+ label: "Success Message",
82
+ component: "Box",
83
+ props: [
84
+ {
85
+ type: "expression",
86
+ name: e,
87
+ code: "formState === 'success'"
88
+ }
89
+ ],
90
+ children: [
91
+ {
92
+ type: "text",
93
+ value: "Thank you for getting in touch!",
94
+ placeholder: !0
95
+ }
96
+ ]
97
+ },
98
+ {
99
+ type: "instance",
100
+ label: "Error Message",
101
+ component: "Box",
102
+ props: [
103
+ {
104
+ type: "expression",
105
+ name: e,
106
+ code: "formState === 'error'"
107
+ }
108
+ ],
109
+ children: [
110
+ {
111
+ type: "text",
112
+ value: "Sorry, something went wrong.",
113
+ placeholder: !0
114
+ }
115
+ ]
116
+ }
117
+ ]
118
+ }
119
+ ]
120
+ }, i = {
121
+ props: o,
122
+ initialProps: ["id", "className", "state", "action"]
123
+ };
124
+ export {
125
+ c as meta,
126
+ i as propsMeta
127
+ };
@@ -0,0 +1,44 @@
1
+ import { jsxs as n, jsx as p } from "react/jsx-runtime";
2
+ import { ReactSdkContext as y } from "@webstudio-is/react-sdk/runtime";
3
+ import { forwardRef as b, useContext as h, createElement as u, Children as g } from "react";
4
+ const x = b(
5
+ ({ tag: i = "", children: e, ...o }, c) => {
6
+ const { renderer: f } = h(y), s = Object.entries(o).filter(
7
+ ([t]) => t.startsWith("data-") === !1 && t.startsWith("aria-") === !1
8
+ ).filter(([t]) => t !== "tabIndex").filter(([, t]) => typeof t != "function");
9
+ if (f === void 0) {
10
+ const t = Object.fromEntries(s);
11
+ return u(i, t, e);
12
+ }
13
+ const r = g.toArray(e), l = r.length > 0 && r.every((t) => typeof t == "string"), a = i.replace(/^[^\p{L}_]+/u, "").replaceAll(/[^\p{L}\p{N}\-._:]+/gu, ""), d = s.map(
14
+ ([t, m]) => `${t}=${JSON.stringify(m)}`
15
+ );
16
+ return /* @__PURE__ */ n("div", { ...o, children: [
17
+ /* @__PURE__ */ n("span", { style: { color: "rgb(16, 23, 233)" }, children: [
18
+ "<",
19
+ [a, ...d].join(" "),
20
+ ">"
21
+ ] }),
22
+ r.length > 0 && /* @__PURE__ */ p(
23
+ "div",
24
+ {
25
+ ref: c,
26
+ style: {
27
+ display: l ? "inline" : "block",
28
+ marginLeft: l ? 0 : "1rem"
29
+ },
30
+ children: e
31
+ }
32
+ ),
33
+ /* @__PURE__ */ n("span", { style: { color: "rgb(16, 23, 233)" }, children: [
34
+ "</",
35
+ a,
36
+ ">"
37
+ ] })
38
+ ] });
39
+ }
40
+ );
41
+ x.displayName = "XmlNode";
42
+ export {
43
+ x as XmlNode
44
+ };
@@ -0,0 +1,18 @@
1
+ import { XmlIcon as o } from "@webstudio-is/icons/svg";
2
+ import "@webstudio-is/react-sdk";
3
+ import { props as t } from "./__generated__/xml-node.props.js";
4
+ const i = {
5
+ category: "xml",
6
+ order: 6,
7
+ type: "container",
8
+ icon: o,
9
+ stylable: !1,
10
+ description: "XML Node"
11
+ }, a = {
12
+ props: t,
13
+ initialProps: ["tag"]
14
+ };
15
+ export {
16
+ i as meta,
17
+ a as propsMeta
18
+ };
@@ -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,18 @@
1
+ import { CalendarIcon as t } from "@webstudio-is/icons/svg";
2
+ import "@webstudio-is/react-sdk";
3
+ import { props as e } from "./__generated__/xml-time.props.js";
4
+ const i = {
5
+ category: "xml",
6
+ type: "container",
7
+ description: "Converts machine-readable date and time to ISO format.",
8
+ icon: t,
9
+ stylable: !1,
10
+ order: 7
11
+ }, n = {
12
+ props: e,
13
+ initialProps: ["datetime", "dateStyle"]
14
+ };
15
+ export {
16
+ i as meta,
17
+ n as propsMeta
18
+ };
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "@webstudio-is/sdk-components-react",
3
+ "version": "0.0.1-c87cdba.0",
4
+ "description": "Webstudio default library for react",
5
+ "author": "Webstudio <github@webstudio.is>",
6
+ "homepage": "https://webstudio.is",
7
+ "license": "AGPL-3.0-or-later",
8
+ "private": false,
9
+ "type": "module",
10
+ "sideEffects": false,
11
+ "files": [
12
+ "lib/*",
13
+ "!*.{test,stories}.*"
14
+ ],
15
+ "exports": {
16
+ ".": {
17
+ "webstudio": "./src/components.ts",
18
+ "types": "./lib/types/components.d.ts",
19
+ "import": "./lib/components.js"
20
+ },
21
+ "./metas": {
22
+ "webstudio": "./src/metas.ts",
23
+ "types": "./lib/types/metas.d.ts",
24
+ "import": "./lib/metas.js"
25
+ },
26
+ "./props": {
27
+ "webstudio": "./src/props.ts",
28
+ "types": "./lib/types/props.d.ts",
29
+ "import": "./lib/props.js"
30
+ },
31
+ "./hooks": {
32
+ "webstudio": "./src/hooks.ts",
33
+ "types": "./lib/types/hooks.d.ts",
34
+ "import": "./lib/hooks.js"
35
+ },
36
+ "./templates": {
37
+ "webstudio": "./src/templates.ts",
38
+ "types": "./lib/types/templates.d.ts",
39
+ "import": "./lib/templates.js"
40
+ }
41
+ },
42
+ "peerDependencies": {
43
+ "react": "18.3.0-canary-14898b6a9-20240318",
44
+ "react-dom": "18.3.0-canary-14898b6a9-20240318"
45
+ },
46
+ "dependencies": {
47
+ "@react-aria/utils": "^3.26.0",
48
+ "await-interaction-response": "^0.0.2",
49
+ "colord": "^2.9.3",
50
+ "micromark": "^4.0.1",
51
+ "micromark-extension-gfm-table": "^2.1.0",
52
+ "@webstudio-is/icons": "0.0.1-c87cdba.0",
53
+ "@webstudio-is/sdk": "0.0.1-c87cdba.0",
54
+ "@webstudio-is/image": "0.0.1-c87cdba.0",
55
+ "@webstudio-is/react-sdk": "0.0.1-c87cdba.0"
56
+ },
57
+ "devDependencies": {
58
+ "@testing-library/react": "^14.2.2",
59
+ "@types/react": "^18.2.70",
60
+ "@types/react-dom": "^18.2.25",
61
+ "react": "18.3.0-canary-14898b6a9-20240318",
62
+ "react-dom": "18.3.0-canary-14898b6a9-20240318",
63
+ "vitest": "^2.1.8",
64
+ "@webstudio-is/template": "0.0.1-c87cdba.0",
65
+ "@webstudio-is/tsconfig": "1.0.8-c87cdba.0",
66
+ "@webstudio-is/generate-arg-types": "0.0.1-c87cdba.0"
67
+ },
68
+ "scripts": {
69
+ "build": "vite build --config ../../vite.sdk-components.config.ts",
70
+ "build:args": "NODE_OPTIONS=--conditions=webstudio generate-arg-types './src/*.tsx !./src/*.stories.tsx !./src/*.test.{ts,tsx} !./src/*.ws.ts !./src/*.ws.ts !./src/*.template.tsx' && prettier --write \"**/*.props.ts\"",
71
+ "dts": "tsc --project tsconfig.dts.json",
72
+ "test": "vitest run",
73
+ "typecheck": "tsc"
74
+ }
75
+ }