@measured/puck 0.18.3-canary.9e8e47b → 0.19.0-canary.0ea6ce4

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.
@@ -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 = (content, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
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 = (item, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
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, { changed, lastData: oldItem });
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(data, config, onResolveStart, onResolveEnd) {
193
- return __async(this, null, function* () {
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(defaultedData, config);
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-ppm982Jh.mjs';
2
- export { Q as Adaptor, K as ArrayField, s as ArrayState, a3 as AsFieldProps, B as BaseData, z as BaseField, u as ComponentConfig, x as ComponentData, y as Content, Y as CustomField, a0 as DefaultRootProps, $ as DefaultRootRenderProps, l as Direction, m as DragAxis, X as ExternalField, W as ExternalFieldWithAdaptor, q as FieldRenderFunctions, Z as Fields, r as ItemWithId, M as MappedItem, N as NumberField, L as ObjectField, p as OverrideKey, t as PuckComponent, _ as PuckContext, J as RadioField, w as RootData, R as RootDataWithProps, v as RootDataWithoutProps, S as SelectField, T as TextField, G as TextareaField, n as Viewport, a4 as WithChildren, a1 as WithId, a2 as WithPuckProps, o as overrideKeys, a5 as resolveAllData } from './resolve-all-data-ppm982Jh.mjs';
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-D4okkICg.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-D4okkICg.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-ppm982Jh.js';
2
- export { Q as Adaptor, K as ArrayField, s as ArrayState, a3 as AsFieldProps, B as BaseData, z as BaseField, u as ComponentConfig, x as ComponentData, y as Content, Y as CustomField, a0 as DefaultRootProps, $ as DefaultRootRenderProps, l as Direction, m as DragAxis, X as ExternalField, W as ExternalFieldWithAdaptor, q as FieldRenderFunctions, Z as Fields, r as ItemWithId, M as MappedItem, N as NumberField, L as ObjectField, p as OverrideKey, t as PuckComponent, _ as PuckContext, J as RadioField, w as RootData, R as RootDataWithProps, v as RootDataWithoutProps, S as SelectField, T as TextField, G as TextareaField, n as Viewport, a4 as WithChildren, a1 as WithId, a2 as WithPuckProps, o as overrideKeys, a5 as resolveAllData } from './resolve-all-data-ppm982Jh.js';
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-D4okkICg.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-D4okkICg.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 = (content, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
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 = (item, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
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, { changed, lastData: oldItem });
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,9 @@ 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,
2423
+ step: field.type === "number" ? field.step : void 0
2413
2424
  }
2414
2425
  )
2415
2426
  }
@@ -2985,6 +2996,7 @@ init_react_import();
2985
2996
  var import_jsx_runtime17 = require("react/jsx-runtime");
2986
2997
  var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
2987
2998
  var TextareaField = ({
2999
+ field,
2988
3000
  onChange,
2989
3001
  readOnly,
2990
3002
  value,
@@ -3004,7 +3016,8 @@ var TextareaField = ({
3004
3016
  onChange: (e) => onChange(e.currentTarget.value),
3005
3017
  readOnly,
3006
3018
  tabIndex: readOnly ? -1 : void 0,
3007
- rows: 5
3019
+ rows: 5,
3020
+ placeholder: field.type === "textarea" ? field.placeholder : void 0
3008
3021
  }
3009
3022
  ) });
3010
3023
  };
@@ -4188,6 +4201,7 @@ var DropZoneEdit = (0, import_react30.forwardRef)(
4188
4201
  const componentId = item.props.id;
4189
4202
  const puckProps = {
4190
4203
  renderDropZone: DropZoneEditPure,
4204
+ metadata: appContext2.metadata,
4191
4205
  isEditing: true,
4192
4206
  dragRef: null
4193
4207
  };
@@ -4285,13 +4299,15 @@ var DropZoneRender = (0, import_react30.forwardRef)(
4285
4299
  config,
4286
4300
  areaId: item.props.id,
4287
4301
  depth: 1,
4288
- path: []
4302
+ path: [],
4303
+ metadata: (ctx == null ? void 0 : ctx.metadata) || {}
4289
4304
  },
4290
4305
  children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
4291
4306
  Component.render,
4292
4307
  __spreadProps(__spreadValues({}, item.props), {
4293
4308
  puck: {
4294
- renderDropZone: DropZoneRenderPure
4309
+ renderDropZone: DropZoneRenderPure,
4310
+ metadata: (ctx == null ? void 0 : ctx.metadata) || {}
4295
4311
  }
4296
4312
  })
4297
4313
  )
@@ -5033,7 +5049,7 @@ var DragDropContextClient = ({
5033
5049
  children,
5034
5050
  disableAutoScroll
5035
5051
  }) => {
5036
- const { state, config, dispatch, resolveData } = useAppContext();
5052
+ const { state, config, dispatch, resolveData, metadata } = useAppContext();
5037
5053
  const id = (0, import_react32.useId)();
5038
5054
  const { data } = state;
5039
5055
  const debouncedParamsRef = (0, import_react32.useRef)(null);
@@ -5392,7 +5408,8 @@ var DragDropContextClient = ({
5392
5408
  registerPath,
5393
5409
  unregisterPath,
5394
5410
  pathData,
5395
- path: []
5411
+ path: [],
5412
+ metadata
5396
5413
  },
5397
5414
  children
5398
5415
  }
@@ -6467,7 +6484,8 @@ init_react_import();
6467
6484
  var import_jsx_runtime32 = require("react/jsx-runtime");
6468
6485
  function Render({
6469
6486
  config,
6470
- data
6487
+ data,
6488
+ metadata = {}
6471
6489
  }) {
6472
6490
  var _a;
6473
6491
  const defaultedData = __spreadProps(__spreadValues({}, data), {
@@ -6485,7 +6503,8 @@ function Render({
6485
6503
  config,
6486
6504
  mode: "render",
6487
6505
  depth: 0,
6488
- path: []
6506
+ path: [],
6507
+ metadata
6489
6508
  },
6490
6509
  children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6491
6510
  config.root.render,
@@ -6512,7 +6531,8 @@ function Render({
6512
6531
  config,
6513
6532
  mode: "render",
6514
6533
  depth: 0,
6515
- path: []
6534
+ path: [],
6535
+ metadata
6516
6536
  },
6517
6537
  children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(DropZonePure, { zone: rootDroppableId })
6518
6538
  }
@@ -6576,7 +6596,8 @@ var Preview2 = ({ id = "puck-preview" }) => {
6576
6596
  puck: {
6577
6597
  renderDropZone: DropZonePure,
6578
6598
  isEditing: true,
6579
- dragRef: null
6599
+ dragRef: null,
6600
+ metadata: {}
6580
6601
  },
6581
6602
  editMode: true,
6582
6603
  children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropZonePure, { zone: rootDroppableId })
@@ -7571,7 +7592,8 @@ function Puck({
7571
7592
  viewports = defaultViewports,
7572
7593
  iframe: _iframe,
7573
7594
  dnd,
7574
- initialHistory: _initialHistory
7595
+ initialHistory: _initialHistory,
7596
+ metadata
7575
7597
  }) {
7576
7598
  var _a, _b;
7577
7599
  const iframe = __spreadValues({
@@ -7784,7 +7806,8 @@ function Puck({
7784
7806
  edit: true
7785
7807
  }, permissions),
7786
7808
  getPermissions: () => ({}),
7787
- refreshPermissions: () => null
7809
+ refreshPermissions: () => null,
7810
+ metadata: metadata || {}
7788
7811
  },
7789
7812
  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
7813
  "div",
@@ -7988,10 +8011,14 @@ function transformProps(data, propTransforms) {
7988
8011
 
7989
8012
  // lib/resolve-all-data.ts
7990
8013
  init_react_import();
7991
- function resolveAllData(data, config, onResolveStart, onResolveEnd) {
7992
- return __async(this, null, function* () {
8014
+ function resolveAllData(_0, _1) {
8015
+ return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
7993
8016
  const defaultedData = defaultData(data);
7994
- const dynamicRoot = yield resolveRootData(defaultedData, config);
8017
+ const dynamicRoot = yield resolveRootData(
8018
+ defaultedData,
8019
+ config,
8020
+ metadata
8021
+ );
7995
8022
  const { zones = {} } = data;
7996
8023
  const zoneKeys = Object.keys(zones);
7997
8024
  const resolvedZones = {};
@@ -8000,6 +8027,7 @@ function resolveAllData(data, config, onResolveStart, onResolveEnd) {
8000
8027
  resolvedZones[zoneKey] = yield resolveAllComponentData(
8001
8028
  zones[zoneKey],
8002
8029
  config,
8030
+ metadata,
8003
8031
  onResolveStart,
8004
8032
  onResolveEnd
8005
8033
  );
@@ -8009,6 +8037,7 @@ function resolveAllData(data, config, onResolveStart, onResolveEnd) {
8009
8037
  content: yield resolveAllComponentData(
8010
8038
  defaultedData.content,
8011
8039
  config,
8040
+ metadata,
8012
8041
  onResolveStart,
8013
8042
  onResolveEnd
8014
8043
  ),
package/dist/index.mjs CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  resolveRootData,
17
17
  rootDroppableId,
18
18
  setupZone
19
- } from "./chunk-CHWFBYEM.mjs";
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,9 @@ 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,
2238
+ step: field.type === "number" ? field.step : void 0
2234
2239
  }
2235
2240
  )
2236
2241
  }
@@ -2812,6 +2817,7 @@ init_react_import();
2812
2817
  import { jsx as jsx17 } from "react/jsx-runtime";
2813
2818
  var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
2814
2819
  var TextareaField = ({
2820
+ field,
2815
2821
  onChange,
2816
2822
  readOnly,
2817
2823
  value,
@@ -2831,7 +2837,8 @@ var TextareaField = ({
2831
2837
  onChange: (e) => onChange(e.currentTarget.value),
2832
2838
  readOnly,
2833
2839
  tabIndex: readOnly ? -1 : void 0,
2834
- rows: 5
2840
+ rows: 5,
2841
+ placeholder: field.type === "textarea" ? field.placeholder : void 0
2835
2842
  }
2836
2843
  ) });
2837
2844
  };
@@ -4042,6 +4049,7 @@ var DropZoneEdit = forwardRef3(
4042
4049
  const componentId = item.props.id;
4043
4050
  const puckProps = {
4044
4051
  renderDropZone: DropZoneEditPure,
4052
+ metadata: appContext2.metadata,
4045
4053
  isEditing: true,
4046
4054
  dragRef: null
4047
4055
  };
@@ -4139,13 +4147,15 @@ var DropZoneRender = forwardRef3(
4139
4147
  config,
4140
4148
  areaId: item.props.id,
4141
4149
  depth: 1,
4142
- path: []
4150
+ path: [],
4151
+ metadata: (ctx == null ? void 0 : ctx.metadata) || {}
4143
4152
  },
4144
4153
  children: /* @__PURE__ */ jsx22(
4145
4154
  Component.render,
4146
4155
  __spreadProps(__spreadValues({}, item.props), {
4147
4156
  puck: {
4148
- renderDropZone: DropZoneRenderPure
4157
+ renderDropZone: DropZoneRenderPure,
4158
+ metadata: (ctx == null ? void 0 : ctx.metadata) || {}
4149
4159
  }
4150
4160
  })
4151
4161
  )
@@ -4887,7 +4897,7 @@ var DragDropContextClient = ({
4887
4897
  children,
4888
4898
  disableAutoScroll
4889
4899
  }) => {
4890
- const { state, config, dispatch, resolveData } = useAppContext();
4900
+ const { state, config, dispatch, resolveData, metadata } = useAppContext();
4891
4901
  const id = useId();
4892
4902
  const { data } = state;
4893
4903
  const debouncedParamsRef = useRef3(null);
@@ -5246,7 +5256,8 @@ var DragDropContextClient = ({
5246
5256
  registerPath,
5247
5257
  unregisterPath,
5248
5258
  pathData,
5249
- path: []
5259
+ path: [],
5260
+ metadata
5250
5261
  },
5251
5262
  children
5252
5263
  }
@@ -6332,7 +6343,8 @@ init_react_import();
6332
6343
  import { jsx as jsx32 } from "react/jsx-runtime";
6333
6344
  function Render({
6334
6345
  config,
6335
- data
6346
+ data,
6347
+ metadata = {}
6336
6348
  }) {
6337
6349
  var _a;
6338
6350
  const defaultedData = __spreadProps(__spreadValues({}, data), {
@@ -6350,7 +6362,8 @@ function Render({
6350
6362
  config,
6351
6363
  mode: "render",
6352
6364
  depth: 0,
6353
- path: []
6365
+ path: [],
6366
+ metadata
6354
6367
  },
6355
6368
  children: /* @__PURE__ */ jsx32(
6356
6369
  config.root.render,
@@ -6377,7 +6390,8 @@ function Render({
6377
6390
  config,
6378
6391
  mode: "render",
6379
6392
  depth: 0,
6380
- path: []
6393
+ path: [],
6394
+ metadata
6381
6395
  },
6382
6396
  children: /* @__PURE__ */ jsx32(DropZonePure, { zone: rootDroppableId })
6383
6397
  }
@@ -6441,7 +6455,8 @@ var Preview2 = ({ id = "puck-preview" }) => {
6441
6455
  puck: {
6442
6456
  renderDropZone: DropZonePure,
6443
6457
  isEditing: true,
6444
- dragRef: null
6458
+ dragRef: null,
6459
+ metadata: {}
6445
6460
  },
6446
6461
  editMode: true,
6447
6462
  children: /* @__PURE__ */ jsx33(DropZonePure, { zone: rootDroppableId })
@@ -7442,7 +7457,8 @@ function Puck({
7442
7457
  viewports = defaultViewports,
7443
7458
  iframe: _iframe,
7444
7459
  dnd,
7445
- initialHistory: _initialHistory
7460
+ initialHistory: _initialHistory,
7461
+ metadata
7446
7462
  }) {
7447
7463
  var _a, _b;
7448
7464
  const iframe = __spreadValues({
@@ -7655,7 +7671,8 @@ function Puck({
7655
7671
  edit: true
7656
7672
  }, permissions),
7657
7673
  getPermissions: () => ({}),
7658
- refreshPermissions: () => null
7674
+ refreshPermissions: () => null,
7675
+ metadata: metadata || {}
7659
7676
  },
7660
7677
  children: /* @__PURE__ */ jsx39(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx39(CustomPuck, { children: children || /* @__PURE__ */ jsx39(
7661
7678
  "div",
@@ -25,14 +25,18 @@ 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;
35
+ step?: number;
33
36
  };
34
37
  type TextareaField = BaseField & {
35
38
  type: "textarea";
39
+ placeholder?: string;
36
40
  };
37
41
  type SelectField = BaseField & {
38
42
  type: "select";
@@ -154,6 +158,7 @@ type ComponentConfig<RenderProps extends DefaultComponentProps = DefaultComponen
154
158
  resolveData?: (data: DataShape, params: {
155
159
  changed: Partial<Record<keyof FieldProps, boolean>>;
156
160
  lastData: DataShape | null;
161
+ metadata: Metadata;
157
162
  }) => Promise<{
158
163
  props?: Partial<FieldProps>;
159
164
  readOnly?: Partial<Record<keyof FieldProps, boolean>>;
@@ -209,6 +214,7 @@ type UserGenerics<UserConfig extends Config = Config, UserProps extends ExtractP
209
214
 
210
215
  type PuckContext = {
211
216
  renderDropZone: React.FC<DropZoneProps>;
217
+ metadata: Metadata;
212
218
  isEditing: boolean;
213
219
  dragRef: ((element: Element | null) => void) | null;
214
220
  };
@@ -251,6 +257,9 @@ type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps
251
257
  content: Content<Props>;
252
258
  zones?: Record<string, Content<Props>>;
253
259
  };
260
+ type Metadata = {
261
+ [key: string]: any;
262
+ };
254
263
 
255
264
  type ItemWithId = {
256
265
  _arrayId: string;
@@ -457,6 +466,6 @@ type PuckAction = {
457
466
  recordHistory?: boolean;
458
467
  } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
459
468
 
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>>;
469
+ 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
470
 
462
- export { type DefaultRootRenderProps 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 TextareaField as G, type History as H, type IframeConfig as I, type RadioField as J, type ArrayField as K, type ObjectField as L, type MappedItem as M, type NumberField as N, type OnAction as O, type Permissions as P, type Adaptor as Q, type RootDataWithProps as R, type SelectField as S, type TextField as T, type UserGenerics as U, type Viewports as V, type ExternalFieldWithAdaptor as W, type ExternalField as X, type CustomField as Y, type Fields as Z, type PuckContext as _, type Field as a, type DefaultRootProps as a0, type WithId as a1, type WithPuckProps as a2, type AsFieldProps as a3, type WithChildren as a4, resolveAllData as a5, 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 Content as y, type BaseField as z };
471
+ 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,18 @@ 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;
35
+ step?: number;
33
36
  };
34
37
  type TextareaField = BaseField & {
35
38
  type: "textarea";
39
+ placeholder?: string;
36
40
  };
37
41
  type SelectField = BaseField & {
38
42
  type: "select";
@@ -154,6 +158,7 @@ type ComponentConfig<RenderProps extends DefaultComponentProps = DefaultComponen
154
158
  resolveData?: (data: DataShape, params: {
155
159
  changed: Partial<Record<keyof FieldProps, boolean>>;
156
160
  lastData: DataShape | null;
161
+ metadata: Metadata;
157
162
  }) => Promise<{
158
163
  props?: Partial<FieldProps>;
159
164
  readOnly?: Partial<Record<keyof FieldProps, boolean>>;
@@ -209,6 +214,7 @@ type UserGenerics<UserConfig extends Config = Config, UserProps extends ExtractP
209
214
 
210
215
  type PuckContext = {
211
216
  renderDropZone: React.FC<DropZoneProps>;
217
+ metadata: Metadata;
212
218
  isEditing: boolean;
213
219
  dragRef: ((element: Element | null) => void) | null;
214
220
  };
@@ -251,6 +257,9 @@ type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps
251
257
  content: Content<Props>;
252
258
  zones?: Record<string, Content<Props>>;
253
259
  };
260
+ type Metadata = {
261
+ [key: string]: any;
262
+ };
254
263
 
255
264
  type ItemWithId = {
256
265
  _arrayId: string;
@@ -457,6 +466,6 @@ type PuckAction = {
457
466
  recordHistory?: boolean;
458
467
  } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
459
468
 
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>>;
469
+ 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
470
 
462
- export { type DefaultRootRenderProps 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 TextareaField as G, type History as H, type IframeConfig as I, type RadioField as J, type ArrayField as K, type ObjectField as L, type MappedItem as M, type NumberField as N, type OnAction as O, type Permissions as P, type Adaptor as Q, type RootDataWithProps as R, type SelectField as S, type TextField as T, type UserGenerics as U, type Viewports as V, type ExternalFieldWithAdaptor as W, type ExternalField as X, type CustomField as Y, type Fields as Z, type PuckContext as _, type Field as a, type DefaultRootProps as a0, type WithId as a1, type WithPuckProps as a2, type AsFieldProps as a3, type WithChildren as a4, resolveAllData as a5, 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 Content as y, type BaseField as z };
471
+ 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-ppm982Jh.mjs';
3
- export { a5 as resolveAllData } from './resolve-all-data-ppm982Jh.mjs';
2
+ import { C as Config, U as UserGenerics, M as Metadata } from './resolve-all-data-D4okkICg.mjs';
3
+ export { a6 as resolveAllData } from './resolve-all-data-D4okkICg.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-ppm982Jh.js';
3
- export { a5 as resolveAllData } from './resolve-all-data-ppm982Jh.js';
2
+ import { C as Config, U as UserGenerics, M as Metadata } from './resolve-all-data-D4okkICg.js';
3
+ export { a6 as resolveAllData } from './resolve-all-data-D4okkICg.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({ config, data }) {
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)(DropZoneRender, { zone, data, config }),
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)(DropZoneRender, { config, data, zone: rootDroppableId })
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)(DropZoneRender, { config, data, zone: rootDroppableId });
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 = (content, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
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 = (item, config, onResolveStart, onResolveEnd) => __async(void 0, null, function* () {
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, { changed, lastData: oldItem });
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(data, config, onResolveStart, onResolveEnd) {
247
- return __async(this, null, function* () {
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(defaultedData, config);
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-CHWFBYEM.mjs";
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({ config, data }) {
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(DropZoneRender, { zone, data, config }),
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(DropZoneRender, { config, data, zone: rootDroppableId })
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(DropZoneRender, { config, data, zone: rootDroppableId });
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.18.3-canary.9e8e47b",
3
+ "version": "0.19.0-canary.0ea6ce4",
4
4
  "author": "Measured Corporation Ltd <hello@measured.co>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",