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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/lib/__generated__/blockquote.props.js +2 -512
  2. package/lib/__generated__/body.props.js +2 -506
  3. package/lib/__generated__/bold.props.js +2 -506
  4. package/lib/__generated__/box.props.js +3 -524
  5. package/lib/__generated__/button.props.js +2 -568
  6. package/lib/__generated__/checkbox.props.js +1 -662
  7. package/lib/__generated__/code-text.props.js +1 -504
  8. package/lib/__generated__/form.props.js +2 -554
  9. package/lib/__generated__/head-link.props.js +2 -618
  10. package/lib/__generated__/head-meta.props.js +2 -530
  11. package/lib/__generated__/head-slot.props.js +4 -0
  12. package/lib/__generated__/head-title.props.js +2 -506
  13. package/lib/__generated__/heading.props.js +3 -513
  14. package/lib/__generated__/html-embed.props.js +6 -1
  15. package/lib/__generated__/image.props.js +1 -581
  16. package/lib/__generated__/input.props.js +2 -694
  17. package/lib/__generated__/italic.props.js +2 -506
  18. package/lib/__generated__/label.props.js +2 -518
  19. package/lib/__generated__/link.props.js +4 -555
  20. package/lib/__generated__/list-item.props.js +2 -512
  21. package/lib/__generated__/list.props.js +1 -523
  22. package/lib/__generated__/markdown-embed.props.js +2 -3
  23. package/lib/__generated__/option.props.js +2 -530
  24. package/lib/__generated__/paragraph.props.js +2 -506
  25. package/lib/__generated__/radio-button.props.js +1 -662
  26. package/lib/__generated__/select.props.js +2 -554
  27. package/lib/__generated__/separator.props.js +2 -506
  28. package/lib/__generated__/span.props.js +2 -506
  29. package/lib/__generated__/subscript.props.js +2 -506
  30. package/lib/__generated__/superscript.props.js +2 -506
  31. package/lib/__generated__/text.props.js +3 -513
  32. package/lib/__generated__/textarea.props.js +2 -585
  33. package/lib/__generated__/time.props.js +1 -8
  34. package/lib/__generated__/video.props.js +4 -0
  35. package/lib/__generated__/vimeo-play-button.props.js +2 -567
  36. package/lib/__generated__/vimeo-preview-image.props.js +1 -580
  37. package/lib/__generated__/vimeo-spinner.props.js +2 -506
  38. package/lib/__generated__/vimeo.props.js +2 -505
  39. package/lib/__generated__/webhook-form.props.js +1 -557
  40. package/lib/__generated__/xml-node.props.js +8 -3
  41. package/lib/__generated__/xml-time.props.js +4 -3
  42. package/lib/__generated__/youtube.props.js +1 -498
  43. package/lib/blockquote.ws.js +18 -25
  44. package/lib/body.ws.js +6 -25
  45. package/lib/bold.ws.js +6 -15
  46. package/lib/box.js +9 -6
  47. package/lib/box.ws.js +37 -27
  48. package/lib/button.ws.js +7 -24
  49. package/lib/checkbox.ws.js +8 -26
  50. package/lib/code-text.ws.js +18 -26
  51. package/lib/components.js +6 -4
  52. package/lib/form.ws.js +9 -23
  53. package/lib/fragment.ws.js +2 -8
  54. package/lib/head-link.ws.js +9 -14
  55. package/lib/head-meta.ws.js +9 -14
  56. package/lib/head-slot.js +4 -5
  57. package/lib/head-slot.template.js +1 -1
  58. package/lib/head-slot.ws.js +9 -20
  59. package/lib/head-title.ws.js +6 -11
  60. package/lib/heading.js +9 -6
  61. package/lib/heading.ws.js +20 -23
  62. package/lib/html-embed.ws.js +22 -20
  63. package/lib/image.ws.js +21 -28
  64. package/lib/input.js +18 -14
  65. package/lib/input.ws.js +11 -37
  66. package/lib/italic.ws.js +6 -21
  67. package/lib/label.ws.js +7 -18
  68. package/lib/link.ws.js +11 -32
  69. package/lib/list-item.ws.js +6 -22
  70. package/lib/list.ws.js +15 -22
  71. package/lib/markdown-embed.js +3 -3
  72. package/lib/markdown-embed.ws.js +13 -11
  73. package/lib/metas.js +6 -4
  74. package/lib/option.js +3 -1
  75. package/lib/option.ws.js +9 -18
  76. package/lib/paragraph.ws.js +7 -20
  77. package/lib/radio-button.ws.js +10 -29
  78. package/lib/rich-text-link.ws.js +3 -7
  79. package/lib/select.js +27 -14
  80. package/lib/select.ws.js +10 -28
  81. package/lib/separator.ws.js +14 -24
  82. package/lib/shared/video.js +13 -0
  83. package/lib/slot.ws.js +3 -7
  84. package/lib/span.ws.js +8 -15
  85. package/lib/subscript.ws.js +7 -16
  86. package/lib/superscript.ws.js +7 -16
  87. package/lib/templates.js +12 -36
  88. package/lib/text.js +9 -7
  89. package/lib/text.ws.js +22 -19
  90. package/lib/textarea.js +16 -5
  91. package/lib/textarea.ws.js +13 -35
  92. package/lib/time.js +2 -1
  93. package/lib/time.ws.js +12 -15
  94. package/lib/types/blockquote.ws.d.ts +1 -2
  95. package/lib/types/body.ws.d.ts +1 -2
  96. package/lib/types/bold.ws.d.ts +1 -2
  97. package/lib/types/box.d.ts +2 -3
  98. package/lib/types/box.ws.d.ts +1 -2
  99. package/lib/types/button.ws.d.ts +1 -2
  100. package/lib/types/checkbox.d.ts +1 -1
  101. package/lib/types/checkbox.ws.d.ts +1 -2
  102. package/lib/types/code-text.ws.d.ts +1 -2
  103. package/lib/types/components.d.ts +1 -0
  104. package/lib/types/form.ws.d.ts +1 -2
  105. package/lib/types/fragment.ws.d.ts +1 -2
  106. package/lib/types/head-link.ws.d.ts +1 -2
  107. package/lib/types/head-meta.ws.d.ts +1 -2
  108. package/lib/types/head-slot.ws.d.ts +1 -2
  109. package/lib/types/head-title.ws.d.ts +1 -2
  110. package/lib/types/heading.d.ts +1 -2
  111. package/lib/types/heading.ws.d.ts +1 -2
  112. package/lib/types/html-embed.ws.d.ts +1 -2
  113. package/lib/types/image.ws.d.ts +1 -2
  114. package/lib/types/input.d.ts +1 -4
  115. package/lib/types/input.ws.d.ts +1 -2
  116. package/lib/types/italic.ws.d.ts +1 -2
  117. package/lib/types/label.ws.d.ts +1 -2
  118. package/lib/types/link.ws.d.ts +1 -2
  119. package/lib/types/list-item.ws.d.ts +1 -2
  120. package/lib/types/list.ws.d.ts +1 -2
  121. package/lib/types/markdown-embed.d.ts +3 -3
  122. package/lib/types/markdown-embed.ws.d.ts +1 -2
  123. package/lib/types/metas.d.ts +1 -0
  124. package/lib/types/option.d.ts +0 -1
  125. package/lib/types/option.ws.d.ts +1 -2
  126. package/lib/types/paragraph.ws.d.ts +1 -2
  127. package/lib/types/radio-button.d.ts +1 -1
  128. package/lib/types/radio-button.ws.d.ts +1 -2
  129. package/lib/types/rich-text-link.ws.d.ts +1 -2
  130. package/lib/types/select.d.ts +0 -1
  131. package/lib/types/select.ws.d.ts +1 -2
  132. package/lib/types/separator.ws.d.ts +1 -2
  133. package/lib/types/shared/video.d.ts +7 -0
  134. package/lib/types/slot.ws.d.ts +1 -2
  135. package/lib/types/span.ws.d.ts +1 -2
  136. package/lib/types/subscript.ws.d.ts +1 -2
  137. package/lib/types/superscript.ws.d.ts +1 -2
  138. package/lib/types/templates.d.ts +0 -12
  139. package/lib/types/text.d.ts +2 -3
  140. package/lib/types/text.ws.d.ts +1 -2
  141. package/lib/types/textarea.d.ts +0 -1
  142. package/lib/types/textarea.ws.d.ts +1 -2
  143. package/lib/types/time.d.ts +2 -4
  144. package/lib/types/time.ws.d.ts +1 -2
  145. package/lib/types/video.d.ts +9 -0
  146. package/lib/types/video.ws.d.ts +2 -0
  147. package/lib/types/vimeo-play-button.ws.d.ts +1 -2
  148. package/lib/types/vimeo-preview-image.d.ts +21 -21
  149. package/lib/types/vimeo-preview-image.ws.d.ts +1 -2
  150. package/lib/types/vimeo-spinner.ws.d.ts +1 -2
  151. package/lib/types/vimeo.d.ts +0 -6
  152. package/lib/types/vimeo.ws.d.ts +1 -2
  153. package/lib/types/webhook-form.ws.d.ts +1 -2
  154. package/lib/types/xml-node.ws.d.ts +1 -2
  155. package/lib/types/xml-time.ws.d.ts +1 -2
  156. package/lib/types/youtube.ws.d.ts +1 -2
  157. package/lib/video.js +53 -0
  158. package/lib/video.ws.js +44 -0
  159. package/lib/vimeo-play-button.js +4 -4
  160. package/lib/vimeo-play-button.ws.js +13 -26
  161. package/lib/vimeo-preview-image.js +5 -5
  162. package/lib/vimeo-preview-image.ws.js +8 -10
  163. package/lib/vimeo-spinner.js +1 -1
  164. package/lib/vimeo-spinner.ws.js +12 -19
  165. package/lib/vimeo.js +98 -99
  166. package/lib/vimeo.template.js +22 -21
  167. package/lib/vimeo.ws.js +16 -21
  168. package/lib/webhook-form.template.js +59 -20
  169. package/lib/webhook-form.ws.js +16 -15
  170. package/lib/xml-node.js +17 -16
  171. package/lib/xml-node.ws.js +5 -8
  172. package/lib/xml-time.ws.js +4 -7
  173. package/lib/youtube.js +152 -131
  174. package/lib/youtube.template.js +16 -15
  175. package/lib/youtube.ws.js +15 -21
  176. package/package.json +13 -16
  177. package/lib/__generated__/head.props.js +0 -508
  178. package/lib/blockquote.template.js +0 -11
  179. package/lib/button.template.js +0 -11
  180. package/lib/checkbox.template.js +0 -14
  181. package/lib/heading.template.js +0 -11
  182. package/lib/label.template.js +0 -10
  183. package/lib/link.template.js +0 -11
  184. package/lib/list-item.template.js +0 -11
  185. package/lib/list.template.js +0 -15
  186. package/lib/paragraph.template.js +0 -11
  187. package/lib/props.js +0 -90
  188. package/lib/radio-button.template.js +0 -14
  189. package/lib/select.template.js +0 -16
  190. package/lib/text.template.js +0 -11
  191. package/lib/types/blockquote.template.d.ts +0 -2
  192. package/lib/types/button.template.d.ts +0 -2
  193. package/lib/types/checkbox.template.d.ts +0 -2
  194. package/lib/types/heading.template.d.ts +0 -2
  195. package/lib/types/label.template.d.ts +0 -2
  196. package/lib/types/link.template.d.ts +0 -2
  197. package/lib/types/list-item.template.d.ts +0 -2
  198. package/lib/types/list.template.d.ts +0 -2
  199. package/lib/types/paragraph.template.d.ts +0 -2
  200. package/lib/types/props.d.ts +0 -44
  201. package/lib/types/radio-button.template.d.ts +0 -2
  202. package/lib/types/select.template.d.ts +0 -2
  203. package/lib/types/text.template.d.ts +0 -2
  204. /package/lib/types/__generated__/{head.props.d.ts → video.props.d.ts} +0 -0
