@measured/puck 0.16.0-canary.f0655f0 → 0.16.0-canary.fc564d7

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.
@@ -0,0 +1,250 @@
1
+ import { F as Field, a as FieldProps, C as Config, D as Data, I as ItemSelector, P as PuckAction, b as DropZoneProps, U as UserGenerics, c as UiState, O as OnAction, d as Permissions, e as Plugin, f as Overrides, V as Viewports, g as IframeConfig, h as InitialHistory, i as DefaultComponentProps, j as DefaultRootFieldProps, k as ComponentData, H as History, A as AppState, E as ExtractPropsFromConfig, l as ExtractRootPropsFromConfig, m as ComponentDataMap } from './actions-9pHbVtMU.mjs';
2
+ export { L as Adaptor, J as ArrayField, s as ArrayState, a2 as AsFieldProps, B as BaseData, y as BaseField, u as ComponentConfig, x as Content, X as CustomField, $ as DefaultRootProps, _ as DefaultRootRenderProps, W as ExternalField, Q as ExternalFieldWithAdaptor, q as FieldRenderFunctions, Y as Fields, r as ItemWithId, M as MappedItem, N as NumberField, K as ObjectField, p as OverrideKey, t as PuckComponent, Z as PuckContext, G as RadioField, w as RootData, R as RootDataWithProps, v as RootDataWithoutProps, S as SelectField, T as TextField, z as TextareaField, n as Viewport, a3 as WithChildren, a0 as WithId, a1 as WithPuckProps, o as overrideKeys } from './actions-9pHbVtMU.mjs';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import * as react from 'react';
5
+ import { ReactNode, SyntheticEvent, ReactElement, CSSProperties } from 'react';
6
+ import { DragStart, DragUpdate } from '@measured/dnd';
7
+
8
+ declare const ActionBar: {
9
+ ({ label, children, }: {
10
+ label?: string;
11
+ children?: ReactNode;
12
+ }): react_jsx_runtime.JSX.Element;
13
+ Action: ({ children, label, onClick, }: {
14
+ children: ReactNode;
15
+ label?: string;
16
+ onClick: (e: SyntheticEvent) => void;
17
+ }) => react_jsx_runtime.JSX.Element;
18
+ Group: ({ children }: {
19
+ children: ReactNode;
20
+ }) => react_jsx_runtime.JSX.Element;
21
+ };
22
+ declare const Action: ({ children, label, onClick, }: {
23
+ children: ReactNode;
24
+ label?: string;
25
+ onClick: (e: SyntheticEvent) => void;
26
+ }) => react_jsx_runtime.JSX.Element;
27
+ declare const Group: ({ children }: {
28
+ children: ReactNode;
29
+ }) => react_jsx_runtime.JSX.Element;
30
+
31
+ declare const FieldLabel: ({ children, icon, label, el, readOnly, className, }: {
32
+ children?: ReactNode;
33
+ icon?: ReactNode;
34
+ label: string;
35
+ el?: "label" | "div";
36
+ readOnly?: boolean;
37
+ className?: string;
38
+ }) => react_jsx_runtime.JSX.Element;
39
+ type FieldLabelPropsInternal = {
40
+ children?: ReactNode;
41
+ icon?: ReactNode;
42
+ label?: string;
43
+ el?: "label" | "div";
44
+ readOnly?: boolean;
45
+ };
46
+ declare const FieldLabelInternal: ({ children, icon, label, el, readOnly, }: FieldLabelPropsInternal) => react_jsx_runtime.JSX.Element;
47
+ type FieldPropsInternalOptional<ValueType = any, F = Field<any>> = FieldProps<ValueType, F> & {
48
+ Label?: React.FC<FieldLabelPropsInternal>;
49
+ label?: string;
50
+ name?: string;
51
+ };
52
+ type FieldPropsInternal<ValueType = any, F = Field<any>> = FieldProps<ValueType, F> & {
53
+ Label: React.FC<FieldLabelPropsInternal>;
54
+ label?: string;
55
+ id: string;
56
+ name?: string;
57
+ };
58
+ declare function AutoFieldPrivate<ValueType = any, FieldType extends Field<ValueType> = Field<ValueType>>(props: FieldPropsInternalOptional<ValueType, FieldType> & {
59
+ Label?: React.FC<FieldLabelPropsInternal>;
60
+ }): react_jsx_runtime.JSX.Element;
61
+ declare function AutoField<ValueType = any, FieldType extends Field<ValueType> = Field<ValueType>>(props: FieldProps<ValueType, FieldType>): react_jsx_runtime.JSX.Element;
62
+
63
+ declare const Button: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, icon, size, loading: loadingProp, }: {
64
+ children: ReactNode;
65
+ href?: string;
66
+ onClick?: (e: any) => void | Promise<void>;
67
+ variant?: "primary" | "secondary";
68
+ type?: "button" | "submit" | "reset";
69
+ disabled?: boolean;
70
+ tabIndex?: number;
71
+ newTab?: boolean;
72
+ fullWidth?: boolean;
73
+ icon?: ReactNode;
74
+ size?: "medium" | "large";
75
+ loading?: boolean;
76
+ }) => react_jsx_runtime.JSX.Element;
77
+
78
+ declare const Drawer: {
79
+ ({ children, droppableId: _droppableId, direction, }: {
80
+ children: ReactNode;
81
+ droppableId?: string;
82
+ direction?: "vertical" | "horizontal";
83
+ }): react_jsx_runtime.JSX.Element;
84
+ Item: ({ name, children, id, label, index, isDragDisabled, }: {
85
+ name: string;
86
+ children?: (props: {
87
+ children: ReactNode;
88
+ name: string;
89
+ }) => ReactElement;
90
+ id?: string;
91
+ label?: string;
92
+ index: number;
93
+ isDragDisabled?: boolean;
94
+ }) => react_jsx_runtime.JSX.Element;
95
+ };
96
+
97
+ type PathData = Record<string, {
98
+ path: string[];
99
+ label: string;
100
+ }>;
101
+ type DropZoneContext<UserConfig extends Config = Config> = {
102
+ data: Data;
103
+ config: UserConfig;
104
+ componentState?: Record<string, any>;
105
+ itemSelector?: ItemSelector | null;
106
+ setItemSelector?: (newIndex: ItemSelector | null) => void;
107
+ dispatch?: (action: PuckAction) => void;
108
+ areaId?: string;
109
+ draggedItem?: DragStart & Partial<DragUpdate>;
110
+ placeholderStyle?: CSSProperties;
111
+ hoveringArea?: string | null;
112
+ setHoveringArea?: (area: string | null) => void;
113
+ hoveringZone?: string | null;
114
+ setHoveringZone?: (zone: string | null) => void;
115
+ hoveringComponent?: string | null;
116
+ setHoveringComponent?: (id: string | null) => void;
117
+ registerZoneArea?: (areaId: string) => void;
118
+ areasWithZones?: Record<string, boolean>;
119
+ registerZone?: (zoneCompound: string) => void;
120
+ unregisterZone?: (zoneCompound: string) => void;
121
+ activeZones?: Record<string, boolean>;
122
+ pathData?: PathData;
123
+ registerPath?: (selector: ItemSelector) => void;
124
+ mode?: "edit" | "render";
125
+ zoneWillDrag?: string;
126
+ setZoneWillDrag?: (zone: string) => void;
127
+ } | null;
128
+ declare const dropZoneContext: react.Context<DropZoneContext<Config>>;
129
+ declare const DropZoneProvider: ({ children, value, }: {
130
+ children: ReactNode;
131
+ value: DropZoneContext;
132
+ }) => react_jsx_runtime.JSX.Element;
133
+
134
+ declare function DropZone(props: DropZoneProps): react_jsx_runtime.JSX.Element;
135
+
136
+ declare const IconButton: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, title, }: {
137
+ children: ReactNode;
138
+ href?: string;
139
+ onClick?: (e: SyntheticEvent) => void | Promise<void>;
140
+ variant?: "primary" | "secondary";
141
+ type?: "button" | "submit" | "reset";
142
+ disabled?: boolean;
143
+ tabIndex?: number;
144
+ newTab?: boolean;
145
+ fullWidth?: boolean;
146
+ title: string;
147
+ }) => react_jsx_runtime.JSX.Element;
148
+
149
+ 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, }: {
150
+ children?: ReactNode;
151
+ config: UserConfig;
152
+ data: Partial<G["UserData"] | Data>;
153
+ ui?: Partial<UiState>;
154
+ onChange?: (data: G["UserData"]) => void;
155
+ onPublish?: (data: G["UserData"]) => void;
156
+ onAction?: OnAction<G["UserData"]>;
157
+ permissions?: Partial<Permissions>;
158
+ plugins?: Plugin[];
159
+ overrides?: Partial<Overrides>;
160
+ renderHeader?: (props: {
161
+ children: ReactNode;
162
+ dispatch: (action: PuckAction) => void;
163
+ state: G["UserAppState"];
164
+ }) => ReactElement;
165
+ renderHeaderActions?: (props: {
166
+ state: G["UserAppState"];
167
+ dispatch: (action: PuckAction) => void;
168
+ }) => ReactElement;
169
+ headerTitle?: string;
170
+ headerPath?: string;
171
+ viewports?: Viewports;
172
+ iframe?: IframeConfig;
173
+ dnd?: {
174
+ disableAutoScroll?: boolean;
175
+ };
176
+ initialHistory?: InitialHistory;
177
+ }): react_jsx_runtime.JSX.Element;
178
+ declare namespace Puck {
179
+ var Components: () => react_jsx_runtime.JSX.Element;
180
+ var Fields: () => react_jsx_runtime.JSX.Element;
181
+ var Outline: () => react_jsx_runtime.JSX.Element;
182
+ var Preview: ({ id }: {
183
+ id?: string;
184
+ }) => react_jsx_runtime.JSX.Element;
185
+ }
186
+
187
+ declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, }: {
188
+ config: UserConfig;
189
+ data: Partial<G["UserData"] | Data>;
190
+ }): react_jsx_runtime.JSX.Element;
191
+
192
+ declare function migrate(data: Data): Data;
193
+
194
+ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
195
+ [ComponentName in keyof Props]: (props: Props[ComponentName] & {
196
+ [key: string]: any;
197
+ }) => Props[ComponentName];
198
+ } & {
199
+ root: (props: RootProps & {
200
+ [key: string]: any;
201
+ }) => RootProps;
202
+ }>;
203
+ declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
204
+
205
+ 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>>;
206
+
207
+ type HistoryStore<D = any> = {
208
+ index: number;
209
+ hasPast: boolean;
210
+ hasFuture: boolean;
211
+ histories: History<D>[];
212
+ record: (data: D) => void;
213
+ back: VoidFunction;
214
+ forward: VoidFunction;
215
+ currentHistory: History;
216
+ nextHistory: History<D> | null;
217
+ prevHistory: History<D> | null;
218
+ setHistories: (histories: History[]) => void;
219
+ setHistoryIndex: (index: number) => void;
220
+ };
221
+
222
+ type PermissionsArgs<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
223
+ item?: G["UserComponentData"];
224
+ type?: keyof G["UserProps"];
225
+ root?: boolean;
226
+ };
227
+ type GetPermissions<UserConfig extends Config = Config> = (params?: PermissionsArgs<UserConfig>) => Partial<Permissions>;
228
+ type RefreshPermissions<UserConfig extends Config = Config> = (params?: PermissionsArgs<UserConfig>, force?: boolean) => void;
229
+
230
+ declare const usePuck: <UserConfig extends Config = Config>() => {
231
+ appState: AppState<Data<ExtractPropsFromConfig<UserConfig>, ExtractRootPropsFromConfig<UserConfig>>>;
232
+ config: UserConfig;
233
+ dispatch: (action: PuckAction) => void;
234
+ getPermissions: GetPermissions<UserConfig>;
235
+ refreshPermissions: RefreshPermissions<UserConfig>;
236
+ history: {
237
+ back: VoidFunction;
238
+ forward: VoidFunction;
239
+ setHistories: (histories: History[]) => void;
240
+ setHistoryIndex: (index: number) => void;
241
+ hasPast: boolean;
242
+ hasFuture: boolean;
243
+ histories: History<any>[];
244
+ index: number;
245
+ historyStore: HistoryStore | undefined;
246
+ };
247
+ selectedItem: ComponentDataMap<ExtractPropsFromConfig<UserConfig>> | null;
248
+ };
249
+
250
+ export { Action, ActionBar, AppState, AutoField, AutoFieldPrivate, Button, ComponentData, ComponentDataMap, Config, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, DropZone, DropZoneProvider, ExtractPropsFromConfig, ExtractRootPropsFromConfig, Field, FieldLabel, FieldLabelInternal, FieldProps, type FieldPropsInternal, Group, History, IconButton, IframeConfig, InitialHistory, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, Render, UiState, UserGenerics, Viewports, dropZoneContext, migrate, resolveAllData, transformProps, usePuck };
package/dist/index.d.ts CHANGED
@@ -1,133 +1,10 @@
1
- import { U as UiState, D as Data, A as AppState, I as ItemSelector, F as Field, a as FieldProps, C as Config, b as DropZoneProps, P as Permissions, V as Viewports, c as DefaultComponentProps, d as DefaultRootProps, M as MappedItem, R as RootData, e as RootDataWithProps, f as ComponentData } from './Config-CkVFT1_w.js';
2
- export { r as Adaptor, q as ArrayField, m as ArrayState, B as BaseData, n as BaseField, j as ComponentConfig, g as Content, t as CustomField, s as ExternalField, E as ExternalFieldWithAdaptor, u as Fields, l as ItemWithId, N as NumberField, O as ObjectField, h as PuckComponent, i as PuckContext, p as RadioField, k as RootDataWithoutProps, S as SelectField, T as TextField, o as TextareaField } from './Config-CkVFT1_w.js';
3
- import * as react from 'react';
4
- import { ReactNode, ReactElement, SyntheticEvent, CSSProperties } from 'react';
1
+ import { F as Field, a as FieldProps, C as Config, D as Data, I as ItemSelector, P as PuckAction, b as DropZoneProps, U as UserGenerics, c as UiState, O as OnAction, d as Permissions, e as Plugin, f as Overrides, V as Viewports, g as IframeConfig, h as InitialHistory, i as DefaultComponentProps, j as DefaultRootFieldProps, k as ComponentData, H as History, A as AppState, E as ExtractPropsFromConfig, l as ExtractRootPropsFromConfig, m as ComponentDataMap } from './actions-9pHbVtMU.js';
2
+ export { L as Adaptor, J as ArrayField, s as ArrayState, a2 as AsFieldProps, B as BaseData, y as BaseField, u as ComponentConfig, x as Content, X as CustomField, $ as DefaultRootProps, _ as DefaultRootRenderProps, W as ExternalField, Q as ExternalFieldWithAdaptor, q as FieldRenderFunctions, Y as Fields, r as ItemWithId, M as MappedItem, N as NumberField, K as ObjectField, p as OverrideKey, t as PuckComponent, Z as PuckContext, G as RadioField, w as RootData, R as RootDataWithProps, v as RootDataWithoutProps, S as SelectField, T as TextField, z as TextareaField, n as Viewport, a3 as WithChildren, a0 as WithId, a1 as WithPuckProps, o as overrideKeys } from './actions-9pHbVtMU.js';
5
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import * as react from 'react';
5
+ import { ReactNode, SyntheticEvent, ReactElement, CSSProperties } from 'react';
6
6
  import { DragStart, DragUpdate } from '@measured/dnd';
