@webstudio-is/sdk-components-react 0.83.0 → 0.85.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/cjs/components.js +0 -16
- package/lib/cjs/form.ws.js +1 -1
- package/lib/cjs/list.ws.js +1 -1
- package/lib/cjs/metas.js +0 -16
- package/lib/cjs/props.js +0 -16
- package/lib/components.js +0 -24
- package/lib/form.ws.js +1 -1
- package/lib/list.ws.js +1 -1
- package/lib/metas.js +0 -32
- package/lib/props.js +0 -32
- package/lib/types/components.d.ts +0 -3
- package/lib/types/metas.d.ts +0 -3
- package/lib/types/props.d.ts +0 -3
- package/lib/types/vimeo-preview-image.d.ts +3 -3
- package/package.json +8 -13
- package/src/components.ts +0 -11
- package/src/form.ws.tsx +1 -1
- package/src/list.ws.tsx +1 -1
- package/src/metas.ts +0 -21
- package/src/props.ts +0 -19
- package/lib/__generated__/radix-dialog.props.js +0 -2120
- package/lib/__generated__/radix-popover.props.js +0 -463
- package/lib/__generated__/radix-tooltip.props.js +0 -473
- package/lib/cjs/__generated__/radix-dialog.props.js +0 -2140
- package/lib/cjs/__generated__/radix-popover.props.js +0 -483
- package/lib/cjs/__generated__/radix-tooltip.props.js +0 -493
- package/lib/cjs/radix-dialog.js +0 -61
- package/lib/cjs/radix-dialog.ws.js +0 -300
- package/lib/cjs/radix-popover.js +0 -59
- package/lib/cjs/radix-popover.ws.js +0 -139
- package/lib/cjs/radix-tooltip.js +0 -51
- package/lib/cjs/radix-tooltip.ws.js +0 -140
- package/lib/cjs/theme/radix-common-types.js +0 -16
- package/lib/cjs/theme/tailwind-classes.js +0 -439
- package/lib/cjs/theme/tailwind-colors.js +0 -33
- package/lib/cjs/theme/tailwind-theme.js +0 -46
- package/lib/radix-dialog.js +0 -36
- package/lib/radix-dialog.ws.js +0 -279
- package/lib/radix-popover.js +0 -34
- package/lib/radix-popover.ws.js +0 -114
- package/lib/radix-tooltip.js +0 -26
- package/lib/radix-tooltip.ws.js +0 -115
- package/lib/theme/radix-common-types.js +0 -0
- package/lib/theme/tailwind-classes.js +0 -419
- package/lib/theme/tailwind-colors.js +0 -13
- package/lib/theme/tailwind-theme.js +0 -16
- package/lib/types/__generated__/radix-dialog.props.d.ts +0 -8
- package/lib/types/__generated__/radix-popover.props.d.ts +0 -4
- package/lib/types/__generated__/radix-tooltip.props.d.ts +0 -4
- package/lib/types/radix-dialog.d.ts +0 -26
- package/lib/types/radix-dialog.ws.d.ts +0 -23
- package/lib/types/radix-popover.d.ts +0 -22
- package/lib/types/radix-popover.ws.d.ts +0 -15
- package/lib/types/radix-tooltip.d.ts +0 -22
- package/lib/types/radix-tooltip.ws.d.ts +0 -15
- package/lib/types/theme/radix-common-types.d.ts +0 -84
- package/lib/types/theme/tailwind-classes.d.ts +0 -69
- package/lib/types/theme/tailwind-colors.d.ts +0 -19
- package/lib/types/theme/tailwind-theme.d.ts +0 -72
- package/src/__generated__/radix-dialog.props.ts +0 -2363
- package/src/__generated__/radix-popover.props.ts +0 -510
- package/src/__generated__/radix-tooltip.props.ts +0 -521
- package/src/radix-dialog.tsx +0 -91
- package/src/radix-dialog.ws.tsx +0 -291
- package/src/radix-popover.tsx +0 -89
- package/src/radix-popover.ws.tsx +0 -124
- package/src/radix-tooltip.tsx +0 -84
- package/src/radix-tooltip.ws.tsx +0 -125
- package/src/theme/radix-common-types.ts +0 -495
- package/src/theme/tailwind-classes.ts +0 -570
- package/src/theme/tailwind-colors.ts +0 -47
- package/src/theme/tailwind-theme.ts +0 -24
package/src/radix-dialog.ws.tsx
DELETED
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import { RadioCheckedIcon } from "@webstudio-is/icons/svg";
|
|
2
|
-
import {
|
|
3
|
-
type WsComponentMeta,
|
|
4
|
-
type WsComponentPropsMeta,
|
|
5
|
-
} from "@webstudio-is/react-sdk";
|
|
6
|
-
import * as tc from "./theme/tailwind-classes";
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
propsDialog,
|
|
10
|
-
propsDialogContent,
|
|
11
|
-
propsDialogTrigger,
|
|
12
|
-
propsDialogOverlay,
|
|
13
|
-
propsDialogClose,
|
|
14
|
-
propsDialogTitle,
|
|
15
|
-
propsDialogDescription,
|
|
16
|
-
} from "./__generated__/radix-dialog.props";
|
|
17
|
-
|
|
18
|
-
// @todo add [data-state] to button and link
|
|
19
|
-
export const metaDialogTrigger: WsComponentMeta = {
|
|
20
|
-
category: "hidden",
|
|
21
|
-
invalidAncestors: [],
|
|
22
|
-
type: "container",
|
|
23
|
-
label: "DialogTrigger",
|
|
24
|
-
icon: RadioCheckedIcon,
|
|
25
|
-
stylable: false,
|
|
26
|
-
detachable: false,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const metaDialogContent: WsComponentMeta = {
|
|
30
|
-
category: "hidden",
|
|
31
|
-
invalidAncestors: [],
|
|
32
|
-
type: "container",
|
|
33
|
-
label: "DialogContent",
|
|
34
|
-
icon: RadioCheckedIcon,
|
|
35
|
-
detachable: false,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export const metaDialogOverlay: WsComponentMeta = {
|
|
39
|
-
category: "hidden",
|
|
40
|
-
invalidAncestors: [],
|
|
41
|
-
type: "container",
|
|
42
|
-
label: "DialogOverlay",
|
|
43
|
-
icon: RadioCheckedIcon,
|
|
44
|
-
detachable: false,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export const metaDialogTitle: WsComponentMeta = {
|
|
48
|
-
category: "hidden",
|
|
49
|
-
invalidAncestors: [],
|
|
50
|
-
type: "container",
|
|
51
|
-
label: "DialogTitle",
|
|
52
|
-
icon: RadioCheckedIcon,
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export const metaDialogDescription: WsComponentMeta = {
|
|
56
|
-
category: "hidden",
|
|
57
|
-
invalidAncestors: [],
|
|
58
|
-
type: "container",
|
|
59
|
-
label: "DialogDescription",
|
|
60
|
-
icon: RadioCheckedIcon,
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export const metaDialogClose: WsComponentMeta = {
|
|
64
|
-
category: "hidden",
|
|
65
|
-
invalidAncestors: [],
|
|
66
|
-
type: "container",
|
|
67
|
-
label: "DialogClose",
|
|
68
|
-
icon: RadioCheckedIcon,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Styles source without animations:
|
|
73
|
-
* https://github.com/shadcn-ui/ui/blob/main/apps/www/registry/default/ui/dialog.tsx
|
|
74
|
-
*
|
|
75
|
-
* Attributions
|
|
76
|
-
* MIT License
|
|
77
|
-
* Copyright (c) 2023 shadcn
|
|
78
|
-
**/
|
|
79
|
-
export const metaDialog: WsComponentMeta = {
|
|
80
|
-
category: "radix",
|
|
81
|
-
invalidAncestors: [],
|
|
82
|
-
type: "container",
|
|
83
|
-
label: "Dialog",
|
|
84
|
-
icon: RadioCheckedIcon,
|
|
85
|
-
order: 15,
|
|
86
|
-
stylable: false,
|
|
87
|
-
template: [
|
|
88
|
-
{
|
|
89
|
-
type: "instance",
|
|
90
|
-
component: "Dialog",
|
|
91
|
-
label: "Dialog",
|
|
92
|
-
props: [
|
|
93
|
-
{
|
|
94
|
-
name: "isOpen",
|
|
95
|
-
// We don't have support for boolean or undefined, instead of binding on open we bind on a string
|
|
96
|
-
type: "string",
|
|
97
|
-
value: "initial",
|
|
98
|
-
dataSourceRef: {
|
|
99
|
-
type: "variable",
|
|
100
|
-
name: "isOpen",
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
],
|
|
104
|
-
children: [
|
|
105
|
-
{
|
|
106
|
-
type: "instance",
|
|
107
|
-
component: "DialogTrigger",
|
|
108
|
-
props: [],
|
|
109
|
-
children: [
|
|
110
|
-
{
|
|
111
|
-
type: "instance",
|
|
112
|
-
component: "Button",
|
|
113
|
-
children: [{ type: "text", value: "Button" }],
|
|
114
|
-
},
|
|
115
|
-
],
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
type: "instance",
|
|
119
|
-
component: "DialogOverlay",
|
|
120
|
-
label: "Dialog Overlay",
|
|
121
|
-
props: [],
|
|
122
|
-
/**
|
|
123
|
-
* fixed inset-0 z-50 bg-background/80 backdrop-blur-sm
|
|
124
|
-
* flex
|
|
125
|
-
**/
|
|
126
|
-
styles: [
|
|
127
|
-
tc.fixed(),
|
|
128
|
-
tc.inset(0),
|
|
129
|
-
tc.z(50),
|
|
130
|
-
tc.bg("background", 80),
|
|
131
|
-
tc.backdropBlur("sm"),
|
|
132
|
-
// To allow positioning Content
|
|
133
|
-
tc.flex(),
|
|
134
|
-
].flat(),
|
|
135
|
-
children: [
|
|
136
|
-
{
|
|
137
|
-
type: "instance",
|
|
138
|
-
component: "DialogContent",
|
|
139
|
-
label: "Dialog Content",
|
|
140
|
-
props: [],
|
|
141
|
-
/**
|
|
142
|
-
* fixed w-full z-50
|
|
143
|
-
* grid gap-4 max-w-lg
|
|
144
|
-
* m-auto
|
|
145
|
-
* border bg-background p-6 shadow-lg
|
|
146
|
-
**/
|
|
147
|
-
styles: [
|
|
148
|
-
tc.w("full"),
|
|
149
|
-
tc.z(50),
|
|
150
|
-
tc.flex(),
|
|
151
|
-
tc.flex("col"),
|
|
152
|
-
tc.gap(4),
|
|
153
|
-
tc.m("auto"),
|
|
154
|
-
tc.maxW("lg"),
|
|
155
|
-
tc.border(),
|
|
156
|
-
tc.bg("background"),
|
|
157
|
-
tc.p(6),
|
|
158
|
-
tc.shadow("lg"),
|
|
159
|
-
tc.relative(),
|
|
160
|
-
].flat(),
|
|
161
|
-
children: [
|
|
162
|
-
{
|
|
163
|
-
type: "instance",
|
|
164
|
-
component: "Box",
|
|
165
|
-
label: "Dialog Header",
|
|
166
|
-
props: [],
|
|
167
|
-
styles: [tc.flex(), tc.flex("col"), tc.gap(1)].flat(),
|
|
168
|
-
children: [
|
|
169
|
-
{
|
|
170
|
-
type: "instance",
|
|
171
|
-
component: "DialogTitle",
|
|
172
|
-
label: "Dialog Title",
|
|
173
|
-
props: [],
|
|
174
|
-
/**
|
|
175
|
-
* text-lg leading-none tracking-tight
|
|
176
|
-
**/
|
|
177
|
-
styles: [
|
|
178
|
-
tc.my(0),
|
|
179
|
-
tc.leading("none"),
|
|
180
|
-
tc.text("lg"),
|
|
181
|
-
tc.tracking("tight"),
|
|
182
|
-
].flat(),
|
|
183
|
-
children: [
|
|
184
|
-
{
|
|
185
|
-
type: "text",
|
|
186
|
-
value: "Dialog Title",
|
|
187
|
-
},
|
|
188
|
-
],
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
type: "instance",
|
|
192
|
-
component: "DialogDescription",
|
|
193
|
-
label: "Dialog Description",
|
|
194
|
-
props: [],
|
|
195
|
-
/**
|
|
196
|
-
* text-sm text-muted-foreground
|
|
197
|
-
**/
|
|
198
|
-
styles: [
|
|
199
|
-
tc.my(0),
|
|
200
|
-
tc.text("sm"),
|
|
201
|
-
tc.text("mutedForeground"),
|
|
202
|
-
].flat(),
|
|
203
|
-
children: [
|
|
204
|
-
{
|
|
205
|
-
type: "text",
|
|
206
|
-
value: "dialog description text you can edit",
|
|
207
|
-
},
|
|
208
|
-
],
|
|
209
|
-
},
|
|
210
|
-
],
|
|
211
|
-
},
|
|
212
|
-
|
|
213
|
-
{
|
|
214
|
-
type: "instance",
|
|
215
|
-
component: "Text",
|
|
216
|
-
children: [{ type: "text", value: "The text you can edit" }],
|
|
217
|
-
},
|
|
218
|
-
|
|
219
|
-
{
|
|
220
|
-
type: "instance",
|
|
221
|
-
component: "DialogClose",
|
|
222
|
-
label: "Dialog Close",
|
|
223
|
-
props: [],
|
|
224
|
-
/**
|
|
225
|
-
* absolute right-4 top-4
|
|
226
|
-
* rounded-sm opacity-70
|
|
227
|
-
* ring-offset-background
|
|
228
|
-
* hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2
|
|
229
|
-
* flex items-center justify-center h-4 w-4
|
|
230
|
-
**/
|
|
231
|
-
styles: [
|
|
232
|
-
tc.absolute(),
|
|
233
|
-
tc.right(4),
|
|
234
|
-
tc.top(4),
|
|
235
|
-
tc.rounded("sm"),
|
|
236
|
-
tc.opacity(70),
|
|
237
|
-
tc.flex(),
|
|
238
|
-
tc.items("center"),
|
|
239
|
-
tc.justify("center"),
|
|
240
|
-
tc.h(4),
|
|
241
|
-
tc.w(4),
|
|
242
|
-
tc.border(0),
|
|
243
|
-
tc.bg("transparent"),
|
|
244
|
-
tc.outline("none"),
|
|
245
|
-
tc.hover(tc.opacity(100)),
|
|
246
|
-
tc.focus(tc.ring("ring", 2, "background", 2)),
|
|
247
|
-
].flat(),
|
|
248
|
-
children: [{ type: "text", value: "✕" }],
|
|
249
|
-
},
|
|
250
|
-
],
|
|
251
|
-
},
|
|
252
|
-
],
|
|
253
|
-
},
|
|
254
|
-
],
|
|
255
|
-
},
|
|
256
|
-
],
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
export const propsMetaDialog: WsComponentPropsMeta = {
|
|
260
|
-
props: propsDialog,
|
|
261
|
-
initialProps: ["isOpen", "modal"],
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
export const propsMetaDialogTrigger: WsComponentPropsMeta = {
|
|
265
|
-
props: propsDialogTrigger,
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
export const propsMetaDialogContent: WsComponentPropsMeta = {
|
|
269
|
-
props: propsDialogContent,
|
|
270
|
-
initialProps: [],
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
export const propsMetaDialogOverlay: WsComponentPropsMeta = {
|
|
274
|
-
props: propsDialogOverlay,
|
|
275
|
-
initialProps: [],
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
export const propsMetaDialogClose: WsComponentPropsMeta = {
|
|
279
|
-
props: propsDialogClose,
|
|
280
|
-
initialProps: [],
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
export const propsMetaDialogTitle: WsComponentPropsMeta = {
|
|
284
|
-
props: propsDialogTitle,
|
|
285
|
-
initialProps: [],
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
export const propsMetaDialogDescription: WsComponentPropsMeta = {
|
|
289
|
-
props: propsDialogDescription,
|
|
290
|
-
initialProps: [],
|
|
291
|
-
};
|
package/src/radix-popover.tsx
DELETED
|
@@ -1,89 +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 * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
5
|
-
import {
|
|
6
|
-
splitPropsWithWebstudioAttributes,
|
|
7
|
-
type WebstudioAttributes,
|
|
8
|
-
} from "@webstudio-is/react-sdk";
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
forwardRef,
|
|
12
|
-
type ElementRef,
|
|
13
|
-
type ComponentPropsWithoutRef,
|
|
14
|
-
Children,
|
|
15
|
-
type ReactNode,
|
|
16
|
-
} from "react";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* We don't have support for boolean or undefined nor in UI not at Data variables,
|
|
20
|
-
* instead of binding on "open" prop we bind variable on a isOpen prop to be able to show Popover in the builder
|
|
21
|
-
**/
|
|
22
|
-
type BuilderPopoverProps = {
|
|
23
|
-
isOpen: "initial" | "open" | "closed";
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Popover and PopoverTrigger are HTML-less components.
|
|
28
|
-
* To make them work in our system, we wrap their attributes with a div that has a display: contents property.
|
|
29
|
-
*
|
|
30
|
-
* These divs function like fragments, with all web studio-related attributes attached to them.
|
|
31
|
-
*/
|
|
32
|
-
const DisplayContentsStyle = { display: "contents" };
|
|
33
|
-
|
|
34
|
-
export const Popover = forwardRef<
|
|
35
|
-
ElementRef<"div">,
|
|
36
|
-
WebstudioAttributes &
|
|
37
|
-
ComponentPropsWithoutRef<typeof PopoverPrimitive.Root> &
|
|
38
|
-
BuilderPopoverProps
|
|
39
|
-
>(({ open: openProp, isOpen, ...props }, ref) => {
|
|
40
|
-
const [webstudioAttributes, restProps] =
|
|
41
|
-
splitPropsWithWebstudioAttributes(props);
|
|
42
|
-
|
|
43
|
-
const open =
|
|
44
|
-
openProp ??
|
|
45
|
-
(isOpen === "open" ? true : isOpen === "closed" ? false : undefined);
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<div ref={ref} style={DisplayContentsStyle} {...webstudioAttributes}>
|
|
49
|
-
<PopoverPrimitive.Root open={open} {...restProps} />
|
|
50
|
-
</div>
|
|
51
|
-
);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* We're not exposing the 'asChild' property for the Trigger.
|
|
56
|
-
* Instead, we're enforcing 'asChild=true' for the Trigger and making it style-less.
|
|
57
|
-
* This avoids situations where the Trigger inadvertently passes all styles to its child,
|
|
58
|
-
* which would prevent us from displaying styles properly in the builder.
|
|
59
|
-
*/
|
|
60
|
-
export const PopoverTrigger = forwardRef<
|
|
61
|
-
ElementRef<"div">,
|
|
62
|
-
WebstudioAttributes & { children: ReactNode }
|
|
63
|
-
>(({ children, ...props }, ref) => {
|
|
64
|
-
const firstChild = Children.toArray(children)[0];
|
|
65
|
-
const [webstudioAttributes, restProps] =
|
|
66
|
-
splitPropsWithWebstudioAttributes(props);
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<div ref={ref} style={DisplayContentsStyle} {...webstudioAttributes}>
|
|
70
|
-
<PopoverPrimitive.Trigger asChild={true} {...restProps}>
|
|
71
|
-
{firstChild ?? <button>Add button or link</button>}
|
|
72
|
-
</PopoverPrimitive.Trigger>
|
|
73
|
-
</div>
|
|
74
|
-
);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
export const PopoverContent = forwardRef<
|
|
78
|
-
ElementRef<typeof PopoverPrimitive.Content>,
|
|
79
|
-
ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
|
|
80
|
-
>(({ sideOffset = 4, align = "center", ...props }, ref) => (
|
|
81
|
-
<PopoverPrimitive.Portal>
|
|
82
|
-
<PopoverPrimitive.Content
|
|
83
|
-
ref={ref}
|
|
84
|
-
align="center"
|
|
85
|
-
sideOffset={sideOffset}
|
|
86
|
-
{...props}
|
|
87
|
-
/>
|
|
88
|
-
</PopoverPrimitive.Portal>
|
|
89
|
-
));
|
package/src/radix-popover.ws.tsx
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { RadioCheckedIcon } from "@webstudio-is/icons/svg";
|
|
2
|
-
import {
|
|
3
|
-
type WsComponentMeta,
|
|
4
|
-
type WsComponentPropsMeta,
|
|
5
|
-
} from "@webstudio-is/react-sdk";
|
|
6
|
-
import * as tc from "./theme/tailwind-classes";
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
propsPopover,
|
|
10
|
-
propsPopoverContent,
|
|
11
|
-
propsPopoverTrigger,
|
|
12
|
-
} from "./__generated__/radix-popover.props";
|
|
13
|
-
|
|
14
|
-
// @todo add [data-state] to button and link
|
|
15
|
-
export const metaPopoverTrigger: WsComponentMeta = {
|
|
16
|
-
category: "hidden",
|
|
17
|
-
invalidAncestors: [],
|
|
18
|
-
type: "container",
|
|
19
|
-
label: "PopoverTrigger",
|
|
20
|
-
icon: RadioCheckedIcon,
|
|
21
|
-
stylable: false,
|
|
22
|
-
detachable: false,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const metaPopoverContent: WsComponentMeta = {
|
|
26
|
-
category: "hidden",
|
|
27
|
-
invalidAncestors: [],
|
|
28
|
-
type: "container",
|
|
29
|
-
label: "PopoverContent",
|
|
30
|
-
icon: RadioCheckedIcon,
|
|
31
|
-
detachable: false,
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Styles source without animations:
|
|
36
|
-
* https://github.com/shadcn-ui/ui/blob/main/apps/www/registry/default/ui/popover.tsx
|
|
37
|
-
*
|
|
38
|
-
* Attributions
|
|
39
|
-
* MIT License
|
|
40
|
-
* Copyright (c) 2023 shadcn
|
|
41
|
-
**/
|
|
42
|
-
export const metaPopover: WsComponentMeta = {
|
|
43
|
-
category: "radix",
|
|
44
|
-
invalidAncestors: [],
|
|
45
|
-
type: "container",
|
|
46
|
-
label: "Popover",
|
|
47
|
-
icon: RadioCheckedIcon,
|
|
48
|
-
order: 15,
|
|
49
|
-
stylable: false,
|
|
50
|
-
template: [
|
|
51
|
-
{
|
|
52
|
-
type: "instance",
|
|
53
|
-
component: "Popover",
|
|
54
|
-
label: "Popover",
|
|
55
|
-
props: [
|
|
56
|
-
{
|
|
57
|
-
name: "isOpen",
|
|
58
|
-
// We don't have support for boolean or undefined, instead of binding on open we bind on a string
|
|
59
|
-
type: "string",
|
|
60
|
-
value: "initial",
|
|
61
|
-
dataSourceRef: {
|
|
62
|
-
type: "variable",
|
|
63
|
-
name: "isOpen",
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
children: [
|
|
68
|
-
{
|
|
69
|
-
type: "instance",
|
|
70
|
-
component: "PopoverTrigger",
|
|
71
|
-
props: [],
|
|
72
|
-
children: [
|
|
73
|
-
{
|
|
74
|
-
type: "instance",
|
|
75
|
-
component: "Button",
|
|
76
|
-
children: [{ type: "text", value: "Button" }],
|
|
77
|
-
},
|
|
78
|
-
],
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
type: "instance",
|
|
82
|
-
component: "PopoverContent",
|
|
83
|
-
label: "Popover Content",
|
|
84
|
-
props: [],
|
|
85
|
-
/**
|
|
86
|
-
* z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none
|
|
87
|
-
**/
|
|
88
|
-
styles: [
|
|
89
|
-
tc.z(50),
|
|
90
|
-
tc.w(72),
|
|
91
|
-
tc.rounded("md"),
|
|
92
|
-
tc.border(),
|
|
93
|
-
tc.bg("popover"),
|
|
94
|
-
tc.p(4),
|
|
95
|
-
tc.text("popoverForeground"),
|
|
96
|
-
tc.shadow("md"),
|
|
97
|
-
tc.outline("none"),
|
|
98
|
-
].flat(),
|
|
99
|
-
children: [
|
|
100
|
-
{
|
|
101
|
-
type: "instance",
|
|
102
|
-
component: "Text",
|
|
103
|
-
children: [{ type: "text", value: "The text you can edit" }],
|
|
104
|
-
},
|
|
105
|
-
],
|
|
106
|
-
},
|
|
107
|
-
],
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
export const propsMetaPopover: WsComponentPropsMeta = {
|
|
113
|
-
props: propsPopover,
|
|
114
|
-
initialProps: ["isOpen", "modal"],
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
export const propsMetaPopoverTrigger: WsComponentPropsMeta = {
|
|
118
|
-
props: propsPopoverTrigger,
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
export const propsMetaPopoverContent: WsComponentPropsMeta = {
|
|
122
|
-
props: propsPopoverContent,
|
|
123
|
-
initialProps: ["side", "sideOffset", "align", "alignOffset"],
|
|
124
|
-
};
|
package/src/radix-tooltip.tsx
DELETED
|
@@ -1,84 +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 * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
5
|
-
import {
|
|
6
|
-
splitPropsWithWebstudioAttributes,
|
|
7
|
-
type WebstudioAttributes,
|
|
8
|
-
} from "@webstudio-is/react-sdk";
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
forwardRef,
|
|
12
|
-
type ElementRef,
|
|
13
|
-
type ComponentPropsWithoutRef,
|
|
14
|
-
Children,
|
|
15
|
-
type ReactNode,
|
|
16
|
-
} from "react";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* We don't have support for boolean or undefined nor in UI not at Data variables,
|
|
20
|
-
* instead of binding on "open" prop we bind variable on a isOpen prop to be able to show Tooltip in the builder
|
|
21
|
-
**/
|
|
22
|
-
type BuilderTooltipProps = {
|
|
23
|
-
isOpen: "initial" | "open" | "closed";
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Tooltip and TooltipTrigger are HTML-less components.
|
|
28
|
-
* To make them work in our system, we wrap their attributes with a div that has a display: contents property.
|
|
29
|
-
*
|
|
30
|
-
* These divs function like fragments, with all web studio-related attributes attached to them.
|
|
31
|
-
*/
|
|
32
|
-
const DisplayContentsStyle = { display: "contents" };
|
|
33
|
-
|
|
34
|
-
export const Tooltip = forwardRef<
|
|
35
|
-
ElementRef<"div">,
|
|
36
|
-
WebstudioAttributes &
|
|
37
|
-
ComponentPropsWithoutRef<typeof TooltipPrimitive.Root> &
|
|
38
|
-
BuilderTooltipProps
|
|
39
|
-
>(({ open: openProp, isOpen, ...props }, ref) => {
|
|
40
|
-
const [webstudioAttributes, restProps] =
|
|
41
|
-
splitPropsWithWebstudioAttributes(props);
|
|
42
|
-
|
|
43
|
-
const open =
|
|
44
|
-
openProp ??
|
|
45
|
-
(isOpen === "open" ? true : isOpen === "closed" ? false : undefined);
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<div ref={ref} style={DisplayContentsStyle} {...webstudioAttributes}>
|
|
49
|
-
<TooltipPrimitive.Root open={open} {...restProps} />
|
|
50
|
-
</div>
|
|
51
|
-
);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* We're not exposing the 'asChild' property for the Trigger.
|
|
56
|
-
* Instead, we're enforcing 'asChild=true' for the Trigger and making it style-less.
|
|
57
|
-
* This avoids situations where the Trigger inadvertently passes all styles to its child,
|
|
58
|
-
* which would prevent us from displaying styles properly in the builder.
|
|
59
|
-
*/
|
|
60
|
-
export const TooltipTrigger = forwardRef<
|
|
61
|
-
ElementRef<"div">,
|
|
62
|
-
WebstudioAttributes & { children: ReactNode }
|
|
63
|
-
>(({ children, ...props }, ref) => {
|
|
64
|
-
const firstChild = Children.toArray(children)[0];
|
|
65
|
-
const [webstudioAttributes, restProps] =
|
|
66
|
-
splitPropsWithWebstudioAttributes(props);
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<div ref={ref} style={DisplayContentsStyle} {...webstudioAttributes}>
|
|
70
|
-
<TooltipPrimitive.Trigger asChild={true} {...restProps}>
|
|
71
|
-
{firstChild ?? <button>Add button or link</button>}
|
|
72
|
-
</TooltipPrimitive.Trigger>
|
|
73
|
-
</div>
|
|
74
|
-
);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
export const TooltipContent = forwardRef<
|
|
78
|
-
ElementRef<typeof TooltipPrimitive.Content>,
|
|
79
|
-
ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
|
|
80
|
-
>(({ sideOffset = 4, ...props }, ref) => (
|
|
81
|
-
<TooltipPrimitive.Portal>
|
|
82
|
-
<TooltipPrimitive.Content ref={ref} sideOffset={sideOffset} {...props} />
|
|
83
|
-
</TooltipPrimitive.Portal>
|
|
84
|
-
));
|
package/src/radix-tooltip.ws.tsx
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { RadioCheckedIcon } from "@webstudio-is/icons/svg";
|
|
2
|
-
import {
|
|
3
|
-
type WsComponentMeta,
|
|
4
|
-
type WsComponentPropsMeta,
|
|
5
|
-
} from "@webstudio-is/react-sdk";
|
|
6
|
-
import * as tc from "./theme/tailwind-classes";
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
propsTooltip,
|
|
10
|
-
propsTooltipContent,
|
|
11
|
-
propsTooltipTrigger,
|
|
12
|
-
} from "./__generated__/radix-tooltip.props";
|
|
13
|
-
|
|
14
|
-
// @todo add [data-state] to button and link
|
|
15
|
-
export const metaTooltipTrigger: WsComponentMeta = {
|
|
16
|
-
category: "hidden",
|
|
17
|
-
detachable: false,
|
|
18
|
-
invalidAncestors: [],
|
|
19
|
-
type: "container",
|
|
20
|
-
label: "TooltipTrigger",
|
|
21
|
-
icon: RadioCheckedIcon,
|
|
22
|
-
stylable: false,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const metaTooltipContent: WsComponentMeta = {
|
|
26
|
-
category: "hidden",
|
|
27
|
-
detachable: false,
|
|
28
|
-
invalidAncestors: [],
|
|
29
|
-
type: "container",
|
|
30
|
-
label: "TooltipContent",
|
|
31
|
-
icon: RadioCheckedIcon,
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Styles source without animations:
|
|
36
|
-
* https://github.com/shadcn-ui/ui/blob/main/apps/www/registry/default/ui/tooltip.tsx
|
|
37
|
-
*
|
|
38
|
-
* Attributions
|
|
39
|
-
* MIT License
|
|
40
|
-
* Copyright (c) 2023 shadcn
|
|
41
|
-
**/
|
|
42
|
-
export const metaTooltip: WsComponentMeta = {
|
|
43
|
-
category: "radix",
|
|
44
|
-
invalidAncestors: [],
|
|
45
|
-
type: "container",
|
|
46
|
-
label: "Tooltip",
|
|
47
|
-
icon: RadioCheckedIcon,
|
|
48
|
-
order: 15,
|
|
49
|
-
stylable: false,
|
|
50
|
-
template: [
|
|
51
|
-
{
|
|
52
|
-
type: "instance",
|
|
53
|
-
component: "Tooltip",
|
|
54
|
-
label: "Tooltip",
|
|
55
|
-
props: [
|
|
56
|
-
{
|
|
57
|
-
name: "isOpen",
|
|
58
|
-
// We don't have support for boolean or undefined, instead of binding on open we bind on a string
|
|
59
|
-
type: "string",
|
|
60
|
-
value: "initial",
|
|
61
|
-
dataSourceRef: {
|
|
62
|
-
type: "variable",
|
|
63
|
-
name: "isOpen",
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
children: [
|
|
68
|
-
{
|
|
69
|
-
type: "instance",
|
|
70
|
-
component: "TooltipTrigger",
|
|
71
|
-
props: [],
|
|
72
|
-
children: [
|
|
73
|
-
{
|
|
74
|
-
type: "instance",
|
|
75
|
-
component: "Button",
|
|
76
|
-
children: [{ type: "text", value: "Button" }],
|
|
77
|
-
},
|
|
78
|
-
],
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
type: "instance",
|
|
82
|
-
component: "TooltipContent",
|
|
83
|
-
label: "Tooltip Content",
|
|
84
|
-
props: [],
|
|
85
|
-
/**
|
|
86
|
-
* z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md
|
|
87
|
-
**/
|
|
88
|
-
styles: [
|
|
89
|
-
tc.z(50),
|
|
90
|
-
tc.overflow("hidden"),
|
|
91
|
-
tc.rounded("md"),
|
|
92
|
-
tc.border(),
|
|
93
|
-
tc.bg("popover"),
|
|
94
|
-
tc.px(3),
|
|
95
|
-
tc.py(1.5),
|
|
96
|
-
tc.text("sm"),
|
|
97
|
-
tc.text("popoverForeground"),
|
|
98
|
-
tc.shadow("md"),
|
|
99
|
-
].flat(),
|
|
100
|
-
children: [
|
|
101
|
-
{
|
|
102
|
-
type: "instance",
|
|
103
|
-
component: "Text",
|
|
104
|
-
children: [{ type: "text", value: "The text you can edit" }],
|
|
105
|
-
},
|
|
106
|
-
],
|
|
107
|
-
},
|
|
108
|
-
],
|
|
109
|
-
},
|
|
110
|
-
],
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export const propsMetaTooltip: WsComponentPropsMeta = {
|
|
114
|
-
props: propsTooltip,
|
|
115
|
-
initialProps: ["isOpen", "delayDuration", "disableHoverableContent"],
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
export const propsMetaTooltipTrigger: WsComponentPropsMeta = {
|
|
119
|
-
props: propsTooltipTrigger,
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export const propsMetaTooltipContent: WsComponentPropsMeta = {
|
|
123
|
-
props: propsTooltipContent,
|
|
124
|
-
initialProps: ["side", "sideOffset", "align", "alignOffset"],
|
|
125
|
-
};
|