@webstudio-is/sdk-components-react-radix 0.87.1 → 0.89.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 (192) hide show
  1. package/lib/__generated__/accordion.props.js +605 -114
  2. package/lib/__generated__/button.props.js +158 -47
  3. package/lib/__generated__/checkbox.props.js +1083 -0
  4. package/lib/__generated__/collapsible.props.js +234 -44
  5. package/lib/__generated__/dialog.props.js +611 -121
  6. package/lib/__generated__/input.props.js +264 -47
  7. package/lib/__generated__/label.props.js +123 -23
  8. package/lib/__generated__/navigation-menu.props.js +2565 -0
  9. package/lib/__generated__/popover.props.js +129 -28
  10. package/lib/__generated__/radio-group.props.js +1627 -0
  11. package/lib/__generated__/select.props.js +3678 -0
  12. package/lib/__generated__/sheet.props.js +591 -121
  13. package/lib/__generated__/switch.props.js +1083 -0
  14. package/lib/__generated__/tabs.props.js +906 -68
  15. package/lib/__generated__/textarea.props.js +177 -31
  16. package/lib/__generated__/tooltip.props.js +131 -29
  17. package/lib/accordion.js +11 -4
  18. package/lib/accordion.ws.js +88 -72
  19. package/lib/checkbox.js +13 -0
  20. package/lib/checkbox.ws.js +153 -0
  21. package/lib/cjs/__generated__/accordion.props.js +605 -114
  22. package/lib/cjs/__generated__/button.props.js +158 -47
  23. package/lib/cjs/__generated__/checkbox.props.js +1103 -0
  24. package/lib/cjs/__generated__/collapsible.props.js +234 -44
  25. package/lib/cjs/__generated__/dialog.props.js +611 -121
  26. package/lib/cjs/__generated__/input.props.js +264 -47
  27. package/lib/cjs/__generated__/label.props.js +123 -23
  28. package/lib/cjs/__generated__/navigation-menu.props.js +2585 -0
  29. package/lib/cjs/__generated__/popover.props.js +129 -28
  30. package/lib/cjs/__generated__/radio-group.props.js +1647 -0
  31. package/lib/cjs/__generated__/select.props.js +3698 -0
  32. package/lib/cjs/__generated__/sheet.props.js +591 -121
  33. package/lib/cjs/__generated__/switch.props.js +1103 -0
  34. package/lib/cjs/__generated__/tabs.props.js +906 -68
  35. package/lib/cjs/__generated__/textarea.props.js +177 -31
  36. package/lib/cjs/__generated__/tooltip.props.js +131 -29
  37. package/lib/cjs/accordion.js +11 -4
  38. package/lib/cjs/accordion.ws.js +86 -71
  39. package/lib/cjs/{textarea.js → checkbox.js} +9 -6
  40. package/lib/cjs/checkbox.ws.js +174 -0
  41. package/lib/cjs/collapsible.ws.js +5 -1
  42. package/lib/cjs/components.js +27 -14
  43. package/lib/cjs/dialog.ws.js +18 -17
  44. package/lib/cjs/hooks.js +5 -1
  45. package/lib/cjs/label.ws.js +2 -1
  46. package/lib/cjs/metas.js +29 -14
  47. package/lib/cjs/navigation-menu.js +107 -0
  48. package/lib/cjs/navigation-menu.ws.js +514 -0
  49. package/lib/cjs/popover.ws.js +13 -9
  50. package/lib/cjs/props-descriptions.js +56 -0
  51. package/lib/cjs/props.js +27 -14
  52. package/lib/cjs/{button.js → radio-group.js} +10 -8
  53. package/lib/cjs/radio-group.ws.js +191 -0
  54. package/lib/cjs/select.js +83 -0
  55. package/lib/cjs/select.ws.js +350 -0
  56. package/lib/cjs/sheet.ws.js +88 -176
  57. package/lib/cjs/{input.js → switch.js} +8 -9
  58. package/lib/cjs/switch.ws.js +173 -0
  59. package/lib/cjs/tabs.js +2 -3
  60. package/lib/cjs/tabs.ws.js +14 -18
  61. package/lib/cjs/theme/styles.js +100 -0
  62. package/lib/cjs/theme/tailwind-classes.js +125 -16
  63. package/lib/cjs/theme/tailwind-colors.js +1 -0
  64. package/lib/cjs/tooltip.ws.js +12 -8
  65. package/lib/collapsible.ws.js +5 -1
  66. package/lib/components.js +44 -22
  67. package/lib/dialog.ws.js +18 -17
  68. package/lib/hooks.js +5 -1
  69. package/lib/label.ws.js +2 -1
  70. package/lib/metas.js +58 -24
  71. package/lib/navigation-menu.js +85 -0
  72. package/lib/navigation-menu.ws.js +501 -0
  73. package/lib/popover.ws.js +13 -9
  74. package/lib/props-descriptions.js +36 -0
  75. package/lib/props.js +56 -24
  76. package/lib/radio-group.js +11 -0
  77. package/lib/radio-group.ws.js +173 -0
  78. package/lib/select.js +75 -0
  79. package/lib/select.ws.js +338 -0
  80. package/lib/sheet.ws.js +89 -194
  81. package/lib/switch.js +7 -0
  82. package/lib/switch.ws.js +145 -0
  83. package/lib/tabs.js +3 -5
  84. package/lib/tabs.ws.js +15 -19
  85. package/lib/theme/styles.js +70 -0
  86. package/lib/theme/tailwind-classes.js +125 -16
  87. package/lib/theme/tailwind-colors.js +1 -0
  88. package/lib/tooltip.ws.js +12 -8
  89. package/lib/types/__generated__/checkbox.props.d.ts +3 -0
  90. package/lib/types/__generated__/navigation-menu.props.d.ts +8 -0
  91. package/lib/types/__generated__/radio-group.props.d.ts +4 -0
  92. package/lib/types/__generated__/select.props.d.ts +9 -0
  93. package/lib/types/__generated__/switch.props.d.ts +3 -0
  94. package/lib/types/checkbox.d.ts +6 -0
  95. package/lib/types/checkbox.stories.d.ts +11 -0
  96. package/lib/types/checkbox.ws.d.ts +5 -0
  97. package/lib/types/components.d.ts +5 -4
  98. package/lib/types/metas.d.ts +6 -4
  99. package/lib/types/navigation-menu.d.ts +15 -0
  100. package/lib/types/navigation-menu.ws.d.ts +15 -0
  101. package/lib/types/props-descriptions.d.ts +29 -0
  102. package/lib/types/props.d.ts +5 -4
  103. package/lib/types/radio-group.d.ts +5 -0
  104. package/lib/types/radio-group.stories.d.ts +9 -0
  105. package/lib/types/radio-group.ws.d.ts +7 -0
  106. package/lib/types/select.d.ts +14 -0
  107. package/lib/types/select.ws.d.ts +17 -0
  108. package/lib/types/sheet.ws.d.ts +2 -15
  109. package/lib/types/switch.d.ts +4 -0
  110. package/lib/types/switch.stories.d.ts +9 -0
  111. package/lib/types/switch.ws.d.ts +5 -0
  112. package/lib/types/tabs.d.ts +3 -12
  113. package/lib/types/theme/radix-common-types.d.ts +3 -2
  114. package/lib/types/theme/styles.d.ts +215 -0
  115. package/lib/types/theme/tailwind-classes.d.ts +16 -6
  116. package/lib/types/theme/tailwind-colors.d.ts +1 -0
  117. package/lib/types/theme/tailwind-theme.d.ts +1 -1
  118. package/package.json +12 -7
  119. package/src/__generated__/accordion.props.ts +675 -108
  120. package/src/__generated__/button.props.ts +177 -45
  121. package/src/__generated__/checkbox.props.ts +1217 -0
  122. package/src/__generated__/collapsible.props.ts +261 -42
  123. package/src/__generated__/dialog.props.ts +682 -115
  124. package/src/__generated__/input.props.ts +292 -44
  125. package/src/__generated__/label.props.ts +137 -22
  126. package/src/__generated__/navigation-menu.props.ts +2882 -0
  127. package/src/__generated__/popover.props.ts +142 -24
  128. package/src/__generated__/radio-group.props.ts +1828 -0
  129. package/src/__generated__/select.props.ts +4130 -0
  130. package/src/__generated__/sheet.props.ts +657 -110
  131. package/src/__generated__/switch.props.ts +1217 -0
  132. package/src/__generated__/tabs.props.ts +1019 -67
  133. package/src/__generated__/textarea.props.ts +195 -30
  134. package/src/__generated__/tooltip.props.ts +145 -25
  135. package/src/accordion.tsx +14 -7
  136. package/src/accordion.ws.ts +87 -70
  137. package/src/{textarea.stories.ts → checkbox.stories.ts} +6 -11
  138. package/src/checkbox.tsx +22 -0
  139. package/src/checkbox.ws.ts +154 -0
  140. package/src/collapsible.ws.ts +6 -1
  141. package/src/components.ts +25 -12
  142. package/src/dialog.ws.tsx +17 -16
  143. package/src/hooks.ts +4 -0
  144. package/src/label.ws.ts +3 -1
  145. package/src/metas.ts +36 -12
  146. package/src/navigation-menu.stories.tsx +21 -0
  147. package/src/navigation-menu.tsx +130 -0
  148. package/src/navigation-menu.ws.ts +524 -0
  149. package/src/popover.ws.tsx +13 -9
  150. package/src/props-descriptions.ts +43 -0
  151. package/src/props.ts +35 -12
  152. package/src/{input.stories.ts → radio-group.stories.ts} +6 -15
  153. package/src/radio-group.tsx +17 -0
  154. package/src/radio-group.ws.ts +178 -0
  155. package/src/select.stories.tsx +21 -0
  156. package/src/select.tsx +112 -0
  157. package/src/select.ws.ts +349 -0
  158. package/src/sheet.ws.tsx +91 -209
  159. package/src/{button.stories.ts → switch.stories.ts} +6 -19
  160. package/src/switch.tsx +10 -0
  161. package/src/switch.ws.ts +146 -0
  162. package/src/tabs.tsx +4 -17
  163. package/src/tabs.ws.ts +19 -19
  164. package/src/theme/radix-common-types.ts +3 -2
  165. package/src/theme/styles.ts +80 -0
  166. package/src/theme/tailwind-classes.ts +150 -14
  167. package/src/theme/tailwind-colors.ts +1 -0
  168. package/src/tooltip.ws.tsx +13 -8
  169. package/lib/button.js +0 -8
  170. package/lib/button.ws.js +0 -133
  171. package/lib/cjs/button.ws.js +0 -160
  172. package/lib/cjs/input.ws.js +0 -103
  173. package/lib/cjs/textarea.ws.js +0 -98
  174. package/lib/input.js +0 -8
  175. package/lib/input.ws.js +0 -75
  176. package/lib/textarea.js +0 -8
  177. package/lib/textarea.ws.js +0 -70
  178. package/lib/types/button.d.ts +0 -7
  179. package/lib/types/button.stories.d.ts +0 -20
  180. package/lib/types/button.ws.d.ts +0 -7
  181. package/lib/types/input.d.ts +0 -2
  182. package/lib/types/input.stories.d.ts +0 -20
  183. package/lib/types/input.ws.d.ts +0 -3
  184. package/lib/types/textarea.d.ts +0 -2
  185. package/lib/types/textarea.stories.d.ts +0 -14
  186. package/lib/types/textarea.ws.d.ts +0 -3
  187. package/src/button.tsx +0 -25
  188. package/src/button.ws.ts +0 -155
  189. package/src/input.tsx +0 -12
  190. package/src/input.ws.ts +0 -78
  191. package/src/textarea.tsx +0 -12
  192. package/src/textarea.ws.ts +0 -74
