@measured/puck 0.21.0-canary.cf074bc6 → 0.21.0-canary.dfecd012

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.
@@ -19,12 +19,13 @@ import {
19
19
  rootDroppableId,
20
20
  rootZone,
21
21
  setupZone,
22
+ toComponent,
22
23
  useFieldTransforms,
23
24
  useSlots,
24
25
  walkAppState,
25
26
  walkField,
26
27
  walkTree
27
- } from "./chunk-OOLYDXKW.mjs";
28
+ } from "./chunk-JA7SEUEH.mjs";
28
29
 
29
30
  // ../../node_modules/classnames/index.js
30
31
  var require_classnames = __commonJS({
@@ -88,6 +89,42 @@ var require_classnames = __commonJS({
88
89
  }
89
90
  });
90
91
 
92
+ // ../../node_modules/fast-deep-equal/index.js
93
+ var require_fast_deep_equal = __commonJS({
94
+ "../../node_modules/fast-deep-equal/index.js"(exports, module) {
95
+ "use strict";
96
+ init_react_import();
97
+ module.exports = function equal(a, b) {
98
+ if (a === b) return true;
99
+ if (a && b && typeof a == "object" && typeof b == "object") {
100
+ if (a.constructor !== b.constructor) return false;
101
+ var length, i, keys;
102
+ if (Array.isArray(a)) {
103
+ length = a.length;
104
+ if (length != b.length) return false;
105
+ for (i = length; i-- !== 0; )
106
+ if (!equal(a[i], b[i])) return false;
107
+ return true;
108
+ }
109
+ if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
110
+ if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
111
+ if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
112
+ keys = Object.keys(a);
113
+ length = keys.length;
114
+ if (length !== Object.keys(b).length) return false;
115
+ for (i = length; i-- !== 0; )
116
+ if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
117
+ for (i = length; i-- !== 0; ) {
118
+ var key = keys[i];
119
+ if (!equal(a[key], b[key])) return false;
120
+ }
121
+ return true;
122
+ }
123
+ return a !== a && b !== b;
124
+ };
125
+ }
126
+ });
127
+
91
128
  // types/API/Overrides.ts
92
129
  init_react_import();
93
130
  var overrideKeys = [
@@ -820,6 +857,10 @@ var monitorHotkeys = (doc) => {
820
857
  useHotkeyStore.getState().reset();
821
858
  }
822
859
  };
860
+ const onBlur = () => {
861
+ useHotkeyStore.getState().reset();
862
+ };
863
+ window.addEventListener("blur", onBlur);
823
864
  doc.addEventListener("keydown", onKeyDown);
824
865
  doc.addEventListener("keyup", onKeyUp);
825
866
  doc.addEventListener("visibilitychange", onVisibilityChanged);
@@ -827,6 +868,7 @@ var monitorHotkeys = (doc) => {
827
868
  doc.removeEventListener("keydown", onKeyDown);
828
869
  doc.removeEventListener("keyup", onKeyUp);
829
870
  doc.removeEventListener("visibilitychange", onVisibilityChanged);
871
+ window.removeEventListener("blur", onBlur);
830
872
  };
831
873
  };
