@measured/puck 0.19.0-canary.8d459e4e → 0.19.0-canary.91cb9cee

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/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 './resolve-all-data-DtB0OZRl.mjs';
3
- export { ad as resolveAllData, ac as transformProps } from './resolve-all-data-DtB0OZRl.mjs';
2
+ import { a as Config, U as UserGenerics, M as Metadata } from './walk-tree-DOB5QZVq.mjs';
3
+ export { af as migrate, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-DOB5QZVq.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 './resolve-all-data-DtB0OZRl.js';
3
- export { ad as resolveAllData, ac as transformProps } from './resolve-all-data-DtB0OZRl.js';
2
+ import { a as Config, U as UserGenerics, M as Metadata } from './walk-tree-DOB5QZVq.js';
3
+ export { af as migrate, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-DOB5QZVq.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
@@ -68,8 +68,10 @@ var __async = (__this, __arguments, generator) => {
68
68
  var rsc_exports = {};
69
69
  __export(rsc_exports, {
70
70
  Render: () => Render,
71
+ migrate: () => migrate,
71
72
  resolveAllData: () => resolveAllData,
72
- transformProps: () => transformProps
73
+ transformProps: () => transformProps,
74
+ walkTree: () => walkTree
73
75
  });
74
76
  module.exports = __toCommonJS(rsc_exports);
75
77
 
@@ -118,7 +120,11 @@ function useSlots(config, props, renderSlotEdit, renderSlotRender = renderSlotEd
118
120
  }
119
121
  return slotProps2;
120
122
  }, [config, readOnly, forceReadOnly]);
121
- return __spreadValues(__spreadValues({}, props), slotProps);
123
+ const mergedProps = (0, import_react2.useMemo)(
124
+ () => __spreadValues(__spreadValues({}, props), slotProps),
125
+ [props, slotProps]
126
+ );
127
+ return mergedProps;
122
128
  }
123
129
 
124
130
  // components/SlotRender/server.tsx
@@ -286,6 +292,23 @@ function mapSlotsAsync(_0, _1) {
286
292
  return __spreadProps(__spreadValues({}, item), { props });
287
293
  });
288
294
  }
295
+ function mapSlotsSync(item, map, isSlot2 = isSlot) {
296
+ var _a, _b;
297
+ const props = __spreadValues({}, item.props);
298
+ const propKeys = Object.keys(props);
299
+ for (let i = 0; i < propKeys.length; i++) {
300
+ const propKey = propKeys[i];
301
+ const itemType = "type" in item ? item.type : "root";
302
+ if (isSlot2(itemType, propKey, props[propKey])) {
303
+ const content = props[propKey];
304
+ const mappedContent = content.map((item2) => {
305
+ return mapSlotsSync(item2, map, isSlot2);
306
+ });
307
+ props[propKey] = (_b = map(mappedContent, (_a = props.id) != null ? _a : "root", propKey)) != null ? _b : mappedContent;
308
+ }
309
+ }
310
+ return __spreadProps(__spreadValues({}, item), { props });
311
+ }
289
312
 
290
313
  // lib/get-changed.ts
291
314
  var getChanged = (newItem, oldItem) => {
@@ -426,12 +449,46 @@ function resolveAllData(_0, _1) {
426
449
  });
427
450
  }
428
451
 
452
+ // lib/data/walk-tree.ts
453
+ function walkTree(data, config, callbackFn) {
454
+ var _a, _b;
455
+ const isSlot2 = createIsSlotConfig(config);
456
+ const walkItem = (item) => {
457
+ return mapSlotsSync(
458
+ item,
459
+ (content, parentId, propName) => callbackFn(content, { parentId, propName }),
460
+ isSlot2
461
+ );
462
+ };
463
+ if ("props" in data) {
464
+ return walkItem(data);
465
+ }
466
+ const _data = data;
467
+ const zones = (_a = _data.zones) != null ? _a : {};
468
+ const mappedContent = _data.content.map(walkItem);
469
+ return {
470
+ root: walkItem(_data.root),
471
+ content: (_b = callbackFn(mappedContent, {
472
+ parentId: "root",
473
+ propName: "default-zone"
474
+ })) != null ? _b : mappedContent,
475
+ zones: Object.keys(zones).reduce(
476
+ (acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
477
+ [zoneCompound]: zones[zoneCompound].map(walkItem)
478
+ }),
479
+ {}
480
+ )
481
+ };
482
+ }
483
+
429
484
  // lib/transform-props.ts
