@measured/puck-plugin-heading-analyzer 0.20.0-canary.755737e8 → 0.20.0-canary.93d525c5
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.css +145 -0
- package/dist/index.d.mts +13 -31
- package/dist/index.d.ts +13 -31
- package/dist/index.js +2286 -203
- package/dist/index.mjs +2287 -204
- 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,12 +146,162 @@ var require_classnames = __commonJS({
|
|
126
146
|
}
|
127
147
|
});
|
128
148
|
|
149
|
+
// ../../node_modules/flat/index.js
|
150
|
+
var require_flat = __commonJS({
|
151
|
+
"../../node_modules/flat/index.js"(exports, module) {
|
152
|
+
"use strict";
|
153
|
+
init_react_import();
|
154
|
+
module.exports = flatten3;
|
155
|
+
flatten3.flatten = flatten3;
|
156
|
+
flatten3.unflatten = unflatten2;
|
157
|
+
function isBuffer(obj) {
|
158
|
+
return obj && obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
|
159
|
+
}
|
160
|
+
function keyIdentity(key) {
|
161
|
+
return key;
|
162
|
+
}
|
163
|
+
function flatten3(target, opts) {
|
164
|
+
opts = opts || {};
|
165
|
+
const delimiter = opts.delimiter || ".";
|
166
|
+
const maxDepth = opts.maxDepth;
|
167
|
+
const transformKey = opts.transformKey || keyIdentity;
|
168
|
+
const output = {};
|
169
|
+
function step(object, prev, currentDepth) {
|
170
|
+
currentDepth = currentDepth || 1;
|
171
|
+
Object.keys(object).forEach(function(key) {
|
172
|
+
const value = object[key];
|
173
|
+
const isarray = opts.safe && Array.isArray(value);
|
174
|
+
const type = Object.prototype.toString.call(value);
|
175
|
+
const isbuffer = isBuffer(value);
|
176
|
+
const isobject = type === "[object Object]" || type === "[object Array]";
|
177
|
+
const newKey = prev ? prev + delimiter + transformKey(key) : transformKey(key);
|
178
|
+
if (!isarray && !isbuffer && isobject && Object.keys(value).length && (!opts.maxDepth || currentDepth < maxDepth)) {
|
179
|
+
return step(value, newKey, currentDepth + 1);
|
180
|
+
}
|
181
|
+
output[newKey] = value;
|
182
|
+
});
|
183
|
+
}
|
184
|
+
step(target);
|
185
|
+
return output;
|
186
|
+
}
|
187
|
+
function unflatten2(target, opts) {
|
188
|
+
opts = opts || {};
|
189
|
+
const delimiter = opts.delimiter || ".";
|
190
|
+
const overwrite = opts.overwrite || false;
|
191
|
+
const transformKey = opts.transformKey || keyIdentity;
|
192
|
+
const result = {};
|
193
|
+
const isbuffer = isBuffer(target);
|
194
|
+
if (isbuffer || Object.prototype.toString.call(target) !== "[object Object]") {
|
195
|
+
return target;
|
196
|
+
}
|
197
|
+
function getkey(key) {
|
198
|
+
const parsedKey = Number(key);
|
199
|
+
return isNaN(parsedKey) || key.indexOf(".") !== -1 || opts.object ? key : parsedKey;
|
200
|
+
}
|
201
|
+
function addKeys(keyPrefix, recipient, target2) {
|
202
|
+
return Object.keys(target2).reduce(function(result2, key) {
|
203
|
+
result2[keyPrefix + delimiter + key] = target2[key];
|
204
|
+
return result2;
|
205
|
+
}, recipient);
|
206
|
+
}
|
207
|
+
function isEmpty(val) {
|
208
|
+
const type = Object.prototype.toString.call(val);
|
209
|
+
const isArray = type === "[object Array]";
|
210
|
+
const isObject = type === "[object Object]";
|
211
|
+
if (!val) {
|
212
|
+
return true;
|
213
|
+
} else if (isArray) {
|
214
|
+
return !val.length;
|
215
|
+
} else if (isObject) {
|
216
|
+
return !Object.keys(val).length;
|
217
|
+
}
|
218
|
+
}
|
219
|
+
target = Object.keys(target).reduce(function(result2, key) {
|
220
|
+
const type = Object.prototype.toString.call(target[key]);
|
221
|
+
const isObject = type === "[object Object]" || type === "[object Array]";
|
222
|
+
if (!isObject || isEmpty(target[key])) {
|
223
|
+
result2[key] = target[key];
|
224
|
+
return result2;
|
225
|
+
} else {
|
226
|
+
return addKeys(
|
227
|
+
key,
|
228
|
+
result2,
|
229
|
+
flatten3(target[key], opts)
|
230
|
+
);
|
231
|
+
}
|
232
|
+
}, {});
|
233
|
+
Object.keys(target).forEach(function(key) {
|
234
|
+
const split = key.split(delimiter).map(transformKey);
|
235
|
+
let key1 = getkey(split.shift());
|
236
|
+
let key2 = getkey(split[0]);
|
237
|
+
let recipient = result;
|
238
|
+
while (key2 !== void 0) {
|
239
|
+
if (key1 === "__proto__") {
|
240
|
+
return;
|
241
|
+
}
|
242
|
+
const type = Object.prototype.toString.call(recipient[key1]);
|
243
|
+
const isobject = type === "[object Object]" || type === "[object Array]";
|
244
|
+
if (!overwrite && !isobject && typeof recipient[key1] !== "undefined") {
|
245
|
+
return;
|
246
|
+
}
|
247
|
+
if (overwrite && !isobject || !overwrite && recipient[key1] == null) {
|
248
|
+
recipient[key1] = typeof key2 === "number" && !opts.object ? [] : {};
|
249
|
+
}
|
250
|
+
recipient = recipient[key1];
|
251
|
+
if (split.length > 0) {
|
252
|
+
key1 = getkey(split.shift());
|
253
|
+
key2 = getkey(split[0]);
|
254
|
+
}
|
255
|
+
}
|
256
|
+
recipient[key1] = unflatten2(target[key], opts);
|
257
|
+
});
|
258
|
+
return result;
|
259
|
+
}
|
260
|
+
}
|
261
|
+
});
|
262
|
+
|
263
|
+
// ../../node_modules/fast-deep-equal/index.js
|
264
|
+
var require_fast_deep_equal = __commonJS({
|
265
|
+
"../../node_modules/fast-deep-equal/index.js"(exports, module) {
|
266
|
+
"use strict";
|
267
|
+
init_react_import();
|
268
|
+
module.exports = function equal(a, b) {
|
269
|
+
if (a === b) return true;
|
270
|
+
if (a && b && typeof a == "object" && typeof b == "object") {
|
271
|
+
if (a.constructor !== b.constructor) return false;
|
272
|
+
var length, i, keys;
|
273
|
+
if (Array.isArray(a)) {
|
274
|
+
length = a.length;
|
275
|
+
if (length != b.length) return false;
|
276
|
+
for (i = length; i-- !== 0; )
|
277
|
+
if (!equal(a[i], b[i])) return false;
|
278
|
+
return true;
|
279
|
+
}
|
280
|
+
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
281
|
+
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
282
|
+
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
283
|
+
keys = Object.keys(a);
|
284
|
+
length = keys.length;
|
285
|
+
if (length !== Object.keys(b).length) return false;
|
286
|
+
for (i = length; i-- !== 0; )
|
287
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
288
|
+
for (i = length; i-- !== 0; ) {
|
289
|
+
var key = keys[i];
|
290
|
+
if (!equal(a[key], b[key])) return false;
|
291
|
+
}
|
292
|
+
return true;
|
293
|
+
}
|
294
|
+
return a !== a && b !== b;
|
295
|
+
};
|
296
|
+
}
|
297
|
+
});
|
298
|
+
|
129
299
|
// index.ts
|
130
300
|
init_react_import();
|
131
301
|
|
132
302
|
// src/HeadingAnalyzer.tsx
|
133
303
|
init_react_import();
|
134
|
-
import { useEffect, useState } from "react";
|
304
|
+
import { useEffect as useEffect5, useState } from "react";
|
135
305
|
|
136
306
|
// css-module:/home/runner/work/puck/puck/packages/plugin-heading-analyzer/src/HeadingAnalyzer.module.css#css-module
|
137
307
|
init_react_import();
|
@@ -140,12 +310,12 @@ var HeadingAnalyzer_module_default = { "HeadingAnalyzer": "_HeadingAnalyzer_116v
|
|
140
310
|
// src/HeadingAnalyzer.tsx
|
141
311
|
import { createUsePuck } from "@measured/puck";
|
142
312
|
|
143
|
-
// ../core/components/
|
313
|
+
// ../core/components/SidebarSection/index.tsx
|
144
314
|
init_react_import();
|
145
315
|
|
146
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/
|
316
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
147
317
|
init_react_import();
|
148
|
-
var styles_module_default = { "
|
318
|
+
var styles_module_default = { "SidebarSection": "_SidebarSection_8boj8_1", "SidebarSection-title": "_SidebarSection-title_8boj8_12", "SidebarSection--noBorderTop": "_SidebarSection--noBorderTop_8boj8_20", "SidebarSection-content": "_SidebarSection-content_8boj8_24", "SidebarSection--noPadding": "_SidebarSection--noPadding_8boj8_28", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_8boj8_41", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_8boj8_70", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_8boj8_41", "SidebarSection-heading": "_SidebarSection-heading_8boj8_82", "SidebarSection-loadingOverlay": "_SidebarSection-loadingOverlay_8boj8_86" };
|
149
319
|
|
150
320
|
// ../core/lib/get-class-name-factory.ts
|
151
321
|
init_react_import();
|
@@ -174,50 +344,29 @@ var getClassNameFactory = (rootClass, styles, config = { baseClass: "" }) => (op
|
|
174
344
|
};
|
175
345
|
var get_class_name_factory_default = getClassNameFactory;
|
176
346
|
|
177
|
-
// ../core/components/
|
347
|
+
// ../core/components/Heading/index.tsx
|
348
|
+
init_react_import();
|
349
|
+
|
350
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Heading/styles.module.css#css-module
|
351
|
+
init_react_import();
|
352
|
+
var styles_module_default2 = { "Heading": "_Heading_qxrry_1", "Heading--xxxxl": "_Heading--xxxxl_qxrry_12", "Heading--xxxl": "_Heading--xxxl_qxrry_18", "Heading--xxl": "_Heading--xxl_qxrry_22", "Heading--xl": "_Heading--xl_qxrry_26", "Heading--l": "_Heading--l_qxrry_30", "Heading--m": "_Heading--m_qxrry_34", "Heading--s": "_Heading--s_qxrry_38", "Heading--xs": "_Heading--xs_qxrry_42" };
|
353
|
+
|
354
|
+
// ../core/components/Heading/index.tsx
|
178
355
|
import { jsx } from "react/jsx-runtime";
|
179
|
-
var getClassName = get_class_name_factory_default("
|
180
|
-
var
|
181
|
-
|
182
|
-
return /* @__PURE__ */ jsx("ul", { className: getClassName(), children });
|
183
|
-
};
|
184
|
-
OutlineList.Clickable = ({ children }) => /* @__PURE__ */ jsx("div", { className: getClassNameItem({ clickable: true }), children });
|
185
|
-
OutlineList.Item = ({
|
186
|
-
children,
|
187
|
-
onClick
|
188
|
-
}) => {
|
356
|
+
var getClassName = get_class_name_factory_default("Heading", styles_module_default2);
|
357
|
+
var Heading = ({ children, rank, size = "m" }) => {
|
358
|
+
const Tag = rank ? `h${rank}` : "span";
|
189
359
|
return /* @__PURE__ */ jsx(
|
190
|
-
|
360
|
+
Tag,
|
191
361
|
{
|
192
|
-
className:
|
193
|
-
|
362
|
+
className: getClassName({
|
363
|
+
[size]: true
|
364
|
+
}),
|
194
365
|
children
|
195
366
|
}
|
196
367
|
);
|
197
368
|
};
|
198
369
|
|
199
|
-
// ../core/lib/scroll-into-view.ts
|
200
|
-
init_react_import();
|
201
|
-
var scrollIntoView = (el) => {
|
202
|
-
const oldStyle = __spreadValues({}, el.style);
|
203
|
-
el.style.scrollMargin = "256px";
|
204
|
-
if (el) {
|
205
|
-
el == null ? void 0 : el.scrollIntoView({ behavior: "smooth" });
|
206
|
-
el.style.scrollMargin = oldStyle.scrollMargin || "";
|
207
|
-
}
|
208
|
-
};
|
209
|
-
|
210
|
-
// ../core/lib/get-frame.ts
|
211
|
-
init_react_import();
|
212
|
-
var getFrame = () => {
|
213
|
-
if (typeof window === "undefined") return;
|
214
|
-
let frameEl = document.querySelector("#preview-frame");
|
215
|
-
if ((frameEl == null ? void 0 : frameEl.tagName) === "IFRAME") {
|
216
|
-
return frameEl.contentDocument || document;
|
217
|
-
}
|
218
|
-
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
219
|
-
};
|
220
|
-
|
221
370
|
// ../../node_modules/lucide-react/dist/esm/lucide-react.js
|
222
371
|
init_react_import();
|
223
372
|
|
@@ -305,187 +454,2119 @@ var createLucideIcon = (iconName, iconNode) => {
|
|
305
454
|
return Component;
|
306
455
|
};
|
307
456
|
|
308
|
-
// ../../node_modules/lucide-react/dist/esm/icons/
|
457
|
+
// ../../node_modules/lucide-react/dist/esm/icons/chevron-right.js
|
309
458
|
init_react_import();
|
310
|
-
var
|
311
|
-
["path", { d: "
|
312
|
-
["path", { d: "M4 18V6", key: "1rz3zl" }],
|
313
|
-
["path", { d: "M12 18V6", key: "zqpxq5" }],
|
314
|
-
["path", { d: "m17 12 3-2v8", key: "1hhhft" }]
|
459
|
+
var ChevronRight = createLucideIcon("ChevronRight", [
|
460
|
+
["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]
|
315
461
|
]);
|
316
462
|
|
317
|
-
// ../core/lib/
|
463
|
+
// ../core/lib/use-breadcrumbs.ts
|
318
464
|
init_react_import();
|
465
|
+
import { useMemo as useMemo2 } from "react";
|
319
466
|
|
320
|
-
// ../core/
|
467
|
+
// ../core/store/index.ts
|
321
468
|
init_react_import();
|
322
469
|
|
323
|
-
// ../core/
|
470
|
+
// ../core/reducer/index.ts
|
324
471
|
init_react_import();
|
325
472
|
|
326
|
-
// ../core/
|
473
|
+
// ../core/reducer/actions/set.ts
|
327
474
|
init_react_import();
|
328
475
|
|
329
|
-
//
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
476
|
+
// ../core/lib/data/walk-app-state.ts
|
477
|
+
init_react_import();
|
478
|
+
|
479
|
+
// ../core/lib/data/for-related-zones.ts
|
480
|
+
init_react_import();
|
481
|
+
|
482
|
+
// ../core/lib/get-zone-id.ts
|
483
|
+
init_react_import();
|
484
|
+
|
485
|
+
// ../core/lib/root-droppable-id.ts
|
486
|
+
init_react_import();
|
487
|
+
var rootAreaId = "root";
|
488
|
+
var rootZone = "default-zone";
|
489
|
+
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
490
|
+
|
491
|
+
// ../core/lib/get-zone-id.ts
|
492
|
+
var getZoneId = (zoneCompound) => {
|
493
|
+
if (!zoneCompound) {
|
494
|
+
return [];
|
495
|
+
}
|
496
|
+
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
497
|
+
return zoneCompound.split(":");
|
498
|
+
}
|
499
|
+
return [rootDroppableId, zoneCompound];
|
500
|
+
};
|
501
|
+
|
502
|
+
// ../core/lib/data/for-related-zones.ts
|
503
|
+
function forRelatedZones(item, data, cb, path = []) {
|
504
|
+
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
|
505
|
+
const [parentId] = getZoneId(zoneCompound);
|
506
|
+
if (parentId === item.props.id) {
|
507
|
+
cb(path, zoneCompound, content);
|
341
508
|
}
|
342
|
-
_outline.push({
|
343
|
-
rank: parseInt(item.tagName.split("H")[1]),
|
344
|
-
text: item.textContent,
|
345
|
-
element: item
|
346
|
-
});
|
347
509
|
});
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
510
|
+
}
|
511
|
+
|
512
|
+
// ../core/lib/data/map-slots.ts
|
513
|
+
init_react_import();
|
514
|
+
|
515
|
+
// ../core/lib/data/default-slots.ts
|
516
|
+
init_react_import();
|
517
|
+
var defaultSlots = (value, fields) => Object.keys(fields).reduce(
|
518
|
+
(acc, fieldName) => fields[fieldName].type === "slot" ? __spreadValues({ [fieldName]: [] }, acc) : acc,
|
519
|
+
value
|
520
|
+
);
|
521
|
+
|
522
|
+
// ../core/lib/data/map-slots.ts
|
523
|
+
var isPromise = (v) => !!v && typeof v.then === "function";
|
524
|
+
var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
|
525
|
+
var containsPromise = (arr) => arr.some(isPromise);
|
526
|
+
var walkField = ({
|
527
|
+
value,
|
528
|
+
fields,
|
529
|
+
map,
|
530
|
+
propKey = "",
|
531
|
+
propPath = "",
|
532
|
+
id = "",
|
533
|
+
config,
|
534
|
+
recurseSlots = false
|
535
|
+
}) => {
|
536
|
+
var _a, _b, _c;
|
537
|
+
if (((_a = fields[propKey]) == null ? void 0 : _a.type) === "slot") {
|
538
|
+
const content = value || [];
|
539
|
+
const mappedContent = recurseSlots ? content.map((el) => {
|
540
|
+
var _a2;
|
541
|
+
const componentConfig = config.components[el.type];
|
542
|
+
if (!componentConfig) {
|
543
|
+
throw new Error(`Could not find component config for ${el.type}`);
|
367
544
|
}
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
545
|
+
const fields2 = (_a2 = componentConfig.fields) != null ? _a2 : {};
|
546
|
+
return walkField({
|
547
|
+
value: __spreadProps(__spreadValues({}, el), { props: defaultSlots(el.props, fields2) }),
|
548
|
+
fields: fields2,
|
549
|
+
map,
|
550
|
+
id: el.props.id,
|
551
|
+
config,
|
552
|
+
recurseSlots
|
553
|
+
});
|
554
|
+
}) : content;
|
555
|
+
if (containsPromise(mappedContent)) {
|
556
|
+
return Promise.all(mappedContent);
|
557
|
+
}
|
558
|
+
return map(mappedContent, id, propPath, fields[propKey], propPath);
|
559
|
+
}
|
560
|
+
if (value && typeof value === "object") {
|
561
|
+
if (Array.isArray(value)) {
|
562
|
+
const arrayFields = ((_b = fields[propKey]) == null ? void 0 : _b.type) === "array" ? fields[propKey].arrayFields : null;
|
563
|
+
if (!arrayFields) return value;
|
564
|
+
const newValue = value.map(
|
565
|
+
(el, idx) => walkField({
|
566
|
+
value: el,
|
567
|
+
fields: arrayFields,
|
568
|
+
map,
|
569
|
+
propKey,
|
570
|
+
propPath: `${propPath}[${idx}]`,
|
571
|
+
id,
|
572
|
+
config,
|
573
|
+
recurseSlots
|
574
|
+
})
|
575
|
+
);
|
576
|
+
if (containsPromise(newValue)) {
|
577
|
+
return Promise.all(newValue);
|
377
578
|
}
|
579
|
+
return newValue;
|
580
|
+
} else if ("$$typeof" in value) {
|
581
|
+
return value;
|
582
|
+
} else {
|
583
|
+
const objectFields = ((_c = fields[propKey]) == null ? void 0 : _c.type) === "object" ? fields[propKey].objectFields : fields;
|
584
|
+
return walkObject({
|
585
|
+
value,
|
586
|
+
fields: objectFields,
|
587
|
+
map,
|
588
|
+
id,
|
589
|
+
getPropPath: (k) => `${propPath}.${k}`,
|
590
|
+
config,
|
591
|
+
recurseSlots
|
592
|
+
});
|
378
593
|
}
|
379
|
-
(_b = path[path.length - 1].children) == null ? void 0 : _b.push(node);
|
380
|
-
path.push(node);
|
381
594
|
}
|
382
|
-
return
|
595
|
+
return value;
|
596
|
+
};
|
597
|
+
var walkObject = ({
|
598
|
+
value,
|
599
|
+
fields,
|
600
|
+
map,
|
601
|
+
id,
|
602
|
+
getPropPath,
|
603
|
+
config,
|
604
|
+
recurseSlots
|
605
|
+
}) => {
|
606
|
+
const newProps = Object.entries(value).map(([k, v]) => {
|
607
|
+
const opts = {
|
608
|
+
value: v,
|
609
|
+
fields,
|
610
|
+
map,
|
611
|
+
propKey: k,
|
612
|
+
propPath: getPropPath(k),
|
613
|
+
id,
|
614
|
+
config,
|
615
|
+
recurseSlots
|
616
|
+
};
|
617
|
+
const newValue = walkField(opts);
|
618
|
+
if (isPromise(newValue)) {
|
619
|
+
return newValue.then((resolvedValue) => ({
|
620
|
+
[k]: resolvedValue
|
621
|
+
}));
|
622
|
+
}
|
623
|
+
return {
|
624
|
+
[k]: newValue
|
625
|
+
};
|
626
|
+
}, {});
|
627
|
+
if (containsPromise(newProps)) {
|
628
|
+
return Promise.all(newProps).then(flatten);
|
629
|
+
}
|
630
|
+
return flatten(newProps);
|
631
|
+
};
|
632
|
+
function mapSlots(item, map, config, recurseSlots = false) {
|
633
|
+
var _a, _b, _c, _d, _e;
|
634
|
+
const itemType = "type" in item ? item.type : "root";
|
635
|
+
const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
|
636
|
+
const newProps = walkObject({
|
637
|
+
value: defaultSlots((_b = item.props) != null ? _b : {}, (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {}),
|
638
|
+
fields: (_d = componentConfig == null ? void 0 : componentConfig.fields) != null ? _d : {},
|
639
|
+
map,
|
640
|
+
id: item.props ? (_e = item.props.id) != null ? _e : "root" : "root",
|
641
|
+
getPropPath: (k) => k,
|
642
|
+
config,
|
643
|
+
recurseSlots
|
644
|
+
});
|
645
|
+
if (isPromise(newProps)) {
|
646
|
+
return newProps.then((resolvedProps) => __spreadProps(__spreadValues({}, item), {
|
647
|
+
props: resolvedProps
|
648
|
+
}));
|
649
|
+
}
|
650
|
+
return __spreadProps(__spreadValues({}, item), {
|
651
|
+
props: newProps
|
652
|
+
});
|
383
653
|
}
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
654
|
+
|
655
|
+
// ../core/lib/data/flatten-node.ts
|
656
|
+
init_react_import();
|
657
|
+
var import_flat = __toESM(require_flat());
|
658
|
+
|
659
|
+
// ../core/lib/data/strip-slots.ts
|
660
|
+
init_react_import();
|
661
|
+
var stripSlots = (data, config) => {
|
662
|
+
return mapSlots(data, () => null, config);
|
663
|
+
};
|
664
|
+
|
665
|
+
// ../core/lib/data/flatten-node.ts
|
666
|
+
var { flatten: flatten2, unflatten } = import_flat.default;
|
667
|
+
var flattenNode = (node, config) => {
|
668
|
+
return __spreadProps(__spreadValues({}, node), {
|
669
|
+
props: flatten2(stripSlots(node, config).props)
|
670
|
+
});
|
671
|
+
};
|
672
|
+
|
673
|
+
// ../core/lib/data/walk-app-state.ts
|
674
|
+
function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
675
|
+
var _a;
|
676
|
+
let newZones = {};
|
677
|
+
const newZoneIndex = {};
|
678
|
+
const newNodeIndex = {};
|
679
|
+
const processContent = (path, zoneCompound, content, zoneType, newId) => {
|
680
|
+
var _a2;
|
681
|
+
const [parentId] = zoneCompound.split(":");
|
682
|
+
const mappedContent = ((_a2 = mapContent(content, zoneCompound, zoneType)) != null ? _a2 : content) || [];
|
683
|
+
const [_2, zone] = zoneCompound.split(":");
|
684
|
+
const newZoneCompound = `${newId || parentId}:${zone}`;
|
685
|
+
const newContent2 = mappedContent.map(
|
686
|
+
(zoneChild, index) => processItem(zoneChild, [...path, newZoneCompound], index)
|
687
|
+
);
|
688
|
+
newZoneIndex[newZoneCompound] = {
|
689
|
+
contentIds: newContent2.map((item) => item.props.id),
|
690
|
+
type: zoneType
|
393
691
|
};
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
692
|
+
return [newZoneCompound, newContent2];
|
693
|
+
};
|
694
|
+
const processRelatedZones = (item, newId, initialPath) => {
|
695
|
+
forRelatedZones(
|
696
|
+
item,
|
697
|
+
state.data,
|
698
|
+
(relatedPath, relatedZoneCompound, relatedContent) => {
|
699
|
+
const [zoneCompound, newContent2] = processContent(
|
700
|
+
relatedPath,
|
701
|
+
relatedZoneCompound,
|
702
|
+
relatedContent,
|
703
|
+
"dropzone",
|
704
|
+
newId
|
705
|
+
);
|
706
|
+
newZones[zoneCompound] = newContent2;
|
707
|
+
},
|
708
|
+
initialPath
|
709
|
+
);
|
710
|
+
};
|
711
|
+
const processItem = (item, path, index) => {
|
712
|
+
const mappedItem = mapNodeOrSkip(item, path, index);
|
713
|
+
if (!mappedItem) return item;
|
714
|
+
const id = mappedItem.props.id;
|
715
|
+
const newProps = __spreadProps(__spreadValues({}, mapSlots(
|
716
|
+
mappedItem,
|
717
|
+
(content, parentId2, slotId) => {
|
718
|
+
const zoneCompound = `${parentId2}:${slotId}`;
|
719
|
+
const [_2, newContent2] = processContent(
|
720
|
+
path,
|
721
|
+
zoneCompound,
|
722
|
+
content,
|
723
|
+
"slot",
|
724
|
+
parentId2
|
725
|
+
);
|
726
|
+
return newContent2;
|
727
|
+
},
|
728
|
+
config
|
729
|
+
).props), {
|
730
|
+
id
|
403
731
|
});
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
732
|
+
processRelatedZones(item, id, path);
|
733
|
+
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
|
734
|
+
const thisZoneCompound = path[path.length - 1];
|
735
|
+
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
736
|
+
newNodeIndex[id] = {
|
737
|
+
data: newItem,
|
738
|
+
flatData: flattenNode(newItem, config),
|
739
|
+
path,
|
740
|
+
parentId,
|
741
|
+
zone
|
411
742
|
};
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
registerFrameObserver();
|
743
|
+
const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
|
744
|
+
if (newProps.id === "root") {
|
745
|
+
delete finalData["type"];
|
746
|
+
delete finalData.props["id"];
|
417
747
|
}
|
418
|
-
return
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
)
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
748
|
+
return finalData;
|
749
|
+
};
|
750
|
+
const zones = state.data.zones || {};
|
751
|
+
const [_, newContent] = processContent(
|
752
|
+
[],
|
753
|
+
rootDroppableId,
|
754
|
+
state.data.content,
|
755
|
+
"root"
|
756
|
+
);
|
757
|
+
const processedContent = newContent;
|
758
|
+
const zonesAlreadyProcessed = Object.keys(newZones);
|
759
|
+
Object.keys(zones || {}).forEach((zoneCompound) => {
|
760
|
+
const [parentId] = zoneCompound.split(":");
|
761
|
+
if (zonesAlreadyProcessed.includes(zoneCompound)) {
|
762
|
+
return;
|
763
|
+
}
|
764
|
+
const [_2, newContent2] = processContent(
|
765
|
+
[rootDroppableId],
|
766
|
+
zoneCompound,
|
767
|
+
zones[zoneCompound],
|
768
|
+
"dropzone",
|
769
|
+
parentId
|
770
|
+
);
|
771
|
+
newZones[zoneCompound] = newContent2;
|
772
|
+
}, newZones);
|
773
|
+
const processedRoot = processItem(
|
774
|
+
{
|
775
|
+
type: "root",
|
776
|
+
props: __spreadProps(__spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root), { id: "root" })
|
777
|
+
},
|
778
|
+
[],
|
779
|
+
-1
|
780
|
+
);
|
781
|
+
const root = __spreadProps(__spreadValues({}, state.data.root), {
|
782
|
+
props: processedRoot.props
|
783
|
+
});
|
784
|
+
return __spreadProps(__spreadValues({}, state), {
|
785
|
+
data: {
|
786
|
+
root,
|
787
|
+
content: processedContent,
|
788
|
+
zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
|
789
|
+
},
|
790
|
+
indexes: {
|
791
|
+
nodes: __spreadValues(__spreadValues({}, state.indexes.nodes), newNodeIndex),
|
792
|
+
zones: __spreadValues(__spreadValues({}, state.indexes.zones), newZoneIndex)
|
793
|
+
}
|
794
|
+
});
|
795
|
+
}
|
796
|
+
|
797
|
+
// ../core/reducer/actions/set.ts
|
798
|
+
var setAction = (state, action, appStore) => {
|
799
|
+
if (typeof action.state === "object") {
|
800
|
+
const newState = __spreadValues(__spreadValues({}, state), action.state);
|
801
|
+
if (action.state.indexes) {
|
802
|
+
return newState;
|
803
|
+
}
|
804
|
+
console.warn(
|
805
|
+
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
806
|
+
);
|
807
|
+
return walkAppState(newState, appStore.config);
|
808
|
+
}
|
809
|
+
return __spreadValues(__spreadValues({}, state), action.state(state));
|
810
|
+
};
|
811
|
+
|
812
|
+
// ../core/reducer/actions/insert.ts
|
813
|
+
init_react_import();
|
814
|
+
|
815
|
+
// ../core/lib/data/insert.ts
|
816
|
+
init_react_import();
|
817
|
+
var insert = (list, index, item) => {
|
818
|
+
const result = Array.from(list || []);
|
819
|
+
result.splice(index, 0, item);
|
820
|
+
return result;
|
821
|
+
};
|
822
|
+
|
823
|
+
// ../core/lib/generate-id.ts
|
824
|
+
init_react_import();
|
825
|
+
|
826
|
+
// ../../node_modules/uuid/dist/esm-node/index.js
|
827
|
+
init_react_import();
|
828
|
+
|
829
|
+
// ../../node_modules/uuid/dist/esm-node/rng.js
|
830
|
+
init_react_import();
|
831
|
+
import crypto from "crypto";
|
832
|
+
var rnds8Pool = new Uint8Array(256);
|
833
|
+
var poolPtr = rnds8Pool.length;
|
834
|
+
function rng() {
|
835
|
+
if (poolPtr > rnds8Pool.length - 16) {
|
836
|
+
crypto.randomFillSync(rnds8Pool);
|
837
|
+
poolPtr = 0;
|
838
|
+
}
|
839
|
+
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
840
|
+
}
|
841
|
+
|
842
|
+
// ../../node_modules/uuid/dist/esm-node/stringify.js
|
843
|
+
init_react_import();
|
844
|
+
var byteToHex = [];
|
845
|
+
for (let i = 0; i < 256; ++i) {
|
846
|
+
byteToHex.push((i + 256).toString(16).slice(1));
|
847
|
+
}
|
848
|
+
function unsafeStringify(arr, offset = 0) {
|
849
|
+
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]];
|
850
|
+
}
|
851
|
+
|
852
|
+
// ../../node_modules/uuid/dist/esm-node/v4.js
|
853
|
+
init_react_import();
|
854
|
+
|
855
|
+
// ../../node_modules/uuid/dist/esm-node/native.js
|
856
|
+
init_react_import();
|
857
|
+
import crypto2 from "crypto";
|
858
|
+
var native_default = {
|
859
|
+
randomUUID: crypto2.randomUUID
|
860
|
+
};
|
861
|
+
|
862
|
+
// ../../node_modules/uuid/dist/esm-node/v4.js
|
863
|
+
function v4(options, buf, offset) {
|
864
|
+
if (native_default.randomUUID && !buf && !options) {
|
865
|
+
return native_default.randomUUID();
|
866
|
+
}
|
867
|
+
options = options || {};
|
868
|
+
const rnds = options.random || (options.rng || rng)();
|
869
|
+
rnds[6] = rnds[6] & 15 | 64;
|
870
|
+
rnds[8] = rnds[8] & 63 | 128;
|
871
|
+
if (buf) {
|
872
|
+
offset = offset || 0;
|
873
|
+
for (let i = 0; i < 16; ++i) {
|
874
|
+
buf[offset + i] = rnds[i];
|
875
|
+
}
|
876
|
+
return buf;
|
877
|
+
}
|
878
|
+
return unsafeStringify(rnds);
|
879
|
+
}
|
880
|
+
var v4_default = v4;
|
881
|
+
|
882
|
+
// ../core/lib/generate-id.ts
|
883
|
+
var generateId = (type) => type ? `${type}-${v4_default()}` : v4_default();
|
884
|
+
|
885
|
+
// ../core/lib/data/get-ids-for-parent.ts
|
886
|
+
init_react_import();
|
887
|
+
var getIdsForParent = (zoneCompound, state) => {
|
888
|
+
const [parentId] = zoneCompound.split(":");
|
889
|
+
const node = state.indexes.nodes[parentId];
|
890
|
+
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
|
891
|
+
};
|
892
|
+
|
893
|
+
// ../core/lib/data/populate-ids.ts
|
894
|
+
init_react_import();
|
895
|
+
|
896
|
+
// ../core/lib/data/walk-tree.ts
|
897
|
+
init_react_import();
|
898
|
+
function walkTree(data, config, callbackFn) {
|
899
|
+
var _a, _b;
|
900
|
+
const walkItem = (item) => {
|
901
|
+
return mapSlots(
|
902
|
+
item,
|
903
|
+
(content, parentId, propName) => {
|
904
|
+
var _a2;
|
905
|
+
return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
|
906
|
+
},
|
907
|
+
config,
|
908
|
+
true
|
909
|
+
);
|
910
|
+
};
|
911
|
+
if ("props" in data) {
|
912
|
+
return walkItem(data);
|
913
|
+
}
|
914
|
+
const _data = data;
|
915
|
+
const zones = (_a = _data.zones) != null ? _a : {};
|
916
|
+
const mappedContent = _data.content.map(walkItem);
|
917
|
+
return {
|
918
|
+
root: walkItem(_data.root),
|
919
|
+
content: (_b = callbackFn(mappedContent, {
|
920
|
+
parentId: "root",
|
921
|
+
propName: "default-zone"
|
922
|
+
})) != null ? _b : mappedContent,
|
923
|
+
zones: Object.keys(zones).reduce(
|
924
|
+
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
|
925
|
+
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
926
|
+
}),
|
927
|
+
{}
|
928
|
+
)
|
929
|
+
};
|
930
|
+
}
|
931
|
+
|
932
|
+
// ../core/lib/data/populate-ids.ts
|
933
|
+
var populateIds = (data, config, override = false) => {
|
934
|
+
const id = generateId(data.type);
|
935
|
+
return walkTree(
|
936
|
+
__spreadProps(__spreadValues({}, data), {
|
937
|
+
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({}, data.props)
|
938
|
+
}),
|
939
|
+
config,
|
940
|
+
(contents) => contents.map((item) => {
|
941
|
+
const id2 = generateId(item.type);
|
942
|
+
return __spreadProps(__spreadValues({}, item), {
|
943
|
+
props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
|
944
|
+
});
|
945
|
+
})
|
946
|
+
);
|
947
|
+
};
|
948
|
+
|
949
|
+
// ../core/reducer/actions/insert.ts
|
950
|
+
function insertAction(state, action, appStore) {
|
951
|
+
const id = action.id || generateId(action.componentType);
|
952
|
+
const emptyComponentData = populateIds(
|
953
|
+
{
|
954
|
+
type: action.componentType,
|
955
|
+
props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
|
956
|
+
id
|
957
|
+
})
|
958
|
+
},
|
959
|
+
appStore.config
|
960
|
+
);
|
961
|
+
const [parentId] = action.destinationZone.split(":");
|
962
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
963
|
+
return walkAppState(
|
964
|
+
state,
|
965
|
+
appStore.config,
|
966
|
+
(content, zoneCompound) => {
|
967
|
+
if (zoneCompound === action.destinationZone) {
|
968
|
+
return insert(
|
969
|
+
content || [],
|
970
|
+
action.destinationIndex,
|
971
|
+
emptyComponentData
|
972
|
+
);
|
973
|
+
}
|
974
|
+
return content;
|
975
|
+
},
|
976
|
+
(childItem, path) => {
|
977
|
+
if (childItem.props.id === id || childItem.props.id === parentId) {
|
978
|
+
return childItem;
|
979
|
+
} else if (idsInPath.includes(childItem.props.id)) {
|
980
|
+
return childItem;
|
981
|
+
} else if (path.includes(action.destinationZone)) {
|
982
|
+
return childItem;
|
983
|
+
}
|
984
|
+
return null;
|
985
|
+
}
|
986
|
+
);
|
987
|
+
}
|
988
|
+
|
989
|
+
// ../core/reducer/actions/replace.ts
|
990
|
+
init_react_import();
|
991
|
+
|
992
|
+
// ../core/rsc.tsx
|
993
|
+
init_react_import();
|
994
|
+
|
995
|
+
// ../core/components/ServerRender/index.tsx
|
996
|
+
init_react_import();
|
997
|
+
|
998
|
+
// ../core/lib/data/setup-zone.ts
|
999
|
+
init_react_import();
|
1000
|
+
var setupZone = (data, zoneKey) => {
|
1001
|
+
if (zoneKey === rootDroppableId) {
|
1002
|
+
return data;
|
1003
|
+
}
|
1004
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
1005
|
+
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
1006
|
+
});
|
1007
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
1008
|
+
return newData;
|
1009
|
+
};
|
1010
|
+
|
1011
|
+
// ../core/lib/use-slots.tsx
|
1012
|
+
init_react_import();
|
1013
|
+
import { useMemo } from "react";
|
1014
|
+
function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
1015
|
+
const slotProps = useMemo(() => {
|
1016
|
+
const mapped = mapSlots(
|
1017
|
+
item,
|
1018
|
+
(content, _parentId, propName, field, propPath) => {
|
1019
|
+
const wildcardPath = propPath.replace(/\[\d+\]/g, "[*]");
|
1020
|
+
const isReadOnly = (readOnly == null ? void 0 : readOnly[propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly;
|
1021
|
+
const render = isReadOnly ? renderSlotRender : renderSlotEdit;
|
1022
|
+
const Slot = (dzProps) => render(__spreadProps(__spreadValues({
|
1023
|
+
allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
|
1024
|
+
disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
|
1025
|
+
}, dzProps), {
|
1026
|
+
zone: propName,
|
1027
|
+
content
|
1028
|
+
}));
|
1029
|
+
return Slot;
|
1030
|
+
},
|
1031
|
+
config
|
1032
|
+
).props;
|
1033
|
+
return mapped;
|
1034
|
+
}, [config, item, readOnly, forceReadOnly]);
|
1035
|
+
const mergedProps = useMemo(
|
1036
|
+
() => __spreadValues(__spreadValues({}, item.props), slotProps),
|
1037
|
+
[item.props, slotProps]
|
1038
|
+
);
|
1039
|
+
return mergedProps;
|
1040
|
+
}
|
1041
|
+
|
1042
|
+
// ../core/components/SlotRender/server.tsx
|
1043
|
+
init_react_import();
|
1044
|
+
import { forwardRef as forwardRef3 } from "react";
|
1045
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
1046
|
+
var SlotRenderPure = (props) => /* @__PURE__ */ jsx2(SlotRender, __spreadValues({}, props));
|
1047
|
+
var Item = ({
|
1048
|
+
config,
|
1049
|
+
item,
|
1050
|
+
metadata
|
1051
|
+
}) => {
|
1052
|
+
const Component = config.components[item.type];
|
1053
|
+
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ jsx2(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
1054
|
+
return /* @__PURE__ */ jsx2(
|
1055
|
+
Component.render,
|
1056
|
+
__spreadProps(__spreadValues({}, props), {
|
1057
|
+
puck: __spreadProps(__spreadValues({}, props.puck), {
|
1058
|
+
renderDropZone: DropZoneRender,
|
1059
|
+
metadata: metadata || {}
|
1060
|
+
})
|
1061
|
+
})
|
1062
|
+
);
|
1063
|
+
};
|
1064
|
+
var SlotRender = forwardRef3(
|
1065
|
+
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
1066
|
+
return /* @__PURE__ */ jsx2("div", { className, style, ref, children: content.map((item) => {
|
1067
|
+
if (!config.components[item.type]) {
|
1068
|
+
return null;
|
1069
|
+
}
|
1070
|
+
return /* @__PURE__ */ jsx2(
|
1071
|
+
Item,
|
1072
|
+
{
|
1073
|
+
config,
|
1074
|
+
item,
|
1075
|
+
metadata
|
1076
|
+
},
|
1077
|
+
item.props.id
|
1078
|
+
);
|
1079
|
+
}) });
|
1080
|
+
}
|
1081
|
+
);
|
1082
|
+
|
1083
|
+
// ../core/components/ServerRender/index.tsx
|
1084
|
+
import { Fragment, jsx as jsx3 } from "react/jsx-runtime";
|
1085
|
+
function DropZoneRender({
|
1086
|
+
zone,
|
1087
|
+
data,
|
1088
|
+
areaId = "root",
|
1089
|
+
config,
|
1090
|
+
metadata = {}
|
1091
|
+
}) {
|
1092
|
+
let zoneCompound = rootDroppableId;
|
1093
|
+
let content = (data == null ? void 0 : data.content) || [];
|
1094
|
+
if (!data || !config) {
|
1095
|
+
return null;
|
1096
|
+
}
|
1097
|
+
if (areaId !== rootAreaId && zone !== rootZone) {
|
1098
|
+
zoneCompound = `${areaId}:${zone}`;
|
1099
|
+
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
1100
|
+
}
|
1101
|
+
return /* @__PURE__ */ jsx3(Fragment, { children: content.map((item) => {
|
1102
|
+
const Component = config.components[item.type];
|
1103
|
+
const props = __spreadProps(__spreadValues({}, item.props), {
|
1104
|
+
puck: {
|
1105
|
+
renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ jsx3(
|
1106
|
+
DropZoneRender,
|
1107
|
+
{
|
1108
|
+
zone: zone2,
|
1109
|
+
data,
|
1110
|
+
areaId: item.props.id,
|
1111
|
+
config,
|
1112
|
+
metadata
|
1113
|
+
}
|
1114
|
+
),
|
1115
|
+
metadata,
|
1116
|
+
dragRef: null,
|
1117
|
+
isEditing: false
|
1118
|
+
}
|
1119
|
+
});
|
1120
|
+
const renderItem = __spreadProps(__spreadValues({}, item), { props });
|
1121
|
+
const propsWithSlots = useSlots(config, renderItem, (props2) => /* @__PURE__ */ jsx3(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
|
1122
|
+
if (Component) {
|
1123
|
+
return /* @__PURE__ */ jsx3(Component.render, __spreadValues({}, propsWithSlots), renderItem.props.id);
|
1124
|
+
}
|
1125
|
+
return null;
|
1126
|
+
}) });
|
1127
|
+
}
|
1128
|
+
|
1129
|
+
// ../core/lib/resolve-all-data.ts
|
1130
|
+
init_react_import();
|
1131
|
+
|
1132
|
+
// ../core/lib/resolve-component-data.ts
|
1133
|
+
init_react_import();
|
1134
|
+
|
1135
|
+
// ../core/lib/get-changed.ts
|
1136
|
+
init_react_import();
|
1137
|
+
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1138
|
+
var getChanged = (newItem, oldItem) => {
|
1139
|
+
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
1140
|
+
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
1141
|
+
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
1142
|
+
return __spreadProps(__spreadValues({}, acc), {
|
1143
|
+
[item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
|
1144
|
+
});
|
1145
|
+
}, {}) : {};
|
1146
|
+
};
|
1147
|
+
|
1148
|
+
// ../core/lib/resolve-component-data.ts
|
1149
|
+
var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
|
1150
|
+
var cache = { lastChange: {} };
|
1151
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
1152
|
+
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
1153
|
+
const resolvedItem = __spreadValues({}, item);
|
1154
|
+
const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
|
1155
|
+
const id = "id" in item.props ? item.props.id : "root";
|
1156
|
+
if (shouldRunResolver) {
|
1157
|
+
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
1158
|
+
if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
|
1159
|
+
return { node: resolved, didChange: false };
|
1160
|
+
}
|
1161
|
+
const changed = getChanged(item, oldItem);
|
1162
|
+
if (onResolveStart) {
|
1163
|
+
onResolveStart(item);
|
1164
|
+
}
|
1165
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
1166
|
+
changed,
|
1167
|
+
lastData: oldItem,
|
1168
|
+
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
1169
|
+
trigger
|
1170
|
+
});
|
1171
|
+
resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
|
1172
|
+
if (Object.keys(readOnly).length) {
|
1173
|
+
resolvedItem.readOnly = readOnly;
|
1174
|
+
}
|
1175
|
+
}
|
1176
|
+
let itemWithResolvedChildren = yield mapSlots(
|
1177
|
+
resolvedItem,
|
1178
|
+
(content) => __async(void 0, null, function* () {
|
1179
|
+
return yield Promise.all(
|
1180
|
+
content.map(
|
1181
|
+
(childItem) => __async(void 0, null, function* () {
|
1182
|
+
return (yield resolveComponentData(
|
1183
|
+
childItem,
|
1184
|
+
config,
|
1185
|
+
metadata,
|
1186
|
+
onResolveStart,
|
1187
|
+
onResolveEnd,
|
1188
|
+
trigger
|
1189
|
+
)).node;
|
1190
|
+
})
|
1191
|
+
)
|
1192
|
+
);
|
1193
|
+
}),
|
1194
|
+
config
|
1195
|
+
);
|
1196
|
+
if (shouldRunResolver && onResolveEnd) {
|
1197
|
+
onResolveEnd(resolvedItem);
|
1198
|
+
}
|
1199
|
+
cache.lastChange[id] = {
|
1200
|
+
item,
|
1201
|
+
resolved: itemWithResolvedChildren
|
1202
|
+
};
|
1203
|
+
return {
|
1204
|
+
node: itemWithResolvedChildren,
|
1205
|
+
didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
|
1206
|
+
};
|
1207
|
+
});
|
1208
|
+
|
1209
|
+
// ../core/lib/data/default-data.ts
|
1210
|
+
init_react_import();
|
1211
|
+
|
1212
|
+
// ../core/lib/data/to-component.ts
|
1213
|
+
init_react_import();
|
1214
|
+
|
1215
|
+
// ../core/lib/transform-props.ts
|
1216
|
+
init_react_import();
|
1217
|
+
|
1218
|
+
// ../core/lib/migrate.ts
|
1219
|
+
init_react_import();
|
1220
|
+
|
1221
|
+
// ../core/store/default-app-state.ts
|
1222
|
+
init_react_import();
|
1223
|
+
|
1224
|
+
// ../core/components/ViewportControls/default-viewports.ts
|
1225
|
+
init_react_import();
|
1226
|
+
var defaultViewports = [
|
1227
|
+
{ width: 360, height: "auto", icon: "Smartphone", label: "Small" },
|
1228
|
+
{ width: 768, height: "auto", icon: "Tablet", label: "Medium" },
|
1229
|
+
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
1230
|
+
];
|
1231
|
+
|
1232
|
+
// ../core/store/default-app-state.ts
|
1233
|
+
var defaultAppState = {
|
1234
|
+
data: { content: [], root: {}, zones: {} },
|
1235
|
+
ui: {
|
1236
|
+
leftSideBarVisible: true,
|
1237
|
+
rightSideBarVisible: true,
|
1238
|
+
arrayState: {},
|
1239
|
+
itemSelector: null,
|
1240
|
+
componentList: {},
|
1241
|
+
isDragging: false,
|
1242
|
+
previewMode: "edit",
|
1243
|
+
viewports: {
|
1244
|
+
current: {
|
1245
|
+
width: defaultViewports[0].width,
|
1246
|
+
height: defaultViewports[0].height || "auto"
|
1247
|
+
},
|
1248
|
+
options: [],
|
1249
|
+
controlsVisible: true
|
1250
|
+
},
|
1251
|
+
field: { focus: null }
|
1252
|
+
},
|
1253
|
+
indexes: {
|
1254
|
+
nodes: {},
|
1255
|
+
zones: {}
|
1256
|
+
}
|
1257
|
+
};
|
1258
|
+
|
1259
|
+
// ../core/reducer/actions/replace.ts
|
1260
|
+
var replaceAction = (state, action, appStore) => {
|
1261
|
+
const [parentId] = action.destinationZone.split(":");
|
1262
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
1263
|
+
const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
|
1264
|
+
const idChanged = originalId !== action.data.props.id;
|
1265
|
+
if (idChanged) {
|
1266
|
+
throw new Error(
|
1267
|
+
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
1268
|
+
);
|
1269
|
+
}
|
1270
|
+
const newSlotIds = [];
|
1271
|
+
const data = walkTree(action.data, appStore.config, (contents, opts) => {
|
1272
|
+
newSlotIds.push(`${opts.parentId}:${opts.propName}`);
|
1273
|
+
return contents.map((item) => {
|
1274
|
+
const id = generateId(item.type);
|
1275
|
+
return __spreadProps(__spreadValues({}, item), {
|
1276
|
+
props: __spreadValues({ id }, item.props)
|
1277
|
+
});
|
1278
|
+
});
|
1279
|
+
});
|
1280
|
+
const stateWithDeepSlotsRemoved = __spreadValues({}, state);
|
1281
|
+
Object.keys(state.indexes.zones).forEach((zoneCompound) => {
|
1282
|
+
const id = zoneCompound.split(":")[0];
|
1283
|
+
if (id === originalId) {
|
1284
|
+
if (!newSlotIds.includes(zoneCompound)) {
|
1285
|
+
delete stateWithDeepSlotsRemoved.indexes.zones[zoneCompound];
|
1286
|
+
}
|
1287
|
+
}
|
1288
|
+
});
|
1289
|
+
return walkAppState(
|
1290
|
+
stateWithDeepSlotsRemoved,
|
1291
|
+
appStore.config,
|
1292
|
+
(content, zoneCompound) => {
|
1293
|
+
const newContent = [...content];
|
1294
|
+
if (zoneCompound === action.destinationZone) {
|
1295
|
+
newContent[action.destinationIndex] = data;
|
1296
|
+
}
|
1297
|
+
return newContent;
|
1298
|
+
},
|
1299
|
+
(childItem, path) => {
|
1300
|
+
const pathIds = path.map((p) => p.split(":")[0]);
|
1301
|
+
if (childItem.props.id === data.props.id) {
|
1302
|
+
return data;
|
1303
|
+
} else if (childItem.props.id === parentId) {
|
1304
|
+
return childItem;
|
1305
|
+
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
1306
|
+
return childItem;
|
1307
|
+
} else if (pathIds.indexOf(data.props.id) > -1) {
|
1308
|
+
return childItem;
|
1309
|
+
}
|
1310
|
+
return null;
|
1311
|
+
}
|
1312
|
+
);
|
1313
|
+
};
|
1314
|
+
|
1315
|
+
// ../core/reducer/actions/replace-root.ts
|
1316
|
+
init_react_import();
|
1317
|
+
var replaceRootAction = (state, action, appStore) => {
|
1318
|
+
return walkAppState(
|
1319
|
+
state,
|
1320
|
+
appStore.config,
|
1321
|
+
(content) => content,
|
1322
|
+
(childItem) => {
|
1323
|
+
if (childItem.props.id === "root") {
|
1324
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
1325
|
+
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
1326
|
+
readOnly: action.root.readOnly
|
1327
|
+
});
|
1328
|
+
}
|
1329
|
+
return childItem;
|
1330
|
+
}
|
1331
|
+
);
|
1332
|
+
};
|
1333
|
+
|
1334
|
+
// ../core/reducer/actions/duplicate.ts
|
1335
|
+
init_react_import();
|
1336
|
+
|
1337
|
+
// ../core/lib/data/get-item.ts
|
1338
|
+
init_react_import();
|
1339
|
+
function getItem(selector, state) {
|
1340
|
+
var _a, _b;
|
1341
|
+
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
1342
|
+
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
1343
|
+
}
|
1344
|
+
|
1345
|
+
// ../core/reducer/actions/duplicate.ts
|
1346
|
+
function duplicateAction(state, action, appStore) {
|
1347
|
+
const item = getItem(
|
1348
|
+
{ index: action.sourceIndex, zone: action.sourceZone },
|
1349
|
+
state
|
1350
|
+
);
|
1351
|
+
const idsInPath = getIdsForParent(action.sourceZone, state);
|
1352
|
+
const newItem = __spreadProps(__spreadValues({}, item), {
|
1353
|
+
props: __spreadProps(__spreadValues({}, item.props), {
|
1354
|
+
id: generateId(item.type)
|
1355
|
+
})
|
1356
|
+
});
|
1357
|
+
const modified = walkAppState(
|
1358
|
+
state,
|
1359
|
+
appStore.config,
|
1360
|
+
(content, zoneCompound) => {
|
1361
|
+
if (zoneCompound === action.sourceZone) {
|
1362
|
+
return insert(content, action.sourceIndex + 1, item);
|
1363
|
+
}
|
1364
|
+
return content;
|
1365
|
+
},
|
1366
|
+
(childItem, path, index) => {
|
1367
|
+
const zoneCompound = path[path.length - 1];
|
1368
|
+
const parents = path.map((p) => p.split(":")[0]);
|
1369
|
+
if (parents.indexOf(newItem.props.id) > -1) {
|
1370
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
1371
|
+
props: __spreadProps(__spreadValues({}, childItem.props), {
|
1372
|
+
id: generateId(childItem.type)
|
1373
|
+
})
|
1374
|
+
});
|
1375
|
+
}
|
1376
|
+
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
1377
|
+
return newItem;
|
1378
|
+
}
|
1379
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
1380
|
+
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
1381
|
+
return childItem;
|
1382
|
+
}
|
1383
|
+
return null;
|
1384
|
+
}
|
1385
|
+
);
|
1386
|
+
return __spreadProps(__spreadValues({}, modified), {
|
1387
|
+
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
1388
|
+
itemSelector: {
|
1389
|
+
index: action.sourceIndex + 1,
|
1390
|
+
zone: action.sourceZone
|
1391
|
+
}
|
1392
|
+
})
|
1393
|
+
});
|
1394
|
+
}
|
1395
|
+
|
1396
|
+
// ../core/reducer/actions/reorder.ts
|
1397
|
+
init_react_import();
|
1398
|
+
|
1399
|
+
// ../core/reducer/actions/move.ts
|
1400
|
+
init_react_import();
|
1401
|
+
|
1402
|
+
// ../core/lib/data/remove.ts
|
1403
|
+
init_react_import();
|
1404
|
+
var remove = (list, index) => {
|
1405
|
+
const result = Array.from(list);
|
1406
|
+
result.splice(index, 1);
|
1407
|
+
return result;
|
1408
|
+
};
|
1409
|
+
|
1410
|
+
// ../core/reducer/actions/move.ts
|
1411
|
+
var moveAction = (state, action, appStore) => {
|
1412
|
+
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
1413
|
+
return state;
|
1414
|
+
}
|
1415
|
+
const item = getItem(
|
1416
|
+
{ zone: action.sourceZone, index: action.sourceIndex },
|
1417
|
+
state
|
1418
|
+
);
|
1419
|
+
if (!item) return state;
|
1420
|
+
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
1421
|
+
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
1422
|
+
return walkAppState(
|
1423
|
+
state,
|
1424
|
+
appStore.config,
|
1425
|
+
(content, zoneCompound) => {
|
1426
|
+
if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
|
1427
|
+
return insert(
|
1428
|
+
remove(content, action.sourceIndex),
|
1429
|
+
action.destinationIndex,
|
1430
|
+
item
|
1431
|
+
);
|
1432
|
+
} else if (zoneCompound === action.sourceZone) {
|
1433
|
+
return remove(content, action.sourceIndex);
|
1434
|
+
} else if (zoneCompound === action.destinationZone) {
|
1435
|
+
return insert(content, action.destinationIndex, item);
|
1436
|
+
}
|
1437
|
+
return content;
|
1438
|
+
},
|
1439
|
+
(childItem, path) => {
|
1440
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
1441
|
+
const [destinationZoneParent] = action.destinationZone.split(":");
|
1442
|
+
const childId = childItem.props.id;
|
1443
|
+
if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1 || path.includes(action.destinationZone)) {
|
1444
|
+
return childItem;
|
1445
|
+
}
|
1446
|
+
return null;
|
1447
|
+
}
|
1448
|
+
);
|
1449
|
+
};
|
1450
|
+
|
1451
|
+
// ../core/reducer/actions/reorder.ts
|
1452
|
+
var reorderAction = (state, action, appStore) => {
|
1453
|
+
return moveAction(
|
1454
|
+
state,
|
1455
|
+
{
|
1456
|
+
type: "move",
|
1457
|
+
sourceIndex: action.sourceIndex,
|
1458
|
+
sourceZone: action.destinationZone,
|
1459
|
+
destinationIndex: action.destinationIndex,
|
1460
|
+
destinationZone: action.destinationZone
|
1461
|
+
},
|
1462
|
+
appStore
|
1463
|
+
);
|
1464
|
+
};
|
1465
|
+
|
1466
|
+
// ../core/reducer/actions/remove.ts
|
1467
|
+
init_react_import();
|
1468
|
+
var removeAction = (state, action, appStore) => {
|
1469
|
+
const item = getItem({ index: action.index, zone: action.zone }, state);
|
1470
|
+
const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
|
1471
|
+
(acc, [nodeId, nodeData]) => {
|
1472
|
+
const pathIds = nodeData.path.map((p) => p.split(":")[0]);
|
1473
|
+
if (pathIds.includes(item.props.id)) {
|
1474
|
+
return [...acc, nodeId];
|
1475
|
+
}
|
1476
|
+
return acc;
|
1477
|
+
},
|
1478
|
+
[item.props.id]
|
1479
|
+
);
|
1480
|
+
const newState = walkAppState(
|
1481
|
+
state,
|
1482
|
+
appStore.config,
|
1483
|
+
(content, zoneCompound) => {
|
1484
|
+
if (zoneCompound === action.zone) {
|
1485
|
+
return remove(content, action.index);
|
1486
|
+
}
|
1487
|
+
return content;
|
1488
|
+
}
|
1489
|
+
);
|
1490
|
+
Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
|
1491
|
+
const parentId = zoneCompound.split(":")[0];
|
1492
|
+
if (nodesToDelete.includes(parentId) && newState.data.zones) {
|
1493
|
+
delete newState.data.zones[zoneCompound];
|
1494
|
+
}
|
1495
|
+
});
|
1496
|
+
Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
|
1497
|
+
const parentId = zoneCompound.split(":")[0];
|
1498
|
+
if (nodesToDelete.includes(parentId)) {
|
1499
|
+
delete newState.indexes.zones[zoneCompound];
|
1500
|
+
}
|
1501
|
+
});
|
1502
|
+
nodesToDelete.forEach((id) => {
|
1503
|
+
delete newState.indexes.nodes[id];
|
1504
|
+
});
|
1505
|
+
return newState;
|
1506
|
+
};
|
1507
|
+
|
1508
|
+
// ../core/reducer/actions/register-zone.ts
|
1509
|
+
init_react_import();
|
1510
|
+
var zoneCache = {};
|
1511
|
+
function registerZoneAction(state, action) {
|
1512
|
+
if (zoneCache[action.zone]) {
|
1513
|
+
return __spreadProps(__spreadValues({}, state), {
|
1514
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
1515
|
+
zones: __spreadProps(__spreadValues({}, state.data.zones), {
|
1516
|
+
[action.zone]: zoneCache[action.zone]
|
1517
|
+
})
|
1518
|
+
}),
|
1519
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1520
|
+
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
|
1521
|
+
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
|
1522
|
+
contentIds: zoneCache[action.zone].map((item) => item.props.id),
|
1523
|
+
type: "dropzone"
|
1524
|
+
})
|
1525
|
+
})
|
1526
|
+
})
|
1527
|
+
});
|
1528
|
+
}
|
1529
|
+
return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
|
1530
|
+
}
|
1531
|
+
function unregisterZoneAction(state, action) {
|
1532
|
+
const _zones = __spreadValues({}, state.data.zones || {});
|
1533
|
+
const zoneIndex = __spreadValues({}, state.indexes.zones || {});
|
1534
|
+
if (_zones[action.zone]) {
|
1535
|
+
zoneCache[action.zone] = _zones[action.zone];
|
1536
|
+
delete _zones[action.zone];
|
1537
|
+
}
|
1538
|
+
delete zoneIndex[action.zone];
|
1539
|
+
return __spreadProps(__spreadValues({}, state), {
|
1540
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
1541
|
+
zones: _zones
|
1542
|
+
}),
|
1543
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1544
|
+
zones: zoneIndex
|
1545
|
+
})
|
1546
|
+
});
|
1547
|
+
}
|
1548
|
+
|
1549
|
+
// ../core/reducer/actions/set-data.ts
|
1550
|
+
init_react_import();
|
1551
|
+
var setDataAction = (state, action, appStore) => {
|
1552
|
+
if (typeof action.data === "object") {
|
1553
|
+
console.warn(
|
1554
|
+
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1555
|
+
);
|
1556
|
+
return walkAppState(
|
1557
|
+
__spreadProps(__spreadValues({}, state), {
|
1558
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
1559
|
+
}),
|
1560
|
+
appStore.config
|
1561
|
+
);
|
1562
|
+
}
|
1563
|
+
return walkAppState(
|
1564
|
+
__spreadProps(__spreadValues({}, state), {
|
1565
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
1566
|
+
}),
|
1567
|
+
appStore.config
|
1568
|
+
);
|
1569
|
+
};
|
1570
|
+
|
1571
|
+
// ../core/reducer/actions/set-ui.ts
|
1572
|
+
init_react_import();
|
1573
|
+
var setUiAction = (state, action) => {
|
1574
|
+
if (typeof action.ui === "object") {
|
1575
|
+
return __spreadProps(__spreadValues({}, state), {
|
1576
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
|
1577
|
+
});
|
1578
|
+
}
|
1579
|
+
return __spreadProps(__spreadValues({}, state), {
|
1580
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
|
1581
|
+
});
|
1582
|
+
};
|
1583
|
+
|
1584
|
+
// ../core/lib/data/make-state-public.ts
|
1585
|
+
init_react_import();
|
1586
|
+
var makeStatePublic = (state) => {
|
1587
|
+
const { data, ui } = state;
|
1588
|
+
return { data, ui };
|
1589
|
+
};
|
1590
|
+
|
1591
|
+
// ../core/reducer/actions.tsx
|
1592
|
+
init_react_import();
|
1593
|
+
|
1594
|
+
// ../core/reducer/index.ts
|
1595
|
+
function storeInterceptor(reducer, record, onAction) {
|
1596
|
+
return (state, action) => {
|
1597
|
+
const newAppState = reducer(state, action);
|
1598
|
+
const isValidType = ![
|
1599
|
+
"registerZone",
|
1600
|
+
"unregisterZone",
|
1601
|
+
"setData",
|
1602
|
+
"setUi",
|
1603
|
+
"set"
|
1604
|
+
].includes(action.type);
|
1605
|
+
if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
|
1606
|
+
if (record) record(newAppState);
|
1607
|
+
}
|
1608
|
+
onAction == null ? void 0 : onAction(action, makeStatePublic(newAppState), makeStatePublic(state));
|
1609
|
+
return newAppState;
|
1610
|
+
};
|
1611
|
+
}
|
1612
|
+
function createReducer({
|
1613
|
+
record,
|
1614
|
+
onAction,
|
1615
|
+
appStore
|
1616
|
+
}) {
|
1617
|
+
return storeInterceptor(
|
1618
|
+
(state, action) => {
|
1619
|
+
if (action.type === "set") {
|
1620
|
+
return setAction(state, action, appStore);
|
1621
|
+
}
|
1622
|
+
if (action.type === "insert") {
|
1623
|
+
return insertAction(state, action, appStore);
|
1624
|
+
}
|
1625
|
+
if (action.type === "replace") {
|
1626
|
+
return replaceAction(state, action, appStore);
|
1627
|
+
}
|
1628
|
+
if (action.type === "replaceRoot") {
|
1629
|
+
return replaceRootAction(state, action, appStore);
|
1630
|
+
}
|
1631
|
+
if (action.type === "duplicate") {
|
1632
|
+
return duplicateAction(state, action, appStore);
|
1633
|
+
}
|
1634
|
+
if (action.type === "reorder") {
|
1635
|
+
return reorderAction(state, action, appStore);
|
1636
|
+
}
|
1637
|
+
if (action.type === "move") {
|
1638
|
+
return moveAction(state, action, appStore);
|
1639
|
+
}
|
1640
|
+
if (action.type === "remove") {
|
1641
|
+
return removeAction(state, action, appStore);
|
1642
|
+
}
|
1643
|
+
if (action.type === "registerZone") {
|
1644
|
+
return registerZoneAction(state, action);
|
1645
|
+
}
|
1646
|
+
if (action.type === "unregisterZone") {
|
1647
|
+
return unregisterZoneAction(state, action);
|
1648
|
+
}
|
1649
|
+
if (action.type === "setData") {
|
1650
|
+
return setDataAction(state, action, appStore);
|
1651
|
+
}
|
1652
|
+
if (action.type === "setUi") {
|
1653
|
+
return setUiAction(state, action);
|
1654
|
+
}
|
1655
|
+
return state;
|
1656
|
+
},
|
1657
|
+
record,
|
1658
|
+
onAction
|
1659
|
+
);
|
1660
|
+
}
|
1661
|
+
|
1662
|
+
// ../../node_modules/zustand/esm/vanilla.mjs
|
1663
|
+
init_react_import();
|
1664
|
+
var createStoreImpl = (createState) => {
|
1665
|
+
let state;
|
1666
|
+
const listeners = /* @__PURE__ */ new Set();
|
1667
|
+
const setState = (partial, replace) => {
|
1668
|
+
const nextState = typeof partial === "function" ? partial(state) : partial;
|
1669
|
+
if (!Object.is(nextState, state)) {
|
1670
|
+
const previousState = state;
|
1671
|
+
state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
|
1672
|
+
listeners.forEach((listener) => listener(state, previousState));
|
1673
|
+
}
|
1674
|
+
};
|
1675
|
+
const getState = () => state;
|
1676
|
+
const getInitialState = () => initialState;
|
1677
|
+
const subscribe = (listener) => {
|
1678
|
+
listeners.add(listener);
|
1679
|
+
return () => listeners.delete(listener);
|
1680
|
+
};
|
1681
|
+
const api = { setState, getState, getInitialState, subscribe };
|
1682
|
+
const initialState = state = createState(setState, getState, api);
|
1683
|
+
return api;
|
1684
|
+
};
|
1685
|
+
var createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
|
1686
|
+
|
1687
|
+
// ../../node_modules/zustand/esm/react.mjs
|
1688
|
+
init_react_import();
|
1689
|
+
import React2 from "react";
|
1690
|
+
var identity = (arg) => arg;
|
1691
|
+
function useStore(api, selector = identity) {
|
1692
|
+
const slice = React2.useSyncExternalStore(
|
1693
|
+
api.subscribe,
|
1694
|
+
() => selector(api.getState()),
|
1695
|
+
() => selector(api.getInitialState())
|
1696
|
+
);
|
1697
|
+
React2.useDebugValue(slice);
|
1698
|
+
return slice;
|
1699
|
+
}
|
1700
|
+
var createImpl = (createState) => {
|
1701
|
+
const api = createStore(createState);
|
1702
|
+
const useBoundStore = (selector) => useStore(api, selector);
|
1703
|
+
Object.assign(useBoundStore, api);
|
1704
|
+
return useBoundStore;
|
1705
|
+
};
|
1706
|
+
var create = (createState) => createState ? createImpl(createState) : createImpl;
|
1707
|
+
|
1708
|
+
// ../../node_modules/zustand/esm/middleware.mjs
|
1709
|
+
init_react_import();
|
1710
|
+
var subscribeWithSelectorImpl = (fn) => (set, get, api) => {
|
1711
|
+
const origSubscribe = api.subscribe;
|
1712
|
+
api.subscribe = (selector, optListener, options) => {
|
1713
|
+
let listener = selector;
|
1714
|
+
if (optListener) {
|
1715
|
+
const equalityFn = (options == null ? void 0 : options.equalityFn) || Object.is;
|
1716
|
+
let currentSlice = selector(api.getState());
|
1717
|
+
listener = (state) => {
|
1718
|
+
const nextSlice = selector(state);
|
1719
|
+
if (!equalityFn(currentSlice, nextSlice)) {
|
1720
|
+
const previousSlice = currentSlice;
|
1721
|
+
optListener(currentSlice = nextSlice, previousSlice);
|
1722
|
+
}
|
1723
|
+
};
|
1724
|
+
if (options == null ? void 0 : options.fireImmediately) {
|
1725
|
+
optListener(currentSlice, currentSlice);
|
1726
|
+
}
|
1727
|
+
}
|
1728
|
+
return origSubscribe(listener);
|
1729
|
+
};
|
1730
|
+
const initialState = fn(set, get, api);
|
1731
|
+
return initialState;
|
1732
|
+
};
|
1733
|
+
var subscribeWithSelector = subscribeWithSelectorImpl;
|
1734
|
+
|
1735
|
+
// ../core/store/index.ts
|
1736
|
+
import { createContext, useContext } from "react";
|
1737
|
+
|
1738
|
+
// ../core/store/slices/history.ts
|
1739
|
+
init_react_import();
|
1740
|
+
import { useEffect as useEffect2 } from "react";
|
1741
|
+
|
1742
|
+
// ../core/lib/use-hotkey.ts
|
1743
|
+
init_react_import();
|
1744
|
+
import { useEffect } from "react";
|
1745
|
+
var useHotkeyStore = create()(
|
1746
|
+
subscribeWithSelector((set) => ({
|
1747
|
+
held: {},
|
1748
|
+
hold: (key) => set((s) => s.held[key] ? s : { held: __spreadProps(__spreadValues({}, s.held), { [key]: true }) }),
|
1749
|
+
release: (key) => set((s) => s.held[key] ? { held: __spreadProps(__spreadValues({}, s.held), { [key]: false }) } : s),
|
1750
|
+
reset: (held = {}) => set(() => ({ held })),
|
1751
|
+
triggers: {}
|
1752
|
+
}))
|
1753
|
+
);
|
1754
|
+
|
1755
|
+
// ../core/store/slices/history.ts
|
1756
|
+
var EMPTY_HISTORY_INDEX = 0;
|
1757
|
+
function debounce(func, timeout = 300) {
|
1758
|
+
let timer;
|
1759
|
+
return (...args) => {
|
1760
|
+
clearTimeout(timer);
|
1761
|
+
timer = setTimeout(() => {
|
1762
|
+
func(...args);
|
1763
|
+
}, timeout);
|
1764
|
+
};
|
1765
|
+
}
|
1766
|
+
var tidyState = (state) => {
|
1767
|
+
return __spreadProps(__spreadValues({}, state), {
|
1768
|
+
ui: __spreadProps(__spreadValues({}, state.ui), {
|
1769
|
+
field: {
|
1770
|
+
focus: null
|
1771
|
+
}
|
1772
|
+
})
|
1773
|
+
});
|
1774
|
+
};
|
1775
|
+
var createHistorySlice = (set, get) => {
|
1776
|
+
const record = debounce((state) => {
|
1777
|
+
const { histories, index } = get().history;
|
1778
|
+
const history = {
|
1779
|
+
state,
|
1780
|
+
id: generateId("history")
|
1781
|
+
};
|
1782
|
+
const newHistories = [...histories.slice(0, index + 1), history];
|
1783
|
+
set({
|
1784
|
+
history: __spreadProps(__spreadValues({}, get().history), {
|
1785
|
+
histories: newHistories,
|
1786
|
+
index: newHistories.length - 1
|
1787
|
+
})
|
1788
|
+
});
|
1789
|
+
}, 250);
|
1790
|
+
return {
|
1791
|
+
initialAppState: {},
|
1792
|
+
index: EMPTY_HISTORY_INDEX,
|
1793
|
+
histories: [],
|
1794
|
+
hasPast: () => get().history.index > EMPTY_HISTORY_INDEX,
|
1795
|
+
hasFuture: () => get().history.index < get().history.histories.length - 1,
|
1796
|
+
prevHistory: () => {
|
1797
|
+
const { history } = get();
|
1798
|
+
return history.hasPast() ? history.histories[history.index - 1] : null;
|
1799
|
+
},
|
1800
|
+
nextHistory: () => {
|
1801
|
+
const s = get().history;
|
1802
|
+
return s.hasFuture() ? s.histories[s.index + 1] : null;
|
1803
|
+
},
|
1804
|
+
currentHistory: () => get().history.histories[get().history.index],
|
1805
|
+
back: () => {
|
1806
|
+
var _a;
|
1807
|
+
const { history, dispatch } = get();
|
1808
|
+
if (history.hasPast()) {
|
1809
|
+
const state = tidyState(
|
1810
|
+
((_a = history.prevHistory()) == null ? void 0 : _a.state) || history.initialAppState
|
1811
|
+
);
|
1812
|
+
dispatch({
|
1813
|
+
type: "set",
|
1814
|
+
state
|
1815
|
+
});
|
1816
|
+
set({ history: __spreadProps(__spreadValues({}, history), { index: history.index - 1 }) });
|
1817
|
+
}
|
1818
|
+
},
|
1819
|
+
forward: () => {
|
1820
|
+
var _a;
|
1821
|
+
const { history, dispatch } = get();
|
1822
|
+
if (history.hasFuture()) {
|
1823
|
+
const state = (_a = history.nextHistory()) == null ? void 0 : _a.state;
|
1824
|
+
dispatch({ type: "set", state: state ? tidyState(state) : {} });
|
1825
|
+
set({ history: __spreadProps(__spreadValues({}, history), { index: history.index + 1 }) });
|
1826
|
+
}
|
1827
|
+
},
|
1828
|
+
setHistories: (histories) => {
|
1829
|
+
var _a;
|
1830
|
+
const { dispatch, history } = get();
|
1831
|
+
dispatch({
|
1832
|
+
type: "set",
|
1833
|
+
state: ((_a = histories[histories.length - 1]) == null ? void 0 : _a.state) || history.initialAppState
|
1834
|
+
});
|
1835
|
+
set({ history: __spreadProps(__spreadValues({}, history), { histories, index: histories.length - 1 }) });
|
1836
|
+
},
|
1837
|
+
setHistoryIndex: (index) => {
|
1838
|
+
var _a;
|
1839
|
+
const { dispatch, history } = get();
|
1840
|
+
dispatch({
|
1841
|
+
type: "set",
|
1842
|
+
state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
|
1843
|
+
});
|
1844
|
+
set({ history: __spreadProps(__spreadValues({}, history), { index }) });
|
1845
|
+
},
|
1846
|
+
record
|
1847
|
+
};
|
1848
|
+
};
|
1849
|
+
|
1850
|
+
// ../core/store/slices/nodes.ts
|
1851
|
+
init_react_import();
|
1852
|
+
var createNodesSlice = (set, get) => ({
|
1853
|
+
nodes: {},
|
1854
|
+
registerNode: (id, node) => {
|
1855
|
+
const s = get().nodes;
|
1856
|
+
const emptyNode = {
|
1857
|
+
id,
|
1858
|
+
methods: {
|
1859
|
+
sync: () => null,
|
1860
|
+
hideOverlay: () => null,
|
1861
|
+
showOverlay: () => null
|
1862
|
+
},
|
1863
|
+
element: null
|
1864
|
+
};
|
1865
|
+
const existingNode = s.nodes[id];
|
1866
|
+
set({
|
1867
|
+
nodes: __spreadProps(__spreadValues({}, s), {
|
1868
|
+
nodes: __spreadProps(__spreadValues({}, s.nodes), {
|
1869
|
+
[id]: __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, emptyNode), existingNode), node), {
|
1870
|
+
id
|
1871
|
+
})
|
1872
|
+
})
|
1873
|
+
})
|
1874
|
+
});
|
1875
|
+
},
|
1876
|
+
unregisterNode: (id) => {
|
1877
|
+
const s = get().nodes;
|
1878
|
+
const existingNode = s.nodes[id];
|
1879
|
+
if (existingNode) {
|
1880
|
+
const newNodes = __spreadValues({}, s.nodes);
|
1881
|
+
delete newNodes[id];
|
1882
|
+
set({
|
1883
|
+
nodes: __spreadProps(__spreadValues({}, s), {
|
1884
|
+
nodes: newNodes
|
1885
|
+
})
|
1886
|
+
});
|
1887
|
+
}
|
1888
|
+
}
|
1889
|
+
});
|
1890
|
+
|
1891
|
+
// ../core/store/slices/permissions.ts
|
1892
|
+
init_react_import();
|
1893
|
+
import { useEffect as useEffect3 } from "react";
|
1894
|
+
|
1895
|
+
// ../core/lib/data/flatten-data.ts
|
1896
|
+
init_react_import();
|
1897
|
+
var flattenData = (state, config) => {
|
1898
|
+
const data = [];
|
1899
|
+
walkAppState(
|
1900
|
+
state,
|
1901
|
+
config,
|
1902
|
+
(content) => content,
|
1903
|
+
(item) => {
|
1904
|
+
data.push(item);
|
1905
|
+
return null;
|
1906
|
+
}
|
1907
|
+
);
|
1908
|
+
return data;
|
1909
|
+
};
|
1910
|
+
|
1911
|
+
// ../core/store/slices/permissions.ts
|
1912
|
+
var createPermissionsSlice = (set, get) => {
|
1913
|
+
const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
|
1914
|
+
const { state, permissions, config } = get();
|
1915
|
+
const { cache: cache2, globalPermissions } = permissions;
|
1916
|
+
const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
|
1917
|
+
var _a, _b, _c;
|
1918
|
+
const { config: config2, state: appState, setComponentLoading } = get();
|
1919
|
+
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
1920
|
+
if (!componentConfig) {
|
1921
|
+
return;
|
1922
|
+
}
|
1923
|
+
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
1924
|
+
if (componentConfig.resolvePermissions) {
|
1925
|
+
const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
|
1926
|
+
if (Object.values(changed).some((el) => el === true) || force2) {
|
1927
|
+
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
1928
|
+
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
1929
|
+
item2,
|
1930
|
+
{
|
1931
|
+
changed,
|
1932
|
+
lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
|
1933
|
+
permissions: initialPermissions,
|
1934
|
+
appState: makeStatePublic(appState),
|
1935
|
+
lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
|
1936
|
+
}
|
1937
|
+
);
|
1938
|
+
const latest = get().permissions;
|
1939
|
+
set({
|
1940
|
+
permissions: __spreadProps(__spreadValues({}, latest), {
|
1941
|
+
cache: __spreadProps(__spreadValues({}, latest.cache), {
|
1942
|
+
[item2.props.id]: {
|
1943
|
+
lastData: item2,
|
1944
|
+
lastPermissions: resolvedPermissions
|
1945
|
+
}
|
1946
|
+
}),
|
1947
|
+
resolvedPermissions: __spreadProps(__spreadValues({}, latest.resolvedPermissions), {
|
1948
|
+
[item2.props.id]: resolvedPermissions
|
1949
|
+
})
|
1950
|
+
})
|
1951
|
+
});
|
1952
|
+
clearTimeout2();
|
1953
|
+
}
|
1954
|
+
}
|
1955
|
+
});
|
1956
|
+
const resolveDataForRoot = (force2 = false) => {
|
1957
|
+
const { state: appState } = get();
|
1958
|
+
resolveDataForItem(
|
1959
|
+
// Shim the root data in by conforming to component data shape
|
1960
|
+
{
|
1961
|
+
type: "root",
|
1962
|
+
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "root" })
|
1963
|
+
},
|
1964
|
+
force2
|
1965
|
+
);
|
1966
|
+
};
|
1967
|
+
const { item, type, root } = params;
|
1968
|
+
if (item) {
|
1969
|
+
yield resolveDataForItem(item, force);
|
1970
|
+
} else if (type) {
|
1971
|
+
flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(void 0, null, function* () {
|
1972
|
+
yield resolveDataForItem(item2, force);
|
1973
|
+
}));
|
1974
|
+
} else if (root) {
|
1975
|
+
resolveDataForRoot(force);
|
1976
|
+
} else {
|
1977
|
+
flattenData(state, config).map((item2) => __async(void 0, null, function* () {
|
1978
|
+
yield resolveDataForItem(item2, force);
|
1979
|
+
}));
|
1980
|
+
}
|
1981
|
+
});
|
1982
|
+
const refreshPermissions = (params) => resolvePermissions(params, true);
|
1983
|
+
return {
|
1984
|
+
cache: {},
|
1985
|
+
globalPermissions: {
|
1986
|
+
drag: true,
|
1987
|
+
edit: true,
|
1988
|
+
delete: true,
|
1989
|
+
duplicate: true,
|
1990
|
+
insert: true
|
1991
|
+
},
|
1992
|
+
resolvedPermissions: {},
|
1993
|
+
getPermissions: ({ item, type, root } = {}) => {
|
1994
|
+
const { config, permissions } = get();
|
1995
|
+
const { globalPermissions, resolvedPermissions } = permissions;
|
1996
|
+
if (item) {
|
1997
|
+
const componentConfig = config.components[item.type];
|
1998
|
+
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
|
1999
|
+
const resolvedForItem = resolvedPermissions[item.props.id];
|
2000
|
+
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
2001
|
+
} else if (type) {
|
2002
|
+
const componentConfig = config.components[type];
|
2003
|
+
return __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
|
2004
|
+
} else if (root) {
|
2005
|
+
const rootConfig = config.root;
|
2006
|
+
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
|
2007
|
+
const resolvedForItem = resolvedPermissions["root"];
|
2008
|
+
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
2009
|
+
}
|
2010
|
+
return globalPermissions;
|
2011
|
+
},
|
2012
|
+
resolvePermissions,
|
2013
|
+
refreshPermissions
|
2014
|
+
};
|
2015
|
+
};
|
2016
|
+
|
2017
|
+
// ../core/store/slices/fields.ts
|
2018
|
+
init_react_import();
|
2019
|
+
import { useCallback, useEffect as useEffect4 } from "react";
|
2020
|
+
var createFieldsSlice = (_set, _get) => {
|
2021
|
+
return {
|
2022
|
+
fields: {},
|
2023
|
+
loading: false,
|
2024
|
+
lastResolvedData: {},
|
2025
|
+
id: void 0
|
2026
|
+
};
|
2027
|
+
};
|
2028
|
+
|
2029
|
+
// ../core/lib/data/to-root.ts
|
2030
|
+
init_react_import();
|
2031
|
+
var toRoot = (item) => {
|
2032
|
+
if ("type" in item && item.type !== "root") {
|
2033
|
+
throw new Error("Converting non-root item to root.");
|
2034
|
+
}
|
2035
|
+
const { readOnly } = item;
|
2036
|
+
if (item.props) {
|
2037
|
+
if ("id" in item.props) {
|
2038
|
+
const _a = item.props, { id } = _a, props = __objRest(_a, ["id"]);
|
2039
|
+
return { props, readOnly };
|
2040
|
+
}
|
2041
|
+
return { props: item.props, readOnly };
|
2042
|
+
}
|
2043
|
+
return { props: {}, readOnly };
|
2044
|
+
};
|
2045
|
+
|
2046
|
+
// ../core/store/index.ts
|
2047
|
+
var defaultPageFields = {
|
2048
|
+
title: { type: "text" }
|
2049
|
+
};
|
2050
|
+
var createAppStore = (initialAppStore) => create()(
|
2051
|
+
subscribeWithSelector((set, get) => {
|
2052
|
+
var _a, _b;
|
2053
|
+
return __spreadProps(__spreadValues({
|
2054
|
+
state: defaultAppState,
|
2055
|
+
config: { components: {} },
|
2056
|
+
componentState: {},
|
2057
|
+
plugins: [],
|
2058
|
+
overrides: {},
|
2059
|
+
viewports: defaultViewports,
|
2060
|
+
zoomConfig: {
|
2061
|
+
autoZoom: 1,
|
2062
|
+
rootHeight: 0,
|
2063
|
+
zoom: 1
|
2064
|
+
},
|
2065
|
+
status: "LOADING",
|
2066
|
+
iframe: {},
|
2067
|
+
metadata: {}
|
2068
|
+
}, initialAppStore), {
|
2069
|
+
fields: createFieldsSlice(set, get),
|
2070
|
+
history: createHistorySlice(set, get),
|
2071
|
+
nodes: createNodesSlice(set, get),
|
2072
|
+
permissions: createPermissionsSlice(set, get),
|
2073
|
+
getComponentConfig: (type) => {
|
2074
|
+
var _a2;
|
2075
|
+
const { config, selectedItem } = get();
|
2076
|
+
const rootFields = ((_a2 = config.root) == null ? void 0 : _a2.fields) || defaultPageFields;
|
2077
|
+
return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
|
2078
|
+
},
|
2079
|
+
selectedItem: ((_a = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _a.ui.itemSelector) ? getItem(
|
2080
|
+
(_b = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _b.ui.itemSelector,
|
2081
|
+
initialAppStore.state
|
2082
|
+
) : null,
|
2083
|
+
dispatch: (action) => set((s) => {
|
2084
|
+
var _a2, _b2;
|
2085
|
+
const { record } = get().history;
|
2086
|
+
const dispatch = createReducer({
|
2087
|
+
record,
|
2088
|
+
appStore: s
|
2089
|
+
});
|
2090
|
+
const state = dispatch(s.state, action);
|
2091
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
2092
|
+
(_b2 = (_a2 = get()).onAction) == null ? void 0 : _b2.call(_a2, action, state, get().state);
|
2093
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
2094
|
+
}),
|
2095
|
+
setZoomConfig: (zoomConfig) => set({ zoomConfig }),
|
2096
|
+
setStatus: (status) => set({ status }),
|
2097
|
+
setComponentState: (componentState) => set({ componentState }),
|
2098
|
+
pendingLoadTimeouts: {},
|
2099
|
+
setComponentLoading: (id, loading = true, defer = 0) => {
|
2100
|
+
const { setComponentState, pendingLoadTimeouts } = get();
|
2101
|
+
const loadId = generateId();
|
2102
|
+
const setLoading = () => {
|
2103
|
+
var _a2;
|
2104
|
+
const { componentState } = get();
|
2105
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
2106
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
2107
|
+
loadingCount: (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) + 1
|
2108
|
+
})
|
2109
|
+
}));
|
2110
|
+
};
|
2111
|
+
const unsetLoading = () => {
|
2112
|
+
var _a2;
|
2113
|
+
const { componentState } = get();
|
2114
|
+
clearTimeout(timeout);
|
2115
|
+
delete pendingLoadTimeouts[loadId];
|
2116
|
+
set({ pendingLoadTimeouts });
|
2117
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
2118
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
2119
|
+
loadingCount: Math.max(
|
2120
|
+
(((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) - 1,
|
2121
|
+
0
|
2122
|
+
)
|
2123
|
+
})
|
2124
|
+
}));
|
2125
|
+
};
|
2126
|
+
const timeout = setTimeout(() => {
|
2127
|
+
if (loading) {
|
2128
|
+
setLoading();
|
2129
|
+
} else {
|
2130
|
+
unsetLoading();
|
2131
|
+
}
|
2132
|
+
delete pendingLoadTimeouts[loadId];
|
2133
|
+
set({ pendingLoadTimeouts });
|
2134
|
+
}, defer);
|
2135
|
+
set({
|
2136
|
+
pendingLoadTimeouts: __spreadProps(__spreadValues({}, pendingLoadTimeouts), {
|
2137
|
+
[id]: timeout
|
2138
|
+
})
|
2139
|
+
});
|
2140
|
+
return unsetLoading;
|
2141
|
+
},
|
2142
|
+
unsetComponentLoading: (id) => {
|
2143
|
+
const { setComponentLoading } = get();
|
2144
|
+
setComponentLoading(id, false);
|
2145
|
+
},
|
2146
|
+
// Helper
|
2147
|
+
setUi: (ui, recordHistory) => set((s) => {
|
2148
|
+
const dispatch = createReducer({
|
2149
|
+
record: () => {
|
2150
|
+
},
|
2151
|
+
appStore: s
|
2152
|
+
});
|
2153
|
+
const state = dispatch(s.state, {
|
2154
|
+
type: "setUi",
|
2155
|
+
ui,
|
2156
|
+
recordHistory
|
2157
|
+
});
|
2158
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
2159
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
2160
|
+
}),
|
2161
|
+
resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
|
2162
|
+
const { config, metadata, setComponentLoading, permissions } = get();
|
2163
|
+
const timeouts = {};
|
2164
|
+
return yield resolveComponentData(
|
2165
|
+
componentData,
|
2166
|
+
config,
|
2167
|
+
metadata,
|
2168
|
+
(item) => {
|
2169
|
+
const id = "id" in item.props ? item.props.id : "root";
|
2170
|
+
timeouts[id] = setComponentLoading(id, true, 50);
|
2171
|
+
},
|
2172
|
+
(item) => __async(void 0, null, function* () {
|
2173
|
+
const id = "id" in item.props ? item.props.id : "root";
|
2174
|
+
if ("type" in item) {
|
2175
|
+
yield permissions.refreshPermissions({ item });
|
2176
|
+
} else {
|
2177
|
+
yield permissions.refreshPermissions({ root: true });
|
2178
|
+
}
|
2179
|
+
timeouts[id]();
|
2180
|
+
}),
|
2181
|
+
trigger
|
2182
|
+
);
|
2183
|
+
}),
|
2184
|
+
resolveAndCommitData: () => __async(void 0, null, function* () {
|
2185
|
+
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
2186
|
+
walkAppState(
|
2187
|
+
state,
|
2188
|
+
config,
|
2189
|
+
(content) => content,
|
2190
|
+
(childItem) => {
|
2191
|
+
resolveComponentData2(childItem, "load").then((resolved) => {
|
2192
|
+
const { state: state2 } = get();
|
2193
|
+
const node = state2.indexes.nodes[resolved.node.props.id];
|
2194
|
+
if (node && resolved.didChange) {
|
2195
|
+
if (resolved.node.props.id === "root") {
|
2196
|
+
dispatch({
|
2197
|
+
type: "replaceRoot",
|
2198
|
+
root: toRoot(resolved.node)
|
2199
|
+
});
|
2200
|
+
} else {
|
2201
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
2202
|
+
const parentZone = state2.indexes.zones[zoneCompound];
|
2203
|
+
const index = parentZone.contentIds.indexOf(
|
2204
|
+
resolved.node.props.id
|
2205
|
+
);
|
2206
|
+
dispatch({
|
2207
|
+
type: "replace",
|
2208
|
+
data: resolved.node,
|
2209
|
+
destinationIndex: index,
|
2210
|
+
destinationZone: zoneCompound
|
2211
|
+
});
|
2212
|
+
}
|
2213
|
+
}
|
2214
|
+
});
|
2215
|
+
return childItem;
|
2216
|
+
}
|
2217
|
+
);
|
2218
|
+
})
|
2219
|
+
});
|
2220
|
+
})
|
2221
|
+
);
|
2222
|
+
var appStoreContext = createContext(createAppStore());
|
2223
|
+
function useAppStore(selector) {
|
2224
|
+
const context = useContext(appStoreContext);
|
2225
|
+
return useStore(context, selector);
|
2226
|
+
}
|
2227
|
+
function useAppStoreApi() {
|
2228
|
+
return useContext(appStoreContext);
|
2229
|
+
}
|
2230
|
+
|
2231
|
+
// ../core/lib/use-breadcrumbs.ts
|
2232
|
+
var useBreadcrumbs = (renderCount) => {
|
2233
|
+
const selectedId = useAppStore((s) => {
|
2234
|
+
var _a;
|
2235
|
+
return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
|
2236
|
+
});
|
2237
|
+
const config = useAppStore((s) => s.config);
|
2238
|
+
const path = useAppStore((s) => {
|
2239
|
+
var _a;
|
2240
|
+
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
2241
|
+
});
|
2242
|
+
const appStore = useAppStoreApi();
|
2243
|
+
return useMemo2(() => {
|
2244
|
+
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
2245
|
+
var _a, _b, _c;
|
2246
|
+
const [componentId] = zoneCompound.split(":");
|
2247
|
+
if (componentId === "root") {
|
2248
|
+
return {
|
2249
|
+
label: "Page",
|
2250
|
+
selector: null
|
2251
|
+
};
|
2252
|
+
}
|
2253
|
+
const node = appStore.getState().state.indexes.nodes[componentId];
|
2254
|
+
const parentId = node.path[node.path.length - 1];
|
2255
|
+
const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
|
2256
|
+
const index = contentIds.indexOf(componentId);
|
2257
|
+
const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
|
2258
|
+
return {
|
2259
|
+
label,
|
2260
|
+
selector: node ? {
|
2261
|
+
index,
|
2262
|
+
zone: node.path[node.path.length - 1]
|
2263
|
+
} : null
|
2264
|
+
};
|
2265
|
+
})) || [];
|
2266
|
+
if (renderCount) {
|
2267
|
+
return breadcrumbs.slice(breadcrumbs.length - renderCount);
|
2268
|
+
}
|
2269
|
+
return breadcrumbs;
|
2270
|
+
}, [path, renderCount]);
|
2271
|
+
};
|
2272
|
+
|
2273
|
+
// ../core/components/Loader/index.tsx
|
2274
|
+
init_react_import();
|
2275
|
+
|
2276
|
+
// ../core/lib/index.ts
|
2277
|
+
init_react_import();
|
2278
|
+
|
2279
|
+
// ../core/lib/filter.ts
|
2280
|
+
init_react_import();
|
2281
|
+
|
2282
|
+
// ../core/lib/data/reorder.ts
|
2283
|
+
init_react_import();
|
2284
|
+
|
2285
|
+
// ../core/lib/data/replace.ts
|
2286
|
+
init_react_import();
|
2287
|
+
|
2288
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
|
2289
|
+
init_react_import();
|
2290
|
+
var styles_module_default3 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
|
2291
|
+
|
2292
|
+
// ../core/components/Loader/index.tsx
|
2293
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
2294
|
+
var getClassName2 = get_class_name_factory_default("Loader", styles_module_default3);
|
2295
|
+
var Loader = (_a) => {
|
2296
|
+
var _b = _a, {
|
2297
|
+
color,
|
2298
|
+
size = 16
|
2299
|
+
} = _b, props = __objRest(_b, [
|
2300
|
+
"color",
|
2301
|
+
"size"
|
2302
|
+
]);
|
2303
|
+
return /* @__PURE__ */ jsx4(
|
2304
|
+
"span",
|
2305
|
+
__spreadValues({
|
2306
|
+
className: getClassName2(),
|
2307
|
+
style: {
|
2308
|
+
width: size,
|
2309
|
+
height: size,
|
2310
|
+
color
|
2311
|
+
},
|
2312
|
+
"aria-label": "loading"
|
2313
|
+
}, props)
|
2314
|
+
);
|
2315
|
+
};
|
2316
|
+
|
2317
|
+
// ../core/components/SidebarSection/index.tsx
|
2318
|
+
import { jsx as jsx5, jsxs } from "react/jsx-runtime";
|
2319
|
+
var getClassName3 = get_class_name_factory_default("SidebarSection", styles_module_default);
|
2320
|
+
var SidebarSection = ({
|
2321
|
+
children,
|
2322
|
+
title,
|
2323
|
+
background,
|
2324
|
+
showBreadcrumbs,
|
2325
|
+
noBorderTop,
|
2326
|
+
noPadding,
|
2327
|
+
isLoading
|
2328
|
+
}) => {
|
2329
|
+
const setUi = useAppStore((s) => s.setUi);
|
2330
|
+
const breadcrumbs = useBreadcrumbs(1);
|
2331
|
+
return /* @__PURE__ */ jsxs(
|
2332
|
+
"div",
|
2333
|
+
{
|
2334
|
+
className: getClassName3({ noBorderTop, noPadding }),
|
2335
|
+
style: { background },
|
2336
|
+
children: [
|
2337
|
+
/* @__PURE__ */ jsx5("div", { className: getClassName3("title"), children: /* @__PURE__ */ jsxs("div", { className: getClassName3("breadcrumbs"), children: [
|
2338
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs("div", { className: getClassName3("breadcrumb"), children: [
|
2339
|
+
/* @__PURE__ */ jsx5(
|
2340
|
+
"button",
|
2341
|
+
{
|
2342
|
+
type: "button",
|
2343
|
+
className: getClassName3("breadcrumbLabel"),
|
2344
|
+
onClick: () => setUi({ itemSelector: breadcrumb.selector }),
|
2345
|
+
children: breadcrumb.label
|
2346
|
+
}
|
2347
|
+
),
|
2348
|
+
/* @__PURE__ */ jsx5(ChevronRight, { size: 16 })
|
2349
|
+
] }, i)) : null,
|
2350
|
+
/* @__PURE__ */ jsx5("div", { className: getClassName3("heading"), children: /* @__PURE__ */ jsx5(Heading, { rank: "2", size: "xs", children: title }) })
|
2351
|
+
] }) }),
|
2352
|
+
/* @__PURE__ */ jsx5("div", { className: getClassName3("content"), children }),
|
2353
|
+
isLoading && /* @__PURE__ */ jsx5("div", { className: getClassName3("loadingOverlay"), children: /* @__PURE__ */ jsx5(Loader, { size: 32 }) })
|
2354
|
+
]
|
2355
|
+
}
|
2356
|
+
);
|
2357
|
+
};
|
2358
|
+
|
2359
|
+
// ../core/components/OutlineList/index.tsx
|
2360
|
+
init_react_import();
|
2361
|
+
|
2362
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/OutlineList/styles.module.css#css-module
|
2363
|
+
init_react_import();
|
2364
|
+
var styles_module_default4 = { "OutlineList": "_OutlineList_w4lzv_1", "OutlineListItem": "_OutlineListItem_w4lzv_25", "OutlineListItem--clickable": "_OutlineListItem--clickable_w4lzv_45" };
|
2365
|
+
|
2366
|
+
// ../core/components/OutlineList/index.tsx
|
2367
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
2368
|
+
var getClassName4 = get_class_name_factory_default("OutlineList", styles_module_default4);
|
2369
|
+
var getClassNameItem = get_class_name_factory_default("OutlineListItem", styles_module_default4);
|
2370
|
+
var OutlineList = ({ children }) => {
|
2371
|
+
return /* @__PURE__ */ jsx6("ul", { className: getClassName4(), children });
|
2372
|
+
};
|
2373
|
+
OutlineList.Clickable = ({ children }) => /* @__PURE__ */ jsx6("div", { className: getClassNameItem({ clickable: true }), children });
|
2374
|
+
OutlineList.Item = ({
|
2375
|
+
children,
|
2376
|
+
onClick
|
2377
|
+
}) => {
|
2378
|
+
return /* @__PURE__ */ jsx6(
|
2379
|
+
"li",
|
2380
|
+
{
|
2381
|
+
className: getClassNameItem({ clickable: !!onClick }),
|
2382
|
+
onClick,
|
2383
|
+
children
|
2384
|
+
}
|
2385
|
+
);
|
2386
|
+
};
|
2387
|
+
|
2388
|
+
// ../core/lib/scroll-into-view.ts
|
2389
|
+
init_react_import();
|
2390
|
+
var scrollIntoView = (el) => {
|
2391
|
+
const oldStyle = __spreadValues({}, el.style);
|
2392
|
+
el.style.scrollMargin = "256px";
|
2393
|
+
if (el) {
|
2394
|
+
el == null ? void 0 : el.scrollIntoView({ behavior: "smooth" });
|
2395
|
+
el.style.scrollMargin = oldStyle.scrollMargin || "";
|
2396
|
+
}
|
2397
|
+
};
|
2398
|
+
|
2399
|
+
// ../core/lib/get-frame.ts
|
2400
|
+
init_react_import();
|
2401
|
+
var getFrame = () => {
|
2402
|
+
if (typeof window === "undefined") return;
|
2403
|
+
let frameEl = document.querySelector("#preview-frame");
|
2404
|
+
if ((frameEl == null ? void 0 : frameEl.tagName) === "IFRAME") {
|
2405
|
+
return frameEl.contentDocument || document;
|
2406
|
+
}
|
2407
|
+
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
2408
|
+
};
|
2409
|
+
|
2410
|
+
// src/HeadingAnalyzer.tsx
|
2411
|
+
import ReactFromJSONModule from "react-from-json";
|
2412
|
+
import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
|
2413
|
+
var getClassName5 = get_class_name_factory_default("HeadingAnalyzer", HeadingAnalyzer_module_default);
|
2414
|
+
var getClassNameItem2 = get_class_name_factory_default("HeadingAnalyzerItem", HeadingAnalyzer_module_default);
|
2415
|
+
var ReactFromJSON = ReactFromJSONModule.default || ReactFromJSONModule;
|
2416
|
+
var getOutline = ({ frame } = {}) => {
|
2417
|
+
const headings = (frame == null ? void 0 : frame.querySelectorAll("h1,h2,h3,h4,h5,h6")) || [];
|
2418
|
+
const _outline = [];
|
2419
|
+
headings.forEach((item, i) => {
|
2420
|
+
if (item.closest("[data-dnd-dragging]")) {
|
2421
|
+
return;
|
2422
|
+
}
|
2423
|
+
_outline.push({
|
2424
|
+
rank: parseInt(item.tagName.split("H")[1]),
|
2425
|
+
text: item.textContent,
|
2426
|
+
element: item
|
2427
|
+
});
|
2428
|
+
});
|
2429
|
+
return _outline;
|
2430
|
+
};
|
2431
|
+
function buildHierarchy(frame) {
|
2432
|
+
var _a, _b;
|
2433
|
+
const headings = getOutline({ frame });
|
2434
|
+
const root = { rank: 0, children: [], text: "" };
|
2435
|
+
let path = [root];
|
2436
|
+
for (let heading of headings) {
|
2437
|
+
const node = {
|
2438
|
+
rank: heading.rank,
|
2439
|
+
text: heading.text,
|
2440
|
+
children: [],
|
2441
|
+
element: heading.element
|
2442
|
+
};
|
2443
|
+
if (node.rank === 1) {
|
2444
|
+
path = [root];
|
2445
|
+
} else {
|
2446
|
+
while (path[path.length - 1].rank >= node.rank) {
|
2447
|
+
path.pop();
|
2448
|
+
}
|
2449
|
+
while (path.length < node.rank) {
|
2450
|
+
const missingNode = {
|
2451
|
+
rank: path.length,
|
2452
|
+
missing: true,
|
2453
|
+
children: [],
|
2454
|
+
text: ""
|
2455
|
+
};
|
2456
|
+
(_a = path[path.length - 1].children) == null ? void 0 : _a.push(missingNode);
|
2457
|
+
path.push(missingNode);
|
2458
|
+
}
|
2459
|
+
}
|
2460
|
+
(_b = path[path.length - 1].children) == null ? void 0 : _b.push(node);
|
2461
|
+
path.push(node);
|
2462
|
+
}
|
2463
|
+
return root.children;
|
2464
|
+
}
|
2465
|
+
var usePuck = createUsePuck();
|
2466
|
+
var HeadingAnalyzer = () => {
|
2467
|
+
const data = usePuck((s) => s.appState.data);
|
2468
|
+
const [hierarchy, setHierarchy] = useState([]);
|
2469
|
+
useEffect5(() => {
|
2470
|
+
const frame = getFrame();
|
2471
|
+
let entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
2472
|
+
const createHierarchy = () => {
|
2473
|
+
setHierarchy(buildHierarchy(entry));
|
2474
|
+
};
|
2475
|
+
const entryObserver = new MutationObserver(() => {
|
2476
|
+
createHierarchy();
|
2477
|
+
});
|
2478
|
+
const frameObserver = new MutationObserver(() => {
|
2479
|
+
entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
2480
|
+
if (entry) {
|
2481
|
+
registerEntryObserver();
|
2482
|
+
frameObserver.disconnect();
|
2483
|
+
}
|
2484
|
+
});
|
2485
|
+
const registerEntryObserver = () => {
|
2486
|
+
if (!entry) return;
|
2487
|
+
entryObserver.observe(entry, { subtree: true, childList: true });
|
2488
|
+
};
|
2489
|
+
const registerFrameObserver = () => {
|
2490
|
+
if (!frame) return;
|
2491
|
+
frameObserver.observe(frame, { subtree: true, childList: true });
|
2492
|
+
};
|
2493
|
+
if (entry) {
|
2494
|
+
createHierarchy();
|
2495
|
+
registerEntryObserver();
|
2496
|
+
} else {
|
2497
|
+
registerFrameObserver();
|
2498
|
+
}
|
2499
|
+
return () => {
|
2500
|
+
entryObserver.disconnect();
|
2501
|
+
frameObserver.disconnect();
|
2502
|
+
};
|
2503
|
+
}, [data]);
|
2504
|
+
return /* @__PURE__ */ jsxs2("div", { className: getClassName5(), children: [
|
2505
|
+
/* @__PURE__ */ jsxs2(
|
2506
|
+
"small",
|
2507
|
+
{
|
2508
|
+
className: getClassName5("cssWarning"),
|
2509
|
+
style: {
|
2510
|
+
color: "var(--puck-color-red-04)",
|
2511
|
+
display: "block",
|
2512
|
+
marginBottom: 16
|
2513
|
+
},
|
2514
|
+
children: [
|
2515
|
+
"Heading analyzer styles not loaded. Please review the",
|
2516
|
+
" ",
|
2517
|
+
/* @__PURE__ */ jsx7("a", { href: "https://github.com/measuredco/puck/blob/main/packages/plugin-heading-analyzer/README.md", children: "README" }),
|
2518
|
+
"."
|
2519
|
+
]
|
2520
|
+
}
|
2521
|
+
),
|
2522
|
+
hierarchy.length === 0 && /* @__PURE__ */ jsx7("div", { children: "No headings." }),
|
2523
|
+
/* @__PURE__ */ jsx7(OutlineList, { children: /* @__PURE__ */ jsx7(
|
2524
|
+
ReactFromJSON,
|
2525
|
+
{
|
2526
|
+
mapping: {
|
2527
|
+
Root: (props) => /* @__PURE__ */ jsx7(Fragment2, { children: props.children }),
|
2528
|
+
OutlineListItem: (props) => /* @__PURE__ */ jsxs2(OutlineList.Item, { children: [
|
2529
|
+
/* @__PURE__ */ jsx7(OutlineList.Clickable, { children: /* @__PURE__ */ jsx7(
|
2530
|
+
"small",
|
2531
|
+
{
|
2532
|
+
className: getClassNameItem2({ missing: props.missing }),
|
2533
|
+
onClick: typeof props.element == "undefined" ? void 0 : (e) => {
|
2534
|
+
e.stopPropagation();
|
2535
|
+
const el = props.element;
|
2536
|
+
const oldStyle = __spreadValues({}, el.style);
|
2537
|
+
if (el) {
|
2538
|
+
scrollIntoView(el);
|
2539
|
+
el.style.outline = "4px solid var(--puck-color-rose-06)";
|
2540
|
+
el.style.outlineOffset = "4px";
|
2541
|
+
setTimeout(() => {
|
2542
|
+
el.style.outline = oldStyle.outline || "";
|
2543
|
+
el.style.outlineOffset = oldStyle.outlineOffset || "";
|
2544
|
+
}, 2e3);
|
2545
|
+
}
|
2546
|
+
},
|
2547
|
+
children: props.missing ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
2548
|
+
/* @__PURE__ */ jsxs2("b", { children: [
|
2549
|
+
"H",
|
2550
|
+
props.rank
|
2551
|
+
] }),
|
2552
|
+
": Missing"
|
2553
|
+
] }) : /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
2554
|
+
/* @__PURE__ */ jsxs2("b", { children: [
|
2555
|
+
"H",
|
2556
|
+
props.rank
|
2557
|
+
] }),
|
2558
|
+
": ",
|
2559
|
+
props.text
|
2560
|
+
] })
|
2561
|
+
}
|
2562
|
+
) }),
|
2563
|
+
/* @__PURE__ */ jsx7(OutlineList, { children: props.children })
|
2564
|
+
] })
|
2565
|
+
},
|
2566
|
+
entry: {
|
2567
|
+
props: { children: hierarchy },
|
2568
|
+
type: "Root"
|
2569
|
+
},
|
489
2570
|
mapProp: (prop) => {
|
490
2571
|
if (prop && prop.rank) {
|
491
2572
|
return {
|
@@ -500,10 +2581,12 @@ var HeadingAnalyzer = () => {
|
|
500
2581
|
] });
|
501
2582
|
};
|
502
2583
|
var headingAnalyzer = {
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
2584
|
+
overrides: {
|
2585
|
+
fields: ({ children, itemSelector }) => /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
2586
|
+
children,
|
2587
|
+
/* @__PURE__ */ jsx7("div", { style: { display: itemSelector ? "none" : "block" }, children: /* @__PURE__ */ jsx7(SidebarSection, { title: "Heading Outline", children: /* @__PURE__ */ jsx7(HeadingAnalyzer, {}) }) })
|
2588
|
+
] })
|
2589
|
+
}
|
507
2590
|
};
|
508
2591
|
var HeadingAnalyzer_default = headingAnalyzer;
|
509
2592
|
export {
|
@@ -550,7 +2633,7 @@ lucide-react/dist/esm/createLucideIcon.js:
|
|
550
2633
|
* See the LICENSE file in the root directory of this source tree.
|
551
2634
|
*)
|
552
2635
|
|
553
|
-
lucide-react/dist/esm/icons/
|
2636
|
+
lucide-react/dist/esm/icons/chevron-right.js:
|
554
2637
|
(**
|
555
2638
|
* @license lucide-react v0.468.0 - ISC
|
556
2639
|
*
|