@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/{chunk-COT3ZFIM.mjs → chunk-GL73J54P.mjs} +334 -31
- package/dist/index.css +133 -131
- package/dist/index.d.mts +13 -7
- package/dist/index.d.ts +13 -7
- package/dist/index.js +950 -1072
- package/dist/index.mjs +865 -1303
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +331 -34
- 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
@@ -8,9 +8,6 @@ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
8
|
var __getProtoOf = Object.getPrototypeOf;
|
9
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
10
10
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
11
|
-
var __typeError = (msg) => {
|
12
|
-
throw TypeError(msg);
|
13
|
-
};
|
14
11
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
15
12
|
var __spreadValues = (a, b) => {
|
16
13
|
for (var prop in b || (b = {}))
|
@@ -58,10 +55,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
58
55
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
59
56
|
mod
|
60
57
|
));
|
61
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
62
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
63
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
64
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
65
58
|
var __async = (__this, __arguments, generator) => {
|
66
59
|
return new Promise((resolve, reject) => {
|
67
60
|
var fulfilled = (value) => {
|
@@ -227,7 +220,11 @@ function useSlots(config, props, renderSlotEdit, renderSlotRender = renderSlotEd
|
|
227
220
|
}
|
228
221
|
return slotProps2;
|
229
222
|
}, [config, readOnly, forceReadOnly]);
|
230
|
-
|
223
|
+
const mergedProps = useMemo(
|
224
|
+
() => __spreadValues(__spreadValues({}, props), slotProps),
|
225
|
+
[props, slotProps]
|
226
|
+
);
|
227
|
+
return mergedProps;
|
231
228
|
}
|
232
229
|
|
233
230
|
// components/SlotRender/server.tsx
|
@@ -363,6 +360,316 @@ function Render({
|
|
363
360
|
);
|
364
361
|
}
|
365
362
|
|
363
|
+
// lib/migrate.ts
|
364
|
+
init_react_import();
|
365
|
+
|
366
|
+
// store/default-app-state.ts
|
367
|
+
init_react_import();
|
368
|
+
|
369
|
+
// components/ViewportControls/default-viewports.ts
|
370
|
+
init_react_import();
|
371
|
+
var defaultViewports = [
|
372
|
+
{ width: 360, height: "auto", icon: "Smartphone", label: "Small" },
|
373
|
+
{ width: 768, height: "auto", icon: "Tablet", label: "Medium" },
|
374
|
+
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
375
|
+
];
|
376
|
+
|
377
|
+
// store/default-app-state.ts
|
378
|
+
var defaultAppState = {
|
379
|
+
data: { content: [], root: {}, zones: {} },
|
380
|
+
ui: {
|
381
|
+
leftSideBarVisible: true,
|
382
|
+
rightSideBarVisible: true,
|
383
|
+
arrayState: {},
|
384
|
+
itemSelector: null,
|
385
|
+
componentList: {},
|
386
|
+
isDragging: false,
|
387
|
+
previewMode: "edit",
|
388
|
+
viewports: {
|
389
|
+
current: {
|
390
|
+
width: defaultViewports[0].width,
|
391
|
+
height: defaultViewports[0].height || "auto"
|
392
|
+
},
|
393
|
+
options: [],
|
394
|
+
controlsVisible: true
|
395
|
+
},
|
396
|
+
field: { focus: null }
|
397
|
+
},
|
398
|
+
indexes: {
|
399
|
+
nodes: {},
|
400
|
+
zones: {}
|
401
|
+
}
|
402
|
+
};
|
403
|
+
|
404
|
+
// lib/data/walk-app-state.ts
|
405
|
+
init_react_import();
|
406
|
+
|
407
|
+
// lib/data/for-each-slot.ts
|
408
|
+
init_react_import();
|
409
|
+
var forEachSlot = (item, cb, recursive = false, isSlot2 = isSlot) => {
|
410
|
+
const props = item.props || {};
|
411
|
+
const propKeys = Object.keys(props);
|
412
|
+
for (let i = 0; i < propKeys.length; i++) {
|
413
|
+
const propKey = propKeys[i];
|
414
|
+
const itemType = "type" in item ? item.type : "root";
|
415
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
416
|
+
const content = props[propKey];
|
417
|
+
cb(props.id, propKey, content);
|
418
|
+
if (recursive) {
|
419
|
+
content.forEach(
|
420
|
+
(childItem) => __async(void 0, null, function* () {
|
421
|
+
return forEachSlot(childItem, cb, true, isSlot2);
|
422
|
+
})
|
423
|
+
);
|
424
|
+
}
|
425
|
+
}
|
426
|
+
}
|
427
|
+
};
|
428
|
+
|
429
|
+
// lib/data/for-related-zones.ts
|
430
|
+
init_react_import();
|
431
|
+
|
432
|
+
// lib/get-zone-id.ts
|
433
|
+
init_react_import();
|
434
|
+
var getZoneId = (zoneCompound) => {
|
435
|
+
if (!zoneCompound) {
|
436
|
+
return [];
|
437
|
+
}
|
438
|
+
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
439
|
+
return zoneCompound.split(":");
|
440
|
+
}
|
441
|
+
return [rootDroppableId, zoneCompound];
|
442
|
+
};
|
443
|
+
|
444
|
+
// lib/data/for-related-zones.ts
|
445
|
+
function forRelatedZones(item, data, cb, path = []) {
|
446
|
+
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
|
447
|
+
const [parentId] = getZoneId(zoneCompound);
|
448
|
+
if (parentId === item.props.id) {
|
449
|
+
cb(path, zoneCompound, content);
|
450
|
+
}
|
451
|
+
});
|
452
|
+
}
|
453
|
+
|
454
|
+
// lib/data/strip-slots.ts
|
455
|
+
init_react_import();
|
456
|
+
var stripSlots = (data) => {
|
457
|
+
return __spreadProps(__spreadValues({}, data), {
|
458
|
+
props: Object.entries(data.props).reduce(
|
459
|
+
(acc, [propKey, propVal]) => {
|
460
|
+
if (isSlot(propVal)) {
|
461
|
+
return acc;
|
462
|
+
}
|
463
|
+
return __spreadProps(__spreadValues({}, acc), { [propKey]: propVal });
|
464
|
+
},
|
465
|
+
{ id: data.props.id }
|
466
|
+
)
|
467
|
+
});
|
468
|
+
};
|
469
|
+
|
470
|
+
// lib/data/walk-app-state.ts
|
471
|
+
function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
472
|
+
var _a;
|
473
|
+
let newZones = {};
|
474
|
+
const newZoneIndex = {};
|
475
|
+
const newNodeIndex = {};
|
476
|
+
const processContent = (path, zoneCompound, content, zoneType, newId) => {
|
477
|
+
var _a2;
|
478
|
+
const [parentId] = zoneCompound.split(":");
|
479
|
+
const mappedContent = ((_a2 = mapContent(content, zoneCompound, zoneType)) != null ? _a2 : content) || [];
|
480
|
+
const [_2, zone] = zoneCompound.split(":");
|
481
|
+
const newZoneCompound = `${newId || parentId}:${zone}`;
|
482
|
+
const newContent2 = mappedContent.map(
|
483
|
+
(zoneChild, index) => processItem(zoneChild, [...path, newZoneCompound], index)
|
484
|
+
);
|
485
|
+
newZoneIndex[newZoneCompound] = {
|
486
|
+
contentIds: newContent2.map((item) => item.props.id),
|
487
|
+
type: zoneType
|
488
|
+
};
|
489
|
+
return [newZoneCompound, newContent2];
|
490
|
+
};
|
491
|
+
const processRelatedZones = (item, newId, initialPath) => {
|
492
|
+
forRelatedZones(
|
493
|
+
item,
|
494
|
+
state.data,
|
495
|
+
(relatedPath, relatedZoneCompound, relatedContent) => {
|
496
|
+
const [zoneCompound, newContent2] = processContent(
|
497
|
+
relatedPath,
|
498
|
+
relatedZoneCompound,
|
499
|
+
relatedContent,
|
500
|
+
"dropzone",
|
501
|
+
newId
|
502
|
+
);
|
503
|
+
newZones[zoneCompound] = newContent2;
|
504
|
+
},
|
505
|
+
initialPath
|
506
|
+
);
|
507
|
+
};
|
508
|
+
const processItem = (item, path, index) => {
|
509
|
+
const mappedItem = mapNodeOrSkip(item, path, index);
|
510
|
+
if (!mappedItem) return item;
|
511
|
+
const id = mappedItem.props.id;
|
512
|
+
const newProps = __spreadValues({}, mappedItem.props);
|
513
|
+
forEachSlot(
|
514
|
+
mappedItem,
|
515
|
+
(parentId2, slotId, content) => {
|
516
|
+
const zoneCompound = `${parentId2}:${slotId}`;
|
517
|
+
const [_2, newContent2] = processContent(
|
518
|
+
path,
|
519
|
+
zoneCompound,
|
520
|
+
content,
|
521
|
+
"slot",
|
522
|
+
parentId2
|
523
|
+
);
|
524
|
+
newProps[slotId] = newContent2;
|
525
|
+
},
|
526
|
+
false,
|
527
|
+
createIsSlotConfig(config)
|
528
|
+
);
|
529
|
+
processRelatedZones(item, id, path);
|
530
|
+
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
|
531
|
+
const thisZoneCompound = path[path.length - 1];
|
532
|
+
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
533
|
+
newNodeIndex[id] = {
|
534
|
+
data: newItem,
|
535
|
+
flatData: stripSlots(newItem),
|
536
|
+
path,
|
537
|
+
parentId,
|
538
|
+
zone
|
539
|
+
};
|
540
|
+
const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
|
541
|
+
if (newProps.id === "root") {
|
542
|
+
delete finalData["type"];
|
543
|
+
delete finalData.props["id"];
|
544
|
+
}
|
545
|
+
return finalData;
|
546
|
+
};
|
547
|
+
const zones = state.data.zones || {};
|
548
|
+
const [_, newContent] = processContent(
|
549
|
+
[],
|
550
|
+
rootDroppableId,
|
551
|
+
state.data.content,
|
552
|
+
"root"
|
553
|
+
);
|
554
|
+
const processedContent = newContent;
|
555
|
+
const zonesAlreadyProcessed = Object.keys(newZones);
|
556
|
+
Object.keys(zones || {}).forEach((zoneCompound) => {
|
557
|
+
const [parentId] = zoneCompound.split(":");
|
558
|
+
if (zonesAlreadyProcessed.includes(zoneCompound)) {
|
559
|
+
return;
|
560
|
+
}
|
561
|
+
const [_2, newContent2] = processContent(
|
562
|
+
[rootDroppableId],
|
563
|
+
zoneCompound,
|
564
|
+
zones[zoneCompound],
|
565
|
+
"dropzone",
|
566
|
+
parentId
|
567
|
+
);
|
568
|
+
newZones[zoneCompound] = newContent2;
|
569
|
+
}, newZones);
|
570
|
+
const processedRoot = processItem(
|
571
|
+
{
|
572
|
+
type: "root",
|
573
|
+
props: __spreadProps(__spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root), { id: "root" })
|
574
|
+
},
|
575
|
+
[],
|
576
|
+
-1
|
577
|
+
);
|
578
|
+
const root = __spreadProps(__spreadValues({}, state.data.root), {
|
579
|
+
props: processedRoot.props
|
580
|
+
});
|
581
|
+
return __spreadProps(__spreadValues({}, state), {
|
582
|
+
data: {
|
583
|
+
root,
|
584
|
+
content: processedContent,
|
585
|
+
zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
|
586
|
+
},
|
587
|
+
indexes: {
|
588
|
+
nodes: __spreadValues(__spreadValues({}, state.indexes.nodes), newNodeIndex),
|
589
|
+
zones: __spreadValues(__spreadValues({}, state.indexes.zones), newZoneIndex)
|
590
|
+
}
|
591
|
+
});
|
592
|
+
}
|
593
|
+
|
594
|
+
// lib/migrate.ts
|
595
|
+
var migrations = [
|
596
|
+
// Migrate root to root.props
|
597
|
+
(data) => {
|
598
|
+
const rootProps = data.root.props || data.root;
|
599
|
+
if (Object.keys(data.root).length > 0 && !data.root.props) {
|
600
|
+
console.warn(
|
601
|
+
"Migration applied: Root props moved from `root` to `root.props`."
|
602
|
+
);
|
603
|
+
return __spreadProps(__spreadValues({}, data), {
|
604
|
+
root: {
|
605
|
+
props: __spreadValues({}, rootProps)
|
606
|
+
}
|
607
|
+
});
|
608
|
+
}
|
609
|
+
return data;
|
610
|
+
},
|
611
|
+
// Migrate zones to slots
|
612
|
+
(data, config) => {
|
613
|
+
var _a;
|
614
|
+
if (!config) return data;
|
615
|
+
console.log("Migrating DropZones to slots...");
|
616
|
+
const updatedItems = {};
|
617
|
+
const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
|
618
|
+
const { indexes } = walkAppState(appState, config);
|
619
|
+
const deletedCompounds = [];
|
620
|
+
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
621
|
+
var _a2, _b;
|
622
|
+
if (zoneType === "dropzone") {
|
623
|
+
const [id, slotName] = zoneCompound.split(":");
|
624
|
+
const nodeData = indexes.nodes[id].data;
|
625
|
+
const componentType = nodeData.type;
|
626
|
+
const configForComponent = id === "root" ? config.root : config.components[componentType];
|
627
|
+
if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
|
628
|
+
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
629
|
+
props: __spreadProps(__spreadValues({}, nodeData.props), {
|
630
|
+
[slotName]: content
|
631
|
+
})
|
632
|
+
});
|
633
|
+
deletedCompounds.push(zoneCompound);
|
634
|
+
}
|
635
|
+
return content;
|
636
|
+
}
|
637
|
+
return content;
|
638
|
+
});
|
639
|
+
const updated = walkAppState(
|
640
|
+
appState,
|
641
|
+
config,
|
642
|
+
(content) => content,
|
643
|
+
(item) => {
|
644
|
+
var _a2;
|
645
|
+
return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
|
646
|
+
}
|
647
|
+
);
|
648
|
+
deletedCompounds.forEach((zoneCompound) => {
|
649
|
+
var _a2;
|
650
|
+
const [_, propName] = zoneCompound.split(":");
|
651
|
+
console.log(
|
652
|
+
`\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
|
653
|
+
);
|
654
|
+
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
655
|
+
});
|
656
|
+
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
657
|
+
const [_, propName] = zoneCompound.split(":");
|
658
|
+
throw new Error(
|
659
|
+
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
660
|
+
);
|
661
|
+
});
|
662
|
+
delete updated.data.zones;
|
663
|
+
return updated.data;
|
664
|
+
}
|
665
|
+
];
|
666
|
+
function migrate(data, config) {
|
667
|
+
return migrations == null ? void 0 : migrations.reduce(
|
668
|
+
(acc, migration) => migration(acc, config),
|
669
|
+
data
|
670
|
+
);
|
671
|
+
}
|
672
|
+
|
366
673
|
// lib/transform-props.ts
|
367
674
|
init_react_import();
|
368
675
|
|
@@ -374,11 +681,13 @@ var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
|
374
681
|
});
|
375
682
|
|
376
683
|
// lib/transform-props.ts
|
377
|
-
function transformProps(data, propTransforms) {
|
684
|
+
function transformProps(data, propTransforms, config = { components: {} }) {
|
378
685
|
const mapItem = (item) => {
|
379
686
|
if (propTransforms[item.type]) {
|
380
687
|
return __spreadProps(__spreadValues({}, item), {
|
381
|
-
props:
|
688
|
+
props: __spreadValues({
|
689
|
+
id: item.props.id
|
690
|
+
}, propTransforms[item.type](item.props))
|
382
691
|
});
|
383
692
|
}
|
384
693
|
return item;
|
@@ -387,23 +696,18 @@ function transformProps(data, propTransforms) {
|
|
387
696
|
const rootProps = defaultedData.root.props || defaultedData.root;
|
388
697
|
let newRoot = __spreadValues({}, defaultedData.root);
|
389
698
|
if (propTransforms["root"]) {
|
390
|
-
|
391
|
-
newRoot.props = propTransforms["root"](rootProps);
|
392
|
-
} else {
|
393
|
-
newRoot = propTransforms["root"](rootProps);
|
394
|
-
}
|
699
|
+
newRoot.props = propTransforms["root"](rootProps);
|
395
700
|
}
|
396
|
-
const
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
return afterPropTransforms;
|
701
|
+
const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
|
702
|
+
const updatedData = walkTree(
|
703
|
+
dataWithUpdatedRoot,
|
704
|
+
config,
|
705
|
+
(content) => content.map(mapItem)
|
706
|
+
);
|
707
|
+
if (!defaultedData.root.props) {
|
708
|
+
updatedData.root = updatedData.root.props;
|
709
|
+
}
|
710
|
+
return updatedData;
|
407
711
|
}
|
408
712
|
|
409
713
|
// lib/resolve-all-data.ts
|
@@ -553,24 +857,23 @@ export {
|
|
553
857
|
__objRest,
|
554
858
|
__commonJS,
|
555
859
|
__toESM,
|
556
|
-
__privateGet,
|
557
|
-
__privateAdd,
|
558
|
-
__privateSet,
|
559
860
|
__async,
|
560
861
|
init_react_import,
|
561
|
-
isSlot,
|
562
|
-
createIsSlotConfig,
|
563
862
|
rootAreaId,
|
564
863
|
rootZone,
|
565
864
|
rootDroppableId,
|
865
|
+
walkAppState,
|
566
866
|
walkTree,
|
567
867
|
setupZone,
|
868
|
+
defaultViewports,
|
568
869
|
getChanged,
|
569
870
|
resolveComponentData,
|
871
|
+
defaultAppState,
|
570
872
|
useSlots,
|
571
873
|
Render,
|
572
874
|
SlotRenderPure,
|
573
875
|
SlotRender,
|
876
|
+
migrate,
|
574
877
|
transformProps,
|
575
878
|
resolveAllData
|
576
879
|
};
|