@measured/puck 0.21.0-canary.ace4c8b3 → 0.21.0-canary.af48a401

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.
@@ -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
  });
@@ -5233,7 +5242,8 @@ var useMinEmptyHeight = ({
5233
5242
  }
5234
5243
  }
5235
5244
  }, [ref.current, draggedItem, onDragFinished]);
5236
- return [prevHeight || userMinEmptyHeight, isAnimating];
5245
+ const returnedMinHeight = isNaN(Number(userMinEmptyHeight)) ? userMinEmptyHeight : `${userMinEmptyHeight}px`;
5246
+ return [prevHeight ? `${prevHeight}px` : returnedMinHeight, isAnimating];
5237
5247
  };
5238
5248
 
5239
5249
  // lib/assign-refs.ts
@@ -5467,8 +5477,9 @@ var Item = ({
5467
5477
  );
5468
5478
  };
5469
5479
  var SlotRender = (0, import_react31.forwardRef)(
5470
- function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
5471
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className, style, ref, children: content.map((item) => {
5480
+ function SlotRenderInternal({ className, style, content, config, metadata, as }, ref) {
5481
+ const El = as != null ? as : "div";
5482
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(El, { className, style, ref, children: content.map((item) => {
5472
5483
  if (!config.components[item.type]) {
5473
5484
  return null;
5474
5485
  }
@@ -5982,8 +5993,9 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5982
5993
  disallow,
5983
5994
  style,
5984
5995
  className,
5985
- minEmptyHeight: userMinEmptyHeight = 128,
5986
- collisionAxis
5996
+ minEmptyHeight: userMinEmptyHeight = "128px",
5997
+ collisionAxis,
5998
+ as
5987
5999
  }, userRef) {
5988
6000
  const ctx = (0, import_react34.useContext)(dropZoneContext);
5989
6001
  const appStoreApi = useAppStoreApi();
@@ -6126,8 +6138,9 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
6126
6138
  userMinEmptyHeight,
6127
6139
  ref
6128
6140
  });
6141
+ const El = as != null ? as : "div";
6129
6142
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
6130
- "div",
6143
+ El,
6131
6144
  {
6132
6145
  className: `${getClassName18({
6133
6146
  isRootZone,
@@ -6143,7 +6156,7 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
6143
6156
  "data-testid": `dropzone:${zoneCompound}`,
6144
6157
  "data-puck-dropzone": zoneCompound,
6145
6158
  style: __spreadProps(__spreadValues({}, style), {
6146
- "--min-empty-height": `${minEmptyHeight}px`,
6159
+ "--min-empty-height": minEmptyHeight,
6147
6160
  backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
6148
6161
  }),
6149
6162
  children: contentIdsWithPreview.map((componentId, i) => {
@@ -6190,7 +6203,7 @@ var DropZoneRenderItem = ({
6190
6203
  };
6191
6204
  var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZoneRender, __spreadValues({}, props));
6192
6205
  var DropZoneRender = (0, import_react34.forwardRef)(
6193
- function DropZoneRenderInternal({ className, style, zone }, ref) {
6206
+ function DropZoneRenderInternal({ className, style, zone, as }, ref) {
6194
6207
  const ctx = (0, import_react34.useContext)(dropZoneContext);
6195
6208
  const { areaId = "root" } = ctx || {};
6196
6209
  const { config, data, metadata } = (0, import_react34.useContext)(renderContext);
@@ -6203,13 +6216,14 @@ var DropZoneRender = (0, import_react34.forwardRef)(
6203
6216
  }
6204
6217
  }
6205
6218
  }, [content]);
6219
+ const El = as != null ? as : "div";
6206
6220
  if (!data || !config) {
6207
6221
  return null;
6208
6222
  }
6209
6223
  if (zoneCompound !== rootDroppableId) {
6210
6224
  content = setupZone(data, zoneCompound).zones[zoneCompound];
6211
6225
  }
6212
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className, style, ref, children: content.map((item) => {
6226
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(El, { className, style, ref, children: content.map((item) => {
6213
6227
  const Component = config.components[item.type];
6214
6228
  if (Component) {
6215
6229
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
@@ -6516,6 +6530,7 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
6516
6530
  // lib/insert-component.ts
6517
6531
  init_react_import();
6518
6532
  var insertComponent = (componentType, zone, index, appStore) => __async(null, null, function* () {
6533
+ const { getState } = appStore;
6519
6534
  const id = generateId(componentType);
6520
6535
  const insertActionData = {
6521
6536
  type: "insert",
@@ -6524,8 +6539,9 @@ var insertComponent = (componentType, zone, index, appStore) => __async(null, nu
6524
6539
  destinationZone: zone,
6525
6540
  id
6526
6541
  };
6527
- const { state, dispatch, resolveComponentData: resolveComponentData2 } = appStore;
6528
- const insertedState = insertAction(state, insertActionData, appStore);
6542
+ const stateBefore = getState().state;
6543
+ const insertedState = insertAction(stateBefore, insertActionData, getState());
6544
+ const dispatch = getState().dispatch;
6529
6545
  dispatch(__spreadProps(__spreadValues({}, insertActionData), {
6530
6546
  // Dispatch insert rather set, as user's may rely on this via onAction
6531
6547
  // We must always record history here so the insert is added to user history
@@ -6533,23 +6549,21 @@ var insertComponent = (componentType, zone, index, appStore) => __async(null, nu
6533
6549
  // entries on insert - one for the initial insert, and one when the data resolves
6534
6550
  recordHistory: true
6535
6551
  }));
6536
- const itemSelector = {
6537
- index,
6538
- zone
6539
- };
6552
+ const itemSelector = { index, zone };
6540
6553
  dispatch({ type: "setUi", ui: { itemSelector } });
6541
6554
  const itemData = getItem(itemSelector, insertedState);
6542
- if (itemData) {
6543
- const resolved = yield resolveComponentData2(itemData, "insert");
6544
- if (resolved.didChange) {
6545
- dispatch({
6546
- type: "replace",
6547
- destinationZone: itemSelector.zone,
6548
- destinationIndex: itemSelector.index,
6549
- data: resolved.node
6550
- });
6551
- }
6552
- }
6555
+ if (!itemData) return;
6556
+ const resolveComponentData2 = getState().resolveComponentData;
6557
+ const resolved = yield resolveComponentData2(itemData, "insert");
6558
+ if (!resolved.didChange) return;
6559
+ const latestItemSelector = getSelectorForId(getState().state, id);
6560
+ if (!latestItemSelector) return;
6561
+ dispatch({
6562
+ type: "replace",
6563
+ destinationZone: latestItemSelector.zone,
6564
+ destinationIndex: latestItemSelector.index,
6565
+ data: resolved.node
6566
+ });
6553
6567
  });
6554
6568
 
6555
6569
  // components/DragDropContext/index.tsx
@@ -6786,7 +6800,7 @@ var DragDropContextClient = ({
6786
6800
  thisPreview.componentType,
6787
6801
  thisPreview.zone,
6788
6802
  thisPreview.index,
6789
- appStore.getState()
6803
+ appStore
6790
6804
  );
6791
6805
  } else if (initialSelector.current) {
6792
6806
  dispatch({
@@ -7224,48 +7238,47 @@ var DefaultFields = ({
7224
7238
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_jsx_runtime30.Fragment, { children });
7225
7239
  };
7226
7240
  var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(null, null, function* () {
7227
- let currentProps;
7228
7241
  const { dispatch, state, selectedItem, resolveComponentData: resolveComponentData2 } = appStore.getState();
7229
7242
  const { data, ui } = state;
7230
7243
  const { itemSelector } = ui;
7231
7244
  const rootProps = data.root.props || data.root;
7232
- if (selectedItem) {
7233
- currentProps = selectedItem.props;
7234
- } else {
7235
- currentProps = rootProps;
7236
- }
7237
- const newProps = __spreadProps(__spreadValues({}, currentProps), {
7238
- [fieldName]: value
7239
- });
7245
+ const currentProps = selectedItem ? selectedItem.props : rootProps;
7246
+ const newProps = __spreadProps(__spreadValues({}, currentProps), { [fieldName]: value });
7240
7247
  if (selectedItem && itemSelector) {
7248
+ const resolved = yield resolveComponentData2(
7249
+ __spreadProps(__spreadValues({}, selectedItem), { props: newProps }),
7250
+ "replace"
7251
+ );
7252
+ const latestSelector = getSelectorForId(
7253
+ appStore.getState().state,
7254
+ selectedItem.props.id
7255
+ );
7256
+ if (!latestSelector) return;
7241
7257
  dispatch({
7242
7258
  type: "replace",
7243
- destinationIndex: itemSelector.index,
7244
- destinationZone: itemSelector.zone || rootDroppableId,
7245
- data: (yield resolveComponentData2(
7246
- __spreadProps(__spreadValues({}, selectedItem), { props: newProps }),
7259
+ destinationIndex: latestSelector.index,
7260
+ destinationZone: latestSelector.zone || rootDroppableId,
7261
+ data: resolved.node,
7262
+ ui: updatedUi
7263
+ });
7264
+ return;
7265
+ }
7266
+ if (data.root.props) {
7267
+ dispatch({
7268
+ type: "replaceRoot",
7269
+ root: (yield resolveComponentData2(
7270
+ __spreadProps(__spreadValues({}, data.root), { props: newProps }),
7247
7271
  "replace"
7248
7272
  )).node,
7249
- ui: updatedUi
7273
+ ui: __spreadValues(__spreadValues({}, ui), updatedUi),
7274
+ recordHistory: true
7250
7275
  });
7251
- } else {
7252
- if (data.root.props) {
7253
- dispatch({
7254
- type: "replaceRoot",
7255
- root: (yield resolveComponentData2(
7256
- __spreadProps(__spreadValues({}, data.root), { props: newProps }),
7257
- "replace"
7258
- )).node,
7259
- ui: __spreadValues(__spreadValues({}, ui), updatedUi),
7260
- recordHistory: true
7261
- });
7262
- } else {
7263
- dispatch({
7264
- type: "setData",
7265
- data: { root: newProps }
7266
- });
7267
- }
7276
+ return;
7268
7277
  }
7278
+ dispatch({
7279
+ type: "setData",
7280
+ data: { root: newProps }
7281
+ });
7269
7282
  });
7270
7283
  var FieldsChild = ({ fieldName }) => {
7271
7284
  const field = useAppStore((s) => s.fields.fields[fieldName]);
@@ -8731,7 +8744,15 @@ var generateUsePuck = (store) => {
8731
8744
  selectedItem: store.selectedItem || null,
8732
8745
  getItemBySelector: (selector) => getItem(selector, store.state),
8733
8746
  getItemById: (id) => store.state.indexes.nodes[id].data,
8734
- getSelectorForId: (id) => getSelectorForId(store.state, id)
8747
+ getSelectorForId: (id) => getSelectorForId(store.state, id),
8748
+ getParentById: (id) => {
8749
+ const node = store.state.indexes.nodes[id];
8750
+ const parentId = node.parentId;
8751
+ if (parentId === null) return;
8752
+ const parentNode = store.state.indexes.nodes[parentId];
8753
+ if (!parentNode) return;
8754
+ return parentNode.data;
8755
+ }
8735
8756
  };
8736
8757
  return storeData;
8737
8758
  };
@@ -9350,7 +9371,12 @@ function PuckProvider({ children }) {
9350
9371
  });
9351
9372
  })
9352
9373
  );
9353
- const initialHistoryIndex = (_initialHistory == null ? void 0 : _initialHistory.index) || blendedHistories.length - 1;
9374
+ const initialHistoryIndex = (0, import_react60.useMemo)(() => {
9375
+ if ((_initialHistory == null ? void 0 : _initialHistory.index) !== void 0 && (_initialHistory == null ? void 0 : _initialHistory.index) >= 0 && (_initialHistory == null ? void 0 : _initialHistory.index) < blendedHistories.length) {
9376
+ return _initialHistory == null ? void 0 : _initialHistory.index;
9377
+ }
9378
+ return blendedHistories.length - 1;
9379
+ }, []);
9354
9380
  const initialAppState = blendedHistories[initialHistoryIndex].state;
9355
9381
  const loadedOverrides = useLoadedOverrides({
9356
9382
  overrides,
@@ -18,14 +18,14 @@ import {
18
18
  setDeep,
19
19
  useGetPuck,
20
20
  usePuck
21
- } from "./chunk-AIFI2M23.mjs";
21
+ } from "./chunk-UABEUL66.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-CkSoNBF7.mjs';
3
- export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-CkSoNBF7.mjs';
2
+ import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-CgWnYC1X.mjs';
3
+ export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-CgWnYC1X.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-CkSoNBF7.js';
3
- export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-CkSoNBF7.js';
2
+ import { C as Config, U as UserGenerics, M as Metadata } from './walk-tree-CgWnYC1X.js';
3
+ export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-CgWnYC1X.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, ReactNode, CSSProperties, ElementType, JSX } from 'react';
2
2
 
3
3
  type ItemSelector = {
4
4
  index: number;
@@ -53,7 +53,7 @@ interface ArrayField<Props extends {
53
53
  } ? Field<Props[0][SubPropName], UserField> | UserField : Field<Props[0][SubPropName], UserField>;
54
54
  };
55
55
  defaultItemProps?: Props[0] | ((index: number) => Props[0]);
56
- getItemSummary?: (item: Props[0], index?: number) => string;
56
+ getItemSummary?: (item: Props[0], index?: number) => ReactNode;
57
57
  max?: number;
58
58
  min?: number;
59
59
  }
@@ -80,7 +80,7 @@ type ExternalFieldWithAdaptor<Props extends any = {
80
80
  placeholder?: string;
81
81
  adaptor: Adaptor<any, any, Props>;
82
82
  adaptorParams?: object;
83
- getItemSummary: (item: NotUndefined<Props>, index?: number) => string;
83
+ getItemSummary: (item: NotUndefined<Props>, index?: number) => ReactNode;
84
84
  };
85
85
  type CacheOpts = {
86
86
  enabled?: boolean;
@@ -97,7 +97,7 @@ interface ExternalField<Props extends any = {
97
97
  }) => Promise<any[] | null>;
98
98
  mapProp?: (value: any) => Props;
99
99
  mapRow?: (value: any) => Record<string, string | number | ReactElement>;
100
- getItemSummary?: (item: NotUndefined<Props>, index?: number) => string;
100
+ getItemSummary?: (item: NotUndefined<Props>, index?: number) => ReactNode;
101
101
  showSearch?: boolean;
102
102
  renderFooter?: (props: {
103
103
  items: any[];
@@ -146,9 +146,10 @@ type DropZoneProps = {
146
146
  allow?: string[];
147
147
  disallow?: string[];
148
148
  style?: CSSProperties;
149
- minEmptyHeight?: number;
149
+ minEmptyHeight?: CSSProperties["minHeight"] | number;
150
150
  className?: string;
151
151
  collisionAxis?: DragAxis;
152
+ as?: ElementType;
152
153
  };
153
154
 
154
155
  type PuckContext = {
@@ -239,6 +240,7 @@ UserField extends BaseField = {}> = {
239
240
  permissions: Partial<Permissions>;
240
241
  appState: AppState;
241
242
  lastData: DataShape | null;
243
+ parent: ComponentData | null;
242
244
  }) => Promise<Partial<Permissions>> | Partial<Permissions>;
243
245
  metadata?: ComponentMetadata;
244
246
  } & ComponentConfigExtensions;
@@ -1,4 +1,4 @@
1
- import { ReactElement, CSSProperties, ReactNode, JSX } from 'react';
1
+ import { ReactElement, ReactNode, CSSProperties, ElementType, JSX } from 'react';
2
2
 
3
3
  type ItemSelector = {
4
4
  index: number;
@@ -53,7 +53,7 @@ interface ArrayField<Props extends {
53
53
  } ? Field<Props[0][SubPropName], UserField> | UserField : Field<Props[0][SubPropName], UserField>;
54
54
  };
55
55
  defaultItemProps?: Props[0] | ((index: number) => Props[0]);
56
- getItemSummary?: (item: Props[0], index?: number) => string;
56
+ getItemSummary?: (item: Props[0], index?: number) => ReactNode;
57
57
  max?: number;
58
58
  min?: number;
59
59
  }
@@ -80,7 +80,7 @@ type ExternalFieldWithAdaptor<Props extends any = {
80
80
  placeholder?: string;
81
81
  adaptor: Adaptor<any, any, Props>;
82
82
  adaptorParams?: object;
83
- getItemSummary: (item: NotUndefined<Props>, index?: number) => string;
83
+ getItemSummary: (item: NotUndefined<Props>, index?: number) => ReactNode;
84
84
  };
85
85
  type CacheOpts = {
86
86
  enabled?: boolean;
@@ -97,7 +97,7 @@ interface ExternalField<Props extends any = {
97
97
  }) => Promise<any[] | null>;
98
98
  mapProp?: (value: any) => Props;
99
99
  mapRow?: (value: any) => Record<string, string | number | ReactElement>;
100
- getItemSummary?: (item: NotUndefined<Props>, index?: number) => string;
100
+ getItemSummary?: (item: NotUndefined<Props>, index?: number) => ReactNode;
101
101
  showSearch?: boolean;
102
102
  renderFooter?: (props: {
103
103
  items: any[];
@@ -146,9 +146,10 @@ type DropZoneProps = {
146
146
  allow?: string[];
147
147
  disallow?: string[];
148
148
  style?: CSSProperties;
149
- minEmptyHeight?: number;
149
+ minEmptyHeight?: CSSProperties["minHeight"] | number;
150
150
  className?: string;
151
151
  collisionAxis?: DragAxis;
152
+ as?: ElementType;
152
153
  };
153
154
 
154
155
  type PuckContext = {
@@ -239,6 +240,7 @@ UserField extends BaseField = {}> = {
239
240
  permissions: Partial<Permissions>;
240
241
  appState: AppState;
241
242
  lastData: DataShape | null;
243
+ parent: ComponentData | null;
242
244
  }) => Promise<Partial<Permissions>> | Partial<Permissions>;
243
245
  metadata?: ComponentMetadata;
244
246
  } & ComponentConfigExtensions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.21.0-canary.ace4c8b3",
3
+ "version": "0.21.0-canary.af48a401",
4
4
  "description": "The open-source visual editor for React",
5
5
  "author": "Chris Villa <chris@puckeditor.com>",
6
6
  "repository": "measuredco/puck",