@webstudio-is/sdk-components-react-radix 0.219.0 → 0.221.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 (51) hide show
  1. package/lib/__generated__/popover.props.js +2 -1
  2. package/lib/__generated__/tabs.props.js +2 -2
  3. package/lib/accordion.js +35 -23
  4. package/lib/accordion.template.js +4 -4
  5. package/lib/accordion.ws.js +27 -49
  6. package/lib/checkbox.js +17 -6
  7. package/lib/checkbox.ws.js +21 -36
  8. package/lib/collapsible.js +29 -26
  9. package/lib/collapsible.ws.js +8 -21
  10. package/lib/components.js +46 -45
  11. package/lib/dialog.js +50 -56
  12. package/lib/dialog.ws.js +36 -65
  13. package/lib/label.ws.js +8 -14
  14. package/lib/metas.js +45 -44
  15. package/lib/navigation-menu.ws.js +21 -35
  16. package/lib/popover.js +36 -32
  17. package/lib/popover.template.js +50 -20
  18. package/lib/popover.ws.js +35 -27
  19. package/lib/radio-group.js +10 -7
  20. package/lib/radio-group.ws.js +26 -44
  21. package/lib/select.js +49 -35
  22. package/lib/select.ws.js +33 -63
  23. package/lib/switch.js +9 -6
  24. package/lib/switch.ws.js +21 -44
  25. package/lib/tabs.js +46 -50
  26. package/lib/tabs.template.js +5 -5
  27. package/lib/tabs.ws.js +20 -42
  28. package/lib/tooltip.js +34 -31
  29. package/lib/tooltip.ws.js +12 -20
  30. package/lib/types/__generated__/popover.props.d.ts +1 -0
  31. package/lib/types/accordion.ws.d.ts +1 -6
  32. package/lib/types/checkbox.ws.d.ts +1 -3
  33. package/lib/types/collapsible.d.ts +2 -2
  34. package/lib/types/collapsible.ws.d.ts +1 -4
  35. package/lib/types/components.d.ts +1 -1
  36. package/lib/types/dialog.ws.d.ts +1 -8
  37. package/lib/types/label.ws.d.ts +1 -2
  38. package/lib/types/metas.d.ts +1 -1
  39. package/lib/types/navigation-menu.ws.d.ts +1 -8
  40. package/lib/types/popover.d.ts +1 -0
  41. package/lib/types/popover.ws.d.ts +2 -4
  42. package/lib/types/radio-group.d.ts +1 -1
  43. package/lib/types/radio-group.ws.d.ts +1 -4
  44. package/lib/types/select.ws.d.ts +1 -9
  45. package/lib/types/switch.ws.d.ts +1 -3
  46. package/lib/types/tabs.d.ts +1 -4
  47. package/lib/types/tabs.ws.d.ts +1 -5
  48. package/lib/types/tooltip.ws.d.ts +1 -4
  49. package/package.json +9 -15
  50. package/lib/props.js +0 -62
  51. package/lib/types/props.d.ts +0 -12
