@measured/puck-plugin-heading-analyzer 0.19.0-canary.036267f6 → 0.19.0-canary.046cb9ed
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/README.md +1 -1
- package/dist/index.d.mts +17 -9
- package/dist/index.d.ts +17 -9
- package/dist/index.js +780 -611
- package/dist/index.mjs +780 -611
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
@@ -356,131 +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-app-state.ts
|
363
363
|
init_react_import();
|
364
|
-
var insert = (list, index, item) => {
|
365
|
-
const result = Array.from(list || []);
|
366
|
-
result.splice(index, 0, item);
|
367
|
-
return result;
|
368
|
-
};
|
369
|
-
|
370
|
-
// ../core/lib/remove.ts
|
371
|
-
init_react_import();
|
372
|
-
var remove = (list, index) => {
|
373
|
-
const result = Array.from(list);
|
374
|
-
result.splice(index, 1);
|
375
|
-
return result;
|
376
|
-
};
|
377
|
-
|
378
|
-
// ../core/lib/setup-zone.ts
|
379
|
-
init_react_import();
|
380
|
-
|
381
|
-
// ../core/lib/root-droppable-id.ts
|
382
|
-
init_react_import();
|
383
|
-
var rootAreaId = "root";
|
384
|
-
var rootZone = "default-zone";
|
385
|
-
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
386
|
-
|
387
|
-
// ../core/lib/setup-zone.ts
|
388
|
-
var setupZone = (data, zoneKey) => {
|
389
|
-
if (zoneKey === rootDroppableId) {
|
390
|
-
return data;
|
391
|
-
}
|
392
|
-
const newData = __spreadProps(__spreadValues({}, data), {
|
393
|
-
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
394
|
-
});
|
395
|
-
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
396
|
-
return newData;
|
397
|
-
};
|
398
|
-
|
399
|
-
// ../core/lib/get-item.ts
|
400
|
-
init_react_import();
|
401
|
-
function getItem(selector, state) {
|
402
|
-
var _a, _b;
|
403
|
-
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
404
|
-
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
405
|
-
}
|
406
|
-
|
407
|
-
// ../core/lib/generate-id.ts
|
408
|
-
init_react_import();
|
409
|
-
|
410
|
-
// ../../node_modules/uuid/dist/esm-node/index.js
|
411
|
-
init_react_import();
|
412
|
-
|
413
|
-
// ../../node_modules/uuid/dist/esm-node/rng.js
|
414
|
-
init_react_import();
|
415
|
-
import crypto from "crypto";
|
416
|
-
var rnds8Pool = new Uint8Array(256);
|
417
|
-
var poolPtr = rnds8Pool.length;
|
418
|
-
function rng() {
|
419
|
-
if (poolPtr > rnds8Pool.length - 16) {
|
420
|
-
crypto.randomFillSync(rnds8Pool);
|
421
|
-
poolPtr = 0;
|
422
|
-
}
|
423
|
-
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
424
|
-
}
|
425
|
-
|
426
|
-
// ../../node_modules/uuid/dist/esm-node/stringify.js
|
427
|
-
init_react_import();
|
428
|
-
var byteToHex = [];
|
429
|
-
for (let i = 0; i < 256; ++i) {
|
430
|
-
byteToHex.push((i + 256).toString(16).slice(1));
|
431
|
-
}
|
432
|
-
function unsafeStringify(arr, offset = 0) {
|
433
|
-
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]];
|
434
|
-
}
|
435
364
|
|
436
|
-
//
|
365
|
+
// ../core/lib/data/for-each-slot.ts
|
437
366
|
init_react_import();
|
438
367
|
|
439
|
-
//
|
440
|
-
init_react_import();
|
441
|
-
import crypto2 from "crypto";
|
442
|
-
var native_default = {
|
443
|
-
randomUUID: crypto2.randomUUID
|
444
|
-
};
|
445
|
-
|
446
|
-
// ../../node_modules/uuid/dist/esm-node/v4.js
|
447
|
-
function v4(options, buf, offset) {
|
448
|
-
if (native_default.randomUUID && !buf && !options) {
|
449
|
-
return native_default.randomUUID();
|
450
|
-
}
|
451
|
-
options = options || {};
|
452
|
-
const rnds = options.random || (options.rng || rng)();
|
453
|
-
rnds[6] = rnds[6] & 15 | 64;
|
454
|
-
rnds[8] = rnds[8] & 63 | 128;
|
455
|
-
if (buf) {
|
456
|
-
offset = offset || 0;
|
457
|
-
for (let i = 0; i < 16; ++i) {
|
458
|
-
buf[offset + i] = rnds[i];
|
459
|
-
}
|
460
|
-
return buf;
|
461
|
-
}
|
462
|
-
return unsafeStringify(rnds);
|
463
|
-
}
|
464
|
-
var v4_default = v4;
|
465
|
-
|
466
|
-
// ../core/lib/generate-id.ts
|
467
|
-
var generateId = (type) => type ? `${type}-${v4_default()}` : v4_default();
|
468
|
-
|
469
|
-
// ../core/lib/walk-tree.ts
|
470
|
-
init_react_import();
|
471
|
-
|
472
|
-
// ../core/lib/for-each-slot.ts
|
473
|
-
init_react_import();
|
474
|
-
|
475
|
-
// ../core/lib/is-slot.ts
|
368
|
+
// ../core/lib/data/is-slot.ts
|
476
369
|
init_react_import();
|
477
370
|
var isSlot = (prop) => {
|
478
371
|
var _a, _b;
|
479
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";
|
480
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
|
+
};
|
481
380
|
|
482
|
-
// ../core/lib/for-each-slot.ts
|
483
|
-
var forEachSlot = (
|
381
|
+
// ../core/lib/data/for-each-slot.ts
|
382
|
+
var forEachSlot = (item, cb, recursive = false, isSlot2 = isSlot) => {
|
484
383
|
const props = item.props || {};
|
485
384
|
const propKeys = Object.keys(props);
|
486
385
|
for (let i = 0; i < propKeys.length; i++) {
|
@@ -488,23 +387,31 @@ var forEachSlot = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function*
|
|
488
387
|
const itemType = "type" in item ? item.type : "root";
|
489
388
|
if (isSlot2(itemType, propKey, props[propKey])) {
|
490
389
|
const content = props[propKey];
|
491
|
-
|
390
|
+
cb(props.id, propKey, content);
|
492
391
|
if (recursive) {
|
493
392
|
content.forEach(
|
494
393
|
(childItem) => __async(void 0, null, function* () {
|
495
|
-
return
|
394
|
+
return forEachSlot(childItem, cb, true, isSlot2);
|
496
395
|
})
|
497
396
|
);
|
498
397
|
}
|
499
398
|
}
|
500
399
|
}
|
501
|
-
}
|
400
|
+
};
|
502
401
|
|
503
|
-
// ../core/lib/for-related-zones.ts
|
402
|
+
// ../core/lib/data/for-related-zones.ts
|
504
403
|
init_react_import();
|
505
404
|
|
506
405
|
// ../core/lib/get-zone-id.ts
|
507
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
|
508
415
|
var getZoneId = (zoneCompound) => {
|
509
416
|
if (!zoneCompound) {
|
510
417
|
return [];
|
@@ -515,19 +422,17 @@ var getZoneId = (zoneCompound) => {
|
|
515
422
|
return [rootDroppableId, zoneCompound];
|
516
423
|
};
|
517
424
|
|
518
|
-
// ../core/lib/for-related-zones.ts
|
425
|
+
// ../core/lib/data/for-related-zones.ts
|
519
426
|
function forRelatedZones(item, data, cb, path = []) {
|
520
427
|
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
|
521
428
|
const [parentId] = getZoneId(zoneCompound);
|
522
429
|
if (parentId === item.props.id) {
|
523
|
-
const newPath = [...path, zoneCompound];
|
524
|
-
content.forEach((item2) => forRelatedZones(item2, data, cb, newPath));
|
525
430
|
cb(path, zoneCompound, content);
|
526
431
|
}
|
527
432
|
});
|
528
433
|
}
|
529
434
|
|
530
|
-
// ../core/lib/strip-slots.ts
|
435
|
+
// ../core/lib/data/strip-slots.ts
|
531
436
|
init_react_import();
|
532
437
|
var stripSlots = (data) => {
|
533
438
|
return __spreadProps(__spreadValues({}, data), {
|
@@ -543,8 +448,8 @@ var stripSlots = (data) => {
|
|
543
448
|
});
|
544
449
|
};
|
545
450
|
|
546
|
-
// ../core/lib/walk-
|
547
|
-
function
|
451
|
+
// ../core/lib/data/walk-app-state.ts
|
452
|
+
function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
548
453
|
var _a;
|
549
454
|
let newZones = {};
|
550
455
|
const newZoneIndex = {};
|
@@ -585,7 +490,6 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
585
490
|
const mappedItem = mapNodeOrSkip(item, path, index);
|
586
491
|
if (!mappedItem) return item;
|
587
492
|
const id = mappedItem.props.id;
|
588
|
-
processRelatedZones(item, id, path);
|
589
493
|
const newProps = __spreadValues({}, mappedItem.props);
|
590
494
|
forEachSlot(
|
591
495
|
mappedItem,
|
@@ -601,13 +505,9 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
601
505
|
newProps[slotId] = newContent2;
|
602
506
|
},
|
603
507
|
false,
|
604
|
-
(
|
605
|
-
var _a2, _b;
|
606
|
-
const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
|
607
|
-
if (!configForComponent) return isSlot(propValue);
|
608
|
-
return ((_b = (_a2 = configForComponent.fields) == null ? void 0 : _a2[propName]) == null ? void 0 : _b.type) === "slot";
|
609
|
-
}
|
508
|
+
createIsSlotConfig(config)
|
610
509
|
);
|
510
|
+
processRelatedZones(item, id, path);
|
611
511
|
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
|
612
512
|
const thisZoneCompound = path[path.length - 1];
|
613
513
|
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
@@ -618,7 +518,7 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
618
518
|
parentId,
|
619
519
|
zone
|
620
520
|
};
|
621
|
-
const finalData = newItem;
|
521
|
+
const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
|
622
522
|
if (newProps.id === "root") {
|
623
523
|
delete finalData["type"];
|
624
524
|
delete finalData.props["id"];
|
@@ -633,8 +533,12 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
633
533
|
"root"
|
634
534
|
);
|
635
535
|
const processedContent = newContent;
|
536
|
+
const zonesAlreadyProcessed = Object.keys(newZones);
|
636
537
|
Object.keys(zones || {}).forEach((zoneCompound) => {
|
637
538
|
const [parentId] = zoneCompound.split(":");
|
539
|
+
if (zonesAlreadyProcessed.includes(zoneCompound)) {
|
540
|
+
return;
|
541
|
+
}
|
638
542
|
const [_2, newContent2] = processContent(
|
639
543
|
[rootDroppableId],
|
640
544
|
zoneCompound,
|
@@ -658,7 +562,6 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
658
562
|
return __spreadProps(__spreadValues({}, state), {
|
659
563
|
data: {
|
660
564
|
root,
|
661
|
-
// 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.
|
662
565
|
content: processedContent,
|
663
566
|
zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
|
664
567
|
},
|
@@ -669,60 +572,214 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
669
572
|
});
|
670
573
|
}
|
671
574
|
|
672
|
-
// ../core/
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
delete nodes[subItem.props.id];
|
682
|
-
});
|
683
|
-
delete zones[zoneCompound];
|
684
|
-
});
|
685
|
-
};
|
686
|
-
const dindexChildren = (item) => {
|
687
|
-
forEachSlot(
|
688
|
-
item,
|
689
|
-
(parentId, slotId, content) => {
|
690
|
-
const zoneCompound = `${parentId}:${slotId}`;
|
691
|
-
delete zones[zoneCompound];
|
692
|
-
content.forEach((item2) => {
|
693
|
-
dindexRelatedZones(item2);
|
694
|
-
delete nodes[item2.props.id];
|
695
|
-
});
|
696
|
-
},
|
697
|
-
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."
|
698
584
|
);
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
delete nodes[componentData.props.id];
|
703
|
-
return { nodes, zones };
|
585
|
+
return walkAppState(newState, appStore.config);
|
586
|
+
}
|
587
|
+
return __spreadValues(__spreadValues({}, state), action.state(state));
|
704
588
|
};
|
705
589
|
|
706
|
-
// ../core/reducer/
|
707
|
-
|
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();
|
708
665
|
var getIdsForParent = (zoneCompound, state) => {
|
709
666
|
const [parentId] = zoneCompound.split(":");
|
710
667
|
const node = state.indexes.nodes[parentId];
|
711
668
|
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
|
712
669
|
};
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
670
|
+
|
671
|
+
// ../core/lib/data/populate-ids.ts
|
672
|
+
init_react_import();
|
673
|
+
|
674
|
+
// ../core/lib/data/walk-tree.ts
|
675
|
+
init_react_import();
|
676
|
+
|
677
|
+
// ../core/lib/data/map-slots.ts
|
678
|
+
init_react_import();
|
679
|
+
function mapSlotsAsync(_0, _1) {
|
680
|
+
return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
|
681
|
+
const props = __spreadValues({}, item.props);
|
682
|
+
const propKeys = Object.keys(props);
|
683
|
+
for (let i = 0; i < propKeys.length; i++) {
|
684
|
+
const propKey = propKeys[i];
|
685
|
+
const itemType = "type" in item ? item.type : "root";
|
686
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
687
|
+
const content = props[propKey];
|
688
|
+
const mappedContent = recursive ? yield Promise.all(
|
689
|
+
content.map((item2) => __async(this, null, function* () {
|
690
|
+
return yield mapSlotsAsync(item2, map, recursive, isSlot2);
|
691
|
+
}))
|
692
|
+
) : content;
|
693
|
+
props[propKey] = yield map(mappedContent, propKey);
|
694
|
+
}
|
695
|
+
}
|
696
|
+
return __spreadProps(__spreadValues({}, item), { props });
|
697
|
+
});
|
698
|
+
}
|
699
|
+
function mapSlotsSync(item, map, isSlot2 = isSlot) {
|
700
|
+
var _a, _b;
|
701
|
+
const props = __spreadValues({}, item.props);
|
702
|
+
const propKeys = Object.keys(props);
|
703
|
+
for (let i = 0; i < propKeys.length; i++) {
|
704
|
+
const propKey = propKeys[i];
|
705
|
+
const itemType = "type" in item ? item.type : "root";
|
706
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
707
|
+
const content = props[propKey];
|
708
|
+
const mappedContent = content.map((item2) => {
|
709
|
+
return mapSlotsSync(item2, map, isSlot2);
|
710
|
+
});
|
711
|
+
props[propKey] = (_b = map(mappedContent, (_a = props.id) != null ? _a : "root", propKey)) != null ? _b : mappedContent;
|
712
|
+
}
|
713
|
+
}
|
714
|
+
return __spreadProps(__spreadValues({}, item), { props });
|
715
|
+
}
|
716
|
+
|
717
|
+
// ../core/lib/data/walk-tree.ts
|
718
|
+
function walkTree(data, config, callbackFn) {
|
719
|
+
var _a, _b;
|
720
|
+
const isSlot2 = createIsSlotConfig(config);
|
721
|
+
const walkItem = (item) => {
|
722
|
+
return mapSlotsSync(
|
723
|
+
item,
|
724
|
+
(content, parentId, propName) => callbackFn(content, { parentId, propName }),
|
725
|
+
isSlot2
|
726
|
+
);
|
727
|
+
};
|
728
|
+
if ("props" in data) {
|
729
|
+
return walkItem(data);
|
730
|
+
}
|
731
|
+
const _data = data;
|
732
|
+
const zones = (_a = _data.zones) != null ? _a : {};
|
733
|
+
const mappedContent = _data.content.map(walkItem);
|
734
|
+
return {
|
735
|
+
root: walkItem(_data.root),
|
736
|
+
content: (_b = callbackFn(mappedContent, {
|
737
|
+
parentId: "root",
|
738
|
+
propName: "default-zone"
|
739
|
+
})) != null ? _b : mappedContent,
|
740
|
+
zones: Object.keys(zones).reduce(
|
741
|
+
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
|
742
|
+
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
743
|
+
}),
|
744
|
+
{}
|
745
|
+
)
|
720
746
|
};
|
747
|
+
}
|
748
|
+
|
749
|
+
// ../core/lib/data/populate-ids.ts
|
750
|
+
var populateIds = (data, config, override = false) => {
|
751
|
+
const id = generateId(data.type);
|
752
|
+
return walkTree(
|
753
|
+
__spreadProps(__spreadValues({}, data), {
|
754
|
+
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({ id }, data.props)
|
755
|
+
}),
|
756
|
+
config,
|
757
|
+
(contents) => contents.map((item) => {
|
758
|
+
const id2 = generateId(item.type);
|
759
|
+
return __spreadProps(__spreadValues({}, item), {
|
760
|
+
props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
|
761
|
+
});
|
762
|
+
})
|
763
|
+
);
|
764
|
+
};
|
765
|
+
|
766
|
+
// ../core/reducer/actions/insert.ts
|
767
|
+
function insertAction(state, action, appStore) {
|
768
|
+
const id = action.id || generateId(action.componentType);
|
769
|
+
const emptyComponentData = populateIds(
|
770
|
+
{
|
771
|
+
type: action.componentType,
|
772
|
+
props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
|
773
|
+
id
|
774
|
+
})
|
775
|
+
},
|
776
|
+
appStore.config
|
777
|
+
);
|
721
778
|
const [parentId] = action.destinationZone.split(":");
|
722
779
|
const idsInPath = getIdsForParent(action.destinationZone, state);
|
723
|
-
return
|
780
|
+
return walkAppState(
|
724
781
|
state,
|
725
|
-
config,
|
782
|
+
appStore.config,
|
726
783
|
(content, zoneCompound) => {
|
727
784
|
if (zoneCompound === action.destinationZone) {
|
728
785
|
return insert(
|
@@ -733,18 +790,154 @@ function insertAction(state, action, config) {
|
|
733
790
|
}
|
734
791
|
return content;
|
735
792
|
},
|
736
|
-
(childItem, path) => {
|
737
|
-
if (childItem.props.id === id || childItem.props.id === parentId) {
|
738
|
-
return childItem;
|
739
|
-
} else if (idsInPath.includes(childItem.props.id)) {
|
740
|
-
return childItem;
|
741
|
-
} else if (path.includes(action.destinationZone)) {
|
793
|
+
(childItem, path) => {
|
794
|
+
if (childItem.props.id === id || childItem.props.id === parentId) {
|
795
|
+
return childItem;
|
796
|
+
} else if (idsInPath.includes(childItem.props.id)) {
|
797
|
+
return childItem;
|
798
|
+
} else if (path.includes(action.destinationZone)) {
|
799
|
+
return childItem;
|
800
|
+
}
|
801
|
+
return null;
|
802
|
+
}
|
803
|
+
);
|
804
|
+
}
|
805
|
+
|
806
|
+
// ../core/reducer/actions/replace.ts
|
807
|
+
init_react_import();
|
808
|
+
var replaceAction = (state, action, appStore) => {
|
809
|
+
const [parentId] = action.destinationZone.split(":");
|
810
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
811
|
+
const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
|
812
|
+
const idChanged = originalId !== action.data.props.id;
|
813
|
+
if (idChanged) {
|
814
|
+
throw new Error(
|
815
|
+
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
816
|
+
);
|
817
|
+
}
|
818
|
+
const data = populateIds(action.data, appStore.config);
|
819
|
+
return walkAppState(
|
820
|
+
state,
|
821
|
+
appStore.config,
|
822
|
+
(content, zoneCompound) => {
|
823
|
+
const newContent = [...content];
|
824
|
+
if (zoneCompound === action.destinationZone) {
|
825
|
+
newContent[action.destinationIndex] = data;
|
826
|
+
}
|
827
|
+
return newContent;
|
828
|
+
},
|
829
|
+
(childItem, path) => {
|
830
|
+
const pathIds = path.map((p) => p.split(":")[0]);
|
831
|
+
if (childItem.props.id === data.props.id) {
|
832
|
+
return data;
|
833
|
+
} else if (childItem.props.id === parentId) {
|
834
|
+
return childItem;
|
835
|
+
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
836
|
+
return childItem;
|
837
|
+
} else if (pathIds.indexOf(data.props.id) > -1) {
|
838
|
+
return childItem;
|
839
|
+
}
|
840
|
+
return null;
|
841
|
+
}
|
842
|
+
);
|
843
|
+
};
|
844
|
+
|
845
|
+
// ../core/reducer/actions/replace-root.ts
|
846
|
+
init_react_import();
|
847
|
+
var replaceRootAction = (state, action, appStore) => {
|
848
|
+
return walkAppState(
|
849
|
+
state,
|
850
|
+
appStore.config,
|
851
|
+
(content) => content,
|
852
|
+
(childItem) => {
|
853
|
+
if (childItem.props.id === "root") {
|
854
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
855
|
+
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
856
|
+
readOnly: action.root.readOnly
|
857
|
+
});
|
858
|
+
}
|
859
|
+
return childItem;
|
860
|
+
}
|
861
|
+
);
|
862
|
+
};
|
863
|
+
|
864
|
+
// ../core/reducer/actions/duplicate.ts
|
865
|
+
init_react_import();
|
866
|
+
|
867
|
+
// ../core/lib/data/get-item.ts
|
868
|
+
init_react_import();
|
869
|
+
function getItem(selector, state) {
|
870
|
+
var _a, _b;
|
871
|
+
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
872
|
+
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
873
|
+
}
|
874
|
+
|
875
|
+
// ../core/reducer/actions/duplicate.ts
|
876
|
+
function duplicateAction(state, action, appStore) {
|
877
|
+
const item = getItem(
|
878
|
+
{ index: action.sourceIndex, zone: action.sourceZone },
|
879
|
+
state
|
880
|
+
);
|
881
|
+
const idsInPath = getIdsForParent(action.sourceZone, state);
|
882
|
+
const newItem = __spreadProps(__spreadValues({}, item), {
|
883
|
+
props: __spreadProps(__spreadValues({}, item.props), {
|
884
|
+
id: generateId(item.type)
|
885
|
+
})
|
886
|
+
});
|
887
|
+
const modified = walkAppState(
|
888
|
+
state,
|
889
|
+
appStore.config,
|
890
|
+
(content, zoneCompound) => {
|
891
|
+
if (zoneCompound === action.sourceZone) {
|
892
|
+
return insert(content, action.sourceIndex + 1, item);
|
893
|
+
}
|
894
|
+
return content;
|
895
|
+
},
|
896
|
+
(childItem, path, index) => {
|
897
|
+
const zoneCompound = path[path.length - 1];
|
898
|
+
const parents = path.map((p) => p.split(":")[0]);
|
899
|
+
if (parents.indexOf(newItem.props.id) > -1) {
|
900
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
901
|
+
props: __spreadProps(__spreadValues({}, childItem.props), {
|
902
|
+
id: generateId(childItem.type)
|
903
|
+
})
|
904
|
+
});
|
905
|
+
}
|
906
|
+
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
907
|
+
return newItem;
|
908
|
+
}
|
909
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
910
|
+
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
742
911
|
return childItem;
|
743
912
|
}
|
744
913
|
return null;
|
745
914
|
}
|
746
915
|
);
|
916
|
+
return __spreadProps(__spreadValues({}, modified), {
|
917
|
+
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
918
|
+
itemSelector: {
|
919
|
+
index: action.sourceIndex + 1,
|
920
|
+
zone: action.sourceZone
|
921
|
+
}
|
922
|
+
})
|
923
|
+
});
|
747
924
|
}
|
925
|
+
|
926
|
+
// ../core/reducer/actions/reorder.ts
|
927
|
+
init_react_import();
|
928
|
+
|
929
|
+
// ../core/reducer/actions/move.ts
|
930
|
+
init_react_import();
|
931
|
+
|
932
|
+
// ../core/lib/data/remove.ts
|
933
|
+
init_react_import();
|
934
|
+
var remove = (list, index) => {
|
935
|
+
const result = Array.from(list);
|
936
|
+
result.splice(index, 1);
|
937
|
+
return result;
|
938
|
+
};
|
939
|
+
|
940
|
+
// ../core/reducer/actions/move.ts
|
748
941
|
var moveAction = (state, action, appStore) => {
|
749
942
|
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
750
943
|
return state;
|
@@ -756,7 +949,7 @@ var moveAction = (state, action, appStore) => {
|
|
756
949
|
if (!item) return state;
|
757
950
|
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
758
951
|
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
759
|
-
return
|
952
|
+
return walkAppState(
|
760
953
|
state,
|
761
954
|
appStore.config,
|
762
955
|
(content, zoneCompound) => {
|
@@ -784,222 +977,161 @@ var moveAction = (state, action, appStore) => {
|
|
784
977
|
}
|
785
978
|
);
|
786
979
|
};
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
return
|
980
|
+
|
981
|
+
// ../core/reducer/actions/reorder.ts
|
982
|
+
var reorderAction = (state, action, appStore) => {
|
983
|
+
return moveAction(
|
984
|
+
state,
|
985
|
+
{
|
986
|
+
type: "move",
|
987
|
+
sourceIndex: action.sourceIndex,
|
988
|
+
sourceZone: action.destinationZone,
|
989
|
+
destinationIndex: action.destinationIndex,
|
990
|
+
destinationZone: action.destinationZone
|
991
|
+
},
|
992
|
+
appStore
|
993
|
+
);
|
994
|
+
};
|
995
|
+
|
996
|
+
// ../core/reducer/actions/remove.ts
|
997
|
+
init_react_import();
|
998
|
+
var removeAction = (state, action, appStore) => {
|
999
|
+
const item = getItem({ index: action.index, zone: action.zone }, state);
|
1000
|
+
const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
|
1001
|
+
(acc, [nodeId, nodeData]) => {
|
1002
|
+
const pathIds = nodeData.path.map((p) => p.split(":")[0]);
|
1003
|
+
if (pathIds.includes(item.props.id)) {
|
1004
|
+
return [...acc, nodeId];
|
1005
|
+
}
|
1006
|
+
return acc;
|
1007
|
+
},
|
1008
|
+
[item.props.id]
|
1009
|
+
);
|
1010
|
+
const newState = walkAppState(
|
791
1011
|
state,
|
792
1012
|
appStore.config,
|
793
|
-
(content) =>
|
794
|
-
|
795
|
-
|
796
|
-
if (childItem.props.id === action.data.props.id) {
|
797
|
-
return action.data;
|
798
|
-
} else if (childItem.props.id === parentId) {
|
799
|
-
return childItem;
|
800
|
-
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
801
|
-
return childItem;
|
802
|
-
} else if (pathIds.indexOf(action.data.props.id) > -1) {
|
803
|
-
return childItem;
|
1013
|
+
(content, zoneCompound) => {
|
1014
|
+
if (zoneCompound === action.zone) {
|
1015
|
+
return remove(content, action.index);
|
804
1016
|
}
|
805
|
-
return
|
1017
|
+
return content;
|
806
1018
|
}
|
807
1019
|
);
|
808
|
-
}
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
if (action.state.indexes) {
|
813
|
-
console.warn(
|
814
|
-
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
815
|
-
);
|
816
|
-
return newState;
|
1020
|
+
Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
|
1021
|
+
const parentId = zoneCompound.split(":")[0];
|
1022
|
+
if (nodesToDelete.includes(parentId) && newState.data.zones) {
|
1023
|
+
delete newState.data.zones[zoneCompound];
|
817
1024
|
}
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
if (action.type === "set") {
|
824
|
-
return setAction(state, action, appStore);
|
825
|
-
}
|
826
|
-
if (action.type === "insert") {
|
827
|
-
return insertAction(state, action, appStore.config);
|
828
|
-
}
|
829
|
-
if (action.type === "replace") {
|
830
|
-
return replaceAction(state, action, appStore);
|
831
|
-
}
|
832
|
-
if (action.type === "replaceRoot") {
|
833
|
-
return walkTree(
|
834
|
-
state,
|
835
|
-
appStore.config,
|
836
|
-
(content) => content,
|
837
|
-
(childItem) => {
|
838
|
-
if (childItem.props.id === "root") {
|
839
|
-
return __spreadProps(__spreadValues({}, childItem), {
|
840
|
-
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
841
|
-
readOnly: action.root.readOnly
|
842
|
-
});
|
843
|
-
}
|
844
|
-
return childItem;
|
845
|
-
}
|
846
|
-
);
|
847
|
-
}
|
848
|
-
if (action.type === "duplicate") {
|
849
|
-
const item = getItem(
|
850
|
-
{ index: action.sourceIndex, zone: action.sourceZone },
|
851
|
-
state
|
852
|
-
);
|
853
|
-
const idsInPath = getIdsForParent(action.sourceZone, state);
|
854
|
-
const newItem = __spreadProps(__spreadValues({}, item), {
|
855
|
-
props: __spreadProps(__spreadValues({}, item.props), {
|
856
|
-
id: generateId(item.type)
|
857
|
-
})
|
858
|
-
});
|
859
|
-
const modified = walkTree(
|
860
|
-
state,
|
861
|
-
appStore.config,
|
862
|
-
(content, zoneCompound) => {
|
863
|
-
if (zoneCompound === action.sourceZone) {
|
864
|
-
return insert(content, action.sourceIndex + 1, item);
|
865
|
-
}
|
866
|
-
return content;
|
867
|
-
},
|
868
|
-
(childItem, path, index) => {
|
869
|
-
const zoneCompound = path[path.length - 1];
|
870
|
-
const parents = path.map((p) => p.split(":")[0]);
|
871
|
-
if (parents.indexOf(newItem.props.id) > -1) {
|
872
|
-
return __spreadProps(__spreadValues({}, childItem), {
|
873
|
-
props: __spreadProps(__spreadValues({}, childItem.props), {
|
874
|
-
id: generateId(childItem.type)
|
875
|
-
})
|
876
|
-
});
|
877
|
-
}
|
878
|
-
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
879
|
-
return newItem;
|
880
|
-
}
|
881
|
-
const [sourceZoneParent] = action.sourceZone.split(":");
|
882
|
-
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
883
|
-
return childItem;
|
884
|
-
}
|
885
|
-
return null;
|
886
|
-
}
|
887
|
-
);
|
888
|
-
return __spreadProps(__spreadValues({}, modified), {
|
889
|
-
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
890
|
-
itemSelector: {
|
891
|
-
index: action.sourceIndex + 1,
|
892
|
-
zone: action.sourceZone
|
893
|
-
}
|
894
|
-
})
|
895
|
-
});
|
896
|
-
}
|
897
|
-
if (action.type === "reorder") {
|
898
|
-
return moveAction(
|
899
|
-
state,
|
900
|
-
{
|
901
|
-
type: "move",
|
902
|
-
sourceIndex: action.sourceIndex,
|
903
|
-
sourceZone: action.destinationZone,
|
904
|
-
destinationIndex: action.destinationIndex,
|
905
|
-
destinationZone: action.destinationZone
|
906
|
-
},
|
907
|
-
appStore
|
908
|
-
);
|
909
|
-
}
|
910
|
-
if (action.type === "move") {
|
911
|
-
return moveAction(state, action, appStore);
|
912
|
-
}
|
913
|
-
if (action.type === "remove") {
|
914
|
-
const item = getItem({ index: action.index, zone: action.zone }, state);
|
915
|
-
let deindexed = deindex(state, item);
|
916
|
-
const [parentId] = action.zone.split(":");
|
917
|
-
return walkTree(
|
918
|
-
__spreadProps(__spreadValues({}, state), { indexes: deindexed }),
|
919
|
-
appStore.config,
|
920
|
-
(content, zoneCompound) => {
|
921
|
-
if (zoneCompound === action.zone) {
|
922
|
-
return remove(content, action.index);
|
923
|
-
}
|
924
|
-
return content;
|
925
|
-
},
|
926
|
-
(childItem, path) => {
|
927
|
-
const parentIds = path.map((p) => p.split(":")[0]);
|
928
|
-
if (childItem.props.id === parentId || childItem.props.id === item.props.id || parentIds.indexOf(item.props.id) > -1) {
|
929
|
-
return childItem;
|
930
|
-
}
|
931
|
-
return null;
|
932
|
-
}
|
933
|
-
);
|
934
|
-
}
|
935
|
-
if (action.type === "registerZone") {
|
936
|
-
if (zoneCache[action.zone]) {
|
937
|
-
return __spreadProps(__spreadValues({}, state), {
|
938
|
-
data: __spreadProps(__spreadValues({}, state.data), {
|
939
|
-
zones: __spreadProps(__spreadValues({}, state.data.zones), {
|
940
|
-
[action.zone]: zoneCache[action.zone]
|
941
|
-
})
|
942
|
-
}),
|
943
|
-
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
944
|
-
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
|
945
|
-
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
|
946
|
-
contentIds: zoneCache[action.zone].map((item) => item.props.id),
|
947
|
-
type: "dropzone"
|
948
|
-
})
|
949
|
-
})
|
950
|
-
})
|
951
|
-
});
|
1025
|
+
});
|
1026
|
+
Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
|
1027
|
+
const parentId = zoneCompound.split(":")[0];
|
1028
|
+
if (nodesToDelete.includes(parentId)) {
|
1029
|
+
delete newState.indexes.zones[zoneCompound];
|
952
1030
|
}
|
953
|
-
|
1031
|
+
});
|
1032
|
+
nodesToDelete.forEach((id) => {
|
1033
|
+
delete newState.indexes.nodes[id];
|
1034
|
+
});
|
1035
|
+
return newState;
|
1036
|
+
};
|
1037
|
+
|
1038
|
+
// ../core/reducer/actions/register-zone.ts
|
1039
|
+
init_react_import();
|
1040
|
+
|
1041
|
+
// ../core/lib/data/setup-zone.ts
|
1042
|
+
init_react_import();
|
1043
|
+
var setupZone = (data, zoneKey) => {
|
1044
|
+
if (zoneKey === rootDroppableId) {
|
1045
|
+
return data;
|
954
1046
|
}
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
1047
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
1048
|
+
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
1049
|
+
});
|
1050
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
1051
|
+
return newData;
|
1052
|
+
};
|
1053
|
+
|
1054
|
+
// ../core/reducer/actions/register-zone.ts
|
1055
|
+
var zoneCache = {};
|
1056
|
+
function registerZoneAction(state, action) {
|
1057
|
+
if (zoneCache[action.zone]) {
|
963
1058
|
return __spreadProps(__spreadValues({}, state), {
|
964
1059
|
data: __spreadProps(__spreadValues({}, state.data), {
|
965
|
-
zones:
|
1060
|
+
zones: __spreadProps(__spreadValues({}, state.data.zones), {
|
1061
|
+
[action.zone]: zoneCache[action.zone]
|
1062
|
+
})
|
966
1063
|
}),
|
967
1064
|
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
968
|
-
zones:
|
1065
|
+
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
|
1066
|
+
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
|
1067
|
+
contentIds: zoneCache[action.zone].map((item) => item.props.id),
|
1068
|
+
type: "dropzone"
|
1069
|
+
})
|
1070
|
+
})
|
969
1071
|
})
|
970
1072
|
});
|
971
1073
|
}
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
}
|
984
|
-
|
1074
|
+
return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
|
1075
|
+
}
|
1076
|
+
function unregisterZoneAction(state, action) {
|
1077
|
+
const _zones = __spreadValues({}, state.data.zones || {});
|
1078
|
+
const zoneIndex = __spreadValues({}, state.indexes.zones || {});
|
1079
|
+
if (_zones[action.zone]) {
|
1080
|
+
zoneCache[action.zone] = _zones[action.zone];
|
1081
|
+
delete _zones[action.zone];
|
1082
|
+
}
|
1083
|
+
delete zoneIndex[action.zone];
|
1084
|
+
return __spreadProps(__spreadValues({}, state), {
|
1085
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
1086
|
+
zones: _zones
|
1087
|
+
}),
|
1088
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1089
|
+
zones: zoneIndex
|
1090
|
+
})
|
1091
|
+
});
|
1092
|
+
}
|
1093
|
+
|
1094
|
+
// ../core/reducer/actions/set-data.ts
|
1095
|
+
init_react_import();
|
1096
|
+
var setDataAction = (state, action, appStore) => {
|
1097
|
+
if (typeof action.data === "object") {
|
1098
|
+
console.warn(
|
1099
|
+
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1100
|
+
);
|
1101
|
+
return walkAppState(
|
985
1102
|
__spreadProps(__spreadValues({}, state), {
|
986
|
-
data: __spreadValues(__spreadValues({}, state.data), action.data
|
1103
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
987
1104
|
}),
|
988
1105
|
appStore.config
|
989
1106
|
);
|
990
1107
|
}
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
1108
|
+
return walkAppState(
|
1109
|
+
__spreadProps(__spreadValues({}, state), {
|
1110
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
1111
|
+
}),
|
1112
|
+
appStore.config
|
1113
|
+
);
|
1114
|
+
};
|
1115
|
+
|
1116
|
+
// ../core/reducer/actions/set-ui.ts
|
1117
|
+
init_react_import();
|
1118
|
+
var setUiAction = (state, action) => {
|
1119
|
+
if (typeof action.ui === "object") {
|
997
1120
|
return __spreadProps(__spreadValues({}, state), {
|
998
|
-
ui: __spreadValues(__spreadValues({}, state.ui), action.ui
|
1121
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
|
999
1122
|
});
|
1000
1123
|
}
|
1001
|
-
return state
|
1002
|
-
}
|
1124
|
+
return __spreadProps(__spreadValues({}, state), {
|
1125
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
|
1126
|
+
});
|
1127
|
+
};
|
1128
|
+
|
1129
|
+
// ../core/lib/data/make-state-public.ts
|
1130
|
+
init_react_import();
|
1131
|
+
var makeStatePublic = (state) => {
|
1132
|
+
const { data, ui } = state;
|
1133
|
+
return { data, ui };
|
1134
|
+
};
|
1003
1135
|
|
1004
1136
|
// ../core/reducer/actions.tsx
|
1005
1137
|
init_react_import();
|
@@ -1018,7 +1150,7 @@ function storeInterceptor(reducer, record, onAction) {
|
|
1018
1150
|
if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
|
1019
1151
|
if (record) record(newAppState);
|
1020
1152
|
}
|
1021
|
-
onAction == null ? void 0 : onAction(action, newAppState, state);
|
1153
|
+
onAction == null ? void 0 : onAction(action, makeStatePublic(newAppState), makeStatePublic(state));
|
1022
1154
|
return newAppState;
|
1023
1155
|
};
|
1024
1156
|
}
|
@@ -1029,8 +1161,43 @@ function createReducer({
|
|
1029
1161
|
}) {
|
1030
1162
|
return storeInterceptor(
|
1031
1163
|
(state, action) => {
|
1032
|
-
|
1033
|
-
|
1164
|
+
if (action.type === "set") {
|
1165
|
+
return setAction(state, action, appStore);
|
1166
|
+
}
|
1167
|
+
if (action.type === "insert") {
|
1168
|
+
return insertAction(state, action, appStore);
|
1169
|
+
}
|
1170
|
+
if (action.type === "replace") {
|
1171
|
+
return replaceAction(state, action, appStore);
|
1172
|
+
}
|
1173
|
+
if (action.type === "replaceRoot") {
|
1174
|
+
return replaceRootAction(state, action, appStore);
|
1175
|
+
}
|
1176
|
+
if (action.type === "duplicate") {
|
1177
|
+
return duplicateAction(state, action, appStore);
|
1178
|
+
}
|
1179
|
+
if (action.type === "reorder") {
|
1180
|
+
return reorderAction(state, action, appStore);
|
1181
|
+
}
|
1182
|
+
if (action.type === "move") {
|
1183
|
+
return moveAction(state, action, appStore);
|
1184
|
+
}
|
1185
|
+
if (action.type === "remove") {
|
1186
|
+
return removeAction(state, action, appStore);
|
1187
|
+
}
|
1188
|
+
if (action.type === "registerZone") {
|
1189
|
+
return registerZoneAction(state, action);
|
1190
|
+
}
|
1191
|
+
if (action.type === "unregisterZone") {
|
1192
|
+
return unregisterZoneAction(state, action);
|
1193
|
+
}
|
1194
|
+
if (action.type === "setData") {
|
1195
|
+
return setDataAction(state, action, appStore);
|
1196
|
+
}
|
1197
|
+
if (action.type === "setUi") {
|
1198
|
+
return setUiAction(state, action);
|
1199
|
+
}
|
1200
|
+
return state;
|
1034
1201
|
},
|
1035
1202
|
record,
|
1036
1203
|
onAction
|
@@ -1225,7 +1392,7 @@ var createHistorySlice = (set, get) => {
|
|
1225
1392
|
const { dispatch, history } = get();
|
1226
1393
|
dispatch({
|
1227
1394
|
type: "set",
|
1228
|
-
state: ((_a = history.histories[
|
1395
|
+
state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
|
1229
1396
|
});
|
1230
1397
|
set({ history: __spreadProps(__spreadValues({}, history), { index }) });
|
1231
1398
|
},
|
@@ -1274,11 +1441,11 @@ var createNodesSlice = (set, get) => ({
|
|
1274
1441
|
init_react_import();
|
1275
1442
|
import { useEffect as useEffect3 } from "react";
|
1276
1443
|
|
1277
|
-
// ../core/lib/flatten-data.ts
|
1444
|
+
// ../core/lib/data/flatten-data.ts
|
1278
1445
|
init_react_import();
|
1279
1446
|
var flattenData = (state, config) => {
|
1280
1447
|
const data = [];
|
1281
|
-
|
1448
|
+
walkAppState(
|
1282
1449
|
state,
|
1283
1450
|
config,
|
1284
1451
|
(content) => content,
|
@@ -1309,12 +1476,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1309
1476
|
const { cache: cache2, globalPermissions } = permissions;
|
1310
1477
|
const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
|
1311
1478
|
var _a, _b, _c;
|
1312
|
-
const {
|
1313
|
-
config: config2,
|
1314
|
-
state: appState,
|
1315
|
-
setComponentLoading,
|
1316
|
-
unsetComponentLoading
|
1317
|
-
} = get();
|
1479
|
+
const { config: config2, state: appState, setComponentLoading } = get();
|
1318
1480
|
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
1319
1481
|
if (!componentConfig) {
|
1320
1482
|
return;
|
@@ -1323,14 +1485,14 @@ var createPermissionsSlice = (set, get) => {
|
|
1323
1485
|
if (componentConfig.resolvePermissions) {
|
1324
1486
|
const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
|
1325
1487
|
if (Object.values(changed).some((el) => el === true) || force2) {
|
1326
|
-
setComponentLoading(item2.props.id);
|
1488
|
+
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
1327
1489
|
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
1328
1490
|
item2,
|
1329
1491
|
{
|
1330
1492
|
changed,
|
1331
1493
|
lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
|
1332
1494
|
permissions: initialPermissions,
|
1333
|
-
appState,
|
1495
|
+
appState: makeStatePublic(appState),
|
1334
1496
|
lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
|
1335
1497
|
}
|
1336
1498
|
);
|
@@ -1348,7 +1510,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1348
1510
|
})
|
1349
1511
|
})
|
1350
1512
|
});
|
1351
|
-
|
1513
|
+
clearTimeout2();
|
1352
1514
|
}
|
1353
1515
|
}
|
1354
1516
|
});
|
@@ -1358,7 +1520,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1358
1520
|
// Shim the root data in by conforming to component data shape
|
1359
1521
|
{
|
1360
1522
|
type: "root",
|
1361
|
-
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "
|
1523
|
+
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "root" })
|
1362
1524
|
},
|
1363
1525
|
force2
|
1364
1526
|
);
|
@@ -1373,7 +1535,6 @@ var createPermissionsSlice = (set, get) => {
|
|
1373
1535
|
} else if (root) {
|
1374
1536
|
resolveDataForRoot(force);
|
1375
1537
|
} else {
|
1376
|
-
resolveDataForRoot(force);
|
1377
1538
|
flattenData(state, config).map((item2) => __async(void 0, null, function* () {
|
1378
1539
|
yield resolveDataForItem(item2, force);
|
1379
1540
|
}));
|
@@ -1404,7 +1565,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1404
1565
|
} else if (root) {
|
1405
1566
|
const rootConfig = config.root;
|
1406
1567
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
|
1407
|
-
const resolvedForItem = resolvedPermissions["
|
1568
|
+
const resolvedForItem = resolvedPermissions["root"];
|
1408
1569
|
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
1409
1570
|
}
|
1410
1571
|
return globalPermissions;
|
@@ -1421,45 +1582,22 @@ var createFieldsSlice = (_set, _get) => {
|
|
1421
1582
|
return {
|
1422
1583
|
fields: {},
|
1423
1584
|
loading: false,
|
1424
|
-
lastResolvedData: {}
|
1585
|
+
lastResolvedData: {},
|
1586
|
+
id: void 0
|
1425
1587
|
};
|
1426
1588
|
};
|
1427
1589
|
|
1428
1590
|
// ../core/lib/resolve-component-data.ts
|
1429
1591
|
init_react_import();
|
1430
|
-
|
1431
|
-
// ../core/lib/map-slots.ts
|
1432
|
-
init_react_import();
|
1433
|
-
function mapSlots(item, map, recursive = true, isSlot2) {
|
1434
|
-
return __async(this, null, function* () {
|
1435
|
-
const props = __spreadValues({}, item.props);
|
1436
|
-
yield forEachSlot(
|
1437
|
-
item,
|
1438
|
-
(_parentId, propName, content) => __async(this, null, function* () {
|
1439
|
-
const mappedContent = recursive ? yield Promise.all(
|
1440
|
-
content.map((item2) => __async(this, null, function* () {
|
1441
|
-
return yield mapSlots(item2, map, recursive, isSlot2);
|
1442
|
-
}))
|
1443
|
-
) : content;
|
1444
|
-
props[propName] = yield map(mappedContent, propName);
|
1445
|
-
}),
|
1446
|
-
false,
|
1447
|
-
isSlot2
|
1448
|
-
);
|
1449
|
-
return __spreadProps(__spreadValues({}, item), { props });
|
1450
|
-
});
|
1451
|
-
}
|
1452
|
-
|
1453
|
-
// ../core/lib/resolve-component-data.ts
|
1454
1592
|
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1455
1593
|
var cache = { lastChange: {} };
|
1456
1594
|
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
|
1457
|
-
const configForItem = "type" in item ? config.components[item.type] : config.root;
|
1595
|
+
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
1458
1596
|
if ((configForItem == null ? void 0 : configForItem.resolveData) && item.props) {
|
1459
1597
|
const id = "id" in item.props ? item.props.id : "root";
|
1460
1598
|
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
1461
|
-
if (item && item
|
1462
|
-
return resolved;
|
1599
|
+
if (item && (0, import_fast_deep_equal.default)(item, oldItem)) {
|
1600
|
+
return { node: resolved, didChange: false };
|
1463
1601
|
}
|
1464
1602
|
const changed = getChanged(item, oldItem);
|
1465
1603
|
if (onResolveStart) {
|
@@ -1468,30 +1606,35 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
1468
1606
|
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
1469
1607
|
changed,
|
1470
1608
|
lastData: oldItem,
|
1471
|
-
metadata,
|
1609
|
+
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
1472
1610
|
trigger
|
1473
1611
|
});
|
1474
1612
|
let resolvedItem = __spreadProps(__spreadValues({}, item), {
|
1475
1613
|
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
1476
1614
|
});
|
1477
1615
|
if (recursive) {
|
1478
|
-
resolvedItem = yield
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1616
|
+
resolvedItem = yield mapSlotsAsync(
|
1617
|
+
resolvedItem,
|
1618
|
+
(content) => __async(void 0, null, function* () {
|
1619
|
+
return Promise.all(
|
1620
|
+
content.map(
|
1621
|
+
(childItem) => __async(void 0, null, function* () {
|
1622
|
+
return (yield resolveComponentData(
|
1623
|
+
childItem,
|
1624
|
+
config,
|
1625
|
+
metadata,
|
1626
|
+
onResolveStart,
|
1627
|
+
onResolveEnd,
|
1628
|
+
trigger,
|
1629
|
+
false
|
1630
|
+
)).node;
|
1631
|
+
})
|
1632
|
+
)
|
1633
|
+
);
|
1634
|
+
}),
|
1635
|
+
false,
|
1636
|
+
createIsSlotConfig(config)
|
1637
|
+
);
|
1495
1638
|
}
|
1496
1639
|
if (Object.keys(readOnly).length) {
|
1497
1640
|
resolvedItem.readOnly = readOnly;
|
@@ -1508,7 +1651,7 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
1508
1651
|
return { node: item, didChange: false };
|
1509
1652
|
});
|
1510
1653
|
|
1511
|
-
// ../core/lib/to-root.ts
|
1654
|
+
// ../core/lib/data/to-root.ts
|
1512
1655
|
init_react_import();
|
1513
1656
|
var toRoot = (item) => {
|
1514
1657
|
if ("type" in item && item.type !== "root") {
|
@@ -1555,172 +1698,176 @@ var defaultPageFields = {
|
|
1555
1698
|
title: { type: "text" }
|
1556
1699
|
};
|
1557
1700
|
var createAppStore = (initialAppStore) => create()(
|
1558
|
-
subscribeWithSelector((set, get) =>
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
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
|
-
|
1701
|
+
subscribeWithSelector((set, get) => {
|
1702
|
+
var _a, _b;
|
1703
|
+
return __spreadProps(__spreadValues({
|
1704
|
+
state: defaultAppState,
|
1705
|
+
config: { components: {} },
|
1706
|
+
componentState: {},
|
1707
|
+
plugins: [],
|
1708
|
+
overrides: {},
|
1709
|
+
viewports: defaultViewports,
|
1710
|
+
zoomConfig: {
|
1711
|
+
autoZoom: 1,
|
1712
|
+
rootHeight: 0,
|
1713
|
+
zoom: 1
|
1714
|
+
},
|
1715
|
+
status: "LOADING",
|
1716
|
+
iframe: {},
|
1717
|
+
metadata: {}
|
1718
|
+
}, initialAppStore), {
|
1719
|
+
fields: createFieldsSlice(set, get),
|
1720
|
+
history: createHistorySlice(set, get),
|
1721
|
+
nodes: createNodesSlice(set, get),
|
1722
|
+
permissions: createPermissionsSlice(set, get),
|
1723
|
+
getComponentConfig: (type) => {
|
1724
|
+
var _a2;
|
1725
|
+
const { config, selectedItem } = get();
|
1726
|
+
const rootFields = ((_a2 = config.root) == null ? void 0 : _a2.fields) || defaultPageFields;
|
1727
|
+
return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
|
1728
|
+
},
|
1729
|
+
selectedItem: ((_a = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _a.ui.itemSelector) ? getItem(
|
1730
|
+
(_b = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _b.ui.itemSelector,
|
1731
|
+
initialAppStore.state
|
1732
|
+
) : null,
|
1733
|
+
dispatch: (action) => set((s) => {
|
1734
|
+
var _a2, _b2;
|
1735
|
+
const { record } = get().history;
|
1736
|
+
const dispatch = createReducer({
|
1737
|
+
record,
|
1738
|
+
appStore: s
|
1739
|
+
});
|
1740
|
+
const state = dispatch(s.state, action);
|
1741
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1742
|
+
(_b2 = (_a2 = get()).onAction) == null ? void 0 : _b2.call(_a2, action, state, get().state);
|
1743
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1744
|
+
}),
|
1745
|
+
setZoomConfig: (zoomConfig) => set({ zoomConfig }),
|
1746
|
+
setStatus: (status) => set({ status }),
|
1747
|
+
setComponentState: (componentState) => set({ componentState }),
|
1748
|
+
pendingLoadTimeouts: {},
|
1749
|
+
setComponentLoading: (id, loading = true, defer = 0) => {
|
1750
|
+
const { setComponentState, pendingLoadTimeouts } = get();
|
1751
|
+
const loadId = generateId();
|
1752
|
+
const setLoading = () => {
|
1753
|
+
var _a2;
|
1754
|
+
const { componentState } = get();
|
1755
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1756
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1757
|
+
loadingCount: (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) + 1
|
1758
|
+
})
|
1759
|
+
}));
|
1760
|
+
};
|
1761
|
+
const unsetLoading = () => {
|
1762
|
+
var _a2;
|
1763
|
+
const { componentState } = get();
|
1764
|
+
clearTimeout(timeout);
|
1765
|
+
delete pendingLoadTimeouts[loadId];
|
1766
|
+
set({ pendingLoadTimeouts });
|
1767
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1768
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1769
|
+
loadingCount: Math.max(
|
1770
|
+
(((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) - 1,
|
1771
|
+
0
|
1772
|
+
)
|
1773
|
+
})
|
1774
|
+
}));
|
1775
|
+
};
|
1776
|
+
const timeout = setTimeout(() => {
|
1777
|
+
if (loading) {
|
1778
|
+
setLoading();
|
1779
|
+
} else {
|
1780
|
+
unsetLoading();
|
1781
|
+
}
|
1782
|
+
delete pendingLoadTimeouts[loadId];
|
1783
|
+
set({ pendingLoadTimeouts });
|
1784
|
+
}, defer);
|
1785
|
+
set({
|
1786
|
+
pendingLoadTimeouts: __spreadProps(__spreadValues({}, pendingLoadTimeouts), {
|
1787
|
+
[id]: timeout
|
1621
1788
|
})
|
1622
|
-
})
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
}
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1662
|
-
}),
|
1663
|
-
// resolveDataRuns: 0,
|
1664
|
-
// resolveData: (newAppState) =>
|
1665
|
-
// set((s) => {
|
1666
|
-
// resolveData(newAppState, get);
|
1667
|
-
// return { ...s, resolveDataRuns: s.resolveDataRuns + 1 };
|
1668
|
-
// }),
|
1669
|
-
resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
|
1670
|
-
const { config, metadata, setComponentLoading } = get();
|
1671
|
-
return yield resolveComponentData(
|
1672
|
-
componentData,
|
1673
|
-
config,
|
1674
|
-
metadata,
|
1675
|
-
(item) => setComponentLoading(
|
1676
|
-
"id" in item.props ? item.props.id : "root",
|
1677
|
-
true,
|
1678
|
-
50
|
1679
|
-
),
|
1680
|
-
(item) => setComponentLoading(
|
1681
|
-
"id" in item.props ? item.props.id : "root",
|
1682
|
-
false,
|
1683
|
-
0
|
1684
|
-
),
|
1685
|
-
trigger
|
1686
|
-
);
|
1687
|
-
}),
|
1688
|
-
resolveAndCommitData: () => __async(void 0, null, function* () {
|
1689
|
-
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
1690
|
-
walkTree(
|
1691
|
-
state,
|
1692
|
-
config,
|
1693
|
-
(content) => content,
|
1694
|
-
(childItem) => {
|
1695
|
-
resolveComponentData2(childItem, "load").then((resolved) => {
|
1696
|
-
const { state: state2 } = get();
|
1697
|
-
const node = state2.indexes.nodes[resolved.node.props.id];
|
1698
|
-
if (node && resolved.didChange) {
|
1699
|
-
if (resolved.node.props.id === "root") {
|
1700
|
-
dispatch({
|
1701
|
-
type: "replaceRoot",
|
1702
|
-
root: toRoot(resolved.node)
|
1703
|
-
});
|
1704
|
-
} else {
|
1705
|
-
const zoneCompound = `${node.parentId}:${node.zone}`;
|
1706
|
-
const parentZone = state2.indexes.zones[zoneCompound];
|
1707
|
-
const index = parentZone.contentIds.indexOf(
|
1708
|
-
resolved.node.props.id
|
1709
|
-
);
|
1710
|
-
dispatch({
|
1711
|
-
type: "replace",
|
1712
|
-
data: resolved.node,
|
1713
|
-
destinationIndex: index,
|
1714
|
-
destinationZone: zoneCompound
|
1715
|
-
});
|
1716
|
-
}
|
1789
|
+
});
|
1790
|
+
return unsetLoading;
|
1791
|
+
},
|
1792
|
+
unsetComponentLoading: (id) => {
|
1793
|
+
const { setComponentLoading } = get();
|
1794
|
+
setComponentLoading(id, false);
|
1795
|
+
},
|
1796
|
+
// Helper
|
1797
|
+
setUi: (ui, recordHistory) => set((s) => {
|
1798
|
+
const dispatch = createReducer({
|
1799
|
+
record: () => {
|
1800
|
+
},
|
1801
|
+
appStore: s
|
1802
|
+
});
|
1803
|
+
const state = dispatch(s.state, {
|
1804
|
+
type: "setUi",
|
1805
|
+
ui,
|
1806
|
+
recordHistory
|
1807
|
+
});
|
1808
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1809
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1810
|
+
}),
|
1811
|
+
resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
|
1812
|
+
const { config, metadata, setComponentLoading, permissions } = get();
|
1813
|
+
const timeouts = {};
|
1814
|
+
return yield resolveComponentData(
|
1815
|
+
componentData,
|
1816
|
+
config,
|
1817
|
+
metadata,
|
1818
|
+
(item) => {
|
1819
|
+
const id = "id" in item.props ? item.props.id : "root";
|
1820
|
+
timeouts[id] = setComponentLoading(id, true, 50);
|
1821
|
+
},
|
1822
|
+
(item) => __async(void 0, null, function* () {
|
1823
|
+
const id = "id" in item.props ? item.props.id : "root";
|
1824
|
+
if ("type" in item) {
|
1825
|
+
yield permissions.refreshPermissions({ item });
|
1826
|
+
} else {
|
1827
|
+
yield permissions.refreshPermissions({ root: true });
|
1717
1828
|
}
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1829
|
+
timeouts[id]();
|
1830
|
+
}),
|
1831
|
+
trigger
|
1832
|
+
);
|
1833
|
+
}),
|
1834
|
+
resolveAndCommitData: () => __async(void 0, null, function* () {
|
1835
|
+
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
1836
|
+
walkAppState(
|
1837
|
+
state,
|
1838
|
+
config,
|
1839
|
+
(content) => content,
|
1840
|
+
(childItem) => {
|
1841
|
+
resolveComponentData2(childItem, "load").then((resolved) => {
|
1842
|
+
const { state: state2 } = get();
|
1843
|
+
const node = state2.indexes.nodes[resolved.node.props.id];
|
1844
|
+
if (node && resolved.didChange) {
|
1845
|
+
if (resolved.node.props.id === "root") {
|
1846
|
+
dispatch({
|
1847
|
+
type: "replaceRoot",
|
1848
|
+
root: toRoot(resolved.node)
|
1849
|
+
});
|
1850
|
+
} else {
|
1851
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
1852
|
+
const parentZone = state2.indexes.zones[zoneCompound];
|
1853
|
+
const index = parentZone.contentIds.indexOf(
|
1854
|
+
resolved.node.props.id
|
1855
|
+
);
|
1856
|
+
dispatch({
|
1857
|
+
type: "replace",
|
1858
|
+
data: resolved.node,
|
1859
|
+
destinationIndex: index,
|
1860
|
+
destinationZone: zoneCompound
|
1861
|
+
});
|
1862
|
+
}
|
1863
|
+
}
|
1864
|
+
});
|
1865
|
+
return childItem;
|
1866
|
+
}
|
1867
|
+
);
|
1868
|
+
})
|
1869
|
+
});
|
1870
|
+
})
|
1724
1871
|
);
|
1725
1872
|
var appStoreContext = createContext(createAppStore());
|
1726
1873
|
function useAppStore(selector) {
|
@@ -1782,10 +1929,10 @@ init_react_import();
|
|
1782
1929
|
// ../core/lib/filter.ts
|
1783
1930
|
init_react_import();
|
1784
1931
|
|
1785
|
-
// ../core/lib/reorder.ts
|
1932
|
+
// ../core/lib/data/reorder.ts
|
1786
1933
|
init_react_import();
|
1787
1934
|
|
1788
|
-
// ../core/lib/replace.ts
|
1935
|
+
// ../core/lib/data/replace.ts
|
1789
1936
|
init_react_import();
|
1790
1937
|
|
1791
1938
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
|
@@ -1971,15 +2118,37 @@ var HeadingAnalyzer = () => {
|
|
1971
2118
|
const [hierarchy, setHierarchy] = useState([]);
|
1972
2119
|
useEffect5(() => {
|
1973
2120
|
const frame = getFrame();
|
1974
|
-
|
1975
|
-
|
1976
|
-
setHierarchy(buildHierarchy(entry));
|
1977
|
-
const observer = new MutationObserver(() => {
|
2121
|
+
let entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
2122
|
+
const createHierarchy = () => {
|
1978
2123
|
setHierarchy(buildHierarchy(entry));
|
2124
|
+
};
|
2125
|
+
const entryObserver = new MutationObserver(() => {
|
2126
|
+
createHierarchy();
|
2127
|
+
});
|
2128
|
+
const frameObserver = new MutationObserver(() => {
|
2129
|
+
entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
2130
|
+
if (entry) {
|
2131
|
+
registerEntryObserver();
|
2132
|
+
frameObserver.disconnect();
|
2133
|
+
}
|
1979
2134
|
});
|
1980
|
-
|
2135
|
+
const registerEntryObserver = () => {
|
2136
|
+
if (!entry) return;
|
2137
|
+
entryObserver.observe(entry, { subtree: true, childList: true });
|
2138
|
+
};
|
2139
|
+
const registerFrameObserver = () => {
|
2140
|
+
if (!frame) return;
|
2141
|
+
frameObserver.observe(frame, { subtree: true, childList: true });
|
2142
|
+
};
|
2143
|
+
if (entry) {
|
2144
|
+
createHierarchy();
|
2145
|
+
registerEntryObserver();
|
2146
|
+
} else {
|
2147
|
+
registerFrameObserver();
|
2148
|
+
}
|
1981
2149
|
return () => {
|
1982
|
-
|
2150
|
+
entryObserver.disconnect();
|
2151
|
+
frameObserver.disconnect();
|
1983
2152
|
};
|
1984
2153
|
}, [data]);
|
1985
2154
|
return /* @__PURE__ */ jsxs2("div", { className: getClassName5(), children: [
|