7
7
 
8
- type InsertAction = {
9
- type: "insert";
10
- componentType: string;
11
- destinationIndex: number;
12
- destinationZone: string;
13
- id?: string;
14
- };
15
- type DuplicateAction = {
16
- type: "duplicate";
17
- sourceIndex: number;
18
- sourceZone: string;
19
- };
20
- type ReplaceAction = {
21
- type: "replace";
22
- destinationIndex: number;
23
- destinationZone: string;
24
- data: any;
25
- };
26
- type ReorderAction = {
27
- type: "reorder";
28
- sourceIndex: number;
29
- destinationIndex: number;
30
- destinationZone: string;
31
- };
32
- type MoveAction = {
33
- type: "move";
34
- sourceIndex: number;
35
- sourceZone: string;
36
- destinationIndex: number;
37
- destinationZone: string;
38
- };
39
- type RemoveAction = {
40
- type: "remove";
41
- index: number;
42
- zone: string;
43
- };
44
- type SetUiAction = {
45
- type: "setUi";
46
- ui: Partial<UiState> | ((previous: UiState) => Partial<UiState>);
47
- };
48
- type SetDataAction = {
49
- type: "setData";
50
- data: Partial<Data> | ((previous: Data) => Partial<Data>);
51
- };
52
- type SetAction = {
53
- type: "set";
54
- state: Partial<AppState> | ((previous: AppState) => Partial<AppState>);
55
- };
56
- type RegisterZoneAction = {
57
- type: "registerZone";
58
- zone: string;
59
- };
60
- type UnregisterZoneAction = {
61
- type: "unregisterZone";
62
- zone: string;
63
- };
64
- type PuckAction = {
65
- recordHistory?: boolean;
66
- } & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
67
-
68
- type RenderFunc<Props extends {
69
- [key: string]: any;
70
- } = {
71
- children: ReactNode;
72
- }> = (props: Props) => ReactElement;
73
- declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "components", "componentItem", "outline", "puck", "preview"];
74
- type OverrideKey = (typeof overrideKeys)[number];
75
- type OverridesGeneric<Shape extends {
76
- [key in OverrideKey]: any;
77
- }> = Shape;
78
- type Overrides = OverridesGeneric<{
79
- fieldTypes: Partial<FieldRenderFunctions>;
80
- header: RenderFunc<{
81
- actions: ReactNode;
82
- children: ReactNode;
83
- }>;
84
- actionBar: RenderFunc<{
85
- label?: string;
86
- children: ReactNode;
87
- }>;
88
- headerActions: RenderFunc<{
89
- children: ReactNode;
90
- }>;
91
- preview: RenderFunc;
92
- fields: RenderFunc<{
93
- children: ReactNode;
94
- isLoading: boolean;
95
- itemSelector?: ItemSelector | null;
96
- }>;
97
- fieldLabel: RenderFunc<{
98
- children?: ReactNode;
99
- icon?: ReactNode;
100
- label: string;
101
- el?: "label" | "div";
102
- readOnly?: boolean;
103
- className?: string;
104
- }>;
105
- components: RenderFunc;
106
- componentItem: RenderFunc<{
107
- children: ReactNode;
108
- name: string;
109
- }>;
110
- outline: RenderFunc;
111
- puck: RenderFunc;
112
- }>;
113
- type FieldRenderFunctions = Omit<{
114
- [Type in Field["type"]]: React.FunctionComponent<FieldProps<Extract<Field, {
115
- type: Type;
116
- }>> & {
117
- children: ReactNode;
118
- name: string;
119
- }>;
120
- }, "custom"> & {
121
- [key: string]: React.FunctionComponent<FieldProps<any> & {
122
- children: ReactNode;
123
- name: string;
124
- }>;
125
- };
126
-
127
- type Plugin = {
128
- overrides: Partial<Overrides>;
129
- };
130
-
131
8
  declare const ActionBar: {
132
9
  ({ label, children, }: {
133
10
  label?: string;
@@ -138,12 +15,18 @@ declare const ActionBar: {
138
15
  label?: string;
139
16
  onClick: (e: SyntheticEvent) => void;
140
17
  }) => react_jsx_runtime.JSX.Element;
18
+ Group: ({ children }: {
19
+ children: ReactNode;
20
+ }) => react_jsx_runtime.JSX.Element;
141
21
  };
142
22
  declare const Action: ({ children, label, onClick, }: {
143
23
  children: ReactNode;
144
24
  label?: string;
145
25
  onClick: (e: SyntheticEvent) => void;
146
26
  }) => react_jsx_runtime.JSX.Element;
27
+ declare const Group: ({ children }: {
28
+ children: ReactNode;
29
+ }) => react_jsx_runtime.JSX.Element;
147
30
 
148
31
  declare const FieldLabel: ({ children, icon, label, el, readOnly, className, }: {
149
32
  children?: ReactNode;
@@ -211,27 +94,6 @@ declare const Drawer: {
211
94
  }) => react_jsx_runtime.JSX.Element;
212
95
  };
213
96
 
214
- type History<D = any> = {
215
- id: string;
216
- data: D;
217
- };
218
- type HistoryStore<D = any> = {
219
- index: number;
220
- hasPast: boolean;
221
- hasFuture: boolean;
222
- histories: History<D>[];
223
- record: (data: D) => void;
224
- back: VoidFunction;
225
- forward: VoidFunction;
226
- currentHistory: History;
227
- nextHistory: History<D> | null;
228
- prevHistory: History<D> | null;
229
- setHistories: (histories: History[]) => void;
230
- setHistoryIndex: (index: number) => void;
231
- };
232
-
233
- type OnAction = (action: PuckAction, appState: AppState, prevAppState: AppState) => void;
234
-
235
97
  type PathData = Record<string, {
236
98
  path: string[];
237
99
  label: string;
@@ -284,28 +146,24 @@ declare const IconButton: ({ children, href, onClick, variant, type, disabled, t
284
146
  title: string;
285
147
  }) => react_jsx_runtime.JSX.Element;
286
148
 
287
- type IframeConfig = {
288
- enabled?: boolean;
289
- };
290
-
291
- declare function Puck<UserConfig extends Config = Config>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, onAction, permissions, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe, dnd, initialHistory, }: {
149
+ 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, }: {
292
150
  children?: ReactNode;
293
151
  config: UserConfig;
294
- data: Partial<Data>;
152
+ data: Partial<G["UserData"] | Data>;
295
153
  ui?: Partial<UiState>;
296
- onChange?: (data: Data) => void;
297
- onPublish?: (data: Data) => void;
298
- onAction?: OnAction;
154
+ onChange?: (data: G["UserData"]) => void;
155
+ onPublish?: (data: G["UserData"]) => void;
156
+ onAction?: OnAction<G["UserData"]>;
299
157
  permissions?: Partial<Permissions>;
300
158
  plugins?: Plugin[];
301
159
  overrides?: Partial<Overrides>;
302
160
  renderHeader?: (props: {
303
161
  children: ReactNode;
304
162
  dispatch: (action: PuckAction) => void;
305
- state: AppState;
163
+ state: G["UserAppState"];
306
164
  }) => ReactElement;
307
165
  renderHeaderActions?: (props: {
308
- state: AppState;
166
+ state: G["UserAppState"];
309
167
  dispatch: (action: PuckAction) => void;
310
168
  }) => ReactElement;
311
169
  headerTitle?: string;
@@ -315,10 +173,7 @@ declare function Puck<UserConfig extends Config = Config>({ children, config, da
315
173
  dnd?: {
316
174
  disableAutoScroll?: boolean;
317
175
  };
318
- initialHistory?: {
319
- histories: History<any>[];
320
- index: number;
321
- };
176
+ initialHistory?: InitialHistory;
322
177
  }): react_jsx_runtime.JSX.Element;
323
178
  declare namespace Puck {
324
179
  var Components: () => react_jsx_runtime.JSX.Element;
@@ -329,14 +184,14 @@ declare namespace Puck {
329
184
  }) => react_jsx_runtime.JSX.Element;
330
185
  }
331
186
 
332
- declare function Render<UserConfig extends Config = Config>({ config, data, }: {
187
+ declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, }: {
333
188
  config: UserConfig;
334
- data: Partial<Data>;
189
+ data: Partial<G["UserData"] | Data>;
335
190
  }): react_jsx_runtime.JSX.Element;
336
191
 
337
192
  declare function migrate(data: Data): Data;
338
193
 
339
- type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultRootProps = DefaultRootProps> = Partial<{
194
+ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
340
195
  [ComponentName in keyof Props]: (props: Props[ComponentName] & {
341
196
  [key: string]: any;
342
197
  }) => Props[ComponentName];
@@ -345,29 +200,39 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
345
200
  [key: string]: any;
346
201
  }) => RootProps;
