@measured/puck 0.14.3-canary.9df6633 → 0.15.0-canary.aedd401

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -60,10 +60,7 @@ const config = {
60
60
  };
61
61
 
62
62
  // Describe the initial data
63
- const initialData = {
64
- content: [],
65
- root: {},
66
- };
63
+ const initialData = {};
67
64
 
68
65
  // Save the data to your database
69
66
  const save = (data) => {};
@@ -110,16 +110,12 @@ type ExternalField<Props extends {
110
110
  filterFields?: Record<string, Field>;
111
111
  initialFilters?: Record<string, any>;
112
112
  };
113
- type CustomField<Props extends {
114
- [key: string]: any;
115
- } = {
116
- [key: string]: any;
117
- }> = BaseField & {
113
+ type CustomField<Props extends any = {}> = BaseField & {
118
114
  type: "custom";
119
115
  render: (props: {
120
- field: CustomField;
116
+ field: CustomField<Props>;
121
117
  name: string;
122
- value: any;
118
+ value: Props;
123
119
  onChange: (value: Props) => void;
124
120
  readOnly?: boolean;
125
121
  }) => ReactElement;
@@ -128,7 +124,7 @@ type Field<Props extends {
128
124
  [key: string]: any;
129
125
  } = {
130
126
  [key: string]: any;
131
- }> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<Props> | ObjectField<Props> | ExternalField<Props> | ExternalFieldWithAdaptor<Props> | CustomField;
127
+ }> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<Props> | ObjectField<Props> | ExternalField<Props> | ExternalFieldWithAdaptor<Props> | CustomField<Props>;
132
128
  type DefaultRootProps = {
133
129
  title?: string;
134
130
  [key: string]: any;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { U as UiState, D as Data, A as AppState, C as Config, a as DefaultRootProps, I as ItemSelector, b as DropZoneProps, F as Field, V as Viewports, c as DefaultComponentProps, M as MappedItem, R as RootDataWithProps, d as RootData, e as ComponentData } from './Config-09628f3c.js';
2
- export { i as Adaptor, h as ArrayField, s as ArrayState, p as BaseData, B as BaseField, o as ComponentConfig, m as Content, k as CustomField, j as ExternalField, E as ExternalFieldWithAdaptor, l as Fields, r as ItemWithId, N as NumberField, O as ObjectField, P as PuckComponent, n as PuckContext, g as RadioField, q as RootDataWithoutProps, S as SelectField, T as TextField, f as TextareaField } from './Config-09628f3c.js';
1
+ import { U as UiState, D as Data, A as AppState, C as Config, a as DefaultRootProps, I as ItemSelector, b as DropZoneProps, F as Field, V as Viewports, c as DefaultComponentProps, M as MappedItem, R as RootDataWithProps, d as RootData, e as ComponentData } from './Config-550396e1.js';
2
+ export { i as Adaptor, h as ArrayField, s as ArrayState, p as BaseData, B as BaseField, o as ComponentConfig, m as Content, k as CustomField, j as ExternalField, E as ExternalFieldWithAdaptor, l as Fields, r as ItemWithId, N as NumberField, O as ObjectField, P as PuckComponent, n as PuckContext, g as RadioField, q as RootDataWithoutProps, S as SelectField, T as TextField, f as TextareaField } from './Config-550396e1.js';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as react from 'react';
5
5
  import { ReactNode, ReactElement, CSSProperties, SyntheticEvent } from 'react';
@@ -185,7 +185,7 @@ type Overrides = OverridesGeneric<{
185
185
  children: ReactNode;
186
186
  }>;
187
187
  headerActions: RenderFunc<{
188
- children?: ReactNode;
188
+ children: ReactNode;
189
189
  }>;
190
190
  preview: RenderFunc;
191
191
  fields: RenderFunc<{
@@ -232,7 +232,7 @@ type IframeConfig = {
232
232
  declare function Puck<UserConfig extends Config = Config>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe, dnd, }: {
233
233
  children?: ReactNode;
234
234
  config: UserConfig;
235
- data: Data;
235
+ data: Partial<Data>;
236
236
  ui?: Partial<UiState>;
237
237
  onChange?: (data: Data) => void;
238
238
  onPublish?: (data: Data) => void;
@@ -266,7 +266,7 @@ declare namespace Puck {
266
266
 
267
267
  declare function Render<UserConfig extends Config = Config>({ config, data, }: {
268
268
  config: UserConfig;
269
- data: Data;
269
+ data: Partial<Data>;
270
270
  }): react_jsx_runtime.JSX.Element;
271
271
 
272
272
  declare function migrate(data: Data): Data;
@@ -280,9 +280,9 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
280
280
  [key: string]: any;
281
281
  }) => RootProps;
282
282
  }>;
283
- declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultComponentProps>(data: Data, propTransforms: PropTransform<Props, RootProps>): Data;
283
+ declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultComponentProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
284
284
 
285
- declare function resolveAllData(data: Data, config: Config, onResolveStart?: (item: MappedItem) => void, onResolveEnd?: (item: MappedItem) => void): Promise<{
285
+ declare function resolveAllData(data: Partial<Data>, config: Config, onResolveStart?: (item: MappedItem) => void, onResolveEnd?: (item: MappedItem) => void): Promise<{
286
286
  root: RootDataWithProps<DefaultRootProps> | RootData<DefaultRootProps>;
287
287
  content: any[];
288
288
  zones: Record<string, MappedItem[]>;