@measured/puck 0.7.1-canary.9b15c6b → 0.7.1-canary.c2d7fae

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.js CHANGED
@@ -147,10 +147,13 @@ var require_classnames = __commonJS({
147
147
  var core_exports = {};
148
148
  __export(core_exports, {
149
149
  Button: () => Button,
150
+ DropZone: () => DropZone,
151
+ DropZoneProvider: () => DropZoneProvider,
150
152
  FieldLabel: () => FieldLabel,
151
153
  IconButton: () => IconButton,
152
154
  Puck: () => Puck,
153
- Render: () => Render
155
+ Render: () => Render,
156
+ dropZoneContext: () => dropZoneContext
154
157
  });
155
158
  module.exports = __toCommonJS(core_exports);
156
159
  init_react_import();
@@ -253,12 +256,584 @@ var Button = ({
253
256
  return el;
254
257
  };
255
258
 
259
+ // components/DropZone/index.tsx
260
+ init_react_import();
261
+ var import_react7 = require("react");
262
+
263
+ // components/DraggableComponent/index.tsx
264
+ init_react_import();
265
+ var import_react4 = require("react");
266
+ var import_react_beautiful_dnd = require("react-beautiful-dnd");
267
+
268
+ // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
269
+ init_react_import();
270
+ var styles_module_default = { "DraggableComponent": "_DraggableComponent_1nlo8_1", "DraggableComponent--isDragging": "_DraggableComponent--isDragging_1nlo8_6", "DraggableComponent-contents": "_DraggableComponent-contents_1nlo8_12", "DraggableComponent-overlay": "_DraggableComponent-overlay_1nlo8_24", "DraggableComponent--isLocked": "_DraggableComponent--isLocked_1nlo8_39", "DraggableComponent--forceHover": "_DraggableComponent--forceHover_1nlo8_45", "DraggableComponent--indicativeHover": "_DraggableComponent--indicativeHover_1nlo8_50", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_1nlo8_57", "DraggableComponent-actions": "_DraggableComponent-actions_1nlo8_70", "DraggableComponent-actionsLabel": "_DraggableComponent-actionsLabel_1nlo8_93", "DraggableComponent-action": "_DraggableComponent-action_1nlo8_70" };
271
+
272
+ // components/DraggableComponent/index.tsx
273
+ var import_react_feather = require("react-feather");
274
+
275
+ // lib/use-modifier-held.ts
276
+ init_react_import();
277
+ var import_react3 = require("react");
278
+ var useModifierHeld = (modifier) => {
279
+ const [modifierHeld, setModifierHeld] = (0, import_react3.useState)(false);
280
+ (0, import_react3.useEffect)(() => {
281
+ function downHandler({ key }) {
282
+ if (key === modifier) {
283
+ setModifierHeld(true);
284
+ }
285
+ }
286
+ function upHandler({ key }) {
287
+ if (key === modifier) {
288
+ setModifierHeld(false);
289
+ }
290
+ }
291
+ window.addEventListener("keydown", downHandler);
292
+ window.addEventListener("keyup", upHandler);
293
+ return () => {
294
+ window.removeEventListener("keydown", downHandler);
295
+ window.removeEventListener("keyup", upHandler);
296
+ };
297
+ }, [modifier]);
298
+ return modifierHeld;
299
+ };
300
+
301
+ // components/DraggableComponent/index.tsx
302
+ var import_jsx_runtime2 = require("react/jsx-runtime");
303
+ var getClassName2 = get_class_name_factory_default("DraggableComponent", styles_module_default);
304
+ var DraggableComponent = ({
305
+ children,
306
+ id,
307
+ index,
308
+ isSelected = false,
309
+ onClick = () => null,
310
+ onMount = () => null,
311
+ onMouseOver = () => null,
312
+ onMouseOut = () => null,
313
+ onDelete = () => null,
314
+ onDuplicate = () => null,
315
+ debug,
316
+ label,
317
+ isLocked = false,
318
+ isDragDisabled,
319
+ forceHover = false,
320
+ indicativeHover = false,
321
+ style
322
+ }) => {
323
+ const isModifierHeld = useModifierHeld("Alt");
324
+ (0, import_react4.useEffect)(onMount, []);
325
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
326
+ import_react_beautiful_dnd.Draggable,
327
+ {
328
+ draggableId: id,
329
+ index,
330
+ isDragDisabled,
331
+ children: (provided, snapshot) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
332
+ "div",
333
+ __spreadProps(__spreadValues(__spreadValues({
334
+ ref: provided.innerRef
335
+ }, provided.draggableProps), provided.dragHandleProps), {
336
+ className: getClassName2({
337
+ isSelected,
338
+ isModifierHeld,
339
+ isDragging: snapshot.isDragging,
340
+ isLocked,
341
+ forceHover,
342
+ indicativeHover
343
+ }),
344
+ style: __spreadProps(__spreadValues(__spreadValues({}, style), provided.draggableProps.style), {
345
+ cursor: isModifierHeld ? "initial" : "grab"
346
+ }),
347
+ onMouseOver,
348
+ onMouseOut,
349
+ onClick,
350
+ children: [
351
+ debug,
352
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: getClassName2("contents"), children }),
353
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: getClassName2("overlay"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: getClassName2("actions"), children: [
354
+ label && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: getClassName2("actionsLabel"), children: label }),
355
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: getClassName2("action"), onClick: onDuplicate, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_feather.Copy, { size: 16 }) }),
356
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: getClassName2("action"), onClick: onDelete, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_feather.Trash, { size: 16 }) })
357
+ ] }) })
358
+ ]
359
+ })
360
+ )
361
+ },
362
+ id
363
+ );
364
+ };
365
+
366
+ // components/DroppableStrictMode/index.tsx
367
+ init_react_import();
368
+ var import_react5 = require("react");
369
+ var import_react_beautiful_dnd2 = require("react-beautiful-dnd");
370
+ var import_jsx_runtime3 = require("react/jsx-runtime");
371
+ var DroppableStrictMode = (_a) => {
372
+ var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
373
+ const [enabled, setEnabled] = (0, import_react5.useState)(false);
374
+ (0, import_react5.useEffect)(() => {
375
+ const animation = requestAnimationFrame(() => setEnabled(true));
376
+ return () => {
377
+ cancelAnimationFrame(animation);
378
+ setEnabled(false);
379
+ };
380
+ }, []);
381
+ if (!enabled) {
382
+ return null;
383
+ }
384
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_beautiful_dnd2.Droppable, __spreadProps(__spreadValues({}, props), { children }));
385
+ };
386
+ var DroppableStrictMode_default = DroppableStrictMode;
387
+
388
+ // lib/get-item.ts
389
+ init_react_import();
390
+
391
+ // lib/root-droppable-id.ts
392
+ init_react_import();
393
+ var rootDroppableId = "default-zone";
394
+
395
+ // lib/setup-zone.ts
396
+ init_react_import();
397
+ var setupZone = (data, zoneKey) => {
398
+ if (zoneKey === rootDroppableId) {
399
+ return data;
400
+ }
401
+ const newData = __spreadValues({}, data);
402
+ newData.zones = data.zones || {};
403
+ newData.zones[zoneKey] = newData.zones[zoneKey] || [];
404
+ return newData;
405
+ };
406
+
407
+ // lib/get-item.ts
408
+ var getItem = (selector, data) => {
409
+ if (!selector.zone || selector.zone === rootDroppableId) {
410
+ return data.content[selector.index];
411
+ }
412
+ return setupZone(data, selector.zone).zones[selector.zone][selector.index];
413
+ };
414
+
415
+ // lib/index.ts
416
+ init_react_import();
417
+
418
+ // lib/filter.ts
419
+ init_react_import();
420
+ var filter = (obj, validKeys) => {
421
+ return validKeys.reduce((acc, item) => {
422
+ if (typeof obj[item] !== "undefined") {
423
+ return __spreadProps(__spreadValues({}, acc), { [item]: obj[item] });
424
+ }
425
+ return acc;
426
+ }, {});
427
+ };
428
+
429
+ // lib/reorder.ts
430
+ init_react_import();
431
+ var reorder = (list, startIndex, endIndex) => {
432
+ const result = Array.from(list);
433
+ const [removed] = result.splice(startIndex, 1);
434
+ result.splice(endIndex, 0, removed);
435
+ return result;
436
+ };
437
+
438
+ // lib/replace.ts
439
+ init_react_import();
440
+ var replace = (list, index, newItem) => {
441
+ const result = Array.from(list);
442
+ result.splice(index, 1);
443
+ result.splice(index, 0, newItem);
444
+ return result;
445
+ };
446
+
447
+ // css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css#css-module
448
+ init_react_import();
449
+ var styles_module_default2 = { "DropZone": "_DropZone_1980k_1", "DropZone-content": "_DropZone-content_1980k_11", "DropZone--userIsDragging": "_DropZone--userIsDragging_1980k_16", "DropZone--draggingOverArea": "_DropZone--draggingOverArea_1980k_20", "DropZone--draggingNewComponent": "_DropZone--draggingNewComponent_1980k_21", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_1980k_27", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_1980k_28", "DropZone--isDisabled": "_DropZone--isDisabled_1980k_29", "DropZone--isRootZone": "_DropZone--isRootZone_1980k_30", "DropZone--hasChildren": "_DropZone--hasChildren_1980k_36", "DropZone--isDestination": "_DropZone--isDestination_1980k_41", "DropZone-item": "_DropZone-item_1980k_49", "DropZone-hitbox": "_DropZone-hitbox_1980k_57" };
450
+
451
+ // components/DropZone/context.tsx
452
+ init_react_import();
453
+ var import_react6 = require("react");
454
+ var import_use_debounce = require("use-debounce");
455
+
456
+ // lib/get-zone-id.ts
457
+ init_react_import();
458
+ var getZoneId = (zoneCompound) => {
459
+ if (!zoneCompound) {
460
+ return [];
461
+ }
462
+ if (zoneCompound && zoneCompound.indexOf(":") > -1) {
463
+ return zoneCompound.split(":");
464
+ }
465
+ return ["root", zoneCompound];
466
+ };
467
+
468
+ // components/DropZone/context.tsx
469
+ var import_jsx_runtime4 = require("react/jsx-runtime");
470
+ var dropZoneContext = (0, import_react6.createContext)(null);
471
+ var DropZoneProvider = ({
472
+ children,
473
+ value
474
+ }) => {
475
+ const [hoveringArea, setHoveringArea] = (0, import_react6.useState)(null);
476
+ const [hoveringZone, setHoveringZone] = (0, import_react6.useState)(
477
+ rootDroppableId
478
+ );
479
+ const [hoveringComponent, setHoveringComponent] = (0, import_react6.useState)();
480
+ const [hoveringAreaDb] = (0, import_use_debounce.useDebounce)(hoveringArea, 75, { leading: false });
481
+ const [areasWithZones, setAreasWithZones] = (0, import_react6.useState)(
482
+ {}
483
+ );
484
+ const [activeZones, setActiveZones] = (0, import_react6.useState)({});
485
+ const { dispatch = null } = value ? value : {};
486
+ const registerZoneArea = (0, import_react6.useCallback)(
487
+ (area) => {
488
+ setAreasWithZones((latest) => __spreadProps(__spreadValues({}, latest), { [area]: true }));
489
+ },
490
+ [setAreasWithZones]
491
+ );
492
+ const registerZone = (0, import_react6.useCallback)(
493
+ (zoneCompound) => {
494
+ if (!dispatch) {
495
+ return;
496
+ }
497
+ dispatch({
498
+ type: "registerZone",
499
+ zone: zoneCompound
500
+ });
501
+ setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
502
+ },
503
+ [setActiveZones, dispatch]
504
+ );
505
+ const unregisterZone = (0, import_react6.useCallback)(
506
+ (zoneCompound) => {
507
+ if (!dispatch) {
508
+ return;
509
+ }
510
+ dispatch({
511
+ type: "unregisterZone",
512
+ zone: zoneCompound
513
+ });
514
+ setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
515
+ [zoneCompound]: false
516
+ }));
517
+ },
518
+ [setActiveZones, dispatch]
519
+ );
520
+ const [pathData, setPathData] = (0, import_react6.useState)();
521
+ const registerPath = (0, import_react6.useCallback)(
522
+ (selector) => {
523
+ if (!(value == null ? void 0 : value.data)) {
524
+ return;
525
+ }
526
+ const item = getItem(selector, value.data);
527
+ if (!item) {
528
+ return;
529
+ }
530
+ const [area] = getZoneId(selector.zone);
531
+ setPathData((latestPathData = {}) => {
532
+ const pathData2 = latestPathData[area] || [];
533
+ return __spreadProps(__spreadValues({}, latestPathData), {
534
+ [item.props.id]: [
535
+ ...pathData2,
536
+ {
537
+ selector,
538
+ label: item.type
539
+ }
540
+ ]
541
+ });
542
+ });
543
+ },
544
+ [value, setPathData]
545
+ );
546
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: value && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
547
+ dropZoneContext.Provider,
548
+ {
549
+ value: __spreadValues({
550
+ hoveringArea: value.draggedItem ? hoveringAreaDb : hoveringArea,
551
+ setHoveringArea,
552
+ hoveringZone,
553
+ setHoveringZone,
554
+ hoveringComponent,
555
+ setHoveringComponent,
556
+ registerZoneArea,
557
+ areasWithZones,
558
+ registerZone,
559
+ unregisterZone,
560
+ activeZones,
561
+ registerPath,
562
+ pathData
563
+ }, value),
564
+ children
565
+ }
566
+ ) });
567
+ };
568
+
569
+ // components/DropZone/index.tsx
570
+ var import_jsx_runtime5 = require("react/jsx-runtime");
571
+ var getClassName3 = get_class_name_factory_default("DropZone", styles_module_default2);
572
+ function DropZoneEdit({ zone, style }) {
573
+ var _a;
574
+ const ctx = (0, import_react7.useContext)(dropZoneContext);
575
+ const {
576
+ // These all need setting via context
577
+ data,
578
+ dispatch = () => null,
579
+ config,
580
+ itemSelector,
581
+ setItemSelector = () => null,
582
+ areaId,
583
+ draggedItem,
584
+ placeholderStyle,
585
+ registerZoneArea,
586
+ areasWithZones,
587
+ hoveringComponent
588
+ } = ctx || {};
589
+ let content = data.content || [];
590
+ let zoneCompound = rootDroppableId;
591
+ (0, import_react7.useEffect)(() => {
592
+ if (areaId && registerZoneArea) {
593
+ registerZoneArea(areaId);
594
+ }
595
+ }, [areaId]);
596
+ (0, import_react7.useEffect)(() => {
597
+ if (ctx == null ? void 0 : ctx.registerZone) {
598
+ ctx == null ? void 0 : ctx.registerZone(zoneCompound);
599
+ }
600
+ return () => {
601
+ if (ctx == null ? void 0 : ctx.unregisterZone) {
602
+ ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
603
+ }
604
+ };
605
+ }, []);
606
+ if (areaId) {
607
+ if (zone !== rootDroppableId) {
608
+ zoneCompound = `${areaId}:${zone}`;
609
+ content = setupZone(data, zoneCompound).zones[zoneCompound];
610
+ }
611
+ }
612
+ const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
613
+ const draggedSourceId = draggedItem && draggedItem.source.droppableId;
614
+ const draggedDestinationId = draggedItem && ((_a = draggedItem.destination) == null ? void 0 : _a.droppableId);
615
+ const [zoneArea] = getZoneId(zoneCompound);
616
+ const [draggedSourceArea] = getZoneId(draggedSourceId);
617
+ const userIsDragging = !!draggedItem;
618
+ const draggingOverArea = userIsDragging && zoneArea === draggedSourceArea;
619
+ const draggingNewComponent = draggedSourceId === "component-list";
620
+ if (!(ctx == null ? void 0 : ctx.config) || !ctx.setHoveringArea || !ctx.setHoveringZone || !ctx.setHoveringComponent || !ctx.setItemSelector || !ctx.registerPath || !ctx.dispatch) {
621
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: "DropZone requires context to work." });
622
+ }
623
+ const {
624
+ hoveringArea = "root",
625
+ setHoveringArea,
626
+ hoveringZone,
627
+ setHoveringZone,
628
+ setHoveringComponent
629
+ } = ctx;
630
+ const hoveringOverArea = hoveringArea ? hoveringArea === zoneArea : isRootZone;
631
+ const hoveringOverZone = hoveringZone === zoneCompound;
632
+ let isEnabled = false;
633
+ if (userIsDragging) {
634
+ if (draggingNewComponent) {
635
+ isEnabled = hoveringOverArea;
636
+ } else {
637
+ isEnabled = draggingOverArea && hoveringOverZone;
638
+ }
639
+ }
640
+ const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
641
+ const isAreaSelected = selectedItem && zoneArea === selectedItem.props.id;
642
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
643
+ "div",
644
+ {
645
+ className: getClassName3({
646
+ isRootZone,
647
+ userIsDragging,
648
+ draggingOverArea,
649
+ hoveringOverArea,
650
+ draggingNewComponent,
651
+ isDestination: draggedDestinationId === zoneCompound,
652
+ isDisabled: !isEnabled,
653
+ isAreaSelected,
654
+ hasChildren: content.length > 0
655
+ }),
656
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
657
+ DroppableStrictMode_default,
658
+ {
659
+ droppableId: zoneCompound,
660
+ direction: "vertical",
661
+ isDropDisabled: !isEnabled,
662
+ children: (provided, snapshot) => {
663
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
664
+ "div",
665
+ __spreadProps(__spreadValues({}, (provided || { droppableProps: {} }).droppableProps), {
666
+ className: getClassName3("content"),
667
+ ref: provided == null ? void 0 : provided.innerRef,
668
+ style,
669
+ id: zoneCompound,
670
+ onMouseOver: (e) => {
671
+ e.stopPropagation();
672
+ setHoveringArea(zoneArea);
673
+ setHoveringZone(zoneCompound);
674
+ },
675
+ children: [
676
+ content.map((item, i) => {
677
+ var _a2;
678
+ const componentId = item.props.id;
679
+ const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, (_a2 = config.components[item.type]) == null ? void 0 : _a2.defaultProps), item.props), {
680
+ editMode: true
681
+ });
682
+ const isSelected = (selectedItem == null ? void 0 : selectedItem.props.id) === componentId || false;
683
+ const containsZone = areasWithZones ? areasWithZones[componentId] : false;
684
+ const Render2 = config.components[item.type] ? config.components[item.type].render : () => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
685
+ "No configuration for ",
686
+ item.type
687
+ ] });
688
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: getClassName3("item"), children: [
689
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
690
+ DropZoneProvider,
691
+ {
692
+ value: __spreadProps(__spreadValues({}, ctx), {
693
+ areaId: componentId
694
+ }),
695
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
696
+ DraggableComponent,
697
+ {
698
+ label: item.type.toString(),
699
+ id: `draggable-${componentId}`,
700
+ index: i,
701
+ isSelected,
702
+ isLocked: userIsDragging,
703
+ forceHover: hoveringComponent === componentId && !userIsDragging,
704
+ indicativeHover: userIsDragging && containsZone && hoveringArea === componentId,
705
+ onMount: () => {
706
+ ctx.registerPath({
707
+ index: i,
708
+ zone: zoneCompound
709
+ });
710
+ },
711
+ onClick: (e) => {
712
+ setItemSelector({
713
+ index: i,
714
+ zone: zoneCompound
715
+ });
716
+ e.stopPropagation();
717
+ },
718
+ onMouseOver: (e) => {
719
+ e.stopPropagation();
720
+ if (containsZone) {
721
+ setHoveringArea(componentId);
722
+ } else {
723
+ setHoveringArea(zoneArea);
724
+ }
725
+ setHoveringComponent(componentId);
726
+ setHoveringZone(zoneCompound);
727
+ },
728
+ onMouseOut: () => {
729
+ setHoveringArea(null);
730
+ setHoveringZone(null);
731
+ setHoveringComponent(null);
732
+ },
733
+ onDelete: (e) => {
734
+ dispatch({
735
+ type: "remove",
736
+ index: i,
737
+ zone: zoneCompound
738
+ });
739
+ setItemSelector(null);
740
+ e.stopPropagation();
741
+ },
742
+ onDuplicate: (e) => {
743
+ dispatch({
744
+ type: "duplicate",
745
+ sourceIndex: i,
746
+ sourceZone: zoneCompound
747
+ });
748
+ setItemSelector({
749
+ zone: zoneCompound,
750
+ index: i + 1
751
+ });
752
+ e.stopPropagation();
753
+ },
754
+ style: {
755
+ pointerEvents: userIsDragging && draggingNewComponent ? "all" : void 0
756
+ },
757
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { zoom: 0.75 }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Render2, __spreadValues({}, defaultedProps)) })
758
+ }
759
+ )
760
+ }
761
+ ),
762
+ userIsDragging && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
763
+ "div",
764
+ {
765
+ className: getClassName3("hitbox"),
766
+ onMouseOver: (e) => {
767
+ e.stopPropagation();
768
+ setHoveringArea(zoneArea);
769
+ setHoveringZone(zoneCompound);
770
+ }
771
+ }
772
+ )
773
+ ] }, item.props.id);
774
+ }),
775
+ provided == null ? void 0 : provided.placeholder,
776
+ (snapshot == null ? void 0 : snapshot.isDraggingOver) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
777
+ "div",
778
+ {
779
+ "data-puck-placeholder": true,
780
+ style: __spreadProps(__spreadValues({}, placeholderStyle), {
781
+ background: "var(--puck-color-azure-5)",
782
+ opacity: 0.3,
783
+ zIndex: 0
784
+ })
785
+ }
786
+ )
787
+ ]
788
+ })
789
+ );
790
+ }
791
+ }
792
+ )
793
+ }
794
+ );
795
+ }
796
+ function DropZoneRender({ zone }) {
797
+ const ctx = (0, import_react7.useContext)(dropZoneContext);
798
+ const { data, areaId = "root", config } = ctx || {};
799
+ let zoneCompound = rootDroppableId;
800
+ let content = (data == null ? void 0 : data.content) || [];
801
+ if (!data || !config) {
802
+ return null;
803
+ }
804
+ if (areaId && zone && zone !== rootDroppableId) {
805
+ zoneCompound = `${areaId}:${zone}`;
806
+ content = setupZone(data, zoneCompound).zones[zoneCompound];
807
+ }
808
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: content.map((item) => {
809
+ const Component = config.components[item.type];
810
+ if (Component) {
811
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
812
+ DropZoneProvider,
813
+ {
814
+ value: { data, config, areaId: item.props.id },
815
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Component.render, __spreadValues({}, item.props))
816
+ },
817
+ item.props.id
818
+ );
819
+ }
820
+ return null;
821
+ }) });
822
+ }
823
+ function DropZone(props) {
824
+ const ctx = (0, import_react7.useContext)(dropZoneContext);
825
+ if ((ctx == null ? void 0 : ctx.mode) === "edit") {
826
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DropZoneEdit, __spreadValues({}, props));
827
+ }
828
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DropZoneRender, __spreadValues({}, props));
829
+ }
830
+
256
831
  // components/IconButton/index.ts
