@webstudio-is/sdk-components-react-radix 0.0.0-017f1bd

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 (120) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +4 -0
  3. package/lib/__generated__/accordion.props.js +64 -0
  4. package/lib/__generated__/checkbox.props.js +18 -0
  5. package/lib/__generated__/collapsible.props.js +19 -0
  6. package/lib/__generated__/dialog.props.js +24 -0
  7. package/lib/__generated__/label.props.js +4 -0
  8. package/lib/__generated__/navigation-menu.props.js +48 -0
  9. package/lib/__generated__/popover.props.js +62 -0
  10. package/lib/__generated__/radio-group.props.js +70 -0
  11. package/lib/__generated__/select.props.js +114 -0
  12. package/lib/__generated__/switch.props.js +18 -0
  13. package/lib/__generated__/tabs.props.js +65 -0
  14. package/lib/__generated__/tooltip.props.js +78 -0
  15. package/lib/accordion.js +49 -0
  16. package/lib/accordion.template.js +95 -0
  17. package/lib/accordion.ws.js +80 -0
  18. package/lib/checkbox.js +19 -0
  19. package/lib/checkbox.template.js +63 -0
  20. package/lib/checkbox.ws.js +36 -0
  21. package/lib/collapsible.js +40 -0
  22. package/lib/collapsible.template.js +16 -0
  23. package/lib/collapsible.ws.js +39 -0
  24. package/lib/components.js +63 -0
  25. package/lib/dialog.js +96 -0
  26. package/lib/dialog.template.js +119 -0
  27. package/lib/dialog.ws.js +80 -0
  28. package/lib/hooks.js +21 -0
  29. package/lib/label.js +7 -0
  30. package/lib/label.template.js +23 -0
  31. package/lib/label.ws.js +12 -0
  32. package/lib/metas.js +63 -0
  33. package/lib/navigation-menu.js +60 -0
  34. package/lib/navigation-menu.template.js +283 -0
  35. package/lib/navigation-menu.ws.js +93 -0
  36. package/lib/popover.js +52 -0
  37. package/lib/popover.template.js +63 -0
  38. package/lib/popover.ws.js +51 -0
  39. package/lib/radio-group.js +12 -0
  40. package/lib/radio-group.template.js +66 -0
  41. package/lib/radio-group.ws.js +49 -0
  42. package/lib/select.js +58 -0
  43. package/lib/select.template.js +121 -0
  44. package/lib/select.ws.js +89 -0
  45. package/lib/shared/meta.js +13 -0
  46. package/lib/shared/preset-styles.js +38 -0
  47. package/lib/shared/proxy.js +5 -0
  48. package/lib/shared/styles.js +51 -0
  49. package/lib/shared/theme.js +119 -0
  50. package/lib/sheet.template.js +129 -0
  51. package/lib/switch.js +11 -0
  52. package/lib/switch.template.js +63 -0
  53. package/lib/switch.ws.js +40 -0
  54. package/lib/tabs.js +62 -0
  55. package/lib/tabs.template.js +66 -0
  56. package/lib/tabs.ws.js +53 -0
  57. package/lib/templates.js +28 -0
  58. package/lib/tooltip.js +48 -0
  59. package/lib/tooltip.template.js +33 -0
  60. package/lib/tooltip.ws.js +35 -0
  61. package/lib/types/__generated__/accordion.props.d.ts +6 -0
  62. package/lib/types/__generated__/checkbox.props.d.ts +3 -0
  63. package/lib/types/__generated__/collapsible.props.d.ts +4 -0
  64. package/lib/types/__generated__/dialog.props.d.ts +8 -0
  65. package/lib/types/__generated__/label.props.d.ts +2 -0
  66. package/lib/types/__generated__/navigation-menu.props.d.ts +8 -0
  67. package/lib/types/__generated__/popover.props.d.ts +5 -0
  68. package/lib/types/__generated__/radio-group.props.d.ts +4 -0
  69. package/lib/types/__generated__/select.props.d.ts +9 -0
  70. package/lib/types/__generated__/switch.props.d.ts +3 -0
  71. package/lib/types/__generated__/tabs.props.d.ts +5 -0
  72. package/lib/types/__generated__/tooltip.props.d.ts +4 -0
  73. package/lib/types/accordion.d.ts +11 -0
  74. package/lib/types/accordion.template.d.ts +10 -0
  75. package/lib/types/accordion.ws.d.ts +6 -0
  76. package/lib/types/checkbox.d.ts +9 -0
  77. package/lib/types/checkbox.template.d.ts +2 -0
  78. package/lib/types/checkbox.ws.d.ts +3 -0
  79. package/lib/types/collapsible.d.ts +15 -0
  80. package/lib/types/collapsible.template.d.ts +2 -0
  81. package/lib/types/collapsible.ws.d.ts +4 -0
  82. package/lib/types/components.d.ts +12 -0
  83. package/lib/types/dialog.d.ts +23 -0
  84. package/lib/types/dialog.template.d.ts +10 -0
  85. package/lib/types/dialog.ws.d.ts +8 -0
  86. package/lib/types/hooks.d.ts +2 -0
  87. package/lib/types/label.d.ts +2 -0
  88. package/lib/types/label.template.d.ts +10 -0
  89. package/lib/types/label.ws.d.ts +2 -0
  90. package/lib/types/metas.d.ts +12 -0
  91. package/lib/types/navigation-menu.d.ts +10 -0
  92. package/lib/types/navigation-menu.template.d.ts +2 -0
  93. package/lib/types/navigation-menu.ws.d.ts +8 -0
  94. package/lib/types/popover.d.ts +16 -0
  95. package/lib/types/popover.template.d.ts +10 -0
  96. package/lib/types/popover.ws.d.ts +5 -0
  97. package/lib/types/props-descriptions.d.ts +29 -0
  98. package/lib/types/radio-group.d.ts +5 -0
  99. package/lib/types/radio-group.template.d.ts +2 -0
  100. package/lib/types/radio-group.ws.d.ts +4 -0
  101. package/lib/types/select.d.ts +14 -0
  102. package/lib/types/select.template.d.ts +2 -0
  103. package/lib/types/select.ws.d.ts +9 -0
  104. package/lib/types/shared/meta.d.ts +1 -0
  105. package/lib/types/shared/preset-styles.d.ts +2 -0
  106. package/lib/types/shared/proxy.d.ts +16 -0
  107. package/lib/types/shared/styles.d.ts +2 -0
  108. package/lib/types/shared/theme.d.ts +212 -0
  109. package/lib/types/sheet.template.d.ts +10 -0
  110. package/lib/types/switch.d.ts +4 -0
  111. package/lib/types/switch.template.d.ts +2 -0
  112. package/lib/types/switch.ws.d.ts +3 -0
  113. package/lib/types/tabs.d.ts +10 -0
  114. package/lib/types/tabs.template.d.ts +2 -0
  115. package/lib/types/tabs.ws.d.ts +5 -0
  116. package/lib/types/templates.d.ts +13 -0
  117. package/lib/types/tooltip.d.ts +15 -0
  118. package/lib/types/tooltip.template.d.ts +10 -0
  119. package/lib/types/tooltip.ws.d.ts +4 -0
  120. package/package.json +79 -0
