@measured/puck 0.18.3-canary.9e8e47b → 0.18.3

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.
@@ -457,6 +457,17 @@ type PuckAction = {
457
457
  recordHistory?: boolean;
458
458
  } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
459
459
 
460
+ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
461
+ [ComponentName in keyof Props]: (props: Props[ComponentName] & {
462
+ [key: string]: any;
463
+ }) => Props[ComponentName];
464
+ } & {
465
+ root: (props: RootProps & {
466
+ [key: string]: any;
467
+ }) => RootProps;
468
+ }>;
469
+ declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
470
+
460
471
  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>>;
461
472
 
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 };
473
+ export { type DefaultRootProps 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 ArrayField as G, type History as H, type IframeConfig as I, type ObjectField as J, type Adaptor as K, type ExternalFieldWithAdaptor as L, type MappedItem as M, type NumberField as N, type OnAction as O, type Permissions as P, type ExternalField as Q, type RootDataWithProps as R, type SelectField as S, type TextField as T, type UserGenerics as U, type Viewports as V, type CustomField as W, type Fields as X, type PuckContext as Y, type DefaultRootFieldProps as Z, type DefaultRootRenderProps as _, type Field as a, type DefaultComponentProps as a0, type WithId as a1, type WithPuckProps as a2, type AsFieldProps as a3, type WithChildren as a4, transformProps 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 ExtractRootPropsFromConfig as h, type ComponentDataMap as i, type Direction as j, type DragAxis as k, type Viewport as l, type OverrideKey as m, type FieldRenderFunctions as n, overrideKeys as o, type ItemWithId as p, type ArrayState as q, type PuckComponent as r, type ComponentConfig as s, type RootDataWithoutProps as t, type RootData as u, type ComponentData as v, type Content as w, type BaseField as x, type TextareaField as y, type RadioField as z };
@@ -457,6 +457,17 @@ type PuckAction = {
457
457
  recordHistory?: boolean;
458
458
  } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
459
459
 
460
+ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
461
+ [ComponentName in keyof Props]: (props: Props[ComponentName] & {
462
+ [key: string]: any;
463
+ }) => Props[ComponentName];
464
+ } & {
465
+ root: (props: RootProps & {
466
+ [key: string]: any;
467
+ }) => RootProps;
468
+ }>;
469
+ declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
470
+
460
471
  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>>;
461
472
 
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 };
473
+ export { type DefaultRootProps 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 ArrayField as G, type History as H, type IframeConfig as I, type ObjectField as J, type Adaptor as K, type ExternalFieldWithAdaptor as L, type MappedItem as M, type NumberField as N, type OnAction as O, type Permissions as P, type ExternalField as Q, type RootDataWithProps as R, type SelectField as S, type TextField as T, type UserGenerics as U, type Viewports as V, type CustomField as W, type Fields as X, type PuckContext as Y, type DefaultRootFieldProps as Z, type DefaultRootRenderProps as _, type Field as a, type DefaultComponentProps as a0, type WithId as a1, type WithPuckProps as a2, type AsFieldProps as a3, type WithChildren as a4, transformProps 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 ExtractRootPropsFromConfig as h, type ComponentDataMap as i, type Direction as j, type DragAxis as k, type Viewport as l, type OverrideKey as m, type FieldRenderFunctions as n, overrideKeys as o, type ItemWithId as p, type ArrayState as q, type PuckComponent as r, type ComponentConfig as s, type RootDataWithoutProps as t, type RootData as u, type ComponentData as v, type Content as w, type BaseField as x, type TextareaField as y, type RadioField as z };
package/dist/rsc.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as Config, U as UserGenerics } 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 } from './resolve-all-data-ChsqfT2w.mjs';
3
+ export { a6 as resolveAllData, a5 as transformProps } from './resolve-all-data-ChsqfT2w.mjs';
4
4
  import 'react';
5
5
 
6
6
  declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data }: {
package/dist/rsc.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as Config, U as UserGenerics } 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 } from './resolve-all-data-ChsqfT2w.js';
3
+ export { a6 as resolveAllData, a5 as transformProps } from './resolve-all-data-ChsqfT2w.js';
4
4
  import 'react';
5
5
 
6
6
  declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data }: {
package/dist/rsc.js CHANGED
@@ -68,7 +68,8 @@ var __async = (__this, __arguments, generator) => {
68
68
  var rsc_exports = {};
69
69
  __export(rsc_exports, {
70
70
  Render: () => Render,
71
- resolveAllData: () => resolveAllData
71
+ resolveAllData: () => resolveAllData,
72
+ transformProps: () => transformProps
72
73
  });
73
74
  module.exports = __toCommonJS(rsc_exports);
74
75
 
@@ -271,8 +272,42 @@ function resolveAllData(data, config, onResolveStart, onResolveEnd) {
271
272
  });
272
273
  });
273
274
  }
275
+
276
+ // lib/transform-props.ts
277
+ function transformProps(data, propTransforms) {
278
+ const mapItem = (item) => {
279
+ if (propTransforms[item.type]) {
280
+ return __spreadProps(__spreadValues({}, item), {
281
+ props: propTransforms[item.type](item.props)
282
+ });
283
+ }
284
+ return item;
285
+ };
286
+ const defaultedData = defaultData(data);
287
+ const rootProps = defaultedData.root.props || defaultedData.root;
288
+ let newRoot = __spreadValues({}, defaultedData.root);
289
+ if (propTransforms["root"]) {
290
+ if (defaultedData.root.props) {
291
+ newRoot.props = propTransforms["root"](rootProps);
292
+ } else {
293
+ newRoot = propTransforms["root"](rootProps);
294
+ }
295
+ }
296
+ const afterPropTransforms = __spreadProps(__spreadValues({}, defaultedData), {
297
+ root: newRoot,
298
+ content: defaultedData.content.map(mapItem),
299
+ zones: Object.keys(data.zones || {}).reduce(
300
+ (acc, zoneKey) => __spreadProps(__spreadValues({}, acc), {
301
+ [zoneKey]: data.zones[zoneKey].map(mapItem)
302
+ }),
303
+ {}
304
+ )
305
+ });
306
+ return afterPropTransforms;
307
+ }
274
308
  // Annotate the CommonJS export names for ESM import in node:
275
309
  0 && (module.exports = {
276
310
  Render,
277
- resolveAllData
311
+ resolveAllData,
312
+ transformProps
278
313
  });
package/dist/rsc.mjs CHANGED
@@ -4,8 +4,9 @@ import {
4
4
  init_react_import,
5
5
  resolveAllData,
6
6
  rootDroppableId,
7
- setupZone
8
- } from "./chunk-CHWFBYEM.mjs";
7
+ setupZone,
8
+ transformProps
9
+ } from "./chunk-4QIG6FWS.mjs";
9
10
 
10
11
  // rsc.tsx
11
12
  init_react_import();
@@ -76,5 +77,6 @@ function Render({ config, data }) {
76
77
  }
77
78
  export {
78
79
  Render,
79
- resolveAllData
80
+ resolveAllData,
81
+ transformProps
80
82
  };
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.18.3",
4
4
  "author": "Measured Corporation Ltd <hello@measured.co>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",
@@ -78,6 +78,6 @@
78
78
  "zustand": "^5.0.2"
79
79
  },
80
80
  "peerDependencies": {
81
- "react": "^17.0.0 || ^18.0.0 || ^19.0.0"
81
+ "react": "^18.0.0 || ^19.0.0"
82
82
  }
83
83
  }