@webstudio-is/sdk-components-react-radix 0.90.0 → 0.92.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 (199) hide show
  1. package/lib/__generated__/accordion.props.js +6 -12
  2. package/lib/__generated__/checkbox.props.js +3 -6
  3. package/lib/__generated__/collapsible.props.js +4 -8
  4. package/lib/__generated__/dialog.props.js +8 -16
  5. package/lib/__generated__/label.props.js +2 -4
  6. package/lib/__generated__/navigation-menu.props.js +8 -16
  7. package/lib/__generated__/popover.props.js +4 -8
  8. package/lib/__generated__/radio-group.props.js +4 -8
  9. package/lib/__generated__/select.props.js +15 -19
  10. package/lib/__generated__/sheet.props.js +8 -16
  11. package/lib/__generated__/switch.props.js +3 -6
  12. package/lib/__generated__/tabs.props.js +5 -10
  13. package/lib/__generated__/tooltip.props.js +4 -8
  14. package/lib/accordion.js +7 -14
  15. package/{src/accordion.stories.tsx → lib/accordion.stories.js} +9 -12
  16. package/lib/accordion.ws.js +11 -22
  17. package/lib/checkbox.js +3 -6
  18. package/lib/checkbox.stories.js +19 -0
  19. package/lib/checkbox.ws.js +5 -10
  20. package/lib/collapsible.js +5 -10
  21. package/{src/collapsible.stories.tsx → lib/collapsible.stories.js} +9 -12
  22. package/lib/collapsible.ws.js +7 -14
  23. package/lib/components.js +13 -62
  24. package/lib/dialog.js +9 -18
  25. package/{src/dialog.stories.tsx → lib/dialog.stories.js} +9 -12
  26. package/lib/dialog.ws.js +17 -30
  27. package/lib/hooks.js +2 -4
  28. package/lib/label.js +2 -4
  29. package/lib/label.stories.js +19 -0
  30. package/lib/label.ws.js +3 -6
  31. package/lib/metas.js +55 -105
  32. package/lib/navigation-menu.js +9 -18
  33. package/{src/navigation-menu.stories.tsx → lib/navigation-menu.stories.js} +9 -12
  34. package/lib/navigation-menu.ws.js +16 -31
  35. package/lib/popover.js +5 -10
  36. package/{src/popover.stories.tsx → lib/popover.stories.js} +9 -12
  37. package/lib/popover.ws.js +7 -14
  38. package/lib/props-descriptions.js +2 -4
  39. package/lib/props.js +54 -103
  40. package/lib/radio-group.js +4 -8
  41. package/lib/radio-group.stories.js +19 -0
  42. package/lib/radio-group.ws.js +7 -14
  43. package/lib/select.js +10 -20
  44. package/{src/select.stories.tsx → lib/select.stories.js} +9 -12
  45. package/lib/select.ws.js +17 -34
  46. package/lib/sheet.js +9 -18
  47. package/{src/sheet.stories.tsx → lib/sheet.stories.js} +9 -12
  48. package/lib/sheet.ws.js +2 -4
  49. package/lib/switch.js +3 -6
  50. package/lib/switch.stories.js +19 -0
  51. package/lib/switch.ws.js +5 -10
  52. package/lib/tabs.js +6 -12
  53. package/{src/tabs.stories.tsx → lib/tabs.stories.js} +9 -12
  54. package/lib/tabs.ws.js +9 -18
  55. package/lib/theme/__generated__/tailwind-theme.js +517 -0
  56. package/lib/theme/styles.js +3 -6
  57. package/lib/theme/tailwind-classes.js +149 -301
  58. package/lib/theme/tailwind-colors.js +2 -4
  59. package/lib/tooltip.js +5 -10
  60. package/{src/tooltip.stories.tsx → lib/tooltip.stories.js} +9 -12
  61. package/lib/tooltip.ws.js +7 -14
  62. package/lib/types/__generated__/accordion.props.d.ts +1 -1
  63. package/lib/types/__generated__/checkbox.props.d.ts +1 -1
  64. package/lib/types/__generated__/collapsible.props.d.ts +1 -1
  65. package/lib/types/__generated__/dialog.props.d.ts +1 -1
  66. package/lib/types/__generated__/label.props.d.ts +1 -1
  67. package/lib/types/__generated__/navigation-menu.props.d.ts +1 -1
  68. package/lib/types/__generated__/popover.props.d.ts +1 -1
  69. package/lib/types/__generated__/radio-group.props.d.ts +1 -1
  70. package/lib/types/__generated__/select.props.d.ts +1 -1
  71. package/lib/types/__generated__/sheet.props.d.ts +1 -1
  72. package/lib/types/__generated__/switch.props.d.ts +1 -1
  73. package/lib/types/__generated__/tabs.props.d.ts +1 -1
  74. package/lib/types/__generated__/tooltip.props.d.ts +1 -1
  75. package/lib/types/accordion.d.ts +1 -1
  76. package/lib/types/sheet.d.ts +1 -1
  77. package/lib/types/theme/__generated__/tailwind-theme.d.ts +26 -0
  78. package/lib/types/theme/styles.d.ts +60 -60
  79. package/lib/types/theme/tailwind-classes.d.ts +33 -33
  80. package/package.json +20 -23
  81. package/lib/__generated__/button.props.js +0 -565
  82. package/lib/__generated__/input.props.js +0 -668
  83. package/lib/__generated__/textarea.props.js +0 -577
  84. package/lib/cjs/__generated__/accordion.props.js +0 -2645
  85. package/lib/cjs/__generated__/button.props.js +0 -585
  86. package/lib/cjs/__generated__/checkbox.props.js +0 -1103
  87. package/lib/cjs/__generated__/collapsible.props.js +0 -1050
  88. package/lib/cjs/__generated__/dialog.props.js +0 -2623
  89. package/lib/cjs/__generated__/input.props.js +0 -688
  90. package/lib/cjs/__generated__/label.props.js +0 -541
  91. package/lib/cjs/__generated__/navigation-menu.props.js +0 -2585
  92. package/lib/cjs/__generated__/popover.props.js +0 -582
  93. package/lib/cjs/__generated__/radio-group.props.js +0 -1647
  94. package/lib/cjs/__generated__/select.props.js +0 -3698
  95. package/lib/cjs/__generated__/sheet.props.js +0 -2642
  96. package/lib/cjs/__generated__/switch.props.js +0 -1103
  97. package/lib/cjs/__generated__/tabs.props.js +0 -2144
  98. package/lib/cjs/__generated__/textarea.props.js +0 -597
  99. package/lib/cjs/__generated__/tooltip.props.js +0 -593
  100. package/lib/cjs/accordion.js +0 -67
  101. package/lib/cjs/accordion.ws.js +0 -285
  102. package/lib/cjs/checkbox.js +0 -31
  103. package/lib/cjs/checkbox.ws.js +0 -174
  104. package/lib/cjs/collapsible.js +0 -53
  105. package/lib/cjs/collapsible.ws.js +0 -122
  106. package/lib/cjs/components.js +0 -82
  107. package/lib/cjs/dialog.js +0 -89
  108. package/lib/cjs/dialog.ws.js +0 -314
  109. package/lib/cjs/hooks.js +0 -43
  110. package/lib/cjs/label.js +0 -37
  111. package/lib/cjs/label.ws.js +0 -75
  112. package/lib/cjs/metas.js +0 -84
  113. package/lib/cjs/navigation-menu.js +0 -107
  114. package/lib/cjs/navigation-menu.ws.js +0 -514
  115. package/lib/cjs/package.json +0 -1
  116. package/lib/cjs/popover.js +0 -90
  117. package/lib/cjs/popover.ws.js +0 -142
  118. package/lib/cjs/props-descriptions.js +0 -56
  119. package/lib/cjs/props.js +0 -82
  120. package/lib/cjs/radio-group.js +0 -30
  121. package/lib/cjs/radio-group.ws.js +0 -191
  122. package/lib/cjs/select.js +0 -83
  123. package/lib/cjs/select.ws.js +0 -350
  124. package/lib/cjs/sheet.js +0 -96
  125. package/lib/cjs/sheet.ws.js +0 -257
  126. package/lib/cjs/switch.js +0 -27
  127. package/lib/cjs/switch.ws.js +0 -173
  128. package/lib/cjs/tabs.js +0 -59
  129. package/lib/cjs/tabs.ws.js +0 -196
  130. package/lib/cjs/theme/radix-common-types.js +0 -16
  131. package/lib/cjs/theme/styles.js +0 -96
  132. package/lib/cjs/theme/tailwind-classes.js +0 -819
  133. package/lib/cjs/theme/tailwind-colors.js +0 -45
  134. package/lib/cjs/theme/tailwind-theme.js +0 -46
  135. package/lib/cjs/tooltip.js +0 -87
  136. package/lib/cjs/tooltip.ws.js +0 -143
  137. package/lib/theme/radix-common-types.js +0 -0
  138. package/lib/theme/tailwind-theme.js +0 -16
  139. package/lib/types/__generated__/button.props.d.ts +0 -2
  140. package/lib/types/__generated__/input.props.d.ts +0 -2
  141. package/lib/types/__generated__/textarea.props.d.ts +0 -2
  142. package/lib/types/theme/radix-common-types.d.ts +0 -85
  143. package/lib/types/theme/tailwind-theme.d.ts +0 -72
  144. package/src/__generated__/accordion.props.ts +0 -2949
  145. package/src/__generated__/button.props.ts +0 -635
  146. package/src/__generated__/checkbox.props.ts +0 -1217
  147. package/src/__generated__/collapsible.props.ts +0 -1156
  148. package/src/__generated__/dialog.props.ts +0 -2923
  149. package/src/__generated__/input.props.ts +0 -748
  150. package/src/__generated__/label.props.ts +0 -585
  151. package/src/__generated__/navigation-menu.props.ts +0 -2882
  152. package/src/__generated__/popover.props.ts +0 -626
  153. package/src/__generated__/radio-group.props.ts +0 -1828
  154. package/src/__generated__/select.props.ts +0 -4130
  155. package/src/__generated__/sheet.props.ts +0 -2942
  156. package/src/__generated__/switch.props.ts +0 -1217
  157. package/src/__generated__/tabs.props.ts +0 -2386
  158. package/src/__generated__/textarea.props.ts +0 -645
  159. package/src/__generated__/tooltip.props.ts +0 -639
  160. package/src/accordion.tsx +0 -88
  161. package/src/accordion.ws.ts +0 -296
  162. package/src/checkbox.stories.ts +0 -22
  163. package/src/checkbox.tsx +0 -22
  164. package/src/checkbox.ws.ts +0 -154
  165. package/src/collapsible.tsx +0 -62
  166. package/src/collapsible.ws.ts +0 -115
  167. package/src/components.ts +0 -50
  168. package/src/dialog.tsx +0 -92
  169. package/src/dialog.ws.tsx +0 -318
  170. package/src/hooks.ts +0 -22
  171. package/src/label.stories.ts +0 -22
  172. package/src/label.tsx +0 -15
  173. package/src/label.ws.ts +0 -50
  174. package/src/metas.ts +0 -74
  175. package/src/navigation-menu.tsx +0 -130
  176. package/src/navigation-menu.ws.ts +0 -524
  177. package/src/popover.tsx +0 -96
  178. package/src/popover.ws.tsx +0 -128
  179. package/src/props-descriptions.ts +0 -43
  180. package/src/props.ts +0 -73
  181. package/src/radio-group.stories.ts +0 -22
  182. package/src/radio-group.tsx +0 -17
  183. package/src/radio-group.ws.ts +0 -178
  184. package/src/select.tsx +0 -112
  185. package/src/select.ws.ts +0 -349
  186. package/src/sheet.tsx +0 -79
  187. package/src/sheet.ws.tsx +0 -236
  188. package/src/switch.stories.ts +0 -22
  189. package/src/switch.tsx +0 -10
  190. package/src/switch.ws.ts +0 -146
  191. package/src/tabs.tsx +0 -64
  192. package/src/tabs.ws.ts +0 -198
  193. package/src/theme/radix-common-types.ts +0 -496
  194. package/src/theme/styles.ts +0 -76
  195. package/src/theme/tailwind-classes.ts +0 -1026
  196. package/src/theme/tailwind-colors.ts +0 -39
  197. package/src/theme/tailwind-theme.ts +0 -24
  198. package/src/tooltip.tsx +0 -95
  199. package/src/tooltip.ws.tsx +0 -130
