@measured/puck 0.19.0-canary.85ee736 → 0.19.0-canary.8d459e4e
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/README.md +2 -4
- package/dist/chunk-D6ENWNOG.mjs +543 -0
- package/dist/index.css +72 -55
- package/dist/index.d.mts +116 -118
- package/dist/index.d.ts +116 -118
- package/dist/index.js +2241 -1667
- package/dist/index.mjs +1933 -1578
- package/dist/{resolve-all-data-wwgDuTnC.d.mts → resolve-all-data-DtB0OZRl.d.mts} +81 -22
- package/dist/{resolve-all-data-wwgDuTnC.d.ts → resolve-all-data-DtB0OZRl.d.ts} +81 -22
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +278 -135
- package/dist/rsc.mjs +5 -104
- package/package.json +6 -5
- package/dist/chunk-T6VJEBJD.mjs +0 -272
package/dist/rsc.js
CHANGED
@@ -68,7 +68,8 @@ var __async = (__this, __arguments, generator) => {
|
|
68
68
|
var rsc_exports = {};
|
69
69
|
__export(rsc_exports, {
|
70
70
|
Render: () => Render,
|
71
|
-
resolveAllData: () => resolveAllData
|
71
|
+
resolveAllData: () => resolveAllData,
|
72
|
+
transformProps: () => transformProps
|
72
73
|
});
|
73
74
|
module.exports = __toCommonJS(rsc_exports);
|
74
75
|
|
@@ -80,7 +81,7 @@ var rootAreaId = "root";
|
|
80
81
|
var rootZone = "default-zone";
|
81
82
|
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
82
83
|
|
83
|
-
// lib/setup-zone.ts
|
84
|
+
// lib/data/setup-zone.ts
|
84
85
|
var setupZone = (data, zoneKey) => {
|
85
86
|
if (zoneKey === rootDroppableId) {
|
86
87
|
return data;
|
@@ -92,8 +93,76 @@ var setupZone = (data, zoneKey) => {
|
|
92
93
|
return newData;
|
93
94
|
};
|
94
95
|
|
95
|
-
//
|
96
|
+
// lib/use-slots.tsx
|
97
|
+
var import_react2 = require("react");
|
98
|
+
function useSlots(config, props, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
99
|
+
const slotProps = (0, import_react2.useMemo)(() => {
|
100
|
+
if (!(config == null ? void 0 : config.fields)) return props;
|
101
|
+
const slotProps2 = {};
|
102
|
+
const fieldKeys = Object.keys(config.fields);
|
103
|
+
for (let i = 0; i < fieldKeys.length; i++) {
|
104
|
+
const fieldKey = fieldKeys[i];
|
105
|
+
const field = config.fields[fieldKey];
|
106
|
+
if ((field == null ? void 0 : field.type) === "slot") {
|
107
|
+
const content = props[fieldKey] || [];
|
108
|
+
const render = (readOnly == null ? void 0 : readOnly[fieldKey]) || forceReadOnly ? renderSlotRender : renderSlotEdit;
|
109
|
+
const Slot = (dzProps) => render(__spreadProps(__spreadValues({
|
110
|
+
allow: field.allow,
|
111
|
+
disallow: field.disallow
|
112
|
+
}, dzProps), {
|
113
|
+
zone: fieldKey,
|
114
|
+
content
|
115
|
+
}));
|
116
|
+
slotProps2[fieldKey] = Slot;
|
117
|
+
}
|
118
|
+
}
|
119
|
+
return slotProps2;
|
120
|
+
}, [config, readOnly, forceReadOnly]);
|
121
|
+
return __spreadValues(__spreadValues({}, props), slotProps);
|
122
|
+
}
|
123
|
+
|
124
|
+
// components/SlotRender/server.tsx
|
125
|
+
var import_react3 = require("react");
|
96
126
|
var import_jsx_runtime = require("react/jsx-runtime");
|
127
|
+
var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SlotRender, __spreadValues({}, props));
|
128
|
+
var Item = ({
|
129
|
+
config,
|
130
|
+
item,
|
131
|
+
metadata
|
132
|
+
}) => {
|
133
|
+
const Component = config.components[item.type];
|
134
|
+
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
136
|
+
Component.render,
|
137
|
+
__spreadProps(__spreadValues({}, props), {
|
138
|
+
puck: __spreadProps(__spreadValues({}, props.puck), {
|
139
|
+
renderDropZone: DropZoneRender,
|
140
|
+
metadata: metadata || {}
|
141
|
+
})
|
142
|
+
})
|
143
|
+
);
|
144
|
+
};
|
145
|
+
var SlotRender = (0, import_react3.forwardRef)(
|
146
|
+
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
147
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className, style, ref, children: content.map((item) => {
|
148
|
+
if (!config.components[item.type]) {
|
149
|
+
return null;
|
150
|
+
}
|
151
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
152
|
+
Item,
|
153
|
+
{
|
154
|
+
config,
|
155
|
+
item,
|
156
|
+
metadata
|
157
|
+
},
|
158
|
+
item.props.id
|
159
|
+
);
|
160
|
+
}) });
|
161
|
+
}
|
162
|
+
);
|
163
|
+
|
164
|
+
// components/ServerRender/index.tsx
|
165
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
97
166
|
function DropZoneRender({
|
98
167
|
zone,
|
99
168
|
data,
|
@@ -110,28 +179,26 @@ function DropZoneRender({
|
|
110
179
|
zoneCompound = `${areaId}:${zone}`;
|
111
180
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
112
181
|
}
|
113
|
-
return /* @__PURE__ */ (0,
|
182
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: content.map((item) => {
|
114
183
|
const Component = config.components[item.type];
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
data,
|
125
|
-
areaId: item.props.id,
|
126
|
-
config,
|
127
|
-
metadata
|
128
|
-
}
|
129
|
-
),
|
184
|
+
const props = __spreadProps(__spreadValues({}, item.props), {
|
185
|
+
puck: {
|
186
|
+
renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
187
|
+
DropZoneRender,
|
188
|
+
{
|
189
|
+
zone: zone2,
|
190
|
+
data,
|
191
|
+
areaId: item.props.id,
|
192
|
+
config,
|
130
193
|
metadata
|
131
194
|
}
|
132
|
-
|
133
|
-
|
134
|
-
|
195
|
+
),
|
196
|
+
metadata
|
197
|
+
}
|
198
|
+
});
|
199
|
+
const propsWithSlots = useSlots(Component, props, (props2) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
|
200
|
+
if (Component) {
|
201
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Component.render, __spreadValues({}, propsWithSlots), item.props.id);
|
135
202
|
}
|
136
203
|
return null;
|
137
204
|
}) });
|
@@ -139,44 +206,43 @@ function DropZoneRender({
|
|
139
206
|
function Render({
|
140
207
|
config,
|
141
208
|
data,
|
142
|
-
metadata
|
209
|
+
metadata = {}
|
143
210
|
}) {
|
144
211
|
var _a;
|
212
|
+
const rootProps = data.root.props || data.root;
|
213
|
+
const title = rootProps.title || "";
|
214
|
+
const props = __spreadProps(__spreadValues({}, rootProps), {
|
215
|
+
puck: {
|
216
|
+
renderDropZone: ({ zone }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
217
|
+
DropZoneRender,
|
218
|
+
{
|
219
|
+
zone,
|
220
|
+
data,
|
221
|
+
config,
|
222
|
+
metadata
|
223
|
+
}
|
224
|
+
),
|
225
|
+
isEditing: false,
|
226
|
+
dragRef: null,
|
227
|
+
metadata
|
228
|
+
},
|
229
|
+
title,
|
230
|
+
editMode: false,
|
231
|
+
id: "puck-root"
|
232
|
+
});
|
233
|
+
const propsWithSlots = useSlots(config.root, props, (props2) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
|
145
234
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
zone,
|
156
|
-
data,
|
157
|
-
config,
|
158
|
-
metadata
|
159
|
-
}
|
160
|
-
),
|
161
|
-
isEditing: false,
|
162
|
-
dragRef: null
|
163
|
-
},
|
164
|
-
title,
|
165
|
-
editMode: false,
|
166
|
-
id: "puck-root",
|
167
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
168
|
-
DropZoneRender,
|
169
|
-
{
|
170
|
-
config,
|
171
|
-
data,
|
172
|
-
zone: rootZone,
|
173
|
-
metadata
|
174
|
-
}
|
175
|
-
)
|
176
|
-
})
|
177
|
-
);
|
235
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
236
|
+
DropZoneRender,
|
237
|
+
{
|
238
|
+
config,
|
239
|
+
data,
|
240
|
+
zone: rootZone,
|
241
|
+
metadata
|
242
|
+
}
|
243
|
+
) }));
|
178
244
|
}
|
179
|
-
return /* @__PURE__ */ (0,
|
245
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
180
246
|
DropZoneRender,
|
181
247
|
{
|
182
248
|
config,
|
@@ -187,6 +253,40 @@ function Render({
|
|
187
253
|
);
|
188
254
|
}
|
189
255
|
|
256
|
+
// lib/data/is-slot.ts
|
257
|
+
var isSlot = (prop) => {
|
258
|
+
var _a, _b;
|
259
|
+
return Array.isArray(prop) && typeof ((_a = prop[0]) == null ? void 0 : _a.type) === "string" && typeof ((_b = prop[0]) == null ? void 0 : _b.props) === "object";
|
260
|
+
};
|
261
|
+
var createIsSlotConfig = (config) => (itemType, propName, propValue) => {
|
262
|
+
var _a, _b;
|
263
|
+
const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
|
264
|
+
if (!configForComponent) return isSlot(propValue);
|
265
|
+
return ((_b = (_a = configForComponent.fields) == null ? void 0 : _a[propName]) == null ? void 0 : _b.type) === "slot";
|
266
|
+
};
|
267
|
+
|
268
|
+
// lib/data/map-slots.ts
|
269
|
+
function mapSlotsAsync(_0, _1) {
|
270
|
+
return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
|
271
|
+
const props = __spreadValues({}, item.props);
|
272
|
+
const propKeys = Object.keys(props);
|
273
|
+
for (let i = 0; i < propKeys.length; i++) {
|
274
|
+
const propKey = propKeys[i];
|
275
|
+
const itemType = "type" in item ? item.type : "root";
|
276
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
277
|
+
const content = props[propKey];
|
278
|
+
const mappedContent = recursive ? yield Promise.all(
|
279
|
+
content.map((item2) => __async(this, null, function* () {
|
280
|
+
return yield mapSlotsAsync(item2, map, recursive, isSlot2);
|
281
|
+
}))
|
282
|
+
) : content;
|
283
|
+
props[propKey] = yield map(mappedContent, propKey);
|
284
|
+
}
|
285
|
+
}
|
286
|
+
return __spreadProps(__spreadValues({}, item), { props });
|
287
|
+
});
|
288
|
+
}
|
289
|
+
|
190
290
|
// lib/get-changed.ts
|
191
291
|
var getChanged = (newItem, oldItem) => {
|
192
292
|
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
@@ -199,26 +299,15 @@ var getChanged = (newItem, oldItem) => {
|
|
199
299
|
};
|
200
300
|
|
201
301
|
// lib/resolve-component-data.ts
|
302
|
+
var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
|
202
303
|
var cache = { lastChange: {} };
|
203
|
-
var
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
onResolveStart,
|
211
|
-
onResolveEnd
|
212
|
-
);
|
213
|
-
}))
|
214
|
-
);
|
215
|
-
});
|
216
|
-
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd) {
|
217
|
-
const configForItem = config.components[item.type];
|
218
|
-
if (configForItem.resolveData) {
|
219
|
-
const { item: oldItem = null, resolved = {} } = cache.lastChange[item.props.id] || {};
|
220
|
-
if (item && item === oldItem) {
|
221
|
-
return resolved;
|
304
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
|
305
|
+
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
306
|
+
if ((configForItem == null ? void 0 : configForItem.resolveData) && item.props) {
|
307
|
+
const id = "id" in item.props ? item.props.id : "root";
|
308
|
+
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
309
|
+
if (item && (0, import_fast_deep_equal.default)(item, oldItem)) {
|
310
|
+
return { node: resolved, didChange: false };
|
222
311
|
}
|
223
312
|
const changed = getChanged(item, oldItem);
|
224
313
|
if (onResolveStart) {
|
@@ -227,97 +316,151 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
227
316
|
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
228
317
|
changed,
|
229
318
|
lastData: oldItem,
|
230
|
-
metadata
|
319
|
+
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
320
|
+
trigger
|
231
321
|
});
|
232
|
-
|
322
|
+
let resolvedItem = __spreadProps(__spreadValues({}, item), {
|
233
323
|
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
234
324
|
});
|
325
|
+
if (recursive) {
|
326
|
+
resolvedItem = yield mapSlotsAsync(
|
327
|
+
resolvedItem,
|
328
|
+
(content) => __async(void 0, null, function* () {
|
329
|
+
return Promise.all(
|
330
|
+
content.map(
|
331
|
+
(childItem) => __async(void 0, null, function* () {
|
332
|
+
return (yield resolveComponentData(
|
333
|
+
childItem,
|
334
|
+
config,
|
335
|
+
metadata,
|
336
|
+
onResolveStart,
|
337
|
+
onResolveEnd,
|
338
|
+
trigger,
|
339
|
+
false
|
340
|
+
)).node;
|
341
|
+
})
|
342
|
+
)
|
343
|
+
);
|
344
|
+
}),
|
345
|
+
false,
|
346
|
+
createIsSlotConfig(config)
|
347
|
+
);
|
348
|
+
}
|
235
349
|
if (Object.keys(readOnly).length) {
|
236
350
|
resolvedItem.readOnly = readOnly;
|
237
351
|
}
|
238
|
-
cache.lastChange[
|
352
|
+
cache.lastChange[id] = {
|
239
353
|
item,
|
240
354
|
resolved: resolvedItem
|
241
355
|
};
|
242
356
|
if (onResolveEnd) {
|
243
357
|
onResolveEnd(resolvedItem);
|
244
358
|
}
|
245
|
-
return resolvedItem;
|
359
|
+
return { node: resolvedItem, didChange: !(0, import_fast_deep_equal.default)(item, resolvedItem) };
|
246
360
|
}
|
247
|
-
return item;
|
361
|
+
return { node: item, didChange: false };
|
248
362
|
});
|
249
363
|
|
250
|
-
// lib/
|
251
|
-
var cache2 = {};
|
252
|
-
function resolveRootData(data, config, metadata) {
|
253
|
-
return __async(this, null, function* () {
|
254
|
-
var _a, _b, _c, _d, _e;
|
255
|
-
if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
|
256
|
-
if (((_b = cache2.lastChange) == null ? void 0 : _b.original) === data.root) {
|
257
|
-
return cache2.lastChange.resolved;
|
258
|
-
}
|
259
|
-
const changed = getChanged(data.root, (_c = cache2.lastChange) == null ? void 0 : _c.original);
|
260
|
-
const rootWithProps = data.root;
|
261
|
-
const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
|
262
|
-
changed,
|
263
|
-
lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {},
|
264
|
-
metadata: metadata || {}
|
265
|
-
});
|
266
|
-
cache2.lastChange = {
|
267
|
-
original: data.root,
|
268
|
-
resolved: resolvedRoot
|
269
|
-
};
|
270
|
-
return __spreadProps(__spreadValues(__spreadValues({}, data.root), resolvedRoot), {
|
271
|
-
props: __spreadValues(__spreadValues({}, data.root.props), resolvedRoot.props)
|
272
|
-
});
|
273
|
-
}
|
274
|
-
return data.root;
|
275
|
-
});
|
276
|
-
}
|
277
|
-
|
278
|
-
// lib/default-data.ts
|
364
|
+
// lib/data/default-data.ts
|
279
365
|
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
280
366
|
root: data.root || {},
|
281
367
|
content: data.content || []
|
282
368
|
});
|
283
369
|
|
370
|
+
// lib/data/to-component.ts
|
371
|
+
var toComponent = (item) => {
|
372
|
+
return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
|
373
|
+
props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
|
374
|
+
type: "root"
|
375
|
+
});
|
376
|
+
};
|
377
|
+
|
284
378
|
// lib/resolve-all-data.ts
|
285
379
|
function resolveAllData(_0, _1) {
|
286
380
|
return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
|
381
|
+
var _a;
|
287
382
|
const defaultedData = defaultData(data);
|
288
|
-
const
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
const { zones = {} } = data;
|
294
|
-
const zoneKeys = Object.keys(zones);
|
295
|
-
const resolvedZones = {};
|
296
|
-
for (let i = 0; i < zoneKeys.length; i++) {
|
297
|
-
const zoneKey = zoneKeys[i];
|
298
|
-
resolvedZones[zoneKey] = yield resolveAllComponentData(
|
299
|
-
zones[zoneKey],
|
383
|
+
const resolveNode = (_node) => __async(this, null, function* () {
|
384
|
+
const node = toComponent(_node);
|
385
|
+
onResolveStart == null ? void 0 : onResolveStart(node);
|
386
|
+
const resolved = (yield resolveComponentData(
|
387
|
+
node,
|
300
388
|
config,
|
301
389
|
metadata,
|
302
|
-
|
303
|
-
|
390
|
+
() => {
|
391
|
+
},
|
392
|
+
() => {
|
393
|
+
},
|
394
|
+
"force",
|
395
|
+
false
|
396
|
+
)).node;
|
397
|
+
const resolvedDeep = yield mapSlotsAsync(
|
398
|
+
resolved,
|
399
|
+
processContent,
|
400
|
+
false
|
304
401
|
);
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
),
|
315
|
-
|
402
|
+
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
403
|
+
return resolvedDeep;
|
404
|
+
});
|
405
|
+
const processContent = (content) => __async(this, null, function* () {
|
406
|
+
return Promise.all(content.map(resolveNode));
|
407
|
+
});
|
408
|
+
const processZones = () => __async(this, null, function* () {
|
409
|
+
var _a2;
|
410
|
+
const zones = (_a2 = data.zones) != null ? _a2 : {};
|
411
|
+
Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
|
412
|
+
zones[zoneKey] = yield Promise.all(content.map(resolveNode));
|
413
|
+
}));
|
414
|
+
return zones;
|
316
415
|
});
|
416
|
+
const dynamic = {
|
417
|
+
root: yield resolveNode(defaultedData.root),
|
418
|
+
content: yield processContent(defaultedData.content),
|
419
|
+
zones: yield processZones()
|
420
|
+
};
|
421
|
+
Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
|
422
|
+
const content = defaultedData.zones[zoneKey];
|
423
|
+
dynamic.zones[zoneKey] = yield processContent(content);
|
424
|
+
}), {});
|
425
|
+
return dynamic;
|
426
|
+
});
|
427
|
+
}
|
428
|
+
|
429
|
+
// lib/transform-props.ts
|
430
|
+
function transformProps(data, propTransforms) {
|
431
|
+
const mapItem = (item) => {
|
432
|
+
if (propTransforms[item.type]) {
|
433
|
+
return __spreadProps(__spreadValues({}, item), {
|
434
|
+
props: propTransforms[item.type](item.props)
|
435
|
+
});
|
436
|
+
}
|
437
|
+
return item;
|
438
|
+
};
|
439
|
+
const defaultedData = defaultData(data);
|
440
|
+
const rootProps = defaultedData.root.props || defaultedData.root;
|
441
|
+
let newRoot = __spreadValues({}, defaultedData.root);
|
442
|
+
if (propTransforms["root"]) {
|
443
|
+
if (defaultedData.root.props) {
|
444
|
+
newRoot.props = propTransforms["root"](rootProps);
|
445
|
+
} else {
|
446
|
+
newRoot = propTransforms["root"](rootProps);
|
447
|
+
}
|
448
|
+
}
|
449
|
+
const afterPropTransforms = __spreadProps(__spreadValues({}, defaultedData), {
|
450
|
+
root: newRoot,
|
451
|
+
content: defaultedData.content.map(mapItem),
|
452
|
+
zones: Object.keys(data.zones || {}).reduce(
|
453
|
+
(acc, zoneKey) => __spreadProps(__spreadValues({}, acc), {
|
454
|
+
[zoneKey]: data.zones[zoneKey].map(mapItem)
|
455
|
+
}),
|
456
|
+
{}
|
457
|
+
)
|
317
458
|
});
|
459
|
+
return afterPropTransforms;
|
318
460
|
}
|
319
461
|
// Annotate the CommonJS export names for ESM import in node:
|
320
462
|
0 && (module.exports = {
|
321
463
|
Render,
|
322
|
-
resolveAllData
|
464
|
+
resolveAllData,
|
465
|
+
transformProps
|
323
466
|
});
|
package/dist/rsc.mjs
CHANGED
@@ -1,113 +1,14 @@
|
|
1
1
|
import {
|
2
|
-
|
3
|
-
__spreadValues,
|
2
|
+
Render,
|
4
3
|
init_react_import,
|
5
4
|
resolveAllData,
|
6
|
-
|
7
|
-
|
8
|
-
rootZone,
|
9
|
-
setupZone
|
10
|
-
} from "./chunk-T6VJEBJD.mjs";
|
5
|
+
transformProps
|
6
|
+
} from "./chunk-D6ENWNOG.mjs";
|
11
7
|
|
12
8
|
// rsc.tsx
|
13
9
|
init_react_import();
|
14
|
-
|
15
|
-
// components/ServerRender/index.tsx
|
16
|
-
init_react_import();
|
17
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
18
|
-
function DropZoneRender({
|
19
|
-
zone,
|
20
|
-
data,
|
21
|
-
areaId = "root",
|
22
|
-
config,
|
23
|
-
metadata = {}
|
24
|
-
}) {
|
25
|
-
let zoneCompound = rootDroppableId;
|
26
|
-
let content = (data == null ? void 0 : data.content) || [];
|
27
|
-
if (!data || !config) {
|
28
|
-
return null;
|
29
|
-
}
|
30
|
-
if (areaId !== rootAreaId && zone !== rootZone) {
|
31
|
-
zoneCompound = `${areaId}:${zone}`;
|
32
|
-
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
33
|
-
}
|
34
|
-
return /* @__PURE__ */ jsx(Fragment, { children: content.map((item) => {
|
35
|
-
const Component = config.components[item.type];
|
36
|
-
if (Component) {
|
37
|
-
return /* @__PURE__ */ jsx(
|
38
|
-
Component.render,
|
39
|
-
__spreadProps(__spreadValues({}, item.props), {
|
40
|
-
puck: {
|
41
|
-
renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ jsx(
|
42
|
-
DropZoneRender,
|
43
|
-
{
|
44
|
-
zone: zone2,
|
45
|
-
data,
|
46
|
-
areaId: item.props.id,
|
47
|
-
config,
|
48
|
-
metadata
|
49
|
-
}
|
50
|
-
),
|
51
|
-
metadata
|
52
|
-
}
|
53
|
-
}),
|
54
|
-
item.props.id
|
55
|
-
);
|
56
|
-
}
|
57
|
-
return null;
|
58
|
-
}) });
|
59
|
-
}
|
60
|
-
function Render({
|
61
|
-
config,
|
62
|
-
data,
|
63
|
-
metadata
|
64
|
-
}) {
|
65
|
-
var _a;
|
66
|
-
if ((_a = config.root) == null ? void 0 : _a.render) {
|
67
|
-
const rootProps = data.root.props || data.root;
|
68
|
-
const title = rootProps.title || "";
|
69
|
-
return /* @__PURE__ */ jsx(
|
70
|
-
config.root.render,
|
71
|
-
__spreadProps(__spreadValues({}, rootProps), {
|
72
|
-
puck: {
|
73
|
-
renderDropZone: ({ zone }) => /* @__PURE__ */ jsx(
|
74
|
-
DropZoneRender,
|
75
|
-
{
|
76
|
-
zone,
|
77
|
-
data,
|
78
|
-
config,
|
79
|
-
metadata
|
80
|
-
}
|
81
|
-
),
|
82
|
-
isEditing: false,
|
83
|
-
dragRef: null
|
84
|
-
},
|
85
|
-
title,
|
86
|
-
editMode: false,
|
87
|
-
id: "puck-root",
|
88
|
-
children: /* @__PURE__ */ jsx(
|
89
|
-
DropZoneRender,
|
90
|
-
{
|
91
|
-
config,
|
92
|
-
data,
|
93
|
-
zone: rootZone,
|
94
|
-
metadata
|
95
|
-
}
|
96
|
-
)
|
97
|
-
})
|
98
|
-
);
|
99
|
-
}
|
100
|
-
return /* @__PURE__ */ jsx(
|
101
|
-
DropZoneRender,
|
102
|
-
{
|
103
|
-
config,
|
104
|
-
data,
|
105
|
-
zone: rootZone,
|
106
|
-
metadata
|
107
|
-
}
|
108
|
-
);
|
109
|
-
}
|
110
10
|
export {
|
111
11
|
Render,
|
112
|
-
resolveAllData
|
12
|
+
resolveAllData,
|
13
|
+
transformProps
|
113
14
|
};
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@measured/puck",
|
3
|
-
"version": "0.19.0-canary.
|
4
|
-
"author": "
|
3
|
+
"version": "0.19.0-canary.8d459e4e",
|
4
|
+
"author": "Chris Villa <chris@puckeditor.com>",
|
5
5
|
"repository": "measuredco/puck",
|
6
6
|
"bugs": "https://github.com/measuredco/puck/issues",
|
7
7
|
"homepage": "https://puckeditor.com",
|
@@ -27,7 +27,8 @@
|
|
27
27
|
"require": "./dist/rsc.js"
|
28
28
|
},
|
29
29
|
"./puck.css": "./dist/index.css",
|
30
|
-
"./dist/index.css": "./dist/index.css"
|
30
|
+
"./dist/index.css": "./dist/index.css",
|
31
|
+
"./package.json": "./package.json"
|
31
32
|
},
|
32
33
|
"typesVersions": {
|
33
34
|
"*": {
|
@@ -76,9 +77,9 @@
|
|
76
77
|
"react-hotkeys-hook": "^4.6.1",
|
77
78
|
"use-debounce": "^9.0.4",
|
78
79
|
"uuid": "^9.0.1",
|
79
|
-
"zustand": "^5.0.
|
80
|
+
"zustand": "^5.0.3"
|
80
81
|
},
|
81
82
|
"peerDependencies": {
|
82
|
-
"react": "^
|
83
|
+
"react": "^18.0.0 || ^19.0.0"
|
83
84
|
}
|
84
85
|
}
|