@measured/puck-plugin-heading-analyzer 0.18.3-canary.154e7f7 → 0.19.0-canary.0a3e56e
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/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1243 -194
- package/dist/index.mjs +1237 -198
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
@@ -55,6 +55,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
55
55
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
56
56
|
mod
|
57
57
|
));
|
58
|
+
var __async = (__this, __arguments, generator) => {
|
59
|
+
return new Promise((resolve, reject) => {
|
60
|
+
var fulfilled = (value) => {
|
61
|
+
try {
|
62
|
+
step(generator.next(value));
|
63
|
+
} catch (e) {
|
64
|
+
reject(e);
|
65
|
+
}
|
66
|
+
};
|
67
|
+
var rejected = (value) => {
|
68
|
+
try {
|
69
|
+
step(generator.throw(value));
|
70
|
+
} catch (e) {
|
71
|
+
reject(e);
|
72
|
+
}
|
73
|
+
};
|
74
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
75
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
76
|
+
});
|
77
|
+
};
|
58
78
|
|
59
79
|
// ../tsup-config/react-import.js
|
60
80
|
import React from "react";
|
@@ -126,19 +146,55 @@ var require_classnames = __commonJS({
|
|
126
146
|
}
|
127
147
|
});
|
128
148
|
|
149
|
+
// ../../node_modules/fast-deep-equal/index.js
|
150
|
+
var require_fast_deep_equal = __commonJS({
|
151
|
+
"../../node_modules/fast-deep-equal/index.js"(exports, module) {
|
152
|
+
"use strict";
|
153
|
+
init_react_import();
|
154
|
+
module.exports = function equal(a, b) {
|
155
|
+
if (a === b) return true;
|
156
|
+
if (a && b && typeof a == "object" && typeof b == "object") {
|
157
|
+
if (a.constructor !== b.constructor) return false;
|
158
|
+
var length, i, keys;
|
159
|
+
if (Array.isArray(a)) {
|
160
|
+
length = a.length;
|
161
|
+
if (length != b.length) return false;
|
162
|
+
for (i = length; i-- !== 0; )
|
163
|
+
if (!equal(a[i], b[i])) return false;
|
164
|
+
return true;
|
165
|
+
}
|
166
|
+
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
167
|
+
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
168
|
+
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
169
|
+
keys = Object.keys(a);
|
170
|
+
length = keys.length;
|
171
|
+
if (length !== Object.keys(b).length) return false;
|
172
|
+
for (i = length; i-- !== 0; )
|
173
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
174
|
+
for (i = length; i-- !== 0; ) {
|
175
|
+
var key = keys[i];
|
176
|
+
if (!equal(a[key], b[key])) return false;
|
177
|
+
}
|
178
|
+
return true;
|
179
|
+
}
|
180
|
+
return a !== a && b !== b;
|
181
|
+
};
|
182
|
+
}
|
183
|
+
});
|
184
|
+
|
129
185
|
// index.ts
|
130
186
|
init_react_import();
|
131
187
|
|
132
188
|
// src/HeadingAnalyzer.tsx
|
133
189
|
init_react_import();
|
134
|
-
import { useEffect as
|
190
|
+
import { useEffect as useEffect6, useState } from "react";
|
135
191
|
|
136
192
|
// css-module:/home/runner/work/puck/puck/packages/plugin-heading-analyzer/src/HeadingAnalyzer.module.css#css-module
|
137
193
|
init_react_import();
|
138
194
|
var HeadingAnalyzer_module_default = { "HeadingAnalyzer": "_HeadingAnalyzer_116v6_1", "HeadingAnalyzer-cssWarning": "_HeadingAnalyzer-cssWarning_116v6_5", "HeadingAnalyzerItem": "_HeadingAnalyzerItem_116v6_9", "HeadingAnalyzerItem--missing": "_HeadingAnalyzerItem--missing_116v6_13" };
|
139
195
|
|
140
196
|
// src/HeadingAnalyzer.tsx
|
141
|
-
import {
|
197
|
+
import { createUsePuck } from "@measured/puck";
|
142
198
|
|
143
199
|
// ../core/components/SidebarSection/index.tsx
|
144
200
|
init_react_import();
|
@@ -292,141 +348,519 @@ var ChevronRight = createLucideIcon("ChevronRight", [
|
|
292
348
|
|
293
349
|
// ../core/lib/use-breadcrumbs.ts
|
294
350
|
init_react_import();
|
295
|
-
import {
|
351
|
+
import { useMemo } from "react";
|
296
352
|
|
297
|
-
// ../core/
|
353
|
+
// ../core/store/index.ts
|
298
354
|
init_react_import();
|
299
|
-
import {
|
300
|
-
createContext as createContext2,
|
301
|
-
useCallback as useCallback3,
|
302
|
-
useMemo,
|
303
|
-
useState as useState4
|
304
|
-
} from "react";
|
305
355
|
|
306
|
-
// ../core/
|
356
|
+
// ../core/reducer/index.ts
|
307
357
|
init_react_import();
|
308
|
-
import {
|
309
|
-
createContext,
|
310
|
-
useContext,
|
311
|
-
useEffect as useEffect3,
|
312
|
-
useState as useState3
|
313
|
-
} from "react";
|
314
358
|
|
315
|
-
// ../core/
|
359
|
+
// ../core/reducer/data.ts
|
360
|
+
init_react_import();
|
361
|
+
|
362
|
+
// ../core/lib/reorder.ts
|
316
363
|
init_react_import();
|
364
|
+
var reorder = (list, startIndex, endIndex) => {
|
365
|
+
const result = Array.from(list);
|
366
|
+
const [removed] = result.splice(startIndex, 1);
|
367
|
+
result.splice(endIndex, 0, removed);
|
368
|
+
return result;
|
369
|
+
};
|
317
370
|
|
318
371
|
// ../core/lib/root-droppable-id.ts
|
319
372
|
init_react_import();
|
320
|
-
var
|
373
|
+
var rootAreaId = "root";
|
374
|
+
var rootZone = "default-zone";
|
375
|
+
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
376
|
+
|
377
|
+
// ../core/lib/insert.ts
|
378
|
+
init_react_import();
|
379
|
+
var insert = (list, index, item) => {
|
380
|
+
const result = Array.from(list);
|
381
|
+
result.splice(index, 0, item);
|
382
|
+
return result;
|
383
|
+
};
|
384
|
+
|
385
|
+
// ../core/lib/remove.ts
|
386
|
+
init_react_import();
|
387
|
+
var remove = (list, index) => {
|
388
|
+
const result = Array.from(list);
|
389
|
+
result.splice(index, 1);
|
390
|
+
return result;
|
391
|
+
};
|
321
392
|
|
322
393
|
// ../core/lib/setup-zone.ts
|
323
394
|
init_react_import();
|
395
|
+
var setupZone = (data, zoneKey) => {
|
396
|
+
if (zoneKey === rootDroppableId) {
|
397
|
+
return data;
|
398
|
+
}
|
399
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
400
|
+
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
401
|
+
});
|
402
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
403
|
+
return newData;
|
404
|
+
};
|
324
405
|
|
325
|
-
// ../core/
|
406
|
+
// ../core/lib/replace.ts
|
326
407
|
init_react_import();
|
327
|
-
var
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
408
|
+
var replace = (list, index, newItem) => {
|
409
|
+
const result = Array.from(list);
|
410
|
+
result.splice(index, 1);
|
411
|
+
result.splice(index, 0, newItem);
|
412
|
+
return result;
|
413
|
+
};
|
332
414
|
|
333
|
-
// ../core/lib/
|
415
|
+
// ../core/lib/get-item.ts
|
334
416
|
init_react_import();
|
335
|
-
|
417
|
+
function getItem(selector, data, dynamicProps = {}) {
|
418
|
+
if (!selector.zone || selector.zone === rootDroppableId) {
|
419
|
+
const item2 = data.content[selector.index];
|
420
|
+
return (item2 == null ? void 0 : item2.props) ? __spreadProps(__spreadValues({}, item2), { props: dynamicProps[item2.props.id] || item2.props }) : void 0;
|
421
|
+
}
|
422
|
+
const item = setupZone(data, selector.zone).zones[selector.zone][selector.index];
|
423
|
+
return (item == null ? void 0 : item.props) ? __spreadProps(__spreadValues({}, item), { props: dynamicProps[item.props.id] || item.props }) : void 0;
|
424
|
+
}
|
336
425
|
|
337
|
-
// ../core/lib/
|
426
|
+
// ../core/lib/reduce-related-zones.ts
|
338
427
|
init_react_import();
|
339
428
|
|
340
|
-
// ../core/lib/
|
429
|
+
// ../core/lib/generate-id.ts
|
341
430
|
init_react_import();
|
342
431
|
|
343
|
-
//
|
432
|
+
// ../../node_modules/uuid/dist/esm-node/index.js
|
344
433
|
init_react_import();
|
345
|
-
import { useCallback as useCallback2, useEffect as useEffect2, useState as useState2 } from "react";
|
346
434
|
|
347
|
-
//
|
435
|
+
// ../../node_modules/uuid/dist/esm-node/rng.js
|
348
436
|
init_react_import();
|
437
|
+
import crypto from "crypto";
|
438
|
+
var rnds8Pool = new Uint8Array(256);
|
439
|
+
var poolPtr = rnds8Pool.length;
|
440
|
+
function rng() {
|
441
|
+
if (poolPtr > rnds8Pool.length - 16) {
|
442
|
+
crypto.randomFillSync(rnds8Pool);
|
443
|
+
poolPtr = 0;
|
444
|
+
}
|
445
|
+
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
446
|
+
}
|
349
447
|
|
350
|
-
//
|
448
|
+
// ../../node_modules/uuid/dist/esm-node/stringify.js
|
351
449
|
init_react_import();
|
450
|
+
var byteToHex = [];
|
451
|
+
for (let i = 0; i < 256; ++i) {
|
452
|
+
byteToHex.push((i + 256).toString(16).slice(1));
|
453
|
+
}
|
454
|
+
function unsafeStringify(arr, offset = 0) {
|
455
|
+
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
456
|
+
}
|
352
457
|
|
353
|
-
//
|
458
|
+
// ../../node_modules/uuid/dist/esm-node/v4.js
|
354
459
|
init_react_import();
|
355
460
|
|
356
|
-
//
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
461
|
+
// ../../node_modules/uuid/dist/esm-node/native.js
|
462
|
+
init_react_import();
|
463
|
+
import crypto2 from "crypto";
|
464
|
+
var native_default = {
|
465
|
+
randomUUID: crypto2.randomUUID
|
466
|
+
};
|
467
|
+
|
468
|
+
// ../../node_modules/uuid/dist/esm-node/v4.js
|
469
|
+
function v4(options, buf, offset) {
|
470
|
+
if (native_default.randomUUID && !buf && !options) {
|
471
|
+
return native_default.randomUUID();
|
472
|
+
}
|
473
|
+
options = options || {};
|
474
|
+
const rnds = options.random || (options.rng || rng)();
|
475
|
+
rnds[6] = rnds[6] & 15 | 64;
|
476
|
+
rnds[8] = rnds[8] & 63 | 128;
|
477
|
+
if (buf) {
|
478
|
+
offset = offset || 0;
|
479
|
+
for (let i = 0; i < 16; ++i) {
|
480
|
+
buf[offset + i] = rnds[i];
|
481
|
+
}
|
482
|
+
return buf;
|
483
|
+
}
|
484
|
+
return unsafeStringify(rnds);
|
485
|
+
}
|
486
|
+
var v4_default = v4;
|
487
|
+
|
488
|
+
// ../core/lib/generate-id.ts
|
489
|
+
var generateId = (type) => type ? `${type}-${v4_default()}` : v4_default();
|
490
|
+
|
491
|
+
// ../core/lib/get-zone-id.ts
|
492
|
+
init_react_import();
|
493
|
+
var getZoneId = (zoneCompound) => {
|
494
|
+
if (!zoneCompound) {
|
495
|
+
return [];
|
496
|
+
}
|
497
|
+
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
498
|
+
return zoneCompound.split(":");
|
499
|
+
}
|
500
|
+
return [rootDroppableId, zoneCompound];
|
501
|
+
};
|
502
|
+
|
503
|
+
// ../core/lib/reduce-related-zones.ts
|
504
|
+
function reduceRelatedZones(item, data, fn) {
|
505
|
+
return __spreadProps(__spreadValues({}, data), {
|
506
|
+
zones: Object.keys(data.zones || {}).reduce(
|
507
|
+
(acc, key) => {
|
508
|
+
const [parentId] = getZoneId(key);
|
509
|
+
if (parentId === item.props.id) {
|
510
|
+
const zones = data.zones;
|
511
|
+
return fn(acc, key, zones[key]);
|
512
|
+
}
|
513
|
+
return __spreadProps(__spreadValues({}, acc), { [key]: data.zones[key] });
|
372
514
|
},
|
373
|
-
|
374
|
-
|
515
|
+
{}
|
516
|
+
)
|
517
|
+
});
|
518
|
+
}
|
519
|
+
var findRelatedByZoneId = (zoneId, data) => {
|
520
|
+
const [zoneParentId] = getZoneId(zoneId);
|
521
|
+
return (data.zones[zoneId] || []).reduce(
|
522
|
+
(acc, zoneItem) => {
|
523
|
+
const related = findRelatedByItem(zoneItem, data);
|
524
|
+
if (zoneItem.props.id === zoneParentId) {
|
525
|
+
return __spreadProps(__spreadValues(__spreadValues({}, acc), related), { [zoneId]: zoneItem });
|
526
|
+
}
|
527
|
+
return __spreadValues(__spreadValues({}, acc), related);
|
375
528
|
},
|
376
|
-
|
529
|
+
{}
|
530
|
+
);
|
531
|
+
};
|
532
|
+
var findRelatedByItem = (item, data) => {
|
533
|
+
return Object.keys(data.zones || {}).reduce(
|
534
|
+
(acc, zoneId) => {
|
535
|
+
const [zoneParentId] = getZoneId(zoneId);
|
536
|
+
if (item.props.id === zoneParentId) {
|
537
|
+
const related = findRelatedByZoneId(zoneId, data);
|
538
|
+
return __spreadProps(__spreadValues(__spreadValues({}, acc), related), {
|
539
|
+
[zoneId]: data.zones[zoneId]
|
540
|
+
});
|
541
|
+
}
|
542
|
+
return acc;
|
543
|
+
},
|
544
|
+
{}
|
545
|
+
);
|
546
|
+
};
|
547
|
+
var removeRelatedZones = (item, data) => {
|
548
|
+
const newData = __spreadValues({}, data);
|
549
|
+
const related = findRelatedByItem(item, data);
|
550
|
+
Object.keys(related).forEach((key) => {
|
551
|
+
delete newData.zones[key];
|
552
|
+
});
|
553
|
+
return newData;
|
554
|
+
};
|
555
|
+
function duplicateRelatedZones(item, data, newId) {
|
556
|
+
return reduceRelatedZones(item, data, (acc, key, zone) => {
|
557
|
+
const dupedZone = zone.map((zoneItem) => __spreadProps(__spreadValues({}, zoneItem), {
|
558
|
+
props: __spreadProps(__spreadValues({}, zoneItem.props), { id: generateId(zoneItem.type) })
|
559
|
+
}));
|
560
|
+
const dupeOfDupes = dupedZone.reduce(
|
561
|
+
(dupeOfDupes2, item2, index) => __spreadValues(__spreadValues({}, dupeOfDupes2), duplicateRelatedZones(zone[index], data, item2.props.id).zones),
|
562
|
+
acc
|
563
|
+
);
|
564
|
+
const [_, zoneId] = getZoneId(key);
|
565
|
+
return __spreadProps(__spreadValues({}, dupeOfDupes), {
|
566
|
+
[key]: zone,
|
567
|
+
[`${newId}:${zoneId}`]: dupedZone
|
568
|
+
});
|
569
|
+
});
|
570
|
+
}
|
571
|
+
|
572
|
+
// ../core/reducer/data.ts
|
573
|
+
var zoneCache = {};
|
574
|
+
var replaceAction = (data, action) => {
|
575
|
+
if (action.destinationZone === rootDroppableId) {
|
576
|
+
return __spreadProps(__spreadValues({}, data), {
|
577
|
+
content: replace(data.content, action.destinationIndex, action.data)
|
578
|
+
});
|
377
579
|
}
|
580
|
+
const newData = setupZone(data, action.destinationZone);
|
581
|
+
return __spreadProps(__spreadValues({}, newData), {
|
582
|
+
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
583
|
+
[action.destinationZone]: replace(
|
584
|
+
newData.zones[action.destinationZone],
|
585
|
+
action.destinationIndex,
|
586
|
+
action.data
|
587
|
+
)
|
588
|
+
})
|
589
|
+
});
|
378
590
|
};
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
}
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
},
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
};
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
591
|
+
function insertAction(data, action, config) {
|
592
|
+
const emptyComponentData = {
|
593
|
+
type: action.componentType,
|
594
|
+
props: __spreadProps(__spreadValues({}, config.components[action.componentType].defaultProps || {}), {
|
595
|
+
id: action.id || generateId(action.componentType)
|
596
|
+
})
|
597
|
+
};
|
598
|
+
if (action.destinationZone === rootDroppableId) {
|
599
|
+
return __spreadProps(__spreadValues({}, data), {
|
600
|
+
content: insert(
|
601
|
+
data.content,
|
602
|
+
action.destinationIndex,
|
603
|
+
emptyComponentData
|
604
|
+
)
|
605
|
+
});
|
606
|
+
}
|
607
|
+
const newData = setupZone(data, action.destinationZone);
|
608
|
+
return __spreadProps(__spreadValues({}, data), {
|
609
|
+
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
610
|
+
[action.destinationZone]: insert(
|
611
|
+
newData.zones[action.destinationZone],
|
612
|
+
action.destinationIndex,
|
613
|
+
emptyComponentData
|
614
|
+
)
|
615
|
+
})
|
616
|
+
});
|
617
|
+
}
|
618
|
+
var reorderAction = (data, action) => {
|
619
|
+
if (action.destinationZone === rootDroppableId) {
|
620
|
+
return __spreadProps(__spreadValues({}, data), {
|
621
|
+
content: reorder(
|
622
|
+
data.content,
|
623
|
+
action.sourceIndex,
|
624
|
+
action.destinationIndex
|
625
|
+
)
|
626
|
+
});
|
627
|
+
}
|
628
|
+
const newData = setupZone(data, action.destinationZone);
|
629
|
+
return __spreadProps(__spreadValues({}, data), {
|
630
|
+
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
631
|
+
[action.destinationZone]: reorder(
|
632
|
+
newData.zones[action.destinationZone],
|
633
|
+
action.sourceIndex,
|
634
|
+
action.destinationIndex
|
635
|
+
)
|
636
|
+
})
|
637
|
+
});
|
638
|
+
};
|
639
|
+
function reduceData(data, action, config) {
|
640
|
+
if (action.type === "insert") {
|
641
|
+
return insertAction(data, action, config);
|
642
|
+
}
|
643
|
+
if (action.type === "duplicate") {
|
644
|
+
const item = getItem(
|
645
|
+
{ index: action.sourceIndex, zone: action.sourceZone },
|
646
|
+
data
|
647
|
+
);
|
648
|
+
const newItem = __spreadProps(__spreadValues({}, item), {
|
649
|
+
props: __spreadProps(__spreadValues({}, item.props), {
|
650
|
+
id: generateId(item.type)
|
651
|
+
})
|
652
|
+
});
|
653
|
+
const dataWithRelatedDuplicated = duplicateRelatedZones(
|
654
|
+
item,
|
655
|
+
data,
|
656
|
+
newItem.props.id
|
657
|
+
);
|
658
|
+
if (action.sourceZone === rootDroppableId) {
|
659
|
+
return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
|
660
|
+
content: insert(data.content, action.sourceIndex + 1, newItem)
|
415
661
|
});
|
416
662
|
}
|
417
|
-
|
663
|
+
return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
|
664
|
+
zones: __spreadProps(__spreadValues({}, dataWithRelatedDuplicated.zones), {
|
665
|
+
[action.sourceZone]: insert(
|
666
|
+
dataWithRelatedDuplicated.zones[action.sourceZone],
|
667
|
+
action.sourceIndex + 1,
|
668
|
+
newItem
|
669
|
+
)
|
670
|
+
})
|
671
|
+
});
|
672
|
+
}
|
673
|
+
if (action.type === "reorder") {
|
674
|
+
return reorderAction(data, action);
|
675
|
+
}
|
676
|
+
if (action.type === "move") {
|
677
|
+
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
678
|
+
return data;
|
679
|
+
}
|
680
|
+
const newData = setupZone(
|
681
|
+
setupZone(data, action.sourceZone),
|
682
|
+
action.destinationZone
|
683
|
+
);
|
684
|
+
const item = getItem(
|
685
|
+
{ zone: action.sourceZone, index: action.sourceIndex },
|
686
|
+
newData
|
687
|
+
);
|
688
|
+
if (action.sourceZone === action.destinationZone) {
|
689
|
+
return reorderAction(data, __spreadProps(__spreadValues({}, action), { type: "reorder" }));
|
690
|
+
}
|
691
|
+
if (action.sourceZone === rootDroppableId) {
|
692
|
+
return __spreadProps(__spreadValues({}, newData), {
|
693
|
+
content: remove(newData.content, action.sourceIndex),
|
694
|
+
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
695
|
+
[action.destinationZone]: insert(
|
696
|
+
newData.zones[action.destinationZone],
|
697
|
+
action.destinationIndex,
|
698
|
+
item
|
699
|
+
)
|
700
|
+
})
|
701
|
+
});
|
702
|
+
}
|
703
|
+
if (action.destinationZone === rootDroppableId) {
|
704
|
+
return __spreadProps(__spreadValues({}, newData), {
|
705
|
+
content: insert(newData.content, action.destinationIndex, item),
|
706
|
+
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
707
|
+
[action.sourceZone]: remove(
|
708
|
+
newData.zones[action.sourceZone],
|
709
|
+
action.sourceIndex
|
710
|
+
)
|
711
|
+
})
|
712
|
+
});
|
713
|
+
}
|
714
|
+
return __spreadProps(__spreadValues({}, newData), {
|
715
|
+
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
716
|
+
[action.sourceZone]: remove(
|
717
|
+
newData.zones[action.sourceZone],
|
718
|
+
action.sourceIndex
|
719
|
+
),
|
720
|
+
[action.destinationZone]: insert(
|
721
|
+
newData.zones[action.destinationZone],
|
722
|
+
action.destinationIndex,
|
723
|
+
item
|
724
|
+
)
|
725
|
+
})
|
726
|
+
});
|
727
|
+
}
|
728
|
+
if (action.type === "replace") {
|
729
|
+
return replaceAction(data, action);
|
730
|
+
}
|
731
|
+
if (action.type === "remove") {
|
732
|
+
const item = getItem({ index: action.index, zone: action.zone }, data);
|
733
|
+
const dataWithRelatedRemoved = setupZone(
|
734
|
+
removeRelatedZones(item, data),
|
735
|
+
action.zone
|
736
|
+
);
|
737
|
+
if (action.zone === rootDroppableId) {
|
738
|
+
return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
|
739
|
+
content: remove(data.content, action.index)
|
740
|
+
});
|
741
|
+
}
|
742
|
+
return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
|
743
|
+
zones: __spreadProps(__spreadValues({}, dataWithRelatedRemoved.zones), {
|
744
|
+
[action.zone]: remove(
|
745
|
+
dataWithRelatedRemoved.zones[action.zone],
|
746
|
+
action.index
|
747
|
+
)
|
748
|
+
})
|
749
|
+
});
|
750
|
+
}
|
751
|
+
if (action.type === "registerZone") {
|
752
|
+
if (zoneCache[action.zone]) {
|
753
|
+
return __spreadProps(__spreadValues({}, data), {
|
754
|
+
zones: __spreadProps(__spreadValues({}, data.zones), {
|
755
|
+
[action.zone]: zoneCache[action.zone]
|
756
|
+
})
|
757
|
+
});
|
758
|
+
}
|
759
|
+
return setupZone(data, action.zone);
|
760
|
+
}
|
761
|
+
if (action.type === "unregisterZone") {
|
762
|
+
const _zones = __spreadValues({}, data.zones || {});
|
763
|
+
if (_zones[action.zone]) {
|
764
|
+
zoneCache[action.zone] = _zones[action.zone];
|
765
|
+
delete _zones[action.zone];
|
766
|
+
}
|
767
|
+
return __spreadProps(__spreadValues({}, data), { zones: _zones });
|
768
|
+
}
|
769
|
+
if (action.type === "setData") {
|
770
|
+
if (typeof action.data === "object") {
|
771
|
+
return __spreadValues(__spreadValues({}, data), action.data);
|
772
|
+
}
|
773
|
+
return __spreadValues(__spreadValues({}, data), action.data(data));
|
774
|
+
}
|
775
|
+
return data;
|
418
776
|
}
|
419
777
|
|
778
|
+
// ../core/reducer/state.ts
|
779
|
+
init_react_import();
|
780
|
+
var reduceUi = (ui, action) => {
|
781
|
+
if (action.type === "setUi") {
|
782
|
+
if (typeof action.ui === "object") {
|
783
|
+
return __spreadValues(__spreadValues({}, ui), action.ui);
|
784
|
+
}
|
785
|
+
return __spreadValues(__spreadValues({}, ui), action.ui(ui));
|
786
|
+
}
|
787
|
+
if (action.type === "duplicate") {
|
788
|
+
return __spreadProps(__spreadValues({}, ui), {
|
789
|
+
itemSelector: { index: action.sourceIndex + 1, zone: action.sourceZone }
|
790
|
+
});
|
791
|
+
}
|
792
|
+
if (action.type === "remove") {
|
793
|
+
return __spreadProps(__spreadValues({}, ui), {
|
794
|
+
itemSelector: null
|
795
|
+
});
|
796
|
+
}
|
797
|
+
return ui;
|
798
|
+
};
|
799
|
+
|
800
|
+
// ../core/reducer/actions.tsx
|
801
|
+
init_react_import();
|
802
|
+
|
803
|
+
// ../core/reducer/index.ts
|
804
|
+
function storeInterceptor(reducer, record, onAction) {
|
805
|
+
return (state, action) => {
|
806
|
+
const newAppState = reducer(state, action);
|
807
|
+
const isValidType = ![
|
808
|
+
"registerZone",
|
809
|
+
"unregisterZone",
|
810
|
+
"setData",
|
811
|
+
"setUi",
|
812
|
+
"set"
|
813
|
+
].includes(action.type);
|
814
|
+
if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
|
815
|
+
if (record) record(newAppState);
|
816
|
+
}
|
817
|
+
onAction == null ? void 0 : onAction(action, newAppState, state);
|
818
|
+
return newAppState;
|
819
|
+
};
|
820
|
+
}
|
821
|
+
var setAction = (state, action) => {
|
822
|
+
if (typeof action.state === "object") {
|
823
|
+
return __spreadValues(__spreadValues({}, state), action.state);
|
824
|
+
}
|
825
|
+
return __spreadValues(__spreadValues({}, state), action.state(state));
|
826
|
+
};
|
827
|
+
function createReducer({
|
828
|
+
config,
|
829
|
+
record,
|
830
|
+
onAction
|
831
|
+
}) {
|
832
|
+
return storeInterceptor(
|
833
|
+
(state, action) => {
|
834
|
+
const data = reduceData(state.data, action, config);
|
835
|
+
const ui = reduceUi(state.ui, action);
|
836
|
+
if (action.type === "set") {
|
837
|
+
return setAction(state, action);
|
838
|
+
}
|
839
|
+
return { data, ui };
|
840
|
+
},
|
841
|
+
record,
|
842
|
+
onAction
|
843
|
+
);
|
844
|
+
}
|
845
|
+
|
846
|
+
// ../core/components/ViewportControls/default-viewports.ts
|
847
|
+
init_react_import();
|
848
|
+
var defaultViewports = [
|
849
|
+
{ width: 360, height: "auto", icon: "Smartphone", label: "Small" },
|
850
|
+
{ width: 768, height: "auto", icon: "Tablet", label: "Medium" },
|
851
|
+
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
852
|
+
];
|
853
|
+
|
420
854
|
// ../../node_modules/zustand/esm/vanilla.mjs
|
421
855
|
init_react_import();
|
422
856
|
var createStoreImpl = (createState) => {
|
423
857
|
let state;
|
424
858
|
const listeners = /* @__PURE__ */ new Set();
|
425
|
-
const setState = (partial,
|
859
|
+
const setState = (partial, replace2) => {
|
426
860
|
const nextState = typeof partial === "function" ? partial(state) : partial;
|
427
861
|
if (!Object.is(nextState, state)) {
|
428
862
|
const previousState = state;
|
429
|
-
state = (
|
863
|
+
state = (replace2 != null ? replace2 : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
|
430
864
|
listeners.forEach((listener) => listener(state, previousState));
|
431
865
|
}
|
432
866
|
};
|
@@ -442,94 +876,701 @@ var createStoreImpl = (createState) => {
|
|
442
876
|
};
|
443
877
|
var createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
|
444
878
|
|
445
|
-
//
|
446
|
-
import { Fragment, jsx as jsx3 } from "react/jsx-runtime";
|
447
|
-
var dropZoneContext = createContext2(null);
|
448
|
-
var ZoneStoreContext = createContext2(
|
449
|
-
createStore(() => ({
|
450
|
-
zoneDepthIndex: {},
|
451
|
-
nextZoneDepthIndex: {},
|
452
|
-
areaDepthIndex: {},
|
453
|
-
nextAreaDepthIndex: {},
|
454
|
-
draggedItem: null,
|
455
|
-
previewIndex: {}
|
456
|
-
}))
|
457
|
-
);
|
458
|
-
|
459
|
-
// ../core/lib/get-zone-id.ts
|
879
|
+
// ../../node_modules/zustand/esm/react.mjs
|
460
880
|
init_react_import();
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
881
|
+
import React2 from "react";
|
882
|
+
var identity = (arg) => arg;
|
883
|
+
function useStore(api, selector = identity) {
|
884
|
+
const slice = React2.useSyncExternalStore(
|
885
|
+
api.subscribe,
|
886
|
+
() => selector(api.getState()),
|
887
|
+
() => selector(api.getInitialState())
|
888
|
+
);
|
889
|
+
React2.useDebugValue(slice);
|
890
|
+
return slice;
|
891
|
+
}
|
892
|
+
var createImpl = (createState) => {
|
893
|
+
const api = createStore(createState);
|
894
|
+
const useBoundStore = (selector) => useStore(api, selector);
|
895
|
+
Object.assign(useBoundStore, api);
|
896
|
+
return useBoundStore;
|
469
897
|
};
|
898
|
+
var create = (createState) => createState ? createImpl(createState) : createImpl;
|
470
899
|
|
471
|
-
//
|
472
|
-
|
473
|
-
|
474
|
-
const
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
{
|
483
|
-
|
484
|
-
|
900
|
+
// ../../node_modules/zustand/esm/middleware.mjs
|
901
|
+
init_react_import();
|
902
|
+
var subscribeWithSelectorImpl = (fn) => (set, get, api) => {
|
903
|
+
const origSubscribe = api.subscribe;
|
904
|
+
api.subscribe = (selector, optListener, options) => {
|
905
|
+
let listener = selector;
|
906
|
+
if (optListener) {
|
907
|
+
const equalityFn = (options == null ? void 0 : options.equalityFn) || Object.is;
|
908
|
+
let currentSlice = selector(api.getState());
|
909
|
+
listener = (state) => {
|
910
|
+
const nextSlice = selector(state);
|
911
|
+
if (!equalityFn(currentSlice, nextSlice)) {
|
912
|
+
const previousSlice = currentSlice;
|
913
|
+
optListener(currentSlice = nextSlice, previousSlice);
|
485
914
|
}
|
486
|
-
|
915
|
+
};
|
916
|
+
if (options == null ? void 0 : options.fireImmediately) {
|
917
|
+
optListener(currentSlice, currentSlice);
|
918
|
+
}
|
919
|
+
}
|
920
|
+
return origSubscribe(listener);
|
921
|
+
};
|
922
|
+
const initialState = fn(set, get, api);
|
923
|
+
return initialState;
|
924
|
+
};
|
925
|
+
var subscribeWithSelector = subscribeWithSelectorImpl;
|
926
|
+
|
927
|
+
// ../core/lib/resolve-data.ts
|
928
|
+
init_react_import();
|
929
|
+
|
930
|
+
// ../core/lib/resolve-component-data.ts
|
931
|
+
init_react_import();
|
932
|
+
|
933
|
+
// ../core/lib/get-changed.ts
|
934
|
+
init_react_import();
|
935
|
+
var getChanged = (newItem, oldItem) => {
|
936
|
+
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
937
|
+
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
938
|
+
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
939
|
+
return __spreadProps(__spreadValues({}, acc), {
|
940
|
+
[item]: oldItemProps[item] !== newItemProps[item]
|
941
|
+
});
|
942
|
+
}, {}) : {};
|
943
|
+
};
|
944
|
+
|
945
|
+
// ../core/lib/resolve-component-data.ts
|
946
|
+
var cache = { lastChange: {} };
|
947
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd) {
|
948
|
+
const configForItem = config.components[item.type];
|
949
|
+
if (configForItem.resolveData) {
|
950
|
+
const { item: oldItem = null, resolved = {} } = cache.lastChange[item.props.id] || {};
|
951
|
+
if (item && item === oldItem) {
|
952
|
+
return resolved;
|
487
953
|
}
|
488
|
-
const
|
489
|
-
|
490
|
-
|
491
|
-
parentZone = data.zones[parentZoneCompound];
|
954
|
+
const changed = getChanged(item, oldItem);
|
955
|
+
if (onResolveStart) {
|
956
|
+
onResolveStart(item);
|
492
957
|
}
|
493
|
-
|
494
|
-
|
958
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
959
|
+
changed,
|
960
|
+
lastData: oldItem,
|
961
|
+
metadata
|
962
|
+
});
|
963
|
+
const resolvedItem = __spreadProps(__spreadValues({}, item), {
|
964
|
+
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
965
|
+
});
|
966
|
+
if (Object.keys(readOnly).length) {
|
967
|
+
resolvedItem.readOnly = readOnly;
|
968
|
+
}
|
969
|
+
cache.lastChange[item.props.id] = {
|
970
|
+
item,
|
971
|
+
resolved: resolvedItem
|
972
|
+
};
|
973
|
+
if (onResolveEnd) {
|
974
|
+
onResolveEnd(resolvedItem);
|
495
975
|
}
|
496
|
-
|
497
|
-
|
976
|
+
return resolvedItem;
|
977
|
+
}
|
978
|
+
return item;
|
979
|
+
});
|
980
|
+
|
981
|
+
// ../core/lib/apply-dynamic-props.ts
|
982
|
+
init_react_import();
|
983
|
+
var applyDynamicProps = (data, dynamicProps, rootData) => {
|
984
|
+
return __spreadProps(__spreadValues({}, data), {
|
985
|
+
root: rootData ? __spreadValues(__spreadValues({}, data.root), rootData ? rootData : {}) : data.root,
|
986
|
+
content: data.content.map((item) => {
|
987
|
+
return dynamicProps[item.props.id] ? __spreadValues(__spreadValues({}, item), dynamicProps[item.props.id]) : item;
|
988
|
+
}),
|
989
|
+
zones: Object.keys(data.zones || {}).reduce((acc, zoneKey) => {
|
990
|
+
return __spreadProps(__spreadValues({}, acc), {
|
991
|
+
[zoneKey]: data.zones[zoneKey].map((item) => {
|
992
|
+
return dynamicProps[item.props.id] ? __spreadValues(__spreadValues({}, item), dynamicProps[item.props.id]) : item;
|
993
|
+
})
|
994
|
+
});
|
995
|
+
}, {})
|
996
|
+
});
|
997
|
+
};
|
998
|
+
|
999
|
+
// ../core/lib/resolve-root-data.ts
|
1000
|
+
init_react_import();
|
1001
|
+
var cache2 = {};
|
1002
|
+
function resolveRootData(data, config, metadata) {
|
1003
|
+
return __async(this, null, function* () {
|
1004
|
+
var _a, _b, _c, _d, _e;
|
1005
|
+
if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
|
1006
|
+
if (((_b = cache2.lastChange) == null ? void 0 : _b.original) === data.root) {
|
1007
|
+
return cache2.lastChange.resolved;
|
1008
|
+
}
|
1009
|
+
const changed = getChanged(data.root, (_c = cache2.lastChange) == null ? void 0 : _c.original);
|
1010
|
+
const rootWithProps = data.root;
|
1011
|
+
const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
|
1012
|
+
changed,
|
1013
|
+
lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {},
|
1014
|
+
metadata: metadata || {}
|
1015
|
+
});
|
1016
|
+
cache2.lastChange = {
|
1017
|
+
original: data.root,
|
1018
|
+
resolved: resolvedRoot
|
1019
|
+
};
|
1020
|
+
return __spreadProps(__spreadValues(__spreadValues({}, data.root), resolvedRoot), {
|
1021
|
+
props: __spreadValues(__spreadValues({}, data.root.props), resolvedRoot.props)
|
1022
|
+
});
|
1023
|
+
}
|
1024
|
+
return data.root;
|
1025
|
+
});
|
1026
|
+
}
|
1027
|
+
|
1028
|
+
// ../core/lib/flatten-data.ts
|
1029
|
+
init_react_import();
|
1030
|
+
var flattenData = (data) => {
|
1031
|
+
return Object.keys(data.zones || {}).reduce(
|
1032
|
+
(acc, zone) => [...acc, ...data.zones[zone]],
|
1033
|
+
data.content
|
1034
|
+
);
|
1035
|
+
};
|
1036
|
+
|
1037
|
+
// ../core/lib/resolve-data.ts
|
1038
|
+
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1039
|
+
var resolveData = (newAppState, appStoreData) => {
|
1040
|
+
const {
|
1041
|
+
state: appState,
|
1042
|
+
config,
|
1043
|
+
dispatch,
|
1044
|
+
resolveDataRuns,
|
1045
|
+
setComponentLoading,
|
1046
|
+
unsetComponentLoading,
|
1047
|
+
metadata,
|
1048
|
+
permissions
|
1049
|
+
} = appStoreData;
|
1050
|
+
const deferredSetStates = {};
|
1051
|
+
const _setComponentLoading = (id, loading, defer = 0) => {
|
1052
|
+
if (deferredSetStates[id]) {
|
1053
|
+
clearTimeout(deferredSetStates[id]);
|
1054
|
+
delete deferredSetStates[id];
|
1055
|
+
}
|
1056
|
+
deferredSetStates[id] = setTimeout(() => {
|
1057
|
+
if (loading) {
|
1058
|
+
setComponentLoading(id);
|
1059
|
+
} else {
|
1060
|
+
unsetComponentLoading(id);
|
1061
|
+
}
|
1062
|
+
delete deferredSetStates[id];
|
1063
|
+
}, defer);
|
1064
|
+
};
|
1065
|
+
const runResolvers = () => __async(void 0, null, function* () {
|
1066
|
+
const newData = newAppState.data;
|
1067
|
+
const flatContent = flattenData(newData).filter(
|
1068
|
+
(item) => {
|
1069
|
+
var _a;
|
1070
|
+
return !!((_a = config.components[item.type]) == null ? void 0 : _a.resolveData);
|
1071
|
+
}
|
498
1072
|
);
|
499
|
-
const
|
500
|
-
|
501
|
-
|
1073
|
+
const applyIfChange = (dynamicDataMap, dynamicRoot) => {
|
1074
|
+
const processed = applyDynamicProps(
|
1075
|
+
__spreadValues({}, appState.data),
|
1076
|
+
dynamicDataMap,
|
1077
|
+
dynamicRoot
|
1078
|
+
);
|
1079
|
+
const processedAppState = __spreadProps(__spreadValues({}, appState), { data: processed });
|
1080
|
+
const containsChanges = !(0, import_fast_deep_equal.default)(appState, processedAppState);
|
1081
|
+
if (containsChanges) {
|
1082
|
+
dispatch({
|
1083
|
+
type: "set",
|
1084
|
+
state: (prev) => __spreadProps(__spreadValues({}, prev), {
|
1085
|
+
data: applyDynamicProps(prev.data, dynamicDataMap, dynamicRoot),
|
1086
|
+
ui: resolveDataRuns > 0 ? __spreadValues(__spreadValues({}, prev.ui), newAppState.ui) : prev.ui
|
1087
|
+
}),
|
1088
|
+
recordHistory: resolveDataRuns > 0
|
1089
|
+
});
|
1090
|
+
}
|
1091
|
+
};
|
1092
|
+
const promises = [];
|
1093
|
+
promises.push(
|
1094
|
+
(() => __async(void 0, null, function* () {
|
1095
|
+
_setComponentLoading("puck-root", true, 50);
|
1096
|
+
const dynamicRoot = yield resolveRootData(newData, config, metadata);
|
1097
|
+
applyIfChange({}, dynamicRoot);
|
1098
|
+
_setComponentLoading("puck-root", false);
|
1099
|
+
}))()
|
1100
|
+
);
|
1101
|
+
flatContent.forEach((item) => {
|
1102
|
+
promises.push(
|
1103
|
+
(() => __async(void 0, null, function* () {
|
1104
|
+
permissions.resolvePermissions({ item }, true);
|
1105
|
+
const dynamicData = yield resolveComponentData(
|
1106
|
+
item,
|
1107
|
+
config,
|
1108
|
+
metadata,
|
1109
|
+
(item2) => {
|
1110
|
+
_setComponentLoading(item2.props.id, true, 50);
|
1111
|
+
},
|
1112
|
+
(item2) => {
|
1113
|
+
deferredSetStates[item2.props.id];
|
1114
|
+
_setComponentLoading(item2.props.id, false);
|
1115
|
+
}
|
1116
|
+
);
|
1117
|
+
const dynamicDataMap = { [item.props.id]: dynamicData };
|
1118
|
+
applyIfChange(dynamicDataMap);
|
1119
|
+
}))()
|
1120
|
+
);
|
1121
|
+
});
|
1122
|
+
yield Promise.all(promises);
|
1123
|
+
});
|
1124
|
+
return runResolvers();
|
1125
|
+
};
|
1126
|
+
|
1127
|
+
// ../core/store/index.ts
|
1128
|
+
import { createContext, useContext } from "react";
|
1129
|
+
|
1130
|
+
// ../core/store/slices/history.ts
|
1131
|
+
init_react_import();
|
1132
|
+
import { useEffect as useEffect2 } from "react";
|
1133
|
+
|
1134
|
+
// ../core/lib/use-hotkey.ts
|
1135
|
+
init_react_import();
|
1136
|
+
import { useEffect } from "react";
|
1137
|
+
var useHotkeyStore = create()(
|
1138
|
+
subscribeWithSelector((set) => ({
|
1139
|
+
held: {},
|
1140
|
+
hold: (key) => set((s) => s.held[key] ? s : { held: __spreadProps(__spreadValues({}, s.held), { [key]: true }) }),
|
1141
|
+
release: (key) => set((s) => s.held[key] ? { held: __spreadProps(__spreadValues({}, s.held), { [key]: false }) } : s),
|
1142
|
+
reset: (held = {}) => set(() => ({ held })),
|
1143
|
+
triggers: {}
|
1144
|
+
}))
|
1145
|
+
);
|
1146
|
+
|
1147
|
+
// ../core/store/slices/history.ts
|
1148
|
+
var EMPTY_HISTORY_INDEX = 0;
|
1149
|
+
function debounce(func, timeout = 300) {
|
1150
|
+
let timer;
|
1151
|
+
return (...args) => {
|
1152
|
+
clearTimeout(timer);
|
1153
|
+
timer = setTimeout(() => {
|
1154
|
+
func(...args);
|
1155
|
+
}, timeout);
|
1156
|
+
};
|
1157
|
+
}
|
1158
|
+
var tidyState = (state) => {
|
1159
|
+
return __spreadProps(__spreadValues({}, state), {
|
1160
|
+
ui: __spreadProps(__spreadValues({}, state.ui), {
|
1161
|
+
field: {
|
1162
|
+
focus: null
|
1163
|
+
}
|
1164
|
+
})
|
1165
|
+
});
|
1166
|
+
};
|
1167
|
+
var createHistorySlice = (set, get) => {
|
1168
|
+
const record = debounce((state) => {
|
1169
|
+
const { histories, index } = get().history;
|
1170
|
+
const history = {
|
1171
|
+
state,
|
1172
|
+
id: generateId("history")
|
1173
|
+
};
|
1174
|
+
const newHistories = [...histories.slice(0, index + 1), history];
|
1175
|
+
set({
|
1176
|
+
history: __spreadProps(__spreadValues({}, get().history), {
|
1177
|
+
histories: newHistories,
|
1178
|
+
index: newHistories.length - 1
|
1179
|
+
})
|
1180
|
+
});
|
1181
|
+
}, 250);
|
1182
|
+
return {
|
1183
|
+
initialAppState: {},
|
1184
|
+
index: EMPTY_HISTORY_INDEX,
|
1185
|
+
histories: [],
|
1186
|
+
hasPast: () => get().history.index > EMPTY_HISTORY_INDEX,
|
1187
|
+
hasFuture: () => get().history.index < get().history.histories.length - 1,
|
1188
|
+
prevHistory: () => {
|
1189
|
+
const { history } = get();
|
1190
|
+
return history.hasPast() ? history.histories[history.index - 1] : null;
|
1191
|
+
},
|
1192
|
+
nextHistory: () => {
|
1193
|
+
const s = get().history;
|
1194
|
+
return s.hasFuture() ? s.histories[s.index + 1] : null;
|
1195
|
+
},
|
1196
|
+
currentHistory: () => get().history.histories[get().history.index],
|
1197
|
+
back: () => {
|
1198
|
+
var _a;
|
1199
|
+
const { history, dispatch } = get();
|
1200
|
+
if (history.hasPast()) {
|
1201
|
+
const state = tidyState(
|
1202
|
+
((_a = history.prevHistory()) == null ? void 0 : _a.state) || history.initialAppState
|
1203
|
+
);
|
1204
|
+
dispatch({
|
1205
|
+
type: "set",
|
1206
|
+
state
|
1207
|
+
});
|
1208
|
+
set({ history: __spreadProps(__spreadValues({}, history), { index: history.index - 1 }) });
|
1209
|
+
}
|
1210
|
+
},
|
1211
|
+
forward: () => {
|
1212
|
+
var _a;
|
1213
|
+
const { history, dispatch } = get();
|
1214
|
+
if (history.hasFuture()) {
|
1215
|
+
const state = (_a = history.nextHistory()) == null ? void 0 : _a.state;
|
1216
|
+
dispatch({ type: "set", state: state ? tidyState(state) : {} });
|
1217
|
+
set({ history: __spreadProps(__spreadValues({}, history), { index: history.index + 1 }) });
|
1218
|
+
}
|
1219
|
+
},
|
1220
|
+
setHistories: (histories) => {
|
1221
|
+
var _a;
|
1222
|
+
const { dispatch, history } = get();
|
1223
|
+
dispatch({
|
1224
|
+
type: "set",
|
1225
|
+
state: ((_a = history.histories[history.histories.length - 1]) == null ? void 0 : _a.state) || history.initialAppState
|
1226
|
+
});
|
1227
|
+
set({ history: __spreadProps(__spreadValues({}, history), { histories, index: histories.length - 1 }) });
|
1228
|
+
},
|
1229
|
+
setHistoryIndex: (index) => {
|
1230
|
+
var _a;
|
1231
|
+
const { dispatch, history } = get();
|
1232
|
+
dispatch({
|
1233
|
+
type: "set",
|
1234
|
+
state: ((_a = history.histories[history.index]) == null ? void 0 : _a.state) || history.initialAppState
|
1235
|
+
});
|
1236
|
+
set({ history: __spreadProps(__spreadValues({}, history), { index }) });
|
1237
|
+
},
|
1238
|
+
record
|
1239
|
+
};
|
1240
|
+
};
|
1241
|
+
|
1242
|
+
// ../core/store/slices/nodes.ts
|
1243
|
+
init_react_import();
|
1244
|
+
var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
|
1245
|
+
import { useEffect as useEffect3 } from "react";
|
1246
|
+
var partialDeepEqual = (newItem, existingItem) => {
|
1247
|
+
const filteredExistingItem = Object.keys(newItem).reduce(
|
1248
|
+
(acc, key) => __spreadProps(__spreadValues({}, acc), { [key]: existingItem[key] }),
|
1249
|
+
{}
|
1250
|
+
);
|
1251
|
+
return (0, import_fast_deep_equal2.default)(newItem, filteredExistingItem);
|
1252
|
+
};
|
1253
|
+
var createNodesSlice = (set, get) => ({
|
1254
|
+
nodes: {},
|
1255
|
+
registerNode: (id, node) => {
|
1256
|
+
const s = get().nodes;
|
1257
|
+
if (s.nodes[id] && partialDeepEqual(node, s.nodes[id])) {
|
1258
|
+
return;
|
502
1259
|
}
|
503
|
-
|
504
|
-
|
505
|
-
{
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
1260
|
+
const emptyNode = {
|
1261
|
+
id,
|
1262
|
+
methods: { sync: () => null },
|
1263
|
+
data: { props: { id }, type: "unknown" },
|
1264
|
+
parentId: "",
|
1265
|
+
zone: "",
|
1266
|
+
path: [],
|
1267
|
+
element: null,
|
1268
|
+
index: -1
|
1269
|
+
};
|
1270
|
+
const existingNode = s.nodes[id];
|
1271
|
+
set({
|
1272
|
+
nodes: __spreadProps(__spreadValues({}, s), {
|
1273
|
+
nodes: __spreadProps(__spreadValues({}, s.nodes), {
|
1274
|
+
[id]: __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, emptyNode), existingNode), node), {
|
1275
|
+
id
|
1276
|
+
})
|
1277
|
+
})
|
1278
|
+
})
|
1279
|
+
});
|
1280
|
+
},
|
1281
|
+
unregisterNode: (id) => {
|
1282
|
+
const s = get().nodes;
|
1283
|
+
const existingNode = s.nodes[id];
|
1284
|
+
if (existingNode) {
|
1285
|
+
const newNodes = __spreadValues({}, s.nodes);
|
1286
|
+
delete newNodes[id];
|
1287
|
+
set({
|
1288
|
+
nodes: __spreadProps(__spreadValues({}, s), {
|
1289
|
+
nodes: newNodes
|
1290
|
+
})
|
1291
|
+
});
|
1292
|
+
}
|
1293
|
+
}
|
1294
|
+
});
|
1295
|
+
|
1296
|
+
// ../core/store/slices/permissions.ts
|
1297
|
+
init_react_import();
|
1298
|
+
import { useEffect as useEffect4 } from "react";
|
1299
|
+
var createPermissionsSlice = (set, get) => {
|
1300
|
+
const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
|
1301
|
+
const { state, permissions } = get();
|
1302
|
+
const { cache: cache3, globalPermissions } = permissions;
|
1303
|
+
const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
|
1304
|
+
var _a, _b, _c;
|
1305
|
+
const {
|
1306
|
+
config,
|
1307
|
+
state: appState,
|
1308
|
+
setComponentLoading,
|
1309
|
+
unsetComponentLoading
|
1310
|
+
} = get();
|
1311
|
+
const componentConfig = item2.type === "root" ? config.root : config.components[item2.type];
|
1312
|
+
if (!componentConfig) {
|
1313
|
+
return;
|
1314
|
+
}
|
1315
|
+
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
1316
|
+
if (componentConfig.resolvePermissions) {
|
1317
|
+
const changed = getChanged(item2, (_a = cache3[item2.props.id]) == null ? void 0 : _a.lastData);
|
1318
|
+
if (Object.values(changed).some((el) => el === true) || force2) {
|
1319
|
+
setComponentLoading(item2.props.id);
|
1320
|
+
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
1321
|
+
item2,
|
1322
|
+
{
|
1323
|
+
changed,
|
1324
|
+
lastPermissions: ((_b = cache3[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
|
1325
|
+
permissions: initialPermissions,
|
1326
|
+
appState,
|
1327
|
+
lastData: ((_c = cache3[item2.props.id]) == null ? void 0 : _c.lastData) || null
|
1328
|
+
}
|
1329
|
+
);
|
1330
|
+
const latest = get().permissions;
|
1331
|
+
set({
|
1332
|
+
permissions: __spreadProps(__spreadValues({}, latest), {
|
1333
|
+
cache: __spreadProps(__spreadValues({}, latest.cache), {
|
1334
|
+
[item2.props.id]: {
|
1335
|
+
lastData: item2,
|
1336
|
+
lastPermissions: resolvedPermissions
|
1337
|
+
}
|
1338
|
+
}),
|
1339
|
+
resolvedPermissions: __spreadProps(__spreadValues({}, latest.resolvedPermissions), {
|
1340
|
+
[item2.props.id]: resolvedPermissions
|
1341
|
+
})
|
1342
|
+
})
|
1343
|
+
});
|
1344
|
+
unsetComponentLoading(item2.props.id);
|
1345
|
+
}
|
1346
|
+
}
|
1347
|
+
});
|
1348
|
+
const resolveDataForRoot = (force2 = false) => {
|
1349
|
+
const { state: appState } = get();
|
1350
|
+
resolveDataForItem(
|
1351
|
+
// Shim the root data in by conforming to component data shape
|
1352
|
+
{
|
1353
|
+
type: "root",
|
1354
|
+
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "puck-root" })
|
510
1355
|
},
|
511
|
-
|
1356
|
+
force2
|
1357
|
+
);
|
1358
|
+
};
|
1359
|
+
const { item, type, root } = params;
|
1360
|
+
if (item) {
|
1361
|
+
yield resolveDataForItem(item, force);
|
1362
|
+
} else if (type) {
|
1363
|
+
flattenData(state.data).filter((item2) => item2.type === type).map((item2) => __async(void 0, null, function* () {
|
1364
|
+
yield resolveDataForItem(item2, force);
|
1365
|
+
}));
|
1366
|
+
} else if (root) {
|
1367
|
+
resolveDataForRoot(force);
|
1368
|
+
} else {
|
1369
|
+
resolveDataForRoot(force);
|
1370
|
+
flattenData(state.data).map((item2) => __async(void 0, null, function* () {
|
1371
|
+
yield resolveDataForItem(item2, force);
|
1372
|
+
}));
|
1373
|
+
}
|
1374
|
+
});
|
1375
|
+
const refreshPermissions = (params) => resolvePermissions(params, true);
|
1376
|
+
return {
|
1377
|
+
cache: {},
|
1378
|
+
globalPermissions: {
|
1379
|
+
drag: true,
|
1380
|
+
edit: true,
|
1381
|
+
delete: true,
|
1382
|
+
duplicate: true,
|
1383
|
+
insert: true
|
1384
|
+
},
|
1385
|
+
resolvedPermissions: {},
|
1386
|
+
getPermissions: ({ item, type, root } = {}) => {
|
1387
|
+
const { config, permissions } = get();
|
1388
|
+
const { globalPermissions, resolvedPermissions } = permissions;
|
1389
|
+
if (item) {
|
1390
|
+
const componentConfig = config.components[item.type];
|
1391
|
+
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
|
1392
|
+
const resolvedForItem = resolvedPermissions[item.props.id];
|
1393
|
+
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
1394
|
+
} else if (type) {
|
1395
|
+
const componentConfig = config.components[type];
|
1396
|
+
return __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
|
1397
|
+
} else if (root) {
|
1398
|
+
const rootConfig = config.root;
|
1399
|
+
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
|
1400
|
+
const resolvedForItem = resolvedPermissions["puck-root"];
|
1401
|
+
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
512
1402
|
}
|
513
|
-
|
514
|
-
|
1403
|
+
return globalPermissions;
|
1404
|
+
},
|
1405
|
+
resolvePermissions,
|
1406
|
+
refreshPermissions
|
1407
|
+
};
|
1408
|
+
};
|
1409
|
+
|
1410
|
+
// ../core/store/slices/fields.ts
|
1411
|
+
init_react_import();
|
1412
|
+
import { useCallback, useEffect as useEffect5 } from "react";
|
1413
|
+
var createFieldsStore = (_set, _get) => {
|
1414
|
+
return {
|
1415
|
+
fields: {},
|
1416
|
+
loading: false,
|
1417
|
+
lastResolvedData: {}
|
1418
|
+
};
|
515
1419
|
};
|
1420
|
+
|
1421
|
+
// ../core/store/index.ts
|
1422
|
+
var defaultAppState = {
|
1423
|
+
data: { content: [], root: {}, zones: {} },
|
1424
|
+
ui: {
|
1425
|
+
leftSideBarVisible: true,
|
1426
|
+
rightSideBarVisible: true,
|
1427
|
+
arrayState: {},
|
1428
|
+
itemSelector: null,
|
1429
|
+
componentList: {},
|
1430
|
+
isDragging: false,
|
1431
|
+
previewMode: "edit",
|
1432
|
+
viewports: {
|
1433
|
+
current: {
|
1434
|
+
width: defaultViewports[0].width,
|
1435
|
+
height: defaultViewports[0].height || "auto"
|
1436
|
+
},
|
1437
|
+
options: [],
|
1438
|
+
controlsVisible: true
|
1439
|
+
},
|
1440
|
+
field: { focus: null }
|
1441
|
+
}
|
1442
|
+
};
|
1443
|
+
var defaultPageFields = {
|
1444
|
+
title: { type: "text" }
|
1445
|
+
};
|
1446
|
+
var createAppStore = (initialAppStore) => create()(
|
1447
|
+
subscribeWithSelector((set, get) => __spreadProps(__spreadValues({
|
1448
|
+
state: defaultAppState,
|
1449
|
+
config: { components: {} },
|
1450
|
+
componentState: {},
|
1451
|
+
plugins: [],
|
1452
|
+
overrides: {},
|
1453
|
+
viewports: defaultViewports,
|
1454
|
+
zoomConfig: {
|
1455
|
+
autoZoom: 1,
|
1456
|
+
rootHeight: 0,
|
1457
|
+
zoom: 1
|
1458
|
+
},
|
1459
|
+
status: "LOADING",
|
1460
|
+
iframe: {},
|
1461
|
+
metadata: {}
|
1462
|
+
}, initialAppStore), {
|
1463
|
+
fields: createFieldsStore(set, get),
|
1464
|
+
history: createHistorySlice(set, get),
|
1465
|
+
nodes: createNodesSlice(set, get),
|
1466
|
+
permissions: createPermissionsSlice(set, get),
|
1467
|
+
getComponentConfig: (type) => {
|
1468
|
+
var _a;
|
1469
|
+
const { config, selectedItem } = get();
|
1470
|
+
const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
|
1471
|
+
return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
|
1472
|
+
},
|
1473
|
+
dispatch: (action) => set((s) => {
|
1474
|
+
var _a, _b;
|
1475
|
+
const { record } = get().history;
|
1476
|
+
const dispatch = createReducer({ config: s.config, record });
|
1477
|
+
const state = dispatch(s.state, action);
|
1478
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state.data) : null;
|
1479
|
+
(_b = (_a = get()).onAction) == null ? void 0 : _b.call(_a, action, state, get().state);
|
1480
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1481
|
+
}),
|
1482
|
+
setZoomConfig: (zoomConfig) => set({ zoomConfig }),
|
1483
|
+
setStatus: (status) => set({ status }),
|
1484
|
+
setComponentState: (componentState) => set({ componentState }),
|
1485
|
+
setComponentLoading: (id) => {
|
1486
|
+
var _a;
|
1487
|
+
const { setComponentState, componentState } = get();
|
1488
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1489
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1490
|
+
loadingCount: (((_a = componentState[id]) == null ? void 0 : _a.loadingCount) || 0) + 1
|
1491
|
+
})
|
1492
|
+
}));
|
1493
|
+
},
|
1494
|
+
unsetComponentLoading: (id) => {
|
1495
|
+
var _a;
|
1496
|
+
const { setComponentState, componentState } = get();
|
1497
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1498
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1499
|
+
loadingCount: Math.max(
|
1500
|
+
(((_a = componentState[id]) == null ? void 0 : _a.loadingCount) || 0) - 1,
|
1501
|
+
0
|
1502
|
+
)
|
1503
|
+
})
|
1504
|
+
}));
|
1505
|
+
},
|
1506
|
+
// Helper
|
1507
|
+
setUi: (ui, recordHistory) => set((s) => {
|
1508
|
+
const dispatch = createReducer({
|
1509
|
+
config: s.config,
|
1510
|
+
record: () => {
|
1511
|
+
}
|
1512
|
+
});
|
1513
|
+
const state = dispatch(s.state, {
|
1514
|
+
type: "setUi",
|
1515
|
+
ui,
|
1516
|
+
recordHistory
|
1517
|
+
});
|
1518
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state.data) : null;
|
1519
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1520
|
+
}),
|
1521
|
+
resolveDataRuns: 0,
|
1522
|
+
resolveData: (newAppState) => set((s) => {
|
1523
|
+
resolveData(newAppState, get());
|
1524
|
+
return __spreadProps(__spreadValues({}, s), { resolveDataRuns: s.resolveDataRuns + 1 });
|
1525
|
+
})
|
1526
|
+
}))
|
1527
|
+
);
|
1528
|
+
var appStoreContext = createContext(createAppStore());
|
1529
|
+
function useAppStore(selector) {
|
1530
|
+
const context = useContext(appStoreContext);
|
1531
|
+
return useStore(context, selector);
|
1532
|
+
}
|
1533
|
+
function useAppStoreApi() {
|
1534
|
+
return useContext(appStoreContext);
|
1535
|
+
}
|
1536
|
+
|
1537
|
+
// ../core/lib/use-breadcrumbs.ts
|
516
1538
|
var useBreadcrumbs = (renderCount) => {
|
517
|
-
const {
|
518
|
-
|
519
|
-
selectedItem
|
520
|
-
}
|
521
|
-
const
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
1539
|
+
const selectedId = useAppStore((s) => {
|
1540
|
+
var _a;
|
1541
|
+
return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
|
1542
|
+
});
|
1543
|
+
const config = useAppStore((s) => s.config);
|
1544
|
+
const path = useAppStore((s) => {
|
1545
|
+
var _a;
|
1546
|
+
return (_a = s.nodes.nodes[selectedId]) == null ? void 0 : _a.path;
|
1547
|
+
});
|
1548
|
+
const appStore = useAppStoreApi();
|
1549
|
+
return useMemo(() => {
|
1550
|
+
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
1551
|
+
var _a, _b;
|
1552
|
+
const [componentId] = zoneCompound.split(":");
|
1553
|
+
if (componentId === "root") {
|
1554
|
+
return {
|
1555
|
+
label: "Page",
|
1556
|
+
selector: null
|
1557
|
+
};
|
1558
|
+
}
|
1559
|
+
const node = appStore.getState().nodes.nodes[componentId];
|
1560
|
+
const label = node ? (_b = (_a = config.components[node.data.type]) == null ? void 0 : _a.label) != null ? _b : node.data.type : "Component";
|
1561
|
+
return {
|
1562
|
+
label,
|
1563
|
+
selector: node ? {
|
1564
|
+
index: node.index,
|
1565
|
+
zone: node.path[node.path.length - 1]
|
1566
|
+
} : null
|
1567
|
+
};
|
1568
|
+
})) || [];
|
528
1569
|
if (renderCount) {
|
529
1570
|
return breadcrumbs.slice(breadcrumbs.length - renderCount);
|
530
1571
|
}
|
531
1572
|
return breadcrumbs;
|
532
|
-
}, [
|
1573
|
+
}, [path, renderCount]);
|
533
1574
|
};
|
534
1575
|
|
535
1576
|
// ../core/components/Loader/index.tsx
|
@@ -541,18 +1582,12 @@ init_react_import();
|
|
541
1582
|
// ../core/lib/filter.ts
|
542
1583
|
init_react_import();
|
543
1584
|
|
544
|
-
// ../core/lib/reorder.ts
|
545
|
-
init_react_import();
|
546
|
-
|
547
|
-
// ../core/lib/replace.ts
|
548
|
-
init_react_import();
|
549
|
-
|
550
1585
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
|
551
1586
|
init_react_import();
|
552
1587
|
var styles_module_default3 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
|
553
1588
|
|
554
1589
|
// ../core/components/Loader/index.tsx
|
555
|
-
import { jsx as
|
1590
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
556
1591
|
var getClassName2 = get_class_name_factory_default("Loader", styles_module_default3);
|
557
1592
|
var Loader = (_a) => {
|
558
1593
|
var _b = _a, {
|
@@ -562,7 +1597,7 @@ var Loader = (_a) => {
|
|
562
1597
|
"color",
|
563
1598
|
"size"
|
564
1599
|
]);
|
565
|
-
return /* @__PURE__ */
|
1600
|
+
return /* @__PURE__ */ jsx2(
|
566
1601
|
"span",
|
567
1602
|
__spreadValues({
|
568
1603
|
className: getClassName2(),
|
@@ -577,7 +1612,7 @@ var Loader = (_a) => {
|
|
577
1612
|
};
|
578
1613
|
|
579
1614
|
// ../core/components/SidebarSection/index.tsx
|
580
|
-
import { jsx as
|
1615
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
581
1616
|
var getClassName3 = get_class_name_factory_default("SidebarSection", styles_module_default);
|
582
1617
|
var SidebarSection = ({
|
583
1618
|
children,
|
@@ -588,7 +1623,7 @@ var SidebarSection = ({
|
|
588
1623
|
noPadding,
|
589
1624
|
isLoading
|
590
1625
|
}) => {
|
591
|
-
const
|
1626
|
+
const setUi = useAppStore((s) => s.setUi);
|
592
1627
|
const breadcrumbs = useBreadcrumbs(1);
|
593
1628
|
return /* @__PURE__ */ jsxs(
|
594
1629
|
"div",
|
@@ -596,9 +1631,9 @@ var SidebarSection = ({
|
|
596
1631
|
className: getClassName3({ noBorderTop, noPadding }),
|
597
1632
|
style: { background },
|
598
1633
|
children: [
|
599
|
-
/* @__PURE__ */
|
1634
|
+
/* @__PURE__ */ jsx3("div", { className: getClassName3("title"), children: /* @__PURE__ */ jsxs("div", { className: getClassName3("breadcrumbs"), children: [
|
600
1635
|
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs("div", { className: getClassName3("breadcrumb"), children: [
|
601
|
-
/* @__PURE__ */
|
1636
|
+
/* @__PURE__ */ jsx3(
|
602
1637
|
"button",
|
603
1638
|
{
|
604
1639
|
type: "button",
|
@@ -607,12 +1642,12 @@ var SidebarSection = ({
|
|
607
1642
|
children: breadcrumb.label
|
608
1643
|
}
|
609
1644
|
),
|
610
|
-
/* @__PURE__ */
|
1645
|
+
/* @__PURE__ */ jsx3(ChevronRight, { size: 16 })
|
611
1646
|
] }, i)) : null,
|
612
|
-
/* @__PURE__ */
|
1647
|
+
/* @__PURE__ */ jsx3("div", { className: getClassName3("heading"), children: /* @__PURE__ */ jsx3(Heading, { rank: "2", size: "xs", children: title }) })
|
613
1648
|
] }) }),
|
614
|
-
/* @__PURE__ */
|
615
|
-
isLoading && /* @__PURE__ */
|
1649
|
+
/* @__PURE__ */ jsx3("div", { className: getClassName3("content"), children }),
|
1650
|
+
isLoading && /* @__PURE__ */ jsx3("div", { className: getClassName3("loadingOverlay"), children: /* @__PURE__ */ jsx3(Loader, { size: 32 }) })
|
616
1651
|
]
|
617
1652
|
}
|
618
1653
|
);
|
@@ -626,18 +1661,18 @@ init_react_import();
|
|
626
1661
|
var styles_module_default4 = { "OutlineList": "_OutlineList_w4lzv_1", "OutlineListItem": "_OutlineListItem_w4lzv_25", "OutlineListItem--clickable": "_OutlineListItem--clickable_w4lzv_45" };
|
627
1662
|
|
628
1663
|
// ../core/components/OutlineList/index.tsx
|
629
|
-
import { jsx as
|
1664
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
630
1665
|
var getClassName4 = get_class_name_factory_default("OutlineList", styles_module_default4);
|
631
1666
|
var getClassNameItem = get_class_name_factory_default("OutlineListItem", styles_module_default4);
|
632
1667
|
var OutlineList = ({ children }) => {
|
633
|
-
return /* @__PURE__ */
|
1668
|
+
return /* @__PURE__ */ jsx4("ul", { className: getClassName4(), children });
|
634
1669
|
};
|
635
|
-
OutlineList.Clickable = ({ children }) => /* @__PURE__ */
|
1670
|
+
OutlineList.Clickable = ({ children }) => /* @__PURE__ */ jsx4("div", { className: getClassNameItem({ clickable: true }), children });
|
636
1671
|
OutlineList.Item = ({
|
637
1672
|
children,
|
638
1673
|
onClick
|
639
1674
|
}) => {
|
640
|
-
return /* @__PURE__ */
|
1675
|
+
return /* @__PURE__ */ jsx4(
|
641
1676
|
"li",
|
642
1677
|
{
|
643
1678
|
className: getClassNameItem({ clickable: !!onClick }),
|
@@ -671,7 +1706,7 @@ var getFrame = () => {
|
|
671
1706
|
|
672
1707
|
// src/HeadingAnalyzer.tsx
|
673
1708
|
import ReactFromJSONModule from "react-from-json";
|
674
|
-
import { Fragment
|
1709
|
+
import { Fragment, jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
675
1710
|
var getClassName5 = get_class_name_factory_default("HeadingAnalyzer", HeadingAnalyzer_module_default);
|
676
1711
|
var getClassNameItem2 = get_class_name_factory_default("HeadingAnalyzerItem", HeadingAnalyzer_module_default);
|
677
1712
|
var ReactFromJSON = ReactFromJSONModule.default || ReactFromJSONModule;
|
@@ -679,6 +1714,9 @@ var getOutline = ({ frame } = {}) => {
|
|
679
1714
|
const headings = (frame == null ? void 0 : frame.querySelectorAll("h1,h2,h3,h4,h5,h6")) || [];
|
680
1715
|
const _outline = [];
|
681
1716
|
headings.forEach((item, i) => {
|
1717
|
+
if (item.closest("[data-dnd-dragging]")) {
|
1718
|
+
return;
|
1719
|
+
}
|
682
1720
|
_outline.push({
|
683
1721
|
rank: parseInt(item.tagName.split("H")[1]),
|
684
1722
|
text: item.textContent,
|
@@ -721,10 +1759,11 @@ function buildHierarchy(frame) {
|
|
721
1759
|
}
|
722
1760
|
return root.children;
|
723
1761
|
}
|
1762
|
+
var usePuck = createUsePuck();
|
724
1763
|
var HeadingAnalyzer = () => {
|
725
|
-
const
|
726
|
-
const [hierarchy, setHierarchy] =
|
727
|
-
|
1764
|
+
const data = usePuck((s) => s.appState.data);
|
1765
|
+
const [hierarchy, setHierarchy] = useState([]);
|
1766
|
+
useEffect6(() => {
|
728
1767
|
const frame = getFrame();
|
729
1768
|
const entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
730
1769
|
if (!entry) return;
|
@@ -736,7 +1775,7 @@ var HeadingAnalyzer = () => {
|
|
736
1775
|
return () => {
|
737
1776
|
observer.disconnect();
|
738
1777
|
};
|
739
|
-
}, [
|
1778
|
+
}, [data]);
|
740
1779
|
return /* @__PURE__ */ jsxs2("div", { className: getClassName5(), children: [
|
741
1780
|
/* @__PURE__ */ jsxs2(
|
742
1781
|
"small",
|
@@ -750,19 +1789,19 @@ var HeadingAnalyzer = () => {
|
|
750
1789
|
children: [
|
751
1790
|
"Heading analyzer styles not loaded. Please review the",
|
752
1791
|
" ",
|
753
|
-
/* @__PURE__ */
|
1792
|
+
/* @__PURE__ */ jsx5("a", { href: "https://github.com/measuredco/puck/blob/main/packages/plugin-heading-analyzer/README.md", children: "README" }),
|
754
1793
|
"."
|
755
1794
|
]
|
756
1795
|
}
|
757
1796
|
),
|
758
|
-
hierarchy.length === 0 && /* @__PURE__ */
|
759
|
-
/* @__PURE__ */
|
1797
|
+
hierarchy.length === 0 && /* @__PURE__ */ jsx5("div", { children: "No headings." }),
|
1798
|
+
/* @__PURE__ */ jsx5(OutlineList, { children: /* @__PURE__ */ jsx5(
|
760
1799
|
ReactFromJSON,
|
761
1800
|
{
|
762
1801
|
mapping: {
|
763
|
-
Root: (props) => /* @__PURE__ */
|
1802
|
+
Root: (props) => /* @__PURE__ */ jsx5(Fragment, { children: props.children }),
|
764
1803
|
OutlineListItem: (props) => /* @__PURE__ */ jsxs2(OutlineList.Item, { children: [
|
765
|
-
/* @__PURE__ */
|
1804
|
+
/* @__PURE__ */ jsx5(OutlineList.Clickable, { children: /* @__PURE__ */ jsx5(
|
766
1805
|
"small",
|
767
1806
|
{
|
768
1807
|
className: getClassNameItem2({ missing: props.missing }),
|
@@ -780,13 +1819,13 @@ var HeadingAnalyzer = () => {
|
|
780
1819
|
}, 2e3);
|
781
1820
|
}
|
782
1821
|
},
|
783
|
-
children: props.missing ? /* @__PURE__ */ jsxs2(
|
1822
|
+
children: props.missing ? /* @__PURE__ */ jsxs2(Fragment, { children: [
|
784
1823
|
/* @__PURE__ */ jsxs2("b", { children: [
|
785
1824
|
"H",
|
786
1825
|
props.rank
|
787
1826
|
] }),
|
788
1827
|
": Missing"
|
789
|
-
] }) : /* @__PURE__ */ jsxs2(
|
1828
|
+
] }) : /* @__PURE__ */ jsxs2(Fragment, { children: [
|
790
1829
|
/* @__PURE__ */ jsxs2("b", { children: [
|
791
1830
|
"H",
|
792
1831
|
props.rank
|
@@ -796,7 +1835,7 @@ var HeadingAnalyzer = () => {
|
|
796
1835
|
] })
|
797
1836
|
}
|
798
1837
|
) }),
|
799
|
-
/* @__PURE__ */
|
1838
|
+
/* @__PURE__ */ jsx5(OutlineList, { children: props.children })
|
800
1839
|
] })
|
801
1840
|
},
|
802
1841
|
entry: {
|
@@ -818,9 +1857,9 @@ var HeadingAnalyzer = () => {
|
|
818
1857
|
};
|
819
1858
|
var headingAnalyzer = {
|
820
1859
|
overrides: {
|
821
|
-
fields: ({ children, itemSelector }) => /* @__PURE__ */ jsxs2(
|
1860
|
+
fields: ({ children, itemSelector }) => /* @__PURE__ */ jsxs2(Fragment, { children: [
|
822
1861
|
children,
|
823
|
-
/* @__PURE__ */
|
1862
|
+
/* @__PURE__ */ jsx5("div", { style: { display: itemSelector ? "none" : "block" }, children: /* @__PURE__ */ jsx5(SidebarSection, { title: "Heading Outline", children: /* @__PURE__ */ jsx5(HeadingAnalyzer, {}) }) })
|
824
1863
|
] })
|
825
1864
|
}
|
826
1865
|
};
|