@measured/puck 0.16.0-canary.6d43ba0 → 0.16.0-canary.72b8720

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.
package/dist/index.d.mts CHANGED
@@ -1,137 +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 DefaultRootFieldProps, e as ComponentData, R as RootData, f as RootDataWithProps, g as Content } from './Config-XUGMjfT5.mjs';
2
- export { u as Adaptor, t as ArrayField, p as ArrayState, B as BaseData, q as BaseField, l as ComponentConfig, m as ComponentDataMap, w as CustomField, i as DefaultRootProps, h as DefaultRootRenderProps, v as ExternalField, E as ExternalFieldWithAdaptor, x as Fields, o as ItemWithId, M as MappedItem, N as NumberField, O as ObjectField, j as PuckComponent, k as PuckContext, s as RadioField, n as RootDataWithoutProps, S as SelectField, T as TextField, r as TextareaField } from './Config-XUGMjfT5.mjs';
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.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';
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
- iframe: RenderFunc<{
111
- children: ReactNode;
112
- document?: Document;
113
- }>;
114
- outline: RenderFunc;
115
- puck: RenderFunc;
116
- }>;
117
- type FieldRenderFunctions = Omit<{
118
- [Type in Field["type"]]: React.FunctionComponent<FieldProps<Extract<Field, {
119
- type: Type;
120
- }>> & {
121
- children: ReactNode;
122
- name: string;
123
- }>;
124
- }, "custom"> & {
125
- [key: string]: React.FunctionComponent<FieldProps<any> & {
126
- children: ReactNode;
127
- name: string;
128
- }>;
129
- };
130
-
131
- type Plugin = {
132
- overrides: Partial<Overrides>;
133
- };
134
-
135
8
  declare const ActionBar: {
136
9
  ({ label, children, }: {
137
10
  label?: string;
@@ -142,12 +15,18 @@ declare const ActionBar: {
142
15
  label?: string;
143
16
  onClick: (e: SyntheticEvent) => void;
144
17
  }) => react_jsx_runtime.JSX.Element;
18
+ Group: ({ children }: {
19
+ children: ReactNode;
20
+ }) => react_jsx_runtime.JSX.Element;
145
21
  };
146
22
  declare const Action: ({ children, label, onClick, }: {
147
23
  children: ReactNode;
148
24
  label?: string;
149
25
  onClick: (e: SyntheticEvent) => void;
150
26
  }) => react_jsx_runtime.JSX.Element;
27
+ declare const Group: ({ children }: {
28
+ children: ReactNode;
29
+ }) => react_jsx_runtime.JSX.Element;
151
30
 
152
31
  declare const FieldLabel: ({ children, icon, label, el, readOnly, className, }: {
153
32
  children?: ReactNode;
@@ -215,27 +94,6 @@ declare const Drawer: {
215
94
  }) => react_jsx_runtime.JSX.Element;
216
95
  };
217
96
 
218
- type History<D = any> = {
219
- id: string;
220
- data: D;
221
- };
222
- type HistoryStore<D = any> = {
223
- index: number;
224
- hasPast: boolean;
225
- hasFuture: boolean;
226
- histories: History<D>[];
227
- record: (data: D) => void;
228
- back: VoidFunction;
229
- forward: VoidFunction;
230
- currentHistory: History;
231
- nextHistory: History<D> | null;
232
- prevHistory: History<D> | null;
233
- setHistories: (histories: History[]) => void;
234
- setHistoryIndex: (index: number) => void;
235
- };
236
-
237
- type OnAction = (action: PuckAction, appState: AppState, prevAppState: AppState) => void;
238
-
239
97
  type PathData = Record<string, {
240
98
  path: string[];
241
99
  label: string;
@@ -288,28 +146,24 @@ declare const IconButton: ({ children, href, onClick, variant, type, disabled, t
288
146
  title: string;
289
147
  }) => react_jsx_runtime.JSX.Element;
290
148
 
291
- type IframeConfig = {
292
- enabled?: boolean;
293
- };
294
-
295
- 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, }: {
296
150
  children?: ReactNode;
297
151
  config: UserConfig;
298
- data: Partial<Data>;
152
+ data: Partial<G["UserData"] | Data>;
299
153
  ui?: Partial<UiState>;
300
- onChange?: (data: Data) => void;
301
- onPublish?: (data: Data) => void;
302
- onAction?: OnAction;
154
+ onChange?: (data: G["UserData"]) => void;
155
+ onPublish?: (data: G["UserData"]) => void;
156
+ onAction?: OnAction<G["UserData"]>;
303
157
  permissions?: Partial<Permissions>;
304
158
  plugins?: Plugin[];
305
159
  overrides?: Partial<Overrides>;
306
160
  renderHeader?: (props: {
307
161
  children: ReactNode;
308
162
  dispatch: (action: PuckAction) => void;
309
- state: AppState;
163
+ state: G["UserAppState"];
310
164
  }) => ReactElement;
311
165
  renderHeaderActions?: (props: {
312
- state: AppState;
166
+ state: G["UserAppState"];
313
167
  dispatch: (action: PuckAction) => void;
314
168
  }) => ReactElement;
315
169
  headerTitle?: string;
@@ -319,10 +173,7 @@ declare function Puck<UserConfig extends Config = Config>({ children, config, da
319
173
  dnd?: {
320
174
  disableAutoScroll?: boolean;
321
175
  };
322
- initialHistory?: {
323
- histories: History<any>[];
324
- index: number;
325
- };
176
+ initialHistory?: InitialHistory;
326
177
  }): react_jsx_runtime.JSX.Element;
327
178
  declare namespace Puck {
328
179
  var Components: () => react_jsx_runtime.JSX.Element;
@@ -333,9 +184,9 @@ declare namespace Puck {
333
184
  }) => react_jsx_runtime.JSX.Element;
334
185
  }
335
186
 
336
- 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, }: {
337
188
  config: UserConfig;
338
- data: Partial<Data>;
189
+ data: Partial<G["UserData"] | Data>;
339
190
  }): react_jsx_runtime.JSX.Element;