257
832
  init_react_import();
258
833
 
259
834
  // components/IconButton/IconButton.tsx
260
835
  init_react_import();
261
- var import_react3 = require("react");
836
+ var import_react8 = require("react");
262
837
 
263
838
  // css-module:/home/runner/work/puck/puck/packages/core/components/IconButton/IconButton.module.css#css-module
264
839
  init_react_import();
@@ -266,8 +841,8 @@ var IconButton_module_default = { "IconButton": "_IconButton_13gzt_1" };
266
841
 
267
842
  // components/IconButton/IconButton.tsx
268
843
  var import_react_spinners2 = require("react-spinners");
269
- var import_jsx_runtime2 = require("react/jsx-runtime");
270
- var getClassName2 = get_class_name_factory_default("IconButton", IconButton_module_default);
844
+ var import_jsx_runtime6 = require("react/jsx-runtime");
845
+ var getClassName4 = get_class_name_factory_default("IconButton", IconButton_module_default);
271
846
  var IconButton = ({
272
847
  children,
273
848
  href,
@@ -280,12 +855,12 @@ var IconButton = ({
280
855
  fullWidth,
281
856
  title
282
857
  }) => {
283
- const [loading, setLoading] = (0, import_react3.useState)(false);
858
+ const [loading, setLoading] = (0, import_react8.useState)(false);
284
859
  const ElementType = href ? "a" : "button";
285
- const el = /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
860
+ const el = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
286
861
  ElementType,
287
862
  {
288
- className: getClassName2({
863
+ className: getClassName4({
289
864
  primary: variant === "primary",
290
865
  secondary: variant === "secondary",
291
866
  disabled,
@@ -308,9 +883,9 @@ var IconButton = ({
308
883
  title,
309
884
  children: [
310
885
  children,
311
- loading && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
886
+ loading && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
312
887
  "\xA0\xA0",
313
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_spinners2.ClipLoader, { color: "inherit", size: "14px" })
888
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_spinners2.ClipLoader, { color: "inherit", size: "14px" })
314
889
  ] })
315
890
  ]
316
891
  }
@@ -320,129 +895,33 @@ var IconButton = ({
320
895
 
321
896
  // components/Puck/index.tsx
322
897
  init_react_import();
323
- var import_react8 = require("react");
898
+ var import_react12 = require("react");
324
899
  var import_react_beautiful_dnd4 = require("react-beautiful-dnd");
325
900
 
326
- // components/DroppableStrictMode/index.tsx
327
- init_react_import();
328
- var import_react4 = require("react");
329
- var import_react_beautiful_dnd = require("react-beautiful-dnd");
330
- var import_jsx_runtime3 = require("react/jsx-runtime");
331
- var DroppableStrictMode = (_a) => {
332
- var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
333
- const [enabled, setEnabled] = (0, import_react4.useState)(false);
334
- (0, import_react4.useEffect)(() => {
335
- const animation = requestAnimationFrame(() => setEnabled(true));
336
- return () => {
337
- cancelAnimationFrame(animation);
338
- setEnabled(false);
339
- };
340
- }, []);
341
- if (!enabled) {
342
- return null;
343
- }
344
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_beautiful_dnd.Droppable, __spreadProps(__spreadValues({}, props), { children }));
345
- };
346
- var DroppableStrictMode_default = DroppableStrictMode;
347
-
348
- // components/DraggableComponent/index.tsx
349
- init_react_import();
350
- var import_react_beautiful_dnd2 = require("react-beautiful-dnd");
351
-
352
- // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
353
- init_react_import();
354
- var styles_module_default = { "DraggableComponent": "_DraggableComponent_1ew8n_1", "DraggableComponent-contents": "_DraggableComponent-contents_1ew8n_5", "DraggableComponent-overlay": "_DraggableComponent-overlay_1ew8n_16", "DraggableComponent--isModifierHeld": "_DraggableComponent--isModifierHeld_1ew8n_32", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_1ew8n_36", "DraggableComponent-actions": "_DraggableComponent-actions_1ew8n_41", "DraggableComponent-actionsLabel": "_DraggableComponent-actionsLabel_1ew8n_56", "DraggableComponent-action": "_DraggableComponent-action_1ew8n_41" };
355
-
356
- // components/DraggableComponent/index.tsx
357
- var import_react_feather = require("react-feather");
358
-
359
- // lib/use-modifier-held.ts
360
- init_react_import();
361
- var import_react5 = require("react");
362
- var useModifierHeld = (modifier) => {
363
- const [modifierHeld, setModifierHeld] = (0, import_react5.useState)(false);
364
- function downHandler({ key }) {
365
- if (key === modifier) {
366
- setModifierHeld(true);
367
- }
368
- }
369
- function upHandler({ key }) {
370
- if (key === modifier) {
371
- setModifierHeld(false);
372
- }
373
- }
374
- (0, import_react5.useEffect)(() => {
375
- window.addEventListener("keydown", downHandler);
376
- window.addEventListener("keyup", upHandler);
377
- return () => {
378
- window.removeEventListener("keydown", downHandler);
379
- window.removeEventListener("keyup", upHandler);
380
- };
381
- }, []);
382
- return modifierHeld;
383
- };
384
-
385
- // components/DraggableComponent/index.tsx
386
- var import_jsx_runtime4 = require("react/jsx-runtime");
387
- var getClassName3 = get_class_name_factory_default("DraggableComponent", styles_module_default);
388
- var DraggableComponent = ({
389
- children,
390
- id,
391
- index,
392
- isSelected = false,
393
- onClick = () => null,
394
- onDelete = () => null,
395
- onDuplicate = () => null,
396
- debug,
397
- label
398
- }) => {
399
- const isModifierHeld = useModifierHeld("Alt");
400
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_beautiful_dnd2.Draggable, { draggableId: id, index, children: (provided) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
401
- "div",
402
- __spreadProps(__spreadValues(__spreadValues({
403
- ref: provided.innerRef
404
- }, provided.draggableProps), provided.dragHandleProps), {
405
- className: getClassName3({ isSelected, isModifierHeld }),
406
- style: __spreadProps(__spreadValues({}, provided.draggableProps.style), {
407
- cursor: isModifierHeld ? "initial" : "grab"
408
- }),
409
- children: [
410
- debug,
411
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassName3("contents"), children }),
412
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassName3("overlay"), onClick, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: getClassName3("actions"), children: [
413
- label && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassName3("actionsLabel"), children: label }),
414
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { className: getClassName3("action"), onClick: onDuplicate, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_feather.Copy, {}) }),
415
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { className: getClassName3("action"), onClick: onDelete, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_feather.Trash, {}) })
416
- ] }) })
417
- ]
418
- })
419
- ) }, id);
420
- };
421
-
422
901
  // components/InputOrGroup/index.tsx
