@measured/puck 0.19.0-canary.de23f9d → 0.19.0-canary.e52d3b85

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.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import {
2
+ SlotRenderPure,
2
3
  __spreadProps,
3
4
  __spreadValues,
4
5
  init_react_import,
@@ -6,8 +7,10 @@ import {
6
7
  rootAreaId,
7
8
  rootDroppableId,
8
9
  rootZone,
9
- setupZone
10
- } from "./chunk-T6VJEBJD.mjs";
10
+ setupZone,
11
+ transformProps,
12
+ useSlots
13
+ } from "./chunk-ZOHJNF5K.mjs";
11
14
 
12
15
  // rsc.tsx
13
16
  init_react_import();
@@ -33,26 +36,24 @@ function DropZoneRender({
33
36
  }
34
37
  return /* @__PURE__ */ jsx(Fragment, { children: content.map((item) => {
35
38
  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
- ),
39
+ const props = __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,
51
48
  metadata
52
49
  }
53
- }),
54
- item.props.id
55
- );
50
+ ),
51
+ metadata
52
+ }
53
+ });
54
+ const propsWithSlots = useSlots(config.root, props, (props2) => /* @__PURE__ */ jsx(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
55
+ if (Component) {
56
+ return /* @__PURE__ */ jsx(Component.render, __spreadValues({}, propsWithSlots), item.props.id);
56
57
  }
57
58
  return null;
58
59
  }) });
