@toriistudio/v0-playground 0.3.0 → 0.4.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/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +142 -116
- package/dist/index.mjs +128 -102
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -251,7 +251,7 @@ var useControls = (schema, options) => {
|
|
|
251
251
|
}
|
|
252
252
|
}, [JSON.stringify(mergedSchema), JSON.stringify(ctx.values)]);
|
|
253
253
|
const typedValues = ctx.values;
|
|
254
|
-
const
|
|
254
|
+
const jsx16 = (0, import_react2.useCallback)(() => {
|
|
255
255
|
if (!options?.componentName) return "";
|
|
256
256
|
const props = Object.entries(typedValues).map(([key, val]) => {
|
|
257
257
|
if (typeof val === "string") return `${key}="${val}"`;
|
|
@@ -265,41 +265,20 @@ var useControls = (schema, options) => {
|
|
|
265
265
|
controls: ctx.values,
|
|
266
266
|
schema: ctx.schema,
|
|
267
267
|
setValue: ctx.setValue,
|
|
268
|
-
jsx:
|
|
268
|
+
jsx: jsx16
|
|
269
269
|
};
|
|
270
270
|
};
|
|
271
271
|
var useUrlSyncedControls = useControls;
|
|
272
272
|
|
|
273
|
-
// src/components/PreviewContainer/PreviewContainer.tsx
|
|
274
|
-
var import_react3 = require("react");
|
|
275
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
276
|
-
var PreviewContainer = ({ children, hideControls }) => {
|
|
277
|
-
const { leftPanelWidth, isDesktop, isHydrated, containerRef } = useResizableLayout();
|
|
278
|
-
const previewRef = (0, import_react3.useRef)(null);
|
|
279
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
280
|
-
"div",
|
|
281
|
-
{
|
|
282
|
-
ref: previewRef,
|
|
283
|
-
className: "order-1 md:order-2 flex-1 bg-black overflow-auto flex items-center justify-center relative",
|
|
284
|
-
style: isHydrated && isDesktop && !hideControls ? {
|
|
285
|
-
width: `${100 - leftPanelWidth}%`,
|
|
286
|
-
marginLeft: `${leftPanelWidth}%`
|
|
287
|
-
} : {},
|
|
288
|
-
children
|
|
289
|
-
}
|
|
290
|
-
);
|
|
291
|
-
};
|
|
292
|
-
var PreviewContainer_default = PreviewContainer;
|
|
293
|
-
|
|
294
273
|
// src/components/ControlPanel/ControlPanel.tsx
|
|
295
|
-
var
|
|
274
|
+
var import_react4 = require("react");
|
|
296
275
|
var import_lucide_react3 = require("lucide-react");
|
|
297
276
|
|
|
298
277
|
// src/hooks/usePreviewUrl.ts
|
|
299
|
-
var
|
|
278
|
+
var import_react3 = require("react");
|
|
300
279
|
var usePreviewUrl = (values, basePath = "") => {
|
|
301
|
-
const [url, setUrl] = (0,
|
|
302
|
-
(0,
|
|
280
|
+
const [url, setUrl] = (0, import_react3.useState)("");
|
|
281
|
+
(0, import_react3.useEffect)(() => {
|
|
303
282
|
if (typeof window === "undefined") return;
|
|
304
283
|
const params = new URLSearchParams();
|
|
305
284
|
params.set("nocontrols", "true");
|
|
@@ -315,7 +294,7 @@ var usePreviewUrl = (values, basePath = "") => {
|
|
|
315
294
|
};
|
|
316
295
|
|
|
317
296
|
// src/components/ui/switch.tsx
|
|
318
|
-
var
|
|
297
|
+
var React3 = __toESM(require("react"));
|
|
319
298
|
var SwitchPrimitives = __toESM(require("@radix-ui/react-switch"));
|
|
320
299
|
|
|
321
300
|
// src/lib/utils.ts
|
|
@@ -326,8 +305,8 @@ function cn(...inputs) {
|
|
|
326
305
|
}
|
|
327
306
|
|
|
328
307
|
// src/components/ui/switch.tsx
|
|
329
|
-
var
|
|
330
|
-
var Switch =
|
|
308
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
309
|
+
var Switch = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
331
310
|
SwitchPrimitives.Root,
|
|
332
311
|
{
|
|
333
312
|
className: cn(
|
|
@@ -336,7 +315,7 @@ var Switch = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
336
315
|
),
|
|
337
316
|
...props,
|
|
338
317
|
ref,
|
|
339
|
-
children: /* @__PURE__ */ (0,
|
|
318
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
340
319
|
SwitchPrimitives.Thumb,
|
|
341
320
|
{
|
|
342
321
|
className: cn(
|
|
@@ -349,14 +328,14 @@ var Switch = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
349
328
|
Switch.displayName = SwitchPrimitives.Root.displayName;
|
|
350
329
|
|
|
351
330
|
// src/components/ui/label.tsx
|
|
352
|
-
var
|
|
331
|
+
var React4 = __toESM(require("react"));
|
|
353
332
|
var LabelPrimitive = __toESM(require("@radix-ui/react-label"));
|
|
354
333
|
var import_class_variance_authority = require("class-variance-authority");
|
|
355
|
-
var
|
|
334
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
356
335
|
var labelVariants = (0, import_class_variance_authority.cva)(
|
|
357
336
|
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
358
337
|
);
|
|
359
|
-
var Label =
|
|
338
|
+
var Label = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
360
339
|
LabelPrimitive.Root,
|
|
361
340
|
{
|
|
362
341
|
ref,
|
|
@@ -367,10 +346,10 @@ var Label = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
367
346
|
Label.displayName = LabelPrimitive.Root.displayName;
|
|
368
347
|
|
|
369
348
|
// src/components/ui/slider.tsx
|
|
370
|
-
var
|
|
349
|
+
var React5 = __toESM(require("react"));
|
|
371
350
|
var SliderPrimitive = __toESM(require("@radix-ui/react-slider"));
|
|
372
|
-
var
|
|
373
|
-
var Slider =
|
|
351
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
352
|
+
var Slider = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
374
353
|
SliderPrimitive.Root,
|
|
375
354
|
{
|
|
376
355
|
ref,
|
|
@@ -380,19 +359,19 @@ var Slider = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
380
359
|
),
|
|
381
360
|
...props,
|
|
382
361
|
children: [
|
|
383
|
-
/* @__PURE__ */ (0,
|
|
384
|
-
/* @__PURE__ */ (0,
|
|
362
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SliderPrimitive.Track, { className: "relative h-2 w-full grow overflow-hidden rounded-full bg-secondary", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SliderPrimitive.Range, { className: "absolute h-full bg-primary" }) }),
|
|
363
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SliderPrimitive.Thumb, { className: "block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50" })
|
|
385
364
|
]
|
|
386
365
|
}
|
|
387
366
|
));
|
|
388
367
|
Slider.displayName = SliderPrimitive.Root.displayName;
|
|
389
368
|
|
|
390
369
|
// src/components/ui/input.tsx
|
|
391
|
-
var
|
|
392
|
-
var
|
|
393
|
-
var Input =
|
|
370
|
+
var React6 = __toESM(require("react"));
|
|
371
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
372
|
+
var Input = React6.forwardRef(
|
|
394
373
|
({ className, type, ...props }, ref) => {
|
|
395
|
-
return /* @__PURE__ */ (0,
|
|
374
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
396
375
|
"input",
|
|
397
376
|
{
|
|
398
377
|
type,
|
|
@@ -409,13 +388,13 @@ var Input = React7.forwardRef(
|
|
|
409
388
|
Input.displayName = "Input";
|
|
410
389
|
|
|
411
390
|
// src/components/ui/select.tsx
|
|
412
|
-
var
|
|
391
|
+
var React7 = __toESM(require("react"));
|
|
413
392
|
var SelectPrimitive = __toESM(require("@radix-ui/react-select"));
|
|
414
393
|
var import_lucide_react2 = require("lucide-react");
|
|
415
|
-
var
|
|
394
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
416
395
|
var Select = SelectPrimitive.Root;
|
|
417
396
|
var SelectValue = SelectPrimitive.Value;
|
|
418
|
-
var SelectTrigger =
|
|
397
|
+
var SelectTrigger = React7.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
419
398
|
SelectPrimitive.Trigger,
|
|
420
399
|
{
|
|
421
400
|
ref,
|
|
@@ -426,12 +405,12 @@ var SelectTrigger = React8.forwardRef(({ className, children, ...props }, ref) =
|
|
|
426
405
|
...props,
|
|
427
406
|
children: [
|
|
428
407
|
children,
|
|
429
|
-
/* @__PURE__ */ (0,
|
|
408
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react2.ChevronDown, { className: "h-4 w-4 opacity-50" }) })
|
|
430
409
|
]
|
|
431
410
|
}
|
|
432
411
|
));
|
|
433
412
|
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
434
|
-
var SelectScrollUpButton =
|
|
413
|
+
var SelectScrollUpButton = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
435
414
|
SelectPrimitive.ScrollUpButton,
|
|
436
415
|
{
|
|
437
416
|
ref,
|
|
@@ -440,11 +419,11 @@ var SelectScrollUpButton = React8.forwardRef(({ className, ...props }, ref) => /
|
|
|
440
419
|
className
|
|
441
420
|
),
|
|
442
421
|
...props,
|
|
443
|
-
children: /* @__PURE__ */ (0,
|
|
422
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react2.ChevronUp, { className: "h-4 w-4" })
|
|
444
423
|
}
|
|
445
424
|
));
|
|
446
425
|
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
447
|
-
var SelectScrollDownButton =
|
|
426
|
+
var SelectScrollDownButton = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
448
427
|
SelectPrimitive.ScrollDownButton,
|
|
449
428
|
{
|
|
450
429
|
ref,
|
|
@@ -453,11 +432,11 @@ var SelectScrollDownButton = React8.forwardRef(({ className, ...props }, ref) =>
|
|
|
453
432
|
className
|
|
454
433
|
),
|
|
455
434
|
...props,
|
|
456
|
-
children: /* @__PURE__ */ (0,
|
|
435
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react2.ChevronDown, { className: "h-4 w-4" })
|
|
457
436
|
}
|
|
458
437
|
));
|
|
459
438
|
SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
|
|
460
|
-
var SelectContent =
|
|
439
|
+
var SelectContent = React7.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SelectPrimitive.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
461
440
|
SelectPrimitive.Content,
|
|
462
441
|
{
|
|
463
442
|
ref,
|
|
@@ -469,8 +448,8 @@ var SelectContent = React8.forwardRef(({ className, children, position = "popper
|
|
|
469
448
|
position,
|
|
470
449
|
...props,
|
|
471
450
|
children: [
|
|
472
|
-
/* @__PURE__ */ (0,
|
|
473
|
-
/* @__PURE__ */ (0,
|
|
451
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SelectScrollUpButton, {}),
|
|
452
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
474
453
|
SelectPrimitive.Viewport,
|
|
475
454
|
{
|
|
476
455
|
className: cn(
|
|
@@ -480,12 +459,12 @@ var SelectContent = React8.forwardRef(({ className, children, position = "popper
|
|
|
480
459
|
children
|
|
481
460
|
}
|
|
482
461
|
),
|
|
483
|
-
/* @__PURE__ */ (0,
|
|
462
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SelectScrollDownButton, {})
|
|
484
463
|
]
|
|
485
464
|
}
|
|
486
465
|
) }));
|
|
487
466
|
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
488
|
-
var SelectLabel =
|
|
467
|
+
var SelectLabel = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
489
468
|
SelectPrimitive.Label,
|
|
490
469
|
{
|
|
491
470
|
ref,
|
|
@@ -494,7 +473,7 @@ var SelectLabel = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE
|
|
|
494
473
|
}
|
|
495
474
|
));
|
|
496
475
|
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
497
|
-
var SelectItem =
|
|
476
|
+
var SelectItem = React7.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
498
477
|
SelectPrimitive.Item,
|
|
499
478
|
{
|
|
500
479
|
ref,
|
|
@@ -504,13 +483,13 @@ var SelectItem = React8.forwardRef(({ className, children, ...props }, ref) => /
|
|
|
504
483
|
),
|
|
505
484
|
...props,
|
|
506
485
|
children: [
|
|
507
|
-
/* @__PURE__ */ (0,
|
|
508
|
-
/* @__PURE__ */ (0,
|
|
486
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react2.Check, { className: "h-4 w-4" }) }) }),
|
|
487
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SelectPrimitive.ItemText, { children })
|
|
509
488
|
]
|
|
510
489
|
}
|
|
511
490
|
));
|
|
512
491
|
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
513
|
-
var SelectSeparator =
|
|
492
|
+
var SelectSeparator = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
514
493
|
SelectPrimitive.Separator,
|
|
515
494
|
{
|
|
516
495
|
ref,
|
|
@@ -521,10 +500,10 @@ var SelectSeparator = React8.forwardRef(({ className, ...props }, ref) => /* @__
|
|
|
521
500
|
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
522
501
|
|
|
523
502
|
// src/components/ui/button.tsx
|
|
524
|
-
var
|
|
503
|
+
var React8 = __toESM(require("react"));
|
|
525
504
|
var import_react_slot = require("@radix-ui/react-slot");
|
|
526
505
|
var import_class_variance_authority2 = require("class-variance-authority");
|
|
527
|
-
var
|
|
506
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
528
507
|
var buttonVariants = (0, import_class_variance_authority2.cva)(
|
|
529
508
|
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
530
509
|
{
|
|
@@ -550,10 +529,10 @@ var buttonVariants = (0, import_class_variance_authority2.cva)(
|
|
|
550
529
|
}
|
|
551
530
|
}
|
|
552
531
|
);
|
|
553
|
-
var Button =
|
|
532
|
+
var Button = React8.forwardRef(
|
|
554
533
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
555
534
|
const Comp = asChild ? import_react_slot.Slot : "button";
|
|
556
|
-
return /* @__PURE__ */ (0,
|
|
535
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
557
536
|
Comp,
|
|
558
537
|
{
|
|
559
538
|
className: cn(buttonVariants({ variant, size, className })),
|
|
@@ -566,10 +545,10 @@ var Button = React9.forwardRef(
|
|
|
566
545
|
Button.displayName = "Button";
|
|
567
546
|
|
|
568
547
|
// src/components/ControlPanel/ControlPanel.tsx
|
|
569
|
-
var
|
|
548
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
570
549
|
var ControlPanel = () => {
|
|
571
|
-
const [copied, setCopied] = (0,
|
|
572
|
-
const { leftPanelWidth, isDesktop, isHydrated
|
|
550
|
+
const [copied, setCopied] = (0, import_react4.useState)(false);
|
|
551
|
+
const { leftPanelWidth, isDesktop, isHydrated } = useResizableLayout();
|
|
573
552
|
const { schema, setValue, values, componentName, config } = useControlsContext();
|
|
574
553
|
const previewUrl = usePreviewUrl(values);
|
|
575
554
|
const normalControls = Object.entries(schema).filter(
|
|
@@ -578,7 +557,7 @@ var ControlPanel = () => {
|
|
|
578
557
|
const buttonControls = Object.entries(schema).filter(
|
|
579
558
|
([, control]) => control.type === "button" && !control.hidden
|
|
580
559
|
);
|
|
581
|
-
const
|
|
560
|
+
const jsx16 = (0, import_react4.useMemo)(() => {
|
|
582
561
|
if (!componentName) return "";
|
|
583
562
|
const props = Object.entries(values).map(([key, val]) => {
|
|
584
563
|
if (typeof val === "string") return `${key}="${val}"`;
|
|
@@ -587,7 +566,7 @@ var ControlPanel = () => {
|
|
|
587
566
|
}).join(" ");
|
|
588
567
|
return `<${componentName} ${props} />`;
|
|
589
568
|
}, [componentName, values]);
|
|
590
|
-
return /* @__PURE__ */ (0,
|
|
569
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
591
570
|
"div",
|
|
592
571
|
{
|
|
593
572
|
className: `order-2 md:order-1 w-full md:h-auto p-2 md:p-4 bg-stone-900 font-mono text-stone-300 transition-opacity duration-300 ${!isHydrated ? "opacity-0" : "opacity-100"}`,
|
|
@@ -606,19 +585,19 @@ var ControlPanel = () => {
|
|
|
606
585
|
overflowY: "auto"
|
|
607
586
|
} : {}
|
|
608
587
|
},
|
|
609
|
-
children: /* @__PURE__ */ (0,
|
|
610
|
-
/* @__PURE__ */ (0,
|
|
611
|
-
/* @__PURE__ */ (0,
|
|
588
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "mb-10 space-y-4 p-2 md:p-4 border border-stone-700 rounded-md", children: [
|
|
589
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "space-y-1", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h1", { className: "text-lg text-stone-100 font-bold", children: config?.mainLabel ?? "Controls" }) }),
|
|
590
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-4 pt-2", children: [
|
|
612
591
|
normalControls.map(([key, control]) => {
|
|
613
592
|
const value = values[key];
|
|
614
593
|
switch (control.type) {
|
|
615
594
|
case "boolean":
|
|
616
|
-
return /* @__PURE__ */ (0,
|
|
595
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
617
596
|
"div",
|
|
618
597
|
{
|
|
619
598
|
className: "flex items-center space-x-4 border-t border-stone-700 pt-4",
|
|
620
599
|
children: [
|
|
621
|
-
/* @__PURE__ */ (0,
|
|
600
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
622
601
|
Switch,
|
|
623
602
|
{
|
|
624
603
|
id: key,
|
|
@@ -627,19 +606,19 @@ var ControlPanel = () => {
|
|
|
627
606
|
className: "data-[state=checked]:bg-stone-700 data-[state=unchecked]:bg-stone-700/40"
|
|
628
607
|
}
|
|
629
608
|
),
|
|
630
|
-
/* @__PURE__ */ (0,
|
|
609
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Label, { htmlFor: key, className: "cursor-pointer", children: key })
|
|
631
610
|
]
|
|
632
611
|
},
|
|
633
612
|
key
|
|
634
613
|
);
|
|
635
614
|
case "number":
|
|
636
|
-
return /* @__PURE__ */ (0,
|
|
637
|
-
/* @__PURE__ */ (0,
|
|
615
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-2 w-full", children: [
|
|
616
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex items-center justify-between pb-1", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Label, { className: "text-stone-300", htmlFor: key, children: [
|
|
638
617
|
key,
|
|
639
618
|
": ",
|
|
640
619
|
value
|
|
641
620
|
] }) }),
|
|
642
|
-
/* @__PURE__ */ (0,
|
|
621
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
643
622
|
Slider,
|
|
644
623
|
{
|
|
645
624
|
id: key,
|
|
@@ -653,7 +632,7 @@ var ControlPanel = () => {
|
|
|
653
632
|
)
|
|
654
633
|
] }, key);
|
|
655
634
|
case "string":
|
|
656
|
-
return /* @__PURE__ */ (0,
|
|
635
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
657
636
|
Input,
|
|
658
637
|
{
|
|
659
638
|
id: key,
|
|
@@ -665,9 +644,9 @@ var ControlPanel = () => {
|
|
|
665
644
|
key
|
|
666
645
|
);
|
|
667
646
|
case "color":
|
|
668
|
-
return /* @__PURE__ */ (0,
|
|
669
|
-
/* @__PURE__ */ (0,
|
|
670
|
-
/* @__PURE__ */ (0,
|
|
647
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-2 w-full", children: [
|
|
648
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex items-center justify-between pb-1", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Label, { className: "text-stone-300", htmlFor: key, children: key }) }),
|
|
649
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
671
650
|
"input",
|
|
672
651
|
{
|
|
673
652
|
type: "color",
|
|
@@ -679,20 +658,20 @@ var ControlPanel = () => {
|
|
|
679
658
|
)
|
|
680
659
|
] }, key);
|
|
681
660
|
case "select":
|
|
682
|
-
return /* @__PURE__ */ (0,
|
|
661
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
683
662
|
"div",
|
|
684
663
|
{
|
|
685
664
|
className: "space-y-2 border-t border-stone-700 pt-4",
|
|
686
665
|
children: [
|
|
687
|
-
/* @__PURE__ */ (0,
|
|
688
|
-
/* @__PURE__ */ (0,
|
|
666
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Label, { className: "text-stone-300", htmlFor: key, children: key }),
|
|
667
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
689
668
|
Select,
|
|
690
669
|
{
|
|
691
670
|
value,
|
|
692
671
|
onValueChange: (val) => setValue(key, val),
|
|
693
672
|
children: [
|
|
694
|
-
/* @__PURE__ */ (0,
|
|
695
|
-
/* @__PURE__ */ (0,
|
|
673
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SelectTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SelectValue, { placeholder: "Select option" }) }),
|
|
674
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SelectContent, { children: control.options.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SelectItem, { value: opt, children: opt }, opt)) })
|
|
696
675
|
]
|
|
697
676
|
}
|
|
698
677
|
)
|
|
@@ -704,35 +683,35 @@ var ControlPanel = () => {
|
|
|
704
683
|
return null;
|
|
705
684
|
}
|
|
706
685
|
}),
|
|
707
|
-
(buttonControls.length > 0 ||
|
|
686
|
+
(buttonControls.length > 0 || jsx16) && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
708
687
|
"div",
|
|
709
688
|
{
|
|
710
689
|
className: `${normalControls.length > 0 ? "border-t" : ""} border-stone-700`,
|
|
711
690
|
children: [
|
|
712
|
-
|
|
691
|
+
jsx16 && config?.showCopyButton !== false && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex-1 pt-4", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
713
692
|
"button",
|
|
714
693
|
{
|
|
715
694
|
onClick: () => {
|
|
716
|
-
navigator.clipboard.writeText(
|
|
695
|
+
navigator.clipboard.writeText(jsx16);
|
|
717
696
|
setCopied(true);
|
|
718
697
|
setTimeout(() => setCopied(false), 5e3);
|
|
719
698
|
},
|
|
720
699
|
className: "w-full px-4 py-2 text-sm bg-stone-700 hover:bg-stone-600 text-white rounded flex items-center justify-center gap-2",
|
|
721
|
-
children: copied ? /* @__PURE__ */ (0,
|
|
722
|
-
/* @__PURE__ */ (0,
|
|
700
|
+
children: copied ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
701
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react3.Check, { className: "w-4 h-4" }),
|
|
723
702
|
"Copied"
|
|
724
|
-
] }) : /* @__PURE__ */ (0,
|
|
725
|
-
/* @__PURE__ */ (0,
|
|
703
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
704
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react3.Copy, { className: "w-4 h-4" }),
|
|
726
705
|
"Copy to Clipboard"
|
|
727
706
|
] })
|
|
728
707
|
}
|
|
729
708
|
) }, "control-panel-jsx"),
|
|
730
|
-
buttonControls.length > 0 && /* @__PURE__ */ (0,
|
|
731
|
-
([key, control]) => control.type === "button" ? /* @__PURE__ */ (0,
|
|
709
|
+
buttonControls.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex flex-wrap gap-2 pt-4", children: buttonControls.map(
|
|
710
|
+
([key, control]) => control.type === "button" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
732
711
|
"div",
|
|
733
712
|
{
|
|
734
713
|
className: "flex-1",
|
|
735
|
-
children: control.render ? control.render() : /* @__PURE__ */ (0,
|
|
714
|
+
children: control.render ? control.render() : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
736
715
|
"button",
|
|
737
716
|
{
|
|
738
717
|
onClick: control.onClick,
|
|
@@ -748,7 +727,7 @@ var ControlPanel = () => {
|
|
|
748
727
|
}
|
|
749
728
|
)
|
|
750
729
|
] }),
|
|
751
|
-
previewUrl && /* @__PURE__ */ (0,
|
|
730
|
+
previewUrl && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Button, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
752
731
|
"a",
|
|
753
732
|
{
|
|
754
733
|
href: previewUrl,
|
|
@@ -756,7 +735,7 @@ var ControlPanel = () => {
|
|
|
756
735
|
rel: "noopener noreferrer",
|
|
757
736
|
className: "w-full px-4 py-2 text-sm text-center bg-stone-800 hover:bg-stone-700 text-white rounded",
|
|
758
737
|
children: [
|
|
759
|
-
/* @__PURE__ */ (0,
|
|
738
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react3.SquareArrowOutUpRight, {}),
|
|
760
739
|
" Open in a New Tab"
|
|
761
740
|
]
|
|
762
741
|
}
|
|
@@ -767,8 +746,55 @@ var ControlPanel = () => {
|
|
|
767
746
|
};
|
|
768
747
|
var ControlPanel_default = ControlPanel;
|
|
769
748
|
|
|
770
|
-
// src/components/
|
|
749
|
+
// src/components/PreviewContainer/PreviewContainer.tsx
|
|
750
|
+
var import_react5 = require("react");
|
|
751
|
+
|
|
752
|
+
// src/components/Grid/Grid.tsx
|
|
753
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
754
|
+
function Grid() {
|
|
755
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
756
|
+
"div",
|
|
757
|
+
{
|
|
758
|
+
className: "absolute inset-0 w-screen h-screen z-[0] blur-[1px]",
|
|
759
|
+
style: {
|
|
760
|
+
backgroundImage: `
|
|
761
|
+
linear-gradient(to right,rgb(13, 13, 13) 1px, transparent 1px),
|
|
762
|
+
linear-gradient(to bottom,rgb(13, 13, 13) 1px, transparent 1px)
|
|
763
|
+
`,
|
|
764
|
+
backgroundSize: "1rem 1rem",
|
|
765
|
+
backgroundPosition: "center"
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
);
|
|
769
|
+
}
|
|
770
|
+
var Grid_default = Grid;
|
|
771
|
+
|
|
772
|
+
// src/components/PreviewContainer/PreviewContainer.tsx
|
|
771
773
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
774
|
+
var PreviewContainer = ({ children, hideControls }) => {
|
|
775
|
+
const { config } = useControlsContext();
|
|
776
|
+
const { leftPanelWidth, isDesktop, isHydrated, containerRef } = useResizableLayout();
|
|
777
|
+
const previewRef = (0, import_react5.useRef)(null);
|
|
778
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
779
|
+
"div",
|
|
780
|
+
{
|
|
781
|
+
ref: previewRef,
|
|
782
|
+
className: "order-1 md:order-2 flex-1 bg-black overflow-auto flex items-center justify-center relative",
|
|
783
|
+
style: isHydrated && isDesktop && !hideControls ? {
|
|
784
|
+
width: `${100 - leftPanelWidth}%`,
|
|
785
|
+
marginLeft: `${leftPanelWidth}%`
|
|
786
|
+
} : {},
|
|
787
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "w-screen h-screen", children: [
|
|
788
|
+
config?.showGrid && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Grid_default, {}),
|
|
789
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "w-screen h-screen flex items-center justify-center relative", children })
|
|
790
|
+
] })
|
|
791
|
+
}
|
|
792
|
+
);
|
|
793
|
+
};
|
|
794
|
+
var PreviewContainer_default = PreviewContainer;
|
|
795
|
+
|
|
796
|
+
// src/components/Playground/Playground.tsx
|
|
797
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
772
798
|
var NO_CONTROLS_PARAM = "nocontrols";
|
|
773
799
|
function Playground({ children }) {
|
|
774
800
|
const [isHydrated, setIsHydrated] = (0, import_react6.useState)(false);
|
|
@@ -786,20 +812,20 @@ function Playground({ children }) {
|
|
|
786
812
|
setTimeout(() => setCopied(false), 2e3);
|
|
787
813
|
};
|
|
788
814
|
if (!isHydrated) return null;
|
|
789
|
-
return /* @__PURE__ */ (0,
|
|
790
|
-
hideControls && /* @__PURE__ */ (0,
|
|
815
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ResizableLayout, { hideControls, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(ControlsProvider, { children: [
|
|
816
|
+
hideControls && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
791
817
|
"button",
|
|
792
818
|
{
|
|
793
819
|
onClick: handleCopy,
|
|
794
820
|
className: "absolute top-4 right-4 z-50 flex items-center gap-1 rounded bg-black/70 px-3 py-1 text-white hover:bg-black",
|
|
795
821
|
children: [
|
|
796
|
-
copied ? /* @__PURE__ */ (0,
|
|
822
|
+
copied ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react4.Check, { size: 16 }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react4.Copy, { size: 16 }),
|
|
797
823
|
copied ? "Copied!" : "Share"
|
|
798
824
|
]
|
|
799
825
|
}
|
|
800
826
|
),
|
|
801
|
-
/* @__PURE__ */ (0,
|
|
802
|
-
!hideControls && /* @__PURE__ */ (0,
|
|
827
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(PreviewContainer_default, { hideControls, children }),
|
|
828
|
+
!hideControls && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ControlPanel_default, {})
|
|
803
829
|
] }) });
|
|
804
830
|
}
|
|
805
831
|
|
|
@@ -813,7 +839,7 @@ var import_react7 = require("react");
|
|
|
813
839
|
var import_drei = require("@react-three/drei");
|
|
814
840
|
var import_fiber = require("@react-three/fiber");
|
|
815
841
|
var import_lodash = require("lodash");
|
|
816
|
-
var
|
|
842
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
817
843
|
function CameraLogger() {
|
|
818
844
|
const { camera } = (0, import_fiber.useThree)();
|
|
819
845
|
const controlsRef = (0, import_react7.useRef)(null);
|
|
@@ -830,11 +856,11 @@ function CameraLogger() {
|
|
|
830
856
|
controls.addEventListener("change", handler);
|
|
831
857
|
return () => controls.removeEventListener("change", handler);
|
|
832
858
|
}, []);
|
|
833
|
-
return /* @__PURE__ */ (0,
|
|
859
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_drei.OrbitControls, { ref: controlsRef });
|
|
834
860
|
}
|
|
835
861
|
|
|
836
862
|
// src/components/Canvas/Canvas.tsx
|
|
837
|
-
var
|
|
863
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
838
864
|
var ResponsiveCamera = ({
|
|
839
865
|
height,
|
|
840
866
|
width
|
|
@@ -875,28 +901,28 @@ var Canvas = ({ mediaProps, children }) => {
|
|
|
875
901
|
...mediaProps || {},
|
|
876
902
|
size: mediaProps?.size || { width: 400, height: 400 }
|
|
877
903
|
};
|
|
878
|
-
return /* @__PURE__ */ (0,
|
|
904
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
879
905
|
"div",
|
|
880
906
|
{
|
|
881
907
|
ref: canvasRef,
|
|
882
908
|
className: "w-full h-full pointer-events-none relative touch-none",
|
|
883
|
-
children: /* @__PURE__ */ (0,
|
|
909
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
884
910
|
import_fiber2.Canvas,
|
|
885
911
|
{
|
|
886
912
|
resize: { polyfill: ResizeObserver },
|
|
887
913
|
style: { width: parentSize?.width, height: parentSize?.height },
|
|
888
914
|
gl: { preserveDrawingBuffer: true },
|
|
889
915
|
children: [
|
|
890
|
-
parentSize?.height && parentSize?.width && /* @__PURE__ */ (0,
|
|
916
|
+
parentSize?.height && parentSize?.width && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
891
917
|
ResponsiveCamera,
|
|
892
918
|
{
|
|
893
919
|
height: parentSize.height,
|
|
894
920
|
width: parentSize.width
|
|
895
921
|
}
|
|
896
922
|
),
|
|
897
|
-
mediaProps?.debugOrbit && /* @__PURE__ */ (0,
|
|
898
|
-
/* @__PURE__ */ (0,
|
|
899
|
-
/* @__PURE__ */ (0,
|
|
923
|
+
mediaProps?.debugOrbit && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CameraLogger, {}),
|
|
924
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("ambientLight", { intensity: 1 }),
|
|
925
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("pointLight", { position: [10, 10, 10] }),
|
|
900
926
|
import_react8.default.cloneElement(children, mergedMediaProps)
|
|
901
927
|
]
|
|
902
928
|
}
|
|
@@ -907,12 +933,12 @@ var Canvas = ({ mediaProps, children }) => {
|
|
|
907
933
|
var Canvas_default = Canvas;
|
|
908
934
|
|
|
909
935
|
// src/components/PlaygroundCanvas/PlaygroundCanvas.tsx
|
|
910
|
-
var
|
|
936
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
911
937
|
var PlaygroundCanvas = ({
|
|
912
938
|
children,
|
|
913
939
|
mediaProps
|
|
914
940
|
}) => {
|
|
915
|
-
return /* @__PURE__ */ (0,
|
|
941
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Playground, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Canvas_default, { mediaProps, children }) });
|
|
916
942
|
};
|
|
917
943
|
var PlaygroundCanvas_default = PlaygroundCanvas;
|
|
918
944
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -221,7 +221,7 @@ var useControls = (schema, options) => {
|
|
|
221
221
|
}
|
|
222
222
|
}, [JSON.stringify(mergedSchema), JSON.stringify(ctx.values)]);
|
|
223
223
|
const typedValues = ctx.values;
|
|
224
|
-
const
|
|
224
|
+
const jsx16 = useCallback(() => {
|
|
225
225
|
if (!options?.componentName) return "";
|
|
226
226
|
const props = Object.entries(typedValues).map(([key, val]) => {
|
|
227
227
|
if (typeof val === "string") return `${key}="${val}"`;
|
|
@@ -235,32 +235,11 @@ var useControls = (schema, options) => {
|
|
|
235
235
|
controls: ctx.values,
|
|
236
236
|
schema: ctx.schema,
|
|
237
237
|
setValue: ctx.setValue,
|
|
238
|
-
jsx:
|
|
238
|
+
jsx: jsx16
|
|
239
239
|
};
|
|
240
240
|
};
|
|
241
241
|
var useUrlSyncedControls = useControls;
|
|
242
242
|
|
|
243
|
-
// src/components/PreviewContainer/PreviewContainer.tsx
|
|
244
|
-
import { useRef as useRef2 } from "react";
|
|
245
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
246
|
-
var PreviewContainer = ({ children, hideControls }) => {
|
|
247
|
-
const { leftPanelWidth, isDesktop, isHydrated, containerRef } = useResizableLayout();
|
|
248
|
-
const previewRef = useRef2(null);
|
|
249
|
-
return /* @__PURE__ */ jsx3(
|
|
250
|
-
"div",
|
|
251
|
-
{
|
|
252
|
-
ref: previewRef,
|
|
253
|
-
className: "order-1 md:order-2 flex-1 bg-black overflow-auto flex items-center justify-center relative",
|
|
254
|
-
style: isHydrated && isDesktop && !hideControls ? {
|
|
255
|
-
width: `${100 - leftPanelWidth}%`,
|
|
256
|
-
marginLeft: `${leftPanelWidth}%`
|
|
257
|
-
} : {},
|
|
258
|
-
children
|
|
259
|
-
}
|
|
260
|
-
);
|
|
261
|
-
};
|
|
262
|
-
var PreviewContainer_default = PreviewContainer;
|
|
263
|
-
|
|
264
243
|
// src/components/ControlPanel/ControlPanel.tsx
|
|
265
244
|
import { useState as useState4, useMemo as useMemo2 } from "react";
|
|
266
245
|
import { Check as Check2, Copy, SquareArrowOutUpRight } from "lucide-react";
|
|
@@ -285,7 +264,7 @@ var usePreviewUrl = (values, basePath = "") => {
|
|
|
285
264
|
};
|
|
286
265
|
|
|
287
266
|
// src/components/ui/switch.tsx
|
|
288
|
-
import * as
|
|
267
|
+
import * as React3 from "react";
|
|
289
268
|
import * as SwitchPrimitives from "@radix-ui/react-switch";
|
|
290
269
|
|
|
291
270
|
// src/lib/utils.ts
|
|
@@ -296,8 +275,8 @@ function cn(...inputs) {
|
|
|
296
275
|
}
|
|
297
276
|
|
|
298
277
|
// src/components/ui/switch.tsx
|
|
299
|
-
import { jsx as
|
|
300
|
-
var Switch =
|
|
278
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
279
|
+
var Switch = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx3(
|
|
301
280
|
SwitchPrimitives.Root,
|
|
302
281
|
{
|
|
303
282
|
className: cn(
|
|
@@ -306,7 +285,7 @@ var Switch = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
306
285
|
),
|
|
307
286
|
...props,
|
|
308
287
|
ref,
|
|
309
|
-
children: /* @__PURE__ */
|
|
288
|
+
children: /* @__PURE__ */ jsx3(
|
|
310
289
|
SwitchPrimitives.Thumb,
|
|
311
290
|
{
|
|
312
291
|
className: cn(
|
|
@@ -319,14 +298,14 @@ var Switch = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
319
298
|
Switch.displayName = SwitchPrimitives.Root.displayName;
|
|
320
299
|
|
|
321
300
|
// src/components/ui/label.tsx
|
|
322
|
-
import * as
|
|
301
|
+
import * as React4 from "react";
|
|
323
302
|
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
324
303
|
import { cva } from "class-variance-authority";
|
|
325
|
-
import { jsx as
|
|
304
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
326
305
|
var labelVariants = cva(
|
|
327
306
|
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
328
307
|
);
|
|
329
|
-
var Label =
|
|
308
|
+
var Label = React4.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx4(
|
|
330
309
|
LabelPrimitive.Root,
|
|
331
310
|
{
|
|
332
311
|
ref,
|
|
@@ -337,10 +316,10 @@ var Label = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
337
316
|
Label.displayName = LabelPrimitive.Root.displayName;
|
|
338
317
|
|
|
339
318
|
// src/components/ui/slider.tsx
|
|
340
|
-
import * as
|
|
319
|
+
import * as React5 from "react";
|
|
341
320
|
import * as SliderPrimitive from "@radix-ui/react-slider";
|
|
342
|
-
import { jsx as
|
|
343
|
-
var Slider =
|
|
321
|
+
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
322
|
+
var Slider = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxs2(
|
|
344
323
|
SliderPrimitive.Root,
|
|
345
324
|
{
|
|
346
325
|
ref,
|
|
@@ -350,19 +329,19 @@ var Slider = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
350
329
|
),
|
|
351
330
|
...props,
|
|
352
331
|
children: [
|
|
353
|
-
/* @__PURE__ */
|
|
354
|
-
/* @__PURE__ */
|
|
332
|
+
/* @__PURE__ */ jsx5(SliderPrimitive.Track, { className: "relative h-2 w-full grow overflow-hidden rounded-full bg-secondary", children: /* @__PURE__ */ jsx5(SliderPrimitive.Range, { className: "absolute h-full bg-primary" }) }),
|
|
333
|
+
/* @__PURE__ */ jsx5(SliderPrimitive.Thumb, { className: "block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50" })
|
|
355
334
|
]
|
|
356
335
|
}
|
|
357
336
|
));
|
|
358
337
|
Slider.displayName = SliderPrimitive.Root.displayName;
|
|
359
338
|
|
|
360
339
|
// src/components/ui/input.tsx
|
|
361
|
-
import * as
|
|
362
|
-
import { jsx as
|
|
363
|
-
var Input =
|
|
340
|
+
import * as React6 from "react";
|
|
341
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
342
|
+
var Input = React6.forwardRef(
|
|
364
343
|
({ className, type, ...props }, ref) => {
|
|
365
|
-
return /* @__PURE__ */
|
|
344
|
+
return /* @__PURE__ */ jsx6(
|
|
366
345
|
"input",
|
|
367
346
|
{
|
|
368
347
|
type,
|
|
@@ -379,13 +358,13 @@ var Input = React7.forwardRef(
|
|
|
379
358
|
Input.displayName = "Input";
|
|
380
359
|
|
|
381
360
|
// src/components/ui/select.tsx
|
|
382
|
-
import * as
|
|
361
|
+
import * as React7 from "react";
|
|
383
362
|
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
384
363
|
import { Check, ChevronDown, ChevronUp } from "lucide-react";
|
|
385
|
-
import { jsx as
|
|
364
|
+
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
386
365
|
var Select = SelectPrimitive.Root;
|
|
387
366
|
var SelectValue = SelectPrimitive.Value;
|
|
388
|
-
var SelectTrigger =
|
|
367
|
+
var SelectTrigger = React7.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs3(
|
|
389
368
|
SelectPrimitive.Trigger,
|
|
390
369
|
{
|
|
391
370
|
ref,
|
|
@@ -396,12 +375,12 @@ var SelectTrigger = React8.forwardRef(({ className, children, ...props }, ref) =
|
|
|
396
375
|
...props,
|
|
397
376
|
children: [
|
|
398
377
|
children,
|
|
399
|
-
/* @__PURE__ */
|
|
378
|
+
/* @__PURE__ */ jsx7(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx7(ChevronDown, { className: "h-4 w-4 opacity-50" }) })
|
|
400
379
|
]
|
|
401
380
|
}
|
|
402
381
|
));
|
|
403
382
|
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
404
|
-
var SelectScrollUpButton =
|
|
383
|
+
var SelectScrollUpButton = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx7(
|
|
405
384
|
SelectPrimitive.ScrollUpButton,
|
|
406
385
|
{
|
|
407
386
|
ref,
|
|
@@ -410,11 +389,11 @@ var SelectScrollUpButton = React8.forwardRef(({ className, ...props }, ref) => /
|
|
|
410
389
|
className
|
|
411
390
|
),
|
|
412
391
|
...props,
|
|
413
|
-
children: /* @__PURE__ */
|
|
392
|
+
children: /* @__PURE__ */ jsx7(ChevronUp, { className: "h-4 w-4" })
|
|
414
393
|
}
|
|
415
394
|
));
|
|
416
395
|
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
417
|
-
var SelectScrollDownButton =
|
|
396
|
+
var SelectScrollDownButton = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx7(
|
|
418
397
|
SelectPrimitive.ScrollDownButton,
|
|
419
398
|
{
|
|
420
399
|
ref,
|
|
@@ -423,11 +402,11 @@ var SelectScrollDownButton = React8.forwardRef(({ className, ...props }, ref) =>
|
|
|
423
402
|
className
|
|
424
403
|
),
|
|
425
404
|
...props,
|
|
426
|
-
children: /* @__PURE__ */
|
|
405
|
+
children: /* @__PURE__ */ jsx7(ChevronDown, { className: "h-4 w-4" })
|
|
427
406
|
}
|
|
428
407
|
));
|
|
429
408
|
SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
|
|
430
|
-
var SelectContent =
|
|
409
|
+
var SelectContent = React7.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsx7(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs3(
|
|
431
410
|
SelectPrimitive.Content,
|
|
432
411
|
{
|
|
433
412
|
ref,
|
|
@@ -439,8 +418,8 @@ var SelectContent = React8.forwardRef(({ className, children, position = "popper
|
|
|
439
418
|
position,
|
|
440
419
|
...props,
|
|
441
420
|
children: [
|
|
442
|
-
/* @__PURE__ */
|
|
443
|
-
/* @__PURE__ */
|
|
421
|
+
/* @__PURE__ */ jsx7(SelectScrollUpButton, {}),
|
|
422
|
+
/* @__PURE__ */ jsx7(
|
|
444
423
|
SelectPrimitive.Viewport,
|
|
445
424
|
{
|
|
446
425
|
className: cn(
|
|
@@ -450,12 +429,12 @@ var SelectContent = React8.forwardRef(({ className, children, position = "popper
|
|
|
450
429
|
children
|
|
451
430
|
}
|
|
452
431
|
),
|
|
453
|
-
/* @__PURE__ */
|
|
432
|
+
/* @__PURE__ */ jsx7(SelectScrollDownButton, {})
|
|
454
433
|
]
|
|
455
434
|
}
|
|
456
435
|
) }));
|
|
457
436
|
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
458
|
-
var SelectLabel =
|
|
437
|
+
var SelectLabel = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx7(
|
|
459
438
|
SelectPrimitive.Label,
|
|
460
439
|
{
|
|
461
440
|
ref,
|
|
@@ -464,7 +443,7 @@ var SelectLabel = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE
|
|
|
464
443
|
}
|
|
465
444
|
));
|
|
466
445
|
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
467
|
-
var SelectItem =
|
|
446
|
+
var SelectItem = React7.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs3(
|
|
468
447
|
SelectPrimitive.Item,
|
|
469
448
|
{
|
|
470
449
|
ref,
|
|
@@ -474,13 +453,13 @@ var SelectItem = React8.forwardRef(({ className, children, ...props }, ref) => /
|
|
|
474
453
|
),
|
|
475
454
|
...props,
|
|
476
455
|
children: [
|
|
477
|
-
/* @__PURE__ */
|
|
478
|
-
/* @__PURE__ */
|
|
456
|
+
/* @__PURE__ */ jsx7("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx7(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx7(Check, { className: "h-4 w-4" }) }) }),
|
|
457
|
+
/* @__PURE__ */ jsx7(SelectPrimitive.ItemText, { children })
|
|
479
458
|
]
|
|
480
459
|
}
|
|
481
460
|
));
|
|
482
461
|
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
483
|
-
var SelectSeparator =
|
|
462
|
+
var SelectSeparator = React7.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx7(
|
|
484
463
|
SelectPrimitive.Separator,
|
|
485
464
|
{
|
|
486
465
|
ref,
|
|
@@ -491,10 +470,10 @@ var SelectSeparator = React8.forwardRef(({ className, ...props }, ref) => /* @__
|
|
|
491
470
|
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
492
471
|
|
|
493
472
|
// src/components/ui/button.tsx
|
|
494
|
-
import * as
|
|
473
|
+
import * as React8 from "react";
|
|
495
474
|
import { Slot } from "@radix-ui/react-slot";
|
|
496
475
|
import { cva as cva2 } from "class-variance-authority";
|
|
497
|
-
import { jsx as
|
|
476
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
498
477
|
var buttonVariants = cva2(
|
|
499
478
|
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
500
479
|
{
|
|
@@ -520,10 +499,10 @@ var buttonVariants = cva2(
|
|
|
520
499
|
}
|
|
521
500
|
}
|
|
522
501
|
);
|
|
523
|
-
var Button =
|
|
502
|
+
var Button = React8.forwardRef(
|
|
524
503
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
525
504
|
const Comp = asChild ? Slot : "button";
|
|
526
|
-
return /* @__PURE__ */
|
|
505
|
+
return /* @__PURE__ */ jsx8(
|
|
527
506
|
Comp,
|
|
528
507
|
{
|
|
529
508
|
className: cn(buttonVariants({ variant, size, className })),
|
|
@@ -536,10 +515,10 @@ var Button = React9.forwardRef(
|
|
|
536
515
|
Button.displayName = "Button";
|
|
537
516
|
|
|
538
517
|
// src/components/ControlPanel/ControlPanel.tsx
|
|
539
|
-
import { Fragment, jsx as
|
|
518
|
+
import { Fragment, jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
540
519
|
var ControlPanel = () => {
|
|
541
520
|
const [copied, setCopied] = useState4(false);
|
|
542
|
-
const { leftPanelWidth, isDesktop, isHydrated
|
|
521
|
+
const { leftPanelWidth, isDesktop, isHydrated } = useResizableLayout();
|
|
543
522
|
const { schema, setValue, values, componentName, config } = useControlsContext();
|
|
544
523
|
const previewUrl = usePreviewUrl(values);
|
|
545
524
|
const normalControls = Object.entries(schema).filter(
|
|
@@ -548,7 +527,7 @@ var ControlPanel = () => {
|
|
|
548
527
|
const buttonControls = Object.entries(schema).filter(
|
|
549
528
|
([, control]) => control.type === "button" && !control.hidden
|
|
550
529
|
);
|
|
551
|
-
const
|
|
530
|
+
const jsx16 = useMemo2(() => {
|
|
552
531
|
if (!componentName) return "";
|
|
553
532
|
const props = Object.entries(values).map(([key, val]) => {
|
|
554
533
|
if (typeof val === "string") return `${key}="${val}"`;
|
|
@@ -557,7 +536,7 @@ var ControlPanel = () => {
|
|
|
557
536
|
}).join(" ");
|
|
558
537
|
return `<${componentName} ${props} />`;
|
|
559
538
|
}, [componentName, values]);
|
|
560
|
-
return /* @__PURE__ */
|
|
539
|
+
return /* @__PURE__ */ jsx9(
|
|
561
540
|
"div",
|
|
562
541
|
{
|
|
563
542
|
className: `order-2 md:order-1 w-full md:h-auto p-2 md:p-4 bg-stone-900 font-mono text-stone-300 transition-opacity duration-300 ${!isHydrated ? "opacity-0" : "opacity-100"}`,
|
|
@@ -577,7 +556,7 @@ var ControlPanel = () => {
|
|
|
577
556
|
} : {}
|
|
578
557
|
},
|
|
579
558
|
children: /* @__PURE__ */ jsxs4("div", { className: "mb-10 space-y-4 p-2 md:p-4 border border-stone-700 rounded-md", children: [
|
|
580
|
-
/* @__PURE__ */
|
|
559
|
+
/* @__PURE__ */ jsx9("div", { className: "space-y-1", children: /* @__PURE__ */ jsx9("h1", { className: "text-lg text-stone-100 font-bold", children: config?.mainLabel ?? "Controls" }) }),
|
|
581
560
|
/* @__PURE__ */ jsxs4("div", { className: "space-y-4 pt-2", children: [
|
|
582
561
|
normalControls.map(([key, control]) => {
|
|
583
562
|
const value = values[key];
|
|
@@ -588,7 +567,7 @@ var ControlPanel = () => {
|
|
|
588
567
|
{
|
|
589
568
|
className: "flex items-center space-x-4 border-t border-stone-700 pt-4",
|
|
590
569
|
children: [
|
|
591
|
-
/* @__PURE__ */
|
|
570
|
+
/* @__PURE__ */ jsx9(
|
|
592
571
|
Switch,
|
|
593
572
|
{
|
|
594
573
|
id: key,
|
|
@@ -597,19 +576,19 @@ var ControlPanel = () => {
|
|
|
597
576
|
className: "data-[state=checked]:bg-stone-700 data-[state=unchecked]:bg-stone-700/40"
|
|
598
577
|
}
|
|
599
578
|
),
|
|
600
|
-
/* @__PURE__ */
|
|
579
|
+
/* @__PURE__ */ jsx9(Label, { htmlFor: key, className: "cursor-pointer", children: key })
|
|
601
580
|
]
|
|
602
581
|
},
|
|
603
582
|
key
|
|
604
583
|
);
|
|
605
584
|
case "number":
|
|
606
585
|
return /* @__PURE__ */ jsxs4("div", { className: "space-y-2 w-full", children: [
|
|
607
|
-
/* @__PURE__ */
|
|
586
|
+
/* @__PURE__ */ jsx9("div", { className: "flex items-center justify-between pb-1", children: /* @__PURE__ */ jsxs4(Label, { className: "text-stone-300", htmlFor: key, children: [
|
|
608
587
|
key,
|
|
609
588
|
": ",
|
|
610
589
|
value
|
|
611
590
|
] }) }),
|
|
612
|
-
/* @__PURE__ */
|
|
591
|
+
/* @__PURE__ */ jsx9(
|
|
613
592
|
Slider,
|
|
614
593
|
{
|
|
615
594
|
id: key,
|
|
@@ -623,7 +602,7 @@ var ControlPanel = () => {
|
|
|
623
602
|
)
|
|
624
603
|
] }, key);
|
|
625
604
|
case "string":
|
|
626
|
-
return /* @__PURE__ */
|
|
605
|
+
return /* @__PURE__ */ jsx9(
|
|
627
606
|
Input,
|
|
628
607
|
{
|
|
629
608
|
id: key,
|
|
@@ -636,8 +615,8 @@ var ControlPanel = () => {
|
|
|
636
615
|
);
|
|
637
616
|
case "color":
|
|
638
617
|
return /* @__PURE__ */ jsxs4("div", { className: "space-y-2 w-full", children: [
|
|
639
|
-
/* @__PURE__ */
|
|
640
|
-
/* @__PURE__ */
|
|
618
|
+
/* @__PURE__ */ jsx9("div", { className: "flex items-center justify-between pb-1", children: /* @__PURE__ */ jsx9(Label, { className: "text-stone-300", htmlFor: key, children: key }) }),
|
|
619
|
+
/* @__PURE__ */ jsx9(
|
|
641
620
|
"input",
|
|
642
621
|
{
|
|
643
622
|
type: "color",
|
|
@@ -654,15 +633,15 @@ var ControlPanel = () => {
|
|
|
654
633
|
{
|
|
655
634
|
className: "space-y-2 border-t border-stone-700 pt-4",
|
|
656
635
|
children: [
|
|
657
|
-
/* @__PURE__ */
|
|
636
|
+
/* @__PURE__ */ jsx9(Label, { className: "text-stone-300", htmlFor: key, children: key }),
|
|
658
637
|
/* @__PURE__ */ jsxs4(
|
|
659
638
|
Select,
|
|
660
639
|
{
|
|
661
640
|
value,
|
|
662
641
|
onValueChange: (val) => setValue(key, val),
|
|
663
642
|
children: [
|
|
664
|
-
/* @__PURE__ */
|
|
665
|
-
/* @__PURE__ */
|
|
643
|
+
/* @__PURE__ */ jsx9(SelectTrigger, { children: /* @__PURE__ */ jsx9(SelectValue, { placeholder: "Select option" }) }),
|
|
644
|
+
/* @__PURE__ */ jsx9(SelectContent, { children: control.options.map((opt) => /* @__PURE__ */ jsx9(SelectItem, { value: opt, children: opt }, opt)) })
|
|
666
645
|
]
|
|
667
646
|
}
|
|
668
647
|
)
|
|
@@ -674,35 +653,35 @@ var ControlPanel = () => {
|
|
|
674
653
|
return null;
|
|
675
654
|
}
|
|
676
655
|
}),
|
|
677
|
-
(buttonControls.length > 0 ||
|
|
656
|
+
(buttonControls.length > 0 || jsx16) && /* @__PURE__ */ jsxs4(
|
|
678
657
|
"div",
|
|
679
658
|
{
|
|
680
659
|
className: `${normalControls.length > 0 ? "border-t" : ""} border-stone-700`,
|
|
681
660
|
children: [
|
|
682
|
-
|
|
661
|
+
jsx16 && config?.showCopyButton !== false && /* @__PURE__ */ jsx9("div", { className: "flex-1 pt-4", children: /* @__PURE__ */ jsx9(
|
|
683
662
|
"button",
|
|
684
663
|
{
|
|
685
664
|
onClick: () => {
|
|
686
|
-
navigator.clipboard.writeText(
|
|
665
|
+
navigator.clipboard.writeText(jsx16);
|
|
687
666
|
setCopied(true);
|
|
688
667
|
setTimeout(() => setCopied(false), 5e3);
|
|
689
668
|
},
|
|
690
669
|
className: "w-full px-4 py-2 text-sm bg-stone-700 hover:bg-stone-600 text-white rounded flex items-center justify-center gap-2",
|
|
691
670
|
children: copied ? /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
692
|
-
/* @__PURE__ */
|
|
671
|
+
/* @__PURE__ */ jsx9(Check2, { className: "w-4 h-4" }),
|
|
693
672
|
"Copied"
|
|
694
673
|
] }) : /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
695
|
-
/* @__PURE__ */
|
|
674
|
+
/* @__PURE__ */ jsx9(Copy, { className: "w-4 h-4" }),
|
|
696
675
|
"Copy to Clipboard"
|
|
697
676
|
] })
|
|
698
677
|
}
|
|
699
678
|
) }, "control-panel-jsx"),
|
|
700
|
-
buttonControls.length > 0 && /* @__PURE__ */
|
|
701
|
-
([key, control]) => control.type === "button" ? /* @__PURE__ */
|
|
679
|
+
buttonControls.length > 0 && /* @__PURE__ */ jsx9("div", { className: "flex flex-wrap gap-2 pt-4", children: buttonControls.map(
|
|
680
|
+
([key, control]) => control.type === "button" ? /* @__PURE__ */ jsx9(
|
|
702
681
|
"div",
|
|
703
682
|
{
|
|
704
683
|
className: "flex-1",
|
|
705
|
-
children: control.render ? control.render() : /* @__PURE__ */
|
|
684
|
+
children: control.render ? control.render() : /* @__PURE__ */ jsx9(
|
|
706
685
|
"button",
|
|
707
686
|
{
|
|
708
687
|
onClick: control.onClick,
|
|
@@ -718,7 +697,7 @@ var ControlPanel = () => {
|
|
|
718
697
|
}
|
|
719
698
|
)
|
|
720
699
|
] }),
|
|
721
|
-
previewUrl && /* @__PURE__ */
|
|
700
|
+
previewUrl && /* @__PURE__ */ jsx9(Button, { asChild: true, children: /* @__PURE__ */ jsxs4(
|
|
722
701
|
"a",
|
|
723
702
|
{
|
|
724
703
|
href: previewUrl,
|
|
@@ -726,7 +705,7 @@ var ControlPanel = () => {
|
|
|
726
705
|
rel: "noopener noreferrer",
|
|
727
706
|
className: "w-full px-4 py-2 text-sm text-center bg-stone-800 hover:bg-stone-700 text-white rounded",
|
|
728
707
|
children: [
|
|
729
|
-
/* @__PURE__ */
|
|
708
|
+
/* @__PURE__ */ jsx9(SquareArrowOutUpRight, {}),
|
|
730
709
|
" Open in a New Tab"
|
|
731
710
|
]
|
|
732
711
|
}
|
|
@@ -737,8 +716,55 @@ var ControlPanel = () => {
|
|
|
737
716
|
};
|
|
738
717
|
var ControlPanel_default = ControlPanel;
|
|
739
718
|
|
|
740
|
-
// src/components/
|
|
719
|
+
// src/components/PreviewContainer/PreviewContainer.tsx
|
|
720
|
+
import { useRef as useRef2 } from "react";
|
|
721
|
+
|
|
722
|
+
// src/components/Grid/Grid.tsx
|
|
723
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
724
|
+
function Grid() {
|
|
725
|
+
return /* @__PURE__ */ jsx10(
|
|
726
|
+
"div",
|
|
727
|
+
{
|
|
728
|
+
className: "absolute inset-0 w-screen h-screen z-[0] blur-[1px]",
|
|
729
|
+
style: {
|
|
730
|
+
backgroundImage: `
|
|
731
|
+
linear-gradient(to right,rgb(13, 13, 13) 1px, transparent 1px),
|
|
732
|
+
linear-gradient(to bottom,rgb(13, 13, 13) 1px, transparent 1px)
|
|
733
|
+
`,
|
|
734
|
+
backgroundSize: "1rem 1rem",
|
|
735
|
+
backgroundPosition: "center"
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
);
|
|
739
|
+
}
|
|
740
|
+
var Grid_default = Grid;
|
|
741
|
+
|
|
742
|
+
// src/components/PreviewContainer/PreviewContainer.tsx
|
|
741
743
|
import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
744
|
+
var PreviewContainer = ({ children, hideControls }) => {
|
|
745
|
+
const { config } = useControlsContext();
|
|
746
|
+
const { leftPanelWidth, isDesktop, isHydrated, containerRef } = useResizableLayout();
|
|
747
|
+
const previewRef = useRef2(null);
|
|
748
|
+
return /* @__PURE__ */ jsx11(
|
|
749
|
+
"div",
|
|
750
|
+
{
|
|
751
|
+
ref: previewRef,
|
|
752
|
+
className: "order-1 md:order-2 flex-1 bg-black overflow-auto flex items-center justify-center relative",
|
|
753
|
+
style: isHydrated && isDesktop && !hideControls ? {
|
|
754
|
+
width: `${100 - leftPanelWidth}%`,
|
|
755
|
+
marginLeft: `${leftPanelWidth}%`
|
|
756
|
+
} : {},
|
|
757
|
+
children: /* @__PURE__ */ jsxs5("div", { className: "w-screen h-screen", children: [
|
|
758
|
+
config?.showGrid && /* @__PURE__ */ jsx11(Grid_default, {}),
|
|
759
|
+
/* @__PURE__ */ jsx11("div", { className: "w-screen h-screen flex items-center justify-center relative", children })
|
|
760
|
+
] })
|
|
761
|
+
}
|
|
762
|
+
);
|
|
763
|
+
};
|
|
764
|
+
var PreviewContainer_default = PreviewContainer;
|
|
765
|
+
|
|
766
|
+
// src/components/Playground/Playground.tsx
|
|
767
|
+
import { jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
742
768
|
var NO_CONTROLS_PARAM = "nocontrols";
|
|
743
769
|
function Playground({ children }) {
|
|
744
770
|
const [isHydrated, setIsHydrated] = useState5(false);
|
|
@@ -756,20 +782,20 @@ function Playground({ children }) {
|
|
|
756
782
|
setTimeout(() => setCopied(false), 2e3);
|
|
757
783
|
};
|
|
758
784
|
if (!isHydrated) return null;
|
|
759
|
-
return /* @__PURE__ */
|
|
760
|
-
hideControls && /* @__PURE__ */
|
|
785
|
+
return /* @__PURE__ */ jsx12(ResizableLayout, { hideControls, children: /* @__PURE__ */ jsxs6(ControlsProvider, { children: [
|
|
786
|
+
hideControls && /* @__PURE__ */ jsxs6(
|
|
761
787
|
"button",
|
|
762
788
|
{
|
|
763
789
|
onClick: handleCopy,
|
|
764
790
|
className: "absolute top-4 right-4 z-50 flex items-center gap-1 rounded bg-black/70 px-3 py-1 text-white hover:bg-black",
|
|
765
791
|
children: [
|
|
766
|
-
copied ? /* @__PURE__ */
|
|
792
|
+
copied ? /* @__PURE__ */ jsx12(Check3, { size: 16 }) : /* @__PURE__ */ jsx12(Copy2, { size: 16 }),
|
|
767
793
|
copied ? "Copied!" : "Share"
|
|
768
794
|
]
|
|
769
795
|
}
|
|
770
796
|
),
|
|
771
|
-
/* @__PURE__ */
|
|
772
|
-
!hideControls && /* @__PURE__ */
|
|
797
|
+
/* @__PURE__ */ jsx12(PreviewContainer_default, { hideControls, children }),
|
|
798
|
+
!hideControls && /* @__PURE__ */ jsx12(ControlPanel_default, {})
|
|
773
799
|
] }) });
|
|
774
800
|
}
|
|
775
801
|
|
|
@@ -783,7 +809,7 @@ import { useRef as useRef3, useEffect as useEffect5 } from "react";
|
|
|
783
809
|
import { OrbitControls } from "@react-three/drei";
|
|
784
810
|
import { useThree } from "@react-three/fiber";
|
|
785
811
|
import { debounce } from "lodash";
|
|
786
|
-
import { jsx as
|
|
812
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
787
813
|
function CameraLogger() {
|
|
788
814
|
const { camera } = useThree();
|
|
789
815
|
const controlsRef = useRef3(null);
|
|
@@ -800,11 +826,11 @@ function CameraLogger() {
|
|
|
800
826
|
controls.addEventListener("change", handler);
|
|
801
827
|
return () => controls.removeEventListener("change", handler);
|
|
802
828
|
}, []);
|
|
803
|
-
return /* @__PURE__ */
|
|
829
|
+
return /* @__PURE__ */ jsx13(OrbitControls, { ref: controlsRef });
|
|
804
830
|
}
|
|
805
831
|
|
|
806
832
|
// src/components/Canvas/Canvas.tsx
|
|
807
|
-
import { jsx as
|
|
833
|
+
import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
808
834
|
var ResponsiveCamera = ({
|
|
809
835
|
height,
|
|
810
836
|
width
|
|
@@ -845,28 +871,28 @@ var Canvas = ({ mediaProps, children }) => {
|
|
|
845
871
|
...mediaProps || {},
|
|
846
872
|
size: mediaProps?.size || { width: 400, height: 400 }
|
|
847
873
|
};
|
|
848
|
-
return /* @__PURE__ */
|
|
874
|
+
return /* @__PURE__ */ jsx14(
|
|
849
875
|
"div",
|
|
850
876
|
{
|
|
851
877
|
ref: canvasRef,
|
|
852
878
|
className: "w-full h-full pointer-events-none relative touch-none",
|
|
853
|
-
children: /* @__PURE__ */
|
|
879
|
+
children: /* @__PURE__ */ jsxs7(
|
|
854
880
|
ThreeCanvas,
|
|
855
881
|
{
|
|
856
882
|
resize: { polyfill: ResizeObserver },
|
|
857
883
|
style: { width: parentSize?.width, height: parentSize?.height },
|
|
858
884
|
gl: { preserveDrawingBuffer: true },
|
|
859
885
|
children: [
|
|
860
|
-
parentSize?.height && parentSize?.width && /* @__PURE__ */
|
|
886
|
+
parentSize?.height && parentSize?.width && /* @__PURE__ */ jsx14(
|
|
861
887
|
ResponsiveCamera,
|
|
862
888
|
{
|
|
863
889
|
height: parentSize.height,
|
|
864
890
|
width: parentSize.width
|
|
865
891
|
}
|
|
866
892
|
),
|
|
867
|
-
mediaProps?.debugOrbit && /* @__PURE__ */
|
|
868
|
-
/* @__PURE__ */
|
|
869
|
-
/* @__PURE__ */
|
|
893
|
+
mediaProps?.debugOrbit && /* @__PURE__ */ jsx14(CameraLogger, {}),
|
|
894
|
+
/* @__PURE__ */ jsx14("ambientLight", { intensity: 1 }),
|
|
895
|
+
/* @__PURE__ */ jsx14("pointLight", { position: [10, 10, 10] }),
|
|
870
896
|
React11.cloneElement(children, mergedMediaProps)
|
|
871
897
|
]
|
|
872
898
|
}
|
|
@@ -877,12 +903,12 @@ var Canvas = ({ mediaProps, children }) => {
|
|
|
877
903
|
var Canvas_default = Canvas;
|
|
878
904
|
|
|
879
905
|
// src/components/PlaygroundCanvas/PlaygroundCanvas.tsx
|
|
880
|
-
import { jsx as
|
|
906
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
881
907
|
var PlaygroundCanvas = ({
|
|
882
908
|
children,
|
|
883
909
|
mediaProps
|
|
884
910
|
}) => {
|
|
885
|
-
return /* @__PURE__ */
|
|
911
|
+
return /* @__PURE__ */ jsx15(Playground, { children: /* @__PURE__ */ jsx15(Canvas_default, { mediaProps, children }) });
|
|
886
912
|
};
|
|
887
913
|
var PlaygroundCanvas_default = PlaygroundCanvas;
|
|
888
914
|
export {
|