@measured/puck-plugin-heading-analyzer 0.19.0-canary.ad78e98 → 0.19.0-canary.b46ce9ce
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 +23 -10
- package/dist/index.d.ts +23 -10
- package/dist/index.js +1226 -673
- package/dist/index.mjs +1219 -666
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
@@ -146,6 +146,120 @@ var require_classnames = __commonJS({
|
|
146
146
|
}
|
147
147
|
});
|
148
148
|
|
149
|
+
// ../../node_modules/flat/index.js
|
150
|
+
var require_flat = __commonJS({
|
151
|
+
"../../node_modules/flat/index.js"(exports, module) {
|
152
|
+
"use strict";
|
153
|
+
init_react_import();
|
154
|
+
module.exports = flatten3;
|
155
|
+
flatten3.flatten = flatten3;
|
156
|
+
flatten3.unflatten = unflatten2;
|
157
|
+
function isBuffer(obj) {
|
158
|
+
return obj && obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
|
159
|
+
}
|
160
|
+
function keyIdentity(key) {
|
161
|
+
return key;
|
162
|
+
}
|
163
|
+
function flatten3(target, opts) {
|
164
|
+
opts = opts || {};
|
165
|
+
const delimiter = opts.delimiter || ".";
|
166
|
+
const maxDepth = opts.maxDepth;
|
167
|
+
const transformKey = opts.transformKey || keyIdentity;
|
168
|
+
const output = {};
|
169
|
+
function step(object, prev, currentDepth) {
|
170
|
+
currentDepth = currentDepth || 1;
|
171
|
+
Object.keys(object).forEach(function(key) {
|
172
|
+
const value = object[key];
|
173
|
+
const isarray = opts.safe && Array.isArray(value);
|
174
|
+
const type = Object.prototype.toString.call(value);
|
175
|
+
const isbuffer = isBuffer(value);
|
176
|
+
const isobject = type === "[object Object]" || type === "[object Array]";
|
177
|
+
const newKey = prev ? prev + delimiter + transformKey(key) : transformKey(key);
|
178
|
+
if (!isarray && !isbuffer && isobject && Object.keys(value).length && (!opts.maxDepth || currentDepth < maxDepth)) {
|
179
|
+
return step(value, newKey, currentDepth + 1);
|
180
|
+
}
|
181
|
+
output[newKey] = value;
|
182
|
+
});
|
183
|
+
}
|
184
|
+
step(target);
|
185
|
+
return output;
|
186
|
+
}
|
187
|
+
function unflatten2(target, opts) {
|
188
|
+
opts = opts || {};
|
189
|
+
const delimiter = opts.delimiter || ".";
|
190
|
+
const overwrite = opts.overwrite || false;
|
191
|
+
const transformKey = opts.transformKey || keyIdentity;
|
192
|
+
const result = {};
|
193
|
+
const isbuffer = isBuffer(target);
|
194
|
+
if (isbuffer || Object.prototype.toString.call(target) !== "[object Object]") {
|
195
|
+
return target;
|
196
|
+
}
|
197
|
+
function getkey(key) {
|
198
|
+
const parsedKey = Number(key);
|
199
|
+
return isNaN(parsedKey) || key.indexOf(".") !== -1 || opts.object ? key : parsedKey;
|
200
|
+
}
|
201
|
+
function addKeys(keyPrefix, recipient, target2) {
|
202
|
+
return Object.keys(target2).reduce(function(result2, key) {
|
203
|
+
result2[keyPrefix + delimiter + key] = target2[key];
|
204
|
+
return result2;
|
205
|
+
}, recipient);
|
206
|
+
}
|
207
|
+
function isEmpty(val) {
|
208
|
+
const type = Object.prototype.toString.call(val);
|
209
|
+
const isArray = type === "[object Array]";
|
210
|
+
const isObject = type === "[object Object]";
|
211
|
+
if (!val) {
|
212
|
+
return true;
|
213
|
+
} else if (isArray) {
|
214
|
+
return !val.length;
|
215
|
+
} else if (isObject) {
|
216
|
+
return !Object.keys(val).length;
|
217
|
+
}
|
218
|
+
}
|
219
|
+
target = Object.keys(target).reduce(function(result2, key) {
|
220
|
+
const type = Object.prototype.toString.call(target[key]);
|
221
|
+
const isObject = type === "[object Object]" || type === "[object Array]";
|
222
|
+
if (!isObject || isEmpty(target[key])) {
|
223
|
+
result2[key] = target[key];
|
224
|
+
return result2;
|
225
|
+
} else {
|
226
|
+
return addKeys(
|
227
|
+
key,
|
228
|
+
result2,
|
229
|
+
flatten3(target[key], opts)
|
230
|
+
);
|
231
|
+
}
|
232
|
+
}, {});
|
233
|
+
Object.keys(target).forEach(function(key) {
|
234
|
+
const split = key.split(delimiter).map(transformKey);
|
235
|
+
let key1 = getkey(split.shift());
|
236
|
+
let key2 = getkey(split[0]);
|
237
|
+
let recipient = result;
|
238
|
+
while (key2 !== void 0) {
|
239
|
+
if (key1 === "__proto__") {
|
240
|
+
return;
|
241
|
+
}
|
242
|
+
const type = Object.prototype.toString.call(recipient[key1]);
|
243
|
+
const isobject = type === "[object Object]" || type === "[object Array]";
|
244
|
+
if (!overwrite && !isobject && typeof recipient[key1] !== "undefined") {
|
245
|
+
return;
|
246
|
+
}
|
247
|
+
if (overwrite && !isobject || !overwrite && recipient[key1] == null) {
|
248
|
+
recipient[key1] = typeof key2 === "number" && !opts.object ? [] : {};
|
249
|
+
}
|
250
|
+
recipient = recipient[key1];
|
251
|
+
if (split.length > 0) {
|
252
|
+
key1 = getkey(split.shift());
|
253
|
+
key2 = getkey(split[0]);
|
254
|
+
}
|
255
|
+
}
|
256
|
+
recipient[key1] = unflatten2(target[key], opts);
|
257
|
+
});
|
258
|
+
return result;
|
259
|
+
}
|
260
|
+
}
|
261
|
+
});
|
262
|
+
|
149
263
|
// ../../node_modules/fast-deep-equal/index.js
|
150
264
|
var require_fast_deep_equal = __commonJS({
|
151
265
|
"../../node_modules/fast-deep-equal/index.js"(exports, module) {
|
@@ -187,7 +301,7 @@ init_react_import();
|
|
187
301
|
|
188
302
|
// src/HeadingAnalyzer.tsx
|
189
303
|
init_react_import();
|
190
|
-
import { useEffect as
|
304
|
+
import { useEffect as useEffect5, useState } from "react";
|
191
305
|
|
192
306
|
// css-module:/home/runner/work/puck/puck/packages/plugin-heading-analyzer/src/HeadingAnalyzer.module.css#css-module
|
193
307
|
init_react_import();
|
@@ -356,17 +470,17 @@ init_react_import();
|
|
356
470
|
// ../core/reducer/index.ts
|
357
471
|
init_react_import();
|
358
472
|
|
359
|
-
// ../core/reducer/
|
473
|
+
// ../core/reducer/actions/set.ts
|
360
474
|
init_react_import();
|
361
475
|
|
362
|
-
// ../core/lib/
|
476
|
+
// ../core/lib/data/walk-app-state.ts
|
477
|
+
init_react_import();
|
478
|
+
|
479
|
+
// ../core/lib/data/for-related-zones.ts
|
480
|
+
init_react_import();
|
481
|
+
|
482
|
+
// ../core/lib/get-zone-id.ts
|
363
483
|
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
484
|
|
371
485
|
// ../core/lib/root-droppable-id.ts
|
372
486
|
init_react_import();
|
@@ -374,57 +488,327 @@ var rootAreaId = "root";
|
|
374
488
|
var rootZone = "default-zone";
|
375
489
|
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
376
490
|
|
377
|
-
// ../core/lib/
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
491
|
+
// ../core/lib/get-zone-id.ts
|
492
|
+
var getZoneId = (zoneCompound) => {
|
493
|
+
if (!zoneCompound) {
|
494
|
+
return [];
|
495
|
+
}
|
496
|
+
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
497
|
+
return zoneCompound.split(":");
|
498
|
+
}
|
499
|
+
return [rootDroppableId, zoneCompound];
|
383
500
|
};
|
384
501
|
|
385
|
-
// ../core/lib/
|
502
|
+
// ../core/lib/data/for-related-zones.ts
|
503
|
+
function forRelatedZones(item, data, cb, path = []) {
|
504
|
+
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
|
505
|
+
const [parentId] = getZoneId(zoneCompound);
|
506
|
+
if (parentId === item.props.id) {
|
507
|
+
cb(path, zoneCompound, content);
|
508
|
+
}
|
509
|
+
});
|
510
|
+
}
|
511
|
+
|
512
|
+
// ../core/lib/data/map-slots.ts
|
386
513
|
init_react_import();
|
387
|
-
var
|
388
|
-
|
389
|
-
|
390
|
-
|
514
|
+
var isPromise = (v) => !!v && typeof v.then === "function";
|
515
|
+
var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
|
516
|
+
var containsPromise = (arr) => arr.some(isPromise);
|
517
|
+
var walkField = ({
|
518
|
+
value,
|
519
|
+
fields,
|
520
|
+
map,
|
521
|
+
propKey = "",
|
522
|
+
propPath = "",
|
523
|
+
id = "",
|
524
|
+
config,
|
525
|
+
recurseSlots = false
|
526
|
+
}) => {
|
527
|
+
var _a, _b, _c;
|
528
|
+
if (((_a = fields[propKey]) == null ? void 0 : _a.type) === "slot") {
|
529
|
+
const content = value || [];
|
530
|
+
const mappedContent = recurseSlots ? content.map((el) => {
|
531
|
+
var _a2;
|
532
|
+
const componentConfig = config.components[el.type];
|
533
|
+
if (!componentConfig) {
|
534
|
+
throw new Error(`Could not find component config for ${el.type}`);
|
535
|
+
}
|
536
|
+
const fields2 = (_a2 = componentConfig.fields) != null ? _a2 : {};
|
537
|
+
return walkField({
|
538
|
+
value: el,
|
539
|
+
fields: fields2,
|
540
|
+
map,
|
541
|
+
id: el.props.id,
|
542
|
+
config,
|
543
|
+
recurseSlots
|
544
|
+
});
|
545
|
+
}) : content;
|
546
|
+
if (containsPromise(mappedContent)) {
|
547
|
+
return Promise.all(mappedContent);
|
548
|
+
}
|
549
|
+
return map(mappedContent, id, propPath, fields[propKey], propPath);
|
550
|
+
}
|
551
|
+
if (value && typeof value === "object") {
|
552
|
+
if (Array.isArray(value)) {
|
553
|
+
const arrayFields = ((_b = fields[propKey]) == null ? void 0 : _b.type) === "array" ? fields[propKey].arrayFields : null;
|
554
|
+
if (!arrayFields) return value;
|
555
|
+
const newValue = value.map(
|
556
|
+
(el, idx) => walkField({
|
557
|
+
value: el,
|
558
|
+
fields: arrayFields,
|
559
|
+
map,
|
560
|
+
propKey,
|
561
|
+
propPath: `${propPath}[${idx}]`,
|
562
|
+
id,
|
563
|
+
config,
|
564
|
+
recurseSlots
|
565
|
+
})
|
566
|
+
);
|
567
|
+
if (containsPromise(newValue)) {
|
568
|
+
return Promise.all(newValue);
|
569
|
+
}
|
570
|
+
return newValue;
|
571
|
+
} else if ("$$typeof" in value) {
|
572
|
+
return value;
|
573
|
+
} else {
|
574
|
+
const objectFields = ((_c = fields[propKey]) == null ? void 0 : _c.type) === "object" ? fields[propKey].objectFields : fields;
|
575
|
+
return walkObject({
|
576
|
+
value,
|
577
|
+
fields: objectFields,
|
578
|
+
map,
|
579
|
+
id,
|
580
|
+
getPropPath: (k) => `${propPath}.${k}`,
|
581
|
+
config,
|
582
|
+
recurseSlots
|
583
|
+
});
|
584
|
+
}
|
585
|
+
}
|
586
|
+
return value;
|
587
|
+
};
|
588
|
+
var walkObject = ({
|
589
|
+
value,
|
590
|
+
fields,
|
591
|
+
map,
|
592
|
+
id,
|
593
|
+
getPropPath,
|
594
|
+
config,
|
595
|
+
recurseSlots
|
596
|
+
}) => {
|
597
|
+
const newProps = Object.entries(value).map(([k, v]) => {
|
598
|
+
const opts = {
|
599
|
+
value: v,
|
600
|
+
fields,
|
601
|
+
map,
|
602
|
+
propKey: k,
|
603
|
+
propPath: getPropPath(k),
|
604
|
+
id,
|
605
|
+
config,
|
606
|
+
recurseSlots
|
607
|
+
};
|
608
|
+
const newValue = walkField(opts);
|
609
|
+
if (isPromise(newValue)) {
|
610
|
+
return newValue.then((resolvedValue) => ({
|
611
|
+
[k]: resolvedValue
|
612
|
+
}));
|
613
|
+
}
|
614
|
+
return {
|
615
|
+
[k]: newValue
|
616
|
+
};
|
617
|
+
}, {});
|
618
|
+
if (containsPromise(newProps)) {
|
619
|
+
return Promise.all(newProps).then(flatten);
|
620
|
+
}
|
621
|
+
return flatten(newProps);
|
391
622
|
};
|
623
|
+
function mapSlots(item, map, config, recurseSlots = false) {
|
624
|
+
var _a, _b, _c, _d;
|
625
|
+
const itemType = "type" in item ? item.type : "root";
|
626
|
+
const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
|
627
|
+
const newProps = walkObject({
|
628
|
+
value: (_b = item.props) != null ? _b : {},
|
629
|
+
fields: (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {},
|
630
|
+
map,
|
631
|
+
id: item.props ? (_d = item.props.id) != null ? _d : "root" : "root",
|
632
|
+
getPropPath: (k) => k,
|
633
|
+
config,
|
634
|
+
recurseSlots
|
635
|
+
});
|
636
|
+
if (isPromise(newProps)) {
|
637
|
+
return newProps.then((resolvedProps) => __spreadProps(__spreadValues({}, item), {
|
638
|
+
props: resolvedProps
|
639
|
+
}));
|
640
|
+
}
|
641
|
+
return __spreadProps(__spreadValues({}, item), {
|
642
|
+
props: newProps
|
643
|
+
});
|
644
|
+
}
|
392
645
|
|
393
|
-
// ../core/lib/
|
646
|
+
// ../core/lib/data/flatten-node.ts
|
394
647
|
init_react_import();
|
395
|
-
var
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
648
|
+
var import_flat = __toESM(require_flat());
|
649
|
+
|
650
|
+
// ../core/lib/data/strip-slots.ts
|
651
|
+
init_react_import();
|
652
|
+
var stripSlots = (data, config) => {
|
653
|
+
return mapSlots(data, () => null, config);
|
654
|
+
};
|
655
|
+
|
656
|
+
// ../core/lib/data/flatten-node.ts
|
657
|
+
var flattenNode = (node, config) => {
|
658
|
+
return __spreadProps(__spreadValues({}, node), {
|
659
|
+
props: (0, import_flat.flatten)(stripSlots(node, config).props)
|
401
660
|
});
|
402
|
-
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
403
|
-
return newData;
|
404
661
|
};
|
405
662
|
|
406
|
-
// ../core/lib/
|
407
|
-
|
408
|
-
var
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
663
|
+
// ../core/lib/data/walk-app-state.ts
|
664
|
+
function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
665
|
+
var _a;
|
666
|
+
let newZones = {};
|
667
|
+
const newZoneIndex = {};
|
668
|
+
const newNodeIndex = {};
|
669
|
+
const processContent = (path, zoneCompound, content, zoneType, newId) => {
|
670
|
+
var _a2;
|
671
|
+
const [parentId] = zoneCompound.split(":");
|
672
|
+
const mappedContent = ((_a2 = mapContent(content, zoneCompound, zoneType)) != null ? _a2 : content) || [];
|
673
|
+
const [_2, zone] = zoneCompound.split(":");
|
674
|
+
const newZoneCompound = `${newId || parentId}:${zone}`;
|
675
|
+
const newContent2 = mappedContent.map(
|
676
|
+
(zoneChild, index) => processItem(zoneChild, [...path, newZoneCompound], index)
|
677
|
+
);
|
678
|
+
newZoneIndex[newZoneCompound] = {
|
679
|
+
contentIds: newContent2.map((item) => item.props.id),
|
680
|
+
type: zoneType
|
681
|
+
};
|
682
|
+
return [newZoneCompound, newContent2];
|
683
|
+
};
|
684
|
+
const processRelatedZones = (item, newId, initialPath) => {
|
685
|
+
forRelatedZones(
|
686
|
+
item,
|
687
|
+
state.data,
|
688
|
+
(relatedPath, relatedZoneCompound, relatedContent) => {
|
689
|
+
const [zoneCompound, newContent2] = processContent(
|
690
|
+
relatedPath,
|
691
|
+
relatedZoneCompound,
|
692
|
+
relatedContent,
|
693
|
+
"dropzone",
|
694
|
+
newId
|
695
|
+
);
|
696
|
+
newZones[zoneCompound] = newContent2;
|
697
|
+
},
|
698
|
+
initialPath
|
699
|
+
);
|
700
|
+
};
|
701
|
+
const processItem = (item, path, index) => {
|
702
|
+
const mappedItem = mapNodeOrSkip(item, path, index);
|
703
|
+
if (!mappedItem) return item;
|
704
|
+
const id = mappedItem.props.id;
|
705
|
+
const newProps = __spreadProps(__spreadValues({}, mapSlots(
|
706
|
+
mappedItem,
|
707
|
+
(content, parentId2, slotId) => {
|
708
|
+
const zoneCompound = `${parentId2}:${slotId}`;
|
709
|
+
const [_2, newContent2] = processContent(
|
710
|
+
path,
|
711
|
+
zoneCompound,
|
712
|
+
content,
|
713
|
+
"slot",
|
714
|
+
parentId2
|
715
|
+
);
|
716
|
+
return newContent2;
|
717
|
+
},
|
718
|
+
config
|
719
|
+
).props), {
|
720
|
+
id
|
721
|
+
});
|
722
|
+
processRelatedZones(item, id, path);
|
723
|
+
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
|
724
|
+
const thisZoneCompound = path[path.length - 1];
|
725
|
+
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
726
|
+
newNodeIndex[id] = {
|
727
|
+
data: newItem,
|
728
|
+
flatData: flattenNode(newItem, config),
|
729
|
+
path,
|
730
|
+
parentId,
|
731
|
+
zone
|
732
|
+
};
|
733
|
+
const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
|
734
|
+
if (newProps.id === "root") {
|
735
|
+
delete finalData["type"];
|
736
|
+
delete finalData.props["id"];
|
737
|
+
}
|
738
|
+
return finalData;
|
739
|
+
};
|
740
|
+
const zones = state.data.zones || {};
|
741
|
+
const [_, newContent] = processContent(
|
742
|
+
[],
|
743
|
+
rootDroppableId,
|
744
|
+
state.data.content,
|
745
|
+
"root"
|
746
|
+
);
|
747
|
+
const processedContent = newContent;
|
748
|
+
const zonesAlreadyProcessed = Object.keys(newZones);
|
749
|
+
Object.keys(zones || {}).forEach((zoneCompound) => {
|
750
|
+
const [parentId] = zoneCompound.split(":");
|
751
|
+
if (zonesAlreadyProcessed.includes(zoneCompound)) {
|
752
|
+
return;
|
753
|
+
}
|
754
|
+
const [_2, newContent2] = processContent(
|
755
|
+
[rootDroppableId],
|
756
|
+
zoneCompound,
|
757
|
+
zones[zoneCompound],
|
758
|
+
"dropzone",
|
759
|
+
parentId
|
760
|
+
);
|
761
|
+
newZones[zoneCompound] = newContent2;
|
762
|
+
}, newZones);
|
763
|
+
const processedRoot = processItem(
|
764
|
+
{
|
765
|
+
type: "root",
|
766
|
+
props: __spreadProps(__spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root), { id: "root" })
|
767
|
+
},
|
768
|
+
[],
|
769
|
+
-1
|
770
|
+
);
|
771
|
+
const root = __spreadProps(__spreadValues({}, state.data.root), {
|
772
|
+
props: processedRoot.props
|
773
|
+
});
|
774
|
+
return __spreadProps(__spreadValues({}, state), {
|
775
|
+
data: {
|
776
|
+
root,
|
777
|
+
content: processedContent,
|
778
|
+
zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
|
779
|
+
},
|
780
|
+
indexes: {
|
781
|
+
nodes: __spreadValues(__spreadValues({}, state.indexes.nodes), newNodeIndex),
|
782
|
+
zones: __spreadValues(__spreadValues({}, state.indexes.zones), newZoneIndex)
|
783
|
+
}
|
784
|
+
});
|
785
|
+
}
|
786
|
+
|
787
|
+
// ../core/reducer/actions/set.ts
|
788
|
+
var setAction = (state, action, appStore) => {
|
789
|
+
if (typeof action.state === "object") {
|
790
|
+
const newState = __spreadValues(__spreadValues({}, state), action.state);
|
791
|
+
if (action.state.indexes) {
|
792
|
+
return newState;
|
793
|
+
}
|
794
|
+
console.warn(
|
795
|
+
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
796
|
+
);
|
797
|
+
return walkAppState(newState, appStore.config);
|
798
|
+
}
|
799
|
+
return __spreadValues(__spreadValues({}, state), action.state(state));
|
413
800
|
};
|
414
801
|
|
415
|
-
// ../core/
|
802
|
+
// ../core/reducer/actions/insert.ts
|
416
803
|
init_react_import();
|
417
|
-
function getItem(selector, data, dynamicProps = {}) {
|
418
|
-
if (!selector.zone || selector.zone === rootDroppableId) {
|
419
|
-
const item2 = data.content[selector.index];
|
420
|
-
return (item2 == null ? void 0 : item2.props) ? __spreadProps(__spreadValues({}, item2), { props: dynamicProps[item2.props.id] || item2.props }) : void 0;
|
421
|
-
}
|
422
|
-
const item = setupZone(data, selector.zone).zones[selector.zone][selector.index];
|
423
|
-
return (item == null ? void 0 : item.props) ? __spreadProps(__spreadValues({}, item), { props: dynamicProps[item.props.id] || item.props }) : void 0;
|
424
|
-
}
|
425
804
|
|
426
|
-
// ../core/lib/
|
805
|
+
// ../core/lib/data/insert.ts
|
427
806
|
init_react_import();
|
807
|
+
var insert = (list, index, item) => {
|
808
|
+
const result = Array.from(list || []);
|
809
|
+
result.splice(index, 0, item);
|
810
|
+
return result;
|
811
|
+
};
|
428
812
|
|
429
813
|
// ../core/lib/generate-id.ts
|
430
814
|
init_react_import();
|
@@ -488,313 +872,438 @@ var v4_default = v4;
|
|
488
872
|
// ../core/lib/generate-id.ts
|
489
873
|
var generateId = (type) => type ? `${type}-${v4_default()}` : v4_default();
|
490
874
|
|
491
|
-
// ../core/lib/get-
|
875
|
+
// ../core/lib/data/get-ids-for-parent.ts
|
492
876
|
init_react_import();
|
493
|
-
var
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
498
|
-
return zoneCompound.split(":");
|
499
|
-
}
|
500
|
-
return [rootDroppableId, zoneCompound];
|
877
|
+
var getIdsForParent = (zoneCompound, state) => {
|
878
|
+
const [parentId] = zoneCompound.split(":");
|
879
|
+
const node = state.indexes.nodes[parentId];
|
880
|
+
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
|
501
881
|
};
|
502
882
|
|
503
|
-
// ../core/lib/
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
883
|
+
// ../core/lib/data/populate-ids.ts
|
884
|
+
init_react_import();
|
885
|
+
|
886
|
+
// ../core/lib/data/walk-tree.ts
|
887
|
+
init_react_import();
|
888
|
+
function walkTree(data, config, callbackFn) {
|
889
|
+
var _a, _b;
|
890
|
+
const walkItem = (item) => {
|
891
|
+
return mapSlots(
|
892
|
+
item,
|
893
|
+
(content, parentId, propName) => {
|
894
|
+
var _a2;
|
895
|
+
return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
|
514
896
|
},
|
897
|
+
config,
|
898
|
+
true
|
899
|
+
);
|
900
|
+
};
|
901
|
+
if ("props" in data) {
|
902
|
+
return walkItem(data);
|
903
|
+
}
|
904
|
+
const _data = data;
|
905
|
+
const zones = (_a = _data.zones) != null ? _a : {};
|
906
|
+
const mappedContent = _data.content.map(walkItem);
|
907
|
+
return {
|
908
|
+
root: walkItem(_data.root),
|
909
|
+
content: (_b = callbackFn(mappedContent, {
|
910
|
+
parentId: "root",
|
911
|
+
propName: "default-zone"
|
912
|
+
})) != null ? _b : mappedContent,
|
913
|
+
zones: Object.keys(zones).reduce(
|
914
|
+
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
|
915
|
+
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
916
|
+
}),
|
515
917
|
{}
|
516
918
|
)
|
517
|
-
}
|
919
|
+
};
|
518
920
|
}
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
921
|
+
|
922
|
+
// ../core/lib/data/populate-ids.ts
|
923
|
+
var populateIds = (data, config, override = false) => {
|
924
|
+
const id = generateId(data.type);
|
925
|
+
return walkTree(
|
926
|
+
__spreadProps(__spreadValues({}, data), {
|
927
|
+
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({}, data.props)
|
928
|
+
}),
|
929
|
+
config,
|
930
|
+
(contents) => contents.map((item) => {
|
931
|
+
const id2 = generateId(item.type);
|
932
|
+
return __spreadProps(__spreadValues({}, item), {
|
933
|
+
props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
|
934
|
+
});
|
935
|
+
})
|
936
|
+
);
|
937
|
+
};
|
938
|
+
|
939
|
+
// ../core/reducer/actions/insert.ts
|
940
|
+
function insertAction(state, action, appStore) {
|
941
|
+
const id = action.id || generateId(action.componentType);
|
942
|
+
const emptyComponentData = populateIds(
|
943
|
+
{
|
944
|
+
type: action.componentType,
|
945
|
+
props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
|
946
|
+
id
|
947
|
+
})
|
948
|
+
},
|
949
|
+
appStore.config
|
950
|
+
);
|
951
|
+
const [parentId] = action.destinationZone.split(":");
|
952
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
953
|
+
return walkAppState(
|
954
|
+
state,
|
955
|
+
appStore.config,
|
956
|
+
(content, zoneCompound) => {
|
957
|
+
if (zoneCompound === action.destinationZone) {
|
958
|
+
return insert(
|
959
|
+
content || [],
|
960
|
+
action.destinationIndex,
|
961
|
+
emptyComponentData
|
962
|
+
);
|
526
963
|
}
|
527
|
-
return
|
964
|
+
return content;
|
528
965
|
},
|
529
|
-
{
|
966
|
+
(childItem, path) => {
|
967
|
+
if (childItem.props.id === id || childItem.props.id === parentId) {
|
968
|
+
return childItem;
|
969
|
+
} else if (idsInPath.includes(childItem.props.id)) {
|
970
|
+
return childItem;
|
971
|
+
} else if (path.includes(action.destinationZone)) {
|
972
|
+
return childItem;
|
973
|
+
}
|
974
|
+
return null;
|
975
|
+
}
|
530
976
|
);
|
531
|
-
}
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
977
|
+
}
|
978
|
+
|
979
|
+
// ../core/reducer/actions/replace.ts
|
980
|
+
init_react_import();
|
981
|
+
var replaceAction = (state, action, appStore) => {
|
982
|
+
const [parentId] = action.destinationZone.split(":");
|
983
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
984
|
+
const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
|
985
|
+
const idChanged = originalId !== action.data.props.id;
|
986
|
+
if (idChanged) {
|
987
|
+
throw new Error(
|
988
|
+
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
989
|
+
);
|
990
|
+
}
|
991
|
+
const data = populateIds(action.data, appStore.config);
|
992
|
+
return walkAppState(
|
993
|
+
state,
|
994
|
+
appStore.config,
|
995
|
+
(content, zoneCompound) => {
|
996
|
+
const newContent = [...content];
|
997
|
+
if (zoneCompound === action.destinationZone) {
|
998
|
+
newContent[action.destinationIndex] = data;
|
541
999
|
}
|
542
|
-
return
|
1000
|
+
return newContent;
|
543
1001
|
},
|
544
|
-
{
|
1002
|
+
(childItem, path) => {
|
1003
|
+
const pathIds = path.map((p) => p.split(":")[0]);
|
1004
|
+
if (childItem.props.id === data.props.id) {
|
1005
|
+
return data;
|
1006
|
+
} else if (childItem.props.id === parentId) {
|
1007
|
+
return childItem;
|
1008
|
+
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
1009
|
+
return childItem;
|
1010
|
+
} else if (pathIds.indexOf(data.props.id) > -1) {
|
1011
|
+
return childItem;
|
1012
|
+
}
|
1013
|
+
return null;
|
1014
|
+
}
|
545
1015
|
);
|
546
1016
|
};
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
1017
|
+
|
1018
|
+
// ../core/reducer/actions/replace-root.ts
|
1019
|
+
init_react_import();
|
1020
|
+
var replaceRootAction = (state, action, appStore) => {
|
1021
|
+
return walkAppState(
|
1022
|
+
state,
|
1023
|
+
appStore.config,
|
1024
|
+
(content) => content,
|
1025
|
+
(childItem) => {
|
1026
|
+
if (childItem.props.id === "root") {
|
1027
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
1028
|
+
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
1029
|
+
readOnly: action.root.readOnly
|
1030
|
+
});
|
1031
|
+
}
|
1032
|
+
return childItem;
|
1033
|
+
}
|
1034
|
+
);
|
554
1035
|
};
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
return __spreadProps(__spreadValues({}, dupeOfDupes), {
|
566
|
-
[key]: zone,
|
567
|
-
[`${newId}:${zoneId}`]: dupedZone
|
568
|
-
});
|
569
|
-
});
|
1036
|
+
|
1037
|
+
// ../core/reducer/actions/duplicate.ts
|
1038
|
+
init_react_import();
|
1039
|
+
|
1040
|
+
// ../core/lib/data/get-item.ts
|
1041
|
+
init_react_import();
|
1042
|
+
function getItem(selector, state) {
|
1043
|
+
var _a, _b;
|
1044
|
+
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
1045
|
+
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
570
1046
|
}
|
571
1047
|
|
572
|
-
// ../core/reducer/
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
}
|
580
|
-
|
581
|
-
|
582
|
-
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
583
|
-
[action.destinationZone]: replace(
|
584
|
-
newData.zones[action.destinationZone],
|
585
|
-
action.destinationIndex,
|
586
|
-
action.data
|
587
|
-
)
|
1048
|
+
// ../core/reducer/actions/duplicate.ts
|
1049
|
+
function duplicateAction(state, action, appStore) {
|
1050
|
+
const item = getItem(
|
1051
|
+
{ index: action.sourceIndex, zone: action.sourceZone },
|
1052
|
+
state
|
1053
|
+
);
|
1054
|
+
const idsInPath = getIdsForParent(action.sourceZone, state);
|
1055
|
+
const newItem = __spreadProps(__spreadValues({}, item), {
|
1056
|
+
props: __spreadProps(__spreadValues({}, item.props), {
|
1057
|
+
id: generateId(item.type)
|
588
1058
|
})
|
589
1059
|
});
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
1060
|
+
const modified = walkAppState(
|
1061
|
+
state,
|
1062
|
+
appStore.config,
|
1063
|
+
(content, zoneCompound) => {
|
1064
|
+
if (zoneCompound === action.sourceZone) {
|
1065
|
+
return insert(content, action.sourceIndex + 1, item);
|
1066
|
+
}
|
1067
|
+
return content;
|
1068
|
+
},
|
1069
|
+
(childItem, path, index) => {
|
1070
|
+
const zoneCompound = path[path.length - 1];
|
1071
|
+
const parents = path.map((p) => p.split(":")[0]);
|
1072
|
+
if (parents.indexOf(newItem.props.id) > -1) {
|
1073
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
1074
|
+
props: __spreadProps(__spreadValues({}, childItem.props), {
|
1075
|
+
id: generateId(childItem.type)
|
1076
|
+
})
|
1077
|
+
});
|
1078
|
+
}
|
1079
|
+
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
1080
|
+
return newItem;
|
1081
|
+
}
|
1082
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
1083
|
+
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
1084
|
+
return childItem;
|
1085
|
+
}
|
1086
|
+
return null;
|
1087
|
+
}
|
1088
|
+
);
|
1089
|
+
return __spreadProps(__spreadValues({}, modified), {
|
1090
|
+
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
1091
|
+
itemSelector: {
|
1092
|
+
index: action.sourceIndex + 1,
|
1093
|
+
zone: action.sourceZone
|
1094
|
+
}
|
615
1095
|
})
|
616
1096
|
});
|
617
1097
|
}
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
const
|
629
|
-
|
630
|
-
|
631
|
-
[action.destinationZone]: reorder(
|
632
|
-
newData.zones[action.destinationZone],
|
633
|
-
action.sourceIndex,
|
634
|
-
action.destinationIndex
|
635
|
-
)
|
636
|
-
})
|
637
|
-
});
|
1098
|
+
|
1099
|
+
// ../core/reducer/actions/reorder.ts
|
1100
|
+
init_react_import();
|
1101
|
+
|
1102
|
+
// ../core/reducer/actions/move.ts
|
1103
|
+
init_react_import();
|
1104
|
+
|
1105
|
+
// ../core/lib/data/remove.ts
|
1106
|
+
init_react_import();
|
1107
|
+
var remove = (list, index) => {
|
1108
|
+
const result = Array.from(list);
|
1109
|
+
result.splice(index, 1);
|
1110
|
+
return result;
|
638
1111
|
};
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
const item = getItem(
|
645
|
-
{ index: action.sourceIndex, zone: action.sourceZone },
|
646
|
-
data
|
647
|
-
);
|
648
|
-
const newItem = __spreadProps(__spreadValues({}, item), {
|
649
|
-
props: __spreadProps(__spreadValues({}, item.props), {
|
650
|
-
id: generateId(item.type)
|
651
|
-
})
|
652
|
-
});
|
653
|
-
const dataWithRelatedDuplicated = duplicateRelatedZones(
|
654
|
-
item,
|
655
|
-
data,
|
656
|
-
newItem.props.id
|
657
|
-
);
|
658
|
-
if (action.sourceZone === rootDroppableId) {
|
659
|
-
return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
|
660
|
-
content: insert(data.content, action.sourceIndex + 1, newItem)
|
661
|
-
});
|
662
|
-
}
|
663
|
-
return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
|
664
|
-
zones: __spreadProps(__spreadValues({}, dataWithRelatedDuplicated.zones), {
|
665
|
-
[action.sourceZone]: insert(
|
666
|
-
dataWithRelatedDuplicated.zones[action.sourceZone],
|
667
|
-
action.sourceIndex + 1,
|
668
|
-
newItem
|
669
|
-
)
|
670
|
-
})
|
671
|
-
});
|
672
|
-
}
|
673
|
-
if (action.type === "reorder") {
|
674
|
-
return reorderAction(data, action);
|
1112
|
+
|
1113
|
+
// ../core/reducer/actions/move.ts
|
1114
|
+
var moveAction = (state, action, appStore) => {
|
1115
|
+
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
1116
|
+
return state;
|
675
1117
|
}
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
1118
|
+
const item = getItem(
|
1119
|
+
{ zone: action.sourceZone, index: action.sourceIndex },
|
1120
|
+
state
|
1121
|
+
);
|
1122
|
+
if (!item) return state;
|
1123
|
+
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
1124
|
+
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
1125
|
+
return walkAppState(
|
1126
|
+
state,
|
1127
|
+
appStore.config,
|
1128
|
+
(content, zoneCompound) => {
|
1129
|
+
if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
|
1130
|
+
return insert(
|
1131
|
+
remove(content, action.sourceIndex),
|
1132
|
+
action.destinationIndex,
|
1133
|
+
item
|
1134
|
+
);
|
1135
|
+
} else if (zoneCompound === action.sourceZone) {
|
1136
|
+
return remove(content, action.sourceIndex);
|
1137
|
+
} else if (zoneCompound === action.destinationZone) {
|
1138
|
+
return insert(content, action.destinationIndex, item);
|
1139
|
+
}
|
1140
|
+
return content;
|
1141
|
+
},
|
1142
|
+
(childItem, path) => {
|
1143
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
1144
|
+
const [destinationZoneParent] = action.destinationZone.split(":");
|
1145
|
+
const childId = childItem.props.id;
|
1146
|
+
if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1 || path.includes(action.destinationZone)) {
|
1147
|
+
return childItem;
|
1148
|
+
}
|
1149
|
+
return null;
|
690
1150
|
}
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
1151
|
+
);
|
1152
|
+
};
|
1153
|
+
|
1154
|
+
// ../core/reducer/actions/reorder.ts
|
1155
|
+
var reorderAction = (state, action, appStore) => {
|
1156
|
+
return moveAction(
|
1157
|
+
state,
|
1158
|
+
{
|
1159
|
+
type: "move",
|
1160
|
+
sourceIndex: action.sourceIndex,
|
1161
|
+
sourceZone: action.destinationZone,
|
1162
|
+
destinationIndex: action.destinationIndex,
|
1163
|
+
destinationZone: action.destinationZone
|
1164
|
+
},
|
1165
|
+
appStore
|
1166
|
+
);
|
1167
|
+
};
|
1168
|
+
|
1169
|
+
// ../core/reducer/actions/remove.ts
|
1170
|
+
init_react_import();
|
1171
|
+
var removeAction = (state, action, appStore) => {
|
1172
|
+
const item = getItem({ index: action.index, zone: action.zone }, state);
|
1173
|
+
const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
|
1174
|
+
(acc, [nodeId, nodeData]) => {
|
1175
|
+
const pathIds = nodeData.path.map((p) => p.split(":")[0]);
|
1176
|
+
if (pathIds.includes(item.props.id)) {
|
1177
|
+
return [...acc, nodeId];
|
1178
|
+
}
|
1179
|
+
return acc;
|
1180
|
+
},
|
1181
|
+
[item.props.id]
|
1182
|
+
);
|
1183
|
+
const newState = walkAppState(
|
1184
|
+
state,
|
1185
|
+
appStore.config,
|
1186
|
+
(content, zoneCompound) => {
|
1187
|
+
if (zoneCompound === action.zone) {
|
1188
|
+
return remove(content, action.index);
|
1189
|
+
}
|
1190
|
+
return content;
|
702
1191
|
}
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
newData.zones[action.sourceZone],
|
709
|
-
action.sourceIndex
|
710
|
-
)
|
711
|
-
})
|
712
|
-
});
|
1192
|
+
);
|
1193
|
+
Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
|
1194
|
+
const parentId = zoneCompound.split(":")[0];
|
1195
|
+
if (nodesToDelete.includes(parentId) && newState.data.zones) {
|
1196
|
+
delete newState.data.zones[zoneCompound];
|
713
1197
|
}
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
),
|
720
|
-
[action.destinationZone]: insert(
|
721
|
-
newData.zones[action.destinationZone],
|
722
|
-
action.destinationIndex,
|
723
|
-
item
|
724
|
-
)
|
725
|
-
})
|
726
|
-
});
|
727
|
-
}
|
728
|
-
if (action.type === "replace") {
|
729
|
-
return replaceAction(data, action);
|
730
|
-
}
|
731
|
-
if (action.type === "remove") {
|
732
|
-
const item = getItem({ index: action.index, zone: action.zone }, data);
|
733
|
-
const dataWithRelatedRemoved = setupZone(
|
734
|
-
removeRelatedZones(item, data),
|
735
|
-
action.zone
|
736
|
-
);
|
737
|
-
if (action.zone === rootDroppableId) {
|
738
|
-
return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
|
739
|
-
content: remove(data.content, action.index)
|
740
|
-
});
|
1198
|
+
});
|
1199
|
+
Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
|
1200
|
+
const parentId = zoneCompound.split(":")[0];
|
1201
|
+
if (nodesToDelete.includes(parentId)) {
|
1202
|
+
delete newState.indexes.zones[zoneCompound];
|
741
1203
|
}
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
1204
|
+
});
|
1205
|
+
nodesToDelete.forEach((id) => {
|
1206
|
+
delete newState.indexes.nodes[id];
|
1207
|
+
});
|
1208
|
+
return newState;
|
1209
|
+
};
|
1210
|
+
|
1211
|
+
// ../core/reducer/actions/register-zone.ts
|
1212
|
+
init_react_import();
|
1213
|
+
|
1214
|
+
// ../core/lib/data/setup-zone.ts
|
1215
|
+
init_react_import();
|
1216
|
+
var setupZone = (data, zoneKey) => {
|
1217
|
+
if (zoneKey === rootDroppableId) {
|
1218
|
+
return data;
|
750
1219
|
}
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
1220
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
1221
|
+
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
1222
|
+
});
|
1223
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
1224
|
+
return newData;
|
1225
|
+
};
|
1226
|
+
|
1227
|
+
// ../core/reducer/actions/register-zone.ts
|
1228
|
+
var zoneCache = {};
|
1229
|
+
function registerZoneAction(state, action) {
|
1230
|
+
if (zoneCache[action.zone]) {
|
1231
|
+
return __spreadProps(__spreadValues({}, state), {
|
1232
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
1233
|
+
zones: __spreadProps(__spreadValues({}, state.data.zones), {
|
755
1234
|
[action.zone]: zoneCache[action.zone]
|
756
1235
|
})
|
757
|
-
})
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
}
|
767
|
-
return __spreadProps(__spreadValues({}, data), { zones: _zones });
|
1236
|
+
}),
|
1237
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1238
|
+
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
|
1239
|
+
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
|
1240
|
+
contentIds: zoneCache[action.zone].map((item) => item.props.id),
|
1241
|
+
type: "dropzone"
|
1242
|
+
})
|
1243
|
+
})
|
1244
|
+
})
|
1245
|
+
});
|
768
1246
|
}
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
1247
|
+
return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
|
1248
|
+
}
|
1249
|
+
function unregisterZoneAction(state, action) {
|
1250
|
+
const _zones = __spreadValues({}, state.data.zones || {});
|
1251
|
+
const zoneIndex = __spreadValues({}, state.indexes.zones || {});
|
1252
|
+
if (_zones[action.zone]) {
|
1253
|
+
zoneCache[action.zone] = _zones[action.zone];
|
1254
|
+
delete _zones[action.zone];
|
774
1255
|
}
|
775
|
-
|
1256
|
+
delete zoneIndex[action.zone];
|
1257
|
+
return __spreadProps(__spreadValues({}, state), {
|
1258
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
1259
|
+
zones: _zones
|
1260
|
+
}),
|
1261
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1262
|
+
zones: zoneIndex
|
1263
|
+
})
|
1264
|
+
});
|
776
1265
|
}
|
777
1266
|
|
778
|
-
// ../core/reducer/
|
1267
|
+
// ../core/reducer/actions/set-data.ts
|
779
1268
|
init_react_import();
|
780
|
-
var
|
781
|
-
if (action.
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
return
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
1269
|
+
var setDataAction = (state, action, appStore) => {
|
1270
|
+
if (typeof action.data === "object") {
|
1271
|
+
console.warn(
|
1272
|
+
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1273
|
+
);
|
1274
|
+
return walkAppState(
|
1275
|
+
__spreadProps(__spreadValues({}, state), {
|
1276
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
1277
|
+
}),
|
1278
|
+
appStore.config
|
1279
|
+
);
|
791
1280
|
}
|
792
|
-
|
793
|
-
|
794
|
-
|
1281
|
+
return walkAppState(
|
1282
|
+
__spreadProps(__spreadValues({}, state), {
|
1283
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
1284
|
+
}),
|
1285
|
+
appStore.config
|
1286
|
+
);
|
1287
|
+
};
|
1288
|
+
|
1289
|
+
// ../core/reducer/actions/set-ui.ts
|
1290
|
+
init_react_import();
|
1291
|
+
var setUiAction = (state, action) => {
|
1292
|
+
if (typeof action.ui === "object") {
|
1293
|
+
return __spreadProps(__spreadValues({}, state), {
|
1294
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
|
795
1295
|
});
|
796
1296
|
}
|
797
|
-
return
|
1297
|
+
return __spreadProps(__spreadValues({}, state), {
|
1298
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
|
1299
|
+
});
|
1300
|
+
};
|
1301
|
+
|
1302
|
+
// ../core/lib/data/make-state-public.ts
|
1303
|
+
init_react_import();
|
1304
|
+
var makeStatePublic = (state) => {
|
1305
|
+
const { data, ui } = state;
|
1306
|
+
return { data, ui };
|
798
1307
|
};
|
799
1308
|
|
800
1309
|
// ../core/reducer/actions.tsx
|
@@ -814,29 +1323,54 @@ function storeInterceptor(reducer, record, onAction) {
|
|
814
1323
|
if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
|
815
1324
|
if (record) record(newAppState);
|
816
1325
|
}
|
817
|
-
onAction == null ? void 0 : onAction(action, newAppState, state);
|
1326
|
+
onAction == null ? void 0 : onAction(action, makeStatePublic(newAppState), makeStatePublic(state));
|
818
1327
|
return newAppState;
|
819
1328
|
};
|
820
1329
|
}
|
821
|
-
var setAction = (state, action) => {
|
822
|
-
if (typeof action.state === "object") {
|
823
|
-
return __spreadValues(__spreadValues({}, state), action.state);
|
824
|
-
}
|
825
|
-
return __spreadValues(__spreadValues({}, state), action.state(state));
|
826
|
-
};
|
827
1330
|
function createReducer({
|
828
|
-
config,
|
829
1331
|
record,
|
830
|
-
onAction
|
1332
|
+
onAction,
|
1333
|
+
appStore
|
831
1334
|
}) {
|
832
1335
|
return storeInterceptor(
|
833
1336
|
(state, action) => {
|
834
|
-
const data = reduceData(state.data, action, config);
|
835
|
-
const ui = reduceUi(state.ui, action);
|
836
1337
|
if (action.type === "set") {
|
837
|
-
return setAction(state, action);
|
1338
|
+
return setAction(state, action, appStore);
|
1339
|
+
}
|
1340
|
+
if (action.type === "insert") {
|
1341
|
+
return insertAction(state, action, appStore);
|
1342
|
+
}
|
1343
|
+
if (action.type === "replace") {
|
1344
|
+
return replaceAction(state, action, appStore);
|
1345
|
+
}
|
1346
|
+
if (action.type === "replaceRoot") {
|
1347
|
+
return replaceRootAction(state, action, appStore);
|
1348
|
+
}
|
1349
|
+
if (action.type === "duplicate") {
|
1350
|
+
return duplicateAction(state, action, appStore);
|
1351
|
+
}
|
1352
|
+
if (action.type === "reorder") {
|
1353
|
+
return reorderAction(state, action, appStore);
|
1354
|
+
}
|
1355
|
+
if (action.type === "move") {
|
1356
|
+
return moveAction(state, action, appStore);
|
1357
|
+
}
|
1358
|
+
if (action.type === "remove") {
|
1359
|
+
return removeAction(state, action, appStore);
|
1360
|
+
}
|
1361
|
+
if (action.type === "registerZone") {
|
1362
|
+
return registerZoneAction(state, action);
|
1363
|
+
}
|
1364
|
+
if (action.type === "unregisterZone") {
|
1365
|
+
return unregisterZoneAction(state, action);
|
838
1366
|
}
|
839
|
-
|
1367
|
+
if (action.type === "setData") {
|
1368
|
+
return setDataAction(state, action, appStore);
|
1369
|
+
}
|
1370
|
+
if (action.type === "setUi") {
|
1371
|
+
return setUiAction(state, action);
|
1372
|
+
}
|
1373
|
+
return state;
|
840
1374
|
},
|
841
1375
|
record,
|
842
1376
|
onAction
|
@@ -856,11 +1390,11 @@ init_react_import();
|
|
856
1390
|
var createStoreImpl = (createState) => {
|
857
1391
|
let state;
|
858
1392
|
const listeners = /* @__PURE__ */ new Set();
|
859
|
-
const setState = (partial,
|
1393
|
+
const setState = (partial, replace) => {
|
860
1394
|
const nextState = typeof partial === "function" ? partial(state) : partial;
|
861
1395
|
if (!Object.is(nextState, state)) {
|
862
1396
|
const previousState = state;
|
863
|
-
state = (
|
1397
|
+
state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
|
864
1398
|
listeners.forEach((listener) => listener(state, previousState));
|
865
1399
|
}
|
866
1400
|
};
|
@@ -924,206 +1458,6 @@ var subscribeWithSelectorImpl = (fn) => (set, get, api) => {
|
|
924
1458
|
};
|
925
1459
|
var subscribeWithSelector = subscribeWithSelectorImpl;
|
926
1460
|
|
927
|
-
// ../core/lib/resolve-data.ts
|
928
|
-
init_react_import();
|
929
|
-
|
930
|
-
// ../core/lib/resolve-component-data.ts
|
931
|
-
init_react_import();
|
932
|
-
|
933
|
-
// ../core/lib/get-changed.ts
|
934
|
-
init_react_import();
|
935
|
-
var getChanged = (newItem, oldItem) => {
|
936
|
-
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
937
|
-
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
938
|
-
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
939
|
-
return __spreadProps(__spreadValues({}, acc), {
|
940
|
-
[item]: oldItemProps[item] !== newItemProps[item]
|
941
|
-
});
|
942
|
-
}, {}) : {};
|
943
|
-
};
|
944
|
-
|
945
|
-
// ../core/lib/resolve-component-data.ts
|
946
|
-
var cache = { lastChange: {} };
|
947
|
-
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd) {
|
948
|
-
const configForItem = config.components[item.type];
|
949
|
-
if (configForItem.resolveData) {
|
950
|
-
const { item: oldItem = null, resolved = {} } = cache.lastChange[item.props.id] || {};
|
951
|
-
if (item && item === oldItem) {
|
952
|
-
return resolved;
|
953
|
-
}
|
954
|
-
const changed = getChanged(item, oldItem);
|
955
|
-
if (onResolveStart) {
|
956
|
-
onResolveStart(item);
|
957
|
-
}
|
958
|
-
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
959
|
-
changed,
|
960
|
-
lastData: oldItem,
|
961
|
-
metadata
|
962
|
-
});
|
963
|
-
const resolvedItem = __spreadProps(__spreadValues({}, item), {
|
964
|
-
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
965
|
-
});
|
966
|
-
if (Object.keys(readOnly).length) {
|
967
|
-
resolvedItem.readOnly = readOnly;
|
968
|
-
}
|
969
|
-
cache.lastChange[item.props.id] = {
|
970
|
-
item,
|
971
|
-
resolved: resolvedItem
|
972
|
-
};
|
973
|
-
if (onResolveEnd) {
|
974
|
-
onResolveEnd(resolvedItem);
|
975
|
-
}
|
976
|
-
return resolvedItem;
|
977
|
-
}
|
978
|
-
return item;
|
979
|
-
});
|
980
|
-
|
981
|
-
// ../core/lib/apply-dynamic-props.ts
|
982
|
-
init_react_import();
|
983
|
-
var applyDynamicProps = (data, dynamicProps, rootData) => {
|
984
|
-
return __spreadProps(__spreadValues({}, data), {
|
985
|
-
root: rootData ? __spreadValues(__spreadValues({}, data.root), rootData ? rootData : {}) : data.root,
|
986
|
-
content: data.content.map((item) => {
|
987
|
-
return dynamicProps[item.props.id] ? __spreadValues(__spreadValues({}, item), dynamicProps[item.props.id]) : item;
|
988
|
-
}),
|
989
|
-
zones: Object.keys(data.zones || {}).reduce((acc, zoneKey) => {
|
990
|
-
return __spreadProps(__spreadValues({}, acc), {
|
991
|
-
[zoneKey]: data.zones[zoneKey].map((item) => {
|
992
|
-
return dynamicProps[item.props.id] ? __spreadValues(__spreadValues({}, item), dynamicProps[item.props.id]) : item;
|
993
|
-
})
|
994
|
-
});
|
995
|
-
}, {})
|
996
|
-
});
|
997
|
-
};
|
998
|
-
|
999
|
-
// ../core/lib/resolve-root-data.ts
|
1000
|
-
init_react_import();
|
1001
|
-
var cache2 = {};
|
1002
|
-
function resolveRootData(data, config, metadata) {
|
1003
|
-
return __async(this, null, function* () {
|
1004
|
-
var _a, _b, _c, _d, _e;
|
1005
|
-
if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
|
1006
|
-
if (((_b = cache2.lastChange) == null ? void 0 : _b.original) === data.root) {
|
1007
|
-
return cache2.lastChange.resolved;
|
1008
|
-
}
|
1009
|
-
const changed = getChanged(data.root, (_c = cache2.lastChange) == null ? void 0 : _c.original);
|
1010
|
-
const rootWithProps = data.root;
|
1011
|
-
const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
|
1012
|
-
changed,
|
1013
|
-
lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {},
|
1014
|
-
metadata: metadata || {}
|
1015
|
-
});
|
1016
|
-
cache2.lastChange = {
|
1017
|
-
original: data.root,
|
1018
|
-
resolved: resolvedRoot
|
1019
|
-
};
|
1020
|
-
return __spreadProps(__spreadValues(__spreadValues({}, data.root), resolvedRoot), {
|
1021
|
-
props: __spreadValues(__spreadValues({}, data.root.props), resolvedRoot.props)
|
1022
|
-
});
|
1023
|
-
}
|
1024
|
-
return data.root;
|
1025
|
-
});
|
1026
|
-
}
|
1027
|
-
|
1028
|
-
// ../core/lib/flatten-data.ts
|
1029
|
-
init_react_import();
|
1030
|
-
var flattenData = (data) => {
|
1031
|
-
return Object.keys(data.zones || {}).reduce(
|
1032
|
-
(acc, zone) => [...acc, ...data.zones[zone]],
|
1033
|
-
data.content
|
1034
|
-
);
|
1035
|
-
};
|
1036
|
-
|
1037
|
-
// ../core/lib/resolve-data.ts
|
1038
|
-
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1039
|
-
var resolveData = (newAppState, appStoreData) => {
|
1040
|
-
const {
|
1041
|
-
state: appState,
|
1042
|
-
config,
|
1043
|
-
dispatch,
|
1044
|
-
resolveDataRuns,
|
1045
|
-
setComponentLoading,
|
1046
|
-
unsetComponentLoading,
|
1047
|
-
metadata,
|
1048
|
-
permissions
|
1049
|
-
} = appStoreData;
|
1050
|
-
const deferredSetStates = {};
|
1051
|
-
const _setComponentLoading = (id, loading, defer = 0) => {
|
1052
|
-
if (deferredSetStates[id]) {
|
1053
|
-
clearTimeout(deferredSetStates[id]);
|
1054
|
-
delete deferredSetStates[id];
|
1055
|
-
}
|
1056
|
-
deferredSetStates[id] = setTimeout(() => {
|
1057
|
-
if (loading) {
|
1058
|
-
setComponentLoading(id);
|
1059
|
-
} else {
|
1060
|
-
unsetComponentLoading(id);
|
1061
|
-
}
|
1062
|
-
delete deferredSetStates[id];
|
1063
|
-
}, defer);
|
1064
|
-
};
|
1065
|
-
const runResolvers = () => __async(void 0, null, function* () {
|
1066
|
-
const newData = newAppState.data;
|
1067
|
-
const flatContent = flattenData(newData).filter(
|
1068
|
-
(item) => {
|
1069
|
-
var _a;
|
1070
|
-
return !!((_a = config.components[item.type]) == null ? void 0 : _a.resolveData);
|
1071
|
-
}
|
1072
|
-
);
|
1073
|
-
const applyIfChange = (dynamicDataMap, dynamicRoot) => {
|
1074
|
-
const processed = applyDynamicProps(
|
1075
|
-
__spreadValues({}, appState.data),
|
1076
|
-
dynamicDataMap,
|
1077
|
-
dynamicRoot
|
1078
|
-
);
|
1079
|
-
const processedAppState = __spreadProps(__spreadValues({}, appState), { data: processed });
|
1080
|
-
const containsChanges = !(0, import_fast_deep_equal.default)(appState, processedAppState);
|
1081
|
-
if (containsChanges) {
|
1082
|
-
dispatch({
|
1083
|
-
type: "set",
|
1084
|
-
state: (prev) => __spreadProps(__spreadValues({}, prev), {
|
1085
|
-
data: applyDynamicProps(prev.data, dynamicDataMap, dynamicRoot),
|
1086
|
-
ui: resolveDataRuns > 0 ? __spreadValues(__spreadValues({}, prev.ui), newAppState.ui) : prev.ui
|
1087
|
-
}),
|
1088
|
-
recordHistory: resolveDataRuns > 0
|
1089
|
-
});
|
1090
|
-
}
|
1091
|
-
};
|
1092
|
-
const promises = [];
|
1093
|
-
promises.push(
|
1094
|
-
(() => __async(void 0, null, function* () {
|
1095
|
-
_setComponentLoading("puck-root", true, 50);
|
1096
|
-
const dynamicRoot = yield resolveRootData(newData, config, metadata);
|
1097
|
-
applyIfChange({}, dynamicRoot);
|
1098
|
-
_setComponentLoading("puck-root", false);
|
1099
|
-
}))()
|
1100
|
-
);
|
1101
|
-
flatContent.forEach((item) => {
|
1102
|
-
promises.push(
|
1103
|
-
(() => __async(void 0, null, function* () {
|
1104
|
-
permissions.resolvePermissions({ item }, true);
|
1105
|
-
const dynamicData = yield resolveComponentData(
|
1106
|
-
item,
|
1107
|
-
config,
|
1108
|
-
metadata,
|
1109
|
-
(item2) => {
|
1110
|
-
_setComponentLoading(item2.props.id, true, 50);
|
1111
|
-
},
|
1112
|
-
(item2) => {
|
1113
|
-
deferredSetStates[item2.props.id];
|
1114
|
-
_setComponentLoading(item2.props.id, false);
|
1115
|
-
}
|
1116
|
-
);
|
1117
|
-
const dynamicDataMap = { [item.props.id]: dynamicData };
|
1118
|
-
applyIfChange(dynamicDataMap);
|
1119
|
-
}))()
|
1120
|
-
);
|
1121
|
-
});
|
1122
|
-
yield Promise.all(promises);
|
1123
|
-
});
|
1124
|
-
return runResolvers();
|
1125
|
-
};
|
1126
|
-
|
1127
1461
|
// ../core/store/index.ts
|
1128
1462
|
import { createContext, useContext } from "react";
|
1129
1463
|
|
@@ -1231,7 +1565,7 @@ var createHistorySlice = (set, get) => {
|
|
1231
1565
|
const { dispatch, history } = get();
|
1232
1566
|
dispatch({
|
1233
1567
|
type: "set",
|
1234
|
-
state: ((_a = history.histories[
|
1568
|
+
state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
|
1235
1569
|
});
|
1236
1570
|
set({ history: __spreadProps(__spreadValues({}, history), { index }) });
|
1237
1571
|
},
|
@@ -1241,31 +1575,18 @@ var createHistorySlice = (set, get) => {
|
|
1241
1575
|
|
1242
1576
|
// ../core/store/slices/nodes.ts
|
1243
1577
|
init_react_import();
|
1244
|
-
var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
|
1245
|
-
import { useEffect as useEffect3 } from "react";
|
1246
|
-
var partialDeepEqual = (newItem, existingItem) => {
|
1247
|
-
const filteredExistingItem = Object.keys(newItem).reduce(
|
1248
|
-
(acc, key) => __spreadProps(__spreadValues({}, acc), { [key]: existingItem[key] }),
|
1249
|
-
{}
|
1250
|
-
);
|
1251
|
-
return (0, import_fast_deep_equal2.default)(newItem, filteredExistingItem);
|
1252
|
-
};
|
1253
1578
|
var createNodesSlice = (set, get) => ({
|
1254
1579
|
nodes: {},
|
1255
1580
|
registerNode: (id, node) => {
|
1256
1581
|
const s = get().nodes;
|
1257
|
-
if (s.nodes[id] && partialDeepEqual(node, s.nodes[id])) {
|
1258
|
-
return;
|
1259
|
-
}
|
1260
1582
|
const emptyNode = {
|
1261
1583
|
id,
|
1262
|
-
methods: {
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
element: null
|
1268
|
-
index: -1
|
1584
|
+
methods: {
|
1585
|
+
sync: () => null,
|
1586
|
+
hideOverlay: () => null,
|
1587
|
+
showOverlay: () => null
|
1588
|
+
},
|
1589
|
+
element: null
|
1269
1590
|
};
|
1270
1591
|
const existingNode = s.nodes[id];
|
1271
1592
|
set({
|
@@ -1295,36 +1616,61 @@ var createNodesSlice = (set, get) => ({
|
|
1295
1616
|
|
1296
1617
|
// ../core/store/slices/permissions.ts
|
1297
1618
|
init_react_import();
|
1298
|
-
import { useEffect as
|
1619
|
+
import { useEffect as useEffect3 } from "react";
|
1620
|
+
|
1621
|
+
// ../core/lib/data/flatten-data.ts
|
1622
|
+
init_react_import();
|
1623
|
+
var flattenData = (state, config) => {
|
1624
|
+
const data = [];
|
1625
|
+
walkAppState(
|
1626
|
+
state,
|
1627
|
+
config,
|
1628
|
+
(content) => content,
|
1629
|
+
(item) => {
|
1630
|
+
data.push(item);
|
1631
|
+
return null;
|
1632
|
+
}
|
1633
|
+
);
|
1634
|
+
return data;
|
1635
|
+
};
|
1636
|
+
|
1637
|
+
// ../core/lib/get-changed.ts
|
1638
|
+
init_react_import();
|
1639
|
+
var getChanged = (newItem, oldItem) => {
|
1640
|
+
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
1641
|
+
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
1642
|
+
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
1643
|
+
return __spreadProps(__spreadValues({}, acc), {
|
1644
|
+
[item]: oldItemProps[item] !== newItemProps[item]
|
1645
|
+
});
|
1646
|
+
}, {}) : {};
|
1647
|
+
};
|
1648
|
+
|
1649
|
+
// ../core/store/slices/permissions.ts
|
1299
1650
|
var createPermissionsSlice = (set, get) => {
|
1300
1651
|
const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
|
1301
|
-
const { state, permissions } = get();
|
1302
|
-
const { cache:
|
1652
|
+
const { state, permissions, config } = get();
|
1653
|
+
const { cache: cache2, globalPermissions } = permissions;
|
1303
1654
|
const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
|
1304
1655
|
var _a, _b, _c;
|
1305
|
-
const {
|
1306
|
-
|
1307
|
-
state: appState,
|
1308
|
-
setComponentLoading,
|
1309
|
-
unsetComponentLoading
|
1310
|
-
} = get();
|
1311
|
-
const componentConfig = item2.type === "root" ? config.root : config.components[item2.type];
|
1656
|
+
const { config: config2, state: appState, setComponentLoading } = get();
|
1657
|
+
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
1312
1658
|
if (!componentConfig) {
|
1313
1659
|
return;
|
1314
1660
|
}
|
1315
1661
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
1316
1662
|
if (componentConfig.resolvePermissions) {
|
1317
|
-
const changed = getChanged(item2, (_a =
|
1663
|
+
const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
|
1318
1664
|
if (Object.values(changed).some((el) => el === true) || force2) {
|
1319
|
-
setComponentLoading(item2.props.id);
|
1665
|
+
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
1320
1666
|
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
1321
1667
|
item2,
|
1322
1668
|
{
|
1323
1669
|
changed,
|
1324
|
-
lastPermissions: ((_b =
|
1670
|
+
lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
|
1325
1671
|
permissions: initialPermissions,
|
1326
|
-
appState,
|
1327
|
-
lastData: ((_c =
|
1672
|
+
appState: makeStatePublic(appState),
|
1673
|
+
lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
|
1328
1674
|
}
|
1329
1675
|
);
|
1330
1676
|
const latest = get().permissions;
|
@@ -1341,7 +1687,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1341
1687
|
})
|
1342
1688
|
})
|
1343
1689
|
});
|
1344
|
-
|
1690
|
+
clearTimeout2();
|
1345
1691
|
}
|
1346
1692
|
}
|
1347
1693
|
});
|
@@ -1351,7 +1697,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1351
1697
|
// Shim the root data in by conforming to component data shape
|
1352
1698
|
{
|
1353
1699
|
type: "root",
|
1354
|
-
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "
|
1700
|
+
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "root" })
|
1355
1701
|
},
|
1356
1702
|
force2
|
1357
1703
|
);
|
@@ -1360,14 +1706,13 @@ var createPermissionsSlice = (set, get) => {
|
|
1360
1706
|
if (item) {
|
1361
1707
|
yield resolveDataForItem(item, force);
|
1362
1708
|
} else if (type) {
|
1363
|
-
flattenData(state
|
1709
|
+
flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(void 0, null, function* () {
|
1364
1710
|
yield resolveDataForItem(item2, force);
|
1365
1711
|
}));
|
1366
1712
|
} else if (root) {
|
1367
1713
|
resolveDataForRoot(force);
|
1368
1714
|
} else {
|
1369
|
-
|
1370
|
-
flattenData(state.data).map((item2) => __async(void 0, null, function* () {
|
1715
|
+
flattenData(state, config).map((item2) => __async(void 0, null, function* () {
|
1371
1716
|
yield resolveDataForItem(item2, force);
|
1372
1717
|
}));
|
1373
1718
|
}
|
@@ -1397,7 +1742,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1397
1742
|
} else if (root) {
|
1398
1743
|
const rootConfig = config.root;
|
1399
1744
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
|
1400
|
-
const resolvedForItem = resolvedPermissions["
|
1745
|
+
const resolvedForItem = resolvedPermissions["root"];
|
1401
1746
|
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
1402
1747
|
}
|
1403
1748
|
return globalPermissions;
|
@@ -1409,16 +1754,97 @@ var createPermissionsSlice = (set, get) => {
|
|
1409
1754
|
|
1410
1755
|
// ../core/store/slices/fields.ts
|
1411
1756
|
init_react_import();
|
1412
|
-
import { useCallback, useEffect as
|
1413
|
-
var
|
1757
|
+
import { useCallback, useEffect as useEffect4 } from "react";
|
1758
|
+
var createFieldsSlice = (_set, _get) => {
|
1414
1759
|
return {
|
1415
1760
|
fields: {},
|
1416
1761
|
loading: false,
|
1417
|
-
lastResolvedData: {}
|
1762
|
+
lastResolvedData: {},
|
1763
|
+
id: void 0
|
1418
1764
|
};
|
1419
1765
|
};
|
1420
1766
|
|
1421
|
-
// ../core/
|
1767
|
+
// ../core/lib/resolve-component-data.ts
|
1768
|
+
init_react_import();
|
1769
|
+
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1770
|
+
var cache = { lastChange: {} };
|
1771
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
1772
|
+
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
1773
|
+
const resolvedItem = __spreadValues({}, item);
|
1774
|
+
const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
|
1775
|
+
const id = "id" in item.props ? item.props.id : "root";
|
1776
|
+
if (shouldRunResolver) {
|
1777
|
+
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
1778
|
+
if (item && (0, import_fast_deep_equal.default)(item, oldItem)) {
|
1779
|
+
return { node: resolved, didChange: false };
|
1780
|
+
}
|
1781
|
+
const changed = getChanged(item, oldItem);
|
1782
|
+
if (onResolveStart) {
|
1783
|
+
onResolveStart(item);
|
1784
|
+
}
|
1785
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
1786
|
+
changed,
|
1787
|
+
lastData: oldItem,
|
1788
|
+
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
1789
|
+
trigger
|
1790
|
+
});
|
1791
|
+
resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
|
1792
|
+
if (Object.keys(readOnly).length) {
|
1793
|
+
resolvedItem.readOnly = readOnly;
|
1794
|
+
}
|
1795
|
+
}
|
1796
|
+
let itemWithResolvedChildren = yield mapSlots(
|
1797
|
+
resolvedItem,
|
1798
|
+
(content) => __async(void 0, null, function* () {
|
1799
|
+
return yield Promise.all(
|
1800
|
+
content.map(
|
1801
|
+
(childItem) => __async(void 0, null, function* () {
|
1802
|
+
return (yield resolveComponentData(
|
1803
|
+
childItem,
|
1804
|
+
config,
|
1805
|
+
metadata,
|
1806
|
+
onResolveStart,
|
1807
|
+
onResolveEnd,
|
1808
|
+
trigger
|
1809
|
+
)).node;
|
1810
|
+
})
|
1811
|
+
)
|
1812
|
+
);
|
1813
|
+
}),
|
1814
|
+
config
|
1815
|
+
);
|
1816
|
+
if (shouldRunResolver && onResolveEnd) {
|
1817
|
+
onResolveEnd(resolvedItem);
|
1818
|
+
}
|
1819
|
+
cache.lastChange[id] = {
|
1820
|
+
item,
|
1821
|
+
resolved: itemWithResolvedChildren
|
1822
|
+
};
|
1823
|
+
return {
|
1824
|
+
node: itemWithResolvedChildren,
|
1825
|
+
didChange: !(0, import_fast_deep_equal.default)(item, itemWithResolvedChildren)
|
1826
|
+
};
|
1827
|
+
});
|
1828
|
+
|
1829
|
+
// ../core/lib/data/to-root.ts
|
1830
|
+
init_react_import();
|
1831
|
+
var toRoot = (item) => {
|
1832
|
+
if ("type" in item && item.type !== "root") {
|
1833
|
+
throw new Error("Converting non-root item to root.");
|
1834
|
+
}
|
1835
|
+
const { readOnly } = item;
|
1836
|
+
if (item.props) {
|
1837
|
+
if ("id" in item.props) {
|
1838
|
+
const _a = item.props, { id } = _a, props = __objRest(_a, ["id"]);
|
1839
|
+
return { props, readOnly };
|
1840
|
+
}
|
1841
|
+
return { props: item.props, readOnly };
|
1842
|
+
}
|
1843
|
+
return { props: {}, readOnly };
|
1844
|
+
};
|
1845
|
+
|
1846
|
+
// ../core/store/default-app-state.ts
|
1847
|
+
init_react_import();
|
1422
1848
|
var defaultAppState = {
|
1423
1849
|
data: { content: [], root: {}, zones: {} },
|
1424
1850
|
ui: {
|
@@ -1438,92 +1864,188 @@ var defaultAppState = {
|
|
1438
1864
|
controlsVisible: true
|
1439
1865
|
},
|
1440
1866
|
field: { focus: null }
|
1867
|
+
},
|
1868
|
+
indexes: {
|
1869
|
+
nodes: {},
|
1870
|
+
zones: {}
|
1441
1871
|
}
|
1442
1872
|
};
|
1873
|
+
|
1874
|
+
// ../core/store/index.ts
|
1443
1875
|
var defaultPageFields = {
|
1444
1876
|
title: { type: "text" }
|
1445
1877
|
};
|
1446
1878
|
var createAppStore = (initialAppStore) => create()(
|
1447
|
-
subscribeWithSelector((set, get) =>
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
})
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1879
|
+
subscribeWithSelector((set, get) => {
|
1880
|
+
var _a, _b;
|
1881
|
+
return __spreadProps(__spreadValues({
|
1882
|
+
state: defaultAppState,
|
1883
|
+
config: { components: {} },
|
1884
|
+
componentState: {},
|
1885
|
+
plugins: [],
|
1886
|
+
overrides: {},
|
1887
|
+
viewports: defaultViewports,
|
1888
|
+
zoomConfig: {
|
1889
|
+
autoZoom: 1,
|
1890
|
+
rootHeight: 0,
|
1891
|
+
zoom: 1
|
1892
|
+
},
|
1893
|
+
status: "LOADING",
|
1894
|
+
iframe: {},
|
1895
|
+
metadata: {}
|
1896
|
+
}, initialAppStore), {
|
1897
|
+
fields: createFieldsSlice(set, get),
|
1898
|
+
history: createHistorySlice(set, get),
|
1899
|
+
nodes: createNodesSlice(set, get),
|
1900
|
+
permissions: createPermissionsSlice(set, get),
|
1901
|
+
getComponentConfig: (type) => {
|
1902
|
+
var _a2;
|
1903
|
+
const { config, selectedItem } = get();
|
1904
|
+
const rootFields = ((_a2 = config.root) == null ? void 0 : _a2.fields) || defaultPageFields;
|
1905
|
+
return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
|
1906
|
+
},
|
1907
|
+
selectedItem: ((_a = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _a.ui.itemSelector) ? getItem(
|
1908
|
+
(_b = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _b.ui.itemSelector,
|
1909
|
+
initialAppStore.state
|
1910
|
+
) : null,
|
1911
|
+
dispatch: (action) => set((s) => {
|
1912
|
+
var _a2, _b2;
|
1913
|
+
const { record } = get().history;
|
1914
|
+
const dispatch = createReducer({
|
1915
|
+
record,
|
1916
|
+
appStore: s
|
1917
|
+
});
|
1918
|
+
const state = dispatch(s.state, action);
|
1919
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1920
|
+
(_b2 = (_a2 = get()).onAction) == null ? void 0 : _b2.call(_a2, action, state, get().state);
|
1921
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1922
|
+
}),
|
1923
|
+
setZoomConfig: (zoomConfig) => set({ zoomConfig }),
|
1924
|
+
setStatus: (status) => set({ status }),
|
1925
|
+
setComponentState: (componentState) => set({ componentState }),
|
1926
|
+
pendingLoadTimeouts: {},
|
1927
|
+
setComponentLoading: (id, loading = true, defer = 0) => {
|
1928
|
+
const { setComponentState, pendingLoadTimeouts } = get();
|
1929
|
+
const loadId = generateId();
|
1930
|
+
const setLoading = () => {
|
1931
|
+
var _a2;
|
1932
|
+
const { componentState } = get();
|
1933
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1934
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1935
|
+
loadingCount: (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) + 1
|
1936
|
+
})
|
1937
|
+
}));
|
1938
|
+
};
|
1939
|
+
const unsetLoading = () => {
|
1940
|
+
var _a2;
|
1941
|
+
const { componentState } = get();
|
1942
|
+
clearTimeout(timeout);
|
1943
|
+
delete pendingLoadTimeouts[loadId];
|
1944
|
+
set({ pendingLoadTimeouts });
|
1945
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1946
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1947
|
+
loadingCount: Math.max(
|
1948
|
+
(((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) - 1,
|
1949
|
+
0
|
1950
|
+
)
|
1951
|
+
})
|
1952
|
+
}));
|
1953
|
+
};
|
1954
|
+
const timeout = setTimeout(() => {
|
1955
|
+
if (loading) {
|
1956
|
+
setLoading();
|
1957
|
+
} else {
|
1958
|
+
unsetLoading();
|
1959
|
+
}
|
1960
|
+
delete pendingLoadTimeouts[loadId];
|
1961
|
+
set({ pendingLoadTimeouts });
|
1962
|
+
}, defer);
|
1963
|
+
set({
|
1964
|
+
pendingLoadTimeouts: __spreadProps(__spreadValues({}, pendingLoadTimeouts), {
|
1965
|
+
[id]: timeout
|
1966
|
+
})
|
1967
|
+
});
|
1968
|
+
return unsetLoading;
|
1969
|
+
},
|
1970
|
+
unsetComponentLoading: (id) => {
|
1971
|
+
const { setComponentLoading } = get();
|
1972
|
+
setComponentLoading(id, false);
|
1973
|
+
},
|
1974
|
+
// Helper
|
1975
|
+
setUi: (ui, recordHistory) => set((s) => {
|
1976
|
+
const dispatch = createReducer({
|
1977
|
+
record: () => {
|
1978
|
+
},
|
1979
|
+
appStore: s
|
1980
|
+
});
|
1981
|
+
const state = dispatch(s.state, {
|
1982
|
+
type: "setUi",
|
1983
|
+
ui,
|
1984
|
+
recordHistory
|
1985
|
+
});
|
1986
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1987
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1988
|
+
}),
|
1989
|
+
resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
|
1990
|
+
const { config, metadata, setComponentLoading, permissions } = get();
|
1991
|
+
const timeouts = {};
|
1992
|
+
return yield resolveComponentData(
|
1993
|
+
componentData,
|
1994
|
+
config,
|
1995
|
+
metadata,
|
1996
|
+
(item) => {
|
1997
|
+
const id = "id" in item.props ? item.props.id : "root";
|
1998
|
+
timeouts[id] = setComponentLoading(id, true, 50);
|
1999
|
+
},
|
2000
|
+
(item) => __async(void 0, null, function* () {
|
2001
|
+
const id = "id" in item.props ? item.props.id : "root";
|
2002
|
+
if ("type" in item) {
|
2003
|
+
yield permissions.refreshPermissions({ item });
|
2004
|
+
} else {
|
2005
|
+
yield permissions.refreshPermissions({ root: true });
|
2006
|
+
}
|
2007
|
+
timeouts[id]();
|
2008
|
+
}),
|
2009
|
+
trigger
|
2010
|
+
);
|
2011
|
+
}),
|
2012
|
+
resolveAndCommitData: () => __async(void 0, null, function* () {
|
2013
|
+
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
2014
|
+
walkAppState(
|
2015
|
+
state,
|
2016
|
+
config,
|
2017
|
+
(content) => content,
|
2018
|
+
(childItem) => {
|
2019
|
+
resolveComponentData2(childItem, "load").then((resolved) => {
|
2020
|
+
const { state: state2 } = get();
|
2021
|
+
const node = state2.indexes.nodes[resolved.node.props.id];
|
2022
|
+
if (node && resolved.didChange) {
|
2023
|
+
if (resolved.node.props.id === "root") {
|
2024
|
+
dispatch({
|
2025
|
+
type: "replaceRoot",
|
2026
|
+
root: toRoot(resolved.node)
|
2027
|
+
});
|
2028
|
+
} else {
|
2029
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
2030
|
+
const parentZone = state2.indexes.zones[zoneCompound];
|
2031
|
+
const index = parentZone.contentIds.indexOf(
|
2032
|
+
resolved.node.props.id
|
2033
|
+
);
|
2034
|
+
dispatch({
|
2035
|
+
type: "replace",
|
2036
|
+
data: resolved.node,
|
2037
|
+
destinationIndex: index,
|
2038
|
+
destinationZone: zoneCompound
|
2039
|
+
});
|
2040
|
+
}
|
2041
|
+
}
|
2042
|
+
});
|
2043
|
+
return childItem;
|
2044
|
+
}
|
2045
|
+
);
|
2046
|
+
})
|
2047
|
+
});
|
2048
|
+
})
|
1527
2049
|
);
|
1528
2050
|
var appStoreContext = createContext(createAppStore());
|
1529
2051
|
function useAppStore(selector) {
|
@@ -1543,12 +2065,12 @@ var useBreadcrumbs = (renderCount) => {
|
|
1543
2065
|
const config = useAppStore((s) => s.config);
|
1544
2066
|
const path = useAppStore((s) => {
|
1545
2067
|
var _a;
|
1546
|
-
return (_a = s.
|
2068
|
+
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
1547
2069
|
});
|
1548
2070
|
const appStore = useAppStoreApi();
|
1549
2071
|
return useMemo(() => {
|
1550
2072
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
1551
|
-
var _a, _b;
|
2073
|
+
var _a, _b, _c;
|
1552
2074
|
const [componentId] = zoneCompound.split(":");
|
1553
2075
|
if (componentId === "root") {
|
1554
2076
|
return {
|
@@ -1556,12 +2078,15 @@ var useBreadcrumbs = (renderCount) => {
|
|
1556
2078
|
selector: null
|
1557
2079
|
};
|
1558
2080
|
}
|
1559
|
-
const node = appStore.getState().
|
1560
|
-
const
|
2081
|
+
const node = appStore.getState().state.indexes.nodes[componentId];
|
2082
|
+
const parentId = node.path[node.path.length - 1];
|
2083
|
+
const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
|
2084
|
+
const index = contentIds.indexOf(componentId);
|
2085
|
+
const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
|
1561
2086
|
return {
|
1562
2087
|
label,
|
1563
2088
|
selector: node ? {
|
1564
|
-
index
|
2089
|
+
index,
|
1565
2090
|
zone: node.path[node.path.length - 1]
|
1566
2091
|
} : null
|
1567
2092
|
};
|
@@ -1582,6 +2107,12 @@ init_react_import();
|
|
1582
2107
|
// ../core/lib/filter.ts
|
1583
2108
|
init_react_import();
|
1584
2109
|
|
2110
|
+
// ../core/lib/data/reorder.ts
|
2111
|
+
init_react_import();
|
2112
|
+
|
2113
|
+
// ../core/lib/data/replace.ts
|
2114
|
+
init_react_import();
|
2115
|
+
|
1585
2116
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
|
1586
2117
|
init_react_import();
|
1587
2118
|
var styles_module_default3 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
|
@@ -1763,17 +2294,39 @@ var usePuck = createUsePuck();
|
|
1763
2294
|
var HeadingAnalyzer = () => {
|
1764
2295
|
const data = usePuck((s) => s.appState.data);
|
1765
2296
|
const [hierarchy, setHierarchy] = useState([]);
|
1766
|
-
|
2297
|
+
useEffect5(() => {
|
1767
2298
|
const frame = getFrame();
|
1768
|
-
|
1769
|
-
|
1770
|
-
setHierarchy(buildHierarchy(entry));
|
1771
|
-
const observer = new MutationObserver(() => {
|
2299
|
+
let entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
2300
|
+
const createHierarchy = () => {
|
1772
2301
|
setHierarchy(buildHierarchy(entry));
|
2302
|
+
};
|
2303
|
+
const entryObserver = new MutationObserver(() => {
|
2304
|
+
createHierarchy();
|
2305
|
+
});
|
2306
|
+
const frameObserver = new MutationObserver(() => {
|
2307
|
+
entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
2308
|
+
if (entry) {
|
2309
|
+
registerEntryObserver();
|
2310
|
+
frameObserver.disconnect();
|
2311
|
+
}
|
1773
2312
|
});
|
1774
|
-
|
2313
|
+
const registerEntryObserver = () => {
|
2314
|
+
if (!entry) return;
|
2315
|
+
entryObserver.observe(entry, { subtree: true, childList: true });
|
2316
|
+
};
|
2317
|
+
const registerFrameObserver = () => {
|
2318
|
+
if (!frame) return;
|
2319
|
+
frameObserver.observe(frame, { subtree: true, childList: true });
|
2320
|
+
};
|
2321
|
+
if (entry) {
|
2322
|
+
createHierarchy();
|
2323
|
+
registerEntryObserver();
|
2324
|
+
} else {
|
2325
|
+
registerFrameObserver();
|
2326
|
+
}
|
1775
2327
|
return () => {
|
1776
|
-
|
2328
|
+
entryObserver.disconnect();
|
2329
|
+
frameObserver.disconnect();
|
1777
2330
|
};
|
1778
2331
|
}, [data]);
|
1779
2332
|
return /* @__PURE__ */ jsxs2("div", { className: getClassName5(), children: [
|