423
902
  init_react_import();
424
903
 
425
904
  // components/ExternalInput/index.tsx
426
905
  init_react_import();
427
- var import_react6 = require("react");
906
+ var import_react9 = require("react");
428
907
 
429
908
  // css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
430
909
  init_react_import();
431
- var styles_module_default2 = { "ExternalInput": "_ExternalInput_l4bks_1", "ExternalInput-actions": "_ExternalInput-actions_l4bks_5", "ExternalInput-button": "_ExternalInput-button_l4bks_9", "ExternalInput-detachButton": "_ExternalInput-detachButton_l4bks_28", "ExternalInput--hasData": "_ExternalInput--hasData_l4bks_35", "ExternalInput-modal": "_ExternalInput-modal_l4bks_55", "ExternalInput--modalVisible": "_ExternalInput--modalVisible_l4bks_69", "ExternalInput-modalInner": "_ExternalInput-modalInner_l4bks_73", "ExternalInput-modalHeading": "_ExternalInput-modalHeading_l4bks_84", "ExternalInput-modalTableWrapper": "_ExternalInput-modalTableWrapper_l4bks_89" };
910
+ var styles_module_default3 = { "ExternalInput": "_ExternalInput_l4bks_1", "ExternalInput-actions": "_ExternalInput-actions_l4bks_5", "ExternalInput-button": "_ExternalInput-button_l4bks_9", "ExternalInput-detachButton": "_ExternalInput-detachButton_l4bks_28", "ExternalInput--hasData": "_ExternalInput--hasData_l4bks_35", "ExternalInput-modal": "_ExternalInput-modal_l4bks_55", "ExternalInput--modalVisible": "_ExternalInput--modalVisible_l4bks_69", "ExternalInput-modalInner": "_ExternalInput-modalInner_l4bks_73", "ExternalInput-modalHeading": "_ExternalInput-modalHeading_l4bks_84", "ExternalInput-modalTableWrapper": "_ExternalInput-modalTableWrapper_l4bks_89" };
432
911
 
433
912
  // components/ExternalInput/index.tsx
434
913
  var import_react_feather2 = require("react-feather");
435
- var import_jsx_runtime5 = require("react/jsx-runtime");
436
- var getClassName4 = get_class_name_factory_default("ExternalInput", styles_module_default2);
914
+ var import_jsx_runtime7 = require("react/jsx-runtime");
915
+ var getClassName5 = get_class_name_factory_default("ExternalInput", styles_module_default3);
437
916
  var ExternalInput = ({
438
917
  field,
439
918
  onChange,
440
919
  value = null
441
920
  }) => {
442
- const [data, setData] = (0, import_react6.useState)([]);
443
- const [isOpen, setOpen] = (0, import_react6.useState)(false);
444
- const [selectedData, setSelectedData] = (0, import_react6.useState)(value);
445
- (0, import_react6.useEffect)(() => {
921
+ const [data, setData] = (0, import_react9.useState)([]);
922
+ const [isOpen, setOpen] = (0, import_react9.useState)(false);
923
+ const [selectedData, setSelectedData] = (0, import_react9.useState)(value);
924
+ (0, import_react9.useEffect)(() => {
446
925
  (() => __async(void 0, null, function* () {
447
926
  if (field.adaptor) {
448
927
  const listData = yield field.adaptor.fetchList(field.adaptorParams);
@@ -453,35 +932,35 @@ var ExternalInput = ({
453
932
  }))();
454
933
  }, [field.adaptor, field.adaptorParams]);
455
934
  if (!field.adaptor) {
456
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: "Incorrectly configured" });
935
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: "Incorrectly configured" });
457
936
  }
458
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
937
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
459
938
  "div",
460
939
  {
461
- className: getClassName4({
940
+ className: getClassName5({
462
941
  hasData: !!selectedData,
463
942
  modalVisible: isOpen
464
943
  }),
465
944
  children: [
466
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: getClassName4("actions"), children: [
467
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
945
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassName5("actions"), children: [
946
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
468
947
  "button",
469
948
  {
470
949
  onClick: () => setOpen(true),
471
- className: getClassName4("button"),
472
- children: selectedData ? field.getItemSummary ? field.getItemSummary(selectedData) : `${field.adaptor.name} item` : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
473
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_feather2.Link, { size: "16" }),
474
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
950
+ className: getClassName5("button"),
951
+ children: selectedData ? field.getItemSummary ? field.getItemSummary(selectedData) : `${field.adaptor.name} item` : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
952
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_feather2.Link, { size: "16" }),
953
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
475
954
  "Select from ",
476
955
  field.adaptor.name
477
956
  ] })
478
957
  ] })
479
958
  }
480
959
  ),
481
- selectedData && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
960
+ selectedData && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
482
961
  "button",
483
962
  {
484
- className: getClassName4("detachButton"),
963
+ className: getClassName5("detachButton"),
485
964
  onClick: () => {
486
965
  setSelectedData(null);
487
966
  onChange(null);
@@ -490,17 +969,17 @@ var ExternalInput = ({
490
969
  }
491
970
  )
492
971
  ] }),
493
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: getClassName4("modal"), onClick: () => setOpen(false), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
972
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName5("modal"), onClick: () => setOpen(false), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
494
973
  "div",
495
974
  {
496
- className: getClassName4("modalInner"),
975
+ className: getClassName5("modalInner"),
497
976
  onClick: (e) => e.stopPropagation(),
498
977
  children: [
499
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h2", { className: getClassName4("modalHeading"), children: "Select content" }),
500
- data.length ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: getClassName4("modalTableWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("table", { children: [
501
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tr", { children: Object.keys(data[0]).map((key) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("th", { style: { textAlign: "left" }, children: key }, key)) }) }),
502
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tbody", { children: data.map((item, i) => {
503
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
978
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h2", { className: getClassName5("modalHeading"), children: "Select content" }),
979
+ data.length ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName5("modalTableWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("table", { children: [
980
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("tr", { children: Object.keys(data[0]).map((key) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("th", { style: { textAlign: "left" }, children: key }, key)) }) }),
981
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("tbody", { children: data.map((item, i) => {
982
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
504
983
  "tr",
505
984
  {
506
985
  style: { whiteSpace: "nowrap" },
@@ -509,12 +988,12 @@ var ExternalInput = ({
509
988
  setOpen(false);
510
989
  setSelectedData(item);
511
990
  },
512
- children: Object.keys(item).map((key) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { children: item[key] }, key))
991
+ children: Object.keys(item).map((key) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("td", { children: item[key] }, key))
513
992
  },
514
993
  i
515
994
  );
516
995
  }) })
517
- ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { padding: 24 }, children: "No content" })
996
+ ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { padding: 24 }, children: "No content" })
518
997
  ]
519
998
  }
520
999
  ) })
