@measured/puck 0.21.0-canary.20aafb6a → 0.21.0-canary.29ef7131

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.
@@ -681,19 +681,19 @@ init_react_import();
681
681
 
682
682
  // lib/get-changed.ts
683
683
  init_react_import();
684
- import fdeq from "fast-deep-equal";
684
+ import { deepEqual } from "fast-equals";
685
685
  var getChanged = (newItem, oldItem) => {
686
686
  return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
687
687
  const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
688
688
  const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
689
689
  return __spreadProps(__spreadValues({}, acc), {
690
- [item]: !fdeq(oldItemProps[item], newItemProps[item])
690
+ [item]: !deepEqual(oldItemProps[item], newItemProps[item])
691
691
  });
692
692
  }, {}) : {};
693
693
  };
694
694
 
695
695
  // lib/resolve-component-data.ts
696
- import fdeq2 from "fast-deep-equal";
696
+ import { deepEqual as deepEqual2 } from "fast-equals";
697
697
  var cache = { lastChange: {} };
698
698
  var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
699
699
  const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
@@ -702,7 +702,7 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
702
702
  const id = "id" in item.props ? item.props.id : "root";
703
703
  if (shouldRunResolver) {
704
704
  const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
705
- if (trigger !== "force" && item && fdeq2(item, oldItem)) {
705
+ if (trigger !== "force" && item && deepEqual2(item, oldItem)) {
706
706
  return { node: resolved, didChange: false };
707
707
  }
708
708
  const changed = getChanged(item, oldItem);
@@ -752,7 +752,7 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
752
752
  };
753
753
  return {
754
754
  node: itemWithResolvedChildren,
755
- didChange: !fdeq2(item, itemWithResolvedChildren)
755
+ didChange: !deepEqual2(item, itemWithResolvedChildren)
756
756
  };
757
757
  });
758
758
 
