@crediblemark/build 0.25.7 → 0.25.8
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/ArrayField-HYHS4HCO.mjs +17 -0
- package/dist/{Editor-GDIQRAYD.mjs → Editor-P3UUWNSZ.mjs} +8 -10
- package/dist/ObjectField-4N5XWAFL.mjs +17 -0
- package/dist/{actions-LaZpJ1KE.d.ts → actions-CKSDxt4l.d.mts} +1 -1
- package/dist/{actions-LaZpJ1KE.d.mts → actions-CKSDxt4l.d.ts} +1 -1
- package/dist/{chunk-J2UWT4L6.mjs → chunk-44PQTFGV.mjs} +5 -7
- package/dist/{chunk-23V3TMNT.mjs → chunk-AZFZRLP7.mjs} +7 -7
- package/dist/{chunk-ETN6FGIH.mjs → chunk-E4F5M5JH.mjs} +1 -1
- package/dist/chunk-HHKM5MBJ.mjs +3163 -0
- package/dist/{chunk-M4S65TWW.mjs → chunk-KN26YZZJ.mjs} +285 -130
- package/dist/{chunk-ERLZ5CJF.mjs → chunk-MWCFPGI6.mjs} +1153 -3236
- package/dist/{chunk-64A37UUC.mjs → chunk-O44M27KT.mjs} +442 -7
- package/dist/{chunk-EDTYTRV5.mjs → chunk-P2AZFZ7Q.mjs} +2 -2
- package/dist/{chunk-GUUI5HW3.mjs → chunk-PFHKXXSV.mjs} +1 -1
- package/dist/{chunk-JERQUUM4.mjs → chunk-S32JZ2HU.mjs} +1 -1
- package/dist/{chunk-35OY5UFR.mjs → chunk-T2LBDQLG.mjs} +7 -7
- package/dist/{chunk-EWOJLVHT.mjs → chunk-XLRMLBFR.mjs} +1 -1
- package/dist/{chunk-BXF2PDCW.mjs → chunk-Z7DDX2XU.mjs} +2 -2
- package/dist/{full-Y52CQK4X.mjs → full-3VRJOFG5.mjs} +6 -8
- package/dist/{index-CD3PszvP.d.mts → index-Ds4Dkkyr.d.mts} +1 -1
- package/dist/{index-Bj2x5pZ7.d.ts → index-DwajIHZf.d.ts} +1 -1
- package/dist/index.css +188 -2
- package/dist/index.d.mts +8 -40
- package/dist/index.d.ts +8 -40
- package/dist/index.js +1224 -567
- package/dist/index.mjs +25 -25
- package/dist/internal.d.mts +2 -2
- package/dist/internal.d.ts +2 -2
- package/dist/internal.mjs +1 -2
- package/dist/{loaded-K43N3OFP.mjs → loaded-C2JGMUXV.mjs} +3 -5
- package/dist/{loaded-MWBOE5CB.mjs → loaded-FJHWTGH6.mjs} +3 -5
- package/dist/{loaded-IWWCJE75.mjs → loaded-NTEK7RT3.mjs} +3 -5
- package/dist/no-external.css +188 -2
- package/dist/no-external.d.mts +4 -4
- package/dist/no-external.d.ts +4 -4
- package/dist/no-external.js +1224 -567
- package/dist/no-external.mjs +25 -25
- package/dist/rsc.css +1420 -0
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +10324 -1007
- package/dist/rsc.mjs +20 -3
- package/dist/{walk-tree-BEw6kTXm.d.ts → walk-tree-B_jHFa3L.d.mts} +39 -2
- package/dist/{walk-tree-BO8uRNcW.d.mts → walk-tree-DHMRjk5Z.d.ts} +39 -2
- package/package.json +1 -1
- package/dist/ArrayField-OIQQLS2B.mjs +0 -19
- package/dist/ObjectField-WOW3T2WS.mjs +0 -19
- package/dist/chunk-2RLA42JA.mjs +0 -455
- package/dist/chunk-7LXZOPYT.mjs +0 -445
- package/dist/chunk-SMAWAXVX.mjs +0 -139
package/dist/chunk-7LXZOPYT.mjs
DELETED
|
@@ -1,445 +0,0 @@
|
|
|
1
|
-
// lib/data/default-slots.ts
|
|
2
|
-
var defaultSlots = (value, fields) => Object.keys(fields).reduce(
|
|
3
|
-
(acc, fieldName) => fields[fieldName].type === "slot" ? { [fieldName]: [], ...acc } : acc,
|
|
4
|
-
value
|
|
5
|
-
);
|
|
6
|
-
|
|
7
|
-
// lib/data/map-fields.ts
|
|
8
|
-
var isPromise = (v) => !!v && typeof v.then === "function";
|
|
9
|
-
var flatten = (values) => values.reduce((acc, item) => ({ ...acc, ...item }), {});
|
|
10
|
-
var containsPromise = (arr) => arr.some(isPromise);
|
|
11
|
-
var walkField = ({
|
|
12
|
-
value,
|
|
13
|
-
fields,
|
|
14
|
-
mappers,
|
|
15
|
-
propKey = "",
|
|
16
|
-
propPath = "",
|
|
17
|
-
id = "",
|
|
18
|
-
config,
|
|
19
|
-
recurseSlots = false
|
|
20
|
-
}) => {
|
|
21
|
-
const fieldType = fields[propKey]?.type;
|
|
22
|
-
const map = mappers[fieldType];
|
|
23
|
-
if (map && fieldType === "slot") {
|
|
24
|
-
const content = value || [];
|
|
25
|
-
const mappedContent = recurseSlots ? content.map((el) => {
|
|
26
|
-
const componentConfig = config.components[el.type];
|
|
27
|
-
if (!componentConfig) {
|
|
28
|
-
throw new Error(`Could not find component config for ${el.type}`);
|
|
29
|
-
}
|
|
30
|
-
const fields2 = componentConfig.fields ?? {};
|
|
31
|
-
return walkField({
|
|
32
|
-
value: { ...el, props: defaultSlots(el.props, fields2) },
|
|
33
|
-
fields: fields2,
|
|
34
|
-
mappers,
|
|
35
|
-
id: el.props.id,
|
|
36
|
-
config,
|
|
37
|
-
recurseSlots
|
|
38
|
-
});
|
|
39
|
-
}) : content;
|
|
40
|
-
if (containsPromise(mappedContent)) {
|
|
41
|
-
return Promise.all(mappedContent);
|
|
42
|
-
}
|
|
43
|
-
return map({
|
|
44
|
-
value: mappedContent,
|
|
45
|
-
parentId: id,
|
|
46
|
-
propName: propPath,
|
|
47
|
-
field: fields[propKey],
|
|
48
|
-
propPath
|
|
49
|
-
});
|
|
50
|
-
} else if (map && fields[propKey]) {
|
|
51
|
-
return map({
|
|
52
|
-
value,
|
|
53
|
-
parentId: id,
|
|
54
|
-
propName: propKey,
|
|
55
|
-
field: fields[propKey],
|
|
56
|
-
propPath
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
if (value && typeof value === "object") {
|
|
60
|
-
if (Array.isArray(value)) {
|
|
61
|
-
const arrayFields = fields[propKey]?.type === "array" ? fields[propKey].arrayFields : null;
|
|
62
|
-
if (!arrayFields) return value;
|
|
63
|
-
const newValue = value.map(
|
|
64
|
-
(el, idx) => walkField({
|
|
65
|
-
value: el,
|
|
66
|
-
fields: arrayFields,
|
|
67
|
-
mappers,
|
|
68
|
-
propKey,
|
|
69
|
-
propPath: `${propPath}[${idx}]`,
|
|
70
|
-
id,
|
|
71
|
-
config,
|
|
72
|
-
recurseSlots
|
|
73
|
-
})
|
|
74
|
-
);
|
|
75
|
-
if (containsPromise(newValue)) {
|
|
76
|
-
return Promise.all(newValue);
|
|
77
|
-
}
|
|
78
|
-
return newValue;
|
|
79
|
-
} else if ("$$typeof" in value) {
|
|
80
|
-
return value;
|
|
81
|
-
} else {
|
|
82
|
-
const objectFields = fields[propKey]?.type === "object" ? fields[propKey].objectFields : fields;
|
|
83
|
-
return walkObject({
|
|
84
|
-
value,
|
|
85
|
-
fields: objectFields,
|
|
86
|
-
mappers,
|
|
87
|
-
id,
|
|
88
|
-
getPropPath: (k) => `${propPath}.${k}`,
|
|
89
|
-
config,
|
|
90
|
-
recurseSlots
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return value;
|
|
95
|
-
};
|
|
96
|
-
var walkObject = ({
|
|
97
|
-
value,
|
|
98
|
-
fields,
|
|
99
|
-
mappers,
|
|
100
|
-
id,
|
|
101
|
-
getPropPath,
|
|
102
|
-
config,
|
|
103
|
-
recurseSlots
|
|
104
|
-
}) => {
|
|
105
|
-
const newProps = Object.entries(value).map(([k, v]) => {
|
|
106
|
-
const opts = {
|
|
107
|
-
value: v,
|
|
108
|
-
fields,
|
|
109
|
-
mappers,
|
|
110
|
-
propKey: k,
|
|
111
|
-
propPath: getPropPath(k),
|
|
112
|
-
id,
|
|
113
|
-
config,
|
|
114
|
-
recurseSlots
|
|
115
|
-
};
|
|
116
|
-
const newValue = walkField(opts);
|
|
117
|
-
if (isPromise(newValue)) {
|
|
118
|
-
return newValue.then((resolvedValue) => ({
|
|
119
|
-
[k]: resolvedValue
|
|
120
|
-
}));
|
|
121
|
-
}
|
|
122
|
-
return {
|
|
123
|
-
[k]: newValue
|
|
124
|
-
};
|
|
125
|
-
}, {});
|
|
126
|
-
if (containsPromise(newProps)) {
|
|
127
|
-
return Promise.all(newProps).then(flatten);
|
|
128
|
-
}
|
|
129
|
-
return flatten(newProps);
|
|
130
|
-
};
|
|
131
|
-
function mapFields(item, mappers, config, recurseSlots = false, shouldDefaultSlots = true) {
|
|
132
|
-
const itemType = "type" in item ? item.type : "root";
|
|
133
|
-
const componentConfig = itemType === "root" ? config.root : config.components?.[itemType];
|
|
134
|
-
const newProps = walkObject({
|
|
135
|
-
value: shouldDefaultSlots ? defaultSlots(item.props ?? {}, componentConfig?.fields ?? {}) : item.props,
|
|
136
|
-
fields: componentConfig?.fields ?? {},
|
|
137
|
-
mappers,
|
|
138
|
-
id: item.props ? item.props.id ?? "root" : "root",
|
|
139
|
-
getPropPath: (k) => k,
|
|
140
|
-
config,
|
|
141
|
-
recurseSlots
|
|
142
|
-
});
|
|
143
|
-
if (isPromise(newProps)) {
|
|
144
|
-
return newProps.then((resolvedProps) => ({
|
|
145
|
-
...item,
|
|
146
|
-
props: resolvedProps
|
|
147
|
-
}));
|
|
148
|
-
}
|
|
149
|
-
return {
|
|
150
|
-
...item,
|
|
151
|
-
props: newProps
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// lib/data/walk-tree.ts
|
|
156
|
-
function walkTree(data, config, callbackFn) {
|
|
157
|
-
const walkItem = (item) => {
|
|
158
|
-
return mapFields(
|
|
159
|
-
item,
|
|
160
|
-
{
|
|
161
|
-
slot: ({ value, parentId, propName }) => {
|
|
162
|
-
const content = value;
|
|
163
|
-
return callbackFn(content, { parentId, propName }) ?? content;
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
config,
|
|
167
|
-
true
|
|
168
|
-
);
|
|
169
|
-
};
|
|
170
|
-
if ("props" in data) {
|
|
171
|
-
return walkItem(data);
|
|
172
|
-
}
|
|
173
|
-
const _data = data;
|
|
174
|
-
const zones = _data.zones ?? {};
|
|
175
|
-
const mappedContent = _data.content.map(walkItem);
|
|
176
|
-
return {
|
|
177
|
-
root: walkItem(_data.root),
|
|
178
|
-
content: callbackFn(mappedContent, {
|
|
179
|
-
parentId: "root",
|
|
180
|
-
propName: "default-zone"
|
|
181
|
-
}) ?? mappedContent,
|
|
182
|
-
zones: Object.keys(zones).reduce(
|
|
183
|
-
(acc, zoneCompound) => ({
|
|
184
|
-
...acc,
|
|
185
|
-
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
|
186
|
-
}),
|
|
187
|
-
{}
|
|
188
|
-
)
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// lib/generate-id.ts
|
|
193
|
-
import { v4 as uuidv4 } from "uuid";
|
|
194
|
-
var generateId = (type) => type ? `${type}-${uuidv4()}` : uuidv4();
|
|
195
|
-
|
|
196
|
-
// lib/root-droppable-id.ts
|
|
197
|
-
var rootAreaId = "root";
|
|
198
|
-
var rootZone = "default-zone";
|
|
199
|
-
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
|
200
|
-
|
|
201
|
-
// lib/data/flatten-node.ts
|
|
202
|
-
import flat from "flat";
|
|
203
|
-
|
|
204
|
-
// lib/data/strip-slots.ts
|
|
205
|
-
var stripSlots = (data, config) => {
|
|
206
|
-
return mapFields(data, { slot: () => null }, config);
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
// lib/data/flatten-node.ts
|
|
210
|
-
var { flatten: flatten2, unflatten } = flat;
|
|
211
|
-
var isPureObject = (val) => val != null && Object.prototype.toString.call(val) === "[object Object]";
|
|
212
|
-
var emptyArrayStr = "__credbuild_[]";
|
|
213
|
-
var emptyObjectStr = "__credbuild_{}";
|
|
214
|
-
function encodeEmptyObjects(props = {}) {
|
|
215
|
-
const result = {};
|
|
216
|
-
for (const key in props) {
|
|
217
|
-
if (!Object.prototype.hasOwnProperty.call(props, key)) continue;
|
|
218
|
-
const val = props[key];
|
|
219
|
-
if (Array.isArray(val) && val.length === 0) {
|
|
220
|
-
result[key] = emptyArrayStr;
|
|
221
|
-
} else if (isPureObject(val) && Object.keys(val).length === 0) {
|
|
222
|
-
result[key] = emptyObjectStr;
|
|
223
|
-
} else {
|
|
224
|
-
result[key] = val;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
return result;
|
|
228
|
-
}
|
|
229
|
-
function decodeEmptyObjects(props = {}) {
|
|
230
|
-
const result = {};
|
|
231
|
-
for (const key in props) {
|
|
232
|
-
if (!Object.prototype.hasOwnProperty.call(props, key)) continue;
|
|
233
|
-
const val = props[key];
|
|
234
|
-
if (val === emptyArrayStr) {
|
|
235
|
-
result[key] = [];
|
|
236
|
-
} else if (val === emptyObjectStr) {
|
|
237
|
-
result[key] = {};
|
|
238
|
-
} else {
|
|
239
|
-
result[key] = val;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
return result;
|
|
243
|
-
}
|
|
244
|
-
var flattenNode = (node, config) => {
|
|
245
|
-
return {
|
|
246
|
-
...node,
|
|
247
|
-
props: encodeEmptyObjects(flatten2(stripSlots(node, config).props))
|
|
248
|
-
};
|
|
249
|
-
};
|
|
250
|
-
var expandNode = (node) => {
|
|
251
|
-
const props = unflatten(decodeEmptyObjects(node.props));
|
|
252
|
-
return {
|
|
253
|
-
...node,
|
|
254
|
-
props
|
|
255
|
-
};
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
// lib/data/to-component.ts
|
|
259
|
-
var toComponent = (item) => {
|
|
260
|
-
return "type" in item ? item : {
|
|
261
|
-
...item,
|
|
262
|
-
props: { ...item.props, id: "root" },
|
|
263
|
-
type: "root"
|
|
264
|
-
};
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
// lib/get-zone-id.ts
|
|
268
|
-
var getZoneId = (zoneCompound) => {
|
|
269
|
-
if (!zoneCompound) {
|
|
270
|
-
return [];
|
|
271
|
-
}
|
|
272
|
-
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
|
273
|
-
return zoneCompound.split(":");
|
|
274
|
-
}
|
|
275
|
-
return [rootDroppableId, zoneCompound];
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
// lib/data/for-related-zones.ts
|
|
279
|
-
function forRelatedZones(item, data, cb, path = []) {
|
|
280
|
-
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
|
|
281
|
-
const [parentId] = getZoneId(zoneCompound);
|
|
282
|
-
if (parentId === item.props.id) {
|
|
283
|
-
cb(path, zoneCompound, content);
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
// lib/data/walk-app-state.ts
|
|
289
|
-
function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
|
290
|
-
let newZones = {};
|
|
291
|
-
const newZoneIndex = {};
|
|
292
|
-
const newNodeIndex = {};
|
|
293
|
-
const processContent = (path, zoneCompound, content, zoneType, newId) => {
|
|
294
|
-
const [parentId] = zoneCompound.split(":");
|
|
295
|
-
const mappedContent = (mapContent(content, zoneCompound, zoneType) ?? content) || [];
|
|
296
|
-
const [_2, zone] = zoneCompound.split(":");
|
|
297
|
-
const newZoneCompound = `${newId || parentId}:${zone}`;
|
|
298
|
-
const newContent2 = mappedContent.map(
|
|
299
|
-
(zoneChild, index) => processItem(zoneChild, [...path, newZoneCompound], index)
|
|
300
|
-
);
|
|
301
|
-
newZoneIndex[newZoneCompound] = {
|
|
302
|
-
contentIds: newContent2.map((item) => item.props.id),
|
|
303
|
-
type: zoneType
|
|
304
|
-
};
|
|
305
|
-
return [newZoneCompound, newContent2];
|
|
306
|
-
};
|
|
307
|
-
const processRelatedZones = (item, newId, initialPath) => {
|
|
308
|
-
forRelatedZones(
|
|
309
|
-
item,
|
|
310
|
-
state.data,
|
|
311
|
-
(relatedPath, relatedZoneCompound, relatedContent) => {
|
|
312
|
-
const [zoneCompound, newContent2] = processContent(
|
|
313
|
-
relatedPath,
|
|
314
|
-
relatedZoneCompound,
|
|
315
|
-
relatedContent,
|
|
316
|
-
"dropzone",
|
|
317
|
-
newId
|
|
318
|
-
);
|
|
319
|
-
newZones[zoneCompound] = newContent2;
|
|
320
|
-
},
|
|
321
|
-
initialPath
|
|
322
|
-
);
|
|
323
|
-
};
|
|
324
|
-
const processItem = (item, path, index) => {
|
|
325
|
-
const mappedItem = mapNodeOrSkip(item, path, index);
|
|
326
|
-
if (!mappedItem) return item;
|
|
327
|
-
const id = mappedItem.props.id;
|
|
328
|
-
const newProps = {
|
|
329
|
-
...mapFields(
|
|
330
|
-
mappedItem,
|
|
331
|
-
{
|
|
332
|
-
slot: ({ value, parentId: parentId2, propPath }) => {
|
|
333
|
-
const content = value;
|
|
334
|
-
const zoneCompound = `${parentId2}:${propPath}`;
|
|
335
|
-
const [_2, newContent2] = processContent(
|
|
336
|
-
path,
|
|
337
|
-
zoneCompound,
|
|
338
|
-
content,
|
|
339
|
-
"slot",
|
|
340
|
-
parentId2
|
|
341
|
-
);
|
|
342
|
-
return newContent2;
|
|
343
|
-
}
|
|
344
|
-
},
|
|
345
|
-
config
|
|
346
|
-
).props,
|
|
347
|
-
id
|
|
348
|
-
};
|
|
349
|
-
processRelatedZones(item, id, path);
|
|
350
|
-
const newItem = { ...mappedItem, props: newProps };
|
|
351
|
-
const thisZoneCompound = path[path.length - 1];
|
|
352
|
-
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
|
353
|
-
newNodeIndex[id] = {
|
|
354
|
-
data: newItem,
|
|
355
|
-
flatData: flattenNode(newItem, config),
|
|
356
|
-
path,
|
|
357
|
-
parentId,
|
|
358
|
-
zone
|
|
359
|
-
};
|
|
360
|
-
const finalData = { ...newItem, props: { ...newItem.props } };
|
|
361
|
-
if (newProps.id === "root") {
|
|
362
|
-
delete finalData["type"];
|
|
363
|
-
delete finalData.props["id"];
|
|
364
|
-
}
|
|
365
|
-
return finalData;
|
|
366
|
-
};
|
|
367
|
-
const zones = state.data.zones || {};
|
|
368
|
-
const [_, newContent] = processContent(
|
|
369
|
-
[],
|
|
370
|
-
rootDroppableId,
|
|
371
|
-
state.data.content,
|
|
372
|
-
"root"
|
|
373
|
-
);
|
|
374
|
-
const processedContent = newContent;
|
|
375
|
-
const zonesAlreadyProcessed = Object.keys(newZones);
|
|
376
|
-
Object.keys(zones || {}).forEach((zoneCompound) => {
|
|
377
|
-
const [parentId] = zoneCompound.split(":");
|
|
378
|
-
if (zonesAlreadyProcessed.includes(zoneCompound)) {
|
|
379
|
-
return;
|
|
380
|
-
}
|
|
381
|
-
const [_2, newContent2] = processContent(
|
|
382
|
-
[rootDroppableId],
|
|
383
|
-
zoneCompound,
|
|
384
|
-
zones[zoneCompound],
|
|
385
|
-
"dropzone",
|
|
386
|
-
parentId
|
|
387
|
-
);
|
|
388
|
-
newZones[zoneCompound] = newContent2;
|
|
389
|
-
}, newZones);
|
|
390
|
-
let rootAsComponent = toComponent({
|
|
391
|
-
props: { ...state.data.root.props ?? state.data.root }
|
|
392
|
-
});
|
|
393
|
-
if (state.data.root.readOnly) {
|
|
394
|
-
rootAsComponent.readOnly = state.data.root.readOnly;
|
|
395
|
-
}
|
|
396
|
-
const processedRoot = processItem(rootAsComponent, [], -1);
|
|
397
|
-
const root = {
|
|
398
|
-
...state.data.root,
|
|
399
|
-
...processedRoot
|
|
400
|
-
};
|
|
401
|
-
return {
|
|
402
|
-
...state,
|
|
403
|
-
data: {
|
|
404
|
-
root,
|
|
405
|
-
content: processedContent,
|
|
406
|
-
zones: {
|
|
407
|
-
...state.data.zones,
|
|
408
|
-
...newZones
|
|
409
|
-
}
|
|
410
|
-
},
|
|
411
|
-
indexes: {
|
|
412
|
-
nodes: { ...state.indexes.nodes, ...newNodeIndex },
|
|
413
|
-
zones: { ...state.indexes.zones, ...newZoneIndex }
|
|
414
|
-
}
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
// lib/data/setup-zone.ts
|
|
419
|
-
var setupZone = (data, zoneKey) => {
|
|
420
|
-
if (zoneKey === rootDroppableId) {
|
|
421
|
-
return data;
|
|
422
|
-
}
|
|
423
|
-
const newData = {
|
|
424
|
-
...data,
|
|
425
|
-
zones: data.zones ? { ...data.zones } : {}
|
|
426
|
-
};
|
|
427
|
-
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
|
428
|
-
return newData;
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
export {
|
|
432
|
-
generateId,
|
|
433
|
-
rootAreaId,
|
|
434
|
-
rootZone,
|
|
435
|
-
rootDroppableId,
|
|
436
|
-
getZoneId,
|
|
437
|
-
defaultSlots,
|
|
438
|
-
walkField,
|
|
439
|
-
mapFields,
|
|
440
|
-
expandNode,
|
|
441
|
-
toComponent,
|
|
442
|
-
walkAppState,
|
|
443
|
-
walkTree,
|
|
444
|
-
setupZone
|
|
445
|
-
};
|
package/dist/chunk-SMAWAXVX.mjs
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
mapFields,
|
|
3
|
-
toComponent
|
|
4
|
-
} from "./chunk-7LXZOPYT.mjs";
|
|
5
|
-
|
|
6
|
-
// components/ViewportControls/default-viewports.ts
|
|
7
|
-
var defaultViewports = [
|
|
8
|
-
{ width: 360, height: "auto", icon: "Smartphone", label: "Small" },
|
|
9
|
-
{ width: 768, height: "auto", icon: "Tablet", label: "Medium" },
|
|
10
|
-
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" },
|
|
11
|
-
{ width: "100%", height: "auto", icon: "FullWidth", label: "Full-width" }
|
|
12
|
-
];
|
|
13
|
-
|
|
14
|
-
// lib/get-changed.ts
|
|
15
|
-
import { deepEqual } from "fast-equals";
|
|
16
|
-
var getChanged = (newItem, oldItem) => {
|
|
17
|
-
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
|
18
|
-
const newItemProps = newItem?.props || {};
|
|
19
|
-
const oldItemProps = oldItem?.props || {};
|
|
20
|
-
return {
|
|
21
|
-
...acc,
|
|
22
|
-
[item]: !deepEqual(oldItemProps[item], newItemProps[item])
|
|
23
|
-
};
|
|
24
|
-
}, {}) : {};
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// lib/resolve-component-data.ts
|
|
28
|
-
import { deepEqual as deepEqual2 } from "fast-equals";
|
|
29
|
-
var cache = { lastChange: {} };
|
|
30
|
-
var resolveComponentData = async (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", parent = null) => {
|
|
31
|
-
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
|
32
|
-
const resolvedItem = {
|
|
33
|
-
...item
|
|
34
|
-
};
|
|
35
|
-
const shouldRunResolver = configForItem?.resolveData && item.props;
|
|
36
|
-
const id = "id" in item.props ? item.props.id : "root";
|
|
37
|
-
if (shouldRunResolver) {
|
|
38
|
-
const {
|
|
39
|
-
item: oldItem = null,
|
|
40
|
-
resolved = {},
|
|
41
|
-
parentId: oldParentId = null
|
|
42
|
-
} = cache.lastChange[id] || {};
|
|
43
|
-
const isRootOrInserted = oldParentId === null;
|
|
44
|
-
const parentChanged = !isRootOrInserted && parent?.props.id !== oldParentId;
|
|
45
|
-
const dataChanged = item && !deepEqual2(item, oldItem);
|
|
46
|
-
const shouldSkip = trigger === "move" && !parentChanged || trigger !== "move" && trigger !== "force" && !dataChanged;
|
|
47
|
-
if (shouldSkip) {
|
|
48
|
-
return { node: resolved, didChange: false };
|
|
49
|
-
}
|
|
50
|
-
const changed = getChanged(item, oldItem);
|
|
51
|
-
if (onResolveStart) {
|
|
52
|
-
onResolveStart(item);
|
|
53
|
-
}
|
|
54
|
-
const { props: resolvedProps, readOnly = {} } = await configForItem.resolveData(item, {
|
|
55
|
-
changed,
|
|
56
|
-
lastData: oldItem,
|
|
57
|
-
metadata: { ...metadata, ...configForItem.metadata },
|
|
58
|
-
trigger,
|
|
59
|
-
parent
|
|
60
|
-
});
|
|
61
|
-
resolvedItem.props = {
|
|
62
|
-
...item.props,
|
|
63
|
-
...resolvedProps
|
|
64
|
-
};
|
|
65
|
-
if (Object.keys(readOnly).length) {
|
|
66
|
-
resolvedItem.readOnly = readOnly;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
const itemAsComponentData = toComponent(resolvedItem);
|
|
70
|
-
let itemWithResolvedChildren = await mapFields(
|
|
71
|
-
resolvedItem,
|
|
72
|
-
{
|
|
73
|
-
slot: async ({ value }) => {
|
|
74
|
-
const content = value;
|
|
75
|
-
return await Promise.all(
|
|
76
|
-
content.map(
|
|
77
|
-
async (childItem) => (await resolveComponentData(
|
|
78
|
-
childItem,
|
|
79
|
-
config,
|
|
80
|
-
metadata,
|
|
81
|
-
onResolveStart,
|
|
82
|
-
onResolveEnd,
|
|
83
|
-
trigger,
|
|
84
|
-
itemAsComponentData
|
|
85
|
-
)).node
|
|
86
|
-
)
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
config
|
|
91
|
-
);
|
|
92
|
-
if (shouldRunResolver && onResolveEnd) {
|
|
93
|
-
onResolveEnd(resolvedItem);
|
|
94
|
-
}
|
|
95
|
-
cache.lastChange[id] = {
|
|
96
|
-
item,
|
|
97
|
-
resolved: itemWithResolvedChildren,
|
|
98
|
-
parentId: parent?.props.id
|
|
99
|
-
};
|
|
100
|
-
return {
|
|
101
|
-
node: itemWithResolvedChildren,
|
|
102
|
-
didChange: !deepEqual2(item, itemWithResolvedChildren)
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
// store/default-app-state.ts
|
|
107
|
-
var defaultAppState = {
|
|
108
|
-
data: { content: [], root: {}, zones: {} },
|
|
109
|
-
ui: {
|
|
110
|
-
leftSideBarVisible: true,
|
|
111
|
-
rightSideBarVisible: true,
|
|
112
|
-
arrayState: {},
|
|
113
|
-
itemSelector: null,
|
|
114
|
-
componentList: {},
|
|
115
|
-
isDragging: false,
|
|
116
|
-
previewMode: "edit",
|
|
117
|
-
viewports: {
|
|
118
|
-
current: {
|
|
119
|
-
width: defaultViewports[0].width,
|
|
120
|
-
height: defaultViewports[0].height || "auto"
|
|
121
|
-
},
|
|
122
|
-
options: [],
|
|
123
|
-
controlsVisible: true
|
|
124
|
-
},
|
|
125
|
-
field: { focus: null },
|
|
126
|
-
plugin: { current: null }
|
|
127
|
-
},
|
|
128
|
-
indexes: {
|
|
129
|
-
nodes: {},
|
|
130
|
-
zones: {}
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
export {
|
|
135
|
-
defaultViewports,
|
|
136
|
-
getChanged,
|
|
137
|
-
resolveComponentData,
|
|
138
|
-
defaultAppState
|
|
139
|
-
};
|