@webstudio-is/sdk-components-react 0.209.0 → 0.212.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 (43) hide show
  1. package/lib/__generated__/box.props.js +1 -19
  2. package/lib/__generated__/heading.props.js +1 -8
  3. package/lib/__generated__/text.props.js +1 -8
  4. package/lib/__generated__/video.props.js +587 -0
  5. package/lib/box.js +9 -6
  6. package/lib/box.ws.js +38 -18
  7. package/lib/button.ws.js +6 -10
  8. package/lib/checkbox.template.js +1 -1
  9. package/lib/checkbox.ws.js +12 -16
  10. package/lib/code-text.ws.js +4 -8
  11. package/lib/components.js +6 -4
  12. package/lib/form.ws.js +10 -14
  13. package/lib/heading.js +9 -6
  14. package/lib/heading.ws.js +22 -18
  15. package/lib/input.ws.js +8 -12
  16. package/lib/label.ws.js +8 -12
  17. package/lib/link.ws.js +2 -6
  18. package/lib/list-item.ws.js +5 -12
  19. package/lib/metas.js +6 -4
  20. package/lib/option.ws.js +2 -6
  21. package/lib/paragraph.ws.js +6 -10
  22. package/lib/props.js +4 -2
  23. package/lib/radio-button.template.js +1 -1
  24. package/lib/radio-button.ws.js +6 -10
  25. package/lib/select.ws.js +6 -10
  26. package/lib/text.js +9 -7
  27. package/lib/text.ws.js +23 -15
  28. package/lib/textarea.ws.js +10 -14
  29. package/lib/types/__generated__/video.props.d.ts +2 -0
  30. package/lib/types/box.d.ts +2 -3
  31. package/lib/types/components.d.ts +1 -0
  32. package/lib/types/heading.d.ts +1 -2
  33. package/lib/types/link.d.ts +1 -1
  34. package/lib/types/metas.d.ts +1 -0
  35. package/lib/types/props.d.ts +1 -0
  36. package/lib/types/text.d.ts +2 -3
  37. package/lib/types/video.d.ts +7 -0
  38. package/lib/types/video.ws.d.ts +3 -0
  39. package/lib/video.js +46 -0
  40. package/lib/video.ws.js +34 -0
  41. package/lib/webhook-form.ws.js +10 -14
  42. package/lib/youtube.js +115 -101
  43. package/package.json +9 -8
@@ -2,7 +2,7 @@ import { RadioCheckedIcon as e } from "@webstudio-is/icons/svg";
2
2
  import { defaultStates as t } from "@webstudio-is/sdk";
3
3
  import { radio as o } from "@webstudio-is/sdk/normalize.css";
4
4
  import { props as r } from "./__generated__/radio-button.props.js";
