@measured/puck 0.21.0-canary.7dca3a5a → 0.21.0-canary.8358d3e1
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/Editor-F2LSS6SE.css +403 -0
- package/dist/Editor-N46HUQEC.mjs +201 -0
- package/dist/Render-QEMDIDQC.css +101 -0
- package/dist/Render-Y567PGZ7.mjs +53 -0
- package/dist/chunk-3QHWXJEI.mjs +33 -0
- package/dist/chunk-7KY6RHEY.mjs +2230 -0
- package/dist/chunk-C2TVYIYC.mjs +415 -0
- package/dist/chunk-DCSQEDMK.mjs +194 -0
- package/dist/chunk-DJSH5REF.mjs +537 -0
- package/dist/chunk-DNF2EMM4.mjs +63 -0
- package/dist/chunk-FNWOH4R6.mjs +109 -0
- package/dist/chunk-GQKMOYLG.mjs +53 -0
- package/dist/chunk-K3V4LVUL.mjs +704 -0
- package/dist/{chunk-FKDVYRQW.mjs → chunk-N5XMZOMC.mjs} +5078 -7463
- package/dist/chunk-R6CVX2IY.mjs +103 -0
- package/dist/chunk-WUWXFMEM.mjs +11 -0
- package/dist/full-2GJTAAZE.css +301 -0
- package/dist/full-NLUNPJWS.mjs +90 -0
- package/dist/index.css +636 -758
- package/dist/index.d.mts +101 -20
- package/dist/index.d.ts +101 -20
- package/dist/index.js +7363 -4751
- package/dist/index.mjs +25 -15
- package/dist/loaded-EV34KGYJ.mjs +57 -0
- package/dist/loaded-HMSPJUZM.mjs +54 -0
- package/dist/loaded-RVWBFK7L.css +87 -0
- package/dist/loaded-ZXOU6S6R.mjs +54 -0
- package/dist/no-external.css +636 -758
- package/dist/no-external.d.mts +17 -2
- package/dist/no-external.d.ts +17 -2
- package/dist/no-external.js +7360 -4748
- package/dist/no-external.mjs +25 -15
- package/dist/rsc.css +101 -0
- package/dist/rsc.d.mts +17 -2
- package/dist/rsc.d.ts +17 -2
- package/dist/rsc.js +419 -34
- package/dist/rsc.mjs +16 -9
- package/dist/{walk-tree-DS1xB387.d.mts → walk-tree-Ja9bNCM9.d.mts} +216 -26
- package/dist/{walk-tree-DS1xB387.d.ts → walk-tree-Ja9bNCM9.d.ts} +216 -26
- package/package.json +23 -1
- package/dist/chunk-6SIKCDJJ.mjs +0 -967
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__async,
|
|
3
|
+
__spreadProps,
|
|
4
|
+
__spreadValues,
|
|
5
|
+
init_react_import
|
|
6
|
+
} from "./chunk-DCSQEDMK.mjs";
|
|
7
|
+
|
|
8
|
+
// lib/data/walk-tree.ts
|
|
9
|
+
init_react_import();
|
|
10
|
+
|
|
11
|
+
// lib/data/map-fields.ts
|
|
12
|
+
init_react_import();
|
|
13
|
+
|
|
14
|
+
// lib/data/default-slots.ts
|
|
15
|
+
init_react_import();
|
|
16
|
+
var defaultSlots = (value, fields) => Object.keys(fields).reduce(
|
|
17
|
+
(acc, fieldName) => fields[fieldName].type === "slot" ? __spreadValues({ [fieldName]: [] }, acc) : acc,
|
|
18
|
+
value
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
// lib/data/map-fields.ts
|
|
22
|
+
var isPromise = (v) => !!v && typeof v.then === "function";
|
|
23
|
+
var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
|
|
24
|
+
var containsPromise = (arr) => arr.some(isPromise);
|
|
25
|
+
var walkField = ({
|
|
26
|
+
value,
|
|
27
|
+
fields,
|
|
28
|
+
mappers,
|
|
29
|
+
propKey = "",
|
|
30
|
+
propPath = "",
|
|
31
|
+
id = "",
|
|
32
|
+
config,
|
|
33
|
+
recurseSlots = false
|
|
34
|
+
}) => {
|
|
35
|
+
var _a, _b, _c;
|
|
36
|
+
const fieldType = (_a = fields[propKey]) == null ? void 0 : _a.type;
|
|
37
|
+
const map = mappers[fieldType];
|
|
38
|
+
if (map && fieldType === "slot") {
|
|
39
|
+
const content = value || [];
|
|
40
|
+
const mappedContent = recurseSlots ? content.map((el) => {
|
|
41
|
+
var _a2;
|
|
42
|
+
const componentConfig = config.components[el.type];
|
|
43
|
+
if (!componentConfig) {
|
|
44
|
+
throw new Error(`Could not find component config for ${el.type}`);
|
|
45
|
+
}
|
|
46
|
+
const fields2 = (_a2 = componentConfig.fields) != null ? _a2 : {};
|
|
47
|
+
return walkField({
|
|
48
|
+
value: __spreadProps(__spreadValues({}, el), { props: defaultSlots(el.props, fields2) }),
|
|
49
|
+
fields: fields2,
|
|
50
|
+
mappers,
|
|
51
|
+
id: el.props.id,
|
|
52
|
+
config,
|
|
53
|
+
recurseSlots
|
|
54
|
+
});
|
|
55
|
+
}) : content;
|
|
56
|
+
if (containsPromise(mappedContent)) {
|
|
57
|
+
return Promise.all(mappedContent);
|
|
58
|
+
}
|
|
59
|
+
return map({
|
|
60
|
+
value: mappedContent,
|
|
61
|
+
parentId: id,
|
|
62
|
+
propName: propPath,
|
|
63
|
+
field: fields[propKey],
|
|
64
|
+
propPath
|
|
65
|
+
});
|
|
66
|
+
} else if (map && fields[propKey]) {
|
|
67
|
+
return map({
|
|
68
|
+
value,
|
|
69
|
+
parentId: id,
|
|
70
|
+
propName: propKey,
|
|
71
|
+
field: fields[propKey],
|
|
72
|
+
propPath
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
if (value && typeof value === "object") {
|
|
76
|
+
if (Array.isArray(value)) {
|
|
77
|
+
const arrayFields = ((_b = fields[propKey]) == null ? void 0 : _b.type) === "array" ? fields[propKey].arrayFields : null;
|
|
78
|
+
if (!arrayFields) return value;
|
|
79
|
+
const newValue = value.map(
|
|
80
|
+
(el, idx) => walkField({
|
|
81
|
+
value: el,
|
|
82
|
+
fields: arrayFields,
|
|
83
|
+
mappers,
|
|
84
|
+
propKey,
|
|
85
|
+
propPath: `${propPath}[${idx}]`,
|
|
86
|
+
id,
|
|
87
|
+
config,
|
|
88
|
+
recurseSlots
|
|
89
|
+
})
|
|
90
|
+
);
|
|
91
|
+
if (containsPromise(newValue)) {
|
|
92
|
+
return Promise.all(newValue);
|
|
93
|
+
}
|
|
94
|
+
return newValue;
|
|
95
|
+
} else if ("$$typeof" in value) {
|
|
96
|
+
return value;
|
|
97
|
+
} else {
|
|
98
|
+
const objectFields = ((_c = fields[propKey]) == null ? void 0 : _c.type) === "object" ? fields[propKey].objectFields : fields;
|
|
99
|
+
return walkObject({
|
|
100
|
+
value,
|
|
101
|
+
fields: objectFields,
|
|
102
|
+
mappers,
|
|
103
|
+
id,
|
|
104
|
+
getPropPath: (k) => `${propPath}.${k}`,
|
|
105
|
+
config,
|
|
106
|
+
recurseSlots
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return value;
|
|
111
|
+
};
|
|
112
|
+
var walkObject = ({
|
|
113
|
+
value,
|
|
114
|
+
fields,
|
|
115
|
+
mappers,
|
|
116
|
+
id,
|
|
117
|
+
getPropPath,
|
|
118
|
+
config,
|
|
119
|
+
recurseSlots
|
|
120
|
+
}) => {
|
|
121
|
+
const newProps = Object.entries(value).map(([k, v]) => {
|
|
122
|
+
const opts = {
|
|
123
|
+
value: v,
|
|
124
|
+
fields,
|
|
125
|
+
mappers,
|
|
126
|
+
propKey: k,
|
|
127
|
+
propPath: getPropPath(k),
|
|
128
|
+
id,
|
|
129
|
+
config,
|
|
130
|
+
recurseSlots
|
|
131
|
+
};
|
|
132
|
+
const newValue = walkField(opts);
|
|
133
|
+
if (isPromise(newValue)) {
|
|
134
|
+
return newValue.then((resolvedValue) => ({
|
|
135
|
+
[k]: resolvedValue
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
[k]: newValue
|
|
140
|
+
};
|
|
141
|
+
}, {});
|
|
142
|
+
if (containsPromise(newProps)) {
|
|
143
|
+
return Promise.all(newProps).then(flatten);
|
|
144
|
+
}
|
|
145
|
+
return flatten(newProps);
|
|
146
|
+
};
|
|
147
|
+
function mapFields(item, mappers, config, recurseSlots = false) {
|
|
148
|
+
var _a, _b, _c, _d, _e;
|
|
149
|
+
const itemType = "type" in item ? item.type : "root";
|
|
150
|
+
const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
|
|
151
|
+
const newProps = walkObject({
|
|
152
|
+
value: defaultSlots((_b = item.props) != null ? _b : {}, (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {}),
|
|
153
|
+
fields: (_d = componentConfig == null ? void 0 : componentConfig.fields) != null ? _d : {},
|
|
154
|
+
mappers,
|
|
155
|
+
id: item.props ? (_e = item.props.id) != null ? _e : "root" : "root",
|
|
156
|
+
getPropPath: (k) => k,
|
|
157
|
+
config,
|
|
158
|
+
recurseSlots
|
|
159
|
+
});
|
|
160
|
+
if (isPromise(newProps)) {
|
|
161
|
+
return newProps.then((resolvedProps) => __spreadProps(__spreadValues({}, item), {
|
|
162
|
+
props: resolvedProps
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
166
|
+
props: newProps
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// lib/data/walk-tree.ts
|
|
171
|
+
function walkTree(data, config, callbackFn) {
|
|
172
|
+
var _a, _b;
|
|
173
|
+
const walkItem = (item) => {
|
|
174
|
+
return mapFields(
|
|
175
|
+
item,
|
|
176
|
+
{
|
|
177
|
+
slot: ({ value, parentId, propName }) => {
|
|
178
|
+
var _a2;
|
|
179
|
+
const content = value;
|
|
180
|
+
return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
config,
|
|
184
|
+
true
|
|
185
|
+
);
|
|
186
|
+
};
|
|
187
|
+
if ("props" in data) {
|
|
188
|
+
return walkItem(data);
|
|
189
|
+
}
|
|
190
|
+
const _data = data;
|
|
191
|
+
const zones = (_a = _data.zones) != null ? _a : {};
|
|
192
|
+
const mappedContent = _data.content.map(walkItem);
|
|
193
|
+
return {
|
|
194
|
+
root: walkItem(_data.root),
|
|
195
|
+
content: (_b = callbackFn(mappedContent, {
|
|
196
|
+
parentId: "root",
|
|
197
|
+
propName: "default-zone"
|
|
198
|
+
})) != null ? _b : mappedContent,
|
|
199
|
+
zones: Object.keys(zones).reduce(
|
|
200
|
+
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
|
|
201
|
+
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
|
202
|
+
}),
|
|
203
|
+
{}
|
|
204
|
+
)
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// lib/root-droppable-id.ts
|
|
209
|
+
init_react_import();
|
|
210
|
+
var rootAreaId = "root";
|
|
211
|
+
var rootZone = "default-zone";
|
|
212
|
+
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
|
213
|
+
|
|
214
|
+
// lib/data/flatten-node.ts
|
|
215
|
+
init_react_import();
|
|
216
|
+
import flat from "flat";
|
|
217
|
+
|
|
218
|
+
// lib/data/strip-slots.ts
|
|
219
|
+
init_react_import();
|
|
220
|
+
var stripSlots = (data, config) => {
|
|
221
|
+
return mapFields(data, { slot: () => null }, config);
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
// lib/data/flatten-node.ts
|
|
225
|
+
var { flatten: flatten2, unflatten } = flat;
|
|
226
|
+
var flattenNode = (node, config) => {
|
|
227
|
+
return __spreadProps(__spreadValues({}, node), {
|
|
228
|
+
props: flatten2(stripSlots(node, config).props)
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
var expandNode = (node) => {
|
|
232
|
+
const props = unflatten(node.props);
|
|
233
|
+
return __spreadProps(__spreadValues({}, node), {
|
|
234
|
+
props
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
// lib/data/walk-app-state.ts
|
|
239
|
+
init_react_import();
|
|
240
|
+
|
|
241
|
+
// lib/data/for-related-zones.ts
|
|
242
|
+
init_react_import();
|
|
243
|
+
|
|
244
|
+
// lib/get-zone-id.ts
|
|
245
|
+
init_react_import();
|
|
246
|
+
var getZoneId = (zoneCompound) => {
|
|
247
|
+
if (!zoneCompound) {
|
|
248
|
+
return [];
|
|
249
|
+
}
|
|
250
|
+
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
|
251
|
+
return zoneCompound.split(":");
|
|
252
|
+
}
|
|
253
|
+
return [rootDroppableId, zoneCompound];
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
// lib/data/for-related-zones.ts
|
|
257
|
+
function forRelatedZones(item, data, cb, path = []) {
|
|
258
|
+
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
|
|
259
|
+
const [parentId] = getZoneId(zoneCompound);
|
|
260
|
+
if (parentId === item.props.id) {
|
|
261
|
+
cb(path, zoneCompound, content);
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// lib/data/walk-app-state.ts
|
|
267
|
+
function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
|
268
|
+
var _a;
|
|
269
|
+
let newZones = {};
|
|
270
|
+
const newZoneIndex = {};
|
|
271
|
+
const newNodeIndex = {};
|
|
272
|
+
const processContent = (path, zoneCompound, content, zoneType, newId) => {
|
|
273
|
+
var _a2;
|
|
274
|
+
const [parentId] = zoneCompound.split(":");
|
|
275
|
+
const mappedContent = ((_a2 = mapContent(content, zoneCompound, zoneType)) != null ? _a2 : content) || [];
|
|
276
|
+
const [_2, zone] = zoneCompound.split(":");
|
|
277
|
+
const newZoneCompound = `${newId || parentId}:${zone}`;
|
|
278
|
+
const newContent2 = mappedContent.map(
|
|
279
|
+
(zoneChild, index) => processItem(zoneChild, [...path, newZoneCompound], index)
|
|
280
|
+
);
|
|
281
|
+
newZoneIndex[newZoneCompound] = {
|
|
282
|
+
contentIds: newContent2.map((item) => item.props.id),
|
|
283
|
+
type: zoneType
|
|
284
|
+
};
|
|
285
|
+
return [newZoneCompound, newContent2];
|
|
286
|
+
};
|
|
287
|
+
const processRelatedZones = (item, newId, initialPath) => {
|
|
288
|
+
forRelatedZones(
|
|
289
|
+
item,
|
|
290
|
+
state.data,
|
|
291
|
+
(relatedPath, relatedZoneCompound, relatedContent) => {
|
|
292
|
+
const [zoneCompound, newContent2] = processContent(
|
|
293
|
+
relatedPath,
|
|
294
|
+
relatedZoneCompound,
|
|
295
|
+
relatedContent,
|
|
296
|
+
"dropzone",
|
|
297
|
+
newId
|
|
298
|
+
);
|
|
299
|
+
newZones[zoneCompound] = newContent2;
|
|
300
|
+
},
|
|
301
|
+
initialPath
|
|
302
|
+
);
|
|
303
|
+
};
|
|
304
|
+
const processItem = (item, path, index) => {
|
|
305
|
+
const mappedItem = mapNodeOrSkip(item, path, index);
|
|
306
|
+
if (!mappedItem) return item;
|
|
307
|
+
const id = mappedItem.props.id;
|
|
308
|
+
const newProps = __spreadProps(__spreadValues({}, mapFields(
|
|
309
|
+
mappedItem,
|
|
310
|
+
{
|
|
311
|
+
slot: ({ value, parentId: parentId2, propPath }) => {
|
|
312
|
+
const content = value;
|
|
313
|
+
const zoneCompound = `${parentId2}:${propPath}`;
|
|
314
|
+
const [_2, newContent2] = processContent(
|
|
315
|
+
path,
|
|
316
|
+
zoneCompound,
|
|
317
|
+
content,
|
|
318
|
+
"slot",
|
|
319
|
+
parentId2
|
|
320
|
+
);
|
|
321
|
+
return newContent2;
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
config
|
|
325
|
+
).props), {
|
|
326
|
+
id
|
|
327
|
+
});
|
|
328
|
+
processRelatedZones(item, id, path);
|
|
329
|
+
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
|
|
330
|
+
const thisZoneCompound = path[path.length - 1];
|
|
331
|
+
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
|
332
|
+
newNodeIndex[id] = {
|
|
333
|
+
data: newItem,
|
|
334
|
+
flatData: flattenNode(newItem, config),
|
|
335
|
+
path,
|
|
336
|
+
parentId,
|
|
337
|
+
zone
|
|
338
|
+
};
|
|
339
|
+
const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
|
|
340
|
+
if (newProps.id === "root") {
|
|
341
|
+
delete finalData["type"];
|
|
342
|
+
delete finalData.props["id"];
|
|
343
|
+
}
|
|
344
|
+
return finalData;
|
|
345
|
+
};
|
|
346
|
+
const zones = state.data.zones || {};
|
|
347
|
+
const [_, newContent] = processContent(
|
|
348
|
+
[],
|
|
349
|
+
rootDroppableId,
|
|
350
|
+
state.data.content,
|
|
351
|
+
"root"
|
|
352
|
+
);
|
|
353
|
+
const processedContent = newContent;
|
|
354
|
+
const zonesAlreadyProcessed = Object.keys(newZones);
|
|
355
|
+
Object.keys(zones || {}).forEach((zoneCompound) => {
|
|
356
|
+
const [parentId] = zoneCompound.split(":");
|
|
357
|
+
if (zonesAlreadyProcessed.includes(zoneCompound)) {
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
const [_2, newContent2] = processContent(
|
|
361
|
+
[rootDroppableId],
|
|
362
|
+
zoneCompound,
|
|
363
|
+
zones[zoneCompound],
|
|
364
|
+
"dropzone",
|
|
365
|
+
parentId
|
|
366
|
+
);
|
|
367
|
+
newZones[zoneCompound] = newContent2;
|
|
368
|
+
}, newZones);
|
|
369
|
+
const processedRoot = processItem(
|
|
370
|
+
{
|
|
371
|
+
type: "root",
|
|
372
|
+
props: __spreadProps(__spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root), { id: "root" })
|
|
373
|
+
},
|
|
374
|
+
[],
|
|
375
|
+
-1
|
|
376
|
+
);
|
|
377
|
+
const root = __spreadProps(__spreadValues({}, state.data.root), {
|
|
378
|
+
props: processedRoot.props
|
|
379
|
+
});
|
|
380
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
381
|
+
data: {
|
|
382
|
+
root,
|
|
383
|
+
content: processedContent,
|
|
384
|
+
zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
|
|
385
|
+
},
|
|
386
|
+
indexes: {
|
|
387
|
+
nodes: __spreadValues(__spreadValues({}, state.indexes.nodes), newNodeIndex),
|
|
388
|
+
zones: __spreadValues(__spreadValues({}, state.indexes.zones), newZoneIndex)
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// lib/data/setup-zone.ts
|
|
394
|
+
init_react_import();
|
|
395
|
+
var setupZone = (data, zoneKey) => {
|
|
396
|
+
if (zoneKey === rootDroppableId) {
|
|
397
|
+
return data;
|
|
398
|
+
}
|
|
399
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
|
400
|
+
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
|
401
|
+
});
|
|
402
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
|
403
|
+
return newData;
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
// components/ViewportControls/default-viewports.ts
|
|
407
|
+
init_react_import();
|
|
408
|
+
var defaultViewports = [
|
|
409
|
+
{ width: 360, height: "auto", icon: "Smartphone", label: "Small" },
|
|
410
|
+
{ width: 768, height: "auto", icon: "Tablet", label: "Medium" },
|
|
411
|
+
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
|
412
|
+
];
|
|
413
|
+
|
|
414
|
+
// lib/resolve-component-data.ts
|
|
415
|
+
init_react_import();
|
|
416
|
+
|
|
417
|
+
// lib/get-changed.ts
|
|
418
|
+
init_react_import();
|
|
419
|
+
import { deepEqual } from "fast-equals";
|
|
420
|
+
var getChanged = (newItem, oldItem) => {
|
|
421
|
+
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
|
422
|
+
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
|
423
|
+
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
|
424
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
425
|
+
[item]: !deepEqual(oldItemProps[item], newItemProps[item])
|
|
426
|
+
});
|
|
427
|
+
}, {}) : {};
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
// lib/resolve-component-data.ts
|
|
431
|
+
import { deepEqual as deepEqual2 } from "fast-equals";
|
|
432
|
+
var cache = { lastChange: {} };
|
|
433
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
|
434
|
+
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
|
435
|
+
const resolvedItem = __spreadValues({}, item);
|
|
436
|
+
const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
|
|
437
|
+
const id = "id" in item.props ? item.props.id : "root";
|
|
438
|
+
if (shouldRunResolver) {
|
|
439
|
+
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
|
440
|
+
if (trigger !== "force" && item && deepEqual2(item, oldItem)) {
|
|
441
|
+
return { node: resolved, didChange: false };
|
|
442
|
+
}
|
|
443
|
+
const changed = getChanged(item, oldItem);
|
|
444
|
+
if (onResolveStart) {
|
|
445
|
+
onResolveStart(item);
|
|
446
|
+
}
|
|
447
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
|
448
|
+
changed,
|
|
449
|
+
lastData: oldItem,
|
|
450
|
+
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
|
451
|
+
trigger
|
|
452
|
+
});
|
|
453
|
+
resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
|
|
454
|
+
if (Object.keys(readOnly).length) {
|
|
455
|
+
resolvedItem.readOnly = readOnly;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
let itemWithResolvedChildren = yield mapFields(
|
|
459
|
+
resolvedItem,
|
|
460
|
+
{
|
|
461
|
+
slot: (_02) => __async(null, [_02], function* ({ value }) {
|
|
462
|
+
const content = value;
|
|
463
|
+
return yield Promise.all(
|
|
464
|
+
content.map(
|
|
465
|
+
(childItem) => __async(null, null, function* () {
|
|
466
|
+
return (yield resolveComponentData(
|
|
467
|
+
childItem,
|
|
468
|
+
config,
|
|
469
|
+
metadata,
|
|
470
|
+
onResolveStart,
|
|
471
|
+
onResolveEnd,
|
|
472
|
+
trigger
|
|
473
|
+
)).node;
|
|
474
|
+
})
|
|
475
|
+
)
|
|
476
|
+
);
|
|
477
|
+
})
|
|
478
|
+
},
|
|
479
|
+
config
|
|
480
|
+
);
|
|
481
|
+
if (shouldRunResolver && onResolveEnd) {
|
|
482
|
+
onResolveEnd(resolvedItem);
|
|
483
|
+
}
|
|
484
|
+
cache.lastChange[id] = {
|
|
485
|
+
item,
|
|
486
|
+
resolved: itemWithResolvedChildren
|
|
487
|
+
};
|
|
488
|
+
return {
|
|
489
|
+
node: itemWithResolvedChildren,
|
|
490
|
+
didChange: !deepEqual2(item, itemWithResolvedChildren)
|
|
491
|
+
};
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
// store/default-app-state.ts
|
|
495
|
+
init_react_import();
|
|
496
|
+
var defaultAppState = {
|
|
497
|
+
data: { content: [], root: {}, zones: {} },
|
|
498
|
+
ui: {
|
|
499
|
+
leftSideBarVisible: true,
|
|
500
|
+
rightSideBarVisible: true,
|
|
501
|
+
arrayState: {},
|
|
502
|
+
itemSelector: null,
|
|
503
|
+
componentList: {},
|
|
504
|
+
isDragging: false,
|
|
505
|
+
previewMode: "edit",
|
|
506
|
+
viewports: {
|
|
507
|
+
current: {
|
|
508
|
+
width: defaultViewports[0].width,
|
|
509
|
+
height: defaultViewports[0].height || "auto"
|
|
510
|
+
},
|
|
511
|
+
options: [],
|
|
512
|
+
controlsVisible: true
|
|
513
|
+
},
|
|
514
|
+
field: { focus: null }
|
|
515
|
+
},
|
|
516
|
+
indexes: {
|
|
517
|
+
nodes: {},
|
|
518
|
+
zones: {}
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
export {
|
|
523
|
+
rootAreaId,
|
|
524
|
+
rootZone,
|
|
525
|
+
rootDroppableId,
|
|
526
|
+
defaultSlots,
|
|
527
|
+
walkField,
|
|
528
|
+
mapFields,
|
|
529
|
+
expandNode,
|
|
530
|
+
walkAppState,
|
|
531
|
+
walkTree,
|
|
532
|
+
setupZone,
|
|
533
|
+
defaultViewports,
|
|
534
|
+
getChanged,
|
|
535
|
+
resolveComponentData,
|
|
536
|
+
defaultAppState
|
|
537
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Heading1,
|
|
3
|
+
Heading2,
|
|
4
|
+
Heading3,
|
|
5
|
+
Heading4,
|
|
6
|
+
Heading5,
|
|
7
|
+
Heading6
|
|
8
|
+
} from "./chunk-7KY6RHEY.mjs";
|
|
9
|
+
import {
|
|
10
|
+
init_react_import
|
|
11
|
+
} from "./chunk-DCSQEDMK.mjs";
|
|
12
|
+
|
|
13
|
+
// components/RichTextMenu/controls/HeadingSelect/use-options.ts
|
|
14
|
+
init_react_import();
|
|
15
|
+
import { useMemo } from "react";
|
|
16
|
+
var optionNodes = {
|
|
17
|
+
h1: { label: "Heading 1", icon: Heading1 },
|
|
18
|
+
h2: { label: "Heading 2", icon: Heading2 },
|
|
19
|
+
h3: { label: "Heading 3", icon: Heading3 },
|
|
20
|
+
h4: { label: "Heading 4", icon: Heading4 },
|
|
21
|
+
h5: { label: "Heading 5", icon: Heading5 },
|
|
22
|
+
h6: { label: "Heading 6", icon: Heading6 }
|
|
23
|
+
};
|
|
24
|
+
var useHeadingOptions = (fieldOptions) => {
|
|
25
|
+
var _a;
|
|
26
|
+
let blockOptions = [];
|
|
27
|
+
if ((fieldOptions == null ? void 0 : fieldOptions.heading) !== false) {
|
|
28
|
+
if (!((_a = fieldOptions == null ? void 0 : fieldOptions.heading) == null ? void 0 : _a.levels)) {
|
|
29
|
+
blockOptions = ["h1", "h2", "h3", "h4", "h5", "h6"];
|
|
30
|
+
} else {
|
|
31
|
+
if (fieldOptions == null ? void 0 : fieldOptions.heading.levels.includes(1)) {
|
|
32
|
+
blockOptions.push("h1");
|
|
33
|
+
}
|
|
34
|
+
if (fieldOptions == null ? void 0 : fieldOptions.heading.levels.includes(2)) {
|
|
35
|
+
blockOptions.push("h2");
|
|
36
|
+
}
|
|
37
|
+
if (fieldOptions == null ? void 0 : fieldOptions.heading.levels.includes(3)) {
|
|
38
|
+
blockOptions.push("h3");
|
|
39
|
+
}
|
|
40
|
+
if (fieldOptions == null ? void 0 : fieldOptions.heading.levels.includes(4)) {
|
|
41
|
+
blockOptions.push("h4");
|
|
42
|
+
}
|
|
43
|
+
if (fieldOptions == null ? void 0 : fieldOptions.heading.levels.includes(5)) {
|
|
44
|
+
blockOptions.push("h5");
|
|
45
|
+
}
|
|
46
|
+
if (fieldOptions == null ? void 0 : fieldOptions.heading.levels.includes(6)) {
|
|
47
|
+
blockOptions.push("h6");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return useMemo(
|
|
52
|
+
() => blockOptions.map((item) => ({
|
|
53
|
+
value: item,
|
|
54
|
+
label: optionNodes[item].label,
|
|
55
|
+
icon: optionNodes[item].icon
|
|
56
|
+
})),
|
|
57
|
+
[blockOptions]
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
useHeadingOptions
|
|
63
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {
|
|
2
|
+
styles_module_default
|
|
3
|
+
} from "./chunk-WUWXFMEM.mjs";
|
|
4
|
+
import {
|
|
5
|
+
LoadedRichTextMenuInner
|
|
6
|
+
} from "./chunk-K3V4LVUL.mjs";
|
|
7
|
+
import {
|
|
8
|
+
useAppStore,
|
|
9
|
+
useAppStoreApi
|
|
10
|
+
} from "./chunk-7KY6RHEY.mjs";
|
|
11
|
+
import {
|
|
12
|
+
__spreadValues,
|
|
13
|
+
get_class_name_factory_default,
|
|
14
|
+
init_react_import
|
|
15
|
+
} from "./chunk-DCSQEDMK.mjs";
|
|
16
|
+
|
|
17
|
+
// components/RichTextEditor/components/EditorInner.tsx
|
|
18
|
+
init_react_import();
|
|
19
|
+
import {
|
|
20
|
+
memo,
|
|
21
|
+
useCallback
|
|
22
|
+
} from "react";
|
|
23
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
24
|
+
var getClassName = get_class_name_factory_default("RichTextEditor", styles_module_default);
|
|
25
|
+
var EditorInner = memo(
|
|
26
|
+
({
|
|
27
|
+
children,
|
|
28
|
+
menu,
|
|
29
|
+
readOnly = false,
|
|
30
|
+
field,
|
|
31
|
+
inline = false,
|
|
32
|
+
editor,
|
|
33
|
+
id
|
|
34
|
+
}) => {
|
|
35
|
+
const { initialHeight } = field;
|
|
36
|
+
const isActive = useAppStore(
|
|
37
|
+
(s) => {
|
|
38
|
+
var _a;
|
|
39
|
+
return ((_a = s.currentRichText) == null ? void 0 : _a.id) === id && inline === s.currentRichText.inline;
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
const appStoreApi = useAppStoreApi();
|
|
43
|
+
const handleHotkeyCapture = useCallback(
|
|
44
|
+
(event) => {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "i") {
|
|
47
|
+
event.stopPropagation();
|
|
48
|
+
event.preventDefault();
|
|
49
|
+
(_b = editor == null ? void 0 : (_a = editor.commands).toggleItalic) == null ? void 0 : _b.call(_a);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
[editor]
|
|
53
|
+
);
|
|
54
|
+
const handleBlur = useCallback(
|
|
55
|
+
(e) => {
|
|
56
|
+
var _a, _b;
|
|
57
|
+
const targetInMenu = !!((_b = (_a = e.relatedTarget) == null ? void 0 : _a.closest) == null ? void 0 : _b.call(
|
|
58
|
+
_a,
|
|
59
|
+
"[data-puck-rte-menu]"
|
|
60
|
+
));
|
|
61
|
+
if (e.relatedTarget && !targetInMenu) {
|
|
62
|
+
appStoreApi.setState({
|
|
63
|
+
currentRichText: null
|
|
64
|
+
});
|
|
65
|
+
} else {
|
|
66
|
+
e.stopPropagation();
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
[appStoreApi]
|
|
70
|
+
);
|
|
71
|
+
return /* @__PURE__ */ jsxs(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
className: getClassName({
|
|
75
|
+
editor: !inline,
|
|
76
|
+
inline,
|
|
77
|
+
isActive,
|
|
78
|
+
disabled: readOnly
|
|
79
|
+
}),
|
|
80
|
+
style: inline ? {} : { height: initialHeight != null ? initialHeight : 192, overflowY: "auto" },
|
|
81
|
+
onKeyDownCapture: handleHotkeyCapture,
|
|
82
|
+
onBlur: handleBlur,
|
|
83
|
+
children: [
|
|
84
|
+
!inline && /* @__PURE__ */ jsx("div", { className: getClassName("menu"), children: menu }),
|
|
85
|
+
children
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
EditorInner.displayName = "EditorInner";
|
|
92
|
+
|
|
93
|
+
// components/RichTextMenu/index.tsx
|
|
94
|
+
init_react_import();
|
|
95
|
+
import { lazy, Suspense } from "react";
|
|
96
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
97
|
+
var LoadedRichTextMenuFull = lazy(
|
|
98
|
+
() => import("./full-NLUNPJWS.mjs").then((m) => ({
|
|
99
|
+
default: m.LoadedRichTextMenuFull
|
|
100
|
+
}))
|
|
101
|
+
);
|
|
102
|
+
var LoadedRichTextMenu = (props) => {
|
|
103
|
+
return /* @__PURE__ */ jsx2(Suspense, { fallback: /* @__PURE__ */ jsx2(LoadedRichTextMenuInner, __spreadValues({}, props)), children: /* @__PURE__ */ jsx2(LoadedRichTextMenuFull, __spreadValues({}, props)) });
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export {
|
|
107
|
+
EditorInner,
|
|
108
|
+
LoadedRichTextMenu
|
|
109
|
+
};
|