340
191
 
341
192
  declare function migrate(data: Data): Data;
@@ -351,27 +202,37 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
351
202
  }>;
352
203
  declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
353
204
 
354
- 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<{
355
- root: RootData<DefaultRootFieldProps> | RootDataWithProps;
356
- content: Content<Props>;
357
- zones: Record<string, Content<Props>>;
358
- }>;
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;
359
229
 
360
- declare const usePuck: () => {
361
- appState: AppState;
362
- config: Config;
230
+ declare const usePuck: <UserConfig extends Config = Config>() => {
231
+ appState: AppState<Data<ExtractPropsFromConfig<UserConfig>, ExtractRootPropsFromConfig<UserConfig>>>;
232
+ config: UserConfig;
363
233
  dispatch: (action: PuckAction) => void;
364
- getPermissions: ({ item, type, }?: {
365
- item?: ComponentData;
366
- type?: keyof DefaultComponentProps;
367
- }) => {
368
- [x: string]: boolean | undefined;
369
- drag?: boolean | undefined;
370
- duplicate?: boolean | undefined;
371
- delete?: boolean | undefined;
372
- edit?: boolean | undefined;
373
- insert?: boolean | undefined;
374
- };
234
+ getPermissions: GetPermissions<UserConfig>;
235
+ refreshPermissions: RefreshPermissions<UserConfig>;
375
236
  history: {
376
237
  back: VoidFunction;
377
238
  forward: VoidFunction;
@@ -383,7 +244,7 @@ declare const usePuck: () => {
383
244
  index: number;
384
245
  historyStore: HistoryStore | undefined;
385
246
  };
386
- selectedItem: ComponentData<any, string> | null;
247
+ selectedItem: ComponentDataMap<ExtractPropsFromConfig<UserConfig>> | null;
387
248
  };
388
249
 
389
- export { Action, ActionBar, AppState, AutoField, AutoFieldPrivate, Button, ComponentData, Config, Content, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, DropZone, DropZoneProvider, Field, FieldLabel, FieldLabelInternal, FieldProps, type FieldPropsInternal, type History, IconButton, 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 };
package/dist/index.d.ts CHANGED
@@ -1,137 +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 DefaultRootFieldProps, e as ComponentData, R as RootData, f as RootDataWithProps, g as Content } from './Config-XUGMjfT5.js';
2
- export { u as Adaptor, t as ArrayField, p as ArrayState, B as BaseData, q as BaseField, l as ComponentConfig, m as ComponentDataMap, w as CustomField, i as DefaultRootProps, h as DefaultRootRenderProps, v as ExternalField, E as ExternalFieldWithAdaptor, x as Fields, o as ItemWithId, M as MappedItem, N as NumberField, O as ObjectField, j as PuckComponent, k as PuckContext, s as RadioField, n as RootDataWithoutProps, S as SelectField, T as TextField, r as TextareaField } from './Config-XUGMjfT5.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
- iframe: RenderFunc<{
111
- children: ReactNode;
112
- document?: Document;
113
- }>;
114
- outline: RenderFunc;
115
- puck: RenderFunc;
116
- }>;
117
- type FieldRenderFunctions = Omit<{
118
- [Type in Field["type"]]: React.FunctionComponent<FieldProps<Extract<Field, {
119
- type: Type;
120
- }>> & {
121
- children: ReactNode;
122
- name: string;
123
- }>;
124
- }, "custom"> & {
125
- [key: string]: React.FunctionComponent<FieldProps<any> & {
126
- children: ReactNode;
127
- name: string;
128
- }>;
129
- };
130
-
131
- type Plugin = {
132
- overrides: Partial<Overrides>;
133
- };
134
-
135
8
  declare const ActionBar: {
136
9
  ({ label, children, }: {
137
10
  label?: string;
@@ -142,12 +15,18 @@ declare const ActionBar: {
142
15
  label?: string;
143
16
  onClick: (e: SyntheticEvent) => void;
144
17
  }) => react_jsx_runtime.JSX.Element;
18
+ Group: ({ children }: {
19
+ children: ReactNode;
20
+ }) => react_jsx_runtime.JSX.Element;
145
21
  };
146
22
  declare const Action: ({ children, label, onClick, }: {
147
23
  children: ReactNode;
148
24
  label?: string;
149
25
  onClick: (e: SyntheticEvent) => void;
150
26
  }) => react_jsx_runtime.JSX.Element;
27
+ declare const Group: ({ children }: {
28
+ children: ReactNode;
29
+ }) => react_jsx_runtime.JSX.Element;
151
30
 
152
31
  declare const FieldLabel: ({ children, icon, label, el, readOnly, className, }: {
153
32
  children?: ReactNode;
@@ -215,27 +94,6 @@ declare const Drawer: {
215
94
  }) => react_jsx_runtime.JSX.Element;
216
95
  };
217
96
 
218
- type History<D = any> = {
219
- id: string;
220
- data: D;
221
- };
222
- type HistoryStore<D = any> = {
223
- index: number;
224
- hasPast: boolean;
225
- hasFuture: boolean;
226
- histories: History<D>[];
227
- record: (data: D) => void;
228
- back: VoidFunction;
229
- forward: VoidFunction;
230
- currentHistory: History;
231
- nextHistory: History<D> | null;
232
- prevHistory: History<D> | null;
233
- setHistories: (histories: History[]) => void;
234
- setHistoryIndex: (index: number) => void;
235
- };
236
-
237
- type OnAction = (action: PuckAction, appState: AppState, prevAppState: AppState) => void;
238
-
239
97
  type PathData = Record<string, {
240
98
  path: string[];
241
99
  label: string;
@@ -288,28 +146,24 @@ declare const IconButton: ({ children, href, onClick, variant, type, disabled, t
288
146
  title: string;
289
147
  }) => react_jsx_runtime.JSX.Element;
290
148
 
291
- type IframeConfig = {
292
- enabled?: boolean;
293
- };
294
-
295
- 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, }: {
296
150
  children?: ReactNode;
297
151
  config: UserConfig;
298
- data: Partial<Data>;
152
+ data: Partial<G["UserData"] | Data>;
299
153
  ui?: Partial<UiState>;
300
- onChange?: (data: Data) => void;
301
- onPublish?: (data: Data) => void;
302
- onAction?: OnAction;
154
+ onChange?: (data: G["UserData"]) => void;
155
+ onPublish?: (data: G["UserData"]) => void;
156
+ onAction?: OnAction<G["UserData"]>;
303
157
  permissions?: Partial<Permissions>;
304
158
  plugins?: Plugin[];
305
159
  overrides?: Partial<Overrides>;
306
160
  renderHeader?: (props: {
307
161
  children: ReactNode;
308
162
  dispatch: (action: PuckAction) => void;
309
- state: AppState;
163
+ state: G["UserAppState"];
310
164
  }) => ReactElement;
311
165
  renderHeaderActions?: (props: {
312
- state: AppState;
166
+ state: G["UserAppState"];
313
167
  dispatch: (action: PuckAction) => void;
314
168
  }) => ReactElement;
315
169
  headerTitle?: string;
@@ -319,10 +173,7 @@ declare function Puck<UserConfig extends Config = Config>({ children, config, da
319
173
  dnd?: {
320
174
  disableAutoScroll?: boolean;
321
175
  };
322
- initialHistory?: {
323
- histories: History<any>[];
324
- index: number;
325
- };
176
+ initialHistory?: InitialHistory;
326
177
  }): react_jsx_runtime.JSX.Element;
327
178
  declare namespace Puck {
328
179
  var Components: () => react_jsx_runtime.JSX.Element;
@@ -333,9 +184,9 @@ declare namespace Puck {
333
184
  }) => react_jsx_runtime.JSX.Element;
334
185
  }
335
186
 
336
- 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, }: {
337
188
  config: UserConfig;
338
- data: Partial<Data>;
189
+ data: Partial<G["UserData"] | Data>;
339
190
  }): react_jsx_runtime.JSX.Element;
