@measured/puck 0.16.0-canary.0c7fc83 → 0.16.0-canary.2c52d27
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{Config-041c35a2.d.ts → Config-VOJqVbHe.d.ts} +2 -2
- package/dist/index.d.ts +130 -121
- package/dist/index.js +1672 -2204
- package/dist/rsc.d.ts +1 -1
- package/package.json +4 -4
@@ -68,7 +68,7 @@ type ObjectField<Props extends {
|
|
68
68
|
[key: string]: any;
|
69
69
|
}> = BaseField & {
|
70
70
|
type: "object";
|
71
|
-
objectFields: {
|
71
|
+
objectFields: Props extends any[] ? never : {
|
72
72
|
[SubPropName in keyof Props]: Field<Props[SubPropName]>;
|
73
73
|
};
|
74
74
|
};
|
@@ -259,4 +259,4 @@ type AppState = {
|
|
259
259
|
ui: UiState;
|
260
260
|
};
|
261
261
|
|
262
|
-
export { AppState as A, BaseData as B, Config as C, Data as D, ExternalFieldWithAdaptor as E, Field as F, ItemSelector as I, MappedItem as M, NumberField as N, ObjectField as O, PuckComponent as P,
|
262
|
+
export type { AppState as A, BaseData as B, Config as C, Data as D, ExternalFieldWithAdaptor as E, Field as F, ItemSelector as I, MappedItem as M, NumberField as N, ObjectField as O, PuckComponent as P, RootData as R, SelectField as S, TextField as T, UiState as U, Viewports as V, FieldProps as a, DropZoneProps as b, DefaultComponentProps as c, DefaultRootProps as d, RootDataWithProps as e, ComponentData as f, Content as g, PuckContext as h, ComponentConfig as i, RootDataWithoutProps as j, ItemWithId as k, ArrayState as l, BaseField as m, TextareaField as n, RadioField as o, ArrayField as p, Adaptor as q, ExternalField as r, CustomField as s, Fields as t };
|
package/dist/index.d.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
import { U as UiState, D as Data, A as AppState, F as Field, a as FieldProps, C as Config, b as
|
2
|
-
export { q as Adaptor, p as ArrayField, l as ArrayState, B as BaseData, m as BaseField, i as ComponentConfig, g as Content, s as CustomField, r as ExternalField, E as ExternalFieldWithAdaptor, t as Fields, k as ItemWithId, N as NumberField, O as ObjectField, P as PuckComponent, h as PuckContext, o as RadioField, j as RootDataWithoutProps, S as SelectField, T as TextField, n as TextareaField } from './Config-
|
3
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
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, V as Viewports, c as DefaultComponentProps, d as DefaultRootProps, M as MappedItem, R as RootData, e as RootDataWithProps, f as ComponentData } from './Config-VOJqVbHe.js';
|
2
|
+
export { q as Adaptor, p as ArrayField, l as ArrayState, B as BaseData, m as BaseField, i as ComponentConfig, g as Content, s as CustomField, r as ExternalField, E as ExternalFieldWithAdaptor, t as Fields, k as ItemWithId, N as NumberField, O as ObjectField, P as PuckComponent, h as PuckContext, o as RadioField, j as RootDataWithoutProps, S as SelectField, T as TextField, n as TextareaField } from './Config-VOJqVbHe.js';
|
4
3
|
import * as react from 'react';
|
5
4
|
import { ReactNode, ReactElement, CSSProperties, SyntheticEvent } from 'react';
|
5
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
6
6
|
import { DragStart, DragUpdate } from '@measured/dnd';
|
7
7
|
|
8
8
|
type InsertAction = {
|
@@ -64,13 +64,72 @@ type PuckAction = {
|
|
64
64
|
recordHistory?: boolean;
|
65
65
|
} & (ReorderAction | InsertAction | MoveAction | ReplaceAction | RemoveAction | DuplicateAction | SetAction | SetDataAction | SetUiAction | RegisterZoneAction | UnregisterZoneAction);
|
66
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<{
|
93
|
+
children?: ReactNode;
|
94
|
+
icon?: ReactNode;
|
95
|
+
label: string;
|
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
|
+
}>> & {
|
112
|
+
children: ReactNode;
|
113
|
+
name: string;
|
114
|
+
}>;
|
115
|
+
}, "custom"> & {
|
116
|
+
[key: string]: React.FunctionComponent<FieldProps<any> & {
|
117
|
+
children: ReactNode;
|
118
|
+
name: string;
|
119
|
+
}>;
|
120
|
+
};
|
121
|
+
|
122
|
+
type Plugin = {
|
123
|
+
overrides: Partial<Overrides>;
|
124
|
+
};
|
125
|
+
|
67
126
|
declare const FieldLabel: ({ children, icon, label, el, readOnly, className, }: {
|
68
127
|
children?: ReactNode;
|
69
128
|
icon?: ReactNode;
|
70
129
|
label: string;
|
71
|
-
el?: "label" | "div"
|
72
|
-
readOnly?: boolean
|
73
|
-
className?: string
|
130
|
+
el?: "label" | "div";
|
131
|
+
readOnly?: boolean;
|
132
|
+
className?: string;
|
74
133
|
}) => react_jsx_runtime.JSX.Element;
|
75
134
|
type FieldLabelPropsInternal = {
|
76
135
|
children?: ReactNode;
|
@@ -98,37 +157,58 @@ declare function AutoField<ValueType = any, FieldType extends Field<ValueType> =
|
|
98
157
|
|
99
158
|
declare const Button: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, icon, size, loading: loadingProp, }: {
|
100
159
|
children: ReactNode;
|
101
|
-
href?: string
|
102
|
-
onClick?: (
|
103
|
-
variant?: "primary" | "secondary"
|
104
|
-
type?: "button" | "submit" | "reset"
|
105
|
-
disabled?: boolean
|
106
|
-
tabIndex?: number
|
107
|
-
newTab?: boolean
|
108
|
-
fullWidth?: boolean
|
160
|
+
href?: string;
|
161
|
+
onClick?: (e: any) => void | Promise<void>;
|
162
|
+
variant?: "primary" | "secondary";
|
163
|
+
type?: "button" | "submit" | "reset";
|
164
|
+
disabled?: boolean;
|
165
|
+
tabIndex?: number;
|
166
|
+
newTab?: boolean;
|
167
|
+
fullWidth?: boolean;
|
109
168
|
icon?: ReactNode;
|
110
|
-
size?: "medium" | "large"
|
111
|
-
loading?: boolean
|
169
|
+
size?: "medium" | "large";
|
170
|
+
loading?: boolean;
|
112
171
|
}) => react_jsx_runtime.JSX.Element;
|
113
172
|
|
114
173
|
declare const Drawer: {
|
115
174
|
({ children, droppableId: _droppableId, direction, }: {
|
116
175
|
children: ReactNode;
|
117
|
-
droppableId?: string
|
118
|
-
direction?: "vertical" | "horizontal"
|
176
|
+
droppableId?: string;
|
177
|
+
direction?: "vertical" | "horizontal";
|
119
178
|
}): react_jsx_runtime.JSX.Element;
|
120
179
|
Item: ({ name, children, id, label, index, }: {
|
121
180
|
name: string;
|
122
|
-
children?: (
|
181
|
+
children?: (props: {
|
123
182
|
children: ReactNode;
|
124
183
|
name: string;
|
125
|
-
}) => ReactElement
|
126
|
-
id?: string
|
127
|
-
label?: string
|
184
|
+
}) => ReactElement;
|
185
|
+
id?: string;
|
186
|
+
label?: string;
|
128
187
|
index: number;
|
129
188
|
}) => react_jsx_runtime.JSX.Element;
|
130
189
|
};
|
131
190
|
|
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
|
+
|
132
212
|
type PathData = Record<string, {
|
133
213
|
path: string[];
|
134
214
|
label: string;
|
@@ -160,7 +240,7 @@ type DropZoneContext<UserConfig extends Config = Config> = {
|
|
160
240
|
zoneWillDrag?: string;
|
161
241
|
setZoneWillDrag?: (zone: string) => void;
|
162
242
|
} | null;
|
163
|
-
declare const dropZoneContext: react.Context<DropZoneContext<Config
|
243
|
+
declare const dropZoneContext: react.Context<DropZoneContext<Config>>;
|
164
244
|
declare const DropZoneProvider: ({ children, value, }: {
|
165
245
|
children: ReactNode;
|
166
246
|
value: DropZoneContext;
|
@@ -170,104 +250,29 @@ declare function DropZone(props: DropZoneProps): react_jsx_runtime.JSX.Element;
|
|
170
250
|
|
171
251
|
declare const IconButton: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, title, }: {
|
172
252
|
children: ReactNode;
|
173
|
-
href?: string
|
174
|
-
onClick?: (
|
175
|
-
variant?: "primary" | "secondary"
|
176
|
-
type?: "button" | "submit" | "reset"
|
177
|
-
disabled?: boolean
|
178
|
-
tabIndex?: number
|
179
|
-
newTab?: boolean
|
180
|
-
fullWidth?: boolean
|
253
|
+
href?: string;
|
254
|
+
onClick?: (e: SyntheticEvent) => void | Promise<void>;
|
255
|
+
variant?: "primary" | "secondary";
|
256
|
+
type?: "button" | "submit" | "reset";
|
257
|
+
disabled?: boolean;
|
258
|
+
tabIndex?: number;
|
259
|
+
newTab?: boolean;
|
260
|
+
fullWidth?: boolean;
|
181
261
|
title: string;
|
182
262
|
}) => react_jsx_runtime.JSX.Element;
|
183
263
|
|
184
|
-
type RenderFunc<Props extends {
|
185
|
-
[key: string]: any;
|
186
|
-
} = {
|
187
|
-
children: ReactNode;
|
188
|
-
}> = (props: Props) => ReactElement;
|
189
|
-
declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "components", "componentItem", "outline", "puck", "preview"];
|
190
|
-
type OverrideKey = (typeof overrideKeys)[number];
|
191
|
-
type OverridesGeneric<Shape extends {
|
192
|
-
[key in OverrideKey]: any;
|
193
|
-
}> = Shape;
|
194
|
-
type Overrides = OverridesGeneric<{
|
195
|
-
fieldTypes: Partial<FieldRenderFunctions>;
|
196
|
-
header: RenderFunc<{
|
197
|
-
actions: ReactNode;
|
198
|
-
children: ReactNode;
|
199
|
-
}>;
|
200
|
-
headerActions: RenderFunc<{
|
201
|
-
children: ReactNode;
|
202
|
-
}>;
|
203
|
-
preview: RenderFunc;
|
204
|
-
fields: RenderFunc<{
|
205
|
-
children: ReactNode;
|
206
|
-
isLoading: boolean;
|
207
|
-
itemSelector?: ItemSelector | null;
|
208
|
-
}>;
|
209
|
-
fieldLabel: RenderFunc<{
|
210
|
-
children?: ReactNode;
|
211
|
-
icon?: ReactNode;
|
212
|
-
label: string;
|
213
|
-
el?: "label" | "div";
|
214
|
-
readOnly?: boolean;
|
215
|
-
className?: string;
|
216
|
-
}>;
|
217
|
-
components: RenderFunc;
|
218
|
-
componentItem: RenderFunc<{
|
219
|
-
children: ReactNode;
|
220
|
-
name: string;
|
221
|
-
}>;
|
222
|
-
outline: RenderFunc;
|
223
|
-
puck: RenderFunc;
|
224
|
-
}>;
|
225
|
-
type FieldRenderFunctions = Omit<{
|
226
|
-
[Type in Field["type"]]: React.FunctionComponent<FieldProps<Extract<Field, {
|
227
|
-
type: Type;
|
228
|
-
}>> & {
|
229
|
-
children: ReactNode;
|
230
|
-
name: string;
|
231
|
-
}>;
|
232
|
-
}, "custom"> & {
|
233
|
-
[key: string]: React.FunctionComponent<FieldProps<any> & {
|
234
|
-
children: ReactNode;
|
235
|
-
name: string;
|
236
|
-
}>;
|
237
|
-
};
|
238
|
-
|
239
|
-
type Plugin = {
|
240
|
-
overrides: Partial<Overrides>;
|
241
|
-
};
|
242
|
-
|
243
|
-
type History<D = any> = {
|
244
|
-
id: string;
|
245
|
-
data: D;
|
246
|
-
};
|
247
|
-
type HistoryStore<D = any> = {
|
248
|
-
index: number;
|
249
|
-
currentHistory: History;
|
250
|
-
hasPast: boolean;
|
251
|
-
hasFuture: boolean;
|
252
|
-
record: (data: D) => void;
|
253
|
-
back: VoidFunction;
|
254
|
-
forward: VoidFunction;
|
255
|
-
nextHistory: History<D> | null;
|
256
|
-
prevHistory: History<D> | null;
|
257
|
-
histories: History<D>[];
|
258
|
-
};
|
259
|
-
|
260
264
|
type IframeConfig = {
|
261
265
|
enabled?: boolean;
|
262
266
|
};
|
263
267
|
|
264
|
-
declare function Puck<UserConfig extends Config = Config>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe, dnd,
|
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, }: {
|
265
269
|
children?: ReactNode;
|
266
270
|
config: UserConfig;
|
267
271
|
data: Partial<Data>;
|
268
272
|
ui?: Partial<UiState>;
|
269
273
|
onChange?: (data: Data) => void;
|
270
274
|
onPublish?: (data: Data) => void;
|
275
|
+
onAction?: OnAction;
|
271
276
|
plugins?: Plugin[];
|
272
277
|
overrides?: Partial<Overrides>;
|
273
278
|
renderHeader?: (props: {
|
@@ -286,7 +291,7 @@ declare function Puck<UserConfig extends Config = Config>({ children, config, da
|
|
286
291
|
dnd?: {
|
287
292
|
disableAutoScroll?: boolean;
|
288
293
|
};
|
289
|
-
|
294
|
+
initialHistory?: {
|
290
295
|
histories: History<any>[];
|
291
296
|
index: number;
|
292
297
|
};
|
@@ -296,7 +301,7 @@ declare namespace Puck {
|
|
296
301
|
var Fields: () => react_jsx_runtime.JSX.Element;
|
297
302
|
var Outline: () => react_jsx_runtime.JSX.Element;
|
298
303
|
var Preview: ({ id }: {
|
299
|
-
id?: string
|
304
|
+
id?: string;
|
300
305
|
}) => react_jsx_runtime.JSX.Element;
|
301
306
|
}
|
302
307
|
|
@@ -319,25 +324,29 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
|
|
319
324
|
declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultComponentProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
|
320
325
|
|
321
326
|
declare function resolveAllData(data: Partial<Data>, config: Config, onResolveStart?: (item: MappedItem) => void, onResolveEnd?: (item: MappedItem) => void): Promise<{
|
322
|
-
root:
|
323
|
-
content: any
|
327
|
+
root: RootData<DefaultRootProps> | RootDataWithProps;
|
328
|
+
content: any;
|
324
329
|
zones: Record<string, MappedItem[]>;
|
325
330
|
}>;
|
326
331
|
|
327
|
-
type PuckHistory = {
|
328
|
-
back: VoidFunction;
|
329
|
-
forward: VoidFunction;
|
330
|
-
historyStore: HistoryStore;
|
331
|
-
};
|
332
|
-
|
333
332
|
declare const usePuck: () => {
|
334
333
|
appState: AppState;
|
335
|
-
config: Config
|
334
|
+
config: Config;
|
336
335
|
dispatch: (action: PuckAction) => void;
|
337
|
-
history:
|
336
|
+
history: {
|
337
|
+
back: VoidFunction;
|
338
|
+
forward: VoidFunction;
|
339
|
+
setHistories: (histories: History[]) => void;
|
340
|
+
setHistoryIndex: (index: number) => void;
|
341
|
+
hasPast: boolean;
|
342
|
+
hasFuture: boolean;
|
343
|
+
histories: History<any>[];
|
344
|
+
index: number;
|
345
|
+
historyStore: HistoryStore | undefined;
|
346
|
+
};
|
338
347
|
selectedItem: ComponentData<DefaultComponentProps & {
|
339
348
|
id: string;
|
340
349
|
}> | null;
|
341
350
|
};
|
342
351
|
|
343
|
-
export { AppState, AutoField, AutoFieldPrivate, Button, ComponentData, Config, Data, DefaultComponentProps, DefaultRootProps, Drawer, DropZone, DropZoneProvider, Field, FieldLabel, FieldLabelInternal, FieldProps, FieldPropsInternal, IconButton, MappedItem, Puck, PuckAction, Render, RootData, RootDataWithProps, UiState, dropZoneContext, migrate, resolveAllData, transformProps, usePuck };
|
352
|
+
export { AppState, AutoField, AutoFieldPrivate, Button, ComponentData, Config, Data, DefaultComponentProps, DefaultRootProps, Drawer, DropZone, DropZoneProvider, Field, FieldLabel, FieldLabelInternal, FieldProps, type FieldPropsInternal, type History, IconButton, MappedItem, type Plugin, Puck, type PuckAction, Render, RootData, RootDataWithProps, UiState, dropZoneContext, migrate, resolveAllData, transformProps, usePuck };
|