@webstudio-is/sdk-components-react 0.210.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.
package/lib/box.ws.js CHANGED
@@ -1,31 +1,51 @@
1
1
  import { BoxIcon as t } from "@webstudio-is/icons/svg";
2
2
  import { defaultStates as e } from "@webstudio-is/sdk";
3
- import { div as o, address as r, article as a, aside as i, figure as n, footer as s, header as c, main as p, nav as d, section as m } from "@webstudio-is/sdk/normalize.css";
3
+ import { div as r, address as o, article as a, aside as i, figure as s, footer as n, header as p, main as c, nav as d, section as m } from "@webstudio-is/sdk/normalize.css";
4
4
  import { props as f } from "./__generated__/box.props.js";
5
- const g = {
6
- div: o,
7
- address: r,
8
- article: a,
9
- aside: i,
10
- figure: n,
11
- footer: s,
12
- header: c,
13
- main: p,
14
- nav: d,
15
- section: m
16
- }, v = {
5
+ const v = {
17
6
  category: "general",
18
7
  type: "container",
19
8
  description: "A container for content. By default this is a Div, but the tag can be changed in settings.",
20
9
  icon: t,
21
10
  states: e,
22
- presetStyle: g,
11
+ presetStyle: {
12
+ div: r,
13
+ address: o,
14
+ article: a,
15
+ aside: i,
16
+ figure: s,
17
+ footer: n,
18
+ header: p,
19
+ main: c,
20
+ nav: d,
21
+ section: m
22
+ },
23
23
  order: 0
24
- }, b = {
25
- props: f,
26
- initialProps: ["id", "className", "tag"]
24
+ }, y = {
25
+ props: {
26
+ ...f,
27
+ tag: {
28
+ required: !0,
29
+ control: "tag",
30
+ type: "string",
31
+ options: [
32
+ "div",
33
+ "header",
34
+ "footer",
35
+ "nav",
36
+ "main",
37
+ "section",
38
+ "article",
39
+ "aside",
40
+ "address",
41
+ "figure",
42
+ "span"
43
+ ]
44
+ }
45
+ },
46
+ initialProps: ["tag", "id", "className"]
27
47
  };
28
48
  export {
29
49
  v as meta,
30
- b as propsMeta
50
+ y as propsMeta
31
51
  };
@@ -6,7 +6,7 @@ const l = {
6
6
  order: 6,
7
7
  template: /* @__PURE__ */ r(e.Label, { "ws:label": "Checkbox Field", children: [
8
8
  /* @__PURE__ */ o(e.Checkbox, {}),
9
- /* @__PURE__ */ o(e.Text, { "ws:label": "Checkbox Label", tag: "span", children: new c("Checkbox") })
9
+ /* @__PURE__ */ o(e.Text, { "ws:label": "Checkbox Label", "ws:tag": "span", children: new c("Checkbox") })
10
10
  ] })
11
11
  };
12
12
  export {
package/lib/components.js CHANGED
@@ -10,7 +10,7 @@ import { Paragraph as c } from "./paragraph.js";
10
10
  import { Link as B, Link as L } from "./link.js";
11
11
  import { Span as g } from "./span.js";
12
12
  import { Bold as I } from "./bold.js";
13
- import { Italic as V } from "./italic.js";
13
+ import { Italic as h } from "./italic.js";
14
14
  import { Superscript as R } from "./superscript.js";
15
15
  import { Subscript as y } from "./subscript.js";
16
16
  import { Button as E } from "./button.js";
@@ -36,11 +36,12 @@ import { XmlNode as co } from "./xml-node.js";
36
36
  import { XmlTime as Bo } from "./xml-time.js";
37
37
  import { Time as Ho } from "./time.js";
38
38
  import { Select as Fo } from "./select.js";
39
- import { Option as ho } from "./option.js";
39
+ import { Option as Vo } from "./option.js";
40
40
  import { HeadSlot as Po } from "./head-slot.js";
41
41
  import { HeadLink as wo } from "./head-link.js";
42
42
  import { HeadMeta as Co } from "./head-meta.js";
43
43
  import { HeadTitle as Mo } from "./head-title.js";
44
+ import { Video as qo } from "./video.js";
44
45
  export {
45
46
  z as Blockquote,
46
47
  n as Body,
@@ -59,13 +60,13 @@ export {
59
60
  x as HtmlEmbed,
60
61
  Y as Image,
61
62
  X as Input,
62
- V as Italic,
63
+ h as Italic,
63
64
  $ as Label,
64
65
  B as Link,
65
66
  D as List,
66
67
  J as ListItem,
67
68
  a as MarkdownEmbed,
68
- ho as Option,
69
+ Vo as Option,
69
70
  c as Paragraph,
70
71
  to as RadioButton,
71
72
  O as RemixForm,
@@ -79,6 +80,7 @@ export {
79
80
  k as Text,
80
81
  ro as Textarea,
81
82
  Ho as Time,
83
+ qo as Video,
82
84
  fo as Vimeo,
83
85
  ko as VimeoPlayButton,
84
86
  lo as VimeoPreviewImage,
package/lib/heading.js CHANGED
@@ -1,9 +1,12 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import { forwardRef as n } from "react";
3
- const d = "h1", f = n(
4
- ({ tag: a = d, children: o, ...r }, t) => /* @__PURE__ */ e(a, { ...r, ref: t, children: o })
1
+ import { forwardRef as o, createElement as g } from "react";
2
+ import { getTagFromProps as m } from "@webstudio-is/sdk/runtime";
3
+ const n = "h1", d = o(
4
+ ({ tag: e, ...t }, a) => {
5
+ const r = m(t) ?? e ?? n;
6
+ return g(r, { ...t, ref: a });
7
+ }
5
8
  );
6
- f.displayName = "Heading";
9
+ d.displayName = "Heading";
7
10
  export {
8
- f as Heading
11
+ d as Heading
9
12
  };
package/lib/heading.ws.js CHANGED
@@ -1,25 +1,33 @@
1
1
  import { HeadingIcon as t } from "@webstudio-is/icons/svg";
2
2
  import { defaultStates as o } from "@webstudio-is/sdk";
3
- import { h1 as e, h2 as r, h3 as a, h4 as p, h5 as i, h6 as s } from "@webstudio-is/sdk/normalize.css";
4
- import { props as m } from "./__generated__/heading.props.js";
5
- const n = {
6
- h1: e,
7
- h2: r,
8
- h3: a,
9
- h4: p,
10
- h5: i,
11
- h6: s
12
- }, f = {
3
+ import { h1 as r, h2 as e, h3 as p, h4 as a, h5 as i, h6 as s } from "@webstudio-is/sdk/normalize.css";
4
+ import { props as h } from "./__generated__/heading.props.js";
5
+ const d = {
13
6
  type: "container",
14
7
  placeholder: "Heading",
15
8
  icon: t,
16
9
  states: o,
17
- presetStyle: n
10
+ presetStyle: {
11
+ h1: r,
12
+ h2: e,
13
+ h3: p,
14
+ h4: a,
15
+ h5: i,
16
+ h6: s
17
+ }
18
18
  }, g = {
19
- props: m,
20
- initialProps: ["id", "className", "tag"]
19
+ props: {
20
+ ...h,
21
+ tag: {
22
+ required: !0,
23
+ control: "tag",
24
+ type: "string",
25
+ options: ["h1", "h2", "h3", "h4", "h5", "h6"]
26
+ }
27
+ },
28
+ initialProps: ["tag", "id", "className"]
21
29
  };
22
30
  export {
23
- f as meta,
31
+ d as meta,
24
32
  g as propsMeta
25
33
  };
package/lib/metas.js CHANGED
@@ -3,7 +3,7 @@ import { meta as m } from "./fragment.ws.js";
3
3
  import { meta as p } from "./html-embed.ws.js";
4
4
  import { meta as s } from "./markdown-embed.ws.js";
5
5
  import { meta as i } from "./body.ws.js";
6
- import { meta as d } from "./box.ws.js";
6
+ import { meta as n } from "./box.ws.js";
7
7
  import { meta as u } from "./text.ws.js";
8
8
  import { meta as T } from "./heading.ws.js";
9
9
  import { meta as B } from "./paragraph.ws.js";
@@ -30,7 +30,7 @@ import { meta as me } from "./radio-button.ws.js";
30
30
  import { meta as pe } from "./checkbox.ws.js";
31
31
  import { meta as se } from "./vimeo.ws.js";
32
32
  import { meta as ie } from "./youtube.ws.js";
33
- import { meta as de } from "./vimeo-preview-image.ws.js";
33
+ import { meta as ne } from "./vimeo-preview-image.ws.js";
34
34
  import { meta as ue } from "./vimeo-play-button.ws.js";
35
35
  import { meta as Te } from "./vimeo-spinner.ws.js";
36
36
  import { meta as Be } from "./xml-node.ws.js";
@@ -42,11 +42,12 @@ import { meta as Pe } from "./head-slot.ws.js";
42
42
  import { meta as we } from "./head-link.ws.js";
43
43
  import { meta as Ce } from "./head-meta.ws.js";
44
44
  import { meta as Me } from "./head-title.ws.js";
45
+ import { meta as qe } from "./video.ws.js";
45
46
  export {
46
47
  D as Blockquote,
47
48
  i as Body,
48
49
  h as Bold,
49
- d as Box,
50
+ n as Box,
50
51
  M as Button,
51
52
  pe as Checkbox,
52
53
  _ as CodeText,
@@ -80,9 +81,10 @@ export {
80
81
  u as Text,
81
82
  oe as Textarea,
82
83
  Le as Time,
84
+ qe as Video,
83
85
  se as Vimeo,
84
86
  ue as VimeoPlayButton,
85
- de as VimeoPreviewImage,
87
+ ne as VimeoPreviewImage,
86
88
  Te as VimeoSpinner,
87
89
  Be as XmlNode,
88
90
  ke as XmlTime,
package/lib/props.js CHANGED
@@ -3,7 +3,7 @@ import { propsMeta as t } from "./fragment.ws.js";
3
3
  import { propsMeta as s } from "./html-embed.ws.js";
4
4
  import { propsMeta as x } from "./markdown-embed.ws.js";
5
5
  import { propsMeta as f } from "./body.ws.js";
6
- import { propsMeta as n } from "./box.ws.js";
6
+ import { propsMeta as d } from "./box.ws.js";
7
7
  import { propsMeta as l } from "./text.ws.js";
8
8
  import { propsMeta as S } from "./heading.ws.js";
9
9
  import { propsMeta as c } from "./paragraph.ws.js";
@@ -42,11 +42,12 @@ import { propsMeta as Po } from "./head-slot.ws.js";
42
42
  import { propsMeta as wo } from "./head-link.ws.js";
43
43
  import { propsMeta as Co } from "./head-meta.ws.js";
44
44
  import { propsMeta as Xo } from "./head-title.ws.js";
45
+ import { propsMeta as vo } from "./video.ws.js";
45
46
  export {
46
47
  D as Blockquote,
47
48
  f as Body,
48
49
  V as Bold,
49
- n as Box,
50
+ d as Box,
50
51
  E as Button,
51
52
  so as Checkbox,
52
53
  _ as CodeText,
@@ -80,6 +81,7 @@ export {
80
81
  l as Text,
81
82
  po as Textarea,
82
83
  Lo as Time,
84
+ vo as Video,
83
85
  xo as Vimeo,
84
86
  uo as VimeoPlayButton,
85
87
  no as VimeoPreviewImage,
@@ -6,7 +6,7 @@ const r = {
6
6
  order: 5,
7
7
  template: /* @__PURE__ */ t(e.Label, { "ws:label": "Radio Field", children: [
8
8
  /* @__PURE__ */ o(e.RadioButton, {}),
9
- /* @__PURE__ */ o(e.Text, { "ws:label": "Radio Label", tag: "span", children: new a("Radio") })
9
+ /* @__PURE__ */ o(e.Text, { "ws:label": "Radio Label", "ws:tag": "span", children: new a("Radio") })
10
10
  ] })
11
11
  };
12
12
  export {
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
  };
@@ -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
+ };