@@ -525,52 +1004,20 @@ var ExternalInput = ({
525
1004
 
526
1005
  // css-module:/home/runner/work/puck/puck/packages/core/components/InputOrGroup/styles.module.css#css-module
527
1006
  init_react_import();
528
- var styles_module_default3 = { "Input": "_Input_kf9j8_1", "Input-label": "_Input-label_kf9j8_27", "Input-labelIcon": "_Input-labelIcon_kf9j8_34", "Input-input": "_Input-input_kf9j8_39", "Input--readOnly": "_Input--readOnly_kf9j8_60", "Input-arrayItem": "_Input-arrayItem_kf9j8_69", "Input-arrayItemAction": "_Input-arrayItemAction_kf9j8_112", "Input-addButton": "_Input-addButton_kf9j8_131", "Input-array": "_Input-array_kf9j8_69", "Input-radioGroupItems": "_Input-radioGroupItems_kf9j8_152", "Input-radio": "_Input-radio_kf9j8_152", "Input-radioInner": "_Input-radioInner_kf9j8_169" };
529
-
530
- // lib/index.ts
531
- init_react_import();
532
-
533
- // lib/filter.ts
534
- init_react_import();
535
- var filter = (obj, validKeys) => {
536
- return validKeys.reduce((acc, item) => {
537
- if (typeof obj[item] !== "undefined") {
538
- return __spreadProps(__spreadValues({}, acc), { [item]: obj[item] });
539
- }
540
- return acc;
541
- }, {});
542
- };
543
-
544
- // lib/reorder.ts
545
- init_react_import();
546
- var reorder = (list, startIndex, endIndex) => {
547
- const result = Array.from(list);
548
- const [removed] = result.splice(startIndex, 1);
549
- result.splice(endIndex, 0, removed);
550
- return result;
551
- };
552
-
553
- // lib/replace.ts
554
- init_react_import();
555
- var replace = (list, index, newItem) => {
556
- const result = Array.from(list);
557
- result.splice(index, 1);
558
- result.splice(index, 0, newItem);
559
- return result;
560
- };
1007
+ var styles_module_default4 = { "Input": "_Input_16exs_1", "Input-label": "_Input-label_16exs_27", "Input-labelIcon": "_Input-labelIcon_16exs_34", "Input-input": "_Input-input_16exs_39", "Input--readOnly": "_Input--readOnly_16exs_60", "Input-arrayItem": "_Input-arrayItem_16exs_69", "Input-fieldset": "_Input-fieldset_16exs_95", "Input-arrayItemAction": "_Input-arrayItemAction_16exs_117", "Input-addButton": "_Input-addButton_16exs_136", "Input-array": "_Input-array_16exs_69", "Input-radioGroupItems": "_Input-radioGroupItems_16exs_157", "Input-radio": "_Input-radio_16exs_157", "Input-radioInner": "_Input-radioInner_16exs_174", "Input-radioInput": "_Input-radioInput_16exs_186" };
561
1008
 
562
1009
  // components/InputOrGroup/index.tsx
563
1010
  var import_react_feather3 = require("react-feather");
564
- var import_jsx_runtime6 = require("react/jsx-runtime");
565
- var getClassName5 = get_class_name_factory_default("Input", styles_module_default3);
1011
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1012
+ var getClassName6 = get_class_name_factory_default("Input", styles_module_default4);
566
1013
  var FieldLabel = ({
567
1014
  children,
568
1015
  icon,
569
1016
  label
570
1017
  }) => {
571
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { children: [
572
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: getClassName5("label"), children: [
573
- icon && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: getClassName5("labelIcon") }),
1018
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { children: [
1019
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName6("label"), children: [
1020
+ icon && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName6("labelIcon") }),
574
1021
  label
575
1022
  ] }),
576
1023
  children
@@ -588,20 +1035,20 @@ var InputOrGroup = ({
588
1035
  if (!field.arrayFields) {
589
1036
  return null;
590
1037
  }
591
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: getClassName5(), children: [
592
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("b", { className: getClassName5("label"), children: [
593
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: getClassName5("labelIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_feather3.List, { size: 16 }) }),
1038
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName6(), children: [
1039
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("b", { className: getClassName6("label"), children: [
1040
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName6("labelIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_feather3.List, { size: 16 }) }),
594
1041
  label || name
595
1042
  ] }),
596
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: getClassName5("array"), children: [
597
- Array.isArray(value) ? value.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1043
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName6("array"), children: [
1044
+ Array.isArray(value) ? value.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
598
1045
  "details",
599
1046
  {
600
- className: getClassName5("arrayItem"),
1047
+ className: getClassName6("arrayItem"),
601
1048
  children: [
602
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("summary", { children: [
1049
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("summary", { children: [
603
1050
  field.getItemSummary ? field.getItemSummary(item, i) : `Item #${i}`,
604
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: getClassName5("arrayItemAction"), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1051
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName6("arrayItemAction"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
605
1052
  IconButton,
606
1053
  {
607
1054
  onClick: () => {
@@ -610,17 +1057,17 @@ var InputOrGroup = ({
610
1057
  onChange(existingValue);
611
1058
  },
612
1059
  title: "Delete",
613
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_feather3.Trash, { size: 21 })
1060
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_feather3.Trash, { size: 21 })
614
1061
  }
615
1062
  ) })
616
1063
  ] }),
617
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("fieldset", { children: Object.keys(field.arrayFields).map((fieldName) => {
1064
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("fieldset", { className: getClassName6("fieldset"), children: Object.keys(field.arrayFields).map((fieldName) => {
618
1065
  const subField = field.arrayFields[fieldName];
619
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1066
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
620
1067
  InputOrGroup,
621
1068
  {
622
1069
  name: `${name}_${i}_${fieldName}`,
623
- label: fieldName,
1070
+ label: subField.label || fieldName,
624
1071
  field: subField,
625
1072
  value: item[fieldName],
626
1073
  onChange: (val) => onChange(
@@ -633,11 +1080,11 @@ var InputOrGroup = ({
633
1080
  ]
634
1081
  },
635
1082
  `${name}_${i}`
636
- )) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {}),
637
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1083
+ )) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", {}),
1084
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
638
1085
  "button",
639
1086
  {
640
- className: getClassName5("addButton"),
1087
+ className: getClassName6("addButton"),
641
1088
  onClick: () => {
642
1089
  const existingValue = value || [];
643
1090
  onChange([...existingValue, field.defaultItemProps || {}]);
@@ -652,24 +1099,24 @@ var InputOrGroup = ({
652
1099
  if (!field.adaptor) {
653
1100
  return null;
654
1101
  }
655
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: getClassName5(""), children: [
656
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: getClassName5("label"), children: name === "_data" ? "External content" : label || name }),
657
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ExternalInput, { field, onChange, value })
1102
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName6(""), children: [
1103
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName6("label"), children: name === "_data" ? "External content" : label || name }),
1104
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ExternalInput, { field, onChange, value })
658
1105
  ] });
659
1106
  }
660
1107
  if (field.type === "select") {
661
1108
  if (!field.options) {
662
1109
  return null;
663
1110
  }
664
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: getClassName5(), children: [
665
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: getClassName5("label"), children: [
666
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: getClassName5("labelIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_feather3.ChevronDown, { size: 16 }) }),
1111
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { className: getClassName6(), children: [
1112
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName6("label"), children: [
1113
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName6("labelIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_feather3.ChevronDown, { size: 16 }) }),
667
1114
  label || name
668
1115
  ] }),
669
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1116
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
670
1117
  "select",
671
1118
  {
672
- className: getClassName5("input"),
1119
+ className: getClassName6("input"),
673
1120
  onChange: (e) => {
674
1121
  if (e.currentTarget.value === "true" || e.currentTarget.value === "false") {
675
1122
  onChange(Boolean(e.currentTarget.value));
@@ -678,7 +1125,7 @@ var InputOrGroup = ({
678
1125
  onChange(e.currentTarget.value);
679
1126
  },
680
1127
  value,
681
- children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1128
+ children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
682
1129
  "option",
683
1130
  {
684
1131
  label: option.label,
@@ -691,18 +1138,18 @@ var InputOrGroup = ({
691
1138
  ] });
692
1139
  }
693
1140
  if (field.type === "textarea") {
694
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: getClassName5({ readOnly }), children: [
695
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: getClassName5("label"), children: [
696
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: getClassName5("labelIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_feather3.Type, { size: 16 }) }),
1141
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { className: getClassName6({ readOnly }), children: [
1142
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName6("label"), children: [
1143
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName6("labelIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_feather3.Type, { size: 16 }) }),
697
1144
  label || name
698
1145
  ] }),
699
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1146
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
700
1147
  "textarea",
701
1148
  {
702
- className: getClassName5("input"),
1149
+ className: getClassName6("input"),
703
1150
  autoComplete: "off",
704
1151
  name,
705
- value,
1152
+ value: typeof value === "undefined" ? "" : value,
706
1153
  onChange: (e) => onChange(e.currentTarget.value),
707
1154
  readOnly,
708
1155
  rows: 5
@@ -714,20 +1161,21 @@ var InputOrGroup = ({
714
1161
  if (!field.options) {
715
1162
  return null;
716
1163
  }
717
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: getClassName5(), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: getClassName5("radioGroup"), children: [
718
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: getClassName5("label"), children: [
719
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: getClassName5("labelIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_feather3.CheckCircle, { size: 16 }) }),
1164
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName6(), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName6("radioGroup"), children: [
1165
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName6("label"), children: [
1166
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName6("labelIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_feather3.CheckCircle, { size: 16 }) }),
720
1167
  field.label || name
721
1168
  ] }),
722
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: getClassName5("radioGroupItems"), children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1169
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName6("radioGroupItems"), children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
723
1170
  "label",
724
1171
  {
725
- className: getClassName5("radio"),
1172
+ className: getClassName6("radio"),
726
1173
  children: [
727
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1174
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
728
1175
  "input",
729
1176
  {
730
1177
  type: "radio",
1178
+ className: getClassName6("radioInput"),
731
1179
  value: option.value,
732
1180
  name,
733
1181
  onChange: (e) => {
@@ -741,7 +1189,7 @@ var InputOrGroup = ({
741
1189
  defaultChecked: value === option.value
742
1190
  }
743
1191
  ),
744
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: getClassName5("radioInner"), children: option.label || option.value })
1192
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName6("radioInner"), children: option.label || option.value })
745
1193
  ]
746
1194
  },
747
1195
  option.label + option.value
@@ -752,7 +1200,7 @@ var InputOrGroup = ({
752
1200
  if (!field.render) {
753
1201
  return null;
754
1202
  }
755
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: getClassName5(), children: field.render({
1203
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName6(), children: field.render({
756
1204
  field,
757
1205
  name,
758
1206
  value,
@@ -760,23 +1208,29 @@ var InputOrGroup = ({
760
1208
  readOnly
761
1209
  }) });
762
1210
  }
763
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: getClassName5({ readOnly }), children: [
764
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: getClassName5("label"), children: [
765
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: getClassName5("labelIcon"), children: [
766
- field.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_feather3.Type, { size: 16 }),
767
- field.type === "number" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_feather3.Hash, { size: 16 })
1211
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { className: getClassName6({ readOnly }), children: [
1212
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName6("label"), children: [
1213
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassName6("labelIcon"), children: [
1214
+ field.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_feather3.Type, { size: 16 }),
1215
+ field.type === "number" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_feather3.Hash, { size: 16 })
768
1216
  ] }),
769
1217
  label || name
770
1218
  ] }),
771
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1219
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
772
1220
  "input",
773
1221
  {
774
- className: getClassName5("input"),
1222
+ className: getClassName6("input"),
775
1223
  autoComplete: "off",
776
1224
  type: field.type,
777
1225
  name,
778
- value,
779
- onChange: (e) => onChange(e.currentTarget.value),
1226
+ value: typeof value === "undefined" ? "" : value,
1227
+ onChange: (e) => {
1228
+ if (field.type === "number") {
1229
+ onChange(Number(e.currentTarget.value));
1230
+ } else {
1231
+ onChange(e.currentTarget.value);
1232
+ }
1233
+ },
780
1234
  readOnly
781
1235
  }
782
1236
  )
@@ -789,220 +1243,644 @@ var import_react_beautiful_dnd3 = require("react-beautiful-dnd");
789
1243
 
790
1244
  // css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
791
1245
  init_react_import();
792
- var styles_module_default4 = { "ComponentList": "_ComponentList_1sym6_1", "ComponentList-item": "_ComponentList-item_1sym6_8", "ComponentList-itemShadow": "_ComponentList-itemShadow_1sym6_9", "ComponentList-itemIcon": "_ComponentList-itemIcon_1sym6_28" };
1246
+ var styles_module_default5 = { "ComponentList": "_ComponentList_1ybn0_1", "ComponentList-item": "_ComponentList-item_1ybn0_9", "ComponentList-itemShadow": "_ComponentList-itemShadow_1ybn0_10", "ComponentList-itemIcon": "_ComponentList-itemIcon_1ybn0_28" };
793
1247
 
794
1248
  // components/ComponentList/index.tsx
795
1249
  var import_react_feather4 = require("react-feather");
796
- var import_jsx_runtime7 = require("react/jsx-runtime");
797
- var getClassName6 = get_class_name_factory_default("ComponentList", styles_module_default4);
1250
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1251
+ var getClassName7 = get_class_name_factory_default("ComponentList", styles_module_default5);
798
1252
  var ComponentList = ({ config }) => {
799
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DroppableStrictMode_default, { droppableId: "component-list", isDropDisabled: true, children: (provided, snapshot) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1253
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DroppableStrictMode_default, { droppableId: "component-list", isDropDisabled: true, children: (provided, snapshot) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
800
1254
  "div",
801
1255
  __spreadProps(__spreadValues({}, provided.droppableProps), {
802
1256
  ref: provided.innerRef,
803
- className: getClassName6(),
804
- children: Object.keys(config.components).map((componentKey, i) => {
805
- const componentConfig = config[componentKey];
806
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
807
- import_react_beautiful_dnd3.Draggable,
808
- {
809
- draggableId: componentKey,
810
- index: i,
811
- children: (provided2, snapshot2) => {
812
- var _a;
813
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
814
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
815
- "div",
816
- __spreadProps(__spreadValues(__spreadValues({
817
- ref: provided2.innerRef
818
- }, provided2.draggableProps), provided2.dragHandleProps), {
819
- className: getClassName6("item"),
820
- style: __spreadProps(__spreadValues({}, provided2.draggableProps.style), {
821
- transform: snapshot2.isDragging ? (_a = provided2.draggableProps.style) == null ? void 0 : _a.transform : "translate(0px, 0px)"
822
- }),
823
- children: [
824
- componentKey,
825
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName6("itemIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_feather4.Grid, { size: 18 }) })
826
- ]
827
- })
828
- ),
829
- snapshot2.isDragging && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
830
- "div",
831
- {
832
- className: getClassName6("itemShadow"),
833
- style: { transform: "none !important" },
834
- children: [
835
- componentKey,
836
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName6("itemIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_feather4.Grid, { size: 18 }) })
837
- ]
838
- }
839
- )
840
- ] });
841
- }
842
- },
843
- componentKey
844
- );
845
- })
1257
+ className: getClassName7(),
1258
+ children: [
1259
+ Object.keys(config.components).map((componentKey, i) => {
1260
+ const componentConfig = config[componentKey];
1261
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1262
+ import_react_beautiful_dnd3.Draggable,
1263
+ {
1264
+ draggableId: componentKey,
1265
+ index: i,
1266
+ children: (provided2, snapshot2) => {
1267
+ var _a;
1268
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
1269
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1270
+ "div",
1271
+ __spreadProps(__spreadValues(__spreadValues({
1272
+ ref: provided2.innerRef
1273
+ }, provided2.draggableProps), provided2.dragHandleProps), {
1274
+ className: getClassName7("item"),
1275
+ style: __spreadProps(__spreadValues({}, provided2.draggableProps.style), {
1276
+ transform: snapshot2.isDragging ? (_a = provided2.draggableProps.style) == null ? void 0 : _a.transform : "translate(0px, 0px)"
1277
+ }),
1278
+ children: [
1279
+ componentKey,
1280
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassName7("itemIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_feather4.Grid, { size: 18 }) })
1281
+ ]
1282
+ })
1283
+ ),
1284
+ snapshot2.isDragging && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
1285
+ "div",
1286
+ {
1287
+ className: getClassName7("itemShadow"),
1288
+ style: { transform: "none !important" },
1289
+ children: [
1290
+ componentKey,
1291
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassName7("itemIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_feather4.Grid, { size: 18 }) })
1292
+ ]
1293
+ }
1294
+ )
1295
+ ] });
1296
+ }
1297
+ },
1298
+ componentKey
1299
+ );
1300
+ }),
1301
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: { display: "none" }, children: provided.placeholder })
1302
+ ]
846
1303
  })
847
1304
  ) });
848
1305
  };
849
1306
 
850
- // components/OutlineList/index.tsx
1307
+ // lib/use-placeholder-style.ts
1308
+ init_react_import();
1309
+ var import_react10 = require("react");
1310
+ var usePlaceholderStyle = () => {
1311
+ const queryAttr = "data-rbd-drag-handle-draggable-id";
1312
+ const [placeholderStyle, setPlaceholderStyle] = (0, import_react10.useState)();
1313
+ const onDragStartOrUpdate = (draggedItem) => {
1314
+ var _a;
1315
+ const draggableId = draggedItem.draggableId;
1316
+ const destinationIndex = (draggedItem.destination || draggedItem.source).index;
1317
+ const droppableId = (draggedItem.destination || draggedItem.source).droppableId;
1318
+ const domQuery = `[${queryAttr}='${draggableId}']`;
1319
+ const draggedDOM = document.querySelector(domQuery);
1320
+ if (!draggedDOM) {
1321
+ return;
1322
+ }
1323
+ const targetListElement = document.querySelector(
1324
+ `[data-rbd-droppable-id='${droppableId}']`
1325
+ );
1326
+ const { clientHeight } = draggedDOM;
1327
+ if (!targetListElement) {
1328
+ return;
1329
+ }
1330
+ let clientY = 0;
1331
+ const isSameDroppable = draggedItem.source.droppableId === ((_a = draggedItem.destination) == null ? void 0 : _a.droppableId);
1332
+ if (destinationIndex > 0) {
1333
+ const end = destinationIndex > draggedItem.source.index && isSameDroppable ? destinationIndex + 1 : destinationIndex;
1334
+ const children = Array.from(targetListElement.children).filter(
1335
+ (item) => item !== draggedDOM && item.getAttributeNames().indexOf("data-puck-placeholder") === -1 && item.getAttributeNames().indexOf("data-rbd-placeholder-context-id") === -1
1336
+ ).slice(0, end);
1337
+ clientY = children.reduce(
1338
+ (total, item) => total + item.clientHeight + parseInt(window.getComputedStyle(item).marginTop.replace("px", "")) + parseInt(
1339
+ window.getComputedStyle(item).marginBottom.replace("px", "")
1340
+ ),
1341
+ 0
1342
+ );
1343
+ }
1344
+ setPlaceholderStyle({
1345
+ position: "absolute",
1346
+ top: clientY,
1347
+ left: 0,
1348
+ height: clientHeight,
1349
+ width: "100%"
1350
+ });
1351
+ };
1352
+ return { onDragStartOrUpdate, placeholderStyle };
1353
+ };
1354
+
1355
+ // components/SidebarSection/index.tsx
851
1356
  init_react_import();
852
1357
 
853
- // css-module:/home/runner/work/puck/puck/packages/core/components/OutlineList/styles.module.css#css-module
1358
+ // css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
854
1359
  init_react_import();
855
- var styles_module_default5 = { "OutlineList": "_OutlineList_gor6f_1", "OutlineList-clickableItem": "_OutlineList-clickableItem_gor6f_36" };
1360
+ var styles_module_default6 = { "SidebarSection": "_SidebarSection_ivnrs_1", "SidebarSection-title": "_SidebarSection-title_ivnrs_11", "SidebarSection-content": "_SidebarSection-content_ivnrs_18", "SidebarSection--noPadding": "_SidebarSection--noPadding_ivnrs_23", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_ivnrs_32", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_ivnrs_43", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_ivnrs_32", "SidebarSection-heading": "_SidebarSection-heading_ivnrs_55" };
856
1361
 
857
- // components/OutlineList/index.tsx
858
- var import_jsx_runtime8 = require("react/jsx-runtime");
859
- var getClassName7 = get_class_name_factory_default("OutlineList", styles_module_default5);
860
- var OutlineList = ({ children }) => {
861
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { className: getClassName7(), children });
862
- };
863
- OutlineList.Clickable = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName7("clickableItem"), children });
864
- OutlineList.Item = ({
865
- children,
866
- onClick
867
- }) => {
868
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
869
- "li",
1362
+ // components/Heading/index.tsx
1363
+ init_react_import();
1364
+
1365
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Heading/styles.module.css#css-module
1366
+ init_react_import();
1367
+ var styles_module_default7 = { "Heading": "_Heading_1y35v_1", "Heading--xxxxl": "_Heading--xxxxl_1y35v_12", "Heading--xxxl": "_Heading--xxxl_1y35v_18", "Heading--xxl": "_Heading--xxl_1y35v_22", "Heading--xl": "_Heading--xl_1y35v_26", "Heading--l": "_Heading--l_1y35v_30", "Heading--m": "_Heading--m_1y35v_34", "Heading--s": "_Heading--s_1y35v_38", "Heading--xs": "_Heading--xs_1y35v_42" };
1368
+
1369
+ // components/Heading/index.tsx
1370
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1371
+ var getClassName8 = get_class_name_factory_default("Heading", styles_module_default7);
1372
+ var Heading = ({ children, rank, size = "m" }) => {
1373
+ const Tag = rank ? `h${rank}` : "span";
1374
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1375
+ Tag,
870
1376
  {
871
- className: onClick ? getClassName7("clickableItem") : "",
872
- onClick,
1377
+ className: getClassName8({
1378
+ [size]: true
1379
+ }),
873
1380
  children
874
1381
  }
875
1382
  );
876
1383
  };
877
1384
 
878
- // lib/use-placeholder-style.ts
1385
+ // components/SidebarSection/index.tsx
1386
+ var import_react_feather5 = require("react-feather");
1387
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1388
+ var getClassName9 = get_class_name_factory_default("SidebarSection", styles_module_default6);
1389
+ var SidebarSection = ({
1390
+ children,
1391
+ title,
1392
+ background,
1393
+ breadcrumbs = [],
1394
+ breadcrumbClick,
1395
+ noPadding
1396
+ }) => {
1397
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName9({ noPadding }), style: { background }, children: [
1398
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName9("title"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName9("breadcrumbs"), children: [
1399
+ breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName9("breadcrumb"), children: [
1400
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1401
+ "div",
1402
+ {
1403
+ className: getClassName9("breadcrumbLabel"),
1404
+ onClick: () => breadcrumbClick && breadcrumbClick(breadcrumb),
1405
+ children: breadcrumb.label
1406
+ }
1407
+ ),
1408
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_feather5.ChevronRight, { size: 16 })
1409
+ ] }, i)),
1410
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName9("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Heading, { rank: 2, size: "xs", children: title }) })
1411
+ ] }) }),
1412
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName9("content"), children })
1413
+ ] });
1414
+ };
1415
+
1416
+ // components/Puck/index.tsx
1417
+ var import_react_feather7 = require("react-feather");
1418
+
1419
+ // lib/reducer.ts
879
1420
  init_react_import();
880
- var import_react7 = require("react");
881
- var usePlaceholderStyle = () => {
882
- const queryAttr = "data-rbd-drag-handle-draggable-id";
883
- const [placeholderStyle, setPlaceholderStyle] = (0, import_react7.useState)();
884
- const onDragUpdate = (update) => {
885
- if (!update.destination) {
886
- return;
1421
+
1422
+ // lib/insert.ts
1423
+ init_react_import();
1424
+ var insert = (list, index, item) => {
1425
+ const result = Array.from(list);
1426
+ result.splice(index, 0, item);
1427
+ return result;
1428
+ };
1429
+
1430
+ // lib/remove.ts
1431
+ init_react_import();
1432
+ var remove = (list, index) => {
1433
+ const result = Array.from(list);
1434
+ result.splice(index, 1);
1435
+ return result;
1436
+ };
1437
+
1438
+ // lib/reduce-related-zones.ts
1439
+ init_react_import();
1440
+
1441
+ // lib/generate-id.ts
1442
+ init_react_import();
1443
+ var import_crypto = require("crypto");
1444
+ var generateId = (type) => `${type}-${(0, import_crypto.randomBytes)(20).toString("hex")}`;
1445
+
1446
+ // lib/reduce-related-zones.ts
1447
+ var reduceRelatedZones = (item, data, fn) => {
1448
+ return __spreadProps(__spreadValues({}, data), {
1449
+ zones: Object.keys(data.zones || {}).reduce(
1450
+ (acc, key) => {
1451
+ const [parentId] = getZoneId(key);
1452
+ if (parentId === item.props.id) {
1453
+ const zones = data.zones;
1454
+ return fn(acc, key, zones[key]);
1455
+ }
1456
+ return __spreadProps(__spreadValues({}, acc), { [key]: data.zones[key] });
1457
+ },
1458
+ {}
1459
+ )
1460
+ });
1461
+ };
1462
+ var findRelatedByZoneId = (zoneId, data) => {
1463
+ const [zoneParentId] = getZoneId(zoneId);
1464
+ return (data.zones[zoneId] || []).reduce((acc, zoneItem) => {
1465
+ const related = findRelatedByItem(zoneItem, data);
1466
+ if (zoneItem.props.id === zoneParentId) {
1467
+ return __spreadProps(__spreadValues(__spreadValues({}, acc), related), { [zoneId]: zoneItem });
1468
+ }
1469
+ return __spreadValues(__spreadValues({}, acc), related);
1470
+ }, {});
1471
+ };
1472
+ var findRelatedByItem = (item, data) => {
1473
+ return Object.keys(data.zones || {}).reduce((acc, zoneId) => {
1474
+ const [zoneParentId] = getZoneId(zoneId);
1475
+ if (item.props.id === zoneParentId) {
1476
+ const related = findRelatedByZoneId(zoneId, data);
1477
+ return __spreadProps(__spreadValues(__spreadValues({}, acc), related), {
1478
+ [zoneId]: data.zones[zoneId]
1479
+ });
1480
+ }
1481
+ return acc;
1482
+ }, {});
1483
+ };
1484
+ var removeRelatedZones = (item, data) => {
1485
+ const newData = __spreadValues({}, data);
1486
+ const related = findRelatedByItem(item, data);
1487
+ Object.keys(related).forEach((key) => {
1488
+ delete newData.zones[key];
1489
+ });
1490
+ return newData;
1491
+ };
1492
+ var duplicateRelatedZones = (item, data, newId) => {
1493
+ return reduceRelatedZones(item, data, (acc, key, zone) => {
1494
+ const dupedZone = zone.map((zoneItem) => __spreadProps(__spreadValues({}, zoneItem), {
1495
+ props: __spreadProps(__spreadValues({}, zoneItem.props), { id: generateId(zoneItem.type) })
1496
+ }));
1497
+ const dupeOfDupes = dupedZone.reduce(
1498
+ (dupeOfDupes2, item2, index) => __spreadValues(__spreadValues({}, dupeOfDupes2), duplicateRelatedZones(zone[index], data, item2.props.id).zones),
1499
+ acc
1500
+ );
1501
+ const [_, zoneId] = getZoneId(key);
1502
+ return __spreadProps(__spreadValues({}, dupeOfDupes), {
1503
+ [key]: zone,
1504
+ [`${newId}:${zoneId}`]: dupedZone
1505
+ });
1506
+ });
1507
+ };
1508
+
1509
+ // lib/reducer.ts
1510
+ var zoneCache = {};
1511
+ var addToZoneCache = (key, data) => {
1512
+ zoneCache[key] = data;
1513
+ };
1514
+ var createReducer = ({ config }) => (data, action) => {
1515
+ if (action.type === "insert") {
1516
+ const emptyComponentData = {
1517
+ type: action.componentType,
1518
+ props: __spreadProps(__spreadValues({}, config.components[action.componentType].defaultProps || {}), {
1519
+ id: generateId(action.componentType)
1520
+ })
1521
+ };
1522
+ if (action.destinationZone === rootDroppableId) {
1523
+ return __spreadProps(__spreadValues({}, data), {
1524
+ content: insert(
1525
+ data.content,
1526
+ action.destinationIndex,
1527
+ emptyComponentData
1528
+ )
1529
+ });
1530
+ }
1531
+ const newData = setupZone(data, action.destinationZone);
1532
+ return __spreadProps(__spreadValues({}, data), {
1533
+ zones: __spreadProps(__spreadValues({}, newData.zones), {
1534
+ [action.destinationZone]: insert(
1535
+ newData.zones[action.destinationZone],
1536
+ action.destinationIndex,
1537
+ emptyComponentData
1538
+ )
1539
+ })
1540
+ });
1541
+ }
1542
+ if (action.type === "duplicate") {
1543
+ const item = getItem(
1544
+ { index: action.sourceIndex, zone: action.sourceZone },
1545
+ data
1546
+ );
1547
+ const newItem = __spreadProps(__spreadValues({}, item), {
1548
+ props: __spreadProps(__spreadValues({}, item.props), {
1549
+ id: generateId(item.type)
1550
+ })
1551
+ });
1552
+ const dataWithRelatedDuplicated = duplicateRelatedZones(
1553
+ item,
1554
+ data,
1555
+ newItem.props.id
1556
+ );
1557
+ if (action.sourceZone === rootDroppableId) {
1558
+ return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
1559
+ content: insert(data.content, action.sourceIndex + 1, newItem)
1560
+ });
1561
+ }
1562
+ return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
1563
+ zones: __spreadProps(__spreadValues({}, dataWithRelatedDuplicated.zones), {
1564
+ [action.sourceZone]: insert(
1565
+ dataWithRelatedDuplicated.zones[action.sourceZone],
1566
+ action.sourceIndex + 1,
1567
+ newItem
1568
+ )
1569
+ })
1570
+ });
1571
+ }
1572
+ if (action.type === "reorder") {
1573
+ if (action.destinationZone === rootDroppableId) {
1574
+ return __spreadProps(__spreadValues({}, data), {
1575
+ content: reorder(
1576
+ data.content,
1577
+ action.sourceIndex,
1578
+ action.destinationIndex
1579
+ )
1580
+ });
887
1581
  }
888
- const draggableId = update.draggableId;
889
- const destinationIndex = update.destination.index;
890
- const domQuery = `[${queryAttr}='${draggableId}']`;
891
- const draggedDOM = document.querySelector(domQuery);
892
- if (!draggedDOM) {
893
- return;
1582
+ const newData = setupZone(data, action.destinationZone);
1583
+ return __spreadProps(__spreadValues({}, data), {
1584
+ zones: __spreadProps(__spreadValues({}, newData.zones), {
1585
+ [action.destinationZone]: reorder(
1586
+ newData.zones[action.destinationZone],
1587
+ action.sourceIndex,
1588
+ action.destinationIndex
1589
+ )
1590
+ })
1591
+ });
1592
+ }
1593
+ if (action.type === "move") {
1594
+ const newData = setupZone(
1595
+ setupZone(data, action.sourceZone),
1596
+ action.destinationZone
1597
+ );
1598
+ const item = getItem(
1599
+ { zone: action.sourceZone, index: action.sourceIndex },
1600
+ newData
1601
+ );
1602
+ if (action.sourceZone === rootDroppableId) {
1603
+ return __spreadProps(__spreadValues({}, newData), {
1604
+ content: remove(newData.content, action.sourceIndex),
1605
+ zones: __spreadProps(__spreadValues({}, newData.zones), {
1606
+ [action.destinationZone]: insert(
1607
+ newData.zones[action.destinationZone],
1608
+ action.destinationIndex,
1609
+ item
1610
+ )
1611
+ })
1612
+ });
894
1613
  }
895
- const targetListElement = document.querySelector("#puck-drop-zone");
896
- const { clientHeight } = draggedDOM;
897
- if (!targetListElement) {
898
- return;
1614
+ if (action.destinationZone === rootDroppableId) {
1615
+ return __spreadProps(__spreadValues({}, newData), {
1616
+ content: insert(newData.content, action.destinationIndex, item),
1617
+ zones: __spreadProps(__spreadValues({}, newData.zones), {
1618
+ [action.sourceZone]: remove(
1619
+ newData.zones[action.sourceZone],
1620
+ action.sourceIndex
1621
+ )
1622
+ })
1623
+ });
899
1624
  }
900
- let clientY = 0;
901
- if (destinationIndex > 0) {
902
- const children = Array.from(targetListElement.children).filter((item) => item !== draggedDOM).slice(0, destinationIndex);
903
- clientY = children.reduce(
904
- (total, item) => total + item.clientHeight + parseInt(window.getComputedStyle(item).marginTop.replace("px", "")) + parseInt(
905
- window.getComputedStyle(item).marginBottom.replace("px", "")
1625
+ return __spreadProps(__spreadValues({}, newData), {
1626
+ zones: __spreadProps(__spreadValues({}, newData.zones), {
1627
+ [action.sourceZone]: remove(
1628
+ newData.zones[action.sourceZone],
1629
+ action.sourceIndex
906
1630
  ),
907
- 0
908
- );
1631
+ [action.destinationZone]: insert(
1632
+ newData.zones[action.destinationZone],
1633
+ action.destinationIndex,
1634
+ item
1635
+ )
1636
+ })
1637
+ });
1638
+ }
1639
+ if (action.type === "replace") {
1640
+ if (action.destinationZone === rootDroppableId) {
1641
+ return __spreadProps(__spreadValues({}, data), {
1642
+ content: replace(data.content, action.destinationIndex, action.data)
1643
+ });
909
1644
  }
910
- setPlaceholderStyle({
911
- position: "absolute",
912
- top: clientY,
913
- left: 0,
914
- height: clientHeight,
915
- width: "100%"
1645
+ const newData = setupZone(data, action.destinationZone);
1646
+ return __spreadProps(__spreadValues({}, newData), {
1647
+ zones: __spreadProps(__spreadValues({}, newData.zones), {
1648
+ [action.destinationZone]: replace(
1649
+ newData.zones[action.destinationZone],
1650
+ action.destinationIndex,
1651
+ action.data
1652
+ )
1653
+ })
916
1654
  });
917
- };
918
- return { onDragUpdate, placeholderStyle };
1655
+ }
1656
+ if (action.type === "remove") {
1657
+ const item = getItem({ index: action.index, zone: action.zone }, data);
1658
+ const dataWithRelatedRemoved = setupZone(
1659
+ removeRelatedZones(item, data),
1660
+ action.zone
1661
+ );
1662
+ if (action.zone === rootDroppableId) {
1663
+ return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
1664
+ content: remove(data.content, action.index)
1665
+ });
1666
+ }
1667
+ return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
1668
+ zones: __spreadProps(__spreadValues({}, dataWithRelatedRemoved.zones), {
1669
+ [action.zone]: remove(
1670
+ dataWithRelatedRemoved.zones[action.zone],
1671
+ action.index
1672
+ )
1673
+ })
1674
+ });
1675
+ }
1676
+ if (action.type === "registerZone") {
1677
+ if (zoneCache[action.zone]) {
1678
+ return __spreadProps(__spreadValues({}, data), {
1679
+ zones: __spreadProps(__spreadValues({}, data.zones), {
1680
+ [action.zone]: zoneCache[action.zone]
1681
+ })
1682
+ });
1683
+ }
1684
+ return setupZone(data, action.zone);
1685
+ }
1686
+ if (action.type === "unregisterZone") {
1687
+ const _zones = __spreadValues({}, data.zones || {});
1688
+ if (_zones[action.zone]) {
1689
+ zoneCache[action.zone] = _zones[action.zone];
1690
+ delete _zones[action.zone];
1691
+ }
1692
+ return __spreadProps(__spreadValues({}, data), { zones: _zones });
1693
+ }
1694
+ if (action.type === "set") {
1695
+ return __spreadValues(__spreadValues({}, data), action.data);
1696
+ }
1697
+ return data;
919
1698
  };
920
1699
 
921
- // components/SidebarSection/index.tsx
1700
+ // components/LayerTree/index.tsx
922
1701
  init_react_import();
923
1702
 
924
- // css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
1703
+ // css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
925
1704
  init_react_import();
926
- var styles_module_default6 = { "SidebarSection": "_SidebarSection_1y6bv_1", "SidebarSection-title": "_SidebarSection-title_1y6bv_11", "SidebarSection-content": "_SidebarSection-content_1y6bv_17", "SidebarSection--noPadding": "_SidebarSection--noPadding_1y6bv_22", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_1y6bv_31" };
1705
+ var styles_module_default8 = { "LayerTree": "_LayerTree_1dcmd_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_1dcmd_11", "LayerTree-helper": "_LayerTree-helper_1dcmd_17", "Layer": "_Layer_1dcmd_1", "Layer-inner": "_Layer-inner_1dcmd_29", "Layer--containsZone": "_Layer--containsZone_1dcmd_35", "Layer-clickable": "_Layer-clickable_1dcmd_39", "Layer--isSelected": "_Layer--isSelected_1dcmd_48", "Layer--isHovering": "_Layer--isHovering_1dcmd_49", "Layer-chevron": "_Layer-chevron_1dcmd_65", "Layer--childIsSelected": "_Layer--childIsSelected_1dcmd_66", "Layer-zones": "_Layer-zones_1dcmd_70", "Layer-title": "_Layer-title_1dcmd_84", "Layer-icon": "_Layer-icon_1dcmd_92", "Layer-zoneIcon": "_Layer-zoneIcon_1dcmd_97" };
927
1706
 
928
- // components/Heading/index.tsx
1707
+ // lib/scroll-into-view.ts
929
1708
  init_react_import();
1709
+ var scrollIntoView = (el) => {
1710
+ const oldStyle = __spreadValues({}, el.style);
1711
+ el.style.scrollMargin = "256px";
1712
+ if (el) {
1713
+ el == null ? void 0 : el.scrollIntoView({ behavior: "smooth" });
1714
+ el.style.scrollMargin = oldStyle.scrollMargin || "";
1715
+ }
1716
+ };
930
1717
 
931
- // css-module:/home/runner/work/puck/puck/packages/core/components/Heading/styles.module.css#css-module
1718
+ // components/LayerTree/index.tsx
1719
+ var import_react_feather6 = require("react-feather");
1720
+ var import_react11 = require("react");
1721
+
1722
+ // lib/find-zones-for-area.ts
932
1723
  init_react_import();
933
- var styles_module_default7 = { "Heading": "_Heading_1y35v_1", "Heading--xxxxl": "_Heading--xxxxl_1y35v_12", "Heading--xxxl": "_Heading--xxxl_1y35v_18", "Heading--xxl": "_Heading--xxl_1y35v_22", "Heading--xl": "_Heading--xl_1y35v_26", "Heading--l": "_Heading--l_1y35v_30", "Heading--m": "_Heading--m_1y35v_34", "Heading--s": "_Heading--s_1y35v_38", "Heading--xs": "_Heading--xs_1y35v_42" };
1724
+ var findZonesForArea = (data, area) => {
1725
+ const { zones = {} } = data;
1726
+ const result = Object.keys(zones).filter(
1727
+ (zoneId) => getZoneId(zoneId)[0] === area
1728
+ );
1729
+ return result.reduce((acc, key) => {
1730
+ return __spreadProps(__spreadValues({}, acc), { [key]: zones[key] });
1731
+ }, {});
1732
+ };
934
1733
 
935
- // components/Heading/index.tsx
936
- var import_jsx_runtime9 = require("react/jsx-runtime");
937
- var getClassName8 = get_class_name_factory_default("Heading", styles_module_default7);
938
- var Heading = ({ children, rank, size = "m" }) => {
939
- const Tag = rank ? `h${rank}` : "span";
940
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
941
- Tag,
942
- {
943
- className: getClassName8({
944
- [size]: true
945
- }),
946
- children
1734
+ // lib/is-child-of-zone.ts
1735
+ init_react_import();
1736
+ var isChildOfZone = (item, maybeChild, ctx) => {
1737
+ var _a;
1738
+ const { data, pathData = {} } = ctx || {};
1739
+ return maybeChild && data ? !!((_a = pathData[maybeChild.props.id]) == null ? void 0 : _a.find((path) => {
1740
+ if (path.selector) {
1741
+ const pathItem = getItem(path.selector, data);
1742
+ return (pathItem == null ? void 0 : pathItem.props.id) === item.props.id;
947
1743
  }
948
- );
1744
+ return false;
1745
+ })) : false;
949
1746
  };
950
1747
 
951
- // components/SidebarSection/index.tsx
952
- var import_react_feather5 = require("react-feather");
953
- var import_jsx_runtime10 = require("react/jsx-runtime");
954
- var getClassName9 = get_class_name_factory_default("SidebarSection", styles_module_default6);
955
- var SidebarSection = ({
956
- children,
957
- title,
958
- background,
959
- breadcrumb,
960
- breadcrumbClick,
961
- noPadding
1748
+ // components/LayerTree/index.tsx
1749
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1750
+ var getClassName10 = get_class_name_factory_default("LayerTree", styles_module_default8);
1751
+ var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default8);
1752
+ var LayerTree = ({
1753
+ data,
1754
+ zoneContent,
1755
+ itemSelector,
1756
+ setItemSelector,
1757
+ zone,
1758
+ label
962
1759
  }) => {
963
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: getClassName9({ noPadding }), style: { background }, children: [
964
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: getClassName9("title"), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
965
- "span",
966
- {
967
- style: {
968
- display: "flex",
969
- gap: 4,
970
- alignItems: "center"
971
- },
972
- children: [
973
- breadcrumb && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
974
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
975
- "div",
976
- {
977
- className: getClassName9("breadcrumb"),
978
- onClick: breadcrumbClick,
979
- children: breadcrumb
980
- }
981
- ),
982
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_feather5.ChevronRight, { size: 16 })
983
- ] }),
984
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Heading, { rank: 2, size: "xs", children: title })
985
- ]
986
- }
987
- ) }),
988
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: getClassName9("content"), children })
1760
+ const zones = data.zones || {};
1761
+ const ctx = (0, import_react11.useContext)(dropZoneContext);
1762
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
1763
+ label && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassName10("zoneTitle"), children: [
1764
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName10("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_feather6.Layers, { size: "16" }) }),
1765
+ " ",
1766
+ label
1767
+ ] }),
1768
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("ul", { className: getClassName10(), children: [
1769
+ zoneContent.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName10("helper"), children: "No items" }),
1770
+ zoneContent.map((item, i) => {
1771
+ const isSelected = (itemSelector == null ? void 0 : itemSelector.index) === i && (itemSelector.zone === zone || itemSelector.zone === rootDroppableId && !zone);
1772
+ const zonesForItem = findZonesForArea(data, item.props.id);
1773
+ const containsZone = Object.keys(zonesForItem).length > 0;
1774
+ const {
1775
+ setHoveringArea = () => {
1776
+ },
1777
+ setHoveringComponent = () => {
1778
+ },
1779
+ hoveringComponent
1780
+ } = ctx || {};
1781
+ const selectedItem = itemSelector && data ? getItem(itemSelector, data) : null;
1782
+ const isHovering = hoveringComponent === item.props.id;
1783
+ const childIsSelected = isChildOfZone(item, selectedItem, ctx);
1784
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1785
+ "li",
1786
+ {
1787
+ className: getClassNameLayer({
1788
+ isSelected,
1789
+ isHovering,
1790
+ containsZone,
1791
+ childIsSelected
1792
+ }),
1793
+ children: [
1794
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1795
+ "div",
1796
+ {
1797
+ className: getClassNameLayer("clickable"),
1798
+ onClick: () => {
1799
+ if (isSelected) {
1800
+ setItemSelector(null);
1801
+ return;
1802
+ }
1803
+ setItemSelector({
1804
+ index: i,
1805
+ zone
1806
+ });
1807
+ const id = zoneContent[i].props.id;
1808
+ scrollIntoView(
1809
+ document.querySelector(
1810
+ `[data-rbd-drag-handle-draggable-id="draggable-${id}"]`
1811
+ )
1812
+ );
1813
+ },
1814
+ onMouseOver: (e) => {
1815
+ e.stopPropagation();
1816
+ setHoveringArea(item.props.id);
1817
+ setHoveringComponent(item.props.id);
1818
+ },
1819
+ onMouseOut: (e) => {
1820
+ e.stopPropagation();
1821
+ setHoveringArea(null);
1822
+ setHoveringComponent(null);
1823
+ },
1824
+ children: [
1825
+ containsZone && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1826
+ "div",
1827
+ {
1828
+ className: getClassNameLayer("chevron"),
1829
+ title: isSelected ? "Collapse" : "Expand",
1830
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_feather6.ChevronDown, { size: "12" })
1831
+ }
1832
+ ),
1833
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameLayer("title"), children: [
1834
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_feather6.Type, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_feather6.Grid, { size: "16" }) }),
1835
+ item.type
1836
+ ] })
1837
+ ]
1838
+ }
1839
+ ) }),
1840
+ containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1841
+ LayerTree,
1842
+ {
1843
+ data,
1844
+ zoneContent: zones[zoneKey],
1845
+ setItemSelector,
1846
+ itemSelector,
1847
+ zone: zoneKey,
1848
+ label: getZoneId(zoneKey)[1]
1849
+ }
1850
+ ) }, idx))
1851
+ ]
1852
+ },
1853
+ `${item.props.id}_${i}`
1854
+ );
1855
+ })
1856
+ ] })
989
1857
  ] });