@@ -1,42 +1,81 @@
1
- import { jsxs as r, jsx as t } from "react/jsx-runtime";
2
- import { Variable as s, $ as e, expression as o, ActionValue as i, PlaceholderValue as a } from "@webstudio-is/template";
3
- const n = new s("formState", "initial"), w = {
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
4
  category: "data",
5
5
  order: 1,
6
6
  description: "Collect user data and send it to any webhook.",
7
- template: /* @__PURE__ */ r(
8
- e.Form,
7
+ template: /* @__PURE__ */ o(
8
+ r.Form,
9
9
  {
10
- state: o`${n}`,
11
- onStateChange: new i(["state"], o`${n} = state`),
10
+ state: l`${s}`,
11
+ onStateChange: new i(["state"], l`${s} = state`),
12
12
  children: [
13
- /* @__PURE__ */ r(
14
- e.Box,
13
+ /* @__PURE__ */ o(
14
+ e.element,
15
15
  {
16
+ "ws:tag": "div",
16
17
  "ws:label": "Form Content",
17
- "ws:show": o`${n} === 'initial' || ${n} === 'error'`,
18
+ "ws:show": l`${s} === 'initial' || ${s} === 'error'`,
18
19
  children: [
19
- /* @__PURE__ */ t(e.Label, { children: new a("Name") }),
20
- /* @__PURE__ */ t(e.Input, { name: "name" }),
21
- /* @__PURE__ */ t(e.Label, { children: new a("Email") }),
22
- /* @__PURE__ */ t(e.Input, { name: "email" }),
23
- /* @__PURE__ */ t(e.Button, { children: new a("Submit") })
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") })
24
61
  ]
25
62
  }
26
63
  ),
27
64
  /* @__PURE__ */ t(
28
- e.Box,
65
+ e.element,
29
66
  {
67
+ "ws:tag": "div",
30
68
  "ws:label": "Success Message",
31
- "ws:show": o`${n} === 'success'`,
69
+ "ws:show": l`${s} === 'success'`,
32
70
  children: new a("Thank you for getting in touch!")
33
71
  }
34
72
  ),
35
73
  /* @__PURE__ */ t(
36
- e.Box,
74
+ e.element,
37
75
  {
76
+ "ws:tag": "div",
38
77
  "ws:label": "Error Message",
39
- "ws:show": o`${n} === 'error'`,
78
+ "ws:show": l`${s} === 'error'`,
40
79
  children: new a("Sorry, something went wrong.")
41
80
  }
42
81
  )
@@ -45,5 +84,5 @@ const n = new s("formState", "initial"), w = {
45
84
  )
46
85
  };
47
86
  export {
48
- w as meta
87
+ d as meta
49
88
  };
@@ -1,26 +1,27 @@
1
1
  import { WebhookFormIcon as o } from "@webstudio-is/icons/svg";
2
- import { form as t } from "@webstudio-is/sdk/normalize.css";
3
- import { props as e } from "./__generated__/webhook-form.props.js";
4
- const n = {
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
5
  label: "Webhook Form",
6
6
  icon: o,
7
- type: "container",
8
- constraints: {
9
- relation: "ancestor",
10
- component: { $nin: ["Form", "Button", "Link"] }
11
- },
12
7
  presetStyle: {
13
- form: t
8
+ form: e
14
9
  },
15
10
  states: [
16
11
  { selector: "[data-state=error]", label: "Error" },
17
12
  { selector: "[data-state=success]", label: "Success" }
18
- ]
19
- }, c = {
20
- props: e,
21
- initialProps: ["id", "className", "state", "action"]
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
+ }
22
24
  };
23
25
  export {
24
- n as meta,
25
- c as propsMeta
26
+ c as meta
26
27
  };
package/lib/xml-node.js CHANGED
@@ -1,51 +1,52 @@
1
- import { jsxs as t, jsx as r, Fragment as u } from "react/jsx-runtime";
1
+ import { jsxs as r, jsx as t, Fragment as u } from "react/jsx-runtime";
2
2
  import { ReactSdkContext as g, xmlNodeTagSuffix as x } from "@webstudio-is/react-sdk/runtime";
3
- import { forwardRef as b, useContext as N, createElement as C, Children as F } from "react";
3
+ import { forwardRef as b, useContext as C, createElement as N, Children as F } from "react";
4
4
  const j = b(
5
5
  ({ tag: c = "", children: l, ...i }, d) => {
6
- const { renderer: p } = N(g), o = Object.entries(i).filter(
6
+ const { renderer: p } = C(g), o = Object.entries(i).filter(
7
7
  ([e]) => e.startsWith("data-") === !1 && e.startsWith("aria-") === !1
8
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
9
  if (p === void 0) {
10
10
  const e = Object.fromEntries(o);
11
- return C(
11
+ return N(
12
12
  `${s}${x}`,
13
13
  e,
14
14
  l
15
15
  );
16
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__ */ t("span", { children: [
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
18
  " ",
19
- /* @__PURE__ */ r("span", { style: { color: "#FF0000" }, children: f }),
20
- /* @__PURE__ */ r("span", { style: { color: "#000000" }, children: "=" }),
21
- /* @__PURE__ */ t("span", { style: { color: "#0000FF" }, children: [
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
22
  '"',
23
23
  h,
24
24
  '"'
25
25
  ] })
26
26
  ] }, y));
27
- return /* @__PURE__ */ t("div", { ...i, children: [
28
- /* @__PURE__ */ t("span", { children: [
29
- /* @__PURE__ */ t("span", { style: { color: "#800000" }, children: [
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
30
  "<",
31
31
  s
32
32
  ] }),
33
33
  o.length > 0 && m(o),
34
- n.length === 0 ? /* @__PURE__ */ r("span", { style: { color: "#800000" }, children: "/>" }) : /* @__PURE__ */ r("span", { style: { color: "#800000" }, children: ">" })
34
+ n.length === 0 ? /* @__PURE__ */ t("span", { style: { color: "#800000" }, children: "/>" }) : /* @__PURE__ */ t("span", { style: { color: "#800000" }, children: ">" })
35
35
  ] }),
36
- n.length > 0 && /* @__PURE__ */ t(u, { children: [
37
- /* @__PURE__ */ r(
36
+ n.length > 0 && /* @__PURE__ */ r(u, { children: [
37
+ /* @__PURE__ */ t(
38
38
  "div",
39
39
  {
40
40
  ref: d,
41
41
  style: {
42
42
  display: a ? "inline" : "block",
43
- marginLeft: a ? 0 : "1rem"
43
+ marginLeft: a ? 0 : "1rem",
44
+ color: "#000000"
44
45
  },
45
46
  children: l
46
47
  }
47
48
  ),
48
- /* @__PURE__ */ t("span", { style: { color: "#800000" }, children: [
49
+ /* @__PURE__ */ r("span", { style: { color: "#800000" }, children: [
49
50
  "</",
50
51
  s,
51
52
  ">"
@@ -1,16 +1,13 @@
1
1
  import { XmlIcon as o } from "@webstudio-is/icons/svg";
2
2
  import { props as r } from "./__generated__/xml-node.props.js";
3
- const e = {
3
+ const m = {
4
4
  category: "xml",
5
5
  order: 6,
6
- type: "container",
7
6
  icon: o,
8
- description: "XML Node"
9
- }, i = {
10
- props: r,
11
- initialProps: ["tag"]
7
+ description: "XML Node",
8
+ initialProps: ["tag"],
9
+ props: r
12
10
  };
13
11
  export {
14
- e as meta,
15
- i as propsMeta
12
+ m as meta
16
13
  };
@@ -2,15 +2,12 @@ import { CalendarIcon as t } from "@webstudio-is/icons/svg";
2
2
  import { props as e } from "./__generated__/xml-time.props.js";
3
3
  const a = {
4
4
  category: "xml",
5
- type: "container",
6
5
  description: "Converts machine-readable date and time to ISO format.",
7
6
  icon: t,
8
- order: 7
9
- }, i = {
10
- props: e,
11
- initialProps: ["datetime", "dateStyle"]
7
+ order: 7,
8
+ initialProps: ["datetime", "dateStyle"],
9
+ props: e
12
10
  };
13
11
  export {
14
- a as meta,
15
- i as propsMeta
12
+ a as meta
16
13
  };
package/lib/youtube.js CHANGED
@@ -1,8 +1,8 @@
1
- import { jsx as u, jsxs as R, Fragment as _ } from "react/jsx-runtime";
2
- import { forwardRef as L, useState as h, useContext as C, useEffect as y } from "react";
3
- import { ReactSdkContext as I } from "@webstudio-is/react-sdk/runtime";
4
- import { VimeoContext as E } from "./vimeo.js";
5
- const O = "https://www.youtube-nocookie.com", x = "https://www.youtube.com", w = "https://img.youtube.com", k = (e) => {
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
6
  if (e)
7
7
  try {
8
8
  const t = new URL(e);
@@ -10,197 +10,218 @@ const O = "https://www.youtube-nocookie.com", x = "https://www.youtube.com", w =
10
10
  } catch {
11
11
  return e;
12
12
  }
13
- }, S = (e, t) => {
14
- var n, i;
15
- const l = k(e.url), r = new URL(t);
16
- if (l)
17
- r.pathname = `/embed/${l}`;
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
18
  else if (e.url)
19
19
  try {
20
20
  const c = new URL(e.url);
21
21
  r.pathname = c.pathname, r.search = c.search;
22
22
  } catch {
23
23
  }
24
- const o = Object.keys(e), a = {};
25
- for (const c of o)
26
- switch (c) {
27
- case "autoplay":
28
- a.autoplay = e.autoplay ? "1" : "0", e.autoplay && e.muted === void 0 && (a.mute = "1");
29
- break;
30
- case "muted":
31
- a.mute = e.muted ? "1" : "0";
32
- break;
33
- case "showControls":
34
- a.controls = e.showControls ? "1" : "0";
35
- break;
36
- case "showRelatedVideos":
37
- a.rel = e.showRelatedVideos ? "1" : "0";
38
- break;
39
- case "keyboard":
40
- a.keyboard = e.keyboard ? "1" : "0";
41
- break;
42
- case "loop":
43
- a.loop = e.loop ? "1" : "0", e.loop && (e.playlist ?? "").trim() === "" && (a.playlist = l);
44
- break;
45
- case "inline":
46
- a.playsinline = e.inline ? "1" : "0";
47
- break;
48
- case "allowFullscreen":
49
- a.fs = e.allowFullscreen ? "1" : "0";
50
- break;
51
- case "captionLanguage":
52
- a.cc_lang_pref = e.captionLanguage;
53
- break;
54
- case "showCaptions":
55
- a.cc_load_policy = e.showCaptions ? "1" : "0";
56
- break;
57
- case "showAnnotations":
58
- a.iv_load_policy = e.showAnnotations ? "1" : "3";
59
- break;
60
- case "startTime":
61
- a.start = (n = e.startTime) == null ? void 0 : n.toString();
62
- break;
63
- case "endTime":
64
- a.end = (i = e.endTime) == null ? void 0 : i.toString();
65
- break;
66
- case "disableKeyboard":
67
- a.disablekb = e.disableKeyboard ? "1" : "0";
68
- break;
69
- case "language":
70
- a.hl = e.language;
71
- break;
72
- case "listId":
73
- a.list = e.listId;
74
- break;
75
- case "listType":
76
- a.listType = e.listType;
77
- break;
78
- case "color":
79
- a.color = e.color;
80
- break;
81
- case "origin":
82
- a.origin = e.origin;
83
- break;
84
- case "referrer":
85
- a.widget_referrer = e.referrer;
86
- break;
87
- case "playlist":
88
- a.playlist = e.playlist;
89
- break;
90
- }
91
- return Object.entries(a).forEach(([c, s]) => {
92
- s !== void 0 && r.searchParams.append(c, s.toString());
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());
93
98
  }), r.toString();
94
- }, p = (e) => {
99
+ }, R = (e) => {
95
100
  const t = document.createElement("link");
96
101
  t.rel = "preconnect", t.href = e, t.crossOrigin = "true", document.head.appendChild(t);
97
102
  };
98
- let g = !1;
99
- const T = (e) => {
100
- if (!(g || window.matchMedia("(hover: none)").matches)) {
103
+ let _ = !1;
104
+ const F = (e) => {
105
+ if (!(_ || window.matchMedia("(hover: none)").matches)) {
101
106
  try {
102
107
  const t = new URL(e);
103
- p(t.origin);
108
+ R(t.origin);
104
109
  } catch {
105
110
  }
106
- p(w), g = !0;
111
+ R(j), _ = !0;
107
112
  }
108
- }, j = (e) => new URL(`${w}/vi/${e}/maxresdefault.jpg`), A = () => /* @__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' }), N = ({
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 = ({
109
114
  title: e,
110
115
  status: t,
111
- loading: l,
116
+ loading: s,
112
117
  videoUrl: r,
113
- previewImageUrl: o,
118
+ previewImageUrl: i,
114
119
  autoplay: a,
120
+ inline: o,
115
121
  renderer: n,
116
- showPreview: i,
117
- onStatusChange: c,
118
- onPreviewImageUrlChange: s
122
+ showPreview: c,
123
+ onStatusChange: l,
124
+ onPreviewImageUrlChange: d
119
125
  }) => {
120
- const [m, b] = h(0);
126
+ const [h, m] = p(0), b = T(null);
121
127
  return y(() => {
122
- a && n !== "canvas" && t === "initial" && c("loading");
123
- }, [a, t, n, c]), y(() => {
124
- n !== "canvas" && T(r);
128
+ a && n !== "canvas" && t === "initial" && l("loading");
129
+ }, [a, t, n, l]), y(() => {
130
+ n !== "canvas" && F(r);
125
131
  }, [n, r]), y(() => {
126
- const d = k(r);
127
- if (!d || !i) {
128
- s(void 0);
132
+ const f = L(r);
133
+ if (!f || !c) {
134
+ d(void 0);
129
135
  return;
130
136
  }
131
- o || s(j(d));
132
- }, [s, i, r, o]), n === "canvas" || t === "initial" ? null : /* @__PURE__ */ u(
137
+ i || d(Y(f));
138
+ }, [d, c, r, i]), n === "canvas" || t === "initial" ? null : /* @__PURE__ */ u(
133
139
  "iframe",
134
140
  {
141
+ ref: b,
135
142
  title: e,
136
143
  src: r,
137
- loading: l,
144
+ loading: s,
138
145
  allow: "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",
139
146
  allowFullScreen: !0,
140
147
  style: {
141
148
  position: "absolute",
142
149
  width: "100%",
143
150
  height: "100%",
144
- opacity: m,
151
+ opacity: h,
145
152
  transition: "opacity 1s",
146
153
  border: "none"
147
154
  },
148
155
  onLoad: () => {
149
- c("ready"), b(1);
156
+ l("ready"), m(1), !o && !a && b.current && P(b.current);
150
157
  }
151
158
  }
152
159
  );
153
- }, P = L(
160
+ }, $ = x(
154
161
  ({
155
162
  url: e,
156
163
  loading: t = "lazy",
157
- autoplay: l,
164
+ autoplay: s,
158
165
  showPreview: r,
159
- children: o,
160
- privacyEnhancedMode: a,
161
- ...n
162
- }, i) => {
163
- const [c, s] = h("initial"), [m, b] = h(), { renderer: d } = C(I), v = a ?? !0 ? O : x, f = S(
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(
164
177
  {
165
- ...n,
178
+ ...m,
179
+ inline: h,
166
180
  url: e,
167
- autoplay: !0
181
+ keyboard: c,
182
+ showAnnotations: i,
183
+ showCaptions: a,
184
+ allowFullscreen: n,
185
+ showControls: o,
186
+ autoplay: s,
187
+ enablejsapi: !1
168
188
  },
169
- v
189
+ I
170
190
  );
171
191
  return /* @__PURE__ */ u(
172
- E.Provider,
192
+ N.Provider,
173
193
  {
174
194
  value: {
175
- status: c,
176
- previewImageUrl: m,
195
+ status: f,
196
+ previewImageUrl: w,
177
197
  onInitPlayer() {
178
- d !== "canvas" && s("loading");
198
+ k !== "canvas" && g("loading");
179
199
  }
180
200
  },
181
- children: /* @__PURE__ */ u("div", { ...n, ref: i, children: f ? /* @__PURE__ */ R(_, { children: [
182
- o,
201
+ children: /* @__PURE__ */ u("div", { ...m, ref: b, children: v ? /* @__PURE__ */ E(O, { children: [
202
+ l,
183
203
  /* @__PURE__ */ u(
184
- N,
204
+ M,
185
205
  {
186
- title: n.title,
187
- autoplay: l,
188
- videoUrl: f,
189
- previewImageUrl: m,
206
+ title: m.title,
207
+ autoplay: s,
208
+ videoUrl: v,
209
+ previewImageUrl: w,
190
210
  loading: t,
211
+ inline: h,
191
212
  showPreview: r,
192
- renderer: d,
193
- status: c,
194
- onStatusChange: s,
195
- onPreviewImageUrlChange: b
213
+ renderer: k,
214
+ status: f,
215
+ onStatusChange: g,
216
+ onPreviewImageUrlChange: C
196
217
  }
197
218
  )
198
- ] }) : /* @__PURE__ */ u(A, {}) })
219
+ ] }) : /* @__PURE__ */ u(K, {}) })
199
220
  }
200
221
  );
201
222
  }
202
223
  );
203
- P.displayName = "YouTube";
224
+ $.displayName = "YouTube";
204
225
  export {
205
- P as YouTube
226
+ $ as YouTube
206
227
  };