832
874
  var useMonitorHotkeys = () => {
@@ -1029,10 +1071,10 @@ var flattenData = (state, config) => {
1029
1071
 
1030
1072
  // store/slices/permissions.ts
1031
1073
  var createPermissionsSlice = (set, get) => {
1032
- const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
1074
+ const resolvePermissions = (..._0) => __async(null, [..._0], function* (params = {}, force) {
1033
1075
  const { state, permissions, config } = get();
1034
1076
  const { cache, globalPermissions } = permissions;
1035
- const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
1077
+ const resolveDataForItem = (item2, force2 = false) => __async(null, null, function* () {
1036
1078
  var _a, _b, _c;
1037
1079
  const { config: config2, state: appState, setComponentLoading } = get();
1038
1080
  const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
@@ -1087,13 +1129,13 @@ var createPermissionsSlice = (set, get) => {
1087
1129
  if (item) {
1088
1130
  yield resolveDataForItem(item, force);
1089
1131
  } else if (type) {
1090
- flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(void 0, null, function* () {
1132
+ flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(null, null, function* () {
1091
1133
  yield resolveDataForItem(item2, force);
1092
1134
  }));
1093
1135
  } else if (root) {
1094
1136
  resolveDataForRoot(force);
1095
1137
  } else {
1096
- flattenData(state, config).map((item2) => __async(void 0, null, function* () {
1138
+ flattenData(state, config).map((item2) => __async(null, null, function* () {
1097
1139
  yield resolveDataForItem(item2, force);
1098
1140
  }));
1099
1141
  }
@@ -1174,7 +1216,7 @@ var createFieldsSlice = (_set, _get) => {
1174
1216
  };
1175
1217
  var useRegisterFieldsSlice = (appStore, id) => {
1176
1218
  const resolveFields = useCallback(
1177
- (reset) => __async(void 0, null, function* () {
1219
+ (reset) => __async(null, null, function* () {
1178
1220
  var _a, _b;
1179
1221
  const { fields, lastResolvedData } = appStore.getState().fields;
1180
1222
  const metadata = appStore.getState().metadata;
@@ -1374,7 +1416,7 @@ var createAppStore = (initialAppStore) => create2()(
1374
1416
  const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
1375
1417
  return __spreadProps(__spreadValues({}, s), { state, selectedItem });
1376
1418
  }),
1377
- resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
1419
+ resolveComponentData: (componentData, trigger) => __async(null, null, function* () {
1378
1420
  const { config, metadata, setComponentLoading, permissions } = get();
1379
1421
  const timeouts = {};
1380
1422
  return yield resolveComponentData(
@@ -1385,7 +1427,7 @@ var createAppStore = (initialAppStore) => create2()(
1385
1427
  const id = "id" in item.props ? item.props.id : "root";
1386
1428
  timeouts[id] = setComponentLoading(id, true, 50);
1387
1429
  },
1388
- (item) => __async(void 0, null, function* () {
1430
+ (item) => __async(null, null, function* () {
1389
1431
  const id = "id" in item.props ? item.props.id : "root";
1390
1432
  if ("type" in item) {
1391
1433
  yield permissions.refreshPermissions({ item });
@@ -1397,7 +1439,7 @@ var createAppStore = (initialAppStore) => create2()(
1397
1439
  trigger
1398
1440
  );
1399
1441
  }),
1400
- resolveAndCommitData: () => __async(void 0, null, function* () {
1442
+ resolveAndCommitData: () => __async(null, null, function* () {
1401
1443
  const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
1402
1444
  walkAppState(
1403
1445
  state,
@@ -2418,7 +2460,7 @@ var collisionStore = createStore(() => ({
2418
2460
 
2419
2461
  // lib/dnd/collision/dynamic/index.ts
2420
2462
  var flushNext = "";
2421
- var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
2463
+ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => ((input) => {
2422
2464
  var _a, _b, _c, _d, _e;
2423
2465
  const { dragOperation, droppable } = input;
2424
2466
  const { position } = dragOperation;
@@ -2511,7 +2553,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2511
2553
  }
2512
2554
  collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
2513
2555
  return null;
2514
- };
2556
+ });
2515
2557
 
2516
2558
  // components/Sortable/index.tsx
2517
2559
  import { useSortable } from "@dnd-kit/react/sortable";
@@ -2944,8 +2986,9 @@ var ArrayField = ({
2944
2986
  var _a;
2945
2987
  if (isDraggingAny) return;
2946
2988
  const existingValue = value || [];
2989
+ const defaultProps = typeof field.defaultItemProps === "function" ? field.defaultItemProps(existingValue.length) : (_a = field.defaultItemProps) != null ? _a : {};
2947
2990
  const newItem = defaultSlots(
2948
- uniqifyItem((_a = field.defaultItemProps) != null ? _a : {}),
2991
+ uniqifyItem(defaultProps),
2949
2992
  field.arrayFields
2950
2993
  );
2951
2994
  const newValue = [...existingValue, newItem];
@@ -3120,11 +3163,13 @@ var ExternalInput = ({
3120
3163
  id,
3121
3164
  readOnly
3122
3165
  }) => {
3166
+ var _a;
3123
3167
  const {
3124
3168
  mapProp = (val) => val,
3125
3169
  mapRow = (val) => val,
3126
3170
  filterFields
3127
3171
  } = field || {};
3172
+ const { enabled: shouldCacheData } = (_a = field.cache) != null ? _a : { enabled: true };
3128
3173
  const [data, setData] = useState6([]);
3129
3174
  const [isOpen, setOpen] = useState6(false);
3130
3175
  const [isLoading, setIsLoading] = useState6(true);
@@ -3147,14 +3192,21 @@ var ExternalInput = ({
3147
3192
  }, [mappedData]);
3148
3193
  const [searchQuery, setSearchQuery] = useState6(field.initialQuery || "");
3149
3194
  const search = useCallback3(
3150
- (query, filters2) => __async(void 0, null, function* () {
3195
+ (query, filters2) => __async(null, null, function* () {
3151
3196
  setIsLoading(true);
3152
3197
  const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
3153
- const listData = dataCache[cacheKey] || (yield field.fetchList({ query, filters: filters2 }));
3198
+ let listData;
3199
+ if (shouldCacheData && dataCache[cacheKey]) {
3200
+ listData = dataCache[cacheKey];
3201
+ } else {
3202
+ listData = yield field.fetchList({ query, filters: filters2 });
3203
+ }
3154
3204
  if (listData) {
3155
3205
  setData(listData);
3156
3206
  setIsLoading(false);
3157
- dataCache[cacheKey] = listData;
3207
+ if (shouldCacheData) {
3208
+ dataCache[cacheKey] = listData;
3209
+ }
3158
3210
  }
3159
3211
  }),
3160
3212
  [id, field]
@@ -3218,6 +3270,7 @@ var ExternalInput = ({
3218
3270
  }),
3219
3271
  onSubmit: (e) => {
3220
3272
  e.preventDefault();
3273
+ e.stopPropagation();
3221
3274
  search(searchQuery, filters);
3222
3275
  },
3223
3276
  children: [
@@ -3365,7 +3418,7 @@ var ExternalField = ({
3365
3418
  placeholder: ((_a = deprecatedField.adaptor) == null ? void 0 : _a.name) ? `Select from ${deprecatedField.adaptor.name}` : validField.placeholder || "Select data",
3366
3419
  mapProp: ((_b = deprecatedField.adaptor) == null ? void 0 : _b.mapProp) || validField.mapProp,
3367
3420
  mapRow: validField.mapRow,
3368
- fetchList: ((_c = deprecatedField.adaptor) == null ? void 0 : _c.fetchList) ? () => __async(void 0, null, function* () {
3421
+ fetchList: ((_c = deprecatedField.adaptor) == null ? void 0 : _c.fetchList) ? () => __async(null, null, function* () {
3369
3422
  return yield deprecatedField.adaptor.fetchList(
3370
3423
  deprecatedField.adaptorParams
3371
3424
  );
@@ -3741,6 +3794,7 @@ function AutoFieldInternal(props) {
3741
3794
  }
3742
3795
  return (_props) => null;
3743
3796
  }, [field.type]);
3797
+ const fieldKey = field.type === "custom" ? field.key : void 0;
3744
3798
  let FieldComponent = useMemo3(() => {
3745
3799
  if (field.type === "custom") {
3746
3800
  if (!field.render) {
@@ -3750,7 +3804,7 @@ function AutoFieldInternal(props) {
3750
3804
  } else if (field.type !== "slot") {
3751
3805
  return render[field.type];
3752
3806
  }
3753
- }, [field.type, render]);
3807
+ }, [field.type, fieldKey, render]);
3754
3808
  const { visible = true } = props.field;
3755
3809
  if (!visible) {
3756
3810
  return null;
@@ -4128,12 +4182,14 @@ var DraggableComponent = ({
4128
4182
  }
4129
4183
  return cleanup;
4130
4184
  }, [permissions.drag, zoneCompound]);
4185
+ const [, setRerender] = useState10(0);
4131
4186
  const ref = useRef2(null);
4132
4187
  const refSetter = useCallback7(
4133
4188
  (el) => {
4134
4189
  sortableRef(el);
4135
- if (el) {
4190
+ if (ref.current !== el) {
4136
4191
  ref.current = el;
4192
+ setRerender((update) => update + 1);
4137
4193
  }
4138
4194
  },
4139
4195
  [sortableRef]
@@ -4788,7 +4844,20 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
4788
4844
 
4789
4845
  // lib/insert-component.ts
4790
4846
  init_react_import();
4791
- var insertComponent = (componentType, zone, index, appStore) => __async(void 0, null, function* () {
4847
+
4848
+ // lib/get-selector-for-id.ts
4849
+ init_react_import();
4850
+ var getSelectorForId = (state, id) => {
4851
+ const node = state.indexes.nodes[id];
4852
+ if (!node) return;
4853
+ const zoneCompound = `${node.parentId}:${node.zone}`;
4854
+ const index = state.indexes.zones[zoneCompound].contentIds.indexOf(id);
4855
+ return { zone: zoneCompound, index };
4856
+ };
4857
+
4858
+ // lib/insert-component.ts
4859
+ var insertComponent = (componentType, zone, index, appStore) => __async(null, null, function* () {
4860
+ const { getState } = appStore;
4792
4861
  const id = generateId(componentType);
4793
4862
  const insertActionData = {
4794
4863
  type: "insert",
@@ -4797,8 +4866,9 @@ var insertComponent = (componentType, zone, index, appStore) => __async(void 0,
4797
4866
  destinationZone: zone,
4798
4867
  id
4799
4868
  };
4800
- const { state, dispatch, resolveComponentData: resolveComponentData2 } = appStore;
4801
- const insertedState = insertAction(state, insertActionData, appStore);
4869
+ const stateBefore = getState().state;
4870
+ const insertedState = insertAction(stateBefore, insertActionData, getState());
4871
+ const dispatch = getState().dispatch;
4802
4872
  dispatch(__spreadProps(__spreadValues({}, insertActionData), {
4803
4873
  // Dispatch insert rather set, as user's may rely on this via onAction
4804
4874
  // We must always record history here so the insert is added to user history
@@ -4806,23 +4876,21 @@ var insertComponent = (componentType, zone, index, appStore) => __async(void 0,
4806
4876
  // entries on insert - one for the initial insert, and one when the data resolves
4807
4877
  recordHistory: true
4808
4878
  }));
4809
- const itemSelector = {
4810
- index,
4811
- zone
4812
- };
4879
+ const itemSelector = { index, zone };
4813
4880
  dispatch({ type: "setUi", ui: { itemSelector } });
4814
4881
  const itemData = getItem(itemSelector, insertedState);
4815
- if (itemData) {
4816
- const resolved = yield resolveComponentData2(itemData, "insert");
4817
- if (resolved.didChange) {
4818
- dispatch({
4819
- type: "replace",
4820
- destinationZone: itemSelector.zone,
4821
- destinationIndex: itemSelector.index,
4822
- data: resolved.node
4823
- });
4824
- }
4825
- }
4882
+ if (!itemData) return;
4883
+ const resolveComponentData2 = getState().resolveComponentData;
4884
+ const resolved = yield resolveComponentData2(itemData, "insert");
4885
+ if (!resolved.didChange) return;
4886
+ const latestItemSelector = getSelectorForId(getState().state, id);
4887
+ if (!latestItemSelector) return;
4888
+ dispatch({
4889
+ type: "replace",
4890
+ destinationZone: latestItemSelector.zone,
4891
+ destinationIndex: latestItemSelector.index,
4892
+ data: resolved.node
4893
+ });
4826
4894
  });
4827
4895
 
4828
4896
  // components/DragDropContext/index.tsx
@@ -5059,7 +5127,7 @@ var DragDropContextClient = ({
5059
5127
  thisPreview.componentType,
5060
5128
  thisPreview.zone,
5061
5129
  thisPreview.index,
5062
- appStore.getState()
5130
+ appStore
5063
5131
  );
5064
5132
  } else if (initialSelector.current) {
5065
5133
  dispatch({
@@ -5472,7 +5540,7 @@ import { useCallback as useCallback9 } from "react";
5472
5540
  function useRenderedCallback(callback, deps) {
5473
5541
  const manager = useDragDropManager();
5474
5542
  return useCallback9(
5475
- (...args) => __async(this, null, function* () {
5543
+ (...args) => __async(null, null, function* () {
5476
5544
  yield manager == null ? void 0 : manager.renderer.rendering;
5477
5545
  return callback(...args);
5478
5546
  }),
@@ -5638,26 +5706,26 @@ var registerOverlayPortal = (el, opts = {}) => {
5638
5706
  capture: true
5639
5707
  });
5640
5708
  };
5641
- if (disableDragOnFocus) {
5642
- el.addEventListener("focus", onFocus, { capture: true });
5643
- el.addEventListener("blur", onBlur, { capture: true });
5644
- } else if (disableDrag) {
5709
+ if (disableDrag) {
5645
5710
  el.addEventListener("pointerdown", stopPropagation, {
5646
5711
  capture: true
5647
5712
  });
5713
+ } else if (disableDragOnFocus) {
5714
+ el.addEventListener("focus", onFocus, { capture: true });
5715
+ el.addEventListener("blur", onBlur, { capture: true });
5648
5716
  }
5649
5717
  el.setAttribute("data-puck-overlay-portal", "true");
5650
5718
  return () => {
5651
5719
  el.removeEventListener("mouseover", stopPropagation, {
5652
5720
  capture: true
5653
5721
  });
5654
- if (disableDragOnFocus) {
5655
- el.removeEventListener("focus", onFocus, { capture: true });
5656
- el.removeEventListener("blur", onFocus, { capture: true });
5657
- } else if (disableDrag) {
5722
+ if (disableDrag) {
5658
5723
  el.removeEventListener("pointerdown", stopPropagation, {
5659
5724
  capture: true
5660
5725
  });
5726
+ } else if (disableDragOnFocus) {
5727
+ el.removeEventListener("focus", onFocus, { capture: true });
5728
+ el.removeEventListener("blur", onBlur, { capture: true });
5661
5729
  }
5662
5730
  el.removeAttribute("data-puck-overlay-portal");
5663
5731
  };
@@ -5665,7 +5733,7 @@ var registerOverlayPortal = (el, opts = {}) => {
5665
5733
 
5666
5734
  // css-module:/home/runner/work/puck/puck/packages/core/components/InlineTextField/styles.module.css#css-module
5667
5735
  init_react_import();
5668
- var styles_module_default13 = { "InlineTextField": "_InlineTextField_1xph6_1" };
5736
+ var styles_module_default13 = { "InlineTextField": "_InlineTextField_104qp_1" };
5669
5737
 
5670
5738
  // lib/data/set-deep.ts
5671
5739
  init_react_import();
@@ -5701,16 +5769,6 @@ function setDeep(node, path, newVal) {
5701
5769
  return __spreadValues(__spreadValues({}, node), newNode);
5702
5770
  }
5703
5771
 
5704
- // lib/get-selector-for-id.ts
5705
- init_react_import();
5706
- var getSelectorForId = (state, id) => {
5707
- const node = state.indexes.nodes[id];
5708
- if (!node) return;
5709
- const zoneCompound = `${node.parentId}:${node.zone}`;
5710
- const index = state.indexes.zones[zoneCompound].contentIds.indexOf(id);
5711
- return { zone: zoneCompound, index };
5712
- };
5713
-
5714
5772
  // components/InlineTextField/index.tsx
5715
5773
  import { jsx as jsx24 } from "react/jsx-runtime";
5716
5774
  var getClassName18 = get_class_name_factory_default("InlineTextField", styles_module_default13);
@@ -5739,7 +5797,7 @@ var InlineTextFieldInternal = ({
5739
5797
  ref.current.replaceChildren(value);
5740
5798
  }
5741
5799
  const cleanupPortal = registerOverlayPortal(ref.current);
5742
- const handleInput = (e) => __async(void 0, null, function* () {
5800
+ const handleInput = (e) => __async(null, null, function* () {
5743
5801
  var _a2;
5744
5802
  const appStore2 = appStoreApi.getState();
5745
5803
  const node = appStore2.state.indexes.nodes[componentId];
@@ -6031,7 +6089,8 @@ var DropZoneEdit = forwardRef3(
6031
6089
  style,
6032
6090
  className,
6033
6091
  minEmptyHeight: userMinEmptyHeight = 128,
6034
- collisionAxis
6092
+ collisionAxis,
6093
+ as
6035
6094
  }, userRef) {
6036
6095
  const ctx = useContext8(dropZoneContext);
6037
6096
  const appStoreApi = useAppStoreApi();
@@ -6174,8 +6233,9 @@ var DropZoneEdit = forwardRef3(
6174
6233
  userMinEmptyHeight,
6175
6234
  ref
6176
6235
  });
6236
+ const El = as != null ? as : "div";
6177
6237
  return /* @__PURE__ */ jsx26(
6178
- "div",
6238
+ El,
6179
6239
  {
6180
6240
  className: `${getClassName19({
6181
6241
  isRootZone,
@@ -6238,7 +6298,7 @@ var DropZoneRenderItem = ({
6238
6298
  };
6239
6299
  var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx26(DropZoneRender, __spreadValues({}, props));
6240
6300
  var DropZoneRender = forwardRef3(
6241
- function DropZoneRenderInternal({ className, style, zone }, ref) {
6301
+ function DropZoneRenderInternal({ className, style, zone, as }, ref) {
6242
6302
  const ctx = useContext8(dropZoneContext);
6243
6303
  const { areaId = "root" } = ctx || {};
6244
6304
  const { config, data, metadata } = useContext8(renderContext);
@@ -6251,13 +6311,14 @@ var DropZoneRender = forwardRef3(
6251
6311
  }
6252
6312
  }
6253
6313
  }, [content]);
6314
+ const El = as != null ? as : "div";
6254
6315
  if (!data || !config) {
6255
6316
  return null;
6256
6317
  }
6257
6318
  if (zoneCompound !== rootDroppableId) {
6258
6319
  content = setupZone(data, zoneCompound).zones[zoneCompound];
6259
6320
  }
6260
- return /* @__PURE__ */ jsx26("div", { className, style, ref, children: content.map((item) => {
6321
+ return /* @__PURE__ */ jsx26(El, { className, style, ref, children: content.map((item) => {
6261
6322
  const Component = config.components[item.type];
6262
6323
  if (Component) {
6263
6324
  return /* @__PURE__ */ jsx26(
@@ -6400,7 +6461,7 @@ function createUsePuck() {
6400
6461
  }
6401
6462
  const result = useStore3(
6402
6463
  usePuckApi,
6403
- selector != null ? selector : (s) => s
6464
+ selector != null ? selector : ((s) => s)
6404
6465
  );
6405
6466
  return result;
6406
6467
  };
@@ -6547,7 +6608,7 @@ var DefaultFields = ({
6547
6608
  }) => {
6548
6609
  return /* @__PURE__ */ jsx29(Fragment8, { children });
6549
6610
  };
6550
- var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
6611
+ var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(null, null, function* () {
6551
6612
  let currentProps;
6552
6613
  const { dispatch, state, selectedItem, resolveComponentData: resolveComponentData2 } = appStore.getState();
6553
6614
  const { data, ui } = state;
@@ -6921,7 +6982,7 @@ var CopyHostStyles = ({
6921
6982
  let elements = [];
6922
6983
  const hashes = {};
6923
6984
  const lookupEl = (el) => elements.findIndex((elementMap) => elementMap.original === el);
6924
- const mirrorEl = (el, inlineStyles = false) => __async(void 0, null, function* () {
6985
+ const mirrorEl = (el, inlineStyles = false) => __async(null, null, function* () {
6925
6986
  let mirror;
6926
6987
  if (el.nodeName === "LINK" && inlineStyles) {
6927
6988
  mirror = document.createElement("style");
@@ -6953,7 +7014,7 @@ var CopyHostStyles = ({
6953
7014
  }
6954
7015
  return mirror;
6955
7016
  });
6956
- const addEl = (el) => __async(void 0, null, function* () {
7017
+ const addEl = (el) => __async(null, null, function* () {
6957
7018
  const index = lookupEl(el);
6958
7019
  if (index > -1) {
6959
7020
  if (debug)
@@ -7026,7 +7087,7 @@ var CopyHostStyles = ({
7026
7087
  const parentBody = parentDocument.getElementsByTagName("body")[0];
7027
7088
  syncAttributes(parentBody, doc.body);
7028
7089
  Promise.all(
7029
- collectedStyles.map((styleNode, i) => __async(void 0, null, function* () {
7090
+ collectedStyles.map((styleNode, i) => __async(null, null, function* () {
7030
7091
  if (styleNode.nodeName === "LINK") {
7031
7092
  const linkHref = styleNode.href;
7032
7093
  if (hrefs.indexOf(linkHref) > -1) {
@@ -8047,7 +8108,7 @@ var useDeleteHotkeys = () => {
8047
8108
  };
8048
8109
 
8049
8110
  // components/Puck/index.tsx
8050
- import fdeq from "fast-deep-equal";
8111
+ var import_fast_deep_equal = __toESM(require_fast_deep_equal());
8051
8112
 
8052
8113
  // components/Puck/components/Header/index.tsx
8053
8114
  init_react_import();
@@ -8551,9 +8612,13 @@ function PuckProvider({ children }) {
8551
8612
  }
8552
8613
  const rootProps = ((_h = initialData == null ? void 0 : initialData.root) == null ? void 0 : _h.props) || (initialData == null ? void 0 : initialData.root) || {};
8553
8614
  const defaultedRootProps = __spreadValues(__spreadValues({}, (_i = config.root) == null ? void 0 : _i.defaultProps), rootProps);
8615
+ const root = populateIds(
8616
+ toComponent(__spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: defaultedRootProps })),
8617
+ config
8618
+ );
8554
8619
  const newAppState = __spreadProps(__spreadValues({}, defaultAppState), {
8555
8620
  data: __spreadProps(__spreadValues({}, initialData), {
8556
- root: __spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: defaultedRootProps }),
8621
+ root: __spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: root.props }),
8557
8622
  content: initialData.content || []
8558
8623
  }),
8559
8624
  ui: __spreadProps(__spreadValues(__spreadValues({}, initial), clientUiState), {
@@ -8590,7 +8655,12 @@ function PuckProvider({ children }) {
8590
8655
  });
8591
8656
  })
8592
8657
  );
8593
- const initialHistoryIndex = (_initialHistory == null ? void 0 : _initialHistory.index) || blendedHistories.length - 1;
8658
+ const initialHistoryIndex = useMemo20(() => {
8659
+ if ((_initialHistory == null ? void 0 : _initialHistory.index) !== void 0 && (_initialHistory == null ? void 0 : _initialHistory.index) >= 0 && (_initialHistory == null ? void 0 : _initialHistory.index) < blendedHistories.length) {
8660
+ return _initialHistory == null ? void 0 : _initialHistory.index;
8661
+ }
8662
+ return blendedHistories.length - 1;
8663
+ }, []);
8594
8664
  const initialAppState = blendedHistories[initialHistoryIndex].state;
8595
8665
  const loadedOverrides = useLoadedOverrides({
8596
8666
  overrides,
@@ -8649,17 +8719,17 @@ function PuckProvider({ children }) {
8649
8719
  });
8650
8720
  const previousData = useRef12(null);
8651
8721
  useEffect29(() => {
8652
- appStore.subscribe(
8722
+ return appStore.subscribe(
8653
8723
  (s) => s.state.data,
8654
8724
  (data) => {
8655
8725
  if (onChange) {
8656
- if (fdeq(data, previousData.current)) return;
8726
+ if ((0, import_fast_deep_equal.default)(data, previousData.current)) return;
8657
8727
  onChange(data);
8658
8728
  previousData.current = data;
8659
8729
  }
8660
8730
  }
8661
8731
  );
8662
- }, []);
8732
+ }, [onChange]);
8663
8733
  useRegisterPermissionsSlice(appStore, permissions);
8664
8734
  const uPuckStore = useRegisterUsePuckStore(appStore);
8665
8735
  useEffect29(() => {
@@ -8875,269 +8945,38 @@ classnames/index.js:
8875
8945
  *)
8876
8946
 
8877
8947
  lucide-react/dist/esm/shared/src/utils.js:
8878
- (**
8879
- * @license lucide-react v0.468.0 - ISC
8880
- *
8881
- * This source code is licensed under the ISC license.
8882
- * See the LICENSE file in the root directory of this source tree.
8883
- *)
8884
-
8885
8948
  lucide-react/dist/esm/defaultAttributes.js:
8886
- (**
8887
- * @license lucide-react v0.468.0 - ISC
8888
- *
8889
- * This source code is licensed under the ISC license.
8890
- * See the LICENSE file in the root directory of this source tree.
8891
- *)
8892
-
8893
8949
  lucide-react/dist/esm/Icon.js:
8894
- (**
8895
- * @license lucide-react v0.468.0 - ISC
8896
- *
8897
- * This source code is licensed under the ISC license.
8898
- * See the LICENSE file in the root directory of this source tree.
8899
- *)
8900
-
8901
8950
  lucide-react/dist/esm/createLucideIcon.js:
8902
- (**
8903
- * @license lucide-react v0.468.0 - ISC
8904
- *
8905
- * This source code is licensed under the ISC license.
8906
- * See the LICENSE file in the root directory of this source tree.
8907
- *)
8908
-
8909
8951
  lucide-react/dist/esm/icons/chevron-down.js:
8910
- (**
8911
- * @license lucide-react v0.468.0 - ISC
8912
- *
8913
- * This source code is licensed under the ISC license.
8914
- * See the LICENSE file in the root directory of this source tree.
8915
- *)
8916
-
8917
8952
  lucide-react/dist/esm/icons/chevron-right.js:
8918
- (**
8919
- * @license lucide-react v0.468.0 - ISC
8920
- *
8921
- * This source code is licensed under the ISC license.
8922
- * See the LICENSE file in the root directory of this source tree.
8923
- *)
8924
-
8925
8953
  lucide-react/dist/esm/icons/chevron-up.js:
8926
- (**
8927
- * @license lucide-react v0.468.0 - ISC
8928
- *
8929
- * This source code is licensed under the ISC license.
8930
- * See the LICENSE file in the root directory of this source tree.
8931
- *)
8932
-
8933
8954
  lucide-react/dist/esm/icons/circle-check-big.js:
8934
- (**
8935
- * @license lucide-react v0.468.0 - ISC
8936
- *
8937
- * This source code is licensed under the ISC license.
8938
- * See the LICENSE file in the root directory of this source tree.
8939
- *)
8940
-
8941
8955
  lucide-react/dist/esm/icons/copy.js:
8942
- (**
8943
- * @license lucide-react v0.468.0 - ISC
8944
- *
8945
- * This source code is licensed under the ISC license.
8946
- * See the LICENSE file in the root directory of this source tree.
8947
- *)
8948
-
8949
8956
  lucide-react/dist/esm/icons/corner-left-up.js:
8950
- (**
8951
- * @license lucide-react v0.468.0 - ISC
8952
- *
8953
- * This source code is licensed under the ISC license.
8954
- * See the LICENSE file in the root directory of this source tree.
8955
- *)
8956
-
8957
8957
  lucide-react/dist/esm/icons/ellipsis-vertical.js:
8958
- (**
8959
- * @license lucide-react v0.468.0 - ISC
8960
- *
8961
- * This source code is licensed under the ISC license.
8962
- * See the LICENSE file in the root directory of this source tree.
8963
- *)
8964
-
8965
8958
  lucide-react/dist/esm/icons/globe.js:
8966
- (**
8967
- * @license lucide-react v0.468.0 - ISC
8968
- *
8969
- * This source code is licensed under the ISC license.
8970
- * See the LICENSE file in the root directory of this source tree.
8971
- *)
8972
-
8973
8959
  lucide-react/dist/esm/icons/hash.js:
8974
- (**
8975
- * @license lucide-react v0.468.0 - ISC
8976
- *
8977
- * This source code is licensed under the ISC license.
8978
- * See the LICENSE file in the root directory of this source tree.
8979
- *)
8980
-
8981
8960
  lucide-react/dist/esm/icons/layers.js:
8982
- (**
8983
- * @license lucide-react v0.468.0 - ISC
8984
- *
8985
- * This source code is licensed under the ISC license.
8986
- * See the LICENSE file in the root directory of this source tree.
8987
- *)
8988
-
8989
8961
  lucide-react/dist/esm/icons/layout-grid.js:
8990
- (**
8991
- * @license lucide-react v0.468.0 - ISC
8992
- *
8993
- * This source code is licensed under the ISC license.
8994
- * See the LICENSE file in the root directory of this source tree.
8995
- *)
8996
-
8997
8962
  lucide-react/dist/esm/icons/link.js:
8998
- (**
8999
- * @license lucide-react v0.468.0 - ISC
9000
- *
9001
- * This source code is licensed under the ISC license.
9002
- * See the LICENSE file in the root directory of this source tree.
9003
- *)
9004
-
9005
8963
  lucide-react/dist/esm/icons/list.js:
9006
- (**
9007
- * @license lucide-react v0.468.0 - ISC
9008
- *
9009
- * This source code is licensed under the ISC license.
9010
- * See the LICENSE file in the root directory of this source tree.
9011
- *)
9012
-
9013
8964
  lucide-react/dist/esm/icons/lock-open.js:
9014
- (**
9015
- * @license lucide-react v0.468.0 - ISC
9016
- *
9017
- * This source code is licensed under the ISC license.
9018
- * See the LICENSE file in the root directory of this source tree.
9019
- *)
9020
-
9021
8965
  lucide-react/dist/esm/icons/lock.js:
9022
- (**
9023
- * @license lucide-react v0.468.0 - ISC
9024
- *
9025
- * This source code is licensed under the ISC license.
9026
- * See the LICENSE file in the root directory of this source tree.
9027
- *)
9028
-
9029
8966
  lucide-react/dist/esm/icons/monitor.js:
9030
- (**
9031
- * @license lucide-react v0.468.0 - ISC
9032
- *
9033
- * This source code is licensed under the ISC license.
9034
- * See the LICENSE file in the root directory of this source tree.
9035
- *)
9036
-
9037
8967
  lucide-react/dist/esm/icons/panel-left.js:
9038
- (**
9039
- * @license lucide-react v0.468.0 - ISC
9040
- *
9041
- * This source code is licensed under the ISC license.
9042
- * See the LICENSE file in the root directory of this source tree.
9043
- *)
9044
-
9045
8968
  lucide-react/dist/esm/icons/panel-right.js:
9046
- (**
9047
- * @license lucide-react v0.468.0 - ISC
9048
- *
9049
- * This source code is licensed under the ISC license.
9050
- * See the LICENSE file in the root directory of this source tree.
9051
- *)
9052
-
9053
8969
  lucide-react/dist/esm/icons/plus.js:
9054
- (**
9055
- * @license lucide-react v0.468.0 - ISC
9056
- *
9057
- * This source code is licensed under the ISC license.
9058
- * See the LICENSE file in the root directory of this source tree.
9059
- *)
9060
-
9061
8970
  lucide-react/dist/esm/icons/redo-2.js:
9062
- (**
9063
- * @license lucide-react v0.468.0 - ISC
9064
- *
9065
- * This source code is licensed under the ISC license.
9066
- * See the LICENSE file in the root directory of this source tree.
9067
- *)
9068
-
9069
8971
  lucide-react/dist/esm/icons/search.js:
9070
- (**
9071
- * @license lucide-react v0.468.0 - ISC
9072
- *
9073
- * This source code is licensed under the ISC license.
9074
- * See the LICENSE file in the root directory of this source tree.
9075
- *)
9076
-
9077
8972
  lucide-react/dist/esm/icons/sliders-horizontal.js:
9078
- (**
9079
- * @license lucide-react v0.468.0 - ISC
9080
- *
9081
- * This source code is licensed under the ISC license.
9082
- * See the LICENSE file in the root directory of this source tree.
9083
- *)
9084
-
9085
8973
  lucide-react/dist/esm/icons/smartphone.js:
9086
- (**
9087
- * @license lucide-react v0.468.0 - ISC
9088
- *
9089
- * This source code is licensed under the ISC license.
9090
- * See the LICENSE file in the root directory of this source tree.
9091
- *)
9092
-
9093
8974
  lucide-react/dist/esm/icons/tablet.js:
9094
- (**
9095
- * @license lucide-react v0.468.0 - ISC
9096
- *
9097
- * This source code is licensed under the ISC license.
9098
- * See the LICENSE file in the root directory of this source tree.
9099
- *)
9100
-
9101
8975
  lucide-react/dist/esm/icons/trash.js:
9102
- (**
9103
- * @license lucide-react v0.468.0 - ISC
9104
- *
9105
- * This source code is licensed under the ISC license.
9106
- * See the LICENSE file in the root directory of this source tree.
9107
- *)
9108
-
9109
8976
  lucide-react/dist/esm/icons/type.js:
9110
- (**
9111
- * @license lucide-react v0.468.0 - ISC
9112
- *
9113
- * This source code is licensed under the ISC license.
9114
- * See the LICENSE file in the root directory of this source tree.
9115
- *)
9116
-
9117
8977
  lucide-react/dist/esm/icons/undo-2.js:
9118
- (**
9119
- * @license lucide-react v0.468.0 - ISC
9120
- *
9121
- * This source code is licensed under the ISC license.
9122
- * See the LICENSE file in the root directory of this source tree.
9123
- *)
9124
-
9125
8978
  lucide-react/dist/esm/icons/zoom-in.js:
9126
- (**
9127
- * @license lucide-react v0.468.0 - ISC
9128
- *
9129
- * This source code is licensed under the ISC license.
9130
- * See the LICENSE file in the root directory of this source tree.
9131
- *)
9132
-
9133
8979
  lucide-react/dist/esm/icons/zoom-out.js:
9134
- (**
9135
- * @license lucide-react v0.468.0 - ISC
9136
- *
9137
- * This source code is licensed under the ISC license.
9138
- * See the LICENSE file in the root directory of this source tree.
9139
- *)
9140
-
9141
8980
  lucide-react/dist/esm/lucide-react.js:
9142
8981
  (**
9143
8982
  * @license lucide-react v0.468.0 - ISC