@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
package/lib/hooks.js
CHANGED
|
@@ -1,14 +1,475 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
// src/collapsible.tsx
|
|
2
|
+
import {
|
|
3
|
+
forwardRef,
|
|
4
|
+
Children
|
|
5
|
+
} from "react";
|
|
6
|
+
import { Root, Trigger, Content } from "@radix-ui/react-collapsible";
|
|
7
|
+
import { getClosestInstance } from "@webstudio-is/react-sdk";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var CollapsibleTrigger = forwardRef(({ children, ...props }, ref) => {
|
|
10
|
+
const firstChild = Children.toArray(children)[0];
|
|
11
|
+
return /* @__PURE__ */ jsx(Trigger, { asChild: true, ref, ...props, children: firstChild ?? /* @__PURE__ */ jsx("button", { children: "Add button" }) });
|
|
12
|
+
});
|
|
13
|
+
var namespace = "@webstudio-is/sdk-components-react-radix";
|
|
14
|
+
var hooksCollapsible = {
|
|
15
|
+
onNavigatorSelect: (context, event) => {
|
|
16
|
+
for (const instance of event.instancePath) {
|
|
17
|
+
if (instance.component === `${namespace}:CollapsibleContent`) {
|
|
18
|
+
const collapsible = getClosestInstance(
|
|
19
|
+
event.instancePath,
|
|
20
|
+
instance,
|
|
21
|
+
`${namespace}:Collapsible`
|
|
22
|
+
);
|
|
23
|
+
if (collapsible) {
|
|
24
|
+
context.setPropVariable(collapsible.id, "open", true);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// src/tabs.tsx
|
|
32
|
+
import {
|
|
33
|
+
forwardRef as forwardRef2
|
|
34
|
+
} from "react";
|
|
35
|
+
import { Root as Root2, List, Trigger as Trigger2, Content as Content2 } from "@radix-ui/react-tabs";
|
|
36
|
+
import {
|
|
37
|
+
getClosestInstance as getClosestInstance2,
|
|
38
|
+
getIndexWithinAncestorFromComponentProps
|
|
39
|
+
} from "@webstudio-is/react-sdk";
|
|
40
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
41
|
+
var TabsTrigger = forwardRef2(({ value, ...props }, ref) => {
|
|
42
|
+
const index = getIndexWithinAncestorFromComponentProps(props);
|
|
43
|
+
return /* @__PURE__ */ jsx2(Trigger2, { ref, value: value ?? index, ...props });
|
|
44
|
+
});
|
|
45
|
+
var TabsContent = forwardRef2(({ value, ...props }, ref) => {
|
|
46
|
+
const index = getIndexWithinAncestorFromComponentProps(props);
|
|
47
|
+
return /* @__PURE__ */ jsx2(Content2, { ref, value: value ?? index, ...props });
|
|
48
|
+
});
|
|
49
|
+
var namespace2 = "@webstudio-is/sdk-components-react-radix";
|
|
50
|
+
var hooksTabs = {
|
|
51
|
+
onNavigatorSelect: (context, event) => {
|
|
52
|
+
for (const instance of event.instancePath) {
|
|
53
|
+
if (instance.component === `${namespace2}:TabsContent`) {
|
|
54
|
+
const tabs = getClosestInstance2(
|
|
55
|
+
event.instancePath,
|
|
56
|
+
instance,
|
|
57
|
+
`${namespace2}:Tabs`
|
|
58
|
+
);
|
|
59
|
+
const contentValue = context.getPropValue(instance.id, "value") ?? context.indexesWithinAncestors.get(instance.id)?.toString();
|
|
60
|
+
if (tabs && contentValue) {
|
|
61
|
+
context.setPropVariable(tabs.id, "value", contentValue);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// src/dialog.tsx
|
|
69
|
+
import {
|
|
70
|
+
forwardRef as forwardRef3,
|
|
71
|
+
Children as Children2
|
|
72
|
+
} from "react";
|
|
73
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
74
|
+
import { getClosestInstance as getClosestInstance3 } from "@webstudio-is/react-sdk";
|
|
75
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
76
|
+
var Dialog = forwardRef3((props, _ref) => {
|
|
77
|
+
return /* @__PURE__ */ jsx3(DialogPrimitive.Root, { ...props });
|
|
78
|
+
});
|
|
79
|
+
var DialogTrigger = forwardRef3(({ children, ...props }, ref) => {
|
|
80
|
+
const firstChild = Children2.toArray(children)[0];
|
|
81
|
+
return /* @__PURE__ */ jsx3(DialogPrimitive.Trigger, { ref, asChild: true, ...props, children: firstChild ?? /* @__PURE__ */ jsx3("button", { children: "Add button or link" }) });
|
|
82
|
+
});
|
|
83
|
+
var DialogOverlay = forwardRef3((props, ref) => {
|
|
84
|
+
return /* @__PURE__ */ jsx3(DialogPrimitive.DialogPortal, { children: /* @__PURE__ */ jsx3(DialogPrimitive.Overlay, { ref, ...props }) });
|
|
85
|
+
});
|
|
86
|
+
var DialogContent = DialogPrimitive.Content;
|
|
87
|
+
var namespace3 = "@webstudio-is/sdk-components-react-radix";
|
|
88
|
+
var hooksDialog = {
|
|
89
|
+
onNavigatorUnselect: (context, event) => {
|
|
90
|
+
for (const instance of event.instancePath) {
|
|
91
|
+
if (instance.component === `${namespace3}:DialogOverlay`) {
|
|
92
|
+
const dialog = getClosestInstance3(
|
|
93
|
+
event.instancePath,
|
|
94
|
+
instance,
|
|
95
|
+
`${namespace3}:Dialog`
|
|
96
|
+
);
|
|
97
|
+
if (dialog) {
|
|
98
|
+
context.setPropVariable(dialog.id, "open", false);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
onNavigatorSelect: (context, event) => {
|
|
104
|
+
for (const instance of event.instancePath) {
|
|
105
|
+
if (instance.component === `${namespace3}:DialogOverlay`) {
|
|
106
|
+
const dialog = getClosestInstance3(
|
|
107
|
+
event.instancePath,
|
|
108
|
+
instance,
|
|
109
|
+
`${namespace3}:Dialog`
|
|
110
|
+
);
|
|
111
|
+
if (dialog) {
|
|
112
|
+
context.setPropVariable(dialog.id, "open", true);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// src/popover.tsx
|
|
120
|
+
import {
|
|
121
|
+
forwardRef as forwardRef4,
|
|
122
|
+
Children as Children3
|
|
123
|
+
} from "react";
|
|
124
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
125
|
+
import { getClosestInstance as getClosestInstance4 } from "@webstudio-is/react-sdk";
|
|
126
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
127
|
+
var Popover = forwardRef4((props, _ref) => {
|
|
128
|
+
return /* @__PURE__ */ jsx4(PopoverPrimitive.Root, { ...props });
|
|
129
|
+
});
|
|
130
|
+
var PopoverTrigger = forwardRef4(({ children, ...props }, ref) => {
|
|
131
|
+
const firstChild = Children3.toArray(children)[0];
|
|
132
|
+
return /* @__PURE__ */ jsx4(PopoverPrimitive.Trigger, { asChild: true, ref, ...props, children: firstChild ?? /* @__PURE__ */ jsx4("button", { children: "Add button or link" }) });
|
|
133
|
+
});
|
|
134
|
+
var PopoverContent = forwardRef4(
|
|
135
|
+
({ sideOffset = 4, align = "center", hideWhenDetached = true, ...props }, ref) => /* @__PURE__ */ jsx4(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx4(
|
|
136
|
+
PopoverPrimitive.Content,
|
|
137
|
+
{
|
|
138
|
+
ref,
|
|
139
|
+
align: "center",
|
|
140
|
+
sideOffset,
|
|
141
|
+
hideWhenDetached,
|
|
142
|
+
...props
|
|
143
|
+
}
|
|
144
|
+
) })
|
|
145
|
+
);
|
|
146
|
+
var namespace4 = "@webstudio-is/sdk-components-react-radix";
|
|
147
|
+
var hooksPopover = {
|
|
148
|
+
onNavigatorUnselect: (context, event) => {
|
|
149
|
+
for (const instance of event.instancePath) {
|
|
150
|
+
if (instance.component === `${namespace4}:PopoverContent`) {
|
|
151
|
+
const popover = getClosestInstance4(
|
|
152
|
+
event.instancePath,
|
|
153
|
+
instance,
|
|
154
|
+
`${namespace4}:Popover`
|
|
155
|
+
);
|
|
156
|
+
if (popover) {
|
|
157
|
+
context.setPropVariable(popover.id, "open", false);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
onNavigatorSelect: (context, event) => {
|
|
163
|
+
for (const instance of event.instancePath) {
|
|
164
|
+
if (instance.component === `${namespace4}:PopoverContent`) {
|
|
165
|
+
const popover = getClosestInstance4(
|
|
166
|
+
event.instancePath,
|
|
167
|
+
instance,
|
|
168
|
+
`${namespace4}:Popover`
|
|
169
|
+
);
|
|
170
|
+
if (popover) {
|
|
171
|
+
context.setPropVariable(popover.id, "open", true);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// src/sheet.tsx
|
|
179
|
+
import {
|
|
180
|
+
forwardRef as forwardRef5
|
|
181
|
+
} from "react";
|
|
182
|
+
import { getClosestInstance as getClosestInstance5 } from "@webstudio-is/react-sdk";
|
|
183
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
184
|
+
var SheetContent = forwardRef5(
|
|
185
|
+
({ tag = "nav", side = "left", role = "navigation", children, ...props }, ref) => {
|
|
186
|
+
const Tag = tag;
|
|
187
|
+
return /* @__PURE__ */ jsx5(
|
|
188
|
+
DialogContent,
|
|
189
|
+
{
|
|
190
|
+
asChild: true,
|
|
191
|
+
"data-side": side,
|
|
192
|
+
role,
|
|
193
|
+
...props,
|
|
194
|
+
children: /* @__PURE__ */ jsx5(Tag, { ref, children })
|
|
195
|
+
}
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
var namespace5 = "@webstudio-is/sdk-components-react-radix";
|
|
200
|
+
var hooksSheet = {
|
|
201
|
+
onNavigatorUnselect: (context, event) => {
|
|
202
|
+
for (const instance of event.instancePath) {
|
|
203
|
+
if (instance.component === `${namespace5}:SheetOverlay`) {
|
|
204
|
+
const sheet = getClosestInstance5(
|
|
205
|
+
event.instancePath,
|
|
206
|
+
instance,
|
|
207
|
+
`${namespace5}:Sheet`
|
|
208
|
+
);
|
|
209
|
+
if (sheet) {
|
|
210
|
+
context.setPropVariable(sheet.id, "open", false);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
onNavigatorSelect: (context, event) => {
|
|
216
|
+
for (const instance of event.instancePath) {
|
|
217
|
+
if (instance.component === `${namespace5}:SheetOverlay`) {
|
|
218
|
+
const sheet = getClosestInstance5(
|
|
219
|
+
event.instancePath,
|
|
220
|
+
instance,
|
|
221
|
+
`${namespace5}:Sheet`
|
|
222
|
+
);
|
|
223
|
+
if (sheet) {
|
|
224
|
+
context.setPropVariable(sheet.id, "open", true);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// src/tooltip.tsx
|
|
232
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
233
|
+
import { getClosestInstance as getClosestInstance6 } from "@webstudio-is/react-sdk";
|
|
234
|
+
import {
|
|
235
|
+
forwardRef as forwardRef6,
|
|
236
|
+
Children as Children4
|
|
237
|
+
} from "react";
|
|
238
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
239
|
+
var Tooltip = forwardRef6((props, _ref) => {
|
|
240
|
+
return /* @__PURE__ */ jsx6(TooltipPrimitive.Provider, { children: /* @__PURE__ */ jsx6(TooltipPrimitive.Root, { ...props }) });
|
|
241
|
+
});
|
|
242
|
+
var TooltipTrigger = forwardRef6(({ children, ...props }, ref) => {
|
|
243
|
+
const firstChild = Children4.toArray(children)[0];
|
|
244
|
+
return /* @__PURE__ */ jsx6(TooltipPrimitive.Trigger, { asChild: true, ref, ...props, children: firstChild ?? /* @__PURE__ */ jsx6("button", { children: "Add button or link" }) });
|
|
245
|
+
});
|
|
246
|
+
var TooltipContent = forwardRef6(({ sideOffset = 4, hideWhenDetached = true, ...props }, ref) => /* @__PURE__ */ jsx6(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsx6(
|
|
247
|
+
TooltipPrimitive.Content,
|
|
248
|
+
{
|
|
249
|
+
ref,
|
|
250
|
+
hideWhenDetached,
|
|
251
|
+
sideOffset,
|
|
252
|
+
...props
|
|
253
|
+
}
|
|
254
|
+
) }));
|
|
255
|
+
var namespace6 = "@webstudio-is/sdk-components-react-radix";
|
|
256
|
+
var hooksTooltip = {
|
|
257
|
+
onNavigatorUnselect: (context, event) => {
|
|
258
|
+
for (const instance of event.instancePath) {
|
|
259
|
+
if (instance.component === `${namespace6}:TooltipContent`) {
|
|
260
|
+
const tooltip = getClosestInstance6(
|
|
261
|
+
event.instancePath,
|
|
262
|
+
instance,
|
|
263
|
+
`${namespace6}:Tooltip`
|
|
264
|
+
);
|
|
265
|
+
if (tooltip) {
|
|
266
|
+
context.setPropVariable(tooltip.id, "open", false);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
onNavigatorSelect: (context, event) => {
|
|
272
|
+
for (const instance of event.instancePath) {
|
|
273
|
+
if (instance.component === `${namespace6}:TooltipContent`) {
|
|
274
|
+
const tooltip = getClosestInstance6(
|
|
275
|
+
event.instancePath,
|
|
276
|
+
instance,
|
|
277
|
+
`${namespace6}:Tooltip`
|
|
278
|
+
);
|
|
279
|
+
if (tooltip) {
|
|
280
|
+
context.setPropVariable(tooltip.id, "open", true);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
// src/accordion.tsx
|
|
288
|
+
import {
|
|
289
|
+
forwardRef as forwardRef7
|
|
290
|
+
} from "react";
|
|
291
|
+
import {
|
|
292
|
+
Root as Root6,
|
|
293
|
+
Item,
|
|
294
|
+
Header,
|
|
295
|
+
Trigger as Trigger6,
|
|
296
|
+
Content as Content6
|
|
297
|
+
} from "@radix-ui/react-accordion";
|
|
298
|
+
import {
|
|
299
|
+
getClosestInstance as getClosestInstance7,
|
|
300
|
+
getIndexWithinAncestorFromComponentProps as getIndexWithinAncestorFromComponentProps2
|
|
301
|
+
} from "@webstudio-is/react-sdk";
|
|
302
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
303
|
+
var Accordion = forwardRef7((props, ref) => {
|
|
304
|
+
return /* @__PURE__ */ jsx7(Root6, { ref, type: "single", ...props });
|
|
305
|
+
});
|
|
306
|
+
var AccordionItem = forwardRef7(({ value, ...props }, ref) => {
|
|
307
|
+
const index = getIndexWithinAncestorFromComponentProps2(props);
|
|
308
|
+
return /* @__PURE__ */ jsx7(Item, { ref, value: value ?? index, ...props });
|
|
309
|
+
});
|
|
310
|
+
var namespace7 = "@webstudio-is/sdk-components-react-radix";
|
|
311
|
+
var hooksAccordion = {
|
|
312
|
+
onNavigatorSelect: (context, event) => {
|
|
313
|
+
for (const instance of event.instancePath) {
|
|
314
|
+
if (instance.component === `${namespace7}:AccordionContent`) {
|
|
315
|
+
const accordion = getClosestInstance7(
|
|
316
|
+
event.instancePath,
|
|
317
|
+
instance,
|
|
318
|
+
`${namespace7}:Accordion`
|
|
319
|
+
);
|
|
320
|
+
const item = getClosestInstance7(
|
|
321
|
+
event.instancePath,
|
|
322
|
+
instance,
|
|
323
|
+
`${namespace7}:AccordionItem`
|
|
324
|
+
);
|
|
325
|
+
if (accordion && item) {
|
|
326
|
+
const itemValue = context.getPropValue(item.id, "value") ?? context.indexesWithinAncestors.get(item.id)?.toString();
|
|
327
|
+
if (itemValue) {
|
|
328
|
+
context.setPropVariable(accordion.id, "value", itemValue);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
// src/navigation-menu.tsx
|
|
337
|
+
import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
|
|
338
|
+
import {
|
|
339
|
+
getClosestInstance as getClosestInstance8,
|
|
340
|
+
getIndexWithinAncestorFromComponentProps as getIndexWithinAncestorFromComponentProps3,
|
|
341
|
+
ReactSdkContext
|
|
342
|
+
} from "@webstudio-is/react-sdk";
|
|
343
|
+
import {
|
|
344
|
+
Children as Children5,
|
|
345
|
+
forwardRef as forwardRef8,
|
|
346
|
+
useContext
|
|
347
|
+
} from "react";
|
|
348
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
349
|
+
var NavigationMenu = forwardRef8(({ value: propsValue, ...props }, ref) => {
|
|
350
|
+
const { renderer } = useContext(ReactSdkContext);
|
|
351
|
+
let value = propsValue;
|
|
352
|
+
if (renderer === "canvas") {
|
|
353
|
+
value = value === "" ? "-1" : value;
|
|
354
|
+
}
|
|
355
|
+
return /* @__PURE__ */ jsx8(NavigationMenuPrimitive.Root, { ref, value, ...props });
|
|
356
|
+
});
|
|
357
|
+
var NavigationMenuItem = forwardRef8(({ value, ...props }, ref) => {
|
|
358
|
+
const index = getIndexWithinAncestorFromComponentProps3(props);
|
|
359
|
+
return /* @__PURE__ */ jsx8(NavigationMenuPrimitive.Item, { ref, value: value ?? index, ...props });
|
|
360
|
+
});
|
|
361
|
+
var NavigationMenuLink = forwardRef8(({ children, ...props }, ref) => {
|
|
362
|
+
const firstChild = Children5.toArray(children)[0];
|
|
363
|
+
return /* @__PURE__ */ jsx8(NavigationMenuPrimitive.Link, { asChild: true, ref, ...props, children: firstChild ?? /* @__PURE__ */ jsx8("a", { children: "Add link component" }) });
|
|
364
|
+
});
|
|
365
|
+
var NavigationMenuTrigger = forwardRef8(({ children, ...props }, ref) => {
|
|
366
|
+
const firstChild = Children5.toArray(children)[0];
|
|
367
|
+
return /* @__PURE__ */ jsx8(NavigationMenuPrimitive.Trigger, { asChild: true, ref, ...props, children: firstChild ?? /* @__PURE__ */ jsx8("button", { children: "Add button or link" }) });
|
|
368
|
+
});
|
|
369
|
+
var namespace8 = "@webstudio-is/sdk-components-react-radix";
|
|
370
|
+
var hooksNavigationMenu = {
|
|
371
|
+
onNavigatorUnselect: (context, event) => {
|
|
372
|
+
for (const instance of event.instancePath) {
|
|
373
|
+
if (instance.component === `${namespace8}:NavigationMenuContent`) {
|
|
374
|
+
const menu = getClosestInstance8(
|
|
375
|
+
event.instancePath,
|
|
376
|
+
instance,
|
|
377
|
+
`${namespace8}:NavigationMenu`
|
|
378
|
+
);
|
|
379
|
+
if (menu) {
|
|
380
|
+
context.setPropVariable(menu.id, "value", "");
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
onNavigatorSelect: (context, event) => {
|
|
386
|
+
for (const instance of event.instancePath) {
|
|
387
|
+
if (instance.component === `${namespace8}:NavigationMenuContent`) {
|
|
388
|
+
const menu = getClosestInstance8(
|
|
389
|
+
event.instancePath,
|
|
390
|
+
instance,
|
|
391
|
+
`${namespace8}:NavigationMenu`
|
|
392
|
+
);
|
|
393
|
+
const menuItem = getClosestInstance8(
|
|
394
|
+
event.instancePath,
|
|
395
|
+
instance,
|
|
396
|
+
`${namespace8}:NavigationMenuItem`
|
|
397
|
+
);
|
|
398
|
+
if (menuItem === void 0 || menu === void 0) {
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
const contentValue = context.getPropValue(menuItem.id, "value") ?? context.indexesWithinAncestors.get(menuItem.id)?.toString();
|
|
402
|
+
if (contentValue) {
|
|
403
|
+
context.setPropVariable(menu.id, "value", contentValue);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
// src/select.tsx
|
|
411
|
+
import {
|
|
412
|
+
forwardRef as forwardRef9
|
|
413
|
+
} from "react";
|
|
414
|
+
import {
|
|
415
|
+
Root as Root8,
|
|
416
|
+
Value,
|
|
417
|
+
Trigger as Trigger8,
|
|
418
|
+
Content as Content8,
|
|
419
|
+
Item as Item3,
|
|
420
|
+
ItemIndicator,
|
|
421
|
+
ItemText,
|
|
422
|
+
Portal as Portal3,
|
|
423
|
+
Viewport as Viewport2
|
|
424
|
+
} from "@radix-ui/react-select";
|
|
425
|
+
import { getClosestInstance as getClosestInstance9 } from "@webstudio-is/react-sdk";
|
|
426
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
427
|
+
var Select = forwardRef9(({ value, ...props }, _ref) => {
|
|
428
|
+
if (value === "") {
|
|
429
|
+
value = void 0;
|
|
430
|
+
}
|
|
431
|
+
return /* @__PURE__ */ jsx9(Root8, { value, ...props });
|
|
432
|
+
});
|
|
433
|
+
var SelectValue = forwardRef9((props, ref) => {
|
|
434
|
+
return /* @__PURE__ */ jsx9(Value, { ref, ...props });
|
|
435
|
+
});
|
|
436
|
+
var SelectContent = forwardRef9((props, ref) => {
|
|
437
|
+
return /* @__PURE__ */ jsx9(Portal3, { children: /* @__PURE__ */ jsx9(Content8, { ref, ...props, position: "popper" }) });
|
|
438
|
+
});
|
|
439
|
+
var namespace9 = "@webstudio-is/sdk-components-react-radix";
|
|
440
|
+
var hooksSelect = {
|
|
441
|
+
onNavigatorUnselect: (context, event) => {
|
|
442
|
+
for (const instance of event.instancePath) {
|
|
443
|
+
if (instance.component === `${namespace9}:SelectContent`) {
|
|
444
|
+
const select = getClosestInstance9(
|
|
445
|
+
event.instancePath,
|
|
446
|
+
instance,
|
|
447
|
+
`${namespace9}:Select`
|
|
448
|
+
);
|
|
449
|
+
if (select) {
|
|
450
|
+
context.setPropVariable(select.id, "open", false);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
onNavigatorSelect: (context, event) => {
|
|
456
|
+
for (const instance of event.instancePath) {
|
|
457
|
+
if (instance.component === `${namespace9}:SelectContent`) {
|
|
458
|
+
const select = getClosestInstance9(
|
|
459
|
+
event.instancePath,
|
|
460
|
+
instance,
|
|
461
|
+
`${namespace9}:Select`
|
|
462
|
+
);
|
|
463
|
+
if (select) {
|
|
464
|
+
context.setPropVariable(select.id, "open", true);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
// src/hooks.ts
|
|
472
|
+
var hooks = [
|
|
12
473
|
hooksCollapsible,
|
|
13
474
|
hooksTabs,
|
|
14
475
|
hooksDialog,
|
|
@@ -19,3 +480,6 @@ export const hooks = [
|
|
|
19
480
|
hooksNavigationMenu,
|
|
20
481
|
hooksSelect
|
|
21
482
|
];
|
|
483
|
+
export {
|
|
484
|
+
hooks
|
|
485
|
+
};
|