@measured/puck-plugin-heading-analyzer 0.19.0-canary.d9be813b → 0.19.0-canary.e52d3b85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +723 -644
- package/dist/index.mjs +723 -644
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
@@ -356,140 +356,30 @@ init_react_import();
|
|
356
356
|
// ../core/reducer/index.ts
|
357
357
|
init_react_import();
|
358
358
|
|
359
|
-
// ../core/reducer/
|
359
|
+
// ../core/reducer/actions/set.ts
|
360
360
|
init_react_import();
|
361
361
|
|
362
|
-
// ../core/lib/
|
362
|
+
// ../core/lib/data/walk-tree.ts
|
363
363
|
init_react_import();
|
364
|
-
var reorder = (list, startIndex, endIndex) => {
|
365
|
-
const result = Array.from(list);
|
366
|
-
const [removed] = result.splice(startIndex, 1);
|
367
|
-
result.splice(endIndex, 0, removed);
|
368
|
-
return result;
|
369
|
-
};
|
370
|
-
|
371
|
-
// ../core/lib/insert.ts
|
372
|
-
init_react_import();
|
373
|
-
var insert = (list, index, item) => {
|
374
|
-
const result = Array.from(list || []);
|
375
|
-
result.splice(index, 0, item);
|
376
|
-
return result;
|
377
|
-
};
|
378
|
-
|
379
|
-
// ../core/lib/remove.ts
|
380
|
-
init_react_import();
|
381
|
-
var remove = (list, index) => {
|
382
|
-
const result = Array.from(list);
|
383
|
-
result.splice(index, 1);
|
384
|
-
return result;
|
385
|
-
};
|
386
|
-
|
387
|
-
// ../core/lib/setup-zone.ts
|
388
|
-
init_react_import();
|
389
|
-
|
390
|
-
// ../core/lib/root-droppable-id.ts
|
391
|
-
init_react_import();
|
392
|
-
var rootAreaId = "root";
|
393
|
-
var rootZone = "default-zone";
|
394
|
-
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
395
|
-
|
396
|
-
// ../core/lib/setup-zone.ts
|
397
|
-
var setupZone = (data, zoneKey) => {
|
398
|
-
if (zoneKey === rootDroppableId) {
|
399
|
-
return data;
|
400
|
-
}
|
401
|
-
const newData = __spreadProps(__spreadValues({}, data), {
|
402
|
-
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
403
|
-
});
|
404
|
-
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
405
|
-
return newData;
|
406
|
-
};
|
407
|
-
|
408
|
-
// ../core/lib/get-item.ts
|
409
|
-
init_react_import();
|
410
|
-
function getItem(selector, state) {
|
411
|
-
var _a, _b;
|
412
|
-
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
413
|
-
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
414
|
-
}
|
415
|
-
|
416
|
-
// ../core/lib/generate-id.ts
|
417
|
-
init_react_import();
|
418
|
-
|
419
|
-
// ../../node_modules/uuid/dist/esm-node/index.js
|
420
|
-
init_react_import();
|
421
|
-
|
422
|
-
// ../../node_modules/uuid/dist/esm-node/rng.js
|
423
|
-
init_react_import();
|
424
|
-
import crypto from "crypto";
|
425
|
-
var rnds8Pool = new Uint8Array(256);
|
426
|
-
var poolPtr = rnds8Pool.length;
|
427
|
-
function rng() {
|
428
|
-
if (poolPtr > rnds8Pool.length - 16) {
|
429
|
-
crypto.randomFillSync(rnds8Pool);
|
430
|
-
poolPtr = 0;
|
431
|
-
}
|
432
|
-
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
433
|
-
}
|
434
|
-
|
435
|
-
// ../../node_modules/uuid/dist/esm-node/stringify.js
|
436
|
-
init_react_import();
|
437
|
-
var byteToHex = [];
|
438
|
-
for (let i = 0; i < 256; ++i) {
|
439
|
-
byteToHex.push((i + 256).toString(16).slice(1));
|
440
|
-
}
|
441
|
-
function unsafeStringify(arr, offset = 0) {
|
442
|
-
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
443
|
-
}
|
444
|
-
|
445
|
-
// ../../node_modules/uuid/dist/esm-node/v4.js
|
446
|
-
init_react_import();
|
447
|
-
|
448
|
-
// ../../node_modules/uuid/dist/esm-node/native.js
|
449
|
-
init_react_import();
|
450
|
-
import crypto2 from "crypto";
|
451
|
-
var native_default = {
|
452
|
-
randomUUID: crypto2.randomUUID
|
453
|
-
};
|
454
364
|
|
455
|
-
//
|
456
|
-
function v4(options, buf, offset) {
|
457
|
-
if (native_default.randomUUID && !buf && !options) {
|
458
|
-
return native_default.randomUUID();
|
459
|
-
}
|
460
|
-
options = options || {};
|
461
|
-
const rnds = options.random || (options.rng || rng)();
|
462
|
-
rnds[6] = rnds[6] & 15 | 64;
|
463
|
-
rnds[8] = rnds[8] & 63 | 128;
|
464
|
-
if (buf) {
|
465
|
-
offset = offset || 0;
|
466
|
-
for (let i = 0; i < 16; ++i) {
|
467
|
-
buf[offset + i] = rnds[i];
|
468
|
-
}
|
469
|
-
return buf;
|
470
|
-
}
|
471
|
-
return unsafeStringify(rnds);
|
472
|
-
}
|
473
|
-
var v4_default = v4;
|
474
|
-
|
475
|
-
// ../core/lib/generate-id.ts
|
476
|
-
var generateId = (type) => type ? `${type}-${v4_default()}` : v4_default();
|
477
|
-
|
478
|
-
// ../core/lib/walk-tree.ts
|
365
|
+
// ../core/lib/data/for-each-slot.ts
|
479
366
|
init_react_import();
|
480
367
|
|
481
|
-
// ../core/lib/
|
482
|
-
init_react_import();
|
483
|
-
|
484
|
-
// ../core/lib/is-slot.ts
|
368
|
+
// ../core/lib/data/is-slot.ts
|
485
369
|
init_react_import();
|
486
370
|
var isSlot = (prop) => {
|
487
371
|
var _a, _b;
|
488
372
|
return Array.isArray(prop) && typeof ((_a = prop[0]) == null ? void 0 : _a.type) === "string" && typeof ((_b = prop[0]) == null ? void 0 : _b.props) === "object";
|
489
373
|
};
|
374
|
+
var createIsSlotConfig = (config) => (itemType, propName, propValue) => {
|
375
|
+
var _a, _b;
|
376
|
+
const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
|
377
|
+
if (!configForComponent) return isSlot(propValue);
|
378
|
+
return ((_b = (_a = configForComponent.fields) == null ? void 0 : _a[propName]) == null ? void 0 : _b.type) === "slot";
|
379
|
+
};
|
490
380
|
|
491
|
-
// ../core/lib/for-each-slot.ts
|
492
|
-
var forEachSlot = (
|
381
|
+
// ../core/lib/data/for-each-slot.ts
|
382
|
+
var forEachSlot = (item, cb, recursive = false, isSlot2 = isSlot) => {
|
493
383
|
const props = item.props || {};
|
494
384
|
const propKeys = Object.keys(props);
|
495
385
|
for (let i = 0; i < propKeys.length; i++) {
|
@@ -497,23 +387,31 @@ var forEachSlot = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function*
|
|
497
387
|
const itemType = "type" in item ? item.type : "root";
|
498
388
|
if (isSlot2(itemType, propKey, props[propKey])) {
|
499
389
|
const content = props[propKey];
|
500
|
-
|
390
|
+
cb(props.id, propKey, content);
|
501
391
|
if (recursive) {
|
502
392
|
content.forEach(
|
503
393
|
(childItem) => __async(void 0, null, function* () {
|
504
|
-
return
|
394
|
+
return forEachSlot(childItem, cb, true, isSlot2);
|
505
395
|
})
|
506
396
|
);
|
507
397
|
}
|
508
398
|
}
|
509
399
|
}
|
510
|
-
}
|
400
|
+
};
|
511
401
|
|
512
|
-
// ../core/lib/for-related-zones.ts
|
402
|
+
// ../core/lib/data/for-related-zones.ts
|
513
403
|
init_react_import();
|
514
404
|
|
515
405
|
// ../core/lib/get-zone-id.ts
|
516
406
|
init_react_import();
|
407
|
+
|
408
|
+
// ../core/lib/root-droppable-id.ts
|
409
|
+
init_react_import();
|
410
|
+
var rootAreaId = "root";
|
411
|
+
var rootZone = "default-zone";
|
412
|
+
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
413
|
+
|
414
|
+
// ../core/lib/get-zone-id.ts
|
517
415
|
var getZoneId = (zoneCompound) => {
|
518
416
|
if (!zoneCompound) {
|
519
417
|
return [];
|
@@ -524,19 +422,17 @@ var getZoneId = (zoneCompound) => {
|
|
524
422
|
return [rootDroppableId, zoneCompound];
|
525
423
|
};
|
526
424
|
|
527
|
-
// ../core/lib/for-related-zones.ts
|
425
|
+
// ../core/lib/data/for-related-zones.ts
|
528
426
|
function forRelatedZones(item, data, cb, path = []) {
|
529
427
|
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
|
530
428
|
const [parentId] = getZoneId(zoneCompound);
|
531
429
|
if (parentId === item.props.id) {
|
532
|
-
const newPath = [...path, zoneCompound];
|
533
|
-
content.forEach((item2) => forRelatedZones(item2, data, cb, newPath));
|
534
430
|
cb(path, zoneCompound, content);
|
535
431
|
}
|
536
432
|
});
|
537
433
|
}
|
538
434
|
|
539
|
-
// ../core/lib/strip-slots.ts
|
435
|
+
// ../core/lib/data/strip-slots.ts
|
540
436
|
init_react_import();
|
541
437
|
var stripSlots = (data) => {
|
542
438
|
return __spreadProps(__spreadValues({}, data), {
|
@@ -552,7 +448,7 @@ var stripSlots = (data) => {
|
|
552
448
|
});
|
553
449
|
};
|
554
450
|
|
555
|
-
// ../core/lib/walk-tree.ts
|
451
|
+
// ../core/lib/data/walk-tree.ts
|
556
452
|
function walkTree(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
557
453
|
var _a;
|
558
454
|
let newZones = {};
|
@@ -594,7 +490,6 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
594
490
|
const mappedItem = mapNodeOrSkip(item, path, index);
|
595
491
|
if (!mappedItem) return item;
|
596
492
|
const id = mappedItem.props.id;
|
597
|
-
processRelatedZones(item, id, path);
|
598
493
|
const newProps = __spreadValues({}, mappedItem.props);
|
599
494
|
forEachSlot(
|
600
495
|
mappedItem,
|
@@ -610,13 +505,9 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
610
505
|
newProps[slotId] = newContent2;
|
611
506
|
},
|
612
507
|
false,
|
613
|
-
(
|
614
|
-
var _a2, _b;
|
615
|
-
const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
|
616
|
-
if (!configForComponent) return isSlot(propValue);
|
617
|
-
return ((_b = (_a2 = configForComponent.fields) == null ? void 0 : _a2[propName]) == null ? void 0 : _b.type) === "slot";
|
618
|
-
}
|
508
|
+
createIsSlotConfig(config)
|
619
509
|
);
|
510
|
+
processRelatedZones(item, id, path);
|
620
511
|
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
|
621
512
|
const thisZoneCompound = path[path.length - 1];
|
622
513
|
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
@@ -627,7 +518,7 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
627
518
|
parentId,
|
628
519
|
zone
|
629
520
|
};
|
630
|
-
const finalData = newItem;
|
521
|
+
const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
|
631
522
|
if (newProps.id === "root") {
|
632
523
|
delete finalData["type"];
|
633
524
|
delete finalData.props["id"];
|
@@ -642,8 +533,12 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
642
533
|
"root"
|
643
534
|
);
|
644
535
|
const processedContent = newContent;
|
536
|
+
const zonesAlreadyProcessed = Object.keys(newZones);
|
645
537
|
Object.keys(zones || {}).forEach((zoneCompound) => {
|
646
538
|
const [parentId] = zoneCompound.split(":");
|
539
|
+
if (zonesAlreadyProcessed.includes(zoneCompound)) {
|
540
|
+
return;
|
541
|
+
}
|
647
542
|
const [_2, newContent2] = processContent(
|
648
543
|
[rootDroppableId],
|
649
544
|
zoneCompound,
|
@@ -667,7 +562,6 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
667
562
|
return __spreadProps(__spreadValues({}, state), {
|
668
563
|
data: {
|
669
564
|
root,
|
670
|
-
// root: state.data.root, // TODO changing root causes it's entire subtree to re-render. Let's keep this disabled until the performance issues are resolved in #644.
|
671
565
|
content: processedContent,
|
672
566
|
zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
|
673
567
|
},
|
@@ -678,342 +572,467 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
678
572
|
});
|
679
573
|
}
|
680
574
|
|
681
|
-
// ../core/
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
delete nodes[subItem.props.id];
|
691
|
-
});
|
692
|
-
delete zones[zoneCompound];
|
693
|
-
});
|
694
|
-
};
|
695
|
-
const dindexChildren = (item) => {
|
696
|
-
forEachSlot(
|
697
|
-
item,
|
698
|
-
(parentId, slotId, content) => {
|
699
|
-
const zoneCompound = `${parentId}:${slotId}`;
|
700
|
-
delete zones[zoneCompound];
|
701
|
-
content.forEach((item2) => {
|
702
|
-
dindexRelatedZones(item2);
|
703
|
-
delete nodes[item2.props.id];
|
704
|
-
});
|
705
|
-
},
|
706
|
-
true
|
575
|
+
// ../core/reducer/actions/set.ts
|
576
|
+
var setAction = (state, action, appStore) => {
|
577
|
+
if (typeof action.state === "object") {
|
578
|
+
const newState = __spreadValues(__spreadValues({}, state), action.state);
|
579
|
+
if (action.state.indexes) {
|
580
|
+
return newState;
|
581
|
+
}
|
582
|
+
console.warn(
|
583
|
+
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
707
584
|
);
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
delete nodes[componentData.props.id];
|
712
|
-
return { nodes, zones };
|
585
|
+
return walkTree(newState, appStore.config);
|
586
|
+
}
|
587
|
+
return __spreadValues(__spreadValues({}, state), action.state(state));
|
713
588
|
};
|
714
589
|
|
715
|
-
// ../core/reducer/
|
716
|
-
|
590
|
+
// ../core/reducer/actions/insert.ts
|
591
|
+
init_react_import();
|
592
|
+
|
593
|
+
// ../core/lib/data/insert.ts
|
594
|
+
init_react_import();
|
595
|
+
var insert = (list, index, item) => {
|
596
|
+
const result = Array.from(list || []);
|
597
|
+
result.splice(index, 0, item);
|
598
|
+
return result;
|
599
|
+
};
|
600
|
+
|
601
|
+
// ../core/lib/generate-id.ts
|
602
|
+
init_react_import();
|
603
|
+
|
604
|
+
// ../../node_modules/uuid/dist/esm-node/index.js
|
605
|
+
init_react_import();
|
606
|
+
|
607
|
+
// ../../node_modules/uuid/dist/esm-node/rng.js
|
608
|
+
init_react_import();
|
609
|
+
import crypto from "crypto";
|
610
|
+
var rnds8Pool = new Uint8Array(256);
|
611
|
+
var poolPtr = rnds8Pool.length;
|
612
|
+
function rng() {
|
613
|
+
if (poolPtr > rnds8Pool.length - 16) {
|
614
|
+
crypto.randomFillSync(rnds8Pool);
|
615
|
+
poolPtr = 0;
|
616
|
+
}
|
617
|
+
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
618
|
+
}
|
619
|
+
|
620
|
+
// ../../node_modules/uuid/dist/esm-node/stringify.js
|
621
|
+
init_react_import();
|
622
|
+
var byteToHex = [];
|
623
|
+
for (let i = 0; i < 256; ++i) {
|
624
|
+
byteToHex.push((i + 256).toString(16).slice(1));
|
625
|
+
}
|
626
|
+
function unsafeStringify(arr, offset = 0) {
|
627
|
+
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
628
|
+
}
|
629
|
+
|
630
|
+
// ../../node_modules/uuid/dist/esm-node/v4.js
|
631
|
+
init_react_import();
|
632
|
+
|
633
|
+
// ../../node_modules/uuid/dist/esm-node/native.js
|
634
|
+
init_react_import();
|
635
|
+
import crypto2 from "crypto";
|
636
|
+
var native_default = {
|
637
|
+
randomUUID: crypto2.randomUUID
|
638
|
+
};
|
639
|
+
|
640
|
+
// ../../node_modules/uuid/dist/esm-node/v4.js
|
641
|
+
function v4(options, buf, offset) {
|
642
|
+
if (native_default.randomUUID && !buf && !options) {
|
643
|
+
return native_default.randomUUID();
|
644
|
+
}
|
645
|
+
options = options || {};
|
646
|
+
const rnds = options.random || (options.rng || rng)();
|
647
|
+
rnds[6] = rnds[6] & 15 | 64;
|
648
|
+
rnds[8] = rnds[8] & 63 | 128;
|
649
|
+
if (buf) {
|
650
|
+
offset = offset || 0;
|
651
|
+
for (let i = 0; i < 16; ++i) {
|
652
|
+
buf[offset + i] = rnds[i];
|
653
|
+
}
|
654
|
+
return buf;
|
655
|
+
}
|
656
|
+
return unsafeStringify(rnds);
|
657
|
+
}
|
658
|
+
var v4_default = v4;
|
659
|
+
|
660
|
+
// ../core/lib/generate-id.ts
|
661
|
+
var generateId = (type) => type ? `${type}-${v4_default()}` : v4_default();
|
662
|
+
|
663
|
+
// ../core/lib/data/get-ids-for-parent.ts
|
664
|
+
init_react_import();
|
717
665
|
var getIdsForParent = (zoneCompound, state) => {
|
718
666
|
const [parentId] = zoneCompound.split(":");
|
719
667
|
const node = state.indexes.nodes[parentId];
|
720
668
|
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
|
721
669
|
};
|
722
|
-
|
670
|
+
|
671
|
+
// ../core/reducer/actions/insert.ts
|
672
|
+
function insertAction(state, action, appStore) {
|
723
673
|
const id = action.id || generateId(action.componentType);
|
724
674
|
const emptyComponentData = {
|
725
675
|
type: action.componentType,
|
726
|
-
props: __spreadProps(__spreadValues({}, config.components[action.componentType].defaultProps || {}), {
|
676
|
+
props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
|
727
677
|
id
|
728
678
|
})
|
729
679
|
};
|
730
680
|
const [parentId] = action.destinationZone.split(":");
|
681
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
682
|
+
return walkTree(
|
683
|
+
state,
|
684
|
+
appStore.config,
|
685
|
+
(content, zoneCompound) => {
|
686
|
+
if (zoneCompound === action.destinationZone) {
|
687
|
+
return insert(
|
688
|
+
content || [],
|
689
|
+
action.destinationIndex,
|
690
|
+
emptyComponentData
|
691
|
+
);
|
692
|
+
}
|
693
|
+
return content;
|
694
|
+
},
|
695
|
+
(childItem, path) => {
|
696
|
+
if (childItem.props.id === id || childItem.props.id === parentId) {
|
697
|
+
return childItem;
|
698
|
+
} else if (idsInPath.includes(childItem.props.id)) {
|
699
|
+
return childItem;
|
700
|
+
} else if (path.includes(action.destinationZone)) {
|
701
|
+
return childItem;
|
702
|
+
}
|
703
|
+
return null;
|
704
|
+
}
|
705
|
+
);
|
706
|
+
}
|
707
|
+
|
708
|
+
// ../core/reducer/actions/replace.ts
|
709
|
+
init_react_import();
|
710
|
+
var replaceAction = (state, action, appStore) => {
|
711
|
+
const [parentId] = action.destinationZone.split(":");
|
712
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
713
|
+
const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
|
714
|
+
const idChanged = originalId !== action.data.props.id;
|
715
|
+
if (idChanged) {
|
716
|
+
throw new Error(
|
717
|
+
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
718
|
+
);
|
719
|
+
}
|
720
|
+
return walkTree(
|
721
|
+
state,
|
722
|
+
appStore.config,
|
723
|
+
(content, zoneCompound) => {
|
724
|
+
const newContent = [...content];
|
725
|
+
if (zoneCompound === action.destinationZone) {
|
726
|
+
newContent[action.destinationIndex] = action.data;
|
727
|
+
}
|
728
|
+
return newContent;
|
729
|
+
},
|
730
|
+
(childItem, path) => {
|
731
|
+
const pathIds = path.map((p) => p.split(":")[0]);
|
732
|
+
if (childItem.props.id === action.data.props.id) {
|
733
|
+
return action.data;
|
734
|
+
} else if (childItem.props.id === parentId) {
|
735
|
+
return childItem;
|
736
|
+
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
737
|
+
return childItem;
|
738
|
+
} else if (pathIds.indexOf(action.data.props.id) > -1) {
|
739
|
+
return childItem;
|
740
|
+
}
|
741
|
+
return null;
|
742
|
+
}
|
743
|
+
);
|
744
|
+
};
|
745
|
+
|
746
|
+
// ../core/reducer/actions/replace-root.ts
|
747
|
+
init_react_import();
|
748
|
+
var replaceRootAction = (state, action, appStore) => {
|
749
|
+
return walkTree(
|
750
|
+
state,
|
751
|
+
appStore.config,
|
752
|
+
(content) => content,
|
753
|
+
(childItem) => {
|
754
|
+
if (childItem.props.id === "root") {
|
755
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
756
|
+
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
757
|
+
readOnly: action.root.readOnly
|
758
|
+
});
|
759
|
+
}
|
760
|
+
return childItem;
|
761
|
+
}
|
762
|
+
);
|
763
|
+
};
|
764
|
+
|
765
|
+
// ../core/reducer/actions/duplicate.ts
|
766
|
+
init_react_import();
|
767
|
+
|
768
|
+
// ../core/lib/data/get-item.ts
|
769
|
+
init_react_import();
|
770
|
+
function getItem(selector, state) {
|
771
|
+
var _a, _b;
|
772
|
+
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
773
|
+
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
774
|
+
}
|
775
|
+
|
776
|
+
// ../core/reducer/actions/duplicate.ts
|
777
|
+
function duplicateAction(state, action, appStore) {
|
778
|
+
const item = getItem(
|
779
|
+
{ index: action.sourceIndex, zone: action.sourceZone },
|
780
|
+
state
|
781
|
+
);
|
782
|
+
const idsInPath = getIdsForParent(action.sourceZone, state);
|
783
|
+
const newItem = __spreadProps(__spreadValues({}, item), {
|
784
|
+
props: __spreadProps(__spreadValues({}, item.props), {
|
785
|
+
id: generateId(item.type)
|
786
|
+
})
|
787
|
+
});
|
788
|
+
const modified = walkTree(
|
789
|
+
state,
|
790
|
+
appStore.config,
|
791
|
+
(content, zoneCompound) => {
|
792
|
+
if (zoneCompound === action.sourceZone) {
|
793
|
+
return insert(content, action.sourceIndex + 1, item);
|
794
|
+
}
|
795
|
+
return content;
|
796
|
+
},
|
797
|
+
(childItem, path, index) => {
|
798
|
+
const zoneCompound = path[path.length - 1];
|
799
|
+
const parents = path.map((p) => p.split(":")[0]);
|
800
|
+
if (parents.indexOf(newItem.props.id) > -1) {
|
801
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
802
|
+
props: __spreadProps(__spreadValues({}, childItem.props), {
|
803
|
+
id: generateId(childItem.type)
|
804
|
+
})
|
805
|
+
});
|
806
|
+
}
|
807
|
+
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
808
|
+
return newItem;
|
809
|
+
}
|
810
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
811
|
+
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
812
|
+
return childItem;
|
813
|
+
}
|
814
|
+
return null;
|
815
|
+
}
|
816
|
+
);
|
817
|
+
return __spreadProps(__spreadValues({}, modified), {
|
818
|
+
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
819
|
+
itemSelector: {
|
820
|
+
index: action.sourceIndex + 1,
|
821
|
+
zone: action.sourceZone
|
822
|
+
}
|
823
|
+
})
|
824
|
+
});
|
825
|
+
}
|
826
|
+
|
827
|
+
// ../core/reducer/actions/reorder.ts
|
828
|
+
init_react_import();
|
829
|
+
|
830
|
+
// ../core/reducer/actions/move.ts
|
831
|
+
init_react_import();
|
832
|
+
|
833
|
+
// ../core/lib/data/remove.ts
|
834
|
+
init_react_import();
|
835
|
+
var remove = (list, index) => {
|
836
|
+
const result = Array.from(list);
|
837
|
+
result.splice(index, 1);
|
838
|
+
return result;
|
839
|
+
};
|
840
|
+
|
841
|
+
// ../core/reducer/actions/move.ts
|
842
|
+
var moveAction = (state, action, appStore) => {
|
843
|
+
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
844
|
+
return state;
|
845
|
+
}
|
846
|
+
const item = getItem(
|
847
|
+
{ zone: action.sourceZone, index: action.sourceIndex },
|
848
|
+
state
|
849
|
+
);
|
850
|
+
if (!item) return state;
|
851
|
+
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
852
|
+
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
731
853
|
return walkTree(
|
732
854
|
state,
|
733
|
-
config,
|
855
|
+
appStore.config,
|
734
856
|
(content, zoneCompound) => {
|
735
|
-
if (zoneCompound === action.destinationZone) {
|
857
|
+
if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
|
736
858
|
return insert(
|
737
|
-
content
|
859
|
+
remove(content, action.sourceIndex),
|
738
860
|
action.destinationIndex,
|
739
|
-
|
861
|
+
item
|
740
862
|
);
|
863
|
+
} else if (zoneCompound === action.sourceZone) {
|
864
|
+
return remove(content, action.sourceIndex);
|
865
|
+
} else if (zoneCompound === action.destinationZone) {
|
866
|
+
return insert(content, action.destinationIndex, item);
|
741
867
|
}
|
742
868
|
return content;
|
743
869
|
},
|
744
|
-
(childItem) => {
|
745
|
-
|
870
|
+
(childItem, path) => {
|
871
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
872
|
+
const [destinationZoneParent] = action.destinationZone.split(":");
|
873
|
+
const childId = childItem.props.id;
|
874
|
+
if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1 || path.includes(action.destinationZone)) {
|
746
875
|
return childItem;
|
747
876
|
}
|
748
877
|
return null;
|
749
878
|
}
|
750
879
|
);
|
751
|
-
}
|
880
|
+
};
|
881
|
+
|
882
|
+
// ../core/reducer/actions/reorder.ts
|
752
883
|
var reorderAction = (state, action, appStore) => {
|
753
|
-
return
|
884
|
+
return moveAction(
|
754
885
|
state,
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
action.destinationIndex
|
762
|
-
);
|
763
|
-
}
|
764
|
-
return content;
|
886
|
+
{
|
887
|
+
type: "move",
|
888
|
+
sourceIndex: action.sourceIndex,
|
889
|
+
sourceZone: action.destinationZone,
|
890
|
+
destinationIndex: action.destinationIndex,
|
891
|
+
destinationZone: action.destinationZone
|
765
892
|
},
|
766
|
-
|
767
|
-
const zoneCompound = path[path.length - 1];
|
768
|
-
if (index === action.sourceIndex && zoneCompound === action.destinationZone || index === action.destinationIndex && zoneCompound === action.destinationZone) {
|
769
|
-
return childItem;
|
770
|
-
}
|
771
|
-
return null;
|
772
|
-
}
|
893
|
+
appStore
|
773
894
|
);
|
774
895
|
};
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
896
|
+
|
897
|
+
// ../core/reducer/actions/remove.ts
|
898
|
+
init_react_import();
|
899
|
+
var removeAction = (state, action, appStore) => {
|
900
|
+
const item = getItem({ index: action.index, zone: action.zone }, state);
|
901
|
+
const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
|
902
|
+
(acc, [nodeId, nodeData]) => {
|
903
|
+
const pathIds = nodeData.path.map((p) => p.split(":")[0]);
|
904
|
+
if (pathIds.includes(item.props.id)) {
|
905
|
+
return [...acc, nodeId];
|
906
|
+
}
|
907
|
+
return acc;
|
908
|
+
},
|
909
|
+
[item.props.id]
|
910
|
+
);
|
911
|
+
const newState = walkTree(
|
779
912
|
state,
|
780
913
|
appStore.config,
|
781
|
-
(content) =>
|
782
|
-
|
783
|
-
|
784
|
-
if (childItem.props.id === action.data.props.id) {
|
785
|
-
return action.data;
|
786
|
-
} else if (childItem.props.id === parentId) {
|
787
|
-
return childItem;
|
788
|
-
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
789
|
-
return childItem;
|
790
|
-
} else if (pathIds.indexOf(action.data.props.id) > -1) {
|
791
|
-
return childItem;
|
914
|
+
(content, zoneCompound) => {
|
915
|
+
if (zoneCompound === action.zone) {
|
916
|
+
return remove(content, action.index);
|
792
917
|
}
|
793
|
-
return
|
918
|
+
return content;
|
794
919
|
}
|
795
920
|
);
|
796
|
-
}
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
if (action.state.indexes) {
|
801
|
-
console.warn(
|
802
|
-
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
803
|
-
);
|
804
|
-
return newState;
|
805
|
-
}
|
806
|
-
return walkTree(newState, appStore.config);
|
807
|
-
}
|
808
|
-
return __spreadValues(__spreadValues({}, state), action.state(state));
|
809
|
-
};
|
810
|
-
function reduce(state, action, appStore) {
|
811
|
-
if (action.type === "set") {
|
812
|
-
return setAction(state, action, appStore);
|
813
|
-
}
|
814
|
-
if (action.type === "insert") {
|
815
|
-
return insertAction(state, action, appStore.config);
|
816
|
-
}
|
817
|
-
if (action.type === "replace") {
|
818
|
-
return replaceAction(state, action, appStore);
|
819
|
-
}
|
820
|
-
if (action.type === "replaceRoot") {
|
821
|
-
return walkTree(
|
822
|
-
state,
|
823
|
-
appStore.config,
|
824
|
-
(content) => content,
|
825
|
-
(childItem) => {
|
826
|
-
if (childItem.props.id === "root") {
|
827
|
-
return __spreadProps(__spreadValues({}, childItem), {
|
828
|
-
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
829
|
-
readOnly: action.root.readOnly
|
830
|
-
});
|
831
|
-
}
|
832
|
-
return childItem;
|
833
|
-
}
|
834
|
-
);
|
835
|
-
}
|
836
|
-
if (action.type === "duplicate") {
|
837
|
-
const item = getItem(
|
838
|
-
{ index: action.sourceIndex, zone: action.sourceZone },
|
839
|
-
state
|
840
|
-
);
|
841
|
-
const idsInPath = getIdsForParent(action.sourceZone, state);
|
842
|
-
const newItem = __spreadProps(__spreadValues({}, item), {
|
843
|
-
props: __spreadProps(__spreadValues({}, item.props), {
|
844
|
-
id: generateId(item.type)
|
845
|
-
})
|
846
|
-
});
|
847
|
-
const modified = walkTree(
|
848
|
-
state,
|
849
|
-
appStore.config,
|
850
|
-
(content, zoneCompound) => {
|
851
|
-
if (zoneCompound === action.sourceZone) {
|
852
|
-
return insert(content, action.sourceIndex + 1, item);
|
853
|
-
}
|
854
|
-
return content;
|
855
|
-
},
|
856
|
-
(childItem, path, index) => {
|
857
|
-
const zoneCompound = path[path.length - 1];
|
858
|
-
const parents = path.map((p) => p.split(":")[0]);
|
859
|
-
if (parents.indexOf(newItem.props.id) > -1) {
|
860
|
-
return __spreadProps(__spreadValues({}, childItem), {
|
861
|
-
props: __spreadProps(__spreadValues({}, childItem.props), {
|
862
|
-
id: generateId(childItem.type)
|
863
|
-
})
|
864
|
-
});
|
865
|
-
}
|
866
|
-
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
867
|
-
return newItem;
|
868
|
-
}
|
869
|
-
const [sourceZoneParent] = action.sourceZone.split(":");
|
870
|
-
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
871
|
-
return childItem;
|
872
|
-
}
|
873
|
-
return null;
|
874
|
-
}
|
875
|
-
);
|
876
|
-
return __spreadProps(__spreadValues({}, modified), {
|
877
|
-
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
878
|
-
itemSelector: {
|
879
|
-
index: action.sourceIndex + 1,
|
880
|
-
zone: action.sourceZone
|
881
|
-
}
|
882
|
-
})
|
883
|
-
});
|
884
|
-
}
|
885
|
-
if (action.type === "reorder") {
|
886
|
-
return reorderAction(state, action, appStore);
|
887
|
-
}
|
888
|
-
if (action.type === "move") {
|
889
|
-
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
890
|
-
return state;
|
921
|
+
Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
|
922
|
+
const parentId = zoneCompound.split(":")[0];
|
923
|
+
if (nodesToDelete.includes(parentId) && newState.data.zones) {
|
924
|
+
delete newState.data.zones[zoneCompound];
|
891
925
|
}
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
)
|
896
|
-
|
897
|
-
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
898
|
-
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
899
|
-
return walkTree(
|
900
|
-
state,
|
901
|
-
appStore.config,
|
902
|
-
(content, zoneCompound) => {
|
903
|
-
if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
|
904
|
-
return insert(
|
905
|
-
remove(content, action.sourceIndex),
|
906
|
-
action.destinationIndex,
|
907
|
-
item
|
908
|
-
);
|
909
|
-
} else if (zoneCompound === action.sourceZone) {
|
910
|
-
return remove(content, action.sourceIndex);
|
911
|
-
} else if (zoneCompound === action.destinationZone) {
|
912
|
-
return insert(content, action.destinationIndex, item);
|
913
|
-
}
|
914
|
-
return content;
|
915
|
-
},
|
916
|
-
(childItem) => {
|
917
|
-
const [sourceZoneParent] = action.sourceZone.split(":");
|
918
|
-
const [destinationZoneParent] = action.destinationZone.split(":");
|
919
|
-
const childId = childItem.props.id;
|
920
|
-
if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1) {
|
921
|
-
return childItem;
|
922
|
-
}
|
923
|
-
return null;
|
924
|
-
}
|
925
|
-
);
|
926
|
-
}
|
927
|
-
if (action.type === "remove") {
|
928
|
-
const item = getItem({ index: action.index, zone: action.zone }, state);
|
929
|
-
let deindexed = deindex(state, item);
|
930
|
-
const [parentId] = action.zone.split(":");
|
931
|
-
return walkTree(
|
932
|
-
__spreadProps(__spreadValues({}, state), { indexes: deindexed }),
|
933
|
-
appStore.config,
|
934
|
-
(content, zoneCompound) => {
|
935
|
-
if (zoneCompound === action.zone) {
|
936
|
-
return remove(content, action.index);
|
937
|
-
}
|
938
|
-
return content;
|
939
|
-
},
|
940
|
-
(childItem, path) => {
|
941
|
-
const parentIds = path.map((p) => p.split(":")[0]);
|
942
|
-
if (childItem.props.id === parentId || childItem.props.id === item.props.id || parentIds.indexOf(item.props.id) > -1) {
|
943
|
-
return childItem;
|
944
|
-
}
|
945
|
-
return null;
|
946
|
-
}
|
947
|
-
);
|
948
|
-
}
|
949
|
-
if (action.type === "registerZone") {
|
950
|
-
if (zoneCache[action.zone]) {
|
951
|
-
return __spreadProps(__spreadValues({}, state), {
|
952
|
-
data: __spreadProps(__spreadValues({}, state.data), {
|
953
|
-
zones: __spreadProps(__spreadValues({}, state.data.zones), {
|
954
|
-
[action.zone]: zoneCache[action.zone]
|
955
|
-
})
|
956
|
-
}),
|
957
|
-
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
958
|
-
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
|
959
|
-
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
|
960
|
-
contentIds: zoneCache[action.zone].map((item) => item.props.id),
|
961
|
-
type: "dropzone"
|
962
|
-
})
|
963
|
-
})
|
964
|
-
})
|
965
|
-
});
|
926
|
+
});
|
927
|
+
Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
|
928
|
+
const parentId = zoneCompound.split(":")[0];
|
929
|
+
if (nodesToDelete.includes(parentId)) {
|
930
|
+
delete newState.indexes.zones[zoneCompound];
|
966
931
|
}
|
967
|
-
|
932
|
+
});
|
933
|
+
nodesToDelete.forEach((id) => {
|
934
|
+
delete newState.indexes.nodes[id];
|
935
|
+
});
|
936
|
+
return newState;
|
937
|
+
};
|
938
|
+
|
939
|
+
// ../core/reducer/actions/register-zone.ts
|
940
|
+
init_react_import();
|
941
|
+
|
942
|
+
// ../core/lib/data/setup-zone.ts
|
943
|
+
init_react_import();
|
944
|
+
var setupZone = (data, zoneKey) => {
|
945
|
+
if (zoneKey === rootDroppableId) {
|
946
|
+
return data;
|
968
947
|
}
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
948
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
949
|
+
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
950
|
+
});
|
951
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
952
|
+
return newData;
|
953
|
+
};
|
954
|
+
|
955
|
+
// ../core/reducer/actions/register-zone.ts
|
956
|
+
var zoneCache = {};
|
957
|
+
function registerZoneAction(state, action) {
|
958
|
+
if (zoneCache[action.zone]) {
|
977
959
|
return __spreadProps(__spreadValues({}, state), {
|
978
960
|
data: __spreadProps(__spreadValues({}, state.data), {
|
979
|
-
zones:
|
961
|
+
zones: __spreadProps(__spreadValues({}, state.data.zones), {
|
962
|
+
[action.zone]: zoneCache[action.zone]
|
963
|
+
})
|
980
964
|
}),
|
981
965
|
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
982
|
-
zones:
|
966
|
+
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
|
967
|
+
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
|
968
|
+
contentIds: zoneCache[action.zone].map((item) => item.props.id),
|
969
|
+
type: "dropzone"
|
970
|
+
})
|
971
|
+
})
|
983
972
|
})
|
984
973
|
});
|
985
974
|
}
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
}
|
975
|
+
return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
|
976
|
+
}
|
977
|
+
function unregisterZoneAction(state, action) {
|
978
|
+
const _zones = __spreadValues({}, state.data.zones || {});
|
979
|
+
const zoneIndex = __spreadValues({}, state.indexes.zones || {});
|
980
|
+
if (_zones[action.zone]) {
|
981
|
+
zoneCache[action.zone] = _zones[action.zone];
|
982
|
+
delete _zones[action.zone];
|
983
|
+
}
|
984
|
+
delete zoneIndex[action.zone];
|
985
|
+
return __spreadProps(__spreadValues({}, state), {
|
986
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
987
|
+
zones: _zones
|
988
|
+
}),
|
989
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
990
|
+
zones: zoneIndex
|
991
|
+
})
|
992
|
+
});
|
993
|
+
}
|
994
|
+
|
995
|
+
// ../core/reducer/actions/set-data.ts
|
996
|
+
init_react_import();
|
997
|
+
var setDataAction = (state, action, appStore) => {
|
998
|
+
if (typeof action.data === "object") {
|
999
|
+
console.warn(
|
1000
|
+
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1001
|
+
);
|
998
1002
|
return walkTree(
|
999
1003
|
__spreadProps(__spreadValues({}, state), {
|
1000
|
-
data: __spreadValues(__spreadValues({}, state.data), action.data
|
1004
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
1001
1005
|
}),
|
1002
1006
|
appStore.config
|
1003
1007
|
);
|
1004
1008
|
}
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1009
|
+
return walkTree(
|
1010
|
+
__spreadProps(__spreadValues({}, state), {
|
1011
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
1012
|
+
}),
|
1013
|
+
appStore.config
|
1014
|
+
);
|
1015
|
+
};
|
1016
|
+
|
1017
|
+
// ../core/reducer/actions/set-ui.ts
|
1018
|
+
init_react_import();
|
1019
|
+
var setUiAction = (state, action) => {
|
1020
|
+
if (typeof action.ui === "object") {
|
1011
1021
|
return __spreadProps(__spreadValues({}, state), {
|
1012
|
-
ui: __spreadValues(__spreadValues({}, state.ui), action.ui
|
1022
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
|
1013
1023
|
});
|
1014
1024
|
}
|
1015
|
-
return state
|
1016
|
-
}
|
1025
|
+
return __spreadProps(__spreadValues({}, state), {
|
1026
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
|
1027
|
+
});
|
1028
|
+
};
|
1029
|
+
|
1030
|
+
// ../core/lib/data/make-state-public.ts
|
1031
|
+
init_react_import();
|
1032
|
+
var makeStatePublic = (state) => {
|
1033
|
+
const { data, ui } = state;
|
1034
|
+
return { data, ui };
|
1035
|
+
};
|
1017
1036
|
|
1018
1037
|
// ../core/reducer/actions.tsx
|
1019
1038
|
init_react_import();
|
@@ -1032,21 +1051,54 @@ function storeInterceptor(reducer, record, onAction) {
|
|
1032
1051
|
if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
|
1033
1052
|
if (record) record(newAppState);
|
1034
1053
|
}
|
1035
|
-
onAction == null ? void 0 : onAction(action, newAppState, state);
|
1054
|
+
onAction == null ? void 0 : onAction(action, makeStatePublic(newAppState), makeStatePublic(state));
|
1036
1055
|
return newAppState;
|
1037
1056
|
};
|
1038
1057
|
}
|
1039
1058
|
function createReducer({
|
1040
|
-
config,
|
1041
1059
|
record,
|
1042
1060
|
onAction,
|
1043
1061
|
appStore
|
1044
1062
|
}) {
|
1045
1063
|
return storeInterceptor(
|
1046
1064
|
(state, action) => {
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1065
|
+
if (action.type === "set") {
|
1066
|
+
return setAction(state, action, appStore);
|
1067
|
+
}
|
1068
|
+
if (action.type === "insert") {
|
1069
|
+
return insertAction(state, action, appStore);
|
1070
|
+
}
|
1071
|
+
if (action.type === "replace") {
|
1072
|
+
return replaceAction(state, action, appStore);
|
1073
|
+
}
|
1074
|
+
if (action.type === "replaceRoot") {
|
1075
|
+
return replaceRootAction(state, action, appStore);
|
1076
|
+
}
|
1077
|
+
if (action.type === "duplicate") {
|
1078
|
+
return duplicateAction(state, action, appStore);
|
1079
|
+
}
|
1080
|
+
if (action.type === "reorder") {
|
1081
|
+
return reorderAction(state, action, appStore);
|
1082
|
+
}
|
1083
|
+
if (action.type === "move") {
|
1084
|
+
return moveAction(state, action, appStore);
|
1085
|
+
}
|
1086
|
+
if (action.type === "remove") {
|
1087
|
+
return removeAction(state, action, appStore);
|
1088
|
+
}
|
1089
|
+
if (action.type === "registerZone") {
|
1090
|
+
return registerZoneAction(state, action);
|
1091
|
+
}
|
1092
|
+
if (action.type === "unregisterZone") {
|
1093
|
+
return unregisterZoneAction(state, action);
|
1094
|
+
}
|
1095
|
+
if (action.type === "setData") {
|
1096
|
+
return setDataAction(state, action, appStore);
|
1097
|
+
}
|
1098
|
+
if (action.type === "setUi") {
|
1099
|
+
return setUiAction(state, action);
|
1100
|
+
}
|
1101
|
+
return state;
|
1050
1102
|
},
|
1051
1103
|
record,
|
1052
1104
|
onAction
|
@@ -1241,7 +1293,7 @@ var createHistorySlice = (set, get) => {
|
|
1241
1293
|
const { dispatch, history } = get();
|
1242
1294
|
dispatch({
|
1243
1295
|
type: "set",
|
1244
|
-
state: ((_a = history.histories[
|
1296
|
+
state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
|
1245
1297
|
});
|
1246
1298
|
set({ history: __spreadProps(__spreadValues({}, history), { index }) });
|
1247
1299
|
},
|
@@ -1290,7 +1342,7 @@ var createNodesSlice = (set, get) => ({
|
|
1290
1342
|
init_react_import();
|
1291
1343
|
import { useEffect as useEffect3 } from "react";
|
1292
1344
|
|
1293
|
-
// ../core/lib/flatten-data.ts
|
1345
|
+
// ../core/lib/data/flatten-data.ts
|
1294
1346
|
init_react_import();
|
1295
1347
|
var flattenData = (state, config) => {
|
1296
1348
|
const data = [];
|
@@ -1325,12 +1377,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1325
1377
|
const { cache: cache2, globalPermissions } = permissions;
|
1326
1378
|
const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
|
1327
1379
|
var _a, _b, _c;
|
1328
|
-
const {
|
1329
|
-
config: config2,
|
1330
|
-
state: appState,
|
1331
|
-
setComponentLoading,
|
1332
|
-
unsetComponentLoading
|
1333
|
-
} = get();
|
1380
|
+
const { config: config2, state: appState, setComponentLoading } = get();
|
1334
1381
|
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
1335
1382
|
if (!componentConfig) {
|
1336
1383
|
return;
|
@@ -1339,14 +1386,14 @@ var createPermissionsSlice = (set, get) => {
|
|
1339
1386
|
if (componentConfig.resolvePermissions) {
|
1340
1387
|
const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
|
1341
1388
|
if (Object.values(changed).some((el) => el === true) || force2) {
|
1342
|
-
setComponentLoading(item2.props.id);
|
1389
|
+
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
1343
1390
|
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
1344
1391
|
item2,
|
1345
1392
|
{
|
1346
1393
|
changed,
|
1347
1394
|
lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
|
1348
1395
|
permissions: initialPermissions,
|
1349
|
-
appState,
|
1396
|
+
appState: makeStatePublic(appState),
|
1350
1397
|
lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
|
1351
1398
|
}
|
1352
1399
|
);
|
@@ -1364,7 +1411,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1364
1411
|
})
|
1365
1412
|
})
|
1366
1413
|
});
|
1367
|
-
|
1414
|
+
clearTimeout2();
|
1368
1415
|
}
|
1369
1416
|
}
|
1370
1417
|
});
|
@@ -1374,7 +1421,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1374
1421
|
// Shim the root data in by conforming to component data shape
|
1375
1422
|
{
|
1376
1423
|
type: "root",
|
1377
|
-
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "
|
1424
|
+
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "root" })
|
1378
1425
|
},
|
1379
1426
|
force2
|
1380
1427
|
);
|
@@ -1389,7 +1436,6 @@ var createPermissionsSlice = (set, get) => {
|
|
1389
1436
|
} else if (root) {
|
1390
1437
|
resolveDataForRoot(force);
|
1391
1438
|
} else {
|
1392
|
-
resolveDataForRoot(force);
|
1393
1439
|
flattenData(state, config).map((item2) => __async(void 0, null, function* () {
|
1394
1440
|
yield resolveDataForItem(item2, force);
|
1395
1441
|
}));
|
@@ -1420,7 +1466,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1420
1466
|
} else if (root) {
|
1421
1467
|
const rootConfig = config.root;
|
1422
1468
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
|
1423
|
-
const resolvedForItem = resolvedPermissions["
|
1469
|
+
const resolvedForItem = resolvedPermissions["root"];
|
1424
1470
|
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
1425
1471
|
}
|
1426
1472
|
return globalPermissions;
|
@@ -1444,24 +1490,25 @@ var createFieldsSlice = (_set, _get) => {
|
|
1444
1490
|
// ../core/lib/resolve-component-data.ts
|
1445
1491
|
init_react_import();
|
1446
1492
|
|
1447
|
-
// ../core/lib/map-slots.ts
|
1493
|
+
// ../core/lib/data/map-slots.ts
|
1448
1494
|
init_react_import();
|
1449
|
-
function
|
1450
|
-
return __async(this,
|
1495
|
+
function mapSlotsAsync(_0, _1) {
|
1496
|
+
return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
|
1451
1497
|
const props = __spreadValues({}, item.props);
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1498
|
+
const propKeys = Object.keys(props);
|
1499
|
+
for (let i = 0; i < propKeys.length; i++) {
|
1500
|
+
const propKey = propKeys[i];
|
1501
|
+
const itemType = "type" in item ? item.type : "root";
|
1502
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
1503
|
+
const content = props[propKey];
|
1455
1504
|
const mappedContent = recursive ? yield Promise.all(
|
1456
1505
|
content.map((item2) => __async(this, null, function* () {
|
1457
|
-
return yield
|
1506
|
+
return yield mapSlotsAsync(item2, map, recursive, isSlot2);
|
1458
1507
|
}))
|
1459
1508
|
) : content;
|
1460
|
-
props[
|
1461
|
-
}
|
1462
|
-
|
1463
|
-
isSlot2
|
1464
|
-
);
|
1509
|
+
props[propKey] = yield map(mappedContent, propKey);
|
1510
|
+
}
|
1511
|
+
}
|
1465
1512
|
return __spreadProps(__spreadValues({}, item), { props });
|
1466
1513
|
});
|
1467
1514
|
}
|
@@ -1470,12 +1517,12 @@ function mapSlots(item, map, recursive = true, isSlot2) {
|
|
1470
1517
|
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1471
1518
|
var cache = { lastChange: {} };
|
1472
1519
|
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
|
1473
|
-
const configForItem = "type" in item ? config.components[item.type] : config.root;
|
1520
|
+
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
1474
1521
|
if ((configForItem == null ? void 0 : configForItem.resolveData) && item.props) {
|
1475
1522
|
const id = "id" in item.props ? item.props.id : "root";
|
1476
1523
|
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
1477
|
-
if (item && item
|
1478
|
-
return resolved;
|
1524
|
+
if (item && (0, import_fast_deep_equal.default)(item, oldItem)) {
|
1525
|
+
return { node: resolved, didChange: false };
|
1479
1526
|
}
|
1480
1527
|
const changed = getChanged(item, oldItem);
|
1481
1528
|
if (onResolveStart) {
|
@@ -1484,30 +1531,35 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
1484
1531
|
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
1485
1532
|
changed,
|
1486
1533
|
lastData: oldItem,
|
1487
|
-
metadata,
|
1534
|
+
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
1488
1535
|
trigger
|
1489
1536
|
});
|
1490
1537
|
let resolvedItem = __spreadProps(__spreadValues({}, item), {
|
1491
1538
|
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
1492
1539
|
});
|
1493
1540
|
if (recursive) {
|
1494
|
-
resolvedItem = yield
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1541
|
+
resolvedItem = yield mapSlotsAsync(
|
1542
|
+
resolvedItem,
|
1543
|
+
(content) => __async(void 0, null, function* () {
|
1544
|
+
return Promise.all(
|
1545
|
+
content.map(
|
1546
|
+
(childItem) => __async(void 0, null, function* () {
|
1547
|
+
return (yield resolveComponentData(
|
1548
|
+
childItem,
|
1549
|
+
config,
|
1550
|
+
metadata,
|
1551
|
+
onResolveStart,
|
1552
|
+
onResolveEnd,
|
1553
|
+
trigger,
|
1554
|
+
false
|
1555
|
+
)).node;
|
1556
|
+
})
|
1557
|
+
)
|
1558
|
+
);
|
1559
|
+
}),
|
1560
|
+
false,
|
1561
|
+
createIsSlotConfig(config)
|
1562
|
+
);
|
1511
1563
|
}
|
1512
1564
|
if (Object.keys(readOnly).length) {
|
1513
1565
|
resolvedItem.readOnly = readOnly;
|
@@ -1524,7 +1576,7 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
1524
1576
|
return { node: item, didChange: false };
|
1525
1577
|
});
|
1526
1578
|
|
1527
|
-
// ../core/lib/to-root.ts
|
1579
|
+
// ../core/lib/data/to-root.ts
|
1528
1580
|
init_react_import();
|
1529
1581
|
var toRoot = (item) => {
|
1530
1582
|
if ("type" in item && item.type !== "root") {
|
@@ -1571,174 +1623,176 @@ var defaultPageFields = {
|
|
1571
1623
|
title: { type: "text" }
|
1572
1624
|
};
|
1573
1625
|
var createAppStore = (initialAppStore) => create()(
|
1574
|
-
subscribeWithSelector((set, get) =>
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
setComponentState
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1626
|
+
subscribeWithSelector((set, get) => {
|
1627
|
+
var _a, _b;
|
1628
|
+
return __spreadProps(__spreadValues({
|
1629
|
+
state: defaultAppState,
|
1630
|
+
config: { components: {} },
|
1631
|
+
componentState: {},
|
1632
|
+
plugins: [],
|
1633
|
+
overrides: {},
|
1634
|
+
viewports: defaultViewports,
|
1635
|
+
zoomConfig: {
|
1636
|
+
autoZoom: 1,
|
1637
|
+
rootHeight: 0,
|
1638
|
+
zoom: 1
|
1639
|
+
},
|
1640
|
+
status: "LOADING",
|
1641
|
+
iframe: {},
|
1642
|
+
metadata: {}
|
1643
|
+
}, initialAppStore), {
|
1644
|
+
fields: createFieldsSlice(set, get),
|
1645
|
+
history: createHistorySlice(set, get),
|
1646
|
+
nodes: createNodesSlice(set, get),
|
1647
|
+
permissions: createPermissionsSlice(set, get),
|
1648
|
+
getComponentConfig: (type) => {
|
1649
|
+
var _a2;
|
1650
|
+
const { config, selectedItem } = get();
|
1651
|
+
const rootFields = ((_a2 = config.root) == null ? void 0 : _a2.fields) || defaultPageFields;
|
1652
|
+
return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
|
1653
|
+
},
|
1654
|
+
selectedItem: ((_a = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _a.ui.itemSelector) ? getItem(
|
1655
|
+
(_b = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _b.ui.itemSelector,
|
1656
|
+
initialAppStore.state
|
1657
|
+
) : null,
|
1658
|
+
dispatch: (action) => set((s) => {
|
1659
|
+
var _a2, _b2;
|
1660
|
+
const { record } = get().history;
|
1661
|
+
const dispatch = createReducer({
|
1662
|
+
record,
|
1663
|
+
appStore: s
|
1664
|
+
});
|
1665
|
+
const state = dispatch(s.state, action);
|
1666
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1667
|
+
(_b2 = (_a2 = get()).onAction) == null ? void 0 : _b2.call(_a2, action, state, get().state);
|
1668
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1669
|
+
}),
|
1670
|
+
setZoomConfig: (zoomConfig) => set({ zoomConfig }),
|
1671
|
+
setStatus: (status) => set({ status }),
|
1672
|
+
setComponentState: (componentState) => set({ componentState }),
|
1673
|
+
pendingLoadTimeouts: {},
|
1674
|
+
setComponentLoading: (id, loading = true, defer = 0) => {
|
1675
|
+
const { setComponentState, pendingLoadTimeouts } = get();
|
1676
|
+
const loadId = generateId();
|
1677
|
+
const setLoading = () => {
|
1678
|
+
var _a2;
|
1679
|
+
const { componentState } = get();
|
1680
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1681
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1682
|
+
loadingCount: (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) + 1
|
1683
|
+
})
|
1684
|
+
}));
|
1685
|
+
};
|
1686
|
+
const unsetLoading = () => {
|
1687
|
+
var _a2;
|
1688
|
+
const { componentState } = get();
|
1689
|
+
clearTimeout(timeout);
|
1690
|
+
delete pendingLoadTimeouts[loadId];
|
1691
|
+
set({ pendingLoadTimeouts });
|
1692
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1693
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1694
|
+
loadingCount: Math.max(
|
1695
|
+
(((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) - 1,
|
1696
|
+
0
|
1697
|
+
)
|
1698
|
+
})
|
1699
|
+
}));
|
1700
|
+
};
|
1701
|
+
const timeout = setTimeout(() => {
|
1702
|
+
if (loading) {
|
1703
|
+
setLoading();
|
1704
|
+
} else {
|
1705
|
+
unsetLoading();
|
1706
|
+
}
|
1707
|
+
delete pendingLoadTimeouts[loadId];
|
1708
|
+
set({ pendingLoadTimeouts });
|
1709
|
+
}, defer);
|
1710
|
+
set({
|
1711
|
+
pendingLoadTimeouts: __spreadProps(__spreadValues({}, pendingLoadTimeouts), {
|
1712
|
+
[id]: timeout
|
1638
1713
|
})
|
1639
|
-
})
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
}
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1679
|
-
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1680
|
-
}),
|
1681
|
-
// resolveDataRuns: 0,
|
1682
|
-
// resolveData: (newAppState) =>
|
1683
|
-
// set((s) => {
|
1684
|
-
// resolveData(newAppState, get);
|
1685
|
-
// return { ...s, resolveDataRuns: s.resolveDataRuns + 1 };
|
1686
|
-
// }),
|
1687
|
-
resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
|
1688
|
-
const { config, metadata, setComponentLoading } = get();
|
1689
|
-
return yield resolveComponentData(
|
1690
|
-
componentData,
|
1691
|
-
config,
|
1692
|
-
metadata,
|
1693
|
-
(item) => setComponentLoading(
|
1694
|
-
"id" in item.props ? item.props.id : "root",
|
1695
|
-
true,
|
1696
|
-
50
|
1697
|
-
),
|
1698
|
-
(item) => setComponentLoading(
|
1699
|
-
"id" in item.props ? item.props.id : "root",
|
1700
|
-
false,
|
1701
|
-
0
|
1702
|
-
),
|
1703
|
-
trigger
|
1704
|
-
);
|
1705
|
-
}),
|
1706
|
-
resolveAndCommitData: () => __async(void 0, null, function* () {
|
1707
|
-
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
1708
|
-
walkTree(
|
1709
|
-
state,
|
1710
|
-
config,
|
1711
|
-
(content) => content,
|
1712
|
-
(childItem) => {
|
1713
|
-
resolveComponentData2(childItem, "load").then((resolved) => {
|
1714
|
-
const { state: state2 } = get();
|
1715
|
-
const node = state2.indexes.nodes[resolved.node.props.id];
|
1716
|
-
if (node && resolved.didChange) {
|
1717
|
-
if (resolved.node.props.id === "root") {
|
1718
|
-
dispatch({
|
1719
|
-
type: "replaceRoot",
|
1720
|
-
root: toRoot(resolved.node)
|
1721
|
-
});
|
1722
|
-
} else {
|
1723
|
-
const zoneCompound = `${node.parentId}:${node.zone}`;
|
1724
|
-
const parentZone = state2.indexes.zones[zoneCompound];
|
1725
|
-
const index = parentZone.contentIds.indexOf(
|
1726
|
-
resolved.node.props.id
|
1727
|
-
);
|
1728
|
-
dispatch({
|
1729
|
-
type: "replace",
|
1730
|
-
data: resolved.node,
|
1731
|
-
destinationIndex: index,
|
1732
|
-
destinationZone: zoneCompound
|
1733
|
-
});
|
1734
|
-
}
|
1714
|
+
});
|
1715
|
+
return unsetLoading;
|
1716
|
+
},
|
1717
|
+
unsetComponentLoading: (id) => {
|
1718
|
+
const { setComponentLoading } = get();
|
1719
|
+
setComponentLoading(id, false);
|
1720
|
+
},
|
1721
|
+
// Helper
|
1722
|
+
setUi: (ui, recordHistory) => set((s) => {
|
1723
|
+
const dispatch = createReducer({
|
1724
|
+
record: () => {
|
1725
|
+
},
|
1726
|
+
appStore: s
|
1727
|
+
});
|
1728
|
+
const state = dispatch(s.state, {
|
1729
|
+
type: "setUi",
|
1730
|
+
ui,
|
1731
|
+
recordHistory
|
1732
|
+
});
|
1733
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1734
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1735
|
+
}),
|
1736
|
+
resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
|
1737
|
+
const { config, metadata, setComponentLoading, permissions } = get();
|
1738
|
+
const timeouts = {};
|
1739
|
+
return yield resolveComponentData(
|
1740
|
+
componentData,
|
1741
|
+
config,
|
1742
|
+
metadata,
|
1743
|
+
(item) => {
|
1744
|
+
const id = "id" in item.props ? item.props.id : "root";
|
1745
|
+
timeouts[id] = setComponentLoading(id, true, 50);
|
1746
|
+
},
|
1747
|
+
(item) => __async(void 0, null, function* () {
|
1748
|
+
const id = "id" in item.props ? item.props.id : "root";
|
1749
|
+
if ("type" in item) {
|
1750
|
+
yield permissions.refreshPermissions({ item });
|
1751
|
+
} else {
|
1752
|
+
yield permissions.refreshPermissions({ root: true });
|
1735
1753
|
}
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1754
|
+
timeouts[id]();
|
1755
|
+
}),
|
1756
|
+
trigger
|
1757
|
+
);
|
1758
|
+
}),
|
1759
|
+
resolveAndCommitData: () => __async(void 0, null, function* () {
|
1760
|
+
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
1761
|
+
walkTree(
|
1762
|
+
state,
|
1763
|
+
config,
|
1764
|
+
(content) => content,
|
1765
|
+
(childItem) => {
|
1766
|
+
resolveComponentData2(childItem, "load").then((resolved) => {
|
1767
|
+
const { state: state2 } = get();
|
1768
|
+
const node = state2.indexes.nodes[resolved.node.props.id];
|
1769
|
+
if (node && resolved.didChange) {
|
1770
|
+
if (resolved.node.props.id === "root") {
|
1771
|
+
dispatch({
|
1772
|
+
type: "replaceRoot",
|
1773
|
+
root: toRoot(resolved.node)
|
1774
|
+
});
|
1775
|
+
} else {
|
1776
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
1777
|
+
const parentZone = state2.indexes.zones[zoneCompound];
|
1778
|
+
const index = parentZone.contentIds.indexOf(
|
1779
|
+
resolved.node.props.id
|
1780
|
+
);
|
1781
|
+
dispatch({
|
1782
|
+
type: "replace",
|
1783
|
+
data: resolved.node,
|
1784
|
+
destinationIndex: index,
|
1785
|
+
destinationZone: zoneCompound
|
1786
|
+
});
|
1787
|
+
}
|
1788
|
+
}
|
1789
|
+
});
|
1790
|
+
return childItem;
|
1791
|
+
}
|
1792
|
+
);
|
1793
|
+
})
|
1794
|
+
});
|
1795
|
+
})
|
1742
1796
|
);
|
1743
1797
|
var appStoreContext = createContext(createAppStore());
|
1744
1798
|
function useAppStore(selector) {
|
@@ -1800,7 +1854,10 @@ init_react_import();
|
|
1800
1854
|
// ../core/lib/filter.ts
|
1801
1855
|
init_react_import();
|
1802
1856
|
|
1803
|
-
// ../core/lib/
|
1857
|
+
// ../core/lib/data/reorder.ts
|
1858
|
+
init_react_import();
|
1859
|
+
|
1860
|
+
// ../core/lib/data/replace.ts
|
1804
1861
|
init_react_import();
|
1805
1862
|
|
1806
1863
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
|
@@ -1986,15 +2043,37 @@ var HeadingAnalyzer = () => {
|
|
1986
2043
|
const [hierarchy, setHierarchy] = useState([]);
|
1987
2044
|
useEffect5(() => {
|
1988
2045
|
const frame = getFrame();
|
1989
|
-
|
1990
|
-
|
1991
|
-
setHierarchy(buildHierarchy(entry));
|
1992
|
-
const observer = new MutationObserver(() => {
|
2046
|
+
let entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
2047
|
+
const createHierarchy = () => {
|
1993
2048
|
setHierarchy(buildHierarchy(entry));
|
2049
|
+
};
|
2050
|
+
const entryObserver = new MutationObserver(() => {
|
2051
|
+
createHierarchy();
|
2052
|
+
});
|
2053
|
+
const frameObserver = new MutationObserver(() => {
|
2054
|
+
entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
2055
|
+
if (entry) {
|
2056
|
+
registerEntryObserver();
|
2057
|
+
frameObserver.disconnect();
|
2058
|
+
}
|
1994
2059
|
});
|
1995
|
-
|
2060
|
+
const registerEntryObserver = () => {
|
2061
|
+
if (!entry) return;
|
2062
|
+
entryObserver.observe(entry, { subtree: true, childList: true });
|
2063
|
+
};
|
2064
|
+
const registerFrameObserver = () => {
|
2065
|
+
if (!frame) return;
|
2066
|
+
frameObserver.observe(frame, { subtree: true, childList: true });
|
2067
|
+
};
|
2068
|
+
if (entry) {
|
2069
|
+
createHierarchy();
|
2070
|
+
registerEntryObserver();
|
2071
|
+
} else {
|
2072
|
+
registerFrameObserver();
|
2073
|
+
}
|
1996
2074
|
return () => {
|
1997
|
-
|
2075
|
+
entryObserver.disconnect();
|
2076
|
+
frameObserver.disconnect();
|
1998
2077
|
};
|
1999
2078
|
}, [data]);
|
2000
2079
|
return /* @__PURE__ */ jsxs2("div", { className: getClassName5(), children: [
|