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