@toriistudio/v0-playground 0.3.1 → 0.5.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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +144 -116
- package/dist/index.mjs +130 -102
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -59,7 +59,7 @@ type ControlType = ({
|
|
|
59
59
|
} & BaseControl) | ({
|
|
60
60
|
type: "select";
|
|
61
61
|
value: string;
|
|
62
|
-
options: string
|
|
62
|
+
options: Record<string, any>;
|
|
63
63
|
} & BaseControl) | ({
|
|
64
64
|
type: "button";
|
|
65
65
|
onClick?: () => void;
|
|
@@ -70,6 +70,7 @@ type ControlsSchema = Record<string, ControlType>;
|
|
|
70
70
|
type ControlsConfig = {
|
|
71
71
|
showCopyButton?: boolean;
|
|
72
72
|
mainLabel?: string;
|
|
73
|
+
showGrid?: boolean;
|
|
73
74
|
};
|
|
74
75
|
declare const ControlsProvider: ({ children }: {
|
|
75
76
|
children: ReactNode;
|
package/dist/index.d.ts
CHANGED
|
@@ -59,7 +59,7 @@ type ControlType = ({
|
|
|
59
59
|
} & BaseControl) | ({
|
|
60
60
|
type: "select";
|
|
61
61
|
value: string;
|
|
62
|
-
options: string
|
|
62
|
+
options: Record<string, any>;
|
|
63
63
|
} & BaseControl) | ({
|
|
64
64
|
type: "button";
|
|
65
65
|
onClick?: () => void;
|
|
@@ -70,6 +70,7 @@ type ControlsSchema = Record<string, ControlType>;
|
|
|
70
70
|
type ControlsConfig = {
|
|
71
71
|
showCopyButton?: boolean;
|
|
72
72
|
mainLabel?: string;
|
|
73
|
+
showGrid?: boolean;
|
|
73
74
|
};
|
|
74
75
|
declare const ControlsProvider: ({ children }: {
|
|
75
76
|
children: ReactNode;
|
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: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "w-screen h-screen flex items-center justify-center", 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,22 @@ 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: Object.entries(control.options).map(
|
|
675
|
+
([label, _val]) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SelectItem, { value: label, children: label }, label)
|
|
676
|
+
) })
|
|
696
677
|
]
|
|
697
678
|
}
|
|
698
679
|
)
|
|
@@ -704,35 +685,35 @@ var ControlPanel = () => {
|
|
|
704
685
|
return null;
|
|
705
686
|
}
|
|
706
687
|
}),
|
|
707
|
-
(buttonControls.length > 0 ||
|
|
688
|
+
(buttonControls.length > 0 || jsx16) && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
708
689
|
"div",
|
|
709
690
|
{
|
|
710
691
|
className: `${normalControls.length > 0 ? "border-t" : ""} border-stone-700`,
|
|
711
692
|
children: [
|
|
712
|
-
|
|
693
|
+
jsx16 && config?.showCopyButton !== false && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex-1 pt-4", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
713
694
|
"button",
|
|
714
695
|
{
|
|
715
696
|
onClick: () => {
|
|
716
|
-
navigator.clipboard.writeText(
|
|
697
|
+
navigator.clipboard.writeText(jsx16);
|
|
717
698
|
setCopied(true);
|
|
718
699
|
setTimeout(() => setCopied(false), 5e3);
|
|
719
700
|
},
|
|
720
701
|
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,
|
|
702
|
+
children: copied ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
703
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react3.Check, { className: "w-4 h-4" }),
|
|
723
704
|
"Copied"
|
|
724
|
-
] }) : /* @__PURE__ */ (0,
|
|
725
|
-
/* @__PURE__ */ (0,
|
|
705
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
706
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react3.Copy, { className: "w-4 h-4" }),
|
|
726
707
|
"Copy to Clipboard"
|
|
727
708
|
] })
|
|
728
709
|
}
|
|
729
710
|
) }, "control-panel-jsx"),
|
|
730
|
-
buttonControls.length > 0 && /* @__PURE__ */ (0,
|
|
731
|
-
([key, control]) => control.type === "button" ? /* @__PURE__ */ (0,
|
|
711
|
+
buttonControls.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex flex-wrap gap-2 pt-4", children: buttonControls.map(
|
|
712
|
+
([key, control]) => control.type === "button" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
732
713
|
"div",
|
|
733
714
|
{
|
|
734
715
|
className: "flex-1",
|
|
735
|
-
children: control.render ? control.render() : /* @__PURE__ */ (0,
|
|
716
|
+
children: control.render ? control.render() : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
736
717
|
"button",
|
|
737
718
|
{
|
|
738
719
|
onClick: control.onClick,
|
|
@@ -748,7 +729,7 @@ var ControlPanel = () => {
|
|
|
748
729
|
}
|
|
749
730
|
)
|
|
750
731
|
] }),
|
|
751
|
-
previewUrl && /* @__PURE__ */ (0,
|
|
732
|
+
previewUrl && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Button, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
752
733
|
"a",
|
|
753
734
|
{
|
|
754
735
|
href: previewUrl,
|
|
@@ -756,7 +737,7 @@ var ControlPanel = () => {
|
|
|
756
737
|
rel: "noopener noreferrer",
|
|
757
738
|
className: "w-full px-4 py-2 text-sm text-center bg-stone-800 hover:bg-stone-700 text-white rounded",
|
|
758
739
|
children: [
|
|
759
|
-
/* @__PURE__ */ (0,
|
|
740
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react3.SquareArrowOutUpRight, {}),
|
|
760
741
|
" Open in a New Tab"
|
|
761
742
|
]
|
|
762
743
|
}
|
|
@@ -767,8 +748,55 @@ var ControlPanel = () => {
|
|
|
767
748
|
};
|
|
768
749
|
var ControlPanel_default = ControlPanel;
|
|
769
750
|
|
|
770
|
-
// src/components/
|
|
751
|
+
// src/components/PreviewContainer/PreviewContainer.tsx
|
|
752
|
+
var import_react5 = require("react");
|
|
753
|
+
|
|
754
|
+
// src/components/Grid/Grid.tsx
|
|
755
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
756
|
+
function Grid() {
|
|
757
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
758
|
+
"div",
|
|
759
|
+
{
|
|
760
|
+
className: "absolute inset-0 w-screen h-screen z-[0] blur-[1px]",
|
|
761
|
+
style: {
|
|
762
|
+
backgroundImage: `
|
|
763
|
+
linear-gradient(to right,rgb(13, 13, 13) 1px, transparent 1px),
|
|
764
|
+
linear-gradient(to bottom,rgb(13, 13, 13) 1px, transparent 1px)
|
|
765
|
+
`,
|
|
766
|
+
backgroundSize: "1rem 1rem",
|
|
767
|
+
backgroundPosition: "center"
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
);
|
|
771
|
+
}
|
|
772
|
+
var Grid_default = Grid;
|
|
773
|
+
|
|
774
|
+
// src/components/PreviewContainer/PreviewContainer.tsx
|
|
771
775
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
776
|
+
var PreviewContainer = ({ children, hideControls }) => {
|
|
777
|
+
const { config } = useControlsContext();
|
|
778
|
+
const { leftPanelWidth, isDesktop, isHydrated, containerRef } = useResizableLayout();
|
|
779
|
+
const previewRef = (0, import_react5.useRef)(null);
|
|
780
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
781
|
+
"div",
|
|
782
|
+
{
|
|
783
|
+
ref: previewRef,
|
|
784
|
+
className: "order-1 md:order-2 flex-1 bg-black overflow-auto flex items-center justify-center relative",
|
|
785
|
+
style: isHydrated && isDesktop && !hideControls ? {
|
|
786
|
+
width: `${100 - leftPanelWidth}%`,
|
|
787
|
+
marginLeft: `${leftPanelWidth}%`
|
|
788
|
+
} : {},
|
|
789
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "w-screen h-screen", children: [
|
|
790
|
+
config?.showGrid && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Grid_default, {}),
|
|
791
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "w-screen h-screen flex items-center justify-center relative", children })
|
|
792
|
+
] })
|
|
793
|
+
}
|
|
794
|
+
);
|
|
795
|
+
};
|
|
796
|
+
var PreviewContainer_default = PreviewContainer;
|
|
797
|
+
|
|
798
|
+
// src/components/Playground/Playground.tsx
|
|
799
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
772
800
|
var NO_CONTROLS_PARAM = "nocontrols";
|
|
773
801
|
function Playground({ children }) {
|
|
774
802
|
const [isHydrated, setIsHydrated] = (0, import_react6.useState)(false);
|
|
@@ -786,20 +814,20 @@ function Playground({ children }) {
|
|
|
786
814
|
setTimeout(() => setCopied(false), 2e3);
|
|
787
815
|
};
|
|
788
816
|
if (!isHydrated) return null;
|
|
789
|
-
return /* @__PURE__ */ (0,
|
|
790
|
-
hideControls && /* @__PURE__ */ (0,
|
|
817
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ResizableLayout, { hideControls, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(ControlsProvider, { children: [
|
|
818
|
+
hideControls && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
791
819
|
"button",
|
|
792
820
|
{
|
|
793
821
|
onClick: handleCopy,
|
|
794
822
|
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
823
|
children: [
|
|
796
|
-
copied ? /* @__PURE__ */ (0,
|
|
824
|
+
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
825
|
copied ? "Copied!" : "Share"
|
|
798
826
|
]
|
|
799
827
|
}
|
|
800
828
|
),
|
|
801
|
-
/* @__PURE__ */ (0,
|
|
802
|
-
!hideControls && /* @__PURE__ */ (0,
|
|
829
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(PreviewContainer_default, { hideControls, children }),
|
|
830
|
+
!hideControls && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ControlPanel_default, {})
|
|
803
831
|
] }) });
|
|
804
832
|
}
|
|
805
833
|
|
|
@@ -813,7 +841,7 @@ var import_react7 = require("react");
|
|
|
813
841
|
var import_drei = require("@react-three/drei");
|
|
814
842
|
var import_fiber = require("@react-three/fiber");
|
|
815
843
|
var import_lodash = require("lodash");
|
|
816
|
-
var
|
|
844
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
817
845
|
function CameraLogger() {
|
|
818
846
|
const { camera } = (0, import_fiber.useThree)();
|
|
819
847
|
const controlsRef = (0, import_react7.useRef)(null);
|
|
@@ -830,11 +858,11 @@ function CameraLogger() {
|
|
|
830
858
|
controls.addEventListener("change", handler);
|
|
831
859
|
return () => controls.removeEventListener("change", handler);
|
|
832
860
|
}, []);
|
|
833
|
-
return /* @__PURE__ */ (0,
|
|
861
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_drei.OrbitControls, { ref: controlsRef });
|
|
834
862
|
}
|
|
835
863
|
|
|
836
864
|
// src/components/Canvas/Canvas.tsx
|
|
837
|
-
var
|
|
865
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
838
866
|
var ResponsiveCamera = ({
|
|
839
867
|
height,
|
|
840
868
|
width
|
|
@@ -875,28 +903,28 @@ var Canvas = ({ mediaProps, children }) => {
|
|
|
875
903
|
...mediaProps || {},
|
|
876
904
|
size: mediaProps?.size || { width: 400, height: 400 }
|
|
877
905
|
};
|
|
878
|
-
return /* @__PURE__ */ (0,
|
|
906
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
879
907
|
"div",
|
|
880
908
|
{
|
|
881
909
|
ref: canvasRef,
|
|
882
910
|
className: "w-full h-full pointer-events-none relative touch-none",
|
|
883
|
-
children: /* @__PURE__ */ (0,
|
|
911
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
884
912
|
import_fiber2.Canvas,
|
|
885
913
|
{
|
|
886
914
|
resize: { polyfill: ResizeObserver },
|
|
887
915
|
style: { width: parentSize?.width, height: parentSize?.height },
|
|
888
916
|
gl: { preserveDrawingBuffer: true },
|
|
889
917
|
children: [
|
|
890
|
-
parentSize?.height && parentSize?.width && /* @__PURE__ */ (0,
|
|
918
|
+
parentSize?.height && parentSize?.width && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
891
919
|
ResponsiveCamera,
|
|
892
920
|
{
|
|
893
921
|
height: parentSize.height,
|
|
894
922
|
width: parentSize.width
|
|
895
923
|
}
|
|
896
924
|
),
|
|
897
|
-
mediaProps?.debugOrbit && /* @__PURE__ */ (0,
|
|
898
|
-
/* @__PURE__ */ (0,
|
|
899
|
-
/* @__PURE__ */ (0,
|
|
925
|
+
mediaProps?.debugOrbit && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CameraLogger, {}),
|
|
926
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("ambientLight", { intensity: 1 }),
|
|
927
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("pointLight", { position: [10, 10, 10] }),
|
|
900
928
|
import_react8.default.cloneElement(children, mergedMediaProps)
|
|
901
929
|
]
|
|
902
930
|
}
|
|
@@ -907,12 +935,12 @@ var Canvas = ({ mediaProps, children }) => {
|
|
|
907
935
|
var Canvas_default = Canvas;
|
|
908
936
|
|
|
909
937
|
// src/components/PlaygroundCanvas/PlaygroundCanvas.tsx
|
|
910
|
-
var
|
|
938
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
911
939
|
var PlaygroundCanvas = ({
|
|
912
940
|
children,
|
|
913
941
|
mediaProps
|
|
914
942
|
}) => {
|
|
915
|
-
return /* @__PURE__ */ (0,
|
|
943
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Playground, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Canvas_default, { mediaProps, children }) });
|
|
916
944
|
};
|
|
917
945
|
var PlaygroundCanvas_default = PlaygroundCanvas;
|
|
918
946
|
// 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: /* @__PURE__ */ jsx3("div", { className: "w-screen h-screen flex items-center justify-center", 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,17 @@ 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: Object.entries(control.options).map(
|
|
645
|
+
([label, _val]) => /* @__PURE__ */ jsx9(SelectItem, { value: label, children: label }, label)
|
|
646
|
+
) })
|
|
666
647
|
]
|
|
667
648
|
}
|
|
668
649
|
)
|
|
@@ -674,35 +655,35 @@ var ControlPanel = () => {
|
|
|
674
655
|
return null;
|
|
675
656
|
}
|
|
676
657
|
}),
|
|
677
|
-
(buttonControls.length > 0 ||
|
|
658
|
+
(buttonControls.length > 0 || jsx16) && /* @__PURE__ */ jsxs4(
|
|
678
659
|
"div",
|
|
679
660
|
{
|
|
680
661
|
className: `${normalControls.length > 0 ? "border-t" : ""} border-stone-700`,
|
|
681
662
|
children: [
|
|
682
|
-
|
|
663
|
+
jsx16 && config?.showCopyButton !== false && /* @__PURE__ */ jsx9("div", { className: "flex-1 pt-4", children: /* @__PURE__ */ jsx9(
|
|
683
664
|
"button",
|
|
684
665
|
{
|
|
685
666
|
onClick: () => {
|
|
686
|
-
navigator.clipboard.writeText(
|
|
667
|
+
navigator.clipboard.writeText(jsx16);
|
|
687
668
|
setCopied(true);
|
|
688
669
|
setTimeout(() => setCopied(false), 5e3);
|
|
689
670
|
},
|
|
690
671
|
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
672
|
children: copied ? /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
692
|
-
/* @__PURE__ */
|
|
673
|
+
/* @__PURE__ */ jsx9(Check2, { className: "w-4 h-4" }),
|
|
693
674
|
"Copied"
|
|
694
675
|
] }) : /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
695
|
-
/* @__PURE__ */
|
|
676
|
+
/* @__PURE__ */ jsx9(Copy, { className: "w-4 h-4" }),
|
|
696
677
|
"Copy to Clipboard"
|
|
697
678
|
] })
|
|
698
679
|
}
|
|
699
680
|
) }, "control-panel-jsx"),
|
|
700
|
-
buttonControls.length > 0 && /* @__PURE__ */
|
|
701
|
-
([key, control]) => control.type === "button" ? /* @__PURE__ */
|
|
681
|
+
buttonControls.length > 0 && /* @__PURE__ */ jsx9("div", { className: "flex flex-wrap gap-2 pt-4", children: buttonControls.map(
|
|
682
|
+
([key, control]) => control.type === "button" ? /* @__PURE__ */ jsx9(
|
|
702
683
|
"div",
|
|
703
684
|
{
|
|
704
685
|
className: "flex-1",
|
|
705
|
-
children: control.render ? control.render() : /* @__PURE__ */
|
|
686
|
+
children: control.render ? control.render() : /* @__PURE__ */ jsx9(
|
|
706
687
|
"button",
|
|
707
688
|
{
|
|
708
689
|
onClick: control.onClick,
|
|
@@ -718,7 +699,7 @@ var ControlPanel = () => {
|
|
|
718
699
|
}
|
|
719
700
|
)
|
|
720
701
|
] }),
|
|
721
|
-
previewUrl && /* @__PURE__ */
|
|
702
|
+
previewUrl && /* @__PURE__ */ jsx9(Button, { asChild: true, children: /* @__PURE__ */ jsxs4(
|
|
722
703
|
"a",
|
|
723
704
|
{
|
|
724
705
|
href: previewUrl,
|
|
@@ -726,7 +707,7 @@ var ControlPanel = () => {
|
|
|
726
707
|
rel: "noopener noreferrer",
|
|
727
708
|
className: "w-full px-4 py-2 text-sm text-center bg-stone-800 hover:bg-stone-700 text-white rounded",
|
|
728
709
|
children: [
|
|
729
|
-
/* @__PURE__ */
|
|
710
|
+
/* @__PURE__ */ jsx9(SquareArrowOutUpRight, {}),
|
|
730
711
|
" Open in a New Tab"
|
|
731
712
|
]
|
|
732
713
|
}
|
|
@@ -737,8 +718,55 @@ var ControlPanel = () => {
|
|
|
737
718
|
};
|
|
738
719
|
var ControlPanel_default = ControlPanel;
|
|
739
720
|
|
|
740
|
-
// src/components/
|
|
721
|
+
// src/components/PreviewContainer/PreviewContainer.tsx
|
|
722
|
+
import { useRef as useRef2 } from "react";
|
|
723
|
+
|
|
724
|
+
// src/components/Grid/Grid.tsx
|
|
725
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
726
|
+
function Grid() {
|
|
727
|
+
return /* @__PURE__ */ jsx10(
|
|
728
|
+
"div",
|
|
729
|
+
{
|
|
730
|
+
className: "absolute inset-0 w-screen h-screen z-[0] blur-[1px]",
|
|
731
|
+
style: {
|
|
732
|
+
backgroundImage: `
|
|
733
|
+
linear-gradient(to right,rgb(13, 13, 13) 1px, transparent 1px),
|
|
734
|
+
linear-gradient(to bottom,rgb(13, 13, 13) 1px, transparent 1px)
|
|
735
|
+
`,
|
|
736
|
+
backgroundSize: "1rem 1rem",
|
|
737
|
+
backgroundPosition: "center"
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
);
|
|
741
|
+
}
|
|
742
|
+
var Grid_default = Grid;
|
|
743
|
+
|
|
744
|
+
// src/components/PreviewContainer/PreviewContainer.tsx
|
|
741
745
|
import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
746
|
+
var PreviewContainer = ({ children, hideControls }) => {
|
|
747
|
+
const { config } = useControlsContext();
|
|
748
|
+
const { leftPanelWidth, isDesktop, isHydrated, containerRef } = useResizableLayout();
|
|
749
|
+
const previewRef = useRef2(null);
|
|
750
|
+
return /* @__PURE__ */ jsx11(
|
|
751
|
+
"div",
|
|
752
|
+
{
|
|
753
|
+
ref: previewRef,
|
|
754
|
+
className: "order-1 md:order-2 flex-1 bg-black overflow-auto flex items-center justify-center relative",
|
|
755
|
+
style: isHydrated && isDesktop && !hideControls ? {
|
|
756
|
+
width: `${100 - leftPanelWidth}%`,
|
|
757
|
+
marginLeft: `${leftPanelWidth}%`
|
|
758
|
+
} : {},
|
|
759
|
+
children: /* @__PURE__ */ jsxs5("div", { className: "w-screen h-screen", children: [
|
|
760
|
+
config?.showGrid && /* @__PURE__ */ jsx11(Grid_default, {}),
|
|
761
|
+
/* @__PURE__ */ jsx11("div", { className: "w-screen h-screen flex items-center justify-center relative", children })
|
|
762
|
+
] })
|
|
763
|
+
}
|
|
764
|
+
);
|
|
765
|
+
};
|
|
766
|
+
var PreviewContainer_default = PreviewContainer;
|
|
767
|
+
|
|
768
|
+
// src/components/Playground/Playground.tsx
|
|
769
|
+
import { jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
742
770
|
var NO_CONTROLS_PARAM = "nocontrols";
|
|
743
771
|
function Playground({ children }) {
|
|
744
772
|
const [isHydrated, setIsHydrated] = useState5(false);
|
|
@@ -756,20 +784,20 @@ function Playground({ children }) {
|
|
|
756
784
|
setTimeout(() => setCopied(false), 2e3);
|
|
757
785
|
};
|
|
758
786
|
if (!isHydrated) return null;
|
|
759
|
-
return /* @__PURE__ */
|
|
760
|
-
hideControls && /* @__PURE__ */
|
|
787
|
+
return /* @__PURE__ */ jsx12(ResizableLayout, { hideControls, children: /* @__PURE__ */ jsxs6(ControlsProvider, { children: [
|
|
788
|
+
hideControls && /* @__PURE__ */ jsxs6(
|
|
761
789
|
"button",
|
|
762
790
|
{
|
|
763
791
|
onClick: handleCopy,
|
|
764
792
|
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
793
|
children: [
|
|
766
|
-
copied ? /* @__PURE__ */
|
|
794
|
+
copied ? /* @__PURE__ */ jsx12(Check3, { size: 16 }) : /* @__PURE__ */ jsx12(Copy2, { size: 16 }),
|
|
767
795
|
copied ? "Copied!" : "Share"
|
|
768
796
|
]
|
|
769
797
|
}
|
|
770
798
|
),
|
|
771
|
-
/* @__PURE__ */
|
|
772
|
-
!hideControls && /* @__PURE__ */
|
|
799
|
+
/* @__PURE__ */ jsx12(PreviewContainer_default, { hideControls, children }),
|
|
800
|
+
!hideControls && /* @__PURE__ */ jsx12(ControlPanel_default, {})
|
|
773
801
|
] }) });
|
|
774
802
|
}
|
|
775
803
|
|
|
@@ -783,7 +811,7 @@ import { useRef as useRef3, useEffect as useEffect5 } from "react";
|
|
|
783
811
|
import { OrbitControls } from "@react-three/drei";
|
|
784
812
|
import { useThree } from "@react-three/fiber";
|
|
785
813
|
import { debounce } from "lodash";
|
|
786
|
-
import { jsx as
|
|
814
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
787
815
|
function CameraLogger() {
|
|
788
816
|
const { camera } = useThree();
|
|
789
817
|
const controlsRef = useRef3(null);
|
|
@@ -800,11 +828,11 @@ function CameraLogger() {
|
|
|
800
828
|
controls.addEventListener("change", handler);
|
|
801
829
|
return () => controls.removeEventListener("change", handler);
|
|
802
830
|
}, []);
|
|
803
|
-
return /* @__PURE__ */
|
|
831
|
+
return /* @__PURE__ */ jsx13(OrbitControls, { ref: controlsRef });
|
|
804
832
|
}
|
|
805
833
|
|
|
806
834
|
// src/components/Canvas/Canvas.tsx
|
|
807
|
-
import { jsx as
|
|
835
|
+
import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
808
836
|
var ResponsiveCamera = ({
|
|
809
837
|
height,
|
|
810
838
|
width
|
|
@@ -845,28 +873,28 @@ var Canvas = ({ mediaProps, children }) => {
|
|
|
845
873
|
...mediaProps || {},
|
|
846
874
|
size: mediaProps?.size || { width: 400, height: 400 }
|
|
847
875
|
};
|
|
848
|
-
return /* @__PURE__ */
|
|
876
|
+
return /* @__PURE__ */ jsx14(
|
|
849
877
|
"div",
|
|
850
878
|
{
|
|
851
879
|
ref: canvasRef,
|
|
852
880
|
className: "w-full h-full pointer-events-none relative touch-none",
|
|
853
|
-
children: /* @__PURE__ */
|
|
881
|
+
children: /* @__PURE__ */ jsxs7(
|
|
854
882
|
ThreeCanvas,
|
|
855
883
|
{
|
|
856
884
|
resize: { polyfill: ResizeObserver },
|
|
857
885
|
style: { width: parentSize?.width, height: parentSize?.height },
|
|
858
886
|
gl: { preserveDrawingBuffer: true },
|
|
859
887
|
children: [
|
|
860
|
-
parentSize?.height && parentSize?.width && /* @__PURE__ */
|
|
888
|
+
parentSize?.height && parentSize?.width && /* @__PURE__ */ jsx14(
|
|
861
889
|
ResponsiveCamera,
|
|
862
890
|
{
|
|
863
891
|
height: parentSize.height,
|
|
864
892
|
width: parentSize.width
|
|
865
893
|
}
|
|
866
894
|
),
|
|
867
|
-
mediaProps?.debugOrbit && /* @__PURE__ */
|
|
868
|
-
/* @__PURE__ */
|
|
869
|
-
/* @__PURE__ */
|
|
895
|
+
mediaProps?.debugOrbit && /* @__PURE__ */ jsx14(CameraLogger, {}),
|
|
896
|
+
/* @__PURE__ */ jsx14("ambientLight", { intensity: 1 }),
|
|
897
|
+
/* @__PURE__ */ jsx14("pointLight", { position: [10, 10, 10] }),
|
|
870
898
|
React11.cloneElement(children, mergedMediaProps)
|
|
871
899
|
]
|
|
872
900
|
}
|
|
@@ -877,12 +905,12 @@ var Canvas = ({ mediaProps, children }) => {
|
|
|
877
905
|
var Canvas_default = Canvas;
|
|
878
906
|
|
|
879
907
|
// src/components/PlaygroundCanvas/PlaygroundCanvas.tsx
|
|
880
|
-
import { jsx as
|
|
908
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
881
909
|
var PlaygroundCanvas = ({
|
|
882
910
|
children,
|
|
883
911
|
mediaProps
|
|
884
912
|
}) => {
|
|
885
|
-
return /* @__PURE__ */
|
|
913
|
+
return /* @__PURE__ */ jsx15(Playground, { children: /* @__PURE__ */ jsx15(Canvas_default, { mediaProps, children }) });
|
|
886
914
|
};
|
|
887
915
|
var PlaygroundCanvas_default = PlaygroundCanvas;
|
|
888
916
|
export {
|