@measured/puck 0.19.0-canary.32a6f78 → 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.
@@ -22,6 +22,7 @@ type FieldOption = {
22
22
  type FieldOptions = Array<FieldOption> | ReadonlyArray<FieldOption>;
23
23
  type BaseField = {
24
24
  label?: string;
25
+ labelIcon?: ReactElement;
25
26
  };
26
27
  type TextField = BaseField & {
27
28
  type: "text";
@@ -32,6 +33,7 @@ type NumberField = BaseField & {
32
33
  placeholder?: string;
33
34
  min?: number;
34
35
  max?: number;
36
+ step?: number;
35
37
  };
36
38
  type TextareaField = BaseField & {
37
39
  type: "textarea";
@@ -465,6 +467,17 @@ type PuckAction = {
465
467
  recordHistory?: boolean;
466
468
  } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
467
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
+
468
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>>;
469
482
 
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 };
483
+ export { type DefaultComponentProps as $, type AppState as A, type BaseData as B, type Config as C, type DropZoneProps as D, type RadioField as E, type FieldProps as F, type ArrayField as G, type History as H, type IframeConfig as I, type ObjectField as J, type Adaptor as K, type ExternalFieldWithAdaptor as L, type Metadata as M, type NumberField as N, type OnAction as O, type Permissions as P, type ExternalField as Q, type RootDataWithProps as R, type SelectField as S, type TextField as T, type UserGenerics as U, type Viewports as V, type CustomField as W, type PuckContext as X, type DefaultRootFieldProps as Y, type DefaultRootRenderProps as Z, type DefaultRootProps as _, type Field as a, type WithId as a0, type WithPuckProps as a1, type AsFieldProps as a2, type WithChildren as a3, type ExtractPropsFromConfig as a4, type ExtractRootPropsFromConfig as a5, transformProps as a6, resolveAllData as a7, type Data as b, type UiState as c, type Plugin as d, type Overrides as e, type PuckAction as f, type InitialHistory as g, type ComponentData as h, type Fields as i, type ComponentConfig as j, type Direction as k, type DragAxis as l, type Viewport as m, type OverrideKey as n, overrideKeys as o, type FieldRenderFunctions as p, type ItemWithId as q, type ArrayState as r, type PuckComponent as s, type RootDataWithoutProps as t, type RootData as u, type MappedItem as v, type ComponentDataMap as w, type Content as x, type BaseField as y, type TextareaField as z };
@@ -22,6 +22,7 @@ type FieldOption = {
22
22
  type FieldOptions = Array<FieldOption> | ReadonlyArray<FieldOption>;
23
23
  type BaseField = {
24
24
  label?: string;
25
+ labelIcon?: ReactElement;
25
26
  };
26
27
  type TextField = BaseField & {
27
28
  type: "text";
@@ -32,6 +33,7 @@ type NumberField = BaseField & {
32
33
  placeholder?: string;
33
34
  min?: number;
34
35
  max?: number;
36
+ step?: number;
35
37
  };
36
38
  type TextareaField = BaseField & {
37
39
  type: "textarea";
@@ -465,6 +467,17 @@ type PuckAction = {
465
467
  recordHistory?: boolean;
466
468
  } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
467
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
+
468
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>>;
469
482
 
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 };
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,12 +1,12 @@
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-D43Z4niC.mjs';
3
- export { a6 as resolveAllData } from './resolve-all-data-D43Z4niC.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, }: {
7
7
  config: UserConfig;
8
8
  data: G["UserData"];
9
- metadata: Metadata;
9
+ metadata?: Metadata;
10
10
  }): react_jsx_runtime.JSX.Element;
11
11
 
12
12
  export { Render };
package/dist/rsc.d.ts CHANGED
@@ -1,12 +1,12 @@
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-D43Z4niC.js';
3
- export { a6 as resolveAllData } from './resolve-all-data-D43Z4niC.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, }: {
7
7
  config: UserConfig;
8
8
  data: G["UserData"];
9
- metadata: Metadata;
9
+ metadata?: Metadata;
10
10
  }): react_jsx_runtime.JSX.Element;
11
11
 
12
12
  export { Render };
