@measured/puck 0.19.0-canary.5bf4fccf → 0.19.0-canary.6dc5101e
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/{chunk-COT3ZFIM.mjs → chunk-DDGE2CCN.mjs} +329 -30
- package/dist/index.css +4 -4
- package/dist/index.d.mts +9 -5
- package/dist/index.d.ts +9 -5
- package/dist/index.js +217 -531
- package/dist/index.mjs +80 -706
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +326 -33
- package/dist/rsc.mjs +3 -1
- package/dist/{walk-tree-CM-cu7GU.d.mts → walk-tree-DOB5QZVq.d.mts} +9 -7
- package/dist/{walk-tree-CM-cu7GU.d.ts → walk-tree-DOB5QZVq.d.ts} +9 -7
- package/package.json +3 -3
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-
|
3
|
-
export { af as resolveAllData,
|
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-
|
3
|
-
export { af as resolveAllData,
|
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
|
@@ -444,39 +445,6 @@ function resolveAllData(_0, _1) {
|
|
444
445
|
});
|
445
446
|
}
|
446
447
|
|
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
448
|
// lib/data/walk-tree.ts
|
481
449
|
function walkTree(data, config, callbackFn) {
|
482
450
|
var _a, _b;
|
@@ -508,9 +476,334 @@ function walkTree(data, config, callbackFn) {
|
|
508
476
|
)
|
509
477
|
};
|
510
478
|
}
|
479
|
+
|
480
|
+
// lib/transform-props.ts
|
481
|
+
function transformProps(data, propTransforms, config = { components: {} }) {
|
482
|
+
const mapItem = (item) => {
|
483
|
+
if (propTransforms[item.type]) {
|
484
|
+
return __spreadProps(__spreadValues({}, item), {
|
485
|
+
props: __spreadValues({
|
486
|
+
id: item.props.id
|
487
|
+
}, propTransforms[item.type](item.props))
|
488
|
+
});
|
489
|
+
}
|
490
|
+
return item;
|
491
|
+
};
|
492
|
+
const defaultedData = defaultData(data);
|
493
|
+
const rootProps = defaultedData.root.props || defaultedData.root;
|
494
|
+
let newRoot = __spreadValues({}, defaultedData.root);
|
495
|
+
if (propTransforms["root"]) {
|
496
|
+
newRoot.props = propTransforms["root"](rootProps);
|
497
|
+
}
|
498
|
+
const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
|
499
|
+
const updatedData = walkTree(
|
500
|
+
dataWithUpdatedRoot,
|
501
|
+
config,
|
502
|
+
(content) => content.map(mapItem)
|
503
|
+
);
|
504
|
+
if (!defaultedData.root.props) {
|
505
|
+
updatedData.root = updatedData.root.props;
|
506
|
+
}
|
507
|
+
return updatedData;
|
508
|
+
}
|
509
|
+
|
510
|
+
// components/ViewportControls/default-viewports.ts
|
511
|
+
var defaultViewports = [
|
512
|
+
{ width: 360, height: "auto", icon: "Smartphone", label: "Small" },
|
513
|
+
{ width: 768, height: "auto", icon: "Tablet", label: "Medium" },
|
514
|
+
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
515
|
+
];
|
516
|
+
|
517
|
+
// store/default-app-state.ts
|
518
|
+
var defaultAppState = {
|
519
|
+
data: { content: [], root: {}, zones: {} },
|
520
|
+
ui: {
|
521
|
+
leftSideBarVisible: true,
|
522
|
+
rightSideBarVisible: true,
|
523
|
+
arrayState: {},
|
524
|
+
itemSelector: null,
|
525
|
+
componentList: {},
|
526
|
+
isDragging: false,
|
527
|
+
previewMode: "edit",
|
528
|
+
viewports: {
|
529
|
+
current: {
|
530
|
+
width: defaultViewports[0].width,
|
531
|
+
height: defaultViewports[0].height || "auto"
|
532
|
+
},
|
533
|
+
options: [],
|
534
|
+
controlsVisible: true
|
535
|
+
},
|
536
|
+
field: { focus: null }
|
537
|
+
},
|
538
|
+
indexes: {
|
539
|
+
nodes: {},
|
540
|
+
zones: {}
|
541
|
+
}
|
542
|
+
};
|
543
|
+
|
544
|
+
// lib/data/for-each-slot.ts
|
545
|
+
var forEachSlot = (item, cb, recursive = false, isSlot2 = isSlot) => {
|
546
|
+
const props = item.props || {};
|
547
|
+
const propKeys = Object.keys(props);
|
548
|
+
for (let i = 0; i < propKeys.length; i++) {
|
549
|
+
const propKey = propKeys[i];
|
550
|
+
const itemType = "type" in item ? item.type : "root";
|
551
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
552
|
+
const content = props[propKey];
|
553
|
+
cb(props.id, propKey, content);
|
554
|
+
if (recursive) {
|
555
|
+
content.forEach(
|
556
|
+
(childItem) => __async(void 0, null, function* () {
|
557
|
+
return forEachSlot(childItem, cb, true, isSlot2);
|
558
|
+
})
|
559
|
+
);
|
560
|
+
}
|
561
|
+
}
|
562
|
+
}
|
563
|
+
};
|
564
|
+
|
565
|
+
// lib/get-zone-id.ts
|
566
|
+
var getZoneId = (zoneCompound) => {
|
567
|
+
if (!zoneCompound) {
|
568
|
+
return [];
|
569
|
+
}
|
570
|
+
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
571
|
+
return zoneCompound.split(":");
|
572
|
+
}
|
573
|
+
return [rootDroppableId, zoneCompound];
|
574
|
+
};
|
575
|
+
|
576
|
+
// lib/data/for-related-zones.ts
|
577
|
+
function forRelatedZones(item, data, cb, path = []) {
|
578
|
+
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
|
579
|
+
const [parentId] = getZoneId(zoneCompound);
|
580
|
+
if (parentId === item.props.id) {
|
581
|
+
cb(path, zoneCompound, content);
|
582
|
+
}
|
583
|
+
});
|
584
|
+
}
|
585
|
+
|
586
|
+
// lib/data/strip-slots.ts
|
587
|
+
var stripSlots = (data) => {
|
588
|
+
return __spreadProps(__spreadValues({}, data), {
|
589
|
+
props: Object.entries(data.props).reduce(
|
590
|
+
(acc, [propKey, propVal]) => {
|
591
|
+
if (isSlot(propVal)) {
|
592
|
+
return acc;
|
593
|
+
}
|
594
|
+
return __spreadProps(__spreadValues({}, acc), { [propKey]: propVal });
|
595
|
+
},
|
596
|
+
{ id: data.props.id }
|
597
|
+
)
|
598
|
+
});
|
599
|
+
};
|
600
|
+
|
601
|
+
// lib/data/walk-app-state.ts
|
602
|
+
function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
603
|
+
var _a;
|
604
|
+
let newZones = {};
|
605
|
+
const newZoneIndex = {};
|
606
|
+
const newNodeIndex = {};
|
607
|
+
const processContent = (path, zoneCompound, content, zoneType, newId) => {
|
608
|
+
var _a2;
|
609
|
+
const [parentId] = zoneCompound.split(":");
|
610
|
+
const mappedContent = ((_a2 = mapContent(content, zoneCompound, zoneType)) != null ? _a2 : content) || [];
|
611
|
+
const [_2, zone] = zoneCompound.split(":");
|
612
|
+
const newZoneCompound = `${newId || parentId}:${zone}`;
|
613
|
+
const newContent2 = mappedContent.map(
|
614
|
+
(zoneChild, index) => processItem(zoneChild, [...path, newZoneCompound], index)
|
615
|
+
);
|
616
|
+
newZoneIndex[newZoneCompound] = {
|
617
|
+
contentIds: newContent2.map((item) => item.props.id),
|
618
|
+
type: zoneType
|
619
|
+
};
|
620
|
+
return [newZoneCompound, newContent2];
|
621
|
+
};
|
622
|
+
const processRelatedZones = (item, newId, initialPath) => {
|
623
|
+
forRelatedZones(
|
624
|
+
item,
|
625
|
+
state.data,
|
626
|
+
(relatedPath, relatedZoneCompound, relatedContent) => {
|
627
|
+
const [zoneCompound, newContent2] = processContent(
|
628
|
+
relatedPath,
|
629
|
+
relatedZoneCompound,
|
630
|
+
relatedContent,
|
631
|
+
"dropzone",
|
632
|
+
newId
|
633
|
+
);
|
634
|
+
newZones[zoneCompound] = newContent2;
|
635
|
+
},
|
636
|
+
initialPath
|
637
|
+
);
|
638
|
+
};
|
639
|
+
const processItem = (item, path, index) => {
|
640
|
+
const mappedItem = mapNodeOrSkip(item, path, index);
|
641
|
+
if (!mappedItem) return item;
|
642
|
+
const id = mappedItem.props.id;
|
643
|
+
const newProps = __spreadValues({}, mappedItem.props);
|
644
|
+
forEachSlot(
|
645
|
+
mappedItem,
|
646
|
+
(parentId2, slotId, content) => {
|
647
|
+
const zoneCompound = `${parentId2}:${slotId}`;
|
648
|
+
const [_2, newContent2] = processContent(
|
649
|
+
path,
|
650
|
+
zoneCompound,
|
651
|
+
content,
|
652
|
+
"slot",
|
653
|
+
parentId2
|
654
|
+
);
|
655
|
+
newProps[slotId] = newContent2;
|
656
|
+
},
|
657
|
+
false,
|
658
|
+
createIsSlotConfig(config)
|
659
|
+
);
|
660
|
+
processRelatedZones(item, id, path);
|
661
|
+
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
|
662
|
+
const thisZoneCompound = path[path.length - 1];
|
663
|
+
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
664
|
+
newNodeIndex[id] = {
|
665
|
+
data: newItem,
|
666
|
+
flatData: stripSlots(newItem),
|
667
|
+
path,
|
668
|
+
parentId,
|
669
|
+
zone
|
670
|
+
};
|
671
|
+
const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
|
672
|
+
if (newProps.id === "root") {
|
673
|
+
delete finalData["type"];
|
674
|
+
delete finalData.props["id"];
|
675
|
+
}
|
676
|
+
return finalData;
|
677
|
+
};
|
678
|
+
const zones = state.data.zones || {};
|
679
|
+
const [_, newContent] = processContent(
|
680
|
+
[],
|
681
|
+
rootDroppableId,
|
682
|
+
state.data.content,
|
683
|
+
"root"
|
684
|
+
);
|
685
|
+
const processedContent = newContent;
|
686
|
+
const zonesAlreadyProcessed = Object.keys(newZones);
|
687
|
+
Object.keys(zones || {}).forEach((zoneCompound) => {
|
688
|
+
const [parentId] = zoneCompound.split(":");
|
689
|
+
if (zonesAlreadyProcessed.includes(zoneCompound)) {
|
690
|
+
return;
|
691
|
+
}
|
692
|
+
const [_2, newContent2] = processContent(
|
693
|
+
[rootDroppableId],
|
694
|
+
zoneCompound,
|
695
|
+
zones[zoneCompound],
|
696
|
+
"dropzone",
|
697
|
+
parentId
|
698
|
+
);
|
699
|
+
newZones[zoneCompound] = newContent2;
|
700
|
+
}, newZones);
|
701
|
+
const processedRoot = processItem(
|
702
|
+
{
|
703
|
+
type: "root",
|
704
|
+
props: __spreadProps(__spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root), { id: "root" })
|
705
|
+
},
|
706
|
+
[],
|
707
|
+
-1
|
708
|
+
);
|
709
|
+
const root = __spreadProps(__spreadValues({}, state.data.root), {
|
710
|
+
props: processedRoot.props
|
711
|
+
});
|
712
|
+
return __spreadProps(__spreadValues({}, state), {
|
713
|
+
data: {
|
714
|
+
root,
|
715
|
+
content: processedContent,
|
716
|
+
zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
|
717
|
+
},
|
718
|
+
indexes: {
|
719
|
+
nodes: __spreadValues(__spreadValues({}, state.indexes.nodes), newNodeIndex),
|
720
|
+
zones: __spreadValues(__spreadValues({}, state.indexes.zones), newZoneIndex)
|
721
|
+
}
|
722
|
+
});
|
723
|
+
}
|
724
|
+
|
725
|
+
// lib/migrate.ts
|
726
|
+
var migrations = [
|
727
|
+
// Migrate root to root.props
|
728
|
+
(data) => {
|
729
|
+
const rootProps = data.root.props || data.root;
|
730
|
+
if (Object.keys(data.root).length > 0 && !data.root.props) {
|
731
|
+
console.warn(
|
732
|
+
"Migration applied: Root props moved from `root` to `root.props`."
|
733
|
+
);
|
734
|
+
return __spreadProps(__spreadValues({}, data), {
|
735
|
+
root: {
|
736
|
+
props: __spreadValues({}, rootProps)
|
737
|
+
}
|
738
|
+
});
|
739
|
+
}
|
740
|
+
return data;
|
741
|
+
},
|
742
|
+
// Migrate zones to slots
|
743
|
+
(data, config) => {
|
744
|
+
var _a;
|
745
|
+
if (!config) return data;
|
746
|
+
console.log("Migrating DropZones to slots...");
|
747
|
+
const updatedItems = {};
|
748
|
+
const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
|
749
|
+
const { indexes } = walkAppState(appState, config);
|
750
|
+
const deletedCompounds = [];
|
751
|
+
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
752
|
+
var _a2, _b;
|
753
|
+
if (zoneType === "dropzone") {
|
754
|
+
const [id, slotName] = zoneCompound.split(":");
|
755
|
+
const nodeData = indexes.nodes[id].data;
|
756
|
+
const componentType = nodeData.type;
|
757
|
+
const configForComponent = id === "root" ? config.root : config.components[componentType];
|
758
|
+
if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
|
759
|
+
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
760
|
+
props: __spreadProps(__spreadValues({}, nodeData.props), {
|
761
|
+
[slotName]: content
|
762
|
+
})
|
763
|
+
});
|
764
|
+
deletedCompounds.push(zoneCompound);
|
765
|
+
}
|
766
|
+
return content;
|
767
|
+
}
|
768
|
+
return content;
|
769
|
+
});
|
770
|
+
const updated = walkAppState(
|
771
|
+
appState,
|
772
|
+
config,
|
773
|
+
(content) => content,
|
774
|
+
(item) => {
|
775
|
+
var _a2;
|
776
|
+
return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
|
777
|
+
}
|
778
|
+
);
|
779
|
+
deletedCompounds.forEach((zoneCompound) => {
|
780
|
+
var _a2;
|
781
|
+
const [_, propName] = zoneCompound.split(":");
|
782
|
+
console.log(
|
783
|
+
`\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
|
784
|
+
);
|
785
|
+
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
786
|
+
});
|
787
|
+
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
788
|
+
const [_, propName] = zoneCompound.split(":");
|
789
|
+
throw new Error(
|
790
|
+
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
791
|
+
);
|
792
|
+
});
|
793
|
+
delete updated.data.zones;
|
794
|
+
return updated.data;
|
795
|
+
}
|
796
|
+
];
|
797
|
+
function migrate(data, config) {
|
798
|
+
return migrations == null ? void 0 : migrations.reduce(
|
799
|
+
(acc, migration) => migration(acc, config),
|
800
|
+
data
|
801
|
+
);
|
802
|
+
}
|
511
803
|
// Annotate the CommonJS export names for ESM import in node:
|
512
804
|
0 && (module.exports = {
|
513
805
|
Render,
|
806
|
+
migrate,
|
514
807
|
resolveAllData,
|
515
808
|
transformProps,
|
516
809
|
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-
|
8
|
+
} from "./chunk-DDGE2CCN.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:
|
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<
|
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
|
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
|
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:
|
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<
|
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
|
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
|
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.
|
3
|
+
"version": "0.19.0-canary.6dc5101e",
|
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.
|
73
|
-
"@dnd-kit/react": "0.
|
72
|
+
"@dnd-kit/helpers": "0.1.17",
|
73
|
+
"@dnd-kit/react": "0.1.17",
|
74
74
|
"deep-diff": "^1.0.2",
|
75
75
|
"fast-deep-equal": "^3.1.3",
|
76
76
|
"object-hash": "^3.0.0",
|