@crediblemark/build 0.22.0

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.
Files changed (52) hide show
  1. package/LICENSE +21 -0
  2. package/dist/Editor-XZF6CWVW.css +404 -0
  3. package/dist/Editor-ZC67OU2A.mjs +205 -0
  4. package/dist/Render-JBFI6HYN.mjs +55 -0
  5. package/dist/Render-WCX4AXOX.css +102 -0
  6. package/dist/actions-CEH_5LMY.d.mts +838 -0
  7. package/dist/actions-CEH_5LMY.d.ts +838 -0
  8. package/dist/chunk-3AJBFQU4.mjs +560 -0
  9. package/dist/chunk-4SQOX3ZQ.mjs +476 -0
  10. package/dist/chunk-B4BOBGYB.mjs +42 -0
  11. package/dist/chunk-CDMESQDA.mjs +148 -0
  12. package/dist/chunk-DSXRK4QJ.mjs +704 -0
  13. package/dist/chunk-GUJDGRSM.mjs +469 -0
  14. package/dist/chunk-HHBUU7WF.mjs +35 -0
  15. package/dist/chunk-IJHL7BIR.mjs +11 -0
  16. package/dist/chunk-PHGC6QYB.mjs +105 -0
  17. package/dist/chunk-QF3GD5WQ.mjs +65 -0
  18. package/dist/chunk-U2NVBXAC.mjs +2064 -0
  19. package/dist/chunk-VFD76OD5.mjs +55 -0
  20. package/dist/chunk-VGDMWS44.mjs +107 -0
  21. package/dist/chunk-VKBVSWU3.mjs +8538 -0
  22. package/dist/chunk-YH7AXYKP.mjs +109 -0
  23. package/dist/full-ABQQRJAO.css +301 -0
  24. package/dist/full-LJRK5736.mjs +94 -0
  25. package/dist/index-CkSfgrvw.d.ts +117 -0
  26. package/dist/index-Cxwg4vUV.d.mts +117 -0
  27. package/dist/index.css +2576 -0
  28. package/dist/index.d.mts +310 -0
  29. package/dist/index.d.ts +310 -0
  30. package/dist/index.js +15012 -0
  31. package/dist/index.mjs +83 -0
  32. package/dist/internal.d.mts +27 -0
  33. package/dist/internal.d.ts +27 -0
  34. package/dist/internal.js +960 -0
  35. package/dist/internal.mjs +13 -0
  36. package/dist/loaded-DWCENJKQ.mjs +55 -0
  37. package/dist/loaded-N7VXUR4O.mjs +59 -0
  38. package/dist/loaded-NE2PIHUQ.mjs +56 -0
  39. package/dist/loaded-SMEIWWHS.css +87 -0
  40. package/dist/no-external.css +2574 -0
  41. package/dist/no-external.d.mts +21 -0
  42. package/dist/no-external.d.ts +21 -0
  43. package/dist/no-external.js +15012 -0
  44. package/dist/no-external.mjs +83 -0
  45. package/dist/rsc.css +102 -0
  46. package/dist/rsc.d.mts +27 -0
  47. package/dist/rsc.d.ts +27 -0
  48. package/dist/rsc.js +1466 -0
  49. package/dist/rsc.mjs +147 -0
  50. package/dist/walk-tree-B4ZvMfxS.d.ts +29 -0
  51. package/dist/walk-tree-C78ZVz19.d.mts +29 -0
  52. package/package.json +145 -0
