@webstudio-is/sdk-components-react-radix 0.87.0 → 0.88.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 (182) hide show
  1. package/lib/__generated__/accordion.props.js +0 -5
  2. package/lib/__generated__/button.props.js +0 -21
  3. package/lib/__generated__/checkbox.props.js +850 -0
  4. package/lib/__generated__/collapsible.props.js +0 -2
  5. package/lib/__generated__/dialog.props.js +0 -11
  6. package/lib/__generated__/label.props.js +0 -1
  7. package/lib/__generated__/navigation-menu.props.js +2104 -0
  8. package/lib/__generated__/popover.props.js +0 -3
  9. package/lib/__generated__/radio-group.props.js +1282 -0
  10. package/lib/__generated__/select.props.js +2962 -0
  11. package/lib/__generated__/sheet.props.js +0 -11
  12. package/lib/__generated__/switch.props.js +850 -0
  13. package/lib/__generated__/tabs.props.js +428 -5
  14. package/lib/__generated__/tooltip.props.js +0 -2
  15. package/lib/accordion.js +11 -4
  16. package/lib/accordion.ws.js +87 -72
  17. package/lib/checkbox.js +13 -0
  18. package/lib/checkbox.ws.js +151 -0
  19. package/lib/cjs/__generated__/accordion.props.js +0 -5
  20. package/lib/cjs/__generated__/button.props.js +0 -21
  21. package/lib/cjs/__generated__/checkbox.props.js +870 -0
  22. package/lib/cjs/__generated__/collapsible.props.js +0 -2
  23. package/lib/cjs/__generated__/dialog.props.js +0 -11
  24. package/lib/cjs/__generated__/label.props.js +0 -1
  25. package/lib/cjs/__generated__/navigation-menu.props.js +2124 -0
  26. package/lib/cjs/__generated__/popover.props.js +0 -3
  27. package/lib/cjs/__generated__/radio-group.props.js +1302 -0
  28. package/lib/cjs/__generated__/select.props.js +2982 -0
  29. package/lib/cjs/__generated__/sheet.props.js +0 -11
  30. package/lib/cjs/__generated__/switch.props.js +870 -0
  31. package/lib/cjs/__generated__/tabs.props.js +428 -5
  32. package/lib/cjs/__generated__/tooltip.props.js +0 -2
  33. package/lib/cjs/accordion.js +11 -4
  34. package/lib/cjs/accordion.ws.js +85 -71
  35. package/lib/cjs/{textarea.js → checkbox.js} +9 -6
  36. package/lib/cjs/checkbox.ws.js +172 -0
  37. package/lib/cjs/collapsible.ws.js +4 -1
  38. package/lib/cjs/components.js +27 -14
  39. package/lib/cjs/dialog.ws.js +17 -17
  40. package/lib/cjs/hooks.js +5 -1
  41. package/lib/cjs/label.ws.js +1 -1
  42. package/lib/cjs/metas.js +29 -14
  43. package/lib/cjs/navigation-menu.js +107 -0
  44. package/lib/cjs/navigation-menu.ws.js +513 -0
  45. package/lib/cjs/popover.ws.js +12 -9
  46. package/lib/cjs/props.js +27 -14
  47. package/lib/cjs/{button.js → radio-group.js} +10 -8
  48. package/lib/cjs/radio-group.ws.js +188 -0
  49. package/lib/cjs/select.js +81 -0
  50. package/lib/cjs/select.ws.js +349 -0
  51. package/lib/cjs/sheet.ws.js +87 -176
  52. package/lib/cjs/{input.js → switch.js} +8 -9
  53. package/lib/cjs/switch.ws.js +171 -0
  54. package/lib/cjs/tabs.js +2 -3
  55. package/lib/cjs/tabs.ws.js +13 -18
  56. package/lib/cjs/theme/styles.js +100 -0
  57. package/lib/cjs/theme/tailwind-classes.js +125 -16
  58. package/lib/cjs/theme/tailwind-colors.js +1 -0
  59. package/lib/cjs/tooltip.ws.js +11 -8
  60. package/lib/collapsible.ws.js +4 -1
  61. package/lib/components.js +44 -22
  62. package/lib/dialog.ws.js +17 -17
  63. package/lib/hooks.js +5 -1
  64. package/lib/label.ws.js +1 -1
  65. package/lib/metas.js +58 -24
  66. package/lib/navigation-menu.js +85 -0
  67. package/lib/navigation-menu.ws.js +500 -0
  68. package/lib/popover.ws.js +12 -9
  69. package/lib/props.js +56 -24
  70. package/lib/radio-group.js +11 -0
  71. package/lib/radio-group.ws.js +170 -0
  72. package/lib/select.js +73 -0
  73. package/lib/select.ws.js +337 -0
  74. package/lib/sheet.ws.js +88 -194
  75. package/lib/switch.js +7 -0
  76. package/lib/switch.ws.js +143 -0
  77. package/lib/tabs.js +3 -5
  78. package/lib/tabs.ws.js +14 -19
  79. package/lib/theme/styles.js +70 -0
  80. package/lib/theme/tailwind-classes.js +125 -16
  81. package/lib/theme/tailwind-colors.js +1 -0
  82. package/lib/tooltip.ws.js +11 -8
  83. package/lib/types/__generated__/checkbox.props.d.ts +3 -0
  84. package/lib/types/__generated__/navigation-menu.props.d.ts +8 -0
  85. package/lib/types/__generated__/radio-group.props.d.ts +4 -0
  86. package/lib/types/__generated__/select.props.d.ts +9 -0
  87. package/lib/types/__generated__/switch.props.d.ts +3 -0
  88. package/lib/types/checkbox.d.ts +6 -0
  89. package/lib/types/checkbox.stories.d.ts +11 -0
  90. package/lib/types/checkbox.ws.d.ts +5 -0
  91. package/lib/types/components.d.ts +5 -4
  92. package/lib/types/metas.d.ts +6 -4
  93. package/lib/types/navigation-menu.d.ts +15 -0
  94. package/lib/types/navigation-menu.ws.d.ts +15 -0
  95. package/lib/types/props.d.ts +5 -4
  96. package/lib/types/radio-group.d.ts +5 -0
  97. package/lib/types/radio-group.stories.d.ts +9 -0
  98. package/lib/types/radio-group.ws.d.ts +7 -0
  99. package/lib/types/select.d.ts +12 -0
  100. package/lib/types/select.ws.d.ts +17 -0
  101. package/lib/types/sheet.ws.d.ts +2 -15
  102. package/lib/types/switch.d.ts +4 -0
  103. package/lib/types/switch.stories.d.ts +9 -0
  104. package/lib/types/switch.ws.d.ts +5 -0
  105. package/lib/types/tabs.d.ts +3 -12
  106. package/lib/types/theme/radix-common-types.d.ts +3 -2
  107. package/lib/types/theme/styles.d.ts +215 -0
  108. package/lib/types/theme/tailwind-classes.d.ts +16 -6
  109. package/lib/types/theme/tailwind-colors.d.ts +1 -0
  110. package/lib/types/theme/tailwind-theme.d.ts +1 -1
  111. package/package.json +12 -7
  112. package/src/__generated__/accordion.props.ts +0 -5
  113. package/src/__generated__/button.props.ts +0 -21
  114. package/src/__generated__/checkbox.props.ts +948 -0
  115. package/src/__generated__/collapsible.props.ts +0 -2
  116. package/src/__generated__/dialog.props.ts +0 -11
  117. package/src/__generated__/label.props.ts +0 -1
  118. package/src/__generated__/navigation-menu.props.ts +2349 -0
  119. package/src/__generated__/popover.props.ts +0 -3
  120. package/src/__generated__/radio-group.props.ts +1429 -0
  121. package/src/__generated__/select.props.ts +3304 -0
  122. package/src/__generated__/sheet.props.ts +0 -11
  123. package/src/__generated__/switch.props.ts +948 -0
  124. package/src/__generated__/tabs.props.ts +477 -4
  125. package/src/__generated__/tooltip.props.ts +0 -2
  126. package/src/accordion.tsx +14 -7
  127. package/src/accordion.ws.ts +85 -70
  128. package/src/{textarea.stories.ts → checkbox.stories.ts} +6 -11
  129. package/src/checkbox.tsx +22 -0
  130. package/src/checkbox.ws.ts +151 -0
  131. package/src/collapsible.ws.ts +4 -1
  132. package/src/components.ts +25 -12
  133. package/src/dialog.ws.tsx +15 -16
  134. package/src/hooks.ts +4 -0
  135. package/src/label.ws.ts +1 -1
  136. package/src/metas.ts +36 -12
  137. package/src/navigation-menu.stories.tsx +21 -0
  138. package/src/navigation-menu.tsx +130 -0
  139. package/src/navigation-menu.ws.ts +523 -0
  140. package/src/popover.ws.tsx +12 -9
  141. package/src/props.ts +35 -12
  142. package/src/{input.stories.ts → radio-group.stories.ts} +6 -15
  143. package/src/radio-group.tsx +17 -0
  144. package/src/radio-group.ws.ts +174 -0
  145. package/src/select.stories.tsx +21 -0
  146. package/src/select.tsx +107 -0
  147. package/src/select.ws.ts +347 -0
  148. package/src/sheet.ws.tsx +89 -209
  149. package/src/{button.stories.ts → switch.stories.ts} +6 -19
  150. package/src/switch.tsx +10 -0
  151. package/src/switch.ws.ts +143 -0
  152. package/src/tabs.tsx +4 -17
  153. package/src/tabs.ws.ts +17 -19
  154. package/src/theme/radix-common-types.ts +3 -2
  155. package/src/theme/styles.ts +80 -0
  156. package/src/theme/tailwind-classes.ts +150 -14
  157. package/src/theme/tailwind-colors.ts +1 -0
  158. package/src/tooltip.ws.tsx +11 -8
  159. package/lib/button.js +0 -8
  160. package/lib/button.ws.js +0 -133
  161. package/lib/cjs/button.ws.js +0 -160
  162. package/lib/cjs/input.ws.js +0 -103
  163. package/lib/cjs/textarea.ws.js +0 -98
  164. package/lib/input.js +0 -8
  165. package/lib/input.ws.js +0 -75
  166. package/lib/textarea.js +0 -8
  167. package/lib/textarea.ws.js +0 -70
  168. package/lib/types/button.d.ts +0 -7
  169. package/lib/types/button.stories.d.ts +0 -20
  170. package/lib/types/button.ws.d.ts +0 -7
  171. package/lib/types/input.d.ts +0 -2
  172. package/lib/types/input.stories.d.ts +0 -20
  173. package/lib/types/input.ws.d.ts +0 -3
  174. package/lib/types/textarea.d.ts +0 -2
  175. package/lib/types/textarea.stories.d.ts +0 -14
  176. package/lib/types/textarea.ws.d.ts +0 -3
  177. package/src/button.tsx +0 -25
  178. package/src/button.ws.ts +0 -155
  179. package/src/input.tsx +0 -12
  180. package/src/input.ws.ts +0 -78
  181. package/src/textarea.tsx +0 -12
  182. package/src/textarea.ws.ts +0 -74
