@measured/puck 0.16.0-canary.6386bd1 → 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/actions-9pHbVtMU.d.mts +443 -0
- package/dist/actions-9pHbVtMU.d.ts +443 -0
- package/dist/chunk-LM7YWFFF.mjs +114 -0
- package/dist/index.css +173 -137
- package/dist/index.d.mts +250 -0
- package/dist/index.d.ts +68 -170
- package/dist/index.js +1483 -29484
- package/dist/index.mjs +6040 -0
- package/dist/rsc.d.mts +10 -0
- package/dist/rsc.d.ts +1 -1
- package/dist/rsc.js +3 -2
- package/dist/rsc.mjs +80 -0
- package/package.json +14 -6
- package/dist/Config-VOJqVbHe.d.ts +0 -262
package/dist/index.d.mts
ADDED
@@ -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,127 +1,32 @@
|
|
1
|
-
import {
|
2
|
-
export {
|
3
|
-
import * as react from 'react';
|
4
|
-
import { ReactNode, ReactElement, CSSProperties, SyntheticEvent } 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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
destinationIndex: number;
|
12
|
-
destinationZone: string;
|
13
|
-
};
|
14
|
-
type DuplicateAction = {
|
15
|
-
type: "duplicate";
|
16
|
-
sourceIndex: number;
|
17
|
-
sourceZone: string;
|
18
|
-
};
|
19
|
-
type ReplaceAction = {
|
20
|
-
type: "replace";
|
21
|
-
destinationIndex: number;
|
22
|
-
destinationZone: string;
|
23
|
-
data: any;
|
24
|
-
};
|
25
|
-
type ReorderAction = {
|
26
|
-
type: "reorder";
|
27
|
-
sourceIndex: number;
|
28
|
-
destinationIndex: number;
|
29
|
-
destinationZone: string;
|
30
|
-
};
|
31
|
-
type MoveAction = {
|
32
|
-
type: "move";
|
33
|
-
sourceIndex: number;
|
34
|
-
sourceZone: string;
|
35
|
-
destinationIndex: number;
|
36
|
-
destinationZone: string;
|
37
|
-
};
|
38
|
-
type RemoveAction = {
|
39
|
-
type: "remove";
|
40
|
-
index: number;
|
41
|
-
zone: string;
|
42
|
-
};
|
43
|
-
type SetUiAction = {
|
44
|
-
type: "setUi";
|
45
|
-
ui: Partial<UiState> | ((previous: UiState) => Partial<UiState>);
|
46
|
-
};
|
47
|
-
type SetDataAction = {
|
48
|
-
type: "setData";
|
49
|
-
data: Partial<Data> | ((previous: Data) => Partial<Data>);
|
50
|
-
};
|
51
|
-
type SetAction = {
|
52
|
-
type: "set";
|
53
|
-
state: Partial<AppState> | ((previous: AppState) => Partial<AppState>);
|
54
|
-
};
|
55
|
-
type RegisterZoneAction = {
|
56
|
-
type: "registerZone";
|
57
|
-
zone: string;
|
58
|
-
};
|
59
|
-
type UnregisterZoneAction = {
|
60
|
-
type: "unregisterZone";
|
61
|
-
zone: string;
|
62
|
-
};
|
63
|
-
type PuckAction = {
|
64
|
-
recordHistory?: boolean;
|
65
|
-
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
66
|
-
|
67
|
-
type RenderFunc<Props extends {
|
68
|
-
[key: string]: any;
|
69
|
-
} = {
|
70
|
-
children: ReactNode;
|
71
|
-
}> = (props: Props) => ReactElement;
|
72
|
-
declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "components", "componentItem", "outline", "puck", "preview"];
|
73
|
-
type OverrideKey = (typeof overrideKeys)[number];
|
74
|
-
type OverridesGeneric<Shape extends {
|
75
|
-
[key in OverrideKey]: any;
|
76
|
-
}> = Shape;
|
77
|
-
type Overrides = OverridesGeneric<{
|
78
|
-
fieldTypes: Partial<FieldRenderFunctions>;
|
79
|
-
header: RenderFunc<{
|
80
|
-
actions: ReactNode;
|
81
|
-
children: ReactNode;
|
82
|
-
}>;
|
83
|
-
headerActions: RenderFunc<{
|
84
|
-
children: ReactNode;
|
85
|
-
}>;
|
86
|
-
preview: RenderFunc;
|
87
|
-
fields: RenderFunc<{
|
88
|
-
children: ReactNode;
|
89
|
-
isLoading: boolean;
|
90
|
-
itemSelector?: ItemSelector | null;
|
91
|
-
}>;
|
92
|
-
fieldLabel: RenderFunc<{
|
8
|
+
declare const ActionBar: {
|
9
|
+
({ label, children, }: {
|
10
|
+
label?: string;
|
93
11
|
children?: ReactNode;
|
94
|
-
|
95
|
-
|
96
|
-
el?: "label" | "div";
|
97
|
-
readOnly?: boolean;
|
98
|
-
className?: string;
|
99
|
-
}>;
|
100
|
-
components: RenderFunc;
|
101
|
-
componentItem: RenderFunc<{
|
102
|
-
children: ReactNode;
|
103
|
-
name: string;
|
104
|
-
}>;
|
105
|
-
outline: RenderFunc;
|
106
|
-
puck: RenderFunc;
|
107
|
-
}>;
|
108
|
-
type FieldRenderFunctions = Omit<{
|
109
|
-
[Type in Field["type"]]: React.FunctionComponent<FieldProps<Extract<Field, {
|
110
|
-
type: Type;
|
111
|
-
}>> & {
|
12
|
+
}): react_jsx_runtime.JSX.Element;
|
13
|
+
Action: ({ children, label, onClick, }: {
|
112
14
|
children: ReactNode;
|
113
|
-
|
114
|
-
|
115
|
-
}
|
116
|
-
|
15
|
+
label?: string;
|
16
|
+
onClick: (e: SyntheticEvent) => void;
|
17
|
+
}) => react_jsx_runtime.JSX.Element;
|
18
|
+
Group: ({ children }: {
|
117
19
|
children: ReactNode;
|
118
|
-
|
119
|
-
}>;
|
120
|
-
};
|
121
|
-
|
122
|
-
type Plugin = {
|
123
|
-
overrides: Partial<Overrides>;
|
20
|
+
}) => react_jsx_runtime.JSX.Element;
|
124
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;
|
125
30
|
|
126
31
|
declare const FieldLabel: ({ children, icon, label, el, readOnly, className, }: {
|
127
32
|
children?: ReactNode;
|
@@ -176,7 +81,7 @@ declare const Drawer: {
|
|
176
81
|
droppableId?: string;
|
177
82
|
direction?: "vertical" | "horizontal";
|
178
83
|
}): react_jsx_runtime.JSX.Element;
|
179
|
-
Item: ({ name, children, id, label, index, }: {
|
84
|
+
Item: ({ name, children, id, label, index, isDragDisabled, }: {
|
180
85
|
name: string;
|
181
86
|
children?: (props: {
|
182
87
|
children: ReactNode;
|
@@ -185,30 +90,10 @@ declare const Drawer: {
|
|
185
90
|
id?: string;
|
186
91
|
label?: string;
|
187
92
|
index: number;
|
93
|
+
isDragDisabled?: boolean;
|
188
94
|
}) => react_jsx_runtime.JSX.Element;
|
189
95
|
};
|
190
96
|
|
191
|
-
type History<D = any> = {
|
192
|
-
id: string;
|
193
|
-
data: D;
|
194
|
-
};
|
195
|
-
type HistoryStore<D = any> = {
|
196
|
-
index: number;
|
197
|
-
hasPast: boolean;
|
198
|
-
hasFuture: boolean;
|
199
|
-
histories: History<D>[];
|
200
|
-
record: (data: D) => void;
|
201
|
-
back: VoidFunction;
|
202
|
-
forward: VoidFunction;
|
203
|
-
currentHistory: History;
|
204
|
-
nextHistory: History<D> | null;
|
205
|
-
prevHistory: History<D> | null;
|
206
|
-
setHistories: (histories: History[]) => void;
|
207
|
-
setHistoryIndex: (index: number) => void;
|
208
|
-
};
|
209
|
-
|
210
|
-
type OnAction = (action: PuckAction, appState: AppState, prevAppState: AppState) => void;
|
211
|
-
|
212
97
|
type PathData = Record<string, {
|
213
98
|
path: string[];
|
214
99
|
label: string;
|
@@ -261,27 +146,24 @@ declare const IconButton: ({ children, href, onClick, variant, type, disabled, t
|
|
261
146
|
title: string;
|
262
147
|
}) => react_jsx_runtime.JSX.Element;
|
263
148
|
|
264
|
-
|
265
|
-
enabled?: boolean;
|
266
|
-
};
|
267
|
-
|
268
|
-
declare function Puck<UserConfig extends Config = Config>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, onAction, 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, }: {
|
269
150
|
children?: ReactNode;
|
270
151
|
config: UserConfig;
|
271
|
-
data: Partial<Data>;
|
152
|
+
data: Partial<G["UserData"] | Data>;
|
272
153
|
ui?: Partial<UiState>;
|
273
|
-
onChange?: (data:
|
274
|
-
onPublish?: (data:
|
275
|
-
onAction?: OnAction
|
154
|
+
onChange?: (data: G["UserData"]) => void;
|
155
|
+
onPublish?: (data: G["UserData"]) => void;
|
156
|
+
onAction?: OnAction<G["UserData"]>;
|
157
|
+
permissions?: Partial<Permissions>;
|
276
158
|
plugins?: Plugin[];
|
277
159
|
overrides?: Partial<Overrides>;
|
278
160
|
renderHeader?: (props: {
|
279
161
|
children: ReactNode;
|
280
162
|
dispatch: (action: PuckAction) => void;
|
281
|
-
state:
|
163
|
+
state: G["UserAppState"];
|
282
164
|
}) => ReactElement;
|
283
165
|
renderHeaderActions?: (props: {
|
284
|
-
state:
|
166
|
+
state: G["UserAppState"];
|
285
167
|
dispatch: (action: PuckAction) => void;
|
286
168
|
}) => ReactElement;
|
287
169
|
headerTitle?: string;
|
@@ -291,10 +173,7 @@ declare function Puck<UserConfig extends Config = Config>({ children, config, da
|
|
291
173
|
dnd?: {
|
292
174
|
disableAutoScroll?: boolean;
|
293
175
|
};
|
294
|
-
initialHistory?:
|
295
|
-
histories: History<any>[];
|
296
|
-
index: number;
|
297
|
-
};
|
176
|
+
initialHistory?: InitialHistory;
|
298
177
|
}): react_jsx_runtime.JSX.Element;
|
299
178
|
declare namespace Puck {
|
300
179
|
var Components: () => react_jsx_runtime.JSX.Element;
|
@@ -305,14 +184,14 @@ declare namespace Puck {
|
|
305
184
|
}) => react_jsx_runtime.JSX.Element;
|
306
185
|
}
|
307
186
|
|
308
|
-
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, }: {
|
309
188
|
config: UserConfig;
|
310
|
-
data: Partial<Data>;
|
189
|
+
data: Partial<G["UserData"] | Data>;
|
311
190
|
}): react_jsx_runtime.JSX.Element;
|
312
191
|
|
313
192
|
declare function migrate(data: Data): Data;
|
314
193
|
|
315
|
-
type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends
|
194
|
+
type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
|
316
195
|
[ComponentName in keyof Props]: (props: Props[ComponentName] & {
|
317
196
|
[key: string]: any;
|
318
197
|
}) => Props[ComponentName];
|
@@ -321,18 +200,39 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
|
|
321
200
|
[key: string]: any;
|
322
201
|
}) => RootProps;
|
323
202
|
}>;
|
324
|
-
declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps =
|
203
|
+
declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
|
325
204
|
|
326
|
-
declare function resolveAllData(data: Partial<Data>, config: Config, onResolveStart?: (item:
|
327
|
-
root: RootData<DefaultRootProps> | RootDataWithProps;
|
328
|
-
content: any;
|
329
|
-
zones: Record<string, MappedItem[]>;
|
330
|
-
}>;
|
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>>;
|
331
206
|
|
332
|
-
|
333
|
-
|
334
|
-
|
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;
|
335
233
|
dispatch: (action: PuckAction) => void;
|
234
|
+
getPermissions: GetPermissions<UserConfig>;
|
235
|
+
refreshPermissions: RefreshPermissions<UserConfig>;
|
336
236
|
history: {
|
337
237
|
back: VoidFunction;
|
338
238
|
forward: VoidFunction;
|
@@ -344,9 +244,7 @@ declare const usePuck: () => {
|
|
344
244
|
index: number;
|
345
245
|
historyStore: HistoryStore | undefined;
|
346
246
|
};
|
347
|
-
selectedItem:
|
348
|
-
id: string;
|
349
|
-
}> | null;
|
247
|
+
selectedItem: ComponentDataMap<ExtractPropsFromConfig<UserConfig>> | null;
|
350
248
|
};
|
351
249
|
|
352
|
-
export { AppState, AutoField, AutoFieldPrivate, Button, ComponentData, Config, Data, DefaultComponentProps,
|
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 };
|