@measured/puck 0.19.0-canary.0ea6ce4 → 0.19.0-canary.1918ad70
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/chunk-D4ZXRBOO.mjs +5263 -0
- package/dist/index.css +28 -17
- package/dist/index.d.mts +138 -52
- package/dist/index.d.ts +138 -52
- package/dist/index.js +3255 -2757
- package/dist/index.mjs +2310 -6704
- package/dist/{resolve-all-data-D4okkICg.d.mts → resolve-all-data-Cs8PfTrg.d.mts} +66 -12
- package/dist/{resolve-all-data-D4okkICg.d.ts → resolve-all-data-Cs8PfTrg.d.ts} +66 -12
- package/dist/rsc.css +338 -0
- package/dist/rsc.d.mts +3 -3
- package/dist/rsc.d.ts +3 -3
- package/dist/rsc.js +3763 -205
- package/dist/rsc.mjs +59 -56
- package/package.json +6 -4
- package/dist/chunk-FNRHXUGA.mjs +0 -268
package/dist/index.css
CHANGED
@@ -612,6 +612,19 @@ textarea._Input-input_g5w3n_26 {
|
|
612
612
|
}
|
613
613
|
}
|
614
614
|
|
615
|
+
/* components/Sortable/styles.css */
|
616
|
+
[data-dnd-placeholder] * {
|
617
|
+
opacity: 0 !important;
|
618
|
+
}
|
619
|
+
[data-dnd-placeholder] {
|
620
|
+
background: var(--puck-color-azure-09) !important;
|
621
|
+
border: none !important;
|
622
|
+
color: #00000000 !important;
|
623
|
+
opacity: 0.3 !important;
|
624
|
+
outline: none !important;
|
625
|
+
transition: none !important;
|
626
|
+
}
|
627
|
+
|
615
628
|
/* css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css/#css-module-data */
|
616
629
|
._ExternalInput-actions_91ls0_1 {
|
617
630
|
display: flex;
|
@@ -1237,57 +1250,55 @@ textarea._Input-input_g5w3n_26 {
|
|
1237
1250
|
}
|
1238
1251
|
|
1239
1252
|
/* css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css/#css-module-data */
|
1240
|
-
.
|
1253
|
+
._DropZone_3dmev_1 {
|
1241
1254
|
--resize-animation-ms: 150ms;
|
1242
1255
|
position: relative;
|
1243
1256
|
height: 100%;
|
1257
|
+
min-height: var(--min-empty-height);
|
1244
1258
|
outline-offset: -2px;
|
1245
1259
|
width: 100%;
|
1246
1260
|
}
|
1247
|
-
._DropZone--
|
1248
|
-
min-height: var(--min-empty-height);
|
1249
|
-
}
|
1250
|
-
._DropZone--hasChildren_kmkdc_14 {
|
1261
|
+
._DropZone--hasChildren_3dmev_11 {
|
1251
1262
|
min-height: 0;
|
1252
1263
|
}
|
1253
|
-
.
|
1264
|
+
._DropZone_3dmev_1:empty {
|
1254
1265
|
min-height: var(--min-empty-height);
|
1255
1266
|
}
|
1256
|
-
.
|
1267
|
+
._DropZone_3dmev_1:not(._DropZone--userIsDragging_3dmev_19) {
|
1257
1268
|
transition: min-height var(--resize-animation-ms) ease-in;
|
1258
1269
|
}
|
1259
|
-
._DropZone--
|
1260
|
-
._DropZone--
|
1270
|
+
._DropZone--isAreaSelected_3dmev_23,
|
1271
|
+
._DropZone--hoveringOverArea_3dmev_24:not(._DropZone--isRootZone_3dmev_24) {
|
1261
1272
|
background: color-mix(in srgb, var(--puck-color-azure-09) 30%, transparent);
|
1262
1273
|
outline: 2px dashed var(--puck-color-azure-08);
|
1263
1274
|
}
|
1264
|
-
.
|
1275
|
+
._DropZone_3dmev_1:empty {
|
1265
1276
|
background: color-mix(in srgb, var(--puck-color-azure-09) 30%, transparent);
|
1266
1277
|
outline: 2px dashed var(--puck-color-azure-08);
|
1267
1278
|
}
|
1268
|
-
._DropZone--
|
1279
|
+
._DropZone--isDestination_3dmev_34 {
|
1269
1280
|
outline: 2px dashed var(--puck-color-azure-04) !important;
|
1270
1281
|
}
|
1271
|
-
._DropZone--
|
1282
|
+
._DropZone--isDestination_3dmev_34:not(._DropZone--isRootZone_3dmev_24) {
|
1272
1283
|
background: color-mix(in srgb, var(--puck-color-azure-09) 30%, transparent) !important;
|
1273
1284
|
}
|
1274
|
-
._DropZone-
|
1285
|
+
._DropZone-item_3dmev_46 {
|
1275
1286
|
position: relative;
|
1276
1287
|
}
|
1277
|
-
._DropZone-
|
1288
|
+
._DropZone-hitbox_3dmev_50 {
|
1278
1289
|
position: absolute;
|
1279
1290
|
bottom: -12px;
|
1280
1291
|
height: 24px;
|
1281
1292
|
width: 100%;
|
1282
1293
|
z-index: 1;
|
1283
1294
|
}
|
1284
|
-
._DropZone--
|
1295
|
+
._DropZone--isEnabled_3dmev_58._DropZone--userIsDragging_3dmev_19 {
|
1285
1296
|
outline: 2px dashed var(--puck-color-azure-06);
|
1286
1297
|
}
|
1287
|
-
.
|
1298
|
+
._DropZone_3dmev_1 > *:not([data-puck-component]) {
|
1288
1299
|
opacity: 0;
|
1289
1300
|
}
|
1290
|
-
body:has(._DropZone--
|
1301
|
+
body:has(._DropZone--isAnimating_3dmev_67:empty) [data-puck-overlay] {
|
1291
1302
|
opacity: 0 !important;
|
1292
1303
|
}
|
1293
1304
|
|
package/dist/index.d.mts
CHANGED
@@ -1,8 +1,108 @@
|
|
1
|
-
import {
|
2
|
-
export { W as Adaptor, L as ArrayField, s as ArrayState,
|
1
|
+
import { H as History, C as Config, P as Permissions, U as UserGenerics, a as ComponentData, 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 FieldProps, h as Field, D as DropZoneProps, i as Data, j as OnAction, k as InitialHistory } from './resolve-all-data-Cs8PfTrg.mjs';
|
2
|
+
export { W as Adaptor, L as ArrayField, s as ArrayState, a6 as AsFieldProps, B as BaseData, E as BaseField, y as ComponentDataMap, z as Content, Z as CustomField, a3 as DefaultComponentProps, a0 as DefaultRootFieldProps, a2 as DefaultRootProps, a1 as DefaultRootRenderProps, l as Direction, m as DragAxis, Y as ExternalField, X as ExternalFieldWithAdaptor, a8 as ExtractPropsFromConfig, a9 as ExtractRootPropsFromConfig, q as FieldRenderFunctions, r as ItemWithId, x as MappedItem, N as NumberField, Q as ObjectField, p as OverrideKey, t as PuckComponent, $ as PuckContext, K as RadioField, u as RootConfig, w as RootData, v as RootDataWithoutProps, J as SelectField, S as Slot, _ as SlotField, T as TextField, G as TextareaField, n as Viewport, a7 as WithChildren, a4 as WithId, a5 as WithPuckProps, o as overrideKeys, ab as resolveAllData, aa as transformProps } from './resolve-all-data-Cs8PfTrg.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
|
+
};
|
26
|
+
type PuckNodeInstance = {
|
27
|
+
id: string;
|
28
|
+
methods: NodeMethods;
|
29
|
+
element: HTMLElement | null;
|
30
|
+
};
|
31
|
+
type NodesSlice = {
|
32
|
+
nodes: Record<string, PuckNodeInstance | undefined>;
|
33
|
+
registerNode: (id: string, node: Partial<PuckNodeInstance>) => void;
|
34
|
+
unregisterNode: (id: string, node?: Partial<PuckNodeInstance>) => void;
|
35
|
+
};
|
36
|
+
|
37
|
+
type PermissionsArgs<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
38
|
+
item?: G["UserComponentData"] | null;
|
39
|
+
type?: keyof G["UserProps"];
|
40
|
+
root?: boolean;
|
41
|
+
};
|
42
|
+
type GetPermissions<UserConfig extends Config = Config> = (params?: PermissionsArgs<UserConfig>) => Permissions;
|
43
|
+
type ResolvePermissions<UserConfig extends Config = Config> = (params?: PermissionsArgs<UserConfig>, force?: boolean) => void;
|
44
|
+
type RefreshPermissions<UserConfig extends Config = Config> = (params?: PermissionsArgs<UserConfig>, force?: boolean) => void;
|
45
|
+
type Cache = Record<string, {
|
46
|
+
lastPermissions: Partial<Permissions>;
|
47
|
+
lastData: ComponentData | null;
|
48
|
+
}>;
|
49
|
+
type PermissionsSlice = {
|
50
|
+
cache: Cache;
|
51
|
+
globalPermissions: Permissions;
|
52
|
+
resolvedPermissions: Record<string, Partial<Permissions> | undefined>;
|
53
|
+
getPermissions: GetPermissions<Config>;
|
54
|
+
resolvePermissions: ResolvePermissions<Config>;
|
55
|
+
refreshPermissions: RefreshPermissions<Config>;
|
56
|
+
};
|
57
|
+
|
58
|
+
type ComponentOrRootData = Omit<ComponentData<any>, "type">;
|
59
|
+
type FieldsSlice = {
|
60
|
+
fields: Fields | Partial<Fields>;
|
61
|
+
loading: boolean;
|
62
|
+
lastResolvedData: Partial<ComponentOrRootData>;
|
63
|
+
};
|
64
|
+
|
65
|
+
type Status = "LOADING" | "MOUNTED" | "READY";
|
66
|
+
type ZoomConfig = {
|
67
|
+
autoZoom: number;
|
68
|
+
rootHeight: number;
|
69
|
+
zoom: number;
|
70
|
+
};
|
71
|
+
type ComponentState = Record<string, {
|
72
|
+
loadingCount: number;
|
73
|
+
}>;
|
74
|
+
type AppStore<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
75
|
+
state: G["UserAppState"];
|
76
|
+
dispatch: (action: PuckAction) => void;
|
77
|
+
config: UserConfig;
|
78
|
+
componentState: ComponentState;
|
79
|
+
setComponentState: (componentState: ComponentState) => void;
|
80
|
+
setComponentLoading: (id: string, loading?: boolean, defer?: number) => void;
|
81
|
+
unsetComponentLoading: (id: string) => void;
|
82
|
+
pendingComponentLoads: Record<string, NodeJS.Timeout>;
|
83
|
+
resolveComponentData: <T extends ComponentData | RootDataWithProps>(componentData: T, trigger: ResolveDataTrigger) => Promise<{
|
84
|
+
node: T;
|
85
|
+
didChange: boolean;
|
86
|
+
}>;
|
87
|
+
resolveAndCommitData: () => void;
|
88
|
+
plugins: Plugin[];
|
89
|
+
overrides: Partial<Overrides>;
|
90
|
+
viewports: Viewports;
|
91
|
+
zoomConfig: ZoomConfig;
|
92
|
+
setZoomConfig: (zoomConfig: ZoomConfig) => void;
|
93
|
+
status: Status;
|
94
|
+
setStatus: (status: Status) => void;
|
95
|
+
iframe: IframeConfig;
|
96
|
+
selectedItem?: G["UserData"]["content"][0] | null;
|
97
|
+
setUi: (ui: Partial<UiState>, recordHistory?: boolean) => void;
|
98
|
+
getComponentConfig: (type?: string) => ComponentConfig | null | undefined;
|
99
|
+
onAction?: (action: PuckAction, newState: AppState, state: AppState) => void;
|
100
|
+
metadata: Metadata;
|
101
|
+
fields: FieldsSlice;
|
102
|
+
history: HistorySlice;
|
103
|
+
nodes: NodesSlice;
|
104
|
+
permissions: PermissionsSlice;
|
105
|
+
};
|
6
106
|
|
7
107
|
declare const ActionBar: {
|
8
108
|
({ label, children, }: {
|
@@ -42,7 +142,7 @@ declare const FieldLabel: ({ children, icon, label, el, readOnly, className, }:
|
|
42
142
|
className?: string;
|
43
143
|
}) => react_jsx_runtime.JSX.Element;
|
44
144
|
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;
|
145
|
+
declare function AutoField<ValueType = any, FieldType extends FieldNoLabel<ValueType> = FieldNoLabel<ValueType>>(props: FieldProps<FieldType, ValueType>): react_jsx_runtime.JSX.Element | null;
|
46
146
|
|
47
147
|
declare const Button: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, icon, size, loading: loadingProp, ...props }: {
|
48
148
|
children: ReactNode;
|
@@ -93,7 +193,7 @@ declare const IconButton: ({ children, href, onClick, variant, type, disabled, t
|
|
93
193
|
title: string;
|
94
194
|
}) => react_jsx_runtime.JSX.Element;
|
95
195
|
|
96
|
-
|
196
|
+
type PuckProps<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
97
197
|
children?: ReactNode;
|
98
198
|
config: UserConfig;
|
99
199
|
data: Partial<G["UserData"] | Data>;
|
@@ -122,7 +222,8 @@ declare function Puck<UserConfig extends Config = Config, G extends UserGenerics
|
|
122
222
|
};
|
123
223
|
initialHistory?: InitialHistory;
|
124
224
|
metadata?: Metadata;
|
125
|
-
}
|
225
|
+
};
|
226
|
+
declare function Puck<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(props: PuckProps<UserConfig>): react_jsx_runtime.JSX.Element;
|
126
227
|
declare namespace Puck {
|
127
228
|
var Components: () => react_jsx_runtime.JSX.Element;
|
128
229
|
var Fields: ({ wrapFields }: {
|
@@ -134,6 +235,11 @@ declare namespace Puck {
|
|
134
235
|
}) => react_jsx_runtime.JSX.Element;
|
135
236
|
}
|
136
237
|
|
238
|
+
declare const renderContext: react__default.Context<{
|
239
|
+
config: Config;
|
240
|
+
data: Data;
|
241
|
+
metadata: Metadata;
|
242
|
+
}>;
|
137
243
|
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
|
138
244
|
config: UserConfig;
|
139
245
|
data: Partial<G["UserData"] | Data>;
|
@@ -142,58 +248,38 @@ declare function Render<UserConfig extends Config = Config, G extends UserGeneri
|
|
142
248
|
|
143
249
|
declare function migrate(data: Data): Data;
|
144
250
|
|
145
|
-
type
|
146
|
-
|
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;
|
251
|
+
type WithGet<T> = T & {
|
252
|
+
get: () => T;
|
175
253
|
};
|
176
|
-
type
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
appState: AppState<Data<ExtractPropsFromConfig<UserConfig>, ExtractRootPropsFromConfig<UserConfig>>>;
|
181
|
-
config: UserConfig;
|
182
|
-
dispatch: (action: PuckAction) => void;
|
254
|
+
type UsePuckData<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
255
|
+
appState: AppState;
|
256
|
+
config: Config;
|
257
|
+
dispatch: AppStore["dispatch"];
|
183
258
|
getPermissions: GetPermissions<UserConfig>;
|
184
259
|
refreshPermissions: RefreshPermissions<UserConfig>;
|
260
|
+
selectedItem: G["UserComponentData"] | null;
|
185
261
|
history: {
|
186
|
-
back:
|
187
|
-
forward:
|
188
|
-
setHistories:
|
189
|
-
setHistoryIndex:
|
262
|
+
back: HistorySlice["back"];
|
263
|
+
forward: HistorySlice["forward"];
|
264
|
+
setHistories: HistorySlice["setHistories"];
|
265
|
+
setHistoryIndex: HistorySlice["setHistoryIndex"];
|
266
|
+
histories: HistorySlice["histories"];
|
267
|
+
index: HistorySlice["index"];
|
190
268
|
hasPast: boolean;
|
191
269
|
hasFuture: boolean;
|
192
|
-
histories: History<any>[];
|
193
|
-
index: number;
|
194
|
-
historyStore: HistoryStore | undefined;
|
195
270
|
};
|
196
|
-
selectedItem: ComponentDataMap<ExtractPropsFromConfig<UserConfig>> | null;
|
197
271
|
};
|
272
|
+
type UsePuckStore<UserConfig extends Config = Config> = WithGet<UsePuckData<UserConfig>>;
|
273
|
+
/**
|
274
|
+
* createUsePuck
|
275
|
+
*
|
276
|
+
* Create a typed usePuck hook, which is necessary because the user may provide a generic type but not
|
277
|
+
* a selector type, and TS does not currently support partial inference.
|
278
|
+
* Related: https://github.com/microsoft/TypeScript/issues/26242
|
279
|
+
*
|
280
|
+
* @returns a typed usePuck function
|
281
|
+
*/
|
282
|
+
declare function createUsePuck<UserConfig extends Config = Config>(): <T = UsePuckData<UserConfig, UserGenerics<UserConfig>>>(selector: (state: UsePuckStore<UserConfig>) => T) => T;
|
283
|
+
declare function usePuck<UserConfig extends Config = Config>(): UsePuckStore<UserConfig>;
|
198
284
|
|
199
|
-
export { Action, ActionBar, AppState, AutoField, Button,
|
285
|
+
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, Render, ResolveDataTrigger, RootDataWithProps, UiState, type UsePuckData, UserGenerics, Viewports, createUsePuck, migrate, renderContext, usePuck };
|
package/dist/index.d.ts
CHANGED
@@ -1,8 +1,108 @@
|
|
1
|
-
import {
|
2
|
-
export { W as Adaptor, L as ArrayField, s as ArrayState,
|
1
|
+
import { H as History, C as Config, P as Permissions, U as UserGenerics, a as ComponentData, 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 FieldProps, h as Field, D as DropZoneProps, i as Data, j as OnAction, k as InitialHistory } from './resolve-all-data-Cs8PfTrg.js';
|
2
|
+
export { W as Adaptor, L as ArrayField, s as ArrayState, a6 as AsFieldProps, B as BaseData, E as BaseField, y as ComponentDataMap, z as Content, Z as CustomField, a3 as DefaultComponentProps, a0 as DefaultRootFieldProps, a2 as DefaultRootProps, a1 as DefaultRootRenderProps, l as Direction, m as DragAxis, Y as ExternalField, X as ExternalFieldWithAdaptor, a8 as ExtractPropsFromConfig, a9 as ExtractRootPropsFromConfig, q as FieldRenderFunctions, r as ItemWithId, x as MappedItem, N as NumberField, Q as ObjectField, p as OverrideKey, t as PuckComponent, $ as PuckContext, K as RadioField, u as RootConfig, w as RootData, v as RootDataWithoutProps, J as SelectField, S as Slot, _ as SlotField, T as TextField, G as TextareaField, n as Viewport, a7 as WithChildren, a4 as WithId, a5 as WithPuckProps, o as overrideKeys, ab as resolveAllData, aa as transformProps } from './resolve-all-data-Cs8PfTrg.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
|
+
};
|
26
|
+
type PuckNodeInstance = {
|
27
|
+
id: string;
|
28
|
+
methods: NodeMethods;
|
29
|
+
element: HTMLElement | null;
|
30
|
+
};
|
31
|
+
type NodesSlice = {
|
32
|
+
nodes: Record<string, PuckNodeInstance | undefined>;
|
33
|
+
registerNode: (id: string, node: Partial<PuckNodeInstance>) => void;
|
34
|
+
unregisterNode: (id: string, node?: Partial<PuckNodeInstance>) => void;
|
35
|
+
};
|
36
|
+
|
37
|
+
type PermissionsArgs<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
38
|
+
item?: G["UserComponentData"] | null;
|
39
|
+
type?: keyof G["UserProps"];
|
40
|
+
root?: boolean;
|
41
|
+
};
|
42
|
+
type GetPermissions<UserConfig extends Config = Config> = (params?: PermissionsArgs<UserConfig>) => Permissions;
|
43
|
+
type ResolvePermissions<UserConfig extends Config = Config> = (params?: PermissionsArgs<UserConfig>, force?: boolean) => void;
|
44
|
+
type RefreshPermissions<UserConfig extends Config = Config> = (params?: PermissionsArgs<UserConfig>, force?: boolean) => void;
|
45
|
+
type Cache = Record<string, {
|
46
|
+
lastPermissions: Partial<Permissions>;
|
47
|
+
lastData: ComponentData | null;
|
48
|
+
}>;
|
49
|
+
type PermissionsSlice = {
|
50
|
+
cache: Cache;
|
51
|
+
globalPermissions: Permissions;
|
52
|
+
resolvedPermissions: Record<string, Partial<Permissions> | undefined>;
|
53
|
+
getPermissions: GetPermissions<Config>;
|
54
|
+
resolvePermissions: ResolvePermissions<Config>;
|
55
|
+
refreshPermissions: RefreshPermissions<Config>;
|
56
|
+
};
|
57
|
+
|
58
|
+
type ComponentOrRootData = Omit<ComponentData<any>, "type">;
|
59
|
+
type FieldsSlice = {
|
60
|
+
fields: Fields | Partial<Fields>;
|
61
|
+
loading: boolean;
|
62
|
+
lastResolvedData: Partial<ComponentOrRootData>;
|
63
|
+
};
|
64
|
+
|
65
|
+
type Status = "LOADING" | "MOUNTED" | "READY";
|
66
|
+
type ZoomConfig = {
|
67
|
+
autoZoom: number;
|
68
|
+
rootHeight: number;
|
69
|
+
zoom: number;
|
70
|
+
};
|
71
|
+
type ComponentState = Record<string, {
|
72
|
+
loadingCount: number;
|
73
|
+
}>;
|
74
|
+
type AppStore<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
75
|
+
state: G["UserAppState"];
|
76
|
+
dispatch: (action: PuckAction) => void;
|
77
|
+
config: UserConfig;
|
78
|
+
componentState: ComponentState;
|
79
|
+
setComponentState: (componentState: ComponentState) => void;
|
80
|
+
setComponentLoading: (id: string, loading?: boolean, defer?: number) => void;
|
81
|
+
unsetComponentLoading: (id: string) => void;
|
82
|
+
pendingComponentLoads: Record<string, NodeJS.Timeout>;
|
83
|
+
resolveComponentData: <T extends ComponentData | RootDataWithProps>(componentData: T, trigger: ResolveDataTrigger) => Promise<{
|
84
|
+
node: T;
|
85
|
+
didChange: boolean;
|
86
|
+
}>;
|
87
|
+
resolveAndCommitData: () => void;
|
88
|
+
plugins: Plugin[];
|
89
|
+
overrides: Partial<Overrides>;
|
90
|
+
viewports: Viewports;
|
91
|
+
zoomConfig: ZoomConfig;
|
92
|
+
setZoomConfig: (zoomConfig: ZoomConfig) => void;
|
93
|
+
status: Status;
|
94
|
+
setStatus: (status: Status) => void;
|
95
|
+
iframe: IframeConfig;
|
96
|
+
selectedItem?: G["UserData"]["content"][0] | null;
|
97
|
+
setUi: (ui: Partial<UiState>, recordHistory?: boolean) => void;
|
98
|
+
getComponentConfig: (type?: string) => ComponentConfig | null | undefined;
|
99
|
+
onAction?: (action: PuckAction, newState: AppState, state: AppState) => void;
|
100
|
+
metadata: Metadata;
|
101
|
+
fields: FieldsSlice;
|
102
|
+
history: HistorySlice;
|
103
|
+
nodes: NodesSlice;
|
104
|
+
permissions: PermissionsSlice;
|
105
|
+
};
|
6
106
|
|
7
107
|
declare const ActionBar: {
|
8
108
|
({ label, children, }: {
|
@@ -42,7 +142,7 @@ declare const FieldLabel: ({ children, icon, label, el, readOnly, className, }:
|
|
42
142
|
className?: string;
|
43
143
|
}) => react_jsx_runtime.JSX.Element;
|
44
144
|
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;
|
145
|
+
declare function AutoField<ValueType = any, FieldType extends FieldNoLabel<ValueType> = FieldNoLabel<ValueType>>(props: FieldProps<FieldType, ValueType>): react_jsx_runtime.JSX.Element | null;
|
46
146
|
|
47
147
|
declare const Button: ({ children, href, onClick, variant, type, disabled, tabIndex, newTab, fullWidth, icon, size, loading: loadingProp, ...props }: {
|
48
148
|
children: ReactNode;
|
@@ -93,7 +193,7 @@ declare const IconButton: ({ children, href, onClick, variant, type, disabled, t
|
|
93
193
|
title: string;
|
94
194
|
}) => react_jsx_runtime.JSX.Element;
|
95
195
|
|
96
|
-
|
196
|
+
type PuckProps<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
97
197
|
children?: ReactNode;
|
98
198
|
config: UserConfig;
|
99
199
|
data: Partial<G["UserData"] | Data>;
|
@@ -122,7 +222,8 @@ declare function Puck<UserConfig extends Config = Config, G extends UserGenerics
|
|
122
222
|
};
|
123
223
|
initialHistory?: InitialHistory;
|
124
224
|
metadata?: Metadata;
|
125
|
-
}
|
225
|
+
};
|
226
|
+
declare function Puck<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(props: PuckProps<UserConfig>): react_jsx_runtime.JSX.Element;
|
126
227
|
declare namespace Puck {
|
127
228
|
var Components: () => react_jsx_runtime.JSX.Element;
|
128
229
|
var Fields: ({ wrapFields }: {
|
@@ -134,6 +235,11 @@ declare namespace Puck {
|
|
134
235
|
}) => react_jsx_runtime.JSX.Element;
|
135
236
|
}
|
136
237
|
|
238
|
+
declare const renderContext: react__default.Context<{
|
239
|
+
config: Config;
|
240
|
+
data: Data;
|
241
|
+
metadata: Metadata;
|
242
|
+
}>;
|
137
243
|
declare function Render<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>({ config, data, metadata, }: {
|
138
244
|
config: UserConfig;
|
139
245
|
data: Partial<G["UserData"] | Data>;
|
@@ -142,58 +248,38 @@ declare function Render<UserConfig extends Config = Config, G extends UserGeneri
|
|
142
248
|
|
143
249
|
declare function migrate(data: Data): Data;
|
144
250
|
|
145
|
-
type
|
146
|
-
|
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;
|
251
|
+
type WithGet<T> = T & {
|
252
|
+
get: () => T;
|
175
253
|
};
|
176
|
-
type
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
appState: AppState<Data<ExtractPropsFromConfig<UserConfig>, ExtractRootPropsFromConfig<UserConfig>>>;
|
181
|
-
config: UserConfig;
|
182
|
-
dispatch: (action: PuckAction) => void;
|
254
|
+
type UsePuckData<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
255
|
+
appState: AppState;
|
256
|
+
config: Config;
|
257
|
+
dispatch: AppStore["dispatch"];
|
183
258
|
getPermissions: GetPermissions<UserConfig>;
|
184
259
|
refreshPermissions: RefreshPermissions<UserConfig>;
|
260
|
+
selectedItem: G["UserComponentData"] | null;
|
185
261
|
history: {
|
186
|
-
back:
|
187
|
-
forward:
|
188
|
-
setHistories:
|
189
|
-
setHistoryIndex:
|
262
|
+
back: HistorySlice["back"];
|
263
|
+
forward: HistorySlice["forward"];
|
264
|
+
setHistories: HistorySlice["setHistories"];
|
265
|
+
setHistoryIndex: HistorySlice["setHistoryIndex"];
|
266
|
+
histories: HistorySlice["histories"];
|
267
|
+
index: HistorySlice["index"];
|
190
268
|
hasPast: boolean;
|
191
269
|
hasFuture: boolean;
|
192
|
-
histories: History<any>[];
|
193
|
-
index: number;
|
194
|
-
historyStore: HistoryStore | undefined;
|
195
270
|
};
|
196
|
-
selectedItem: ComponentDataMap<ExtractPropsFromConfig<UserConfig>> | null;
|
197
271
|
};
|
272
|
+
type UsePuckStore<UserConfig extends Config = Config> = WithGet<UsePuckData<UserConfig>>;
|
273
|
+
/**
|
274
|
+
* createUsePuck
|
275
|
+
*
|
276
|
+
* Create a typed usePuck hook, which is necessary because the user may provide a generic type but not
|
277
|
+
* a selector type, and TS does not currently support partial inference.
|
278
|
+
* Related: https://github.com/microsoft/TypeScript/issues/26242
|
279
|
+
*
|
280
|
+
* @returns a typed usePuck function
|
281
|
+
*/
|
282
|
+
declare function createUsePuck<UserConfig extends Config = Config>(): <T = UsePuckData<UserConfig, UserGenerics<UserConfig>>>(selector: (state: UsePuckStore<UserConfig>) => T) => T;
|
283
|
+
declare function usePuck<UserConfig extends Config = Config>(): UsePuckStore<UserConfig>;
|
198
284
|
|
199
|
-
export { Action, ActionBar, AppState, AutoField, Button,
|
285
|
+
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, Render, ResolveDataTrigger, RootDataWithProps, UiState, type UsePuckData, UserGenerics, Viewports, createUsePuck, migrate, renderContext, usePuck };
|