@measured/puck 0.18.3-canary.154e7f7 → 0.19.0-canary.32a6f78
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-FNRHXUGA.mjs} +20 -8
- package/dist/index.d.mts +7 -5
- package/dist/index.d.ts +7 -5
- package/dist/index.js +52 -24
- package/dist/index.mjs +33 -17
- package/dist/{resolve-all-data-ppm982Jh.d.mts → resolve-all-data-D43Z4niC.d.mts} +10 -2
- package/dist/{resolve-all-data-ppm982Jh.d.ts → resolve-all-data-D43Z4niC.d.ts} +10 -2
- package/dist/rsc.d.mts +4 -3
- package/dist/rsc.d.ts +4 -3
- package/dist/rsc.js +58 -15
- package/dist/rsc.mjs +39 -8
- package/package.json +1 -1
@@ -111,19 +111,20 @@ var getChanged = (newItem, oldItem) => {
|
|
111
111
|
|
112
112
|
// lib/resolve-component-data.ts
|
113
113
|
var cache = { lastChange: {} };
|
114
|
-
var resolveAllComponentData = (
|
114
|
+
var resolveAllComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (content, config, metadata = {}, onResolveStart, onResolveEnd) {
|
115
115
|
return yield Promise.all(
|
116
116
|
content.map((item) => __async(void 0, null, function* () {
|
117
117
|
return yield resolveComponentData(
|
118
118
|
item,
|
119
119
|
config,
|
120
|
+
metadata,
|
120
121
|
onResolveStart,
|
121
122
|
onResolveEnd
|
122
123
|
);
|
123
124
|
}))
|
124
125
|
);
|
125
126
|
});
|
126
|
-
var resolveComponentData = (
|
127
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd) {
|
127
128
|
const configForItem = config.components[item.type];
|
128
129
|
if (configForItem.resolveData) {
|
129
130
|
const { item: oldItem = null, resolved = {} } = cache.lastChange[item.props.id] || {};
|
@@ -134,7 +135,11 @@ var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __asy
|
|
134
135
|
if (onResolveStart) {
|
135
136
|
onResolveStart(item);
|
136
137
|
}
|
137
|
-
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
138
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
139
|
+
changed,
|
140
|
+
lastData: oldItem,
|
141
|
+
metadata
|
142
|
+
});
|
138
143
|
const resolvedItem = __spreadProps(__spreadValues({}, item), {
|
139
144
|
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
140
145
|
});
|
@@ -156,7 +161,7 @@ var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __asy
|
|
156
161
|
// lib/resolve-root-data.ts
|
157
162
|
init_react_import();
|
158
163
|
var cache2 = {};
|
159
|
-
function resolveRootData(data, config) {
|
164
|
+
function resolveRootData(data, config, metadata) {
|
160
165
|
return __async(this, null, function* () {
|
161
166
|
var _a, _b, _c, _d, _e;
|
162
167
|
if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
|
@@ -167,7 +172,8 @@ function resolveRootData(data, config) {
|
|
167
172
|
const rootWithProps = data.root;
|
168
173
|
const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
|
169
174
|
changed,
|
170
|
-
lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {}
|
175
|
+
lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {},
|
176
|
+
metadata: metadata || {}
|
171
177
|
});
|
172
178
|
cache2.lastChange = {
|
173
179
|
original: data.root,
|
@@ -189,10 +195,14 @@ var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
|
189
195
|
});
|
190
196
|
|
191
197
|
// lib/resolve-all-data.ts
|
192
|
-
function resolveAllData(
|
193
|
-
return __async(this,
|
198
|
+
function resolveAllData(_0, _1) {
|
199
|
+
return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
|
194
200
|
const defaultedData = defaultData(data);
|
195
|
-
const dynamicRoot = yield resolveRootData(
|
201
|
+
const dynamicRoot = yield resolveRootData(
|
202
|
+
defaultedData,
|
203
|
+
config,
|
204
|
+
metadata
|
205
|
+
);
|
196
206
|
const { zones = {} } = data;
|
197
207
|
const zoneKeys = Object.keys(zones);
|
198
208
|
const resolvedZones = {};
|
@@ -201,6 +211,7 @@ function resolveAllData(data, config, onResolveStart, onResolveEnd) {
|
|
201
211
|
resolvedZones[zoneKey] = yield resolveAllComponentData(
|
202
212
|
zones[zoneKey],
|
203
213
|
config,
|
214
|
+
metadata,
|
204
215
|
onResolveStart,
|
205
216
|
onResolveEnd
|
206
217
|
);
|
@@ -210,6 +221,7 @@ function resolveAllData(data, config, onResolveStart, onResolveEnd) {
|
|
210
221
|
content: yield resolveAllComponentData(
|
211
222
|
defaultedData.content,
|
212
223
|
config,
|
224
|
+
metadata,
|
213
225
|
onResolveStart,
|
214
226
|
onResolveEnd
|
215
227
|
),
|
package/dist/index.d.mts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { F as FieldProps, a as Field, D as DropZoneProps, C as Config, U as UserGenerics, b as Data, c as UiState, O as OnAction, P as Permissions, d as Plugin, e as Overrides, f as PuckAction, V as Viewports, I as IframeConfig, g as InitialHistory, h as DefaultComponentProps, i as DefaultRootFieldProps, H as History, A as AppState, E as ExtractPropsFromConfig, j as ExtractRootPropsFromConfig, k as ComponentDataMap } from './resolve-all-data-
|
2
|
-
export {
|
1
|
+
import { F as FieldProps, a as Field, D as DropZoneProps, C as Config, U as UserGenerics, b as Data, c as UiState, O as OnAction, P as Permissions, d as Plugin, e as Overrides, f as PuckAction, V as Viewports, I as IframeConfig, g as InitialHistory, M as Metadata, h as DefaultComponentProps, i as DefaultRootFieldProps, H as History, A as AppState, E as ExtractPropsFromConfig, j as ExtractRootPropsFromConfig, k as ComponentDataMap } from './resolve-all-data-D43Z4niC.mjs';
|
2
|
+
export { W as Adaptor, L as ArrayField, s as ArrayState, a4 as AsFieldProps, B as BaseData, G as BaseField, u as ComponentConfig, x as ComponentData, z as Content, Z as CustomField, a1 as DefaultRootProps, a0 as DefaultRootRenderProps, l as Direction, m as DragAxis, Y as ExternalField, X as ExternalFieldWithAdaptor, q as FieldRenderFunctions, _ as Fields, r as ItemWithId, y as MappedItem, N as NumberField, Q as ObjectField, p as OverrideKey, t as PuckComponent, $ as PuckContext, K as RadioField, w as RootData, R as RootDataWithProps, v as RootDataWithoutProps, S as SelectField, T as TextField, J as TextareaField, n as Viewport, a5 as WithChildren, a2 as WithId, a3 as WithPuckProps, o as overrideKeys, a6 as resolveAllData } from './resolve-all-data-D43Z4niC.mjs';
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
4
4
|
import * as react from 'react';
|
5
5
|
import { ReactNode, SyntheticEvent, ReactElement } from 'react';
|
@@ -93,7 +93,7 @@ declare const IconButton: ({ children, href, onClick, variant, type, disabled, t
|
|
93
93
|
title: string;
|
94
94
|
}) => react_jsx_runtime.JSX.Element;
|
95
95
|
|
96
|
-
declare function Puck<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, onAction, permissions, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe: _iframe, dnd, initialHistory: _initialHistory, }: {
|
96
|
+
declare function Puck<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, onAction, permissions, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe: _iframe, dnd, initialHistory: _initialHistory, metadata, }: {
|
97
97
|
children?: ReactNode;
|
98
98
|
config: UserConfig;
|
99
99
|
data: Partial<G["UserData"] | Data>;
|
@@ -121,6 +121,7 @@ declare function Puck<UserConfig extends Config = Config, G extends UserGenerics
|
|
121
121
|
disableAutoScroll?: boolean;
|
122
122
|
};
|
123
123
|
initialHistory?: InitialHistory;
|
124
|
+
metadata?: Metadata;
|
124
125
|
}): react_jsx_runtime.JSX.Element;
|
125
126
|
declare namespace Puck {
|
126
127
|
var Components: () => react_jsx_runtime.JSX.Element;
|
@@ -133,9 +134,10 @@ declare namespace Puck {
|
|
133
134
|
}) => react_jsx_runtime.JSX.Element;
|
134
135
|
}
|
135
136
|
|
136
|
-
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, }: {
|
137
|
+
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
|
137
138
|
config: UserConfig;
|
138
139
|
data: Partial<G["UserData"] | Data>;
|
140
|
+
metadata?: Metadata;
|
139
141
|
}): react_jsx_runtime.JSX.Element;
|
140
142
|
|
141
143
|
declare function migrate(data: Data): Data;
|
@@ -194,4 +196,4 @@ declare const usePuck: <UserConfig extends Config = Config>() => {
|
|
194
196
|
selectedItem: ComponentDataMap<ExtractPropsFromConfig<UserConfig>> | null;
|
195
197
|
};
|
196
198
|
|
197
|
-
export { Action, ActionBar, AppState, AutoField, Button, ComponentDataMap, Config, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, DropZone, ExtractPropsFromConfig, ExtractRootPropsFromConfig, Field, FieldLabel, FieldProps, Group, History, IconButton, IframeConfig, InitialHistory, Label, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, Render, UiState, UserGenerics, Viewports, migrate, transformProps, usePuck };
|
199
|
+
export { Action, ActionBar, AppState, AutoField, Button, ComponentDataMap, Config, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, DropZone, ExtractPropsFromConfig, ExtractRootPropsFromConfig, Field, FieldLabel, FieldProps, Group, History, IconButton, IframeConfig, InitialHistory, Label, Metadata, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, Render, UiState, UserGenerics, Viewports, migrate, transformProps, usePuck };
|
package/dist/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { F as FieldProps, a as Field, D as DropZoneProps, C as Config, U as UserGenerics, b as Data, c as UiState, O as OnAction, P as Permissions, d as Plugin, e as Overrides, f as PuckAction, V as Viewports, I as IframeConfig, g as InitialHistory, h as DefaultComponentProps, i as DefaultRootFieldProps, H as History, A as AppState, E as ExtractPropsFromConfig, j as ExtractRootPropsFromConfig, k as ComponentDataMap } from './resolve-all-data-
|
2
|
-
export {
|
1
|
+
import { F as FieldProps, a as Field, D as DropZoneProps, C as Config, U as UserGenerics, b as Data, c as UiState, O as OnAction, P as Permissions, d as Plugin, e as Overrides, f as PuckAction, V as Viewports, I as IframeConfig, g as InitialHistory, M as Metadata, h as DefaultComponentProps, i as DefaultRootFieldProps, H as History, A as AppState, E as ExtractPropsFromConfig, j as ExtractRootPropsFromConfig, k as ComponentDataMap } from './resolve-all-data-D43Z4niC.js';
|
2
|
+
export { W as Adaptor, L as ArrayField, s as ArrayState, a4 as AsFieldProps, B as BaseData, G as BaseField, u as ComponentConfig, x as ComponentData, z as Content, Z as CustomField, a1 as DefaultRootProps, a0 as DefaultRootRenderProps, l as Direction, m as DragAxis, Y as ExternalField, X as ExternalFieldWithAdaptor, q as FieldRenderFunctions, _ as Fields, r as ItemWithId, y as MappedItem, N as NumberField, Q as ObjectField, p as OverrideKey, t as PuckComponent, $ as PuckContext, K as RadioField, w as RootData, R as RootDataWithProps, v as RootDataWithoutProps, S as SelectField, T as TextField, J as TextareaField, n as Viewport, a5 as WithChildren, a2 as WithId, a3 as WithPuckProps, o as overrideKeys, a6 as resolveAllData } from './resolve-all-data-D43Z4niC.js';
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
4
4
|
import * as react from 'react';
|
5
5
|
import { ReactNode, SyntheticEvent, ReactElement } from 'react';
|
@@ -93,7 +93,7 @@ declare const IconButton: ({ children, href, onClick, variant, type, disabled, t
|
|
93
93
|
title: string;
|
94
94
|
}) => react_jsx_runtime.JSX.Element;
|
95
95
|
|
96
|
-
declare function Puck<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, onAction, permissions, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe: _iframe, dnd, initialHistory: _initialHistory, }: {
|
96
|
+
declare function Puck<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, onAction, permissions, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe: _iframe, dnd, initialHistory: _initialHistory, metadata, }: {
|
97
97
|
children?: ReactNode;
|
98
98
|
config: UserConfig;
|
99
99
|
data: Partial<G["UserData"] | Data>;
|
@@ -121,6 +121,7 @@ declare function Puck<UserConfig extends Config = Config, G extends UserGenerics
|
|
121
121
|
disableAutoScroll?: boolean;
|
122
122
|
};
|
123
123
|
initialHistory?: InitialHistory;
|
124
|
+
metadata?: Metadata;
|
124
125
|
}): react_jsx_runtime.JSX.Element;
|
125
126
|
declare namespace Puck {
|
126
127
|
var Components: () => react_jsx_runtime.JSX.Element;
|
@@ -133,9 +134,10 @@ declare namespace Puck {
|
|
133
134
|
}) => react_jsx_runtime.JSX.Element;
|
134
135
|
}
|
135
136
|
|
136
|
-
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, }: {
|
137
|
+
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
|
137
138
|
config: UserConfig;
|
138
139
|
data: Partial<G["UserData"] | Data>;
|
140
|
+
metadata?: Metadata;
|
139
141
|
}): react_jsx_runtime.JSX.Element;
|
140
142
|
|
141
143
|
declare function migrate(data: Data): Data;
|
@@ -194,4 +196,4 @@ declare const usePuck: <UserConfig extends Config = Config>() => {
|
|
194
196
|
selectedItem: ComponentDataMap<ExtractPropsFromConfig<UserConfig>> | null;
|
195
197
|
};
|
196
198
|
|
197
|
-
export { Action, ActionBar, AppState, AutoField, Button, ComponentDataMap, Config, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, DropZone, ExtractPropsFromConfig, ExtractRootPropsFromConfig, Field, FieldLabel, FieldProps, Group, History, IconButton, IframeConfig, InitialHistory, Label, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, Render, UiState, UserGenerics, Viewports, migrate, transformProps, usePuck };
|
199
|
+
export { Action, ActionBar, AppState, AutoField, Button, ComponentDataMap, Config, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, DropZone, ExtractPropsFromConfig, ExtractRootPropsFromConfig, Field, FieldLabel, FieldProps, Group, History, IconButton, IframeConfig, InitialHistory, Label, Metadata, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, Render, UiState, UserGenerics, Viewports, migrate, transformProps, usePuck };
|
package/dist/index.js
CHANGED
@@ -962,19 +962,20 @@ var import_react6 = require("react");
|
|
962
962
|
// lib/resolve-component-data.ts
|
963
963
|
init_react_import();
|
964
964
|
var cache = { lastChange: {} };
|
965
|
-
var resolveAllComponentData = (
|
965
|
+
var resolveAllComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (content, config, metadata = {}, onResolveStart, onResolveEnd) {
|
966
966
|
return yield Promise.all(
|
967
967
|
content.map((item) => __async(void 0, null, function* () {
|
968
968
|
return yield resolveComponentData(
|
969
969
|
item,
|
970
970
|
config,
|
971
|
+
metadata,
|
971
972
|
onResolveStart,
|
972
973
|
onResolveEnd
|
973
974
|
);
|
974
975
|
}))
|
975
976
|
);
|
976
977
|
});
|
977
|
-
var resolveComponentData = (
|
978
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd) {
|
978
979
|
const configForItem = config.components[item.type];
|
979
980
|
if (configForItem.resolveData) {
|
980
981
|
const { item: oldItem = null, resolved = {} } = cache.lastChange[item.props.id] || {};
|
@@ -985,7 +986,11 @@ var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __asy
|
|
985
986
|
if (onResolveStart) {
|
986
987
|
onResolveStart(item);
|
987
988
|
}
|
988
|
-
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
989
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
990
|
+
changed,
|
991
|
+
lastData: oldItem,
|
992
|
+
metadata
|
993
|
+
});
|
989
994
|
const resolvedItem = __spreadProps(__spreadValues({}, item), {
|
990
995
|
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
991
996
|
});
|
@@ -1025,7 +1030,7 @@ var applyDynamicProps = (data, dynamicProps, rootData) => {
|
|
1025
1030
|
// lib/resolve-root-data.ts
|
1026
1031
|
init_react_import();
|
1027
1032
|
var cache2 = {};
|
1028
|
-
function resolveRootData(data, config) {
|
1033
|
+
function resolveRootData(data, config, metadata) {
|
1029
1034
|
return __async(this, null, function* () {
|
1030
1035
|
var _a, _b, _c, _d, _e;
|
1031
1036
|
if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
|
@@ -1036,7 +1041,8 @@ function resolveRootData(data, config) {
|
|
1036
1041
|
const rootWithProps = data.root;
|
1037
1042
|
const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
|
1038
1043
|
changed,
|
1039
|
-
lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {}
|
1044
|
+
lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {},
|
1045
|
+
metadata: metadata || {}
|
1040
1046
|
});
|
1041
1047
|
cache2.lastChange = {
|
1042
1048
|
original: data.root,
|
@@ -1051,7 +1057,7 @@ function resolveRootData(data, config) {
|
|
1051
1057
|
}
|
1052
1058
|
|
1053
1059
|
// lib/use-resolved-data.ts
|
1054
|
-
var useResolvedData = (appState, config, dispatch, setComponentLoading, unsetComponentLoading, refreshPermissions) => {
|
1060
|
+
var useResolvedData = (appState, config, dispatch, setComponentLoading, unsetComponentLoading, refreshPermissions, metadata) => {
|
1055
1061
|
const [{ resolverKey, newAppState }, setResolverState] = (0, import_react6.useState)({
|
1056
1062
|
resolverKey: 0,
|
1057
1063
|
newAppState: appState
|
@@ -1105,7 +1111,7 @@ var useResolvedData = (appState, config, dispatch, setComponentLoading, unsetCom
|
|
1105
1111
|
promises.push(
|
1106
1112
|
(() => __async(void 0, null, function* () {
|
1107
1113
|
_setComponentLoading("puck-root", true, 50);
|
1108
|
-
const dynamicRoot = yield resolveRootData(newData, config);
|
1114
|
+
const dynamicRoot = yield resolveRootData(newData, config, metadata);
|
1109
1115
|
applyIfChange({}, dynamicRoot);
|
1110
1116
|
_setComponentLoading("puck-root", false);
|
1111
1117
|
}))()
|
@@ -1117,6 +1123,7 @@ var useResolvedData = (appState, config, dispatch, setComponentLoading, unsetCom
|
|
1117
1123
|
const dynamicData = yield resolveComponentData(
|
1118
1124
|
item,
|
1119
1125
|
config,
|
1126
|
+
metadata,
|
1120
1127
|
(item2) => {
|
1121
1128
|
_setComponentLoading(item2.props.id, true, 50);
|
1122
1129
|
},
|
@@ -1193,7 +1200,8 @@ var defaultContext = {
|
|
1193
1200
|
iframe: {},
|
1194
1201
|
globalPermissions: {},
|
1195
1202
|
getPermissions: () => ({}),
|
1196
|
-
refreshPermissions: () => null
|
1203
|
+
refreshPermissions: () => null,
|
1204
|
+
metadata: {}
|
1197
1205
|
};
|
1198
1206
|
var appContext = (0, import_react7.createContext)(defaultContext);
|
1199
1207
|
var AppProvider = ({
|
@@ -1240,7 +1248,8 @@ var AppProvider = ({
|
|
1240
1248
|
value.dispatch,
|
1241
1249
|
setComponentLoading,
|
1242
1250
|
unsetComponentLoading,
|
1243
|
-
refreshPermissions
|
1251
|
+
refreshPermissions,
|
1252
|
+
value.metadata
|
1244
1253
|
);
|
1245
1254
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
1246
1255
|
appContext.Provider,
|
@@ -2409,7 +2418,8 @@ var DefaultField = ({
|
|
2409
2418
|
tabIndex: readOnly ? -1 : void 0,
|
2410
2419
|
id,
|
2411
2420
|
min: field.type === "number" ? field.min : void 0,
|
2412
|
-
max: field.type === "number" ? field.max : void 0
|
2421
|
+
max: field.type === "number" ? field.max : void 0,
|
2422
|
+
placeholder: field.type === "text" || field.type === "number" ? field.placeholder : void 0
|
2413
2423
|
}
|
2414
2424
|
)
|
2415
2425
|
}
|
@@ -2985,6 +2995,7 @@ init_react_import();
|
|
2985
2995
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
2986
2996
|
var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
|
2987
2997
|
var TextareaField = ({
|
2998
|
+
field,
|
2988
2999
|
onChange,
|
2989
3000
|
readOnly,
|
2990
3001
|
value,
|
@@ -3004,7 +3015,8 @@ var TextareaField = ({
|
|
3004
3015
|
onChange: (e) => onChange(e.currentTarget.value),
|
3005
3016
|
readOnly,
|
3006
3017
|
tabIndex: readOnly ? -1 : void 0,
|
3007
|
-
rows: 5
|
3018
|
+
rows: 5,
|
3019
|
+
placeholder: field.type === "textarea" ? field.placeholder : void 0
|
3008
3020
|
}
|
3009
3021
|
) });
|
3010
3022
|
};
|
@@ -4188,6 +4200,7 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
|
|
4188
4200
|
const componentId = item.props.id;
|
4189
4201
|
const puckProps = {
|
4190
4202
|
renderDropZone: DropZoneEditPure,
|
4203
|
+
metadata: appContext2.metadata,
|
4191
4204
|
isEditing: true,
|
4192
4205
|
dragRef: null
|
4193
4206
|
};
|
@@ -4285,13 +4298,15 @@ var DropZoneRender = (0, import_react30.forwardRef)(
|
|
4285
4298
|
config,
|
4286
4299
|
areaId: item.props.id,
|
4287
4300
|
depth: 1,
|
4288
|
-
path: []
|
4301
|
+
path: [],
|
4302
|
+
metadata: (ctx == null ? void 0 : ctx.metadata) || {}
|
4289
4303
|
},
|
4290
4304
|
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
4291
4305
|
Component.render,
|
4292
4306
|
__spreadProps(__spreadValues({}, item.props), {
|
4293
4307
|
puck: {
|
4294
|
-
renderDropZone: DropZoneRenderPure
|
4308
|
+
renderDropZone: DropZoneRenderPure,
|
4309
|
+
metadata: (ctx == null ? void 0 : ctx.metadata) || {}
|
4295
4310
|
}
|
4296
4311
|
})
|
4297
4312
|
)
|
@@ -5033,7 +5048,7 @@ var DragDropContextClient = ({
|
|
5033
5048
|
children,
|
5034
5049
|
disableAutoScroll
|
5035
5050
|
}) => {
|
5036
|
-
const { state, config, dispatch, resolveData } = useAppContext();
|
5051
|
+
const { state, config, dispatch, resolveData, metadata } = useAppContext();
|
5037
5052
|
const id = (0, import_react32.useId)();
|
5038
5053
|
const { data } = state;
|
5039
5054
|
const debouncedParamsRef = (0, import_react32.useRef)(null);
|
@@ -5392,7 +5407,8 @@ var DragDropContextClient = ({
|
|
5392
5407
|
registerPath,
|
5393
5408
|
unregisterPath,
|
5394
5409
|
pathData,
|
5395
|
-
path: []
|
5410
|
+
path: [],
|
5411
|
+
metadata
|
5396
5412
|
},
|
5397
5413
|
children
|
5398
5414
|
}
|
@@ -6467,7 +6483,8 @@ init_react_import();
|
|
6467
6483
|
var import_jsx_runtime32 = require("react/jsx-runtime");
|
6468
6484
|
function Render({
|
6469
6485
|
config,
|
6470
|
-
data
|
6486
|
+
data,
|
6487
|
+
metadata = {}
|
6471
6488
|
}) {
|
6472
6489
|
var _a;
|
6473
6490
|
const defaultedData = __spreadProps(__spreadValues({}, data), {
|
@@ -6485,7 +6502,8 @@ function Render({
|
|
6485
6502
|
config,
|
6486
6503
|
mode: "render",
|
6487
6504
|
depth: 0,
|
6488
|
-
path: []
|
6505
|
+
path: [],
|
6506
|
+
metadata
|
6489
6507
|
},
|
6490
6508
|
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
6491
6509
|
config.root.render,
|
@@ -6512,7 +6530,8 @@ function Render({
|
|
6512
6530
|
config,
|
6513
6531
|
mode: "render",
|
6514
6532
|
depth: 0,
|
6515
|
-
path: []
|
6533
|
+
path: [],
|
6534
|
+
metadata
|
6516
6535
|
},
|
6517
6536
|
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZonePure, { zone: rootDroppableId })
|
6518
6537
|
}
|
@@ -6576,7 +6595,8 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6576
6595
|
puck: {
|
6577
6596
|
renderDropZone: DropZonePure,
|
6578
6597
|
isEditing: true,
|
6579
|
-
dragRef: null
|
6598
|
+
dragRef: null,
|
6599
|
+
metadata: {}
|
6580
6600
|
},
|
6581
6601
|
editMode: true,
|
6582
6602
|
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZonePure, { zone: rootDroppableId })
|
@@ -7571,7 +7591,8 @@ function Puck({
|
|
7571
7591
|
viewports = defaultViewports,
|
7572
7592
|
iframe: _iframe,
|
7573
7593
|
dnd,
|
7574
|
-
initialHistory: _initialHistory
|
7594
|
+
initialHistory: _initialHistory,
|
7595
|
+
metadata
|
7575
7596
|
}) {
|
7576
7597
|
var _a, _b;
|
7577
7598
|
const iframe = __spreadValues({
|
@@ -7784,7 +7805,8 @@ function Puck({
|
|
7784
7805
|
edit: true
|
7785
7806
|
}, permissions),
|
7786
7807
|
getPermissions: () => ({}),
|
7787
|
-
refreshPermissions: () => null
|
7808
|
+
refreshPermissions: () => null,
|
7809
|
+
metadata: metadata || {}
|
7788
7810
|
},
|
7789
7811
|
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
7790
7812
|
"div",
|
@@ -7988,10 +8010,14 @@ function transformProps(data, propTransforms) {
|
|
7988
8010
|
|
7989
8011
|
// lib/resolve-all-data.ts
|
7990
8012
|
init_react_import();
|
7991
|
-
function resolveAllData(
|
7992
|
-
return __async(this,
|
8013
|
+
function resolveAllData(_0, _1) {
|
8014
|
+
return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
|
7993
8015
|
const defaultedData = defaultData(data);
|
7994
|
-
const dynamicRoot = yield resolveRootData(
|
8016
|
+
const dynamicRoot = yield resolveRootData(
|
8017
|
+
defaultedData,
|
8018
|
+
config,
|
8019
|
+
metadata
|
8020
|
+
);
|
7995
8021
|
const { zones = {} } = data;
|
7996
8022
|
const zoneKeys = Object.keys(zones);
|
7997
8023
|
const resolvedZones = {};
|
@@ -8000,6 +8026,7 @@ function resolveAllData(data, config, onResolveStart, onResolveEnd) {
|
|
8000
8026
|
resolvedZones[zoneKey] = yield resolveAllComponentData(
|
8001
8027
|
zones[zoneKey],
|
8002
8028
|
config,
|
8029
|
+
metadata,
|
8003
8030
|
onResolveStart,
|
8004
8031
|
onResolveEnd
|
8005
8032
|
);
|
@@ -8009,6 +8036,7 @@ function resolveAllData(data, config, onResolveStart, onResolveEnd) {
|
|
8009
8036
|
content: yield resolveAllComponentData(
|
8010
8037
|
defaultedData.content,
|
8011
8038
|
config,
|
8039
|
+
metadata,
|
8012
8040
|
onResolveStart,
|
8013
8041
|
onResolveEnd
|
8014
8042
|
),
|
package/dist/index.mjs
CHANGED
@@ -16,7 +16,7 @@ import {
|
|
16
16
|
resolveRootData,
|
17
17
|
rootDroppableId,
|
18
18
|
setupZone
|
19
|
-
} from "./chunk-
|
19
|
+
} from "./chunk-FNRHXUGA.mjs";
|
20
20
|
|
21
21
|
// ../../node_modules/classnames/index.js
|
22
22
|
var require_classnames = __commonJS({
|
@@ -857,7 +857,7 @@ var applyDynamicProps = (data, dynamicProps, rootData) => {
|
|
857
857
|
};
|
858
858
|
|
859
859
|
// lib/use-resolved-data.ts
|
860
|
-
var useResolvedData = (appState, config, dispatch, setComponentLoading, unsetComponentLoading, refreshPermissions) => {
|
860
|
+
var useResolvedData = (appState, config, dispatch, setComponentLoading, unsetComponentLoading, refreshPermissions, metadata) => {
|
861
861
|
const [{ resolverKey, newAppState }, setResolverState] = useState3({
|
862
862
|
resolverKey: 0,
|
863
863
|
newAppState: appState
|
@@ -911,7 +911,7 @@ var useResolvedData = (appState, config, dispatch, setComponentLoading, unsetCom
|
|
911
911
|
promises.push(
|
912
912
|
(() => __async(void 0, null, function* () {
|
913
913
|
_setComponentLoading("puck-root", true, 50);
|
914
|
-
const dynamicRoot = yield resolveRootData(newData, config);
|
914
|
+
const dynamicRoot = yield resolveRootData(newData, config, metadata);
|
915
915
|
applyIfChange({}, dynamicRoot);
|
916
916
|
_setComponentLoading("puck-root", false);
|
917
917
|
}))()
|
@@ -923,6 +923,7 @@ var useResolvedData = (appState, config, dispatch, setComponentLoading, unsetCom
|
|
923
923
|
const dynamicData = yield resolveComponentData(
|
924
924
|
item,
|
925
925
|
config,
|
926
|
+
metadata,
|
926
927
|
(item2) => {
|
927
928
|
_setComponentLoading(item2.props.id, true, 50);
|
928
929
|
},
|
@@ -999,7 +1000,8 @@ var defaultContext = {
|
|
999
1000
|
iframe: {},
|
1000
1001
|
globalPermissions: {},
|
1001
1002
|
getPermissions: () => ({}),
|
1002
|
-
refreshPermissions: () => null
|
1003
|
+
refreshPermissions: () => null,
|
1004
|
+
metadata: {}
|
1003
1005
|
};
|
1004
1006
|
var appContext = createContext(defaultContext);
|
1005
1007
|
var AppProvider = ({
|
@@ -1046,7 +1048,8 @@ var AppProvider = ({
|
|
1046
1048
|
value.dispatch,
|
1047
1049
|
setComponentLoading,
|
1048
1050
|
unsetComponentLoading,
|
1049
|
-
refreshPermissions
|
1051
|
+
refreshPermissions,
|
1052
|
+
value.metadata
|
1050
1053
|
);
|
1051
1054
|
return /* @__PURE__ */ jsx5(
|
1052
1055
|
appContext.Provider,
|
@@ -2230,7 +2233,8 @@ var DefaultField = ({
|
|
2230
2233
|
tabIndex: readOnly ? -1 : void 0,
|
2231
2234
|
id,
|
2232
2235
|
min: field.type === "number" ? field.min : void 0,
|
2233
|
-
max: field.type === "number" ? field.max : void 0
|
2236
|
+
max: field.type === "number" ? field.max : void 0,
|
2237
|
+
placeholder: field.type === "text" || field.type === "number" ? field.placeholder : void 0
|
2234
2238
|
}
|
2235
2239
|
)
|
2236
2240
|
}
|
@@ -2812,6 +2816,7 @@ init_react_import();
|
|
2812
2816
|
import { jsx as jsx17 } from "react/jsx-runtime";
|
2813
2817
|
var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
|
2814
2818
|
var TextareaField = ({
|
2819
|
+
field,
|
2815
2820
|
onChange,
|
2816
2821
|
readOnly,
|
2817
2822
|
value,
|
@@ -2831,7 +2836,8 @@ var TextareaField = ({
|
|
2831
2836
|
onChange: (e) => onChange(e.currentTarget.value),
|
2832
2837
|
readOnly,
|
2833
2838
|
tabIndex: readOnly ? -1 : void 0,
|
2834
|
-
rows: 5
|
2839
|
+
rows: 5,
|
2840
|
+
placeholder: field.type === "textarea" ? field.placeholder : void 0
|
2835
2841
|
}
|
2836
2842
|
) });
|
2837
2843
|
};
|
@@ -4042,6 +4048,7 @@ var DropZoneEdit = forwardRef3(
|
|
4042
4048
|
const componentId = item.props.id;
|
4043
4049
|
const puckProps = {
|
4044
4050
|
renderDropZone: DropZoneEditPure,
|
4051
|
+
metadata: appContext2.metadata,
|
4045
4052
|
isEditing: true,
|
4046
4053
|
dragRef: null
|
4047
4054
|
};
|
@@ -4139,13 +4146,15 @@ var DropZoneRender = forwardRef3(
|
|
4139
4146
|
config,
|
4140
4147
|
areaId: item.props.id,
|
4141
4148
|
depth: 1,
|
4142
|
-
path: []
|
4149
|
+
path: [],
|
4150
|
+
metadata: (ctx == null ? void 0 : ctx.metadata) || {}
|
4143
4151
|
},
|
4144
4152
|
children: /* @__PURE__ */ jsx22(
|
4145
4153
|
Component.render,
|
4146
4154
|
__spreadProps(__spreadValues({}, item.props), {
|
4147
4155
|
puck: {
|
4148
|
-
renderDropZone: DropZoneRenderPure
|
4156
|
+
renderDropZone: DropZoneRenderPure,
|
4157
|
+
metadata: (ctx == null ? void 0 : ctx.metadata) || {}
|
4149
4158
|
}
|
4150
4159
|
})
|
4151
4160
|
)
|
@@ -4887,7 +4896,7 @@ var DragDropContextClient = ({
|
|
4887
4896
|
children,
|
4888
4897
|
disableAutoScroll
|
4889
4898
|
}) => {
|
4890
|
-
const { state, config, dispatch, resolveData } = useAppContext();
|
4899
|
+
const { state, config, dispatch, resolveData, metadata } = useAppContext();
|
4891
4900
|
const id = useId();
|
4892
4901
|
const { data } = state;
|
4893
4902
|
const debouncedParamsRef = useRef3(null);
|
@@ -5246,7 +5255,8 @@ var DragDropContextClient = ({
|
|
5246
5255
|
registerPath,
|
5247
5256
|
unregisterPath,
|
5248
5257
|
pathData,
|
5249
|
-
path: []
|
5258
|
+
path: [],
|
5259
|
+
metadata
|
5250
5260
|
},
|
5251
5261
|
children
|
5252
5262
|
}
|
@@ -6332,7 +6342,8 @@ init_react_import();
|
|
6332
6342
|
import { jsx as jsx32 } from "react/jsx-runtime";
|
6333
6343
|
function Render({
|
6334
6344
|
config,
|
6335
|
-
data
|
6345
|
+
data,
|
6346
|
+
metadata = {}
|
6336
6347
|
}) {
|
6337
6348
|
var _a;
|
6338
6349
|
const defaultedData = __spreadProps(__spreadValues({}, data), {
|
@@ -6350,7 +6361,8 @@ function Render({
|
|
6350
6361
|
config,
|
6351
6362
|
mode: "render",
|
6352
6363
|
depth: 0,
|
6353
|
-
path: []
|
6364
|
+
path: [],
|
6365
|
+
metadata
|
6354
6366
|
},
|
6355
6367
|
children: /* @__PURE__ */ jsx32(
|
6356
6368
|
config.root.render,
|
@@ -6377,7 +6389,8 @@ function Render({
|
|
6377
6389
|
config,
|
6378
6390
|
mode: "render",
|
6379
6391
|
depth: 0,
|
6380
|
-
path: []
|
6392
|
+
path: [],
|
6393
|
+
metadata
|
6381
6394
|
},
|
6382
6395
|
children: /* @__PURE__ */ jsx32(DropZonePure, { zone: rootDroppableId })
|
6383
6396
|
}
|
@@ -6441,7 +6454,8 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
6441
6454
|
puck: {
|
6442
6455
|
renderDropZone: DropZonePure,
|
6443
6456
|
isEditing: true,
|
6444
|
-
dragRef: null
|
6457
|
+
dragRef: null,
|
6458
|
+
metadata: {}
|
6445
6459
|
},
|
6446
6460
|
editMode: true,
|
6447
6461
|
children: /* @__PURE__ */ jsx33(DropZonePure, { zone: rootDroppableId })
|
@@ -7442,7 +7456,8 @@ function Puck({
|
|
7442
7456
|
viewports = defaultViewports,
|
7443
7457
|
iframe: _iframe,
|
7444
7458
|
dnd,
|
7445
|
-
initialHistory: _initialHistory
|
7459
|
+
initialHistory: _initialHistory,
|
7460
|
+
metadata
|
7446
7461
|
}) {
|
7447
7462
|
var _a, _b;
|
7448
7463
|
const iframe = __spreadValues({
|
@@ -7655,7 +7670,8 @@ function Puck({
|
|
7655
7670
|
edit: true
|
7656
7671
|
}, permissions),
|
7657
7672
|
getPermissions: () => ({}),
|
7658
|
-
refreshPermissions: () => null
|
7673
|
+
refreshPermissions: () => null,
|
7674
|
+
metadata: metadata || {}
|
7659
7675
|
},
|
7660
7676
|
children: /* @__PURE__ */ jsx39(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx39(CustomPuck, { children: children || /* @__PURE__ */ jsx39(
|
7661
7677
|
"div",
|
@@ -25,14 +25,17 @@ type BaseField = {
|
|
25
25
|
};
|
26
26
|
type TextField = BaseField & {
|
27
27
|
type: "text";
|
28
|
+
placeholder?: string;
|
28
29
|
};
|
29
30
|
type NumberField = BaseField & {
|
30
31
|
type: "number";
|
32
|
+
placeholder?: string;
|
31
33
|
min?: number;
|
32
34
|
max?: number;
|
33
35
|
};
|
34
36
|
type TextareaField = BaseField & {
|
35
37
|
type: "textarea";
|
38
|
+
placeholder?: string;
|
36
39
|
};
|
37
40
|
type SelectField = BaseField & {
|
38
41
|
type: "select";
|
@@ -154,6 +157,7 @@ type ComponentConfig<RenderProps extends DefaultComponentProps = DefaultComponen
|
|
154
157
|
resolveData?: (data: DataShape, params: {
|
155
158
|
changed: Partial<Record<keyof FieldProps, boolean>>;
|
156
159
|
lastData: DataShape | null;
|
160
|
+
metadata: Metadata;
|
157
161
|
}) => Promise<{
|
158
162
|
props?: Partial<FieldProps>;
|
159
163
|
readOnly?: Partial<Record<keyof FieldProps, boolean>>;
|
@@ -209,6 +213,7 @@ type UserGenerics<UserConfig extends Config = Config, UserProps extends ExtractP
|
|
209
213
|
|
210
214
|
type PuckContext = {
|
211
215
|
renderDropZone: React.FC<DropZoneProps>;
|
216
|
+
metadata: Metadata;
|
212
217
|
isEditing: boolean;
|
213
218
|
dragRef: ((element: Element | null) => void) | null;
|
214
219
|
};
|
@@ -251,6 +256,9 @@ type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps
|
|
251
256
|
content: Content<Props>;
|
252
257
|
zones?: Record<string, Content<Props>>;
|
253
258
|
};
|
259
|
+
type Metadata = {
|
260
|
+
[key: string]: any;
|
261
|
+
};
|
254
262
|
|
255
263
|
type ItemWithId = {
|
256
264
|
_arrayId: string;
|
@@ -457,6 +465,6 @@ type PuckAction = {
|
|
457
465
|
recordHistory?: boolean;
|
458
466
|
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
459
467
|
|
460
|
-
declare function resolveAllData<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Props, RootProps>>;
|
468
|
+
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
469
|
|
462
|
-
export { type
|
470
|
+
export { type PuckContext as $, type AppState as A, type BaseData as B, type Config as C, type DropZoneProps as D, type ExtractPropsFromConfig as E, type FieldProps as F, type BaseField as G, type History as H, type IframeConfig as I, type TextareaField as J, type RadioField as K, type ArrayField as L, type Metadata as M, type NumberField as N, type OnAction as O, type Permissions as P, type ObjectField as Q, type RootDataWithProps as R, type SelectField as S, type TextField as T, type UserGenerics as U, type Viewports as V, type Adaptor as W, type ExternalFieldWithAdaptor as X, type ExternalField as Y, type CustomField as Z, type Fields as _, type Field as a, type DefaultRootRenderProps as a0, type DefaultRootProps as a1, type WithId as a2, type WithPuckProps as a3, type AsFieldProps as a4, type WithChildren as a5, resolveAllData as a6, 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 DefaultComponentProps as h, type DefaultRootFieldProps as i, type ExtractRootPropsFromConfig as j, type ComponentDataMap as k, type Direction as l, type DragAxis as m, type Viewport as n, overrideKeys as o, type OverrideKey as p, type FieldRenderFunctions as q, type ItemWithId as r, type ArrayState as s, type PuckComponent as t, type ComponentConfig as u, type RootDataWithoutProps as v, type RootData as w, type ComponentData as x, type MappedItem as y, type Content as z };
|
@@ -25,14 +25,17 @@ type BaseField = {
|
|
25
25
|
};
|
26
26
|
type TextField = BaseField & {
|
27
27
|
type: "text";
|
28
|
+
placeholder?: string;
|
28
29
|
};
|
29
30
|
type NumberField = BaseField & {
|
30
31
|
type: "number";
|
32
|
+
placeholder?: string;
|
31
33
|
min?: number;
|
32
34
|
max?: number;
|
33
35
|
};
|
34
36
|
type TextareaField = BaseField & {
|
35
37
|
type: "textarea";
|
38
|
+
placeholder?: string;
|
36
39
|
};
|
37
40
|
type SelectField = BaseField & {
|
38
41
|
type: "select";
|
@@ -154,6 +157,7 @@ type ComponentConfig<RenderProps extends DefaultComponentProps = DefaultComponen
|
|
154
157
|
resolveData?: (data: DataShape, params: {
|
155
158
|
changed: Partial<Record<keyof FieldProps, boolean>>;
|
156
159
|
lastData: DataShape | null;
|
160
|
+
metadata: Metadata;
|
157
161
|
}) => Promise<{
|
158
162
|
props?: Partial<FieldProps>;
|
159
163
|
readOnly?: Partial<Record<keyof FieldProps, boolean>>;
|
@@ -209,6 +213,7 @@ type UserGenerics<UserConfig extends Config = Config, UserProps extends ExtractP
|
|
209
213
|
|
210
214
|
type PuckContext = {
|
211
215
|
renderDropZone: React.FC<DropZoneProps>;
|
216
|
+
metadata: Metadata;
|
212
217
|
isEditing: boolean;
|
213
218
|
dragRef: ((element: Element | null) => void) | null;
|
214
219
|
};
|
@@ -251,6 +256,9 @@ type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps
|
|
251
256
|
content: Content<Props>;
|
252
257
|
zones?: Record<string, Content<Props>>;
|
253
258
|
};
|
259
|
+
type Metadata = {
|
260
|
+
[key: string]: any;
|
261
|
+
};
|
254
262
|
|
255
263
|
type ItemWithId = {
|
256
264
|
_arrayId: string;
|
@@ -457,6 +465,6 @@ type PuckAction = {
|
|
457
465
|
recordHistory?: boolean;
|
458
466
|
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
459
467
|
|
460
|
-
declare function resolveAllData<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Props, RootProps>>;
|
468
|
+
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
469
|
|
462
|
-
export { type
|
470
|
+
export { type PuckContext as $, type AppState as A, type BaseData as B, type Config as C, type DropZoneProps as D, type ExtractPropsFromConfig as E, type FieldProps as F, type BaseField as G, type History as H, type IframeConfig as I, type TextareaField as J, type RadioField as K, type ArrayField as L, type Metadata as M, type NumberField as N, type OnAction as O, type Permissions as P, type ObjectField as Q, type RootDataWithProps as R, type SelectField as S, type TextField as T, type UserGenerics as U, type Viewports as V, type Adaptor as W, type ExternalFieldWithAdaptor as X, type ExternalField as Y, type CustomField as Z, type Fields as _, type Field as a, type DefaultRootRenderProps as a0, type DefaultRootProps as a1, type WithId as a2, type WithPuckProps as a3, type AsFieldProps as a4, type WithChildren as a5, resolveAllData as a6, 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 DefaultComponentProps as h, type DefaultRootFieldProps as i, type ExtractRootPropsFromConfig as j, type ComponentDataMap as k, type Direction as l, type DragAxis as m, type Viewport as n, overrideKeys as o, type OverrideKey as p, type FieldRenderFunctions as q, type ItemWithId as r, type ArrayState as s, type PuckComponent as t, type ComponentConfig as u, type RootDataWithoutProps as v, type RootData as w, type ComponentData as x, type MappedItem as y, type Content 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-D43Z4niC.mjs';
|
3
|
+
export { a6 as resolveAllData } from './resolve-all-data-D43Z4niC.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-D43Z4niC.js';
|
3
|
+
export { a6 as resolveAllData } from './resolve-all-data-D43Z4niC.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
@@ -96,7 +96,8 @@ function DropZoneRender({
|
|
96
96
|
zone,
|
97
97
|
data,
|
98
98
|
areaId = "root",
|
99
|
-
config
|
99
|
+
config,
|
100
|
+
metadata = {}
|
100
101
|
}) {
|
101
102
|
let zoneCompound = rootDroppableId;
|
102
103
|
let content = (data == null ? void 0 : data.content) || [];
|
@@ -120,9 +121,11 @@ function DropZoneRender({
|
|
120
121
|
zone: zone2,
|
121
122
|
data,
|
122
123
|
areaId: item.props.id,
|
123
|
-
config
|
124
|
+
config,
|
125
|
+
metadata
|
124
126
|
}
|
125
|
-
)
|
127
|
+
),
|
128
|
+
metadata
|
126
129
|
}
|
127
130
|
}),
|
128
131
|
item.props.id
|
@@ -131,7 +134,11 @@ function DropZoneRender({
|
|
131
134
|
return null;
|
132
135
|
}) });
|
133
136
|
}
|
134
|
-
function Render({
|
137
|
+
function Render({
|
138
|
+
config,
|
139
|
+
data,
|
140
|
+
metadata
|
141
|
+
}) {
|
135
142
|
var _a;
|
136
143
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
137
144
|
const rootProps = data.root.props || data.root;
|
@@ -140,18 +147,42 @@ function Render({ config, data }) {
|
|
140
147
|
config.root.render,
|
141
148
|
__spreadProps(__spreadValues({}, rootProps), {
|
142
149
|
puck: {
|
143
|
-
renderDropZone: ({ zone }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
150
|
+
renderDropZone: ({ zone }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
151
|
+
DropZoneRender,
|
152
|
+
{
|
153
|
+
zone,
|
154
|
+
data,
|
155
|
+
config,
|
156
|
+
metadata
|
157
|
+
}
|
158
|
+
),
|
144
159
|
isEditing: false,
|
145
160
|
dragRef: null
|
146
161
|
},
|
147
162
|
title,
|
148
163
|
editMode: false,
|
149
164
|
id: "puck-root",
|
150
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
165
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
166
|
+
DropZoneRender,
|
167
|
+
{
|
168
|
+
config,
|
169
|
+
data,
|
170
|
+
zone: rootDroppableId,
|
171
|
+
metadata
|
172
|
+
}
|
173
|
+
)
|
151
174
|
})
|
152
175
|
);
|
153
176
|
}
|
154
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
177
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
178
|
+
DropZoneRender,
|
179
|
+
{
|
180
|
+
config,
|
181
|
+
data,
|
182
|
+
zone: rootDroppableId,
|
183
|
+
metadata
|
184
|
+
}
|
185
|
+
);
|
155
186
|
}
|
156
187
|
|
157
188
|
// lib/get-changed.ts
|
@@ -167,19 +198,20 @@ var getChanged = (newItem, oldItem) => {
|
|
167
198
|
|
168
199
|
// lib/resolve-component-data.ts
|
169
200
|
var cache = { lastChange: {} };
|
170
|
-
var resolveAllComponentData = (
|
201
|
+
var resolveAllComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (content, config, metadata = {}, onResolveStart, onResolveEnd) {
|
171
202
|
return yield Promise.all(
|
172
203
|
content.map((item) => __async(void 0, null, function* () {
|
173
204
|
return yield resolveComponentData(
|
174
205
|
item,
|
175
206
|
config,
|
207
|
+
metadata,
|
176
208
|
onResolveStart,
|
177
209
|
onResolveEnd
|
178
210
|
);
|
179
211
|
}))
|
180
212
|
);
|
181
213
|
});
|
182
|
-
var resolveComponentData = (
|
214
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd) {
|
183
215
|
const configForItem = config.components[item.type];
|
184
216
|
if (configForItem.resolveData) {
|
185
217
|
const { item: oldItem = null, resolved = {} } = cache.lastChange[item.props.id] || {};
|
@@ -190,7 +222,11 @@ var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __asy
|
|
190
222
|
if (onResolveStart) {
|
191
223
|
onResolveStart(item);
|
192
224
|
}
|
193
|
-
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
225
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
226
|
+
changed,
|
227
|
+
lastData: oldItem,
|
228
|
+
metadata
|
229
|
+
});
|
194
230
|
const resolvedItem = __spreadProps(__spreadValues({}, item), {
|
195
231
|
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
196
232
|
});
|
@@ -211,7 +247,7 @@ var resolveComponentData = (item, config, onResolveStart, onResolveEnd) => __asy
|
|
211
247
|
|
212
248
|
// lib/resolve-root-data.ts
|
213
249
|
var cache2 = {};
|
214
|
-
function resolveRootData(data, config) {
|
250
|
+
function resolveRootData(data, config, metadata) {
|
215
251
|
return __async(this, null, function* () {
|
216
252
|
var _a, _b, _c, _d, _e;
|
217
253
|
if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
|
@@ -222,7 +258,8 @@ function resolveRootData(data, config) {
|
|
222
258
|
const rootWithProps = data.root;
|
223
259
|
const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
|
224
260
|
changed,
|
225
|
-
lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {}
|
261
|
+
lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {},
|
262
|
+
metadata: metadata || {}
|
226
263
|
});
|
227
264
|
cache2.lastChange = {
|
228
265
|
original: data.root,
|
@@ -243,10 +280,14 @@ var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
|
243
280
|
});
|
244
281
|
|
245
282
|
// lib/resolve-all-data.ts
|
246
|
-
function resolveAllData(
|
247
|
-
return __async(this,
|
283
|
+
function resolveAllData(_0, _1) {
|
284
|
+
return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
|
248
285
|
const defaultedData = defaultData(data);
|
249
|
-
const dynamicRoot = yield resolveRootData(
|
286
|
+
const dynamicRoot = yield resolveRootData(
|
287
|
+
defaultedData,
|
288
|
+
config,
|
289
|
+
metadata
|
290
|
+
);
|
250
291
|
const { zones = {} } = data;
|
251
292
|
const zoneKeys = Object.keys(zones);
|
252
293
|
const resolvedZones = {};
|
@@ -255,6 +296,7 @@ function resolveAllData(data, config, onResolveStart, onResolveEnd) {
|
|
255
296
|
resolvedZones[zoneKey] = yield resolveAllComponentData(
|
256
297
|
zones[zoneKey],
|
257
298
|
config,
|
299
|
+
metadata,
|
258
300
|
onResolveStart,
|
259
301
|
onResolveEnd
|
260
302
|
);
|
@@ -264,6 +306,7 @@ function resolveAllData(data, config, onResolveStart, onResolveEnd) {
|
|
264
306
|
content: yield resolveAllComponentData(
|
265
307
|
defaultedData.content,
|
266
308
|
config,
|
309
|
+
metadata,
|
267
310
|
onResolveStart,
|
268
311
|
onResolveEnd
|
269
312
|
),
|
package/dist/rsc.mjs
CHANGED
@@ -5,7 +5,7 @@ import {
|
|
5
5
|
resolveAllData,
|
6
6
|
rootDroppableId,
|
7
7
|
setupZone
|
8
|
-
} from "./chunk-
|
8
|
+
} from "./chunk-FNRHXUGA.mjs";
|
9
9
|
|
10
10
|
// rsc.tsx
|
11
11
|
init_react_import();
|
@@ -17,7 +17,8 @@ function DropZoneRender({
|
|
17
17
|
zone,
|
18
18
|
data,
|
19
19
|
areaId = "root",
|
20
|
-
config
|
20
|
+
config,
|
21
|
+
metadata = {}
|
21
22
|
}) {
|
22
23
|
let zoneCompound = rootDroppableId;
|
23
24
|
let content = (data == null ? void 0 : data.content) || [];
|
@@ -41,9 +42,11 @@ function DropZoneRender({
|
|
41
42
|
zone: zone2,
|
42
43
|
data,
|
43
44
|
areaId: item.props.id,
|
44
|
-
config
|
45
|
+
config,
|
46
|
+
metadata
|
45
47
|
}
|
46
|
-
)
|
48
|
+
),
|
49
|
+
metadata
|
47
50
|
}
|
48
51
|
}),
|
49
52
|
item.props.id
|
@@ -52,7 +55,11 @@ function DropZoneRender({
|
|
52
55
|
return null;
|
53
56
|
}) });
|
54
57
|
}
|
55
|
-
function Render({
|
58
|
+
function Render({
|
59
|
+
config,
|
60
|
+
data,
|
61
|
+
metadata
|
62
|
+
}) {
|
56
63
|
var _a;
|
57
64
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
58
65
|
const rootProps = data.root.props || data.root;
|
@@ -61,18 +68,42 @@ function Render({ config, data }) {
|
|
61
68
|
config.root.render,
|
62
69
|
__spreadProps(__spreadValues({}, rootProps), {
|
63
70
|
puck: {
|
64
|
-
renderDropZone: ({ zone }) => /* @__PURE__ */ jsx(
|
71
|
+
renderDropZone: ({ zone }) => /* @__PURE__ */ jsx(
|
72
|
+
DropZoneRender,
|
73
|
+
{
|
74
|
+
zone,
|
75
|
+
data,
|
76
|
+
config,
|
77
|
+
metadata
|
78
|
+
}
|
79
|
+
),
|
65
80
|
isEditing: false,
|
66
81
|
dragRef: null
|
67
82
|
},
|
68
83
|
title,
|
69
84
|
editMode: false,
|
70
85
|
id: "puck-root",
|
71
|
-
children: /* @__PURE__ */ jsx(
|
86
|
+
children: /* @__PURE__ */ jsx(
|
87
|
+
DropZoneRender,
|
88
|
+
{
|
89
|
+
config,
|
90
|
+
data,
|
91
|
+
zone: rootDroppableId,
|
92
|
+
metadata
|
93
|
+
}
|
94
|
+
)
|
72
95
|
})
|
73
96
|
);
|
74
97
|
}
|
75
|
-
return /* @__PURE__ */ jsx(
|
98
|
+
return /* @__PURE__ */ jsx(
|
99
|
+
DropZoneRender,
|
100
|
+
{
|
101
|
+
config,
|
102
|
+
data,
|
103
|
+
zone: rootDroppableId,
|
104
|
+
metadata
|
105
|
+
}
|
106
|
+
);
|
76
107
|
}
|
77
108
|
export {
|
78
109
|
Render,
|
package/package.json
CHANGED