@@ -0,0 +1,95 @@
1
+ import { jsxs as r, jsx as e } from "react/jsx-runtime";
2
+ import { $ as o, PlaceholderValue as s, css as t } from "@webstudio-is/template";
3
+ import { radix as i } from "./shared/proxy.js";
4
+ import { height as h, width as m, transition as a, spacing as c, weights as g, fontSize as f, fontSizeLineHeight as p, borderWidth as w, colors as y } from "./shared/theme.js";
5
+ import { ChevronDownIcon as b } from "@webstudio-is/icons/svg";
6
+ const n = (d, l) => /* @__PURE__ */ r(
7
+ i.AccordionItem,
8
+ {
9
+ "ws:style": t`
10
+ border-bottom: ${w.DEFAULT} solid ${y.border};
11
+ `,
12
+ children: [
13
+ /* @__PURE__ */ e(
14
+ i.AccordionHeader,
15
+ {
16
+ "ws:style": t`
17
+ display: flex;
18
+ `,
19
+ children: /* @__PURE__ */ r(
20
+ i.AccordionTrigger,
21
+ {
22
+ "ws:style": t`
23
+ display: flex;
24
+ flex: 1 1 0;
25
+ align-items: center;
26
+ justify-content: between;
27
+ padding: ${c[4]} 0;
28
+ font-weight: ${g.medium};
29
+ --accordion-trigger-icon-transform: 0deg;
30
+ &:hover {
31
+ text-decoration-line: underline;
32
+ }
33
+ &[data-state="open"] {
34
+ --accordion-trigger-icon-transform: 180deg;
35
+ }
36
+ `,
37
+ children: [
38
+ /* @__PURE__ */ e(o.Text, { children: new s(d) }),
39
+ /* @__PURE__ */ e(
40
+ o.Box,
41
+ {
42
+ "ws:label": "Icon Container",
43
+ "ws:style": t`
44
+ rotate: var(--accordion-trigger-icon-transform);
45
+ height: ${h[4]};
46
+ width: ${m[4]};
47
+ flex-shrink: 0;
48
+ transition: ${a.all};
49
+ transition-duration: 200ms;
50
+ `,
51
+ children: /* @__PURE__ */ e(o.HtmlEmbed, { "ws:label": "Chevron Icon", code: b })
52
+ }
53
+ )
54
+ ]
55
+ }
56
+ )
57
+ }
58
+ ),
59
+ /* @__PURE__ */ e(
60
+ i.AccordionContent,
61
+ {
62
+ "ws:style": t`
63
+ overflow: hidden;
64
+ font-size: ${f.sm};
65
+ line-height: ${p.sm};
66
+ transition: ${a.all};
67
+ padding-bottom: ${c[4]};
68
+ `,
69
+ children: new s(l)
70
+ }
71
+ )
72
+ ]
73
+ }
74
+ ), v = {
75
+ category: "radix",
76
+ description: "A vertically stacked set of interactive headings that each reveal an associated section of content. Clicking on the heading will open the item and close other items.",
77
+ order: 3,
78
+ template: /* @__PURE__ */ r(i.Accordion, { collapsible: !0, value: "0", children: [
79
+ n(
80
+ "Is it accessible?",
81
+ "Yes. It adheres to the WAI-ARIA design pattern."
82
+ ),
83
+ n(
84
+ "Is it styled?",
85
+ "Yes. It comes with default styles that matches the other components' aesthetic."
86
+ ),
87
+ n(
88
+ "Is it animated?",
89
+ "Yes. It's animated by default, but you can disable it if you prefer."
90
+ )
91
+ ] })
92
+ };
93
+ export {
94
+ v as meta
95
+ };
@@ -0,0 +1,80 @@
1
+ import { AccordionIcon as t, ItemIcon as n, HeaderIcon as r, TriggerIcon as c, ContentIcon as i } from "@webstudio-is/icons/svg";
2
+ import { div as o, h3 as a, button as p } from "@webstudio-is/sdk/normalize.css";
3
+ import { radix as e } from "./shared/meta.js";
4
+ import { buttonReset as d } from "./shared/preset-styles.js";
5
+ import { propsAccordion as s, propsAccordionItem as l, propsAccordionHeader as m, propsAccordionTrigger as g, propsAccordionContent as A } from "./__generated__/accordion.props.js";
6
+ const v = {
7
+ icon: t,
8
+ contentModel: {
9
+ category: "instance",
10
+ children: ["instance"],
11
+ descendants: [e.AccordionItem]
12
+ },
13
+ presetStyle: { div: o },
14
+ initialProps: ["value", "collapsible"],
15
+ props: s
16
+ }, x = {
17
+ label: "Item",
18
+ icon: n,
19
+ indexWithinAncestor: e.Accordion,
20
+ contentModel: {
21
+ category: "none",
22
+ children: ["instance"],
23
+ descendants: [e.AccordionHeader, e.AccordionContent]
24
+ },
25
+ presetStyle: { div: o },
26
+ initialProps: ["value"],
27
+ props: l
28
+ }, f = {
29
+ label: "Item Header",
30
+ icon: r,
31
+ contentModel: {
32
+ category: "none",
33
+ children: ["instance"],
34
+ descendants: [e.AccordionTrigger]
35
+ },
36
+ presetStyle: {
37
+ h3: [
38
+ ...a,
39
+ {
40
+ property: "margin-top",
41
+ value: { type: "unit", unit: "px", value: 0 }
42
+ },
43
+ {
44
+ property: "margin-bottom",
45
+ value: { type: "unit", unit: "px", value: 0 }
46
+ }
47
+ ]
48
+ },
49
+ props: m
50
+ }, C = {
51
+ label: "Item Trigger",
52
+ icon: c,
53
+ contentModel: {
54
+ category: "none",
55
+ children: ["instance", "rich-text"]
56
+ },
57
+ states: [{ label: "Open", selector: "[data-state=open]" }],
58
+ presetStyle: {
59
+ button: [p, d].flat()
60
+ },
61
+ props: g
62
+ }, H = {
63
+ label: "Item Content",
64
+ icon: i,
65
+ contentModel: {
66
+ category: "none",
67
+ children: ["instance", "rich-text"]
68
+ },
69
+ presetStyle: {
70
+ div: o
71
+ },
72
+ props: A
73
+ };
74
+ export {
75
+ v as metaAccordion,
76
+ H as metaAccordionContent,
77
+ f as metaAccordionHeader,
78
+ x as metaAccordionItem,
79
+ C as metaAccordionTrigger
80
+ };
@@ -0,0 +1,19 @@
1
+ import { jsx as f } from "react/jsx-runtime";
2
+ import { forwardRef as h, useState as s, useEffect as k } from "react";
3
+ import { Indicator as a, Root as m } from "@radix-ui/react-checkbox";
4
+ const x = h(({ defaultChecked: c, ...o }, r) => {
5
+ const e = o.checked ?? c ?? !1, [n, t] = s(e);
6
+ return k(() => t(e), [e]), /* @__PURE__ */ f(
7
+ m,
8
+ {
9
+ ...o,
10
+ ref: r,
11
+ checked: n,
12
+ onCheckedChange: (d) => t(d === !0)
13
+ }
14
+ );
15
+ }), b = a;
16
+ export {
17
+ x as Checkbox,
18
+ b as CheckboxIndicator
19
+ };
@@ -0,0 +1,63 @@
1
+ import { jsxs as c, jsx as e } from "react/jsx-runtime";
2
+ import { CheckMarkIcon as a } from "@webstudio-is/icons/svg";
3
+ import { $ as t, css as o, PlaceholderValue as l } from "@webstudio-is/template";
4
+ import { radix as r } from "./shared/proxy.js";
5
+ import { height as s, width as d, borderRadius as n, borderWidth as h, colors as i, boxShadow as b, opacity as m, spacing as p } from "./shared/theme.js";
6
+ const y = {
7
+ category: "radix",
8
+ description: "Use within a form to allow your users to toggle between checked and not checked. Group checkboxes by matching their “Name” properties. Unlike radios, any number of checkboxes in a group can be checked.",
9
+ order: 101,
10
+ template: /* @__PURE__ */ c(
11
+ r.Label,
12
+ {
13
+ "ws:label": "Checkbox Field",
14
+ "ws:style": o`
15
+ display: flex;
16
+ gap: ${p[2]};
17
+ align-items: center;
18
+ `,
19
+ children: [
20
+ /* @__PURE__ */ e(
21
+ r.Checkbox,
22
+ {
23
+ "ws:style": o`
24
+ height: ${s[4]};
25
+ width: ${d[4]};
26
+ flex-shrink: 0;
27
+ border-radius: ${n.sm};
28
+ border: ${h.DEFAULT} solid ${i.primary};
29
+ &:focus-visible {
30
+ outline: none;
31
+ box-shadow: ${b.ring};
32
+ }
33
+ &:disabled {
34
+ cursor: not-allowed;
35
+ opacity: ${m[50]};
36
+ }
37
+ &[data-state="checked"] {
38
+ background-color: ${i.primary};
39
+ color: ${i.primaryForeground};
40
+ }
41
+ `,
42
+ children: /* @__PURE__ */ e(
43
+ r.CheckboxIndicator,
44
+ {
45
+ "ws:style": o`
46
+ display: flex;
47
+ align-items: center;
48
+ justify-content: center;
49
+ color: currentColor;
50
+ `,
51
+ children: /* @__PURE__ */ e(t.HtmlEmbed, { "ws:label": "Indicator Icon", code: a })
52
+ }
53
+ )
54
+ }
55
+ ),
56
+ /* @__PURE__ */ e(t.Text, { "ws:label": "Checkbox Label", "ws:tag": "span", children: new l("Checkbox") })
57
+ ]
58
+ }
59
+ )
60
+ };
61
+ export {
62
+ y as meta
63
+ };
@@ -0,0 +1,36 @@
1
+ import { CheckboxCheckedIcon as e, TriggerIcon as t } from "@webstudio-is/icons/svg";
2
+ import { button as o, span as c } from "@webstudio-is/sdk/normalize.css";
3
+ import { radix as n } from "./shared/meta.js";
4
+ import { buttonReset as r } from "./shared/preset-styles.js";
5
+ import { propsCheckbox as a, propsCheckboxIndicator as s } from "./__generated__/checkbox.props.js";
6
+ const m = {
7
+ icon: e,
8
+ contentModel: {
9
+ category: "instance",
10
+ children: ["instance"],
11
+ descendants: [n.CheckboxIndicator]
12
+ },
13
+ states: [
14
+ { label: "Checked", selector: "[data-state=checked]" },
15
+ { label: "Unchecked", selector: "[data-state=unchecked]" }
16
+ ],
17
+ presetStyle: {
18
+ button: [o, r].flat()
19
+ },
20
+ initialProps: ["id", "class", "name", "value", "required", "checked"],
21
+ props: a
22
+ }, k = {
23
+ icon: t,
24
+ contentModel: {
25
+ category: "none",
26
+ children: ["instance", "rich-text"]
27
+ },
28
+ presetStyle: {
29
+ span: c
30
+ },
31
+ props: s
32
+ };
33
+ export {
34
+ m as metaCheckbox,
35
+ k as metaCheckboxIndicator
36
+ };
@@ -0,0 +1,40 @@
1
+ import { jsx as l } from "react/jsx-runtime";
2
+ import { forwardRef as a, useState as c, useEffect as p, Children as f } from "react";
3
+ import { Content as C, Root as m, Trigger as b } from "@radix-ui/react-collapsible";
4
+ import { getClosestInstance as r } from "@webstudio-is/react-sdk/runtime";
5
+ const P = a((n, t) => {
6
+ const o = n.open ?? !1, [e, i] = c(o);
7
+ return p(() => i(o), [o]), /* @__PURE__ */ l(m, { ...n, ref: t, open: e, onOpenChange: i });
8
+ }), $ = a(({ children: n, ...t }, o) => {
9
+ const e = f.toArray(n)[0];
10
+ return /* @__PURE__ */ l(b, { asChild: !0, ref: o, ...t, children: e ?? /* @__PURE__ */ l("button", { children: "Add button" }) });
11
+ }), x = C, s = "@webstudio-is/sdk-components-react-radix", y = {
12
+ onNavigatorSelect: (n, t) => {
13
+ for (const o of t.instancePath)
14
+ if (o.component === `${s}:CollapsibleContent`) {
15
+ const e = r(
16
+ t.instancePath,
17
+ o,
18
+ `${s}:Collapsible`
19
+ );
20
+ e && n.setMemoryProp(e, "open", !0);
21
+ }
22
+ },
23
+ onNavigatorUnselect: (n, t) => {
24
+ for (const o of t.instancePath)
25
+ if (o.component === `${s}:CollapsibleContent`) {
26
+ const e = r(
27
+ t.instancePath,
28
+ o,
29
+ `${s}:Collapsible`
30
+ );
31
+ e && n.setMemoryProp(e, "open", void 0);
32
+ }
33
+ }
34
+ };
35
+ export {
36
+ P as Collapsible,
37
+ x as CollapsibleContent,
38
+ $ as CollapsibleTrigger,
39
+ y as hooksCollapsible
40
+ };
@@ -0,0 +1,16 @@
1
+ import { jsxs as n, jsx as e } from "react/jsx-runtime";
2
+ import { $ as o, PlaceholderValue as l } from "@webstudio-is/template";
3
+ import { radix as t } from "./shared/proxy.js";
4
+ import { getButtonStyle as r } from "./shared/styles.js";
5
+ const p = {
6
+ category: "radix",
7
+ description: "An interactive component which expands and collapses some content, triggered by a button.",
8
+ order: 5,
9
+ template: /* @__PURE__ */ n(t.Collapsible, { children: [
10
+ /* @__PURE__ */ e(t.CollapsibleTrigger, { children: /* @__PURE__ */ e(o.Button, { "ws:style": r("outline"), children: new l("Click to toggle content") }) }),
11
+ /* @__PURE__ */ e(t.CollapsibleContent, { children: /* @__PURE__ */ e(o.Text, { children: new l("Collapsible Content") }) })
12
+ ] })
13
+ };
14
+ export {
15
+ p as meta
16
+ };
@@ -0,0 +1,39 @@
1
+ import { CollapsibleIcon as n, TriggerIcon as t, ContentIcon as l } from "@webstudio-is/icons/svg";
2
+ import { div as o } from "@webstudio-is/sdk/normalize.css";
3
+ import { radix as e } from "./shared/meta.js";
4
+ import { propsCollapsible as r, propsCollapsibleTrigger as i, propsCollapsibleContent as p } from "./__generated__/collapsible.props.js";
5
+ const g = {
6
+ icon: n,
7
+ contentModel: {
8
+ category: "instance",
9
+ children: ["instance"],
10
+ descendants: [e.CollapsibleTrigger, e.CollapsibleContent]
11
+ },
12
+ presetStyle: {
13
+ div: o
14
+ },
15
+ initialProps: ["open"],
16
+ props: r
17
+ }, m = {
18
+ icon: t,
19
+ contentModel: {
20
+ category: "none",
21
+ children: ["instance", "rich-text"]
22
+ },
23
+ props: i
24
+ }, d = {
25
+ icon: l,
26
+ contentModel: {
27
+ category: "none",
28
+ children: ["instance", "rich-text"]
29
+ },
30
+ presetStyle: {
31
+ div: o
32
+ },
33
+ props: p
34
+ };
35
+ export {
36
+ g as metaCollapsible,
37
+ d as metaCollapsibleContent,
38
+ m as metaCollapsibleTrigger
39
+ };
@@ -0,0 +1,63 @@
1
+ import { Collapsible as t, CollapsibleContent as r, CollapsibleTrigger as i } from "./collapsible.js";
2
+ import { Dialog as a, DialogClose as l, DialogContent as g, DialogDescription as p, DialogOverlay as c, DialogTitle as m, DialogTrigger as T } from "./dialog.js";
3
+ import { Popover as C, PopoverClose as d, PopoverContent as f, PopoverTrigger as s } from "./popover.js";
4
+ import { Tooltip as v, TooltipContent as b, TooltipTrigger as S } from "./tooltip.js";
5
+ import { Tabs as D, TabsContent as M, TabsList as N, TabsTrigger as h } from "./tabs.js";
6
+ import { Label as w } from "./label.js";
7
+ import { Accordion as P, AccordionContent as k, AccordionHeader as G, AccordionItem as R, AccordionTrigger as V } from "./accordion.js";
8
+ import { NavigationMenu as H, NavigationMenuContent as O, NavigationMenuItem as j, NavigationMenuLink as q, NavigationMenuList as z, NavigationMenuTrigger as B, NavigationMenuViewport as E } from "./navigation-menu.js";
9
+ import { Select as J, SelectContent as K, SelectItem as Q, SelectItemIndicator as U, SelectItemText as W, SelectTrigger as X, SelectValue as Y, SelectViewport as Z } from "./select.js";
10
+ import { Switch as $, SwitchThumb as oo } from "./switch.js";
11
+ import { Checkbox as to, CheckboxIndicator as ro } from "./checkbox.js";
12
+ import { RadioGroup as no, RadioGroupIndicator as ao, RadioGroupItem as lo } from "./radio-group.js";
13
+ export {
14
+ P as Accordion,
15
+ k as AccordionContent,
16
+ G as AccordionHeader,
17
+ R as AccordionItem,
18
+ V as AccordionTrigger,
19
+ to as Checkbox,
20
+ ro as CheckboxIndicator,
21
+ t as Collapsible,
22
+ r as CollapsibleContent,
23
+ i as CollapsibleTrigger,
24
+ a as Dialog,
25
+ l as DialogClose,
26
+ g as DialogContent,
27
+ p as DialogDescription,
28
+ c as DialogOverlay,
29
+ m as DialogTitle,
30
+ T as DialogTrigger,
31
+ w as Label,
32
+ H as NavigationMenu,
33
+ O as NavigationMenuContent,
34
+ j as NavigationMenuItem,
35
+ q as NavigationMenuLink,
36
+ z as NavigationMenuList,
37
+ B as NavigationMenuTrigger,
38
+ E as NavigationMenuViewport,
39
+ C as Popover,
40
+ d as PopoverClose,
41
+ f as PopoverContent,
42
+ s as PopoverTrigger,
43
+ no as RadioGroup,
44
+ ao as RadioGroupIndicator,
45
+ lo as RadioGroupItem,
46
+ J as Select,
47
+ K as SelectContent,
48
+ Q as SelectItem,
49
+ U as SelectItemIndicator,
50
+ W as SelectItemText,
51
+ X as SelectTrigger,
52
+ Y as SelectValue,
53
+ Z as SelectViewport,
54
+ $ as Switch,
55
+ oo as SwitchThumb,
56
+ D as Tabs,
57
+ M as TabsContent,
58
+ N as TabsList,
59
+ h as TabsTrigger,
60
+ v as Tooltip,
61
+ b as TooltipContent,
62
+ S as TooltipTrigger
63
+ };
package/lib/dialog.js ADDED
@@ -0,0 +1,96 @@
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import v from "await-interaction-response";
3
+ import { forwardRef as c, useContext as p, useState as k, useEffect as d, useCallback as w, Children as y, useRef as A } from "react";
4
+ import * as a from "@radix-ui/react-dialog";
5
+ import { ReactSdkContext as D, getClosestInstance as m } from "@webstudio-is/react-sdk/runtime";
6
+ const C = (t) => {
7
+ const { target: e } = t;
8
+ return !(!(e instanceof HTMLAnchorElement) || e.hasAttribute("href") === !1 || e.href === "#" || e.hasAttribute("target") && e.target === "_blank" || t.ctrlKey || t.metaKey);
9
+ }, O = c((t, e) => {
10
+ const { renderer: n } = p(D), o = t.open ?? !1, [r, l] = k(o);
11
+ d(() => l(o), [o]);
12
+ const i = w(async (f) => {
13
+ await v(), l(f);
14
+ }, []);
15
+ return d(() => {
16
+ if (n !== void 0 || r === !1)
17
+ return;
18
+ const f = (g) => {
19
+ const { target: h } = g;
20
+ if (C(g) !== !1) {
21
+ if (!(h instanceof HTMLAnchorElement))
22
+ return !1;
23
+ h.closest('[role="dialog"]') && (i == null || i(!1));
24
+ }
25
+ };
26
+ return window.addEventListener("click", f), () => window.removeEventListener("click", f);
27
+ }, [r, i, n]), /* @__PURE__ */ s(
28
+ a.Root,
29
+ {
30
+ ...t,
31
+ onOpenChange: i,
32
+ open: r
33
+ }
34
+ );
35
+ }), x = c(({ children: t, ...e }, n) => {
36
+ const o = y.toArray(t)[0];
37
+ return /* @__PURE__ */ s(a.Trigger, { ref: n, asChild: !0, ...e, children: o ?? /* @__PURE__ */ s("button", { children: "Add button or link" }) });
38
+ }), M = c((t, e) => /* @__PURE__ */ s(a.DialogPortal, { children: /* @__PURE__ */ s(a.Overlay, { ref: e, ...t }) })), R = c((t, e) => {
39
+ const n = A(!1), { renderer: o } = p(D);
40
+ return d(() => {
41
+ if (o !== void 0)
42
+ return;
43
+ n.current = !1;
44
+ const r = (l) => {
45
+ const { target: i } = l;
46
+ if (C(l) !== !1) {
47
+ if (!(i instanceof HTMLAnchorElement))
48
+ return !1;
49
+ i.closest('[role="dialog"]') && (n.current = !0);
50
+ }
51
+ };
52
+ return window.addEventListener("click", r), () => window.removeEventListener("click", r);
53
+ }, [o]), /* @__PURE__ */ s(
54
+ a.Content,
55
+ {
56
+ ref: e,
57
+ ...t,
58
+ onCloseAutoFocus: (r) => {
59
+ n.current && r.preventDefault();
60
+ }
61
+ }
62
+ );
63
+ }), $ = a.Close, E = "h1", N = c(({ tag: t = E, children: e, ...n }, o) => /* @__PURE__ */ s(a.DialogTitle, { asChild: !0, children: /* @__PURE__ */ s(t, { ref: o, ...n, children: e }) })), S = a.Description, u = "@webstudio-is/sdk-components-react-radix", F = {
64
+ onNavigatorUnselect: (t, e) => {
65
+ for (const n of e.instancePath)
66
+ if (n.component === `${u}:DialogOverlay`) {
67
+ const o = m(
68
+ e.instancePath,
69
+ n,
70
+ `${u}:Dialog`
71
+ );
72
+ o && t.setMemoryProp(o, "open", void 0);
73
+ }
74
+ },
75
+ onNavigatorSelect: (t, e) => {
76
+ for (const n of e.instancePath)
77
+ if (n.component === `${u}:DialogOverlay`) {
78
+ const o = m(
79
+ e.instancePath,
80
+ n,
81
+ `${u}:Dialog`
82
+ );
83
+ o && t.setMemoryProp(o, "open", !0);
84
+ }
85
+ }
86
+ };
87
+ export {
88
+ O as Dialog,
89
+ $ as DialogClose,
90
+ R as DialogContent,
91
+ S as DialogDescription,
92
+ M as DialogOverlay,
93
+ N as DialogTitle,
94
+ x as DialogTrigger,
95
+ F as hooksDialog
96
+ };
@@ -0,0 +1,119 @@
1
+ import { jsxs as n, jsx as e } from "react/jsx-runtime";
2
+ import { LargeXIcon as p } from "@webstudio-is/icons/svg";
3
+ import { $ as l, PlaceholderValue as r, css as i } from "@webstudio-is/template";
4
+ import { radix as o } from "./shared/proxy.js";
5
+ import { fontSize as d, lineHeight as m, letterSpacing as u, fontSizeLineHeight as w, colors as a, spacing as t, borderRadius as $, opacity as s, height as c, boxShadow as g, width as y, zIndex as h, maxWidth as b, borderWidth as x, blur as f } from "./shared/theme.js";
6
+ import { getButtonStyle as D } from "./shared/styles.js";
7
+ const S = {
8
+ category: "radix",
9
+ description: "Displays content with an overlay that covers the window, triggered by a button. Clicking the overlay will close the dialog.",
10
+ order: 4,
11
+ template: /* @__PURE__ */ n(o.Dialog, { children: [
12
+ /* @__PURE__ */ e(o.DialogTrigger, { children: /* @__PURE__ */ e(l.Button, { "ws:style": D("outline"), children: new r("Button") }) }),
13
+ /* @__PURE__ */ e(
14
+ o.DialogOverlay,
15
+ {
16
+ "ws:style": i`
17
+ position: fixed;
18
+ inset: 0;
19
+ z-index: ${h[50]};
20
+ background-color: rgb(255 255 255 / 0.8);
21
+ backdrop-filter: ${f.sm};
22
+ /* To allow positioning Content */
23
+ display: flex;
24
+ overflow: auto;
25
+ `,
26
+ children: /* @__PURE__ */ n(
27
+ o.DialogContent,
28
+ {
29
+ "ws:style": i`
30
+ width: ${y.full};
31
+ z-index: ${h[50]};
32
+ display: flex;
33
+ flex-direction: column;
34
+ gap: ${t[4]};
35
+ margin: auto;
36
+ max-width: ${b.lg};
37
+ border: ${x.DEFAULT} solid ${a.border};
38
+ background-color: ${a.background};
39
+ padding: ${t[6]};
40
+ box-shadow: ${g.lg};
41
+ position: relative;
42
+ `,
43
+ children: [
44
+ /* @__PURE__ */ n(
45
+ l.Box,
46
+ {
47
+ "ws:label": "Dialog Header",
48
+ "ws:style": i`
49
+ display: flex;
50
+ flex-direction: column;
51
+ gap: ${t[2]};
52
+ `,
53
+ children: [
54
+ /* @__PURE__ */ e(
55
+ o.DialogTitle,
56
+ {
57
+ "ws:style": i`
58
+ font-size: ${d.lg};
59
+ line-height: ${m.none};
60
+ letter-spacing: ${u.tight};
61
+ margin: 0;
62
+ `,
63
+ children: new r("Dialog Title you can edit")
64
+ }
65
+ ),
66
+ /* @__PURE__ */ e(
67
+ o.DialogDescription,
68
+ {
69
+ "ws:style": i`
70
+ font-size: ${d.sm};
71
+ line-height: ${w.sm};
72
+ color: ${a.mutedForeground};
73
+ margin: 0;
74
+ `,
75
+ children: new r("Dialog description text you can edit")
76
+ }
77
+ )
78
+ ]
79
+ }
80
+ ),
81
+ /* @__PURE__ */ e(l.Text, { children: new r("The text you can edit") }),
82
+ /* @__PURE__ */ e(
83
+ o.DialogClose,
84
+ {
85
+ "ws:label": "Close Button",
86
+ "ws:style": i`
87
+ position: absolute;
88
+ right: ${t[4]};
89
+ top: ${t[4]};
90
+ border-radius: ${$.sm};
91
+ opacity: ${s[70]};
92
+ display: flex;
93
+ align-items: center;
94
+ justify-content: center;
95
+ height: ${c[4]};
96
+ width: ${c[4]};
97
+ border: 0;
98
+ background-color: transparent;
99
+ outline: none;
100
+ &:hover {
101
+ opacity: ${s[100]};
102
+ }
103
+ &:focus-visible {
104
+ box-shadow: ${g.ring};
105
+ }
106
+ `,
107
+ children: /* @__PURE__ */ e(l.HtmlEmbed, { "ws:label": "Close Icon", code: p })
108
+ }
109
+ )
110
+ ]
111
+ }
112
+ )
113
+ }
114
+ )
115
+ ] })
116
+ };
117
+ export {
118
+ S as meta
119
+ };