package/lib/sheet.ws.js CHANGED
@@ -1,97 +1,17 @@
1
- import {
2
- HamburgerMenuIcon,
3
- TriggerIcon,
4
- ContentIcon,
5
- OverlayIcon,
6
- HeadingIcon,
7
- TextIcon,
8
- ButtonElementIcon
9
- } from "@webstudio-is/icons/svg";
10
- import {
11
- } from "@webstudio-is/react-sdk";
1
+ import { HamburgerMenuIcon } from "@webstudio-is/icons/svg";
12
2
  import * as tc from "./theme/tailwind-classes";
13
- import {
14
- propsSheet,
15
- propsSheetContent,
16
- propsSheetTrigger,
17
- propsSheetOverlay,
18
- propsSheetClose,
19
- propsSheetTitle,
20
- propsSheetDescription
21
- } from "./__generated__/sheet.props";
22
- import { div, nav, button, h2, p } from "@webstudio-is/react-sdk/css-normalize";
23
- import { template as buttonTemplate } from "./button.ws";
24
- const contentPresetStyle = {
25
- div,
26
- nav
27
- };
28
- const presetStyle = {
29
- div
30
- };
31
- const buttonPresetStyle = {
32
- button
33
- };
34
- const titlePresetStyle = {
35
- h2
36
- };
37
- const descriptionPresetStyle = {
38
- p
39
- };
40
- const metaSheetTrigger = {
41
- category: "hidden",
42
- type: "container",
43
- icon: TriggerIcon,
44
- stylable: false,
45
- detachable: false
46
- };
47
- const metaSheetContent = {
48
- category: "hidden",
49
- type: "container",
50
- icon: ContentIcon,
51
- detachable: false,
52
- presetStyle: contentPresetStyle,
53
- states: [
54
- { selector: "[data-side=top]", label: "Top Side" },
55
- { selector: "[data-side=right]", label: "Right Side" },
56
- { selector: "[data-side=bottom]", label: "Bottom Side" },
57
- { selector: "[data-side=left]", label: "Left Side" }
58
- ]
59
- };
60
- const metaSheetOverlay = {
61
- category: "hidden",
62
- type: "container",
63
- presetStyle,
64
- icon: OverlayIcon,
65
- detachable: false
66
- };
67
- const metaSheetTitle = {
68
- category: "hidden",
69
- type: "container",
70
- presetStyle: titlePresetStyle,
71
- icon: HeadingIcon
72
- };
73
- const metaSheetDescription = {
74
- category: "hidden",
75
- type: "container",
76
- presetStyle: descriptionPresetStyle,
77
- icon: TextIcon
78
- };
79
- const metaSheetClose = {
80
- category: "hidden",
81
- type: "container",
82
- presetStyle: buttonPresetStyle,
83
- icon: ButtonElementIcon
84
- };
85
- const metaSheet = {
3
+ import { getButtonStyles } from "./theme/styles";
4
+ const meta = {
86
5
  category: "radix",
6
+ order: 1,
87
7
  type: "container",
88
8
  icon: HamburgerMenuIcon,
89
- order: 15,
90
9
  stylable: false,
91
10
  template: [
92
11
  {
93
12
  type: "instance",
94
- component: "Sheet",
13
+ component: "Dialog",
14
+ label: "Sheet",
95
15
  dataSources: {
96
16
  sheetOpen: { type: "variable", initialValue: false }
97
17
  },
@@ -112,32 +32,35 @@ const metaSheet = {
112
32
  children: [
113
33
  {
114
34
  type: "instance",
115
- component: "SheetTrigger",
116
- children: buttonTemplate({
117
- props: [
118
- { name: "variant", type: "string", value: "ghost" },
119
- { name: "size", type: "string", value: "icon" }
120
- ],
121
- children: [
122
- {
123
- type: "instance",
124
- component: "HtmlEmbed",
125
- label: "Hamburger Menu Svg",
126
- props: [
127
- {
128
- type: "string",
129
- name: "code",
130
- value: HamburgerMenuIcon
131
- }
132
- ],
133
- children: []
134
- }
135
- ]
136
- })
35
+ component: "DialogTrigger",
36
+ label: "Sheet Trigger",
37
+ children: [
38
+ {
39
+ type: "instance",
40
+ component: "Button",
41
+ styles: getButtonStyles("ghost", "icon"),
42
+ children: [
43
+ {
44
+ type: "instance",
45
+ component: "HtmlEmbed",
46
+ label: "Hamburger Menu Svg",
47
+ props: [
48
+ {
49
+ type: "string",
50
+ name: "code",
51
+ value: HamburgerMenuIcon
52
+ }
53
+ ],
54
+ children: []
55
+ }
56
+ ]
57
+ }
58
+ ]
137
59
  },
138
60
  {
139
61
  type: "instance",
140
- component: "SheetOverlay",
62
+ component: "DialogOverlay",
63
+ label: "Sheet Overlay",
141
64
  /**
142
65
  * fixed inset-0 z-50 bg-background/80 backdrop-blur-sm
143
66
  * flex
@@ -156,7 +79,8 @@ const metaSheet = {
156
79
  children: [
157
80
  {
158
81
  type: "instance",
159
- component: "SheetContent",
82
+ component: "DialogContent",
83
+ label: "Sheet Content",
160
84
  /**
161
85
  * fixed w-full z-50
162
86
  * grid gap-4 max-w-lg
@@ -174,71 +98,81 @@ const metaSheet = {
174
98
  tc.p(6),
175
99
  tc.shadow("lg"),
176
100
  tc.relative(),
177
- tc.state(
178
- [tc.mr("auto"), tc.maxW("sm"), tc.grow()].flat(),
179
- "[data-side=left]"
180
- ),
181
- tc.state(
182
- [tc.ml("auto"), tc.maxW("sm"), tc.grow()].flat(),
183
- "[data-side=right]"
184
- ),
185
- tc.state([tc.mb("auto")].flat(), "[data-side=top]"),
186
- tc.state([tc.mt("auto")].flat(), "[data-side=bottom]")
101
+ // side=left
102
+ tc.mr("auto"),
103
+ tc.maxW("sm"),
104
+ tc.grow()
187
105
  ].flat(),
188
106
  children: [
189
107
  {
190
108
  type: "instance",
191
109
  component: "Box",
192
- label: "Sheet Header",
193
- styles: [tc.flex(), tc.flex("col"), tc.gap(1)].flat(),
110
+ label: "Navigation",
111
+ props: [
112
+ { name: "tag", type: "string", value: "nav" },
113
+ { name: "role", type: "string", value: "navigation" }
114
+ ],
194
115
  children: [
195
116
  {
196
117
  type: "instance",
197
- component: "SheetTitle",
198
- /**
199
- * text-lg leading-none tracking-tight
200
- **/
201
- styles: [
202
- tc.my(0),
203
- tc.leading("none"),
204
- tc.text("lg"),
205
- tc.tracking("tight")
206
- ].flat(),
118
+ component: "Box",
119
+ label: "Sheet Header",
120
+ styles: [tc.flex(), tc.flex("col"), tc.gap(1)].flat(),
207
121
  children: [
208
122
  {
209
- type: "text",
210
- value: "Sheet Title"
123
+ type: "instance",
124
+ component: "DialogTitle",
125
+ label: "Sheet Title",
126
+ /**
127
+ * text-lg leading-none tracking-tight
128
+ **/
129
+ styles: [
130
+ tc.my(0),
131
+ tc.leading("none"),
132
+ tc.text("lg"),
133
+ tc.tracking("tight")
134
+ ].flat(),
135
+ children: [
136
+ {
137
+ type: "text",
138
+ value: "Sheet Title"
139
+ }
140
+ ]
141
+ },
142
+ {
143
+ type: "instance",
144
+ component: "DialogDescription",
145
+ label: "Sheet Description",
146
+ /**
147
+ * text-sm text-muted-foreground
148
+ **/
149
+ styles: [
150
+ tc.my(0),
151
+ tc.text("sm"),
152
+ tc.text("mutedForeground")
153
+ ].flat(),
154
+ children: [
155
+ {
156
+ type: "text",
157
+ value: "Sheet description text you can edit"
158
+ }
159
+ ]
211
160
  }
212
161
  ]
213
162
  },
214
163
  {
215
164
  type: "instance",
216
- component: "SheetDescription",
217
- /**
218
- * text-sm text-muted-foreground
219
- **/
220
- styles: [
221
- tc.my(0),
222
- tc.text("sm"),
223
- tc.text("mutedForeground")
224
- ].flat(),
165
+ component: "Text",
225
166
  children: [
226
- {
227
- type: "text",
228
- value: "sheet description text you can edit"
229
- }
167
+ { type: "text", value: "The text you can edit" }
230
168
  ]
231
169
  }
232
170
  ]
233
171
  },
234
172
  {
235
173
  type: "instance",
236
- component: "Text",
237
- children: [{ type: "text", value: "The text you can edit" }]
238
- },
239
- {
240
- type: "instance",
241
- component: "SheetClose",
174
+ component: "DialogClose",
175
+ label: "Close Button",
242
176
  /**
243
177
  * absolute right-4 top-4
244
178
  * rounded-sm opacity-70
@@ -273,46 +207,6 @@ const metaSheet = {
273
207
  }
274
208
  ]
275
209
  };
276
- const propsMetaSheet = {
277
- props: propsSheet,
278
- initialProps: ["open", "modal"]
279
- };
280
- const propsMetaSheetTrigger = {
281
- props: propsSheetTrigger
282
- };
283
- const propsMetaSheetContent = {
284
- props: propsSheetContent,
285
- initialProps: ["side", "role", "tag"]
286
- };
287
- const propsMetaSheetOverlay = {
288
- props: propsSheetOverlay,
289
- initialProps: []
290
- };
291
- const propsMetaSheetClose = {
292
- props: propsSheetClose,
293
- initialProps: []
294
- };
295
- const propsMetaSheetTitle = {
296
- props: propsSheetTitle,
297
- initialProps: []
298
- };
299
- const propsMetaSheetDescription = {
300
- props: propsSheetDescription,
301
- initialProps: []
302
- };
303
210
  export {
304
- metaSheet,
305
- metaSheetClose,
306
- metaSheetContent,
307
- metaSheetDescription,
308
- metaSheetOverlay,
309
- metaSheetTitle,
310
- metaSheetTrigger,
311
- propsMetaSheet,
312
- propsMetaSheetClose,
313
- propsMetaSheetContent,
314
- propsMetaSheetDescription,
315
- propsMetaSheetOverlay,
316
- propsMetaSheetTitle,
317
- propsMetaSheetTrigger
211
+ meta
318
212
  };
package/lib/switch.js ADDED
@@ -0,0 +1,7 @@
1
+ import { Root, Thumb } from "@radix-ui/react-switch";
2
+ const Switch = Root;
3
+ const SwitchThumb = Thumb;
4
+ export {
5
+ Switch,
6
+ SwitchThumb
7
+ };
@@ -0,0 +1,143 @@
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
+ icon: SwitchIcon,
14
+ states: [
15
+ ...defaultStates,
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
+ }
26
+ ],
27
+ presetStyle: {
28
+ button: [button, buttonReset].flat()
29
+ },
30
+ template: [
31
+ {
32
+ type: "instance",
33
+ component: "Switch",
34
+ dataSources: {
35
+ switchChecked: { type: "variable", initialValue: false }
36
+ },
37
+ props: [
38
+ {
39
+ name: "checked",
40
+ type: "dataSource",
41
+ dataSourceName: "switchChecked"
42
+ },
43
+ {
44
+ name: "onCheckedChange",
45
+ type: "action",
46
+ value: [
47
+ {
48
+ type: "execute",
49
+ args: ["checked"],
50
+ code: `switchChecked = checked`
51
+ }
52
+ ]
53
+ }
54
+ ],
55
+ // peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors
56
+ // focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background
57
+ // disabled:cursor-not-allowed disabled:opacity-50
58
+ // data-[state=checked]:bg-primary
59
+ // data-[state=unchecked]:bg-input
60
+ styles: [
61
+ // We are not supporting peer like styles yet
62
+ tc.inlineFlex(),
63
+ tc.property("height", "24px"),
64
+ tc.property("width", "44px"),
65
+ tc.shrink(0),
66
+ tc.cursor("pointer"),
67
+ tc.items("center"),
68
+ tc.rounded("full"),
69
+ tc.border(2),
70
+ tc.border("transparent"),
71
+ tc.transition("all"),
72
+ tc.focusVisible(
73
+ [tc.outline("none"), tc.ring("ring", 2, "background", 2)].flat()
74
+ ),
75
+ tc.disabled([tc.cursor("not-allowed"), tc.opacity(50)].flat()),
76
+ tc.state([tc.bg("primary")].flat(), "[data-state=checked]"),
77
+ tc.state([tc.bg("input")].flat(), "[data-state=unchecked]")
78
+ ].flat(),
79
+ children: [
80
+ {
81
+ type: "instance",
82
+ component: "SwitchThumb",
83
+ // pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform
84
+ // data-[state=checked]:translate-x-5
85
+ // data-[state=unchecked]:translate-x-0
86
+ styles: [
87
+ tc.pointerEvents("none"),
88
+ tc.block(),
89
+ tc.h(5),
90
+ tc.w(5),
91
+ tc.rounded("full"),
92
+ tc.bg("background"),
93
+ tc.shadow("lg"),
94
+ tc.transition("transform"),
95
+ tc.state(
96
+ [tc.property("transform", "translateX(20px)")].flat(),
97
+ "[data-state=checked]"
98
+ ),
99
+ tc.state(
100
+ [tc.property("transform", "translateX(0px)")].flat(),
101
+ "[data-state=unchecked]"
102
+ )
103
+ ].flat(),
104
+ children: []
105
+ }
106
+ ]
107
+ }
108
+ ]
109
+ };
110
+ const metaSwitchThumb = {
111
+ category: "hidden",
112
+ type: "container",
113
+ icon: TriggerIcon,
114
+ states: [
115
+ ...defaultStates,
116
+ {
117
+ label: "Checked",
118
+ selector: "[data-state=checked]",
119
+ category: "component-states"
120
+ },
121
+ {
122
+ label: "Unchecked",
123
+ selector: "[data-state=unchecked]",
124
+ category: "component-states"
125
+ }
126
+ ],
127
+ presetStyle: {
128
+ span
129
+ }
130
+ };
131
+ const propsMetaSwitch = {
132
+ props: propsSwitch,
133
+ initialProps: ["id", "checked", "name", "required"]
134
+ };
135
+ const propsMetaSwitchThumb = {
136
+ props: propsSwitchThumb
137
+ };
138
+ export {
139
+ metaSwitch,
140
+ metaSwitchThumb,
141
+ propsMetaSwitch,
142
+ propsMetaSwitchThumb
143
+ };
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,6 +44,7 @@ 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,
@@ -82,26 +84,14 @@ const metaTabs = {
82
84
  {
83
85
  type: "instance",
84
86
  component: "TabsTrigger",
85
- children: [
86
- {
87
- type: "instance",
88
- component: "Button",
89
- styles: tabsTriggerStyles,
90
- children: [{ type: "text", value: "Account" }]
91
- }
92
- ]
87
+ styles: tabsTriggerStyles,
88
+ children: [{ type: "text", value: "Account" }]
93
89
  },
94
90
  {
95
91
  type: "instance",
96
92
  component: "TabsTrigger",
97
- children: [
98
- {
99
- type: "instance",
100
- component: "Button",
101
- styles: tabsTriggerStyles,
102
- children: [{ type: "text", value: "Password" }]
103
- }
104
- ]
93
+ styles: tabsTriggerStyles,
94
+ children: [{ type: "text", value: "Password" }]
105
95
  }
106
96
  ]
107
97
  },
@@ -137,7 +127,11 @@ const metaTabsTrigger = {
137
127
  icon: TriggerIcon,
138
128
  requiredAncestors: ["TabsList"],
139
129
  invalidAncestors: ["TabsTrigger"],
140
- indexWithinAncestor: "Tabs"
130
+ indexWithinAncestor: "Tabs",
131
+ label: "Tab Trigger",
132
+ presetStyle: {
133
+ button: [button, buttonReset].flat()
134
+ }
141
135
  };
142
136
  const metaTabsContent = {
143
137
  category: "hidden",
@@ -145,7 +139,8 @@ const metaTabsContent = {
145
139
  icon: ContentIcon,
146
140
  requiredAncestors: ["Tabs"],
147
141
  indexWithinAncestor: "Tabs",
148
- presetStyle
142
+ presetStyle,
143
+ label: "Tab Content"
149
144
  };
150
145
  const propsMetaTabs = {
151
146
  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
+ };