@@ -1,33 +1,63 @@
1
- import { jsxs as i, jsx as o } from "react/jsx-runtime";
2
- import { $ as t, PlaceholderValue as d, css as n } from "@webstudio-is/template";
3
- import { radix as r } from "./shared/proxy.js";
4
- import { getButtonStyle as l } from "./shared/styles.js";
5
- import { zIndex as a, width as p, borderRadius as s, borderWidth as c, colors as e, spacing as m, boxShadow as h } from "./shared/theme.js";
6
- const w = {
1
+ import { jsxs as n, jsx as o } from "react/jsx-runtime";
2
+ import { LargeXIcon as p } from "@webstudio-is/icons/svg";
3
+ import { $ as r, PlaceholderValue as d, css as l } from "@webstudio-is/template";
4
+ import { radix as e } from "./shared/proxy.js";
5
+ import { getButtonStyle as h } from "./shared/styles.js";
6
+ import { spacing as t, borderRadius as s, height as a, opacity as m, boxShadow as c, zIndex as b, width as u, borderWidth as g, colors as i } from "./shared/theme.js";
7
+ const P = {
7
8
  category: "radix",
8
9
  description: "Displays rich content in a portal, triggered by a button.",
9
10
  order: 6,
10
- template: /* @__PURE__ */ i(r.Popover, { children: [
11
- /* @__PURE__ */ o(r.PopoverTrigger, { children: /* @__PURE__ */ o(t.Button, { "ws:style": l("outline"), children: new d("Button") }) }),
12
- /* @__PURE__ */ o(
13
- r.PopoverContent,
11
+ template: /* @__PURE__ */ n(e.Popover, { children: [
12
+ /* @__PURE__ */ o(e.PopoverTrigger, { children: /* @__PURE__ */ o(r.Button, { "ws:style": h("outline"), children: new d("Button") }) }),
13
+ /* @__PURE__ */ n(
14
+ e.PopoverContent,
14
15
  {
15
- "ws:style": n`
16
- z-index: ${a[50]};
17
- width: ${p[72]};
16
+ "ws:style": l`
17
+ z-index: ${b[50]};
18
+ width: ${u[72]};
18
19
  border-radius: ${s.md};
19
- border: ${c.DEFAULT} solid ${e.border};
20
- background-color: ${e.popover};
21
- padding: ${m[4]};
22
- color: ${e.popoverForeground};
23
- box-shadow: ${h.md};
20
+ border: ${g.DEFAULT} solid ${i.border};
21
+ background-color: ${i.popover};
22
+ padding: ${t[4]};
23
+ color: ${i.popoverForeground};
24
+ box-shadow: ${c.md};
24
25
  outline: none;
25
26
  `,
26
- children: /* @__PURE__ */ o(t.Text, { children: new d("The text you can edit") })
27
+ children: [
28
+ /* @__PURE__ */ o(r.Text, { children: new d("The text you can edit") }),
29
+ /* @__PURE__ */ o(
30
+ e.PopoverClose,
31
+ {
32
+ "ws:label": "Close Button",
33
+ "ws:style": l`
34
+ position: absolute;
35
+ right: ${t[4]};
36
+ top: ${t[4]};
37
+ border-radius: ${s.sm};
38
+ display: flex;
39
+ align-items: center;
40
+ justify-content: center;
41
+ height: ${a[4]};
42
+ width: ${a[4]};
43
+ border: 0;
44
+ background-color: transparent;
45
+ outline: none;
46
+ &:hover {
47
+ opacity: ${m[100]};
48
+ }
49
+ &:focus-visible {
50
+ box-shadow: ${c.ring};
51
+ }
52
+ `,
53
+ children: /* @__PURE__ */ o(r.HtmlEmbed, { "ws:label": "Close Icon", code: p })
54
+ }
55
+ )
56
+ ]
27
57
  }
28
58
  )
29
59
  ] })
30
60
  };
31
61
  export {
32
- w as meta
62
+ P as meta
33
63
  };
package/lib/popover.ws.js CHANGED
@@ -1,43 +1,51 @@
1
- import { PopoverIcon as e, TriggerIcon as n, ContentIcon as r } from "@webstudio-is/icons/svg";
2
- import { div as t } from "@webstudio-is/sdk/normalize.css";
1
+ import { PopoverIcon as e, TriggerIcon as t, ContentIcon as n, ButtonElementIcon as r } from "@webstudio-is/icons/svg";
2
+ import { div as p, button as i } from "@webstudio-is/sdk/normalize.css";
3
3
  import { radix as o } from "./shared/meta.js";
4
- import { propsPopover as p, propsPopoverTrigger as i, propsPopoverContent as s } from "./__generated__/popover.props.js";
5
- const v = {
6
- icon: n,
4
+ import { propsPopover as s, propsPopoverTrigger as c, propsPopoverContent as a, propsPopoverClose as l } from "./__generated__/popover.props.js";
5
+ import { buttonReset as d } from "./shared/preset-styles.js";
6
+ const C = {
7
+ icon: t,
7
8
  contentModel: {
8
9
  category: "none",
9
10
  children: ["instance"]
10
- }
11
- }, d = {
12
- icon: r,
11
+ },
12
+ props: c
13
+ }, y = {
14
+ icon: n,
13
15
  contentModel: {
14
16
  category: "none",
15
- children: ["instance"]
17
+ children: ["instance"],
18
+ descendants: [o.PopoverClose]
16
19
  },
17
20
  presetStyle: {
18
- div: t
19
- }
20
- }, l = {
21
+ div: p
22
+ },
23
+ initialProps: ["side", "sideOffset", "align", "alignOffset"],
24
+ props: a
25
+ }, h = {
21
26
  icon: e,
22
27
  contentModel: {
23
28
  category: "instance",
24
29
  children: ["instance"],
25
30
  descendants: [o.PopoverTrigger, o.PopoverContent]
26
- }
27
- }, m = {
28
- props: p,
29
- initialProps: ["open"]
30
- }, f = {
31
- props: i
32
- }, M = {
33
- props: s,
34
- initialProps: ["side", "sideOffset", "align", "alignOffset"]
31
+ },
32
+ initialProps: ["open"],
33
+ props: s
34
+ }, u = {
35
+ icon: r,
36
+ label: "Close Button",
37
+ contentModel: {
38
+ category: "none",
39
+ children: ["instance", "rich-text"]
40
+ },
41
+ presetStyle: {
42
+ button: [d, i].flat()
43
+ },
44
+ props: l
35
45
  };
36
46
  export {
37
- l as metaPopover,
38
- d as metaPopoverContent,
39
- v as metaPopoverTrigger,
40
- m as propsMetaPopover,
41
- M as propsMetaPopoverContent,
42
- f as propsMetaPopoverTrigger
47
+ h as metaPopover,
48
+ u as metaPopoverClose,
49
+ y as metaPopoverContent,
50
+ C as metaPopoverTrigger
43
51
  };
@@ -1,9 +1,12 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- import { forwardRef as m } from "react";
3
- import { Item as d, Indicator as p, Root as e } from "@radix-ui/react-radio-group";
4
- const u = m(({ value: o, defaultValue: r, ...t }, a) => /* @__PURE__ */ i(e, { ...t, defaultValue: o ?? r, ref: a })), R = d, s = p;
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import { forwardRef as c, useState as i, useEffect as m } from "react";
3
+ import { Item as s, Indicator as f, Root as d } from "@radix-ui/react-radio-group";
4
+ const I = c(({ defaultValue: r, ...t }, a) => {
5
+ const o = t.value ?? r ?? "", [u, e] = i(o);
6
+ return m(() => e(o), [o]), /* @__PURE__ */ n(d, { ...t, ref: a, value: u, onValueChange: e });
7
+ }), G = s, V = f;
5
8
  export {
6
- u as RadioGroup,
7
- s as RadioGroupIndicator,
8
- R as RadioGroupItem
9
+ I as RadioGroup,
10
+ V as RadioGroupIndicator,
11
+ G as RadioGroupItem
9
12
  };
@@ -1,67 +1,49 @@
1
- import { RadioGroupIcon as e, ItemIcon as a, TriggerIcon as r } from "@webstudio-is/icons/svg";
2
- import { defaultStates as o } from "@webstudio-is/sdk";
3
- import { div as n, button as s, span as c } from "@webstudio-is/sdk/normalize.css";
4
- import { radix as t } from "./shared/meta.js";
5
- import { buttonReset as p } from "./shared/preset-styles.js";
6
- import { propsRadioGroup as i, propsRadioGroupItem as d, propsRadioGroupIndicator as m } from "./__generated__/radio-group.props.js";
7
- const y = {
1
+ import { RadioGroupIcon as e, ItemIcon as t, TriggerIcon as r } from "@webstudio-is/icons/svg";
2
+ import { div as n, button as a, span as i } from "@webstudio-is/sdk/normalize.css";
3
+ import { radix as o } from "./shared/meta.js";
4
+ import { buttonReset as c } from "./shared/preset-styles.js";
5
+ import { propsRadioGroup as p, propsRadioGroupItem as d, propsRadioGroupIndicator as s } from "./__generated__/radio-group.props.js";
6
+ const G = {
8
7
  icon: e,
9
8
  contentModel: {
10
9
  category: "instance",
11
10
  children: ["instance"],
12
- descendants: [t.RadioGroupItem]
11
+ descendants: [o.RadioGroupItem]
13
12
  },
14
13
  states: [
15
- ...o,
16
- {
17
- label: "Checked",
18
- selector: "[data-state=checked]",
19
- category: "component-states"
20
- },
21
- {
22
- label: "Unchecked",
23
- selector: "[data-state=unchecked]",
24
- category: "component-states"
25
- }
14
+ { label: "Checked", selector: "[data-state=checked]" },
15
+ { label: "Unchecked", selector: "[data-state=unchecked]" }
26
16
  ],
27
17
  presetStyle: {
28
18
  div: n
29
- }
30
- }, g = {
31
- icon: a,
19
+ },
20
+ initialProps: ["id", "class", "name", "value", "required"],
21
+ props: p
22
+ }, h = {
23
+ icon: t,
32
24
  contentModel: {
33
25
  category: "none",
34
26
  children: ["instance"],
35
- descendants: [t.RadioGroupIndicator]
27
+ descendants: [o.RadioGroupIndicator]
36
28
  },
37
- states: o,
38
29
  presetStyle: {
39
- button: [s, p].flat()
40
- }
41
- }, h = {
30
+ button: [a, c].flat()
31
+ },
32
+ initialProps: ["value"],
33
+ props: d
34
+ }, f = {
42
35
  icon: r,
43
36
  contentModel: {
44
37
  category: "none",
45
38
  children: ["instance"]
46
39
  },
47
- states: o,
48
40
  presetStyle: {
49
- span: c
50
- }
51
- }, M = {
52
- props: i,
53
- initialProps: ["id", "className", "name", "value", "required"]
54
- }, b = {
55
- props: d,
56
- initialProps: ["value"]
57
- }, k = {
58
- props: m
41
+ span: i
42
+ },
43
+ props: s
59
44
  };
60
45
  export {
61
- y as metaRadioGroup,
62
- h as metaRadioGroupIndicator,
63
- g as metaRadioGroupItem,
64
- M as propsMetaRadioGroup,
65
- k as propsMetaRadioGroupIndicator,
66
- b as propsMetaRadioGroupItem
46
+ G as metaRadioGroup,
47
+ f as metaRadioGroupIndicator,
48
+ h as metaRadioGroupItem
67
49
  };
package/lib/select.js CHANGED
@@ -1,44 +1,58 @@
1
- import { jsx as c } from "react/jsx-runtime";
2
- import { forwardRef as s, useContext as l } from "react";
3
- import { Viewport as m, Item as p, ItemIndicator as f, ItemText as S, Root as d, Trigger as u, Value as I, Portal as P, Content as g } from "@radix-ui/react-select";
4
- import { ReactSdkContext as x, getClosestInstance as i } from "@webstudio-is/react-sdk/runtime";
5
- const v = s(({ value: e, defaultValue: t, ...o }, n) => /* @__PURE__ */ c(d, { ...o, defaultValue: e ?? t })), T = s((e, t) => {
6
- const { renderer: o } = l(x);
7
- return /* @__PURE__ */ c(u, { onPointerDown: o === "canvas" ? (a) => {
8
- a.preventDefault();
9
- } : void 0, ref: t, ...e });
10
- }), $ = s((e, t) => /* @__PURE__ */ c(I, { ref: t, ...e })), k = s((e, t) => /* @__PURE__ */ c(P, { children: /* @__PURE__ */ c(g, { ref: t, ...e, position: "popper" }) })), D = m, R = p, y = f, M = S, r = "@webstudio-is/sdk-components-react-radix", N = {
11
- onNavigatorUnselect: (e, t) => {
12
- for (const o of t.instancePath)
13
- if (o.component === `${r}:SelectContent`) {
14
- const n = i(
15
- t.instancePath,
16
- o,
17
- `${r}:Select`
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { forwardRef as a, useState as m, useEffect as f, useContext as g } from "react";
3
+ import { Viewport as C, Item as I, ItemIndicator as P, ItemText as h, Root as x, Trigger as V, Value as v, Portal as w, Content as T } from "@radix-ui/react-select";
4
+ import { ReactSdkContext as $, getClosestInstance as u } from "@webstudio-is/react-sdk/runtime";
5
+ const y = a(({ defaultOpen: t, defaultValue: e, ...n }, o) => {
6
+ const c = n.open ?? t ?? !1, [S, l] = m(c);
7
+ f(() => l(c), [c]);
8
+ const i = n.value ?? e ?? "", [d, p] = m(i);
9
+ return f(() => p(i), [i]), /* @__PURE__ */ r(
10
+ x,
11
+ {
12
+ ...n,
13
+ open: S,
14
+ onOpenChange: l,
15
+ value: d,
16
+ onValueChange: p
17
+ }
18
+ );
19
+ }), M = a((t, e) => {
20
+ const { renderer: n } = g($);
21
+ return /* @__PURE__ */ r(V, { onPointerDown: n === "canvas" ? (c) => {
22
+ c.preventDefault();
23
+ } : void 0, ref: e, ...t });
24
+ }), N = a((t, e) => /* @__PURE__ */ r(v, { ref: e, ...t })), b = a((t, e) => /* @__PURE__ */ r(w, { children: /* @__PURE__ */ r(T, { ref: e, ...t, position: "popper" }) })), j = C, E = I, U = P, _ = h, s = "@webstudio-is/sdk-components-react-radix", q = {
25
+ onNavigatorUnselect: (t, e) => {
26
+ for (const n of e.instancePath)
27
+ if (n.component === `${s}:SelectContent`) {
28
+ const o = u(
29
+ e.instancePath,
30
+ n,
31
+ `${s}:Select`
18
32
  );
19
- n && e.setMemoryProp(n, "open", void 0);
33
+ o && t.setMemoryProp(o, "open", void 0);
20
34
  }
21
35
  },
22
- onNavigatorSelect: (e, t) => {
23
- for (const o of t.instancePath)
24
- if (o.component === `${r}:SelectContent`) {
25
- const n = i(
26
- t.instancePath,
27
- o,
28
- `${r}:Select`
36
+ onNavigatorSelect: (t, e) => {
37
+ for (const n of e.instancePath)
38
+ if (n.component === `${s}:SelectContent`) {
39
+ const o = u(
40
+ e.instancePath,
41
+ n,
42
+ `${s}:Select`
29
43
  );
30
- n && e.setMemoryProp(n, "open", !0);
44
+ o && t.setMemoryProp(o, "open", !0);
31
45
  }
32
46
  }
33
47
  };
34
48
  export {
35
- v as Select,
36
- k as SelectContent,
37
- R as SelectItem,
38
- y as SelectItemIndicator,
39
- M as SelectItemText,
40
- T as SelectTrigger,
41
- $ as SelectValue,
42
- D as SelectViewport,
43
- N as hooksSelect
49
+ y as Select,
50
+ b as SelectContent,
51
+ E as SelectItem,
52
+ U as SelectItemIndicator,
53
+ _ as SelectItemText,
54
+ M as SelectTrigger,
55
+ N as SelectValue,
56
+ j as SelectViewport,
57
+ q as hooksSelect
44
58
  };
package/lib/select.ws.js CHANGED
@@ -1,44 +1,44 @@
1
- import { SelectIcon as o, TriggerIcon as c, FormTextFieldIcon as r, ViewportIcon as l, ContentIcon as p, ItemIcon as s, CheckMarkIcon as a, TextIcon as i } from "@webstudio-is/icons/svg";
2
- import { button as S, span as t, div as n } from "@webstudio-is/sdk/normalize.css";
1
+ import { SelectIcon as o, TriggerIcon as c, FormTextFieldIcon as r, ViewportIcon as l, ContentIcon as i, ItemIcon as p, CheckMarkIcon as s, TextIcon as a } from "@webstudio-is/icons/svg";
2
+ import { button as d, span as t, div as n } from "@webstudio-is/sdk/normalize.css";
3
3
  import { radix as e } from "./shared/meta.js";
4
- import { propsSelect as d, propsSelectTrigger as m, propsSelectValue as I, propsSelectViewport as g, propsSelectContent as M, propsSelectItem as y, propsSelectItemIndicator as T, propsSelectItemText as h } from "./__generated__/select.props.js";
5
- const w = {
4
+ import { propsSelect as S, propsSelectTrigger as m, propsSelectValue as I, propsSelectViewport as g, propsSelectContent as y, propsSelectItem as h, propsSelectItemIndicator as T, propsSelectItemText as x } from "./__generated__/select.props.js";
5
+ const b = {
6
6
  icon: o,
7
7
  contentModel: {
8
8
  category: "instance",
9
9
  children: ["instance"],
10
10
  descendants: [e.SelectTrigger, e.SelectContent]
11
- }
12
- }, b = {
11
+ },
12
+ initialProps: ["name", "value", "open", "required"],
13
+ props: S
14
+ }, f = {
13
15
  icon: c,
14
16
  contentModel: {
15
17
  category: "none",
16
18
  children: ["instance"],
17
19
  descendants: [e.SelectValue]
18
20
  },
19
- presetStyle: {
20
- button: S
21
- }
22
- }, f = {
21
+ presetStyle: { button: d },
22
+ props: m
23
+ }, w = {
23
24
  label: "Value",
24
25
  icon: r,
25
26
  contentModel: {
26
27
  category: "none",
27
28
  children: []
28
29
  },
29
- presetStyle: {
30
- span: t
31
- }
30
+ presetStyle: { span: t },
31
+ initialProps: ["placeholder"],
32
+ props: I
32
33
  }, v = {
33
- icon: p,
34
+ icon: i,
34
35
  contentModel: {
35
36
  category: "none",
36
37
  children: ["instance"],
37
38
  descendants: [e.SelectViewport]
38
39
  },
39
- presetStyle: {
40
- div: n
41
- }
40
+ presetStyle: { div: n },
41
+ props: y
42
42
  }, P = {
43
43
  icon: l,
44
44
  contentModel: {
@@ -46,74 +46,44 @@ const w = {
46
46
  children: ["instance"],
47
47
  descendants: [e.SelectItem]
48
48
  },
49
- presetStyle: {
50
- div: n
51
- }
49
+ presetStyle: { div: n },
50
+ props: g
52
51
  }, k = {
53
- icon: s,
52
+ icon: p,
54
53
  contentModel: {
55
54
  category: "none",
56
55
  children: ["instance"],
57
56
  descendants: [e.SelectItemIndicator, e.SelectItemText]
58
57
  },
59
- presetStyle: {
60
- div: n
61
- }
58
+ presetStyle: { div: n },
59
+ initialProps: ["value"],
60
+ props: h
62
61
  }, F = {
63
62
  label: "Indicator",
64
- icon: a,
63
+ icon: s,
65
64
  contentModel: {
66
65
  category: "none",
67
66
  children: ["instance"]
68
67
  },
69
- presetStyle: {
70
- span: t
71
- }
68
+ presetStyle: { span: t },
69
+ props: T
72
70
  }, q = {
73
71
  label: "Item Text",
74
- icon: i,
72
+ icon: a,
75
73
  contentModel: {
76
74
  category: "none",
77
75
  children: ["instance", "rich-text"]
78
76
  },
79
- presetStyle: {
80
- span: t
81
- }
82
- }, j = {
83
- props: d,
84
- initialProps: ["name", "value", "open", "required"]
85
- }, z = {
86
- props: m
87
- }, A = {
88
- props: I,
89
- initialProps: ["placeholder"]
90
- }, B = {
91
- props: M
92
- }, D = {
93
- props: g
94
- }, E = {
95
- props: y,
96
- initialProps: ["value"]
97
- }, G = {
98
- props: T
99
- }, H = {
100
- props: h
77
+ presetStyle: { span: t },
78
+ props: x
101
79
  };
102
80
  export {
103
- w as metaSelect,
81
+ b as metaSelect,
104
82
  v as metaSelectContent,
105
83
  k as metaSelectItem,
106
84
  F as metaSelectItemIndicator,
107
85
  q as metaSelectItemText,
108
- b as metaSelectTrigger,
109
- f as metaSelectValue,
110
- P as metaSelectViewport,
111
- j as propsMetaSelect,
112
- B as propsMetaSelectContent,
113
- E as propsMetaSelectItem,
114
- G as propsMetaSelectItemIndicator,
115
- H as propsMetaSelectItemText,
116
- z as propsMetaSelectTrigger,
117
- A as propsMetaSelectValue,
118
- D as propsMetaSelectViewport
86
+ f as metaSelectTrigger,
87
+ w as metaSelectValue,
88
+ P as metaSelectViewport
119
89
  };
package/lib/switch.js CHANGED
@@ -1,8 +1,11 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import { forwardRef as f } from "react";
3
- import { Thumb as c, Root as h } from "@radix-ui/react-switch";
4
- const d = f(({ defaultChecked: o, checked: r, ...t }, m) => /* @__PURE__ */ e(h, { ...t, ref: m, defaultChecked: r ?? o })), n = c;
1
+ import { jsx as f } from "react/jsx-runtime";
2
+ import { forwardRef as m, useState as n, useEffect as s } from "react";
3
+ import { Thumb as d, Root as u } from "@radix-ui/react-switch";
4
+ const C = m(({ defaultChecked: o, ...t }, r) => {
5
+ const e = t.checked ?? o ?? !1, [h, c] = n(e);
6
+ return s(() => c(e), [e]), /* @__PURE__ */ f(u, { ...t, ref: r, checked: h, onCheckedChange: c });
7
+ }), w = d;
5
8
  export {
6
- d as Switch,
7
- n as SwitchThumb
9
+ C as Switch,
10
+ w as SwitchThumb
8
11
  };
package/lib/switch.ws.js CHANGED
@@ -1,63 +1,40 @@
1
- import { SwitchIcon as e, TriggerIcon as c } from "@webstudio-is/icons/svg";
2
- import { defaultStates as t } from "@webstudio-is/sdk";
3
- import { button as o, span as a } from "@webstudio-is/sdk/normalize.css";
4
- import { radix as s } from "./shared/meta.js";
1
+ import { SwitchIcon as e, TriggerIcon as t } from "@webstudio-is/icons/svg";
2
+ import { button as c, span as o } from "@webstudio-is/sdk/normalize.css";
3
+ import { radix as a } from "./shared/meta.js";
5
4
  import { buttonReset as n } from "./shared/preset-styles.js";
6
- import { propsSwitch as r, propsSwitchThumb as i } from "./__generated__/switch.props.js";
7
- const b = {
5
+ import { propsSwitch as r, propsSwitchThumb as s } from "./__generated__/switch.props.js";
6
+ const m = {
8
7
  icon: e,
9
8
  contentModel: {
10
9
  category: "instance",
11
10
  children: ["instance"],
12
- descendants: [s.SwitchThumb]
11
+ descendants: [a.SwitchThumb]
13
12
  },
14
13
  states: [
15
- ...t,
16
- {
17
- label: "Checked",
18
- selector: "[data-state=checked]",
19
- category: "component-states"
20
- },
21
- {
22
- label: "Unchecked",
23
- selector: "[data-state=unchecked]",
24
- category: "component-states"
25
- }
14
+ { label: "Checked", selector: "[data-state=checked]" },
15
+ { label: "Unchecked", selector: "[data-state=unchecked]" }
26
16
  ],
27
17
  presetStyle: {
28
- button: [o, n].flat()
29
- }
30
- }, S = {
31
- icon: c,
18
+ button: [c, n].flat()
19
+ },
20
+ initialProps: ["id", "class", "name", "value", "checked", "required"],
21
+ props: r
22
+ }, b = {
23
+ icon: t,
32
24
  contentModel: {
33
25
  category: "none",
34
26
  children: ["instance"]
35
27
  },
36
28
  states: [
37
- ...t,
38
- {
39
- label: "Checked",
40
- selector: "[data-state=checked]",
41
- category: "component-states"
42
- },
43
- {
44
- label: "Unchecked",
45
- selector: "[data-state=unchecked]",
46
- category: "component-states"
47
- }
29
+ { label: "Checked", selector: "[data-state=checked]" },
30
+ { label: "Unchecked", selector: "[data-state=unchecked]" }
48
31
  ],
49
32
  presetStyle: {
50
- span: a
51
- }
52
- }, k = {
53
- props: r,
54
- initialProps: ["id", "className", "name", "value", "checked", "required"]
55
- }, f = {
56
- props: i
33
+ span: o
34
+ },
35
+ props: s
57
36
  };
58
37
  export {
59
- b as metaSwitch,
60
- S as metaSwitchThumb,
61
- k as propsMetaSwitch,
62
- f as propsMetaSwitchThumb
38
+ m as metaSwitch,
39
+ b as metaSwitchThumb
63
40
  };