@measured/puck 0.19.0-canary.24030a9 → 0.19.0-canary.25bbe83e

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/rsc.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as Config, U as UserGenerics, M as Metadata } from './resolve-all-data-DleIzc4N.mjs';
3
- export { a6 as resolveAllData } from './resolve-all-data-DleIzc4N.mjs';
2
+ import { a as Config, U as UserGenerics, M as Metadata } from './walk-tree-CM-cu7GU.mjs';
3
+ export { af as resolveAllData, ae as transformProps, w as walkTree } from './walk-tree-CM-cu7GU.mjs';
4
4
  import 'react';
5
5
 
6
6
  declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
package/dist/rsc.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as Config, U as UserGenerics, M as Metadata } from './resolve-all-data-DleIzc4N.js';
3
- export { a6 as resolveAllData } from './resolve-all-data-DleIzc4N.js';
2
+ import { a as Config, U as UserGenerics, M as Metadata } from './walk-tree-CM-cu7GU.js';
3
+ export { af as resolveAllData, ae as transformProps, w as walkTree } from './walk-tree-CM-cu7GU.js';
4
4
  import 'react';
5
5
 
6
6
  declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
package/dist/rsc.js CHANGED
@@ -68,7 +68,9 @@ 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,
73
+ walkTree: () => walkTree
72
74
  });
73
75
  module.exports = __toCommonJS(rsc_exports);
74
76
 
@@ -80,7 +82,7 @@ var rootAreaId = "root";
80
82
  var rootZone = "default-zone";
81
83
  var rootDroppableId = `${rootAreaId}:${rootZone}`;
82
84
 
