@measured/puck 0.21.0-canary.16a3eee1 → 0.21.0-canary.17395b2c

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/dist/Editor-CYTATURR.mjs +204 -0
  2. package/dist/Editor-F2LSS6SE.css +403 -0
  3. package/dist/Render-OFE6QLI2.mjs +55 -0
  4. package/dist/Render-QEMDIDQC.css +101 -0
  5. package/dist/{walk-tree-Ctf3FZQI.d.mts → actions-tsxxcX1z.d.mts} +285 -82
  6. package/dist/{walk-tree-Ctf3FZQI.d.ts → actions-tsxxcX1z.d.ts} +285 -82
  7. package/dist/chunk-72SA22GI.mjs +134 -0
  8. package/dist/chunk-CSSRLPHM.mjs +11 -0
  9. package/dist/chunk-M4QBB3JM.mjs +111 -0
  10. package/dist/chunk-M6W7YEVX.mjs +95 -0
  11. package/dist/chunk-MLTVJA2A.mjs +63 -0
  12. package/dist/chunk-MVJKIFF6.mjs +419 -0
  13. package/dist/chunk-NLUHDYVR.mjs +416 -0
  14. package/dist/chunk-NOJQSXRU.mjs +33 -0
  15. package/dist/chunk-QBGM4ELA.mjs +528 -0
  16. package/dist/chunk-UNQOU2OI.mjs +53 -0
  17. package/dist/chunk-UUOBSXZR.mjs +1807 -0
  18. package/dist/chunk-V5I7CVLT.mjs +103 -0
  19. package/dist/chunk-V7333LON.mjs +708 -0
  20. package/dist/{chunk-JZ2BPCUI.mjs → chunk-V73FDFDB.mjs} +6032 -7351
  21. package/dist/chunk-Y2EFNT5P.mjs +108 -0
  22. package/dist/full-2GJTAAZE.css +301 -0
  23. package/dist/full-GZ4L3XCF.mjs +93 -0
  24. package/dist/index-Ca6V6NQD.d.ts +118 -0
  25. package/dist/index-mQvUCH3C.d.mts +118 -0
  26. package/dist/index.css +1032 -387
  27. package/dist/index.d.mts +116 -114
  28. package/dist/index.d.ts +116 -114
  29. package/dist/index.js +8758 -4944
  30. package/dist/index.mjs +34 -12
  31. package/dist/internal.d.mts +27 -0
  32. package/dist/internal.d.ts +27 -0
  33. package/dist/internal.js +908 -0
  34. package/dist/internal.mjs +13 -0
  35. package/dist/loaded-2MNXXPJP.mjs +57 -0
  36. package/dist/loaded-6QT4HD2O.mjs +57 -0
  37. package/dist/loaded-RVWBFK7L.css +87 -0
  38. package/dist/loaded-ZVPBQVNE.mjs +60 -0
  39. package/dist/no-external.css +1165 -516
  40. package/dist/no-external.d.mts +19 -2
  41. package/dist/no-external.d.ts +19 -2
  42. package/dist/no-external.js +8760 -4943
  43. package/dist/no-external.mjs +36 -9
  44. package/dist/rsc.css +101 -0
  45. package/dist/rsc.d.mts +17 -2
  46. package/dist/rsc.d.ts +17 -2
  47. package/dist/rsc.js +421 -32
  48. package/dist/rsc.mjs +18 -9
  49. package/dist/walk-tree-Bh85NMeo.d.ts +29 -0
  50. package/dist/walk-tree-CDA3K5S3.d.mts +29 -0
  51. package/package.json +31 -4
  52. package/dist/chunk-X7YZ3YE7.mjs +0 -964
