@measured/puck-plugin-heading-analyzer 0.19.0-canary.af4f756 → 0.19.0-canary.b46ce9ce
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 +1220 -1023
- package/dist/index.mjs +1218 -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,57 +488,327 @@ 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
|
677
|
-
|
678
|
-
|
679
|
-
|
514
|
+
var isPromise = (v) => !!v && typeof v.then === "function";
|
515
|
+
var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
|
516
|
+
var containsPromise = (arr) => arr.some(isPromise);
|
517
|
+
var walkField = ({
|
518
|
+
value,
|
519
|
+
fields,
|
520
|
+
map,
|
521
|
+
propKey = "",
|
522
|
+
propPath = "",
|
523
|
+
id = "",
|
524
|
+
config,
|
525
|
+
recurseSlots = false
|
526
|
+
}) => {
|
527
|
+
var _a, _b, _c;
|
528
|
+
if (((_a = fields[propKey]) == null ? void 0 : _a.type) === "slot") {
|
529
|
+
const content = value || [];
|
530
|
+
const mappedContent = recurseSlots ? content.map((el) => {
|
531
|
+
var _a2;
|
532
|
+
const componentConfig = config.components[el.type];
|
533
|
+
if (!componentConfig) {
|
534
|
+
throw new Error(`Could not find component config for ${el.type}`);
|
535
|
+
}
|
536
|
+
const fields2 = (_a2 = componentConfig.fields) != null ? _a2 : {};
|
537
|
+
return walkField({
|
538
|
+
value: el,
|
539
|
+
fields: fields2,
|
540
|
+
map,
|
541
|
+
id: el.props.id,
|
542
|
+
config,
|
543
|
+
recurseSlots
|
544
|
+
});
|
545
|
+
}) : content;
|
546
|
+
if (containsPromise(mappedContent)) {
|
547
|
+
return Promise.all(mappedContent);
|
548
|
+
}
|
549
|
+
return map(mappedContent, id, propPath, fields[propKey], propPath);
|
550
|
+
}
|
551
|
+
if (value && typeof value === "object") {
|
552
|
+
if (Array.isArray(value)) {
|
553
|
+
const arrayFields = ((_b = fields[propKey]) == null ? void 0 : _b.type) === "array" ? fields[propKey].arrayFields : null;
|
554
|
+
if (!arrayFields) return value;
|
555
|
+
const newValue = value.map(
|
556
|
+
(el, idx) => walkField({
|
557
|
+
value: el,
|
558
|
+
fields: arrayFields,
|
559
|
+
map,
|
560
|
+
propKey,
|
561
|
+
propPath: `${propPath}[${idx}]`,
|
562
|
+
id,
|
563
|
+
config,
|
564
|
+
recurseSlots
|
565
|
+
})
|
566
|
+
);
|
567
|
+
if (containsPromise(newValue)) {
|
568
|
+
return Promise.all(newValue);
|
569
|
+
}
|
570
|
+
return newValue;
|
571
|
+
} else if ("$$typeof" in value) {
|
572
|
+
return value;
|
573
|
+
} else {
|
574
|
+
const objectFields = ((_c = fields[propKey]) == null ? void 0 : _c.type) === "object" ? fields[propKey].objectFields : fields;
|
575
|
+
return walkObject({
|
576
|
+
value,
|
577
|
+
fields: objectFields,
|
578
|
+
map,
|
579
|
+
id,
|
580
|
+
getPropPath: (k) => `${propPath}.${k}`,
|
581
|
+
config,
|
582
|
+
recurseSlots
|
583
|
+
});
|
584
|
+
}
|
585
|
+
}
|
586
|
+
return value;
|
680
587
|
};
|
588
|
+
var walkObject = ({
|
589
|
+
value,
|
590
|
+
fields,
|
591
|
+
map,
|
592
|
+
id,
|
593
|
+
getPropPath,
|
594
|
+
config,
|
595
|
+
recurseSlots
|
596
|
+
}) => {
|
597
|
+
const newProps = Object.entries(value).map(([k, v]) => {
|
598
|
+
const opts = {
|
599
|
+
value: v,
|
600
|
+
fields,
|
601
|
+
map,
|
602
|
+
propKey: k,
|
603
|
+
propPath: getPropPath(k),
|
604
|
+
id,
|
605
|
+
config,
|
606
|
+
recurseSlots
|
607
|
+
};
|
608
|
+
const newValue = walkField(opts);
|
609
|
+
if (isPromise(newValue)) {
|
610
|
+
return newValue.then((resolvedValue) => ({
|
611
|
+
[k]: resolvedValue
|
612
|
+
}));
|
613
|
+
}
|
614
|
+
return {
|
615
|
+
[k]: newValue
|
616
|
+
};
|
617
|
+
}, {});
|
618
|
+
if (containsPromise(newProps)) {
|
619
|
+
return Promise.all(newProps).then(flatten);
|
620
|
+
}
|
621
|
+
return flatten(newProps);
|
622
|
+
};
|
623
|
+
function mapSlots(item, map, config, recurseSlots = false) {
|
624
|
+
var _a, _b, _c, _d;
|
625
|
+
const itemType = "type" in item ? item.type : "root";
|
626
|
+
const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
|
627
|
+
const newProps = walkObject({
|
628
|
+
value: (_b = item.props) != null ? _b : {},
|
629
|
+
fields: (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {},
|
630
|
+
map,
|
631
|
+
id: item.props ? (_d = item.props.id) != null ? _d : "root" : "root",
|
632
|
+
getPropPath: (k) => k,
|
633
|
+
config,
|
634
|
+
recurseSlots
|
635
|
+
});
|
636
|
+
if (isPromise(newProps)) {
|
637
|
+
return newProps.then((resolvedProps) => __spreadProps(__spreadValues({}, item), {
|
638
|
+
props: resolvedProps
|
639
|
+
}));
|
640
|
+
}
|
641
|
+
return __spreadProps(__spreadValues({}, item), {
|
642
|
+
props: newProps
|
643
|
+
});
|
644
|
+
}
|
681
645
|
|
682
|
-
// ../core/lib/
|
646
|
+
// ../core/lib/data/flatten-node.ts
|
683
647
|
init_react_import();
|
684
|
-
var
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
648
|
+
var import_flat = __toESM(require_flat());
|
649
|
+
|
650
|
+
// ../core/lib/data/strip-slots.ts
|
651
|
+
init_react_import();
|
652
|
+
var stripSlots = (data, config) => {
|
653
|
+
return mapSlots(data, () => null, config);
|
654
|
+
};
|
655
|
+
|
656
|
+
// ../core/lib/data/flatten-node.ts
|
657
|
+
var flattenNode = (node, config) => {
|
658
|
+
return __spreadProps(__spreadValues({}, node), {
|
659
|
+
props: (0, import_flat.flatten)(stripSlots(node, config).props)
|
690
660
|
});
|
691
|
-
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
692
|
-
return newData;
|
693
661
|
};
|
694
662
|
|
695
|
-
// ../core/lib/
|
696
|
-
|
697
|
-
var
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
663
|
+
// ../core/lib/data/walk-app-state.ts
|
664
|
+
function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
665
|
+
var _a;
|
666
|
+
let newZones = {};
|
667
|
+
const newZoneIndex = {};
|
668
|
+
const newNodeIndex = {};
|
669
|
+
const processContent = (path, zoneCompound, content, zoneType, newId) => {
|
670
|
+
var _a2;
|
671
|
+
const [parentId] = zoneCompound.split(":");
|
672
|
+
const mappedContent = ((_a2 = mapContent(content, zoneCompound, zoneType)) != null ? _a2 : content) || [];
|
673
|
+
const [_2, zone] = zoneCompound.split(":");
|
674
|
+
const newZoneCompound = `${newId || parentId}:${zone}`;
|
675
|
+
const newContent2 = mappedContent.map(
|
676
|
+
(zoneChild, index) => processItem(zoneChild, [...path, newZoneCompound], index)
|
677
|
+
);
|
678
|
+
newZoneIndex[newZoneCompound] = {
|
679
|
+
contentIds: newContent2.map((item) => item.props.id),
|
680
|
+
type: zoneType
|
681
|
+
};
|
682
|
+
return [newZoneCompound, newContent2];
|
683
|
+
};
|
684
|
+
const processRelatedZones = (item, newId, initialPath) => {
|
685
|
+
forRelatedZones(
|
686
|
+
item,
|
687
|
+
state.data,
|
688
|
+
(relatedPath, relatedZoneCompound, relatedContent) => {
|
689
|
+
const [zoneCompound, newContent2] = processContent(
|
690
|
+
relatedPath,
|
691
|
+
relatedZoneCompound,
|
692
|
+
relatedContent,
|
693
|
+
"dropzone",
|
694
|
+
newId
|
695
|
+
);
|
696
|
+
newZones[zoneCompound] = newContent2;
|
697
|
+
},
|
698
|
+
initialPath
|
699
|
+
);
|
700
|
+
};
|
701
|
+
const processItem = (item, path, index) => {
|
702
|
+
const mappedItem = mapNodeOrSkip(item, path, index);
|
703
|
+
if (!mappedItem) return item;
|
704
|
+
const id = mappedItem.props.id;
|
705
|
+
const newProps = __spreadProps(__spreadValues({}, mapSlots(
|
706
|
+
mappedItem,
|
707
|
+
(content, parentId2, slotId) => {
|
708
|
+
const zoneCompound = `${parentId2}:${slotId}`;
|
709
|
+
const [_2, newContent2] = processContent(
|
710
|
+
path,
|
711
|
+
zoneCompound,
|
712
|
+
content,
|
713
|
+
"slot",
|
714
|
+
parentId2
|
715
|
+
);
|
716
|
+
return newContent2;
|
717
|
+
},
|
718
|
+
config
|
719
|
+
).props), {
|
720
|
+
id
|
721
|
+
});
|
722
|
+
processRelatedZones(item, id, path);
|
723
|
+
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
|
724
|
+
const thisZoneCompound = path[path.length - 1];
|
725
|
+
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
726
|
+
newNodeIndex[id] = {
|
727
|
+
data: newItem,
|
728
|
+
flatData: flattenNode(newItem, config),
|
729
|
+
path,
|
730
|
+
parentId,
|
731
|
+
zone
|
732
|
+
};
|
733
|
+
const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
|
734
|
+
if (newProps.id === "root") {
|
735
|
+
delete finalData["type"];
|
736
|
+
delete finalData.props["id"];
|
737
|
+
}
|
738
|
+
return finalData;
|
739
|
+
};
|
740
|
+
const zones = state.data.zones || {};
|
741
|
+
const [_, newContent] = processContent(
|
742
|
+
[],
|
743
|
+
rootDroppableId,
|
744
|
+
state.data.content,
|
745
|
+
"root"
|
746
|
+
);
|
747
|
+
const processedContent = newContent;
|
748
|
+
const zonesAlreadyProcessed = Object.keys(newZones);
|
749
|
+
Object.keys(zones || {}).forEach((zoneCompound) => {
|
750
|
+
const [parentId] = zoneCompound.split(":");
|
751
|
+
if (zonesAlreadyProcessed.includes(zoneCompound)) {
|
752
|
+
return;
|
753
|
+
}
|
754
|
+
const [_2, newContent2] = processContent(
|
755
|
+
[rootDroppableId],
|
756
|
+
zoneCompound,
|
757
|
+
zones[zoneCompound],
|
758
|
+
"dropzone",
|
759
|
+
parentId
|
760
|
+
);
|
761
|
+
newZones[zoneCompound] = newContent2;
|
762
|
+
}, newZones);
|
763
|
+
const processedRoot = processItem(
|
764
|
+
{
|
765
|
+
type: "root",
|
766
|
+
props: __spreadProps(__spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root), { id: "root" })
|
767
|
+
},
|
768
|
+
[],
|
769
|
+
-1
|
770
|
+
);
|
771
|
+
const root = __spreadProps(__spreadValues({}, state.data.root), {
|
772
|
+
props: processedRoot.props
|
773
|
+
});
|
774
|
+
return __spreadProps(__spreadValues({}, state), {
|
775
|
+
data: {
|
776
|
+
root,
|
777
|
+
content: processedContent,
|
778
|
+
zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
|
779
|
+
},
|
780
|
+
indexes: {
|
781
|
+
nodes: __spreadValues(__spreadValues({}, state.indexes.nodes), newNodeIndex),
|
782
|
+
zones: __spreadValues(__spreadValues({}, state.indexes.zones), newZoneIndex)
|
783
|
+
}
|
784
|
+
});
|
785
|
+
}
|
786
|
+
|
787
|
+
// ../core/reducer/actions/set.ts
|
788
|
+
var setAction = (state, action, appStore) => {
|
789
|
+
if (typeof action.state === "object") {
|
790
|
+
const newState = __spreadValues(__spreadValues({}, state), action.state);
|
791
|
+
if (action.state.indexes) {
|
792
|
+
return newState;
|
793
|
+
}
|
794
|
+
console.warn(
|
795
|
+
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
796
|
+
);
|
797
|
+
return walkAppState(newState, appStore.config);
|
798
|
+
}
|
799
|
+
return __spreadValues(__spreadValues({}, state), action.state(state));
|
702
800
|
};
|
703
801
|
|
704
|
-
// ../core/
|
802
|
+
// ../core/reducer/actions/insert.ts
|
705
803
|
init_react_import();
|
706
|
-
function getItem(selector, data, dynamicProps = {}) {
|
707
|
-
if (!selector.zone || selector.zone === rootDroppableId) {
|
708
|
-
const item2 = data.content[selector.index];
|
709
|
-
return (item2 == null ? void 0 : item2.props) ? __spreadProps(__spreadValues({}, item2), { props: dynamicProps[item2.props.id] || item2.props }) : void 0;
|
710
|
-
}
|
711
|
-
const item = setupZone(data, selector.zone).zones[selector.zone][selector.index];
|
712
|
-
return (item == null ? void 0 : item.props) ? __spreadProps(__spreadValues({}, item), { props: dynamicProps[item.props.id] || item.props }) : void 0;
|
713
|
-
}
|
714
804
|
|
715
|
-
// ../core/lib/
|
805
|
+
// ../core/lib/data/insert.ts
|
716
806
|
init_react_import();
|
807
|
+
var insert = (list, index, item) => {
|
808
|
+
const result = Array.from(list || []);
|
809
|
+
result.splice(index, 0, item);
|
810
|
+
return result;
|
811
|
+
};
|
717
812
|
|
718
813
|
// ../core/lib/generate-id.ts
|
719
814
|
init_react_import();
|
@@ -777,313 +872,438 @@ var v4_default = v4;
|
|
777
872
|
// ../core/lib/generate-id.ts
|
778
873
|
var generateId = (type) => type ? `${type}-${v4_default()}` : v4_default();
|
779
874
|
|
780
|
-
// ../core/lib/get-
|
875
|
+
// ../core/lib/data/get-ids-for-parent.ts
|
781
876
|
init_react_import();
|
782
|
-
var
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
787
|
-
return zoneCompound.split(":");
|
788
|
-
}
|
789
|
-
return [rootDroppableId, zoneCompound];
|
877
|
+
var getIdsForParent = (zoneCompound, state) => {
|
878
|
+
const [parentId] = zoneCompound.split(":");
|
879
|
+
const node = state.indexes.nodes[parentId];
|
880
|
+
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
|
790
881
|
};
|
791
882
|
|
792
|
-
// ../core/lib/
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
883
|
+
// ../core/lib/data/populate-ids.ts
|
884
|
+
init_react_import();
|
885
|
+
|
886
|
+
// ../core/lib/data/walk-tree.ts
|
887
|
+
init_react_import();
|
888
|
+
function walkTree(data, config, callbackFn) {
|
889
|
+
var _a, _b;
|
890
|
+
const walkItem = (item) => {
|
891
|
+
return mapSlots(
|
892
|
+
item,
|
893
|
+
(content, parentId, propName) => {
|
894
|
+
var _a2;
|
895
|
+
return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
|
803
896
|
},
|
897
|
+
config,
|
898
|
+
true
|
899
|
+
);
|
900
|
+
};
|
901
|
+
if ("props" in data) {
|
902
|
+
return walkItem(data);
|
903
|
+
}
|
904
|
+
const _data = data;
|
905
|
+
const zones = (_a = _data.zones) != null ? _a : {};
|
906
|
+
const mappedContent = _data.content.map(walkItem);
|
907
|
+
return {
|
908
|
+
root: walkItem(_data.root),
|
909
|
+
content: (_b = callbackFn(mappedContent, {
|
910
|
+
parentId: "root",
|
911
|
+
propName: "default-zone"
|
912
|
+
})) != null ? _b : mappedContent,
|
913
|
+
zones: Object.keys(zones).reduce(
|
914
|
+
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
|
915
|
+
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
916
|
+
}),
|
804
917
|
{}
|
805
918
|
)
|
806
|
-
}
|
919
|
+
};
|
807
920
|
}
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
921
|
+
|
922
|
+
// ../core/lib/data/populate-ids.ts
|
923
|
+
var populateIds = (data, config, override = false) => {
|
924
|
+
const id = generateId(data.type);
|
925
|
+
return walkTree(
|
926
|
+
__spreadProps(__spreadValues({}, data), {
|
927
|
+
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({}, data.props)
|
928
|
+
}),
|
929
|
+
config,
|
930
|
+
(contents) => contents.map((item) => {
|
931
|
+
const id2 = generateId(item.type);
|
932
|
+
return __spreadProps(__spreadValues({}, item), {
|
933
|
+
props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
|
934
|
+
});
|
935
|
+
})
|
936
|
+
);
|
937
|
+
};
|
938
|
+
|
939
|
+
// ../core/reducer/actions/insert.ts
|
940
|
+
function insertAction(state, action, appStore) {
|
941
|
+
const id = action.id || generateId(action.componentType);
|
942
|
+
const emptyComponentData = populateIds(
|
943
|
+
{
|
944
|
+
type: action.componentType,
|
945
|
+
props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
|
946
|
+
id
|
947
|
+
})
|
948
|
+
},
|
949
|
+
appStore.config
|
950
|
+
);
|
951
|
+
const [parentId] = action.destinationZone.split(":");
|
952
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
953
|
+
return walkAppState(
|
954
|
+
state,
|
955
|
+
appStore.config,
|
956
|
+
(content, zoneCompound) => {
|
957
|
+
if (zoneCompound === action.destinationZone) {
|
958
|
+
return insert(
|
959
|
+
content || [],
|
960
|
+
action.destinationIndex,
|
961
|
+
emptyComponentData
|
962
|
+
);
|
815
963
|
}
|
816
|
-
return
|
964
|
+
return content;
|
817
965
|
},
|
818
|
-
{
|
966
|
+
(childItem, path) => {
|
967
|
+
if (childItem.props.id === id || childItem.props.id === parentId) {
|
968
|
+
return childItem;
|
969
|
+
} else if (idsInPath.includes(childItem.props.id)) {
|
970
|
+
return childItem;
|
971
|
+
} else if (path.includes(action.destinationZone)) {
|
972
|
+
return childItem;
|
973
|
+
}
|
974
|
+
return null;
|
975
|
+
}
|
819
976
|
);
|
820
|
-
}
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
977
|
+
}
|
978
|
+
|
979
|
+
// ../core/reducer/actions/replace.ts
|
980
|
+
init_react_import();
|
981
|
+
var replaceAction = (state, action, appStore) => {
|
982
|
+
const [parentId] = action.destinationZone.split(":");
|
983
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
984
|
+
const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
|
985
|
+
const idChanged = originalId !== action.data.props.id;
|
986
|
+
if (idChanged) {
|
987
|
+
throw new Error(
|
988
|
+
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
989
|
+
);
|
990
|
+
}
|
991
|
+
const data = populateIds(action.data, appStore.config);
|
992
|
+
return walkAppState(
|
993
|
+
state,
|
994
|
+
appStore.config,
|
995
|
+
(content, zoneCompound) => {
|
996
|
+
const newContent = [...content];
|
997
|
+
if (zoneCompound === action.destinationZone) {
|
998
|
+
newContent[action.destinationIndex] = data;
|
830
999
|
}
|
831
|
-
return
|
1000
|
+
return newContent;
|
832
1001
|
},
|
833
|
-
{
|
1002
|
+
(childItem, path) => {
|
1003
|
+
const pathIds = path.map((p) => p.split(":")[0]);
|
1004
|
+
if (childItem.props.id === data.props.id) {
|
1005
|
+
return data;
|
1006
|
+
} else if (childItem.props.id === parentId) {
|
1007
|
+
return childItem;
|
1008
|
+
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
1009
|
+
return childItem;
|
1010
|
+
} else if (pathIds.indexOf(data.props.id) > -1) {
|
1011
|
+
return childItem;
|
1012
|
+
}
|
1013
|
+
return null;
|
1014
|
+
}
|
834
1015
|
);
|
835
1016
|
};
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
1017
|
+
|
1018
|
+
// ../core/reducer/actions/replace-root.ts
|
1019
|
+
init_react_import();
|
1020
|
+
var replaceRootAction = (state, action, appStore) => {
|
1021
|
+
return walkAppState(
|
1022
|
+
state,
|
1023
|
+
appStore.config,
|
1024
|
+
(content) => content,
|
1025
|
+
(childItem) => {
|
1026
|
+
if (childItem.props.id === "root") {
|
1027
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
1028
|
+
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
1029
|
+
readOnly: action.root.readOnly
|
1030
|
+
});
|
1031
|
+
}
|
1032
|
+
return childItem;
|
1033
|
+
}
|
1034
|
+
);
|
843
1035
|
};
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
return __spreadProps(__spreadValues({}, dupeOfDupes), {
|
855
|
-
[key]: zone,
|
856
|
-
[`${newId}:${zoneId}`]: dupedZone
|
857
|
-
});
|
858
|
-
});
|
1036
|
+
|
1037
|
+
// ../core/reducer/actions/duplicate.ts
|
1038
|
+
init_react_import();
|
1039
|
+
|
1040
|
+
// ../core/lib/data/get-item.ts
|
1041
|
+
init_react_import();
|
1042
|
+
function getItem(selector, state) {
|
1043
|
+
var _a, _b;
|
1044
|
+
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
1045
|
+
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
859
1046
|
}
|
860
1047
|
|
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
|
-
)
|
1048
|
+
// ../core/reducer/actions/duplicate.ts
|
1049
|
+
function duplicateAction(state, action, appStore) {
|
1050
|
+
const item = getItem(
|
1051
|
+
{ index: action.sourceIndex, zone: action.sourceZone },
|
1052
|
+
state
|
1053
|
+
);
|
1054
|
+
const idsInPath = getIdsForParent(action.sourceZone, state);
|
1055
|
+
const newItem = __spreadProps(__spreadValues({}, item), {
|
1056
|
+
props: __spreadProps(__spreadValues({}, item.props), {
|
1057
|
+
id: generateId(item.type)
|
877
1058
|
})
|
878
1059
|
});
|
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
|
-
|
1060
|
+
const modified = walkAppState(
|
1061
|
+
state,
|
1062
|
+
appStore.config,
|
1063
|
+
(content, zoneCompound) => {
|
1064
|
+
if (zoneCompound === action.sourceZone) {
|
1065
|
+
return insert(content, action.sourceIndex + 1, item);
|
1066
|
+
}
|
1067
|
+
return content;
|
1068
|
+
},
|
1069
|
+
(childItem, path, index) => {
|
1070
|
+
const zoneCompound = path[path.length - 1];
|
1071
|
+
const parents = path.map((p) => p.split(":")[0]);
|
1072
|
+
if (parents.indexOf(newItem.props.id) > -1) {
|
1073
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
1074
|
+
props: __spreadProps(__spreadValues({}, childItem.props), {
|
1075
|
+
id: generateId(childItem.type)
|
1076
|
+
})
|
1077
|
+
});
|
1078
|
+
}
|
1079
|
+
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
1080
|
+
return newItem;
|
1081
|
+
}
|
1082
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
1083
|
+
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
1084
|
+
return childItem;
|
1085
|
+
}
|
1086
|
+
return null;
|
1087
|
+
}
|
1088
|
+
);
|
1089
|
+
return __spreadProps(__spreadValues({}, modified), {
|
1090
|
+
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
1091
|
+
itemSelector: {
|
1092
|
+
index: action.sourceIndex + 1,
|
1093
|
+
zone: action.sourceZone
|
1094
|
+
}
|
904
1095
|
})
|
905
1096
|
});
|
906
1097
|
}
|
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
|
-
});
|
1098
|
+
|
1099
|
+
// ../core/reducer/actions/reorder.ts
|
1100
|
+
init_react_import();
|
1101
|
+
|
1102
|
+
// ../core/reducer/actions/move.ts
|
1103
|
+
init_react_import();
|
1104
|
+
|
1105
|
+
// ../core/lib/data/remove.ts
|
1106
|
+
init_react_import();
|
1107
|
+
var remove = (list, index) => {
|
1108
|
+
const result = Array.from(list);
|
1109
|
+
result.splice(index, 1);
|
1110
|
+
return result;
|
927
1111
|
};
|
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);
|
1112
|
+
|
1113
|
+
// ../core/reducer/actions/move.ts
|
1114
|
+
var moveAction = (state, action, appStore) => {
|
1115
|
+
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
1116
|
+
return state;
|
964
1117
|
}
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
1118
|
+
const item = getItem(
|
1119
|
+
{ zone: action.sourceZone, index: action.sourceIndex },
|
1120
|
+
state
|
1121
|
+
);
|
1122
|
+
if (!item) return state;
|
1123
|
+
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
1124
|
+
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
1125
|
+
return walkAppState(
|
1126
|
+
state,
|
1127
|
+
appStore.config,
|
1128
|
+
(content, zoneCompound) => {
|
1129
|
+
if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
|
1130
|
+
return insert(
|
1131
|
+
remove(content, action.sourceIndex),
|
1132
|
+
action.destinationIndex,
|
1133
|
+
item
|
1134
|
+
);
|
1135
|
+
} else if (zoneCompound === action.sourceZone) {
|
1136
|
+
return remove(content, action.sourceIndex);
|
1137
|
+
} else if (zoneCompound === action.destinationZone) {
|
1138
|
+
return insert(content, action.destinationIndex, item);
|
1139
|
+
}
|
1140
|
+
return content;
|
1141
|
+
},
|
1142
|
+
(childItem, path) => {
|
1143
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
1144
|
+
const [destinationZoneParent] = action.destinationZone.split(":");
|
1145
|
+
const childId = childItem.props.id;
|
1146
|
+
if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1 || path.includes(action.destinationZone)) {
|
1147
|
+
return childItem;
|
1148
|
+
}
|
1149
|
+
return null;
|
979
1150
|
}
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
1151
|
+
);
|
1152
|
+
};
|
1153
|
+
|
1154
|
+
// ../core/reducer/actions/reorder.ts
|
1155
|
+
var reorderAction = (state, action, appStore) => {
|
1156
|
+
return moveAction(
|
1157
|
+
state,
|
1158
|
+
{
|
1159
|
+
type: "move",
|
1160
|
+
sourceIndex: action.sourceIndex,
|
1161
|
+
sourceZone: action.destinationZone,
|
1162
|
+
destinationIndex: action.destinationIndex,
|
1163
|
+
destinationZone: action.destinationZone
|
1164
|
+
},
|
1165
|
+
appStore
|
1166
|
+
);
|
1167
|
+
};
|
1168
|
+
|
1169
|
+
// ../core/reducer/actions/remove.ts
|
1170
|
+
init_react_import();
|
1171
|
+
var removeAction = (state, action, appStore) => {
|
1172
|
+
const item = getItem({ index: action.index, zone: action.zone }, state);
|
1173
|
+
const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
|
1174
|
+
(acc, [nodeId, nodeData]) => {
|
1175
|
+
const pathIds = nodeData.path.map((p) => p.split(":")[0]);
|
1176
|
+
if (pathIds.includes(item.props.id)) {
|
1177
|
+
return [...acc, nodeId];
|
1178
|
+
}
|
1179
|
+
return acc;
|
1180
|
+
},
|
1181
|
+
[item.props.id]
|
1182
|
+
);
|
1183
|
+
const newState = walkAppState(
|
1184
|
+
state,
|
1185
|
+
appStore.config,
|
1186
|
+
(content, zoneCompound) => {
|
1187
|
+
if (zoneCompound === action.zone) {
|
1188
|
+
return remove(content, action.index);
|
1189
|
+
}
|
1190
|
+
return content;
|
991
1191
|
}
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
newData.zones[action.sourceZone],
|
998
|
-
action.sourceIndex
|
999
|
-
)
|
1000
|
-
})
|
1001
|
-
});
|
1192
|
+
);
|
1193
|
+
Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
|
1194
|
+
const parentId = zoneCompound.split(":")[0];
|
1195
|
+
if (nodesToDelete.includes(parentId) && newState.data.zones) {
|
1196
|
+
delete newState.data.zones[zoneCompound];
|
1002
1197
|
}
|
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
|
-
});
|
1198
|
+
});
|
1199
|
+
Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
|
1200
|
+
const parentId = zoneCompound.split(":")[0];
|
1201
|
+
if (nodesToDelete.includes(parentId)) {
|
1202
|
+
delete newState.indexes.zones[zoneCompound];
|
1030
1203
|
}
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1204
|
+
});
|
1205
|
+
nodesToDelete.forEach((id) => {
|
1206
|
+
delete newState.indexes.nodes[id];
|
1207
|
+
});
|
1208
|
+
return newState;
|
1209
|
+
};
|
1210
|
+
|
1211
|
+
// ../core/reducer/actions/register-zone.ts
|
1212
|
+
init_react_import();
|
1213
|
+
|
1214
|
+
// ../core/lib/data/setup-zone.ts
|
1215
|
+
init_react_import();
|
1216
|
+
var setupZone = (data, zoneKey) => {
|
1217
|
+
if (zoneKey === rootDroppableId) {
|
1218
|
+
return data;
|
1039
1219
|
}
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1220
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
1221
|
+
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
1222
|
+
});
|
1223
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
1224
|
+
return newData;
|
1225
|
+
};
|
1226
|
+
|
1227
|
+
// ../core/reducer/actions/register-zone.ts
|
1228
|
+
var zoneCache = {};
|
1229
|
+
function registerZoneAction(state, action) {
|
1230
|
+
if (zoneCache[action.zone]) {
|
1231
|
+
return __spreadProps(__spreadValues({}, state), {
|
1232
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
1233
|
+
zones: __spreadProps(__spreadValues({}, state.data.zones), {
|
1044
1234
|
[action.zone]: zoneCache[action.zone]
|
1045
1235
|
})
|
1046
|
-
})
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
}
|
1056
|
-
return __spreadProps(__spreadValues({}, data), { zones: _zones });
|
1236
|
+
}),
|
1237
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1238
|
+
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
|
1239
|
+
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
|
1240
|
+
contentIds: zoneCache[action.zone].map((item) => item.props.id),
|
1241
|
+
type: "dropzone"
|
1242
|
+
})
|
1243
|
+
})
|
1244
|
+
})
|
1245
|
+
});
|
1057
1246
|
}
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1247
|
+
return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
|
1248
|
+
}
|
1249
|
+
function unregisterZoneAction(state, action) {
|
1250
|
+
const _zones = __spreadValues({}, state.data.zones || {});
|
1251
|
+
const zoneIndex = __spreadValues({}, state.indexes.zones || {});
|
1252
|
+
if (_zones[action.zone]) {
|
1253
|
+
zoneCache[action.zone] = _zones[action.zone];
|
1254
|
+
delete _zones[action.zone];
|
1063
1255
|
}
|
1064
|
-
|
1256
|
+
delete zoneIndex[action.zone];
|
1257
|
+
return __spreadProps(__spreadValues({}, state), {
|
1258
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
1259
|
+
zones: _zones
|
1260
|
+
}),
|
1261
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1262
|
+
zones: zoneIndex
|
1263
|
+
})
|
1264
|
+
});
|
1065
1265
|
}
|
1066
1266
|
|
1067
|
-
// ../core/reducer/
|
1267
|
+
// ../core/reducer/actions/set-data.ts
|
1068
1268
|
init_react_import();
|
1069
|
-
var
|
1070
|
-
if (action.
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
return
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1269
|
+
var setDataAction = (state, action, appStore) => {
|
1270
|
+
if (typeof action.data === "object") {
|
1271
|
+
console.warn(
|
1272
|
+
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1273
|
+
);
|
1274
|
+
return walkAppState(
|
1275
|
+
__spreadProps(__spreadValues({}, state), {
|
1276
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
1277
|
+
}),
|
1278
|
+
appStore.config
|
1279
|
+
);
|
1080
1280
|
}
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1281
|
+
return walkAppState(
|
1282
|
+
__spreadProps(__spreadValues({}, state), {
|
1283
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
1284
|
+
}),
|
1285
|
+
appStore.config
|
1286
|
+
);
|
1287
|
+
};
|
1288
|
+
|
1289
|
+
// ../core/reducer/actions/set-ui.ts
|
1290
|
+
init_react_import();
|
1291
|
+
var setUiAction = (state, action) => {
|
1292
|
+
if (typeof action.ui === "object") {
|
1293
|
+
return __spreadProps(__spreadValues({}, state), {
|
1294
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
|
1084
1295
|
});
|
1085
1296
|
}
|
1086
|
-
return
|
1297
|
+
return __spreadProps(__spreadValues({}, state), {
|
1298
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
|
1299
|
+
});
|
1300
|
+
};
|
1301
|
+
|
1302
|
+
// ../core/lib/data/make-state-public.ts
|
1303
|
+
init_react_import();
|
1304
|
+
var makeStatePublic = (state) => {
|
1305
|
+
const { data, ui } = state;
|
1306
|
+
return { data, ui };
|
1087
1307
|
};
|
1088
1308
|
|
1089
1309
|
// ../core/reducer/actions.tsx
|
@@ -1103,29 +1323,54 @@ function storeInterceptor(reducer, record, onAction) {
|
|
1103
1323
|
if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
|
1104
1324
|
if (record) record(newAppState);
|
1105
1325
|
}
|
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
|
-
};
|
1326
|
+
onAction == null ? void 0 : onAction(action, makeStatePublic(newAppState), makeStatePublic(state));
|
1327
|
+
return newAppState;
|
1328
|
+
};
|
1329
|
+
}
|
1116
1330
|
function createReducer({
|
1117
|
-
config,
|
1118
1331
|
record,
|
1119
|
-
onAction
|
1332
|
+
onAction,
|
1333
|
+
appStore
|
1120
1334
|
}) {
|
1121
1335
|
return storeInterceptor(
|
1122
1336
|
(state, action) => {
|
1123
|
-
const data = reduceData(state.data, action, config);
|
1124
|
-
const ui = reduceUi(state.ui, action);
|
1125
1337
|
if (action.type === "set") {
|
1126
|
-
return setAction(state, action);
|
1338
|
+
return setAction(state, action, appStore);
|
1339
|
+
}
|
1340
|
+
if (action.type === "insert") {
|
1341
|
+
return insertAction(state, action, appStore);
|
1342
|
+
}
|
1343
|
+
if (action.type === "replace") {
|
1344
|
+
return replaceAction(state, action, appStore);
|
1345
|
+
}
|
1346
|
+
if (action.type === "replaceRoot") {
|
1347
|
+
return replaceRootAction(state, action, appStore);
|
1348
|
+
}
|
1349
|
+
if (action.type === "duplicate") {
|
1350
|
+
return duplicateAction(state, action, appStore);
|
1127
1351
|
}
|
1128
|
-
|
1352
|
+
if (action.type === "reorder") {
|
1353
|
+
return reorderAction(state, action, appStore);
|
1354
|
+
}
|
1355
|
+
if (action.type === "move") {
|
1356
|
+
return moveAction(state, action, appStore);
|
1357
|
+
}
|
1358
|
+
if (action.type === "remove") {
|
1359
|
+
return removeAction(state, action, appStore);
|
1360
|
+
}
|
1361
|
+
if (action.type === "registerZone") {
|
1362
|
+
return registerZoneAction(state, action);
|
1363
|
+
}
|
1364
|
+
if (action.type === "unregisterZone") {
|
1365
|
+
return unregisterZoneAction(state, action);
|
1366
|
+
}
|
1367
|
+
if (action.type === "setData") {
|
1368
|
+
return setDataAction(state, action, appStore);
|
1369
|
+
}
|
1370
|
+
if (action.type === "setUi") {
|
1371
|
+
return setUiAction(state, action);
|
1372
|
+
}
|
1373
|
+
return state;
|
1129
1374
|
},
|
1130
1375
|
record,
|
1131
1376
|
onAction
|
@@ -1140,20 +1385,16 @@ var defaultViewports = [
|
|
1140
1385
|
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
1141
1386
|
];
|
1142
1387
|
|
1143
|
-
// ../../node_modules/zustand/esm/index.mjs
|
1144
|
-
init_react_import();
|
1145
|
-
|
1146
1388
|
// ../../node_modules/zustand/esm/vanilla.mjs
|
1147
1389
|
init_react_import();
|
1148
|
-
var import_meta = {};
|
1149
1390
|
var createStoreImpl = (createState) => {
|
1150
1391
|
let state;
|
1151
1392
|
const listeners = /* @__PURE__ */ new Set();
|
1152
|
-
const setState = (partial,
|
1393
|
+
const setState = (partial, replace) => {
|
1153
1394
|
const nextState = typeof partial === "function" ? partial(state) : partial;
|
1154
1395
|
if (!Object.is(nextState, state)) {
|
1155
1396
|
const previousState = state;
|
1156
|
-
state = (
|
1397
|
+
state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
|
1157
1398
|
listeners.forEach((listener) => listener(state, previousState));
|
1158
1399
|
}
|
1159
1400
|
};
|
@@ -1163,53 +1404,28 @@ var createStoreImpl = (createState) => {
|
|
1163
1404
|
listeners.add(listener);
|
1164
1405
|
return () => listeners.delete(listener);
|
1165
1406
|
};
|
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 };
|
1407
|
+
const api = { setState, getState, getInitialState, subscribe };
|
1175
1408
|
const initialState = state = createState(setState, getState, api);
|
1176
1409
|
return api;
|
1177
1410
|
};
|
1178
1411
|
var createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
|
1179
1412
|
|
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;
|
1413
|
+
// ../../node_modules/zustand/esm/react.mjs
|
1414
|
+
init_react_import();
|
1415
|
+
import React2 from "react";
|
1187
1416
|
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(
|
1417
|
+
function useStore(api, selector = identity) {
|
1418
|
+
const slice = React2.useSyncExternalStore(
|
1196
1419
|
api.subscribe,
|
1197
|
-
api.getState,
|
1198
|
-
|
1199
|
-
selector,
|
1200
|
-
equalityFn
|
1420
|
+
() => selector(api.getState()),
|
1421
|
+
() => selector(api.getInitialState())
|
1201
1422
|
);
|
1202
|
-
useDebugValue(slice);
|
1423
|
+
React2.useDebugValue(slice);
|
1203
1424
|
return slice;
|
1204
1425
|
}
|
1205
1426
|
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);
|
1427
|
+
const api = createStore(createState);
|
1428
|
+
const useBoundStore = (selector) => useStore(api, selector);
|
1213
1429
|
Object.assign(useBoundStore, api);
|
1214
1430
|
return useBoundStore;
|
1215
1431
|
};
|
@@ -1242,206 +1458,6 @@ var subscribeWithSelectorImpl = (fn) => (set, get, api) => {
|
|
1242
1458
|
};
|
1243
1459
|
var subscribeWithSelector = subscribeWithSelectorImpl;
|
1244
1460
|
|
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
1461
|
// ../core/store/index.ts
|
1446
1462
|
import { createContext, useContext } from "react";
|
1447
1463
|
|
@@ -1549,7 +1565,7 @@ var createHistorySlice = (set, get) => {
|
|
1549
1565
|
const { dispatch, history } = get();
|
1550
1566
|
dispatch({
|
1551
1567
|
type: "set",
|
1552
|
-
state: ((_a = history.histories[
|
1568
|
+
state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
|
1553
1569
|
});
|
1554
1570
|
set({ history: __spreadProps(__spreadValues({}, history), { index }) });
|
1555
1571
|
},
|
@@ -1559,31 +1575,18 @@ var createHistorySlice = (set, get) => {
|
|
1559
1575
|
|
1560
1576
|
// ../core/store/slices/nodes.ts
|
1561
1577
|
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
1578
|
var createNodesSlice = (set, get) => ({
|
1572
1579
|
nodes: {},
|
1573
1580
|
registerNode: (id, node) => {
|
1574
1581
|
const s = get().nodes;
|
1575
|
-
if (s.nodes[id] && partialDeepEqual(node, s.nodes[id])) {
|
1576
|
-
return;
|
1577
|
-
}
|
1578
1582
|
const emptyNode = {
|
1579
1583
|
id,
|
1580
|
-
methods: {
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
element: null
|
1586
|
-
index: -1
|
1584
|
+
methods: {
|
1585
|
+
sync: () => null,
|
1586
|
+
hideOverlay: () => null,
|
1587
|
+
showOverlay: () => null
|
1588
|
+
},
|
1589
|
+
element: null
|
1587
1590
|
};
|
1588
1591
|
const existingNode = s.nodes[id];
|
1589
1592
|
set({
|
@@ -1613,36 +1616,61 @@ var createNodesSlice = (set, get) => ({
|
|
1613
1616
|
|
1614
1617
|
// ../core/store/slices/permissions.ts
|
1615
1618
|
init_react_import();
|
1616
|
-
import { useEffect as
|
1619
|
+
import { useEffect as useEffect3 } from "react";
|
1620
|
+
|
1621
|
+
// ../core/lib/data/flatten-data.ts
|
1622
|
+
init_react_import();
|
1623
|
+
var flattenData = (state, config) => {
|
1624
|
+
const data = [];
|
1625
|
+
walkAppState(
|
1626
|
+
state,
|
1627
|
+
config,
|
1628
|
+
(content) => content,
|
1629
|
+
(item) => {
|
1630
|
+
data.push(item);
|
1631
|
+
return null;
|
1632
|
+
}
|
1633
|
+
);
|
1634
|
+
return data;
|
1635
|
+
};
|
1636
|
+
|
1637
|
+
// ../core/lib/get-changed.ts
|
1638
|
+
init_react_import();
|
1639
|
+
var getChanged = (newItem, oldItem) => {
|
1640
|
+
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
1641
|
+
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
1642
|
+
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
1643
|
+
return __spreadProps(__spreadValues({}, acc), {
|
1644
|
+
[item]: oldItemProps[item] !== newItemProps[item]
|
1645
|
+
});
|
1646
|
+
}, {}) : {};
|
1647
|
+
};
|
1648
|
+
|
1649
|
+
// ../core/store/slices/permissions.ts
|
1617
1650
|
var createPermissionsSlice = (set, get) => {
|
1618
1651
|
const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
|
1619
|
-
const { state, permissions } = get();
|
1620
|
-
const { cache:
|
1652
|
+
const { state, permissions, config } = get();
|
1653
|
+
const { cache: cache2, globalPermissions } = permissions;
|
1621
1654
|
const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
|
1622
1655
|
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];
|
1656
|
+
const { config: config2, state: appState, setComponentLoading } = get();
|
1657
|
+
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
1630
1658
|
if (!componentConfig) {
|
1631
1659
|
return;
|
1632
1660
|
}
|
1633
1661
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
1634
1662
|
if (componentConfig.resolvePermissions) {
|
1635
|
-
const changed = getChanged(item2, (_a =
|
1663
|
+
const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
|
1636
1664
|
if (Object.values(changed).some((el) => el === true) || force2) {
|
1637
|
-
setComponentLoading(item2.props.id);
|
1665
|
+
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
1638
1666
|
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
1639
1667
|
item2,
|
1640
1668
|
{
|
1641
1669
|
changed,
|
1642
|
-
lastPermissions: ((_b =
|
1670
|
+
lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
|
1643
1671
|
permissions: initialPermissions,
|
1644
|
-
appState,
|
1645
|
-
lastData: ((_c =
|
1672
|
+
appState: makeStatePublic(appState),
|
1673
|
+
lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
|
1646
1674
|
}
|
1647
1675
|
);
|
1648
1676
|
const latest = get().permissions;
|
@@ -1659,7 +1687,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1659
1687
|
})
|
1660
1688
|
})
|
1661
1689
|
});
|
1662
|
-
|
1690
|
+
clearTimeout2();
|
1663
1691
|
}
|
1664
1692
|
}
|
1665
1693
|
});
|
@@ -1669,7 +1697,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1669
1697
|
// Shim the root data in by conforming to component data shape
|
1670
1698
|
{
|
1671
1699
|
type: "root",
|
1672
|
-
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "
|
1700
|
+
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "root" })
|
1673
1701
|
},
|
1674
1702
|
force2
|
1675
1703
|
);
|
@@ -1678,14 +1706,13 @@ var createPermissionsSlice = (set, get) => {
|
|
1678
1706
|
if (item) {
|
1679
1707
|
yield resolveDataForItem(item, force);
|
1680
1708
|
} else if (type) {
|
1681
|
-
flattenData(state
|
1709
|
+
flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(void 0, null, function* () {
|
1682
1710
|
yield resolveDataForItem(item2, force);
|
1683
1711
|
}));
|
1684
1712
|
} else if (root) {
|
1685
1713
|
resolveDataForRoot(force);
|
1686
1714
|
} else {
|
1687
|
-
|
1688
|
-
flattenData(state.data).map((item2) => __async(void 0, null, function* () {
|
1715
|
+
flattenData(state, config).map((item2) => __async(void 0, null, function* () {
|
1689
1716
|
yield resolveDataForItem(item2, force);
|
1690
1717
|
}));
|
1691
1718
|
}
|
@@ -1715,7 +1742,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1715
1742
|
} else if (root) {
|
1716
1743
|
const rootConfig = config.root;
|
1717
1744
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
|
1718
|
-
const resolvedForItem = resolvedPermissions["
|
1745
|
+
const resolvedForItem = resolvedPermissions["root"];
|
1719
1746
|
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
1720
1747
|
}
|
1721
1748
|
return globalPermissions;
|
@@ -1727,16 +1754,97 @@ var createPermissionsSlice = (set, get) => {
|
|
1727
1754
|
|
1728
1755
|
// ../core/store/slices/fields.ts
|
1729
1756
|
init_react_import();
|
1730
|
-
import { useCallback, useEffect as
|
1731
|
-
var
|
1757
|
+
import { useCallback, useEffect as useEffect4 } from "react";
|
1758
|
+
var createFieldsSlice = (_set, _get) => {
|
1732
1759
|
return {
|
1733
1760
|
fields: {},
|
1734
1761
|
loading: false,
|
1735
|
-
lastResolvedData: {}
|
1762
|
+
lastResolvedData: {},
|
1763
|
+
id: void 0
|
1736
1764
|
};
|
1737
1765
|
};
|
1738
1766
|
|
1739
|
-
// ../core/
|
1767
|
+
// ../core/lib/resolve-component-data.ts
|
1768
|
+
init_react_import();
|
1769
|
+
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1770
|
+
var cache = { lastChange: {} };
|
1771
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
1772
|
+
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
1773
|
+
const resolvedItem = __spreadValues({}, item);
|
1774
|
+
const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
|
1775
|
+
const id = "id" in item.props ? item.props.id : "root";
|
1776
|
+
if (shouldRunResolver) {
|
1777
|
+
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
1778
|
+
if (item && (0, import_fast_deep_equal.default)(item, oldItem)) {
|
1779
|
+
return { node: resolved, didChange: false };
|
1780
|
+
}
|
1781
|
+
const changed = getChanged(item, oldItem);
|
1782
|
+
if (onResolveStart) {
|
1783
|
+
onResolveStart(item);
|
1784
|
+
}
|
1785
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
1786
|
+
changed,
|
1787
|
+
lastData: oldItem,
|
1788
|
+
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
1789
|
+
trigger
|
1790
|
+
});
|
1791
|
+
resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
|
1792
|
+
if (Object.keys(readOnly).length) {
|
1793
|
+
resolvedItem.readOnly = readOnly;
|
1794
|
+
}
|
1795
|
+
}
|
1796
|
+
let itemWithResolvedChildren = yield mapSlots(
|
1797
|
+
resolvedItem,
|
1798
|
+
(content) => __async(void 0, null, function* () {
|
1799
|
+
return yield Promise.all(
|
1800
|
+
content.map(
|
1801
|
+
(childItem) => __async(void 0, null, function* () {
|
1802
|
+
return (yield resolveComponentData(
|
1803
|
+
childItem,
|
1804
|
+
config,
|
1805
|
+
metadata,
|
1806
|
+
onResolveStart,
|
1807
|
+
onResolveEnd,
|
1808
|
+
trigger
|
1809
|
+
)).node;
|
1810
|
+
})
|
1811
|
+
)
|
1812
|
+
);
|
1813
|
+
}),
|
1814
|
+
config
|
1815
|
+
);
|
1816
|
+
if (shouldRunResolver && onResolveEnd) {
|
1817
|
+
onResolveEnd(resolvedItem);
|
1818
|
+
}
|
1819
|
+
cache.lastChange[id] = {
|
1820
|
+
item,
|
1821
|
+
resolved: itemWithResolvedChildren
|
1822
|
+
};
|
1823
|
+
return {
|
1824
|
+
node: itemWithResolvedChildren,
|
1825
|
+
didChange: !(0, import_fast_deep_equal.default)(item, itemWithResolvedChildren)
|
1826
|
+
};
|
1827
|
+
});
|
1828
|
+
|
1829
|
+
// ../core/lib/data/to-root.ts
|
1830
|
+
init_react_import();
|
1831
|
+
var toRoot = (item) => {
|
1832
|
+
if ("type" in item && item.type !== "root") {
|
1833
|
+
throw new Error("Converting non-root item to root.");
|
1834
|
+
}
|
1835
|
+
const { readOnly } = item;
|
1836
|
+
if (item.props) {
|
1837
|
+
if ("id" in item.props) {
|
1838
|
+
const _a = item.props, { id } = _a, props = __objRest(_a, ["id"]);
|
1839
|
+
return { props, readOnly };
|
1840
|
+
}
|
1841
|
+
return { props: item.props, readOnly };
|
1842
|
+
}
|
1843
|
+
return { props: {}, readOnly };
|
1844
|
+
};
|
1845
|
+
|
1846
|
+
// ../core/store/default-app-state.ts
|
1847
|
+
init_react_import();
|
1740
1848
|
var defaultAppState = {
|
1741
1849
|
data: { content: [], root: {}, zones: {} },
|
1742
1850
|
ui: {
|
@@ -1756,92 +1864,188 @@ var defaultAppState = {
|
|
1756
1864
|
controlsVisible: true
|
1757
1865
|
},
|
1758
1866
|
field: { focus: null }
|
1867
|
+
},
|
1868
|
+
indexes: {
|
1869
|
+
nodes: {},
|
1870
|
+
zones: {}
|
1759
1871
|
}
|
1760
1872
|
};
|
1873
|
+
|
1874
|
+
// ../core/store/index.ts
|
1761
1875
|
var defaultPageFields = {
|
1762
1876
|
title: { type: "text" }
|
1763
1877
|
};
|
1764
1878
|
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
|
-
|
1879
|
+
subscribeWithSelector((set, get) => {
|
1880
|
+
var _a, _b;
|
1881
|
+
return __spreadProps(__spreadValues({
|
1882
|
+
state: defaultAppState,
|
1883
|
+
config: { components: {} },
|
1884
|
+
componentState: {},
|
1885
|
+
plugins: [],
|
1886
|
+
overrides: {},
|
1887
|
+
viewports: defaultViewports,
|
1888
|
+
zoomConfig: {
|
1889
|
+
autoZoom: 1,
|
1890
|
+
rootHeight: 0,
|
1891
|
+
zoom: 1
|
1892
|
+
},
|
1893
|
+
status: "LOADING",
|
1894
|
+
iframe: {},
|
1895
|
+
metadata: {}
|
1896
|
+
}, initialAppStore), {
|
1897
|
+
fields: createFieldsSlice(set, get),
|
1898
|
+
history: createHistorySlice(set, get),
|
1899
|
+
nodes: createNodesSlice(set, get),
|
1900
|
+
permissions: createPermissionsSlice(set, get),
|
1901
|
+
getComponentConfig: (type) => {
|
1902
|
+
var _a2;
|
1903
|
+
const { config, selectedItem } = get();
|
1904
|
+
const rootFields = ((_a2 = config.root) == null ? void 0 : _a2.fields) || defaultPageFields;
|
1905
|
+
return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
|
1906
|
+
},
|
1907
|
+
selectedItem: ((_a = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _a.ui.itemSelector) ? getItem(
|
1908
|
+
(_b = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _b.ui.itemSelector,
|
1909
|
+
initialAppStore.state
|
1910
|
+
) : null,
|
1911
|
+
dispatch: (action) => set((s) => {
|
1912
|
+
var _a2, _b2;
|
1913
|
+
const { record } = get().history;
|
1914
|
+
const dispatch = createReducer({
|
1915
|
+
record,
|
1916
|
+
appStore: s
|
1917
|
+
});
|
1918
|
+
const state = dispatch(s.state, action);
|
1919
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1920
|
+
(_b2 = (_a2 = get()).onAction) == null ? void 0 : _b2.call(_a2, action, state, get().state);
|
1921
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1922
|
+
}),
|
1923
|
+
setZoomConfig: (zoomConfig) => set({ zoomConfig }),
|
1924
|
+
setStatus: (status) => set({ status }),
|
1925
|
+
setComponentState: (componentState) => set({ componentState }),
|
1926
|
+
pendingLoadTimeouts: {},
|
1927
|
+
setComponentLoading: (id, loading = true, defer = 0) => {
|
1928
|
+
const { setComponentState, pendingLoadTimeouts } = get();
|
1929
|
+
const loadId = generateId();
|
1930
|
+
const setLoading = () => {
|
1931
|
+
var _a2;
|
1932
|
+
const { componentState } = get();
|
1933
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1934
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1935
|
+
loadingCount: (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) + 1
|
1936
|
+
})
|
1937
|
+
}));
|
1938
|
+
};
|
1939
|
+
const unsetLoading = () => {
|
1940
|
+
var _a2;
|
1941
|
+
const { componentState } = get();
|
1942
|
+
clearTimeout(timeout);
|
1943
|
+
delete pendingLoadTimeouts[loadId];
|
1944
|
+
set({ pendingLoadTimeouts });
|
1945
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1946
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1947
|
+
loadingCount: Math.max(
|
1948
|
+
(((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) - 1,
|
1949
|
+
0
|
1950
|
+
)
|
1951
|
+
})
|
1952
|
+
}));
|
1953
|
+
};
|
1954
|
+
const timeout = setTimeout(() => {
|
1955
|
+
if (loading) {
|
1956
|
+
setLoading();
|
1957
|
+
} else {
|
1958
|
+
unsetLoading();
|
1959
|
+
}
|
1960
|
+
delete pendingLoadTimeouts[loadId];
|
1961
|
+
set({ pendingLoadTimeouts });
|
1962
|
+
}, defer);
|
1963
|
+
set({
|
1964
|
+
pendingLoadTimeouts: __spreadProps(__spreadValues({}, pendingLoadTimeouts), {
|
1965
|
+
[id]: timeout
|
1966
|
+
})
|
1967
|
+
});
|
1968
|
+
return unsetLoading;
|
1969
|
+
},
|
1970
|
+
unsetComponentLoading: (id) => {
|
1971
|
+
const { setComponentLoading } = get();
|
1972
|
+
setComponentLoading(id, false);
|
1973
|
+
},
|
1974
|
+
// Helper
|
1975
|
+
setUi: (ui, recordHistory) => set((s) => {
|
1976
|
+
const dispatch = createReducer({
|
1977
|
+
record: () => {
|
1978
|
+
},
|
1979
|
+
appStore: s
|
1980
|
+
});
|
1981
|
+
const state = dispatch(s.state, {
|
1982
|
+
type: "setUi",
|
1983
|
+
ui,
|
1984
|
+
recordHistory
|
1985
|
+
});
|
1986
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1987
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1988
|
+
}),
|
1989
|
+
resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
|
1990
|
+
const { config, metadata, setComponentLoading, permissions } = get();
|
1991
|
+
const timeouts = {};
|
1992
|
+
return yield resolveComponentData(
|
1993
|
+
componentData,
|
1994
|
+
config,
|
1995
|
+
metadata,
|
1996
|
+
(item) => {
|
1997
|
+
const id = "id" in item.props ? item.props.id : "root";
|
1998
|
+
timeouts[id] = setComponentLoading(id, true, 50);
|
1999
|
+
},
|
2000
|
+
(item) => __async(void 0, null, function* () {
|
2001
|
+
const id = "id" in item.props ? item.props.id : "root";
|
2002
|
+
if ("type" in item) {
|
2003
|
+
yield permissions.refreshPermissions({ item });
|
2004
|
+
} else {
|
2005
|
+
yield permissions.refreshPermissions({ root: true });
|
2006
|
+
}
|
2007
|
+
timeouts[id]();
|
2008
|
+
}),
|
2009
|
+
trigger
|
2010
|
+
);
|
2011
|
+
}),
|
2012
|
+
resolveAndCommitData: () => __async(void 0, null, function* () {
|
2013
|
+
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
2014
|
+
walkAppState(
|
2015
|
+
state,
|
2016
|
+
config,
|
2017
|
+
(content) => content,
|
2018
|
+
(childItem) => {
|
2019
|
+
resolveComponentData2(childItem, "load").then((resolved) => {
|
2020
|
+
const { state: state2 } = get();
|
2021
|
+
const node = state2.indexes.nodes[resolved.node.props.id];
|
2022
|
+
if (node && resolved.didChange) {
|
2023
|
+
if (resolved.node.props.id === "root") {
|
2024
|
+
dispatch({
|
2025
|
+
type: "replaceRoot",
|
2026
|
+
root: toRoot(resolved.node)
|
2027
|
+
});
|
2028
|
+
} else {
|
2029
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
2030
|
+
const parentZone = state2.indexes.zones[zoneCompound];
|
2031
|
+
const index = parentZone.contentIds.indexOf(
|
2032
|
+
resolved.node.props.id
|
2033
|
+
);
|
2034
|
+
dispatch({
|
2035
|
+
type: "replace",
|
2036
|
+
data: resolved.node,
|
2037
|
+
destinationIndex: index,
|
2038
|
+
destinationZone: zoneCompound
|
2039
|
+
});
|
2040
|
+
}
|
2041
|
+
}
|
2042
|
+
});
|
2043
|
+
return childItem;
|
2044
|
+
}
|
2045
|
+
);
|
2046
|
+
})
|
2047
|
+
});
|
2048
|
+
})
|
1845
2049
|
);
|
1846
2050
|
var appStoreContext = createContext(createAppStore());
|
1847
2051
|
function useAppStore(selector) {
|
@@ -1861,12 +2065,12 @@ var useBreadcrumbs = (renderCount) => {
|
|
1861
2065
|
const config = useAppStore((s) => s.config);
|
1862
2066
|
const path = useAppStore((s) => {
|
1863
2067
|
var _a;
|
1864
|
-
return (_a = s.
|
2068
|
+
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
1865
2069
|
});
|
1866
2070
|
const appStore = useAppStoreApi();
|
1867
2071
|
return useMemo(() => {
|
1868
2072
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
1869
|
-
var _a, _b;
|
2073
|
+
var _a, _b, _c;
|
1870
2074
|
const [componentId] = zoneCompound.split(":");
|
1871
2075
|
if (componentId === "root") {
|
1872
2076
|
return {
|
@@ -1874,12 +2078,15 @@ var useBreadcrumbs = (renderCount) => {
|
|
1874
2078
|
selector: null
|
1875
2079
|
};
|
1876
2080
|
}
|
1877
|
-
const node = appStore.getState().
|
1878
|
-
const
|
2081
|
+
const node = appStore.getState().state.indexes.nodes[componentId];
|
2082
|
+
const parentId = node.path[node.path.length - 1];
|
2083
|
+
const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
|
2084
|
+
const index = contentIds.indexOf(componentId);
|
2085
|
+
const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
|
1879
2086
|
return {
|
1880
2087
|
label,
|
1881
2088
|
selector: node ? {
|
1882
|
-
index
|
2089
|
+
index,
|
1883
2090
|
zone: node.path[node.path.length - 1]
|
1884
2091
|
} : null
|
1885
2092
|
};
|
@@ -1900,6 +2107,12 @@ init_react_import();
|
|
1900
2107
|
// ../core/lib/filter.ts
|
1901
2108
|
init_react_import();
|
1902
2109
|
|
2110
|
+
// ../core/lib/data/reorder.ts
|
2111
|
+
init_react_import();
|
2112
|
+
|
2113
|
+
// ../core/lib/data/replace.ts
|
2114
|
+
init_react_import();
|
2115
|
+
|
1903
2116
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
|
1904
2117
|
init_react_import();
|
1905
2118
|
var styles_module_default3 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
|
@@ -2081,17 +2294,39 @@ var usePuck = createUsePuck();
|
|
2081
2294
|
var HeadingAnalyzer = () => {
|
2082
2295
|
const data = usePuck((s) => s.appState.data);
|
2083
2296
|
const [hierarchy, setHierarchy] = useState([]);
|
2084
|
-
|
2297
|
+
useEffect5(() => {
|
2085
2298
|
const frame = getFrame();
|
2086
|
-
|
2087
|
-
|
2088
|
-
setHierarchy(buildHierarchy(entry));
|
2089
|
-
const observer = new MutationObserver(() => {
|
2299
|
+
let entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
2300
|
+
const createHierarchy = () => {
|
2090
2301
|
setHierarchy(buildHierarchy(entry));
|
2302
|
+
};
|
2303
|
+
const entryObserver = new MutationObserver(() => {
|
2304
|
+
createHierarchy();
|
2305
|
+
});
|
2306
|
+
const frameObserver = new MutationObserver(() => {
|
2307
|
+
entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
2308
|
+
if (entry) {
|
2309
|
+
registerEntryObserver();
|
2310
|
+
frameObserver.disconnect();
|
2311
|
+
}
|
2091
2312
|
});
|
2092
|
-
|
2313
|
+
const registerEntryObserver = () => {
|
2314
|
+
if (!entry) return;
|
2315
|
+
entryObserver.observe(entry, { subtree: true, childList: true });
|
2316
|
+
};
|
2317
|
+
const registerFrameObserver = () => {
|
2318
|
+
if (!frame) return;
|
2319
|
+
frameObserver.observe(frame, { subtree: true, childList: true });
|
2320
|
+
};
|
2321
|
+
if (entry) {
|
2322
|
+
createHierarchy();
|
2323
|
+
registerEntryObserver();
|
2324
|
+
} else {
|
2325
|
+
registerFrameObserver();
|
2326
|
+
}
|
2093
2327
|
return () => {
|
2094
|
-
|
2328
|
+
entryObserver.disconnect();
|
2329
|
+
frameObserver.disconnect();
|
2095
2330
|
};
|
2096
2331
|
}, [data]);
|
2097
2332
|
return /* @__PURE__ */ jsxs2("div", { className: getClassName5(), children: [
|
@@ -2194,50 +2429,6 @@ classnames/index.js:
|
|
2194
2429
|
http://jedwatson.github.io/classnames
|
2195
2430
|
*)
|
2196
2431
|
|
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
2432
|
lucide-react/dist/esm/shared/src/utils.js:
|
2242
2433
|
(**
|
2243
2434
|
* @license lucide-react v0.468.0 - ISC
|