@measured/puck 0.21.0-canary.f5820ce9 → 0.21.0-canary.fee2ba98

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-EHVB6NFF.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-DwdqNb63.d.mts} +265 -75
  6. package/dist/{walk-tree-Ctf3FZQI.d.ts → actions-DwdqNb63.d.ts} +265 -75
  7. package/dist/chunk-2334PLLL.mjs +111 -0
  8. package/dist/chunk-4N3WJM5Y.mjs +33 -0
  9. package/dist/{chunk-AO6Y47WD.mjs → chunk-6AGLD64M.mjs} +4819 -6477
  10. package/dist/chunk-CSSRLPHM.mjs +11 -0
  11. package/dist/chunk-D6RJOV2Z.mjs +1727 -0
  12. package/dist/chunk-M6W7YEVX.mjs +95 -0
  13. package/dist/chunk-NLUHDYVR.mjs +416 -0
  14. package/dist/chunk-NQEE2254.mjs +706 -0
  15. package/dist/chunk-PXYVL42X.mjs +53 -0
  16. package/dist/chunk-QBGM4ELA.mjs +528 -0
  17. package/dist/chunk-QLQZDFXM.mjs +63 -0
  18. package/dist/chunk-T3WX7XJ6.mjs +132 -0
  19. package/dist/chunk-V5I7CVLT.mjs +103 -0
  20. package/dist/chunk-Y2EFNT5P.mjs +108 -0
  21. package/dist/chunk-Y656T6AQ.mjs +419 -0
  22. package/dist/full-2GJTAAZE.css +301 -0
  23. package/dist/full-TVZATY2K.mjs +93 -0
  24. package/dist/index-AfAtzigt.d.ts +117 -0
  25. package/dist/index-jxA1wrW4.d.mts +117 -0
  26. package/dist/index.css +278 -22
  27. package/dist/index.d.mts +99 -113
  28. package/dist/index.d.ts +99 -113
  29. package/dist/index.js +6647 -3315
  30. package/dist/index.mjs +26 -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-ICVILKS6.mjs +60 -0
  36. package/dist/loaded-IHAGHNLA.mjs +57 -0
  37. package/dist/loaded-ONU7LATV.mjs +57 -0
  38. package/dist/loaded-RVWBFK7L.css +87 -0
  39. package/dist/no-external.css +425 -165
  40. package/dist/no-external.d.mts +19 -2
  41. package/dist/no-external.d.ts +19 -2
  42. package/dist/no-external.js +6646 -3311
  43. package/dist/no-external.mjs +28 -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 +417 -30
  48. package/dist/rsc.mjs +18 -9
  49. package/dist/walk-tree-DRy9ca1P.d.ts +29 -0
  50. package/dist/walk-tree-Dppc3XGY.d.mts +29 -0
  51. package/package.json +31 -4
  52. package/dist/chunk-VBJEDLUM.mjs +0 -965
