@measured/puck-plugin-heading-analyzer 0.19.0-canary.b918900 → 0.19.0-canary.bc5bfff1
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 +22 -10
- package/dist/index.d.ts +22 -10
- package/dist/index.js +1204 -673
- package/dist/index.mjs +1197 -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 = flatten2;
|
155
|
+
flatten2.flatten = flatten2;
|
156
|
+
flatten2.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 flatten2(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
|
+
flatten2(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,58 +488,305 @@ 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 remove = (list, index) => {
|
388
|
-
const result = Array.from(list);
|
389
|
-
result.splice(index, 1);
|
390
|
-
return result;
|
391
|
-
};
|
392
514
|
|
393
|
-
// ../core/lib/
|
515
|
+
// ../core/lib/data/is-slot.ts
|
394
516
|
init_react_import();
|
395
|
-
var
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
517
|
+
var isSlot = (prop) => {
|
518
|
+
var _a, _b;
|
519
|
+
return Array.isArray(prop) && typeof ((_a = prop[0]) == null ? void 0 : _a.type) === "string" && typeof ((_b = prop[0]) == null ? void 0 : _b.props) === "object";
|
520
|
+
};
|
521
|
+
var createIsSlotConfig = (config) => (itemType, propName, propValue) => {
|
522
|
+
var _a, _b;
|
523
|
+
const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
|
524
|
+
if (!configForComponent) return isSlot(propValue);
|
525
|
+
return ((_b = (_a = configForComponent.fields) == null ? void 0 : _a[propName]) == null ? void 0 : _b.type) === "slot";
|
526
|
+
};
|
527
|
+
|
528
|
+
// ../core/lib/data/map-slots.ts
|
529
|
+
function mapSlotsAsync(_0, _1) {
|
530
|
+
return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
|
531
|
+
const props = __spreadValues({}, item.props);
|
532
|
+
const propKeys = Object.keys(props);
|
533
|
+
for (let i = 0; i < propKeys.length; i++) {
|
534
|
+
const propKey = propKeys[i];
|
535
|
+
const itemType = "type" in item ? item.type : "root";
|
536
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
537
|
+
const content = props[propKey];
|
538
|
+
const mappedContent = recursive ? yield Promise.all(
|
539
|
+
content.map((item2) => __async(this, null, function* () {
|
540
|
+
return yield mapSlotsAsync(item2, map, recursive, isSlot2);
|
541
|
+
}))
|
542
|
+
) : content;
|
543
|
+
props[propKey] = yield map(mappedContent, propKey);
|
544
|
+
}
|
545
|
+
}
|
546
|
+
return __spreadProps(__spreadValues({}, item), { props });
|
401
547
|
});
|
402
|
-
|
403
|
-
|
548
|
+
}
|
549
|
+
var walkField = ({
|
550
|
+
value,
|
551
|
+
fields,
|
552
|
+
map,
|
553
|
+
propKey = "",
|
554
|
+
propPath = "",
|
555
|
+
id = ""
|
556
|
+
}) => {
|
557
|
+
var _a, _b, _c;
|
558
|
+
if (((_a = fields[propKey]) == null ? void 0 : _a.type) === "slot") {
|
559
|
+
const content = value || [];
|
560
|
+
return map(content, id, propPath, fields[propKey], propPath);
|
561
|
+
}
|
562
|
+
if (value && typeof value === "object") {
|
563
|
+
if (Array.isArray(value)) {
|
564
|
+
const arrayFields = ((_b = fields[propKey]) == null ? void 0 : _b.type) === "array" ? fields[propKey].arrayFields : null;
|
565
|
+
if (!arrayFields) return value;
|
566
|
+
return value.map(
|
567
|
+
(el, idx) => walkField({
|
568
|
+
value: el,
|
569
|
+
fields: arrayFields,
|
570
|
+
map,
|
571
|
+
propKey,
|
572
|
+
propPath: `${propPath}[${idx}]`,
|
573
|
+
id
|
574
|
+
})
|
575
|
+
);
|
576
|
+
} else if ("$$typeof" in value) {
|
577
|
+
return value;
|
578
|
+
} else {
|
579
|
+
const objectFields = ((_c = fields[propKey]) == null ? void 0 : _c.type) === "object" ? fields[propKey].objectFields : fields;
|
580
|
+
return Object.entries(value).reduce(
|
581
|
+
(acc, [k, v]) => {
|
582
|
+
const newValue = walkField({
|
583
|
+
value: v,
|
584
|
+
fields: objectFields,
|
585
|
+
map,
|
586
|
+
propKey: k,
|
587
|
+
propPath: `${propPath}.${k}`,
|
588
|
+
id
|
589
|
+
});
|
590
|
+
if (typeof newValue === "undefined" || newValue === v) return acc;
|
591
|
+
return __spreadProps(__spreadValues({}, acc), {
|
592
|
+
[k]: newValue
|
593
|
+
});
|
594
|
+
},
|
595
|
+
value
|
596
|
+
);
|
597
|
+
}
|
598
|
+
}
|
599
|
+
return value;
|
404
600
|
};
|
601
|
+
function mapSlotsSync(item, map, config) {
|
602
|
+
var _a, _b, _c;
|
603
|
+
const itemType = "type" in item ? item.type : "root";
|
604
|
+
const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
|
605
|
+
const newProps = __spreadValues({}, (_b = item.props) != null ? _b : {});
|
606
|
+
Object.entries((_c = item.props) != null ? _c : {}).forEach(([k, v]) => {
|
607
|
+
var _a2, _b2;
|
608
|
+
const newValue = walkField({
|
609
|
+
value: v,
|
610
|
+
fields: (_a2 = componentConfig == null ? void 0 : componentConfig.fields) != null ? _a2 : {},
|
611
|
+
map,
|
612
|
+
propKey: k,
|
613
|
+
propPath: k,
|
614
|
+
id: (_b2 = item.props.id) != null ? _b2 : "root"
|
615
|
+
});
|
616
|
+
newProps[k] = newValue;
|
617
|
+
}, item.props);
|
618
|
+
return __spreadProps(__spreadValues({}, item), {
|
619
|
+
props: newProps
|
620
|
+
});
|
621
|
+
}
|
405
622
|
|
406
|
-
// ../core/lib/
|
623
|
+
// ../core/lib/data/flatten-node.ts
|
407
624
|
init_react_import();
|
408
|
-
var
|
409
|
-
const result = Array.from(list);
|
410
|
-
result.splice(index, 1);
|
411
|
-
result.splice(index, 0, newItem);
|
412
|
-
return result;
|
413
|
-
};
|
625
|
+
var import_flat = __toESM(require_flat());
|
414
626
|
|
415
|
-
// ../core/lib/
|
627
|
+
// ../core/lib/data/strip-slots.ts
|
416
628
|
init_react_import();
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
return
|
629
|
+
var stripSlots = (data, config) => {
|
630
|
+
return mapSlotsSync(data, () => null, config);
|
631
|
+
};
|
632
|
+
|
633
|
+
// ../core/lib/data/flatten-node.ts
|
634
|
+
var flattenNode = (node, config) => {
|
635
|
+
return __spreadProps(__spreadValues({}, node), {
|
636
|
+
props: (0, import_flat.flatten)(stripSlots(node, config).props)
|
637
|
+
});
|
638
|
+
};
|
639
|
+
|
640
|
+
// ../core/lib/data/walk-app-state.ts
|
641
|
+
function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
642
|
+
var _a;
|
643
|
+
let newZones = {};
|
644
|
+
const newZoneIndex = {};
|
645
|
+
const newNodeIndex = {};
|
646
|
+
const processContent = (path, zoneCompound, content, zoneType, newId) => {
|
647
|
+
var _a2;
|
648
|
+
const [parentId] = zoneCompound.split(":");
|
649
|
+
const mappedContent = ((_a2 = mapContent(content, zoneCompound, zoneType)) != null ? _a2 : content) || [];
|
650
|
+
const [_2, zone] = zoneCompound.split(":");
|
651
|
+
const newZoneCompound = `${newId || parentId}:${zone}`;
|
652
|
+
const newContent2 = mappedContent.map(
|
653
|
+
(zoneChild, index) => processItem(zoneChild, [...path, newZoneCompound], index)
|
654
|
+
);
|
655
|
+
newZoneIndex[newZoneCompound] = {
|
656
|
+
contentIds: newContent2.map((item) => item.props.id),
|
657
|
+
type: zoneType
|
658
|
+
};
|
659
|
+
return [newZoneCompound, newContent2];
|
660
|
+
};
|
661
|
+
const processRelatedZones = (item, newId, initialPath) => {
|
662
|
+
forRelatedZones(
|
663
|
+
item,
|
664
|
+
state.data,
|
665
|
+
(relatedPath, relatedZoneCompound, relatedContent) => {
|
666
|
+
const [zoneCompound, newContent2] = processContent(
|
667
|
+
relatedPath,
|
668
|
+
relatedZoneCompound,
|
669
|
+
relatedContent,
|
670
|
+
"dropzone",
|
671
|
+
newId
|
672
|
+
);
|
673
|
+
newZones[zoneCompound] = newContent2;
|
674
|
+
},
|
675
|
+
initialPath
|
676
|
+
);
|
677
|
+
};
|
678
|
+
const processItem = (item, path, index) => {
|
679
|
+
const mappedItem = mapNodeOrSkip(item, path, index);
|
680
|
+
if (!mappedItem) return item;
|
681
|
+
const id = mappedItem.props.id;
|
682
|
+
const newProps = __spreadProps(__spreadValues({}, mapSlotsSync(
|
683
|
+
mappedItem,
|
684
|
+
(content, parentId2, slotId) => {
|
685
|
+
const zoneCompound = `${parentId2}:${slotId}`;
|
686
|
+
const [_2, newContent2] = processContent(
|
687
|
+
path,
|
688
|
+
zoneCompound,
|
689
|
+
content,
|
690
|
+
"slot",
|
691
|
+
parentId2
|
692
|
+
);
|
693
|
+
return newContent2;
|
694
|
+
},
|
695
|
+
config
|
696
|
+
).props), {
|
697
|
+
id
|
698
|
+
});
|
699
|
+
processRelatedZones(item, id, path);
|
700
|
+
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
|
701
|
+
const thisZoneCompound = path[path.length - 1];
|
702
|
+
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
703
|
+
newNodeIndex[id] = {
|
704
|
+
data: newItem,
|
705
|
+
flatData: flattenNode(newItem, config),
|
706
|
+
path,
|
707
|
+
parentId,
|
708
|
+
zone
|
709
|
+
};
|
710
|
+
const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
|
711
|
+
if (newProps.id === "root") {
|
712
|
+
delete finalData["type"];
|
713
|
+
delete finalData.props["id"];
|
714
|
+
}
|
715
|
+
return finalData;
|
716
|
+
};
|
717
|
+
const zones = state.data.zones || {};
|
718
|
+
const [_, newContent] = processContent(
|
719
|
+
[],
|
720
|
+
rootDroppableId,
|
721
|
+
state.data.content,
|
722
|
+
"root"
|
723
|
+
);
|
724
|
+
const processedContent = newContent;
|
725
|
+
const zonesAlreadyProcessed = Object.keys(newZones);
|
726
|
+
Object.keys(zones || {}).forEach((zoneCompound) => {
|
727
|
+
const [parentId] = zoneCompound.split(":");
|
728
|
+
if (zonesAlreadyProcessed.includes(zoneCompound)) {
|
729
|
+
return;
|
730
|
+
}
|
731
|
+
const [_2, newContent2] = processContent(
|
732
|
+
[rootDroppableId],
|
733
|
+
zoneCompound,
|
734
|
+
zones[zoneCompound],
|
735
|
+
"dropzone",
|
736
|
+
parentId
|
737
|
+
);
|
738
|
+
newZones[zoneCompound] = newContent2;
|
739
|
+
}, newZones);
|
740
|
+
const processedRoot = processItem(
|
741
|
+
{
|
742
|
+
type: "root",
|
743
|
+
props: __spreadProps(__spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root), { id: "root" })
|
744
|
+
},
|
745
|
+
[],
|
746
|
+
-1
|
747
|
+
);
|
748
|
+
const root = __spreadProps(__spreadValues({}, state.data.root), {
|
749
|
+
props: processedRoot.props
|
750
|
+
});
|
751
|
+
return __spreadProps(__spreadValues({}, state), {
|
752
|
+
data: {
|
753
|
+
root,
|
754
|
+
content: processedContent,
|
755
|
+
zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
|
756
|
+
},
|
757
|
+
indexes: {
|
758
|
+
nodes: __spreadValues(__spreadValues({}, state.indexes.nodes), newNodeIndex),
|
759
|
+
zones: __spreadValues(__spreadValues({}, state.indexes.zones), newZoneIndex)
|
760
|
+
}
|
761
|
+
});
|
424
762
|
}
|
425
763
|
|
426
|
-
// ../core/
|
764
|
+
// ../core/reducer/actions/set.ts
|
765
|
+
var setAction = (state, action, appStore) => {
|
766
|
+
if (typeof action.state === "object") {
|
767
|
+
const newState = __spreadValues(__spreadValues({}, state), action.state);
|
768
|
+
if (action.state.indexes) {
|
769
|
+
return newState;
|
770
|
+
}
|
771
|
+
console.warn(
|
772
|
+
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
773
|
+
);
|
774
|
+
return walkAppState(newState, appStore.config);
|
775
|
+
}
|
776
|
+
return __spreadValues(__spreadValues({}, state), action.state(state));
|
777
|
+
};
|
778
|
+
|
779
|
+
// ../core/reducer/actions/insert.ts
|
427
780
|
init_react_import();
|
428
781
|
|
782
|
+
// ../core/lib/data/insert.ts
|
783
|
+
init_react_import();
|
784
|
+
var insert = (list, index, item) => {
|
785
|
+
const result = Array.from(list || []);
|
786
|
+
result.splice(index, 0, item);
|
787
|
+
return result;
|
788
|
+
};
|
789
|
+
|
429
790
|
// ../core/lib/generate-id.ts
|
430
791
|
init_react_import();
|
431
792
|
|
@@ -488,313 +849,437 @@ var v4_default = v4;
|
|
488
849
|
// ../core/lib/generate-id.ts
|
489
850
|
var generateId = (type) => type ? `${type}-${v4_default()}` : v4_default();
|
490
851
|
|
491
|
-
// ../core/lib/get-
|
852
|
+
// ../core/lib/data/get-ids-for-parent.ts
|
492
853
|
init_react_import();
|
493
|
-
var
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
498
|
-
return zoneCompound.split(":");
|
499
|
-
}
|
500
|
-
return [rootDroppableId, zoneCompound];
|
854
|
+
var getIdsForParent = (zoneCompound, state) => {
|
855
|
+
const [parentId] = zoneCompound.split(":");
|
856
|
+
const node = state.indexes.nodes[parentId];
|
857
|
+
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
|
501
858
|
};
|
502
859
|
|
503
|
-
// ../core/lib/
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
860
|
+
// ../core/lib/data/populate-ids.ts
|
861
|
+
init_react_import();
|
862
|
+
|
863
|
+
// ../core/lib/data/walk-tree.ts
|
864
|
+
init_react_import();
|
865
|
+
function walkTree(data, config, callbackFn) {
|
866
|
+
var _a, _b;
|
867
|
+
const walkItem = (item) => {
|
868
|
+
return mapSlotsSync(
|
869
|
+
item,
|
870
|
+
(content, parentId, propName) => {
|
871
|
+
var _a2;
|
872
|
+
return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
|
514
873
|
},
|
874
|
+
config
|
875
|
+
);
|
876
|
+
};
|
877
|
+
if ("props" in data) {
|
878
|
+
return walkItem(data);
|
879
|
+
}
|
880
|
+
const _data = data;
|
881
|
+
const zones = (_a = _data.zones) != null ? _a : {};
|
882
|
+
const mappedContent = _data.content.map(walkItem);
|
883
|
+
return {
|
884
|
+
root: walkItem(_data.root),
|
885
|
+
content: (_b = callbackFn(mappedContent, {
|
886
|
+
parentId: "root",
|
887
|
+
propName: "default-zone"
|
888
|
+
})) != null ? _b : mappedContent,
|
889
|
+
zones: Object.keys(zones).reduce(
|
890
|
+
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
|
891
|
+
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
892
|
+
}),
|
515
893
|
{}
|
516
894
|
)
|
517
|
-
}
|
895
|
+
};
|
518
896
|
}
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
897
|
+
|
898
|
+
// ../core/lib/data/populate-ids.ts
|
899
|
+
var populateIds = (data, config, override = false) => {
|
900
|
+
const id = generateId(data.type);
|
901
|
+
return walkTree(
|
902
|
+
__spreadProps(__spreadValues({}, data), {
|
903
|
+
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({ id }, data.props)
|
904
|
+
}),
|
905
|
+
config,
|
906
|
+
(contents) => contents.map((item) => {
|
907
|
+
const id2 = generateId(item.type);
|
908
|
+
return __spreadProps(__spreadValues({}, item), {
|
909
|
+
props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
|
910
|
+
});
|
911
|
+
})
|
912
|
+
);
|
913
|
+
};
|
914
|
+
|
915
|
+
// ../core/reducer/actions/insert.ts
|
916
|
+
function insertAction(state, action, appStore) {
|
917
|
+
const id = action.id || generateId(action.componentType);
|
918
|
+
const emptyComponentData = populateIds(
|
919
|
+
{
|
920
|
+
type: action.componentType,
|
921
|
+
props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
|
922
|
+
id
|
923
|
+
})
|
924
|
+
},
|
925
|
+
appStore.config
|
926
|
+
);
|
927
|
+
const [parentId] = action.destinationZone.split(":");
|
928
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
929
|
+
return walkAppState(
|
930
|
+
state,
|
931
|
+
appStore.config,
|
932
|
+
(content, zoneCompound) => {
|
933
|
+
if (zoneCompound === action.destinationZone) {
|
934
|
+
return insert(
|
935
|
+
content || [],
|
936
|
+
action.destinationIndex,
|
937
|
+
emptyComponentData
|
938
|
+
);
|
526
939
|
}
|
527
|
-
return
|
940
|
+
return content;
|
528
941
|
},
|
529
|
-
{
|
942
|
+
(childItem, path) => {
|
943
|
+
if (childItem.props.id === id || childItem.props.id === parentId) {
|
944
|
+
return childItem;
|
945
|
+
} else if (idsInPath.includes(childItem.props.id)) {
|
946
|
+
return childItem;
|
947
|
+
} else if (path.includes(action.destinationZone)) {
|
948
|
+
return childItem;
|
949
|
+
}
|
950
|
+
return null;
|
951
|
+
}
|
530
952
|
);
|
531
|
-
}
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
953
|
+
}
|
954
|
+
|
955
|
+
// ../core/reducer/actions/replace.ts
|
956
|
+
init_react_import();
|
957
|
+
var replaceAction = (state, action, appStore) => {
|
958
|
+
const [parentId] = action.destinationZone.split(":");
|
959
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
960
|
+
const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
|
961
|
+
const idChanged = originalId !== action.data.props.id;
|
962
|
+
if (idChanged) {
|
963
|
+
throw new Error(
|
964
|
+
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
965
|
+
);
|
966
|
+
}
|
967
|
+
const data = populateIds(action.data, appStore.config);
|
968
|
+
return walkAppState(
|
969
|
+
state,
|
970
|
+
appStore.config,
|
971
|
+
(content, zoneCompound) => {
|
972
|
+
const newContent = [...content];
|
973
|
+
if (zoneCompound === action.destinationZone) {
|
974
|
+
newContent[action.destinationIndex] = data;
|
541
975
|
}
|
542
|
-
return
|
976
|
+
return newContent;
|
543
977
|
},
|
544
|
-
{
|
978
|
+
(childItem, path) => {
|
979
|
+
const pathIds = path.map((p) => p.split(":")[0]);
|
980
|
+
if (childItem.props.id === data.props.id) {
|
981
|
+
return data;
|
982
|
+
} else if (childItem.props.id === parentId) {
|
983
|
+
return childItem;
|
984
|
+
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
985
|
+
return childItem;
|
986
|
+
} else if (pathIds.indexOf(data.props.id) > -1) {
|
987
|
+
return childItem;
|
988
|
+
}
|
989
|
+
return null;
|
990
|
+
}
|
545
991
|
);
|
546
992
|
};
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
993
|
+
|
994
|
+
// ../core/reducer/actions/replace-root.ts
|
995
|
+
init_react_import();
|
996
|
+
var replaceRootAction = (state, action, appStore) => {
|
997
|
+
return walkAppState(
|
998
|
+
state,
|
999
|
+
appStore.config,
|
1000
|
+
(content) => content,
|
1001
|
+
(childItem) => {
|
1002
|
+
if (childItem.props.id === "root") {
|
1003
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
1004
|
+
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
1005
|
+
readOnly: action.root.readOnly
|
1006
|
+
});
|
1007
|
+
}
|
1008
|
+
return childItem;
|
1009
|
+
}
|
1010
|
+
);
|
554
1011
|
};
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
return __spreadProps(__spreadValues({}, dupeOfDupes), {
|
566
|
-
[key]: zone,
|
567
|
-
[`${newId}:${zoneId}`]: dupedZone
|
568
|
-
});
|
569
|
-
});
|
1012
|
+
|
1013
|
+
// ../core/reducer/actions/duplicate.ts
|
1014
|
+
init_react_import();
|
1015
|
+
|
1016
|
+
// ../core/lib/data/get-item.ts
|
1017
|
+
init_react_import();
|
1018
|
+
function getItem(selector, state) {
|
1019
|
+
var _a, _b;
|
1020
|
+
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
1021
|
+
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
570
1022
|
}
|
571
1023
|
|
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
|
-
)
|
1024
|
+
// ../core/reducer/actions/duplicate.ts
|
1025
|
+
function duplicateAction(state, action, appStore) {
|
1026
|
+
const item = getItem(
|
1027
|
+
{ index: action.sourceIndex, zone: action.sourceZone },
|
1028
|
+
state
|
1029
|
+
);
|
1030
|
+
const idsInPath = getIdsForParent(action.sourceZone, state);
|
1031
|
+
const newItem = __spreadProps(__spreadValues({}, item), {
|
1032
|
+
props: __spreadProps(__spreadValues({}, item.props), {
|
1033
|
+
id: generateId(item.type)
|
588
1034
|
})
|
589
1035
|
});
|
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
|
-
|
1036
|
+
const modified = walkAppState(
|
1037
|
+
state,
|
1038
|
+
appStore.config,
|
1039
|
+
(content, zoneCompound) => {
|
1040
|
+
if (zoneCompound === action.sourceZone) {
|
1041
|
+
return insert(content, action.sourceIndex + 1, item);
|
1042
|
+
}
|
1043
|
+
return content;
|
1044
|
+
},
|
1045
|
+
(childItem, path, index) => {
|
1046
|
+
const zoneCompound = path[path.length - 1];
|
1047
|
+
const parents = path.map((p) => p.split(":")[0]);
|
1048
|
+
if (parents.indexOf(newItem.props.id) > -1) {
|
1049
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
1050
|
+
props: __spreadProps(__spreadValues({}, childItem.props), {
|
1051
|
+
id: generateId(childItem.type)
|
1052
|
+
})
|
1053
|
+
});
|
1054
|
+
}
|
1055
|
+
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
1056
|
+
return newItem;
|
1057
|
+
}
|
1058
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
1059
|
+
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
1060
|
+
return childItem;
|
1061
|
+
}
|
1062
|
+
return null;
|
1063
|
+
}
|
1064
|
+
);
|
1065
|
+
return __spreadProps(__spreadValues({}, modified), {
|
1066
|
+
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
1067
|
+
itemSelector: {
|
1068
|
+
index: action.sourceIndex + 1,
|
1069
|
+
zone: action.sourceZone
|
1070
|
+
}
|
615
1071
|
})
|
616
1072
|
});
|
617
1073
|
}
|
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
|
-
});
|
1074
|
+
|
1075
|
+
// ../core/reducer/actions/reorder.ts
|
1076
|
+
init_react_import();
|
1077
|
+
|
1078
|
+
// ../core/reducer/actions/move.ts
|
1079
|
+
init_react_import();
|
1080
|
+
|
1081
|
+
// ../core/lib/data/remove.ts
|
1082
|
+
init_react_import();
|
1083
|
+
var remove = (list, index) => {
|
1084
|
+
const result = Array.from(list);
|
1085
|
+
result.splice(index, 1);
|
1086
|
+
return result;
|
638
1087
|
};
|
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);
|
1088
|
+
|
1089
|
+
// ../core/reducer/actions/move.ts
|
1090
|
+
var moveAction = (state, action, appStore) => {
|
1091
|
+
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
1092
|
+
return state;
|
675
1093
|
}
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
1094
|
+
const item = getItem(
|
1095
|
+
{ zone: action.sourceZone, index: action.sourceIndex },
|
1096
|
+
state
|
1097
|
+
);
|
1098
|
+
if (!item) return state;
|
1099
|
+
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
1100
|
+
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
1101
|
+
return walkAppState(
|
1102
|
+
state,
|
1103
|
+
appStore.config,
|
1104
|
+
(content, zoneCompound) => {
|
1105
|
+
if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
|
1106
|
+
return insert(
|
1107
|
+
remove(content, action.sourceIndex),
|
1108
|
+
action.destinationIndex,
|
1109
|
+
item
|
1110
|
+
);
|
1111
|
+
} else if (zoneCompound === action.sourceZone) {
|
1112
|
+
return remove(content, action.sourceIndex);
|
1113
|
+
} else if (zoneCompound === action.destinationZone) {
|
1114
|
+
return insert(content, action.destinationIndex, item);
|
1115
|
+
}
|
1116
|
+
return content;
|
1117
|
+
},
|
1118
|
+
(childItem, path) => {
|
1119
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
1120
|
+
const [destinationZoneParent] = action.destinationZone.split(":");
|
1121
|
+
const childId = childItem.props.id;
|
1122
|
+
if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1 || path.includes(action.destinationZone)) {
|
1123
|
+
return childItem;
|
1124
|
+
}
|
1125
|
+
return null;
|
690
1126
|
}
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
1127
|
+
);
|
1128
|
+
};
|
1129
|
+
|
1130
|
+
// ../core/reducer/actions/reorder.ts
|
1131
|
+
var reorderAction = (state, action, appStore) => {
|
1132
|
+
return moveAction(
|
1133
|
+
state,
|
1134
|
+
{
|
1135
|
+
type: "move",
|
1136
|
+
sourceIndex: action.sourceIndex,
|
1137
|
+
sourceZone: action.destinationZone,
|
1138
|
+
destinationIndex: action.destinationIndex,
|
1139
|
+
destinationZone: action.destinationZone
|
1140
|
+
},
|
1141
|
+
appStore
|
1142
|
+
);
|
1143
|
+
};
|
1144
|
+
|
1145
|
+
// ../core/reducer/actions/remove.ts
|
1146
|
+
init_react_import();
|
1147
|
+
var removeAction = (state, action, appStore) => {
|
1148
|
+
const item = getItem({ index: action.index, zone: action.zone }, state);
|
1149
|
+
const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
|
1150
|
+
(acc, [nodeId, nodeData]) => {
|
1151
|
+
const pathIds = nodeData.path.map((p) => p.split(":")[0]);
|
1152
|
+
if (pathIds.includes(item.props.id)) {
|
1153
|
+
return [...acc, nodeId];
|
1154
|
+
}
|
1155
|
+
return acc;
|
1156
|
+
},
|
1157
|
+
[item.props.id]
|
1158
|
+
);
|
1159
|
+
const newState = walkAppState(
|
1160
|
+
state,
|
1161
|
+
appStore.config,
|
1162
|
+
(content, zoneCompound) => {
|
1163
|
+
if (zoneCompound === action.zone) {
|
1164
|
+
return remove(content, action.index);
|
1165
|
+
}
|
1166
|
+
return content;
|
702
1167
|
}
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
newData.zones[action.sourceZone],
|
709
|
-
action.sourceIndex
|
710
|
-
)
|
711
|
-
})
|
712
|
-
});
|
1168
|
+
);
|
1169
|
+
Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
|
1170
|
+
const parentId = zoneCompound.split(":")[0];
|
1171
|
+
if (nodesToDelete.includes(parentId) && newState.data.zones) {
|
1172
|
+
delete newState.data.zones[zoneCompound];
|
713
1173
|
}
|
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
|
-
});
|
1174
|
+
});
|
1175
|
+
Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
|
1176
|
+
const parentId = zoneCompound.split(":")[0];
|
1177
|
+
if (nodesToDelete.includes(parentId)) {
|
1178
|
+
delete newState.indexes.zones[zoneCompound];
|
741
1179
|
}
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
1180
|
+
});
|
1181
|
+
nodesToDelete.forEach((id) => {
|
1182
|
+
delete newState.indexes.nodes[id];
|
1183
|
+
});
|
1184
|
+
return newState;
|
1185
|
+
};
|
1186
|
+
|
1187
|
+
// ../core/reducer/actions/register-zone.ts
|
1188
|
+
init_react_import();
|
1189
|
+
|
1190
|
+
// ../core/lib/data/setup-zone.ts
|
1191
|
+
init_react_import();
|
1192
|
+
var setupZone = (data, zoneKey) => {
|
1193
|
+
if (zoneKey === rootDroppableId) {
|
1194
|
+
return data;
|
750
1195
|
}
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
1196
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
1197
|
+
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
1198
|
+
});
|
1199
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
1200
|
+
return newData;
|
1201
|
+
};
|
1202
|
+
|
1203
|
+
// ../core/reducer/actions/register-zone.ts
|
1204
|
+
var zoneCache = {};
|
1205
|
+
function registerZoneAction(state, action) {
|
1206
|
+
if (zoneCache[action.zone]) {
|
1207
|
+
return __spreadProps(__spreadValues({}, state), {
|
1208
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
1209
|
+
zones: __spreadProps(__spreadValues({}, state.data.zones), {
|
755
1210
|
[action.zone]: zoneCache[action.zone]
|
756
1211
|
})
|
757
|
-
})
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
}
|
767
|
-
return __spreadProps(__spreadValues({}, data), { zones: _zones });
|
1212
|
+
}),
|
1213
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1214
|
+
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
|
1215
|
+
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
|
1216
|
+
contentIds: zoneCache[action.zone].map((item) => item.props.id),
|
1217
|
+
type: "dropzone"
|
1218
|
+
})
|
1219
|
+
})
|
1220
|
+
})
|
1221
|
+
});
|
768
1222
|
}
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
1223
|
+
return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
|
1224
|
+
}
|
1225
|
+
function unregisterZoneAction(state, action) {
|
1226
|
+
const _zones = __spreadValues({}, state.data.zones || {});
|
1227
|
+
const zoneIndex = __spreadValues({}, state.indexes.zones || {});
|
1228
|
+
if (_zones[action.zone]) {
|
1229
|
+
zoneCache[action.zone] = _zones[action.zone];
|
1230
|
+
delete _zones[action.zone];
|
774
1231
|
}
|
775
|
-
|
1232
|
+
delete zoneIndex[action.zone];
|
1233
|
+
return __spreadProps(__spreadValues({}, state), {
|
1234
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
1235
|
+
zones: _zones
|
1236
|
+
}),
|
1237
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1238
|
+
zones: zoneIndex
|
1239
|
+
})
|
1240
|
+
});
|
776
1241
|
}
|
777
1242
|
|
778
|
-
// ../core/reducer/
|
1243
|
+
// ../core/reducer/actions/set-data.ts
|
779
1244
|
init_react_import();
|
780
|
-
var
|
781
|
-
if (action.
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
return
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
1245
|
+
var setDataAction = (state, action, appStore) => {
|
1246
|
+
if (typeof action.data === "object") {
|
1247
|
+
console.warn(
|
1248
|
+
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1249
|
+
);
|
1250
|
+
return walkAppState(
|
1251
|
+
__spreadProps(__spreadValues({}, state), {
|
1252
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
1253
|
+
}),
|
1254
|
+
appStore.config
|
1255
|
+
);
|
791
1256
|
}
|
792
|
-
|
793
|
-
|
794
|
-
|
1257
|
+
return walkAppState(
|
1258
|
+
__spreadProps(__spreadValues({}, state), {
|
1259
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
1260
|
+
}),
|
1261
|
+
appStore.config
|
1262
|
+
);
|
1263
|
+
};
|
1264
|
+
|
1265
|
+
// ../core/reducer/actions/set-ui.ts
|
1266
|
+
init_react_import();
|
1267
|
+
var setUiAction = (state, action) => {
|
1268
|
+
if (typeof action.ui === "object") {
|
1269
|
+
return __spreadProps(__spreadValues({}, state), {
|
1270
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
|
795
1271
|
});
|
796
1272
|
}
|
797
|
-
return
|
1273
|
+
return __spreadProps(__spreadValues({}, state), {
|
1274
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
|
1275
|
+
});
|
1276
|
+
};
|
1277
|
+
|
1278
|
+
// ../core/lib/data/make-state-public.ts
|
1279
|
+
init_react_import();
|
1280
|
+
var makeStatePublic = (state) => {
|
1281
|
+
const { data, ui } = state;
|
1282
|
+
return { data, ui };
|
798
1283
|
};
|
799
1284
|
|
800
1285
|
// ../core/reducer/actions.tsx
|
@@ -814,29 +1299,54 @@ function storeInterceptor(reducer, record, onAction) {
|
|
814
1299
|
if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
|
815
1300
|
if (record) record(newAppState);
|
816
1301
|
}
|
817
|
-
onAction == null ? void 0 : onAction(action, newAppState, state);
|
1302
|
+
onAction == null ? void 0 : onAction(action, makeStatePublic(newAppState), makeStatePublic(state));
|
818
1303
|
return newAppState;
|
819
1304
|
};
|
820
1305
|
}
|
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
1306
|
function createReducer({
|
828
|
-
config,
|
829
1307
|
record,
|
830
|
-
onAction
|
1308
|
+
onAction,
|
1309
|
+
appStore
|
831
1310
|
}) {
|
832
1311
|
return storeInterceptor(
|
833
1312
|
(state, action) => {
|
834
|
-
const data = reduceData(state.data, action, config);
|
835
|
-
const ui = reduceUi(state.ui, action);
|
836
1313
|
if (action.type === "set") {
|
837
|
-
return setAction(state, action);
|
1314
|
+
return setAction(state, action, appStore);
|
1315
|
+
}
|
1316
|
+
if (action.type === "insert") {
|
1317
|
+
return insertAction(state, action, appStore);
|
1318
|
+
}
|
1319
|
+
if (action.type === "replace") {
|
1320
|
+
return replaceAction(state, action, appStore);
|
1321
|
+
}
|
1322
|
+
if (action.type === "replaceRoot") {
|
1323
|
+
return replaceRootAction(state, action, appStore);
|
1324
|
+
}
|
1325
|
+
if (action.type === "duplicate") {
|
1326
|
+
return duplicateAction(state, action, appStore);
|
1327
|
+
}
|
1328
|
+
if (action.type === "reorder") {
|
1329
|
+
return reorderAction(state, action, appStore);
|
1330
|
+
}
|
1331
|
+
if (action.type === "move") {
|
1332
|
+
return moveAction(state, action, appStore);
|
1333
|
+
}
|
1334
|
+
if (action.type === "remove") {
|
1335
|
+
return removeAction(state, action, appStore);
|
838
1336
|
}
|
839
|
-
|
1337
|
+
if (action.type === "registerZone") {
|
1338
|
+
return registerZoneAction(state, action);
|
1339
|
+
}
|
1340
|
+
if (action.type === "unregisterZone") {
|
1341
|
+
return unregisterZoneAction(state, action);
|
1342
|
+
}
|
1343
|
+
if (action.type === "setData") {
|
1344
|
+
return setDataAction(state, action, appStore);
|
1345
|
+
}
|
1346
|
+
if (action.type === "setUi") {
|
1347
|
+
return setUiAction(state, action);
|
1348
|
+
}
|
1349
|
+
return state;
|
840
1350
|
},
|
841
1351
|
record,
|
842
1352
|
onAction
|
@@ -856,11 +1366,11 @@ init_react_import();
|
|
856
1366
|
var createStoreImpl = (createState) => {
|
857
1367
|
let state;
|
858
1368
|
const listeners = /* @__PURE__ */ new Set();
|
859
|
-
const setState = (partial,
|
1369
|
+
const setState = (partial, replace) => {
|
860
1370
|
const nextState = typeof partial === "function" ? partial(state) : partial;
|
861
1371
|
if (!Object.is(nextState, state)) {
|
862
1372
|
const previousState = state;
|
863
|
-
state = (
|
1373
|
+
state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
|
864
1374
|
listeners.forEach((listener) => listener(state, previousState));
|
865
1375
|
}
|
866
1376
|
};
|
@@ -924,206 +1434,6 @@ var subscribeWithSelectorImpl = (fn) => (set, get, api) => {
|
|
924
1434
|
};
|
925
1435
|
var subscribeWithSelector = subscribeWithSelectorImpl;
|
926
1436
|
|
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
1437
|
// ../core/store/index.ts
|
1128
1438
|
import { createContext, useContext } from "react";
|
1129
1439
|
|
@@ -1231,7 +1541,7 @@ var createHistorySlice = (set, get) => {
|
|
1231
1541
|
const { dispatch, history } = get();
|
1232
1542
|
dispatch({
|
1233
1543
|
type: "set",
|
1234
|
-
state: ((_a = history.histories[
|
1544
|
+
state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
|
1235
1545
|
});
|
1236
1546
|
set({ history: __spreadProps(__spreadValues({}, history), { index }) });
|
1237
1547
|
},
|
@@ -1241,31 +1551,18 @@ var createHistorySlice = (set, get) => {
|
|
1241
1551
|
|
1242
1552
|
// ../core/store/slices/nodes.ts
|
1243
1553
|
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
1554
|
var createNodesSlice = (set, get) => ({
|
1254
1555
|
nodes: {},
|
1255
1556
|
registerNode: (id, node) => {
|
1256
1557
|
const s = get().nodes;
|
1257
|
-
if (s.nodes[id] && partialDeepEqual(node, s.nodes[id])) {
|
1258
|
-
return;
|
1259
|
-
}
|
1260
1558
|
const emptyNode = {
|
1261
1559
|
id,
|
1262
|
-
methods: {
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
element: null
|
1268
|
-
index: -1
|
1560
|
+
methods: {
|
1561
|
+
sync: () => null,
|
1562
|
+
hideOverlay: () => null,
|
1563
|
+
showOverlay: () => null
|
1564
|
+
},
|
1565
|
+
element: null
|
1269
1566
|
};
|
1270
1567
|
const existingNode = s.nodes[id];
|
1271
1568
|
set({
|
@@ -1295,36 +1592,61 @@ var createNodesSlice = (set, get) => ({
|
|
1295
1592
|
|
1296
1593
|
// ../core/store/slices/permissions.ts
|
1297
1594
|
init_react_import();
|
1298
|
-
import { useEffect as
|
1595
|
+
import { useEffect as useEffect3 } from "react";
|
1596
|
+
|
1597
|
+
// ../core/lib/data/flatten-data.ts
|
1598
|
+
init_react_import();
|
1599
|
+
var flattenData = (state, config) => {
|
1600
|
+
const data = [];
|
1601
|
+
walkAppState(
|
1602
|
+
state,
|
1603
|
+
config,
|
1604
|
+
(content) => content,
|
1605
|
+
(item) => {
|
1606
|
+
data.push(item);
|
1607
|
+
return null;
|
1608
|
+
}
|
1609
|
+
);
|
1610
|
+
return data;
|
1611
|
+
};
|
1612
|
+
|
1613
|
+
// ../core/lib/get-changed.ts
|
1614
|
+
init_react_import();
|
1615
|
+
var getChanged = (newItem, oldItem) => {
|
1616
|
+
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
1617
|
+
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
1618
|
+
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
1619
|
+
return __spreadProps(__spreadValues({}, acc), {
|
1620
|
+
[item]: oldItemProps[item] !== newItemProps[item]
|
1621
|
+
});
|
1622
|
+
}, {}) : {};
|
1623
|
+
};
|
1624
|
+
|
1625
|
+
// ../core/store/slices/permissions.ts
|
1299
1626
|
var createPermissionsSlice = (set, get) => {
|
1300
1627
|
const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
|
1301
|
-
const { state, permissions } = get();
|
1302
|
-
const { cache:
|
1628
|
+
const { state, permissions, config } = get();
|
1629
|
+
const { cache: cache2, globalPermissions } = permissions;
|
1303
1630
|
const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
|
1304
1631
|
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];
|
1632
|
+
const { config: config2, state: appState, setComponentLoading } = get();
|
1633
|
+
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
1312
1634
|
if (!componentConfig) {
|
1313
1635
|
return;
|
1314
1636
|
}
|
1315
1637
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
1316
1638
|
if (componentConfig.resolvePermissions) {
|
1317
|
-
const changed = getChanged(item2, (_a =
|
1639
|
+
const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
|
1318
1640
|
if (Object.values(changed).some((el) => el === true) || force2) {
|
1319
|
-
setComponentLoading(item2.props.id);
|
1641
|
+
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
1320
1642
|
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
1321
1643
|
item2,
|
1322
1644
|
{
|
1323
1645
|
changed,
|
1324
|
-
lastPermissions: ((_b =
|
1646
|
+
lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
|
1325
1647
|
permissions: initialPermissions,
|
1326
|
-
appState,
|
1327
|
-
lastData: ((_c =
|
1648
|
+
appState: makeStatePublic(appState),
|
1649
|
+
lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
|
1328
1650
|
}
|
1329
1651
|
);
|
1330
1652
|
const latest = get().permissions;
|
@@ -1341,7 +1663,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1341
1663
|
})
|
1342
1664
|
})
|
1343
1665
|
});
|
1344
|
-
|
1666
|
+
clearTimeout2();
|
1345
1667
|
}
|
1346
1668
|
}
|
1347
1669
|
});
|
@@ -1351,7 +1673,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1351
1673
|
// Shim the root data in by conforming to component data shape
|
1352
1674
|
{
|
1353
1675
|
type: "root",
|
1354
|
-
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "
|
1676
|
+
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "root" })
|
1355
1677
|
},
|
1356
1678
|
force2
|
1357
1679
|
);
|
@@ -1360,14 +1682,13 @@ var createPermissionsSlice = (set, get) => {
|
|
1360
1682
|
if (item) {
|
1361
1683
|
yield resolveDataForItem(item, force);
|
1362
1684
|
} else if (type) {
|
1363
|
-
flattenData(state
|
1685
|
+
flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(void 0, null, function* () {
|
1364
1686
|
yield resolveDataForItem(item2, force);
|
1365
1687
|
}));
|
1366
1688
|
} else if (root) {
|
1367
1689
|
resolveDataForRoot(force);
|
1368
1690
|
} else {
|
1369
|
-
|
1370
|
-
flattenData(state.data).map((item2) => __async(void 0, null, function* () {
|
1691
|
+
flattenData(state, config).map((item2) => __async(void 0, null, function* () {
|
1371
1692
|
yield resolveDataForItem(item2, force);
|
1372
1693
|
}));
|
1373
1694
|
}
|
@@ -1397,7 +1718,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1397
1718
|
} else if (root) {
|
1398
1719
|
const rootConfig = config.root;
|
1399
1720
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
|
1400
|
-
const resolvedForItem = resolvedPermissions["
|
1721
|
+
const resolvedForItem = resolvedPermissions["root"];
|
1401
1722
|
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
1402
1723
|
}
|
1403
1724
|
return globalPermissions;
|
@@ -1409,16 +1730,99 @@ var createPermissionsSlice = (set, get) => {
|
|
1409
1730
|
|
1410
1731
|
// ../core/store/slices/fields.ts
|
1411
1732
|
init_react_import();
|
1412
|
-
import { useCallback, useEffect as
|
1413
|
-
var
|
1733
|
+
import { useCallback, useEffect as useEffect4 } from "react";
|
1734
|
+
var createFieldsSlice = (_set, _get) => {
|
1414
1735
|
return {
|
1415
1736
|
fields: {},
|
1416
1737
|
loading: false,
|
1417
|
-
lastResolvedData: {}
|
1738
|
+
lastResolvedData: {},
|
1739
|
+
id: void 0
|
1418
1740
|
};
|
1419
1741
|
};
|
1420
1742
|
|
1421
|
-
// ../core/
|
1743
|
+
// ../core/lib/resolve-component-data.ts
|
1744
|
+
init_react_import();
|
1745
|
+
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1746
|
+
var cache = { lastChange: {} };
|
1747
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
|
1748
|
+
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
1749
|
+
if ((configForItem == null ? void 0 : configForItem.resolveData) && item.props) {
|
1750
|
+
const id = "id" in item.props ? item.props.id : "root";
|
1751
|
+
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
1752
|
+
if (item && (0, import_fast_deep_equal.default)(item, oldItem)) {
|
1753
|
+
return { node: resolved, didChange: false };
|
1754
|
+
}
|
1755
|
+
const changed = getChanged(item, oldItem);
|
1756
|
+
if (onResolveStart) {
|
1757
|
+
onResolveStart(item);
|
1758
|
+
}
|
1759
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
1760
|
+
changed,
|
1761
|
+
lastData: oldItem,
|
1762
|
+
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
1763
|
+
trigger
|
1764
|
+
});
|
1765
|
+
let resolvedItem = __spreadProps(__spreadValues({}, item), {
|
1766
|
+
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
1767
|
+
});
|
1768
|
+
if (recursive) {
|
1769
|
+
resolvedItem = yield mapSlotsAsync(
|
1770
|
+
resolvedItem,
|
1771
|
+
(content) => __async(void 0, null, function* () {
|
1772
|
+
return Promise.all(
|
1773
|
+
content.map(
|
1774
|
+
(childItem) => __async(void 0, null, function* () {
|
1775
|
+
return (yield resolveComponentData(
|
1776
|
+
childItem,
|
1777
|
+
config,
|
1778
|
+
metadata,
|
1779
|
+
onResolveStart,
|
1780
|
+
onResolveEnd,
|
1781
|
+
trigger,
|
1782
|
+
false
|
1783
|
+
)).node;
|
1784
|
+
})
|
1785
|
+
)
|
1786
|
+
);
|
1787
|
+
}),
|
1788
|
+
false,
|
1789
|
+
createIsSlotConfig(config)
|
1790
|
+
);
|
1791
|
+
}
|
1792
|
+
if (Object.keys(readOnly).length) {
|
1793
|
+
resolvedItem.readOnly = readOnly;
|
1794
|
+
}
|
1795
|
+
cache.lastChange[id] = {
|
1796
|
+
item,
|
1797
|
+
resolved: resolvedItem
|
1798
|
+
};
|
1799
|
+
if (onResolveEnd) {
|
1800
|
+
onResolveEnd(resolvedItem);
|
1801
|
+
}
|
1802
|
+
return { node: resolvedItem, didChange: !(0, import_fast_deep_equal.default)(item, resolvedItem) };
|
1803
|
+
}
|
1804
|
+
return { node: item, didChange: false };
|
1805
|
+
});
|
1806
|
+
|
1807
|
+
// ../core/lib/data/to-root.ts
|
1808
|
+
init_react_import();
|
1809
|
+
var toRoot = (item) => {
|
1810
|
+
if ("type" in item && item.type !== "root") {
|
1811
|
+
throw new Error("Converting non-root item to root.");
|
1812
|
+
}
|
1813
|
+
const { readOnly } = item;
|
1814
|
+
if (item.props) {
|
1815
|
+
if ("id" in item.props) {
|
1816
|
+
const _a = item.props, { id } = _a, props = __objRest(_a, ["id"]);
|
1817
|
+
return { props, readOnly };
|
1818
|
+
}
|
1819
|
+
return { props: item.props, readOnly };
|
1820
|
+
}
|
1821
|
+
return { props: {}, readOnly };
|
1822
|
+
};
|
1823
|
+
|
1824
|
+
// ../core/store/default-app-state.ts
|
1825
|
+
init_react_import();
|
1422
1826
|
var defaultAppState = {
|
1423
1827
|
data: { content: [], root: {}, zones: {} },
|
1424
1828
|
ui: {
|
@@ -1438,92 +1842,188 @@ var defaultAppState = {
|
|
1438
1842
|
controlsVisible: true
|
1439
1843
|
},
|
1440
1844
|
field: { focus: null }
|
1845
|
+
},
|
1846
|
+
indexes: {
|
1847
|
+
nodes: {},
|
1848
|
+
zones: {}
|
1441
1849
|
}
|
1442
1850
|
};
|
1851
|
+
|
1852
|
+
// ../core/store/index.ts
|
1443
1853
|
var defaultPageFields = {
|
1444
1854
|
title: { type: "text" }
|
1445
1855
|
};
|
1446
1856
|
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
|
-
|
1857
|
+
subscribeWithSelector((set, get) => {
|
1858
|
+
var _a, _b;
|
1859
|
+
return __spreadProps(__spreadValues({
|
1860
|
+
state: defaultAppState,
|
1861
|
+
config: { components: {} },
|
1862
|
+
componentState: {},
|
1863
|
+
plugins: [],
|
1864
|
+
overrides: {},
|
1865
|
+
viewports: defaultViewports,
|
1866
|
+
zoomConfig: {
|
1867
|
+
autoZoom: 1,
|
1868
|
+
rootHeight: 0,
|
1869
|
+
zoom: 1
|
1870
|
+
},
|
1871
|
+
status: "LOADING",
|
1872
|
+
iframe: {},
|
1873
|
+
metadata: {}
|
1874
|
+
}, initialAppStore), {
|
1875
|
+
fields: createFieldsSlice(set, get),
|
1876
|
+
history: createHistorySlice(set, get),
|
1877
|
+
nodes: createNodesSlice(set, get),
|
1878
|
+
permissions: createPermissionsSlice(set, get),
|
1879
|
+
getComponentConfig: (type) => {
|
1880
|
+
var _a2;
|
1881
|
+
const { config, selectedItem } = get();
|
1882
|
+
const rootFields = ((_a2 = config.root) == null ? void 0 : _a2.fields) || defaultPageFields;
|
1883
|
+
return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
|
1884
|
+
},
|
1885
|
+
selectedItem: ((_a = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _a.ui.itemSelector) ? getItem(
|
1886
|
+
(_b = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _b.ui.itemSelector,
|
1887
|
+
initialAppStore.state
|
1888
|
+
) : null,
|
1889
|
+
dispatch: (action) => set((s) => {
|
1890
|
+
var _a2, _b2;
|
1891
|
+
const { record } = get().history;
|
1892
|
+
const dispatch = createReducer({
|
1893
|
+
record,
|
1894
|
+
appStore: s
|
1895
|
+
});
|
1896
|
+
const state = dispatch(s.state, action);
|
1897
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1898
|
+
(_b2 = (_a2 = get()).onAction) == null ? void 0 : _b2.call(_a2, action, state, get().state);
|
1899
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1900
|
+
}),
|
1901
|
+
setZoomConfig: (zoomConfig) => set({ zoomConfig }),
|
1902
|
+
setStatus: (status) => set({ status }),
|
1903
|
+
setComponentState: (componentState) => set({ componentState }),
|
1904
|
+
pendingLoadTimeouts: {},
|
1905
|
+
setComponentLoading: (id, loading = true, defer = 0) => {
|
1906
|
+
const { setComponentState, pendingLoadTimeouts } = get();
|
1907
|
+
const loadId = generateId();
|
1908
|
+
const setLoading = () => {
|
1909
|
+
var _a2;
|
1910
|
+
const { componentState } = get();
|
1911
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1912
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1913
|
+
loadingCount: (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) + 1
|
1914
|
+
})
|
1915
|
+
}));
|
1916
|
+
};
|
1917
|
+
const unsetLoading = () => {
|
1918
|
+
var _a2;
|
1919
|
+
const { componentState } = get();
|
1920
|
+
clearTimeout(timeout);
|
1921
|
+
delete pendingLoadTimeouts[loadId];
|
1922
|
+
set({ pendingLoadTimeouts });
|
1923
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1924
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1925
|
+
loadingCount: Math.max(
|
1926
|
+
(((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) - 1,
|
1927
|
+
0
|
1928
|
+
)
|
1929
|
+
})
|
1930
|
+
}));
|
1931
|
+
};
|
1932
|
+
const timeout = setTimeout(() => {
|
1933
|
+
if (loading) {
|
1934
|
+
setLoading();
|
1935
|
+
} else {
|
1936
|
+
unsetLoading();
|
1937
|
+
}
|
1938
|
+
delete pendingLoadTimeouts[loadId];
|
1939
|
+
set({ pendingLoadTimeouts });
|
1940
|
+
}, defer);
|
1941
|
+
set({
|
1942
|
+
pendingLoadTimeouts: __spreadProps(__spreadValues({}, pendingLoadTimeouts), {
|
1943
|
+
[id]: timeout
|
1944
|
+
})
|
1945
|
+
});
|
1946
|
+
return unsetLoading;
|
1947
|
+
},
|
1948
|
+
unsetComponentLoading: (id) => {
|
1949
|
+
const { setComponentLoading } = get();
|
1950
|
+
setComponentLoading(id, false);
|
1951
|
+
},
|
1952
|
+
// Helper
|
1953
|
+
setUi: (ui, recordHistory) => set((s) => {
|
1954
|
+
const dispatch = createReducer({
|
1955
|
+
record: () => {
|
1956
|
+
},
|
1957
|
+
appStore: s
|
1958
|
+
});
|
1959
|
+
const state = dispatch(s.state, {
|
1960
|
+
type: "setUi",
|
1961
|
+
ui,
|
1962
|
+
recordHistory
|
1963
|
+
});
|
1964
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1965
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1966
|
+
}),
|
1967
|
+
resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
|
1968
|
+
const { config, metadata, setComponentLoading, permissions } = get();
|
1969
|
+
const timeouts = {};
|
1970
|
+
return yield resolveComponentData(
|
1971
|
+
componentData,
|
1972
|
+
config,
|
1973
|
+
metadata,
|
1974
|
+
(item) => {
|
1975
|
+
const id = "id" in item.props ? item.props.id : "root";
|
1976
|
+
timeouts[id] = setComponentLoading(id, true, 50);
|
1977
|
+
},
|
1978
|
+
(item) => __async(void 0, null, function* () {
|
1979
|
+
const id = "id" in item.props ? item.props.id : "root";
|
1980
|
+
if ("type" in item) {
|
1981
|
+
yield permissions.refreshPermissions({ item });
|
1982
|
+
} else {
|
1983
|
+
yield permissions.refreshPermissions({ root: true });
|
1984
|
+
}
|
1985
|
+
timeouts[id]();
|
1986
|
+
}),
|
1987
|
+
trigger
|
1988
|
+
);
|
1989
|
+
}),
|
1990
|
+
resolveAndCommitData: () => __async(void 0, null, function* () {
|
1991
|
+
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
1992
|
+
walkAppState(
|
1993
|
+
state,
|
1994
|
+
config,
|
1995
|
+
(content) => content,
|
1996
|
+
(childItem) => {
|
1997
|
+
resolveComponentData2(childItem, "load").then((resolved) => {
|
1998
|
+
const { state: state2 } = get();
|
1999
|
+
const node = state2.indexes.nodes[resolved.node.props.id];
|
2000
|
+
if (node && resolved.didChange) {
|
2001
|
+
if (resolved.node.props.id === "root") {
|
2002
|
+
dispatch({
|
2003
|
+
type: "replaceRoot",
|
2004
|
+
root: toRoot(resolved.node)
|
2005
|
+
});
|
2006
|
+
} else {
|
2007
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
2008
|
+
const parentZone = state2.indexes.zones[zoneCompound];
|
2009
|
+
const index = parentZone.contentIds.indexOf(
|
2010
|
+
resolved.node.props.id
|
2011
|
+
);
|
2012
|
+
dispatch({
|
2013
|
+
type: "replace",
|
2014
|
+
data: resolved.node,
|
2015
|
+
destinationIndex: index,
|
2016
|
+
destinationZone: zoneCompound
|
2017
|
+
});
|
2018
|
+
}
|
2019
|
+
}
|
2020
|
+
});
|
2021
|
+
return childItem;
|
2022
|
+
}
|
2023
|
+
);
|
2024
|
+
})
|
2025
|
+
});
|
2026
|
+
})
|
1527
2027
|
);
|
1528
2028
|
var appStoreContext = createContext(createAppStore());
|
1529
2029
|
function useAppStore(selector) {
|
@@ -1543,12 +2043,12 @@ var useBreadcrumbs = (renderCount) => {
|
|
1543
2043
|
const config = useAppStore((s) => s.config);
|
1544
2044
|
const path = useAppStore((s) => {
|
1545
2045
|
var _a;
|
1546
|
-
return (_a = s.
|
2046
|
+
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
1547
2047
|
});
|
1548
2048
|
const appStore = useAppStoreApi();
|
1549
2049
|
return useMemo(() => {
|
1550
2050
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
1551
|
-
var _a, _b;
|
2051
|
+
var _a, _b, _c;
|
1552
2052
|
const [componentId] = zoneCompound.split(":");
|
1553
2053
|
if (componentId === "root") {
|
1554
2054
|
return {
|
@@ -1556,12 +2056,15 @@ var useBreadcrumbs = (renderCount) => {
|
|
1556
2056
|
selector: null
|
1557
2057
|
};
|
1558
2058
|
}
|
1559
|
-
const node = appStore.getState().
|
1560
|
-
const
|
2059
|
+
const node = appStore.getState().state.indexes.nodes[componentId];
|
2060
|
+
const parentId = node.path[node.path.length - 1];
|
2061
|
+
const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
|
2062
|
+
const index = contentIds.indexOf(componentId);
|
2063
|
+
const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
|
1561
2064
|
return {
|
1562
2065
|
label,
|
1563
2066
|
selector: node ? {
|
1564
|
-
index
|
2067
|
+
index,
|
1565
2068
|
zone: node.path[node.path.length - 1]
|
1566
2069
|
} : null
|
1567
2070
|
};
|
@@ -1582,6 +2085,12 @@ init_react_import();
|
|
1582
2085
|
// ../core/lib/filter.ts
|
1583
2086
|
init_react_import();
|
1584
2087
|
|
2088
|
+
// ../core/lib/data/reorder.ts
|
2089
|
+
init_react_import();
|
2090
|
+
|
2091
|
+
// ../core/lib/data/replace.ts
|
2092
|
+
init_react_import();
|
2093
|
+
|
1585
2094
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
|
1586
2095
|
init_react_import();
|
1587
2096
|
var styles_module_default3 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
|
@@ -1763,17 +2272,39 @@ var usePuck = createUsePuck();
|
|
1763
2272
|
var HeadingAnalyzer = () => {
|
1764
2273
|
const data = usePuck((s) => s.appState.data);
|
1765
2274
|
const [hierarchy, setHierarchy] = useState([]);
|
1766
|
-
|
2275
|
+
useEffect5(() => {
|
1767
2276
|
const frame = getFrame();
|
1768
|
-
|
1769
|
-
|
1770
|
-
setHierarchy(buildHierarchy(entry));
|
1771
|
-
const observer = new MutationObserver(() => {
|
2277
|
+
let entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
2278
|
+
const createHierarchy = () => {
|
1772
2279
|
setHierarchy(buildHierarchy(entry));
|
2280
|
+
};
|
2281
|
+
const entryObserver = new MutationObserver(() => {
|
2282
|
+
createHierarchy();
|
2283
|
+
});
|
2284
|
+
const frameObserver = new MutationObserver(() => {
|
2285
|
+
entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
2286
|
+
if (entry) {
|
2287
|
+
registerEntryObserver();
|
2288
|
+
frameObserver.disconnect();
|
2289
|
+
}
|
1773
2290
|
});
|
1774
|
-
|
2291
|
+
const registerEntryObserver = () => {
|
2292
|
+
if (!entry) return;
|
2293
|
+
entryObserver.observe(entry, { subtree: true, childList: true });
|
2294
|
+
};
|
2295
|
+
const registerFrameObserver = () => {
|
2296
|
+
if (!frame) return;
|
2297
|
+
frameObserver.observe(frame, { subtree: true, childList: true });
|
2298
|
+
};
|
2299
|
+
if (entry) {
|
2300
|
+
createHierarchy();
|
2301
|
+
registerEntryObserver();
|
2302
|
+
} else {
|
2303
|
+
registerFrameObserver();
|
2304
|
+
}
|
1775
2305
|
return () => {
|
1776
|
-
|
2306
|
+
entryObserver.disconnect();
|
2307
|
+
frameObserver.disconnect();
|
1777
2308
|
};
|
1778
2309
|
}, [data]);
|
1779
2310
|
return /* @__PURE__ */ jsxs2("div", { className: getClassName5(), children: [
|