@measured/puck 0.21.0-canary.a5160e5d → 0.21.0-canary.ace4c8b3
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-LAV6OYHN.mjs → chunk-AIFI2M23.mjs} +30 -257
- package/dist/{chunk-VBJEDLUM.mjs → chunk-TC25DCTQ.mjs} +8 -8
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +40 -267
- package/dist/index.mjs +2 -2
- package/dist/no-external.d.mts +1 -1
- package/dist/no-external.d.ts +1 -1
- package/dist/no-external.js +37 -264
- package/dist/no-external.mjs +2 -2
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +8 -8
- package/dist/rsc.mjs +1 -1
- package/dist/{walk-tree-DkTSFbz_.d.mts → walk-tree-CkSoNBF7.d.mts} +52 -43
- package/dist/{walk-tree-DkTSFbz_.d.ts → walk-tree-CkSoNBF7.d.ts} +52 -43
- package/package.json +1 -1
|
@@ -10,63 +10,63 @@ type FieldOption = {
|
|
|
10
10
|
value: string | number | boolean | undefined | null | object;
|
|
11
11
|
};
|
|
12
12
|
type FieldOptions = Array<FieldOption> | ReadonlyArray<FieldOption>;
|
|
13
|
-
|
|
13
|
+
interface BaseField {
|
|
14
14
|
label?: string;
|
|
15
15
|
labelIcon?: ReactElement;
|
|
16
|
-
metadata?:
|
|
16
|
+
metadata?: FieldMetadata;
|
|
17
17
|
visible?: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
18
|
+
}
|
|
19
|
+
interface TextField extends BaseField {
|
|
20
20
|
type: "text";
|
|
21
21
|
placeholder?: string;
|
|
22
22
|
contentEditable?: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
23
|
+
}
|
|
24
|
+
interface NumberField extends BaseField {
|
|
25
25
|
type: "number";
|
|
26
26
|
placeholder?: string;
|
|
27
27
|
min?: number;
|
|
28
28
|
max?: number;
|
|
29
29
|
step?: number;
|
|
30
|
-
}
|
|
31
|
-
|
|
30
|
+
}
|
|
31
|
+
interface TextareaField extends BaseField {
|
|
32
32
|
type: "textarea";
|
|
33
33
|
placeholder?: string;
|
|
34
34
|
contentEditable?: boolean;
|
|
35
|
-
}
|
|
36
|
-
|
|
35
|
+
}
|
|
36
|
+
interface SelectField extends BaseField {
|
|
37
37
|
type: "select";
|
|
38
38
|
options: FieldOptions;
|
|
39
|
-
}
|
|
40
|
-
|
|
39
|
+
}
|
|
40
|
+
interface RadioField extends BaseField {
|
|
41
41
|
type: "radio";
|
|
42
42
|
options: FieldOptions;
|
|
43
|
-
}
|
|
44
|
-
|
|
43
|
+
}
|
|
44
|
+
interface ArrayField<Props extends {
|
|
45
45
|
[key: string]: any;
|
|
46
46
|
}[] = {
|
|
47
47
|
[key: string]: any;
|
|
48
|
-
}[], UserField extends {} = {}>
|
|
48
|
+
}[], UserField extends {} = {}> extends BaseField {
|
|
49
49
|
type: "array";
|
|
50
50
|
arrayFields: {
|
|
51
51
|
[SubPropName in keyof Props[0]]: UserField extends {
|
|
52
52
|
type: PropertyKey;
|
|
53
53
|
} ? Field<Props[0][SubPropName], UserField> | UserField : Field<Props[0][SubPropName], UserField>;
|
|
54
54
|
};
|
|
55
|
-
defaultItemProps?: Props[0];
|
|
55
|
+
defaultItemProps?: Props[0] | ((index: number) => Props[0]);
|
|
56
56
|
getItemSummary?: (item: Props[0], index?: number) => string;
|
|
57
57
|
max?: number;
|
|
58
58
|
min?: number;
|
|
59
|
-
}
|
|
60
|
-
|
|
59
|
+
}
|
|
60
|
+
interface ObjectField<Props extends any = {
|
|
61
61
|
[key: string]: any;
|
|
62
|
-
}, UserField extends {} = {}>
|
|
62
|
+
}, UserField extends {} = {}> extends BaseField {
|
|
63
63
|
type: "object";
|
|
64
64
|
objectFields: {
|
|
65
65
|
[SubPropName in keyof Props]: UserField extends {
|
|
66
66
|
type: PropertyKey;
|
|
67
67
|
} ? Field<Props[SubPropName]> | UserField : Field<Props[SubPropName]>;
|
|
68
68
|
};
|
|
69
|
-
}
|
|
69
|
+
}
|
|
70
70
|
type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, PropShape = TableShape> = {
|
|
71
71
|
name: string;
|
|
72
72
|
fetchList: (adaptorParams?: AdaptorParams) => Promise<TableShape[] | null>;
|
|
@@ -85,9 +85,9 @@ type ExternalFieldWithAdaptor<Props extends any = {
|
|
|
85
85
|
type CacheOpts = {
|
|
86
86
|
enabled?: boolean;
|
|
87
87
|
};
|
|
88
|
-
|
|
88
|
+
interface ExternalField<Props extends any = {
|
|
89
89
|
[key: string]: any;
|
|
90
|
-
}>
|
|
90
|
+
}> extends BaseField {
|
|
91
91
|
type: "external";
|
|
92
92
|
cache?: CacheOpts;
|
|
93
93
|
placeholder?: string;
|
|
@@ -105,7 +105,7 @@ type ExternalField<Props extends any = {
|
|
|
105
105
|
initialQuery?: string;
|
|
106
106
|
filterFields?: Record<string, Field>;
|
|
107
107
|
initialFilters?: Record<string, any>;
|
|
108
|
-
}
|
|
108
|
+
}
|
|
109
109
|
type CustomFieldRender<Value extends any> = (props: {
|
|
110
110
|
field: CustomField<Value>;
|
|
111
111
|
name: string;
|
|
@@ -114,16 +114,17 @@ type CustomFieldRender<Value extends any> = (props: {
|
|
|
114
114
|
onChange: (value: Value) => void;
|
|
115
115
|
readOnly?: boolean;
|
|
116
116
|
}) => ReactElement;
|
|
117
|
-
|
|
117
|
+
interface CustomField<Value extends any> extends BaseField {
|
|
118
118
|
type: "custom";
|
|
119
119
|
render: CustomFieldRender<Value>;
|
|
120
120
|
contentEditable?: boolean;
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
key?: string;
|
|
122
|
+
}
|
|
123
|
+
interface SlotField extends BaseField {
|
|
123
124
|
type: "slot";
|
|
124
125
|
allow?: string[];
|
|
125
126
|
disallow?: string[];
|
|
126
|
-
}
|
|
127
|
+
}
|
|
127
128
|
type Field<ValueType = any, UserField extends {} = {}> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType extends {
|
|
128
129
|
[key: string]: any;
|
|
129
130
|
}[] ? ValueType : never, UserField> | ObjectField<ValueType, UserField> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
|
|
@@ -151,7 +152,7 @@ type DropZoneProps = {
|
|
|
151
152
|
};
|
|
152
153
|
|
|
153
154
|
type PuckContext = {
|
|
154
|
-
renderDropZone: React.
|
|
155
|
+
renderDropZone: (props: DropZoneProps) => React.ReactNode;
|
|
155
156
|
metadata: Metadata;
|
|
156
157
|
isEditing: boolean;
|
|
157
158
|
dragRef: ((element: Element | null) => void) | null;
|
|
@@ -201,6 +202,8 @@ type ResolveDataTrigger = "insert" | "replace" | "load" | "force";
|
|
|
201
202
|
type WithPartialProps<T, Props extends DefaultComponentProps> = Omit<T, "props"> & {
|
|
202
203
|
props?: Partial<Props>;
|
|
203
204
|
};
|
|
205
|
+
interface ComponentConfigExtensions {
|
|
206
|
+
}
|
|
204
207
|
type ComponentConfigInternal<RenderProps extends DefaultComponentProps, FieldProps extends DefaultComponentProps, DataShape = Omit<ComponentData<FieldProps>, "type">, // NB this doesn't include AllProps, so types will not contain deep slot types. To fix, we require a breaking change.
|
|
205
208
|
UserField extends BaseField = {}> = {
|
|
206
209
|
render: PuckComponent<RenderProps>;
|
|
@@ -216,7 +219,7 @@ UserField extends BaseField = {}> = {
|
|
|
216
219
|
fields: Fields<FieldProps>;
|
|
217
220
|
lastFields: Fields<FieldProps>;
|
|
218
221
|
lastData: DataShape | null;
|
|
219
|
-
metadata:
|
|
222
|
+
metadata: ComponentMetadata;
|
|
220
223
|
appState: AppState;
|
|
221
224
|
parent: ComponentData | null;
|
|
222
225
|
}) => Promise<Fields<FieldProps>> | Fields<FieldProps>;
|
|
@@ -225,7 +228,7 @@ UserField extends BaseField = {}> = {
|
|
|
225
228
|
id: string;
|
|
226
229
|
}>;
|
|
227
230
|
lastData: DataShape | null;
|
|
228
|
-
metadata:
|
|
231
|
+
metadata: ComponentMetadata;
|
|
229
232
|
trigger: ResolveDataTrigger;
|
|
230
233
|
}) => Promise<WithPartialProps<DataShape, FieldProps>> | WithPartialProps<DataShape, FieldProps>;
|
|
231
234
|
resolvePermissions?: (data: DataShape, params: {
|
|
@@ -237,8 +240,8 @@ UserField extends BaseField = {}> = {
|
|
|
237
240
|
appState: AppState;
|
|
238
241
|
lastData: DataShape | null;
|
|
239
242
|
}) => Promise<Partial<Permissions>> | Partial<Permissions>;
|
|
240
|
-
metadata?:
|
|
241
|
-
};
|
|
243
|
+
metadata?: ComponentMetadata;
|
|
244
|
+
} & ComponentConfigExtensions;
|
|
242
245
|
type ComponentConfig<RenderPropsOrParams extends LeftOrExactRight<RenderPropsOrParams, DefaultComponentProps, ComponentConfigParams> = DefaultComponentProps, FieldProps extends DefaultComponentProps = RenderPropsOrParams extends {
|
|
243
246
|
props: any;
|
|
244
247
|
} ? RenderPropsOrParams["props"] : RenderPropsOrParams, DataShape = Omit<ComponentData<FieldProps>, "type">> = RenderPropsOrParams extends ComponentConfigParams<infer ParamsRenderProps, never> ? ComponentConfigInternal<ParamsRenderProps, FieldProps, DataShape, {}> : RenderPropsOrParams extends ComponentConfigParams<infer ParamsRenderProps, infer ParamsFields> ? ComponentConfigInternal<ParamsRenderProps, FieldProps, DataShape, ParamsFields[keyof ParamsFields] & BaseField> : ComponentConfigInternal<RenderPropsOrParams, FieldProps, DataShape>;
|
|
@@ -269,6 +272,16 @@ type ExtractConfigParams<UserConfig extends ConfigInternal> = UserConfig extends
|
|
|
269
272
|
type: string;
|
|
270
273
|
} ? UserField : Field;
|
|
271
274
|
} : never;
|
|
275
|
+
type ConfigParams<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = any, CategoryNames extends string[] = string[], UserFields extends FieldsExtension = FieldsExtension> = {
|
|
276
|
+
components?: Components;
|
|
277
|
+
root?: RootProps;
|
|
278
|
+
categories?: CategoryNames;
|
|
279
|
+
fields?: AssertHasValue<UserFields>;
|
|
280
|
+
};
|
|
281
|
+
type ComponentConfigParams<Props extends DefaultComponentProps = DefaultComponentProps, UserFields extends FieldsExtension = never> = {
|
|
282
|
+
props: Props;
|
|
283
|
+
fields?: AssertHasValue<UserFields>;
|
|
284
|
+
};
|
|
272
285
|
|
|
273
286
|
type BaseData<Props extends {
|
|
274
287
|
[key: string]: any;
|
|
@@ -309,6 +322,12 @@ type Data<Components extends DefaultComponents = DefaultComponents, RootProps ex
|
|
|
309
322
|
type Metadata = {
|
|
310
323
|
[key: string]: any;
|
|
311
324
|
};
|
|
325
|
+
interface PuckMetadata extends Metadata {
|
|
326
|
+
}
|
|
327
|
+
interface ComponentMetadata extends PuckMetadata {
|
|
328
|
+
}
|
|
329
|
+
interface FieldMetadata extends Metadata {
|
|
330
|
+
}
|
|
312
331
|
|
|
313
332
|
type ItemWithId = {
|
|
314
333
|
_arrayId: string;
|
|
@@ -377,21 +396,11 @@ type BuiltinTypes = Date | RegExp | Error | Function | symbol | null | undefined
|
|
|
377
396
|
type WithDeepSlots<T, SlotType = T> = T extends Slot ? SlotType : T extends (infer U)[] ? Array<WithDeepSlots<U, SlotType>> : T extends (infer U)[] ? WithDeepSlots<U, SlotType>[] : T extends BuiltinTypes ? T : T extends object ? {
|
|
378
397
|
[K in keyof T]: WithDeepSlots<T[K], SlotType>;
|
|
379
398
|
} : T;
|
|
380
|
-
type ConfigParams<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = any, CategoryNames extends string[] = string[], UserFields extends FieldsExtension = FieldsExtension> = {
|
|
381
|
-
components?: Components;
|
|
382
|
-
root?: RootProps;
|
|
383
|
-
categories?: CategoryNames;
|
|
384
|
-
fields?: AssertHasValue<UserFields>;
|
|
385
|
-
};
|
|
386
399
|
type FieldsExtension = {
|
|
387
400
|
[Type in string]: {
|
|
388
401
|
type: Type;
|
|
389
402
|
};
|
|
390
403
|
};
|
|
391
|
-
type ComponentConfigParams<Props extends DefaultComponentProps = DefaultComponentProps, UserFields extends FieldsExtension = never> = {
|
|
392
|
-
props: Props;
|
|
393
|
-
fields?: AssertHasValue<UserFields>;
|
|
394
|
-
};
|
|
395
404
|
type Exact<T, Target> = Record<Exclude<keyof T, keyof Target>, never>;
|
|
396
405
|
type LeftOrExactRight<Union, Left, Right> = (Left & Union extends Right ? Exact<Union, Right> : Left) | (Right & Exact<Union, Right>);
|
|
397
406
|
type AssertHasValue<T, True = T, False = never> = [keyof T] extends [
|
|
@@ -635,4 +644,4 @@ type WalkTreeOptions = {
|
|
|
635
644
|
};
|
|
636
645
|
declare function walkTree<T extends ComponentData | RootData | G["UserData"], UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(data: T, config: UserConfig, callbackFn: (data: Content, options: WalkTreeOptions) => Content | null | void): T;
|
|
637
646
|
|
|
638
|
-
export { type
|
|
647
|
+
export { type MappedItem as $, type AppState as A, type ArrayState as B, type Config as C, type DropZoneProps as D, type SlotComponent as E, type Fields as F, type PuckComponent as G, type History as H, type IframeConfig as I, type ComponentConfigExtensions as J, type RootConfig as K, type DefaultComponents as L, type Metadata as M, type ExtractConfigParams as N, type Overrides as O, type Permissions as P, type ConfigParams as Q, type RootDataWithProps as R, type Slot as S, type ComponentConfigParams as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type BaseData as X, type RootDataWithoutProps as Y, type RootData as Z, type ComponentDataOptionalId as _, type ComponentData as a, type ComponentDataMap as a0, type Content as a1, type PuckMetadata as a2, type ComponentMetadata as a3, type FieldMetadata as a4, type BaseField as a5, type TextField as a6, type NumberField as a7, type TextareaField as a8, type SelectField as a9, type RadioField as aa, type ArrayField as ab, type ObjectField as ac, type Adaptor as ad, type ExternalFieldWithAdaptor as ae, type CacheOpts as af, type ExternalField as ag, type CustomFieldRender as ah, type CustomField as ai, type SlotField as aj, type PuckContext as ak, type DefaultRootFieldProps as al, type DefaultRootRenderProps as am, type DefaultRootProps as an, type DefaultComponentProps as ao, type WithId as ap, type WithPuckProps as aq, type AsFieldProps as ar, type WithChildren as as, type ExtractField as at, type PuckAction as b, type ResolveDataTrigger as c, type Plugin as d, type UiState as e, type ComponentConfig as f, type FieldTransforms as g, type Field as h, type FieldProps as i, type Data as j, type OnAction as k, type InitialHistory as l, migrate as m, type ItemSelector as n, type Direction as o, type DragAxis as p, type Viewport as q, resolveAllData as r, type FieldTransformFnParams as s, transformProps as t, type FieldTransformFn as u, overrideKeys as v, walkTree as w, type OverrideKey as x, type FieldRenderFunctions as y, type ItemWithId as z };
|
|
@@ -10,63 +10,63 @@ type FieldOption = {
|
|
|
10
10
|
value: string | number | boolean | undefined | null | object;
|
|
11
11
|
};
|
|
12
12
|
type FieldOptions = Array<FieldOption> | ReadonlyArray<FieldOption>;
|
|
13
|
-
|
|
13
|
+
interface BaseField {
|
|
14
14
|
label?: string;
|
|
15
15
|
labelIcon?: ReactElement;
|
|
16
|
-
metadata?:
|
|
16
|
+
metadata?: FieldMetadata;
|
|
17
17
|
visible?: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
18
|
+
}
|
|
19
|
+
interface TextField extends BaseField {
|
|
20
20
|
type: "text";
|
|
21
21
|
placeholder?: string;
|
|
22
22
|
contentEditable?: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
23
|
+
}
|
|
24
|
+
interface NumberField extends BaseField {
|
|
25
25
|
type: "number";
|
|
26
26
|
placeholder?: string;
|
|
27
27
|
min?: number;
|
|
28
28
|
max?: number;
|
|
29
29
|
step?: number;
|
|
30
|
-
}
|
|
31
|
-
|
|
30
|
+
}
|
|
31
|
+
interface TextareaField extends BaseField {
|
|
32
32
|
type: "textarea";
|
|
33
33
|
placeholder?: string;
|
|
34
34
|
contentEditable?: boolean;
|
|
35
|
-
}
|
|
36
|
-
|
|
35
|
+
}
|
|
36
|
+
interface SelectField extends BaseField {
|
|
37
37
|
type: "select";
|
|
38
38
|
options: FieldOptions;
|
|
39
|
-
}
|
|
40
|
-
|
|
39
|
+
}
|
|
40
|
+
interface RadioField extends BaseField {
|
|
41
41
|
type: "radio";
|
|
42
42
|
options: FieldOptions;
|
|
43
|
-
}
|
|
44
|
-
|
|
43
|
+
}
|
|
44
|
+
interface ArrayField<Props extends {
|
|
45
45
|
[key: string]: any;
|
|
46
46
|
}[] = {
|
|
47
47
|
[key: string]: any;
|
|
48
|
-
}[], UserField extends {} = {}>
|
|
48
|
+
}[], UserField extends {} = {}> extends BaseField {
|
|
49
49
|
type: "array";
|
|
50
50
|
arrayFields: {
|
|
51
51
|
[SubPropName in keyof Props[0]]: UserField extends {
|
|
52
52
|
type: PropertyKey;
|
|
53
53
|
} ? Field<Props[0][SubPropName], UserField> | UserField : Field<Props[0][SubPropName], UserField>;
|
|
54
54
|
};
|
|
55
|
-
defaultItemProps?: Props[0];
|
|
55
|
+
defaultItemProps?: Props[0] | ((index: number) => Props[0]);
|
|
56
56
|
getItemSummary?: (item: Props[0], index?: number) => string;
|
|
57
57
|
max?: number;
|
|
58
58
|
min?: number;
|
|
59
|
-
}
|
|
60
|
-
|
|
59
|
+
}
|
|
60
|
+
interface ObjectField<Props extends any = {
|
|
61
61
|
[key: string]: any;
|
|
62
|
-
}, UserField extends {} = {}>
|
|
62
|
+
}, UserField extends {} = {}> extends BaseField {
|
|
63
63
|
type: "object";
|
|
64
64
|
objectFields: {
|
|
65
65
|
[SubPropName in keyof Props]: UserField extends {
|
|
66
66
|
type: PropertyKey;
|
|
67
67
|
} ? Field<Props[SubPropName]> | UserField : Field<Props[SubPropName]>;
|
|
68
68
|
};
|
|
69
|
-
}
|
|
69
|
+
}
|
|
70
70
|
type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, PropShape = TableShape> = {
|
|
71
71
|
name: string;
|
|
72
72
|
fetchList: (adaptorParams?: AdaptorParams) => Promise<TableShape[] | null>;
|
|
@@ -85,9 +85,9 @@ type ExternalFieldWithAdaptor<Props extends any = {
|
|
|
85
85
|
type CacheOpts = {
|
|
86
86
|
enabled?: boolean;
|
|
87
87
|
};
|
|
88
|
-
|
|
88
|
+
interface ExternalField<Props extends any = {
|
|
89
89
|
[key: string]: any;
|
|
90
|
-
}>
|
|
90
|
+
}> extends BaseField {
|
|
91
91
|
type: "external";
|
|
92
92
|
cache?: CacheOpts;
|
|
93
93
|
placeholder?: string;
|
|
@@ -105,7 +105,7 @@ type ExternalField<Props extends any = {
|
|
|
105
105
|
initialQuery?: string;
|
|
106
106
|
filterFields?: Record<string, Field>;
|
|
107
107
|
initialFilters?: Record<string, any>;
|
|
108
|
-
}
|
|
108
|
+
}
|
|
109
109
|
type CustomFieldRender<Value extends any> = (props: {
|
|
110
110
|
field: CustomField<Value>;
|
|
111
111
|
name: string;
|
|
@@ -114,16 +114,17 @@ type CustomFieldRender<Value extends any> = (props: {
|
|
|
114
114
|
onChange: (value: Value) => void;
|
|
115
115
|
readOnly?: boolean;
|
|
116
116
|
}) => ReactElement;
|
|
117
|
-
|
|
117
|
+
interface CustomField<Value extends any> extends BaseField {
|
|
118
118
|
type: "custom";
|
|
119
119
|
render: CustomFieldRender<Value>;
|
|
120
120
|
contentEditable?: boolean;
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
key?: string;
|
|
122
|
+
}
|
|
123
|
+
interface SlotField extends BaseField {
|
|
123
124
|
type: "slot";
|
|
124
125
|
allow?: string[];
|
|
125
126
|
disallow?: string[];
|
|
126
|
-
}
|
|
127
|
+
}
|
|
127
128
|
type Field<ValueType = any, UserField extends {} = {}> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType extends {
|
|
128
129
|
[key: string]: any;
|
|
129
130
|
}[] ? ValueType : never, UserField> | ObjectField<ValueType, UserField> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
|
|
@@ -151,7 +152,7 @@ type DropZoneProps = {
|
|
|
151
152
|
};
|
|
152
153
|
|
|
153
154
|
type PuckContext = {
|
|
154
|
-
renderDropZone: React.
|
|
155
|
+
renderDropZone: (props: DropZoneProps) => React.ReactNode;
|
|
155
156
|
metadata: Metadata;
|
|
156
157
|
isEditing: boolean;
|
|
157
158
|
dragRef: ((element: Element | null) => void) | null;
|
|
@@ -201,6 +202,8 @@ type ResolveDataTrigger = "insert" | "replace" | "load" | "force";
|
|
|
201
202
|
type WithPartialProps<T, Props extends DefaultComponentProps> = Omit<T, "props"> & {
|
|
202
203
|
props?: Partial<Props>;
|
|
203
204
|
};
|
|
205
|
+
interface ComponentConfigExtensions {
|
|
206
|
+
}
|
|
204
207
|
type ComponentConfigInternal<RenderProps extends DefaultComponentProps, FieldProps extends DefaultComponentProps, DataShape = Omit<ComponentData<FieldProps>, "type">, // NB this doesn't include AllProps, so types will not contain deep slot types. To fix, we require a breaking change.
|
|
205
208
|
UserField extends BaseField = {}> = {
|
|
206
209
|
render: PuckComponent<RenderProps>;
|
|
@@ -216,7 +219,7 @@ UserField extends BaseField = {}> = {
|
|
|
216
219
|
fields: Fields<FieldProps>;
|
|
217
220
|
lastFields: Fields<FieldProps>;
|
|
218
221
|
lastData: DataShape | null;
|
|
219
|
-
metadata:
|
|
222
|
+
metadata: ComponentMetadata;
|
|
220
223
|
appState: AppState;
|
|
221
224
|
parent: ComponentData | null;
|
|
222
225
|
}) => Promise<Fields<FieldProps>> | Fields<FieldProps>;
|
|
@@ -225,7 +228,7 @@ UserField extends BaseField = {}> = {
|
|
|
225
228
|
id: string;
|
|
226
229
|
}>;
|
|
227
230
|
lastData: DataShape | null;
|
|
228
|
-
metadata:
|
|
231
|
+
metadata: ComponentMetadata;
|
|
229
232
|
trigger: ResolveDataTrigger;
|
|
230
233
|
}) => Promise<WithPartialProps<DataShape, FieldProps>> | WithPartialProps<DataShape, FieldProps>;
|
|
231
234
|
resolvePermissions?: (data: DataShape, params: {
|
|
@@ -237,8 +240,8 @@ UserField extends BaseField = {}> = {
|
|
|
237
240
|
appState: AppState;
|
|
238
241
|
lastData: DataShape | null;
|
|
239
242
|
}) => Promise<Partial<Permissions>> | Partial<Permissions>;
|
|
240
|
-
metadata?:
|
|
241
|
-
};
|
|
243
|
+
metadata?: ComponentMetadata;
|
|
244
|
+
} & ComponentConfigExtensions;
|
|
242
245
|
type ComponentConfig<RenderPropsOrParams extends LeftOrExactRight<RenderPropsOrParams, DefaultComponentProps, ComponentConfigParams> = DefaultComponentProps, FieldProps extends DefaultComponentProps = RenderPropsOrParams extends {
|
|
243
246
|
props: any;
|
|
244
247
|
} ? RenderPropsOrParams["props"] : RenderPropsOrParams, DataShape = Omit<ComponentData<FieldProps>, "type">> = RenderPropsOrParams extends ComponentConfigParams<infer ParamsRenderProps, never> ? ComponentConfigInternal<ParamsRenderProps, FieldProps, DataShape, {}> : RenderPropsOrParams extends ComponentConfigParams<infer ParamsRenderProps, infer ParamsFields> ? ComponentConfigInternal<ParamsRenderProps, FieldProps, DataShape, ParamsFields[keyof ParamsFields] & BaseField> : ComponentConfigInternal<RenderPropsOrParams, FieldProps, DataShape>;
|
|
@@ -269,6 +272,16 @@ type ExtractConfigParams<UserConfig extends ConfigInternal> = UserConfig extends
|
|
|
269
272
|
type: string;
|
|
270
273
|
} ? UserField : Field;
|
|
271
274
|
} : never;
|
|
275
|
+
type ConfigParams<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = any, CategoryNames extends string[] = string[], UserFields extends FieldsExtension = FieldsExtension> = {
|
|
276
|
+
components?: Components;
|
|
277
|
+
root?: RootProps;
|
|
278
|
+
categories?: CategoryNames;
|
|
279
|
+
fields?: AssertHasValue<UserFields>;
|
|
280
|
+
};
|
|
281
|
+
type ComponentConfigParams<Props extends DefaultComponentProps = DefaultComponentProps, UserFields extends FieldsExtension = never> = {
|
|
282
|
+
props: Props;
|
|
283
|
+
fields?: AssertHasValue<UserFields>;
|
|
284
|
+
};
|
|
272
285
|
|
|
273
286
|
type BaseData<Props extends {
|
|
274
287
|
[key: string]: any;
|
|
@@ -309,6 +322,12 @@ type Data<Components extends DefaultComponents = DefaultComponents, RootProps ex
|
|
|
309
322
|
type Metadata = {
|
|
310
323
|
[key: string]: any;
|
|
311
324
|
};
|
|
325
|
+
interface PuckMetadata extends Metadata {
|
|
326
|
+
}
|
|
327
|
+
interface ComponentMetadata extends PuckMetadata {
|
|
328
|
+
}
|
|
329
|
+
interface FieldMetadata extends Metadata {
|
|
330
|
+
}
|
|
312
331
|
|
|
313
332
|
type ItemWithId = {
|
|
314
333
|
_arrayId: string;
|
|
@@ -377,21 +396,11 @@ type BuiltinTypes = Date | RegExp | Error | Function | symbol | null | undefined
|
|
|
377
396
|
type WithDeepSlots<T, SlotType = T> = T extends Slot ? SlotType : T extends (infer U)[] ? Array<WithDeepSlots<U, SlotType>> : T extends (infer U)[] ? WithDeepSlots<U, SlotType>[] : T extends BuiltinTypes ? T : T extends object ? {
|
|
378
397
|
[K in keyof T]: WithDeepSlots<T[K], SlotType>;
|
|
379
398
|
} : T;
|
|
380
|
-
type ConfigParams<Components extends DefaultComponents = DefaultComponents, RootProps extends DefaultComponentProps = any, CategoryNames extends string[] = string[], UserFields extends FieldsExtension = FieldsExtension> = {
|
|
381
|
-
components?: Components;
|
|
382
|
-
root?: RootProps;
|
|
383
|
-
categories?: CategoryNames;
|
|
384
|
-
fields?: AssertHasValue<UserFields>;
|
|
385
|
-
};
|
|
386
399
|
type FieldsExtension = {
|
|
387
400
|
[Type in string]: {
|
|
388
401
|
type: Type;
|
|
389
402
|
};
|
|
390
403
|
};
|
|
391
|
-
type ComponentConfigParams<Props extends DefaultComponentProps = DefaultComponentProps, UserFields extends FieldsExtension = never> = {
|
|
392
|
-
props: Props;
|
|
393
|
-
fields?: AssertHasValue<UserFields>;
|
|
394
|
-
};
|
|
395
404
|
type Exact<T, Target> = Record<Exclude<keyof T, keyof Target>, never>;
|
|
396
405
|
type LeftOrExactRight<Union, Left, Right> = (Left & Union extends Right ? Exact<Union, Right> : Left) | (Right & Exact<Union, Right>);
|
|
397
406
|
type AssertHasValue<T, True = T, False = never> = [keyof T] extends [
|
|
@@ -635,4 +644,4 @@ type WalkTreeOptions = {
|
|
|
635
644
|
};
|
|
636
645
|
declare function walkTree<T extends ComponentData | RootData | G["UserData"], UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(data: T, config: UserConfig, callbackFn: (data: Content, options: WalkTreeOptions) => Content | null | void): T;
|
|
637
646
|
|
|
638
|
-
export { type
|
|
647
|
+
export { type MappedItem as $, type AppState as A, type ArrayState as B, type Config as C, type DropZoneProps as D, type SlotComponent as E, type Fields as F, type PuckComponent as G, type History as H, type IframeConfig as I, type ComponentConfigExtensions as J, type RootConfig as K, type DefaultComponents as L, type Metadata as M, type ExtractConfigParams as N, type Overrides as O, type Permissions as P, type ConfigParams as Q, type RootDataWithProps as R, type Slot as S, type ComponentConfigParams as T, type UserGenerics as U, type Viewports as V, type WithSlotProps as W, type BaseData as X, type RootDataWithoutProps as Y, type RootData as Z, type ComponentDataOptionalId as _, type ComponentData as a, type ComponentDataMap as a0, type Content as a1, type PuckMetadata as a2, type ComponentMetadata as a3, type FieldMetadata as a4, type BaseField as a5, type TextField as a6, type NumberField as a7, type TextareaField as a8, type SelectField as a9, type RadioField as aa, type ArrayField as ab, type ObjectField as ac, type Adaptor as ad, type ExternalFieldWithAdaptor as ae, type CacheOpts as af, type ExternalField as ag, type CustomFieldRender as ah, type CustomField as ai, type SlotField as aj, type PuckContext as ak, type DefaultRootFieldProps as al, type DefaultRootRenderProps as am, type DefaultRootProps as an, type DefaultComponentProps as ao, type WithId as ap, type WithPuckProps as aq, type AsFieldProps as ar, type WithChildren as as, type ExtractField as at, type PuckAction as b, type ResolveDataTrigger as c, type Plugin as d, type UiState as e, type ComponentConfig as f, type FieldTransforms as g, type Field as h, type FieldProps as i, type Data as j, type OnAction as k, type InitialHistory as l, migrate as m, type ItemSelector as n, type Direction as o, type DragAxis as p, type Viewport as q, resolveAllData as r, type FieldTransformFnParams as s, transformProps as t, type FieldTransformFn as u, overrideKeys as v, walkTree as w, type OverrideKey as x, type FieldRenderFunctions as y, type ItemWithId as z };
|
package/package.json
CHANGED