83
- // lib/setup-zone.ts
85
+ // lib/data/setup-zone.ts
84
86
  var setupZone = (data, zoneKey) => {
85
87
  if (zoneKey === rootDroppableId) {
86
88
  return data;
@@ -92,8 +94,76 @@ var setupZone = (data, zoneKey) => {
92
94
  return newData;
93
95
  };
94
96
 
95
- // components/ServerRender/index.tsx
97
+ // lib/use-slots.tsx
98
+ var import_react2 = require("react");
99
+ function useSlots(config, props, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
100
+ const slotProps = (0, import_react2.useMemo)(() => {
101
+ if (!(config == null ? void 0 : config.fields)) return props;
102
+ const slotProps2 = {};
103
+ const fieldKeys = Object.keys(config.fields);
104
+ for (let i = 0; i < fieldKeys.length; i++) {
105
+ const fieldKey = fieldKeys[i];
106
+ const field = config.fields[fieldKey];
107
+ if ((field == null ? void 0 : field.type) === "slot") {
108
+ const content = props[fieldKey] || [];
109
+ const render = (readOnly == null ? void 0 : readOnly[fieldKey]) || forceReadOnly ? renderSlotRender : renderSlotEdit;
110
+ const Slot = (dzProps) => render(__spreadProps(__spreadValues({
111
+ allow: field.allow,
112
+ disallow: field.disallow
113
+ }, dzProps), {
114
+ zone: fieldKey,
115
+ content
116
+ }));
117
+ slotProps2[fieldKey] = Slot;
118
+ }
119
+ }
120
+ return slotProps2;
121
+ }, [config, readOnly, forceReadOnly]);
122
+ return __spreadValues(__spreadValues({}, props), slotProps);
123
+ }
124
+
125
+ // components/SlotRender/server.tsx
126
+ var import_react3 = require("react");
96
127
  var import_jsx_runtime = require("react/jsx-runtime");
128
+ var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SlotRender, __spreadValues({}, props));
129
+ var Item = ({
130
+ config,
131
+ item,
132
+ metadata
133
+ }) => {
134
+ const Component = config.components[item.type];
135
+ const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
136
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
137
+ Component.render,
138
+ __spreadProps(__spreadValues({}, props), {
139
+ puck: __spreadProps(__spreadValues({}, props.puck), {
140
+ renderDropZone: DropZoneRender,
141
+ metadata: metadata || {}
142
+ })
143
+ })
144
+ );
145
+ };
146
+ var SlotRender = (0, import_react3.forwardRef)(
147
+ function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
148
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className, style, ref, children: content.map((item) => {
149
+ if (!config.components[item.type]) {
150
+ return null;
151
+ }
152
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
153
+ Item,
154
+ {
155
+ config,
156
+ item,
157
+ metadata
158
+ },
159
+ item.props.id
160
+ );
161
+ }) });
162
+ }
163
+ );
164
+
165
+ // components/ServerRender/index.tsx
166
+ var import_jsx_runtime2 = require("react/jsx-runtime");
97
167
  function DropZoneRender({
98
168
  zone,
99
169
  data,
@@ -110,28 +180,26 @@ function DropZoneRender({
110
180
  zoneCompound = `${areaId}:${zone}`;
111
181
  content = setupZone(data, zoneCompound).zones[zoneCompound];
112
182
  }
113
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: content.map((item) => {
183
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: content.map((item) => {
114
184
  const Component = config.components[item.type];
115
- if (Component) {
116
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
117
- Component.render,
118
- __spreadProps(__spreadValues({}, item.props), {
119
- puck: {
120
- renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
121
- DropZoneRender,
122
- {
123
- zone: zone2,
124
- data,
125
- areaId: item.props.id,
126
- config,
127
- metadata
128
- }
129
- ),
185
+ const props = __spreadProps(__spreadValues({}, item.props), {
186
+ puck: {
187
+ renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
188
+ DropZoneRender,
189
+ {
190
+ zone: zone2,
191
+ data,
192
+ areaId: item.props.id,
193
+ config,
130
194
  metadata
131
195
  }
132
- }),
133
- item.props.id
134
- );
196
+ ),
197
+ metadata
198
+ }
199
+ });
200
+ const propsWithSlots = useSlots(Component, props, (props2) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
201
+ if (Component) {
202
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Component.render, __spreadValues({}, propsWithSlots), item.props.id);
135
203
  }
136
204
  return null;
137
205
  }) });
@@ -139,44 +207,43 @@ function DropZoneRender({
139
207
  function Render({
140
208
  config,
141
209
  data,
142
- metadata
210
+ metadata = {}
143
211
  }) {
144
212
  var _a;
213
+ const rootProps = data.root.props || data.root;
214
+ const title = rootProps.title || "";
215
+ const props = __spreadProps(__spreadValues({}, rootProps), {
216
+ puck: {
217
+ renderDropZone: ({ zone }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
218
+ DropZoneRender,
219
+ {
220
+ zone,
221
+ data,
222
+ config,
223
+ metadata
224
+ }
225
+ ),
226
+ isEditing: false,
227
+ dragRef: null,
228
+ metadata
229
+ },
230
+ title,
231
+ editMode: false,
232
+ id: "puck-root"
233
+ });
234
+ const propsWithSlots = useSlots(config.root, props, (props2) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
145
235
  if ((_a = config.root) == null ? void 0 : _a.render) {
146
- const rootProps = data.root.props || data.root;
147
- const title = rootProps.title || "";
148
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
149
- config.root.render,
150
- __spreadProps(__spreadValues({}, rootProps), {
151
- puck: {
152
- renderDropZone: ({ zone }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
153
- DropZoneRender,
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
- );
236
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
237
+ DropZoneRender,
238
+ {
239
+ config,
240
+ data,
241
+ zone: rootZone,
242
+ metadata
243
+ }
244
+ ) }));
178
245
  }
179
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
246
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
180
247
  DropZoneRender,
181
248
  {
182
249
  config,
@@ -187,6 +254,57 @@ function Render({
187
254
  );
188
255
  }
189
256
 
257
+ // lib/data/is-slot.ts
258
+ var isSlot = (prop) => {
259
+ var _a, _b;
260
+ return Array.isArray(prop) && typeof ((_a = prop[0]) == null ? void 0 : _a.type) === "string" && typeof ((_b = prop[0]) == null ? void 0 : _b.props) === "object";
261
+ };
262
+ var createIsSlotConfig = (config) => (itemType, propName, propValue) => {
263
+ var _a, _b;
264
+ const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
265
+ if (!configForComponent) return isSlot(propValue);
266
+ return ((_b = (_a = configForComponent.fields) == null ? void 0 : _a[propName]) == null ? void 0 : _b.type) === "slot";
267
+ };
268
+
269
+ // lib/data/map-slots.ts
270
+ function mapSlotsAsync(_0, _1) {
271
+ return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
272
+ const props = __spreadValues({}, item.props);
273
+ const propKeys = Object.keys(props);
274
+ for (let i = 0; i < propKeys.length; i++) {
275
+ const propKey = propKeys[i];
276
+ const itemType = "type" in item ? item.type : "root";
277
+ if (isSlot2(itemType, propKey, props[propKey])) {
278
+ const content = props[propKey];
279
+ const mappedContent = recursive ? yield Promise.all(
280
+ content.map((item2) => __async(this, null, function* () {
281
+ return yield mapSlotsAsync(item2, map, recursive, isSlot2);
282
+ }))
283
+ ) : content;
284
+ props[propKey] = yield map(mappedContent, propKey);
285
+ }
286
+ }
287
+ return __spreadProps(__spreadValues({}, item), { props });
288
+ });
289
+ }
290
+ function mapSlotsSync(item, map, isSlot2 = isSlot) {
291
+ var _a, _b;
292
+ const props = __spreadValues({}, item.props);
293
+ const propKeys = Object.keys(props);
294
+ for (let i = 0; i < propKeys.length; i++) {
295
+ const propKey = propKeys[i];
296
+ const itemType = "type" in item ? item.type : "root";
297
+ if (isSlot2(itemType, propKey, props[propKey])) {
298
+ const content = props[propKey];
299
+ const mappedContent = content.map((item2) => {
300
+ return mapSlotsSync(item2, map, isSlot2);
301
+ });
302
+ props[propKey] = (_b = map(mappedContent, (_a = props.id) != null ? _a : "root", propKey)) != null ? _b : mappedContent;
303
+ }
304
+ }
305
+ return __spreadProps(__spreadValues({}, item), { props });
306
+ }
307
+
190
308
  // lib/get-changed.ts
191
309
  var getChanged = (newItem, oldItem) => {
192
310
  return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
@@ -199,26 +317,15 @@ var getChanged = (newItem, oldItem) => {
199
317
  };
200
318
 
201
319
  // lib/resolve-component-data.ts
320
+ var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
202
321
  var cache = { lastChange: {} };
203
- var resolveAllComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (content, config, metadata = {}, onResolveStart, onResolveEnd) {
204
- return yield Promise.all(
205
- content.map((item) => __async(void 0, null, function* () {
206
- return yield resolveComponentData(
207
- item,
208
- config,
209
- metadata,
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;
322
+ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
323
+ const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
324
+ if ((configForItem == null ? void 0 : configForItem.resolveData) && item.props) {
325
+ const id = "id" in item.props ? item.props.id : "root";
326
+ const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
327
+ if (item && (0, import_fast_deep_equal.default)(item, oldItem)) {
328
+ return { node: resolved, didChange: false };
222
329
  }
223
330
  const changed = getChanged(item, oldItem);
224
331
  if (onResolveStart) {
@@ -227,97 +334,184 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
227
334
  const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
228
335
  changed,
229
336
  lastData: oldItem,
230
- metadata
337
+ metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
338
+ trigger
231
339
  });
232
- const resolvedItem = __spreadProps(__spreadValues({}, item), {
340
+ let resolvedItem = __spreadProps(__spreadValues({}, item), {
233
341
  props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
234
342
  });
343
+ if (recursive) {
344
+ resolvedItem = yield mapSlotsAsync(
345
+ resolvedItem,
346
+ (content) => __async(void 0, null, function* () {
347
+ return Promise.all(
348
+ content.map(
349
+ (childItem) => __async(void 0, null, function* () {
350
+ return (yield resolveComponentData(
351
+ childItem,
352
+ config,
353
+ metadata,
354
+ onResolveStart,
355
+ onResolveEnd,
356
+ trigger,
357
+ false
358
+ )).node;
359
+ })
360
+ )
361
+ );
362
+ }),
363
+ false,
364
+ createIsSlotConfig(config)
365
+ );
366
+ }
235
367
  if (Object.keys(readOnly).length) {
236
368
  resolvedItem.readOnly = readOnly;
237
369
  }
238
- cache.lastChange[item.props.id] = {
370
+ cache.lastChange[id] = {
239
371
  item,
240
372
  resolved: resolvedItem
241
373
  };
242
374
  if (onResolveEnd) {
243
375
  onResolveEnd(resolvedItem);
244
376
  }
245
- return resolvedItem;
377
+ return { node: resolvedItem, didChange: !(0, import_fast_deep_equal.default)(item, resolvedItem) };
246
378
  }
247
- return item;
379
+ return { node: item, didChange: false };
248
380
  });
249
381
 
250
- // lib/resolve-root-data.ts
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
382
+ // lib/data/default-data.ts
279
383
  var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
280
384
  root: data.root || {},
281
385
  content: data.content || []
282
386
  });
283
387
 
388
+ // lib/data/to-component.ts
389
+ var toComponent = (item) => {
390
+ return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
391
+ props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
392
+ type: "root"
393
+ });
394
+ };
395
+
284
396
  // lib/resolve-all-data.ts
285
397
  function resolveAllData(_0, _1) {
286
398
  return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
399
+ var _a;
287
400
  const defaultedData = defaultData(data);
288
- const dynamicRoot = yield resolveRootData(
289
- defaultedData,
290
- config,
291
- metadata
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],
401
+ const resolveNode = (_node) => __async(this, null, function* () {
402
+ const node = toComponent(_node);
403
+ onResolveStart == null ? void 0 : onResolveStart(node);
404
+ const resolved = (yield resolveComponentData(
405
+ node,
300
406
  config,
301
407
  metadata,
302
- onResolveStart,
303
- onResolveEnd
408
+ () => {
409
+ },
410
+ () => {
411
+ },
412
+ "force",
413
+ false
414
+ )).node;
415
+ const resolvedDeep = yield mapSlotsAsync(
416
+ resolved,
417
+ processContent,
418
+ false
304
419
  );
305
- }
306
- return __spreadProps(__spreadValues({}, defaultedData), {
307
- root: dynamicRoot,
308
- content: yield resolveAllComponentData(
309
- defaultedData.content,
310
- config,
311
- metadata,
312
- onResolveStart,
313
- onResolveEnd
314
- ),
315
- zones: resolvedZones
420
+ onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
421
+ return resolvedDeep;
422
+ });
423
+ const processContent = (content) => __async(this, null, function* () {
424
+ return Promise.all(content.map(resolveNode));
425
+ });
426
+ const processZones = () => __async(this, null, function* () {
427
+ var _a2;
428
+ const zones = (_a2 = data.zones) != null ? _a2 : {};
429
+ Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
430
+ zones[zoneKey] = yield Promise.all(content.map(resolveNode));
431
+ }));
432
+ return zones;
316
433
  });
434
+ const dynamic = {
435
+ root: yield resolveNode(defaultedData.root),
436
+ content: yield processContent(defaultedData.content),
437
+ zones: yield processZones()
438
+ };
439
+ Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
440
+ const content = defaultedData.zones[zoneKey];
441
+ dynamic.zones[zoneKey] = yield processContent(content);
442
+ }), {});
443
+ return dynamic;
317
444
  });
318
445
  }