990
1858
  };
991
1859
 
992
- // lib/scroll-into-view.ts
1860
+ // lib/area-contains-zones.ts
993
1861
  init_react_import();
994
- var scrollIntoView = (el) => {
995
- const oldStyle = __spreadValues({}, el.style);
996
- el.style.scrollMargin = "256px";
997
- if (el) {
998
- el == null ? void 0 : el.scrollIntoView({ behavior: "smooth" });
999
- el.style.scrollMargin = oldStyle.scrollMargin || "";
1862
+ var areaContainsZones = (data, area) => {
1863
+ const zones = Object.keys(findZonesForArea(data, area));
1864
+ return zones.length > 0;
1865
+ };
1866
+
1867
+ // lib/flush-zones.ts
1868
+ init_react_import();
1869
+ var flushZones = (data) => {
1870
+ const containsZones = typeof data.zones !== "undefined";
1871
+ if (containsZones) {
1872
+ Object.keys(data.zones || {}).forEach((zone) => {
1873
+ addToZoneCache(zone, data.zones[zone]);
1874
+ });
1875
+ return __spreadProps(__spreadValues({}, data), {
1876
+ zones: {}
1877
+ });
1000
1878
  }
1879
+ return data;
1001
1880
  };
1002
1881
 
1003
1882
  // components/Puck/index.tsx
1004
- var import_react_feather6 = require("react-feather");
1005
- var import_jsx_runtime11 = require("react/jsx-runtime");
1883
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1006
1884
  var defaultPageFields = {
1007
1885
  title: { type: "text" }
1008
1886
  };
@@ -1013,7 +1891,7 @@ var PluginRenderer = ({
1013
1891
  renderMethod
1014
1892
  }) => {
1015
1893
  return plugins.filter((item) => item[renderMethod]).map((item) => item[renderMethod]).reduce(
1016
- (accChildren, Item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Item, { data, children: accChildren }),
1894
+ (accChildren, Item) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Item, { data, children: accChildren }),
1017
1895
  children
1018
1896
  );
1019
1897
  };
@@ -1029,12 +1907,17 @@ function Puck({
1029
1907
  headerPath
1030
1908
  }) {
1031
1909
  var _a, _b;
1032
- const [data, setData] = (0, import_react8.useState)(initialData);
1033
- const [selectedIndex, setSelectedIndex] = (0, import_react8.useState)(null);
1034
- const Page = (0, import_react8.useCallback)(
1910
+ const [reducer] = (0, import_react12.useState)(() => createReducer({ config }));
1911
+ const [data, dispatch] = (0, import_react12.useReducer)(
1912
+ reducer,
1913
+ flushZones(initialData)
1914
+ );
1915
+ const [itemSelector, setItemSelector] = (0, import_react12.useState)(null);
1916
+ const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
1917
+ const Page = (0, import_react12.useCallback)(
1035
1918
  (pageProps) => {
1036
1919
  var _a2, _b2;
1037
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1920
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1038
1921
  PluginRenderer,
1039
1922
  {
1040
1923
  plugins,
@@ -1046,8 +1929,8 @@ function Puck({
1046
1929
  },
1047
1930
  [config.root]
1048
1931
  );
1049
- const PageFieldWrapper = (0, import_react8.useCallback)(
1050
- (props) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1932
+ const PageFieldWrapper = (0, import_react12.useCallback)(
1933
+ (props) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1051
1934
  PluginRenderer,
1052
1935
  {
1053
1936
  plugins,
@@ -1058,8 +1941,8 @@ function Puck({
1058
1941
  ),
1059
1942
  []
1060
1943
  );
1061
- const ComponentFieldWrapper = (0, import_react8.useCallback)(
1062
- (props) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1944
+ const ComponentFieldWrapper = (0, import_react12.useCallback)(
1945
+ (props) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1063
1946
  PluginRenderer,
1064
1947
  {
1065
1948
  plugins,
@@ -1070,396 +1953,372 @@ function Puck({
1070
1953
  ),
1071
1954
  []
1072
1955
  );
1073
- const FieldWrapper = selectedIndex !== null ? ComponentFieldWrapper : PageFieldWrapper;
1956
+ const FieldWrapper = itemSelector ? ComponentFieldWrapper : PageFieldWrapper;
1074
1957
  const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
1075
- let fields = selectedIndex !== null ? ((_b = config.components[data.content[selectedIndex].type]) == null ? void 0 : _b.fields) || {} : rootFields;
1076
- (0, import_react8.useEffect)(() => {
1958
+ let fields = selectedItem ? ((_b = config.components[selectedItem.type]) == null ? void 0 : _b.fields) || {} : rootFields;
1959
+ (0, import_react12.useEffect)(() => {
1077
1960
  if (onChange)
1078
1961
  onChange(data);
1079
1962
  }, [data]);
1080
- const { onDragUpdate, placeholderStyle } = usePlaceholderStyle();
1081
- const [leftSidebarVisible, setLeftSidebarVisible] = (0, import_react8.useState)(true);
1082
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "puck", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1963
+ const { onDragStartOrUpdate, placeholderStyle } = usePlaceholderStyle();
1964
+ const [leftSidebarVisible, setLeftSidebarVisible] = (0, import_react12.useState)(true);
1965
+ const [draggedItem, setDraggedItem] = (0, import_react12.useState)();
1966
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "puck", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1083
1967
  import_react_beautiful_dnd4.DragDropContext,
1084
1968
  {
1085
- onDragUpdate,
1969
+ onDragUpdate: (update) => {
1970
+ setDraggedItem(__spreadValues(__spreadValues({}, draggedItem), update));
1971
+ onDragStartOrUpdate(update);
1972
+ },
1973
+ onBeforeDragStart: (start) => {
1974
+ onDragStartOrUpdate(start);
1975
+ setItemSelector(null);
1976
+ },
1086
1977
  onDragEnd: (droppedItem) => {
1978
+ setDraggedItem(void 0);
1087
1979
  if (!droppedItem.destination) {
1088
- console.warn("No destination specified");
1089
1980
  return;
1090
1981
  }
1091
- if (droppedItem.source.droppableId === "component-list") {
1092
- const emptyComponentData = {
1093
- type: droppedItem.draggableId,
1094
- props: __spreadProps(__spreadValues({}, config.components[droppedItem.draggableId].defaultProps || {}), {
1095
- id: `${droppedItem.draggableId}-${(/* @__PURE__ */ new Date()).getTime()}`
1096
- // TODO make random string
1097
- })
1098
- };
1099
- const newData = __spreadValues({}, data);
1100
- newData.content.splice(
1101
- droppedItem.destination.index,
1102
- 0,
1103
- emptyComponentData
1104
- );
1105
- setData(newData);
1106
- setSelectedIndex(droppedItem.destination.index);
1982
+ if (droppedItem.source.droppableId === "component-list" && droppedItem.destination) {
1983
+ dispatch({
1984
+ type: "insert",
1985
+ componentType: droppedItem.draggableId,
1986
+ destinationIndex: droppedItem.destination.index,
1987
+ destinationZone: droppedItem.destination.droppableId
1988
+ });
1989
+ setItemSelector({
1990
+ index: droppedItem.destination.index,
1991
+ zone: droppedItem.destination.droppableId
1992
+ });
1993
+ return;
1107
1994
  } else {
1108
- setData(__spreadProps(__spreadValues({}, data), {
1109
- content: reorder(
1110
- data.content,
1111
- droppedItem.source.index,
1112
- droppedItem.destination.index
1113
- )
1114
- }));
1115
- setSelectedIndex(null);
1995
+ const { source, destination } = droppedItem;
1996
+ if (source.droppableId === destination.droppableId) {
1997
+ dispatch({
1998
+ type: "reorder",
1999
+ sourceIndex: source.index,
2000
+ destinationIndex: destination.index,
2001
+ destinationZone: destination.droppableId
2002
+ });
2003
+ } else {
2004
+ dispatch({
2005
+ type: "move",
2006
+ sourceZone: source.droppableId,
2007
+ sourceIndex: source.index,
2008
+ destinationIndex: destination.index,
2009
+ destinationZone: destination.droppableId
2010
+ });
2011
+ }
2012
+ setItemSelector({
2013
+ index: destination.index,
2014
+ zone: destination.droppableId
2015
+ });
1116
2016
  }
1117
2017
  },
1118
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1119
- "div",
2018
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2019
+ DropZoneProvider,
1120
2020
  {
1121
- style: {
1122
- display: "grid",
1123
- gridTemplateAreas: '"header header header" "left editor right"',
1124
- gridTemplateColumns: `${leftSidebarVisible ? "288px" : "0px"} auto 288px`,
1125
- gridTemplateRows: "min-content auto",
1126
- height: "100vh",
1127
- position: "fixed",
1128
- top: 0,
1129
- bottom: 0,
1130
- left: 0,
1131
- right: 0
2021
+ value: {
2022
+ data,
2023
+ itemSelector,
2024
+ setItemSelector,
2025
+ config,
2026
+ dispatch,
2027
+ draggedItem,
2028
+ placeholderStyle,
2029
+ mode: "edit",
2030
+ areaId: "root"
1132
2031
  },
1133
- children: [
1134
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1135
- "header",
2032
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(dropZoneContext.Consumer, { children: (ctx) => {
2033
+ let path = (ctx == null ? void 0 : ctx.pathData) && selectedItem ? ctx == null ? void 0 : ctx.pathData[selectedItem == null ? void 0 : selectedItem.props.id] : void 0;
2034
+ if (path) {
2035
+ path = [{ label: "Page", selector: null }, ...path];
2036
+ path = path.slice(path.length - 2, path.length - 1);
2037
+ }
2038
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2039
+ "div",
1136
2040
  {
1137
2041
  style: {
1138
- gridArea: "header",
1139
- borderBottom: "1px solid var(--puck-color-grey-8)"
2042
+ display: "grid",
2043
+ gridTemplateAreas: '"header header header" "left editor right"',
2044
+ gridTemplateColumns: `${leftSidebarVisible ? "288px" : "0px"} auto 288px`,
2045
+ gridTemplateRows: "min-content auto",
2046
+ height: "100vh",
2047
+ position: "fixed",
2048
+ top: 0,
2049
+ bottom: 0,
2050
+ left: 0,
2051
+ right: 0
1140
2052
  },
1141
- children: renderHeader ? renderHeader({
1142
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1143
- Button,
2053
+ children: [
2054
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2055
+ "header",
1144
2056
  {
1145
- onClick: () => {
1146
- onPublish(data);
2057
+ style: {
2058
+ gridArea: "header",
2059
+ borderBottom: "1px solid var(--puck-color-grey-8)"
1147
2060
  },
1148
- icon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_feather6.Globe, { size: "14px" }),
1149
- children: "Publish"
1150
- }
1151
- ),
1152
- data,
1153
- setData
1154
- }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1155
- "div",
1156
- {
1157
- style: {
1158
- display: "grid",
1159
- padding: 16,
1160
- gridTemplateAreas: '"left middle right"',
1161
- gridTemplateColumns: "288px auto 288px",
1162
- gridTemplateRows: "auto"
1163
- },
1164
- children: [
1165
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1166
- "div",
1167
- {
1168
- style: {
1169
- display: "flex",
1170
- gap: 16
1171
- },
1172
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1173
- IconButton,
1174
- {
1175
- onClick: () => setLeftSidebarVisible(!leftSidebarVisible),
1176
- title: "Toggle left sidebar",
1177
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_feather6.Sidebar, {})
1178
- }
1179
- )
1180
- }
1181
- ),
1182
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1183
- "div",
1184
- {
1185
- style: {
1186
- display: "flex",
1187
- justifyContent: "center",
1188
- alignItems: "center"
1189
- },
1190
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Heading, { rank: 2, size: "xs", children: [
1191
- headerTitle || data.root.title || "Page",
1192
- headerPath && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("small", { style: { fontWeight: 400, marginLeft: 4 }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("code", { children: headerPath }) })
1193
- ] })
1194
- }
1195
- ),
1196
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2061
+ children: renderHeader ? renderHeader({
2062
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2063
+ Button,
2064
+ {
2065
+ onClick: () => {
2066
+ onPublish(data);
2067
+ },
2068
+ icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_feather7.Globe, { size: "14px" }),
2069
+ children: "Publish"
2070
+ }
2071
+ ),
2072
+ data,
2073
+ dispatch
2074
+ }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1197
2075
  "div",
1198
2076
  {
1199
2077
  style: {
1200
- display: "flex",
1201
- gap: 16,
1202
- justifyContent: "flex-end"
2078
+ display: "grid",
2079
+ padding: 16,
2080
+ gridTemplateAreas: '"left middle right"',
2081
+ gridTemplateColumns: "288px auto 288px",
2082
+ gridTemplateRows: "auto"
1203
2083
  },
1204
2084
  children: [
1205
- renderHeaderActions && renderHeaderActions({ data, setData }),
1206
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1207
- Button,
2085
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2086
+ "div",
2087
+ {
2088
+ style: {
2089
+ display: "flex",
2090
+ gap: 16
2091
+ },
2092
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2093
+ IconButton,
2094
+ {
2095
+ onClick: () => setLeftSidebarVisible(!leftSidebarVisible),
2096
+ title: "Toggle left sidebar",
2097
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_feather7.Sidebar, {})
2098
+ }
2099
+ )
2100
+ }
2101
+ ),
2102
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2103
+ "div",
2104
+ {
2105
+ style: {
2106
+ display: "flex",
2107
+ justifyContent: "center",
2108
+ alignItems: "center"
2109
+ },
2110
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Heading, { rank: 2, size: "xs", children: [
2111
+ headerTitle || data.root.title || "Page",
2112
+ headerPath && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("small", { style: { fontWeight: 400, marginLeft: 4 }, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("code", { children: headerPath }) })
2113
+ ] })
2114
+ }
2115
+ ),
2116
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2117
+ "div",
1208
2118
  {
1209
- onClick: () => {
1210
- onPublish(data);
2119
+ style: {
2120
+ display: "flex",
2121
+ gap: 16,
2122
+ justifyContent: "flex-end"
1211
2123
  },
1212
- icon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_feather6.Globe, { size: "14px" }),
1213
- children: "Publish"
2124
+ children: [
2125
+ renderHeaderActions && renderHeaderActions({ data, dispatch }),
2126
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2127
+ Button,
2128
+ {
2129
+ onClick: () => {
2130
+ onPublish(data);
2131
+ },
2132
+ icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_feather7.Globe, { size: "14px" }),
2133
+ children: "Publish"
2134
+ }
2135
+ )
2136
+ ]
1214
2137
  }
1215
2138
  )
1216
2139
  ]
1217
2140
  }
1218
2141
  )
1219
- ]
1220
- }
1221
- )
1222
- }
1223
- ),
1224
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1225
- "div",
1226
- {
1227
- style: {
1228
- gridArea: "left",
1229
- background: "var(--puck-color-grey-11)",
1230
- borderRight: "1px solid var(--puck-color-grey-8)",
1231
- overflowY: "auto",
1232
- display: "flex",
1233
- flexDirection: "column"
1234
- },
1235
- children: [
1236
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SidebarSection, { title: "Components", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ComponentList, { config }) }),
1237
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(SidebarSection, { title: "Outline", children: [
1238
- data.content.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1239
- "div",
1240
- {
1241
- style: {
1242
- textAlign: "center",
1243
- color: "var(--puck-color-grey-6)",
1244
- fontFamily: "var(--puck-font-stack)"
1245
- },
1246
- children: "Add items to your page"
1247
- }
1248
- ),
1249
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(OutlineList, { children: data.content.map((item, i) => {
1250
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1251
- OutlineList.Item,
1252
- {
1253
- onClick: () => {
1254
- setSelectedIndex(i);
1255
- const id = data.content[i].props.id;
1256
- scrollIntoView(
1257
- document.querySelector(
1258
- `[data-rbd-drag-handle-draggable-id="draggable-${id}"]`
1259
- )
1260
- );
1261
- },
1262
- children: item.type
1263
- },
1264
- i
1265
- );
1266
- }) })
1267
- ] })
1268
- ]
1269
- }
1270
- ),
1271
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1272
- "div",
1273
- {
1274
- style: {
1275
- background: "var(--puck-color-grey-9)",
1276
- padding: 32,
1277
- overflowY: "auto",
1278
- gridArea: "editor"
1279
- },
1280
- onClick: () => setSelectedIndex(null),
1281
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1282
- "div",
1283
- {
1284
- className: "puck-root",
1285
- style: {
1286
- background: "white",
1287
- borderRadius: 16,
1288
- border: "1px solid var(--puck-color-grey-8)",
1289
- overflow: "hidden",
1290
- zoom: 0.75
1291
- },
1292
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Page, __spreadProps(__spreadValues({ data }, data.root), { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DroppableStrictMode_default, { droppableId: "droppable", children: (provided, snapshot) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1293
- "div",
1294
- __spreadProps(__spreadValues({}, provided.droppableProps), {
1295
- ref: provided.innerRef,
1296
- style: {
1297
- minHeight: 128,
1298
- position: "relative",
1299
- zoom: 1.33
1300
- },
1301
- id: "puck-drop-zone",
1302
- children: [
1303
- data.content.map((item, i) => {
1304
- var _a2;
1305
- const Render2 = config.components[item.type] ? config.components[item.type].render : () => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
1306
- "No configuration for ",
1307
- item.type
1308
- ] });
1309
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1310
- DraggableComponent,
1311
- {
1312
- label: item.type.toString(),
1313
- id: `draggable-${item.props.id}`,
1314
- index: i,
1315
- isSelected: selectedIndex === i,
1316
- onClick: (e) => {
1317
- setSelectedIndex(i);
1318
- e.stopPropagation();
1319
- },
1320
- onDelete: (e) => {
1321
- const newData = __spreadValues({}, data);
1322
- newData.content.splice(i, 1);
1323
- setSelectedIndex(null);
1324
- setData(newData);
1325
- e.stopPropagation();
1326
- },
1327
- onDuplicate: (e) => {
1328
- const newData = __spreadValues({}, data);
1329
- const newItem = __spreadProps(__spreadValues({}, newData.content[i]), {
1330
- props: __spreadProps(__spreadValues({}, newData.content[i].props), {
1331
- id: `${newData.content[i].type}-${(/* @__PURE__ */ new Date()).getTime()}`
1332
- })
1333
- });
1334
- newData.content.splice(i + 1, 0, newItem);
1335
- setData(newData);
1336
- e.stopPropagation();
1337
- },
1338
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: { zoom: 0.75 }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1339
- Render2,
1340
- __spreadProps(__spreadValues(__spreadValues({}, (_a2 = config.components[item.type]) == null ? void 0 : _a2.defaultProps), item.props), {
1341
- editMode: true
1342
- })
1343
- ) })
1344
- },
1345
- item.props.id
1346
- );
1347
- }),
1348
- provided.placeholder,
1349
- snapshot.isDraggingOver && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1350
- "div",
2142
+ }
2143
+ ),
2144
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2145
+ "div",
2146
+ {
2147
+ style: {
2148
+ gridArea: "left",
2149
+ background: "var(--puck-color-grey-11)",
2150
+ borderRight: "1px solid var(--puck-color-grey-8)",
2151
+ overflowY: "auto",
2152
+ display: "flex",
2153
+ flexDirection: "column"
2154
+ },
2155
+ children: [
2156
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(SidebarSection, { title: "Components", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ComponentList, { config }) }),
2157
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(SidebarSection, { title: "Outline", children: [
2158
+ (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2159
+ LayerTree,
1351
2160
  {
1352
- style: __spreadProps(__spreadValues({}, placeholderStyle), {
1353
- background: "var(--puck-color-azure-8)",
1354
- zIndex: 0
1355
- })
2161
+ data,
2162
+ label: areaContainsZones(data, "root") ? rootDroppableId : "",
2163
+ zoneContent: data.content,
2164
+ setItemSelector,
2165
+ itemSelector
2166
+ }
2167
+ ),
2168
+ Object.entries(findZonesForArea(data, "root")).map(
2169
+ ([zoneKey, zone]) => {
2170
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2171
+ LayerTree,
2172
+ {
2173
+ data,
2174
+ label: zoneKey,
2175
+ zone: zoneKey,
2176
+ zoneContent: zone,
2177
+ setItemSelector,
2178
+ itemSelector
2179
+ },
2180
+ zoneKey
2181
+ );
1356
2182
  }
1357
2183
  )
1358
- ]
1359
- })
1360
- ) }) }))
1361
- }
1362
- )
1363
- }
1364
- ),
1365
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1366
- "div",
1367
- {
1368
- style: {
1369
- borderLeft: "1px solid var(--puck-color-grey-8)",
1370
- overflowY: "auto",
1371
- gridArea: "right",
1372
- fontFamily: "var(--puck-font-stack)",
1373
- display: "flex",
1374
- flexDirection: "column"
1375
- },
1376
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FieldWrapper, { data, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1377
- SidebarSection,
1378
- {
1379
- noPadding: true,
1380
- breadcrumb: selectedIndex !== null ? "Page" : "",
1381
- breadcrumbClick: () => setSelectedIndex(null),
1382
- title: selectedIndex !== null ? data.content[selectedIndex].type : "Page",
1383
- children: Object.keys(fields).map((fieldName) => {
1384
- var _a2, _b2, _c, _d;
1385
- const field = fields[fieldName];
1386
- const onChange2 = (value) => {
1387
- let currentProps;
1388
- let newProps;
1389
- if (selectedIndex !== null) {
1390
- currentProps = data.content[selectedIndex].props;
1391
- } else {
1392
- currentProps = data.root;
2184
+ ] })
2185
+ ]
2186
+ }
2187
+ ),
2188
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2189
+ "div",
2190
+ {
2191
+ style: {
2192
+ background: "var(--puck-color-grey-10)",
2193
+ padding: 32,
2194
+ overflowY: "auto",
2195
+ gridArea: "editor",
2196
+ position: "relative"
2197
+ },
2198
+ onClick: () => setItemSelector(null),
2199
+ id: "puck-frame",
2200
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2201
+ "div",
2202
+ {
2203
+ className: "puck-root",
2204
+ style: {
2205
+ background: "white",
2206
+ border: "1px solid var(--puck-color-grey-8)",
2207
+ zoom: 0.75
2208
+ },
2209
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Page, __spreadProps(__spreadValues({ data }, data.root), { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DropZone, { zone: rootDroppableId }) }))
1393
2210
  }
