@plasmicpkgs/radix-ui 0.0.22 → 0.0.24

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/dist/index.mjs ADDED
@@ -0,0 +1,1044 @@
1
+ // src/popover.tsx
2
+ import * as PopoverPrimitive from "@radix-ui/react-popover";
3
+ import * as React2 from "react";
4
+ import clsx from "clsx";
5
+
6
+ // src/reg-util.ts
7
+ import {
8
+ default as registerComponent
9
+ } from "@plasmicapp/host/registerComponent";
10
+ import {
11
+ default as registerGlobalContext
12
+ } from "@plasmicapp/host/registerGlobalContext";
13
+ function registerComponentHelper(loader, component, meta) {
14
+ if (loader) {
15
+ loader.registerComponent(component, meta);
16
+ } else {
17
+ registerComponent(component, meta);
18
+ }
19
+ }
20
+
21
+ // src/util.tsx
22
+ import * as React from "react";
23
+ import { useState } from "react";
24
+ import { omit, pick } from "remeda";
25
+ var DEBUG_SLOWDOWN = 1;
26
+ var enterAnims = [
27
+ "fade-in",
28
+ "zoom-enter",
29
+ "slide-in-from-top",
30
+ "slide-in-from-right",
31
+ "slide-in-from-bottom",
32
+ "slide-in-from-left"
33
+ ];
34
+ var exitAnims = [
35
+ "fade-out",
36
+ "zoom-exit",
37
+ "slide-out-to-top",
38
+ "slide-out-to-right",
39
+ "slide-out-to-bottom",
40
+ "slide-out-to-left"
41
+ ];
42
+ var id = 0;
43
+ var _a;
44
+ var useId2 = (_a = React.useId) != null ? _a : () => useState(() => "" + id++);
45
+ var StyleWrapper = ({
46
+ children,
47
+ cssStr
48
+ }) => {
49
+ const dynClass = "pd__" + useId2().replace(/:/g, "");
50
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, children(dynClass), /* @__PURE__ */ React.createElement("style", null, dynClass ? cssStr.replace(/&/g, `.${dynClass}`) : ""));
51
+ };
52
+ var Animated = ({
53
+ children,
54
+ enterAnimations = ["fade-in"],
55
+ exitAnimations = ["fade-out"],
56
+ enterDuration = 0.15 * DEBUG_SLOWDOWN,
57
+ exitDuration = 0.15 * DEBUG_SLOWDOWN,
58
+ enterOpacity = 0,
59
+ exitOpacity = 0,
60
+ enterScale = 0.95,
61
+ exitScale = 0.95,
62
+ enterTranslateX = "100%",
63
+ exitTranslateX = "100%",
64
+ enterTranslateY = "100%",
65
+ exitTranslateY = "100%",
66
+ enterTiming = "ease",
67
+ exitTiming = "ease",
68
+ enterDelay = 0,
69
+ exitDelay = 0
70
+ }) => {
71
+ const pct = (x) => typeof x === "number" || (x == null ? void 0 : x.match(/.*\d$/)) ? x + "%" : x;
72
+ const neg = (x) => x.startsWith("-") ? x : "-" + x;
73
+ const animations = {
74
+ "fade-in": `--tw-enter-opacity: ${enterOpacity};`,
75
+ "fade-out": `--tw-exit-opacity: ${exitOpacity};`,
76
+ "slide-in-from-top": `--tw-enter-translate-y: ${neg(
77
+ pct(enterTranslateY)
78
+ )};`,
79
+ "slide-out-to-top": `--tw-exit-translate-y: ${neg(pct(exitTranslateY))};`,
80
+ "slide-in-from-right": `--tw-enter-translate-x: ${pct(enterTranslateX)};`,
81
+ "slide-out-to-right": `--tw-exit-translate-x: ${pct(exitTranslateX)};`,
82
+ "slide-in-from-bottom": `--tw-enter-translate-y: ${pct(enterTranslateY)};`,
83
+ "slide-out-to-bottom": `--tw-exit-translate-y: ${pct(exitTranslateY)};`,
84
+ "slide-in-from-left": `--tw-enter-translate-x: ${neg(
85
+ pct(enterTranslateX)
86
+ )};`,
87
+ "slide-out-to-left": `--tw-exit-translate-x: ${neg(pct(exitTranslateX))};`,
88
+ "zoom-enter": `--tw-enter-scale: ${enterScale};`,
89
+ "zoom-exit": `--tw-exit-scale: ${exitScale};`
90
+ };
91
+ return /* @__PURE__ */ React.createElement(
92
+ StyleWrapper,
93
+ {
94
+ cssStr: `
95
+ &&[data-state=closed] {
96
+ animation-duration: ${exitDuration}s;
97
+ animation-timing-function: ${exitTiming};
98
+ animation-delay: ${exitDelay};
99
+ ${exitAnimations.map((exitAnimation) => {
100
+ var _a2;
101
+ return (_a2 = animations[exitAnimation]) != null ? _a2 : "";
102
+ }).join(" ")}
103
+ }
104
+ &&,
105
+ &&[data-state=open] {
106
+ animation-duration: ${enterDuration}s;
107
+ animation-timing-function: ${enterTiming};
108
+ animation-delay: ${enterDelay};
109
+ ${enterAnimations.map((enterAnimation) => {
110
+ var _a2;
111
+ return (_a2 = animations[enterAnimation]) != null ? _a2 : "";
112
+ }).join(" ")}
113
+ }
114
+ `
115
+ },
116
+ children
117
+ );
118
+ };
119
+ function splitAnimProps(props) {
120
+ const keys = [
121
+ "enterAnimations",
122
+ "exitAnimations",
123
+ "enterDuration",
124
+ "exitDuration",
125
+ "enterTranslateX",
126
+ "exitTranslateX",
127
+ "enterTranslateY",
128
+ "exitTranslateY",
129
+ "enterTiming",
130
+ "exitTiming",
131
+ "enterDelay",
132
+ "exitDelay",
133
+ "enterScale",
134
+ "exitScale",
135
+ "enterOpacity",
136
+ "exitOpacity"
137
+ ];
138
+ const a = pick(props, keys);
139
+ const b = omit(props, keys);
140
+ return [a, b];
141
+ }
142
+ function mungeNames(names) {
143
+ return names.map((name) => ({
144
+ label: name.replace(/-/g, " "),
145
+ value: name
146
+ }));
147
+ }
148
+ var animPropTypes = ({
149
+ defaultEnterAnimations,
150
+ defaultExitAnimations
151
+ }) => {
152
+ const getEnterAnimations = (ps) => {
153
+ var _a2;
154
+ return (_a2 = ps.enterAnimations) != null ? _a2 : defaultEnterAnimations == null ? void 0 : defaultEnterAnimations(ps);
155
+ };
156
+ const getExitAnimations = (ps) => {
157
+ var _a2;
158
+ return (_a2 = ps.exitAnimations) != null ? _a2 : defaultExitAnimations == null ? void 0 : defaultExitAnimations(ps);
159
+ };
160
+ return {
161
+ enterAnimations: {
162
+ type: "choice",
163
+ options: mungeNames(enterAnims),
164
+ multiSelect: true,
165
+ defaultValueHint: defaultEnterAnimations != null ? defaultEnterAnimations : ["fade-in"]
166
+ },
167
+ exitAnimations: {
168
+ type: "choice",
169
+ options: mungeNames(exitAnims),
170
+ multiSelect: true,
171
+ defaultValueHint: defaultExitAnimations != null ? defaultExitAnimations : ["fade-out"]
172
+ },
173
+ enterDuration: { type: "number", defaultValueHint: 0.15 },
174
+ exitDuration: { type: "number", defaultValueHint: 0.15 },
175
+ enterTranslateX: {
176
+ type: "string",
177
+ defaultValueHint: "100%",
178
+ hidden: (ps) => {
179
+ var _a2, _b;
180
+ return !((_a2 = getEnterAnimations(ps)) == null ? void 0 : _a2.includes("slide-in-from-right")) && !((_b = getEnterAnimations(ps)) == null ? void 0 : _b.includes("slide-in-from-left"));
181
+ }
182
+ },
183
+ exitTranslateX: {
184
+ type: "string",
185
+ advanced: true,
186
+ defaultValueHint: "100%",
187
+ hidden: (ps) => {
188
+ var _a2, _b;
189
+ return !((_a2 = getExitAnimations(ps)) == null ? void 0 : _a2.includes("slide-out-to-right")) && !((_b = getExitAnimations(ps)) == null ? void 0 : _b.includes("slide-out-to-left"));
190
+ }
191
+ },
192
+ enterTranslateY: {
193
+ type: "string",
194
+ advanced: true,
195
+ defaultValueHint: "100%",
196
+ hidden: (ps) => {
197
+ var _a2, _b;
198
+ return !((_a2 = getEnterAnimations(ps)) == null ? void 0 : _a2.includes("slide-in-from-bottom")) && !((_b = getEnterAnimations(ps)) == null ? void 0 : _b.includes("slide-in-from-top"));
199
+ }
200
+ },
201
+ exitTranslateY: {
202
+ type: "string",
203
+ advanced: true,
204
+ defaultValueHint: "100%",
205
+ hidden: (ps) => {
206
+ var _a2, _b;
207
+ return !((_a2 = getExitAnimations(ps)) == null ? void 0 : _a2.includes("slide-out-to-bottom")) && !((_b = getExitAnimations(ps)) == null ? void 0 : _b.includes("slide-out-to-top"));
208
+ }
209
+ },
210
+ enterOpacity: {
211
+ type: "number",
212
+ advanced: true,
213
+ defaultValueHint: 0,
214
+ hidden: (ps) => {
215
+ var _a2;
216
+ return !((_a2 = getEnterAnimations(ps)) == null ? void 0 : _a2.includes("fade-in"));
217
+ }
218
+ },
219
+ exitOpacity: {
220
+ type: "number",
221
+ advanced: true,
222
+ defaultValueHint: 0,
223
+ hidden: (ps) => {
224
+ var _a2;
225
+ return !((_a2 = getExitAnimations(ps)) == null ? void 0 : _a2.includes("fade-out"));
226
+ }
227
+ },
228
+ enterScale: {
229
+ type: "number",
230
+ advanced: true,
231
+ defaultValueHint: 0.95,
232
+ hidden: (ps) => {
233
+ var _a2;
234
+ return !((_a2 = getEnterAnimations(ps)) == null ? void 0 : _a2.includes("zoom-enter"));
235
+ }
236
+ },
237
+ exitScale: {
238
+ type: "number",
239
+ advanced: true,
240
+ defaultValueHint: 0.95,
241
+ hidden: (ps) => {
242
+ var _a2;
243
+ return !((_a2 = getExitAnimations(ps)) == null ? void 0 : _a2.includes("zoom-exit"));
244
+ }
245
+ },
246
+ enterDelay: { type: "number", advanced: true, defaultValueHint: 0 },
247
+ exitDelay: { type: "number", advanced: true, defaultValueHint: 0 },
248
+ enterTiming: {
249
+ type: "string",
250
+ advanced: true,
251
+ defaultValueHint: "ease",
252
+ ...{
253
+ suggestions: ["linear", "ease", "ease-in", "ease-out", "ease-in-out"]
254
+ }
255
+ },
256
+ exitTiming: {
257
+ type: "string",
258
+ advanced: true,
259
+ defaultValueHint: "ease",
260
+ ...{
261
+ suggestions: ["linear", "ease", "ease-in", "ease-out", "ease-in-out"]
262
+ }
263
+ }
264
+ };
265
+ };
266
+ var overlayStates = {
267
+ open: {
268
+ type: "writable",
269
+ valueProp: "open",
270
+ onChangeProp: "onOpenChange",
271
+ variableType: "boolean"
272
+ }
273
+ };
274
+ var overlayProps = ({
275
+ defaultSlotContent,
276
+ triggerSlotName,
277
+ openDisplay
278
+ }) => ({
279
+ open: {
280
+ type: "boolean",
281
+ displayName: openDisplay,
282
+ editOnly: true,
283
+ uncontrolledProp: "defaultOpen"
284
+ },
285
+ modal: {
286
+ type: "boolean",
287
+ advanced: true,
288
+ description: "Disable interaction with outside elements. Only popover content will be visible to screen readers."
289
+ },
290
+ onOpenChange: {
291
+ type: "eventHandler",
292
+ argTypes: [
293
+ {
294
+ type: "boolean",
295
+ name: "open"
296
+ }
297
+ ]
298
+ },
299
+ [triggerSlotName]: {
300
+ type: "slot",
301
+ defaultValue: [defaultSlotContent],
302
+ ...{
303
+ mergeWithParent: true
304
+ }
305
+ },
306
+ themeResetClass: { type: "themeResetClass" }
307
+ });
308
+ function prefixClasses(x) {
309
+ return x.trim().split(/\s+/g).map((part) => `pl__${part}`).join(" ");
310
+ }
311
+ var prefixedBaseStyles = `
312
+ .box-border {
313
+ box-sizing: border-box;
314
+ }
315
+
316
+ .sr-only {
317
+ position: absolute;
318
+ width: 1px;
319
+ height: 1px;
320
+ padding: 0;
321
+ margin: -1px;
322
+ overflow: hidden;
323
+ clip: rect(0, 0, 0, 0);
324
+ white-space: nowrap;
325
+ border-width: 0;
326
+ }
327
+ .absolute {
328
+ position: absolute;
329
+ }
330
+ .relative {
331
+ position: relative;
332
+ }
333
+ .transition {
334
+ transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter;
335
+ }
336
+ .h-full {
337
+ height: 100%;
338
+ }
339
+ .z-50 { z-index: 50; }
340
+ .fixed { position: fixed; }
341
+ .inset-0 { top: 0; left: 0; right: 0; bottom: 0; }
342
+ .bottom-0 {
343
+ bottom: 0px;
344
+ }
345
+ .left-0 {
346
+ left: 0px;
347
+ }
348
+ .right-0 {
349
+ right: 0px;
350
+ }
351
+ .top-0 {
352
+ top: 0px;
353
+ }
354
+ .right-4 {
355
+ right: 1rem;
356
+ }
357
+ .top-4 {
358
+ top: 1rem;
359
+ }
360
+ .h-4 { height: 1rem; }
361
+ .w-4 { width: 1rem; }
362
+ .outline-none { outline: none; }
363
+
364
+ @keyframes plsmc-enter {
365
+
366
+ from {
367
+ opacity: var(--tw-enter-opacity, 1);
368
+ transform: translate3d(var(--tw-enter-translate-x, 0), var(--tw-enter-translate-y, 0), 0) scale3d(var(--tw-enter-scale, 1), var(--tw-enter-scale, 1), var(--tw-enter-scale, 1)) rotate(var(--tw-enter-rotate, 0));
369
+ }
370
+ }
371
+
372
+ @keyframes plsmc-exit {
373
+
374
+ to {
375
+ opacity: var(--tw-exit-opacity, 1);
376
+ transform: translate3d(var(--tw-exit-translate-x, 0), var(--tw-exit-translate-y, 0), 0) scale3d(var(--tw-exit-scale, 1), var(--tw-exit-scale, 1), var(--tw-exit-scale, 1)) rotate(var(--tw-exit-rotate, 0));
377
+ }
378
+ }
379
+ .animate-in,
380
+ .data-\\[state\\=open\\]\\:animate-in[data-state=open] {
381
+ animation-name: plsmc-enter;
382
+ animation-duration: 150ms;
383
+ --tw-enter-opacity: initial;
384
+ --tw-enter-scale: initial;
385
+ --tw-enter-rotate: initial;
386
+ --tw-enter-translate-x: initial;
387
+ --tw-enter-translate-y: initial;
388
+ }
389
+ .animate-out,
390
+ .data-\\[state\\=closed\\]\\:animate-out[data-state=closed] {
391
+ animation-name: plsmc-exit;
392
+ animation-duration: 150ms;
393
+ --tw-exit-opacity: initial;
394
+ --tw-exit-scale: initial;
395
+ --tw-exit-rotate: initial;
396
+ --tw-exit-translate-x: initial;
397
+ --tw-exit-translate-y: initial;
398
+ }
399
+ .data-\\[side\\=bottom\\]\\:slide-in-from-top-2[data-side=bottom] {
400
+ --tw-enter-translate-y: -0.5rem;
401
+ }
402
+
403
+ .data-\\[side\\=left\\]\\:slide-in-from-right-2[data-side=left] {
404
+ --tw-enter-translate-x: 0.5rem;
405
+ }
406
+
407
+ .data-\\[side\\=right\\]\\:slide-in-from-left-2[data-side=right] {
408
+ --tw-enter-translate-x: -0.5rem;
409
+ }
410
+
411
+ .data-\\[side\\=top\\]\\:slide-in-from-bottom-2[data-side=top] {
412
+ --tw-enter-translate-y: 0.5rem;
413
+ }
414
+
415
+ `.replace(/\n\./g, ".pl__");
416
+ function BaseStyles() {
417
+ return /* @__PURE__ */ React.createElement("style", { dangerouslySetInnerHTML: { __html: prefixedBaseStyles } });
418
+ }
419
+ var popoverProps = {
420
+ side: {
421
+ type: "choice",
422
+ options: ["top", "bottom", "left", "right"],
423
+ defaultValueHint: "bottom"
424
+ },
425
+ sideOffset: {
426
+ type: "number",
427
+ defaultValueHint: 4,
428
+ advanced: true
429
+ },
430
+ align: {
431
+ type: "choice",
432
+ options: ["center", "start", "end"],
433
+ defaultValueHint: "center"
434
+ },
435
+ alignOffset: {
436
+ type: "number",
437
+ defaultValueHint: 0,
438
+ advanced: true
439
+ },
440
+ ...animPropTypes({
441
+ defaultEnterAnimations: () => ["fade-in", "zoom-enter"],
442
+ defaultExitAnimations: () => ["fade-out", "zoom-exit"]
443
+ }),
444
+ slideIn: {
445
+ type: "boolean",
446
+ defaultValueHint: true,
447
+ description: "Add additional subtle slide-in animation on reveal, which can depend on where the tooltip is dynamically placed."
448
+ }
449
+ };
450
+
451
+ // src/popover.tsx
452
+ function Popover({
453
+ // root
454
+ open,
455
+ onOpenChange,
456
+ defaultOpen,
457
+ modal,
458
+ // content
459
+ className,
460
+ sideOffset = 4,
461
+ themeResetClass,
462
+ overlay,
463
+ slideIn = true,
464
+ // trigger/anchor
465
+ trigger = true,
466
+ children,
467
+ ...props
468
+ }) {
469
+ const [animProps, rest] = splitAnimProps(props);
470
+ return /* @__PURE__ */ React2.createElement(
471
+ Animated,
472
+ {
473
+ enterAnimations: ["fade-in", "zoom-enter"],
474
+ exitAnimations: ["fade-out", "zoom-exit"],
475
+ ...animProps
476
+ },
477
+ (dynClass) => /* @__PURE__ */ React2.createElement(
478
+ PopoverPrimitive.Root,
479
+ {
480
+ open,
481
+ onOpenChange,
482
+ defaultOpen,
483
+ modal
484
+ },
485
+ trigger ? /* @__PURE__ */ React2.createElement(PopoverPrimitive.Trigger, { asChild: true }, children) : /* @__PURE__ */ React2.createElement(PopoverPrimitive.Anchor, { asChild: true }, children),
486
+ /* @__PURE__ */ React2.createElement(PopoverPrimitive.Portal, null, /* @__PURE__ */ React2.createElement(
487
+ PopoverPrimitive.Content,
488
+ {
489
+ className: clsx(
490
+ prefixClasses(
491
+ "outline-none data-[state=open]:animate-in data-[state=closed]:animate-out"
492
+ ),
493
+ slideIn ? prefixClasses(
494
+ "data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
495
+ ) : "",
496
+ dynClass ? dynClass : "",
497
+ className,
498
+ themeResetClass
499
+ ),
500
+ sideOffset,
501
+ ...rest
502
+ },
503
+ overlay
504
+ )),
505
+ /* @__PURE__ */ React2.createElement(BaseStyles, null)
506
+ )
507
+ );
508
+ }
509
+ Popover.displayName = "PlasmicRadixPopover";
510
+ function registerPopover(PLASMIC) {
511
+ registerComponentHelper(PLASMIC, Popover, {
512
+ name: "hostless-radix-popover",
513
+ displayName: "Popover Core",
514
+ importPath: "@plasmicpkgs/radix-ui",
515
+ importName: "Popover",
516
+ states: overlayStates,
517
+ props: {
518
+ ...overlayProps({
519
+ triggerSlotName: "children",
520
+ defaultSlotContent: {
521
+ type: "default-component",
522
+ kind: "button",
523
+ props: {
524
+ children: { type: "text", value: `Show popover` }
525
+ }
526
+ }
527
+ }),
528
+ trigger: {
529
+ type: "boolean",
530
+ displayName: "Trigger on click",
531
+ defaultValueHint: true,
532
+ advanced: true
533
+ },
534
+ ...popoverProps,
535
+ overlay: {
536
+ type: "slot",
537
+ defaultValue: {
538
+ type: "vbox",
539
+ styles: {
540
+ padding: "16px",
541
+ width: "300px",
542
+ maxWidth: "100%",
543
+ borderWidth: "1px",
544
+ borderStyle: "solid",
545
+ borderColor: "#E2E8F0",
546
+ backgroundColor: "white",
547
+ borderRadius: "8px",
548
+ boxShadow: "0px 4px 16px 0px #00000033",
549
+ alignItems: "stretch"
550
+ },
551
+ children: ["Here is the popover content."]
552
+ },
553
+ ...{
554
+ mergeWithParent: true
555
+ }
556
+ }
557
+ }
558
+ });
559
+ }
560
+
561
+ // src/dialog.tsx
562
+ import * as DialogPrimitive from "@radix-ui/react-dialog";
563
+ import { cva } from "class-variance-authority";
564
+ import { X } from "lucide-react";
565
+ import * as React3 from "react";
566
+ import clsx2 from "clsx";
567
+ var DialogClose = React3.forwardRef((props) => {
568
+ var _a2;
569
+ return /* @__PURE__ */ React3.createElement(DialogPrimitive.Close, { ...props, asChild: true }, /* @__PURE__ */ React3.createElement("div", { className: props.className }, (_a2 = props.children) != null ? _a2 : /* @__PURE__ */ React3.createElement(X, { className: prefixClasses("h-4 w-4") }), /* @__PURE__ */ React3.createElement("span", { className: prefixClasses("sr-only") }, "Close")));
570
+ });
571
+ DialogClose.displayName = "PlasmicRadixDialogClose";
572
+ var DialogOverlay = React3.forwardRef(({ className, ...props }, ref) => {
573
+ return /* @__PURE__ */ React3.createElement(Animated, { ...props }, (dynClass) => /* @__PURE__ */ React3.createElement(
574
+ DialogPrimitive.Overlay,
575
+ {
576
+ className: clsx2(
577
+ [
578
+ "fixed inset-0 z-50 data-[state=open]:animate-in data-[state=closed]:animate-out"
579
+ ].map(prefixClasses),
580
+ dynClass ? dynClass : "",
581
+ className
582
+ ),
583
+ ...props,
584
+ ref
585
+ }
586
+ ));
587
+ });
588
+ DialogOverlay.displayName = "PlasmicOverlay";
589
+ var DialogContent = React3.forwardRef(({ className, themeResetClass, ...props }, ref) => {
590
+ var _a2, _b;
591
+ const [animProps, rest] = splitAnimProps(props);
592
+ return /* @__PURE__ */ React3.createElement(
593
+ Animated,
594
+ {
595
+ ...animProps,
596
+ enterAnimations: (_a2 = animProps.enterAnimations) != null ? _a2 : ["zoom-enter", "fade-in"],
597
+ exitAnimations: (_b = animProps.exitAnimations) != null ? _b : ["zoom-exit", "fade-out"]
598
+ },
599
+ (dynClass) => /* @__PURE__ */ React3.createElement(
600
+ DialogPrimitive.Content,
601
+ {
602
+ ...rest,
603
+ className: clsx2(
604
+ prefixClasses(
605
+ "fixed z-50 outline-none relative box-border data-[state=open]:animate-in data-[state=closed]:animate-out"
606
+ ),
607
+ dynClass ? dynClass : "",
608
+ themeResetClass,
609
+ className
610
+ ),
611
+ ref
612
+ }
613
+ )
614
+ );
615
+ });
616
+ DialogContent.displayName = "PlasmicRadixDialogContent";
617
+ function getDefaultSheetAnims(side = "right") {
618
+ return {
619
+ right: ["slide-in-from-right", "slide-out-to-right"],
620
+ bottom: ["slide-in-from-bottom", "slide-out-to-bottom"],
621
+ left: ["slide-in-from-left", "slide-out-to-left"],
622
+ top: ["slide-in-from-top", "slide-out-to-top"]
623
+ }[side];
624
+ }
625
+ var SheetContent = React3.forwardRef(({ className, themeResetClass, side = "right", ...props }, ref) => {
626
+ var _a2, _b;
627
+ const [defaultEnterAnimation, defaultExitAnimation] = getDefaultSheetAnims(
628
+ side != null ? side : "right"
629
+ );
630
+ return /* @__PURE__ */ React3.createElement(
631
+ Animated,
632
+ {
633
+ ...props,
634
+ enterAnimations: (_a2 = props.enterAnimations) != null ? _a2 : [defaultEnterAnimation],
635
+ exitAnimations: (_b = props.exitAnimations) != null ? _b : [defaultExitAnimation]
636
+ },
637
+ (dynClass) => /* @__PURE__ */ React3.createElement(
638
+ DialogPrimitive.Content,
639
+ {
640
+ className: clsx2(
641
+ sheetVariants({ side }),
642
+ dynClass ? dynClass : "",
643
+ className
644
+ ),
645
+ ...props,
646
+ ref
647
+ }
648
+ )
649
+ );
650
+ });
651
+ SheetContent.displayName = "PlasmicRadixSheetContent";
652
+ var sheetVariants = cva(
653
+ prefixClasses(
654
+ "fixed z-50 outline-none relative data-[state=open]:animate-in data-[state=closed]:animate-out"
655
+ ),
656
+ {
657
+ variants: {
658
+ side: {
659
+ top: prefixClasses("inset-x-0 top-0"),
660
+ bottom: prefixClasses("inset-x-0 bottom-0"),
661
+ left: prefixClasses("inset-y-0 left-0 h-full"),
662
+ right: prefixClasses("inset-y-0 right-0 h-full")
663
+ }
664
+ },
665
+ defaultVariants: {
666
+ side: "right"
667
+ }
668
+ }
669
+ );
670
+ var Dialog = React3.forwardRef(
671
+ ({
672
+ open,
673
+ onOpenChange,
674
+ modal,
675
+ themeResetClass,
676
+ children,
677
+ noContain,
678
+ defaultOpen,
679
+ triggerSlot,
680
+ overlayClassName,
681
+ ...props
682
+ }, ref) => /* @__PURE__ */ React3.createElement(
683
+ DialogPrimitive.Root,
684
+ {
685
+ open,
686
+ modal,
687
+ onOpenChange,
688
+ defaultOpen
689
+ },
690
+ /* @__PURE__ */ React3.createElement(DialogPrimitive.Trigger, { asChild: true }, triggerSlot),
691
+ noContain ? /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(DialogPrimitive.Portal, null, /* @__PURE__ */ React3.createElement(
692
+ DialogOverlay,
693
+ {
694
+ ref,
695
+ ...props,
696
+ className: clsx2(overlayClassName, themeResetClass)
697
+ }
698
+ ), children)) : /* @__PURE__ */ React3.createElement(DialogPrimitive.Portal, null, /* @__PURE__ */ React3.createElement(
699
+ DialogOverlay,
700
+ {
701
+ ref,
702
+ ...props,
703
+ className: clsx2(overlayClassName, themeResetClass)
704
+ },
705
+ children
706
+ )),
707
+ /* @__PURE__ */ React3.createElement(BaseStyles, null)
708
+ )
709
+ );
710
+ Dialog.displayName = "PlasmicRadixDialog";
711
+ var DialogTitle = DialogPrimitive.Title;
712
+ var DialogDescription = DialogPrimitive.Description;
713
+ function registerDialog(PLASMIC) {
714
+ registerComponentHelper(PLASMIC, Dialog, {
715
+ name: "hostless-radix-dialog",
716
+ displayName: "Dialog Core",
717
+ importPath: "@plasmicpkgs/radix-ui",
718
+ importName: "Dialog",
719
+ styleSections: false,
720
+ defaultStyles: {
721
+ // Note: unable to set position styles since Plasmic coerces to auto layout
722
+ display: "flex",
723
+ alignItems: "center",
724
+ justifyContent: "center",
725
+ backdropFilter: "blur(10px)",
726
+ background: "rgba(255,255,255,0.8)"
727
+ },
728
+ props: {
729
+ ...overlayProps({
730
+ defaultSlotContent: {
731
+ type: "default-component",
732
+ kind: "button",
733
+ props: {
734
+ children: { type: "text", value: `Show dialog` }
735
+ }
736
+ },
737
+ triggerSlotName: "triggerSlot"
738
+ }),
739
+ overlayClassName: {
740
+ type: "class"
741
+ },
742
+ noContain: {
743
+ type: "boolean",
744
+ advanced: true,
745
+ description: "Place the dialog content over the overlay instead of inside the overlay. Useful for separating their animations, but you also won't be able to conveniently set layout on the overlay as a parent."
746
+ },
747
+ children: {
748
+ type: "slot",
749
+ allowedComponents: [
750
+ "hostless-radix-sheet-content",
751
+ "hostless-radix-dialog-content"
752
+ ],
753
+ defaultValue: {
754
+ type: "component",
755
+ name: "hostless-radix-dialog-content"
756
+ }
757
+ }
758
+ },
759
+ states: overlayStates
760
+ });
761
+ registerComponentHelper(PLASMIC, DialogClose, {
762
+ name: "hostless-radix-dialog-close",
763
+ displayName: "Dialog Close",
764
+ importPath: "@plasmicpkgs/radix-ui",
765
+ importName: "DialogClose",
766
+ parentComponentName: "hostless-radix-dialog",
767
+ defaultStyles: {
768
+ position: "absolute",
769
+ top: "16px",
770
+ right: "16px",
771
+ opacity: "0.7",
772
+ borderRadius: "999px"
773
+ },
774
+ props: {
775
+ children: {
776
+ type: "slot",
777
+ hidePlaceholder: true
778
+ }
779
+ }
780
+ });
781
+ const dialogStyles = {
782
+ width: "400px",
783
+ maxWidth: "100%",
784
+ background: "rgb(255,255,255)",
785
+ borderWidth: "1px",
786
+ borderStyle: "solid",
787
+ borderColor: "#E2E8F0",
788
+ boxShadow: "0px 4px 16px 0px #00000033"
789
+ };
790
+ registerComponentHelper(PLASMIC, SheetContent, {
791
+ name: "hostless-radix-sheet-content",
792
+ displayName: "Drawer Content",
793
+ importPath: "@plasmicpkgs/radix-ui",
794
+ importName: "SheetContent",
795
+ parentComponentName: "hostless-radix-dialog",
796
+ defaultStyles: {
797
+ // Positions can sometimes take effect since these can be implicitly inserted as children of other default content, thus escaping Plasmic's layout coersion.
798
+ position: "fixed",
799
+ top: 0,
800
+ right: 0,
801
+ bottom: 0,
802
+ padding: "16px",
803
+ ...dialogStyles
804
+ },
805
+ props: {
806
+ side: {
807
+ type: "choice",
808
+ options: ["right", "bottom", "left", "top"],
809
+ defaultValueHint: "right"
810
+ },
811
+ themeResetClass: { type: "themeResetClass" },
812
+ children: {
813
+ type: "slot",
814
+ defaultValue: [
815
+ {
816
+ type: "vbox",
817
+ styles: {
818
+ alignItems: "stretch",
819
+ gap: "8px"
820
+ },
821
+ children: [
822
+ {
823
+ type: "component",
824
+ name: "hostless-radix-dialog-title"
825
+ },
826
+ {
827
+ type: "component",
828
+ name: "hostless-radix-dialog-description"
829
+ }
830
+ ]
831
+ },
832
+ {
833
+ type: "component",
834
+ name: "hostless-radix-dialog-close"
835
+ }
836
+ ]
837
+ },
838
+ ...animPropTypes({
839
+ defaultEnterAnimations: (ps) => [getDefaultSheetAnims(ps.side)[0]],
840
+ defaultExitAnimations: (ps) => [getDefaultSheetAnims(ps.side)[1]]
841
+ })
842
+ }
843
+ });
844
+ registerComponentHelper(PLASMIC, DialogContent, {
845
+ name: "hostless-radix-dialog-content",
846
+ displayName: "Dialog Content",
847
+ importPath: "@plasmicpkgs/radix-ui",
848
+ importName: "DialogContent",
849
+ parentComponentName: "hostless-radix-dialog",
850
+ defaultStyles: {
851
+ // No need for position here, just relying on layout container parent.
852
+ padding: "24px",
853
+ borderRadius: "8px",
854
+ ...dialogStyles
855
+ },
856
+ props: {
857
+ themeResetClass: { type: "themeResetClass" },
858
+ children: {
859
+ type: "slot",
860
+ defaultValue: [
861
+ {
862
+ type: "vbox",
863
+ styles: {
864
+ alignItems: "stretch",
865
+ gap: "8px"
866
+ },
867
+ children: [
868
+ {
869
+ type: "component",
870
+ name: "hostless-radix-dialog-title"
871
+ },
872
+ {
873
+ type: "component",
874
+ name: "hostless-radix-dialog-description"
875
+ }
876
+ ]
877
+ },
878
+ {
879
+ type: "component",
880
+ name: "hostless-radix-dialog-close"
881
+ }
882
+ ]
883
+ },
884
+ ...animPropTypes({
885
+ defaultEnterAnimations: () => ["zoom-enter", "fade-in"],
886
+ defaultExitAnimations: () => ["zoom-exit", "fade-out"]
887
+ })
888
+ }
889
+ });
890
+ registerComponentHelper(PLASMIC, DialogTitle, {
891
+ name: "hostless-radix-dialog-title",
892
+ displayName: "Dialog Title",
893
+ importPath: "@plasmicpkgs/radix-ui",
894
+ importName: "DialogTitle",
895
+ parentComponentName: "hostless-radix-dialog",
896
+ props: {
897
+ children: {
898
+ type: "slot",
899
+ defaultValue: "Sheet title"
900
+ }
901
+ }
902
+ });
903
+ registerComponentHelper(PLASMIC, DialogDescription, {
904
+ name: "hostless-radix-dialog-description",
905
+ displayName: "Dialog Description",
906
+ importPath: "@plasmicpkgs/radix-ui",
907
+ importName: "DialogDescription",
908
+ parentComponentName: "hostless-radix-dialog",
909
+ props: {
910
+ children: {
911
+ type: "slot",
912
+ defaultValue: "Sheet description"
913
+ }
914
+ }
915
+ });
916
+ }
917
+
918
+ // src/tooltip.tsx
919
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
920
+ import clsx3 from "clsx";
921
+ import * as React4 from "react";
922
+ var Tooltip = React4.forwardRef(
923
+ ({
924
+ // content & custom
925
+ className,
926
+ sideOffset = 4,
927
+ themeResetClass,
928
+ slideIn = true,
929
+ overlay,
930
+ // root
931
+ delayDuration,
932
+ disableHoverableContent,
933
+ open,
934
+ onOpenChange,
935
+ defaultOpen,
936
+ // trigger/anchor
937
+ children,
938
+ ...props
939
+ }, ref) => {
940
+ const [animProps, rest] = splitAnimProps(props);
941
+ return /* @__PURE__ */ React4.createElement(
942
+ Animated,
943
+ {
944
+ enterAnimations: ["fade-in", "zoom-enter"],
945
+ exitAnimations: ["fade-out", "zoom-exit"],
946
+ ...animProps
947
+ },
948
+ (dynClass) => /* @__PURE__ */ React4.createElement(TooltipPrimitive.Provider, null, /* @__PURE__ */ React4.createElement(
949
+ TooltipPrimitive.Root,
950
+ {
951
+ ...{
952
+ delayDuration,
953
+ disableHoverableContent,
954
+ open,
955
+ onOpenChange,
956
+ defaultOpen
957
+ }
958
+ },
959
+ /* @__PURE__ */ React4.createElement(TooltipPrimitive.Trigger, { asChild: true }, children),
960
+ /* @__PURE__ */ React4.createElement(
961
+ TooltipPrimitive.Content,
962
+ {
963
+ ref,
964
+ sideOffset,
965
+ className: clsx3(
966
+ prefixClasses("animate-in data-[state=closed]:animate-out"),
967
+ slideIn ? prefixClasses(
968
+ "data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
969
+ ) : "",
970
+ dynClass ? dynClass : "",
971
+ className,
972
+ themeResetClass
973
+ ),
974
+ ...rest
975
+ },
976
+ overlay
977
+ ),
978
+ /* @__PURE__ */ React4.createElement(BaseStyles, null)
979
+ ))
980
+ );
981
+ }
982
+ );
983
+ Tooltip.displayName = "PlasmicRadixTooltip";
984
+ function registerTooltip(PLASMIC) {
985
+ registerComponentHelper(PLASMIC, Tooltip, {
986
+ name: "hostless-radix-tooltip",
987
+ displayName: "Tooltip Core",
988
+ importPath: "@plasmicpkgs/radix-ui",
989
+ importName: "Tooltip",
990
+ props: {
991
+ ...overlayProps({
992
+ triggerSlotName: "children",
993
+ defaultSlotContent: { type: "text", value: "I have a tooltip." },
994
+ openDisplay: "Preview open"
995
+ }),
996
+ ...popoverProps,
997
+ overlay: {
998
+ type: "slot",
999
+ defaultValue: {
1000
+ type: "vbox",
1001
+ styles: {
1002
+ padding: "16px",
1003
+ width: "300px",
1004
+ maxWidth: "100%",
1005
+ borderWidth: "1px",
1006
+ borderStyle: "solid",
1007
+ borderColor: "#E2E8F0",
1008
+ backgroundColor: "white",
1009
+ borderRadius: "8px",
1010
+ boxShadow: "0px 4px 16px 0px #00000033",
1011
+ alignItems: "stretch"
1012
+ },
1013
+ children: ["Here is the tooltip content."]
1014
+ },
1015
+ ...{
1016
+ mergeWithParent: true
1017
+ }
1018
+ }
1019
+ }
1020
+ });
1021
+ }
1022
+
1023
+ // src/index.tsx
1024
+ function registerAll(PLASMIC) {
1025
+ registerPopover(PLASMIC);
1026
+ registerDialog(PLASMIC);
1027
+ registerTooltip(PLASMIC);
1028
+ }
1029
+ export {
1030
+ Dialog,
1031
+ DialogClose,
1032
+ DialogContent,
1033
+ DialogDescription,
1034
+ DialogTitle,
1035
+ Popover,
1036
+ SheetContent,
1037
+ Tooltip,
1038
+ popoverProps,
1039
+ registerAll,
1040
+ registerDialog,
1041
+ registerPopover,
1042
+ registerTooltip,
1043
+ sheetVariants
1044
+ };