@measured/puck 0.20.3-canary.d855fa8c → 0.21.0-canary.049cfbbc

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-TC25DCTQ.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 = [
@@ -768,7 +805,9 @@ var keyCodeMap = {
768
805
  KeyW: "w",
769
806
  KeyX: "x",
770
807
  KeyY: "y",
771
- KeyZ: "z"
808
+ KeyZ: "z",
809
+ Delete: "delete",
810
+ Backspace: "backspace"
772
811
  };
773
812
  var useHotkeyStore = create()(
774
813
  subscribeWithSelector((set) => ({
@@ -792,8 +831,10 @@ var monitorHotkeys = (doc) => {
792
831
  ([key2, value]) => value === !!combo[key2]
793
832
  );
794
833
  if (conditionMet) {
795
- e.preventDefault();
796
- cb();
834
+ const handled = cb(e);
835
+ if (handled !== false) {
836
+ e.preventDefault();
837
+ }
797
838
  }
798
839
  });
799
840
  if (key !== "meta" && key !== "ctrl" && key !== "shift") {
@@ -816,6 +857,10 @@ var monitorHotkeys = (doc) => {
816
857
  useHotkeyStore.getState().reset();
817
858
  }
818
859
  };
860
+ const onBlur = () => {
861
+ useHotkeyStore.getState().reset();
862
+ };
863
+ window.addEventListener("blur", onBlur);
819
864
  doc.addEventListener("keydown", onKeyDown);
820
865
  doc.addEventListener("keyup", onKeyUp);
821
866
  doc.addEventListener("visibilitychange", onVisibilityChanged);
@@ -823,6 +868,7 @@ var monitorHotkeys = (doc) => {
823
868
  doc.removeEventListener("keydown", onKeyDown);
824
869
  doc.removeEventListener("keyup", onKeyUp);
825
870
  doc.removeEventListener("visibilitychange", onVisibilityChanged);
871
+ window.removeEventListener("blur", onBlur);
826
872
  };
827
873
  };
828
874
  var useMonitorHotkeys = () => {
@@ -1017,7 +1063,7 @@ var flattenData = (state, config) => {
1017
1063
  (content) => content,
1018
1064
  (item) => {
1019
1065
  data.push(item);
1020
- return null;
1066
+ return item;
1021
1067
  }
1022
1068
  );
1023
1069
  return data;
@@ -1025,10 +1071,10 @@ var flattenData = (state, config) => {
1025
1071
 
1026
1072
  // store/slices/permissions.ts
1027
1073
  var createPermissionsSlice = (set, get) => {
1028
- const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
1074
+ const resolvePermissions = (..._0) => __async(null, [..._0], function* (params = {}, force) {
1029
1075
  const { state, permissions, config } = get();
1030
1076
  const { cache, globalPermissions } = permissions;
1031
- const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
1077
+ const resolveDataForItem = (item2, force2 = false) => __async(null, null, function* () {
1032
1078
  var _a, _b, _c;
1033
1079
  const { config: config2, state: appState, setComponentLoading } = get();
1034
1080
  const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
@@ -1083,13 +1129,13 @@ var createPermissionsSlice = (set, get) => {
1083
1129
  if (item) {
1084
1130
  yield resolveDataForItem(item, force);
1085
1131
  } else if (type) {
1086
- 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* () {
1087
1133
  yield resolveDataForItem(item2, force);
1088
1134
  }));
1089
1135
  } else if (root) {
1090
1136
  resolveDataForRoot(force);
1091
1137
  } else {
1092
- flattenData(state, config).map((item2) => __async(void 0, null, function* () {
1138
+ flattenData(state, config).map((item2) => __async(null, null, function* () {
1093
1139
  yield resolveDataForItem(item2, force);
1094
1140
  }));
1095
1141
  }
@@ -1170,9 +1216,10 @@ var createFieldsSlice = (_set, _get) => {
1170
1216
  };
1171
1217
  var useRegisterFieldsSlice = (appStore, id) => {
1172
1218
  const resolveFields = useCallback(
1173
- (reset) => __async(void 0, null, function* () {
1219
+ (reset) => __async(null, null, function* () {
1174
1220
  var _a, _b;
1175
1221
  const { fields, lastResolvedData } = appStore.getState().fields;
1222
+ const metadata = appStore.getState().metadata;
1176
1223
  const nodes = appStore.getState().state.indexes.nodes;
1177
1224
  const node = nodes[id || "root"];
1178
1225
  const componentData = node == null ? void 0 : node.data;
@@ -1202,6 +1249,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
1202
1249
  changed,
1203
1250
  fields: defaultFields2,
1204
1251
  lastFields,
1252
+ metadata: __spreadValues(__spreadValues({}, metadata), componentConfig.metadata),
1205
1253
  lastData,
1206
1254
  appState: makeStatePublic(state),
1207
1255
  parent
@@ -1368,7 +1416,7 @@ var createAppStore = (initialAppStore) => create2()(
1368
1416
  const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
1369
1417
  return __spreadProps(__spreadValues({}, s), { state, selectedItem });
1370
1418
  }),
1371
- resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
1419
+ resolveComponentData: (componentData, trigger) => __async(null, null, function* () {
1372
1420
  const { config, metadata, setComponentLoading, permissions } = get();
1373
1421
  const timeouts = {};
1374
1422
  return yield resolveComponentData(
@@ -1379,7 +1427,7 @@ var createAppStore = (initialAppStore) => create2()(
1379
1427
  const id = "id" in item.props ? item.props.id : "root";
1380
1428
  timeouts[id] = setComponentLoading(id, true, 50);
1381
1429
  },
1382
- (item) => __async(void 0, null, function* () {
1430
+ (item) => __async(null, null, function* () {
1383
1431
  const id = "id" in item.props ? item.props.id : "root";
1384
1432
  if ("type" in item) {
1385
1433
  yield permissions.refreshPermissions({ item });
@@ -1391,7 +1439,7 @@ var createAppStore = (initialAppStore) => create2()(
1391
1439
  trigger
1392
1440
  );
1393
1441
  }),
1394
- resolveAndCommitData: () => __async(void 0, null, function* () {
1442
+ resolveAndCommitData: () => __async(null, null, function* () {
1395
1443
  const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
1396
1444
  walkAppState(
1397
1445
  state,
@@ -2412,7 +2460,7 @@ var collisionStore = createStore(() => ({
2412
2460
 
2413
2461
  // lib/dnd/collision/dynamic/index.ts
2414
2462
  var flushNext = "";
2415
- var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
2463
+ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => ((input) => {
2416
2464
  var _a, _b, _c, _d, _e;
2417
2465
  const { dragOperation, droppable } = input;
2418
2466
  const { position } = dragOperation;
@@ -2505,7 +2553,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
2505
2553
  }
2506
2554
  collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
2507
2555
  return null;
2508
- };
2556
+ });
2509
2557
 
2510
2558
  // components/Sortable/index.tsx
2511
2559
  import { useSortable } from "@dnd-kit/react/sortable";
@@ -2938,8 +2986,9 @@ var ArrayField = ({
2938
2986
  var _a;
2939
2987
  if (isDraggingAny) return;
2940
2988
  const existingValue = value || [];
2989
+ const defaultProps = typeof field.defaultItemProps === "function" ? field.defaultItemProps(existingValue.length) : (_a = field.defaultItemProps) != null ? _a : {};
2941
2990
  const newItem = defaultSlots(
2942
- uniqifyItem((_a = field.defaultItemProps) != null ? _a : {}),
2991
+ uniqifyItem(defaultProps),
2943
2992
  field.arrayFields
2944
2993
  );
2945
2994
  const newValue = [...existingValue, newItem];
@@ -3114,11 +3163,13 @@ var ExternalInput = ({
3114
3163
  id,
3115
3164
  readOnly
3116
3165
  }) => {
3166
+ var _a;
3117
3167
  const {
3118
3168
  mapProp = (val) => val,
3119
3169
  mapRow = (val) => val,
3120
3170
  filterFields
3121
3171
  } = field || {};
3172
+ const { enabled: shouldCacheData } = (_a = field.cache) != null ? _a : { enabled: true };
3122
3173
  const [data, setData] = useState6([]);
3123
3174
  const [isOpen, setOpen] = useState6(false);
3124
3175
  const [isLoading, setIsLoading] = useState6(true);
@@ -3141,14 +3192,21 @@ var ExternalInput = ({
3141
3192
  }, [mappedData]);
3142
3193
  const [searchQuery, setSearchQuery] = useState6(field.initialQuery || "");
3143
3194
  const search = useCallback3(
3144
- (query, filters2) => __async(void 0, null, function* () {
3195
+ (query, filters2) => __async(null, null, function* () {
3145
3196
  setIsLoading(true);
3146
3197
  const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
3147
- 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
+ }
3148
3204
  if (listData) {
3149
3205
  setData(listData);
3150
3206
  setIsLoading(false);
3151
- dataCache[cacheKey] = listData;
3207
+ if (shouldCacheData) {
3208
+ dataCache[cacheKey] = listData;
3209
+ }
3152
3210
  }
3153
3211
  }),
3154
3212
  [id, field]
@@ -3212,6 +3270,7 @@ var ExternalInput = ({
3212
3270
  }),
3213
3271
  onSubmit: (e) => {
3214
3272
  e.preventDefault();
3273
+ e.stopPropagation();
3215
3274
  search(searchQuery, filters);
3216
3275
  },
3217
3276
  children: [
@@ -3359,7 +3418,7 @@ var ExternalField = ({
3359
3418
  placeholder: ((_a = deprecatedField.adaptor) == null ? void 0 : _a.name) ? `Select from ${deprecatedField.adaptor.name}` : validField.placeholder || "Select data",
3360
3419
  mapProp: ((_b = deprecatedField.adaptor) == null ? void 0 : _b.mapProp) || validField.mapProp,
3361
3420
  mapRow: validField.mapRow,
3362
- 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* () {
3363
3422
  return yield deprecatedField.adaptor.fetchList(
3364
3423
  deprecatedField.adaptorParams
3365
3424
  );
@@ -4122,12 +4181,14 @@ var DraggableComponent = ({
4122
4181
  }
4123
4182
  return cleanup;
4124
4183
  }, [permissions.drag, zoneCompound]);
4184
+ const [, setRerender] = useState10(0);
4125
4185
  const ref = useRef2(null);
4126
4186
  const refSetter = useCallback7(
4127
4187
  (el) => {
4128
4188
  sortableRef(el);
4129
- if (el) {
4189
+ if (ref.current !== el) {
4130
4190
  ref.current = el;
4191
+ setRerender((update) => update + 1);
4131
4192
  }
4132
4193
  },
4133
4194
  [sortableRef]
@@ -4782,7 +4843,7 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
4782
4843
 
4783
4844
  // lib/insert-component.ts
4784
4845
  init_react_import();
4785
- var insertComponent = (componentType, zone, index, appStore) => __async(void 0, null, function* () {
4846
+ var insertComponent = (componentType, zone, index, appStore) => __async(null, null, function* () {
4786
4847
  const id = generateId(componentType);
4787
4848
  const insertActionData = {
4788
4849
  type: "insert",
@@ -5466,7 +5527,7 @@ import { useCallback as useCallback9 } from "react";
5466
5527
  function useRenderedCallback(callback, deps) {
5467
5528
  const manager = useDragDropManager();
5468
5529
  return useCallback9(
5469
- (...args) => __async(this, null, function* () {
5530
+ (...args) => __async(null, null, function* () {
5470
5531
  yield manager == null ? void 0 : manager.renderer.rendering;
5471
5532
  return callback(...args);
5472
5533
  }),
@@ -5632,26 +5693,26 @@ var registerOverlayPortal = (el, opts = {}) => {
5632
5693
  capture: true
5633
5694
  });
5634
5695
  };
5635
- if (disableDragOnFocus) {
5636
- el.addEventListener("focus", onFocus, { capture: true });
5637
- el.addEventListener("blur", onBlur, { capture: true });
5638
- } else if (disableDrag) {
5696
+ if (disableDrag) {
5639
5697
  el.addEventListener("pointerdown", stopPropagation, {
5640
5698
  capture: true
5641
5699
  });
5700
+ } else if (disableDragOnFocus) {
5701
+ el.addEventListener("focus", onFocus, { capture: true });
5702
+ el.addEventListener("blur", onBlur, { capture: true });
5642
5703
  }
5643
5704
  el.setAttribute("data-puck-overlay-portal", "true");
5644
5705
  return () => {
5645
5706
  el.removeEventListener("mouseover", stopPropagation, {
5646
5707
  capture: true
5647
5708
  });
5648
- if (disableDragOnFocus) {
5649
- el.removeEventListener("focus", onFocus, { capture: true });
5650
- el.removeEventListener("blur", onFocus, { capture: true });
5651
- } else if (disableDrag) {
5709
+ if (disableDrag) {
5652
5710
  el.removeEventListener("pointerdown", stopPropagation, {
5653
5711
  capture: true
5654
5712
  });
5713
+ } else if (disableDragOnFocus) {
5714
+ el.removeEventListener("focus", onFocus, { capture: true });
5715
+ el.removeEventListener("blur", onBlur, { capture: true });
5655
5716
  }
5656
5717
  el.removeAttribute("data-puck-overlay-portal");
5657
5718
  };
@@ -5659,7 +5720,7 @@ var registerOverlayPortal = (el, opts = {}) => {
5659
5720
 
5660
5721
  // css-module:/home/runner/work/puck/puck/packages/core/components/InlineTextField/styles.module.css#css-module
5661
5722
  init_react_import();
5662
- var styles_module_default13 = { "InlineTextField": "_InlineTextField_1xph6_1" };
5723
+ var styles_module_default13 = { "InlineTextField": "_InlineTextField_104qp_1" };
5663
5724
 
5664
5725
  // lib/data/set-deep.ts
5665
5726
  init_react_import();
@@ -5733,7 +5794,7 @@ var InlineTextFieldInternal = ({
5733
5794
  ref.current.replaceChildren(value);
5734
5795
  }
5735
5796
  const cleanupPortal = registerOverlayPortal(ref.current);
5736
- const handleInput = (e) => __async(void 0, null, function* () {
5797
+ const handleInput = (e) => __async(null, null, function* () {
5737
5798
  var _a2;
5738
5799
  const appStore2 = appStoreApi.getState();
5739
5800
  const node = appStore2.state.indexes.nodes[componentId];
@@ -6394,7 +6455,7 @@ function createUsePuck() {
6394
6455
  }
6395
6456
  const result = useStore3(
6396
6457
  usePuckApi,
6397
- selector != null ? selector : (s) => s
6458
+ selector != null ? selector : ((s) => s)
6398
6459
  );
6399
6460
  return result;
6400
6461
  };
@@ -6419,7 +6480,7 @@ function useGetPuck() {
6419
6480
  init_react_import();
6420
6481
  import {
6421
6482
  createContext as createContext8,
6422
- useCallback as useCallback20,
6483
+ useCallback as useCallback21,
6423
6484
  useContext as useContext13,
6424
6485
  useEffect as useEffect29,
6425
6486
  useMemo as useMemo20,
@@ -6541,7 +6602,7 @@ var DefaultFields = ({
6541
6602
  }) => {
6542
6603
  return /* @__PURE__ */ jsx29(Fragment8, { children });
6543
6604
  };
6544
- var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
6605
+ var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(null, null, function* () {
6545
6606
  let currentProps;
6546
6607
  const { dispatch, state, selectedItem, resolveComponentData: resolveComponentData2 } = appStore.getState();
6547
6608
  const { data, ui } = state;
@@ -6915,7 +6976,7 @@ var CopyHostStyles = ({
6915
6976
  let elements = [];
6916
6977
  const hashes = {};
6917
6978
  const lookupEl = (el) => elements.findIndex((elementMap) => elementMap.original === el);
6918
- const mirrorEl = (el, inlineStyles = false) => __async(void 0, null, function* () {
6979
+ const mirrorEl = (el, inlineStyles = false) => __async(null, null, function* () {
6919
6980
  let mirror;
6920
6981
  if (el.nodeName === "LINK" && inlineStyles) {
6921
6982
  mirror = document.createElement("style");
@@ -6947,7 +7008,7 @@ var CopyHostStyles = ({
6947
7008
  }
6948
7009
  return mirror;
6949
7010
  });
6950
- const addEl = (el) => __async(void 0, null, function* () {
7011
+ const addEl = (el) => __async(null, null, function* () {
6951
7012
  const index = lookupEl(el);
6952
7013
  if (index > -1) {
6953
7014
  if (debug)
@@ -7020,7 +7081,7 @@ var CopyHostStyles = ({
7020
7081
  const parentBody = parentDocument.getElementsByTagName("body")[0];
7021
7082
  syncAttributes(parentBody, doc.body);
7022
7083
  Promise.all(
7023
- collectedStyles.map((styleNode, i) => __async(void 0, null, function* () {
7084
+ collectedStyles.map((styleNode, i) => __async(null, null, function* () {
7024
7085
  if (styleNode.nodeName === "LINK") {
7025
7086
  const linkHref = styleNode.href;
7026
7087
  if (hrefs.indexOf(linkHref) > -1) {
@@ -7979,12 +8040,73 @@ var usePreviewModeHotkeys = () => {
7979
8040
  useHotkey({ ctrl: true, i: true }, toggleInteractive);
7980
8041
  };
7981
8042
 
8043
+ // lib/use-delete-hotkeys.ts
8044
+ init_react_import();
8045
+ import { useCallback as useCallback17 } from "react";
8046
+ var isElementVisible = (element) => {
8047
+ let current = element;
8048
+ while (current && current !== document.body) {
8049
+ const style = window.getComputedStyle(current);
8050
+ if (style.display === "none" || style.visibility === "hidden" || style.opacity === "0" || current.getAttribute("aria-hidden") === "true" || current.hasAttribute("hidden")) {
8051
+ return false;
8052
+ }
8053
+ current = current.parentElement;
8054
+ }
8055
+ return true;
8056
+ };
8057
+ var shouldBlockDeleteHotkey = (e) => {
8058
+ var _a;
8059
+ if (e == null ? void 0 : e.defaultPrevented) return true;
8060
+ const origin = ((_a = e == null ? void 0 : e.composedPath) == null ? void 0 : _a.call(e)[0]) || (e == null ? void 0 : e.target) || document.activeElement;
8061
+ if (origin instanceof HTMLElement) {
8062
+ const tag = origin.tagName.toLowerCase();
8063
+ if (tag === "input" || tag === "textarea" || tag === "select") return true;
8064
+ if (origin.isContentEditable) return true;
8065
+ const role = origin.getAttribute("role");
8066
+ if (role === "textbox" || role === "combobox" || role === "searchbox" || role === "listbox" || role === "grid") {
8067
+ return true;
8068
+ }
8069
+ }
8070
+ const modal = document.querySelector(
8071
+ 'dialog[open], [aria-modal="true"], [role="dialog"], [role="alertdialog"]'
8072
+ );
8073
+ if (modal && isElementVisible(modal)) {
8074
+ return true;
8075
+ }
8076
+ return false;
8077
+ };
8078
+ var useDeleteHotkeys = () => {
8079
+ const appStore = useAppStoreApi();
8080
+ const deleteSelectedComponent = useCallback17(
8081
+ (e) => {
8082
+ var _a;
8083
+ if (shouldBlockDeleteHotkey(e)) {
8084
+ return false;
8085
+ }
8086
+ const { state, dispatch, permissions, selectedItem } = appStore.getState();
8087
+ const sel = (_a = state.ui) == null ? void 0 : _a.itemSelector;
8088
+ if (!(sel == null ? void 0 : sel.zone) || !selectedItem) return true;
8089
+ if (!permissions.getPermissions({ item: selectedItem }).delete)
8090
+ return true;
8091
+ dispatch({
8092
+ type: "remove",
8093
+ index: sel.index,
8094
+ zone: sel.zone
8095
+ });
8096
+ return true;
8097
+ },
8098
+ [appStore]
8099
+ );
8100
+ useHotkey({ delete: true }, deleteSelectedComponent);
8101
+ useHotkey({ backspace: true }, deleteSelectedComponent);
8102
+ };
8103
+
7982
8104
  // components/Puck/index.tsx
7983
- import fdeq from "fast-deep-equal";
8105
+ var import_fast_deep_equal = __toESM(require_fast_deep_equal());
7984
8106
 
7985
8107
  // components/Puck/components/Header/index.tsx
7986
8108
  init_react_import();
7987
- import { memo as memo4, useCallback as useCallback17, useMemo as useMemo19, useState as useState23 } from "react";
8109
+ import { memo as memo4, useCallback as useCallback18, useMemo as useMemo19, useState as useState23 } from "react";
7988
8110
 
7989
8111
  // components/MenuBar/index.tsx
7990
8112
  init_react_import();
@@ -8111,7 +8233,7 @@ var HeaderInner = () => {
8111
8233
  const rightSideBarVisible = useAppStore(
8112
8234
  (s) => s.state.ui.rightSideBarVisible
8113
8235
  );
8114
- const toggleSidebars = useCallback17(
8236
+ const toggleSidebars = useCallback18(
8115
8237
  (sidebar) => {
8116
8238
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
8117
8239
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -8221,7 +8343,7 @@ init_react_import();
8221
8343
 
8222
8344
  // components/Puck/components/ResizeHandle/index.tsx
8223
8345
  init_react_import();
8224
- import { useCallback as useCallback18, useRef as useRef10 } from "react";
8346
+ import { useCallback as useCallback19, useRef as useRef10 } from "react";
8225
8347
 
8226
8348
  // css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/ResizeHandle/styles.module.css#css-module
8227
8349
  init_react_import();
@@ -8242,7 +8364,7 @@ var ResizeHandle = ({
8242
8364
  const isDragging = useRef10(false);
8243
8365
  const startX = useRef10(0);
8244
8366
  const startWidth = useRef10(0);
8245
- const handleMouseMove = useCallback18(
8367
+ const handleMouseMove = useCallback19(
8246
8368
  (e) => {
8247
8369
  if (!isDragging.current) return;
8248
8370
  const delta = e.clientX - startX.current;
@@ -8253,7 +8375,7 @@ var ResizeHandle = ({
8253
8375
  },
8254
8376
  [onResize, position]
8255
8377
  );
8256
- const handleMouseUp = useCallback18(() => {
8378
+ const handleMouseUp = useCallback19(() => {
8257
8379
  var _a;
8258
8380
  if (!isDragging.current) return;
8259
8381
  isDragging.current = false;
@@ -8269,7 +8391,7 @@ var ResizeHandle = ({
8269
8391
  onResizeEnd(finalWidth);
8270
8392
  resetAutoZoom();
8271
8393
  }, [onResizeEnd]);
8272
- const handleMouseDown = useCallback18(
8394
+ const handleMouseDown = useCallback19(
8273
8395
  (e) => {
8274
8396
  var _a;
8275
8397
  isDragging.current = true;
@@ -8329,7 +8451,7 @@ var Sidebar = ({
8329
8451
 
8330
8452
  // lib/use-sidebar-resize.ts
8331
8453
  init_react_import();
8332
- import { useCallback as useCallback19, useEffect as useEffect28, useRef as useRef11, useState as useState24 } from "react";
8454
+ import { useCallback as useCallback20, useEffect as useEffect28, useRef as useRef11, useState as useState24 } from "react";
8333
8455
  function useSidebarResize(position, dispatch) {
8334
8456
  const [width, setWidth] = useState24(null);
8335
8457
  const sidebarRef = useRef11(null);
@@ -8366,7 +8488,7 @@ function useSidebarResize(position, dispatch) {
8366
8488
  setWidth(storeWidth);
8367
8489
  }
8368
8490
  }, [storeWidth]);
8369
- const handleResizeEnd = useCallback19(
8491
+ const handleResizeEnd = useCallback20(
8370
8492
  (width2) => {
8371
8493
  dispatch({
8372
8494
  type: "setUi",
@@ -8484,9 +8606,13 @@ function PuckProvider({ children }) {
8484
8606
  }
8485
8607
  const rootProps = ((_h = initialData == null ? void 0 : initialData.root) == null ? void 0 : _h.props) || (initialData == null ? void 0 : initialData.root) || {};
8486
8608
  const defaultedRootProps = __spreadValues(__spreadValues({}, (_i = config.root) == null ? void 0 : _i.defaultProps), rootProps);
8609
+ const root = populateIds(
8610
+ toComponent(__spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: defaultedRootProps })),
8611
+ config
8612
+ );
8487
8613
  const newAppState = __spreadProps(__spreadValues({}, defaultAppState), {
8488
8614
  data: __spreadProps(__spreadValues({}, initialData), {
8489
- root: __spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: defaultedRootProps }),
8615
+ root: __spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: root.props }),
8490
8616
  content: initialData.content || []
8491
8617
  }),
8492
8618
  ui: __spreadProps(__spreadValues(__spreadValues({}, initial), clientUiState), {
@@ -8537,7 +8663,7 @@ function PuckProvider({ children }) {
8537
8663
  );
8538
8664
  return __spreadValues(__spreadValues({}, pluginFieldTransforms), fieldTransforms);
8539
8665
  }, [fieldTransforms, plugins]);
8540
- const generateAppStore = useCallback20(
8666
+ const generateAppStore = useCallback21(
8541
8667
  (state) => {
8542
8668
  return {
8543
8669
  state,
@@ -8582,17 +8708,17 @@ function PuckProvider({ children }) {
8582
8708
  });
8583
8709
  const previousData = useRef12(null);
8584
8710
  useEffect29(() => {
8585
- appStore.subscribe(
8711
+ return appStore.subscribe(
8586
8712
  (s) => s.state.data,
8587
8713
  (data) => {
8588
8714
  if (onChange) {
8589
- if (fdeq(data, previousData.current)) return;
8715
+ if ((0, import_fast_deep_equal.default)(data, previousData.current)) return;
8590
8716
  onChange(data);
8591
8717
  previousData.current = data;
8592
8718
  }
8593
8719
  }
8594
8720
  );
8595
- }, []);
8721
+ }, [onChange]);
8596
8722
  useRegisterPermissionsSlice(appStore, permissions);
8597
8723
  const uPuckStore = useRegisterUsePuckStore(appStore);
8598
8724
  useEffect29(() => {
@@ -8666,6 +8792,7 @@ function PuckLayout({ children }) {
8666
8792
  }, []);
8667
8793
  const ready = useAppStore((s) => s.status === "READY");
8668
8794
  useMonitorHotkeys();
8795
+ useDeleteHotkeys();
8669
8796
  useEffect29(() => {
8670
8797
  if (ready && iframe.enabled) {
8671
8798
  const frameDoc = getFrame();
@@ -8807,269 +8934,38 @@ classnames/index.js:
8807
8934
  *)
8808
8935
 
8809
8936
  lucide-react/dist/esm/shared/src/utils.js:
8810
- (**
8811
- * @license lucide-react v0.468.0 - ISC
8812
- *
8813
- * This source code is licensed under the ISC license.
8814
- * See the LICENSE file in the root directory of this source tree.
8815
- *)
8816
-
8817
8937
  lucide-react/dist/esm/defaultAttributes.js:
8818
- (**
8819
- * @license lucide-react v0.468.0 - ISC
8820
- *
8821
- * This source code is licensed under the ISC license.
8822
- * See the LICENSE file in the root directory of this source tree.
8823
- *)
8824
-
8825
8938
  lucide-react/dist/esm/Icon.js:
8826
- (**
8827
- * @license lucide-react v0.468.0 - ISC
8828
- *
8829
- * This source code is licensed under the ISC license.
8830
- * See the LICENSE file in the root directory of this source tree.
8831
- *)
8832
-
8833
8939
  lucide-react/dist/esm/createLucideIcon.js:
8834
- (**
8835
- * @license lucide-react v0.468.0 - ISC
8836
- *
8837
- * This source code is licensed under the ISC license.
8838
- * See the LICENSE file in the root directory of this source tree.
8839
- *)
8840
-
8841
8940
  lucide-react/dist/esm/icons/chevron-down.js:
8842
- (**
8843
- * @license lucide-react v0.468.0 - ISC
8844
- *
8845
- * This source code is licensed under the ISC license.
8846
- * See the LICENSE file in the root directory of this source tree.
8847
- *)
8848
-
8849
8941
  lucide-react/dist/esm/icons/chevron-right.js:
8850
- (**
8851
- * @license lucide-react v0.468.0 - ISC
8852
- *
8853
- * This source code is licensed under the ISC license.
8854
- * See the LICENSE file in the root directory of this source tree.
8855
- *)
8856
-
8857
8942
  lucide-react/dist/esm/icons/chevron-up.js:
8858
- (**
8859
- * @license lucide-react v0.468.0 - ISC
8860
- *
8861
- * This source code is licensed under the ISC license.
8862
- * See the LICENSE file in the root directory of this source tree.
8863
- *)
8864
-
8865
8943
  lucide-react/dist/esm/icons/circle-check-big.js:
8866
- (**
8867
- * @license lucide-react v0.468.0 - ISC
8868
- *
8869
- * This source code is licensed under the ISC license.
8870
- * See the LICENSE file in the root directory of this source tree.
8871
- *)
8872
-
8873
8944
  lucide-react/dist/esm/icons/copy.js:
8874
- (**
8875
- * @license lucide-react v0.468.0 - ISC
8876
- *
8877
- * This source code is licensed under the ISC license.
8878
- * See the LICENSE file in the root directory of this source tree.
8879
- *)
8880
-
8881
8945
  lucide-react/dist/esm/icons/corner-left-up.js:
8882
- (**
8883
- * @license lucide-react v0.468.0 - ISC
8884
- *
8885
- * This source code is licensed under the ISC license.
8886
- * See the LICENSE file in the root directory of this source tree.
8887
- *)
8888
-
8889
8946
  lucide-react/dist/esm/icons/ellipsis-vertical.js:
8890
- (**
8891
- * @license lucide-react v0.468.0 - ISC
8892
- *
8893
- * This source code is licensed under the ISC license.
8894
- * See the LICENSE file in the root directory of this source tree.
8895
- *)
8896
-
8897
8947
  lucide-react/dist/esm/icons/globe.js:
8898
- (**
8899
- * @license lucide-react v0.468.0 - ISC
8900
- *
8901
- * This source code is licensed under the ISC license.
8902
- * See the LICENSE file in the root directory of this source tree.
8903
- *)
8904
-
8905
8948
  lucide-react/dist/esm/icons/hash.js:
8906
- (**
8907
- * @license lucide-react v0.468.0 - ISC
8908
- *
8909
- * This source code is licensed under the ISC license.
8910
- * See the LICENSE file in the root directory of this source tree.
8911
- *)
8912
-
8913
8949
  lucide-react/dist/esm/icons/layers.js:
8914
- (**
8915
- * @license lucide-react v0.468.0 - ISC
8916
- *
8917
- * This source code is licensed under the ISC license.
8918
- * See the LICENSE file in the root directory of this source tree.
8919
- *)
8920
-
8921
8950
  lucide-react/dist/esm/icons/layout-grid.js:
8922
- (**
8923
- * @license lucide-react v0.468.0 - ISC
8924
- *
8925
- * This source code is licensed under the ISC license.
8926
- * See the LICENSE file in the root directory of this source tree.
8927
- *)
8928
-
8929
8951
  lucide-react/dist/esm/icons/link.js:
8930
- (**
8931
- * @license lucide-react v0.468.0 - ISC
8932
- *
8933
- * This source code is licensed under the ISC license.
8934
- * See the LICENSE file in the root directory of this source tree.
8935
- *)
8936
-
8937
8952
  lucide-react/dist/esm/icons/list.js:
8938
- (**
8939
- * @license lucide-react v0.468.0 - ISC
8940
- *
8941
- * This source code is licensed under the ISC license.
8942
- * See the LICENSE file in the root directory of this source tree.
8943
- *)
8944
-
8945
8953
  lucide-react/dist/esm/icons/lock-open.js:
8946
- (**
8947
- * @license lucide-react v0.468.0 - ISC
8948
- *
8949
- * This source code is licensed under the ISC license.
8950
- * See the LICENSE file in the root directory of this source tree.
8951
- *)
8952
-
8953
8954
  lucide-react/dist/esm/icons/lock.js:
8954
- (**
8955
- * @license lucide-react v0.468.0 - ISC
8956
- *
8957
- * This source code is licensed under the ISC license.
8958
- * See the LICENSE file in the root directory of this source tree.
8959
- *)
8960
-
8961
8955
  lucide-react/dist/esm/icons/monitor.js:
8962
- (**
8963
- * @license lucide-react v0.468.0 - ISC
8964
- *
8965
- * This source code is licensed under the ISC license.
8966
- * See the LICENSE file in the root directory of this source tree.
8967
- *)
8968
-
8969
8956
  lucide-react/dist/esm/icons/panel-left.js:
8970
- (**
8971
- * @license lucide-react v0.468.0 - ISC
8972
- *
8973
- * This source code is licensed under the ISC license.
8974
- * See the LICENSE file in the root directory of this source tree.
8975
- *)
8976
-
8977
8957
  lucide-react/dist/esm/icons/panel-right.js:
8978
- (**
8979
- * @license lucide-react v0.468.0 - ISC
8980
- *
8981
- * This source code is licensed under the ISC license.
8982
- * See the LICENSE file in the root directory of this source tree.
8983
- *)
8984
-
8985
8958
  lucide-react/dist/esm/icons/plus.js:
8986
- (**
8987
- * @license lucide-react v0.468.0 - ISC
8988
- *
8989
- * This source code is licensed under the ISC license.
8990
- * See the LICENSE file in the root directory of this source tree.
8991
- *)
8992
-
8993
8959
  lucide-react/dist/esm/icons/redo-2.js:
8994
- (**
8995
- * @license lucide-react v0.468.0 - ISC
8996
- *
8997
- * This source code is licensed under the ISC license.
8998
- * See the LICENSE file in the root directory of this source tree.
8999
- *)
9000
-
9001
8960
  lucide-react/dist/esm/icons/search.js:
9002
- (**
9003
- * @license lucide-react v0.468.0 - ISC
9004
- *
9005
- * This source code is licensed under the ISC license.
9006
- * See the LICENSE file in the root directory of this source tree.
9007
- *)
9008
-
9009
8961
  lucide-react/dist/esm/icons/sliders-horizontal.js:
9010
- (**
9011
- * @license lucide-react v0.468.0 - ISC
9012
- *
9013
- * This source code is licensed under the ISC license.
9014
- * See the LICENSE file in the root directory of this source tree.
9015
- *)
9016
-
9017
8962
  lucide-react/dist/esm/icons/smartphone.js:
9018
- (**
9019
- * @license lucide-react v0.468.0 - ISC
9020
- *
9021
- * This source code is licensed under the ISC license.
9022
- * See the LICENSE file in the root directory of this source tree.
9023
- *)
9024
-
9025
8963
  lucide-react/dist/esm/icons/tablet.js:
9026
- (**
9027
- * @license lucide-react v0.468.0 - ISC
9028
- *
9029
- * This source code is licensed under the ISC license.
9030
- * See the LICENSE file in the root directory of this source tree.
9031
- *)
9032
-
9033
8964
  lucide-react/dist/esm/icons/trash.js:
9034
- (**
9035
- * @license lucide-react v0.468.0 - ISC
9036
- *
9037
- * This source code is licensed under the ISC license.
9038
- * See the LICENSE file in the root directory of this source tree.
9039
- *)
9040
-
9041
8965
  lucide-react/dist/esm/icons/type.js:
9042
- (**
9043
- * @license lucide-react v0.468.0 - ISC
9044
- *
9045
- * This source code is licensed under the ISC license.
9046
- * See the LICENSE file in the root directory of this source tree.
9047
- *)
9048
-
9049
8966
  lucide-react/dist/esm/icons/undo-2.js:
9050
- (**
9051
- * @license lucide-react v0.468.0 - ISC
9052
- *
9053
- * This source code is licensed under the ISC license.
9054
- * See the LICENSE file in the root directory of this source tree.
9055
- *)
9056
-
9057
8967
  lucide-react/dist/esm/icons/zoom-in.js:
9058
- (**
9059
- * @license lucide-react v0.468.0 - ISC
9060
- *
9061
- * This source code is licensed under the ISC license.
9062
- * See the LICENSE file in the root directory of this source tree.
9063
- *)
9064
-
9065
8968
  lucide-react/dist/esm/icons/zoom-out.js:
9066
- (**
9067
- * @license lucide-react v0.468.0 - ISC
9068
- *
9069
- * This source code is licensed under the ISC license.
9070
- * See the LICENSE file in the root directory of this source tree.
9071
- *)
9072
-
9073
8969
  lucide-react/dist/esm/lucide-react.js:
9074
8970
  (**
9075
8971
  * @license lucide-react v0.468.0 - ISC