@measured/puck 0.18.3-canary.9e8e47b → 0.19.0-canary.020071e
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/{chunk-CHWFBYEM.mjs → chunk-7N5DRY4G.mjs} +69 -17
- package/dist/index.d.mts +126 -37
- package/dist/index.d.ts +126 -37
- package/dist/index.js +5173 -4883
- package/dist/index.mjs +2996 -2759
- package/dist/{resolve-all-data-ppm982Jh.d.mts → resolve-all-data-3XjIPfNh.d.mts} +23 -2
- package/dist/{resolve-all-data-ppm982Jh.d.ts → resolve-all-data-3XjIPfNh.d.ts} +23 -2
- package/dist/rsc.d.mts +4 -3
- package/dist/rsc.d.ts +4 -3
- package/dist/rsc.js +99 -19
- package/dist/rsc.mjs +46 -11
- package/package.json +5 -3
@@ -22,17 +22,22 @@ type FieldOption = {
|
|
22
22
|
type FieldOptions = Array<FieldOption> | ReadonlyArray<FieldOption>;
|
23
23
|
type BaseField = {
|
24
24
|
label?: string;
|
25
|
+
labelIcon?: ReactElement;
|
25
26
|
};
|
26
27
|
type TextField = BaseField & {
|
27
28
|
type: "text";
|
29
|
+
placeholder?: string;
|
28
30
|
};
|
29
31
|
type NumberField = BaseField & {
|
30
32
|
type: "number";
|
33
|
+
placeholder?: string;
|
31
34
|
min?: number;
|
32
35
|
max?: number;
|
36
|
+
step?: number;
|
33
37
|
};
|
34
38
|
type TextareaField = BaseField & {
|
35
39
|
type: "textarea";
|
40
|
+
placeholder?: string;
|
36
41
|
};
|
37
42
|
type SelectField = BaseField & {
|
38
43
|
type: "select";
|
@@ -154,6 +159,7 @@ type ComponentConfig<RenderProps extends DefaultComponentProps = DefaultComponen
|
|
154
159
|
resolveData?: (data: DataShape, params: {
|
155
160
|
changed: Partial<Record<keyof FieldProps, boolean>>;
|
156
161
|
lastData: DataShape | null;
|
162
|
+
metadata: Metadata;
|
157
163
|
}) => Promise<{
|
158
164
|
props?: Partial<FieldProps>;
|
159
165
|
readOnly?: Partial<Record<keyof FieldProps, boolean>>;
|
@@ -209,6 +215,7 @@ type UserGenerics<UserConfig extends Config = Config, UserProps extends ExtractP
|
|
209
215
|
|
210
216
|
type PuckContext = {
|
211
217
|
renderDropZone: React.FC<DropZoneProps>;
|
218
|
+
metadata: Metadata;
|
212
219
|
isEditing: boolean;
|
213
220
|
dragRef: ((element: Element | null) => void) | null;
|
214
221
|
};
|
@@ -251,6 +258,9 @@ type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps
|
|
251
258
|
content: Content<Props>;
|
252
259
|
zones?: Record<string, Content<Props>>;
|
253
260
|
};
|
261
|
+
type Metadata = {
|
262
|
+
[key: string]: any;
|
263
|
+
};
|
254
264
|
|
255
265
|
type ItemWithId = {
|
256
266
|
_arrayId: string;
|
@@ -457,6 +467,17 @@ type PuckAction = {
|
|
457
467
|
recordHistory?: boolean;
|
458
468
|
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
459
469
|
|
460
|
-
|
470
|
+
type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
|
471
|
+
[ComponentName in keyof Props]: (props: Props[ComponentName] & {
|
472
|
+
[key: string]: any;
|
473
|
+
}) => Props[ComponentName];
|
474
|
+
} & {
|
475
|
+
root: (props: RootProps & {
|
476
|
+
[key: string]: any;
|
477
|
+
}) => RootProps;
|
478
|
+
}>;
|
479
|
+
declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
|
480
|
+
|
481
|
+
declare function resolveAllData<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, metadata?: Metadata, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Props, RootProps>>;
|
461
482
|
|
462
|
-
export { type
|
483
|
+
export { type DefaultComponentProps as $, type AppState as A, type BaseData as B, type Config as C, type DropZoneProps as D, type RadioField as E, type FieldProps as F, type ArrayField as G, type History as H, type IframeConfig as I, type ObjectField as J, type Adaptor as K, type ExternalFieldWithAdaptor as L, type Metadata as M, type NumberField as N, type OnAction as O, type Permissions as P, type ExternalField as Q, type RootDataWithProps as R, type SelectField as S, type TextField as T, type UserGenerics as U, type Viewports as V, type CustomField as W, type PuckContext as X, type DefaultRootFieldProps as Y, type DefaultRootRenderProps as Z, type DefaultRootProps as _, type Field as a, type WithId as a0, type WithPuckProps as a1, type AsFieldProps as a2, type WithChildren as a3, type ExtractPropsFromConfig as a4, type ExtractRootPropsFromConfig as a5, transformProps as a6, resolveAllData as a7, type Data as b, type UiState as c, type Plugin as d, type Overrides as e, type PuckAction as f, type InitialHistory as g, type ComponentData as h, type Fields as i, type ComponentConfig as j, type Direction as k, type DragAxis as l, type Viewport as m, type OverrideKey as n, overrideKeys as o, type FieldRenderFunctions as p, type ItemWithId as q, type ArrayState as r, type PuckComponent as s, type RootDataWithoutProps as t, type RootData as u, type MappedItem as v, type ComponentDataMap as w, type Content as x, type BaseField as y, type TextareaField as z };
|
@@ -22,17 +22,22 @@ type FieldOption = {
|
|
22
22
|
type FieldOptions = Array<FieldOption> | ReadonlyArray<FieldOption>;
|
23
23
|
type BaseField = {
|
24
24
|
label?: string;
|
25
|
+
labelIcon?: ReactElement;
|
25
26
|
};
|
26
27
|
type TextField = BaseField & {
|
27
28
|
type: "text";
|
29
|
+
placeholder?: string;
|
28
30
|
};
|
29
31
|
type NumberField = BaseField & {
|
30
32
|
type: "number";
|
33
|
+
placeholder?: string;
|
31
34
|
min?: number;
|
32
35
|
max?: number;
|
36
|
+
step?: number;
|
33
37
|
};
|
34
38
|
type TextareaField = BaseField & {
|
35
39
|
type: "textarea";
|
40
|
+
placeholder?: string;
|
36
41
|
};
|
37
42
|
type SelectField = BaseField & {
|
38
43
|
type: "select";
|
@@ -154,6 +159,7 @@ type ComponentConfig<RenderProps extends DefaultComponentProps = DefaultComponen
|
|
154
159
|
resolveData?: (data: DataShape, params: {
|
155
160
|
changed: Partial<Record<keyof FieldProps, boolean>>;
|
156
161
|
lastData: DataShape | null;
|
162
|
+
metadata: Metadata;
|
157
163
|
}) => Promise<{
|
158
164
|
props?: Partial<FieldProps>;
|
159
165
|
readOnly?: Partial<Record<keyof FieldProps, boolean>>;
|
@@ -209,6 +215,7 @@ type UserGenerics<UserConfig extends Config = Config, UserProps extends ExtractP
|
|
209
215
|
|
210
216
|
type PuckContext = {
|
211
217
|
renderDropZone: React.FC<DropZoneProps>;
|
218
|
+
metadata: Metadata;
|
212
219
|
isEditing: boolean;
|
213
220
|
dragRef: ((element: Element | null) => void) | null;
|
214
221
|
};
|
@@ -251,6 +258,9 @@ type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps
|
|
251
258
|
content: Content<Props>;
|
252
259
|
zones?: Record<string, Content<Props>>;
|
253
260
|
};
|
261
|
+
type Metadata = {
|
262
|
+
[key: string]: any;
|
263
|
+
};
|
254
264
|
|
255
265
|
type ItemWithId = {
|
256
266
|
_arrayId: string;
|
@@ -457,6 +467,17 @@ type PuckAction = {
|
|
457
467
|
recordHistory?: boolean;
|
458
468
|
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
459
469
|
|
460
|
-
|
470
|
+
type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
|
471
|
+
[ComponentName in keyof Props]: (props: Props[ComponentName] & {
|
472
|
+
[key: string]: any;
|
473
|
+
}) => Props[ComponentName];
|
474
|
+
} & {
|
475
|
+
root: (props: RootProps & {
|
476
|
+
[key: string]: any;
|
477
|
+
}) => RootProps;
|
478
|
+
}>;
|
479
|
+
declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
|
480
|
+
|
481
|
+
declare function resolveAllData<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, metadata?: Metadata, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Props, RootProps>>;
|
461
482
|
|
462
|
-
export { type
|
483
|
+
export { type DefaultComponentProps as $, type AppState as A, type BaseData as B, type Config as C, type DropZoneProps as D, type RadioField as E, type FieldProps as F, type ArrayField as G, type History as H, type IframeConfig as I, type ObjectField as J, type Adaptor as K, type ExternalFieldWithAdaptor as L, type Metadata as M, type NumberField as N, type OnAction as O, type Permissions as P, type ExternalField as Q, type RootDataWithProps as R, type SelectField as S, type TextField as T, type UserGenerics as U, type Viewports as V, type CustomField as W, type PuckContext as X, type DefaultRootFieldProps as Y, type DefaultRootRenderProps as Z, type DefaultRootProps as _, type Field as a, type WithId as a0, type WithPuckProps as a1, type AsFieldProps as a2, type WithChildren as a3, type ExtractPropsFromConfig as a4, type ExtractRootPropsFromConfig as a5, transformProps as a6, resolveAllData as a7, type Data as b, type UiState as c, type Plugin as d, type Overrides as e, type PuckAction as f, type InitialHistory as g, type ComponentData as h, type Fields as i, type ComponentConfig as j, type Direction as k, type DragAxis as l, type Viewport as m, type OverrideKey as n, overrideKeys as o, type FieldRenderFunctions as p, type ItemWithId as q, type ArrayState as r, type PuckComponent as s, type RootDataWithoutProps as t, type RootData as u, type MappedItem as v, type ComponentDataMap as w, type Content as x, type BaseField as y, type TextareaField as z };
|
package/dist/rsc.d.mts
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
2
|
-
import { C as Config, U as UserGenerics } from './resolve-all-data-
|
3
|
-
export {
|
2
|
+
import { C as Config, U as UserGenerics, M as Metadata } from './resolve-all-data-3XjIPfNh.mjs';
|
3
|
+
export { a7 as resolveAllData, a6 as transformProps } from './resolve-all-data-3XjIPfNh.mjs';
|
4
4
|
import 'react';
|
5
5
|
|
6
|
-
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data }: {
|
6
|
+
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
|
7
7
|
config: UserConfig;
|
8
8
|
data: G["UserData"];
|
9
|
+
metadata?: Metadata;
|
9
10
|
}): react_jsx_runtime.JSX.Element;
|
10
11
|
|
11
12
|
export { Render };
|
package/dist/rsc.d.ts
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
2
|
-
import { C as Config, U as UserGenerics } from './resolve-all-data-
|
3
|
-
export {
|
2
|
+
import { C as Config, U as UserGenerics, M as Metadata } from './resolve-all-data-3XjIPfNh.js';
|
3
|
+
export { a7 as resolveAllData, a6 as transformProps } from './resolve-all-data-3XjIPfNh.js';
|
4
4
|
import 'react';
|
5
5
|
|
6
|
-
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data }: {
|
6
|
+
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
|
7
7
|
config: UserConfig;
|
8
8
|
data: G["UserData"];
|
9
|
+
metadata?: Metadata;
|
9
10
|
}): react_jsx_runtime.JSX.Element;
|
10
11
|
|
11
12
|
export { Render };
|
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
|
|
@@ -76,7 +77,9 @@ module.exports = __toCommonJS(rsc_exports);
|
|
76
77
|
var import_react = __toESM(require("react"));
|
77
78
|
|
78
79
|
// lib/root-droppable-id.ts
|
79
|
-
var
|
80
|
+
var rootAreaId = "root";
|
81
|
+
var rootZone = "default-zone";
|
82
|
+
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
80
83
|
|
81
84
|
// lib/setup-zone.ts
|
82
85
|
var setupZone = (data, zoneKey) => {
|
@@ -96,14 +99,15 @@ function DropZoneRender({
|
|
96
99
|
zone,
|
97
100
|
data,
|
98
101
|
areaId = "root",
|
99
|
-
config
|
102
|
+
config,
|
103
|
+
metadata = {}
|
100
104
|
}) {
|
101
105
|
let zoneCompound = rootDroppableId;
|
102
106
|
let content = (data == null ? void 0 : data.content) || [];
|
103
107
|
if (!data || !config) {
|
104
108
|
return null;
|
105
109
|
}
|
106
|
-
if (areaId
|
110
|
+
if (areaId !== rootAreaId && zone !== rootZone) {
|
107
111
|
zoneCompound = `${areaId}:${zone}`;
|
108
112
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
109
113
|
}
|
@@ -120,9 +124,11 @@ function DropZoneRender({
|
|
120
124
|
zone: zone2,
|
121
125
|
data,
|
122
126
|
areaId: item.props.id,
|
123
|
-
config
|
127
|
+
config,
|
128
|
+
metadata
|
124
129
|
}
|
125
|
-
)
|
130
|
+
),
|
131
|
+
metadata
|
126
132
|
}
|
127
133
|
}),
|
128
134
|
item.props.id
|
@@ -131,7 +137,11 @@ function DropZoneRender({
|
|
131
137
|
return null;
|
132
138
|
}) });
|
133
139
|
}
|
134
|
-
function Render({
|
140
|
+
function Render({
|
141
|
+
config,
|
142
|
+
data,
|
143
|
+
metadata
|
144
|
+
}) {
|
135
145
|
var _a;
|
136
146
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
137
147
|
const rootProps = data.root.props || data.root;
|
@@ -140,18 +150,42 @@ function Render({ config, data }) {
|
|
140
150
|
config.root.render,
|
141
151
|
__spreadProps(__spreadValues({}, rootProps), {
|
142
152
|
puck: {
|
143
|
-
renderDropZone: ({ zone }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
153
|
+
renderDropZone: ({ zone }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
154
|
+
DropZoneRender,
|
155
|
+
{
|
156
|
+
zone,
|
157
|
+
data,
|
158
|
+
config,
|
159
|
+
metadata
|
160
|
+
}
|
161
|
+
),
|
144
162
|
isEditing: false,
|
145
163
|
dragRef: null
|
146
164
|
},
|
147
165
|
title,
|
148
166
|
editMode: false,
|
149
167
|
id: "puck-root",
|
150
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
168
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
169
|
+
DropZoneRender,
|
170
|
+
{
|
171
|
+
config,
|
172
|
+
data,
|
173
|
+
zone: rootZone,
|
174
|
+
metadata
|
175
|
+
}
|
176
|
+
)
|
151
177
|
})
|
152
178
|
);
|
153
179
|
}
|
154
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
180
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
181
|
+
DropZoneRender,
|
182
|
+
{
|
183
|
+
config,
|
184
|
+
data,
|
185
|
+
zone: rootZone,
|
186
|
+
metadata
|
187
|
+
}
|
188
|
+
);
|
155
189
|
}
|
156
190
|
|
157
191
|
// lib/get-changed.ts
|
@@ -167,19 +201,20 @@ var getChanged = (newItem, oldItem) => {
|
|
167
201
|
|
168
202
|
// lib/resolve-component-data.ts
|
169
203
|
var cache = { lastChange: {} };
|
170
|
-
var resolveAllComponentData = (
|
204
|
+
var resolveAllComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (content, config, metadata = {}, onResolveStart, onResolveEnd) {
|
171
205
|
return yield Promise.all(
|
172
206
|
content.map((item) => __async(void 0, null, function* () {
|
173
207
|
return yield resolveComponentData(
|
174
208
|
item,
|
175
209
|
config,
|
210
|
+
metadata,
|
176
211
|
onResolveStart,
|
177
212
|
onResolveEnd
|
178
213
|
);
|
179
214
|
}))
|
180
215
|
);
|
181
216
|
});
|
182
|
-
var resolveComponentData = (
|
217
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd) {
|
183
218
|
const configForItem = config.components[item.type];
|
184
219
|
if (configForItem.resolveData) {
|
185
220
|
const { item: oldItem = null, resolved = {} } = cache.lastChange[item.props.id] || {};
|
@@ -190,7 +225,11 @@ var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __asy
|
|
190
225
|
if (onResolveStart) {
|
191
226
|
onResolveStart(item);
|
192
227
|
}
|
193
|
-
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
228
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
229
|
+
changed,
|
230
|
+
lastData: oldItem,
|
231
|
+
metadata
|
232
|
+
});
|
194
233
|
const resolvedItem = __spreadProps(__spreadValues({}, item), {
|
195
234
|
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
196
235
|
});
|
@@ -211,7 +250,7 @@ var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __asy
|
|
211
250
|
|
212
251
|
// lib/resolve-root-data.ts
|
213
252
|
var cache2 = {};
|
214
|
-
function resolveRootData(data, config) {
|
253
|
+
function resolveRootData(data, config, metadata) {
|
215
254
|
return __async(this, null, function* () {
|
216
255
|
var _a, _b, _c, _d, _e;
|
217
256
|
if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
|
@@ -222,7 +261,8 @@ function resolveRootData(data, config) {
|
|
222
261
|
const rootWithProps = data.root;
|
223
262
|
const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
|
224
263
|
changed,
|
225
|
-
lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {}
|
264
|
+
lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {},
|
265
|
+
metadata: metadata || {}
|
226
266
|
});
|
227
267
|
cache2.lastChange = {
|
228
268
|
original: data.root,
|
@@ -243,10 +283,14 @@ var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
|
243
283
|
});
|
244
284
|
|
245
285
|
// lib/resolve-all-data.ts
|
246
|
-
function resolveAllData(
|
247
|
-
return __async(this,
|
286
|
+
function resolveAllData(_0, _1) {
|
287
|
+
return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
|
248
288
|
const defaultedData = defaultData(data);
|
249
|
-
const dynamicRoot = yield resolveRootData(
|
289
|
+
const dynamicRoot = yield resolveRootData(
|
290
|
+
defaultedData,
|
291
|
+
config,
|
292
|
+
metadata
|
293
|
+
);
|
250
294
|
const { zones = {} } = data;
|
251
295
|
const zoneKeys = Object.keys(zones);
|
252
296
|
const resolvedZones = {};
|
@@ -255,6 +299,7 @@ function resolveAllData(data, config, onResolveStart, onResolveEnd) {
|
|
255
299
|
resolvedZones[zoneKey] = yield resolveAllComponentData(
|
256
300
|
zones[zoneKey],
|
257
301
|
config,
|
302
|
+
metadata,
|
258
303
|
onResolveStart,
|
259
304
|
onResolveEnd
|
260
305
|
);
|
@@ -264,6 +309,7 @@ function resolveAllData(data, config, onResolveStart, onResolveEnd) {
|
|
264
309
|
content: yield resolveAllComponentData(
|
265
310
|
defaultedData.content,
|
266
311
|
config,
|
312
|
+
metadata,
|
267
313
|
onResolveStart,
|
268
314
|
onResolveEnd
|
269
315
|
),
|
@@ -271,8 +317,42 @@ function resolveAllData(data, config, onResolveStart, onResolveEnd) {
|
|
271
317
|
});
|
272
318
|
});
|
273
319
|
}
|
320
|
+
|
321
|
+
// lib/transform-props.ts
|
322
|
+
function transformProps(data, propTransforms) {
|
323
|
+
const mapItem = (item) => {
|
324
|
+
if (propTransforms[item.type]) {
|
325
|
+
return __spreadProps(__spreadValues({}, item), {
|
326
|
+
props: propTransforms[item.type](item.props)
|
327
|
+
});
|
328
|
+
}
|
329
|
+
return item;
|
330
|
+
};
|
331
|
+
const defaultedData = defaultData(data);
|
332
|
+
const rootProps = defaultedData.root.props || defaultedData.root;
|
333
|
+
let newRoot = __spreadValues({}, defaultedData.root);
|
334
|
+
if (propTransforms["root"]) {
|
335
|
+
if (defaultedData.root.props) {
|
336
|
+
newRoot.props = propTransforms["root"](rootProps);
|
337
|
+
} else {
|
338
|
+
newRoot = propTransforms["root"](rootProps);
|
339
|
+
}
|
340
|
+
}
|
341
|
+
const afterPropTransforms = __spreadProps(__spreadValues({}, defaultedData), {
|
342
|
+
root: newRoot,
|
343
|
+
content: defaultedData.content.map(mapItem),
|
344
|
+
zones: Object.keys(data.zones || {}).reduce(
|
345
|
+
(acc, zoneKey) => __spreadProps(__spreadValues({}, acc), {
|
346
|
+
[zoneKey]: data.zones[zoneKey].map(mapItem)
|
347
|
+
}),
|
348
|
+
{}
|
349
|
+
)
|
350
|
+
});
|
351
|
+
return afterPropTransforms;
|
352
|
+
}
|
274
353
|
// Annotate the CommonJS export names for ESM import in node:
|
275
354
|
0 && (module.exports = {
|
276
355
|
Render,
|
277
|
-
resolveAllData
|
356
|
+
resolveAllData,
|
357
|
+
transformProps
|
278
358
|
});
|
package/dist/rsc.mjs
CHANGED
@@ -3,9 +3,12 @@ import {
|
|
3
3
|
__spreadValues,
|
4
4
|
init_react_import,
|
5
5
|
resolveAllData,
|
6
|
+
rootAreaId,
|
6
7
|
rootDroppableId,
|
7
|
-
|
8
|
-
|
8
|
+
rootZone,
|
9
|
+
setupZone,
|
10
|
+
transformProps
|
11
|
+
} from "./chunk-7N5DRY4G.mjs";
|
9
12
|
|
10
13
|
// rsc.tsx
|
11
14
|
init_react_import();
|
@@ -17,14 +20,15 @@ function DropZoneRender({
|
|
17
20
|
zone,
|
18
21
|
data,
|
19
22
|
areaId = "root",
|
20
|
-
config
|
23
|
+
config,
|
24
|
+
metadata = {}
|
21
25
|
}) {
|
22
26
|
let zoneCompound = rootDroppableId;
|
23
27
|
let content = (data == null ? void 0 : data.content) || [];
|
24
28
|
if (!data || !config) {
|
25
29
|
return null;
|
26
30
|
}
|
27
|
-
if (areaId
|
31
|
+
if (areaId !== rootAreaId && zone !== rootZone) {
|
28
32
|
zoneCompound = `${areaId}:${zone}`;
|
29
33
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
30
34
|
}
|
@@ -41,9 +45,11 @@ function DropZoneRender({
|
|
41
45
|
zone: zone2,
|
42
46
|
data,
|
43
47
|
areaId: item.props.id,
|
44
|
-
config
|
48
|
+
config,
|
49
|
+
metadata
|
45
50
|
}
|
46
|
-
)
|
51
|
+
),
|
52
|
+
metadata
|
47
53
|
}
|
48
54
|
}),
|
49
55
|
item.props.id
|
@@ -52,7 +58,11 @@ function DropZoneRender({
|
|
52
58
|
return null;
|
53
59
|
}) });
|
54
60
|
}
|
55
|
-
function Render({
|
61
|
+
function Render({
|
62
|
+
config,
|
63
|
+
data,
|
64
|
+
metadata
|
65
|
+
}) {
|
56
66
|
var _a;
|
57
67
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
58
68
|
const rootProps = data.root.props || data.root;
|
@@ -61,20 +71,45 @@ function Render({ config, data }) {
|
|
61
71
|
config.root.render,
|
62
72
|
__spreadProps(__spreadValues({}, rootProps), {
|
63
73
|
puck: {
|
64
|
-
renderDropZone: ({ zone }) => /* @__PURE__ */ jsx(
|
74
|
+
renderDropZone: ({ zone }) => /* @__PURE__ */ jsx(
|
75
|
+
DropZoneRender,
|
76
|
+
{
|
77
|
+
zone,
|
78
|
+
data,
|
79
|
+
config,
|
80
|
+
metadata
|
81
|
+
}
|
82
|
+
),
|
65
83
|
isEditing: false,
|
66
84
|
dragRef: null
|
67
85
|
},
|
68
86
|
title,
|
69
87
|
editMode: false,
|
70
88
|
id: "puck-root",
|
71
|
-
children: /* @__PURE__ */ jsx(
|
89
|
+
children: /* @__PURE__ */ jsx(
|
90
|
+
DropZoneRender,
|
91
|
+
{
|
92
|
+
config,
|
93
|
+
data,
|
94
|
+
zone: rootZone,
|
95
|
+
metadata
|
96
|
+
}
|
97
|
+
)
|
72
98
|
})
|
73
99
|
);
|
74
100
|
}
|
75
|
-
return /* @__PURE__ */ jsx(
|
101
|
+
return /* @__PURE__ */ jsx(
|
102
|
+
DropZoneRender,
|
103
|
+
{
|
104
|
+
config,
|
105
|
+
data,
|
106
|
+
zone: rootZone,
|
107
|
+
metadata
|
108
|
+
}
|
109
|
+
);
|
76
110
|
}
|
77
111
|
export {
|
78
112
|
Render,
|
79
|
-
resolveAllData
|
113
|
+
resolveAllData,
|
114
|
+
transformProps
|
80
115
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@measured/puck",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.19.0-canary.020071e",
|
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
|
"*": {
|
@@ -71,11 +72,12 @@
|
|
71
72
|
"@dnd-kit/helpers": "0.0.7-beta-20250130032138",
|
72
73
|
"@dnd-kit/react": "0.0.7-beta-20250130032138",
|
73
74
|
"deep-diff": "^1.0.2",
|
75
|
+
"fast-deep-equal": "^3.1.3",
|
74
76
|
"object-hash": "^3.0.0",
|
75
77
|
"react-hotkeys-hook": "^4.6.1",
|
76
78
|
"use-debounce": "^9.0.4",
|
77
79
|
"uuid": "^9.0.1",
|
78
|
-
"zustand": "^5.
|
80
|
+
"zustand": "^4.5.6"
|
79
81
|
},
|
80
82
|
"peerDependencies": {
|
81
83
|
"react": "^17.0.0 || ^18.0.0 || ^19.0.0"
|