@@ -958,6 +958,7 @@ export {
958
958
  useSlots,
959
959
  SlotRenderPure,
960
960
  SlotRender,
961
+ toComponent,
961
962
  migrate,
962
963
  transformProps,
963
964
  resolveAllData
@@ -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-VBJEDLUM.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 = () => {
@@ -1021,7 +1063,7 @@ var flattenData = (state, config) => {
1021
1063
  (content) => content,
1022
1064
  (item) => {
1023
1065
  data.push(item);
1024
- return null;
1066
+ return item;
1025
1067
  }
1026
1068
  );
1027
1069
  return data;
@@ -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);
@@ -3150,11 +3195,18 @@ var ExternalInput = ({
3150
3195
  (query, filters2) => __async(void 0, 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: [
@@ -4128,12 +4181,14 @@ var DraggableComponent = ({
4128
4181
  }
4129
4182
  return cleanup;
4130
4183
  }, [permissions.drag, zoneCompound]);
4184
+ const [, setRerender] = useState10(0);
4131
4185
  const ref = useRef2(null);
4132
4186
  const refSetter = useCallback7(
4133
4187
  (el) => {
4134
4188
  sortableRef(el);
4135
- if (el) {
4189
+ if (ref.current !== el) {
4136
4190
  ref.current = el;
4191
+ setRerender((update) => update + 1);
4137
4192
  }
4138
4193
  },
4139
4194
  [sortableRef]
@@ -5638,26 +5693,26 @@ var registerOverlayPortal = (el, opts = {}) => {
5638
5693
  capture: true
5639
5694
  });
5640
5695
  };
5641
- if (disableDragOnFocus) {
5642
- el.addEventListener("focus", onFocus, { capture: true });
5643
- el.addEventListener("blur", onBlur, { capture: true });
5644
- } else if (disableDrag) {
5696
+ if (disableDrag) {
5645
5697
  el.addEventListener("pointerdown", stopPropagation, {
5646
5698
  capture: true
5647
5699
  });
5700
+ } else if (disableDragOnFocus) {
5701
+ el.addEventListener("focus", onFocus, { capture: true });
5702
+ el.addEventListener("blur", onBlur, { capture: true });
5648
5703
  }
5649
5704
  el.setAttribute("data-puck-overlay-portal", "true");
5650
5705
  return () => {
5651
5706
  el.removeEventListener("mouseover", stopPropagation, {
5652
5707
  capture: true
5653
5708
  });
5654
- if (disableDragOnFocus) {
5655
- el.removeEventListener("focus", onFocus, { capture: true });
5656
- el.removeEventListener("blur", onFocus, { capture: true });
5657
- } else if (disableDrag) {
5709
+ if (disableDrag) {
5658
5710
  el.removeEventListener("pointerdown", stopPropagation, {
5659
5711
  capture: true
5660
5712
  });
5713
+ } else if (disableDragOnFocus) {
5714
+ el.removeEventListener("focus", onFocus, { capture: true });
5715
+ el.removeEventListener("blur", onBlur, { capture: true });
5661
5716
  }
5662
5717
  el.removeAttribute("data-puck-overlay-portal");
5663
5718
  };
@@ -5665,7 +5720,7 @@ var registerOverlayPortal = (el, opts = {}) => {
5665
5720
 
5666
5721
  // css-module:/home/runner/work/puck/puck/packages/core/components/InlineTextField/styles.module.css#css-module
5667
5722
  init_react_import();
5668
- var styles_module_default13 = { "InlineTextField": "_InlineTextField_1xph6_1" };
5723
+ var styles_module_default13 = { "InlineTextField": "_InlineTextField_104qp_1" };
5669
5724
 
5670
5725
  // lib/data/set-deep.ts
5671
5726
  init_react_import();
@@ -8047,7 +8102,7 @@ var useDeleteHotkeys = () => {
8047
8102
  };
8048
8103
 
8049
8104
  // components/Puck/index.tsx
8050
- import fdeq from "fast-deep-equal";
8105
+ var import_fast_deep_equal = __toESM(require_fast_deep_equal());
8051
8106
 
8052
8107
  // components/Puck/components/Header/index.tsx
8053
8108
  init_react_import();
@@ -8551,9 +8606,13 @@ function PuckProvider({ children }) {
8551
8606
  }
8552
8607
  const rootProps = ((_h = initialData == null ? void 0 : initialData.root) == null ? void 0 : _h.props) || (initialData == null ? void 0 : initialData.root) || {};
8553
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
+ );
8554
8613
  const newAppState = __spreadProps(__spreadValues({}, defaultAppState), {
8555
8614
  data: __spreadProps(__spreadValues({}, initialData), {
8556
- root: __spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: defaultedRootProps }),
8615
+ root: __spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: root.props }),
8557
8616
  content: initialData.content || []
8558
8617
  }),
8559
8618
  ui: __spreadProps(__spreadValues(__spreadValues({}, initial), clientUiState), {
@@ -8649,17 +8708,17 @@ function PuckProvider({ children }) {
8649
8708
  });
8650
8709
  const previousData = useRef12(null);
8651
8710
  useEffect29(() => {
8652
- appStore.subscribe(
8711
+ return appStore.subscribe(
8653
8712
  (s) => s.state.data,
8654
8713
  (data) => {
8655
8714
  if (onChange) {
8656
- if (fdeq(data, previousData.current)) return;
8715
+ if ((0, import_fast_deep_equal.default)(data, previousData.current)) return;
8657
8716
  onChange(data);
8658
8717
  previousData.current = data;
8659
8718
  }
8660
8719
  }
8661
8720
  );
8662
- }, []);
8721
+ }, [onChange]);
8663
8722
  useRegisterPermissionsSlice(appStore, permissions);
8664
8723
  const uPuckStore = useRegisterUsePuckStore(appStore);
8665
8724
  useEffect29(() => {
package/dist/index.css CHANGED
@@ -1331,16 +1331,17 @@ body:has(._DropZone--isAnimating_1i2sv_68:empty) [data-puck-overlay] {
1331
1331
  }
1332
1332
 
1333
1333
  /* css-module:/home/runner/work/puck/puck/packages/core/components/InlineTextField/styles.module.css/#css-module-data */
1334
- ._InlineTextField_1xph6_1 {
1334
+ ._InlineTextField_104qp_1 {
1335
1335
  cursor: text;
1336
1336
  display: inline-block;
1337
1337
  white-space: pre-wrap;
1338
+ text-decoration: inherit;
1338
1339
  }
1339
- [data-dnd-dragging] ._InlineTextField_1xph6_1 {
1340
+ [data-dnd-dragging] ._InlineTextField_104qp_1 {
1340
1341
  cursor: none;
1341
1342
  caret-color: transparent;
1342
1343
  }
1343
- [data-dnd-dragging] ._InlineTextField_1xph6_1::selection {
1344
+ [data-dnd-dragging] ._InlineTextField_104qp_1::selection {
1344
1345
  display: none;
1345
1346
  }
1346
1347
 
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { H as History, P as Permissions, a as ComponentData, C as Config, U as UserGenerics, F as Fields, b as PuckAction, R as RootDataWithProps, c as ResolveDataTrigger, d as Plugin, O as Overrides, V as Viewports, I as IframeConfig, e as UiState, f as ComponentConfig, A as AppState, M as Metadata, g as FieldTransforms, h as Field, i as FieldProps, D as DropZoneProps, j as Data, k as OnAction, l as InitialHistory, n as ItemSelector } from './walk-tree-Ctf3FZQI.mjs';
2
- export { a7 as Adaptor, a5 as ArrayField, B as ArrayState, ak as AsFieldProps, N as BaseData, $ as BaseField, Z as ComponentDataMap, X as ComponentDataOptionalId, _ as Content, ab as CustomField, aa as CustomFieldRender, ah as DefaultComponentProps, K as DefaultComponents, ae as DefaultRootFieldProps, ag as DefaultRootProps, af as DefaultRootRenderProps, o as Direction, p as DragAxis, a9 as ExternalField, a8 as ExternalFieldWithAdaptor, L as ExtractConfigParams, am as ExtractField, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, z as ItemWithId, Y as MappedItem, a1 as NumberField, a6 as ObjectField, x as OverrideKey, G as PuckComponent, ad as PuckContext, a4 as RadioField, J as RootConfig, T as RootData, Q as RootDataWithoutProps, a3 as SelectField, S as Slot, E as SlotComponent, ac as SlotField, a0 as TextField, a2 as TextareaField, q as Viewport, al as WithChildren, ai as WithId, aj as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-Ctf3FZQI.mjs';
1
+ import { H as History, P as Permissions, a as ComponentData, C as Config, U as UserGenerics, F as Fields, b as PuckAction, R as RootDataWithProps, c as ResolveDataTrigger, d as Plugin, O as Overrides, V as Viewports, I as IframeConfig, e as UiState, f as ComponentConfig, A as AppState, M as Metadata, g as FieldTransforms, h as Field, i as FieldProps, D as DropZoneProps, j as Data, k as OnAction, l as InitialHistory, n as ItemSelector } from './walk-tree-7SvCIsj8.mjs';
2
+ export { a7 as Adaptor, a5 as ArrayField, B as ArrayState, al as AsFieldProps, N as BaseData, $ as BaseField, a9 as CacheOpts, Z as ComponentDataMap, X as ComponentDataOptionalId, _ as Content, ac as CustomField, ab as CustomFieldRender, ai as DefaultComponentProps, K as DefaultComponents, af as DefaultRootFieldProps, ah as DefaultRootProps, ag as DefaultRootRenderProps, o as Direction, p as DragAxis, aa as ExternalField, a8 as ExternalFieldWithAdaptor, L as ExtractConfigParams, an as ExtractField, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, z as ItemWithId, Y as MappedItem, a1 as NumberField, a6 as ObjectField, x as OverrideKey, G as PuckComponent, ae as PuckContext, a4 as RadioField, J as RootConfig, T as RootData, Q as RootDataWithoutProps, a3 as SelectField, S as Slot, E as SlotComponent, ad as SlotField, a0 as TextField, a2 as TextareaField, q as Viewport, am as WithChildren, aj as WithId, ak as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-7SvCIsj8.mjs';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as react from 'react';
5
5
  import react__default, { ReactNode, SyntheticEvent, ReactElement } from 'react';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { H as History, P as Permissions, a as ComponentData, C as Config, U as UserGenerics, F as Fields, b as PuckAction, R as RootDataWithProps, c as ResolveDataTrigger, d as Plugin, O as Overrides, V as Viewports, I as IframeConfig, e as UiState, f as ComponentConfig, A as AppState, M as Metadata, g as FieldTransforms, h as Field, i as FieldProps, D as DropZoneProps, j as Data, k as OnAction, l as InitialHistory, n as ItemSelector } from './walk-tree-Ctf3FZQI.js';
2
- export { a7 as Adaptor, a5 as ArrayField, B as ArrayState, ak as AsFieldProps, N as BaseData, $ as BaseField, Z as ComponentDataMap, X as ComponentDataOptionalId, _ as Content, ab as CustomField, aa as CustomFieldRender, ah as DefaultComponentProps, K as DefaultComponents, ae as DefaultRootFieldProps, ag as DefaultRootProps, af as DefaultRootRenderProps, o as Direction, p as DragAxis, a9 as ExternalField, a8 as ExternalFieldWithAdaptor, L as ExtractConfigParams, am as ExtractField, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, z as ItemWithId, Y as MappedItem, a1 as NumberField, a6 as ObjectField, x as OverrideKey, G as PuckComponent, ad as PuckContext, a4 as RadioField, J as RootConfig, T as RootData, Q as RootDataWithoutProps, a3 as SelectField, S as Slot, E as SlotComponent, ac as SlotField, a0 as TextField, a2 as TextareaField, q as Viewport, al as WithChildren, ai as WithId, aj as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-Ctf3FZQI.js';
1
+ import { H as History, P as Permissions, a as ComponentData, C as Config, U as UserGenerics, F as Fields, b as PuckAction, R as RootDataWithProps, c as ResolveDataTrigger, d as Plugin, O as Overrides, V as Viewports, I as IframeConfig, e as UiState, f as ComponentConfig, A as AppState, M as Metadata, g as FieldTransforms, h as Field, i as FieldProps, D as DropZoneProps, j as Data, k as OnAction, l as InitialHistory, n as ItemSelector } from './walk-tree-7SvCIsj8.js';
2
+ export { a7 as Adaptor, a5 as ArrayField, B as ArrayState, al as AsFieldProps, N as BaseData, $ as BaseField, a9 as CacheOpts, Z as ComponentDataMap, X as ComponentDataOptionalId, _ as Content, ac as CustomField, ab as CustomFieldRender, ai as DefaultComponentProps, K as DefaultComponents, af as DefaultRootFieldProps, ah as DefaultRootProps, ag as DefaultRootRenderProps, o as Direction, p as DragAxis, aa as ExternalField, a8 as ExternalFieldWithAdaptor, L as ExtractConfigParams, an as ExtractField, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, z as ItemWithId, Y as MappedItem, a1 as NumberField, a6 as ObjectField, x as OverrideKey, G as PuckComponent, ae as PuckContext, a4 as RadioField, J as RootConfig, T as RootData, Q as RootDataWithoutProps, a3 as SelectField, S as Slot, E as SlotComponent, ad as SlotField, a0 as TextField, a2 as TextareaField, q as Viewport, am as WithChildren, aj as WithId, ak as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-7SvCIsj8.js';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as react from 'react';
5
5
  import react__default, { ReactNode, SyntheticEvent, ReactElement } from 'react';
package/dist/index.js CHANGED
@@ -153,6 +153,42 @@ var require_classnames = __commonJS({
153
153
  }
154
154
  });
155
155
 
156
+ // ../../node_modules/fast-deep-equal/index.js
157
+ var require_fast_deep_equal = __commonJS({
158
+ "../../node_modules/fast-deep-equal/index.js"(exports2, module2) {
159
+ "use strict";
160
+ init_react_import();
161
+ module2.exports = function equal(a, b) {
162
+ if (a === b) return true;
163
+ if (a && b && typeof a == "object" && typeof b == "object") {
164
+ if (a.constructor !== b.constructor) return false;
165
+ var length, i, keys;
166
+ if (Array.isArray(a)) {
167
+ length = a.length;
168
+ if (length != b.length) return false;
169
+ for (i = length; i-- !== 0; )
170
+ if (!equal(a[i], b[i])) return false;
171
+ return true;
172
+ }
173
+ if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
174
+ if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
175
+ if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
176
+ keys = Object.keys(a);
177
+ length = keys.length;
178
+ if (length !== Object.keys(b).length) return false;
179
+ for (i = length; i-- !== 0; )
180
+ if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
181
+ for (i = length; i-- !== 0; ) {
182
+ var key = keys[i];
183
+ if (!equal(a[key], b[key])) return false;
184
+ }
185
+ return true;
186
+ }
187
+ return a !== a && b !== b;
188
+ };
189
+ }
190
+ });
191
+
156
192
  // bundle/index.ts
157
193
  var bundle_exports = {};
158
194
  __export(bundle_exports, {
@@ -1713,6 +1749,10 @@ var monitorHotkeys = (doc) => {
1713
1749
  useHotkeyStore.getState().reset();
1714
1750
  }
1715
1751
  };
1752
+ const onBlur = () => {
1753
+ useHotkeyStore.getState().reset();
1754
+ };
1755
+ window.addEventListener("blur", onBlur);
1716
1756
  doc.addEventListener("keydown", onKeyDown);
1717
1757
  doc.addEventListener("keyup", onKeyUp);
1718
1758
  doc.addEventListener("visibilitychange", onVisibilityChanged);
@@ -1720,6 +1760,7 @@ var monitorHotkeys = (doc) => {
1720
1760
  doc.removeEventListener("keydown", onKeyDown);
1721
1761
  doc.removeEventListener("keyup", onKeyUp);
1722
1762
  doc.removeEventListener("visibilitychange", onVisibilityChanged);
1763
+ window.removeEventListener("blur", onBlur);
1723
1764
  };
1724
1765
  };
1725
1766
  var useMonitorHotkeys = () => {
@@ -1914,7 +1955,7 @@ var flattenData = (state, config) => {
1914
1955
  (content) => content,
1915
1956
  (item) => {
1916
1957
  data.push(item);
1917
- return null;
1958
+ return item;
1918
1959
  }
1919
1960
  );
1920
1961
  return data;
@@ -1922,13 +1963,13 @@ var flattenData = (state, config) => {
1922
1963
 
1923
1964
  // lib/get-changed.ts
1924
1965
  init_react_import();
1925
- var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
1966
+ var import_fast_equals = require("fast-equals");
1926
1967
  var getChanged = (newItem, oldItem) => {
1927
1968
  return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
1928
1969
  const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
1929
1970
  const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
1930
1971
  return __spreadProps(__spreadValues({}, acc), {
1931
- [item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
1972
+ [item]: !(0, import_fast_equals.deepEqual)(oldItemProps[item], newItemProps[item])
1932
1973
  });
1933
1974
  }, {}) : {};
1934
1975
  };
@@ -2149,7 +2190,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
2149
2190
 
2150
2191
  // lib/resolve-component-data.ts
2151
2192
  init_react_import();
2152
- var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
2193
+ var import_fast_equals2 = require("fast-equals");
2153
2194
  var cache = { lastChange: {} };
2154
2195
  var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
2155
2196
  const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
@@ -2158,7 +2199,7 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
2158
2199
  const id = "id" in item.props ? item.props.id : "root";
2159
2200
  if (shouldRunResolver) {
2160
2201
  const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
2161
- if (trigger !== "force" && item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
2202
+ if (trigger !== "force" && item && (0, import_fast_equals2.deepEqual)(item, oldItem)) {
2162
2203
  return { node: resolved, didChange: false };
2163
2204
  }
2164
2205
  const changed = getChanged(item, oldItem);
@@ -2208,7 +2249,7 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
2208
2249
  };
2209
2250
  return {
2210
2251
  node: itemWithResolvedChildren,
2211
- didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
2252
+ didChange: !(0, import_fast_equals2.deepEqual)(item, itemWithResolvedChildren)
2212
2253
  };
2213
2254
  });
2214
2255
 
@@ -3494,8 +3535,9 @@ var ArrayField = ({
3494
3535
  var _a;
3495
3536
  if (isDraggingAny) return;
3496
3537
  const existingValue = value || [];
3538
+ const defaultProps = typeof field.defaultItemProps === "function" ? field.defaultItemProps(existingValue.length) : (_a = field.defaultItemProps) != null ? _a : {};
3497
3539
  const newItem = defaultSlots(
3498
- uniqifyItem((_a = field.defaultItemProps) != null ? _a : {}),
3540
+ uniqifyItem(defaultProps),
3499
3541
  field.arrayFields
3500
3542
  );
3501
3543
  const newValue = [...existingValue, newItem];
@@ -3754,11 +3796,13 @@ var ExternalInput = ({
3754
3796
  id,
3755
3797
  readOnly
3756
3798
  }) => {
3799
+ var _a;
3757
3800
  const {
3758
3801
  mapProp = (val) => val,
3759
3802
  mapRow = (val) => val,
3760
3803
  filterFields
3761
3804
  } = field || {};
3805
+ const { enabled: shouldCacheData } = (_a = field.cache) != null ? _a : { enabled: true };
3762
3806
  const [data, setData] = (0, import_react17.useState)([]);
3763
3807
  const [isOpen, setOpen] = (0, import_react17.useState)(false);
3764
3808
  const [isLoading, setIsLoading] = (0, import_react17.useState)(true);
@@ -3784,11 +3828,18 @@ var ExternalInput = ({
3784
3828
  (query, filters2) => __async(void 0, null, function* () {
3785
3829
  setIsLoading(true);
3786
3830
  const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
3787
- 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
+ }
3788
3837
  if (listData) {
3789
3838
  setData(listData);
3790
3839
  setIsLoading(false);
3791
- dataCache[cacheKey] = listData;
3840
+ if (shouldCacheData) {
3841
+ dataCache[cacheKey] = listData;
3842
+ }
3792
3843
  }
3793
3844
  }),
3794
3845
  [id, field]
@@ -3852,6 +3903,7 @@ var ExternalInput = ({
3852
3903
  }),
3853
3904
  onSubmit: (e) => {
3854
3905
  e.preventDefault();
3906
+ e.stopPropagation();
3855
3907
  search(searchQuery, filters);
3856
3908
  },
3857
3909
  children: [
@@ -4755,12 +4807,14 @@ var DraggableComponent = ({
4755
4807
  }
4756
4808
  return cleanup;
4757
4809
  }, [permissions.drag, zoneCompound]);
4810
+ const [, setRerender] = (0, import_react24.useState)(0);
4758
4811
  const ref = (0, import_react24.useRef)(null);
4759
4812
  const refSetter = (0, import_react24.useCallback)(
4760
4813
  (el) => {
4761
4814
  sortableRef(el);
4762
- if (el) {
4815
+ if (ref.current !== el) {
4763
4816
  ref.current = el;
4817
+ setRerender((update) => update + 1);
4764
4818
  }
4765
4819
  },
4766
4820
  [sortableRef]
@@ -5535,26 +5589,26 @@ var registerOverlayPortal = (el, opts = {}) => {
5535
5589
  capture: true
5536
5590
  });
5537
5591
  };
5538
- if (disableDragOnFocus) {
5539
- el.addEventListener("focus", onFocus, { capture: true });
5540
- el.addEventListener("blur", onBlur, { capture: true });
5541
- } else if (disableDrag) {
5592
+ if (disableDrag) {
5542
5593
  el.addEventListener("pointerdown", stopPropagation, {
5543
5594
  capture: true
5544
5595
  });
5596
+ } else if (disableDragOnFocus) {
5597
+ el.addEventListener("focus", onFocus, { capture: true });
5598
+ el.addEventListener("blur", onBlur, { capture: true });
5545
5599
  }
5546
5600
  el.setAttribute("data-puck-overlay-portal", "true");
5547
5601
  return () => {
5548
5602
  el.removeEventListener("mouseover", stopPropagation, {
5549
5603
  capture: true
5550
5604
  });
5551
- if (disableDragOnFocus) {
5552
- el.removeEventListener("focus", onFocus, { capture: true });
5553
- el.removeEventListener("blur", onFocus, { capture: true });
5554
- } else if (disableDrag) {
5605
+ if (disableDrag) {
5555
5606
  el.removeEventListener("pointerdown", stopPropagation, {
5556
5607
  capture: true
5557
5608
  });
5609
+ } else if (disableDragOnFocus) {
5610
+ el.removeEventListener("focus", onFocus, { capture: true });
5611
+ el.removeEventListener("blur", onBlur, { capture: true });
5558
5612
  }
5559
5613
  el.removeAttribute("data-puck-overlay-portal");
5560
5614
  };
@@ -5562,7 +5616,7 @@ var registerOverlayPortal = (el, opts = {}) => {
5562
5616
 
5563
5617
  // css-module:/home/runner/work/puck/puck/packages/core/components/InlineTextField/styles.module.css#css-module
5564
5618
  init_react_import();
5565
- var styles_module_default13 = { "InlineTextField": "_InlineTextField_1xph6_1" };
5619
+ var styles_module_default13 = { "InlineTextField": "_InlineTextField_104qp_1" };
5566
5620
 
5567
5621
  // lib/data/set-deep.ts
5568
5622
  init_react_import();
@@ -8739,7 +8793,7 @@ function useGetPuck() {
8739
8793
  }
8740
8794
 
8741
8795
  // components/Puck/index.tsx
8742
- var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
8796
+ var import_fast_deep_equal = __toESM(require_fast_deep_equal());
8743
8797
 
8744
8798
  // components/Puck/components/Header/index.tsx
8745
8799
  init_react_import();
@@ -9167,6 +9221,15 @@ function useSidebarResize(position, dispatch) {
9167
9221
  };
9168
9222
  }
9169
9223
 
9224
+ // lib/data/to-component.ts
9225
+ init_react_import();
9226
+ var toComponent = (item) => {
9227
+ return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
9228
+ props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
9229
+ type: "root"
9230
+ });
9231
+ };
9232
+
9170
9233
  // components/Puck/index.tsx
9171
9234
  var import_jsx_runtime46 = require("react/jsx-runtime");
9172
9235
  var getClassName31 = get_class_name_factory_default("Puck", styles_module_default15);
@@ -9243,9 +9306,13 @@ function PuckProvider({ children }) {
9243
9306
  }
9244
9307
  const rootProps = ((_h = initialData == null ? void 0 : initialData.root) == null ? void 0 : _h.props) || (initialData == null ? void 0 : initialData.root) || {};
9245
9308
  const defaultedRootProps = __spreadValues(__spreadValues({}, (_i = config.root) == null ? void 0 : _i.defaultProps), rootProps);
9309
+ const root = populateIds(
9310
+ toComponent(__spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: defaultedRootProps })),
9311
+ config
9312
+ );
9246
9313
  const newAppState = __spreadProps(__spreadValues({}, defaultAppState), {
9247
9314
  data: __spreadProps(__spreadValues({}, initialData), {
9248
- root: __spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: defaultedRootProps }),
9315
+ root: __spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: root.props }),
9249
9316
  content: initialData.content || []
9250
9317
  }),
9251
9318
  ui: __spreadProps(__spreadValues(__spreadValues({}, initial), clientUiState), {
@@ -9341,17 +9408,17 @@ function PuckProvider({ children }) {
9341
9408
  });
9342
9409
  const previousData = (0, import_react60.useRef)(null);
9343
9410
  (0, import_react60.useEffect)(() => {
9344
- appStore.subscribe(
9411
+ return appStore.subscribe(
9345
9412
  (s) => s.state.data,
9346
9413
  (data) => {
9347
9414
  if (onChange) {
9348
- if ((0, import_fast_deep_equal3.default)(data, previousData.current)) return;
9415
+ if ((0, import_fast_deep_equal.default)(data, previousData.current)) return;
9349
9416
  onChange(data);
9350
9417
  previousData.current = data;
9351
9418
  }
9352
9419
  }
9353
9420
  );
9354
- }, []);
9421
+ }, [onChange]);
9355
9422
  useRegisterPermissionsSlice(appStore, permissions);
9356
9423
  const uPuckStore = useRegisterUsePuckStore(appStore);
9357
9424
  (0, import_react60.useEffect)(() => {
@@ -9664,17 +9731,6 @@ function transformProps(data, propTransforms, config = { components: {} }) {
9664
9731
 
9665
9732
  // lib/resolve-all-data.ts
9666
9733
  init_react_import();
9667
-
9668
- // lib/data/to-component.ts
9669
- init_react_import();
9670
- var toComponent = (item) => {
9671
- return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
9672
- props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
9673
- type: "root"
9674
- });
9675
- };
9676
-
9677
- // lib/resolve-all-data.ts
9678
9734
  function resolveAllData(_0, _1) {
9679
9735
  return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
9680
9736
  var _a;
package/dist/index.mjs CHANGED
@@ -18,14 +18,14 @@ import {
18
18
  setDeep,
19
19
  useGetPuck,
20
20
  usePuck
21
- } from "./chunk-MSKEXIWC.mjs";
21
+ } from "./chunk-YRZRLNQC.mjs";
22
22
  import {
23
23
  init_react_import,
24
24
  migrate,
25
25
  resolveAllData,
26
26
  transformProps,
27
27
  walkTree
28
- } from "./chunk-OOLYDXKW.mjs";
28
+ } from "./chunk-VBJEDLUM.mjs";
29
29
 
30
30
  // bundle/index.ts
31
31
  init_react_import();
@@ -1329,16 +1329,17 @@ body:has(._DropZone--isAnimating_1i2sv_68:empty) [data-puck-overlay] {
1329
1329
  }
1330
1330
 
1331
1331
  /* css-module:/home/runner/work/puck/puck/packages/core/components/InlineTextField/styles.module.css/#css-module-data */
1332
- ._InlineTextField_1xph6_1 {
1332
+ ._InlineTextField_104qp_1 {
1333
1333
  cursor: text;
1334
1334
  display: inline-block;
1335
1335
  white-space: pre-wrap;
1336
+ text-decoration: inherit;
1336
1337
  }
1337
- [data-dnd-dragging] ._InlineTextField_1xph6_1 {
1338
+ [data-dnd-dragging] ._InlineTextField_104qp_1 {
1338
1339
  cursor: none;
1339
1340
  caret-color: transparent;
1340
1341
  }
1341
- [data-dnd-dragging] ._InlineTextField_1xph6_1::selection {
1342
+ [data-dnd-dragging] ._InlineTextField_104qp_1::selection {
1342
1343
  display: none;
1343
1344
  }
1344
1345
 
@@ -1,4 +1,4 @@
1
- export { a7 as Adaptor, A as AppState, a5 as ArrayField, B as ArrayState, ak as AsFieldProps, N as BaseData, $ as BaseField, f as ComponentConfig, a as ComponentData, Z as ComponentDataMap, X as ComponentDataOptionalId, C as Config, _ as Content, ab as CustomField, aa as CustomFieldRender, j as Data, ah as DefaultComponentProps, K as DefaultComponents, ae as DefaultRootFieldProps, ag as DefaultRootProps, af as DefaultRootRenderProps, o as Direction, p as DragAxis, a9 as ExternalField, a8 as ExternalFieldWithAdaptor, L as ExtractConfigParams, am as ExtractField, h as Field, i as FieldProps, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, g as FieldTransforms, F as Fields, H as History, I as IframeConfig, l as InitialHistory, z as ItemWithId, Y as MappedItem, M as Metadata, a1 as NumberField, a6 as ObjectField, k as OnAction, x as OverrideKey, O as Overrides, P as Permissions, d as Plugin, b as PuckAction, G as PuckComponent, ad as PuckContext, a4 as RadioField, c as ResolveDataTrigger, J as RootConfig, T as RootData, R as RootDataWithProps, Q as RootDataWithoutProps, a3 as SelectField, S as Slot, E as SlotComponent, ac as SlotField, a0 as TextField, a2 as TextareaField, e as UiState, U as UserGenerics, q as Viewport, V as Viewports, al as WithChildren, ai as WithId, aj as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-Ctf3FZQI.mjs';
1
+ export { a7 as Adaptor, A as AppState, a5 as ArrayField, B as ArrayState, al as AsFieldProps, N as BaseData, $ as BaseField, a9 as CacheOpts, f as ComponentConfig, a as ComponentData, Z as ComponentDataMap, X as ComponentDataOptionalId, C as Config, _ as Content, ac as CustomField, ab as CustomFieldRender, j as Data, ai as DefaultComponentProps, K as DefaultComponents, af as DefaultRootFieldProps, ah as DefaultRootProps, ag as DefaultRootRenderProps, o as Direction, p as DragAxis, aa as ExternalField, a8 as ExternalFieldWithAdaptor, L as ExtractConfigParams, an as ExtractField, h as Field, i as FieldProps, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, g as FieldTransforms, F as Fields, H as History, I as IframeConfig, l as InitialHistory, z as ItemWithId, Y as MappedItem, M as Metadata, a1 as NumberField, a6 as ObjectField, k as OnAction, x as OverrideKey, O as Overrides, P as Permissions, d as Plugin, b as PuckAction, G as PuckComponent, ae as PuckContext, a4 as RadioField, c as ResolveDataTrigger, J as RootConfig, T as RootData, R as RootDataWithProps, Q as RootDataWithoutProps, a3 as SelectField, S as Slot, E as SlotComponent, ad as SlotField, a0 as TextField, a2 as TextareaField, e as UiState, U as UserGenerics, q as Viewport, V as Viewports, am as WithChildren, aj as WithId, ak as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-7SvCIsj8.mjs';
2
2
  export { Action, ActionBar, AutoField, Button, Drawer, DropZone, FieldLabel, Group, IconButton, Label, Puck, PuckApi, Render, UsePuckData, createUsePuck, registerOverlayPortal, renderContext, setDeep, useGetPuck, usePuck } from './index.mjs';
3
3
  import 'react';
4
4
  import 'react/jsx-runtime';
@@ -1,4 +1,4 @@
1
- export { a7 as Adaptor, A as AppState, a5 as ArrayField, B as ArrayState, ak as AsFieldProps, N as BaseData, $ as BaseField, f as ComponentConfig, a as ComponentData, Z as ComponentDataMap, X as ComponentDataOptionalId, C as Config, _ as Content, ab as CustomField, aa as CustomFieldRender, j as Data, ah as DefaultComponentProps, K as DefaultComponents, ae as DefaultRootFieldProps, ag as DefaultRootProps, af as DefaultRootRenderProps, o as Direction, p as DragAxis, a9 as ExternalField, a8 as ExternalFieldWithAdaptor, L as ExtractConfigParams, am as ExtractField, h as Field, i as FieldProps, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, g as FieldTransforms, F as Fields, H as History, I as IframeConfig, l as InitialHistory, z as ItemWithId, Y as MappedItem, M as Metadata, a1 as NumberField, a6 as ObjectField, k as OnAction, x as OverrideKey, O as Overrides, P as Permissions, d as Plugin, b as PuckAction, G as PuckComponent, ad as PuckContext, a4 as RadioField, c as ResolveDataTrigger, J as RootConfig, T as RootData, R as RootDataWithProps, Q as RootDataWithoutProps, a3 as SelectField, S as Slot, E as SlotComponent, ac as SlotField, a0 as TextField, a2 as TextareaField, e as UiState, U as UserGenerics, q as Viewport, V as Viewports, al as WithChildren, ai as WithId, aj as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-Ctf3FZQI.js';
1
+ export { a7 as Adaptor, A as AppState, a5 as ArrayField, B as ArrayState, al as AsFieldProps, N as BaseData, $ as BaseField, a9 as CacheOpts, f as ComponentConfig, a as ComponentData, Z as ComponentDataMap, X as ComponentDataOptionalId, C as Config, _ as Content, ac as CustomField, ab as CustomFieldRender, j as Data, ai as DefaultComponentProps, K as DefaultComponents, af as DefaultRootFieldProps, ah as DefaultRootProps, ag as DefaultRootRenderProps, o as Direction, p as DragAxis, aa as ExternalField, a8 as ExternalFieldWithAdaptor, L as ExtractConfigParams, an as ExtractField, h as Field, i as FieldProps, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, g as FieldTransforms, F as Fields, H as History, I as IframeConfig, l as InitialHistory, z as ItemWithId, Y as MappedItem, M as Metadata, a1 as NumberField, a6 as ObjectField, k as OnAction, x as OverrideKey, O as Overrides, P as Permissions, d as Plugin, b as PuckAction, G as PuckComponent, ae as PuckContext, a4 as RadioField, c as ResolveDataTrigger, J as RootConfig, T as RootData, R as RootDataWithProps, Q as RootDataWithoutProps, a3 as SelectField, S as Slot, E as SlotComponent, ad as SlotField, a0 as TextField, a2 as TextareaField, e as UiState, U as UserGenerics, q as Viewport, V as Viewports, am as WithChildren, aj as WithId, ak as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-7SvCIsj8.js';
2
2
  export { Action, ActionBar, AutoField, Button, Drawer, DropZone, FieldLabel, Group, IconButton, Label, Puck, PuckApi, Render, UsePuckData, createUsePuck, registerOverlayPortal, renderContext, setDeep, useGetPuck, usePuck } from './index.js';
3
3
  import 'react';
4
4
  import 'react/jsx-runtime';
@@ -153,6 +153,42 @@ var require_classnames = __commonJS({
153
153
  }
154
154
  });
155
155
 
156
+ // ../../node_modules/fast-deep-equal/index.js
157
+ var require_fast_deep_equal = __commonJS({
158
+ "../../node_modules/fast-deep-equal/index.js"(exports2, module2) {
159
+ "use strict";
160
+ init_react_import();
161
+ module2.exports = function equal(a, b) {
162
+ if (a === b) return true;
163
+ if (a && b && typeof a == "object" && typeof b == "object") {
164
+ if (a.constructor !== b.constructor) return false;
165
+ var length, i, keys;
166
+ if (Array.isArray(a)) {
167
+ length = a.length;
168
+ if (length != b.length) return false;
169
+ for (i = length; i-- !== 0; )
170
+ if (!equal(a[i], b[i])) return false;
171
+ return true;
172
+ }
173
+ if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
174
+ if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
175
+ if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
176
+ keys = Object.keys(a);
177
+ length = keys.length;
178
+ if (length !== Object.keys(b).length) return false;
179
+ for (i = length; i-- !== 0; )
180
+ if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
181
+ for (i = length; i-- !== 0; ) {
182
+ var key = keys[i];
183
+ if (!equal(a[key], b[key])) return false;
184
+ }
185
+ return true;
186
+ }
187
+ return a !== a && b !== b;
188
+ };
189
+ }
190
+ });
191
+
156
192
  // bundle/no-external.ts
157
193
  var no_external_exports = {};
158
194
  __export(no_external_exports, {
@@ -1713,6 +1749,10 @@ var monitorHotkeys = (doc) => {
1713
1749
  useHotkeyStore.getState().reset();
1714
1750
  }
1715
1751
  };
1752
+ const onBlur = () => {
1753
+ useHotkeyStore.getState().reset();
1754
+ };
1755
+ window.addEventListener("blur", onBlur);
1716
1756
  doc.addEventListener("keydown", onKeyDown);
1717
1757
  doc.addEventListener("keyup", onKeyUp);
1718
1758
  doc.addEventListener("visibilitychange", onVisibilityChanged);
@@ -1720,6 +1760,7 @@ var monitorHotkeys = (doc) => {
1720
1760
  doc.removeEventListener("keydown", onKeyDown);
1721
1761
  doc.removeEventListener("keyup", onKeyUp);
1722
1762
  doc.removeEventListener("visibilitychange", onVisibilityChanged);
1763
+ window.removeEventListener("blur", onBlur);
1723
1764
  };
1724
1765
  };
1725
1766
  var useMonitorHotkeys = () => {
@@ -1914,7 +1955,7 @@ var flattenData = (state, config) => {
1914
1955
  (content) => content,
1915
1956
  (item) => {
1916
1957
  data.push(item);
1917
- return null;
1958
+ return item;
1918
1959
  }
1919
1960
  );
1920
1961
  return data;
@@ -1922,13 +1963,13 @@ var flattenData = (state, config) => {
1922
1963
 
1923
1964
  // lib/get-changed.ts
1924
1965
  init_react_import();
1925
- var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
1966
+ var import_fast_equals = require("fast-equals");
1926
1967
  var getChanged = (newItem, oldItem) => {
1927
1968
  return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
1928
1969
  const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
1929
1970
  const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
1930
1971
  return __spreadProps(__spreadValues({}, acc), {
1931
- [item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
1972
+ [item]: !(0, import_fast_equals.deepEqual)(oldItemProps[item], newItemProps[item])
1932
1973
  });
1933
1974
  }, {}) : {};
1934
1975
  };
@@ -2149,7 +2190,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
2149
2190
 
2150
2191
  // lib/resolve-component-data.ts
2151
2192
  init_react_import();
2152
- var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
2193
+ var import_fast_equals2 = require("fast-equals");
2153
2194
  var cache = { lastChange: {} };
2154
2195
  var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
2155
2196
  const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
@@ -2158,7 +2199,7 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
2158
2199
  const id = "id" in item.props ? item.props.id : "root";
2159
2200
  if (shouldRunResolver) {
2160
2201
  const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
2161
- if (trigger !== "force" && item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
2202
+ if (trigger !== "force" && item && (0, import_fast_equals2.deepEqual)(item, oldItem)) {
2162
2203
  return { node: resolved, didChange: false };
2163
2204
  }
2164
2205
  const changed = getChanged(item, oldItem);
@@ -2208,7 +2249,7 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
2208
2249
  };
2209
2250
  return {
2210
2251
  node: itemWithResolvedChildren,
2211
- didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
2252
+ didChange: !(0, import_fast_equals2.deepEqual)(item, itemWithResolvedChildren)
2212
2253
  };
2213
2254
  });
2214
2255
 
@@ -3494,8 +3535,9 @@ var ArrayField = ({
3494
3535
  var _a;
3495
3536
  if (isDraggingAny) return;
3496
3537
  const existingValue = value || [];
3538
+ const defaultProps = typeof field.defaultItemProps === "function" ? field.defaultItemProps(existingValue.length) : (_a = field.defaultItemProps) != null ? _a : {};
3497
3539
  const newItem = defaultSlots(
3498
- uniqifyItem((_a = field.defaultItemProps) != null ? _a : {}),
3540
+ uniqifyItem(defaultProps),
3499
3541
  field.arrayFields
3500
3542
  );
3501
3543
  const newValue = [...existingValue, newItem];
@@ -3754,11 +3796,13 @@ var ExternalInput = ({
3754
3796
  id,
3755
3797
  readOnly
3756
3798
  }) => {
3799
+ var _a;
3757
3800
  const {
3758
3801
  mapProp = (val) => val,
3759
3802
  mapRow = (val) => val,
3760
3803
  filterFields
3761
3804
  } = field || {};
3805
+ const { enabled: shouldCacheData } = (_a = field.cache) != null ? _a : { enabled: true };
3762
3806
  const [data, setData] = (0, import_react17.useState)([]);
3763
3807
  const [isOpen, setOpen] = (0, import_react17.useState)(false);
3764
3808
  const [isLoading, setIsLoading] = (0, import_react17.useState)(true);
@@ -3784,11 +3828,18 @@ var ExternalInput = ({
3784
3828
  (query, filters2) => __async(void 0, null, function* () {
3785
3829
  setIsLoading(true);
3786
3830
  const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
3787
- 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
+ }
3788
3837
  if (listData) {
3789
3838
  setData(listData);
3790
3839
  setIsLoading(false);
3791
- dataCache[cacheKey] = listData;
3840
+ if (shouldCacheData) {
3841
+ dataCache[cacheKey] = listData;
3842
+ }
3792
3843
  }
3793
3844
  }),
3794
3845
  [id, field]
@@ -3852,6 +3903,7 @@ var ExternalInput = ({
3852
3903
  }),
3853
3904
  onSubmit: (e) => {
3854
3905
  e.preventDefault();
3906
+ e.stopPropagation();
3855
3907
  search(searchQuery, filters);
3856
3908
  },
3857
3909
  children: [
@@ -4755,12 +4807,14 @@ var DraggableComponent = ({
4755
4807
  }
4756
4808
  return cleanup;
4757
4809
  }, [permissions.drag, zoneCompound]);
4810
+ const [, setRerender] = (0, import_react24.useState)(0);
4758
4811
  const ref = (0, import_react24.useRef)(null);
4759
4812
  const refSetter = (0, import_react24.useCallback)(
4760
4813
  (el) => {
4761
4814
  sortableRef(el);
4762
- if (el) {
4815
+ if (ref.current !== el) {
4763
4816
  ref.current = el;
4817
+ setRerender((update) => update + 1);
4764
4818
  }
4765
4819
  },
4766
4820
  [sortableRef]
@@ -5535,26 +5589,26 @@ var registerOverlayPortal = (el, opts = {}) => {
5535
5589
  capture: true
5536
5590
  });
5537
5591
  };
5538
- if (disableDragOnFocus) {
5539
- el.addEventListener("focus", onFocus, { capture: true });
5540
- el.addEventListener("blur", onBlur, { capture: true });
5541
- } else if (disableDrag) {
5592
+ if (disableDrag) {
5542
5593
  el.addEventListener("pointerdown", stopPropagation, {
5543
5594
  capture: true
5544
5595
  });
5596
+ } else if (disableDragOnFocus) {
5597
+ el.addEventListener("focus", onFocus, { capture: true });
5598
+ el.addEventListener("blur", onBlur, { capture: true });
5545
5599
  }
5546
5600
  el.setAttribute("data-puck-overlay-portal", "true");
5547
5601
  return () => {
5548
5602
  el.removeEventListener("mouseover", stopPropagation, {
5549
5603
  capture: true
5550
5604
  });
5551
- if (disableDragOnFocus) {
5552
- el.removeEventListener("focus", onFocus, { capture: true });
5553
- el.removeEventListener("blur", onFocus, { capture: true });
5554
- } else if (disableDrag) {
5605
+ if (disableDrag) {
5555
5606
  el.removeEventListener("pointerdown", stopPropagation, {
5556
5607
  capture: true
5557
5608
  });
5609
+ } else if (disableDragOnFocus) {
5610
+ el.removeEventListener("focus", onFocus, { capture: true });
5611
+ el.removeEventListener("blur", onBlur, { capture: true });
5558
5612
  }
5559
5613
  el.removeAttribute("data-puck-overlay-portal");
5560
5614
  };
@@ -5562,7 +5616,7 @@ var registerOverlayPortal = (el, opts = {}) => {
5562
5616
 
5563
5617
  // css-module:/home/runner/work/puck/puck/packages/core/components/InlineTextField/styles.module.css#css-module
5564
5618
  init_react_import();
5565
- var styles_module_default13 = { "InlineTextField": "_InlineTextField_1xph6_1" };
5619
+ var styles_module_default13 = { "InlineTextField": "_InlineTextField_104qp_1" };
5566
5620
 
5567
5621
  // lib/data/set-deep.ts
5568
5622
  init_react_import();
@@ -8739,7 +8793,7 @@ function useGetPuck() {
8739
8793
  }
8740
8794
 
8741
8795
  // components/Puck/index.tsx
8742
- var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
8796
+ var import_fast_deep_equal = __toESM(require_fast_deep_equal());
8743
8797
 
8744
8798
  // components/Puck/components/Header/index.tsx
8745
8799
  init_react_import();
@@ -9167,6 +9221,15 @@ function useSidebarResize(position, dispatch) {
9167
9221
  };
9168
9222
  }
9169
9223
 
9224
+ // lib/data/to-component.ts
9225
+ init_react_import();
9226
+ var toComponent = (item) => {
9227
+ return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
9228
+ props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
9229
+ type: "root"
9230
+ });
9231
+ };
9232
+
9170
9233
  // components/Puck/index.tsx
9171
9234
  var import_jsx_runtime46 = require("react/jsx-runtime");
9172
9235
  var getClassName31 = get_class_name_factory_default("Puck", styles_module_default15);
@@ -9243,9 +9306,13 @@ function PuckProvider({ children }) {
9243
9306
  }
9244
9307
  const rootProps = ((_h = initialData == null ? void 0 : initialData.root) == null ? void 0 : _h.props) || (initialData == null ? void 0 : initialData.root) || {};
9245
9308
  const defaultedRootProps = __spreadValues(__spreadValues({}, (_i = config.root) == null ? void 0 : _i.defaultProps), rootProps);
9309
+ const root = populateIds(
9310
+ toComponent(__spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: defaultedRootProps })),
9311
+ config
9312
+ );
9246
9313
  const newAppState = __spreadProps(__spreadValues({}, defaultAppState), {
9247
9314
  data: __spreadProps(__spreadValues({}, initialData), {
9248
- root: __spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: defaultedRootProps }),
9315
+ root: __spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: root.props }),
9249
9316
  content: initialData.content || []
9250
9317
  }),
9251
9318
  ui: __spreadProps(__spreadValues(__spreadValues({}, initial), clientUiState), {
@@ -9341,17 +9408,17 @@ function PuckProvider({ children }) {
9341
9408
  });
9342
9409
  const previousData = (0, import_react60.useRef)(null);
9343
9410
  (0, import_react60.useEffect)(() => {
9344
- appStore.subscribe(
9411
+ return appStore.subscribe(
9345
9412
  (s) => s.state.data,
9346
9413
  (data) => {
9347
9414
  if (onChange) {
9348
- if ((0, import_fast_deep_equal3.default)(data, previousData.current)) return;
9415
+ if ((0, import_fast_deep_equal.default)(data, previousData.current)) return;
9349
9416
  onChange(data);
9350
9417
  previousData.current = data;
9351
9418
  }
9352
9419
  }
9353
9420
  );
9354
- }, []);
9421
+ }, [onChange]);
9355
9422
  useRegisterPermissionsSlice(appStore, permissions);
9356
9423
  const uPuckStore = useRegisterUsePuckStore(appStore);
9357
9424
  (0, import_react60.useEffect)(() => {
@@ -9664,17 +9731,6 @@ function transformProps(data, propTransforms, config = { components: {} }) {
9664
9731
 
9665
9732
  // lib/resolve-all-data.ts
9666
9733
  init_react_import();
9667
-
9668
- // lib/data/to-component.ts
9669
- init_react_import();
9670
- var toComponent = (item) => {
9671
- return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
9672
- props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
9673
- type: "root"
9674
- });
9675
- };
9676
-
9677
- // lib/resolve-all-data.ts
9678
9734
  function resolveAllData(_0, _1) {
9679
9735
  return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
9680
9736
  var _a;
@@ -18,14 +18,14 @@ import {
18
18
  setDeep,
19
19
  useGetPuck,
20
20
  usePuck
21
- } from "./chunk-MSKEXIWC.mjs";
21
+ } from "./chunk-YRZRLNQC.mjs";
22
22
  import {
23
23
  init_react_import,
24
24
  migrate,
25
25
  resolveAllData,
26
26
  transformProps,
27
27
  walkTree
28
- } from "./chunk-OOLYDXKW.mjs";
28
+ } from "./chunk-VBJEDLUM.mjs";
29
29
 
30
30
  // bundle/no-external.ts
31
31
  init_react_import();
package/dist/rsc.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-Ctf3FZQI.mjs';
3
- export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-Ctf3FZQI.mjs';
2
+ import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-7SvCIsj8.mjs';
3
+ export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-7SvCIsj8.mjs';
4
4
  import 'react';
5
5
 
6
6
  declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
package/dist/rsc.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-Ctf3FZQI.js';
3
- export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-Ctf3FZQI.js';
2
+ import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-7SvCIsj8.js';
3
+ export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-7SvCIsj8.js';
4
4
  import 'react';
5
5
 
6
6
  declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
package/dist/rsc.js CHANGED
@@ -460,19 +460,19 @@ function Render({
460
460
  }
461
461
 
462
462
  // lib/get-changed.ts
463
- var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
463
+ var import_fast_equals = require("fast-equals");
464
464
  var getChanged = (newItem, oldItem) => {
465
465
  return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
466
466
  const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
467
467
  const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
468
468
  return __spreadProps(__spreadValues({}, acc), {
469
- [item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
469
+ [item]: !(0, import_fast_equals.deepEqual)(oldItemProps[item], newItemProps[item])
470
470
  });
471
471
  }, {}) : {};
472
472
  };
473
473
 
474
474
  // lib/resolve-component-data.ts
475
- var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
475
+ var import_fast_equals2 = require("fast-equals");
476
476
  var cache = { lastChange: {} };
477
477
  var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
478
478
  const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
@@ -481,7 +481,7 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
481
481
  const id = "id" in item.props ? item.props.id : "root";
482
482
  if (shouldRunResolver) {
483
483
  const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
484
- if (trigger !== "force" && item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
484
+ if (trigger !== "force" && item && (0, import_fast_equals2.deepEqual)(item, oldItem)) {
485
485
  return { node: resolved, didChange: false };
486
486
  }
487
487
  const changed = getChanged(item, oldItem);
@@ -531,7 +531,7 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
531
531
  };
532
532
  return {
533
533
  node: itemWithResolvedChildren,
534
- didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
534
+ didChange: !(0, import_fast_equals2.deepEqual)(item, itemWithResolvedChildren)
535
535
  };
536
536
  });
537
537
 
package/dist/rsc.mjs CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  transformProps,
13
13
  useSlots,
14
14
  walkTree
15
- } from "./chunk-OOLYDXKW.mjs";
15
+ } from "./chunk-VBJEDLUM.mjs";
16
16
 
17
17
  // bundle/rsc.tsx
18
18
  init_react_import();
@@ -52,7 +52,7 @@ type ArrayField<Props extends {
52
52
  type: PropertyKey;
53
53
  } ? Field<Props[0][SubPropName], UserField> | UserField : Field<Props[0][SubPropName], UserField>;
54
54
  };
55
- defaultItemProps?: Props[0];
55
+ defaultItemProps?: Props[0] | ((index: number) => Props[0]);
56
56
  getItemSummary?: (item: Props[0], index?: number) => string;
57
57
  max?: number;
58
58
  min?: number;
@@ -82,10 +82,14 @@ type ExternalFieldWithAdaptor<Props extends any = {
82
82
  adaptorParams?: object;
83
83
  getItemSummary: (item: NotUndefined<Props>, index?: number) => string;
84
84
  };
85
+ type CacheOpts = {
86
+ enabled?: boolean;
87
+ };
85
88
  type ExternalField<Props extends any = {
86
89
  [key: string]: any;
87
90
  }> = BaseField & {
88
91
  type: "external";
92
+ cache?: CacheOpts;
89
93
  placeholder?: string;
90
94
  fetchList: (params: {
91
95
  query: string;
@@ -147,7 +151,7 @@ type DropZoneProps = {
147
151
  };
148
152
 
149
153
  type PuckContext = {
150
- renderDropZone: React.FC<DropZoneProps>;
154
+ renderDropZone: (props: DropZoneProps) => React.ReactNode;
151
155
  metadata: Metadata;
152
156
  isEditing: boolean;
153
157
  dragRef: ((element: Element | null) => void) | null;
@@ -631,4 +635,4 @@ type WalkTreeOptions = {
631
635
  };
632
636
  declare function walkTree<T extends ComponentData | RootData | G["UserData"], UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(data: T, config: UserConfig, callbackFn: (data: Content, options: WalkTreeOptions) => Content | null | void): T;
633
637
 
634
- export { type BaseField as $, type AppState as A, type ArrayState as B, type Config as C, type DropZoneProps as D, type SlotComponent as E, type Fields as F, type PuckComponent as G, type History as H, type IframeConfig as I, type RootConfig as J, type DefaultComponents as K, type ExtractConfigParams as L, type Metadata as M, type BaseData as N, type Overrides as O, type Permissions as P, type RootDataWithoutProps as Q, type RootDataWithProps as R, type Slot as S, type RootData as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type ComponentDataOptionalId as X, type MappedItem as Y, type ComponentDataMap as Z, type Content as _, type ComponentData as a, type TextField as a0, type NumberField as a1, type TextareaField as a2, type SelectField as a3, type RadioField as a4, type ArrayField as a5, type ObjectField as a6, type Adaptor as a7, type ExternalFieldWithAdaptor as a8, type ExternalField as a9, type CustomFieldRender as aa, type CustomField as ab, type SlotField as ac, type PuckContext as ad, type DefaultRootFieldProps as ae, type DefaultRootRenderProps as af, type DefaultRootProps as ag, type DefaultComponentProps as ah, type WithId as ai, type WithPuckProps as aj, type AsFieldProps as ak, type WithChildren as al, type ExtractField as am, type PuckAction as b, type ResolveDataTrigger as c, type Plugin as d, type UiState as e, type ComponentConfig as f, type FieldTransforms as g, type Field as h, type FieldProps as i, type Data as j, type OnAction as k, type InitialHistory as l, migrate as m, type ItemSelector as n, type Direction as o, type DragAxis as p, type Viewport as q, resolveAllData as r, type FieldTransformFnParams as s, transformProps as t, type FieldTransformFn as u, overrideKeys as v, walkTree as w, type OverrideKey as x, type FieldRenderFunctions as y, type ItemWithId as z };
638
+ export { type BaseField as $, type AppState as A, type ArrayState as B, type Config as C, type DropZoneProps as D, type SlotComponent as E, type Fields as F, type PuckComponent as G, type History as H, type IframeConfig as I, type RootConfig as J, type DefaultComponents as K, type ExtractConfigParams as L, type Metadata as M, type BaseData as N, type Overrides as O, type Permissions as P, type RootDataWithoutProps as Q, type RootDataWithProps as R, type Slot as S, type RootData as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type ComponentDataOptionalId as X, type MappedItem as Y, type ComponentDataMap as Z, type Content as _, type ComponentData as a, type TextField as a0, type NumberField as a1, type TextareaField as a2, type SelectField as a3, type RadioField as a4, type ArrayField as a5, type ObjectField as a6, type Adaptor as a7, type ExternalFieldWithAdaptor as a8, type CacheOpts as a9, type ExternalField as aa, type CustomFieldRender as ab, type CustomField as ac, type SlotField as ad, type PuckContext as ae, type DefaultRootFieldProps as af, type DefaultRootRenderProps as ag, type DefaultRootProps as ah, type DefaultComponentProps as ai, type WithId as aj, type WithPuckProps as ak, type AsFieldProps as al, type WithChildren as am, type ExtractField as an, type PuckAction as b, type ResolveDataTrigger as c, type Plugin as d, type UiState as e, type ComponentConfig as f, type FieldTransforms as g, type Field as h, type FieldProps as i, type Data as j, type OnAction as k, type InitialHistory as l, migrate as m, type ItemSelector as n, type Direction as o, type DragAxis as p, type Viewport as q, resolveAllData as r, type FieldTransformFnParams as s, transformProps as t, type FieldTransformFn as u, overrideKeys as v, walkTree as w, type OverrideKey as x, type FieldRenderFunctions as y, type ItemWithId as z };
@@ -52,7 +52,7 @@ type ArrayField<Props extends {
52
52
  type: PropertyKey;
53
53
  } ? Field<Props[0][SubPropName], UserField> | UserField : Field<Props[0][SubPropName], UserField>;
54
54
  };
55
- defaultItemProps?: Props[0];
55
+ defaultItemProps?: Props[0] | ((index: number) => Props[0]);
56
56
  getItemSummary?: (item: Props[0], index?: number) => string;
57
57
  max?: number;
58
58
  min?: number;
@@ -82,10 +82,14 @@ type ExternalFieldWithAdaptor<Props extends any = {
82
82
  adaptorParams?: object;
83
83
  getItemSummary: (item: NotUndefined<Props>, index?: number) => string;
84
84
  };
85
+ type CacheOpts = {
86
+ enabled?: boolean;
87
+ };
85
88
  type ExternalField<Props extends any = {
86
89
  [key: string]: any;
87
90
  }> = BaseField & {
88
91
  type: "external";
92
+ cache?: CacheOpts;
89
93
  placeholder?: string;
90
94
  fetchList: (params: {
91
95
  query: string;
@@ -147,7 +151,7 @@ type DropZoneProps = {
147
151
  };
148
152
 
149
153
  type PuckContext = {
150
- renderDropZone: React.FC<DropZoneProps>;
154
+ renderDropZone: (props: DropZoneProps) => React.ReactNode;
151
155
  metadata: Metadata;
152
156
  isEditing: boolean;
153
157
  dragRef: ((element: Element | null) => void) | null;
@@ -631,4 +635,4 @@ type WalkTreeOptions = {
631
635
  };
632
636
  declare function walkTree<T extends ComponentData | RootData | G["UserData"], UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(data: T, config: UserConfig, callbackFn: (data: Content, options: WalkTreeOptions) => Content | null | void): T;
633
637
 
634
- export { type BaseField as $, type AppState as A, type ArrayState as B, type Config as C, type DropZoneProps as D, type SlotComponent as E, type Fields as F, type PuckComponent as G, type History as H, type IframeConfig as I, type RootConfig as J, type DefaultComponents as K, type ExtractConfigParams as L, type Metadata as M, type BaseData as N, type Overrides as O, type Permissions as P, type RootDataWithoutProps as Q, type RootDataWithProps as R, type Slot as S, type RootData as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type ComponentDataOptionalId as X, type MappedItem as Y, type ComponentDataMap as Z, type Content as _, type ComponentData as a, type TextField as a0, type NumberField as a1, type TextareaField as a2, type SelectField as a3, type RadioField as a4, type ArrayField as a5, type ObjectField as a6, type Adaptor as a7, type ExternalFieldWithAdaptor as a8, type ExternalField as a9, type CustomFieldRender as aa, type CustomField as ab, type SlotField as ac, type PuckContext as ad, type DefaultRootFieldProps as ae, type DefaultRootRenderProps as af, type DefaultRootProps as ag, type DefaultComponentProps as ah, type WithId as ai, type WithPuckProps as aj, type AsFieldProps as ak, type WithChildren as al, type ExtractField as am, type PuckAction as b, type ResolveDataTrigger as c, type Plugin as d, type UiState as e, type ComponentConfig as f, type FieldTransforms as g, type Field as h, type FieldProps as i, type Data as j, type OnAction as k, type InitialHistory as l, migrate as m, type ItemSelector as n, type Direction as o, type DragAxis as p, type Viewport as q, resolveAllData as r, type FieldTransformFnParams as s, transformProps as t, type FieldTransformFn as u, overrideKeys as v, walkTree as w, type OverrideKey as x, type FieldRenderFunctions as y, type ItemWithId as z };
638
+ export { type BaseField as $, type AppState as A, type ArrayState as B, type Config as C, type DropZoneProps as D, type SlotComponent as E, type Fields as F, type PuckComponent as G, type History as H, type IframeConfig as I, type RootConfig as J, type DefaultComponents as K, type ExtractConfigParams as L, type Metadata as M, type BaseData as N, type Overrides as O, type Permissions as P, type RootDataWithoutProps as Q, type RootDataWithProps as R, type Slot as S, type RootData as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type ComponentDataOptionalId as X, type MappedItem as Y, type ComponentDataMap as Z, type Content as _, type ComponentData as a, type TextField as a0, type NumberField as a1, type TextareaField as a2, type SelectField as a3, type RadioField as a4, type ArrayField as a5, type ObjectField as a6, type Adaptor as a7, type ExternalFieldWithAdaptor as a8, type CacheOpts as a9, type ExternalField as aa, type CustomFieldRender as ab, type CustomField as ac, type SlotField as ad, type PuckContext as ae, type DefaultRootFieldProps as af, type DefaultRootRenderProps as ag, type DefaultRootProps as ah, type DefaultComponentProps as ai, type WithId as aj, type WithPuckProps as ak, type AsFieldProps as al, type WithChildren as am, type ExtractField as an, type PuckAction as b, type ResolveDataTrigger as c, type Plugin as d, type UiState as e, type ComponentConfig as f, type FieldTransforms as g, type Field as h, type FieldProps as i, type Data as j, type OnAction as k, type InitialHistory as l, migrate as m, type ItemSelector as n, type Direction as o, type DragAxis as p, type Viewport as q, resolveAllData as r, type FieldTransformFnParams as s, transformProps as t, type FieldTransformFn as u, overrideKeys as v, walkTree as w, type OverrideKey as x, type FieldRenderFunctions as y, type ItemWithId as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.21.0-canary.20aafb6a",
3
+ "version": "0.21.0-canary.29ef7131",
4
4
  "description": "The open-source visual editor for React",
5
5
  "author": "Chris Villa <chris@puckeditor.com>",
6
6
  "repository": "measuredco/puck",
@@ -96,7 +96,7 @@
96
96
  "@dnd-kit/helpers": "0.1.18",
97
97
  "@dnd-kit/react": "0.1.18",
98
98
  "deep-diff": "^1.0.2",
99
- "fast-deep-equal": "^3.1.3",
99
+ "fast-equals": "5.2.2",
100
100
  "flat": "^5.0.2",
101
101
  "object-hash": "^3.0.0",
102
102
  "react-hotkeys-hook": "^4.6.1",