@measured/puck 0.19.0-canary.24030a9 → 0.19.0-canary.46835fd

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.
@@ -467,6 +467,17 @@ type PuckAction = {
467
467
  recordHistory?: boolean;
468
468
  } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
469
469
 
470
+ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
471
+ [ComponentName in keyof Props]: (props: Props[ComponentName] & {
472
+ [key: string]: any;
473
+ }) => Props[ComponentName];
474
+ } & {
475
+ root: (props: RootProps & {
476
+ [key: string]: any;
477
+ }) => RootProps;
478
+ }>;
479
+ declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
480
+
470
481
  declare function resolveAllData<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, metadata?: Metadata, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Props, RootProps>>;
471
482
 
472
- export { type DefaultRootProps as $, type AppState as A, type BaseData as B, type Config as C, type DropZoneProps as D, type BaseField 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 Metadata 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 PuckContext as Z, type DefaultRootRenderProps as _, type Field as a, type WithId as a0, type WithPuckProps as a1, type AsFieldProps as a2, type WithChildren as a3, type ExtractPropsFromConfig as a4, type ExtractRootPropsFromConfig as a5, 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 ComponentData as j, type Fields as k, type ComponentConfig as l, type Direction as m, type DragAxis as n, type Viewport as o, overrideKeys as p, type OverrideKey as q, type FieldRenderFunctions as r, type ItemWithId as s, type ArrayState as t, type PuckComponent as u, type RootDataWithoutProps as v, type RootData as w, type MappedItem as x, type ComponentDataMap as y, type Content as z };
483
+ export { type DefaultComponentProps as $, type AppState as A, type BaseData as B, type Config as C, type DropZoneProps as D, type RadioField as E, type FieldProps as F, type ArrayField as G, type History as H, type IframeConfig as I, type ObjectField as J, type Adaptor as K, type ExternalFieldWithAdaptor as L, type Metadata as M, type NumberField as N, type OnAction as O, type Permissions as P, type ExternalField as Q, type RootDataWithProps as R, type SelectField as S, type TextField as T, type UserGenerics as U, type Viewports as V, type CustomField as W, type PuckContext as X, type DefaultRootFieldProps as Y, type DefaultRootRenderProps as Z, type DefaultRootProps as _, type Field as a, type WithId as a0, type WithPuckProps as a1, type AsFieldProps as a2, type WithChildren as a3, type ExtractPropsFromConfig as a4, type ExtractRootPropsFromConfig as a5, transformProps as a6, resolveAllData as a7, type Data as b, type UiState as c, type Plugin as d, type Overrides as e, type PuckAction as f, type InitialHistory as g, type ComponentData as h, type Fields as i, type ComponentConfig as j, type Direction as k, type DragAxis as l, type Viewport as m, type OverrideKey as n, overrideKeys as o, type FieldRenderFunctions as p, type ItemWithId as q, type ArrayState as r, type PuckComponent as s, type RootDataWithoutProps as t, type RootData as u, type MappedItem as v, type ComponentDataMap as w, type Content as x, type BaseField as y, type TextareaField as z };
@@ -467,6 +467,17 @@ type PuckAction = {
467
467
  recordHistory?: boolean;
468
468
  } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
469
469
 
470
+ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
471
+ [ComponentName in keyof Props]: (props: Props[ComponentName] & {
472
+ [key: string]: any;
473
+ }) => Props[ComponentName];
474
+ } & {
475
+ root: (props: RootProps & {
476
+ [key: string]: any;
477
+ }) => RootProps;
478
+ }>;
479
+ declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
480
+
470
481
  declare function resolveAllData<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends Record<string, any> = DefaultRootFieldProps>(data: Partial<Data>, config: Config, metadata?: Metadata, onResolveStart?: (item: ComponentData) => void, onResolveEnd?: (item: ComponentData) => void): Promise<Data<Props, RootProps>>;
471
482
 
