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