@measured/puck 0.16.0-canary.1beaf6b → 0.16.0-canary.257e4be
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-Dyg9ei4T.d.mts +433 -0
- package/dist/actions-Dyg9ei4T.d.ts +433 -0
- package/dist/chunk-LM7YWFFF.mjs +114 -0
- package/dist/index.css +56 -29
- package/dist/index.d.mts +245 -0
- package/dist/index.d.ts +52 -175
- package/dist/index.js +608 -28794
- package/dist/index.mjs +5929 -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.ts
CHANGED
@@ -1,141 +1,24 @@
|
|
1
|
-
import {
|
2
|
-
export {
|
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, E as ExtractPropsFromConfig, c as ExtractRootPropsFromConfig, U as UiState, O as OnAction, d as Permissions, e as Plugin, f as Overrides, A as AppState, V as Viewports, g as IframeConfig, h as InitialHistory, i as DefaultComponentProps, j as DefaultRootFieldProps, k as ComponentData, H as History } from './actions-Dyg9ei4T.js';
|
2
|
+
export { K as Adaptor, G as ArrayField, q as ArrayState, a1 as AsFieldProps, B as BaseData, x as BaseField, s as ComponentConfig, v as ComponentDataMap, w as Content, W as CustomField, _ as DefaultRootProps, Z as DefaultRootRenderProps, Q as ExternalField, L as ExternalFieldWithAdaptor, n as FieldRenderFunctions, X as Fields, p as ItemWithId, M as MappedItem, N as NumberField, J as ObjectField, m as OverrideKey, r as PuckComponent, Y as PuckContext, z as RadioField, u as RootData, R as RootDataWithProps, t as RootDataWithoutProps, S as SelectField, T as TextField, y as TextareaField, l as Viewport, a2 as WithChildren, $ as WithId, a0 as WithPuckProps, o as overrideKeys } from './actions-Dyg9ei4T.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
|
-
headerActions: RenderFunc<{
|
85
|
-
children: ReactNode;
|
86
|
-
}>;
|
87
|
-
preview: RenderFunc;
|
88
|
-
fields: RenderFunc<{
|
89
|
-
children: ReactNode;
|
90
|
-
isLoading: boolean;
|
91
|
-
itemSelector?: ItemSelector | null;
|
92
|
-
}>;
|
93
|
-
fieldLabel: RenderFunc<{
|
94
|
-
children?: ReactNode;
|
95
|
-
icon?: ReactNode;
|
96
|
-
label: string;
|
97
|
-
el?: "label" | "div";
|
98
|
-
readOnly?: boolean;
|
99
|
-
className?: string;
|
100
|
-
}>;
|
101
|
-
components: RenderFunc;
|
102
|
-
componentItem: RenderFunc<{
|
103
|
-
children: ReactNode;
|
104
|
-
name: string;
|
105
|
-
}>;
|
106
|
-
outline: RenderFunc;
|
107
|
-
puck: RenderFunc;
|
108
|
-
}>;
|
109
|
-
type FieldRenderFunctions = Omit<{
|
110
|
-
[Type in Field["type"]]: React.FunctionComponent<FieldProps<Extract<Field, {
|
111
|
-
type: Type;
|
112
|
-
}>> & {
|
113
|
-
children: ReactNode;
|
114
|
-
name: string;
|
115
|
-
}>;
|
116
|
-
}, "custom"> & {
|
117
|
-
[key: string]: React.FunctionComponent<FieldProps<any> & {
|
118
|
-
children: ReactNode;
|
119
|
-
name: string;
|
120
|
-
}>;
|
121
|
-
};
|
122
|
-
|
123
|
-
type Plugin = {
|
124
|
-
overrides: Partial<Overrides>;
|
125
|
-
};
|
126
|
-
|
127
8
|
declare const ActionBar: {
|
128
9
|
({ label, children, }: {
|
129
10
|
label?: string;
|
130
11
|
children?: ReactNode;
|
131
12
|
}): react_jsx_runtime.JSX.Element;
|
132
|
-
Action: ({ children, onClick, }: {
|
13
|
+
Action: ({ children, label, onClick, }: {
|
133
14
|
children: ReactNode;
|
15
|
+
label?: string;
|
134
16
|
onClick: (e: SyntheticEvent) => void;
|
135
17
|
}) => react_jsx_runtime.JSX.Element;
|
136
18
|
};
|
137
|
-
declare const Action: ({ children, onClick, }: {
|
19
|
+
declare const Action: ({ children, label, onClick, }: {
|
138
20
|
children: ReactNode;
|
21
|
+
label?: string;
|
139
22
|
onClick: (e: SyntheticEvent) => void;
|
140
23
|
}) => react_jsx_runtime.JSX.Element;
|
141
24
|
|
@@ -192,7 +75,7 @@ declare const Drawer: {
|
|
192
75
|
droppableId?: string;
|
193
76
|
direction?: "vertical" | "horizontal";
|
194
77
|
}): react_jsx_runtime.JSX.Element;
|
195
|
-
Item: ({ name, children, id, label, index, }: {
|
78
|
+
Item: ({ name, children, id, label, index, isDragDisabled, }: {
|
196
79
|
name: string;
|
197
80
|
children?: (props: {
|
198
81
|
children: ReactNode;
|
@@ -201,30 +84,10 @@ declare const Drawer: {
|
|
201
84
|
id?: string;
|
202
85
|
label?: string;
|
203
86
|
index: number;
|
87
|
+
isDragDisabled?: boolean;
|
204
88
|
}) => react_jsx_runtime.JSX.Element;
|
205
89
|
};
|
206
90
|
|
207
|
-
type History<D = any> = {
|
208
|
-
id: string;
|
209
|
-
data: D;
|
210
|
-
};
|
211
|
-
type HistoryStore<D = any> = {
|
212
|
-
index: number;
|
213
|
-
hasPast: boolean;
|
214
|
-
hasFuture: boolean;
|
215
|
-
histories: History<D>[];
|
216
|
-
record: (data: D) => void;
|
217
|
-
back: VoidFunction;
|
218
|
-
forward: VoidFunction;
|
219
|
-
currentHistory: History;
|
220
|
-
nextHistory: History<D> | null;
|
221
|
-
prevHistory: History<D> | null;
|
222
|
-
setHistories: (histories: History[]) => void;
|
223
|
-
setHistoryIndex: (index: number) => void;
|
224
|
-
};
|
225
|
-
|
226
|
-
type OnAction = (action: PuckAction, appState: AppState, prevAppState: AppState) => void;
|
227
|
-
|
228
91
|
type PathData = Record<string, {
|
229
92
|
path: string[];
|
230
93
|
label: string;
|
@@ -277,27 +140,24 @@ declare const IconButton: ({ children, href, onClick, variant, type, disabled, t
|
|
277
140
|
title: string;
|
278
141
|
}) => react_jsx_runtime.JSX.Element;
|
279
142
|
|
280
|
-
|
281
|
-
enabled?: boolean;
|
282
|
-
};
|
283
|
-
|
284
|
-
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, }: {
|
143
|
+
declare function Puck<UserConfig extends Config = Config, UserProps extends ExtractPropsFromConfig<UserConfig> = ExtractPropsFromConfig<UserConfig>, UserRootProps extends ExtractRootPropsFromConfig<UserConfig> = ExtractRootPropsFromConfig<UserConfig>, UserData extends Data<UserProps, UserRootProps> | Data = Data<UserProps, UserRootProps>>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, onAction, permissions, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe, dnd, initialHistory: _initialHistory, }: {
|
285
144
|
children?: ReactNode;
|
286
145
|
config: UserConfig;
|
287
|
-
data: Partial<
|
146
|
+
data: Partial<UserData>;
|
288
147
|
ui?: Partial<UiState>;
|
289
|
-
onChange?: (data:
|
290
|
-
onPublish?: (data:
|
291
|
-
onAction?: OnAction
|
148
|
+
onChange?: (data: UserData) => void;
|
149
|
+
onPublish?: (data: UserData) => void;
|
150
|
+
onAction?: OnAction<UserData>;
|
151
|
+
permissions?: Partial<Permissions>;
|
292
152
|
plugins?: Plugin[];
|
293
153
|
overrides?: Partial<Overrides>;
|
294
154
|
renderHeader?: (props: {
|
295
155
|
children: ReactNode;
|
296
156
|
dispatch: (action: PuckAction) => void;
|
297
|
-
state: AppState
|
157
|
+
state: AppState<UserData>;
|
298
158
|
}) => ReactElement;
|
299
159
|
renderHeaderActions?: (props: {
|
300
|
-
state: AppState
|
160
|
+
state: AppState<UserData>;
|
301
161
|
dispatch: (action: PuckAction) => void;
|
302
162
|
}) => ReactElement;
|
303
163
|
headerTitle?: string;
|
@@ -307,10 +167,7 @@ declare function Puck<UserConfig extends Config = Config>({ children, config, da
|
|
307
167
|
dnd?: {
|
308
168
|
disableAutoScroll?: boolean;
|
309
169
|
};
|
310
|
-
initialHistory?:
|
311
|
-
histories: History<any>[];
|
312
|
-
index: number;
|
313
|
-
};
|
170
|
+
initialHistory?: InitialHistory;
|
314
171
|
}): react_jsx_runtime.JSX.Element;
|
315
172
|
declare namespace Puck {
|
316
173
|
var Components: () => react_jsx_runtime.JSX.Element;
|
@@ -321,14 +178,14 @@ declare namespace Puck {
|
|
321
178
|
}) => react_jsx_runtime.JSX.Element;
|
322
179
|
}
|
323
180
|
|
324
|
-
declare function Render<UserConfig extends Config = Config>({ config, data
|
181
|
+
declare function Render<UserConfig extends Config = Config, UserProps extends ExtractPropsFromConfig<UserConfig> = ExtractPropsFromConfig<UserConfig>, UserRootProps extends ExtractRootPropsFromConfig<UserConfig> = ExtractRootPropsFromConfig<UserConfig>, UserData extends Data<UserProps, UserRootProps> | Data = Data<UserProps, UserRootProps>>({ config, data }: {
|
325
182
|
config: UserConfig;
|
326
|
-
data: Partial<
|
183
|
+
data: Partial<UserData>;
|
327
184
|
}): react_jsx_runtime.JSX.Element;
|
328
185
|
|
329
186
|
declare function migrate(data: Data): Data;
|
330
187
|
|
331
|
-
type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends
|
188
|
+
type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
|
332
189
|
[ComponentName in keyof Props]: (props: Props[ComponentName] & {
|
333
190
|
[key: string]: any;
|
334
191
|
}) => Props[ComponentName];
|
@@ -337,18 +194,40 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
|
|
337
194
|
[key: string]: any;
|
338
195
|
}) => RootProps;
|
339
196
|
}>;
|
340
|
-
declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps =
|
197
|
+
declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
|
341
198
|
|
342
|
-
declare function resolveAllData(data: Partial<Data>, config: Config, onResolveStart?: (item:
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
199
|
+
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>>;
|
200
|
+
|
201
|
+
type HistoryStore<D = any> = {
|
202
|
+
index: number;
|
203
|
+
hasPast: boolean;
|
204
|
+
hasFuture: boolean;
|
205
|
+
histories: History<D>[];
|
206
|
+
record: (data: D) => void;
|
207
|
+
back: VoidFunction;
|
208
|
+
forward: VoidFunction;
|
209
|
+
currentHistory: History;
|
210
|
+
nextHistory: History<D> | null;
|
211
|
+
prevHistory: History<D> | null;
|
212
|
+
setHistories: (histories: History[]) => void;
|
213
|
+
setHistoryIndex: (index: number) => void;
|
214
|
+
};
|
347
215
|
|
348
216
|
declare const usePuck: () => {
|
349
217
|
appState: AppState;
|
350
218
|
config: Config;
|
351
219
|
dispatch: (action: PuckAction) => void;
|
220
|
+
getPermissions: ({ item, type, }?: {
|
221
|
+
item?: ComponentData;
|
222
|
+
type?: keyof DefaultComponentProps;
|
223
|
+
}) => {
|
224
|
+
[x: string]: boolean | undefined;
|
225
|
+
drag?: boolean | undefined;
|
226
|
+
duplicate?: boolean | undefined;
|
227
|
+
delete?: boolean | undefined;
|
228
|
+
edit?: boolean | undefined;
|
229
|
+
insert?: boolean | undefined;
|
230
|
+
};
|
352
231
|
history: {
|
353
232
|
back: VoidFunction;
|
354
233
|
forward: VoidFunction;
|
@@ -360,9 +239,7 @@ declare const usePuck: () => {
|
|
360
239
|
index: number;
|
361
240
|
historyStore: HistoryStore | undefined;
|
362
241
|
};
|
363
|
-
selectedItem: ComponentData<
|
364
|
-
id: string;
|
365
|
-
}> | null;
|
242
|
+
selectedItem: ComponentData<any, string> | null;
|
366
243
|
};
|
367
244
|
|
368
|
-
export { Action, ActionBar, AppState, AutoField, AutoFieldPrivate, Button, ComponentData, Config, Data, DefaultComponentProps,
|
245
|
+
export { Action, ActionBar, AppState, AutoField, AutoFieldPrivate, Button, ComponentData, Config, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, DropZone, DropZoneProvider, ExtractPropsFromConfig, ExtractRootPropsFromConfig, Field, FieldLabel, FieldLabelInternal, FieldProps, type FieldPropsInternal, History, IconButton, IframeConfig, InitialHistory, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, Render, UiState, Viewports, dropZoneContext, migrate, resolveAllData, transformProps, usePuck };
|