@measured/puck-plugin-heading-analyzer 0.19.0-canary.e62832e → 0.19.0-canary.e7f6a34e
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 +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +984 -1040
- package/dist/index.mjs +979 -1041
- package/package.json +3 -3
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,75 +368,247 @@ init_react_import();
|
|
651
368
|
// ../core/reducer/index.ts
|
652
369
|
init_react_import();
|
653
370
|
|
654
|
-
// ../core/reducer/
|
371
|
+
// ../core/reducer/actions/set.ts
|
655
372
|
init_react_import();
|
656
373
|
|
657
|
-
// ../core/lib/
|
374
|
+
// ../core/lib/data/walk-tree.ts
|
658
375
|
init_react_import();
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
376
|
+
|
377
|
+
// ../core/lib/data/for-each-slot.ts
|
378
|
+
init_react_import();
|
379
|
+
|
380
|
+
// ../core/lib/data/is-slot.ts
|
381
|
+
init_react_import();
|
382
|
+
var isSlot = (prop) => {
|
383
|
+
var _a, _b;
|
384
|
+
return Array.isArray(prop) && typeof ((_a = prop[0]) == null ? void 0 : _a.type) === "string" && typeof ((_b = prop[0]) == null ? void 0 : _b.props) === "object";
|
385
|
+
};
|
386
|
+
var createIsSlotConfig = (config) => (itemType, propName, propValue) => {
|
387
|
+
var _a, _b;
|
388
|
+
const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
|
389
|
+
if (!configForComponent) return isSlot(propValue);
|
390
|
+
return ((_b = (_a = configForComponent.fields) == null ? void 0 : _a[propName]) == null ? void 0 : _b.type) === "slot";
|
391
|
+
};
|
392
|
+
|
393
|
+
// ../core/lib/data/for-each-slot.ts
|
394
|
+
var forEachSlot = (item, cb, recursive = false, isSlot2 = isSlot) => {
|
395
|
+
const props = item.props || {};
|
396
|
+
const propKeys = Object.keys(props);
|
397
|
+
for (let i = 0; i < propKeys.length; i++) {
|
398
|
+
const propKey = propKeys[i];
|
399
|
+
const itemType = "type" in item ? item.type : "root";
|
400
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
401
|
+
const content = props[propKey];
|
402
|
+
cb(props.id, propKey, content);
|
403
|
+
if (recursive) {
|
404
|
+
content.forEach(
|
405
|
+
(childItem) => __async(void 0, null, function* () {
|
406
|
+
return forEachSlot(childItem, cb, true, isSlot2);
|
407
|
+
})
|
408
|
+
);
|
409
|
+
}
|
410
|
+
}
|
411
|
+
}
|
664
412
|
};
|
665
413
|
|
414
|
+
// ../core/lib/data/for-related-zones.ts
|
415
|
+
init_react_import();
|
416
|
+
|
417
|
+
// ../core/lib/get-zone-id.ts
|
418
|
+
init_react_import();
|
419
|
+
|
666
420
|
// ../core/lib/root-droppable-id.ts
|
667
421
|
init_react_import();
|
668
422
|
var rootAreaId = "root";
|
669
423
|
var rootZone = "default-zone";
|
670
424
|
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
671
425
|
|
672
|
-
// ../core/lib/
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
426
|
+
// ../core/lib/get-zone-id.ts
|
427
|
+
var getZoneId = (zoneCompound) => {
|
428
|
+
if (!zoneCompound) {
|
429
|
+
return [];
|
430
|
+
}
|
431
|
+
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
432
|
+
return zoneCompound.split(":");
|
433
|
+
}
|
434
|
+
return [rootDroppableId, zoneCompound];
|
678
435
|
};
|
679
436
|
|
680
|
-
// ../core/lib/
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
}
|
437
|
+
// ../core/lib/data/for-related-zones.ts
|
438
|
+
function forRelatedZones(item, data, cb, path = []) {
|
439
|
+
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
|
440
|
+
const [parentId] = getZoneId(zoneCompound);
|
441
|
+
if (parentId === item.props.id) {
|
442
|
+
cb(path, zoneCompound, content);
|
443
|
+
}
|
444
|
+
});
|
445
|
+
}
|
687
446
|
|
688
|
-
// ../core/lib/
|
447
|
+
// ../core/lib/data/strip-slots.ts
|
689
448
|
init_react_import();
|
690
|
-
var
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
449
|
+
var stripSlots = (data) => {
|
450
|
+
return __spreadProps(__spreadValues({}, data), {
|
451
|
+
props: Object.entries(data.props).reduce(
|
452
|
+
(acc, [propKey, propVal]) => {
|
453
|
+
if (isSlot(propVal)) {
|
454
|
+
return acc;
|
455
|
+
}
|
456
|
+
return __spreadProps(__spreadValues({}, acc), { [propKey]: propVal });
|
457
|
+
},
|
458
|
+
{ id: data.props.id }
|
459
|
+
)
|
696
460
|
});
|
697
|
-
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
698
|
-
return newData;
|
699
461
|
};
|
700
462
|
|
701
|
-
// ../core/lib/
|
702
|
-
|
703
|
-
var
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
463
|
+
// ../core/lib/data/walk-tree.ts
|
464
|
+
function walkTree(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
465
|
+
var _a;
|
466
|
+
let newZones = {};
|
467
|
+
const newZoneIndex = {};
|
468
|
+
const newNodeIndex = {};
|
469
|
+
const processContent = (path, zoneCompound, content, zoneType, newId) => {
|
470
|
+
var _a2;
|
471
|
+
const [parentId] = zoneCompound.split(":");
|
472
|
+
const mappedContent = ((_a2 = mapContent(content, zoneCompound, zoneType)) != null ? _a2 : content) || [];
|
473
|
+
const [_2, zone] = zoneCompound.split(":");
|
474
|
+
const newZoneCompound = `${newId || parentId}:${zone}`;
|
475
|
+
const newContent2 = mappedContent.map(
|
476
|
+
(zoneChild, index) => processItem(zoneChild, [...path, newZoneCompound], index)
|
477
|
+
);
|
478
|
+
newZoneIndex[newZoneCompound] = {
|
479
|
+
contentIds: newContent2.map((item) => item.props.id),
|
480
|
+
type: zoneType
|
481
|
+
};
|
482
|
+
return [newZoneCompound, newContent2];
|
483
|
+
};
|
484
|
+
const processRelatedZones = (item, newId, initialPath) => {
|
485
|
+
forRelatedZones(
|
486
|
+
item,
|
487
|
+
state.data,
|
488
|
+
(relatedPath, relatedZoneCompound, relatedContent) => {
|
489
|
+
const [zoneCompound, newContent2] = processContent(
|
490
|
+
relatedPath,
|
491
|
+
relatedZoneCompound,
|
492
|
+
relatedContent,
|
493
|
+
"dropzone",
|
494
|
+
newId
|
495
|
+
);
|
496
|
+
newZones[zoneCompound] = newContent2;
|
497
|
+
},
|
498
|
+
initialPath
|
499
|
+
);
|
500
|
+
};
|
501
|
+
const processItem = (item, path, index) => {
|
502
|
+
const mappedItem = mapNodeOrSkip(item, path, index);
|
503
|
+
if (!mappedItem) return item;
|
504
|
+
const id = mappedItem.props.id;
|
505
|
+
const newProps = __spreadValues({}, mappedItem.props);
|
506
|
+
forEachSlot(
|
507
|
+
mappedItem,
|
508
|
+
(parentId2, slotId, content) => {
|
509
|
+
const zoneCompound = `${parentId2}:${slotId}`;
|
510
|
+
const [_2, newContent2] = processContent(
|
511
|
+
path,
|
512
|
+
zoneCompound,
|
513
|
+
content,
|
514
|
+
"slot",
|
515
|
+
parentId2
|
516
|
+
);
|
517
|
+
newProps[slotId] = newContent2;
|
518
|
+
},
|
519
|
+
false,
|
520
|
+
createIsSlotConfig(config)
|
521
|
+
);
|
522
|
+
processRelatedZones(item, id, path);
|
523
|
+
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
|
524
|
+
const thisZoneCompound = path[path.length - 1];
|
525
|
+
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
526
|
+
newNodeIndex[id] = {
|
527
|
+
data: newItem,
|
528
|
+
flatData: stripSlots(newItem),
|
529
|
+
path,
|
530
|
+
parentId,
|
531
|
+
zone
|
532
|
+
};
|
533
|
+
const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
|
534
|
+
if (newProps.id === "root") {
|
535
|
+
delete finalData["type"];
|
536
|
+
delete finalData.props["id"];
|
537
|
+
}
|
538
|
+
return finalData;
|
539
|
+
};
|
540
|
+
const zones = state.data.zones || {};
|
541
|
+
const [_, newContent] = processContent(
|
542
|
+
[],
|
543
|
+
rootDroppableId,
|
544
|
+
state.data.content,
|
545
|
+
"root"
|
546
|
+
);
|
547
|
+
const processedContent = newContent;
|
548
|
+
const zonesAlreadyProcessed = Object.keys(newZones);
|
549
|
+
Object.keys(zones || {}).forEach((zoneCompound) => {
|
550
|
+
const [parentId] = zoneCompound.split(":");
|
551
|
+
if (zonesAlreadyProcessed.includes(zoneCompound)) {
|
552
|
+
return;
|
553
|
+
}
|
554
|
+
const [_2, newContent2] = processContent(
|
555
|
+
[rootDroppableId],
|
556
|
+
zoneCompound,
|
557
|
+
zones[zoneCompound],
|
558
|
+
"dropzone",
|
559
|
+
parentId
|
560
|
+
);
|
561
|
+
newZones[zoneCompound] = newContent2;
|
562
|
+
}, newZones);
|
563
|
+
const processedRoot = processItem(
|
564
|
+
{
|
565
|
+
type: "root",
|
566
|
+
props: __spreadProps(__spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root), { id: "root" })
|
567
|
+
},
|
568
|
+
[],
|
569
|
+
-1
|
570
|
+
);
|
571
|
+
const root = __spreadProps(__spreadValues({}, state.data.root), {
|
572
|
+
props: processedRoot.props
|
573
|
+
});
|
574
|
+
return __spreadProps(__spreadValues({}, state), {
|
575
|
+
data: {
|
576
|
+
root,
|
577
|
+
content: processedContent,
|
578
|
+
zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
|
579
|
+
},
|
580
|
+
indexes: {
|
581
|
+
nodes: __spreadValues(__spreadValues({}, state.indexes.nodes), newNodeIndex),
|
582
|
+
zones: __spreadValues(__spreadValues({}, state.indexes.zones), newZoneIndex)
|
583
|
+
}
|
584
|
+
});
|
585
|
+
}
|
586
|
+
|
587
|
+
// ../core/reducer/actions/set.ts
|
588
|
+
var setAction = (state, action, appStore) => {
|
589
|
+
if (typeof action.state === "object") {
|
590
|
+
const newState = __spreadValues(__spreadValues({}, state), action.state);
|
591
|
+
if (action.state.indexes) {
|
592
|
+
return newState;
|
593
|
+
}
|
594
|
+
console.warn(
|
595
|
+
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
596
|
+
);
|
597
|
+
return walkTree(newState, appStore.config);
|
598
|
+
}
|
599
|
+
return __spreadValues(__spreadValues({}, state), action.state(state));
|
708
600
|
};
|
709
601
|
|
710
|
-
// ../core/
|
602
|
+
// ../core/reducer/actions/insert.ts
|
711
603
|
init_react_import();
|
712
|
-
function getItem(selector, data, dynamicProps = {}) {
|
713
|
-
if (!selector.zone || selector.zone === rootDroppableId) {
|
714
|
-
const item2 = data.content[selector.index];
|
715
|
-
return (item2 == null ? void 0 : item2.props) ? __spreadProps(__spreadValues({}, item2), { props: dynamicProps[item2.props.id] || item2.props }) : void 0;
|
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;
|
719
|
-
}
|
720
604
|
|
721
|
-
// ../core/lib/
|
605
|
+
// ../core/lib/data/insert.ts
|
722
606
|
init_react_import();
|
607
|
+
var insert = (list, index, item) => {
|
608
|
+
const result = Array.from(list || []);
|
609
|
+
result.splice(index, 0, item);
|
610
|
+
return result;
|
611
|
+
};
|
723
612
|
|
724
613
|
// ../core/lib/generate-id.ts
|
725
614
|
init_react_import();
|
@@ -783,313 +672,378 @@ var v4_default = v4;
|
|
783
672
|
// ../core/lib/generate-id.ts
|
784
673
|
var generateId = (type) => type ? `${type}-${v4_default()}` : v4_default();
|
785
674
|
|
786
|
-
// ../core/lib/get-
|
675
|
+
// ../core/lib/data/get-ids-for-parent.ts
|
787
676
|
init_react_import();
|
788
|
-
var
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
793
|
-
return zoneCompound.split(":");
|
794
|
-
}
|
795
|
-
return [rootDroppableId, zoneCompound];
|
677
|
+
var getIdsForParent = (zoneCompound, state) => {
|
678
|
+
const [parentId] = zoneCompound.split(":");
|
679
|
+
const node = state.indexes.nodes[parentId];
|
680
|
+
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
|
796
681
|
};
|
797
682
|
|
798
|
-
// ../core/
|
799
|
-
function
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
683
|
+
// ../core/reducer/actions/insert.ts
|
684
|
+
function insertAction(state, action, appStore) {
|
685
|
+
const id = action.id || generateId(action.componentType);
|
686
|
+
const emptyComponentData = {
|
687
|
+
type: action.componentType,
|
688
|
+
props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
|
689
|
+
id
|
690
|
+
})
|
691
|
+
};
|
692
|
+
const [parentId] = action.destinationZone.split(":");
|
693
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
694
|
+
return walkTree(
|
695
|
+
state,
|
696
|
+
appStore.config,
|
697
|
+
(content, zoneCompound) => {
|
698
|
+
if (zoneCompound === action.destinationZone) {
|
699
|
+
return insert(
|
700
|
+
content || [],
|
701
|
+
action.destinationIndex,
|
702
|
+
emptyComponentData
|
703
|
+
);
|
704
|
+
}
|
705
|
+
return content;
|
706
|
+
},
|
707
|
+
(childItem, path) => {
|
708
|
+
if (childItem.props.id === id || childItem.props.id === parentId) {
|
709
|
+
return childItem;
|
710
|
+
} else if (idsInPath.includes(childItem.props.id)) {
|
711
|
+
return childItem;
|
712
|
+
} else if (path.includes(action.destinationZone)) {
|
713
|
+
return childItem;
|
714
|
+
}
|
715
|
+
return null;
|
716
|
+
}
|
717
|
+
);
|
813
718
|
}
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
719
|
+
|
720
|
+
// ../core/reducer/actions/replace.ts
|
721
|
+
init_react_import();
|
722
|
+
var replaceAction = (state, action, appStore) => {
|
723
|
+
const [parentId] = action.destinationZone.split(":");
|
724
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
725
|
+
const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
|
726
|
+
const idChanged = originalId !== action.data.props.id;
|
727
|
+
if (idChanged) {
|
728
|
+
throw new Error(
|
729
|
+
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
730
|
+
);
|
731
|
+
}
|
732
|
+
return walkTree(
|
733
|
+
state,
|
734
|
+
appStore.config,
|
735
|
+
(content, zoneCompound) => {
|
736
|
+
const newContent = [...content];
|
737
|
+
if (zoneCompound === action.destinationZone) {
|
738
|
+
newContent[action.destinationIndex] = action.data;
|
821
739
|
}
|
822
|
-
return
|
740
|
+
return newContent;
|
823
741
|
},
|
824
|
-
{
|
742
|
+
(childItem, path) => {
|
743
|
+
const pathIds = path.map((p) => p.split(":")[0]);
|
744
|
+
if (childItem.props.id === action.data.props.id) {
|
745
|
+
return action.data;
|
746
|
+
} else if (childItem.props.id === parentId) {
|
747
|
+
return childItem;
|
748
|
+
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
749
|
+
return childItem;
|
750
|
+
} else if (pathIds.indexOf(action.data.props.id) > -1) {
|
751
|
+
return childItem;
|
752
|
+
}
|
753
|
+
return null;
|
754
|
+
}
|
825
755
|
);
|
826
756
|
};
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
757
|
+
|
758
|
+
// ../core/reducer/actions/replace-root.ts
|
759
|
+
init_react_import();
|
760
|
+
var replaceRootAction = (state, action, appStore) => {
|
761
|
+
return walkTree(
|
762
|
+
state,
|
763
|
+
appStore.config,
|
764
|
+
(content) => content,
|
765
|
+
(childItem) => {
|
766
|
+
if (childItem.props.id === "root") {
|
767
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
768
|
+
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
769
|
+
readOnly: action.root.readOnly
|
835
770
|
});
|
836
771
|
}
|
837
|
-
return
|
838
|
-
}
|
839
|
-
{}
|
772
|
+
return childItem;
|
773
|
+
}
|
840
774
|
);
|
841
775
|
};
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
return
|
852
|
-
const dupedZone = zone.map((zoneItem) => __spreadProps(__spreadValues({}, zoneItem), {
|
853
|
-
props: __spreadProps(__spreadValues({}, zoneItem.props), { id: generateId(zoneItem.type) })
|
854
|
-
}));
|
855
|
-
const dupeOfDupes = dupedZone.reduce(
|
856
|
-
(dupeOfDupes2, item2, index) => __spreadValues(__spreadValues({}, dupeOfDupes2), duplicateRelatedZones(zone[index], data, item2.props.id).zones),
|
857
|
-
acc
|
858
|
-
);
|
859
|
-
const [_, zoneId] = getZoneId(key);
|
860
|
-
return __spreadProps(__spreadValues({}, dupeOfDupes), {
|
861
|
-
[key]: zone,
|
862
|
-
[`${newId}:${zoneId}`]: dupedZone
|
863
|
-
});
|
864
|
-
});
|
776
|
+
|
777
|
+
// ../core/reducer/actions/duplicate.ts
|
778
|
+
init_react_import();
|
779
|
+
|
780
|
+
// ../core/lib/data/get-item.ts
|
781
|
+
init_react_import();
|
782
|
+
function getItem(selector, state) {
|
783
|
+
var _a, _b;
|
784
|
+
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
785
|
+
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
865
786
|
}
|
866
787
|
|
867
|
-
// ../core/reducer/
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
}
|
875
|
-
|
876
|
-
|
877
|
-
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
878
|
-
[action.destinationZone]: replace(
|
879
|
-
newData.zones[action.destinationZone],
|
880
|
-
action.destinationIndex,
|
881
|
-
action.data
|
882
|
-
)
|
788
|
+
// ../core/reducer/actions/duplicate.ts
|
789
|
+
function duplicateAction(state, action, appStore) {
|
790
|
+
const item = getItem(
|
791
|
+
{ index: action.sourceIndex, zone: action.sourceZone },
|
792
|
+
state
|
793
|
+
);
|
794
|
+
const idsInPath = getIdsForParent(action.sourceZone, state);
|
795
|
+
const newItem = __spreadProps(__spreadValues({}, item), {
|
796
|
+
props: __spreadProps(__spreadValues({}, item.props), {
|
797
|
+
id: generateId(item.type)
|
883
798
|
})
|
884
799
|
});
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
800
|
+
const modified = walkTree(
|
801
|
+
state,
|
802
|
+
appStore.config,
|
803
|
+
(content, zoneCompound) => {
|
804
|
+
if (zoneCompound === action.sourceZone) {
|
805
|
+
return insert(content, action.sourceIndex + 1, item);
|
806
|
+
}
|
807
|
+
return content;
|
808
|
+
},
|
809
|
+
(childItem, path, index) => {
|
810
|
+
const zoneCompound = path[path.length - 1];
|
811
|
+
const parents = path.map((p) => p.split(":")[0]);
|
812
|
+
if (parents.indexOf(newItem.props.id) > -1) {
|
813
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
814
|
+
props: __spreadProps(__spreadValues({}, childItem.props), {
|
815
|
+
id: generateId(childItem.type)
|
816
|
+
})
|
817
|
+
});
|
818
|
+
}
|
819
|
+
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
820
|
+
return newItem;
|
821
|
+
}
|
822
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
823
|
+
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
824
|
+
return childItem;
|
825
|
+
}
|
826
|
+
return null;
|
827
|
+
}
|
828
|
+
);
|
829
|
+
return __spreadProps(__spreadValues({}, modified), {
|
830
|
+
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
831
|
+
itemSelector: {
|
832
|
+
index: action.sourceIndex + 1,
|
833
|
+
zone: action.sourceZone
|
834
|
+
}
|
910
835
|
})
|
911
836
|
});
|
912
837
|
}
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
const
|
924
|
-
|
925
|
-
|
926
|
-
[action.destinationZone]: reorder(
|
927
|
-
newData.zones[action.destinationZone],
|
928
|
-
action.sourceIndex,
|
929
|
-
action.destinationIndex
|
930
|
-
)
|
931
|
-
})
|
932
|
-
});
|
838
|
+
|
839
|
+
// ../core/reducer/actions/reorder.ts
|
840
|
+
init_react_import();
|
841
|
+
|
842
|
+
// ../core/reducer/actions/move.ts
|
843
|
+
init_react_import();
|
844
|
+
|
845
|
+
// ../core/lib/data/remove.ts
|
846
|
+
init_react_import();
|
847
|
+
var remove = (list, index) => {
|
848
|
+
const result = Array.from(list);
|
849
|
+
result.splice(index, 1);
|
850
|
+
return result;
|
933
851
|
};
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
const item = getItem(
|
940
|
-
{ index: action.sourceIndex, zone: action.sourceZone },
|
941
|
-
data
|
942
|
-
);
|
943
|
-
const newItem = __spreadProps(__spreadValues({}, item), {
|
944
|
-
props: __spreadProps(__spreadValues({}, item.props), {
|
945
|
-
id: generateId(item.type)
|
946
|
-
})
|
947
|
-
});
|
948
|
-
const dataWithRelatedDuplicated = duplicateRelatedZones(
|
949
|
-
item,
|
950
|
-
data,
|
951
|
-
newItem.props.id
|
952
|
-
);
|
953
|
-
if (action.sourceZone === rootDroppableId) {
|
954
|
-
return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
|
955
|
-
content: insert(data.content, action.sourceIndex + 1, newItem)
|
956
|
-
});
|
957
|
-
}
|
958
|
-
return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
|
959
|
-
zones: __spreadProps(__spreadValues({}, dataWithRelatedDuplicated.zones), {
|
960
|
-
[action.sourceZone]: insert(
|
961
|
-
dataWithRelatedDuplicated.zones[action.sourceZone],
|
962
|
-
action.sourceIndex + 1,
|
963
|
-
newItem
|
964
|
-
)
|
965
|
-
})
|
966
|
-
});
|
967
|
-
}
|
968
|
-
if (action.type === "reorder") {
|
969
|
-
return reorderAction(data, action);
|
852
|
+
|
853
|
+
// ../core/reducer/actions/move.ts
|
854
|
+
var moveAction = (state, action, appStore) => {
|
855
|
+
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
856
|
+
return state;
|
970
857
|
}
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
858
|
+
const item = getItem(
|
859
|
+
{ zone: action.sourceZone, index: action.sourceIndex },
|
860
|
+
state
|
861
|
+
);
|
862
|
+
if (!item) return state;
|
863
|
+
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
864
|
+
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
865
|
+
return walkTree(
|
866
|
+
state,
|
867
|
+
appStore.config,
|
868
|
+
(content, zoneCompound) => {
|
869
|
+
if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
|
870
|
+
return insert(
|
871
|
+
remove(content, action.sourceIndex),
|
872
|
+
action.destinationIndex,
|
873
|
+
item
|
874
|
+
);
|
875
|
+
} else if (zoneCompound === action.sourceZone) {
|
876
|
+
return remove(content, action.sourceIndex);
|
877
|
+
} else if (zoneCompound === action.destinationZone) {
|
878
|
+
return insert(content, action.destinationIndex, item);
|
879
|
+
}
|
880
|
+
return content;
|
881
|
+
},
|
882
|
+
(childItem, path) => {
|
883
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
884
|
+
const [destinationZoneParent] = action.destinationZone.split(":");
|
885
|
+
const childId = childItem.props.id;
|
886
|
+
if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1 || path.includes(action.destinationZone)) {
|
887
|
+
return childItem;
|
888
|
+
}
|
889
|
+
return null;
|
985
890
|
}
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
891
|
+
);
|
892
|
+
};
|
893
|
+
|
894
|
+
// ../core/reducer/actions/reorder.ts
|
895
|
+
var reorderAction = (state, action, appStore) => {
|
896
|
+
return moveAction(
|
897
|
+
state,
|
898
|
+
{
|
899
|
+
type: "move",
|
900
|
+
sourceIndex: action.sourceIndex,
|
901
|
+
sourceZone: action.destinationZone,
|
902
|
+
destinationIndex: action.destinationIndex,
|
903
|
+
destinationZone: action.destinationZone
|
904
|
+
},
|
905
|
+
appStore
|
906
|
+
);
|
907
|
+
};
|
908
|
+
|
909
|
+
// ../core/reducer/actions/remove.ts
|
910
|
+
init_react_import();
|
911
|
+
var removeAction = (state, action, appStore) => {
|
912
|
+
const item = getItem({ index: action.index, zone: action.zone }, state);
|
913
|
+
const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
|
914
|
+
(acc, [nodeId, nodeData]) => {
|
915
|
+
const pathIds = nodeData.path.map((p) => p.split(":")[0]);
|
916
|
+
if (pathIds.includes(item.props.id)) {
|
917
|
+
return [...acc, nodeId];
|
918
|
+
}
|
919
|
+
return acc;
|
920
|
+
},
|
921
|
+
[item.props.id]
|
922
|
+
);
|
923
|
+
const newState = walkTree(
|
924
|
+
state,
|
925
|
+
appStore.config,
|
926
|
+
(content, zoneCompound) => {
|
927
|
+
if (zoneCompound === action.zone) {
|
928
|
+
return remove(content, action.index);
|
929
|
+
}
|
930
|
+
return content;
|
997
931
|
}
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
newData.zones[action.sourceZone],
|
1004
|
-
action.sourceIndex
|
1005
|
-
)
|
1006
|
-
})
|
1007
|
-
});
|
932
|
+
);
|
933
|
+
Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
|
934
|
+
const parentId = zoneCompound.split(":")[0];
|
935
|
+
if (nodesToDelete.includes(parentId) && newState.data.zones) {
|
936
|
+
delete newState.data.zones[zoneCompound];
|
1008
937
|
}
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
),
|
1015
|
-
[action.destinationZone]: insert(
|
1016
|
-
newData.zones[action.destinationZone],
|
1017
|
-
action.destinationIndex,
|
1018
|
-
item
|
1019
|
-
)
|
1020
|
-
})
|
1021
|
-
});
|
1022
|
-
}
|
1023
|
-
if (action.type === "replace") {
|
1024
|
-
return replaceAction(data, action);
|
1025
|
-
}
|
1026
|
-
if (action.type === "remove") {
|
1027
|
-
const item = getItem({ index: action.index, zone: action.zone }, data);
|
1028
|
-
const dataWithRelatedRemoved = setupZone(
|
1029
|
-
removeRelatedZones(item, data),
|
1030
|
-
action.zone
|
1031
|
-
);
|
1032
|
-
if (action.zone === rootDroppableId) {
|
1033
|
-
return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
|
1034
|
-
content: remove(data.content, action.index)
|
1035
|
-
});
|
938
|
+
});
|
939
|
+
Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
|
940
|
+
const parentId = zoneCompound.split(":")[0];
|
941
|
+
if (nodesToDelete.includes(parentId)) {
|
942
|
+
delete newState.indexes.zones[zoneCompound];
|
1036
943
|
}
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
944
|
+
});
|
945
|
+
nodesToDelete.forEach((id) => {
|
946
|
+
delete newState.indexes.nodes[id];
|
947
|
+
});
|
948
|
+
return newState;
|
949
|
+
};
|
950
|
+
|
951
|
+
// ../core/reducer/actions/register-zone.ts
|
952
|
+
init_react_import();
|
953
|
+
|
954
|
+
// ../core/lib/data/setup-zone.ts
|
955
|
+
init_react_import();
|
956
|
+
var setupZone = (data, zoneKey) => {
|
957
|
+
if (zoneKey === rootDroppableId) {
|
958
|
+
return data;
|
1045
959
|
}
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
960
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
961
|
+
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
962
|
+
});
|
963
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
964
|
+
return newData;
|
965
|
+
};
|
966
|
+
|
967
|
+
// ../core/reducer/actions/register-zone.ts
|
968
|
+
var zoneCache = {};
|
969
|
+
function registerZoneAction(state, action) {
|
970
|
+
if (zoneCache[action.zone]) {
|
971
|
+
return __spreadProps(__spreadValues({}, state), {
|
972
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
973
|
+
zones: __spreadProps(__spreadValues({}, state.data.zones), {
|
1050
974
|
[action.zone]: zoneCache[action.zone]
|
1051
975
|
})
|
1052
|
-
})
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
}
|
1062
|
-
return __spreadProps(__spreadValues({}, data), { zones: _zones });
|
976
|
+
}),
|
977
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
978
|
+
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
|
979
|
+
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
|
980
|
+
contentIds: zoneCache[action.zone].map((item) => item.props.id),
|
981
|
+
type: "dropzone"
|
982
|
+
})
|
983
|
+
})
|
984
|
+
})
|
985
|
+
});
|
1063
986
|
}
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
987
|
+
return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
|
988
|
+
}
|
989
|
+
function unregisterZoneAction(state, action) {
|
990
|
+
const _zones = __spreadValues({}, state.data.zones || {});
|
991
|
+
const zoneIndex = __spreadValues({}, state.indexes.zones || {});
|
992
|
+
if (_zones[action.zone]) {
|
993
|
+
zoneCache[action.zone] = _zones[action.zone];
|
994
|
+
delete _zones[action.zone];
|
1069
995
|
}
|
1070
|
-
|
996
|
+
delete zoneIndex[action.zone];
|
997
|
+
return __spreadProps(__spreadValues({}, state), {
|
998
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
999
|
+
zones: _zones
|
1000
|
+
}),
|
1001
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1002
|
+
zones: zoneIndex
|
1003
|
+
})
|
1004
|
+
});
|
1071
1005
|
}
|
1072
1006
|
|
1073
|
-
// ../core/reducer/
|
1007
|
+
// ../core/reducer/actions/set-data.ts
|
1074
1008
|
init_react_import();
|
1075
|
-
var
|
1076
|
-
if (action.
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
return
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1009
|
+
var setDataAction = (state, action, appStore) => {
|
1010
|
+
if (typeof action.data === "object") {
|
1011
|
+
console.warn(
|
1012
|
+
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1013
|
+
);
|
1014
|
+
return walkTree(
|
1015
|
+
__spreadProps(__spreadValues({}, state), {
|
1016
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
1017
|
+
}),
|
1018
|
+
appStore.config
|
1019
|
+
);
|
1086
1020
|
}
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1021
|
+
return walkTree(
|
1022
|
+
__spreadProps(__spreadValues({}, state), {
|
1023
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
1024
|
+
}),
|
1025
|
+
appStore.config
|
1026
|
+
);
|
1027
|
+
};
|
1028
|
+
|
1029
|
+
// ../core/reducer/actions/set-ui.ts
|
1030
|
+
init_react_import();
|
1031
|
+
var setUiAction = (state, action) => {
|
1032
|
+
if (typeof action.ui === "object") {
|
1033
|
+
return __spreadProps(__spreadValues({}, state), {
|
1034
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
|
1090
1035
|
});
|
1091
1036
|
}
|
1092
|
-
return
|
1037
|
+
return __spreadProps(__spreadValues({}, state), {
|
1038
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
|
1039
|
+
});
|
1040
|
+
};
|
1041
|
+
|
1042
|
+
// ../core/lib/data/make-state-public.ts
|
1043
|
+
init_react_import();
|
1044
|
+
var makeStatePublic = (state) => {
|
1045
|
+
const { data, ui } = state;
|
1046
|
+
return { data, ui };
|
1093
1047
|
};
|
1094
1048
|
|
1095
1049
|
// ../core/reducer/actions.tsx
|
@@ -1109,29 +1063,54 @@ function storeInterceptor(reducer, record, onAction) {
|
|
1109
1063
|
if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
|
1110
1064
|
if (record) record(newAppState);
|
1111
1065
|
}
|
1112
|
-
onAction == null ? void 0 : onAction(action, newAppState, state);
|
1066
|
+
onAction == null ? void 0 : onAction(action, makeStatePublic(newAppState), makeStatePublic(state));
|
1113
1067
|
return newAppState;
|
1114
1068
|
};
|
1115
1069
|
}
|
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
1070
|
function createReducer({
|
1123
|
-
config,
|
1124
1071
|
record,
|
1125
|
-
onAction
|
1072
|
+
onAction,
|
1073
|
+
appStore
|
1126
1074
|
}) {
|
1127
1075
|
return storeInterceptor(
|
1128
1076
|
(state, action) => {
|
1129
|
-
const data = reduceData(state.data, action, config);
|
1130
|
-
const ui = reduceUi(state.ui, action);
|
1131
1077
|
if (action.type === "set") {
|
1132
|
-
return setAction(state, action);
|
1078
|
+
return setAction(state, action, appStore);
|
1079
|
+
}
|
1080
|
+
if (action.type === "insert") {
|
1081
|
+
return insertAction(state, action, appStore);
|
1082
|
+
}
|
1083
|
+
if (action.type === "replace") {
|
1084
|
+
return replaceAction(state, action, appStore);
|
1085
|
+
}
|
1086
|
+
if (action.type === "replaceRoot") {
|
1087
|
+
return replaceRootAction(state, action, appStore);
|
1088
|
+
}
|
1089
|
+
if (action.type === "duplicate") {
|
1090
|
+
return duplicateAction(state, action, appStore);
|
1091
|
+
}
|
1092
|
+
if (action.type === "reorder") {
|
1093
|
+
return reorderAction(state, action, appStore);
|
1094
|
+
}
|
1095
|
+
if (action.type === "move") {
|
1096
|
+
return moveAction(state, action, appStore);
|
1097
|
+
}
|
1098
|
+
if (action.type === "remove") {
|
1099
|
+
return removeAction(state, action, appStore);
|
1100
|
+
}
|
1101
|
+
if (action.type === "registerZone") {
|
1102
|
+
return registerZoneAction(state, action);
|
1103
|
+
}
|
1104
|
+
if (action.type === "unregisterZone") {
|
1105
|
+
return unregisterZoneAction(state, action);
|
1106
|
+
}
|
1107
|
+
if (action.type === "setData") {
|
1108
|
+
return setDataAction(state, action, appStore);
|
1109
|
+
}
|
1110
|
+
if (action.type === "setUi") {
|
1111
|
+
return setUiAction(state, action);
|
1133
1112
|
}
|
1134
|
-
return
|
1113
|
+
return state;
|
1135
1114
|
},
|
1136
1115
|
record,
|
1137
1116
|
onAction
|
@@ -1146,20 +1125,16 @@ var defaultViewports = [
|
|
1146
1125
|
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
1147
1126
|
];
|
1148
1127
|
|
1149
|
-
// ../../node_modules/zustand/esm/index.mjs
|
1150
|
-
init_react_import();
|
1151
|
-
|
1152
1128
|
// ../../node_modules/zustand/esm/vanilla.mjs
|
1153
1129
|
init_react_import();
|
1154
|
-
var import_meta = {};
|
1155
1130
|
var createStoreImpl = (createState) => {
|
1156
1131
|
let state;
|
1157
1132
|
const listeners = /* @__PURE__ */ new Set();
|
1158
|
-
const setState = (partial,
|
1133
|
+
const setState = (partial, replace) => {
|
1159
1134
|
const nextState = typeof partial === "function" ? partial(state) : partial;
|
1160
1135
|
if (!Object.is(nextState, state)) {
|
1161
1136
|
const previousState = state;
|
1162
|
-
state = (
|
1137
|
+
state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
|
1163
1138
|
listeners.forEach((listener) => listener(state, previousState));
|
1164
1139
|
}
|
1165
1140
|
};
|
@@ -1169,53 +1144,28 @@ var createStoreImpl = (createState) => {
|
|
1169
1144
|
listeners.add(listener);
|
1170
1145
|
return () => listeners.delete(listener);
|
1171
1146
|
};
|
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 };
|
1147
|
+
const api = { setState, getState, getInitialState, subscribe };
|
1181
1148
|
const initialState = state = createState(setState, getState, api);
|
1182
1149
|
return api;
|
1183
1150
|
};
|
1184
1151
|
var createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
|
1185
1152
|
|
1186
|
-
// ../../node_modules/zustand/esm/
|
1153
|
+
// ../../node_modules/zustand/esm/react.mjs
|
1154
|
+
init_react_import();
|
1187
1155
|
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
1156
|
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(
|
1157
|
+
function useStore(api, selector = identity) {
|
1158
|
+
const slice = import_react4.default.useSyncExternalStore(
|
1202
1159
|
api.subscribe,
|
1203
|
-
api.getState,
|
1204
|
-
|
1205
|
-
selector,
|
1206
|
-
equalityFn
|
1160
|
+
() => selector(api.getState()),
|
1161
|
+
() => selector(api.getInitialState())
|
1207
1162
|
);
|
1208
|
-
useDebugValue(slice);
|
1163
|
+
import_react4.default.useDebugValue(slice);
|
1209
1164
|
return slice;
|
1210
1165
|
}
|
1211
1166
|
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);
|
1167
|
+
const api = createStore(createState);
|
1168
|
+
const useBoundStore = (selector) => useStore(api, selector);
|
1219
1169
|
Object.assign(useBoundStore, api);
|
1220
1170
|
return useBoundStore;
|
1221
1171
|
};
|
@@ -1248,208 +1198,8 @@ var subscribeWithSelectorImpl = (fn) => (set, get, api) => {
|
|
1248
1198
|
};
|
1249
1199
|
var subscribeWithSelector = subscribeWithSelectorImpl;
|
1250
1200
|
|
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
1201
|
// ../core/store/index.ts
|
1452
|
-
var
|
1202
|
+
var import_react9 = require("react");
|
1453
1203
|
|
1454
1204
|
// ../core/store/slices/history.ts
|
1455
1205
|
init_react_import();
|
@@ -1555,7 +1305,7 @@ var createHistorySlice = (set, get) => {
|
|
1555
1305
|
const { dispatch, history } = get();
|
1556
1306
|
dispatch({
|
1557
1307
|
type: "set",
|
1558
|
-
state: ((_a = history.histories[
|
1308
|
+
state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
|
1559
1309
|
});
|
1560
1310
|
set({ history: __spreadProps(__spreadValues({}, history), { index }) });
|
1561
1311
|
},
|
@@ -1565,31 +1315,14 @@ var createHistorySlice = (set, get) => {
|
|
1565
1315
|
|
1566
1316
|
// ../core/store/slices/nodes.ts
|
1567
1317
|
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
1318
|
var createNodesSlice = (set, get) => ({
|
1578
1319
|
nodes: {},
|
1579
1320
|
registerNode: (id, node) => {
|
1580
1321
|
const s = get().nodes;
|
1581
|
-
if (s.nodes[id] && partialDeepEqual(node, s.nodes[id])) {
|
1582
|
-
return;
|
1583
|
-
}
|
1584
1322
|
const emptyNode = {
|
1585
1323
|
id,
|
1586
1324
|
methods: { sync: () => null },
|
1587
|
-
|
1588
|
-
parentId: "",
|
1589
|
-
zone: "",
|
1590
|
-
path: [],
|
1591
|
-
element: null,
|
1592
|
-
index: -1
|
1325
|
+
element: null
|
1593
1326
|
};
|
1594
1327
|
const existingNode = s.nodes[id];
|
1595
1328
|
set({
|
@@ -1619,36 +1352,61 @@ var createNodesSlice = (set, get) => ({
|
|
1619
1352
|
|
1620
1353
|
// ../core/store/slices/permissions.ts
|
1621
1354
|
init_react_import();
|
1622
|
-
var
|
1355
|
+
var import_react7 = require("react");
|
1356
|
+
|
1357
|
+
// ../core/lib/data/flatten-data.ts
|
1358
|
+
init_react_import();
|
1359
|
+
var flattenData = (state, config) => {
|
1360
|
+
const data = [];
|
1361
|
+
walkTree(
|
1362
|
+
state,
|
1363
|
+
config,
|
1364
|
+
(content) => content,
|
1365
|
+
(item) => {
|
1366
|
+
data.push(item);
|
1367
|
+
return null;
|
1368
|
+
}
|
1369
|
+
);
|
1370
|
+
return data;
|
1371
|
+
};
|
1372
|
+
|
1373
|
+
// ../core/lib/get-changed.ts
|
1374
|
+
init_react_import();
|
1375
|
+
var getChanged = (newItem, oldItem) => {
|
1376
|
+
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
1377
|
+
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
1378
|
+
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
1379
|
+
return __spreadProps(__spreadValues({}, acc), {
|
1380
|
+
[item]: oldItemProps[item] !== newItemProps[item]
|
1381
|
+
});
|
1382
|
+
}, {}) : {};
|
1383
|
+
};
|
1384
|
+
|
1385
|
+
// ../core/store/slices/permissions.ts
|
1623
1386
|
var createPermissionsSlice = (set, get) => {
|
1624
1387
|
const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
|
1625
|
-
const { state, permissions } = get();
|
1626
|
-
const { cache:
|
1388
|
+
const { state, permissions, config } = get();
|
1389
|
+
const { cache: cache2, globalPermissions } = permissions;
|
1627
1390
|
const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
|
1628
1391
|
var _a, _b, _c;
|
1629
|
-
const {
|
1630
|
-
|
1631
|
-
state: appState,
|
1632
|
-
setComponentLoading,
|
1633
|
-
unsetComponentLoading
|
1634
|
-
} = get();
|
1635
|
-
const componentConfig = item2.type === "root" ? config.root : config.components[item2.type];
|
1392
|
+
const { config: config2, state: appState, setComponentLoading } = get();
|
1393
|
+
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
1636
1394
|
if (!componentConfig) {
|
1637
1395
|
return;
|
1638
1396
|
}
|
1639
1397
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
1640
1398
|
if (componentConfig.resolvePermissions) {
|
1641
|
-
const changed = getChanged(item2, (_a =
|
1399
|
+
const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
|
1642
1400
|
if (Object.values(changed).some((el) => el === true) || force2) {
|
1643
|
-
setComponentLoading(item2.props.id);
|
1401
|
+
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
1644
1402
|
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
1645
1403
|
item2,
|
1646
1404
|
{
|
1647
1405
|
changed,
|
1648
|
-
lastPermissions: ((_b =
|
1406
|
+
lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
|
1649
1407
|
permissions: initialPermissions,
|
1650
|
-
appState,
|
1651
|
-
lastData: ((_c =
|
1408
|
+
appState: makeStatePublic(appState),
|
1409
|
+
lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
|
1652
1410
|
}
|
1653
1411
|
);
|
1654
1412
|
const latest = get().permissions;
|
@@ -1665,7 +1423,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1665
1423
|
})
|
1666
1424
|
})
|
1667
1425
|
});
|
1668
|
-
|
1426
|
+
clearTimeout2();
|
1669
1427
|
}
|
1670
1428
|
}
|
1671
1429
|
});
|
@@ -1675,7 +1433,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1675
1433
|
// Shim the root data in by conforming to component data shape
|
1676
1434
|
{
|
1677
1435
|
type: "root",
|
1678
|
-
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "
|
1436
|
+
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "root" })
|
1679
1437
|
},
|
1680
1438
|
force2
|
1681
1439
|
);
|
@@ -1684,14 +1442,13 @@ var createPermissionsSlice = (set, get) => {
|
|
1684
1442
|
if (item) {
|
1685
1443
|
yield resolveDataForItem(item, force);
|
1686
1444
|
} else if (type) {
|
1687
|
-
flattenData(state
|
1445
|
+
flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(void 0, null, function* () {
|
1688
1446
|
yield resolveDataForItem(item2, force);
|
1689
1447
|
}));
|
1690
1448
|
} else if (root) {
|
1691
1449
|
resolveDataForRoot(force);
|
1692
1450
|
} else {
|
1693
|
-
|
1694
|
-
flattenData(state.data).map((item2) => __async(void 0, null, function* () {
|
1451
|
+
flattenData(state, config).map((item2) => __async(void 0, null, function* () {
|
1695
1452
|
yield resolveDataForItem(item2, force);
|
1696
1453
|
}));
|
1697
1454
|
}
|
@@ -1721,7 +1478,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1721
1478
|
} else if (root) {
|
1722
1479
|
const rootConfig = config.root;
|
1723
1480
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
|
1724
|
-
const resolvedForItem = resolvedPermissions["
|
1481
|
+
const resolvedForItem = resolvedPermissions["root"];
|
1725
1482
|
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
1726
1483
|
}
|
1727
1484
|
return globalPermissions;
|
@@ -1733,8 +1490,8 @@ var createPermissionsSlice = (set, get) => {
|
|
1733
1490
|
|
1734
1491
|
// ../core/store/slices/fields.ts
|
1735
1492
|
init_react_import();
|
1736
|
-
var
|
1737
|
-
var
|
1493
|
+
var import_react8 = require("react");
|
1494
|
+
var createFieldsSlice = (_set, _get) => {
|
1738
1495
|
return {
|
1739
1496
|
fields: {},
|
1740
1497
|
loading: false,
|
@@ -1742,6 +1499,112 @@ var createFieldsStore = (_set, _get) => {
|
|
1742
1499
|
};
|
1743
1500
|
};
|
1744
1501
|
|
1502
|
+
// ../core/lib/resolve-component-data.ts
|
1503
|
+
init_react_import();
|
1504
|
+
|
1505
|
+
// ../core/lib/data/map-slots.ts
|
1506
|
+
init_react_import();
|
1507
|
+
function mapSlotsAsync(_0, _1) {
|
1508
|
+
return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
|
1509
|
+
const props = __spreadValues({}, item.props);
|
1510
|
+
const propKeys = Object.keys(props);
|
1511
|
+
for (let i = 0; i < propKeys.length; i++) {
|
1512
|
+
const propKey = propKeys[i];
|
1513
|
+
const itemType = "type" in item ? item.type : "root";
|
1514
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
1515
|
+
const content = props[propKey];
|
1516
|
+
const mappedContent = recursive ? yield Promise.all(
|
1517
|
+
content.map((item2) => __async(this, null, function* () {
|
1518
|
+
return yield mapSlotsAsync(item2, map, recursive, isSlot2);
|
1519
|
+
}))
|
1520
|
+
) : content;
|
1521
|
+
props[propKey] = yield map(mappedContent, propKey);
|
1522
|
+
}
|
1523
|
+
}
|
1524
|
+
return __spreadProps(__spreadValues({}, item), { props });
|
1525
|
+
});
|
1526
|
+
}
|
1527
|
+
|
1528
|
+
// ../core/lib/resolve-component-data.ts
|
1529
|
+
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1530
|
+
var cache = { lastChange: {} };
|
1531
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
|
1532
|
+
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
1533
|
+
if ((configForItem == null ? void 0 : configForItem.resolveData) && item.props) {
|
1534
|
+
const id = "id" in item.props ? item.props.id : "root";
|
1535
|
+
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
1536
|
+
if (item && (0, import_fast_deep_equal.default)(item, oldItem)) {
|
1537
|
+
return { node: resolved, didChange: false };
|
1538
|
+
}
|
1539
|
+
const changed = getChanged(item, oldItem);
|
1540
|
+
if (onResolveStart) {
|
1541
|
+
onResolveStart(item);
|
1542
|
+
}
|
1543
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
1544
|
+
changed,
|
1545
|
+
lastData: oldItem,
|
1546
|
+
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
1547
|
+
trigger
|
1548
|
+
});
|
1549
|
+
let resolvedItem = __spreadProps(__spreadValues({}, item), {
|
1550
|
+
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
1551
|
+
});
|
1552
|
+
if (recursive) {
|
1553
|
+
resolvedItem = yield mapSlotsAsync(
|
1554
|
+
resolvedItem,
|
1555
|
+
(content) => __async(void 0, null, function* () {
|
1556
|
+
return Promise.all(
|
1557
|
+
content.map(
|
1558
|
+
(childItem) => __async(void 0, null, function* () {
|
1559
|
+
return (yield resolveComponentData(
|
1560
|
+
childItem,
|
1561
|
+
config,
|
1562
|
+
metadata,
|
1563
|
+
onResolveStart,
|
1564
|
+
onResolveEnd,
|
1565
|
+
trigger,
|
1566
|
+
false
|
1567
|
+
)).node;
|
1568
|
+
})
|
1569
|
+
)
|
1570
|
+
);
|
1571
|
+
}),
|
1572
|
+
false,
|
1573
|
+
createIsSlotConfig(config)
|
1574
|
+
);
|
1575
|
+
}
|
1576
|
+
if (Object.keys(readOnly).length) {
|
1577
|
+
resolvedItem.readOnly = readOnly;
|
1578
|
+
}
|
1579
|
+
cache.lastChange[id] = {
|
1580
|
+
item,
|
1581
|
+
resolved: resolvedItem
|
1582
|
+
};
|
1583
|
+
if (onResolveEnd) {
|
1584
|
+
onResolveEnd(resolvedItem);
|
1585
|
+
}
|
1586
|
+
return { node: resolvedItem, didChange: !(0, import_fast_deep_equal.default)(item, resolvedItem) };
|
1587
|
+
}
|
1588
|
+
return { node: item, didChange: false };
|
1589
|
+
});
|
1590
|
+
|
1591
|
+
// ../core/lib/data/to-root.ts
|
1592
|
+
init_react_import();
|
1593
|
+
var toRoot = (item) => {
|
1594
|
+
if ("type" in item && item.type !== "root") {
|
1595
|
+
throw new Error("Converting non-root item to root.");
|
1596
|
+
}
|
1597
|
+
const { readOnly } = item;
|
1598
|
+
if (item.props) {
|
1599
|
+
if ("id" in item.props) {
|
1600
|
+
const _a = item.props, { id } = _a, props = __objRest(_a, ["id"]);
|
1601
|
+
return { props, readOnly };
|
1602
|
+
}
|
1603
|
+
return { props: item.props, readOnly };
|
1604
|
+
}
|
1605
|
+
return { props: {}, readOnly };
|
1606
|
+
};
|
1607
|
+
|
1745
1608
|
// ../core/store/index.ts
|
1746
1609
|
var defaultAppState = {
|
1747
1610
|
data: { content: [], root: {}, zones: {} },
|
@@ -1762,100 +1625,194 @@ var defaultAppState = {
|
|
1762
1625
|
controlsVisible: true
|
1763
1626
|
},
|
1764
1627
|
field: { focus: null }
|
1628
|
+
},
|
1629
|
+
indexes: {
|
1630
|
+
nodes: {},
|
1631
|
+
zones: {}
|
1765
1632
|
}
|
1766
1633
|
};
|
1767
1634
|
var defaultPageFields = {
|
1768
1635
|
title: { type: "text" }
|
1769
1636
|
};
|
1770
1637
|
var createAppStore = (initialAppStore) => create()(
|
1771
|
-
subscribeWithSelector((set, get) =>
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1815
|
-
|
1816
|
-
})
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1638
|
+
subscribeWithSelector((set, get) => {
|
1639
|
+
var _a, _b;
|
1640
|
+
return __spreadProps(__spreadValues({
|
1641
|
+
state: defaultAppState,
|
1642
|
+
config: { components: {} },
|
1643
|
+
componentState: {},
|
1644
|
+
plugins: [],
|
1645
|
+
overrides: {},
|
1646
|
+
viewports: defaultViewports,
|
1647
|
+
zoomConfig: {
|
1648
|
+
autoZoom: 1,
|
1649
|
+
rootHeight: 0,
|
1650
|
+
zoom: 1
|
1651
|
+
},
|
1652
|
+
status: "LOADING",
|
1653
|
+
iframe: {},
|
1654
|
+
metadata: {}
|
1655
|
+
}, initialAppStore), {
|
1656
|
+
fields: createFieldsSlice(set, get),
|
1657
|
+
history: createHistorySlice(set, get),
|
1658
|
+
nodes: createNodesSlice(set, get),
|
1659
|
+
permissions: createPermissionsSlice(set, get),
|
1660
|
+
getComponentConfig: (type) => {
|
1661
|
+
var _a2;
|
1662
|
+
const { config, selectedItem } = get();
|
1663
|
+
const rootFields = ((_a2 = config.root) == null ? void 0 : _a2.fields) || defaultPageFields;
|
1664
|
+
return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
|
1665
|
+
},
|
1666
|
+
selectedItem: ((_a = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _a.ui.itemSelector) ? getItem(
|
1667
|
+
(_b = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _b.ui.itemSelector,
|
1668
|
+
initialAppStore.state
|
1669
|
+
) : null,
|
1670
|
+
dispatch: (action) => set((s) => {
|
1671
|
+
var _a2, _b2;
|
1672
|
+
const { record } = get().history;
|
1673
|
+
const dispatch = createReducer({
|
1674
|
+
record,
|
1675
|
+
appStore: s
|
1676
|
+
});
|
1677
|
+
const state = dispatch(s.state, action);
|
1678
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1679
|
+
(_b2 = (_a2 = get()).onAction) == null ? void 0 : _b2.call(_a2, action, state, get().state);
|
1680
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1681
|
+
}),
|
1682
|
+
setZoomConfig: (zoomConfig) => set({ zoomConfig }),
|
1683
|
+
setStatus: (status) => set({ status }),
|
1684
|
+
setComponentState: (componentState) => set({ componentState }),
|
1685
|
+
pendingLoadTimeouts: {},
|
1686
|
+
setComponentLoading: (id, loading = true, defer = 0) => {
|
1687
|
+
const { setComponentState, pendingLoadTimeouts } = get();
|
1688
|
+
const loadId = generateId();
|
1689
|
+
const setLoading = () => {
|
1690
|
+
var _a2;
|
1691
|
+
const { componentState } = get();
|
1692
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1693
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1694
|
+
loadingCount: (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) + 1
|
1695
|
+
})
|
1696
|
+
}));
|
1697
|
+
};
|
1698
|
+
const unsetLoading = () => {
|
1699
|
+
var _a2;
|
1700
|
+
const { componentState } = get();
|
1701
|
+
clearTimeout(timeout);
|
1702
|
+
delete pendingLoadTimeouts[loadId];
|
1703
|
+
set({ pendingLoadTimeouts });
|
1704
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1705
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1706
|
+
loadingCount: Math.max(
|
1707
|
+
(((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) - 1,
|
1708
|
+
0
|
1709
|
+
)
|
1710
|
+
})
|
1711
|
+
}));
|
1712
|
+
};
|
1713
|
+
const timeout = setTimeout(() => {
|
1714
|
+
if (loading) {
|
1715
|
+
setLoading();
|
1716
|
+
} else {
|
1717
|
+
unsetLoading();
|
1718
|
+
}
|
1719
|
+
delete pendingLoadTimeouts[loadId];
|
1720
|
+
set({ pendingLoadTimeouts });
|
1721
|
+
}, defer);
|
1722
|
+
set({
|
1723
|
+
pendingLoadTimeouts: __spreadProps(__spreadValues({}, pendingLoadTimeouts), {
|
1724
|
+
[id]: timeout
|
1725
|
+
})
|
1726
|
+
});
|
1727
|
+
return unsetLoading;
|
1728
|
+
},
|
1729
|
+
unsetComponentLoading: (id) => {
|
1730
|
+
const { setComponentLoading } = get();
|
1731
|
+
setComponentLoading(id, false);
|
1732
|
+
},
|
1733
|
+
// Helper
|
1734
|
+
setUi: (ui, recordHistory) => set((s) => {
|
1735
|
+
const dispatch = createReducer({
|
1736
|
+
record: () => {
|
1737
|
+
},
|
1738
|
+
appStore: s
|
1739
|
+
});
|
1740
|
+
const state = dispatch(s.state, {
|
1741
|
+
type: "setUi",
|
1742
|
+
ui,
|
1743
|
+
recordHistory
|
1744
|
+
});
|
1745
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1746
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1747
|
+
}),
|
1748
|
+
resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
|
1749
|
+
const { config, metadata, setComponentLoading, permissions } = get();
|
1750
|
+
const timeouts = {};
|
1751
|
+
return yield resolveComponentData(
|
1752
|
+
componentData,
|
1753
|
+
config,
|
1754
|
+
metadata,
|
1755
|
+
(item) => {
|
1756
|
+
const id = "id" in item.props ? item.props.id : "root";
|
1757
|
+
timeouts[id] = setComponentLoading(id, true, 50);
|
1758
|
+
},
|
1759
|
+
(item) => __async(void 0, null, function* () {
|
1760
|
+
const id = "id" in item.props ? item.props.id : "root";
|
1761
|
+
if ("type" in item) {
|
1762
|
+
yield permissions.refreshPermissions({ item });
|
1763
|
+
} else {
|
1764
|
+
yield permissions.refreshPermissions({ root: true });
|
1765
|
+
}
|
1766
|
+
timeouts[id]();
|
1767
|
+
}),
|
1768
|
+
trigger
|
1769
|
+
);
|
1770
|
+
}),
|
1771
|
+
resolveAndCommitData: () => __async(void 0, null, function* () {
|
1772
|
+
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
1773
|
+
walkTree(
|
1774
|
+
state,
|
1775
|
+
config,
|
1776
|
+
(content) => content,
|
1777
|
+
(childItem) => {
|
1778
|
+
resolveComponentData2(childItem, "load").then((resolved) => {
|
1779
|
+
const { state: state2 } = get();
|
1780
|
+
const node = state2.indexes.nodes[resolved.node.props.id];
|
1781
|
+
if (node && resolved.didChange) {
|
1782
|
+
if (resolved.node.props.id === "root") {
|
1783
|
+
dispatch({
|
1784
|
+
type: "replaceRoot",
|
1785
|
+
root: toRoot(resolved.node)
|
1786
|
+
});
|
1787
|
+
} else {
|
1788
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
1789
|
+
const parentZone = state2.indexes.zones[zoneCompound];
|
1790
|
+
const index = parentZone.contentIds.indexOf(
|
1791
|
+
resolved.node.props.id
|
1792
|
+
);
|
1793
|
+
dispatch({
|
1794
|
+
type: "replace",
|
1795
|
+
data: resolved.node,
|
1796
|
+
destinationIndex: index,
|
1797
|
+
destinationZone: zoneCompound
|
1798
|
+
});
|
1799
|
+
}
|
1800
|
+
}
|
1801
|
+
});
|
1802
|
+
return childItem;
|
1803
|
+
}
|
1804
|
+
);
|
1805
|
+
})
|
1806
|
+
});
|
1807
|
+
})
|
1851
1808
|
);
|
1852
|
-
var appStoreContext = (0,
|
1809
|
+
var appStoreContext = (0, import_react9.createContext)(createAppStore());
|
1853
1810
|
function useAppStore(selector) {
|
1854
|
-
const context = (0,
|
1811
|
+
const context = (0, import_react9.useContext)(appStoreContext);
|
1855
1812
|
return useStore(context, selector);
|
1856
1813
|
}
|
1857
1814
|
function useAppStoreApi() {
|
1858
|
-
return (0,
|
1815
|
+
return (0, import_react9.useContext)(appStoreContext);
|
1859
1816
|
}
|
1860
1817
|
|
1861
1818
|
// ../core/lib/use-breadcrumbs.ts
|
@@ -1867,12 +1824,12 @@ var useBreadcrumbs = (renderCount) => {
|
|
1867
1824
|
const config = useAppStore((s) => s.config);
|
1868
1825
|
const path = useAppStore((s) => {
|
1869
1826
|
var _a;
|
1870
|
-
return (_a = s.
|
1827
|
+
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
1871
1828
|
});
|
1872
1829
|
const appStore = useAppStoreApi();
|
1873
|
-
return (0,
|
1830
|
+
return (0, import_react10.useMemo)(() => {
|
1874
1831
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
1875
|
-
var _a, _b;
|
1832
|
+
var _a, _b, _c;
|
1876
1833
|
const [componentId] = zoneCompound.split(":");
|
1877
1834
|
if (componentId === "root") {
|
1878
1835
|
return {
|
@@ -1880,12 +1837,15 @@ var useBreadcrumbs = (renderCount) => {
|
|
1880
1837
|
selector: null
|
1881
1838
|
};
|
1882
1839
|
}
|
1883
|
-
const node = appStore.getState().
|
1884
|
-
const
|
1840
|
+
const node = appStore.getState().state.indexes.nodes[componentId];
|
1841
|
+
const parentId = node.path[node.path.length - 1];
|
1842
|
+
const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
|
1843
|
+
const index = contentIds.indexOf(componentId);
|
1844
|
+
const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
|
1885
1845
|
return {
|
1886
1846
|
label,
|
1887
1847
|
selector: node ? {
|
1888
|
-
index
|
1848
|
+
index,
|
1889
1849
|
zone: node.path[node.path.length - 1]
|
1890
1850
|
} : null
|
1891
1851
|
};
|
@@ -1906,6 +1866,12 @@ init_react_import();
|
|
1906
1866
|
// ../core/lib/filter.ts
|
1907
1867
|
init_react_import();
|
1908
1868
|
|
1869
|
+
// ../core/lib/data/reorder.ts
|
1870
|
+
init_react_import();
|
1871
|
+
|
1872
|
+
// ../core/lib/data/replace.ts
|
1873
|
+
init_react_import();
|
1874
|
+
|
1909
1875
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
|
1910
1876
|
init_react_import();
|
1911
1877
|
var styles_module_default3 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
|
@@ -2086,18 +2052,40 @@ function buildHierarchy(frame) {
|
|
2086
2052
|
var usePuck = (0, import_puck.createUsePuck)();
|
2087
2053
|
var HeadingAnalyzer = () => {
|
2088
2054
|
const data = usePuck((s) => s.appState.data);
|
2089
|
-
const [hierarchy, setHierarchy] = (0,
|
2090
|
-
(0,
|
2055
|
+
const [hierarchy, setHierarchy] = (0, import_react11.useState)([]);
|
2056
|
+
(0, import_react11.useEffect)(() => {
|
2091
2057
|
const frame = getFrame();
|
2092
|
-
|
2093
|
-
|
2094
|
-
setHierarchy(buildHierarchy(entry));
|
2095
|
-
const observer = new MutationObserver(() => {
|
2058
|
+
let entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
2059
|
+
const createHierarchy = () => {
|
2096
2060
|
setHierarchy(buildHierarchy(entry));
|
2061
|
+
};
|
2062
|
+
const entryObserver = new MutationObserver(() => {
|
2063
|
+
createHierarchy();
|
2064
|
+
});
|
2065
|
+
const frameObserver = new MutationObserver(() => {
|
2066
|
+
entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
2067
|
+
if (entry) {
|
2068
|
+
registerEntryObserver();
|
2069
|
+
frameObserver.disconnect();
|
2070
|
+
}
|
2097
2071
|
});
|
2098
|
-
|
2072
|
+
const registerEntryObserver = () => {
|
2073
|
+
if (!entry) return;
|
2074
|
+
entryObserver.observe(entry, { subtree: true, childList: true });
|
2075
|
+
};
|
2076
|
+
const registerFrameObserver = () => {
|
2077
|
+
if (!frame) return;
|
2078
|
+
frameObserver.observe(frame, { subtree: true, childList: true });
|
2079
|
+
};
|
2080
|
+
if (entry) {
|
2081
|
+
createHierarchy();
|
2082
|
+
registerEntryObserver();
|
2083
|
+
} else {
|
2084
|
+
registerFrameObserver();
|
2085
|
+
}
|
2099
2086
|
return () => {
|
2100
|
-
|
2087
|
+
entryObserver.disconnect();
|
2088
|
+
frameObserver.disconnect();
|
2101
2089
|
};
|
2102
2090
|
}, [data]);
|
2103
2091
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: getClassName5(), children: [
|
@@ -2197,50 +2185,6 @@ classnames/index.js:
|
|
2197
2185
|
http://jedwatson.github.io/classnames
|
2198
2186
|
*)
|
2199
2187
|
|
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
2188
|
lucide-react/dist/esm/shared/src/utils.js:
|
2245
2189
|
(**
|
2246
2190
|
* @license lucide-react v0.468.0 - ISC
|