1394
- if (fieldName === "_data") {
1395
- if (!value) {
1396
- const _a3 = currentProps._meta || {}, { locked } = _a3, _meta = __objRest(_a3, ["locked"]);
1397
- newProps = __spreadProps(__spreadValues({}, currentProps), {
1398
- _data: void 0,
1399
- _meta
1400
- });
1401
- } else {
1402
- const changedFields = filter(
1403
- // filter out anything not supported by this component
1404
- value,
1405
- Object.keys(fields)
1406
- );
1407
- newProps = __spreadProps(__spreadValues(__spreadValues({}, currentProps), changedFields), {
1408
- _data: value,
1409
- // TODO perf - this is duplicative and will make payload larger
1410
- _meta: {
1411
- locked: Object.keys(changedFields)
2211
+ )
2212
+ }
2213
+ ),
2214
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2215
+ "div",
2216
+ {
2217
+ style: {
2218
+ borderLeft: "1px solid var(--puck-color-grey-8)",
2219
+ overflowY: "auto",
2220
+ gridArea: "right",
2221
+ fontFamily: "var(--puck-font-stack)",
2222
+ display: "flex",
2223
+ flexDirection: "column"
2224
+ },
2225
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(FieldWrapper, { data, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2226
+ SidebarSection,
2227
+ {
2228
+ noPadding: true,
2229
+ breadcrumbs: path,
2230
+ breadcrumbClick: (breadcrumb) => setItemSelector(breadcrumb.selector),
2231
+ title: selectedItem ? selectedItem.type : "Page",
2232
+ children: Object.keys(fields).map((fieldName) => {
2233
+ var _a2, _b2, _c, _d;
2234
+ const field = fields[fieldName];
2235
+ const onChange2 = (value) => {
2236
+ let currentProps;
2237
+ let newProps;
2238
+ if (selectedItem) {
2239
+ currentProps = selectedItem.props;
2240
+ } else {
2241
+ currentProps = data.root;
1412
2242
  }
1413
- });
1414
- }
1415
- } else {
1416
- newProps = __spreadProps(__spreadValues({}, currentProps), {
1417
- [fieldName]: value
1418
- });
1419
- }
1420
- if (selectedIndex !== null) {
1421
- setData(__spreadProps(__spreadValues({}, data), {
1422
- content: replace(data.content, selectedIndex, __spreadProps(__spreadValues({}, data.content[selectedIndex]), {
1423
- props: newProps
1424
- }))
1425
- }));
1426
- } else {
1427
- setData(__spreadProps(__spreadValues({}, data), { root: newProps }));
2243
+ if (fieldName === "_data") {
2244
+ if (!value) {
2245
+ const _a3 = currentProps._meta || {}, { locked } = _a3, _meta = __objRest(_a3, ["locked"]);
2246
+ newProps = __spreadProps(__spreadValues({}, currentProps), {
2247
+ _data: void 0,
2248
+ _meta
2249
+ });
2250
+ } else {
2251
+ const changedFields = filter(
2252
+ // filter out anything not supported by this component
2253
+ value,
2254
+ Object.keys(fields)
2255
+ );
2256
+ newProps = __spreadProps(__spreadValues(__spreadValues({}, currentProps), changedFields), {
2257
+ _data: value,
2258
+ // TODO perf - this is duplicative and will make payload larger
2259
+ _meta: {
2260
+ locked: Object.keys(changedFields)
2261
+ }
2262
+ });
2263
+ }
2264
+ } else {
2265
+ newProps = __spreadProps(__spreadValues({}, currentProps), {
2266
+ [fieldName]: value
2267
+ });
2268
+ }
2269
+ if (itemSelector) {
2270
+ dispatch({
2271
+ type: "replace",
2272
+ destinationIndex: itemSelector.index,
2273
+ destinationZone: itemSelector.zone || rootDroppableId,
2274
+ data: __spreadProps(__spreadValues({}, selectedItem), { props: newProps })
2275
+ });
2276
+ } else {
2277
+ dispatch({
2278
+ type: "set",
2279
+ data: { root: newProps }
2280
+ });
2281
+ }
2282
+ };
2283
+ if (selectedItem && itemSelector) {
2284
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2285
+ InputOrGroup,
2286
+ {
2287
+ field,
2288
+ name: fieldName,
2289
+ label: field.label,
2290
+ readOnly: ((_b2 = (_a2 = getItem(
2291
+ itemSelector,
2292
+ data
2293
+ ).props._meta) == null ? void 0 : _a2.locked) == null ? void 0 : _b2.indexOf(fieldName)) > -1,
2294
+ value: selectedItem.props[fieldName],
2295
+ onChange: onChange2
2296
+ },
2297
+ `${selectedItem.props.id}_${fieldName}`
2298
+ );
2299
+ } else {
2300
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2301
+ InputOrGroup,
2302
+ {
2303
+ field,
2304
+ name: fieldName,
2305
+ label: field.label,
2306
+ readOnly: ((_d = (_c = data.root._meta) == null ? void 0 : _c.locked) == null ? void 0 : _d.indexOf(fieldName)) > -1,
2307
+ value: data.root[fieldName],
2308
+ onChange: onChange2
2309
+ },
2310
+ `page_${fieldName}`
2311
+ );
2312
+ }
2313
+ })
1428
2314
  }
