@measured/puck 0.12.0-canary.39005a4 → 0.12.0-canary.53618f5

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
@@ -327,7 +327,7 @@ var require_react_is_development = __commonJS({
327
327
  var ContextProvider = REACT_PROVIDER_TYPE;
328
328
  var Element = REACT_ELEMENT_TYPE;
329
329
  var ForwardRef = REACT_FORWARD_REF_TYPE;
330
- var Fragment12 = REACT_FRAGMENT_TYPE;
330
+ var Fragment14 = REACT_FRAGMENT_TYPE;
331
331
  var Lazy = REACT_LAZY_TYPE;
332
332
  var Memo = REACT_MEMO_TYPE;
333
333
  var Portal = REACT_PORTAL_TYPE;
@@ -386,7 +386,7 @@ var require_react_is_development = __commonJS({
386
386
  exports.ContextProvider = ContextProvider;
387
387
  exports.Element = Element;
388
388
  exports.ForwardRef = ForwardRef;
389
- exports.Fragment = Fragment12;
389
+ exports.Fragment = Fragment14;
390
390
  exports.Lazy = Lazy;
391
391
  exports.Memo = Memo;
392
392
  exports.Portal = Portal;
@@ -760,7 +760,7 @@ var require_factoryWithTypeCheckers = __commonJS({
760
760
  function validate(props, propName, componentName, location, propFullName) {
761
761
  if (!(props[propName] instanceof expectedClass)) {
762
762
  var expectedClassName = expectedClass.name || ANONYMOUS;
763
- var actualClassName = getClassName18(props[propName]);
763
+ var actualClassName = getClassName20(props[propName]);
764
764
  return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + actualClassName + "` supplied to `" + componentName + "`, expected ") + ("instance of `" + expectedClassName + "`."));
765
765
  }
766
766
  return null;
@@ -1012,7 +1012,7 @@ var require_factoryWithTypeCheckers = __commonJS({
1012
1012
  return type;
1013
1013
  }
1014
1014
  }
1015
- function getClassName18(propValue) {
1015
+ function getClassName20(propValue) {
1016
1016
  if (!propValue.constructor || !propValue.constructor.name) {
1017
1017
  return ANONYMOUS;
1018
1018
  }
@@ -9040,7 +9040,7 @@ var require_react_dom_development = __commonJS({
9040
9040
  var HostPortal = 4;
9041
9041
  var HostComponent = 5;
9042
9042
  var HostText = 6;
9043
- var Fragment12 = 7;
9043
+ var Fragment14 = 7;
9044
9044
  var Mode = 8;
9045
9045
  var ContextConsumer = 9;
9046
9046
  var ContextProvider = 10;
@@ -10196,7 +10196,7 @@ var require_react_dom_development = __commonJS({
10196
10196
  return "DehydratedFragment";
10197
10197
  case ForwardRef:
10198
10198
  return getWrappedName$1(type, type.render, "ForwardRef");
10199
- case Fragment12:
10199
+ case Fragment14:
10200
10200
  return "Fragment";
10201
10201
  case HostComponent:
10202
10202
  return type;
@@ -14313,7 +14313,7 @@ var require_react_dom_development = __commonJS({
14313
14313
  defaultPrevented: 0,
14314
14314
  isTrusted: 0
14315
14315
  };
14316
- var SyntheticEvent2 = createSyntheticEvent(EventInterface);
14316
+ var SyntheticEvent3 = createSyntheticEvent(EventInterface);
14317
14317
  var UIEventInterface = assign({}, EventInterface, {
14318
14318
  view: 0,
14319
14319
  detail: 0
@@ -14789,7 +14789,7 @@ var require_react_dom_development = __commonJS({
14789
14789
  enqueueStateRestore(target);
14790
14790
  var listeners = accumulateTwoPhaseListeners(inst, "onChange");
14791
14791
  if (listeners.length > 0) {
14792
- var event = new SyntheticEvent2("onChange", "change", null, nativeEvent, target);
14792
+ var event = new SyntheticEvent3("onChange", "change", null, nativeEvent, target);
14793
14793
  dispatchQueue.push({
14794
14794
  event,
14795
14795
  listeners
@@ -15293,7 +15293,7 @@ var require_react_dom_development = __commonJS({
15293
15293
  lastSelection = currentSelection;
15294
15294
  var listeners = accumulateTwoPhaseListeners(activeElementInst$1, "onSelect");
15295
15295
  if (listeners.length > 0) {
15296
- var event = new SyntheticEvent2("onSelect", "select", null, nativeEvent, nativeEventTarget);
15296
+ var event = new SyntheticEvent3("onSelect", "select", null, nativeEvent, nativeEventTarget);
15297
15297
  dispatchQueue.push({
15298
15298
  event,
15299
15299
  listeners
@@ -15405,7 +15405,7 @@ var require_react_dom_development = __commonJS({
15405
15405
  if (reactName === void 0) {
15406
15406
  return;
15407
15407
  }
15408
- var SyntheticEventCtor = SyntheticEvent2;
15408
+ var SyntheticEventCtor = SyntheticEvent3;
15409
15409
  var reactEventType = domEventName;
15410
15410
  switch (domEventName) {
15411
15411
  case "keypress":
@@ -19867,7 +19867,7 @@ var require_react_dom_development = __commonJS({
19867
19867
  }
19868
19868
  }
19869
19869
  function updateFragment2(returnFiber, current2, fragment, lanes, key) {
19870
- if (current2 === null || current2.tag !== Fragment12) {
19870
+ if (current2 === null || current2.tag !== Fragment14) {
19871
19871
  var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);
19872
19872
  created.return = returnFiber;
19873
19873
  return created;
@@ -20270,7 +20270,7 @@ var require_react_dom_development = __commonJS({
20270
20270
  if (child.key === key) {
20271
20271
  var elementType = element.type;
20272
20272
  if (elementType === REACT_FRAGMENT_TYPE) {
20273
- if (child.tag === Fragment12) {
20273
+ if (child.tag === Fragment14) {
20274
20274
  deleteRemainingChildren(returnFiber, child.sibling);
20275
20275
  var existing = useFiber(child, element.props.children);
20276
20276
  existing.return = returnFiber;
@@ -24445,7 +24445,7 @@ var require_react_dom_development = __commonJS({
24445
24445
  var _resolvedProps2 = workInProgress2.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
24446
24446
  return updateForwardRef(current2, workInProgress2, type, _resolvedProps2, renderLanes2);
24447
24447
  }
24448
- case Fragment12:
24448
+ case Fragment14:
24449
24449
  return updateFragment(current2, workInProgress2, renderLanes2);
24450
24450
  case Mode:
24451
24451
  return updateMode(current2, workInProgress2, renderLanes2);
@@ -24718,7 +24718,7 @@ var require_react_dom_development = __commonJS({
24718
24718
  case SimpleMemoComponent:
24719
24719
  case FunctionComponent:
24720
24720
  case ForwardRef:
24721
- case Fragment12:
24721
+ case Fragment14:
24722
24722
  case Mode:
24723
24723
  case Profiler:
24724
24724
  case ContextConsumer:
@@ -28977,7 +28977,7 @@ var require_react_dom_development = __commonJS({
28977
28977
  return fiber;
28978
28978
  }
28979
28979
  function createFiberFromFragment(elements, mode, lanes, key) {
28980
- var fiber = createFiber(Fragment12, elements, key, mode);
28980
+ var fiber = createFiber(Fragment14, elements, key, mode);
28981
28981
  fiber.lanes = lanes;
28982
28982
  return fiber;
28983
28983
  }
@@ -30125,7 +30125,7 @@ var import_react2 = require("react");
30125
30125
 
30126
30126
  // css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
30127
30127
  init_react_import();
30128
- var Button_module_default = { "Button": "_Button_1muck_1", "Button--medium": "_Button--medium_1muck_20", "Button--large": "_Button--large_1muck_27", "Button-icon": "_Button-icon_1muck_34", "Button--primary": "_Button--primary_1muck_42", "Button--secondary": "_Button--secondary_1muck_51", "Button--flush": "_Button--flush_1muck_62", "Button--disabled": "_Button--disabled_1muck_66", "Button--fullWidth": "_Button--fullWidth_1muck_76" };
30128
+ var Button_module_default = { "Button": "_Button_1brfa_1", "Button--medium": "_Button--medium_1brfa_22", "Button--large": "_Button--large_1brfa_29", "Button-icon": "_Button-icon_1brfa_36", "Button--primary": "_Button--primary_1brfa_44", "Button--secondary": "_Button--secondary_1brfa_53", "Button--flush": "_Button--flush_1brfa_64", "Button--disabled": "_Button--disabled_1brfa_68", "Button--fullWidth": "_Button--fullWidth_1brfa_78" };
30129
30129
 
30130
30130
  // lib/get-class-name-factory.ts
30131
30131
  init_react_import();
@@ -31974,6 +31974,7 @@ var defaultAppState = {
31974
31974
  data: { content: [], root: { title: "" } },
31975
31975
  ui: {
31976
31976
  leftSideBarVisible: true,
31977
+ rightSideBarVisible: true,
31977
31978
  arrayState: {},
31978
31979
  itemSelector: null,
31979
31980
  componentList: {}
@@ -32301,7 +32302,7 @@ var import_react26 = require("react");
32301
32302
 
32302
32303
  // css-module:/home/runner/work/puck/puck/packages/core/components/IconButton/IconButton.module.css#css-module
32303
32304
  init_react_import();
32304
- var IconButton_module_default = { "IconButton": "_IconButton_13gzt_1" };
32305
+ var IconButton_module_default = { "IconButton": "_IconButton_38xdr_1", "IconButton-title": "_IconButton-title_38xdr_18" };
32305
32306
 
32306
32307
  // components/IconButton/IconButton.tsx
32307
32308
  var import_react_spinners3 = require("react-spinners");
@@ -32346,10 +32347,11 @@ var IconButton = ({
32346
32347
  href,
32347
32348
  title,
32348
32349
  children: [
32350
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: getClassName4("title"), children: title }),
32349
32351
  children,
32350
32352
  loading && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
32351
32353
  "\xA0\xA0",
32352
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_spinners3.ClipLoader, { color: "inherit", size: "14px" })
32354
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_spinners3.ClipLoader, { "aria-label": "Loading", color: "inherit", size: "14px" })
32353
32355
  ] })
32354
32356
  ]
32355
32357
  }
@@ -32359,7 +32361,7 @@ var IconButton = ({
32359
32361
 
32360
32362
  // components/Puck/index.tsx
32361
32363
  init_react_import();
32362
- var import_react38 = require("react");
32364
+ var import_react39 = require("react");
32363
32365
  var import_dnd7 = require("@hello-pangea/dnd");
32364
32366
 
32365
32367
  // components/InputOrGroup/index.tsx
@@ -32367,10 +32369,10 @@ init_react_import();
32367
32369
 
32368
32370
  // css-module:/home/runner/work/puck/puck/packages/core/components/InputOrGroup/styles.module.css#css-module
32369
32371
  init_react_import();
32370
- var styles_module_default3 = { "Input": "_Input_1kw16_1", "Input-label": "_Input-label_1kw16_27", "Input-labelIcon": "_Input-labelIcon_1kw16_34", "Input-disabledIcon": "_Input-disabledIcon_1kw16_40", "Input-input": "_Input-input_1kw16_45", "Input--readOnly": "_Input--readOnly_1kw16_66", "Input-radioGroupItems": "_Input-radioGroupItems_1kw16_78", "Input-radio": "_Input-radio_1kw16_78", "Input-radioInner": "_Input-radioInner_1kw16_95", "Input-radioInput": "_Input-radioInput_1kw16_117" };
32372
+ var styles_module_default3 = { "Input": "_Input_1jyrm_1", "Input-label": "_Input-label_1jyrm_27", "Input-labelIcon": "_Input-labelIcon_1jyrm_35", "Input-disabledIcon": "_Input-disabledIcon_1jyrm_41", "Input-input": "_Input-input_1jyrm_46", "Input--readOnly": "_Input--readOnly_1jyrm_69", "Input-radioGroupItems": "_Input-radioGroupItems_1jyrm_87", "Input-radio": "_Input-radio_1jyrm_87", "Input-radioInner": "_Input-radioInner_1jyrm_104", "Input-radioInput": "_Input-radioInput_1jyrm_126" };
32371
32373
 
32372
32374
  // components/InputOrGroup/index.tsx
32373
- var import_react30 = require("react");
32375
+ var import_react31 = require("react");
32374
32376
 
32375
32377
  // components/InputOrGroup/fields/index.tsx
32376
32378
  init_react_import();
@@ -32380,7 +32382,7 @@ init_react_import();
32380
32382
 
32381
32383
  // css-module:/home/runner/work/puck/puck/packages/core/components/InputOrGroup/fields/ArrayField/styles.module.css#css-module
32382
32384
  init_react_import();
32383
- var styles_module_default4 = { "ArrayField": "_ArrayField_13rp0_5", "ArrayField--isDraggingFrom": "_ArrayField--isDraggingFrom_13rp0_13", "ArrayField-addButton": "_ArrayField-addButton_13rp0_17", "ArrayField--hasItems": "_ArrayField--hasItems_13rp0_31", "ArrayFieldItem": "_ArrayFieldItem_13rp0_45", "ArrayFieldItem--isDragging": "_ArrayFieldItem--isDragging_13rp0_53", "ArrayFieldItem--isExpanded": "_ArrayFieldItem--isExpanded_13rp0_58", "ArrayFieldItem-summary": "_ArrayFieldItem-summary_13rp0_72", "ArrayFieldItem--readOnly": "_ArrayFieldItem--readOnly_13rp0_84", "ArrayFieldItem-body": "_ArrayFieldItem-body_13rp0_105", "ArrayFieldItem-fieldset": "_ArrayFieldItem-fieldset_13rp0_113", "ArrayFieldItem-rhs": "_ArrayFieldItem-rhs_13rp0_120", "ArrayFieldItem-actions": "_ArrayFieldItem-actions_13rp0_126", "ArrayFieldItem-action": "_ArrayFieldItem-action_13rp0_126" };
32385
+ var styles_module_default4 = { "ArrayField": "_ArrayField_1auyc_5", "ArrayField--isDraggingFrom": "_ArrayField--isDraggingFrom_1auyc_13", "ArrayField-addButton": "_ArrayField-addButton_1auyc_17", "ArrayField--hasItems": "_ArrayField--hasItems_1auyc_31", "ArrayFieldItem": "_ArrayFieldItem_1auyc_45", "ArrayFieldItem--isDragging": "_ArrayFieldItem--isDragging_1auyc_53", "ArrayFieldItem--isExpanded": "_ArrayFieldItem--isExpanded_1auyc_58", "ArrayFieldItem-summary": "_ArrayFieldItem-summary_1auyc_73", "ArrayFieldItem--readOnly": "_ArrayFieldItem--readOnly_1auyc_86", "ArrayFieldItem-body": "_ArrayFieldItem-body_1auyc_107", "ArrayFieldItem-fieldset": "_ArrayFieldItem-fieldset_1auyc_115", "ArrayFieldItem-rhs": "_ArrayFieldItem-rhs_1auyc_122", "ArrayFieldItem-actions": "_ArrayFieldItem-actions_1auyc_128", "ArrayFieldItem-action": "_ArrayFieldItem-action_1auyc_128" };
32384
32386
 
32385
32387
  // components/InputOrGroup/fields/ArrayField/index.tsx
32386
32388
  var import_dnd4 = require("@hello-pangea/dnd");
@@ -32434,11 +32436,6 @@ var Draggable2 = ({
32434
32436
  );
32435
32437
  };
32436
32438
 
32437
- // lib/generate-id.ts
32438
- init_react_import();
32439
- var import_crypto = require("crypto");
32440
- var generateId = (type) => `${type}-${(0, import_crypto.randomBytes)(20).toString("hex")}`;
32441
-
32442
32439
  // components/InputOrGroup/fields/ArrayField/index.tsx
32443
32440
  var import_react27 = require("react");
32444
32441
 
@@ -32465,40 +32462,59 @@ var ArrayField = ({
32465
32462
  name,
32466
32463
  label,
32467
32464
  readOnly,
32468
- readOnlyFields = {}
32465
+ readOnlyFields = {},
32466
+ id
32469
32467
  }) => {
32470
- const [arrayFieldId] = (0, import_react27.useState)(generateId("ArrayField"));
32471
32468
  const { state, setUi } = useAppContext();
32472
- const arrayState = state.ui.arrayState[arrayFieldId] || {
32473
- items: Array.from(value || []).map((v) => ({
32474
- _arrayId: generateId("ArrayItem"),
32475
- data: v
32476
- })),
32469
+ const arrayState = state.ui.arrayState[id] || {
32470
+ items: Array.from(value || []).map((item, idx) => {
32471
+ return {
32472
+ _originalIndex: idx,
32473
+ _arrayId: `${id}-${idx}`,
32474
+ data: item
32475
+ };
32476
+ }),
32477
32477
  openId: ""
32478
32478
  };
32479
- const setArrayState = (0, import_react27.useCallback)(
32480
- (newArrayState, recordHistory = false) => {
32481
- setUi(
32482
- {
32483
- arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
32484
- [arrayFieldId]: __spreadValues(__spreadValues({}, arrayState), newArrayState)
32485
- })
32486
- },
32487
- recordHistory
32488
- );
32479
+ const [localState, setLocalState] = (0, import_react27.useState)({ arrayState, value });
32480
+ (0, import_react27.useEffect)(() => {
32481
+ setLocalState({ arrayState, value });
32482
+ }, [value, state.ui.arrayState[id]]);
32483
+ const mapArrayStateToUi = (0, import_react27.useCallback)(
32484
+ (partialArrayState) => {
32485
+ return {
32486
+ arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
32487
+ [id]: __spreadValues(__spreadValues({}, arrayState), partialArrayState)
32488
+ })
32489
+ };
32490
+ },
32491
+ [arrayState]
32492
+ );
32493
+ const getHighestIndex = (0, import_react27.useCallback)(() => {
32494
+ return arrayState.items.reduce(
32495
+ (acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
32496
+ -1
32497
+ );
32498
+ }, [arrayState]);
32499
+ const regenerateArrayState = (0, import_react27.useCallback)(
32500
+ (value2) => {
32501
+ let highestIndex = getHighestIndex();
32502
+ const newItems = Array.from(value2 || []).map((item, idx) => {
32503
+ var _a;
32504
+ const arrayStateItem = arrayState.items[idx];
32505
+ return {
32506
+ _originalIndex: typeof (arrayStateItem == null ? void 0 : arrayStateItem._originalIndex) !== "undefined" ? arrayStateItem._originalIndex : ++highestIndex,
32507
+ _arrayId: ((_a = arrayState.items[idx]) == null ? void 0 : _a._arrayId) || `${id}-${highestIndex}`,
32508
+ data: item
32509
+ };
32510
+ });
32511
+ return __spreadProps(__spreadValues({}, arrayState), { items: newItems });
32489
32512
  },
32490
32513
  [arrayState]
32491
32514
  );
32492
32515
  (0, import_react27.useEffect)(() => {
32493
- const newItems = Array.from(value || []).map((item, idx) => {
32494
- var _a;
32495
- return {
32496
- _arrayId: ((_a = arrayState.items[idx]) == null ? void 0 : _a._arrayId) || generateId("ArrayItem"),
32497
- data: item
32498
- };
32499
- });
32500
- setArrayState({ items: newItems });
32501
- }, [value]);
32516
+ setUi(mapArrayStateToUi(arrayState));
32517
+ }, []);
32502
32518
  if (field.type !== "array" || !field.arrayFields) {
32503
32519
  return null;
32504
32520
  }
@@ -32513,15 +32529,27 @@ var ArrayField = ({
32513
32529
  import_dnd5.DragDropContext,
32514
32530
  {
32515
32531
  onDragEnd: (event) => {
32516
- var _a;
32532
+ var _a, _b;
32517
32533
  if (event.destination) {
32518
32534
  const newValue = reorder(
32519
- arrayState.items,
32535
+ value,
32520
32536
  event.source.index,
32521
32537
  (_a = event.destination) == null ? void 0 : _a.index
32522
32538
  );
32523
- setArrayState(__spreadProps(__spreadValues({}, arrayState), { items: newValue }), false);
32524
- onChange(newValue.map(({ data }) => data));
32539
+ const newArrayStateItems = reorder(
32540
+ arrayState.items,
32541
+ event.source.index,
32542
+ (_b = event.destination) == null ? void 0 : _b.index
32543
+ );
32544
+ onChange(newValue, {
32545
+ arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
32546
+ [id]: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
32547
+ })
32548
+ });
32549
+ setLocalState({
32550
+ value: newValue,
32551
+ arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
32552
+ });
32525
32553
  }
32526
32554
  },
32527
32555
  children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dnd4.Droppable, { droppableId: "array", isDropDisabled: readOnly, children: (provided, snapshot) => {
@@ -32534,97 +32562,104 @@ var ArrayField = ({
32534
32562
  hasItems: Array.isArray(value) && value.length > 0
32535
32563
  }),
32536
32564
  children: [
32537
- Array.isArray(value) && value.length > 0 ? arrayState.items.map(({ _arrayId, data }, i) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
32538
- Draggable2,
32539
- {
32540
- id: _arrayId,
32541
- index: i,
32542
- className: (_, snapshot2) => getClassNameItem({
32543
- isExpanded: arrayState.openId === _arrayId,
32544
- isDragging: snapshot2.isDragging,
32545
- readOnly
32546
- }),
32547
- isDragDisabled: readOnly,
32548
- children: () => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
32549
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
32550
- "div",
32551
- {
32552
- onClick: () => {
32553
- if (arrayState.openId === _arrayId) {
32554
- setArrayState({
32555
- openId: ""
32556
- });
32557
- } else {
32558
- setArrayState({
32559
- openId: _arrayId
32560
- });
32561
- }
32562
- },
32563
- className: getClassNameItem("summary"),
32564
- children: [
32565
- field.getItemSummary ? field.getItemSummary(data, i) : `Item #${i}`,
32566
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassNameItem("rhs"), children: [
32567
- !readOnly && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("actions"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
32568
- IconButton,
32569
- {
32570
- onClick: () => {
32571
- const existingValue = [
32572
- ...value || []
32573
- ];
32574
- const existingItems = [
32575
- ...arrayState.items || []
32576
- ];
32577
- existingValue.splice(i, 1);
32578
- existingItems.splice(i, 1);
32579
- setArrayState(
32580
- { items: existingItems },
32581
- true
32582
- );
32583
- onChange(existingValue);
32584
- },
32585
- title: "Delete",
32586
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(trash_default, { size: 16 })
32587
- }
32588
- ) }) }),
32589
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DragIcon, {}) })
32590
- ] })
32591
- ]
32592
- }
32593
- ),
32594
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
32595
- "fieldset",
32596
- {
32597
- className: getClassNameItem("fieldset"),
32598
- children: Object.keys(field.arrayFields).map(
32599
- (fieldName) => {
32600
- const subField = field.arrayFields[fieldName];
32601
- const subFieldName = `${name}[${i}].${fieldName}`;
32602
- const wildcardFieldName = `${name}[*].${fieldName}`;
32603
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
32604
- InputOrGroup,
32605
- {
32606
- name: subFieldName,
32607
- label: subField.label || fieldName,
32608
- readOnly: typeof readOnlyFields[subFieldName] !== "undefined" ? readOnlyFields[subFieldName] : readOnlyFields[wildcardFieldName],
32609
- readOnlyFields,
32610
- field: subField,
32611
- value: data[fieldName],
32612
- onChange: (val) => onChange(
32565
+ localState.arrayState.items.map((item, i) => {
32566
+ const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
32567
+ const data = Array.from(localState.value || [])[i];
32568
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
32569
+ Draggable2,
32570
+ {
32571
+ id: _arrayId,
32572
+ index: i,
32573
+ className: (_, snapshot2) => getClassNameItem({
32574
+ isExpanded: arrayState.openId === _arrayId,
32575
+ isDragging: snapshot2 == null ? void 0 : snapshot2.isDragging,
32576
+ readOnly
32577
+ }),
32578
+ isDragDisabled: readOnly,
32579
+ children: () => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
32580
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
32581
+ "div",
32582
+ {
32583
+ onClick: () => {
32584
+ if (arrayState.openId === _arrayId) {
32585
+ setUi(
32586
+ mapArrayStateToUi({
32587
+ openId: ""
32588
+ })
32589
+ );
32590
+ } else {
32591
+ setUi(
32592
+ mapArrayStateToUi({
32593
+ openId: _arrayId
32594
+ })
32595
+ );
32596
+ }
32597
+ },
32598
+ className: getClassNameItem("summary"),
32599
+ children: [
32600
+ field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
32601
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: getClassNameItem("rhs"), children: [
32602
+ !readOnly && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("actions"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
32603
+ IconButton,
32604
+ {
32605
+ onClick: (e) => {
32606
+ e.stopPropagation();
32607
+ const existingValue = [
32608
+ ...value || []
32609
+ ];
32610
+ const existingItems = [
32611
+ ...arrayState.items || []
32612
+ ];
32613
+ existingValue.splice(i, 1);
32614
+ existingItems.splice(i, 1);
32615
+ onChange(
32616
+ existingValue,
32617
+ mapArrayStateToUi({
32618
+ items: existingItems
32619
+ })
32620
+ );
32621
+ },
32622
+ title: "Delete",
32623
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(trash_default, { size: 16 })
32624
+ }
32625
+ ) }) }),
32626
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DragIcon, {}) })
32627
+ ] })
32628
+ ]
32629
+ }
32630
+ ),
32631
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map(
32632
+ (fieldName) => {
32633
+ const subField = field.arrayFields[fieldName];
32634
+ const subFieldName = `${name}[${i}].${fieldName}`;
32635
+ const wildcardFieldName = `${name}[*].${fieldName}`;
32636
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
32637
+ InputOrGroup,
32638
+ {
32639
+ name: subFieldName,
32640
+ label: subField.label || fieldName,
32641
+ id: `${id}_${fieldName}`,
32642
+ readOnly: typeof readOnlyFields[subFieldName] !== "undefined" ? readOnlyFields[subFieldName] : readOnlyFields[wildcardFieldName],
32643
+ readOnlyFields,
32644
+ field: subField,
32645
+ value: data[fieldName],
32646
+ onChange: (val) => {
32647
+ onChange(
32613
32648
  replace(value, i, __spreadProps(__spreadValues({}, data), {
32614
32649
  [fieldName]: val
32615
32650
  }))
32616
- )
32617
- },
32618
- subFieldName
32619
- );
32620
- }
32621
- )
32622
- }
32623
- ) })
32624
- ] })
32625
- },
32626
- _arrayId
32627
- )) : null,
32651
+ );
32652
+ }
32653
+ },
32654
+ subFieldName
32655
+ );
32656
+ }
32657
+ ) }) })
32658
+ ] })
32659
+ },
32660
+ _arrayId
32661
+ );
32662
+ }),
32628
32663
  provided.placeholder,
32629
32664
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
32630
32665
  "button",
@@ -32632,7 +32667,12 @@ var ArrayField = ({
32632
32667
  className: getClassName6("addButton"),
32633
32668
  onClick: () => {
32634
32669
  const existingValue = value || [];
32635
- onChange([...existingValue, field.defaultItemProps || {}]);
32670
+ const newValue = [
32671
+ ...existingValue,
32672
+ field.defaultItemProps || {}
32673
+ ];
32674
+ const newArrayState = regenerateArrayState(newValue);
32675
+ onChange(newValue, mapArrayStateToUi(newArrayState));
32636
32676
  },
32637
32677
  children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(plus_default, { size: "21" })
32638
32678
  }
@@ -32657,7 +32697,8 @@ var DefaultField = ({
32657
32697
  readOnly,
32658
32698
  value,
32659
32699
  name,
32660
- label
32700
+ label,
32701
+ id
32661
32702
  }) => {
32662
32703
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
32663
32704
  FieldLabelInternal,
@@ -32683,7 +32724,8 @@ var DefaultField = ({
32683
32724
  onChange(e.currentTarget.value);
32684
32725
  }
32685
32726
  },
32686
- readOnly
32727
+ readOnly,
32728
+ id
32687
32729
  }
32688
32730
  )
32689
32731
  }
@@ -32692,18 +32734,19 @@ var DefaultField = ({
32692
32734
 
32693
32735
  // components/InputOrGroup/fields/ExternalField/index.tsx
32694
32736
  init_react_import();
32695
- var import_react29 = require("react");
32737
+ var import_react30 = require("react");
32696
32738
 
32697
32739
  // components/ExternalInput/index.tsx
32698
32740
  init_react_import();
32699
- var import_react28 = require("react");
32741
+ var import_react29 = require("react");
32700
32742
 
32701
32743
  // css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
32702
32744
  init_react_import();
32703
- var styles_module_default6 = { "ExternalInput": "_ExternalInput_z7jih_1", "ExternalInput-actions": "_ExternalInput-actions_z7jih_5", "ExternalInput-button": "_ExternalInput-button_z7jih_9", "ExternalInput-detachButton": "_ExternalInput-detachButton_z7jih_28", "ExternalInput--dataSelected": "_ExternalInput--dataSelected_z7jih_35", "ExternalInputModal": "_ExternalInputModal_z7jih_56", "ExternalInputModal-masthead": "_ExternalInputModal-masthead_z7jih_63", "ExternalInputModal-tableWrapper": "_ExternalInputModal-tableWrapper_z7jih_68", "ExternalInputModal-table": "_ExternalInputModal-table_z7jih_68", "ExternalInputModal-thead": "_ExternalInputModal-thead_z7jih_82", "ExternalInputModal-th": "_ExternalInputModal-th_z7jih_82", "ExternalInputModal-td": "_ExternalInputModal-td_z7jih_96", "ExternalInputModal-tr": "_ExternalInputModal-tr_z7jih_101", "ExternalInputModal-tbody": "_ExternalInputModal-tbody_z7jih_113", "ExternalInputModal--hasData": "_ExternalInputModal--hasData_z7jih_132", "ExternalInputModal-loadingBanner": "_ExternalInputModal-loadingBanner_z7jih_136", "ExternalInputModal--isLoading": "_ExternalInputModal--isLoading_z7jih_144", "ExternalInputModal-noContentBanner": "_ExternalInputModal-noContentBanner_z7jih_148", "ExternalInputModal--loaded": "_ExternalInputModal--loaded_z7jih_152" };
32745
+ var styles_module_default6 = { "ExternalInput": "_ExternalInput_157li_1", "ExternalInput-actions": "_ExternalInput-actions_157li_5", "ExternalInput-button": "_ExternalInput-button_157li_9", "ExternalInput-detachButton": "_ExternalInput-detachButton_157li_28", "ExternalInput--dataSelected": "_ExternalInput--dataSelected_157li_35", "ExternalInputModal": "_ExternalInputModal_157li_56", "ExternalInputModal-masthead": "_ExternalInputModal-masthead_157li_63", "ExternalInputModal-tableWrapper": "_ExternalInputModal-tableWrapper_157li_68", "ExternalInputModal-table": "_ExternalInputModal-table_157li_68", "ExternalInputModal-thead": "_ExternalInputModal-thead_157li_83", "ExternalInputModal-th": "_ExternalInputModal-th_157li_83", "ExternalInputModal-td": "_ExternalInputModal-td_157li_97", "ExternalInputModal-tr": "_ExternalInputModal-tr_157li_102", "ExternalInputModal-tbody": "_ExternalInputModal-tbody_157li_114", "ExternalInputModal--hasData": "_ExternalInputModal--hasData_157li_133", "ExternalInputModal-loadingBanner": "_ExternalInputModal-loadingBanner_157li_137", "ExternalInputModal--isLoading": "_ExternalInputModal--isLoading_157li_145", "ExternalInputModal-noContentBanner": "_ExternalInputModal-noContentBanner_157li_149", "ExternalInputModal--loaded": "_ExternalInputModal--loaded_157li_153" };
32704
32746
 
32705
32747
  // components/Modal/index.tsx
32706
32748
  init_react_import();
32749
+ var import_react28 = require("react");
32707
32750
 
32708
32751
  // css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
32709
32752
  init_react_import();
@@ -32718,7 +32761,10 @@ var Modal = ({
32718
32761
  onClose,
32719
32762
  isOpen
32720
32763
  }) => {
32721
- const rootEl = document.getElementById("puck-portal-root");
32764
+ const [rootEl, setRootEl] = (0, import_react28.useState)(null);
32765
+ (0, import_react28.useEffect)(() => {
32766
+ setRootEl(document.getElementById("puck-portal-root"));
32767
+ }, []);
32722
32768
  if (!rootEl) {
32723
32769
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", {});
32724
32770
  }
@@ -32768,13 +32814,14 @@ var ExternalInput = ({
32768
32814
  field,
32769
32815
  onChange,
32770
32816
  value = null,
32771
- name
32817
+ name,
32818
+ id
32772
32819
  }) => {
32773
32820
  const { mapProp = (val) => val } = field || {};
32774
- const [data, setData] = (0, import_react28.useState)([]);
32775
- const [isOpen, setOpen] = (0, import_react28.useState)(false);
32776
- const [isLoading, setIsLoading] = (0, import_react28.useState)(true);
32777
- const keys = (0, import_react28.useMemo)(() => {
32821
+ const [data, setData] = (0, import_react29.useState)([]);
32822
+ const [isOpen, setOpen] = (0, import_react29.useState)(false);
32823
+ const [isLoading, setIsLoading] = (0, import_react29.useState)(true);
32824
+ const keys = (0, import_react29.useMemo)(() => {
32778
32825
  const validKeys = /* @__PURE__ */ new Set();
32779
32826
  for (const item of data) {
32780
32827
  for (const key of Object.keys(item)) {
@@ -32785,7 +32832,7 @@ var ExternalInput = ({
32785
32832
  }
32786
32833
  return Array.from(validKeys);
32787
32834
  }, [data]);
32788
- (0, import_react28.useEffect)(() => {
32835
+ (0, import_react29.useEffect)(() => {
32789
32836
  (() => __async(void 0, null, function* () {
32790
32837
  const listData = dataCache[name] || (yield field.fetchList());
32791
32838
  if (listData) {
@@ -32802,6 +32849,7 @@ var ExternalInput = ({
32802
32849
  dataSelected: !!value,
32803
32850
  modalVisible: isOpen
32804
32851
  }),
32852
+ id,
32805
32853
  children: [
32806
32854
  /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassName10("actions"), children: [
32807
32855
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
@@ -32879,12 +32927,13 @@ var ExternalField = ({
32879
32927
  onChange,
32880
32928
  value,
32881
32929
  name,
32882
- label
32930
+ label,
32931
+ id
32883
32932
  }) => {
32884
32933
  var _a, _b, _c;
32885
32934
  const validField = field;
32886
32935
  const deprecatedField = field;
32887
- (0, import_react29.useEffect)(() => {
32936
+ (0, import_react30.useEffect)(() => {
32888
32937
  if (deprecatedField.adaptor) {
32889
32938
  console.error(
32890
32939
  "Warning: The `adaptor` API is deprecated. Please use updated APIs on the `external` field instead. This will be a breaking change in a future release."
@@ -32906,7 +32955,7 @@ var ExternalField = ({
32906
32955
  name,
32907
32956
  field: __spreadProps(__spreadValues({}, validField), {
32908
32957
  // DEPRECATED
32909
- placeholder: ((_a = deprecatedField.adaptor) == null ? void 0 : _a.name) ? `Select from ${deprecatedField.adaptor.name}` : validField.placeholder,
32958
+ placeholder: ((_a = deprecatedField.adaptor) == null ? void 0 : _a.name) ? `Select from ${deprecatedField.adaptor.name}` : validField.placeholder || "Select data",
32910
32959
  mapProp: ((_b = deprecatedField.adaptor) == null ? void 0 : _b.mapProp) || validField.mapProp,
32911
32960
  fetchList: ((_c = deprecatedField.adaptor) == null ? void 0 : _c.fetchList) ? () => __async(void 0, null, function* () {
32912
32961
  return yield deprecatedField.adaptor.fetchList(
@@ -32915,7 +32964,8 @@ var ExternalField = ({
32915
32964
  }) : validField.fetchList
32916
32965
  }),
32917
32966
  onChange,
32918
- value
32967
+ value,
32968
+ id
32919
32969
  }
32920
32970
  )
32921
32971
  }
@@ -32931,7 +32981,8 @@ var RadioField = ({
32931
32981
  onChange,
32932
32982
  readOnly,
32933
32983
  value,
32934
- name
32984
+ name,
32985
+ id
32935
32986
  }) => {
32936
32987
  if (field.type !== "radio" || !field.options) {
32937
32988
  return null;
@@ -32943,7 +32994,7 @@ var RadioField = ({
32943
32994
  label: field.label || name,
32944
32995
  readOnly,
32945
32996
  el: "div",
32946
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioGroupItems"), children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
32997
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
32947
32998
  "label",
32948
32999
  {
32949
33000
  className: getClassName11("radio"),
@@ -32985,7 +33036,8 @@ var SelectField = ({
32985
33036
  label,
32986
33037
  value,
32987
33038
  name,
32988
- readOnly
33039
+ readOnly,
33040
+ id
32989
33041
  }) => {
32990
33042
  if (field.type !== "select" || !field.options) {
32991
33043
  return null;
@@ -32999,6 +33051,7 @@ var SelectField = ({
32999
33051
  children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
33000
33052
  "select",
33001
33053
  {
33054
+ id,
33002
33055
  className: getClassName12("input"),
33003
33056
  disabled: readOnly,
33004
33057
  onChange: (e) => {
@@ -33032,7 +33085,8 @@ var TextareaField = ({
33032
33085
  readOnly,
33033
33086
  value,
33034
33087
  name,
33035
- label
33088
+ label,
33089
+ id
33036
33090
  }) => {
33037
33091
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
33038
33092
  FieldLabelInternal,
@@ -33043,6 +33097,7 @@ var TextareaField = ({
33043
33097
  children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
33044
33098
  "textarea",
33045
33099
  {
33100
+ id,
33046
33101
  className: getClassName13("input"),
33047
33102
  autoComplete: "off",
33048
33103
  name,
@@ -33085,7 +33140,6 @@ var FieldLabelInternal = ({
33085
33140
  el = "label",
33086
33141
  readOnly
33087
33142
  }) => {
33088
- const El = el;
33089
33143
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
33090
33144
  FieldLabel,
33091
33145
  {
@@ -33101,19 +33155,19 @@ var FieldLabelInternal = ({
33101
33155
  var InputOrGroup = (_a) => {
33102
33156
  var _b = _a, { onChange } = _b, props = __objRest(_b, ["onChange"]);
33103
33157
  const { name, field, value, readOnly } = props;
33104
- const [localValue, setLocalValue] = (0, import_react30.useState)(value);
33158
+ const [localValue, setLocalValue] = (0, import_react31.useState)(value);
33105
33159
  const onChangeDb = (0, import_use_debounce2.useDebouncedCallback)(
33106
- (val) => {
33107
- onChange(val);
33160
+ (val, ui) => {
33161
+ onChange(val, ui);
33108
33162
  },
33109
33163
  50,
33110
33164
  { leading: true }
33111
33165
  );
33112
- const onChangeLocal = (0, import_react30.useCallback)((val) => {
33166
+ const onChangeLocal = (0, import_react31.useCallback)((val, ui) => {
33113
33167
  setLocalValue(val);
33114
- onChangeDb(val);
33168
+ onChangeDb(val, ui);
33115
33169
  }, []);
33116
- (0, import_react30.useEffect)(() => {
33170
+ (0, import_react31.useEffect)(() => {
33117
33171
  setLocalValue(value);
33118
33172
  }, [value]);
33119
33173
  const localProps = {
@@ -33154,7 +33208,7 @@ var import_dnd6 = require("@hello-pangea/dnd");
33154
33208
 
33155
33209
  // css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
33156
33210
  init_react_import();
33157
- var styles_module_default9 = { "ComponentList": "_ComponentList_3rdy2_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_3rdy2_6", "ComponentList-content": "_ComponentList-content_3rdy2_10", "ComponentList-title": "_ComponentList-title_3rdy2_18", "ComponentList-titleIcon": "_ComponentList-titleIcon_3rdy2_39", "ComponentListItem": "_ComponentListItem_3rdy2_43", "ComponentListItem-draggable": "_ComponentListItem-draggable_3rdy2_43", "ComponentListItemIcon": "_ComponentListItemIcon_3rdy2_61", "ComponentList--isDraggingFrom": "_ComponentList--isDraggingFrom_3rdy2_65" };
33211
+ var styles_module_default9 = { "ComponentList": "_ComponentList_1m8r5_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1m8r5_6", "ComponentList-content": "_ComponentList-content_1m8r5_10", "ComponentList-title": "_ComponentList-title_1m8r5_18", "ComponentList-titleIcon": "_ComponentList-titleIcon_1m8r5_39", "ComponentListItem": "_ComponentListItem_1m8r5_43", "ComponentListItem-draggable": "_ComponentListItem-draggable_1m8r5_43", "ComponentListItem-name": "_ComponentListItem-name_1m8r5_60", "ComponentList--isDraggingFrom": "_ComponentList--isDraggingFrom_1m8r5_66" };
33158
33212
 
33159
33213
  // components/ComponentList/index.tsx
33160
33214
  var import_jsx_runtime18 = require("react/jsx-runtime");
@@ -33174,7 +33228,7 @@ var ComponentListItem = ({
33174
33228
  disableAnimations: true,
33175
33229
  className: () => getClassNameItem2("draggable"),
33176
33230
  children: () => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
33177
- component,
33231
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassNameItem2("name"), children: component }),
33178
33232
  /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DragIcon, {}) })
33179
33233
  ] })
33180
33234
  },
@@ -33243,10 +33297,10 @@ ComponentList.Item = ComponentListItem;
33243
33297
 
33244
33298
  // lib/use-placeholder-style.ts
33245
33299
  init_react_import();
33246
- var import_react31 = require("react");
33300
+ var import_react32 = require("react");
33247
33301
  var usePlaceholderStyle = () => {
33248
33302
  const queryAttr = "data-rfd-drag-handle-draggable-id";
33249
- const [placeholderStyle, setPlaceholderStyle] = (0, import_react31.useState)();
33303
+ const [placeholderStyle, setPlaceholderStyle] = (0, import_react32.useState)();
33250
33304
  const onDragStartOrUpdate = (draggedItem) => {
33251
33305
  var _a;
33252
33306
  const draggableId = draggedItem.draggableId;
@@ -33294,11 +33348,11 @@ init_react_import();
33294
33348
 
33295
33349
  // css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
33296
33350
  init_react_import();
33297
- var styles_module_default10 = { "SidebarSection": "_SidebarSection_r7dv3_1", "SidebarSection-title": "_SidebarSection-title_r7dv3_12", "SidebarSection-content": "_SidebarSection-content_r7dv3_19", "SidebarSection--noPadding": "_SidebarSection--noPadding_r7dv3_24", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_r7dv3_33", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_r7dv3_44", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_r7dv3_33", "SidebarSection-heading": "_SidebarSection-heading_r7dv3_56", "SidebarSection-loadingOverlay": "_SidebarSection-loadingOverlay_r7dv3_60" };
33351
+ var styles_module_default10 = { "SidebarSection": "_SidebarSection_1uyg2_1", "SidebarSection-title": "_SidebarSection-title_1uyg2_12", "SidebarSection-content": "_SidebarSection-content_1uyg2_19", "SidebarSection--noPadding": "_SidebarSection--noPadding_1uyg2_24", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_1uyg2_37", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_1uyg2_48", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_1uyg2_37", "SidebarSection-heading": "_SidebarSection-heading_1uyg2_60", "SidebarSection-loadingOverlay": "_SidebarSection-loadingOverlay_1uyg2_64" };
33298
33352
 
33299
33353
  // lib/use-breadcrumbs.ts
33300
33354
  init_react_import();
33301
- var import_react32 = require("react");
33355
+ var import_react33 = require("react");
33302
33356
  var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
33303
33357
  const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
33304
33358
  const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
@@ -33348,8 +33402,8 @@ var useBreadcrumbs = (renderCount) => {
33348
33402
  state: { data },
33349
33403
  selectedItem
33350
33404
  } = useAppContext();
33351
- const dzContext = (0, import_react32.useContext)(dropZoneContext);
33352
- return (0, import_react32.useMemo)(() => {
33405
+ const dzContext = (0, import_react33.useContext)(dropZoneContext);
33406
+ return (0, import_react33.useMemo)(() => {
33353
33407
  const breadcrumbs = convertPathDataToBreadcrumbs(
33354
33408
  selectedItem,
33355
33409
  dzContext == null ? void 0 : dzContext.pathData,
@@ -33401,15 +33455,22 @@ init_react_import();
33401
33455
 
33402
33456
  // lib/use-puck-history.ts
33403
33457
  init_react_import();
33404
- var import_react34 = require("react");
33458
+ var import_react35 = require("react");
33405
33459
 
33406
33460
  // lib/use-action-history.ts
33407
33461
  init_react_import();
33408
- var import_react33 = require("react");
33462
+ var import_react34 = require("react");
33463
+
33464
+ // lib/generate-id.ts
33465
+ init_react_import();
33466
+ var import_crypto = require("crypto");
33467
+ var generateId = (type) => `${type}-${(0, import_crypto.randomBytes)(20).toString("hex")}`;
33468
+
33469
+ // lib/use-action-history.ts
33409
33470
  var EMPTY_HISTORY_INDEX = -1;
33410
33471
  function useActionHistory() {
33411
- const [histories, setHistories] = (0, import_react33.useState)([]);
33412
- const [currentHistoryIndex, setCurrentHistoryIndex] = (0, import_react33.useState)(EMPTY_HISTORY_INDEX);
33472
+ const [histories, setHistories] = (0, import_react34.useState)([]);
33473
+ const [currentHistoryIndex, setCurrentHistoryIndex] = (0, import_react34.useState)(EMPTY_HISTORY_INDEX);
33413
33474
  const currentHistory = histories[currentHistoryIndex];
33414
33475
  const canRewind = currentHistoryIndex > EMPTY_HISTORY_INDEX;
33415
33476
  const canForward = currentHistoryIndex < histories.length - 1;
@@ -33488,7 +33549,7 @@ function usePuckHistory({
33488
33549
  dispatch
33489
33550
  });
33490
33551
  }, DEBOUNCE_TIME);
33491
- (0, import_react34.useEffect)(() => {
33552
+ (0, import_react35.useEffect)(() => {
33492
33553
  historyEmitter.on(RECORD_DIFF, handleRecordDiff);
33493
33554
  return () => {
33494
33555
  historyEmitter.off(RECORD_DIFF, handleRecordDiff);
@@ -33814,13 +33875,19 @@ var storeInterceptor = (reducer) => {
33814
33875
  return newAppState;
33815
33876
  };
33816
33877
  };
33878
+ var setAction = (state, action) => {
33879
+ if (typeof action.state === "object") {
33880
+ return __spreadValues(__spreadValues({}, state), action.state);
33881
+ }
33882
+ return __spreadValues(__spreadValues({}, state), action.state(state));
33883
+ };
33817
33884
  var createReducer = ({
33818
33885
  config
33819
33886
  }) => storeInterceptor((state, action) => {
33820
33887
  const data = reduceData(state.data, action, config);
33821
33888
  const ui = reduceUi(state.ui, action);
33822
33889
  if (action.type === "set") {
33823
- return __spreadValues(__spreadValues({}, state), action.state);
33890
+ return setAction(state, action);
33824
33891
  }
33825
33892
  return { data, ui };
33826
33893
  });
@@ -33830,7 +33897,7 @@ init_react_import();
33830
33897
 
33831
33898
  // css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
33832
33899
  init_react_import();
33833
- var styles_module_default11 = { "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" };
33900
+ var styles_module_default11 = { "LayerTree": "_LayerTree_o89yt_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_o89yt_11", "LayerTree-helper": "_LayerTree-helper_o89yt_17", "Layer": "_Layer_o89yt_1", "Layer-inner": "_Layer-inner_o89yt_29", "Layer--containsZone": "_Layer--containsZone_o89yt_35", "Layer-clickable": "_Layer-clickable_o89yt_39", "Layer--isSelected": "_Layer--isSelected_o89yt_48", "Layer--isHovering": "_Layer--isHovering_o89yt_49", "Layer-chevron": "_Layer-chevron_o89yt_65", "Layer--childIsSelected": "_Layer--childIsSelected_o89yt_66", "Layer-zones": "_Layer-zones_o89yt_70", "Layer-title": "_Layer-title_o89yt_84", "Layer-name": "_Layer-name_o89yt_93", "Layer-icon": "_Layer-icon_o89yt_99", "Layer-zoneIcon": "_Layer-zoneIcon_o89yt_104" };
33834
33901
 
33835
33902
  // lib/scroll-into-view.ts
33836
33903
  init_react_import();
@@ -33844,7 +33911,7 @@ var scrollIntoView = (el) => {
33844
33911
  };
33845
33912
 
33846
33913
  // components/LayerTree/index.tsx
33847
- var import_react35 = require("react");
33914
+ var import_react36 = require("react");
33848
33915
 
33849
33916
  // lib/find-zones-for-area.ts
33850
33917
  init_react_import();
@@ -33882,7 +33949,7 @@ var LayerTree = ({
33882
33949
  label
33883
33950
  }) => {
33884
33951
  const zones = data.zones || {};
33885
- const ctx = (0, import_react35.useContext)(dropZoneContext);
33952
+ const ctx = (0, import_react36.useContext)(dropZoneContext);
33886
33953
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
33887
33954
  label && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: getClassName17("zoneTitle"), children: [
33888
33955
  /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName17("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(layers_default, { size: "16" }) }),
@@ -33956,7 +34023,7 @@ var LayerTree = ({
33956
34023
  ),
33957
34024
  /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: getClassNameLayer("title"), children: [
33958
34025
  /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(type_default, { size: "16" }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(grid_default, { size: "16" }) }),
33959
- item.type
34026
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassNameLayer("name"), children: item.type })
33960
34027
  ] })
33961
34028
  ]
33962
34029
  }
@@ -34007,11 +34074,11 @@ var flushZones = (appState) => {
34007
34074
 
34008
34075
  // lib/use-component-list.tsx
34009
34076
  init_react_import();
34010
- var import_react36 = require("react");
34077
+ var import_react37 = require("react");
34011
34078
  var import_jsx_runtime21 = require("react/jsx-runtime");
34012
34079
  var useComponentList = (config, ui) => {
34013
- const [componentList, setComponentList] = (0, import_react36.useState)();
34014
- (0, import_react36.useEffect)(() => {
34080
+ const [componentList, setComponentList] = (0, import_react37.useState)();
34081
+ (0, import_react37.useEffect)(() => {
34015
34082
  var _a, _b, _c;
34016
34083
  if (Object.keys(ui.componentList).length > 0) {
34017
34084
  const matchedComponents = [];
@@ -34077,7 +34144,7 @@ var useComponentList = (config, ui) => {
34077
34144
 
34078
34145
  // lib/use-resolved-data.ts
34079
34146
  init_react_import();
34080
- var import_react37 = require("react");
34147
+ var import_react38 = require("react");
34081
34148
 
34082
34149
  // lib/resolve-component-data.ts
34083
34150
  init_react_import();
@@ -34191,20 +34258,20 @@ var resolveRootData = (data, config) => __async(void 0, null, function* () {
34191
34258
  });
34192
34259
 
34193
34260
  // lib/use-resolved-data.ts
34194
- var useResolvedData = (data, config, dispatch) => {
34195
- const [{ resolverKey, newData }, setResolverState] = (0, import_react37.useState)({
34261
+ var useResolvedData = (appState, config, dispatch) => {
34262
+ const [{ resolverKey, newAppState }, setResolverState] = (0, import_react38.useState)({
34196
34263
  resolverKey: 0,
34197
- newData: data
34264
+ newAppState: appState
34198
34265
  });
34199
- const [componentState, setComponentState] = (0, import_react37.useState)({});
34266
+ const [componentState, setComponentState] = (0, import_react38.useState)({});
34200
34267
  const deferredSetStates = {};
34201
- const setComponentLoading = (0, import_react37.useCallback)(
34268
+ const setComponentLoading = (0, import_react38.useCallback)(
34202
34269
  (id, loading, defer = 0) => {
34203
34270
  if (deferredSetStates[id]) {
34204
34271
  clearTimeout(deferredSetStates[id]);
34205
34272
  delete deferredSetStates[id];
34206
34273
  }
34207
- const setLoading = deferredSetStates[id] = setTimeout(() => {
34274
+ deferredSetStates[id] = setTimeout(() => {
34208
34275
  setComponentState((prev) => __spreadProps(__spreadValues({}, prev), {
34209
34276
  [id]: __spreadProps(__spreadValues({}, prev[id]), { loading })
34210
34277
  }));
@@ -34214,14 +34281,23 @@ var useResolvedData = (data, config, dispatch) => {
34214
34281
  []
34215
34282
  );
34216
34283
  const runResolvers = () => __async(void 0, null, function* () {
34284
+ const newData = newAppState.data;
34217
34285
  const flatContent = Object.keys(newData.zones || {}).reduce((acc, zone) => [...acc, ...newData.zones[zone]], newData.content).filter((item) => !!config.components[item.type].resolveData);
34218
34286
  const applyIfChange = (dynamicDataMap, dynamicRoot) => {
34219
- const processed = applyDynamicProps(data, dynamicDataMap, dynamicRoot);
34220
- const containsChanges = JSON.stringify(data) !== JSON.stringify(processed);
34287
+ const processed = applyDynamicProps(
34288
+ appState.data,
34289
+ dynamicDataMap,
34290
+ dynamicRoot
34291
+ );
34292
+ const processedAppState = __spreadProps(__spreadValues({}, appState), { data: processed });
34293
+ const containsChanges = JSON.stringify(appState) !== JSON.stringify(processedAppState);
34221
34294
  if (containsChanges) {
34222
34295
  dispatch({
34223
- type: "setData",
34224
- data: (prev) => applyDynamicProps(prev, dynamicDataMap, dynamicRoot),
34296
+ type: "set",
34297
+ state: (prev) => __spreadProps(__spreadValues({}, prev), {
34298
+ data: applyDynamicProps(prev.data, dynamicDataMap, dynamicRoot),
34299
+ ui: __spreadValues(__spreadValues({}, prev.ui), newAppState.ui)
34300
+ }),
34225
34301
  recordHistory: resolverKey > 0
34226
34302
  });
34227
34303
  }
@@ -34256,13 +34332,13 @@ var useResolvedData = (data, config, dispatch) => {
34256
34332
  });
34257
34333
  yield Promise.all(promises);
34258
34334
  });
34259
- (0, import_react37.useEffect)(() => {
34335
+ (0, import_react38.useEffect)(() => {
34260
34336
  runResolvers();
34261
34337
  }, [resolverKey]);
34262
- const resolveData = (0, import_react37.useCallback)((newData2 = data) => {
34338
+ const resolveData = (0, import_react38.useCallback)((newAppState2 = appState) => {
34263
34339
  setResolverState((curr) => ({
34264
34340
  resolverKey: curr.resolverKey + 1,
34265
- newData: newData2
34341
+ newAppState: newAppState2
34266
34342
  }));
34267
34343
  }, []);
34268
34344
  return {
@@ -34271,8 +34347,86 @@ var useResolvedData = (data, config, dispatch) => {
34271
34347
  };
34272
34348
  };
34273
34349
 
34274
- // components/Puck/index.tsx
34350
+ // components/MenuBar/index.tsx
34351
+ init_react_import();
34352
+
34353
+ // css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
34354
+ init_react_import();
34355
+ var styles_module_default12 = { "MenuBar": "_MenuBar_12sp7_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_12sp7_14", "MenuBar-inner": "_MenuBar-inner_12sp7_29", "MenuBar-history": "_MenuBar-history_12sp7_45" };
34356
+
34357
+ // components/MenuBar/index.tsx
34275
34358
  var import_jsx_runtime22 = require("react/jsx-runtime");
34359
+ var getClassName18 = get_class_name_factory_default("MenuBar", styles_module_default12);
34360
+ var MenuBar = ({
34361
+ appState,
34362
+ data = { content: [], root: { props: { title: "" } } },
34363
+ dispatch,
34364
+ menuOpen = false,
34365
+ onPublish,
34366
+ renderHeaderActions,
34367
+ setMenuOpen
34368
+ }) => {
34369
+ const { canForward, canRewind, rewind, forward } = usePuckHistory({
34370
+ appState,
34371
+ dispatch
34372
+ });
34373
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34374
+ "div",
34375
+ {
34376
+ className: getClassName18({ menuOpen }),
34377
+ onClick: (event) => {
34378
+ var _a;
34379
+ const element = event.target;
34380
+ if (window.matchMedia("(min-width: 638px)").matches) {
34381
+ return;
34382
+ }
34383
+ if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
34384
+ setMenuOpen(false);
34385
+ }
34386
+ },
34387
+ children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: getClassName18("inner"), children: [
34388
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: getClassName18("history"), children: [
34389
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(IconButton, { title: "undo", disabled: !canRewind, onClick: rewind, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34390
+ chevron_left_default,
34391
+ {
34392
+ size: 21,
34393
+ stroke: canRewind ? "var(--puck-color-black)" : "var(--puck-color-grey-7)"
34394
+ }
34395
+ ) }),
34396
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(IconButton, { title: "redo", disabled: !canForward, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34397
+ chevron_right_default,
34398
+ {
34399
+ size: 21,
34400
+ stroke: canForward ? "var(--puck-color-black)" : "var(--puck-color-grey-7)"
34401
+ }
34402
+ ) })
34403
+ ] }),
34404
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_jsx_runtime22.Fragment, { children: renderHeaderActions && renderHeaderActions({
34405
+ state: appState,
34406
+ dispatch
34407
+ }) }),
34408
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34409
+ Button,
34410
+ {
34411
+ onClick: () => {
34412
+ onPublish(data);
34413
+ },
34414
+ icon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(globe_default, { size: "14px" }),
34415
+ children: "Publish"
34416
+ }
34417
+ ) })
34418
+ ] })
34419
+ }
34420
+ );
34421
+ };
34422
+
34423
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
34424
+ init_react_import();
34425
+ var styles_module_default13 = { "Puck": "_Puck_103k9_19", "Puck--leftSideBarVisible": "_Puck--leftSideBarVisible_103k9_35", "Puck--rightSideBarVisible": "_Puck--rightSideBarVisible_103k9_41", "Puck-header": "_Puck-header_103k9_95", "Puck-headerInner": "_Puck-headerInner_103k9_104", "Puck-headerToggle": "_Puck-headerToggle_103k9_114", "Puck-rightSideBarToggle": "_Puck-rightSideBarToggle_103k9_121", "Puck-leftSideBarToggle": "_Puck-leftSideBarToggle_103k9_126", "Puck-headerTitle": "_Puck-headerTitle_103k9_130", "Puck-headerPath": "_Puck-headerPath_103k9_134", "Puck-headerTools": "_Puck-headerTools_103k9_141", "Puck-menuButton": "_Puck-menuButton_103k9_147", "Puck--menuOpen": "_Puck--menuOpen_103k9_152", "Puck-leftSideBar": "_Puck-leftSideBar_103k9_126", "Puck-frame": "_Puck-frame_103k9_171", "Puck-root": "_Puck-root_103k9_179", "Puck-page": "_Puck-page_103k9_192", "Puck-rightSideBar": "_Puck-rightSideBar_103k9_121" };
34426
+
34427
+ // components/Puck/index.tsx
34428
+ var import_jsx_runtime23 = require("react/jsx-runtime");
34429
+ var getClassName19 = get_class_name_factory_default("Puck", styles_module_default13);
34276
34430
  var defaultPageFields = {
34277
34431
  title: { type: "text" }
34278
34432
  };
@@ -34284,7 +34438,7 @@ var PluginRenderer = ({
34284
34438
  renderMethod
34285
34439
  }) => {
34286
34440
  return plugins.filter((item) => item[renderMethod]).map((item) => item[renderMethod]).reduce(
34287
- (accChildren, Item) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Item, { dispatch, state, children: accChildren }),
34441
+ (accChildren, Item) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Item, { dispatch, state, children: accChildren }),
34288
34442
  children
34289
34443
  );
34290
34444
  };
@@ -34301,8 +34455,8 @@ function Puck({
34301
34455
  headerPath
34302
34456
  }) {
34303
34457
  var _a, _b;
34304
- const [reducer] = (0, import_react38.useState)(() => createReducer({ config }));
34305
- const initialAppState = __spreadProps(__spreadValues({}, defaultAppState), {
34458
+ const [reducer] = (0, import_react39.useState)(() => createReducer({ config }));
34459
+ const [initialAppState] = (0, import_react39.useState)(__spreadProps(__spreadValues({}, defaultAppState), {
34306
34460
  data: initialData,
34307
34461
  ui: __spreadProps(__spreadValues({}, defaultAppState.ui), {
34308
34462
  // Store categories under componentList on state to allow render functions and plugins to modify
@@ -34320,23 +34474,20 @@ function Puck({
34320
34474
  {}
34321
34475
  ) : {}
34322
34476
  })
34323
- });
34324
- const [appState, dispatch] = (0, import_react38.useReducer)(
34477
+ }));
34478
+ const [appState, dispatch] = (0, import_react39.useReducer)(
34325
34479
  reducer,
34326
34480
  flushZones(initialAppState)
34327
34481
  );
34328
34482
  const { data, ui } = appState;
34329
34483
  const { resolveData, componentState } = useResolvedData(
34330
- data,
34484
+ appState,
34331
34485
  config,
34332
34486
  dispatch
34333
34487
  );
34334
- const { canForward, canRewind, rewind, forward } = usePuckHistory({
34335
- appState,
34336
- dispatch
34337
- });
34338
- const { itemSelector, leftSideBarVisible } = ui;
34339
- const setItemSelector = (0, import_react38.useCallback)(
34488
+ const [menuOpen, setMenuOpen] = (0, import_react39.useState)(false);
34489
+ const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
34490
+ const setItemSelector = (0, import_react39.useCallback)(
34340
34491
  (newItemSelector) => {
34341
34492
  dispatch({
34342
34493
  type: "setUi",
@@ -34346,10 +34497,10 @@ function Puck({
34346
34497
  []
34347
34498
  );
34348
34499
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
34349
- const Page = (0, import_react38.useCallback)(
34500
+ const Page = (0, import_react39.useCallback)(
34350
34501
  (pageProps) => {
34351
34502
  var _a2, _b2;
34352
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34503
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
34353
34504
  PluginRenderer,
34354
34505
  {
34355
34506
  plugins,
@@ -34362,8 +34513,8 @@ function Puck({
34362
34513
  },
34363
34514
  [config.root]
34364
34515
  );
34365
- const PageFieldWrapper = (0, import_react38.useCallback)(
34366
- (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34516
+ const PageFieldWrapper = (0, import_react39.useCallback)(
34517
+ (props) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
34367
34518
  PluginRenderer,
34368
34519
  {
34369
34520
  plugins,
@@ -34375,8 +34526,8 @@ function Puck({
34375
34526
  ),
34376
34527
  []
34377
34528
  );
34378
- const ComponentFieldWrapper = (0, import_react38.useCallback)(
34379
- (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34529
+ const ComponentFieldWrapper = (0, import_react39.useCallback)(
34530
+ (props) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
34380
34531
  PluginRenderer,
34381
34532
  {
34382
34533
  plugins,
@@ -34388,8 +34539,8 @@ function Puck({
34388
34539
  ),
34389
34540
  []
34390
34541
  );
34391
- const ComponentListWrapper = (0, import_react38.useCallback)((props) => {
34392
- const children = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34542
+ const ComponentListWrapper = (0, import_react39.useCallback)((props) => {
34543
+ const children = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
34393
34544
  PluginRenderer,
34394
34545
  {
34395
34546
  plugins,
@@ -34408,27 +34559,64 @@ function Puck({
34408
34559
  const FieldWrapper = itemSelector ? ComponentFieldWrapper : PageFieldWrapper;
34409
34560
  const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
34410
34561
  let fields = selectedItem ? ((_b = config.components[selectedItem.type]) == null ? void 0 : _b.fields) || {} : rootFields;
34411
- (0, import_react38.useEffect)(() => {
34562
+ (0, import_react39.useEffect)(() => {
34412
34563
  if (onChange)
34413
34564
  onChange(data);
34414
34565
  }, [data]);
34415
34566
  const { onDragStartOrUpdate, placeholderStyle } = usePlaceholderStyle();
34416
- const [draggedItem, setDraggedItem] = (0, import_react38.useState)();
34567
+ const [draggedItem, setDraggedItem] = (0, import_react39.useState)();
34417
34568
  const componentList = useComponentList(config, appState.ui);
34418
34569
  const rootProps = data.root.props || data.root;
34419
- (0, import_react38.useEffect)(() => {
34570
+ (0, import_react39.useEffect)(() => {
34420
34571
  if (Object.keys(data.root).length > 0 && !data.root.props) {
34421
34572
  console.error(
34422
34573
  "Warning: Defining props on `root` is deprecated. Please use `root.props`. This will be a breaking change in a future release."
34423
34574
  );
34424
34575
  }
34425
34576
  }, []);
34426
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "puck", children: [
34427
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34577
+ const toggleSidebars = (0, import_react39.useCallback)(
34578
+ (sidebar) => {
34579
+ const widerViewport = window.matchMedia("(min-width: 638px)").matches;
34580
+ const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
34581
+ const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
34582
+ dispatch({
34583
+ type: "setUi",
34584
+ ui: __spreadValues({
34585
+ [`${sidebar}SideBarVisible`]: !sideBarVisible
34586
+ }, !widerViewport ? { [oppositeSideBar]: false } : {})
34587
+ });
34588
+ },
34589
+ [dispatch, leftSideBarVisible, rightSideBarVisible]
34590
+ );
34591
+ (0, import_react39.useEffect)(() => {
34592
+ if (!window.matchMedia("(min-width: 638px)").matches) {
34593
+ dispatch({
34594
+ type: "setUi",
34595
+ ui: {
34596
+ leftSideBarVisible: false,
34597
+ rightSideBarVisible: false
34598
+ }
34599
+ });
34600
+ }
34601
+ const handleResize = () => {
34602
+ if (!window.matchMedia("(min-width: 638px)").matches) {
34603
+ dispatch({
34604
+ type: "setUi",
34605
+ ui: (ui2) => __spreadValues(__spreadValues({}, ui2), ui2.rightSideBarVisible ? { leftSideBarVisible: false } : {})
34606
+ });
34607
+ }
34608
+ };
34609
+ window.addEventListener("resize", handleResize);
34610
+ return () => {
34611
+ window.removeEventListener("resize", handleResize);
34612
+ };
34613
+ }, []);
34614
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { children: [
34615
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
34428
34616
  AppProvider,
34429
34617
  {
34430
34618
  value: { state: appState, dispatch, config, componentState },
34431
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34619
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
34432
34620
  import_dnd7.DragDropContext,
34433
34621
  {
34434
34622
  onDragUpdate: (update) => {
@@ -34481,7 +34669,7 @@ function Puck({
34481
34669
  });
34482
34670
  }
34483
34671
  },
34484
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34672
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
34485
34673
  DropZoneProvider,
34486
34674
  {
34487
34675
  value: {
@@ -34495,248 +34683,133 @@ function Puck({
34495
34683
  mode: "edit",
34496
34684
  areaId: "root"
34497
34685
  },
34498
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(dropZoneContext.Consumer, { children: (ctx) => {
34686
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(dropZoneContext.Consumer, { children: (ctx) => {
34499
34687
  var _a2, _b2;
34500
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
34688
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
34501
34689
  "div",
34502
34690
  {
34503
- style: {
34504
- display: "grid",
34505
- gridTemplateAreas: '"header header header" "left editor right"',
34506
- gridTemplateColumns: `${leftSideBarVisible ? "288px" : "0px"} auto 288px`,
34507
- gridTemplateRows: "min-content auto",
34508
- height: "100vh",
34509
- position: "fixed",
34510
- top: 0,
34511
- bottom: 0,
34512
- left: 0,
34513
- right: 0
34514
- },
34691
+ className: getClassName19({
34692
+ leftSideBarVisible,
34693
+ menuOpen,
34694
+ rightSideBarVisible
34695
+ }),
34515
34696
  children: [
34516
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34517
- "header",
34518
- {
34519
- style: {
34520
- gridArea: "header",
34521
- color: "var(--puck-color-black)",
34522
- background: "var(--puck-color-white)",
34523
- borderBottom: "1px solid var(--puck-color-grey-8)"
34524
- },
34525
- children: renderHeader ? renderHeader({
34526
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34527
- Button,
34528
- {
34529
- onClick: () => {
34530
- onPublish(data);
34531
- },
34532
- icon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(globe_default, { size: "14px" }),
34533
- children: "Publish"
34534
- }
34535
- ),
34536
- dispatch,
34537
- state: appState
34538
- }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
34539
- "div",
34697
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("header", { className: getClassName19("header"), children: renderHeader ? renderHeader({
34698
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
34699
+ Button,
34700
+ {
34701
+ onClick: () => {
34702
+ onPublish(data);
34703
+ },
34704
+ icon: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(globe_default, { size: "14px" }),
34705
+ children: "Publish"
34706
+ }
34707
+ ),
34708
+ dispatch,
34709
+ state: appState
34710
+ }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: getClassName19("headerInner"), children: [
34711
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: getClassName19("headerToggle"), children: [
34712
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName19("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
34713
+ IconButton,
34540
34714
  {
34541
- style: {
34542
- display: "grid",
34543
- padding: 16,
34544
- gridTemplateAreas: '"left middle right"',
34545
- gridTemplateColumns: "344px auto 344px",
34546
- gridTemplateRows: "auto"
34715
+ onClick: () => {
34716
+ toggleSidebars("left");
34547
34717
  },
34548
- children: [
34549
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34550
- "div",
34551
- {
34552
- style: {
34553
- display: "flex",
34554
- gap: 16
34555
- },
34556
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34557
- IconButton,
34558
- {
34559
- onClick: () => dispatch({
34560
- type: "setUi",
34561
- ui: {
34562
- leftSideBarVisible: !leftSideBarVisible
34563
- }
34564
- }),
34565
- title: "Toggle left sidebar",
34566
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(sidebar_default, {})
34567
- }
34568
- )
34569
- }
34570
- ),
34571
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34572
- "div",
34573
- {
34574
- style: {
34575
- display: "flex",
34576
- justifyContent: "center",
34577
- alignItems: "center"
34578
- },
34579
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(Heading, { rank: 2, size: "xs", children: [
34580
- headerTitle || rootProps.title || "Page",
34581
- headerPath && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34582
- "small",
34583
- {
34584
- style: { fontWeight: 400, marginLeft: 4 },
34585
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("code", { children: headerPath })
34586
- }
34587
- )
34588
- ] })
34589
- }
34590
- ),
34591
- /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
34592
- "div",
34593
- {
34594
- style: {
34595
- display: "flex",
34596
- gap: 16,
34597
- justifyContent: "flex-end"
34598
- },
34599
- children: [
34600
- /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { style: { display: "flex" }, children: [
34601
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34602
- IconButton,
34603
- {
34604
- title: "undo",
34605
- disabled: !canRewind,
34606
- onClick: rewind,
34607
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34608
- chevron_left_default,
34609
- {
34610
- size: 21,
34611
- stroke: canRewind ? "var(--puck-color-black)" : "var(--puck-color-grey-7)"
34612
- }
34613
- )
34614
- }
34615
- ),
34616
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34617
- IconButton,
34618
- {
34619
- title: "redo",
34620
- disabled: !canForward,
34621
- onClick: forward,
34622
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34623
- chevron_right_default,
34624
- {
34625
- size: 21,
34626
- stroke: canForward ? "var(--puck-color-black)" : "var(--puck-color-grey-7)"
34627
- }
34628
- )
34629
- }
34630
- )
34631
- ] }),
34632
- renderHeaderActions && renderHeaderActions({
34633
- state: appState,
34634
- dispatch
34635
- }),
34636
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34637
- Button,
34638
- {
34639
- onClick: () => {
34640
- onPublish(data);
34641
- },
34642
- icon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(globe_default, { size: "14px" }),
34643
- children: "Publish"
34644
- }
34645
- )
34646
- ]
34647
- }
34648
- )
34649
- ]
34718
+ title: "Toggle left sidebar",
34719
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(sidebar_default, { focusable: "false" })
34720
+ }
34721
+ ) }),
34722
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName19("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
34723
+ IconButton,
34724
+ {
34725
+ onClick: () => {
34726
+ toggleSidebars("right");
34727
+ },
34728
+ title: "Toggle right sidebar",
34729
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(sidebar_default, { focusable: "false" })
34730
+ }
34731
+ ) })
34732
+ ] }),
34733
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName19("headerTitle"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(Heading, { rank: 2, size: "xs", children: [
34734
+ headerTitle || rootProps.title || "Page",
34735
+ headerPath && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
34736
+ " ",
34737
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("code", { className: getClassName19("headerPath"), children: headerPath })
34738
+ ] })
34739
+ ] }) }),
34740
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: getClassName19("headerTools"), children: [
34741
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName19("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
34742
+ IconButton,
34743
+ {
34744
+ onClick: () => {
34745
+ return setMenuOpen(!menuOpen);
34746
+ },
34747
+ title: "Toggle menu bar",
34748
+ children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(chevron_up_default, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(chevron_down_default, { focusable: "false" })
34749
+ }
34750
+ ) }),
34751
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
34752
+ MenuBar,
34753
+ {
34754
+ appState,
34755
+ data,
34756
+ dispatch,
34757
+ onPublish,
34758
+ menuOpen,
34759
+ renderHeaderActions,
34760
+ setMenuOpen
34650
34761
  }
34651
34762
  )
34652
- }
34653
- ),
34654
- /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
34655
- "div",
34656
- {
34657
- style: {
34658
- gridArea: "left",
34659
- background: "var(--puck-color-grey-11)",
34660
- borderRight: "1px solid var(--puck-color-grey-8)",
34661
- overflowY: "auto",
34662
- display: "flex",
34663
- flexDirection: "column"
34664
- },
34665
- children: [
34666
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SidebarSection, { title: "Components", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ComponentListWrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ComponentList, { id: "all" }) }) }),
34667
- /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(SidebarSection, { title: "Outline", children: [
34668
- (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34763
+ ] })
34764
+ ] }) }),
34765
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: getClassName19("leftSideBar"), children: [
34766
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(SidebarSection, { title: "Components", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ComponentListWrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ComponentList, { id: "all" }) }) }),
34767
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(SidebarSection, { title: "Outline", children: [
34768
+ (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
34769
+ LayerTree,
34770
+ {
34771
+ data,
34772
+ label: areaContainsZones(data, "root") ? rootDroppableId : "",
34773
+ zoneContent: data.content,
34774
+ setItemSelector,
34775
+ itemSelector
34776
+ }
34777
+ ),
34778
+ Object.entries(findZonesForArea(data, "root")).map(
34779
+ ([zoneKey, zone]) => {
34780
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
34669
34781
  LayerTree,
34670
34782
  {
34671
34783
  data,
34672
- label: areaContainsZones(data, "root") ? rootDroppableId : "",
34673
- zoneContent: data.content,
34784
+ label: zoneKey,
34785
+ zone: zoneKey,
34786
+ zoneContent: zone,
34674
34787
  setItemSelector,
34675
34788
  itemSelector
34676
- }
34677
- ),
34678
- Object.entries(findZonesForArea(data, "root")).map(
34679
- ([zoneKey, zone]) => {
34680
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34681
- LayerTree,
34682
- {
34683
- data,
34684
- label: zoneKey,
34685
- zone: zoneKey,
34686
- zoneContent: zone,
34687
- setItemSelector,
34688
- itemSelector
34689
- },
34690
- zoneKey
34691
- );
34692
- }
34693
- )
34694
- ] })
34695
- ]
34696
- }
34697
- ),
34698
- /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
34789
+ },
34790
+ zoneKey
34791
+ );
34792
+ }
34793
+ )
34794
+ ] })
34795
+ ] }),
34796
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
34699
34797
  "div",
34700
34798
  {
34701
- style: {
34702
- overflowY: "auto",
34703
- gridArea: "editor",
34704
- position: "relative",
34705
- display: "flex",
34706
- flexDirection: "column"
34707
- },
34799
+ className: getClassName19("frame"),
34708
34800
  onClick: () => setItemSelector(null),
34709
34801
  id: "puck-frame",
34710
34802
  children: [
34711
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34712
- "div",
34713
- {
34714
- className: "puck-root",
34715
- style: {
34716
- boxShadow: "0px 0px 0px 32px var(--puck-color-grey-10)",
34717
- margin: 32,
34718
- zoom: 0.75
34719
- },
34720
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34721
- "div",
34722
- {
34723
- style: {
34724
- border: "1px solid var(--puck-color-grey-8)"
34725
- },
34726
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34727
- Page,
34728
- __spreadProps(__spreadValues({
34729
- dispatch,
34730
- state: appState
34731
- }, data.root), {
34732
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(DropZone, { zone: rootDroppableId })
34733
- })
34734
- )
34735
- }
34736
- )
34737
- }
34738
- ),
34739
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34803
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName19("root"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName19("page"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
34804
+ Page,
34805
+ __spreadProps(__spreadValues({
34806
+ dispatch,
34807
+ state: appState
34808
+ }, rootProps), {
34809
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZone, { zone: rootDroppableId })
34810
+ })
34811
+ ) }) }),
34812
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
34740
34813
  "div",
34741
34814
  {
34742
34815
  style: {
@@ -34749,106 +34822,118 @@ function Puck({
34749
34822
  ]
34750
34823
  }
34751
34824
  ),
34752
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34753
- "div",
34825
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: getClassName19("rightSideBar"), children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(FieldWrapper, { dispatch, state: appState, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
34826
+ SidebarSection,
34754
34827
  {
34755
- style: {
34756
- borderLeft: "1px solid var(--puck-color-grey-8)",
34757
- overflowY: "auto",
34758
- gridArea: "right",
34759
- fontFamily: "var(--puck-font-stack)",
34760
- display: "flex",
34761
- flexDirection: "column",
34762
- background: "var(--puck-color-white)"
34763
- },
34764
- children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(FieldWrapper, { dispatch, state: appState, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34765
- SidebarSection,
34766
- {
34767
- noPadding: true,
34768
- showBreadcrumbs: true,
34769
- title: selectedItem ? selectedItem.type : "Page",
34770
- isLoading: selectedItem ? (_a2 = componentState[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a2.loading : (_b2 = componentState["puck-root"]) == null ? void 0 : _b2.loading,
34771
- children: Object.keys(fields).map((fieldName) => {
34772
- const field = fields[fieldName];
34773
- const onChange2 = (value) => {
34774
- var _a3, _b3;
34775
- let currentProps;
34776
- if (selectedItem) {
34777
- currentProps = selectedItem.props;
34778
- } else {
34779
- currentProps = data.root;
34780
- }
34781
- const newProps = __spreadProps(__spreadValues({}, currentProps), {
34782
- [fieldName]: value
34783
- });
34784
- if (itemSelector) {
34785
- const action = {
34786
- type: "replace",
34787
- destinationIndex: itemSelector.index,
34788
- destinationZone: itemSelector.zone || rootDroppableId,
34789
- data: __spreadProps(__spreadValues({}, selectedItem), { props: newProps })
34790
- };
34791
- if ((_a3 = config.components[selectedItem.type]) == null ? void 0 : _a3.resolveData) {
34792
- resolveData(replaceAction(data, action));
34793
- } else {
34794
- dispatch(action);
34795
- }
34796
- } else {
34797
- if (data.root.props) {
34798
- if ((_b3 = config.root) == null ? void 0 : _b3.resolveData) {
34799
- resolveData(__spreadProps(__spreadValues({}, data), {
34800
- root: { props: { newProps } }
34801
- }));
34802
- } else {
34803
- dispatch({
34804
- type: "setData",
34805
- data: { root: { props: { newProps } } }
34806
- });
34807
- }
34808
- } else {
34809
- dispatch({
34810
- type: "setData",
34811
- data: { root: newProps }
34812
- });
34813
- }
34828
+ noPadding: true,
34829
+ showBreadcrumbs: true,
34830
+ title: selectedItem ? selectedItem.type : "Page",
34831
+ isLoading: selectedItem ? (_a2 = componentState[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a2.loading : (_b2 = componentState["puck-root"]) == null ? void 0 : _b2.loading,
34832
+ children: Object.keys(fields).map((fieldName) => {
34833
+ const field = fields[fieldName];
34834
+ const onChange2 = (value, updatedUi) => {
34835
+ var _a3, _b3;
34836
+ let currentProps;
34837
+ if (selectedItem) {
34838
+ currentProps = selectedItem.props;
34839
+ } else {
34840
+ currentProps = rootProps;
34841
+ }
34842
+ const newProps = __spreadProps(__spreadValues({}, currentProps), {
34843
+ [fieldName]: value
34844
+ });
34845
+ if (itemSelector) {
34846
+ const replaceActionData = {
34847
+ type: "replace",
34848
+ destinationIndex: itemSelector.index,
34849
+ destinationZone: itemSelector.zone || rootDroppableId,
34850
+ data: __spreadProps(__spreadValues({}, selectedItem), { props: newProps })
34851
+ };
34852
+ const replacedData = replaceAction(
34853
+ data,
34854
+ replaceActionData
34855
+ );
34856
+ const setActionData = {
34857
+ type: "set",
34858
+ state: {
34859
+ data: __spreadValues(__spreadValues({}, data), replacedData),
34860
+ ui: __spreadValues(__spreadValues({}, ui), updatedUi)
34814
34861
  }
34815
34862
  };
34816
- if (selectedItem && itemSelector) {
34817
- const { readOnly = {} } = selectedItem;
34818
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34819
- InputOrGroup,
34820
- {
34821
- field,
34822
- name: fieldName,
34823
- label: field.label,
34824
- readOnly: readOnly[fieldName],
34825
- readOnlyFields: readOnly,
34826
- value: selectedItem.props[fieldName],
34827
- onChange: onChange2
34828
- },
34829
- `${selectedItem.props.id}_${fieldName}`
34863
+ if ((_a3 = config.components[selectedItem.type]) == null ? void 0 : _a3.resolveData) {
34864
+ resolveData(
34865
+ setAction(appState, setActionData)
34830
34866
  );
34831
34867
  } else {
34832
- const { readOnly = {} } = data.root;
34833
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
34834
- InputOrGroup,
34835
- {
34836
- field,
34837
- name: fieldName,
34838
- label: field.label,
34839
- readOnly: readOnly[fieldName],
34840
- readOnlyFields: readOnly,
34841
- value: rootProps[fieldName],
34842
- onChange: onChange2
34843
- },
34844
- `page_${fieldName}`
34845
- );
34868
+ dispatch(__spreadProps(__spreadValues({}, setActionData), {
34869
+ recordHistory: true
34870
+ }));
34846
34871
  }
34847
- })
34872
+ } else {
34873
+ if (data.root.props) {
34874
+ if ((_b3 = config.root) == null ? void 0 : _b3.resolveData) {
34875
+ resolveData({
34876
+ ui: __spreadValues(__spreadValues({}, ui), updatedUi),
34877
+ data: __spreadProps(__spreadValues({}, data), {
34878
+ root: { props: newProps }
34879
+ })
34880
+ });
34881
+ } else {
34882
+ dispatch({
34883
+ type: "set",
34884
+ state: {
34885
+ ui: __spreadValues(__spreadValues({}, ui), updatedUi),
34886
+ data: __spreadProps(__spreadValues({}, data), {
34887
+ root: { props: newProps }
34888
+ })
34889
+ },
34890
+ recordHistory: true
34891
+ });
34892
+ }
34893
+ } else {
34894
+ dispatch({
34895
+ type: "setData",
34896
+ data: { root: newProps }
34897
+ });
34898
+ }
34899
+ }
34900
+ };
34901
+ if (selectedItem && itemSelector) {
34902
+ const { readOnly = {} } = selectedItem;
34903
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
34904
+ InputOrGroup,
34905
+ {
34906
+ field,
34907
+ name: fieldName,
34908
+ id: `${selectedItem.props.id}_${fieldName}`,
34909
+ label: field.label,
34910
+ readOnly: readOnly[fieldName],
34911
+ readOnlyFields: readOnly,
34912
+ value: selectedItem.props[fieldName],
34913
+ onChange: onChange2
34914
+ },
34915
+ `${selectedItem.props.id}_${fieldName}`
34916
+ );
34917
+ } else {
34918
+ const { readOnly = {} } = data.root;
34919
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
34920
+ InputOrGroup,
34921
+ {
34922
+ field,
34923
+ name: fieldName,
34924
+ id: `root_${fieldName}`,
34925
+ label: field.label,
34926
+ readOnly: readOnly[fieldName],
34927
+ readOnlyFields: readOnly,
34928
+ value: rootProps[fieldName],
34929
+ onChange: onChange2
34930
+ },
34931
+ `page_${fieldName}`
34932
+ );
34848
34933
  }
34849
- ) })
34934
+ })
34850
34935
  }
34851
- )
34936
+ ) }) })
34852
34937
  ]
34853
34938
  }
34854
34939
  );
@@ -34859,19 +34944,19 @@ function Puck({
34859
34944
  )
34860
34945
  }
34861
34946
  ),
34862
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { id: "puck-portal-root" })
34947
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id: "puck-portal-root" })
34863
34948
  ] });
34864
34949
  }
34865
34950
 
34866
34951
  // components/Render/index.tsx
34867
34952
  init_react_import();
34868
- var import_jsx_runtime23 = require("react/jsx-runtime");
34953
+ var import_jsx_runtime24 = require("react/jsx-runtime");
34869
34954
  function Render({ config, data }) {
34870
34955
  var _a;
34871
34956
  const rootProps = data.root.props || data.root;
34872
34957
  const title = rootProps.title || "";
34873
34958
  if ((_a = config.root) == null ? void 0 : _a.render) {
34874
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZoneProvider, { value: { data, config, mode: "render" }, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
34959
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneProvider, { value: { data, config, mode: "render" }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
34875
34960
  config.root.render,
34876
34961
  __spreadProps(__spreadValues({}, rootProps), {
34877
34962
  puck: {
@@ -34880,11 +34965,11 @@ function Render({ config, data }) {
34880
34965
  title,
34881
34966
  editMode: false,
34882
34967
  id: "puck-root",
34883
- children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZone, { zone: rootDroppableId })
34968
+ children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZone, { zone: rootDroppableId })
34884
34969
  })
34885
34970
  ) });
34886
34971
  }
34887
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZoneProvider, { value: { data, config, mode: "render" }, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DropZone, { zone: rootDroppableId }) });
34972
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZoneProvider, { value: { data, config, mode: "render" }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropZone, { zone: rootDroppableId }) });
34888
34973
  }
34889
34974
 
34890
34975
  // lib/resolve-all-data.ts