@measured/puck 0.21.0-canary.15fe8d60 → 0.21.0-canary.1b69a8f3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,7 +25,7 @@ import {
25
25
  walkAppState,
26
26
  walkField,
27
27
  walkTree
28
- } from "./chunk-TC25DCTQ.mjs";
28
+ } from "./chunk-JA7SEUEH.mjs";
29
29
 
30
30
  // ../../node_modules/classnames/index.js
31
31
  var require_classnames = __commonJS({
@@ -1074,26 +1074,34 @@ var createPermissionsSlice = (set, get) => {
1074
1074
  const resolvePermissions = (..._0) => __async(null, [..._0], function* (params = {}, force) {
1075
1075
  const { state, permissions, config } = get();
1076
1076
  const { cache, globalPermissions } = permissions;
1077
- const resolveDataForItem = (item2, force2 = false) => __async(null, null, function* () {
1078
- var _a, _b, _c;
1077
+ const resolvePermissionsForItem = (item2, force2 = false) => __async(null, null, function* () {
1078
+ var _a, _b;
1079
1079
  const { config: config2, state: appState, setComponentLoading } = get();
1080
+ const itemCache = cache[item2.props.id];
1081
+ const nodes = appState.indexes.nodes;
1082
+ const parentId = (_a = nodes[item2.props.id]) == null ? void 0 : _a.parentId;
1083
+ const parentNode = parentId ? nodes[parentId] : null;
1084
+ const parentData = (_b = parentNode == null ? void 0 : parentNode.data) != null ? _b : null;
1080
1085
  const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
1081
1086
  if (!componentConfig) {
1082
1087
  return;
1083
1088
  }
1084
1089
  const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
1085
1090
  if (componentConfig.resolvePermissions) {
1086
- const changed = getChanged(item2, (_a = cache[item2.props.id]) == null ? void 0 : _a.lastData);
1087
- if (Object.values(changed).some((el) => el === true) || force2) {
1091
+ const changed = getChanged(item2, itemCache == null ? void 0 : itemCache.lastData);
1092
+ const propsChanged = Object.values(changed).some((el) => el === true);
1093
+ const parentChanged = (itemCache == null ? void 0 : itemCache.lastParentId) !== parentId;
1094
+ if (propsChanged || parentChanged || force2) {
1088
1095
  const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
1089
1096
  const resolvedPermissions = yield componentConfig.resolvePermissions(
1090
1097
  item2,
1091
1098
  {
1092
1099
  changed,
1093
- lastPermissions: ((_b = cache[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
1100
+ lastPermissions: (itemCache == null ? void 0 : itemCache.lastPermissions) || null,
1094
1101
  permissions: initialPermissions,
1095
1102
  appState: makeStatePublic(appState),
1096
- lastData: ((_c = cache[item2.props.id]) == null ? void 0 : _c.lastData) || null
1103
+ lastData: (itemCache == null ? void 0 : itemCache.lastData) || null,
1104
+ parent: parentData
1097
1105
  }
1098
1106
  );
1099
1107
  const latest = get().permissions;
@@ -1101,6 +1109,7 @@ var createPermissionsSlice = (set, get) => {
1101
1109
  permissions: __spreadProps(__spreadValues({}, latest), {
1102
1110
  cache: __spreadProps(__spreadValues({}, latest.cache), {
1103
1111
  [item2.props.id]: {
1112
+ lastParentId: parentId,
1104
1113
  lastData: item2,
1105
1114
  lastPermissions: resolvedPermissions
1106
1115
  }
@@ -1114,9 +1123,9 @@ var createPermissionsSlice = (set, get) => {
1114
1123
  }
1115
1124
  }
1116
1125
  });
1117
- const resolveDataForRoot = (force2 = false) => {
1126
+ const resolvePermissionsForRoot = (force2 = false) => {
1118
1127
  const { state: appState } = get();
1119
- resolveDataForItem(
1128
+ resolvePermissionsForItem(
1120
1129
  // Shim the root data in by conforming to component data shape
1121
1130
  {
1122
1131
  type: "root",
@@ -1127,16 +1136,16 @@ var createPermissionsSlice = (set, get) => {
1127
1136
  };
1128
1137
  const { item, type, root } = params;
1129
1138
  if (item) {
1130
- yield resolveDataForItem(item, force);
1139
+ yield resolvePermissionsForItem(item, force);
1131
1140
  } else if (type) {
1132
1141
  flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(null, null, function* () {
1133
- yield resolveDataForItem(item2, force);
1142
+ yield resolvePermissionsForItem(item2, force);
1134
1143
  }));
1135
1144
  } else if (root) {
1136
- resolveDataForRoot(force);
1145
+ resolvePermissionsForRoot(force);
1137
1146
  } else {
1138
1147
  flattenData(state, config).map((item2) => __async(null, null, function* () {
1139
- yield resolveDataForItem(item2, force);
1148
+ yield resolvePermissionsForItem(item2, force);
1140
1149
  }));
1141
1150
  }
1142
1151
  });
@@ -3794,6 +3803,7 @@ function AutoFieldInternal(props) {
3794
3803
  }
3795
3804
  return (_props) => null;
3796
3805
  }, [field.type]);
3806
+ const fieldKey = field.type === "custom" ? field.key : void 0;
3797
3807
  let FieldComponent = useMemo3(() => {
3798
3808
  if (field.type === "custom") {
3799
3809
  if (!field.render) {
@@ -3803,7 +3813,7 @@ function AutoFieldInternal(props) {
3803
3813
  } else if (field.type !== "slot") {
3804
3814
  return render[field.type];
3805
3815
  }
3806
- }, [field.type, render]);
3816
+ }, [field.type, fieldKey, render]);
3807
3817
  const { visible = true } = props.field;
3808
3818
  if (!visible) {
3809
3819
  return null;
@@ -4843,7 +4853,20 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
4843
4853
 
4844
4854
  // lib/insert-component.ts
4845
4855
  init_react_import();
4856
+
4857
+ // lib/get-selector-for-id.ts
4858
+ init_react_import();
4859
+ var getSelectorForId = (state, id) => {
4860
+ const node = state.indexes.nodes[id];
4861
+ if (!node) return;
4862
+ const zoneCompound = `${node.parentId}:${node.zone}`;
4863
+ const index = state.indexes.zones[zoneCompound].contentIds.indexOf(id);
4864
+ return { zone: zoneCompound, index };
4865
+ };
4866
+
4867
+ // lib/insert-component.ts
4846
4868
  var insertComponent = (componentType, zone, index, appStore) => __async(null, null, function* () {
4869
+ const { getState } = appStore;
4847
4870
  const id = generateId(componentType);
4848
4871
  const insertActionData = {
4849
4872
  type: "insert",
@@ -4852,8 +4875,9 @@ var insertComponent = (componentType, zone, index, appStore) => __async(null, nu
4852
4875
  destinationZone: zone,
4853
4876
  id
4854
4877
  };
4855
- const { state, dispatch, resolveComponentData: resolveComponentData2 } = appStore;
4856
- const insertedState = insertAction(state, insertActionData, appStore);
4878
+ const stateBefore = getState().state;
4879
+ const insertedState = insertAction(stateBefore, insertActionData, getState());
4880
+ const dispatch = getState().dispatch;
4857
4881
  dispatch(__spreadProps(__spreadValues({}, insertActionData), {
4858
4882
  // Dispatch insert rather set, as user's may rely on this via onAction
4859
4883
  // We must always record history here so the insert is added to user history
@@ -4861,23 +4885,21 @@ var insertComponent = (componentType, zone, index, appStore) => __async(null, nu
4861
4885
  // entries on insert - one for the initial insert, and one when the data resolves
4862
4886
  recordHistory: true
4863
4887
  }));
4864
- const itemSelector = {
4865
- index,
4866
- zone
4867
- };
4888
+ const itemSelector = { index, zone };
4868
4889
  dispatch({ type: "setUi", ui: { itemSelector } });
4869
4890
  const itemData = getItem(itemSelector, insertedState);
4870
- if (itemData) {
4871
- const resolved = yield resolveComponentData2(itemData, "insert");
4872
- if (resolved.didChange) {
4873
- dispatch({
4874
- type: "replace",
4875
- destinationZone: itemSelector.zone,
4876
- destinationIndex: itemSelector.index,
4877
- data: resolved.node
4878
- });
4879
- }
4880
- }
4891
+ if (!itemData) return;
4892
+ const resolveComponentData2 = getState().resolveComponentData;
4893
+ const resolved = yield resolveComponentData2(itemData, "insert");
4894
+ if (!resolved.didChange) return;
4895
+ const latestItemSelector = getSelectorForId(getState().state, id);
4896
+ if (!latestItemSelector) return;
4897
+ dispatch({
4898
+ type: "replace",
4899
+ destinationZone: latestItemSelector.zone,
4900
+ destinationIndex: latestItemSelector.index,
4901
+ data: resolved.node
4902
+ });
4881
4903
  });
4882
4904
 
4883
4905
  // components/DragDropContext/index.tsx
@@ -5114,7 +5136,7 @@ var DragDropContextClient = ({
5114
5136
  thisPreview.componentType,
5115
5137
  thisPreview.zone,
5116
5138
  thisPreview.index,
5117
- appStore.getState()
5139
+ appStore
5118
5140
  );
5119
5141
  } else if (initialSelector.current) {
5120
5142
  dispatch({
@@ -5756,16 +5778,6 @@ function setDeep(node, path, newVal) {
5756
5778
  return __spreadValues(__spreadValues({}, node), newNode);
5757
5779
  }
5758
5780
 
5759
- // lib/get-selector-for-id.ts
5760
- init_react_import();
5761
- var getSelectorForId = (state, id) => {
5762
- const node = state.indexes.nodes[id];
5763
- if (!node) return;
5764
- const zoneCompound = `${node.parentId}:${node.zone}`;
5765
- const index = state.indexes.zones[zoneCompound].contentIds.indexOf(id);
5766
- return { zone: zoneCompound, index };
5767
- };
5768
-
5769
5781
  // components/InlineTextField/index.tsx
5770
5782
  import { jsx as jsx24 } from "react/jsx-runtime";
5771
5783
  var getClassName18 = get_class_name_factory_default("InlineTextField", styles_module_default13);
@@ -6086,7 +6098,8 @@ var DropZoneEdit = forwardRef3(
6086
6098
  style,
6087
6099
  className,
6088
6100
  minEmptyHeight: userMinEmptyHeight = 128,
6089
- collisionAxis
6101
+ collisionAxis,
6102
+ as
6090
6103
  }, userRef) {
6091
6104
  const ctx = useContext8(dropZoneContext);
6092
6105
  const appStoreApi = useAppStoreApi();
@@ -6229,8 +6242,9 @@ var DropZoneEdit = forwardRef3(
6229
6242
  userMinEmptyHeight,
6230
6243
  ref
6231
6244
  });
6245
+ const El = as != null ? as : "div";
6232
6246
  return /* @__PURE__ */ jsx26(
6233
- "div",
6247
+ El,
6234
6248
  {
6235
6249
  className: `${getClassName19({
6236
6250
  isRootZone,
@@ -6293,7 +6307,7 @@ var DropZoneRenderItem = ({
6293
6307
  };
6294
6308
  var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx26(DropZoneRender, __spreadValues({}, props));
6295
6309
  var DropZoneRender = forwardRef3(
6296
- function DropZoneRenderInternal({ className, style, zone }, ref) {
6310
+ function DropZoneRenderInternal({ className, style, zone, as }, ref) {
6297
6311
  const ctx = useContext8(dropZoneContext);
6298
6312
  const { areaId = "root" } = ctx || {};
6299
6313
  const { config, data, metadata } = useContext8(renderContext);
@@ -6306,13 +6320,14 @@ var DropZoneRender = forwardRef3(
6306
6320
  }
6307
6321
  }
6308
6322
  }, [content]);
6323
+ const El = as != null ? as : "div";
6309
6324
  if (!data || !config) {
6310
6325
  return null;
6311
6326
  }
6312
6327
  if (zoneCompound !== rootDroppableId) {
6313
6328
  content = setupZone(data, zoneCompound).zones[zoneCompound];
6314
6329
  }
6315
- return /* @__PURE__ */ jsx26("div", { className, style, ref, children: content.map((item) => {
6330
+ return /* @__PURE__ */ jsx26(El, { className, style, ref, children: content.map((item) => {
6316
6331
  const Component = config.components[item.type];
6317
6332
  if (Component) {
6318
6333
  return /* @__PURE__ */ jsx26(
@@ -6603,48 +6618,47 @@ var DefaultFields = ({
6603
6618
  return /* @__PURE__ */ jsx29(Fragment8, { children });
6604
6619
  };
6605
6620
  var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(null, null, function* () {
6606
- let currentProps;
6607
6621
  const { dispatch, state, selectedItem, resolveComponentData: resolveComponentData2 } = appStore.getState();
6608
6622
  const { data, ui } = state;
6609
6623
  const { itemSelector } = ui;
6610
6624
  const rootProps = data.root.props || data.root;
6611
- if (selectedItem) {
6612
- currentProps = selectedItem.props;
6613
- } else {
6614
- currentProps = rootProps;
6615
- }
6616
- const newProps = __spreadProps(__spreadValues({}, currentProps), {
6617
- [fieldName]: value
6618
- });
6625
+ const currentProps = selectedItem ? selectedItem.props : rootProps;
6626
+ const newProps = __spreadProps(__spreadValues({}, currentProps), { [fieldName]: value });
6619
6627
  if (selectedItem && itemSelector) {
6628
+ const resolved = yield resolveComponentData2(
6629
+ __spreadProps(__spreadValues({}, selectedItem), { props: newProps }),
6630
+ "replace"
6631
+ );
6632
+ const latestSelector = getSelectorForId(
6633
+ appStore.getState().state,
6634
+ selectedItem.props.id
6635
+ );
6636
+ if (!latestSelector) return;
6620
6637
  dispatch({
6621
6638
  type: "replace",
6622
- destinationIndex: itemSelector.index,
6623
- destinationZone: itemSelector.zone || rootDroppableId,
6624
- data: (yield resolveComponentData2(
6625
- __spreadProps(__spreadValues({}, selectedItem), { props: newProps }),
6639
+ destinationIndex: latestSelector.index,
6640
+ destinationZone: latestSelector.zone || rootDroppableId,
6641
+ data: resolved.node,
6642
+ ui: updatedUi
6643
+ });
6644
+ return;
6645
+ }
6646
+ if (data.root.props) {
6647
+ dispatch({
6648
+ type: "replaceRoot",
6649
+ root: (yield resolveComponentData2(
6650
+ __spreadProps(__spreadValues({}, data.root), { props: newProps }),
6626
6651
  "replace"
6627
6652
  )).node,
6628
- ui: updatedUi
6653
+ ui: __spreadValues(__spreadValues({}, ui), updatedUi),
6654
+ recordHistory: true
6629
6655
  });
6630
- } else {
6631
- if (data.root.props) {
6632
- dispatch({
6633
- type: "replaceRoot",
6634
- root: (yield resolveComponentData2(
6635
- __spreadProps(__spreadValues({}, data.root), { props: newProps }),
6636
- "replace"
6637
- )).node,
6638
- ui: __spreadValues(__spreadValues({}, ui), updatedUi),
6639
- recordHistory: true
6640
- });
6641
- } else {
6642
- dispatch({
6643
- type: "setData",
6644
- data: { root: newProps }
6645
- });
6646
- }
6656
+ return;
6647
6657
  }
6658
+ dispatch({
6659
+ type: "setData",
6660
+ data: { root: newProps }
6661
+ });
6648
6662
  });
6649
6663
  var FieldsChild = ({ fieldName }) => {
6650
6664
  const field = useAppStore((s) => s.fields.fields[fieldName]);
@@ -8649,7 +8663,12 @@ function PuckProvider({ children }) {
8649
8663
  });
8650
8664
  })
8651
8665
  );
8652
- const initialHistoryIndex = (_initialHistory == null ? void 0 : _initialHistory.index) || blendedHistories.length - 1;
8666
+ const initialHistoryIndex = useMemo20(() => {
8667
+ if ((_initialHistory == null ? void 0 : _initialHistory.index) !== void 0 && (_initialHistory == null ? void 0 : _initialHistory.index) >= 0 && (_initialHistory == null ? void 0 : _initialHistory.index) < blendedHistories.length) {
8668
+ return _initialHistory == null ? void 0 : _initialHistory.index;
8669
+ }
8670
+ return blendedHistories.length - 1;
8671
+ }, []);
8653
8672
  const initialAppState = blendedHistories[initialHistoryIndex].state;
8654
8673
  const loadedOverrides = useLoadedOverrides({
8655
8674
  overrides,
@@ -914,8 +914,9 @@ var Item = ({
914
914
  );
915
915
  };
916
916
  var SlotRender = forwardRef(
917
- function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
918
- return /* @__PURE__ */ jsx("div", { className, style, ref, children: content.map((item) => {
917
+ function SlotRenderInternal({ className, style, content, config, metadata, as }, ref) {
918
+ const El = as != null ? as : "div";
919
+ return /* @__PURE__ */ jsx(El, { className, style, ref, children: content.map((item) => {
919
920
  if (!config.components[item.type]) {
920
921
  return null;
921
922
  }
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-BMbIeiqs.mjs';
2
- export { ad as Adaptor, ab as ArrayField, B as ArrayState, ar as AsFieldProps, X as BaseData, a5 as BaseField, af as CacheOpts, J as ComponentConfigExtensions, T as ComponentConfigParams, a0 as ComponentDataMap, _ as ComponentDataOptionalId, a3 as ComponentMetadata, Q as ConfigParams, a1 as Content, ai as CustomField, ah as CustomFieldRender, ao as DefaultComponentProps, L as DefaultComponents, al as DefaultRootFieldProps, an as DefaultRootProps, am as DefaultRootRenderProps, o as Direction, p as DragAxis, ag as ExternalField, ae as ExternalFieldWithAdaptor, N as ExtractConfigParams, at as ExtractField, a4 as FieldMetadata, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, z as ItemWithId, $ as MappedItem, a7 as NumberField, ac as ObjectField, x as OverrideKey, G as PuckComponent, ak as PuckContext, a2 as PuckMetadata, aa as RadioField, K as RootConfig, Z as RootData, Y as RootDataWithoutProps, a9 as SelectField, S as Slot, E as SlotComponent, aj as SlotField, a6 as TextField, a8 as TextareaField, q as Viewport, as as WithChildren, ap as WithId, aq as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-BMbIeiqs.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-BjNPkzm9.mjs';
2
+ export { ad as Adaptor, ab as ArrayField, B as ArrayState, ar as AsFieldProps, X as BaseData, a5 as BaseField, af as CacheOpts, J as ComponentConfigExtensions, T as ComponentConfigParams, a0 as ComponentDataMap, _ as ComponentDataOptionalId, a3 as ComponentMetadata, Q as ConfigParams, a1 as Content, ai as CustomField, ah as CustomFieldRender, ao as DefaultComponentProps, L as DefaultComponents, al as DefaultRootFieldProps, an as DefaultRootProps, am as DefaultRootRenderProps, o as Direction, p as DragAxis, ag as ExternalField, ae as ExternalFieldWithAdaptor, N as ExtractConfigParams, at as ExtractField, a4 as FieldMetadata, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, z as ItemWithId, $ as MappedItem, a7 as NumberField, ac as ObjectField, x as OverrideKey, G as PuckComponent, ak as PuckContext, a2 as PuckMetadata, aa as RadioField, K as RootConfig, Z as RootData, Y as RootDataWithoutProps, a9 as SelectField, S as Slot, E as SlotComponent, aj as SlotField, a6 as TextField, a8 as TextareaField, q as Viewport, as as WithChildren, ap as WithId, aq as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-BjNPkzm9.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';
@@ -47,6 +47,7 @@ type RefreshPermissions<UserConfig extends Config = Config> = (params?: Permissi
47
47
  type Cache = Record<string, {
48
48
  lastPermissions: Partial<Permissions>;
49
49
  lastData: ComponentData | null;
50
+ lastParentId: string | null;
50
51
  }>;
51
52
  type PermissionsSlice = {
52
53
  cache: Cache;
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-BMbIeiqs.js';
2
- export { ad as Adaptor, ab as ArrayField, B as ArrayState, ar as AsFieldProps, X as BaseData, a5 as BaseField, af as CacheOpts, J as ComponentConfigExtensions, T as ComponentConfigParams, a0 as ComponentDataMap, _ as ComponentDataOptionalId, a3 as ComponentMetadata, Q as ConfigParams, a1 as Content, ai as CustomField, ah as CustomFieldRender, ao as DefaultComponentProps, L as DefaultComponents, al as DefaultRootFieldProps, an as DefaultRootProps, am as DefaultRootRenderProps, o as Direction, p as DragAxis, ag as ExternalField, ae as ExternalFieldWithAdaptor, N as ExtractConfigParams, at as ExtractField, a4 as FieldMetadata, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, z as ItemWithId, $ as MappedItem, a7 as NumberField, ac as ObjectField, x as OverrideKey, G as PuckComponent, ak as PuckContext, a2 as PuckMetadata, aa as RadioField, K as RootConfig, Z as RootData, Y as RootDataWithoutProps, a9 as SelectField, S as Slot, E as SlotComponent, aj as SlotField, a6 as TextField, a8 as TextareaField, q as Viewport, as as WithChildren, ap as WithId, aq as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-BMbIeiqs.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-BjNPkzm9.js';
2
+ export { ad as Adaptor, ab as ArrayField, B as ArrayState, ar as AsFieldProps, X as BaseData, a5 as BaseField, af as CacheOpts, J as ComponentConfigExtensions, T as ComponentConfigParams, a0 as ComponentDataMap, _ as ComponentDataOptionalId, a3 as ComponentMetadata, Q as ConfigParams, a1 as Content, ai as CustomField, ah as CustomFieldRender, ao as DefaultComponentProps, L as DefaultComponents, al as DefaultRootFieldProps, an as DefaultRootProps, am as DefaultRootRenderProps, o as Direction, p as DragAxis, ag as ExternalField, ae as ExternalFieldWithAdaptor, N as ExtractConfigParams, at as ExtractField, a4 as FieldMetadata, y as FieldRenderFunctions, u as FieldTransformFn, s as FieldTransformFnParams, z as ItemWithId, $ as MappedItem, a7 as NumberField, ac as ObjectField, x as OverrideKey, G as PuckComponent, ak as PuckContext, a2 as PuckMetadata, aa as RadioField, K as RootConfig, Z as RootData, Y as RootDataWithoutProps, a9 as SelectField, S as Slot, E as SlotComponent, aj as SlotField, a6 as TextField, a8 as TextareaField, q as Viewport, as as WithChildren, ap as WithId, aq as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-BjNPkzm9.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';
@@ -47,6 +47,7 @@ type RefreshPermissions<UserConfig extends Config = Config> = (params?: Permissi
47
47
  type Cache = Record<string, {
48
48
  lastPermissions: Partial<Permissions>;
49
49
  lastData: ComponentData | null;
50
+ lastParentId: string | null;
50
51
  }>;
51
52
  type PermissionsSlice = {
52
53
  cache: Cache;
package/dist/index.js CHANGED
@@ -1979,26 +1979,34 @@ var createPermissionsSlice = (set, get) => {
1979
1979
  const resolvePermissions = (..._0) => __async(null, [..._0], function* (params = {}, force) {
1980
1980
  const { state, permissions, config } = get();
1981
1981
  const { cache: cache2, globalPermissions } = permissions;
1982
- const resolveDataForItem = (item2, force2 = false) => __async(null, null, function* () {
1983
- var _a, _b, _c;
1982
+ const resolvePermissionsForItem = (item2, force2 = false) => __async(null, null, function* () {
1983
+ var _a, _b;
1984
1984
  const { config: config2, state: appState, setComponentLoading } = get();
1985
+ const itemCache = cache2[item2.props.id];
1986
+ const nodes = appState.indexes.nodes;
1987
+ const parentId = (_a = nodes[item2.props.id]) == null ? void 0 : _a.parentId;
1988
+ const parentNode = parentId ? nodes[parentId] : null;
1989
+ const parentData = (_b = parentNode == null ? void 0 : parentNode.data) != null ? _b : null;
1985
1990
  const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
1986
1991
  if (!componentConfig) {
1987
1992
  return;
1988
1993
  }
1989
1994
  const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
1990
1995
  if (componentConfig.resolvePermissions) {
1991
- const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
1992
- if (Object.values(changed).some((el) => el === true) || force2) {
1996
+ const changed = getChanged(item2, itemCache == null ? void 0 : itemCache.lastData);
1997
+ const propsChanged = Object.values(changed).some((el) => el === true);
1998
+ const parentChanged = (itemCache == null ? void 0 : itemCache.lastParentId) !== parentId;
1999
+ if (propsChanged || parentChanged || force2) {
1993
2000
  const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
1994
2001
  const resolvedPermissions = yield componentConfig.resolvePermissions(
1995
2002
  item2,
1996
2003
  {
1997
2004
  changed,
1998
- lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
2005
+ lastPermissions: (itemCache == null ? void 0 : itemCache.lastPermissions) || null,
1999
2006
  permissions: initialPermissions,
2000
2007
  appState: makeStatePublic(appState),
2001
- lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
2008
+ lastData: (itemCache == null ? void 0 : itemCache.lastData) || null,
2009
+ parent: parentData
2002
2010
  }
2003
2011
  );
2004
2012
  const latest = get().permissions;
@@ -2006,6 +2014,7 @@ var createPermissionsSlice = (set, get) => {
2006
2014
  permissions: __spreadProps(__spreadValues({}, latest), {
2007
2015
  cache: __spreadProps(__spreadValues({}, latest.cache), {
2008
2016
  [item2.props.id]: {
2017
+ lastParentId: parentId,
2009
2018
  lastData: item2,
2010
2019
  lastPermissions: resolvedPermissions
2011
2020
  }
@@ -2019,9 +2028,9 @@ var createPermissionsSlice = (set, get) => {
2019
2028
  }
2020
2029
  }
2021
2030
  });
2022
- const resolveDataForRoot = (force2 = false) => {
2031
+ const resolvePermissionsForRoot = (force2 = false) => {
2023
2032
  const { state: appState } = get();
2024
- resolveDataForItem(
2033
+ resolvePermissionsForItem(
2025
2034
  // Shim the root data in by conforming to component data shape
2026
2035
  {
2027
2036
  type: "root",
@@ -2032,16 +2041,16 @@ var createPermissionsSlice = (set, get) => {
2032
2041
  };
2033
2042
  const { item, type, root } = params;
2034
2043
  if (item) {
2035
- yield resolveDataForItem(item, force);
2044
+ yield resolvePermissionsForItem(item, force);
2036
2045
  } else if (type) {
2037
2046
  flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(null, null, function* () {
2038
- yield resolveDataForItem(item2, force);
2047
+ yield resolvePermissionsForItem(item2, force);
2039
2048
  }));
2040
2049
  } else if (root) {
2041
- resolveDataForRoot(force);
2050
+ resolvePermissionsForRoot(force);
2042
2051
  } else {
2043
2052
  flattenData(state, config).map((item2) => __async(null, null, function* () {
2044
- yield resolveDataForItem(item2, force);
2053
+ yield resolvePermissionsForItem(item2, force);
2045
2054
  }));
2046
2055
  }
2047
2056
  });
@@ -4427,6 +4436,7 @@ function AutoFieldInternal(props) {
4427
4436
  }
4428
4437
  return (_props) => null;
4429
4438
  }, [field.type]);
4439
+ const fieldKey = field.type === "custom" ? field.key : void 0;
4430
4440
  let FieldComponent = (0, import_react20.useMemo)(() => {
4431
4441
  if (field.type === "custom") {
4432
4442
  if (!field.render) {
@@ -4436,7 +4446,7 @@ function AutoFieldInternal(props) {
4436
4446
  } else if (field.type !== "slot") {
4437
4447
  return render[field.type];
4438
4448
  }
4439
- }, [field.type, render]);
4449
+ }, [field.type, fieldKey, render]);
4440
4450
  const { visible = true } = props.field;
4441
4451
  if (!visible) {
4442
4452
  return null;
@@ -5466,8 +5476,9 @@ var Item = ({
5466
5476
  );
5467
5477
  };
5468
5478
  var SlotRender = (0, import_react31.forwardRef)(
5469
- function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
5470
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className, style, ref, children: content.map((item) => {
5479
+ function SlotRenderInternal({ className, style, content, config, metadata, as }, ref) {
5480
+ const El = as != null ? as : "div";
5481
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(El, { className, style, ref, children: content.map((item) => {
5471
5482
  if (!config.components[item.type]) {
5472
5483
  return null;
5473
5484
  }
@@ -5982,7 +5993,8 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5982
5993
  style,
5983
5994
  className,
5984
5995
  minEmptyHeight: userMinEmptyHeight = 128,
5985
- collisionAxis
5996
+ collisionAxis,
5997
+ as
5986
5998
  }, userRef) {
5987
5999
  const ctx = (0, import_react34.useContext)(dropZoneContext);
5988
6000
  const appStoreApi = useAppStoreApi();
@@ -6125,8 +6137,9 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
6125
6137
  userMinEmptyHeight,
6126
6138
  ref
6127
6139
  });
6140
+ const El = as != null ? as : "div";
6128
6141
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
6129
- "div",
6142
+ El,
6130
6143
  {
6131
6144
  className: `${getClassName18({
6132
6145
  isRootZone,
@@ -6189,7 +6202,7 @@ var DropZoneRenderItem = ({
6189
6202
  };
6190
6203
  var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZoneRender, __spreadValues({}, props));
6191
6204
  var DropZoneRender = (0, import_react34.forwardRef)(
6192
- function DropZoneRenderInternal({ className, style, zone }, ref) {
6205
+ function DropZoneRenderInternal({ className, style, zone, as }, ref) {
6193
6206
  const ctx = (0, import_react34.useContext)(dropZoneContext);
6194
6207
  const { areaId = "root" } = ctx || {};
6195
6208
  const { config, data, metadata } = (0, import_react34.useContext)(renderContext);
@@ -6202,13 +6215,14 @@ var DropZoneRender = (0, import_react34.forwardRef)(
6202
6215
  }
6203
6216
  }
6204
6217
  }, [content]);
6218
+ const El = as != null ? as : "div";
6205
6219
  if (!data || !config) {
6206
6220
  return null;
6207
6221
  }
6208
6222
  if (zoneCompound !== rootDroppableId) {
6209
6223
  content = setupZone(data, zoneCompound).zones[zoneCompound];
6210
6224
  }
6211
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className, style, ref, children: content.map((item) => {
6225
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(El, { className, style, ref, children: content.map((item) => {
6212
6226
  const Component = config.components[item.type];
6213
6227
  if (Component) {
6214
6228
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
@@ -6515,6 +6529,7 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
6515
6529
  // lib/insert-component.ts
6516
6530
  init_react_import();
6517
6531
  var insertComponent = (componentType, zone, index, appStore) => __async(null, null, function* () {
6532
+ const { getState } = appStore;
6518
6533
  const id = generateId(componentType);
6519
6534
  const insertActionData = {
6520
6535
  type: "insert",
@@ -6523,8 +6538,9 @@ var insertComponent = (componentType, zone, index, appStore) => __async(null, nu
6523
6538
  destinationZone: zone,
6524
6539
  id
6525
6540
  };
6526
- const { state, dispatch, resolveComponentData: resolveComponentData2 } = appStore;
6527
- const insertedState = insertAction(state, insertActionData, appStore);
6541
+ const stateBefore = getState().state;
6542
+ const insertedState = insertAction(stateBefore, insertActionData, getState());
6543
+ const dispatch = getState().dispatch;
6528
6544
  dispatch(__spreadProps(__spreadValues({}, insertActionData), {
6529
6545
  // Dispatch insert rather set, as user's may rely on this via onAction
6530
6546
  // We must always record history here so the insert is added to user history
@@ -6532,23 +6548,21 @@ var insertComponent = (componentType, zone, index, appStore) => __async(null, nu
6532
6548
  // entries on insert - one for the initial insert, and one when the data resolves
6533
6549
  recordHistory: true
6534
6550
  }));
6535
- const itemSelector = {
6536
- index,
6537
- zone
6538
- };
6551
+ const itemSelector = { index, zone };
6539
6552
  dispatch({ type: "setUi", ui: { itemSelector } });
6540
6553
  const itemData = getItem(itemSelector, insertedState);
6541
- if (itemData) {
6542
- const resolved = yield resolveComponentData2(itemData, "insert");
6543
- if (resolved.didChange) {
6544
- dispatch({
6545
- type: "replace",
6546
- destinationZone: itemSelector.zone,
6547
- destinationIndex: itemSelector.index,
6548
- data: resolved.node
6549
- });
6550
- }
6551
- }
6554
+ if (!itemData) return;
6555
+ const resolveComponentData2 = getState().resolveComponentData;
6556
+ const resolved = yield resolveComponentData2(itemData, "insert");
6557
+ if (!resolved.didChange) return;
6558
+ const latestItemSelector = getSelectorForId(getState().state, id);
6559
+ if (!latestItemSelector) return;
6560
+ dispatch({
6561
+ type: "replace",
6562
+ destinationZone: latestItemSelector.zone,
6563
+ destinationIndex: latestItemSelector.index,
6564
+ data: resolved.node
6565
+ });
6552
6566
  });
6553
6567
 
6554
6568
  // components/DragDropContext/index.tsx
@@ -6785,7 +6799,7 @@ var DragDropContextClient = ({
6785
6799
  thisPreview.componentType,
6786
6800
  thisPreview.zone,
6787
6801
  thisPreview.index,
6788
- appStore.getState()
6802
+ appStore
6789
6803
  );
6790
6804
  } else if (initialSelector.current) {
6791
6805
  dispatch({
@@ -7223,48 +7237,47 @@ var DefaultFields = ({
7223
7237
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children });
7224
7238
  };
7225
7239
  var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(null, null, function* () {
7226
- let currentProps;
7227
7240
  const { dispatch, state, selectedItem, resolveComponentData: resolveComponentData2 } = appStore.getState();
7228
7241
  const { data, ui } = state;
7229
7242
  const { itemSelector } = ui;
7230
7243
  const rootProps = data.root.props || data.root;
7231
- if (selectedItem) {
7232
- currentProps = selectedItem.props;
7233
- } else {
7234
- currentProps = rootProps;
7235
- }
7236
- const newProps = __spreadProps(__spreadValues({}, currentProps), {
7237
- [fieldName]: value
7238
- });
7244
+ const currentProps = selectedItem ? selectedItem.props : rootProps;
7245
+ const newProps = __spreadProps(__spreadValues({}, currentProps), { [fieldName]: value });
7239
7246
  if (selectedItem && itemSelector) {
7247
+ const resolved = yield resolveComponentData2(
7248
+ __spreadProps(__spreadValues({}, selectedItem), { props: newProps }),
7249
+ "replace"
7250
+ );
7251
+ const latestSelector = getSelectorForId(
7252
+ appStore.getState().state,
7253
+ selectedItem.props.id
7254
+ );
7255
+ if (!latestSelector) return;
7240
7256
  dispatch({
7241
7257
  type: "replace",
7242
- destinationIndex: itemSelector.index,
7243
- destinationZone: itemSelector.zone || rootDroppableId,
7244
- data: (yield resolveComponentData2(
7245
- __spreadProps(__spreadValues({}, selectedItem), { props: newProps }),
7258
+ destinationIndex: latestSelector.index,
7259
+ destinationZone: latestSelector.zone || rootDroppableId,
7260
+ data: resolved.node,
7261
+ ui: updatedUi
7262
+ });
7263
+ return;
7264
+ }
7265
+ if (data.root.props) {
7266
+ dispatch({
7267
+ type: "replaceRoot",
7268
+ root: (yield resolveComponentData2(
7269
+ __spreadProps(__spreadValues({}, data.root), { props: newProps }),
7246
7270
  "replace"
7247
7271
  )).node,
7248
- ui: updatedUi
7272
+ ui: __spreadValues(__spreadValues({}, ui), updatedUi),
7273
+ recordHistory: true
7249
7274
  });
7250
- } else {
7251
- if (data.root.props) {
7252
- dispatch({
7253
- type: "replaceRoot",
7254
- root: (yield resolveComponentData2(
7255
- __spreadProps(__spreadValues({}, data.root), { props: newProps }),
7256
- "replace"
7257
- )).node,
7258
- ui: __spreadValues(__spreadValues({}, ui), updatedUi),
7259
- recordHistory: true
7260
- });
7261
- } else {
7262
- dispatch({
7263
- type: "setData",
7264
- data: { root: newProps }
7265
- });
7266
- }
7275
+ return;
7267
7276
  }
7277
+ dispatch({
7278
+ type: "setData",
7279
+ data: { root: newProps }
7280
+ });
7268
7281
  });
7269
7282
  var FieldsChild = ({ fieldName }) => {
7270
7283
  const field = useAppStore((s) => s.fields.fields[fieldName]);
@@ -9349,7 +9362,12 @@ function PuckProvider({ children }) {
9349
9362
  });
9350
9363
  })
9351
9364
  );
9352
- const initialHistoryIndex = (_initialHistory == null ? void 0 : _initialHistory.index) || blendedHistories.length - 1;
9365
+ const initialHistoryIndex = (0, import_react60.useMemo)(() => {
9366
+ if ((_initialHistory == null ? void 0 : _initialHistory.index) !== void 0 && (_initialHistory == null ? void 0 : _initialHistory.index) >= 0 && (_initialHistory == null ? void 0 : _initialHistory.index) < blendedHistories.length) {
9367
+ return _initialHistory == null ? void 0 : _initialHistory.index;
9368
+ }
9369
+ return blendedHistories.length - 1;
9370
+ }, []);
9353
9371
  const initialAppState = blendedHistories[initialHistoryIndex].state;
9354
9372
  const loadedOverrides = useLoadedOverrides({
9355
9373
  overrides,
package/dist/index.mjs CHANGED
@@ -18,14 +18,14 @@ import {
18
18
  setDeep,
19
19
  useGetPuck,
20
20
  usePuck
21
- } from "./chunk-JB4ZAK5S.mjs";
21
+ } from "./chunk-47DMTRCY.mjs";
22
22
  import {
23
23
  init_react_import,
24
24
  migrate,
25
25
  resolveAllData,
26
26
  transformProps,
27
27
  walkTree
28
- } from "./chunk-TC25DCTQ.mjs";
28
+ } from "./chunk-JA7SEUEH.mjs";
29
29
 
30
30
  // bundle/index.ts
31
31
  init_react_import();
@@ -1,4 +1,4 @@
1
- export { ad as Adaptor, A as AppState, ab as ArrayField, B as ArrayState, ar as AsFieldProps, X as BaseData, a5 as BaseField, af as CacheOpts, f as ComponentConfig, J as ComponentConfigExtensions, T as ComponentConfigParams, a as ComponentData, a0 as ComponentDataMap, _ as ComponentDataOptionalId, a3 as ComponentMetadata, C as Config, Q as ConfigParams, a1 as Content, ai as CustomField, ah as CustomFieldRender, j as Data, ao as DefaultComponentProps, L as DefaultComponents, al as DefaultRootFieldProps, an as DefaultRootProps, am as DefaultRootRenderProps, o as Direction, p as DragAxis, ag as ExternalField, ae as ExternalFieldWithAdaptor, N as ExtractConfigParams, at as ExtractField, h as Field, a4 as FieldMetadata, 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, $ as MappedItem, M as Metadata, a7 as NumberField, ac as ObjectField, k as OnAction, x as OverrideKey, O as Overrides, P as Permissions, d as Plugin, b as PuckAction, G as PuckComponent, ak as PuckContext, a2 as PuckMetadata, aa as RadioField, c as ResolveDataTrigger, K as RootConfig, Z as RootData, R as RootDataWithProps, Y as RootDataWithoutProps, a9 as SelectField, S as Slot, E as SlotComponent, aj as SlotField, a6 as TextField, a8 as TextareaField, e as UiState, U as UserGenerics, q as Viewport, V as Viewports, as as WithChildren, ap as WithId, aq as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-BMbIeiqs.mjs';
1
+ export { ad as Adaptor, A as AppState, ab as ArrayField, B as ArrayState, ar as AsFieldProps, X as BaseData, a5 as BaseField, af as CacheOpts, f as ComponentConfig, J as ComponentConfigExtensions, T as ComponentConfigParams, a as ComponentData, a0 as ComponentDataMap, _ as ComponentDataOptionalId, a3 as ComponentMetadata, C as Config, Q as ConfigParams, a1 as Content, ai as CustomField, ah as CustomFieldRender, j as Data, ao as DefaultComponentProps, L as DefaultComponents, al as DefaultRootFieldProps, an as DefaultRootProps, am as DefaultRootRenderProps, o as Direction, p as DragAxis, ag as ExternalField, ae as ExternalFieldWithAdaptor, N as ExtractConfigParams, at as ExtractField, h as Field, a4 as FieldMetadata, 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, $ as MappedItem, M as Metadata, a7 as NumberField, ac as ObjectField, k as OnAction, x as OverrideKey, O as Overrides, P as Permissions, d as Plugin, b as PuckAction, G as PuckComponent, ak as PuckContext, a2 as PuckMetadata, aa as RadioField, c as ResolveDataTrigger, K as RootConfig, Z as RootData, R as RootDataWithProps, Y as RootDataWithoutProps, a9 as SelectField, S as Slot, E as SlotComponent, aj as SlotField, a6 as TextField, a8 as TextareaField, e as UiState, U as UserGenerics, q as Viewport, V as Viewports, as as WithChildren, ap as WithId, aq as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-BjNPkzm9.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 { ad as Adaptor, A as AppState, ab as ArrayField, B as ArrayState, ar as AsFieldProps, X as BaseData, a5 as BaseField, af as CacheOpts, f as ComponentConfig, J as ComponentConfigExtensions, T as ComponentConfigParams, a as ComponentData, a0 as ComponentDataMap, _ as ComponentDataOptionalId, a3 as ComponentMetadata, C as Config, Q as ConfigParams, a1 as Content, ai as CustomField, ah as CustomFieldRender, j as Data, ao as DefaultComponentProps, L as DefaultComponents, al as DefaultRootFieldProps, an as DefaultRootProps, am as DefaultRootRenderProps, o as Direction, p as DragAxis, ag as ExternalField, ae as ExternalFieldWithAdaptor, N as ExtractConfigParams, at as ExtractField, h as Field, a4 as FieldMetadata, 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, $ as MappedItem, M as Metadata, a7 as NumberField, ac as ObjectField, k as OnAction, x as OverrideKey, O as Overrides, P as Permissions, d as Plugin, b as PuckAction, G as PuckComponent, ak as PuckContext, a2 as PuckMetadata, aa as RadioField, c as ResolveDataTrigger, K as RootConfig, Z as RootData, R as RootDataWithProps, Y as RootDataWithoutProps, a9 as SelectField, S as Slot, E as SlotComponent, aj as SlotField, a6 as TextField, a8 as TextareaField, e as UiState, U as UserGenerics, q as Viewport, V as Viewports, as as WithChildren, ap as WithId, aq as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-BMbIeiqs.js';
1
+ export { ad as Adaptor, A as AppState, ab as ArrayField, B as ArrayState, ar as AsFieldProps, X as BaseData, a5 as BaseField, af as CacheOpts, f as ComponentConfig, J as ComponentConfigExtensions, T as ComponentConfigParams, a as ComponentData, a0 as ComponentDataMap, _ as ComponentDataOptionalId, a3 as ComponentMetadata, C as Config, Q as ConfigParams, a1 as Content, ai as CustomField, ah as CustomFieldRender, j as Data, ao as DefaultComponentProps, L as DefaultComponents, al as DefaultRootFieldProps, an as DefaultRootProps, am as DefaultRootRenderProps, o as Direction, p as DragAxis, ag as ExternalField, ae as ExternalFieldWithAdaptor, N as ExtractConfigParams, at as ExtractField, h as Field, a4 as FieldMetadata, 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, $ as MappedItem, M as Metadata, a7 as NumberField, ac as ObjectField, k as OnAction, x as OverrideKey, O as Overrides, P as Permissions, d as Plugin, b as PuckAction, G as PuckComponent, ak as PuckContext, a2 as PuckMetadata, aa as RadioField, c as ResolveDataTrigger, K as RootConfig, Z as RootData, R as RootDataWithProps, Y as RootDataWithoutProps, a9 as SelectField, S as Slot, E as SlotComponent, aj as SlotField, a6 as TextField, a8 as TextareaField, e as UiState, U as UserGenerics, q as Viewport, V as Viewports, as as WithChildren, ap as WithId, aq as WithPuckProps, W as WithSlotProps, m as migrate, v as overrideKeys, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-BjNPkzm9.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';
@@ -1979,26 +1979,34 @@ var createPermissionsSlice = (set, get) => {
1979
1979
  const resolvePermissions = (..._0) => __async(null, [..._0], function* (params = {}, force) {
1980
1980
  const { state, permissions, config } = get();
1981
1981
  const { cache: cache2, globalPermissions } = permissions;
1982
- const resolveDataForItem = (item2, force2 = false) => __async(null, null, function* () {
1983
- var _a, _b, _c;
1982
+ const resolvePermissionsForItem = (item2, force2 = false) => __async(null, null, function* () {
1983
+ var _a, _b;
1984
1984
  const { config: config2, state: appState, setComponentLoading } = get();
1985
+ const itemCache = cache2[item2.props.id];
1986
+ const nodes = appState.indexes.nodes;
1987
+ const parentId = (_a = nodes[item2.props.id]) == null ? void 0 : _a.parentId;
1988
+ const parentNode = parentId ? nodes[parentId] : null;
1989
+ const parentData = (_b = parentNode == null ? void 0 : parentNode.data) != null ? _b : null;
1985
1990
  const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
1986
1991
  if (!componentConfig) {
1987
1992
  return;
1988
1993
  }
1989
1994
  const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
1990
1995
  if (componentConfig.resolvePermissions) {
1991
- const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
1992
- if (Object.values(changed).some((el) => el === true) || force2) {
1996
+ const changed = getChanged(item2, itemCache == null ? void 0 : itemCache.lastData);
1997
+ const propsChanged = Object.values(changed).some((el) => el === true);
1998
+ const parentChanged = (itemCache == null ? void 0 : itemCache.lastParentId) !== parentId;
1999
+ if (propsChanged || parentChanged || force2) {
1993
2000
  const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
1994
2001
  const resolvedPermissions = yield componentConfig.resolvePermissions(
1995
2002
  item2,
1996
2003
  {
1997
2004
  changed,
1998
- lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
2005
+ lastPermissions: (itemCache == null ? void 0 : itemCache.lastPermissions) || null,
1999
2006
  permissions: initialPermissions,
2000
2007
  appState: makeStatePublic(appState),
2001
- lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
2008
+ lastData: (itemCache == null ? void 0 : itemCache.lastData) || null,
2009
+ parent: parentData
2002
2010
  }
2003
2011
  );
2004
2012
  const latest = get().permissions;
@@ -2006,6 +2014,7 @@ var createPermissionsSlice = (set, get) => {
2006
2014
  permissions: __spreadProps(__spreadValues({}, latest), {
2007
2015
  cache: __spreadProps(__spreadValues({}, latest.cache), {
2008
2016
  [item2.props.id]: {
2017
+ lastParentId: parentId,
2009
2018
  lastData: item2,
2010
2019
  lastPermissions: resolvedPermissions
2011
2020
  }
@@ -2019,9 +2028,9 @@ var createPermissionsSlice = (set, get) => {
2019
2028
  }
2020
2029
  }
2021
2030
  });
2022
- const resolveDataForRoot = (force2 = false) => {
2031
+ const resolvePermissionsForRoot = (force2 = false) => {
2023
2032
  const { state: appState } = get();
2024
- resolveDataForItem(
2033
+ resolvePermissionsForItem(
2025
2034
  // Shim the root data in by conforming to component data shape
2026
2035
  {
2027
2036
  type: "root",
@@ -2032,16 +2041,16 @@ var createPermissionsSlice = (set, get) => {
2032
2041
  };
2033
2042
  const { item, type, root } = params;
2034
2043
  if (item) {
2035
- yield resolveDataForItem(item, force);
2044
+ yield resolvePermissionsForItem(item, force);
2036
2045
  } else if (type) {
2037
2046
  flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(null, null, function* () {
2038
- yield resolveDataForItem(item2, force);
2047
+ yield resolvePermissionsForItem(item2, force);
2039
2048
  }));
2040
2049
  } else if (root) {
2041
- resolveDataForRoot(force);
2050
+ resolvePermissionsForRoot(force);
2042
2051
  } else {
2043
2052
  flattenData(state, config).map((item2) => __async(null, null, function* () {
2044
- yield resolveDataForItem(item2, force);
2053
+ yield resolvePermissionsForItem(item2, force);
2045
2054
  }));
2046
2055
  }
2047
2056
  });
@@ -4427,6 +4436,7 @@ function AutoFieldInternal(props) {
4427
4436
  }
4428
4437
  return (_props) => null;
4429
4438
  }, [field.type]);
4439
+ const fieldKey = field.type === "custom" ? field.key : void 0;
4430
4440
  let FieldComponent = (0, import_react20.useMemo)(() => {
4431
4441
  if (field.type === "custom") {
4432
4442
  if (!field.render) {
@@ -4436,7 +4446,7 @@ function AutoFieldInternal(props) {
4436
4446
  } else if (field.type !== "slot") {
4437
4447
  return render[field.type];
4438
4448
  }
4439
- }, [field.type, render]);
4449
+ }, [field.type, fieldKey, render]);
4440
4450
  const { visible = true } = props.field;
4441
4451
  if (!visible) {
4442
4452
  return null;
@@ -5466,8 +5476,9 @@ var Item = ({
5466
5476
  );
5467
5477
  };
5468
5478
  var SlotRender = (0, import_react31.forwardRef)(
5469
- function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
5470
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className, style, ref, children: content.map((item) => {
5479
+ function SlotRenderInternal({ className, style, content, config, metadata, as }, ref) {
5480
+ const El = as != null ? as : "div";
5481
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(El, { className, style, ref, children: content.map((item) => {
5471
5482
  if (!config.components[item.type]) {
5472
5483
  return null;
5473
5484
  }
@@ -5982,7 +5993,8 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5982
5993
  style,
5983
5994
  className,
5984
5995
  minEmptyHeight: userMinEmptyHeight = 128,
5985
- collisionAxis
5996
+ collisionAxis,
5997
+ as
5986
5998
  }, userRef) {
5987
5999
  const ctx = (0, import_react34.useContext)(dropZoneContext);
5988
6000
  const appStoreApi = useAppStoreApi();
@@ -6125,8 +6137,9 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
6125
6137
  userMinEmptyHeight,
6126
6138
  ref
6127
6139
  });
6140
+ const El = as != null ? as : "div";
6128
6141
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
6129
- "div",
6142
+ El,
6130
6143
  {
6131
6144
  className: `${getClassName18({
6132
6145
  isRootZone,
@@ -6189,7 +6202,7 @@ var DropZoneRenderItem = ({
6189
6202
  };
6190
6203
  var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZoneRender, __spreadValues({}, props));
6191
6204
  var DropZoneRender = (0, import_react34.forwardRef)(
6192
- function DropZoneRenderInternal({ className, style, zone }, ref) {
6205
+ function DropZoneRenderInternal({ className, style, zone, as }, ref) {
6193
6206
  const ctx = (0, import_react34.useContext)(dropZoneContext);
6194
6207
  const { areaId = "root" } = ctx || {};
6195
6208
  const { config, data, metadata } = (0, import_react34.useContext)(renderContext);
@@ -6202,13 +6215,14 @@ var DropZoneRender = (0, import_react34.forwardRef)(
6202
6215
  }
6203
6216
  }
6204
6217
  }, [content]);
6218
+ const El = as != null ? as : "div";
6205
6219
  if (!data || !config) {
6206
6220
  return null;
6207
6221
  }
6208
6222
  if (zoneCompound !== rootDroppableId) {
6209
6223
  content = setupZone(data, zoneCompound).zones[zoneCompound];
6210
6224
  }
6211
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className, style, ref, children: content.map((item) => {
6225
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(El, { className, style, ref, children: content.map((item) => {
6212
6226
  const Component = config.components[item.type];
6213
6227
  if (Component) {
6214
6228
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
@@ -6515,6 +6529,7 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
6515
6529
  // lib/insert-component.ts
6516
6530
  init_react_import();
6517
6531
  var insertComponent = (componentType, zone, index, appStore) => __async(null, null, function* () {
6532
+ const { getState } = appStore;
6518
6533
  const id = generateId(componentType);
6519
6534
  const insertActionData = {
6520
6535
  type: "insert",
@@ -6523,8 +6538,9 @@ var insertComponent = (componentType, zone, index, appStore) => __async(null, nu
6523
6538
  destinationZone: zone,
6524
6539
  id
6525
6540
  };
6526
- const { state, dispatch, resolveComponentData: resolveComponentData2 } = appStore;
6527
- const insertedState = insertAction(state, insertActionData, appStore);
6541
+ const stateBefore = getState().state;
6542
+ const insertedState = insertAction(stateBefore, insertActionData, getState());
6543
+ const dispatch = getState().dispatch;
6528
6544
  dispatch(__spreadProps(__spreadValues({}, insertActionData), {
6529
6545
  // Dispatch insert rather set, as user's may rely on this via onAction
6530
6546
  // We must always record history here so the insert is added to user history
@@ -6532,23 +6548,21 @@ var insertComponent = (componentType, zone, index, appStore) => __async(null, nu
6532
6548
  // entries on insert - one for the initial insert, and one when the data resolves
6533
6549
  recordHistory: true
6534
6550
  }));
6535
- const itemSelector = {
6536
- index,
6537
- zone
6538
- };
6551
+ const itemSelector = { index, zone };
6539
6552
  dispatch({ type: "setUi", ui: { itemSelector } });
6540
6553
  const itemData = getItem(itemSelector, insertedState);
6541
- if (itemData) {
6542
- const resolved = yield resolveComponentData2(itemData, "insert");
6543
- if (resolved.didChange) {
6544
- dispatch({
6545
- type: "replace",
6546
- destinationZone: itemSelector.zone,
6547
- destinationIndex: itemSelector.index,
6548
- data: resolved.node
6549
- });
6550
- }
6551
- }
6554
+ if (!itemData) return;
6555
+ const resolveComponentData2 = getState().resolveComponentData;
6556
+ const resolved = yield resolveComponentData2(itemData, "insert");
6557
+ if (!resolved.didChange) return;
6558
+ const latestItemSelector = getSelectorForId(getState().state, id);
6559
+ if (!latestItemSelector) return;
6560
+ dispatch({
6561
+ type: "replace",
6562
+ destinationZone: latestItemSelector.zone,
6563
+ destinationIndex: latestItemSelector.index,
6564
+ data: resolved.node
6565
+ });
6552
6566
  });
6553
6567
 
6554
6568
  // components/DragDropContext/index.tsx
@@ -6785,7 +6799,7 @@ var DragDropContextClient = ({
6785
6799
  thisPreview.componentType,
6786
6800
  thisPreview.zone,
6787
6801
  thisPreview.index,
6788
- appStore.getState()
6802
+ appStore
6789
6803
  );
6790
6804
  } else if (initialSelector.current) {
6791
6805
  dispatch({
@@ -7223,48 +7237,47 @@ var DefaultFields = ({
7223
7237
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children });
7224
7238
  };
7225
7239
  var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(null, null, function* () {
7226
- let currentProps;
7227
7240
  const { dispatch, state, selectedItem, resolveComponentData: resolveComponentData2 } = appStore.getState();
7228
7241
  const { data, ui } = state;
7229
7242
  const { itemSelector } = ui;
7230
7243
  const rootProps = data.root.props || data.root;
7231
- if (selectedItem) {
7232
- currentProps = selectedItem.props;
7233
- } else {
7234
- currentProps = rootProps;
7235
- }
7236
- const newProps = __spreadProps(__spreadValues({}, currentProps), {
7237
- [fieldName]: value
7238
- });
7244
+ const currentProps = selectedItem ? selectedItem.props : rootProps;
7245
+ const newProps = __spreadProps(__spreadValues({}, currentProps), { [fieldName]: value });
7239
7246
  if (selectedItem && itemSelector) {
7247
+ const resolved = yield resolveComponentData2(
7248
+ __spreadProps(__spreadValues({}, selectedItem), { props: newProps }),
7249
+ "replace"
7250
+ );
7251
+ const latestSelector = getSelectorForId(
7252
+ appStore.getState().state,
7253
+ selectedItem.props.id
7254
+ );
7255
+ if (!latestSelector) return;
7240
7256
  dispatch({
7241
7257
  type: "replace",
7242
- destinationIndex: itemSelector.index,
7243
- destinationZone: itemSelector.zone || rootDroppableId,
7244
- data: (yield resolveComponentData2(
7245
- __spreadProps(__spreadValues({}, selectedItem), { props: newProps }),
7258
+ destinationIndex: latestSelector.index,
7259
+ destinationZone: latestSelector.zone || rootDroppableId,
7260
+ data: resolved.node,
7261
+ ui: updatedUi
7262
+ });
7263
+ return;
7264
+ }
7265
+ if (data.root.props) {
7266
+ dispatch({
7267
+ type: "replaceRoot",
7268
+ root: (yield resolveComponentData2(
7269
+ __spreadProps(__spreadValues({}, data.root), { props: newProps }),
7246
7270
  "replace"
7247
7271
  )).node,
7248
- ui: updatedUi
7272
+ ui: __spreadValues(__spreadValues({}, ui), updatedUi),
7273
+ recordHistory: true
7249
7274
  });
7250
- } else {
7251
- if (data.root.props) {
7252
- dispatch({
7253
- type: "replaceRoot",
7254
- root: (yield resolveComponentData2(
7255
- __spreadProps(__spreadValues({}, data.root), { props: newProps }),
7256
- "replace"
7257
- )).node,
7258
- ui: __spreadValues(__spreadValues({}, ui), updatedUi),
7259
- recordHistory: true
7260
- });
7261
- } else {
7262
- dispatch({
7263
- type: "setData",
7264
- data: { root: newProps }
7265
- });
7266
- }
7275
+ return;
7267
7276
  }
7277
+ dispatch({
7278
+ type: "setData",
7279
+ data: { root: newProps }
7280
+ });
7268
7281
  });
7269
7282
  var FieldsChild = ({ fieldName }) => {
7270
7283
  const field = useAppStore((s) => s.fields.fields[fieldName]);
@@ -9349,7 +9362,12 @@ function PuckProvider({ children }) {
9349
9362
  });
9350
9363
  })
9351
9364
  );
9352
- const initialHistoryIndex = (_initialHistory == null ? void 0 : _initialHistory.index) || blendedHistories.length - 1;
9365
+ const initialHistoryIndex = (0, import_react60.useMemo)(() => {
9366
+ if ((_initialHistory == null ? void 0 : _initialHistory.index) !== void 0 && (_initialHistory == null ? void 0 : _initialHistory.index) >= 0 && (_initialHistory == null ? void 0 : _initialHistory.index) < blendedHistories.length) {
9367
+ return _initialHistory == null ? void 0 : _initialHistory.index;
9368
+ }
9369
+ return blendedHistories.length - 1;
9370
+ }, []);
9353
9371
  const initialAppState = blendedHistories[initialHistoryIndex].state;
9354
9372
  const loadedOverrides = useLoadedOverrides({
9355
9373
  overrides,
@@ -18,14 +18,14 @@ import {
18
18
  setDeep,
19
19
  useGetPuck,
20
20
  usePuck
21
- } from "./chunk-JB4ZAK5S.mjs";
21
+ } from "./chunk-47DMTRCY.mjs";
22
22
  import {
23
23
  init_react_import,
24
24
  migrate,
25
25
  resolveAllData,
26
26
  transformProps,
27
27
  walkTree
28
- } from "./chunk-TC25DCTQ.mjs";
28
+ } from "./chunk-JA7SEUEH.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-BMbIeiqs.mjs';
3
- export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-BMbIeiqs.mjs';
2
+ import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-BjNPkzm9.mjs';
3
+ export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-BjNPkzm9.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-BMbIeiqs.js';
3
- export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-BMbIeiqs.js';
2
+ import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-BjNPkzm9.js';
3
+ export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-BjNPkzm9.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
@@ -346,8 +346,9 @@ var Item = ({
346
346
  );
347
347
  };
348
348
  var SlotRender = (0, import_react3.forwardRef)(
349
- function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
350
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className, style, ref, children: content.map((item) => {
349
+ function SlotRenderInternal({ className, style, content, config, metadata, as }, ref) {
350
+ const El = as != null ? as : "div";
351
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(El, { className, style, ref, children: content.map((item) => {
351
352
  if (!config.components[item.type]) {
352
353
  return null;
353
354
  }
package/dist/rsc.mjs CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  transformProps,
13
13
  useSlots,
14
14
  walkTree
15
- } from "./chunk-TC25DCTQ.mjs";
15
+ } from "./chunk-JA7SEUEH.mjs";
16
16
 
17
17
  // bundle/rsc.tsx
18
18
  init_react_import();
@@ -1,4 +1,4 @@
1
- import { ReactElement, CSSProperties, ReactNode, JSX } from 'react';
1
+ import { ReactElement, CSSProperties, ElementType, ReactNode, JSX } from 'react';
2
2
 
3
3
  type ItemSelector = {
4
4
  index: number;
@@ -118,6 +118,7 @@ interface CustomField<Value extends any> extends BaseField {
118
118
  type: "custom";
119
119
  render: CustomFieldRender<Value>;
120
120
  contentEditable?: boolean;
121
+ key?: string;
121
122
  }
122
123
  interface SlotField extends BaseField {
123
124
  type: "slot";
@@ -148,6 +149,7 @@ type DropZoneProps = {
148
149
  minEmptyHeight?: number;
149
150
  className?: string;
150
151
  collisionAxis?: DragAxis;
152
+ as?: ElementType;
151
153
  };
152
154
 
153
155
  type PuckContext = {
@@ -238,6 +240,7 @@ UserField extends BaseField = {}> = {
238
240
  permissions: Partial<Permissions>;
239
241
  appState: AppState;
240
242
  lastData: DataShape | null;
243
+ parent: ComponentData | null;
241
244
  }) => Promise<Partial<Permissions>> | Partial<Permissions>;
242
245
  metadata?: ComponentMetadata;
243
246
  } & ComponentConfigExtensions;
@@ -1,4 +1,4 @@
1
- import { ReactElement, CSSProperties, ReactNode, JSX } from 'react';
1
+ import { ReactElement, CSSProperties, ElementType, ReactNode, JSX } from 'react';
2
2
 
3
3
  type ItemSelector = {
4
4
  index: number;
@@ -118,6 +118,7 @@ interface CustomField<Value extends any> extends BaseField {
118
118
  type: "custom";
119
119
  render: CustomFieldRender<Value>;
120
120
  contentEditable?: boolean;
121
+ key?: string;
121
122
  }
122
123
  interface SlotField extends BaseField {
123
124
  type: "slot";
@@ -148,6 +149,7 @@ type DropZoneProps = {
148
149
  minEmptyHeight?: number;
149
150
  className?: string;
150
151
  collisionAxis?: DragAxis;
152
+ as?: ElementType;
151
153
  };
152
154
 
153
155
  type PuckContext = {
@@ -238,6 +240,7 @@ UserField extends BaseField = {}> = {
238
240
  permissions: Partial<Permissions>;
239
241
  appState: AppState;
240
242
  lastData: DataShape | null;
243
+ parent: ComponentData | null;
241
244
  }) => Promise<Partial<Permissions>> | Partial<Permissions>;
242
245
  metadata?: ComponentMetadata;
243
246
  } & ComponentConfigExtensions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.21.0-canary.15fe8d60",
3
+ "version": "0.21.0-canary.1b69a8f3",
4
4
  "description": "The open-source visual editor for React",
5
5
  "author": "Chris Villa <chris@puckeditor.com>",
6
6
  "repository": "measuredco/puck",