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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
  }
@@ -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({
@@ -3794,6 +3794,7 @@ function AutoFieldInternal(props) {
3794
3794
  }
3795
3795
  return (_props) => null;
3796
3796
  }, [field.type]);
3797
+ const fieldKey = field.type === "custom" ? field.key : void 0;
3797
3798
  let FieldComponent = useMemo3(() => {
3798
3799
  if (field.type === "custom") {
3799
3800
  if (!field.render) {
@@ -3803,7 +3804,7 @@ function AutoFieldInternal(props) {
3803
3804
  } else if (field.type !== "slot") {
3804
3805
  return render[field.type];
3805
3806
  }
3806
- }, [field.type, render]);
3807
+ }, [field.type, fieldKey, render]);
3807
3808
  const { visible = true } = props.field;
3808
3809
  if (!visible) {
3809
3810
  return null;
@@ -6086,7 +6087,8 @@ var DropZoneEdit = forwardRef3(
6086
6087
  style,
6087
6088
  className,
6088
6089
  minEmptyHeight: userMinEmptyHeight = 128,
6089
- collisionAxis
6090
+ collisionAxis,
6091
+ as
6090
6092
  }, userRef) {
6091
6093
  const ctx = useContext8(dropZoneContext);
6092
6094
  const appStoreApi = useAppStoreApi();
@@ -6229,8 +6231,9 @@ var DropZoneEdit = forwardRef3(
6229
6231
  userMinEmptyHeight,
6230
6232
  ref
6231
6233
  });