472
- export { type DefaultRootProps as $, type AppState as A, type BaseData as B, type Config as C, type DropZoneProps as D, type BaseField 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 Metadata 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 PuckContext as Z, type DefaultRootRenderProps as _, type Field as a, type WithId as a0, type WithPuckProps as a1, type AsFieldProps as a2, type WithChildren as a3, type ExtractPropsFromConfig as a4, type ExtractRootPropsFromConfig as a5, 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 ComponentData as j, type Fields as k, type ComponentConfig as l, type Direction as m, type DragAxis as n, type Viewport as o, overrideKeys as p, type OverrideKey as q, type FieldRenderFunctions as r, type ItemWithId as s, type ArrayState as t, type PuckComponent as u, type RootDataWithoutProps as v, type RootData as w, type MappedItem as x, type ComponentDataMap as y, type Content as z };
483
+ export { type DefaultComponentProps as $, type AppState as A, type BaseData as B, type Config as C, type DropZoneProps as D, type RadioField as E, type FieldProps as F, type ArrayField as G, type History as H, type IframeConfig as I, type ObjectField as J, type Adaptor as K, type ExternalFieldWithAdaptor as L, type Metadata as M, type NumberField as N, type OnAction as O, type Permissions as P, type ExternalField as Q, type RootDataWithProps as R, type SelectField as S, type TextField as T, type UserGenerics as U, type Viewports as V, type CustomField as W, type PuckContext as X, type DefaultRootFieldProps as Y, type DefaultRootRenderProps as Z, type DefaultRootProps as _, type Field as a, type WithId as a0, type WithPuckProps as a1, type AsFieldProps as a2, type WithChildren as a3, type ExtractPropsFromConfig as a4, type ExtractRootPropsFromConfig as a5, transformProps as a6, resolveAllData as a7, type Data as b, type UiState as c, type Plugin as d, type Overrides as e, type PuckAction as f, type InitialHistory as g, type ComponentData as h, type Fields as i, type ComponentConfig as j, type Direction as k, type DragAxis as l, type Viewport as m, type OverrideKey as n, overrideKeys as o, type FieldRenderFunctions as p, type ItemWithId as q, type ArrayState as r, type PuckComponent as s, type RootDataWithoutProps as t, type RootData as u, type MappedItem as v, type ComponentDataMap as w, type Content as x, type BaseField as y, type TextareaField as z };
package/dist/rsc.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as Config, U as UserGenerics, M as Metadata } from './resolve-all-data-DleIzc4N.mjs';
3
- export { a6 as resolveAllData } from './resolve-all-data-DleIzc4N.mjs';
2
+ import { C as Config, U as UserGenerics, M as Metadata } from './resolve-all-data-3XjIPfNh.mjs';
3
+ export { a7 as resolveAllData, a6 as transformProps } from './resolve-all-data-3XjIPfNh.mjs';
4
4
  import 'react';
5
5
 
6
6
  declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
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, M as Metadata } from './resolve-all-data-DleIzc4N.js';
3
- export { a6 as resolveAllData } from './resolve-all-data-DleIzc4N.js';
2
+ import { C as Config, U as UserGenerics, M as Metadata } from './resolve-all-data-3XjIPfNh.js';
3
+ export { a7 as resolveAllData, a6 as transformProps } from './resolve-all-data-3XjIPfNh.js';
4
4
  import 'react';
5
5
 
6
6
  declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
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
 
@@ -316,8 +317,42 @@ function resolveAllData(_0, _1) {
316
317
  });
317
318
  });
318
319
  }
320
+
321
+ // lib/transform-props.ts
322
+ function transformProps(data, propTransforms) {
323
+ const mapItem = (item) => {
324
+ if (propTransforms[item.type]) {
325
+ return __spreadProps(__spreadValues({}, item), {
326
+ props: propTransforms[item.type](item.props)
327
+ });
328
+ }
329
+ return item;
330
+ };
331
+ const defaultedData = defaultData(data);
332
+ const rootProps = defaultedData.root.props || defaultedData.root;
333
+ let newRoot = __spreadValues({}, defaultedData.root);
334
+ if (propTransforms["root"]) {
335
+ if (defaultedData.root.props) {
336
+ newRoot.props = propTransforms["root"](rootProps);
337
+ } else {
338
+ newRoot = propTransforms["root"](rootProps);
339
+ }
340
+ }
341
+ const afterPropTransforms = __spreadProps(__spreadValues({}, defaultedData), {
342
+ root: newRoot,
343
+ content: defaultedData.content.map(mapItem),
344
+ zones: Object.keys(data.zones || {}).reduce(
345
+ (acc, zoneKey) => __spreadProps(__spreadValues({}, acc), {
346
+ [zoneKey]: data.zones[zoneKey].map(mapItem)
347
+ }),
348
+ {}
349
+ )
350
+ });
351
+ return afterPropTransforms;
352
+ }
319
353
  // Annotate the CommonJS export names for ESM import in node:
320
354
  0 && (module.exports = {
321
355
  Render,
322
- resolveAllData
356
+ resolveAllData,
357
+ transformProps
323
358
  });
package/dist/rsc.mjs CHANGED
@@ -6,8 +6,9 @@ import {
6
6
  rootAreaId,
7
7
  rootDroppableId,
8
8
  rootZone,
9
- setupZone
10
- } from "./chunk-T6VJEBJD.mjs";
9
+ setupZone,
10
+ transformProps
11
+ } from "./chunk-7N5DRY4G.mjs";
11
12
 
12
13
  // rsc.tsx
13
14
  init_react_import();
@@ -109,5 +110,6 @@ function Render({
109
110
  }
110
111
  export {
111
112
  Render,
112
- resolveAllData
113
+ resolveAllData,
114
+ transformProps
113
115
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.19.0-canary.24030a9",
3
+ "version": "0.19.0-canary.46835fd",
4
4
  "author": "Measured Corporation Ltd <hello@measured.co>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",
@@ -77,7 +77,7 @@
77
77
  "react-hotkeys-hook": "^4.6.1",
78
78
  "use-debounce": "^9.0.4",
79
79
  "uuid": "^9.0.1",
80
- "zustand": "^5.0.2"
80
+ "zustand": "^4.5.6"
81
81
  },
82
82
  "peerDependencies": {
83
83
  "react": "^17.0.0 || ^18.0.0 || ^19.0.0"