@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
@@ -1,524 +0,0 @@
1
- import {
2
- ContentIcon,
3
- ListIcon,
4
- ListItemIcon,
5
- TriggerIcon,
6
- BoxIcon,
7
- ChevronDownIcon,
8
- ViewportIcon,
9
- NavigationMenuIcon,
10
- } from "@webstudio-is/icons/svg";
11
- import type {
12
- PresetStyle,
13
- WsComponentMeta,
14
- WsComponentPropsMeta,
15
- } from "@webstudio-is/react-sdk";
16
- import { div } from "@webstudio-is/react-sdk/css-normalize";
17
- import * as tc from "./theme/tailwind-classes";
18
- import { getButtonStyles } from "./theme/styles";
19
- import {
20
- propsNavigationMenu,
21
- propsNavigationMenuItem,
22
- propsNavigationMenuTrigger,
23
- propsNavigationMenuContent,
24
- propsNavigationMenuLink,
25
- propsNavigationMenuList,
26
- propsNavigationMenuViewport,
27
- } from "./__generated__/navigation-menu.props";
28
-
29
- const presetStyle = {
30
- div,
31
- } satisfies PresetStyle<"div">;
32
-
33
- const components = [
34
- {
35
- title: "Sheet",
36
- href: "/docs/components/sheet",
37
- description:
38
- "Extends the Dialog component to display content that complements the main content of the screen.",
39
- },
40
- {
41
- title: "Navigation Menu",
42
- href: "/docs/components/navigation-menu",
43
- description: "A collection of links for navigating websites.",
44
- },
45
- {
46
- title: "Tabs",
47
- href: "/docs/components/tabs",
48
- description:
49
- "A set of layered sections of content—known as tab panels—that are displayed one at a time.",
50
- },
51
- {
52
- title: "Accordion",
53
- href: "/docs/components/accordion",
54
- description:
55
- "A vertically stacked set of interactive headings that each reveal a section of content.",
56
- },
57
- {
58
- title: "Dialog",
59
- href: "/docs/components/dialog",
60
- description:
61
- "A window overlaid on either the primary window or another dialog window, rendering the content underneath inert.",
62
- },
63
- {
64
- title: "Collapsible",
65
- href: "/docs/components/collapsible",
66
- description: "An interactive component which expands/collapses a panel.",
67
- },
68
-
69
- {
70
- title: "Popover",
71
- href: "/docs/components/popover",
72
- description: "Displays rich content in a portal, triggered by a button.",
73
- },
74
-
75
- {
76
- title: "Tooltip",
77
- href: "/docs/components/tooltip",
78
- description:
79
- "A popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it.",
80
- },
81
-
82
- {
83
- title: "Button",
84
- href: "/docs/components/button",
85
- description: "Displays a button or a component that looks like a button.",
86
- },
87
- ];
88
-
89
- const navItem = (
90
- props: (typeof components)[number]
91
- ): NonNullable<WsComponentMeta["template"]> => [
92
- {
93
- type: "instance",
94
- component: "NavigationMenuLink",
95
- children: [
96
- {
97
- type: "instance",
98
- component: "Link",
99
- // block select-none space-y-1 rounded-md p-3 leading-none
100
- // no-underline outline-none transition-colors
101
- // hover:bg-accent hover:text-accent-foreground
102
- // focus:bg-accent focus:text-accent-foreground
103
- styles: [
104
- tc.text("inherit"),
105
- tc.flex(),
106
- tc.flex("col"),
107
- tc.select("none"),
108
- tc.gap(1),
109
- tc.rounded("md"),
110
- tc.p(3),
111
- tc.leading("none"),
112
- tc.noUnderline(),
113
- tc.outline("none"),
114
- tc.hover([tc.bg("accent"), tc.text("accentForeground")].flat()),
115
- tc.focus([tc.bg("accent"), tc.text("accentForeground")].flat()),
116
- ].flat(),
117
- props: [
118
- {
119
- name: "href",
120
- type: "string",
121
- value: `https://ui.shadcn.com${props.href}`,
122
- },
123
- ],
124
- children: [
125
- {
126
- type: "instance",
127
- component: "Text",
128
- // text-sm font-medium leading-none
129
- styles: [
130
- tc.text("sm"),
131
- tc.font("medium"),
132
- tc.leading("none"),
133
- ].flat(),
134
- children: [
135
- {
136
- type: "text",
137
- value: props.title,
138
- },
139
- ],
140
- },
141
- {
142
- type: "instance",
143
- component: "Paragraph",
144
- // line-clamp-2 text-sm leading-snug text-muted-foreground
145
- styles: [
146
- tc.m(0),
147
- tc.lineClamp(2),
148
- tc.text("sm"),
149
- tc.leading("snug"),
150
- tc.text("mutedForeground"),
151
- ].flat(),
152
-
153
- children: [
154
- {
155
- type: "text",
156
- value: props.description,
157
- },
158
- ],
159
- },
160
- ],
161
- },
162
- ],
163
- },
164
- ];
165
-
166
- const navItemsList = (props: {
167
- count: number;
168
- offset: number;
169
- }): NonNullable<WsComponentMeta["template"]> => [
170
- {
171
- type: "instance",
172
- component: "Box",
173
- label: "Flex Column",
174
- styles: [tc.w(64), tc.flex(), tc.gap(4), tc.flex("col")].flat(),
175
- children: Array.from(Array(props.count), (_, index) =>
176
- navItem(components[index + props.offset])
177
- ).flat(),
178
- },
179
- ];
180
-
181
- const menuItemLink = (props: {
182
- title: string;
183
- }): NonNullable<WsComponentMeta["template"]> => [
184
- {
185
- type: "instance",
186
- component: "NavigationMenuItem",
187
- children: [
188
- {
189
- type: "instance",
190
- component: "NavigationMenuLink",
191
- children: [
192
- {
193
- type: "instance",
194
- component: "Link",
195
- styles: [
196
- getButtonStyles("ghost", "sm"),
197
- tc.noUnderline(),
198
- tc.text("current"),
199
- ].flat(),
200
- children: [{ type: "text", value: props.title }],
201
- },
202
- ],
203
- },
204
- ],
205
- },
206
- ];
207
-
208
- const menuItem = (props: {
209
- title: string;
210
- children: NonNullable<WsComponentMeta["template"]>;
211
- padding: 0 | 2;
212
- }): NonNullable<WsComponentMeta["template"]> => [
213
- {
214
- type: "instance",
215
- component: "NavigationMenuItem",
216
- children: [
217
- {
218
- type: "instance",
219
- component: "NavigationMenuTrigger",
220
- children: [
221
- {
222
- type: "instance",
223
- component: "Button",
224
- styles: [
225
- getButtonStyles("ghost", "sm"),
226
- tc.property("--navigation-menu-trigger-icon-transform", "0deg"),
227
- tc.state(
228
- [
229
- tc.property(
230
- "--navigation-menu-trigger-icon-transform",
231
- "180deg"
232
- ),
233
- ],
234
- "[data-state=open]"
235
- ),
236
- ].flat(),
237
- children: [
238
- {
239
- type: "instance",
240
- component: "Text",
241
- children: [{ type: "text", value: props.title }],
242
- },
243
- {
244
- type: "instance",
245
- component: "Box",
246
- label: "Icon Container",
247
- // h-4 w-4 shrink-0 transition-transform duration-200
248
- styles: [
249
- tc.ml(1),
250
- tc.property(
251
- "rotate",
252
- "--navigation-menu-trigger-icon-transform"
253
- ),
254
- tc.h(4),
255
- tc.w(4),
256
- tc.shrink(0),
257
- tc.transition("all"),
258
- tc.duration(200),
259
- ].flat(),
260
- children: [
261
- {
262
- type: "instance",
263
- component: "HtmlEmbed",
264
- label: "Chevron Icon",
265
- props: [
266
- {
267
- type: "string",
268
- name: "code",
269
- value: ChevronDownIcon,
270
- },
271
- ],
272
- children: [],
273
- },
274
- ],
275
- },
276
- ],
277
- },
278
- ],
279
- },
280
- {
281
- type: "instance",
282
- component: "NavigationMenuContent",
283
- // left-0 top-0 absolute w-max
284
- styles: [
285
- tc.left(0),
286
- tc.top(0),
287
- tc.absolute(),
288
- tc.w("max"),
289
- tc.p(4),
290
- ].flat(),
291
- children: [
292
- {
293
- type: "instance",
294
- component: "Box",
295
- label: "Content",
296
- styles: [tc.flex(), tc.gap(4), tc.p(props.padding)].flat(),
297
- children: props.children,
298
- },
299
- ],
300
- },
301
- ],
302
- },
303
- ];
304
-
305
- export const metaNavigationMenu: WsComponentMeta = {
306
- category: "radix",
307
- order: 2,
308
- type: "container",
309
- description: "A collection of links for navigating websites.",
310
- icon: NavigationMenuIcon,
311
- presetStyle,
312
-
313
- template: [
314
- {
315
- type: "instance",
316
- component: "NavigationMenu",
317
- dataSources: {
318
- menuValue: { type: "variable", initialValue: "" },
319
- },
320
- props: [
321
- { type: "dataSource", name: "value", dataSourceName: "menuValue" },
322
- {
323
- name: "onValueChange",
324
- type: "action",
325
- value: [
326
- {
327
- type: "execute",
328
- args: ["value"],
329
- code: `menuValue = value`,
330
- },
331
- ],
332
- },
333
- ],
334
- // relative
335
- // Omiting this: z-10 flex max-w-max flex-1 items-center justify-center
336
- styles: [tc.relative(), tc.maxW("max")].flat(),
337
- children: [
338
- {
339
- type: "instance",
340
- component: "NavigationMenuList",
341
- styles: [
342
- // ul defaults in tailwind
343
- tc.p(0),
344
- tc.m(0),
345
- // shadcdn styles
346
- tc.flex(),
347
- tc.flex(1),
348
- tc.list("none"),
349
- tc.items("center"),
350
- tc.justify("center"),
351
- tc.gap(1),
352
- ].flat(),
353
- children: [
354
- ...menuItem({
355
- title: "About",
356
- padding: 2,
357
- children: [
358
- {
359
- type: "instance",
360
- component: "Box",
361
- styles: [
362
- tc.bg("border"),
363
- tc.p(4),
364
- tc.w(48),
365
- tc.rounded("md"),
366
- ].flat(),
367
- children: [
368
- {
369
- type: "text",
370
- value: "",
371
- },
372
- ],
373
- },
374
- ...navItemsList({ count: 3, offset: 0 }),
375
- ],
376
- }),
377
- ...menuItem({
378
- title: "Components",
379
- padding: 0,
380
- children: [
381
- ...navItemsList({ count: 3, offset: 3 }),
382
- ...navItemsList({ count: 3, offset: 6 }),
383
- ],
384
- }),
385
- ...menuItemLink({ title: "Standalone" }),
386
- ],
387
- },
388
-
389
- {
390
- type: "instance",
391
- component: "Box",
392
- label: "Viewport Container",
393
- // absolute left-0 top-full flex justify-center
394
- styles: [
395
- tc.absolute(),
396
- tc.left(0),
397
- tc.top("full"),
398
- tc.flex(),
399
- tc.justify("center"),
400
- ].flat(),
401
-
402
- children: [
403
- {
404
- type: "instance",
405
- component: "NavigationMenuViewport",
406
- /*
407
- origin-top-center relative mt-1.5 w-full
408
- overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-lg
409
- h-[var(--radix-navigation-menu-viewport-height)]
410
- w-[var(--radix-navigation-menu-viewport-width)]
411
- // anims
412
- [animation-duration:150ms!important] [transition-duration:150ms!important]
413
- data-[state=open]:animate-in data-[state=closed]:animate-out
414
- data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90
415
- */
416
- styles: [
417
- tc.relative(),
418
- tc.mt(1.5),
419
- tc.overflow("hidden"),
420
- tc.rounded("md"),
421
- tc.border(),
422
- tc.bg("popover"),
423
- tc.text("popoverForeground"),
424
- tc.shadow("lg"),
425
- tc.property(
426
- "height",
427
- "--radix-navigation-menu-viewport-height"
428
- ),
429
- tc.property("width", "--radix-navigation-menu-viewport-width"),
430
- ].flat(),
431
- children: [],
432
- },
433
- ],
434
- },
435
- ],
436
- },
437
- ],
438
- };
439
-
440
- export const metaNavigationMenuList: WsComponentMeta = {
441
- category: "hidden",
442
- detachable: false,
443
- type: "container",
444
- icon: ListIcon,
445
- requiredAncestors: ["NavigationMenu"],
446
- presetStyle,
447
- label: "Menu List",
448
- };
449
-
450
- export const metaNavigationMenuItem: WsComponentMeta = {
451
- category: "hidden",
452
- type: "container",
453
- icon: ListItemIcon,
454
- requiredAncestors: ["NavigationMenu"],
455
- presetStyle,
456
- indexWithinAncestor: "NavigationMenu",
457
- label: "Menu Item",
458
- };
459
- export const metaNavigationMenuTrigger: WsComponentMeta = {
460
- category: "hidden",
461
- detachable: false,
462
- stylable: false,
463
- type: "container",
464
- icon: TriggerIcon,
465
- requiredAncestors: ["NavigationMenuItem"],
466
- presetStyle,
467
- label: "Menu Trigger",
468
- };
469
- export const metaNavigationMenuContent: WsComponentMeta = {
470
- category: "hidden",
471
- detachable: false,
472
- type: "container",
473
- icon: ContentIcon,
474
- requiredAncestors: ["NavigationMenuItem"],
475
- indexWithinAncestor: "NavigationMenu",
476
- presetStyle,
477
- label: "Menu Content",
478
- };
479
-
480
- export const metaNavigationMenuLink: WsComponentMeta = {
481
- category: "hidden",
482
- detachable: true,
483
- type: "container",
484
- stylable: false,
485
- icon: BoxIcon,
486
- // https://github.com/webstudio-is/webstudio-builder/issues/2193
487
- // requiredAncestors: ["NavigationMenuContent", "NavigationMenuItem"],
488
- // Temporary restrict to NavigationMenu
489
- requiredAncestors: ["NavigationMenu"],
490
- presetStyle,
491
- label: "Accessible Link Wrapper",
492
- };
493
-
494
- export const metaNavigationMenuViewport: WsComponentMeta = {
495
- category: "hidden",
496
- detachable: true,
497
- type: "container",
498
- icon: ViewportIcon,
499
- requiredAncestors: ["NavigationMenu"],
500
- presetStyle,
501
- label: "Menu Viewport",
502
- };
503
-
504
- export const propsMetaNavigationMenu: WsComponentPropsMeta = {
505
- props: propsNavigationMenu,
506
- };
507
- export const propsMetaNavigationMenuItem: WsComponentPropsMeta = {
508
- props: propsNavigationMenuItem,
509
- };
510
- export const propsMetaNavigationMenuTrigger: WsComponentPropsMeta = {
511
- props: propsNavigationMenuTrigger,
512
- };
513
- export const propsMetaNavigationMenuContent: WsComponentPropsMeta = {
514
- props: propsNavigationMenuContent,
515
- };
516
- export const propsMetaNavigationMenuLink: WsComponentPropsMeta = {
517
- props: propsNavigationMenuLink,
518
- };
519
- export const propsMetaNavigationMenuList: WsComponentPropsMeta = {
520
- props: propsNavigationMenuList,
521
- };
522
- export const propsMetaNavigationMenuViewport: WsComponentPropsMeta = {
523
- props: propsNavigationMenuViewport,
524
- };
package/src/popover.tsx DELETED
@@ -1,96 +0,0 @@
1
- /* eslint-disable react/display-name */
2
- // We can't use .displayName until this is merged https://github.com/styleguidist/react-docgen-typescript/pull/449
3
-
4
- import {
5
- type ComponentPropsWithoutRef,
6
- type ReactNode,
7
- forwardRef,
8
- Children,
9
- } from "react";
10
- import * as PopoverPrimitive from "@radix-ui/react-popover";
11
- import { getClosestInstance, type Hook } from "@webstudio-is/react-sdk";
12
-
13
- // wrap in forwardRef because Root is functional component without ref
14
- export const Popover = forwardRef<
15
- HTMLDivElement,
16
- Omit<ComponentPropsWithoutRef<typeof PopoverPrimitive.Root>, "defaultOpen">
17
- >((props, _ref) => {
18
- return <PopoverPrimitive.Root {...props} />;
19
- });
20
-
21
- /**
22
- * We're not exposing the 'asChild' property for the Trigger.
23
- * Instead, we're enforcing 'asChild=true' for the Trigger and making it style-less.
24
- * This avoids situations where the Trigger inadvertently passes all styles to its child,
25
- * which would prevent us from displaying styles properly in the builder.
26
- */
27
- export const PopoverTrigger = forwardRef<
28
- HTMLButtonElement,
29
- { children: ReactNode }
30
- >(({ children, ...props }, ref) => {
31
- const firstChild = Children.toArray(children)[0];
32
-
33
- return (
34
- <PopoverPrimitive.Trigger asChild={true} ref={ref} {...props}>
35
- {firstChild ?? <button>Add button or link</button>}
36
- </PopoverPrimitive.Trigger>
37
- );
38
- });
39
-
40
- export const PopoverContent = forwardRef<
41
- HTMLDivElement,
42
- ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
43
- >(
44
- (
45
- { sideOffset = 4, align = "center", hideWhenDetached = true, ...props },
46
- ref
47
- ) => (
48
- <PopoverPrimitive.Portal>
49
- <PopoverPrimitive.Content
50
- ref={ref}
51
- align="center"
52
- sideOffset={sideOffset}
53
- hideWhenDetached={hideWhenDetached}
54
- {...props}
55
- />
56
- </PopoverPrimitive.Portal>
57
- )
58
- );
59
-
60
- /* BUILDER HOOKS */
61
-
62
- const namespace = "@webstudio-is/sdk-components-react-radix";
63
-
64
- // For each PopoverContent component within the selection,
65
- // we identify its closest parent Popover component
66
- // and update its open prop bound to variable.
67
- export const hooksPopover: Hook = {
68
- onNavigatorUnselect: (context, event) => {
69
- for (const instance of event.instancePath) {
70
- if (instance.component === `${namespace}:PopoverContent`) {
71
- const popover = getClosestInstance(
72
- event.instancePath,
73
- instance,
74
- `${namespace}:Popover`
75
- );
76
- if (popover) {
77
- context.setPropVariable(popover.id, "open", false);
78
- }
79
- }
80
- }
81
- },
82
- onNavigatorSelect: (context, event) => {
83
- for (const instance of event.instancePath) {
84
- if (instance.component === `${namespace}:PopoverContent`) {
85
- const popover = getClosestInstance(
86
- event.instancePath,
87
- instance,
88
- `${namespace}:Popover`
89
- );
90
- if (popover) {
91
- context.setPropVariable(popover.id, "open", true);
92
- }
93
- }
94
- }
95
- },
96
- };