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