6234
+ const El = as != null ? as : "div";
6232
6235
  return /* @__PURE__ */ jsx26(
6233
- "div",
6236
+ El,
6234
6237
  {
6235
6238
  className: `${getClassName19({
6236
6239
  isRootZone,
@@ -6293,7 +6296,7 @@ var DropZoneRenderItem = ({
6293
6296
  };
6294
6297
  var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx26(DropZoneRender, __spreadValues({}, props));
6295
6298
  var DropZoneRender = forwardRef3(
6296
- function DropZoneRenderInternal({ className, style, zone }, ref) {
6299
+ function DropZoneRenderInternal({ className, style, zone, as }, ref) {
6297
6300
  const ctx = useContext8(dropZoneContext);
6298
6301
  const { areaId = "root" } = ctx || {};
6299
6302
  const { config, data, metadata } = useContext8(renderContext);
@@ -6306,13 +6309,14 @@ var DropZoneRender = forwardRef3(
6306
6309
  }
6307
6310
  }
6308
6311
  }, [content]);
6312
+ const El = as != null ? as : "div";
6309
6313
  if (!data || !config) {
6310
6314
  return null;
6311
6315
  }
6312
6316
  if (zoneCompound !== rootDroppableId) {
6313
6317
  content = setupZone(data, zoneCompound).zones[zoneCompound];
6314
6318
  }
6315
- return /* @__PURE__ */ jsx26("div", { className, style, ref, children: content.map((item) => {
6319
+ return /* @__PURE__ */ jsx26(El, { className, style, ref, children: content.map((item) => {
6316
6320
  const Component = config.components[item.type];
6317
6321
  if (Component) {
6318
6322
  return /* @__PURE__ */ jsx26(
@@ -8649,7 +8653,12 @@ function PuckProvider({ children }) {
8649
8653
  });
8650
8654
  })
8651
8655
  );
8652
- const initialHistoryIndex = (_initialHistory == null ? void 0 : _initialHistory.index) || blendedHistories.length - 1;
8656
+ const initialHistoryIndex = useMemo20(() => {
8657
+ if ((_initialHistory == null ? void 0 : _initialHistory.index) !== void 0 && (_initialHistory == null ? void 0 : _initialHistory.index) >= 0 && (_initialHistory == null ? void 0 : _initialHistory.index) < blendedHistories.length) {
8658
+ return _initialHistory == null ? void 0 : _initialHistory.index;
8659
+ }
8660
+ return blendedHistories.length - 1;
8661
+ }, []);
8653
8662
  const initialAppState = blendedHistories[initialHistoryIndex].state;
8654
8663
  const loadedOverrides = useLoadedOverrides({
8655
8664
  overrides,
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-BqwnaCVe.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-BqwnaCVe.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-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-BqwnaCVe.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-BqwnaCVe.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
@@ -4427,6 +4427,7 @@ function AutoFieldInternal(props) {
4427
4427
  }
4428
4428
  return (_props) => null;
4429
4429
  }, [field.type]);
4430
+ const fieldKey = field.type === "custom" ? field.key : void 0;
4430
4431
  let FieldComponent = (0, import_react20.useMemo)(() => {
4431
4432
  if (field.type === "custom") {
4432
4433
  if (!field.render) {
@@ -4436,7 +4437,7 @@ function AutoFieldInternal(props) {
4436
4437
  } else if (field.type !== "slot") {
4437
4438
  return render[field.type];
4438
4439
  }
4439
- }, [field.type, render]);
4440
+ }, [field.type, fieldKey, render]);
4440
4441
  const { visible = true } = props.field;
4441
4442
  if (!visible) {
4442
4443
  return null;
@@ -5466,8 +5467,9 @@ var Item = ({
5466
5467
  );
5467
5468
  };
5468
5469
  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) => {
5470
+ function SlotRenderInternal({ className, style, content, config, metadata, as }, ref) {
5471
+ const El = as != null ? as : "div";
5472
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(El, { className, style, ref, children: content.map((item) => {
5471
5473
  if (!config.components[item.type]) {
5472
5474
  return null;
5473
5475
  }
@@ -5982,7 +5984,8 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5982
5984
  style,
5983
5985
  className,
5984
5986
  minEmptyHeight: userMinEmptyHeight = 128,
5985
- collisionAxis
5987
+ collisionAxis,
5988
+ as
5986
5989
  }, userRef) {
5987
5990
  const ctx = (0, import_react34.useContext)(dropZoneContext);
5988
5991
  const appStoreApi = useAppStoreApi();
@@ -6125,8 +6128,9 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
6125
6128
  userMinEmptyHeight,
6126
6129
  ref
6127
6130
  });
6131
+ const El = as != null ? as : "div";
6128
6132
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
6129
- "div",
6133
+ El,
6130
6134
  {
6131
6135
  className: `${getClassName18({
6132
6136
  isRootZone,
@@ -6189,7 +6193,7 @@ var DropZoneRenderItem = ({
6189
6193
  };
6190
6194
  var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZoneRender, __spreadValues({}, props));
6191
6195
  var DropZoneRender = (0, import_react34.forwardRef)(
6192
- function DropZoneRenderInternal({ className, style, zone }, ref) {
6196
+ function DropZoneRenderInternal({ className, style, zone, as }, ref) {
6193
6197
  const ctx = (0, import_react34.useContext)(dropZoneContext);
6194
6198
  const { areaId = "root" } = ctx || {};
6195
6199
  const { config, data, metadata } = (0, import_react34.useContext)(renderContext);
@@ -6202,13 +6206,14 @@ var DropZoneRender = (0, import_react34.forwardRef)(
6202
6206
  }
6203
6207
  }
6204
6208
  }, [content]);
6209
+ const El = as != null ? as : "div";
6205
6210
  if (!data || !config) {
6206
6211
  return null;
6207
6212
  }
6208
6213
  if (zoneCompound !== rootDroppableId) {
6209
6214
  content = setupZone(data, zoneCompound).zones[zoneCompound];
6210
6215
  }
6211
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className, style, ref, children: content.map((item) => {
6216
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(El, { className, style, ref, children: content.map((item) => {
6212
6217
  const Component = config.components[item.type];
6213
6218
  if (Component) {
6214
6219
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
@@ -9349,7 +9354,12 @@ function PuckProvider({ children }) {
9349
9354
  });
9350
9355
  })
9351
9356
  );
9352
- const initialHistoryIndex = (_initialHistory == null ? void 0 : _initialHistory.index) || blendedHistories.length - 1;
9357
+ const initialHistoryIndex = (0, import_react60.useMemo)(() => {
9358
+ if ((_initialHistory == null ? void 0 : _initialHistory.index) !== void 0 && (_initialHistory == null ? void 0 : _initialHistory.index) >= 0 && (_initialHistory == null ? void 0 : _initialHistory.index) < blendedHistories.length) {
9359
+ return _initialHistory == null ? void 0 : _initialHistory.index;
9360
+ }
9361
+ return blendedHistories.length - 1;
9362
+ }, []);
9353
9363
  const initialAppState = blendedHistories[initialHistoryIndex].state;
9354
9364
  const loadedOverrides = useLoadedOverrides({
9355
9365
  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-VL643U2B.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-BqwnaCVe.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-BqwnaCVe.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';
@@ -4427,6 +4427,7 @@ function AutoFieldInternal(props) {
4427
4427
  }
4428
4428
  return (_props) => null;
4429
4429
  }, [field.type]);
4430
+ const fieldKey = field.type === "custom" ? field.key : void 0;
4430
4431
  let FieldComponent = (0, import_react20.useMemo)(() => {
4431
4432
  if (field.type === "custom") {
4432
4433
  if (!field.render) {
@@ -4436,7 +4437,7 @@ function AutoFieldInternal(props) {
4436
4437
  } else if (field.type !== "slot") {
4437
4438
  return render[field.type];
4438
4439
  }
4439
- }, [field.type, render]);
4440
+ }, [field.type, fieldKey, render]);
4440
4441
  const { visible = true } = props.field;
4441
4442
  if (!visible) {
4442
4443
  return null;
@@ -5466,8 +5467,9 @@ var Item = ({
5466
5467
  );
5467
5468
  };
5468
5469
  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) => {
5470
+ function SlotRenderInternal({ className, style, content, config, metadata, as }, ref) {
5471
+ const El = as != null ? as : "div";
5472
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(El, { className, style, ref, children: content.map((item) => {
5471
5473
  if (!config.components[item.type]) {
5472
5474
  return null;
5473
5475
  }
@@ -5982,7 +5984,8 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
5982
5984
  style,
5983
5985
  className,
5984
5986
  minEmptyHeight: userMinEmptyHeight = 128,
5985
- collisionAxis
5987
+ collisionAxis,
5988
+ as
5986
5989
  }, userRef) {
5987
5990
  const ctx = (0, import_react34.useContext)(dropZoneContext);
5988
5991
  const appStoreApi = useAppStoreApi();
@@ -6125,8 +6128,9 @@ var DropZoneEdit = (0, import_react34.forwardRef)(
6125
6128
  userMinEmptyHeight,
6126
6129
  ref
6127
6130
  });
6131
+ const El = as != null ? as : "div";
6128
6132
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
6129
- "div",
6133
+ El,
6130
6134
  {
6131
6135
  className: `${getClassName18({
6132
6136
  isRootZone,
@@ -6189,7 +6193,7 @@ var DropZoneRenderItem = ({
6189
6193
  };
6190
6194
  var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropZoneRender, __spreadValues({}, props));
6191
6195
  var DropZoneRender = (0, import_react34.forwardRef)(
6192
- function DropZoneRenderInternal({ className, style, zone }, ref) {
6196
+ function DropZoneRenderInternal({ className, style, zone, as }, ref) {
6193
6197
  const ctx = (0, import_react34.useContext)(dropZoneContext);
6194
6198
  const { areaId = "root" } = ctx || {};
6195
6199
  const { config, data, metadata } = (0, import_react34.useContext)(renderContext);
@@ -6202,13 +6206,14 @@ var DropZoneRender = (0, import_react34.forwardRef)(
6202
6206
  }
6203
6207
  }
6204
6208
  }, [content]);
6209
+ const El = as != null ? as : "div";
6205
6210
  if (!data || !config) {
6206
6211
  return null;
6207
6212
  }
6208
6213
  if (zoneCompound !== rootDroppableId) {
6209
6214
  content = setupZone(data, zoneCompound).zones[zoneCompound];
6210
6215
  }
6211
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className, style, ref, children: content.map((item) => {
6216
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(El, { className, style, ref, children: content.map((item) => {
6212
6217
  const Component = config.components[item.type];
6213
6218
  if (Component) {
6214
6219
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
@@ -9349,7 +9354,12 @@ function PuckProvider({ children }) {
9349
9354
  });
9350
9355
  })
9351
9356
  );
9352
- const initialHistoryIndex = (_initialHistory == null ? void 0 : _initialHistory.index) || blendedHistories.length - 1;
9357
+ const initialHistoryIndex = (0, import_react60.useMemo)(() => {
9358
+ if ((_initialHistory == null ? void 0 : _initialHistory.index) !== void 0 && (_initialHistory == null ? void 0 : _initialHistory.index) >= 0 && (_initialHistory == null ? void 0 : _initialHistory.index) < blendedHistories.length) {
9359
+ return _initialHistory == null ? void 0 : _initialHistory.index;
9360
+ }
9361
+ return blendedHistories.length - 1;
9362
+ }, []);
9353
9363
  const initialAppState = blendedHistories[initialHistoryIndex].state;
9354
9364
  const loadedOverrides = useLoadedOverrides({
9355
9365
  overrides,
@@ -18,14 +18,14 @@ import {
18
18
  setDeep,
19
19
  useGetPuck,
20
20
  usePuck
21
- } from "./chunk-JB4ZAK5S.mjs";
21
+ } from "./chunk-VL643U2B.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-BqwnaCVe.mjs';
3
+ export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-BqwnaCVe.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-BqwnaCVe.js';
3
+ export { m as migrate, r as resolveAllData, t as transformProps, w as walkTree } from './walk-tree-BqwnaCVe.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 = {
@@ -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 = {
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.1cec93c4",
4
4
  "description": "The open-source visual editor for React",
5
5
  "author": "Chris Villa <chris@puckeditor.com>",
6
6
  "repository": "measuredco/puck",