@measured/puck 0.21.0-canary.74d9a160 → 0.21.0-canary.79a26849

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.
@@ -25,7 +25,7 @@ import {
25
25
  walkAppState,
26
26
  walkField,
27
27
  walkTree
28
- } from "./chunk-VBJEDLUM.mjs";
28
+ } from "./chunk-JA7SEUEH.mjs";
29
29
 
30
30
  // ../../node_modules/classnames/index.js
31
31
  var require_classnames = __commonJS({
@@ -1071,29 +1071,37 @@ var flattenData = (state, config) => {
1071
1071
 
1072
1072
  // store/slices/permissions.ts
1073
1073
  var createPermissionsSlice = (set, get) => {
1074
- const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
1074
+ const resolvePermissions = (..._0) => __async(null, [..._0], function* (params = {}, force) {
1075
1075
  const { state, permissions, config } = get();
1076
1076
  const { cache, globalPermissions } = permissions;
1077
- const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
1078
- var _a, _b, _c;
1077
+ const resolvePermissionsForItem = (item2, force2 = false) => __async(null, null, function* () {
1078
+ var _a, _b;
1079
1079
  const { config: config2, state: appState, setComponentLoading } = get();
1080
+ const itemCache = cache[item2.props.id];
1081
+ const nodes = appState.indexes.nodes;
1082
+ const parentId = (_a = nodes[item2.props.id]) == null ? void 0 : _a.parentId;
1083
+ const parentNode = parentId ? nodes[parentId] : null;
1084
+ const parentData = (_b = parentNode == null ? void 0 : parentNode.data) != null ? _b : null;
1080
1085
  const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
1081
1086
  if (!componentConfig) {
1082
1087
  return;
1083
1088
  }
1084
1089
  const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
1085
1090
  if (componentConfig.resolvePermissions) {
1086
- const changed = getChanged(item2, (_a = cache[item2.props.id]) == null ? void 0 : _a.lastData);
1087
- if (Object.values(changed).some((el) => el === true) || force2) {
1091
+ const changed = getChanged(item2, itemCache == null ? void 0 : itemCache.lastData);
1092
+ const propsChanged = Object.values(changed).some((el) => el === true);
1093
+ const parentChanged = (itemCache == null ? void 0 : itemCache.lastParentId) !== parentId;
1094
+ if (propsChanged || parentChanged || force2) {
1088
1095
  const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
1089
1096
  const resolvedPermissions = yield componentConfig.resolvePermissions(
1090
1097
  item2,
1091
1098
  {
1092
1099
  changed,
1093
- lastPermissions: ((_b = cache[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
1100
+ lastPermissions: (itemCache == null ? void 0 : itemCache.lastPermissions) || null,
1094
1101
  permissions: initialPermissions,
1095
1102
  appState: makeStatePublic(appState),
1096
- lastData: ((_c = cache[item2.props.id]) == null ? void 0 : _c.lastData) || null
1103
+ lastData: (itemCache == null ? void 0 : itemCache.lastData) || null,
1104
+ parent: parentData
1097
1105
  }
1098
1106
  );
1099
1107
  const latest = get().permissions;
@@ -1101,6 +1109,7 @@ var createPermissionsSlice = (set, get) => {
1101
1109
  permissions: __spreadProps(__spreadValues({}, latest), {
1102
1110
  cache: __spreadProps(__spreadValues({}, latest.cache), {
1103
1111
  [item2.props.id]: {
1112
+ lastParentId: parentId,
1104
1113
  lastData: item2,
1105
1114
  lastPermissions: resolvedPermissions
1106
1115
  }
@@ -1114,9 +1123,9 @@ var createPermissionsSlice = (set, get) => {
1114
1123
  }
1115
1124
  }
1116
1125
  });
1117
- const resolveDataForRoot = (force2 = false) => {
1126
+ const resolvePermissionsForRoot = (force2 = false) => {
1118
1127
  const { state: appState } = get();
1119
- resolveDataForItem(
1128
+ resolvePermissionsForItem(
1120
1129
  // Shim the root data in by conforming to component data shape
1121
1130
  {
1122
1131
  type: "root",
@@ -1127,16 +1136,16 @@ var createPermissionsSlice = (set, get) => {
1127
1136
  };
1128
1137
  const { item, type, root } = params;
1129
1138
  if (item) {
1130
- yield resolveDataForItem(item, force);
1139
+ yield resolvePermissionsForItem(item, force);
1131
1140
  } else if (type) {
1132
- flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(void 0, null, function* () {
1133
- yield resolveDataForItem(item2, force);
1141
+ flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(null, null, function* () {
1142
+ yield resolvePermissionsForItem(item2, force);
1134
1143
  }));
1135
1144
  } else if (root) {
1136
- resolveDataForRoot(force);
1145
+ resolvePermissionsForRoot(force);
1137
1146
  } else {
1138
- flattenData(state, config).map((item2) => __async(void 0, null, function* () {
1139
- yield resolveDataForItem(item2, force);
1147
+ flattenData(state, config).map((item2) => __async(null, null, function* () {
1148
+ yield resolvePermissionsForItem(item2, force);
1140
1149
  }));
1141
1150
  }
1142
1151
  });
@@ -1216,7 +1225,7 @@ var createFieldsSlice = (_set, _get) => {
1216
1225
  };
1217
1226
  var useRegisterFieldsSlice = (appStore, id) => {
1218
1227
  const resolveFields = useCallback(
1219
- (reset) => __async(void 0, null, function* () {
1228
+ (reset) => __async(null, null, function* () {
1220
1229
  var _a, _b;
1221
1230
  const { fields, lastResolvedData } = appStore.getState().fields;
1222
1231
  const metadata = appStore.getState().metadata;
@@ -1416,7 +1425,7 @@ var createAppStore = (initialAppStore) => create2()(
1416
1425
  const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
1417
1426
  return __spreadProps(__spreadValues({}, s), { state, selectedItem });
1418
1427
  }),
1419
- resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
1428
+ resolveComponentData: (componentData, trigger) => __async(null, null, function* () {
1420
1429
  const { config, metadata, setComponentLoading, permissions } = get();
1421
1430
  const timeouts = {};
1422
1431
  return yield resolveComponentData(
@@ -1427,7 +1436,7 @@ var createAppStore = (initialAppStore) => create2()(
1427
1436
  const id = "id" in item.props ? item.props.id : "root";
1428
1437
  timeouts[id] = setComponentLoading(id, true, 50);
1429
1438
  },
1430
- (item) => __async(void 0, null, function* () {
1439
+ (item) => __async(null, null, function* () {
1431
1440
  const id = "id" in item.props ? item.props.id : "root";
1432
1441
  if ("type" in item) {
1433
1442
  yield permissions.refreshPermissions({ item });
@@ -1439,7 +1448,7 @@ var createAppStore = (initialAppStore) => create2()(
1439
1448
  trigger
1440
1449
  );
1441
1450
  }),
1442
- resolveAndCommitData: () => __async(void 0, null, function* () {
1451
+ resolveAndCommitData: () => __async(null, null, function* () {
1443
1452
  const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
1444
1453
  walkAppState(
1445
1454
  state,
@@ -2460,7 +2469,7 @@ var collisionStore = createStore(() => ({
2460
2469
 
2461
2470
  // lib/dnd/collision/dynamic/index.ts
2462
2471
  var flushNext = "";
2463
- var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
2472
+ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => ((input) => {
2464
2473
  var _a, _b, _c, _d, _e;
2465
2474
  const { dragOperation, droppable } = input;
2466
2475
  const { position } = dragOperation;
@@ -2553,7 +2562,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2553
2562
  }
2554
2563
  collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
2555
2564
  return null;
2556
- };
2565
+ });
2557
2566
 
2558
2567
  // components/Sortable/index.tsx
2559
2568
  import { useSortable } from "@dnd-kit/react/sortable";
@@ -2986,8 +2995,9 @@ var ArrayField = ({
2986
2995
  var _a;
2987
2996
  if (isDraggingAny) return;
2988
2997
  const existingValue = value || [];
2998
+ const defaultProps = typeof field.defaultItemProps === "function" ? field.defaultItemProps(existingValue.length) : (_a = field.defaultItemProps) != null ? _a : {};
2989
2999
  const newItem = defaultSlots(
2990
- uniqifyItem((_a = field.defaultItemProps) != null ? _a : {}),
3000
+ uniqifyItem(defaultProps),
2991
3001
  field.arrayFields
2992
3002
  );
2993
3003
  const newValue = [...existingValue, newItem];
@@ -3191,7 +3201,7 @@ var ExternalInput = ({
3191
3201
  }, [mappedData]);
3192
3202
  const [searchQuery, setSearchQuery] = useState6(field.initialQuery || "");
3193
3203
  const search = useCallback3(
3194
- (query, filters2) => __async(void 0, null, function* () {
3204
+ (query, filters2) => __async(null, null, function* () {
3195
3205
  setIsLoading(true);
3196
3206
  const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
3197
3207
  let listData;
@@ -3417,7 +3427,7 @@ var ExternalField = ({
3417
3427
  placeholder: ((_a = deprecatedField.adaptor) == null ? void 0 : _a.name) ? `Select from ${deprecatedField.adaptor.name}` : validField.placeholder || "Select data",
3418
3428
  mapProp: ((_b = deprecatedField.adaptor) == null ? void 0 : _b.mapProp) || validField.mapProp,
3419
3429
  mapRow: validField.mapRow,
3420
- fetchList: ((_c = deprecatedField.adaptor) == null ? void 0 : _c.fetchList) ? () => __async(void 0, null, function* () {
3430
+ fetchList: ((_c = deprecatedField.adaptor) == null ? void 0 : _c.fetchList) ? () => __async(null, null, function* () {
3421
3431
  return yield deprecatedField.adaptor.fetchList(
3422
3432
  deprecatedField.adaptorParams
3423
3433
  );
@@ -3793,6 +3803,7 @@ function AutoFieldInternal(props) {
3793
3803
  }
3794
3804
  return (_props) => null;
3795
3805
  }, [field.type]);
3806
+ const fieldKey = field.type === "custom" ? field.key : void 0;
3796
3807
  let FieldComponent = useMemo3(() => {
3797
3808
  if (field.type === "custom") {
3798
3809
  if (!field.render) {
@@ -3802,7 +3813,7 @@ function AutoFieldInternal(props) {
3802
3813
  } else if (field.type !== "slot") {
3803
3814
  return render[field.type];
3804
3815
  }
3805
- }, [field.type, render]);
3816
+ }, [field.type, fieldKey, render]);
3806
3817
  const { visible = true } = props.field;
3807
3818
  if (!visible) {
3808
3819
  return null;
@@ -4842,7 +4853,20 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
4842
4853
 
4843
4854
  // lib/insert-component.ts
4844
4855
  init_react_import();
4845
- var insertComponent = (componentType, zone, index, appStore) => __async(void 0, null, function* () {
4856
+
4857
+ // lib/get-selector-for-id.ts
4858
+ init_react_import();
4859
+ var getSelectorForId = (state, id) => {
4860
+ const node = state.indexes.nodes[id];
4861
+ if (!node) return;
4862
+ const zoneCompound = `${node.parentId}:${node.zone}`;
4863
+ const index = state.indexes.zones[zoneCompound].contentIds.indexOf(id);
4864
+ return { zone: zoneCompound, index };
4865
+ };
4866
+
4867
+ // lib/insert-component.ts
4868
+ var insertComponent = (componentType, zone, index, appStore) => __async(null, null, function* () {
4869
+ const { getState } = appStore;
4846
4870
  const id = generateId(componentType);
4847
4871
  const insertActionData = {
4848
4872
  type: "insert",
@@ -4851,8 +4875,9 @@ var insertComponent = (componentType, zone, index, appStore) => __async(void 0,
4851
4875
  destinationZone: zone,
4852
4876
  id
4853
4877
  };
4854
- const { state, dispatch, resolveComponentData: resolveComponentData2 } = appStore;
4855
- const insertedState = insertAction(state, insertActionData, appStore);
4878
+ const stateBefore = getState().state;
4879
+ const insertedState = insertAction(stateBefore, insertActionData, getState());
4880
+ const dispatch = getState().dispatch;
4856
4881
  dispatch(__spreadProps(__spreadValues({}, insertActionData), {
4857
4882
  // Dispatch insert rather set, as user's may rely on this via onAction
4858
4883
  // We must always record history here so the insert is added to user history
@@ -4860,23 +4885,21 @@ var insertComponent = (componentType, zone, index, appStore) => __async(void 0,
4860
4885
  // entries on insert - one for the initial insert, and one when the data resolves
4861
4886
  recordHistory: true
4862
4887
  }));
4863
- const itemSelector = {
4864
- index,
4865
- zone
4866
- };
4888
+ const itemSelector = { index, zone };
4867
4889
  dispatch({ type: "setUi", ui: { itemSelector } });
4868
4890
  const itemData = getItem(itemSelector, insertedState);
4869
- if (itemData) {
4870
- const resolved = yield resolveComponentData2(itemData, "insert");
4871
- if (resolved.didChange) {
4872
- dispatch({
4873
- type: "replace",
4874
- destinationZone: itemSelector.zone,
4875
- destinationIndex: itemSelector.index,
4876
- data: resolved.node
4877
- });
4878
- }
4879
- }
4891
+ if (!itemData) return;
4892
+ const resolveComponentData2 = getState().resolveComponentData;
4893
+ const resolved = yield resolveComponentData2(itemData, "insert");
4894
+ if (!resolved.didChange) return;
4895
+ const latestItemSelector = getSelectorForId(getState().state, id);
4896
+ if (!latestItemSelector) return;
4897
+ dispatch({
4898
+ type: "replace",
4899
+ destinationZone: latestItemSelector.zone,
4900
+ destinationIndex: latestItemSelector.index,
4901
+ data: resolved.node
4902
+ });
4880
4903
  });
4881
4904
 
4882
4905
  // components/DragDropContext/index.tsx
@@ -5113,7 +5136,7 @@ var DragDropContextClient = ({
5113
5136
  thisPreview.componentType,
5114
5137
  thisPreview.zone,
5115
5138
  thisPreview.index,
5116
- appStore.getState()
5139
+ appStore
5117
5140
  );
5118
5141
  } else if (initialSelector.current) {
5119
5142
  dispatch({
@@ -5497,7 +5520,8 @@ var useMinEmptyHeight = ({
5497
5520
  }
5498
5521
  }
5499
5522
  }, [ref.current, draggedItem, onDragFinished]);
5500
- return [prevHeight || userMinEmptyHeight, isAnimating];
5523
+ const returnedMinHeight = isNaN(Number(userMinEmptyHeight)) ? userMinEmptyHeight : `${userMinEmptyHeight}px`;
5524
+ return [prevHeight ? `${prevHeight}px` : returnedMinHeight, isAnimating];
5501
5525
  };
5502
5526
 
5503
5527
  // lib/assign-refs.ts
@@ -5526,7 +5550,7 @@ import { useCallback as useCallback9 } from "react";
5526
5550
  function useRenderedCallback(callback, deps) {
5527
5551
  const manager = useDragDropManager();
5528
5552
  return useCallback9(
5529
- (...args) => __async(this, null, function* () {
5553
+ (...args) => __async(null, null, function* () {
5530
5554
  yield manager == null ? void 0 : manager.renderer.rendering;
5531
5555
  return callback(...args);
5532
5556
  }),
@@ -5755,16 +5779,6 @@ function setDeep(node, path, newVal) {
5755
5779
  return __spreadValues(__spreadValues({}, node), newNode);
5756
5780
  }
5757
5781
 
5758
- // lib/get-selector-for-id.ts
5759
- init_react_import();
5760
- var getSelectorForId = (state, id) => {
5761
- const node = state.indexes.nodes[id];
5762
- if (!node) return;
5763
- const zoneCompound = `${node.parentId}:${node.zone}`;
5764
- const index = state.indexes.zones[zoneCompound].contentIds.indexOf(id);
5765
- return { zone: zoneCompound, index };
5766
- };
5767
-
5768
5782
  // components/InlineTextField/index.tsx
5769
5783
  import { jsx as jsx24 } from "react/jsx-runtime";
5770
5784
  var getClassName18 = get_class_name_factory_default("InlineTextField", styles_module_default13);
@@ -5793,7 +5807,7 @@ var InlineTextFieldInternal = ({
5793
5807
  ref.current.replaceChildren(value);
5794
5808
  }
5795
5809
  const cleanupPortal = registerOverlayPortal(ref.current);
5796
- const handleInput = (e) => __async(void 0, null, function* () {
5810
+ const handleInput = (e) => __async(null, null, function* () {
5797
5811
  var _a2;
5798
5812
  const appStore2 = appStoreApi.getState();
5799
5813
  const node = appStore2.state.indexes.nodes[componentId];
@@ -6084,8 +6098,9 @@ var DropZoneEdit = forwardRef3(
6084
6098
  disallow,
6085
6099
  style,
6086
6100
  className,
6087
- minEmptyHeight: userMinEmptyHeight = 128,
6088
- collisionAxis
6101
+ minEmptyHeight: userMinEmptyHeight = "128px",
6102
+ collisionAxis,
6103
+ as
6089
6104
  }, userRef) {
6090
6105
  const ctx = useContext8(dropZoneContext);
6091
6106
  const appStoreApi = useAppStoreApi();
@@ -6228,8 +6243,9 @@ var DropZoneEdit = forwardRef3(
6228
6243
  userMinEmptyHeight,
6229
6244
  ref
6230
6245
  });
6246
+ const El = as != null ? as : "div";
6231
6247
  return /* @__PURE__ */ jsx26(
6232
- "div",
6248
+ El,
6233
6249
  {
6234
6250
  className: `${getClassName19({
6235
6251
  isRootZone,
@@ -6245,7 +6261,7 @@ var DropZoneEdit = forwardRef3(
6245
6261
  "data-testid": `dropzone:${zoneCompound}`,
6246
6262
  "data-puck-dropzone": zoneCompound,
6247
6263
  style: __spreadProps(__spreadValues({}, style), {
6248
- "--min-empty-height": `${minEmptyHeight}px`,
6264
+ "--min-empty-height": minEmptyHeight,
6249
6265
  backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
6250
6266
  }),
6251
6267
  children: contentIdsWithPreview.map((componentId, i) => {
@@ -6292,7 +6308,7 @@ var DropZoneRenderItem = ({
6292
6308
  };
6293
6309
  var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx26(DropZoneRender, __spreadValues({}, props));
6294
6310
  var DropZoneRender = forwardRef3(
6295
- function DropZoneRenderInternal({ className, style, zone }, ref) {
6311
+ function DropZoneRenderInternal({ className, style, zone, as }, ref) {
6296
6312
  const ctx = useContext8(dropZoneContext);
6297
6313
  const { areaId = "root" } = ctx || {};
6298
6314
  const { config, data, metadata } = useContext8(renderContext);
@@ -6305,13 +6321,14 @@ var DropZoneRender = forwardRef3(
6305
6321
  }
6306
6322
  }
6307
6323
  }, [content]);
6324
+ const El = as != null ? as : "div";
6308
6325
  if (!data || !config) {
6309
6326
  return null;
6310
6327
  }
6311
6328
  if (zoneCompound !== rootDroppableId) {
6312
6329
  content = setupZone(data, zoneCompound).zones[zoneCompound];
6313
6330
  }
6314
- return /* @__PURE__ */ jsx26("div", { className, style, ref, children: content.map((item) => {
6331
+ return /* @__PURE__ */ jsx26(El, { className, style, ref, children: content.map((item) => {
6315
6332
  const Component = config.components[item.type];
6316
6333
  if (Component) {
6317
6334
  return /* @__PURE__ */ jsx26(
@@ -6413,7 +6430,15 @@ var generateUsePuck = (store) => {
6413
6430
  selectedItem: store.selectedItem || null,
6414
6431
  getItemBySelector: (selector) => getItem(selector, store.state),
6415
6432
  getItemById: (id) => store.state.indexes.nodes[id].data,
6416
- getSelectorForId: (id) => getSelectorForId(store.state, id)
6433
+ getSelectorForId: (id) => getSelectorForId(store.state, id),
6434
+ getParentById: (id) => {
6435
+ const node = store.state.indexes.nodes[id];
6436
+ const parentId = node.parentId;
6437
+ if (parentId === null) return;
6438
+ const parentNode = store.state.indexes.nodes[parentId];
6439
+ if (!parentNode) return;
6440
+ return parentNode.data;
6441
+ }
6417
6442
  };
6418
6443
  return storeData;
6419
6444
  };
@@ -6454,7 +6479,7 @@ function createUsePuck() {
6454
6479
  }
6455
6480
  const result = useStore3(
6456
6481
  usePuckApi,
6457
- selector != null ? selector : (s) => s
6482
+ selector != null ? selector : ((s) => s)
6458
6483
  );
6459
6484
  return result;
6460
6485
  };
@@ -6601,49 +6626,48 @@ var DefaultFields = ({
6601
6626
  }) => {
6602
6627
  return /* @__PURE__ */ jsx29(Fragment8, { children });
6603
6628
  };
6604
- var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
6605
- let currentProps;
6629
+ var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(null, null, function* () {
6606
6630
  const { dispatch, state, selectedItem, resolveComponentData: resolveComponentData2 } = appStore.getState();
6607
6631
  const { data, ui } = state;
6608
6632
  const { itemSelector } = ui;
6609
6633
  const rootProps = data.root.props || data.root;
6610
- if (selectedItem) {
6611
- currentProps = selectedItem.props;
6612
- } else {
6613
- currentProps = rootProps;
6614
- }
6615
- const newProps = __spreadProps(__spreadValues({}, currentProps), {
6616
- [fieldName]: value
6617
- });
6634
+ const currentProps = selectedItem ? selectedItem.props : rootProps;
6635
+ const newProps = __spreadProps(__spreadValues({}, currentProps), { [fieldName]: value });
6618
6636
  if (selectedItem && itemSelector) {
6637
+ const resolved = yield resolveComponentData2(
6638
+ __spreadProps(__spreadValues({}, selectedItem), { props: newProps }),
6639
+ "replace"
6640
+ );
6641
+ const latestSelector = getSelectorForId(
6642
+ appStore.getState().state,
6643
+ selectedItem.props.id
6644
+ );
6645
+ if (!latestSelector) return;
6619
6646
  dispatch({
6620
6647
  type: "replace",
6621
- destinationIndex: itemSelector.index,
6622
- destinationZone: itemSelector.zone || rootDroppableId,
6623
- data: (yield resolveComponentData2(
6624
- __spreadProps(__spreadValues({}, selectedItem), { props: newProps }),
6648
+ destinationIndex: latestSelector.index,
6649
+ destinationZone: latestSelector.zone || rootDroppableId,
6650
+ data: resolved.node,
6651
+ ui: updatedUi
6652
+ });
6653
+ return;
6654
+ }
6655
+ if (data.root.props) {
6656
+ dispatch({
6657
+ type: "replaceRoot",
6658
+ root: (yield resolveComponentData2(
6659
+ __spreadProps(__spreadValues({}, data.root), { props: newProps }),
6625
6660
  "replace"
6626
6661
  )).node,
6627
- ui: updatedUi
6662
+ ui: __spreadValues(__spreadValues({}, ui), updatedUi),
6663
+ recordHistory: true
6628
6664
  });
6629
- } else {
6630
- if (data.root.props) {
6631
- dispatch({
6632
- type: "replaceRoot",
6633
- root: (yield resolveComponentData2(
6634
- __spreadProps(__spreadValues({}, data.root), { props: newProps }),
6635
- "replace"
6636
- )).node,
6637
- ui: __spreadValues(__spreadValues({}, ui), updatedUi),
6638
- recordHistory: true
6639
- });
6640
- } else {
6641
- dispatch({
6642
- type: "setData",
6643
- data: { root: newProps }
6644
- });
6645
- }
6665
+ return;
6646
6666
  }
6667
+ dispatch({
6668
+ type: "setData",
6669
+ data: { root: newProps }
6670
+ });
6647
6671
  });
6648
6672
  var FieldsChild = ({ fieldName }) => {
6649
6673
  const field = useAppStore((s) => s.fields.fields[fieldName]);
@@ -6975,7 +6999,7 @@ var CopyHostStyles = ({
6975
6999
  let elements = [];
6976
7000
  const hashes = {};
6977
7001
  const lookupEl = (el) => elements.findIndex((elementMap) => elementMap.original === el);
6978
- const mirrorEl = (el, inlineStyles = false) => __async(void 0, null, function* () {
7002
+ const mirrorEl = (el, inlineStyles = false) => __async(null, null, function* () {
6979
7003
  let mirror;
6980
7004
  if (el.nodeName === "LINK" && inlineStyles) {
6981
7005
  mirror = document.createElement("style");
@@ -7007,7 +7031,7 @@ var CopyHostStyles = ({
7007
7031
  }
7008
7032
  return mirror;
7009
7033
  });
7010
- const addEl = (el) => __async(void 0, null, function* () {
7034
+ const addEl = (el) => __async(null, null, function* () {
7011
7035
  const index = lookupEl(el);
7012
7036
  if (index > -1) {
7013
7037
  if (debug)
@@ -7080,7 +7104,7 @@ var CopyHostStyles = ({
7080
7104
  const parentBody = parentDocument.getElementsByTagName("body")[0];
7081
7105
  syncAttributes(parentBody, doc.body);
7082
7106
  Promise.all(
7083
- collectedStyles.map((styleNode, i) => __async(void 0, null, function* () {
7107
+ collectedStyles.map((styleNode, i) => __async(null, null, function* () {
7084
7108
  if (styleNode.nodeName === "LINK") {
7085
7109
  const linkHref = styleNode.href;
7086
7110
  if (hrefs.indexOf(linkHref) > -1) {
@@ -8648,7 +8672,12 @@ function PuckProvider({ children }) {
8648
8672
  });
8649
8673
  })
8650
8674
  );
8651
- const initialHistoryIndex = (_initialHistory == null ? void 0 : _initialHistory.index) || blendedHistories.length - 1;
8675
+ const initialHistoryIndex = useMemo20(() => {
8676
+ if ((_initialHistory == null ? void 0 : _initialHistory.index) !== void 0 && (_initialHistory == null ? void 0 : _initialHistory.index) >= 0 && (_initialHistory == null ? void 0 : _initialHistory.index) < blendedHistories.length) {
8677
+ return _initialHistory == null ? void 0 : _initialHistory.index;
8678
+ }
8679
+ return blendedHistories.length - 1;
8680
+ }, []);
8652
8681
  const initialAppState = blendedHistories[initialHistoryIndex].state;
8653
8682
  const loadedOverrides = useLoadedOverrides({
8654
8683
  overrides,
@@ -8707,7 +8736,7 @@ function PuckProvider({ children }) {
8707
8736
  });
8708
8737
  const previousData = useRef12(null);
8709
8738
  useEffect29(() => {
8710
- appStore.subscribe(
8739
+ return appStore.subscribe(
8711
8740
  (s) => s.state.data,
8712
8741
  (data) => {
8713
8742
  if (onChange) {
@@ -8717,7 +8746,7 @@ function PuckProvider({ children }) {
8717
8746
  }
8718
8747
  }
8719
8748
  );
8720
- }, []);
8749
+ }, [onChange]);
8721
8750
  useRegisterPermissionsSlice(appStore, permissions);
8722
8751
  const uPuckStore = useRegisterUsePuckStore(appStore);
8723
8752
  useEffect29(() => {
@@ -8933,269 +8962,38 @@ classnames/index.js:
8933
8962
  *)
8934
8963
 
8935
8964
  lucide-react/dist/esm/shared/src/utils.js:
8936
- (**
8937
- * @license lucide-react v0.468.0 - ISC
8938
- *
8939
- * This source code is licensed under the ISC license.
8940
- * See the LICENSE file in the root directory of this source tree.
8941
- *)
8942
-
8943
8965
  lucide-react/dist/esm/defaultAttributes.js:
8944
- (**
8945
- * @license lucide-react v0.468.0 - ISC
8946
- *
8947
- * This source code is licensed under the ISC license.
8948
- * See the LICENSE file in the root directory of this source tree.
8949
- *)
8950
-
8951
8966
  lucide-react/dist/esm/Icon.js:
8952
- (**
8953
- * @license lucide-react v0.468.0 - ISC
8954
- *
8955
- * This source code is licensed under the ISC license.
8956
- * See the LICENSE file in the root directory of this source tree.
8957
- *)
8958
-
8959
8967
  lucide-react/dist/esm/createLucideIcon.js:
8960
- (**
8961
- * @license lucide-react v0.468.0 - ISC
8962
- *
8963
- * This source code is licensed under the ISC license.
8964
- * See the LICENSE file in the root directory of this source tree.
8965
- *)
8966
-
8967
8968
  lucide-react/dist/esm/icons/chevron-down.js:
8968
- (**
8969
- * @license lucide-react v0.468.0 - ISC
8970
- *
8971
- * This source code is licensed under the ISC license.
8972
- * See the LICENSE file in the root directory of this source tree.
8973
- *)
8974
-
8975
8969
  lucide-react/dist/esm/icons/chevron-right.js:
8976
- (**
8977
- * @license lucide-react v0.468.0 - ISC
8978
- *
8979
- * This source code is licensed under the ISC license.
8980
- * See the LICENSE file in the root directory of this source tree.
8981
- *)
8982
-
8983
8970
  lucide-react/dist/esm/icons/chevron-up.js:
8984
- (**
8985
- * @license lucide-react v0.468.0 - ISC
8986
- *
8987
- * This source code is licensed under the ISC license.
8988
- * See the LICENSE file in the root directory of this source tree.
8989
- *)
8990
-
8991
8971
  lucide-react/dist/esm/icons/circle-check-big.js:
8992
- (**
8993
- * @license lucide-react v0.468.0 - ISC
8994
- *
8995
- * This source code is licensed under the ISC license.
8996
- * See the LICENSE file in the root directory of this source tree.
8997
- *)
8998
-
8999
8972
  lucide-react/dist/esm/icons/copy.js:
9000
- (**
9001
- * @license lucide-react v0.468.0 - ISC
9002
- *
9003
- * This source code is licensed under the ISC license.
9004
- * See the LICENSE file in the root directory of this source tree.
9005
- *)
9006
-
9007
8973
  lucide-react/dist/esm/icons/corner-left-up.js:
9008
- (**
9009
- * @license lucide-react v0.468.0 - ISC
9010
- *
9011
- * This source code is licensed under the ISC license.
9012
- * See the LICENSE file in the root directory of this source tree.
9013
- *)
9014
-
9015
8974
  lucide-react/dist/esm/icons/ellipsis-vertical.js:
9016
- (**
9017
- * @license lucide-react v0.468.0 - ISC
9018
- *
9019
- * This source code is licensed under the ISC license.
9020
- * See the LICENSE file in the root directory of this source tree.
9021
- *)
9022
-
9023
8975
  lucide-react/dist/esm/icons/globe.js:
9024
- (**
9025
- * @license lucide-react v0.468.0 - ISC
9026
- *
9027
- * This source code is licensed under the ISC license.
9028
- * See the LICENSE file in the root directory of this source tree.
9029
- *)
9030
-
9031
8976
  lucide-react/dist/esm/icons/hash.js:
9032
- (**
9033
- * @license lucide-react v0.468.0 - ISC
9034
- *
9035
- * This source code is licensed under the ISC license.
9036
- * See the LICENSE file in the root directory of this source tree.
9037
- *)
9038
-
9039
8977
  lucide-react/dist/esm/icons/layers.js:
9040
- (**
9041
- * @license lucide-react v0.468.0 - ISC
9042
- *
9043
- * This source code is licensed under the ISC license.
9044
- * See the LICENSE file in the root directory of this source tree.
9045
- *)
9046
-
9047
8978
  lucide-react/dist/esm/icons/layout-grid.js:
9048
- (**
9049
- * @license lucide-react v0.468.0 - ISC
9050
- *
9051
- * This source code is licensed under the ISC license.
9052
- * See the LICENSE file in the root directory of this source tree.
9053
- *)
9054
-
9055
8979
  lucide-react/dist/esm/icons/link.js:
9056
- (**
9057
- * @license lucide-react v0.468.0 - ISC
9058
- *
9059
- * This source code is licensed under the ISC license.
9060
- * See the LICENSE file in the root directory of this source tree.
9061
- *)
9062
-
9063
8980
  lucide-react/dist/esm/icons/list.js:
9064
- (**
9065
- * @license lucide-react v0.468.0 - ISC
9066
- *
9067
- * This source code is licensed under the ISC license.
9068
- * See the LICENSE file in the root directory of this source tree.
9069
- *)
9070
-
9071
8981
  lucide-react/dist/esm/icons/lock-open.js:
9072
- (**
9073
- * @license lucide-react v0.468.0 - ISC
9074
- *
9075
- * This source code is licensed under the ISC license.
9076
- * See the LICENSE file in the root directory of this source tree.
9077
- *)
9078
-
9079
8982
  lucide-react/dist/esm/icons/lock.js:
9080
- (**
9081
- * @license lucide-react v0.468.0 - ISC
9082
- *
9083
- * This source code is licensed under the ISC license.
9084
- * See the LICENSE file in the root directory of this source tree.
9085
- *)
9086
-
9087
8983
  lucide-react/dist/esm/icons/monitor.js:
9088
- (**
9089
- * @license lucide-react v0.468.0 - ISC
9090
- *
9091
- * This source code is licensed under the ISC license.
9092
- * See the LICENSE file in the root directory of this source tree.
9093
- *)
9094
-
9095
8984
  lucide-react/dist/esm/icons/panel-left.js:
9096
- (**
9097
- * @license lucide-react v0.468.0 - ISC
9098
- *
9099
- * This source code is licensed under the ISC license.
9100
- * See the LICENSE file in the root directory of this source tree.
9101
- *)
9102
-
9103
8985
  lucide-react/dist/esm/icons/panel-right.js:
9104
- (**
9105
- * @license lucide-react v0.468.0 - ISC
9106
- *
9107
- * This source code is licensed under the ISC license.
9108
- * See the LICENSE file in the root directory of this source tree.
9109
- *)
9110
-
9111
8986
  lucide-react/dist/esm/icons/plus.js:
9112
- (**
9113
- * @license lucide-react v0.468.0 - ISC
9114
- *
9115
- * This source code is licensed under the ISC license.
9116
- * See the LICENSE file in the root directory of this source tree.
9117
- *)
9118
-
9119
8987
  lucide-react/dist/esm/icons/redo-2.js:
9120
- (**
9121
- * @license lucide-react v0.468.0 - ISC
9122
- *
9123
- * This source code is licensed under the ISC license.
9124
- * See the LICENSE file in the root directory of this source tree.
9125
- *)
9126
-
9127
8988
  lucide-react/dist/esm/icons/search.js:
9128
- (**
9129
- * @license lucide-react v0.468.0 - ISC
9130
- *
9131
- * This source code is licensed under the ISC license.
9132
- * See the LICENSE file in the root directory of this source tree.
9133
- *)
9134
-
9135
8989
  lucide-react/dist/esm/icons/sliders-horizontal.js:
9136
- (**
9137
- * @license lucide-react v0.468.0 - ISC
9138
- *
9139
- * This source code is licensed under the ISC license.
9140
- * See the LICENSE file in the root directory of this source tree.
9141
- *)
9142
-
9143
8990
  lucide-react/dist/esm/icons/smartphone.js:
9144
- (**
9145
- * @license lucide-react v0.468.0 - ISC
9146
- *
9147
- * This source code is licensed under the ISC license.
9148
- * See the LICENSE file in the root directory of this source tree.
9149
- *)
9150
-
9151
8991
  lucide-react/dist/esm/icons/tablet.js:
9152
- (**
9153
- * @license lucide-react v0.468.0 - ISC
9154
- *
9155
- * This source code is licensed under the ISC license.
9156
- * See the LICENSE file in the root directory of this source tree.
9157
- *)
9158
-
9159
8992
  lucide-react/dist/esm/icons/trash.js:
9160
- (**
9161
- * @license lucide-react v0.468.0 - ISC
9162
- *
9163
- * This source code is licensed under the ISC license.
9164
- * See the LICENSE file in the root directory of this source tree.
9165
- *)
9166
-
9167
8993
  lucide-react/dist/esm/icons/type.js:
9168
- (**
9169
- * @license lucide-react v0.468.0 - ISC
9170
- *
9171
- * This source code is licensed under the ISC license.
9172
- * See the LICENSE file in the root directory of this source tree.
9173
- *)
9174
-
9175
8994
  lucide-react/dist/esm/icons/undo-2.js:
9176
- (**
9177
- * @license lucide-react v0.468.0 - ISC
9178
- *
9179
- * This source code is licensed under the ISC license.
9180
- * See the LICENSE file in the root directory of this source tree.
9181
- *)
9182
-
9183
8995
  lucide-react/dist/esm/icons/zoom-in.js:
9184
- (**
9185
- * @license lucide-react v0.468.0 - ISC
9186
- *
9187
- * This source code is licensed under the ISC license.
9188
- * See the LICENSE file in the root directory of this source tree.
9189
- *)
9190
-
9191
8996
  lucide-react/dist/esm/icons/zoom-out.js:
9192
- (**
9193
- * @license lucide-react v0.468.0 - ISC
9194
- *
9195
- * This source code is licensed under the ISC license.
9196
- * See the LICENSE file in the root directory of this source tree.
9197
- *)
9198
-
9199
8997
  lucide-react/dist/esm/lucide-react.js:
9200
8998
  (**
9201
8999
  * @license lucide-react v0.468.0 - ISC