@@ -0,0 +1,145 @@
1
+ import { SwitchIcon, TriggerIcon } from "@webstudio-is/icons/svg";
2
+ import {
3
+ defaultStates
4
+ } from "@webstudio-is/react-sdk";
5
+ import { button, span } from "@webstudio-is/react-sdk/css-normalize";
6
+ import * as tc from "./theme/tailwind-classes";
7
+ import { buttonReset } from "./theme/styles";
8
+ import { propsSwitch, propsSwitchThumb } from "./__generated__/switch.props";
9
+ const metaSwitch = {
10
+ category: "radix",
11
+ order: 11,
12
+ type: "container",
13
+ description: "A control that allows the user to toggle between checked and not checked.",
14
+ icon: SwitchIcon,
15
+ states: [
16
+ ...defaultStates,
17
+ {
18
+ label: "Checked",
19
+ selector: "[data-state=checked]",
20
+ category: "component-states"
21
+ },
22
+ {
23
+ label: "Unchecked",
24
+ selector: "[data-state=unchecked]",
25
+ category: "component-states"
26
+ }
27
+ ],
28
+ presetStyle: {
29
+ button: [button, buttonReset].flat()
30
+ },
31
+ template: [
32
+ {
33
+ type: "instance",
34
+ component: "Switch",
35
+ dataSources: {
36
+ switchChecked: { type: "variable", initialValue: false }
37
+ },
38
+ props: [
39
+ {
40
+ name: "checked",
41
+ type: "dataSource",
42
+ dataSourceName: "switchChecked"
43
+ },
44
+ {
45
+ name: "onCheckedChange",
46
+ type: "action",
47
+ value: [
48
+ {
49
+ type: "execute",
50
+ args: ["checked"],
51
+ code: `switchChecked = checked`
52
+ }
53
+ ]
54
+ }
55
+ ],
56
+ // peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors
57
+ // focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background
58
+ // disabled:cursor-not-allowed disabled:opacity-50
59
+ // data-[state=checked]:bg-primary
60
+ // data-[state=unchecked]:bg-input
61
+ styles: [
62
+ // We are not supporting peer like styles yet
63
+ tc.inlineFlex(),
64
+ tc.property("height", "24px"),
65
+ tc.property("width", "44px"),
66
+ tc.shrink(0),
67
+ tc.cursor("pointer"),
68
+ tc.items("center"),
69
+ tc.rounded("full"),
70
+ tc.border(2),
71
+ tc.border("transparent"),
72
+ tc.transition("all"),
73
+ tc.focusVisible(
74
+ [tc.outline("none"), tc.ring("ring", 2, "background", 2)].flat()
75
+ ),
76
+ tc.disabled([tc.cursor("not-allowed"), tc.opacity(50)].flat()),
77
+ tc.state([tc.bg("primary")].flat(), "[data-state=checked]"),
78
+ tc.state([tc.bg("input")].flat(), "[data-state=unchecked]")
79
+ ].flat(),
80
+ children: [
81
+ {
82
+ type: "instance",
83
+ component: "SwitchThumb",
84
+ // pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform
85
+ // data-[state=checked]:translate-x-5
86
+ // data-[state=unchecked]:translate-x-0
87
+ styles: [
88
+ tc.pointerEvents("none"),
89
+ tc.block(),
90
+ tc.h(5),
91
+ tc.w(5),
92
+ tc.rounded("full"),
93
+ tc.bg("background"),
94
+ tc.shadow("lg"),
95
+ tc.transition("transform"),
96
+ tc.state(
97
+ [tc.property("transform", "translateX(20px)")].flat(),
98
+ "[data-state=checked]"
99
+ ),
100
+ tc.state(
101
+ [tc.property("transform", "translateX(0px)")].flat(),
102
+ "[data-state=unchecked]"
103
+ )
104
+ ].flat(),
105
+ children: []
106
+ }
107
+ ]
108
+ }
109
+ ]
110
+ };
111
+ const metaSwitchThumb = {
112
+ category: "hidden",
113
+ type: "container",
114
+ detachable: false,
115
+ icon: TriggerIcon,
116
+ states: [
117
+ ...defaultStates,
118
+ {
119
+ label: "Checked",
120
+ selector: "[data-state=checked]",
121
+ category: "component-states"
122
+ },
123
+ {
124
+ label: "Unchecked",
125
+ selector: "[data-state=unchecked]",
126
+ category: "component-states"
127
+ }
128
+ ],
129
+ presetStyle: {
130
+ span
131
+ }
132
+ };
133
+ const propsMetaSwitch = {
134
+ props: propsSwitch,
135
+ initialProps: ["id", "checked", "name", "required"]
136
+ };
137
+ const propsMetaSwitchThumb = {
138
+ props: propsSwitchThumb
139
+ };
140
+ export {
141
+ metaSwitch,
142
+ metaSwitchThumb,
143
+ propsMetaSwitch,
144
+ propsMetaSwitchThumb
145
+ };
package/lib/tabs.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import {
3
- forwardRef,
4
- Children
3
+ forwardRef
5
4
  } from "react";
