@measured/puck 0.19.0-canary.5bf4fccf → 0.19.0-canary.61865257

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 './walk-tree-CM-cu7GU.mjs';
3
- export { af as resolveAllData, ae as transformProps, w as walkTree } from './walk-tree-CM-cu7GU.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 './walk-tree-CM-cu7GU.js';
3
- export { af as resolveAllData, ae as transformProps, w as walkTree } from './walk-tree-CM-cu7GU.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,6 +68,7 @@ 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
73
  transformProps: () => transformProps,
73
74
  walkTree: () => walkTree
@@ -119,7 +120,11 @@ function useSlots(config, props, renderSlotEdit, renderSlotRender = renderSlotEd
119
120
  }
120
121
  return slotProps2;
121
122
  }, [config, readOnly, forceReadOnly]);
122
- return __spreadValues(__spreadValues({}, props), slotProps);
123
+ const mergedProps = (0, import_react2.useMemo)(
124
+ () => __spreadValues(__spreadValues({}, props), slotProps),
125
+ [props, slotProps]
126
+ );
127
+ return mergedProps;
123
128
  }
124
129
 
125
130
  // components/SlotRender/server.tsx
@@ -444,39 +449,6 @@ function resolveAllData(_0, _1) {
444
449
  });
445
450
  }
446
451
 
447
- // lib/transform-props.ts
448
- function transformProps(data, propTransforms) {
449
- const mapItem = (item) => {
450
- if (propTransforms[item.type]) {
451
- return __spreadProps(__spreadValues({}, item), {
452
- props: propTransforms[item.type](item.props)
453
- });
454
- }
455
- return item;
456
- };
457
- const defaultedData = defaultData(data);
458
- const rootProps = defaultedData.root.props || defaultedData.root;
459
- let newRoot = __spreadValues({}, defaultedData.root);
460
- if (propTransforms["root"]) {
461
- if (defaultedData.root.props) {
462
- newRoot.props = propTransforms["root"](rootProps);
463
- } else {
464
- newRoot = propTransforms["root"](rootProps);
465
- }
466
- }
467
- const afterPropTransforms = __spreadProps(__spreadValues({}, defaultedData), {
468
- root: newRoot,
469
- content: defaultedData.content.map(mapItem),
470
- zones: Object.keys(data.zones || {}).reduce(
471
- (acc, zoneKey) => __spreadProps(__spreadValues({}, acc), {
472
- [zoneKey]: data.zones[zoneKey].map(mapItem)
473
- }),
474
- {}
475
- )
476
- });
477
- return afterPropTransforms;
478
- }
479
-
480
452
  // lib/data/walk-tree.ts
481
453
  function walkTree(data, config, callbackFn) {
482
454
  var _a, _b;
@@ -508,9 +480,334 @@ function walkTree(data, config, callbackFn) {
508
480
  )
509
481
  };
510
482
  }
483
+
484
+ // lib/transform-props.ts
485
+ function transformProps(data, propTransforms, config = { components: {} }) {
486
+ const mapItem = (item) => {
487
+ if (propTransforms[item.type]) {
488
+ return __spreadProps(__spreadValues({}, item), {
489
+ props: __spreadValues({
490
+ id: item.props.id
491
+ }, propTransforms[item.type](item.props))
492
+ });
493
+ }
494
+ return item;
495
+ };
496
+ const defaultedData = defaultData(data);
497
+ const rootProps = defaultedData.root.props || defaultedData.root;
498
+ let newRoot = __spreadValues({}, defaultedData.root);
499
+ if (propTransforms["root"]) {
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
+ }
565
+ }
566
+ }
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 }
601
+ )
602
+ });
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
+ );
806
+ }
511
807
  // Annotate the CommonJS export names for ESM import in node:
