@measured/puck-plugin-heading-analyzer 0.19.0-canary.d9be813b → 0.19.0-canary.db75e42b
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 +18 -9
- package/dist/index.d.ts +18 -9
- package/dist/index.js +1042 -709
- package/dist/index.mjs +1042 -709
- 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) {
|
@@ -356,35 +470,16 @@ 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
|
363
477
|
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
478
|
|
371
|
-
// ../core/lib/
|
479
|
+
// ../core/lib/data/for-related-zones.ts
|
372
480
|
init_react_import();
|
373
|
-
var insert = (list, index, item) => {
|
374
|
-
const result = Array.from(list || []);
|
375
|
-
result.splice(index, 0, item);
|
376
|
-
return result;
|
377
|
-
};
|
378
481
|
|
379
|
-
// ../core/lib/
|
380
|
-
init_react_import();
|
381
|
-
var remove = (list, index) => {
|
382
|
-
const result = Array.from(list);
|
383
|
-
result.splice(index, 1);
|
384
|
-
return result;
|
385
|
-
};
|
386
|
-
|
387
|
-
// ../core/lib/setup-zone.ts
|
482
|
+
// ../core/lib/get-zone-id.ts
|
388
483
|
init_react_import();
|
389
484
|
|
390
485
|
// ../core/lib/root-droppable-id.ts
|
@@ -393,127 +488,7 @@ var rootAreaId = "root";
|
|
393
488
|
var rootZone = "default-zone";
|
394
489
|
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
395
490
|
|
396
|
-
// ../core/lib/setup-zone.ts
|
397
|
-
var setupZone = (data, zoneKey) => {
|
398
|
-
if (zoneKey === rootDroppableId) {
|
399
|
-
return data;
|
400
|
-
}
|
401
|
-
const newData = __spreadProps(__spreadValues({}, data), {
|
402
|
-
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
403
|
-
});
|
404
|
-
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
405
|
-
return newData;
|
406
|
-
};
|
407
|
-
|
408
|
-
// ../core/lib/get-item.ts
|
409
|
-
init_react_import();
|
410
|
-
function getItem(selector, state) {
|
411
|
-
var _a, _b;
|
412
|
-
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
413
|
-
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
414
|
-
}
|
415
|
-
|
416
|
-
// ../core/lib/generate-id.ts
|
417
|
-
init_react_import();
|
418
|
-
|
419
|
-
// ../../node_modules/uuid/dist/esm-node/index.js
|
420
|
-
init_react_import();
|
421
|
-
|
422
|
-
// ../../node_modules/uuid/dist/esm-node/rng.js
|
423
|
-
init_react_import();
|
424
|
-
import crypto from "crypto";
|
425
|
-
var rnds8Pool = new Uint8Array(256);
|
426
|
-
var poolPtr = rnds8Pool.length;
|
427
|
-
function rng() {
|
428
|
-
if (poolPtr > rnds8Pool.length - 16) {
|
429
|
-
crypto.randomFillSync(rnds8Pool);
|
430
|
-
poolPtr = 0;
|
431
|
-
}
|
432
|
-
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
433
|
-
}
|
434
|
-
|
435
|
-
// ../../node_modules/uuid/dist/esm-node/stringify.js
|
436
|
-
init_react_import();
|
437
|
-
var byteToHex = [];
|
438
|
-
for (let i = 0; i < 256; ++i) {
|
439
|
-
byteToHex.push((i + 256).toString(16).slice(1));
|
440
|
-
}
|
441
|
-
function unsafeStringify(arr, offset = 0) {
|
442
|
-
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
443
|
-
}
|
444
|
-
|
445
|
-
// ../../node_modules/uuid/dist/esm-node/v4.js
|
446
|
-
init_react_import();
|
447
|
-
|
448
|
-
// ../../node_modules/uuid/dist/esm-node/native.js
|
449
|
-
init_react_import();
|
450
|
-
import crypto2 from "crypto";
|
451
|
-
var native_default = {
|
452
|
-
randomUUID: crypto2.randomUUID
|
453
|
-
};
|
454
|
-
|
455
|
-
// ../../node_modules/uuid/dist/esm-node/v4.js
|
456
|
-
function v4(options, buf, offset) {
|
457
|
-
if (native_default.randomUUID && !buf && !options) {
|
458
|
-
return native_default.randomUUID();
|
459
|
-
}
|
460
|
-
options = options || {};
|
461
|
-
const rnds = options.random || (options.rng || rng)();
|
462
|
-
rnds[6] = rnds[6] & 15 | 64;
|
463
|
-
rnds[8] = rnds[8] & 63 | 128;
|
464
|
-
if (buf) {
|
465
|
-
offset = offset || 0;
|
466
|
-
for (let i = 0; i < 16; ++i) {
|
467
|
-
buf[offset + i] = rnds[i];
|
468
|
-
}
|
469
|
-
return buf;
|
470
|
-
}
|
471
|
-
return unsafeStringify(rnds);
|
472
|
-
}
|
473
|
-
var v4_default = v4;
|
474
|
-
|
475
|
-
// ../core/lib/generate-id.ts
|
476
|
-
var generateId = (type) => type ? `${type}-${v4_default()}` : v4_default();
|
477
|
-
|
478
|
-
// ../core/lib/walk-tree.ts
|
479
|
-
init_react_import();
|
480
|
-
|
481
|
-
// ../core/lib/for-each-slot.ts
|
482
|
-
init_react_import();
|
483
|
-
|
484
|
-
// ../core/lib/is-slot.ts
|
485
|
-
init_react_import();
|
486
|
-
var isSlot = (prop) => {
|
487
|
-
var _a, _b;
|
488
|
-
return Array.isArray(prop) && typeof ((_a = prop[0]) == null ? void 0 : _a.type) === "string" && typeof ((_b = prop[0]) == null ? void 0 : _b.props) === "object";
|
489
|
-
};
|
490
|
-
|
491
|
-
// ../core/lib/for-each-slot.ts
|
492
|
-
var forEachSlot = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, cb, recursive = false, isSlot2 = isSlot) {
|
493
|
-
const props = item.props || {};
|
494
|
-
const propKeys = Object.keys(props);
|
495
|
-
for (let i = 0; i < propKeys.length; i++) {
|
496
|
-
const propKey = propKeys[i];
|
497
|
-
const itemType = "type" in item ? item.type : "root";
|
498
|
-
if (isSlot2(itemType, propKey, props[propKey])) {
|
499
|
-
const content = props[propKey];
|
500
|
-
yield cb(props.id, propKey, content);
|
501
|
-
if (recursive) {
|
502
|
-
content.forEach(
|
503
|
-
(childItem) => __async(void 0, null, function* () {
|
504
|
-
return yield forEachSlot(childItem, cb, true, isSlot2);
|
505
|
-
})
|
506
|
-
);
|
507
|
-
}
|
508
|
-
}
|
509
|
-
}
|
510
|
-
});
|
511
|
-
|
512
|
-
// ../core/lib/for-related-zones.ts
|
513
|
-
init_react_import();
|
514
|
-
|
515
491
|
// ../core/lib/get-zone-id.ts
|
516
|
-
init_react_import();
|
517
492
|
var getZoneId = (zoneCompound) => {
|
518
493
|
if (!zoneCompound) {
|
519
494
|
return [];
|
@@ -524,36 +499,169 @@ var getZoneId = (zoneCompound) => {
|
|
524
499
|
return [rootDroppableId, zoneCompound];
|
525
500
|
};
|
526
501
|
|
527
|
-
// ../core/lib/for-related-zones.ts
|
502
|
+
// ../core/lib/data/for-related-zones.ts
|
528
503
|
function forRelatedZones(item, data, cb, path = []) {
|
529
504
|
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
|
530
505
|
const [parentId] = getZoneId(zoneCompound);
|
531
506
|
if (parentId === item.props.id) {
|
532
|
-
const newPath = [...path, zoneCompound];
|
533
|
-
content.forEach((item2) => forRelatedZones(item2, data, cb, newPath));
|
534
507
|
cb(path, zoneCompound, content);
|
535
508
|
}
|
536
509
|
});
|
537
510
|
}
|
538
511
|
|
539
|
-
// ../core/lib/
|
512
|
+
// ../core/lib/data/map-slots.ts
|
540
513
|
init_react_import();
|
541
|
-
var
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
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);
|
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
|
+
}
|
645
|
+
|
646
|
+
// ../core/lib/data/flatten-node.ts
|
647
|
+
init_react_import();
|
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)
|
552
660
|
});
|
553
661
|
};
|
554
662
|
|
555
|
-
// ../core/lib/walk-
|
556
|
-
function
|
663
|
+
// ../core/lib/data/walk-app-state.ts
|
664
|
+
function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
557
665
|
var _a;
|
558
666
|
let newZones = {};
|
559
667
|
const newZoneIndex = {};
|
@@ -594,11 +702,9 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
594
702
|
const mappedItem = mapNodeOrSkip(item, path, index);
|
595
703
|
if (!mappedItem) return item;
|
596
704
|
const id = mappedItem.props.id;
|
597
|
-
|
598
|
-
const newProps = __spreadValues({}, mappedItem.props);
|
599
|
-
forEachSlot(
|
705
|
+
const newProps = __spreadProps(__spreadValues({}, mapSlots(
|
600
706
|
mappedItem,
|
601
|
-
(parentId2, slotId
|
707
|
+
(content, parentId2, slotId) => {
|
602
708
|
const zoneCompound = `${parentId2}:${slotId}`;
|
603
709
|
const [_2, newContent2] = processContent(
|
604
710
|
path,
|
@@ -607,27 +713,24 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
607
713
|
"slot",
|
608
714
|
parentId2
|
609
715
|
);
|
610
|
-
|
716
|
+
return newContent2;
|
611
717
|
},
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
return ((_b = (_a2 = configForComponent.fields) == null ? void 0 : _a2[propName]) == null ? void 0 : _b.type) === "slot";
|
618
|
-
}
|
619
|
-
);
|
718
|
+
config
|
719
|
+
).props), {
|
720
|
+
id
|
721
|
+
});
|
722
|
+
processRelatedZones(item, id, path);
|
620
723
|
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
|
621
724
|
const thisZoneCompound = path[path.length - 1];
|
622
725
|
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
623
726
|
newNodeIndex[id] = {
|
624
727
|
data: newItem,
|
625
|
-
flatData:
|
728
|
+
flatData: flattenNode(newItem, config),
|
626
729
|
path,
|
627
730
|
parentId,
|
628
731
|
zone
|
629
732
|
};
|
630
|
-
const finalData = newItem;
|
733
|
+
const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
|
631
734
|
if (newProps.id === "root") {
|
632
735
|
delete finalData["type"];
|
633
736
|
delete finalData.props["id"];
|
@@ -642,8 +745,12 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
642
745
|
"root"
|
643
746
|
);
|
644
747
|
const processedContent = newContent;
|
748
|
+
const zonesAlreadyProcessed = Object.keys(newZones);
|
645
749
|
Object.keys(zones || {}).forEach((zoneCompound) => {
|
646
750
|
const [parentId] = zoneCompound.split(":");
|
751
|
+
if (zonesAlreadyProcessed.includes(zoneCompound)) {
|
752
|
+
return;
|
753
|
+
}
|
647
754
|
const [_2, newContent2] = processContent(
|
648
755
|
[rootDroppableId],
|
649
756
|
zoneCompound,
|
@@ -667,7 +774,6 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
667
774
|
return __spreadProps(__spreadValues({}, state), {
|
668
775
|
data: {
|
669
776
|
root,
|
670
|
-
// root: state.data.root, // TODO changing root causes it's entire subtree to re-render. Let's keep this disabled until the performance issues are resolved in #644.
|
671
777
|
content: processedContent,
|
672
778
|
zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
|
673
779
|
},
|
@@ -678,59 +784,175 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
678
784
|
});
|
679
785
|
}
|
680
786
|
|
681
|
-
// ../core/
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
delete nodes[subItem.props.id];
|
691
|
-
});
|
692
|
-
delete zones[zoneCompound];
|
693
|
-
});
|
694
|
-
};
|
695
|
-
const dindexChildren = (item) => {
|
696
|
-
forEachSlot(
|
697
|
-
item,
|
698
|
-
(parentId, slotId, content) => {
|
699
|
-
const zoneCompound = `${parentId}:${slotId}`;
|
700
|
-
delete zones[zoneCompound];
|
701
|
-
content.forEach((item2) => {
|
702
|
-
dindexRelatedZones(item2);
|
703
|
-
delete nodes[item2.props.id];
|
704
|
-
});
|
705
|
-
},
|
706
|
-
true
|
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."
|
707
796
|
);
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
delete nodes[componentData.props.id];
|
712
|
-
return { nodes, zones };
|
797
|
+
return walkAppState(newState, appStore.config);
|
798
|
+
}
|
799
|
+
return __spreadValues(__spreadValues({}, state), action.state(state));
|
713
800
|
};
|
714
801
|
|
715
|
-
// ../core/reducer/
|
716
|
-
|
802
|
+
// ../core/reducer/actions/insert.ts
|
803
|
+
init_react_import();
|
804
|
+
|
805
|
+
// ../core/lib/data/insert.ts
|
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
|
+
};
|
812
|
+
|
813
|
+
// ../core/lib/generate-id.ts
|
814
|
+
init_react_import();
|
815
|
+
|
816
|
+
// ../../node_modules/uuid/dist/esm-node/index.js
|
817
|
+
init_react_import();
|
818
|
+
|
819
|
+
// ../../node_modules/uuid/dist/esm-node/rng.js
|
820
|
+
init_react_import();
|
821
|
+
import crypto from "crypto";
|
822
|
+
var rnds8Pool = new Uint8Array(256);
|
823
|
+
var poolPtr = rnds8Pool.length;
|
824
|
+
function rng() {
|
825
|
+
if (poolPtr > rnds8Pool.length - 16) {
|
826
|
+
crypto.randomFillSync(rnds8Pool);
|
827
|
+
poolPtr = 0;
|
828
|
+
}
|
829
|
+
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
830
|
+
}
|
831
|
+
|
832
|
+
// ../../node_modules/uuid/dist/esm-node/stringify.js
|
833
|
+
init_react_import();
|
834
|
+
var byteToHex = [];
|
835
|
+
for (let i = 0; i < 256; ++i) {
|
836
|
+
byteToHex.push((i + 256).toString(16).slice(1));
|
837
|
+
}
|
838
|
+
function unsafeStringify(arr, offset = 0) {
|
839
|
+
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
840
|
+
}
|
841
|
+
|
842
|
+
// ../../node_modules/uuid/dist/esm-node/v4.js
|
843
|
+
init_react_import();
|
844
|
+
|
845
|
+
// ../../node_modules/uuid/dist/esm-node/native.js
|
846
|
+
init_react_import();
|
847
|
+
import crypto2 from "crypto";
|
848
|
+
var native_default = {
|
849
|
+
randomUUID: crypto2.randomUUID
|
850
|
+
};
|
851
|
+
|
852
|
+
// ../../node_modules/uuid/dist/esm-node/v4.js
|
853
|
+
function v4(options, buf, offset) {
|
854
|
+
if (native_default.randomUUID && !buf && !options) {
|
855
|
+
return native_default.randomUUID();
|
856
|
+
}
|
857
|
+
options = options || {};
|
858
|
+
const rnds = options.random || (options.rng || rng)();
|
859
|
+
rnds[6] = rnds[6] & 15 | 64;
|
860
|
+
rnds[8] = rnds[8] & 63 | 128;
|
861
|
+
if (buf) {
|
862
|
+
offset = offset || 0;
|
863
|
+
for (let i = 0; i < 16; ++i) {
|
864
|
+
buf[offset + i] = rnds[i];
|
865
|
+
}
|
866
|
+
return buf;
|
867
|
+
}
|
868
|
+
return unsafeStringify(rnds);
|
869
|
+
}
|
870
|
+
var v4_default = v4;
|
871
|
+
|
872
|
+
// ../core/lib/generate-id.ts
|
873
|
+
var generateId = (type) => type ? `${type}-${v4_default()}` : v4_default();
|
874
|
+
|
875
|
+
// ../core/lib/data/get-ids-for-parent.ts
|
876
|
+
init_react_import();
|
717
877
|
var getIdsForParent = (zoneCompound, state) => {
|
718
878
|
const [parentId] = zoneCompound.split(":");
|
719
879
|
const node = state.indexes.nodes[parentId];
|
720
880
|
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
|
721
881
|
};
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
882
|
+
|
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;
|
896
|
+
},
|
897
|
+
config,
|
898
|
+
true
|
899
|
+
);
|
729
900
|
};
|
730
|
-
|
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
|
+
}),
|
917
|
+
{}
|
918
|
+
)
|
919
|
+
};
|
920
|
+
}
|
921
|
+
|
922
|
+
// ../core/lib/data/populate-ids.ts
|
923
|
+
var populateIds = (data, config, override = false) => {
|
924
|
+
const id = generateId(data.type);
|
731
925
|
return walkTree(
|
732
|
-
|
926
|
+
__spreadProps(__spreadValues({}, data), {
|
927
|
+
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({}, data.props)
|
928
|
+
}),
|
733
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,
|
734
956
|
(content, zoneCompound) => {
|
735
957
|
if (zoneCompound === action.destinationZone) {
|
736
958
|
return insert(
|
@@ -741,279 +963,348 @@ function insertAction(state, action, config) {
|
|
741
963
|
}
|
742
964
|
return content;
|
743
965
|
},
|
744
|
-
(childItem) => {
|
966
|
+
(childItem, path) => {
|
745
967
|
if (childItem.props.id === id || childItem.props.id === parentId) {
|
746
968
|
return childItem;
|
969
|
+
} else if (idsInPath.includes(childItem.props.id)) {
|
970
|
+
return childItem;
|
971
|
+
} else if (path.includes(action.destinationZone)) {
|
972
|
+
return childItem;
|
747
973
|
}
|
748
974
|
return null;
|
749
975
|
}
|
750
976
|
);
|
751
977
|
}
|
752
|
-
|
753
|
-
|
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;
|
999
|
+
}
|
1000
|
+
return newContent;
|
1001
|
+
},
|
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
|
+
}
|
1015
|
+
);
|
1016
|
+
};
|
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
|
+
);
|
1035
|
+
};
|
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;
|
1046
|
+
}
|
1047
|
+
|
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)
|
1058
|
+
})
|
1059
|
+
});
|
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
|
+
}
|
1095
|
+
})
|
1096
|
+
});
|
1097
|
+
}
|
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;
|
1111
|
+
};
|
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;
|
1117
|
+
}
|
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(
|
754
1126
|
state,
|
755
1127
|
appStore.config,
|
756
1128
|
(content, zoneCompound) => {
|
757
|
-
if (zoneCompound === action.destinationZone) {
|
758
|
-
return
|
759
|
-
content
|
760
|
-
action.
|
761
|
-
|
1129
|
+
if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
|
1130
|
+
return insert(
|
1131
|
+
remove(content, action.sourceIndex),
|
1132
|
+
action.destinationIndex,
|
1133
|
+
item
|
762
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);
|
763
1139
|
}
|
764
1140
|
return content;
|
765
1141
|
},
|
766
|
-
(childItem, path
|
767
|
-
const
|
768
|
-
|
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)) {
|
769
1147
|
return childItem;
|
770
1148
|
}
|
771
1149
|
return null;
|
772
1150
|
}
|
773
1151
|
);
|
774
1152
|
};
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
return
|
1153
|
+
|
1154
|
+
// ../core/reducer/actions/reorder.ts
|
1155
|
+
var reorderAction = (state, action, appStore) => {
|
1156
|
+
return moveAction(
|
779
1157
|
state,
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
789
|
-
return childItem;
|
790
|
-
} else if (pathIds.indexOf(action.data.props.id) > -1) {
|
791
|
-
return childItem;
|
792
|
-
}
|
793
|
-
return null;
|
794
|
-
}
|
1158
|
+
{
|
1159
|
+
type: "move",
|
1160
|
+
sourceIndex: action.sourceIndex,
|
1161
|
+
sourceZone: action.destinationZone,
|
1162
|
+
destinationIndex: action.destinationIndex,
|
1163
|
+
destinationZone: action.destinationZone
|
1164
|
+
},
|
1165
|
+
appStore
|
795
1166
|
);
|
796
1167
|
};
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
}
|
808
|
-
return __spreadValues(__spreadValues({}, state), action.state(state));
|
809
|
-
};
|
810
|
-
function reduce(state, action, appStore) {
|
811
|
-
if (action.type === "set") {
|
812
|
-
return setAction(state, action, appStore);
|
813
|
-
}
|
814
|
-
if (action.type === "insert") {
|
815
|
-
return insertAction(state, action, appStore.config);
|
816
|
-
}
|
817
|
-
if (action.type === "replace") {
|
818
|
-
return replaceAction(state, action, appStore);
|
819
|
-
}
|
820
|
-
if (action.type === "replaceRoot") {
|
821
|
-
return walkTree(
|
822
|
-
state,
|
823
|
-
appStore.config,
|
824
|
-
(content) => content,
|
825
|
-
(childItem) => {
|
826
|
-
if (childItem.props.id === "root") {
|
827
|
-
return __spreadProps(__spreadValues({}, childItem), {
|
828
|
-
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
829
|
-
readOnly: action.root.readOnly
|
830
|
-
});
|
831
|
-
}
|
832
|
-
return childItem;
|
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];
|
833
1178
|
}
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
id: generateId(item.type)
|
845
|
-
})
|
846
|
-
});
|
847
|
-
const modified = walkTree(
|
848
|
-
state,
|
849
|
-
appStore.config,
|
850
|
-
(content, zoneCompound) => {
|
851
|
-
if (zoneCompound === action.sourceZone) {
|
852
|
-
return insert(content, action.sourceIndex + 1, item);
|
853
|
-
}
|
854
|
-
return content;
|
855
|
-
},
|
856
|
-
(childItem, path, index) => {
|
857
|
-
const zoneCompound = path[path.length - 1];
|
858
|
-
const parents = path.map((p) => p.split(":")[0]);
|
859
|
-
if (parents.indexOf(newItem.props.id) > -1) {
|
860
|
-
return __spreadProps(__spreadValues({}, childItem), {
|
861
|
-
props: __spreadProps(__spreadValues({}, childItem.props), {
|
862
|
-
id: generateId(childItem.type)
|
863
|
-
})
|
864
|
-
});
|
865
|
-
}
|
866
|
-
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
867
|
-
return newItem;
|
868
|
-
}
|
869
|
-
const [sourceZoneParent] = action.sourceZone.split(":");
|
870
|
-
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
871
|
-
return childItem;
|
872
|
-
}
|
873
|
-
return null;
|
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);
|
874
1189
|
}
|
875
|
-
|
876
|
-
return __spreadProps(__spreadValues({}, modified), {
|
877
|
-
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
878
|
-
itemSelector: {
|
879
|
-
index: action.sourceIndex + 1,
|
880
|
-
zone: action.sourceZone
|
881
|
-
}
|
882
|
-
})
|
883
|
-
});
|
884
|
-
}
|
885
|
-
if (action.type === "reorder") {
|
886
|
-
return reorderAction(state, action, appStore);
|
887
|
-
}
|
888
|
-
if (action.type === "move") {
|
889
|
-
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
890
|
-
return state;
|
1190
|
+
return content;
|
891
1191
|
}
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
)
|
896
|
-
|
897
|
-
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
898
|
-
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
899
|
-
return walkTree(
|
900
|
-
state,
|
901
|
-
appStore.config,
|
902
|
-
(content, zoneCompound) => {
|
903
|
-
if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
|
904
|
-
return insert(
|
905
|
-
remove(content, action.sourceIndex),
|
906
|
-
action.destinationIndex,
|
907
|
-
item
|
908
|
-
);
|
909
|
-
} else if (zoneCompound === action.sourceZone) {
|
910
|
-
return remove(content, action.sourceIndex);
|
911
|
-
} else if (zoneCompound === action.destinationZone) {
|
912
|
-
return insert(content, action.destinationIndex, item);
|
913
|
-
}
|
914
|
-
return content;
|
915
|
-
},
|
916
|
-
(childItem) => {
|
917
|
-
const [sourceZoneParent] = action.sourceZone.split(":");
|
918
|
-
const [destinationZoneParent] = action.destinationZone.split(":");
|
919
|
-
const childId = childItem.props.id;
|
920
|
-
if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1) {
|
921
|
-
return childItem;
|
922
|
-
}
|
923
|
-
return null;
|
924
|
-
}
|
925
|
-
);
|
926
|
-
}
|
927
|
-
if (action.type === "remove") {
|
928
|
-
const item = getItem({ index: action.index, zone: action.zone }, state);
|
929
|
-
let deindexed = deindex(state, item);
|
930
|
-
const [parentId] = action.zone.split(":");
|
931
|
-
return walkTree(
|
932
|
-
__spreadProps(__spreadValues({}, state), { indexes: deindexed }),
|
933
|
-
appStore.config,
|
934
|
-
(content, zoneCompound) => {
|
935
|
-
if (zoneCompound === action.zone) {
|
936
|
-
return remove(content, action.index);
|
937
|
-
}
|
938
|
-
return content;
|
939
|
-
},
|
940
|
-
(childItem, path) => {
|
941
|
-
const parentIds = path.map((p) => p.split(":")[0]);
|
942
|
-
if (childItem.props.id === parentId || childItem.props.id === item.props.id || parentIds.indexOf(item.props.id) > -1) {
|
943
|
-
return childItem;
|
944
|
-
}
|
945
|
-
return null;
|
946
|
-
}
|
947
|
-
);
|
948
|
-
}
|
949
|
-
if (action.type === "registerZone") {
|
950
|
-
if (zoneCache[action.zone]) {
|
951
|
-
return __spreadProps(__spreadValues({}, state), {
|
952
|
-
data: __spreadProps(__spreadValues({}, state.data), {
|
953
|
-
zones: __spreadProps(__spreadValues({}, state.data.zones), {
|
954
|
-
[action.zone]: zoneCache[action.zone]
|
955
|
-
})
|
956
|
-
}),
|
957
|
-
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
958
|
-
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
|
959
|
-
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
|
960
|
-
contentIds: zoneCache[action.zone].map((item) => item.props.id),
|
961
|
-
type: "dropzone"
|
962
|
-
})
|
963
|
-
})
|
964
|
-
})
|
965
|
-
});
|
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];
|
966
1197
|
}
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
if (_zones[action.zone]) {
|
973
|
-
zoneCache[action.zone] = _zones[action.zone];
|
974
|
-
delete _zones[action.zone];
|
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];
|
975
1203
|
}
|
976
|
-
|
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;
|
1219
|
+
}
|
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]) {
|
977
1231
|
return __spreadProps(__spreadValues({}, state), {
|
978
1232
|
data: __spreadProps(__spreadValues({}, state.data), {
|
979
|
-
zones:
|
1233
|
+
zones: __spreadProps(__spreadValues({}, state.data.zones), {
|
1234
|
+
[action.zone]: zoneCache[action.zone]
|
1235
|
+
})
|
980
1236
|
}),
|
981
1237
|
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
982
|
-
zones:
|
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
|
+
})
|
983
1244
|
})
|
984
1245
|
});
|
985
1246
|
}
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
}
|
998
|
-
|
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];
|
1255
|
+
}
|
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
|
+
});
|
1265
|
+
}
|
1266
|
+
|
1267
|
+
// ../core/reducer/actions/set-data.ts
|
1268
|
+
init_react_import();
|
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(
|
999
1275
|
__spreadProps(__spreadValues({}, state), {
|
1000
|
-
data: __spreadValues(__spreadValues({}, state.data), action.data
|
1276
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
1001
1277
|
}),
|
1002
1278
|
appStore.config
|
1003
1279
|
);
|
1004
1280
|
}
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
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") {
|
1011
1293
|
return __spreadProps(__spreadValues({}, state), {
|
1012
|
-
ui: __spreadValues(__spreadValues({}, state.ui), action.ui
|
1294
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
|
1013
1295
|
});
|
1014
1296
|
}
|
1015
|
-
return state
|
1016
|
-
}
|
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 };
|
1307
|
+
};
|
1017
1308
|
|
1018
1309
|
// ../core/reducer/actions.tsx
|
1019
1310
|
init_react_import();
|
@@ -1032,21 +1323,54 @@ function storeInterceptor(reducer, record, onAction) {
|
|
1032
1323
|
if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
|
1033
1324
|
if (record) record(newAppState);
|
1034
1325
|
}
|
1035
|
-
onAction == null ? void 0 : onAction(action, newAppState, state);
|
1326
|
+
onAction == null ? void 0 : onAction(action, makeStatePublic(newAppState), makeStatePublic(state));
|
1036
1327
|
return newAppState;
|
1037
1328
|
};
|
1038
1329
|
}
|
1039
1330
|
function createReducer({
|
1040
|
-
config,
|
1041
1331
|
record,
|
1042
1332
|
onAction,
|
1043
1333
|
appStore
|
1044
1334
|
}) {
|
1045
1335
|
return storeInterceptor(
|
1046
1336
|
(state, action) => {
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1337
|
+
if (action.type === "set") {
|
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);
|
1366
|
+
}
|
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;
|
1050
1374
|
},
|
1051
1375
|
record,
|
1052
1376
|
onAction
|
@@ -1241,7 +1565,7 @@ var createHistorySlice = (set, get) => {
|
|
1241
1565
|
const { dispatch, history } = get();
|
1242
1566
|
dispatch({
|
1243
1567
|
type: "set",
|
1244
|
-
state: ((_a = history.histories[
|
1568
|
+
state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
|
1245
1569
|
});
|
1246
1570
|
set({ history: __spreadProps(__spreadValues({}, history), { index }) });
|
1247
1571
|
},
|
@@ -1257,7 +1581,11 @@ var createNodesSlice = (set, get) => ({
|
|
1257
1581
|
const s = get().nodes;
|
1258
1582
|
const emptyNode = {
|
1259
1583
|
id,
|
1260
|
-
methods: {
|
1584
|
+
methods: {
|
1585
|
+
sync: () => null,
|
1586
|
+
hideOverlay: () => null,
|
1587
|
+
showOverlay: () => null
|
1588
|
+
},
|
1261
1589
|
element: null
|
1262
1590
|
};
|
1263
1591
|
const existingNode = s.nodes[id];
|
@@ -1290,11 +1618,11 @@ var createNodesSlice = (set, get) => ({
|
|
1290
1618
|
init_react_import();
|
1291
1619
|
import { useEffect as useEffect3 } from "react";
|
1292
1620
|
|
1293
|
-
// ../core/lib/flatten-data.ts
|
1621
|
+
// ../core/lib/data/flatten-data.ts
|
1294
1622
|
init_react_import();
|
1295
1623
|
var flattenData = (state, config) => {
|
1296
1624
|
const data = [];
|
1297
|
-
|
1625
|
+
walkAppState(
|
1298
1626
|
state,
|
1299
1627
|
config,
|
1300
1628
|
(content) => content,
|
@@ -1308,12 +1636,13 @@ var flattenData = (state, config) => {
|
|
1308
1636
|
|
1309
1637
|
// ../core/lib/get-changed.ts
|
1310
1638
|
init_react_import();
|
1639
|
+
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1311
1640
|
var getChanged = (newItem, oldItem) => {
|
1312
1641
|
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
1313
1642
|
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
1314
1643
|
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
1315
1644
|
return __spreadProps(__spreadValues({}, acc), {
|
1316
|
-
[item]: oldItemProps[item]
|
1645
|
+
[item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
|
1317
1646
|
});
|
1318
1647
|
}, {}) : {};
|
1319
1648
|
};
|
@@ -1325,12 +1654,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1325
1654
|
const { cache: cache2, globalPermissions } = permissions;
|
1326
1655
|
const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
|
1327
1656
|
var _a, _b, _c;
|
1328
|
-
const {
|
1329
|
-
config: config2,
|
1330
|
-
state: appState,
|
1331
|
-
setComponentLoading,
|
1332
|
-
unsetComponentLoading
|
1333
|
-
} = get();
|
1657
|
+
const { config: config2, state: appState, setComponentLoading } = get();
|
1334
1658
|
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
1335
1659
|
if (!componentConfig) {
|
1336
1660
|
return;
|
@@ -1339,14 +1663,14 @@ var createPermissionsSlice = (set, get) => {
|
|
1339
1663
|
if (componentConfig.resolvePermissions) {
|
1340
1664
|
const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
|
1341
1665
|
if (Object.values(changed).some((el) => el === true) || force2) {
|
1342
|
-
setComponentLoading(item2.props.id);
|
1666
|
+
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
1343
1667
|
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
1344
1668
|
item2,
|
1345
1669
|
{
|
1346
1670
|
changed,
|
1347
1671
|
lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
|
1348
1672
|
permissions: initialPermissions,
|
1349
|
-
appState,
|
1673
|
+
appState: makeStatePublic(appState),
|
1350
1674
|
lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
|
1351
1675
|
}
|
1352
1676
|
);
|
@@ -1364,7 +1688,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1364
1688
|
})
|
1365
1689
|
})
|
1366
1690
|
});
|
1367
|
-
|
1691
|
+
clearTimeout2();
|
1368
1692
|
}
|
1369
1693
|
}
|
1370
1694
|
});
|
@@ -1374,7 +1698,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1374
1698
|
// Shim the root data in by conforming to component data shape
|
1375
1699
|
{
|
1376
1700
|
type: "root",
|
1377
|
-
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "
|
1701
|
+
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "root" })
|
1378
1702
|
},
|
1379
1703
|
force2
|
1380
1704
|
);
|
@@ -1389,7 +1713,6 @@ var createPermissionsSlice = (set, get) => {
|
|
1389
1713
|
} else if (root) {
|
1390
1714
|
resolveDataForRoot(force);
|
1391
1715
|
} else {
|
1392
|
-
resolveDataForRoot(force);
|
1393
1716
|
flattenData(state, config).map((item2) => __async(void 0, null, function* () {
|
1394
1717
|
yield resolveDataForItem(item2, force);
|
1395
1718
|
}));
|
@@ -1420,7 +1743,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1420
1743
|
} else if (root) {
|
1421
1744
|
const rootConfig = config.root;
|
1422
1745
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
|
1423
|
-
const resolvedForItem = resolvedPermissions["
|
1746
|
+
const resolvedForItem = resolvedPermissions["root"];
|
1424
1747
|
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
1425
1748
|
}
|
1426
1749
|
return globalPermissions;
|
@@ -1437,45 +1760,24 @@ var createFieldsSlice = (_set, _get) => {
|
|
1437
1760
|
return {
|
1438
1761
|
fields: {},
|
1439
1762
|
loading: false,
|
1440
|
-
lastResolvedData: {}
|
1763
|
+
lastResolvedData: {},
|
1764
|
+
id: void 0
|
1441
1765
|
};
|
1442
1766
|
};
|
1443
1767
|
|
1444
1768
|
// ../core/lib/resolve-component-data.ts
|
1445
1769
|
init_react_import();
|
1446
|
-
|
1447
|
-
// ../core/lib/map-slots.ts
|
1448
|
-
init_react_import();
|
1449
|
-
function mapSlots(item, map, recursive = true, isSlot2) {
|
1450
|
-
return __async(this, null, function* () {
|
1451
|
-
const props = __spreadValues({}, item.props);
|
1452
|
-
yield forEachSlot(
|
1453
|
-
item,
|
1454
|
-
(_parentId, propName, content) => __async(this, null, function* () {
|
1455
|
-
const mappedContent = recursive ? yield Promise.all(
|
1456
|
-
content.map((item2) => __async(this, null, function* () {
|
1457
|
-
return yield mapSlots(item2, map, recursive, isSlot2);
|
1458
|
-
}))
|
1459
|
-
) : content;
|
1460
|
-
props[propName] = yield map(mappedContent, propName);
|
1461
|
-
}),
|
1462
|
-
false,
|
1463
|
-
isSlot2
|
1464
|
-
);
|
1465
|
-
return __spreadProps(__spreadValues({}, item), { props });
|
1466
|
-
});
|
1467
|
-
}
|
1468
|
-
|
1469
|
-
// ../core/lib/resolve-component-data.ts
|
1470
|
-
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1770
|
+
var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
|
1471
1771
|
var cache = { lastChange: {} };
|
1472
|
-
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace"
|
1473
|
-
const configForItem = "type" in item ? config.components[item.type] : config.root;
|
1474
|
-
|
1475
|
-
|
1772
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
1773
|
+
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
1774
|
+
const resolvedItem = __spreadValues({}, item);
|
1775
|
+
const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
|
1776
|
+
const id = "id" in item.props ? item.props.id : "root";
|
1777
|
+
if (shouldRunResolver) {
|
1476
1778
|
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
1477
|
-
if (item && item
|
1478
|
-
return resolved;
|
1779
|
+
if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
|
1780
|
+
return { node: resolved, didChange: false };
|
1479
1781
|
}
|
1480
1782
|
const changed = getChanged(item, oldItem);
|
1481
1783
|
if (onResolveStart) {
|
@@ -1484,47 +1786,48 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
1484
1786
|
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
1485
1787
|
changed,
|
1486
1788
|
lastData: oldItem,
|
1487
|
-
metadata,
|
1789
|
+
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
1488
1790
|
trigger
|
1489
1791
|
});
|
1490
|
-
|
1491
|
-
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
1492
|
-
});
|
1493
|
-
if (recursive) {
|
1494
|
-
resolvedItem = yield mapSlots(resolvedItem, (content) => __async(void 0, null, function* () {
|
1495
|
-
return Promise.all(
|
1496
|
-
content.map(
|
1497
|
-
(childItem) => __async(void 0, null, function* () {
|
1498
|
-
return (yield resolveComponentData(
|
1499
|
-
childItem,
|
1500
|
-
config,
|
1501
|
-
metadata,
|
1502
|
-
onResolveStart,
|
1503
|
-
onResolveEnd,
|
1504
|
-
trigger,
|
1505
|
-
false
|
1506
|
-
)).node;
|
1507
|
-
})
|
1508
|
-
)
|
1509
|
-
);
|
1510
|
-
}));
|
1511
|
-
}
|
1792
|
+
resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
|
1512
1793
|
if (Object.keys(readOnly).length) {
|
1513
1794
|
resolvedItem.readOnly = readOnly;
|
1514
1795
|
}
|
1515
|
-
cache.lastChange[id] = {
|
1516
|
-
item,
|
1517
|
-
resolved: resolvedItem
|
1518
|
-
};
|
1519
|
-
if (onResolveEnd) {
|
1520
|
-
onResolveEnd(resolvedItem);
|
1521
|
-
}
|
1522
|
-
return { node: resolvedItem, didChange: !(0, import_fast_deep_equal.default)(item, resolvedItem) };
|
1523
1796
|
}
|
1524
|
-
|
1797
|
+
let itemWithResolvedChildren = yield mapSlots(
|
1798
|
+
resolvedItem,
|
1799
|
+
(content) => __async(void 0, null, function* () {
|
1800
|
+
return yield Promise.all(
|
1801
|
+
content.map(
|
1802
|
+
(childItem) => __async(void 0, null, function* () {
|
1803
|
+
return (yield resolveComponentData(
|
1804
|
+
childItem,
|
1805
|
+
config,
|
1806
|
+
metadata,
|
1807
|
+
onResolveStart,
|
1808
|
+
onResolveEnd,
|
1809
|
+
trigger
|
1810
|
+
)).node;
|
1811
|
+
})
|
1812
|
+
)
|
1813
|
+
);
|
1814
|
+
}),
|
1815
|
+
config
|
1816
|
+
);
|
1817
|
+
if (shouldRunResolver && onResolveEnd) {
|
1818
|
+
onResolveEnd(resolvedItem);
|
1819
|
+
}
|
1820
|
+
cache.lastChange[id] = {
|
1821
|
+
item,
|
1822
|
+
resolved: itemWithResolvedChildren
|
1823
|
+
};
|
1824
|
+
return {
|
1825
|
+
node: itemWithResolvedChildren,
|
1826
|
+
didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
|
1827
|
+
};
|
1525
1828
|
});
|
1526
1829
|
|
1527
|
-
// ../core/lib/to-root.ts
|
1830
|
+
// ../core/lib/data/to-root.ts
|
1528
1831
|
init_react_import();
|
1529
1832
|
var toRoot = (item) => {
|
1530
1833
|
if ("type" in item && item.type !== "root") {
|
@@ -1541,7 +1844,8 @@ var toRoot = (item) => {
|
|
1541
1844
|
return { props: {}, readOnly };
|
1542
1845
|
};
|
1543
1846
|
|
1544
|
-
// ../core/store/
|
1847
|
+
// ../core/store/default-app-state.ts
|
1848
|
+
init_react_import();
|
1545
1849
|
var defaultAppState = {
|
1546
1850
|
data: { content: [], root: {}, zones: {} },
|
1547
1851
|
ui: {
|
@@ -1567,178 +1871,182 @@ var defaultAppState = {
|
|
1567
1871
|
zones: {}
|
1568
1872
|
}
|
1569
1873
|
};
|
1874
|
+
|
1875
|
+
// ../core/store/index.ts
|
1570
1876
|
var defaultPageFields = {
|
1571
1877
|
title: { type: "text" }
|
1572
1878
|
};
|
1573
1879
|
var createAppStore = (initialAppStore) => create()(
|
1574
|
-
subscribeWithSelector((set, get) =>
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
setComponentState
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1880
|
+
subscribeWithSelector((set, get) => {
|
1881
|
+
var _a, _b;
|
1882
|
+
return __spreadProps(__spreadValues({
|
1883
|
+
state: defaultAppState,
|
1884
|
+
config: { components: {} },
|
1885
|
+
componentState: {},
|
1886
|
+
plugins: [],
|
1887
|
+
overrides: {},
|
1888
|
+
viewports: defaultViewports,
|
1889
|
+
zoomConfig: {
|
1890
|
+
autoZoom: 1,
|
1891
|
+
rootHeight: 0,
|
1892
|
+
zoom: 1
|
1893
|
+
},
|
1894
|
+
status: "LOADING",
|
1895
|
+
iframe: {},
|
1896
|
+
metadata: {}
|
1897
|
+
}, initialAppStore), {
|
1898
|
+
fields: createFieldsSlice(set, get),
|
1899
|
+
history: createHistorySlice(set, get),
|
1900
|
+
nodes: createNodesSlice(set, get),
|
1901
|
+
permissions: createPermissionsSlice(set, get),
|
1902
|
+
getComponentConfig: (type) => {
|
1903
|
+
var _a2;
|
1904
|
+
const { config, selectedItem } = get();
|
1905
|
+
const rootFields = ((_a2 = config.root) == null ? void 0 : _a2.fields) || defaultPageFields;
|
1906
|
+
return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
|
1907
|
+
},
|
1908
|
+
selectedItem: ((_a = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _a.ui.itemSelector) ? getItem(
|
1909
|
+
(_b = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _b.ui.itemSelector,
|
1910
|
+
initialAppStore.state
|
1911
|
+
) : null,
|
1912
|
+
dispatch: (action) => set((s) => {
|
1913
|
+
var _a2, _b2;
|
1914
|
+
const { record } = get().history;
|
1915
|
+
const dispatch = createReducer({
|
1916
|
+
record,
|
1917
|
+
appStore: s
|
1918
|
+
});
|
1919
|
+
const state = dispatch(s.state, action);
|
1920
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1921
|
+
(_b2 = (_a2 = get()).onAction) == null ? void 0 : _b2.call(_a2, action, state, get().state);
|
1922
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1923
|
+
}),
|
1924
|
+
setZoomConfig: (zoomConfig) => set({ zoomConfig }),
|
1925
|
+
setStatus: (status) => set({ status }),
|
1926
|
+
setComponentState: (componentState) => set({ componentState }),
|
1927
|
+
pendingLoadTimeouts: {},
|
1928
|
+
setComponentLoading: (id, loading = true, defer = 0) => {
|
1929
|
+
const { setComponentState, pendingLoadTimeouts } = get();
|
1930
|
+
const loadId = generateId();
|
1931
|
+
const setLoading = () => {
|
1932
|
+
var _a2;
|
1933
|
+
const { componentState } = get();
|
1934
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1935
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1936
|
+
loadingCount: (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) + 1
|
1937
|
+
})
|
1938
|
+
}));
|
1939
|
+
};
|
1940
|
+
const unsetLoading = () => {
|
1941
|
+
var _a2;
|
1942
|
+
const { componentState } = get();
|
1943
|
+
clearTimeout(timeout);
|
1944
|
+
delete pendingLoadTimeouts[loadId];
|
1945
|
+
set({ pendingLoadTimeouts });
|
1946
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1947
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1948
|
+
loadingCount: Math.max(
|
1949
|
+
(((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) - 1,
|
1950
|
+
0
|
1951
|
+
)
|
1952
|
+
})
|
1953
|
+
}));
|
1954
|
+
};
|
1955
|
+
const timeout = setTimeout(() => {
|
1956
|
+
if (loading) {
|
1957
|
+
setLoading();
|
1958
|
+
} else {
|
1959
|
+
unsetLoading();
|
1960
|
+
}
|
1961
|
+
delete pendingLoadTimeouts[loadId];
|
1962
|
+
set({ pendingLoadTimeouts });
|
1963
|
+
}, defer);
|
1964
|
+
set({
|
1965
|
+
pendingLoadTimeouts: __spreadProps(__spreadValues({}, pendingLoadTimeouts), {
|
1966
|
+
[id]: timeout
|
1638
1967
|
})
|
1639
|
-
})
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
}
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1679
|
-
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1680
|
-
}),
|
1681
|
-
// resolveDataRuns: 0,
|
1682
|
-
// resolveData: (newAppState) =>
|
1683
|
-
// set((s) => {
|
1684
|
-
// resolveData(newAppState, get);
|
1685
|
-
// return { ...s, resolveDataRuns: s.resolveDataRuns + 1 };
|
1686
|
-
// }),
|
1687
|
-
resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
|
1688
|
-
const { config, metadata, setComponentLoading } = get();
|
1689
|
-
return yield resolveComponentData(
|
1690
|
-
componentData,
|
1691
|
-
config,
|
1692
|
-
metadata,
|
1693
|
-
(item) => setComponentLoading(
|
1694
|
-
"id" in item.props ? item.props.id : "root",
|
1695
|
-
true,
|
1696
|
-
50
|
1697
|
-
),
|
1698
|
-
(item) => setComponentLoading(
|
1699
|
-
"id" in item.props ? item.props.id : "root",
|
1700
|
-
false,
|
1701
|
-
0
|
1702
|
-
),
|
1703
|
-
trigger
|
1704
|
-
);
|
1705
|
-
}),
|
1706
|
-
resolveAndCommitData: () => __async(void 0, null, function* () {
|
1707
|
-
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
1708
|
-
walkTree(
|
1709
|
-
state,
|
1710
|
-
config,
|
1711
|
-
(content) => content,
|
1712
|
-
(childItem) => {
|
1713
|
-
resolveComponentData2(childItem, "load").then((resolved) => {
|
1714
|
-
const { state: state2 } = get();
|
1715
|
-
const node = state2.indexes.nodes[resolved.node.props.id];
|
1716
|
-
if (node && resolved.didChange) {
|
1717
|
-
if (resolved.node.props.id === "root") {
|
1718
|
-
dispatch({
|
1719
|
-
type: "replaceRoot",
|
1720
|
-
root: toRoot(resolved.node)
|
1721
|
-
});
|
1722
|
-
} else {
|
1723
|
-
const zoneCompound = `${node.parentId}:${node.zone}`;
|
1724
|
-
const parentZone = state2.indexes.zones[zoneCompound];
|
1725
|
-
const index = parentZone.contentIds.indexOf(
|
1726
|
-
resolved.node.props.id
|
1727
|
-
);
|
1728
|
-
dispatch({
|
1729
|
-
type: "replace",
|
1730
|
-
data: resolved.node,
|
1731
|
-
destinationIndex: index,
|
1732
|
-
destinationZone: zoneCompound
|
1733
|
-
});
|
1734
|
-
}
|
1968
|
+
});
|
1969
|
+
return unsetLoading;
|
1970
|
+
},
|
1971
|
+
unsetComponentLoading: (id) => {
|
1972
|
+
const { setComponentLoading } = get();
|
1973
|
+
setComponentLoading(id, false);
|
1974
|
+
},
|
1975
|
+
// Helper
|
1976
|
+
setUi: (ui, recordHistory) => set((s) => {
|
1977
|
+
const dispatch = createReducer({
|
1978
|
+
record: () => {
|
1979
|
+
},
|
1980
|
+
appStore: s
|
1981
|
+
});
|
1982
|
+
const state = dispatch(s.state, {
|
1983
|
+
type: "setUi",
|
1984
|
+
ui,
|
1985
|
+
recordHistory
|
1986
|
+
});
|
1987
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1988
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1989
|
+
}),
|
1990
|
+
resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
|
1991
|
+
const { config, metadata, setComponentLoading, permissions } = get();
|
1992
|
+
const timeouts = {};
|
1993
|
+
return yield resolveComponentData(
|
1994
|
+
componentData,
|
1995
|
+
config,
|
1996
|
+
metadata,
|
1997
|
+
(item) => {
|
1998
|
+
const id = "id" in item.props ? item.props.id : "root";
|
1999
|
+
timeouts[id] = setComponentLoading(id, true, 50);
|
2000
|
+
},
|
2001
|
+
(item) => __async(void 0, null, function* () {
|
2002
|
+
const id = "id" in item.props ? item.props.id : "root";
|
2003
|
+
if ("type" in item) {
|
2004
|
+
yield permissions.refreshPermissions({ item });
|
2005
|
+
} else {
|
2006
|
+
yield permissions.refreshPermissions({ root: true });
|
1735
2007
|
}
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
2008
|
+
timeouts[id]();
|
2009
|
+
}),
|
2010
|
+
trigger
|
2011
|
+
);
|
2012
|
+
}),
|
2013
|
+
resolveAndCommitData: () => __async(void 0, null, function* () {
|
2014
|
+
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
2015
|
+
walkAppState(
|
2016
|
+
state,
|
2017
|
+
config,
|
2018
|
+
(content) => content,
|
2019
|
+
(childItem) => {
|
2020
|
+
resolveComponentData2(childItem, "load").then((resolved) => {
|
2021
|
+
const { state: state2 } = get();
|
2022
|
+
const node = state2.indexes.nodes[resolved.node.props.id];
|
2023
|
+
if (node && resolved.didChange) {
|
2024
|
+
if (resolved.node.props.id === "root") {
|
2025
|
+
dispatch({
|
2026
|
+
type: "replaceRoot",
|
2027
|
+
root: toRoot(resolved.node)
|
2028
|
+
});
|
2029
|
+
} else {
|
2030
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
2031
|
+
const parentZone = state2.indexes.zones[zoneCompound];
|
2032
|
+
const index = parentZone.contentIds.indexOf(
|
2033
|
+
resolved.node.props.id
|
2034
|
+
);
|
2035
|
+
dispatch({
|
2036
|
+
type: "replace",
|
2037
|
+
data: resolved.node,
|
2038
|
+
destinationIndex: index,
|
2039
|
+
destinationZone: zoneCompound
|
2040
|
+
});
|
2041
|
+
}
|
2042
|
+
}
|
2043
|
+
});
|
2044
|
+
return childItem;
|
2045
|
+
}
|
2046
|
+
);
|
2047
|
+
})
|
2048
|
+
});
|
2049
|
+
})
|
1742
2050
|
);
|
1743
2051
|
var appStoreContext = createContext(createAppStore());
|
1744
2052
|
function useAppStore(selector) {
|
@@ -1800,7 +2108,10 @@ init_react_import();
|
|
1800
2108
|
// ../core/lib/filter.ts
|
1801
2109
|
init_react_import();
|
1802
2110
|
|
1803
|
-
// ../core/lib/
|
2111
|
+
// ../core/lib/data/reorder.ts
|
2112
|
+
init_react_import();
|
2113
|
+
|
2114
|
+
// ../core/lib/data/replace.ts
|
1804
2115
|
init_react_import();
|
1805
2116
|
|
1806
2117
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
|
@@ -1986,15 +2297,37 @@ var HeadingAnalyzer = () => {
|
|
1986
2297
|
const [hierarchy, setHierarchy] = useState([]);
|
1987
2298
|
useEffect5(() => {
|
1988
2299
|
const frame = getFrame();
|
1989
|
-
|
1990
|
-
|
1991
|
-
setHierarchy(buildHierarchy(entry));
|
1992
|
-
const observer = new MutationObserver(() => {
|
2300
|
+
let entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
2301
|
+
const createHierarchy = () => {
|
1993
2302
|
setHierarchy(buildHierarchy(entry));
|
2303
|
+
};
|
2304
|
+
const entryObserver = new MutationObserver(() => {
|
2305
|
+
createHierarchy();
|
2306
|
+
});
|
2307
|
+
const frameObserver = new MutationObserver(() => {
|
2308
|
+
entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
2309
|
+
if (entry) {
|
2310
|
+
registerEntryObserver();
|
2311
|
+
frameObserver.disconnect();
|
2312
|
+
}
|
1994
2313
|
});
|
1995
|
-
|
2314
|
+
const registerEntryObserver = () => {
|
2315
|
+
if (!entry) return;
|
2316
|
+
entryObserver.observe(entry, { subtree: true, childList: true });
|
2317
|
+
};
|
2318
|
+
const registerFrameObserver = () => {
|
2319
|
+
if (!frame) return;
|
2320
|
+
frameObserver.observe(frame, { subtree: true, childList: true });
|
2321
|
+
};
|
2322
|
+
if (entry) {
|
2323
|
+
createHierarchy();
|
2324
|
+
registerEntryObserver();
|
2325
|
+
} else {
|
2326
|
+
registerFrameObserver();
|
2327
|
+
}
|
1996
2328
|
return () => {
|
1997
|
-
|
2329
|
+
entryObserver.disconnect();
|
2330
|
+
frameObserver.disconnect();
|
1998
2331
|
};
|
1999
2332
|
}, [data]);
|
2000
2333
|
return /* @__PURE__ */ jsxs2("div", { className: getClassName5(), children: [
|