@measured/puck 0.21.0-canary.79a26849 → 0.21.0-canary.7c2f9283
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-32UYWE6W.mjs +204 -0
- package/dist/Editor-IQP25PUX.css +404 -0
- package/dist/Render-3OV4N4MT.css +102 -0
- package/dist/Render-FXZX6NFH.mjs +55 -0
- package/dist/{walk-tree-CgWnYC1X.d.mts → actions-BkBoKAc5.d.mts} +226 -37
- package/dist/{walk-tree-CgWnYC1X.d.ts → actions-BkBoKAc5.d.ts} +226 -37
- package/dist/chunk-3VQHXASI.mjs +33 -0
- package/dist/chunk-6KNQXLQR.mjs +708 -0
- package/dist/chunk-AOEDIUVK.mjs +11 -0
- package/dist/{chunk-UABEUL66.mjs → chunk-FCCNEDWR.mjs} +6964 -7964
- package/dist/chunk-GVKHZNTR.mjs +53 -0
- package/dist/chunk-K562SEXI.mjs +1813 -0
- package/dist/chunk-KN3XDS7U.mjs +528 -0
- package/dist/chunk-M6W7YEVX.mjs +95 -0
- package/dist/chunk-MEL7FUSF.mjs +63 -0
- package/dist/chunk-NYGQH27S.mjs +445 -0
- package/dist/chunk-Q3TJ2VYO.mjs +436 -0
- package/dist/chunk-REWRIUGR.mjs +156 -0
- package/dist/chunk-V2IQTPPK.mjs +111 -0
- package/dist/chunk-V5I7CVLT.mjs +103 -0
- package/dist/chunk-Y2EFNT5P.mjs +108 -0
- package/dist/full-2GJTAAZE.css +301 -0
- package/dist/full-4OS3O57Y.mjs +93 -0
- package/dist/index-bqD1SEOb.d.mts +118 -0
- package/dist/index-lt1zf5WR.d.ts +118 -0
- package/dist/index.css +1032 -385
- package/dist/index.d.mts +115 -115
- package/dist/index.d.ts +115 -115
- package/dist/index.js +9636 -5416
- package/dist/index.mjs +34 -12
- package/dist/internal.d.mts +27 -0
- package/dist/internal.d.ts +27 -0
- package/dist/internal.js +927 -0
- package/dist/internal.mjs +13 -0
- package/dist/loaded-DCQVLO7I.mjs +57 -0
- package/dist/loaded-JGRO7BH7.mjs +57 -0
- package/dist/loaded-KKVJE5KH.mjs +60 -0
- package/dist/loaded-RVWBFK7L.css +87 -0
- package/dist/no-external.css +1121 -470
- package/dist/no-external.d.mts +19 -2
- package/dist/no-external.d.ts +19 -2
- package/dist/no-external.js +9639 -5416
- package/dist/no-external.mjs +36 -9
- package/dist/rsc.css +102 -0
- package/dist/rsc.d.mts +17 -2
- package/dist/rsc.d.ts +17 -2
- package/dist/rsc.js +547 -98
- package/dist/rsc.mjs +18 -9
- package/dist/walk-tree-CRRDqx6_.d.mts +29 -0
- package/dist/walk-tree-CS7sEpfG.d.ts +29 -0
- package/package.json +31 -4
- package/dist/chunk-JA7SEUEH.mjs +0 -966
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
import {
|
|
2
|
+
rootDroppableId,
|
|
3
|
+
setupZone,
|
|
4
|
+
walkAppState,
|
|
5
|
+
walkTree
|
|
6
|
+
} from "./chunk-Q3TJ2VYO.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,95 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __objRest = (source, exclude) => {
|
|
25
|
+
var target = {};
|
|
26
|
+
for (var prop in source)
|
|
27
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
if (source != null && __getOwnPropSymbols)
|
|
30
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
+
target[prop] = source[prop];
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
};
|
|
36
|
+
var __esm = (fn, res) => function __init() {
|
|
37
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
38
|
+
};
|
|
39
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
40
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
41
|
+
};
|
|
42
|
+
var __copyProps = (to, from, except, desc) => {
|
|
43
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
44
|
+
for (let key of __getOwnPropNames(from))
|
|
45
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
46
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
47
|
+
}
|
|
48
|
+
return to;
|
|
49
|
+
};
|
|
50
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
51
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
52
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
53
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
54
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
55
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
56
|
+
mod
|
|
57
|
+
));
|
|
58
|
+
var __async = (__this, __arguments, generator) => {
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
var fulfilled = (value) => {
|
|
61
|
+
try {
|
|
62
|
+
step(generator.next(value));
|
|
63
|
+
} catch (e) {
|
|
64
|
+
reject(e);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var rejected = (value) => {
|
|
68
|
+
try {
|
|
69
|
+
step(generator.throw(value));
|
|
70
|
+
} catch (e) {
|
|
71
|
+
reject(e);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
75
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// ../tsup-config/react-import.js
|
|
80
|
+
import React from "react";
|
|
81
|
+
var init_react_import = __esm({
|
|
82
|
+
"../tsup-config/react-import.js"() {
|
|
83
|
+
"use strict";
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
export {
|
|
88
|
+
__spreadValues,
|
|
89
|
+
__spreadProps,
|
|
90
|
+
__objRest,
|
|
91
|
+
__commonJS,
|
|
92
|
+
__toESM,
|
|
93
|
+
__async,
|
|
94
|
+
init_react_import
|
|
95
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Heading1,
|
|
3
|
+
Heading2,
|
|
4
|
+
Heading3,
|
|
5
|
+
Heading4,
|
|
6
|
+
Heading5,
|
|
7
|
+
Heading6
|
|
8
|
+
} from "./chunk-K562SEXI.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
|
+
};
|