512
808
  0 && (module.exports = {
513
809
  Render,
810
+ migrate,
514
811
  resolveAllData,
515
812
  transformProps,
516
813
  walkTree
package/dist/rsc.mjs CHANGED
@@ -1,15 +1,17 @@
1
1
  import {
2
2
  Render,
3
3
  init_react_import,
4
+ migrate,
4
5
  resolveAllData,
5
6
  transformProps,
6
7
  walkTree
7
- } from "./chunk-COT3ZFIM.mjs";
8
+ } from "./chunk-GL73J54P.mjs";
8
9
 
9
10
  // rsc.tsx
10
11
  init_react_import();
11
12
  export {
12
13
  Render,
14
+ migrate,
13
15
  resolveAllData,
14
16
  transformProps,
15
17
  walkTree
@@ -255,13 +255,13 @@ 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: WithPopulatedSlots<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<WithPopulatedSlots<Props>>;
264
+ props: WithId<WithSlotProps<Props>>;
265
265
  } & BaseData<Props>;
266
266
  type ComponentDataOptionalId<Props extends DefaultComponentProps = DefaultComponentProps, Name = string> = {
267
267
  type: Name;
@@ -345,9 +345,6 @@ type PrivateAppState<UserData extends Data = Data> = AppState<UserData> & {
345
345
  zones: ZoneIndex;
346
346
  };
347
347
  };
348
- type WithPopulatedSlots<Props extends DefaultComponentProps = DefaultComponentProps, SlotProps extends DefaultComponentProps = Props> = Props extends any ? any : {
349
- [PropName in keyof Props]: Props[PropName] extends Slot<SlotProps> ? Content<SlotProps> : Props[PropName];
350
- };
351
348
 
352
349
  type RenderFunc<Props extends {
353
350
  [key: string]: any;
@@ -462,6 +459,9 @@ type Slot<Props extends {
462
459
  }> = {
463
460
  [K in keyof Props]: ComponentDataOptionalId<Props[K], K extends string ? K : never>;
464
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
+ };
465
465
 
466
466
  type InsertAction = {
467
467
  type: "insert";
@@ -529,6 +529,8 @@ type PuckAction = {
529
529
  recordHistory?: boolean;
530
530
  } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
531
531
 
532
+ declare function migrate(data: Data, config?: Config): Data;
533
+
532
534
  type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
533
535
  [ComponentName in keyof Props]: (props: Props[ComponentName] & {
534
536
  [key: string]: any;
@@ -538,7 +540,7 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
538
540
  [key: string]: any;
539
541
  }) => RootProps;
540
542
  }>;
541
- 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;
542
544
 
543
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>>;
544
546
 
@@ -548,4 +550,4 @@ type WalkTreeOptions = {
548
550
  };
549
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;
550
552
 
551
- export { type ExternalField 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 RadioField as W, type ArrayField as X, type ObjectField as Y, type Adaptor as Z, type ExternalFieldWithAdaptor as _, type Config as a, type CustomFieldRender as a0, type CustomField as a1, type SlotField as a2, type PuckContext as a3, type DefaultRootFieldProps as a4, type DefaultRootRenderProps as a5, type DefaultRootProps as a6, type DefaultComponentProps as a7, type WithId as a8, type WithPuckProps as a9, type AsFieldProps as aa, type WithChildren as ab, type ExtractPropsFromConfig as ac, type ExtractRootPropsFromConfig as ad, transformProps as ae, resolveAllData as af, 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 };
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,13 +255,13 @@ 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: WithPopulatedSlots<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<WithPopulatedSlots<Props>>;
264
+ props: WithId<WithSlotProps<Props>>;
265
265
  } & BaseData<Props>;
266
266
  type ComponentDataOptionalId<Props extends DefaultComponentProps = DefaultComponentProps, Name = string> = {
267
267
  type: Name;
@@ -345,9 +345,6 @@ type PrivateAppState<UserData extends Data = Data> = AppState<UserData> & {
345
345
  zones: ZoneIndex;
346
346
  };
347
347
  };
348
- type WithPopulatedSlots<Props extends DefaultComponentProps = DefaultComponentProps, SlotProps extends DefaultComponentProps = Props> = Props extends any ? any : {
349
- [PropName in keyof Props]: Props[PropName] extends Slot<SlotProps> ? Content<SlotProps> : Props[PropName];
350
- };
351
348
 
352
349
  type RenderFunc<Props extends {
353
350
  [key: string]: any;
@@ -462,6 +459,9 @@ type Slot<Props extends {
462
459
  }> = {
463
460
  [K in keyof Props]: ComponentDataOptionalId<Props[K], K extends string ? K : never>;
464
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
+ };
465
465
 
466
466
  type InsertAction = {
467
467
  type: "insert";
@@ -529,6 +529,8 @@ type PuckAction = {
529
529
  recordHistory?: boolean;
530
530
  } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | ReplaceRootAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
531
531
 
532
+ declare function migrate(data: Data, config?: Config): Data;
533
+
532
534
  type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
533
535
  [ComponentName in keyof Props]: (props: Props[ComponentName] & {
534
536
  [key: string]: any;
@@ -538,7 +540,7 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
538
540
  [key: string]: any;
539
541
  }) => RootProps;
540
542
  }>;
541
- 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;
542
544
 
543
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>>;
544
546
 
@@ -548,4 +550,4 @@ type WalkTreeOptions = {
548
550
  };
549
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;
550
552
 
551
- export { type ExternalField 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 RadioField as W, type ArrayField as X, type ObjectField as Y, type Adaptor as Z, type ExternalFieldWithAdaptor as _, type Config as a, type CustomFieldRender as a0, type CustomField as a1, type SlotField as a2, type PuckContext as a3, type DefaultRootFieldProps as a4, type DefaultRootRenderProps as a5, type DefaultRootProps as a6, type DefaultComponentProps as a7, type WithId as a8, type WithPuckProps as a9, type AsFieldProps as aa, type WithChildren as ab, type ExtractPropsFromConfig as ac, type ExtractRootPropsFromConfig as ad, transformProps as ae, resolveAllData as af, 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 };
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.5bf4fccf",
3
+ "version": "0.19.0-canary.61865257",
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",