@measured/puck 0.19.1-canary.c0055df8 → 0.19.1

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.
package/dist/index.mjs CHANGED
@@ -25,7 +25,7 @@ import {
25
25
  walkAppState,
26
26
  walkField,
27
27
  walkTree
28
- } from "./chunk-H4SMAS54.mjs";
28
+ } from "./chunk-IM42S4YL.mjs";
29
29
 
30
30
  // ../../node_modules/classnames/index.js
31
31
  var require_classnames = __commonJS({
@@ -813,9 +813,27 @@ var replaceAction = (state, action, appStore) => {
813
813
  `Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
814
814
  );
815
815
  }
816
- const data = populateIds(action.data, appStore.config);
816
+ const newSlotIds = [];
817
+ const data = walkTree(action.data, appStore.config, (contents, opts) => {
818
+ newSlotIds.push(`${opts.parentId}:${opts.propName}`);
819
+ return contents.map((item) => {
820
+ const id = generateId(item.type);
821
+ return __spreadProps(__spreadValues({}, item), {
822
+ props: __spreadValues({ id }, item.props)
823
+ });
824
+ });
825
+ });
826
+ const stateWithDeepSlotsRemoved = __spreadValues({}, state);
827
+ Object.keys(state.indexes.zones).forEach((zoneCompound) => {
828
+ const id = zoneCompound.split(":")[0];
829
+ if (id === originalId) {
830
+ if (!newSlotIds.includes(zoneCompound)) {
831
+ delete stateWithDeepSlotsRemoved.indexes.zones[zoneCompound];
832
+ }
833
+ }
834
+ });
817
835
  return walkAppState(
818
- state,
836
+ stateWithDeepSlotsRemoved,
819
837
  appStore.config,
820
838
  (content, zoneCompound) => {
821
839
  const newContent = [...content];
package/dist/rsc.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { a as Config, U as UserGenerics, M as Metadata } from './walk-tree-DBd3aQ_5.mjs';
3
- export { af as migrate, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-DBd3aQ_5.mjs';
2
+ import { a as Config, U as UserGenerics, M as Metadata } from './walk-tree-DrJNb8b-.mjs';
3
+ export { af as migrate, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-DrJNb8b-.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 { a as Config, U as UserGenerics, M as Metadata } from './walk-tree-DBd3aQ_5.js';
3
- export { af as migrate, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-DBd3aQ_5.js';
2
+ import { a as Config, U as UserGenerics, M as Metadata } from './walk-tree-DrJNb8b-.js';
3
+ export { af as migrate, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-DrJNb8b-.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
@@ -659,7 +659,7 @@ function forRelatedZones(item, data, cb, path = []) {
659
659
  }
660
660
 
661
661
  // lib/data/flatten-node.ts
662
- var import_flat = require("flat");
662
+ var import_flat = __toESM(require("flat"));
663
663
 
664
664
  // lib/data/strip-slots.ts
665
665
  var stripSlots = (data, config) => {
@@ -667,9 +667,10 @@ var stripSlots = (data, config) => {
667
667
  };
668
668
 
669
669
  // lib/data/flatten-node.ts
670
+ var { flatten: flatten2, unflatten } = import_flat.default;
670
671
  var flattenNode = (node, config) => {
671
672
  return __spreadProps(__spreadValues({}, node), {
672
- props: (0, import_flat.flatten)(stripSlots(node, config).props)
673
+ props: flatten2(stripSlots(node, config).props)
673
674
  });
674
675
  };
675
676
 
@@ -824,7 +825,7 @@ var migrations = [
824
825
  const { indexes } = walkAppState(appState, config);
825
826
  const deletedCompounds = [];
826
827
  walkAppState(appState, config, (content, zoneCompound, zoneType) => {
827
- var _a2, _b;
828
+ var _a2, _b, _c;
828
829
  if (zoneType === "dropzone") {
829
830
  const [id, slotName] = zoneCompound.split(":");
830
831
  const nodeData = indexes.nodes[id].data;
@@ -832,7 +833,7 @@ var migrations = [
832
833
  const configForComponent = id === "root" ? config.root : config.components[componentType];
833
834
  if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
834
835
  updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
835
- props: __spreadProps(__spreadValues({}, nodeData.props), {
836
+ props: __spreadProps(__spreadValues(__spreadValues({}, nodeData.props), (_c = updatedItems[id]) == null ? void 0 : _c.props), {
836
837
  [slotName]: content
837
838
  })
838
839
  });
package/dist/rsc.mjs CHANGED
@@ -1,14 +1,10 @@
1
1
  import {
2
2
  Render,
3
- init_react_import,
4
3
  migrate,
5
4
  resolveAllData,
6
5
  transformProps,
7
6
  walkTree
8
- } from "./chunk-H4SMAS54.mjs";
9
-
10
- // rsc.tsx
11
- init_react_import();
7
+ } from "./chunk-IM42S4YL.mjs";
12
8
  export {
13
9
  Render,
14
10
  migrate,
@@ -346,10 +346,11 @@ type PrivateAppState<UserData extends Data = Data> = AppState<UserData> & {
346
346
  };
347
347
  };
348
348
  type DefaultAllProps = Record<string, DefaultComponentProps>;
349
+ type BuiltinTypes = Date | RegExp | Error | Function | symbol | null | undefined;
349
350
  /**
350
351
  * Recursively walk T and replace Slots with SlotComponents
351
352
  */
352
- type WithDeepSlots<T, SlotType = T> = T extends Slot ? SlotType : T extends (infer U)[] ? Array<WithDeepSlots<U, SlotType>> : T extends (infer U)[] ? WithDeepSlots<U, SlotType>[] : T extends object ? {
353
+ type WithDeepSlots<T, SlotType = T> = T extends Slot ? SlotType : T extends (infer U)[] ? Array<WithDeepSlots<U, SlotType>> : T extends (infer U)[] ? WithDeepSlots<U, SlotType>[] : T extends BuiltinTypes ? T : T extends object ? {
353
354
  [K in keyof T]: WithDeepSlots<T[K], SlotType>;
354
355
  } : T;
355
356
 
@@ -346,10 +346,11 @@ type PrivateAppState<UserData extends Data = Data> = AppState<UserData> & {
346
346
  };
347
347
  };
348
348
  type DefaultAllProps = Record<string, DefaultComponentProps>;
349
+ type BuiltinTypes = Date | RegExp | Error | Function | symbol | null | undefined;
349
350
  /**
350
351
  * Recursively walk T and replace Slots with SlotComponents
351
352
  */
352
- type WithDeepSlots<T, SlotType = T> = T extends Slot ? SlotType : T extends (infer U)[] ? Array<WithDeepSlots<U, SlotType>> : T extends (infer U)[] ? WithDeepSlots<U, SlotType>[] : T extends object ? {
353
+ type WithDeepSlots<T, SlotType = T> = T extends Slot ? SlotType : T extends (infer U)[] ? Array<WithDeepSlots<U, SlotType>> : T extends (infer U)[] ? WithDeepSlots<U, SlotType>[] : T extends BuiltinTypes ? T : T extends object ? {
353
354
  [K in keyof T]: WithDeepSlots<T[K], SlotType>;
354
355
  } : T;
355
356
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.19.1-canary.c0055df8",
3
+ "version": "0.19.1",
4
4
  "author": "Chris Villa <chris@puckeditor.com>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",