@measured/puck-plugin-heading-analyzer 0.19.0-canary.0308d24 → 0.19.0-canary.036267f6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +772 -922
- package/dist/index.mjs +765 -921
- package/package.json +2 -2
package/dist/index.js
CHANGED
@@ -153,289 +153,6 @@ var require_classnames = __commonJS({
|
|
153
153
|
}
|
154
154
|
});
|
155
155
|
|
156
|
-
// ../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js
|
157
|
-
var require_use_sync_external_store_shim_production = __commonJS({
|
158
|
-
"../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js"(exports2) {
|
159
|
-
"use strict";
|
160
|
-
init_react_import();
|
161
|
-
var React2 = require("react");
|
162
|
-
function is(x, y) {
|
163
|
-
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
164
|
-
}
|
165
|
-
var objectIs = "function" === typeof Object.is ? Object.is : is;
|
166
|
-
var useState2 = React2.useState;
|
167
|
-
var useEffect7 = React2.useEffect;
|
168
|
-
var useLayoutEffect = React2.useLayoutEffect;
|
169
|
-
var useDebugValue2 = React2.useDebugValue;
|
170
|
-
function useSyncExternalStore$2(subscribe, getSnapshot) {
|
171
|
-
var value = getSnapshot(), _useState = useState2({ inst: { value, getSnapshot } }), inst = _useState[0].inst, forceUpdate = _useState[1];
|
172
|
-
useLayoutEffect(
|
173
|
-
function() {
|
174
|
-
inst.value = value;
|
175
|
-
inst.getSnapshot = getSnapshot;
|
176
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
177
|
-
},
|
178
|
-
[subscribe, value, getSnapshot]
|
179
|
-
);
|
180
|
-
useEffect7(
|
181
|
-
function() {
|
182
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
183
|
-
return subscribe(function() {
|
184
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
185
|
-
});
|
186
|
-
},
|
187
|
-
[subscribe]
|
188
|
-
);
|
189
|
-
useDebugValue2(value);
|
190
|
-
return value;
|
191
|
-
}
|
192
|
-
function checkIfSnapshotChanged(inst) {
|
193
|
-
var latestGetSnapshot = inst.getSnapshot;
|
194
|
-
inst = inst.value;
|
195
|
-
try {
|
196
|
-
var nextValue = latestGetSnapshot();
|
197
|
-
return !objectIs(inst, nextValue);
|
198
|
-
} catch (error) {
|
199
|
-
return true;
|
200
|
-
}
|
201
|
-
}
|
202
|
-
function useSyncExternalStore$1(subscribe, getSnapshot) {
|
203
|
-
return getSnapshot();
|
204
|
-
}
|
205
|
-
var shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
|
206
|
-
exports2.useSyncExternalStore = void 0 !== React2.useSyncExternalStore ? React2.useSyncExternalStore : shim;
|
207
|
-
}
|
208
|
-
});
|
209
|
-
|
210
|
-
// ../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
|
211
|
-
var require_use_sync_external_store_shim_development = __commonJS({
|
212
|
-
"../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports2) {
|
213
|
-
"use strict";
|
214
|
-
init_react_import();
|
215
|
-
"production" !== process.env.NODE_ENV && function() {
|
216
|
-
function is(x, y) {
|
217
|
-
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
218
|
-
}
|
219
|
-
function useSyncExternalStore$2(subscribe, getSnapshot) {
|
220
|
-
didWarnOld18Alpha || void 0 === React2.startTransition || (didWarnOld18Alpha = true, console.error(
|
221
|
-
"You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
|
222
|
-
));
|
223
|
-
var value = getSnapshot();
|
224
|
-
if (!didWarnUncachedGetSnapshot) {
|
225
|
-
var cachedValue = getSnapshot();
|
226
|
-
objectIs(value, cachedValue) || (console.error(
|
227
|
-
"The result of getSnapshot should be cached to avoid an infinite loop"
|
228
|
-
), didWarnUncachedGetSnapshot = true);
|
229
|
-
}
|
230
|
-
cachedValue = useState2({
|
231
|
-
inst: { value, getSnapshot }
|
232
|
-
});
|
233
|
-
var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
|
234
|
-
useLayoutEffect(
|
235
|
-
function() {
|
236
|
-
inst.value = value;
|
237
|
-
inst.getSnapshot = getSnapshot;
|
238
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
239
|
-
},
|
240
|
-
[subscribe, value, getSnapshot]
|
241
|
-
);
|
242
|
-
useEffect7(
|
243
|
-
function() {
|
244
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
245
|
-
return subscribe(function() {
|
246
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
247
|
-
});
|
248
|
-
},
|
249
|
-
[subscribe]
|
250
|
-
);
|
251
|
-
useDebugValue2(value);
|
252
|
-
return value;
|
253
|
-
}
|
254
|
-
function checkIfSnapshotChanged(inst) {
|
255
|
-
var latestGetSnapshot = inst.getSnapshot;
|
256
|
-
inst = inst.value;
|
257
|
-
try {
|
258
|
-
var nextValue = latestGetSnapshot();
|
259
|
-
return !objectIs(inst, nextValue);
|
260
|
-
} catch (error) {
|
261
|
-
return true;
|
262
|
-
}
|
263
|
-
}
|
264
|
-
function useSyncExternalStore$1(subscribe, getSnapshot) {
|
265
|
-
return getSnapshot();
|
266
|
-
}
|
267
|
-
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
268
|
-
var React2 = require("react"), objectIs = "function" === typeof Object.is ? Object.is : is, useState2 = React2.useState, useEffect7 = React2.useEffect, useLayoutEffect = React2.useLayoutEffect, useDebugValue2 = React2.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
|
269
|
-
exports2.useSyncExternalStore = void 0 !== React2.useSyncExternalStore ? React2.useSyncExternalStore : shim;
|
270
|
-
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
271
|
-
}();
|
272
|
-
}
|
273
|
-
});
|
274
|
-
|
275
|
-
// ../../node_modules/use-sync-external-store/shim/index.js
|
276
|
-
var require_shim = __commonJS({
|
277
|
-
"../../node_modules/use-sync-external-store/shim/index.js"(exports2, module2) {
|
278
|
-
"use strict";
|
279
|
-
init_react_import();
|
280
|
-
if (process.env.NODE_ENV === "production") {
|
281
|
-
module2.exports = require_use_sync_external_store_shim_production();
|
282
|
-
} else {
|
283
|
-
module2.exports = require_use_sync_external_store_shim_development();
|
284
|
-
}
|
285
|
-
}
|
286
|
-
});
|
287
|
-
|
288
|
-
// ../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js
|
289
|
-
var require_with_selector_production = __commonJS({
|
290
|
-
"../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js"(exports2) {
|
291
|
-
"use strict";
|
292
|
-
init_react_import();
|
293
|
-
var React2 = require("react");
|
294
|
-
var shim = require_shim();
|
295
|
-
function is(x, y) {
|
296
|
-
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
297
|
-
}
|
298
|
-
var objectIs = "function" === typeof Object.is ? Object.is : is;
|
299
|
-
var useSyncExternalStore = shim.useSyncExternalStore;
|
300
|
-
var useRef = React2.useRef;
|
301
|
-
var useEffect7 = React2.useEffect;
|
302
|
-
var useMemo2 = React2.useMemo;
|
303
|
-
var useDebugValue2 = React2.useDebugValue;
|
304
|
-
exports2.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
305
|
-
var instRef = useRef(null);
|
306
|
-
if (null === instRef.current) {
|
307
|
-
var inst = { hasValue: false, value: null };
|
308
|
-
instRef.current = inst;
|
309
|
-
} else inst = instRef.current;
|
310
|
-
instRef = useMemo2(
|
311
|
-
function() {
|
312
|
-
function memoizedSelector(nextSnapshot) {
|
313
|
-
if (!hasMemo) {
|
314
|
-
hasMemo = true;
|
315
|
-
memoizedSnapshot = nextSnapshot;
|
316
|
-
nextSnapshot = selector(nextSnapshot);
|
317
|
-
if (void 0 !== isEqual && inst.hasValue) {
|
318
|
-
var currentSelection = inst.value;
|
319
|
-
if (isEqual(currentSelection, nextSnapshot))
|
320
|
-
return memoizedSelection = currentSelection;
|
321
|
-
}
|
322
|
-
return memoizedSelection = nextSnapshot;
|
323
|
-
}
|
324
|
-
currentSelection = memoizedSelection;
|
325
|
-
if (objectIs(memoizedSnapshot, nextSnapshot)) return currentSelection;
|
326
|
-
var nextSelection = selector(nextSnapshot);
|
327
|
-
if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
|
328
|
-
return memoizedSnapshot = nextSnapshot, currentSelection;
|
329
|
-
memoizedSnapshot = nextSnapshot;
|
330
|
-
return memoizedSelection = nextSelection;
|
331
|
-
}
|
332
|
-
var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
|
333
|
-
return [
|
334
|
-
function() {
|
335
|
-
return memoizedSelector(getSnapshot());
|
336
|
-
},
|
337
|
-
null === maybeGetServerSnapshot ? void 0 : function() {
|
338
|
-
return memoizedSelector(maybeGetServerSnapshot());
|
339
|
-
}
|
340
|
-
];
|
341
|
-
},
|
342
|
-
[getSnapshot, getServerSnapshot, selector, isEqual]
|
343
|
-
);
|
344
|
-
var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);
|
345
|
-
useEffect7(
|
346
|
-
function() {
|
347
|
-
inst.hasValue = true;
|
348
|
-
inst.value = value;
|
349
|
-
},
|
350
|
-
[value]
|
351
|
-
);
|
352
|
-
useDebugValue2(value);
|
353
|
-
return value;
|
354
|
-
};
|
355
|
-
}
|
356
|
-
});
|
357
|
-
|
358
|
-
// ../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
|
359
|
-
var require_with_selector_development = __commonJS({
|
360
|
-
"../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports2) {
|
361
|
-
"use strict";
|
362
|
-
init_react_import();
|
363
|
-
"production" !== process.env.NODE_ENV && function() {
|
364
|
-
function is(x, y) {
|
365
|
-
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
366
|
-
}
|
367
|
-
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
368
|
-
var React2 = require("react"), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore = shim.useSyncExternalStore, useRef = React2.useRef, useEffect7 = React2.useEffect, useMemo2 = React2.useMemo, useDebugValue2 = React2.useDebugValue;
|
369
|
-
exports2.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
370
|
-
var instRef = useRef(null);
|
371
|
-
if (null === instRef.current) {
|
372
|
-
var inst = { hasValue: false, value: null };
|
373
|
-
instRef.current = inst;
|
374
|
-
} else inst = instRef.current;
|
375
|
-
instRef = useMemo2(
|
376
|
-
function() {
|
377
|
-
function memoizedSelector(nextSnapshot) {
|
378
|
-
if (!hasMemo) {
|
379
|
-
hasMemo = true;
|
380
|
-
memoizedSnapshot = nextSnapshot;
|
381
|
-
nextSnapshot = selector(nextSnapshot);
|
382
|
-
if (void 0 !== isEqual && inst.hasValue) {
|
383
|
-
var currentSelection = inst.value;
|
384
|
-
if (isEqual(currentSelection, nextSnapshot))
|
385
|
-
return memoizedSelection = currentSelection;
|
386
|
-
}
|
387
|
-
return memoizedSelection = nextSnapshot;
|
388
|
-
}
|
389
|
-
currentSelection = memoizedSelection;
|
390
|
-
if (objectIs(memoizedSnapshot, nextSnapshot))
|
391
|
-
return currentSelection;
|
392
|
-
var nextSelection = selector(nextSnapshot);
|
393
|
-
if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
|
394
|
-
return memoizedSnapshot = nextSnapshot, currentSelection;
|
395
|
-
memoizedSnapshot = nextSnapshot;
|
396
|
-
return memoizedSelection = nextSelection;
|
397
|
-
}
|
398
|
-
var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
|
399
|
-
return [
|
400
|
-
function() {
|
401
|
-
return memoizedSelector(getSnapshot());
|
402
|
-
},
|
403
|
-
null === maybeGetServerSnapshot ? void 0 : function() {
|
404
|
-
return memoizedSelector(maybeGetServerSnapshot());
|
405
|
-
}
|
406
|
-
];
|
407
|
-
},
|
408
|
-
[getSnapshot, getServerSnapshot, selector, isEqual]
|
409
|
-
);
|
410
|
-
var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);
|
411
|
-
useEffect7(
|
412
|
-
function() {
|
413
|
-
inst.hasValue = true;
|
414
|
-
inst.value = value;
|
415
|
-
},
|
416
|
-
[value]
|
417
|
-
);
|
418
|
-
useDebugValue2(value);
|
419
|
-
return value;
|
420
|
-
};
|
421
|
-
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
422
|
-
}();
|
423
|
-
}
|
424
|
-
});
|
425
|
-
|
426
|
-
// ../../node_modules/use-sync-external-store/shim/with-selector.js
|
427
|
-
var require_with_selector = __commonJS({
|
428
|
-
"../../node_modules/use-sync-external-store/shim/with-selector.js"(exports2, module2) {
|
429
|
-
"use strict";
|
430
|
-
init_react_import();
|
431
|
-
if (process.env.NODE_ENV === "production") {
|
432
|
-
module2.exports = require_with_selector_production();
|
433
|
-
} else {
|
434
|
-
module2.exports = require_with_selector_development();
|
435
|
-
}
|
436
|
-
}
|
437
|
-
});
|
438
|
-
|
439
156
|
// ../../node_modules/fast-deep-equal/index.js
|
440
157
|
var require_fast_deep_equal = __commonJS({
|
441
158
|
"../../node_modules/fast-deep-equal/index.js"(exports2, module2) {
|
@@ -482,7 +199,7 @@ init_react_import();
|
|
482
199
|
|
483
200
|
// src/HeadingAnalyzer.tsx
|
484
201
|
init_react_import();
|
485
|
-
var
|
202
|
+
var import_react11 = require("react");
|
486
203
|
|
487
204
|
// css-module:/home/runner/work/puck/puck/packages/plugin-heading-analyzer/src/HeadingAnalyzer.module.css#css-module
|
488
205
|
init_react_import();
|
@@ -643,7 +360,7 @@ var ChevronRight = createLucideIcon("ChevronRight", [
|
|
643
360
|
|
644
361
|
// ../core/lib/use-breadcrumbs.ts
|
645
362
|
init_react_import();
|
646
|
-
var
|
363
|
+
var import_react10 = require("react");
|
647
364
|
|
648
365
|
// ../core/store/index.ts
|
649
366
|
init_react_import();
|
@@ -651,28 +368,13 @@ init_react_import();
|
|
651
368
|
// ../core/reducer/index.ts
|
652
369
|
init_react_import();
|
653
370
|
|
654
|
-
// ../core/reducer/
|
655
|
-
init_react_import();
|
656
|
-
|
657
|
-
// ../core/lib/reorder.ts
|
371
|
+
// ../core/reducer/reduce.ts
|
658
372
|
init_react_import();
|
659
|
-
var reorder = (list, startIndex, endIndex) => {
|
660
|
-
const result = Array.from(list);
|
661
|
-
const [removed] = result.splice(startIndex, 1);
|
662
|
-
result.splice(endIndex, 0, removed);
|
663
|
-
return result;
|
664
|
-
};
|
665
|
-
|
666
|
-
// ../core/lib/root-droppable-id.ts
|
667
|
-
init_react_import();
|
668
|
-
var rootAreaId = "root";
|
669
|
-
var rootZone = "default-zone";
|
670
|
-
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
671
373
|
|
672
374
|
// ../core/lib/insert.ts
|
673
375
|
init_react_import();
|
674
376
|
var insert = (list, index, item) => {
|
675
|
-
const result = Array.from(list);
|
377
|
+
const result = Array.from(list || []);
|
676
378
|
result.splice(index, 0, item);
|
677
379
|
return result;
|
678
380
|
};
|
@@ -687,6 +389,14 @@ var remove = (list, index) => {
|
|
687
389
|
|
688
390
|
// ../core/lib/setup-zone.ts
|
689
391
|
init_react_import();
|
392
|
+
|
393
|
+
// ../core/lib/root-droppable-id.ts
|
394
|
+
init_react_import();
|
395
|
+
var rootAreaId = "root";
|
396
|
+
var rootZone = "default-zone";
|
397
|
+
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
398
|
+
|
399
|
+
// ../core/lib/setup-zone.ts
|
690
400
|
var setupZone = (data, zoneKey) => {
|
691
401
|
if (zoneKey === rootDroppableId) {
|
692
402
|
return data;
|
@@ -698,29 +408,14 @@ var setupZone = (data, zoneKey) => {
|
|
698
408
|
return newData;
|
699
409
|
};
|
700
410
|
|
701
|
-
// ../core/lib/replace.ts
|
702
|
-
init_react_import();
|
703
|
-
var replace = (list, index, newItem) => {
|
704
|
-
const result = Array.from(list);
|
705
|
-
result.splice(index, 1);
|
706
|
-
result.splice(index, 0, newItem);
|
707
|
-
return result;
|
708
|
-
};
|
709
|
-
|
710
411
|
// ../core/lib/get-item.ts
|
711
412
|
init_react_import();
|
712
|
-
function getItem(selector,
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
}
|
717
|
-
const item = setupZone(data, selector.zone).zones[selector.zone][selector.index];
|
718
|
-
return (item == null ? void 0 : item.props) ? __spreadProps(__spreadValues({}, item), { props: dynamicProps[item.props.id] || item.props }) : void 0;
|
413
|
+
function getItem(selector, state) {
|
414
|
+
var _a, _b;
|
415
|
+
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
416
|
+
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
719
417
|
}
|
720
418
|
|
721
|
-
// ../core/lib/reduce-related-zones.ts
|
722
|
-
init_react_import();
|
723
|
-
|
724
419
|
// ../core/lib/generate-id.ts
|
725
420
|
init_react_import();
|
726
421
|
|
@@ -783,6 +478,43 @@ var v4_default = v4;
|
|
783
478
|
// ../core/lib/generate-id.ts
|
784
479
|
var generateId = (type) => type ? `${type}-${v4_default()}` : v4_default();
|
785
480
|
|
481
|
+
// ../core/lib/walk-tree.ts
|
482
|
+
init_react_import();
|
483
|
+
|
484
|
+
// ../core/lib/for-each-slot.ts
|
485
|
+
init_react_import();
|
486
|
+
|
487
|
+
// ../core/lib/is-slot.ts
|
488
|
+
init_react_import();
|
489
|
+
var isSlot = (prop) => {
|
490
|
+
var _a, _b;
|
491
|
+
return Array.isArray(prop) && typeof ((_a = prop[0]) == null ? void 0 : _a.type) === "string" && typeof ((_b = prop[0]) == null ? void 0 : _b.props) === "object";
|
492
|
+
};
|
493
|
+
|
494
|
+
// ../core/lib/for-each-slot.ts
|
495
|
+
var forEachSlot = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, cb, recursive = false, isSlot2 = isSlot) {
|
496
|
+
const props = item.props || {};
|
497
|
+
const propKeys = Object.keys(props);
|
498
|
+
for (let i = 0; i < propKeys.length; i++) {
|
499
|
+
const propKey = propKeys[i];
|
500
|
+
const itemType = "type" in item ? item.type : "root";
|
501
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
502
|
+
const content = props[propKey];
|
503
|
+
yield cb(props.id, propKey, content);
|
504
|
+
if (recursive) {
|
505
|
+
content.forEach(
|
506
|
+
(childItem) => __async(void 0, null, function* () {
|
507
|
+
return yield forEachSlot(childItem, cb, true, isSlot2);
|
508
|
+
})
|
509
|
+
);
|
510
|
+
}
|
511
|
+
}
|
512
|
+
}
|
513
|
+
});
|
514
|
+
|
515
|
+
// ../core/lib/for-related-zones.ts
|
516
|
+
init_react_import();
|
517
|
+
|
786
518
|
// ../core/lib/get-zone-id.ts
|
787
519
|
init_react_import();
|
788
520
|
var getZoneId = (zoneCompound) => {
|
@@ -795,302 +527,491 @@ var getZoneId = (zoneCompound) => {
|
|
795
527
|
return [rootDroppableId, zoneCompound];
|
796
528
|
};
|
797
529
|
|
798
|
-
// ../core/lib/
|
799
|
-
function
|
530
|
+
// ../core/lib/for-related-zones.ts
|
531
|
+
function forRelatedZones(item, data, cb, path = []) {
|
532
|
+
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
|
533
|
+
const [parentId] = getZoneId(zoneCompound);
|
534
|
+
if (parentId === item.props.id) {
|
535
|
+
const newPath = [...path, zoneCompound];
|
536
|
+
content.forEach((item2) => forRelatedZones(item2, data, cb, newPath));
|
537
|
+
cb(path, zoneCompound, content);
|
538
|
+
}
|
539
|
+
});
|
540
|
+
}
|
541
|
+
|
542
|
+
// ../core/lib/strip-slots.ts
|
543
|
+
init_react_import();
|
544
|
+
var stripSlots = (data) => {
|
800
545
|
return __spreadProps(__spreadValues({}, data), {
|
801
|
-
|
802
|
-
(acc,
|
803
|
-
|
804
|
-
|
805
|
-
const zones = data.zones;
|
806
|
-
return fn(acc, key, zones[key]);
|
546
|
+
props: Object.entries(data.props).reduce(
|
547
|
+
(acc, [propKey, propVal]) => {
|
548
|
+
if (isSlot(propVal)) {
|
549
|
+
return acc;
|
807
550
|
}
|
808
|
-
return __spreadProps(__spreadValues({}, acc), { [
|
551
|
+
return __spreadProps(__spreadValues({}, acc), { [propKey]: propVal });
|
809
552
|
},
|
810
|
-
{}
|
553
|
+
{ id: data.props.id }
|
811
554
|
)
|
812
555
|
});
|
813
|
-
}
|
814
|
-
var findRelatedByZoneId = (zoneId, data) => {
|
815
|
-
const [zoneParentId] = getZoneId(zoneId);
|
816
|
-
return (data.zones[zoneId] || []).reduce(
|
817
|
-
(acc, zoneItem) => {
|
818
|
-
const related = findRelatedByItem(zoneItem, data);
|
819
|
-
if (zoneItem.props.id === zoneParentId) {
|
820
|
-
return __spreadProps(__spreadValues(__spreadValues({}, acc), related), { [zoneId]: zoneItem });
|
821
|
-
}
|
822
|
-
return __spreadValues(__spreadValues({}, acc), related);
|
823
|
-
},
|
824
|
-
{}
|
825
|
-
);
|
826
556
|
};
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
557
|
+
|
558
|
+
// ../core/lib/walk-tree.ts
|
559
|
+
function walkTree(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
560
|
+
var _a;
|
561
|
+
let newZones = {};
|
562
|
+
const newZoneIndex = {};
|
563
|
+
const newNodeIndex = {};
|
564
|
+
const processContent = (path, zoneCompound, content, zoneType, newId) => {
|
565
|
+
var _a2;
|
566
|
+
const [parentId] = zoneCompound.split(":");
|
567
|
+
const mappedContent = ((_a2 = mapContent(content, zoneCompound, zoneType)) != null ? _a2 : content) || [];
|
568
|
+
const [_2, zone] = zoneCompound.split(":");
|
569
|
+
const newZoneCompound = `${newId || parentId}:${zone}`;
|
570
|
+
const newContent2 = mappedContent.map(
|
571
|
+
(zoneChild, index) => processItem(zoneChild, [...path, newZoneCompound], index)
|
572
|
+
);
|
573
|
+
newZoneIndex[newZoneCompound] = {
|
574
|
+
contentIds: newContent2.map((item) => item.props.id),
|
575
|
+
type: zoneType
|
576
|
+
};
|
577
|
+
return [newZoneCompound, newContent2];
|
578
|
+
};
|
579
|
+
const processRelatedZones = (item, newId, initialPath) => {
|
580
|
+
forRelatedZones(
|
581
|
+
item,
|
582
|
+
state.data,
|
583
|
+
(relatedPath, relatedZoneCompound, relatedContent) => {
|
584
|
+
const [zoneCompound, newContent2] = processContent(
|
585
|
+
relatedPath,
|
586
|
+
relatedZoneCompound,
|
587
|
+
relatedContent,
|
588
|
+
"dropzone",
|
589
|
+
newId
|
590
|
+
);
|
591
|
+
newZones[zoneCompound] = newContent2;
|
592
|
+
},
|
593
|
+
initialPath
|
594
|
+
);
|
595
|
+
};
|
596
|
+
const processItem = (item, path, index) => {
|
597
|
+
const mappedItem = mapNodeOrSkip(item, path, index);
|
598
|
+
if (!mappedItem) return item;
|
599
|
+
const id = mappedItem.props.id;
|
600
|
+
processRelatedZones(item, id, path);
|
601
|
+
const newProps = __spreadValues({}, mappedItem.props);
|
602
|
+
forEachSlot(
|
603
|
+
mappedItem,
|
604
|
+
(parentId2, slotId, content) => {
|
605
|
+
const zoneCompound = `${parentId2}:${slotId}`;
|
606
|
+
const [_2, newContent2] = processContent(
|
607
|
+
path,
|
608
|
+
zoneCompound,
|
609
|
+
content,
|
610
|
+
"slot",
|
611
|
+
parentId2
|
612
|
+
);
|
613
|
+
newProps[slotId] = newContent2;
|
614
|
+
},
|
615
|
+
false,
|
616
|
+
(itemType, propName, propValue) => {
|
617
|
+
var _a2, _b;
|
618
|
+
const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
|
619
|
+
if (!configForComponent) return isSlot(propValue);
|
620
|
+
return ((_b = (_a2 = configForComponent.fields) == null ? void 0 : _a2[propName]) == null ? void 0 : _b.type) === "slot";
|
836
621
|
}
|
837
|
-
|
622
|
+
);
|
623
|
+
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
|
624
|
+
const thisZoneCompound = path[path.length - 1];
|
625
|
+
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
626
|
+
newNodeIndex[id] = {
|
627
|
+
data: newItem,
|
628
|
+
flatData: stripSlots(newItem),
|
629
|
+
path,
|
630
|
+
parentId,
|
631
|
+
zone
|
632
|
+
};
|
633
|
+
const finalData = newItem;
|
634
|
+
if (newProps.id === "root") {
|
635
|
+
delete finalData["type"];
|
636
|
+
delete finalData.props["id"];
|
637
|
+
}
|
638
|
+
return finalData;
|
639
|
+
};
|
640
|
+
const zones = state.data.zones || {};
|
641
|
+
const [_, newContent] = processContent(
|
642
|
+
[],
|
643
|
+
rootDroppableId,
|
644
|
+
state.data.content,
|
645
|
+
"root"
|
646
|
+
);
|
647
|
+
const processedContent = newContent;
|
648
|
+
Object.keys(zones || {}).forEach((zoneCompound) => {
|
649
|
+
const [parentId] = zoneCompound.split(":");
|
650
|
+
const [_2, newContent2] = processContent(
|
651
|
+
[rootDroppableId],
|
652
|
+
zoneCompound,
|
653
|
+
zones[zoneCompound],
|
654
|
+
"dropzone",
|
655
|
+
parentId
|
656
|
+
);
|
657
|
+
newZones[zoneCompound] = newContent2;
|
658
|
+
}, newZones);
|
659
|
+
const processedRoot = processItem(
|
660
|
+
{
|
661
|
+
type: "root",
|
662
|
+
props: __spreadProps(__spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root), { id: "root" })
|
838
663
|
},
|
839
|
-
|
664
|
+
[],
|
665
|
+
-1
|
840
666
|
);
|
841
|
-
}
|
842
|
-
|
843
|
-
const newData = __spreadValues({}, data);
|
844
|
-
const related = findRelatedByItem(item, data);
|
845
|
-
Object.keys(related).forEach((key) => {
|
846
|
-
delete newData.zones[key];
|
667
|
+
const root = __spreadProps(__spreadValues({}, state.data.root), {
|
668
|
+
props: processedRoot.props
|
847
669
|
});
|
848
|
-
return
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
}
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
const [_, zoneId] = getZoneId(key);
|
860
|
-
return __spreadProps(__spreadValues({}, dupeOfDupes), {
|
861
|
-
[key]: zone,
|
862
|
-
[`${newId}:${zoneId}`]: dupedZone
|
863
|
-
});
|
670
|
+
return __spreadProps(__spreadValues({}, state), {
|
671
|
+
data: {
|
672
|
+
root,
|
673
|
+
// 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.
|
674
|
+
content: processedContent,
|
675
|
+
zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
|
676
|
+
},
|
677
|
+
indexes: {
|
678
|
+
nodes: __spreadValues(__spreadValues({}, state.indexes.nodes), newNodeIndex),
|
679
|
+
zones: __spreadValues(__spreadValues({}, state.indexes.zones), newZoneIndex)
|
680
|
+
}
|
864
681
|
});
|
865
682
|
}
|
866
683
|
|
867
|
-
// ../core/
|
868
|
-
|
869
|
-
var
|
870
|
-
|
871
|
-
|
872
|
-
|
684
|
+
// ../core/lib/deindex.ts
|
685
|
+
init_react_import();
|
686
|
+
var deindex = (state, componentData) => {
|
687
|
+
let zones = __spreadValues({}, state.indexes.zones);
|
688
|
+
let nodes = __spreadValues({}, state.indexes.nodes);
|
689
|
+
const dindexRelatedZones = (item) => {
|
690
|
+
forRelatedZones(item, state.data, (_path, zoneCompound, content) => {
|
691
|
+
content.forEach((subItem) => {
|
692
|
+
dindexChildren(subItem);
|
693
|
+
delete nodes[subItem.props.id];
|
694
|
+
});
|
695
|
+
delete zones[zoneCompound];
|
873
696
|
});
|
874
|
-
}
|
875
|
-
const
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
697
|
+
};
|
698
|
+
const dindexChildren = (item) => {
|
699
|
+
forEachSlot(
|
700
|
+
item,
|
701
|
+
(parentId, slotId, content) => {
|
702
|
+
const zoneCompound = `${parentId}:${slotId}`;
|
703
|
+
delete zones[zoneCompound];
|
704
|
+
content.forEach((item2) => {
|
705
|
+
dindexRelatedZones(item2);
|
706
|
+
delete nodes[item2.props.id];
|
707
|
+
});
|
708
|
+
},
|
709
|
+
true
|
710
|
+
);
|
711
|
+
};
|
712
|
+
dindexRelatedZones(componentData);
|
713
|
+
dindexChildren(componentData);
|
714
|
+
delete nodes[componentData.props.id];
|
715
|
+
return { nodes, zones };
|
885
716
|
};
|
886
|
-
|
717
|
+
|
718
|
+
// ../core/reducer/reduce.ts
|
719
|
+
var zoneCache = {};
|
720
|
+
var getIdsForParent = (zoneCompound, state) => {
|
721
|
+
const [parentId] = zoneCompound.split(":");
|
722
|
+
const node = state.indexes.nodes[parentId];
|
723
|
+
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
|
724
|
+
};
|
725
|
+
function insertAction(state, action, config) {
|
726
|
+
const id = action.id || generateId(action.componentType);
|
887
727
|
const emptyComponentData = {
|
888
728
|
type: action.componentType,
|
889
729
|
props: __spreadProps(__spreadValues({}, config.components[action.componentType].defaultProps || {}), {
|
890
|
-
id
|
730
|
+
id
|
891
731
|
})
|
892
732
|
};
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
)
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
)
|
910
|
-
|
911
|
-
|
733
|
+
const [parentId] = action.destinationZone.split(":");
|
734
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
735
|
+
return walkTree(
|
736
|
+
state,
|
737
|
+
config,
|
738
|
+
(content, zoneCompound) => {
|
739
|
+
if (zoneCompound === action.destinationZone) {
|
740
|
+
return insert(
|
741
|
+
content || [],
|
742
|
+
action.destinationIndex,
|
743
|
+
emptyComponentData
|
744
|
+
);
|
745
|
+
}
|
746
|
+
return content;
|
747
|
+
},
|
748
|
+
(childItem, path) => {
|
749
|
+
if (childItem.props.id === id || childItem.props.id === parentId) {
|
750
|
+
return childItem;
|
751
|
+
} else if (idsInPath.includes(childItem.props.id)) {
|
752
|
+
return childItem;
|
753
|
+
} else if (path.includes(action.destinationZone)) {
|
754
|
+
return childItem;
|
755
|
+
}
|
756
|
+
return null;
|
757
|
+
}
|
758
|
+
);
|
912
759
|
}
|
913
|
-
var
|
914
|
-
if (action.destinationZone ===
|
915
|
-
return
|
916
|
-
content: reorder(
|
917
|
-
data.content,
|
918
|
-
action.sourceIndex,
|
919
|
-
action.destinationIndex
|
920
|
-
)
|
921
|
-
});
|
760
|
+
var moveAction = (state, action, appStore) => {
|
761
|
+
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
762
|
+
return state;
|
922
763
|
}
|
923
|
-
const
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
764
|
+
const item = getItem(
|
765
|
+
{ zone: action.sourceZone, index: action.sourceIndex },
|
766
|
+
state
|
767
|
+
);
|
768
|
+
if (!item) return state;
|
769
|
+
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
770
|
+
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
771
|
+
return walkTree(
|
772
|
+
state,
|
773
|
+
appStore.config,
|
774
|
+
(content, zoneCompound) => {
|
775
|
+
if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
|
776
|
+
return insert(
|
777
|
+
remove(content, action.sourceIndex),
|
778
|
+
action.destinationIndex,
|
779
|
+
item
|
780
|
+
);
|
781
|
+
} else if (zoneCompound === action.sourceZone) {
|
782
|
+
return remove(content, action.sourceIndex);
|
783
|
+
} else if (zoneCompound === action.destinationZone) {
|
784
|
+
return insert(content, action.destinationIndex, item);
|
785
|
+
}
|
786
|
+
return content;
|
787
|
+
},
|
788
|
+
(childItem, path) => {
|
789
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
790
|
+
const [destinationZoneParent] = action.destinationZone.split(":");
|
791
|
+
const childId = childItem.props.id;
|
792
|
+
if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1 || path.includes(action.destinationZone)) {
|
793
|
+
return childItem;
|
794
|
+
}
|
795
|
+
return null;
|
796
|
+
}
|
797
|
+
);
|
798
|
+
};
|
799
|
+
var replaceAction = (state, action, appStore) => {
|
800
|
+
const [parentId] = action.destinationZone.split(":");
|
801
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
802
|
+
return walkTree(
|
803
|
+
state,
|
804
|
+
appStore.config,
|
805
|
+
(content) => content,
|
806
|
+
(childItem, path) => {
|
807
|
+
const pathIds = path.map((p) => p.split(":")[0]);
|
808
|
+
if (childItem.props.id === action.data.props.id) {
|
809
|
+
return action.data;
|
810
|
+
} else if (childItem.props.id === parentId) {
|
811
|
+
return childItem;
|
812
|
+
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
813
|
+
return childItem;
|
814
|
+
} else if (pathIds.indexOf(action.data.props.id) > -1) {
|
815
|
+
return childItem;
|
816
|
+
}
|
817
|
+
return null;
|
818
|
+
}
|
819
|
+
);
|
820
|
+
};
|
821
|
+
var setAction = (state, action, appStore) => {
|
822
|
+
if (typeof action.state === "object") {
|
823
|
+
const newState = __spreadValues(__spreadValues({}, state), action.state);
|
824
|
+
if (action.state.indexes) {
|
825
|
+
console.warn(
|
826
|
+
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
827
|
+
);
|
828
|
+
return newState;
|
829
|
+
}
|
830
|
+
return walkTree(newState, appStore.config);
|
831
|
+
}
|
832
|
+
return __spreadValues(__spreadValues({}, state), action.state(state));
|
933
833
|
};
|
934
|
-
function
|
834
|
+
function reduce(state, action, appStore) {
|
835
|
+
if (action.type === "set") {
|
836
|
+
return setAction(state, action, appStore);
|
837
|
+
}
|
935
838
|
if (action.type === "insert") {
|
936
|
-
return insertAction(
|
839
|
+
return insertAction(state, action, appStore.config);
|
840
|
+
}
|
841
|
+
if (action.type === "replace") {
|
842
|
+
return replaceAction(state, action, appStore);
|
843
|
+
}
|
844
|
+
if (action.type === "replaceRoot") {
|
845
|
+
return walkTree(
|
846
|
+
state,
|
847
|
+
appStore.config,
|
848
|
+
(content) => content,
|
849
|
+
(childItem) => {
|
850
|
+
if (childItem.props.id === "root") {
|
851
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
852
|
+
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
853
|
+
readOnly: action.root.readOnly
|
854
|
+
});
|
855
|
+
}
|
856
|
+
return childItem;
|
857
|
+
}
|
858
|
+
);
|
937
859
|
}
|
938
860
|
if (action.type === "duplicate") {
|
939
861
|
const item = getItem(
|
940
862
|
{ index: action.sourceIndex, zone: action.sourceZone },
|
941
|
-
|
863
|
+
state
|
942
864
|
);
|
865
|
+
const idsInPath = getIdsForParent(action.sourceZone, state);
|
943
866
|
const newItem = __spreadProps(__spreadValues({}, item), {
|
944
867
|
props: __spreadProps(__spreadValues({}, item.props), {
|
945
868
|
id: generateId(item.type)
|
946
869
|
})
|
947
870
|
});
|
948
|
-
const
|
949
|
-
|
950
|
-
|
951
|
-
|
871
|
+
const modified = walkTree(
|
872
|
+
state,
|
873
|
+
appStore.config,
|
874
|
+
(content, zoneCompound) => {
|
875
|
+
if (zoneCompound === action.sourceZone) {
|
876
|
+
return insert(content, action.sourceIndex + 1, item);
|
877
|
+
}
|
878
|
+
return content;
|
879
|
+
},
|
880
|
+
(childItem, path, index) => {
|
881
|
+
const zoneCompound = path[path.length - 1];
|
882
|
+
const parents = path.map((p) => p.split(":")[0]);
|
883
|
+
if (parents.indexOf(newItem.props.id) > -1) {
|
884
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
885
|
+
props: __spreadProps(__spreadValues({}, childItem.props), {
|
886
|
+
id: generateId(childItem.type)
|
887
|
+
})
|
888
|
+
});
|
889
|
+
}
|
890
|
+
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
891
|
+
return newItem;
|
892
|
+
}
|
893
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
894
|
+
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
895
|
+
return childItem;
|
896
|
+
}
|
897
|
+
return null;
|
898
|
+
}
|
952
899
|
);
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
zones: __spreadProps(__spreadValues({}, dataWithRelatedDuplicated.zones), {
|
960
|
-
[action.sourceZone]: insert(
|
961
|
-
dataWithRelatedDuplicated.zones[action.sourceZone],
|
962
|
-
action.sourceIndex + 1,
|
963
|
-
newItem
|
964
|
-
)
|
900
|
+
return __spreadProps(__spreadValues({}, modified), {
|
901
|
+
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
902
|
+
itemSelector: {
|
903
|
+
index: action.sourceIndex + 1,
|
904
|
+
zone: action.sourceZone
|
905
|
+
}
|
965
906
|
})
|
966
907
|
});
|
967
908
|
}
|
968
909
|
if (action.type === "reorder") {
|
969
|
-
return
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
const item = getItem(
|
980
|
-
{ zone: action.sourceZone, index: action.sourceIndex },
|
981
|
-
newData
|
910
|
+
return moveAction(
|
911
|
+
state,
|
912
|
+
{
|
913
|
+
type: "move",
|
914
|
+
sourceIndex: action.sourceIndex,
|
915
|
+
sourceZone: action.destinationZone,
|
916
|
+
destinationIndex: action.destinationIndex,
|
917
|
+
destinationZone: action.destinationZone
|
918
|
+
},
|
919
|
+
appStore
|
982
920
|
);
|
983
|
-
if (action.sourceZone === action.destinationZone) {
|
984
|
-
return reorderAction(data, __spreadProps(__spreadValues({}, action), { type: "reorder" }));
|
985
|
-
}
|
986
|
-
if (action.sourceZone === rootDroppableId) {
|
987
|
-
return __spreadProps(__spreadValues({}, newData), {
|
988
|
-
content: remove(newData.content, action.sourceIndex),
|
989
|
-
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
990
|
-
[action.destinationZone]: insert(
|
991
|
-
newData.zones[action.destinationZone],
|
992
|
-
action.destinationIndex,
|
993
|
-
item
|
994
|
-
)
|
995
|
-
})
|
996
|
-
});
|
997
|
-
}
|
998
|
-
if (action.destinationZone === rootDroppableId) {
|
999
|
-
return __spreadProps(__spreadValues({}, newData), {
|
1000
|
-
content: insert(newData.content, action.destinationIndex, item),
|
1001
|
-
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
1002
|
-
[action.sourceZone]: remove(
|
1003
|
-
newData.zones[action.sourceZone],
|
1004
|
-
action.sourceIndex
|
1005
|
-
)
|
1006
|
-
})
|
1007
|
-
});
|
1008
|
-
}
|
1009
|
-
return __spreadProps(__spreadValues({}, newData), {
|
1010
|
-
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
1011
|
-
[action.sourceZone]: remove(
|
1012
|
-
newData.zones[action.sourceZone],
|
1013
|
-
action.sourceIndex
|
1014
|
-
),
|
1015
|
-
[action.destinationZone]: insert(
|
1016
|
-
newData.zones[action.destinationZone],
|
1017
|
-
action.destinationIndex,
|
1018
|
-
item
|
1019
|
-
)
|
1020
|
-
})
|
1021
|
-
});
|
1022
921
|
}
|
1023
|
-
if (action.type === "
|
1024
|
-
return
|
922
|
+
if (action.type === "move") {
|
923
|
+
return moveAction(state, action, appStore);
|
1025
924
|
}
|
1026
925
|
if (action.type === "remove") {
|
1027
|
-
const item = getItem({ index: action.index, zone: action.zone },
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
926
|
+
const item = getItem({ index: action.index, zone: action.zone }, state);
|
927
|
+
let deindexed = deindex(state, item);
|
928
|
+
const [parentId] = action.zone.split(":");
|
929
|
+
return walkTree(
|
930
|
+
__spreadProps(__spreadValues({}, state), { indexes: deindexed }),
|
931
|
+
appStore.config,
|
932
|
+
(content, zoneCompound) => {
|
933
|
+
if (zoneCompound === action.zone) {
|
934
|
+
return remove(content, action.index);
|
935
|
+
}
|
936
|
+
return content;
|
937
|
+
},
|
938
|
+
(childItem, path) => {
|
939
|
+
const parentIds = path.map((p) => p.split(":")[0]);
|
940
|
+
if (childItem.props.id === parentId || childItem.props.id === item.props.id || parentIds.indexOf(item.props.id) > -1) {
|
941
|
+
return childItem;
|
942
|
+
}
|
943
|
+
return null;
|
944
|
+
}
|
1031
945
|
);
|
1032
|
-
if (action.zone === rootDroppableId) {
|
1033
|
-
return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
|
1034
|
-
content: remove(data.content, action.index)
|
1035
|
-
});
|
1036
|
-
}
|
1037
|
-
return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
|
1038
|
-
zones: __spreadProps(__spreadValues({}, dataWithRelatedRemoved.zones), {
|
1039
|
-
[action.zone]: remove(
|
1040
|
-
dataWithRelatedRemoved.zones[action.zone],
|
1041
|
-
action.index
|
1042
|
-
)
|
1043
|
-
})
|
1044
|
-
});
|
1045
946
|
}
|
1046
947
|
if (action.type === "registerZone") {
|
1047
948
|
if (zoneCache[action.zone]) {
|
1048
|
-
return __spreadProps(__spreadValues({},
|
1049
|
-
|
1050
|
-
|
949
|
+
return __spreadProps(__spreadValues({}, state), {
|
950
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
951
|
+
zones: __spreadProps(__spreadValues({}, state.data.zones), {
|
952
|
+
[action.zone]: zoneCache[action.zone]
|
953
|
+
})
|
954
|
+
}),
|
955
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
956
|
+
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
|
957
|
+
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
|
958
|
+
contentIds: zoneCache[action.zone].map((item) => item.props.id),
|
959
|
+
type: "dropzone"
|
960
|
+
})
|
961
|
+
})
|
1051
962
|
})
|
1052
963
|
});
|
1053
964
|
}
|
1054
|
-
return setupZone(data, action.zone);
|
965
|
+
return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
|
1055
966
|
}
|
1056
967
|
if (action.type === "unregisterZone") {
|
1057
|
-
const _zones = __spreadValues({}, data.zones || {});
|
968
|
+
const _zones = __spreadValues({}, state.data.zones || {});
|
969
|
+
const zoneIndex = __spreadValues({}, state.indexes.zones || {});
|
1058
970
|
if (_zones[action.zone]) {
|
1059
971
|
zoneCache[action.zone] = _zones[action.zone];
|
1060
972
|
delete _zones[action.zone];
|
1061
973
|
}
|
1062
|
-
|
974
|
+
delete zoneIndex[action.zone];
|
975
|
+
return __spreadProps(__spreadValues({}, state), {
|
976
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
977
|
+
zones: _zones
|
978
|
+
}),
|
979
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
980
|
+
zones: zoneIndex
|
981
|
+
})
|
982
|
+
});
|
1063
983
|
}
|
1064
984
|
if (action.type === "setData") {
|
1065
985
|
if (typeof action.data === "object") {
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
}
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
var reduceUi = (ui, action) => {
|
1076
|
-
if (action.type === "setUi") {
|
1077
|
-
if (typeof action.ui === "object") {
|
1078
|
-
return __spreadValues(__spreadValues({}, ui), action.ui);
|
986
|
+
console.warn(
|
987
|
+
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
988
|
+
);
|
989
|
+
return walkTree(
|
990
|
+
__spreadProps(__spreadValues({}, state), {
|
991
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
992
|
+
}),
|
993
|
+
appStore.config
|
994
|
+
);
|
1079
995
|
}
|
1080
|
-
return
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
996
|
+
return walkTree(
|
997
|
+
__spreadProps(__spreadValues({}, state), {
|
998
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
999
|
+
}),
|
1000
|
+
appStore.config
|
1001
|
+
);
|
1086
1002
|
}
|
1087
|
-
if (action.type === "
|
1088
|
-
|
1089
|
-
|
1003
|
+
if (action.type === "setUi") {
|
1004
|
+
if (typeof action.ui === "object") {
|
1005
|
+
return __spreadProps(__spreadValues({}, state), {
|
1006
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
|
1007
|
+
});
|
1008
|
+
}
|
1009
|
+
return __spreadProps(__spreadValues({}, state), {
|
1010
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
|
1090
1011
|
});
|
1091
1012
|
}
|
1092
|
-
return
|
1093
|
-
}
|
1013
|
+
return state;
|
1014
|
+
}
|
1094
1015
|
|
1095
1016
|
// ../core/reducer/actions.tsx
|
1096
1017
|
init_react_import();
|
@@ -1113,25 +1034,15 @@ function storeInterceptor(reducer, record, onAction) {
|
|
1113
1034
|
return newAppState;
|
1114
1035
|
};
|
1115
1036
|
}
|
1116
|
-
var setAction = (state, action) => {
|
1117
|
-
if (typeof action.state === "object") {
|
1118
|
-
return __spreadValues(__spreadValues({}, state), action.state);
|
1119
|
-
}
|
1120
|
-
return __spreadValues(__spreadValues({}, state), action.state(state));
|
1121
|
-
};
|
1122
1037
|
function createReducer({
|
1123
|
-
config,
|
1124
1038
|
record,
|
1125
|
-
onAction
|
1039
|
+
onAction,
|
1040
|
+
appStore
|
1126
1041
|
}) {
|
1127
1042
|
return storeInterceptor(
|
1128
1043
|
(state, action) => {
|
1129
|
-
const
|
1130
|
-
|
1131
|
-
if (action.type === "set") {
|
1132
|
-
return setAction(state, action);
|
1133
|
-
}
|
1134
|
-
return { data, ui };
|
1044
|
+
const result = reduce(state, action, appStore);
|
1045
|
+
return result;
|
1135
1046
|
},
|
1136
1047
|
record,
|
1137
1048
|
onAction
|
@@ -1146,20 +1057,16 @@ var defaultViewports = [
|
|
1146
1057
|
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
1147
1058
|
];
|
1148
1059
|
|
1149
|
-
// ../../node_modules/zustand/esm/index.mjs
|
1150
|
-
init_react_import();
|
1151
|
-
|
1152
1060
|
// ../../node_modules/zustand/esm/vanilla.mjs
|
1153
1061
|
init_react_import();
|
1154
|
-
var import_meta = {};
|
1155
1062
|
var createStoreImpl = (createState) => {
|
1156
1063
|
let state;
|
1157
1064
|
const listeners = /* @__PURE__ */ new Set();
|
1158
|
-
const setState = (partial,
|
1065
|
+
const setState = (partial, replace) => {
|
1159
1066
|
const nextState = typeof partial === "function" ? partial(state) : partial;
|
1160
1067
|
if (!Object.is(nextState, state)) {
|
1161
1068
|
const previousState = state;
|
1162
|
-
state = (
|
1069
|
+
state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
|
1163
1070
|
listeners.forEach((listener) => listener(state, previousState));
|
1164
1071
|
}
|
1165
1072
|
};
|
@@ -1169,53 +1076,28 @@ var createStoreImpl = (createState) => {
|
|
1169
1076
|
listeners.add(listener);
|
1170
1077
|
return () => listeners.delete(listener);
|
1171
1078
|
};
|
1172
|
-
const
|
1173
|
-
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
1174
|
-
console.warn(
|
1175
|
-
"[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."
|
1176
|
-
);
|
1177
|
-
}
|
1178
|
-
listeners.clear();
|
1179
|
-
};
|
1180
|
-
const api = { setState, getState, getInitialState, subscribe, destroy };
|
1079
|
+
const api = { setState, getState, getInitialState, subscribe };
|
1181
1080
|
const initialState = state = createState(setState, getState, api);
|
1182
1081
|
return api;
|
1183
1082
|
};
|
1184
1083
|
var createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
|
1185
1084
|
|
1186
|
-
// ../../node_modules/zustand/esm/
|
1085
|
+
// ../../node_modules/zustand/esm/react.mjs
|
1086
|
+
init_react_import();
|
1187
1087
|
var import_react4 = __toESM(require("react"), 1);
|
1188
|
-
var import_with_selector = __toESM(require_with_selector(), 1);
|
1189
|
-
var import_meta2 = {};
|
1190
|
-
var { useDebugValue } = import_react4.default;
|
1191
|
-
var { useSyncExternalStoreWithSelector } = import_with_selector.default;
|
1192
|
-
var didWarnAboutEqualityFn = false;
|
1193
1088
|
var identity = (arg) => arg;
|
1194
|
-
function useStore(api, selector = identity
|
1195
|
-
|
1196
|
-
console.warn(
|
1197
|
-
"[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"
|
1198
|
-
);
|
1199
|
-
didWarnAboutEqualityFn = true;
|
1200
|
-
}
|
1201
|
-
const slice = useSyncExternalStoreWithSelector(
|
1089
|
+
function useStore(api, selector = identity) {
|
1090
|
+
const slice = import_react4.default.useSyncExternalStore(
|
1202
1091
|
api.subscribe,
|
1203
|
-
api.getState,
|
1204
|
-
|
1205
|
-
selector,
|
1206
|
-
equalityFn
|
1092
|
+
() => selector(api.getState()),
|
1093
|
+
() => selector(api.getInitialState())
|
1207
1094
|
);
|
1208
|
-
useDebugValue(slice);
|
1095
|
+
import_react4.default.useDebugValue(slice);
|
1209
1096
|
return slice;
|
1210
1097
|
}
|
1211
1098
|
var createImpl = (createState) => {
|
1212
|
-
|
1213
|
-
|
1214
|
-
"[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`."
|
1215
|
-
);
|
1216
|
-
}
|
1217
|
-
const api = typeof createState === "function" ? createStore(createState) : createState;
|
1218
|
-
const useBoundStore = (selector, equalityFn) => useStore(api, selector, equalityFn);
|
1099
|
+
const api = createStore(createState);
|
1100
|
+
const useBoundStore = (selector) => useStore(api, selector);
|
1219
1101
|
Object.assign(useBoundStore, api);
|
1220
1102
|
return useBoundStore;
|
1221
1103
|
};
|
@@ -1248,208 +1130,8 @@ var subscribeWithSelectorImpl = (fn) => (set, get, api) => {
|
|
1248
1130
|
};
|
1249
1131
|
var subscribeWithSelector = subscribeWithSelectorImpl;
|
1250
1132
|
|
1251
|
-
// ../core/lib/resolve-data.ts
|
1252
|
-
init_react_import();
|
1253
|
-
|
1254
|
-
// ../core/lib/resolve-component-data.ts
|
1255
|
-
init_react_import();
|
1256
|
-
|
1257
|
-
// ../core/lib/get-changed.ts
|
1258
|
-
init_react_import();
|
1259
|
-
var getChanged = (newItem, oldItem) => {
|
1260
|
-
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
1261
|
-
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
1262
|
-
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
1263
|
-
return __spreadProps(__spreadValues({}, acc), {
|
1264
|
-
[item]: oldItemProps[item] !== newItemProps[item]
|
1265
|
-
});
|
1266
|
-
}, {}) : {};
|
1267
|
-
};
|
1268
|
-
|
1269
|
-
// ../core/lib/resolve-component-data.ts
|
1270
|
-
var cache = { lastChange: {} };
|
1271
|
-
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd) {
|
1272
|
-
const configForItem = config.components[item.type];
|
1273
|
-
if (configForItem.resolveData) {
|
1274
|
-
const { item: oldItem = null, resolved = {} } = cache.lastChange[item.props.id] || {};
|
1275
|
-
if (item && item === oldItem) {
|
1276
|
-
return resolved;
|
1277
|
-
}
|
1278
|
-
const changed = getChanged(item, oldItem);
|
1279
|
-
if (onResolveStart) {
|
1280
|
-
onResolveStart(item);
|
1281
|
-
}
|
1282
|
-
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
1283
|
-
changed,
|
1284
|
-
lastData: oldItem,
|
1285
|
-
metadata
|
1286
|
-
});
|
1287
|
-
const resolvedItem = __spreadProps(__spreadValues({}, item), {
|
1288
|
-
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
1289
|
-
});
|
1290
|
-
if (Object.keys(readOnly).length) {
|
1291
|
-
resolvedItem.readOnly = readOnly;
|
1292
|
-
}
|
1293
|
-
cache.lastChange[item.props.id] = {
|
1294
|
-
item,
|
1295
|
-
resolved: resolvedItem
|
1296
|
-
};
|
1297
|
-
if (onResolveEnd) {
|
1298
|
-
onResolveEnd(resolvedItem);
|
1299
|
-
}
|
1300
|
-
return resolvedItem;
|
1301
|
-
}
|
1302
|
-
return item;
|
1303
|
-
});
|
1304
|
-
|
1305
|
-
// ../core/lib/apply-dynamic-props.ts
|
1306
|
-
init_react_import();
|
1307
|
-
var applyDynamicProps = (data, dynamicProps, rootData) => {
|
1308
|
-
return __spreadProps(__spreadValues({}, data), {
|
1309
|
-
root: rootData ? __spreadValues(__spreadValues({}, data.root), rootData ? rootData : {}) : data.root,
|
1310
|
-
content: data.content.map((item) => {
|
1311
|
-
return dynamicProps[item.props.id] ? __spreadValues(__spreadValues({}, item), dynamicProps[item.props.id]) : item;
|
1312
|
-
}),
|
1313
|
-
zones: Object.keys(data.zones || {}).reduce((acc, zoneKey) => {
|
1314
|
-
return __spreadProps(__spreadValues({}, acc), {
|
1315
|
-
[zoneKey]: data.zones[zoneKey].map((item) => {
|
1316
|
-
return dynamicProps[item.props.id] ? __spreadValues(__spreadValues({}, item), dynamicProps[item.props.id]) : item;
|
1317
|
-
})
|
1318
|
-
});
|
1319
|
-
}, {})
|
1320
|
-
});
|
1321
|
-
};
|
1322
|
-
|
1323
|
-
// ../core/lib/resolve-root-data.ts
|
1324
|
-
init_react_import();
|
1325
|
-
var cache2 = {};
|
1326
|
-
function resolveRootData(data, config, metadata) {
|
1327
|
-
return __async(this, null, function* () {
|
1328
|
-
var _a, _b, _c, _d, _e;
|
1329
|
-
if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
|
1330
|
-
if (((_b = cache2.lastChange) == null ? void 0 : _b.original) === data.root) {
|
1331
|
-
return cache2.lastChange.resolved;
|
1332
|
-
}
|
1333
|
-
const changed = getChanged(data.root, (_c = cache2.lastChange) == null ? void 0 : _c.original);
|
1334
|
-
const rootWithProps = data.root;
|
1335
|
-
const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
|
1336
|
-
changed,
|
1337
|
-
lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {},
|
1338
|
-
metadata: metadata || {}
|
1339
|
-
});
|
1340
|
-
cache2.lastChange = {
|
1341
|
-
original: data.root,
|
1342
|
-
resolved: resolvedRoot
|
1343
|
-
};
|
1344
|
-
return __spreadProps(__spreadValues(__spreadValues({}, data.root), resolvedRoot), {
|
1345
|
-
props: __spreadValues(__spreadValues({}, data.root.props), resolvedRoot.props)
|
1346
|
-
});
|
1347
|
-
}
|
1348
|
-
return data.root;
|
1349
|
-
});
|
1350
|
-
}
|
1351
|
-
|
1352
|
-
// ../core/lib/flatten-data.ts
|
1353
|
-
init_react_import();
|
1354
|
-
var flattenData = (data) => {
|
1355
|
-
return Object.keys(data.zones || {}).reduce(
|
1356
|
-
(acc, zone) => [...acc, ...data.zones[zone]],
|
1357
|
-
data.content
|
1358
|
-
);
|
1359
|
-
};
|
1360
|
-
|
1361
|
-
// ../core/lib/resolve-data.ts
|
1362
|
-
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1363
|
-
var resolveData = (newAppState, appStoreData) => {
|
1364
|
-
const {
|
1365
|
-
state: appState,
|
1366
|
-
config,
|
1367
|
-
dispatch,
|
1368
|
-
resolveDataRuns,
|
1369
|
-
setComponentLoading,
|
1370
|
-
unsetComponentLoading,
|
1371
|
-
metadata,
|
1372
|
-
permissions
|
1373
|
-
} = appStoreData;
|
1374
|
-
const deferredSetStates = {};
|
1375
|
-
const _setComponentLoading = (id, loading, defer = 0) => {
|
1376
|
-
if (deferredSetStates[id]) {
|
1377
|
-
clearTimeout(deferredSetStates[id]);
|
1378
|
-
delete deferredSetStates[id];
|
1379
|
-
}
|
1380
|
-
deferredSetStates[id] = setTimeout(() => {
|
1381
|
-
if (loading) {
|
1382
|
-
setComponentLoading(id);
|
1383
|
-
} else {
|
1384
|
-
unsetComponentLoading(id);
|
1385
|
-
}
|
1386
|
-
delete deferredSetStates[id];
|
1387
|
-
}, defer);
|
1388
|
-
};
|
1389
|
-
const runResolvers = () => __async(void 0, null, function* () {
|
1390
|
-
const newData = newAppState.data;
|
1391
|
-
const flatContent = flattenData(newData).filter(
|
1392
|
-
(item) => {
|
1393
|
-
var _a;
|
1394
|
-
return !!((_a = config.components[item.type]) == null ? void 0 : _a.resolveData);
|
1395
|
-
}
|
1396
|
-
);
|
1397
|
-
const applyIfChange = (dynamicDataMap, dynamicRoot) => {
|
1398
|
-
const processed = applyDynamicProps(
|
1399
|
-
__spreadValues({}, appState.data),
|
1400
|
-
dynamicDataMap,
|
1401
|
-
dynamicRoot
|
1402
|
-
);
|
1403
|
-
const processedAppState = __spreadProps(__spreadValues({}, appState), { data: processed });
|
1404
|
-
const containsChanges = !(0, import_fast_deep_equal.default)(appState, processedAppState);
|
1405
|
-
if (containsChanges) {
|
1406
|
-
dispatch({
|
1407
|
-
type: "set",
|
1408
|
-
state: (prev) => __spreadProps(__spreadValues({}, prev), {
|
1409
|
-
data: applyDynamicProps(prev.data, dynamicDataMap, dynamicRoot),
|
1410
|
-
ui: resolveDataRuns > 0 ? __spreadValues(__spreadValues({}, prev.ui), newAppState.ui) : prev.ui
|
1411
|
-
}),
|
1412
|
-
recordHistory: resolveDataRuns > 0
|
1413
|
-
});
|
1414
|
-
}
|
1415
|
-
};
|
1416
|
-
const promises = [];
|
1417
|
-
promises.push(
|
1418
|
-
(() => __async(void 0, null, function* () {
|
1419
|
-
_setComponentLoading("puck-root", true, 50);
|
1420
|
-
const dynamicRoot = yield resolveRootData(newData, config, metadata);
|
1421
|
-
applyIfChange({}, dynamicRoot);
|
1422
|
-
_setComponentLoading("puck-root", false);
|
1423
|
-
}))()
|
1424
|
-
);
|
1425
|
-
flatContent.forEach((item) => {
|
1426
|
-
promises.push(
|
1427
|
-
(() => __async(void 0, null, function* () {
|
1428
|
-
permissions.resolvePermissions({ item }, true);
|
1429
|
-
const dynamicData = yield resolveComponentData(
|
1430
|
-
item,
|
1431
|
-
config,
|
1432
|
-
metadata,
|
1433
|
-
(item2) => {
|
1434
|
-
_setComponentLoading(item2.props.id, true, 50);
|
1435
|
-
},
|
1436
|
-
(item2) => {
|
1437
|
-
deferredSetStates[item2.props.id];
|
1438
|
-
_setComponentLoading(item2.props.id, false);
|
1439
|
-
}
|
1440
|
-
);
|
1441
|
-
const dynamicDataMap = { [item.props.id]: dynamicData };
|
1442
|
-
applyIfChange(dynamicDataMap);
|
1443
|
-
}))()
|
1444
|
-
);
|
1445
|
-
});
|
1446
|
-
yield Promise.all(promises);
|
1447
|
-
});
|
1448
|
-
return runResolvers();
|
1449
|
-
};
|
1450
|
-
|
1451
1133
|
// ../core/store/index.ts
|
1452
|
-
var
|
1134
|
+
var import_react9 = require("react");
|
1453
1135
|
|
1454
1136
|
// ../core/store/slices/history.ts
|
1455
1137
|
init_react_import();
|
@@ -1565,31 +1247,14 @@ var createHistorySlice = (set, get) => {
|
|
1565
1247
|
|
1566
1248
|
// ../core/store/slices/nodes.ts
|
1567
1249
|
init_react_import();
|
1568
|
-
var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
|
1569
|
-
var import_react7 = require("react");
|
1570
|
-
var partialDeepEqual = (newItem, existingItem) => {
|
1571
|
-
const filteredExistingItem = Object.keys(newItem).reduce(
|
1572
|
-
(acc, key) => __spreadProps(__spreadValues({}, acc), { [key]: existingItem[key] }),
|
1573
|
-
{}
|
1574
|
-
);
|
1575
|
-
return (0, import_fast_deep_equal2.default)(newItem, filteredExistingItem);
|
1576
|
-
};
|
1577
1250
|
var createNodesSlice = (set, get) => ({
|
1578
1251
|
nodes: {},
|
1579
1252
|
registerNode: (id, node) => {
|
1580
1253
|
const s = get().nodes;
|
1581
|
-
if (s.nodes[id] && partialDeepEqual(node, s.nodes[id])) {
|
1582
|
-
return;
|
1583
|
-
}
|
1584
1254
|
const emptyNode = {
|
1585
1255
|
id,
|
1586
1256
|
methods: { sync: () => null },
|
1587
|
-
|
1588
|
-
parentId: "",
|
1589
|
-
zone: "",
|
1590
|
-
path: [],
|
1591
|
-
element: null,
|
1592
|
-
index: -1
|
1257
|
+
element: null
|
1593
1258
|
};
|
1594
1259
|
const existingNode = s.nodes[id];
|
1595
1260
|
set({
|
@@ -1619,36 +1284,66 @@ var createNodesSlice = (set, get) => ({
|
|
1619
1284
|
|
1620
1285
|
// ../core/store/slices/permissions.ts
|
1621
1286
|
init_react_import();
|
1622
|
-
var
|
1287
|
+
var import_react7 = require("react");
|
1288
|
+
|
1289
|
+
// ../core/lib/flatten-data.ts
|
1290
|
+
init_react_import();
|
1291
|
+
var flattenData = (state, config) => {
|
1292
|
+
const data = [];
|
1293
|
+
walkTree(
|
1294
|
+
state,
|
1295
|
+
config,
|
1296
|
+
(content) => content,
|
1297
|
+
(item) => {
|
1298
|
+
data.push(item);
|
1299
|
+
return null;
|
1300
|
+
}
|
1301
|
+
);
|
1302
|
+
return data;
|
1303
|
+
};
|
1304
|
+
|
1305
|
+
// ../core/lib/get-changed.ts
|
1306
|
+
init_react_import();
|
1307
|
+
var getChanged = (newItem, oldItem) => {
|
1308
|
+
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
1309
|
+
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
1310
|
+
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
1311
|
+
return __spreadProps(__spreadValues({}, acc), {
|
1312
|
+
[item]: oldItemProps[item] !== newItemProps[item]
|
1313
|
+
});
|
1314
|
+
}, {}) : {};
|
1315
|
+
};
|
1316
|
+
|
1317
|
+
// ../core/store/slices/permissions.ts
|
1623
1318
|
var createPermissionsSlice = (set, get) => {
|
1624
1319
|
const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
|
1625
|
-
const { state, permissions } = get();
|
1626
|
-
const { cache:
|
1320
|
+
const { state, permissions, config } = get();
|
1321
|
+
const { cache: cache2, globalPermissions } = permissions;
|
1627
1322
|
const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
|
1628
1323
|
var _a, _b, _c;
|
1629
1324
|
const {
|
1630
|
-
config,
|
1325
|
+
config: config2,
|
1631
1326
|
state: appState,
|
1632
1327
|
setComponentLoading,
|
1633
1328
|
unsetComponentLoading
|
1634
1329
|
} = get();
|
1635
|
-
const componentConfig = item2.type === "root" ?
|
1330
|
+
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
1636
1331
|
if (!componentConfig) {
|
1637
1332
|
return;
|
1638
1333
|
}
|
1639
1334
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
1640
1335
|
if (componentConfig.resolvePermissions) {
|
1641
|
-
const changed = getChanged(item2, (_a =
|
1336
|
+
const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
|
1642
1337
|
if (Object.values(changed).some((el) => el === true) || force2) {
|
1643
1338
|
setComponentLoading(item2.props.id);
|
1644
1339
|
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
1645
1340
|
item2,
|
1646
1341
|
{
|
1647
1342
|
changed,
|
1648
|
-
lastPermissions: ((_b =
|
1343
|
+
lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
|
1649
1344
|
permissions: initialPermissions,
|
1650
1345
|
appState,
|
1651
|
-
lastData: ((_c =
|
1346
|
+
lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
|
1652
1347
|
}
|
1653
1348
|
);
|
1654
1349
|
const latest = get().permissions;
|
@@ -1684,14 +1379,14 @@ var createPermissionsSlice = (set, get) => {
|
|
1684
1379
|
if (item) {
|
1685
1380
|
yield resolveDataForItem(item, force);
|
1686
1381
|
} else if (type) {
|
1687
|
-
flattenData(state
|
1382
|
+
flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(void 0, null, function* () {
|
1688
1383
|
yield resolveDataForItem(item2, force);
|
1689
1384
|
}));
|
1690
1385
|
} else if (root) {
|
1691
1386
|
resolveDataForRoot(force);
|
1692
1387
|
} else {
|
1693
1388
|
resolveDataForRoot(force);
|
1694
|
-
flattenData(state
|
1389
|
+
flattenData(state, config).map((item2) => __async(void 0, null, function* () {
|
1695
1390
|
yield resolveDataForItem(item2, force);
|
1696
1391
|
}));
|
1697
1392
|
}
|
@@ -1733,8 +1428,8 @@ var createPermissionsSlice = (set, get) => {
|
|
1733
1428
|
|
1734
1429
|
// ../core/store/slices/fields.ts
|
1735
1430
|
init_react_import();
|
1736
|
-
var
|
1737
|
-
var
|
1431
|
+
var import_react8 = require("react");
|
1432
|
+
var createFieldsSlice = (_set, _get) => {
|
1738
1433
|
return {
|
1739
1434
|
fields: {},
|
1740
1435
|
loading: false,
|
@@ -1742,6 +1437,106 @@ var createFieldsStore = (_set, _get) => {
|
|
1742
1437
|
};
|
1743
1438
|
};
|
1744
1439
|
|
1440
|
+
// ../core/lib/resolve-component-data.ts
|
1441
|
+
init_react_import();
|
1442
|
+
|
1443
|
+
// ../core/lib/map-slots.ts
|
1444
|
+
init_react_import();
|
1445
|
+
function mapSlots(item, map, recursive = true, isSlot2) {
|
1446
|
+
return __async(this, null, function* () {
|
1447
|
+
const props = __spreadValues({}, item.props);
|
1448
|
+
yield forEachSlot(
|
1449
|
+
item,
|
1450
|
+
(_parentId, propName, content) => __async(this, null, function* () {
|
1451
|
+
const mappedContent = recursive ? yield Promise.all(
|
1452
|
+
content.map((item2) => __async(this, null, function* () {
|
1453
|
+
return yield mapSlots(item2, map, recursive, isSlot2);
|
1454
|
+
}))
|
1455
|
+
) : content;
|
1456
|
+
props[propName] = yield map(mappedContent, propName);
|
1457
|
+
}),
|
1458
|
+
false,
|
1459
|
+
isSlot2
|
1460
|
+
);
|
1461
|
+
return __spreadProps(__spreadValues({}, item), { props });
|
1462
|
+
});
|
1463
|
+
}
|
1464
|
+
|
1465
|
+
// ../core/lib/resolve-component-data.ts
|
1466
|
+
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1467
|
+
var cache = { lastChange: {} };
|
1468
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
|
1469
|
+
const configForItem = "type" in item ? config.components[item.type] : config.root;
|
1470
|
+
if ((configForItem == null ? void 0 : configForItem.resolveData) && item.props) {
|
1471
|
+
const id = "id" in item.props ? item.props.id : "root";
|
1472
|
+
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
1473
|
+
if (item && item === oldItem) {
|
1474
|
+
return resolved;
|
1475
|
+
}
|
1476
|
+
const changed = getChanged(item, oldItem);
|
1477
|
+
if (onResolveStart) {
|
1478
|
+
onResolveStart(item);
|
1479
|
+
}
|
1480
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
1481
|
+
changed,
|
1482
|
+
lastData: oldItem,
|
1483
|
+
metadata,
|
1484
|
+
trigger
|
1485
|
+
});
|
1486
|
+
let resolvedItem = __spreadProps(__spreadValues({}, item), {
|
1487
|
+
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
1488
|
+
});
|
1489
|
+
if (recursive) {
|
1490
|
+
resolvedItem = yield mapSlots(resolvedItem, (content) => __async(void 0, null, function* () {
|
1491
|
+
return Promise.all(
|
1492
|
+
content.map(
|
1493
|
+
(childItem) => __async(void 0, null, function* () {
|
1494
|
+
return (yield resolveComponentData(
|
1495
|
+
childItem,
|
1496
|
+
config,
|
1497
|
+
metadata,
|
1498
|
+
onResolveStart,
|
1499
|
+
onResolveEnd,
|
1500
|
+
trigger,
|
1501
|
+
false
|
1502
|
+
)).node;
|
1503
|
+
})
|
1504
|
+
)
|
1505
|
+
);
|
1506
|
+
}));
|
1507
|
+
}
|
1508
|
+
if (Object.keys(readOnly).length) {
|
1509
|
+
resolvedItem.readOnly = readOnly;
|
1510
|
+
}
|
1511
|
+
cache.lastChange[id] = {
|
1512
|
+
item,
|
1513
|
+
resolved: resolvedItem
|
1514
|
+
};
|
1515
|
+
if (onResolveEnd) {
|
1516
|
+
onResolveEnd(resolvedItem);
|
1517
|
+
}
|
1518
|
+
return { node: resolvedItem, didChange: !(0, import_fast_deep_equal.default)(item, resolvedItem) };
|
1519
|
+
}
|
1520
|
+
return { node: item, didChange: false };
|
1521
|
+
});
|
1522
|
+
|
1523
|
+
// ../core/lib/to-root.ts
|
1524
|
+
init_react_import();
|
1525
|
+
var toRoot = (item) => {
|
1526
|
+
if ("type" in item && item.type !== "root") {
|
1527
|
+
throw new Error("Converting non-root item to root.");
|
1528
|
+
}
|
1529
|
+
const { readOnly } = item;
|
1530
|
+
if (item.props) {
|
1531
|
+
if ("id" in item.props) {
|
1532
|
+
const _a = item.props, { id } = _a, props = __objRest(_a, ["id"]);
|
1533
|
+
return { props, readOnly };
|
1534
|
+
}
|
1535
|
+
return { props: item.props, readOnly };
|
1536
|
+
}
|
1537
|
+
return { props: {}, readOnly };
|
1538
|
+
};
|
1539
|
+
|
1745
1540
|
// ../core/store/index.ts
|
1746
1541
|
var defaultAppState = {
|
1747
1542
|
data: { content: [], root: {}, zones: {} },
|
@@ -1762,6 +1557,10 @@ var defaultAppState = {
|
|
1762
1557
|
controlsVisible: true
|
1763
1558
|
},
|
1764
1559
|
field: { focus: null }
|
1560
|
+
},
|
1561
|
+
indexes: {
|
1562
|
+
nodes: {},
|
1563
|
+
zones: {}
|
1765
1564
|
}
|
1766
1565
|
};
|
1767
1566
|
var defaultPageFields = {
|
@@ -1784,7 +1583,7 @@ var createAppStore = (initialAppStore) => create()(
|
|
1784
1583
|
iframe: {},
|
1785
1584
|
metadata: {}
|
1786
1585
|
}, initialAppStore), {
|
1787
|
-
fields:
|
1586
|
+
fields: createFieldsSlice(set, get),
|
1788
1587
|
history: createHistorySlice(set, get),
|
1789
1588
|
nodes: createNodesSlice(set, get),
|
1790
1589
|
permissions: createPermissionsSlice(set, get),
|
@@ -1797,65 +1596,151 @@ var createAppStore = (initialAppStore) => create()(
|
|
1797
1596
|
dispatch: (action) => set((s) => {
|
1798
1597
|
var _a, _b;
|
1799
1598
|
const { record } = get().history;
|
1800
|
-
const dispatch = createReducer({
|
1599
|
+
const dispatch = createReducer({
|
1600
|
+
record,
|
1601
|
+
appStore: s
|
1602
|
+
});
|
1801
1603
|
const state = dispatch(s.state, action);
|
1802
|
-
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state
|
1604
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1803
1605
|
(_b = (_a = get()).onAction) == null ? void 0 : _b.call(_a, action, state, get().state);
|
1804
1606
|
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1805
1607
|
}),
|
1806
1608
|
setZoomConfig: (zoomConfig) => set({ zoomConfig }),
|
1807
1609
|
setStatus: (status) => set({ status }),
|
1808
1610
|
setComponentState: (componentState) => set({ componentState }),
|
1809
|
-
|
1810
|
-
|
1811
|
-
const { setComponentState,
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1611
|
+
pendingComponentLoads: {},
|
1612
|
+
setComponentLoading: (id, loading = true, defer = 0) => {
|
1613
|
+
const { setComponentState, pendingComponentLoads } = get();
|
1614
|
+
const thisPendingComponentLoads = __spreadValues({}, pendingComponentLoads);
|
1615
|
+
const setLoading = () => {
|
1616
|
+
var _a;
|
1617
|
+
const { componentState } = get();
|
1618
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1619
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1620
|
+
loadingCount: (((_a = componentState[id]) == null ? void 0 : _a.loadingCount) || 0) + 1
|
1621
|
+
})
|
1622
|
+
}));
|
1623
|
+
};
|
1624
|
+
const unsetLoading = () => {
|
1625
|
+
var _a;
|
1626
|
+
const { componentState } = get();
|
1627
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1628
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1629
|
+
loadingCount: Math.max(
|
1630
|
+
(((_a = componentState[id]) == null ? void 0 : _a.loadingCount) || 0) - 1,
|
1631
|
+
0
|
1632
|
+
)
|
1633
|
+
})
|
1634
|
+
}));
|
1635
|
+
};
|
1636
|
+
if (thisPendingComponentLoads[id]) {
|
1637
|
+
clearTimeout(thisPendingComponentLoads[id]);
|
1638
|
+
delete thisPendingComponentLoads[id];
|
1639
|
+
set({ pendingComponentLoads: thisPendingComponentLoads });
|
1640
|
+
}
|
1641
|
+
const timeout = setTimeout(() => {
|
1642
|
+
if (loading) {
|
1643
|
+
setLoading();
|
1644
|
+
} else {
|
1645
|
+
unsetLoading();
|
1646
|
+
}
|
1647
|
+
delete thisPendingComponentLoads[id];
|
1648
|
+
set({ pendingComponentLoads: thisPendingComponentLoads });
|
1649
|
+
}, defer);
|
1650
|
+
set({
|
1651
|
+
pendingComponentLoads: __spreadProps(__spreadValues({}, thisPendingComponentLoads), {
|
1652
|
+
[id]: timeout
|
1815
1653
|
})
|
1816
|
-
})
|
1654
|
+
});
|
1817
1655
|
},
|
1818
1656
|
unsetComponentLoading: (id) => {
|
1819
|
-
|
1820
|
-
|
1821
|
-
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1822
|
-
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1823
|
-
loadingCount: Math.max(
|
1824
|
-
(((_a = componentState[id]) == null ? void 0 : _a.loadingCount) || 0) - 1,
|
1825
|
-
0
|
1826
|
-
)
|
1827
|
-
})
|
1828
|
-
}));
|
1657
|
+
const { setComponentLoading } = get();
|
1658
|
+
setComponentLoading(id, false);
|
1829
1659
|
},
|
1830
1660
|
// Helper
|
1831
1661
|
setUi: (ui, recordHistory) => set((s) => {
|
1832
1662
|
const dispatch = createReducer({
|
1833
|
-
config: s.config,
|
1834
1663
|
record: () => {
|
1835
|
-
}
|
1664
|
+
},
|
1665
|
+
appStore: s
|
1836
1666
|
});
|
1837
1667
|
const state = dispatch(s.state, {
|
1838
1668
|
type: "setUi",
|
1839
1669
|
ui,
|
1840
1670
|
recordHistory
|
1841
1671
|
});
|
1842
|
-
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state
|
1672
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1843
1673
|
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1844
1674
|
}),
|
1845
|
-
resolveDataRuns: 0,
|
1846
|
-
resolveData: (newAppState) =>
|
1847
|
-
|
1848
|
-
|
1675
|
+
// resolveDataRuns: 0,
|
1676
|
+
// resolveData: (newAppState) =>
|
1677
|
+
// set((s) => {
|
1678
|
+
// resolveData(newAppState, get);
|
1679
|
+
// return { ...s, resolveDataRuns: s.resolveDataRuns + 1 };
|
1680
|
+
// }),
|
1681
|
+
resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
|
1682
|
+
const { config, metadata, setComponentLoading } = get();
|
1683
|
+
return yield resolveComponentData(
|
1684
|
+
componentData,
|
1685
|
+
config,
|
1686
|
+
metadata,
|
1687
|
+
(item) => setComponentLoading(
|
1688
|
+
"id" in item.props ? item.props.id : "root",
|
1689
|
+
true,
|
1690
|
+
50
|
1691
|
+
),
|
1692
|
+
(item) => setComponentLoading(
|
1693
|
+
"id" in item.props ? item.props.id : "root",
|
1694
|
+
false,
|
1695
|
+
0
|
1696
|
+
),
|
1697
|
+
trigger
|
1698
|
+
);
|
1699
|
+
}),
|
1700
|
+
resolveAndCommitData: () => __async(void 0, null, function* () {
|
1701
|
+
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
1702
|
+
walkTree(
|
1703
|
+
state,
|
1704
|
+
config,
|
1705
|
+
(content) => content,
|
1706
|
+
(childItem) => {
|
1707
|
+
resolveComponentData2(childItem, "load").then((resolved) => {
|
1708
|
+
const { state: state2 } = get();
|
1709
|
+
const node = state2.indexes.nodes[resolved.node.props.id];
|
1710
|
+
if (node && resolved.didChange) {
|
1711
|
+
if (resolved.node.props.id === "root") {
|
1712
|
+
dispatch({
|
1713
|
+
type: "replaceRoot",
|
1714
|
+
root: toRoot(resolved.node)
|
1715
|
+
});
|
1716
|
+
} else {
|
1717
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
1718
|
+
const parentZone = state2.indexes.zones[zoneCompound];
|
1719
|
+
const index = parentZone.contentIds.indexOf(
|
1720
|
+
resolved.node.props.id
|
1721
|
+
);
|
1722
|
+
dispatch({
|
1723
|
+
type: "replace",
|
1724
|
+
data: resolved.node,
|
1725
|
+
destinationIndex: index,
|
1726
|
+
destinationZone: zoneCompound
|
1727
|
+
});
|
1728
|
+
}
|
1729
|
+
}
|
1730
|
+
});
|
1731
|
+
return childItem;
|
1732
|
+
}
|
1733
|
+
);
|
1849
1734
|
})
|
1850
1735
|
}))
|
1851
1736
|
);
|
1852
|
-
var appStoreContext = (0,
|
1737
|
+
var appStoreContext = (0, import_react9.createContext)(createAppStore());
|
1853
1738
|
function useAppStore(selector) {
|
1854
|
-
const context = (0,
|
1739
|
+
const context = (0, import_react9.useContext)(appStoreContext);
|
1855
1740
|
return useStore(context, selector);
|
1856
1741
|
}
|
1857
1742
|
function useAppStoreApi() {
|
1858
|
-
return (0,
|
1743
|
+
return (0, import_react9.useContext)(appStoreContext);
|
1859
1744
|
}
|
1860
1745
|
|
1861
1746
|
// ../core/lib/use-breadcrumbs.ts
|
@@ -1867,12 +1752,12 @@ var useBreadcrumbs = (renderCount) => {
|
|
1867
1752
|
const config = useAppStore((s) => s.config);
|
1868
1753
|
const path = useAppStore((s) => {
|
1869
1754
|
var _a;
|
1870
|
-
return (_a = s.
|
1755
|
+
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
1871
1756
|
});
|
1872
1757
|
const appStore = useAppStoreApi();
|
1873
|
-
return (0,
|
1758
|
+
return (0, import_react10.useMemo)(() => {
|
1874
1759
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
1875
|
-
var _a, _b;
|
1760
|
+
var _a, _b, _c;
|
1876
1761
|
const [componentId] = zoneCompound.split(":");
|
1877
1762
|
if (componentId === "root") {
|
1878
1763
|
return {
|
@@ -1880,12 +1765,15 @@ var useBreadcrumbs = (renderCount) => {
|
|
1880
1765
|
selector: null
|
1881
1766
|
};
|
1882
1767
|
}
|
1883
|
-
const node = appStore.getState().
|
1884
|
-
const
|
1768
|
+
const node = appStore.getState().state.indexes.nodes[componentId];
|
1769
|
+
const parentId = node.path[node.path.length - 1];
|
1770
|
+
const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
|
1771
|
+
const index = contentIds.indexOf(componentId);
|
1772
|
+
const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
|
1885
1773
|
return {
|
1886
1774
|
label,
|
1887
1775
|
selector: node ? {
|
1888
|
-
index
|
1776
|
+
index,
|
1889
1777
|
zone: node.path[node.path.length - 1]
|
1890
1778
|
} : null
|
1891
1779
|
};
|
@@ -1906,6 +1794,12 @@ init_react_import();
|
|
1906
1794
|
// ../core/lib/filter.ts
|
1907
1795
|
init_react_import();
|
1908
1796
|
|
1797
|
+
// ../core/lib/reorder.ts
|
1798
|
+
init_react_import();
|
1799
|
+
|
1800
|
+
// ../core/lib/replace.ts
|
1801
|
+
init_react_import();
|
1802
|
+
|
1909
1803
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
|
1910
1804
|
init_react_import();
|
1911
1805
|
var styles_module_default3 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
|
@@ -2086,8 +1980,8 @@ function buildHierarchy(frame) {
|
|
2086
1980
|
var usePuck = (0, import_puck.createUsePuck)();
|
2087
1981
|
var HeadingAnalyzer = () => {
|
2088
1982
|
const data = usePuck((s) => s.appState.data);
|
2089
|
-
const [hierarchy, setHierarchy] = (0,
|
2090
|
-
(0,
|
1983
|
+
const [hierarchy, setHierarchy] = (0, import_react11.useState)([]);
|
1984
|
+
(0, import_react11.useEffect)(() => {
|
2091
1985
|
const frame = getFrame();
|
2092
1986
|
const entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
2093
1987
|
if (!entry) return;
|
@@ -2197,50 +2091,6 @@ classnames/index.js:
|
|
2197
2091
|
http://jedwatson.github.io/classnames
|
2198
2092
|
*)
|
2199
2093
|
|
2200
|
-
use-sync-external-store/cjs/use-sync-external-store-shim.production.js:
|
2201
|
-
(**
|
2202
|
-
* @license React
|
2203
|
-
* use-sync-external-store-shim.production.js
|
2204
|
-
*
|
2205
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
2206
|
-
*
|
2207
|
-
* This source code is licensed under the MIT license found in the
|
2208
|
-
* LICENSE file in the root directory of this source tree.
|
2209
|
-
*)
|
2210
|
-
|
2211
|
-
use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
|
2212
|
-
(**
|
2213
|
-
* @license React
|
2214
|
-
* use-sync-external-store-shim.development.js
|
2215
|
-
*
|
2216
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
2217
|
-
*
|
2218
|
-
* This source code is licensed under the MIT license found in the
|
2219
|
-
* LICENSE file in the root directory of this source tree.
|
2220
|
-
*)
|
2221
|
-
|
2222
|
-
use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js:
|
2223
|
-
(**
|
2224
|
-
* @license React
|
2225
|
-
* use-sync-external-store-shim/with-selector.production.js
|
2226
|
-
*
|
2227
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
2228
|
-
*
|
2229
|
-
* This source code is licensed under the MIT license found in the
|
2230
|
-
* LICENSE file in the root directory of this source tree.
|
2231
|
-
*)
|
2232
|
-
|
2233
|
-
use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
|
2234
|
-
(**
|
2235
|
-
* @license React
|
2236
|
-
* use-sync-external-store-shim/with-selector.development.js
|
2237
|
-
*
|
2238
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
2239
|
-
*
|
2240
|
-
* This source code is licensed under the MIT license found in the
|
2241
|
-
* LICENSE file in the root directory of this source tree.
|
2242
|
-
*)
|
2243
|
-
|
2244
2094
|
lucide-react/dist/esm/shared/src/utils.js:
|
2245
2095
|
(**
|
2246
2096
|
* @license lucide-react v0.468.0 - ISC
|