347
202
  }>;
348
- declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultComponentProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
203
+ declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
349
204
 
350
- declare function resolveAllData(data: Partial<Data>, config: Config, onResolveStart?: (item: MappedItem) => void, onResolveEnd?: (item: MappedItem) => void): Promise<{
351
- root: RootData<DefaultRootProps> | RootDataWithProps;
352
- content: any;
353
- zones: Record<string, MappedItem[]>;
354
- }>;
205
+ 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>>;
206
+
207
+ type HistoryStore<D = any> = {
208
+ index: number;
209
+ hasPast: boolean;
210
+ hasFuture: boolean;
211
+ histories: History<D>[];
212
+ record: (data: D) => void;
213
+ back: VoidFunction;
214
+ forward: VoidFunction;
215
+ currentHistory: History;
216
+ nextHistory: History<D> | null;
217
+ prevHistory: History<D> | null;
218
+ setHistories: (histories: History[]) => void;
219
+ setHistoryIndex: (index: number) => void;
220
+ };
221
+
222
+ type PermissionsArgs<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
223
+ item?: G["UserComponentData"];
224
+ type?: keyof G["UserProps"];
225
+ root?: boolean;
226
+ };
227
+ type GetPermissions<UserConfig extends Config = Config> = (params?: PermissionsArgs<UserConfig>) => Partial<Permissions>;
228
+ type RefreshPermissions<UserConfig extends Config = Config> = (params?: PermissionsArgs<UserConfig>, force?: boolean) => void;
355
229
 
