@measured/puck 0.16.0-canary.54b5a87 → 0.16.0-canary.60fe631
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 +127 -121
- package/dist/index.js +1658 -2197
- 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,56 @@ 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
|
+
|
132
210
|
type PathData = Record<string, {
|
133
211
|
path: string[];
|
134
212
|
label: string;
|
@@ -160,7 +238,7 @@ type DropZoneContext<UserConfig extends Config = Config> = {
|
|
160
238
|
zoneWillDrag?: string;
|
161
239
|
setZoneWillDrag?: (zone: string) => void;
|
162
240
|
} | null;
|
163
|
-
declare const dropZoneContext: react.Context<DropZoneContext<Config
|
241
|
+
declare const dropZoneContext: react.Context<DropZoneContext<Config>>;
|
164
242
|
declare const DropZoneProvider: ({ children, value, }: {
|
165
243
|
children: ReactNode;
|
166
244
|
value: DropZoneContext;
|
@@ -170,98 +248,22 @@ declare function DropZone(props: DropZoneProps): react_jsx_runtime.JSX.Element;
|
|
170
248
|
|
171
249
|
declare const IconButton: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, title, }: {
|
172
250
|
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
|
251
|
+
href?: string;
|
252
|
+
onClick?: (e: SyntheticEvent) => void | Promise<void>;
|
253
|
+
variant?: "primary" | "secondary";
|
254
|
+
type?: "button" | "submit" | "reset";
|
255
|
+
disabled?: boolean;
|
256
|
+
tabIndex?: number;
|
257
|
+
newTab?: boolean;
|
258
|
+
fullWidth?: boolean;
|
181
259
|
title: string;
|
182
260
|
}) => react_jsx_runtime.JSX.Element;
|
183
261
|
|
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
262
|
type IframeConfig = {
|
261
263
|
enabled?: boolean;
|
262
264
|
};
|
263
265
|
|
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,
|
266
|
+
declare function Puck<UserConfig extends Config = Config>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe, dnd, initialHistory, }: {
|
265
267
|
children?: ReactNode;
|
266
268
|
config: UserConfig;
|
267
269
|
data: Partial<Data>;
|
@@ -286,7 +288,7 @@ declare function Puck<UserConfig extends Config = Config>({ children, config, da
|
|
286
288
|
dnd?: {
|
287
289
|
disableAutoScroll?: boolean;
|
288
290
|
};
|
289
|
-
|
291
|
+
initialHistory?: {
|
290
292
|
histories: History<any>[];
|
291
293
|
index: number;
|
292
294
|
};
|
@@ -296,7 +298,7 @@ declare namespace Puck {
|
|
296
298
|
var Fields: () => react_jsx_runtime.JSX.Element;
|
297
299
|
var Outline: () => react_jsx_runtime.JSX.Element;
|
298
300
|
var Preview: ({ id }: {
|
299
|
-
id?: string
|
301
|
+
id?: string;
|
300
302
|
}) => react_jsx_runtime.JSX.Element;
|
301
303
|
}
|
302
304
|
|
@@ -319,25 +321,29 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
|
|
319
321
|
declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultComponentProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
|
320
322
|
|
321
323
|
declare function resolveAllData(data: Partial<Data>, config: Config, onResolveStart?: (item: MappedItem) => void, onResolveEnd?: (item: MappedItem) => void): Promise<{
|
322
|
-
root:
|
323
|
-
content: any
|
324
|
+
root: RootData<DefaultRootProps> | RootDataWithProps;
|
325
|
+
content: any;
|
324
326
|
zones: Record<string, MappedItem[]>;
|
325
327
|
}>;
|
326
328
|
|
327
|
-
type PuckHistory = {
|
328
|
-
back: VoidFunction;
|
329
|
-
forward: VoidFunction;
|
330
|
-
historyStore: HistoryStore;
|
331
|
-
};
|
332
|
-
|
333
329
|
declare const usePuck: () => {
|
334
330
|
appState: AppState;
|
335
|
-
config: Config
|
331
|
+
config: Config;
|
336
332
|
dispatch: (action: PuckAction) => void;
|
337
|
-
history:
|
333
|
+
history: {
|
334
|
+
back: VoidFunction;
|
335
|
+
forward: VoidFunction;
|
336
|
+
setHistories: (histories: History[]) => void;
|
337
|
+
setHistoryIndex: (index: number) => void;
|
338
|
+
hasPast: boolean;
|
339
|
+
hasFuture: boolean;
|
340
|
+
histories: History<any>[];
|
341
|
+
index: number;
|
342
|
+
historyStore: HistoryStore | undefined;
|
343
|
+
};
|
338
344
|
selectedItem: ComponentData<DefaultComponentProps & {
|
339
345
|
id: string;
|
340
346
|
}> | null;
|
341
347
|
};
|
342
348
|
|
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 };
|
349
|
+
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 };
|