446
+
447
+ // lib/transform-props.ts
448
+ function transformProps(data, propTransforms) {
449
+ const mapItem = (item) => {
450
+ if (propTransforms[item.type]) {
451
+ return __spreadProps(__spreadValues({}, item), {
452
+ props: propTransforms[item.type](item.props)
453
+ });
454
+ }
455
+ return item;
456
+ };
457
+ const defaultedData = defaultData(data);
458
+ const rootProps = defaultedData.root.props || defaultedData.root;
459
+ let newRoot = __spreadValues({}, defaultedData.root);
460
+ if (propTransforms["root"]) {
461
+ if (defaultedData.root.props) {
462
+ newRoot.props = propTransforms["root"](rootProps);
463
+ } else {
464
+ newRoot = propTransforms["root"](rootProps);
465
+ }
466
+ }
467
+ const afterPropTransforms = __spreadProps(__spreadValues({}, defaultedData), {
468
+ root: newRoot,
469
+ content: defaultedData.content.map(mapItem),
470
+ zones: Object.keys(data.zones || {}).reduce(
471
+ (acc, zoneKey) => __spreadProps(__spreadValues({}, acc), {
472
+ [zoneKey]: data.zones[zoneKey].map(mapItem)
473
+ }),
474
+ {}
475
+ )
476
+ });
477
+ return afterPropTransforms;
478
+ }
479
+
480
+ // lib/data/walk-tree.ts
481
+ function walkTree(data, config, callbackFn) {
482
+ var _a, _b;
483
+ const isSlot2 = createIsSlotConfig(config);
484
+ const walkItem = (item) => {
485
+ return mapSlotsSync(
486
+ item,
487
+ (content, parentId, propName) => callbackFn(content, { parentId, propName }),
488
+ isSlot2
489
+ );
490
+ };
491
+ if ("props" in data) {
492
+ return walkItem(data);
493
+ }
494
+ const _data = data;
495
+ const zones = (_a = _data.zones) != null ? _a : {};
496
+ const mappedContent = _data.content.map(walkItem);
497
+ return {
498
+ root: walkItem(_data.root),
499
+ content: (_b = callbackFn(mappedContent, {
500
+ parentId: "root",
501
+ propName: "default-zone"
502
+ })) != null ? _b : mappedContent,
503
+ zones: Object.keys(zones).reduce(
504
+ (acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
505
+ [zoneCompound]: zones[zoneCompound].map(walkItem)
506
+ }),
507
+ {}
508
+ )
509
+ };
510
+ }
319
511
  // Annotate the CommonJS export names for ESM import in node:
320
512
  0 && (module.exports = {
321
513
  Render,
322
- resolveAllData
514
+ resolveAllData,
515
+ transformProps,
516
+ walkTree
323
517
  });
package/dist/rsc.mjs CHANGED
@@ -1,113 +1,16 @@
1
1
  import {
2
- __spreadProps,
3
- __spreadValues,
2
+ Render,
4
3
  init_react_import,
5
4
  resolveAllData,
6
- rootAreaId,
7
- rootDroppableId,
8
- rootZone,
9
- setupZone
10
- } from "./chunk-T6VJEBJD.mjs";
5
+ transformProps,
6
+ walkTree
7
+ } from "./chunk-COT3ZFIM.mjs";
11
8
 
12
9
  // rsc.tsx
13
10
  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
11
  export {
111
12
  Render,
112
- resolveAllData
13
+ resolveAllData,
14
+ transformProps,
15
+ walkTree
113
16
  };