340
191
 
341
192
  declare function migrate(data: Data): Data;
@@ -351,27 +202,37 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
351
202
  }>;
352
203
  declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
353
204
 
354
- 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<{
355
- root: RootData<DefaultRootFieldProps> | RootDataWithProps;
356
- content: Content<Props>;
357
- zones: Record<string, Content<Props>>;
358
- }>;
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;
359
229
 
360
- declare const usePuck: () => {
361
- appState: AppState;
362
- config: Config;
230
+ declare const usePuck: <UserConfig extends Config = Config>() => {
231
+ appState: AppState<Data<ExtractPropsFromConfig<UserConfig>, ExtractRootPropsFromConfig<UserConfig>>>;
232
+ config: UserConfig;
363
233
  dispatch: (action: PuckAction) => void;
364
- getPermissions: ({ item, type, }?: {
365
- item?: ComponentData;
366
- type?: keyof DefaultComponentProps;
367
- }) => {
368
- [x: string]: boolean | undefined;
369
- drag?: boolean | undefined;
370
- duplicate?: boolean | undefined;
371
- delete?: boolean | undefined;
372
- edit?: boolean | undefined;
373
- insert?: boolean | undefined;
374
- };
234
+ getPermissions: GetPermissions<UserConfig>;
235
+ refreshPermissions: RefreshPermissions<UserConfig>;
375
236
  history: {
376
237
  back: VoidFunction;
377
238
  forward: VoidFunction;
@@ -383,7 +244,7 @@ declare const usePuck: () => {
383
244
  index: number;
384
245
  historyStore: HistoryStore | undefined;
385
246
  };
386
- selectedItem: ComponentData<any, string> | null;
247
+ selectedItem: ComponentDataMap<ExtractPropsFromConfig<UserConfig>> | null;
387
248
  };
388
249
 
389
- export { Action, ActionBar, AppState, AutoField, AutoFieldPrivate, Button, ComponentData, Config, Content, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, DropZone, DropZoneProvider, Field, FieldLabel, FieldLabelInternal, FieldProps, type FieldPropsInternal, type History, IconButton, 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 };