@measured/puck-plugin-heading-analyzer 0.20.0-canary.755737e8 → 0.20.0-canary.8909f8cc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +145 -0
- package/dist/index.d.mts +16 -32
- package/dist/index.d.ts +16 -32
- package/dist/index.js +2016 -69
- package/dist/index.mjs +2015 -68
- package/package.json +2 -2
package/dist/index.js
CHANGED
@@ -61,6 +61,26 @@ 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
|
+
};
|
64
84
|
|
65
85
|
// ../tsup-config/react-import.js
|
66
86
|
var import_react;
|
@@ -133,6 +153,156 @@ var require_classnames = __commonJS({
|
|
133
153
|
}
|
134
154
|
});
|
135
155
|
|
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
|
+
|
136
306
|
// index.ts
|
137
307
|
var plugin_heading_analyzer_exports = {};
|
138
308
|
__export(plugin_heading_analyzer_exports, {
|
@@ -143,7 +313,7 @@ init_react_import();
|
|
143
313
|
|
144
314
|
// src/HeadingAnalyzer.tsx
|
145
315
|
init_react_import();
|
146
|
-
var
|
316
|
+
var import_react12 = require("react");
|
147
317
|
|
148
318
|
// css-module:/home/runner/work/puck/puck/packages/plugin-heading-analyzer/src/HeadingAnalyzer.module.css#css-module
|
149
319
|
init_react_import();
|
@@ -152,12 +322,12 @@ var HeadingAnalyzer_module_default = { "HeadingAnalyzer": "_HeadingAnalyzer_116v
|
|
152
322
|
// src/HeadingAnalyzer.tsx
|
153
323
|
var import_puck = require("@measured/puck");
|
154
324
|
|
155
|
-
// ../core/components/
|
325
|
+
// ../core/components/SidebarSection/index.tsx
|
156
326
|
init_react_import();
|
157
327
|
|
158
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/
|
328
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
159
329
|
init_react_import();
|
160
|
-
var styles_module_default = { "
|
330
|
+
var styles_module_default = { "SidebarSection": "_SidebarSection_8boj8_1", "SidebarSection-title": "_SidebarSection-title_8boj8_12", "SidebarSection--noBorderTop": "_SidebarSection--noBorderTop_8boj8_20", "SidebarSection-content": "_SidebarSection-content_8boj8_24", "SidebarSection--noPadding": "_SidebarSection--noPadding_8boj8_28", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_8boj8_41", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_8boj8_70", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_8boj8_41", "SidebarSection-heading": "_SidebarSection-heading_8boj8_82", "SidebarSection-loadingOverlay": "_SidebarSection-loadingOverlay_8boj8_86" };
|
161
331
|
|
162
332
|
// ../core/lib/get-class-name-factory.ts
|
163
333
|
init_react_import();
|
@@ -186,50 +356,29 @@ var getClassNameFactory = (rootClass, styles, config = { baseClass: "" }) => (op
|
|
186
356
|
};
|
187
357
|
var get_class_name_factory_default = getClassNameFactory;
|
188
358
|
|
189
|
-
// ../core/components/
|
359
|
+
// ../core/components/Heading/index.tsx
|
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
|
190
367
|
var import_jsx_runtime = require("react/jsx-runtime");
|
191
|
-
var getClassName = get_class_name_factory_default("
|
192
|
-
var
|
193
|
-
|
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
|
-
}) => {
|
368
|
+
var getClassName = get_class_name_factory_default("Heading", styles_module_default2);
|
369
|
+
var Heading = ({ children, rank, size = "m" }) => {
|
370
|
+
const Tag = rank ? `h${rank}` : "span";
|
201
371
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
202
|
-
|
372
|
+
Tag,
|
203
373
|
{
|
204
|
-
className:
|
205
|
-
|
374
|
+
className: getClassName({
|
375
|
+
[size]: true
|
376
|
+
}),
|
206
377
|
children
|
207
378
|
}
|
208
379
|
);
|
209
380
|
};
|
210
381
|
|
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
|
-
|
233
382
|
// ../../node_modules/lucide-react/dist/esm/lucide-react.js
|
234
383
|
init_react_import();
|
235
384
|
|
@@ -317,15 +466,1682 @@ var createLucideIcon = (iconName, iconNode) => {
|
|
317
466
|
return Component;
|
318
467
|
};
|
319
468
|
|
320
|
-
// ../../node_modules/lucide-react/dist/esm/icons/
|
469
|
+
// ../../node_modules/lucide-react/dist/esm/icons/chevron-right.js
|
321
470
|
init_react_import();
|
322
|
-
var
|
323
|
-
["path", { d: "
|
324
|
-
["path", { d: "M4 18V6", key: "1rz3zl" }],
|
325
|
-
["path", { d: "M12 18V6", key: "zqpxq5" }],
|
326
|
-
["path", { d: "m17 12 3-2v8", key: "1hhhft" }]
|
471
|
+
var ChevronRight = createLucideIcon("ChevronRight", [
|
472
|
+
["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]
|
327
473
|
]);
|
328
474
|
|
475
|
+
// ../core/lib/use-breadcrumbs.ts
|
476
|
+
init_react_import();
|
477
|
+
var import_react10 = 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
|
489
|
+
init_react_import();
|
490
|
+
|
491
|
+
// ../core/lib/data/for-related-zones.ts
|
492
|
+
init_react_import();
|
493
|
+
|
494
|
+
// ../core/lib/get-zone-id.ts
|
495
|
+
init_react_import();
|
496
|
+
|
497
|
+
// ../core/lib/root-droppable-id.ts
|
498
|
+
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
|
+
|
514
|
+
// ../core/lib/data/for-related-zones.ts
|
515
|
+
function forRelatedZones(item, data, cb, path = []) {
|
516
|
+
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
|
517
|
+
const [parentId] = getZoneId(zoneCompound);
|
518
|
+
if (parentId === item.props.id) {
|
519
|
+
cb(path, zoneCompound, content);
|
520
|
+
}
|
521
|
+
});
|
522
|
+
}
|
523
|
+
|
524
|
+
// ../core/lib/data/map-slots.ts
|
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;
|
608
|
+
};
|
609
|
+
var walkObject = ({
|
610
|
+
value,
|
611
|
+
fields,
|
612
|
+
map,
|
613
|
+
id,
|
614
|
+
getPropPath,
|
615
|
+
config,
|
616
|
+
recurseSlots
|
617
|
+
}) => {
|
618
|
+
const newProps = Object.entries(value).map(([k, v]) => {
|
619
|
+
const opts = {
|
620
|
+
value: v,
|
621
|
+
fields,
|
622
|
+
map,
|
623
|
+
propKey: k,
|
624
|
+
propPath: getPropPath(k),
|
625
|
+
id,
|
626
|
+
config,
|
627
|
+
recurseSlots
|
628
|
+
};
|
629
|
+
const newValue = walkField(opts);
|
630
|
+
if (isPromise(newValue)) {
|
631
|
+
return newValue.then((resolvedValue) => ({
|
632
|
+
[k]: resolvedValue
|
633
|
+
}));
|
634
|
+
}
|
635
|
+
return {
|
636
|
+
[k]: newValue
|
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
|
+
}));
|
661
|
+
}
|
662
|
+
return __spreadProps(__spreadValues({}, item), {
|
663
|
+
props: newProps
|
664
|
+
});
|
665
|
+
}
|
666
|
+
|
667
|
+
// ../core/lib/data/flatten-node.ts
|
668
|
+
init_react_import();
|
669
|
+
var import_flat = __toESM(require_flat());
|
670
|
+
|
671
|
+
// ../core/lib/data/strip-slots.ts
|
672
|
+
init_react_import();
|
673
|
+
var stripSlots = (data, config) => {
|
674
|
+
return mapSlots(data, () => null, config);
|
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
|
703
|
+
};
|
704
|
+
return [newZoneCompound, newContent2];
|
705
|
+
};
|
706
|
+
const processRelatedZones = (item, newId, initialPath) => {
|
707
|
+
forRelatedZones(
|
708
|
+
item,
|
709
|
+
state.data,
|
710
|
+
(relatedPath, relatedZoneCompound, relatedContent) => {
|
711
|
+
const [zoneCompound, newContent2] = processContent(
|
712
|
+
relatedPath,
|
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
|
743
|
+
});
|
744
|
+
processRelatedZones(item, id, path);
|
745
|
+
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
|
746
|
+
const thisZoneCompound = path[path.length - 1];
|
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
|
754
|
+
};
|
755
|
+
const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
|
756
|
+
if (newProps.id === "root") {
|
757
|
+
delete finalData["type"];
|
758
|
+
delete finalData.props["id"];
|
759
|
+
}
|
760
|
+
return finalData;
|
761
|
+
};
|
762
|
+
const zones = state.data.zones || {};
|
763
|
+
const [_, newContent] = processContent(
|
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
|
+
var replaceAction = (state, action, appStore) => {
|
1004
|
+
const [parentId] = action.destinationZone.split(":");
|
1005
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
1006
|
+
const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
|
1007
|
+
const idChanged = originalId !== action.data.props.id;
|
1008
|
+
if (idChanged) {
|
1009
|
+
throw new Error(
|
1010
|
+
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
1011
|
+
);
|
1012
|
+
}
|
1013
|
+
const newSlotIds = [];
|
1014
|
+
const data = walkTree(action.data, appStore.config, (contents, opts) => {
|
1015
|
+
newSlotIds.push(`${opts.parentId}:${opts.propName}`);
|
1016
|
+
return contents.map((item) => {
|
1017
|
+
const id = generateId(item.type);
|
1018
|
+
return __spreadProps(__spreadValues({}, item), {
|
1019
|
+
props: __spreadValues({ id }, item.props)
|
1020
|
+
});
|
1021
|
+
});
|
1022
|
+
});
|
1023
|
+
const stateWithDeepSlotsRemoved = __spreadValues({}, state);
|
1024
|
+
Object.keys(state.indexes.zones).forEach((zoneCompound) => {
|
1025
|
+
const id = zoneCompound.split(":")[0];
|
1026
|
+
if (id === originalId) {
|
1027
|
+
if (!newSlotIds.includes(zoneCompound)) {
|
1028
|
+
delete stateWithDeepSlotsRemoved.indexes.zones[zoneCompound];
|
1029
|
+
}
|
1030
|
+
}
|
1031
|
+
});
|
1032
|
+
return walkAppState(
|
1033
|
+
stateWithDeepSlotsRemoved,
|
1034
|
+
appStore.config,
|
1035
|
+
(content, zoneCompound) => {
|
1036
|
+
const newContent = [...content];
|
1037
|
+
if (zoneCompound === action.destinationZone) {
|
1038
|
+
newContent[action.destinationIndex] = data;
|
1039
|
+
}
|
1040
|
+
return newContent;
|
1041
|
+
},
|
1042
|
+
(childItem, path) => {
|
1043
|
+
const pathIds = path.map((p) => p.split(":")[0]);
|
1044
|
+
if (childItem.props.id === data.props.id) {
|
1045
|
+
return data;
|
1046
|
+
} else if (childItem.props.id === parentId) {
|
1047
|
+
return childItem;
|
1048
|
+
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
1049
|
+
return childItem;
|
1050
|
+
} else if (pathIds.indexOf(data.props.id) > -1) {
|
1051
|
+
return childItem;
|
1052
|
+
}
|
1053
|
+
return null;
|
1054
|
+
}
|
1055
|
+
);
|
1056
|
+
};
|
1057
|
+
|
1058
|
+
// ../core/reducer/actions/replace-root.ts
|
1059
|
+
init_react_import();
|
1060
|
+
var replaceRootAction = (state, action, appStore) => {
|
1061
|
+
return walkAppState(
|
1062
|
+
state,
|
1063
|
+
appStore.config,
|
1064
|
+
(content) => content,
|
1065
|
+
(childItem) => {
|
1066
|
+
if (childItem.props.id === "root") {
|
1067
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
1068
|
+
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
1069
|
+
readOnly: action.root.readOnly
|
1070
|
+
});
|
1071
|
+
}
|
1072
|
+
return childItem;
|
1073
|
+
}
|
1074
|
+
);
|
1075
|
+
};
|
1076
|
+
|
1077
|
+
// ../core/reducer/actions/duplicate.ts
|
1078
|
+
init_react_import();
|
1079
|
+
|
1080
|
+
// ../core/lib/data/get-item.ts
|
1081
|
+
init_react_import();
|
1082
|
+
function getItem(selector, state) {
|
1083
|
+
var _a, _b;
|
1084
|
+
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
1085
|
+
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
1086
|
+
}
|
1087
|
+
|
1088
|
+
// ../core/reducer/actions/duplicate.ts
|
1089
|
+
function duplicateAction(state, action, appStore) {
|
1090
|
+
const item = getItem(
|
1091
|
+
{ index: action.sourceIndex, zone: action.sourceZone },
|
1092
|
+
state
|
1093
|
+
);
|
1094
|
+
const idsInPath = getIdsForParent(action.sourceZone, state);
|
1095
|
+
const newItem = __spreadProps(__spreadValues({}, item), {
|
1096
|
+
props: __spreadProps(__spreadValues({}, item.props), {
|
1097
|
+
id: generateId(item.type)
|
1098
|
+
})
|
1099
|
+
});
|
1100
|
+
const modified = walkAppState(
|
1101
|
+
state,
|
1102
|
+
appStore.config,
|
1103
|
+
(content, zoneCompound) => {
|
1104
|
+
if (zoneCompound === action.sourceZone) {
|
1105
|
+
return insert(content, action.sourceIndex + 1, item);
|
1106
|
+
}
|
1107
|
+
return content;
|
1108
|
+
},
|
1109
|
+
(childItem, path, index) => {
|
1110
|
+
const zoneCompound = path[path.length - 1];
|
1111
|
+
const parents = path.map((p) => p.split(":")[0]);
|
1112
|
+
if (parents.indexOf(newItem.props.id) > -1) {
|
1113
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
1114
|
+
props: __spreadProps(__spreadValues({}, childItem.props), {
|
1115
|
+
id: generateId(childItem.type)
|
1116
|
+
})
|
1117
|
+
});
|
1118
|
+
}
|
1119
|
+
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
1120
|
+
return newItem;
|
1121
|
+
}
|
1122
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
1123
|
+
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
1124
|
+
return childItem;
|
1125
|
+
}
|
1126
|
+
return null;
|
1127
|
+
}
|
1128
|
+
);
|
1129
|
+
return __spreadProps(__spreadValues({}, modified), {
|
1130
|
+
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
1131
|
+
itemSelector: {
|
1132
|
+
index: action.sourceIndex + 1,
|
1133
|
+
zone: action.sourceZone
|
1134
|
+
}
|
1135
|
+
})
|
1136
|
+
});
|
1137
|
+
}
|
1138
|
+
|
1139
|
+
// ../core/reducer/actions/reorder.ts
|
1140
|
+
init_react_import();
|
1141
|
+
|
1142
|
+
// ../core/reducer/actions/move.ts
|
1143
|
+
init_react_import();
|
1144
|
+
|
1145
|
+
// ../core/lib/data/remove.ts
|
1146
|
+
init_react_import();
|
1147
|
+
var remove = (list, index) => {
|
1148
|
+
const result = Array.from(list);
|
1149
|
+
result.splice(index, 1);
|
1150
|
+
return result;
|
1151
|
+
};
|
1152
|
+
|
1153
|
+
// ../core/reducer/actions/move.ts
|
1154
|
+
var moveAction = (state, action, appStore) => {
|
1155
|
+
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
1156
|
+
return state;
|
1157
|
+
}
|
1158
|
+
const item = getItem(
|
1159
|
+
{ zone: action.sourceZone, index: action.sourceIndex },
|
1160
|
+
state
|
1161
|
+
);
|
1162
|
+
if (!item) return state;
|
1163
|
+
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
1164
|
+
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
1165
|
+
return walkAppState(
|
1166
|
+
state,
|
1167
|
+
appStore.config,
|
1168
|
+
(content, zoneCompound) => {
|
1169
|
+
if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
|
1170
|
+
return insert(
|
1171
|
+
remove(content, action.sourceIndex),
|
1172
|
+
action.destinationIndex,
|
1173
|
+
item
|
1174
|
+
);
|
1175
|
+
} else if (zoneCompound === action.sourceZone) {
|
1176
|
+
return remove(content, action.sourceIndex);
|
1177
|
+
} else if (zoneCompound === action.destinationZone) {
|
1178
|
+
return insert(content, action.destinationIndex, item);
|
1179
|
+
}
|
1180
|
+
return content;
|
1181
|
+
},
|
1182
|
+
(childItem, path) => {
|
1183
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
1184
|
+
const [destinationZoneParent] = action.destinationZone.split(":");
|
1185
|
+
const childId = childItem.props.id;
|
1186
|
+
if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1 || path.includes(action.destinationZone)) {
|
1187
|
+
return childItem;
|
1188
|
+
}
|
1189
|
+
return null;
|
1190
|
+
}
|
1191
|
+
);
|
1192
|
+
};
|
1193
|
+
|
1194
|
+
// ../core/reducer/actions/reorder.ts
|
1195
|
+
var reorderAction = (state, action, appStore) => {
|
1196
|
+
return moveAction(
|
1197
|
+
state,
|
1198
|
+
{
|
1199
|
+
type: "move",
|
1200
|
+
sourceIndex: action.sourceIndex,
|
1201
|
+
sourceZone: action.destinationZone,
|
1202
|
+
destinationIndex: action.destinationIndex,
|
1203
|
+
destinationZone: action.destinationZone
|
1204
|
+
},
|
1205
|
+
appStore
|
1206
|
+
);
|
1207
|
+
};
|
1208
|
+
|
1209
|
+
// ../core/reducer/actions/remove.ts
|
1210
|
+
init_react_import();
|
1211
|
+
var removeAction = (state, action, appStore) => {
|
1212
|
+
const item = getItem({ index: action.index, zone: action.zone }, state);
|
1213
|
+
const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
|
1214
|
+
(acc, [nodeId, nodeData]) => {
|
1215
|
+
const pathIds = nodeData.path.map((p) => p.split(":")[0]);
|
1216
|
+
if (pathIds.includes(item.props.id)) {
|
1217
|
+
return [...acc, nodeId];
|
1218
|
+
}
|
1219
|
+
return acc;
|
1220
|
+
},
|
1221
|
+
[item.props.id]
|
1222
|
+
);
|
1223
|
+
const newState = walkAppState(
|
1224
|
+
state,
|
1225
|
+
appStore.config,
|
1226
|
+
(content, zoneCompound) => {
|
1227
|
+
if (zoneCompound === action.zone) {
|
1228
|
+
return remove(content, action.index);
|
1229
|
+
}
|
1230
|
+
return content;
|
1231
|
+
}
|
1232
|
+
);
|
1233
|
+
Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
|
1234
|
+
const parentId = zoneCompound.split(":")[0];
|
1235
|
+
if (nodesToDelete.includes(parentId) && newState.data.zones) {
|
1236
|
+
delete newState.data.zones[zoneCompound];
|
1237
|
+
}
|
1238
|
+
});
|
1239
|
+
Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
|
1240
|
+
const parentId = zoneCompound.split(":")[0];
|
1241
|
+
if (nodesToDelete.includes(parentId)) {
|
1242
|
+
delete newState.indexes.zones[zoneCompound];
|
1243
|
+
}
|
1244
|
+
});
|
1245
|
+
nodesToDelete.forEach((id) => {
|
1246
|
+
delete newState.indexes.nodes[id];
|
1247
|
+
});
|
1248
|
+
return newState;
|
1249
|
+
};
|
1250
|
+
|
1251
|
+
// ../core/reducer/actions/register-zone.ts
|
1252
|
+
init_react_import();
|
1253
|
+
|
1254
|
+
// ../core/lib/data/setup-zone.ts
|
1255
|
+
init_react_import();
|
1256
|
+
var setupZone = (data, zoneKey) => {
|
1257
|
+
if (zoneKey === rootDroppableId) {
|
1258
|
+
return data;
|
1259
|
+
}
|
1260
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
1261
|
+
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
1262
|
+
});
|
1263
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
1264
|
+
return newData;
|
1265
|
+
};
|
1266
|
+
|
1267
|
+
// ../core/reducer/actions/register-zone.ts
|
1268
|
+
var zoneCache = {};
|
1269
|
+
function registerZoneAction(state, action) {
|
1270
|
+
if (zoneCache[action.zone]) {
|
1271
|
+
return __spreadProps(__spreadValues({}, state), {
|
1272
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
1273
|
+
zones: __spreadProps(__spreadValues({}, state.data.zones), {
|
1274
|
+
[action.zone]: zoneCache[action.zone]
|
1275
|
+
})
|
1276
|
+
}),
|
1277
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1278
|
+
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
|
1279
|
+
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
|
1280
|
+
contentIds: zoneCache[action.zone].map((item) => item.props.id),
|
1281
|
+
type: "dropzone"
|
1282
|
+
})
|
1283
|
+
})
|
1284
|
+
})
|
1285
|
+
});
|
1286
|
+
}
|
1287
|
+
return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
|
1288
|
+
}
|
1289
|
+
function unregisterZoneAction(state, action) {
|
1290
|
+
const _zones = __spreadValues({}, state.data.zones || {});
|
1291
|
+
const zoneIndex = __spreadValues({}, state.indexes.zones || {});
|
1292
|
+
if (_zones[action.zone]) {
|
1293
|
+
zoneCache[action.zone] = _zones[action.zone];
|
1294
|
+
delete _zones[action.zone];
|
1295
|
+
}
|
1296
|
+
delete zoneIndex[action.zone];
|
1297
|
+
return __spreadProps(__spreadValues({}, state), {
|
1298
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
1299
|
+
zones: _zones
|
1300
|
+
}),
|
1301
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1302
|
+
zones: zoneIndex
|
1303
|
+
})
|
1304
|
+
});
|
1305
|
+
}
|
1306
|
+
|
1307
|
+
// ../core/reducer/actions/set-data.ts
|
1308
|
+
init_react_import();
|
1309
|
+
var setDataAction = (state, action, appStore) => {
|
1310
|
+
if (typeof action.data === "object") {
|
1311
|
+
console.warn(
|
1312
|
+
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1313
|
+
);
|
1314
|
+
return walkAppState(
|
1315
|
+
__spreadProps(__spreadValues({}, state), {
|
1316
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
1317
|
+
}),
|
1318
|
+
appStore.config
|
1319
|
+
);
|
1320
|
+
}
|
1321
|
+
return walkAppState(
|
1322
|
+
__spreadProps(__spreadValues({}, state), {
|
1323
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
1324
|
+
}),
|
1325
|
+
appStore.config
|
1326
|
+
);
|
1327
|
+
};
|
1328
|
+
|
1329
|
+
// ../core/reducer/actions/set-ui.ts
|
1330
|
+
init_react_import();
|
1331
|
+
var setUiAction = (state, action) => {
|
1332
|
+
if (typeof action.ui === "object") {
|
1333
|
+
return __spreadProps(__spreadValues({}, state), {
|
1334
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
|
1335
|
+
});
|
1336
|
+
}
|
1337
|
+
return __spreadProps(__spreadValues({}, state), {
|
1338
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
|
1339
|
+
});
|
1340
|
+
};
|
1341
|
+
|
1342
|
+
// ../core/lib/data/make-state-public.ts
|
1343
|
+
init_react_import();
|
1344
|
+
var makeStatePublic = (state) => {
|
1345
|
+
const { data, ui } = state;
|
1346
|
+
return { data, ui };
|
1347
|
+
};
|
1348
|
+
|
1349
|
+
// ../core/reducer/actions.tsx
|
1350
|
+
init_react_import();
|
1351
|
+
|
1352
|
+
// ../core/reducer/index.ts
|
1353
|
+
function storeInterceptor(reducer, record, onAction) {
|
1354
|
+
return (state, action) => {
|
1355
|
+
const newAppState = reducer(state, action);
|
1356
|
+
const isValidType = ![
|
1357
|
+
"registerZone",
|
1358
|
+
"unregisterZone",
|
1359
|
+
"setData",
|
1360
|
+
"setUi",
|
1361
|
+
"set"
|
1362
|
+
].includes(action.type);
|
1363
|
+
if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
|
1364
|
+
if (record) record(newAppState);
|
1365
|
+
}
|
1366
|
+
onAction == null ? void 0 : onAction(action, makeStatePublic(newAppState), makeStatePublic(state));
|
1367
|
+
return newAppState;
|
1368
|
+
};
|
1369
|
+
}
|
1370
|
+
function createReducer({
|
1371
|
+
record,
|
1372
|
+
onAction,
|
1373
|
+
appStore
|
1374
|
+
}) {
|
1375
|
+
return storeInterceptor(
|
1376
|
+
(state, action) => {
|
1377
|
+
if (action.type === "set") {
|
1378
|
+
return setAction(state, action, appStore);
|
1379
|
+
}
|
1380
|
+
if (action.type === "insert") {
|
1381
|
+
return insertAction(state, action, appStore);
|
1382
|
+
}
|
1383
|
+
if (action.type === "replace") {
|
1384
|
+
return replaceAction(state, action, appStore);
|
1385
|
+
}
|
1386
|
+
if (action.type === "replaceRoot") {
|
1387
|
+
return replaceRootAction(state, action, appStore);
|
1388
|
+
}
|
1389
|
+
if (action.type === "duplicate") {
|
1390
|
+
return duplicateAction(state, action, appStore);
|
1391
|
+
}
|
1392
|
+
if (action.type === "reorder") {
|
1393
|
+
return reorderAction(state, action, appStore);
|
1394
|
+
}
|
1395
|
+
if (action.type === "move") {
|
1396
|
+
return moveAction(state, action, appStore);
|
1397
|
+
}
|
1398
|
+
if (action.type === "remove") {
|
1399
|
+
return removeAction(state, action, appStore);
|
1400
|
+
}
|
1401
|
+
if (action.type === "registerZone") {
|
1402
|
+
return registerZoneAction(state, action);
|
1403
|
+
}
|
1404
|
+
if (action.type === "unregisterZone") {
|
1405
|
+
return unregisterZoneAction(state, action);
|
1406
|
+
}
|
1407
|
+
if (action.type === "setData") {
|
1408
|
+
return setDataAction(state, action, appStore);
|
1409
|
+
}
|
1410
|
+
if (action.type === "setUi") {
|
1411
|
+
return setUiAction(state, action);
|
1412
|
+
}
|
1413
|
+
return state;
|
1414
|
+
},
|
1415
|
+
record,
|
1416
|
+
onAction
|
1417
|
+
);
|
1418
|
+
}
|
1419
|
+
|
1420
|
+
// ../core/components/ViewportControls/default-viewports.ts
|
1421
|
+
init_react_import();
|
1422
|
+
var defaultViewports = [
|
1423
|
+
{ width: 360, height: "auto", icon: "Smartphone", label: "Small" },
|
1424
|
+
{ width: 768, height: "auto", icon: "Tablet", label: "Medium" },
|
1425
|
+
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
1426
|
+
];
|
1427
|
+
|
1428
|
+
// ../../node_modules/zustand/esm/vanilla.mjs
|
1429
|
+
init_react_import();
|
1430
|
+
var createStoreImpl = (createState) => {
|
1431
|
+
let state;
|
1432
|
+
const listeners = /* @__PURE__ */ new Set();
|
1433
|
+
const setState = (partial, replace) => {
|
1434
|
+
const nextState = typeof partial === "function" ? partial(state) : partial;
|
1435
|
+
if (!Object.is(nextState, state)) {
|
1436
|
+
const previousState = state;
|
1437
|
+
state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
|
1438
|
+
listeners.forEach((listener) => listener(state, previousState));
|
1439
|
+
}
|
1440
|
+
};
|
1441
|
+
const getState = () => state;
|
1442
|
+
const getInitialState = () => initialState;
|
1443
|
+
const subscribe = (listener) => {
|
1444
|
+
listeners.add(listener);
|
1445
|
+
return () => listeners.delete(listener);
|
1446
|
+
};
|
1447
|
+
const api = { setState, getState, getInitialState, subscribe };
|
1448
|
+
const initialState = state = createState(setState, getState, api);
|
1449
|
+
return api;
|
1450
|
+
};
|
1451
|
+
var createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
|
1452
|
+
|
1453
|
+
// ../../node_modules/zustand/esm/react.mjs
|
1454
|
+
init_react_import();
|
1455
|
+
var import_react4 = __toESM(require("react"), 1);
|
1456
|
+
var identity = (arg) => arg;
|
1457
|
+
function useStore(api, selector = identity) {
|
1458
|
+
const slice = import_react4.default.useSyncExternalStore(
|
1459
|
+
api.subscribe,
|
1460
|
+
() => selector(api.getState()),
|
1461
|
+
() => selector(api.getInitialState())
|
1462
|
+
);
|
1463
|
+
import_react4.default.useDebugValue(slice);
|
1464
|
+
return slice;
|
1465
|
+
}
|
1466
|
+
var createImpl = (createState) => {
|
1467
|
+
const api = createStore(createState);
|
1468
|
+
const useBoundStore = (selector) => useStore(api, selector);
|
1469
|
+
Object.assign(useBoundStore, api);
|
1470
|
+
return useBoundStore;
|
1471
|
+
};
|
1472
|
+
var create = (createState) => createState ? createImpl(createState) : createImpl;
|
1473
|
+
|
1474
|
+
// ../../node_modules/zustand/esm/middleware.mjs
|
1475
|
+
init_react_import();
|
1476
|
+
var subscribeWithSelectorImpl = (fn) => (set, get, api) => {
|
1477
|
+
const origSubscribe = api.subscribe;
|
1478
|
+
api.subscribe = (selector, optListener, options) => {
|
1479
|
+
let listener = selector;
|
1480
|
+
if (optListener) {
|
1481
|
+
const equalityFn = (options == null ? void 0 : options.equalityFn) || Object.is;
|
1482
|
+
let currentSlice = selector(api.getState());
|
1483
|
+
listener = (state) => {
|
1484
|
+
const nextSlice = selector(state);
|
1485
|
+
if (!equalityFn(currentSlice, nextSlice)) {
|
1486
|
+
const previousSlice = currentSlice;
|
1487
|
+
optListener(currentSlice = nextSlice, previousSlice);
|
1488
|
+
}
|
1489
|
+
};
|
1490
|
+
if (options == null ? void 0 : options.fireImmediately) {
|
1491
|
+
optListener(currentSlice, currentSlice);
|
1492
|
+
}
|
1493
|
+
}
|
1494
|
+
return origSubscribe(listener);
|
1495
|
+
};
|
1496
|
+
const initialState = fn(set, get, api);
|
1497
|
+
return initialState;
|
1498
|
+
};
|
1499
|
+
var subscribeWithSelector = subscribeWithSelectorImpl;
|
1500
|
+
|
1501
|
+
// ../core/store/index.ts
|
1502
|
+
var import_react9 = require("react");
|
1503
|
+
|
1504
|
+
// ../core/store/slices/history.ts
|
1505
|
+
init_react_import();
|
1506
|
+
var import_react6 = require("react");
|
1507
|
+
|
1508
|
+
// ../core/lib/use-hotkey.ts
|
1509
|
+
init_react_import();
|
1510
|
+
var import_react5 = require("react");
|
1511
|
+
var useHotkeyStore = create()(
|
1512
|
+
subscribeWithSelector((set) => ({
|
1513
|
+
held: {},
|
1514
|
+
hold: (key) => set((s) => s.held[key] ? s : { held: __spreadProps(__spreadValues({}, s.held), { [key]: true }) }),
|
1515
|
+
release: (key) => set((s) => s.held[key] ? { held: __spreadProps(__spreadValues({}, s.held), { [key]: false }) } : s),
|
1516
|
+
reset: (held = {}) => set(() => ({ held })),
|
1517
|
+
triggers: {}
|
1518
|
+
}))
|
1519
|
+
);
|
1520
|
+
|
1521
|
+
// ../core/store/slices/history.ts
|
1522
|
+
var EMPTY_HISTORY_INDEX = 0;
|
1523
|
+
function debounce(func, timeout = 300) {
|
1524
|
+
let timer;
|
1525
|
+
return (...args) => {
|
1526
|
+
clearTimeout(timer);
|
1527
|
+
timer = setTimeout(() => {
|
1528
|
+
func(...args);
|
1529
|
+
}, timeout);
|
1530
|
+
};
|
1531
|
+
}
|
1532
|
+
var tidyState = (state) => {
|
1533
|
+
return __spreadProps(__spreadValues({}, state), {
|
1534
|
+
ui: __spreadProps(__spreadValues({}, state.ui), {
|
1535
|
+
field: {
|
1536
|
+
focus: null
|
1537
|
+
}
|
1538
|
+
})
|
1539
|
+
});
|
1540
|
+
};
|
1541
|
+
var createHistorySlice = (set, get) => {
|
1542
|
+
const record = debounce((state) => {
|
1543
|
+
const { histories, index } = get().history;
|
1544
|
+
const history = {
|
1545
|
+
state,
|
1546
|
+
id: generateId("history")
|
1547
|
+
};
|
1548
|
+
const newHistories = [...histories.slice(0, index + 1), history];
|
1549
|
+
set({
|
1550
|
+
history: __spreadProps(__spreadValues({}, get().history), {
|
1551
|
+
histories: newHistories,
|
1552
|
+
index: newHistories.length - 1
|
1553
|
+
})
|
1554
|
+
});
|
1555
|
+
}, 250);
|
1556
|
+
return {
|
1557
|
+
initialAppState: {},
|
1558
|
+
index: EMPTY_HISTORY_INDEX,
|
1559
|
+
histories: [],
|
1560
|
+
hasPast: () => get().history.index > EMPTY_HISTORY_INDEX,
|
1561
|
+
hasFuture: () => get().history.index < get().history.histories.length - 1,
|
1562
|
+
prevHistory: () => {
|
1563
|
+
const { history } = get();
|
1564
|
+
return history.hasPast() ? history.histories[history.index - 1] : null;
|
1565
|
+
},
|
1566
|
+
nextHistory: () => {
|
1567
|
+
const s = get().history;
|
1568
|
+
return s.hasFuture() ? s.histories[s.index + 1] : null;
|
1569
|
+
},
|
1570
|
+
currentHistory: () => get().history.histories[get().history.index],
|
1571
|
+
back: () => {
|
1572
|
+
var _a;
|
1573
|
+
const { history, dispatch } = get();
|
1574
|
+
if (history.hasPast()) {
|
1575
|
+
const state = tidyState(
|
1576
|
+
((_a = history.prevHistory()) == null ? void 0 : _a.state) || history.initialAppState
|
1577
|
+
);
|
1578
|
+
dispatch({
|
1579
|
+
type: "set",
|
1580
|
+
state
|
1581
|
+
});
|
1582
|
+
set({ history: __spreadProps(__spreadValues({}, history), { index: history.index - 1 }) });
|
1583
|
+
}
|
1584
|
+
},
|
1585
|
+
forward: () => {
|
1586
|
+
var _a;
|
1587
|
+
const { history, dispatch } = get();
|
1588
|
+
if (history.hasFuture()) {
|
1589
|
+
const state = (_a = history.nextHistory()) == null ? void 0 : _a.state;
|
1590
|
+
dispatch({ type: "set", state: state ? tidyState(state) : {} });
|
1591
|
+
set({ history: __spreadProps(__spreadValues({}, history), { index: history.index + 1 }) });
|
1592
|
+
}
|
1593
|
+
},
|
1594
|
+
setHistories: (histories) => {
|
1595
|
+
var _a;
|
1596
|
+
const { dispatch, history } = get();
|
1597
|
+
dispatch({
|
1598
|
+
type: "set",
|
1599
|
+
state: ((_a = histories[histories.length - 1]) == null ? void 0 : _a.state) || history.initialAppState
|
1600
|
+
});
|
1601
|
+
set({ history: __spreadProps(__spreadValues({}, history), { histories, index: histories.length - 1 }) });
|
1602
|
+
},
|
1603
|
+
setHistoryIndex: (index) => {
|
1604
|
+
var _a;
|
1605
|
+
const { dispatch, history } = get();
|
1606
|
+
dispatch({
|
1607
|
+
type: "set",
|
1608
|
+
state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
|
1609
|
+
});
|
1610
|
+
set({ history: __spreadProps(__spreadValues({}, history), { index }) });
|
1611
|
+
},
|
1612
|
+
record
|
1613
|
+
};
|
1614
|
+
};
|
1615
|
+
|
1616
|
+
// ../core/store/slices/nodes.ts
|
1617
|
+
init_react_import();
|
1618
|
+
var createNodesSlice = (set, get) => ({
|
1619
|
+
nodes: {},
|
1620
|
+
registerNode: (id, node) => {
|
1621
|
+
const s = get().nodes;
|
1622
|
+
const emptyNode = {
|
1623
|
+
id,
|
1624
|
+
methods: {
|
1625
|
+
sync: () => null,
|
1626
|
+
hideOverlay: () => null,
|
1627
|
+
showOverlay: () => null
|
1628
|
+
},
|
1629
|
+
element: null
|
1630
|
+
};
|
1631
|
+
const existingNode = s.nodes[id];
|
1632
|
+
set({
|
1633
|
+
nodes: __spreadProps(__spreadValues({}, s), {
|
1634
|
+
nodes: __spreadProps(__spreadValues({}, s.nodes), {
|
1635
|
+
[id]: __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, emptyNode), existingNode), node), {
|
1636
|
+
id
|
1637
|
+
})
|
1638
|
+
})
|
1639
|
+
})
|
1640
|
+
});
|
1641
|
+
},
|
1642
|
+
unregisterNode: (id) => {
|
1643
|
+
const s = get().nodes;
|
1644
|
+
const existingNode = s.nodes[id];
|
1645
|
+
if (existingNode) {
|
1646
|
+
const newNodes = __spreadValues({}, s.nodes);
|
1647
|
+
delete newNodes[id];
|
1648
|
+
set({
|
1649
|
+
nodes: __spreadProps(__spreadValues({}, s), {
|
1650
|
+
nodes: newNodes
|
1651
|
+
})
|
1652
|
+
});
|
1653
|
+
}
|
1654
|
+
}
|
1655
|
+
});
|
1656
|
+
|
1657
|
+
// ../core/store/slices/permissions.ts
|
1658
|
+
init_react_import();
|
1659
|
+
var import_react7 = require("react");
|
1660
|
+
|
1661
|
+
// ../core/lib/data/flatten-data.ts
|
1662
|
+
init_react_import();
|
1663
|
+
var flattenData = (state, config) => {
|
1664
|
+
const data = [];
|
1665
|
+
walkAppState(
|
1666
|
+
state,
|
1667
|
+
config,
|
1668
|
+
(content) => content,
|
1669
|
+
(item) => {
|
1670
|
+
data.push(item);
|
1671
|
+
return null;
|
1672
|
+
}
|
1673
|
+
);
|
1674
|
+
return data;
|
1675
|
+
};
|
1676
|
+
|
1677
|
+
// ../core/lib/get-changed.ts
|
1678
|
+
init_react_import();
|
1679
|
+
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1680
|
+
var getChanged = (newItem, oldItem) => {
|
1681
|
+
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
1682
|
+
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
1683
|
+
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
1684
|
+
return __spreadProps(__spreadValues({}, acc), {
|
1685
|
+
[item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
|
1686
|
+
});
|
1687
|
+
}, {}) : {};
|
1688
|
+
};
|
1689
|
+
|
1690
|
+
// ../core/store/slices/permissions.ts
|
1691
|
+
var createPermissionsSlice = (set, get) => {
|
1692
|
+
const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
|
1693
|
+
const { state, permissions, config } = get();
|
1694
|
+
const { cache: cache2, globalPermissions } = permissions;
|
1695
|
+
const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
|
1696
|
+
var _a, _b, _c;
|
1697
|
+
const { config: config2, state: appState, setComponentLoading } = get();
|
1698
|
+
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
1699
|
+
if (!componentConfig) {
|
1700
|
+
return;
|
1701
|
+
}
|
1702
|
+
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
1703
|
+
if (componentConfig.resolvePermissions) {
|
1704
|
+
const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
|
1705
|
+
if (Object.values(changed).some((el) => el === true) || force2) {
|
1706
|
+
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
1707
|
+
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
1708
|
+
item2,
|
1709
|
+
{
|
1710
|
+
changed,
|
1711
|
+
lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
|
1712
|
+
permissions: initialPermissions,
|
1713
|
+
appState: makeStatePublic(appState),
|
1714
|
+
lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
|
1715
|
+
}
|
1716
|
+
);
|
1717
|
+
const latest = get().permissions;
|
1718
|
+
set({
|
1719
|
+
permissions: __spreadProps(__spreadValues({}, latest), {
|
1720
|
+
cache: __spreadProps(__spreadValues({}, latest.cache), {
|
1721
|
+
[item2.props.id]: {
|
1722
|
+
lastData: item2,
|
1723
|
+
lastPermissions: resolvedPermissions
|
1724
|
+
}
|
1725
|
+
}),
|
1726
|
+
resolvedPermissions: __spreadProps(__spreadValues({}, latest.resolvedPermissions), {
|
1727
|
+
[item2.props.id]: resolvedPermissions
|
1728
|
+
})
|
1729
|
+
})
|
1730
|
+
});
|
1731
|
+
clearTimeout2();
|
1732
|
+
}
|
1733
|
+
}
|
1734
|
+
});
|
1735
|
+
const resolveDataForRoot = (force2 = false) => {
|
1736
|
+
const { state: appState } = get();
|
1737
|
+
resolveDataForItem(
|
1738
|
+
// Shim the root data in by conforming to component data shape
|
1739
|
+
{
|
1740
|
+
type: "root",
|
1741
|
+
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "root" })
|
1742
|
+
},
|
1743
|
+
force2
|
1744
|
+
);
|
1745
|
+
};
|
1746
|
+
const { item, type, root } = params;
|
1747
|
+
if (item) {
|
1748
|
+
yield resolveDataForItem(item, force);
|
1749
|
+
} else if (type) {
|
1750
|
+
flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(void 0, null, function* () {
|
1751
|
+
yield resolveDataForItem(item2, force);
|
1752
|
+
}));
|
1753
|
+
} else if (root) {
|
1754
|
+
resolveDataForRoot(force);
|
1755
|
+
} else {
|
1756
|
+
flattenData(state, config).map((item2) => __async(void 0, null, function* () {
|
1757
|
+
yield resolveDataForItem(item2, force);
|
1758
|
+
}));
|
1759
|
+
}
|
1760
|
+
});
|
1761
|
+
const refreshPermissions = (params) => resolvePermissions(params, true);
|
1762
|
+
return {
|
1763
|
+
cache: {},
|
1764
|
+
globalPermissions: {
|
1765
|
+
drag: true,
|
1766
|
+
edit: true,
|
1767
|
+
delete: true,
|
1768
|
+
duplicate: true,
|
1769
|
+
insert: true
|
1770
|
+
},
|
1771
|
+
resolvedPermissions: {},
|
1772
|
+
getPermissions: ({ item, type, root } = {}) => {
|
1773
|
+
const { config, permissions } = get();
|
1774
|
+
const { globalPermissions, resolvedPermissions } = permissions;
|
1775
|
+
if (item) {
|
1776
|
+
const componentConfig = config.components[item.type];
|
1777
|
+
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
|
1778
|
+
const resolvedForItem = resolvedPermissions[item.props.id];
|
1779
|
+
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
1780
|
+
} else if (type) {
|
1781
|
+
const componentConfig = config.components[type];
|
1782
|
+
return __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
|
1783
|
+
} else if (root) {
|
1784
|
+
const rootConfig = config.root;
|
1785
|
+
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
|
1786
|
+
const resolvedForItem = resolvedPermissions["root"];
|
1787
|
+
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
1788
|
+
}
|
1789
|
+
return globalPermissions;
|
1790
|
+
},
|
1791
|
+
resolvePermissions,
|
1792
|
+
refreshPermissions
|
1793
|
+
};
|
1794
|
+
};
|
1795
|
+
|
1796
|
+
// ../core/store/slices/fields.ts
|
1797
|
+
init_react_import();
|
1798
|
+
var import_react8 = require("react");
|
1799
|
+
var createFieldsSlice = (_set, _get) => {
|
1800
|
+
return {
|
1801
|
+
fields: {},
|
1802
|
+
loading: false,
|
1803
|
+
lastResolvedData: {},
|
1804
|
+
id: void 0
|
1805
|
+
};
|
1806
|
+
};
|
1807
|
+
|
1808
|
+
// ../core/lib/resolve-component-data.ts
|
1809
|
+
init_react_import();
|
1810
|
+
var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
|
1811
|
+
var cache = { lastChange: {} };
|
1812
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
1813
|
+
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
1814
|
+
const resolvedItem = __spreadValues({}, item);
|
1815
|
+
const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
|
1816
|
+
const id = "id" in item.props ? item.props.id : "root";
|
1817
|
+
if (shouldRunResolver) {
|
1818
|
+
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
1819
|
+
if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
|
1820
|
+
return { node: resolved, didChange: false };
|
1821
|
+
}
|
1822
|
+
const changed = getChanged(item, oldItem);
|
1823
|
+
if (onResolveStart) {
|
1824
|
+
onResolveStart(item);
|
1825
|
+
}
|
1826
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
1827
|
+
changed,
|
1828
|
+
lastData: oldItem,
|
1829
|
+
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
1830
|
+
trigger
|
1831
|
+
});
|
1832
|
+
resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
|
1833
|
+
if (Object.keys(readOnly).length) {
|
1834
|
+
resolvedItem.readOnly = readOnly;
|
1835
|
+
}
|
1836
|
+
}
|
1837
|
+
let itemWithResolvedChildren = yield mapSlots(
|
1838
|
+
resolvedItem,
|
1839
|
+
(content) => __async(void 0, null, function* () {
|
1840
|
+
return yield Promise.all(
|
1841
|
+
content.map(
|
1842
|
+
(childItem) => __async(void 0, null, function* () {
|
1843
|
+
return (yield resolveComponentData(
|
1844
|
+
childItem,
|
1845
|
+
config,
|
1846
|
+
metadata,
|
1847
|
+
onResolveStart,
|
1848
|
+
onResolveEnd,
|
1849
|
+
trigger
|
1850
|
+
)).node;
|
1851
|
+
})
|
1852
|
+
)
|
1853
|
+
);
|
1854
|
+
}),
|
1855
|
+
config
|
1856
|
+
);
|
1857
|
+
if (shouldRunResolver && onResolveEnd) {
|
1858
|
+
onResolveEnd(resolvedItem);
|
1859
|
+
}
|
1860
|
+
cache.lastChange[id] = {
|
1861
|
+
item,
|
1862
|
+
resolved: itemWithResolvedChildren
|
1863
|
+
};
|
1864
|
+
return {
|
1865
|
+
node: itemWithResolvedChildren,
|
1866
|
+
didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
|
1867
|
+
};
|
1868
|
+
});
|
1869
|
+
|
1870
|
+
// ../core/lib/data/to-root.ts
|
1871
|
+
init_react_import();
|
1872
|
+
var toRoot = (item) => {
|
1873
|
+
if ("type" in item && item.type !== "root") {
|
1874
|
+
throw new Error("Converting non-root item to root.");
|
1875
|
+
}
|
1876
|
+
const { readOnly } = item;
|
1877
|
+
if (item.props) {
|
1878
|
+
if ("id" in item.props) {
|
1879
|
+
const _a = item.props, { id } = _a, props = __objRest(_a, ["id"]);
|
1880
|
+
return { props, readOnly };
|
1881
|
+
}
|
1882
|
+
return { props: item.props, readOnly };
|
1883
|
+
}
|
1884
|
+
return { props: {}, readOnly };
|
1885
|
+
};
|
1886
|
+
|
1887
|
+
// ../core/store/default-app-state.ts
|
1888
|
+
init_react_import();
|
1889
|
+
var defaultAppState = {
|
1890
|
+
data: { content: [], root: {}, zones: {} },
|
1891
|
+
ui: {
|
1892
|
+
leftSideBarVisible: true,
|
1893
|
+
rightSideBarVisible: true,
|
1894
|
+
arrayState: {},
|
1895
|
+
itemSelector: null,
|
1896
|
+
componentList: {},
|
1897
|
+
isDragging: false,
|
1898
|
+
previewMode: "edit",
|
1899
|
+
viewports: {
|
1900
|
+
current: {
|
1901
|
+
width: defaultViewports[0].width,
|
1902
|
+
height: defaultViewports[0].height || "auto"
|
1903
|
+
},
|
1904
|
+
options: [],
|
1905
|
+
controlsVisible: true
|
1906
|
+
},
|
1907
|
+
field: { focus: null }
|
1908
|
+
},
|
1909
|
+
indexes: {
|
1910
|
+
nodes: {},
|
1911
|
+
zones: {}
|
1912
|
+
}
|
1913
|
+
};
|
1914
|
+
|
1915
|
+
// ../core/store/index.ts
|
1916
|
+
var defaultPageFields = {
|
1917
|
+
title: { type: "text" }
|
1918
|
+
};
|
1919
|
+
var createAppStore = (initialAppStore) => create()(
|
1920
|
+
subscribeWithSelector((set, get) => {
|
1921
|
+
var _a, _b;
|
1922
|
+
return __spreadProps(__spreadValues({
|
1923
|
+
state: defaultAppState,
|
1924
|
+
config: { components: {} },
|
1925
|
+
componentState: {},
|
1926
|
+
plugins: [],
|
1927
|
+
overrides: {},
|
1928
|
+
viewports: defaultViewports,
|
1929
|
+
zoomConfig: {
|
1930
|
+
autoZoom: 1,
|
1931
|
+
rootHeight: 0,
|
1932
|
+
zoom: 1
|
1933
|
+
},
|
1934
|
+
status: "LOADING",
|
1935
|
+
iframe: {},
|
1936
|
+
metadata: {}
|
1937
|
+
}, initialAppStore), {
|
1938
|
+
fields: createFieldsSlice(set, get),
|
1939
|
+
history: createHistorySlice(set, get),
|
1940
|
+
nodes: createNodesSlice(set, get),
|
1941
|
+
permissions: createPermissionsSlice(set, get),
|
1942
|
+
getComponentConfig: (type) => {
|
1943
|
+
var _a2;
|
1944
|
+
const { config, selectedItem } = get();
|
1945
|
+
const rootFields = ((_a2 = config.root) == null ? void 0 : _a2.fields) || defaultPageFields;
|
1946
|
+
return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
|
1947
|
+
},
|
1948
|
+
selectedItem: ((_a = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _a.ui.itemSelector) ? getItem(
|
1949
|
+
(_b = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _b.ui.itemSelector,
|
1950
|
+
initialAppStore.state
|
1951
|
+
) : null,
|
1952
|
+
dispatch: (action) => set((s) => {
|
1953
|
+
var _a2, _b2;
|
1954
|
+
const { record } = get().history;
|
1955
|
+
const dispatch = createReducer({
|
1956
|
+
record,
|
1957
|
+
appStore: s
|
1958
|
+
});
|
1959
|
+
const state = dispatch(s.state, action);
|
1960
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1961
|
+
(_b2 = (_a2 = get()).onAction) == null ? void 0 : _b2.call(_a2, action, state, get().state);
|
1962
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1963
|
+
}),
|
1964
|
+
setZoomConfig: (zoomConfig) => set({ zoomConfig }),
|
1965
|
+
setStatus: (status) => set({ status }),
|
1966
|
+
setComponentState: (componentState) => set({ componentState }),
|
1967
|
+
pendingLoadTimeouts: {},
|
1968
|
+
setComponentLoading: (id, loading = true, defer = 0) => {
|
1969
|
+
const { setComponentState, pendingLoadTimeouts } = get();
|
1970
|
+
const loadId = generateId();
|
1971
|
+
const setLoading = () => {
|
1972
|
+
var _a2;
|
1973
|
+
const { componentState } = get();
|
1974
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1975
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1976
|
+
loadingCount: (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) + 1
|
1977
|
+
})
|
1978
|
+
}));
|
1979
|
+
};
|
1980
|
+
const unsetLoading = () => {
|
1981
|
+
var _a2;
|
1982
|
+
const { componentState } = get();
|
1983
|
+
clearTimeout(timeout);
|
1984
|
+
delete pendingLoadTimeouts[loadId];
|
1985
|
+
set({ pendingLoadTimeouts });
|
1986
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1987
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1988
|
+
loadingCount: Math.max(
|
1989
|
+
(((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) - 1,
|
1990
|
+
0
|
1991
|
+
)
|
1992
|
+
})
|
1993
|
+
}));
|
1994
|
+
};
|
1995
|
+
const timeout = setTimeout(() => {
|
1996
|
+
if (loading) {
|
1997
|
+
setLoading();
|
1998
|
+
} else {
|
1999
|
+
unsetLoading();
|
2000
|
+
}
|
2001
|
+
delete pendingLoadTimeouts[loadId];
|
2002
|
+
set({ pendingLoadTimeouts });
|
2003
|
+
}, defer);
|
2004
|
+
set({
|
2005
|
+
pendingLoadTimeouts: __spreadProps(__spreadValues({}, pendingLoadTimeouts), {
|
2006
|
+
[id]: timeout
|
2007
|
+
})
|
2008
|
+
});
|
2009
|
+
return unsetLoading;
|
2010
|
+
},
|
2011
|
+
unsetComponentLoading: (id) => {
|
2012
|
+
const { setComponentLoading } = get();
|
2013
|
+
setComponentLoading(id, false);
|
2014
|
+
},
|
2015
|
+
// Helper
|
2016
|
+
setUi: (ui, recordHistory) => set((s) => {
|
2017
|
+
const dispatch = createReducer({
|
2018
|
+
record: () => {
|
2019
|
+
},
|
2020
|
+
appStore: s
|
2021
|
+
});
|
2022
|
+
const state = dispatch(s.state, {
|
2023
|
+
type: "setUi",
|
2024
|
+
ui,
|
2025
|
+
recordHistory
|
2026
|
+
});
|
2027
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
2028
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
2029
|
+
}),
|
2030
|
+
resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
|
2031
|
+
const { config, metadata, setComponentLoading, permissions } = get();
|
2032
|
+
const timeouts = {};
|
2033
|
+
return yield resolveComponentData(
|
2034
|
+
componentData,
|
2035
|
+
config,
|
2036
|
+
metadata,
|
2037
|
+
(item) => {
|
2038
|
+
const id = "id" in item.props ? item.props.id : "root";
|
2039
|
+
timeouts[id] = setComponentLoading(id, true, 50);
|
2040
|
+
},
|
2041
|
+
(item) => __async(void 0, null, function* () {
|
2042
|
+
const id = "id" in item.props ? item.props.id : "root";
|
2043
|
+
if ("type" in item) {
|
2044
|
+
yield permissions.refreshPermissions({ item });
|
2045
|
+
} else {
|
2046
|
+
yield permissions.refreshPermissions({ root: true });
|
2047
|
+
}
|
2048
|
+
timeouts[id]();
|
2049
|
+
}),
|
2050
|
+
trigger
|
2051
|
+
);
|
2052
|
+
}),
|
2053
|
+
resolveAndCommitData: () => __async(void 0, null, function* () {
|
2054
|
+
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
2055
|
+
walkAppState(
|
2056
|
+
state,
|
2057
|
+
config,
|
2058
|
+
(content) => content,
|
2059
|
+
(childItem) => {
|
2060
|
+
resolveComponentData2(childItem, "load").then((resolved) => {
|
2061
|
+
const { state: state2 } = get();
|
2062
|
+
const node = state2.indexes.nodes[resolved.node.props.id];
|
2063
|
+
if (node && resolved.didChange) {
|
2064
|
+
if (resolved.node.props.id === "root") {
|
2065
|
+
dispatch({
|
2066
|
+
type: "replaceRoot",
|
2067
|
+
root: toRoot(resolved.node)
|
2068
|
+
});
|
2069
|
+
} else {
|
2070
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
2071
|
+
const parentZone = state2.indexes.zones[zoneCompound];
|
2072
|
+
const index = parentZone.contentIds.indexOf(
|
2073
|
+
resolved.node.props.id
|
2074
|
+
);
|
2075
|
+
dispatch({
|
2076
|
+
type: "replace",
|
2077
|
+
data: resolved.node,
|
2078
|
+
destinationIndex: index,
|
2079
|
+
destinationZone: zoneCompound
|
2080
|
+
});
|
2081
|
+
}
|
2082
|
+
}
|
2083
|
+
});
|
2084
|
+
return childItem;
|
2085
|
+
}
|
2086
|
+
);
|
2087
|
+
})
|
2088
|
+
});
|
2089
|
+
})
|
2090
|
+
);
|
2091
|
+
var appStoreContext = (0, import_react9.createContext)(createAppStore());
|
2092
|
+
function useAppStore(selector) {
|
2093
|
+
const context = (0, import_react9.useContext)(appStoreContext);
|
2094
|
+
return useStore(context, selector);
|
2095
|
+
}
|
2096
|
+
function useAppStoreApi() {
|
2097
|
+
return (0, import_react9.useContext)(appStoreContext);
|
2098
|
+
}
|
2099
|
+
|
2100
|
+
// ../core/lib/use-breadcrumbs.ts
|
2101
|
+
var useBreadcrumbs = (renderCount) => {
|
2102
|
+
const selectedId = useAppStore((s) => {
|
2103
|
+
var _a;
|
2104
|
+
return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
|
2105
|
+
});
|
2106
|
+
const config = useAppStore((s) => s.config);
|
2107
|
+
const path = useAppStore((s) => {
|
2108
|
+
var _a;
|
2109
|
+
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
2110
|
+
});
|
2111
|
+
const appStore = useAppStoreApi();
|
2112
|
+
return (0, import_react10.useMemo)(() => {
|
2113
|
+
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
2114
|
+
var _a, _b, _c;
|
2115
|
+
const [componentId] = zoneCompound.split(":");
|
2116
|
+
if (componentId === "root") {
|
2117
|
+
return {
|
2118
|
+
label: "Page",
|
2119
|
+
selector: null
|
2120
|
+
};
|
2121
|
+
}
|
2122
|
+
const node = appStore.getState().state.indexes.nodes[componentId];
|
2123
|
+
const parentId = node.path[node.path.length - 1];
|
2124
|
+
const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
|
2125
|
+
const index = contentIds.indexOf(componentId);
|
2126
|
+
const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
|
2127
|
+
return {
|
2128
|
+
label,
|
2129
|
+
selector: node ? {
|
2130
|
+
index,
|
2131
|
+
zone: node.path[node.path.length - 1]
|
2132
|
+
} : null
|
2133
|
+
};
|
2134
|
+
})) || [];
|
2135
|
+
if (renderCount) {
|
2136
|
+
return breadcrumbs.slice(breadcrumbs.length - renderCount);
|
2137
|
+
}
|
2138
|
+
return breadcrumbs;
|
2139
|
+
}, [path, renderCount]);
|
2140
|
+
};
|
2141
|
+
|
2142
|
+
// ../core/components/Loader/index.tsx
|
2143
|
+
init_react_import();
|
2144
|
+
|
329
2145
|
// ../core/lib/index.ts
|
330
2146
|
init_react_import();
|
331
2147
|
|
@@ -338,10 +2154,139 @@ init_react_import();
|
|
338
2154
|
// ../core/lib/data/replace.ts
|
339
2155
|
init_react_import();
|
340
2156
|
|
2157
|
+
// ../core/lib/use-reset-auto-zoom.ts
|
2158
|
+
init_react_import();
|
2159
|
+
var import_react11 = require("react");
|
2160
|
+
|
2161
|
+
// ../core/lib/get-zoom-config.ts
|
2162
|
+
init_react_import();
|
2163
|
+
|
2164
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
|
2165
|
+
init_react_import();
|
2166
|
+
var styles_module_default3 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
|
2167
|
+
|
2168
|
+
// ../core/components/Loader/index.tsx
|
2169
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
2170
|
+
var getClassName2 = get_class_name_factory_default("Loader", styles_module_default3);
|
2171
|
+
var Loader = (_a) => {
|
2172
|
+
var _b = _a, {
|
2173
|
+
color,
|
2174
|
+
size = 16
|
2175
|
+
} = _b, props = __objRest(_b, [
|
2176
|
+
"color",
|
2177
|
+
"size"
|
2178
|
+
]);
|
2179
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
2180
|
+
"span",
|
2181
|
+
__spreadValues({
|
2182
|
+
className: getClassName2(),
|
2183
|
+
style: {
|
2184
|
+
width: size,
|
2185
|
+
height: size,
|
2186
|
+
color
|
2187
|
+
},
|
2188
|
+
"aria-label": "loading"
|
2189
|
+
}, props)
|
2190
|
+
);
|
2191
|
+
};
|
2192
|
+
|
2193
|
+
// ../core/components/SidebarSection/index.tsx
|
2194
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
2195
|
+
var getClassName3 = get_class_name_factory_default("SidebarSection", styles_module_default);
|
2196
|
+
var SidebarSection = ({
|
2197
|
+
children,
|
2198
|
+
title,
|
2199
|
+
background,
|
2200
|
+
showBreadcrumbs,
|
2201
|
+
noBorderTop,
|
2202
|
+
noPadding,
|
2203
|
+
isLoading
|
2204
|
+
}) => {
|
2205
|
+
const setUi = useAppStore((s) => s.setUi);
|
2206
|
+
const breadcrumbs = useBreadcrumbs(1);
|
2207
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
2208
|
+
"div",
|
2209
|
+
{
|
2210
|
+
className: getClassName3({ noBorderTop, noPadding }),
|
2211
|
+
style: { background },
|
2212
|
+
children: [
|
2213
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName3("title"), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: getClassName3("breadcrumbs"), children: [
|
2214
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: getClassName3("breadcrumb"), children: [
|
2215
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
2216
|
+
"button",
|
2217
|
+
{
|
2218
|
+
type: "button",
|
2219
|
+
className: getClassName3("breadcrumbLabel"),
|
2220
|
+
onClick: () => setUi({ itemSelector: breadcrumb.selector }),
|
2221
|
+
children: breadcrumb.label
|
2222
|
+
}
|
2223
|
+
),
|
2224
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChevronRight, { size: 16 })
|
2225
|
+
] }, i)) : null,
|
2226
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName3("heading"), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Heading, { rank: "2", size: "xs", children: title }) })
|
2227
|
+
] }) }),
|
2228
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName3("content"), children }),
|
2229
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName3("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Loader, { size: 32 }) })
|
2230
|
+
]
|
2231
|
+
}
|
2232
|
+
);
|
2233
|
+
};
|
2234
|
+
|
2235
|
+
// ../core/components/OutlineList/index.tsx
|
2236
|
+
init_react_import();
|
2237
|
+
|
2238
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/OutlineList/styles.module.css#css-module
|
2239
|
+
init_react_import();
|
2240
|
+
var styles_module_default4 = { "OutlineList": "_OutlineList_w4lzv_1", "OutlineListItem": "_OutlineListItem_w4lzv_25", "OutlineListItem--clickable": "_OutlineListItem--clickable_w4lzv_45" };
|
2241
|
+
|
2242
|
+
// ../core/components/OutlineList/index.tsx
|
2243
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
2244
|
+
var getClassName4 = get_class_name_factory_default("OutlineList", styles_module_default4);
|
2245
|
+
var getClassNameItem = get_class_name_factory_default("OutlineListItem", styles_module_default4);
|
2246
|
+
var OutlineList = ({ children }) => {
|
2247
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { className: getClassName4(), children });
|
2248
|
+
};
|
2249
|
+
OutlineList.Clickable = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassNameItem({ clickable: true }), children });
|
2250
|
+
OutlineList.Item = ({
|
2251
|
+
children,
|
2252
|
+
onClick
|
2253
|
+
}) => {
|
2254
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
2255
|
+
"li",
|
2256
|
+
{
|
2257
|
+
className: getClassNameItem({ clickable: !!onClick }),
|
2258
|
+
onClick,
|
2259
|
+
children
|
2260
|
+
}
|
2261
|
+
);
|
2262
|
+
};
|
2263
|
+
|
2264
|
+
// ../core/lib/scroll-into-view.ts
|
2265
|
+
init_react_import();
|
2266
|
+
var scrollIntoView = (el) => {
|
2267
|
+
const oldStyle = __spreadValues({}, el.style);
|
2268
|
+
el.style.scrollMargin = "256px";
|
2269
|
+
if (el) {
|
2270
|
+
el == null ? void 0 : el.scrollIntoView({ behavior: "smooth" });
|
2271
|
+
el.style.scrollMargin = oldStyle.scrollMargin || "";
|
2272
|
+
}
|
2273
|
+
};
|
2274
|
+
|
2275
|
+
// ../core/lib/get-frame.ts
|
2276
|
+
init_react_import();
|
2277
|
+
var getFrame = () => {
|
2278
|
+
if (typeof window === "undefined") return;
|
2279
|
+
let frameEl = document.querySelector("#preview-frame");
|
2280
|
+
if ((frameEl == null ? void 0 : frameEl.tagName) === "IFRAME") {
|
2281
|
+
return frameEl.contentDocument || document;
|
2282
|
+
}
|
2283
|
+
return (frameEl == null ? void 0 : frameEl.ownerDocument) || document;
|
2284
|
+
};
|
2285
|
+
|
341
2286
|
// src/HeadingAnalyzer.tsx
|
342
2287
|
var import_react_from_json = __toESM(require("react-from-json"));
|
343
|
-
var
|
344
|
-
var
|
2288
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
2289
|
+
var getClassName5 = get_class_name_factory_default("HeadingAnalyzer", HeadingAnalyzer_module_default);
|
345
2290
|
var getClassNameItem2 = get_class_name_factory_default("HeadingAnalyzerItem", HeadingAnalyzer_module_default);
|
346
2291
|
var ReactFromJSON = import_react_from_json.default.default || import_react_from_json.default;
|
347
2292
|
var getOutline = ({ frame } = {}) => {
|
@@ -396,8 +2341,8 @@ function buildHierarchy(frame) {
|
|
396
2341
|
var usePuck = (0, import_puck.createUsePuck)();
|
397
2342
|
var HeadingAnalyzer = () => {
|
398
2343
|
const data = usePuck((s) => s.appState.data);
|
399
|
-
const [hierarchy, setHierarchy] = (0,
|
400
|
-
(0,
|
2344
|
+
const [hierarchy, setHierarchy] = (0, import_react12.useState)([]);
|
2345
|
+
(0, import_react12.useEffect)(() => {
|
401
2346
|
const frame = getFrame();
|
402
2347
|
let entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
|
403
2348
|
const createHierarchy = () => {
|
@@ -432,11 +2377,11 @@ var HeadingAnalyzer = () => {
|
|
432
2377
|
frameObserver.disconnect();
|
433
2378
|
};
|
434
2379
|
}, [data]);
|
435
|
-
return /* @__PURE__ */ (0,
|
436
|
-
/* @__PURE__ */ (0,
|
2380
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: getClassName5(), children: [
|
2381
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
437
2382
|
"small",
|
438
2383
|
{
|
439
|
-
className:
|
2384
|
+
className: getClassName5("cssWarning"),
|
440
2385
|
style: {
|
441
2386
|
color: "var(--puck-color-red-04)",
|
442
2387
|
display: "block",
|
@@ -445,19 +2390,19 @@ var HeadingAnalyzer = () => {
|
|
445
2390
|
children: [
|
446
2391
|
"Heading analyzer styles not loaded. Please review the",
|
447
2392
|
" ",
|
448
|
-
/* @__PURE__ */ (0,
|
2393
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("a", { href: "https://github.com/measuredco/puck/blob/main/packages/plugin-heading-analyzer/README.md", children: "README" }),
|
449
2394
|
"."
|
450
2395
|
]
|
451
2396
|
}
|
452
2397
|
),
|
453
|
-
hierarchy.length === 0 && /* @__PURE__ */ (0,
|
454
|
-
/* @__PURE__ */ (0,
|
2398
|
+
hierarchy.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: "No headings." }),
|
2399
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OutlineList, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
455
2400
|
ReactFromJSON,
|
456
2401
|
{
|
457
2402
|
mapping: {
|
458
|
-
Root: (props) => /* @__PURE__ */ (0,
|
459
|
-
OutlineListItem: (props) => /* @__PURE__ */ (0,
|
460
|
-
/* @__PURE__ */ (0,
|
2403
|
+
Root: (props) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: props.children }),
|
2404
|
+
OutlineListItem: (props) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(OutlineList.Item, { children: [
|
2405
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OutlineList.Clickable, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
461
2406
|
"small",
|
462
2407
|
{
|
463
2408
|
className: getClassNameItem2({ missing: props.missing }),
|
@@ -475,14 +2420,14 @@ var HeadingAnalyzer = () => {
|
|
475
2420
|
}, 2e3);
|
476
2421
|
}
|
477
2422
|
},
|
478
|
-
children: props.missing ? /* @__PURE__ */ (0,
|
479
|
-
/* @__PURE__ */ (0,
|
2423
|
+
children: props.missing ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
2424
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("b", { children: [
|
480
2425
|
"H",
|
481
2426
|
props.rank
|
482
2427
|
] }),
|
483
2428
|
": Missing"
|
484
|
-
] }) : /* @__PURE__ */ (0,
|
485
|
-
/* @__PURE__ */ (0,
|
2429
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
2430
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("b", { children: [
|
486
2431
|
"H",
|
487
2432
|
props.rank
|
488
2433
|
] }),
|
@@ -491,7 +2436,7 @@ var HeadingAnalyzer = () => {
|
|
491
2436
|
] })
|
492
2437
|
}
|
493
2438
|
) }),
|
494
|
-
/* @__PURE__ */ (0,
|
2439
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OutlineList, { children: props.children })
|
495
2440
|
] })
|
496
2441
|
},
|
497
2442
|
entry: {
|
@@ -512,10 +2457,12 @@ var HeadingAnalyzer = () => {
|
|
512
2457
|
] });
|
513
2458
|
};
|
514
2459
|
var headingAnalyzer = {
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
2460
|
+
overrides: {
|
2461
|
+
fields: ({ children, itemSelector }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
2462
|
+
children,
|
2463
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { display: itemSelector ? "none" : "block" }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SidebarSection, { title: "Heading Outline", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(HeadingAnalyzer, {}) }) })
|
2464
|
+
] })
|
2465
|
+
}
|
519
2466
|
};
|
520
2467
|
var HeadingAnalyzer_default = headingAnalyzer;
|
521
2468
|
/*! Bundled license information:
|
@@ -559,7 +2506,7 @@ lucide-react/dist/esm/createLucideIcon.js:
|
|
559
2506
|
* See the LICENSE file in the root directory of this source tree.
|
560
2507
|
*)
|
561
2508
|
|
562
|
-
lucide-react/dist/esm/icons/
|
2509
|
+
lucide-react/dist/esm/icons/chevron-right.js:
|
563
2510
|
(**
|
564
2511
|
* @license lucide-react v0.468.0 - ISC
|
565
2512
|
*
|