@@ -0,0 +1,53 @@
1
+ import {
2
+ AlignCenter,
3
+ AlignJustify,
4
+ AlignLeft,
5
+ AlignRight
6
+ } from "./chunk-D6RJOV2Z.mjs";
7
+ import {
8
+ init_react_import
9
+ } from "./chunk-M6W7YEVX.mjs";
10
+
11
+ // components/RichTextMenu/controls/AlignSelect/use-options.ts
12
+ init_react_import();
13
+ import { useMemo } from "react";
14
+ var optionNodes = {
15
+ left: { label: "Left", icon: AlignLeft },
16
+ center: { label: "Center", icon: AlignCenter },
17
+ right: { label: "Right", icon: AlignRight },
18
+ justify: { label: "Justify", icon: AlignJustify }
19
+ };
20
+ var useAlignOptions = (fieldOptions) => {
21
+ var _a;
22
+ let blockOptions = [];
23
+ if ((fieldOptions == null ? void 0 : fieldOptions.textAlign) !== false) {
24
+ if (!((_a = fieldOptions == null ? void 0 : fieldOptions.textAlign) == null ? void 0 : _a.alignments)) {
25
+ blockOptions = ["left", "center", "right", "justify"];
26
+ } else {
27
+ if (fieldOptions == null ? void 0 : fieldOptions.textAlign.alignments.includes("left")) {
28
+ blockOptions.push("left");
29
+ }
30
+ if (fieldOptions == null ? void 0 : fieldOptions.textAlign.alignments.includes("center")) {
31
+ blockOptions.push("center");
32
+ }
33
+ if (fieldOptions == null ? void 0 : fieldOptions.textAlign.alignments.includes("right")) {
34
+ blockOptions.push("right");
35
+ }
36
+ if (fieldOptions == null ? void 0 : fieldOptions.textAlign.alignments.includes("justify")) {
37
+ blockOptions.push("justify");
38
+ }
39
+ }
40
+ }
41
+ return useMemo(
42
+ () => blockOptions.map((item) => ({
43
+ value: item,
44
+ label: optionNodes[item].label,
45
+ icon: optionNodes[item].icon
46
+ })),
47
+ [blockOptions]
48
+ );
49
+ };
50
+
51
+ export {
52
+ useAlignOptions
53
+ };
@@ -0,0 +1,528 @@
1
+ import {
2
+ rootDroppableId,
3
+ setupZone,
4
+ walkAppState,
5
+ walkTree
6
+ } from "./chunk-NLUHDYVR.mjs";
7
+ import {
8
+ __spreadProps,
9
+ __spreadValues,
10
+ init_react_import
11
+ } from "./chunk-M6W7YEVX.mjs";
12
+
13
+ // reducer/index.ts
14
+ init_react_import();
15
+
16
+ // reducer/actions/set.ts
17
+ init_react_import();
18
+ var setAction = (state, action, appStore) => {
19
+ if (typeof action.state === "object") {
20
+ const newState = __spreadValues(__spreadValues({}, state), action.state);
21
+ if (action.state.indexes) {
22
+ return newState;
23
+ }
24
+ console.warn(
25
+ "`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
26
+ );
27
+ return walkAppState(newState, appStore.config);
28
+ }
29
+ return __spreadValues(__spreadValues({}, state), action.state(state));
30
+ };
31
+
32
+ // reducer/actions/insert.ts
33
+ init_react_import();
34
+
35
+ // lib/data/insert.ts
36
+ init_react_import();
37
+ var insert = (list, index, item) => {
38
+ const result = Array.from(list || []);
39
+ result.splice(index, 0, item);
40
+ return result;
41
+ };
42
+
43
+ // lib/generate-id.ts
44
+ init_react_import();
45
+ import { v4 as uuidv4 } from "uuid";
46
+ var generateId = (type) => type ? `${type}-${uuidv4()}` : uuidv4();
47
+
48
+ // lib/data/get-ids-for-parent.ts
49
+ init_react_import();
50
+ var getIdsForParent = (zoneCompound, state) => {
51
+ const [parentId] = zoneCompound.split(":");
52
+ const node = state.indexes.nodes[parentId];
53
+ return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
54
+ };
55
+
56
+ // lib/data/populate-ids.ts
57
+ init_react_import();
58
+ var populateIds = (data, config, override = false) => {
59
+ const id = generateId(data.type);
60
+ return walkTree(
61
+ __spreadProps(__spreadValues({}, data), {
62
+ props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({}, data.props)
63
+ }),
64
+ config,
65
+ (contents) => contents.map((item) => {
66
+ const id2 = generateId(item.type);
67
+ return __spreadProps(__spreadValues({}, item), {
68
+ props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
69
+ });
70
+ })
71
+ );
72
+ };
73
+
74
+ // reducer/actions/insert.ts
75
+ function insertAction(state, action, appStore) {
76
+ const id = action.id || generateId(action.componentType);
77
+ const emptyComponentData = populateIds(
78
+ {
79
+ type: action.componentType,
80
+ props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
81
+ id
82
+ })
83
+ },
84
+ appStore.config
85
+ );
86
+ const [parentId] = action.destinationZone.split(":");
87
+ const idsInPath = getIdsForParent(action.destinationZone, state);
88
+ return walkAppState(
89
+ state,
90
+ appStore.config,
91
+ (content, zoneCompound) => {
92
+ if (zoneCompound === action.destinationZone) {
93
+ return insert(
94
+ content || [],
95
+ action.destinationIndex,
96
+ emptyComponentData
97
+ );
98
+ }
99
+ return content;
100
+ },
101
+ (childItem, path) => {
102
+ if (childItem.props.id === id || childItem.props.id === parentId) {
103
+ return childItem;
104
+ } else if (idsInPath.includes(childItem.props.id)) {
105
+ return childItem;
106
+ } else if (path.includes(action.destinationZone)) {
107
+ return childItem;
108
+ }
109
+ return null;
110
+ }
111
+ );
112
+ }
113
+
114
+ // reducer/actions/replace.ts
115
+ init_react_import();
116
+ var replaceAction = (state, action, appStore) => {
117
+ const [parentId] = action.destinationZone.split(":");
118
+ const idsInPath = getIdsForParent(action.destinationZone, state);
119
+ const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
120
+ const idChanged = originalId !== action.data.props.id;
121
+ if (idChanged) {
122
+ throw new Error(
123
+ `Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
124
+ );
125
+ }
126
+ const newSlotIds = [];
127
+ const data = walkTree(action.data, appStore.config, (contents, opts) => {
128
+ newSlotIds.push(`${opts.parentId}:${opts.propName}`);
129
+ return contents.map((item) => {
130
+ const id = generateId(item.type);
131
+ return __spreadProps(__spreadValues({}, item), {
132
+ props: __spreadValues({ id }, item.props)
133
+ });
134
+ });
135
+ });
136
+ const stateWithDeepSlotsRemoved = __spreadProps(__spreadValues({}, state), {
137
+ ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
138
+ });
139
+ Object.keys(state.indexes.zones).forEach((zoneCompound) => {
140
+ const id = zoneCompound.split(":")[0];
141
+ if (id === originalId) {
142
+ if (!newSlotIds.includes(zoneCompound)) {
143
+ delete stateWithDeepSlotsRemoved.indexes.zones[zoneCompound];
144
+ }
145
+ }
146
+ });
147
+ return walkAppState(
148
+ stateWithDeepSlotsRemoved,
149
+ appStore.config,
150
+ (content, zoneCompound) => {
151
+ const newContent = [...content];
152
+ if (zoneCompound === action.destinationZone) {
153
+ newContent[action.destinationIndex] = data;
154
+ }
155
+ return newContent;
156
+ },
157
+ (childItem, path) => {
158
+ const pathIds = path.map((p) => p.split(":")[0]);
159
+ if (childItem.props.id === data.props.id) {
160
+ return data;
161
+ } else if (childItem.props.id === parentId) {
162
+ return childItem;
163
+ } else if (idsInPath.indexOf(childItem.props.id) > -1) {
164
+ return childItem;
165
+ } else if (pathIds.indexOf(data.props.id) > -1) {
166
+ return childItem;
167
+ }
168
+ return null;
169
+ }
170
+ );
171
+ };
172
+
173
+ // reducer/actions/replace-root.ts
174
+ init_react_import();
175
+ var replaceRootAction = (state, action, appStore) => {
176
+ return walkAppState(
177
+ state,
178
+ appStore.config,
179
+ (content) => content,
180
+ (childItem) => {
181
+ if (childItem.props.id === "root") {
182
+ return __spreadProps(__spreadValues({}, childItem), {
183
+ props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
184
+ readOnly: action.root.readOnly
185
+ });
186
+ }
187
+ return childItem;
188
+ }
189
+ );
190
+ };
191
+
192
+ // reducer/actions/duplicate.ts
193
+ init_react_import();
194
+
195
+ // lib/data/get-item.ts
196
+ init_react_import();
197
+ function getItem(selector, state) {
198
+ var _a, _b;
199
+ const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
200
+ return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
201
+ }
202
+
203
+ // reducer/actions/duplicate.ts
204
+ function duplicateAction(state, action, appStore) {
205
+ const item = getItem(
206
+ { index: action.sourceIndex, zone: action.sourceZone },
207
+ state
208
+ );
209
+ const idsInPath = getIdsForParent(action.sourceZone, state);
210
+ const newItem = __spreadProps(__spreadValues({}, item), {
211
+ props: __spreadProps(__spreadValues({}, item.props), {
212
+ id: generateId(item.type)
213
+ })
214
+ });
215
+ const modified = walkAppState(
216
+ state,
217
+ appStore.config,
218
+ (content, zoneCompound) => {
219
+ if (zoneCompound === action.sourceZone) {
220
+ return insert(content, action.sourceIndex + 1, item);
221
+ }
222
+ return content;
223
+ },
224
+ (childItem, path, index) => {
225
+ const zoneCompound = path[path.length - 1];
226
+ const parents = path.map((p) => p.split(":")[0]);
227
+ if (parents.indexOf(newItem.props.id) > -1) {
228
+ return __spreadProps(__spreadValues({}, childItem), {
229
+ props: __spreadProps(__spreadValues({}, childItem.props), {
230
+ id: generateId(childItem.type)
231
+ })
232
+ });
233
+ }
234
+ if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
235
+ return newItem;
236
+ }
237
+ const [sourceZoneParent] = action.sourceZone.split(":");
238
+ if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
239
+ return childItem;
240
+ }
241
+ return null;
242
+ }
243
+ );
244
+ return __spreadProps(__spreadValues({}, modified), {
245
+ ui: __spreadProps(__spreadValues({}, modified.ui), {
246
+ itemSelector: {
247
+ index: action.sourceIndex + 1,
248
+ zone: action.sourceZone
249
+ }
250
+ })
251
+ });
252
+ }
253
+
254
+ // reducer/actions/reorder.ts
255
+ init_react_import();
256
+
257
+ // reducer/actions/move.ts
258
+ init_react_import();
259
+
260
+ // lib/data/remove.ts
261
+ init_react_import();
262
+ var remove = (list, index) => {
263
+ const result = Array.from(list);
264
+ result.splice(index, 1);
265
+ return result;
266
+ };
267
+
268
+ // reducer/actions/move.ts
269
+ var moveAction = (state, action, appStore) => {
270
+ if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
271
+ return state;
272
+ }
273
+ const item = getItem(
274
+ { zone: action.sourceZone, index: action.sourceIndex },
275
+ state
276
+ );
277
+ if (!item) return state;
278
+ const idsInSourcePath = getIdsForParent(action.sourceZone, state);
279
+ const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
280
+ return walkAppState(
281
+ state,
282
+ appStore.config,
283
+ (content, zoneCompound) => {
284
+ if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
285
+ return insert(
286
+ remove(content, action.sourceIndex),
287
+ action.destinationIndex,
288
+ item
289
+ );
290
+ } else if (zoneCompound === action.sourceZone) {
291
+ return remove(content, action.sourceIndex);
292
+ } else if (zoneCompound === action.destinationZone) {
293
+ return insert(content, action.destinationIndex, item);
294
+ }
295
+ return content;
296
+ },
297
+ (childItem, path) => {
298
+ const [sourceZoneParent] = action.sourceZone.split(":");
299
+ const [destinationZoneParent] = action.destinationZone.split(":");
300
+ const childId = childItem.props.id;
301
+ if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1 || path.includes(action.destinationZone)) {
302
+ return childItem;
303
+ }
304
+ return null;
305
+ }
306
+ );
307
+ };
308
+
309
+ // reducer/actions/reorder.ts
310
+ var reorderAction = (state, action, appStore) => {
311
+ return moveAction(
312
+ state,
313
+ {
314
+ type: "move",
315
+ sourceIndex: action.sourceIndex,
316
+ sourceZone: action.destinationZone,
317
+ destinationIndex: action.destinationIndex,
318
+ destinationZone: action.destinationZone
319
+ },
320
+ appStore
321
+ );
322
+ };
323
+
324
+ // reducer/actions/remove.ts
325
+ init_react_import();
326
+ var removeAction = (state, action, appStore) => {
327
+ const item = getItem({ index: action.index, zone: action.zone }, state);
328
+ const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
329
+ (acc, [nodeId, nodeData]) => {
330
+ const pathIds = nodeData.path.map((p) => p.split(":")[0]);
331
+ if (pathIds.includes(item.props.id)) {
332
+ return [...acc, nodeId];
333
+ }
334
+ return acc;
335
+ },
336
+ [item.props.id]
337
+ );
338
+ const newState = walkAppState(
339
+ state,
340
+ appStore.config,
341
+ (content, zoneCompound) => {
342
+ if (zoneCompound === action.zone) {
343
+ return remove(content, action.index);
344
+ }
345
+ return content;
346
+ }
347
+ );
348
+ Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
349
+ const parentId = zoneCompound.split(":")[0];
350
+ if (nodesToDelete.includes(parentId) && newState.data.zones) {
351
+ delete newState.data.zones[zoneCompound];
352
+ }
353
+ });
354
+ Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
355
+ const parentId = zoneCompound.split(":")[0];
356
+ if (nodesToDelete.includes(parentId)) {
357
+ delete newState.indexes.zones[zoneCompound];
358
+ }
359
+ });
360
+ nodesToDelete.forEach((id) => {
361
+ delete newState.indexes.nodes[id];
362
+ });
363
+ return newState;
364
+ };
365
+
366
+ // reducer/actions/register-zone.ts
367
+ init_react_import();
368
+ var zoneCache = {};
369
+ function registerZoneAction(state, action) {
370
+ if (zoneCache[action.zone]) {
371
+ return __spreadProps(__spreadValues({}, state), {
372
+ data: __spreadProps(__spreadValues({}, state.data), {
373
+ zones: __spreadProps(__spreadValues({}, state.data.zones), {
374
+ [action.zone]: zoneCache[action.zone]
375
+ })
376
+ }),
377
+ indexes: __spreadProps(__spreadValues({}, state.indexes), {
378
+ zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
379
+ [action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
380
+ contentIds: zoneCache[action.zone].map((item) => item.props.id),
381
+ type: "dropzone"
382
+ })
383
+ })
384
+ })
385
+ });
386
+ }
387
+ return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
388
+ }
389
+ function unregisterZoneAction(state, action) {
390
+ const _zones = __spreadValues({}, state.data.zones || {});
391
+ const zoneIndex = __spreadValues({}, state.indexes.zones || {});
392
+ if (_zones[action.zone]) {
393
+ zoneCache[action.zone] = _zones[action.zone];
394
+ delete _zones[action.zone];
395
+ }
396
+ delete zoneIndex[action.zone];
397
+ return __spreadProps(__spreadValues({}, state), {
398
+ data: __spreadProps(__spreadValues({}, state.data), {
399
+ zones: _zones
400
+ }),
401
+ indexes: __spreadProps(__spreadValues({}, state.indexes), {
402
+ zones: zoneIndex
403
+ })
404
+ });
405
+ }
406
+
407
+ // reducer/actions/set-data.ts
408
+ init_react_import();
409
+ var setDataAction = (state, action, appStore) => {
410
+ if (typeof action.data === "object") {
411
+ console.warn(
412
+ "`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
413
+ );
414
+ return walkAppState(
415
+ __spreadProps(__spreadValues({}, state), {
416
+ data: __spreadValues(__spreadValues({}, state.data), action.data)
417
+ }),
418
+ appStore.config
419
+ );
420
+ }
421
+ return walkAppState(
422
+ __spreadProps(__spreadValues({}, state), {
423
+ data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
424
+ }),
425
+ appStore.config
426
+ );
427
+ };
428
+
429
+ // reducer/actions/set-ui.ts
430
+ init_react_import();
431
+ var setUiAction = (state, action) => {
432
+ if (typeof action.ui === "object") {
433
+ return __spreadProps(__spreadValues({}, state), {
434
+ ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
435
+ });
436
+ }
437
+ return __spreadProps(__spreadValues({}, state), {
438
+ ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
439
+ });
440
+ };
441
+
442
+ // lib/data/make-state-public.ts
443
+ init_react_import();
444
+ var makeStatePublic = (state) => {
445
+ const { data, ui } = state;
446
+ return { data, ui };
447
+ };
448
+
449
+ // reducer/actions.tsx
450
+ init_react_import();
451
+
452
+ // reducer/index.ts
453
+ function storeInterceptor(reducer, record, onAction) {
454
+ return (state, action) => {
455
+ const newAppState = reducer(state, action);
456
+ const isValidType = ![
457
+ "registerZone",
458
+ "unregisterZone",
459
+ "setData",
460
+ "setUi",
461
+ "set"
462
+ ].includes(action.type);
463
+ if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
464
+ if (record) record(newAppState);
465
+ }
466
+ onAction == null ? void 0 : onAction(action, makeStatePublic(newAppState), makeStatePublic(state));
467
+ return newAppState;
468
+ };
469
+ }
470
+ function createReducer({
471
+ record,
472
+ onAction,
473
+ appStore
474
+ }) {
475
+ return storeInterceptor(
476
+ (state, action) => {
477
+ if (action.type === "set") {
478
+ return setAction(state, action, appStore);
479
+ }
480
+ if (action.type === "insert") {
481
+ return insertAction(state, action, appStore);
482
+ }
483
+ if (action.type === "replace") {
484
+ return replaceAction(state, action, appStore);
485
+ }
486
+ if (action.type === "replaceRoot") {
487
+ return replaceRootAction(state, action, appStore);
488
+ }
489
+ if (action.type === "duplicate") {
490
+ return duplicateAction(state, action, appStore);
491
+ }
492
+ if (action.type === "reorder") {
493
+ return reorderAction(state, action, appStore);
494
+ }
495
+ if (action.type === "move") {
496
+ return moveAction(state, action, appStore);
497
+ }
498
+ if (action.type === "remove") {
499
+ return removeAction(state, action, appStore);
500
+ }
501
+ if (action.type === "registerZone") {
502
+ return registerZoneAction(state, action);
503
+ }
504
+ if (action.type === "unregisterZone") {
505
+ return unregisterZoneAction(state, action);
506
+ }
507
+ if (action.type === "setData") {
508
+ return setDataAction(state, action, appStore);
509
+ }
510
+ if (action.type === "setUi") {
511
+ return setUiAction(state, action);
512
+ }
513
+ return state;
514
+ },
515
+ record,
516
+ onAction
517
+ );
518
+ }
519
+
520
+ export {
521
+ insert,
522
+ generateId,
523
+ populateIds,
524
+ insertAction,
525
+ getItem,
526
+ makeStatePublic,
527
+ createReducer
528
+ };
@@ -0,0 +1,63 @@
1
+ import {
2
+ Heading1,
3
+ Heading2,
4
+ Heading3,
5
+ Heading4,
6
+ Heading5,
7
+ Heading6
8
+ } from "./chunk-D6RJOV2Z.mjs";
9
+ import {
10
+ init_react_import
11
+ } from "./chunk-M6W7YEVX.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
+ };