@@ -0,0 +1,476 @@
1
+ import {
2
+ styles_module_default
3
+ } from "./chunk-IJHL7BIR.mjs";
4
+ import {
5
+ defaultAppState,
6
+ resolveComponentData
7
+ } from "./chunk-CDMESQDA.mjs";
8
+ import {
9
+ get_class_name_factory_default
10
+ } from "./chunk-YH7AXYKP.mjs";
11
+ import {
12
+ generateId,
13
+ getZoneId,
14
+ mapFields,
15
+ toComponent,
16
+ walkAppState,
17
+ walkTree
18
+ } from "./chunk-GUJDGRSM.mjs";
19
+ import {
20
+ init_react_import
21
+ } from "./chunk-B4BOBGYB.mjs";
22
+
23
+ // lib/migrate.ts
24
+ init_react_import();
25
+ var migrations = [
26
+ // Migrate root to root.props
27
+ (data) => {
28
+ const rootProps = data.root.props || data.root;
29
+ if (Object.keys(data.root).length > 0 && !data.root.props) {
30
+ console.warn(
31
+ "Migration applied: Root props moved from `root` to `root.props`."
32
+ );
33
+ return {
34
+ ...data,
35
+ root: {
36
+ props: {
37
+ ...rootProps
38
+ }
39
+ }
40
+ };
41
+ }
42
+ return data;
43
+ },
44
+ // Migrate zones to slots
45
+ (data, config, migrationOptions) => {
46
+ if (!config) return data;
47
+ console.log("Migrating DropZones to slots...");
48
+ const updatedItems = {};
49
+ const appState = { ...defaultAppState, data };
50
+ const { indexes } = walkAppState(appState, config);
51
+ const deletedCompounds = [];
52
+ walkAppState(appState, config, (content, zoneCompound, zoneType) => {
53
+ if (zoneType === "dropzone") {
54
+ const [id, slotName] = zoneCompound.split(":");
55
+ const nodeData = indexes.nodes[id].data;
56
+ const componentType = nodeData.type;
57
+ const configForComponent = id === "root" ? config.root : config.components[componentType];
58
+ if (configForComponent?.fields?.[slotName]?.type === "slot") {
59
+ updatedItems[id] = {
60
+ ...nodeData,
61
+ props: {
62
+ ...nodeData.props,
63
+ ...updatedItems[id]?.props,
64
+ [slotName]: content
65
+ }
66
+ };
67
+ deletedCompounds.push(zoneCompound);
68
+ }
69
+ return content;
70
+ }
71
+ return content;
72
+ });
73
+ const updated = walkAppState(
74
+ appState,
75
+ config,
76
+ (content) => content,
77
+ (item) => {
78
+ return updatedItems[item.props.id] ?? item;
79
+ }
80
+ );
81
+ deletedCompounds.forEach((zoneCompound) => {
82
+ const [_, propName] = zoneCompound.split(":");
83
+ console.log(
84
+ `\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
85
+ );
86
+ delete updated.data.zones?.[zoneCompound];
87
+ });
88
+ if (migrationOptions?.migrateDynamicZonesForComponent) {
89
+ const unmigratedZonesGrouped = {};
90
+ Object.keys(updated.data.zones ?? {}).forEach((zoneCompound) => {
91
+ const [componentId, propName] = zoneCompound.split(":");
92
+ const content = updated.data.zones?.[zoneCompound];
93
+ if (!content) {
94
+ return;
95
+ }
96
+ if (!unmigratedZonesGrouped[componentId]) {
97
+ unmigratedZonesGrouped[componentId] = {};
98
+ }
99
+ if (!unmigratedZonesGrouped[componentId][propName]) {
100
+ unmigratedZonesGrouped[componentId][propName] = content;
101
+ }
102
+ });
103
+ Object.keys(unmigratedZonesGrouped).forEach((componentId) => {
104
+ updated.data = walkTree(updated.data, config, (content) => {
105
+ return content.map((child) => {
106
+ if (child.props.id !== componentId) {
107
+ return child;
108
+ }
109
+ const migrateFn = migrationOptions?.migrateDynamicZonesForComponent?.[child.type];
110
+ if (!migrateFn) {
111
+ return child;
112
+ }
113
+ const zones = unmigratedZonesGrouped[componentId];
114
+ const migratedProps = migrateFn(child.props, zones);
115
+ Object.keys(zones).forEach((propName) => {
116
+ const zoneCompound = `${componentId}:${propName}`;
117
+ console.log(`\u2713 Success: Migrated "${zoneCompound}" DropZone`);
118
+ delete updated.data.zones?.[zoneCompound];
119
+ });
120
+ return {
121
+ ...child,
122
+ props: migratedProps
123
+ };
124
+ });
125
+ });
126
+ });
127
+ }
128
+ Object.keys(updated.data.zones ?? {}).forEach((zoneCompound) => {
129
+ const [_, propName] = zoneCompound.split(":");
130
+ throw new Error(
131
+ `Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
132
+ );
133
+ });
134
+ delete updated.data.zones;
135
+ return updated.data;
136
+ }
137
+ ];
138
+ function migrate(data, config, migrationOptions) {
139
+ return migrations?.reduce(
140
+ (acc, migration) => migration(acc, config, migrationOptions),
141
+ data
142
+ );
143
+ }
144
+
145
+ // lib/transform-props.ts
146
+ init_react_import();
147
+
148
+ // lib/data/default-data.ts
149
+ init_react_import();
150
+ var defaultData = (data) => ({
151
+ ...data,
152
+ root: data.root || {},
153
+ content: data.content || []
154
+ });
155
+
156
+ // lib/transform-props.ts
157
+ function transformProps(data, propTransforms, config = { components: {} }) {
158
+ const mapItem = (item) => {
159
+ if (propTransforms[item.type]) {
160
+ return {
161
+ ...item,
162
+ props: {
163
+ id: item.props.id,
164
+ ...propTransforms[item.type](item.props)
165
+ }
166
+ };
167
+ }
168
+ return item;
169
+ };
170
+ const defaultedData = defaultData(data);
171
+ const rootProps = defaultedData.root.props || defaultedData.root;
172
+ let newRoot = { ...defaultedData.root };
173
+ if (propTransforms["root"]) {
174
+ newRoot.props = propTransforms["root"](rootProps);
175
+ }
176
+ const dataWithUpdatedRoot = { ...defaultedData, root: newRoot };
177
+ const updatedData = walkTree(
178
+ dataWithUpdatedRoot,
179
+ config,
180
+ (content) => content.map(mapItem)
181
+ );
182
+ if (!defaultedData.root.props) {
183
+ updatedData.root = updatedData.root.props;
184
+ }
185
+ return updatedData;
186
+ }
187
+
188
+ // lib/resolve-all-data.ts
189
+ init_react_import();
190
+
191
+ // lib/group-zones-by-component.ts
192
+ init_react_import();
193
+ var groupZonesByComponent = (data) => {
194
+ const zoneEntries = Object.entries(data.zones ?? {});
195
+ return zoneEntries.reduce((acc, [zoneCompound, zoneContent]) => {
196
+ const [componentId, zoneName] = getZoneId(zoneCompound);
197
+ if (!componentId.length || !zoneName.length) return acc;
198
+ if (!acc[componentId]) {
199
+ acc[componentId] = [];
200
+ }
201
+ acc[componentId].push({ zoneCompound, content: zoneContent });
202
+ return acc;
203
+ }, {});
204
+ };
205
+
206
+ // lib/resolve-all-data.ts
207
+ async function resolveAllData(data, config, metadata = {}, onResolveStart, onResolveEnd) {
208
+ const defaultedData = defaultData(data);
209
+ const zonesByComponent = groupZonesByComponent(defaultedData);
210
+ let resolvedZones = {};
211
+ const resolveNode = async (_node, parent) => {
212
+ const node = toComponent(_node);
213
+ onResolveStart?.(node);
214
+ const resolved = (await resolveComponentData(
215
+ node,
216
+ config,
217
+ metadata,
218
+ () => {
219
+ },
220
+ () => {
221
+ },
222
+ "force",
223
+ parent
224
+ )).node;
225
+ const resolvedAsComponent = toComponent(resolved);
226
+ const resolvedDeepPromise = mapFields(
227
+ resolved,
228
+ {
229
+ slot: ({ value }) => processContent(value, resolvedAsComponent)
230
+ },
231
+ config
232
+ );
233
+ let resolveZonePromises = [];
234
+ if (zonesByComponent[resolvedAsComponent.props.id]) {
235
+ resolveZonePromises = zonesByComponent[resolvedAsComponent.props.id].map(
236
+ async ({ zoneCompound, content }) => {
237
+ resolvedZones[zoneCompound] = await processContent(
238
+ content,
239
+ resolvedAsComponent
240
+ );
241
+ }
242
+ );
243
+ }
244
+ const resolvedDeep = await resolvedDeepPromise;
245
+ await Promise.all(resolveZonePromises);
246
+ onResolveEnd?.(toComponent(resolvedDeep));
247
+ return resolvedDeep;
248
+ };
249
+ const processContent = async (content, parent) => {
250
+ return Promise.all(content.map((item) => resolveNode(item, parent)));
251
+ };
252
+ const result = defaultData({});
253
+ result.root = await resolveNode(defaultedData.root, null);
254
+ result.content = await processContent(
255
+ defaultedData.content,
256
+ toComponent(result.root)
257
+ );
258
+ result.zones = resolvedZones;
259
+ return result;
260
+ }
261
+
262
+ // lib/field-transforms/default-transforms/slot-transform.tsx
263
+ init_react_import();
264
+ var getSlotTransform = (renderSlotEdit, renderSlotRender = renderSlotEdit) => ({
265
+ slot: ({ value: content, propName, field, isReadOnly }) => {
266
+ const render = isReadOnly ? renderSlotRender : renderSlotEdit;
267
+ const Slot = (dzProps) => render({
268
+ allow: field?.type === "slot" ? field.allow : [],
269
+ disallow: field?.type === "slot" ? field.disallow : [],
270
+ ...dzProps,
271
+ zone: propName,
272
+ content
273
+ });
274
+ return Slot;
275
+ }
276
+ });
277
+
278
+ // lib/use-slots.tsx
279
+ init_react_import();
280
+
281
+ // lib/field-transforms/use-field-transforms.tsx
282
+ init_react_import();
283
+ import { useMemo } from "react";
284
+
285
+ // lib/field-transforms/build-mappers.ts
286
+ init_react_import();
287
+ function buildMappers(transforms, readOnly, forceReadOnly) {
288
+ return Object.keys(transforms).reduce((acc, _fieldType) => {
289
+ const fieldType = _fieldType;
290
+ return {
291
+ ...acc,
292
+ [fieldType]: ({
293
+ parentId,
294
+ ...params
295
+ }) => {
296
+ const wildcardPath = params.propPath.replace(/\[\d+\]/g, "[*]");
297
+ const isReadOnly = readOnly?.[params.propPath] || readOnly?.[wildcardPath] || forceReadOnly || false;
298
+ const fn = transforms[fieldType];
299
+ return fn?.({
300
+ ...params,
301
+ isReadOnly,
302
+ componentId: parentId
303
+ });
304
+ }
305
+ };
306
+ }, {});
307
+ }
308
+
309
+ // lib/field-transforms/use-field-transforms.tsx
310
+ function useFieldTransforms(config, item, transforms, readOnly, forceReadOnly) {
311
+ const mappers = useMemo(
312
+ () => buildMappers(transforms, readOnly, forceReadOnly),
313
+ [transforms, readOnly, forceReadOnly]
314
+ );
315
+ const transformedProps = useMemo(() => {
316
+ return mapFields(item, mappers, config).props;
317
+ }, [config, item, mappers]);
318
+ const mergedProps = useMemo(
319
+ () => ({ ...item.props, ...transformedProps }),
320
+ [item.props, transformedProps]
321
+ );
322
+ return mergedProps;
323
+ }
324
+
325
+ // lib/use-slots.tsx
326
+ function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
327
+ return useFieldTransforms(
328
+ config,
329
+ item,
330
+ getSlotTransform(renderSlotEdit, renderSlotRender),
331
+ readOnly,
332
+ forceReadOnly
333
+ );
334
+ }
335
+
336
+ // components/RichTextEditor/lib/use-richtext-props.tsx
337
+ init_react_import();
338
+ import { lazy, Suspense, useMemo as useMemo2 } from "react";
339
+
340
+ // components/RichTextEditor/components/RenderFallback.tsx
341
+ init_react_import();
342
+ import { jsx } from "react/jsx-runtime";
343
+ var getClassName = get_class_name_factory_default("RichTextEditor", styles_module_default);
344
+ function RichTextRenderFallback({ content }) {
345
+ return /* @__PURE__ */ jsx("div", { className: getClassName(), children: /* @__PURE__ */ jsx(
346
+ "div",
347
+ {
348
+ className: "rich-text",
349
+ dangerouslySetInnerHTML: { __html: content }
350
+ }
351
+ ) });
352
+ }
353
+
354
+ // components/RichTextEditor/lib/mapDeep.ts
355
+ init_react_import();
356
+ var mapDeep = (source, path, render) => {
357
+ if (!source) {
358
+ return null;
359
+ }
360
+ if (path.length === 0) {
361
+ return render(source);
362
+ }
363
+ const [key, ...rest] = path;
364
+ if (Array.isArray(source)) {
365
+ return source.map((item) => mapDeep(item, path, render));
366
+ }
367
+ return {
368
+ ...source,
369
+ [key]: mapDeep(source[key], rest, render)
370
+ };
371
+ };
372
+
373
+ // components/RichTextEditor/lib/use-richtext-props.tsx
374
+ import { jsx as jsx2 } from "react/jsx-runtime";
375
+ var findAllRichtextKeys = (fields, path = []) => {
376
+ if (!fields) return [];
377
+ const result = [];
378
+ for (const [key, field] of Object.entries(fields)) {
379
+ const currentPath = [...path, key];
380
+ if (field.type === "richtext") {
381
+ result.push({
382
+ path: currentPath,
383
+ field
384
+ });
385
+ }
386
+ if (field.type === "array" && "arrayFields" in field) {
387
+ result.push(...findAllRichtextKeys(field.arrayFields, currentPath));
388
+ }
389
+ if (field.type === "object" && "objectFields" in field) {
390
+ result.push(...findAllRichtextKeys(field.objectFields, currentPath));
391
+ }
392
+ }
393
+ return result;
394
+ };
395
+ function useRichtextProps(fields, props) {
396
+ const richtextKeys = useMemo2(() => findAllRichtextKeys(fields), [fields]);
397
+ const richtextProps = useMemo2(() => {
398
+ if (!richtextKeys?.length) return {};
399
+ const RichTextRender = lazy(
400
+ () => import("./Render-JBFI6HYN.mjs").then((m) => ({
401
+ default: m.RichTextRender
402
+ }))
403
+ );
404
+ let result = { ...props };
405
+ for (const { path, field } of richtextKeys) {
406
+ result = mapDeep(result, path, (content) => /* @__PURE__ */ jsx2(
407
+ Suspense,
408
+ {
409
+ fallback: /* @__PURE__ */ jsx2(RichTextRenderFallback, { content }),
410
+ children: /* @__PURE__ */ jsx2(RichTextRender, { content, field })
411
+ },
412
+ generateId()
413
+ ));
414
+ }
415
+ return result;
416
+ }, [richtextKeys, props]);
417
+ return richtextProps;
418
+ }
419
+
420
+ // components/SlotRender/server.tsx
421
+ init_react_import();
422
+ import { forwardRef } from "react";
423
+ import { jsx as jsx3 } from "react/jsx-runtime";
424
+ var SlotRenderPure = (props) => /* @__PURE__ */ jsx3(SlotRender, { ...props });
425
+ var Item = ({
426
+ config,
427
+ item,
428
+ metadata
429
+ }) => {
430
+ const Component = config.components[item.type];
431
+ const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ jsx3(SlotRenderPure, { ...slotProps, config, metadata }));
432
+ const richtextProps = useRichtextProps(Component.fields, props);
433
+ return /* @__PURE__ */ jsx3(
434
+ Component.render,
435
+ {
436
+ ...props,
437
+ ...richtextProps,
438
+ credbuild: {
439
+ ...props.credbuild,
440
+ metadata: metadata || {}
441
+ }
442
+ }
443
+ );
444
+ };
445
+ var SlotRender = forwardRef(
446
+ function SlotRenderInternal({ className, style, content, config, metadata, as }, ref) {
447
+ const El = as ?? "div";
448
+ return /* @__PURE__ */ jsx3(El, { className, style, ref, children: content.map((item) => {
449
+ if (!config.components[item.type]) {
450
+ return null;
451
+ }
452
+ return /* @__PURE__ */ jsx3(
453
+ Item,
454
+ {
455
+ config,
456
+ item,
457
+ metadata
458
+ },
459
+ item.props.id
460
+ );
461
+ }) });
462
+ }
463
+ );
464
+
465
+ export {
466
+ buildMappers,
467
+ getSlotTransform,
468
+ useSlots,
469
+ RichTextRenderFallback,
470
+ useRichtextProps,
471
+ SlotRenderPure,
472
+ SlotRender,
473
+ migrate,
474
+ transformProps,
475
+ resolveAllData
476
+ };
@@ -0,0 +1,42 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __esm = (fn, res) => function __init() {
8
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
+ };
10
+ var __commonJS = (cb, mod) => function __require() {
11
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+
30
+ // react-import.js
31
+ import React from "react";
32
+ var init_react_import = __esm({
33
+ "react-import.js"() {
34
+ "use strict";
35
+ }
36
+ });
37
+
38
+ export {
39
+ __commonJS,
40
+ __toESM,
41
+ init_react_import
42
+ };
@@ -0,0 +1,148 @@
1
+ import {
2
+ mapFields,
3
+ toComponent
4
+ } from "./chunk-GUJDGRSM.mjs";
5
+ import {
6
+ init_react_import
7
+ } from "./chunk-B4BOBGYB.mjs";
8
+
9
+ // components/ViewportControls/default-viewports.ts
10
+ init_react_import();
11
+ var defaultViewports = [
12
+ { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
13
+ { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
14
+ { width: 1280, height: "auto", icon: "Monitor", label: "Large" },
15
+ { width: "100%", height: "auto", icon: "FullWidth", label: "Full-width" }
16
+ ];
17
+
18
+ // lib/resolve-component-data.ts
19
+ init_react_import();
20
+
21
+ // lib/get-changed.ts
22
+ init_react_import();
23
+ import { deepEqual } from "fast-equals";
24
+ var getChanged = (newItem, oldItem) => {
25
+ return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
26
+ const newItemProps = newItem?.props || {};
27
+ const oldItemProps = oldItem?.props || {};
28
+ return {
29
+ ...acc,
30
+ [item]: !deepEqual(oldItemProps[item], newItemProps[item])
31
+ };
32
+ }, {}) : {};
33
+ };
34
+
35
+ // lib/resolve-component-data.ts
36
+ import { deepEqual as deepEqual2 } from "fast-equals";
37
+ var cache = { lastChange: {} };
38
+ var resolveComponentData = async (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", parent = null) => {
39
+ const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
40
+ const resolvedItem = {
41
+ ...item
42
+ };
43
+ const shouldRunResolver = configForItem?.resolveData && item.props;
44
+ const id = "id" in item.props ? item.props.id : "root";
45
+ if (shouldRunResolver) {
46
+ const {
47
+ item: oldItem = null,
48
+ resolved = {},
49
+ parentId: oldParentId = null
50
+ } = cache.lastChange[id] || {};
51
+ const isRootOrInserted = oldParentId === null;
52
+ const parentChanged = !isRootOrInserted && parent?.props.id !== oldParentId;
53
+ const dataChanged = item && !deepEqual2(item, oldItem);
54
+ const shouldSkip = trigger === "move" && !parentChanged || trigger !== "move" && trigger !== "force" && !dataChanged;
55
+ if (shouldSkip) {
56
+ return { node: resolved, didChange: false };
57
+ }
58
+ const changed = getChanged(item, oldItem);
59
+ if (onResolveStart) {
60
+ onResolveStart(item);
61
+ }
62
+ const { props: resolvedProps, readOnly = {} } = await configForItem.resolveData(item, {
63
+ changed,
64
+ lastData: oldItem,
65
+ metadata: { ...metadata, ...configForItem.metadata },
66
+ trigger,
67
+ parent
68
+ });
69
+ resolvedItem.props = {
70
+ ...item.props,
71
+ ...resolvedProps
72
+ };
73
+ if (Object.keys(readOnly).length) {
74
+ resolvedItem.readOnly = readOnly;
75
+ }
76
+ }
77
+ const itemAsComponentData = toComponent(resolvedItem);
78
+ let itemWithResolvedChildren = await mapFields(
79
+ resolvedItem,
80
+ {
81
+ slot: async ({ value }) => {
82
+ const content = value;
83
+ return await Promise.all(
84
+ content.map(
85
+ async (childItem) => (await resolveComponentData(
86
+ childItem,
87
+ config,
88
+ metadata,
89
+ onResolveStart,
90
+ onResolveEnd,
91
+ trigger,
92
+ itemAsComponentData
93
+ )).node
94
+ )
95
+ );
96
+ }
97
+ },
98
+ config
99
+ );
100
+ if (shouldRunResolver && onResolveEnd) {
101
+ onResolveEnd(resolvedItem);
102
+ }
103
+ cache.lastChange[id] = {
104
+ item,
105
+ resolved: itemWithResolvedChildren,
106
+ parentId: parent?.props.id
107
+ };
108
+ return {
109
+ node: itemWithResolvedChildren,
110
+ didChange: !deepEqual2(item, itemWithResolvedChildren)
111
+ };
112
+ };
113
+
114
+ // store/default-app-state.ts
115
+ init_react_import();
116
+ var defaultAppState = {
117
+ data: { content: [], root: {}, zones: {} },
118
+ ui: {
119
+ leftSideBarVisible: true,
120
+ rightSideBarVisible: true,
121
+ arrayState: {},
122
+ itemSelector: null,
123
+ componentList: {},
124
+ isDragging: false,
125
+ previewMode: "edit",
126
+ viewports: {
127
+ current: {
128
+ width: defaultViewports[0].width,
129
+ height: defaultViewports[0].height || "auto"
130
+ },
131
+ options: [],
132
+ controlsVisible: true
133
+ },
134
+ field: { focus: null },
135
+ plugin: { current: null }
136
+ },
137
+ indexes: {
138
+ nodes: {},
139
+ zones: {}
140
+ }
141
+ };
142
+
143
+ export {
144
+ defaultViewports,
145
+ getChanged,
146
+ resolveComponentData,
147
+ defaultAppState
148
+ };