@@ -60,42 +61,41 @@ function DropZoneRender({
60
61
  function Render({
61
62
  config,
62
63
  data,
63
- metadata
64
+ metadata = {}
64
65
  }) {
65
66
  var _a;
67
+ const rootProps = data.root.props || data.root;
68
+ const title = rootProps.title || "";
69
+ const props = __spreadProps(__spreadValues({}, rootProps), {
70
+ puck: {
71
+ renderDropZone: ({ zone }) => /* @__PURE__ */ jsx(
72
+ DropZoneRender,
73
+ {
74
+ zone,
75
+ data,
76
+ config,
77
+ metadata
78
+ }
79
+ ),
80
+ isEditing: false,
81
+ dragRef: null,
82
+ metadata
83
+ },
84
+ title,
85
+ editMode: false,
86
+ id: "puck-root"
87
+ });
88
+ const propsWithSlots = useSlots(config.root, props, (props2) => /* @__PURE__ */ jsx(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
66
89
  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
- );
90
+ return /* @__PURE__ */ jsx(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ jsx(
91
+ DropZoneRender,
92
+ {
93
+ config,
94
+ data,
95
+ zone: rootZone,
96
+ metadata
97
+ }
98
+ ) }));
99
99
  }
100
100
  return /* @__PURE__ */ jsx(
101
101
  DropZoneRender,
@@ -109,5 +109,6 @@ function Render({
109
109
  }
110
110
  export {
111
111
  Render,
112
- resolveAllData
112
+ resolveAllData,
113
+ transformProps
113
114
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.19.0-canary.de23f9d",
3
+ "version": "0.19.0-canary.e52d3b85",
4
4
  "author": "Measured Corporation Ltd <hello@measured.co>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",
@@ -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.2"
80
+ "zustand": "^5.0.3"
80
81
  },
81
82
  "peerDependencies": {
82
- "react": "^17.0.0 || ^18.0.0 || ^19.0.0"
83
+ "react": "^18.0.0 || ^19.0.0"
83
84
  }
84
85
  }
@@ -1,272 +0,0 @@
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 __typeError = (msg) => {
12
- throw TypeError(msg);
13
- };
14
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15
- var __spreadValues = (a, b) => {
16
- for (var prop in b || (b = {}))
17
- if (__hasOwnProp.call(b, prop))
18
- __defNormalProp(a, prop, b[prop]);
19
- if (__getOwnPropSymbols)
20
- for (var prop of __getOwnPropSymbols(b)) {
21
- if (__propIsEnum.call(b, prop))
22
- __defNormalProp(a, prop, b[prop]);
23
- }
24
- return a;
25
- };
26
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
27
- var __objRest = (source, exclude) => {
28
- var target = {};
29
- for (var prop in source)
30
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
31
- target[prop] = source[prop];
32
- if (source != null && __getOwnPropSymbols)
33
- for (var prop of __getOwnPropSymbols(source)) {
34
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
35
- target[prop] = source[prop];
36
- }
37
- return target;
38
- };
39
- var __esm = (fn, res) => function __init() {
40
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
41
- };
42
- var __commonJS = (cb, mod) => function __require() {
43
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
44
- };
45
- var __copyProps = (to, from, except, desc) => {
46
- if (from && typeof from === "object" || typeof from === "function") {
47
- for (let key of __getOwnPropNames(from))
48
- if (!__hasOwnProp.call(to, key) && key !== except)
49
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
50
- }
51
- return to;
52
- };
53
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
54
- // If the importer is in node compatibility mode or this is not an ESM
55
- // file that has been converted to a CommonJS file using a Babel-
56
- // compatible transform (i.e. "__esModule" has not been set), then set
57
- // "default" to the CommonJS "module.exports" for node compatibility.
58
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
59
- mod
60
- ));
61
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
62
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
63
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
64
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
65
- var __async = (__this, __arguments, generator) => {
66
- return new Promise((resolve, reject) => {
67
- var fulfilled = (value) => {
68
- try {
69
- step(generator.next(value));
70
- } catch (e) {
71
- reject(e);
72
- }
73
- };
74
- var rejected = (value) => {
75
- try {
76
- step(generator.throw(value));
77
- } catch (e) {
78
- reject(e);
79
- }
80
- };
81
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
82
- step((generator = generator.apply(__this, __arguments)).next());
83
- });
84
- };
85
-
86
- // ../tsup-config/react-import.js
87
- import React from "react";
88
- var init_react_import = __esm({
89
- "../tsup-config/react-import.js"() {
90
- "use strict";
91
- }
92
- });
93
-
94
- // lib/resolve-all-data.ts
95
- init_react_import();
96
-
97
- // lib/resolve-component-data.ts
98
- init_react_import();
99
-
100
- // lib/get-changed.ts
101
- init_react_import();
102
- var getChanged = (newItem, oldItem) => {
103
- return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
104
- const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
105
- const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
106
- return __spreadProps(__spreadValues({}, acc), {
107
- [item]: oldItemProps[item] !== newItemProps[item]
108
- });
109
- }, {}) : {};
110
- };
111
-
112
- // lib/resolve-component-data.ts
113
- var cache = { lastChange: {} };
114
- var resolveAllComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (content, config, metadata = {}, onResolveStart, onResolveEnd) {
115
- return yield Promise.all(
116
- content.map((item) => __async(void 0, null, function* () {
117
- return yield resolveComponentData(
118
- item,
119
- config,
120
- metadata,
121
- onResolveStart,
122
- onResolveEnd
123
- );
124
- }))
125
- );
126
- });
127
- var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd) {
128
- const configForItem = config.components[item.type];
129
- if (configForItem.resolveData) {
130
- const { item: oldItem = null, resolved = {} } = cache.lastChange[item.props.id] || {};
131
- if (item && item === oldItem) {
132
- return resolved;
133
- }
134
- const changed = getChanged(item, oldItem);
135
- if (onResolveStart) {
136
- onResolveStart(item);
137
- }
138
- const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
139
- changed,
140
- lastData: oldItem,
141
- metadata
142
- });
143
- const resolvedItem = __spreadProps(__spreadValues({}, item), {
144
- props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
145
- });
146
- if (Object.keys(readOnly).length) {
147
- resolvedItem.readOnly = readOnly;
148
- }
149
- cache.lastChange[item.props.id] = {
150
- item,
151
- resolved: resolvedItem
152
- };
153
- if (onResolveEnd) {
154
- onResolveEnd(resolvedItem);
155
- }
156
- return resolvedItem;
157
- }
158
- return item;
159
- });
160
-
161
- // lib/resolve-root-data.ts
162
- init_react_import();
163
- var cache2 = {};
164
- function resolveRootData(data, config, metadata) {
165
- return __async(this, null, function* () {
166
- var _a, _b, _c, _d, _e;
167
- if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
168
- if (((_b = cache2.lastChange) == null ? void 0 : _b.original) === data.root) {
169
- return cache2.lastChange.resolved;
170
- }
171
- const changed = getChanged(data.root, (_c = cache2.lastChange) == null ? void 0 : _c.original);
172
- const rootWithProps = data.root;
173
- const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
174
- changed,
175
- lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {},
176
- metadata: metadata || {}
177
- });
178
- cache2.lastChange = {
179
- original: data.root,
180
- resolved: resolvedRoot
181
- };
182
- return __spreadProps(__spreadValues(__spreadValues({}, data.root), resolvedRoot), {
183
- props: __spreadValues(__spreadValues({}, data.root.props), resolvedRoot.props)
184
- });
185
- }
186
- return data.root;
187
- });
188
- }
189
-
190
- // lib/default-data.ts
191
- init_react_import();
192
- var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
193
- root: data.root || {},
194
- content: data.content || []
195
- });
196
-
197
- // lib/resolve-all-data.ts
198
- function resolveAllData(_0, _1) {
199
- return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
200
- const defaultedData = defaultData(data);
201
- const dynamicRoot = yield resolveRootData(
202
- defaultedData,
203
- config,
204
- metadata
205
- );
206
- const { zones = {} } = data;
207
- const zoneKeys = Object.keys(zones);
208
- const resolvedZones = {};
209
- for (let i = 0; i < zoneKeys.length; i++) {
210
- const zoneKey = zoneKeys[i];
211
- resolvedZones[zoneKey] = yield resolveAllComponentData(
212
- zones[zoneKey],
213
- config,
214
- metadata,
215
- onResolveStart,
216
- onResolveEnd
217
- );
218
- }
219
- return __spreadProps(__spreadValues({}, defaultedData), {
220
- root: dynamicRoot,
221
- content: yield resolveAllComponentData(
222
- defaultedData.content,
223
- config,
224
- metadata,
225
- onResolveStart,
226
- onResolveEnd
227
- ),
228
- zones: resolvedZones
229
- });
230
- });
231
- }
232
-
233
- // lib/root-droppable-id.ts
234
- init_react_import();
235
- var rootAreaId = "root";
236
- var rootZone = "default-zone";
237
- var rootDroppableId = `${rootAreaId}:${rootZone}`;
238
-
239
- // lib/setup-zone.ts
240
- init_react_import();
241
- var setupZone = (data, zoneKey) => {
242
- if (zoneKey === rootDroppableId) {
243
- return data;
244
- }
245
- const newData = __spreadProps(__spreadValues({}, data), {
246
- zones: data.zones ? __spreadValues({}, data.zones) : {}
247
- });
248
- newData.zones[zoneKey] = newData.zones[zoneKey] || [];
249
- return newData;
250
- };
251
-
252
- export {
253
- __spreadValues,
254
- __spreadProps,
255
- __objRest,
256
- __commonJS,
257
- __toESM,
258
- __privateGet,
259
- __privateAdd,
260
- __privateSet,
261
- __async,
262
- init_react_import,
263
- rootAreaId,
264
- rootZone,
265
- rootDroppableId,
266
- setupZone,
267
- getChanged,
268
- resolveComponentData,
269
- resolveRootData,
270
- defaultData,
271
- resolveAllData
272
- };