356
- declare const usePuck: () => {
357
- appState: AppState;
358
- config: Config;
230
+ declare const usePuck: <UserConfig extends Config = Config>() => {
231
+ appState: AppState<Data<ExtractPropsFromConfig<UserConfig>, ExtractRootPropsFromConfig<UserConfig>>>;
232
+ config: UserConfig;
359
233
  dispatch: (action: PuckAction) => void;
360
- getPermissions: ({ item, type, }?: {
361
- item?: ComponentData;
362
- type?: keyof DefaultComponentProps;
363
- }) => {
364
- [x: string]: boolean | undefined;
365
- drag?: boolean | undefined;
366
- duplicate?: boolean | undefined;
367
- delete?: boolean | undefined;
368
- edit?: boolean | undefined;
369
- insert?: boolean | undefined;
370
- };
234
+ getPermissions: GetPermissions<UserConfig>;
235
+ refreshPermissions: RefreshPermissions<UserConfig>;
371
236
  history: {
372
237
  back: VoidFunction;
373
238
  forward: VoidFunction;
@@ -379,9 +244,7 @@ declare const usePuck: () => {
379
244
  index: number;
380
245
  historyStore: HistoryStore | undefined;
381
246
  };
382
- selectedItem: ComponentData<DefaultComponentProps & {
383
- id: string;
384
- }> | null;
247
+ selectedItem: ComponentDataMap<ExtractPropsFromConfig<UserConfig>> | null;
385
248
  };
386
249
 
387
- export { Action, ActionBar, AppState, AutoField, AutoFieldPrivate, Button, ComponentData, Config, Data, DefaultComponentProps, DefaultRootProps, Drawer, DropZone, DropZoneProvider, Field, FieldLabel, FieldLabelInternal, FieldProps, type FieldPropsInternal, type History, IconButton, MappedItem, Permissions, type Plugin, Puck, type PuckAction, Render, RootData, RootDataWithProps, UiState, dropZoneContext, migrate, resolveAllData, transformProps, usePuck };
250
+ export { Action, ActionBar, AppState, AutoField, AutoFieldPrivate, Button, ComponentData, ComponentDataMap, Config, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, DropZone, DropZoneProvider, ExtractPropsFromConfig, ExtractRootPropsFromConfig, Field, FieldLabel, FieldLabelInternal, FieldProps, type FieldPropsInternal, Group, History, IconButton, IframeConfig, InitialHistory, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, Render, UiState, UserGenerics, Viewports, dropZoneContext, migrate, resolveAllData, transformProps, usePuck };