@measured/puck 0.16.0-canary.53c8bfc → 0.16.0-canary.555902
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{Config-CkVFT1_w.d.mts → Config-RpUGTBxI.d.mts} +49 -42
- package/dist/{Config-CkVFT1_w.d.ts → Config-RpUGTBxI.d.ts} +49 -42
- package/dist/{chunk-TM7CT64S.mjs → chunk-7CYJT5DS.mjs} +6 -2
- package/dist/index.d.mts +19 -25
- package/dist/index.d.ts +19 -25
- package/dist/index.js +113 -98
- package/dist/index.mjs +108 -97
- package/dist/rsc.d.mts +1 -1
- package/dist/rsc.d.ts +1 -1
- package/dist/rsc.js +6 -2
- package/dist/rsc.mjs +1 -1
- package/package.json +13 -4
@@ -128,7 +128,7 @@ type Field<Props extends any = any> = TextField | NumberField | TextareaField |
|
|
128
128
|
[key: string]: any;
|
129
129
|
} ? Props : any> | CustomField<Props>;
|
130
130
|
type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps> = {
|
131
|
-
[PropName in keyof Omit<
|
131
|
+
[PropName in keyof Omit<ComponentProps, "editMode">]: Field<ComponentProps[PropName]>;
|
132
132
|
};
|
133
133
|
type FieldProps<ValueType = any, F = Field<any>> = {
|
134
134
|
field: F;
|
@@ -138,54 +138,60 @@ type FieldProps<ValueType = any, F = Field<any>> = {
|
|
138
138
|
readOnly?: boolean;
|
139
139
|
};
|
140
140
|
|
141
|
-
type
|
141
|
+
type WithId<Props> = Props & {
|
142
142
|
id: string;
|
143
143
|
};
|
144
|
-
type
|
144
|
+
type WithPuckProps<Props> = Props & {
|
145
|
+
puck: PuckContext;
|
146
|
+
editMode?: boolean;
|
147
|
+
};
|
148
|
+
type AsFieldProps<Props> = Omit<Props, "children" | "puck" | "editMode">;
|
149
|
+
type WithChildren<Props> = Props & {
|
150
|
+
children: ReactNode;
|
151
|
+
};
|
152
|
+
type DefaultRootFieldProps = {
|
145
153
|
title?: string;
|
146
|
-
[key: string]: any;
|
147
154
|
};
|
155
|
+
type DefaultRootRenderProps<Props extends DefaultComponentProps = DefaultRootFieldProps> = WithPuckProps<WithChildren<Props>>;
|
156
|
+
type DefaultRootProps = DefaultRootRenderProps;
|
148
157
|
type DefaultComponentProps = {
|
149
158
|
[key: string]: any;
|
150
|
-
editMode?: boolean;
|
151
159
|
};
|
152
|
-
type Content<
|
160
|
+
type Content<PropsMap extends {
|
153
161
|
[key: string]: any;
|
154
162
|
} = {
|
155
163
|
[key: string]: any;
|
156
|
-
}> =
|
157
|
-
type PuckComponent<Props> = (props: WithPuckProps<Props
|
158
|
-
puck: PuckContext;
|
159
|
-
}>) => JSX.Element;
|
164
|
+
}> = ComponentDataMap<PropsMap>[];
|
165
|
+
type PuckComponent<Props> = (props: WithId<WithPuckProps<Props>>) => JSX.Element;
|
160
166
|
type PuckContext = {
|
161
167
|
renderDropZone: React.FC<DropZoneProps>;
|
162
168
|
isEditing: boolean;
|
163
169
|
};
|
164
|
-
type ComponentConfig<
|
165
|
-
render: PuckComponent<
|
170
|
+
type ComponentConfig<RenderProps extends DefaultComponentProps = DefaultComponentProps, FieldProps extends DefaultComponentProps = RenderProps, DataShape = Omit<ComponentData<FieldProps>, "type">> = {
|
171
|
+
render: PuckComponent<RenderProps>;
|
166
172
|
label?: string;
|
167
|
-
defaultProps?:
|
168
|
-
fields?: Fields<
|
173
|
+
defaultProps?: FieldProps;
|
174
|
+
fields?: Fields<FieldProps>;
|
169
175
|
permissions?: Partial<Permissions>;
|
170
176
|
resolveFields?: (data: DataShape, params: {
|
171
|
-
changed: Partial<Record<keyof
|
172
|
-
fields: Fields<
|
173
|
-
lastFields: Fields<
|
177
|
+
changed: Partial<Record<keyof FieldProps, boolean>>;
|
178
|
+
fields: Fields<FieldProps>;
|
179
|
+
lastFields: Fields<FieldProps>;
|
174
180
|
lastData: DataShape;
|
175
181
|
appState: AppState;
|
176
|
-
}) => Promise<Fields<
|
182
|
+
}) => Promise<Fields<FieldProps>> | Fields<FieldProps>;
|
177
183
|
resolveData?: (data: DataShape, params: {
|
178
|
-
changed: Partial<Record<keyof
|
184
|
+
changed: Partial<Record<keyof FieldProps, boolean>>;
|
179
185
|
lastData: DataShape;
|
180
186
|
}) => Promise<{
|
181
|
-
props?: Partial<
|
182
|
-
readOnly?: Partial<Record<keyof
|
187
|
+
props?: Partial<FieldProps>;
|
188
|
+
readOnly?: Partial<Record<keyof FieldProps, boolean>>;
|
183
189
|
}> | {
|
184
|
-
props?: Partial<
|
185
|
-
readOnly?: Partial<Record<keyof
|
190
|
+
props?: Partial<FieldProps>;
|
191
|
+
readOnly?: Partial<Record<keyof FieldProps, boolean>>;
|
186
192
|
};
|
187
193
|
resolvePermissions?: (data: DataShape, params: {
|
188
|
-
changed: Partial<Record<keyof
|
194
|
+
changed: Partial<Record<keyof FieldProps, boolean>>;
|
189
195
|
lastPermissions: Partial<Permissions> | undefined;
|
190
196
|
initialPermissions: Partial<Permissions>;
|
191
197
|
appState: AppState;
|
@@ -197,19 +203,17 @@ type Category<ComponentName> = {
|
|
197
203
|
visible?: boolean;
|
198
204
|
defaultExpanded?: boolean;
|
199
205
|
};
|
200
|
-
type Config<Props extends
|
206
|
+
type Config<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = any, CategoryName extends string = string> = {
|
201
207
|
categories?: Record<CategoryName, Category<keyof Props>> & {
|
202
208
|
other?: Category<keyof Props>;
|
203
209
|
};
|
204
210
|
components: {
|
205
211
|
[ComponentName in keyof Props]: Omit<ComponentConfig<Props[ComponentName], Props[ComponentName]>, "type">;
|
206
212
|
};
|
207
|
-
root?: Partial<ComponentConfig<RootProps
|
208
|
-
children?: ReactNode;
|
209
|
-
}, Partial<RootProps & {
|
210
|
-
children?: ReactNode;
|
211
|
-
}>, RootData>>;
|
213
|
+
root?: Partial<ComponentConfig<DefaultRootRenderProps<RootProps>, AsFieldProps<RootProps>, RootData>>;
|
212
214
|
};
|
215
|
+
type ExtractPropsFromConfig<UserConfig> = UserConfig extends Config<infer P, any, any> ? P : never;
|
216
|
+
type ExtractRootPropsFromConfig<UserConfig> = UserConfig extends Config<any, infer P, any> ? P : never;
|
213
217
|
type BaseData<Props extends {
|
214
218
|
[key: string]: any;
|
215
219
|
} = {
|
@@ -217,20 +221,23 @@ type BaseData<Props extends {
|
|
217
221
|
}> = {
|
218
222
|
readOnly?: Partial<Record<keyof Props, boolean>>;
|
219
223
|
};
|
220
|
-
type ComponentData<Props extends DefaultComponentProps = DefaultComponentProps> = {
|
221
|
-
type:
|
222
|
-
props:
|
224
|
+
type ComponentData<Props extends DefaultComponentProps = DefaultComponentProps, Name = string> = {
|
225
|
+
type: Name;
|
226
|
+
props: WithId<Props>;
|
223
227
|
} & BaseData<Props>;
|
224
|
-
type
|
228
|
+
type ComponentDataMap<Props extends Record<string, DefaultComponentProps> = DefaultComponentProps> = {
|
229
|
+
[K in keyof Props]: ComponentData<Props[K], K extends string ? K : never>;
|
230
|
+
}[keyof Props];
|
231
|
+
type RootDataWithProps<Props extends DefaultComponentProps = DefaultRootFieldProps> = BaseData<Props> & {
|
225
232
|
props: Props;
|
226
233
|
};
|
227
|
-
type RootDataWithoutProps<Props extends
|
228
|
-
type RootData<Props extends
|
234
|
+
type RootDataWithoutProps<Props extends DefaultComponentProps = DefaultRootFieldProps> = Props;
|
235
|
+
type RootData<Props extends DefaultComponentProps = DefaultRootFieldProps> = Partial<RootDataWithProps<AsFieldProps<Props>>> & Partial<RootDataWithoutProps<Props>>;
|
229
236
|
type MappedItem = ComponentData;
|
230
|
-
type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends
|
237
|
+
type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = {
|
231
238
|
root: RootData<RootProps>;
|
232
|
-
content: Content<
|
233
|
-
zones?: Record<string, Content<
|
239
|
+
content: Content<Props>;
|
240
|
+
zones?: Record<string, Content<Props>>;
|
234
241
|
};
|
235
242
|
type ItemWithId = {
|
236
243
|
_arrayId: string;
|
@@ -261,8 +268,8 @@ type UiState = {
|
|
261
268
|
options: Viewport[];
|
262
269
|
};
|
263
270
|
};
|
264
|
-
type AppState = {
|
265
|
-
data:
|
271
|
+
type AppState<UserData extends Data = Data> = {
|
272
|
+
data: UserData;
|
266
273
|
ui: UiState;
|
267
274
|
};
|
268
275
|
type Permissions = {
|
@@ -273,4 +280,4 @@ type Permissions = {
|
|
273
280
|
insert: boolean;
|
274
281
|
} & Record<string, boolean>;
|
275
282
|
|
276
|
-
export type { AppState as A, BaseData as B, Config as C, Data as D,
|
283
|
+
export type { AppState as A, BaseData as B, Config as C, Data as D, ExtractPropsFromConfig as E, Field as F, ItemSelector as I, MappedItem as M, NumberField as N, ObjectField as O, Permissions as P, RootDataWithProps as R, SelectField as S, TextField as T, UiState as U, Viewports as V, FieldProps as a, DropZoneProps as b, ExtractRootPropsFromConfig as c, DefaultComponentProps as d, DefaultRootFieldProps as e, ComponentData as f, DefaultRootRenderProps as g, DefaultRootProps as h, Content as i, PuckComponent as j, PuckContext as k, ComponentConfig as l, ComponentDataMap as m, RootDataWithoutProps as n, RootData as o, ItemWithId as p, ArrayState as q, BaseField as r, TextareaField as s, RadioField as t, ArrayField as u, Adaptor as v, ExternalFieldWithAdaptor as w, ExternalField as x, CustomField as y, Fields as z };
|
@@ -128,7 +128,7 @@ type Field<Props extends any = any> = TextField | NumberField | TextareaField |
|
|
128
128
|
[key: string]: any;
|
129
129
|
} ? Props : any> | CustomField<Props>;
|
130
130
|
type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps> = {
|
131
|
-
[PropName in keyof Omit<
|
131
|
+
[PropName in keyof Omit<ComponentProps, "editMode">]: Field<ComponentProps[PropName]>;
|
132
132
|
};
|
133
133
|
type FieldProps<ValueType = any, F = Field<any>> = {
|
134
134
|
field: F;
|
@@ -138,54 +138,60 @@ type FieldProps<ValueType = any, F = Field<any>> = {
|
|
138
138
|
readOnly?: boolean;
|
139
139
|
};
|
140
140
|
|
141
|
-
type
|
141
|
+
type WithId<Props> = Props & {
|
142
142
|
id: string;
|
143
143
|
};
|
144
|
-
type
|
144
|
+
type WithPuckProps<Props> = Props & {
|
145
|
+
puck: PuckContext;
|
146
|
+
editMode?: boolean;
|
147
|
+
};
|
148
|
+
type AsFieldProps<Props> = Omit<Props, "children" | "puck" | "editMode">;
|
149
|
+
type WithChildren<Props> = Props & {
|
150
|
+
children: ReactNode;
|
151
|
+
};
|
152
|
+
type DefaultRootFieldProps = {
|
145
153
|
title?: string;
|
146
|
-
[key: string]: any;
|
147
154
|
};
|
155
|
+
type DefaultRootRenderProps<Props extends DefaultComponentProps = DefaultRootFieldProps> = WithPuckProps<WithChildren<Props>>;
|
156
|
+
type DefaultRootProps = DefaultRootRenderProps;
|
148
157
|
type DefaultComponentProps = {
|
149
158
|
[key: string]: any;
|
150
|
-
editMode?: boolean;
|
151
159
|
};
|
152
|
-
type Content<
|
160
|
+
type Content<PropsMap extends {
|
153
161
|
[key: string]: any;
|
154
162
|
} = {
|
155
163
|
[key: string]: any;
|
156
|
-
}> =
|
157
|
-
type PuckComponent<Props> = (props: WithPuckProps<Props
|
158
|
-
puck: PuckContext;
|
159
|
-
}>) => JSX.Element;
|
164
|
+
}> = ComponentDataMap<PropsMap>[];
|
165
|
+
type PuckComponent<Props> = (props: WithId<WithPuckProps<Props>>) => JSX.Element;
|
160
166
|
type PuckContext = {
|
161
167
|
renderDropZone: React.FC<DropZoneProps>;
|
162
168
|
isEditing: boolean;
|
163
169
|
};
|
164
|
-
type ComponentConfig<
|
165
|
-
render: PuckComponent<
|
170
|
+
type ComponentConfig<RenderProps extends DefaultComponentProps = DefaultComponentProps, FieldProps extends DefaultComponentProps = RenderProps, DataShape = Omit<ComponentData<FieldProps>, "type">> = {
|
171
|
+
render: PuckComponent<RenderProps>;
|
166
172
|
label?: string;
|
167
|
-
defaultProps?:
|
168
|
-
fields?: Fields<
|
173
|
+
defaultProps?: FieldProps;
|
174
|
+
fields?: Fields<FieldProps>;
|
169
175
|
permissions?: Partial<Permissions>;
|
170
176
|
resolveFields?: (data: DataShape, params: {
|
171
|
-
changed: Partial<Record<keyof
|
172
|
-
fields: Fields<
|
173
|
-
lastFields: Fields<
|
177
|
+
changed: Partial<Record<keyof FieldProps, boolean>>;
|
178
|
+
fields: Fields<FieldProps>;
|
179
|
+
lastFields: Fields<FieldProps>;
|
174
180
|
lastData: DataShape;
|
175
181
|
appState: AppState;
|
176
|
-
}) => Promise<Fields<
|
182
|
+
}) => Promise<Fields<FieldProps>> | Fields<FieldProps>;
|
177
183
|
resolveData?: (data: DataShape, params: {
|
178
|
-
changed: Partial<Record<keyof
|
184
|
+
changed: Partial<Record<keyof FieldProps, boolean>>;
|
179
185
|
lastData: DataShape;
|
180
186
|
}) => Promise<{
|
181
|
-
props?: Partial<
|
182
|
-
readOnly?: Partial<Record<keyof
|
187
|
+
props?: Partial<FieldProps>;
|
188
|
+
readOnly?: Partial<Record<keyof FieldProps, boolean>>;
|
183
189
|
}> | {
|
184
|
-
props?: Partial<
|
185
|
-
readOnly?: Partial<Record<keyof
|
190
|
+
props?: Partial<FieldProps>;
|
191
|
+
readOnly?: Partial<Record<keyof FieldProps, boolean>>;
|
186
192
|
};
|
187
193
|
resolvePermissions?: (data: DataShape, params: {
|
188
|
-
changed: Partial<Record<keyof
|
194
|
+
changed: Partial<Record<keyof FieldProps, boolean>>;
|
189
195
|
lastPermissions: Partial<Permissions> | undefined;
|
190
196
|
initialPermissions: Partial<Permissions>;
|
191
197
|
appState: AppState;
|
@@ -197,19 +203,17 @@ type Category<ComponentName> = {
|
|
197
203
|
visible?: boolean;
|
198
204
|
defaultExpanded?: boolean;
|
199
205
|
};
|
200
|
-
type Config<Props extends
|
206
|
+
type Config<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = any, CategoryName extends string = string> = {
|
201
207
|
categories?: Record<CategoryName, Category<keyof Props>> & {
|
202
208
|
other?: Category<keyof Props>;
|
203
209
|
};
|
204
210
|
components: {
|
205
211
|
[ComponentName in keyof Props]: Omit<ComponentConfig<Props[ComponentName], Props[ComponentName]>, "type">;
|
206
212
|
};
|
207
|
-
root?: Partial<ComponentConfig<RootProps
|
208
|
-
children?: ReactNode;
|
209
|
-
}, Partial<RootProps & {
|
210
|
-
children?: ReactNode;
|
211
|
-
}>, RootData>>;
|
213
|
+
root?: Partial<ComponentConfig<DefaultRootRenderProps<RootProps>, AsFieldProps<RootProps>, RootData>>;
|
212
214
|
};
|
215
|
+
type ExtractPropsFromConfig<UserConfig> = UserConfig extends Config<infer P, any, any> ? P : never;
|
216
|
+
type ExtractRootPropsFromConfig<UserConfig> = UserConfig extends Config<any, infer P, any> ? P : never;
|
213
217
|
type BaseData<Props extends {
|
214
218
|
[key: string]: any;
|
215
219
|
} = {
|
@@ -217,20 +221,23 @@ type BaseData<Props extends {
|
|
217
221
|
}> = {
|
218
222
|
readOnly?: Partial<Record<keyof Props, boolean>>;
|
219
223
|
};
|
220
|
-
type ComponentData<Props extends DefaultComponentProps = DefaultComponentProps> = {
|
221
|
-
type:
|
222
|
-
props:
|
224
|
+
type ComponentData<Props extends DefaultComponentProps = DefaultComponentProps, Name = string> = {
|
225
|
+
type: Name;
|
226
|
+
props: WithId<Props>;
|
223
227
|
} & BaseData<Props>;
|
224
|
-
type
|
228
|
+
type ComponentDataMap<Props extends Record<string, DefaultComponentProps> = DefaultComponentProps> = {
|
229
|
+
[K in keyof Props]: ComponentData<Props[K], K extends string ? K : never>;
|
230
|
+
}[keyof Props];
|
231
|
+
type RootDataWithProps<Props extends DefaultComponentProps = DefaultRootFieldProps> = BaseData<Props> & {
|
225
232
|
props: Props;
|
226
233
|
};
|
227
|
-
type RootDataWithoutProps<Props extends
|
228
|
-
type RootData<Props extends
|
234
|
+
type RootDataWithoutProps<Props extends DefaultComponentProps = DefaultRootFieldProps> = Props;
|
235
|
+
type RootData<Props extends DefaultComponentProps = DefaultRootFieldProps> = Partial<RootDataWithProps<AsFieldProps<Props>>> & Partial<RootDataWithoutProps<Props>>;
|
229
236
|
type MappedItem = ComponentData;
|
230
|
-
type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends
|
237
|
+
type Data<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = {
|
231
238
|
root: RootData<RootProps>;
|
232
|
-
content: Content<
|
233
|
-
zones?: Record<string, Content<
|
239
|
+
content: Content<Props>;
|
240
|
+
zones?: Record<string, Content<Props>>;
|
234
241
|
};
|
235
242
|
type ItemWithId = {
|
236
243
|
_arrayId: string;
|
@@ -261,8 +268,8 @@ type UiState = {
|
|
261
268
|
options: Viewport[];
|
262
269
|
};
|
263
270
|
};
|
264
|
-
type AppState = {
|
265
|
-
data:
|
271
|
+
type AppState<UserData extends Data = Data> = {
|
272
|
+
data: UserData;
|
266
273
|
ui: UiState;
|
267
274
|
};
|
268
275
|
type Permissions = {
|
@@ -273,4 +280,4 @@ type Permissions = {
|
|
273
280
|
insert: boolean;
|
274
281
|
} & Record<string, boolean>;
|
275
282
|
|
276
|
-
export type { AppState as A, BaseData as B, Config as C, Data as D,
|
283
|
+
export type { AppState as A, BaseData as B, Config as C, Data as D, ExtractPropsFromConfig as E, Field as F, ItemSelector as I, MappedItem as M, NumberField as N, ObjectField as O, Permissions as P, RootDataWithProps as R, SelectField as S, TextField as T, UiState as U, Viewports as V, FieldProps as a, DropZoneProps as b, ExtractRootPropsFromConfig as c, DefaultComponentProps as d, DefaultRootFieldProps as e, ComponentData as f, DefaultRootRenderProps as g, DefaultRootProps as h, Content as i, PuckComponent as j, PuckContext as k, ComponentConfig as l, ComponentDataMap as m, RootDataWithoutProps as n, RootData as o, ItemWithId as p, ArrayState as q, BaseField as r, TextareaField as s, RadioField as t, ArrayField as u, Adaptor as v, ExternalFieldWithAdaptor as w, ExternalField as x, CustomField as y, Fields as z };
|
@@ -90,12 +90,16 @@ var rootDroppableId = "default-zone";
|
|
90
90
|
|
91
91
|
// lib/setup-zone.ts
|
92
92
|
init_react_import();
|
93
|
+
function ensureZones(data) {
|
94
|
+
return __spreadProps(__spreadValues({}, data), {
|
95
|
+
zones: data.zones || {}
|
96
|
+
});
|
97
|
+
}
|
93
98
|
var setupZone = (data, zoneKey) => {
|
94
99
|
if (zoneKey === rootDroppableId) {
|
95
100
|
return data;
|
96
101
|
}
|
97
|
-
const newData =
|
98
|
-
newData.zones = data.zones || {};
|
102
|
+
const newData = ensureZones(data);
|
99
103
|
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
100
104
|
return newData;
|
101
105
|
};
|
package/dist/index.d.mts
CHANGED
@@ -1,5 +1,5 @@
|
|
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,
|
2
|
-
export {
|
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, E as ExtractPropsFromConfig, c as ExtractRootPropsFromConfig, P as Permissions, V as Viewports, d as DefaultComponentProps, e as DefaultRootFieldProps, f as ComponentData } from './Config-RpUGTBxI.mjs';
|
2
|
+
export { v as Adaptor, u as ArrayField, q as ArrayState, B as BaseData, r as BaseField, l as ComponentConfig, m as ComponentDataMap, i as Content, y as CustomField, h as DefaultRootProps, g as DefaultRootRenderProps, x as ExternalField, w as ExternalFieldWithAdaptor, z as Fields, p as ItemWithId, M as MappedItem, N as NumberField, O as ObjectField, j as PuckComponent, k as PuckContext, t as RadioField, o as RootData, R as RootDataWithProps, n as RootDataWithoutProps, S as SelectField, T as TextField, s as TextareaField } from './Config-RpUGTBxI.mjs';
|
3
3
|
import * as react from 'react';
|
4
4
|
import { ReactNode, ReactElement, SyntheticEvent, CSSProperties } from 'react';
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
@@ -49,9 +49,9 @@ type SetDataAction = {
|
|
49
49
|
type: "setData";
|
50
50
|
data: Partial<Data> | ((previous: Data) => Partial<Data>);
|
51
51
|
};
|
52
|
-
type SetAction = {
|
52
|
+
type SetAction<UserData extends Data = Data> = {
|
53
53
|
type: "set";
|
54
|
-
state: Partial<AppState
|
54
|
+
state: Partial<AppState<UserData>> | ((previous: AppState<UserData>) => Partial<AppState<UserData>>);
|
55
55
|
};
|
56
56
|
type RegisterZoneAction = {
|
57
57
|
type: "registerZone";
|
@@ -234,7 +234,7 @@ type HistoryStore<D = any> = {
|
|
234
234
|
setHistoryIndex: (index: number) => void;
|
235
235
|
};
|
236
236
|
|
237
|
-
type OnAction = (action: PuckAction, appState: AppState
|
237
|
+
type OnAction<UserData extends Data = Data> = (action: PuckAction, appState: AppState<UserData>, prevAppState: AppState<UserData>) => void;
|
238
238
|
|
239
239
|
type PathData = Record<string, {
|
240
240
|
path: string[];
|
@@ -292,24 +292,24 @@ type IframeConfig = {
|
|
292
292
|
enabled?: boolean;
|
293
293
|
};
|
294
294
|
|
295
|
-
declare function Puck<UserConfig extends Config = Config>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, onAction, permissions, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe, dnd, initialHistory, }: {
|
295
|
+
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<UserProps, UserRootProps>>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, onAction, permissions, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe, dnd, initialHistory, }: {
|
296
296
|
children?: ReactNode;
|
297
297
|
config: UserConfig;
|
298
|
-
data: Partial<
|
298
|
+
data: Partial<UserData>;
|
299
299
|
ui?: Partial<UiState>;
|
300
|
-
onChange?: (data:
|
301
|
-
onPublish?: (data:
|
302
|
-
onAction?: OnAction
|
300
|
+
onChange?: (data: UserData) => void;
|
301
|
+
onPublish?: (data: UserData) => void;
|
302
|
+
onAction?: OnAction<UserData>;
|
303
303
|
permissions?: Partial<Permissions>;
|
304
304
|
plugins?: Plugin[];
|
305
305
|
overrides?: Partial<Overrides>;
|
306
306
|
renderHeader?: (props: {
|
307
307
|
children: ReactNode;
|
308
308
|
dispatch: (action: PuckAction) => void;
|
309
|
-
state: AppState
|
309
|
+
state: AppState<UserData>;
|
310
310
|
}) => ReactElement;
|
311
311
|
renderHeaderActions?: (props: {
|
312
|
-
state: AppState
|
312
|
+
state: AppState<UserData>;
|
313
313
|
dispatch: (action: PuckAction) => void;
|
314
314
|
}) => ReactElement;
|
315
315
|
headerTitle?: string;
|
@@ -333,14 +333,14 @@ declare namespace Puck {
|
|
333
333
|
}) => react_jsx_runtime.JSX.Element;
|
334
334
|
}
|
335
335
|
|
336
|
-
declare function Render<UserConfig extends Config = Config>({ config, data
|
336
|
+
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<UserProps, UserRootProps>>({ config, data }: {
|
337
337
|
config: UserConfig;
|
338
|
-
data: Partial<
|
338
|
+
data: Partial<UserData>;
|
339
339
|
}): react_jsx_runtime.JSX.Element;
|
340
340
|
|
341
341
|
declare function migrate(data: Data): Data;
|
342
342
|
|
343
|
-
type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends
|
343
|
+
type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
|
344
344
|
[ComponentName in keyof Props]: (props: Props[ComponentName] & {
|
345
345
|
[key: string]: any;
|
346
346
|
}) => Props[ComponentName];
|
@@ -349,13 +349,9 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
|
|
349
349
|
[key: string]: any;
|
350
350
|
}) => RootProps;
|
351
351
|
}>;
|
352
|
-
declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps =
|
352
|
+
declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
|
353
353
|
|
354
|
-
declare function resolveAllData(data: Partial<Data>, config: Config, onResolveStart?: (item:
|
355
|
-
root: RootData<DefaultRootProps> | RootDataWithProps;
|
356
|
-
content: any;
|
357
|
-
zones: Record<string, MappedItem[]>;
|
358
|
-
}>;
|
354
|
+
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>>;
|
359
355
|
|
360
356
|
declare const usePuck: () => {
|
361
357
|
appState: AppState;
|
@@ -383,9 +379,7 @@ declare const usePuck: () => {
|
|
383
379
|
index: number;
|
384
380
|
historyStore: HistoryStore | undefined;
|
385
381
|
};
|
386
|
-
selectedItem: ComponentData<
|
387
|
-
id: string;
|
388
|
-
}> | null;
|
382
|
+
selectedItem: ComponentData<any, string> | null;
|
389
383
|
};
|
390
384
|
|
391
|
-
export { Action, ActionBar, AppState, AutoField, AutoFieldPrivate, Button, ComponentData, Config, Data, DefaultComponentProps,
|
385
|
+
export { Action, ActionBar, AppState, AutoField, AutoFieldPrivate, Button, ComponentData, Config, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, DropZone, DropZoneProvider, ExtractPropsFromConfig, ExtractRootPropsFromConfig, Field, FieldLabel, FieldLabelInternal, FieldProps, type FieldPropsInternal, type History, IconButton, Permissions, type Plugin, Puck, type PuckAction, Render, UiState, dropZoneContext, migrate, resolveAllData, transformProps, usePuck };
|
package/dist/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
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,
|
2
|
-
export {
|
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, E as ExtractPropsFromConfig, c as ExtractRootPropsFromConfig, P as Permissions, V as Viewports, d as DefaultComponentProps, e as DefaultRootFieldProps, f as ComponentData } from './Config-RpUGTBxI.js';
|
2
|
+
export { v as Adaptor, u as ArrayField, q as ArrayState, B as BaseData, r as BaseField, l as ComponentConfig, m as ComponentDataMap, i as Content, y as CustomField, h as DefaultRootProps, g as DefaultRootRenderProps, x as ExternalField, w as ExternalFieldWithAdaptor, z as Fields, p as ItemWithId, M as MappedItem, N as NumberField, O as ObjectField, j as PuckComponent, k as PuckContext, t as RadioField, o as RootData, R as RootDataWithProps, n as RootDataWithoutProps, S as SelectField, T as TextField, s as TextareaField } from './Config-RpUGTBxI.js';
|
3
3
|
import * as react from 'react';
|
4
4
|
import { ReactNode, ReactElement, SyntheticEvent, CSSProperties } from 'react';
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
@@ -49,9 +49,9 @@ type SetDataAction = {
|
|
49
49
|
type: "setData";
|
50
50
|
data: Partial<Data> | ((previous: Data) => Partial<Data>);
|
51
51
|
};
|
52
|
-
type SetAction = {
|
52
|
+
type SetAction<UserData extends Data = Data> = {
|
53
53
|
type: "set";
|
54
|
-
state: Partial<AppState
|
54
|
+
state: Partial<AppState<UserData>> | ((previous: AppState<UserData>) => Partial<AppState<UserData>>);
|
55
55
|
};
|
56
56
|
type RegisterZoneAction = {
|
57
57
|
type: "registerZone";
|
@@ -234,7 +234,7 @@ type HistoryStore<D = any> = {
|
|
234
234
|
setHistoryIndex: (index: number) => void;
|
235
235
|
};
|
236
236
|
|
237
|
-
type OnAction = (action: PuckAction, appState: AppState
|
237
|
+
type OnAction<UserData extends Data = Data> = (action: PuckAction, appState: AppState<UserData>, prevAppState: AppState<UserData>) => void;
|
238
238
|
|
239
239
|
type PathData = Record<string, {
|
240
240
|
path: string[];
|
@@ -292,24 +292,24 @@ type IframeConfig = {
|
|
292
292
|
enabled?: boolean;
|
293
293
|
};
|
294
294
|
|
295
|
-
declare function Puck<UserConfig extends Config = Config>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, onAction, permissions, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe, dnd, initialHistory, }: {
|
295
|
+
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<UserProps, UserRootProps>>({ children, config, data: initialData, ui: initialUi, onChange, onPublish, onAction, permissions, plugins, overrides, renderHeader, renderHeaderActions, headerTitle, headerPath, viewports, iframe, dnd, initialHistory, }: {
|
296
296
|
children?: ReactNode;
|
297
297
|
config: UserConfig;
|
298
|
-
data: Partial<
|
298
|
+
data: Partial<UserData>;
|
299
299
|
ui?: Partial<UiState>;
|
300
|
-
onChange?: (data:
|
301
|
-
onPublish?: (data:
|
302
|
-
onAction?: OnAction
|
300
|
+
onChange?: (data: UserData) => void;
|
301
|
+
onPublish?: (data: UserData) => void;
|
302
|
+
onAction?: OnAction<UserData>;
|
303
303
|
permissions?: Partial<Permissions>;
|
304
304
|
plugins?: Plugin[];
|
305
305
|
overrides?: Partial<Overrides>;
|
306
306
|
renderHeader?: (props: {
|
307
307
|
children: ReactNode;
|
308
308
|
dispatch: (action: PuckAction) => void;
|
309
|
-
state: AppState
|
309
|
+
state: AppState<UserData>;
|
310
310
|
}) => ReactElement;
|
311
311
|
renderHeaderActions?: (props: {
|
312
|
-
state: AppState
|
312
|
+
state: AppState<UserData>;
|
313
313
|
dispatch: (action: PuckAction) => void;
|
314
314
|
}) => ReactElement;
|
315
315
|
headerTitle?: string;
|
@@ -333,14 +333,14 @@ declare namespace Puck {
|
|
333
333
|
}) => react_jsx_runtime.JSX.Element;
|
334
334
|
}
|
335
335
|
|
336
|
-
declare function Render<UserConfig extends Config = Config>({ config, data
|
336
|
+
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<UserProps, UserRootProps>>({ config, data }: {
|
337
337
|
config: UserConfig;
|
338
|
-
data: Partial<
|
338
|
+
data: Partial<UserData>;
|
339
339
|
}): react_jsx_runtime.JSX.Element;
|
340
340
|
|
341
341
|
declare function migrate(data: Data): Data;
|
342
342
|
|
343
|
-
type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends
|
343
|
+
type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps> = Partial<{
|
344
344
|
[ComponentName in keyof Props]: (props: Props[ComponentName] & {
|
345
345
|
[key: string]: any;
|
346
346
|
}) => Props[ComponentName];
|
@@ -349,13 +349,9 @@ type PropTransform<Props extends DefaultComponentProps = DefaultComponentProps,
|
|
349
349
|
[key: string]: any;
|
350
350
|
}) => RootProps;
|
351
351
|
}>;
|
352
|
-
declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps =
|
352
|
+
declare function transformProps<Props extends DefaultComponentProps = DefaultComponentProps, RootProps extends DefaultComponentProps = DefaultRootFieldProps>(data: Partial<Data>, propTransforms: PropTransform<Props, RootProps>): Data;
|
353
353
|
|
354
|
-
declare function resolveAllData(data: Partial<Data>, config: Config, onResolveStart?: (item:
|
355
|
-
root: RootData<DefaultRootProps> | RootDataWithProps;
|
356
|
-
content: any;
|
357
|
-
zones: Record<string, MappedItem[]>;
|
358
|
-
}>;
|
354
|
+
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>>;
|
359
355
|
|
360
356
|
declare const usePuck: () => {
|
361
357
|
appState: AppState;
|
@@ -383,9 +379,7 @@ declare const usePuck: () => {
|
|
383
379
|
index: number;
|
384
380
|
historyStore: HistoryStore | undefined;
|
385
381
|
};
|
386
|
-
selectedItem: ComponentData<
|
387
|
-
id: string;
|
388
|
-
}> | null;
|
382
|
+
selectedItem: ComponentData<any, string> | null;
|
389
383
|
};
|
390
384
|
|
391
|
-
export { Action, ActionBar, AppState, AutoField, AutoFieldPrivate, Button, ComponentData, Config, Data, DefaultComponentProps,
|
385
|
+
export { Action, ActionBar, AppState, AutoField, AutoFieldPrivate, Button, ComponentData, Config, Data, DefaultComponentProps, DefaultRootFieldProps, Drawer, DropZone, DropZoneProvider, ExtractPropsFromConfig, ExtractRootPropsFromConfig, Field, FieldLabel, FieldLabelInternal, FieldProps, type FieldPropsInternal, type History, IconButton, Permissions, type Plugin, Puck, type PuckAction, Render, UiState, dropZoneContext, migrate, resolveAllData, transformProps, usePuck };
|