package/src/select.ws.ts DELETED
@@ -1,349 +0,0 @@
1
- import {
2
- SelectIcon,
3
- TriggerIcon,
4
- FormTextFieldIcon,
5
- ContentIcon,
6
- ItemIcon,
7
- ViewportIcon,
8
- TextIcon,
9
- CheckMarkIcon,
10
- } from "@webstudio-is/icons/svg";
11
- import type {
12
- EmbedTemplateInstance,
13
- PresetStyle,
14
- WsComponentMeta,
15
- WsComponentPropsMeta,
16
- WsEmbedTemplate,
17
- } from "@webstudio-is/react-sdk";
18
- import { button, div, span } from "@webstudio-is/react-sdk/css-normalize";
19
- import * as tc from "./theme/tailwind-classes";
20
- import {
21
- propsSelect,
22
- propsSelectContent,
23
- propsSelectItem,
24
- propsSelectItemIndicator,
25
- propsSelectItemText,
26
- propsSelectTrigger,
27
- propsSelectValue,
28
- propsSelectViewport,
29
- } from "./__generated__/select.props";
30
-
31
- const presetStyle = {
32
- div,
33
- } satisfies PresetStyle<"div">;
34
-
35
- const createSelectItem = ({
36
- props,
37
- children,
38
- }: {
39
- props?: EmbedTemplateInstance["props"];
40
- children: WsEmbedTemplate;
41
- }): EmbedTemplateInstance => ({
42
- type: "instance",
43
- component: "SelectItem",
44
- props,
45
- // relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none
46
- // focus:bg-accent focus:text-accent-foreground
47
- // data-[disabled]:pointer-events-none data-[disabled]:opacity-50
48
- styles: [
49
- tc.relative(),
50
- tc.flex(),
51
- tc.w("full"),
52
- tc.cursor("default"),
53
- tc.select("none"),
54
- tc.items("center"),
55
- tc.rounded("md"),
56
- tc.py(1.5),
57
- tc.pl(8),
58
- tc.pr(2),
59
- tc.text("sm"),
60
- tc.outline("none"),
61
- tc.focus([tc.bg("accent"), tc.text("accentForeground")].flat()),
62
- tc.state(
63
- [tc.pointerEvents("none"), tc.opacity(50)].flat(),
64
- "[data-disabled]"
65
- ),
66
- ].flat(),
67
- children: [
68
- {
69
- type: "instance",
70
- component: "SelectItemIndicator",
71
- // absolute left-2 flex h-3.5 w-3.5 items-center justify-center
72
- styles: [
73
- tc.absolute(),
74
- tc.left(2),
75
- tc.flex(),
76
- tc.h(3.5),
77
- tc.w(3.5),
78
- tc.items("center"),
79
- tc.justify("center"),
80
- ].flat(),
81
- children: [
82
- {
83
- type: "instance",
84
- component: "HtmlEmbed",
85
- label: "Indicator Icon",
86
- props: [
87
- {
88
- type: "string",
89
- name: "code",
90
- value: CheckMarkIcon,
91
- },
92
- ],
93
- children: [],
94
- },
95
- ],
96
- },
97
- {
98
- type: "instance",
99
- component: "SelectItemText",
100
- children,
101
- },
102
- ],
103
- });
104
-
105
- export const metaSelect: WsComponentMeta = {
106
- category: "radix",
107
- order: 10,
108
- type: "container",
109
- icon: SelectIcon,
110
- stylable: false,
111
- description:
112
- "Use within a form to give your users a list of options to choose from.",
113
- template: [
114
- {
115
- type: "instance",
116
- component: "Select",
117
- dataSources: {
118
- selectValue: { type: "variable", initialValue: "" },
119
- selectOpen: { type: "variable", initialValue: false },
120
- },
121
- props: [
122
- {
123
- name: "value",
124
- type: "dataSource",
125
- dataSourceName: "selectValue",
126
- },
127
- {
128
- name: "onValueChange",
129
- type: "action",
130
- value: [
131
- { type: "execute", args: ["value"], code: `selectValue = value` },
132
- ],
133
- },
134
- {
135
- name: "open",
136
- type: "dataSource",
137
- dataSourceName: "selectOpen",
138
- },
139
- {
140
- name: "onOpenChange",
141
- type: "action",
142
- value: [
143
- { type: "execute", args: ["open"], code: `selectOpen = open` },
144
- ],
145
- },
146
- ],
147
- children: [
148
- {
149
- type: "instance",
150
- component: "SelectTrigger",
151
- // flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background
152
- // placeholder:text-muted-foreground
153
- // focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2
154
- // disabled:cursor-not-allowed disabled:opacity-50
155
- styles: [
156
- tc.flex(),
157
- tc.h(10),
158
- tc.w("full"),
159
- tc.items("center"),
160
- tc.justify("between"),
161
- tc.rounded("md"),
162
- tc.border(),
163
- tc.border("input"),
164
- tc.bg("background"),
165
- tc.px(3),
166
- tc.py(2),
167
- tc.text("sm"),
168
- tc.state([tc.text("mutedForeground")].flat(), "::placeholder"),
169
- tc.focus(
170
- [tc.outline("none"), tc.ring("ring", 2, "background", 2)].flat()
171
- ),
172
- tc.disabled([tc.cursor("not-allowed"), tc.opacity(50)].flat()),
173
- ].flat(),
174
- children: [
175
- {
176
- type: "instance",
177
- component: "SelectValue",
178
- props: [{ name: "placeholder", type: "string", value: "Theme" }],
179
- children: [],
180
- },
181
- ],
182
- },
183
- {
184
- type: "instance",
185
- component: "SelectContent",
186
- // relative z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md
187
- // data-[state=open]:animate-in
188
- // data-[state=closed]:animate-out data-[state=closed]:fade-out-0
189
- // data-[state=open]:fade-in-0
190
- // data-[state=closed]:zoom-out-95
191
- // data-[state=open]:zoom-in-95
192
- // data-[side=bottom]:slide-in-from-top-2
193
- // data-[side=left]:slide-in-from-right-2
194
- // data-[side=right]:slide-in-from-left-2
195
- // data-[side=top]:slide-in-from-bottom-2
196
- // position=popper
197
- // data-[side=bottom]:translate-y-1
198
- // data-[side=left]:-translate-x-1
199
- // data-[side=right]:translate-x-1
200
- // data-[side=top]:-translate-y-1
201
- styles: [
202
- tc.relative(),
203
- tc.z(50),
204
- tc.property("minWidth", "8rem"),
205
- tc.overflow("hidden"),
206
- tc.rounded("md"),
207
- tc.border(),
208
- tc.bg("popover"),
209
- tc.text("popoverForeground"),
210
- tc.shadow("md"),
211
- ].flat(),
212
- children: [
213
- {
214
- type: "instance",
215
- component: "SelectViewport",
216
- // p-1
217
- // position=popper
218
- // h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]
219
- styles: [
220
- tc.p(1),
221
- tc.property("height", "--radix-select-trigger-height"),
222
- tc.w("full"),
223
- tc.property("minWidth", "--radix-select-trigger-width"),
224
- ].flat(),
225
- children: [
226
- createSelectItem({
227
- props: [{ name: "value", type: "string", value: "light" }],
228
- children: [{ type: "text", value: "Light" }],
229
- }),
230
- createSelectItem({
231
- props: [{ name: "value", type: "string", value: "dark" }],
232
- children: [{ type: "text", value: "Dark" }],
233
- }),
234
- createSelectItem({
235
- props: [{ name: "value", type: "string", value: "system" }],
236
- children: [{ type: "text", value: "System" }],
237
- }),
238
- ],
239
- },
240
- ],
241
- },
242
- ],
243
- },
244
- ],
245
- };
246
-
247
- export const metaSelectTrigger: WsComponentMeta = {
248
- category: "hidden",
249
- type: "container",
250
- icon: TriggerIcon,
251
- detachable: false,
252
- presetStyle: {
253
- button,
254
- },
255
- };
256
-
257
- export const metaSelectValue: WsComponentMeta = {
258
- category: "hidden",
259
- type: "container",
260
- label: "Value",
261
- icon: FormTextFieldIcon,
262
- detachable: false,
263
- presetStyle: {
264
- span,
265
- },
266
- };
267
-
268
- export const metaSelectContent: WsComponentMeta = {
269
- category: "hidden",
270
- type: "container",
271
- icon: ContentIcon,
272
- detachable: false,
273
- presetStyle,
274
- };
275
-
276
- export const metaSelectViewport: WsComponentMeta = {
277
- category: "hidden",
278
- type: "container",
279
- icon: ViewportIcon,
280
- detachable: false,
281
- presetStyle,
282
- };
283
-
284
- export const metaSelectItem: WsComponentMeta = {
285
- category: "hidden",
286
- type: "container",
287
- icon: ItemIcon,
288
- requiredAncestors: ["SelectViewport"],
289
- presetStyle,
290
- };
291
-
292
- export const metaSelectItemIndicator: WsComponentMeta = {
293
- category: "hidden",
294
- type: "container",
295
- label: "Indicator",
296
- icon: CheckMarkIcon,
297
- detachable: false,
298
- requiredAncestors: ["SelectItem"],
299
- presetStyle: {
300
- span,
301
- },
302
- };
303
-
304
- export const metaSelectItemText: WsComponentMeta = {
305
- category: "hidden",
306
- type: "container",
307
- label: "Item Text",
308
- icon: TextIcon,
309
- detachable: false,
310
- requiredAncestors: ["SelectItem"],
311
- presetStyle: {
312
- span,
313
- },
314
- };
315
-
316
- export const propsMetaSelect: WsComponentPropsMeta = {
317
- props: propsSelect,
318
- initialProps: ["value", "open", "name", "required"],
319
- };
320
-
321
- export const propsMetaSelectTrigger: WsComponentPropsMeta = {
322
- props: propsSelectTrigger,
323
- };
324
-
325
- export const propsMetaSelectValue: WsComponentPropsMeta = {
326
- props: propsSelectValue,
327
- initialProps: ["placeholder"],
328
- };
329
-
330
- export const propsMetaSelectContent: WsComponentPropsMeta = {
331
- props: propsSelectContent,
332
- };
333
-
334
- export const propsMetaSelectViewport: WsComponentPropsMeta = {
335
- props: propsSelectViewport,
336
- };
337
-
338
- export const propsMetaSelectItem: WsComponentPropsMeta = {
339
- props: propsSelectItem,
340
- initialProps: ["value"],
341
- };
342
-
343
- export const propsMetaSelectItemIndicator: WsComponentPropsMeta = {
344
- props: propsSelectItemIndicator,
345
- };
346
-
347
- export const propsMetaSelectItemText: WsComponentPropsMeta = {
348
- props: propsSelectItemText,
349
- };
package/src/sheet.tsx DELETED
@@ -1,79 +0,0 @@
1
- import {
2
- forwardRef,
3
- type ElementRef,
4
- type ComponentPropsWithoutRef,
5
- } from "react";
6
- import { getClosestInstance, type Hook } from "@webstudio-is/react-sdk";
7
- import * as Dialog from "./dialog";
8
-
9
- export const Sheet = Dialog.Dialog;
10
- export const SheetTrigger = Dialog.DialogTrigger;
11
- export const SheetOverlay = Dialog.DialogOverlay;
12
- export const SheetClose = Dialog.DialogClose;
13
- export const SheetTitle = Dialog.DialogTitle;
14
- export const SheetDescription = Dialog.DialogDescription;
15
-
16
- // eslint-disable-next-line react/display-name
17
- export const SheetContent = forwardRef<
18
- ElementRef<"div">,
19
- ComponentPropsWithoutRef<typeof Dialog.DialogContent> & {
20
- tag?: "div" | "nav";
21
- side?: "top" | "right" | "bottom" | "left";
22
- }
23
- >(
24
- (
25
- { tag = "nav", side = "left", role = "navigation", children, ...props },
26
- ref
27
- ) => {
28
- // Do not do this at args like { tag: Tag = "nav" }, generate-arg-types will not find defaultValue in that case
29
- const Tag = tag;
30
- return (
31
- <Dialog.DialogContent
32
- asChild={true}
33
- data-side={side}
34
- role={role}
35
- {...props}
36
- >
37
- <Tag ref={ref}>{children}</Tag>
38
- </Dialog.DialogContent>
39
- );
40
- }
41
- );
42
-
43
- /* BUILDER HOOKS */
44
-
45
- const namespace = "@webstudio-is/sdk-components-react-radix";
46
-
47
- // For each SheetOverlay component within the selection,
48
- // we identify its closest parent Sheet component
49
- // and update its open prop bound to variable.
50
- export const hooksSheet: Hook = {
51
- onNavigatorUnselect: (context, event) => {
52
- for (const instance of event.instancePath) {
53
- if (instance.component === `${namespace}:SheetOverlay`) {
54
- const sheet = getClosestInstance(
55
- event.instancePath,
56
- instance,
57
- `${namespace}:Sheet`
58
- );
59
- if (sheet) {
60
- context.setPropVariable(sheet.id, "open", false);
61
- }
62
- }
63
- }
64
- },
65
- onNavigatorSelect: (context, event) => {
66
- for (const instance of event.instancePath) {
67
- if (instance.component === `${namespace}:SheetOverlay`) {
68
- const sheet = getClosestInstance(
69
- event.instancePath,
70
- instance,
71
- `${namespace}:Sheet`
72
- );
73
- if (sheet) {
74
- context.setPropVariable(sheet.id, "open", true);
75
- }
76
- }
77
- }
78
- },
79
- };
package/src/sheet.ws.tsx DELETED
@@ -1,236 +0,0 @@
1
- import { HamburgerMenuIcon, LargeXIcon } from "@webstudio-is/icons/svg";
2
- import type { WsComponentMeta } from "@webstudio-is/react-sdk";
3
- import * as tc from "./theme/tailwind-classes";
4
- import { getButtonStyles } from "./theme/styles";
5
-
6
- /**
7
- * Styles source without animations:
8
- * https://github.com/shadcn-ui/ui/blob/main/apps/www/registry/default/ui/sheet.tsx
9
- *
10
- * Attributions
11
- * MIT License
12
- * Copyright (c) 2023 shadcn
13
- **/
14
- export const meta: WsComponentMeta = {
15
- category: "radix",
16
- order: 1,
17
- type: "container",
18
- icon: HamburgerMenuIcon,
19
- stylable: false,
20
- description:
21
- "Displays content in a menu that slides out from the side of the screen, triggered by a button. Use this component for a typical mobile hamburger menu.",
22
- template: [
23
- {
24
- type: "instance",
25
- component: "Dialog",
26
- label: "Sheet",
27
- dataSources: {
28
- sheetOpen: { type: "variable", initialValue: false },
29
- },
30
- props: [
31
- {
32
- type: "dataSource",
33
- name: "open",
34
- dataSourceName: "sheetOpen",
35
- },
36
- {
37
- name: "onOpenChange",
38
- type: "action",
39
- value: [
40
- { type: "execute", args: ["open"], code: `sheetOpen = open` },
41
- ],
42
- },
43
- ],
44
- children: [
45
- {
46
- type: "instance",
47
- component: "DialogTrigger",
48
- label: "Sheet Trigger",
49
- children: [
50
- {
51
- type: "instance",
52
- component: "Button",
53
- styles: getButtonStyles("ghost", "icon"),
54
- children: [
55
- {
56
- type: "instance",
57
- component: "HtmlEmbed",
58
- label: "Hamburger Menu Svg",
59
- props: [
60
- {
61
- type: "string",
62
- name: "code",
63
- value: HamburgerMenuIcon,
64
- },
65
- ],
66
- children: [],
67
- },
68
- ],
69
- },
70
- ],
71
- },
72
- {
73
- type: "instance",
74
- component: "DialogOverlay",
75
- label: "Sheet Overlay",
76
- /**
77
- * fixed inset-0 z-50 bg-background/80 backdrop-blur-sm
78
- * flex
79
- **/
80
- styles: [
81
- tc.fixed(),
82
- tc.inset(0),
83
- tc.z(50),
84
- tc.bg("background", 80),
85
- tc.backdropBlur("sm"),
86
- // To allow positioning Content
87
- tc.flex(),
88
- tc.flex("col"),
89
- tc.overflow("auto"),
90
- ].flat(),
91
- children: [
92
- {
93
- type: "instance",
94
- component: "DialogContent",
95
- label: "Sheet Content",
96
- /**
97
- * fixed w-full z-50
98
- * grid gap-4 max-w-lg
99
- * m-auto
100
- * border bg-background p-6 shadow-lg
101
- **/
102
- styles: [
103
- tc.w("full"),
104
- tc.z(50),
105
- tc.flex(),
106
- tc.flex("col"),
107
- tc.gap(4),
108
- tc.border(),
109
- tc.bg("background"),
110
- tc.p(6),
111
- tc.shadow("lg"),
112
- tc.relative(),
113
- // side=left
114
- tc.mr("auto"),
115
- tc.maxW("sm"),
116
- tc.grow(),
117
- ].flat(),
118
- children: [
119
- {
120
- type: "instance",
121
- component: "Box",
122
- label: "Navigation",
123
- props: [
124
- { name: "tag", type: "string", value: "nav" },
125
- { name: "role", type: "string", value: "navigation" },
126
- ],
127
- children: [
128
- {
129
- type: "instance",
130
- component: "Box",
131
- label: "Sheet Header",
132
- styles: [tc.flex(), tc.flex("col"), tc.gap(1)].flat(),
133
- children: [
134
- {
135
- type: "instance",
136
- component: "DialogTitle",
137
- label: "Sheet Title",
138
- /**
139
- * text-lg leading-none tracking-tight
140
- **/
141
- styles: [
142
- tc.my(0),
143
- tc.leading("none"),
144
- tc.text("lg"),
145
- tc.tracking("tight"),
146
- ].flat(),
147
- children: [
148
- {
149
- type: "text",
150
- value: "Sheet Title",
151
- },
152
- ],
153
- },
154
- {
155
- type: "instance",
156
- component: "DialogDescription",
157
- label: "Sheet Description",
158
- /**
159
- * text-sm text-muted-foreground
160
- **/
161
- styles: [
162
- tc.my(0),
163
- tc.text("sm"),
164
- tc.text("mutedForeground"),
165
- ].flat(),
166
- children: [
167
- {
168
- type: "text",
169
- value: "Sheet description text you can edit",
170
- },
171
- ],
172
- },
173
- ],
174
- },
175
-
176
- {
177
- type: "instance",
178
- component: "Text",
179
- children: [
180
- { type: "text", value: "The text you can edit" },
181
- ],
182
- },
183
- ],
184
- },
185
- {
186
- type: "instance",
187
- component: "DialogClose",
188
- label: "Close Button",
189
- /**
190
- * absolute right-4 top-4
191
- * rounded-sm opacity-70
192
- * ring-offset-background
193
- * hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2
194
- * flex items-center justify-center h-4 w-4
195
- **/
196
- styles: [
197
- tc.absolute(),
198
- tc.right(4),
199
- tc.top(4),
200
- tc.rounded("sm"),
201
- tc.opacity(70),
202
- tc.flex(),
203
- tc.items("center"),
204
- tc.justify("center"),
205
- tc.h(4),
206
- tc.w(4),
207
- tc.border(0),
208
- tc.bg("transparent"),
209
- tc.outline("none"),
210
- tc.hover(tc.opacity(100)),
211
- tc.focus(tc.ring("ring", 2, "background", 2)),
212
- ].flat(),
213
- children: [
214
- {
215
- type: "instance",
216
- component: "HtmlEmbed",
217
- label: "Close Icon",
218
- props: [
219
- {
220
- type: "string",
221
- name: "code",
222
- value: LargeXIcon,
223
- },
224
- ],
225
- children: [],
226
- },
227
- ],
228
- },
229
- ],
230
- },
231
- ],
232
- },
233
- ],
234
- },
235
- ],
236
- };
@@ -1,22 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react";
2
- import { renderComponentTemplate } from "@webstudio-is/react-sdk";
3
- import * as baseComponents from "@webstudio-is/sdk-components-react";
4
- import * as baseMetas from "@webstudio-is/sdk-components-react/metas";
5
- import * as radixComponents from "./components";
6
- import * as radixMetas from "./metas";
7
- import { Switch as SwitchPrimitive } from "./switch";
8
-
9
- export default {
10
- title: "Components/Switch",
11
- component: SwitchPrimitive,
12
- } satisfies Meta<typeof SwitchPrimitive>;
13
-
14
- export const Switch: StoryObj<typeof SwitchPrimitive> = {
15
- render: (props) =>
16
- renderComponentTemplate({
17
- name: "Switch",
18
- props: { ...props },
19
- components: { ...baseComponents, ...radixComponents },
20
- metas: { ...baseMetas, ...radixMetas },
21
- }),
22
- };
package/src/switch.tsx DELETED
@@ -1,10 +0,0 @@
1
- import type { ForwardRefExoticComponent, ComponentPropsWithRef } from "react";
2
- import { Root, Thumb } from "@radix-ui/react-switch";
3
-
4
- export const Switch: ForwardRefExoticComponent<
5
- ComponentPropsWithRef<typeof Root>
6
- > = Root;
7
-
8
- export const SwitchThumb: ForwardRefExoticComponent<
9
- ComponentPropsWithRef<typeof Thumb>
10
- > = Thumb;