6
5
  import { Root, List, Trigger, Content } from "@radix-ui/react-tabs";
7
6
  import {
@@ -10,10 +9,9 @@ import {
10
9
  } from "@webstudio-is/react-sdk";
11
10
  const Tabs = Root;
12
11
  const TabsList = List;
13
- const TabsTrigger = forwardRef(({ value, children, ...props }, ref) => {
14
- const firstChild = Children.toArray(children)[0];
12
+ const TabsTrigger = forwardRef(({ value, ...props }, ref) => {
15
13
  const index = getIndexWithinAncestorFromComponentProps(props);
16
- return /* @__PURE__ */ jsx(Trigger, { ref, value: value ?? index, asChild: true, ...props, children: firstChild ?? /* @__PURE__ */ jsx("button", { children: "Add button" }) });
14
+ return /* @__PURE__ */ jsx(Trigger, { ref, value: value ?? index, ...props });
17
15
  });
18
16
  const TabsContent = forwardRef(({ value, ...props }, ref) => {
19
17
  const index = getIndexWithinAncestorFromComponentProps(props);
package/lib/tabs.ws.js CHANGED
@@ -4,8 +4,9 @@ import {
4
4
  TabsIcon,
5
5
  TriggerIcon
6
6
  } from "@webstudio-is/icons/svg";
7
- import { div } from "@webstudio-is/react-sdk/css-normalize";
7
+ import { button, div } from "@webstudio-is/react-sdk/css-normalize";
8
8
  import * as tc from "./theme/tailwind-classes";
9
+ import { buttonReset } from "./theme/styles";
9
10
  import {
10
11
  propsTabs,
11
12
  propsTabsList,
@@ -43,9 +44,11 @@ const tabsContentStyles = [
43
44
  ].flat();
44
45
  const metaTabs = {
45
46
  category: "radix",
47
+ order: 2,
46
48
  type: "container",
47
49
  icon: TabsIcon,
48
50
  presetStyle,
51
+ description: "A set of panels with content that are displayed one at a time. Duplicate both a tab trigger and tab content to add more tabs. Triggers and content are connected according to their order in the Navigator.",
49
52
  template: [
50
53
  {
51
54
  type: "instance",
@@ -82,26 +85,14 @@ const metaTabs = {
82
85
  {
83
86
  type: "instance",
84
87
  component: "TabsTrigger",
85
- children: [
86
- {
87
- type: "instance",
88
- component: "Button",
89
- styles: tabsTriggerStyles,
90
- children: [{ type: "text", value: "Account" }]
91
- }
92
- ]
88
+ styles: tabsTriggerStyles,
89
+ children: [{ type: "text", value: "Account" }]
93
90
  },
94
91
  {
95
92
  type: "instance",
96
93
  component: "TabsTrigger",
97
- children: [
98
- {
99
- type: "instance",
100
- component: "Button",
101
- styles: tabsTriggerStyles,
102
- children: [{ type: "text", value: "Password" }]
103
- }
104
- ]
94
+ styles: tabsTriggerStyles,
95
+ children: [{ type: "text", value: "Password" }]
105
96
  }
106
97
  ]
107
98
  },
@@ -137,7 +128,11 @@ const metaTabsTrigger = {
137
128
  icon: TriggerIcon,
138
129
  requiredAncestors: ["TabsList"],
139
130
  invalidAncestors: ["TabsTrigger"],
140
- indexWithinAncestor: "Tabs"
131
+ indexWithinAncestor: "Tabs",
132
+ label: "Tab Trigger",
133
+ presetStyle: {
134
+ button: [button, buttonReset].flat()
135
+ }
141
136
  };
142
137
  const metaTabsContent = {
143
138
  category: "hidden",
@@ -145,7 +140,8 @@ const metaTabsContent = {
145
140
  icon: ContentIcon,
146
141
  requiredAncestors: ["Tabs"],
147
142
  indexWithinAncestor: "Tabs",
148
- presetStyle
143
+ presetStyle,
144
+ label: "Tab Content"
149
145
  };
150
146
  const propsMetaTabs = {
151
147
  props: propsTabs
@@ -0,0 +1,70 @@
1
+ import * as tc from "./tailwind-classes";
2
+ const getButtonStyles = (variant, size = "default") => {
3
+ const styles = [
4
+ // 'inline-flex items-center justify-center rounded-md text-sm font-medium
5
+ // ring-offset-background transition-colors
6
+ // focus-visible:outline-none focus-visible:ring-2
7
+ // focus-visible:ring-ring focus-visible:ring-offset-2
8
+ // disabled:pointer-events-none disabled:opacity-50'
9
+ tc.border(0),
10
+ tc.bg("transparent"),
11
+ tc.inlineFlex(),
12
+ tc.items("center"),
13
+ tc.justify("center"),
14
+ tc.rounded("md"),
15
+ tc.text("sm"),
16
+ tc.font("medium"),
17
+ tc.focusVisible(
18
+ [tc.outline("none"), tc.ring("ring", 2, "background", 2)].flat()
19
+ ),
20
+ tc.state([tc.pointerEvents("none"), tc.opacity(50)].flat(), ":disabled")
21
+ ].flat();
22
+ let variantStyles = [];
23
+ if (variant === "ghost") {
24
+ variantStyles = [
25
+ tc.state([tc.bg("accent"), tc.text("accentForeground")].flat(), ":hover")
26
+ ].flat();
27
+ }
28
+ if (variant === "outline") {
29
+ variantStyles = [
30
+ tc.border(),
31
+ tc.border("input"),
32
+ tc.bg("background"),
33
+ tc.state(
34
+ [tc.bg("accent", 90), tc.text("accentForeground")].flat(),
35
+ ":hover"
36
+ )
37
+ ].flat();
38
+ }
39
+ let sizeStyles = [];
40
+ if (size === "icon") {
41
+ sizeStyles = [tc.h(10), tc.w(10)].flat();
42
+ }
43
+ if (size === "sm") {
44
+ sizeStyles = [tc.h(10), tc.px(3)].flat();
45
+ }
46
+ if (size === "default") {
47
+ sizeStyles = [tc.h(10), tc.px(4), tc.py(2)].flat();
48
+ }
49
+ return [...styles, ...variantStyles, ...sizeStyles];
50
+ };
51
+ const buttonReset = [
52
+ {
53
+ property: "backgroundColor",
54
+ value: { type: "keyword", value: "transparent" }
55
+ },
56
+ {
57
+ property: "backgroundImage",
58
+ value: { type: "keyword", value: "none" }
59
+ },
60
+ {
61
+ property: "cursor",
62
+ value: { type: "keyword", value: "pointer" }
63
+ },
64
+ tc.border(0),
65
+ tc.p(0)
66
+ ].flat();
67
+ export {
68
+ buttonReset,
69
+ getButtonStyles
70
+ };
@@ -4,6 +4,18 @@ import {
4
4
  parseBoxShadow,
5
5
  StyleValue
6
6
  } from "@webstudio-is/css-data";
7
+ const property = (property2, value) => {
8
+ if (value.startsWith("--")) {
9
+ return {
10
+ property: property2,
11
+ value: { type: "var", value: value.slice(2), fallbacks: [] }
12
+ };
13
+ }
14
+ return {
15
+ property: property2,
16
+ value: { type: "unparsed", value }
17
+ };
18
+ };
7
19
  const preflight = () => {
8
20
  const borderColorValue = parseCssValue("color", theme("colors")["border"]);
9
21
  return [
@@ -140,11 +152,11 @@ const borderB = (borderWidthOrColor) => {
140
152
  }
141
153
  ];
142
154
  };
143
- const paddingProperty = (property) => (padding) => {
155
+ const paddingProperty = (property2) => (padding) => {
144
156
  const key = `${padding}`;
145
157
  const valueString = theme("padding")?.[key] ?? "0";
146
- const value = parseCssValue(property, valueString);
147
- return [{ property, value }];
158
+ const value = parseCssValue(property2, valueString);
159
+ return [{ property: property2, value }];
148
160
  };
149
161
  const pt = (padding) => {
150
162
  return paddingProperty("paddingTop")(padding);
@@ -167,11 +179,11 @@ const py = (padding) => {
167
179
  const p = (padding) => {
168
180
  return [px(padding), py(padding)].flat();
169
181
  };
170
- const marginProperty = (property) => (margin) => {
182
+ const marginProperty = (property2) => (margin) => {
171
183
  const key = `${margin}`;
172
184
  const valueString = theme("margin")?.[key] ?? "0";
173
- const value = parseCssValue(property, valueString);
174
- return [{ property, value }];
185
+ const value = parseCssValue(property2, valueString);
186
+ return [{ property: property2, value }];
175
187
  };
176
188
  const ml = (margin) => {
177
189
  return marginProperty("marginLeft")(margin);
@@ -239,11 +251,11 @@ const maxW = (spacing) => {
239
251
  const value = parseCssValue("width", valueString);
240
252
  return [{ property: "maxWidth", value }];
241
253
  };
242
- const positionStyle = (property, spacing) => {
254
+ const positionStyle = (property2, spacing) => {
243
255
  const key = `${spacing}`;
244
- const valueString = theme("spacing")?.[key] ?? "0";
245
- const value = parseCssValue(property, valueString);
246
- return { property, value };
256
+ const valueString = theme("inset")?.[key] ?? "0";
257
+ const value = parseCssValue(property2, valueString);
258
+ return { property: property2, value };
247
259
  };
248
260
  const top = (spacing) => [positionStyle("top", spacing)];
249
261
  const right = (spacing) => [positionStyle("right", spacing)];
@@ -255,6 +267,21 @@ const inset = (spacing) => [
255
267
  positionStyle("top", spacing),
256
268
  positionStyle("bottom", spacing)
257
269
  ];
270
+ const aspect = (value) => {
271
+ let unparsed = value;
272
+ if (value === "square") {
273
+ unparsed = "1 / 1";
274
+ }
275
+ if (value === "video") {
276
+ unparsed = "16 / 9";
277
+ }
278
+ return [
279
+ {
280
+ property: "aspectRatio",
281
+ value: { type: "unparsed", value: unparsed }
282
+ }
283
+ ];
284
+ };
258
285
  const backdropBlur = (blur) => {
259
286
  const valueString = theme("blur")[blur];
260
287
  const value = {
@@ -263,6 +290,22 @@ const backdropBlur = (blur) => {
263
290
  };
264
291
  return [{ property: "backdropFilter", value }];
265
292
  };
293
+ const list = (listStyle) => {
294
+ const valueString = theme("listStyleType")[listStyle];
295
+ const value = parseCssValue("listStyleType", valueString);
296
+ return [{ property: "listStyleType", value }];
297
+ };
298
+ const select = (selectValue) => {
299
+ return [
300
+ {
301
+ property: "userSelect",
302
+ value: {
303
+ type: "keyword",
304
+ value: "none"
305
+ }
306
+ }
307
+ ];
308
+ };
266
309
  const bg = (color, alpha) => {
267
310
  const value = parseCssValue("backgroundColor", theme("colors")[color]);
268
311
  if (alpha !== void 0 && value.type === "rgb") {
@@ -334,6 +377,9 @@ const inlineFlex = () => {
334
377
  { property: "display", value: { type: "keyword", value: "inline-flex" } }
335
378
  ];
336
379
  };
380
+ const block = () => {
381
+ return [{ property: "display", value: { type: "keyword", value: "block" } }];
382
+ };
337
383
  const flexDirection = { row: "row", col: "column" };
338
384
  const flex = (flexParam) => {
339
385
  if (flexParam === void 0) {
@@ -417,11 +463,15 @@ const grow = () => {
417
463
  return [
418
464
  {
419
465
  property: "flexGrow",
420
- value: {
421
- type: "unit",
422
- value: 1,
423
- unit: "number"
424
- }
466
+ value: { type: "unit", value: 1, unit: "number" }
467
+ }
468
+ ];
469
+ };
470
+ const shrink = (value) => {
471
+ return [
472
+ {
473
+ property: "flexGrow",
474
+ value: { type: "unit", value, unit: "number" }
425
475
  }
426
476
  ];
427
477
  };
@@ -434,6 +484,40 @@ const gap = (gapValue) => {
434
484
  { property: "columnGap", value }
435
485
  ];
436
486
  };
487
+ const lineClamp = (lineClampValue) => {
488
+ const key = `${lineClampValue}`;
489
+ const valueString = theme("lineClamp")?.[key];
490
+ return [
491
+ {
492
+ property: "overflow",
493
+ value: {
494
+ type: "keyword",
495
+ value: "hidden"
496
+ }
497
+ },
498
+ {
499
+ property: "display",
500
+ value: {
501
+ type: "keyword",
502
+ value: "-webkit-box"
503
+ }
504
+ },
505
+ {
506
+ property: "-webkit-box-orient",
507
+ value: {
508
+ type: "keyword",
509
+ value: "vertical"
510
+ }
511
+ },
512
+ {
513
+ property: "-webkit-line-clamp",
514
+ value: {
515
+ type: "keyword",
516
+ value: valueString
517
+ }
518
+ }
519
+ ];
520
+ };
437
521
  const leading = (lineHeight) => {
438
522
  const key = `${lineHeight}`;
439
523
  const valueString = theme("lineHeight")[key];
@@ -501,6 +585,14 @@ const text = (sizeOrColor) => {
501
585
  }
502
586
  ];
503
587
  };
588
+ const noUnderline = () => {
589
+ return [
590
+ {
591
+ property: "textDecorationLine",
592
+ value: { type: "keyword", value: "none" }
593
+ }
594
+ ];
595
+ };
504
596
  const underline = () => {
505
597
  return [
506
598
  {
@@ -589,7 +681,7 @@ const transition = (value) => {
589
681
  return [
590
682
  {
591
683
  property: "transitionProperty",
592
- value: { type: "keyword", value: "all" }
684
+ value: { type: "keyword", value }
593
685
  },
594
686
  {
595
687
  property: "transitionTimingFunction",
@@ -601,6 +693,14 @@ const transition = (value) => {
601
693
  }
602
694
  ];
603
695
  };
696
+ const duration = (ms) => {
697
+ return [
698
+ {
699
+ property: "transitionDuration",
700
+ value: { type: "unit", value: ms, unit: "ms" }
701
+ }
702
+ ];
703
+ };
604
704
  const hover = (value) => {
605
705
  return value.map((decl) => ({
606
706
  ...decl,
@@ -633,13 +733,16 @@ const state = (value, state2) => {
633
733
  };
634
734
  export {
635
735
  absolute,
736
+ aspect,
636
737
  backdropBlur,
637
738
  bg,
739
+ block,
638
740
  border,
639
741
  borderB,
640
742
  bottom,
641
743
  cursor,
642
744
  disabled,
745
+ duration,
643
746
  fixed,
644
747
  flex,
645
748
  focus,
@@ -656,6 +759,8 @@ export {
656
759
  justify,
657
760
  leading,
658
761
  left,
762
+ lineClamp,
763
+ list,
659
764
  m,
660
765
  maxW,
661
766
  mb,
@@ -665,6 +770,7 @@ export {
665
770
  mt,
666
771
  mx,
667
772
  my,
773
+ noUnderline,
668
774
  opacity,
669
775
  outline,
670
776
  overflow,
@@ -673,6 +779,7 @@ export {
673
779
  pl,
674
780
  pointerEvents,
675
781
  pr,
782
+ property,
676
783
  pt,
677
784
  px,
678
785
  py,
@@ -680,7 +787,9 @@ export {
680
787
  right,
681
788
  ring,
682
789
  rounded,
790
+ select,
683
791
  shadow,
792
+ shrink,
684
793
  state,
685
794
  text,
686
795
  top,
@@ -1,6 +1,7 @@
1
1
  const colors = {
2
2
  transparent: "transparent",
3
3
  current: "currentColor",
4
+ inherit: "inherit",
4
5
  popover: "rgb(255, 255, 255)",
5
6
  popoverForeground: "rgb(2, 8, 23)",
6
7
  border: "rgb(226, 232, 240)",
package/lib/tooltip.ws.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { TooltipIcon, TriggerIcon, ContentIcon } from "@webstudio-is/icons/svg";
2
2
  import {
3
3
  } from "@webstudio-is/react-sdk";
4
+ import { div } from "@webstudio-is/react-sdk/css-normalize";
4
5
  import * as tc from "./theme/tailwind-classes";
5
6
  import {
6
7
  propsTooltip,
7
8
  propsTooltipContent,
8
9
  propsTooltipTrigger
9
10
  } from "./__generated__/tooltip.props";
10
- import { div } from "@webstudio-is/react-sdk/css-normalize";
11
- import { template as buttonTemplate } from "./button.ws";
11
+ import { getButtonStyles } from "./theme/styles";
12
12
  const presetStyle = {
13
13
  div
14
14
  };
@@ -28,10 +28,11 @@ const metaTooltipContent = {
28
28
  };
29
29
  const metaTooltip = {
30
30
  category: "radix",
31
+ order: 7,
31
32
  type: "container",
32
33
  icon: TooltipIcon,
33
- order: 15,
34
34
  stylable: false,
35
+ description: "Displays content that is related to the trigger, when the trigger is hovered with the mouse or focused with the keyboard. You are reading an example of a tooltip right now.",
35
36
  template: [
36
37
  {
37
38
  type: "instance",
@@ -57,15 +58,18 @@ const metaTooltip = {
57
58
  {
58
59
  type: "instance",
59
60
  component: "TooltipTrigger",
60
- props: [],
61
- children: buttonTemplate({
62
- children: [{ type: "text", value: "Button" }]
63
- })
61
+ children: [
62
+ {
63
+ type: "instance",
64
+ component: "Button",
65
+ styles: getButtonStyles("outline"),
66
+ children: [{ type: "text", value: "Button" }]
67
+ }
68
+ ]
64
69
  },
65
70
  {
66
71
  type: "instance",
67
72
  component: "TooltipContent",
68
- props: [],
69
73
  /**
70
74
  * z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md
71
75
  **/
@@ -0,0 +1,3 @@
1
+ import type { PropMeta } from "@webstudio-is/generate-arg-types";
2
+ export declare const propsCheckbox: Record<string, PropMeta>;
3
+ export declare const propsCheckboxIndicator: Record<string, PropMeta>;
@@ -0,0 +1,8 @@
1
+ import type { PropMeta } from "@webstudio-is/generate-arg-types";
2
+ export declare const propsNavigationMenu: Record<string, PropMeta>;
3
+ export declare const propsNavigationMenuList: Record<string, PropMeta>;
4
+ export declare const propsNavigationMenuViewport: Record<string, PropMeta>;
5
+ export declare const propsNavigationMenuContent: Record<string, PropMeta>;
6
+ export declare const propsNavigationMenuItem: Record<string, PropMeta>;
7
+ export declare const propsNavigationMenuLink: Record<string, PropMeta>;
8
+ export declare const propsNavigationMenuTrigger: Record<string, PropMeta>;
@@ -0,0 +1,4 @@
1
+ import type { PropMeta } from "@webstudio-is/generate-arg-types";
2
+ export declare const propsRadioGroup: Record<string, PropMeta>;
3
+ export declare const propsRadioGroupItem: Record<string, PropMeta>;
4
+ export declare const propsRadioGroupIndicator: Record<string, PropMeta>;
@@ -0,0 +1,9 @@
1
+ import type { PropMeta } from "@webstudio-is/generate-arg-types";
2
+ export declare const propsSelect: Record<string, PropMeta>;
3
+ export declare const propsSelectTrigger: Record<string, PropMeta>;
4
+ export declare const propsSelectValue: Record<string, PropMeta>;
5
+ export declare const propsSelectContent: Record<string, PropMeta>;
6
+ export declare const propsSelectViewport: Record<string, PropMeta>;
7
+ export declare const propsSelectItem: Record<string, PropMeta>;
8
+ export declare const propsSelectItemIndicator: Record<string, PropMeta>;
9
+ export declare const propsSelectItemText: Record<string, PropMeta>;
@@ -0,0 +1,3 @@
1
+ import type { PropMeta } from "@webstudio-is/generate-arg-types";
2
+ export declare const propsSwitch: Record<string, PropMeta>;
3
+ export declare const propsSwitchThumb: Record<string, PropMeta>;
@@ -0,0 +1,6 @@
1
+ import { type ForwardRefExoticComponent, type ComponentPropsWithRef } from "react";
2
+ import { Indicator } from "@radix-ui/react-checkbox";
3
+ export declare const Checkbox: ForwardRefExoticComponent<Omit<Omit<import("@radix-ui/react-checkbox").CheckboxProps & import("react").RefAttributes<HTMLButtonElement>, "checked"> & {
4
+ checked: boolean;
5
+ }, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
6
+ export declare const CheckboxIndicator: ForwardRefExoticComponent<ComponentPropsWithRef<typeof Indicator>>;