1429
- };
1430
- if (selectedIndex !== null) {
1431
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1432
- InputOrGroup,
1433
- {
1434
- field,
1435
- name: fieldName,
1436
- label: field.label,
1437
- readOnly: ((_b2 = (_a2 = data.content[selectedIndex].props._meta) == null ? void 0 : _a2.locked) == null ? void 0 : _b2.indexOf(fieldName)) > -1,
1438
- value: data.content[selectedIndex].props[fieldName],
1439
- onChange: onChange2
1440
- },
1441
- `${data.content[selectedIndex].props.id}_${fieldName}`
1442
- );
1443
- } else {
1444
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1445
- InputOrGroup,
1446
- {
1447
- field,
1448
- name: fieldName,
1449
- label: field.label,
1450
- readOnly: ((_d = (_c = data.root._meta) == null ? void 0 : _c.locked) == null ? void 0 : _d.indexOf(fieldName)) > -1,
1451
- value: data.root[fieldName],
1452
- onChange: onChange2
1453
- },
1454
- `page_${fieldName}`
1455
- );
1456
- }
1457
- })
1458
- }
1459
- ) })
2315
+ ) })
2316
+ }
2317
+ )
2318
+ ]
1460
2319
  }
1461
- )
1462
- ]
2320
+ );
2321
+ } })
1463
2322
  }
