@measured/puck 0.21.0-canary.16a3eee1 → 0.21.0-canary.1cec93c4

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
@@ -190,8 +190,8 @@ var require_fast_deep_equal = __commonJS({
190
190
  });
191
191
 
192
192
  // bundle/index.ts
193
- var bundle_exports = {};
194
- __export(bundle_exports, {
193
+ var index_exports = {};
194
+ __export(index_exports, {
195
195
  Action: () => Action,
196
196
  ActionBar: () => ActionBar,
197
197
  AutoField: () => AutoField,
@@ -216,7 +216,7 @@ __export(bundle_exports, {
216
216
  usePuck: () => usePuck,
217
217
  walkTree: () => walkTree
218
218
  });
219
- module.exports = __toCommonJS(bundle_exports);
219
+ module.exports = __toCommonJS(index_exports);
220
220
  init_react_import();
221
221
 
222
222
  // bundle/core.ts
@@ -1749,6 +1749,10 @@ var monitorHotkeys = (doc) => {
1749
1749
  useHotkeyStore.getState().reset();
1750
1750
  }
1751
1751
  };
1752
+ const onBlur = () => {
1753
+ useHotkeyStore.getState().reset();
1754
+ };
1755
+ window.addEventListener("blur", onBlur);
1752
1756
  doc.addEventListener("keydown", onKeyDown);
1753
1757
  doc.addEventListener("keyup", onKeyUp);
1754
1758
  doc.addEventListener("visibilitychange", onVisibilityChanged);
@@ -1756,6 +1760,7 @@ var monitorHotkeys = (doc) => {
1756
1760
  doc.removeEventListener("keydown", onKeyDown);
1757
1761
  doc.removeEventListener("keyup", onKeyUp);
1758
1762
  doc.removeEventListener("visibilitychange", onVisibilityChanged);
1763
+ window.removeEventListener("blur", onBlur);
1759
1764
  };
1760
1765
  };
1761
1766
  var useMonitorHotkeys = () => {
@@ -1971,10 +1976,10 @@ var getChanged = (newItem, oldItem) => {
1971
1976
 
1972
1977
  // store/slices/permissions.ts
1973
1978
  var createPermissionsSlice = (set, get) => {
1974
- const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
1979
+ const resolvePermissions = (..._0) => __async(null, [..._0], function* (params = {}, force) {
1975
1980
  const { state, permissions, config } = get();
1976
1981
  const { cache: cache2, globalPermissions } = permissions;
1977
- const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
1982
+ const resolveDataForItem = (item2, force2 = false) => __async(null, null, function* () {
1978
1983
  var _a, _b, _c;
1979
1984
  const { config: config2, state: appState, setComponentLoading } = get();
1980
1985
  const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
@@ -2029,13 +2034,13 @@ var createPermissionsSlice = (set, get) => {
2029
2034
  if (item) {
2030
2035
  yield resolveDataForItem(item, force);
2031
2036
  } else if (type) {
2032
- flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(void 0, null, function* () {
2037
+ flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(null, null, function* () {
2033
2038
  yield resolveDataForItem(item2, force);
2034
2039
  }));
2035
2040
  } else if (root) {
2036
2041
  resolveDataForRoot(force);
2037
2042
  } else {
2038
- flattenData(state, config).map((item2) => __async(void 0, null, function* () {
2043
+ flattenData(state, config).map((item2) => __async(null, null, function* () {
2039
2044
  yield resolveDataForItem(item2, force);
2040
2045
  }));
2041
2046
  }
@@ -2116,7 +2121,7 @@ var createFieldsSlice = (_set, _get) => {
2116
2121
  };
2117
2122
  var useRegisterFieldsSlice = (appStore, id) => {
2118
2123
  const resolveFields = (0, import_react7.useCallback)(
2119
- (reset) => __async(void 0, null, function* () {
2124
+ (reset) => __async(null, null, function* () {
2120
2125
  var _a, _b;
2121
2126
  const { fields, lastResolvedData } = appStore.getState().fields;
2122
2127
  const metadata = appStore.getState().metadata;
@@ -2187,7 +2192,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
2187
2192
  init_react_import();
2188
2193
  var import_fast_equals2 = require("fast-equals");
2189
2194
  var cache = { lastChange: {} };
2190
- var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
2195
+ var resolveComponentData = (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
2191
2196
  const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
2192
2197
  const resolvedItem = __spreadValues({}, item);
2193
2198
  const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
@@ -2215,11 +2220,11 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
2215
2220
  let itemWithResolvedChildren = yield mapFields(
2216
2221
  resolvedItem,
2217
2222
  {
2218
- slot: (_02) => __async(void 0, [_02], function* ({ value }) {
2223
+ slot: (_02) => __async(null, [_02], function* ({ value }) {
2219
2224
  const content = value;
2220
2225
  return yield Promise.all(
2221
2226
  content.map(
2222
- (childItem) => __async(void 0, null, function* () {
2227
+ (childItem) => __async(null, null, function* () {
2223
2228
  return (yield resolveComponentData(
2224
2229
  childItem,
2225
2230
  config,
@@ -2409,7 +2414,7 @@ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
2409
2414
  const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
2410
2415
  return __spreadProps(__spreadValues({}, s), { state, selectedItem });
2411
2416
  }),
2412
- resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
2417
+ resolveComponentData: (componentData, trigger) => __async(null, null, function* () {
2413
2418
  const { config, metadata, setComponentLoading, permissions } = get();
2414
2419
  const timeouts = {};
2415
2420
  return yield resolveComponentData(
@@ -2420,7 +2425,7 @@ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
2420
2425
  const id = "id" in item.props ? item.props.id : "root";
2421
2426
  timeouts[id] = setComponentLoading(id, true, 50);
2422
2427
  },
2423
- (item) => __async(void 0, null, function* () {
2428
+ (item) => __async(null, null, function* () {
2424
2429
  const id = "id" in item.props ? item.props.id : "root";
2425
2430
  if ("type" in item) {
2426
2431
  yield permissions.refreshPermissions({ item });
@@ -2432,7 +2437,7 @@ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
2432
2437
  trigger
2433
2438
  );
2434
2439
  }),
2435
- resolveAndCommitData: () => __async(void 0, null, function* () {
2440
+ resolveAndCommitData: () => __async(null, null, function* () {
2436
2441
  const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
2437
2442
  walkAppState(
2438
2443
  state,
@@ -3004,7 +3009,7 @@ var collisionStore = (0, import_vanilla.createStore)(() => ({
3004
3009
 
3005
3010
  // lib/dnd/collision/dynamic/index.ts
3006
3011
  var flushNext = "";
3007
- var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
3012
+ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => ((input) => {
3008
3013
  var _a, _b, _c, _d, _e;
3009
3014
  const { dragOperation, droppable } = input;
3010
3015
  const { position } = dragOperation;
@@ -3097,7 +3102,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
3097
3102
  }
3098
3103
  collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
3099
3104
  return null;
3100
- };
3105
+ });
3101
3106
 
3102
3107
  // components/Sortable/index.tsx
3103
3108
  var import_sortable = require("@dnd-kit/react/sortable");
@@ -3530,8 +3535,9 @@ var ArrayField = ({
3530
3535
  var _a;
3531
3536
  if (isDraggingAny) return;
3532
3537
  const existingValue = value || [];
3538
+ const defaultProps = typeof field.defaultItemProps === "function" ? field.defaultItemProps(existingValue.length) : (_a = field.defaultItemProps) != null ? _a : {};
3533
3539
  const newItem = defaultSlots(
3534
- uniqifyItem((_a = field.defaultItemProps) != null ? _a : {}),
3540
+ uniqifyItem(defaultProps),
3535
3541
  field.arrayFields
3536
3542
  );
3537
3543
  const newValue = [...existingValue, newItem];
@@ -3790,11 +3796,13 @@ var ExternalInput = ({
3790
3796
  id,
3791
3797
  readOnly
3792
3798
  }) => {
3799
+ var _a;
3793
3800
  const {
3794
3801
  mapProp = (val) => val,
3795
3802
  mapRow = (val) => val,
3796
3803
  filterFields
3797
3804
  } = field || {};
3805
+ const { enabled: shouldCacheData } = (_a = field.cache) != null ? _a : { enabled: true };
3798
3806
  const [data, setData] = (0, import_react17.useState)([]);
3799
3807
  const [isOpen, setOpen] = (0, import_react17.useState)(false);
3800
3808
  const [isLoading, setIsLoading] = (0, import_react17.useState)(true);
@@ -3817,14 +3825,21 @@ var ExternalInput = ({
3817
3825
  }, [mappedData]);
3818
3826
  const [searchQuery, setSearchQuery] = (0, import_react17.useState)(field.initialQuery || "");
3819
3827
  const search = (0, import_react17.useCallback)(
3820
- (query, filters2) => __async(void 0, null, function* () {
3828
+ (query, filters2) => __async(null, null, function* () {
3821
3829
  setIsLoading(true);
3822
3830
  const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
3823
- const listData = dataCache[cacheKey] || (yield field.fetchList({ query, filters: filters2 }));
3831
+ let listData;
3832
+ if (shouldCacheData && dataCache[cacheKey]) {
3833
+ listData = dataCache[cacheKey];
3834
+ } else {
3835
+ listData = yield field.fetchList({ query, filters: filters2 });
3836
+ }
3824
3837
  if (listData) {
3825
3838
  setData(listData);
3826
3839
  setIsLoading(false);
3827
- dataCache[cacheKey] = listData;
3840
+ if (shouldCacheData) {
3841
+ dataCache[cacheKey] = listData;
3842
+ }
3828
3843
  }
3829
3844
  }),
3830
3845
  [id, field]
@@ -3888,6 +3903,7 @@ var ExternalInput = ({
3888
3903
  }),
3889
3904
  onSubmit: (e) => {
3890
3905
  e.preventDefault();
3906
+ e.stopPropagation();
3891
3907
  search(searchQuery, filters);
3892
3908
  },
3893
3909
  children: [
@@ -4035,7 +4051,7 @@ var ExternalField = ({
4035
4051
  placeholder: ((_a = deprecatedField.adaptor) == null ? void 0 : _a.name) ? `Select from ${deprecatedField.adaptor.name}` : validField.placeholder || "Select data",
4036
4052
  mapProp: ((_b = deprecatedField.adaptor) == null ? void 0 : _b.mapProp) || validField.mapProp,
4037
4053
  mapRow: validField.mapRow,
4038
- fetchList: ((_c = deprecatedField.adaptor) == null ? void 0 : _c.fetchList) ? () => __async(void 0, null, function* () {
4054
+ fetchList: ((_c = deprecatedField.adaptor) == null ? void 0 : _c.fetchList) ? () => __async(null, null, function* () {
4039
4055
  return yield deprecatedField.adaptor.fetchList(
4040
4056
  deprecatedField.adaptorParams
4041
4057
  );
@@ -4411,6 +4427,7 @@ function AutoFieldInternal(props) {
4411
4427
  }
4412
4428
  return (_props) => null;
4413
4429
  }, [field.type]);
4430
+ const fieldKey = field.type === "custom" ? field.key : void 0;
4414
4431
  let FieldComponent = (0, import_react20.useMemo)(() => {
4415
4432
  if (field.type === "custom") {
4416
4433
  if (!field.render) {
@@ -4420,7 +4437,7 @@ function AutoFieldInternal(props) {
4420
4437
  } else if (field.type !== "slot") {
4421
4438
  return render[field.type];
4422
4439
  }
4423
- }, [field.type, render]);
4440
+ }, [field.type, fieldKey, render]);
4424
4441
  const { visible = true } = props.field;
4425
4442
  if (!visible) {
4426
4443
  return null;
@@ -4791,12 +4808,14 @@ var DraggableComponent = ({
4791
4808
  }
4792
4809
  return cleanup;
4793
4810
  }, [permissions.drag, zoneCompound]);
4811
+ const [, setRerender] = (0, import_react24.useState)(0);
4794
4812
  const ref = (0, import_react24.useRef)(null);
4795
4813
  const refSetter = (0, import_react24.useCallback)(
4796
4814
  (el) => {
4797
4815
  sortableRef(el);
4798
- if (el) {
4816
+ if (ref.current !== el) {
4799
4817
  ref.current = el;
4818
+ setRerender((update) => update + 1);
4800
4819
  }
4801
4820
  },
4802
4821
  [sortableRef]
@@ -5243,7 +5262,7 @@ var import_react27 = require("react");
5243
5262
  function useRenderedCallback(callback, deps) {
5244
5263
  const manager = (0, import_react26.useDragDropManager)();
5245
5264
  return (0, import_react27.useCallback)(
5246
- (...args) => __async(this, null, function* () {
5265
+ (...args) => __async(null, null, function* () {
5247
5266
  yield manager == null ? void 0 : manager.renderer.rendering;
5248
5267
  return callback(...args);
5249
5268
  }),
@@ -5448,8 +5467,9 @@ var Item = ({
5448
5467
  );
5449
5468
  };
5450
5469
  var SlotRender = (0, import_react31.forwardRef)(
5451
- function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
5452
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className, style, ref, children: content.map((item) => {
5470
+ function SlotRenderInternal({ className, style, content, config, metadata, as }, ref) {
5471
+ const El = as != null ? as : "div";
5472
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(El, { className, style, ref, children: content.map((item) => {
5453
5473
  if (!config.components[item.type]) {
5454
5474
  return null;
5455
5475
  }
@@ -5571,26 +5591,26 @@ var registerOverlayPortal = (el, opts = {}) => {
5571
5591
  capture: true
5572
5592
  });
5573
5593
  };
5574
- if (disableDragOnFocus) {
5575
- el.addEventListener("focus", onFocus, { capture: true });
5576
- el.addEventListener("blur", onBlur, { capture: true });
5577
- } else if (disableDrag) {
5594
+ if (disableDrag) {
5578
5595
  el.addEventListener("pointerdown", stopPropagation, {
5579
5596
  capture: true
5580
5597
  });
5598
+ } else if (disableDragOnFocus) {
5599
+ el.addEventListener("focus", onFocus, { capture: true });
5600
+ el.addEventListener("blur", onBlur, { capture: true });
5581
5601
  }
5582
5602
  el.setAttribute("data-puck-overlay-portal", "true");
5583
5603
  return () => {
5584
5604
  el.removeEventListener("mouseover", stopPropagation, {
5585
5605
  capture: true
5586
5606
  });
5587
- if (disableDragOnFocus) {
5588
- el.removeEventListener("focus", onFocus, { capture: true });
5589
- el.removeEventListener("blur", onFocus, { capture: true });
5590
- } else if (disableDrag) {
5607
+ if (disableDrag) {
5591
5608
  el.removeEventListener("pointerdown", stopPropagation, {
5592
5609
  capture: true
5593
5610
  });
5611
+ } else if (disableDragOnFocus) {
5612
+ el.removeEventListener("focus", onFocus, { capture: true });
5613
+ el.removeEventListener("blur", onBlur, { capture: true });
5594
5614
  }
5595
5615
  el.removeAttribute("data-puck-overlay-portal");
5596
5616
  };
@@ -5598,7 +5618,7 @@ var registerOverlayPortal = (el, opts = {}) => {
5598
5618
 
5599
5619
  // css-module:/home/runner/work/puck/puck/packages/core/components/InlineTextField/styles.module.css#css-module
5600
5620
  init_react_import();
5601
- var styles_module_default13 = { "InlineTextField": "_InlineTextField_1xph6_1" };
5621
+ var styles_module_default13 = { "InlineTextField": "_InlineTextField_104qp_1" };
5602
5622
 
5603
5623
  // lib/data/set-deep.ts
5604
5624
  init_react_import();
@@ -5672,7 +5692,7 @@ var InlineTextFieldInternal = ({
5672
5692
  ref.current.replaceChildren(value);
5673
5693
  }
5674
5694
  const cleanupPortal = registerOverlayPortal(ref.current);
5675
- const handleInput = (e) => __async(void 0, null, function* () {
5695
+ const handleInput = (e) => __async(null, null, function* () {
5676
5696
  var _a2;
5677
5697
  const appStore2 = appStoreApi.getState();
5678
5698
  const node = appStore2.state.indexes.nodes[componentId];
@@ -5964,7 +5984,8 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5964
5984
  style,
5965
5985
  className,
5966
5986
  minEmptyHeight: userMinEmptyHeight = 128,
5967
- collisionAxis
5987
+ collisionAxis,
5988
+ as
5968
5989
  }, userRef) {
5969
5990
  const ctx = (0, import_react34.useContext)(dropZoneContext);
5970
5991
  const appStoreApi = useAppStoreApi();
@@ -6107,8 +6128,9 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
6107
6128
  userMinEmptyHeight,
6108
6129
  ref
6109
6130
  });
6131
+ const El = as != null ? as : "div";
6110
6132
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
6111
- "div",
6133
+ El,
6112
6134
  {
6113
6135
  className: `${getClassName18({
6114
6136
  isRootZone,
@@ -6171,7 +6193,7 @@ var DropZoneRenderItem = ({
6171
6193
  };
6172
6194
  var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZoneRender, __spreadValues({}, props));
6173
6195
  var DropZoneRender = (0, import_react34.forwardRef)(
6174
- function DropZoneRenderInternal({ className, style, zone }, ref) {
6196
+ function DropZoneRenderInternal({ className, style, zone, as }, ref) {
6175
6197
  const ctx = (0, import_react34.useContext)(dropZoneContext);
6176
6198
  const { areaId = "root" } = ctx || {};
6177
6199
  const { config, data, metadata } = (0, import_react34.useContext)(renderContext);
@@ -6184,13 +6206,14 @@ var DropZoneRender = (0, import_react34.forwardRef)(
6184
6206
  }
6185
6207
  }
6186
6208
  }, [content]);
6209
+ const El = as != null ? as : "div";
6187
6210
  if (!data || !config) {
6188
6211
  return null;
6189
6212
  }
6190
6213
  if (zoneCompound !== rootDroppableId) {
6191
6214
  content = setupZone(data, zoneCompound).zones[zoneCompound];
6192
6215
  }
6193
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className, style, ref, children: content.map((item) => {
6216
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(El, { className, style, ref, children: content.map((item) => {
6194
6217
  const Component = config.components[item.type];
6195
6218
  if (Component) {
6196
6219
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
@@ -6496,7 +6519,7 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
6496
6519
 
6497
6520
  // lib/insert-component.ts
6498
6521
  init_react_import();
6499
- var insertComponent = (componentType, zone, index, appStore) => __async(void 0, null, function* () {
6522
+ var insertComponent = (componentType, zone, index, appStore) => __async(null, null, function* () {
6500
6523
  const id = generateId(componentType);
6501
6524
  const insertActionData = {
6502
6525
  type: "insert",
@@ -7204,7 +7227,7 @@ var DefaultFields = ({
7204
7227
  }) => {
7205
7228
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children });
7206
7229
  };
7207
- var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
7230
+ var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(null, null, function* () {
7208
7231
  let currentProps;
7209
7232
  const { dispatch, state, selectedItem, resolveComponentData: resolveComponentData2 } = appStore.getState();
7210
7233
  const { data, ui } = state;
@@ -7573,7 +7596,7 @@ var CopyHostStyles = ({
7573
7596
  let elements = [];
7574
7597
  const hashes = {};
7575
7598
  const lookupEl = (el) => elements.findIndex((elementMap) => elementMap.original === el);
7576
- const mirrorEl = (el, inlineStyles = false) => __async(void 0, null, function* () {
7599
+ const mirrorEl = (el, inlineStyles = false) => __async(null, null, function* () {
7577
7600
  let mirror;
7578
7601
  if (el.nodeName === "LINK" && inlineStyles) {
7579
7602
  mirror = document.createElement("style");
@@ -7605,7 +7628,7 @@ var CopyHostStyles = ({
7605
7628
  }
7606
7629
  return mirror;
7607
7630
  });
7608
- const addEl = (el) => __async(void 0, null, function* () {
7631
+ const addEl = (el) => __async(null, null, function* () {
7609
7632
  const index = lookupEl(el);
7610
7633
  if (index > -1) {
7611
7634
  if (debug)
@@ -7678,7 +7701,7 @@ var CopyHostStyles = ({
7678
7701
  const parentBody = parentDocument.getElementsByTagName("body")[0];
7679
7702
  syncAttributes(parentBody, doc.body);
7680
7703
  Promise.all(
7681
- collectedStyles.map((styleNode, i) => __async(void 0, null, function* () {
7704
+ collectedStyles.map((styleNode, i) => __async(null, null, function* () {
7682
7705
  if (styleNode.nodeName === "LINK") {
7683
7706
  const linkHref = styleNode.href;
7684
7707
  if (hrefs.indexOf(linkHref) > -1) {
@@ -8753,7 +8776,7 @@ function createUsePuck() {
8753
8776
  }
8754
8777
  const result = (0, import_zustand6.useStore)(
8755
8778
  usePuckApi,
8756
- selector != null ? selector : (s) => s
8779
+ selector != null ? selector : ((s) => s)
8757
8780
  );
8758
8781
  return result;
8759
8782
  };
@@ -9203,6 +9226,15 @@ function useSidebarResize(position, dispatch) {
9203
9226
  };
9204
9227
  }
9205
9228
 
9229
+ // lib/data/to-component.ts
9230
+ init_react_import();
9231
+ var toComponent = (item) => {
9232
+ return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
9233
+ props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
9234
+ type: "root"
9235
+ });
9236
+ };
9237
+
9206
9238
  // components/Puck/index.tsx
9207
9239
  var import_jsx_runtime46 = require("react/jsx-runtime");
9208
9240
  var getClassName31 = get_class_name_factory_default("Puck", styles_module_default15);
@@ -9279,9 +9311,13 @@ function PuckProvider({ children }) {
9279
9311
  }
9280
9312
  const rootProps = ((_h = initialData == null ? void 0 : initialData.root) == null ? void 0 : _h.props) || (initialData == null ? void 0 : initialData.root) || {};
9281
9313
  const defaultedRootProps = __spreadValues(__spreadValues({}, (_i = config.root) == null ? void 0 : _i.defaultProps), rootProps);
9314
+ const root = populateIds(
9315
+ toComponent(__spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: defaultedRootProps })),
9316
+ config
9317
+ );
9282
9318
  const newAppState = __spreadProps(__spreadValues({}, defaultAppState), {
9283
9319
  data: __spreadProps(__spreadValues({}, initialData), {
9284
- root: __spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: defaultedRootProps }),
9320
+ root: __spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: root.props }),
9285
9321
  content: initialData.content || []
9286
9322
  }),
9287
9323
  ui: __spreadProps(__spreadValues(__spreadValues({}, initial), clientUiState), {
@@ -9318,7 +9354,12 @@ function PuckProvider({ children }) {
9318
9354
  });
9319
9355
  })
9320
9356
  );
9321
- const initialHistoryIndex = (_initialHistory == null ? void 0 : _initialHistory.index) || blendedHistories.length - 1;
9357
+ const initialHistoryIndex = (0, import_react60.useMemo)(() => {
9358
+ if ((_initialHistory == null ? void 0 : _initialHistory.index) !== void 0 && (_initialHistory == null ? void 0 : _initialHistory.index) >= 0 && (_initialHistory == null ? void 0 : _initialHistory.index) < blendedHistories.length) {
9359
+ return _initialHistory == null ? void 0 : _initialHistory.index;
9360
+ }
9361
+ return blendedHistories.length - 1;
9362
+ }, []);
9322
9363
  const initialAppState = blendedHistories[initialHistoryIndex].state;
9323
9364
  const loadedOverrides = useLoadedOverrides({
9324
9365
  overrides,
@@ -9377,7 +9418,7 @@ function PuckProvider({ children }) {
9377
9418
  });
9378
9419
  const previousData = (0, import_react60.useRef)(null);
9379
9420
  (0, import_react60.useEffect)(() => {
9380
- appStore.subscribe(
9421
+ return appStore.subscribe(
9381
9422
  (s) => s.state.data,
9382
9423
  (data) => {
9383
9424
  if (onChange) {
@@ -9387,7 +9428,7 @@ function PuckProvider({ children }) {
9387
9428
  }
9388
9429
  }
9389
9430
  );
9390
- }, []);
9431
+ }, [onChange]);
9391
9432
  useRegisterPermissionsSlice(appStore, permissions);
9392
9433
  const uPuckStore = useRegisterUsePuckStore(appStore);
9393
9434
  (0, import_react60.useEffect)(() => {
@@ -9700,22 +9741,11 @@ function transformProps(data, propTransforms, config = { components: {} }) {
9700
9741
 
9701
9742
  // lib/resolve-all-data.ts
9702
9743
  init_react_import();
9703
-
9704
- // lib/data/to-component.ts
9705
- init_react_import();
9706
- var toComponent = (item) => {
9707
- return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
9708
- props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
9709
- type: "root"
9710
- });
9711
- };
9712
-
9713
- // lib/resolve-all-data.ts
9714
9744
  function resolveAllData(_0, _1) {
9715
9745
  return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
9716
9746
  var _a;
9717
9747
  const defaultedData = defaultData(data);
9718
- const resolveNode = (_node) => __async(this, null, function* () {
9748
+ const resolveNode = (_node) => __async(null, null, function* () {
9719
9749
  const node = toComponent(_node);
9720
9750
  onResolveStart == null ? void 0 : onResolveStart(node);
9721
9751
  const resolved = (yield resolveComponentData(
@@ -9736,13 +9766,13 @@ function resolveAllData(_0, _1) {
9736
9766
  onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
9737
9767
  return resolvedDeep;
9738
9768
  });
9739
- const processContent = (content) => __async(this, null, function* () {
9769
+ const processContent = (content) => __async(null, null, function* () {
9740
9770
  return Promise.all(content.map(resolveNode));
9741
9771
  });
9742
- const processZones = () => __async(this, null, function* () {
9772
+ const processZones = () => __async(null, null, function* () {
9743
9773
  var _a2;
9744
9774
  const zones = (_a2 = data.zones) != null ? _a2 : {};
9745
- Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
9775
+ Object.entries(zones).forEach((_02) => __async(null, [_02], function* ([zoneKey, content]) {
9746
9776
  zones[zoneKey] = yield Promise.all(content.map(resolveNode));
9747
9777
  }));
9748
9778
  return zones;
@@ -9752,7 +9782,7 @@ function resolveAllData(_0, _1) {
9752
9782
  content: yield processContent(defaultedData.content),
9753
9783
  zones: yield processZones()
9754
9784
  };
9755
- Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
9785
+ Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(null, null, function* () {
9756
9786
  const content = defaultedData.zones[zoneKey];
9757
9787
  dynamic.zones[zoneKey] = yield processContent(content);
9758
9788
  }), {});
@@ -9795,269 +9825,38 @@ classnames/index.js:
9795
9825
  *)
9796
9826
 
9797
9827
  lucide-react/dist/esm/shared/src/utils.js:
9798
- (**
9799
- * @license lucide-react v0.468.0 - ISC
9800
- *
9801
- * This source code is licensed under the ISC license.
9802
- * See the LICENSE file in the root directory of this source tree.
9803
- *)
9804
-
9805
9828
  lucide-react/dist/esm/defaultAttributes.js:
9806
- (**
9807
- * @license lucide-react v0.468.0 - ISC
9808
- *
9809
- * This source code is licensed under the ISC license.
9810
- * See the LICENSE file in the root directory of this source tree.
9811
- *)
9812
-
9813
9829
  lucide-react/dist/esm/Icon.js:
9814
- (**
9815
- * @license lucide-react v0.468.0 - ISC
9816
- *
9817
- * This source code is licensed under the ISC license.
9818
- * See the LICENSE file in the root directory of this source tree.
9819
- *)
9820
-
9821
9830
  lucide-react/dist/esm/createLucideIcon.js:
9822
- (**
9823
- * @license lucide-react v0.468.0 - ISC
9824
- *
9825
- * This source code is licensed under the ISC license.
9826
- * See the LICENSE file in the root directory of this source tree.
9827
- *)
9828
-
9829
9831
  lucide-react/dist/esm/icons/chevron-down.js:
9830
- (**
9831
- * @license lucide-react v0.468.0 - ISC
9832
- *
9833
- * This source code is licensed under the ISC license.
9834
- * See the LICENSE file in the root directory of this source tree.
9835
- *)
9836
-
9837
9832
  lucide-react/dist/esm/icons/chevron-right.js:
9838
- (**
9839
- * @license lucide-react v0.468.0 - ISC
9840
- *
9841
- * This source code is licensed under the ISC license.
9842
- * See the LICENSE file in the root directory of this source tree.
9843
- *)
9844
-
9845
9833
  lucide-react/dist/esm/icons/chevron-up.js:
9846
- (**
9847
- * @license lucide-react v0.468.0 - ISC
9848
- *
9849
- * This source code is licensed under the ISC license.
9850
- * See the LICENSE file in the root directory of this source tree.
9851
- *)
9852
-
9853
9834
  lucide-react/dist/esm/icons/circle-check-big.js:
9854
- (**
9855
- * @license lucide-react v0.468.0 - ISC
9856
- *
9857
- * This source code is licensed under the ISC license.
9858
- * See the LICENSE file in the root directory of this source tree.
9859
- *)
9860
-
9861
9835
  lucide-react/dist/esm/icons/copy.js:
9862
- (**
9863
- * @license lucide-react v0.468.0 - ISC
9864
- *
9865
- * This source code is licensed under the ISC license.
9866
- * See the LICENSE file in the root directory of this source tree.
9867
- *)
9868
-
9869
9836
  lucide-react/dist/esm/icons/corner-left-up.js:
9870
- (**
9871
- * @license lucide-react v0.468.0 - ISC
9872
- *
9873
- * This source code is licensed under the ISC license.
9874
- * See the LICENSE file in the root directory of this source tree.
9875
- *)
9876
-
9877
9837
  lucide-react/dist/esm/icons/ellipsis-vertical.js:
9878
- (**
9879
- * @license lucide-react v0.468.0 - ISC
9880
- *
9881
- * This source code is licensed under the ISC license.
9882
- * See the LICENSE file in the root directory of this source tree.
9883
- *)
9884
-
9885
9838
  lucide-react/dist/esm/icons/globe.js:
9886
- (**
9887
- * @license lucide-react v0.468.0 - ISC
9888
- *
9889
- * This source code is licensed under the ISC license.
9890
- * See the LICENSE file in the root directory of this source tree.
9891
- *)
9892
-
9893
9839
  lucide-react/dist/esm/icons/hash.js:
9894
- (**
9895
- * @license lucide-react v0.468.0 - ISC
9896
- *
9897
- * This source code is licensed under the ISC license.
9898
- * See the LICENSE file in the root directory of this source tree.
9899
- *)
9900
-
9901
9840
  lucide-react/dist/esm/icons/layers.js:
9902
- (**
9903
- * @license lucide-react v0.468.0 - ISC
9904
- *
9905
- * This source code is licensed under the ISC license.
9906
- * See the LICENSE file in the root directory of this source tree.
9907
- *)
9908
-
9909
9841
  lucide-react/dist/esm/icons/layout-grid.js:
9910
- (**
9911
- * @license lucide-react v0.468.0 - ISC
9912
- *
9913
- * This source code is licensed under the ISC license.
9914
- * See the LICENSE file in the root directory of this source tree.
9915
- *)
9916
-
9917
9842
  lucide-react/dist/esm/icons/link.js:
9918
- (**
9919
- * @license lucide-react v0.468.0 - ISC
9920
- *
9921
- * This source code is licensed under the ISC license.
9922
- * See the LICENSE file in the root directory of this source tree.
9923
- *)
9924
-
9925
9843
  lucide-react/dist/esm/icons/list.js:
9926
- (**
9927
- * @license lucide-react v0.468.0 - ISC
9928
- *
9929
- * This source code is licensed under the ISC license.
9930
- * See the LICENSE file in the root directory of this source tree.
9931
- *)
9932
-
9933
9844
  lucide-react/dist/esm/icons/lock-open.js:
9934
- (**
9935
- * @license lucide-react v0.468.0 - ISC
9936
- *
9937
- * This source code is licensed under the ISC license.
9938
- * See the LICENSE file in the root directory of this source tree.
9939
- *)
9940
-
9941
9845
  lucide-react/dist/esm/icons/lock.js:
9942
- (**
9943
- * @license lucide-react v0.468.0 - ISC
9944
- *
9945
- * This source code is licensed under the ISC license.
9946
- * See the LICENSE file in the root directory of this source tree.
9947
- *)
9948
-
9949
9846
  lucide-react/dist/esm/icons/monitor.js:
9950
- (**
9951
- * @license lucide-react v0.468.0 - ISC
9952
- *
9953
- * This source code is licensed under the ISC license.
9954
- * See the LICENSE file in the root directory of this source tree.
9955
- *)
9956
-
9957
9847
  lucide-react/dist/esm/icons/panel-left.js:
9958
- (**
9959
- * @license lucide-react v0.468.0 - ISC
9960
- *
9961
- * This source code is licensed under the ISC license.
9962
- * See the LICENSE file in the root directory of this source tree.
9963
- *)
9964
-
9965
9848
  lucide-react/dist/esm/icons/panel-right.js:
9966
- (**
9967
- * @license lucide-react v0.468.0 - ISC
9968
- *
9969
- * This source code is licensed under the ISC license.
9970
- * See the LICENSE file in the root directory of this source tree.
9971
- *)
9972
-
9973
9849
  lucide-react/dist/esm/icons/plus.js:
9974
- (**
9975
- * @license lucide-react v0.468.0 - ISC
9976
- *
9977
- * This source code is licensed under the ISC license.
9978
- * See the LICENSE file in the root directory of this source tree.
9979
- *)
9980
-
9981
9850
  lucide-react/dist/esm/icons/redo-2.js:
9982
- (**
9983
- * @license lucide-react v0.468.0 - ISC
9984
- *
9985
- * This source code is licensed under the ISC license.
9986
- * See the LICENSE file in the root directory of this source tree.
9987
- *)
9988
-
9989
9851
  lucide-react/dist/esm/icons/search.js:
9990
- (**
9991
- * @license lucide-react v0.468.0 - ISC
9992
- *
9993
- * This source code is licensed under the ISC license.
9994
- * See the LICENSE file in the root directory of this source tree.
9995
- *)
9996
-
9997
9852
  lucide-react/dist/esm/icons/sliders-horizontal.js:
9998
- (**
9999
- * @license lucide-react v0.468.0 - ISC
10000
- *
10001
- * This source code is licensed under the ISC license.
10002
- * See the LICENSE file in the root directory of this source tree.
10003
- *)
10004
-
10005
9853
  lucide-react/dist/esm/icons/smartphone.js:
10006
- (**
10007
- * @license lucide-react v0.468.0 - ISC
10008
- *
10009
- * This source code is licensed under the ISC license.
10010
- * See the LICENSE file in the root directory of this source tree.
10011
- *)
10012
-
10013
9854
  lucide-react/dist/esm/icons/tablet.js:
10014
- (**
10015
- * @license lucide-react v0.468.0 - ISC
10016
- *
10017
- * This source code is licensed under the ISC license.
10018
- * See the LICENSE file in the root directory of this source tree.
10019
- *)
10020
-
10021
9855
  lucide-react/dist/esm/icons/trash.js:
10022
- (**
10023
- * @license lucide-react v0.468.0 - ISC
10024
- *
10025
- * This source code is licensed under the ISC license.
10026
- * See the LICENSE file in the root directory of this source tree.
10027
- *)
10028
-
10029
9856
  lucide-react/dist/esm/icons/type.js:
10030
- (**
10031
- * @license lucide-react v0.468.0 - ISC
10032
- *
10033
- * This source code is licensed under the ISC license.
10034
- * See the LICENSE file in the root directory of this source tree.
10035
- *)
10036
-
10037
9857
  lucide-react/dist/esm/icons/undo-2.js:
10038
- (**
10039
- * @license lucide-react v0.468.0 - ISC
10040
- *
10041
- * This source code is licensed under the ISC license.
10042
- * See the LICENSE file in the root directory of this source tree.
10043
- *)
10044
-
10045
9858
  lucide-react/dist/esm/icons/zoom-in.js:
10046
- (**
10047
- * @license lucide-react v0.468.0 - ISC
10048
- *
10049
- * This source code is licensed under the ISC license.
10050
- * See the LICENSE file in the root directory of this source tree.
10051
- *)
10052
-
10053
9859
  lucide-react/dist/esm/icons/zoom-out.js:
10054
- (**
10055
- * @license lucide-react v0.468.0 - ISC
10056
- *
10057
- * This source code is licensed under the ISC license.
10058
- * See the LICENSE file in the root directory of this source tree.
10059
- *)
10060
-
10061
9860
  lucide-react/dist/esm/lucide-react.js:
10062
9861
  (**
10063
9862
  * @license lucide-react v0.468.0 - ISC