@measured/puck-plugin-heading-analyzer 0.19.0-canary.af4f756 → 0.19.0-canary.b22833ee
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.mts +22 -10
- package/dist/index.d.ts +22 -10
- package/dist/index.js +1230 -1023
- package/dist/index.mjs +1228 -1027
- 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,285 +146,116 @@ var require_classnames = __commonJS({
|
|
152
146
|
}
|
153
147
|
});
|
154
148
|
|
155
|
-
// ../../node_modules/
|
156
|
-
var
|
157
|
-
"../../node_modules/
|
149
|
+
// ../../node_modules/flat/index.js
|
150
|
+
var require_flat = __commonJS({
|
151
|
+
"../../node_modules/flat/index.js"(exports, module) {
|
158
152
|
"use strict";
|
159
153
|
init_react_import();
|
160
|
-
|
161
|
-
|
162
|
-
|
154
|
+
module.exports = flatten3;
|
155
|
+
flatten3.flatten = flatten3;
|
156
|
+
flatten3.unflatten = unflatten2;
|
157
|
+
function isBuffer(obj) {
|
158
|
+
return obj && obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
|
163
159
|
}
|
164
|
-
|
165
|
-
|
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;
|
160
|
+
function keyIdentity(key) {
|
161
|
+
return key;
|
190
162
|
}
|
191
|
-
function
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
163
|
+
function flatten3(target, opts) {
|
164
|
+
opts = opts || {};
|
165
|
+
const delimiter = opts.delimiter || ".";
|
166
|
+
const maxDepth = opts.maxDepth;
|
167
|
+
const transformKey = opts.transformKey || keyIdentity;
|
168
|
+
const output = {};
|
169
|
+
function step(object, prev, currentDepth) {
|
170
|
+
currentDepth = currentDepth || 1;
|
171
|
+
Object.keys(object).forEach(function(key) {
|
172
|
+
const value = object[key];
|
173
|
+
const isarray = opts.safe && Array.isArray(value);
|
174
|
+
const type = Object.prototype.toString.call(value);
|
175
|
+
const isbuffer = isBuffer(value);
|
176
|
+
const isobject = type === "[object Object]" || type === "[object Array]";
|
177
|
+
const newKey = prev ? prev + delimiter + transformKey(key) : transformKey(key);
|
178
|
+
if (!isarray && !isbuffer && isobject && Object.keys(value).length && (!opts.maxDepth || currentDepth < maxDepth)) {
|
179
|
+
return step(value, newKey, currentDepth + 1);
|
180
|
+
}
|
181
|
+
output[newKey] = value;
|
182
|
+
});
|
199
183
|
}
|
184
|
+
step(target);
|
185
|
+
return output;
|
200
186
|
}
|
201
|
-
function
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
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;
|
187
|
+
function unflatten2(target, opts) {
|
188
|
+
opts = opts || {};
|
189
|
+
const delimiter = opts.delimiter || ".";
|
190
|
+
const overwrite = opts.overwrite || false;
|
191
|
+
const transformKey = opts.transformKey || keyIdentity;
|
192
|
+
const result = {};
|
193
|
+
const isbuffer = isBuffer(target);
|
194
|
+
if (isbuffer || Object.prototype.toString.call(target) !== "[object Object]") {
|
195
|
+
return target;
|
217
196
|
}
|
218
|
-
function
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
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;
|
197
|
+
function getkey(key) {
|
198
|
+
const parsedKey = Number(key);
|
199
|
+
return isNaN(parsedKey) || key.indexOf(".") !== -1 || opts.object ? key : parsedKey;
|
200
|
+
}
|
201
|
+
function addKeys(keyPrefix, recipient, target2) {
|
202
|
+
return Object.keys(target2).reduce(function(result2, key) {
|
203
|
+
result2[keyPrefix + delimiter + key] = target2[key];
|
204
|
+
return result2;
|
205
|
+
}, recipient);
|
252
206
|
}
|
253
|
-
function
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
return !objectIs(inst, nextValue);
|
259
|
-
} catch (error) {
|
207
|
+
function isEmpty(val) {
|
208
|
+
const type = Object.prototype.toString.call(val);
|
209
|
+
const isArray = type === "[object Array]";
|
210
|
+
const isObject = type === "[object Object]";
|
211
|
+
if (!val) {
|
260
212
|
return true;
|
213
|
+
} else if (isArray) {
|
214
|
+
return !val.length;
|
215
|
+
} else if (isObject) {
|
216
|
+
return !Object.keys(val).length;
|
261
217
|
}
|
262
218
|
}
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
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;
|
219
|
+
target = Object.keys(target).reduce(function(result2, key) {
|
220
|
+
const type = Object.prototype.toString.call(target[key]);
|
221
|
+
const isObject = type === "[object Object]" || type === "[object Array]";
|
222
|
+
if (!isObject || isEmpty(target[key])) {
|
223
|
+
result2[key] = target[key];
|
224
|
+
return result2;
|
225
|
+
} else {
|
226
|
+
return addKeys(
|
227
|
+
key,
|
228
|
+
result2,
|
229
|
+
flatten3(target[key], opts)
|
230
|
+
);
|
231
|
+
}
|
232
|
+
}, {});
|
233
|
+
Object.keys(target).forEach(function(key) {
|
234
|
+
const split = key.split(delimiter).map(transformKey);
|
235
|
+
let key1 = getkey(split.shift());
|
236
|
+
let key2 = getkey(split[0]);
|
237
|
+
let recipient = result;
|
238
|
+
while (key2 !== void 0) {
|
239
|
+
if (key1 === "__proto__") {
|
240
|
+
return;
|
330
241
|
}
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
];
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
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();
|
242
|
+
const type = Object.prototype.toString.call(recipient[key1]);
|
243
|
+
const isobject = type === "[object Object]" || type === "[object Array]";
|
244
|
+
if (!overwrite && !isobject && typeof recipient[key1] !== "undefined") {
|
245
|
+
return;
|
246
|
+
}
|
247
|
+
if (overwrite && !isobject || !overwrite && recipient[key1] == null) {
|
248
|
+
recipient[key1] = typeof key2 === "number" && !opts.object ? [] : {};
|
249
|
+
}
|
250
|
+
recipient = recipient[key1];
|
251
|
+
if (split.length > 0) {
|
252
|
+
key1 = getkey(split.shift());
|
253
|
+
key2 = getkey(split[0]);
|
254
|
+
}
|
255
|
+
}
|
256
|
+
recipient[key1] = unflatten2(target[key], opts);
|
257
|
+
});
|
258
|
+
return result;
|
434
259
|
}
|
435
260
|
}
|
436
261
|
});
|
@@ -476,7 +301,7 @@ init_react_import();
|
|
476
301
|
|
477
302
|
// src/HeadingAnalyzer.tsx
|
478
303
|
init_react_import();
|
479
|
-
import { useEffect as
|
304
|
+
import { useEffect as useEffect5, useState } from "react";
|
480
305
|
|
481
306
|
// css-module:/home/runner/work/puck/puck/packages/plugin-heading-analyzer/src/HeadingAnalyzer.module.css#css-module
|
482
307
|
init_react_import();
|
@@ -645,17 +470,17 @@ init_react_import();
|
|
645
470
|
// ../core/reducer/index.ts
|
646
471
|
init_react_import();
|
647
472
|
|
648
|
-
// ../core/reducer/
|
473
|
+
// ../core/reducer/actions/set.ts
|
649
474
|
init_react_import();
|
650
475
|
|
651
|
-
// ../core/lib/
|
476
|
+
// ../core/lib/data/walk-app-state.ts
|
477
|
+
init_react_import();
|
478
|
+
|
479
|
+
// ../core/lib/data/for-related-zones.ts
|
480
|
+
init_react_import();
|
481
|
+
|
482
|
+
// ../core/lib/get-zone-id.ts
|
652
483
|
init_react_import();
|
653
|
-
var reorder = (list, startIndex, endIndex) => {
|
654
|
-
const result = Array.from(list);
|
655
|
-
const [removed] = result.splice(startIndex, 1);
|
656
|
-
result.splice(endIndex, 0, removed);
|
657
|
-
return result;
|
658
|
-
};
|
659
484
|
|
660
485
|
// ../core/lib/root-droppable-id.ts
|
661
486
|
init_react_import();
|
@@ -663,58 +488,337 @@ var rootAreaId = "root";
|
|
663
488
|
var rootZone = "default-zone";
|
664
489
|
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
665
490
|
|
666
|
-
// ../core/lib/
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
491
|
+
// ../core/lib/get-zone-id.ts
|
492
|
+
var getZoneId = (zoneCompound) => {
|
493
|
+
if (!zoneCompound) {
|
494
|
+
return [];
|
495
|
+
}
|
496
|
+
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
497
|
+
return zoneCompound.split(":");
|
498
|
+
}
|
499
|
+
return [rootDroppableId, zoneCompound];
|
672
500
|
};
|
673
501
|
|
674
|
-
// ../core/lib/
|
502
|
+
// ../core/lib/data/for-related-zones.ts
|
503
|
+
function forRelatedZones(item, data, cb, path = []) {
|
504
|
+
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
|
505
|
+
const [parentId] = getZoneId(zoneCompound);
|
506
|
+
if (parentId === item.props.id) {
|
507
|
+
cb(path, zoneCompound, content);
|
508
|
+
}
|
509
|
+
});
|
510
|
+
}
|
511
|
+
|
512
|
+
// ../core/lib/data/map-slots.ts
|
675
513
|
init_react_import();
|
676
|
-
var remove = (list, index) => {
|
677
|
-
const result = Array.from(list);
|
678
|
-
result.splice(index, 1);
|
679
|
-
return result;
|
680
|
-
};
|
681
514
|
|
682
|
-
// ../core/lib/
|
515
|
+
// ../core/lib/data/default-slots.ts
|
683
516
|
init_react_import();
|
684
|
-
var
|
685
|
-
|
686
|
-
|
517
|
+
var defaultSlots = (value, fields) => Object.keys(fields).reduce(
|
518
|
+
(acc, fieldName) => fields[fieldName].type === "slot" ? __spreadValues({ [fieldName]: [] }, acc) : acc,
|
519
|
+
value
|
520
|
+
);
|
521
|
+
|
522
|
+
// ../core/lib/data/map-slots.ts
|
523
|
+
var isPromise = (v) => !!v && typeof v.then === "function";
|
524
|
+
var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
|
525
|
+
var containsPromise = (arr) => arr.some(isPromise);
|
526
|
+
var walkField = ({
|
527
|
+
value,
|
528
|
+
fields,
|
529
|
+
map,
|
530
|
+
propKey = "",
|
531
|
+
propPath = "",
|
532
|
+
id = "",
|
533
|
+
config,
|
534
|
+
recurseSlots = false
|
535
|
+
}) => {
|
536
|
+
var _a, _b, _c;
|
537
|
+
if (((_a = fields[propKey]) == null ? void 0 : _a.type) === "slot") {
|
538
|
+
const content = value || [];
|
539
|
+
const mappedContent = recurseSlots ? content.map((el) => {
|
540
|
+
var _a2;
|
541
|
+
const componentConfig = config.components[el.type];
|
542
|
+
if (!componentConfig) {
|
543
|
+
throw new Error(`Could not find component config for ${el.type}`);
|
544
|
+
}
|
545
|
+
const fields2 = (_a2 = componentConfig.fields) != null ? _a2 : {};
|
546
|
+
return walkField({
|
547
|
+
value: __spreadProps(__spreadValues({}, el), { props: defaultSlots(el.props, fields2) }),
|
548
|
+
fields: fields2,
|
549
|
+
map,
|
550
|
+
id: el.props.id,
|
551
|
+
config,
|
552
|
+
recurseSlots
|
553
|
+
});
|
554
|
+
}) : content;
|
555
|
+
if (containsPromise(mappedContent)) {
|
556
|
+
return Promise.all(mappedContent);
|
557
|
+
}
|
558
|
+
return map(mappedContent, id, propPath, fields[propKey], propPath);
|
687
559
|
}
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
560
|
+
if (value && typeof value === "object") {
|
561
|
+
if (Array.isArray(value)) {
|
562
|
+
const arrayFields = ((_b = fields[propKey]) == null ? void 0 : _b.type) === "array" ? fields[propKey].arrayFields : null;
|
563
|
+
if (!arrayFields) return value;
|
564
|
+
const newValue = value.map(
|
565
|
+
(el, idx) => walkField({
|
566
|
+
value: el,
|
567
|
+
fields: arrayFields,
|
568
|
+
map,
|
569
|
+
propKey,
|
570
|
+
propPath: `${propPath}[${idx}]`,
|
571
|
+
id,
|
572
|
+
config,
|
573
|
+
recurseSlots
|
574
|
+
})
|
575
|
+
);
|
576
|
+
if (containsPromise(newValue)) {
|
577
|
+
return Promise.all(newValue);
|
578
|
+
}
|
579
|
+
return newValue;
|
580
|
+
} else if ("$$typeof" in value) {
|
581
|
+
return value;
|
582
|
+
} else {
|
583
|
+
const objectFields = ((_c = fields[propKey]) == null ? void 0 : _c.type) === "object" ? fields[propKey].objectFields : fields;
|
584
|
+
return walkObject({
|
585
|
+
value,
|
586
|
+
fields: objectFields,
|
587
|
+
map,
|
588
|
+
id,
|
589
|
+
getPropPath: (k) => `${propPath}.${k}`,
|
590
|
+
config,
|
591
|
+
recurseSlots
|
592
|
+
});
|
593
|
+
}
|
594
|
+
}
|
595
|
+
return value;
|
596
|
+
};
|
597
|
+
var walkObject = ({
|
598
|
+
value,
|
599
|
+
fields,
|
600
|
+
map,
|
601
|
+
id,
|
602
|
+
getPropPath,
|
603
|
+
config,
|
604
|
+
recurseSlots
|
605
|
+
}) => {
|
606
|
+
const newProps = Object.entries(value).map(([k, v]) => {
|
607
|
+
const opts = {
|
608
|
+
value: v,
|
609
|
+
fields,
|
610
|
+
map,
|
611
|
+
propKey: k,
|
612
|
+
propPath: getPropPath(k),
|
613
|
+
id,
|
614
|
+
config,
|
615
|
+
recurseSlots
|
616
|
+
};
|
617
|
+
const newValue = walkField(opts);
|
618
|
+
if (isPromise(newValue)) {
|
619
|
+
return newValue.then((resolvedValue) => ({
|
620
|
+
[k]: resolvedValue
|
621
|
+
}));
|
622
|
+
}
|
623
|
+
return {
|
624
|
+
[k]: newValue
|
625
|
+
};
|
626
|
+
}, {});
|
627
|
+
if (containsPromise(newProps)) {
|
628
|
+
return Promise.all(newProps).then(flatten);
|
629
|
+
}
|
630
|
+
return flatten(newProps);
|
693
631
|
};
|
632
|
+
function mapSlots(item, map, config, recurseSlots = false) {
|
633
|
+
var _a, _b, _c, _d, _e;
|
634
|
+
const itemType = "type" in item ? item.type : "root";
|
635
|
+
const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
|
636
|
+
const newProps = walkObject({
|
637
|
+
value: defaultSlots((_b = item.props) != null ? _b : {}, (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {}),
|
638
|
+
fields: (_d = componentConfig == null ? void 0 : componentConfig.fields) != null ? _d : {},
|
639
|
+
map,
|
640
|
+
id: item.props ? (_e = item.props.id) != null ? _e : "root" : "root",
|
641
|
+
getPropPath: (k) => k,
|
642
|
+
config,
|
643
|
+
recurseSlots
|
644
|
+
});
|
645
|
+
if (isPromise(newProps)) {
|
646
|
+
return newProps.then((resolvedProps) => __spreadProps(__spreadValues({}, item), {
|
647
|
+
props: resolvedProps
|
648
|
+
}));
|
649
|
+
}
|
650
|
+
return __spreadProps(__spreadValues({}, item), {
|
651
|
+
props: newProps
|
652
|
+
});
|
653
|
+
}
|
694
654
|
|
695
|
-
// ../core/lib/
|
655
|
+
// ../core/lib/data/flatten-node.ts
|
696
656
|
init_react_import();
|
697
|
-
var
|
698
|
-
const result = Array.from(list);
|
699
|
-
result.splice(index, 1);
|
700
|
-
result.splice(index, 0, newItem);
|
701
|
-
return result;
|
702
|
-
};
|
657
|
+
var import_flat = __toESM(require_flat());
|
703
658
|
|
704
|
-
// ../core/lib/
|
659
|
+
// ../core/lib/data/strip-slots.ts
|
705
660
|
init_react_import();
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
return
|
661
|
+
var stripSlots = (data, config) => {
|
662
|
+
return mapSlots(data, () => null, config);
|
663
|
+
};
|
664
|
+
|
665
|
+
// ../core/lib/data/flatten-node.ts
|
666
|
+
var flattenNode = (node, config) => {
|
667
|
+
return __spreadProps(__spreadValues({}, node), {
|
668
|
+
props: (0, import_flat.flatten)(stripSlots(node, config).props)
|
669
|
+
});
|
670
|
+
};
|
671
|
+
|
672
|
+
// ../core/lib/data/walk-app-state.ts
|
673
|
+
function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
674
|
+
var _a;
|
675
|
+
let newZones = {};
|
676
|
+
const newZoneIndex = {};
|
677
|
+
const newNodeIndex = {};
|
678
|
+
const processContent = (path, zoneCompound, content, zoneType, newId) => {
|
679
|
+
var _a2;
|
680
|
+
const [parentId] = zoneCompound.split(":");
|
681
|
+
const mappedContent = ((_a2 = mapContent(content, zoneCompound, zoneType)) != null ? _a2 : content) || [];
|
682
|
+
const [_2, zone] = zoneCompound.split(":");
|
683
|
+
const newZoneCompound = `${newId || parentId}:${zone}`;
|
684
|
+
const newContent2 = mappedContent.map(
|
685
|
+
(zoneChild, index) => processItem(zoneChild, [...path, newZoneCompound], index)
|
686
|
+
);
|
687
|
+
newZoneIndex[newZoneCompound] = {
|
688
|
+
contentIds: newContent2.map((item) => item.props.id),
|
689
|
+
type: zoneType
|
690
|
+
};
|
691
|
+
return [newZoneCompound, newContent2];
|
692
|
+
};
|
693
|
+
const processRelatedZones = (item, newId, initialPath) => {
|
694
|
+
forRelatedZones(
|
695
|
+
item,
|
696
|
+
state.data,
|
697
|
+
(relatedPath, relatedZoneCompound, relatedContent) => {
|
698
|
+
const [zoneCompound, newContent2] = processContent(
|
699
|
+
relatedPath,
|
700
|
+
relatedZoneCompound,
|
701
|
+
relatedContent,
|
702
|
+
"dropzone",
|
703
|
+
newId
|
704
|
+
);
|
705
|
+
newZones[zoneCompound] = newContent2;
|
706
|
+
},
|
707
|
+
initialPath
|
708
|
+
);
|
709
|
+
};
|
710
|
+
const processItem = (item, path, index) => {
|
711
|
+
const mappedItem = mapNodeOrSkip(item, path, index);
|
712
|
+
if (!mappedItem) return item;
|
713
|
+
const id = mappedItem.props.id;
|
714
|
+
const newProps = __spreadProps(__spreadValues({}, mapSlots(
|
715
|
+
mappedItem,
|
716
|
+
(content, parentId2, slotId) => {
|
717
|
+
const zoneCompound = `${parentId2}:${slotId}`;
|
718
|
+
const [_2, newContent2] = processContent(
|
719
|
+
path,
|
720
|
+
zoneCompound,
|
721
|
+
content,
|
722
|
+
"slot",
|
723
|
+
parentId2
|
724
|
+
);
|
725
|
+
return newContent2;
|
726
|
+
},
|
727
|
+
config
|
728
|
+
).props), {
|
729
|
+
id
|
730
|
+
});
|
731
|
+
processRelatedZones(item, id, path);
|
732
|
+
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
|
733
|
+
const thisZoneCompound = path[path.length - 1];
|
734
|
+
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
735
|
+
newNodeIndex[id] = {
|
736
|
+
data: newItem,
|
737
|
+
flatData: flattenNode(newItem, config),
|
738
|
+
path,
|
739
|
+
parentId,
|
740
|
+
zone
|
741
|
+
};
|
742
|
+
const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
|
743
|
+
if (newProps.id === "root") {
|
744
|
+
delete finalData["type"];
|
745
|
+
delete finalData.props["id"];
|
746
|
+
}
|
747
|
+
return finalData;
|
748
|
+
};
|
749
|
+
const zones = state.data.zones || {};
|
750
|
+
const [_, newContent] = processContent(
|
751
|
+
[],
|
752
|
+
rootDroppableId,
|
753
|
+
state.data.content,
|
754
|
+
"root"
|
755
|
+
);
|
756
|
+
const processedContent = newContent;
|
757
|
+
const zonesAlreadyProcessed = Object.keys(newZones);
|
758
|
+
Object.keys(zones || {}).forEach((zoneCompound) => {
|
759
|
+
const [parentId] = zoneCompound.split(":");
|
760
|
+
if (zonesAlreadyProcessed.includes(zoneCompound)) {
|
761
|
+
return;
|
762
|
+
}
|
763
|
+
const [_2, newContent2] = processContent(
|
764
|
+
[rootDroppableId],
|
765
|
+
zoneCompound,
|
766
|
+
zones[zoneCompound],
|
767
|
+
"dropzone",
|
768
|
+
parentId
|
769
|
+
);
|
770
|
+
newZones[zoneCompound] = newContent2;
|
771
|
+
}, newZones);
|
772
|
+
const processedRoot = processItem(
|
773
|
+
{
|
774
|
+
type: "root",
|
775
|
+
props: __spreadProps(__spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root), { id: "root" })
|
776
|
+
},
|
777
|
+
[],
|
778
|
+
-1
|
779
|
+
);
|
780
|
+
const root = __spreadProps(__spreadValues({}, state.data.root), {
|
781
|
+
props: processedRoot.props
|
782
|
+
});
|
783
|
+
return __spreadProps(__spreadValues({}, state), {
|
784
|
+
data: {
|
785
|
+
root,
|
786
|
+
content: processedContent,
|
787
|
+
zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
|
788
|
+
},
|
789
|
+
indexes: {
|
790
|
+
nodes: __spreadValues(__spreadValues({}, state.indexes.nodes), newNodeIndex),
|
791
|
+
zones: __spreadValues(__spreadValues({}, state.indexes.zones), newZoneIndex)
|
792
|
+
}
|
793
|
+
});
|
713
794
|
}
|
714
795
|
|
715
|
-
// ../core/
|
796
|
+
// ../core/reducer/actions/set.ts
|
797
|
+
var setAction = (state, action, appStore) => {
|
798
|
+
if (typeof action.state === "object") {
|
799
|
+
const newState = __spreadValues(__spreadValues({}, state), action.state);
|
800
|
+
if (action.state.indexes) {
|
801
|
+
return newState;
|
802
|
+
}
|
803
|
+
console.warn(
|
804
|
+
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
805
|
+
);
|
806
|
+
return walkAppState(newState, appStore.config);
|
807
|
+
}
|
808
|
+
return __spreadValues(__spreadValues({}, state), action.state(state));
|
809
|
+
};
|
810
|
+
|
811
|
+
// ../core/reducer/actions/insert.ts
|
716
812
|
init_react_import();
|
717
813
|
|
814
|
+
// ../core/lib/data/insert.ts
|
815
|
+
init_react_import();
|
816
|
+
var insert = (list, index, item) => {
|
817
|
+
const result = Array.from(list || []);
|
818
|
+
result.splice(index, 0, item);
|
819
|
+
return result;
|
820
|
+
};
|
821
|
+
|
718
822
|
// ../core/lib/generate-id.ts
|
719
823
|
init_react_import();
|
720
824
|
|
@@ -777,313 +881,438 @@ var v4_default = v4;
|
|
777
881
|
// ../core/lib/generate-id.ts
|
778
882
|
var generateId = (type) => type ? `${type}-${v4_default()}` : v4_default();
|
779
883
|
|
780
|
-
// ../core/lib/get-
|
884
|
+
// ../core/lib/data/get-ids-for-parent.ts
|
781
885
|
init_react_import();
|
782
|
-
var
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
787
|
-
return zoneCompound.split(":");
|
788
|
-
}
|
789
|
-
return [rootDroppableId, zoneCompound];
|
886
|
+
var getIdsForParent = (zoneCompound, state) => {
|
887
|
+
const [parentId] = zoneCompound.split(":");
|
888
|
+
const node = state.indexes.nodes[parentId];
|
889
|
+
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
|
790
890
|
};
|
791
891
|
|
792
|
-
// ../core/lib/
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
892
|
+
// ../core/lib/data/populate-ids.ts
|
893
|
+
init_react_import();
|
894
|
+
|
895
|
+
// ../core/lib/data/walk-tree.ts
|
896
|
+
init_react_import();
|
897
|
+
function walkTree(data, config, callbackFn) {
|
898
|
+
var _a, _b;
|
899
|
+
const walkItem = (item) => {
|
900
|
+
return mapSlots(
|
901
|
+
item,
|
902
|
+
(content, parentId, propName) => {
|
903
|
+
var _a2;
|
904
|
+
return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
|
803
905
|
},
|
906
|
+
config,
|
907
|
+
true
|
908
|
+
);
|
909
|
+
};
|
910
|
+
if ("props" in data) {
|
911
|
+
return walkItem(data);
|
912
|
+
}
|
913
|
+
const _data = data;
|
914
|
+
const zones = (_a = _data.zones) != null ? _a : {};
|
915
|
+
const mappedContent = _data.content.map(walkItem);
|
916
|
+
return {
|
917
|
+
root: walkItem(_data.root),
|
918
|
+
content: (_b = callbackFn(mappedContent, {
|
919
|
+
parentId: "root",
|
920
|
+
propName: "default-zone"
|
921
|
+
})) != null ? _b : mappedContent,
|
922
|
+
zones: Object.keys(zones).reduce(
|
923
|
+
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
|
924
|
+
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
925
|
+
}),
|
804
926
|
{}
|
805
927
|
)
|
806
|
-
}
|
928
|
+
};
|
807
929
|
}
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
930
|
+
|
931
|
+
// ../core/lib/data/populate-ids.ts
|
932
|
+
var populateIds = (data, config, override = false) => {
|
933
|
+
const id = generateId(data.type);
|
934
|
+
return walkTree(
|
935
|
+
__spreadProps(__spreadValues({}, data), {
|
936
|
+
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({}, data.props)
|
937
|
+
}),
|
938
|
+
config,
|
939
|
+
(contents) => contents.map((item) => {
|
940
|
+
const id2 = generateId(item.type);
|
941
|
+
return __spreadProps(__spreadValues({}, item), {
|
942
|
+
props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
|
943
|
+
});
|
944
|
+
})
|
945
|
+
);
|
946
|
+
};
|
947
|
+
|
948
|
+
// ../core/reducer/actions/insert.ts
|
949
|
+
function insertAction(state, action, appStore) {
|
950
|
+
const id = action.id || generateId(action.componentType);
|
951
|
+
const emptyComponentData = populateIds(
|
952
|
+
{
|
953
|
+
type: action.componentType,
|
954
|
+
props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
|
955
|
+
id
|
956
|
+
})
|
957
|
+
},
|
958
|
+
appStore.config
|
959
|
+
);
|
960
|
+
const [parentId] = action.destinationZone.split(":");
|
961
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
962
|
+
return walkAppState(
|
963
|
+
state,
|
964
|
+
appStore.config,
|
965
|
+
(content, zoneCompound) => {
|
966
|
+
if (zoneCompound === action.destinationZone) {
|
967
|
+
return insert(
|
968
|
+
content || [],
|
969
|
+
action.destinationIndex,
|
970
|
+
emptyComponentData
|
971
|
+
);
|
815
972
|
}
|
816
|
-
return
|
973
|
+
return content;
|
817
974
|
},
|
818
|
-
{
|
975
|
+
(childItem, path) => {
|
976
|
+
if (childItem.props.id === id || childItem.props.id === parentId) {
|
977
|
+
return childItem;
|
978
|
+
} else if (idsInPath.includes(childItem.props.id)) {
|
979
|
+
return childItem;
|
980
|
+
} else if (path.includes(action.destinationZone)) {
|
981
|
+
return childItem;
|
982
|
+
}
|
983
|
+
return null;
|
984
|
+
}
|
819
985
|
);
|
820
|
-
}
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
986
|
+
}
|
987
|
+
|
988
|
+
// ../core/reducer/actions/replace.ts
|
989
|
+
init_react_import();
|
990
|
+
var replaceAction = (state, action, appStore) => {
|
991
|
+
const [parentId] = action.destinationZone.split(":");
|
992
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
993
|
+
const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
|
994
|
+
const idChanged = originalId !== action.data.props.id;
|
995
|
+
if (idChanged) {
|
996
|
+
throw new Error(
|
997
|
+
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
998
|
+
);
|
999
|
+
}
|
1000
|
+
const data = populateIds(action.data, appStore.config);
|
1001
|
+
return walkAppState(
|
1002
|
+
state,
|
1003
|
+
appStore.config,
|
1004
|
+
(content, zoneCompound) => {
|
1005
|
+
const newContent = [...content];
|
1006
|
+
if (zoneCompound === action.destinationZone) {
|
1007
|
+
newContent[action.destinationIndex] = data;
|
830
1008
|
}
|
831
|
-
return
|
1009
|
+
return newContent;
|
832
1010
|
},
|
833
|
-
{
|
1011
|
+
(childItem, path) => {
|
1012
|
+
const pathIds = path.map((p) => p.split(":")[0]);
|
1013
|
+
if (childItem.props.id === data.props.id) {
|
1014
|
+
return data;
|
1015
|
+
} else if (childItem.props.id === parentId) {
|
1016
|
+
return childItem;
|
1017
|
+
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
1018
|
+
return childItem;
|
1019
|
+
} else if (pathIds.indexOf(data.props.id) > -1) {
|
1020
|
+
return childItem;
|
1021
|
+
}
|
1022
|
+
return null;
|
1023
|
+
}
|
834
1024
|
);
|
835
1025
|
};
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
1026
|
+
|
1027
|
+
// ../core/reducer/actions/replace-root.ts
|
1028
|
+
init_react_import();
|
1029
|
+
var replaceRootAction = (state, action, appStore) => {
|
1030
|
+
return walkAppState(
|
1031
|
+
state,
|
1032
|
+
appStore.config,
|
1033
|
+
(content) => content,
|
1034
|
+
(childItem) => {
|
1035
|
+
if (childItem.props.id === "root") {
|
1036
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
1037
|
+
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
1038
|
+
readOnly: action.root.readOnly
|
1039
|
+
});
|
1040
|
+
}
|
1041
|
+
return childItem;
|
1042
|
+
}
|
1043
|
+
);
|
843
1044
|
};
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
return __spreadProps(__spreadValues({}, dupeOfDupes), {
|
855
|
-
[key]: zone,
|
856
|
-
[`${newId}:${zoneId}`]: dupedZone
|
857
|
-
});
|
858
|
-
});
|
1045
|
+
|
1046
|
+
// ../core/reducer/actions/duplicate.ts
|
1047
|
+
init_react_import();
|
1048
|
+
|
1049
|
+
// ../core/lib/data/get-item.ts
|
1050
|
+
init_react_import();
|
1051
|
+
function getItem(selector, state) {
|
1052
|
+
var _a, _b;
|
1053
|
+
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
1054
|
+
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
859
1055
|
}
|
860
1056
|
|
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
|
-
)
|
1057
|
+
// ../core/reducer/actions/duplicate.ts
|
1058
|
+
function duplicateAction(state, action, appStore) {
|
1059
|
+
const item = getItem(
|
1060
|
+
{ index: action.sourceIndex, zone: action.sourceZone },
|
1061
|
+
state
|
1062
|
+
);
|
1063
|
+
const idsInPath = getIdsForParent(action.sourceZone, state);
|
1064
|
+
const newItem = __spreadProps(__spreadValues({}, item), {
|
1065
|
+
props: __spreadProps(__spreadValues({}, item.props), {
|
1066
|
+
id: generateId(item.type)
|
877
1067
|
})
|
878
1068
|
});
|
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
|
-
|
1069
|
+
const modified = walkAppState(
|
1070
|
+
state,
|
1071
|
+
appStore.config,
|
1072
|
+
(content, zoneCompound) => {
|
1073
|
+
if (zoneCompound === action.sourceZone) {
|
1074
|
+
return insert(content, action.sourceIndex + 1, item);
|
1075
|
+
}
|
1076
|
+
return content;
|
1077
|
+
},
|
1078
|
+
(childItem, path, index) => {
|
1079
|
+
const zoneCompound = path[path.length - 1];
|
1080
|
+
const parents = path.map((p) => p.split(":")[0]);
|
1081
|
+
if (parents.indexOf(newItem.props.id) > -1) {
|
1082
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
1083
|
+
props: __spreadProps(__spreadValues({}, childItem.props), {
|
1084
|
+
id: generateId(childItem.type)
|
1085
|
+
})
|
1086
|
+
});
|
1087
|
+
}
|
1088
|
+
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
1089
|
+
return newItem;
|
1090
|
+
}
|
1091
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
1092
|
+
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
1093
|
+
return childItem;
|
1094
|
+
}
|
1095
|
+
return null;
|
1096
|
+
}
|
1097
|
+
);
|
1098
|
+
return __spreadProps(__spreadValues({}, modified), {
|
1099
|
+
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
1100
|
+
itemSelector: {
|
1101
|
+
index: action.sourceIndex + 1,
|
1102
|
+
zone: action.sourceZone
|
1103
|
+
}
|
904
1104
|
})
|
905
1105
|
});
|
906
1106
|
}
|
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
|
-
});
|
1107
|
+
|
1108
|
+
// ../core/reducer/actions/reorder.ts
|
1109
|
+
init_react_import();
|
1110
|
+
|
1111
|
+
// ../core/reducer/actions/move.ts
|
1112
|
+
init_react_import();
|
1113
|
+
|
1114
|
+
// ../core/lib/data/remove.ts
|
1115
|
+
init_react_import();
|
1116
|
+
var remove = (list, index) => {
|
1117
|
+
const result = Array.from(list);
|
1118
|
+
result.splice(index, 1);
|
1119
|
+
return result;
|
927
1120
|
};
|
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);
|
1121
|
+
|
1122
|
+
// ../core/reducer/actions/move.ts
|
1123
|
+
var moveAction = (state, action, appStore) => {
|
1124
|
+
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
1125
|
+
return state;
|
964
1126
|
}
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
1127
|
+
const item = getItem(
|
1128
|
+
{ zone: action.sourceZone, index: action.sourceIndex },
|
1129
|
+
state
|
1130
|
+
);
|
1131
|
+
if (!item) return state;
|
1132
|
+
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
1133
|
+
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
1134
|
+
return walkAppState(
|
1135
|
+
state,
|
1136
|
+
appStore.config,
|
1137
|
+
(content, zoneCompound) => {
|
1138
|
+
if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
|
1139
|
+
return insert(
|
1140
|
+
remove(content, action.sourceIndex),
|
1141
|
+
action.destinationIndex,
|
1142
|
+
item
|
1143
|
+
);
|
1144
|
+
} else if (zoneCompound === action.sourceZone) {
|
1145
|
+
return remove(content, action.sourceIndex);
|
1146
|
+
} else if (zoneCompound === action.destinationZone) {
|
1147
|
+
return insert(content, action.destinationIndex, item);
|
1148
|
+
}
|
1149
|
+
return content;
|
1150
|
+
},
|
1151
|
+
(childItem, path) => {
|
1152
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
1153
|
+
const [destinationZoneParent] = action.destinationZone.split(":");
|
1154
|
+
const childId = childItem.props.id;
|
1155
|
+
if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1 || path.includes(action.destinationZone)) {
|
1156
|
+
return childItem;
|
1157
|
+
}
|
1158
|
+
return null;
|
979
1159
|
}
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
1160
|
+
);
|
1161
|
+
};
|
1162
|
+
|
1163
|
+
// ../core/reducer/actions/reorder.ts
|
1164
|
+
var reorderAction = (state, action, appStore) => {
|
1165
|
+
return moveAction(
|
1166
|
+
state,
|
1167
|
+
{
|
1168
|
+
type: "move",
|
1169
|
+
sourceIndex: action.sourceIndex,
|
1170
|
+
sourceZone: action.destinationZone,
|
1171
|
+
destinationIndex: action.destinationIndex,
|
1172
|
+
destinationZone: action.destinationZone
|
1173
|
+
},
|
1174
|
+
appStore
|
1175
|
+
);
|
1176
|
+
};
|
1177
|
+
|
1178
|
+
// ../core/reducer/actions/remove.ts
|
1179
|
+
init_react_import();
|
1180
|
+
var removeAction = (state, action, appStore) => {
|
1181
|
+
const item = getItem({ index: action.index, zone: action.zone }, state);
|
1182
|
+
const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
|
1183
|
+
(acc, [nodeId, nodeData]) => {
|
1184
|
+
const pathIds = nodeData.path.map((p) => p.split(":")[0]);
|
1185
|
+
if (pathIds.includes(item.props.id)) {
|
1186
|
+
return [...acc, nodeId];
|
1187
|
+
}
|
1188
|
+
return acc;
|
1189
|
+
},
|
1190
|
+
[item.props.id]
|
1191
|
+
);
|
1192
|
+
const newState = walkAppState(
|
1193
|
+
state,
|
1194
|
+
appStore.config,
|
1195
|
+
(content, zoneCompound) => {
|
1196
|
+
if (zoneCompound === action.zone) {
|
1197
|
+
return remove(content, action.index);
|
1198
|
+
}
|
1199
|
+
return content;
|
991
1200
|
}
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
newData.zones[action.sourceZone],
|
998
|
-
action.sourceIndex
|
999
|
-
)
|
1000
|
-
})
|
1001
|
-
});
|
1201
|
+
);
|
1202
|
+
Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
|
1203
|
+
const parentId = zoneCompound.split(":")[0];
|
1204
|
+
if (nodesToDelete.includes(parentId) && newState.data.zones) {
|
1205
|
+
delete newState.data.zones[zoneCompound];
|
1002
1206
|
}
|
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
|
-
});
|
1207
|
+
});
|
1208
|
+
Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
|
1209
|
+
const parentId = zoneCompound.split(":")[0];
|
1210
|
+
if (nodesToDelete.includes(parentId)) {
|
1211
|
+
delete newState.indexes.zones[zoneCompound];
|
1030
1212
|
}
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1213
|
+
});
|
1214
|
+
nodesToDelete.forEach((id) => {
|
1215
|
+
delete newState.indexes.nodes[id];
|
1216
|
+
});
|
1217
|
+
return newState;
|
1218
|
+
};
|
1219
|
+
|
1220
|
+
// ../core/reducer/actions/register-zone.ts
|
1221
|
+
init_react_import();
|
1222
|
+
|
1223
|
+
// ../core/lib/data/setup-zone.ts
|
1224
|
+
init_react_import();
|
1225
|
+
var setupZone = (data, zoneKey) => {
|
1226
|
+
if (zoneKey === rootDroppableId) {
|
1227
|
+
return data;
|
1039
1228
|
}
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1229
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
1230
|
+
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
1231
|
+
});
|
1232
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
1233
|
+
return newData;
|
1234
|
+
};
|
1235
|
+
|
1236
|
+
// ../core/reducer/actions/register-zone.ts
|
1237
|
+
var zoneCache = {};
|
1238
|
+
function registerZoneAction(state, action) {
|
1239
|
+
if (zoneCache[action.zone]) {
|
1240
|
+
return __spreadProps(__spreadValues({}, state), {
|
1241
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
1242
|
+
zones: __spreadProps(__spreadValues({}, state.data.zones), {
|
1044
1243
|
[action.zone]: zoneCache[action.zone]
|
1045
1244
|
})
|
1046
|
-
})
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
}
|
1056
|
-
return __spreadProps(__spreadValues({}, data), { zones: _zones });
|
1245
|
+
}),
|
1246
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1247
|
+
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
|
1248
|
+
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
|
1249
|
+
contentIds: zoneCache[action.zone].map((item) => item.props.id),
|
1250
|
+
type: "dropzone"
|
1251
|
+
})
|
1252
|
+
})
|
1253
|
+
})
|
1254
|
+
});
|
1057
1255
|
}
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1256
|
+
return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
|
1257
|
+
}
|
1258
|
+
function unregisterZoneAction(state, action) {
|
1259
|
+
const _zones = __spreadValues({}, state.data.zones || {});
|
1260
|
+
const zoneIndex = __spreadValues({}, state.indexes.zones || {});
|
1261
|
+
if (_zones[action.zone]) {
|
1262
|
+
zoneCache[action.zone] = _zones[action.zone];
|
1263
|
+
delete _zones[action.zone];
|
1063
1264
|
}
|
1064
|
-
|
1265
|
+
delete zoneIndex[action.zone];
|
1266
|
+
return __spreadProps(__spreadValues({}, state), {
|
1267
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
1268
|
+
zones: _zones
|
1269
|
+
}),
|
1270
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1271
|
+
zones: zoneIndex
|
1272
|
+
})
|
1273
|
+
});
|
1065
1274
|
}
|
1066
1275
|
|
1067
|
-
// ../core/reducer/
|
1276
|
+
// ../core/reducer/actions/set-data.ts
|
1068
1277
|
init_react_import();
|
1069
|
-
var
|
1070
|
-
if (action.
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
return
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1278
|
+
var setDataAction = (state, action, appStore) => {
|
1279
|
+
if (typeof action.data === "object") {
|
1280
|
+
console.warn(
|
1281
|
+
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1282
|
+
);
|
1283
|
+
return walkAppState(
|
1284
|
+
__spreadProps(__spreadValues({}, state), {
|
1285
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
1286
|
+
}),
|
1287
|
+
appStore.config
|
1288
|
+
);
|
1080
1289
|
}
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1290
|
+
return walkAppState(
|
1291
|
+
__spreadProps(__spreadValues({}, state), {
|
1292
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
1293
|
+
}),
|
1294
|
+
appStore.config
|
1295
|
+
);
|
1296
|
+
};
|
1297
|
+
|
1298
|
+
// ../core/reducer/actions/set-ui.ts
|
1299
|
+
init_react_import();
|
1300
|
+
var setUiAction = (state, action) => {
|
1301
|
+
if (typeof action.ui === "object") {
|
1302
|
+
return __spreadProps(__spreadValues({}, state), {
|
1303
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
|
1084
1304
|
});
|
1085
1305
|
}
|
1086
|
-
return
|
1306
|
+
return __spreadProps(__spreadValues({}, state), {
|
1307
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
|
1308
|
+
});
|
1309
|
+
};
|
1310
|
+
|
1311
|
+
// ../core/lib/data/make-state-public.ts
|
1312
|
+
init_react_import();
|
1313
|
+
var makeStatePublic = (state) => {
|
1314
|
+
const { data, ui } = state;
|
1315
|
+
return { data, ui };
|
1087
1316
|
};
|
1088
1317
|
|
1089
1318
|
// ../core/reducer/actions.tsx
|
@@ -1103,29 +1332,54 @@ function storeInterceptor(reducer, record, onAction) {
|
|
1103
1332
|
if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
|
1104
1333
|
if (record) record(newAppState);
|
1105
1334
|
}
|
1106
|
-
onAction == null ? void 0 : onAction(action, newAppState, state);
|
1107
|
-
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
|
-
};
|
1335
|
+
onAction == null ? void 0 : onAction(action, makeStatePublic(newAppState), makeStatePublic(state));
|
1336
|
+
return newAppState;
|
1337
|
+
};
|
1338
|
+
}
|
1116
1339
|
function createReducer({
|
1117
|
-
config,
|
1118
1340
|
record,
|
1119
|
-
onAction
|
1341
|
+
onAction,
|
1342
|
+
appStore
|
1120
1343
|
}) {
|
1121
1344
|
return storeInterceptor(
|
1122
1345
|
(state, action) => {
|
1123
|
-
const data = reduceData(state.data, action, config);
|
1124
|
-
const ui = reduceUi(state.ui, action);
|
1125
1346
|
if (action.type === "set") {
|
1126
|
-
return setAction(state, action);
|
1347
|
+
return setAction(state, action, appStore);
|
1348
|
+
}
|
1349
|
+
if (action.type === "insert") {
|
1350
|
+
return insertAction(state, action, appStore);
|
1351
|
+
}
|
1352
|
+
if (action.type === "replace") {
|
1353
|
+
return replaceAction(state, action, appStore);
|
1354
|
+
}
|
1355
|
+
if (action.type === "replaceRoot") {
|
1356
|
+
return replaceRootAction(state, action, appStore);
|
1357
|
+
}
|
1358
|
+
if (action.type === "duplicate") {
|
1359
|
+
return duplicateAction(state, action, appStore);
|
1127
1360
|
}
|
1128
|
-
|
1361
|
+
if (action.type === "reorder") {
|
1362
|
+
return reorderAction(state, action, appStore);
|
1363
|
+
}
|
1364
|
+
if (action.type === "move") {
|
1365
|
+
return moveAction(state, action, appStore);
|
1366
|
+
}
|
1367
|
+
if (action.type === "remove") {
|
1368
|
+
return removeAction(state, action, appStore);
|
1369
|
+
}
|
1370
|
+
if (action.type === "registerZone") {
|
1371
|
+
return registerZoneAction(state, action);
|
1372
|
+
}
|
1373
|
+
if (action.type === "unregisterZone") {
|
1374
|
+
return unregisterZoneAction(state, action);
|
1375
|
+
}
|
1376
|
+
if (action.type === "setData") {
|
1377
|
+
return setDataAction(state, action, appStore);
|
1378
|
+
}
|
1379
|
+
if (action.type === "setUi") {
|
1380
|
+
return setUiAction(state, action);
|
1381
|
+
}
|
1382
|
+
return state;
|
1129
1383
|
},
|
1130
1384
|
record,
|
1131
1385
|
onAction
|
@@ -1140,20 +1394,16 @@ var defaultViewports = [
|
|
1140
1394
|
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
1141
1395
|
];
|
1142
1396
|
|
1143
|
-
// ../../node_modules/zustand/esm/index.mjs
|
1144
|
-
init_react_import();
|
1145
|
-
|
1146
1397
|
// ../../node_modules/zustand/esm/vanilla.mjs
|
1147
1398
|
init_react_import();
|
1148
|
-
var import_meta = {};
|
1149
1399
|
var createStoreImpl = (createState) => {
|
1150
1400
|
let state;
|
1151
1401
|
const listeners = /* @__PURE__ */ new Set();
|
1152
|
-
const setState = (partial,
|
1402
|
+
const setState = (partial, replace) => {
|
1153
1403
|
const nextState = typeof partial === "function" ? partial(state) : partial;
|
1154
1404
|
if (!Object.is(nextState, state)) {
|
1155
1405
|
const previousState = state;
|
1156
|
-
state = (
|
1406
|
+
state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
|
1157
1407
|
listeners.forEach((listener) => listener(state, previousState));
|
1158
1408
|
}
|
1159
1409
|
};
|
@@ -1163,53 +1413,28 @@ var createStoreImpl = (createState) => {
|
|
1163
1413
|
listeners.add(listener);
|
1164
1414
|
return () => listeners.delete(listener);
|
1165
1415
|
};
|
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 };
|
1416
|
+
const api = { setState, getState, getInitialState, subscribe };
|
1175
1417
|
const initialState = state = createState(setState, getState, api);
|
1176
1418
|
return api;
|
1177
1419
|
};
|
1178
1420
|
var createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
|
1179
1421
|
|
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;
|
1422
|
+
// ../../node_modules/zustand/esm/react.mjs
|
1423
|
+
init_react_import();
|
1424
|
+
import React2 from "react";
|
1187
1425
|
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(
|
1426
|
+
function useStore(api, selector = identity) {
|
1427
|
+
const slice = React2.useSyncExternalStore(
|
1196
1428
|
api.subscribe,
|
1197
|
-
api.getState,
|
1198
|
-
|
1199
|
-
selector,
|
1200
|
-
equalityFn
|
1429
|
+
() => selector(api.getState()),
|
1430
|
+
() => selector(api.getInitialState())
|
1201
1431
|
);
|
1202
|
-
useDebugValue(slice);
|
1432
|
+
React2.useDebugValue(slice);
|
1203
1433
|
return slice;
|
1204
1434
|
}
|
1205
1435
|
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);
|
1436
|
+
const api = createStore(createState);
|
1437
|
+
const useBoundStore = (selector) => useStore(api, selector);
|
1213
1438
|
Object.assign(useBoundStore, api);
|
1214
1439
|
return useBoundStore;
|
1215
1440
|
};
|
@@ -1242,206 +1467,6 @@ var subscribeWithSelectorImpl = (fn) => (set, get, api) => {
|
|
1242
1467
|
};
|
1243
1468
|
var subscribeWithSelector = subscribeWithSelectorImpl;
|
1244
1469
|
|
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
1470
|
// ../core/store/index.ts
|
1446
1471
|
import { createContext, useContext } from "react";
|
1447
1472
|
|
@@ -1549,7 +1574,7 @@ var createHistorySlice = (set, get) => {
|
|
1549
1574
|
const { dispatch, history } = get();
|
1550
1575
|
dispatch({
|
1551
1576
|
type: "set",
|
1552
|
-
state: ((_a = history.histories[
|
1577
|
+
state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
|
1553
1578
|
});
|
1554
1579
|
set({ history: __spreadProps(__spreadValues({}, history), { index }) });
|
1555
1580
|
},
|
@@ -1559,31 +1584,18 @@ var createHistorySlice = (set, get) => {
|
|
1559
1584
|
|
1560
1585
|
// ../core/store/slices/nodes.ts
|
1561
1586
|
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
1587
|
var createNodesSlice = (set, get) => ({
|
1572
1588
|
nodes: {},
|
1573
1589
|
registerNode: (id, node) => {
|
1574
1590
|
const s = get().nodes;
|
1575
|
-
if (s.nodes[id] && partialDeepEqual(node, s.nodes[id])) {
|
1576
|
-
return;
|
1577
|
-
}
|
1578
1591
|
const emptyNode = {
|
1579
1592
|
id,
|
1580
|
-
methods: {
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
element: null
|
1586
|
-
index: -1
|
1593
|
+
methods: {
|
1594
|
+
sync: () => null,
|
1595
|
+
hideOverlay: () => null,
|
1596
|
+
showOverlay: () => null
|
1597
|
+
},
|
1598
|
+
element: null
|
1587
1599
|
};
|
1588
1600
|
const existingNode = s.nodes[id];
|
1589
1601
|
set({
|
@@ -1613,36 +1625,62 @@ var createNodesSlice = (set, get) => ({
|
|
1613
1625
|
|
1614
1626
|
// ../core/store/slices/permissions.ts
|
1615
1627
|
init_react_import();
|
1616
|
-
import { useEffect as
|
1628
|
+
import { useEffect as useEffect3 } from "react";
|
1629
|
+
|
1630
|
+
// ../core/lib/data/flatten-data.ts
|
1631
|
+
init_react_import();
|
1632
|
+
var flattenData = (state, config) => {
|
1633
|
+
const data = [];
|
1634
|
+
walkAppState(
|
1635
|
+
state,
|
1636
|
+
config,
|
1637
|
+
(content) => content,
|
1638
|
+
(item) => {
|
1639
|
+
data.push(item);
|
1640
|
+
return null;
|
1641
|
+
}
|
1642
|
+
);
|
1643
|
+
return data;
|
1644
|
+
};
|
1645
|
+
|
1646
|
+
// ../core/lib/get-changed.ts
|
1647
|
+
init_react_import();
|
1648
|
+
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1649
|
+
var getChanged = (newItem, oldItem) => {
|
1650
|
+
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
1651
|
+
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
1652
|
+
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
1653
|
+
return __spreadProps(__spreadValues({}, acc), {
|
1654
|
+
[item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
|
1655
|
+
});
|
1656
|
+
}, {}) : {};
|
1657
|
+
};
|
1658
|
+
|
1659
|
+
// ../core/store/slices/permissions.ts
|
1617
1660
|
var createPermissionsSlice = (set, get) => {
|
1618
1661
|
const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
|
1619
|
-
const { state, permissions } = get();
|
1620
|
-
const { cache:
|
1662
|
+
const { state, permissions, config } = get();
|
1663
|
+
const { cache: cache2, globalPermissions } = permissions;
|
1621
1664
|
const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
|
1622
1665
|
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];
|
1666
|
+
const { config: config2, state: appState, setComponentLoading } = get();
|
1667
|
+
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
1630
1668
|
if (!componentConfig) {
|
1631
1669
|
return;
|
1632
1670
|
}
|
1633
1671
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
1634
1672
|
if (componentConfig.resolvePermissions) {
|
1635
|
-
const changed = getChanged(item2, (_a =
|
1673
|
+
const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
|
1636
1674
|
if (Object.values(changed).some((el) => el === true) || force2) {
|
1637
|
-
setComponentLoading(item2.props.id);
|
1675
|
+
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
1638
1676
|
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
1639
1677
|
item2,
|
1640
1678
|
{
|
1641
1679
|
changed,
|
1642
|
-
lastPermissions: ((_b =
|
1680
|
+
lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
|
1643
1681
|
permissions: initialPermissions,
|
1644
|
-
appState,
|
1645
|
-
lastData: ((_c =
|
1682
|
+
appState: makeStatePublic(appState),
|
1683
|
+
lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
|
1646
1684
|
}
|
1647
1685
|
);
|
1648
1686
|
const latest = get().permissions;
|
@@ -1659,7 +1697,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1659
1697
|
})
|
1660
1698
|
})
|
1661
1699
|
});
|
1662
|
-
|
1700
|
+
clearTimeout2();
|
1663
1701
|
}
|
1664
1702
|
}
|
1665
1703
|
});
|
@@ -1669,7 +1707,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1669
1707
|
// Shim the root data in by conforming to component data shape
|
1670
1708
|
{
|
1671
1709
|
type: "root",
|
1672
|
-
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "
|
1710
|
+
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "root" })
|
1673
1711
|
},
|
1674
1712
|
force2
|
1675
1713
|
);
|
@@ -1678,14 +1716,13 @@ var createPermissionsSlice = (set, get) => {
|
|
1678
1716
|
if (item) {
|
1679
1717
|
yield resolveDataForItem(item, force);
|
1680
1718
|
} else if (type) {
|
1681
|
-
flattenData(state
|
1719
|
+
flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(void 0, null, function* () {
|
1682
1720
|
yield resolveDataForItem(item2, force);
|
1683
1721
|
}));
|
1684
1722
|
} else if (root) {
|
1685
1723
|
resolveDataForRoot(force);
|
1686
1724
|
} else {
|
1687
|
-
|
1688
|
-
flattenData(state.data).map((item2) => __async(void 0, null, function* () {
|
1725
|
+
flattenData(state, config).map((item2) => __async(void 0, null, function* () {
|
1689
1726
|
yield resolveDataForItem(item2, force);
|
1690
1727
|
}));
|
1691
1728
|
}
|
@@ -1715,7 +1752,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1715
1752
|
} else if (root) {
|
1716
1753
|
const rootConfig = config.root;
|
1717
1754
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
|
1718
|
-
const resolvedForItem = resolvedPermissions["
|
1755
|
+
const resolvedForItem = resolvedPermissions["root"];
|
1719
1756
|
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
1720
1757
|
}
|
1721
1758
|
return globalPermissions;
|
@@ -1727,16 +1764,97 @@ var createPermissionsSlice = (set, get) => {
|
|
1727
1764
|
|
1728
1765
|
// ../core/store/slices/fields.ts
|
1729
1766
|
init_react_import();
|
1730
|
-
import { useCallback, useEffect as
|
1731
|
-
var
|
1767
|
+
import { useCallback, useEffect as useEffect4 } from "react";
|
1768
|
+
var createFieldsSlice = (_set, _get) => {
|
1732
1769
|
return {
|
1733
1770
|
fields: {},
|
1734
1771
|
loading: false,
|
1735
|
-
lastResolvedData: {}
|
1772
|
+
lastResolvedData: {},
|
1773
|
+
id: void 0
|
1736
1774
|
};
|
1737
1775
|
};
|
1738
1776
|
|
1739
|
-
// ../core/
|
1777
|
+
// ../core/lib/resolve-component-data.ts
|
1778
|
+
init_react_import();
|
1779
|
+
var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
|
1780
|
+
var cache = { lastChange: {} };
|
1781
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
1782
|
+
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
1783
|
+
const resolvedItem = __spreadValues({}, item);
|
1784
|
+
const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
|
1785
|
+
const id = "id" in item.props ? item.props.id : "root";
|
1786
|
+
if (shouldRunResolver) {
|
1787
|
+
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
1788
|
+
if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
|
1789
|
+
return { node: resolved, didChange: false };
|
1790
|
+
}
|
1791
|
+
const changed = getChanged(item, oldItem);
|
1792
|
+
if (onResolveStart) {
|
1793
|
+
onResolveStart(item);
|
1794
|
+
}
|
1795
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
1796
|
+
changed,
|
1797
|
+
lastData: oldItem,
|
1798
|
+
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
1799
|
+
trigger
|
1800
|
+
});
|
1801
|
+
resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
|
1802
|
+
if (Object.keys(readOnly).length) {
|
1803
|
+
resolvedItem.readOnly = readOnly;
|
1804
|
+
}
|
1805
|
+
}
|
1806
|
+
let itemWithResolvedChildren = yield mapSlots(
|
1807
|
+
resolvedItem,
|
1808
|
+
(content) => __async(void 0, null, function* () {
|
1809
|
+
return yield Promise.all(
|
1810
|
+
content.map(
|
1811
|
+
(childItem) => __async(void 0, null, function* () {
|
1812
|
+
return (yield resolveComponentData(
|
1813
|
+
childItem,
|
1814
|
+
config,
|
1815
|
+
metadata,
|
1816
|
+
onResolveStart,
|
1817
|
+
onResolveEnd,
|
1818
|
+
trigger
|
1819
|
+
)).node;
|
1820
|
+
})
|
1821
|
+
)
|
1822
|
+
);
|
1823
|
+
}),
|
1824
|
+
config
|
1825
|
+
);
|
1826
|
+
if (shouldRunResolver && onResolveEnd) {
|
1827
|
+
onResolveEnd(resolvedItem);
|
1828
|
+
}
|
1829
|
+
cache.lastChange[id] = {
|
1830
|
+
item,
|
1831
|
+
resolved: itemWithResolvedChildren
|
1832
|
+
};
|
1833
|
+
return {
|
1834
|
+
node: itemWithResolvedChildren,
|
1835
|
+
didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
|
1836
|
+
};
|
1837
|
+
});
|
1838
|
+
|
1839
|
+
// ../core/lib/data/to-root.ts
|
1840
|
+
init_react_import();
|
1841
|
+
var toRoot = (item) => {
|
1842
|
+
if ("type" in item && item.type !== "root") {
|
1843
|
+
throw new Error("Converting non-root item to root.");
|
1844
|
+
}
|
1845
|
+
const { readOnly } = item;
|
1846
|
+
if (item.props) {
|
1847
|
+
if ("id" in item.props) {
|
1848
|
+
const _a = item.props, { id } = _a, props = __objRest(_a, ["id"]);
|
1849
|
+
return { props, readOnly };
|
1850
|
+
}
|
1851
|
+
return { props: item.props, readOnly };
|
1852
|
+
}
|
1853
|
+
return { props: {}, readOnly };
|
1854
|
+
};
|
1855
|
+
|
1856
|
+
// ../core/store/default-app-state.ts
|
1857
|
+
init_react_import();
|
1740
1858
|
var defaultAppState = {
|
1741
1859
|
data: { content: [], root: {}, zones: {} },
|
1742
1860
|
ui: {
|
@@ -1756,92 +1874,188 @@ var defaultAppState = {
|
|
1756
1874
|
controlsVisible: true
|
1757
1875
|
},
|
1758
1876
|
field: { focus: null }
|
1877
|
+
},
|
1878
|
+
indexes: {
|
1879
|
+
nodes: {},
|
1880
|
+
zones: {}
|
1759
1881
|
}
|
1760
1882
|
};
|
1883
|
+
|
1884
|
+
// ../core/store/index.ts
|
1761
1885
|
var defaultPageFields = {
|
1762
1886
|
title: { type: "text" }
|
1763
1887
|
};
|
1764
1888
|
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
|
-
|
1889
|
+
subscribeWithSelector((set, get) => {
|
1890
|
+
var _a, _b;
|
1891
|
+
return __spreadProps(__spreadValues({
|
1892
|
+
state: defaultAppState,
|
1893
|
+
config: { components: {} },
|
1894
|
+
componentState: {},
|
1895
|
+
plugins: [],
|
1896
|
+
overrides: {},
|
1897
|
+
viewports: defaultViewports,
|
1898
|
+
zoomConfig: {
|
1899
|
+
autoZoom: 1,
|
1900
|
+
rootHeight: 0,
|
1901
|
+
zoom: 1
|
1902
|
+
},
|
1903
|
+
status: "LOADING",
|
1904
|
+
iframe: {},
|
1905
|
+
metadata: {}
|
1906
|
+
}, initialAppStore), {
|
1907
|
+
fields: createFieldsSlice(set, get),
|
1908
|
+
history: createHistorySlice(set, get),
|
1909
|
+
nodes: createNodesSlice(set, get),
|
1910
|
+
permissions: createPermissionsSlice(set, get),
|
1911
|
+
getComponentConfig: (type) => {
|
1912
|
+
var _a2;
|
1913
|
+
const { config, selectedItem } = get();
|
1914
|
+
const rootFields = ((_a2 = config.root) == null ? void 0 : _a2.fields) || defaultPageFields;
|
1915
|
+
return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
|
1916
|
+
},
|
1917
|
+
selectedItem: ((_a = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _a.ui.itemSelector) ? getItem(
|
1918
|
+
(_b = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _b.ui.itemSelector,
|
1919
|
+
initialAppStore.state
|
1920
|
+
) : null,
|
1921
|
+
dispatch: (action) => set((s) => {
|
1922
|
+
var _a2, _b2;
|
1923
|
+
const { record } = get().history;
|
1924
|
+
const dispatch = createReducer({
|
1925
|
+
record,
|
1926
|
+
appStore: s
|
1927
|
+
});
|
1928
|
+
const state = dispatch(s.state, action);
|
1929
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1930
|
+
(_b2 = (_a2 = get()).onAction) == null ? void 0 : _b2.call(_a2, action, state, get().state);
|
1931
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1932
|
+
}),
|
1933
|
+
setZoomConfig: (zoomConfig) => set({ zoomConfig }),
|
1934
|
+
setStatus: (status) => set({ status }),
|
1935
|
+
setComponentState: (componentState) => set({ componentState }),
|
1936
|
+
pendingLoadTimeouts: {},
|
1937
|
+
setComponentLoading: (id, loading = true, defer = 0) => {
|
1938
|
+
const { setComponentState, pendingLoadTimeouts } = get();
|
1939
|
+
const loadId = generateId();
|
1940
|
+
const setLoading = () => {
|
1941
|
+
var _a2;
|
1942
|
+
const { componentState } = get();
|
1943
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1944
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1945
|
+
loadingCount: (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) + 1
|
1946
|
+
})
|
1947
|
+
}));
|
1948
|
+
};
|
1949
|
+
const unsetLoading = () => {
|
1950
|
+
var _a2;
|
1951
|
+
const { componentState } = get();
|
1952
|
+
clearTimeout(timeout);
|
1953
|
+
delete pendingLoadTimeouts[loadId];
|
1954
|
+
set({ pendingLoadTimeouts });
|
1955
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1956
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1957
|
+
loadingCount: Math.max(
|
1958
|
+
(((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) - 1,
|
1959
|
+
0
|
1960
|
+
)
|
1961
|
+
})
|
1962
|
+
}));
|
1963
|
+
};
|
1964
|
+
const timeout = setTimeout(() => {
|
1965
|
+
if (loading) {
|
1966
|
+
setLoading();
|
1967
|
+
} else {
|
1968
|
+
unsetLoading();
|
1969
|
+
}
|
1970
|
+
delete pendingLoadTimeouts[loadId];
|
1971
|
+
set({ pendingLoadTimeouts });
|
1972
|
+
}, defer);
|
1973
|
+
set({
|
1974
|
+
pendingLoadTimeouts: __spreadProps(__spreadValues({}, pendingLoadTimeouts), {
|
1975
|
+
[id]: timeout
|
1976
|
+
})
|
1977
|
+
});
|
1978
|
+
return unsetLoading;
|
1979
|
+
},
|
1980
|
+
unsetComponentLoading: (id) => {
|
1981
|
+
const { setComponentLoading } = get();
|
1982
|
+
setComponentLoading(id, false);
|
1983
|
+
},
|
1984
|
+
// Helper
|
1985
|
+
setUi: (ui, recordHistory) => set((s) => {
|
1986
|
+
const dispatch = createReducer({
|
1987
|
+
record: () => {
|
1988
|
+
},
|
1989
|
+
appStore: s
|
1990
|
+
});
|
1991
|
+
const state = dispatch(s.state, {
|
1992
|
+
type: "setUi",
|
1993
|
+
ui,
|
1994
|
+
recordHistory
|
1995
|
+
});
|
1996
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1997
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1998
|
+
}),
|
1999
|
+
resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
|
2000
|
+
const { config, metadata, setComponentLoading, permissions } = get();
|
2001
|
+
const timeouts = {};
|
2002
|
+
return yield resolveComponentData(
|
2003
|
+
componentData,
|
2004
|
+
config,
|
2005
|
+
metadata,
|
2006
|
+
(item) => {
|
2007
|
+
const id = "id" in item.props ? item.props.id : "root";
|
2008
|
+
timeouts[id] = setComponentLoading(id, true, 50);
|
2009
|
+
},
|
2010
|
+
(item) => __async(void 0, null, function* () {
|
2011
|
+
const id = "id" in item.props ? item.props.id : "root";
|
2012
|
+
if ("type" in item) {
|
2013
|
+
yield permissions.refreshPermissions({ item });
|
2014
|
+
} else {
|
2015
|
+
yield permissions.refreshPermissions({ root: true });
|
2016
|
+
}
|
2017
|
+
timeouts[id]();
|
2018
|
+
}),
|
2019
|
+
trigger
|
2020
|
+
);
|
2021
|
+
}),
|
2022
|
+
resolveAndCommitData: () => __async(void 0, null, function* () {
|
2023
|
+
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
2024
|
+
walkAppState(
|
2025
|
+
state,
|
2026
|
+
config,
|
2027
|
+
(content) => content,
|
2028
|
+
(childItem) => {
|
2029
|
+
resolveComponentData2(childItem, "load").then((resolved) => {
|
2030
|
+
const { state: state2 } = get();
|
2031
|
+
const node = state2.indexes.nodes[resolved.node.props.id];
|
2032
|
+
if (node && resolved.didChange) {
|
2033
|
+
if (resolved.node.props.id === "root") {
|
2034
|
+
dispatch({
|
2035
|
+
type: "replaceRoot",
|
2036
|
+
root: toRoot(resolved.node)
|
2037
|
+
});
|
2038
|
+
} else {
|
2039
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
2040
|
+
const parentZone = state2.indexes.zones[zoneCompound];
|
2041
|
+
const index = parentZone.contentIds.indexOf(
|
2042
|
+
resolved.node.props.id
|
2043
|
+
);
|
2044
|
+
dispatch({
|
2045
|
+
type: "replace",
|
2046
|
+
data: resolved.node,
|
2047
|
+
destinationIndex: index,
|
2048
|
+
destinationZone: zoneCompound
|
2049
|
+
});
|
2050
|
+
}
|
2051
|
+
}
|
2052
|
+
});
|
2053
|
+
return childItem;
|
2054
|
+
}
|
2055
|
+
);
|
2056
|
+
})
|
2057
|
+
});
|
2058
|
+
})
|
1845
2059
|
);
|
1846
2060
|
var appStoreContext = createContext(createAppStore());
|
1847
2061
|
function useAppStore(selector) {
|
@@ -1861,12 +2075,12 @@ var useBreadcrumbs = (renderCount) => {
|
|
1861
2075
|
const config = useAppStore((s) => s.config);
|
1862
2076
|
const path = useAppStore((s) => {
|
1863
2077
|
var _a;
|
1864
|
-
return (_a = s.
|
2078
|
+
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
1865
2079
|
});
|
1866
2080
|
const appStore = useAppStoreApi();
|
1867
2081
|
return useMemo(() => {
|
1868
2082
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
1869
|
-
var _a, _b;
|
2083
|
+
var _a, _b, _c;
|
1870
2084
|
const [componentId] = zoneCompound.split(":");
|
1871
2085
|
if (componentId === "root") {
|
1872
2086
|
return {
|
@@ -1874,12 +2088,15 @@ var useBreadcrumbs = (renderCount) => {
|
|
1874
2088
|
selector: null
|
1875
2089
|
};
|
1876
2090
|
}
|
1877
|
-
const node = appStore.getState().
|
1878
|
-
const
|
2091
|
+
const node = appStore.getState().state.indexes.nodes[componentId];
|
2092
|
+
const parentId = node.path[node.path.length - 1];
|
2093
|
+
const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
|
2094
|
+
const index = contentIds.indexOf(componentId);
|
2095
|
+
const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
|
1879
2096
|
return {
|
1880
2097
|
label,
|
1881
2098
|
selector: node ? {
|
1882
|
-
index
|
2099
|
+
index,
|
1883
2100
|
zone: node.path[node.path.length - 1]
|
1884
2101
|
} : null
|
1885
2102
|
};
|
@@ -1900,6 +2117,12 @@ init_react_import();
|
|
1900
2117
|
// ../core/lib/filter.ts
|
1901
2118
|
init_react_import();
|
1902
2119
|
|
2120
|
+
// ../core/lib/data/reorder.ts
|
2121
|
+
init_react_import();
|
2122
|
+
|
2123
|
+
// ../core/lib/data/replace.ts
|
2124
|
+
init_react_import();
|
2125
|
+
|
1903
2126
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
|
1904
2127
|
init_react_import();
|
1905
2128
|
var styles_module_default3 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
|
@@ -2081,17 +2304,39 @@ var usePuck = createUsePuck();
|
|
2081
2304
|
var HeadingAnalyzer = () => {
|
2082
2305
|
const data = usePuck((s) => s.appState.data);
|
2083
2306
|
const [hierarchy, setHierarchy] = useState([]);
|
2084
|
-
|
2307
|
+
useEffect5(() => {
|
2085
2308
|
const frame = getFrame();
|
2086
|
-
|
2087
|
-
|
2088
|
-
setHierarchy(buildHierarchy(entry));
|
2089
|
-
const observer = new MutationObserver(() => {
|
2309
|
+
let entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
2310
|
+
const createHierarchy = () => {
|
2090
2311
|
setHierarchy(buildHierarchy(entry));
|
2312
|
+
};
|
2313
|
+
const entryObserver = new MutationObserver(() => {
|
2314
|
+
createHierarchy();
|
2315
|
+
});
|
2316
|
+
const frameObserver = new MutationObserver(() => {
|
2317
|
+
entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
2318
|
+
if (entry) {
|
2319
|
+
registerEntryObserver();
|
2320
|
+
frameObserver.disconnect();
|
2321
|
+
}
|
2091
2322
|
});
|
2092
|
-
|
2323
|
+
const registerEntryObserver = () => {
|
2324
|
+
if (!entry) return;
|
2325
|
+
entryObserver.observe(entry, { subtree: true, childList: true });
|
2326
|
+
};
|
2327
|
+
const registerFrameObserver = () => {
|
2328
|
+
if (!frame) return;
|
2329
|
+
frameObserver.observe(frame, { subtree: true, childList: true });
|
2330
|
+
};
|
2331
|
+
if (entry) {
|
2332
|
+
createHierarchy();
|
2333
|
+
registerEntryObserver();
|
2334
|
+
} else {
|
2335
|
+
registerFrameObserver();
|
2336
|
+
}
|
2093
2337
|
return () => {
|
2094
|
-
|
2338
|
+
entryObserver.disconnect();
|
2339
|
+
frameObserver.disconnect();
|
2095
2340
|
};
|
2096
2341
|
}, [data]);
|
2097
2342
|
return /* @__PURE__ */ jsxs2("div", { className: getClassName5(), children: [
|
@@ -2194,50 +2439,6 @@ classnames/index.js:
|
|
2194
2439
|
http://jedwatson.github.io/classnames
|
2195
2440
|
*)
|
2196
2441
|
|
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
2442
|
lucide-react/dist/esm/shared/src/utils.js:
|
2242
2443
|
(**
|
2243
2444
|
* @license lucide-react v0.468.0 - ISC
|