1464
2323
  )
1465
2324
  }
@@ -1468,28 +2327,23 @@ function Puck({
1468
2327
 
1469
2328
  // components/Render/index.tsx
1470
2329
  init_react_import();
1471
- var import_jsx_runtime12 = require("react/jsx-runtime");
2330
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1472
2331
  function Render({ config, data }) {
1473
- const children = data.content.map((item) => {
1474
- var _a;
1475
- const Component = (_a = config.components[item.type]) == null ? void 0 : _a.render;
1476
- if (Component) {
1477
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Component, __spreadValues({}, item.props), item.props.id);
1478
- }
1479
- return null;
1480
- });
1481
2332
  if (config.root) {
1482
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(config.root.render, __spreadProps(__spreadValues({}, data.root), { editMode: false, children }));
2333
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DropZoneProvider, { value: { data, config, mode: "render" }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(config.root.render, __spreadProps(__spreadValues({}, data.root), { editMode: false, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DropZone, { zone: rootDroppableId }) })) });
1483
2334
  }
1484
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { children });
2335
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DropZoneProvider, { value: { data, config, mode: "render" }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DropZone, { zone: rootDroppableId }) });
1485
2336
  }
1486
2337
  // Annotate the CommonJS export names for ESM import in node:
1487
2338
  0 && (module.exports = {
1488
2339
  Button,
2340
+ DropZone,
2341
+ DropZoneProvider,
1489
2342
  FieldLabel,
1490
2343
  IconButton,
1491
2344
  Puck,
1492
- Render
2345
+ Render,
2346
+ dropZoneContext
1493
2347
  });
1494
2348
  /*! Bundled license information:
1495
2349