5
- const i = {
5
+ const a = {
6
6
  input: [
7
7
  ...o,
8
8
  {
@@ -10,15 +10,11 @@ const i = {
10
10
  value: { type: "unit", unit: "em", value: 0.5 }
11
11
  }
12
12
  ]
13
- }, p = {
14
- constraints: {
15
- relation: "ancestor",
16
- component: { $nin: ["Button", "Link"] }
17
- },
13
+ }, s = {
18
14
  type: "control",
19
15
  label: "Radio",
20
16
  icon: e,
21
- presetStyle: i,
17
+ presetStyle: a,
22
18
  states: [
23
19
  ...t,
24
20
  { selector: ":checked", label: "Checked" },
@@ -30,11 +26,11 @@ const i = {
30
26
  //{ selector: ":read-only", label: "Read Only" },
31
27
  //{ selector: ":read-write", label: "Read Write" },
32
28
  ]
33
- }, s = {
29
+ }, n = {
34
30
  props: r,
35
31
  initialProps: ["id", "className", "name", "value", "required", "checked"]
36
32
  };
37
33
  export {
38
- p as meta,
39
- s as propsMeta
34
+ s as meta,
35
+ n as propsMeta
40
36
  };
package/lib/select.ws.js CHANGED
@@ -1,32 +1,28 @@
1
1
  import { SelectIcon as e } from "@webstudio-is/icons/svg";
2
- import { defaultStates as t } from "@webstudio-is/sdk";
3
- import { select as l } from "@webstudio-is/sdk/normalize.css";
2
+ import { defaultStates as l } from "@webstudio-is/sdk";
3
+ import { select as t } from "@webstudio-is/sdk/normalize.css";
4
4
  import { props as o } from "./__generated__/select.props.js";
5
5
  const r = {
6
6
  select: [
7
- ...l,
7
+ ...t,
8
8
  {
9
9
  property: "display",
10
10
  value: { type: "keyword", value: "block" }
11
11
  }
12
12
  ]
13
13
  }, c = {
14
- constraints: {
15
- relation: "ancestor",
16
- component: { $nin: ["Button", "Link"] }
17
- },
18
14
  type: "container",
19
15
  icon: e,
20
16
  presetStyle: r,
21
17
  states: [
22
- ...t,
18
+ ...l,
23
19
  { selector: "::placeholder", label: "Placeholder" },
24
20
  { selector: ":valid", label: "Valid" },
25
21
  { selector: ":invalid", label: "Invalid" },
26
22
  { selector: ":required", label: "Required" },
27
23
  { selector: ":optional", label: "Optional" }
28
24
  ]
29
- }, p = {
25
+ }, d = {
30
26
  props: o,
31
27
  initialProps: [
32
28
  "id",
@@ -40,5 +36,5 @@ const r = {
40
36
  };
41
37
  export {
42
38
  c as meta,
43
- p as propsMeta
39
+ d as propsMeta
44
40
  };
package/lib/text.js CHANGED
@@ -1,10 +1,12 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import { forwardRef as f } from "react";
3
- const m = "div", s = f(
4
- ({ tag: t = m, children: o, ...r }, a) => /* @__PURE__ */ e(t, { ...r, ref: a, children: o })
1
+ import { forwardRef as a, createElement as m } from "react";
2
+ import { getTagFromProps as f } from "@webstudio-is/sdk/runtime";
3
+ const g = "div", n = a(
4
+ ({ tag: e, ...t }, r) => {
5
+ const o = f(t) ?? e ?? g;
6
+ return m(o, { ...t, ref: r });
7
+ }
5
8
  );
6
- s.displayName = "Text";
9
+ n.displayName = "Text";
7
10
  export {
8
- s as Text,
9
- m as defaultTag
11
+ n as Text
10
12
  };
package/lib/text.ws.js CHANGED
@@ -2,24 +2,32 @@ import { TextIcon as t } from "@webstudio-is/icons/svg";
2
2
  import { defaultStates as e } from "@webstudio-is/sdk";
3
3
  import { div as o } from "@webstudio-is/sdk/normalize.css";
4
4
  import { props as i } from "./__generated__/text.props.js";
5
- const r = {
6
- div: [
7
- ...o,
8
- {
9
- property: "min-height",
10
- value: { type: "unit", unit: "em", value: 1 }
11
- }
12
- ]
13
- }, n = {
5
+ const s = {
14
6
  type: "container",
15
7
  icon: t,
16
8
  states: e,
17
- presetStyle: r
18
- }, c = {
19
- props: i,
20
- initialProps: ["id", "className", "tag"]
9
+ presetStyle: {
10
+ div: [
11
+ ...o,
12
+ {
13
+ property: "min-height",
14
+ value: { type: "unit", unit: "em", value: 1 }
15
+ }
16
+ ]
17
+ }
18
+ }, m = {
19
+ props: {
20
+ ...i,
21
+ tag: {
22
+ required: !0,
23
+ control: "tag",
24
+ type: "string",
25
+ options: ["div", "cite", "figcaption", "span"]
26
+ }
27
+ },
28
+ initialProps: ["tag", "id", "className"]
21
29
  };
22
30
  export {
23
- n as meta,
24
- c as propsMeta
31
+ s as meta,
32
+ m as propsMeta
25
33
  };
@@ -1,10 +1,10 @@
1
1
  import { FormTextAreaIcon as e } from "@webstudio-is/icons/svg";
2
- import { defaultStates as o } from "@webstudio-is/sdk";
3
- import { textarea as t } from "@webstudio-is/sdk/normalize.css";
4
- import { props as r } from "./__generated__/textarea.props.js";
2
+ import { defaultStates as r } from "@webstudio-is/sdk";
3
+ import { textarea as o } from "@webstudio-is/sdk/normalize.css";
4
+ import { props as t } from "./__generated__/textarea.props.js";
5
5
  const l = {
6
6
  textarea: [
7
- ...t,
7
+ ...o,
8
8
  // resize doesn't work well while on canvas
9
9
  { property: "resize", value: { type: "keyword", value: "none" } },
10
10
  {
@@ -12,7 +12,7 @@ const l = {
12
12
  value: { type: "keyword", value: "block" }
13
13
  }
14
14
  ]
15
- }, p = {
15
+ }, c = {
16
16
  category: "forms",
17
17
  type: "control",
18
18
  label: "Text Area",
@@ -20,12 +20,8 @@ const l = {
20
20
  icon: e,
21
21
  presetStyle: l,
22
22
  order: 4,
23
- constraints: {
24
- relation: "ancestor",
25
- component: { $nin: ["Button", "Link"] }
26
- },
27
23
  states: [
28
- ...o,
24
+ ...r,
29
25
  { selector: "::placeholder", label: "Placeholder" },
30
26
  { selector: ":valid", label: "Valid" },
31
27
  { selector: ":invalid", label: "Invalid" },
@@ -37,8 +33,8 @@ const l = {
37
33
  //{ selector: ":read-only", label: "Read Only" },
38
34
  //{ selector: ":read-write", label: "Read Write" },
39
35
  ]
40
- }, c = {
41
- props: r,
36
+ }, n = {
37
+ props: t,
42
38
  initialProps: [
43
39
  "id",
44
40
  "className",
@@ -50,6 +46,6 @@ const l = {
50
46
  ]
51
47
  };
52
48
  export {
53
- p as meta,
54
- c as propsMeta
49
+ c as meta,
50
+ n as propsMeta
55
51
  };
@@ -0,0 +1,2 @@
1
+ import type { PropMeta } from "@webstudio-is/sdk";
2
+ export declare const props: Record<string, PropMeta>;
@@ -1,8 +1,7 @@
1
1
  import { type ComponentProps } from "react";
2
- export declare const defaultTag = "div";
2
+ declare const defaultTag = "div";
3
3
  type Props = ComponentProps<typeof defaultTag> & {
4
- /** Use this property to change the HTML tag of this element to semantically structure and describe the content of a webpage. This can be important for accessibility tools and search engine optimization. */
5
- tag?: "div" | "header" | "footer" | "nav" | "main" | "section" | "article" | "aside" | "address" | "figure";
4
+ tag?: string;
6
5
  };
7
6
  export declare const Box: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
8
7
  export {};
@@ -42,3 +42,4 @@ export { HeadSlot } from "./head-slot";
42
42
  export { HeadLink } from "./head-link";
43
43
  export { HeadMeta } from "./head-meta";
44
44
  export { HeadTitle } from "./head-title";
45
+ export { Video } from "./video";
@@ -1,8 +1,7 @@
1
1
  import { type ComponentProps } from "react";
2
2
  declare const defaultTag = "h1";
3
3
  type Props = ComponentProps<typeof defaultTag> & {
4
- /** Use HTML heading levels (h1-h6) to structure content hierarchically, with h1 as the main title and subsequent levels representing sub-sections. Maintain a logical order and avoid skipping levels to ensure consistent and meaningful organization. */
5
- tag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
4
+ tag?: string;
6
5
  };
7
6
  export declare const Heading: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<HTMLHeadingElement>>;
8
7
  export {};
@@ -1,5 +1,5 @@
1
1
  export declare const defaultTag = "a";
2
- export declare const Link: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "target" | "download"> & {
2
+ export declare const Link: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "download" | "target"> & {
3
3
  target?: "_self" | "_blank" | "_parent" | "_top";
4
4
  download?: boolean;
5
5
  prefetch?: "none" | "intent" | "render" | "viewport";
@@ -42,3 +42,4 @@ export { meta as HeadSlot } from "./head-slot.ws";
42
42
  export { meta as HeadLink } from "./head-link.ws";
43
43
  export { meta as HeadMeta } from "./head-meta.ws";
44
44
  export { meta as HeadTitle } from "./head-title.ws";
45
+ export { meta as Video } from "./video.ws";
@@ -42,3 +42,4 @@ export { propsMeta as HeadSlot } from "./head-slot.ws";
42
42
  export { propsMeta as HeadLink } from "./head-link.ws";
43
43
  export { propsMeta as HeadMeta } from "./head-meta.ws";
44
44
  export { propsMeta as HeadTitle } from "./head-title.ws";
45
+ export { propsMeta as Video } from "./video.ws";
@@ -1,8 +1,7 @@
1
1
  import { type ComponentProps } from "react";
2
- export declare const defaultTag = "div";
2
+ declare const defaultTag = "div";
3
3
  type Props = ComponentProps<typeof defaultTag> & {
4
- /** Use this property to change the HTML tag of this element to semantically structure and describe the content of a webpage. This can be important for accessibility tools and search engine optimization. */
5
- tag?: "div" | "span" | "figcaption" | "cite";
4
+ tag?: string;
6
5
  };
7
6
  export declare const Text: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
8
7
  export {};
@@ -0,0 +1,7 @@
1
+ import type { Atom } from "nanostores";
2
+ export declare const defaultTag = "video";
3
+ export declare const Video: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLVideoElement> & import("react").VideoHTMLAttributes<HTMLVideoElement> & {
4
+ $progress?: Atom<number | undefined>;
5
+ $visible?: Atom<boolean>;
6
+ $timeline?: boolean;
7
+ }, "ref"> & import("react").RefAttributes<HTMLVideoElement>>;
@@ -0,0 +1,3 @@
1
+ import { type WsComponentMeta, type WsComponentPropsMeta } from "@webstudio-is/sdk";
2
+ export declare const meta: WsComponentMeta;
3
+ export declare const propsMeta: WsComponentPropsMeta;
package/lib/video.js ADDED
@@ -0,0 +1,46 @@
1
+ import { jsx as b } from "react/jsx-runtime";
2
+ import { forwardRef as m, useId as V, useEffect as _ } from "react";
3
+ const a = "data-ws-video-id", H = {
4
+ HAVE_NOTHING: 0,
5
+ HAVE_METADATA: 1,
6
+ HAVE_CURRENT_DATA: 2,
7
+ HAVE_FUTURE_DATA: 3,
8
+ HAVE_ENOUGH_DATA: 4
9
+ }, N = m(({ $progress: r, $visible: n, $timeline: f, children: d, ...c }, A) => {
10
+ const s = V(), l = {
11
+ [a]: s
12
+ };
13
+ return _(() => {
14
+ if (r === void 0 || n === void 0)
15
+ return;
16
+ const e = document.querySelector(`[${a}="${s}"]`);
17
+ if (e === null || !(e instanceof HTMLVideoElement))
18
+ return;
19
+ if (e.play().catch(() => {
20
+ }), e.pause(), f)
21
+ return r.subscribe((i) => {
22
+ if (e.readyState < H.HAVE_METADATA || (e.paused || e.pause(), e.seeking))
23
+ return;
24
+ let u = e.duration;
25
+ Number.isNaN(u) || (Number.isFinite(u) || (u = 60), e.currentTime = (i ?? 0) * u);
26
+ });
27
+ let t = !1, o = !1;
28
+ const T = n.subscribe((i) => {
29
+ o = i, o === !1 && t === !1 && !e.loop && (e.currentTime = 0);
30
+ }), E = r.subscribe((i) => {
31
+ if (t && (i === void 0 || i === 0 || i === 1)) {
32
+ t = !1, e.pause(), o === !1 && t === !1 && !e.loop && (e.currentTime = 0);
33
+ return;
34
+ }
35
+ t || (t = !0, e.ended || e.play().catch(() => {
36
+ }));
37
+ });
38
+ return () => {
39
+ E(), T();
40
+ };
41
+ }, [r, f, n, s]), /* @__PURE__ */ b("video", { ...c, ...l, ref: A, children: d });
42
+ });
43
+ N.displayName = "Video";
44
+ export {
45
+ N as Video
46
+ };
@@ -0,0 +1,34 @@
1
+ import { VideoIcon as o } from "@webstudio-is/icons/svg";
2
+ import "@webstudio-is/sdk";
3
+ import { props as t } from "./__generated__/video.props.js";
4
+ const r = {
5
+ type: "control",
6
+ icon: o,
7
+ presetStyle: {
8
+ video: [
9
+ {
10
+ property: "max-width",
11
+ value: { type: "unit", unit: "%", value: 100 }
12
+ }
13
+ ]
14
+ }
15
+ }, a = {
16
+ props: t,
17
+ initialProps: [
18
+ "id",
19
+ "className",
20
+ "width",
21
+ "height",
22
+ "src",
23
+ "autoPlay",
24
+ "controls",
25
+ "loop",
26
+ "muted",
27
+ "preload",
28
+ "playsInline"
29
+ ]
30
+ };
31
+ export {
32
+ r as meta,
33
+ a as propsMeta
34
+ };
@@ -1,24 +1,20 @@
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 = {
1
+ import { WebhookFormIcon as e } from "@webstudio-is/icons/svg";
2
+ import { form as o } 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
- icon: o,
6
+ icon: e,
7
7
  type: "container",
8
- constraints: {
9
- relation: "ancestor",
10
- component: { $nin: ["Form", "Button", "Link"] }
11
- },
12
8
  presetStyle: {
13
- form: t
9
+ form: o
14
10
  },
15
11
  states: [
16
12
  { selector: "[data-state=error]", label: "Error" },
17
13
  { selector: "[data-state=success]", label: "Success" }
18
14
  ]
19
- }, c = {
15
+ }, i = {
20
16
  props: {
21
- ...e,
17
+ ...r,
22
18
  action: {
23
19
  type: "resource",
24
20
  control: "resource",
@@ -29,6 +25,6 @@ const n = {
29
25
  initialProps: ["id", "className", "state", "action"]
30
26
  };
31
27
  export {
32
- n as meta,
33
- c as propsMeta
28
+ c as meta,
29
+ i as propsMeta
34
30
  };