package/dist/rsc.js CHANGED
@@ -68,7 +68,8 @@ var __async = (__this, __arguments, generator) => {
68
68
  var rsc_exports = {};
69
69
  __export(rsc_exports, {
70
70
  Render: () => Render,
71
- resolveAllData: () => resolveAllData
71
+ resolveAllData: () => resolveAllData,
72
+ transformProps: () => transformProps
72
73
  });
73
74
  module.exports = __toCommonJS(rsc_exports);
74
75
 
@@ -76,7 +77,9 @@ module.exports = __toCommonJS(rsc_exports);
76
77
  var import_react = __toESM(require("react"));
77
78
 
78
79
  // lib/root-droppable-id.ts
79
- var rootDroppableId = "default-zone";
80
+ var rootAreaId = "root";
81
+ var rootZone = "default-zone";
82
+ var rootDroppableId = `${rootAreaId}:${rootZone}`;
80
83
 
81
84
  // lib/setup-zone.ts
82
85
  var setupZone = (data, zoneKey) => {
@@ -104,7 +107,7 @@ function DropZoneRender({
104
107
  if (!data || !config) {
105
108
  return null;
106
109
  }
107
- if (areaId && zone && zone !== rootDroppableId) {
110
+ if (areaId !== rootAreaId && zone !== rootZone) {
108
111
  zoneCompound = `${areaId}:${zone}`;
109
112
  content = setupZone(data, zoneCompound).zones[zoneCompound];
110
113
  }
@@ -167,7 +170,7 @@ function Render({
167
170
  {
168
171
  config,
169
172
  data,
170
- zone: rootDroppableId,
173
+ zone: rootZone,
171
174
  metadata
172
175
  }
173
176
  )
@@ -179,7 +182,7 @@ function Render({
179
182
  {
180
183
  config,
181
184
  data,
182
- zone: rootDroppableId,
185
+ zone: rootZone,
183
186
  metadata
184
187
  }
185
188
  );
@@ -314,8 +317,42 @@ function resolveAllData(_0, _1) {
314
317
  });
315
318
  });
316
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
+ }
317
353
  // Annotate the CommonJS export names for ESM import in node:
318
354
  0 && (module.exports = {
319
355
  Render,
320
- resolveAllData
356
+ resolveAllData,
357
+ transformProps
321
358
  });
package/dist/rsc.mjs CHANGED
@@ -3,9 +3,12 @@ import {
3
3
  __spreadValues,
4
4
  init_react_import,
5
5
  resolveAllData,
6
+ rootAreaId,
6
7
  rootDroppableId,
7
- setupZone
8
- } from "./chunk-FNRHXUGA.mjs";
8
+ rootZone,
9
+ setupZone,
10
+ transformProps
11
+ } from "./chunk-7N5DRY4G.mjs";
9
12
 
10
13
  // rsc.tsx
11
14
  init_react_import();
@@ -25,7 +28,7 @@ function DropZoneRender({
25
28
  if (!data || !config) {
26
29
  return null;
27
30
  }
28
- if (areaId && zone && zone !== rootDroppableId) {
31
+ if (areaId !== rootAreaId && zone !== rootZone) {
29
32
  zoneCompound = `${areaId}:${zone}`;
30
33
  content = setupZone(data, zoneCompound).zones[zoneCompound];
31
34
  }
@@ -88,7 +91,7 @@ function Render({
88
91
  {
89
92
  config,
90
93
  data,
91
- zone: rootDroppableId,
94
+ zone: rootZone,
92
95
  metadata
93
96
  }
94
97
  )
@@ -100,12 +103,13 @@ function Render({
100
103
  {
101
104
  config,
102
105
  data,
103
- zone: rootDroppableId,
106
+ zone: rootZone,
104
107
  metadata
105
108
  }
106
109
  );
107
110
  }
108
111
  export {
109
112
  Render,
110
- resolveAllData
113
+ resolveAllData,
114
+ transformProps
111
115
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.19.0-canary.32a6f78",
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",
@@ -27,7 +27,8 @@
27
27
  "require": "./dist/rsc.js"
28
28
  },
29
29
  "./puck.css": "./dist/index.css",
30
- "./dist/index.css": "./dist/index.css"
30
+ "./dist/index.css": "./dist/index.css",
31
+ "./package.json": "./package.json"
31
32
  },
32
33
  "typesVersions": {
33
34
  "*": {
@@ -71,11 +72,12 @@
71
72
  "@dnd-kit/helpers": "0.0.7-beta-20250130032138",
72
73
  "@dnd-kit/react": "0.0.7-beta-20250130032138",
73
74
  "deep-diff": "^1.0.2",
75
+ "fast-deep-equal": "^3.1.3",
74
76
  "object-hash": "^3.0.0",
75
77
  "react-hotkeys-hook": "^4.6.1",
76
78
  "use-debounce": "^9.0.4",
77
79
  "uuid": "^9.0.1",
78
- "zustand": "^5.0.2"
80
+ "zustand": "^4.5.6"
79
81
  },
80
82
  "peerDependencies": {
81
83
  "react": "^17.0.0 || ^18.0.0 || ^19.0.0"