@@ -0,0 +1,416 @@
1
+ import {
2
+ __spreadProps,
3
+ __spreadValues,
4
+ init_react_import
5
+ } from "./chunk-M6W7YEVX.mjs";
6
+
7
+ // lib/data/walk-tree.ts
8
+ init_react_import();
9
+
10
+ // lib/data/map-fields.ts
11
+ init_react_import();
12
+
13
+ // lib/data/default-slots.ts
14
+ init_react_import();
15
+ var defaultSlots = (value, fields) => Object.keys(fields).reduce(
16
+ (acc, fieldName) => fields[fieldName].type === "slot" ? __spreadValues({ [fieldName]: [] }, acc) : acc,
17
+ value
18
+ );
19
+
20
+ // lib/data/map-fields.ts
21
+ var isPromise = (v) => !!v && typeof v.then === "function";
22
+ var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
23
+ var containsPromise = (arr) => arr.some(isPromise);
24
+ var walkField = ({
25
+ value,
26
+ fields,
27
+ mappers,
28
+ propKey = "",
29
+ propPath = "",
30
+ id = "",
31
+ config,
32
+ recurseSlots = false
33
+ }) => {
34
+ var _a, _b, _c;
35
+ const fieldType = (_a = fields[propKey]) == null ? void 0 : _a.type;
36
+ const map = mappers[fieldType];
37
+ if (map && fieldType === "slot") {
38
+ const content = value || [];
39
+ const mappedContent = recurseSlots ? content.map((el) => {
40
+ var _a2;
41
+ const componentConfig = config.components[el.type];
42
+ if (!componentConfig) {
43
+ throw new Error(`Could not find component config for ${el.type}`);
44
+ }
45
+ const fields2 = (_a2 = componentConfig.fields) != null ? _a2 : {};
46
+ return walkField({
47
+ value: __spreadProps(__spreadValues({}, el), { props: defaultSlots(el.props, fields2) }),
48
+ fields: fields2,
49
+ mappers,
50
+ id: el.props.id,
51
+ config,
52
+ recurseSlots
53
+ });
54
+ }) : content;
55
+ if (containsPromise(mappedContent)) {
56
+ return Promise.all(mappedContent);
57
+ }
58
+ return map({
59
+ value: mappedContent,
60
+ parentId: id,
61
+ propName: propPath,
62
+ field: fields[propKey],
63
+ propPath
64
+ });
65
+ } else if (map && fields[propKey]) {
66
+ return map({
67
+ value,
68
+ parentId: id,
69
+ propName: propKey,
70
+ field: fields[propKey],
71
+ propPath
72
+ });
73
+ }
74
+ if (value && typeof value === "object") {
75
+ if (Array.isArray(value)) {
76
+ const arrayFields = ((_b = fields[propKey]) == null ? void 0 : _b.type) === "array" ? fields[propKey].arrayFields : null;
77
+ if (!arrayFields) return value;
78
+ const newValue = value.map(
79
+ (el, idx) => walkField({
80
+ value: el,
81
+ fields: arrayFields,
82
+ mappers,
83
+ propKey,
84
+ propPath: `${propPath}[${idx}]`,
85
+ id,
86
+ config,
87
+ recurseSlots
88
+ })
89
+ );
90
+ if (containsPromise(newValue)) {
91
+ return Promise.all(newValue);
92
+ }
93
+ return newValue;
94
+ } else if ("$$typeof" in value) {
95
+ return value;
96
+ } else {
97
+ const objectFields = ((_c = fields[propKey]) == null ? void 0 : _c.type) === "object" ? fields[propKey].objectFields : fields;
98
+ return walkObject({
99
+ value,
100
+ fields: objectFields,
101
+ mappers,
102
+ id,
103
+ getPropPath: (k) => `${propPath}.${k}`,
104
+ config,
105
+ recurseSlots
106
+ });
107
+ }
108
+ }
109
+ return value;
110
+ };
111
+ var walkObject = ({
112
+ value,
113
+ fields,
114
+ mappers,
115
+ id,
116
+ getPropPath,
117
+ config,
118
+ recurseSlots
119
+ }) => {
120
+ const newProps = Object.entries(value).map(([k, v]) => {
121
+ const opts = {
122
+ value: v,
123
+ fields,
124
+ mappers,
125
+ propKey: k,
126
+ propPath: getPropPath(k),
127
+ id,
128
+ config,
129
+ recurseSlots
130
+ };
131
+ const newValue = walkField(opts);
132
+ if (isPromise(newValue)) {
133
+ return newValue.then((resolvedValue) => ({
134
+ [k]: resolvedValue
135
+ }));
136
+ }
137
+ return {
138
+ [k]: newValue
139
+ };
140
+ }, {});
141
+ if (containsPromise(newProps)) {
142
+ return Promise.all(newProps).then(flatten);
143
+ }
144
+ return flatten(newProps);
145
+ };
146
+ function mapFields(item, mappers, config, recurseSlots = false) {
147
+ var _a, _b, _c, _d, _e;
148
+ const itemType = "type" in item ? item.type : "root";
149
+ const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
150
+ const newProps = walkObject({
151
+ value: defaultSlots((_b = item.props) != null ? _b : {}, (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {}),
152
+ fields: (_d = componentConfig == null ? void 0 : componentConfig.fields) != null ? _d : {},
153
+ mappers,
154
+ id: item.props ? (_e = item.props.id) != null ? _e : "root" : "root",
155
+ getPropPath: (k) => k,
156
+ config,
157
+ recurseSlots
158
+ });
159
+ if (isPromise(newProps)) {
160
+ return newProps.then((resolvedProps) => __spreadProps(__spreadValues({}, item), {
161
+ props: resolvedProps
162
+ }));
163
+ }
164
+ return __spreadProps(__spreadValues({}, item), {
165
+ props: newProps
166
+ });
167
+ }
168
+
169
+ // lib/data/walk-tree.ts
170
+ function walkTree(data, config, callbackFn) {
171
+ var _a, _b;
172
+ const walkItem = (item) => {
173
+ return mapFields(
174
+ item,
175
+ {
176
+ slot: ({ value, parentId, propName }) => {
177
+ var _a2;
178
+ const content = value;
179
+ return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
180
+ }
181
+ },
182
+ config,
183
+ true
184
+ );
185
+ };
186
+ if ("props" in data) {
187
+ return walkItem(data);
188
+ }
189
+ const _data = data;
190
+ const zones = (_a = _data.zones) != null ? _a : {};
191
+ const mappedContent = _data.content.map(walkItem);
192
+ return {
193
+ root: walkItem(_data.root),
194
+ content: (_b = callbackFn(mappedContent, {
195
+ parentId: "root",
196
+ propName: "default-zone"
197
+ })) != null ? _b : mappedContent,
198
+ zones: Object.keys(zones).reduce(
199
+ (acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
200
+ [zoneCompound]: zones[zoneCompound].map(walkItem)
201
+ }),
202
+ {}
203
+ )
204
+ };
205
+ }
206
+
207
+ // lib/root-droppable-id.ts
208
+ init_react_import();
209
+ var rootAreaId = "root";
210
+ var rootZone = "default-zone";
211
+ var rootDroppableId = `${rootAreaId}:${rootZone}`;
212
+
213
+ // lib/data/flatten-node.ts
214
+ init_react_import();
215
+ import flat from "flat";
216
+
217
+ // lib/data/strip-slots.ts
218
+ init_react_import();
219
+ var stripSlots = (data, config) => {
220
+ return mapFields(data, { slot: () => null }, config);
221
+ };
222
+
223
+ // lib/data/flatten-node.ts
224
+ var { flatten: flatten2, unflatten } = flat;
225
+ var flattenNode = (node, config) => {
226
+ return __spreadProps(__spreadValues({}, node), {
227
+ props: flatten2(stripSlots(node, config).props)
228
+ });
229
+ };
230
+ var expandNode = (node) => {
231
+ const props = unflatten(node.props);
232
+ return __spreadProps(__spreadValues({}, node), {
233
+ props
234
+ });
235
+ };
236
+
237
+ // lib/data/walk-app-state.ts
238
+ init_react_import();
239
+
240
+ // lib/data/for-related-zones.ts
241
+ init_react_import();
242
+
243
+ // lib/get-zone-id.ts
244
+ init_react_import();
245
+ var getZoneId = (zoneCompound) => {
246
+ if (!zoneCompound) {
247
+ return [];
248
+ }
249
+ if (zoneCompound && zoneCompound.indexOf(":") > -1) {
250
+ return zoneCompound.split(":");
251
+ }
252
+ return [rootDroppableId, zoneCompound];
253
+ };
254
+
255
+ // lib/data/for-related-zones.ts
256
+ function forRelatedZones(item, data, cb, path = []) {
257
+ Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
258
+ const [parentId] = getZoneId(zoneCompound);
259
+ if (parentId === item.props.id) {
260
+ cb(path, zoneCompound, content);
261
+ }
262
+ });
263
+ }
264
+
265
+ // lib/data/walk-app-state.ts
266
+ function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
267
+ var _a;
268
+ let newZones = {};
269
+ const newZoneIndex = {};
270
+ const newNodeIndex = {};
271
+ const processContent = (path, zoneCompound, content, zoneType, newId) => {
272
+ var _a2;
273
+ const [parentId] = zoneCompound.split(":");
274
+ const mappedContent = ((_a2 = mapContent(content, zoneCompound, zoneType)) != null ? _a2 : content) || [];
275
+ const [_2, zone] = zoneCompound.split(":");
276
+ const newZoneCompound = `${newId || parentId}:${zone}`;
277
+ const newContent2 = mappedContent.map(
278
+ (zoneChild, index) => processItem(zoneChild, [...path, newZoneCompound], index)
279
+ );
280
+ newZoneIndex[newZoneCompound] = {
281
+ contentIds: newContent2.map((item) => item.props.id),
282
+ type: zoneType
283
+ };
284
+ return [newZoneCompound, newContent2];
285
+ };
286
+ const processRelatedZones = (item, newId, initialPath) => {
287
+ forRelatedZones(
288
+ item,
289
+ state.data,
290
+ (relatedPath, relatedZoneCompound, relatedContent) => {
291
+ const [zoneCompound, newContent2] = processContent(
292
+ relatedPath,
293
+ relatedZoneCompound,
294
+ relatedContent,
295
+ "dropzone",
296
+ newId
297
+ );
298
+ newZones[zoneCompound] = newContent2;
299
+ },
300
+ initialPath
301
+ );
302
+ };
303
+ const processItem = (item, path, index) => {
304
+ const mappedItem = mapNodeOrSkip(item, path, index);
305
+ if (!mappedItem) return item;
306
+ const id = mappedItem.props.id;
307
+ const newProps = __spreadProps(__spreadValues({}, mapFields(
308
+ mappedItem,
309
+ {
310
+ slot: ({ value, parentId: parentId2, propPath }) => {
311
+ const content = value;
312
+ const zoneCompound = `${parentId2}:${propPath}`;
313
+ const [_2, newContent2] = processContent(
314
+ path,
315
+ zoneCompound,
316
+ content,
317
+ "slot",
318
+ parentId2
319
+ );
320
+ return newContent2;
321
+ }
322
+ },
323
+ config
324
+ ).props), {
325
+ id
326
+ });
327
+ processRelatedZones(item, id, path);
328
+ const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
329
+ const thisZoneCompound = path[path.length - 1];
330
+ const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
331
+ newNodeIndex[id] = {
332
+ data: newItem,
333
+ flatData: flattenNode(newItem, config),
334
+ path,
335
+ parentId,
336
+ zone
337
+ };
338
+ const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
339
+ if (newProps.id === "root") {
340
+ delete finalData["type"];
341
+ delete finalData.props["id"];
342
+ }
343
+ return finalData;
344
+ };
345
+ const zones = state.data.zones || {};
346
+ const [_, newContent] = processContent(
347
+ [],
348
+ rootDroppableId,
349
+ state.data.content,
350
+ "root"
351
+ );
352
+ const processedContent = newContent;
353
+ const zonesAlreadyProcessed = Object.keys(newZones);
354
+ Object.keys(zones || {}).forEach((zoneCompound) => {
355
+ const [parentId] = zoneCompound.split(":");
356
+ if (zonesAlreadyProcessed.includes(zoneCompound)) {
357
+ return;
358
+ }
359
+ const [_2, newContent2] = processContent(
360
+ [rootDroppableId],
361
+ zoneCompound,
362
+ zones[zoneCompound],
363
+ "dropzone",
364
+ parentId
365
+ );
366
+ newZones[zoneCompound] = newContent2;
367
+ }, newZones);
368
+ const processedRoot = processItem(
369
+ {
370
+ type: "root",
371
+ props: __spreadProps(__spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root), { id: "root" })
372
+ },
373
+ [],
374
+ -1
375
+ );
376
+ const root = __spreadProps(__spreadValues({}, state.data.root), {
377
+ props: processedRoot.props
378
+ });
379
+ return __spreadProps(__spreadValues({}, state), {
380
+ data: {
381
+ root,
382
+ content: processedContent,
383
+ zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
384
+ },
385
+ indexes: {
386
+ nodes: __spreadValues(__spreadValues({}, state.indexes.nodes), newNodeIndex),
387
+ zones: __spreadValues(__spreadValues({}, state.indexes.zones), newZoneIndex)
388
+ }
389
+ });
390
+ }
391
+
392
+ // lib/data/setup-zone.ts
393
+ init_react_import();
394
+ var setupZone = (data, zoneKey) => {
395
+ if (zoneKey === rootDroppableId) {
396
+ return data;
397
+ }
398
+ const newData = __spreadProps(__spreadValues({}, data), {
399
+ zones: data.zones ? __spreadValues({}, data.zones) : {}
400
+ });
401
+ newData.zones[zoneKey] = newData.zones[zoneKey] || [];
402
+ return newData;
403
+ };
404
+
405
+ export {
406
+ rootAreaId,
407
+ rootZone,
408
+ rootDroppableId,
409
+ defaultSlots,
410
+ walkField,
411
+ mapFields,
412
+ expandNode,
413
+ walkAppState,
414
+ walkTree,
415
+ setupZone
416
+ };
@@ -0,0 +1,33 @@
1
+ import {
2
+ List,
3
+ ListOrdered
4
+ } from "./chunk-UUOBSXZR.mjs";
5
+ import {
6
+ init_react_import
7
+ } from "./chunk-M6W7YEVX.mjs";
8
+
9
+ // components/RichTextMenu/controls/ListSelect/use-options.ts
10
+ init_react_import();
11
+ import { useMemo } from "react";
12
+ var optionNodes = {
13
+ ul: { label: "Bullet list", icon: List },
14
+ ol: { label: "Numbered list", icon: ListOrdered }
15
+ };
16
+ var useListOptions = (fieldOptions) => {
17
+ let blockOptions = [];
18
+ if ((fieldOptions == null ? void 0 : fieldOptions.listItem) !== false) {
19
+ blockOptions = ["ul", "ol"];
20
+ }
21
+ return useMemo(
22
+ () => blockOptions.map((item) => ({
23
+ value: item,
24
+ label: optionNodes[item].label,
25
+ icon: optionNodes[item].icon
26
+ })),
27
+ [blockOptions]
28
+ );
29
+ };
30
+
31
+ export {
32
+ useListOptions
33
+ };