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