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