430
- function transformProps(data, propTransforms) {
485
+ function transformProps(data, propTransforms, config = { components: {} }) {
431
486
  const mapItem = (item) => {
432
487
  if (propTransforms[item.type]) {
433
488
  return __spreadProps(__spreadValues({}, item), {
434
- props: propTransforms[item.type](item.props)
489
+ props: __spreadValues({
490
+ id: item.props.id
491
+ }, propTransforms[item.type](item.props))
435
492
  });
436
493
  }
437
494
  return item;
@@ -440,27 +497,318 @@ function transformProps(data, propTransforms) {
440
497
  const rootProps = defaultedData.root.props || defaultedData.root;
441
498
  let newRoot = __spreadValues({}, defaultedData.root);
442
499
  if (propTransforms["root"]) {
443
- if (defaultedData.root.props) {
444
- newRoot.props = propTransforms["root"](rootProps);
445
- } else {
446
- newRoot = propTransforms["root"](rootProps);
500
+ newRoot.props = propTransforms["root"](rootProps);
501
+ }
502
+ const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
503
+ const updatedData = walkTree(
504
+ dataWithUpdatedRoot,
505
+ config,
506
+ (content) => content.map(mapItem)
507
+ );
508
+ if (!defaultedData.root.props) {
509
+ updatedData.root = updatedData.root.props;
510
+ }
511
+ return updatedData;
512
+ }
513
+
514
+ // components/ViewportControls/default-viewports.ts
515
+ var defaultViewports = [
516
+ { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
517
+ { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
518
+ { width: 1280, height: "auto", icon: "Monitor", label: "Large" }
519
+ ];
520
+
521
+ // store/default-app-state.ts
522
+ var defaultAppState = {
523
+ data: { content: [], root: {}, zones: {} },
524
+ ui: {
525
+ leftSideBarVisible: true,
526
+ rightSideBarVisible: true,
527
+ arrayState: {},
528
+ itemSelector: null,
529
+ componentList: {},
530
+ isDragging: false,
531
+ previewMode: "edit",
532
+ viewports: {
533
+ current: {
534
+ width: defaultViewports[0].width,
535
+ height: defaultViewports[0].height || "auto"
536
+ },
537
+ options: [],
538
+ controlsVisible: true
539
+ },
540
+ field: { focus: null }
541
+ },
542
+ indexes: {
543
+ nodes: {},
544
+ zones: {}
545
+ }
546
+ };
547
+
548
+ // lib/data/for-each-slot.ts
549
+ var forEachSlot = (item, cb, recursive = false, isSlot2 = isSlot) => {
550
+ const props = item.props || {};
551
+ const propKeys = Object.keys(props);
552
+ for (let i = 0; i < propKeys.length; i++) {
553
+ const propKey = propKeys[i];
554
+ const itemType = "type" in item ? item.type : "root";
555
+ if (isSlot2(itemType, propKey, props[propKey])) {
556
+ const content = props[propKey];
557
+ cb(props.id, propKey, content);
558
+ if (recursive) {
559
+ content.forEach(
560
+ (childItem) => __async(void 0, null, function* () {
561
+ return forEachSlot(childItem, cb, true, isSlot2);
562
+ })
563
+ );
564
+ }
447
565
  }
448
566
  }
449
- const afterPropTransforms = __spreadProps(__spreadValues({}, defaultedData), {
450
- root: newRoot,
451
- content: defaultedData.content.map(mapItem),
452
- zones: Object.keys(data.zones || {}).reduce(
453
- (acc, zoneKey) => __spreadProps(__spreadValues({}, acc), {
454
- [zoneKey]: data.zones[zoneKey].map(mapItem)
455
- }),
456
- {}
567
+ };
568
+
569
+ // lib/get-zone-id.ts
570
+ var getZoneId = (zoneCompound) => {
571
+ if (!zoneCompound) {
572
+ return [];
573
+ }
574
+ if (zoneCompound && zoneCompound.indexOf(":") > -1) {
575
+ return zoneCompound.split(":");
576
+ }
577
+ return [rootDroppableId, zoneCompound];
578
+ };
579
+
580
+ // lib/data/for-related-zones.ts
581
+ function forRelatedZones(item, data, cb, path = []) {
582
+ Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
583
+ const [parentId] = getZoneId(zoneCompound);
584
+ if (parentId === item.props.id) {
585
+ cb(path, zoneCompound, content);
586
+ }
587
+ });
588
+ }
589
+
590
+ // lib/data/strip-slots.ts
591
+ var stripSlots = (data) => {
592
+ return __spreadProps(__spreadValues({}, data), {
593
+ props: Object.entries(data.props).reduce(
594
+ (acc, [propKey, propVal]) => {
595
+ if (isSlot(propVal)) {
596
+ return acc;
597
+ }
598
+ return __spreadProps(__spreadValues({}, acc), { [propKey]: propVal });
599
+ },
600
+ { id: data.props.id }
457
601
  )
458
602
  });
459
- return afterPropTransforms;
603
+ };
604
+
605
+ // lib/data/walk-app-state.ts
606
+ function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
607
+ var _a;
608
+ let newZones = {};
609
+ const newZoneIndex = {};
610
+ const newNodeIndex = {};
611
+ const processContent = (path, zoneCompound, content, zoneType, newId) => {
612
+ var _a2;
613
+ const [parentId] = zoneCompound.split(":");
614
+ const mappedContent = ((_a2 = mapContent(content, zoneCompound, zoneType)) != null ? _a2 : content) || [];
615
+ const [_2, zone] = zoneCompound.split(":");
616
+ const newZoneCompound = `${newId || parentId}:${zone}`;
617
+ const newContent2 = mappedContent.map(
618
+ (zoneChild, index) => processItem(zoneChild, [...path, newZoneCompound], index)
619
+ );
620
+ newZoneIndex[newZoneCompound] = {
621
+ contentIds: newContent2.map((item) => item.props.id),
622
+ type: zoneType
623
+ };
624
+ return [newZoneCompound, newContent2];
625
+ };
626
+ const processRelatedZones = (item, newId, initialPath) => {
627
+ forRelatedZones(
628
+ item,
629
+ state.data,
630
+ (relatedPath, relatedZoneCompound, relatedContent) => {
631
+ const [zoneCompound, newContent2] = processContent(
632
+ relatedPath,
633
+ relatedZoneCompound,
634
+ relatedContent,
635
+ "dropzone",
636
+ newId
637
+ );
638
+ newZones[zoneCompound] = newContent2;
639
+ },
640
+ initialPath
641
+ );
642
+ };
643
+ const processItem = (item, path, index) => {
644
+ const mappedItem = mapNodeOrSkip(item, path, index);
645
+ if (!mappedItem) return item;
646
+ const id = mappedItem.props.id;
647
+ const newProps = __spreadValues({}, mappedItem.props);
648
+ forEachSlot(
649
+ mappedItem,
650
+ (parentId2, slotId, content) => {
651
+ const zoneCompound = `${parentId2}:${slotId}`;
652
+ const [_2, newContent2] = processContent(
653
+ path,
654
+ zoneCompound,
655
+ content,
656
+ "slot",
657
+ parentId2
658
+ );
659
+ newProps[slotId] = newContent2;
660
+ },
661
+ false,
662
+ createIsSlotConfig(config)
663
+ );
664
+ processRelatedZones(item, id, path);
665
+ const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
666
+ const thisZoneCompound = path[path.length - 1];
667
+ const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
668
+ newNodeIndex[id] = {
669
+ data: newItem,
670
+ flatData: stripSlots(newItem),
671
+ path,
672
+ parentId,
673
+ zone
674
+ };
675
+ const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
676
+ if (newProps.id === "root") {
677
+ delete finalData["type"];
678
+ delete finalData.props["id"];
679
+ }
680
+ return finalData;
681
+ };
682
+ const zones = state.data.zones || {};
683
+ const [_, newContent] = processContent(
684
+ [],
685
+ rootDroppableId,
686
+ state.data.content,
687
+ "root"
688
+ );
689
+ const processedContent = newContent;
690
+ const zonesAlreadyProcessed = Object.keys(newZones);
691
+ Object.keys(zones || {}).forEach((zoneCompound) => {
692
+ const [parentId] = zoneCompound.split(":");
693
+ if (zonesAlreadyProcessed.includes(zoneCompound)) {
694
+ return;
695
+ }
696
+ const [_2, newContent2] = processContent(
697
+ [rootDroppableId],
698
+ zoneCompound,
699
+ zones[zoneCompound],
700
+ "dropzone",
701
+ parentId
702
+ );
703
+ newZones[zoneCompound] = newContent2;
704
+ }, newZones);
705
+ const processedRoot = processItem(
706
+ {
707
+ type: "root",
708
+ props: __spreadProps(__spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root), { id: "root" })
709
+ },
710
+ [],
711
+ -1
712
+ );
713
+ const root = __spreadProps(__spreadValues({}, state.data.root), {
714
+ props: processedRoot.props
715
+ });
716
+ return __spreadProps(__spreadValues({}, state), {
717
+ data: {
718
+ root,
719
+ content: processedContent,
720
+ zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
721
+ },
722
+ indexes: {
723
+ nodes: __spreadValues(__spreadValues({}, state.indexes.nodes), newNodeIndex),
724
+ zones: __spreadValues(__spreadValues({}, state.indexes.zones), newZoneIndex)
725
+ }
726
+ });
727
+ }
728
+
729
+ // lib/migrate.ts
730
+ var migrations = [
731
+ // Migrate root to root.props
732
+ (data) => {
733
+ const rootProps = data.root.props || data.root;
734
+ if (Object.keys(data.root).length > 0 && !data.root.props) {
735
+ console.warn(
736
+ "Migration applied: Root props moved from `root` to `root.props`."
737
+ );
738
+ return __spreadProps(__spreadValues({}, data), {
739
+ root: {
740
+ props: __spreadValues({}, rootProps)
741
+ }
742
+ });
743
+ }
744
+ return data;
745
+ },
746
+ // Migrate zones to slots
747
+ (data, config) => {
748
+ var _a;
749
+ if (!config) return data;
750
+ console.log("Migrating DropZones to slots...");
751
+ const updatedItems = {};
752
+ const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
753
+ const { indexes } = walkAppState(appState, config);
754
+ const deletedCompounds = [];
755
+ walkAppState(appState, config, (content, zoneCompound, zoneType) => {
756
+ var _a2, _b;
757
+ if (zoneType === "dropzone") {
758
+ const [id, slotName] = zoneCompound.split(":");
759
+ const nodeData = indexes.nodes[id].data;
760
+ const componentType = nodeData.type;
761
+ const configForComponent = id === "root" ? config.root : config.components[componentType];
762
+ if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
763
+ updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
764
+ props: __spreadProps(__spreadValues({}, nodeData.props), {
765
+ [slotName]: content
766
+ })
767
+ });
768
+ deletedCompounds.push(zoneCompound);
769
+ }
770
+ return content;
771
+ }
772
+ return content;
773
+ });
774
+ const updated = walkAppState(
775
+ appState,
776
+ config,
777
+ (content) => content,
778
+ (item) => {
779
+ var _a2;
780
+ return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
781
+ }
782
+ );
783
+ deletedCompounds.forEach((zoneCompound) => {
784
+ var _a2;
785
+ const [_, propName] = zoneCompound.split(":");
786
+ console.log(
787
+ `\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
788
+ );
789
+ (_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
790
+ });
791
+ Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
792
+ const [_, propName] = zoneCompound.split(":");
793
+ throw new Error(
794
+ `Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
795
+ );
796
+ });
797
+ delete updated.data.zones;
798
+ return updated.data;
799
+ }
800
+ ];
801
+ function migrate(data, config) {
802
+ return migrations == null ? void 0 : migrations.reduce(
803
+ (acc, migration) => migration(acc, config),
804
+ data
805
+ );
460
806
  }
461
807
  // Annotate the CommonJS export names for ESM import in node:
462
808
  0 && (module.exports = {
463
809
  Render,
810
+ migrate,
464
811
  resolveAllData,
465
- transformProps
812
+ transformProps,
813
+ walkTree
466
814
  });
package/dist/rsc.mjs CHANGED
@@ -1,14 +1,18 @@
1
1
  import {
2
2
  Render,
3
3
  init_react_import,
4
+ migrate,
4
5
  resolveAllData,
5
- transformProps
6
- } from "./chunk-D6ENWNOG.mjs";
6
+ transformProps,
7
+ walkTree
8
+ } from "./chunk-GL73J54P.mjs";
7
9
 
8
10
  // rsc.tsx
9
11
  init_react_import();
10
12
  export {
11
13
  Render,
14
+ migrate,
12
15
  resolveAllData,
13
- transformProps
16
+ transformProps,
17
+ walkTree
14
18
  };
@@ -255,22 +255,28 @@ type BaseData<Props extends {
255
255
  readOnly?: Partial<Record<keyof Props, boolean>>;
256
256
  };
257
257
  type RootDataWithProps<Props extends DefaultComponentProps = DefaultRootFieldProps> = BaseData<Props> & {
258
- props: Props;
258
+ props: WithSlotProps<Props>;
259
259
  };
260
260
  type RootDataWithoutProps<Props extends DefaultComponentProps = DefaultRootFieldProps> = Props;
261
261
  type RootData<Props extends DefaultComponentProps = DefaultRootFieldProps> = Partial<RootDataWithProps<AsFieldProps<Props>>> & Partial<RootDataWithoutProps<Props>>;
262
262
  type ComponentData<Props extends DefaultComponentProps = DefaultComponentProps, Name = string> = {
263
263
  type: Name;
264
- props: WithId<Props>;
264
+ props: WithId<WithSlotProps<Props>>;
265
+ } & BaseData<Props>;
266
+ type ComponentDataOptionalId<Props extends DefaultComponentProps = DefaultComponentProps, Name = string> = {
267
+ type: Name;
268
+ props: Props & {
269
+ id?: string;
270
+ };
265
271
  } & BaseData<Props>;
266
272
  type MappedItem = ComponentData;
267
273
  type ComponentDataMap<Props extends Record<string, DefaultComponentProps> = DefaultComponentProps> = {
268
274
  [K in keyof Props]: ComponentData<Props[K], K extends string ? K : never>;
269
275
  }[keyof Props];
270
276
  type Content<PropsMap extends {
271
- [key: string]: any;
277
+ [key: string]: DefaultComponentProps;
272
278
  } = {
273
- [key: string]: any;
279
+ [key: string]: DefaultComponentProps;
274
280
  }> = ComponentDataMap<PropsMap>[];
275
281
  type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = {
276
282
  root: RootData<RootProps>;
@@ -446,7 +452,16 @@ type InitialHistoryNoAppend<AS = Partial<AppState>> = {
446
452
  appendData?: false;
447
453
  };
448
454
  type InitialHistory<AS = Partial<AppState>> = InitialHistoryAppend<AS> | InitialHistoryNoAppend<AS>;
449
- type Slot = Content;
455
+ type Slot<Props extends {
456
+ [key: string]: DefaultComponentProps;
457
+ } = {
458
+ [key: string]: DefaultComponentProps;
459
+ }> = {
460
+ [K in keyof Props]: ComponentDataOptionalId<Props[K], K extends string ? K : never>;
461
+ }[keyof Props][];
462
+ type WithSlotProps<Props extends DefaultComponentProps = DefaultComponentProps, SlotProps extends DefaultComponentProps = Props> = Props extends any ? any : {
463
+ [PropName in keyof Props]: Props[PropName] extends Slot<SlotProps> ? Content<SlotProps> : Props[PropName];
464
+ };
450
465
 
451
466
  type InsertAction = {
452
467
  type: "insert";
@@ -514,6 +529,8 @@ type PuckAction = {
514
529
  recordHistory?: boolean;
515
530
  } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
516
531
 
532
+ declare function migrate(data: Data, config?: Config): Data;
533
+
517
534
  type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
518
535
  [ComponentName in keyof Props]: (props: Props[ComponentName] & {
519
536
  [key: string]: any;
@@ -523,8 +540,14 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
523
540
  [key: string]: any;
524
541
  }) => RootProps;
525
542
  }>;
526
- declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
543
+ declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>, config?: Config): Data;
527
544
 
528
545
  declare function resolveAllData<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, metadata?: Metadata, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Props, RootProps>>;
529
546
 
530
- export { type CustomField as $, type AppState as A, type BaseData as B, type ComponentData as C, type DropZoneProps as D, type ComponentDataMap as E, type Fields as F, type BaseField as G, type History as H, type IframeConfig as I, type TextareaField as J, type SelectField as K, type RadioField as L, type Metadata as M, type NumberField as N, type Overrides as O, type Permissions as P, type ArrayField as Q, type RootDataWithProps as R, type Slot as S, type TextField as T, type UserGenerics as U, type Viewports as V, type ObjectField as W, type Adaptor as X, type ExternalFieldWithAdaptor as Y, type ExternalField as Z, type CustomFieldRender as _, type Config as a, type SlotField as a0, type PuckContext as a1, type DefaultRootFieldProps as a2, type DefaultRootRenderProps as a3, type DefaultRootProps as a4, type DefaultComponentProps as a5, type WithId as a6, type WithPuckProps as a7, type AsFieldProps as a8, type WithChildren as a9, type ExtractPropsFromConfig as aa, type ExtractRootPropsFromConfig as ab, transformProps as ac, resolveAllData as ad, type PuckAction as b, type ResolveDataTrigger as c, type Plugin as d, type UiState as e, type ComponentConfig as f, type Field as g, type FieldProps as h, type Data as i, type OnAction as j, type InitialHistory as k, type RootData as l, type Content as m, type ItemSelector as n, type Direction as o, type DragAxis as p, type Viewport as q, overrideKeys as r, type OverrideKey as s, type FieldRenderFunctions as t, type ItemWithId as u, type ArrayState as v, type PuckComponent as w, type RootConfig as x, type RootDataWithoutProps as y, type MappedItem as z };
547
+ type WalkTreeOptions = {
548
+ parentId: string;
549
+ propName: string;
550
+ };
551
+ declare function walkTree<T extends ComponentData | RootData | G["UserData"], UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(data: T, config: UserConfig, callbackFn: (data: Content, options: WalkTreeOptions) => Content | null | void): T;
552
+
553
+ export { type ExternalFieldWithAdaptor as $, type AppState as A, type BaseData as B, type ComponentData as C, type DropZoneProps as D, type MappedItem as E, type Fields as F, type ComponentDataMap as G, type History as H, type IframeConfig as I, type Content as J, type BaseField as K, type TextareaField as L, type Metadata as M, type NumberField as N, type Overrides as O, type Permissions as P, type SelectField as Q, type RootDataWithProps as R, type Slot as S, type TextField as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type RadioField as X, type ArrayField as Y, type ObjectField as Z, type Adaptor as _, type Config as a, type ExternalField as a0, type CustomFieldRender as a1, type CustomField as a2, type SlotField as a3, type PuckContext as a4, type DefaultRootFieldProps as a5, type DefaultRootRenderProps as a6, type DefaultRootProps as a7, type DefaultComponentProps as a8, type WithId as a9, type WithPuckProps as aa, type AsFieldProps as ab, type WithChildren as ac, type ExtractPropsFromConfig as ad, type ExtractRootPropsFromConfig as ae, migrate as af, transformProps as ag, resolveAllData as ah, type PuckAction as b, type ResolveDataTrigger as c, type Plugin as d, type UiState as e, type ComponentConfig as f, type Field as g, type FieldProps as h, type Data as i, type OnAction as j, type InitialHistory as k, type ItemSelector as l, type Direction as m, type DragAxis as n, type Viewport as o, overrideKeys as p, type OverrideKey as q, type FieldRenderFunctions as r, type ItemWithId as s, type ArrayState as t, type PuckComponent as u, type RootConfig as v, walkTree as w, type RootDataWithoutProps as x, type RootData as y, type ComponentDataOptionalId as z };
@@ -255,22 +255,28 @@ type BaseData<Props extends {
255
255
  readOnly?: Partial<Record<keyof Props, boolean>>;
256
256
  };
257
257
  type RootDataWithProps<Props extends DefaultComponentProps = DefaultRootFieldProps> = BaseData<Props> & {
258
- props: Props;
258
+ props: WithSlotProps<Props>;
259
259
  };
260
260
  type RootDataWithoutProps<Props extends DefaultComponentProps = DefaultRootFieldProps> = Props;
261
261
  type RootData<Props extends DefaultComponentProps = DefaultRootFieldProps> = Partial<RootDataWithProps<AsFieldProps<Props>>> & Partial<RootDataWithoutProps<Props>>;
262
262
  type ComponentData<Props extends DefaultComponentProps = DefaultComponentProps, Name = string> = {
263
263
  type: Name;
264
- props: WithId<Props>;
264
+ props: WithId<WithSlotProps<Props>>;
265
+ } & BaseData<Props>;
266
+ type ComponentDataOptionalId<Props extends DefaultComponentProps = DefaultComponentProps, Name = string> = {
267
+ type: Name;
268
+ props: Props & {
269
+ id?: string;
270
+ };
265
271
  } & BaseData<Props>;
266
272
  type MappedItem = ComponentData;
267
273
  type ComponentDataMap<Props extends Record<string, DefaultComponentProps> = DefaultComponentProps> = {
268
274
  [K in keyof Props]: ComponentData<Props[K], K extends string ? K : never>;
269
275
  }[keyof Props];
270
276
  type Content<PropsMap extends {
271
- [key: string]: any;
277
+ [key: string]: DefaultComponentProps;
272
278
  } = {
273
- [key: string]: any;
279
+ [key: string]: DefaultComponentProps;
274
280
  }> = ComponentDataMap<PropsMap>[];
275
281
  type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = {
276
282
  root: RootData<RootProps>;
@@ -446,7 +452,16 @@ type InitialHistoryNoAppend<AS = Partial<AppState>> = {
446
452
  appendData?: false;
447
453
  };
448
454
  type InitialHistory<AS = Partial<AppState>> = InitialHistoryAppend<AS> | InitialHistoryNoAppend<AS>;
449
- type Slot = Content;
455
+ type Slot<Props extends {
456
+ [key: string]: DefaultComponentProps;
457
+ } = {
458
+ [key: string]: DefaultComponentProps;
459
+ }> = {
460
+ [K in keyof Props]: ComponentDataOptionalId<Props[K], K extends string ? K : never>;
461
+ }[keyof Props][];
462
+ type WithSlotProps<Props extends DefaultComponentProps = DefaultComponentProps, SlotProps extends DefaultComponentProps = Props> = Props extends any ? any : {
463
+ [PropName in keyof Props]: Props[PropName] extends Slot<SlotProps> ? Content<SlotProps> : Props[PropName];
464
+ };
450
465
 
451
466
  type InsertAction = {
452
467
  type: "insert";
@@ -514,6 +529,8 @@ type PuckAction = {
514
529
  recordHistory?: boolean;
515
530
  } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
516
531
 
532
+ declare function migrate(data: Data, config?: Config): Data;
533
+
517
534
  type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
518
535
  [ComponentName in keyof Props]: (props: Props[ComponentName] & {
519
536
  [key: string]: any;
@@ -523,8 +540,14 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
523
540
  [key: string]: any;
524
541
  }) => RootProps;
525
542
  }>;
526
- declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
543
+ declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>, config?: Config): Data;
527
544
 
528
545
  declare function resolveAllData<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, metadata?: Metadata, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Props, RootProps>>;
529
546
 
530
- export { type CustomField as $, type AppState as A, type BaseData as B, type ComponentData as C, type DropZoneProps as D, type ComponentDataMap as E, type Fields as F, type BaseField as G, type History as H, type IframeConfig as I, type TextareaField as J, type SelectField as K, type RadioField as L, type Metadata as M, type NumberField as N, type Overrides as O, type Permissions as P, type ArrayField as Q, type RootDataWithProps as R, type Slot as S, type TextField as T, type UserGenerics as U, type Viewports as V, type ObjectField as W, type Adaptor as X, type ExternalFieldWithAdaptor as Y, type ExternalField as Z, type CustomFieldRender as _, type Config as a, type SlotField as a0, type PuckContext as a1, type DefaultRootFieldProps as a2, type DefaultRootRenderProps as a3, type DefaultRootProps as a4, type DefaultComponentProps as a5, type WithId as a6, type WithPuckProps as a7, type AsFieldProps as a8, type WithChildren as a9, type ExtractPropsFromConfig as aa, type ExtractRootPropsFromConfig as ab, transformProps as ac, resolveAllData as ad, type PuckAction as b, type ResolveDataTrigger as c, type Plugin as d, type UiState as e, type ComponentConfig as f, type Field as g, type FieldProps as h, type Data as i, type OnAction as j, type InitialHistory as k, type RootData as l, type Content as m, type ItemSelector as n, type Direction as o, type DragAxis as p, type Viewport as q, overrideKeys as r, type OverrideKey as s, type FieldRenderFunctions as t, type ItemWithId as u, type ArrayState as v, type PuckComponent as w, type RootConfig as x, type RootDataWithoutProps as y, type MappedItem as z };
547
+ type WalkTreeOptions = {
548
+ parentId: string;
549
+ propName: string;
550
+ };
551
+ declare function walkTree<T extends ComponentData | RootData | G["UserData"], UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(data: T, config: UserConfig, callbackFn: (data: Content, options: WalkTreeOptions) => Content | null | void): T;
552
+
553
+ export { type ExternalFieldWithAdaptor as $, type AppState as A, type BaseData as B, type ComponentData as C, type DropZoneProps as D, type MappedItem as E, type Fields as F, type ComponentDataMap as G, type History as H, type IframeConfig as I, type Content as J, type BaseField as K, type TextareaField as L, type Metadata as M, type NumberField as N, type Overrides as O, type Permissions as P, type SelectField as Q, type RootDataWithProps as R, type Slot as S, type TextField as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type RadioField as X, type ArrayField as Y, type ObjectField as Z, type Adaptor as _, type Config as a, type ExternalField as a0, type CustomFieldRender as a1, type CustomField as a2, type SlotField as a3, type PuckContext as a4, type DefaultRootFieldProps as a5, type DefaultRootRenderProps as a6, type DefaultRootProps as a7, type DefaultComponentProps as a8, type WithId as a9, type WithPuckProps as aa, type AsFieldProps as ab, type WithChildren as ac, type ExtractPropsFromConfig as ad, type ExtractRootPropsFromConfig as ae, migrate as af, transformProps as ag, resolveAllData as ah, type PuckAction as b, type ResolveDataTrigger as c, type Plugin as d, type UiState as e, type ComponentConfig as f, type Field as g, type FieldProps as h, type Data as i, type OnAction as j, type InitialHistory as k, type ItemSelector as l, type Direction as m, type DragAxis as n, type Viewport as o, overrideKeys as p, type OverrideKey as q, type FieldRenderFunctions as r, type ItemWithId as s, type ArrayState as t, type PuckComponent as u, type RootConfig as v, walkTree as w, type RootDataWithoutProps as x, type RootData as y, type ComponentDataOptionalId as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.19.0-canary.8d459e4e",
3
+ "version": "0.19.0-canary.91cb9cee",
4
4
  "author": "Chris Villa <chris@puckeditor.com>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",
@@ -69,8 +69,8 @@
69
69
  "typescript": "^5.5.4"
70
70
  },
71
71
  "dependencies": {
72
- "@dnd-kit/helpers": "0.0.7-beta-20250130032138",
73
- "@dnd-kit/react": "0.0.7-beta-20250130032138",
72
+ "@dnd-kit/helpers": "0.1.18-beta-20250525014052",
73
+ "@dnd-kit/react": "0.1.18-beta-20250525014052",
74
74
  "deep-diff": "^1.0.2",
75
75
  "fast-deep-equal": "^3.1.3",
76
76
  "object-hash": "^3.0.0",