@measured/puck 0.19.0-canary.b9add22 → 0.19.0-canary.bc5bfff1
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/README.md +2 -4
- package/dist/chunk-DCJTUSJF.mjs +925 -0
- package/dist/index.css +201 -184
- package/dist/index.d.mts +152 -55
- package/dist/index.d.ts +152 -55
- package/dist/index.js +4343 -3548
- package/dist/index.mjs +3468 -3286
- package/dist/rsc.d.mts +3 -3
- package/dist/rsc.d.ts +3 -3
- package/dist/rsc.js +668 -137
- package/dist/rsc.mjs +9 -102
- package/dist/{resolve-all-data-DIpcwlzP.d.mts → walk-tree-lpK_Xw1z.d.mts} +121 -28
- package/dist/{resolve-all-data-DIpcwlzP.d.ts → walk-tree-lpK_Xw1z.d.ts} +121 -28
- package/package.json +11 -7
- package/dist/chunk-FNRHXUGA.mjs +0 -268
package/dist/index.d.mts
CHANGED
@@ -1,8 +1,111 @@
|
|
1
|
-
import {
|
2
|
-
export {
|
1
|
+
import { H as History, P as Permissions, C as ComponentData, a as Config, U as UserGenerics, F as Fields, b as PuckAction, R as RootDataWithProps, c as ResolveDataTrigger, d as Plugin, O as Overrides, V as Viewports, I as IframeConfig, e as UiState, f as ComponentConfig, A as AppState, M as Metadata, g as Field, h as FieldProps, D as DropZoneProps, i as Data, j as OnAction, k as InitialHistory, l as ItemSelector } from './walk-tree-lpK_Xw1z.mjs';
|
2
|
+
export { _ as Adaptor, Y as ArrayField, t as ArrayState, ab as AsFieldProps, B as BaseData, K as BaseField, G as ComponentDataMap, z as ComponentDataOptionalId, J as Content, a2 as CustomField, a1 as CustomFieldRender, a8 as DefaultComponentProps, a5 as DefaultRootFieldProps, a7 as DefaultRootProps, a6 as DefaultRootRenderProps, m as Direction, n as DragAxis, a0 as ExternalField, $ as ExternalFieldWithAdaptor, ad as ExtractPropsFromConfig, ae as ExtractRootPropsFromConfig, r as FieldRenderFunctions, s as ItemWithId, E as MappedItem, N as NumberField, Z as ObjectField, q as OverrideKey, u as PuckComponent, a4 as PuckContext, X as RadioField, v as RootConfig, y as RootData, x as RootDataWithoutProps, Q as SelectField, S as Slot, a3 as SlotField, T as TextField, L as TextareaField, o as Viewport, ac as WithChildren, a9 as WithId, aa as WithPuckProps, W as WithSlotProps, af as migrate, p as overrideKeys, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-lpK_Xw1z.mjs';
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
4
4
|
import * as react from 'react';
|
5
|
-
import { ReactNode, SyntheticEvent, ReactElement } from 'react';
|
5
|
+
import react__default, { ReactNode, SyntheticEvent, ReactElement } from 'react';
|
6
|
+
|
7
|
+
type HistorySlice<D = any> = {
|
8
|
+
index: number;
|
9
|
+
hasPast: () => boolean;
|
10
|
+
hasFuture: () => boolean;
|
11
|
+
histories: History<D>[];
|
12
|
+
record: (data: D) => void;
|
13
|
+
back: VoidFunction;
|
14
|
+
forward: VoidFunction;
|
15
|
+
currentHistory: () => History;
|
16
|
+
nextHistory: () => History<D> | null;
|
17
|
+
prevHistory: () => History<D> | null;
|
18
|
+
setHistories: (histories: History[]) => void;
|
19
|
+
setHistoryIndex: (index: number) => void;
|
20
|
+
initialAppState: D;
|
21
|
+
};
|
22
|
+
|
23
|
+
type NodeMethods = {
|
24
|
+
sync: () => void;
|
25
|
+
hideOverlay: () => void;
|
26
|
+
showOverlay: () => void;
|
27
|
+
};
|
28
|
+
type PuckNodeInstance = {
|
29
|
+
id: string;
|
30
|
+
methods: NodeMethods;
|
31
|
+
element: HTMLElement | null;
|
32
|
+
};
|
33
|
+
type NodesSlice = {
|
34
|
+
nodes: Record<string, PuckNodeInstance | undefined>;
|
35
|
+
registerNode: (id: string, node: Partial<PuckNodeInstance>) => void;
|
36
|
+
unregisterNode: (id: string, node?: Partial<PuckNodeInstance>) => void;
|
37
|
+
};
|
38
|
+
|
39
|
+
type PermissionsArgs<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
40
|
+
item?: G["UserComponentData"] | null;
|
41
|
+
type?: keyof G["UserProps"];
|
42
|
+
root?: boolean;
|
43
|
+
};
|
44
|
+
type GetPermissions<UserConfig extends Config = Config> = (params?: PermissionsArgs<UserConfig>) => Permissions;
|
45
|
+
type ResolvePermissions<UserConfig extends Config = Config> = (params?: PermissionsArgs<UserConfig>, force?: boolean) => void;
|
46
|
+
type RefreshPermissions<UserConfig extends Config = Config> = (params?: PermissionsArgs<UserConfig>, force?: boolean) => void;
|
47
|
+
type Cache = Record<string, {
|
48
|
+
lastPermissions: Partial<Permissions>;
|
49
|
+
lastData: ComponentData | null;
|
50
|
+
}>;
|
51
|
+
type PermissionsSlice = {
|
52
|
+
cache: Cache;
|
53
|
+
globalPermissions: Permissions;
|
54
|
+
resolvedPermissions: Record<string, Partial<Permissions> | undefined>;
|
55
|
+
getPermissions: GetPermissions<Config>;
|
56
|
+
resolvePermissions: ResolvePermissions<Config>;
|
57
|
+
refreshPermissions: RefreshPermissions<Config>;
|
58
|
+
};
|
59
|
+
|
60
|
+
type ComponentOrRootData = Omit<ComponentData<any>, "type">;
|
61
|
+
type FieldsSlice = {
|
62
|
+
fields: Fields | Partial<Fields>;
|
63
|
+
loading: boolean;
|
64
|
+
lastResolvedData: Partial<ComponentOrRootData>;
|
65
|
+
id: string | undefined;
|
66
|
+
};
|
67
|
+
|
68
|
+
type Status = "LOADING" | "MOUNTED" | "READY";
|
69
|
+
type ZoomConfig = {
|
70
|
+
autoZoom: number;
|
71
|
+
rootHeight: number;
|
72
|
+
zoom: number;
|
73
|
+
};
|
74
|
+
type ComponentState = Record<string, {
|
75
|
+
loadingCount: number;
|
76
|
+
}>;
|
77
|
+
type AppStore<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
78
|
+
state: G["UserAppState"];
|
79
|
+
dispatch: (action: PuckAction) => void;
|
80
|
+
config: UserConfig;
|
81
|
+
componentState: ComponentState;
|
82
|
+
setComponentState: (componentState: ComponentState) => void;
|
83
|
+
setComponentLoading: (id: string, loading?: boolean, defer?: number) => () => void;
|
84
|
+
unsetComponentLoading: (id: string) => void;
|
85
|
+
pendingLoadTimeouts: Record<string, NodeJS.Timeout>;
|
86
|
+
resolveComponentData: <T extends ComponentData | RootDataWithProps>(componentData: T, trigger: ResolveDataTrigger) => Promise<{
|
87
|
+
node: T;
|
88
|
+
didChange: boolean;
|
89
|
+
}>;
|
90
|
+
resolveAndCommitData: () => void;
|
91
|
+
plugins: Plugin[];
|
92
|
+
overrides: Partial<Overrides>;
|
93
|
+
viewports: Viewports;
|
94
|
+
zoomConfig: ZoomConfig;
|
95
|
+
setZoomConfig: (zoomConfig: ZoomConfig) => void;
|
96
|
+
status: Status;
|
97
|
+
setStatus: (status: Status) => void;
|
98
|
+
iframe: IframeConfig;
|
99
|
+
selectedItem?: G["UserData"]["content"][0] | null;
|
100
|
+
setUi: (ui: Partial<UiState>, recordHistory?: boolean) => void;
|
101
|
+
getComponentConfig: (type?: string) => ComponentConfig | null | undefined;
|
102
|
+
onAction?: (action: PuckAction, newState: AppState, state: AppState) => void;
|
103
|
+
metadata: Metadata;
|
104
|
+
fields: FieldsSlice;
|
105
|
+
history: HistorySlice;
|
106
|
+
nodes: NodesSlice;
|
107
|
+
permissions: PermissionsSlice;
|
108
|
+
};
|
6
109
|
|
7
110
|
declare const ActionBar: {
|
8
111
|
({ label, children, }: {
|
@@ -42,7 +145,7 @@ declare const FieldLabel: ({ children, icon, label, el, readOnly, className, }:
|
|
42
145
|
className?: string;
|
43
146
|
}) => react_jsx_runtime.JSX.Element;
|
44
147
|
type FieldNoLabel<Props extends any = any> = Omit<Field<Props>, "label">;
|
45
|
-
declare function AutoField<ValueType = any, FieldType extends FieldNoLabel<ValueType> = FieldNoLabel<ValueType>>(props: FieldProps<FieldType, ValueType>): react_jsx_runtime.JSX.Element;
|
148
|
+
declare function AutoField<ValueType = any, FieldType extends FieldNoLabel<ValueType> = FieldNoLabel<ValueType>>(props: FieldProps<FieldType, ValueType>): react_jsx_runtime.JSX.Element | null;
|
46
149
|
|
47
150
|
declare const Button: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, icon, size, loading: loadingProp, ...props }: {
|
48
151
|
children: ReactNode;
|
@@ -93,7 +196,7 @@ declare const IconButton: ({ children, href, onClick, variant, type, disabled, t
|
|
93
196
|
title: string;
|
94
197
|
}) => react_jsx_runtime.JSX.Element;
|
95
198
|
|
96
|
-
|
199
|
+
type PuckProps<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
97
200
|
children?: ReactNode;
|
98
201
|
config: UserConfig;
|
99
202
|
data: Partial<G["UserData"] | Data>;
|
@@ -122,78 +225,72 @@ declare function Puck<UserConfig extends Config = Config, G extends UserGenerics
|
|
122
225
|
};
|
123
226
|
initialHistory?: InitialHistory;
|
124
227
|
metadata?: Metadata;
|
125
|
-
}
|
228
|
+
};
|
229
|
+
declare function Puck<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(props: PuckProps<UserConfig>): react_jsx_runtime.JSX.Element;
|
126
230
|
declare namespace Puck {
|
127
231
|
var Components: () => react_jsx_runtime.JSX.Element;
|
128
|
-
var Fields: ({ wrapFields }: {
|
232
|
+
var Fields: react.MemoExoticComponent<({ wrapFields }: {
|
129
233
|
wrapFields?: boolean;
|
130
|
-
}) => react_jsx_runtime.JSX.Element
|
234
|
+
}) => react_jsx_runtime.JSX.Element>;
|
131
235
|
var Outline: () => react_jsx_runtime.JSX.Element;
|
132
236
|
var Preview: ({ id }: {
|
133
237
|
id?: string;
|
134
238
|
}) => react_jsx_runtime.JSX.Element;
|
135
239
|
}
|
136
240
|
|
241
|
+
declare const renderContext: react__default.Context<{
|
242
|
+
config: Config;
|
243
|
+
data: Data;
|
244
|
+
metadata: Metadata;
|
245
|
+
}>;
|
137
246
|
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
|
138
247
|
config: UserConfig;
|
139
248
|
data: Partial<G["UserData"] | Data>;
|
140
249
|
metadata?: Metadata;
|
141
250
|
}): react_jsx_runtime.JSX.Element;
|
142
251
|
|
143
|
-
|
144
|
-
|
145
|
-
type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
|
146
|
-
[ComponentName in keyof Props]: (props: Props[ComponentName] & {
|
147
|
-
[key: string]: any;
|
148
|
-
}) => Props[ComponentName];
|
149
|
-
} & {
|
150
|
-
root: (props: RootProps & {
|
151
|
-
[key: string]: any;
|
152
|
-
}) => RootProps;
|
153
|
-
}>;
|
154
|
-
declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
|
155
|
-
|
156
|
-
type HistoryStore<D = any> = {
|
157
|
-
index: number;
|
158
|
-
hasPast: boolean;
|
159
|
-
hasFuture: boolean;
|
160
|
-
histories: History<D>[];
|
161
|
-
record: (data: D) => void;
|
162
|
-
back: VoidFunction;
|
163
|
-
forward: VoidFunction;
|
164
|
-
currentHistory: History;
|
165
|
-
nextHistory: History<D> | null;
|
166
|
-
prevHistory: History<D> | null;
|
167
|
-
setHistories: (histories: History[]) => void;
|
168
|
-
setHistoryIndex: (index: number) => void;
|
169
|
-
};
|
170
|
-
|
171
|
-
type PermissionsArgs<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
172
|
-
item?: G["UserComponentData"];
|
173
|
-
type?: keyof G["UserProps"];
|
174
|
-
root?: boolean;
|
252
|
+
type WithGet<T> = T & {
|
253
|
+
get: () => T;
|
175
254
|
};
|
176
|
-
type
|
177
|
-
|
178
|
-
|
179
|
-
declare const usePuck: <UserConfig extends Config = Config>() => {
|
180
|
-
appState: AppState<Data<ExtractPropsFromConfig<UserConfig>, ExtractRootPropsFromConfig<UserConfig>>>;
|
255
|
+
type UsePuckData<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
256
|
+
appState: AppState;
|
181
257
|
config: UserConfig;
|
182
|
-
dispatch:
|
258
|
+
dispatch: AppStore["dispatch"];
|
183
259
|
getPermissions: GetPermissions<UserConfig>;
|
184
260
|
refreshPermissions: RefreshPermissions<UserConfig>;
|
261
|
+
selectedItem: G["UserComponentData"] | null;
|
262
|
+
getItemBySelector: (selector: ItemSelector) => ComponentData | undefined;
|
263
|
+
getItemById: (id: string) => ComponentData | undefined;
|
264
|
+
getSelectorForId: (id: string) => Required<ItemSelector> | undefined;
|
185
265
|
history: {
|
186
|
-
back:
|
187
|
-
forward:
|
188
|
-
setHistories:
|
189
|
-
setHistoryIndex:
|
266
|
+
back: HistorySlice["back"];
|
267
|
+
forward: HistorySlice["forward"];
|
268
|
+
setHistories: HistorySlice["setHistories"];
|
269
|
+
setHistoryIndex: HistorySlice["setHistoryIndex"];
|
270
|
+
histories: HistorySlice["histories"];
|
271
|
+
index: HistorySlice["index"];
|
190
272
|
hasPast: boolean;
|
191
273
|
hasFuture: boolean;
|
192
|
-
histories: History<any>[];
|
193
|
-
index: number;
|
194
|
-
historyStore: HistoryStore | undefined;
|
195
274
|
};
|
196
|
-
selectedItem: ComponentDataMap<ExtractPropsFromConfig<UserConfig>> | null;
|
197
275
|
};
|
276
|
+
type PuckApi<UserConfig extends Config = Config> = UsePuckData<UserConfig>;
|
277
|
+
type UsePuckStore<UserConfig extends Config = Config> = WithGet<PuckApi<UserConfig>>;
|
278
|
+
/**
|
279
|
+
* createUsePuck
|
280
|
+
*
|
281
|
+
* Create a typed usePuck hook, which is necessary because the user may provide a generic type but not
|
282
|
+
* a selector type, and TS does not currently support partial inference.
|
283
|
+
* Related: https://github.com/microsoft/TypeScript/issues/26242
|
284
|
+
*
|
285
|
+
* @returns a typed usePuck function
|
286
|
+
*/
|
287
|
+
declare function createUsePuck<UserConfig extends Config = Config>(): <T = PuckApi<UserConfig>>(selector: (state: UsePuckStore<UserConfig>) => T) => T;
|
288
|
+
declare function usePuck<UserConfig extends Config = Config>(): UsePuckStore<UserConfig>;
|
289
|
+
/**
|
290
|
+
* Get the latest state without relying on a render
|
291
|
+
*
|
292
|
+
* @returns PuckApi
|
293
|
+
*/
|
294
|
+
declare function useGetPuck(): () => UsePuckStore<Config>;
|
198
295
|
|
199
|
-
export { Action, ActionBar, AppState, AutoField, Button,
|
296
|
+
export { Action, ActionBar, AppState, AutoField, Button, ComponentConfig, ComponentData, Config, Data, Drawer, DropZone, Field, FieldLabel, FieldProps, Fields, Group, History, IconButton, IframeConfig, InitialHistory, Label, Metadata, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, type PuckApi, Render, ResolveDataTrigger, RootDataWithProps, UiState, type UsePuckData, UserGenerics, Viewports, createUsePuck, renderContext, useGetPuck, usePuck };
|
package/dist/index.d.ts
CHANGED
@@ -1,8 +1,111 @@
|
|
1
|
-
import {
|
2
|
-
export {
|
1
|
+
import { H as History, P as Permissions, C as ComponentData, a as Config, U as UserGenerics, F as Fields, b as PuckAction, R as RootDataWithProps, c as ResolveDataTrigger, d as Plugin, O as Overrides, V as Viewports, I as IframeConfig, e as UiState, f as ComponentConfig, A as AppState, M as Metadata, g as Field, h as FieldProps, D as DropZoneProps, i as Data, j as OnAction, k as InitialHistory, l as ItemSelector } from './walk-tree-lpK_Xw1z.js';
|
2
|
+
export { _ as Adaptor, Y as ArrayField, t as ArrayState, ab as AsFieldProps, B as BaseData, K as BaseField, G as ComponentDataMap, z as ComponentDataOptionalId, J as Content, a2 as CustomField, a1 as CustomFieldRender, a8 as DefaultComponentProps, a5 as DefaultRootFieldProps, a7 as DefaultRootProps, a6 as DefaultRootRenderProps, m as Direction, n as DragAxis, a0 as ExternalField, $ as ExternalFieldWithAdaptor, ad as ExtractPropsFromConfig, ae as ExtractRootPropsFromConfig, r as FieldRenderFunctions, s as ItemWithId, E as MappedItem, N as NumberField, Z as ObjectField, q as OverrideKey, u as PuckComponent, a4 as PuckContext, X as RadioField, v as RootConfig, y as RootData, x as RootDataWithoutProps, Q as SelectField, S as Slot, a3 as SlotField, T as TextField, L as TextareaField, o as Viewport, ac as WithChildren, a9 as WithId, aa as WithPuckProps, W as WithSlotProps, af as migrate, p as overrideKeys, ah as resolveAllData, ag as transformProps, w as walkTree } from './walk-tree-lpK_Xw1z.js';
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
4
4
|
import * as react from 'react';
|
5
|
-
import { ReactNode, SyntheticEvent, ReactElement } from 'react';
|
5
|
+
import react__default, { ReactNode, SyntheticEvent, ReactElement } from 'react';
|
6
|
+
|
7
|
+
type HistorySlice<D = any> = {
|
8
|
+
index: number;
|
9
|
+
hasPast: () => boolean;
|
10
|
+
hasFuture: () => boolean;
|
11
|
+
histories: History<D>[];
|
12
|
+
record: (data: D) => void;
|
13
|
+
back: VoidFunction;
|
14
|
+
forward: VoidFunction;
|
15
|
+
currentHistory: () => History;
|
16
|
+
nextHistory: () => History<D> | null;
|
17
|
+
prevHistory: () => History<D> | null;
|
18
|
+
setHistories: (histories: History[]) => void;
|
19
|
+
setHistoryIndex: (index: number) => void;
|
20
|
+
initialAppState: D;
|
21
|
+
};
|
22
|
+
|
23
|
+
type NodeMethods = {
|
24
|
+
sync: () => void;
|
25
|
+
hideOverlay: () => void;
|
26
|
+
showOverlay: () => void;
|
27
|
+
};
|
28
|
+
type PuckNodeInstance = {
|
29
|
+
id: string;
|
30
|
+
methods: NodeMethods;
|
31
|
+
element: HTMLElement | null;
|
32
|
+
};
|
33
|
+
type NodesSlice = {
|
34
|
+
nodes: Record<string, PuckNodeInstance | undefined>;
|
35
|
+
registerNode: (id: string, node: Partial<PuckNodeInstance>) => void;
|
36
|
+
unregisterNode: (id: string, node?: Partial<PuckNodeInstance>) => void;
|
37
|
+
};
|
38
|
+
|
39
|
+
type PermissionsArgs<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
40
|
+
item?: G["UserComponentData"] | null;
|
41
|
+
type?: keyof G["UserProps"];
|
42
|
+
root?: boolean;
|
43
|
+
};
|
44
|
+
type GetPermissions<UserConfig extends Config = Config> = (params?: PermissionsArgs<UserConfig>) => Permissions;
|
45
|
+
type ResolvePermissions<UserConfig extends Config = Config> = (params?: PermissionsArgs<UserConfig>, force?: boolean) => void;
|
46
|
+
type RefreshPermissions<UserConfig extends Config = Config> = (params?: PermissionsArgs<UserConfig>, force?: boolean) => void;
|
47
|
+
type Cache = Record<string, {
|
48
|
+
lastPermissions: Partial<Permissions>;
|
49
|
+
lastData: ComponentData | null;
|
50
|
+
}>;
|
51
|
+
type PermissionsSlice = {
|
52
|
+
cache: Cache;
|
53
|
+
globalPermissions: Permissions;
|
54
|
+
resolvedPermissions: Record<string, Partial<Permissions> | undefined>;
|
55
|
+
getPermissions: GetPermissions<Config>;
|
56
|
+
resolvePermissions: ResolvePermissions<Config>;
|
57
|
+
refreshPermissions: RefreshPermissions<Config>;
|
58
|
+
};
|
59
|
+
|
60
|
+
type ComponentOrRootData = Omit<ComponentData<any>, "type">;
|
61
|
+
type FieldsSlice = {
|
62
|
+
fields: Fields | Partial<Fields>;
|
63
|
+
loading: boolean;
|
64
|
+
lastResolvedData: Partial<ComponentOrRootData>;
|
65
|
+
id: string | undefined;
|
66
|
+
};
|
67
|
+
|
68
|
+
type Status = "LOADING" | "MOUNTED" | "READY";
|
69
|
+
type ZoomConfig = {
|
70
|
+
autoZoom: number;
|
71
|
+
rootHeight: number;
|
72
|
+
zoom: number;
|
73
|
+
};
|
74
|
+
type ComponentState = Record<string, {
|
75
|
+
loadingCount: number;
|
76
|
+
}>;
|
77
|
+
type AppStore<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
78
|
+
state: G["UserAppState"];
|
79
|
+
dispatch: (action: PuckAction) => void;
|
80
|
+
config: UserConfig;
|
81
|
+
componentState: ComponentState;
|
82
|
+
setComponentState: (componentState: ComponentState) => void;
|
83
|
+
setComponentLoading: (id: string, loading?: boolean, defer?: number) => () => void;
|
84
|
+
unsetComponentLoading: (id: string) => void;
|
85
|
+
pendingLoadTimeouts: Record<string, NodeJS.Timeout>;
|
86
|
+
resolveComponentData: <T extends ComponentData | RootDataWithProps>(componentData: T, trigger: ResolveDataTrigger) => Promise<{
|
87
|
+
node: T;
|
88
|
+
didChange: boolean;
|
89
|
+
}>;
|
90
|
+
resolveAndCommitData: () => void;
|
91
|
+
plugins: Plugin[];
|
92
|
+
overrides: Partial<Overrides>;
|
93
|
+
viewports: Viewports;
|
94
|
+
zoomConfig: ZoomConfig;
|
95
|
+
setZoomConfig: (zoomConfig: ZoomConfig) => void;
|
96
|
+
status: Status;
|
97
|
+
setStatus: (status: Status) => void;
|
98
|
+
iframe: IframeConfig;
|
99
|
+
selectedItem?: G["UserData"]["content"][0] | null;
|
100
|
+
setUi: (ui: Partial<UiState>, recordHistory?: boolean) => void;
|
101
|
+
getComponentConfig: (type?: string) => ComponentConfig | null | undefined;
|
102
|
+
onAction?: (action: PuckAction, newState: AppState, state: AppState) => void;
|
103
|
+
metadata: Metadata;
|
104
|
+
fields: FieldsSlice;
|
105
|
+
history: HistorySlice;
|
106
|
+
nodes: NodesSlice;
|
107
|
+
permissions: PermissionsSlice;
|
108
|
+
};
|
6
109
|
|
7
110
|
declare const ActionBar: {
|
8
111
|
({ label, children, }: {
|
@@ -42,7 +145,7 @@ declare const FieldLabel: ({ children, icon, label, el, readOnly, className, }:
|
|
42
145
|
className?: string;
|
43
146
|
}) => react_jsx_runtime.JSX.Element;
|
44
147
|
type FieldNoLabel<Props extends any = any> = Omit<Field<Props>, "label">;
|
45
|
-
declare function AutoField<ValueType = any, FieldType extends FieldNoLabel<ValueType> = FieldNoLabel<ValueType>>(props: FieldProps<FieldType, ValueType>): react_jsx_runtime.JSX.Element;
|
148
|
+
declare function AutoField<ValueType = any, FieldType extends FieldNoLabel<ValueType> = FieldNoLabel<ValueType>>(props: FieldProps<FieldType, ValueType>): react_jsx_runtime.JSX.Element | null;
|
46
149
|
|
47
150
|
declare const Button: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, icon, size, loading: loadingProp, ...props }: {
|
48
151
|
children: ReactNode;
|
@@ -93,7 +196,7 @@ declare const IconButton: ({ children, href, onClick, variant, type, disabled, t
|
|
93
196
|
title: string;
|
94
197
|
}) => react_jsx_runtime.JSX.Element;
|
95
198
|
|
96
|
-
|
199
|
+
type PuckProps<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
97
200
|
children?: ReactNode;
|
98
201
|
config: UserConfig;
|
99
202
|
data: Partial<G["UserData"] | Data>;
|
@@ -122,78 +225,72 @@ declare function Puck<UserConfig extends Config = Config, G extends UserGenerics
|
|
122
225
|
};
|
123
226
|
initialHistory?: InitialHistory;
|
124
227
|
metadata?: Metadata;
|
125
|
-
}
|
228
|
+
};
|
229
|
+
declare function Puck<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(props: PuckProps<UserConfig>): react_jsx_runtime.JSX.Element;
|
126
230
|
declare namespace Puck {
|
127
231
|
var Components: () => react_jsx_runtime.JSX.Element;
|
128
|
-
var Fields: ({ wrapFields }: {
|
232
|
+
var Fields: react.MemoExoticComponent<({ wrapFields }: {
|
129
233
|
wrapFields?: boolean;
|
130
|
-
}) => react_jsx_runtime.JSX.Element
|
234
|
+
}) => react_jsx_runtime.JSX.Element>;
|
131
235
|
var Outline: () => react_jsx_runtime.JSX.Element;
|
132
236
|
var Preview: ({ id }: {
|
133
237
|
id?: string;
|
134
238
|
}) => react_jsx_runtime.JSX.Element;
|
135
239
|
}
|
136
240
|
|
241
|
+
declare const renderContext: react__default.Context<{
|
242
|
+
config: Config;
|
243
|
+
data: Data;
|
244
|
+
metadata: Metadata;
|
245
|
+
}>;
|
137
246
|
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
|
138
247
|
config: UserConfig;
|
139
248
|
data: Partial<G["UserData"] | Data>;
|
140
249
|
metadata?: Metadata;
|
141
250
|
}): react_jsx_runtime.JSX.Element;
|
142
251
|
|
143
|
-
|
144
|
-
|
145
|
-
type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
|
146
|
-
[ComponentName in keyof Props]: (props: Props[ComponentName] & {
|
147
|
-
[key: string]: any;
|
148
|
-
}) => Props[ComponentName];
|
149
|
-
} & {
|
150
|
-
root: (props: RootProps & {
|
151
|
-
[key: string]: any;
|
152
|
-
}) => RootProps;
|
153
|
-
}>;
|
154
|
-
declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
|
155
|
-
|
156
|
-
type HistoryStore<D = any> = {
|
157
|
-
index: number;
|
158
|
-
hasPast: boolean;
|
159
|
-
hasFuture: boolean;
|
160
|
-
histories: History<D>[];
|
161
|
-
record: (data: D) => void;
|
162
|
-
back: VoidFunction;
|
163
|
-
forward: VoidFunction;
|
164
|
-
currentHistory: History;
|
165
|
-
nextHistory: History<D> | null;
|
166
|
-
prevHistory: History<D> | null;
|
167
|
-
setHistories: (histories: History[]) => void;
|
168
|
-
setHistoryIndex: (index: number) => void;
|
169
|
-
};
|
170
|
-
|
171
|
-
type PermissionsArgs<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
172
|
-
item?: G["UserComponentData"];
|
173
|
-
type?: keyof G["UserProps"];
|
174
|
-
root?: boolean;
|
252
|
+
type WithGet<T> = T & {
|
253
|
+
get: () => T;
|
175
254
|
};
|
176
|
-
type
|
177
|
-
|
178
|
-
|
179
|
-
declare const usePuck: <UserConfig extends Config = Config>() => {
|
180
|
-
appState: AppState<Data<ExtractPropsFromConfig<UserConfig>, ExtractRootPropsFromConfig<UserConfig>>>;
|
255
|
+
type UsePuckData<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
256
|
+
appState: AppState;
|
181
257
|
config: UserConfig;
|
182
|
-
dispatch:
|
258
|
+
dispatch: AppStore["dispatch"];
|
183
259
|
getPermissions: GetPermissions<UserConfig>;
|
184
260
|
refreshPermissions: RefreshPermissions<UserConfig>;
|
261
|
+
selectedItem: G["UserComponentData"] | null;
|
262
|
+
getItemBySelector: (selector: ItemSelector) => ComponentData | undefined;
|
263
|
+
getItemById: (id: string) => ComponentData | undefined;
|
264
|
+
getSelectorForId: (id: string) => Required<ItemSelector> | undefined;
|
185
265
|
history: {
|
186
|
-
back:
|
187
|
-
forward:
|
188
|
-
setHistories:
|
189
|
-
setHistoryIndex:
|
266
|
+
back: HistorySlice["back"];
|
267
|
+
forward: HistorySlice["forward"];
|
268
|
+
setHistories: HistorySlice["setHistories"];
|
269
|
+
setHistoryIndex: HistorySlice["setHistoryIndex"];
|
270
|
+
histories: HistorySlice["histories"];
|
271
|
+
index: HistorySlice["index"];
|
190
272
|
hasPast: boolean;
|
191
273
|
hasFuture: boolean;
|
192
|
-
histories: History<any>[];
|
193
|
-
index: number;
|
194
|
-
historyStore: HistoryStore | undefined;
|
195
274
|
};
|
196
|
-
selectedItem: ComponentDataMap<ExtractPropsFromConfig<UserConfig>> | null;
|
197
275
|
};
|
276
|
+
type PuckApi<UserConfig extends Config = Config> = UsePuckData<UserConfig>;
|
277
|
+
type UsePuckStore<UserConfig extends Config = Config> = WithGet<PuckApi<UserConfig>>;
|
278
|
+
/**
|
279
|
+
* createUsePuck
|
280
|
+
*
|
281
|
+
* Create a typed usePuck hook, which is necessary because the user may provide a generic type but not
|
282
|
+
* a selector type, and TS does not currently support partial inference.
|
283
|
+
* Related: https://github.com/microsoft/TypeScript/issues/26242
|
284
|
+
*
|
285
|
+
* @returns a typed usePuck function
|
286
|
+
*/
|
287
|
+
declare function createUsePuck<UserConfig extends Config = Config>(): <T = PuckApi<UserConfig>>(selector: (state: UsePuckStore<UserConfig>) => T) => T;
|
288
|
+
declare function usePuck<UserConfig extends Config = Config>(): UsePuckStore<UserConfig>;
|
289
|
+
/**
|
290
|
+
* Get the latest state without relying on a render
|
291
|
+
*
|
292
|
+
* @returns PuckApi
|
293
|
+
*/
|
294
|
+
declare function useGetPuck(): () => UsePuckStore<Config>;
|
198
295
|
|
199
|
-
export { Action, ActionBar, AppState, AutoField, Button,
|
296
|
+
export { Action, ActionBar, AppState, AutoField, Button, ComponentConfig, ComponentData, Config, Data, Drawer, DropZone, Field, FieldLabel, FieldProps, Fields, Group, History, IconButton, IframeConfig, InitialHistory, Label, Metadata, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, type PuckApi, Render, ResolveDataTrigger, RootDataWithProps, UiState, type UsePuckData, UserGenerics, Viewports, createUsePuck, renderContext, useGetPuck, usePuck };
|